You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/03/06 16:02:00 UTC
[GitHub] sterlinghughes closed pull request #126: don't merge: code cleanup support
sterlinghughes closed pull request #126: don't merge: code cleanup support
URL: https://github.com/apache/mynewt-newt/pull/126
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/Gopkg.lock b/Gopkg.lock
new file mode 100644
index 00000000..5d58f391
--- /dev/null
+++ b/Gopkg.lock
@@ -0,0 +1,165 @@
+# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
+
+
+[[projects]]
+ name = "github.com/Sirupsen/logrus"
+ packages = ["."]
+ revision = "f006c2ac4710855cf0f916dd6b77acf6b048dc6e"
+ version = "v1.0.3"
+
+[[projects]]
+ branch = "master"
+ name = "github.com/armon/consul-api"
+ packages = ["."]
+ revision = "dcfedd50ed5334f96adee43fc88518a4f095e15c"
+
+[[projects]]
+ name = "github.com/coreos/etcd"
+ packages = ["client","pkg/pathutil","pkg/srv","pkg/types","version"]
+ revision = "d0d1a87aa96ae14914751d42264262cb69eda170"
+ version = "v3.2.5"
+
+[[projects]]
+ name = "github.com/coreos/go-semver"
+ packages = ["semver"]
+ revision = "8ab6407b697782a06568d4b7f1db25550ec2e4c6"
+ version = "v0.2.0"
+
+[[projects]]
+ name = "github.com/davecgh/go-spew"
+ packages = ["spew"]
+ revision = "346938d642f2ec3594ed81d874461961cd0faa76"
+ version = "v1.1.0"
+
+[[projects]]
+ branch = "master"
+ name = "github.com/dustin/go-coap"
+ packages = ["."]
+ revision = "ddcc80675fa42611359d91a6dfa5aa57fb90e72b"
+
+[[projects]]
+ name = "github.com/inconshreveable/mousetrap"
+ packages = ["."]
+ revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75"
+ version = "v1.0"
+
+[[projects]]
+ branch = "master"
+ name = "github.com/joaojeronimo/go-crc16"
+ packages = ["."]
+ revision = "59bd0194935ecff6f47039ee12efd09ff894a14a"
+
+[[projects]]
+ branch = "master"
+ name = "github.com/kr/pretty"
+ packages = ["."]
+ revision = "cfb55aafdaf3ec08f0db22699ab822c50091b1c4"
+
+[[projects]]
+ branch = "master"
+ name = "github.com/kr/text"
+ packages = ["."]
+ revision = "7cafcd837844e784b526369c9bce262804aebc60"
+
+[[projects]]
+ branch = "master"
+ name = "github.com/mitchellh/go-homedir"
+ packages = ["."]
+ revision = "b8bc1bf767474819792c23f32d8286a45736f1c6"
+
+[[projects]]
+ branch = "master"
+ name = "github.com/mitchellh/mapstructure"
+ packages = ["."]
+ revision = "d0303fe809921458f417bcf828397a65db30a7e4"
+
+[[projects]]
+ name = "github.com/pmezard/go-difflib"
+ packages = ["difflib"]
+ revision = "792786c7400a136282c1664665ae0a8db921c6c2"
+ version = "v1.0.0"
+
+[[projects]]
+ branch = "master"
+ name = "github.com/runtimeco/gatt"
+ packages = [".","linux","linux/cmd","linux/evt","linux/gioctl","linux/socket","linux/util","xpc"]
+ revision = "ceaca1e3d4b698ce4f610b8c71ebc5cde9ad40dd"
+
+[[projects]]
+ name = "github.com/spf13/cast"
+ packages = ["."]
+ revision = "acbeb36b902d72a7a4c18e8f3241075e7ab763e4"
+ version = "v1.1.0"
+
+[[projects]]
+ branch = "master"
+ name = "github.com/spf13/cobra"
+ packages = ["."]
+ revision = "4a7b7e65864c064d48dce82efbbfed2bdc0bf2aa"
+
+[[projects]]
+ branch = "master"
+ name = "github.com/spf13/jwalterweatherman"
+ packages = ["."]
+ revision = "0efa5202c04663c757d84f90f5219c1250baf94f"
+
+[[projects]]
+ name = "github.com/spf13/pflag"
+ packages = ["."]
+ revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66"
+ version = "v1.0.0"
+
+[[projects]]
+ name = "github.com/stretchr/testify"
+ packages = ["assert"]
+ revision = "69483b4bd14f5845b5a1e55bca19e954e827f1d0"
+ version = "v1.1.4"
+
+[[projects]]
+ branch = "master"
+ name = "github.com/tarm/serial"
+ packages = ["."]
+ revision = "e50d7d20b1f68657808356d33b4404890487ceee"
+
+[[projects]]
+ branch = "master"
+ name = "github.com/ugorji/go"
+ packages = ["codec"]
+ revision = "5efa3251c7f7d05e5d9704a69a984ec9f1386a40"
+
+[[projects]]
+ branch = "master"
+ name = "github.com/xordataexchange/crypt"
+ packages = ["backend","backend/consul","backend/etcd","config","encoding/secconf"]
+ revision = "b2862e3d0a775f18c7cfe02273500ae307b61218"
+
+[[projects]]
+ branch = "master"
+ name = "golang.org/x/crypto"
+ packages = ["cast5","openpgp","openpgp/armor","openpgp/elgamal","openpgp/errors","openpgp/packet","openpgp/s2k","pbkdf2","ssh/terminal"]
+ revision = "eb71ad9bd329b5ac0fd0148dd99bd62e8be8e035"
+
+[[projects]]
+ branch = "master"
+ name = "golang.org/x/net"
+ packages = ["context"]
+ revision = "1c05540f6879653db88113bc4a2b70aec4bd491f"
+
+[[projects]]
+ branch = "master"
+ name = "golang.org/x/sys"
+ packages = ["unix","windows"]
+ revision = "43e60d72a8e2bd92ee98319ba9a384a0e9837c08"
+
+[[projects]]
+ name = "gopkg.in/fsnotify.v1"
+ packages = ["."]
+ revision = "629574ca2a5df945712d3079857300b5e4da0236"
+ version = "v1.4.2"
+
+[solve-meta]
+ analyzer-name = "dep"
+ analyzer-version = 1
+ inputs-digest = "517322e007714705a5f65b2d4cff247d1f838f8ca953cafe4a4d47257c0c2b64"
+ solver-name = "gps-cdcl"
+ solver-version = 1
diff --git a/Gopkg.toml b/Gopkg.toml
new file mode 100644
index 00000000..961246da
--- /dev/null
+++ b/Gopkg.toml
@@ -0,0 +1,86 @@
+
+# Gopkg.toml example
+#
+# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
+# for detailed Gopkg.toml documentation.
+#
+# required = ["github.com/user/thing/cmd/thing"]
+# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
+#
+# [[constraint]]
+# name = "github.com/user/project"
+# version = "1.0.0"
+#
+# [[constraint]]
+# name = "github.com/user/project2"
+# branch = "dev"
+# source = "github.com/myfork/project2"
+#
+# [[override]]
+# name = "github.com/x/y"
+# version = "2.4.0"
+
+
+[[constraint]]
+ name = "github.com/Sirupsen/logrus"
+ version = "1.0.3"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/dustin/go-coap"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/joaojeronimo/go-crc16"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/kr/pretty"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/mitchellh/go-homedir"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/mitchellh/mapstructure"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/runtimeco/gatt"
+
+[[constraint]]
+ name = "github.com/spf13/cast"
+ version = "1.1.0"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/spf13/cobra"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/spf13/jwalterweatherman"
+
+[[constraint]]
+ name = "github.com/spf13/pflag"
+ version = "1.0.0"
+
+[[constraint]]
+ name = "github.com/stretchr/testify"
+ version = "1.1.4"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/tarm/serial"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/ugorji/go"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/xordataexchange/crypt"
+
+[[constraint]]
+ name = "gopkg.in/fsnotify.v1"
+ version = "1.4.2"
diff --git a/build.go b/build.go
new file mode 100644
index 00000000..bc3687c2
--- /dev/null
+++ b/build.go
@@ -0,0 +1,452 @@
+// +build ignore
+
+// BSD 2-Clause License
+//
+// Copyright (c) 2016, Alexander Neumann
+// 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.
+//
+// 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 HOLDER 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.
+//
+// From: https://github.com/fd0/build-go
+
+package main
+
+import (
+ "fmt"
+ "io"
+ "io/ioutil"
+ "os"
+ "os/exec"
+ "path"
+ "path/filepath"
+ "runtime"
+ "strings"
+)
+
+var (
+ verbose bool
+ keepGopath bool
+ runTests bool
+)
+
+var config = struct {
+ Name string
+ Namespace string
+ Main string
+ Tests []string
+}{
+ Name: "newt", // name of the program executable and directory
+ Namespace: "mynewt.apache.org/newt", // subdir of GOPATH, e.g. "github.com/foo/bar"
+ Main: "mynewt.apache.org/newt/newt", // package name for the main package
+ Tests: []string{ // tests to run
+ "mynewt.apache.org/newt/newt/image",
+ },
+}
+
+// specialDir returns true if the file begins with a special character ('.' or '_').
+func specialDir(name string) bool {
+ if name == "." {
+ return false
+ }
+
+ base := filepath.Base(name)
+ if base == "vendor" || base[0] == '_' || base[0] == '.' {
+ return true
+ }
+
+ return false
+}
+
+// excludePath returns true if the file should not be copied to the new GOPATH.
+func excludePath(name string) bool {
+ ext := path.Ext(name)
+ if ext == ".go" || ext == ".s" {
+ return false
+ }
+
+ parentDir := filepath.Base(filepath.Dir(name))
+ if parentDir == "testdata" {
+ return false
+ }
+
+ return true
+}
+
+// updateGopath builds a valid GOPATH at dst, with all Go files in src/ copied
+// to dst/prefix/, so calling
+//
+// updateGopath("/tmp/gopath", "/home/u/restic", "github.com/restic/restic")
+//
+// with "/home/u/restic" containing the file "foo.go" yields the following tree
+// at "/tmp/gopath":
+//
+// /tmp/gopath
+// ??? src
+// ??? github.com
+// ??? restic
+// ??? restic
+// ??? foo.go
+func updateGopath(dst, src, prefix string) error {
+ return filepath.Walk(src, func(name string, fi os.FileInfo, err error) error {
+ if name == src {
+ return err
+ }
+
+ if specialDir(name) {
+ if fi.IsDir() {
+ return filepath.SkipDir
+ }
+
+ return nil
+ }
+
+ if fi.IsDir() {
+ return nil
+ }
+
+ if excludePath(name) {
+ return nil
+ }
+
+ intermediatePath, err := filepath.Rel(src, name)
+ if err != nil {
+ return err
+ }
+
+ fileSrc := filepath.Join(src, intermediatePath)
+ fileDst := filepath.Join(dst, "src", prefix, intermediatePath)
+
+ return copyFile(fileDst, fileSrc)
+ })
+}
+
+func directoryExists(dirname string) bool {
+ stat, err := os.Stat(dirname)
+ if err != nil && os.IsNotExist(err) {
+ return false
+ }
+
+ return stat.IsDir()
+}
+
+// copyFile creates dst from src, preserving file attributes and timestamps.
+func copyFile(dst, src string) error {
+ fi, err := os.Stat(src)
+ if err != nil {
+ return err
+ }
+
+ fsrc, err := os.Open(src)
+ if err != nil {
+ return err
+ }
+
+ if err = os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
+ fmt.Printf("MkdirAll(%v)\n", filepath.Dir(dst))
+ return err
+ }
+
+ fdst, err := os.Create(dst)
+ if err != nil {
+ return err
+ }
+
+ if _, err = io.Copy(fdst, fsrc); err != nil {
+ return err
+ }
+
+ if err == nil {
+ err = fsrc.Close()
+ }
+
+ if err == nil {
+ err = fdst.Close()
+ }
+
+ if err == nil {
+ err = os.Chmod(dst, fi.Mode())
+ }
+
+ if err == nil {
+ err = os.Chtimes(dst, fi.ModTime(), fi.ModTime())
+ }
+
+ return nil
+}
+
+// die prints the message with fmt.Fprintf() to stderr and exits with an error
+// code.
+func die(message string, args ...interface{}) {
+ fmt.Fprintf(os.Stderr, message, args...)
+ os.Exit(1)
+}
+
+func showUsage(output io.Writer) {
+ fmt.Fprintf(output, "USAGE: go run build.go OPTIONS\n")
+ fmt.Fprintf(output, "\n")
+ fmt.Fprintf(output, "OPTIONS:\n")
+ fmt.Fprintf(output, " -v --verbose output more messages\n")
+ fmt.Fprintf(output, " -t --tags specify additional build tags\n")
+ fmt.Fprintf(output, " -k --keep-gopath do not remove the GOPATH after build\n")
+ fmt.Fprintf(output, " -T --test run tests\n")
+ fmt.Fprintf(output, " --goos value set GOOS for cross-compilation\n")
+ fmt.Fprintf(output, " --goarch value set GOARCH for cross-compilation\n")
+}
+
+func verbosePrintf(message string, args ...interface{}) {
+ if !verbose {
+ return
+ }
+
+ fmt.Printf("build: "+message, args...)
+}
+
+// cleanEnv returns a clean environment with GOPATH and GOBIN removed (if
+// present).
+func cleanEnv() (env []string) {
+ for _, v := range os.Environ() {
+ if strings.HasPrefix(v, "GOPATH=") || strings.HasPrefix(v, "GOBIN=") {
+ continue
+ }
+
+ env = append(env, v)
+ }
+
+ return env
+}
+
+// build runs "go build args..." with GOPATH set to gopath.
+func build(cwd, goos, goarch, gopath string, args ...string) error {
+ args = append([]string{"build"}, args...)
+ cmd := exec.Command("go", args...)
+ cmd.Env = append(cleanEnv(), "GOPATH="+gopath, "GOARCH="+goarch, "GOOS="+goos)
+ cmd.Dir = cwd
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ verbosePrintf("go %s\n", args)
+
+ return cmd.Run()
+}
+
+// test runs "go test args..." with GOPATH set to gopath.
+func test(cwd, gopath string, args ...string) error {
+ args = append([]string{"test"}, args...)
+ cmd := exec.Command("go", args...)
+ cmd.Env = append(cleanEnv(), "GOPATH="+gopath)
+ cmd.Dir = cwd
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ verbosePrintf("go %s\n", args)
+
+ return cmd.Run()
+}
+
+// getVersion returns the version string from the file VERSION in the current
+// directory.
+func getVersionFromFile() string {
+ buf, err := ioutil.ReadFile("VERSION")
+ if err != nil {
+ verbosePrintf("error reading file VERSION: %v\n", err)
+ return ""
+ }
+
+ return strings.TrimSpace(string(buf))
+}
+
+// getVersion returns a version string which is a combination of the contents
+// of the file VERSION in the current directory and the version from git (if
+// available).
+func getVersion() string {
+ versionFile := getVersionFromFile()
+ versionGit := getVersionFromGit()
+
+ verbosePrintf("version from file 'VERSION' is %q, version from git %q\n",
+ versionFile, versionGit)
+
+ switch {
+ case versionFile == "":
+ return versionGit
+ case versionGit == "":
+ return versionFile
+ }
+
+ return fmt.Sprintf("%s (%s)", versionFile, versionGit)
+}
+
+// getVersionFromGit returns a version string that identifies the currently
+// checked out git commit.
+func getVersionFromGit() string {
+ cmd := exec.Command("git", "describe",
+ "--long", "--tags", "--dirty", "--always")
+ out, err := cmd.Output()
+ if err != nil {
+ verbosePrintf("git describe returned error: %v\n", err)
+ return ""
+ }
+
+ version := strings.TrimSpace(string(out))
+ verbosePrintf("git version is %s\n", version)
+ return version
+}
+
+// Constants represents a set of constants that are set in the final binary to
+// the given value via compiler flags.
+type Constants map[string]string
+
+// LDFlags returns the string that can be passed to go build's `-ldflags`.
+func (cs Constants) LDFlags() string {
+ l := make([]string, 0, len(cs))
+
+ for k, v := range cs {
+ l = append(l, fmt.Sprintf(`-X "%s=%s"`, k, v))
+ }
+
+ return strings.Join(l, " ")
+}
+
+func main() {
+ buildTags := []string{}
+
+ skipNext := false
+ params := os.Args[1:]
+
+ targetGOOS := runtime.GOOS
+ targetGOARCH := runtime.GOARCH
+
+ for i, arg := range params {
+ if skipNext {
+ skipNext = false
+ continue
+ }
+
+ switch arg {
+ case "-v", "--verbose":
+ verbose = true
+ case "-k", "--keep-gopath":
+ keepGopath = true
+ case "-t", "-tags", "--tags":
+ if i+1 >= len(params) {
+ die("-t given but no tag specified")
+ }
+ skipNext = true
+ buildTags = strings.Split(params[i+1], " ")
+ case "-T", "--test":
+ runTests = true
+ case "--goos":
+ skipNext = true
+ targetGOOS = params[i+1]
+ case "--goarch":
+ skipNext = true
+ targetGOARCH = params[i+1]
+ case "-h":
+ showUsage(os.Stdout)
+ return
+ default:
+ fmt.Fprintf(os.Stderr, "Error: unknown option %q\n\n", arg)
+ showUsage(os.Stderr)
+ os.Exit(1)
+ }
+ }
+
+ if len(buildTags) == 0 {
+ verbosePrintf("adding build-tag release\n")
+ buildTags = []string{"release"}
+ }
+
+ for i := range buildTags {
+ buildTags[i] = strings.TrimSpace(buildTags[i])
+ }
+
+ verbosePrintf("build tags: %s\n", buildTags)
+
+ root, err := os.Getwd()
+ if err != nil {
+ die("Getwd(): %v\n", err)
+ }
+
+ gopath, err := ioutil.TempDir("", fmt.Sprintf("%v-build-", config.Name))
+ if err != nil {
+ die("TempDir(): %v\n", err)
+ }
+
+ verbosePrintf("create GOPATH at %v\n", gopath)
+ if err = updateGopath(gopath, root, config.Namespace); err != nil {
+ die("copying files from %v/src to %v/src failed: %v\n", root, gopath, err)
+ }
+
+ vendor := filepath.Join(root, "vendor")
+ if directoryExists(vendor) {
+ if err = updateGopath(gopath, vendor, ""); err != nil {
+ die("copying files from %v to %v failed: %v\n", root, gopath, err)
+ }
+ }
+
+ defer func() {
+ if !keepGopath {
+ verbosePrintf("remove %v\n", gopath)
+ if err = os.RemoveAll(gopath); err != nil {
+ die("remove GOPATH at %s failed: %v\n", err)
+ }
+ } else {
+ verbosePrintf("leaving temporary GOPATH at %v\n", gopath)
+ }
+ }()
+
+ outputFilename := config.Name
+ if targetGOOS == "windows" {
+ outputFilename += ".exe"
+ }
+
+ cwd, err := os.Getwd()
+ if err != nil {
+ die("Getwd() returned %v\n", err)
+ }
+ output := filepath.Join(cwd, outputFilename)
+
+ version := getVersion()
+ constants := Constants{}
+ if version != "" {
+ constants["main.version"] = version
+ }
+ ldflags := "-s -w " + constants.LDFlags()
+ verbosePrintf("ldflags: %s\n", ldflags)
+
+ args := []string{
+ "-tags", strings.Join(buildTags, " "),
+ "-ldflags", ldflags,
+ "-o", output, config.Main,
+ }
+
+ err = build(filepath.Join(gopath, "src"), targetGOOS, targetGOARCH, gopath, args...)
+ if err != nil {
+ die("build failed: %v\n", err)
+ }
+
+ if runTests {
+ verbosePrintf("running tests\n")
+
+ err = test(cwd, gopath, config.Tests...)
+ if err != nil {
+ die("running tests failed: %v\n", err)
+ }
+ }
+}
diff --git a/newt/builder/cmake.go b/newt/builder/cmake.go
index af26011c..837f336a 100644
--- a/newt/builder/cmake.go
+++ b/newt/builder/cmake.go
@@ -41,7 +41,7 @@ func CmakeListsPath() string {
}
func EscapeName(name string) string {
- return strings.Replace(name, "/","_", -1)
+ return strings.Replace(name, "/", "_", -1)
}
func CmakeSourceObjectWrite(w io.Writer, cj toolchain.CompilerJob) {
diff --git a/newt/builder/symbol_tree.go b/newt/builder/symbol_tree.go
index 2318da10..cf290f7e 100644
--- a/newt/builder/symbol_tree.go
+++ b/newt/builder/symbol_tree.go
@@ -149,7 +149,7 @@ func (f *File) String(indent string, level int, total uint64) string {
percent := 100 * float64(size) / float64(total)
if f.Symbols[sym].Size > 0 {
str += fmt.Sprintf(outputFormatting,
- strings.Repeat(indent, level+1)+ f.Symbols[sym].Name,
+ strings.Repeat(indent, level+1)+f.Symbols[sym].Name,
size, percent)
}
}
diff --git a/newt/builder/targetbuild.go b/newt/builder/targetbuild.go
index 8acb276f..6d505041 100644
--- a/newt/builder/targetbuild.go
+++ b/newt/builder/targetbuild.go
@@ -793,7 +793,7 @@ func (t *TargetBuilder) CreateImages(version string,
t.LoaderBuilder.AppHexPath(),
tgtArea.Offset)
err = c.ConvertBinToHex(t.LoaderBuilder.AppImgPath(),
- t.LoaderBuilder.AppHexPath(), tgtArea.Offset)
+ t.LoaderBuilder.AppHexPath(), tgtArea.Offset)
if err != nil {
log.Errorf("Can't convert to hexfile %s\n", err.Error())
}
@@ -807,7 +807,7 @@ func (t *TargetBuilder) CreateImages(version string,
flashTargetArea := ""
if t.LoaderBuilder == nil {
flashTargetArea = flash.FLASH_AREA_NAME_IMAGE_0
- } else {
+ } else {
flashTargetArea = flash.FLASH_AREA_NAME_IMAGE_1
}
tgtArea := t.bspPkg.FlashMap.Areas[flashTargetArea]
@@ -817,7 +817,7 @@ func (t *TargetBuilder) CreateImages(version string,
t.AppBuilder.AppHexPath(),
tgtArea.Offset)
err = c.ConvertBinToHex(t.AppBuilder.AppImgPath(),
- t.AppBuilder.AppHexPath(), tgtArea.Offset)
+ t.AppBuilder.AppHexPath(), tgtArea.Offset)
if err != nil {
log.Errorf("Can't convert to hexfile %s\n", err.Error())
}
diff --git a/newt/image/encrypted.go b/newt/image/encrypted.go
new file mode 100644
index 00000000..9d8ce58a
--- /dev/null
+++ b/newt/image/encrypted.go
@@ -0,0 +1,176 @@
+/**
+ * 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.
+ */
+
+// Decoder for PKCS#5 encrypted PKCS#8 private keys.
+package image
+
+import (
+ "crypto/aes"
+ "crypto/cipher"
+ "crypto/sha1"
+ "crypto/x509"
+ "crypto/x509/pkix"
+ "encoding/asn1"
+ "fmt"
+
+ "golang.org/x/crypto/pbkdf2"
+ "golang.org/x/crypto/ssh/terminal"
+)
+
+var (
+ oidPbes2 = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 5, 13}
+ oidPbkdf2 = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 5, 12}
+ oidAes128CBC = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 1, 2}
+ oidAes256CBC = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 1, 42}
+)
+
+// We only support a narrow set of possible key types, namely the type
+// generated by either MCUboot's `imgtool.py` command, or using an
+// OpenSSL command such as:
+//
+// openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 \
+// -aes-256-cbc > keyfile.pem
+//
+// or similar for ECDSA. Specifically, the encryption must be done
+// with PBES2, and PBKDF2, and aes-256-cbc used as the cipher.
+type pkcs5 struct {
+ Algo pkix.AlgorithmIdentifier
+ Encrypted []byte
+}
+
+// The parameters when the algorithm in pkcs5 is oidPbes2
+type pbes2 struct {
+ KeyDerivationFunc pkix.AlgorithmIdentifier
+ EncryptionScheme pkix.AlgorithmIdentifier
+}
+
+// Salt is given as a choice, but we will only support the inlined
+// octet string.
+type pbkdf2Param struct {
+ Salt []byte
+ IterCount int
+ // Optional and default values omitted, and unsupported.
+}
+
+func parseEncryptedPrivateKey(der []byte) (key interface{}, err error) {
+ var wrapper pkcs5
+ if _, err = asn1.Unmarshal(der, &wrapper); err != nil {
+ return nil, err
+ }
+ if !wrapper.Algo.Algorithm.Equal(oidPbes2) {
+ return nil, fmt.Errorf("pkcs5: Unknown PKCS#5 wrapper algorithm: %v", wrapper.Algo.Algorithm)
+ }
+
+ var pbparm pbes2
+ if _, err = asn1.Unmarshal(wrapper.Algo.Parameters.FullBytes, &pbparm); err != nil {
+ return nil, err
+ }
+ if !pbparm.KeyDerivationFunc.Algorithm.Equal(oidPbkdf2) {
+ return nil, fmt.Errorf("pkcs5: Unknown KDF: %v", pbparm.KeyDerivationFunc.Algorithm)
+ }
+
+ var kdfParam pbkdf2Param
+ if _, err = asn1.Unmarshal(pbparm.KeyDerivationFunc.Parameters.FullBytes, &kdfParam); err != nil {
+ return nil, err
+ }
+
+ // Get the encryption used.
+ size := 0
+ var iv []byte
+ switch {
+ case pbparm.EncryptionScheme.Algorithm.Equal(oidAes256CBC):
+ size = 32
+ if _, err = asn1.Unmarshal(pbparm.EncryptionScheme.Parameters.FullBytes, &iv); err != nil {
+ return nil, err
+ }
+ case pbparm.EncryptionScheme.Algorithm.Equal(oidAes128CBC):
+ size = 16
+ if _, err = asn1.Unmarshal(pbparm.EncryptionScheme.Parameters.FullBytes, &iv); err != nil {
+ return nil, err
+ }
+ default:
+ return nil, fmt.Errorf("pkcs5: Unsupported cipher: %v", pbparm.EncryptionScheme.Algorithm)
+ }
+
+ return unwrapPbes2Pbkdf2(&kdfParam, size, iv, wrapper.Encrypted)
+}
+
+func unwrapPbes2Pbkdf2(param *pbkdf2Param, size int, iv []byte, encrypted []byte) (key interface{}, err error) {
+ pass, err := getPassword()
+ if err != nil {
+ return nil, err
+ }
+ cryptoKey := pbkdf2.Key(pass, param.Salt, param.IterCount, size, sha1.New)
+
+ block, err := aes.NewCipher(cryptoKey)
+ if err != nil {
+ return nil, err
+ }
+ enc := cipher.NewCBCDecrypter(block, iv)
+
+ plain := make([]byte, len(encrypted))
+ enc.CryptBlocks(plain, encrypted)
+
+ plain, err = checkPkcs7Padding(plain)
+ if err != nil {
+ return nil, err
+ }
+
+ return x509.ParsePKCS8PrivateKey(plain)
+}
+
+// Verify that PKCS#7 padding is correct on this plaintext message.
+// Returns a new slice with the padding removed.
+func checkPkcs7Padding(buf []byte) ([]byte, error) {
+ if len(buf) < 16 {
+ return nil, fmt.Errorf("Invalid padded buffer")
+ }
+
+ padLen := int(buf[len(buf)-1])
+ if padLen < 1 || padLen > 16 {
+ return nil, fmt.Errorf("Invalid padded buffer")
+ }
+
+ if padLen > len(buf) {
+ return nil, fmt.Errorf("Invalid padded buffer")
+ }
+
+ for pos := len(buf) - padLen; pos < len(buf); pos++ {
+ if int(buf[pos]) != padLen {
+ return nil, fmt.Errorf("Invalid padded buffer")
+ }
+ }
+
+ return buf[:len(buf)-padLen], nil
+}
+
+// For testing, a key can be set here. If this is empty, the key will
+// be queried via prompt.
+var KeyPassword = []byte{}
+
+// Prompt the user for a password, unless we have stored one for
+// testing.
+func getPassword() ([]byte, error) {
+ if len(KeyPassword) != 0 {
+ return KeyPassword, nil
+ }
+
+ fmt.Printf("key password: ")
+ return terminal.ReadPassword(0)
+}
diff --git a/newt/image/image.go b/newt/image/image.go
index 57821cb5..176939b4 100644
--- a/newt/image/image.go
+++ b/newt/image/image.go
@@ -335,6 +335,34 @@ func (image *Image) SetSigningKey(fileName string, keyId uint8) error {
}
image.SigningEC = privateKey
}
+ if block != nil && block.Type == "PRIVATE KEY" {
+ // This indicates a PKCS#8 unencrypted private key.
+ // The particular type of key will be indicated within
+ // the key itself.
+ privateKey, err := x509.ParsePKCS8PrivateKey(block.Bytes)
+ if err != nil {
+ return util.NewNewtError(fmt.Sprintf("Private key parsing "+
+ "failed: %s", err))
+ }
+
+ err = image.storeKey(privateKey)
+ if err != nil {
+ return err
+ }
+ }
+ if block != nil && block.Type == "ENCRYPTED PRIVATE KEY" {
+ // This indicates a PKCS#8 key wrapped with PKCS#5
+ // encryption.
+ privateKey, err := parseEncryptedPrivateKey(block.Bytes)
+ if err != nil {
+ return util.FmtNewtError("Unable to decode encrypted private key: %s", err)
+ }
+
+ err = image.storeKey(privateKey)
+ if err != nil {
+ return err
+ }
+ }
if image.SigningEC == nil && image.SigningRSA == nil {
return util.NewNewtError("Unknown private key format, EC/RSA private " +
"key in PEM format only.")
@@ -344,6 +372,21 @@ func (image *Image) SetSigningKey(fileName string, keyId uint8) error {
return nil
}
+// Store the given key in this image, determining the type of key and
+// storing it in the appropriate field.
+func (image *Image) storeKey(key interface{}) (err error) {
+ switch priv := key.(type) {
+ case *rsa.PrivateKey:
+ image.SigningRSA = priv
+ case *ecdsa.PrivateKey:
+ image.SigningEC = priv
+ default:
+ return util.NewNewtError("Unknown private key format")
+ }
+
+ return nil
+}
+
func (image *Image) sigHdrTypeV1() (uint32, error) {
if image.SigningRSA != nil {
if UseRsaPss {
@@ -536,7 +579,7 @@ func (image *Image) generateV1(loader *Image) error {
}
imgFile, err := os.OpenFile(image.TargetImg,
- os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0777)
+ os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
if err != nil {
return util.NewNewtError(fmt.Sprintf("Can't open target image %s: %s",
image.TargetImg, err.Error()))
@@ -816,7 +859,7 @@ func (image *Image) generateV2(loader *Image) error {
}
imgFile, err := os.OpenFile(image.TargetImg,
- os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0777)
+ os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
if err != nil {
return util.NewNewtError(fmt.Sprintf("Can't open target image %s: %s",
image.TargetImg, err.Error()))
diff --git a/newt/image/keys_test.go b/newt/image/keys_test.go
new file mode 100644
index 00000000..ca24b98e
--- /dev/null
+++ b/newt/image/keys_test.go
@@ -0,0 +1,227 @@
+package image_test
+
+import (
+ "io/ioutil"
+ "os"
+ "path"
+ "testing"
+
+ "mynewt.apache.org/newt/newt/image"
+)
+
+func TestRSA(t *testing.T) {
+ signatureTest(t, rsaPkcs1Private)
+}
+
+func TestPlainRSAPKCS8(t *testing.T) {
+ signatureTest(t, rsaPkcs8Private)
+}
+
+func TestEcdsa(t *testing.T) {
+ signatureTest(t, ecdsaPrivate)
+}
+
+func TestPlainEcdsaPkcs8(t *testing.T) {
+ signatureTest(t, ecdsaPkcs8Private)
+}
+
+func TestEncryptedRSA(t *testing.T) {
+ image.KeyPassword = []byte("sample")
+ signatureTest(t, rsaEncryptedPrivate)
+ image.KeyPassword = []byte{}
+}
+
+func TestEncryptedEcdsa(t *testing.T) {
+ image.KeyPassword = []byte("sample")
+ signatureTest(t, ecdsaEncryptedPrivate)
+ image.KeyPassword = []byte{}
+}
+
+func signatureTest(t *testing.T, privateKey []byte) {
+ tmpdir, err := ioutil.TempDir("", "newttest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(tmpdir)
+
+ // Create a source image. Format doesn't really matter that
+ // much, since the header will be placed on it by the image
+ // tool.
+
+ simpleName := path.Join(tmpdir, "simple.bin")
+ hashedName := path.Join(tmpdir, "simple-hashed.bin")
+ signedName := path.Join(tmpdir, "simple-signed.bin")
+ keyName := path.Join(tmpdir, "private.pem")
+
+ tmp := make([]byte, 256)
+ for i := 0; i < len(tmp); i++ {
+ tmp[i] = byte(i & 0xFF)
+ }
+ err = ioutil.WriteFile(simpleName, tmp, 0644)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ img, err := image.NewImage(simpleName, hashedName)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ img.SetVersion("1.5")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ img.Generate(nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // Now try with a signature.
+ err = ioutil.WriteFile(keyName, privateKey, 0644)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ img, err = image.NewImage(simpleName, signedName)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ err = img.SetSigningKey(keyName, 0)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ err = img.SetVersion("1.6")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ err = img.Generate(nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+
+// An RSA private key in the old PKCS1 format.
+var rsaPkcs1Private = []byte(`-----BEGIN RSA PRIVATE KEY-----
+MIIEpAIBAAKCAQEA6q2Q/VoFf6U5xm35ynls+HDbHKwfIbBr27PtFJxlS9YT0xKJ
+bcZScPTVizTlft0wfp2TctX/vGd/Y/X3qo5ckRmz+lKUeHm46i4k6rtOBbhBz2id
+hwrO7/ylzwaf8lxn2dj/9ikoYQKFtBb/cKu8wyuvW3gs/ou51AVEF8aKTrl5Expy
+PrhSlh97er2zUmm8NAoo259I5yHK1SvR9kCw2gNXSDQLpFlK2WikdmEbIu0N+cvN
+WM4ONAhffkasznrEOoLPSI66RDrzYhi/Ks9t+N2buEOXao19fDRcSHgZLKT8e6W6
+uK7WxRiEzNbajzgDddbZFqWlcpE7sqPNHFBijwIDAQABAoIBAQDdXx7fLpTzROvM
+F5/C9GnrraGzWVYAlIgZ9o8Umzceo3GN8PV8fND1xq7Novc9he8h8QjPEbksg0Dz
+DWo0FBiTs3hIELAHOWNKXH7sggVmddp2iUvXwEVWsq/CK5CjsbExGXbSQR7a6+Mt
+72fEY+wq+0Fuel2PPETuEI2cE+gRuyspIcO7asmMvLRkxLi2EXU0s4JlqV9UfxKQ
+aqn0PHlRXa5SIzys3mVhXuoe45T50+VKX0DIfu/RuV8njNkkMx74DeEVvf5W4MJW
+vHrRBHoK6KoMrqiwafyPLW/Rh6fMYAdPrffMVuuThtG7Hp83VBVX1HxFhI4Jrf3S
+Hf63hmSZAoGBAO2R/vYBl57qgWEKiMQaU8rzctRbP0TtTsqNdISPMnHV1Tn/rNAU
+m0N7/6IBDb+IlndXDQwIsW/DTXhF2XJSu7n6GXua8B1LF+zuVWUsFfmE3+eLz7B8
+x8G/OkSnOTfRZCYWEoEvzhynn1dlADQ+x49I/XmKqccvAhY71glk6WULAoGBAPzi
+IYo9G+ktlNj9/3OciX7aTCiIIMDyPYtYS6wi59gwH9IswaicHYK4w2fDpTWKlzEE
+18dKF4puuI5GxnKCwHBiWxGhij063cZKKMqA64X41csK+mumux/PAb2gKbGSzzoF
+mSgkKXJ+sZ4ytlgsijEAHV85Sw7j+xy8A0qnCWMNAoGAeCDR7q1hcM8duucrvxWc
+90vg7bZyKLVimROsLneGR3+cAWbiiJlS5W3nFpE31XkItLHE/CfNKTl1i/KuAJwL
+JwBrMFBpSDa3k2v0rGL9fZ2N5rSQwapnC/ZZTWvNiAcOgB+7Ha4BqAWuke+VidWQ
+7Ug4O+Q882Y2xO1ezoNDbX8CgYBq228KyAm8PXuRObsw8iuTg9D8q5ETlwj0kcng
+IhvP2X4IxMrMYbOCompHtX9hIYADwaUgXCmYYHLyA+wlRSTmGFmdGKKefvppqLqV
+32YmhWBp3Oi2hoy5wzJcG4qis4OHZAg00xsEe464Z3tvxNpcHE1NCJuz3hglKzlE
+2VJ5HQKBgQDRisWDbdnOEp7LTXp3Aa33PF1Rx/pkFk4Wb+2Hk977O1OxsAin2cKM
+S5HCltHvON2sCmSQUIxMXXKaNPJiGL3UZJxWZDj38zSg0vO+msmemS1Yjt0xCpbO
+pkl0kvKb/NVlsY4w9kquvql+t9e1rUu9Ug28TKEsSjc9SFrcnVPoNA==
+-----END RSA PRIVATE KEY-----
+`)
+
+// An RSA private key in PKCS8 format, with no encryption.
+var rsaPkcs8Private = []byte(`-----BEGIN PRIVATE KEY-----
+MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC+FjuXqPSPucsQ
+adxY4nw+9kTgAdsXRIPxq4Q//wkfjEjYhDczN+/rafi0hApuRh7PN7VMGOsDGGR1
+edyertiLt3SfUHAZROIqZ0VAoKGtxgXmnC+s+mMujAv9Ssntbmbi5tNxDcltdWjA
+SdBn7tbIMVVofKaMMugyuXCglxebMm8yxtkSgUvE1E6zZERnteDJTPo8dBCiqkvU
+hf+vG9s1j9lNDMjrZ+d5CHIFmBxJ/WFa6m49lNBFb1Ba43bKdj6mkK05rZ4VWMXU
+evy3Z/UUgU4VPJpoB+GIKy82iOrtjiU7s/6aDkvZ2e+fgxKksN0pzFE9azeA73QS
+bamp28E/AgMBAAECggEBAJ78+4UDFOKt1JF66YkSjjcfRkZSZwyUCwP0oF3ik5/m
+dvtZws29KJevgAyEMDFBxv0srB/k65QgL84uSgATYB2kKRAjeE86VSyASeUfNXui
+GEdlNV8p4hEJo/GMP06uu7FmvU1e6a36uM20L3LuyoiQ8s29DJRQ8/ORNQmstlrg
+J32FZSjTF1mElGPSc1koxhWvl1hE7UGE9pxsSfdsvPNhCIWwAOnVnIv49xG8EWaK
+CkHhEVVdZW8IvO9GYR5U0BJcgzNmdNkS8HVQBIxZtboGAAuPI32EC7siDomKmCF6
+rEcs40f/J/RlK6lrTyKKfqWb4DPtRrOSh9cmjrFFZlECgYEA6mZIANLXJd7CINZ9
+fjotI+FxH8BDOZF7l8xTnOk1e3Me1ia7t2GMcIL+frfG/zMBiDFq0IQuUYScRK1v
+pAILjJKFiU6yY8vH6FZ3mXqiiag6RPa+q89DaUsO0uXRUjQvhtTd5Yy6r8Eac1ya
+y6XC5T5sCJ6HgaF3qlheap+5FkkCgYEAz5qSLShV5oekuj1R0fs+h/Yn7VW9Q0sj
+px8jOD4MWc8gPZ9gZe0UPTvofOLrM3eAetP4egSif99AE9iD8EbiBzAt16OX7EN8
+d7xNiIN922Ep3pubcD6f1vglaI7Thrca/p52g6kWPip6+PWFd1acU6u31Uj0Xvgz
+VFiafstF+0cCgYEAw2sOcJFXCZ2Tnyjzav85jwZu95ek9CPUNJQGyXSsQAWUGdok
++hf7q/mqDx9Maoqtpkv8z2bD7vZuCdvGjaee1U16wyS3GPhV69/ayjwxsi5slf5Y
+rIiZnPkUnMM5Jh2X2gMyFCSlp82ILdFwxIOn3tOR4gW411w0lfIilSYgevECgYA3
+JAgVZHREcdzH9seHrWLze+co+6/0cr26guO46YogRIp8s5tIF0tb5FCg8yijl+cR
+OMHzrs12h1aertCEfl9Ep4BVmUcd4uLpbqNtUfeY0FrtnIkRrCCKWYieF+mJC5No
+86/o0n1s752QCK51fxSwiJigVutJWkVP7uTCLr2cuwKBgQCJPWMcWmSuRlLOVWnO
+jPFoa02Bb83n8GrRpQkpkZZofHextwfo2dd1sZF72zghRsbdC6e0Zj1GrekJOYXO
+8AXmCpyKlXJU7iH5tPGSo68uFN05R6mINbTNmEIQBNTKv8UoKT+nHcTycFrVtarX
+A8EPW2xB86m+Bjq/GNyRgfbPMg==
+-----END PRIVATE KEY-----
+`)
+
+// An ECDSA key in the X.509 internal private key format.
+var ecdsaPrivate = []byte(`-----BEGIN EC PRIVATE KEY-----
+MGgCAQEEHF64kDx3pZyVvezbqYMIxlLbtuPQmI85k4GRy1mgBwYFK4EEACGhPAM6
+AASRtolOCTLQYkDefkIF02tUXR92MKHrbtH4WK/8bfTSFVkaygTPdJbpNthK2wae
+oX9ZeFHS1pcOfQ==
+-----END EC PRIVATE KEY-----
+`)
+
+// An ECDSA key in PKCS#8 format, no encryption.
+var ecdsaPkcs8Private = []byte(`-----BEGIN PRIVATE KEY-----
+MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgHKeDq4UU6M+c+pMm
+j0AQZlBs7f4r67668eDCUB8aDR2hRANCAATyZPzsx+xn9JtlxdspevTrYisiMTjl
+YuBJCrV1FZj2HkplEgO+ZIMuD7eRvyTEBS2bw6F1aCeKOMUmYVImAbpc
+-----END PRIVATE KEY-----
+`)
+
+// A password-protected RSA private key in PKCS#5/8 format. The
+// password for this key is "sample".
+var rsaEncryptedPrivate = []byte(`-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIRMifqJThk8kCAggA
+MB0GCWCGSAFlAwQBKgQQTMUBoFpzjJ5UNRnCIeqf4QSCBNDkQvXnUNmss8erKiDo
+Uqs2tf9ZD8MjDThLBmF/gV1dg1q6aDY+3fI2E4yLXJb2PmKcUq82YZ0FDeoCvJRJ
+BCurzM9slur5akpNBTFoFwtFsdHz7nKNS4MHUul22rGBnVFUUNTySmpjl/m+dxWO
+fa6tWpGTAr7tsCy9gF5PxpSw7NR/NpIL0PmpydHWhTs1tl2csqBqK6Tp014Kefi/
+pmmeb2eRl5cmprxW32rW2QBMtv4z91SsbnlVdz4r8txTG+3S4td9v9jD5kqcIiC2
+KQHrbH9y7okUk/ISsp9ANKPJt10fbYDxORiMK57XssXy1enGjpkIIrUGz1TMydkD
+USfwqkmPuIrrzOXnbxU4ef2wC/pA/h9Smby3WWYo8725/1kZyIediNDcgi/Qgrs4
+1VQAYzsD6duwyUNSo+tgmYVFGvZhsottus3fMWe/Ay1biJ6z6Vk8gqKWI1VV/REJ
+zK/I9hgKGxj2N2Ff6E/YkcwQenHWj/iDWLjvokyOBnPFNqzzM2Qqo1XFpzj4EO5D
+0WD4EzZYvUhk3lZZNydvXiuy8RrCVLLJMS08XgOqQaiFqqxj2hjRwv3nBesk7iA8
+5Tv8GMa5QkNrISCnp4/uGBh+v/CjwVRqPTcK3/mctPN2nLhI6H4pF4Y6apXkz1TN
+NMQqxaxmVVg8fyLaS4/xfUr8LAmiEtOwvs0XOhcqCTvvlsO4N+yec4VD4gmsTDY9
+/2b/+YwSlGMpA+GQQbg0FraaF8NyJRG1mSER6WiUGGM1cuKK44nzBbykQbZwzDSA
+kkhjDaadkhv/NPKAUR3sNy2GXVaNL/ItCpQUHRKKcIPp0HhdXsl0YebuwRlHjw/6
+UOdzNYe23e40X/Xl3vmOKRbzhLP/qO2DV21o0wI4ujF8Xu5h1h8s49HPp58G1ldy
+/hJ6durYKX8T5khiR2iXYewoy0YObuccV//Ov1/ySOp/x0/QuCl/swvs8Jf7awnu
+rpRrHPArpCvMmXmt5Y+TFYXFjkJGwsxTew5TcwBebBlIET2XNbo2pbz4WqJ3eVlK
+CNZVDEZ8mMrGT00FBi759Vfw9rhrnqXnLlNtJZ5VCXFUw8Tos302sLaQWXzHYyf8
+4awM8G9PSu5Q9lFcN9od4H95YrAAv/l8F+pcGgEKD8ZuzsgFIalqgx5wzmUMDcPM
+NKV5u9mtHjI92ru6NB8rGesM6sy6kBGvpotsDWawpV2SoCrkbyEkk+kXaGS+fsG7
+D2H37GfktN8R5Ktc0Uf/JJiNfDzq8lk1J4r7LBQlWUbhKbfGMYxt+7Xo0GsqAsLp
+PKSUwx+hTZb3BmW6s4Q6vivI1MdQbWVT1zh41StvfRSNlo70iOFxOM0lU1jjY989
+UKo+gcolddvZbMNwip0ILPO3dsa+he1jJ/gbo9qBHLy7plfsBLLakZP1Nu6xdlqQ
+TSSobaE8uxUMZk+wMWClA9AOZ1TcUr2yRV5GVj/bxG9ab+H37vF9F8vFE+jjJ7yN
+6pjdohm4gXeSVx7ON4SeZLsVwNYkCVYS89E81qLx1jP9F57+6IUGDZN5EMC0aJLT
+ny75MCCLT00KD7BFsb0KDLXxp++eu/L2hinorT3p6dXp/9mUoxmy6wJqEyqCFniZ
+N2GZN7+LDTIbHUxCijVWamU2DQ==
+-----END ENCRYPTED PRIVATE KEY-----
+`)
+
+// A password-protected ECDSA private key in PKCS#5/8 format. The
+// password for this key is "sample"
+var ecdsaEncryptedPrivate = []byte(`-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIHeMEkGCSqGSIb3DQEFDTA8MBsGCSqGSIb3DQEFDDAOBAjlKrDSKNg9QQICCAAw
+HQYJYIZIAWUDBAEqBBDliPNzQTNpdlppTcYpmuhWBIGQVhfWaVSzUvi/qIZLiZVn
+Nulfw5jDOlbn3UBX9kp/Z9Pro582Q0kjzLfm5UahvDINEJWxL4pc/28UnGQTBr0Q
+nSEg+RbqpuD099C38H0Gq/YkIM+RDG4aiQrkmzHXyVsHshIbG+z2LsLTIwmU69/Z
+v0nX6/hGErVR8YWcrOne086rCvfJVrxyO5+EUqrkLhEr
+-----END ENCRYPTED PRIVATE KEY-----
+`)
diff --git a/newt/mfg/create.go b/newt/mfg/create.go
index 2ee9f070..65bb58b6 100644
--- a/newt/mfg/create.go
+++ b/newt/mfg/create.go
@@ -44,8 +44,8 @@ type mfgManifest struct {
}
type mfgSection struct {
- offset int
- blob []byte
+ offset int
+ blob []byte
}
type createState struct {
diff --git a/newt/mfg/load.go b/newt/mfg/load.go
index b2250ed4..b58e4c6d 100644
--- a/newt/mfg/load.go
+++ b/newt/mfg/load.go
@@ -289,7 +289,7 @@ func Load(basePkg *pkg.LocalPackage) (*MfgImage, error) {
return nil, mi.loadError(err.Error())
}
mi.compiler, err = toolchain.NewCompiler(compilerPkg.BasePath(), "",
- target.DEFAULT_BUILD_PROFILE)
+ target.DEFAULT_BUILD_PROFILE)
if err != nil {
return nil, mi.loadError(err.Error())
}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/.travis.yml b/newt/vendor/github.com/Sirupsen/logrus/.travis.yml
deleted file mode 100644
index ec7dd783..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/.travis.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-language: go
-go:
- - 1.6
- - 1.7
- - tip
-install:
- - go get -t $(go list ./... | grep -v /examples/)
-script:
- - GOMAXPROCS=4 GORACE="halt_on_error=1" go test -race -v $(go list ./... | grep -v /examples/)
diff --git a/newt/vendor/github.com/Sirupsen/logrus/CHANGELOG.md b/newt/vendor/github.com/Sirupsen/logrus/CHANGELOG.md
deleted file mode 100644
index f2c2bc21..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/CHANGELOG.md
+++ /dev/null
@@ -1,66 +0,0 @@
-# 0.10.0
-
-* feature: Add a test hook (#180)
-* feature: `ParseLevel` is now case-insensitive (#326)
-* feature: `FieldLogger` interface that generalizes `Logger` and `Entry` (#308)
-* performance: avoid re-allocations on `WithFields` (#335)
-
-# 0.9.0
-
-* logrus/text_formatter: don't emit empty msg
-* logrus/hooks/airbrake: move out of main repository
-* logrus/hooks/sentry: move out of main repository
-* logrus/hooks/papertrail: move out of main repository
-* logrus/hooks/bugsnag: move out of main repository
-* logrus/core: run tests with `-race`
-* logrus/core: detect TTY based on `stderr`
-* logrus/core: support `WithError` on logger
-* logrus/core: Solaris support
-
-# 0.8.7
-
-* logrus/core: fix possible race (#216)
-* logrus/doc: small typo fixes and doc improvements
-
-
-# 0.8.6
-
-* hooks/raven: allow passing an initialized client
-
-# 0.8.5
-
-* logrus/core: revert #208
-
-# 0.8.4
-
-* formatter/text: fix data race (#218)
-
-# 0.8.3
-
-* logrus/core: fix entry log level (#208)
-* logrus/core: improve performance of text formatter by 40%
-* logrus/core: expose `LevelHooks` type
-* logrus/core: add support for DragonflyBSD and NetBSD
-* formatter/text: print structs more verbosely
-
-# 0.8.2
-
-* logrus: fix more Fatal family functions
-
-# 0.8.1
-
-* logrus: fix not exiting on `Fatalf` and `Fatalln`
-
-# 0.8.0
-
-* logrus: defaults to stderr instead of stdout
-* hooks/sentry: add special field for `*http.Request`
-* formatter/text: ignore Windows for colors
-
-# 0.7.3
-
-* formatter/\*: allow configuration of timestamp layout
-
-# 0.7.2
-
-* formatter/text: Add configuration option for time format (#158)
diff --git a/newt/vendor/github.com/Sirupsen/logrus/README.md b/newt/vendor/github.com/Sirupsen/logrus/README.md
deleted file mode 100644
index f9cfb0a5..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/README.md
+++ /dev/null
@@ -1,426 +0,0 @@
-# Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/> [![Build Status](https://travis-ci.org/Sirupsen/logrus.svg?branch=master)](https://travis-ci.org/Sirupsen/logrus) [![GoDoc](https://godoc.org/github.com/Sirupsen/logrus?status.svg)](https://godoc.org/github.com/Sirupsen/logrus)
-
-Logrus is a structured logger for Go (golang), completely API compatible with
-the standard library logger. [Godoc][godoc]. **Please note the Logrus API is not
-yet stable (pre 1.0). Logrus itself is completely stable and has been used in
-many large deployments. The core API is unlikely to change much but please
-version control your Logrus to make sure you aren't fetching latest `master` on
-every build.**
-
-Nicely color-coded in development (when a TTY is attached, otherwise just
-plain text):
-
-![Colored](http://i.imgur.com/PY7qMwd.png)
-
-With `log.SetFormatter(&log.JSONFormatter{})`, for easy parsing by logstash
-or Splunk:
-
-```json
-{"animal":"walrus","level":"info","msg":"A group of walrus emerges from the
-ocean","size":10,"time":"2014-03-10 19:57:38.562264131 -0400 EDT"}
-
-{"level":"warning","msg":"The group's number increased tremendously!",
-"number":122,"omg":true,"time":"2014-03-10 19:57:38.562471297 -0400 EDT"}
-
-{"animal":"walrus","level":"info","msg":"A giant walrus appears!",
-"size":10,"time":"2014-03-10 19:57:38.562500591 -0400 EDT"}
-
-{"animal":"walrus","level":"info","msg":"Tremendously sized cow enters the ocean.",
-"size":9,"time":"2014-03-10 19:57:38.562527896 -0400 EDT"}
-
-{"level":"fatal","msg":"The ice breaks!","number":100,"omg":true,
-"time":"2014-03-10 19:57:38.562543128 -0400 EDT"}
-```
-
-With the default `log.SetFormatter(&log.TextFormatter{})` when a TTY is not
-attached, the output is compatible with the
-[logfmt](http://godoc.org/github.com/kr/logfmt) format:
-
-```text
-time="2015-03-26T01:27:38-04:00" level=debug msg="Started observing beach" animal=walrus number=8
-time="2015-03-26T01:27:38-04:00" level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10
-time="2015-03-26T01:27:38-04:00" level=warning msg="The group's number increased tremendously!" number=122 omg=true
-time="2015-03-26T01:27:38-04:00" level=debug msg="Temperature changes" temperature=-4
-time="2015-03-26T01:27:38-04:00" level=panic msg="It's over 9000!" animal=orca size=9009
-time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x2082280c0 map[animal:orca size:9009] 2015-03-26 01:27:38.441574009 -0400 EDT panic It's over 9000!} number=100 omg=true
-exit status 1
-```
-
-#### Example
-
-The simplest way to use Logrus is simply the package-level exported logger:
-
-```go
-package main
-
-import (
- log "github.com/Sirupsen/logrus"
-)
-
-func main() {
- log.WithFields(log.Fields{
- "animal": "walrus",
- }).Info("A walrus appears")
-}
-```
-
-Note that it's completely api-compatible with the stdlib logger, so you can
-replace your `log` imports everywhere with `log "github.com/Sirupsen/logrus"`
-and you'll now have the flexibility of Logrus. You can customize it all you
-want:
-
-```go
-package main
-
-import (
- "os"
- log "github.com/Sirupsen/logrus"
-)
-
-func init() {
- // Log as JSON instead of the default ASCII formatter.
- log.SetFormatter(&log.JSONFormatter{})
-
- // Output to stderr instead of stdout, could also be a file.
- log.SetOutput(os.Stderr)
-
- // Only log the warning severity or above.
- log.SetLevel(log.WarnLevel)
-}
-
-func main() {
- log.WithFields(log.Fields{
- "animal": "walrus",
- "size": 10,
- }).Info("A group of walrus emerges from the ocean")
-
- log.WithFields(log.Fields{
- "omg": true,
- "number": 122,
- }).Warn("The group's number increased tremendously!")
-
- log.WithFields(log.Fields{
- "omg": true,
- "number": 100,
- }).Fatal("The ice breaks!")
-
- // A common pattern is to re-use fields between logging statements by re-using
- // the logrus.Entry returned from WithFields()
- contextLogger := log.WithFields(log.Fields{
- "common": "this is a common field",
- "other": "I also should be logged always",
- })
-
- contextLogger.Info("I'll be logged with common and other field")
- contextLogger.Info("Me too")
-}
-```
-
-For more advanced usage such as logging to multiple locations from the same
-application, you can also create an instance of the `logrus` Logger:
-
-```go
-package main
-
-import (
- "github.com/Sirupsen/logrus"
-)
-
-// Create a new instance of the logger. You can have any number of instances.
-var log = logrus.New()
-
-func main() {
- // The API for setting attributes is a little different than the package level
- // exported logger. See Godoc.
- log.Out = os.Stderr
-
- log.WithFields(logrus.Fields{
- "animal": "walrus",
- "size": 10,
- }).Info("A group of walrus emerges from the ocean")
-}
-```
-
-#### Fields
-
-Logrus encourages careful, structured logging though logging fields instead of
-long, unparseable error messages. For example, instead of: `log.Fatalf("Failed
-to send event %s to topic %s with key %d")`, you should log the much more
-discoverable:
-
-```go
-log.WithFields(log.Fields{
- "event": event,
- "topic": topic,
- "key": key,
-}).Fatal("Failed to send event")
-```
-
-We've found this API forces you to think about logging in a way that produces
-much more useful logging messages. We've been in countless situations where just
-a single added field to a log statement that was already there would've saved us
-hours. The `WithFields` call is optional.
-
-In general, with Logrus using any of the `printf`-family functions should be
-seen as a hint you should add a field, however, you can still use the
-`printf`-family functions with Logrus.
-
-#### Hooks
-
-You can add hooks for logging levels. For example to send errors to an exception
-tracking service on `Error`, `Fatal` and `Panic`, info to StatsD or log to
-multiple places simultaneously, e.g. syslog.
-
-Logrus comes with [built-in hooks](hooks/). Add those, or your custom hook, in
-`init`:
-
-```go
-import (
- log "github.com/Sirupsen/logrus"
- "gopkg.in/gemnasium/logrus-airbrake-hook.v2" // the package is named "aibrake"
- logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog"
- "log/syslog"
-)
-
-func init() {
-
- // Use the Airbrake hook to report errors that have Error severity or above to
- // an exception tracker. You can create custom hooks, see the Hooks section.
- log.AddHook(airbrake.NewHook(123, "xyz", "production"))
-
- hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
- if err != nil {
- log.Error("Unable to connect to local syslog daemon")
- } else {
- log.AddHook(hook)
- }
-}
-```
-Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). For the detail, please check the [syslog hook README](hooks/syslog/README.md).
-
-| Hook | Description |
-| ----- | ----------- |
-| [Airbrake](https://github.com/gemnasium/logrus-airbrake-hook) | Send errors to the Airbrake API V3. Uses the official [`gobrake`](https://github.com/airbrake/gobrake) behind the scenes. |
-| [Airbrake "legacy"](https://github.com/gemnasium/logrus-airbrake-legacy-hook) | Send errors to an exception tracking service compatible with the Airbrake API V2. Uses [`airbrake-go`](https://github.com/tobi/airbrake-go) behind the scenes. |
-| [Papertrail](https://github.com/polds/logrus-papertrail-hook) | Send errors to the [Papertrail](https://papertrailapp.com) hosted logging service via UDP. |
-| [Syslog](https://github.com/Sirupsen/logrus/blob/master/hooks/syslog/syslog.go) | Send errors to remote syslog server. Uses standard library `log/syslog` behind the scenes. |
-| [Bugsnag](https://github.com/Shopify/logrus-bugsnag/blob/master/bugsnag.go) | Send errors to the Bugsnag exception tracking service. |
-| [Sentry](https://github.com/evalphobia/logrus_sentry) | Send errors to the Sentry error logging and aggregation service. |
-| [Hiprus](https://github.com/nubo/hiprus) | Send errors to a channel in hipchat. |
-| [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) |
-| [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. |
-| [Journalhook](https://github.com/wercker/journalhook) | Hook for logging to `systemd-journald` |
-| [Graylog](https://github.com/gemnasium/logrus-graylog-hook) | Hook for logging to [Graylog](http://graylog2.org/) |
-| [Raygun](https://github.com/squirkle/logrus-raygun-hook) | Hook for logging to [Raygun.io](http://raygun.io/) |
-| [LFShook](https://github.com/rifflock/lfshook) | Hook for logging to the local filesystem |
-| [Honeybadger](https://github.com/agonzalezro/logrus_honeybadger) | Hook for sending exceptions to Honeybadger |
-| [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail |
-| [Rollrus](https://github.com/heroku/rollrus) | Hook for sending errors to rollbar |
-| [Fluentd](https://github.com/evalphobia/logrus_fluent) | Hook for logging to fluentd |
-| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb |
-| [Influxus] (http://github.com/vlad-doru/influxus) | Hook for concurrently logging to [InfluxDB] (http://influxdata.com/) |
-| [InfluxDB](https://github.com/Abramovic/logrus_influxdb) | Hook for logging to influxdb |
-| [Octokit](https://github.com/dorajistyle/logrus-octokit-hook) | Hook for logging to github via octokit |
-| [DeferPanic](https://github.com/deferpanic/dp-logrus) | Hook for logging to DeferPanic |
-| [Redis-Hook](https://github.com/rogierlommers/logrus-redis-hook) | Hook for logging to a ELK stack (through Redis) |
-| [Amqp-Hook](https://github.com/vladoatanasov/logrus_amqp) | Hook for logging to Amqp broker (Like RabbitMQ) |
-| [KafkaLogrus](https://github.com/goibibo/KafkaLogrus) | Hook for logging to kafka |
-| [Typetalk](https://github.com/dragon3/logrus-typetalk-hook) | Hook for logging to [Typetalk](https://www.typetalk.in/) |
-| [ElasticSearch](https://github.com/sohlich/elogrus) | Hook for logging to ElasticSearch|
-| [Sumorus](https://github.com/doublefree/sumorus) | Hook for logging to [SumoLogic](https://www.sumologic.com/)|
-| [Scribe](https://github.com/sagar8192/logrus-scribe-hook) | Hook for logging to [Scribe](https://github.com/facebookarchive/scribe)|
-| [Logstash](https://github.com/bshuster-repo/logrus-logstash-hook) | Hook for logging to [Logstash](https://www.elastic.co/products/logstash) |
-| [logz.io](https://github.com/ripcurld00d/logrus-logzio-hook) | Hook for logging to [logz.io](https://logz.io), a Log as a Service using Logstash |
-| [Logmatic.io](https://github.com/logmatic/logmatic-go) | Hook for logging to [Logmatic.io](http://logmatic.io/) |
-| [Pushover](https://github.com/toorop/logrus_pushover) | Send error via [Pushover](https://pushover.net) |
-| [PostgreSQL](https://github.com/gemnasium/logrus-postgresql-hook) | Send logs to [PostgreSQL](http://postgresql.org) |
-
-
-#### Level logging
-
-Logrus has six logging levels: Debug, Info, Warning, Error, Fatal and Panic.
-
-```go
-log.Debug("Useful debugging information.")
-log.Info("Something noteworthy happened!")
-log.Warn("You should probably take a look at this.")
-log.Error("Something failed but I'm not quitting.")
-// Calls os.Exit(1) after logging
-log.Fatal("Bye.")
-// Calls panic() after logging
-log.Panic("I'm bailing.")
-```
-
-You can set the logging level on a `Logger`, then it will only log entries with
-that severity or anything above it:
-
-```go
-// Will log anything that is info or above (warn, error, fatal, panic). Default.
-log.SetLevel(log.InfoLevel)
-```
-
-It may be useful to set `log.Level = logrus.DebugLevel` in a debug or verbose
-environment if your application has that.
-
-#### Entries
-
-Besides the fields added with `WithField` or `WithFields` some fields are
-automatically added to all logging events:
-
-1. `time`. The timestamp when the entry was created.
-2. `msg`. The logging message passed to `{Info,Warn,Error,Fatal,Panic}` after
- the `AddFields` call. E.g. `Failed to send event.`
-3. `level`. The logging level. E.g. `info`.
-
-#### Environments
-
-Logrus has no notion of environment.
-
-If you wish for hooks and formatters to only be used in specific environments,
-you should handle that yourself. For example, if your application has a global
-variable `Environment`, which is a string representation of the environment you
-could do:
-
-```go
-import (
- log "github.com/Sirupsen/logrus"
-)
-
-init() {
- // do something here to set environment depending on an environment variable
- // or command-line flag
- if Environment == "production" {
- log.SetFormatter(&log.JSONFormatter{})
- } else {
- // The TextFormatter is default, you don't actually have to do this.
- log.SetFormatter(&log.TextFormatter{})
- }
-}
-```
-
-This configuration is how `logrus` was intended to be used, but JSON in
-production is mostly only useful if you do log aggregation with tools like
-Splunk or Logstash.
-
-#### Formatters
-
-The built-in logging formatters are:
-
-* `logrus.TextFormatter`. Logs the event in colors if stdout is a tty, otherwise
- without colors.
- * *Note:* to force colored output when there is no TTY, set the `ForceColors`
- field to `true`. To force no colored output even if there is a TTY set the
- `DisableColors` field to `true`
-* `logrus.JSONFormatter`. Logs fields as JSON.
-
-Third party logging formatters:
-
-* [`logstash`](https://github.com/bshuster-repo/logrus-logstash-hook). Logs fields as [Logstash](http://logstash.net) Events.
-* [`prefixed`](https://github.com/x-cray/logrus-prefixed-formatter). Displays log entry source along with alternative layout.
-* [`zalgo`](https://github.com/aybabtme/logzalgo). Invoking the P??o???w????e????r???? ??????????f??? ?????Z?????a????l??g??o???!?????? ?????.
-
-You can define your formatter by implementing the `Formatter` interface,
-requiring a `Format` method. `Format` takes an `*Entry`. `entry.Data` is a
-`Fields` type (`map[string]interface{}`) with all your fields as well as the
-default ones (see Entries section above):
-
-```go
-type MyJSONFormatter struct {
-}
-
-log.SetFormatter(new(MyJSONFormatter))
-
-func (f *MyJSONFormatter) Format(entry *Entry) ([]byte, error) {
- // Note this doesn't include Time, Level and Message which are available on
- // the Entry. Consult `godoc` on information about those fields or read the
- // source of the official loggers.
- serialized, err := json.Marshal(entry.Data)
- if err != nil {
- return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
- }
- return append(serialized, '\n'), nil
-}
-```
-
-#### Logger as an `io.Writer`
-
-Logrus can be transformed into an `io.Writer`. That writer is the end of an `io.Pipe` and it is your responsibility to close it.
-
-```go
-w := logger.Writer()
-defer w.Close()
-
-srv := http.Server{
- // create a stdlib log.Logger that writes to
- // logrus.Logger.
- ErrorLog: log.New(w, "", 0),
-}
-```
-
-Each line written to that writer will be printed the usual way, using formatters
-and hooks. The level for those entries is `info`.
-
-#### Rotation
-
-Log rotation is not provided with Logrus. Log rotation should be done by an
-external program (like `logrotate(8)`) that can compress and delete old log
-entries. It should not be a feature of the application-level logger.
-
-#### Tools
-
-| Tool | Description |
-| ---- | ----------- |
-|[Logrus Mate](https://github.com/gogap/logrus_mate)|Logrus mate is a tool for Logrus to manage loggers, you can initial logger's level, hook and formatter by config file, the logger will generated with different config at different environment.|
-|[Logrus Viper Helper](https://github.com/heirko/go-contrib/tree/master/logrusHelper)|An Helper arround Logrus to wrap with spf13/Viper to load configuration with fangs! And to simplify Logrus configuration use some behavior of [Logrus Mate](https://github.com/gogap/logrus_mate). [sample](https://github.com/heirko/iris-contrib/blob/master/middleware/logrus-logger/example) |
-
-#### Testing
-
-Logrus has a built in facility for asserting the presence of log messages. This is implemented through the `test` hook and provides:
-
-* decorators for existing logger (`test.NewLocal` and `test.NewGlobal`) which basically just add the `test` hook
-* a test logger (`test.NewNullLogger`) that just records log messages (and does not output any):
-
-```go
-logger, hook := NewNullLogger()
-logger.Error("Hello error")
-
-assert.Equal(1, len(hook.Entries))
-assert.Equal(logrus.ErrorLevel, hook.LastEntry().Level)
-assert.Equal("Hello error", hook.LastEntry().Message)
-
-hook.Reset()
-assert.Nil(hook.LastEntry())
-```
-
-#### Fatal handlers
-
-Logrus can register one or more functions that will be called when any `fatal`
-level message is logged. The registered handlers will be executed before
-logrus performs a `os.Exit(1)`. This behavior may be helpful if callers need
-to gracefully shutdown. Unlike a `panic("Something went wrong...")` call which can be intercepted with a deferred `recover` a call to `os.Exit(1)` can not be intercepted.
-
-```
-...
-handler := func() {
- // gracefully shutdown something...
-}
-logrus.RegisterExitHandler(handler)
-...
-```
-
-#### Thread safty
-
-By default Logger is protected by mutex for concurrent writes, this mutex is invoked when calling hooks and writing logs.
-If you are sure such locking is not needed, you can call logger.SetNoLock() to disable the locking.
-
-Situation when locking is not needed includes:
-
-* You have no hooks registered, or hooks calling is already thread-safe.
-
-* Writing to logger.Out is already thread-safe, for example:
-
- 1) logger.Out is protected by locks.
-
- 2) logger.Out is a os.File handler opened with `O_APPEND` flag, and every write is smaller than 4k. (This allow multi-thread/multi-process writing)
-
- (Refer to http://www.notthewizard.com/2014/06/17/are-files-appends-really-atomic/)
diff --git a/newt/vendor/github.com/Sirupsen/logrus/alt_exit.go b/newt/vendor/github.com/Sirupsen/logrus/alt_exit.go
deleted file mode 100644
index b4c9e847..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/alt_exit.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package logrus
-
-// The following code was sourced and modified from the
-// https://bitbucket.org/tebeka/atexit package governed by the following license:
-//
-// Copyright (c) 2012 Miki Tebeka <mi...@gmail.com>.
-//
-// 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.
-
-import (
- "fmt"
- "os"
-)
-
-var handlers = []func(){}
-
-func runHandler(handler func()) {
- defer func() {
- if err := recover(); err != nil {
- fmt.Fprintln(os.Stderr, "Error: Logrus exit handler error:", err)
- }
- }()
-
- handler()
-}
-
-func runHandlers() {
- for _, handler := range handlers {
- runHandler(handler)
- }
-}
-
-// Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code)
-func Exit(code int) {
- runHandlers()
- os.Exit(code)
-}
-
-// RegisterExitHandler adds a Logrus Exit handler, call logrus.Exit to invoke
-// all handlers. The handlers will also be invoked when any Fatal log entry is
-// made.
-//
-// This method is useful when a caller wishes to use logrus to log a fatal
-// message but also needs to gracefully shutdown. An example usecase could be
-// closing database connections, or sending a alert that the application is
-// closing.
-func RegisterExitHandler(handler func()) {
- handlers = append(handlers, handler)
-}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/doc.go b/newt/vendor/github.com/Sirupsen/logrus/doc.go
deleted file mode 100644
index dddd5f87..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/doc.go
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-Package logrus is a structured logger for Go, completely API compatible with the standard library logger.
-
-
-The simplest way to use Logrus is simply the package-level exported logger:
-
- package main
-
- import (
- log "github.com/Sirupsen/logrus"
- )
-
- func main() {
- log.WithFields(log.Fields{
- "animal": "walrus",
- "number": 1,
- "size": 10,
- }).Info("A walrus appears")
- }
-
-Output:
- time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10
-
-For a full guide visit https://github.com/Sirupsen/logrus
-*/
-package logrus
diff --git a/newt/vendor/github.com/Sirupsen/logrus/entry.go b/newt/vendor/github.com/Sirupsen/logrus/entry.go
deleted file mode 100644
index 4edbe7a2..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/entry.go
+++ /dev/null
@@ -1,275 +0,0 @@
-package logrus
-
-import (
- "bytes"
- "fmt"
- "os"
- "sync"
- "time"
-)
-
-var bufferPool *sync.Pool
-
-func init() {
- bufferPool = &sync.Pool{
- New: func() interface{} {
- return new(bytes.Buffer)
- },
- }
-}
-
-// Defines the key when adding errors using WithError.
-var ErrorKey = "error"
-
-// An entry is the final or intermediate Logrus logging entry. It contains all
-// the fields passed with WithField{,s}. It's finally logged when Debug, Info,
-// Warn, Error, Fatal or Panic is called on it. These objects can be reused and
-// passed around as much as you wish to avoid field duplication.
-type Entry struct {
- Logger *Logger
-
- // Contains all the fields set by the user.
- Data Fields
-
- // Time at which the log entry was created
- Time time.Time
-
- // Level the log entry was logged at: Debug, Info, Warn, Error, Fatal or Panic
- Level Level
-
- // Message passed to Debug, Info, Warn, Error, Fatal or Panic
- Message string
-
- // When formatter is called in entry.log(), an Buffer may be set to entry
- Buffer *bytes.Buffer
-}
-
-func NewEntry(logger *Logger) *Entry {
- return &Entry{
- Logger: logger,
- // Default is three fields, give a little extra room
- Data: make(Fields, 5),
- }
-}
-
-// Returns the string representation from the reader and ultimately the
-// formatter.
-func (entry *Entry) String() (string, error) {
- serialized, err := entry.Logger.Formatter.Format(entry)
- if err != nil {
- return "", err
- }
- str := string(serialized)
- return str, nil
-}
-
-// Add an error as single field (using the key defined in ErrorKey) to the Entry.
-func (entry *Entry) WithError(err error) *Entry {
- return entry.WithField(ErrorKey, err)
-}
-
-// Add a single field to the Entry.
-func (entry *Entry) WithField(key string, value interface{}) *Entry {
- return entry.WithFields(Fields{key: value})
-}
-
-// Add a map of fields to the Entry.
-func (entry *Entry) WithFields(fields Fields) *Entry {
- data := make(Fields, len(entry.Data)+len(fields))
- for k, v := range entry.Data {
- data[k] = v
- }
- for k, v := range fields {
- data[k] = v
- }
- return &Entry{Logger: entry.Logger, Data: data}
-}
-
-// This function is not declared with a pointer value because otherwise
-// race conditions will occur when using multiple goroutines
-func (entry Entry) log(level Level, msg string) {
- var buffer *bytes.Buffer
- entry.Time = time.Now()
- entry.Level = level
- entry.Message = msg
-
- if err := entry.Logger.Hooks.Fire(level, &entry); err != nil {
- entry.Logger.mu.Lock()
- fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err)
- entry.Logger.mu.Unlock()
- }
- buffer = bufferPool.Get().(*bytes.Buffer)
- buffer.Reset()
- defer bufferPool.Put(buffer)
- entry.Buffer = buffer
- serialized, err := entry.Logger.Formatter.Format(&entry)
- entry.Buffer = nil
- if err != nil {
- entry.Logger.mu.Lock()
- fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err)
- entry.Logger.mu.Unlock()
- } else {
- entry.Logger.mu.Lock()
- _, err = entry.Logger.Out.Write(serialized)
- if err != nil {
- fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
- }
- entry.Logger.mu.Unlock()
- }
-
- // To avoid Entry#log() returning a value that only would make sense for
- // panic() to use in Entry#Panic(), we avoid the allocation by checking
- // directly here.
- if level <= PanicLevel {
- panic(&entry)
- }
-}
-
-func (entry *Entry) Debug(args ...interface{}) {
- if entry.Logger.Level >= DebugLevel {
- entry.log(DebugLevel, fmt.Sprint(args...))
- }
-}
-
-func (entry *Entry) Print(args ...interface{}) {
- entry.Info(args...)
-}
-
-func (entry *Entry) Info(args ...interface{}) {
- if entry.Logger.Level >= InfoLevel {
- entry.log(InfoLevel, fmt.Sprint(args...))
- }
-}
-
-func (entry *Entry) Warn(args ...interface{}) {
- if entry.Logger.Level >= WarnLevel {
- entry.log(WarnLevel, fmt.Sprint(args...))
- }
-}
-
-func (entry *Entry) Warning(args ...interface{}) {
- entry.Warn(args...)
-}
-
-func (entry *Entry) Error(args ...interface{}) {
- if entry.Logger.Level >= ErrorLevel {
- entry.log(ErrorLevel, fmt.Sprint(args...))
- }
-}
-
-func (entry *Entry) Fatal(args ...interface{}) {
- if entry.Logger.Level >= FatalLevel {
- entry.log(FatalLevel, fmt.Sprint(args...))
- }
- Exit(1)
-}
-
-func (entry *Entry) Panic(args ...interface{}) {
- if entry.Logger.Level >= PanicLevel {
- entry.log(PanicLevel, fmt.Sprint(args...))
- }
- panic(fmt.Sprint(args...))
-}
-
-// Entry Printf family functions
-
-func (entry *Entry) Debugf(format string, args ...interface{}) {
- if entry.Logger.Level >= DebugLevel {
- entry.Debug(fmt.Sprintf(format, args...))
- }
-}
-
-func (entry *Entry) Infof(format string, args ...interface{}) {
- if entry.Logger.Level >= InfoLevel {
- entry.Info(fmt.Sprintf(format, args...))
- }
-}
-
-func (entry *Entry) Printf(format string, args ...interface{}) {
- entry.Infof(format, args...)
-}
-
-func (entry *Entry) Warnf(format string, args ...interface{}) {
- if entry.Logger.Level >= WarnLevel {
- entry.Warn(fmt.Sprintf(format, args...))
- }
-}
-
-func (entry *Entry) Warningf(format string, args ...interface{}) {
- entry.Warnf(format, args...)
-}
-
-func (entry *Entry) Errorf(format string, args ...interface{}) {
- if entry.Logger.Level >= ErrorLevel {
- entry.Error(fmt.Sprintf(format, args...))
- }
-}
-
-func (entry *Entry) Fatalf(format string, args ...interface{}) {
- if entry.Logger.Level >= FatalLevel {
- entry.Fatal(fmt.Sprintf(format, args...))
- }
- Exit(1)
-}
-
-func (entry *Entry) Panicf(format string, args ...interface{}) {
- if entry.Logger.Level >= PanicLevel {
- entry.Panic(fmt.Sprintf(format, args...))
- }
-}
-
-// Entry Println family functions
-
-func (entry *Entry) Debugln(args ...interface{}) {
- if entry.Logger.Level >= DebugLevel {
- entry.Debug(entry.sprintlnn(args...))
- }
-}
-
-func (entry *Entry) Infoln(args ...interface{}) {
- if entry.Logger.Level >= InfoLevel {
- entry.Info(entry.sprintlnn(args...))
- }
-}
-
-func (entry *Entry) Println(args ...interface{}) {
- entry.Infoln(args...)
-}
-
-func (entry *Entry) Warnln(args ...interface{}) {
- if entry.Logger.Level >= WarnLevel {
- entry.Warn(entry.sprintlnn(args...))
- }
-}
-
-func (entry *Entry) Warningln(args ...interface{}) {
- entry.Warnln(args...)
-}
-
-func (entry *Entry) Errorln(args ...interface{}) {
- if entry.Logger.Level >= ErrorLevel {
- entry.Error(entry.sprintlnn(args...))
- }
-}
-
-func (entry *Entry) Fatalln(args ...interface{}) {
- if entry.Logger.Level >= FatalLevel {
- entry.Fatal(entry.sprintlnn(args...))
- }
- Exit(1)
-}
-
-func (entry *Entry) Panicln(args ...interface{}) {
- if entry.Logger.Level >= PanicLevel {
- entry.Panic(entry.sprintlnn(args...))
- }
-}
-
-// Sprintlnn => Sprint no newline. This is to get the behavior of how
-// fmt.Sprintln where spaces are always added between operands, regardless of
-// their type. Instead of vendoring the Sprintln implementation to spare a
-// string allocation, we do the simplest thing.
-func (entry *Entry) sprintlnn(args ...interface{}) string {
- msg := fmt.Sprintln(args...)
- return msg[:len(msg)-1]
-}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/exported.go b/newt/vendor/github.com/Sirupsen/logrus/exported.go
deleted file mode 100644
index 9a0120ac..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/exported.go
+++ /dev/null
@@ -1,193 +0,0 @@
-package logrus
-
-import (
- "io"
-)
-
-var (
- // std is the name of the standard logger in stdlib `log`
- std = New()
-)
-
-func StandardLogger() *Logger {
- return std
-}
-
-// SetOutput sets the standard logger output.
-func SetOutput(out io.Writer) {
- std.mu.Lock()
- defer std.mu.Unlock()
- std.Out = out
-}
-
-// SetFormatter sets the standard logger formatter.
-func SetFormatter(formatter Formatter) {
- std.mu.Lock()
- defer std.mu.Unlock()
- std.Formatter = formatter
-}
-
-// SetLevel sets the standard logger level.
-func SetLevel(level Level) {
- std.mu.Lock()
- defer std.mu.Unlock()
- std.Level = level
-}
-
-// GetLevel returns the standard logger level.
-func GetLevel() Level {
- std.mu.Lock()
- defer std.mu.Unlock()
- return std.Level
-}
-
-// AddHook adds a hook to the standard logger hooks.
-func AddHook(hook Hook) {
- std.mu.Lock()
- defer std.mu.Unlock()
- std.Hooks.Add(hook)
-}
-
-// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key.
-func WithError(err error) *Entry {
- return std.WithField(ErrorKey, err)
-}
-
-// WithField creates an entry from the standard logger and adds a field to
-// it. If you want multiple fields, use `WithFields`.
-//
-// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
-// or Panic on the Entry it returns.
-func WithField(key string, value interface{}) *Entry {
- return std.WithField(key, value)
-}
-
-// WithFields creates an entry from the standard logger and adds multiple
-// fields to it. This is simply a helper for `WithField`, invoking it
-// once for each field.
-//
-// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
-// or Panic on the Entry it returns.
-func WithFields(fields Fields) *Entry {
- return std.WithFields(fields)
-}
-
-// Debug logs a message at level Debug on the standard logger.
-func Debug(args ...interface{}) {
- std.Debug(args...)
-}
-
-// Print logs a message at level Info on the standard logger.
-func Print(args ...interface{}) {
- std.Print(args...)
-}
-
-// Info logs a message at level Info on the standard logger.
-func Info(args ...interface{}) {
- std.Info(args...)
-}
-
-// Warn logs a message at level Warn on the standard logger.
-func Warn(args ...interface{}) {
- std.Warn(args...)
-}
-
-// Warning logs a message at level Warn on the standard logger.
-func Warning(args ...interface{}) {
- std.Warning(args...)
-}
-
-// Error logs a message at level Error on the standard logger.
-func Error(args ...interface{}) {
- std.Error(args...)
-}
-
-// Panic logs a message at level Panic on the standard logger.
-func Panic(args ...interface{}) {
- std.Panic(args...)
-}
-
-// Fatal logs a message at level Fatal on the standard logger.
-func Fatal(args ...interface{}) {
- std.Fatal(args...)
-}
-
-// Debugf logs a message at level Debug on the standard logger.
-func Debugf(format string, args ...interface{}) {
- std.Debugf(format, args...)
-}
-
-// Printf logs a message at level Info on the standard logger.
-func Printf(format string, args ...interface{}) {
- std.Printf(format, args...)
-}
-
-// Infof logs a message at level Info on the standard logger.
-func Infof(format string, args ...interface{}) {
- std.Infof(format, args...)
-}
-
-// Warnf logs a message at level Warn on the standard logger.
-func Warnf(format string, args ...interface{}) {
- std.Warnf(format, args...)
-}
-
-// Warningf logs a message at level Warn on the standard logger.
-func Warningf(format string, args ...interface{}) {
- std.Warningf(format, args...)
-}
-
-// Errorf logs a message at level Error on the standard logger.
-func Errorf(format string, args ...interface{}) {
- std.Errorf(format, args...)
-}
-
-// Panicf logs a message at level Panic on the standard logger.
-func Panicf(format string, args ...interface{}) {
- std.Panicf(format, args...)
-}
-
-// Fatalf logs a message at level Fatal on the standard logger.
-func Fatalf(format string, args ...interface{}) {
- std.Fatalf(format, args...)
-}
-
-// Debugln logs a message at level Debug on the standard logger.
-func Debugln(args ...interface{}) {
- std.Debugln(args...)
-}
-
-// Println logs a message at level Info on the standard logger.
-func Println(args ...interface{}) {
- std.Println(args...)
-}
-
-// Infoln logs a message at level Info on the standard logger.
-func Infoln(args ...interface{}) {
- std.Infoln(args...)
-}
-
-// Warnln logs a message at level Warn on the standard logger.
-func Warnln(args ...interface{}) {
- std.Warnln(args...)
-}
-
-// Warningln logs a message at level Warn on the standard logger.
-func Warningln(args ...interface{}) {
- std.Warningln(args...)
-}
-
-// Errorln logs a message at level Error on the standard logger.
-func Errorln(args ...interface{}) {
- std.Errorln(args...)
-}
-
-// Panicln logs a message at level Panic on the standard logger.
-func Panicln(args ...interface{}) {
- std.Panicln(args...)
-}
-
-// Fatalln logs a message at level Fatal on the standard logger.
-func Fatalln(args ...interface{}) {
- std.Fatalln(args...)
-}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/formatter.go b/newt/vendor/github.com/Sirupsen/logrus/formatter.go
deleted file mode 100644
index b5fbe934..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/formatter.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package logrus
-
-import "time"
-
-const DefaultTimestampFormat = time.RFC3339
-
-// The Formatter interface is used to implement a custom Formatter. It takes an
-// `Entry`. It exposes all the fields, including the default ones:
-//
-// * `entry.Data["msg"]`. The message passed from Info, Warn, Error ..
-// * `entry.Data["time"]`. The timestamp.
-// * `entry.Data["level"]. The level the entry was logged at.
-//
-// Any additional fields added with `WithField` or `WithFields` are also in
-// `entry.Data`. Format is expected to return an array of bytes which are then
-// logged to `logger.Out`.
-type Formatter interface {
- Format(*Entry) ([]byte, error)
-}
-
-// This is to not silently overwrite `time`, `msg` and `level` fields when
-// dumping it. If this code wasn't there doing:
-//
-// logrus.WithField("level", 1).Info("hello")
-//
-// Would just silently drop the user provided level. Instead with this code
-// it'll logged as:
-//
-// {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."}
-//
-// It's not exported because it's still using Data in an opinionated way. It's to
-// avoid code duplication between the two default formatters.
-func prefixFieldClashes(data Fields) {
- if t, ok := data["time"]; ok {
- data["fields.time"] = t
- }
-
- if m, ok := data["msg"]; ok {
- data["fields.msg"] = m
- }
-
- if l, ok := data["level"]; ok {
- data["fields.level"] = l
- }
-}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/json_formatter.go b/newt/vendor/github.com/Sirupsen/logrus/json_formatter.go
deleted file mode 100644
index f3729bff..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/json_formatter.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package logrus
-
-import (
- "encoding/json"
- "fmt"
-)
-
-type fieldKey string
-type FieldMap map[fieldKey]string
-
-const (
- FieldKeyMsg = "msg"
- FieldKeyLevel = "level"
- FieldKeyTime = "time"
-)
-
-func (f FieldMap) resolve(key fieldKey) string {
- if k, ok := f[key]; ok {
- return k
- }
-
- return string(key)
-}
-
-type JSONFormatter struct {
- // TimestampFormat sets the format used for marshaling timestamps.
- TimestampFormat string
-
- // FieldMap allows users to customize the names of keys for various fields.
- // As an example:
- // formatter := &JSONFormatter{
- // FieldMap: FieldMap{
- // FieldKeyTime: "@timestamp",
- // FieldKeyLevel: "@level",
- // FieldKeyLevel: "@message",
- // },
- // }
- FieldMap FieldMap
-}
-
-func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
- data := make(Fields, len(entry.Data)+3)
- for k, v := range entry.Data {
- switch v := v.(type) {
- case error:
- // Otherwise errors are ignored by `encoding/json`
- // https://github.com/Sirupsen/logrus/issues/137
- data[k] = v.Error()
- default:
- data[k] = v
- }
- }
- prefixFieldClashes(data)
-
- timestampFormat := f.TimestampFormat
- if timestampFormat == "" {
- timestampFormat = DefaultTimestampFormat
- }
-
- data[f.FieldMap.resolve(FieldKeyTime)] = entry.Time.Format(timestampFormat)
- data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message
- data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String()
-
- serialized, err := json.Marshal(data)
- if err != nil {
- return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
- }
- return append(serialized, '\n'), nil
-}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/logger.go b/newt/vendor/github.com/Sirupsen/logrus/logger.go
deleted file mode 100644
index b769f3d3..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/logger.go
+++ /dev/null
@@ -1,308 +0,0 @@
-package logrus
-
-import (
- "io"
- "os"
- "sync"
-)
-
-type Logger struct {
- // The logs are `io.Copy`'d to this in a mutex. It's common to set this to a
- // file, or leave it default which is `os.Stderr`. You can also set this to
- // something more adventorous, such as logging to Kafka.
- Out io.Writer
- // Hooks for the logger instance. These allow firing events based on logging
- // levels and log entries. For example, to send errors to an error tracking
- // service, log to StatsD or dump the core on fatal errors.
- Hooks LevelHooks
- // All log entries pass through the formatter before logged to Out. The
- // included formatters are `TextFormatter` and `JSONFormatter` for which
- // TextFormatter is the default. In development (when a TTY is attached) it
- // logs with colors, but to a file it wouldn't. You can easily implement your
- // own that implements the `Formatter` interface, see the `README` or included
- // formatters for examples.
- Formatter Formatter
- // The logging level the logger should log at. This is typically (and defaults
- // to) `logrus.Info`, which allows Info(), Warn(), Error() and Fatal() to be
- // logged. `logrus.Debug` is useful in
- Level Level
- // Used to sync writing to the log. Locking is enabled by Default
- mu MutexWrap
- // Reusable empty entry
- entryPool sync.Pool
-}
-
-type MutexWrap struct {
- lock sync.Mutex
- disabled bool
-}
-
-func (mw *MutexWrap) Lock() {
- if !mw.disabled {
- mw.lock.Lock()
- }
-}
-
-func (mw *MutexWrap) Unlock() {
- if !mw.disabled {
- mw.lock.Unlock()
- }
-}
-
-func (mw *MutexWrap) Disable() {
- mw.disabled = true
-}
-
-// Creates a new logger. Configuration should be set by changing `Formatter`,
-// `Out` and `Hooks` directly on the default logger instance. You can also just
-// instantiate your own:
-//
-// var log = &Logger{
-// Out: os.Stderr,
-// Formatter: new(JSONFormatter),
-// Hooks: make(LevelHooks),
-// Level: logrus.DebugLevel,
-// }
-//
-// It's recommended to make this a global instance called `log`.
-func New() *Logger {
- return &Logger{
- Out: os.Stderr,
- Formatter: new(TextFormatter),
- Hooks: make(LevelHooks),
- Level: InfoLevel,
- }
-}
-
-func (logger *Logger) newEntry() *Entry {
- entry, ok := logger.entryPool.Get().(*Entry)
- if ok {
- return entry
- }
- return NewEntry(logger)
-}
-
-func (logger *Logger) releaseEntry(entry *Entry) {
- logger.entryPool.Put(entry)
-}
-
-// Adds a field to the log entry, note that it doesn't log until you call
-// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry.
-// If you want multiple fields, use `WithFields`.
-func (logger *Logger) WithField(key string, value interface{}) *Entry {
- entry := logger.newEntry()
- defer logger.releaseEntry(entry)
- return entry.WithField(key, value)
-}
-
-// Adds a struct of fields to the log entry. All it does is call `WithField` for
-// each `Field`.
-func (logger *Logger) WithFields(fields Fields) *Entry {
- entry := logger.newEntry()
- defer logger.releaseEntry(entry)
- return entry.WithFields(fields)
-}
-
-// Add an error as single field to the log entry. All it does is call
-// `WithError` for the given `error`.
-func (logger *Logger) WithError(err error) *Entry {
- entry := logger.newEntry()
- defer logger.releaseEntry(entry)
- return entry.WithError(err)
-}
-
-func (logger *Logger) Debugf(format string, args ...interface{}) {
- if logger.Level >= DebugLevel {
- entry := logger.newEntry()
- entry.Debugf(format, args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Infof(format string, args ...interface{}) {
- if logger.Level >= InfoLevel {
- entry := logger.newEntry()
- entry.Infof(format, args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Printf(format string, args ...interface{}) {
- entry := logger.newEntry()
- entry.Printf(format, args...)
- logger.releaseEntry(entry)
-}
-
-func (logger *Logger) Warnf(format string, args ...interface{}) {
- if logger.Level >= WarnLevel {
- entry := logger.newEntry()
- entry.Warnf(format, args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Warningf(format string, args ...interface{}) {
- if logger.Level >= WarnLevel {
- entry := logger.newEntry()
- entry.Warnf(format, args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Errorf(format string, args ...interface{}) {
- if logger.Level >= ErrorLevel {
- entry := logger.newEntry()
- entry.Errorf(format, args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Fatalf(format string, args ...interface{}) {
- if logger.Level >= FatalLevel {
- entry := logger.newEntry()
- entry.Fatalf(format, args...)
- logger.releaseEntry(entry)
- }
- Exit(1)
-}
-
-func (logger *Logger) Panicf(format string, args ...interface{}) {
- if logger.Level >= PanicLevel {
- entry := logger.newEntry()
- entry.Panicf(format, args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Debug(args ...interface{}) {
- if logger.Level >= DebugLevel {
- entry := logger.newEntry()
- entry.Debug(args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Info(args ...interface{}) {
- if logger.Level >= InfoLevel {
- entry := logger.newEntry()
- entry.Info(args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Print(args ...interface{}) {
- entry := logger.newEntry()
- entry.Info(args...)
- logger.releaseEntry(entry)
-}
-
-func (logger *Logger) Warn(args ...interface{}) {
- if logger.Level >= WarnLevel {
- entry := logger.newEntry()
- entry.Warn(args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Warning(args ...interface{}) {
- if logger.Level >= WarnLevel {
- entry := logger.newEntry()
- entry.Warn(args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Error(args ...interface{}) {
- if logger.Level >= ErrorLevel {
- entry := logger.newEntry()
- entry.Error(args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Fatal(args ...interface{}) {
- if logger.Level >= FatalLevel {
- entry := logger.newEntry()
- entry.Fatal(args...)
- logger.releaseEntry(entry)
- }
- Exit(1)
-}
-
-func (logger *Logger) Panic(args ...interface{}) {
- if logger.Level >= PanicLevel {
- entry := logger.newEntry()
- entry.Panic(args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Debugln(args ...interface{}) {
- if logger.Level >= DebugLevel {
- entry := logger.newEntry()
- entry.Debugln(args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Infoln(args ...interface{}) {
- if logger.Level >= InfoLevel {
- entry := logger.newEntry()
- entry.Infoln(args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Println(args ...interface{}) {
- entry := logger.newEntry()
- entry.Println(args...)
- logger.releaseEntry(entry)
-}
-
-func (logger *Logger) Warnln(args ...interface{}) {
- if logger.Level >= WarnLevel {
- entry := logger.newEntry()
- entry.Warnln(args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Warningln(args ...interface{}) {
- if logger.Level >= WarnLevel {
- entry := logger.newEntry()
- entry.Warnln(args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Errorln(args ...interface{}) {
- if logger.Level >= ErrorLevel {
- entry := logger.newEntry()
- entry.Errorln(args...)
- logger.releaseEntry(entry)
- }
-}
-
-func (logger *Logger) Fatalln(args ...interface{}) {
- if logger.Level >= FatalLevel {
- entry := logger.newEntry()
- entry.Fatalln(args...)
- logger.releaseEntry(entry)
- }
- Exit(1)
-}
-
-func (logger *Logger) Panicln(args ...interface{}) {
- if logger.Level >= PanicLevel {
- entry := logger.newEntry()
- entry.Panicln(args...)
- logger.releaseEntry(entry)
- }
-}
-
-//When file is opened with appending mode, it's safe to
-//write concurrently to a file (within 4k message on Linux).
-//In these cases user can choose to disable the lock.
-func (logger *Logger) SetNoLock() {
- logger.mu.Disable()
-}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/logrus.go b/newt/vendor/github.com/Sirupsen/logrus/logrus.go
deleted file mode 100644
index e5966911..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/logrus.go
+++ /dev/null
@@ -1,143 +0,0 @@
-package logrus
-
-import (
- "fmt"
- "log"
- "strings"
-)
-
-// Fields type, used to pass to `WithFields`.
-type Fields map[string]interface{}
-
-// Level type
-type Level uint8
-
-// Convert the Level to a string. E.g. PanicLevel becomes "panic".
-func (level Level) String() string {
- switch level {
- case DebugLevel:
- return "debug"
- case InfoLevel:
- return "info"
- case WarnLevel:
- return "warning"
- case ErrorLevel:
- return "error"
- case FatalLevel:
- return "fatal"
- case PanicLevel:
- return "panic"
- }
-
- return "unknown"
-}
-
-// ParseLevel takes a string level and returns the Logrus log level constant.
-func ParseLevel(lvl string) (Level, error) {
- switch strings.ToLower(lvl) {
- case "panic":
- return PanicLevel, nil
- case "fatal":
- return FatalLevel, nil
- case "error":
- return ErrorLevel, nil
- case "warn", "warning":
- return WarnLevel, nil
- case "info":
- return InfoLevel, nil
- case "debug":
- return DebugLevel, nil
- }
-
- var l Level
- return l, fmt.Errorf("not a valid logrus Level: %q", lvl)
-}
-
-// A constant exposing all logging levels
-var AllLevels = []Level{
- PanicLevel,
- FatalLevel,
- ErrorLevel,
- WarnLevel,
- InfoLevel,
- DebugLevel,
-}
-
-// These are the different logging levels. You can set the logging level to log
-// on your instance of logger, obtained with `logrus.New()`.
-const (
- // PanicLevel level, highest level of severity. Logs and then calls panic with the
- // message passed to Debug, Info, ...
- PanicLevel Level = iota
- // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the
- // logging level is set to Panic.
- FatalLevel
- // ErrorLevel level. Logs. Used for errors that should definitely be noted.
- // Commonly used for hooks to send errors to an error tracking service.
- ErrorLevel
- // WarnLevel level. Non-critical entries that deserve eyes.
- WarnLevel
- // InfoLevel level. General operational entries about what's going on inside the
- // application.
- InfoLevel
- // DebugLevel level. Usually only enabled when debugging. Very verbose logging.
- DebugLevel
-)
-
-// Won't compile if StdLogger can't be realized by a log.Logger
-var (
- _ StdLogger = &log.Logger{}
- _ StdLogger = &Entry{}
- _ StdLogger = &Logger{}
-)
-
-// StdLogger is what your logrus-enabled library should take, that way
-// it'll accept a stdlib logger and a logrus logger. There's no standard
-// interface, this is the closest we get, unfortunately.
-type StdLogger interface {
- Print(...interface{})
- Printf(string, ...interface{})
- Println(...interface{})
-
- Fatal(...interface{})
- Fatalf(string, ...interface{})
- Fatalln(...interface{})
-
- Panic(...interface{})
- Panicf(string, ...interface{})
- Panicln(...interface{})
-}
-
-// The FieldLogger interface generalizes the Entry and Logger types
-type FieldLogger interface {
- WithField(key string, value interface{}) *Entry
- WithFields(fields Fields) *Entry
- WithError(err error) *Entry
-
- Debugf(format string, args ...interface{})
- Infof(format string, args ...interface{})
- Printf(format string, args ...interface{})
- Warnf(format string, args ...interface{})
- Warningf(format string, args ...interface{})
- Errorf(format string, args ...interface{})
- Fatalf(format string, args ...interface{})
- Panicf(format string, args ...interface{})
-
- Debug(args ...interface{})
- Info(args ...interface{})
- Print(args ...interface{})
- Warn(args ...interface{})
- Warning(args ...interface{})
- Error(args ...interface{})
- Fatal(args ...interface{})
- Panic(args ...interface{})
-
- Debugln(args ...interface{})
- Infoln(args ...interface{})
- Println(args ...interface{})
- Warnln(args ...interface{})
- Warningln(args ...interface{})
- Errorln(args ...interface{})
- Fatalln(args ...interface{})
- Panicln(args ...interface{})
-}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/terminal_appengine.go b/newt/vendor/github.com/Sirupsen/logrus/terminal_appengine.go
deleted file mode 100644
index 1960169e..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/terminal_appengine.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// +build appengine
-
-package logrus
-
-// IsTerminal returns true if stderr's file descriptor is a terminal.
-func IsTerminal() bool {
- return true
-}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/terminal_bsd.go b/newt/vendor/github.com/Sirupsen/logrus/terminal_bsd.go
deleted file mode 100644
index 5f6be4d3..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/terminal_bsd.go
+++ /dev/null
@@ -1,10 +0,0 @@
-// +build darwin freebsd openbsd netbsd dragonfly
-// +build !appengine
-
-package logrus
-
-import "syscall"
-
-const ioctlReadTermios = syscall.TIOCGETA
-
-type Termios syscall.Termios
diff --git a/newt/vendor/github.com/Sirupsen/logrus/terminal_linux.go b/newt/vendor/github.com/Sirupsen/logrus/terminal_linux.go
deleted file mode 100644
index 308160ca..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/terminal_linux.go
+++ /dev/null
@@ -1,14 +0,0 @@
-// Based on ssh/terminal:
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build !appengine
-
-package logrus
-
-import "syscall"
-
-const ioctlReadTermios = syscall.TCGETS
-
-type Termios syscall.Termios
diff --git a/newt/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go b/newt/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go
deleted file mode 100644
index 329038f6..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go
+++ /dev/null
@@ -1,22 +0,0 @@
-// Based on ssh/terminal:
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build linux darwin freebsd openbsd netbsd dragonfly
-// +build !appengine
-
-package logrus
-
-import (
- "syscall"
- "unsafe"
-)
-
-// IsTerminal returns true if stderr's file descriptor is a terminal.
-func IsTerminal() bool {
- fd := syscall.Stderr
- var termios Termios
- _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
- return err == 0
-}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/terminal_solaris.go b/newt/vendor/github.com/Sirupsen/logrus/terminal_solaris.go
deleted file mode 100644
index a3c6f6e7..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/terminal_solaris.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// +build solaris,!appengine
-
-package logrus
-
-import (
- "os"
-
- "golang.org/x/sys/unix"
-)
-
-// IsTerminal returns true if the given file descriptor is a terminal.
-func IsTerminal() bool {
- _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA)
- return err == nil
-}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/terminal_windows.go b/newt/vendor/github.com/Sirupsen/logrus/terminal_windows.go
deleted file mode 100644
index 3727e8ad..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/terminal_windows.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Based on ssh/terminal:
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build windows,!appengine
-
-package logrus
-
-import (
- "syscall"
- "unsafe"
-)
-
-var kernel32 = syscall.NewLazyDLL("kernel32.dll")
-
-var (
- procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
-)
-
-// IsTerminal returns true if stderr's file descriptor is a terminal.
-func IsTerminal() bool {
- fd := syscall.Stderr
- var st uint32
- r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
- return r != 0 && e == 0
-}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/text_formatter.go b/newt/vendor/github.com/Sirupsen/logrus/text_formatter.go
deleted file mode 100644
index 9114b3ca..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/text_formatter.go
+++ /dev/null
@@ -1,168 +0,0 @@
-package logrus
-
-import (
- "bytes"
- "fmt"
- "runtime"
- "sort"
- "strings"
- "time"
-)
-
-const (
- nocolor = 0
- red = 31
- green = 32
- yellow = 33
- blue = 34
- gray = 37
-)
-
-var (
- baseTimestamp time.Time
- isTerminal bool
-)
-
-func init() {
- baseTimestamp = time.Now()
- isTerminal = IsTerminal()
-}
-
-func miniTS() int {
- return int(time.Since(baseTimestamp) / time.Second)
-}
-
-type TextFormatter struct {
- // Set to true to bypass checking for a TTY before outputting colors.
- ForceColors bool
-
- // Force disabling colors.
- DisableColors bool
-
- // Disable timestamp logging. useful when output is redirected to logging
- // system that already adds timestamps.
- DisableTimestamp bool
-
- // Enable logging the full timestamp when a TTY is attached instead of just
- // the time passed since beginning of execution.
- FullTimestamp bool
-
- // TimestampFormat to use for display when a full timestamp is printed
- TimestampFormat string
-
- // The fields are sorted by default for a consistent output. For applications
- // that log extremely frequently and don't use the JSON formatter this may not
- // be desired.
- DisableSorting bool
-}
-
-func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
- var b *bytes.Buffer
- var keys []string = make([]string, 0, len(entry.Data))
- for k := range entry.Data {
- keys = append(keys, k)
- }
-
- if !f.DisableSorting {
- sort.Strings(keys)
- }
- if entry.Buffer != nil {
- b = entry.Buffer
- } else {
- b = &bytes.Buffer{}
- }
-
- prefixFieldClashes(entry.Data)
-
- isColorTerminal := isTerminal && (runtime.GOOS != "windows")
- isColored := (f.ForceColors || isColorTerminal) && !f.DisableColors
-
- timestampFormat := f.TimestampFormat
- if timestampFormat == "" {
- timestampFormat = DefaultTimestampFormat
- }
- if isColored {
- f.printColored(b, entry, keys, timestampFormat)
- } else {
- if !f.DisableTimestamp {
- f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat))
- }
- f.appendKeyValue(b, "level", entry.Level.String())
- if entry.Message != "" {
- f.appendKeyValue(b, "msg", entry.Message)
- }
- for _, key := range keys {
- f.appendKeyValue(b, key, entry.Data[key])
- }
- }
-
- b.WriteByte('\n')
- return b.Bytes(), nil
-}
-
-func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, timestampFormat string) {
- var levelColor int
- switch entry.Level {
- case DebugLevel:
- levelColor = gray
- case WarnLevel:
- levelColor = yellow
- case ErrorLevel, FatalLevel, PanicLevel:
- levelColor = red
- default:
- levelColor = blue
- }
-
- levelText := strings.ToUpper(entry.Level.String())[0:4]
-
- if !f.FullTimestamp {
- fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, miniTS(), entry.Message)
- } else {
- fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message)
- }
- for _, k := range keys {
- v := entry.Data[k]
- fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=", levelColor, k)
- f.appendValue(b, v)
- }
-}
-
-func needsQuoting(text string) bool {
- for _, ch := range text {
- if !((ch >= 'a' && ch <= 'z') ||
- (ch >= 'A' && ch <= 'Z') ||
- (ch >= '0' && ch <= '9') ||
- ch == '-' || ch == '.') {
- return true
- }
- }
- return false
-}
-
-func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) {
-
- b.WriteString(key)
- b.WriteByte('=')
- f.appendValue(b, value)
- b.WriteByte(' ')
-}
-
-func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) {
- switch value := value.(type) {
- case string:
- if !needsQuoting(value) {
- b.WriteString(value)
- } else {
- fmt.Fprintf(b, "%q", value)
- }
- case error:
- errmsg := value.Error()
- if !needsQuoting(errmsg) {
- b.WriteString(errmsg)
- } else {
- fmt.Fprintf(b, "%q", errmsg)
- }
- default:
- fmt.Fprint(b, value)
- }
-}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/writer.go b/newt/vendor/github.com/Sirupsen/logrus/writer.go
deleted file mode 100644
index f74d2aa5..00000000
--- a/newt/vendor/github.com/Sirupsen/logrus/writer.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package logrus
-
-import (
- "bufio"
- "io"
- "runtime"
-)
-
-func (logger *Logger) Writer() *io.PipeWriter {
- return logger.WriterLevel(InfoLevel)
-}
-
-func (logger *Logger) WriterLevel(level Level) *io.PipeWriter {
- reader, writer := io.Pipe()
-
- var printFunc func(args ...interface{})
- switch level {
- case DebugLevel:
- printFunc = logger.Debug
- case InfoLevel:
- printFunc = logger.Info
- case WarnLevel:
- printFunc = logger.Warn
- case ErrorLevel:
- printFunc = logger.Error
- case FatalLevel:
- printFunc = logger.Fatal
- case PanicLevel:
- printFunc = logger.Panic
- default:
- printFunc = logger.Print
- }
-
- go logger.writerScanner(reader, printFunc)
- runtime.SetFinalizer(writer, writerFinalizer)
-
- return writer
-}
-
-func (logger *Logger) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) {
- scanner := bufio.NewScanner(reader)
- for scanner.Scan() {
- printFunc(scanner.Text())
- }
- if err := scanner.Err(); err != nil {
- logger.Errorf("Error while reading from Writer: %s", err)
- }
- reader.Close()
-}
-
-func writerFinalizer(writer *io.PipeWriter) {
- writer.Close()
-}
diff --git a/newt/vendor/github.com/mitchellh/mapstructure/.travis.yml b/newt/vendor/github.com/mitchellh/mapstructure/.travis.yml
deleted file mode 100644
index 7f3fe9a9..00000000
--- a/newt/vendor/github.com/mitchellh/mapstructure/.travis.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-language: go
-
-go:
- - 1.4
-
-script:
- - go test
diff --git a/newt/vendor/github.com/mitchellh/mapstructure/decode_hooks.go b/newt/vendor/github.com/mitchellh/mapstructure/decode_hooks.go
deleted file mode 100644
index 115ae67c..00000000
--- a/newt/vendor/github.com/mitchellh/mapstructure/decode_hooks.go
+++ /dev/null
@@ -1,154 +0,0 @@
-package mapstructure
-
-import (
- "errors"
- "reflect"
- "strconv"
- "strings"
- "time"
-)
-
-// typedDecodeHook takes a raw DecodeHookFunc (an interface{}) and turns
-// it into the proper DecodeHookFunc type, such as DecodeHookFuncType.
-func typedDecodeHook(h DecodeHookFunc) DecodeHookFunc {
- // Create variables here so we can reference them with the reflect pkg
- var f1 DecodeHookFuncType
- var f2 DecodeHookFuncKind
-
- // Fill in the variables into this interface and the rest is done
- // automatically using the reflect package.
- potential := []interface{}{f1, f2}
-
- v := reflect.ValueOf(h)
- vt := v.Type()
- for _, raw := range potential {
- pt := reflect.ValueOf(raw).Type()
- if vt.ConvertibleTo(pt) {
- return v.Convert(pt).Interface()
- }
- }
-
- return nil
-}
-
-// DecodeHookExec executes the given decode hook. This should be used
-// since it'll naturally degrade to the older backwards compatible DecodeHookFunc
-// that took reflect.Kind instead of reflect.Type.
-func DecodeHookExec(
- raw DecodeHookFunc,
- from reflect.Type, to reflect.Type,
- data interface{}) (interface{}, error) {
- // Build our arguments that reflect expects
- argVals := make([]reflect.Value, 3)
- argVals[0] = reflect.ValueOf(from)
- argVals[1] = reflect.ValueOf(to)
- argVals[2] = reflect.ValueOf(data)
-
- switch f := typedDecodeHook(raw).(type) {
- case DecodeHookFuncType:
- return f(from, to, data)
- case DecodeHookFuncKind:
- return f(from.Kind(), to.Kind(), data)
- default:
- return nil, errors.New("invalid decode hook signature")
- }
-}
-
-// ComposeDecodeHookFunc creates a single DecodeHookFunc that
-// automatically composes multiple DecodeHookFuncs.
-//
-// The composed funcs are called in order, with the result of the
-// previous transformation.
-func ComposeDecodeHookFunc(fs ...DecodeHookFunc) DecodeHookFunc {
- return func(
- f reflect.Type,
- t reflect.Type,
- data interface{}) (interface{}, error) {
- var err error
- for _, f1 := range fs {
- data, err = DecodeHookExec(f1, f, t, data)
- if err != nil {
- return nil, err
- }
-
- // Modify the from kind to be correct with the new data
- f = nil
- if val := reflect.ValueOf(data); val.IsValid() {
- f = val.Type()
- }
- }
-
- return data, nil
- }
-}
-
-// StringToSliceHookFunc returns a DecodeHookFunc that converts
-// string to []string by splitting on the given sep.
-func StringToSliceHookFunc(sep string) DecodeHookFunc {
- return func(
- f reflect.Kind,
- t reflect.Kind,
- data interface{}) (interface{}, error) {
- if f != reflect.String || t != reflect.Slice {
- return data, nil
- }
-
- raw := data.(string)
- if raw == "" {
- return []string{}, nil
- }
-
- return strings.Split(raw, sep), nil
- }
-}
-
-// StringToTimeDurationHookFunc returns a DecodeHookFunc that converts
-// strings to time.Duration.
-func StringToTimeDurationHookFunc() DecodeHookFunc {
- return func(
- f reflect.Type,
- t reflect.Type,
- data interface{}) (interface{}, error) {
- if f.Kind() != reflect.String {
- return data, nil
- }
- if t != reflect.TypeOf(time.Duration(5)) {
- return data, nil
- }
-
- // Convert it by parsing
- return time.ParseDuration(data.(string))
- }
-}
-
-func WeaklyTypedHook(
- f reflect.Kind,
- t reflect.Kind,
- data interface{}) (interface{}, error) {
- dataVal := reflect.ValueOf(data)
- switch t {
- case reflect.String:
- switch f {
- case reflect.Bool:
- if dataVal.Bool() {
- return "1", nil
- } else {
- return "0", nil
- }
- case reflect.Float32:
- return strconv.FormatFloat(dataVal.Float(), 'f', -1, 64), nil
- case reflect.Int:
- return strconv.FormatInt(dataVal.Int(), 10), nil
- case reflect.Slice:
- dataType := dataVal.Type()
- elemKind := dataType.Elem().Kind()
- if elemKind == reflect.Uint8 {
- return string(dataVal.Interface().([]uint8)), nil
- }
- case reflect.Uint:
- return strconv.FormatUint(dataVal.Uint(), 10), nil
- }
- }
-
- return data, nil
-}
diff --git a/newt/vendor/github.com/mitchellh/mapstructure/mapstructure.go b/newt/vendor/github.com/mitchellh/mapstructure/mapstructure.go
deleted file mode 100644
index b0ab89b6..00000000
--- a/newt/vendor/github.com/mitchellh/mapstructure/mapstructure.go
+++ /dev/null
@@ -1,782 +0,0 @@
-// The mapstructure package exposes functionality to convert an
-// abitrary map[string]interface{} into a native Go structure.
-//
-// The Go structure can be arbitrarily complex, containing slices,
-// other structs, etc. and the decoder will properly decode nested
-// maps and so on into the proper structures in the native Go struct.
-// See the examples to see what the decoder is capable of.
-package mapstructure
-
-import (
- "encoding/json"
- "errors"
- "fmt"
- "reflect"
- "sort"
- "strconv"
- "strings"
-)
-
-// DecodeHookFunc is the callback function that can be used for
-// data transformations. See "DecodeHook" in the DecoderConfig
-// struct.
-//
-// The type should be DecodeHookFuncType or DecodeHookFuncKind.
-// Either is accepted. Types are a superset of Kinds (Types can return
-// Kinds) and are generally a richer thing to use, but Kinds are simpler
-// if you only need those.
-//
-// The reason DecodeHookFunc is multi-typed is for backwards compatibility:
-// we started with Kinds and then realized Types were the better solution,
-// but have a promise to not break backwards compat so we now support
-// both.
-type DecodeHookFunc interface{}
-
-type DecodeHookFuncType func(reflect.Type, reflect.Type, interface{}) (interface{}, error)
-type DecodeHookFuncKind func(reflect.Kind, reflect.Kind, interface{}) (interface{}, error)
-
-// DecoderConfig is the configuration that is used to create a new decoder
-// and allows customization of various aspects of decoding.
-type DecoderConfig struct {
- // DecodeHook, if set, will be called before any decoding and any
- // type conversion (if WeaklyTypedInput is on). This lets you modify
- // the values before they're set down onto the resulting struct.
- //
- // If an error is returned, the entire decode will fail with that
- // error.
- DecodeHook DecodeHookFunc
-
- // If ErrorUnused is true, then it is an error for there to exist
- // keys in the original map that were unused in the decoding process
- // (extra keys).
- ErrorUnused bool
-
- // ZeroFields, if set to true, will zero fields before writing them.
- // For example, a map will be emptied before decoded values are put in
- // it. If this is false, a map will be merged.
- ZeroFields bool
-
- // If WeaklyTypedInput is true, the decoder will make the following
- // "weak" conversions:
- //
- // - bools to string (true = "1", false = "0")
- // - numbers to string (base 10)
- // - bools to int/uint (true = 1, false = 0)
- // - strings to int/uint (base implied by prefix)
- // - int to bool (true if value != 0)
- // - string to bool (accepts: 1, t, T, TRUE, true, True, 0, f, F,
- // FALSE, false, False. Anything else is an error)
- // - empty array = empty map and vice versa
- // - negative numbers to overflowed uint values (base 10)
- // - slice of maps to a merged map
- //
- WeaklyTypedInput bool
-
- // Metadata is the struct that will contain extra metadata about
- // the decoding. If this is nil, then no metadata will be tracked.
- Metadata *Metadata
-
- // Result is a pointer to the struct that will contain the decoded
- // value.
- Result interface{}
-
- // The tag name that mapstructure reads for field names. This
- // defaults to "mapstructure"
- TagName string
-}
-
-// A Decoder takes a raw interface value and turns it into structured
-// data, keeping track of rich error information along the way in case
-// anything goes wrong. Unlike the basic top-level Decode method, you can
-// more finely control how the Decoder behaves using the DecoderConfig
-// structure. The top-level Decode method is just a convenience that sets
-// up the most basic Decoder.
-type Decoder struct {
- config *DecoderConfig
-}
-
-// Metadata contains information about decoding a structure that
-// is tedious or difficult to get otherwise.
-type Metadata struct {
- // Keys are the keys of the structure which were successfully decoded
- Keys []string
-
- // Unused is a slice of keys that were found in the raw value but
- // weren't decoded since there was no matching field in the result interface
- Unused []string
-}
-
-// Decode takes a map and uses reflection to convert it into the
-// given Go native structure. val must be a pointer to a struct.
-func Decode(m interface{}, rawVal interface{}) error {
- config := &DecoderConfig{
- Metadata: nil,
- Result: rawVal,
- }
-
- decoder, err := NewDecoder(config)
- if err != nil {
- return err
- }
-
- return decoder.Decode(m)
-}
-
-// WeakDecode is the same as Decode but is shorthand to enable
-// WeaklyTypedInput. See DecoderConfig for more info.
-func WeakDecode(input, output interface{}) error {
- config := &DecoderConfig{
- Metadata: nil,
- Result: output,
- WeaklyTypedInput: true,
- }
-
- decoder, err := NewDecoder(config)
- if err != nil {
- return err
- }
-
- return decoder.Decode(input)
-}
-
-// NewDecoder returns a new decoder for the given configuration. Once
-// a decoder has been returned, the same configuration must not be used
-// again.
-func NewDecoder(config *DecoderConfig) (*Decoder, error) {
- val := reflect.ValueOf(config.Result)
- if val.Kind() != reflect.Ptr {
- return nil, errors.New("result must be a pointer")
- }
-
- val = val.Elem()
- if !val.CanAddr() {
- return nil, errors.New("result must be addressable (a pointer)")
- }
-
- if config.Metadata != nil {
- if config.Metadata.Keys == nil {
- config.Metadata.Keys = make([]string, 0)
- }
-
- if config.Metadata.Unused == nil {
- config.Metadata.Unused = make([]string, 0)
- }
- }
-
- if config.TagName == "" {
- config.TagName = "mapstructure"
- }
-
- result := &Decoder{
- config: config,
- }
-
- return result, nil
-}
-
-// Decode decodes the given raw interface to the target pointer specified
-// by the configuration.
-func (d *Decoder) Decode(raw interface{}) error {
- return d.decode("", raw, reflect.ValueOf(d.config.Result).Elem())
-}
-
-// Decodes an unknown data type into a specific reflection value.
-func (d *Decoder) decode(name string, data interface{}, val reflect.Value) error {
- if data == nil {
- // If the data is nil, then we don't set anything.
- return nil
- }
-
- dataVal := reflect.ValueOf(data)
- if !dataVal.IsValid() {
- // If the data value is invalid, then we just set the value
- // to be the zero value.
- val.Set(reflect.Zero(val.Type()))
- return nil
- }
-
- if d.config.DecodeHook != nil {
- // We have a DecodeHook, so let's pre-process the data.
- var err error
- data, err = DecodeHookExec(
- d.config.DecodeHook,
- dataVal.Type(), val.Type(), data)
- if err != nil {
- return err
- }
- }
-
- var err error
- dataKind := getKind(val)
- switch dataKind {
- case reflect.Bool:
- err = d.decodeBool(name, data, val)
- case reflect.Interface:
- err = d.decodeBasic(name, data, val)
- case reflect.String:
- err = d.decodeString(name, data, val)
- case reflect.Int:
- err = d.decodeInt(name, data, val)
- case reflect.Uint:
- err = d.decodeUint(name, data, val)
- case reflect.Float32:
- err = d.decodeFloat(name, data, val)
- case reflect.Struct:
- err = d.decodeStruct(name, data, val)
- case reflect.Map:
- err = d.decodeMap(name, data, val)
- case reflect.Ptr:
- err = d.decodePtr(name, data, val)
- case reflect.Slice:
- err = d.decodeSlice(name, data, val)
- default:
- // If we reached this point then we weren't able to decode it
- return fmt.Errorf("%s: unsupported type: %s", name, dataKind)
- }
-
- // If we reached here, then we successfully decoded SOMETHING, so
- // mark the key as used if we're tracking metadata.
- if d.config.Metadata != nil && name != "" {
- d.config.Metadata.Keys = append(d.config.Metadata.Keys, name)
- }
-
- return err
-}
-
-// This decodes a basic type (bool, int, string, etc.) and sets the
-// value to "data" of that type.
-func (d *Decoder) decodeBasic(name string, data interface{}, val reflect.Value) error {
- dataVal := reflect.ValueOf(data)
- if !dataVal.IsValid() {
- dataVal = reflect.Zero(val.Type())
- }
-
- dataValType := dataVal.Type()
- if !dataValType.AssignableTo(val.Type()) {
- return fmt.Errorf(
- "'%s' expected type '%s', got '%s'",
- name, val.Type(), dataValType)
- }
-
- val.Set(dataVal)
- return nil
-}
-
-func (d *Decoder) decodeString(name string, data interface{}, val reflect.Value) error {
- dataVal := reflect.ValueOf(data)
- dataKind := getKind(dataVal)
-
- converted := true
- switch {
- case dataKind == reflect.String:
- val.SetString(dataVal.String())
- case dataKind == reflect.Bool && d.config.WeaklyTypedInput:
- if dataVal.Bool() {
- val.SetString("1")
- } else {
- val.SetString("0")
- }
- case dataKind == reflect.Int && d.config.WeaklyTypedInput:
- val.SetString(strconv.FormatInt(dataVal.Int(), 10))
- case dataKind == reflect.Uint && d.config.WeaklyTypedInput:
- val.SetString(strconv.FormatUint(dataVal.Uint(), 10))
- case dataKind == reflect.Float32 && d.config.WeaklyTypedInput:
- val.SetString(strconv.FormatFloat(dataVal.Float(), 'f', -1, 64))
- case dataKind == reflect.Slice && d.config.WeaklyTypedInput:
- dataType := dataVal.Type()
- elemKind := dataType.Elem().Kind()
- switch {
- case elemKind == reflect.Uint8:
- val.SetString(string(dataVal.Interface().([]uint8)))
- default:
- converted = false
- }
- default:
- converted = false
- }
-
- if !converted {
- return fmt.Errorf(
- "'%s' expected type '%s', got unconvertible type '%s'",
- name, val.Type(), dataVal.Type())
- }
-
- return nil
-}
-
-func (d *Decoder) decodeInt(name string, data interface{}, val reflect.Value) error {
- dataVal := reflect.ValueOf(data)
- dataKind := getKind(dataVal)
- dataType := dataVal.Type()
-
- switch {
- case dataKind == reflect.Int:
- val.SetInt(dataVal.Int())
- case dataKind == reflect.Uint:
- val.SetInt(int64(dataVal.Uint()))
- case dataKind == reflect.Float32:
- val.SetInt(int64(dataVal.Float()))
- case dataKind == reflect.Bool && d.config.WeaklyTypedInput:
- if dataVal.Bool() {
- val.SetInt(1)
- } else {
- val.SetInt(0)
- }
- case dataKind == reflect.String && d.config.WeaklyTypedInput:
- i, err := strconv.ParseInt(dataVal.String(), 0, val.Type().Bits())
- if err == nil {
- val.SetInt(i)
- } else {
- return fmt.Errorf("cannot parse '%s' as int: %s", name, err)
- }
- case dataType.PkgPath() == "encoding/json" && dataType.Name() == "Number":
- jn := data.(json.Number)
- i, err := jn.Int64()
- if err != nil {
- return fmt.Errorf(
- "error decoding json.Number into %s: %s", name, err)
- }
- val.SetInt(i)
- default:
- return fmt.Errorf(
- "'%s' expected type '%s', got unconvertible type '%s'",
- name, val.Type(), dataVal.Type())
- }
-
- return nil
-}
-
-func (d *Decoder) decodeUint(name string, data interface{}, val reflect.Value) error {
- dataVal := reflect.ValueOf(data)
- dataKind := getKind(dataVal)
-
- switch {
- case dataKind == reflect.Int:
- i := dataVal.Int()
- if i < 0 && !d.config.WeaklyTypedInput {
- return fmt.Errorf("cannot parse '%s', %d overflows uint",
- name, i)
- }
- val.SetUint(uint64(i))
- case dataKind == reflect.Uint:
- val.SetUint(dataVal.Uint())
- case dataKind == reflect.Float32:
- f := dataVal.Float()
- if f < 0 && !d.config.WeaklyTypedInput {
- return fmt.Errorf("cannot parse '%s', %f overflows uint",
- name, f)
- }
- val.SetUint(uint64(f))
- case dataKind == reflect.Bool && d.config.WeaklyTypedInput:
- if dataVal.Bool() {
- val.SetUint(1)
- } else {
- val.SetUint(0)
- }
- case dataKind == reflect.String && d.config.WeaklyTypedInput:
- i, err := strconv.ParseUint(dataVal.String(), 0, val.Type().Bits())
- if err == nil {
- val.SetUint(i)
- } else {
- return fmt.Errorf("cannot parse '%s' as uint: %s", name, err)
- }
- default:
- return fmt.Errorf(
- "'%s' expected type '%s', got unconvertible type '%s'",
- name, val.Type(), dataVal.Type())
- }
-
- return nil
-}
-
-func (d *Decoder) decodeBool(name string, data interface{}, val reflect.Value) error {
- dataVal := reflect.ValueOf(data)
- dataKind := getKind(dataVal)
-
- switch {
- case dataKind == reflect.Bool:
- val.SetBool(dataVal.Bool())
- case dataKind == reflect.Int && d.config.WeaklyTypedInput:
- val.SetBool(dataVal.Int() != 0)
- case dataKind == reflect.Uint && d.config.WeaklyTypedInput:
- val.SetBool(dataVal.Uint() != 0)
- case dataKind == reflect.Float32 && d.config.WeaklyTypedInput:
- val.SetBool(dataVal.Float() != 0)
- case dataKind == reflect.String && d.config.WeaklyTypedInput:
- b, err := strconv.ParseBool(dataVal.String())
- if err == nil {
- val.SetBool(b)
- } else if dataVal.String() == "" {
- val.SetBool(false)
- } else {
- return fmt.Errorf("cannot parse '%s' as bool: %s", name, err)
- }
- default:
- return fmt.Errorf(
- "'%s' expected type '%s', got unconvertible type '%s'",
- name, val.Type(), dataVal.Type())
- }
-
- return nil
-}
-
-func (d *Decoder) decodeFloat(name string, data interface{}, val reflect.Value) error {
- dataVal := reflect.ValueOf(data)
- dataKind := getKind(dataVal)
- dataType := dataVal.Type()
-
- switch {
- case dataKind == reflect.Int:
- val.SetFloat(float64(dataVal.Int()))
- case dataKind == reflect.Uint:
- val.SetFloat(float64(dataVal.Uint()))
- case dataKind == reflect.Float32:
- val.SetFloat(float64(dataVal.Float()))
- case dataKind == reflect.Bool && d.config.WeaklyTypedInput:
- if dataVal.Bool() {
- val.SetFloat(1)
- } else {
- val.SetFloat(0)
- }
- case dataKind == reflect.String && d.config.WeaklyTypedInput:
- f, err := strconv.ParseFloat(dataVal.String(), val.Type().Bits())
- if err == nil {
- val.SetFloat(f)
- } else {
- return fmt.Errorf("cannot parse '%s' as float: %s", name, err)
- }
- case dataType.PkgPath() == "encoding/json" && dataType.Name() == "Number":
- jn := data.(json.Number)
- i, err := jn.Float64()
- if err != nil {
- return fmt.Errorf(
- "error decoding json.Number into %s: %s", name, err)
- }
- val.SetFloat(i)
- default:
- return fmt.Errorf(
- "'%s' expected type '%s', got unconvertible type '%s'",
- name, val.Type(), dataVal.Type())
- }
-
- return nil
-}
-
-func (d *Decoder) decodeMap(name string, data interface{}, val reflect.Value) error {
- valType := val.Type()
- valKeyType := valType.Key()
- valElemType := valType.Elem()
-
- // By default we overwrite keys in the current map
- valMap := val
-
- // If the map is nil or we're purposely zeroing fields, make a new map
- if valMap.IsNil() || d.config.ZeroFields {
- // Make a new map to hold our result
- mapType := reflect.MapOf(valKeyType, valElemType)
- valMap = reflect.MakeMap(mapType)
- }
-
- // Check input type
- dataVal := reflect.Indirect(reflect.ValueOf(data))
- if dataVal.Kind() != reflect.Map {
- // In weak mode, we accept a slice of maps as an input...
- if d.config.WeaklyTypedInput {
- switch dataVal.Kind() {
- case reflect.Array, reflect.Slice:
- // Special case for BC reasons (covered by tests)
- if dataVal.Len() == 0 {
- val.Set(valMap)
- return nil
- }
-
- for i := 0; i < dataVal.Len(); i++ {
- err := d.decode(
- fmt.Sprintf("%s[%d]", name, i),
- dataVal.Index(i).Interface(), val)
- if err != nil {
- return err
- }
- }
-
- return nil
- }
- }
-
- return fmt.Errorf("'%s' expected a map, got '%s'", name, dataVal.Kind())
- }
-
- // Accumulate errors
- errors := make([]string, 0)
-
- for _, k := range dataVal.MapKeys() {
- fieldName := fmt.Sprintf("%s[%s]", name, k)
-
- // First decode the key into the proper type
- currentKey := reflect.Indirect(reflect.New(valKeyType))
- if err := d.decode(fieldName, k.Interface(), currentKey); err != nil {
- errors = appendErrors(errors, err)
- continue
- }
-
- // Next decode the data into the proper type
- v := dataVal.MapIndex(k).Interface()
- currentVal := reflect.Indirect(reflect.New(valElemType))
- if err := d.decode(fieldName, v, currentVal); err != nil {
- errors = appendErrors(errors, err)
- continue
- }
-
- valMap.SetMapIndex(currentKey, currentVal)
- }
-
- // Set the built up map to the value
- val.Set(valMap)
-
- // If we had errors, return those
- if len(errors) > 0 {
- return &Error{errors}
- }
-
- return nil
-}
-
-func (d *Decoder) decodePtr(name string, data interface{}, val reflect.Value) error {
- // Create an element of the concrete (non pointer) type and decode
- // into that. Then set the value of the pointer to this type.
- valType := val.Type()
- valElemType := valType.Elem()
- realVal := reflect.New(valElemType)
- if err := d.decode(name, data, reflect.Indirect(realVal)); err != nil {
- return err
- }
-
- val.Set(realVal)
- return nil
-}
-
-func (d *Decoder) decodeSlice(name string, data interface{}, val reflect.Value) error {
- dataVal := reflect.Indirect(reflect.ValueOf(data))
- dataValKind := dataVal.Kind()
- valType := val.Type()
- valElemType := valType.Elem()
- sliceType := reflect.SliceOf(valElemType)
-
- // Check input type
- if dataValKind != reflect.Array && dataValKind != reflect.Slice {
- // Accept empty map instead of array/slice in weakly typed mode
- if d.config.WeaklyTypedInput && dataVal.Kind() == reflect.Map && dataVal.Len() == 0 {
- val.Set(reflect.MakeSlice(sliceType, 0, 0))
- return nil
- } else {
- return fmt.Errorf(
- "'%s': source data must be an array or slice, got %s", name, dataValKind)
- }
- }
-
- // Make a new slice to hold our result, same size as the original data.
- valSlice := reflect.MakeSlice(sliceType, dataVal.Len(), dataVal.Len())
-
- // Accumulate any errors
- errors := make([]string, 0)
-
- for i := 0; i < dataVal.Len(); i++ {
- currentData := dataVal.Index(i).Interface()
- currentField := valSlice.Index(i)
-
- fieldName := fmt.Sprintf("%s[%d]", name, i)
- if err := d.decode(fieldName, currentData, currentField); err != nil {
- errors = appendErrors(errors, err)
- }
- }
-
- // Finally, set the value to the slice we built up
- val.Set(valSlice)
-
- // If there were errors, we return those
- if len(errors) > 0 {
- return &Error{errors}
- }
-
- return nil
-}
-
-func (d *Decoder) decodeStruct(name string, data interface{}, val reflect.Value) error {
- dataVal := reflect.Indirect(reflect.ValueOf(data))
-
- // If the type of the value to write to and the data match directly,
- // then we just set it directly instead of recursing into the structure.
- if dataVal.Type() == val.Type() {
- val.Set(dataVal)
- return nil
- }
-
- dataValKind := dataVal.Kind()
- if dataValKind != reflect.Map {
- return fmt.Errorf("'%s' expected a map, got '%s'", name, dataValKind)
- }
-
- dataValType := dataVal.Type()
- if kind := dataValType.Key().Kind(); kind != reflect.String && kind != reflect.Interface {
- return fmt.Errorf(
- "'%s' needs a map with string keys, has '%s' keys",
- name, dataValType.Key().Kind())
- }
-
- dataValKeys := make(map[reflect.Value]struct{})
- dataValKeysUnused := make(map[interface{}]struct{})
- for _, dataValKey := range dataVal.MapKeys() {
- dataValKeys[dataValKey] = struct{}{}
- dataValKeysUnused[dataValKey.Interface()] = struct{}{}
- }
-
- errors := make([]string, 0)
-
- // This slice will keep track of all the structs we'll be decoding.
- // There can be more than one struct if there are embedded structs
- // that are squashed.
- structs := make([]reflect.Value, 1, 5)
- structs[0] = val
-
- // Compile the list of all the fields that we're going to be decoding
- // from all the structs.
- fields := make(map[*reflect.StructField]reflect.Value)
- for len(structs) > 0 {
- structVal := structs[0]
- structs = structs[1:]
-
- structType := structVal.Type()
-
- for i := 0; i < structType.NumField(); i++ {
- fieldType := structType.Field(i)
- fieldKind := fieldType.Type.Kind()
-
- // If "squash" is specified in the tag, we squash the field down.
- squash := false
- tagParts := strings.Split(fieldType.Tag.Get(d.config.TagName), ",")
- for _, tag := range tagParts[1:] {
- if tag == "squash" {
- squash = true
- break
- }
- }
-
- if squash {
- if fieldKind != reflect.Struct {
- errors = appendErrors(errors,
- fmt.Errorf("%s: unsupported type for squash: %s", fieldType.Name, fieldKind))
- } else {
- structs = append(structs, val.FieldByName(fieldType.Name))
- }
- continue
- }
-
- // Normal struct field, store it away
- fields[&fieldType] = structVal.Field(i)
- }
- }
-
- for fieldType, field := range fields {
- fieldName := fieldType.Name
-
- tagValue := fieldType.Tag.Get(d.config.TagName)
- tagValue = strings.SplitN(tagValue, ",", 2)[0]
- if tagValue != "" {
- fieldName = tagValue
- }
-
- rawMapKey := reflect.ValueOf(fieldName)
- rawMapVal := dataVal.MapIndex(rawMapKey)
- if !rawMapVal.IsValid() {
- // Do a slower search by iterating over each key and
- // doing case-insensitive search.
- for dataValKey := range dataValKeys {
- mK, ok := dataValKey.Interface().(string)
- if !ok {
- // Not a string key
- continue
- }
-
- if strings.EqualFold(mK, fieldName) {
- rawMapKey = dataValKey
- rawMapVal = dataVal.MapIndex(dataValKey)
- break
- }
- }
-
- if !rawMapVal.IsValid() {
- // There was no matching key in the map for the value in
- // the struct. Just ignore.
- continue
- }
- }
-
- // Delete the key we're using from the unused map so we stop tracking
- delete(dataValKeysUnused, rawMapKey.Interface())
-
- if !field.IsValid() {
- // This should never happen
- panic("field is not valid")
- }
-
- // If we can't set the field, then it is unexported or something,
- // and we just continue onwards.
- if !field.CanSet() {
- continue
- }
-
- // If the name is empty string, then we're at the root, and we
- // don't dot-join the fields.
- if name != "" {
- fieldName = fmt.Sprintf("%s.%s", name, fieldName)
- }
-
- if err := d.decode(fieldName, rawMapVal.Interface(), field); err != nil {
- errors = appendErrors(errors, err)
- }
- }
-
- if d.config.ErrorUnused && len(dataValKeysUnused) > 0 {
- keys := make([]string, 0, len(dataValKeysUnused))
- for rawKey := range dataValKeysUnused {
- keys = append(keys, rawKey.(string))
- }
- sort.Strings(keys)
-
- err := fmt.Errorf("'%s' has invalid keys: %s", name, strings.Join(keys, ", "))
- errors = appendErrors(errors, err)
- }
-
- if len(errors) > 0 {
- return &Error{errors}
- }
-
- // Add the unused keys to the list of unused keys if we're tracking metadata
- if d.config.Metadata != nil {
- for rawKey := range dataValKeysUnused {
- key := rawKey.(string)
- if name != "" {
- key = fmt.Sprintf("%s.%s", name, key)
- }
-
- d.config.Metadata.Unused = append(d.config.Metadata.Unused, key)
- }
- }
-
- return nil
-}
-
-func getKind(val reflect.Value) reflect.Kind {
- kind := val.Kind()
-
- switch {
- case kind >= reflect.Int && kind <= reflect.Int64:
- return reflect.Int
- case kind >= reflect.Uint && kind <= reflect.Uint64:
- return reflect.Uint
- case kind >= reflect.Float32 && kind <= reflect.Float64:
- return reflect.Float32
- default:
- return kind
- }
-}
diff --git a/newt/vendor/github.com/spf13/cast/README.md b/newt/vendor/github.com/spf13/cast/README.md
deleted file mode 100644
index af7a1fdc..00000000
--- a/newt/vendor/github.com/spf13/cast/README.md
+++ /dev/null
@@ -1,72 +0,0 @@
-cast
-====
-
-Easy and safe casting from one type to another in Go
-
-Don?t Panic! ... Cast
-
-## What is Cast?
-
-Cast is a library to convert between different go types in a consistent and easy way.
-
-Cast provides simple functions to easily convert a number to a string, an
-interface into a bool, etc. Cast does this intelligently when an obvious
-conversion is possible. It doesn?t make any attempts to guess what you meant,
-for example you can only convert a string to an int when it is a string
-representation of an int such as ?8?. Cast was developed for use in
-[Hugo](http://hugo.spf13.com), a website engine which uses YAML, TOML or JSON
-for meta data.
-
-## Why use Cast?
-
-When working with dynamic data in Go you often need to cast or convert the data
-from one type into another. Cast goes beyond just using type assertion (though
-it uses that when possible) to provide a very straightforward and convenient
-library.
-
-If you are working with interfaces to handle things like dynamic content
-you?ll need an easy way to convert an interface into a given type. This
-is the library for you.
-
-If you are taking in data from YAML, TOML or JSON or other formats which lack
-full types, then Cast is the library for you.
-
-## Usage
-
-Cast provides a handful of To_____ methods. These methods will always return
-the desired type. **If input is provided that will not convert to that type, the
-0 or nil value for that type will be returned**.
-
-Cast also provides identical methods To_____E. These return the same result as
-the To_____ methods, plus an additional error which tells you if it successfully
-converted. Using these methods you can tell the difference between when the
-input matched the zero value or when the conversion failed and the zero value
-was returned.
-
-The following examples are merely a sample of what is available. Please review
-the code for a complete set.
-
-### Example ?ToString?:
-
- cast.ToString("mayonegg") // "mayonegg"
- cast.ToString(8) // "8"
- cast.ToString(8.31) // "8.31"
- cast.ToString([]byte("one time")) // "one time"
- cast.ToString(nil) // ""
-
- var foo interface{} = "one more time"
- cast.ToString(foo) // "one more time"
-
-
-### Example ?ToInt?:
-
- cast.ToInt(8) // 8
- cast.ToInt(8.31) // 8
- cast.ToInt("8") // 8
- cast.ToInt(true) // 1
- cast.ToInt(false) // 0
-
- var eight interface{} = 8
- cast.ToInt(eight) // 8
- cast.ToInt(nil) // 0
-
diff --git a/newt/vendor/github.com/spf13/cast/cast.go b/newt/vendor/github.com/spf13/cast/cast.go
deleted file mode 100644
index 6ca3e0e8..00000000
--- a/newt/vendor/github.com/spf13/cast/cast.go
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright ? 2014 Steve Francia <sp...@spf13.com>.
-//
-// Use of this source code is governed by an MIT-style
-// license that can be found in the LICENSE file.
-
-package cast
-
-import "time"
-
-func ToBool(i interface{}) bool {
- v, _ := ToBoolE(i)
- return v
-}
-
-func ToTime(i interface{}) time.Time {
- v, _ := ToTimeE(i)
- return v
-}
-
-func ToDuration(i interface{}) time.Duration {
- v, _ := ToDurationE(i)
- return v
-}
-
-func ToFloat64(i interface{}) float64 {
- v, _ := ToFloat64E(i)
- return v
-}
-
-func ToInt64(i interface{}) int64 {
- v, _ := ToInt64E(i)
- return v
-}
-
-func ToInt(i interface{}) int {
- v, _ := ToIntE(i)
- return v
-}
-
-func ToString(i interface{}) string {
- v, _ := ToStringE(i)
- return v
-}
-
-func ToStringMapString(i interface{}) map[string]string {
- v, _ := ToStringMapStringE(i)
- return v
-}
-
-func ToStringMapStringSlice(i interface{}) map[string][]string {
- v, _ := ToStringMapStringSliceE(i)
- return v
-}
-
-func ToStringMapBool(i interface{}) map[string]bool {
- v, _ := ToStringMapBoolE(i)
- return v
-}
-
-func ToStringMap(i interface{}) map[string]interface{} {
- v, _ := ToStringMapE(i)
- return v
-}
-
-func ToSlice(i interface{}) []interface{} {
- v, _ := ToSliceE(i)
- return v
-}
-
-func ToBoolSlice(i interface{}) []bool {
- v, _ := ToBoolSliceE(i)
- return v
-}
-
-func ToStringSlice(i interface{}) []string {
- v, _ := ToStringSliceE(i)
- return v
-}
-
-func ToIntSlice(i interface{}) []int {
- v, _ := ToIntSliceE(i)
- return v
-}
diff --git a/newt/vendor/github.com/spf13/cast/caste.go b/newt/vendor/github.com/spf13/cast/caste.go
deleted file mode 100644
index 23f0fe8c..00000000
--- a/newt/vendor/github.com/spf13/cast/caste.go
+++ /dev/null
@@ -1,527 +0,0 @@
-// Copyright ? 2014 Steve Francia <sp...@spf13.com>.
-//
-// Use of this source code is governed by an MIT-style
-// license that can be found in the LICENSE file.
-
-package cast
-
-import (
- "fmt"
- "html/template"
- "reflect"
- "strconv"
- "strings"
- "time"
-)
-
-// ToTimeE casts an empty interface to time.Time.
-func ToTimeE(i interface{}) (tim time.Time, err error) {
- i = indirect(i)
-
- switch s := i.(type) {
- case time.Time:
- return s, nil
- case string:
- d, e := StringToDate(s)
- if e == nil {
- return d, nil
- }
- return time.Time{}, fmt.Errorf("Could not parse Date/Time format: %v\n", e)
- default:
- return time.Time{}, fmt.Errorf("Unable to Cast %#v to Time\n", i)
- }
-}
-
-// ToDurationE casts an empty interface to time.Duration.
-func ToDurationE(i interface{}) (d time.Duration, err error) {
- i = indirect(i)
-
- switch s := i.(type) {
- case time.Duration:
- return s, nil
- case int64, int32, int16, int8, int:
- d = time.Duration(ToInt64(s))
- return
- case float32, float64:
- d = time.Duration(ToFloat64(s))
- return
- case string:
- if strings.ContainsAny(s, "nsu?mh") {
- d, err = time.ParseDuration(s)
- } else {
- d, err = time.ParseDuration(s + "ns")
- }
- return
- default:
- err = fmt.Errorf("Unable to Cast %#v to Duration\n", i)
- return
- }
-}
-
-// ToBoolE casts an empty interface to a bool.
-func ToBoolE(i interface{}) (bool, error) {
-
- i = indirect(i)
-
- switch b := i.(type) {
- case bool:
- return b, nil
- case nil:
- return false, nil
- case int:
- if i.(int) != 0 {
- return true, nil
- }
- return false, nil
- case string:
- return strconv.ParseBool(i.(string))
- default:
- return false, fmt.Errorf("Unable to Cast %#v to bool", i)
- }
-}
-
-// ToFloat64E casts an empty interface to a float64.
-func ToFloat64E(i interface{}) (float64, error) {
- i = indirect(i)
-
- switch s := i.(type) {
- case float64:
- return s, nil
- case float32:
- return float64(s), nil
- case int64:
- return float64(s), nil
- case int32:
- return float64(s), nil
- case int16:
- return float64(s), nil
- case int8:
- return float64(s), nil
- case int:
- return float64(s), nil
- case string:
- v, err := strconv.ParseFloat(s, 64)
- if err == nil {
- return float64(v), nil
- }
- return 0.0, fmt.Errorf("Unable to Cast %#v to float", i)
- default:
- return 0.0, fmt.Errorf("Unable to Cast %#v to float", i)
- }
-}
-
-// ToInt64E casts an empty interface to an int64.
-func ToInt64E(i interface{}) (int64, error) {
- i = indirect(i)
-
- switch s := i.(type) {
- case int64:
- return s, nil
- case int:
- return int64(s), nil
- case int32:
- return int64(s), nil
- case int16:
- return int64(s), nil
- case int8:
- return int64(s), nil
- case string:
- v, err := strconv.ParseInt(s, 0, 0)
- if err == nil {
- return v, nil
- }
- return 0, fmt.Errorf("Unable to Cast %#v to int64", i)
- case float64:
- return int64(s), nil
- case bool:
- if bool(s) {
- return int64(1), nil
- }
- return int64(0), nil
- case nil:
- return int64(0), nil
- default:
- return int64(0), fmt.Errorf("Unable to Cast %#v to int64", i)
- }
-}
-
-// ToIntE casts an empty interface to an int.
-func ToIntE(i interface{}) (int, error) {
- i = indirect(i)
-
- switch s := i.(type) {
- case int:
- return s, nil
- case int64:
- return int(s), nil
- case int32:
- return int(s), nil
- case int16:
- return int(s), nil
- case int8:
- return int(s), nil
- case string:
- v, err := strconv.ParseInt(s, 0, 0)
- if err == nil {
- return int(v), nil
- }
- return 0, fmt.Errorf("Unable to Cast %#v to int", i)
- case float64:
- return int(s), nil
- case bool:
- if bool(s) {
- return 1, nil
- }
- return 0, nil
- case nil:
- return 0, nil
- default:
- return 0, fmt.Errorf("Unable to Cast %#v to int", i)
- }
-}
-
-// From html/template/content.go
-// Copyright 2011 The Go Authors. All rights reserved.
-// indirect returns the value, after dereferencing as many times
-// as necessary to reach the base type (or nil).
-func indirect(a interface{}) interface{} {
- if a == nil {
- return nil
- }
- if t := reflect.TypeOf(a); t.Kind() != reflect.Ptr {
- // Avoid creating a reflect.Value if it's not a pointer.
- return a
- }
- v := reflect.ValueOf(a)
- for v.Kind() == reflect.Ptr && !v.IsNil() {
- v = v.Elem()
- }
- return v.Interface()
-}
-
-// From html/template/content.go
-// Copyright 2011 The Go Authors. All rights reserved.
-// indirectToStringerOrError returns the value, after dereferencing as many times
-// as necessary to reach the base type (or nil) or an implementation of fmt.Stringer
-// or error,
-func indirectToStringerOrError(a interface{}) interface{} {
- if a == nil {
- return nil
- }
-
- var errorType = reflect.TypeOf((*error)(nil)).Elem()
- var fmtStringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem()
-
- v := reflect.ValueOf(a)
- for !v.Type().Implements(fmtStringerType) && !v.Type().Implements(errorType) && v.Kind() == reflect.Ptr && !v.IsNil() {
- v = v.Elem()
- }
- return v.Interface()
-}
-
-// ToStringE casts an empty interface to a string.
-func ToStringE(i interface{}) (string, error) {
- i = indirectToStringerOrError(i)
-
- switch s := i.(type) {
- case string:
- return s, nil
- case bool:
- return strconv.FormatBool(s), nil
- case float64:
- return strconv.FormatFloat(i.(float64), 'f', -1, 64), nil
- case int64:
- return strconv.FormatInt(i.(int64), 10), nil
- case int:
- return strconv.FormatInt(int64(i.(int)), 10), nil
- case []byte:
- return string(s), nil
- case template.HTML:
- return string(s), nil
- case template.URL:
- return string(s), nil
- case template.JS:
- return string(s), nil
- case template.CSS:
- return string(s), nil
- case template.HTMLAttr:
- return string(s), nil
- case nil:
- return "", nil
- case fmt.Stringer:
- return s.String(), nil
- case error:
- return s.Error(), nil
- default:
- return "", fmt.Errorf("Unable to Cast %#v to string", i)
- }
-}
-
-// ToStringMapStringE casts an empty interface to a map[string]string.
-func ToStringMapStringE(i interface{}) (map[string]string, error) {
-
- var m = map[string]string{}
-
- switch v := i.(type) {
- case map[string]string:
- return v, nil
- case map[string]interface{}:
- for k, val := range v {
- m[ToString(k)] = ToString(val)
- }
- return m, nil
- case map[interface{}]string:
- for k, val := range v {
- m[ToString(k)] = ToString(val)
- }
- return m, nil
- case map[interface{}]interface{}:
- for k, val := range v {
- m[ToString(k)] = ToString(val)
- }
- return m, nil
- default:
- return m, fmt.Errorf("Unable to Cast %#v to map[string]string", i)
- }
-}
-
-// ToStringMapStringSliceE casts an empty interface to a map[string][]string.
-func ToStringMapStringSliceE(i interface{}) (map[string][]string, error) {
-
- var m = map[string][]string{}
-
- switch v := i.(type) {
- case map[string][]string:
- return v, nil
- case map[string][]interface{}:
- for k, val := range v {
- m[ToString(k)] = ToStringSlice(val)
- }
- return m, nil
- case map[string]string:
- for k, val := range v {
- m[ToString(k)] = []string{val}
- }
- case map[string]interface{}:
- for k, val := range v {
- switch vt := val.(type) {
- case []interface{}:
- m[ToString(k)] = ToStringSlice(vt)
- case []string:
- m[ToString(k)] = vt
- default:
- m[ToString(k)] = []string{ToString(val)}
- }
- }
- return m, nil
- case map[interface{}][]string:
- for k, val := range v {
- m[ToString(k)] = ToStringSlice(val)
- }
- return m, nil
- case map[interface{}]string:
- for k, val := range v {
- m[ToString(k)] = ToStringSlice(val)
- }
- return m, nil
- case map[interface{}][]interface{}:
- for k, val := range v {
- m[ToString(k)] = ToStringSlice(val)
- }
- return m, nil
- case map[interface{}]interface{}:
- for k, val := range v {
- key, err := ToStringE(k)
- if err != nil {
- return m, fmt.Errorf("Unable to Cast %#v to map[string][]string", i)
- }
- value, err := ToStringSliceE(val)
- if err != nil {
- return m, fmt.Errorf("Unable to Cast %#v to map[string][]string", i)
- }
- m[key] = value
- }
- default:
- return m, fmt.Errorf("Unable to Cast %#v to map[string][]string", i)
- }
- return m, nil
-}
-
-// ToStringMapBoolE casts an empty interface to a map[string]bool.
-func ToStringMapBoolE(i interface{}) (map[string]bool, error) {
-
- var m = map[string]bool{}
-
- switch v := i.(type) {
- case map[interface{}]interface{}:
- for k, val := range v {
- m[ToString(k)] = ToBool(val)
- }
- return m, nil
- case map[string]interface{}:
- for k, val := range v {
- m[ToString(k)] = ToBool(val)
- }
- return m, nil
- case map[string]bool:
- return v, nil
- default:
- return m, fmt.Errorf("Unable to Cast %#v to map[string]bool", i)
- }
-}
-
-// ToStringMapE casts an empty interface to a map[string]interface{}.
-func ToStringMapE(i interface{}) (map[string]interface{}, error) {
-
- var m = map[string]interface{}{}
-
- switch v := i.(type) {
- case map[interface{}]interface{}:
- for k, val := range v {
- m[ToString(k)] = val
- }
- return m, nil
- case map[string]interface{}:
- return v, nil
- default:
- return m, fmt.Errorf("Unable to Cast %#v to map[string]interface{}", i)
- }
-}
-
-// ToSliceE casts an empty interface to a []interface{}.
-func ToSliceE(i interface{}) ([]interface{}, error) {
-
- var s []interface{}
-
- switch v := i.(type) {
- case []interface{}:
- for _, u := range v {
- s = append(s, u)
- }
- return s, nil
- case []map[string]interface{}:
- for _, u := range v {
- s = append(s, u)
- }
- return s, nil
- default:
- return s, fmt.Errorf("Unable to Cast %#v of type %v to []interface{}", i, reflect.TypeOf(i))
- }
-}
-
-// ToBoolSliceE casts an empty interface to a []bool.
-func ToBoolSliceE(i interface{}) ([]bool, error) {
-
- if i == nil {
- return []bool{}, fmt.Errorf("Unable to Cast %#v to []bool", i)
- }
-
- switch v := i.(type) {
- case []bool:
- return v, nil
- }
-
- kind := reflect.TypeOf(i).Kind()
- switch kind {
- case reflect.Slice, reflect.Array:
- s := reflect.ValueOf(i)
- a := make([]bool, s.Len())
- for j := 0; j < s.Len(); j++ {
- val, err := ToBoolE(s.Index(j).Interface())
- if err != nil {
- return []bool{}, fmt.Errorf("Unable to Cast %#v to []bool", i)
- }
- a[j] = val
- }
- return a, nil
- default:
- return []bool{}, fmt.Errorf("Unable to Cast %#v to []bool", i)
- }
-}
-
-// ToStringSliceE casts an empty interface to a []string.
-func ToStringSliceE(i interface{}) ([]string, error) {
-
- var a []string
-
- switch v := i.(type) {
- case []interface{}:
- for _, u := range v {
- a = append(a, ToString(u))
- }
- return a, nil
- case []string:
- return v, nil
- case string:
- return strings.Fields(v), nil
- case interface{}:
- str, err := ToStringE(v)
- if err != nil {
- return a, fmt.Errorf("Unable to Cast %#v to []string", i)
- }
- return []string{str}, nil
- default:
- return a, fmt.Errorf("Unable to Cast %#v to []string", i)
- }
-}
-
-// ToIntSliceE casts an empty interface to a []int.
-func ToIntSliceE(i interface{}) ([]int, error) {
-
- if i == nil {
- return []int{}, fmt.Errorf("Unable to Cast %#v to []int", i)
- }
-
- switch v := i.(type) {
- case []int:
- return v, nil
- }
-
- kind := reflect.TypeOf(i).Kind()
- switch kind {
- case reflect.Slice, reflect.Array:
- s := reflect.ValueOf(i)
- a := make([]int, s.Len())
- for j := 0; j < s.Len(); j++ {
- val, err := ToIntE(s.Index(j).Interface())
- if err != nil {
- return []int{}, fmt.Errorf("Unable to Cast %#v to []int", i)
- }
- a[j] = val
- }
- return a, nil
- default:
- return []int{}, fmt.Errorf("Unable to Cast %#v to []int", i)
- }
-}
-
-// StringToDate casts an empty interface to a time.Time.
-func StringToDate(s string) (time.Time, error) {
- return parseDateWith(s, []string{
- time.RFC3339,
- "2006-01-02T15:04:05", // iso8601 without timezone
- time.RFC1123Z,
- time.RFC1123,
- time.RFC822Z,
- time.RFC822,
- time.ANSIC,
- time.UnixDate,
- time.RubyDate,
- "2006-01-02 15:04:05Z07:00",
- "02 Jan 06 15:04 MST",
- "2006-01-02",
- "02 Jan 2006",
- "2006-01-02 15:04:05 -07:00",
- "2006-01-02 15:04:05 -0700",
- "2006-01-02 15:04:05",
- })
-}
-
-func parseDateWith(s string, dates []string) (d time.Time, e error) {
- for _, dateType := range dates {
- if d, e = time.Parse(dateType, s); e == nil {
- return
- }
- }
- return d, fmt.Errorf("Unable to parse date: %s", s)
-}
diff --git a/newt/vendor/github.com/spf13/cobra/.travis.yml b/newt/vendor/github.com/spf13/cobra/.travis.yml
deleted file mode 100644
index bd72adf6..00000000
--- a/newt/vendor/github.com/spf13/cobra/.travis.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-language: go
-
-matrix:
- include:
- - go: 1.4.3
- env: NOVET=true # No bundled vet.
- - go: 1.5.4
- - go: 1.6.3
- - go: 1.7
- - go: tip
- allow_failures:
- - go: tip
-
-before_install:
- - mkdir -p bin
- - curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.3/shellcheck
- - chmod +x bin/shellcheck
-script:
- - PATH=$PATH:$PWD/bin go test -v ./...
- - go build
- - diff -u <(echo -n) <(gofmt -d -s .)
- - if [ -z $NOVET ]; then
- diff -u <(echo -n) <(go tool vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint');
- fi
diff --git a/newt/vendor/github.com/spf13/cobra/README.md b/newt/vendor/github.com/spf13/cobra/README.md
deleted file mode 100644
index 5d2504b1..00000000
--- a/newt/vendor/github.com/spf13/cobra/README.md
+++ /dev/null
@@ -1,898 +0,0 @@
-![cobra logo](https://cloud.githubusercontent.com/assets/173412/10886352/ad566232-814f-11e5-9cd0-aa101788c117.png)
-
-Cobra is both a library for creating powerful modern CLI applications as well as a program to generate applications and command files.
-
-Many of the most widely used Go projects are built using Cobra including:
-
-* [Kubernetes](http://kubernetes.io/)
-* [Hugo](http://gohugo.io)
-* [rkt](https://github.com/coreos/rkt)
-* [etcd](https://github.com/coreos/etcd)
-* [Docker (distribution)](https://github.com/docker/distribution)
-* [OpenShift](https://www.openshift.com/)
-* [Delve](https://github.com/derekparker/delve)
-* [GopherJS](http://www.gopherjs.org/)
-* [CockroachDB](http://www.cockroachlabs.com/)
-* [Bleve](http://www.blevesearch.com/)
-* [ProjectAtomic (enterprise)](http://www.projectatomic.io/)
-* [Parse (CLI)](https://parse.com/)
-* [GiantSwarm's swarm](https://github.com/giantswarm/cli)
-* [Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack)
-
-
-[![Build Status](https://travis-ci.org/spf13/cobra.svg "Travis CI status")](https://travis-ci.org/spf13/cobra)
-[![CircleCI status](https://circleci.com/gh/spf13/cobra.png?circle-token=:circle-token "CircleCI status")](https://circleci.com/gh/spf13/cobra)
-[![GoDoc](https://godoc.org/github.com/spf13/cobra?status.svg)](https://godoc.org/github.com/spf13/cobra)
-
-![cobra](https://cloud.githubusercontent.com/assets/173412/10911369/84832a8e-8212-11e5-9f82-cc96660a4794.gif)
-
-# Overview
-
-Cobra is a library providing a simple interface to create powerful modern CLI
-interfaces similar to git & go tools.
-
-Cobra is also an application that will generate your application scaffolding to rapidly
-develop a Cobra-based application.
-
-Cobra provides:
-* Easy subcommand-based CLIs: `app server`, `app fetch`, etc.
-* Fully POSIX-compliant flags (including short & long versions)
-* Nested subcommands
-* Global, local and cascading flags
-* Easy generation of applications & commands with `cobra create appname` & `cobra add cmdname`
-* Intelligent suggestions (`app srver`... did you mean `app server`?)
-* Automatic help generation for commands and flags
-* Automatic detailed help for `app help [command]`
-* Automatic help flag recognition of `-h`, `--help`, etc.
-* Automatically generated bash autocomplete for your application
-* Automatically generated man pages for your application
-* Command aliases so you can change things without breaking them
-* The flexibilty to define your own help, usage, etc.
-* Optional tight integration with [viper](http://github.com/spf13/viper) for 12-factor apps
-
-Cobra has an exceptionally clean interface and simple design without needless
-constructors or initialization methods.
-
-Applications built with Cobra commands are designed to be as user-friendly as
-possible. Flags can be placed before or after the command (as long as a
-confusing space isn?t provided). Both short and long flags can be used. A
-command need not even be fully typed. Help is automatically generated and
-available for the application or for a specific command using either the help
-command or the `--help` flag.
-
-# Concepts
-
-Cobra is built on a structure of commands, arguments & flags.
-
-**Commands** represent actions, **Args** are things and **Flags** are modifiers for those actions.
-
-The best applications will read like sentences when used. Users will know how
-to use the application because they will natively understand how to use it.
-
-The pattern to follow is
-`APPNAME VERB NOUN --ADJECTIVE.`
- or
-`APPNAME COMMAND ARG --FLAG`
-
-A few good real world examples may better illustrate this point.
-
-In the following example, 'server' is a command, and 'port' is a flag:
-
- > hugo server --port=1313
-
-In this command we are telling Git to clone the url bare.
-
- > git clone URL --bare
-
-## Commands
-
-Command is the central point of the application. Each interaction that
-the application supports will be contained in a Command. A command can
-have children commands and optionally run an action.
-
-In the example above, 'server' is the command.
-
-A Command has the following structure:
-
-```go
-type Command struct {
- Use string // The one-line usage message.
- Short string // The short description shown in the 'help' output.
- Long string // The long message shown in the 'help <this-command>' output.
- Run func(cmd *Command, args []string) // Run runs the command.
-}
-```
-
-## Flags
-
-A Flag is a way to modify the behavior of a command. Cobra supports
-fully POSIX-compliant flags as well as the Go [flag package](https://golang.org/pkg/flag/).
-A Cobra command can define flags that persist through to children commands
-and flags that are only available to that command.
-
-In the example above, 'port' is the flag.
-
-Flag functionality is provided by the [pflag
-library](https://github.com/ogier/pflag), a fork of the flag standard library
-which maintains the same interface while adding POSIX compliance.
-
-## Usage
-
-Cobra works by creating a set of commands and then organizing them into a tree.
-The tree defines the structure of the application.
-
-Once each command is defined with its corresponding flags, then the
-tree is assigned to the commander which is finally executed.
-
-# Installing
-Using Cobra is easy. First, use `go get` to install the latest version
-of the library. This command will install the `cobra` generator executible
-along with the library:
-
- > go get -v github.com/spf13/cobra/cobra
-
-Next, include Cobra in your application:
-
-```go
-import "github.com/spf13/cobra"
-```
-
-# Getting Started
-
-While you are welcome to provide your own organization, typically a Cobra based
-application will follow the following organizational structure.
-
-```
- ? appName/
- ? cmd/
- add.go
- your.go
- commands.go
- here.go
- main.go
-```
-
-In a Cobra app, typically the main.go file is very bare. It serves, one purpose, to initialize Cobra.
-
-```go
-package main
-
-import "{pathToYourApp}/cmd"
-
-func main() {
- if err := cmd.RootCmd.Execute(); err != nil {
- fmt.Println(err)
- os.Exit(-1)
- }
-}
-```
-
-## Using the Cobra Generator
-
-Cobra provides its own program that will create your application and add any
-commands you want. It's the easiest way to incorporate Cobra into your application.
-
-In order to use the cobra command, compile it using the following command:
-
- > go install github.com/spf13/cobra/cobra
-
-This will create the cobra executable under your go path bin directory!
-
-### cobra init
-
-The `cobra init [yourApp]` command will create your initial application code
-for you. It is a very powerful application that will populate your program with
-the right structure so you can immediately enjoy all the benefits of Cobra. It
-will also automatically apply the license you specify to your application.
-
-Cobra init is pretty smart. You can provide it a full path, or simply a path
-similar to what is expected in the import.
-
-```
-cobra init github.com/spf13/newAppName
-```
-
-### cobra add
-
-Once an application is initialized Cobra can create additional commands for you.
-Let's say you created an app and you wanted the following commands for it:
-
-* app serve
-* app config
-* app config create
-
-In your project directory (where your main.go file is) you would run the following:
-
-```
-cobra add serve
-cobra add config
-cobra add create -p 'configCmd'
-```
-
-Once you have run these three commands you would have an app structure that would look like:
-
-```
- ? app/
- ? cmd/
- serve.go
- config.go
- create.go
- main.go
-```
-
-at this point you can run `go run main.go` and it would run your app. `go run
-main.go serve`, `go run main.go config`, `go run main.go config create` along
-with `go run main.go help serve`, etc would all work.
-
-Obviously you haven't added your own code to these yet, the commands are ready
-for you to give them their tasks. Have fun.
-
-### Configuring the cobra generator
-
-The cobra generator will be easier to use if you provide a simple configuration
-file which will help you eliminate providing a bunch of repeated information in
-flags over and over.
-
-An example ~/.cobra.yaml file:
-
-```yaml
-author: Steve Francia <sp...@spf13.com>
-license: MIT
-```
-
-You can specify no license by setting `license` to `none` or you can specify
-a custom license:
-
-```yaml
-license:
- header: This file is part of {{ .appName }}.
- text: |
- {{ .copyright }}
-
- This is my license. There are many like it, but this one is mine.
- My license is my best friend. It is my life. I must master it as I must
- master my life.
-```
-
-## Manually implementing Cobra
-
-To manually implement cobra you need to create a bare main.go file and a RootCmd file.
-You will optionally provide additional commands as you see fit.
-
-### Create the root command
-
-The root command represents your binary itself.
-
-
-#### Manually create rootCmd
-
-Cobra doesn't require any special constructors. Simply create your commands.
-
-Ideally you place this in app/cmd/root.go:
-
-```go
-var RootCmd = &cobra.Command{
- Use: "hugo",
- Short: "Hugo is a very fast static site generator",
- Long: `A Fast and Flexible Static Site Generator built with
- love by spf13 and friends in Go.
- Complete documentation is available at http://hugo.spf13.com`,
- Run: func(cmd *cobra.Command, args []string) {
- // Do Stuff Here
- },
-}
-```
-
-You will additionally define flags and handle configuration in your init() function.
-
-for example cmd/root.go:
-
-```go
-func init() {
- cobra.OnInitialize(initConfig)
- RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cobra.yaml)")
- RootCmd.PersistentFlags().StringVarP(&projectBase, "projectbase", "b", "", "base project directory eg. github.com/spf13/")
- RootCmd.PersistentFlags().StringP("author", "a", "YOUR NAME", "Author name for copyright attribution")
- RootCmd.PersistentFlags().StringVarP(&userLicense, "license", "l", "", "Name of license for the project (can provide `licensetext` in config)")
- RootCmd.PersistentFlags().Bool("viper", true, "Use Viper for configuration")
- viper.BindPFlag("author", RootCmd.PersistentFlags().Lookup("author"))
- viper.BindPFlag("projectbase", RootCmd.PersistentFlags().Lookup("projectbase"))
- viper.BindPFlag("useViper", RootCmd.PersistentFlags().Lookup("viper"))
- viper.SetDefault("author", "NAME HERE <EMAIL ADDRESS>")
- viper.SetDefault("license", "apache")
-}
-```
-
-### Create your main.go
-
-With the root command you need to have your main function execute it.
-Execute should be run on the root for clarity, though it can be called on any command.
-
-In a Cobra app, typically the main.go file is very bare. It serves, one purpose, to initialize Cobra.
-
-```go
-package main
-
-import "{pathToYourApp}/cmd"
-
-func main() {
- if err := cmd.RootCmd.Execute(); err != nil {
- fmt.Println(err)
- os.Exit(-1)
- }
-}
-```
-
-
-### Create additional commands
-
-Additional commands can be defined and typically are each given their own file
-inside of the cmd/ directory.
-
-If you wanted to create a version command you would create cmd/version.go and
-populate it with the following:
-
-```go
-package cmd
-
-import (
- "github.com/spf13/cobra"
-)
-
-func init() {
- RootCmd.AddCommand(versionCmd)
-}
-
-var versionCmd = &cobra.Command{
- Use: "version",
- Short: "Print the version number of Hugo",
- Long: `All software has versions. This is Hugo's`,
- Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("Hugo Static Site Generator v0.9 -- HEAD")
- },
-}
-```
-
-### Attach command to its parent
-
-
-If you notice in the above example we attach the command to its parent. In
-this case the parent is the rootCmd. In this example we are attaching it to the
-root, but commands can be attached at any level.
-
-```go
-RootCmd.AddCommand(versionCmd)
-```
-
-### Remove a command from its parent
-
-Removing a command is not a common action in simple programs, but it allows 3rd
-parties to customize an existing command tree.
-
-In this example, we remove the existing `VersionCmd` command of an existing
-root command, and we replace it with our own version:
-
-```go
-mainlib.RootCmd.RemoveCommand(mainlib.VersionCmd)
-mainlib.RootCmd.AddCommand(versionCmd)
-```
-
-## Working with Flags
-
-Flags provide modifiers to control how the action command operates.
-
-### Assign flags to a command
-
-Since the flags are defined and used in different locations, we need to
-define a variable outside with the correct scope to assign the flag to
-work with.
-
-```go
-var Verbose bool
-var Source string
-```
-
-There are two different approaches to assign a flag.
-
-### Persistent Flags
-
-A flag can be 'persistent' meaning that this flag will be available to the
-command it's assigned to as well as every command under that command. For
-global flags, assign a flag as a persistent flag on the root.
-
-```go
-RootCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "verbose output")
-```
-
-### Local Flags
-
-A flag can also be assigned locally which will only apply to that specific command.
-
-```go
-RootCmd.Flags().StringVarP(&Source, "source", "s", "", "Source directory to read from")
-```
-
-
-## Example
-
-In the example below, we have defined three commands. Two are at the top level
-and one (cmdTimes) is a child of one of the top commands. In this case the root
-is not executable meaning that a subcommand is required. This is accomplished
-by not providing a 'Run' for the 'rootCmd'.
-
-We have only defined one flag for a single command.
-
-More documentation about flags is available at https://github.com/spf13/pflag
-
-```go
-package main
-
-import (
- "fmt"
- "strings"
-
- "github.com/spf13/cobra"
-)
-
-func main() {
-
- var echoTimes int
-
- var cmdPrint = &cobra.Command{
- Use: "print [string to print]",
- Short: "Print anything to the screen",
- Long: `print is for printing anything back to the screen.
- For many years people have printed back to the screen.
- `,
- Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("Print: " + strings.Join(args, " "))
- },
- }
-
- var cmdEcho = &cobra.Command{
- Use: "echo [string to echo]",
- Short: "Echo anything to the screen",
- Long: `echo is for echoing anything back.
- Echo works a lot like print, except it has a child command.
- `,
- Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("Print: " + strings.Join(args, " "))
- },
- }
-
- var cmdTimes = &cobra.Command{
- Use: "times [# times] [string to echo]",
- Short: "Echo anything to the screen more times",
- Long: `echo things multiple times back to the user by providing
- a count and a string.`,
- Run: func(cmd *cobra.Command, args []string) {
- for i := 0; i < echoTimes; i++ {
- fmt.Println("Echo: " + strings.Join(args, " "))
- }
- },
- }
-
- cmdTimes.Flags().IntVarP(&echoTimes, "times", "t", 1, "times to echo the input")
-
- var rootCmd = &cobra.Command{Use: "app"}
- rootCmd.AddCommand(cmdPrint, cmdEcho)
- cmdEcho.AddCommand(cmdTimes)
- rootCmd.Execute()
-}
-```
-
-For a more complete example of a larger application, please checkout [Hugo](http://gohugo.io/).
-
-## The Help Command
-
-Cobra automatically adds a help command to your application when you have subcommands.
-This will be called when a user runs 'app help'. Additionally, help will also
-support all other commands as input. Say, for instance, you have a command called
-'create' without any additional configuration; Cobra will work when 'app help
-create' is called. Every command will automatically have the '--help' flag added.
-
-### Example
-
-The following output is automatically generated by Cobra. Nothing beyond the
-command and flag definitions are needed.
-
- > hugo help
-
- hugo is the main command, used to build your Hugo site.
-
- Hugo is a Fast and Flexible Static Site Generator
- built with love by spf13 and friends in Go.
-
- Complete documentation is available at http://gohugo.io/.
-
- Usage:
- hugo [flags]
- hugo [command]
-
- Available Commands:
- server Hugo runs its own webserver to render the files
- version Print the version number of Hugo
- config Print the site configuration
- check Check content in the source directory
- benchmark Benchmark hugo by building a site a number of times.
- convert Convert your content to different formats
- new Create new content for your site
- list Listing out various types of content
- undraft Undraft changes the content's draft status from 'True' to 'False'
- genautocomplete Generate shell autocompletion script for Hugo
- gendoc Generate Markdown documentation for the Hugo CLI.
- genman Generate man page for Hugo
- import Import your site from others.
-
- Flags:
- -b, --baseURL="": hostname (and path) to the root, e.g. http://spf13.com/
- -D, --buildDrafts[=false]: include content marked as draft
- -F, --buildFuture[=false]: include content with publishdate in the future
- --cacheDir="": filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/
- --canonifyURLs[=false]: if true, all relative URLs will be canonicalized using baseURL
- --config="": config file (default is path/config.yaml|json|toml)
- -d, --destination="": filesystem path to write files to
- --disableRSS[=false]: Do not build RSS files
- --disableSitemap[=false]: Do not build Sitemap file
- --editor="": edit new content with this editor, if provided
- --ignoreCache[=false]: Ignores the cache directory for reading but still writes to it
- --log[=false]: Enable Logging
- --logFile="": Log File path (if set, logging enabled automatically)
- --noTimes[=false]: Don't sync modification time of files
- --pluralizeListTitles[=true]: Pluralize titles in lists using inflect
- --preserveTaxonomyNames[=false]: Preserve taxonomy names as written ("G?rard Depardieu" vs "gerard-depardieu")
- -s, --source="": filesystem path to read files relative from
- --stepAnalysis[=false]: display memory and timing of different steps of the program
- -t, --theme="": theme to use (located in /themes/THEMENAME/)
- --uglyURLs[=false]: if true, use /filename.html instead of /filename/
- -v, --verbose[=false]: verbose output
- --verboseLog[=false]: verbose logging
- -w, --watch[=false]: watch filesystem for changes and recreate as needed
-
- Use "hugo [command] --help" for more information about a command.
-
-
-Help is just a command like any other. There is no special logic or behavior
-around it. In fact, you can provide your own if you want.
-
-### Defining your own help
-
-You can provide your own Help command or your own template for the default command to use.
-
-The default help command is
-
-```go
-func (c *Command) initHelp() {
- if c.helpCommand == nil {
- c.helpCommand = &Command{
- Use: "help [command]",
- Short: "Help about any command",
- Long: `Help provides help for any command in the application.
- Simply type ` + c.Name() + ` help [path to command] for full details.`,
- Run: c.HelpFunc(),
- }
- }
- c.AddCommand(c.helpCommand)
-}
-```
-
-You can provide your own command, function or template through the following methods:
-
-```go
-command.SetHelpCommand(cmd *Command)
-
-command.SetHelpFunc(f func(*Command, []string))
-
-command.SetHelpTemplate(s string)
-```
-
-The latter two will also apply to any children commands.
-
-## Usage
-
-When the user provides an invalid flag or invalid command, Cobra responds by
-showing the user the 'usage'.
-
-### Example
-You may recognize this from the help above. That's because the default help
-embeds the usage as part of its output.
-
- Usage:
- hugo [flags]
- hugo [command]
-
- Available Commands:
- server Hugo runs its own webserver to render the files
- version Print the version number of Hugo
- config Print the site configuration
- check Check content in the source directory
- benchmark Benchmark hugo by building a site a number of times.
- convert Convert your content to different formats
- new Create new content for your site
- list Listing out various types of content
- undraft Undraft changes the content's draft status from 'True' to 'False'
- genautocomplete Generate shell autocompletion script for Hugo
- gendoc Generate Markdown documentation for the Hugo CLI.
- genman Generate man page for Hugo
- import Import your site from others.
-
- Flags:
- -b, --baseURL="": hostname (and path) to the root, e.g. http://spf13.com/
- -D, --buildDrafts[=false]: include content marked as draft
- -F, --buildFuture[=false]: include content with publishdate in the future
- --cacheDir="": filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/
- --canonifyURLs[=false]: if true, all relative URLs will be canonicalized using baseURL
- --config="": config file (default is path/config.yaml|json|toml)
- -d, --destination="": filesystem path to write files to
- --disableRSS[=false]: Do not build RSS files
- --disableSitemap[=false]: Do not build Sitemap file
- --editor="": edit new content with this editor, if provided
- --ignoreCache[=false]: Ignores the cache directory for reading but still writes to it
- --log[=false]: Enable Logging
- --logFile="": Log File path (if set, logging enabled automatically)
- --noTimes[=false]: Don't sync modification time of files
- --pluralizeListTitles[=true]: Pluralize titles in lists using inflect
- --preserveTaxonomyNames[=false]: Preserve taxonomy names as written ("G?rard Depardieu" vs "gerard-depardieu")
- -s, --source="": filesystem path to read files relative from
- --stepAnalysis[=false]: display memory and timing of different steps of the program
- -t, --theme="": theme to use (located in /themes/THEMENAME/)
- --uglyURLs[=false]: if true, use /filename.html instead of /filename/
- -v, --verbose[=false]: verbose output
- --verboseLog[=false]: verbose logging
- -w, --watch[=false]: watch filesystem for changes and recreate as needed
-
-### Defining your own usage
-You can provide your own usage function or template for Cobra to use.
-
-The default usage function is:
-
-```go
-return func(c *Command) error {
- err := tmpl(c.Out(), c.UsageTemplate(), c)
- return err
-}
-```
-
-Like help, the function and template are overridable through public methods:
-
-```go
-command.SetUsageFunc(f func(*Command) error)
-
-command.SetUsageTemplate(s string)
-```
-
-## PreRun or PostRun Hooks
-
-It is possible to run functions before or after the main `Run` function of your command. The `PersistentPreRun` and `PreRun` functions will be executed before `Run`. `PersistentPostRun` and `PostRun` will be executed after `Run`. The `Persistent*Run` functions will be inherited by children if they do not declare their own. These functions are run in the following order:
-
-- `PersistentPreRun`
-- `PreRun`
-- `Run`
-- `PostRun`
-- `PersistentPostRun`
-
-An example of two commands which use all of these features is below. When the subcommand is executed, it will run the root command's `PersistentPreRun` but not the root command's `PersistentPostRun`:
-
-```go
-package main
-
-import (
- "fmt"
-
- "github.com/spf13/cobra"
-)
-
-func main() {
-
- var rootCmd = &cobra.Command{
- Use: "root [sub]",
- Short: "My root command",
- PersistentPreRun: func(cmd *cobra.Command, args []string) {
- fmt.Printf("Inside rootCmd PersistentPreRun with args: %v\n", args)
- },
- PreRun: func(cmd *cobra.Command, args []string) {
- fmt.Printf("Inside rootCmd PreRun with args: %v\n", args)
- },
- Run: func(cmd *cobra.Command, args []string) {
- fmt.Printf("Inside rootCmd Run with args: %v\n", args)
- },
- PostRun: func(cmd *cobra.Command, args []string) {
- fmt.Printf("Inside rootCmd PostRun with args: %v\n", args)
- },
- PersistentPostRun: func(cmd *cobra.Command, args []string) {
- fmt.Printf("Inside rootCmd PersistentPostRun with args: %v\n", args)
- },
- }
-
- var subCmd = &cobra.Command{
- Use: "sub [no options!]",
- Short: "My subcommand",
- PreRun: func(cmd *cobra.Command, args []string) {
- fmt.Printf("Inside subCmd PreRun with args: %v\n", args)
- },
- Run: func(cmd *cobra.Command, args []string) {
- fmt.Printf("Inside subCmd Run with args: %v\n", args)
- },
- PostRun: func(cmd *cobra.Command, args []string) {
- fmt.Printf("Inside subCmd PostRun with args: %v\n", args)
- },
- PersistentPostRun: func(cmd *cobra.Command, args []string) {
- fmt.Printf("Inside subCmd PersistentPostRun with args: %v\n", args)
- },
- }
-
- rootCmd.AddCommand(subCmd)
-
- rootCmd.SetArgs([]string{""})
- _ = rootCmd.Execute()
- fmt.Print("\n")
- rootCmd.SetArgs([]string{"sub", "arg1", "arg2"})
- _ = rootCmd.Execute()
-}
-```
-
-
-## Alternative Error Handling
-
-Cobra also has functions where the return signature is an error. This allows for errors to bubble up to the top,
-providing a way to handle the errors in one location. The current list of functions that return an error is:
-
-* PersistentPreRunE
-* PreRunE
-* RunE
-* PostRunE
-* PersistentPostRunE
-
-If you would like to silence the default `error` and `usage` output in favor of your own, you can set `SilenceUsage`
-and `SilenceErrors` to `false` on the command. A child command respects these flags if they are set on the parent
-command.
-
-**Example Usage using RunE:**
-
-```go
-package main
-
-import (
- "errors"
- "log"
-
- "github.com/spf13/cobra"
-)
-
-func main() {
- var rootCmd = &cobra.Command{
- Use: "hugo",
- Short: "Hugo is a very fast static site generator",
- Long: `A Fast and Flexible Static Site Generator built with
- love by spf13 and friends in Go.
- Complete documentation is available at http://hugo.spf13.com`,
- RunE: func(cmd *cobra.Command, args []string) error {
- // Do Stuff Here
- return errors.New("some random error")
- },
- }
-
- if err := rootCmd.Execute(); err != nil {
- log.Fatal(err)
- }
-}
-```
-
-## Suggestions when "unknown command" happens
-
-Cobra will print automatic suggestions when "unknown command" errors happen. This allows Cobra to behave similarly to the `git` command when a typo happens. For example:
-
-```
-$ hugo srever
-Error: unknown command "srever" for "hugo"
-
-Did you mean this?
- server
-
-Run 'hugo --help' for usage.
-```
-
-Suggestions are automatic based on every subcommand registered and use an implementation of [Levenshtein distance](http://en.wikipedia.org/wiki/Levenshtein_distance). Every registered command that matches a minimum distance of 2 (ignoring case) will be displayed as a suggestion.
-
-If you need to disable suggestions or tweak the string distance in your command, use:
-
-```go
-command.DisableSuggestions = true
-```
-
-or
-
-```go
-command.SuggestionsMinimumDistance = 1
-```
-
-You can also explicitly set names for which a given command will be suggested using the `SuggestFor` attribute. This allows suggestions for strings that are not close in terms of string distance, but makes sense in your set of commands and for some which you don't want aliases. Example:
-
-```
-$ kubectl remove
-Error: unknown command "remove" for "kubectl"
-
-Did you mean this?
- delete
-
-Run 'kubectl help' for usage.
-```
-
-## Generating Markdown-formatted documentation for your command
-
-Cobra can generate a Markdown-formatted document based on the subcommands, flags, etc. A simple example of how to do this for your command can be found in [Markdown Docs](doc/md_docs.md).
-
-## Generating man pages for your command
-
-Cobra can generate a man page based on the subcommands, flags, etc. A simple example of how to do this for your command can be found in [Man Docs](doc/man_docs.md).
-
-## Generating bash completions for your command
-
-Cobra can generate a bash-completion file. If you add more information to your command, these completions can be amazingly powerful and flexible. Read more about it in [Bash Completions](bash_completions.md).
-
-## Debugging
-
-Cobra provides a ?DebugFlags? method on a command which, when called, will print
-out everything Cobra knows about the flags for each command.
-
-### Example
-
-```go
-command.DebugFlags()
-```
-
-## Release Notes
-* **0.9.0** June 17, 2014
- * flags can appears anywhere in the args (provided they are unambiguous)
- * --help prints usage screen for app or command
- * Prefix matching for commands
- * Cleaner looking help and usage output
- * Extensive test suite
-* **0.8.0** Nov 5, 2013
- * Reworked interface to remove commander completely
- * Command now primary structure
- * No initialization needed
- * Usage & Help templates & functions definable at any level
- * Updated Readme
-* **0.7.0** Sept 24, 2013
- * Needs more eyes
- * Test suite
- * Support for automatic error messages
- * Support for help command
- * Support for printing to any io.Writer instead of os.Stderr
- * Support for persistent flags which cascade down tree
- * Ready for integration into Hugo
-* **0.1.0** Sept 3, 2013
- * Implement first draft
-
-## Extensions
-
-Libraries for extending Cobra:
-
-* [cmdns](https://github.com/gosuri/cmdns): Enables name spacing a command's immediate children. It provides an alternative way to structure subcommands, similar to `heroku apps:create` and `ovrclk clusters:launch`.
-
-## ToDo
-* Launch proper documentation site
-
-## Contributing
-
-1. Fork it
-2. Create your feature branch (`git checkout -b my-new-feature`)
-3. Commit your changes (`git commit -am 'Add some feature'`)
-4. Push to the branch (`git push origin my-new-feature`)
-5. Create new Pull Request
-
-## Contributors
-
-Names in no particular order:
-
-* [spf13](https://github.com/spf13),
-[eparis](https://github.com/eparis),
-[bep](https://github.com/bep), and many more!
-
-## License
-
-Cobra is released under the Apache 2.0 license. See [LICENSE.txt](https://github.com/spf13/cobra/blob/master/LICENSE.txt)
-
-
-[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/spf13/cobra/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
diff --git a/newt/vendor/github.com/spf13/cobra/bash_completions.go b/newt/vendor/github.com/spf13/cobra/bash_completions.go
deleted file mode 100644
index 7a5bd4d7..00000000
--- a/newt/vendor/github.com/spf13/cobra/bash_completions.go
+++ /dev/null
@@ -1,641 +0,0 @@
-package cobra
-
-import (
- "fmt"
- "io"
- "os"
- "sort"
- "strings"
-
- "github.com/spf13/pflag"
-)
-
-const (
- BashCompFilenameExt = "cobra_annotation_bash_completion_filename_extensions"
- BashCompCustom = "cobra_annotation_bash_completion_custom"
- BashCompOneRequiredFlag = "cobra_annotation_bash_completion_one_required_flag"
- BashCompSubdirsInDir = "cobra_annotation_bash_completion_subdirs_in_dir"
-)
-
-func preamble(out io.Writer, name string) error {
- _, err := fmt.Fprintf(out, "# bash completion for %-36s -*- shell-script -*-\n", name)
- if err != nil {
- return err
- }
- _, err = fmt.Fprint(out, `
-__debug()
-{
- if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then
- echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
- fi
-}
-
-# Homebrew on Macs have version 1.3 of bash-completion which doesn't include
-# _init_completion. This is a very minimal version of that function.
-__my_init_completion()
-{
- COMPREPLY=()
- _get_comp_words_by_ref "$@" cur prev words cword
-}
-
-__index_of_word()
-{
- local w word=$1
- shift
- index=0
- for w in "$@"; do
- [[ $w = "$word" ]] && return
- index=$((index+1))
- done
- index=-1
-}
-
-__contains_word()
-{
- local w word=$1; shift
- for w in "$@"; do
- [[ $w = "$word" ]] && return
- done
- return 1
-}
-
-__handle_reply()
-{
- __debug "${FUNCNAME[0]}"
- case $cur in
- -*)
- if [[ $(type -t compopt) = "builtin" ]]; then
- compopt -o nospace
- fi
- local allflags
- if [ ${#must_have_one_flag[@]} -ne 0 ]; then
- allflags=("${must_have_one_flag[@]}")
- else
- allflags=("${flags[*]} ${two_word_flags[*]}")
- fi
- COMPREPLY=( $(compgen -W "${allflags[*]}" -- "$cur") )
- if [[ $(type -t compopt) = "builtin" ]]; then
- [[ "${COMPREPLY[0]}" == *= ]] || compopt +o nospace
- fi
-
- # complete after --flag=abc
- if [[ $cur == *=* ]]; then
- if [[ $(type -t compopt) = "builtin" ]]; then
- compopt +o nospace
- fi
-
- local index flag
- flag="${cur%%=*}"
- __index_of_word "${flag}" "${flags_with_completion[@]}"
- if [[ ${index} -ge 0 ]]; then
- COMPREPLY=()
- PREFIX=""
- cur="${cur#*=}"
- ${flags_completion[${index}]}
- if [ -n "${ZSH_VERSION}" ]; then
- # zfs completion needs --flag= prefix
- eval "COMPREPLY=( \"\${COMPREPLY[@]/#/${flag}=}\" )"
- fi
- fi
- fi
- return 0;
- ;;
- esac
-
- # check if we are handling a flag with special work handling
- local index
- __index_of_word "${prev}" "${flags_with_completion[@]}"
- if [[ ${index} -ge 0 ]]; then
- ${flags_completion[${index}]}
- return
- fi
-
- # we are parsing a flag and don't have a special handler, no completion
- if [[ ${cur} != "${words[cword]}" ]]; then
- return
- fi
-
- local completions
- completions=("${commands[@]}")
- if [[ ${#must_have_one_noun[@]} -ne 0 ]]; then
- completions=("${must_have_one_noun[@]}")
- fi
- if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then
- completions+=("${must_have_one_flag[@]}")
- fi
- COMPREPLY=( $(compgen -W "${completions[*]}" -- "$cur") )
-
- if [[ ${#COMPREPLY[@]} -eq 0 && ${#noun_aliases[@]} -gt 0 && ${#must_have_one_noun[@]} -ne 0 ]]; then
- COMPREPLY=( $(compgen -W "${noun_aliases[*]}" -- "$cur") )
- fi
-
- if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
- declare -F __custom_func >/dev/null && __custom_func
- fi
-
- __ltrim_colon_completions "$cur"
-}
-
-# The arguments should be in the form "ext1|ext2|extn"
-__handle_filename_extension_flag()
-{
- local ext="$1"
- _filedir "@(${ext})"
-}
-
-__handle_subdirs_in_dir_flag()
-{
- local dir="$1"
- pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1
-}
-
-__handle_flag()
-{
- __debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
-
- # if a command required a flag, and we found it, unset must_have_one_flag()
- local flagname=${words[c]}
- local flagvalue
- # if the word contained an =
- if [[ ${words[c]} == *"="* ]]; then
- flagvalue=${flagname#*=} # take in as flagvalue after the =
- flagname=${flagname%%=*} # strip everything after the =
- flagname="${flagname}=" # but put the = back
- fi
- __debug "${FUNCNAME[0]}: looking for ${flagname}"
- if __contains_word "${flagname}" "${must_have_one_flag[@]}"; then
- must_have_one_flag=()
- fi
-
- # if you set a flag which only applies to this command, don't show subcommands
- if __contains_word "${flagname}" "${local_nonpersistent_flags[@]}"; then
- commands=()
- fi
-
- # keep flag value with flagname as flaghash
- if [ -n "${flagvalue}" ] ; then
- flaghash[${flagname}]=${flagvalue}
- elif [ -n "${words[ $((c+1)) ]}" ] ; then
- flaghash[${flagname}]=${words[ $((c+1)) ]}
- else
- flaghash[${flagname}]="true" # pad "true" for bool flag
- fi
-
- # skip the argument to a two word flag
- if __contains_word "${words[c]}" "${two_word_flags[@]}"; then
- c=$((c+1))
- # if we are looking for a flags value, don't show commands
- if [[ $c -eq $cword ]]; then
- commands=()
- fi
- fi
-
- c=$((c+1))
-
-}
-
-__handle_noun()
-{
- __debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
-
- if __contains_word "${words[c]}" "${must_have_one_noun[@]}"; then
- must_have_one_noun=()
- elif __contains_word "${words[c]}" "${noun_aliases[@]}"; then
- must_have_one_noun=()
- fi
-
- nouns+=("${words[c]}")
- c=$((c+1))
-}
-
-__handle_command()
-{
- __debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
-
- local next_command
- if [[ -n ${last_command} ]]; then
- next_command="_${last_command}_${words[c]//:/__}"
- else
- if [[ $c -eq 0 ]]; then
- next_command="_$(basename "${words[c]//:/__}")"
- else
- next_command="_${words[c]//:/__}"
- fi
- fi
- c=$((c+1))
- __debug "${FUNCNAME[0]}: looking for ${next_command}"
- declare -F $next_command >/dev/null && $next_command
-}
-
-__handle_word()
-{
- if [[ $c -ge $cword ]]; then
- __handle_reply
- return
- fi
- __debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
- if [[ "${words[c]}" == -* ]]; then
- __handle_flag
- elif __contains_word "${words[c]}" "${commands[@]}"; then
- __handle_command
- elif [[ $c -eq 0 ]] && __contains_word "$(basename "${words[c]}")" "${commands[@]}"; then
- __handle_command
- else
- __handle_noun
- fi
- __handle_word
-}
-
-`)
- return err
-}
-
-func postscript(w io.Writer, name string) error {
- name = strings.Replace(name, ":", "__", -1)
- _, err := fmt.Fprintf(w, "__start_%s()\n", name)
- if err != nil {
- return err
- }
- _, err = fmt.Fprintf(w, `{
- local cur prev words cword
- declare -A flaghash 2>/dev/null || :
- if declare -F _init_completion >/dev/null 2>&1; then
- _init_completion -s || return
- else
- __my_init_completion -n "=" || return
- fi
-
- local c=0
- local flags=()
- local two_word_flags=()
- local local_nonpersistent_flags=()
- local flags_with_completion=()
- local flags_completion=()
- local commands=("%s")
- local must_have_one_flag=()
- local must_have_one_noun=()
- local last_command
- local nouns=()
-
- __handle_word
-}
-
-`, name)
- if err != nil {
- return err
- }
- _, err = fmt.Fprintf(w, `if [[ $(type -t compopt) = "builtin" ]]; then
- complete -o default -F __start_%s %s
-else
- complete -o default -o nospace -F __start_%s %s
-fi
-
-`, name, name, name, name)
- if err != nil {
- return err
- }
- _, err = fmt.Fprintf(w, "# ex: ts=4 sw=4 et filetype=sh\n")
- return err
-}
-
-func writeCommands(cmd *Command, w io.Writer) error {
- if _, err := fmt.Fprintf(w, " commands=()\n"); err != nil {
- return err
- }
- for _, c := range cmd.Commands() {
- if !c.IsAvailableCommand() || c == cmd.helpCommand {
- continue
- }
- if _, err := fmt.Fprintf(w, " commands+=(%q)\n", c.Name()); err != nil {
- return err
- }
- }
- _, err := fmt.Fprintf(w, "\n")
- return err
-}
-
-func writeFlagHandler(name string, annotations map[string][]string, w io.Writer) error {
- for key, value := range annotations {
- switch key {
- case BashCompFilenameExt:
- _, err := fmt.Fprintf(w, " flags_with_completion+=(%q)\n", name)
- if err != nil {
- return err
- }
-
- if len(value) > 0 {
- ext := "__handle_filename_extension_flag " + strings.Join(value, "|")
- _, err = fmt.Fprintf(w, " flags_completion+=(%q)\n", ext)
- } else {
- ext := "_filedir"
- _, err = fmt.Fprintf(w, " flags_completion+=(%q)\n", ext)
- }
- if err != nil {
- return err
- }
- case BashCompCustom:
- _, err := fmt.Fprintf(w, " flags_with_completion+=(%q)\n", name)
- if err != nil {
- return err
- }
- if len(value) > 0 {
- handlers := strings.Join(value, "; ")
- _, err = fmt.Fprintf(w, " flags_completion+=(%q)\n", handlers)
- } else {
- _, err = fmt.Fprintf(w, " flags_completion+=(:)\n")
- }
- if err != nil {
- return err
- }
- case BashCompSubdirsInDir:
- _, err := fmt.Fprintf(w, " flags_with_completion+=(%q)\n", name)
-
- if len(value) == 1 {
- ext := "__handle_subdirs_in_dir_flag " + value[0]
- _, err = fmt.Fprintf(w, " flags_completion+=(%q)\n", ext)
- } else {
- ext := "_filedir -d"
- _, err = fmt.Fprintf(w, " flags_completion+=(%q)\n", ext)
- }
- if err != nil {
- return err
- }
- }
- }
- return nil
-}
-
-func writeShortFlag(flag *pflag.Flag, w io.Writer) error {
- b := (len(flag.NoOptDefVal) > 0)
- name := flag.Shorthand
- format := " "
- if !b {
- format += "two_word_"
- }
- format += "flags+=(\"-%s\")\n"
- if _, err := fmt.Fprintf(w, format, name); err != nil {
- return err
- }
- return writeFlagHandler("-"+name, flag.Annotations, w)
-}
-
-func writeFlag(flag *pflag.Flag, w io.Writer) error {
- b := (len(flag.NoOptDefVal) > 0)
- name := flag.Name
- format := " flags+=(\"--%s"
- if !b {
- format += "="
- }
- format += "\")\n"
- if _, err := fmt.Fprintf(w, format, name); err != nil {
- return err
- }
- return writeFlagHandler("--"+name, flag.Annotations, w)
-}
-
-func writeLocalNonPersistentFlag(flag *pflag.Flag, w io.Writer) error {
- b := (len(flag.NoOptDefVal) > 0)
- name := flag.Name
- format := " local_nonpersistent_flags+=(\"--%s"
- if !b {
- format += "="
- }
- format += "\")\n"
- _, err := fmt.Fprintf(w, format, name)
- return err
-}
-
-func writeFlags(cmd *Command, w io.Writer) error {
- _, err := fmt.Fprintf(w, ` flags=()
- two_word_flags=()
- local_nonpersistent_flags=()
- flags_with_completion=()
- flags_completion=()
-
-`)
- if err != nil {
- return err
- }
- localNonPersistentFlags := cmd.LocalNonPersistentFlags()
- var visitErr error
- cmd.NonInheritedFlags().VisitAll(func(flag *pflag.Flag) {
- if nonCompletableFlag(flag) {
- return
- }
- if err := writeFlag(flag, w); err != nil {
- visitErr = err
- return
- }
- if len(flag.Shorthand) > 0 {
- if err := writeShortFlag(flag, w); err != nil {
- visitErr = err
- return
- }
- }
- if localNonPersistentFlags.Lookup(flag.Name) != nil {
- if err := writeLocalNonPersistentFlag(flag, w); err != nil {
- visitErr = err
- return
- }
- }
- })
- if visitErr != nil {
- return visitErr
- }
- cmd.InheritedFlags().VisitAll(func(flag *pflag.Flag) {
- if nonCompletableFlag(flag) {
- return
- }
- if err := writeFlag(flag, w); err != nil {
- visitErr = err
- return
- }
- if len(flag.Shorthand) > 0 {
- if err := writeShortFlag(flag, w); err != nil {
- visitErr = err
- return
- }
- }
- })
- if visitErr != nil {
- return visitErr
- }
-
- _, err = fmt.Fprintf(w, "\n")
- return err
-}
-
-func writeRequiredFlag(cmd *Command, w io.Writer) error {
- if _, err := fmt.Fprintf(w, " must_have_one_flag=()\n"); err != nil {
- return err
- }
- flags := cmd.NonInheritedFlags()
- var visitErr error
- flags.VisitAll(func(flag *pflag.Flag) {
- if nonCompletableFlag(flag) {
- return
- }
- for key := range flag.Annotations {
- switch key {
- case BashCompOneRequiredFlag:
- format := " must_have_one_flag+=(\"--%s"
- b := (flag.Value.Type() == "bool")
- if !b {
- format += "="
- }
- format += "\")\n"
- if _, err := fmt.Fprintf(w, format, flag.Name); err != nil {
- visitErr = err
- return
- }
-
- if len(flag.Shorthand) > 0 {
- if _, err := fmt.Fprintf(w, " must_have_one_flag+=(\"-%s\")\n", flag.Shorthand); err != nil {
- visitErr = err
- return
- }
- }
- }
- }
- })
- return visitErr
-}
-
-func writeRequiredNouns(cmd *Command, w io.Writer) error {
- if _, err := fmt.Fprintf(w, " must_have_one_noun=()\n"); err != nil {
- return err
- }
- sort.Sort(sort.StringSlice(cmd.ValidArgs))
- for _, value := range cmd.ValidArgs {
- if _, err := fmt.Fprintf(w, " must_have_one_noun+=(%q)\n", value); err != nil {
- return err
- }
- }
- return nil
-}
-
-func writeArgAliases(cmd *Command, w io.Writer) error {
- if _, err := fmt.Fprintf(w, " noun_aliases=()\n"); err != nil {
- return err
- }
- sort.Sort(sort.StringSlice(cmd.ArgAliases))
- for _, value := range cmd.ArgAliases {
- if _, err := fmt.Fprintf(w, " noun_aliases+=(%q)\n", value); err != nil {
- return err
- }
- }
- return nil
-}
-
-func gen(cmd *Command, w io.Writer) error {
- for _, c := range cmd.Commands() {
- if !c.IsAvailableCommand() || c == cmd.helpCommand {
- continue
- }
- if err := gen(c, w); err != nil {
- return err
- }
- }
- commandName := cmd.CommandPath()
- commandName = strings.Replace(commandName, " ", "_", -1)
- commandName = strings.Replace(commandName, ":", "__", -1)
- if _, err := fmt.Fprintf(w, "_%s()\n{\n", commandName); err != nil {
- return err
- }
- if _, err := fmt.Fprintf(w, " last_command=%q\n", commandName); err != nil {
- return err
- }
- if err := writeCommands(cmd, w); err != nil {
- return err
- }
- if err := writeFlags(cmd, w); err != nil {
- return err
- }
- if err := writeRequiredFlag(cmd, w); err != nil {
- return err
- }
- if err := writeRequiredNouns(cmd, w); err != nil {
- return err
- }
- if err := writeArgAliases(cmd, w); err != nil {
- return err
- }
- if _, err := fmt.Fprintf(w, "}\n\n"); err != nil {
- return err
- }
- return nil
-}
-
-func (cmd *Command) GenBashCompletion(w io.Writer) error {
- if err := preamble(w, cmd.Name()); err != nil {
- return err
- }
- if len(cmd.BashCompletionFunction) > 0 {
- if _, err := fmt.Fprintf(w, "%s\n", cmd.BashCompletionFunction); err != nil {
- return err
- }
- }
- if err := gen(cmd, w); err != nil {
- return err
- }
- return postscript(w, cmd.Name())
-}
-
-func nonCompletableFlag(flag *pflag.Flag) bool {
- return flag.Hidden || len(flag.Deprecated) > 0
-}
-
-func (cmd *Command) GenBashCompletionFile(filename string) error {
- outFile, err := os.Create(filename)
- if err != nil {
- return err
- }
- defer outFile.Close()
-
- return cmd.GenBashCompletion(outFile)
-}
-
-// MarkFlagRequired adds the BashCompOneRequiredFlag annotation to the named flag, if it exists.
-func (cmd *Command) MarkFlagRequired(name string) error {
- return MarkFlagRequired(cmd.Flags(), name)
-}
-
-// MarkPersistentFlagRequired adds the BashCompOneRequiredFlag annotation to the named persistent flag, if it exists.
-func (cmd *Command) MarkPersistentFlagRequired(name string) error {
- return MarkFlagRequired(cmd.PersistentFlags(), name)
-}
-
-// MarkFlagRequired adds the BashCompOneRequiredFlag annotation to the named flag in the flag set, if it exists.
-func MarkFlagRequired(flags *pflag.FlagSet, name string) error {
- return flags.SetAnnotation(name, BashCompOneRequiredFlag, []string{"true"})
-}
-
-// MarkFlagFilename adds the BashCompFilenameExt annotation to the named flag, if it exists.
-// Generated bash autocompletion will select filenames for the flag, limiting to named extensions if provided.
-func (cmd *Command) MarkFlagFilename(name string, extensions ...string) error {
- return MarkFlagFilename(cmd.Flags(), name, extensions...)
-}
-
-// MarkFlagCustom adds the BashCompCustom annotation to the named flag, if it exists.
-// Generated bash autocompletion will call the bash function f for the flag.
-func (cmd *Command) MarkFlagCustom(name string, f string) error {
- return MarkFlagCustom(cmd.Flags(), name, f)
-}
-
-// MarkPersistentFlagFilename adds the BashCompFilenameExt annotation to the named persistent flag, if it exists.
-// Generated bash autocompletion will select filenames for the flag, limiting to named extensions if provided.
-func (cmd *Command) MarkPersistentFlagFilename(name string, extensions ...string) error {
- return MarkFlagFilename(cmd.PersistentFlags(), name, extensions...)
-}
-
-// MarkFlagFilename adds the BashCompFilenameExt annotation to the named flag in the flag set, if it exists.
-// Generated bash autocompletion will select filenames for the flag, limiting to named extensions if provided.
-func MarkFlagFilename(flags *pflag.FlagSet, name string, extensions ...string) error {
- return flags.SetAnnotation(name, BashCompFilenameExt, extensions)
-}
-
-// MarkFlagCustom adds the BashCompCustom annotation to the named flag in the flag set, if it exists.
-// Generated bash autocompletion will call the bash function f for the flag.
-func MarkFlagCustom(flags *pflag.FlagSet, name string, f string) error {
- return flags.SetAnnotation(name, BashCompCustom, []string{f})
-}
diff --git a/newt/vendor/github.com/spf13/cobra/bash_completions.md b/newt/vendor/github.com/spf13/cobra/bash_completions.md
deleted file mode 100644
index 6e3b71f1..00000000
--- a/newt/vendor/github.com/spf13/cobra/bash_completions.md
+++ /dev/null
@@ -1,206 +0,0 @@
-# Generating Bash Completions For Your Own cobra.Command
-
-Generating bash completions from a cobra command is incredibly easy. An actual program which does so for the kubernetes kubectl binary is as follows:
-
-```go
-package main
-
-import (
- "io/ioutil"
- "os"
-
- "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd"
-)
-
-func main() {
- kubectl := cmd.NewFactory(nil).NewKubectlCommand(os.Stdin, ioutil.Discard, ioutil.Discard)
- kubectl.GenBashCompletionFile("out.sh")
-}
-```
-
-That will get you completions of subcommands and flags. If you make additional annotations to your code, you can get even more intelligent and flexible behavior.
-
-## Creating your own custom functions
-
-Some more actual code that works in kubernetes:
-
-```bash
-const (
- bash_completion_func = `__kubectl_parse_get()
-{
- local kubectl_output out
- if kubectl_output=$(kubectl get --no-headers "$1" 2>/dev/null); then
- out=($(echo "${kubectl_output}" | awk '{print $1}'))
- COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) )
- fi
-}
-
-__kubectl_get_resource()
-{
- if [[ ${#nouns[@]} -eq 0 ]]; then
- return 1
- fi
- __kubectl_parse_get ${nouns[${#nouns[@]} -1]}
- if [[ $? -eq 0 ]]; then
- return 0
- fi
-}
-
-__custom_func() {
- case ${last_command} in
- kubectl_get | kubectl_describe | kubectl_delete | kubectl_stop)
- __kubectl_get_resource
- return
- ;;
- *)
- ;;
- esac
-}
-`)
-```
-
-And then I set that in my command definition:
-
-```go
-cmds := &cobra.Command{
- Use: "kubectl",
- Short: "kubectl controls the Kubernetes cluster manager",
- Long: `kubectl controls the Kubernetes cluster manager.
-
-Find more information at https://github.com/GoogleCloudPlatform/kubernetes.`,
- Run: runHelp,
- BashCompletionFunction: bash_completion_func,
-}
-```
-
-The `BashCompletionFunction` option is really only valid/useful on the root command. Doing the above will cause `__custom_func()` to be called when the built in processor was unable to find a solution. In the case of kubernetes a valid command might look something like `kubectl get pod [mypod]`. If you type `kubectl get pod [tab][tab]` the `__customc_func()` will run because the cobra.Command only understood "kubectl" and "get." `__custom_func()` will see that the cobra.Command is "kubectl_get" and will thus call another helper `__kubectl_get_resource()`. `__kubectl_get_resource` will look at the 'nouns' collected. In our example the only noun will be `pod`. So it will call `__kubectl_parse_get pod`. `__kubectl_parse_get` will actually call out to kubernetes and get any pods. It will then set `COMPREPLY` to valid pods!
-
-## Have the completions code complete your 'nouns'
-
-In the above example "pod" was assumed to already be typed. But if you want `kubectl get [tab][tab]` to show a list of valid "nouns" you have to set them. Simplified code from `kubectl get` looks like:
-
-```go
-validArgs []string = { "pod", "node", "service", "replicationcontroller" }
-
-cmd := &cobra.Command{
- Use: "get [(-o|--output=)json|yaml|template|...] (RESOURCE [NAME] | RESOURCE/NAME ...)",
- Short: "Display one or many resources",
- Long: get_long,
- Example: get_example,
- Run: func(cmd *cobra.Command, args []string) {
- err := RunGet(f, out, cmd, args)
- util.CheckErr(err)
- },
- ValidArgs: validArgs,
-}
-```
-
-Notice we put the "ValidArgs" on the "get" subcommand. Doing so will give results like
-
-```bash
-# kubectl get [tab][tab]
-node pod replicationcontroller service
-```
-
-## Plural form and shortcuts for nouns
-
-If your nouns have a number of aliases, you can define them alongside `ValidArgs` using `ArgAliases`:
-
-```go`
-argAliases []string = { "pods", "nodes", "services", "svc", "replicationcontrollers", "rc" }
-
-cmd := &cobra.Command{
- ...
- ValidArgs: validArgs,
- ArgAliases: argAliases
-}
-```
-
-The aliases are not shown to the user on tab completion, but they are accepted as valid nouns by
-the completion algorithm if entered manually, e.g. in:
-
-```bash
-# kubectl get rc [tab][tab]
-backend frontend database
-```
-
-Note that without declaring `rc` as an alias, the completion algorithm would show the list of nouns
-in this example again instead of the replication controllers.
-
-## Mark flags as required
-
-Most of the time completions will only show subcommands. But if a flag is required to make a subcommand work, you probably want it to show up when the user types [tab][tab]. Marking a flag as 'Required' is incredibly easy.
-
-```go
-cmd.MarkFlagRequired("pod")
-cmd.MarkFlagRequired("container")
-```
-
-and you'll get something like
-
-```bash
-# kubectl exec [tab][tab][tab]
--c --container= -p --pod=
-```
-
-# Specify valid filename extensions for flags that take a filename
-
-In this example we use --filename= and expect to get a json or yaml file as the argument. To make this easier we annotate the --filename flag with valid filename extensions.
-
-```go
- annotations := []string{"json", "yaml", "yml"}
- annotation := make(map[string][]string)
- annotation[cobra.BashCompFilenameExt] = annotations
-
- flag := &pflag.Flag{
- Name: "filename",
- Shorthand: "f",
- Usage: usage,
- Value: value,
- DefValue: value.String(),
- Annotations: annotation,
- }
- cmd.Flags().AddFlag(flag)
-```
-
-Now when you run a command with this filename flag you'll get something like
-
-```bash
-# kubectl create -f
-test/ example/ rpmbuild/
-hello.yml test.json
-```
-
-So while there are many other files in the CWD it only shows me subdirs and those with valid extensions.
-
-# Specifiy custom flag completion
-
-Similar to the filename completion and filtering using cobra.BashCompFilenameExt, you can specifiy
-a custom flag completion function with cobra.BashCompCustom:
-
-```go
- annotation := make(map[string][]string)
- annotation[cobra.BashCompFilenameExt] = []string{"__kubectl_get_namespaces"}
-
- flag := &pflag.Flag{
- Name: "namespace",
- Usage: usage,
- Annotations: annotation,
- }
- cmd.Flags().AddFlag(flag)
-```
-
-In addition add the `__handle_namespace_flag` implementation in the `BashCompletionFunction`
-value, e.g.:
-
-```bash
-__kubectl_get_namespaces()
-{
- local template
- template="{{ range .items }}{{ .metadata.name }} {{ end }}"
- local kubectl_out
- if kubectl_out=$(kubectl get -o template --template="${template}" namespace 2>/dev/null); then
- COMPREPLY=( $( compgen -W "${kubectl_out}[*]" -- "$cur" ) )
- fi
-}
-```
diff --git a/newt/vendor/github.com/spf13/cobra/cobra.go b/newt/vendor/github.com/spf13/cobra/cobra.go
deleted file mode 100644
index b39c715a..00000000
--- a/newt/vendor/github.com/spf13/cobra/cobra.go
+++ /dev/null
@@ -1,173 +0,0 @@
-// Copyright ? 2013 Steve Francia <sp...@spf13.com>.
-//
-// Licensed 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.
-
-// Commands similar to git, go tools and other modern CLI tools
-// inspired by go, go-Commander, gh and subcommand
-
-package cobra
-
-import (
- "fmt"
- "io"
- "reflect"
- "strconv"
- "strings"
- "text/template"
- "unicode"
-)
-
-var templateFuncs = template.FuncMap{
- "trim": strings.TrimSpace,
- "trimRightSpace": trimRightSpace,
- "appendIfNotPresent": appendIfNotPresent,
- "rpad": rpad,
- "gt": Gt,
- "eq": Eq,
-}
-
-var initializers []func()
-
-// Automatic prefix matching can be a dangerous thing to automatically enable in CLI tools.
-// Set this to true to enable it.
-var EnablePrefixMatching = false
-
-// EnableCommandSorting controls sorting of the slice of commands, which is turned on by default.
-// To disable sorting, set it to false.
-var EnableCommandSorting = true
-
-// AddTemplateFunc adds a template function that's available to Usage and Help
-// template generation.
-func AddTemplateFunc(name string, tmplFunc interface{}) {
- templateFuncs[name] = tmplFunc
-}
-
-// AddTemplateFuncs adds multiple template functions availalble to Usage and
-// Help template generation.
-func AddTemplateFuncs(tmplFuncs template.FuncMap) {
- for k, v := range tmplFuncs {
- templateFuncs[k] = v
- }
-}
-
-// OnInitialize takes a series of func() arguments and appends them to a slice of func().
-func OnInitialize(y ...func()) {
- initializers = append(initializers, y...)
-}
-
-// Gt takes two types and checks whether the first type is greater than the second. In case of types Arrays, Chans,
-// Maps and Slices, Gt will compare their lengths. Ints are compared directly while strings are first parsed as
-// ints and then compared.
-func Gt(a interface{}, b interface{}) bool {
- var left, right int64
- av := reflect.ValueOf(a)
-
- switch av.Kind() {
- case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:
- left = int64(av.Len())
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- left = av.Int()
- case reflect.String:
- left, _ = strconv.ParseInt(av.String(), 10, 64)
- }
-
- bv := reflect.ValueOf(b)
-
- switch bv.Kind() {
- case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:
- right = int64(bv.Len())
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- right = bv.Int()
- case reflect.String:
- right, _ = strconv.ParseInt(bv.String(), 10, 64)
- }
-
- return left > right
-}
-
-// Eq takes two types and checks whether they are equal. Supported types are int and string. Unsupported types will panic.
-func Eq(a interface{}, b interface{}) bool {
- av := reflect.ValueOf(a)
- bv := reflect.ValueOf(b)
-
- switch av.Kind() {
- case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:
- panic("Eq called on unsupported type")
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return av.Int() == bv.Int()
- case reflect.String:
- return av.String() == bv.String()
- }
- return false
-}
-
-func trimRightSpace(s string) string {
- return strings.TrimRightFunc(s, unicode.IsSpace)
-}
-
-// appendIfNotPresent will append stringToAppend to the end of s, but only if it's not yet present in s.
-func appendIfNotPresent(s, stringToAppend string) string {
- if strings.Contains(s, stringToAppend) {
- return s
- }
- return s + " " + stringToAppend
-}
-
-// rpad adds padding to the right of a string.
-func rpad(s string, padding int) string {
- template := fmt.Sprintf("%%-%ds", padding)
- return fmt.Sprintf(template, s)
-}
-
-// tmpl executes the given template text on data, writing the result to w.
-func tmpl(w io.Writer, text string, data interface{}) error {
- t := template.New("top")
- t.Funcs(templateFuncs)
- template.Must(t.Parse(text))
- return t.Execute(w, data)
-}
-
-// ld compares two strings and returns the levenshtein distance between them.
-func ld(s, t string, ignoreCase bool) int {
- if ignoreCase {
- s = strings.ToLower(s)
- t = strings.ToLower(t)
- }
- d := make([][]int, len(s)+1)
- for i := range d {
- d[i] = make([]int, len(t)+1)
- }
- for i := range d {
- d[i][0] = i
- }
- for j := range d[0] {
- d[0][j] = j
- }
- for j := 1; j <= len(t); j++ {
- for i := 1; i <= len(s); i++ {
- if s[i-1] == t[j-1] {
- d[i][j] = d[i-1][j-1]
- } else {
- min := d[i-1][j]
- if d[i][j-1] < min {
- min = d[i][j-1]
- }
- if d[i-1][j-1] < min {
- min = d[i-1][j-1]
- }
- d[i][j] = min + 1
- }
- }
-
- }
- return d[len(s)][len(t)]
-}
diff --git a/newt/vendor/github.com/spf13/cobra/command.go b/newt/vendor/github.com/spf13/cobra/command.go
deleted file mode 100644
index 49889318..00000000
--- a/newt/vendor/github.com/spf13/cobra/command.go
+++ /dev/null
@@ -1,1291 +0,0 @@
-// Copyright ? 2013 Steve Francia <sp...@spf13.com>.
-//
-// Licensed 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 cobra is a commander providing a simple interface to create powerful modern CLI interfaces.
-//In addition to providing an interface, Cobra simultaneously provides a controller to organize your application code.
-package cobra
-
-import (
- "bytes"
- "fmt"
- "io"
- "os"
- "path/filepath"
- "sort"
- "strings"
-
- flag "github.com/spf13/pflag"
-)
-
-// Command is just that, a command for your application.
-// eg. 'go run' ... 'run' is the command. Cobra requires
-// you to define the usage and description as part of your command
-// definition to ensure usability.
-type Command struct {
- // Name is the command name, usually the executable's name.
- name string
- // The one-line usage message.
- Use string
- // An array of aliases that can be used instead of the first word in Use.
- Aliases []string
- // An array of command names for which this command will be suggested - similar to aliases but only suggests.
- SuggestFor []string
- // The short description shown in the 'help' output.
- Short string
- // The long message shown in the 'help <this-command>' output.
- Long string
- // Examples of how to use the command
- Example string
- // List of all valid non-flag arguments that are accepted in bash completions
- ValidArgs []string
- // List of aliases for ValidArgs. These are not suggested to the user in the bash
- // completion, but accepted if entered manually.
- ArgAliases []string
- // Custom functions used by the bash autocompletion generator
- BashCompletionFunction string
- // Is this command deprecated and should print this string when used?
- Deprecated string
- // Is this command hidden and should NOT show up in the list of available commands?
- Hidden bool
- // Full set of flags
- flags *flag.FlagSet
- // Set of flags childrens of this command will inherit
- pflags *flag.FlagSet
- // Flags that are declared specifically by this command (not inherited).
- lflags *flag.FlagSet
- // SilenceErrors is an option to quiet errors down stream
- SilenceErrors bool
- // Silence Usage is an option to silence usage when an error occurs.
- SilenceUsage bool
- // The *Run functions are executed in the following order:
- // * PersistentPreRun()
- // * PreRun()
- // * Run()
- // * PostRun()
- // * PersistentPostRun()
- // All functions get the same args, the arguments after the command name
- // PersistentPreRun: children of this command will inherit and execute
- PersistentPreRun func(cmd *Command, args []string)
- // PersistentPreRunE: PersistentPreRun but returns an error
- PersistentPreRunE func(cmd *Command, args []string) error
- // PreRun: children of this command will not inherit.
- PreRun func(cmd *Command, args []string)
- // PreRunE: PreRun but returns an error
- PreRunE func(cmd *Command, args []string) error
- // Run: Typically the actual work function. Most commands will only implement this
- Run func(cmd *Command, args []string)
- // RunE: Run but returns an error
- RunE func(cmd *Command, args []string) error
- // PostRun: run after the Run command.
- PostRun func(cmd *Command, args []string)
- // PostRunE: PostRun but returns an error
- PostRunE func(cmd *Command, args []string) error
- // PersistentPostRun: children of this command will inherit and execute after PostRun
- PersistentPostRun func(cmd *Command, args []string)
- // PersistentPostRunE: PersistentPostRun but returns an error
- PersistentPostRunE func(cmd *Command, args []string) error
- // DisableAutoGenTag remove
- DisableAutoGenTag bool
- // Commands is the list of commands supported by this program.
- commands []*Command
- // Parent Command for this command
- parent *Command
- // max lengths of commands' string lengths for use in padding
- commandsMaxUseLen int
- commandsMaxCommandPathLen int
- commandsMaxNameLen int
- // is commands slice are sorted or not
- commandsAreSorted bool
-
- flagErrorBuf *bytes.Buffer
-
- args []string // actual args parsed from flags
- output *io.Writer // out writer if set in SetOutput(w)
- usageFunc func(*Command) error // Usage can be defined by application
- usageTemplate string // Can be defined by Application
- flagErrorFunc func(*Command, error) error
- helpTemplate string // Can be defined by Application
- helpFunc func(*Command, []string) // Help can be defined by application
- helpCommand *Command // The help command
- // The global normalization function that we can use on every pFlag set and children commands
- globNormFunc func(f *flag.FlagSet, name string) flag.NormalizedName
-
- // Disable the suggestions based on Levenshtein distance that go along with 'unknown command' messages
- DisableSuggestions bool
- // If displaying suggestions, allows to set the minimum levenshtein distance to display, must be > 0
- SuggestionsMinimumDistance int
-
- // Disable the flag parsing. If this is true all flags will be passed to the command as arguments.
- DisableFlagParsing bool
-}
-
-// os.Args[1:] by default, if desired, can be overridden
-// particularly useful when testing.
-func (c *Command) SetArgs(a []string) {
- c.args = a
-}
-
-// SetOutput sets the destination for usage and error messages.
-// If output is nil, os.Stderr is used.
-func (c *Command) SetOutput(output io.Writer) {
- c.output = &output
-}
-
-// Usage can be defined by application.
-func (c *Command) SetUsageFunc(f func(*Command) error) {
- c.usageFunc = f
-}
-
-// Can be defined by Application.
-func (c *Command) SetUsageTemplate(s string) {
- c.usageTemplate = s
-}
-
-// SetFlagErrorFunc sets a function to generate an error when flag parsing
-// fails
-func (c *Command) SetFlagErrorFunc(f func(*Command, error) error) {
- c.flagErrorFunc = f
-}
-
-// Can be defined by Application
-func (c *Command) SetHelpFunc(f func(*Command, []string)) {
- c.helpFunc = f
-}
-
-func (c *Command) SetHelpCommand(cmd *Command) {
- c.helpCommand = cmd
-}
-
-// Can be defined by Application.
-func (c *Command) SetHelpTemplate(s string) {
- c.helpTemplate = s
-}
-
-// SetGlobalNormalizationFunc sets a normalization function to all flag sets and also to child commands.
-// The user should not have a cyclic dependency on commands.
-func (c *Command) SetGlobalNormalizationFunc(n func(f *flag.FlagSet, name string) flag.NormalizedName) {
- c.Flags().SetNormalizeFunc(n)
- c.PersistentFlags().SetNormalizeFunc(n)
- c.globNormFunc = n
-
- for _, command := range c.commands {
- command.SetGlobalNormalizationFunc(n)
- }
-}
-
-func (c *Command) OutOrStdout() io.Writer {
- return c.getOut(os.Stdout)
-}
-
-func (c *Command) OutOrStderr() io.Writer {
- return c.getOut(os.Stderr)
-}
-
-func (c *Command) getOut(def io.Writer) io.Writer {
- if c.output != nil {
- return *c.output
- }
- if c.HasParent() {
- return c.parent.getOut(def)
- }
- return def
-}
-
-// UsageFunc returns either the function set by SetUsageFunc for this command
-// or a parent, or it returns a default usage function.
-func (c *Command) UsageFunc() (f func(*Command) error) {
- if c.usageFunc != nil {
- return c.usageFunc
- }
-
- if c.HasParent() {
- return c.parent.UsageFunc()
- }
- return func(c *Command) error {
- c.mergePersistentFlags()
- err := tmpl(c.OutOrStderr(), c.UsageTemplate(), c)
- if err != nil {
- c.Println(err)
- }
- return err
- }
-}
-
-// Usage puts out the usage for the command.
-// Used when a user provides invalid input.
-// Can be defined by user by overriding UsageFunc.
-func (c *Command) Usage() error {
- return c.UsageFunc()(c)
-}
-
-// HelpFunc returns either the function set by SetHelpFunc for this command
-// or a parent, or it returns a function with default help behavior.
-func (c *Command) HelpFunc() func(*Command, []string) {
- if helpFunc := c.checkHelpFunc(); helpFunc != nil {
- return helpFunc
- }
- return func(*Command, []string) {
- c.mergePersistentFlags()
- err := tmpl(c.OutOrStdout(), c.HelpTemplate(), c)
- if err != nil {
- c.Println(err)
- }
- }
-}
-
-// checkHelpFunc checks if there is helpFunc in ancestors of c.
-func (c *Command) checkHelpFunc() func(*Command, []string) {
- if c == nil {
- return nil
- }
- if c.helpFunc != nil {
- return c.helpFunc
- }
- if c.HasParent() {
- return c.parent.checkHelpFunc()
- }
- return nil
-}
-
-// Help puts out the help for the command.
-// Used when a user calls help [command].
-// Can be defined by user by overriding HelpFunc.
-func (c *Command) Help() error {
- c.HelpFunc()(c, []string{})
- return nil
-}
-
-func (c *Command) UsageString() string {
- tmpOutput := c.output
- bb := new(bytes.Buffer)
- c.SetOutput(bb)
- c.Usage()
- c.output = tmpOutput
- return bb.String()
-}
-
-// FlagErrorFunc returns either the function set by SetFlagErrorFunc for this
-// command or a parent, or it returns a function which returns the original
-// error.
-func (c *Command) FlagErrorFunc() (f func(*Command, error) error) {
- if c.flagErrorFunc != nil {
- return c.flagErrorFunc
- }
-
- if c.HasParent() {
- return c.parent.FlagErrorFunc()
- }
- return func(c *Command, err error) error {
- return err
- }
-}
-
-var minUsagePadding = 25
-
-func (c *Command) UsagePadding() int {
- if c.parent == nil || minUsagePadding > c.parent.commandsMaxUseLen {
- return minUsagePadding
- }
- return c.parent.commandsMaxUseLen
-}
-
-var minCommandPathPadding = 11
-
-//
-func (c *Command) CommandPathPadding() int {
- if c.parent == nil || minCommandPathPadding > c.parent.commandsMaxCommandPathLen {
- return minCommandPathPadding
- }
- return c.parent.commandsMaxCommandPathLen
-}
-
-var minNamePadding = 11
-
-func (c *Command) NamePadding() int {
- if c.parent == nil || minNamePadding > c.parent.commandsMaxNameLen {
- return minNamePadding
- }
- return c.parent.commandsMaxNameLen
-}
-
-func (c *Command) UsageTemplate() string {
- if c.usageTemplate != "" {
- return c.usageTemplate
- }
-
- if c.HasParent() {
- return c.parent.UsageTemplate()
- }
- return `Usage:{{if .Runnable}}
- {{if .HasAvailableFlags}}{{appendIfNotPresent .UseLine "[flags]"}}{{else}}{{.UseLine}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
- {{ .CommandPath}} [command]{{end}}{{if gt .Aliases 0}}
-
-Aliases:
- {{.NameAndAliases}}
-{{end}}{{if .HasExample}}
-
-Examples:
-{{ .Example }}{{end}}{{ if .HasAvailableSubCommands}}
-
-Available Commands:{{range .Commands}}{{if .IsAvailableCommand}}
- {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{ if .HasAvailableLocalFlags}}
-
-Flags:
-{{.LocalFlags.FlagUsages | trimRightSpace}}{{end}}{{ if .HasAvailableInheritedFlags}}
-
-Global Flags:
-{{.InheritedFlags.FlagUsages | trimRightSpace}}{{end}}{{if .HasHelpSubCommands}}
-
-Additional help topics:{{range .Commands}}{{if .IsHelpCommand}}
- {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{ if .HasAvailableSubCommands }}
-
-Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
-`
-}
-
-func (c *Command) HelpTemplate() string {
- if c.helpTemplate != "" {
- return c.helpTemplate
- }
-
- if c.HasParent() {
- return c.parent.HelpTemplate()
- }
- return `{{with or .Long .Short }}{{. | trim}}
-
-{{end}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}`
-}
-
-// Really only used when casting a command to a commander.
-func (c *Command) resetChildrensParents() {
- for _, x := range c.commands {
- x.parent = c
- }
-}
-
-// Test if the named flag is a boolean flag.
-func isBooleanFlag(name string, f *flag.FlagSet) bool {
- flag := f.Lookup(name)
- if flag == nil {
- return false
- }
- return flag.Value.Type() == "bool"
-}
-
-// Test if the named flag is a boolean flag.
-func isBooleanShortFlag(name string, f *flag.FlagSet) bool {
- result := false
- f.VisitAll(func(f *flag.Flag) {
- if f.Shorthand == name && f.Value.Type() == "bool" {
- result = true
- }
- })
- return result
-}
-
-func stripFlags(args []string, c *Command) []string {
- if len(args) < 1 {
- return args
- }
- c.mergePersistentFlags()
-
- commands := []string{}
-
- inQuote := false
- inFlag := false
- for _, y := range args {
- if !inQuote {
- switch {
- case strings.HasPrefix(y, "\""):
- inQuote = true
- case strings.Contains(y, "=\""):
- inQuote = true
- case strings.HasPrefix(y, "--") && !strings.Contains(y, "="):
- // TODO: this isn't quite right, we should really check ahead for 'true' or 'false'
- inFlag = !isBooleanFlag(y[2:], c.Flags())
- case strings.HasPrefix(y, "-") && !strings.Contains(y, "=") && len(y) == 2 && !isBooleanShortFlag(y[1:], c.Flags()):
- inFlag = true
- case inFlag:
- inFlag = false
- case y == "":
- // strip empty commands, as the go tests expect this to be ok....
- case !strings.HasPrefix(y, "-"):
- commands = append(commands, y)
- inFlag = false
- }
- }
-
- if strings.HasSuffix(y, "\"") && !strings.HasSuffix(y, "\\\"") {
- inQuote = false
- }
- }
-
- return commands
-}
-
-// argsMinusFirstX removes only the first x from args. Otherwise, commands that look like
-// openshift admin policy add-role-to-user admin my-user, lose the admin argument (arg[4]).
-func argsMinusFirstX(args []string, x string) []string {
- for i, y := range args {
- if x == y {
- ret := []string{}
- ret = append(ret, args[:i]...)
- ret = append(ret, args[i+1:]...)
- return ret
- }
- }
- return args
-}
-
-// find the target command given the args and command tree
-// Meant to be run on the highest node. Only searches down.
-func (c *Command) Find(args []string) (*Command, []string, error) {
- if c == nil {
- return nil, nil, fmt.Errorf("Called find() on a nil Command")
- }
-
- var innerfind func(*Command, []string) (*Command, []string)
-
- innerfind = func(c *Command, innerArgs []string) (*Command, []string) {
- argsWOflags := stripFlags(innerArgs, c)
- if len(argsWOflags) == 0 {
- return c, innerArgs
- }
- nextSubCmd := argsWOflags[0]
- matches := make([]*Command, 0)
- for _, cmd := range c.commands {
- if cmd.Name() == nextSubCmd || cmd.HasAlias(nextSubCmd) { // exact name or alias match
- return innerfind(cmd, argsMinusFirstX(innerArgs, nextSubCmd))
- }
- if EnablePrefixMatching {
- if strings.HasPrefix(cmd.Name(), nextSubCmd) { // prefix match
- matches = append(matches, cmd)
- }
- for _, x := range cmd.Aliases {
- if strings.HasPrefix(x, nextSubCmd) {
- matches = append(matches, cmd)
- }
- }
- }
- }
-
- // only accept a single prefix match - multiple matches would be ambiguous
- if len(matches) == 1 {
- return innerfind(matches[0], argsMinusFirstX(innerArgs, argsWOflags[0]))
- }
-
- return c, innerArgs
- }
-
- commandFound, a := innerfind(c, args)
- argsWOflags := stripFlags(a, commandFound)
-
- // no subcommand, always take args
- if !commandFound.HasSubCommands() {
- return commandFound, a, nil
- }
-
- // root command with subcommands, do subcommand checking
- if commandFound == c && len(argsWOflags) > 0 {
- suggestionsString := ""
- if !c.DisableSuggestions {
- if c.SuggestionsMinimumDistance <= 0 {
- c.SuggestionsMinimumDistance = 2
- }
- if suggestions := c.SuggestionsFor(argsWOflags[0]); len(suggestions) > 0 {
- suggestionsString += "\n\nDid you mean this?\n"
- for _, s := range suggestions {
- suggestionsString += fmt.Sprintf("\t%v\n", s)
- }
- }
- }
- return commandFound, a, fmt.Errorf("unknown command %q for %q%s", argsWOflags[0], commandFound.CommandPath(), suggestionsString)
- }
-
- return commandFound, a, nil
-}
-
-func (c *Command) SuggestionsFor(typedName string) []string {
- suggestions := []string{}
- for _, cmd := range c.commands {
- if cmd.IsAvailableCommand() {
- levenshteinDistance := ld(typedName, cmd.Name(), true)
- suggestByLevenshtein := levenshteinDistance <= c.SuggestionsMinimumDistance
- suggestByPrefix := strings.HasPrefix(strings.ToLower(cmd.Name()), strings.ToLower(typedName))
- if suggestByLevenshtein || suggestByPrefix {
- suggestions = append(suggestions, cmd.Name())
- }
- for _, explicitSuggestion := range cmd.SuggestFor {
- if strings.EqualFold(typedName, explicitSuggestion) {
- suggestions = append(suggestions, cmd.Name())
- }
- }
- }
- }
- return suggestions
-}
-
-func (c *Command) VisitParents(fn func(*Command)) {
- var traverse func(*Command) *Command
-
- traverse = func(x *Command) *Command {
- if x != c {
- fn(x)
- }
- if x.HasParent() {
- return traverse(x.parent)
- }
- return x
- }
- traverse(c)
-}
-
-func (c *Command) Root() *Command {
- var findRoot func(*Command) *Command
-
- findRoot = func(x *Command) *Command {
- if x.HasParent() {
- return findRoot(x.parent)
- }
- return x
- }
-
- return findRoot(c)
-}
-
-// ArgsLenAtDash will return the length of f.Args at the moment when a -- was
-// found during arg parsing. This allows your program to know which args were
-// before the -- and which came after. (Description from
-// https://godoc.org/github.com/spf13/pflag#FlagSet.ArgsLenAtDash).
-func (c *Command) ArgsLenAtDash() int {
- return c.Flags().ArgsLenAtDash()
-}
-
-func (c *Command) execute(a []string) (err error) {
- if c == nil {
- return fmt.Errorf("Called Execute() on a nil Command")
- }
-
- if len(c.Deprecated) > 0 {
- c.Printf("Command %q is deprecated, %s\n", c.Name(), c.Deprecated)
- }
-
- // initialize help flag as the last point possible to allow for user
- // overriding
- c.initHelpFlag()
-
- err = c.ParseFlags(a)
- if err != nil {
- return c.FlagErrorFunc()(c, err)
- }
- // If help is called, regardless of other flags, return we want help
- // Also say we need help if the command isn't runnable.
- helpVal, err := c.Flags().GetBool("help")
- if err != nil {
- // should be impossible to get here as we always declare a help
- // flag in initHelpFlag()
- c.Println("\"help\" flag declared as non-bool. Please correct your code")
- return err
- }
-
- if helpVal || !c.Runnable() {
- return flag.ErrHelp
- }
-
- c.preRun()
-
- argWoFlags := c.Flags().Args()
- if c.DisableFlagParsing {
- argWoFlags = a
- }
-
- for p := c; p != nil; p = p.Parent() {
- if p.PersistentPreRunE != nil {
- if err := p.PersistentPreRunE(c, argWoFlags); err != nil {
- return err
- }
- break
- } else if p.PersistentPreRun != nil {
- p.PersistentPreRun(c, argWoFlags)
- break
- }
- }
- if c.PreRunE != nil {
- if err := c.PreRunE(c, argWoFlags); err != nil {
- return err
- }
- } else if c.PreRun != nil {
- c.PreRun(c, argWoFlags)
- }
-
- if c.RunE != nil {
- if err := c.RunE(c, argWoFlags); err != nil {
- return err
- }
- } else {
- c.Run(c, argWoFlags)
- }
- if c.PostRunE != nil {
- if err := c.PostRunE(c, argWoFlags); err != nil {
- return err
- }
- } else if c.PostRun != nil {
- c.PostRun(c, argWoFlags)
- }
- for p := c; p != nil; p = p.Parent() {
- if p.PersistentPostRunE != nil {
- if err := p.PersistentPostRunE(c, argWoFlags); err != nil {
- return err
- }
- break
- } else if p.PersistentPostRun != nil {
- p.PersistentPostRun(c, argWoFlags)
- break
- }
- }
-
- return nil
-}
-
-func (c *Command) preRun() {
- for _, x := range initializers {
- x()
- }
-}
-
-func (c *Command) errorMsgFromParse() string {
- s := c.flagErrorBuf.String()
-
- x := strings.Split(s, "\n")
-
- if len(x) > 0 {
- return x[0]
- }
- return ""
-}
-
-// Call execute to use the args (os.Args[1:] by default)
-// and run through the command tree finding appropriate matches
-// for commands and then corresponding flags.
-func (c *Command) Execute() error {
- _, err := c.ExecuteC()
- return err
-}
-
-func (c *Command) ExecuteC() (cmd *Command, err error) {
-
- // Regardless of what command execute is called on, run on Root only
- if c.HasParent() {
- return c.Root().ExecuteC()
- }
-
- // windows hook
- if preExecHookFn != nil {
- preExecHookFn(c)
- }
-
- // initialize help as the last point possible to allow for user
- // overriding
- c.initHelpCmd()
-
- var args []string
-
- // Workaround FAIL with "go test -v" or "cobra.test -test.v", see #155
- if c.args == nil && filepath.Base(os.Args[0]) != "cobra.test" {
- args = os.Args[1:]
- } else {
- args = c.args
- }
-
- cmd, flags, err := c.Find(args)
- if err != nil {
- // If found parse to a subcommand and then failed, talk about the subcommand
- if cmd != nil {
- c = cmd
- }
- if !c.SilenceErrors {
- c.Println("Error:", err.Error())
- c.Printf("Run '%v --help' for usage.\n", c.CommandPath())
- }
- return c, err
- }
- err = cmd.execute(flags)
- if err != nil {
- // Always show help if requested, even if SilenceErrors is in
- // effect
- if err == flag.ErrHelp {
- cmd.HelpFunc()(cmd, args)
- return cmd, nil
- }
-
- // If root command has SilentErrors flagged,
- // all subcommands should respect it
- if !cmd.SilenceErrors && !c.SilenceErrors {
- c.Println("Error:", err.Error())
- }
-
- // If root command has SilentUsage flagged,
- // all subcommands should respect it
- if !cmd.SilenceUsage && !c.SilenceUsage {
- c.Println(cmd.UsageString())
- }
- return cmd, err
- }
- return cmd, nil
-}
-
-func (c *Command) initHelpFlag() {
- c.mergePersistentFlags()
- if c.Flags().Lookup("help") == nil {
- c.Flags().BoolP("help", "h", false, "help for "+c.Name())
- }
-}
-
-func (c *Command) initHelpCmd() {
- if c.helpCommand == nil {
- if !c.HasSubCommands() {
- return
- }
-
- c.helpCommand = &Command{
- Use: "help [command]",
- Short: "Help about any command",
- Long: `Help provides help for any command in the application.
- Simply type ` + c.Name() + ` help [path to command] for full details.`,
- PersistentPreRun: func(cmd *Command, args []string) {},
- PersistentPostRun: func(cmd *Command, args []string) {},
-
- Run: func(c *Command, args []string) {
- cmd, _, e := c.Root().Find(args)
- if cmd == nil || e != nil {
- c.Printf("Unknown help topic %#q.", args)
- c.Root().Usage()
- } else {
- cmd.Help()
- }
- },
- }
- }
- c.AddCommand(c.helpCommand)
-}
-
-// Used for testing.
-func (c *Command) ResetCommands() {
- c.commands = nil
- c.helpCommand = nil
-}
-
-// Sorts commands by their names.
-type commandSorterByName []*Command
-
-func (c commandSorterByName) Len() int { return len(c) }
-func (c commandSorterByName) Swap(i, j int) { c[i], c[j] = c[j], c[i] }
-func (c commandSorterByName) Less(i, j int) bool { return c[i].Name() < c[j].Name() }
-
-// Commands returns a sorted slice of child commands.
-func (c *Command) Commands() []*Command {
- // do not sort commands if it already sorted or sorting was disabled
- if EnableCommandSorting && !c.commandsAreSorted {
- sort.Sort(commandSorterByName(c.commands))
- c.commandsAreSorted = true
- }
- return c.commands
-}
-
-// AddCommand adds one or more commands to this parent command.
-func (c *Command) AddCommand(cmds ...*Command) {
- for i, x := range cmds {
- if cmds[i] == c {
- panic("Command can't be a child of itself")
- }
- cmds[i].parent = c
- // update max lengths
- usageLen := len(x.Use)
- if usageLen > c.commandsMaxUseLen {
- c.commandsMaxUseLen = usageLen
- }
- commandPathLen := len(x.CommandPath())
- if commandPathLen > c.commandsMaxCommandPathLen {
- c.commandsMaxCommandPathLen = commandPathLen
- }
- nameLen := len(x.Name())
- if nameLen > c.commandsMaxNameLen {
- c.commandsMaxNameLen = nameLen
- }
- // If global normalization function exists, update all children
- if c.globNormFunc != nil {
- x.SetGlobalNormalizationFunc(c.globNormFunc)
- }
- c.commands = append(c.commands, x)
- c.commandsAreSorted = false
- }
-}
-
-// RemoveCommand removes one or more commands from a parent command.
-func (c *Command) RemoveCommand(cmds ...*Command) {
- commands := []*Command{}
-main:
- for _, command := range c.commands {
- for _, cmd := range cmds {
- if command == cmd {
- command.parent = nil
- continue main
- }
- }
- commands = append(commands, command)
- }
- c.commands = commands
- // recompute all lengths
- c.commandsMaxUseLen = 0
- c.commandsMaxCommandPathLen = 0
- c.commandsMaxNameLen = 0
- for _, command := range c.commands {
- usageLen := len(command.Use)
- if usageLen > c.commandsMaxUseLen {
- c.commandsMaxUseLen = usageLen
- }
- commandPathLen := len(command.CommandPath())
- if commandPathLen > c.commandsMaxCommandPathLen {
- c.commandsMaxCommandPathLen = commandPathLen
- }
- nameLen := len(command.Name())
- if nameLen > c.commandsMaxNameLen {
- c.commandsMaxNameLen = nameLen
- }
- }
-}
-
-// Print is a convenience method to Print to the defined output, fallback to Stderr if not set.
-func (c *Command) Print(i ...interface{}) {
- fmt.Fprint(c.OutOrStderr(), i...)
-}
-
-// Println is a convenience method to Println to the defined output, fallback to Stderr if not set.
-func (c *Command) Println(i ...interface{}) {
- str := fmt.Sprintln(i...)
- c.Print(str)
-}
-
-// Printf is a convenience method to Printf to the defined output, fallback to Stderr if not set.
-func (c *Command) Printf(format string, i ...interface{}) {
- str := fmt.Sprintf(format, i...)
- c.Print(str)
-}
-
-// CommandPath returns the full path to this command.
-func (c *Command) CommandPath() string {
- str := c.Name()
- x := c
- for x.HasParent() {
- str = x.parent.Name() + " " + str
- x = x.parent
- }
- return str
-}
-
-// UseLine puts out the full usage for a given command (including parents).
-func (c *Command) UseLine() string {
- str := ""
- if c.HasParent() {
- str = c.parent.CommandPath() + " "
- }
- return str + c.Use
-}
-
-// For use in determining which flags have been assigned to which commands
-// and which persist.
-func (c *Command) DebugFlags() {
- c.Println("DebugFlags called on", c.Name())
- var debugflags func(*Command)
-
- debugflags = func(x *Command) {
- if x.HasFlags() || x.HasPersistentFlags() {
- c.Println(x.Name())
- }
- if x.HasFlags() {
- x.flags.VisitAll(func(f *flag.Flag) {
- if x.HasPersistentFlags() {
- if x.persistentFlag(f.Name) == nil {
- c.Println(" -"+f.Shorthand+",", "--"+f.Name, "["+f.DefValue+"]", "", f.Value, " [L]")
- } else {
- c.Println(" -"+f.Shorthand+",", "--"+f.Name, "["+f.DefValue+"]", "", f.Value, " [LP]")
- }
- } else {
- c.Println(" -"+f.Shorthand+",", "--"+f.Name, "["+f.DefValue+"]", "", f.Value, " [L]")
- }
- })
- }
- if x.HasPersistentFlags() {
- x.pflags.VisitAll(func(f *flag.Flag) {
- if x.HasFlags() {
- if x.flags.Lookup(f.Name) == nil {
- c.Println(" -"+f.Shorthand+",", "--"+f.Name, "["+f.DefValue+"]", "", f.Value, " [P]")
- }
- } else {
- c.Println(" -"+f.Shorthand+",", "--"+f.Name, "["+f.DefValue+"]", "", f.Value, " [P]")
- }
- })
- }
- c.Println(x.flagErrorBuf)
- if x.HasSubCommands() {
- for _, y := range x.commands {
- debugflags(y)
- }
- }
- }
-
- debugflags(c)
-}
-
-// Name returns the command's name: the first word in the use line.
-func (c *Command) Name() string {
- if c.name != "" {
- return c.name
- }
- name := c.Use
- i := strings.Index(name, " ")
- if i >= 0 {
- name = name[:i]
- }
- return name
-}
-
-// HasAlias determines if a given string is an alias of the command.
-func (c *Command) HasAlias(s string) bool {
- for _, a := range c.Aliases {
- if a == s {
- return true
- }
- }
- return false
-}
-
-func (c *Command) NameAndAliases() string {
- return strings.Join(append([]string{c.Name()}, c.Aliases...), ", ")
-}
-
-func (c *Command) HasExample() bool {
- return len(c.Example) > 0
-}
-
-// Runnable determines if the command is itself runnable.
-func (c *Command) Runnable() bool {
- return c.Run != nil || c.RunE != nil
-}
-
-// HasSubCommands determines if the command has children commands.
-func (c *Command) HasSubCommands() bool {
- return len(c.commands) > 0
-}
-
-// IsAvailableCommand determines if a command is available as a non-help command
-// (this includes all non deprecated/hidden commands).
-func (c *Command) IsAvailableCommand() bool {
- if len(c.Deprecated) != 0 || c.Hidden {
- return false
- }
-
- if c.HasParent() && c.Parent().helpCommand == c {
- return false
- }
-
- if c.Runnable() || c.HasAvailableSubCommands() {
- return true
- }
-
- return false
-}
-
-// IsHelpCommand determines if a command is a 'help' command; a help command is
-// determined by the fact that it is NOT runnable/hidden/deprecated, and has no
-// sub commands that are runnable/hidden/deprecated.
-func (c *Command) IsHelpCommand() bool {
-
- // if a command is runnable, deprecated, or hidden it is not a 'help' command
- if c.Runnable() || len(c.Deprecated) != 0 || c.Hidden {
- return false
- }
-
- // if any non-help sub commands are found, the command is not a 'help' command
- for _, sub := range c.commands {
- if !sub.IsHelpCommand() {
- return false
- }
- }
-
- // the command either has no sub commands, or no non-help sub commands
- return true
-}
-
-// HasHelpSubCommands determines if a command has any available 'help' sub commands
-// that need to be shown in the usage/help default template under 'additional help
-// topics'.
-func (c *Command) HasHelpSubCommands() bool {
-
- // return true on the first found available 'help' sub command
- for _, sub := range c.commands {
- if sub.IsHelpCommand() {
- return true
- }
- }
-
- // the command either has no sub commands, or no available 'help' sub commands
- return false
-}
-
-// HasAvailableSubCommands determines if a command has available sub commands that
-// need to be shown in the usage/help default template under 'available commands'.
-func (c *Command) HasAvailableSubCommands() bool {
-
- // return true on the first found available (non deprecated/help/hidden)
- // sub command
- for _, sub := range c.commands {
- if sub.IsAvailableCommand() {
- return true
- }
- }
-
- // the command either has no sub comamnds, or no available (non deprecated/help/hidden)
- // sub commands
- return false
-}
-
-// HasParent determines if the command is a child command.
-func (c *Command) HasParent() bool {
- return c.parent != nil
-}
-
-// GlobalNormalizationFunc returns the global normalization function or nil if doesn't exists.
-func (c *Command) GlobalNormalizationFunc() func(f *flag.FlagSet, name string) flag.NormalizedName {
- return c.globNormFunc
-}
-
-// Flage returns the complete FlagSet that applies
-// to this command (local and persistent declared here and by all parents).
-func (c *Command) Flags() *flag.FlagSet {
- if c.flags == nil {
- c.flags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- if c.flagErrorBuf == nil {
- c.flagErrorBuf = new(bytes.Buffer)
- }
- c.flags.SetOutput(c.flagErrorBuf)
- }
- return c.flags
-}
-
-// LocalNonPersistentFlags are flags specific to this command which will NOT persist to subcommands.
-func (c *Command) LocalNonPersistentFlags() *flag.FlagSet {
- persistentFlags := c.PersistentFlags()
-
- out := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- c.LocalFlags().VisitAll(func(f *flag.Flag) {
- if persistentFlags.Lookup(f.Name) == nil {
- out.AddFlag(f)
- }
- })
- return out
-}
-
-// LocalFlags returns the local FlagSet specifically set in the current command.
-func (c *Command) LocalFlags() *flag.FlagSet {
- c.mergePersistentFlags()
-
- local := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- c.lflags.VisitAll(func(f *flag.Flag) {
- local.AddFlag(f)
- })
- if !c.HasParent() {
- flag.CommandLine.VisitAll(func(f *flag.Flag) {
- if local.Lookup(f.Name) == nil {
- local.AddFlag(f)
- }
- })
- }
- return local
-}
-
-// InheritedFlags returns all flags which were inherited from parents commands.
-func (c *Command) InheritedFlags() *flag.FlagSet {
- c.mergePersistentFlags()
-
- inherited := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- local := c.LocalFlags()
-
- var rmerge func(x *Command)
-
- rmerge = func(x *Command) {
- if x.HasPersistentFlags() {
- x.PersistentFlags().VisitAll(func(f *flag.Flag) {
- if inherited.Lookup(f.Name) == nil && local.Lookup(f.Name) == nil {
- inherited.AddFlag(f)
- }
- })
- }
- if x.HasParent() {
- rmerge(x.parent)
- }
- }
-
- if c.HasParent() {
- rmerge(c.parent)
- }
-
- return inherited
-}
-
-// NonInheritedFlags returns all flags which were not inherited from parent commands.
-func (c *Command) NonInheritedFlags() *flag.FlagSet {
- return c.LocalFlags()
-}
-
-// PersistentFlags returns the persistent FlagSet specifically set in the current command.
-func (c *Command) PersistentFlags() *flag.FlagSet {
- if c.pflags == nil {
- c.pflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- if c.flagErrorBuf == nil {
- c.flagErrorBuf = new(bytes.Buffer)
- }
- c.pflags.SetOutput(c.flagErrorBuf)
- }
- return c.pflags
-}
-
-// ResetFlags is used in testing.
-func (c *Command) ResetFlags() {
- c.flagErrorBuf = new(bytes.Buffer)
- c.flagErrorBuf.Reset()
- c.flags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- c.flags.SetOutput(c.flagErrorBuf)
- c.pflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- c.pflags.SetOutput(c.flagErrorBuf)
-}
-
-// Does the command contain any flags (local plus persistent from the entire structure).
-func (c *Command) HasFlags() bool {
- return c.Flags().HasFlags()
-}
-
-// Does the command contain persistent flags.
-func (c *Command) HasPersistentFlags() bool {
- return c.PersistentFlags().HasFlags()
-}
-
-// Does the command has flags specifically declared locally.
-func (c *Command) HasLocalFlags() bool {
- return c.LocalFlags().HasFlags()
-}
-
-// Does the command have flags inherited from its parent command.
-func (c *Command) HasInheritedFlags() bool {
- return c.InheritedFlags().HasFlags()
-}
-
-// Does the command contain any flags (local plus persistent from the entire
-// structure) which are not hidden or deprecated.
-func (c *Command) HasAvailableFlags() bool {
- return c.Flags().HasAvailableFlags()
-}
-
-// Does the command contain persistent flags which are not hidden or deprecated.
-func (c *Command) HasAvailablePersistentFlags() bool {
- return c.PersistentFlags().HasAvailableFlags()
-}
-
-// Does the command has flags specifically declared locally which are not hidden
-// or deprecated.
-func (c *Command) HasAvailableLocalFlags() bool {
- return c.LocalFlags().HasAvailableFlags()
-}
-
-// Does the command have flags inherited from its parent command which are
-// not hidden or deprecated.
-func (c *Command) HasAvailableInheritedFlags() bool {
- return c.InheritedFlags().HasAvailableFlags()
-}
-
-// Flag climbs up the command tree looking for matching flag.
-func (c *Command) Flag(name string) (flag *flag.Flag) {
- flag = c.Flags().Lookup(name)
-
- if flag == nil {
- flag = c.persistentFlag(name)
- }
-
- return
-}
-
-// Recursively find matching persistent flag.
-func (c *Command) persistentFlag(name string) (flag *flag.Flag) {
- if c.HasPersistentFlags() {
- flag = c.PersistentFlags().Lookup(name)
- }
-
- if flag == nil && c.HasParent() {
- flag = c.parent.persistentFlag(name)
- }
- return
-}
-
-// ParseFlags parses persistent flag tree and local flags.
-func (c *Command) ParseFlags(args []string) (err error) {
- if c.DisableFlagParsing {
- return nil
- }
- c.mergePersistentFlags()
- err = c.Flags().Parse(args)
- return
-}
-
-// Parent returns a commands parent command.
-func (c *Command) Parent() *Command {
- return c.parent
-}
-
-func (c *Command) mergePersistentFlags() {
- var rmerge func(x *Command)
-
- // Save the set of local flags
- if c.lflags == nil {
- c.lflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- if c.flagErrorBuf == nil {
- c.flagErrorBuf = new(bytes.Buffer)
- }
- c.lflags.SetOutput(c.flagErrorBuf)
- addtolocal := func(f *flag.Flag) {
- c.lflags.AddFlag(f)
- }
- c.Flags().VisitAll(addtolocal)
- c.PersistentFlags().VisitAll(addtolocal)
- }
- rmerge = func(x *Command) {
- if !x.HasParent() {
- flag.CommandLine.VisitAll(func(f *flag.Flag) {
- if x.PersistentFlags().Lookup(f.Name) == nil {
- x.PersistentFlags().AddFlag(f)
- }
- })
- }
- if x.HasPersistentFlags() {
- x.PersistentFlags().VisitAll(func(f *flag.Flag) {
- if c.Flags().Lookup(f.Name) == nil {
- c.Flags().AddFlag(f)
- }
- })
- }
- if x.HasParent() {
- rmerge(x.parent)
- }
- }
-
- rmerge(c)
-}
diff --git a/newt/vendor/github.com/spf13/cobra/command_win.go b/newt/vendor/github.com/spf13/cobra/command_win.go
deleted file mode 100644
index 4b0eaa1b..00000000
--- a/newt/vendor/github.com/spf13/cobra/command_win.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// +build windows
-
-package cobra
-
-import (
- "os"
- "time"
-
- "github.com/inconshreveable/mousetrap"
-)
-
-var preExecHookFn = preExecHook
-
-// enables an information splash screen on Windows if the CLI is started from explorer.exe.
-var MousetrapHelpText string = `This is a command line tool
-
-You need to open cmd.exe and run it from there.
-`
-
-func preExecHook(c *Command) {
- if mousetrap.StartedByExplorer() {
- c.Print(MousetrapHelpText)
- time.Sleep(5 * time.Second)
- os.Exit(1)
- }
-}
diff --git a/newt/vendor/github.com/spf13/jwalterweatherman/README.md b/newt/vendor/github.com/spf13/jwalterweatherman/README.md
deleted file mode 100644
index c6f327c1..00000000
--- a/newt/vendor/github.com/spf13/jwalterweatherman/README.md
+++ /dev/null
@@ -1,161 +0,0 @@
-jWalterWeatherman
-=================
-
-Seamless printing to the terminal (stdout) and logging to a io.Writer
-(file) that?s as easy to use as fmt.Println.
-
-![and_that__s_why_you_always_leave_a_note_by_jonnyetc-d57q7um](https://cloud.githubusercontent.com/assets/173412/11002937/ccd01654-847d-11e5-828e-12ebaf582eaf.jpg)
-Graphic by [JonnyEtc](http://jonnyetc.deviantart.com/art/And-That-s-Why-You-Always-Leave-a-Note-315311422)
-
-JWW is primarily a wrapper around the excellent standard log library. It
-provides a few advantages over using the standard log library alone.
-
-1. Ready to go out of the box.
-2. One library for both printing to the terminal and logging (to files).
-3. Really easy to log to either a temp file or a file you specify.
-
-
-I really wanted a very straightforward library that could seamlessly do
-the following things.
-
-1. Replace all the println, printf, etc statements thought my code with
- something more useful
-2. Allow the user to easily control what levels are printed to stdout
-3. Allow the user to easily control what levels are logged
-4. Provide an easy mechanism (like fmt.Println) to print info to the user
- which can be easily logged as well
-5. Due to 2 & 3 provide easy verbose mode for output and logs
-6. Not have any unnecessary initialization cruft. Just use it.
-
-# Usage
-
-## Step 1. Use it
-Put calls throughout your source based on type of feedback.
-No initialization or setup needs to happen. Just start calling things.
-
-Available Loggers are:
-
- * TRACE
- * DEBUG
- * INFO
- * WARN
- * ERROR
- * CRITICAL
- * FATAL
-
-These each are loggers based on the log standard library and follow the
-standard usage. Eg..
-
-```go
- import (
- jww "github.com/spf13/jwalterweatherman"
- )
-
- ...
-
- if err != nil {
-
- // This is a pretty serious error and the user should know about
- // it. It will be printed to the terminal as well as logged under the
- // default thresholds.
-
- jww.ERROR.Println(err)
- }
-
- if err2 != nil {
- // This error isn?t going to materially change the behavior of the
- // application, but it?s something that may not be what the user
- // expects. Under the default thresholds, Warn will be logged, but
- // not printed to the terminal.
-
- jww.WARN.Println(err2)
- }
-
- // Information that?s relevant to what?s happening, but not very
- // important for the user. Under the default thresholds this will be
- // discarded.
-
- jww.INFO.Printf("information %q", response)
-
-```
-
-_Why 7 levels?_
-
-Maybe you think that 7 levels are too much for any application... and you
-are probably correct. Just because there are seven levels doesn?t mean
-that you should be using all 7 levels. Pick the right set for your needs.
-Remember they only have to mean something to your project.
-
-## Step 2. Optionally configure JWW
-
-Under the default thresholds :
-
- * Debug, Trace & Info goto /dev/null
- * Warn and above is logged (when a log file/io.Writer is provided)
- * Error and above is printed to the terminal (stdout)
-
-### Changing the thresholds
-
-The threshold can be changed at any time, but will only affect calls that
-execute after the change was made.
-
-This is very useful if your application has a verbose mode. Of course you
-can decide what verbose means to you or even have multiple levels of
-verbosity.
-
-
-```go
- import (
- jww "github.com/spf13/jwalterweatherman"
- )
-
- if Verbose {
- jww.SetLogThreshold(jww.LevelTrace)
- jww.SetStdoutThreshold(jww.LevelInfo)
- }
-```
-
-Note that JWW's own internal output uses log levels as well, so set the log
-level before making any other calls if you want to see what it's up to.
-
-### Using a temp log file
-
-JWW conveniently creates a temporary file and sets the log Handle to
-a io.Writer created for it. You should call this early in your application
-initialization routine as it will only log calls made after it is executed.
-When this option is used, the library will fmt.Println where to find the
-log file.
-
-```go
- import (
- jww "github.com/spf13/jwalterweatherman"
- )
-
- jww.UseTempLogFile("YourAppName")
-
-```
-
-### Setting a log file
-
-JWW can log to any file you provide a path to (provided it?s writable).
-Will only append to this file.
-
-
-```go
- import (
- jww "github.com/spf13/jwalterweatherman"
- )
-
- jww.SetLogFile("/path/to/logfile")
-
-```
-
-
-# More information
-
-This is an early release. I?ve been using it for a while and this is the
-third interface I?ve tried. I like this one pretty well, but no guarantees
-that it won?t change a bit.
-
-I wrote this for use in [hugo](http://hugo.spf13.com). If you are looking
-for a static website engine that?s super fast please checkout Hugo.
diff --git a/newt/vendor/github.com/spf13/jwalterweatherman/thatswhyyoualwaysleaveanote.go b/newt/vendor/github.com/spf13/jwalterweatherman/thatswhyyoualwaysleaveanote.go
deleted file mode 100644
index b64ed469..00000000
--- a/newt/vendor/github.com/spf13/jwalterweatherman/thatswhyyoualwaysleaveanote.go
+++ /dev/null
@@ -1,256 +0,0 @@
-// Copyright ? 2016 Steve Francia <sp...@spf13.com>.
-//
-// Use of this source code is governed by an MIT-style
-// license that can be found in the LICENSE file.
-
-package jwalterweatherman
-
-import (
- "fmt"
- "io"
- "io/ioutil"
- "log"
- "os"
- "sync/atomic"
-)
-
-// Level describes the chosen log level between
-// debug and critical.
-type Level int
-
-type NotePad struct {
- Handle io.Writer
- Level Level
- Prefix string
- Logger **log.Logger
- counter uint64
-}
-
-func (n *NotePad) incr() {
- atomic.AddUint64(&n.counter, 1)
-}
-
-func (n *NotePad) resetCounter() {
- atomic.StoreUint64(&n.counter, 0)
-}
-
-func (n *NotePad) getCount() uint64 {
- return atomic.LoadUint64(&n.counter)
-}
-
-type countingWriter struct {
- incrFunc func()
-}
-
-func (cw *countingWriter) Write(p []byte) (n int, err error) {
- cw.incrFunc()
-
- return 0, nil
-}
-
-// Feedback is special. It writes plainly to the output while
-// logging with the standard extra information (date, file, etc)
-// Only Println and Printf are currently provided for this
-type Feedback struct{}
-
-const (
- LevelTrace Level = iota
- LevelDebug
- LevelInfo
- LevelWarn
- LevelError
- LevelCritical
- LevelFatal
- DefaultLogThreshold = LevelWarn
- DefaultStdoutThreshold = LevelError
-)
-
-var (
- TRACE *log.Logger
- DEBUG *log.Logger
- INFO *log.Logger
- WARN *log.Logger
- ERROR *log.Logger
- CRITICAL *log.Logger
- FATAL *log.Logger
- LOG *log.Logger
- FEEDBACK Feedback
- LogHandle io.Writer = ioutil.Discard
- OutHandle io.Writer = os.Stdout
- BothHandle io.Writer = io.MultiWriter(LogHandle, OutHandle)
- NotePads []*NotePad = []*NotePad{trace, debug, info, warn, err, critical, fatal}
-
- trace *NotePad = &NotePad{Level: LevelTrace, Handle: os.Stdout, Logger: &TRACE, Prefix: "TRACE: "}
- debug *NotePad = &NotePad{Level: LevelDebug, Handle: os.Stdout, Logger: &DEBUG, Prefix: "DEBUG: "}
- info *NotePad = &NotePad{Level: LevelInfo, Handle: os.Stdout, Logger: &INFO, Prefix: "INFO: "}
- warn *NotePad = &NotePad{Level: LevelWarn, Handle: os.Stdout, Logger: &WARN, Prefix: "WARN: "}
- err *NotePad = &NotePad{Level: LevelError, Handle: os.Stdout, Logger: &ERROR, Prefix: "ERROR: "}
- critical *NotePad = &NotePad{Level: LevelCritical, Handle: os.Stdout, Logger: &CRITICAL, Prefix: "CRITICAL: "}
- fatal *NotePad = &NotePad{Level: LevelFatal, Handle: os.Stdout, Logger: &FATAL, Prefix: "FATAL: "}
- logThreshold Level = DefaultLogThreshold
- outputThreshold Level = DefaultStdoutThreshold
-)
-
-const (
- DATE = log.Ldate
- TIME = log.Ltime
- SFILE = log.Lshortfile
- LFILE = log.Llongfile
- MSEC = log.Lmicroseconds
-)
-
-var logFlags = DATE | TIME | SFILE
-
-func init() {
- SetStdoutThreshold(DefaultStdoutThreshold)
-}
-
-// initialize will setup the jWalterWeatherman standard approach of providing the user
-// some feedback and logging a potentially different amount based on independent log and output thresholds.
-// By default the output has a lower threshold than logged
-// Don't use if you have manually set the Handles of the different levels as it will overwrite them.
-func initialize() {
- BothHandle = io.MultiWriter(LogHandle, OutHandle)
-
- for _, n := range NotePads {
- if n.Level < outputThreshold && n.Level < logThreshold {
- n.Handle = ioutil.Discard
- } else if n.Level >= outputThreshold && n.Level >= logThreshold {
- n.Handle = BothHandle
- } else if n.Level >= outputThreshold && n.Level < logThreshold {
- n.Handle = OutHandle
- } else {
- n.Handle = LogHandle
- }
- }
-
- for _, n := range NotePads {
- n.Handle = io.MultiWriter(n.Handle, &countingWriter{n.incr})
- *n.Logger = log.New(n.Handle, n.Prefix, logFlags)
- }
-
- LOG = log.New(LogHandle,
- "LOG: ",
- logFlags)
-}
-
-// Set the log Flags (Available flag: DATE, TIME, SFILE, LFILE and MSEC)
-func SetLogFlag(flags int) {
- logFlags = flags
- initialize()
-}
-
-// Level returns the current global log threshold.
-func LogThreshold() Level {
- return logThreshold
-}
-
-// Level returns the current global output threshold.
-func StdoutThreshold() Level {
- return outputThreshold
-}
-
-// Ensures that the level provided is within the bounds of available levels
-func levelCheck(level Level) Level {
- switch {
- case level <= LevelTrace:
- return LevelTrace
- case level >= LevelFatal:
- return LevelFatal
- default:
- return level
- }
-}
-
-// Establishes a threshold where anything matching or above will be logged
-func SetLogThreshold(level Level) {
- logThreshold = levelCheck(level)
- initialize()
-}
-
-// Establishes a threshold where anything matching or above will be output
-func SetStdoutThreshold(level Level) {
- outputThreshold = levelCheck(level)
- initialize()
-}
-
-// Conveniently Sets the Log Handle to a io.writer created for the file behind the given filepath
-// Will only append to this file
-func SetLogFile(path string) {
- file, err := os.OpenFile(path, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666)
- if err != nil {
- CRITICAL.Println("Failed to open log file:", path, err)
- os.Exit(-1)
- }
-
- INFO.Println("Logging to", file.Name())
-
- LogHandle = file
- initialize()
-}
-
-// Conveniently Creates a temporary file and sets the Log Handle to a io.writer created for it
-func UseTempLogFile(prefix string) {
- file, err := ioutil.TempFile(os.TempDir(), prefix)
- if err != nil {
- CRITICAL.Println(err)
- }
-
- INFO.Println("Logging to", file.Name())
-
- LogHandle = file
- initialize()
-}
-
-// LogCountForLevel returns the number of log invocations for a given level.
-func LogCountForLevel(l Level) uint64 {
- for _, np := range NotePads {
- if np.Level == l {
- return np.getCount()
- }
- }
- return 0
-}
-
-// LogCountForLevelsGreaterThanorEqualTo returns the number of log invocations
-// greater than or equal to a given level threshold.
-func LogCountForLevelsGreaterThanorEqualTo(threshold Level) uint64 {
- var cnt uint64
- for _, np := range NotePads {
- if np.Level >= threshold {
- cnt += np.getCount()
- }
- }
- return cnt
-}
-
-// ResetLogCounters resets the invocation counters for all levels.
-func ResetLogCounters() {
- for _, np := range NotePads {
- np.resetCounter()
- }
-}
-
-// Disables logging for the entire JWW system
-func DiscardLogging() {
- LogHandle = ioutil.Discard
- initialize()
-}
-
-// Feedback is special. It writes plainly to the output while
-// logging with the standard extra information (date, file, etc)
-// Only Println and Printf are currently provided for this
-func (fb *Feedback) Println(v ...interface{}) {
- s := fmt.Sprintln(v...)
- fmt.Print(s)
- LOG.Output(2, s)
-}
-
-// Feedback is special. It writes plainly to the output while
-// logging with the standard extra information (date, file, etc)
-// Only Println and Printf are currently provided for this
-func (fb *Feedback) Printf(format string, v ...interface{}) {
- s := fmt.Sprintf(format, v...)
- fmt.Print(s)
- LOG.Output(2, s)
-}
diff --git a/newt/vendor/github.com/spf13/pflag/.travis.yml b/newt/vendor/github.com/spf13/pflag/.travis.yml
deleted file mode 100644
index 707bdc39..00000000
--- a/newt/vendor/github.com/spf13/pflag/.travis.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-sudo: false
-
-language: go
-
-go:
- - 1.6.3
- - 1.7.3
- - tip
-
-matrix:
- allow_failures:
- - go: tip
-install:
- - go get github.com/golang/lint/golint
- - export PATH=$GOPATH/bin:$PATH
- - go install ./...
-
-script:
- - verify/all.sh -v
- - go test ./...
diff --git a/newt/vendor/github.com/spf13/pflag/README.md b/newt/vendor/github.com/spf13/pflag/README.md
deleted file mode 100644
index 08ad9456..00000000
--- a/newt/vendor/github.com/spf13/pflag/README.md
+++ /dev/null
@@ -1,275 +0,0 @@
-[![Build Status](https://travis-ci.org/spf13/pflag.svg?branch=master)](https://travis-ci.org/spf13/pflag)
-
-## Description
-
-pflag is a drop-in replacement for Go's flag package, implementing
-POSIX/GNU-style --flags.
-
-pflag is compatible with the [GNU extensions to the POSIX recommendations
-for command-line options][1]. For a more precise description, see the
-"Command-line flag syntax" section below.
-
-[1]: http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html
-
-pflag is available under the same style of BSD license as the Go language,
-which can be found in the LICENSE file.
-
-## Installation
-
-pflag is available using the standard `go get` command.
-
-Install by running:
-
- go get github.com/spf13/pflag
-
-Run tests by running:
-
- go test github.com/spf13/pflag
-
-## Usage
-
-pflag is a drop-in replacement of Go's native flag package. If you import
-pflag under the name "flag" then all code should continue to function
-with no changes.
-
-``` go
-import flag "github.com/spf13/pflag"
-```
-
-There is one exception to this: if you directly instantiate the Flag struct
-there is one more field "Shorthand" that you will need to set.
-Most code never instantiates this struct directly, and instead uses
-functions such as String(), BoolVar(), and Var(), and is therefore
-unaffected.
-
-Define flags using flag.String(), Bool(), Int(), etc.
-
-This declares an integer flag, -flagname, stored in the pointer ip, with type *int.
-
-``` go
-var ip *int = flag.Int("flagname", 1234, "help message for flagname")
-```
-
-If you like, you can bind the flag to a variable using the Var() functions.
-
-``` go
-var flagvar int
-func init() {
- flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname")
-}
-```
-
-Or you can create custom flags that satisfy the Value interface (with
-pointer receivers) and couple them to flag parsing by
-
-``` go
-flag.Var(&flagVal, "name", "help message for flagname")
-```
-
-For such flags, the default value is just the initial value of the variable.
-
-After all flags are defined, call
-
-``` go
-flag.Parse()
-```
-
-to parse the command line into the defined flags.
-
-Flags may then be used directly. If you're using the flags themselves,
-they are all pointers; if you bind to variables, they're values.
-
-``` go
-fmt.Println("ip has value ", *ip)
-fmt.Println("flagvar has value ", flagvar)
-```
-
-There are helpers function to get values later if you have the FlagSet but
-it was difficult to keep up with all of the flag pointers in your code.
-If you have a pflag.FlagSet with a flag called 'flagname' of type int you
-can use GetInt() to get the int value. But notice that 'flagname' must exist
-and it must be an int. GetString("flagname") will fail.
-
-``` go
-i, err := flagset.GetInt("flagname")
-```
-
-After parsing, the arguments after the flag are available as the
-slice flag.Args() or individually as flag.Arg(i).
-The arguments are indexed from 0 through flag.NArg()-1.
-
-The pflag package also defines some new functions that are not in flag,
-that give one-letter shorthands for flags. You can use these by appending
-'P' to the name of any function that defines a flag.
-
-``` go
-var ip = flag.IntP("flagname", "f", 1234, "help message")
-var flagvar bool
-func init() {
- flag.BoolVarP("boolname", "b", true, "help message")
-}
-flag.VarP(&flagVar, "varname", "v", 1234, "help message")
-```
-
-Shorthand letters can be used with single dashes on the command line.
-Boolean shorthand flags can be combined with other shorthand flags.
-
-The default set of command-line flags is controlled by
-top-level functions. The FlagSet type allows one to define
-independent sets of flags, such as to implement subcommands
-in a command-line interface. The methods of FlagSet are
-analogous to the top-level functions for the command-line
-flag set.
-
-## Setting no option default values for flags
-
-After you create a flag it is possible to set the pflag.NoOptDefVal for
-the given flag. Doing this changes the meaning of the flag slightly. If
-a flag has a NoOptDefVal and the flag is set on the command line without
-an option the flag will be set to the NoOptDefVal. For example given:
-
-``` go
-var ip = flag.IntP("flagname", "f", 1234, "help message")
-flag.Lookup("flagname").NoOptDefVal = "4321"
-```
-
-Would result in something like
-
-| Parsed Arguments | Resulting Value |
-| ------------- | ------------- |
-| --flagname=1357 | ip=1357 |
-| --flagname | ip=4321 |
-| [nothing] | ip=1234 |
-
-## Command line flag syntax
-
-```
---flag // boolean flags, or flags with no option default values
---flag x // only on flags without a default value
---flag=x
-```
-
-Unlike the flag package, a single dash before an option means something
-different than a double dash. Single dashes signify a series of shorthand
-letters for flags. All but the last shorthand letter must be boolean flags
-or a flag with a default value
-
-```
-// boolean or flags where the 'no option default value' is set
--f
--f=true
--abc
-but
--b true is INVALID
-
-// non-boolean and flags without a 'no option default value'
--n 1234
--n=1234
--n1234
-
-// mixed
--abcs "hello"
--absd="hello"
--abcs1234
-```
-
-Flag parsing stops after the terminator "--". Unlike the flag package,
-flags can be interspersed with arguments anywhere on the command line
-before this terminator.
-
-Integer flags accept 1234, 0664, 0x1234 and may be negative.
-Boolean flags (in their long form) accept 1, 0, t, f, true, false,
-TRUE, FALSE, True, False.
-Duration flags accept any input valid for time.ParseDuration.
-
-## Mutating or "Normalizing" Flag names
-
-It is possible to set a custom flag name 'normalization function.' It allows flag names to be mutated both when created in the code and when used on the command line to some 'normalized' form. The 'normalized' form is used for comparison. Two examples of using the custom normalization func follow.
-
-**Example #1**: You want -, _, and . in flags to compare the same. aka --my-flag == --my_flag == --my.flag
-
-``` go
-func wordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
- from := []string{"-", "_"}
- to := "."
- for _, sep := range from {
- name = strings.Replace(name, sep, to, -1)
- }
- return pflag.NormalizedName(name)
-}
-
-myFlagSet.SetNormalizeFunc(wordSepNormalizeFunc)
-```
-
-**Example #2**: You want to alias two flags. aka --old-flag-name == --new-flag-name
-
-``` go
-func aliasNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
- switch name {
- case "old-flag-name":
- name = "new-flag-name"
- break
- }
- return pflag.NormalizedName(name)
-}
-
-myFlagSet.SetNormalizeFunc(aliasNormalizeFunc)
-```
-
-## Deprecating a flag or its shorthand
-It is possible to deprecate a flag, or just its shorthand. Deprecating a flag/shorthand hides it from help text and prints a usage message when the deprecated flag/shorthand is used.
-
-**Example #1**: You want to deprecate a flag named "badflag" as well as inform the users what flag they should use instead.
-```go
-// deprecate a flag by specifying its name and a usage message
-flags.MarkDeprecated("badflag", "please use --good-flag instead")
-```
-This hides "badflag" from help text, and prints `Flag --badflag has been deprecated, please use --good-flag instead` when "badflag" is used.
-
-**Example #2**: You want to keep a flag name "noshorthandflag" but deprecate its shortname "n".
-```go
-// deprecate a flag shorthand by specifying its flag name and a usage message
-flags.MarkShorthandDeprecated("noshorthandflag", "please use --noshorthandflag only")
-```
-This hides the shortname "n" from help text, and prints `Flag shorthand -n has been deprecated, please use --noshorthandflag only` when the shorthand "n" is used.
-
-Note that usage message is essential here, and it should not be empty.
-
-## Hidden flags
-It is possible to mark a flag as hidden, meaning it will still function as normal, however will not show up in usage/help text.
-
-**Example**: You have a flag named "secretFlag" that you need for internal use only and don't want it showing up in help text, or for its usage text to be available.
-```go
-// hide a flag by specifying its name
-flags.MarkHidden("secretFlag")
-```
-
-## Supporting Go flags when using pflag
-In order to support flags defined using Go's `flag` package, they must be added to the `pflag` flagset. This is usually necessary
-to support flags defined by third-party dependencies (e.g. `golang/glog`).
-
-**Example**: You want to add the Go flags to the `CommandLine` flagset
-```go
-import (
- goflag "flag"
- flag "github.com/spf13/pflag"
-)
-
-var ip *int = flag.Int("flagname", 1234, "help message for flagname")
-
-func main() {
- flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
- flag.Parse()
-}
-```
-
-## More info
-
-You can see the full reference documentation of the pflag package
-[at godoc.org][3], or through go's standard documentation system by
-running `godoc -http=:6060` and browsing to
-[http://localhost:6060/pkg/github.com/ogier/pflag][2] after
-installation.
-
-[2]: http://localhost:6060/pkg/github.com/ogier/pflag
-[3]: http://godoc.org/github.com/ogier/pflag
diff --git a/newt/vendor/github.com/spf13/pflag/count.go b/newt/vendor/github.com/spf13/pflag/count.go
deleted file mode 100644
index d22be41f..00000000
--- a/newt/vendor/github.com/spf13/pflag/count.go
+++ /dev/null
@@ -1,94 +0,0 @@
-package pflag
-
-import "strconv"
-
-// -- count Value
-type countValue int
-
-func newCountValue(val int, p *int) *countValue {
- *p = val
- return (*countValue)(p)
-}
-
-func (i *countValue) Set(s string) error {
- v, err := strconv.ParseInt(s, 0, 64)
- // -1 means that no specific value was passed, so increment
- if v == -1 {
- *i = countValue(*i + 1)
- } else {
- *i = countValue(v)
- }
- return err
-}
-
-func (i *countValue) Type() string {
- return "count"
-}
-
-func (i *countValue) String() string { return strconv.Itoa(int(*i)) }
-
-func countConv(sval string) (interface{}, error) {
- i, err := strconv.Atoi(sval)
- if err != nil {
- return nil, err
- }
- return i, nil
-}
-
-// GetCount return the int value of a flag with the given name
-func (f *FlagSet) GetCount(name string) (int, error) {
- val, err := f.getFlagType(name, "count", countConv)
- if err != nil {
- return 0, err
- }
- return val.(int), nil
-}
-
-// CountVar defines a count flag with specified name, default value, and usage string.
-// The argument p points to an int variable in which to store the value of the flag.
-// A count flag will add 1 to its value evey time it is found on the command line
-func (f *FlagSet) CountVar(p *int, name string, usage string) {
- f.CountVarP(p, name, "", usage)
-}
-
-// CountVarP is like CountVar only take a shorthand for the flag name.
-func (f *FlagSet) CountVarP(p *int, name, shorthand string, usage string) {
- flag := f.VarPF(newCountValue(0, p), name, shorthand, usage)
- flag.NoOptDefVal = "-1"
-}
-
-// CountVar like CountVar only the flag is placed on the CommandLine instead of a given flag set
-func CountVar(p *int, name string, usage string) {
- CommandLine.CountVar(p, name, usage)
-}
-
-// CountVarP is like CountVar only take a shorthand for the flag name.
-func CountVarP(p *int, name, shorthand string, usage string) {
- CommandLine.CountVarP(p, name, shorthand, usage)
-}
-
-// Count defines a count flag with specified name, default value, and usage string.
-// The return value is the address of an int variable that stores the value of the flag.
-// A count flag will add 1 to its value evey time it is found on the command line
-func (f *FlagSet) Count(name string, usage string) *int {
- p := new(int)
- f.CountVarP(p, name, "", usage)
- return p
-}
-
-// CountP is like Count only takes a shorthand for the flag name.
-func (f *FlagSet) CountP(name, shorthand string, usage string) *int {
- p := new(int)
- f.CountVarP(p, name, shorthand, usage)
- return p
-}
-
-// Count like Count only the flag is placed on the CommandLine isntead of a given flag set
-func Count(name string, usage string) *int {
- return CommandLine.CountP(name, "", usage)
-}
-
-// CountP is like Count only takes a shorthand for the flag name.
-func CountP(name, shorthand string, usage string) *int {
- return CommandLine.CountP(name, shorthand, usage)
-}
diff --git a/newt/vendor/github.com/spf13/pflag/flag.go b/newt/vendor/github.com/spf13/pflag/flag.go
deleted file mode 100644
index fa815642..00000000
--- a/newt/vendor/github.com/spf13/pflag/flag.go
+++ /dev/null
@@ -1,947 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-/*
-Package pflag is a drop-in replacement for Go's flag package, implementing
-POSIX/GNU-style --flags.
-
-pflag is compatible with the GNU extensions to the POSIX recommendations
-for command-line options. See
-http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html
-
-Usage:
-
-pflag is a drop-in replacement of Go's native flag package. If you import
-pflag under the name "flag" then all code should continue to function
-with no changes.
-
- import flag "github.com/ogier/pflag"
-
- There is one exception to this: if you directly instantiate the Flag struct
-there is one more field "Shorthand" that you will need to set.
-Most code never instantiates this struct directly, and instead uses
-functions such as String(), BoolVar(), and Var(), and is therefore
-unaffected.
-
-Define flags using flag.String(), Bool(), Int(), etc.
-
-This declares an integer flag, -flagname, stored in the pointer ip, with type *int.
- var ip = flag.Int("flagname", 1234, "help message for flagname")
-If you like, you can bind the flag to a variable using the Var() functions.
- var flagvar int
- func init() {
- flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname")
- }
-Or you can create custom flags that satisfy the Value interface (with
-pointer receivers) and couple them to flag parsing by
- flag.Var(&flagVal, "name", "help message for flagname")
-For such flags, the default value is just the initial value of the variable.
-
-After all flags are defined, call
- flag.Parse()
-to parse the command line into the defined flags.
-
-Flags may then be used directly. If you're using the flags themselves,
-they are all pointers; if you bind to variables, they're values.
- fmt.Println("ip has value ", *ip)
- fmt.Println("flagvar has value ", flagvar)
-
-After parsing, the arguments after the flag are available as the
-slice flag.Args() or individually as flag.Arg(i).
-The arguments are indexed from 0 through flag.NArg()-1.
-
-The pflag package also defines some new functions that are not in flag,
-that give one-letter shorthands for flags. You can use these by appending
-'P' to the name of any function that defines a flag.
- var ip = flag.IntP("flagname", "f", 1234, "help message")
- var flagvar bool
- func init() {
- flag.BoolVarP("boolname", "b", true, "help message")
- }
- flag.VarP(&flagVar, "varname", "v", 1234, "help message")
-Shorthand letters can be used with single dashes on the command line.
-Boolean shorthand flags can be combined with other shorthand flags.
-
-Command line flag syntax:
- --flag // boolean flags only
- --flag=x
-
-Unlike the flag package, a single dash before an option means something
-different than a double dash. Single dashes signify a series of shorthand
-letters for flags. All but the last shorthand letter must be boolean flags.
- // boolean flags
- -f
- -abc
- // non-boolean flags
- -n 1234
- -Ifile
- // mixed
- -abcs "hello"
- -abcn1234
-
-Flag parsing stops after the terminator "--". Unlike the flag package,
-flags can be interspersed with arguments anywhere on the command line
-before this terminator.
-
-Integer flags accept 1234, 0664, 0x1234 and may be negative.
-Boolean flags (in their long form) accept 1, 0, t, f, true, false,
-TRUE, FALSE, True, False.
-Duration flags accept any input valid for time.ParseDuration.
-
-The default set of command-line flags is controlled by
-top-level functions. The FlagSet type allows one to define
-independent sets of flags, such as to implement subcommands
-in a command-line interface. The methods of FlagSet are
-analogous to the top-level functions for the command-line
-flag set.
-*/
-package pflag
-
-import (
- "bytes"
- "errors"
- "fmt"
- "io"
- "os"
- "sort"
- "strings"
-)
-
-// ErrHelp is the error returned if the flag -help is invoked but no such flag is defined.
-var ErrHelp = errors.New("pflag: help requested")
-
-// ErrorHandling defines how to handle flag parsing errors.
-type ErrorHandling int
-
-const (
- // ContinueOnError will return an err from Parse() if an error is found
- ContinueOnError ErrorHandling = iota
- // ExitOnError will call os.Exit(2) if an error is found when parsing
- ExitOnError
- // PanicOnError will panic() if an error is found when parsing flags
- PanicOnError
-)
-
-// NormalizedName is a flag name that has been normalized according to rules
-// for the FlagSet (e.g. making '-' and '_' equivalent).
-type NormalizedName string
-
-// A FlagSet represents a set of defined flags.
-type FlagSet struct {
- // Usage is the function called when an error occurs while parsing flags.
- // The field is a function (not a method) that may be changed to point to
- // a custom error handler.
- Usage func()
-
- name string
- parsed bool
- actual map[NormalizedName]*Flag
- formal map[NormalizedName]*Flag
- shorthands map[byte]*Flag
- args []string // arguments after flags
- argsLenAtDash int // len(args) when a '--' was located when parsing, or -1 if no --
- exitOnError bool // does the program exit if there's an error?
- errorHandling ErrorHandling
- output io.Writer // nil means stderr; use out() accessor
- interspersed bool // allow interspersed option/non-option args
- normalizeNameFunc func(f *FlagSet, name string) NormalizedName
-}
-
-// A Flag represents the state of a flag.
-type Flag struct {
- Name string // name as it appears on command line
- Shorthand string // one-letter abbreviated flag
- Usage string // help message
- Value Value // value as set
- DefValue string // default value (as text); for usage message
- Changed bool // If the user set the value (or if left to default)
- NoOptDefVal string //default value (as text); if the flag is on the command line without any options
- Deprecated string // If this flag is deprecated, this string is the new or now thing to use
- Hidden bool // used by cobra.Command to allow flags to be hidden from help/usage text
- ShorthandDeprecated string // If the shorthand of this flag is deprecated, this string is the new or now thing to use
- Annotations map[string][]string // used by cobra.Command bash autocomple code
-}
-
-// Value is the interface to the dynamic value stored in a flag.
-// (The default value is represented as a string.)
-type Value interface {
- String() string
- Set(string) error
- Type() string
-}
-
-// sortFlags returns the flags as a slice in lexicographical sorted order.
-func sortFlags(flags map[NormalizedName]*Flag) []*Flag {
- list := make(sort.StringSlice, len(flags))
- i := 0
- for k := range flags {
- list[i] = string(k)
- i++
- }
- list.Sort()
- result := make([]*Flag, len(list))
- for i, name := range list {
- result[i] = flags[NormalizedName(name)]
- }
- return result
-}
-
-// SetNormalizeFunc allows you to add a function which can translate flag names.
-// Flags added to the FlagSet will be translated and then when anything tries to
-// look up the flag that will also be translated. So it would be possible to create
-// a flag named "getURL" and have it translated to "geturl". A user could then pass
-// "--getUrl" which may also be translated to "geturl" and everything will work.
-func (f *FlagSet) SetNormalizeFunc(n func(f *FlagSet, name string) NormalizedName) {
- f.normalizeNameFunc = n
- for k, v := range f.formal {
- delete(f.formal, k)
- nname := f.normalizeFlagName(string(k))
- f.formal[nname] = v
- v.Name = string(nname)
- }
-}
-
-// GetNormalizeFunc returns the previously set NormalizeFunc of a function which
-// does no translation, if not set previously.
-func (f *FlagSet) GetNormalizeFunc() func(f *FlagSet, name string) NormalizedName {
- if f.normalizeNameFunc != nil {
- return f.normalizeNameFunc
- }
- return func(f *FlagSet, name string) NormalizedName { return NormalizedName(name) }
-}
-
-func (f *FlagSet) normalizeFlagName(name string) NormalizedName {
- n := f.GetNormalizeFunc()
- return n(f, name)
-}
-
-func (f *FlagSet) out() io.Writer {
- if f.output == nil {
- return os.Stderr
- }
- return f.output
-}
-
-// SetOutput sets the destination for usage and error messages.
-// If output is nil, os.Stderr is used.
-func (f *FlagSet) SetOutput(output io.Writer) {
- f.output = output
-}
-
-// VisitAll visits the flags in lexicographical order, calling fn for each.
-// It visits all flags, even those not set.
-func (f *FlagSet) VisitAll(fn func(*Flag)) {
- for _, flag := range sortFlags(f.formal) {
- fn(flag)
- }
-}
-
-// HasFlags returns a bool to indicate if the FlagSet has any flags definied.
-func (f *FlagSet) HasFlags() bool {
- return len(f.formal) > 0
-}
-
-// HasAvailableFlags returns a bool to indicate if the FlagSet has any flags
-// definied that are not hidden or deprecated.
-func (f *FlagSet) HasAvailableFlags() bool {
- for _, flag := range f.formal {
- if !flag.Hidden && len(flag.Deprecated) == 0 {
- return true
- }
- }
- return false
-}
-
-// VisitAll visits the command-line flags in lexicographical order, calling
-// fn for each. It visits all flags, even those not set.
-func VisitAll(fn func(*Flag)) {
- CommandLine.VisitAll(fn)
-}
-
-// Visit visits the flags in lexicographical order, calling fn for each.
-// It visits only those flags that have been set.
-func (f *FlagSet) Visit(fn func(*Flag)) {
- for _, flag := range sortFlags(f.actual) {
- fn(flag)
- }
-}
-
-// Visit visits the command-line flags in lexicographical order, calling fn
-// for each. It visits only those flags that have been set.
-func Visit(fn func(*Flag)) {
- CommandLine.Visit(fn)
-}
-
-// Lookup returns the Flag structure of the named flag, returning nil if none exists.
-func (f *FlagSet) Lookup(name string) *Flag {
- return f.lookup(f.normalizeFlagName(name))
-}
-
-// lookup returns the Flag structure of the named flag, returning nil if none exists.
-func (f *FlagSet) lookup(name NormalizedName) *Flag {
- return f.formal[name]
-}
-
-// func to return a given type for a given flag name
-func (f *FlagSet) getFlagType(name string, ftype string, convFunc func(sval string) (interface{}, error)) (interface{}, error) {
- flag := f.Lookup(name)
- if flag == nil {
- err := fmt.Errorf("flag accessed but not defined: %s", name)
- return nil, err
- }
-
- if flag.Value.Type() != ftype {
- err := fmt.Errorf("trying to get %s value of flag of type %s", ftype, flag.Value.Type())
- return nil, err
- }
-
- sval := flag.Value.String()
- result, err := convFunc(sval)
- if err != nil {
- return nil, err
- }
- return result, nil
-}
-
-// ArgsLenAtDash will return the length of f.Args at the moment when a -- was
-// found during arg parsing. This allows your program to know which args were
-// before the -- and which came after.
-func (f *FlagSet) ArgsLenAtDash() int {
- return f.argsLenAtDash
-}
-
-// MarkDeprecated indicated that a flag is deprecated in your program. It will
-// continue to function but will not show up in help or usage messages. Using
-// this flag will also print the given usageMessage.
-func (f *FlagSet) MarkDeprecated(name string, usageMessage string) error {
- flag := f.Lookup(name)
- if flag == nil {
- return fmt.Errorf("flag %q does not exist", name)
- }
- if len(usageMessage) == 0 {
- return fmt.Errorf("deprecated message for flag %q must be set", name)
- }
- flag.Deprecated = usageMessage
- return nil
-}
-
-// MarkShorthandDeprecated will mark the shorthand of a flag deprecated in your
-// program. It will continue to function but will not show up in help or usage
-// messages. Using this flag will also print the given usageMessage.
-func (f *FlagSet) MarkShorthandDeprecated(name string, usageMessage string) error {
- flag := f.Lookup(name)
- if flag == nil {
- return fmt.Errorf("flag %q does not exist", name)
- }
- if len(usageMessage) == 0 {
- return fmt.Errorf("deprecated message for flag %q must be set", name)
- }
- flag.ShorthandDeprecated = usageMessage
- return nil
-}
-
-// MarkHidden sets a flag to 'hidden' in your program. It will continue to
-// function but will not show up in help or usage messages.
-func (f *FlagSet) MarkHidden(name string) error {
- flag := f.Lookup(name)
- if flag == nil {
- return fmt.Errorf("flag %q does not exist", name)
- }
- flag.Hidden = true
- return nil
-}
-
-// Lookup returns the Flag structure of the named command-line flag,
-// returning nil if none exists.
-func Lookup(name string) *Flag {
- return CommandLine.Lookup(name)
-}
-
-// Set sets the value of the named flag.
-func (f *FlagSet) Set(name, value string) error {
- normalName := f.normalizeFlagName(name)
- flag, ok := f.formal[normalName]
- if !ok {
- return fmt.Errorf("no such flag -%v", name)
- }
- err := flag.Value.Set(value)
- if err != nil {
- return err
- }
- if f.actual == nil {
- f.actual = make(map[NormalizedName]*Flag)
- }
- f.actual[normalName] = flag
- flag.Changed = true
- if len(flag.Deprecated) > 0 {
- fmt.Fprintf(os.Stderr, "Flag --%s has been deprecated, %s\n", flag.Name, flag.Deprecated)
- }
- return nil
-}
-
-// SetAnnotation allows one to set arbitrary annotations on a flag in the FlagSet.
-// This is sometimes used by spf13/cobra programs which want to generate additional
-// bash completion information.
-func (f *FlagSet) SetAnnotation(name, key string, values []string) error {
- normalName := f.normalizeFlagName(name)
- flag, ok := f.formal[normalName]
- if !ok {
- return fmt.Errorf("no such flag -%v", name)
- }
- if flag.Annotations == nil {
- flag.Annotations = map[string][]string{}
- }
- flag.Annotations[key] = values
- return nil
-}
-
-// Changed returns true if the flag was explicitly set during Parse() and false
-// otherwise
-func (f *FlagSet) Changed(name string) bool {
- flag := f.Lookup(name)
- // If a flag doesn't exist, it wasn't changed....
- if flag == nil {
- return false
- }
- return flag.Changed
-}
-
-// Set sets the value of the named command-line flag.
-func Set(name, value string) error {
- return CommandLine.Set(name, value)
-}
-
-// PrintDefaults prints, to standard error unless configured
-// otherwise, the default values of all defined flags in the set.
-func (f *FlagSet) PrintDefaults() {
- usages := f.FlagUsages()
- fmt.Fprint(f.out(), usages)
-}
-
-// defaultIsZeroValue returns true if the default value for this flag represents
-// a zero value.
-func (f *Flag) defaultIsZeroValue() bool {
- switch f.Value.(type) {
- case boolFlag:
- return f.DefValue == "false"
- case *durationValue:
- // Beginning in Go 1.7, duration zero values are "0s"
- return f.DefValue == "0" || f.DefValue == "0s"
- case *intValue, *int8Value, *int32Value, *int64Value, *uintValue, *uint8Value, *uint16Value, *uint32Value, *uint64Value, *countValue, *float32Value, *float64Value:
- return f.DefValue == "0"
- case *stringValue:
- return f.DefValue == ""
- case *ipValue, *ipMaskValue, *ipNetValue:
- return f.DefValue == "<nil>"
- case *intSliceValue, *stringSliceValue, *stringArrayValue:
- return f.DefValue == "[]"
- default:
- switch f.Value.String() {
- case "false":
- return true
- case "<nil>":
- return true
- case "":
- return true
- case "0":
- return true
- }
- return false
- }
-}
-
-// UnquoteUsage extracts a back-quoted name from the usage
-// string for a flag and returns it and the un-quoted usage.
-// Given "a `name` to show" it returns ("name", "a name to show").
-// If there are no back quotes, the name is an educated guess of the
-// type of the flag's value, or the empty string if the flag is boolean.
-func UnquoteUsage(flag *Flag) (name string, usage string) {
- // Look for a back-quoted name, but avoid the strings package.
- usage = flag.Usage
- for i := 0; i < len(usage); i++ {
- if usage[i] == '`' {
- for j := i + 1; j < len(usage); j++ {
- if usage[j] == '`' {
- name = usage[i+1 : j]
- usage = usage[:i] + name + usage[j+1:]
- return name, usage
- }
- }
- break // Only one back quote; use type name.
- }
- }
-
- name = flag.Value.Type()
- switch name {
- case "bool":
- name = ""
- case "float64":
- name = "float"
- case "int64":
- name = "int"
- case "uint64":
- name = "uint"
- }
-
- return
-}
-
-// FlagUsages Returns a string containing the usage information for all flags in
-// the FlagSet
-func (f *FlagSet) FlagUsages() string {
- x := new(bytes.Buffer)
-
- lines := make([]string, 0, len(f.formal))
-
- maxlen := 0
- f.VisitAll(func(flag *Flag) {
- if len(flag.Deprecated) > 0 || flag.Hidden {
- return
- }
-
- line := ""
- if len(flag.Shorthand) > 0 && len(flag.ShorthandDeprecated) == 0 {
- line = fmt.Sprintf(" -%s, --%s", flag.Shorthand, flag.Name)
- } else {
- line = fmt.Sprintf(" --%s", flag.Name)
- }
-
- varname, usage := UnquoteUsage(flag)
- if len(varname) > 0 {
- line += " " + varname
- }
- if len(flag.NoOptDefVal) > 0 {
- switch flag.Value.Type() {
- case "string":
- line += fmt.Sprintf("[=\"%s\"]", flag.NoOptDefVal)
- case "bool":
- if flag.NoOptDefVal != "true" {
- line += fmt.Sprintf("[=%s]", flag.NoOptDefVal)
- }
- default:
- line += fmt.Sprintf("[=%s]", flag.NoOptDefVal)
- }
- }
-
- // This special character will be replaced with spacing once the
- // correct alignment is calculated
- line += "\x00"
- if len(line) > maxlen {
- maxlen = len(line)
- }
-
- line += usage
- if !flag.defaultIsZeroValue() {
- if flag.Value.Type() == "string" {
- line += fmt.Sprintf(" (default \"%s\")", flag.DefValue)
- } else {
- line += fmt.Sprintf(" (default %s)", flag.DefValue)
- }
- }
-
- lines = append(lines, line)
- })
-
- for _, line := range lines {
- sidx := strings.Index(line, "\x00")
- spacing := strings.Repeat(" ", maxlen-sidx)
- fmt.Fprintln(x, line[:sidx], spacing, line[sidx+1:])
- }
-
- return x.String()
-}
-
-// PrintDefaults prints to standard error the default values of all defined command-line flags.
-func PrintDefaults() {
- CommandLine.PrintDefaults()
-}
-
-// defaultUsage is the default function to print a usage message.
-func defaultUsage(f *FlagSet) {
- fmt.Fprintf(f.out(), "Usage of %s:\n", f.name)
- f.PrintDefaults()
-}
-
-// NOTE: Usage is not just defaultUsage(CommandLine)
-// because it serves (via godoc flag Usage) as the example
-// for how to write your own usage function.
-
-// Usage prints to standard error a usage message documenting all defined command-line flags.
-// The function is a variable that may be changed to point to a custom function.
-// By default it prints a simple header and calls PrintDefaults; for details about the
-// format of the output and how to control it, see the documentation for PrintDefaults.
-var Usage = func() {
- fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
- PrintDefaults()
-}
-
-// NFlag returns the number of flags that have been set.
-func (f *FlagSet) NFlag() int { return len(f.actual) }
-
-// NFlag returns the number of command-line flags that have been set.
-func NFlag() int { return len(CommandLine.actual) }
-
-// Arg returns the i'th argument. Arg(0) is the first remaining argument
-// after flags have been processed.
-func (f *FlagSet) Arg(i int) string {
- if i < 0 || i >= len(f.args) {
- return ""
- }
- return f.args[i]
-}
-
-// Arg returns the i'th command-line argument. Arg(0) is the first remaining argument
-// after flags have been processed.
-func Arg(i int) string {
- return CommandLine.Arg(i)
-}
-
-// NArg is the number of arguments remaining after flags have been processed.
-func (f *FlagSet) NArg() int { return len(f.args) }
-
-// NArg is the number of arguments remaining after flags have been processed.
-func NArg() int { return len(CommandLine.args) }
-
-// Args returns the non-flag arguments.
-func (f *FlagSet) Args() []string { return f.args }
-
-// Args returns the non-flag command-line arguments.
-func Args() []string { return CommandLine.args }
-
-// Var defines a flag with the specified name and usage string. The type and
-// value of the flag are represented by the first argument, of type Value, which
-// typically holds a user-defined implementation of Value. For instance, the
-// caller could create a flag that turns a comma-separated string into a slice
-// of strings by giving the slice the methods of Value; in particular, Set would
-// decompose the comma-separated string into the slice.
-func (f *FlagSet) Var(value Value, name string, usage string) {
- f.VarP(value, name, "", usage)
-}
-
-// VarPF is like VarP, but returns the flag created
-func (f *FlagSet) VarPF(value Value, name, shorthand, usage string) *Flag {
- // Remember the default value as a string; it won't change.
- flag := &Flag{
- Name: name,
- Shorthand: shorthand,
- Usage: usage,
- Value: value,
- DefValue: value.String(),
- }
- f.AddFlag(flag)
- return flag
-}
-
-// VarP is like Var, but accepts a shorthand letter that can be used after a single dash.
-func (f *FlagSet) VarP(value Value, name, shorthand, usage string) {
- _ = f.VarPF(value, name, shorthand, usage)
-}
-
-// AddFlag will add the flag to the FlagSet
-func (f *FlagSet) AddFlag(flag *Flag) {
- // Call normalizeFlagName function only once
- normalizedFlagName := f.normalizeFlagName(flag.Name)
-
- _, alreadythere := f.formal[normalizedFlagName]
- if alreadythere {
- msg := fmt.Sprintf("%s flag redefined: %s", f.name, flag.Name)
- fmt.Fprintln(f.out(), msg)
- panic(msg) // Happens only if flags are declared with identical names
- }
- if f.formal == nil {
- f.formal = make(map[NormalizedName]*Flag)
- }
-
- flag.Name = string(normalizedFlagName)
- f.formal[normalizedFlagName] = flag
-
- if len(flag.Shorthand) == 0 {
- return
- }
- if len(flag.Shorthand) > 1 {
- fmt.Fprintf(f.out(), "%s shorthand more than ASCII character: %s\n", f.name, flag.Shorthand)
- panic("shorthand is more than one character")
- }
- if f.shorthands == nil {
- f.shorthands = make(map[byte]*Flag)
- }
- c := flag.Shorthand[0]
- old, alreadythere := f.shorthands[c]
- if alreadythere {
- fmt.Fprintf(f.out(), "%s shorthand reused: %q for %s already used for %s\n", f.name, c, flag.Name, old.Name)
- panic("shorthand redefinition")
- }
- f.shorthands[c] = flag
-}
-
-// AddFlagSet adds one FlagSet to another. If a flag is already present in f
-// the flag from newSet will be ignored
-func (f *FlagSet) AddFlagSet(newSet *FlagSet) {
- if newSet == nil {
- return
- }
- newSet.VisitAll(func(flag *Flag) {
- if f.Lookup(flag.Name) == nil {
- f.AddFlag(flag)
- }
- })
-}
-
-// Var defines a flag with the specified name and usage string. The type and
-// value of the flag are represented by the first argument, of type Value, which
-// typically holds a user-defined implementation of Value. For instance, the
-// caller could create a flag that turns a comma-separated string into a slice
-// of strings by giving the slice the methods of Value; in particular, Set would
-// decompose the comma-separated string into the slice.
-func Var(value Value, name string, usage string) {
- CommandLine.VarP(value, name, "", usage)
-}
-
-// VarP is like Var, but accepts a shorthand letter that can be used after a single dash.
-func VarP(value Value, name, shorthand, usage string) {
- CommandLine.VarP(value, name, shorthand, usage)
-}
-
-// failf prints to standard error a formatted error and usage message and
-// returns the error.
-func (f *FlagSet) failf(format string, a ...interface{}) error {
- err := fmt.Errorf(format, a...)
- fmt.Fprintln(f.out(), err)
- f.usage()
- return err
-}
-
-// usage calls the Usage method for the flag set, or the usage function if
-// the flag set is CommandLine.
-func (f *FlagSet) usage() {
- if f == CommandLine {
- Usage()
- } else if f.Usage == nil {
- defaultUsage(f)
- } else {
- f.Usage()
- }
-}
-
-func (f *FlagSet) setFlag(flag *Flag, value string, origArg string) error {
- if err := flag.Value.Set(value); err != nil {
- return f.failf("invalid argument %q for %s: %v", value, origArg, err)
- }
- // mark as visited for Visit()
- if f.actual == nil {
- f.actual = make(map[NormalizedName]*Flag)
- }
- f.actual[f.normalizeFlagName(flag.Name)] = flag
- flag.Changed = true
- if len(flag.Deprecated) > 0 {
- fmt.Fprintf(os.Stderr, "Flag --%s has been deprecated, %s\n", flag.Name, flag.Deprecated)
- }
- if len(flag.ShorthandDeprecated) > 0 && containsShorthand(origArg, flag.Shorthand) {
- fmt.Fprintf(os.Stderr, "Flag shorthand -%s has been deprecated, %s\n", flag.Shorthand, flag.ShorthandDeprecated)
- }
- return nil
-}
-
-func containsShorthand(arg, shorthand string) bool {
- // filter out flags --<flag_name>
- if strings.HasPrefix(arg, "-") {
- return false
- }
- arg = strings.SplitN(arg, "=", 2)[0]
- return strings.Contains(arg, shorthand)
-}
-
-func (f *FlagSet) parseLongArg(s string, args []string) (a []string, err error) {
- a = args
- name := s[2:]
- if len(name) == 0 || name[0] == '-' || name[0] == '=' {
- err = f.failf("bad flag syntax: %s", s)
- return
- }
- split := strings.SplitN(name, "=", 2)
- name = split[0]
- flag, alreadythere := f.formal[f.normalizeFlagName(name)]
- if !alreadythere {
- if name == "help" { // special case for nice help message.
- f.usage()
- return a, ErrHelp
- }
- err = f.failf("unknown flag: --%s", name)
- return
- }
- var value string
- if len(split) == 2 {
- // '--flag=arg'
- value = split[1]
- } else if len(flag.NoOptDefVal) > 0 {
- // '--flag' (arg was optional)
- value = flag.NoOptDefVal
- } else if len(a) > 0 {
- // '--flag arg'
- value = a[0]
- a = a[1:]
- } else {
- // '--flag' (arg was required)
- err = f.failf("flag needs an argument: %s", s)
- return
- }
- err = f.setFlag(flag, value, s)
- return
-}
-
-func (f *FlagSet) parseSingleShortArg(shorthands string, args []string) (outShorts string, outArgs []string, err error) {
- if strings.HasPrefix(shorthands, "test.") {
- return
- }
- outArgs = args
- outShorts = shorthands[1:]
- c := shorthands[0]
-
- flag, alreadythere := f.shorthands[c]
- if !alreadythere {
- if c == 'h' { // special case for nice help message.
- f.usage()
- err = ErrHelp
- return
- }
- //TODO continue on error
- err = f.failf("unknown shorthand flag: %q in -%s", c, shorthands)
- return
- }
- var value string
- if len(shorthands) > 2 && shorthands[1] == '=' {
- value = shorthands[2:]
- outShorts = ""
- } else if len(flag.NoOptDefVal) > 0 {
- value = flag.NoOptDefVal
- } else if len(shorthands) > 1 {
- value = shorthands[1:]
- outShorts = ""
- } else if len(args) > 0 {
- value = args[0]
- outArgs = args[1:]
- } else {
- err = f.failf("flag needs an argument: %q in -%s", c, shorthands)
- return
- }
- err = f.setFlag(flag, value, shorthands)
- return
-}
-
-func (f *FlagSet) parseShortArg(s string, args []string) (a []string, err error) {
- a = args
- shorthands := s[1:]
-
- for len(shorthands) > 0 {
- shorthands, a, err = f.parseSingleShortArg(shorthands, args)
- if err != nil {
- return
- }
- }
-
- return
-}
-
-func (f *FlagSet) parseArgs(args []string) (err error) {
- for len(args) > 0 {
- s := args[0]
- args = args[1:]
- if len(s) == 0 || s[0] != '-' || len(s) == 1 {
- if !f.interspersed {
- f.args = append(f.args, s)
- f.args = append(f.args, args...)
- return nil
- }
- f.args = append(f.args, s)
- continue
- }
-
- if s[1] == '-' {
- if len(s) == 2 { // "--" terminates the flags
- f.argsLenAtDash = len(f.args)
- f.args = append(f.args, args...)
- break
- }
- args, err = f.parseLongArg(s, args)
- } else {
- args, err = f.parseShortArg(s, args)
- }
- if err != nil {
- return
- }
- }
- return
-}
-
-// Parse parses flag definitions from the argument list, which should not
-// include the command name. Must be called after all flags in the FlagSet
-// are defined and before flags are accessed by the program.
-// The return value will be ErrHelp if -help was set but not defined.
-func (f *FlagSet) Parse(arguments []string) error {
- f.parsed = true
- f.args = make([]string, 0, len(arguments))
- err := f.parseArgs(arguments)
- if err != nil {
- switch f.errorHandling {
- case ContinueOnError:
- return err
- case ExitOnError:
- os.Exit(2)
- case PanicOnError:
- panic(err)
- }
- }
- return nil
-}
-
-// Parsed reports whether f.Parse has been called.
-func (f *FlagSet) Parsed() bool {
- return f.parsed
-}
-
-// Parse parses the command-line flags from os.Args[1:]. Must be called
-// after all flags are defined and before flags are accessed by the program.
-func Parse() {
- // Ignore errors; CommandLine is set for ExitOnError.
- CommandLine.Parse(os.Args[1:])
-}
-
-// SetInterspersed sets whether to support interspersed option/non-option arguments.
-func SetInterspersed(interspersed bool) {
- CommandLine.SetInterspersed(interspersed)
-}
-
-// Parsed returns true if the command-line flags have been parsed.
-func Parsed() bool {
- return CommandLine.Parsed()
-}
-
-// CommandLine is the default set of command-line flags, parsed from os.Args.
-var CommandLine = NewFlagSet(os.Args[0], ExitOnError)
-
-// NewFlagSet returns a new, empty flag set with the specified name and
-// error handling property.
-func NewFlagSet(name string, errorHandling ErrorHandling) *FlagSet {
- f := &FlagSet{
- name: name,
- errorHandling: errorHandling,
- argsLenAtDash: -1,
- interspersed: true,
- }
- return f
-}
-
-// SetInterspersed sets whether to support interspersed option/non-option arguments.
-func (f *FlagSet) SetInterspersed(interspersed bool) {
- f.interspersed = interspersed
-}
-
-// Init sets the name and error handling property for a flag set.
-// By default, the zero FlagSet uses an empty name and the
-// ContinueOnError error handling policy.
-func (f *FlagSet) Init(name string, errorHandling ErrorHandling) {
- f.name = name
- f.errorHandling = errorHandling
- f.argsLenAtDash = -1
-}
diff --git a/newt/vendor/github.com/spf13/pflag/golangflag.go b/newt/vendor/github.com/spf13/pflag/golangflag.go
deleted file mode 100644
index b056147f..00000000
--- a/newt/vendor/github.com/spf13/pflag/golangflag.go
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package pflag
-
-import (
- goflag "flag"
- "fmt"
- "reflect"
- "strings"
-)
-
-var _ = fmt.Print
-
-// flagValueWrapper implements pflag.Value around a flag.Value. The main
-// difference here is the addition of the Type method that returns a string
-// name of the type. As this is generally unknown, we approximate that with
-// reflection.
-type flagValueWrapper struct {
- inner goflag.Value
- flagType string
-}
-
-// We are just copying the boolFlag interface out of goflag as that is what
-// they use to decide if a flag should get "true" when no arg is given.
-type goBoolFlag interface {
- goflag.Value
- IsBoolFlag() bool
-}
-
-func wrapFlagValue(v goflag.Value) Value {
- // If the flag.Value happens to also be a pflag.Value, just use it directly.
- if pv, ok := v.(Value); ok {
- return pv
- }
-
- pv := &flagValueWrapper{
- inner: v,
- }
-
- t := reflect.TypeOf(v)
- if t.Kind() == reflect.Interface || t.Kind() == reflect.Ptr {
- t = t.Elem()
- }
-
- pv.flagType = strings.TrimSuffix(t.Name(), "Value")
- return pv
-}
-
-func (v *flagValueWrapper) String() string {
- return v.inner.String()
-}
-
-func (v *flagValueWrapper) Set(s string) error {
- return v.inner.Set(s)
-}
-
-func (v *flagValueWrapper) Type() string {
- return v.flagType
-}
-
-// PFlagFromGoFlag will return a *pflag.Flag given a *flag.Flag
-// If the *flag.Flag.Name was a single character (ex: `v`) it will be accessiblei
-// with both `-v` and `--v` in flags. If the golang flag was more than a single
-// character (ex: `verbose`) it will only be accessible via `--verbose`
-func PFlagFromGoFlag(goflag *goflag.Flag) *Flag {
- // Remember the default value as a string; it won't change.
- flag := &Flag{
- Name: goflag.Name,
- Usage: goflag.Usage,
- Value: wrapFlagValue(goflag.Value),
- // Looks like golang flags don't set DefValue correctly :-(
- //DefValue: goflag.DefValue,
- DefValue: goflag.Value.String(),
- }
- // Ex: if the golang flag was -v, allow both -v and --v to work
- if len(flag.Name) == 1 {
- flag.Shorthand = flag.Name
- }
- if fv, ok := goflag.Value.(goBoolFlag); ok && fv.IsBoolFlag() {
- flag.NoOptDefVal = "true"
- }
- return flag
-}
-
-// AddGoFlag will add the given *flag.Flag to the pflag.FlagSet
-func (f *FlagSet) AddGoFlag(goflag *goflag.Flag) {
- if f.Lookup(goflag.Name) != nil {
- return
- }
- newflag := PFlagFromGoFlag(goflag)
- f.AddFlag(newflag)
-}
-
-// AddGoFlagSet will add the given *flag.FlagSet to the pflag.FlagSet
-func (f *FlagSet) AddGoFlagSet(newSet *goflag.FlagSet) {
- if newSet == nil {
- return
- }
- newSet.VisitAll(func(goflag *goflag.Flag) {
- f.AddGoFlag(goflag)
- })
-}
diff --git a/newt/vendor/github.com/spf13/pflag/ip.go b/newt/vendor/github.com/spf13/pflag/ip.go
deleted file mode 100644
index 88a17430..00000000
--- a/newt/vendor/github.com/spf13/pflag/ip.go
+++ /dev/null
@@ -1,96 +0,0 @@
-package pflag
-
-import (
- "fmt"
- "net"
- "strings"
-)
-
-var _ = strings.TrimSpace
-
-// -- net.IP value
-type ipValue net.IP
-
-func newIPValue(val net.IP, p *net.IP) *ipValue {
- *p = val
- return (*ipValue)(p)
-}
-
-func (i *ipValue) String() string { return net.IP(*i).String() }
-func (i *ipValue) Set(s string) error {
- ip := net.ParseIP(strings.TrimSpace(s))
- if ip == nil {
- return fmt.Errorf("failed to parse IP: %q", s)
- }
- *i = ipValue(ip)
- return nil
-}
-
-func (i *ipValue) Type() string {
- return "ip"
-}
-
-func ipConv(sval string) (interface{}, error) {
- ip := net.ParseIP(sval)
- if ip != nil {
- return ip, nil
- }
- return nil, fmt.Errorf("invalid string being converted to IP address: %s", sval)
-}
-
-// GetIP return the net.IP value of a flag with the given name
-func (f *FlagSet) GetIP(name string) (net.IP, error) {
- val, err := f.getFlagType(name, "ip", ipConv)
- if err != nil {
- return nil, err
- }
- return val.(net.IP), nil
-}
-
-// IPVar defines an net.IP flag with specified name, default value, and usage string.
-// The argument p points to an net.IP variable in which to store the value of the flag.
-func (f *FlagSet) IPVar(p *net.IP, name string, value net.IP, usage string) {
- f.VarP(newIPValue(value, p), name, "", usage)
-}
-
-// IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash.
-func (f *FlagSet) IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) {
- f.VarP(newIPValue(value, p), name, shorthand, usage)
-}
-
-// IPVar defines an net.IP flag with specified name, default value, and usage string.
-// The argument p points to an net.IP variable in which to store the value of the flag.
-func IPVar(p *net.IP, name string, value net.IP, usage string) {
- CommandLine.VarP(newIPValue(value, p), name, "", usage)
-}
-
-// IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash.
-func IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) {
- CommandLine.VarP(newIPValue(value, p), name, shorthand, usage)
-}
-
-// IP defines an net.IP flag with specified name, default value, and usage string.
-// The return value is the address of an net.IP variable that stores the value of the flag.
-func (f *FlagSet) IP(name string, value net.IP, usage string) *net.IP {
- p := new(net.IP)
- f.IPVarP(p, name, "", value, usage)
- return p
-}
-
-// IPP is like IP, but accepts a shorthand letter that can be used after a single dash.
-func (f *FlagSet) IPP(name, shorthand string, value net.IP, usage string) *net.IP {
- p := new(net.IP)
- f.IPVarP(p, name, shorthand, value, usage)
- return p
-}
-
-// IP defines an net.IP flag with specified name, default value, and usage string.
-// The return value is the address of an net.IP variable that stores the value of the flag.
-func IP(name string, value net.IP, usage string) *net.IP {
- return CommandLine.IPP(name, "", value, usage)
-}
-
-// IPP is like IP, but accepts a shorthand letter that can be used after a single dash.
-func IPP(name, shorthand string, value net.IP, usage string) *net.IP {
- return CommandLine.IPP(name, shorthand, value, usage)
-}
diff --git a/newt/vendor/github.com/spf13/pflag/ipnet.go b/newt/vendor/github.com/spf13/pflag/ipnet.go
deleted file mode 100644
index 149b764b..00000000
--- a/newt/vendor/github.com/spf13/pflag/ipnet.go
+++ /dev/null
@@ -1,100 +0,0 @@
-package pflag
-
-import (
- "fmt"
- "net"
- "strings"
-)
-
-// IPNet adapts net.IPNet for use as a flag.
-type ipNetValue net.IPNet
-
-func (ipnet ipNetValue) String() string {
- n := net.IPNet(ipnet)
- return n.String()
-}
-
-func (ipnet *ipNetValue) Set(value string) error {
- _, n, err := net.ParseCIDR(strings.TrimSpace(value))
- if err != nil {
- return err
- }
- *ipnet = ipNetValue(*n)
- return nil
-}
-
-func (*ipNetValue) Type() string {
- return "ipNet"
-}
-
-var _ = strings.TrimSpace
-
-func newIPNetValue(val net.IPNet, p *net.IPNet) *ipNetValue {
- *p = val
- return (*ipNetValue)(p)
-}
-
-func ipNetConv(sval string) (interface{}, error) {
- _, n, err := net.ParseCIDR(strings.TrimSpace(sval))
- if err == nil {
- return *n, nil
- }
- return nil, fmt.Errorf("invalid string being converted to IPNet: %s", sval)
-}
-
-// GetIPNet return the net.IPNet value of a flag with the given name
-func (f *FlagSet) GetIPNet(name string) (net.IPNet, error) {
- val, err := f.getFlagType(name, "ipNet", ipNetConv)
- if err != nil {
- return net.IPNet{}, err
- }
- return val.(net.IPNet), nil
-}
-
-// IPNetVar defines an net.IPNet flag with specified name, default value, and usage string.
-// The argument p points to an net.IPNet variable in which to store the value of the flag.
-func (f *FlagSet) IPNetVar(p *net.IPNet, name string, value net.IPNet, usage string) {
- f.VarP(newIPNetValue(value, p), name, "", usage)
-}
-
-// IPNetVarP is like IPNetVar, but accepts a shorthand letter that can be used after a single dash.
-func (f *FlagSet) IPNetVarP(p *net.IPNet, name, shorthand string, value net.IPNet, usage string) {
- f.VarP(newIPNetValue(value, p), name, shorthand, usage)
-}
-
-// IPNetVar defines an net.IPNet flag with specified name, default value, and usage string.
-// The argument p points to an net.IPNet variable in which to store the value of the flag.
-func IPNetVar(p *net.IPNet, name string, value net.IPNet, usage string) {
- CommandLine.VarP(newIPNetValue(value, p), name, "", usage)
-}
-
-// IPNetVarP is like IPNetVar, but accepts a shorthand letter that can be used after a single dash.
-func IPNetVarP(p *net.IPNet, name, shorthand string, value net.IPNet, usage string) {
- CommandLine.VarP(newIPNetValue(value, p), name, shorthand, usage)
-}
-
-// IPNet defines an net.IPNet flag with specified name, default value, and usage string.
-// The return value is the address of an net.IPNet variable that stores the value of the flag.
-func (f *FlagSet) IPNet(name string, value net.IPNet, usage string) *net.IPNet {
- p := new(net.IPNet)
- f.IPNetVarP(p, name, "", value, usage)
- return p
-}
-
-// IPNetP is like IPNet, but accepts a shorthand letter that can be used after a single dash.
-func (f *FlagSet) IPNetP(name, shorthand string, value net.IPNet, usage string) *net.IPNet {
- p := new(net.IPNet)
- f.IPNetVarP(p, name, shorthand, value, usage)
- return p
-}
-
-// IPNet defines an net.IPNet flag with specified name, default value, and usage string.
-// The return value is the address of an net.IPNet variable that stores the value of the flag.
-func IPNet(name string, value net.IPNet, usage string) *net.IPNet {
- return CommandLine.IPNetP(name, "", value, usage)
-}
-
-// IPNetP is like IPNet, but accepts a shorthand letter that can be used after a single dash.
-func IPNetP(name, shorthand string, value net.IPNet, usage string) *net.IPNet {
- return CommandLine.IPNetP(name, shorthand, value, usage)
-}
diff --git a/newt/vendor/github.com/spf13/pflag/string_array.go b/newt/vendor/github.com/spf13/pflag/string_array.go
deleted file mode 100644
index 93b4e432..00000000
--- a/newt/vendor/github.com/spf13/pflag/string_array.go
+++ /dev/null
@@ -1,109 +0,0 @@
-package pflag
-
-import (
- "fmt"
-)
-
-var _ = fmt.Fprint
-
-// -- stringArray Value
-type stringArrayValue struct {
- value *[]string
- changed bool
-}
-
-func newStringArrayValue(val []string, p *[]string) *stringArrayValue {
- ssv := new(stringArrayValue)
- ssv.value = p
- *ssv.value = val
- return ssv
-}
-
-func (s *stringArrayValue) Set(val string) error {
- if !s.changed {
- *s.value = []string{val}
- s.changed = true
- } else {
- *s.value = append(*s.value, val)
- }
- return nil
-}
-
-func (s *stringArrayValue) Type() string {
- return "stringArray"
-}
-
-func (s *stringArrayValue) String() string {
- str, _ := writeAsCSV(*s.value)
- return "[" + str + "]"
-}
-
-func stringArrayConv(sval string) (interface{}, error) {
- sval = sval[1 : len(sval)-1]
- // An empty string would cause a array with one (empty) string
- if len(sval) == 0 {
- return []string{}, nil
- }
- return readAsCSV(sval)
-}
-
-// GetStringArray return the []string value of a flag with the given name
-func (f *FlagSet) GetStringArray(name string) ([]string, error) {
- val, err := f.getFlagType(name, "stringArray", stringArrayConv)
- if err != nil {
- return []string{}, err
- }
- return val.([]string), nil
-}
-
-// StringArrayVar defines a string flag with specified name, default value, and usage string.
-// The argument p points to a []string variable in which to store the values of the multiple flags.
-// The value of each argument will not try to be separated by comma
-func (f *FlagSet) StringArrayVar(p *[]string, name string, value []string, usage string) {
- f.VarP(newStringArrayValue(value, p), name, "", usage)
-}
-
-// StringArrayVarP is like StringArrayVar, but accepts a shorthand letter that can be used after a single dash.
-func (f *FlagSet) StringArrayVarP(p *[]string, name, shorthand string, value []string, usage string) {
- f.VarP(newStringArrayValue(value, p), name, shorthand, usage)
-}
-
-// StringArrayVar defines a string flag with specified name, default value, and usage string.
-// The argument p points to a []string variable in which to store the value of the flag.
-// The value of each argument will not try to be separated by comma
-func StringArrayVar(p *[]string, name string, value []string, usage string) {
- CommandLine.VarP(newStringArrayValue(value, p), name, "", usage)
-}
-
-// StringArrayVarP is like StringArrayVar, but accepts a shorthand letter that can be used after a single dash.
-func StringArrayVarP(p *[]string, name, shorthand string, value []string, usage string) {
- CommandLine.VarP(newStringArrayValue(value, p), name, shorthand, usage)
-}
-
-// StringArray defines a string flag with specified name, default value, and usage string.
-// The return value is the address of a []string variable that stores the value of the flag.
-// The value of each argument will not try to be separated by comma
-func (f *FlagSet) StringArray(name string, value []string, usage string) *[]string {
- p := []string{}
- f.StringArrayVarP(&p, name, "", value, usage)
- return &p
-}
-
-// StringArrayP is like StringArray, but accepts a shorthand letter that can be used after a single dash.
-func (f *FlagSet) StringArrayP(name, shorthand string, value []string, usage string) *[]string {
- p := []string{}
- f.StringArrayVarP(&p, name, shorthand, value, usage)
- return &p
-}
-
-// StringArray defines a string flag with specified name, default value, and usage string.
-// The return value is the address of a []string variable that stores the value of the flag.
-// The value of each argument will not try to be separated by comma
-func StringArray(name string, value []string, usage string) *[]string {
- return CommandLine.StringArrayP(name, "", value, usage)
-}
-
-// StringArrayP is like StringArray, but accepts a shorthand letter that can be used after a single dash.
-func StringArrayP(name, shorthand string, value []string, usage string) *[]string {
- return CommandLine.StringArrayP(name, shorthand, value, usage)
-}
diff --git a/newt/vendor/github.com/spf13/pflag/string_slice.go b/newt/vendor/github.com/spf13/pflag/string_slice.go
deleted file mode 100644
index 7829cfaf..00000000
--- a/newt/vendor/github.com/spf13/pflag/string_slice.go
+++ /dev/null
@@ -1,132 +0,0 @@
-package pflag
-
-import (
- "bytes"
- "encoding/csv"
- "fmt"
- "strings"
-)
-
-var _ = fmt.Fprint
-
-// -- stringSlice Value
-type stringSliceValue struct {
- value *[]string
- changed bool
-}
-
-func newStringSliceValue(val []string, p *[]string) *stringSliceValue {
- ssv := new(stringSliceValue)
- ssv.value = p
- *ssv.value = val
- return ssv
-}
-
-func readAsCSV(val string) ([]string, error) {
- if val == "" {
- return []string{}, nil
- }
- stringReader := strings.NewReader(val)
- csvReader := csv.NewReader(stringReader)
- return csvReader.Read()
-}
-
-func writeAsCSV(vals []string) (string, error) {
- b := &bytes.Buffer{}
- w := csv.NewWriter(b)
- err := w.Write(vals)
- if err != nil {
- return "", err
- }
- w.Flush()
- return strings.TrimSuffix(b.String(), fmt.Sprintln()), nil
-}
-
-func (s *stringSliceValue) Set(val string) error {
- v, err := readAsCSV(val)
- if err != nil {
- return err
- }
- if !s.changed {
- *s.value = v
- } else {
- *s.value = append(*s.value, v...)
- }
- s.changed = true
- return nil
-}
-
-func (s *stringSliceValue) Type() string {
- return "stringSlice"
-}
-
-func (s *stringSliceValue) String() string {
- str, _ := writeAsCSV(*s.value)
- return "[" + str + "]"
-}
-
-func stringSliceConv(sval string) (interface{}, error) {
- sval = sval[1 : len(sval)-1]
- // An empty string would cause a slice with one (empty) string
- if len(sval) == 0 {
- return []string{}, nil
- }
- return readAsCSV(sval)
-}
-
-// GetStringSlice return the []string value of a flag with the given name
-func (f *FlagSet) GetStringSlice(name string) ([]string, error) {
- val, err := f.getFlagType(name, "stringSlice", stringSliceConv)
- if err != nil {
- return []string{}, err
- }
- return val.([]string), nil
-}
-
-// StringSliceVar defines a string flag with specified name, default value, and usage string.
-// The argument p points to a []string variable in which to store the value of the flag.
-func (f *FlagSet) StringSliceVar(p *[]string, name string, value []string, usage string) {
- f.VarP(newStringSliceValue(value, p), name, "", usage)
-}
-
-// StringSliceVarP is like StringSliceVar, but accepts a shorthand letter that can be used after a single dash.
-func (f *FlagSet) StringSliceVarP(p *[]string, name, shorthand string, value []string, usage string) {
- f.VarP(newStringSliceValue(value, p), name, shorthand, usage)
-}
-
-// StringSliceVar defines a string flag with specified name, default value, and usage string.
-// The argument p points to a []string variable in which to store the value of the flag.
-func StringSliceVar(p *[]string, name string, value []string, usage string) {
- CommandLine.VarP(newStringSliceValue(value, p), name, "", usage)
-}
-
-// StringSliceVarP is like StringSliceVar, but accepts a shorthand letter that can be used after a single dash.
-func StringSliceVarP(p *[]string, name, shorthand string, value []string, usage string) {
- CommandLine.VarP(newStringSliceValue(value, p), name, shorthand, usage)
-}
-
-// StringSlice defines a string flag with specified name, default value, and usage string.
-// The return value is the address of a []string variable that stores the value of the flag.
-func (f *FlagSet) StringSlice(name string, value []string, usage string) *[]string {
- p := []string{}
- f.StringSliceVarP(&p, name, "", value, usage)
- return &p
-}
-
-// StringSliceP is like StringSlice, but accepts a shorthand letter that can be used after a single dash.
-func (f *FlagSet) StringSliceP(name, shorthand string, value []string, usage string) *[]string {
- p := []string{}
- f.StringSliceVarP(&p, name, shorthand, value, usage)
- return &p
-}
-
-// StringSlice defines a string flag with specified name, default value, and usage string.
-// The return value is the address of a []string variable that stores the value of the flag.
-func StringSlice(name string, value []string, usage string) *[]string {
- return CommandLine.StringSliceP(name, "", value, usage)
-}
-
-// StringSliceP is like StringSlice, but accepts a shorthand letter that can be used after a single dash.
-func StringSliceP(name, shorthand string, value []string, usage string) *[]string {
- return CommandLine.StringSliceP(name, shorthand, value, usage)
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/asm.s b/newt/vendor/golang.org/x/sys/unix/asm.s
deleted file mode 100644
index 8ed2fdb9..00000000
--- a/newt/vendor/golang.org/x/sys/unix/asm.s
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build !gccgo
-
-#include "textflag.h"
-
-TEXT ?use(SB),NOSPLIT,$0
- RET
diff --git a/newt/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s b/newt/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
deleted file mode 100644
index 43ed17a0..00000000
--- a/newt/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build !gccgo
-
-#include "textflag.h"
-
-//
-// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
-//
-
-TEXT ?sysvicall6(SB),NOSPLIT,$0-64
- JMP syscall?sysvicall6(SB)
-
-TEXT ?rawSysvicall6(SB),NOSPLIT,$0-64
- JMP syscall?rawSysvicall6(SB)
diff --git a/newt/vendor/golang.org/x/sys/unix/flock.go b/newt/vendor/golang.org/x/sys/unix/flock.go
deleted file mode 100644
index ce67a595..00000000
--- a/newt/vendor/golang.org/x/sys/unix/flock.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// +build linux darwin freebsd openbsd netbsd dragonfly
-
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build darwin dragonfly freebsd linux netbsd openbsd
-
-package unix
-
-import "unsafe"
-
-// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
-// systems by flock_linux_32bit.go to be SYS_FCNTL64.
-var fcntl64Syscall uintptr = SYS_FCNTL
-
-// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
-func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
- _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
- if errno == 0 {
- return nil
- }
- return errno
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/flock_linux_32bit.go b/newt/vendor/golang.org/x/sys/unix/flock_linux_32bit.go
deleted file mode 100644
index 362831c3..00000000
--- a/newt/vendor/golang.org/x/sys/unix/flock_linux_32bit.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// +build linux,386 linux,arm
-
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package unix
-
-func init() {
- // On 32-bit Linux systems, the fcntl syscall that matches Go's
- // Flock_t type is SYS_FCNTL64, not SYS_FCNTL.
- fcntl64Syscall = SYS_FCNTL64
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/mkall.sh b/newt/vendor/golang.org/x/sys/unix/mkall.sh
deleted file mode 100755
index 2a1473f1..00000000
--- a/newt/vendor/golang.org/x/sys/unix/mkall.sh
+++ /dev/null
@@ -1,292 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-# The unix package provides access to the raw system call
-# interface of the underlying operating system. Porting Go to
-# a new architecture/operating system combination requires
-# some manual effort, though there are tools that automate
-# much of the process. The auto-generated files have names
-# beginning with z.
-#
-# This script runs or (given -n) prints suggested commands to generate z files
-# for the current system. Running those commands is not automatic.
-# This script is documentation more than anything else.
-#
-# * asm_${GOOS}_${GOARCH}.s
-#
-# This hand-written assembly file implements system call dispatch.
-# There are three entry points:
-#
-# func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr);
-# func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
-# func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr);
-#
-# The first and second are the standard ones; they differ only in
-# how many arguments can be passed to the kernel.
-# The third is for low-level use by the ForkExec wrapper;
-# unlike the first two, it does not call into the scheduler to
-# let it know that a system call is running.
-#
-# * syscall_${GOOS}.go
-#
-# This hand-written Go file implements system calls that need
-# special handling and lists "//sys" comments giving prototypes
-# for ones that can be auto-generated. Mksyscall reads those
-# comments to generate the stubs.
-#
-# * syscall_${GOOS}_${GOARCH}.go
-#
-# Same as syscall_${GOOS}.go except that it contains code specific
-# to ${GOOS} on one particular architecture.
-#
-# * types_${GOOS}.c
-#
-# This hand-written C file includes standard C headers and then
-# creates typedef or enum names beginning with a dollar sign
-# (use of $ in variable names is a gcc extension). The hardest
-# part about preparing this file is figuring out which headers to
-# include and which symbols need to be #defined to get the
-# actual data structures that pass through to the kernel system calls.
-# Some C libraries present alternate versions for binary compatibility
-# and translate them on the way in and out of system calls, but
-# there is almost always a #define that can get the real ones.
-# See types_darwin.c and types_linux.c for examples.
-#
-# * zerror_${GOOS}_${GOARCH}.go
-#
-# This machine-generated file defines the system's error numbers,
-# error strings, and signal numbers. The generator is "mkerrors.sh".
-# Usually no arguments are needed, but mkerrors.sh will pass its
-# arguments on to godefs.
-#
-# * zsyscall_${GOOS}_${GOARCH}.go
-#
-# Generated by mksyscall.pl; see syscall_${GOOS}.go above.
-#
-# * zsysnum_${GOOS}_${GOARCH}.go
-#
-# Generated by mksysnum_${GOOS}.
-#
-# * ztypes_${GOOS}_${GOARCH}.go
-#
-# Generated by godefs; see types_${GOOS}.c above.
-
-GOOSARCH="${GOOS}_${GOARCH}"
-
-# defaults
-mksyscall="./mksyscall.pl"
-mkerrors="./mkerrors.sh"
-zerrors="zerrors_$GOOSARCH.go"
-mksysctl=""
-zsysctl="zsysctl_$GOOSARCH.go"
-mksysnum=
-mktypes=
-run="sh"
-
-case "$1" in
--syscalls)
- for i in zsyscall*go
- do
- sed 1q $i | sed 's;^// ;;' | sh > _$i && gofmt < _$i > $i
- rm _$i
- done
- exit 0
- ;;
--n)
- run="cat"
- shift
-esac
-
-case "$#" in
-0)
- ;;
-*)
- echo 'usage: mkall.sh [-n]' 1>&2
- exit 2
-esac
-
-GOOSARCH_in=syscall_$GOOSARCH.go
-case "$GOOSARCH" in
-_* | *_ | _)
- echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
- exit 1
- ;;
-darwin_386)
- mkerrors="$mkerrors -m32"
- mksyscall="./mksyscall.pl -l32"
- mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-darwin_amd64)
- mkerrors="$mkerrors -m64"
- mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-darwin_arm)
- mkerrors="$mkerrors"
- mksysnum="./mksysnum_darwin.pl /usr/include/sys/syscall.h"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-darwin_arm64)
- mkerrors="$mkerrors -m64"
- mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-dragonfly_386)
- mkerrors="$mkerrors -m32"
- mksyscall="./mksyscall.pl -l32 -dragonfly"
- mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-dragonfly_amd64)
- mkerrors="$mkerrors -m64"
- mksyscall="./mksyscall.pl -dragonfly"
- mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-freebsd_386)
- mkerrors="$mkerrors -m32"
- mksyscall="./mksyscall.pl -l32"
- mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-freebsd_amd64)
- mkerrors="$mkerrors -m64"
- mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-freebsd_arm)
- mkerrors="$mkerrors"
- mksyscall="./mksyscall.pl -l32 -arm"
- mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across over platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-linux_386)
- mkerrors="$mkerrors -m32"
- mksyscall="./mksyscall.pl -l32"
- mksysnum="./mksysnum_linux.pl /usr/include/asm/unistd_32.h"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-linux_amd64)
- unistd_h=$(ls -1 /usr/include/asm/unistd_64.h /usr/include/x86_64-linux-gnu/asm/unistd_64.h 2>/dev/null | head -1)
- if [ "$unistd_h" = "" ]; then
- echo >&2 cannot find unistd_64.h
- exit 1
- fi
- mkerrors="$mkerrors -m64"
- mksysnum="./mksysnum_linux.pl $unistd_h"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-linux_arm)
- mkerrors="$mkerrors"
- mksyscall="./mksyscall.pl -l32 -arm"
- mksysnum="curl -s 'http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/arch/arm/include/uapi/asm/unistd.h' | ./mksysnum_linux.pl -"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-linux_arm64)
- unistd_h=$(ls -1 /usr/include/asm/unistd.h /usr/include/asm-generic/unistd.h 2>/dev/null | head -1)
- if [ "$unistd_h" = "" ]; then
- echo >&2 cannot find unistd_64.h
- exit 1
- fi
- mksysnum="./mksysnum_linux.pl $unistd_h"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across over platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-linux_ppc64)
- GOOSARCH_in=syscall_linux_ppc64x.go
- unistd_h=/usr/include/asm/unistd.h
- mkerrors="$mkerrors -m64"
- mksysnum="./mksysnum_linux.pl $unistd_h"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-linux_ppc64le)
- GOOSARCH_in=syscall_linux_ppc64x.go
- unistd_h=/usr/include/powerpc64le-linux-gnu/asm/unistd.h
- mkerrors="$mkerrors -m64"
- mksysnum="./mksysnum_linux.pl $unistd_h"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-linux_s390x)
- GOOSARCH_in=syscall_linux_s390x.go
- unistd_h=/usr/include/asm/unistd.h
- mkerrors="$mkerrors -m64"
- mksysnum="./mksysnum_linux.pl $unistd_h"
- # Let the type of C char be signed to make the bare sys
- # API more consistent between platforms.
- # This is a deliberate departure from the way the syscall
- # package generates its version of the types file.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-linux_sparc64)
- GOOSARCH_in=syscall_linux_sparc64.go
- unistd_h=/usr/include/sparc64-linux-gnu/asm/unistd.h
- mkerrors="$mkerrors -m64"
- mksysnum="./mksysnum_linux.pl $unistd_h"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-netbsd_386)
- mkerrors="$mkerrors -m32"
- mksyscall="./mksyscall.pl -l32 -netbsd"
- mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-netbsd_amd64)
- mkerrors="$mkerrors -m64"
- mksyscall="./mksyscall.pl -netbsd"
- mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-openbsd_386)
- mkerrors="$mkerrors -m32"
- mksyscall="./mksyscall.pl -l32 -openbsd"
- mksysctl="./mksysctl_openbsd.pl"
- zsysctl="zsysctl_openbsd.go"
- mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-openbsd_amd64)
- mkerrors="$mkerrors -m64"
- mksyscall="./mksyscall.pl -openbsd"
- mksysctl="./mksysctl_openbsd.pl"
- zsysctl="zsysctl_openbsd.go"
- mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-solaris_amd64)
- mksyscall="./mksyscall_solaris.pl"
- mkerrors="$mkerrors -m64"
- mksysnum=
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-*)
- echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
- exit 1
- ;;
-esac
-
-(
- if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >$zerrors"; fi
- case "$GOOS" in
- *)
- syscall_goos="syscall_$GOOS.go"
- case "$GOOS" in
- darwin | dragonfly | freebsd | netbsd | openbsd)
- syscall_goos="syscall_bsd.go $syscall_goos"
- ;;
- esac
- if [ -n "$mksyscall" ]; then echo "$mksyscall $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go"; fi
- ;;
- esac
- if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
- if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
- if [ -n "$mktypes" ]; then
- echo "echo // +build $GOARCH,$GOOS > ztypes_$GOOSARCH.go";
- echo "$mktypes types_$GOOS.go | go run mkpost.go >>ztypes_$GOOSARCH.go";
- fi
-) | $run
diff --git a/newt/vendor/golang.org/x/sys/unix/mkerrors.sh b/newt/vendor/golang.org/x/sys/unix/mkerrors.sh
deleted file mode 100755
index 33b7922b..00000000
--- a/newt/vendor/golang.org/x/sys/unix/mkerrors.sh
+++ /dev/null
@@ -1,483 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-# Generate Go code listing errors and other #defined constant
-# values (ENAMETOOLONG etc.), by asking the preprocessor
-# about the definitions.
-
-unset LANG
-export LC_ALL=C
-export LC_CTYPE=C
-
-if test -z "$GOARCH" -o -z "$GOOS"; then
- echo 1>&2 "GOARCH or GOOS not defined in environment"
- exit 1
-fi
-
-CC=${CC:-cc}
-
-if [[ "$GOOS" -eq "solaris" ]]; then
- # Assumes GNU versions of utilities in PATH.
- export PATH=/usr/gnu/bin:$PATH
-fi
-
-uname=$(uname)
-
-includes_Darwin='
-#define _DARWIN_C_SOURCE
-#define KERNEL
-#define _DARWIN_USE_64_BIT_INODE
-#include <sys/types.h>
-#include <sys/event.h>
-#include <sys/ptrace.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/sysctl.h>
-#include <sys/mman.h>
-#include <sys/wait.h>
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_types.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <termios.h>
-'
-
-includes_DragonFly='
-#include <sys/types.h>
-#include <sys/event.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/sysctl.h>
-#include <sys/mman.h>
-#include <sys/wait.h>
-#include <sys/ioctl.h>
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_types.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <termios.h>
-#include <netinet/ip.h>
-#include <net/ip_mroute/ip_mroute.h>
-'
-
-includes_FreeBSD='
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/event.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/sysctl.h>
-#include <sys/mman.h>
-#include <sys/wait.h>
-#include <sys/ioctl.h>
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_types.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <termios.h>
-#include <netinet/ip.h>
-#include <netinet/ip_mroute.h>
-#include <sys/extattr.h>
-
-#if __FreeBSD__ >= 10
-#define IFT_CARP 0xf8 // IFT_CARP is deprecated in FreeBSD 10
-#undef SIOCAIFADDR
-#define SIOCAIFADDR _IOW(105, 26, struct oifaliasreq) // ifaliasreq contains if_data
-#undef SIOCSIFPHYADDR
-#define SIOCSIFPHYADDR _IOW(105, 70, struct oifaliasreq) // ifaliasreq contains if_data
-#endif
-'
-
-includes_Linux='
-#define _LARGEFILE_SOURCE
-#define _LARGEFILE64_SOURCE
-#ifndef __LP64__
-#define _FILE_OFFSET_BITS 64
-#endif
-#define _GNU_SOURCE
-
-#include <bits/sockaddr.h>
-#include <sys/epoll.h>
-#include <sys/inotify.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/prctl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <linux/if.h>
-#include <linux/if_arp.h>
-#include <linux/if_ether.h>
-#include <linux/if_tun.h>
-#include <linux/if_packet.h>
-#include <linux/if_addr.h>
-#include <linux/filter.h>
-#include <linux/netlink.h>
-#include <linux/reboot.h>
-#include <linux/rtnetlink.h>
-#include <linux/ptrace.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/icmpv6.h>
-#include <linux/serial.h>
-#include <net/route.h>
-#include <asm/termbits.h>
-
-#ifndef MSG_FASTOPEN
-#define MSG_FASTOPEN 0x20000000
-#endif
-
-#ifndef PTRACE_GETREGS
-#define PTRACE_GETREGS 0xc
-#endif
-
-#ifndef PTRACE_SETREGS
-#define PTRACE_SETREGS 0xd
-#endif
-
-#ifdef SOL_BLUETOOTH
-// SPARC includes this in /usr/include/sparc64-linux-gnu/bits/socket.h
-// but it is already in bluetooth_linux.go
-#undef SOL_BLUETOOTH
-#endif
-'
-
-includes_NetBSD='
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/event.h>
-#include <sys/mman.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/sysctl.h>
-#include <sys/termios.h>
-#include <sys/ttycom.h>
-#include <sys/wait.h>
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_types.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_mroute.h>
-#include <netinet/if_ether.h>
-
-// Needed since <sys/param.h> refers to it...
-#define schedppq 1
-'
-
-includes_OpenBSD='
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/event.h>
-#include <sys/mman.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/sysctl.h>
-#include <sys/termios.h>
-#include <sys/ttycom.h>
-#include <sys/wait.h>
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_types.h>
-#include <net/if_var.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_mroute.h>
-#include <netinet/if_ether.h>
-#include <net/if_bridge.h>
-
-// We keep some constants not supported in OpenBSD 5.5 and beyond for
-// the promise of compatibility.
-#define EMUL_ENABLED 0x1
-#define EMUL_NATIVE 0x2
-#define IPV6_FAITH 0x1d
-#define IPV6_OPTIONS 0x1
-#define IPV6_RTHDR_STRICT 0x1
-#define IPV6_SOCKOPT_RESERVED1 0x3
-#define SIOCGIFGENERIC 0xc020693a
-#define SIOCSIFGENERIC 0x80206939
-#define WALTSIG 0x4
-'
-
-includes_SunOS='
-#include <limits.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/mman.h>
-#include <sys/wait.h>
-#include <sys/ioctl.h>
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/if_types.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <termios.h>
-#include <netinet/ip.h>
-#include <netinet/ip_mroute.h>
-'
-
-
-includes='
-#include <sys/types.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/ip6.h>
-#include <netinet/tcp.h>
-#include <errno.h>
-#include <sys/signal.h>
-#include <signal.h>
-#include <sys/resource.h>
-#include <time.h>
-'
-ccflags="$@"
-
-# Write go tool cgo -godefs input.
-(
- echo package unix
- echo
- echo '/*'
- indirect="includes_$(uname)"
- echo "${!indirect} $includes"
- echo '*/'
- echo 'import "C"'
- echo 'import "syscall"'
- echo
- echo 'const ('
-
- # The gcc command line prints all the #defines
- # it encounters while processing the input
- echo "${!indirect} $includes" | $CC -x c - -E -dM $ccflags |
- awk '
- $1 != "#define" || $2 ~ /\(/ || $3 == "" {next}
-
- $2 ~ /^E([ABCD]X|[BIS]P|[SD]I|S|FL)$/ {next} # 386 registers
- $2 ~ /^(SIGEV_|SIGSTKSZ|SIGRT(MIN|MAX))/ {next}
- $2 ~ /^(SCM_SRCRT)$/ {next}
- $2 ~ /^(MAP_FAILED)$/ {next}
- $2 ~ /^ELF_.*$/ {next}# <asm/elf.h> contains ELF_ARCH, etc.
-
- $2 ~ /^EXTATTR_NAMESPACE_NAMES/ ||
- $2 ~ /^EXTATTR_NAMESPACE_[A-Z]+_STRING/ {next}
-
- $2 !~ /^ETH_/ &&
- $2 !~ /^EPROC_/ &&
- $2 !~ /^EQUIV_/ &&
- $2 !~ /^EXPR_/ &&
- $2 ~ /^E[A-Z0-9_]+$/ ||
- $2 ~ /^B[0-9_]+$/ ||
- $2 == "BOTHER" ||
- $2 ~ /^CI?BAUD(EX)?$/ ||
- $2 == "IBSHIFT" ||
- $2 ~ /^V[A-Z0-9]+$/ ||
- $2 ~ /^CS[A-Z0-9]/ ||
- $2 ~ /^I(SIG|CANON|CRNL|UCLC|EXTEN|MAXBEL|STRIP|UTF8)$/ ||
- $2 ~ /^IGN/ ||
- $2 ~ /^IX(ON|ANY|OFF)$/ ||
- $2 ~ /^IN(LCR|PCK)$/ ||
- $2 ~ /(^FLU?SH)|(FLU?SH$)/ ||
- $2 ~ /^C(LOCAL|READ|MSPAR|RTSCTS)$/ ||
- $2 == "BRKINT" ||
- $2 == "HUPCL" ||
- $2 == "PENDIN" ||
- $2 == "TOSTOP" ||
- $2 == "XCASE" ||
- $2 == "ALTWERASE" ||
- $2 == "NOKERNINFO" ||
- $2 ~ /^PAR/ ||
- $2 ~ /^SIG[^_]/ ||
- $2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ ||
- $2 ~ /^(NL|CR|TAB|BS|VT|FF)DLY$/ ||
- $2 ~ /^(NL|CR|TAB|BS|VT|FF)[0-9]$/ ||
- $2 ~ /^O?XTABS$/ ||
- $2 ~ /^TC[IO](ON|OFF)$/ ||
- $2 ~ /^IN_/ ||
- $2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
- $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
- $2 == "ICMPV6_FILTER" ||
- $2 == "SOMAXCONN" ||
- $2 == "NAME_MAX" ||
- $2 == "IFNAMSIZ" ||
- $2 ~ /^CTL_(MAXNAME|NET|QUERY)$/ ||
- $2 ~ /^SYSCTL_VERS/ ||
- $2 ~ /^(MS|MNT)_/ ||
- $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
- $2 ~ /^(O|F|FD|NAME|S|PTRACE|PT)_/ ||
- $2 ~ /^LINUX_REBOOT_CMD_/ ||
- $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
- $2 !~ "NLA_TYPE_MASK" &&
- $2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P)_/ ||
- $2 ~ /^SIOC/ ||
- $2 ~ /^TIOC/ ||
- $2 ~ /^TCGET/ ||
- $2 ~ /^TCSET/ ||
- $2 ~ /^TC(FLSH|SBRKP?|XONC)$/ ||
- $2 !~ "RTF_BITS" &&
- $2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
- $2 ~ /^BIOC/ ||
- $2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
- $2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|NOFILE|STACK)|RLIM_INFINITY/ ||
- $2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
- $2 ~ /^CLONE_[A-Z_]+/ ||
- $2 !~ /^(BPF_TIMEVAL)$/ &&
- $2 ~ /^(BPF|DLT)_/ ||
- $2 ~ /^CLOCK_/ ||
- $2 !~ "WMESGLEN" &&
- $2 ~ /^W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", $2, $2)}
- $2 ~ /^__WCOREFLAG$/ {next}
- $2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
-
- {next}
- ' | sort
-
- echo ')'
-) >_const.go
-
-# Pull out the error names for later.
-errors=$(
- echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
- awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' |
- sort
-)
-
-# Pull out the signal names for later.
-signals=$(
- echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
- awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
- egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
- sort
-)
-
-# Again, writing regexps to a file.
-echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
- awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" }' |
- sort >_error.grep
-echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
- awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
- egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
- sort >_signal.grep
-
-echo '// mkerrors.sh' "$@"
-echo '// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT'
-echo
-echo "// +build ${GOARCH},${GOOS}"
-echo
-go tool cgo -godefs -- "$@" _const.go >_error.out
-cat _error.out | grep -vf _error.grep | grep -vf _signal.grep
-echo
-echo '// Errors'
-echo 'const ('
-cat _error.out | grep -f _error.grep | sed 's/=\(.*\)/= syscall.Errno(\1)/'
-echo ')'
-
-echo
-echo '// Signals'
-echo 'const ('
-cat _error.out | grep -f _signal.grep | sed 's/=\(.*\)/= syscall.Signal(\1)/'
-echo ')'
-
-# Run C program to print error and syscall strings.
-(
- echo -E "
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <ctype.h>
-#include <string.h>
-#include <signal.h>
-
-#define nelem(x) (sizeof(x)/sizeof((x)[0]))
-
-enum { A = 'A', Z = 'Z', a = 'a', z = 'z' }; // avoid need for single quotes below
-
-int errors[] = {
-"
- for i in $errors
- do
- echo -E ' '$i,
- done
-
- echo -E "
-};
-
-int signals[] = {
-"
- for i in $signals
- do
- echo -E ' '$i,
- done
-
- # Use -E because on some systems bash builtin interprets \n itself.
- echo -E '
-};
-
-static int
-intcmp(const void *a, const void *b)
-{
- return *(int*)a - *(int*)b;
-}
-
-int
-main(void)
-{
- int i, j, e;
- char buf[1024], *p;
-
- printf("\n\n// Error table\n");
- printf("var errors = [...]string {\n");
- qsort(errors, nelem(errors), sizeof errors[0], intcmp);
- for(i=0; i<nelem(errors); i++) {
- e = errors[i];
- if(i > 0 && errors[i-1] == e)
- continue;
- strcpy(buf, strerror(e));
- // lowercase first letter: Bad -> bad, but STREAM -> STREAM.
- if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
- buf[0] += a - A;
- printf("\t%d: \"%s\",\n", e, buf);
- }
- printf("}\n\n");
-
- printf("\n\n// Signal table\n");
- printf("var signals = [...]string {\n");
- qsort(signals, nelem(signals), sizeof signals[0], intcmp);
- for(i=0; i<nelem(signals); i++) {
- e = signals[i];
- if(i > 0 && signals[i-1] == e)
- continue;
- strcpy(buf, strsignal(e));
- // lowercase first letter: Bad -> bad, but STREAM -> STREAM.
- if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
- buf[0] += a - A;
- // cut trailing : number.
- p = strrchr(buf, ":"[0]);
- if(p)
- *p = '\0';
- printf("\t%d: \"%s\",\n", e, buf);
- }
- printf("}\n\n");
-
- return 0;
-}
-
-'
-) >_errors.c
-
-$CC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c _errors _const.go _error.grep _signal.grep _error.out
diff --git a/newt/vendor/golang.org/x/sys/unix/mkpost.go b/newt/vendor/golang.org/x/sys/unix/mkpost.go
deleted file mode 100644
index ed50d902..00000000
--- a/newt/vendor/golang.org/x/sys/unix/mkpost.go
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2016 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-// mkpost processes the output of cgo -godefs to
-// modify the generated types. It is used to clean up
-// the sys API in an architecture specific manner.
-//
-// mkpost is run after cgo -godefs by mkall.sh.
-package main
-
-import (
- "fmt"
- "go/format"
- "io/ioutil"
- "log"
- "os"
- "regexp"
-)
-
-func main() {
- b, err := ioutil.ReadAll(os.Stdin)
- if err != nil {
- log.Fatal(err)
- }
- s := string(b)
-
- goarch := os.Getenv("GOARCH")
- goos := os.Getenv("GOOS")
- if goarch == "s390x" && goos == "linux" {
- // Export the types of PtraceRegs fields.
- re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)")
- s = re.ReplaceAllString(s, "Ptrace$1")
-
- // Replace padding fields inserted by cgo with blank identifiers.
- re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*")
- s = re.ReplaceAllString(s, "_")
-
- // Replace other unwanted fields with blank identifiers.
- re = regexp.MustCompile("X_[A-Za-z0-9_]*")
- s = re.ReplaceAllString(s, "_")
-
- // Replace the control_regs union with a blank identifier for now.
- re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64")
- s = re.ReplaceAllString(s, "_ [0]uint64")
- }
-
- // gofmt
- b, err = format.Source([]byte(s))
- if err != nil {
- log.Fatal(err)
- }
-
- // Append this command to the header to show where the new file
- // came from.
- re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)")
- b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go"))
-
- fmt.Printf("%s", b)
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/mksyscall.pl b/newt/vendor/golang.org/x/sys/unix/mksyscall.pl
deleted file mode 100755
index b1e7766d..00000000
--- a/newt/vendor/golang.org/x/sys/unix/mksyscall.pl
+++ /dev/null
@@ -1,323 +0,0 @@
-#!/usr/bin/env perl
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-# This program reads a file containing function prototypes
-# (like syscall_darwin.go) and generates system call bodies.
-# The prototypes are marked by lines beginning with "//sys"
-# and read like func declarations if //sys is replaced by func, but:
-# * The parameter lists must give a name for each argument.
-# This includes return parameters.
-# * The parameter lists must give a type for each argument:
-# the (x, y, z int) shorthand is not allowed.
-# * If the return parameter is an error number, it must be named errno.
-
-# A line beginning with //sysnb is like //sys, except that the
-# goroutine will not be suspended during the execution of the system
-# call. This must only be used for system calls which can never
-# block, as otherwise the system call could cause all goroutines to
-# hang.
-
-use strict;
-
-my $cmdline = "mksyscall.pl " . join(' ', @ARGV);
-my $errors = 0;
-my $_32bit = "";
-my $plan9 = 0;
-my $openbsd = 0;
-my $netbsd = 0;
-my $dragonfly = 0;
-my $arm = 0; # 64-bit value should use (even, odd)-pair
-
-if($ARGV[0] eq "-b32") {
- $_32bit = "big-endian";
- shift;
-} elsif($ARGV[0] eq "-l32") {
- $_32bit = "little-endian";
- shift;
-}
-if($ARGV[0] eq "-plan9") {
- $plan9 = 1;
- shift;
-}
-if($ARGV[0] eq "-openbsd") {
- $openbsd = 1;
- shift;
-}
-if($ARGV[0] eq "-netbsd") {
- $netbsd = 1;
- shift;
-}
-if($ARGV[0] eq "-dragonfly") {
- $dragonfly = 1;
- shift;
-}
-if($ARGV[0] eq "-arm") {
- $arm = 1;
- shift;
-}
-
-if($ARGV[0] =~ /^-/) {
- print STDERR "usage: mksyscall.pl [-b32 | -l32] [file ...]\n";
- exit 1;
-}
-
-if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
- print STDERR "GOARCH or GOOS not defined in environment\n";
- exit 1;
-}
-
-sub parseparamlist($) {
- my ($list) = @_;
- $list =~ s/^\s*//;
- $list =~ s/\s*$//;
- if($list eq "") {
- return ();
- }
- return split(/\s*,\s*/, $list);
-}
-
-sub parseparam($) {
- my ($p) = @_;
- if($p !~ /^(\S*) (\S*)$/) {
- print STDERR "$ARGV:$.: malformed parameter: $p\n";
- $errors = 1;
- return ("xx", "int");
- }
- return ($1, $2);
-}
-
-my $text = "";
-while(<>) {
- chomp;
- s/\s+/ /g;
- s/^\s+//;
- s/\s+$//;
- my $nonblock = /^\/\/sysnb /;
- next if !/^\/\/sys / && !$nonblock;
-
- # Line must be of the form
- # func Open(path string, mode int, perm int) (fd int, errno error)
- # Split into name, in params, out params.
- if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$/) {
- print STDERR "$ARGV:$.: malformed //sys declaration\n";
- $errors = 1;
- next;
- }
- my ($func, $in, $out, $sysname) = ($2, $3, $4, $5);
-
- # Split argument lists on comma.
- my @in = parseparamlist($in);
- my @out = parseparamlist($out);
-
- # Try in vain to keep people from editing this file.
- # The theory is that they jump into the middle of the file
- # without reading the header.
- $text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n";
-
- # Go function header.
- my $out_decl = @out ? sprintf(" (%s)", join(', ', @out)) : "";
- $text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out_decl;
-
- # Check if err return available
- my $errvar = "";
- foreach my $p (@out) {
- my ($name, $type) = parseparam($p);
- if($type eq "error") {
- $errvar = $name;
- last;
- }
- }
-
- # Prepare arguments to Syscall.
- my @args = ();
- my @uses = ();
- my $n = 0;
- foreach my $p (@in) {
- my ($name, $type) = parseparam($p);
- if($type =~ /^\*/) {
- push @args, "uintptr(unsafe.Pointer($name))";
- } elsif($type eq "string" && $errvar ne "") {
- $text .= "\tvar _p$n *byte\n";
- $text .= "\t_p$n, $errvar = BytePtrFromString($name)\n";
- $text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
- push @args, "uintptr(unsafe.Pointer(_p$n))";
- push @uses, "use(unsafe.Pointer(_p$n))";
- $n++;
- } elsif($type eq "string") {
- print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
- $text .= "\tvar _p$n *byte\n";
- $text .= "\t_p$n, _ = BytePtrFromString($name)\n";
- push @args, "uintptr(unsafe.Pointer(_p$n))";
- push @uses, "use(unsafe.Pointer(_p$n))";
- $n++;
- } elsif($type =~ /^\[\](.*)/) {
- # Convert slice into pointer, length.
- # Have to be careful not to take address of &a[0] if len == 0:
- # pass dummy pointer in that case.
- # Used to pass nil, but some OSes or simulators reject write(fd, nil, 0).
- $text .= "\tvar _p$n unsafe.Pointer\n";
- $text .= "\tif len($name) > 0 {\n\t\t_p$n = unsafe.Pointer(\&${name}[0])\n\t}";
- $text .= " else {\n\t\t_p$n = unsafe.Pointer(&_zero)\n\t}";
- $text .= "\n";
- push @args, "uintptr(_p$n)", "uintptr(len($name))";
- $n++;
- } elsif($type eq "int64" && ($openbsd || $netbsd)) {
- push @args, "0";
- if($_32bit eq "big-endian") {
- push @args, "uintptr($name>>32)", "uintptr($name)";
- } elsif($_32bit eq "little-endian") {
- push @args, "uintptr($name)", "uintptr($name>>32)";
- } else {
- push @args, "uintptr($name)";
- }
- } elsif($type eq "int64" && $dragonfly) {
- if ($func !~ /^extp(read|write)/i) {
- push @args, "0";
- }
- if($_32bit eq "big-endian") {
- push @args, "uintptr($name>>32)", "uintptr($name)";
- } elsif($_32bit eq "little-endian") {
- push @args, "uintptr($name)", "uintptr($name>>32)";
- } else {
- push @args, "uintptr($name)";
- }
- } elsif($type eq "int64" && $_32bit ne "") {
- if(@args % 2 && $arm) {
- # arm abi specifies 64-bit argument uses
- # (even, odd) pair
- push @args, "0"
- }
- if($_32bit eq "big-endian") {
- push @args, "uintptr($name>>32)", "uintptr($name)";
- } else {
- push @args, "uintptr($name)", "uintptr($name>>32)";
- }
- } else {
- push @args, "uintptr($name)";
- }
- }
-
- # Determine which form to use; pad args with zeros.
- my $asm = "Syscall";
- if ($nonblock) {
- $asm = "RawSyscall";
- }
- if(@args <= 3) {
- while(@args < 3) {
- push @args, "0";
- }
- } elsif(@args <= 6) {
- $asm .= "6";
- while(@args < 6) {
- push @args, "0";
- }
- } elsif(@args <= 9) {
- $asm .= "9";
- while(@args < 9) {
- push @args, "0";
- }
- } else {
- print STDERR "$ARGV:$.: too many arguments to system call\n";
- }
-
- # System call number.
- if($sysname eq "") {
- $sysname = "SYS_$func";
- $sysname =~ s/([a-z])([A-Z])/${1}_$2/g; # turn FooBar into Foo_Bar
- $sysname =~ y/a-z/A-Z/;
- }
-
- # Actual call.
- my $args = join(', ', @args);
- my $call = "$asm($sysname, $args)";
-
- # Assign return values.
- my $body = "";
- my @ret = ("_", "_", "_");
- my $do_errno = 0;
- for(my $i=0; $i<@out; $i++) {
- my $p = $out[$i];
- my ($name, $type) = parseparam($p);
- my $reg = "";
- if($name eq "err" && !$plan9) {
- $reg = "e1";
- $ret[2] = $reg;
- $do_errno = 1;
- } elsif($name eq "err" && $plan9) {
- $ret[0] = "r0";
- $ret[2] = "e1";
- next;
- } else {
- $reg = sprintf("r%d", $i);
- $ret[$i] = $reg;
- }
- if($type eq "bool") {
- $reg = "$reg != 0";
- }
- if($type eq "int64" && $_32bit ne "") {
- # 64-bit number in r1:r0 or r0:r1.
- if($i+2 > @out) {
- print STDERR "$ARGV:$.: not enough registers for int64 return\n";
- }
- if($_32bit eq "big-endian") {
- $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1);
- } else {
- $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i);
- }
- $ret[$i] = sprintf("r%d", $i);
- $ret[$i+1] = sprintf("r%d", $i+1);
- }
- if($reg ne "e1" || $plan9) {
- $body .= "\t$name = $type($reg)\n";
- }
- }
- if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
- $text .= "\t$call\n";
- } else {
- $text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
- }
- foreach my $use (@uses) {
- $text .= "\t$use\n";
- }
- $text .= $body;
-
- if ($plan9 && $ret[2] eq "e1") {
- $text .= "\tif int32(r0) == -1 {\n";
- $text .= "\t\terr = e1\n";
- $text .= "\t}\n";
- } elsif ($do_errno) {
- $text .= "\tif e1 != 0 {\n";
- $text .= "\t\terr = errnoErr(e1)\n";
- $text .= "\t}\n";
- }
- $text .= "\treturn\n";
- $text .= "}\n\n";
-}
-
-chomp $text;
-chomp $text;
-
-if($errors) {
- exit 1;
-}
-
-print <<EOF;
-// $cmdline
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build $ENV{'GOARCH'},$ENV{'GOOS'}
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-$text
-EOF
-exit 0;
diff --git a/newt/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl b/newt/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl
deleted file mode 100755
index 06bade76..00000000
--- a/newt/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl
+++ /dev/null
@@ -1,294 +0,0 @@
-#!/usr/bin/env perl
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-# This program reads a file containing function prototypes
-# (like syscall_solaris.go) and generates system call bodies.
-# The prototypes are marked by lines beginning with "//sys"
-# and read like func declarations if //sys is replaced by func, but:
-# * The parameter lists must give a name for each argument.
-# This includes return parameters.
-# * The parameter lists must give a type for each argument:
-# the (x, y, z int) shorthand is not allowed.
-# * If the return parameter is an error number, it must be named err.
-# * If go func name needs to be different than its libc name,
-# * or the function is not in libc, name could be specified
-# * at the end, after "=" sign, like
-# //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
-
-use strict;
-
-my $cmdline = "mksyscall_solaris.pl " . join(' ', @ARGV);
-my $errors = 0;
-my $_32bit = "";
-
-binmode STDOUT;
-
-if($ARGV[0] eq "-b32") {
- $_32bit = "big-endian";
- shift;
-} elsif($ARGV[0] eq "-l32") {
- $_32bit = "little-endian";
- shift;
-}
-
-if($ARGV[0] =~ /^-/) {
- print STDERR "usage: mksyscall_solaris.pl [-b32 | -l32] [file ...]\n";
- exit 1;
-}
-
-if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
- print STDERR "GOARCH or GOOS not defined in environment\n";
- exit 1;
-}
-
-sub parseparamlist($) {
- my ($list) = @_;
- $list =~ s/^\s*//;
- $list =~ s/\s*$//;
- if($list eq "") {
- return ();
- }
- return split(/\s*,\s*/, $list);
-}
-
-sub parseparam($) {
- my ($p) = @_;
- if($p !~ /^(\S*) (\S*)$/) {
- print STDERR "$ARGV:$.: malformed parameter: $p\n";
- $errors = 1;
- return ("xx", "int");
- }
- return ($1, $2);
-}
-
-my $package = "";
-my $text = "";
-my $dynimports = "";
-my $linknames = "";
-my @vars = ();
-while(<>) {
- chomp;
- s/\s+/ /g;
- s/^\s+//;
- s/\s+$//;
- $package = $1 if !$package && /^package (\S+)$/;
- my $nonblock = /^\/\/sysnb /;
- next if !/^\/\/sys / && !$nonblock;
-
- # Line must be of the form
- # func Open(path string, mode int, perm int) (fd int, err error)
- # Split into name, in params, out params.
- if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$/) {
- print STDERR "$ARGV:$.: malformed //sys declaration\n";
- $errors = 1;
- next;
- }
- my ($nb, $func, $in, $out, $modname, $sysname) = ($1, $2, $3, $4, $5, $6);
-
- # Split argument lists on comma.
- my @in = parseparamlist($in);
- my @out = parseparamlist($out);
-
- # So file name.
- if($modname eq "") {
- $modname = "libc";
- }
-
- # System call name.
- if($sysname eq "") {
- $sysname = "$func";
- }
-
- # System call pointer variable name.
- my $sysvarname = "proc$sysname";
-
- my $strconvfunc = "BytePtrFromString";
- my $strconvtype = "*byte";
-
- $sysname =~ y/A-Z/a-z/; # All libc functions are lowercase.
-
- # Runtime import of function to allow cross-platform builds.
- $dynimports .= "//go:cgo_import_dynamic libc_${sysname} ${sysname} \"$modname.so\"\n";
- # Link symbol to proc address variable.
- $linknames .= "//go:linkname ${sysvarname} libc_${sysname}\n";
- # Library proc address variable.
- push @vars, $sysvarname;
-
- # Go function header.
- $out = join(', ', @out);
- if($out ne "") {
- $out = " ($out)";
- }
- if($text ne "") {
- $text .= "\n"
- }
- $text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out;
-
- # Check if err return available
- my $errvar = "";
- foreach my $p (@out) {
- my ($name, $type) = parseparam($p);
- if($type eq "error") {
- $errvar = $name;
- last;
- }
- }
-
- # Prepare arguments to Syscall.
- my @args = ();
- my @uses = ();
- my $n = 0;
- foreach my $p (@in) {
- my ($name, $type) = parseparam($p);
- if($type =~ /^\*/) {
- push @args, "uintptr(unsafe.Pointer($name))";
- } elsif($type eq "string" && $errvar ne "") {
- $text .= "\tvar _p$n $strconvtype\n";
- $text .= "\t_p$n, $errvar = $strconvfunc($name)\n";
- $text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
- push @args, "uintptr(unsafe.Pointer(_p$n))";
- push @uses, "use(unsafe.Pointer(_p$n))";
- $n++;
- } elsif($type eq "string") {
- print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
- $text .= "\tvar _p$n $strconvtype\n";
- $text .= "\t_p$n, _ = $strconvfunc($name)\n";
- push @args, "uintptr(unsafe.Pointer(_p$n))";
- push @uses, "use(unsafe.Pointer(_p$n))";
- $n++;
- } elsif($type =~ /^\[\](.*)/) {
- # Convert slice into pointer, length.
- # Have to be careful not to take address of &a[0] if len == 0:
- # pass nil in that case.
- $text .= "\tvar _p$n *$1\n";
- $text .= "\tif len($name) > 0 {\n\t\t_p$n = \&$name\[0]\n\t}\n";
- push @args, "uintptr(unsafe.Pointer(_p$n))", "uintptr(len($name))";
- $n++;
- } elsif($type eq "int64" && $_32bit ne "") {
- if($_32bit eq "big-endian") {
- push @args, "uintptr($name >> 32)", "uintptr($name)";
- } else {
- push @args, "uintptr($name)", "uintptr($name >> 32)";
- }
- } elsif($type eq "bool") {
- $text .= "\tvar _p$n uint32\n";
- $text .= "\tif $name {\n\t\t_p$n = 1\n\t} else {\n\t\t_p$n = 0\n\t}\n";
- push @args, "uintptr(_p$n)";
- $n++;
- } else {
- push @args, "uintptr($name)";
- }
- }
- my $nargs = @args;
-
- # Determine which form to use; pad args with zeros.
- my $asm = "sysvicall6";
- if ($nonblock) {
- $asm = "rawSysvicall6";
- }
- if(@args <= 6) {
- while(@args < 6) {
- push @args, "0";
- }
- } else {
- print STDERR "$ARGV:$.: too many arguments to system call\n";
- }
-
- # Actual call.
- my $args = join(', ', @args);
- my $call = "$asm(uintptr(unsafe.Pointer(&$sysvarname)), $nargs, $args)";
-
- # Assign return values.
- my $body = "";
- my $failexpr = "";
- my @ret = ("_", "_", "_");
- my @pout= ();
- my $do_errno = 0;
- for(my $i=0; $i<@out; $i++) {
- my $p = $out[$i];
- my ($name, $type) = parseparam($p);
- my $reg = "";
- if($name eq "err") {
- $reg = "e1";
- $ret[2] = $reg;
- $do_errno = 1;
- } else {
- $reg = sprintf("r%d", $i);
- $ret[$i] = $reg;
- }
- if($type eq "bool") {
- $reg = "$reg != 0";
- }
- if($type eq "int64" && $_32bit ne "") {
- # 64-bit number in r1:r0 or r0:r1.
- if($i+2 > @out) {
- print STDERR "$ARGV:$.: not enough registers for int64 return\n";
- }
- if($_32bit eq "big-endian") {
- $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1);
- } else {
- $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i);
- }
- $ret[$i] = sprintf("r%d", $i);
- $ret[$i+1] = sprintf("r%d", $i+1);
- }
- if($reg ne "e1") {
- $body .= "\t$name = $type($reg)\n";
- }
- }
- if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
- $text .= "\t$call\n";
- } else {
- $text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
- }
- foreach my $use (@uses) {
- $text .= "\t$use\n";
- }
- $text .= $body;
-
- if ($do_errno) {
- $text .= "\tif e1 != 0 {\n";
- $text .= "\t\terr = e1\n";
- $text .= "\t}\n";
- }
- $text .= "\treturn\n";
- $text .= "}\n";
-}
-
-if($errors) {
- exit 1;
-}
-
-print <<EOF;
-// $cmdline
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build $ENV{'GOARCH'},$ENV{'GOOS'}
-
-package $package
-
-import (
- "syscall"
- "unsafe"
-)
-EOF
-
-print "import \"golang.org/x/sys/unix\"\n" if $package ne "unix";
-
-my $vardecls = "\t" . join(",\n\t", @vars);
-$vardecls .= " syscallFunc";
-
-chomp($_=<<EOF);
-
-$dynimports
-$linknames
-var (
-$vardecls
-)
-
-$text
-EOF
-print $_;
-exit 0;
diff --git a/newt/vendor/golang.org/x/sys/unix/mksysnum_darwin.pl b/newt/vendor/golang.org/x/sys/unix/mksysnum_darwin.pl
deleted file mode 100755
index d3e5147f..00000000
--- a/newt/vendor/golang.org/x/sys/unix/mksysnum_darwin.pl
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env perl
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-#
-# Generate system call table for Darwin from sys/syscall.h
-
-use strict;
-
-if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
- print STDERR "GOARCH or GOOS not defined in environment\n";
- exit 1;
-}
-
-my $command = "mksysnum_darwin.pl " . join(' ', @ARGV);
-
-print <<EOF;
-// $command
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build $ENV{'GOARCH'},$ENV{'GOOS'}
-
-package unix
-
-const (
-EOF
-
-while(<>){
- if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){
- my $name = $1;
- my $num = $2;
- $name =~ y/a-z/A-Z/;
- print " SYS_$name = $num;"
- }
-}
-
-print <<EOF;
-)
-EOF
diff --git a/newt/vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl b/newt/vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl
deleted file mode 100755
index 266a248c..00000000
--- a/newt/vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env perl
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-#
-# Generate system call table for DragonFly from master list
-# (for example, /usr/src/sys/kern/syscalls.master).
-
-use strict;
-
-if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
- print STDERR "GOARCH or GOOS not defined in environment\n";
- exit 1;
-}
-
-my $command = "mksysnum_dragonfly.pl " . join(' ', @ARGV);
-
-print <<EOF;
-// $command
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build $ENV{'GOARCH'},$ENV{'GOOS'}
-
-package unix
-
-const (
-EOF
-
-while(<>){
- if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){
- my $num = $1;
- my $proto = $2;
- my $name = "SYS_$3";
- $name =~ y/a-z/A-Z/;
-
- # There are multiple entries for enosys and nosys, so comment them out.
- if($name =~ /^SYS_E?NOSYS$/){
- $name = "// $name";
- }
- if($name eq 'SYS_SYS_EXIT'){
- $name = 'SYS_EXIT';
- }
-
- print " $name = $num; // $proto\n";
- }
-}
-
-print <<EOF;
-)
-EOF
diff --git a/newt/vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl b/newt/vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl
deleted file mode 100755
index b767e124..00000000
--- a/newt/vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/env perl
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-#
-# Generate system call table for FreeBSD from master list
-# (for example, /usr/src/sys/kern/syscalls.master).
-
-use strict;
-
-if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
- print STDERR "GOARCH or GOOS not defined in environment\n";
- exit 1;
-}
-
-my $command = "mksysnum_freebsd.pl " . join(' ', @ARGV);
-
-print <<EOF;
-// $command
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build $ENV{'GOARCH'},$ENV{'GOOS'}
-
-package unix
-
-const (
-EOF
-
-while(<>){
- if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){
- my $num = $1;
- my $proto = $2;
- my $name = "SYS_$3";
- $name =~ y/a-z/A-Z/;
-
- # There are multiple entries for enosys and nosys, so comment them out.
- if($name =~ /^SYS_E?NOSYS$/){
- $name = "// $name";
- }
- if($name eq 'SYS_SYS_EXIT'){
- $name = 'SYS_EXIT';
- }
- if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){
- next
- }
-
- print " $name = $num; // $proto\n";
-
- # We keep Capsicum syscall numbers for FreeBSD
- # 9-STABLE here because we are not sure whether they
- # are mature and stable.
- if($num == 513){
- print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n";
- print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n";
- print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n";
- print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n";
- }
- }
-}
-
-print <<EOF;
-)
-EOF
diff --git a/newt/vendor/golang.org/x/sys/unix/mksysnum_linux.pl b/newt/vendor/golang.org/x/sys/unix/mksysnum_linux.pl
deleted file mode 100755
index 4d4017de..00000000
--- a/newt/vendor/golang.org/x/sys/unix/mksysnum_linux.pl
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env perl
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-use strict;
-
-if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
- print STDERR "GOARCH or GOOS not defined in environment\n";
- exit 1;
-}
-
-my $command = "mksysnum_linux.pl ". join(' ', @ARGV);
-
-print <<EOF;
-// $command
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build $ENV{'GOARCH'},$ENV{'GOOS'}
-
-package unix
-
-const(
-EOF
-
-sub fmt {
- my ($name, $num) = @_;
- if($num > 999){
- # ignore deprecated syscalls that are no longer implemented
- # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716
- return;
- }
- $name =~ y/a-z/A-Z/;
- print " SYS_$name = $num;\n";
-}
-
-my $prev;
-open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc";
-while(<GCC>){
- if(/^#define __NR_syscalls\s+/) {
- # ignore redefinitions of __NR_syscalls
- }
- elsif(/^#define __NR_(\w+)\s+([0-9]+)/){
- $prev = $2;
- fmt($1, $2);
- }
- elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){
- $prev = $2;
- fmt($1, $2);
- }
- elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){
- fmt($1, $prev+$2)
- }
-}
-
-print <<EOF;
-)
-EOF
diff --git a/newt/vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl b/newt/vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl
deleted file mode 100755
index e74616a6..00000000
--- a/newt/vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env perl
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-#
-# Generate system call table for OpenBSD from master list
-# (for example, /usr/src/sys/kern/syscalls.master).
-
-use strict;
-
-if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
- print STDERR "GOARCH or GOOS not defined in environment\n";
- exit 1;
-}
-
-my $command = "mksysnum_netbsd.pl " . join(' ', @ARGV);
-
-print <<EOF;
-// $command
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build $ENV{'GOARCH'},$ENV{'GOOS'}
-
-package unix
-
-const (
-EOF
-
-my $line = '';
-while(<>){
- if($line =~ /^(.*)\\$/) {
- # Handle continuation
- $line = $1;
- $_ =~ s/^\s+//;
- $line .= $_;
- } else {
- # New line
- $line = $_;
- }
- next if $line =~ /\\$/;
- if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) {
- my $num = $1;
- my $proto = $6;
- my $compat = $8;
- my $name = "$7_$9";
-
- $name = "$7_$11" if $11 ne '';
- $name =~ y/a-z/A-Z/;
-
- if($compat eq '' || $compat eq '30' || $compat eq '50') {
- print " $name = $num; // $proto\n";
- }
- }
-}
-
-print <<EOF;
-)
-EOF
diff --git a/newt/vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl b/newt/vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl
deleted file mode 100755
index ae5aad58..00000000
--- a/newt/vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env perl
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-#
-# Generate system call table for OpenBSD from master list
-# (for example, /usr/src/sys/kern/syscalls.master).
-
-use strict;
-
-if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
- print STDERR "GOARCH or GOOS not defined in environment\n";
- exit 1;
-}
-
-my $command = "mksysnum_openbsd.pl " . join(' ', @ARGV);
-
-print <<EOF;
-// $command
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build $ENV{'GOARCH'},$ENV{'GOOS'}
-
-package unix
-
-const (
-EOF
-
-while(<>){
- if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){
- my $num = $1;
- my $proto = $3;
- my $name = $4;
- $name =~ y/a-z/A-Z/;
-
- # There are multiple entries for enosys and nosys, so comment them out.
- if($name =~ /^SYS_E?NOSYS$/){
- $name = "// $name";
- }
- if($name eq 'SYS_SYS_EXIT'){
- $name = 'SYS_EXIT';
- }
-
- print " $name = $num; // $proto\n";
- }
-}
-
-print <<EOF;
-)
-EOF
diff --git a/newt/vendor/golang.org/x/sys/unix/sockcmsg_unix.go b/newt/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
deleted file mode 100644
index f1493a3e..00000000
--- a/newt/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build darwin dragonfly freebsd linux netbsd openbsd solaris
-
-// Socket control messages
-
-package unix
-
-import "unsafe"
-
-// Round the length of a raw sockaddr up to align it properly.
-func cmsgAlignOf(salen int) int {
- salign := sizeofPtr
- // NOTE: It seems like 64-bit Darwin and DragonFly BSD kernels
- // still require 32-bit aligned access to network subsystem.
- if darwin64Bit || dragonfly64Bit {
- salign = 4
- }
- return (salen + salign - 1) & ^(salign - 1)
-}
-
-// CmsgLen returns the value to store in the Len field of the Cmsghdr
-// structure, taking into account any necessary alignment.
-func CmsgLen(datalen int) int {
- return cmsgAlignOf(SizeofCmsghdr) + datalen
-}
-
-// CmsgSpace returns the number of bytes an ancillary element with
-// payload of the passed data length occupies.
-func CmsgSpace(datalen int) int {
- return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen)
-}
-
-func cmsgData(h *Cmsghdr) unsafe.Pointer {
- return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr)))
-}
-
-// SocketControlMessage represents a socket control message.
-type SocketControlMessage struct {
- Header Cmsghdr
- Data []byte
-}
-
-// ParseSocketControlMessage parses b as an array of socket control
-// messages.
-func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) {
- var msgs []SocketControlMessage
- i := 0
- for i+CmsgLen(0) <= len(b) {
- h, dbuf, err := socketControlMessageHeaderAndData(b[i:])
- if err != nil {
- return nil, err
- }
- m := SocketControlMessage{Header: *h, Data: dbuf}
- msgs = append(msgs, m)
- i += cmsgAlignOf(int(h.Len))
- }
- return msgs, nil
-}
-
-func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) {
- h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
- if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) {
- return nil, nil, EINVAL
- }
- return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil
-}
-
-// UnixRights encodes a set of open file descriptors into a socket
-// control message for sending to another process.
-func UnixRights(fds ...int) []byte {
- datalen := len(fds) * 4
- b := make([]byte, CmsgSpace(datalen))
- h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
- h.Level = SOL_SOCKET
- h.Type = SCM_RIGHTS
- h.SetLen(CmsgLen(datalen))
- data := cmsgData(h)
- for _, fd := range fds {
- *(*int32)(data) = int32(fd)
- data = unsafe.Pointer(uintptr(data) + 4)
- }
- return b
-}
-
-// ParseUnixRights decodes a socket control message that contains an
-// integer array of open file descriptors from another process.
-func ParseUnixRights(m *SocketControlMessage) ([]int, error) {
- if m.Header.Level != SOL_SOCKET {
- return nil, EINVAL
- }
- if m.Header.Type != SCM_RIGHTS {
- return nil, EINVAL
- }
- fds := make([]int, len(m.Data)>>2)
- for i, j := 0, 0; i < len(m.Data); i += 4 {
- fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i])))
- j++
- }
- return fds, nil
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/syscall.go b/newt/vendor/golang.org/x/sys/unix/syscall.go
deleted file mode 100644
index 571e6993..00000000
--- a/newt/vendor/golang.org/x/sys/unix/syscall.go
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build darwin dragonfly freebsd linux netbsd openbsd solaris
-
-// Package unix contains an interface to the low-level operating system
-// primitives. OS details vary depending on the underlying system, and
-// by default, godoc will display OS-specific documentation for the current
-// system. If you want godoc to display OS documentation for another
-// system, set $GOOS and $GOARCH to the desired system. For example, if
-// you want to view documentation for freebsd/arm on linux/amd64, set $GOOS
-// to freebsd and $GOARCH to arm.
-// The primary use of this package is inside other packages that provide a more
-// portable interface to the system, such as "os", "time" and "net". Use
-// those packages rather than this one if you can.
-// For details of the functions and data types in this package consult
-// the manuals for the appropriate operating system.
-// These calls return err == nil to indicate success; otherwise
-// err represents an operating system error describing the failure and
-// holds a value of type syscall.Errno.
-package unix
-
-import "unsafe"
-
-// ByteSliceFromString returns a NUL-terminated slice of bytes
-// containing the text of s. If s contains a NUL byte at any
-// location, it returns (nil, EINVAL).
-func ByteSliceFromString(s string) ([]byte, error) {
- for i := 0; i < len(s); i++ {
- if s[i] == 0 {
- return nil, EINVAL
- }
- }
- a := make([]byte, len(s)+1)
- copy(a, s)
- return a, nil
-}
-
-// BytePtrFromString returns a pointer to a NUL-terminated array of
-// bytes containing the text of s. If s contains a NUL byte at any
-// location, it returns (nil, EINVAL).
-func BytePtrFromString(s string) (*byte, error) {
- a, err := ByteSliceFromString(s)
- if err != nil {
- return nil, err
- }
- return &a[0], nil
-}
-
-// Single-word zero for use when we need a valid pointer to 0 bytes.
-// See mkunix.pl.
-var _zero uintptr
-
-func (ts *Timespec) Unix() (sec int64, nsec int64) {
- return int64(ts.Sec), int64(ts.Nsec)
-}
-
-func (tv *Timeval) Unix() (sec int64, nsec int64) {
- return int64(tv.Sec), int64(tv.Usec) * 1000
-}
-
-func (ts *Timespec) Nano() int64 {
- return int64(ts.Sec)*1e9 + int64(ts.Nsec)
-}
-
-func (tv *Timeval) Nano() int64 {
- return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
-}
-
-func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
-
-// use is a no-op, but the compiler cannot see that it is.
-// Calling use(p) ensures that p is kept live until that point.
-//go:noescape
-func use(p unsafe.Pointer)
diff --git a/newt/vendor/golang.org/x/sys/unix/syscall_bsd.go b/newt/vendor/golang.org/x/sys/unix/syscall_bsd.go
deleted file mode 100644
index e9671764..00000000
--- a/newt/vendor/golang.org/x/sys/unix/syscall_bsd.go
+++ /dev/null
@@ -1,628 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build darwin dragonfly freebsd netbsd openbsd
-
-// BSD system call wrappers shared by *BSD based systems
-// including OS X (Darwin) and FreeBSD. Like the other
-// syscall_*.go files it is compiled as Go code but also
-// used as input to mksyscall which parses the //sys
-// lines and generates system call stubs.
-
-package unix
-
-import (
- "runtime"
- "syscall"
- "unsafe"
-)
-
-/*
- * Wrapped
- */
-
-//sysnb getgroups(ngid int, gid *_Gid_t) (n int, err error)
-//sysnb setgroups(ngid int, gid *_Gid_t) (err error)
-
-func Getgroups() (gids []int, err error) {
- n, err := getgroups(0, nil)
- if err != nil {
- return nil, err
- }
- if n == 0 {
- return nil, nil
- }
-
- // Sanity check group count. Max is 16 on BSD.
- if n < 0 || n > 1000 {
- return nil, EINVAL
- }
-
- a := make([]_Gid_t, n)
- n, err = getgroups(n, &a[0])
- if err != nil {
- return nil, err
- }
- gids = make([]int, n)
- for i, v := range a[0:n] {
- gids[i] = int(v)
- }
- return
-}
-
-func Setgroups(gids []int) (err error) {
- if len(gids) == 0 {
- return setgroups(0, nil)
- }
-
- a := make([]_Gid_t, len(gids))
- for i, v := range gids {
- a[i] = _Gid_t(v)
- }
- return setgroups(len(a), &a[0])
-}
-
-func ReadDirent(fd int, buf []byte) (n int, err error) {
- // Final argument is (basep *uintptr) and the syscall doesn't take nil.
- // 64 bits should be enough. (32 bits isn't even on 386). Since the
- // actual system call is getdirentries64, 64 is a good guess.
- // TODO(rsc): Can we use a single global basep for all calls?
- var base = (*uintptr)(unsafe.Pointer(new(uint64)))
- return Getdirentries(fd, buf, base)
-}
-
-// Wait status is 7 bits at bottom, either 0 (exited),
-// 0x7F (stopped), or a signal number that caused an exit.
-// The 0x80 bit is whether there was a core dump.
-// An extra number (exit code, signal causing a stop)
-// is in the high bits.
-
-type WaitStatus uint32
-
-const (
- mask = 0x7F
- core = 0x80
- shift = 8
-
- exited = 0
- stopped = 0x7F
-)
-
-func (w WaitStatus) Exited() bool { return w&mask == exited }
-
-func (w WaitStatus) ExitStatus() int {
- if w&mask != exited {
- return -1
- }
- return int(w >> shift)
-}
-
-func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 }
-
-func (w WaitStatus) Signal() syscall.Signal {
- sig := syscall.Signal(w & mask)
- if sig == stopped || sig == 0 {
- return -1
- }
- return sig
-}
-
-func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 }
-
-func (w WaitStatus) Stopped() bool { return w&mask == stopped && syscall.Signal(w>>shift) != SIGSTOP }
-
-func (w WaitStatus) Continued() bool { return w&mask == stopped && syscall.Signal(w>>shift) == SIGSTOP }
-
-func (w WaitStatus) StopSignal() syscall.Signal {
- if !w.Stopped() {
- return -1
- }
- return syscall.Signal(w>>shift) & 0xFF
-}
-
-func (w WaitStatus) TrapCause() int { return -1 }
-
-//sys wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error)
-
-func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
- var status _C_int
- wpid, err = wait4(pid, &status, options, rusage)
- if wstatus != nil {
- *wstatus = WaitStatus(status)
- }
- return
-}
-
-//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
-//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
-//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
-//sysnb socket(domain int, typ int, proto int) (fd int, err error)
-//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
-//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
-//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
-//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
-//sys Shutdown(s int, how int) (err error)
-
-func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
- if sa.Port < 0 || sa.Port > 0xFFFF {
- return nil, 0, EINVAL
- }
- sa.raw.Len = SizeofSockaddrInet4
- sa.raw.Family = AF_INET
- p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
- p[0] = byte(sa.Port >> 8)
- p[1] = byte(sa.Port)
- for i := 0; i < len(sa.Addr); i++ {
- sa.raw.Addr[i] = sa.Addr[i]
- }
- return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
-}
-
-func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
- if sa.Port < 0 || sa.Port > 0xFFFF {
- return nil, 0, EINVAL
- }
- sa.raw.Len = SizeofSockaddrInet6
- sa.raw.Family = AF_INET6
- p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
- p[0] = byte(sa.Port >> 8)
- p[1] = byte(sa.Port)
- sa.raw.Scope_id = sa.ZoneId
- for i := 0; i < len(sa.Addr); i++ {
- sa.raw.Addr[i] = sa.Addr[i]
- }
- return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
-}
-
-func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
- name := sa.Name
- n := len(name)
- if n >= len(sa.raw.Path) || n == 0 {
- return nil, 0, EINVAL
- }
- sa.raw.Len = byte(3 + n) // 2 for Family, Len; 1 for NUL
- sa.raw.Family = AF_UNIX
- for i := 0; i < n; i++ {
- sa.raw.Path[i] = int8(name[i])
- }
- return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
-}
-
-func (sa *SockaddrDatalink) sockaddr() (unsafe.Pointer, _Socklen, error) {
- if sa.Index == 0 {
- return nil, 0, EINVAL
- }
- sa.raw.Len = sa.Len
- sa.raw.Family = AF_LINK
- sa.raw.Index = sa.Index
- sa.raw.Type = sa.Type
- sa.raw.Nlen = sa.Nlen
- sa.raw.Alen = sa.Alen
- sa.raw.Slen = sa.Slen
- for i := 0; i < len(sa.raw.Data); i++ {
- sa.raw.Data[i] = sa.Data[i]
- }
- return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil
-}
-
-func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
- switch rsa.Addr.Family {
- case AF_LINK:
- pp := (*RawSockaddrDatalink)(unsafe.Pointer(rsa))
- sa := new(SockaddrDatalink)
- sa.Len = pp.Len
- sa.Family = pp.Family
- sa.Index = pp.Index
- sa.Type = pp.Type
- sa.Nlen = pp.Nlen
- sa.Alen = pp.Alen
- sa.Slen = pp.Slen
- for i := 0; i < len(sa.Data); i++ {
- sa.Data[i] = pp.Data[i]
- }
- return sa, nil
-
- case AF_UNIX:
- pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
- if pp.Len < 2 || pp.Len > SizeofSockaddrUnix {
- return nil, EINVAL
- }
- sa := new(SockaddrUnix)
-
- // Some BSDs include the trailing NUL in the length, whereas
- // others do not. Work around this by subtracting the leading
- // family and len. The path is then scanned to see if a NUL
- // terminator still exists within the length.
- n := int(pp.Len) - 2 // subtract leading Family, Len
- for i := 0; i < n; i++ {
- if pp.Path[i] == 0 {
- // found early NUL; assume Len included the NUL
- // or was overestimating.
- n = i
- break
- }
- }
- bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
- sa.Name = string(bytes)
- return sa, nil
-
- case AF_INET:
- pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
- sa := new(SockaddrInet4)
- p := (*[2]byte)(unsafe.Pointer(&pp.Port))
- sa.Port = int(p[0])<<8 + int(p[1])
- for i := 0; i < len(sa.Addr); i++ {
- sa.Addr[i] = pp.Addr[i]
- }
- return sa, nil
-
- case AF_INET6:
- pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
- sa := new(SockaddrInet6)
- p := (*[2]byte)(unsafe.Pointer(&pp.Port))
- sa.Port = int(p[0])<<8 + int(p[1])
- sa.ZoneId = pp.Scope_id
- for i := 0; i < len(sa.Addr); i++ {
- sa.Addr[i] = pp.Addr[i]
- }
- return sa, nil
- }
- return nil, EAFNOSUPPORT
-}
-
-func Accept(fd int) (nfd int, sa Sockaddr, err error) {
- var rsa RawSockaddrAny
- var len _Socklen = SizeofSockaddrAny
- nfd, err = accept(fd, &rsa, &len)
- if err != nil {
- return
- }
- if runtime.GOOS == "darwin" && len == 0 {
- // Accepted socket has no address.
- // This is likely due to a bug in xnu kernels,
- // where instead of ECONNABORTED error socket
- // is accepted, but has no address.
- Close(nfd)
- return 0, nil, ECONNABORTED
- }
- sa, err = anyToSockaddr(&rsa)
- if err != nil {
- Close(nfd)
- nfd = 0
- }
- return
-}
-
-func Getsockname(fd int) (sa Sockaddr, err error) {
- var rsa RawSockaddrAny
- var len _Socklen = SizeofSockaddrAny
- if err = getsockname(fd, &rsa, &len); err != nil {
- return
- }
- // TODO(jsing): DragonFly has a "bug" (see issue 3349), which should be
- // reported upstream.
- if runtime.GOOS == "dragonfly" && rsa.Addr.Family == AF_UNSPEC && rsa.Addr.Len == 0 {
- rsa.Addr.Family = AF_UNIX
- rsa.Addr.Len = SizeofSockaddrUnix
- }
- return anyToSockaddr(&rsa)
-}
-
-//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
-
-func GetsockoptByte(fd, level, opt int) (value byte, err error) {
- var n byte
- vallen := _Socklen(1)
- err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen)
- return n, err
-}
-
-func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) {
- vallen := _Socklen(4)
- err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
- return value, err
-}
-
-func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) {
- var value IPMreq
- vallen := _Socklen(SizeofIPMreq)
- err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
- return &value, err
-}
-
-func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
- var value IPv6Mreq
- vallen := _Socklen(SizeofIPv6Mreq)
- err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
- return &value, err
-}
-
-func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
- var value IPv6MTUInfo
- vallen := _Socklen(SizeofIPv6MTUInfo)
- err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
- return &value, err
-}
-
-func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
- var value ICMPv6Filter
- vallen := _Socklen(SizeofICMPv6Filter)
- err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
- return &value, err
-}
-
-//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
-//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
-//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
-
-func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
- var msg Msghdr
- var rsa RawSockaddrAny
- msg.Name = (*byte)(unsafe.Pointer(&rsa))
- msg.Namelen = uint32(SizeofSockaddrAny)
- var iov Iovec
- if len(p) > 0 {
- iov.Base = (*byte)(unsafe.Pointer(&p[0]))
- iov.SetLen(len(p))
- }
- var dummy byte
- if len(oob) > 0 {
- // receive at least one normal byte
- if len(p) == 0 {
- iov.Base = &dummy
- iov.SetLen(1)
- }
- msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
- msg.SetControllen(len(oob))
- }
- msg.Iov = &iov
- msg.Iovlen = 1
- if n, err = recvmsg(fd, &msg, flags); err != nil {
- return
- }
- oobn = int(msg.Controllen)
- recvflags = int(msg.Flags)
- // source address is only specified if the socket is unconnected
- if rsa.Addr.Family != AF_UNSPEC {
- from, err = anyToSockaddr(&rsa)
- }
- return
-}
-
-//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
-
-func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
- _, err = SendmsgN(fd, p, oob, to, flags)
- return
-}
-
-func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
- var ptr unsafe.Pointer
- var salen _Socklen
- if to != nil {
- ptr, salen, err = to.sockaddr()
- if err != nil {
- return 0, err
- }
- }
- var msg Msghdr
- msg.Name = (*byte)(unsafe.Pointer(ptr))
- msg.Namelen = uint32(salen)
- var iov Iovec
- if len(p) > 0 {
- iov.Base = (*byte)(unsafe.Pointer(&p[0]))
- iov.SetLen(len(p))
- }
- var dummy byte
- if len(oob) > 0 {
- // send at least one normal byte
- if len(p) == 0 {
- iov.Base = &dummy
- iov.SetLen(1)
- }
- msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
- msg.SetControllen(len(oob))
- }
- msg.Iov = &iov
- msg.Iovlen = 1
- if n, err = sendmsg(fd, &msg, flags); err != nil {
- return 0, err
- }
- if len(oob) > 0 && len(p) == 0 {
- n = 0
- }
- return n, nil
-}
-
-//sys kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error)
-
-func Kevent(kq int, changes, events []Kevent_t, timeout *Timespec) (n int, err error) {
- var change, event unsafe.Pointer
- if len(changes) > 0 {
- change = unsafe.Pointer(&changes[0])
- }
- if len(events) > 0 {
- event = unsafe.Pointer(&events[0])
- }
- return kevent(kq, change, len(changes), event, len(events), timeout)
-}
-
-//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
-
-// sysctlmib translates name to mib number and appends any additional args.
-func sysctlmib(name string, args ...int) ([]_C_int, error) {
- // Translate name to mib number.
- mib, err := nametomib(name)
- if err != nil {
- return nil, err
- }
-
- for _, a := range args {
- mib = append(mib, _C_int(a))
- }
-
- return mib, nil
-}
-
-func Sysctl(name string) (string, error) {
- return SysctlArgs(name)
-}
-
-func SysctlArgs(name string, args ...int) (string, error) {
- mib, err := sysctlmib(name, args...)
- if err != nil {
- return "", err
- }
-
- // Find size.
- n := uintptr(0)
- if err := sysctl(mib, nil, &n, nil, 0); err != nil {
- return "", err
- }
- if n == 0 {
- return "", nil
- }
-
- // Read into buffer of that size.
- buf := make([]byte, n)
- if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
- return "", err
- }
-
- // Throw away terminating NUL.
- if n > 0 && buf[n-1] == '\x00' {
- n--
- }
- return string(buf[0:n]), nil
-}
-
-func SysctlUint32(name string) (uint32, error) {
- return SysctlUint32Args(name)
-}
-
-func SysctlUint32Args(name string, args ...int) (uint32, error) {
- mib, err := sysctlmib(name, args...)
- if err != nil {
- return 0, err
- }
-
- n := uintptr(4)
- buf := make([]byte, 4)
- if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
- return 0, err
- }
- if n != 4 {
- return 0, EIO
- }
- return *(*uint32)(unsafe.Pointer(&buf[0])), nil
-}
-
-func SysctlUint64(name string, args ...int) (uint64, error) {
- mib, err := sysctlmib(name, args...)
- if err != nil {
- return 0, err
- }
-
- n := uintptr(8)
- buf := make([]byte, 8)
- if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
- return 0, err
- }
- if n != 8 {
- return 0, EIO
- }
- return *(*uint64)(unsafe.Pointer(&buf[0])), nil
-}
-
-func SysctlRaw(name string, args ...int) ([]byte, error) {
- mib, err := sysctlmib(name, args...)
- if err != nil {
- return nil, err
- }
-
- // Find size.
- n := uintptr(0)
- if err := sysctl(mib, nil, &n, nil, 0); err != nil {
- return nil, err
- }
- if n == 0 {
- return nil, nil
- }
-
- // Read into buffer of that size.
- buf := make([]byte, n)
- if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
- return nil, err
- }
-
- // The actual call may return less than the original reported required
- // size so ensure we deal with that.
- return buf[:n], nil
-}
-
-//sys utimes(path string, timeval *[2]Timeval) (err error)
-
-func Utimes(path string, tv []Timeval) error {
- if tv == nil {
- return utimes(path, nil)
- }
- if len(tv) != 2 {
- return EINVAL
- }
- return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
-}
-
-func UtimesNano(path string, ts []Timespec) error {
- if ts == nil {
- return utimes(path, nil)
- }
- // TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it
- // isn't supported by darwin so this uses utimes instead
- if len(ts) != 2 {
- return EINVAL
- }
- // Not as efficient as it could be because Timespec and
- // Timeval have different types in the different OSes
- tv := [2]Timeval{
- NsecToTimeval(TimespecToNsec(ts[0])),
- NsecToTimeval(TimespecToNsec(ts[1])),
- }
- return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
-}
-
-//sys futimes(fd int, timeval *[2]Timeval) (err error)
-
-func Futimes(fd int, tv []Timeval) error {
- if tv == nil {
- return futimes(fd, nil)
- }
- if len(tv) != 2 {
- return EINVAL
- }
- return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
-}
-
-//sys fcntl(fd int, cmd int, arg int) (val int, err error)
-
-// TODO: wrap
-// Acct(name nil-string) (err error)
-// Gethostuuid(uuid *byte, timeout *Timespec) (err error)
-// Madvise(addr *byte, len int, behav int) (err error)
-// Mprotect(addr *byte, len int, prot int) (err error)
-// Msync(addr *byte, len int, flags int) (err error)
-// Ptrace(req int, pid int, addr uintptr, data int) (ret uintptr, err error)
-
-var mapper = &mmapper{
- active: make(map[*byte][]byte),
- mmap: mmap,
- munmap: munmap,
-}
-
-func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
- return mapper.Mmap(fd, offset, length, prot, flags)
-}
-
-func Munmap(b []byte) (err error) {
- return mapper.Munmap(b)
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/syscall_darwin.go b/newt/vendor/golang.org/x/sys/unix/syscall_darwin.go
deleted file mode 100644
index 3d534d2d..00000000
--- a/newt/vendor/golang.org/x/sys/unix/syscall_darwin.go
+++ /dev/null
@@ -1,511 +0,0 @@
-// Copyright 2009,2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Darwin system calls.
-// This file is compiled as ordinary Go code,
-// but it is also input to mksyscall,
-// which parses the //sys lines and generates system call stubs.
-// Note that sometimes we use a lowercase //sys name and wrap
-// it in our own nicer implementation, either here or in
-// syscall_bsd.go or syscall_unix.go.
-
-package unix
-
-import (
- errorspkg "errors"
- "syscall"
- "unsafe"
-)
-
-const ImplementsGetwd = true
-
-func Getwd() (string, error) {
- buf := make([]byte, 2048)
- attrs, err := getAttrList(".", attrList{CommonAttr: attrCmnFullpath}, buf, 0)
- if err == nil && len(attrs) == 1 && len(attrs[0]) >= 2 {
- wd := string(attrs[0])
- // Sanity check that it's an absolute path and ends
- // in a null byte, which we then strip.
- if wd[0] == '/' && wd[len(wd)-1] == 0 {
- return wd[:len(wd)-1], nil
- }
- }
- // If pkg/os/getwd.go gets ENOTSUP, it will fall back to the
- // slow algorithm.
- return "", ENOTSUP
-}
-
-type SockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [12]int8
- raw RawSockaddrDatalink
-}
-
-// Translate "kern.hostname" to []_C_int{0,1,2,3}.
-func nametomib(name string) (mib []_C_int, err error) {
- const siz = unsafe.Sizeof(mib[0])
-
- // NOTE(rsc): It seems strange to set the buffer to have
- // size CTL_MAXNAME+2 but use only CTL_MAXNAME
- // as the size. I don't know why the +2 is here, but the
- // kernel uses +2 for its own implementation of this function.
- // I am scared that if we don't include the +2 here, the kernel
- // will silently write 2 words farther than we specify
- // and we'll get memory corruption.
- var buf [CTL_MAXNAME + 2]_C_int
- n := uintptr(CTL_MAXNAME) * siz
-
- p := (*byte)(unsafe.Pointer(&buf[0]))
- bytes, err := ByteSliceFromString(name)
- if err != nil {
- return nil, err
- }
-
- // Magic sysctl: "setting" 0.3 to a string name
- // lets you read back the array of integers form.
- if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
- return nil, err
- }
- return buf[0 : n/siz], nil
-}
-
-// ParseDirent parses up to max directory entries in buf,
-// appending the names to names. It returns the number
-// bytes consumed from buf, the number of entries added
-// to names, and the new names slice.
-func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
- origlen := len(buf)
- for max != 0 && len(buf) > 0 {
- dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
- if dirent.Reclen == 0 {
- buf = nil
- break
- }
- buf = buf[dirent.Reclen:]
- if dirent.Ino == 0 { // File absent in directory.
- continue
- }
- bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
- var name = string(bytes[0:dirent.Namlen])
- if name == "." || name == ".." { // Useless names
- continue
- }
- max--
- count++
- names = append(names, name)
- }
- return origlen - len(buf), count, names
-}
-
-//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
-func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
-func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
-
-const (
- attrBitMapCount = 5
- attrCmnFullpath = 0x08000000
-)
-
-type attrList struct {
- bitmapCount uint16
- _ uint16
- CommonAttr uint32
- VolAttr uint32
- DirAttr uint32
- FileAttr uint32
- Forkattr uint32
-}
-
-func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (attrs [][]byte, err error) {
- if len(attrBuf) < 4 {
- return nil, errorspkg.New("attrBuf too small")
- }
- attrList.bitmapCount = attrBitMapCount
-
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return nil, err
- }
-
- _, _, e1 := Syscall6(
- SYS_GETATTRLIST,
- uintptr(unsafe.Pointer(_p0)),
- uintptr(unsafe.Pointer(&attrList)),
- uintptr(unsafe.Pointer(&attrBuf[0])),
- uintptr(len(attrBuf)),
- uintptr(options),
- 0,
- )
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- return nil, e1
- }
- size := *(*uint32)(unsafe.Pointer(&attrBuf[0]))
-
- // dat is the section of attrBuf that contains valid data,
- // without the 4 byte length header. All attribute offsets
- // are relative to dat.
- dat := attrBuf
- if int(size) < len(attrBuf) {
- dat = dat[:size]
- }
- dat = dat[4:] // remove length prefix
-
- for i := uint32(0); int(i) < len(dat); {
- header := dat[i:]
- if len(header) < 8 {
- return attrs, errorspkg.New("truncated attribute header")
- }
- datOff := *(*int32)(unsafe.Pointer(&header[0]))
- attrLen := *(*uint32)(unsafe.Pointer(&header[4]))
- if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) {
- return attrs, errorspkg.New("truncated results; attrBuf too small")
- }
- end := uint32(datOff) + attrLen
- attrs = append(attrs, dat[datOff:end])
- i = end
- if r := i % 4; r != 0 {
- i += (4 - r)
- }
- }
- return
-}
-
-//sysnb pipe() (r int, w int, err error)
-
-func Pipe(p []int) (err error) {
- if len(p) != 2 {
- return EINVAL
- }
- p[0], p[1], err = pipe()
- return
-}
-
-func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
- var _p0 unsafe.Pointer
- var bufsize uintptr
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
- }
- r0, _, e1 := Syscall(SYS_GETFSSTAT64, uintptr(_p0), bufsize, uintptr(flags))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-/*
- * Wrapped
- */
-
-//sys kill(pid int, signum int, posix int) (err error)
-
-func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) }
-
-/*
- * Exposed directly
- */
-//sys Access(path string, mode uint32) (err error)
-//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
-//sys Chdir(path string) (err error)
-//sys Chflags(path string, flags int) (err error)
-//sys Chmod(path string, mode uint32) (err error)
-//sys Chown(path string, uid int, gid int) (err error)
-//sys Chroot(path string) (err error)
-//sys Close(fd int) (err error)
-//sys Dup(fd int) (nfd int, err error)
-//sys Dup2(from int, to int) (err error)
-//sys Exchangedata(path1 string, path2 string, options int) (err error)
-//sys Exit(code int)
-//sys Fchdir(fd int) (err error)
-//sys Fchflags(fd int, flags int) (err error)
-//sys Fchmod(fd int, mode uint32) (err error)
-//sys Fchown(fd int, uid int, gid int) (err error)
-//sys Flock(fd int, how int) (err error)
-//sys Fpathconf(fd int, name int) (val int, err error)
-//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
-//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
-//sys Fsync(fd int) (err error)
-//sys Ftruncate(fd int, length int64) (err error)
-//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64
-//sys Getdtablesize() (size int)
-//sysnb Getegid() (egid int)
-//sysnb Geteuid() (uid int)
-//sysnb Getgid() (gid int)
-//sysnb Getpgid(pid int) (pgid int, err error)
-//sysnb Getpgrp() (pgrp int)
-//sysnb Getpid() (pid int)
-//sysnb Getppid() (ppid int)
-//sys Getpriority(which int, who int) (prio int, err error)
-//sysnb Getrlimit(which int, lim *Rlimit) (err error)
-//sysnb Getrusage(who int, rusage *Rusage) (err error)
-//sysnb Getsid(pid int) (sid int, err error)
-//sysnb Getuid() (uid int)
-//sysnb Issetugid() (tainted bool)
-//sys Kqueue() (fd int, err error)
-//sys Lchown(path string, uid int, gid int) (err error)
-//sys Link(path string, link string) (err error)
-//sys Listen(s int, backlog int) (err error)
-//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
-//sys Mkdir(path string, mode uint32) (err error)
-//sys Mkfifo(path string, mode uint32) (err error)
-//sys Mknod(path string, mode uint32, dev int) (err error)
-//sys Mlock(b []byte) (err error)
-//sys Mlockall(flags int) (err error)
-//sys Mprotect(b []byte, prot int) (err error)
-//sys Munlock(b []byte) (err error)
-//sys Munlockall() (err error)
-//sys Open(path string, mode int, perm uint32) (fd int, err error)
-//sys Pathconf(path string, name int) (val int, err error)
-//sys Pread(fd int, p []byte, offset int64) (n int, err error)
-//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
-//sys read(fd int, p []byte) (n int, err error)
-//sys Readlink(path string, buf []byte) (n int, err error)
-//sys Rename(from string, to string) (err error)
-//sys Revoke(path string) (err error)
-//sys Rmdir(path string) (err error)
-//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
-//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
-//sys Setegid(egid int) (err error)
-//sysnb Seteuid(euid int) (err error)
-//sysnb Setgid(gid int) (err error)
-//sys Setlogin(name string) (err error)
-//sysnb Setpgid(pid int, pgid int) (err error)
-//sys Setpriority(which int, who int, prio int) (err error)
-//sys Setprivexec(flag int) (err error)
-//sysnb Setregid(rgid int, egid int) (err error)
-//sysnb Setreuid(ruid int, euid int) (err error)
-//sysnb Setrlimit(which int, lim *Rlimit) (err error)
-//sysnb Setsid() (pid int, err error)
-//sysnb Settimeofday(tp *Timeval) (err error)
-//sysnb Setuid(uid int) (err error)
-//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
-//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
-//sys Symlink(path string, link string) (err error)
-//sys Sync() (err error)
-//sys Truncate(path string, length int64) (err error)
-//sys Umask(newmask int) (oldmask int)
-//sys Undelete(path string) (err error)
-//sys Unlink(path string) (err error)
-//sys Unmount(path string, flags int) (err error)
-//sys write(fd int, p []byte) (n int, err error)
-//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
-//sys munmap(addr uintptr, length uintptr) (err error)
-//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
-//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
-
-/*
- * Unimplemented
- */
-// Profil
-// Sigaction
-// Sigprocmask
-// Getlogin
-// Sigpending
-// Sigaltstack
-// Ioctl
-// Reboot
-// Execve
-// Vfork
-// Sbrk
-// Sstk
-// Ovadvise
-// Mincore
-// Setitimer
-// Swapon
-// Select
-// Sigsuspend
-// Readv
-// Writev
-// Nfssvc
-// Getfh
-// Quotactl
-// Mount
-// Csops
-// Waitid
-// Add_profil
-// Kdebug_trace
-// Sigreturn
-// Mmap
-// Mlock
-// Munlock
-// Atsocket
-// Kqueue_from_portset_np
-// Kqueue_portset
-// Getattrlist
-// Setattrlist
-// Getdirentriesattr
-// Searchfs
-// Delete
-// Copyfile
-// Poll
-// Watchevent
-// Waitevent
-// Modwatch
-// Getxattr
-// Fgetxattr
-// Setxattr
-// Fsetxattr
-// Removexattr
-// Fremovexattr
-// Listxattr
-// Flistxattr
-// Fsctl
-// Initgroups
-// Posix_spawn
-// Nfsclnt
-// Fhopen
-// Minherit
-// Semsys
-// Msgsys
-// Shmsys
-// Semctl
-// Semget
-// Semop
-// Msgctl
-// Msgget
-// Msgsnd
-// Msgrcv
-// Shmat
-// Shmctl
-// Shmdt
-// Shmget
-// Shm_open
-// Shm_unlink
-// Sem_open
-// Sem_close
-// Sem_unlink
-// Sem_wait
-// Sem_trywait
-// Sem_post
-// Sem_getvalue
-// Sem_init
-// Sem_destroy
-// Open_extended
-// Umask_extended
-// Stat_extended
-// Lstat_extended
-// Fstat_extended
-// Chmod_extended
-// Fchmod_extended
-// Access_extended
-// Settid
-// Gettid
-// Setsgroups
-// Getsgroups
-// Setwgroups
-// Getwgroups
-// Mkfifo_extended
-// Mkdir_extended
-// Identitysvc
-// Shared_region_check_np
-// Shared_region_map_np
-// __pthread_mutex_destroy
-// __pthread_mutex_init
-// __pthread_mutex_lock
-// __pthread_mutex_trylock
-// __pthread_mutex_unlock
-// __pthread_cond_init
-// __pthread_cond_destroy
-// __pthread_cond_broadcast
-// __pthread_cond_signal
-// Setsid_with_pid
-// __pthread_cond_timedwait
-// Aio_fsync
-// Aio_return
-// Aio_suspend
-// Aio_cancel
-// Aio_error
-// Aio_read
-// Aio_write
-// Lio_listio
-// __pthread_cond_wait
-// Iopolicysys
-// Mlockall
-// Munlockall
-// __pthread_kill
-// __pthread_sigmask
-// __sigwait
-// __disable_threadsignal
-// __pthread_markcancel
-// __pthread_canceled
-// __semwait_signal
-// Proc_info
-// sendfile
-// Stat64_extended
-// Lstat64_extended
-// Fstat64_extended
-// __pthread_chdir
-// __pthread_fchdir
-// Audit
-// Auditon
-// Getauid
-// Setauid
-// Getaudit
-// Setaudit
-// Getaudit_addr
-// Setaudit_addr
-// Auditctl
-// Bsdthread_create
-// Bsdthread_terminate
-// Stack_snapshot
-// Bsdthread_register
-// Workq_open
-// Workq_ops
-// __mac_execve
-// __mac_syscall
-// __mac_get_file
-// __mac_set_file
-// __mac_get_link
-// __mac_set_link
-// __mac_get_proc
-// __mac_set_proc
-// __mac_get_fd
-// __mac_set_fd
-// __mac_get_pid
-// __mac_get_lcid
-// __mac_get_lctx
-// __mac_set_lctx
-// Setlcid
-// Read_nocancel
-// Write_nocancel
-// Open_nocancel
-// Close_nocancel
-// Wait4_nocancel
-// Recvmsg_nocancel
-// Sendmsg_nocancel
-// Recvfrom_nocancel
-// Accept_nocancel
-// Msync_nocancel
-// Fcntl_nocancel
-// Select_nocancel
-// Fsync_nocancel
-// Connect_nocancel
-// Sigsuspend_nocancel
-// Readv_nocancel
-// Writev_nocancel
-// Sendto_nocancel
-// Pread_nocancel
-// Pwrite_nocancel
-// Waitid_nocancel
-// Poll_nocancel
-// Msgsnd_nocancel
-// Msgrcv_nocancel
-// Sem_wait_nocancel
-// Aio_suspend_nocancel
-// __sigwait_nocancel
-// __semwait_signal_nocancel
-// __mac_mount
-// __mac_get_mount
-// __mac_getfsstat
diff --git a/newt/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go b/newt/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
deleted file mode 100644
index fc1e5a4a..00000000
--- a/newt/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build amd64,darwin
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
-
-func Getpagesize() int { return 4096 }
-
-func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
-
-func NsecToTimespec(nsec int64) (ts Timespec) {
- ts.Sec = nsec / 1e9
- ts.Nsec = nsec % 1e9
- return
-}
-
-func NsecToTimeval(nsec int64) (tv Timeval) {
- nsec += 999 // round up to microsecond
- tv.Usec = int32(nsec % 1e9 / 1e3)
- tv.Sec = int64(nsec / 1e9)
- return
-}
-
-//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
-func Gettimeofday(tv *Timeval) (err error) {
- // The tv passed to gettimeofday must be non-nil
- // but is otherwise unused. The answers come back
- // in the two registers.
- sec, usec, err := gettimeofday(tv)
- tv.Sec = sec
- tv.Usec = usec
- return err
-}
-
-func SetKevent(k *Kevent_t, fd, mode, flags int) {
- k.Ident = uint64(fd)
- k.Filter = int16(mode)
- k.Flags = uint16(flags)
-}
-
-func (iov *Iovec) SetLen(length int) {
- iov.Len = uint64(length)
-}
-
-func (msghdr *Msghdr) SetControllen(length int) {
- msghdr.Controllen = uint32(length)
-}
-
-func (cmsg *Cmsghdr) SetLen(length int) {
- cmsg.Len = uint32(length)
-}
-
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- var length = uint64(count)
-
- _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
-
- written = int(length)
-
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
-
-// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
-// of darwin/amd64 the syscall is called sysctl instead of __sysctl.
-const SYS___SYSCTL = SYS_SYSCTL
diff --git a/newt/vendor/golang.org/x/sys/unix/syscall_dragonfly.go b/newt/vendor/golang.org/x/sys/unix/syscall_dragonfly.go
deleted file mode 100644
index ec408ee7..00000000
--- a/newt/vendor/golang.org/x/sys/unix/syscall_dragonfly.go
+++ /dev/null
@@ -1,412 +0,0 @@
-// Copyright 2009,2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// FreeBSD system calls.
-// This file is compiled as ordinary Go code,
-// but it is also input to mksyscall,
-// which parses the //sys lines and generates system call stubs.
-// Note that sometimes we use a lowercase //sys name and wrap
-// it in our own nicer implementation, either here or in
-// syscall_bsd.go or syscall_unix.go.
-
-package unix
-
-import "unsafe"
-
-type SockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [12]int8
- Rcf uint16
- Route [16]uint16
- raw RawSockaddrDatalink
-}
-
-// Translate "kern.hostname" to []_C_int{0,1,2,3}.
-func nametomib(name string) (mib []_C_int, err error) {
- const siz = unsafe.Sizeof(mib[0])
-
- // NOTE(rsc): It seems strange to set the buffer to have
- // size CTL_MAXNAME+2 but use only CTL_MAXNAME
- // as the size. I don't know why the +2 is here, but the
- // kernel uses +2 for its own implementation of this function.
- // I am scared that if we don't include the +2 here, the kernel
- // will silently write 2 words farther than we specify
- // and we'll get memory corruption.
- var buf [CTL_MAXNAME + 2]_C_int
- n := uintptr(CTL_MAXNAME) * siz
-
- p := (*byte)(unsafe.Pointer(&buf[0]))
- bytes, err := ByteSliceFromString(name)
- if err != nil {
- return nil, err
- }
-
- // Magic sysctl: "setting" 0.3 to a string name
- // lets you read back the array of integers form.
- if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
- return nil, err
- }
- return buf[0 : n/siz], nil
-}
-
-// ParseDirent parses up to max directory entries in buf,
-// appending the names to names. It returns the number
-// bytes consumed from buf, the number of entries added
-// to names, and the new names slice.
-func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
- origlen := len(buf)
- for max != 0 && len(buf) > 0 {
- dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
- reclen := int(16+dirent.Namlen+1+7) & ^7
- buf = buf[reclen:]
- if dirent.Fileno == 0 { // File absent in directory.
- continue
- }
- bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
- var name = string(bytes[0:dirent.Namlen])
- if name == "." || name == ".." { // Useless names
- continue
- }
- max--
- count++
- names = append(names, name)
- }
- return origlen - len(buf), count, names
-}
-
-//sysnb pipe() (r int, w int, err error)
-
-func Pipe(p []int) (err error) {
- if len(p) != 2 {
- return EINVAL
- }
- p[0], p[1], err = pipe()
- return
-}
-
-//sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error)
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- return extpread(fd, p, 0, offset)
-}
-
-//sys extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error)
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- return extpwrite(fd, p, 0, offset)
-}
-
-func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
- var _p0 unsafe.Pointer
- var bufsize uintptr
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
- }
- r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-/*
- * Exposed directly
- */
-//sys Access(path string, mode uint32) (err error)
-//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
-//sys Chdir(path string) (err error)
-//sys Chflags(path string, flags int) (err error)
-//sys Chmod(path string, mode uint32) (err error)
-//sys Chown(path string, uid int, gid int) (err error)
-//sys Chroot(path string) (err error)
-//sys Close(fd int) (err error)
-//sys Dup(fd int) (nfd int, err error)
-//sys Dup2(from int, to int) (err error)
-//sys Exit(code int)
-//sys Fchdir(fd int) (err error)
-//sys Fchflags(fd int, flags int) (err error)
-//sys Fchmod(fd int, mode uint32) (err error)
-//sys Fchown(fd int, uid int, gid int) (err error)
-//sys Flock(fd int, how int) (err error)
-//sys Fpathconf(fd int, name int) (val int, err error)
-//sys Fstat(fd int, stat *Stat_t) (err error)
-//sys Fstatfs(fd int, stat *Statfs_t) (err error)
-//sys Fsync(fd int) (err error)
-//sys Ftruncate(fd int, length int64) (err error)
-//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error)
-//sys Getdtablesize() (size int)
-//sysnb Getegid() (egid int)
-//sysnb Geteuid() (uid int)
-//sysnb Getgid() (gid int)
-//sysnb Getpgid(pid int) (pgid int, err error)
-//sysnb Getpgrp() (pgrp int)
-//sysnb Getpid() (pid int)
-//sysnb Getppid() (ppid int)
-//sys Getpriority(which int, who int) (prio int, err error)
-//sysnb Getrlimit(which int, lim *Rlimit) (err error)
-//sysnb Getrusage(who int, rusage *Rusage) (err error)
-//sysnb Getsid(pid int) (sid int, err error)
-//sysnb Gettimeofday(tv *Timeval) (err error)
-//sysnb Getuid() (uid int)
-//sys Issetugid() (tainted bool)
-//sys Kill(pid int, signum syscall.Signal) (err error)
-//sys Kqueue() (fd int, err error)
-//sys Lchown(path string, uid int, gid int) (err error)
-//sys Link(path string, link string) (err error)
-//sys Listen(s int, backlog int) (err error)
-//sys Lstat(path string, stat *Stat_t) (err error)
-//sys Mkdir(path string, mode uint32) (err error)
-//sys Mkfifo(path string, mode uint32) (err error)
-//sys Mknod(path string, mode uint32, dev int) (err error)
-//sys Mlock(b []byte) (err error)
-//sys Mlockall(flags int) (err error)
-//sys Mprotect(b []byte, prot int) (err error)
-//sys Munlock(b []byte) (err error)
-//sys Munlockall() (err error)
-//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
-//sys Open(path string, mode int, perm uint32) (fd int, err error)
-//sys Pathconf(path string, name int) (val int, err error)
-//sys read(fd int, p []byte) (n int, err error)
-//sys Readlink(path string, buf []byte) (n int, err error)
-//sys Rename(from string, to string) (err error)
-//sys Revoke(path string) (err error)
-//sys Rmdir(path string) (err error)
-//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
-//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
-//sysnb Setegid(egid int) (err error)
-//sysnb Seteuid(euid int) (err error)
-//sysnb Setgid(gid int) (err error)
-//sys Setlogin(name string) (err error)
-//sysnb Setpgid(pid int, pgid int) (err error)
-//sys Setpriority(which int, who int, prio int) (err error)
-//sysnb Setregid(rgid int, egid int) (err error)
-//sysnb Setreuid(ruid int, euid int) (err error)
-//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
-//sysnb Setresuid(ruid int, euid int, suid int) (err error)
-//sysnb Setrlimit(which int, lim *Rlimit) (err error)
-//sysnb Setsid() (pid int, err error)
-//sysnb Settimeofday(tp *Timeval) (err error)
-//sysnb Setuid(uid int) (err error)
-//sys Stat(path string, stat *Stat_t) (err error)
-//sys Statfs(path string, stat *Statfs_t) (err error)
-//sys Symlink(path string, link string) (err error)
-//sys Sync() (err error)
-//sys Truncate(path string, length int64) (err error)
-//sys Umask(newmask int) (oldmask int)
-//sys Undelete(path string) (err error)
-//sys Unlink(path string) (err error)
-//sys Unmount(path string, flags int) (err error)
-//sys write(fd int, p []byte) (n int, err error)
-//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
-//sys munmap(addr uintptr, length uintptr) (err error)
-//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
-//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
-
-/*
- * Unimplemented
- * TODO(jsing): Update this list for DragonFly.
- */
-// Profil
-// Sigaction
-// Sigprocmask
-// Getlogin
-// Sigpending
-// Sigaltstack
-// Ioctl
-// Reboot
-// Execve
-// Vfork
-// Sbrk
-// Sstk
-// Ovadvise
-// Mincore
-// Setitimer
-// Swapon
-// Select
-// Sigsuspend
-// Readv
-// Writev
-// Nfssvc
-// Getfh
-// Quotactl
-// Mount
-// Csops
-// Waitid
-// Add_profil
-// Kdebug_trace
-// Sigreturn
-// Mmap
-// Atsocket
-// Kqueue_from_portset_np
-// Kqueue_portset
-// Getattrlist
-// Setattrlist
-// Getdirentriesattr
-// Searchfs
-// Delete
-// Copyfile
-// Poll
-// Watchevent
-// Waitevent
-// Modwatch
-// Getxattr
-// Fgetxattr
-// Setxattr
-// Fsetxattr
-// Removexattr
-// Fremovexattr
-// Listxattr
-// Flistxattr
-// Fsctl
-// Initgroups
-// Posix_spawn
-// Nfsclnt
-// Fhopen
-// Minherit
-// Semsys
-// Msgsys
-// Shmsys
-// Semctl
-// Semget
-// Semop
-// Msgctl
-// Msgget
-// Msgsnd
-// Msgrcv
-// Shmat
-// Shmctl
-// Shmdt
-// Shmget
-// Shm_open
-// Shm_unlink
-// Sem_open
-// Sem_close
-// Sem_unlink
-// Sem_wait
-// Sem_trywait
-// Sem_post
-// Sem_getvalue
-// Sem_init
-// Sem_destroy
-// Open_extended
-// Umask_extended
-// Stat_extended
-// Lstat_extended
-// Fstat_extended
-// Chmod_extended
-// Fchmod_extended
-// Access_extended
-// Settid
-// Gettid
-// Setsgroups
-// Getsgroups
-// Setwgroups
-// Getwgroups
-// Mkfifo_extended
-// Mkdir_extended
-// Identitysvc
-// Shared_region_check_np
-// Shared_region_map_np
-// __pthread_mutex_destroy
-// __pthread_mutex_init
-// __pthread_mutex_lock
-// __pthread_mutex_trylock
-// __pthread_mutex_unlock
-// __pthread_cond_init
-// __pthread_cond_destroy
-// __pthread_cond_broadcast
-// __pthread_cond_signal
-// Setsid_with_pid
-// __pthread_cond_timedwait
-// Aio_fsync
-// Aio_return
-// Aio_suspend
-// Aio_cancel
-// Aio_error
-// Aio_read
-// Aio_write
-// Lio_listio
-// __pthread_cond_wait
-// Iopolicysys
-// __pthread_kill
-// __pthread_sigmask
-// __sigwait
-// __disable_threadsignal
-// __pthread_markcancel
-// __pthread_canceled
-// __semwait_signal
-// Proc_info
-// Stat64_extended
-// Lstat64_extended
-// Fstat64_extended
-// __pthread_chdir
-// __pthread_fchdir
-// Audit
-// Auditon
-// Getauid
-// Setauid
-// Getaudit
-// Setaudit
-// Getaudit_addr
-// Setaudit_addr
-// Auditctl
-// Bsdthread_create
-// Bsdthread_terminate
-// Stack_snapshot
-// Bsdthread_register
-// Workq_open
-// Workq_ops
-// __mac_execve
-// __mac_syscall
-// __mac_get_file
-// __mac_set_file
-// __mac_get_link
-// __mac_set_link
-// __mac_get_proc
-// __mac_set_proc
-// __mac_get_fd
-// __mac_set_fd
-// __mac_get_pid
-// __mac_get_lcid
-// __mac_get_lctx
-// __mac_set_lctx
-// Setlcid
-// Read_nocancel
-// Write_nocancel
-// Open_nocancel
-// Close_nocancel
-// Wait4_nocancel
-// Recvmsg_nocancel
-// Sendmsg_nocancel
-// Recvfrom_nocancel
-// Accept_nocancel
-// Msync_nocancel
-// Fcntl_nocancel
-// Select_nocancel
-// Fsync_nocancel
-// Connect_nocancel
-// Sigsuspend_nocancel
-// Readv_nocancel
-// Writev_nocancel
-// Sendto_nocancel
-// Pread_nocancel
-// Pwrite_nocancel
-// Waitid_nocancel
-// Poll_nocancel
-// Msgsnd_nocancel
-// Msgrcv_nocancel
-// Sem_wait_nocancel
-// Aio_suspend_nocancel
-// __sigwait_nocancel
-// __semwait_signal_nocancel
-// __mac_mount
-// __mac_get_mount
-// __mac_getfsstat
diff --git a/newt/vendor/golang.org/x/sys/unix/syscall_freebsd.go b/newt/vendor/golang.org/x/sys/unix/syscall_freebsd.go
deleted file mode 100644
index 520ccbea..00000000
--- a/newt/vendor/golang.org/x/sys/unix/syscall_freebsd.go
+++ /dev/null
@@ -1,683 +0,0 @@
-// Copyright 2009,2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// FreeBSD system calls.
-// This file is compiled as ordinary Go code,
-// but it is also input to mksyscall,
-// which parses the //sys lines and generates system call stubs.
-// Note that sometimes we use a lowercase //sys name and wrap
-// it in our own nicer implementation, either here or in
-// syscall_bsd.go or syscall_unix.go.
-
-package unix
-
-import "unsafe"
-
-type SockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [46]int8
- raw RawSockaddrDatalink
-}
-
-// Translate "kern.hostname" to []_C_int{0,1,2,3}.
-func nametomib(name string) (mib []_C_int, err error) {
- const siz = unsafe.Sizeof(mib[0])
-
- // NOTE(rsc): It seems strange to set the buffer to have
- // size CTL_MAXNAME+2 but use only CTL_MAXNAME
- // as the size. I don't know why the +2 is here, but the
- // kernel uses +2 for its own implementation of this function.
- // I am scared that if we don't include the +2 here, the kernel
- // will silently write 2 words farther than we specify
- // and we'll get memory corruption.
- var buf [CTL_MAXNAME + 2]_C_int
- n := uintptr(CTL_MAXNAME) * siz
-
- p := (*byte)(unsafe.Pointer(&buf[0]))
- bytes, err := ByteSliceFromString(name)
- if err != nil {
- return nil, err
- }
-
- // Magic sysctl: "setting" 0.3 to a string name
- // lets you read back the array of integers form.
- if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
- return nil, err
- }
- return buf[0 : n/siz], nil
-}
-
-// ParseDirent parses up to max directory entries in buf,
-// appending the names to names. It returns the number
-// bytes consumed from buf, the number of entries added
-// to names, and the new names slice.
-func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
- origlen := len(buf)
- for max != 0 && len(buf) > 0 {
- dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
- if dirent.Reclen == 0 {
- buf = nil
- break
- }
- buf = buf[dirent.Reclen:]
- if dirent.Fileno == 0 { // File absent in directory.
- continue
- }
- bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
- var name = string(bytes[0:dirent.Namlen])
- if name == "." || name == ".." { // Useless names
- continue
- }
- max--
- count++
- names = append(names, name)
- }
- return origlen - len(buf), count, names
-}
-
-//sysnb pipe() (r int, w int, err error)
-
-func Pipe(p []int) (err error) {
- if len(p) != 2 {
- return EINVAL
- }
- p[0], p[1], err = pipe()
- return
-}
-
-func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
- var value IPMreqn
- vallen := _Socklen(SizeofIPMreqn)
- errno := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
- return &value, errno
-}
-
-func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
- return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
-}
-
-func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) {
- var rsa RawSockaddrAny
- var len _Socklen = SizeofSockaddrAny
- nfd, err = accept4(fd, &rsa, &len, flags)
- if err != nil {
- return
- }
- if len > SizeofSockaddrAny {
- panic("RawSockaddrAny too small")
- }
- sa, err = anyToSockaddr(&rsa)
- if err != nil {
- Close(nfd)
- nfd = 0
- }
- return
-}
-
-func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
- var _p0 unsafe.Pointer
- var bufsize uintptr
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
- }
- r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-// Derive extattr namespace and attribute name
-
-func xattrnamespace(fullattr string) (ns int, attr string, err error) {
- s := -1
- for idx, val := range fullattr {
- if val == '.' {
- s = idx
- break
- }
- }
-
- if s == -1 {
- return -1, "", ENOATTR
- }
-
- namespace := fullattr[0:s]
- attr = fullattr[s+1:]
-
- switch namespace {
- case "user":
- return EXTATTR_NAMESPACE_USER, attr, nil
- case "system":
- return EXTATTR_NAMESPACE_SYSTEM, attr, nil
- default:
- return -1, "", ENOATTR
- }
-}
-
-func initxattrdest(dest []byte, idx int) (d unsafe.Pointer) {
- if len(dest) > idx {
- return unsafe.Pointer(&dest[idx])
- } else {
- return unsafe.Pointer(_zero)
- }
-}
-
-// FreeBSD implements its own syscalls to handle extended attributes
-
-func Getxattr(file string, attr string, dest []byte) (sz int, err error) {
- d := initxattrdest(dest, 0)
- destsize := len(dest)
-
- nsid, a, err := xattrnamespace(attr)
- if err != nil {
- return -1, err
- }
-
- return ExtattrGetFile(file, nsid, a, uintptr(d), destsize)
-}
-
-func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) {
- d := initxattrdest(dest, 0)
- destsize := len(dest)
-
- nsid, a, err := xattrnamespace(attr)
- if err != nil {
- return -1, err
- }
-
- return ExtattrGetFd(fd, nsid, a, uintptr(d), destsize)
-}
-
-func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) {
- d := initxattrdest(dest, 0)
- destsize := len(dest)
-
- nsid, a, err := xattrnamespace(attr)
- if err != nil {
- return -1, err
- }
-
- return ExtattrGetLink(link, nsid, a, uintptr(d), destsize)
-}
-
-// flags are unused on FreeBSD
-
-func Fsetxattr(fd int, attr string, data []byte, flags int) (err error) {
- d := unsafe.Pointer(&data[0])
- datasiz := len(data)
-
- nsid, a, err := xattrnamespace(attr)
- if err != nil {
- return
- }
-
- _, err = ExtattrSetFd(fd, nsid, a, uintptr(d), datasiz)
- return
-}
-
-func Setxattr(file string, attr string, data []byte, flags int) (err error) {
- d := unsafe.Pointer(&data[0])
- datasiz := len(data)
-
- nsid, a, err := xattrnamespace(attr)
- if err != nil {
- return
- }
-
- _, err = ExtattrSetFile(file, nsid, a, uintptr(d), datasiz)
- return
-}
-
-func Lsetxattr(link string, attr string, data []byte, flags int) (err error) {
- d := unsafe.Pointer(&data[0])
- datasiz := len(data)
-
- nsid, a, err := xattrnamespace(attr)
- if err != nil {
- return
- }
-
- _, err = ExtattrSetLink(link, nsid, a, uintptr(d), datasiz)
- return
-}
-
-func Removexattr(file string, attr string) (err error) {
- nsid, a, err := xattrnamespace(attr)
- if err != nil {
- return
- }
-
- err = ExtattrDeleteFile(file, nsid, a)
- return
-}
-
-func Fremovexattr(fd int, attr string) (err error) {
- nsid, a, err := xattrnamespace(attr)
- if err != nil {
- return
- }
-
- err = ExtattrDeleteFd(fd, nsid, a)
- return
-}
-
-func Lremovexattr(link string, attr string) (err error) {
- nsid, a, err := xattrnamespace(attr)
- if err != nil {
- return
- }
-
- err = ExtattrDeleteLink(link, nsid, a)
- return
-}
-
-func Listxattr(file string, dest []byte) (sz int, err error) {
- d := initxattrdest(dest, 0)
- destsiz := len(dest)
-
- // FreeBSD won't allow you to list xattrs from multiple namespaces
- s := 0
- var e error
- for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
- stmp, e := ExtattrListFile(file, nsid, uintptr(d), destsiz)
-
- /* Errors accessing system attrs are ignored so that
- * we can implement the Linux-like behavior of omitting errors that
- * we don't have read permissions on
- *
- * Linux will still error if we ask for user attributes on a file that
- * we don't have read permissions on, so don't ignore those errors
- */
- if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
- e = nil
- continue
- } else if e != nil {
- return s, e
- }
-
- s += stmp
- destsiz -= s
- if destsiz < 0 {
- destsiz = 0
- }
- d = initxattrdest(dest, s)
- }
-
- return s, e
-}
-
-func Flistxattr(fd int, dest []byte) (sz int, err error) {
- d := initxattrdest(dest, 0)
- destsiz := len(dest)
-
- s := 0
- var e error
- for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
- stmp, e := ExtattrListFd(fd, nsid, uintptr(d), destsiz)
- if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
- e = nil
- continue
- } else if e != nil {
- return s, e
- }
-
- s += stmp
- destsiz -= s
- if destsiz < 0 {
- destsiz = 0
- }
- d = initxattrdest(dest, s)
- }
-
- return s, e
-}
-
-func Llistxattr(link string, dest []byte) (sz int, err error) {
- d := initxattrdest(dest, 0)
- destsiz := len(dest)
-
- s := 0
- var e error
- for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} {
- stmp, e := ExtattrListLink(link, nsid, uintptr(d), destsiz)
- if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER {
- e = nil
- continue
- } else if e != nil {
- return s, e
- }
-
- s += stmp
- destsiz -= s
- if destsiz < 0 {
- destsiz = 0
- }
- d = initxattrdest(dest, s)
- }
-
- return s, e
-}
-
-/*
- * Exposed directly
- */
-//sys Access(path string, mode uint32) (err error)
-//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
-//sys Chdir(path string) (err error)
-//sys Chflags(path string, flags int) (err error)
-//sys Chmod(path string, mode uint32) (err error)
-//sys Chown(path string, uid int, gid int) (err error)
-//sys Chroot(path string) (err error)
-//sys Close(fd int) (err error)
-//sys Dup(fd int) (nfd int, err error)
-//sys Dup2(from int, to int) (err error)
-//sys Exit(code int)
-//sys ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
-//sys ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
-//sys ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error)
-//sys ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
-//sys ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
-//sys ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
-//sys ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error)
-//sys ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
-//sys ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
-//sys ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
-//sys ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error)
-//sys ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
-//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_POSIX_FADVISE
-//sys Fchdir(fd int) (err error)
-//sys Fchflags(fd int, flags int) (err error)
-//sys Fchmod(fd int, mode uint32) (err error)
-//sys Fchown(fd int, uid int, gid int) (err error)
-//sys Flock(fd int, how int) (err error)
-//sys Fpathconf(fd int, name int) (val int, err error)
-//sys Fstat(fd int, stat *Stat_t) (err error)
-//sys Fstatfs(fd int, stat *Statfs_t) (err error)
-//sys Fsync(fd int) (err error)
-//sys Ftruncate(fd int, length int64) (err error)
-//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error)
-//sys Getdtablesize() (size int)
-//sysnb Getegid() (egid int)
-//sysnb Geteuid() (uid int)
-//sysnb Getgid() (gid int)
-//sysnb Getpgid(pid int) (pgid int, err error)
-//sysnb Getpgrp() (pgrp int)
-//sysnb Getpid() (pid int)
-//sysnb Getppid() (ppid int)
-//sys Getpriority(which int, who int) (prio int, err error)
-//sysnb Getrlimit(which int, lim *Rlimit) (err error)
-//sysnb Getrusage(who int, rusage *Rusage) (err error)
-//sysnb Getsid(pid int) (sid int, err error)
-//sysnb Gettimeofday(tv *Timeval) (err error)
-//sysnb Getuid() (uid int)
-//sys Issetugid() (tainted bool)
-//sys Kill(pid int, signum syscall.Signal) (err error)
-//sys Kqueue() (fd int, err error)
-//sys Lchown(path string, uid int, gid int) (err error)
-//sys Link(path string, link string) (err error)
-//sys Listen(s int, backlog int) (err error)
-//sys Lstat(path string, stat *Stat_t) (err error)
-//sys Mkdir(path string, mode uint32) (err error)
-//sys Mkfifo(path string, mode uint32) (err error)
-//sys Mknod(path string, mode uint32, dev int) (err error)
-//sys Mlock(b []byte) (err error)
-//sys Mlockall(flags int) (err error)
-//sys Mprotect(b []byte, prot int) (err error)
-//sys Munlock(b []byte) (err error)
-//sys Munlockall() (err error)
-//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
-//sys Open(path string, mode int, perm uint32) (fd int, err error)
-//sys Pathconf(path string, name int) (val int, err error)
-//sys Pread(fd int, p []byte, offset int64) (n int, err error)
-//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
-//sys read(fd int, p []byte) (n int, err error)
-//sys Readlink(path string, buf []byte) (n int, err error)
-//sys Rename(from string, to string) (err error)
-//sys Revoke(path string) (err error)
-//sys Rmdir(path string) (err error)
-//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
-//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
-//sysnb Setegid(egid int) (err error)
-//sysnb Seteuid(euid int) (err error)
-//sysnb Setgid(gid int) (err error)
-//sys Setlogin(name string) (err error)
-//sysnb Setpgid(pid int, pgid int) (err error)
-//sys Setpriority(which int, who int, prio int) (err error)
-//sysnb Setregid(rgid int, egid int) (err error)
-//sysnb Setreuid(ruid int, euid int) (err error)
-//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
-//sysnb Setresuid(ruid int, euid int, suid int) (err error)
-//sysnb Setrlimit(which int, lim *Rlimit) (err error)
-//sysnb Setsid() (pid int, err error)
-//sysnb Settimeofday(tp *Timeval) (err error)
-//sysnb Setuid(uid int) (err error)
-//sys Stat(path string, stat *Stat_t) (err error)
-//sys Statfs(path string, stat *Statfs_t) (err error)
-//sys Symlink(path string, link string) (err error)
-//sys Sync() (err error)
-//sys Truncate(path string, length int64) (err error)
-//sys Umask(newmask int) (oldmask int)
-//sys Undelete(path string) (err error)
-//sys Unlink(path string) (err error)
-//sys Unmount(path string, flags int) (err error)
-//sys write(fd int, p []byte) (n int, err error)
-//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
-//sys munmap(addr uintptr, length uintptr) (err error)
-//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
-//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
-//sys accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error)
-
-/*
- * Unimplemented
- */
-// Profil
-// Sigaction
-// Sigprocmask
-// Getlogin
-// Sigpending
-// Sigaltstack
-// Ioctl
-// Reboot
-// Execve
-// Vfork
-// Sbrk
-// Sstk
-// Ovadvise
-// Mincore
-// Setitimer
-// Swapon
-// Select
-// Sigsuspend
-// Readv
-// Writev
-// Nfssvc
-// Getfh
-// Quotactl
-// Mount
-// Csops
-// Waitid
-// Add_profil
-// Kdebug_trace
-// Sigreturn
-// Mmap
-// Mlock
-// Munlock
-// Atsocket
-// Kqueue_from_portset_np
-// Kqueue_portset
-// Getattrlist
-// Setattrlist
-// Getdirentriesattr
-// Searchfs
-// Delete
-// Copyfile
-// Poll
-// Watchevent
-// Waitevent
-// Modwatch
-// Getxattr
-// Fgetxattr
-// Setxattr
-// Fsetxattr
-// Removexattr
-// Fremovexattr
-// Listxattr
-// Flistxattr
-// Fsctl
-// Initgroups
-// Posix_spawn
-// Nfsclnt
-// Fhopen
-// Minherit
-// Semsys
-// Msgsys
-// Shmsys
-// Semctl
-// Semget
-// Semop
-// Msgctl
-// Msgget
-// Msgsnd
-// Msgrcv
-// Shmat
-// Shmctl
-// Shmdt
-// Shmget
-// Shm_open
-// Shm_unlink
-// Sem_open
-// Sem_close
-// Sem_unlink
-// Sem_wait
-// Sem_trywait
-// Sem_post
-// Sem_getvalue
-// Sem_init
-// Sem_destroy
-// Open_extended
-// Umask_extended
-// Stat_extended
-// Lstat_extended
-// Fstat_extended
-// Chmod_extended
-// Fchmod_extended
-// Access_extended
-// Settid
-// Gettid
-// Setsgroups
-// Getsgroups
-// Setwgroups
-// Getwgroups
-// Mkfifo_extended
-// Mkdir_extended
-// Identitysvc
-// Shared_region_check_np
-// Shared_region_map_np
-// __pthread_mutex_destroy
-// __pthread_mutex_init
-// __pthread_mutex_lock
-// __pthread_mutex_trylock
-// __pthread_mutex_unlock
-// __pthread_cond_init
-// __pthread_cond_destroy
-// __pthread_cond_broadcast
-// __pthread_cond_signal
-// Setsid_with_pid
-// __pthread_cond_timedwait
-// Aio_fsync
-// Aio_return
-// Aio_suspend
-// Aio_cancel
-// Aio_error
-// Aio_read
-// Aio_write
-// Lio_listio
-// __pthread_cond_wait
-// Iopolicysys
-// Mlockall
-// Munlockall
-// __pthread_kill
-// __pthread_sigmask
-// __sigwait
-// __disable_threadsignal
-// __pthread_markcancel
-// __pthread_canceled
-// __semwait_signal
-// Proc_info
-// Stat64_extended
-// Lstat64_extended
-// Fstat64_extended
-// __pthread_chdir
-// __pthread_fchdir
-// Audit
-// Auditon
-// Getauid
-// Setauid
-// Getaudit
-// Setaudit
-// Getaudit_addr
-// Setaudit_addr
-// Auditctl
-// Bsdthread_create
-// Bsdthread_terminate
-// Stack_snapshot
-// Bsdthread_register
-// Workq_open
-// Workq_ops
-// __mac_execve
-// __mac_syscall
-// __mac_get_file
-// __mac_set_file
-// __mac_get_link
-// __mac_set_link
-// __mac_get_proc
-// __mac_set_proc
-// __mac_get_fd
-// __mac_set_fd
-// __mac_get_pid
-// __mac_get_lcid
-// __mac_get_lctx
-// __mac_set_lctx
-// Setlcid
-// Read_nocancel
-// Write_nocancel
-// Open_nocancel
-// Close_nocancel
-// Wait4_nocancel
-// Recvmsg_nocancel
-// Sendmsg_nocancel
-// Recvfrom_nocancel
-// Accept_nocancel
-// Msync_nocancel
-// Fcntl_nocancel
-// Select_nocancel
-// Fsync_nocancel
-// Connect_nocancel
-// Sigsuspend_nocancel
-// Readv_nocancel
-// Writev_nocancel
-// Sendto_nocancel
-// Pread_nocancel
-// Pwrite_nocancel
-// Waitid_nocancel
-// Poll_nocancel
-// Msgsnd_nocancel
-// Msgrcv_nocancel
-// Sem_wait_nocancel
-// Aio_suspend_nocancel
-// __sigwait_nocancel
-// __semwait_signal_nocancel
-// __mac_mount
-// __mac_get_mount
-// __mac_getfsstat
diff --git a/newt/vendor/golang.org/x/sys/unix/syscall_linux.go b/newt/vendor/golang.org/x/sys/unix/syscall_linux.go
deleted file mode 100644
index 74eae9b6..00000000
--- a/newt/vendor/golang.org/x/sys/unix/syscall_linux.go
+++ /dev/null
@@ -1,1111 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Linux system calls.
-// This file is compiled as ordinary Go code,
-// but it is also input to mksyscall,
-// which parses the //sys lines and generates system call stubs.
-// Note that sometimes we use a lowercase //sys name and
-// wrap it in our own nicer implementation.
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-/*
- * Wrapped
- */
-
-func Access(path string, mode uint32) (err error) {
- return Faccessat(AT_FDCWD, path, mode, 0)
-}
-
-func Chmod(path string, mode uint32) (err error) {
- return Fchmodat(AT_FDCWD, path, mode, 0)
-}
-
-func Chown(path string, uid int, gid int) (err error) {
- return Fchownat(AT_FDCWD, path, uid, gid, 0)
-}
-
-func Creat(path string, mode uint32) (fd int, err error) {
- return Open(path, O_CREAT|O_WRONLY|O_TRUNC, mode)
-}
-
-//sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error)
-
-func Link(oldpath string, newpath string) (err error) {
- return Linkat(AT_FDCWD, oldpath, AT_FDCWD, newpath, 0)
-}
-
-func Mkdir(path string, mode uint32) (err error) {
- return Mkdirat(AT_FDCWD, path, mode)
-}
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- return Mknodat(AT_FDCWD, path, mode, dev)
-}
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- return openat(AT_FDCWD, path, mode|O_LARGEFILE, perm)
-}
-
-//sys openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
-
-func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
- return openat(dirfd, path, flags|O_LARGEFILE, mode)
-}
-
-//sys ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error)
-
-func Ppoll(fds []PollFd, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
- if len(fds) == 0 {
- return ppoll(nil, 0, timeout, sigmask)
- }
- return ppoll(&fds[0], len(fds), timeout, sigmask)
-}
-
-//sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error)
-
-func Readlink(path string, buf []byte) (n int, err error) {
- return Readlinkat(AT_FDCWD, path, buf)
-}
-
-func Rename(oldpath string, newpath string) (err error) {
- return Renameat(AT_FDCWD, oldpath, AT_FDCWD, newpath)
-}
-
-func Rmdir(path string) error {
- return Unlinkat(AT_FDCWD, path, AT_REMOVEDIR)
-}
-
-//sys Symlinkat(oldpath string, newdirfd int, newpath string) (err error)
-
-func Symlink(oldpath string, newpath string) (err error) {
- return Symlinkat(oldpath, AT_FDCWD, newpath)
-}
-
-func Unlink(path string) error {
- return Unlinkat(AT_FDCWD, path, 0)
-}
-
-//sys Unlinkat(dirfd int, path string, flags int) (err error)
-
-//sys utimes(path string, times *[2]Timeval) (err error)
-
-func Utimes(path string, tv []Timeval) error {
- if tv == nil {
- err := utimensat(AT_FDCWD, path, nil, 0)
- if err != ENOSYS {
- return err
- }
- return utimes(path, nil)
- }
- if len(tv) != 2 {
- return EINVAL
- }
- var ts [2]Timespec
- ts[0] = NsecToTimespec(TimevalToNsec(tv[0]))
- ts[1] = NsecToTimespec(TimevalToNsec(tv[1]))
- err := utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
- if err != ENOSYS {
- return err
- }
- return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
-}
-
-//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error)
-
-func UtimesNano(path string, ts []Timespec) error {
- if ts == nil {
- err := utimensat(AT_FDCWD, path, nil, 0)
- if err != ENOSYS {
- return err
- }
- return utimes(path, nil)
- }
- if len(ts) != 2 {
- return EINVAL
- }
- err := utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
- if err != ENOSYS {
- return err
- }
- // If the utimensat syscall isn't available (utimensat was added to Linux
- // in 2.6.22, Released, 8 July 2007) then fall back to utimes
- var tv [2]Timeval
- for i := 0; i < 2; i++ {
- tv[i] = NsecToTimeval(TimespecToNsec(ts[i]))
- }
- return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
-}
-
-func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error {
- if ts == nil {
- return utimensat(dirfd, path, nil, flags)
- }
- if len(ts) != 2 {
- return EINVAL
- }
- return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags)
-}
-
-//sys futimesat(dirfd int, path *byte, times *[2]Timeval) (err error)
-
-func Futimesat(dirfd int, path string, tv []Timeval) error {
- pathp, err := BytePtrFromString(path)
- if err != nil {
- return err
- }
- if tv == nil {
- return futimesat(dirfd, pathp, nil)
- }
- if len(tv) != 2 {
- return EINVAL
- }
- return futimesat(dirfd, pathp, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
-}
-
-func Futimes(fd int, tv []Timeval) (err error) {
- // Believe it or not, this is the best we can do on Linux
- // (and is what glibc does).
- return Utimes("/proc/self/fd/"+itoa(fd), tv)
-}
-
-const ImplementsGetwd = true
-
-//sys Getcwd(buf []byte) (n int, err error)
-
-func Getwd() (wd string, err error) {
- var buf [PathMax]byte
- n, err := Getcwd(buf[0:])
- if err != nil {
- return "", err
- }
- // Getcwd returns the number of bytes written to buf, including the NUL.
- if n < 1 || n > len(buf) || buf[n-1] != 0 {
- return "", EINVAL
- }
- return string(buf[0 : n-1]), nil
-}
-
-func Getgroups() (gids []int, err error) {
- n, err := getgroups(0, nil)
- if err != nil {
- return nil, err
- }
- if n == 0 {
- return nil, nil
- }
-
- // Sanity check group count. Max is 1<<16 on Linux.
- if n < 0 || n > 1<<20 {
- return nil, EINVAL
- }
-
- a := make([]_Gid_t, n)
- n, err = getgroups(n, &a[0])
- if err != nil {
- return nil, err
- }
- gids = make([]int, n)
- for i, v := range a[0:n] {
- gids[i] = int(v)
- }
- return
-}
-
-func Setgroups(gids []int) (err error) {
- if len(gids) == 0 {
- return setgroups(0, nil)
- }
-
- a := make([]_Gid_t, len(gids))
- for i, v := range gids {
- a[i] = _Gid_t(v)
- }
- return setgroups(len(a), &a[0])
-}
-
-type WaitStatus uint32
-
-// Wait status is 7 bits at bottom, either 0 (exited),
-// 0x7F (stopped), or a signal number that caused an exit.
-// The 0x80 bit is whether there was a core dump.
-// An extra number (exit code, signal causing a stop)
-// is in the high bits. At least that's the idea.
-// There are various irregularities. For example, the
-// "continued" status is 0xFFFF, distinguishing itself
-// from stopped via the core dump bit.
-
-const (
- mask = 0x7F
- core = 0x80
- exited = 0x00
- stopped = 0x7F
- shift = 8
-)
-
-func (w WaitStatus) Exited() bool { return w&mask == exited }
-
-func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != exited }
-
-func (w WaitStatus) Stopped() bool { return w&0xFF == stopped }
-
-func (w WaitStatus) Continued() bool { return w == 0xFFFF }
-
-func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 }
-
-func (w WaitStatus) ExitStatus() int {
- if !w.Exited() {
- return -1
- }
- return int(w>>shift) & 0xFF
-}
-
-func (w WaitStatus) Signal() syscall.Signal {
- if !w.Signaled() {
- return -1
- }
- return syscall.Signal(w & mask)
-}
-
-func (w WaitStatus) StopSignal() syscall.Signal {
- if !w.Stopped() {
- return -1
- }
- return syscall.Signal(w>>shift) & 0xFF
-}
-
-func (w WaitStatus) TrapCause() int {
- if w.StopSignal() != SIGTRAP {
- return -1
- }
- return int(w>>shift) >> 8
-}
-
-//sys wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error)
-
-func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
- var status _C_int
- wpid, err = wait4(pid, &status, options, rusage)
- if wstatus != nil {
- *wstatus = WaitStatus(status)
- }
- return
-}
-
-func Mkfifo(path string, mode uint32) (err error) {
- return Mknod(path, mode|S_IFIFO, 0)
-}
-
-func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
- if sa.Port < 0 || sa.Port > 0xFFFF {
- return nil, 0, EINVAL
- }
- sa.raw.Family = AF_INET
- p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
- p[0] = byte(sa.Port >> 8)
- p[1] = byte(sa.Port)
- for i := 0; i < len(sa.Addr); i++ {
- sa.raw.Addr[i] = sa.Addr[i]
- }
- return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil
-}
-
-func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
- if sa.Port < 0 || sa.Port > 0xFFFF {
- return nil, 0, EINVAL
- }
- sa.raw.Family = AF_INET6
- p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
- p[0] = byte(sa.Port >> 8)
- p[1] = byte(sa.Port)
- sa.raw.Scope_id = sa.ZoneId
- for i := 0; i < len(sa.Addr); i++ {
- sa.raw.Addr[i] = sa.Addr[i]
- }
- return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil
-}
-
-func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
- name := sa.Name
- n := len(name)
- if n >= len(sa.raw.Path) {
- return nil, 0, EINVAL
- }
- sa.raw.Family = AF_UNIX
- for i := 0; i < n; i++ {
- sa.raw.Path[i] = int8(name[i])
- }
- // length is family (uint16), name, NUL.
- sl := _Socklen(2)
- if n > 0 {
- sl += _Socklen(n) + 1
- }
- if sa.raw.Path[0] == '@' {
- sa.raw.Path[0] = 0
- // Don't count trailing NUL for abstract address.
- sl--
- }
-
- return unsafe.Pointer(&sa.raw), sl, nil
-}
-
-type SockaddrLinklayer struct {
- Protocol uint16
- Ifindex int
- Hatype uint16
- Pkttype uint8
- Halen uint8
- Addr [8]byte
- raw RawSockaddrLinklayer
-}
-
-func (sa *SockaddrLinklayer) sockaddr() (unsafe.Pointer, _Socklen, error) {
- if sa.Ifindex < 0 || sa.Ifindex > 0x7fffffff {
- return nil, 0, EINVAL
- }
- sa.raw.Family = AF_PACKET
- sa.raw.Protocol = sa.Protocol
- sa.raw.Ifindex = int32(sa.Ifindex)
- sa.raw.Hatype = sa.Hatype
- sa.raw.Pkttype = sa.Pkttype
- sa.raw.Halen = sa.Halen
- for i := 0; i < len(sa.Addr); i++ {
- sa.raw.Addr[i] = sa.Addr[i]
- }
- return unsafe.Pointer(&sa.raw), SizeofSockaddrLinklayer, nil
-}
-
-type SockaddrNetlink struct {
- Family uint16
- Pad uint16
- Pid uint32
- Groups uint32
- raw RawSockaddrNetlink
-}
-
-func (sa *SockaddrNetlink) sockaddr() (unsafe.Pointer, _Socklen, error) {
- sa.raw.Family = AF_NETLINK
- sa.raw.Pad = sa.Pad
- sa.raw.Pid = sa.Pid
- sa.raw.Groups = sa.Groups
- return unsafe.Pointer(&sa.raw), SizeofSockaddrNetlink, nil
-}
-
-type SockaddrHCI struct {
- Dev uint16
- Channel uint16
- raw RawSockaddrHCI
-}
-
-func (sa *SockaddrHCI) sockaddr() (unsafe.Pointer, _Socklen, error) {
- sa.raw.Family = AF_BLUETOOTH
- sa.raw.Dev = sa.Dev
- sa.raw.Channel = sa.Channel
- return unsafe.Pointer(&sa.raw), SizeofSockaddrHCI, nil
-}
-
-func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
- switch rsa.Addr.Family {
- case AF_NETLINK:
- pp := (*RawSockaddrNetlink)(unsafe.Pointer(rsa))
- sa := new(SockaddrNetlink)
- sa.Family = pp.Family
- sa.Pad = pp.Pad
- sa.Pid = pp.Pid
- sa.Groups = pp.Groups
- return sa, nil
-
- case AF_PACKET:
- pp := (*RawSockaddrLinklayer)(unsafe.Pointer(rsa))
- sa := new(SockaddrLinklayer)
- sa.Protocol = pp.Protocol
- sa.Ifindex = int(pp.Ifindex)
- sa.Hatype = pp.Hatype
- sa.Pkttype = pp.Pkttype
- sa.Halen = pp.Halen
- for i := 0; i < len(sa.Addr); i++ {
- sa.Addr[i] = pp.Addr[i]
- }
- return sa, nil
-
- case AF_UNIX:
- pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
- sa := new(SockaddrUnix)
- if pp.Path[0] == 0 {
- // "Abstract" Unix domain socket.
- // Rewrite leading NUL as @ for textual display.
- // (This is the standard convention.)
- // Not friendly to overwrite in place,
- // but the callers below don't care.
- pp.Path[0] = '@'
- }
-
- // Assume path ends at NUL.
- // This is not technically the Linux semantics for
- // abstract Unix domain sockets--they are supposed
- // to be uninterpreted fixed-size binary blobs--but
- // everyone uses this convention.
- n := 0
- for n < len(pp.Path) && pp.Path[n] != 0 {
- n++
- }
- bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
- sa.Name = string(bytes)
- return sa, nil
-
- case AF_INET:
- pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
- sa := new(SockaddrInet4)
- p := (*[2]byte)(unsafe.Pointer(&pp.Port))
- sa.Port = int(p[0])<<8 + int(p[1])
- for i := 0; i < len(sa.Addr); i++ {
- sa.Addr[i] = pp.Addr[i]
- }
- return sa, nil
-
- case AF_INET6:
- pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
- sa := new(SockaddrInet6)
- p := (*[2]byte)(unsafe.Pointer(&pp.Port))
- sa.Port = int(p[0])<<8 + int(p[1])
- sa.ZoneId = pp.Scope_id
- for i := 0; i < len(sa.Addr); i++ {
- sa.Addr[i] = pp.Addr[i]
- }
- return sa, nil
- }
- return nil, EAFNOSUPPORT
-}
-
-func Accept(fd int) (nfd int, sa Sockaddr, err error) {
- var rsa RawSockaddrAny
- var len _Socklen = SizeofSockaddrAny
- nfd, err = accept(fd, &rsa, &len)
- if err != nil {
- return
- }
- sa, err = anyToSockaddr(&rsa)
- if err != nil {
- Close(nfd)
- nfd = 0
- }
- return
-}
-
-func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) {
- var rsa RawSockaddrAny
- var len _Socklen = SizeofSockaddrAny
- nfd, err = accept4(fd, &rsa, &len, flags)
- if err != nil {
- return
- }
- if len > SizeofSockaddrAny {
- panic("RawSockaddrAny too small")
- }
- sa, err = anyToSockaddr(&rsa)
- if err != nil {
- Close(nfd)
- nfd = 0
- }
- return
-}
-
-func Getsockname(fd int) (sa Sockaddr, err error) {
- var rsa RawSockaddrAny
- var len _Socklen = SizeofSockaddrAny
- if err = getsockname(fd, &rsa, &len); err != nil {
- return
- }
- return anyToSockaddr(&rsa)
-}
-
-func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) {
- vallen := _Socklen(4)
- err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
- return value, err
-}
-
-func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) {
- var value IPMreq
- vallen := _Socklen(SizeofIPMreq)
- err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
- return &value, err
-}
-
-func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
- var value IPMreqn
- vallen := _Socklen(SizeofIPMreqn)
- err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
- return &value, err
-}
-
-func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
- var value IPv6Mreq
- vallen := _Socklen(SizeofIPv6Mreq)
- err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
- return &value, err
-}
-
-func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
- var value IPv6MTUInfo
- vallen := _Socklen(SizeofIPv6MTUInfo)
- err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
- return &value, err
-}
-
-func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
- var value ICMPv6Filter
- vallen := _Socklen(SizeofICMPv6Filter)
- err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
- return &value, err
-}
-
-func GetsockoptUcred(fd, level, opt int) (*Ucred, error) {
- var value Ucred
- vallen := _Socklen(SizeofUcred)
- err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
- return &value, err
-}
-
-func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
- return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
-}
-
-func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
- var msg Msghdr
- var rsa RawSockaddrAny
- msg.Name = (*byte)(unsafe.Pointer(&rsa))
- msg.Namelen = uint32(SizeofSockaddrAny)
- var iov Iovec
- if len(p) > 0 {
- iov.Base = (*byte)(unsafe.Pointer(&p[0]))
- iov.SetLen(len(p))
- }
- var dummy byte
- if len(oob) > 0 {
- // receive at least one normal byte
- if len(p) == 0 {
- iov.Base = &dummy
- iov.SetLen(1)
- }
- msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
- msg.SetControllen(len(oob))
- }
- msg.Iov = &iov
- msg.Iovlen = 1
- if n, err = recvmsg(fd, &msg, flags); err != nil {
- return
- }
- oobn = int(msg.Controllen)
- recvflags = int(msg.Flags)
- // source address is only specified if the socket is unconnected
- if rsa.Addr.Family != AF_UNSPEC {
- from, err = anyToSockaddr(&rsa)
- }
- return
-}
-
-func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
- _, err = SendmsgN(fd, p, oob, to, flags)
- return
-}
-
-func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
- var ptr unsafe.Pointer
- var salen _Socklen
- if to != nil {
- var err error
- ptr, salen, err = to.sockaddr()
- if err != nil {
- return 0, err
- }
- }
- var msg Msghdr
- msg.Name = (*byte)(unsafe.Pointer(ptr))
- msg.Namelen = uint32(salen)
- var iov Iovec
- if len(p) > 0 {
- iov.Base = (*byte)(unsafe.Pointer(&p[0]))
- iov.SetLen(len(p))
- }
- var dummy byte
- if len(oob) > 0 {
- // send at least one normal byte
- if len(p) == 0 {
- iov.Base = &dummy
- iov.SetLen(1)
- }
- msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
- msg.SetControllen(len(oob))
- }
- msg.Iov = &iov
- msg.Iovlen = 1
- if n, err = sendmsg(fd, &msg, flags); err != nil {
- return 0, err
- }
- if len(oob) > 0 && len(p) == 0 {
- n = 0
- }
- return n, nil
-}
-
-// BindToDevice binds the socket associated with fd to device.
-func BindToDevice(fd int, device string) (err error) {
- return SetsockoptString(fd, SOL_SOCKET, SO_BINDTODEVICE, device)
-}
-
-//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
-
-func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err error) {
- // The peek requests are machine-size oriented, so we wrap it
- // to retrieve arbitrary-length data.
-
- // The ptrace syscall differs from glibc's ptrace.
- // Peeks returns the word in *data, not as the return value.
-
- var buf [sizeofPtr]byte
-
- // Leading edge. PEEKTEXT/PEEKDATA don't require aligned
- // access (PEEKUSER warns that it might), but if we don't
- // align our reads, we might straddle an unmapped page
- // boundary and not get the bytes leading up to the page
- // boundary.
- n := 0
- if addr%sizeofPtr != 0 {
- err = ptrace(req, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0])))
- if err != nil {
- return 0, err
- }
- n += copy(out, buf[addr%sizeofPtr:])
- out = out[n:]
- }
-
- // Remainder.
- for len(out) > 0 {
- // We use an internal buffer to guarantee alignment.
- // It's not documented if this is necessary, but we're paranoid.
- err = ptrace(req, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0])))
- if err != nil {
- return n, err
- }
- copied := copy(out, buf[0:])
- n += copied
- out = out[copied:]
- }
-
- return n, nil
-}
-
-func PtracePeekText(pid int, addr uintptr, out []byte) (count int, err error) {
- return ptracePeek(PTRACE_PEEKTEXT, pid, addr, out)
-}
-
-func PtracePeekData(pid int, addr uintptr, out []byte) (count int, err error) {
- return ptracePeek(PTRACE_PEEKDATA, pid, addr, out)
-}
-
-func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (count int, err error) {
- // As for ptracePeek, we need to align our accesses to deal
- // with the possibility of straddling an invalid page.
-
- // Leading edge.
- n := 0
- if addr%sizeofPtr != 0 {
- var buf [sizeofPtr]byte
- err = ptrace(peekReq, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0])))
- if err != nil {
- return 0, err
- }
- n += copy(buf[addr%sizeofPtr:], data)
- word := *((*uintptr)(unsafe.Pointer(&buf[0])))
- err = ptrace(pokeReq, pid, addr-addr%sizeofPtr, word)
- if err != nil {
- return 0, err
- }
- data = data[n:]
- }
-
- // Interior.
- for len(data) > sizeofPtr {
- word := *((*uintptr)(unsafe.Pointer(&data[0])))
- err = ptrace(pokeReq, pid, addr+uintptr(n), word)
- if err != nil {
- return n, err
- }
- n += sizeofPtr
- data = data[sizeofPtr:]
- }
-
- // Trailing edge.
- if len(data) > 0 {
- var buf [sizeofPtr]byte
- err = ptrace(peekReq, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0])))
- if err != nil {
- return n, err
- }
- copy(buf[0:], data)
- word := *((*uintptr)(unsafe.Pointer(&buf[0])))
- err = ptrace(pokeReq, pid, addr+uintptr(n), word)
- if err != nil {
- return n, err
- }
- n += len(data)
- }
-
- return n, nil
-}
-
-func PtracePokeText(pid int, addr uintptr, data []byte) (count int, err error) {
- return ptracePoke(PTRACE_POKETEXT, PTRACE_PEEKTEXT, pid, addr, data)
-}
-
-func PtracePokeData(pid int, addr uintptr, data []byte) (count int, err error) {
- return ptracePoke(PTRACE_POKEDATA, PTRACE_PEEKDATA, pid, addr, data)
-}
-
-func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
- return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
-}
-
-func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) {
- return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
-}
-
-func PtraceSetOptions(pid int, options int) (err error) {
- return ptrace(PTRACE_SETOPTIONS, pid, 0, uintptr(options))
-}
-
-func PtraceGetEventMsg(pid int) (msg uint, err error) {
- var data _C_long
- err = ptrace(PTRACE_GETEVENTMSG, pid, 0, uintptr(unsafe.Pointer(&data)))
- msg = uint(data)
- return
-}
-
-func PtraceCont(pid int, signal int) (err error) {
- return ptrace(PTRACE_CONT, pid, 0, uintptr(signal))
-}
-
-func PtraceSyscall(pid int, signal int) (err error) {
- return ptrace(PTRACE_SYSCALL, pid, 0, uintptr(signal))
-}
-
-func PtraceSingleStep(pid int) (err error) { return ptrace(PTRACE_SINGLESTEP, pid, 0, 0) }
-
-func PtraceAttach(pid int) (err error) { return ptrace(PTRACE_ATTACH, pid, 0, 0) }
-
-func PtraceDetach(pid int) (err error) { return ptrace(PTRACE_DETACH, pid, 0, 0) }
-
-//sys reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error)
-
-func Reboot(cmd int) (err error) {
- return reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, "")
-}
-
-func clen(n []byte) int {
- for i := 0; i < len(n); i++ {
- if n[i] == 0 {
- return i
- }
- }
- return len(n)
-}
-
-func ReadDirent(fd int, buf []byte) (n int, err error) {
- return Getdents(fd, buf)
-}
-
-func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
- origlen := len(buf)
- count = 0
- for max != 0 && len(buf) > 0 {
- dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
- buf = buf[dirent.Reclen:]
- if dirent.Ino == 0 { // File absent in directory.
- continue
- }
- bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
- var name = string(bytes[0:clen(bytes[:])])
- if name == "." || name == ".." { // Useless names
- continue
- }
- max--
- count++
- names = append(names, name)
- }
- return origlen - len(buf), count, names
-}
-
-//sys mount(source string, target string, fstype string, flags uintptr, data *byte) (err error)
-
-func Mount(source string, target string, fstype string, flags uintptr, data string) (err error) {
- // Certain file systems get rather angry and EINVAL if you give
- // them an empty string of data, rather than NULL.
- if data == "" {
- return mount(source, target, fstype, flags, nil)
- }
- datap, err := BytePtrFromString(data)
- if err != nil {
- return err
- }
- return mount(source, target, fstype, flags, datap)
-}
-
-// Sendto
-// Recvfrom
-// Socketpair
-
-/*
- * Direct access
- */
-//sys Acct(path string) (err error)
-//sys Adjtimex(buf *Timex) (state int, err error)
-//sys Chdir(path string) (err error)
-//sys Chroot(path string) (err error)
-//sys ClockGettime(clockid int32, time *Timespec) (err error)
-//sys Close(fd int) (err error)
-//sys Dup(oldfd int) (fd int, err error)
-//sys Dup3(oldfd int, newfd int, flags int) (err error)
-//sysnb EpollCreate(size int) (fd int, err error)
-//sysnb EpollCreate1(flag int) (fd int, err error)
-//sysnb EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error)
-//sys Exit(code int) = SYS_EXIT_GROUP
-//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
-//sys Fallocate(fd int, mode uint32, off int64, len int64) (err error)
-//sys Fchdir(fd int) (err error)
-//sys Fchmod(fd int, mode uint32) (err error)
-//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
-//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
-//sys fcntl(fd int, cmd int, arg int) (val int, err error)
-//sys Fdatasync(fd int) (err error)
-//sys Flock(fd int, how int) (err error)
-//sys Fsync(fd int) (err error)
-//sys Getdents(fd int, buf []byte) (n int, err error) = SYS_GETDENTS64
-//sysnb Getpgid(pid int) (pgid int, err error)
-
-func Getpgrp() (pid int) {
- pid, _ = Getpgid(0)
- return
-}
-
-//sysnb Getpid() (pid int)
-//sysnb Getppid() (ppid int)
-//sys Getpriority(which int, who int) (prio int, err error)
-//sysnb Getrusage(who int, rusage *Rusage) (err error)
-//sysnb Getsid(pid int) (sid int, err error)
-//sysnb Gettid() (tid int)
-//sys Getxattr(path string, attr string, dest []byte) (sz int, err error)
-//sys InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error)
-//sysnb InotifyInit1(flags int) (fd int, err error)
-//sysnb InotifyRmWatch(fd int, watchdesc uint32) (success int, err error)
-//sysnb Kill(pid int, sig syscall.Signal) (err error)
-//sys Klogctl(typ int, buf []byte) (n int, err error) = SYS_SYSLOG
-//sys Listxattr(path string, dest []byte) (sz int, err error)
-//sys Mkdirat(dirfd int, path string, mode uint32) (err error)
-//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
-//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
-//sys PivotRoot(newroot string, putold string) (err error) = SYS_PIVOT_ROOT
-//sysnb prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) = SYS_PRLIMIT64
-//sys Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error)
-//sys read(fd int, p []byte) (n int, err error)
-//sys Removexattr(path string, attr string) (err error)
-//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
-//sys Setdomainname(p []byte) (err error)
-//sys Sethostname(p []byte) (err error)
-//sysnb Setpgid(pid int, pgid int) (err error)
-//sysnb Setsid() (pid int, err error)
-//sysnb Settimeofday(tv *Timeval) (err error)
-//sys Setns(fd int, nstype int) (err error)
-
-// issue 1435.
-// On linux Setuid and Setgid only affects the current thread, not the process.
-// This does not match what most callers expect so we must return an error
-// here rather than letting the caller think that the call succeeded.
-
-func Setuid(uid int) (err error) {
- return EOPNOTSUPP
-}
-
-func Setgid(uid int) (err error) {
- return EOPNOTSUPP
-}
-
-//sys Setpriority(which int, who int, prio int) (err error)
-//sys Setxattr(path string, attr string, data []byte, flags int) (err error)
-//sys Sync()
-//sysnb Sysinfo(info *Sysinfo_t) (err error)
-//sys Tee(rfd int, wfd int, len int, flags int) (n int64, err error)
-//sysnb Tgkill(tgid int, tid int, sig syscall.Signal) (err error)
-//sysnb Times(tms *Tms) (ticks uintptr, err error)
-//sysnb Umask(mask int) (oldmask int)
-//sysnb Uname(buf *Utsname) (err error)
-//sys Unmount(target string, flags int) (err error) = SYS_UMOUNT2
-//sys Unshare(flags int) (err error)
-//sys Ustat(dev int, ubuf *Ustat_t) (err error)
-//sys write(fd int, p []byte) (n int, err error)
-//sys exitThread(code int) (err error) = SYS_EXIT
-//sys readlen(fd int, p *byte, np int) (n int, err error) = SYS_READ
-//sys writelen(fd int, p *byte, np int) (n int, err error) = SYS_WRITE
-
-// mmap varies by architecture; see syscall_linux_*.go.
-//sys munmap(addr uintptr, length uintptr) (err error)
-
-var mapper = &mmapper{
- active: make(map[*byte][]byte),
- mmap: mmap,
- munmap: munmap,
-}
-
-func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
- return mapper.Mmap(fd, offset, length, prot, flags)
-}
-
-func Munmap(b []byte) (err error) {
- return mapper.Munmap(b)
-}
-
-//sys Madvise(b []byte, advice int) (err error)
-//sys Mprotect(b []byte, prot int) (err error)
-//sys Mlock(b []byte) (err error)
-//sys Munlock(b []byte) (err error)
-//sys Mlockall(flags int) (err error)
-//sys Munlockall() (err error)
-
-/*
- * Unimplemented
- */
-// AddKey
-// AfsSyscall
-// Alarm
-// ArchPrctl
-// Brk
-// Capget
-// Capset
-// ClockGetres
-// ClockNanosleep
-// ClockSettime
-// Clone
-// CreateModule
-// DeleteModule
-// EpollCtlOld
-// EpollPwait
-// EpollWaitOld
-// Eventfd
-// Execve
-// Fgetxattr
-// Flistxattr
-// Fork
-// Fremovexattr
-// Fsetxattr
-// Futex
-// GetKernelSyms
-// GetMempolicy
-// GetRobustList
-// GetThreadArea
-// Getitimer
-// Getpmsg
-// IoCancel
-// IoDestroy
-// IoGetevents
-// IoSetup
-// IoSubmit
-// Ioctl
-// IoprioGet
-// IoprioSet
-// KexecLoad
-// Keyctl
-// Lgetxattr
-// Llistxattr
-// LookupDcookie
-// Lremovexattr
-// Lsetxattr
-// Mbind
-// MigratePages
-// Mincore
-// ModifyLdt
-// Mount
-// MovePages
-// Mprotect
-// MqGetsetattr
-// MqNotify
-// MqOpen
-// MqTimedreceive
-// MqTimedsend
-// MqUnlink
-// Mremap
-// Msgctl
-// Msgget
-// Msgrcv
-// Msgsnd
-// Msync
-// Newfstatat
-// Nfsservctl
-// Personality
-// Pselect6
-// Ptrace
-// Putpmsg
-// QueryModule
-// Quotactl
-// Readahead
-// Readv
-// RemapFilePages
-// RequestKey
-// RestartSyscall
-// RtSigaction
-// RtSigpending
-// RtSigprocmask
-// RtSigqueueinfo
-// RtSigreturn
-// RtSigsuspend
-// RtSigtimedwait
-// SchedGetPriorityMax
-// SchedGetPriorityMin
-// SchedGetaffinity
-// SchedGetparam
-// SchedGetscheduler
-// SchedRrGetInterval
-// SchedSetaffinity
-// SchedSetparam
-// SchedYield
-// Security
-// Semctl
-// Semget
-// Semop
-// Semtimedop
-// SetMempolicy
-// SetRobustList
-// SetThreadArea
-// SetTidAddress
-// Shmat
-// Shmctl
-// Shmdt
-// Shmget
-// Sigaltstack
-// Signalfd
-// Swapoff
-// Swapon
-// Sysfs
-// TimerCreate
-// TimerDelete
-// TimerGetoverrun
-// TimerGettime
-// TimerSettime
-// Timerfd
-// Tkill (obsolete)
-// Tuxcall
-// Umount2
-// Uselib
-// Utimensat
-// Vfork
-// Vhangup
-// Vmsplice
-// Vserver
-// Waitid
-// _Sysctl
diff --git a/newt/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go b/newt/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go
deleted file mode 100644
index 18911c2d..00000000
--- a/newt/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build amd64,linux
-
-package unix
-
-import "syscall"
-
-//sys Dup2(oldfd int, newfd int) (err error)
-//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
-//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
-//sys Fchown(fd int, uid int, gid int) (err error)
-//sys Fstat(fd int, stat *Stat_t) (err error)
-//sys Fstatfs(fd int, buf *Statfs_t) (err error)
-//sys Ftruncate(fd int, length int64) (err error)
-//sysnb Getegid() (egid int)
-//sysnb Geteuid() (euid int)
-//sysnb Getgid() (gid int)
-//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
-//sysnb Getuid() (uid int)
-//sysnb InotifyInit() (fd int, err error)
-//sys Ioperm(from int, num int, on int) (err error)
-//sys Iopl(level int) (err error)
-//sys Lchown(path string, uid int, gid int) (err error)
-//sys Listen(s int, n int) (err error)
-//sys Lstat(path string, stat *Stat_t) (err error)
-//sys Pause() (err error)
-//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
-//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
-//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
-//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
-//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
-//sys Setfsgid(gid int) (err error)
-//sys Setfsuid(uid int) (err error)
-//sysnb Setregid(rgid int, egid int) (err error)
-//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
-//sysnb Setresuid(ruid int, euid int, suid int) (err error)
-//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
-//sysnb Setreuid(ruid int, euid int) (err error)
-//sys Shutdown(fd int, how int) (err error)
-//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
-//sys Stat(path string, stat *Stat_t) (err error)
-//sys Statfs(path string, buf *Statfs_t) (err error)
-//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
-//sys Truncate(path string, length int64) (err error)
-//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
-//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
-//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
-//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
-//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
-//sysnb setgroups(n int, list *_Gid_t) (err error)
-//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
-//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
-//sysnb socket(domain int, typ int, proto int) (fd int, err error)
-//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
-//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
-//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
-//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
-//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
-//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
-//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
-//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
-
-//go:noescape
-func gettimeofday(tv *Timeval) (err syscall.Errno)
-
-func Gettimeofday(tv *Timeval) (err error) {
- errno := gettimeofday(tv)
- if errno != 0 {
- return errno
- }
- return nil
-}
-
-func Getpagesize() int { return 4096 }
-
-func Time(t *Time_t) (tt Time_t, err error) {
- var tv Timeval
- errno := gettimeofday(&tv)
- if errno != 0 {
- return 0, errno
- }
- if t != nil {
- *t = Time_t(tv.Sec)
- }
- return Time_t(tv.Sec), nil
-}
-
-//sys Utime(path string, buf *Utimbuf) (err error)
-
-func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
-
-func NsecToTimespec(nsec int64) (ts Timespec) {
- ts.Sec = nsec / 1e9
- ts.Nsec = nsec % 1e9
- return
-}
-
-func NsecToTimeval(nsec int64) (tv Timeval) {
- nsec += 999 // round up to microsecond
- tv.Sec = nsec / 1e9
- tv.Usec = nsec % 1e9 / 1e3
- return
-}
-
-//sysnb pipe(p *[2]_C_int) (err error)
-
-func Pipe(p []int) (err error) {
- if len(p) != 2 {
- return EINVAL
- }
- var pp [2]_C_int
- err = pipe(&pp)
- p[0] = int(pp[0])
- p[1] = int(pp[1])
- return
-}
-
-//sysnb pipe2(p *[2]_C_int, flags int) (err error)
-
-func Pipe2(p []int, flags int) (err error) {
- if len(p) != 2 {
- return EINVAL
- }
- var pp [2]_C_int
- err = pipe2(&pp, flags)
- p[0] = int(pp[0])
- p[1] = int(pp[1])
- return
-}
-
-func (r *PtraceRegs) PC() uint64 { return r.Rip }
-
-func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc }
-
-func (iov *Iovec) SetLen(length int) {
- iov.Len = uint64(length)
-}
-
-func (msghdr *Msghdr) SetControllen(length int) {
- msghdr.Controllen = uint64(length)
-}
-
-func (cmsg *Cmsghdr) SetLen(length int) {
- cmsg.Len = uint64(length)
-}
-
-//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
-
-func Poll(fds []PollFd, timeout int) (n int, err error) {
- if len(fds) == 0 {
- return poll(nil, 0, timeout)
- }
- return poll(&fds[0], len(fds), timeout)
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go b/newt/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go
deleted file mode 100644
index 8119fde3..00000000
--- a/newt/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go
+++ /dev/null
@@ -1,208 +0,0 @@
-// Copyright 2015 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build linux
-// +build mips64 mips64le
-
-package unix
-
-//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
-//sys Fchown(fd int, uid int, gid int) (err error)
-//sys Fstatfs(fd int, buf *Statfs_t) (err error)
-//sys Ftruncate(fd int, length int64) (err error)
-//sysnb Getegid() (egid int)
-//sysnb Geteuid() (euid int)
-//sysnb Getgid() (gid int)
-//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
-//sysnb Getuid() (uid int)
-//sys Lchown(path string, uid int, gid int) (err error)
-//sys Listen(s int, n int) (err error)
-//sys Pause() (err error)
-//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
-//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
-//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
-//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6
-//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
-//sys Setfsgid(gid int) (err error)
-//sys Setfsuid(uid int) (err error)
-//sysnb Setregid(rgid int, egid int) (err error)
-//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
-//sysnb Setresuid(ruid int, euid int, suid int) (err error)
-//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
-//sysnb Setreuid(ruid int, euid int) (err error)
-//sys Shutdown(fd int, how int) (err error)
-//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
-//sys Statfs(path string, buf *Statfs_t) (err error)
-//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
-//sys Truncate(path string, length int64) (err error)
-//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
-//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
-//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
-//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
-//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
-//sysnb setgroups(n int, list *_Gid_t) (err error)
-//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
-//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
-//sysnb socket(domain int, typ int, proto int) (fd int, err error)
-//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
-//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
-//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
-//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
-//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
-//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
-//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
-//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
-
-func Getpagesize() int { return 65536 }
-
-//sysnb Gettimeofday(tv *Timeval) (err error)
-
-func Time(t *Time_t) (tt Time_t, err error) {
- var tv Timeval
- err = Gettimeofday(&tv)
- if err != nil {
- return 0, err
- }
- if t != nil {
- *t = Time_t(tv.Sec)
- }
- return Time_t(tv.Sec), nil
-}
-
-//sys Utime(path string, buf *Utimbuf) (err error)
-
-func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
-
-func NsecToTimespec(nsec int64) (ts Timespec) {
- ts.Sec = nsec / 1e9
- ts.Nsec = nsec % 1e9
- return
-}
-
-func NsecToTimeval(nsec int64) (tv Timeval) {
- nsec += 999 // round up to microsecond
- tv.Sec = nsec / 1e9
- tv.Usec = nsec % 1e9 / 1e3
- return
-}
-
-func Pipe(p []int) (err error) {
- if len(p) != 2 {
- return EINVAL
- }
- var pp [2]_C_int
- err = pipe2(&pp, 0)
- p[0] = int(pp[0])
- p[1] = int(pp[1])
- return
-}
-
-//sysnb pipe2(p *[2]_C_int, flags int) (err error)
-
-func Pipe2(p []int, flags int) (err error) {
- if len(p) != 2 {
- return EINVAL
- }
- var pp [2]_C_int
- err = pipe2(&pp, flags)
- p[0] = int(pp[0])
- p[1] = int(pp[1])
- return
-}
-
-func Ioperm(from int, num int, on int) (err error) {
- return ENOSYS
-}
-
-func Iopl(level int) (err error) {
- return ENOSYS
-}
-
-type stat_t struct {
- Dev uint32
- Pad0 [3]int32
- Ino uint64
- Mode uint32
- Nlink uint32
- Uid uint32
- Gid uint32
- Rdev uint32
- Pad1 [3]uint32
- Size int64
- Atime uint32
- Atime_nsec uint32
- Mtime uint32
- Mtime_nsec uint32
- Ctime uint32
- Ctime_nsec uint32
- Blksize uint32
- Pad2 uint32
- Blocks int64
-}
-
-//sys fstat(fd int, st *stat_t) (err error)
-//sys lstat(path string, st *stat_t) (err error)
-//sys stat(path string, st *stat_t) (err error)
-
-func Fstat(fd int, s *Stat_t) (err error) {
- st := &stat_t{}
- err = fstat(fd, st)
- fillStat_t(s, st)
- return
-}
-
-func Lstat(path string, s *Stat_t) (err error) {
- st := &stat_t{}
- err = lstat(path, st)
- fillStat_t(s, st)
- return
-}
-
-func Stat(path string, s *Stat_t) (err error) {
- st := &stat_t{}
- err = stat(path, st)
- fillStat_t(s, st)
- return
-}
-
-func fillStat_t(s *Stat_t, st *stat_t) {
- s.Dev = st.Dev
- s.Ino = st.Ino
- s.Mode = st.Mode
- s.Nlink = st.Nlink
- s.Uid = st.Uid
- s.Gid = st.Gid
- s.Rdev = st.Rdev
- s.Size = st.Size
- s.Atim = Timespec{int64(st.Atime), int64(st.Atime_nsec)}
- s.Mtim = Timespec{int64(st.Mtime), int64(st.Mtime_nsec)}
- s.Ctim = Timespec{int64(st.Ctime), int64(st.Ctime_nsec)}
- s.Blksize = st.Blksize
- s.Blocks = st.Blocks
-}
-
-func (r *PtraceRegs) PC() uint64 { return r.Regs[64] }
-
-func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = pc }
-
-func (iov *Iovec) SetLen(length int) {
- iov.Len = uint64(length)
-}
-
-func (msghdr *Msghdr) SetControllen(length int) {
- msghdr.Controllen = uint64(length)
-}
-
-func (cmsg *Cmsghdr) SetLen(length int) {
- cmsg.Len = uint64(length)
-}
-
-//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
-
-func Poll(fds []PollFd, timeout int) (n int, err error) {
- if len(fds) == 0 {
- return poll(nil, 0, timeout)
- }
- return poll(&fds[0], len(fds), timeout)
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go b/newt/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go
deleted file mode 100644
index 81c5f473..00000000
--- a/newt/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go
+++ /dev/null
@@ -1,329 +0,0 @@
-// Copyright 2016 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build s390x,linux
-
-package unix
-
-import (
- "unsafe"
-)
-
-//sys Dup2(oldfd int, newfd int) (err error)
-//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
-//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
-//sys Fchown(fd int, uid int, gid int) (err error)
-//sys Fstat(fd int, stat *Stat_t) (err error)
-//sys Fstatfs(fd int, buf *Statfs_t) (err error)
-//sys Ftruncate(fd int, length int64) (err error)
-//sysnb Getegid() (egid int)
-//sysnb Geteuid() (euid int)
-//sysnb Getgid() (gid int)
-//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
-//sysnb Getuid() (uid int)
-//sysnb InotifyInit() (fd int, err error)
-//sys Lchown(path string, uid int, gid int) (err error)
-//sys Lstat(path string, stat *Stat_t) (err error)
-//sys Pause() (err error)
-//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
-//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
-//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
-//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
-//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
-//sys Setfsgid(gid int) (err error)
-//sys Setfsuid(uid int) (err error)
-//sysnb Setregid(rgid int, egid int) (err error)
-//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
-//sysnb Setresuid(ruid int, euid int, suid int) (err error)
-//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
-//sysnb Setreuid(ruid int, euid int) (err error)
-//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
-//sys Stat(path string, stat *Stat_t) (err error)
-//sys Statfs(path string, buf *Statfs_t) (err error)
-//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
-//sys Truncate(path string, length int64) (err error)
-//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
-//sysnb setgroups(n int, list *_Gid_t) (err error)
-
-func Getpagesize() int { return 4096 }
-
-//sysnb Gettimeofday(tv *Timeval) (err error)
-
-func Time(t *Time_t) (tt Time_t, err error) {
- var tv Timeval
- err = Gettimeofday(&tv)
- if err != nil {
- return 0, err
- }
- if t != nil {
- *t = Time_t(tv.Sec)
- }
- return Time_t(tv.Sec), nil
-}
-
-//sys Utime(path string, buf *Utimbuf) (err error)
-
-func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
-
-func NsecToTimespec(nsec int64) (ts Timespec) {
- ts.Sec = nsec / 1e9
- ts.Nsec = nsec % 1e9
- return
-}
-
-func NsecToTimeval(nsec int64) (tv Timeval) {
- nsec += 999 // round up to microsecond
- tv.Sec = nsec / 1e9
- tv.Usec = nsec % 1e9 / 1e3
- return
-}
-
-//sysnb pipe2(p *[2]_C_int, flags int) (err error)
-
-func Pipe(p []int) (err error) {
- if len(p) != 2 {
- return EINVAL
- }
- var pp [2]_C_int
- err = pipe2(&pp, 0) // pipe2 is the same as pipe when flags are set to 0.
- p[0] = int(pp[0])
- p[1] = int(pp[1])
- return
-}
-
-func Pipe2(p []int, flags int) (err error) {
- if len(p) != 2 {
- return EINVAL
- }
- var pp [2]_C_int
- err = pipe2(&pp, flags)
- p[0] = int(pp[0])
- p[1] = int(pp[1])
- return
-}
-
-func Ioperm(from int, num int, on int) (err error) {
- return ENOSYS
-}
-
-func Iopl(level int) (err error) {
- return ENOSYS
-}
-
-func (r *PtraceRegs) PC() uint64 { return r.Psw.Addr }
-
-func (r *PtraceRegs) SetPC(pc uint64) { r.Psw.Addr = pc }
-
-func (iov *Iovec) SetLen(length int) {
- iov.Len = uint64(length)
-}
-
-func (msghdr *Msghdr) SetControllen(length int) {
- msghdr.Controllen = uint64(length)
-}
-
-func (cmsg *Cmsghdr) SetLen(length int) {
- cmsg.Len = uint64(length)
-}
-
-// Linux on s390x uses the old mmap interface, which requires arguments to be passed in a struct.
-// mmap2 also requires arguments to be passed in a struct; it is currently not exposed in <asm/unistd.h>.
-func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
- mmap_args := [6]uintptr{addr, length, uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)}
- r0, _, e1 := Syscall(SYS_MMAP, uintptr(unsafe.Pointer(&mmap_args[0])), 0, 0)
- use(unsafe.Pointer(&mmap_args[0]))
- xaddr = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// On s390x Linux, all the socket calls go through an extra indirection.
-// The arguments to the underlying system call (SYS_SOCKETCALL) are the
-// number below and a pointer to an array of uintptr.
-const (
- // see linux/net.h
- netSocket = 1
- netBind = 2
- netConnect = 3
- netListen = 4
- netAccept = 5
- netGetSockName = 6
- netGetPeerName = 7
- netSocketPair = 8
- netSend = 9
- netRecv = 10
- netSendTo = 11
- netRecvFrom = 12
- netShutdown = 13
- netSetSockOpt = 14
- netGetSockOpt = 15
- netSendMsg = 16
- netRecvMsg = 17
- netAccept4 = 18
- netRecvMMsg = 19
- netSendMMsg = 20
-)
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (int, error) {
- args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))}
- fd, _, err := Syscall(SYS_SOCKETCALL, netAccept, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return 0, err
- }
- return int(fd), nil
-}
-
-func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (int, error) {
- args := [4]uintptr{uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags)}
- fd, _, err := Syscall(SYS_SOCKETCALL, netAccept4, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return 0, err
- }
- return int(fd), nil
-}
-
-func getsockname(s int, rsa *RawSockaddrAny, addrlen *_Socklen) error {
- args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))}
- _, _, err := RawSyscall(SYS_SOCKETCALL, netGetSockName, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return err
- }
- return nil
-}
-
-func getpeername(s int, rsa *RawSockaddrAny, addrlen *_Socklen) error {
- args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))}
- _, _, err := RawSyscall(SYS_SOCKETCALL, netGetPeerName, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return err
- }
- return nil
-}
-
-func socketpair(domain int, typ int, flags int, fd *[2]int32) error {
- args := [4]uintptr{uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd))}
- _, _, err := RawSyscall(SYS_SOCKETCALL, netSocketPair, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return err
- }
- return nil
-}
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) error {
- args := [3]uintptr{uintptr(s), uintptr(addr), uintptr(addrlen)}
- _, _, err := Syscall(SYS_SOCKETCALL, netBind, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return err
- }
- return nil
-}
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) error {
- args := [3]uintptr{uintptr(s), uintptr(addr), uintptr(addrlen)}
- _, _, err := Syscall(SYS_SOCKETCALL, netConnect, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return err
- }
- return nil
-}
-
-func socket(domain int, typ int, proto int) (int, error) {
- args := [3]uintptr{uintptr(domain), uintptr(typ), uintptr(proto)}
- fd, _, err := RawSyscall(SYS_SOCKETCALL, netSocket, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return 0, err
- }
- return int(fd), nil
-}
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) error {
- args := [5]uintptr{uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen))}
- _, _, err := Syscall(SYS_SOCKETCALL, netGetSockOpt, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return err
- }
- return nil
-}
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) error {
- args := [4]uintptr{uintptr(s), uintptr(level), uintptr(name), uintptr(val)}
- _, _, err := Syscall(SYS_SOCKETCALL, netSetSockOpt, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return err
- }
- return nil
-}
-
-func recvfrom(s int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (int, error) {
- var base uintptr
- if len(p) > 0 {
- base = uintptr(unsafe.Pointer(&p[0]))
- }
- args := [6]uintptr{uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))}
- n, _, err := Syscall(SYS_SOCKETCALL, netRecvFrom, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return 0, err
- }
- return int(n), nil
-}
-
-func sendto(s int, p []byte, flags int, to unsafe.Pointer, addrlen _Socklen) error {
- var base uintptr
- if len(p) > 0 {
- base = uintptr(unsafe.Pointer(&p[0]))
- }
- args := [6]uintptr{uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(to), uintptr(addrlen)}
- _, _, err := Syscall(SYS_SOCKETCALL, netSendTo, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return err
- }
- return nil
-}
-
-func recvmsg(s int, msg *Msghdr, flags int) (int, error) {
- args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)}
- n, _, err := Syscall(SYS_SOCKETCALL, netRecvMsg, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return 0, err
- }
- return int(n), nil
-}
-
-func sendmsg(s int, msg *Msghdr, flags int) (int, error) {
- args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)}
- n, _, err := Syscall(SYS_SOCKETCALL, netSendMsg, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return 0, err
- }
- return int(n), nil
-}
-
-func Listen(s int, n int) error {
- args := [2]uintptr{uintptr(s), uintptr(n)}
- _, _, err := Syscall(SYS_SOCKETCALL, netListen, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return err
- }
- return nil
-}
-
-func Shutdown(s, how int) error {
- args := [2]uintptr{uintptr(s), uintptr(how)}
- _, _, err := Syscall(SYS_SOCKETCALL, netShutdown, uintptr(unsafe.Pointer(&args)), 0)
- if err != 0 {
- return err
- }
- return nil
-}
-
-//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
-
-func Poll(fds []PollFd, timeout int) (n int, err error) {
- if len(fds) == 0 {
- return poll(nil, 0, timeout)
- }
- return poll(&fds[0], len(fds), timeout)
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/syscall_netbsd.go b/newt/vendor/golang.org/x/sys/unix/syscall_netbsd.go
deleted file mode 100644
index c4e945cd..00000000
--- a/newt/vendor/golang.org/x/sys/unix/syscall_netbsd.go
+++ /dev/null
@@ -1,492 +0,0 @@
-// Copyright 2009,2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// NetBSD system calls.
-// This file is compiled as ordinary Go code,
-// but it is also input to mksyscall,
-// which parses the //sys lines and generates system call stubs.
-// Note that sometimes we use a lowercase //sys name and wrap
-// it in our own nicer implementation, either here or in
-// syscall_bsd.go or syscall_unix.go.
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-type SockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [12]int8
- raw RawSockaddrDatalink
-}
-
-func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
-
-func sysctlNodes(mib []_C_int) (nodes []Sysctlnode, err error) {
- var olen uintptr
-
- // Get a list of all sysctl nodes below the given MIB by performing
- // a sysctl for the given MIB with CTL_QUERY appended.
- mib = append(mib, CTL_QUERY)
- qnode := Sysctlnode{Flags: SYSCTL_VERS_1}
- qp := (*byte)(unsafe.Pointer(&qnode))
- sz := unsafe.Sizeof(qnode)
- if err = sysctl(mib, nil, &olen, qp, sz); err != nil {
- return nil, err
- }
-
- // Now that we know the size, get the actual nodes.
- nodes = make([]Sysctlnode, olen/sz)
- np := (*byte)(unsafe.Pointer(&nodes[0]))
- if err = sysctl(mib, np, &olen, qp, sz); err != nil {
- return nil, err
- }
-
- return nodes, nil
-}
-
-func nametomib(name string) (mib []_C_int, err error) {
-
- // Split name into components.
- var parts []string
- last := 0
- for i := 0; i < len(name); i++ {
- if name[i] == '.' {
- parts = append(parts, name[last:i])
- last = i + 1
- }
- }
- parts = append(parts, name[last:])
-
- // Discover the nodes and construct the MIB OID.
- for partno, part := range parts {
- nodes, err := sysctlNodes(mib)
- if err != nil {
- return nil, err
- }
- for _, node := range nodes {
- n := make([]byte, 0)
- for i := range node.Name {
- if node.Name[i] != 0 {
- n = append(n, byte(node.Name[i]))
- }
- }
- if string(n) == part {
- mib = append(mib, _C_int(node.Num))
- break
- }
- }
- if len(mib) != partno+1 {
- return nil, EINVAL
- }
- }
-
- return mib, nil
-}
-
-// ParseDirent parses up to max directory entries in buf,
-// appending the names to names. It returns the number
-// bytes consumed from buf, the number of entries added
-// to names, and the new names slice.
-func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
- origlen := len(buf)
- for max != 0 && len(buf) > 0 {
- dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
- if dirent.Reclen == 0 {
- buf = nil
- break
- }
- buf = buf[dirent.Reclen:]
- if dirent.Fileno == 0 { // File absent in directory.
- continue
- }
- bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
- var name = string(bytes[0:dirent.Namlen])
- if name == "." || name == ".." { // Useless names
- continue
- }
- max--
- count++
- names = append(names, name)
- }
- return origlen - len(buf), count, names
-}
-
-//sysnb pipe() (fd1 int, fd2 int, err error)
-func Pipe(p []int) (err error) {
- if len(p) != 2 {
- return EINVAL
- }
- p[0], p[1], err = pipe()
- return
-}
-
-//sys getdents(fd int, buf []byte) (n int, err error)
-func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
- return getdents(fd, buf)
-}
-
-// TODO
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- return -1, ENOSYS
-}
-
-/*
- * Exposed directly
- */
-//sys Access(path string, mode uint32) (err error)
-//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
-//sys Chdir(path string) (err error)
-//sys Chflags(path string, flags int) (err error)
-//sys Chmod(path string, mode uint32) (err error)
-//sys Chown(path string, uid int, gid int) (err error)
-//sys Chroot(path string) (err error)
-//sys Close(fd int) (err error)
-//sys Dup(fd int) (nfd int, err error)
-//sys Dup2(from int, to int) (err error)
-//sys Exit(code int)
-//sys Fchdir(fd int) (err error)
-//sys Fchflags(fd int, flags int) (err error)
-//sys Fchmod(fd int, mode uint32) (err error)
-//sys Fchown(fd int, uid int, gid int) (err error)
-//sys Flock(fd int, how int) (err error)
-//sys Fpathconf(fd int, name int) (val int, err error)
-//sys Fstat(fd int, stat *Stat_t) (err error)
-//sys Fsync(fd int) (err error)
-//sys Ftruncate(fd int, length int64) (err error)
-//sysnb Getegid() (egid int)
-//sysnb Geteuid() (uid int)
-//sysnb Getgid() (gid int)
-//sysnb Getpgid(pid int) (pgid int, err error)
-//sysnb Getpgrp() (pgrp int)
-//sysnb Getpid() (pid int)
-//sysnb Getppid() (ppid int)
-//sys Getpriority(which int, who int) (prio int, err error)
-//sysnb Getrlimit(which int, lim *Rlimit) (err error)
-//sysnb Getrusage(who int, rusage *Rusage) (err error)
-//sysnb Getsid(pid int) (sid int, err error)
-//sysnb Gettimeofday(tv *Timeval) (err error)
-//sysnb Getuid() (uid int)
-//sys Issetugid() (tainted bool)
-//sys Kill(pid int, signum syscall.Signal) (err error)
-//sys Kqueue() (fd int, err error)
-//sys Lchown(path string, uid int, gid int) (err error)
-//sys Link(path string, link string) (err error)
-//sys Listen(s int, backlog int) (err error)
-//sys Lstat(path string, stat *Stat_t) (err error)
-//sys Mkdir(path string, mode uint32) (err error)
-//sys Mkfifo(path string, mode uint32) (err error)
-//sys Mknod(path string, mode uint32, dev int) (err error)
-//sys Mlock(b []byte) (err error)
-//sys Mlockall(flags int) (err error)
-//sys Mprotect(b []byte, prot int) (err error)
-//sys Munlock(b []byte) (err error)
-//sys Munlockall() (err error)
-//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
-//sys Open(path string, mode int, perm uint32) (fd int, err error)
-//sys Pathconf(path string, name int) (val int, err error)
-//sys Pread(fd int, p []byte, offset int64) (n int, err error)
-//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
-//sys read(fd int, p []byte) (n int, err error)
-//sys Readlink(path string, buf []byte) (n int, err error)
-//sys Rename(from string, to string) (err error)
-//sys Revoke(path string) (err error)
-//sys Rmdir(path string) (err error)
-//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
-//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
-//sysnb Setegid(egid int) (err error)
-//sysnb Seteuid(euid int) (err error)
-//sysnb Setgid(gid int) (err error)
-//sysnb Setpgid(pid int, pgid int) (err error)
-//sys Setpriority(which int, who int, prio int) (err error)
-//sysnb Setregid(rgid int, egid int) (err error)
-//sysnb Setreuid(ruid int, euid int) (err error)
-//sysnb Setrlimit(which int, lim *Rlimit) (err error)
-//sysnb Setsid() (pid int, err error)
-//sysnb Settimeofday(tp *Timeval) (err error)
-//sysnb Setuid(uid int) (err error)
-//sys Stat(path string, stat *Stat_t) (err error)
-//sys Symlink(path string, link string) (err error)
-//sys Sync() (err error)
-//sys Truncate(path string, length int64) (err error)
-//sys Umask(newmask int) (oldmask int)
-//sys Unlink(path string) (err error)
-//sys Unmount(path string, flags int) (err error)
-//sys write(fd int, p []byte) (n int, err error)
-//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
-//sys munmap(addr uintptr, length uintptr) (err error)
-//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
-//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
-
-/*
- * Unimplemented
- */
-// ____semctl13
-// __clone
-// __fhopen40
-// __fhstat40
-// __fhstatvfs140
-// __fstat30
-// __getcwd
-// __getfh30
-// __getlogin
-// __lstat30
-// __mount50
-// __msgctl13
-// __msync13
-// __ntp_gettime30
-// __posix_chown
-// __posix_fadvise50
-// __posix_fchown
-// __posix_lchown
-// __posix_rename
-// __setlogin
-// __shmctl13
-// __sigaction_sigtramp
-// __sigaltstack14
-// __sigpending14
-// __sigprocmask14
-// __sigsuspend14
-// __sigtimedwait
-// __stat30
-// __syscall
-// __vfork14
-// _ksem_close
-// _ksem_destroy
-// _ksem_getvalue
-// _ksem_init
-// _ksem_open
-// _ksem_post
-// _ksem_trywait
-// _ksem_unlink
-// _ksem_wait
-// _lwp_continue
-// _lwp_create
-// _lwp_ctl
-// _lwp_detach
-// _lwp_exit
-// _lwp_getname
-// _lwp_getprivate
-// _lwp_kill
-// _lwp_park
-// _lwp_self
-// _lwp_setname
-// _lwp_setprivate
-// _lwp_suspend
-// _lwp_unpark
-// _lwp_unpark_all
-// _lwp_wait
-// _lwp_wakeup
-// _pset_bind
-// _sched_getaffinity
-// _sched_getparam
-// _sched_setaffinity
-// _sched_setparam
-// acct
-// aio_cancel
-// aio_error
-// aio_fsync
-// aio_read
-// aio_return
-// aio_suspend
-// aio_write
-// break
-// clock_getres
-// clock_gettime
-// clock_settime
-// compat_09_ogetdomainname
-// compat_09_osetdomainname
-// compat_09_ouname
-// compat_10_omsgsys
-// compat_10_osemsys
-// compat_10_oshmsys
-// compat_12_fstat12
-// compat_12_getdirentries
-// compat_12_lstat12
-// compat_12_msync
-// compat_12_oreboot
-// compat_12_oswapon
-// compat_12_stat12
-// compat_13_sigaction13
-// compat_13_sigaltstack13
-// compat_13_sigpending13
-// compat_13_sigprocmask13
-// compat_13_sigreturn13
-// compat_13_sigsuspend13
-// compat_14___semctl
-// compat_14_msgctl
-// compat_14_shmctl
-// compat_16___sigaction14
-// compat_16___sigreturn14
-// compat_20_fhstatfs
-// compat_20_fstatfs
-// compat_20_getfsstat
-// compat_20_statfs
-// compat_30___fhstat30
-// compat_30___fstat13
-// compat_30___lstat13
-// compat_30___stat13
-// compat_30_fhopen
-// compat_30_fhstat
-// compat_30_fhstatvfs1
-// compat_30_getdents
-// compat_30_getfh
-// compat_30_ntp_gettime
-// compat_30_socket
-// compat_40_mount
-// compat_43_fstat43
-// compat_43_lstat43
-// compat_43_oaccept
-// compat_43_ocreat
-// compat_43_oftruncate
-// compat_43_ogetdirentries
-// compat_43_ogetdtablesize
-// compat_43_ogethostid
-// compat_43_ogethostname
-// compat_43_ogetkerninfo
-// compat_43_ogetpagesize
-// compat_43_ogetpeername
-// compat_43_ogetrlimit
-// compat_43_ogetsockname
-// compat_43_okillpg
-// compat_43_olseek
-// compat_43_ommap
-// compat_43_oquota
-// compat_43_orecv
-// compat_43_orecvfrom
-// compat_43_orecvmsg
-// compat_43_osend
-// compat_43_osendmsg
-// compat_43_osethostid
-// compat_43_osethostname
-// compat_43_osetrlimit
-// compat_43_osigblock
-// compat_43_osigsetmask
-// compat_43_osigstack
-// compat_43_osigvec
-// compat_43_otruncate
-// compat_43_owait
-// compat_43_stat43
-// execve
-// extattr_delete_fd
-// extattr_delete_file
-// extattr_delete_link
-// extattr_get_fd
-// extattr_get_file
-// extattr_get_link
-// extattr_list_fd
-// extattr_list_file
-// extattr_list_link
-// extattr_set_fd
-// extattr_set_file
-// extattr_set_link
-// extattrctl
-// fchroot
-// fdatasync
-// fgetxattr
-// fktrace
-// flistxattr
-// fork
-// fremovexattr
-// fsetxattr
-// fstatvfs1
-// fsync_range
-// getcontext
-// getitimer
-// getvfsstat
-// getxattr
-// ioctl
-// ktrace
-// lchflags
-// lchmod
-// lfs_bmapv
-// lfs_markv
-// lfs_segclean
-// lfs_segwait
-// lgetxattr
-// lio_listio
-// listxattr
-// llistxattr
-// lremovexattr
-// lseek
-// lsetxattr
-// lutimes
-// madvise
-// mincore
-// minherit
-// modctl
-// mq_close
-// mq_getattr
-// mq_notify
-// mq_open
-// mq_receive
-// mq_send
-// mq_setattr
-// mq_timedreceive
-// mq_timedsend
-// mq_unlink
-// mremap
-// msgget
-// msgrcv
-// msgsnd
-// nfssvc
-// ntp_adjtime
-// pmc_control
-// pmc_get_info
-// poll
-// pollts
-// preadv
-// profil
-// pselect
-// pset_assign
-// pset_create
-// pset_destroy
-// ptrace
-// pwritev
-// quotactl
-// rasctl
-// readv
-// reboot
-// removexattr
-// sa_enable
-// sa_preempt
-// sa_register
-// sa_setconcurrency
-// sa_stacks
-// sa_yield
-// sbrk
-// sched_yield
-// semconfig
-// semget
-// semop
-// setcontext
-// setitimer
-// setxattr
-// shmat
-// shmdt
-// shmget
-// sstk
-// statvfs1
-// swapctl
-// sysarch
-// syscall
-// timer_create
-// timer_delete
-// timer_getoverrun
-// timer_gettime
-// timer_settime
-// undelete
-// utrace
-// uuidgen
-// vadvise
-// vfork
-// writev
diff --git a/newt/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/newt/vendor/golang.org/x/sys/unix/syscall_openbsd.go
deleted file mode 100644
index 554a8234..00000000
--- a/newt/vendor/golang.org/x/sys/unix/syscall_openbsd.go
+++ /dev/null
@@ -1,304 +0,0 @@
-// Copyright 2009,2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// OpenBSD system calls.
-// This file is compiled as ordinary Go code,
-// but it is also input to mksyscall,
-// which parses the //sys lines and generates system call stubs.
-// Note that sometimes we use a lowercase //sys name and wrap
-// it in our own nicer implementation, either here or in
-// syscall_bsd.go or syscall_unix.go.
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-type SockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [24]int8
- raw RawSockaddrDatalink
-}
-
-func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
-
-func nametomib(name string) (mib []_C_int, err error) {
-
- // Perform lookup via a binary search
- left := 0
- right := len(sysctlMib) - 1
- for {
- idx := left + (right-left)/2
- switch {
- case name == sysctlMib[idx].ctlname:
- return sysctlMib[idx].ctloid, nil
- case name > sysctlMib[idx].ctlname:
- left = idx + 1
- default:
- right = idx - 1
- }
- if left > right {
- break
- }
- }
- return nil, EINVAL
-}
-
-// ParseDirent parses up to max directory entries in buf,
-// appending the names to names. It returns the number
-// bytes consumed from buf, the number of entries added
-// to names, and the new names slice.
-func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
- origlen := len(buf)
- for max != 0 && len(buf) > 0 {
- dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
- if dirent.Reclen == 0 {
- buf = nil
- break
- }
- buf = buf[dirent.Reclen:]
- if dirent.Fileno == 0 { // File absent in directory.
- continue
- }
- bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
- var name = string(bytes[0:dirent.Namlen])
- if name == "." || name == ".." { // Useless names
- continue
- }
- max--
- count++
- names = append(names, name)
- }
- return origlen - len(buf), count, names
-}
-
-//sysnb pipe(p *[2]_C_int) (err error)
-func Pipe(p []int) (err error) {
- if len(p) != 2 {
- return EINVAL
- }
- var pp [2]_C_int
- err = pipe(&pp)
- p[0] = int(pp[0])
- p[1] = int(pp[1])
- return
-}
-
-//sys getdents(fd int, buf []byte) (n int, err error)
-func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
- return getdents(fd, buf)
-}
-
-// TODO
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- return -1, ENOSYS
-}
-
-func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
- var _p0 unsafe.Pointer
- var bufsize uintptr
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
- }
- r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-/*
- * Exposed directly
- */
-//sys Access(path string, mode uint32) (err error)
-//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
-//sys Chdir(path string) (err error)
-//sys Chflags(path string, flags int) (err error)
-//sys Chmod(path string, mode uint32) (err error)
-//sys Chown(path string, uid int, gid int) (err error)
-//sys Chroot(path string) (err error)
-//sys Close(fd int) (err error)
-//sys Dup(fd int) (nfd int, err error)
-//sys Dup2(from int, to int) (err error)
-//sys Exit(code int)
-//sys Fchdir(fd int) (err error)
-//sys Fchflags(fd int, flags int) (err error)
-//sys Fchmod(fd int, mode uint32) (err error)
-//sys Fchown(fd int, uid int, gid int) (err error)
-//sys Flock(fd int, how int) (err error)
-//sys Fpathconf(fd int, name int) (val int, err error)
-//sys Fstat(fd int, stat *Stat_t) (err error)
-//sys Fstatfs(fd int, stat *Statfs_t) (err error)
-//sys Fsync(fd int) (err error)
-//sys Ftruncate(fd int, length int64) (err error)
-//sysnb Getegid() (egid int)
-//sysnb Geteuid() (uid int)
-//sysnb Getgid() (gid int)
-//sysnb Getpgid(pid int) (pgid int, err error)
-//sysnb Getpgrp() (pgrp int)
-//sysnb Getpid() (pid int)
-//sysnb Getppid() (ppid int)
-//sys Getpriority(which int, who int) (prio int, err error)
-//sysnb Getrlimit(which int, lim *Rlimit) (err error)
-//sysnb Getrusage(who int, rusage *Rusage) (err error)
-//sysnb Getsid(pid int) (sid int, err error)
-//sysnb Gettimeofday(tv *Timeval) (err error)
-//sysnb Getuid() (uid int)
-//sys Issetugid() (tainted bool)
-//sys Kill(pid int, signum syscall.Signal) (err error)
-//sys Kqueue() (fd int, err error)
-//sys Lchown(path string, uid int, gid int) (err error)
-//sys Link(path string, link string) (err error)
-//sys Listen(s int, backlog int) (err error)
-//sys Lstat(path string, stat *Stat_t) (err error)
-//sys Mkdir(path string, mode uint32) (err error)
-//sys Mkfifo(path string, mode uint32) (err error)
-//sys Mknod(path string, mode uint32, dev int) (err error)
-//sys Mlock(b []byte) (err error)
-//sys Mlockall(flags int) (err error)
-//sys Mprotect(b []byte, prot int) (err error)
-//sys Munlock(b []byte) (err error)
-//sys Munlockall() (err error)
-//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
-//sys Open(path string, mode int, perm uint32) (fd int, err error)
-//sys Pathconf(path string, name int) (val int, err error)
-//sys Pread(fd int, p []byte, offset int64) (n int, err error)
-//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
-//sys read(fd int, p []byte) (n int, err error)
-//sys Readlink(path string, buf []byte) (n int, err error)
-//sys Rename(from string, to string) (err error)
-//sys Revoke(path string) (err error)
-//sys Rmdir(path string) (err error)
-//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
-//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
-//sysnb Setegid(egid int) (err error)
-//sysnb Seteuid(euid int) (err error)
-//sysnb Setgid(gid int) (err error)
-//sys Setlogin(name string) (err error)
-//sysnb Setpgid(pid int, pgid int) (err error)
-//sys Setpriority(which int, who int, prio int) (err error)
-//sysnb Setregid(rgid int, egid int) (err error)
-//sysnb Setreuid(ruid int, euid int) (err error)
-//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
-//sysnb Setresuid(ruid int, euid int, suid int) (err error)
-//sysnb Setrlimit(which int, lim *Rlimit) (err error)
-//sysnb Setsid() (pid int, err error)
-//sysnb Settimeofday(tp *Timeval) (err error)
-//sysnb Setuid(uid int) (err error)
-//sys Stat(path string, stat *Stat_t) (err error)
-//sys Statfs(path string, stat *Statfs_t) (err error)
-//sys Symlink(path string, link string) (err error)
-//sys Sync() (err error)
-//sys Truncate(path string, length int64) (err error)
-//sys Umask(newmask int) (oldmask int)
-//sys Unlink(path string) (err error)
-//sys Unmount(path string, flags int) (err error)
-//sys write(fd int, p []byte) (n int, err error)
-//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
-//sys munmap(addr uintptr, length uintptr) (err error)
-//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
-//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
-
-/*
- * Unimplemented
- */
-// __getcwd
-// __semctl
-// __syscall
-// __sysctl
-// adjfreq
-// break
-// clock_getres
-// clock_gettime
-// clock_settime
-// closefrom
-// execve
-// faccessat
-// fchmodat
-// fchownat
-// fcntl
-// fhopen
-// fhstat
-// fhstatfs
-// fork
-// fstatat
-// futimens
-// getfh
-// getgid
-// getitimer
-// getlogin
-// getresgid
-// getresuid
-// getrtable
-// getthrid
-// ioctl
-// ktrace
-// lfs_bmapv
-// lfs_markv
-// lfs_segclean
-// lfs_segwait
-// linkat
-// mincore
-// minherit
-// mkdirat
-// mkfifoat
-// mknodat
-// mount
-// mquery
-// msgctl
-// msgget
-// msgrcv
-// msgsnd
-// nfssvc
-// nnpfspioctl
-// openat
-// poll
-// preadv
-// profil
-// pwritev
-// quotactl
-// readlinkat
-// readv
-// reboot
-// renameat
-// rfork
-// sched_yield
-// semget
-// semop
-// setgroups
-// setitimer
-// setrtable
-// setsockopt
-// shmat
-// shmctl
-// shmdt
-// shmget
-// sigaction
-// sigaltstack
-// sigpending
-// sigprocmask
-// sigreturn
-// sigsuspend
-// symlinkat
-// sysarch
-// syscall
-// threxit
-// thrsigdivert
-// thrsleep
-// thrwakeup
-// unlinkat
-// utimensat
-// vfork
-// writev
diff --git a/newt/vendor/golang.org/x/sys/unix/syscall_solaris.go b/newt/vendor/golang.org/x/sys/unix/syscall_solaris.go
deleted file mode 100644
index acb74b1d..00000000
--- a/newt/vendor/golang.org/x/sys/unix/syscall_solaris.go
+++ /dev/null
@@ -1,725 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Solaris system calls.
-// This file is compiled as ordinary Go code,
-// but it is also input to mksyscall,
-// which parses the //sys lines and generates system call stubs.
-// Note that sometimes we use a lowercase //sys name and wrap
-// it in our own nicer implementation, either here or in
-// syscall_solaris.go or syscall_unix.go.
-
-package unix
-
-import (
- "sync/atomic"
- "syscall"
- "unsafe"
-)
-
-// Implemented in runtime/syscall_solaris.go.
-type syscallFunc uintptr
-
-func rawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
-func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
-
-type SockaddrDatalink struct {
- Family uint16
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [244]int8
- raw RawSockaddrDatalink
-}
-
-func clen(n []byte) int {
- for i := 0; i < len(n); i++ {
- if n[i] == 0 {
- return i
- }
- }
- return len(n)
-}
-
-// ParseDirent parses up to max directory entries in buf,
-// appending the names to names. It returns the number
-// bytes consumed from buf, the number of entries added
-// to names, and the new names slice.
-func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
- origlen := len(buf)
- for max != 0 && len(buf) > 0 {
- dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
- if dirent.Reclen == 0 {
- buf = nil
- break
- }
- buf = buf[dirent.Reclen:]
- if dirent.Ino == 0 { // File absent in directory.
- continue
- }
- bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
- var name = string(bytes[0:clen(bytes[:])])
- if name == "." || name == ".." { // Useless names
- continue
- }
- max--
- count++
- names = append(names, name)
- }
- return origlen - len(buf), count, names
-}
-
-//sysnb pipe(p *[2]_C_int) (n int, err error)
-
-func Pipe(p []int) (err error) {
- if len(p) != 2 {
- return EINVAL
- }
- var pp [2]_C_int
- n, err := pipe(&pp)
- if n != 0 {
- return err
- }
- p[0] = int(pp[0])
- p[1] = int(pp[1])
- return nil
-}
-
-func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
- if sa.Port < 0 || sa.Port > 0xFFFF {
- return nil, 0, EINVAL
- }
- sa.raw.Family = AF_INET
- p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
- p[0] = byte(sa.Port >> 8)
- p[1] = byte(sa.Port)
- for i := 0; i < len(sa.Addr); i++ {
- sa.raw.Addr[i] = sa.Addr[i]
- }
- return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil
-}
-
-func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
- if sa.Port < 0 || sa.Port > 0xFFFF {
- return nil, 0, EINVAL
- }
- sa.raw.Family = AF_INET6
- p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
- p[0] = byte(sa.Port >> 8)
- p[1] = byte(sa.Port)
- sa.raw.Scope_id = sa.ZoneId
- for i := 0; i < len(sa.Addr); i++ {
- sa.raw.Addr[i] = sa.Addr[i]
- }
- return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil
-}
-
-func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
- name := sa.Name
- n := len(name)
- if n >= len(sa.raw.Path) {
- return nil, 0, EINVAL
- }
- sa.raw.Family = AF_UNIX
- for i := 0; i < n; i++ {
- sa.raw.Path[i] = int8(name[i])
- }
- // length is family (uint16), name, NUL.
- sl := _Socklen(2)
- if n > 0 {
- sl += _Socklen(n) + 1
- }
- if sa.raw.Path[0] == '@' {
- sa.raw.Path[0] = 0
- // Don't count trailing NUL for abstract address.
- sl--
- }
-
- return unsafe.Pointer(&sa.raw), sl, nil
-}
-
-//sys getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getsockname
-
-func Getsockname(fd int) (sa Sockaddr, err error) {
- var rsa RawSockaddrAny
- var len _Socklen = SizeofSockaddrAny
- if err = getsockname(fd, &rsa, &len); err != nil {
- return
- }
- return anyToSockaddr(&rsa)
-}
-
-const ImplementsGetwd = true
-
-//sys Getcwd(buf []byte) (n int, err error)
-
-func Getwd() (wd string, err error) {
- var buf [PathMax]byte
- // Getcwd will return an error if it failed for any reason.
- _, err = Getcwd(buf[0:])
- if err != nil {
- return "", err
- }
- n := clen(buf[:])
- if n < 1 {
- return "", EINVAL
- }
- return string(buf[:n]), nil
-}
-
-/*
- * Wrapped
- */
-
-//sysnb getgroups(ngid int, gid *_Gid_t) (n int, err error)
-//sysnb setgroups(ngid int, gid *_Gid_t) (err error)
-
-func Getgroups() (gids []int, err error) {
- n, err := getgroups(0, nil)
- // Check for error and sanity check group count. Newer versions of
- // Solaris allow up to 1024 (NGROUPS_MAX).
- if n < 0 || n > 1024 {
- if err != nil {
- return nil, err
- }
- return nil, EINVAL
- } else if n == 0 {
- return nil, nil
- }
-
- a := make([]_Gid_t, n)
- n, err = getgroups(n, &a[0])
- if n == -1 {
- return nil, err
- }
- gids = make([]int, n)
- for i, v := range a[0:n] {
- gids[i] = int(v)
- }
- return
-}
-
-func Setgroups(gids []int) (err error) {
- if len(gids) == 0 {
- return setgroups(0, nil)
- }
-
- a := make([]_Gid_t, len(gids))
- for i, v := range gids {
- a[i] = _Gid_t(v)
- }
- return setgroups(len(a), &a[0])
-}
-
-func ReadDirent(fd int, buf []byte) (n int, err error) {
- // Final argument is (basep *uintptr) and the syscall doesn't take nil.
- // TODO(rsc): Can we use a single global basep for all calls?
- return Getdents(fd, buf, new(uintptr))
-}
-
-// Wait status is 7 bits at bottom, either 0 (exited),
-// 0x7F (stopped), or a signal number that caused an exit.
-// The 0x80 bit is whether there was a core dump.
-// An extra number (exit code, signal causing a stop)
-// is in the high bits.
-
-type WaitStatus uint32
-
-const (
- mask = 0x7F
- core = 0x80
- shift = 8
-
- exited = 0
- stopped = 0x7F
-)
-
-func (w WaitStatus) Exited() bool { return w&mask == exited }
-
-func (w WaitStatus) ExitStatus() int {
- if w&mask != exited {
- return -1
- }
- return int(w >> shift)
-}
-
-func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 }
-
-func (w WaitStatus) Signal() syscall.Signal {
- sig := syscall.Signal(w & mask)
- if sig == stopped || sig == 0 {
- return -1
- }
- return sig
-}
-
-func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 }
-
-func (w WaitStatus) Stopped() bool { return w&mask == stopped && syscall.Signal(w>>shift) != SIGSTOP }
-
-func (w WaitStatus) Continued() bool { return w&mask == stopped && syscall.Signal(w>>shift) == SIGSTOP }
-
-func (w WaitStatus) StopSignal() syscall.Signal {
- if !w.Stopped() {
- return -1
- }
- return syscall.Signal(w>>shift) & 0xFF
-}
-
-func (w WaitStatus) TrapCause() int { return -1 }
-
-//sys wait4(pid int32, statusp *_C_int, options int, rusage *Rusage) (wpid int32, err error)
-
-func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (int, error) {
- var status _C_int
- rpid, err := wait4(int32(pid), &status, options, rusage)
- wpid := int(rpid)
- if wpid == -1 {
- return wpid, err
- }
- if wstatus != nil {
- *wstatus = WaitStatus(status)
- }
- return wpid, nil
-}
-
-//sys gethostname(buf []byte) (n int, err error)
-
-func Gethostname() (name string, err error) {
- var buf [MaxHostNameLen]byte
- n, err := gethostname(buf[:])
- if n != 0 {
- return "", err
- }
- n = clen(buf[:])
- if n < 1 {
- return "", EFAULT
- }
- return string(buf[:n]), nil
-}
-
-//sys utimes(path string, times *[2]Timeval) (err error)
-
-func Utimes(path string, tv []Timeval) (err error) {
- if tv == nil {
- return utimes(path, nil)
- }
- if len(tv) != 2 {
- return EINVAL
- }
- return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
-}
-
-//sys utimensat(fd int, path string, times *[2]Timespec, flag int) (err error)
-
-func UtimesNano(path string, ts []Timespec) error {
- if ts == nil {
- return utimensat(AT_FDCWD, path, nil, 0)
- }
- if len(ts) != 2 {
- return EINVAL
- }
- return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
-}
-
-func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error {
- if ts == nil {
- return utimensat(dirfd, path, nil, flags)
- }
- if len(ts) != 2 {
- return EINVAL
- }
- return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags)
-}
-
-//sys fcntl(fd int, cmd int, arg int) (val int, err error)
-
-// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
-func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(lk)), 0, 0, 0)
- if e1 != 0 {
- return e1
- }
- return nil
-}
-
-//sys futimesat(fildes int, path *byte, times *[2]Timeval) (err error)
-
-func Futimesat(dirfd int, path string, tv []Timeval) error {
- pathp, err := BytePtrFromString(path)
- if err != nil {
- return err
- }
- if tv == nil {
- return futimesat(dirfd, pathp, nil)
- }
- if len(tv) != 2 {
- return EINVAL
- }
- return futimesat(dirfd, pathp, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
-}
-
-// Solaris doesn't have an futimes function because it allows NULL to be
-// specified as the path for futimesat. However, Go doesn't like
-// NULL-style string interfaces, so this simple wrapper is provided.
-func Futimes(fd int, tv []Timeval) error {
- if tv == nil {
- return futimesat(fd, nil, nil)
- }
- if len(tv) != 2 {
- return EINVAL
- }
- return futimesat(fd, nil, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
-}
-
-func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
- switch rsa.Addr.Family {
- case AF_UNIX:
- pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
- sa := new(SockaddrUnix)
- // Assume path ends at NUL.
- // This is not technically the Solaris semantics for
- // abstract Unix domain sockets -- they are supposed
- // to be uninterpreted fixed-size binary blobs -- but
- // everyone uses this convention.
- n := 0
- for n < len(pp.Path) && pp.Path[n] != 0 {
- n++
- }
- bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
- sa.Name = string(bytes)
- return sa, nil
-
- case AF_INET:
- pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
- sa := new(SockaddrInet4)
- p := (*[2]byte)(unsafe.Pointer(&pp.Port))
- sa.Port = int(p[0])<<8 + int(p[1])
- for i := 0; i < len(sa.Addr); i++ {
- sa.Addr[i] = pp.Addr[i]
- }
- return sa, nil
-
- case AF_INET6:
- pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
- sa := new(SockaddrInet6)
- p := (*[2]byte)(unsafe.Pointer(&pp.Port))
- sa.Port = int(p[0])<<8 + int(p[1])
- sa.ZoneId = pp.Scope_id
- for i := 0; i < len(sa.Addr); i++ {
- sa.Addr[i] = pp.Addr[i]
- }
- return sa, nil
- }
- return nil, EAFNOSUPPORT
-}
-
-//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) = libsocket.accept
-
-func Accept(fd int) (nfd int, sa Sockaddr, err error) {
- var rsa RawSockaddrAny
- var len _Socklen = SizeofSockaddrAny
- nfd, err = accept(fd, &rsa, &len)
- if nfd == -1 {
- return
- }
- sa, err = anyToSockaddr(&rsa)
- if err != nil {
- Close(nfd)
- nfd = 0
- }
- return
-}
-
-//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.recvmsg
-
-func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
- var msg Msghdr
- var rsa RawSockaddrAny
- msg.Name = (*byte)(unsafe.Pointer(&rsa))
- msg.Namelen = uint32(SizeofSockaddrAny)
- var iov Iovec
- if len(p) > 0 {
- iov.Base = (*int8)(unsafe.Pointer(&p[0]))
- iov.SetLen(len(p))
- }
- var dummy int8
- if len(oob) > 0 {
- // receive at least one normal byte
- if len(p) == 0 {
- iov.Base = &dummy
- iov.SetLen(1)
- }
- msg.Accrights = (*int8)(unsafe.Pointer(&oob[0]))
- }
- msg.Iov = &iov
- msg.Iovlen = 1
- if n, err = recvmsg(fd, &msg, flags); n == -1 {
- return
- }
- oobn = int(msg.Accrightslen)
- // source address is only specified if the socket is unconnected
- if rsa.Addr.Family != AF_UNSPEC {
- from, err = anyToSockaddr(&rsa)
- }
- return
-}
-
-func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
- _, err = SendmsgN(fd, p, oob, to, flags)
- return
-}
-
-//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.sendmsg
-
-func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
- var ptr unsafe.Pointer
- var salen _Socklen
- if to != nil {
- ptr, salen, err = to.sockaddr()
- if err != nil {
- return 0, err
- }
- }
- var msg Msghdr
- msg.Name = (*byte)(unsafe.Pointer(ptr))
- msg.Namelen = uint32(salen)
- var iov Iovec
- if len(p) > 0 {
- iov.Base = (*int8)(unsafe.Pointer(&p[0]))
- iov.SetLen(len(p))
- }
- var dummy int8
- if len(oob) > 0 {
- // send at least one normal byte
- if len(p) == 0 {
- iov.Base = &dummy
- iov.SetLen(1)
- }
- msg.Accrights = (*int8)(unsafe.Pointer(&oob[0]))
- }
- msg.Iov = &iov
- msg.Iovlen = 1
- if n, err = sendmsg(fd, &msg, flags); err != nil {
- return 0, err
- }
- if len(oob) > 0 && len(p) == 0 {
- n = 0
- }
- return n, nil
-}
-
-//sys acct(path *byte) (err error)
-
-func Acct(path string) (err error) {
- if len(path) == 0 {
- // Assume caller wants to disable accounting.
- return acct(nil)
- }
-
- pathp, err := BytePtrFromString(path)
- if err != nil {
- return err
- }
- return acct(pathp)
-}
-
-/*
- * Expose the ioctl function
- */
-
-//sys ioctl(fd int, req int, arg uintptr) (err error)
-
-func IoctlSetInt(fd int, req int, value int) (err error) {
- return ioctl(fd, req, uintptr(value))
-}
-
-func IoctlSetWinsize(fd int, req int, value *Winsize) (err error) {
- return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
-}
-
-func IoctlSetTermios(fd int, req int, value *Termios) (err error) {
- return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
-}
-
-func IoctlSetTermio(fd int, req int, value *Termio) (err error) {
- return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
-}
-
-func IoctlGetInt(fd int, req int) (int, error) {
- var value int
- err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
- return value, err
-}
-
-func IoctlGetWinsize(fd int, req int) (*Winsize, error) {
- var value Winsize
- err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
- return &value, err
-}
-
-func IoctlGetTermios(fd int, req int) (*Termios, error) {
- var value Termios
- err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
- return &value, err
-}
-
-func IoctlGetTermio(fd int, req int) (*Termio, error) {
- var value Termio
- err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
- return &value, err
-}
-
-/*
- * Exposed directly
- */
-//sys Access(path string, mode uint32) (err error)
-//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
-//sys Chdir(path string) (err error)
-//sys Chmod(path string, mode uint32) (err error)
-//sys Chown(path string, uid int, gid int) (err error)
-//sys Chroot(path string) (err error)
-//sys Close(fd int) (err error)
-//sys Creat(path string, mode uint32) (fd int, err error)
-//sys Dup(fd int) (nfd int, err error)
-//sys Dup2(oldfd int, newfd int) (err error)
-//sys Exit(code int)
-//sys Fchdir(fd int) (err error)
-//sys Fchmod(fd int, mode uint32) (err error)
-//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
-//sys Fchown(fd int, uid int, gid int) (err error)
-//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
-//sys Fdatasync(fd int) (err error)
-//sys Fpathconf(fd int, name int) (val int, err error)
-//sys Fstat(fd int, stat *Stat_t) (err error)
-//sys Getdents(fd int, buf []byte, basep *uintptr) (n int, err error)
-//sysnb Getgid() (gid int)
-//sysnb Getpid() (pid int)
-//sysnb Getpgid(pid int) (pgid int, err error)
-//sysnb Getpgrp() (pgid int, err error)
-//sys Geteuid() (euid int)
-//sys Getegid() (egid int)
-//sys Getppid() (ppid int)
-//sys Getpriority(which int, who int) (n int, err error)
-//sysnb Getrlimit(which int, lim *Rlimit) (err error)
-//sysnb Getrusage(who int, rusage *Rusage) (err error)
-//sysnb Gettimeofday(tv *Timeval) (err error)
-//sysnb Getuid() (uid int)
-//sys Kill(pid int, signum syscall.Signal) (err error)
-//sys Lchown(path string, uid int, gid int) (err error)
-//sys Link(path string, link string) (err error)
-//sys Listen(s int, backlog int) (err error) = libsocket.listen
-//sys Lstat(path string, stat *Stat_t) (err error)
-//sys Madvise(b []byte, advice int) (err error)
-//sys Mkdir(path string, mode uint32) (err error)
-//sys Mkdirat(dirfd int, path string, mode uint32) (err error)
-//sys Mkfifo(path string, mode uint32) (err error)
-//sys Mkfifoat(dirfd int, path string, mode uint32) (err error)
-//sys Mknod(path string, mode uint32, dev int) (err error)
-//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
-//sys Mlock(b []byte) (err error)
-//sys Mlockall(flags int) (err error)
-//sys Mprotect(b []byte, prot int) (err error)
-//sys Munlock(b []byte) (err error)
-//sys Munlockall() (err error)
-//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
-//sys Open(path string, mode int, perm uint32) (fd int, err error)
-//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
-//sys Pathconf(path string, name int) (val int, err error)
-//sys Pause() (err error)
-//sys Pread(fd int, p []byte, offset int64) (n int, err error)
-//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
-//sys read(fd int, p []byte) (n int, err error)
-//sys Readlink(path string, buf []byte) (n int, err error)
-//sys Rename(from string, to string) (err error)
-//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
-//sys Rmdir(path string) (err error)
-//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = lseek
-//sysnb Setegid(egid int) (err error)
-//sysnb Seteuid(euid int) (err error)
-//sysnb Setgid(gid int) (err error)
-//sys Sethostname(p []byte) (err error)
-//sysnb Setpgid(pid int, pgid int) (err error)
-//sys Setpriority(which int, who int, prio int) (err error)
-//sysnb Setregid(rgid int, egid int) (err error)
-//sysnb Setreuid(ruid int, euid int) (err error)
-//sysnb Setrlimit(which int, lim *Rlimit) (err error)
-//sysnb Setsid() (pid int, err error)
-//sysnb Setuid(uid int) (err error)
-//sys Shutdown(s int, how int) (err error) = libsocket.shutdown
-//sys Stat(path string, stat *Stat_t) (err error)
-//sys Symlink(path string, link string) (err error)
-//sys Sync() (err error)
-//sysnb Times(tms *Tms) (ticks uintptr, err error)
-//sys Truncate(path string, length int64) (err error)
-//sys Fsync(fd int) (err error)
-//sys Ftruncate(fd int, length int64) (err error)
-//sys Umask(mask int) (oldmask int)
-//sysnb Uname(buf *Utsname) (err error)
-//sys Unmount(target string, flags int) (err error) = libc.umount
-//sys Unlink(path string) (err error)
-//sys Unlinkat(dirfd int, path string, flags int) (err error)
-//sys Ustat(dev int, ubuf *Ustat_t) (err error)
-//sys Utime(path string, buf *Utimbuf) (err error)
-//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.bind
-//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.connect
-//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
-//sys munmap(addr uintptr, length uintptr) (err error)
-//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.sendto
-//sys socket(domain int, typ int, proto int) (fd int, err error) = libsocket.socket
-//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) = libsocket.socketpair
-//sys write(fd int, p []byte) (n int, err error)
-//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) = libsocket.getsockopt
-//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getpeername
-//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) = libsocket.setsockopt
-//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) = libsocket.recvfrom
-
-func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procread)), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procwrite)), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-var mapper = &mmapper{
- active: make(map[*byte][]byte),
- mmap: mmap,
- munmap: munmap,
-}
-
-func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
- return mapper.Mmap(fd, offset, length, prot, flags)
-}
-
-func Munmap(b []byte) (err error) {
- return mapper.Munmap(b)
-}
-
-//sys sysconf(name int) (n int64, err error)
-
-// pageSize caches the value of Getpagesize, since it can't change
-// once the system is booted.
-var pageSize int64 // accessed atomically
-
-func Getpagesize() int {
- n := atomic.LoadInt64(&pageSize)
- if n == 0 {
- n, _ = sysconf(_SC_PAGESIZE)
- atomic.StoreInt64(&pageSize, n)
- }
- return int(n)
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/syscall_unix.go b/newt/vendor/golang.org/x/sys/unix/syscall_unix.go
deleted file mode 100644
index b46b2502..00000000
--- a/newt/vendor/golang.org/x/sys/unix/syscall_unix.go
+++ /dev/null
@@ -1,297 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build darwin dragonfly freebsd linux netbsd openbsd solaris
-
-package unix
-
-import (
- "runtime"
- "sync"
- "syscall"
- "unsafe"
-)
-
-var (
- Stdin = 0
- Stdout = 1
- Stderr = 2
-)
-
-const (
- darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8
- dragonfly64Bit = runtime.GOOS == "dragonfly" && sizeofPtr == 8
- netbsd32Bit = runtime.GOOS == "netbsd" && sizeofPtr == 4
-)
-
-// Do the interface allocations only once for common
-// Errno values.
-var (
- errEAGAIN error = syscall.EAGAIN
- errEINVAL error = syscall.EINVAL
- errENOENT error = syscall.ENOENT
-)
-
-// errnoErr returns common boxed Errno values, to prevent
-// allocations at runtime.
-func errnoErr(e syscall.Errno) error {
- switch e {
- case 0:
- return nil
- case EAGAIN:
- return errEAGAIN
- case EINVAL:
- return errEINVAL
- case ENOENT:
- return errENOENT
- }
- return e
-}
-
-func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)
-func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
-func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)
-func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
-
-// Mmap manager, for use by operating system-specific implementations.
-
-type mmapper struct {
- sync.Mutex
- active map[*byte][]byte // active mappings; key is last byte in mapping
- mmap func(addr, length uintptr, prot, flags, fd int, offset int64) (uintptr, error)
- munmap func(addr uintptr, length uintptr) error
-}
-
-func (m *mmapper) Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
- if length <= 0 {
- return nil, EINVAL
- }
-
- // Map the requested memory.
- addr, errno := m.mmap(0, uintptr(length), prot, flags, fd, offset)
- if errno != nil {
- return nil, errno
- }
-
- // Slice memory layout
- var sl = struct {
- addr uintptr
- len int
- cap int
- }{addr, length, length}
-
- // Use unsafe to turn sl into a []byte.
- b := *(*[]byte)(unsafe.Pointer(&sl))
-
- // Register mapping in m and return it.
- p := &b[cap(b)-1]
- m.Lock()
- defer m.Unlock()
- m.active[p] = b
- return b, nil
-}
-
-func (m *mmapper) Munmap(data []byte) (err error) {
- if len(data) == 0 || len(data) != cap(data) {
- return EINVAL
- }
-
- // Find the base of the mapping.
- p := &data[cap(data)-1]
- m.Lock()
- defer m.Unlock()
- b := m.active[p]
- if b == nil || &b[0] != &data[0] {
- return EINVAL
- }
-
- // Unmap the memory and update m.
- if errno := m.munmap(uintptr(unsafe.Pointer(&b[0])), uintptr(len(b))); errno != nil {
- return errno
- }
- delete(m.active, p)
- return nil
-}
-
-func Read(fd int, p []byte) (n int, err error) {
- n, err = read(fd, p)
- if raceenabled {
- if n > 0 {
- raceWriteRange(unsafe.Pointer(&p[0]), n)
- }
- if err == nil {
- raceAcquire(unsafe.Pointer(&ioSync))
- }
- }
- return
-}
-
-func Write(fd int, p []byte) (n int, err error) {
- if raceenabled {
- raceReleaseMerge(unsafe.Pointer(&ioSync))
- }
- n, err = write(fd, p)
- if raceenabled && n > 0 {
- raceReadRange(unsafe.Pointer(&p[0]), n)
- }
- return
-}
-
-// For testing: clients can set this flag to force
-// creation of IPv6 sockets to return EAFNOSUPPORT.
-var SocketDisableIPv6 bool
-
-type Sockaddr interface {
- sockaddr() (ptr unsafe.Pointer, len _Socklen, err error) // lowercase; only we can define Sockaddrs
-}
-
-type SockaddrInet4 struct {
- Port int
- Addr [4]byte
- raw RawSockaddrInet4
-}
-
-type SockaddrInet6 struct {
- Port int
- ZoneId uint32
- Addr [16]byte
- raw RawSockaddrInet6
-}
-
-type SockaddrUnix struct {
- Name string
- raw RawSockaddrUnix
-}
-
-func Bind(fd int, sa Sockaddr) (err error) {
- ptr, n, err := sa.sockaddr()
- if err != nil {
- return err
- }
- return bind(fd, ptr, n)
-}
-
-func Connect(fd int, sa Sockaddr) (err error) {
- ptr, n, err := sa.sockaddr()
- if err != nil {
- return err
- }
- return connect(fd, ptr, n)
-}
-
-func Getpeername(fd int) (sa Sockaddr, err error) {
- var rsa RawSockaddrAny
- var len _Socklen = SizeofSockaddrAny
- if err = getpeername(fd, &rsa, &len); err != nil {
- return
- }
- return anyToSockaddr(&rsa)
-}
-
-func GetsockoptInt(fd, level, opt int) (value int, err error) {
- var n int32
- vallen := _Socklen(4)
- err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen)
- return int(n), err
-}
-
-func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) {
- var rsa RawSockaddrAny
- var len _Socklen = SizeofSockaddrAny
- if n, err = recvfrom(fd, p, flags, &rsa, &len); err != nil {
- return
- }
- if rsa.Addr.Family != AF_UNSPEC {
- from, err = anyToSockaddr(&rsa)
- }
- return
-}
-
-func Sendto(fd int, p []byte, flags int, to Sockaddr) (err error) {
- ptr, n, err := to.sockaddr()
- if err != nil {
- return err
- }
- return sendto(fd, p, flags, ptr, n)
-}
-
-func SetsockoptByte(fd, level, opt int, value byte) (err error) {
- return setsockopt(fd, level, opt, unsafe.Pointer(&value), 1)
-}
-
-func SetsockoptInt(fd, level, opt int, value int) (err error) {
- var n = int32(value)
- return setsockopt(fd, level, opt, unsafe.Pointer(&n), 4)
-}
-
-func SetsockoptInet4Addr(fd, level, opt int, value [4]byte) (err error) {
- return setsockopt(fd, level, opt, unsafe.Pointer(&value[0]), 4)
-}
-
-func SetsockoptIPMreq(fd, level, opt int, mreq *IPMreq) (err error) {
- return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPMreq)
-}
-
-func SetsockoptIPv6Mreq(fd, level, opt int, mreq *IPv6Mreq) (err error) {
- return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPv6Mreq)
-}
-
-func SetsockoptICMPv6Filter(fd, level, opt int, filter *ICMPv6Filter) error {
- return setsockopt(fd, level, opt, unsafe.Pointer(filter), SizeofICMPv6Filter)
-}
-
-func SetsockoptLinger(fd, level, opt int, l *Linger) (err error) {
- return setsockopt(fd, level, opt, unsafe.Pointer(l), SizeofLinger)
-}
-
-func SetsockoptString(fd, level, opt int, s string) (err error) {
- return setsockopt(fd, level, opt, unsafe.Pointer(&[]byte(s)[0]), uintptr(len(s)))
-}
-
-func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (err error) {
- return setsockopt(fd, level, opt, unsafe.Pointer(tv), unsafe.Sizeof(*tv))
-}
-
-func Socket(domain, typ, proto int) (fd int, err error) {
- if domain == AF_INET6 && SocketDisableIPv6 {
- return -1, EAFNOSUPPORT
- }
- fd, err = socket(domain, typ, proto)
- return
-}
-
-func Socketpair(domain, typ, proto int) (fd [2]int, err error) {
- var fdx [2]int32
- err = socketpair(domain, typ, proto, &fdx)
- if err == nil {
- fd[0] = int(fdx[0])
- fd[1] = int(fdx[1])
- }
- return
-}
-
-func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- if raceenabled {
- raceReleaseMerge(unsafe.Pointer(&ioSync))
- }
- return sendfile(outfd, infd, offset, count)
-}
-
-var ioSync int64
-
-func CloseOnExec(fd int) { fcntl(fd, F_SETFD, FD_CLOEXEC) }
-
-func SetNonblock(fd int, nonblocking bool) (err error) {
- flag, err := fcntl(fd, F_GETFL, 0)
- if err != nil {
- return err
- }
- if nonblocking {
- flag |= O_NONBLOCK
- } else {
- flag &= ^O_NONBLOCK
- }
- _, err = fcntl(fd, F_SETFL, flag)
- return err
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/types_darwin.go b/newt/vendor/golang.org/x/sys/unix/types_darwin.go
deleted file mode 100644
index 11532618..00000000
--- a/newt/vendor/golang.org/x/sys/unix/types_darwin.go
+++ /dev/null
@@ -1,250 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-/*
-Input to cgo -godefs. See also mkerrors.sh and mkall.sh
-*/
-
-// +godefs map struct_in_addr [4]byte /* in_addr */
-// +godefs map struct_in6_addr [16]byte /* in6_addr */
-
-package unix
-
-/*
-#define __DARWIN_UNIX03 0
-#define KERNEL
-#define _DARWIN_USE_64_BIT_INODE
-#include <dirent.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <termios.h>
-#include <unistd.h>
-#include <mach/mach.h>
-#include <mach/message.h>
-#include <sys/event.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/param.h>
-#include <sys/ptrace.h>
-#include <sys/resource.h>
-#include <sys/select.h>
-#include <sys/signal.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <sys/un.h>
-#include <sys/wait.h>
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_var.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <netinet/icmp6.h>
-#include <netinet/tcp.h>
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-union sockaddr_all {
- struct sockaddr s1; // this one gets used for fields
- struct sockaddr_in s2; // these pad it out
- struct sockaddr_in6 s3;
- struct sockaddr_un s4;
- struct sockaddr_dl s5;
-};
-
-struct sockaddr_any {
- struct sockaddr addr;
- char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
-};
-
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
-)
-
-// Time
-
-type Timespec C.struct_timespec
-
-type Timeval C.struct_timeval
-
-type Timeval32 C.struct_timeval32
-
-// Processes
-
-type Rusage C.struct_rusage
-
-type Rlimit C.struct_rlimit
-
-type _Gid_t C.gid_t
-
-// Files
-
-type Stat_t C.struct_stat64
-
-type Statfs_t C.struct_statfs64
-
-type Flock_t C.struct_flock
-
-type Fstore_t C.struct_fstore
-
-type Radvisory_t C.struct_radvisory
-
-type Fbootstraptransfer_t C.struct_fbootstraptransfer
-
-type Log2phys_t C.struct_log2phys
-
-type Fsid C.struct_fsid
-
-type Dirent C.struct_dirent
-
-// Sockets
-
-type RawSockaddrInet4 C.struct_sockaddr_in
-
-type RawSockaddrInet6 C.struct_sockaddr_in6
-
-type RawSockaddrUnix C.struct_sockaddr_un
-
-type RawSockaddrDatalink C.struct_sockaddr_dl
-
-type RawSockaddr C.struct_sockaddr
-
-type RawSockaddrAny C.struct_sockaddr_any
-
-type _Socklen C.socklen_t
-
-type Linger C.struct_linger
-
-type Iovec C.struct_iovec
-
-type IPMreq C.struct_ip_mreq
-
-type IPv6Mreq C.struct_ipv6_mreq
-
-type Msghdr C.struct_msghdr
-
-type Cmsghdr C.struct_cmsghdr
-
-type Inet4Pktinfo C.struct_in_pktinfo
-
-type Inet6Pktinfo C.struct_in6_pktinfo
-
-type IPv6MTUInfo C.struct_ip6_mtuinfo
-
-type ICMPv6Filter C.struct_icmp6_filter
-
-const (
- SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
- SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
- SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
- SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
- SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
- SizeofLinger = C.sizeof_struct_linger
- SizeofIPMreq = C.sizeof_struct_ip_mreq
- SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
- SizeofMsghdr = C.sizeof_struct_msghdr
- SizeofCmsghdr = C.sizeof_struct_cmsghdr
- SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo
- SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
- SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
- SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
-)
-
-// Ptrace requests
-
-const (
- PTRACE_TRACEME = C.PT_TRACE_ME
- PTRACE_CONT = C.PT_CONTINUE
- PTRACE_KILL = C.PT_KILL
-)
-
-// Events (kqueue, kevent)
-
-type Kevent_t C.struct_kevent
-
-// Select
-
-type FdSet C.fd_set
-
-// Routing and interface messages
-
-const (
- SizeofIfMsghdr = C.sizeof_struct_if_msghdr
- SizeofIfData = C.sizeof_struct_if_data
- SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
- SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
- SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2
- SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
- SizeofRtMetrics = C.sizeof_struct_rt_metrics
-)
-
-type IfMsghdr C.struct_if_msghdr
-
-type IfData C.struct_if_data
-
-type IfaMsghdr C.struct_ifa_msghdr
-
-type IfmaMsghdr C.struct_ifma_msghdr
-
-type IfmaMsghdr2 C.struct_ifma_msghdr2
-
-type RtMsghdr C.struct_rt_msghdr
-
-type RtMetrics C.struct_rt_metrics
-
-// Berkeley packet filter
-
-const (
- SizeofBpfVersion = C.sizeof_struct_bpf_version
- SizeofBpfStat = C.sizeof_struct_bpf_stat
- SizeofBpfProgram = C.sizeof_struct_bpf_program
- SizeofBpfInsn = C.sizeof_struct_bpf_insn
- SizeofBpfHdr = C.sizeof_struct_bpf_hdr
-)
-
-type BpfVersion C.struct_bpf_version
-
-type BpfStat C.struct_bpf_stat
-
-type BpfProgram C.struct_bpf_program
-
-type BpfInsn C.struct_bpf_insn
-
-type BpfHdr C.struct_bpf_hdr
-
-// Terminal handling
-
-type Termios C.struct_termios
-
-// fchmodat-like syscalls.
-
-const (
- AT_FDCWD = C.AT_FDCWD
- AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/types_dragonfly.go b/newt/vendor/golang.org/x/sys/unix/types_dragonfly.go
deleted file mode 100644
index f3c971df..00000000
--- a/newt/vendor/golang.org/x/sys/unix/types_dragonfly.go
+++ /dev/null
@@ -1,242 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-/*
-Input to cgo -godefs. See also mkerrors.sh and mkall.sh
-*/
-
-// +godefs map struct_in_addr [4]byte /* in_addr */
-// +godefs map struct_in6_addr [16]byte /* in6_addr */
-
-package unix
-
-/*
-#define KERNEL
-#include <dirent.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <termios.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/event.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/param.h>
-#include <sys/ptrace.h>
-#include <sys/resource.h>
-#include <sys/select.h>
-#include <sys/signal.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/un.h>
-#include <sys/wait.h>
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <netinet/icmp6.h>
-#include <netinet/tcp.h>
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-union sockaddr_all {
- struct sockaddr s1; // this one gets used for fields
- struct sockaddr_in s2; // these pad it out
- struct sockaddr_in6 s3;
- struct sockaddr_un s4;
- struct sockaddr_dl s5;
-};
-
-struct sockaddr_any {
- struct sockaddr addr;
- char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
-};
-
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
-)
-
-// Time
-
-type Timespec C.struct_timespec
-
-type Timeval C.struct_timeval
-
-// Processes
-
-type Rusage C.struct_rusage
-
-type Rlimit C.struct_rlimit
-
-type _Gid_t C.gid_t
-
-// Files
-
-const ( // Directory mode bits
- S_IFMT = C.S_IFMT
- S_IFIFO = C.S_IFIFO
- S_IFCHR = C.S_IFCHR
- S_IFDIR = C.S_IFDIR
- S_IFBLK = C.S_IFBLK
- S_IFREG = C.S_IFREG
- S_IFLNK = C.S_IFLNK
- S_IFSOCK = C.S_IFSOCK
- S_ISUID = C.S_ISUID
- S_ISGID = C.S_ISGID
- S_ISVTX = C.S_ISVTX
- S_IRUSR = C.S_IRUSR
- S_IWUSR = C.S_IWUSR
- S_IXUSR = C.S_IXUSR
-)
-
-type Stat_t C.struct_stat
-
-type Statfs_t C.struct_statfs
-
-type Flock_t C.struct_flock
-
-type Dirent C.struct_dirent
-
-type Fsid C.struct_fsid
-
-// Sockets
-
-type RawSockaddrInet4 C.struct_sockaddr_in
-
-type RawSockaddrInet6 C.struct_sockaddr_in6
-
-type RawSockaddrUnix C.struct_sockaddr_un
-
-type RawSockaddrDatalink C.struct_sockaddr_dl
-
-type RawSockaddr C.struct_sockaddr
-
-type RawSockaddrAny C.struct_sockaddr_any
-
-type _Socklen C.socklen_t
-
-type Linger C.struct_linger
-
-type Iovec C.struct_iovec
-
-type IPMreq C.struct_ip_mreq
-
-type IPv6Mreq C.struct_ipv6_mreq
-
-type Msghdr C.struct_msghdr
-
-type Cmsghdr C.struct_cmsghdr
-
-type Inet6Pktinfo C.struct_in6_pktinfo
-
-type IPv6MTUInfo C.struct_ip6_mtuinfo
-
-type ICMPv6Filter C.struct_icmp6_filter
-
-const (
- SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
- SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
- SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
- SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
- SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
- SizeofLinger = C.sizeof_struct_linger
- SizeofIPMreq = C.sizeof_struct_ip_mreq
- SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
- SizeofMsghdr = C.sizeof_struct_msghdr
- SizeofCmsghdr = C.sizeof_struct_cmsghdr
- SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
- SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
- SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
-)
-
-// Ptrace requests
-
-const (
- PTRACE_TRACEME = C.PT_TRACE_ME
- PTRACE_CONT = C.PT_CONTINUE
- PTRACE_KILL = C.PT_KILL
-)
-
-// Events (kqueue, kevent)
-
-type Kevent_t C.struct_kevent
-
-// Select
-
-type FdSet C.fd_set
-
-// Routing and interface messages
-
-const (
- SizeofIfMsghdr = C.sizeof_struct_if_msghdr
- SizeofIfData = C.sizeof_struct_if_data
- SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
- SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
- SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
- SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
- SizeofRtMetrics = C.sizeof_struct_rt_metrics
-)
-
-type IfMsghdr C.struct_if_msghdr
-
-type IfData C.struct_if_data
-
-type IfaMsghdr C.struct_ifa_msghdr
-
-type IfmaMsghdr C.struct_ifma_msghdr
-
-type IfAnnounceMsghdr C.struct_if_announcemsghdr
-
-type RtMsghdr C.struct_rt_msghdr
-
-type RtMetrics C.struct_rt_metrics
-
-// Berkeley packet filter
-
-const (
- SizeofBpfVersion = C.sizeof_struct_bpf_version
- SizeofBpfStat = C.sizeof_struct_bpf_stat
- SizeofBpfProgram = C.sizeof_struct_bpf_program
- SizeofBpfInsn = C.sizeof_struct_bpf_insn
- SizeofBpfHdr = C.sizeof_struct_bpf_hdr
-)
-
-type BpfVersion C.struct_bpf_version
-
-type BpfStat C.struct_bpf_stat
-
-type BpfProgram C.struct_bpf_program
-
-type BpfInsn C.struct_bpf_insn
-
-type BpfHdr C.struct_bpf_hdr
-
-// Terminal handling
-
-type Termios C.struct_termios
diff --git a/newt/vendor/golang.org/x/sys/unix/types_freebsd.go b/newt/vendor/golang.org/x/sys/unix/types_freebsd.go
deleted file mode 100644
index ae24557a..00000000
--- a/newt/vendor/golang.org/x/sys/unix/types_freebsd.go
+++ /dev/null
@@ -1,353 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-/*
-Input to cgo -godefs. See also mkerrors.sh and mkall.sh
-*/
-
-// +godefs map struct_in_addr [4]byte /* in_addr */
-// +godefs map struct_in6_addr [16]byte /* in6_addr */
-
-package unix
-
-/*
-#define KERNEL
-#include <dirent.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <termios.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/event.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/param.h>
-#include <sys/ptrace.h>
-#include <sys/resource.h>
-#include <sys/select.h>
-#include <sys/signal.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/un.h>
-#include <sys/wait.h>
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <netinet/icmp6.h>
-#include <netinet/tcp.h>
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-union sockaddr_all {
- struct sockaddr s1; // this one gets used for fields
- struct sockaddr_in s2; // these pad it out
- struct sockaddr_in6 s3;
- struct sockaddr_un s4;
- struct sockaddr_dl s5;
-};
-
-struct sockaddr_any {
- struct sockaddr addr;
- char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
-};
-
-// This structure is a duplicate of stat on FreeBSD 8-STABLE.
-// See /usr/include/sys/stat.h.
-struct stat8 {
-#undef st_atimespec st_atim
-#undef st_mtimespec st_mtim
-#undef st_ctimespec st_ctim
-#undef st_birthtimespec st_birthtim
- __dev_t st_dev;
- ino_t st_ino;
- mode_t st_mode;
- nlink_t st_nlink;
- uid_t st_uid;
- gid_t st_gid;
- __dev_t st_rdev;
-#if __BSD_VISIBLE
- struct timespec st_atimespec;
- struct timespec st_mtimespec;
- struct timespec st_ctimespec;
-#else
- time_t st_atime;
- long __st_atimensec;
- time_t st_mtime;
- long __st_mtimensec;
- time_t st_ctime;
- long __st_ctimensec;
-#endif
- off_t st_size;
- blkcnt_t st_blocks;
- blksize_t st_blksize;
- fflags_t st_flags;
- __uint32_t st_gen;
- __int32_t st_lspare;
-#if __BSD_VISIBLE
- struct timespec st_birthtimespec;
- unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
- unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
-#else
- time_t st_birthtime;
- long st_birthtimensec;
- unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
- unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
-#endif
-};
-
-// This structure is a duplicate of if_data on FreeBSD 8-STABLE.
-// See /usr/include/net/if.h.
-struct if_data8 {
- u_char ifi_type;
- u_char ifi_physical;
- u_char ifi_addrlen;
- u_char ifi_hdrlen;
- u_char ifi_link_state;
- u_char ifi_spare_char1;
- u_char ifi_spare_char2;
- u_char ifi_datalen;
- u_long ifi_mtu;
- u_long ifi_metric;
- u_long ifi_baudrate;
- u_long ifi_ipackets;
- u_long ifi_ierrors;
- u_long ifi_opackets;
- u_long ifi_oerrors;
- u_long ifi_collisions;
- u_long ifi_ibytes;
- u_long ifi_obytes;
- u_long ifi_imcasts;
- u_long ifi_omcasts;
- u_long ifi_iqdrops;
- u_long ifi_noproto;
- u_long ifi_hwassist;
- time_t ifi_epoch;
- struct timeval ifi_lastchange;
-};
-
-// This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE.
-// See /usr/include/net/if.h.
-struct if_msghdr8 {
- u_short ifm_msglen;
- u_char ifm_version;
- u_char ifm_type;
- int ifm_addrs;
- int ifm_flags;
- u_short ifm_index;
- struct if_data8 ifm_data;
-};
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
-)
-
-// Time
-
-type Timespec C.struct_timespec
-
-type Timeval C.struct_timeval
-
-// Processes
-
-type Rusage C.struct_rusage
-
-type Rlimit C.struct_rlimit
-
-type _Gid_t C.gid_t
-
-// Files
-
-const ( // Directory mode bits
- S_IFMT = C.S_IFMT
- S_IFIFO = C.S_IFIFO
- S_IFCHR = C.S_IFCHR
- S_IFDIR = C.S_IFDIR
- S_IFBLK = C.S_IFBLK
- S_IFREG = C.S_IFREG
- S_IFLNK = C.S_IFLNK
- S_IFSOCK = C.S_IFSOCK
- S_ISUID = C.S_ISUID
- S_ISGID = C.S_ISGID
- S_ISVTX = C.S_ISVTX
- S_IRUSR = C.S_IRUSR
- S_IWUSR = C.S_IWUSR
- S_IXUSR = C.S_IXUSR
-)
-
-type Stat_t C.struct_stat8
-
-type Statfs_t C.struct_statfs
-
-type Flock_t C.struct_flock
-
-type Dirent C.struct_dirent
-
-type Fsid C.struct_fsid
-
-// Advice to Fadvise
-
-const (
- FADV_NORMAL = C.POSIX_FADV_NORMAL
- FADV_RANDOM = C.POSIX_FADV_RANDOM
- FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL
- FADV_WILLNEED = C.POSIX_FADV_WILLNEED
- FADV_DONTNEED = C.POSIX_FADV_DONTNEED
- FADV_NOREUSE = C.POSIX_FADV_NOREUSE
-)
-
-// Sockets
-
-type RawSockaddrInet4 C.struct_sockaddr_in
-
-type RawSockaddrInet6 C.struct_sockaddr_in6
-
-type RawSockaddrUnix C.struct_sockaddr_un
-
-type RawSockaddrDatalink C.struct_sockaddr_dl
-
-type RawSockaddr C.struct_sockaddr
-
-type RawSockaddrAny C.struct_sockaddr_any
-
-type _Socklen C.socklen_t
-
-type Linger C.struct_linger
-
-type Iovec C.struct_iovec
-
-type IPMreq C.struct_ip_mreq
-
-type IPMreqn C.struct_ip_mreqn
-
-type IPv6Mreq C.struct_ipv6_mreq
-
-type Msghdr C.struct_msghdr
-
-type Cmsghdr C.struct_cmsghdr
-
-type Inet6Pktinfo C.struct_in6_pktinfo
-
-type IPv6MTUInfo C.struct_ip6_mtuinfo
-
-type ICMPv6Filter C.struct_icmp6_filter
-
-const (
- SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
- SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
- SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
- SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
- SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
- SizeofLinger = C.sizeof_struct_linger
- SizeofIPMreq = C.sizeof_struct_ip_mreq
- SizeofIPMreqn = C.sizeof_struct_ip_mreqn
- SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
- SizeofMsghdr = C.sizeof_struct_msghdr
- SizeofCmsghdr = C.sizeof_struct_cmsghdr
- SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
- SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
- SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
-)
-
-// Ptrace requests
-
-const (
- PTRACE_TRACEME = C.PT_TRACE_ME
- PTRACE_CONT = C.PT_CONTINUE
- PTRACE_KILL = C.PT_KILL
-)
-
-// Events (kqueue, kevent)
-
-type Kevent_t C.struct_kevent
-
-// Select
-
-type FdSet C.fd_set
-
-// Routing and interface messages
-
-const (
- sizeofIfMsghdr = C.sizeof_struct_if_msghdr
- SizeofIfMsghdr = C.sizeof_struct_if_msghdr8
- sizeofIfData = C.sizeof_struct_if_data
- SizeofIfData = C.sizeof_struct_if_data8
- SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
- SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
- SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
- SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
- SizeofRtMetrics = C.sizeof_struct_rt_metrics
-)
-
-type ifMsghdr C.struct_if_msghdr
-
-type IfMsghdr C.struct_if_msghdr8
-
-type ifData C.struct_if_data
-
-type IfData C.struct_if_data8
-
-type IfaMsghdr C.struct_ifa_msghdr
-
-type IfmaMsghdr C.struct_ifma_msghdr
-
-type IfAnnounceMsghdr C.struct_if_announcemsghdr
-
-type RtMsghdr C.struct_rt_msghdr
-
-type RtMetrics C.struct_rt_metrics
-
-// Berkeley packet filter
-
-const (
- SizeofBpfVersion = C.sizeof_struct_bpf_version
- SizeofBpfStat = C.sizeof_struct_bpf_stat
- SizeofBpfZbuf = C.sizeof_struct_bpf_zbuf
- SizeofBpfProgram = C.sizeof_struct_bpf_program
- SizeofBpfInsn = C.sizeof_struct_bpf_insn
- SizeofBpfHdr = C.sizeof_struct_bpf_hdr
- SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header
-)
-
-type BpfVersion C.struct_bpf_version
-
-type BpfStat C.struct_bpf_stat
-
-type BpfZbuf C.struct_bpf_zbuf
-
-type BpfProgram C.struct_bpf_program
-
-type BpfInsn C.struct_bpf_insn
-
-type BpfHdr C.struct_bpf_hdr
-
-type BpfZbufHeader C.struct_bpf_zbuf_header
-
-// Terminal handling
-
-type Termios C.struct_termios
diff --git a/newt/vendor/golang.org/x/sys/unix/types_linux.go b/newt/vendor/golang.org/x/sys/unix/types_linux.go
deleted file mode 100644
index de80e2c8..00000000
--- a/newt/vendor/golang.org/x/sys/unix/types_linux.go
+++ /dev/null
@@ -1,457 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-/*
-Input to cgo -godefs. See also mkerrors.sh and mkall.sh
-*/
-
-// +godefs map struct_in_addr [4]byte /* in_addr */
-// +godefs map struct_in6_addr [16]byte /* in6_addr */
-
-package unix
-
-/*
-#define _LARGEFILE_SOURCE
-#define _LARGEFILE64_SOURCE
-#define _FILE_OFFSET_BITS 64
-#define _GNU_SOURCE
-
-#include <dirent.h>
-#include <fcntl.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <netpacket/packet.h>
-#include <poll.h>
-#include <signal.h>
-#include <stdio.h>
-#include <sys/epoll.h>
-#include <sys/inotify.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/param.h>
-#include <sys/ptrace.h>
-#include <sys/resource.h>
-#include <sys/select.h>
-#include <sys/signal.h>
-#include <sys/stat.h>
-#include <sys/statfs.h>
-#include <sys/sysinfo.h>
-#include <sys/time.h>
-#include <sys/times.h>
-#include <sys/timex.h>
-#include <sys/types.h>
-#include <sys/un.h>
-#include <sys/user.h>
-#include <sys/utsname.h>
-#include <sys/wait.h>
-#include <linux/filter.h>
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>
-#include <linux/icmpv6.h>
-#include <asm/termbits.h>
-#include <time.h>
-#include <unistd.h>
-#include <ustat.h>
-#include <utime.h>
-#include <bluetooth/bluetooth.h>
-#include <bluetooth/hci.h>
-
-#ifdef TCSETS2
-// On systems that have "struct termios2" use this as type Termios.
-typedef struct termios2 termios_t;
-#else
-typedef struct termios termios_t;
-#endif
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-union sockaddr_all {
- struct sockaddr s1; // this one gets used for fields
- struct sockaddr_in s2; // these pad it out
- struct sockaddr_in6 s3;
- struct sockaddr_un s4;
- struct sockaddr_ll s5;
- struct sockaddr_nl s6;
-};
-
-struct sockaddr_any {
- struct sockaddr addr;
- char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
-};
-
-// copied from /usr/include/linux/un.h
-struct my_sockaddr_un {
- sa_family_t sun_family;
-#if defined(__ARM_EABI__) || defined(__powerpc64__)
- // on ARM char is by default unsigned
- signed char sun_path[108];
-#else
- char sun_path[108];
-#endif
-};
-
-#ifdef __ARM_EABI__
-typedef struct user_regs PtraceRegs;
-#elif defined(__aarch64__)
-typedef struct user_pt_regs PtraceRegs;
-#elif defined(__powerpc64__)
-typedef struct pt_regs PtraceRegs;
-#elif defined(__mips__)
-typedef struct user PtraceRegs;
-#elif defined(__s390x__)
-typedef struct _user_regs_struct PtraceRegs;
-#elif defined(__sparc__)
-#include <asm/ptrace.h>
-typedef struct pt_regs PtraceRegs;
-#else
-typedef struct user_regs_struct PtraceRegs;
-#endif
-
-#if defined(__s390x__)
-typedef struct _user_psw_struct ptracePsw;
-typedef struct _user_fpregs_struct ptraceFpregs;
-typedef struct _user_per_struct ptracePer;
-#else
-typedef struct {} ptracePsw;
-typedef struct {} ptraceFpregs;
-typedef struct {} ptracePer;
-#endif
-
-// The real epoll_event is a union, and godefs doesn't handle it well.
-struct my_epoll_event {
- uint32_t events;
-#if defined(__ARM_EABI__) || defined(__aarch64__)
- // padding is not specified in linux/eventpoll.h but added to conform to the
- // alignment requirements of EABI
- int32_t padFd;
-#elif defined(__powerpc64__) || defined(__s390x__) || defined(__sparc__)
- int32_t _padFd;
-#endif
- int32_t fd;
- int32_t pad;
-};
-
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
- PathMax = C.PATH_MAX
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
-)
-
-// Time
-
-type Timespec C.struct_timespec
-
-type Timeval C.struct_timeval
-
-type Timex C.struct_timex
-
-type Time_t C.time_t
-
-type Tms C.struct_tms
-
-type Utimbuf C.struct_utimbuf
-
-// Processes
-
-type Rusage C.struct_rusage
-
-type Rlimit C.struct_rlimit
-
-type _Gid_t C.gid_t
-
-// Files
-
-type Stat_t C.struct_stat
-
-type Statfs_t C.struct_statfs
-
-type Dirent C.struct_dirent
-
-type Fsid C.fsid_t
-
-type Flock_t C.struct_flock
-
-// Advice to Fadvise
-
-const (
- FADV_NORMAL = C.POSIX_FADV_NORMAL
- FADV_RANDOM = C.POSIX_FADV_RANDOM
- FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL
- FADV_WILLNEED = C.POSIX_FADV_WILLNEED
- FADV_DONTNEED = C.POSIX_FADV_DONTNEED
- FADV_NOREUSE = C.POSIX_FADV_NOREUSE
-)
-
-// Sockets
-
-type RawSockaddrInet4 C.struct_sockaddr_in
-
-type RawSockaddrInet6 C.struct_sockaddr_in6
-
-type RawSockaddrUnix C.struct_my_sockaddr_un
-
-type RawSockaddrLinklayer C.struct_sockaddr_ll
-
-type RawSockaddrNetlink C.struct_sockaddr_nl
-
-type RawSockaddrHCI C.struct_sockaddr_hci
-
-type RawSockaddr C.struct_sockaddr
-
-type RawSockaddrAny C.struct_sockaddr_any
-
-type _Socklen C.socklen_t
-
-type Linger C.struct_linger
-
-type Iovec C.struct_iovec
-
-type IPMreq C.struct_ip_mreq
-
-type IPMreqn C.struct_ip_mreqn
-
-type IPv6Mreq C.struct_ipv6_mreq
-
-type Msghdr C.struct_msghdr
-
-type Cmsghdr C.struct_cmsghdr
-
-type Inet4Pktinfo C.struct_in_pktinfo
-
-type Inet6Pktinfo C.struct_in6_pktinfo
-
-type IPv6MTUInfo C.struct_ip6_mtuinfo
-
-type ICMPv6Filter C.struct_icmp6_filter
-
-type Ucred C.struct_ucred
-
-type TCPInfo C.struct_tcp_info
-
-const (
- SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
- SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
- SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
- SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
- SizeofSockaddrLinklayer = C.sizeof_struct_sockaddr_ll
- SizeofSockaddrNetlink = C.sizeof_struct_sockaddr_nl
- SizeofSockaddrHCI = C.sizeof_struct_sockaddr_hci
- SizeofLinger = C.sizeof_struct_linger
- SizeofIPMreq = C.sizeof_struct_ip_mreq
- SizeofIPMreqn = C.sizeof_struct_ip_mreqn
- SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
- SizeofMsghdr = C.sizeof_struct_msghdr
- SizeofCmsghdr = C.sizeof_struct_cmsghdr
- SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo
- SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
- SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
- SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
- SizeofUcred = C.sizeof_struct_ucred
- SizeofTCPInfo = C.sizeof_struct_tcp_info
-)
-
-// Netlink routing and interface messages
-
-const (
- IFA_UNSPEC = C.IFA_UNSPEC
- IFA_ADDRESS = C.IFA_ADDRESS
- IFA_LOCAL = C.IFA_LOCAL
- IFA_LABEL = C.IFA_LABEL
- IFA_BROADCAST = C.IFA_BROADCAST
- IFA_ANYCAST = C.IFA_ANYCAST
- IFA_CACHEINFO = C.IFA_CACHEINFO
- IFA_MULTICAST = C.IFA_MULTICAST
- IFLA_UNSPEC = C.IFLA_UNSPEC
- IFLA_ADDRESS = C.IFLA_ADDRESS
- IFLA_BROADCAST = C.IFLA_BROADCAST
- IFLA_IFNAME = C.IFLA_IFNAME
- IFLA_MTU = C.IFLA_MTU
- IFLA_LINK = C.IFLA_LINK
- IFLA_QDISC = C.IFLA_QDISC
- IFLA_STATS = C.IFLA_STATS
- IFLA_COST = C.IFLA_COST
- IFLA_PRIORITY = C.IFLA_PRIORITY
- IFLA_MASTER = C.IFLA_MASTER
- IFLA_WIRELESS = C.IFLA_WIRELESS
- IFLA_PROTINFO = C.IFLA_PROTINFO
- IFLA_TXQLEN = C.IFLA_TXQLEN
- IFLA_MAP = C.IFLA_MAP
- IFLA_WEIGHT = C.IFLA_WEIGHT
- IFLA_OPERSTATE = C.IFLA_OPERSTATE
- IFLA_LINKMODE = C.IFLA_LINKMODE
- IFLA_LINKINFO = C.IFLA_LINKINFO
- IFLA_NET_NS_PID = C.IFLA_NET_NS_PID
- IFLA_IFALIAS = C.IFLA_IFALIAS
- IFLA_MAX = C.IFLA_MAX
- RT_SCOPE_UNIVERSE = C.RT_SCOPE_UNIVERSE
- RT_SCOPE_SITE = C.RT_SCOPE_SITE
- RT_SCOPE_LINK = C.RT_SCOPE_LINK
- RT_SCOPE_HOST = C.RT_SCOPE_HOST
- RT_SCOPE_NOWHERE = C.RT_SCOPE_NOWHERE
- RT_TABLE_UNSPEC = C.RT_TABLE_UNSPEC
- RT_TABLE_COMPAT = C.RT_TABLE_COMPAT
- RT_TABLE_DEFAULT = C.RT_TABLE_DEFAULT
- RT_TABLE_MAIN = C.RT_TABLE_MAIN
- RT_TABLE_LOCAL = C.RT_TABLE_LOCAL
- RT_TABLE_MAX = C.RT_TABLE_MAX
- RTA_UNSPEC = C.RTA_UNSPEC
- RTA_DST = C.RTA_DST
- RTA_SRC = C.RTA_SRC
- RTA_IIF = C.RTA_IIF
- RTA_OIF = C.RTA_OIF
- RTA_GATEWAY = C.RTA_GATEWAY
- RTA_PRIORITY = C.RTA_PRIORITY
- RTA_PREFSRC = C.RTA_PREFSRC
- RTA_METRICS = C.RTA_METRICS
- RTA_MULTIPATH = C.RTA_MULTIPATH
- RTA_FLOW = C.RTA_FLOW
- RTA_CACHEINFO = C.RTA_CACHEINFO
- RTA_TABLE = C.RTA_TABLE
- RTN_UNSPEC = C.RTN_UNSPEC
- RTN_UNICAST = C.RTN_UNICAST
- RTN_LOCAL = C.RTN_LOCAL
- RTN_BROADCAST = C.RTN_BROADCAST
- RTN_ANYCAST = C.RTN_ANYCAST
- RTN_MULTICAST = C.RTN_MULTICAST
- RTN_BLACKHOLE = C.RTN_BLACKHOLE
- RTN_UNREACHABLE = C.RTN_UNREACHABLE
- RTN_PROHIBIT = C.RTN_PROHIBIT
- RTN_THROW = C.RTN_THROW
- RTN_NAT = C.RTN_NAT
- RTN_XRESOLVE = C.RTN_XRESOLVE
- RTNLGRP_NONE = C.RTNLGRP_NONE
- RTNLGRP_LINK = C.RTNLGRP_LINK
- RTNLGRP_NOTIFY = C.RTNLGRP_NOTIFY
- RTNLGRP_NEIGH = C.RTNLGRP_NEIGH
- RTNLGRP_TC = C.RTNLGRP_TC
- RTNLGRP_IPV4_IFADDR = C.RTNLGRP_IPV4_IFADDR
- RTNLGRP_IPV4_MROUTE = C.RTNLGRP_IPV4_MROUTE
- RTNLGRP_IPV4_ROUTE = C.RTNLGRP_IPV4_ROUTE
- RTNLGRP_IPV4_RULE = C.RTNLGRP_IPV4_RULE
- RTNLGRP_IPV6_IFADDR = C.RTNLGRP_IPV6_IFADDR
- RTNLGRP_IPV6_MROUTE = C.RTNLGRP_IPV6_MROUTE
- RTNLGRP_IPV6_ROUTE = C.RTNLGRP_IPV6_ROUTE
- RTNLGRP_IPV6_IFINFO = C.RTNLGRP_IPV6_IFINFO
- RTNLGRP_IPV6_PREFIX = C.RTNLGRP_IPV6_PREFIX
- RTNLGRP_IPV6_RULE = C.RTNLGRP_IPV6_RULE
- RTNLGRP_ND_USEROPT = C.RTNLGRP_ND_USEROPT
- SizeofNlMsghdr = C.sizeof_struct_nlmsghdr
- SizeofNlMsgerr = C.sizeof_struct_nlmsgerr
- SizeofRtGenmsg = C.sizeof_struct_rtgenmsg
- SizeofNlAttr = C.sizeof_struct_nlattr
- SizeofRtAttr = C.sizeof_struct_rtattr
- SizeofIfInfomsg = C.sizeof_struct_ifinfomsg
- SizeofIfAddrmsg = C.sizeof_struct_ifaddrmsg
- SizeofRtMsg = C.sizeof_struct_rtmsg
- SizeofRtNexthop = C.sizeof_struct_rtnexthop
-)
-
-type NlMsghdr C.struct_nlmsghdr
-
-type NlMsgerr C.struct_nlmsgerr
-
-type RtGenmsg C.struct_rtgenmsg
-
-type NlAttr C.struct_nlattr
-
-type RtAttr C.struct_rtattr
-
-type IfInfomsg C.struct_ifinfomsg
-
-type IfAddrmsg C.struct_ifaddrmsg
-
-type RtMsg C.struct_rtmsg
-
-type RtNexthop C.struct_rtnexthop
-
-// Linux socket filter
-
-const (
- SizeofSockFilter = C.sizeof_struct_sock_filter
- SizeofSockFprog = C.sizeof_struct_sock_fprog
-)
-
-type SockFilter C.struct_sock_filter
-
-type SockFprog C.struct_sock_fprog
-
-// Inotify
-
-type InotifyEvent C.struct_inotify_event
-
-const SizeofInotifyEvent = C.sizeof_struct_inotify_event
-
-// Ptrace
-
-// Register structures
-type PtraceRegs C.PtraceRegs
-
-// Structures contained in PtraceRegs on s390x (exported by mkpost.go)
-type ptracePsw C.ptracePsw
-
-type ptraceFpregs C.ptraceFpregs
-
-type ptracePer C.ptracePer
-
-// Misc
-
-type FdSet C.fd_set
-
-type Sysinfo_t C.struct_sysinfo
-
-type Utsname C.struct_utsname
-
-type Ustat_t C.struct_ustat
-
-type EpollEvent C.struct_my_epoll_event
-
-const (
- AT_FDCWD = C.AT_FDCWD
- AT_REMOVEDIR = C.AT_REMOVEDIR
- AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW
- AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
-)
-
-type PollFd C.struct_pollfd
-
-const (
- POLLIN = C.POLLIN
- POLLPRI = C.POLLPRI
- POLLOUT = C.POLLOUT
- POLLRDHUP = C.POLLRDHUP
- POLLERR = C.POLLERR
- POLLHUP = C.POLLHUP
- POLLNVAL = C.POLLNVAL
-)
-
-type Sigset_t C.sigset_t
-
-// sysconf information
-
-const _SC_PAGESIZE = C._SC_PAGESIZE
-
-// Terminal handling
-
-type Termios C.termios_t
diff --git a/newt/vendor/golang.org/x/sys/unix/types_netbsd.go b/newt/vendor/golang.org/x/sys/unix/types_netbsd.go
deleted file mode 100644
index d15f93d1..00000000
--- a/newt/vendor/golang.org/x/sys/unix/types_netbsd.go
+++ /dev/null
@@ -1,232 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-/*
-Input to cgo -godefs. See also mkerrors.sh and mkall.sh
-*/
-
-// +godefs map struct_in_addr [4]byte /* in_addr */
-// +godefs map struct_in6_addr [16]byte /* in6_addr */
-
-package unix
-
-/*
-#define KERNEL
-#include <dirent.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <termios.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/event.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/ptrace.h>
-#include <sys/resource.h>
-#include <sys/select.h>
-#include <sys/signal.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-#include <sys/time.h>
-#include <sys/uio.h>
-#include <sys/un.h>
-#include <sys/wait.h>
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <netinet/icmp6.h>
-#include <netinet/tcp.h>
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-union sockaddr_all {
- struct sockaddr s1; // this one gets used for fields
- struct sockaddr_in s2; // these pad it out
- struct sockaddr_in6 s3;
- struct sockaddr_un s4;
- struct sockaddr_dl s5;
-};
-
-struct sockaddr_any {
- struct sockaddr addr;
- char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
-};
-
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
-)
-
-// Time
-
-type Timespec C.struct_timespec
-
-type Timeval C.struct_timeval
-
-// Processes
-
-type Rusage C.struct_rusage
-
-type Rlimit C.struct_rlimit
-
-type _Gid_t C.gid_t
-
-// Files
-
-type Stat_t C.struct_stat
-
-type Statfs_t C.struct_statfs
-
-type Flock_t C.struct_flock
-
-type Dirent C.struct_dirent
-
-type Fsid C.fsid_t
-
-// Sockets
-
-type RawSockaddrInet4 C.struct_sockaddr_in
-
-type RawSockaddrInet6 C.struct_sockaddr_in6
-
-type RawSockaddrUnix C.struct_sockaddr_un
-
-type RawSockaddrDatalink C.struct_sockaddr_dl
-
-type RawSockaddr C.struct_sockaddr
-
-type RawSockaddrAny C.struct_sockaddr_any
-
-type _Socklen C.socklen_t
-
-type Linger C.struct_linger
-
-type Iovec C.struct_iovec
-
-type IPMreq C.struct_ip_mreq
-
-type IPv6Mreq C.struct_ipv6_mreq
-
-type Msghdr C.struct_msghdr
-
-type Cmsghdr C.struct_cmsghdr
-
-type Inet6Pktinfo C.struct_in6_pktinfo
-
-type IPv6MTUInfo C.struct_ip6_mtuinfo
-
-type ICMPv6Filter C.struct_icmp6_filter
-
-const (
- SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
- SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
- SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
- SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
- SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
- SizeofLinger = C.sizeof_struct_linger
- SizeofIPMreq = C.sizeof_struct_ip_mreq
- SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
- SizeofMsghdr = C.sizeof_struct_msghdr
- SizeofCmsghdr = C.sizeof_struct_cmsghdr
- SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
- SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
- SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
-)
-
-// Ptrace requests
-
-const (
- PTRACE_TRACEME = C.PT_TRACE_ME
- PTRACE_CONT = C.PT_CONTINUE
- PTRACE_KILL = C.PT_KILL
-)
-
-// Events (kqueue, kevent)
-
-type Kevent_t C.struct_kevent
-
-// Select
-
-type FdSet C.fd_set
-
-// Routing and interface messages
-
-const (
- SizeofIfMsghdr = C.sizeof_struct_if_msghdr
- SizeofIfData = C.sizeof_struct_if_data
- SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
- SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
- SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
- SizeofRtMetrics = C.sizeof_struct_rt_metrics
-)
-
-type IfMsghdr C.struct_if_msghdr
-
-type IfData C.struct_if_data
-
-type IfaMsghdr C.struct_ifa_msghdr
-
-type IfAnnounceMsghdr C.struct_if_announcemsghdr
-
-type RtMsghdr C.struct_rt_msghdr
-
-type RtMetrics C.struct_rt_metrics
-
-type Mclpool C.struct_mclpool
-
-// Berkeley packet filter
-
-const (
- SizeofBpfVersion = C.sizeof_struct_bpf_version
- SizeofBpfStat = C.sizeof_struct_bpf_stat
- SizeofBpfProgram = C.sizeof_struct_bpf_program
- SizeofBpfInsn = C.sizeof_struct_bpf_insn
- SizeofBpfHdr = C.sizeof_struct_bpf_hdr
-)
-
-type BpfVersion C.struct_bpf_version
-
-type BpfStat C.struct_bpf_stat
-
-type BpfProgram C.struct_bpf_program
-
-type BpfInsn C.struct_bpf_insn
-
-type BpfHdr C.struct_bpf_hdr
-
-type BpfTimeval C.struct_bpf_timeval
-
-// Terminal handling
-
-type Termios C.struct_termios
-
-// Sysctl
-
-type Sysctlnode C.struct_sysctlnode
diff --git a/newt/vendor/golang.org/x/sys/unix/types_openbsd.go b/newt/vendor/golang.org/x/sys/unix/types_openbsd.go
deleted file mode 100644
index b66fe25f..00000000
--- a/newt/vendor/golang.org/x/sys/unix/types_openbsd.go
+++ /dev/null
@@ -1,244 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-/*
-Input to cgo -godefs. See also mkerrors.sh and mkall.sh
-*/
-
-// +godefs map struct_in_addr [4]byte /* in_addr */
-// +godefs map struct_in6_addr [16]byte /* in6_addr */
-
-package unix
-
-/*
-#define KERNEL
-#include <dirent.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <termios.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/event.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/ptrace.h>
-#include <sys/resource.h>
-#include <sys/select.h>
-#include <sys/signal.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/uio.h>
-#include <sys/un.h>
-#include <sys/wait.h>
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <netinet/icmp6.h>
-#include <netinet/tcp.h>
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-union sockaddr_all {
- struct sockaddr s1; // this one gets used for fields
- struct sockaddr_in s2; // these pad it out
- struct sockaddr_in6 s3;
- struct sockaddr_un s4;
- struct sockaddr_dl s5;
-};
-
-struct sockaddr_any {
- struct sockaddr addr;
- char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
-};
-
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
-)
-
-// Time
-
-type Timespec C.struct_timespec
-
-type Timeval C.struct_timeval
-
-// Processes
-
-type Rusage C.struct_rusage
-
-type Rlimit C.struct_rlimit
-
-type _Gid_t C.gid_t
-
-// Files
-
-const ( // Directory mode bits
- S_IFMT = C.S_IFMT
- S_IFIFO = C.S_IFIFO
- S_IFCHR = C.S_IFCHR
- S_IFDIR = C.S_IFDIR
- S_IFBLK = C.S_IFBLK
- S_IFREG = C.S_IFREG
- S_IFLNK = C.S_IFLNK
- S_IFSOCK = C.S_IFSOCK
- S_ISUID = C.S_ISUID
- S_ISGID = C.S_ISGID
- S_ISVTX = C.S_ISVTX
- S_IRUSR = C.S_IRUSR
- S_IWUSR = C.S_IWUSR
- S_IXUSR = C.S_IXUSR
-)
-
-type Stat_t C.struct_stat
-
-type Statfs_t C.struct_statfs
-
-type Flock_t C.struct_flock
-
-type Dirent C.struct_dirent
-
-type Fsid C.fsid_t
-
-// Sockets
-
-type RawSockaddrInet4 C.struct_sockaddr_in
-
-type RawSockaddrInet6 C.struct_sockaddr_in6
-
-type RawSockaddrUnix C.struct_sockaddr_un
-
-type RawSockaddrDatalink C.struct_sockaddr_dl
-
-type RawSockaddr C.struct_sockaddr
-
-type RawSockaddrAny C.struct_sockaddr_any
-
-type _Socklen C.socklen_t
-
-type Linger C.struct_linger
-
-type Iovec C.struct_iovec
-
-type IPMreq C.struct_ip_mreq
-
-type IPv6Mreq C.struct_ipv6_mreq
-
-type Msghdr C.struct_msghdr
-
-type Cmsghdr C.struct_cmsghdr
-
-type Inet6Pktinfo C.struct_in6_pktinfo
-
-type IPv6MTUInfo C.struct_ip6_mtuinfo
-
-type ICMPv6Filter C.struct_icmp6_filter
-
-const (
- SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
- SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
- SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
- SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
- SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
- SizeofLinger = C.sizeof_struct_linger
- SizeofIPMreq = C.sizeof_struct_ip_mreq
- SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
- SizeofMsghdr = C.sizeof_struct_msghdr
- SizeofCmsghdr = C.sizeof_struct_cmsghdr
- SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
- SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
- SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
-)
-
-// Ptrace requests
-
-const (
- PTRACE_TRACEME = C.PT_TRACE_ME
- PTRACE_CONT = C.PT_CONTINUE
- PTRACE_KILL = C.PT_KILL
-)
-
-// Events (kqueue, kevent)
-
-type Kevent_t C.struct_kevent
-
-// Select
-
-type FdSet C.fd_set
-
-// Routing and interface messages
-
-const (
- SizeofIfMsghdr = C.sizeof_struct_if_msghdr
- SizeofIfData = C.sizeof_struct_if_data
- SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
- SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
- SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
- SizeofRtMetrics = C.sizeof_struct_rt_metrics
-)
-
-type IfMsghdr C.struct_if_msghdr
-
-type IfData C.struct_if_data
-
-type IfaMsghdr C.struct_ifa_msghdr
-
-type IfAnnounceMsghdr C.struct_if_announcemsghdr
-
-type RtMsghdr C.struct_rt_msghdr
-
-type RtMetrics C.struct_rt_metrics
-
-type Mclpool C.struct_mclpool
-
-// Berkeley packet filter
-
-const (
- SizeofBpfVersion = C.sizeof_struct_bpf_version
- SizeofBpfStat = C.sizeof_struct_bpf_stat
- SizeofBpfProgram = C.sizeof_struct_bpf_program
- SizeofBpfInsn = C.sizeof_struct_bpf_insn
- SizeofBpfHdr = C.sizeof_struct_bpf_hdr
-)
-
-type BpfVersion C.struct_bpf_version
-
-type BpfStat C.struct_bpf_stat
-
-type BpfProgram C.struct_bpf_program
-
-type BpfInsn C.struct_bpf_insn
-
-type BpfHdr C.struct_bpf_hdr
-
-type BpfTimeval C.struct_bpf_timeval
-
-// Terminal handling
-
-type Termios C.struct_termios
diff --git a/newt/vendor/golang.org/x/sys/unix/types_solaris.go b/newt/vendor/golang.org/x/sys/unix/types_solaris.go
deleted file mode 100644
index c5d5c8f1..00000000
--- a/newt/vendor/golang.org/x/sys/unix/types_solaris.go
+++ /dev/null
@@ -1,262 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-/*
-Input to cgo -godefs. See also mkerrors.sh and mkall.sh
-*/
-
-// +godefs map struct_in_addr [4]byte /* in_addr */
-// +godefs map struct_in6_addr [16]byte /* in6_addr */
-
-package unix
-
-/*
-#define KERNEL
-// These defines ensure that builds done on newer versions of Solaris are
-// backwards-compatible with older versions of Solaris and
-// OpenSolaris-based derivatives.
-#define __USE_SUNOS_SOCKETS__ // msghdr
-#define __USE_LEGACY_PROTOTYPES__ // iovec
-#include <dirent.h>
-#include <fcntl.h>
-#include <netdb.h>
-#include <limits.h>
-#include <signal.h>
-#include <termios.h>
-#include <termio.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/param.h>
-#include <sys/resource.h>
-#include <sys/select.h>
-#include <sys/signal.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/times.h>
-#include <sys/types.h>
-#include <sys/utsname.h>
-#include <sys/un.h>
-#include <sys/wait.h>
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <netinet/icmp6.h>
-#include <netinet/tcp.h>
-#include <ustat.h>
-#include <utime.h>
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-union sockaddr_all {
- struct sockaddr s1; // this one gets used for fields
- struct sockaddr_in s2; // these pad it out
- struct sockaddr_in6 s3;
- struct sockaddr_un s4;
- struct sockaddr_dl s5;
-};
-
-struct sockaddr_any {
- struct sockaddr addr;
- char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
-};
-
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
- PathMax = C.PATH_MAX
- MaxHostNameLen = C.MAXHOSTNAMELEN
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
-)
-
-// Time
-
-type Timespec C.struct_timespec
-
-type Timeval C.struct_timeval
-
-type Timeval32 C.struct_timeval32
-
-type Tms C.struct_tms
-
-type Utimbuf C.struct_utimbuf
-
-// Processes
-
-type Rusage C.struct_rusage
-
-type Rlimit C.struct_rlimit
-
-type _Gid_t C.gid_t
-
-// Files
-
-const ( // Directory mode bits
- S_IFMT = C.S_IFMT
- S_IFIFO = C.S_IFIFO
- S_IFCHR = C.S_IFCHR
- S_IFDIR = C.S_IFDIR
- S_IFBLK = C.S_IFBLK
- S_IFREG = C.S_IFREG
- S_IFLNK = C.S_IFLNK
- S_IFSOCK = C.S_IFSOCK
- S_ISUID = C.S_ISUID
- S_ISGID = C.S_ISGID
- S_ISVTX = C.S_ISVTX
- S_IRUSR = C.S_IRUSR
- S_IWUSR = C.S_IWUSR
- S_IXUSR = C.S_IXUSR
-)
-
-type Stat_t C.struct_stat
-
-type Flock_t C.struct_flock
-
-type Dirent C.struct_dirent
-
-// Sockets
-
-type RawSockaddrInet4 C.struct_sockaddr_in
-
-type RawSockaddrInet6 C.struct_sockaddr_in6
-
-type RawSockaddrUnix C.struct_sockaddr_un
-
-type RawSockaddrDatalink C.struct_sockaddr_dl
-
-type RawSockaddr C.struct_sockaddr
-
-type RawSockaddrAny C.struct_sockaddr_any
-
-type _Socklen C.socklen_t
-
-type Linger C.struct_linger
-
-type Iovec C.struct_iovec
-
-type IPMreq C.struct_ip_mreq
-
-type IPv6Mreq C.struct_ipv6_mreq
-
-type Msghdr C.struct_msghdr
-
-type Cmsghdr C.struct_cmsghdr
-
-type Inet6Pktinfo C.struct_in6_pktinfo
-
-type IPv6MTUInfo C.struct_ip6_mtuinfo
-
-type ICMPv6Filter C.struct_icmp6_filter
-
-const (
- SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
- SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
- SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
- SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
- SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
- SizeofLinger = C.sizeof_struct_linger
- SizeofIPMreq = C.sizeof_struct_ip_mreq
- SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
- SizeofMsghdr = C.sizeof_struct_msghdr
- SizeofCmsghdr = C.sizeof_struct_cmsghdr
- SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
- SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
- SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
-)
-
-// Select
-
-type FdSet C.fd_set
-
-// Misc
-
-type Utsname C.struct_utsname
-
-type Ustat_t C.struct_ustat
-
-const (
- AT_FDCWD = C.AT_FDCWD
- AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
- AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW
- AT_REMOVEDIR = C.AT_REMOVEDIR
- AT_EACCESS = C.AT_EACCESS
-)
-
-// Routing and interface messages
-
-const (
- SizeofIfMsghdr = C.sizeof_struct_if_msghdr
- SizeofIfData = C.sizeof_struct_if_data
- SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
- SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
- SizeofRtMetrics = C.sizeof_struct_rt_metrics
-)
-
-type IfMsghdr C.struct_if_msghdr
-
-type IfData C.struct_if_data
-
-type IfaMsghdr C.struct_ifa_msghdr
-
-type RtMsghdr C.struct_rt_msghdr
-
-type RtMetrics C.struct_rt_metrics
-
-// Berkeley packet filter
-
-const (
- SizeofBpfVersion = C.sizeof_struct_bpf_version
- SizeofBpfStat = C.sizeof_struct_bpf_stat
- SizeofBpfProgram = C.sizeof_struct_bpf_program
- SizeofBpfInsn = C.sizeof_struct_bpf_insn
- SizeofBpfHdr = C.sizeof_struct_bpf_hdr
-)
-
-type BpfVersion C.struct_bpf_version
-
-type BpfStat C.struct_bpf_stat
-
-type BpfProgram C.struct_bpf_program
-
-type BpfInsn C.struct_bpf_insn
-
-type BpfTimeval C.struct_bpf_timeval
-
-type BpfHdr C.struct_bpf_hdr
-
-// sysconf information
-
-const _SC_PAGESIZE = C._SC_PAGESIZE
-
-// Terminal handling
-
-type Termios C.struct_termios
-
-type Termio C.struct_termio
-
-type Winsize C.struct_winsize
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go b/newt/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go
deleted file mode 100644
index 8e638883..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go
+++ /dev/null
@@ -1,1576 +0,0 @@
-// mkerrors.sh -m32
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build 386,darwin
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -m32 _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_APPLETALK = 0x10
- AF_CCITT = 0xa
- AF_CHAOS = 0x5
- AF_CNT = 0x15
- AF_COIP = 0x14
- AF_DATAKIT = 0x9
- AF_DECnet = 0xc
- AF_DLI = 0xd
- AF_E164 = 0x1c
- AF_ECMA = 0x8
- AF_HYLINK = 0xf
- AF_IEEE80211 = 0x25
- AF_IMPLINK = 0x3
- AF_INET = 0x2
- AF_INET6 = 0x1e
- AF_IPX = 0x17
- AF_ISDN = 0x1c
- AF_ISO = 0x7
- AF_LAT = 0xe
- AF_LINK = 0x12
- AF_LOCAL = 0x1
- AF_MAX = 0x28
- AF_NATM = 0x1f
- AF_NDRV = 0x1b
- AF_NETBIOS = 0x21
- AF_NS = 0x6
- AF_OSI = 0x7
- AF_PPP = 0x22
- AF_PUP = 0x4
- AF_RESERVED_36 = 0x24
- AF_ROUTE = 0x11
- AF_SIP = 0x18
- AF_SNA = 0xb
- AF_SYSTEM = 0x20
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_UTUN = 0x26
- B0 = 0x0
- B110 = 0x6e
- B115200 = 0x1c200
- B1200 = 0x4b0
- B134 = 0x86
- B14400 = 0x3840
- B150 = 0x96
- B1800 = 0x708
- B19200 = 0x4b00
- B200 = 0xc8
- B230400 = 0x38400
- B2400 = 0x960
- B28800 = 0x7080
- B300 = 0x12c
- B38400 = 0x9600
- B4800 = 0x12c0
- B50 = 0x32
- B57600 = 0xe100
- B600 = 0x258
- B7200 = 0x1c20
- B75 = 0x4b
- B76800 = 0x12c00
- B9600 = 0x2580
- BIOCFLUSH = 0x20004268
- BIOCGBLEN = 0x40044266
- BIOCGDLT = 0x4004426a
- BIOCGDLTLIST = 0xc00c4279
- BIOCGETIF = 0x4020426b
- BIOCGHDRCMPLT = 0x40044274
- BIOCGRSIG = 0x40044272
- BIOCGRTIMEOUT = 0x4008426e
- BIOCGSEESENT = 0x40044276
- BIOCGSTATS = 0x4008426f
- BIOCIMMEDIATE = 0x80044270
- BIOCPROMISC = 0x20004269
- BIOCSBLEN = 0xc0044266
- BIOCSDLT = 0x80044278
- BIOCSETF = 0x80084267
- BIOCSETFNR = 0x8008427e
- BIOCSETIF = 0x8020426c
- BIOCSHDRCMPLT = 0x80044275
- BIOCSRSIG = 0x80044273
- BIOCSRTIMEOUT = 0x8008426d
- BIOCSSEESENT = 0x80044277
- BIOCVERSION = 0x40044271
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALIGNMENT = 0x4
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXBUFSIZE = 0x80000
- BPF_MAXINSNS = 0x200
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINBUFSIZE = 0x20
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RELEASE = 0x30bb6
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BRKINT = 0x2
- CFLUSH = 0xf
- CLOCAL = 0x8000
- CREAD = 0x800
- CS5 = 0x0
- CS6 = 0x100
- CS7 = 0x200
- CS8 = 0x300
- CSIZE = 0x300
- CSTART = 0x11
- CSTATUS = 0x14
- CSTOP = 0x13
- CSTOPB = 0x400
- CSUSP = 0x1a
- CTL_MAXNAME = 0xc
- CTL_NET = 0x4
- DLT_A429 = 0xb8
- DLT_A653_ICM = 0xb9
- DLT_AIRONET_HEADER = 0x78
- DLT_AOS = 0xde
- DLT_APPLE_IP_OVER_IEEE1394 = 0x8a
- DLT_ARCNET = 0x7
- DLT_ARCNET_LINUX = 0x81
- DLT_ATM_CLIP = 0x13
- DLT_ATM_RFC1483 = 0xb
- DLT_AURORA = 0x7e
- DLT_AX25 = 0x3
- DLT_AX25_KISS = 0xca
- DLT_BACNET_MS_TP = 0xa5
- DLT_BLUETOOTH_HCI_H4 = 0xbb
- DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9
- DLT_CAN20B = 0xbe
- DLT_CAN_SOCKETCAN = 0xe3
- DLT_CHAOS = 0x5
- DLT_CHDLC = 0x68
- DLT_CISCO_IOS = 0x76
- DLT_C_HDLC = 0x68
- DLT_C_HDLC_WITH_DIR = 0xcd
- DLT_DBUS = 0xe7
- DLT_DECT = 0xdd
- DLT_DOCSIS = 0x8f
- DLT_DVB_CI = 0xeb
- DLT_ECONET = 0x73
- DLT_EN10MB = 0x1
- DLT_EN3MB = 0x2
- DLT_ENC = 0x6d
- DLT_ERF = 0xc5
- DLT_ERF_ETH = 0xaf
- DLT_ERF_POS = 0xb0
- DLT_FC_2 = 0xe0
- DLT_FC_2_WITH_FRAME_DELIMS = 0xe1
- DLT_FDDI = 0xa
- DLT_FLEXRAY = 0xd2
- DLT_FRELAY = 0x6b
- DLT_FRELAY_WITH_DIR = 0xce
- DLT_GCOM_SERIAL = 0xad
- DLT_GCOM_T1E1 = 0xac
- DLT_GPF_F = 0xab
- DLT_GPF_T = 0xaa
- DLT_GPRS_LLC = 0xa9
- DLT_GSMTAP_ABIS = 0xda
- DLT_GSMTAP_UM = 0xd9
- DLT_HHDLC = 0x79
- DLT_IBM_SN = 0x92
- DLT_IBM_SP = 0x91
- DLT_IEEE802 = 0x6
- DLT_IEEE802_11 = 0x69
- DLT_IEEE802_11_RADIO = 0x7f
- DLT_IEEE802_11_RADIO_AVS = 0xa3
- DLT_IEEE802_15_4 = 0xc3
- DLT_IEEE802_15_4_LINUX = 0xbf
- DLT_IEEE802_15_4_NOFCS = 0xe6
- DLT_IEEE802_15_4_NONASK_PHY = 0xd7
- DLT_IEEE802_16_MAC_CPS = 0xbc
- DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1
- DLT_IPFILTER = 0x74
- DLT_IPMB = 0xc7
- DLT_IPMB_LINUX = 0xd1
- DLT_IPNET = 0xe2
- DLT_IPOIB = 0xf2
- DLT_IPV4 = 0xe4
- DLT_IPV6 = 0xe5
- DLT_IP_OVER_FC = 0x7a
- DLT_JUNIPER_ATM1 = 0x89
- DLT_JUNIPER_ATM2 = 0x87
- DLT_JUNIPER_ATM_CEMIC = 0xee
- DLT_JUNIPER_CHDLC = 0xb5
- DLT_JUNIPER_ES = 0x84
- DLT_JUNIPER_ETHER = 0xb2
- DLT_JUNIPER_FIBRECHANNEL = 0xea
- DLT_JUNIPER_FRELAY = 0xb4
- DLT_JUNIPER_GGSN = 0x85
- DLT_JUNIPER_ISM = 0xc2
- DLT_JUNIPER_MFR = 0x86
- DLT_JUNIPER_MLFR = 0x83
- DLT_JUNIPER_MLPPP = 0x82
- DLT_JUNIPER_MONITOR = 0xa4
- DLT_JUNIPER_PIC_PEER = 0xae
- DLT_JUNIPER_PPP = 0xb3
- DLT_JUNIPER_PPPOE = 0xa7
- DLT_JUNIPER_PPPOE_ATM = 0xa8
- DLT_JUNIPER_SERVICES = 0x88
- DLT_JUNIPER_SRX_E2E = 0xe9
- DLT_JUNIPER_ST = 0xc8
- DLT_JUNIPER_VP = 0xb7
- DLT_JUNIPER_VS = 0xe8
- DLT_LAPB_WITH_DIR = 0xcf
- DLT_LAPD = 0xcb
- DLT_LIN = 0xd4
- DLT_LINUX_EVDEV = 0xd8
- DLT_LINUX_IRDA = 0x90
- DLT_LINUX_LAPD = 0xb1
- DLT_LINUX_PPP_WITHDIRECTION = 0xa6
- DLT_LINUX_SLL = 0x71
- DLT_LOOP = 0x6c
- DLT_LTALK = 0x72
- DLT_MATCHING_MAX = 0xf5
- DLT_MATCHING_MIN = 0x68
- DLT_MFR = 0xb6
- DLT_MOST = 0xd3
- DLT_MPEG_2_TS = 0xf3
- DLT_MPLS = 0xdb
- DLT_MTP2 = 0x8c
- DLT_MTP2_WITH_PHDR = 0x8b
- DLT_MTP3 = 0x8d
- DLT_MUX27010 = 0xec
- DLT_NETANALYZER = 0xf0
- DLT_NETANALYZER_TRANSPARENT = 0xf1
- DLT_NFC_LLCP = 0xf5
- DLT_NFLOG = 0xef
- DLT_NG40 = 0xf4
- DLT_NULL = 0x0
- DLT_PCI_EXP = 0x7d
- DLT_PFLOG = 0x75
- DLT_PFSYNC = 0x12
- DLT_PPI = 0xc0
- DLT_PPP = 0x9
- DLT_PPP_BSDOS = 0x10
- DLT_PPP_ETHER = 0x33
- DLT_PPP_PPPD = 0xa6
- DLT_PPP_SERIAL = 0x32
- DLT_PPP_WITH_DIR = 0xcc
- DLT_PPP_WITH_DIRECTION = 0xa6
- DLT_PRISM_HEADER = 0x77
- DLT_PRONET = 0x4
- DLT_RAIF1 = 0xc6
- DLT_RAW = 0xc
- DLT_RIO = 0x7c
- DLT_SCCP = 0x8e
- DLT_SITA = 0xc4
- DLT_SLIP = 0x8
- DLT_SLIP_BSDOS = 0xf
- DLT_STANAG_5066_D_PDU = 0xed
- DLT_SUNATM = 0x7b
- DLT_SYMANTEC_FIREWALL = 0x63
- DLT_TZSP = 0x80
- DLT_USB = 0xba
- DLT_USB_LINUX = 0xbd
- DLT_USB_LINUX_MMAPPED = 0xdc
- DLT_USER0 = 0x93
- DLT_USER1 = 0x94
- DLT_USER10 = 0x9d
- DLT_USER11 = 0x9e
- DLT_USER12 = 0x9f
- DLT_USER13 = 0xa0
- DLT_USER14 = 0xa1
- DLT_USER15 = 0xa2
- DLT_USER2 = 0x95
- DLT_USER3 = 0x96
- DLT_USER4 = 0x97
- DLT_USER5 = 0x98
- DLT_USER6 = 0x99
- DLT_USER7 = 0x9a
- DLT_USER8 = 0x9b
- DLT_USER9 = 0x9c
- DLT_WIHART = 0xdf
- DLT_X2E_SERIAL = 0xd5
- DLT_X2E_XORAYA = 0xd6
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x40
- ECHOE = 0x2
- ECHOK = 0x4
- ECHOKE = 0x1
- ECHONL = 0x10
- ECHOPRT = 0x20
- EVFILT_AIO = -0x3
- EVFILT_FS = -0x9
- EVFILT_MACHPORT = -0x8
- EVFILT_PROC = -0x5
- EVFILT_READ = -0x1
- EVFILT_SIGNAL = -0x6
- EVFILT_SYSCOUNT = 0xe
- EVFILT_THREADMARKER = 0xe
- EVFILT_TIMER = -0x7
- EVFILT_USER = -0xa
- EVFILT_VM = -0xc
- EVFILT_VNODE = -0x4
- EVFILT_WRITE = -0x2
- EV_ADD = 0x1
- EV_CLEAR = 0x20
- EV_DELETE = 0x2
- EV_DISABLE = 0x8
- EV_DISPATCH = 0x80
- EV_ENABLE = 0x4
- EV_EOF = 0x8000
- EV_ERROR = 0x4000
- EV_FLAG0 = 0x1000
- EV_FLAG1 = 0x2000
- EV_ONESHOT = 0x10
- EV_OOBAND = 0x2000
- EV_POLL = 0x1000
- EV_RECEIPT = 0x40
- EV_SYSFLAGS = 0xf000
- EXTA = 0x4b00
- EXTB = 0x9600
- EXTPROC = 0x800
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FLUSHO = 0x800000
- F_ADDFILESIGS = 0x3d
- F_ADDSIGS = 0x3b
- F_ALLOCATEALL = 0x4
- F_ALLOCATECONTIG = 0x2
- F_CHKCLEAN = 0x29
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x43
- F_FINDSIGS = 0x4e
- F_FLUSH_DATA = 0x28
- F_FREEZE_FS = 0x35
- F_FULLFSYNC = 0x33
- F_GETCODEDIR = 0x48
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLK = 0x7
- F_GETLKPID = 0x42
- F_GETNOSIGPIPE = 0x4a
- F_GETOWN = 0x5
- F_GETPATH = 0x32
- F_GETPATH_MTMINFO = 0x47
- F_GETPROTECTIONCLASS = 0x3f
- F_GETPROTECTIONLEVEL = 0x4d
- F_GLOBAL_NOCACHE = 0x37
- F_LOG2PHYS = 0x31
- F_LOG2PHYS_EXT = 0x41
- F_NOCACHE = 0x30
- F_NODIRECT = 0x3e
- F_OK = 0x0
- F_PATHPKG_CHECK = 0x34
- F_PEOFPOSMODE = 0x3
- F_PREALLOCATE = 0x2a
- F_RDADVISE = 0x2c
- F_RDAHEAD = 0x2d
- F_RDLCK = 0x1
- F_SETBACKINGSTORE = 0x46
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLK = 0x8
- F_SETLKW = 0x9
- F_SETLKWTIMEOUT = 0xa
- F_SETNOSIGPIPE = 0x49
- F_SETOWN = 0x6
- F_SETPROTECTIONCLASS = 0x40
- F_SETSIZE = 0x2b
- F_SINGLE_WRITER = 0x4c
- F_THAW_FS = 0x36
- F_TRANSCODEKEY = 0x4b
- F_UNLCK = 0x2
- F_VOLPOSMODE = 0x4
- F_WRLCK = 0x3
- HUPCL = 0x4000
- ICANON = 0x100
- ICMP6_FILTER = 0x12
- ICRNL = 0x100
- IEXTEN = 0x400
- IFF_ALLMULTI = 0x200
- IFF_ALTPHYS = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_LINK0 = 0x1000
- IFF_LINK1 = 0x2000
- IFF_LINK2 = 0x4000
- IFF_LOOPBACK = 0x8
- IFF_MULTICAST = 0x8000
- IFF_NOARP = 0x80
- IFF_NOTRAILERS = 0x20
- IFF_OACTIVE = 0x400
- IFF_POINTOPOINT = 0x10
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SIMPLEX = 0x800
- IFF_UP = 0x1
- IFNAMSIZ = 0x10
- IFT_1822 = 0x2
- IFT_AAL5 = 0x31
- IFT_ARCNET = 0x23
- IFT_ARCNETPLUS = 0x24
- IFT_ATM = 0x25
- IFT_BRIDGE = 0xd1
- IFT_CARP = 0xf8
- IFT_CELLULAR = 0xff
- IFT_CEPT = 0x13
- IFT_DS3 = 0x1e
- IFT_ENC = 0xf4
- IFT_EON = 0x19
- IFT_ETHER = 0x6
- IFT_FAITH = 0x38
- IFT_FDDI = 0xf
- IFT_FRELAY = 0x20
- IFT_FRELAYDCE = 0x2c
- IFT_GIF = 0x37
- IFT_HDH1822 = 0x3
- IFT_HIPPI = 0x2f
- IFT_HSSI = 0x2e
- IFT_HY = 0xe
- IFT_IEEE1394 = 0x90
- IFT_IEEE8023ADLAG = 0x88
- IFT_ISDNBASIC = 0x14
- IFT_ISDNPRIMARY = 0x15
- IFT_ISO88022LLC = 0x29
- IFT_ISO88023 = 0x7
- IFT_ISO88024 = 0x8
- IFT_ISO88025 = 0x9
- IFT_ISO88026 = 0xa
- IFT_L2VLAN = 0x87
- IFT_LAPB = 0x10
- IFT_LOCALTALK = 0x2a
- IFT_LOOP = 0x18
- IFT_MIOX25 = 0x26
- IFT_MODEM = 0x30
- IFT_NSIP = 0x1b
- IFT_OTHER = 0x1
- IFT_P10 = 0xc
- IFT_P80 = 0xd
- IFT_PARA = 0x22
- IFT_PDP = 0xff
- IFT_PFLOG = 0xf5
- IFT_PFSYNC = 0xf6
- IFT_PKTAP = 0xfe
- IFT_PPP = 0x17
- IFT_PROPMUX = 0x36
- IFT_PROPVIRTUAL = 0x35
- IFT_PTPSERIAL = 0x16
- IFT_RS232 = 0x21
- IFT_SDLC = 0x11
- IFT_SIP = 0x1f
- IFT_SLIP = 0x1c
- IFT_SMDSDXI = 0x2b
- IFT_SMDSICIP = 0x34
- IFT_SONET = 0x27
- IFT_SONETPATH = 0x32
- IFT_SONETVT = 0x33
- IFT_STARLAN = 0xb
- IFT_STF = 0x39
- IFT_T1 = 0x12
- IFT_ULTRA = 0x1d
- IFT_V35 = 0x2d
- IFT_X25 = 0x5
- IFT_X25DDN = 0x4
- IFT_X25PLE = 0x28
- IFT_XETHER = 0x1a
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLASSD_HOST = 0xfffffff
- IN_CLASSD_NET = 0xf0000000
- IN_CLASSD_NSHIFT = 0x1c
- IN_LINKLOCALNETNUM = 0xa9fe0000
- IN_LOOPBACKNET = 0x7f
- IPPROTO_3PC = 0x22
- IPPROTO_ADFS = 0x44
- IPPROTO_AH = 0x33
- IPPROTO_AHIP = 0x3d
- IPPROTO_APES = 0x63
- IPPROTO_ARGUS = 0xd
- IPPROTO_AX25 = 0x5d
- IPPROTO_BHA = 0x31
- IPPROTO_BLT = 0x1e
- IPPROTO_BRSATMON = 0x4c
- IPPROTO_CFTP = 0x3e
- IPPROTO_CHAOS = 0x10
- IPPROTO_CMTP = 0x26
- IPPROTO_CPHB = 0x49
- IPPROTO_CPNX = 0x48
- IPPROTO_DDP = 0x25
- IPPROTO_DGP = 0x56
- IPPROTO_DIVERT = 0xfe
- IPPROTO_DONE = 0x101
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_EMCON = 0xe
- IPPROTO_ENCAP = 0x62
- IPPROTO_EON = 0x50
- IPPROTO_ESP = 0x32
- IPPROTO_ETHERIP = 0x61
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GGP = 0x3
- IPPROTO_GMTP = 0x64
- IPPROTO_GRE = 0x2f
- IPPROTO_HELLO = 0x3f
- IPPROTO_HMP = 0x14
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IDPR = 0x23
- IPPROTO_IDRP = 0x2d
- IPPROTO_IGMP = 0x2
- IPPROTO_IGP = 0x55
- IPPROTO_IGRP = 0x58
- IPPROTO_IL = 0x28
- IPPROTO_INLSP = 0x34
- IPPROTO_INP = 0x20
- IPPROTO_IP = 0x0
- IPPROTO_IPCOMP = 0x6c
- IPPROTO_IPCV = 0x47
- IPPROTO_IPEIP = 0x5e
- IPPROTO_IPIP = 0x4
- IPPROTO_IPPC = 0x43
- IPPROTO_IPV4 = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_IRTP = 0x1c
- IPPROTO_KRYPTOLAN = 0x41
- IPPROTO_LARP = 0x5b
- IPPROTO_LEAF1 = 0x19
- IPPROTO_LEAF2 = 0x1a
- IPPROTO_MAX = 0x100
- IPPROTO_MAXID = 0x34
- IPPROTO_MEAS = 0x13
- IPPROTO_MHRP = 0x30
- IPPROTO_MICP = 0x5f
- IPPROTO_MTP = 0x5c
- IPPROTO_MUX = 0x12
- IPPROTO_ND = 0x4d
- IPPROTO_NHRP = 0x36
- IPPROTO_NONE = 0x3b
- IPPROTO_NSP = 0x1f
- IPPROTO_NVPII = 0xb
- IPPROTO_OSPFIGP = 0x59
- IPPROTO_PGM = 0x71
- IPPROTO_PIGP = 0x9
- IPPROTO_PIM = 0x67
- IPPROTO_PRM = 0x15
- IPPROTO_PUP = 0xc
- IPPROTO_PVP = 0x4b
- IPPROTO_RAW = 0xff
- IPPROTO_RCCMON = 0xa
- IPPROTO_RDP = 0x1b
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_RVD = 0x42
- IPPROTO_SATEXPAK = 0x40
- IPPROTO_SATMON = 0x45
- IPPROTO_SCCSP = 0x60
- IPPROTO_SCTP = 0x84
- IPPROTO_SDRP = 0x2a
- IPPROTO_SEP = 0x21
- IPPROTO_SRPC = 0x5a
- IPPROTO_ST = 0x7
- IPPROTO_SVMTP = 0x52
- IPPROTO_SWIPE = 0x35
- IPPROTO_TCF = 0x57
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_TPXX = 0x27
- IPPROTO_TRUNK1 = 0x17
- IPPROTO_TRUNK2 = 0x18
- IPPROTO_TTP = 0x54
- IPPROTO_UDP = 0x11
- IPPROTO_VINES = 0x53
- IPPROTO_VISA = 0x46
- IPPROTO_VMTP = 0x51
- IPPROTO_WBEXPAK = 0x4f
- IPPROTO_WBMON = 0x4e
- IPPROTO_WSN = 0x4a
- IPPROTO_XNET = 0xf
- IPPROTO_XTP = 0x24
- IPV6_2292DSTOPTS = 0x17
- IPV6_2292HOPLIMIT = 0x14
- IPV6_2292HOPOPTS = 0x16
- IPV6_2292NEXTHOP = 0x15
- IPV6_2292PKTINFO = 0x13
- IPV6_2292PKTOPTIONS = 0x19
- IPV6_2292RTHDR = 0x18
- IPV6_BINDV6ONLY = 0x1b
- IPV6_BOUND_IF = 0x7d
- IPV6_CHECKSUM = 0x1a
- IPV6_DEFAULT_MULTICAST_HOPS = 0x1
- IPV6_DEFAULT_MULTICAST_LOOP = 0x1
- IPV6_DEFHLIM = 0x40
- IPV6_FAITH = 0x1d
- IPV6_FLOWINFO_MASK = 0xffffff0f
- IPV6_FLOWLABEL_MASK = 0xffff0f00
- IPV6_FRAGTTL = 0x3c
- IPV6_FW_ADD = 0x1e
- IPV6_FW_DEL = 0x1f
- IPV6_FW_FLUSH = 0x20
- IPV6_FW_GET = 0x22
- IPV6_FW_ZERO = 0x21
- IPV6_HLIMDEC = 0x1
- IPV6_IPSEC_POLICY = 0x1c
- IPV6_JOIN_GROUP = 0xc
- IPV6_LEAVE_GROUP = 0xd
- IPV6_MAXHLIM = 0xff
- IPV6_MAXOPTHDR = 0x800
- IPV6_MAXPACKET = 0xffff
- IPV6_MAX_GROUP_SRC_FILTER = 0x200
- IPV6_MAX_MEMBERSHIPS = 0xfff
- IPV6_MAX_SOCK_SRC_FILTER = 0x80
- IPV6_MIN_MEMBERSHIPS = 0x1f
- IPV6_MMTU = 0x500
- IPV6_MULTICAST_HOPS = 0xa
- IPV6_MULTICAST_IF = 0x9
- IPV6_MULTICAST_LOOP = 0xb
- IPV6_PORTRANGE = 0xe
- IPV6_PORTRANGE_DEFAULT = 0x0
- IPV6_PORTRANGE_HIGH = 0x1
- IPV6_PORTRANGE_LOW = 0x2
- IPV6_RECVTCLASS = 0x23
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_SOCKOPT_RESERVED1 = 0x3
- IPV6_TCLASS = 0x24
- IPV6_UNICAST_HOPS = 0x4
- IPV6_V6ONLY = 0x1b
- IPV6_VERSION = 0x60
- IPV6_VERSION_MASK = 0xf0
- IP_ADD_MEMBERSHIP = 0xc
- IP_ADD_SOURCE_MEMBERSHIP = 0x46
- IP_BLOCK_SOURCE = 0x48
- IP_BOUND_IF = 0x19
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0xd
- IP_DROP_SOURCE_MEMBERSHIP = 0x47
- IP_DUMMYNET_CONFIGURE = 0x3c
- IP_DUMMYNET_DEL = 0x3d
- IP_DUMMYNET_FLUSH = 0x3e
- IP_DUMMYNET_GET = 0x40
- IP_FAITH = 0x16
- IP_FW_ADD = 0x28
- IP_FW_DEL = 0x29
- IP_FW_FLUSH = 0x2a
- IP_FW_GET = 0x2c
- IP_FW_RESETLOG = 0x2d
- IP_FW_ZERO = 0x2b
- IP_HDRINCL = 0x2
- IP_IPSEC_POLICY = 0x15
- IP_MAXPACKET = 0xffff
- IP_MAX_GROUP_SRC_FILTER = 0x200
- IP_MAX_MEMBERSHIPS = 0xfff
- IP_MAX_SOCK_MUTE_FILTER = 0x80
- IP_MAX_SOCK_SRC_FILTER = 0x80
- IP_MF = 0x2000
- IP_MIN_MEMBERSHIPS = 0x1f
- IP_MSFILTER = 0x4a
- IP_MSS = 0x240
- IP_MULTICAST_IF = 0x9
- IP_MULTICAST_IFINDEX = 0x42
- IP_MULTICAST_LOOP = 0xb
- IP_MULTICAST_TTL = 0xa
- IP_MULTICAST_VIF = 0xe
- IP_NAT__XXX = 0x37
- IP_OFFMASK = 0x1fff
- IP_OLD_FW_ADD = 0x32
- IP_OLD_FW_DEL = 0x33
- IP_OLD_FW_FLUSH = 0x34
- IP_OLD_FW_GET = 0x36
- IP_OLD_FW_RESETLOG = 0x38
- IP_OLD_FW_ZERO = 0x35
- IP_OPTIONS = 0x1
- IP_PKTINFO = 0x1a
- IP_PORTRANGE = 0x13
- IP_PORTRANGE_DEFAULT = 0x0
- IP_PORTRANGE_HIGH = 0x1
- IP_PORTRANGE_LOW = 0x2
- IP_RECVDSTADDR = 0x7
- IP_RECVIF = 0x14
- IP_RECVOPTS = 0x5
- IP_RECVPKTINFO = 0x1a
- IP_RECVRETOPTS = 0x6
- IP_RECVTTL = 0x18
- IP_RETOPTS = 0x8
- IP_RF = 0x8000
- IP_RSVP_OFF = 0x10
- IP_RSVP_ON = 0xf
- IP_RSVP_VIF_OFF = 0x12
- IP_RSVP_VIF_ON = 0x11
- IP_STRIPHDR = 0x17
- IP_TOS = 0x3
- IP_TRAFFIC_MGT_BACKGROUND = 0x41
- IP_TTL = 0x4
- IP_UNBLOCK_SOURCE = 0x49
- ISIG = 0x80
- ISTRIP = 0x20
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x400
- IXON = 0x200
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_CAN_REUSE = 0x9
- MADV_DONTNEED = 0x4
- MADV_FREE = 0x5
- MADV_FREE_REUSABLE = 0x7
- MADV_FREE_REUSE = 0x8
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_SEQUENTIAL = 0x2
- MADV_WILLNEED = 0x3
- MADV_ZERO_WIRED_PAGES = 0x6
- MAP_ANON = 0x1000
- MAP_COPY = 0x2
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_HASSEMAPHORE = 0x200
- MAP_JIT = 0x800
- MAP_NOCACHE = 0x400
- MAP_NOEXTEND = 0x100
- MAP_NORESERVE = 0x40
- MAP_PRIVATE = 0x2
- MAP_RENAME = 0x20
- MAP_RESERVED0080 = 0x80
- MAP_SHARED = 0x1
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MSG_CTRUNC = 0x20
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x80
- MSG_EOF = 0x100
- MSG_EOR = 0x8
- MSG_FLUSH = 0x400
- MSG_HAVEMORE = 0x2000
- MSG_HOLD = 0x800
- MSG_NEEDSA = 0x10000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_RCVMORE = 0x4000
- MSG_SEND = 0x1000
- MSG_TRUNC = 0x10
- MSG_WAITALL = 0x40
- MSG_WAITSTREAM = 0x200
- MS_ASYNC = 0x1
- MS_DEACTIVATE = 0x8
- MS_INVALIDATE = 0x2
- MS_KILLPAGES = 0x4
- MS_SYNC = 0x10
- NAME_MAX = 0xff
- NET_RT_DUMP = 0x1
- NET_RT_DUMP2 = 0x7
- NET_RT_FLAGS = 0x2
- NET_RT_IFLIST = 0x3
- NET_RT_IFLIST2 = 0x6
- NET_RT_MAXID = 0xa
- NET_RT_STAT = 0x4
- NET_RT_TRASH = 0x5
- NOFLSH = 0x80000000
- NOTE_ABSOLUTE = 0x8
- NOTE_ATTRIB = 0x8
- NOTE_BACKGROUND = 0x40
- NOTE_CHILD = 0x4
- NOTE_CRITICAL = 0x20
- NOTE_DELETE = 0x1
- NOTE_EXEC = 0x20000000
- NOTE_EXIT = 0x80000000
- NOTE_EXITSTATUS = 0x4000000
- NOTE_EXIT_CSERROR = 0x40000
- NOTE_EXIT_DECRYPTFAIL = 0x10000
- NOTE_EXIT_DETAIL = 0x2000000
- NOTE_EXIT_DETAIL_MASK = 0x70000
- NOTE_EXIT_MEMORY = 0x20000
- NOTE_EXIT_REPARENTED = 0x80000
- NOTE_EXTEND = 0x4
- NOTE_FFAND = 0x40000000
- NOTE_FFCOPY = 0xc0000000
- NOTE_FFCTRLMASK = 0xc0000000
- NOTE_FFLAGSMASK = 0xffffff
- NOTE_FFNOP = 0x0
- NOTE_FFOR = 0x80000000
- NOTE_FORK = 0x40000000
- NOTE_LEEWAY = 0x10
- NOTE_LINK = 0x10
- NOTE_LOWAT = 0x1
- NOTE_NONE = 0x80
- NOTE_NSECONDS = 0x4
- NOTE_PCTRLMASK = -0x100000
- NOTE_PDATAMASK = 0xfffff
- NOTE_REAP = 0x10000000
- NOTE_RENAME = 0x20
- NOTE_REVOKE = 0x40
- NOTE_SECONDS = 0x1
- NOTE_SIGNAL = 0x8000000
- NOTE_TRACK = 0x1
- NOTE_TRACKERR = 0x2
- NOTE_TRIGGER = 0x1000000
- NOTE_USECONDS = 0x2
- NOTE_VM_ERROR = 0x10000000
- NOTE_VM_PRESSURE = 0x80000000
- NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000
- NOTE_VM_PRESSURE_TERMINATE = 0x40000000
- NOTE_WRITE = 0x2
- OCRNL = 0x10
- OFDEL = 0x20000
- OFILL = 0x80
- ONLCR = 0x2
- ONLRET = 0x40
- ONOCR = 0x20
- ONOEOT = 0x8
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_ALERT = 0x20000000
- O_APPEND = 0x8
- O_ASYNC = 0x40
- O_CLOEXEC = 0x1000000
- O_CREAT = 0x200
- O_DIRECTORY = 0x100000
- O_DP_GETRAWENCRYPTED = 0x1
- O_DSYNC = 0x400000
- O_EVTONLY = 0x8000
- O_EXCL = 0x800
- O_EXLOCK = 0x20
- O_FSYNC = 0x80
- O_NDELAY = 0x4
- O_NOCTTY = 0x20000
- O_NOFOLLOW = 0x100
- O_NONBLOCK = 0x4
- O_POPUP = 0x80000000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_SHLOCK = 0x10
- O_SYMLINK = 0x200000
- O_SYNC = 0x80
- O_TRUNC = 0x400
- O_WRONLY = 0x1
- PARENB = 0x1000
- PARMRK = 0x8
- PARODD = 0x2000
- PENDIN = 0x20000000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- PT_ATTACH = 0xa
- PT_ATTACHEXC = 0xe
- PT_CONTINUE = 0x7
- PT_DENY_ATTACH = 0x1f
- PT_DETACH = 0xb
- PT_FIRSTMACH = 0x20
- PT_FORCEQUOTA = 0x1e
- PT_KILL = 0x8
- PT_READ_D = 0x2
- PT_READ_I = 0x1
- PT_READ_U = 0x3
- PT_SIGEXC = 0xc
- PT_STEP = 0x9
- PT_THUPDATE = 0xd
- PT_TRACE_ME = 0x0
- PT_WRITE_D = 0x5
- PT_WRITE_I = 0x4
- PT_WRITE_U = 0x6
- RLIMIT_AS = 0x5
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_CPU_USAGE_MONITOR = 0x2
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x8
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = 0x7fffffffffffffff
- RTAX_AUTHOR = 0x6
- RTAX_BRD = 0x7
- RTAX_DST = 0x0
- RTAX_GATEWAY = 0x1
- RTAX_GENMASK = 0x3
- RTAX_IFA = 0x5
- RTAX_IFP = 0x4
- RTAX_MAX = 0x8
- RTAX_NETMASK = 0x2
- RTA_AUTHOR = 0x40
- RTA_BRD = 0x80
- RTA_DST = 0x1
- RTA_GATEWAY = 0x2
- RTA_GENMASK = 0x8
- RTA_IFA = 0x20
- RTA_IFP = 0x10
- RTA_NETMASK = 0x4
- RTF_BLACKHOLE = 0x1000
- RTF_BROADCAST = 0x400000
- RTF_CLONING = 0x100
- RTF_CONDEMNED = 0x2000000
- RTF_DELCLONE = 0x80
- RTF_DONE = 0x40
- RTF_DYNAMIC = 0x10
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_IFREF = 0x4000000
- RTF_IFSCOPE = 0x1000000
- RTF_LLINFO = 0x400
- RTF_LOCAL = 0x200000
- RTF_MODIFIED = 0x20
- RTF_MULTICAST = 0x800000
- RTF_NOIFREF = 0x2000
- RTF_PINNED = 0x100000
- RTF_PRCLONING = 0x10000
- RTF_PROTO1 = 0x8000
- RTF_PROTO2 = 0x4000
- RTF_PROTO3 = 0x40000
- RTF_PROXY = 0x8000000
- RTF_REJECT = 0x8
- RTF_ROUTER = 0x10000000
- RTF_STATIC = 0x800
- RTF_UP = 0x1
- RTF_WASCLONED = 0x20000
- RTF_XRESOLVE = 0x200
- RTM_ADD = 0x1
- RTM_CHANGE = 0x3
- RTM_DELADDR = 0xd
- RTM_DELETE = 0x2
- RTM_DELMADDR = 0x10
- RTM_GET = 0x4
- RTM_GET2 = 0x14
- RTM_IFINFO = 0xe
- RTM_IFINFO2 = 0x12
- RTM_LOCK = 0x8
- RTM_LOSING = 0x5
- RTM_MISS = 0x7
- RTM_NEWADDR = 0xc
- RTM_NEWMADDR = 0xf
- RTM_NEWMADDR2 = 0x13
- RTM_OLDADD = 0x9
- RTM_OLDDEL = 0xa
- RTM_REDIRECT = 0x6
- RTM_RESOLVE = 0xb
- RTM_RTTUNIT = 0xf4240
- RTM_VERSION = 0x5
- RTV_EXPIRE = 0x4
- RTV_HOPCOUNT = 0x2
- RTV_MTU = 0x1
- RTV_RPIPE = 0x8
- RTV_RTT = 0x40
- RTV_RTTVAR = 0x80
- RTV_SPIPE = 0x10
- RTV_SSTHRESH = 0x20
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- SCM_CREDS = 0x3
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x2
- SCM_TIMESTAMP_MONOTONIC = 0x4
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDMULTI = 0x80206931
- SIOCAIFADDR = 0x8040691a
- SIOCARPIPLL = 0xc0206928
- SIOCATMARK = 0x40047307
- SIOCAUTOADDR = 0xc0206926
- SIOCAUTONETMASK = 0x80206927
- SIOCDELMULTI = 0x80206932
- SIOCDIFADDR = 0x80206919
- SIOCDIFPHYADDR = 0x80206941
- SIOCGDRVSPEC = 0xc01c697b
- SIOCGETVLAN = 0xc020697f
- SIOCGHIWAT = 0x40047301
- SIOCGIFADDR = 0xc0206921
- SIOCGIFALTMTU = 0xc0206948
- SIOCGIFASYNCMAP = 0xc020697c
- SIOCGIFBOND = 0xc0206947
- SIOCGIFBRDADDR = 0xc0206923
- SIOCGIFCAP = 0xc020695b
- SIOCGIFCONF = 0xc0086924
- SIOCGIFDEVMTU = 0xc0206944
- SIOCGIFDSTADDR = 0xc0206922
- SIOCGIFFLAGS = 0xc0206911
- SIOCGIFGENERIC = 0xc020693a
- SIOCGIFKPI = 0xc0206987
- SIOCGIFMAC = 0xc0206982
- SIOCGIFMEDIA = 0xc0286938
- SIOCGIFMETRIC = 0xc0206917
- SIOCGIFMTU = 0xc0206933
- SIOCGIFNETMASK = 0xc0206925
- SIOCGIFPDSTADDR = 0xc0206940
- SIOCGIFPHYS = 0xc0206935
- SIOCGIFPSRCADDR = 0xc020693f
- SIOCGIFSTATUS = 0xc331693d
- SIOCGIFVLAN = 0xc020697f
- SIOCGIFWAKEFLAGS = 0xc0206988
- SIOCGLOWAT = 0x40047303
- SIOCGPGRP = 0x40047309
- SIOCIFCREATE = 0xc0206978
- SIOCIFCREATE2 = 0xc020697a
- SIOCIFDESTROY = 0x80206979
- SIOCIFGCLONERS = 0xc00c6981
- SIOCRSLVMULTI = 0xc008693b
- SIOCSDRVSPEC = 0x801c697b
- SIOCSETVLAN = 0x8020697e
- SIOCSHIWAT = 0x80047300
- SIOCSIFADDR = 0x8020690c
- SIOCSIFALTMTU = 0x80206945
- SIOCSIFASYNCMAP = 0x8020697d
- SIOCSIFBOND = 0x80206946
- SIOCSIFBRDADDR = 0x80206913
- SIOCSIFCAP = 0x8020695a
- SIOCSIFDSTADDR = 0x8020690e
- SIOCSIFFLAGS = 0x80206910
- SIOCSIFGENERIC = 0x80206939
- SIOCSIFKPI = 0x80206986
- SIOCSIFLLADDR = 0x8020693c
- SIOCSIFMAC = 0x80206983
- SIOCSIFMEDIA = 0xc0206937
- SIOCSIFMETRIC = 0x80206918
- SIOCSIFMTU = 0x80206934
- SIOCSIFNETMASK = 0x80206916
- SIOCSIFPHYADDR = 0x8040693e
- SIOCSIFPHYS = 0x80206936
- SIOCSIFVLAN = 0x8020697e
- SIOCSLOWAT = 0x80047302
- SIOCSPGRP = 0x80047308
- SOCK_DGRAM = 0x2
- SOCK_MAXADDRLEN = 0xff
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_SOCKET = 0xffff
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x2
- SO_BROADCAST = 0x20
- SO_DEBUG = 0x1
- SO_DONTROUTE = 0x10
- SO_DONTTRUNC = 0x2000
- SO_ERROR = 0x1007
- SO_KEEPALIVE = 0x8
- SO_LABEL = 0x1010
- SO_LINGER = 0x80
- SO_LINGER_SEC = 0x1080
- SO_NKE = 0x1021
- SO_NOADDRERR = 0x1023
- SO_NOSIGPIPE = 0x1022
- SO_NOTIFYCONFLICT = 0x1026
- SO_NP_EXTENSIONS = 0x1083
- SO_NREAD = 0x1020
- SO_NUMRCVPKT = 0x1112
- SO_NWRITE = 0x1024
- SO_OOBINLINE = 0x100
- SO_PEERLABEL = 0x1011
- SO_RANDOMPORT = 0x1082
- SO_RCVBUF = 0x1002
- SO_RCVLOWAT = 0x1004
- SO_RCVTIMEO = 0x1006
- SO_REUSEADDR = 0x4
- SO_REUSEPORT = 0x200
- SO_REUSESHAREUID = 0x1025
- SO_SNDBUF = 0x1001
- SO_SNDLOWAT = 0x1003
- SO_SNDTIMEO = 0x1005
- SO_TIMESTAMP = 0x400
- SO_TIMESTAMP_MONOTONIC = 0x800
- SO_TYPE = 0x1008
- SO_UPCALLCLOSEWAIT = 0x1027
- SO_USELOOPBACK = 0x40
- SO_WANTMORE = 0x4000
- SO_WANTOOBFLAG = 0x8000
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IFWHT = 0xe000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISTXT = 0x200
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TCIFLUSH = 0x1
- TCIOFLUSH = 0x3
- TCOFLUSH = 0x2
- TCP_CONNECTIONTIMEOUT = 0x20
- TCP_ENABLE_ECN = 0x104
- TCP_KEEPALIVE = 0x10
- TCP_KEEPCNT = 0x102
- TCP_KEEPINTVL = 0x101
- TCP_MAXHLEN = 0x3c
- TCP_MAXOLEN = 0x28
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_SACK = 0x4
- TCP_MAX_WINSHIFT = 0xe
- TCP_MINMSS = 0xd8
- TCP_MSS = 0x200
- TCP_NODELAY = 0x1
- TCP_NOOPT = 0x8
- TCP_NOPUSH = 0x4
- TCP_NOTSENT_LOWAT = 0x201
- TCP_RXT_CONNDROPTIME = 0x80
- TCP_RXT_FINDROP = 0x100
- TCP_SENDMOREACKS = 0x103
- TCSAFLUSH = 0x2
- TIOCCBRK = 0x2000747a
- TIOCCDTR = 0x20007478
- TIOCCONS = 0x80047462
- TIOCDCDTIMESTAMP = 0x40087458
- TIOCDRAIN = 0x2000745e
- TIOCDSIMICROCODE = 0x20007455
- TIOCEXCL = 0x2000740d
- TIOCEXT = 0x80047460
- TIOCFLUSH = 0x80047410
- TIOCGDRAINWAIT = 0x40047456
- TIOCGETA = 0x402c7413
- TIOCGETD = 0x4004741a
- TIOCGPGRP = 0x40047477
- TIOCGWINSZ = 0x40087468
- TIOCIXOFF = 0x20007480
- TIOCIXON = 0x20007481
- TIOCMBIC = 0x8004746b
- TIOCMBIS = 0x8004746c
- TIOCMGDTRWAIT = 0x4004745a
- TIOCMGET = 0x4004746a
- TIOCMODG = 0x40047403
- TIOCMODS = 0x80047404
- TIOCMSDTRWAIT = 0x8004745b
- TIOCMSET = 0x8004746d
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x20007471
- TIOCNXCL = 0x2000740e
- TIOCOUTQ = 0x40047473
- TIOCPKT = 0x80047470
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCPTYGNAME = 0x40807453
- TIOCPTYGRANT = 0x20007454
- TIOCPTYUNLK = 0x20007452
- TIOCREMOTE = 0x80047469
- TIOCSBRK = 0x2000747b
- TIOCSCONS = 0x20007463
- TIOCSCTTY = 0x20007461
- TIOCSDRAINWAIT = 0x80047457
- TIOCSDTR = 0x20007479
- TIOCSETA = 0x802c7414
- TIOCSETAF = 0x802c7416
- TIOCSETAW = 0x802c7415
- TIOCSETD = 0x8004741b
- TIOCSIG = 0x2000745f
- TIOCSPGRP = 0x80047476
- TIOCSTART = 0x2000746e
- TIOCSTAT = 0x20007465
- TIOCSTI = 0x80017472
- TIOCSTOP = 0x2000746f
- TIOCSWINSZ = 0x80087467
- TIOCTIMESTAMP = 0x40087459
- TIOCUCNTL = 0x80047466
- TOSTOP = 0x400000
- VDISCARD = 0xf
- VDSUSP = 0xb
- VEOF = 0x0
- VEOL = 0x1
- VEOL2 = 0x2
- VERASE = 0x3
- VINTR = 0x8
- VKILL = 0x5
- VLNEXT = 0xe
- VMIN = 0x10
- VQUIT = 0x9
- VREPRINT = 0x6
- VSTART = 0xc
- VSTATUS = 0x12
- VSTOP = 0xd
- VSUSP = 0xa
- VT0 = 0x0
- VT1 = 0x10000
- VTDLY = 0x10000
- VTIME = 0x11
- VWERASE = 0x4
- WCONTINUED = 0x10
- WCOREFLAG = 0x80
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOWAIT = 0x20
- WORDSIZE = 0x20
- WSTOPPED = 0x8
- WUNTRACED = 0x2
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x30)
- EADDRNOTAVAIL = syscall.Errno(0x31)
- EAFNOSUPPORT = syscall.Errno(0x2f)
- EAGAIN = syscall.Errno(0x23)
- EALREADY = syscall.Errno(0x25)
- EAUTH = syscall.Errno(0x50)
- EBADARCH = syscall.Errno(0x56)
- EBADEXEC = syscall.Errno(0x55)
- EBADF = syscall.Errno(0x9)
- EBADMACHO = syscall.Errno(0x58)
- EBADMSG = syscall.Errno(0x5e)
- EBADRPC = syscall.Errno(0x48)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x59)
- ECHILD = syscall.Errno(0xa)
- ECONNABORTED = syscall.Errno(0x35)
- ECONNREFUSED = syscall.Errno(0x3d)
- ECONNRESET = syscall.Errno(0x36)
- EDEADLK = syscall.Errno(0xb)
- EDESTADDRREQ = syscall.Errno(0x27)
- EDEVERR = syscall.Errno(0x53)
- EDOM = syscall.Errno(0x21)
- EDQUOT = syscall.Errno(0x45)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EFTYPE = syscall.Errno(0x4f)
- EHOSTDOWN = syscall.Errno(0x40)
- EHOSTUNREACH = syscall.Errno(0x41)
- EIDRM = syscall.Errno(0x5a)
- EILSEQ = syscall.Errno(0x5c)
- EINPROGRESS = syscall.Errno(0x24)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x38)
- EISDIR = syscall.Errno(0x15)
- ELAST = syscall.Errno(0x6a)
- ELOOP = syscall.Errno(0x3e)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x28)
- EMULTIHOP = syscall.Errno(0x5f)
- ENAMETOOLONG = syscall.Errno(0x3f)
- ENEEDAUTH = syscall.Errno(0x51)
- ENETDOWN = syscall.Errno(0x32)
- ENETRESET = syscall.Errno(0x34)
- ENETUNREACH = syscall.Errno(0x33)
- ENFILE = syscall.Errno(0x17)
- ENOATTR = syscall.Errno(0x5d)
- ENOBUFS = syscall.Errno(0x37)
- ENODATA = syscall.Errno(0x60)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOLCK = syscall.Errno(0x4d)
- ENOLINK = syscall.Errno(0x61)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x5b)
- ENOPOLICY = syscall.Errno(0x67)
- ENOPROTOOPT = syscall.Errno(0x2a)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x62)
- ENOSTR = syscall.Errno(0x63)
- ENOSYS = syscall.Errno(0x4e)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x39)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x42)
- ENOTRECOVERABLE = syscall.Errno(0x68)
- ENOTSOCK = syscall.Errno(0x26)
- ENOTSUP = syscall.Errno(0x2d)
- ENOTTY = syscall.Errno(0x19)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x66)
- EOVERFLOW = syscall.Errno(0x54)
- EOWNERDEAD = syscall.Errno(0x69)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x2e)
- EPIPE = syscall.Errno(0x20)
- EPROCLIM = syscall.Errno(0x43)
- EPROCUNAVAIL = syscall.Errno(0x4c)
- EPROGMISMATCH = syscall.Errno(0x4b)
- EPROGUNAVAIL = syscall.Errno(0x4a)
- EPROTO = syscall.Errno(0x64)
- EPROTONOSUPPORT = syscall.Errno(0x2b)
- EPROTOTYPE = syscall.Errno(0x29)
- EPWROFF = syscall.Errno(0x52)
- EQFULL = syscall.Errno(0x6a)
- ERANGE = syscall.Errno(0x22)
- EREMOTE = syscall.Errno(0x47)
- EROFS = syscall.Errno(0x1e)
- ERPCMISMATCH = syscall.Errno(0x49)
- ESHLIBVERS = syscall.Errno(0x57)
- ESHUTDOWN = syscall.Errno(0x3a)
- ESOCKTNOSUPPORT = syscall.Errno(0x2c)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESTALE = syscall.Errno(0x46)
- ETIME = syscall.Errno(0x65)
- ETIMEDOUT = syscall.Errno(0x3c)
- ETOOMANYREFS = syscall.Errno(0x3b)
- ETXTBSY = syscall.Errno(0x1a)
- EUSERS = syscall.Errno(0x44)
- EWOULDBLOCK = syscall.Errno(0x23)
- EXDEV = syscall.Errno(0x12)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0xa)
- SIGCHLD = syscall.Signal(0x14)
- SIGCONT = syscall.Signal(0x13)
- SIGEMT = syscall.Signal(0x7)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINFO = syscall.Signal(0x1d)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x17)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPROF = syscall.Signal(0x1b)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTOP = syscall.Signal(0x11)
- SIGSYS = syscall.Signal(0xc)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x12)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGURG = syscall.Signal(0x10)
- SIGUSR1 = syscall.Signal(0x1e)
- SIGUSR2 = syscall.Signal(0x1f)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "device not configured",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource deadlock avoided",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "resource busy",
- 17: "file exists",
- 18: "cross-device link",
- 19: "operation not supported by device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "result too large",
- 35: "resource temporarily unavailable",
- 36: "operation now in progress",
- 37: "operation already in progress",
- 38: "socket operation on non-socket",
- 39: "destination address required",
- 40: "message too long",
- 41: "protocol wrong type for socket",
- 42: "protocol not available",
- 43: "protocol not supported",
- 44: "socket type not supported",
- 45: "operation not supported",
- 46: "protocol family not supported",
- 47: "address family not supported by protocol family",
- 48: "address already in use",
- 49: "can't assign requested address",
- 50: "network is down",
- 51: "network is unreachable",
- 52: "network dropped connection on reset",
- 53: "software caused connection abort",
- 54: "connection reset by peer",
- 55: "no buffer space available",
- 56: "socket is already connected",
- 57: "socket is not connected",
- 58: "can't send after socket shutdown",
- 59: "too many references: can't splice",
- 60: "operation timed out",
- 61: "connection refused",
- 62: "too many levels of symbolic links",
- 63: "file name too long",
- 64: "host is down",
- 65: "no route to host",
- 66: "directory not empty",
- 67: "too many processes",
- 68: "too many users",
- 69: "disc quota exceeded",
- 70: "stale NFS file handle",
- 71: "too many levels of remote in path",
- 72: "RPC struct is bad",
- 73: "RPC version wrong",
- 74: "RPC prog. not avail",
- 75: "program version wrong",
- 76: "bad procedure for program",
- 77: "no locks available",
- 78: "function not implemented",
- 79: "inappropriate file type or format",
- 80: "authentication error",
- 81: "need authenticator",
- 82: "device power is off",
- 83: "device error",
- 84: "value too large to be stored in data type",
- 85: "bad executable (or shared library)",
- 86: "bad CPU type in executable",
- 87: "shared library version mismatch",
- 88: "malformed Mach-o file",
- 89: "operation canceled",
- 90: "identifier removed",
- 91: "no message of desired type",
- 92: "illegal byte sequence",
- 93: "attribute not found",
- 94: "bad message",
- 95: "EMULTIHOP (Reserved)",
- 96: "no message available on STREAM",
- 97: "ENOLINK (Reserved)",
- 98: "no STREAM resources",
- 99: "not a STREAM",
- 100: "protocol error",
- 101: "STREAM ioctl timeout",
- 102: "operation not supported on socket",
- 103: "policy not found",
- 104: "state not recoverable",
- 105: "previous owner died",
- 106: "interface output queue is full",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/BPT trap",
- 6: "abort trap",
- 7: "EMT trap",
- 8: "floating point exception",
- 9: "killed",
- 10: "bus error",
- 11: "segmentation fault",
- 12: "bad system call",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "urgent I/O condition",
- 17: "suspended (signal)",
- 18: "suspended",
- 19: "continued",
- 20: "child exited",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "I/O possible",
- 24: "cputime limit exceeded",
- 25: "filesize limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window size changes",
- 29: "information request",
- 30: "user defined signal 1",
- 31: "user defined signal 2",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/newt/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go
deleted file mode 100644
index 9594f938..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go
+++ /dev/null
@@ -1,1576 +0,0 @@
-// mkerrors.sh -m64
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build amd64,darwin
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -m64 _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_APPLETALK = 0x10
- AF_CCITT = 0xa
- AF_CHAOS = 0x5
- AF_CNT = 0x15
- AF_COIP = 0x14
- AF_DATAKIT = 0x9
- AF_DECnet = 0xc
- AF_DLI = 0xd
- AF_E164 = 0x1c
- AF_ECMA = 0x8
- AF_HYLINK = 0xf
- AF_IEEE80211 = 0x25
- AF_IMPLINK = 0x3
- AF_INET = 0x2
- AF_INET6 = 0x1e
- AF_IPX = 0x17
- AF_ISDN = 0x1c
- AF_ISO = 0x7
- AF_LAT = 0xe
- AF_LINK = 0x12
- AF_LOCAL = 0x1
- AF_MAX = 0x28
- AF_NATM = 0x1f
- AF_NDRV = 0x1b
- AF_NETBIOS = 0x21
- AF_NS = 0x6
- AF_OSI = 0x7
- AF_PPP = 0x22
- AF_PUP = 0x4
- AF_RESERVED_36 = 0x24
- AF_ROUTE = 0x11
- AF_SIP = 0x18
- AF_SNA = 0xb
- AF_SYSTEM = 0x20
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_UTUN = 0x26
- B0 = 0x0
- B110 = 0x6e
- B115200 = 0x1c200
- B1200 = 0x4b0
- B134 = 0x86
- B14400 = 0x3840
- B150 = 0x96
- B1800 = 0x708
- B19200 = 0x4b00
- B200 = 0xc8
- B230400 = 0x38400
- B2400 = 0x960
- B28800 = 0x7080
- B300 = 0x12c
- B38400 = 0x9600
- B4800 = 0x12c0
- B50 = 0x32
- B57600 = 0xe100
- B600 = 0x258
- B7200 = 0x1c20
- B75 = 0x4b
- B76800 = 0x12c00
- B9600 = 0x2580
- BIOCFLUSH = 0x20004268
- BIOCGBLEN = 0x40044266
- BIOCGDLT = 0x4004426a
- BIOCGDLTLIST = 0xc00c4279
- BIOCGETIF = 0x4020426b
- BIOCGHDRCMPLT = 0x40044274
- BIOCGRSIG = 0x40044272
- BIOCGRTIMEOUT = 0x4010426e
- BIOCGSEESENT = 0x40044276
- BIOCGSTATS = 0x4008426f
- BIOCIMMEDIATE = 0x80044270
- BIOCPROMISC = 0x20004269
- BIOCSBLEN = 0xc0044266
- BIOCSDLT = 0x80044278
- BIOCSETF = 0x80104267
- BIOCSETFNR = 0x8010427e
- BIOCSETIF = 0x8020426c
- BIOCSHDRCMPLT = 0x80044275
- BIOCSRSIG = 0x80044273
- BIOCSRTIMEOUT = 0x8010426d
- BIOCSSEESENT = 0x80044277
- BIOCVERSION = 0x40044271
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALIGNMENT = 0x4
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXBUFSIZE = 0x80000
- BPF_MAXINSNS = 0x200
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINBUFSIZE = 0x20
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RELEASE = 0x30bb6
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BRKINT = 0x2
- CFLUSH = 0xf
- CLOCAL = 0x8000
- CREAD = 0x800
- CS5 = 0x0
- CS6 = 0x100
- CS7 = 0x200
- CS8 = 0x300
- CSIZE = 0x300
- CSTART = 0x11
- CSTATUS = 0x14
- CSTOP = 0x13
- CSTOPB = 0x400
- CSUSP = 0x1a
- CTL_MAXNAME = 0xc
- CTL_NET = 0x4
- DLT_A429 = 0xb8
- DLT_A653_ICM = 0xb9
- DLT_AIRONET_HEADER = 0x78
- DLT_AOS = 0xde
- DLT_APPLE_IP_OVER_IEEE1394 = 0x8a
- DLT_ARCNET = 0x7
- DLT_ARCNET_LINUX = 0x81
- DLT_ATM_CLIP = 0x13
- DLT_ATM_RFC1483 = 0xb
- DLT_AURORA = 0x7e
- DLT_AX25 = 0x3
- DLT_AX25_KISS = 0xca
- DLT_BACNET_MS_TP = 0xa5
- DLT_BLUETOOTH_HCI_H4 = 0xbb
- DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9
- DLT_CAN20B = 0xbe
- DLT_CAN_SOCKETCAN = 0xe3
- DLT_CHAOS = 0x5
- DLT_CHDLC = 0x68
- DLT_CISCO_IOS = 0x76
- DLT_C_HDLC = 0x68
- DLT_C_HDLC_WITH_DIR = 0xcd
- DLT_DBUS = 0xe7
- DLT_DECT = 0xdd
- DLT_DOCSIS = 0x8f
- DLT_DVB_CI = 0xeb
- DLT_ECONET = 0x73
- DLT_EN10MB = 0x1
- DLT_EN3MB = 0x2
- DLT_ENC = 0x6d
- DLT_ERF = 0xc5
- DLT_ERF_ETH = 0xaf
- DLT_ERF_POS = 0xb0
- DLT_FC_2 = 0xe0
- DLT_FC_2_WITH_FRAME_DELIMS = 0xe1
- DLT_FDDI = 0xa
- DLT_FLEXRAY = 0xd2
- DLT_FRELAY = 0x6b
- DLT_FRELAY_WITH_DIR = 0xce
- DLT_GCOM_SERIAL = 0xad
- DLT_GCOM_T1E1 = 0xac
- DLT_GPF_F = 0xab
- DLT_GPF_T = 0xaa
- DLT_GPRS_LLC = 0xa9
- DLT_GSMTAP_ABIS = 0xda
- DLT_GSMTAP_UM = 0xd9
- DLT_HHDLC = 0x79
- DLT_IBM_SN = 0x92
- DLT_IBM_SP = 0x91
- DLT_IEEE802 = 0x6
- DLT_IEEE802_11 = 0x69
- DLT_IEEE802_11_RADIO = 0x7f
- DLT_IEEE802_11_RADIO_AVS = 0xa3
- DLT_IEEE802_15_4 = 0xc3
- DLT_IEEE802_15_4_LINUX = 0xbf
- DLT_IEEE802_15_4_NOFCS = 0xe6
- DLT_IEEE802_15_4_NONASK_PHY = 0xd7
- DLT_IEEE802_16_MAC_CPS = 0xbc
- DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1
- DLT_IPFILTER = 0x74
- DLT_IPMB = 0xc7
- DLT_IPMB_LINUX = 0xd1
- DLT_IPNET = 0xe2
- DLT_IPOIB = 0xf2
- DLT_IPV4 = 0xe4
- DLT_IPV6 = 0xe5
- DLT_IP_OVER_FC = 0x7a
- DLT_JUNIPER_ATM1 = 0x89
- DLT_JUNIPER_ATM2 = 0x87
- DLT_JUNIPER_ATM_CEMIC = 0xee
- DLT_JUNIPER_CHDLC = 0xb5
- DLT_JUNIPER_ES = 0x84
- DLT_JUNIPER_ETHER = 0xb2
- DLT_JUNIPER_FIBRECHANNEL = 0xea
- DLT_JUNIPER_FRELAY = 0xb4
- DLT_JUNIPER_GGSN = 0x85
- DLT_JUNIPER_ISM = 0xc2
- DLT_JUNIPER_MFR = 0x86
- DLT_JUNIPER_MLFR = 0x83
- DLT_JUNIPER_MLPPP = 0x82
- DLT_JUNIPER_MONITOR = 0xa4
- DLT_JUNIPER_PIC_PEER = 0xae
- DLT_JUNIPER_PPP = 0xb3
- DLT_JUNIPER_PPPOE = 0xa7
- DLT_JUNIPER_PPPOE_ATM = 0xa8
- DLT_JUNIPER_SERVICES = 0x88
- DLT_JUNIPER_SRX_E2E = 0xe9
- DLT_JUNIPER_ST = 0xc8
- DLT_JUNIPER_VP = 0xb7
- DLT_JUNIPER_VS = 0xe8
- DLT_LAPB_WITH_DIR = 0xcf
- DLT_LAPD = 0xcb
- DLT_LIN = 0xd4
- DLT_LINUX_EVDEV = 0xd8
- DLT_LINUX_IRDA = 0x90
- DLT_LINUX_LAPD = 0xb1
- DLT_LINUX_PPP_WITHDIRECTION = 0xa6
- DLT_LINUX_SLL = 0x71
- DLT_LOOP = 0x6c
- DLT_LTALK = 0x72
- DLT_MATCHING_MAX = 0xf5
- DLT_MATCHING_MIN = 0x68
- DLT_MFR = 0xb6
- DLT_MOST = 0xd3
- DLT_MPEG_2_TS = 0xf3
- DLT_MPLS = 0xdb
- DLT_MTP2 = 0x8c
- DLT_MTP2_WITH_PHDR = 0x8b
- DLT_MTP3 = 0x8d
- DLT_MUX27010 = 0xec
- DLT_NETANALYZER = 0xf0
- DLT_NETANALYZER_TRANSPARENT = 0xf1
- DLT_NFC_LLCP = 0xf5
- DLT_NFLOG = 0xef
- DLT_NG40 = 0xf4
- DLT_NULL = 0x0
- DLT_PCI_EXP = 0x7d
- DLT_PFLOG = 0x75
- DLT_PFSYNC = 0x12
- DLT_PPI = 0xc0
- DLT_PPP = 0x9
- DLT_PPP_BSDOS = 0x10
- DLT_PPP_ETHER = 0x33
- DLT_PPP_PPPD = 0xa6
- DLT_PPP_SERIAL = 0x32
- DLT_PPP_WITH_DIR = 0xcc
- DLT_PPP_WITH_DIRECTION = 0xa6
- DLT_PRISM_HEADER = 0x77
- DLT_PRONET = 0x4
- DLT_RAIF1 = 0xc6
- DLT_RAW = 0xc
- DLT_RIO = 0x7c
- DLT_SCCP = 0x8e
- DLT_SITA = 0xc4
- DLT_SLIP = 0x8
- DLT_SLIP_BSDOS = 0xf
- DLT_STANAG_5066_D_PDU = 0xed
- DLT_SUNATM = 0x7b
- DLT_SYMANTEC_FIREWALL = 0x63
- DLT_TZSP = 0x80
- DLT_USB = 0xba
- DLT_USB_LINUX = 0xbd
- DLT_USB_LINUX_MMAPPED = 0xdc
- DLT_USER0 = 0x93
- DLT_USER1 = 0x94
- DLT_USER10 = 0x9d
- DLT_USER11 = 0x9e
- DLT_USER12 = 0x9f
- DLT_USER13 = 0xa0
- DLT_USER14 = 0xa1
- DLT_USER15 = 0xa2
- DLT_USER2 = 0x95
- DLT_USER3 = 0x96
- DLT_USER4 = 0x97
- DLT_USER5 = 0x98
- DLT_USER6 = 0x99
- DLT_USER7 = 0x9a
- DLT_USER8 = 0x9b
- DLT_USER9 = 0x9c
- DLT_WIHART = 0xdf
- DLT_X2E_SERIAL = 0xd5
- DLT_X2E_XORAYA = 0xd6
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x40
- ECHOE = 0x2
- ECHOK = 0x4
- ECHOKE = 0x1
- ECHONL = 0x10
- ECHOPRT = 0x20
- EVFILT_AIO = -0x3
- EVFILT_FS = -0x9
- EVFILT_MACHPORT = -0x8
- EVFILT_PROC = -0x5
- EVFILT_READ = -0x1
- EVFILT_SIGNAL = -0x6
- EVFILT_SYSCOUNT = 0xe
- EVFILT_THREADMARKER = 0xe
- EVFILT_TIMER = -0x7
- EVFILT_USER = -0xa
- EVFILT_VM = -0xc
- EVFILT_VNODE = -0x4
- EVFILT_WRITE = -0x2
- EV_ADD = 0x1
- EV_CLEAR = 0x20
- EV_DELETE = 0x2
- EV_DISABLE = 0x8
- EV_DISPATCH = 0x80
- EV_ENABLE = 0x4
- EV_EOF = 0x8000
- EV_ERROR = 0x4000
- EV_FLAG0 = 0x1000
- EV_FLAG1 = 0x2000
- EV_ONESHOT = 0x10
- EV_OOBAND = 0x2000
- EV_POLL = 0x1000
- EV_RECEIPT = 0x40
- EV_SYSFLAGS = 0xf000
- EXTA = 0x4b00
- EXTB = 0x9600
- EXTPROC = 0x800
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FLUSHO = 0x800000
- F_ADDFILESIGS = 0x3d
- F_ADDSIGS = 0x3b
- F_ALLOCATEALL = 0x4
- F_ALLOCATECONTIG = 0x2
- F_CHKCLEAN = 0x29
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x43
- F_FINDSIGS = 0x4e
- F_FLUSH_DATA = 0x28
- F_FREEZE_FS = 0x35
- F_FULLFSYNC = 0x33
- F_GETCODEDIR = 0x48
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLK = 0x7
- F_GETLKPID = 0x42
- F_GETNOSIGPIPE = 0x4a
- F_GETOWN = 0x5
- F_GETPATH = 0x32
- F_GETPATH_MTMINFO = 0x47
- F_GETPROTECTIONCLASS = 0x3f
- F_GETPROTECTIONLEVEL = 0x4d
- F_GLOBAL_NOCACHE = 0x37
- F_LOG2PHYS = 0x31
- F_LOG2PHYS_EXT = 0x41
- F_NOCACHE = 0x30
- F_NODIRECT = 0x3e
- F_OK = 0x0
- F_PATHPKG_CHECK = 0x34
- F_PEOFPOSMODE = 0x3
- F_PREALLOCATE = 0x2a
- F_RDADVISE = 0x2c
- F_RDAHEAD = 0x2d
- F_RDLCK = 0x1
- F_SETBACKINGSTORE = 0x46
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLK = 0x8
- F_SETLKW = 0x9
- F_SETLKWTIMEOUT = 0xa
- F_SETNOSIGPIPE = 0x49
- F_SETOWN = 0x6
- F_SETPROTECTIONCLASS = 0x40
- F_SETSIZE = 0x2b
- F_SINGLE_WRITER = 0x4c
- F_THAW_FS = 0x36
- F_TRANSCODEKEY = 0x4b
- F_UNLCK = 0x2
- F_VOLPOSMODE = 0x4
- F_WRLCK = 0x3
- HUPCL = 0x4000
- ICANON = 0x100
- ICMP6_FILTER = 0x12
- ICRNL = 0x100
- IEXTEN = 0x400
- IFF_ALLMULTI = 0x200
- IFF_ALTPHYS = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_LINK0 = 0x1000
- IFF_LINK1 = 0x2000
- IFF_LINK2 = 0x4000
- IFF_LOOPBACK = 0x8
- IFF_MULTICAST = 0x8000
- IFF_NOARP = 0x80
- IFF_NOTRAILERS = 0x20
- IFF_OACTIVE = 0x400
- IFF_POINTOPOINT = 0x10
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SIMPLEX = 0x800
- IFF_UP = 0x1
- IFNAMSIZ = 0x10
- IFT_1822 = 0x2
- IFT_AAL5 = 0x31
- IFT_ARCNET = 0x23
- IFT_ARCNETPLUS = 0x24
- IFT_ATM = 0x25
- IFT_BRIDGE = 0xd1
- IFT_CARP = 0xf8
- IFT_CELLULAR = 0xff
- IFT_CEPT = 0x13
- IFT_DS3 = 0x1e
- IFT_ENC = 0xf4
- IFT_EON = 0x19
- IFT_ETHER = 0x6
- IFT_FAITH = 0x38
- IFT_FDDI = 0xf
- IFT_FRELAY = 0x20
- IFT_FRELAYDCE = 0x2c
- IFT_GIF = 0x37
- IFT_HDH1822 = 0x3
- IFT_HIPPI = 0x2f
- IFT_HSSI = 0x2e
- IFT_HY = 0xe
- IFT_IEEE1394 = 0x90
- IFT_IEEE8023ADLAG = 0x88
- IFT_ISDNBASIC = 0x14
- IFT_ISDNPRIMARY = 0x15
- IFT_ISO88022LLC = 0x29
- IFT_ISO88023 = 0x7
- IFT_ISO88024 = 0x8
- IFT_ISO88025 = 0x9
- IFT_ISO88026 = 0xa
- IFT_L2VLAN = 0x87
- IFT_LAPB = 0x10
- IFT_LOCALTALK = 0x2a
- IFT_LOOP = 0x18
- IFT_MIOX25 = 0x26
- IFT_MODEM = 0x30
- IFT_NSIP = 0x1b
- IFT_OTHER = 0x1
- IFT_P10 = 0xc
- IFT_P80 = 0xd
- IFT_PARA = 0x22
- IFT_PDP = 0xff
- IFT_PFLOG = 0xf5
- IFT_PFSYNC = 0xf6
- IFT_PKTAP = 0xfe
- IFT_PPP = 0x17
- IFT_PROPMUX = 0x36
- IFT_PROPVIRTUAL = 0x35
- IFT_PTPSERIAL = 0x16
- IFT_RS232 = 0x21
- IFT_SDLC = 0x11
- IFT_SIP = 0x1f
- IFT_SLIP = 0x1c
- IFT_SMDSDXI = 0x2b
- IFT_SMDSICIP = 0x34
- IFT_SONET = 0x27
- IFT_SONETPATH = 0x32
- IFT_SONETVT = 0x33
- IFT_STARLAN = 0xb
- IFT_STF = 0x39
- IFT_T1 = 0x12
- IFT_ULTRA = 0x1d
- IFT_V35 = 0x2d
- IFT_X25 = 0x5
- IFT_X25DDN = 0x4
- IFT_X25PLE = 0x28
- IFT_XETHER = 0x1a
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLASSD_HOST = 0xfffffff
- IN_CLASSD_NET = 0xf0000000
- IN_CLASSD_NSHIFT = 0x1c
- IN_LINKLOCALNETNUM = 0xa9fe0000
- IN_LOOPBACKNET = 0x7f
- IPPROTO_3PC = 0x22
- IPPROTO_ADFS = 0x44
- IPPROTO_AH = 0x33
- IPPROTO_AHIP = 0x3d
- IPPROTO_APES = 0x63
- IPPROTO_ARGUS = 0xd
- IPPROTO_AX25 = 0x5d
- IPPROTO_BHA = 0x31
- IPPROTO_BLT = 0x1e
- IPPROTO_BRSATMON = 0x4c
- IPPROTO_CFTP = 0x3e
- IPPROTO_CHAOS = 0x10
- IPPROTO_CMTP = 0x26
- IPPROTO_CPHB = 0x49
- IPPROTO_CPNX = 0x48
- IPPROTO_DDP = 0x25
- IPPROTO_DGP = 0x56
- IPPROTO_DIVERT = 0xfe
- IPPROTO_DONE = 0x101
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_EMCON = 0xe
- IPPROTO_ENCAP = 0x62
- IPPROTO_EON = 0x50
- IPPROTO_ESP = 0x32
- IPPROTO_ETHERIP = 0x61
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GGP = 0x3
- IPPROTO_GMTP = 0x64
- IPPROTO_GRE = 0x2f
- IPPROTO_HELLO = 0x3f
- IPPROTO_HMP = 0x14
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IDPR = 0x23
- IPPROTO_IDRP = 0x2d
- IPPROTO_IGMP = 0x2
- IPPROTO_IGP = 0x55
- IPPROTO_IGRP = 0x58
- IPPROTO_IL = 0x28
- IPPROTO_INLSP = 0x34
- IPPROTO_INP = 0x20
- IPPROTO_IP = 0x0
- IPPROTO_IPCOMP = 0x6c
- IPPROTO_IPCV = 0x47
- IPPROTO_IPEIP = 0x5e
- IPPROTO_IPIP = 0x4
- IPPROTO_IPPC = 0x43
- IPPROTO_IPV4 = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_IRTP = 0x1c
- IPPROTO_KRYPTOLAN = 0x41
- IPPROTO_LARP = 0x5b
- IPPROTO_LEAF1 = 0x19
- IPPROTO_LEAF2 = 0x1a
- IPPROTO_MAX = 0x100
- IPPROTO_MAXID = 0x34
- IPPROTO_MEAS = 0x13
- IPPROTO_MHRP = 0x30
- IPPROTO_MICP = 0x5f
- IPPROTO_MTP = 0x5c
- IPPROTO_MUX = 0x12
- IPPROTO_ND = 0x4d
- IPPROTO_NHRP = 0x36
- IPPROTO_NONE = 0x3b
- IPPROTO_NSP = 0x1f
- IPPROTO_NVPII = 0xb
- IPPROTO_OSPFIGP = 0x59
- IPPROTO_PGM = 0x71
- IPPROTO_PIGP = 0x9
- IPPROTO_PIM = 0x67
- IPPROTO_PRM = 0x15
- IPPROTO_PUP = 0xc
- IPPROTO_PVP = 0x4b
- IPPROTO_RAW = 0xff
- IPPROTO_RCCMON = 0xa
- IPPROTO_RDP = 0x1b
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_RVD = 0x42
- IPPROTO_SATEXPAK = 0x40
- IPPROTO_SATMON = 0x45
- IPPROTO_SCCSP = 0x60
- IPPROTO_SCTP = 0x84
- IPPROTO_SDRP = 0x2a
- IPPROTO_SEP = 0x21
- IPPROTO_SRPC = 0x5a
- IPPROTO_ST = 0x7
- IPPROTO_SVMTP = 0x52
- IPPROTO_SWIPE = 0x35
- IPPROTO_TCF = 0x57
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_TPXX = 0x27
- IPPROTO_TRUNK1 = 0x17
- IPPROTO_TRUNK2 = 0x18
- IPPROTO_TTP = 0x54
- IPPROTO_UDP = 0x11
- IPPROTO_VINES = 0x53
- IPPROTO_VISA = 0x46
- IPPROTO_VMTP = 0x51
- IPPROTO_WBEXPAK = 0x4f
- IPPROTO_WBMON = 0x4e
- IPPROTO_WSN = 0x4a
- IPPROTO_XNET = 0xf
- IPPROTO_XTP = 0x24
- IPV6_2292DSTOPTS = 0x17
- IPV6_2292HOPLIMIT = 0x14
- IPV6_2292HOPOPTS = 0x16
- IPV6_2292NEXTHOP = 0x15
- IPV6_2292PKTINFO = 0x13
- IPV6_2292PKTOPTIONS = 0x19
- IPV6_2292RTHDR = 0x18
- IPV6_BINDV6ONLY = 0x1b
- IPV6_BOUND_IF = 0x7d
- IPV6_CHECKSUM = 0x1a
- IPV6_DEFAULT_MULTICAST_HOPS = 0x1
- IPV6_DEFAULT_MULTICAST_LOOP = 0x1
- IPV6_DEFHLIM = 0x40
- IPV6_FAITH = 0x1d
- IPV6_FLOWINFO_MASK = 0xffffff0f
- IPV6_FLOWLABEL_MASK = 0xffff0f00
- IPV6_FRAGTTL = 0x3c
- IPV6_FW_ADD = 0x1e
- IPV6_FW_DEL = 0x1f
- IPV6_FW_FLUSH = 0x20
- IPV6_FW_GET = 0x22
- IPV6_FW_ZERO = 0x21
- IPV6_HLIMDEC = 0x1
- IPV6_IPSEC_POLICY = 0x1c
- IPV6_JOIN_GROUP = 0xc
- IPV6_LEAVE_GROUP = 0xd
- IPV6_MAXHLIM = 0xff
- IPV6_MAXOPTHDR = 0x800
- IPV6_MAXPACKET = 0xffff
- IPV6_MAX_GROUP_SRC_FILTER = 0x200
- IPV6_MAX_MEMBERSHIPS = 0xfff
- IPV6_MAX_SOCK_SRC_FILTER = 0x80
- IPV6_MIN_MEMBERSHIPS = 0x1f
- IPV6_MMTU = 0x500
- IPV6_MULTICAST_HOPS = 0xa
- IPV6_MULTICAST_IF = 0x9
- IPV6_MULTICAST_LOOP = 0xb
- IPV6_PORTRANGE = 0xe
- IPV6_PORTRANGE_DEFAULT = 0x0
- IPV6_PORTRANGE_HIGH = 0x1
- IPV6_PORTRANGE_LOW = 0x2
- IPV6_RECVTCLASS = 0x23
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_SOCKOPT_RESERVED1 = 0x3
- IPV6_TCLASS = 0x24
- IPV6_UNICAST_HOPS = 0x4
- IPV6_V6ONLY = 0x1b
- IPV6_VERSION = 0x60
- IPV6_VERSION_MASK = 0xf0
- IP_ADD_MEMBERSHIP = 0xc
- IP_ADD_SOURCE_MEMBERSHIP = 0x46
- IP_BLOCK_SOURCE = 0x48
- IP_BOUND_IF = 0x19
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0xd
- IP_DROP_SOURCE_MEMBERSHIP = 0x47
- IP_DUMMYNET_CONFIGURE = 0x3c
- IP_DUMMYNET_DEL = 0x3d
- IP_DUMMYNET_FLUSH = 0x3e
- IP_DUMMYNET_GET = 0x40
- IP_FAITH = 0x16
- IP_FW_ADD = 0x28
- IP_FW_DEL = 0x29
- IP_FW_FLUSH = 0x2a
- IP_FW_GET = 0x2c
- IP_FW_RESETLOG = 0x2d
- IP_FW_ZERO = 0x2b
- IP_HDRINCL = 0x2
- IP_IPSEC_POLICY = 0x15
- IP_MAXPACKET = 0xffff
- IP_MAX_GROUP_SRC_FILTER = 0x200
- IP_MAX_MEMBERSHIPS = 0xfff
- IP_MAX_SOCK_MUTE_FILTER = 0x80
- IP_MAX_SOCK_SRC_FILTER = 0x80
- IP_MF = 0x2000
- IP_MIN_MEMBERSHIPS = 0x1f
- IP_MSFILTER = 0x4a
- IP_MSS = 0x240
- IP_MULTICAST_IF = 0x9
- IP_MULTICAST_IFINDEX = 0x42
- IP_MULTICAST_LOOP = 0xb
- IP_MULTICAST_TTL = 0xa
- IP_MULTICAST_VIF = 0xe
- IP_NAT__XXX = 0x37
- IP_OFFMASK = 0x1fff
- IP_OLD_FW_ADD = 0x32
- IP_OLD_FW_DEL = 0x33
- IP_OLD_FW_FLUSH = 0x34
- IP_OLD_FW_GET = 0x36
- IP_OLD_FW_RESETLOG = 0x38
- IP_OLD_FW_ZERO = 0x35
- IP_OPTIONS = 0x1
- IP_PKTINFO = 0x1a
- IP_PORTRANGE = 0x13
- IP_PORTRANGE_DEFAULT = 0x0
- IP_PORTRANGE_HIGH = 0x1
- IP_PORTRANGE_LOW = 0x2
- IP_RECVDSTADDR = 0x7
- IP_RECVIF = 0x14
- IP_RECVOPTS = 0x5
- IP_RECVPKTINFO = 0x1a
- IP_RECVRETOPTS = 0x6
- IP_RECVTTL = 0x18
- IP_RETOPTS = 0x8
- IP_RF = 0x8000
- IP_RSVP_OFF = 0x10
- IP_RSVP_ON = 0xf
- IP_RSVP_VIF_OFF = 0x12
- IP_RSVP_VIF_ON = 0x11
- IP_STRIPHDR = 0x17
- IP_TOS = 0x3
- IP_TRAFFIC_MGT_BACKGROUND = 0x41
- IP_TTL = 0x4
- IP_UNBLOCK_SOURCE = 0x49
- ISIG = 0x80
- ISTRIP = 0x20
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x400
- IXON = 0x200
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_CAN_REUSE = 0x9
- MADV_DONTNEED = 0x4
- MADV_FREE = 0x5
- MADV_FREE_REUSABLE = 0x7
- MADV_FREE_REUSE = 0x8
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_SEQUENTIAL = 0x2
- MADV_WILLNEED = 0x3
- MADV_ZERO_WIRED_PAGES = 0x6
- MAP_ANON = 0x1000
- MAP_COPY = 0x2
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_HASSEMAPHORE = 0x200
- MAP_JIT = 0x800
- MAP_NOCACHE = 0x400
- MAP_NOEXTEND = 0x100
- MAP_NORESERVE = 0x40
- MAP_PRIVATE = 0x2
- MAP_RENAME = 0x20
- MAP_RESERVED0080 = 0x80
- MAP_SHARED = 0x1
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MSG_CTRUNC = 0x20
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x80
- MSG_EOF = 0x100
- MSG_EOR = 0x8
- MSG_FLUSH = 0x400
- MSG_HAVEMORE = 0x2000
- MSG_HOLD = 0x800
- MSG_NEEDSA = 0x10000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_RCVMORE = 0x4000
- MSG_SEND = 0x1000
- MSG_TRUNC = 0x10
- MSG_WAITALL = 0x40
- MSG_WAITSTREAM = 0x200
- MS_ASYNC = 0x1
- MS_DEACTIVATE = 0x8
- MS_INVALIDATE = 0x2
- MS_KILLPAGES = 0x4
- MS_SYNC = 0x10
- NAME_MAX = 0xff
- NET_RT_DUMP = 0x1
- NET_RT_DUMP2 = 0x7
- NET_RT_FLAGS = 0x2
- NET_RT_IFLIST = 0x3
- NET_RT_IFLIST2 = 0x6
- NET_RT_MAXID = 0xa
- NET_RT_STAT = 0x4
- NET_RT_TRASH = 0x5
- NOFLSH = 0x80000000
- NOTE_ABSOLUTE = 0x8
- NOTE_ATTRIB = 0x8
- NOTE_BACKGROUND = 0x40
- NOTE_CHILD = 0x4
- NOTE_CRITICAL = 0x20
- NOTE_DELETE = 0x1
- NOTE_EXEC = 0x20000000
- NOTE_EXIT = 0x80000000
- NOTE_EXITSTATUS = 0x4000000
- NOTE_EXIT_CSERROR = 0x40000
- NOTE_EXIT_DECRYPTFAIL = 0x10000
- NOTE_EXIT_DETAIL = 0x2000000
- NOTE_EXIT_DETAIL_MASK = 0x70000
- NOTE_EXIT_MEMORY = 0x20000
- NOTE_EXIT_REPARENTED = 0x80000
- NOTE_EXTEND = 0x4
- NOTE_FFAND = 0x40000000
- NOTE_FFCOPY = 0xc0000000
- NOTE_FFCTRLMASK = 0xc0000000
- NOTE_FFLAGSMASK = 0xffffff
- NOTE_FFNOP = 0x0
- NOTE_FFOR = 0x80000000
- NOTE_FORK = 0x40000000
- NOTE_LEEWAY = 0x10
- NOTE_LINK = 0x10
- NOTE_LOWAT = 0x1
- NOTE_NONE = 0x80
- NOTE_NSECONDS = 0x4
- NOTE_PCTRLMASK = -0x100000
- NOTE_PDATAMASK = 0xfffff
- NOTE_REAP = 0x10000000
- NOTE_RENAME = 0x20
- NOTE_REVOKE = 0x40
- NOTE_SECONDS = 0x1
- NOTE_SIGNAL = 0x8000000
- NOTE_TRACK = 0x1
- NOTE_TRACKERR = 0x2
- NOTE_TRIGGER = 0x1000000
- NOTE_USECONDS = 0x2
- NOTE_VM_ERROR = 0x10000000
- NOTE_VM_PRESSURE = 0x80000000
- NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000
- NOTE_VM_PRESSURE_TERMINATE = 0x40000000
- NOTE_WRITE = 0x2
- OCRNL = 0x10
- OFDEL = 0x20000
- OFILL = 0x80
- ONLCR = 0x2
- ONLRET = 0x40
- ONOCR = 0x20
- ONOEOT = 0x8
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_ALERT = 0x20000000
- O_APPEND = 0x8
- O_ASYNC = 0x40
- O_CLOEXEC = 0x1000000
- O_CREAT = 0x200
- O_DIRECTORY = 0x100000
- O_DP_GETRAWENCRYPTED = 0x1
- O_DSYNC = 0x400000
- O_EVTONLY = 0x8000
- O_EXCL = 0x800
- O_EXLOCK = 0x20
- O_FSYNC = 0x80
- O_NDELAY = 0x4
- O_NOCTTY = 0x20000
- O_NOFOLLOW = 0x100
- O_NONBLOCK = 0x4
- O_POPUP = 0x80000000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_SHLOCK = 0x10
- O_SYMLINK = 0x200000
- O_SYNC = 0x80
- O_TRUNC = 0x400
- O_WRONLY = 0x1
- PARENB = 0x1000
- PARMRK = 0x8
- PARODD = 0x2000
- PENDIN = 0x20000000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- PT_ATTACH = 0xa
- PT_ATTACHEXC = 0xe
- PT_CONTINUE = 0x7
- PT_DENY_ATTACH = 0x1f
- PT_DETACH = 0xb
- PT_FIRSTMACH = 0x20
- PT_FORCEQUOTA = 0x1e
- PT_KILL = 0x8
- PT_READ_D = 0x2
- PT_READ_I = 0x1
- PT_READ_U = 0x3
- PT_SIGEXC = 0xc
- PT_STEP = 0x9
- PT_THUPDATE = 0xd
- PT_TRACE_ME = 0x0
- PT_WRITE_D = 0x5
- PT_WRITE_I = 0x4
- PT_WRITE_U = 0x6
- RLIMIT_AS = 0x5
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_CPU_USAGE_MONITOR = 0x2
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x8
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = 0x7fffffffffffffff
- RTAX_AUTHOR = 0x6
- RTAX_BRD = 0x7
- RTAX_DST = 0x0
- RTAX_GATEWAY = 0x1
- RTAX_GENMASK = 0x3
- RTAX_IFA = 0x5
- RTAX_IFP = 0x4
- RTAX_MAX = 0x8
- RTAX_NETMASK = 0x2
- RTA_AUTHOR = 0x40
- RTA_BRD = 0x80
- RTA_DST = 0x1
- RTA_GATEWAY = 0x2
- RTA_GENMASK = 0x8
- RTA_IFA = 0x20
- RTA_IFP = 0x10
- RTA_NETMASK = 0x4
- RTF_BLACKHOLE = 0x1000
- RTF_BROADCAST = 0x400000
- RTF_CLONING = 0x100
- RTF_CONDEMNED = 0x2000000
- RTF_DELCLONE = 0x80
- RTF_DONE = 0x40
- RTF_DYNAMIC = 0x10
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_IFREF = 0x4000000
- RTF_IFSCOPE = 0x1000000
- RTF_LLINFO = 0x400
- RTF_LOCAL = 0x200000
- RTF_MODIFIED = 0x20
- RTF_MULTICAST = 0x800000
- RTF_NOIFREF = 0x2000
- RTF_PINNED = 0x100000
- RTF_PRCLONING = 0x10000
- RTF_PROTO1 = 0x8000
- RTF_PROTO2 = 0x4000
- RTF_PROTO3 = 0x40000
- RTF_PROXY = 0x8000000
- RTF_REJECT = 0x8
- RTF_ROUTER = 0x10000000
- RTF_STATIC = 0x800
- RTF_UP = 0x1
- RTF_WASCLONED = 0x20000
- RTF_XRESOLVE = 0x200
- RTM_ADD = 0x1
- RTM_CHANGE = 0x3
- RTM_DELADDR = 0xd
- RTM_DELETE = 0x2
- RTM_DELMADDR = 0x10
- RTM_GET = 0x4
- RTM_GET2 = 0x14
- RTM_IFINFO = 0xe
- RTM_IFINFO2 = 0x12
- RTM_LOCK = 0x8
- RTM_LOSING = 0x5
- RTM_MISS = 0x7
- RTM_NEWADDR = 0xc
- RTM_NEWMADDR = 0xf
- RTM_NEWMADDR2 = 0x13
- RTM_OLDADD = 0x9
- RTM_OLDDEL = 0xa
- RTM_REDIRECT = 0x6
- RTM_RESOLVE = 0xb
- RTM_RTTUNIT = 0xf4240
- RTM_VERSION = 0x5
- RTV_EXPIRE = 0x4
- RTV_HOPCOUNT = 0x2
- RTV_MTU = 0x1
- RTV_RPIPE = 0x8
- RTV_RTT = 0x40
- RTV_RTTVAR = 0x80
- RTV_SPIPE = 0x10
- RTV_SSTHRESH = 0x20
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- SCM_CREDS = 0x3
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x2
- SCM_TIMESTAMP_MONOTONIC = 0x4
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDMULTI = 0x80206931
- SIOCAIFADDR = 0x8040691a
- SIOCARPIPLL = 0xc0206928
- SIOCATMARK = 0x40047307
- SIOCAUTOADDR = 0xc0206926
- SIOCAUTONETMASK = 0x80206927
- SIOCDELMULTI = 0x80206932
- SIOCDIFADDR = 0x80206919
- SIOCDIFPHYADDR = 0x80206941
- SIOCGDRVSPEC = 0xc028697b
- SIOCGETVLAN = 0xc020697f
- SIOCGHIWAT = 0x40047301
- SIOCGIFADDR = 0xc0206921
- SIOCGIFALTMTU = 0xc0206948
- SIOCGIFASYNCMAP = 0xc020697c
- SIOCGIFBOND = 0xc0206947
- SIOCGIFBRDADDR = 0xc0206923
- SIOCGIFCAP = 0xc020695b
- SIOCGIFCONF = 0xc00c6924
- SIOCGIFDEVMTU = 0xc0206944
- SIOCGIFDSTADDR = 0xc0206922
- SIOCGIFFLAGS = 0xc0206911
- SIOCGIFGENERIC = 0xc020693a
- SIOCGIFKPI = 0xc0206987
- SIOCGIFMAC = 0xc0206982
- SIOCGIFMEDIA = 0xc02c6938
- SIOCGIFMETRIC = 0xc0206917
- SIOCGIFMTU = 0xc0206933
- SIOCGIFNETMASK = 0xc0206925
- SIOCGIFPDSTADDR = 0xc0206940
- SIOCGIFPHYS = 0xc0206935
- SIOCGIFPSRCADDR = 0xc020693f
- SIOCGIFSTATUS = 0xc331693d
- SIOCGIFVLAN = 0xc020697f
- SIOCGIFWAKEFLAGS = 0xc0206988
- SIOCGLOWAT = 0x40047303
- SIOCGPGRP = 0x40047309
- SIOCIFCREATE = 0xc0206978
- SIOCIFCREATE2 = 0xc020697a
- SIOCIFDESTROY = 0x80206979
- SIOCIFGCLONERS = 0xc0106981
- SIOCRSLVMULTI = 0xc010693b
- SIOCSDRVSPEC = 0x8028697b
- SIOCSETVLAN = 0x8020697e
- SIOCSHIWAT = 0x80047300
- SIOCSIFADDR = 0x8020690c
- SIOCSIFALTMTU = 0x80206945
- SIOCSIFASYNCMAP = 0x8020697d
- SIOCSIFBOND = 0x80206946
- SIOCSIFBRDADDR = 0x80206913
- SIOCSIFCAP = 0x8020695a
- SIOCSIFDSTADDR = 0x8020690e
- SIOCSIFFLAGS = 0x80206910
- SIOCSIFGENERIC = 0x80206939
- SIOCSIFKPI = 0x80206986
- SIOCSIFLLADDR = 0x8020693c
- SIOCSIFMAC = 0x80206983
- SIOCSIFMEDIA = 0xc0206937
- SIOCSIFMETRIC = 0x80206918
- SIOCSIFMTU = 0x80206934
- SIOCSIFNETMASK = 0x80206916
- SIOCSIFPHYADDR = 0x8040693e
- SIOCSIFPHYS = 0x80206936
- SIOCSIFVLAN = 0x8020697e
- SIOCSLOWAT = 0x80047302
- SIOCSPGRP = 0x80047308
- SOCK_DGRAM = 0x2
- SOCK_MAXADDRLEN = 0xff
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_SOCKET = 0xffff
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x2
- SO_BROADCAST = 0x20
- SO_DEBUG = 0x1
- SO_DONTROUTE = 0x10
- SO_DONTTRUNC = 0x2000
- SO_ERROR = 0x1007
- SO_KEEPALIVE = 0x8
- SO_LABEL = 0x1010
- SO_LINGER = 0x80
- SO_LINGER_SEC = 0x1080
- SO_NKE = 0x1021
- SO_NOADDRERR = 0x1023
- SO_NOSIGPIPE = 0x1022
- SO_NOTIFYCONFLICT = 0x1026
- SO_NP_EXTENSIONS = 0x1083
- SO_NREAD = 0x1020
- SO_NUMRCVPKT = 0x1112
- SO_NWRITE = 0x1024
- SO_OOBINLINE = 0x100
- SO_PEERLABEL = 0x1011
- SO_RANDOMPORT = 0x1082
- SO_RCVBUF = 0x1002
- SO_RCVLOWAT = 0x1004
- SO_RCVTIMEO = 0x1006
- SO_REUSEADDR = 0x4
- SO_REUSEPORT = 0x200
- SO_REUSESHAREUID = 0x1025
- SO_SNDBUF = 0x1001
- SO_SNDLOWAT = 0x1003
- SO_SNDTIMEO = 0x1005
- SO_TIMESTAMP = 0x400
- SO_TIMESTAMP_MONOTONIC = 0x800
- SO_TYPE = 0x1008
- SO_UPCALLCLOSEWAIT = 0x1027
- SO_USELOOPBACK = 0x40
- SO_WANTMORE = 0x4000
- SO_WANTOOBFLAG = 0x8000
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IFWHT = 0xe000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISTXT = 0x200
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TCIFLUSH = 0x1
- TCIOFLUSH = 0x3
- TCOFLUSH = 0x2
- TCP_CONNECTIONTIMEOUT = 0x20
- TCP_ENABLE_ECN = 0x104
- TCP_KEEPALIVE = 0x10
- TCP_KEEPCNT = 0x102
- TCP_KEEPINTVL = 0x101
- TCP_MAXHLEN = 0x3c
- TCP_MAXOLEN = 0x28
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_SACK = 0x4
- TCP_MAX_WINSHIFT = 0xe
- TCP_MINMSS = 0xd8
- TCP_MSS = 0x200
- TCP_NODELAY = 0x1
- TCP_NOOPT = 0x8
- TCP_NOPUSH = 0x4
- TCP_NOTSENT_LOWAT = 0x201
- TCP_RXT_CONNDROPTIME = 0x80
- TCP_RXT_FINDROP = 0x100
- TCP_SENDMOREACKS = 0x103
- TCSAFLUSH = 0x2
- TIOCCBRK = 0x2000747a
- TIOCCDTR = 0x20007478
- TIOCCONS = 0x80047462
- TIOCDCDTIMESTAMP = 0x40107458
- TIOCDRAIN = 0x2000745e
- TIOCDSIMICROCODE = 0x20007455
- TIOCEXCL = 0x2000740d
- TIOCEXT = 0x80047460
- TIOCFLUSH = 0x80047410
- TIOCGDRAINWAIT = 0x40047456
- TIOCGETA = 0x40487413
- TIOCGETD = 0x4004741a
- TIOCGPGRP = 0x40047477
- TIOCGWINSZ = 0x40087468
- TIOCIXOFF = 0x20007480
- TIOCIXON = 0x20007481
- TIOCMBIC = 0x8004746b
- TIOCMBIS = 0x8004746c
- TIOCMGDTRWAIT = 0x4004745a
- TIOCMGET = 0x4004746a
- TIOCMODG = 0x40047403
- TIOCMODS = 0x80047404
- TIOCMSDTRWAIT = 0x8004745b
- TIOCMSET = 0x8004746d
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x20007471
- TIOCNXCL = 0x2000740e
- TIOCOUTQ = 0x40047473
- TIOCPKT = 0x80047470
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCPTYGNAME = 0x40807453
- TIOCPTYGRANT = 0x20007454
- TIOCPTYUNLK = 0x20007452
- TIOCREMOTE = 0x80047469
- TIOCSBRK = 0x2000747b
- TIOCSCONS = 0x20007463
- TIOCSCTTY = 0x20007461
- TIOCSDRAINWAIT = 0x80047457
- TIOCSDTR = 0x20007479
- TIOCSETA = 0x80487414
- TIOCSETAF = 0x80487416
- TIOCSETAW = 0x80487415
- TIOCSETD = 0x8004741b
- TIOCSIG = 0x2000745f
- TIOCSPGRP = 0x80047476
- TIOCSTART = 0x2000746e
- TIOCSTAT = 0x20007465
- TIOCSTI = 0x80017472
- TIOCSTOP = 0x2000746f
- TIOCSWINSZ = 0x80087467
- TIOCTIMESTAMP = 0x40107459
- TIOCUCNTL = 0x80047466
- TOSTOP = 0x400000
- VDISCARD = 0xf
- VDSUSP = 0xb
- VEOF = 0x0
- VEOL = 0x1
- VEOL2 = 0x2
- VERASE = 0x3
- VINTR = 0x8
- VKILL = 0x5
- VLNEXT = 0xe
- VMIN = 0x10
- VQUIT = 0x9
- VREPRINT = 0x6
- VSTART = 0xc
- VSTATUS = 0x12
- VSTOP = 0xd
- VSUSP = 0xa
- VT0 = 0x0
- VT1 = 0x10000
- VTDLY = 0x10000
- VTIME = 0x11
- VWERASE = 0x4
- WCONTINUED = 0x10
- WCOREFLAG = 0x80
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOWAIT = 0x20
- WORDSIZE = 0x40
- WSTOPPED = 0x8
- WUNTRACED = 0x2
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x30)
- EADDRNOTAVAIL = syscall.Errno(0x31)
- EAFNOSUPPORT = syscall.Errno(0x2f)
- EAGAIN = syscall.Errno(0x23)
- EALREADY = syscall.Errno(0x25)
- EAUTH = syscall.Errno(0x50)
- EBADARCH = syscall.Errno(0x56)
- EBADEXEC = syscall.Errno(0x55)
- EBADF = syscall.Errno(0x9)
- EBADMACHO = syscall.Errno(0x58)
- EBADMSG = syscall.Errno(0x5e)
- EBADRPC = syscall.Errno(0x48)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x59)
- ECHILD = syscall.Errno(0xa)
- ECONNABORTED = syscall.Errno(0x35)
- ECONNREFUSED = syscall.Errno(0x3d)
- ECONNRESET = syscall.Errno(0x36)
- EDEADLK = syscall.Errno(0xb)
- EDESTADDRREQ = syscall.Errno(0x27)
- EDEVERR = syscall.Errno(0x53)
- EDOM = syscall.Errno(0x21)
- EDQUOT = syscall.Errno(0x45)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EFTYPE = syscall.Errno(0x4f)
- EHOSTDOWN = syscall.Errno(0x40)
- EHOSTUNREACH = syscall.Errno(0x41)
- EIDRM = syscall.Errno(0x5a)
- EILSEQ = syscall.Errno(0x5c)
- EINPROGRESS = syscall.Errno(0x24)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x38)
- EISDIR = syscall.Errno(0x15)
- ELAST = syscall.Errno(0x6a)
- ELOOP = syscall.Errno(0x3e)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x28)
- EMULTIHOP = syscall.Errno(0x5f)
- ENAMETOOLONG = syscall.Errno(0x3f)
- ENEEDAUTH = syscall.Errno(0x51)
- ENETDOWN = syscall.Errno(0x32)
- ENETRESET = syscall.Errno(0x34)
- ENETUNREACH = syscall.Errno(0x33)
- ENFILE = syscall.Errno(0x17)
- ENOATTR = syscall.Errno(0x5d)
- ENOBUFS = syscall.Errno(0x37)
- ENODATA = syscall.Errno(0x60)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOLCK = syscall.Errno(0x4d)
- ENOLINK = syscall.Errno(0x61)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x5b)
- ENOPOLICY = syscall.Errno(0x67)
- ENOPROTOOPT = syscall.Errno(0x2a)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x62)
- ENOSTR = syscall.Errno(0x63)
- ENOSYS = syscall.Errno(0x4e)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x39)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x42)
- ENOTRECOVERABLE = syscall.Errno(0x68)
- ENOTSOCK = syscall.Errno(0x26)
- ENOTSUP = syscall.Errno(0x2d)
- ENOTTY = syscall.Errno(0x19)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x66)
- EOVERFLOW = syscall.Errno(0x54)
- EOWNERDEAD = syscall.Errno(0x69)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x2e)
- EPIPE = syscall.Errno(0x20)
- EPROCLIM = syscall.Errno(0x43)
- EPROCUNAVAIL = syscall.Errno(0x4c)
- EPROGMISMATCH = syscall.Errno(0x4b)
- EPROGUNAVAIL = syscall.Errno(0x4a)
- EPROTO = syscall.Errno(0x64)
- EPROTONOSUPPORT = syscall.Errno(0x2b)
- EPROTOTYPE = syscall.Errno(0x29)
- EPWROFF = syscall.Errno(0x52)
- EQFULL = syscall.Errno(0x6a)
- ERANGE = syscall.Errno(0x22)
- EREMOTE = syscall.Errno(0x47)
- EROFS = syscall.Errno(0x1e)
- ERPCMISMATCH = syscall.Errno(0x49)
- ESHLIBVERS = syscall.Errno(0x57)
- ESHUTDOWN = syscall.Errno(0x3a)
- ESOCKTNOSUPPORT = syscall.Errno(0x2c)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESTALE = syscall.Errno(0x46)
- ETIME = syscall.Errno(0x65)
- ETIMEDOUT = syscall.Errno(0x3c)
- ETOOMANYREFS = syscall.Errno(0x3b)
- ETXTBSY = syscall.Errno(0x1a)
- EUSERS = syscall.Errno(0x44)
- EWOULDBLOCK = syscall.Errno(0x23)
- EXDEV = syscall.Errno(0x12)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0xa)
- SIGCHLD = syscall.Signal(0x14)
- SIGCONT = syscall.Signal(0x13)
- SIGEMT = syscall.Signal(0x7)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINFO = syscall.Signal(0x1d)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x17)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPROF = syscall.Signal(0x1b)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTOP = syscall.Signal(0x11)
- SIGSYS = syscall.Signal(0xc)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x12)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGURG = syscall.Signal(0x10)
- SIGUSR1 = syscall.Signal(0x1e)
- SIGUSR2 = syscall.Signal(0x1f)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "device not configured",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource deadlock avoided",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "resource busy",
- 17: "file exists",
- 18: "cross-device link",
- 19: "operation not supported by device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "result too large",
- 35: "resource temporarily unavailable",
- 36: "operation now in progress",
- 37: "operation already in progress",
- 38: "socket operation on non-socket",
- 39: "destination address required",
- 40: "message too long",
- 41: "protocol wrong type for socket",
- 42: "protocol not available",
- 43: "protocol not supported",
- 44: "socket type not supported",
- 45: "operation not supported",
- 46: "protocol family not supported",
- 47: "address family not supported by protocol family",
- 48: "address already in use",
- 49: "can't assign requested address",
- 50: "network is down",
- 51: "network is unreachable",
- 52: "network dropped connection on reset",
- 53: "software caused connection abort",
- 54: "connection reset by peer",
- 55: "no buffer space available",
- 56: "socket is already connected",
- 57: "socket is not connected",
- 58: "can't send after socket shutdown",
- 59: "too many references: can't splice",
- 60: "operation timed out",
- 61: "connection refused",
- 62: "too many levels of symbolic links",
- 63: "file name too long",
- 64: "host is down",
- 65: "no route to host",
- 66: "directory not empty",
- 67: "too many processes",
- 68: "too many users",
- 69: "disc quota exceeded",
- 70: "stale NFS file handle",
- 71: "too many levels of remote in path",
- 72: "RPC struct is bad",
- 73: "RPC version wrong",
- 74: "RPC prog. not avail",
- 75: "program version wrong",
- 76: "bad procedure for program",
- 77: "no locks available",
- 78: "function not implemented",
- 79: "inappropriate file type or format",
- 80: "authentication error",
- 81: "need authenticator",
- 82: "device power is off",
- 83: "device error",
- 84: "value too large to be stored in data type",
- 85: "bad executable (or shared library)",
- 86: "bad CPU type in executable",
- 87: "shared library version mismatch",
- 88: "malformed Mach-o file",
- 89: "operation canceled",
- 90: "identifier removed",
- 91: "no message of desired type",
- 92: "illegal byte sequence",
- 93: "attribute not found",
- 94: "bad message",
- 95: "EMULTIHOP (Reserved)",
- 96: "no message available on STREAM",
- 97: "ENOLINK (Reserved)",
- 98: "no STREAM resources",
- 99: "not a STREAM",
- 100: "protocol error",
- 101: "STREAM ioctl timeout",
- 102: "operation not supported on socket",
- 103: "policy not found",
- 104: "state not recoverable",
- 105: "previous owner died",
- 106: "interface output queue is full",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/BPT trap",
- 6: "abort trap",
- 7: "EMT trap",
- 8: "floating point exception",
- 9: "killed",
- 10: "bus error",
- 11: "segmentation fault",
- 12: "bad system call",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "urgent I/O condition",
- 17: "suspended (signal)",
- 18: "suspended",
- 19: "continued",
- 20: "child exited",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "I/O possible",
- 24: "cputime limit exceeded",
- 25: "filesize limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window size changes",
- 29: "information request",
- 30: "user defined signal 1",
- 31: "user defined signal 2",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go b/newt/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go
deleted file mode 100644
index a410e88e..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go
+++ /dev/null
@@ -1,1293 +0,0 @@
-// mkerrors.sh
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- _const.go
-
-// +build arm,darwin
-
-package unix
-
-import "syscall"
-
-const (
- AF_APPLETALK = 0x10
- AF_CCITT = 0xa
- AF_CHAOS = 0x5
- AF_CNT = 0x15
- AF_COIP = 0x14
- AF_DATAKIT = 0x9
- AF_DECnet = 0xc
- AF_DLI = 0xd
- AF_E164 = 0x1c
- AF_ECMA = 0x8
- AF_HYLINK = 0xf
- AF_IEEE80211 = 0x25
- AF_IMPLINK = 0x3
- AF_INET = 0x2
- AF_INET6 = 0x1e
- AF_IPX = 0x17
- AF_ISDN = 0x1c
- AF_ISO = 0x7
- AF_LAT = 0xe
- AF_LINK = 0x12
- AF_LOCAL = 0x1
- AF_MAX = 0x28
- AF_NATM = 0x1f
- AF_NDRV = 0x1b
- AF_NETBIOS = 0x21
- AF_NS = 0x6
- AF_OSI = 0x7
- AF_PPP = 0x22
- AF_PUP = 0x4
- AF_RESERVED_36 = 0x24
- AF_ROUTE = 0x11
- AF_SIP = 0x18
- AF_SNA = 0xb
- AF_SYSTEM = 0x20
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_UTUN = 0x26
- B0 = 0x0
- B110 = 0x6e
- B115200 = 0x1c200
- B1200 = 0x4b0
- B134 = 0x86
- B14400 = 0x3840
- B150 = 0x96
- B1800 = 0x708
- B19200 = 0x4b00
- B200 = 0xc8
- B230400 = 0x38400
- B2400 = 0x960
- B28800 = 0x7080
- B300 = 0x12c
- B38400 = 0x9600
- B4800 = 0x12c0
- B50 = 0x32
- B57600 = 0xe100
- B600 = 0x258
- B7200 = 0x1c20
- B75 = 0x4b
- B76800 = 0x12c00
- B9600 = 0x2580
- BIOCFLUSH = 0x20004268
- BIOCGBLEN = 0x40044266
- BIOCGDLT = 0x4004426a
- BIOCGDLTLIST = 0xc00c4279
- BIOCGETIF = 0x4020426b
- BIOCGHDRCMPLT = 0x40044274
- BIOCGRSIG = 0x40044272
- BIOCGRTIMEOUT = 0x4010426e
- BIOCGSEESENT = 0x40044276
- BIOCGSTATS = 0x4008426f
- BIOCIMMEDIATE = 0x80044270
- BIOCPROMISC = 0x20004269
- BIOCSBLEN = 0xc0044266
- BIOCSDLT = 0x80044278
- BIOCSETF = 0x80104267
- BIOCSETIF = 0x8020426c
- BIOCSHDRCMPLT = 0x80044275
- BIOCSRSIG = 0x80044273
- BIOCSRTIMEOUT = 0x8010426d
- BIOCSSEESENT = 0x80044277
- BIOCVERSION = 0x40044271
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALIGNMENT = 0x4
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXBUFSIZE = 0x80000
- BPF_MAXINSNS = 0x200
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINBUFSIZE = 0x20
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RELEASE = 0x30bb6
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BRKINT = 0x2
- CFLUSH = 0xf
- CLOCAL = 0x8000
- CREAD = 0x800
- CS5 = 0x0
- CS6 = 0x100
- CS7 = 0x200
- CS8 = 0x300
- CSIZE = 0x300
- CSTART = 0x11
- CSTATUS = 0x14
- CSTOP = 0x13
- CSTOPB = 0x400
- CSUSP = 0x1a
- CTL_MAXNAME = 0xc
- CTL_NET = 0x4
- DLT_APPLE_IP_OVER_IEEE1394 = 0x8a
- DLT_ARCNET = 0x7
- DLT_ATM_CLIP = 0x13
- DLT_ATM_RFC1483 = 0xb
- DLT_AX25 = 0x3
- DLT_CHAOS = 0x5
- DLT_CHDLC = 0x68
- DLT_C_HDLC = 0x68
- DLT_EN10MB = 0x1
- DLT_EN3MB = 0x2
- DLT_FDDI = 0xa
- DLT_IEEE802 = 0x6
- DLT_IEEE802_11 = 0x69
- DLT_IEEE802_11_RADIO = 0x7f
- DLT_IEEE802_11_RADIO_AVS = 0xa3
- DLT_LINUX_SLL = 0x71
- DLT_LOOP = 0x6c
- DLT_NULL = 0x0
- DLT_PFLOG = 0x75
- DLT_PFSYNC = 0x12
- DLT_PPP = 0x9
- DLT_PPP_BSDOS = 0x10
- DLT_PPP_SERIAL = 0x32
- DLT_PRONET = 0x4
- DLT_RAW = 0xc
- DLT_SLIP = 0x8
- DLT_SLIP_BSDOS = 0xf
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x40
- ECHOE = 0x2
- ECHOK = 0x4
- ECHOKE = 0x1
- ECHONL = 0x10
- ECHOPRT = 0x20
- EVFILT_AIO = -0x3
- EVFILT_FS = -0x9
- EVFILT_MACHPORT = -0x8
- EVFILT_PROC = -0x5
- EVFILT_READ = -0x1
- EVFILT_SIGNAL = -0x6
- EVFILT_SYSCOUNT = 0xe
- EVFILT_THREADMARKER = 0xe
- EVFILT_TIMER = -0x7
- EVFILT_USER = -0xa
- EVFILT_VM = -0xc
- EVFILT_VNODE = -0x4
- EVFILT_WRITE = -0x2
- EV_ADD = 0x1
- EV_CLEAR = 0x20
- EV_DELETE = 0x2
- EV_DISABLE = 0x8
- EV_DISPATCH = 0x80
- EV_ENABLE = 0x4
- EV_EOF = 0x8000
- EV_ERROR = 0x4000
- EV_FLAG0 = 0x1000
- EV_FLAG1 = 0x2000
- EV_ONESHOT = 0x10
- EV_OOBAND = 0x2000
- EV_POLL = 0x1000
- EV_RECEIPT = 0x40
- EV_SYSFLAGS = 0xf000
- EXTA = 0x4b00
- EXTB = 0x9600
- EXTPROC = 0x800
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FLUSHO = 0x800000
- F_ADDFILESIGS = 0x3d
- F_ADDSIGS = 0x3b
- F_ALLOCATEALL = 0x4
- F_ALLOCATECONTIG = 0x2
- F_CHKCLEAN = 0x29
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x43
- F_FINDSIGS = 0x4e
- F_FLUSH_DATA = 0x28
- F_FREEZE_FS = 0x35
- F_FULLFSYNC = 0x33
- F_GETCODEDIR = 0x48
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLK = 0x7
- F_GETLKPID = 0x42
- F_GETNOSIGPIPE = 0x4a
- F_GETOWN = 0x5
- F_GETPATH = 0x32
- F_GETPATH_MTMINFO = 0x47
- F_GETPROTECTIONCLASS = 0x3f
- F_GETPROTECTIONLEVEL = 0x4d
- F_GLOBAL_NOCACHE = 0x37
- F_LOG2PHYS = 0x31
- F_LOG2PHYS_EXT = 0x41
- F_NOCACHE = 0x30
- F_NODIRECT = 0x3e
- F_OK = 0x0
- F_PATHPKG_CHECK = 0x34
- F_PEOFPOSMODE = 0x3
- F_PREALLOCATE = 0x2a
- F_RDADVISE = 0x2c
- F_RDAHEAD = 0x2d
- F_RDLCK = 0x1
- F_SETBACKINGSTORE = 0x46
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLK = 0x8
- F_SETLKW = 0x9
- F_SETLKWTIMEOUT = 0xa
- F_SETNOSIGPIPE = 0x49
- F_SETOWN = 0x6
- F_SETPROTECTIONCLASS = 0x40
- F_SETSIZE = 0x2b
- F_SINGLE_WRITER = 0x4c
- F_THAW_FS = 0x36
- F_TRANSCODEKEY = 0x4b
- F_UNLCK = 0x2
- F_VOLPOSMODE = 0x4
- F_WRLCK = 0x3
- HUPCL = 0x4000
- ICANON = 0x100
- ICMP6_FILTER = 0x12
- ICRNL = 0x100
- IEXTEN = 0x400
- IFF_ALLMULTI = 0x200
- IFF_ALTPHYS = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_LINK0 = 0x1000
- IFF_LINK1 = 0x2000
- IFF_LINK2 = 0x4000
- IFF_LOOPBACK = 0x8
- IFF_MULTICAST = 0x8000
- IFF_NOARP = 0x80
- IFF_NOTRAILERS = 0x20
- IFF_OACTIVE = 0x400
- IFF_POINTOPOINT = 0x10
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SIMPLEX = 0x800
- IFF_UP = 0x1
- IFNAMSIZ = 0x10
- IFT_1822 = 0x2
- IFT_AAL5 = 0x31
- IFT_ARCNET = 0x23
- IFT_ARCNETPLUS = 0x24
- IFT_ATM = 0x25
- IFT_BRIDGE = 0xd1
- IFT_CARP = 0xf8
- IFT_CELLULAR = 0xff
- IFT_CEPT = 0x13
- IFT_DS3 = 0x1e
- IFT_ENC = 0xf4
- IFT_EON = 0x19
- IFT_ETHER = 0x6
- IFT_FAITH = 0x38
- IFT_FDDI = 0xf
- IFT_FRELAY = 0x20
- IFT_FRELAYDCE = 0x2c
- IFT_GIF = 0x37
- IFT_HDH1822 = 0x3
- IFT_HIPPI = 0x2f
- IFT_HSSI = 0x2e
- IFT_HY = 0xe
- IFT_IEEE1394 = 0x90
- IFT_IEEE8023ADLAG = 0x88
- IFT_ISDNBASIC = 0x14
- IFT_ISDNPRIMARY = 0x15
- IFT_ISO88022LLC = 0x29
- IFT_ISO88023 = 0x7
- IFT_ISO88024 = 0x8
- IFT_ISO88025 = 0x9
- IFT_ISO88026 = 0xa
- IFT_L2VLAN = 0x87
- IFT_LAPB = 0x10
- IFT_LOCALTALK = 0x2a
- IFT_LOOP = 0x18
- IFT_MIOX25 = 0x26
- IFT_MODEM = 0x30
- IFT_NSIP = 0x1b
- IFT_OTHER = 0x1
- IFT_P10 = 0xc
- IFT_P80 = 0xd
- IFT_PARA = 0x22
- IFT_PDP = 0xff
- IFT_PFLOG = 0xf5
- IFT_PFSYNC = 0xf6
- IFT_PPP = 0x17
- IFT_PROPMUX = 0x36
- IFT_PROPVIRTUAL = 0x35
- IFT_PTPSERIAL = 0x16
- IFT_RS232 = 0x21
- IFT_SDLC = 0x11
- IFT_SIP = 0x1f
- IFT_SLIP = 0x1c
- IFT_SMDSDXI = 0x2b
- IFT_SMDSICIP = 0x34
- IFT_SONET = 0x27
- IFT_SONETPATH = 0x32
- IFT_SONETVT = 0x33
- IFT_STARLAN = 0xb
- IFT_STF = 0x39
- IFT_T1 = 0x12
- IFT_ULTRA = 0x1d
- IFT_V35 = 0x2d
- IFT_X25 = 0x5
- IFT_X25DDN = 0x4
- IFT_X25PLE = 0x28
- IFT_XETHER = 0x1a
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLASSD_HOST = 0xfffffff
- IN_CLASSD_NET = 0xf0000000
- IN_CLASSD_NSHIFT = 0x1c
- IN_LINKLOCALNETNUM = 0xa9fe0000
- IN_LOOPBACKNET = 0x7f
- IPPROTO_3PC = 0x22
- IPPROTO_ADFS = 0x44
- IPPROTO_AH = 0x33
- IPPROTO_AHIP = 0x3d
- IPPROTO_APES = 0x63
- IPPROTO_ARGUS = 0xd
- IPPROTO_AX25 = 0x5d
- IPPROTO_BHA = 0x31
- IPPROTO_BLT = 0x1e
- IPPROTO_BRSATMON = 0x4c
- IPPROTO_CFTP = 0x3e
- IPPROTO_CHAOS = 0x10
- IPPROTO_CMTP = 0x26
- IPPROTO_CPHB = 0x49
- IPPROTO_CPNX = 0x48
- IPPROTO_DDP = 0x25
- IPPROTO_DGP = 0x56
- IPPROTO_DIVERT = 0xfe
- IPPROTO_DONE = 0x101
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_EMCON = 0xe
- IPPROTO_ENCAP = 0x62
- IPPROTO_EON = 0x50
- IPPROTO_ESP = 0x32
- IPPROTO_ETHERIP = 0x61
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GGP = 0x3
- IPPROTO_GMTP = 0x64
- IPPROTO_GRE = 0x2f
- IPPROTO_HELLO = 0x3f
- IPPROTO_HMP = 0x14
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IDPR = 0x23
- IPPROTO_IDRP = 0x2d
- IPPROTO_IGMP = 0x2
- IPPROTO_IGP = 0x55
- IPPROTO_IGRP = 0x58
- IPPROTO_IL = 0x28
- IPPROTO_INLSP = 0x34
- IPPROTO_INP = 0x20
- IPPROTO_IP = 0x0
- IPPROTO_IPCOMP = 0x6c
- IPPROTO_IPCV = 0x47
- IPPROTO_IPEIP = 0x5e
- IPPROTO_IPIP = 0x4
- IPPROTO_IPPC = 0x43
- IPPROTO_IPV4 = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_IRTP = 0x1c
- IPPROTO_KRYPTOLAN = 0x41
- IPPROTO_LARP = 0x5b
- IPPROTO_LEAF1 = 0x19
- IPPROTO_LEAF2 = 0x1a
- IPPROTO_MAX = 0x100
- IPPROTO_MAXID = 0x34
- IPPROTO_MEAS = 0x13
- IPPROTO_MHRP = 0x30
- IPPROTO_MICP = 0x5f
- IPPROTO_MTP = 0x5c
- IPPROTO_MUX = 0x12
- IPPROTO_ND = 0x4d
- IPPROTO_NHRP = 0x36
- IPPROTO_NONE = 0x3b
- IPPROTO_NSP = 0x1f
- IPPROTO_NVPII = 0xb
- IPPROTO_OSPFIGP = 0x59
- IPPROTO_PGM = 0x71
- IPPROTO_PIGP = 0x9
- IPPROTO_PIM = 0x67
- IPPROTO_PRM = 0x15
- IPPROTO_PUP = 0xc
- IPPROTO_PVP = 0x4b
- IPPROTO_RAW = 0xff
- IPPROTO_RCCMON = 0xa
- IPPROTO_RDP = 0x1b
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_RVD = 0x42
- IPPROTO_SATEXPAK = 0x40
- IPPROTO_SATMON = 0x45
- IPPROTO_SCCSP = 0x60
- IPPROTO_SCTP = 0x84
- IPPROTO_SDRP = 0x2a
- IPPROTO_SEP = 0x21
- IPPROTO_SRPC = 0x5a
- IPPROTO_ST = 0x7
- IPPROTO_SVMTP = 0x52
- IPPROTO_SWIPE = 0x35
- IPPROTO_TCF = 0x57
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_TPXX = 0x27
- IPPROTO_TRUNK1 = 0x17
- IPPROTO_TRUNK2 = 0x18
- IPPROTO_TTP = 0x54
- IPPROTO_UDP = 0x11
- IPPROTO_VINES = 0x53
- IPPROTO_VISA = 0x46
- IPPROTO_VMTP = 0x51
- IPPROTO_WBEXPAK = 0x4f
- IPPROTO_WBMON = 0x4e
- IPPROTO_WSN = 0x4a
- IPPROTO_XNET = 0xf
- IPPROTO_XTP = 0x24
- IPV6_2292DSTOPTS = 0x17
- IPV6_2292HOPLIMIT = 0x14
- IPV6_2292HOPOPTS = 0x16
- IPV6_2292NEXTHOP = 0x15
- IPV6_2292PKTINFO = 0x13
- IPV6_2292PKTOPTIONS = 0x19
- IPV6_2292RTHDR = 0x18
- IPV6_BINDV6ONLY = 0x1b
- IPV6_BOUND_IF = 0x7d
- IPV6_CHECKSUM = 0x1a
- IPV6_DEFAULT_MULTICAST_HOPS = 0x1
- IPV6_DEFAULT_MULTICAST_LOOP = 0x1
- IPV6_DEFHLIM = 0x40
- IPV6_FAITH = 0x1d
- IPV6_FLOWINFO_MASK = 0xffffff0f
- IPV6_FLOWLABEL_MASK = 0xffff0f00
- IPV6_FRAGTTL = 0x78
- IPV6_FW_ADD = 0x1e
- IPV6_FW_DEL = 0x1f
- IPV6_FW_FLUSH = 0x20
- IPV6_FW_GET = 0x22
- IPV6_FW_ZERO = 0x21
- IPV6_HLIMDEC = 0x1
- IPV6_IPSEC_POLICY = 0x1c
- IPV6_JOIN_GROUP = 0xc
- IPV6_LEAVE_GROUP = 0xd
- IPV6_MAXHLIM = 0xff
- IPV6_MAXOPTHDR = 0x800
- IPV6_MAXPACKET = 0xffff
- IPV6_MAX_GROUP_SRC_FILTER = 0x200
- IPV6_MAX_MEMBERSHIPS = 0xfff
- IPV6_MAX_SOCK_SRC_FILTER = 0x80
- IPV6_MIN_MEMBERSHIPS = 0x1f
- IPV6_MMTU = 0x500
- IPV6_MULTICAST_HOPS = 0xa
- IPV6_MULTICAST_IF = 0x9
- IPV6_MULTICAST_LOOP = 0xb
- IPV6_PORTRANGE = 0xe
- IPV6_PORTRANGE_DEFAULT = 0x0
- IPV6_PORTRANGE_HIGH = 0x1
- IPV6_PORTRANGE_LOW = 0x2
- IPV6_RECVTCLASS = 0x23
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_SOCKOPT_RESERVED1 = 0x3
- IPV6_TCLASS = 0x24
- IPV6_UNICAST_HOPS = 0x4
- IPV6_V6ONLY = 0x1b
- IPV6_VERSION = 0x60
- IPV6_VERSION_MASK = 0xf0
- IP_ADD_MEMBERSHIP = 0xc
- IP_ADD_SOURCE_MEMBERSHIP = 0x46
- IP_BLOCK_SOURCE = 0x48
- IP_BOUND_IF = 0x19
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0xd
- IP_DROP_SOURCE_MEMBERSHIP = 0x47
- IP_DUMMYNET_CONFIGURE = 0x3c
- IP_DUMMYNET_DEL = 0x3d
- IP_DUMMYNET_FLUSH = 0x3e
- IP_DUMMYNET_GET = 0x40
- IP_FAITH = 0x16
- IP_FW_ADD = 0x28
- IP_FW_DEL = 0x29
- IP_FW_FLUSH = 0x2a
- IP_FW_GET = 0x2c
- IP_FW_RESETLOG = 0x2d
- IP_FW_ZERO = 0x2b
- IP_HDRINCL = 0x2
- IP_IPSEC_POLICY = 0x15
- IP_MAXPACKET = 0xffff
- IP_MAX_GROUP_SRC_FILTER = 0x200
- IP_MAX_MEMBERSHIPS = 0xfff
- IP_MAX_SOCK_MUTE_FILTER = 0x80
- IP_MAX_SOCK_SRC_FILTER = 0x80
- IP_MF = 0x2000
- IP_MIN_MEMBERSHIPS = 0x1f
- IP_MSFILTER = 0x4a
- IP_MSS = 0x240
- IP_MULTICAST_IF = 0x9
- IP_MULTICAST_IFINDEX = 0x42
- IP_MULTICAST_LOOP = 0xb
- IP_MULTICAST_TTL = 0xa
- IP_MULTICAST_VIF = 0xe
- IP_NAT__XXX = 0x37
- IP_OFFMASK = 0x1fff
- IP_OLD_FW_ADD = 0x32
- IP_OLD_FW_DEL = 0x33
- IP_OLD_FW_FLUSH = 0x34
- IP_OLD_FW_GET = 0x36
- IP_OLD_FW_RESETLOG = 0x38
- IP_OLD_FW_ZERO = 0x35
- IP_OPTIONS = 0x1
- IP_PKTINFO = 0x1a
- IP_PORTRANGE = 0x13
- IP_PORTRANGE_DEFAULT = 0x0
- IP_PORTRANGE_HIGH = 0x1
- IP_PORTRANGE_LOW = 0x2
- IP_RECVDSTADDR = 0x7
- IP_RECVIF = 0x14
- IP_RECVOPTS = 0x5
- IP_RECVPKTINFO = 0x1a
- IP_RECVRETOPTS = 0x6
- IP_RECVTTL = 0x18
- IP_RETOPTS = 0x8
- IP_RF = 0x8000
- IP_RSVP_OFF = 0x10
- IP_RSVP_ON = 0xf
- IP_RSVP_VIF_OFF = 0x12
- IP_RSVP_VIF_ON = 0x11
- IP_STRIPHDR = 0x17
- IP_TOS = 0x3
- IP_TRAFFIC_MGT_BACKGROUND = 0x41
- IP_TTL = 0x4
- IP_UNBLOCK_SOURCE = 0x49
- ISIG = 0x80
- ISTRIP = 0x20
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x400
- IXON = 0x200
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_CAN_REUSE = 0x9
- MADV_DONTNEED = 0x4
- MADV_FREE = 0x5
- MADV_FREE_REUSABLE = 0x7
- MADV_FREE_REUSE = 0x8
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_SEQUENTIAL = 0x2
- MADV_WILLNEED = 0x3
- MADV_ZERO_WIRED_PAGES = 0x6
- MAP_ANON = 0x1000
- MAP_COPY = 0x2
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_HASSEMAPHORE = 0x200
- MAP_JIT = 0x800
- MAP_NOCACHE = 0x400
- MAP_NOEXTEND = 0x100
- MAP_NORESERVE = 0x40
- MAP_PRIVATE = 0x2
- MAP_RENAME = 0x20
- MAP_RESERVED0080 = 0x80
- MAP_SHARED = 0x1
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MSG_CTRUNC = 0x20
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x80
- MSG_EOF = 0x100
- MSG_EOR = 0x8
- MSG_FLUSH = 0x400
- MSG_HAVEMORE = 0x2000
- MSG_HOLD = 0x800
- MSG_NEEDSA = 0x10000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_RCVMORE = 0x4000
- MSG_SEND = 0x1000
- MSG_TRUNC = 0x10
- MSG_WAITALL = 0x40
- MSG_WAITSTREAM = 0x200
- MS_ASYNC = 0x1
- MS_DEACTIVATE = 0x8
- MS_INVALIDATE = 0x2
- MS_KILLPAGES = 0x4
- MS_SYNC = 0x10
- NAME_MAX = 0xff
- NET_RT_DUMP = 0x1
- NET_RT_DUMP2 = 0x7
- NET_RT_FLAGS = 0x2
- NET_RT_IFLIST = 0x3
- NET_RT_IFLIST2 = 0x6
- NET_RT_MAXID = 0xa
- NET_RT_STAT = 0x4
- NET_RT_TRASH = 0x5
- NOFLSH = 0x80000000
- NOTE_ABSOLUTE = 0x8
- NOTE_ATTRIB = 0x8
- NOTE_BACKGROUND = 0x40
- NOTE_CHILD = 0x4
- NOTE_CRITICAL = 0x20
- NOTE_DELETE = 0x1
- NOTE_EXEC = 0x20000000
- NOTE_EXIT = 0x80000000
- NOTE_EXITSTATUS = 0x4000000
- NOTE_EXIT_CSERROR = 0x40000
- NOTE_EXIT_DECRYPTFAIL = 0x10000
- NOTE_EXIT_DETAIL = 0x2000000
- NOTE_EXIT_DETAIL_MASK = 0x70000
- NOTE_EXIT_MEMORY = 0x20000
- NOTE_EXIT_REPARENTED = 0x80000
- NOTE_EXTEND = 0x4
- NOTE_FFAND = 0x40000000
- NOTE_FFCOPY = 0xc0000000
- NOTE_FFCTRLMASK = 0xc0000000
- NOTE_FFLAGSMASK = 0xffffff
- NOTE_FFNOP = 0x0
- NOTE_FFOR = 0x80000000
- NOTE_FORK = 0x40000000
- NOTE_LEEWAY = 0x10
- NOTE_LINK = 0x10
- NOTE_LOWAT = 0x1
- NOTE_NONE = 0x80
- NOTE_NSECONDS = 0x4
- NOTE_PCTRLMASK = -0x100000
- NOTE_PDATAMASK = 0xfffff
- NOTE_REAP = 0x10000000
- NOTE_RENAME = 0x20
- NOTE_REVOKE = 0x40
- NOTE_SECONDS = 0x1
- NOTE_SIGNAL = 0x8000000
- NOTE_TRACK = 0x1
- NOTE_TRACKERR = 0x2
- NOTE_TRIGGER = 0x1000000
- NOTE_USECONDS = 0x2
- NOTE_VM_ERROR = 0x10000000
- NOTE_VM_PRESSURE = 0x80000000
- NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000
- NOTE_VM_PRESSURE_TERMINATE = 0x40000000
- NOTE_WRITE = 0x2
- OCRNL = 0x10
- OFDEL = 0x20000
- OFILL = 0x80
- ONLCR = 0x2
- ONLRET = 0x40
- ONOCR = 0x20
- ONOEOT = 0x8
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_ALERT = 0x20000000
- O_APPEND = 0x8
- O_ASYNC = 0x40
- O_CLOEXEC = 0x1000000
- O_CREAT = 0x200
- O_DIRECTORY = 0x100000
- O_DP_GETRAWENCRYPTED = 0x1
- O_DSYNC = 0x400000
- O_EVTONLY = 0x8000
- O_EXCL = 0x800
- O_EXLOCK = 0x20
- O_FSYNC = 0x80
- O_NDELAY = 0x4
- O_NOCTTY = 0x20000
- O_NOFOLLOW = 0x100
- O_NONBLOCK = 0x4
- O_POPUP = 0x80000000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_SHLOCK = 0x10
- O_SYMLINK = 0x200000
- O_SYNC = 0x80
- O_TRUNC = 0x400
- O_WRONLY = 0x1
- PARENB = 0x1000
- PARMRK = 0x8
- PARODD = 0x2000
- PENDIN = 0x20000000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- PT_ATTACH = 0xa
- PT_ATTACHEXC = 0xe
- PT_CONTINUE = 0x7
- PT_DENY_ATTACH = 0x1f
- PT_DETACH = 0xb
- PT_FIRSTMACH = 0x20
- PT_FORCEQUOTA = 0x1e
- PT_KILL = 0x8
- PT_READ_D = 0x2
- PT_READ_I = 0x1
- PT_READ_U = 0x3
- PT_SIGEXC = 0xc
- PT_STEP = 0x9
- PT_THUPDATE = 0xd
- PT_TRACE_ME = 0x0
- PT_WRITE_D = 0x5
- PT_WRITE_I = 0x4
- PT_WRITE_U = 0x6
- RLIMIT_AS = 0x5
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_CPU_USAGE_MONITOR = 0x2
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x8
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = 0x7fffffffffffffff
- RTAX_AUTHOR = 0x6
- RTAX_BRD = 0x7
- RTAX_DST = 0x0
- RTAX_GATEWAY = 0x1
- RTAX_GENMASK = 0x3
- RTAX_IFA = 0x5
- RTAX_IFP = 0x4
- RTAX_MAX = 0x8
- RTAX_NETMASK = 0x2
- RTA_AUTHOR = 0x40
- RTA_BRD = 0x80
- RTA_DST = 0x1
- RTA_GATEWAY = 0x2
- RTA_GENMASK = 0x8
- RTA_IFA = 0x20
- RTA_IFP = 0x10
- RTA_NETMASK = 0x4
- RTF_BLACKHOLE = 0x1000
- RTF_BROADCAST = 0x400000
- RTF_CLONING = 0x100
- RTF_CONDEMNED = 0x2000000
- RTF_DELCLONE = 0x80
- RTF_DONE = 0x40
- RTF_DYNAMIC = 0x10
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_IFREF = 0x4000000
- RTF_IFSCOPE = 0x1000000
- RTF_LLINFO = 0x400
- RTF_LOCAL = 0x200000
- RTF_MODIFIED = 0x20
- RTF_MULTICAST = 0x800000
- RTF_PINNED = 0x100000
- RTF_PRCLONING = 0x10000
- RTF_PROTO1 = 0x8000
- RTF_PROTO2 = 0x4000
- RTF_PROTO3 = 0x40000
- RTF_PROXY = 0x8000000
- RTF_REJECT = 0x8
- RTF_ROUTER = 0x10000000
- RTF_STATIC = 0x800
- RTF_UP = 0x1
- RTF_WASCLONED = 0x20000
- RTF_XRESOLVE = 0x200
- RTM_ADD = 0x1
- RTM_CHANGE = 0x3
- RTM_DELADDR = 0xd
- RTM_DELETE = 0x2
- RTM_DELMADDR = 0x10
- RTM_GET = 0x4
- RTM_GET2 = 0x14
- RTM_IFINFO = 0xe
- RTM_IFINFO2 = 0x12
- RTM_LOCK = 0x8
- RTM_LOSING = 0x5
- RTM_MISS = 0x7
- RTM_NEWADDR = 0xc
- RTM_NEWMADDR = 0xf
- RTM_NEWMADDR2 = 0x13
- RTM_OLDADD = 0x9
- RTM_OLDDEL = 0xa
- RTM_REDIRECT = 0x6
- RTM_RESOLVE = 0xb
- RTM_RTTUNIT = 0xf4240
- RTM_VERSION = 0x5
- RTV_EXPIRE = 0x4
- RTV_HOPCOUNT = 0x2
- RTV_MTU = 0x1
- RTV_RPIPE = 0x8
- RTV_RTT = 0x40
- RTV_RTTVAR = 0x80
- RTV_SPIPE = 0x10
- RTV_SSTHRESH = 0x20
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- SCM_CREDS = 0x3
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x2
- SCM_TIMESTAMP_MONOTONIC = 0x4
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDMULTI = 0x80206931
- SIOCAIFADDR = 0x8040691a
- SIOCARPIPLL = 0xc0206928
- SIOCATMARK = 0x40047307
- SIOCAUTOADDR = 0xc0206926
- SIOCAUTONETMASK = 0x80206927
- SIOCDELMULTI = 0x80206932
- SIOCDIFADDR = 0x80206919
- SIOCDIFPHYADDR = 0x80206941
- SIOCGDRVSPEC = 0xc028697b
- SIOCGETVLAN = 0xc020697f
- SIOCGHIWAT = 0x40047301
- SIOCGIFADDR = 0xc0206921
- SIOCGIFALTMTU = 0xc0206948
- SIOCGIFASYNCMAP = 0xc020697c
- SIOCGIFBOND = 0xc0206947
- SIOCGIFBRDADDR = 0xc0206923
- SIOCGIFCAP = 0xc020695b
- SIOCGIFCONF = 0xc00c6924
- SIOCGIFDEVMTU = 0xc0206944
- SIOCGIFDSTADDR = 0xc0206922
- SIOCGIFFLAGS = 0xc0206911
- SIOCGIFGENERIC = 0xc020693a
- SIOCGIFKPI = 0xc0206987
- SIOCGIFMAC = 0xc0206982
- SIOCGIFMEDIA = 0xc02c6938
- SIOCGIFMETRIC = 0xc0206917
- SIOCGIFMTU = 0xc0206933
- SIOCGIFNETMASK = 0xc0206925
- SIOCGIFPDSTADDR = 0xc0206940
- SIOCGIFPHYS = 0xc0206935
- SIOCGIFPSRCADDR = 0xc020693f
- SIOCGIFSTATUS = 0xc331693d
- SIOCGIFVLAN = 0xc020697f
- SIOCGIFWAKEFLAGS = 0xc0206988
- SIOCGLOWAT = 0x40047303
- SIOCGPGRP = 0x40047309
- SIOCIFCREATE = 0xc0206978
- SIOCIFCREATE2 = 0xc020697a
- SIOCIFDESTROY = 0x80206979
- SIOCIFGCLONERS = 0xc0106981
- SIOCRSLVMULTI = 0xc010693b
- SIOCSDRVSPEC = 0x8028697b
- SIOCSETVLAN = 0x8020697e
- SIOCSHIWAT = 0x80047300
- SIOCSIFADDR = 0x8020690c
- SIOCSIFALTMTU = 0x80206945
- SIOCSIFASYNCMAP = 0x8020697d
- SIOCSIFBOND = 0x80206946
- SIOCSIFBRDADDR = 0x80206913
- SIOCSIFCAP = 0x8020695a
- SIOCSIFDSTADDR = 0x8020690e
- SIOCSIFFLAGS = 0x80206910
- SIOCSIFGENERIC = 0x80206939
- SIOCSIFKPI = 0x80206986
- SIOCSIFLLADDR = 0x8020693c
- SIOCSIFMAC = 0x80206983
- SIOCSIFMEDIA = 0xc0206937
- SIOCSIFMETRIC = 0x80206918
- SIOCSIFMTU = 0x80206934
- SIOCSIFNETMASK = 0x80206916
- SIOCSIFPHYADDR = 0x8040693e
- SIOCSIFPHYS = 0x80206936
- SIOCSIFVLAN = 0x8020697e
- SIOCSLOWAT = 0x80047302
- SIOCSPGRP = 0x80047308
- SOCK_DGRAM = 0x2
- SOCK_MAXADDRLEN = 0xff
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_SOCKET = 0xffff
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x2
- SO_BROADCAST = 0x20
- SO_DEBUG = 0x1
- SO_DONTROUTE = 0x10
- SO_DONTTRUNC = 0x2000
- SO_ERROR = 0x1007
- SO_KEEPALIVE = 0x8
- SO_LABEL = 0x1010
- SO_LINGER = 0x80
- SO_LINGER_SEC = 0x1080
- SO_NKE = 0x1021
- SO_NOADDRERR = 0x1023
- SO_NOSIGPIPE = 0x1022
- SO_NOTIFYCONFLICT = 0x1026
- SO_NP_EXTENSIONS = 0x1083
- SO_NREAD = 0x1020
- SO_NUMRCVPKT = 0x1112
- SO_NWRITE = 0x1024
- SO_OOBINLINE = 0x100
- SO_PEERLABEL = 0x1011
- SO_RANDOMPORT = 0x1082
- SO_RCVBUF = 0x1002
- SO_RCVLOWAT = 0x1004
- SO_RCVTIMEO = 0x1006
- SO_REUSEADDR = 0x4
- SO_REUSEPORT = 0x200
- SO_REUSESHAREUID = 0x1025
- SO_SNDBUF = 0x1001
- SO_SNDLOWAT = 0x1003
- SO_SNDTIMEO = 0x1005
- SO_TIMESTAMP = 0x400
- SO_TIMESTAMP_MONOTONIC = 0x800
- SO_TYPE = 0x1008
- SO_UPCALLCLOSEWAIT = 0x1027
- SO_USELOOPBACK = 0x40
- SO_WANTMORE = 0x4000
- SO_WANTOOBFLAG = 0x8000
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IFWHT = 0xe000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISTXT = 0x200
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TCIFLUSH = 0x1
- TCIOFLUSH = 0x3
- TCOFLUSH = 0x2
- TCP_CONNECTIONTIMEOUT = 0x20
- TCP_ENABLE_ECN = 0x104
- TCP_KEEPALIVE = 0x10
- TCP_KEEPCNT = 0x102
- TCP_KEEPINTVL = 0x101
- TCP_MAXHLEN = 0x3c
- TCP_MAXOLEN = 0x28
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_SACK = 0x4
- TCP_MAX_WINSHIFT = 0xe
- TCP_MINMSS = 0xd8
- TCP_MSS = 0x200
- TCP_NODELAY = 0x1
- TCP_NOOPT = 0x8
- TCP_NOPUSH = 0x4
- TCP_NOTSENT_LOWAT = 0x201
- TCP_RXT_CONNDROPTIME = 0x80
- TCP_RXT_FINDROP = 0x100
- TCP_SENDMOREACKS = 0x103
- TCSAFLUSH = 0x2
- TIOCCBRK = 0x2000747a
- TIOCCDTR = 0x20007478
- TIOCCONS = 0x80047462
- TIOCDCDTIMESTAMP = 0x40107458
- TIOCDRAIN = 0x2000745e
- TIOCDSIMICROCODE = 0x20007455
- TIOCEXCL = 0x2000740d
- TIOCEXT = 0x80047460
- TIOCFLUSH = 0x80047410
- TIOCGDRAINWAIT = 0x40047456
- TIOCGETA = 0x40487413
- TIOCGETD = 0x4004741a
- TIOCGPGRP = 0x40047477
- TIOCGWINSZ = 0x40087468
- TIOCIXOFF = 0x20007480
- TIOCIXON = 0x20007481
- TIOCMBIC = 0x8004746b
- TIOCMBIS = 0x8004746c
- TIOCMGDTRWAIT = 0x4004745a
- TIOCMGET = 0x4004746a
- TIOCMODG = 0x40047403
- TIOCMODS = 0x80047404
- TIOCMSDTRWAIT = 0x8004745b
- TIOCMSET = 0x8004746d
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x20007471
- TIOCNXCL = 0x2000740e
- TIOCOUTQ = 0x40047473
- TIOCPKT = 0x80047470
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCPTYGNAME = 0x40807453
- TIOCPTYGRANT = 0x20007454
- TIOCPTYUNLK = 0x20007452
- TIOCREMOTE = 0x80047469
- TIOCSBRK = 0x2000747b
- TIOCSCONS = 0x20007463
- TIOCSCTTY = 0x20007461
- TIOCSDRAINWAIT = 0x80047457
- TIOCSDTR = 0x20007479
- TIOCSETA = 0x80487414
- TIOCSETAF = 0x80487416
- TIOCSETAW = 0x80487415
- TIOCSETD = 0x8004741b
- TIOCSIG = 0x2000745f
- TIOCSPGRP = 0x80047476
- TIOCSTART = 0x2000746e
- TIOCSTAT = 0x20007465
- TIOCSTI = 0x80017472
- TIOCSTOP = 0x2000746f
- TIOCSWINSZ = 0x80087467
- TIOCTIMESTAMP = 0x40107459
- TIOCUCNTL = 0x80047466
- TOSTOP = 0x400000
- VDISCARD = 0xf
- VDSUSP = 0xb
- VEOF = 0x0
- VEOL = 0x1
- VEOL2 = 0x2
- VERASE = 0x3
- VINTR = 0x8
- VKILL = 0x5
- VLNEXT = 0xe
- VMIN = 0x10
- VQUIT = 0x9
- VREPRINT = 0x6
- VSTART = 0xc
- VSTATUS = 0x12
- VSTOP = 0xd
- VSUSP = 0xa
- VT0 = 0x0
- VT1 = 0x10000
- VTDLY = 0x10000
- VTIME = 0x11
- VWERASE = 0x4
- WCONTINUED = 0x10
- WCOREFLAG = 0x80
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOWAIT = 0x20
- WORDSIZE = 0x40
- WSTOPPED = 0x8
- WUNTRACED = 0x2
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x30)
- EADDRNOTAVAIL = syscall.Errno(0x31)
- EAFNOSUPPORT = syscall.Errno(0x2f)
- EAGAIN = syscall.Errno(0x23)
- EALREADY = syscall.Errno(0x25)
- EAUTH = syscall.Errno(0x50)
- EBADARCH = syscall.Errno(0x56)
- EBADEXEC = syscall.Errno(0x55)
- EBADF = syscall.Errno(0x9)
- EBADMACHO = syscall.Errno(0x58)
- EBADMSG = syscall.Errno(0x5e)
- EBADRPC = syscall.Errno(0x48)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x59)
- ECHILD = syscall.Errno(0xa)
- ECONNABORTED = syscall.Errno(0x35)
- ECONNREFUSED = syscall.Errno(0x3d)
- ECONNRESET = syscall.Errno(0x36)
- EDEADLK = syscall.Errno(0xb)
- EDESTADDRREQ = syscall.Errno(0x27)
- EDEVERR = syscall.Errno(0x53)
- EDOM = syscall.Errno(0x21)
- EDQUOT = syscall.Errno(0x45)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EFTYPE = syscall.Errno(0x4f)
- EHOSTDOWN = syscall.Errno(0x40)
- EHOSTUNREACH = syscall.Errno(0x41)
- EIDRM = syscall.Errno(0x5a)
- EILSEQ = syscall.Errno(0x5c)
- EINPROGRESS = syscall.Errno(0x24)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x38)
- EISDIR = syscall.Errno(0x15)
- ELAST = syscall.Errno(0x6a)
- ELOOP = syscall.Errno(0x3e)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x28)
- EMULTIHOP = syscall.Errno(0x5f)
- ENAMETOOLONG = syscall.Errno(0x3f)
- ENEEDAUTH = syscall.Errno(0x51)
- ENETDOWN = syscall.Errno(0x32)
- ENETRESET = syscall.Errno(0x34)
- ENETUNREACH = syscall.Errno(0x33)
- ENFILE = syscall.Errno(0x17)
- ENOATTR = syscall.Errno(0x5d)
- ENOBUFS = syscall.Errno(0x37)
- ENODATA = syscall.Errno(0x60)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOLCK = syscall.Errno(0x4d)
- ENOLINK = syscall.Errno(0x61)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x5b)
- ENOPOLICY = syscall.Errno(0x67)
- ENOPROTOOPT = syscall.Errno(0x2a)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x62)
- ENOSTR = syscall.Errno(0x63)
- ENOSYS = syscall.Errno(0x4e)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x39)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x42)
- ENOTRECOVERABLE = syscall.Errno(0x68)
- ENOTSOCK = syscall.Errno(0x26)
- ENOTSUP = syscall.Errno(0x2d)
- ENOTTY = syscall.Errno(0x19)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x66)
- EOVERFLOW = syscall.Errno(0x54)
- EOWNERDEAD = syscall.Errno(0x69)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x2e)
- EPIPE = syscall.Errno(0x20)
- EPROCLIM = syscall.Errno(0x43)
- EPROCUNAVAIL = syscall.Errno(0x4c)
- EPROGMISMATCH = syscall.Errno(0x4b)
- EPROGUNAVAIL = syscall.Errno(0x4a)
- EPROTO = syscall.Errno(0x64)
- EPROTONOSUPPORT = syscall.Errno(0x2b)
- EPROTOTYPE = syscall.Errno(0x29)
- EPWROFF = syscall.Errno(0x52)
- EQFULL = syscall.Errno(0x6a)
- ERANGE = syscall.Errno(0x22)
- EREMOTE = syscall.Errno(0x47)
- EROFS = syscall.Errno(0x1e)
- ERPCMISMATCH = syscall.Errno(0x49)
- ESHLIBVERS = syscall.Errno(0x57)
- ESHUTDOWN = syscall.Errno(0x3a)
- ESOCKTNOSUPPORT = syscall.Errno(0x2c)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESTALE = syscall.Errno(0x46)
- ETIME = syscall.Errno(0x65)
- ETIMEDOUT = syscall.Errno(0x3c)
- ETOOMANYREFS = syscall.Errno(0x3b)
- ETXTBSY = syscall.Errno(0x1a)
- EUSERS = syscall.Errno(0x44)
- EWOULDBLOCK = syscall.Errno(0x23)
- EXDEV = syscall.Errno(0x12)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0xa)
- SIGCHLD = syscall.Signal(0x14)
- SIGCONT = syscall.Signal(0x13)
- SIGEMT = syscall.Signal(0x7)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINFO = syscall.Signal(0x1d)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x17)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPROF = syscall.Signal(0x1b)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTOP = syscall.Signal(0x11)
- SIGSYS = syscall.Signal(0xc)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x12)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGURG = syscall.Signal(0x10)
- SIGUSR1 = syscall.Signal(0x1e)
- SIGUSR2 = syscall.Signal(0x1f)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/newt/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go
deleted file mode 100644
index 3189c6b3..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go
+++ /dev/null
@@ -1,1576 +0,0 @@
-// mkerrors.sh -m64
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build arm64,darwin
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -m64 _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_APPLETALK = 0x10
- AF_CCITT = 0xa
- AF_CHAOS = 0x5
- AF_CNT = 0x15
- AF_COIP = 0x14
- AF_DATAKIT = 0x9
- AF_DECnet = 0xc
- AF_DLI = 0xd
- AF_E164 = 0x1c
- AF_ECMA = 0x8
- AF_HYLINK = 0xf
- AF_IEEE80211 = 0x25
- AF_IMPLINK = 0x3
- AF_INET = 0x2
- AF_INET6 = 0x1e
- AF_IPX = 0x17
- AF_ISDN = 0x1c
- AF_ISO = 0x7
- AF_LAT = 0xe
- AF_LINK = 0x12
- AF_LOCAL = 0x1
- AF_MAX = 0x28
- AF_NATM = 0x1f
- AF_NDRV = 0x1b
- AF_NETBIOS = 0x21
- AF_NS = 0x6
- AF_OSI = 0x7
- AF_PPP = 0x22
- AF_PUP = 0x4
- AF_RESERVED_36 = 0x24
- AF_ROUTE = 0x11
- AF_SIP = 0x18
- AF_SNA = 0xb
- AF_SYSTEM = 0x20
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_UTUN = 0x26
- B0 = 0x0
- B110 = 0x6e
- B115200 = 0x1c200
- B1200 = 0x4b0
- B134 = 0x86
- B14400 = 0x3840
- B150 = 0x96
- B1800 = 0x708
- B19200 = 0x4b00
- B200 = 0xc8
- B230400 = 0x38400
- B2400 = 0x960
- B28800 = 0x7080
- B300 = 0x12c
- B38400 = 0x9600
- B4800 = 0x12c0
- B50 = 0x32
- B57600 = 0xe100
- B600 = 0x258
- B7200 = 0x1c20
- B75 = 0x4b
- B76800 = 0x12c00
- B9600 = 0x2580
- BIOCFLUSH = 0x20004268
- BIOCGBLEN = 0x40044266
- BIOCGDLT = 0x4004426a
- BIOCGDLTLIST = 0xc00c4279
- BIOCGETIF = 0x4020426b
- BIOCGHDRCMPLT = 0x40044274
- BIOCGRSIG = 0x40044272
- BIOCGRTIMEOUT = 0x4010426e
- BIOCGSEESENT = 0x40044276
- BIOCGSTATS = 0x4008426f
- BIOCIMMEDIATE = 0x80044270
- BIOCPROMISC = 0x20004269
- BIOCSBLEN = 0xc0044266
- BIOCSDLT = 0x80044278
- BIOCSETF = 0x80104267
- BIOCSETFNR = 0x8010427e
- BIOCSETIF = 0x8020426c
- BIOCSHDRCMPLT = 0x80044275
- BIOCSRSIG = 0x80044273
- BIOCSRTIMEOUT = 0x8010426d
- BIOCSSEESENT = 0x80044277
- BIOCVERSION = 0x40044271
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALIGNMENT = 0x4
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXBUFSIZE = 0x80000
- BPF_MAXINSNS = 0x200
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINBUFSIZE = 0x20
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RELEASE = 0x30bb6
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BRKINT = 0x2
- CFLUSH = 0xf
- CLOCAL = 0x8000
- CREAD = 0x800
- CS5 = 0x0
- CS6 = 0x100
- CS7 = 0x200
- CS8 = 0x300
- CSIZE = 0x300
- CSTART = 0x11
- CSTATUS = 0x14
- CSTOP = 0x13
- CSTOPB = 0x400
- CSUSP = 0x1a
- CTL_MAXNAME = 0xc
- CTL_NET = 0x4
- DLT_A429 = 0xb8
- DLT_A653_ICM = 0xb9
- DLT_AIRONET_HEADER = 0x78
- DLT_AOS = 0xde
- DLT_APPLE_IP_OVER_IEEE1394 = 0x8a
- DLT_ARCNET = 0x7
- DLT_ARCNET_LINUX = 0x81
- DLT_ATM_CLIP = 0x13
- DLT_ATM_RFC1483 = 0xb
- DLT_AURORA = 0x7e
- DLT_AX25 = 0x3
- DLT_AX25_KISS = 0xca
- DLT_BACNET_MS_TP = 0xa5
- DLT_BLUETOOTH_HCI_H4 = 0xbb
- DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9
- DLT_CAN20B = 0xbe
- DLT_CAN_SOCKETCAN = 0xe3
- DLT_CHAOS = 0x5
- DLT_CHDLC = 0x68
- DLT_CISCO_IOS = 0x76
- DLT_C_HDLC = 0x68
- DLT_C_HDLC_WITH_DIR = 0xcd
- DLT_DBUS = 0xe7
- DLT_DECT = 0xdd
- DLT_DOCSIS = 0x8f
- DLT_DVB_CI = 0xeb
- DLT_ECONET = 0x73
- DLT_EN10MB = 0x1
- DLT_EN3MB = 0x2
- DLT_ENC = 0x6d
- DLT_ERF = 0xc5
- DLT_ERF_ETH = 0xaf
- DLT_ERF_POS = 0xb0
- DLT_FC_2 = 0xe0
- DLT_FC_2_WITH_FRAME_DELIMS = 0xe1
- DLT_FDDI = 0xa
- DLT_FLEXRAY = 0xd2
- DLT_FRELAY = 0x6b
- DLT_FRELAY_WITH_DIR = 0xce
- DLT_GCOM_SERIAL = 0xad
- DLT_GCOM_T1E1 = 0xac
- DLT_GPF_F = 0xab
- DLT_GPF_T = 0xaa
- DLT_GPRS_LLC = 0xa9
- DLT_GSMTAP_ABIS = 0xda
- DLT_GSMTAP_UM = 0xd9
- DLT_HHDLC = 0x79
- DLT_IBM_SN = 0x92
- DLT_IBM_SP = 0x91
- DLT_IEEE802 = 0x6
- DLT_IEEE802_11 = 0x69
- DLT_IEEE802_11_RADIO = 0x7f
- DLT_IEEE802_11_RADIO_AVS = 0xa3
- DLT_IEEE802_15_4 = 0xc3
- DLT_IEEE802_15_4_LINUX = 0xbf
- DLT_IEEE802_15_4_NOFCS = 0xe6
- DLT_IEEE802_15_4_NONASK_PHY = 0xd7
- DLT_IEEE802_16_MAC_CPS = 0xbc
- DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1
- DLT_IPFILTER = 0x74
- DLT_IPMB = 0xc7
- DLT_IPMB_LINUX = 0xd1
- DLT_IPNET = 0xe2
- DLT_IPOIB = 0xf2
- DLT_IPV4 = 0xe4
- DLT_IPV6 = 0xe5
- DLT_IP_OVER_FC = 0x7a
- DLT_JUNIPER_ATM1 = 0x89
- DLT_JUNIPER_ATM2 = 0x87
- DLT_JUNIPER_ATM_CEMIC = 0xee
- DLT_JUNIPER_CHDLC = 0xb5
- DLT_JUNIPER_ES = 0x84
- DLT_JUNIPER_ETHER = 0xb2
- DLT_JUNIPER_FIBRECHANNEL = 0xea
- DLT_JUNIPER_FRELAY = 0xb4
- DLT_JUNIPER_GGSN = 0x85
- DLT_JUNIPER_ISM = 0xc2
- DLT_JUNIPER_MFR = 0x86
- DLT_JUNIPER_MLFR = 0x83
- DLT_JUNIPER_MLPPP = 0x82
- DLT_JUNIPER_MONITOR = 0xa4
- DLT_JUNIPER_PIC_PEER = 0xae
- DLT_JUNIPER_PPP = 0xb3
- DLT_JUNIPER_PPPOE = 0xa7
- DLT_JUNIPER_PPPOE_ATM = 0xa8
- DLT_JUNIPER_SERVICES = 0x88
- DLT_JUNIPER_SRX_E2E = 0xe9
- DLT_JUNIPER_ST = 0xc8
- DLT_JUNIPER_VP = 0xb7
- DLT_JUNIPER_VS = 0xe8
- DLT_LAPB_WITH_DIR = 0xcf
- DLT_LAPD = 0xcb
- DLT_LIN = 0xd4
- DLT_LINUX_EVDEV = 0xd8
- DLT_LINUX_IRDA = 0x90
- DLT_LINUX_LAPD = 0xb1
- DLT_LINUX_PPP_WITHDIRECTION = 0xa6
- DLT_LINUX_SLL = 0x71
- DLT_LOOP = 0x6c
- DLT_LTALK = 0x72
- DLT_MATCHING_MAX = 0xf5
- DLT_MATCHING_MIN = 0x68
- DLT_MFR = 0xb6
- DLT_MOST = 0xd3
- DLT_MPEG_2_TS = 0xf3
- DLT_MPLS = 0xdb
- DLT_MTP2 = 0x8c
- DLT_MTP2_WITH_PHDR = 0x8b
- DLT_MTP3 = 0x8d
- DLT_MUX27010 = 0xec
- DLT_NETANALYZER = 0xf0
- DLT_NETANALYZER_TRANSPARENT = 0xf1
- DLT_NFC_LLCP = 0xf5
- DLT_NFLOG = 0xef
- DLT_NG40 = 0xf4
- DLT_NULL = 0x0
- DLT_PCI_EXP = 0x7d
- DLT_PFLOG = 0x75
- DLT_PFSYNC = 0x12
- DLT_PPI = 0xc0
- DLT_PPP = 0x9
- DLT_PPP_BSDOS = 0x10
- DLT_PPP_ETHER = 0x33
- DLT_PPP_PPPD = 0xa6
- DLT_PPP_SERIAL = 0x32
- DLT_PPP_WITH_DIR = 0xcc
- DLT_PPP_WITH_DIRECTION = 0xa6
- DLT_PRISM_HEADER = 0x77
- DLT_PRONET = 0x4
- DLT_RAIF1 = 0xc6
- DLT_RAW = 0xc
- DLT_RIO = 0x7c
- DLT_SCCP = 0x8e
- DLT_SITA = 0xc4
- DLT_SLIP = 0x8
- DLT_SLIP_BSDOS = 0xf
- DLT_STANAG_5066_D_PDU = 0xed
- DLT_SUNATM = 0x7b
- DLT_SYMANTEC_FIREWALL = 0x63
- DLT_TZSP = 0x80
- DLT_USB = 0xba
- DLT_USB_LINUX = 0xbd
- DLT_USB_LINUX_MMAPPED = 0xdc
- DLT_USER0 = 0x93
- DLT_USER1 = 0x94
- DLT_USER10 = 0x9d
- DLT_USER11 = 0x9e
- DLT_USER12 = 0x9f
- DLT_USER13 = 0xa0
- DLT_USER14 = 0xa1
- DLT_USER15 = 0xa2
- DLT_USER2 = 0x95
- DLT_USER3 = 0x96
- DLT_USER4 = 0x97
- DLT_USER5 = 0x98
- DLT_USER6 = 0x99
- DLT_USER7 = 0x9a
- DLT_USER8 = 0x9b
- DLT_USER9 = 0x9c
- DLT_WIHART = 0xdf
- DLT_X2E_SERIAL = 0xd5
- DLT_X2E_XORAYA = 0xd6
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x40
- ECHOE = 0x2
- ECHOK = 0x4
- ECHOKE = 0x1
- ECHONL = 0x10
- ECHOPRT = 0x20
- EVFILT_AIO = -0x3
- EVFILT_FS = -0x9
- EVFILT_MACHPORT = -0x8
- EVFILT_PROC = -0x5
- EVFILT_READ = -0x1
- EVFILT_SIGNAL = -0x6
- EVFILT_SYSCOUNT = 0xe
- EVFILT_THREADMARKER = 0xe
- EVFILT_TIMER = -0x7
- EVFILT_USER = -0xa
- EVFILT_VM = -0xc
- EVFILT_VNODE = -0x4
- EVFILT_WRITE = -0x2
- EV_ADD = 0x1
- EV_CLEAR = 0x20
- EV_DELETE = 0x2
- EV_DISABLE = 0x8
- EV_DISPATCH = 0x80
- EV_ENABLE = 0x4
- EV_EOF = 0x8000
- EV_ERROR = 0x4000
- EV_FLAG0 = 0x1000
- EV_FLAG1 = 0x2000
- EV_ONESHOT = 0x10
- EV_OOBAND = 0x2000
- EV_POLL = 0x1000
- EV_RECEIPT = 0x40
- EV_SYSFLAGS = 0xf000
- EXTA = 0x4b00
- EXTB = 0x9600
- EXTPROC = 0x800
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FLUSHO = 0x800000
- F_ADDFILESIGS = 0x3d
- F_ADDSIGS = 0x3b
- F_ALLOCATEALL = 0x4
- F_ALLOCATECONTIG = 0x2
- F_CHKCLEAN = 0x29
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x43
- F_FINDSIGS = 0x4e
- F_FLUSH_DATA = 0x28
- F_FREEZE_FS = 0x35
- F_FULLFSYNC = 0x33
- F_GETCODEDIR = 0x48
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLK = 0x7
- F_GETLKPID = 0x42
- F_GETNOSIGPIPE = 0x4a
- F_GETOWN = 0x5
- F_GETPATH = 0x32
- F_GETPATH_MTMINFO = 0x47
- F_GETPROTECTIONCLASS = 0x3f
- F_GETPROTECTIONLEVEL = 0x4d
- F_GLOBAL_NOCACHE = 0x37
- F_LOG2PHYS = 0x31
- F_LOG2PHYS_EXT = 0x41
- F_NOCACHE = 0x30
- F_NODIRECT = 0x3e
- F_OK = 0x0
- F_PATHPKG_CHECK = 0x34
- F_PEOFPOSMODE = 0x3
- F_PREALLOCATE = 0x2a
- F_RDADVISE = 0x2c
- F_RDAHEAD = 0x2d
- F_RDLCK = 0x1
- F_SETBACKINGSTORE = 0x46
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLK = 0x8
- F_SETLKW = 0x9
- F_SETLKWTIMEOUT = 0xa
- F_SETNOSIGPIPE = 0x49
- F_SETOWN = 0x6
- F_SETPROTECTIONCLASS = 0x40
- F_SETSIZE = 0x2b
- F_SINGLE_WRITER = 0x4c
- F_THAW_FS = 0x36
- F_TRANSCODEKEY = 0x4b
- F_UNLCK = 0x2
- F_VOLPOSMODE = 0x4
- F_WRLCK = 0x3
- HUPCL = 0x4000
- ICANON = 0x100
- ICMP6_FILTER = 0x12
- ICRNL = 0x100
- IEXTEN = 0x400
- IFF_ALLMULTI = 0x200
- IFF_ALTPHYS = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_LINK0 = 0x1000
- IFF_LINK1 = 0x2000
- IFF_LINK2 = 0x4000
- IFF_LOOPBACK = 0x8
- IFF_MULTICAST = 0x8000
- IFF_NOARP = 0x80
- IFF_NOTRAILERS = 0x20
- IFF_OACTIVE = 0x400
- IFF_POINTOPOINT = 0x10
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SIMPLEX = 0x800
- IFF_UP = 0x1
- IFNAMSIZ = 0x10
- IFT_1822 = 0x2
- IFT_AAL5 = 0x31
- IFT_ARCNET = 0x23
- IFT_ARCNETPLUS = 0x24
- IFT_ATM = 0x25
- IFT_BRIDGE = 0xd1
- IFT_CARP = 0xf8
- IFT_CELLULAR = 0xff
- IFT_CEPT = 0x13
- IFT_DS3 = 0x1e
- IFT_ENC = 0xf4
- IFT_EON = 0x19
- IFT_ETHER = 0x6
- IFT_FAITH = 0x38
- IFT_FDDI = 0xf
- IFT_FRELAY = 0x20
- IFT_FRELAYDCE = 0x2c
- IFT_GIF = 0x37
- IFT_HDH1822 = 0x3
- IFT_HIPPI = 0x2f
- IFT_HSSI = 0x2e
- IFT_HY = 0xe
- IFT_IEEE1394 = 0x90
- IFT_IEEE8023ADLAG = 0x88
- IFT_ISDNBASIC = 0x14
- IFT_ISDNPRIMARY = 0x15
- IFT_ISO88022LLC = 0x29
- IFT_ISO88023 = 0x7
- IFT_ISO88024 = 0x8
- IFT_ISO88025 = 0x9
- IFT_ISO88026 = 0xa
- IFT_L2VLAN = 0x87
- IFT_LAPB = 0x10
- IFT_LOCALTALK = 0x2a
- IFT_LOOP = 0x18
- IFT_MIOX25 = 0x26
- IFT_MODEM = 0x30
- IFT_NSIP = 0x1b
- IFT_OTHER = 0x1
- IFT_P10 = 0xc
- IFT_P80 = 0xd
- IFT_PARA = 0x22
- IFT_PDP = 0xff
- IFT_PFLOG = 0xf5
- IFT_PFSYNC = 0xf6
- IFT_PKTAP = 0xfe
- IFT_PPP = 0x17
- IFT_PROPMUX = 0x36
- IFT_PROPVIRTUAL = 0x35
- IFT_PTPSERIAL = 0x16
- IFT_RS232 = 0x21
- IFT_SDLC = 0x11
- IFT_SIP = 0x1f
- IFT_SLIP = 0x1c
- IFT_SMDSDXI = 0x2b
- IFT_SMDSICIP = 0x34
- IFT_SONET = 0x27
- IFT_SONETPATH = 0x32
- IFT_SONETVT = 0x33
- IFT_STARLAN = 0xb
- IFT_STF = 0x39
- IFT_T1 = 0x12
- IFT_ULTRA = 0x1d
- IFT_V35 = 0x2d
- IFT_X25 = 0x5
- IFT_X25DDN = 0x4
- IFT_X25PLE = 0x28
- IFT_XETHER = 0x1a
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLASSD_HOST = 0xfffffff
- IN_CLASSD_NET = 0xf0000000
- IN_CLASSD_NSHIFT = 0x1c
- IN_LINKLOCALNETNUM = 0xa9fe0000
- IN_LOOPBACKNET = 0x7f
- IPPROTO_3PC = 0x22
- IPPROTO_ADFS = 0x44
- IPPROTO_AH = 0x33
- IPPROTO_AHIP = 0x3d
- IPPROTO_APES = 0x63
- IPPROTO_ARGUS = 0xd
- IPPROTO_AX25 = 0x5d
- IPPROTO_BHA = 0x31
- IPPROTO_BLT = 0x1e
- IPPROTO_BRSATMON = 0x4c
- IPPROTO_CFTP = 0x3e
- IPPROTO_CHAOS = 0x10
- IPPROTO_CMTP = 0x26
- IPPROTO_CPHB = 0x49
- IPPROTO_CPNX = 0x48
- IPPROTO_DDP = 0x25
- IPPROTO_DGP = 0x56
- IPPROTO_DIVERT = 0xfe
- IPPROTO_DONE = 0x101
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_EMCON = 0xe
- IPPROTO_ENCAP = 0x62
- IPPROTO_EON = 0x50
- IPPROTO_ESP = 0x32
- IPPROTO_ETHERIP = 0x61
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GGP = 0x3
- IPPROTO_GMTP = 0x64
- IPPROTO_GRE = 0x2f
- IPPROTO_HELLO = 0x3f
- IPPROTO_HMP = 0x14
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IDPR = 0x23
- IPPROTO_IDRP = 0x2d
- IPPROTO_IGMP = 0x2
- IPPROTO_IGP = 0x55
- IPPROTO_IGRP = 0x58
- IPPROTO_IL = 0x28
- IPPROTO_INLSP = 0x34
- IPPROTO_INP = 0x20
- IPPROTO_IP = 0x0
- IPPROTO_IPCOMP = 0x6c
- IPPROTO_IPCV = 0x47
- IPPROTO_IPEIP = 0x5e
- IPPROTO_IPIP = 0x4
- IPPROTO_IPPC = 0x43
- IPPROTO_IPV4 = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_IRTP = 0x1c
- IPPROTO_KRYPTOLAN = 0x41
- IPPROTO_LARP = 0x5b
- IPPROTO_LEAF1 = 0x19
- IPPROTO_LEAF2 = 0x1a
- IPPROTO_MAX = 0x100
- IPPROTO_MAXID = 0x34
- IPPROTO_MEAS = 0x13
- IPPROTO_MHRP = 0x30
- IPPROTO_MICP = 0x5f
- IPPROTO_MTP = 0x5c
- IPPROTO_MUX = 0x12
- IPPROTO_ND = 0x4d
- IPPROTO_NHRP = 0x36
- IPPROTO_NONE = 0x3b
- IPPROTO_NSP = 0x1f
- IPPROTO_NVPII = 0xb
- IPPROTO_OSPFIGP = 0x59
- IPPROTO_PGM = 0x71
- IPPROTO_PIGP = 0x9
- IPPROTO_PIM = 0x67
- IPPROTO_PRM = 0x15
- IPPROTO_PUP = 0xc
- IPPROTO_PVP = 0x4b
- IPPROTO_RAW = 0xff
- IPPROTO_RCCMON = 0xa
- IPPROTO_RDP = 0x1b
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_RVD = 0x42
- IPPROTO_SATEXPAK = 0x40
- IPPROTO_SATMON = 0x45
- IPPROTO_SCCSP = 0x60
- IPPROTO_SCTP = 0x84
- IPPROTO_SDRP = 0x2a
- IPPROTO_SEP = 0x21
- IPPROTO_SRPC = 0x5a
- IPPROTO_ST = 0x7
- IPPROTO_SVMTP = 0x52
- IPPROTO_SWIPE = 0x35
- IPPROTO_TCF = 0x57
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_TPXX = 0x27
- IPPROTO_TRUNK1 = 0x17
- IPPROTO_TRUNK2 = 0x18
- IPPROTO_TTP = 0x54
- IPPROTO_UDP = 0x11
- IPPROTO_VINES = 0x53
- IPPROTO_VISA = 0x46
- IPPROTO_VMTP = 0x51
- IPPROTO_WBEXPAK = 0x4f
- IPPROTO_WBMON = 0x4e
- IPPROTO_WSN = 0x4a
- IPPROTO_XNET = 0xf
- IPPROTO_XTP = 0x24
- IPV6_2292DSTOPTS = 0x17
- IPV6_2292HOPLIMIT = 0x14
- IPV6_2292HOPOPTS = 0x16
- IPV6_2292NEXTHOP = 0x15
- IPV6_2292PKTINFO = 0x13
- IPV6_2292PKTOPTIONS = 0x19
- IPV6_2292RTHDR = 0x18
- IPV6_BINDV6ONLY = 0x1b
- IPV6_BOUND_IF = 0x7d
- IPV6_CHECKSUM = 0x1a
- IPV6_DEFAULT_MULTICAST_HOPS = 0x1
- IPV6_DEFAULT_MULTICAST_LOOP = 0x1
- IPV6_DEFHLIM = 0x40
- IPV6_FAITH = 0x1d
- IPV6_FLOWINFO_MASK = 0xffffff0f
- IPV6_FLOWLABEL_MASK = 0xffff0f00
- IPV6_FRAGTTL = 0x3c
- IPV6_FW_ADD = 0x1e
- IPV6_FW_DEL = 0x1f
- IPV6_FW_FLUSH = 0x20
- IPV6_FW_GET = 0x22
- IPV6_FW_ZERO = 0x21
- IPV6_HLIMDEC = 0x1
- IPV6_IPSEC_POLICY = 0x1c
- IPV6_JOIN_GROUP = 0xc
- IPV6_LEAVE_GROUP = 0xd
- IPV6_MAXHLIM = 0xff
- IPV6_MAXOPTHDR = 0x800
- IPV6_MAXPACKET = 0xffff
- IPV6_MAX_GROUP_SRC_FILTER = 0x200
- IPV6_MAX_MEMBERSHIPS = 0xfff
- IPV6_MAX_SOCK_SRC_FILTER = 0x80
- IPV6_MIN_MEMBERSHIPS = 0x1f
- IPV6_MMTU = 0x500
- IPV6_MULTICAST_HOPS = 0xa
- IPV6_MULTICAST_IF = 0x9
- IPV6_MULTICAST_LOOP = 0xb
- IPV6_PORTRANGE = 0xe
- IPV6_PORTRANGE_DEFAULT = 0x0
- IPV6_PORTRANGE_HIGH = 0x1
- IPV6_PORTRANGE_LOW = 0x2
- IPV6_RECVTCLASS = 0x23
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_SOCKOPT_RESERVED1 = 0x3
- IPV6_TCLASS = 0x24
- IPV6_UNICAST_HOPS = 0x4
- IPV6_V6ONLY = 0x1b
- IPV6_VERSION = 0x60
- IPV6_VERSION_MASK = 0xf0
- IP_ADD_MEMBERSHIP = 0xc
- IP_ADD_SOURCE_MEMBERSHIP = 0x46
- IP_BLOCK_SOURCE = 0x48
- IP_BOUND_IF = 0x19
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0xd
- IP_DROP_SOURCE_MEMBERSHIP = 0x47
- IP_DUMMYNET_CONFIGURE = 0x3c
- IP_DUMMYNET_DEL = 0x3d
- IP_DUMMYNET_FLUSH = 0x3e
- IP_DUMMYNET_GET = 0x40
- IP_FAITH = 0x16
- IP_FW_ADD = 0x28
- IP_FW_DEL = 0x29
- IP_FW_FLUSH = 0x2a
- IP_FW_GET = 0x2c
- IP_FW_RESETLOG = 0x2d
- IP_FW_ZERO = 0x2b
- IP_HDRINCL = 0x2
- IP_IPSEC_POLICY = 0x15
- IP_MAXPACKET = 0xffff
- IP_MAX_GROUP_SRC_FILTER = 0x200
- IP_MAX_MEMBERSHIPS = 0xfff
- IP_MAX_SOCK_MUTE_FILTER = 0x80
- IP_MAX_SOCK_SRC_FILTER = 0x80
- IP_MF = 0x2000
- IP_MIN_MEMBERSHIPS = 0x1f
- IP_MSFILTER = 0x4a
- IP_MSS = 0x240
- IP_MULTICAST_IF = 0x9
- IP_MULTICAST_IFINDEX = 0x42
- IP_MULTICAST_LOOP = 0xb
- IP_MULTICAST_TTL = 0xa
- IP_MULTICAST_VIF = 0xe
- IP_NAT__XXX = 0x37
- IP_OFFMASK = 0x1fff
- IP_OLD_FW_ADD = 0x32
- IP_OLD_FW_DEL = 0x33
- IP_OLD_FW_FLUSH = 0x34
- IP_OLD_FW_GET = 0x36
- IP_OLD_FW_RESETLOG = 0x38
- IP_OLD_FW_ZERO = 0x35
- IP_OPTIONS = 0x1
- IP_PKTINFO = 0x1a
- IP_PORTRANGE = 0x13
- IP_PORTRANGE_DEFAULT = 0x0
- IP_PORTRANGE_HIGH = 0x1
- IP_PORTRANGE_LOW = 0x2
- IP_RECVDSTADDR = 0x7
- IP_RECVIF = 0x14
- IP_RECVOPTS = 0x5
- IP_RECVPKTINFO = 0x1a
- IP_RECVRETOPTS = 0x6
- IP_RECVTTL = 0x18
- IP_RETOPTS = 0x8
- IP_RF = 0x8000
- IP_RSVP_OFF = 0x10
- IP_RSVP_ON = 0xf
- IP_RSVP_VIF_OFF = 0x12
- IP_RSVP_VIF_ON = 0x11
- IP_STRIPHDR = 0x17
- IP_TOS = 0x3
- IP_TRAFFIC_MGT_BACKGROUND = 0x41
- IP_TTL = 0x4
- IP_UNBLOCK_SOURCE = 0x49
- ISIG = 0x80
- ISTRIP = 0x20
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x400
- IXON = 0x200
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_CAN_REUSE = 0x9
- MADV_DONTNEED = 0x4
- MADV_FREE = 0x5
- MADV_FREE_REUSABLE = 0x7
- MADV_FREE_REUSE = 0x8
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_SEQUENTIAL = 0x2
- MADV_WILLNEED = 0x3
- MADV_ZERO_WIRED_PAGES = 0x6
- MAP_ANON = 0x1000
- MAP_COPY = 0x2
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_HASSEMAPHORE = 0x200
- MAP_JIT = 0x800
- MAP_NOCACHE = 0x400
- MAP_NOEXTEND = 0x100
- MAP_NORESERVE = 0x40
- MAP_PRIVATE = 0x2
- MAP_RENAME = 0x20
- MAP_RESERVED0080 = 0x80
- MAP_SHARED = 0x1
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MSG_CTRUNC = 0x20
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x80
- MSG_EOF = 0x100
- MSG_EOR = 0x8
- MSG_FLUSH = 0x400
- MSG_HAVEMORE = 0x2000
- MSG_HOLD = 0x800
- MSG_NEEDSA = 0x10000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_RCVMORE = 0x4000
- MSG_SEND = 0x1000
- MSG_TRUNC = 0x10
- MSG_WAITALL = 0x40
- MSG_WAITSTREAM = 0x200
- MS_ASYNC = 0x1
- MS_DEACTIVATE = 0x8
- MS_INVALIDATE = 0x2
- MS_KILLPAGES = 0x4
- MS_SYNC = 0x10
- NAME_MAX = 0xff
- NET_RT_DUMP = 0x1
- NET_RT_DUMP2 = 0x7
- NET_RT_FLAGS = 0x2
- NET_RT_IFLIST = 0x3
- NET_RT_IFLIST2 = 0x6
- NET_RT_MAXID = 0xa
- NET_RT_STAT = 0x4
- NET_RT_TRASH = 0x5
- NOFLSH = 0x80000000
- NOTE_ABSOLUTE = 0x8
- NOTE_ATTRIB = 0x8
- NOTE_BACKGROUND = 0x40
- NOTE_CHILD = 0x4
- NOTE_CRITICAL = 0x20
- NOTE_DELETE = 0x1
- NOTE_EXEC = 0x20000000
- NOTE_EXIT = 0x80000000
- NOTE_EXITSTATUS = 0x4000000
- NOTE_EXIT_CSERROR = 0x40000
- NOTE_EXIT_DECRYPTFAIL = 0x10000
- NOTE_EXIT_DETAIL = 0x2000000
- NOTE_EXIT_DETAIL_MASK = 0x70000
- NOTE_EXIT_MEMORY = 0x20000
- NOTE_EXIT_REPARENTED = 0x80000
- NOTE_EXTEND = 0x4
- NOTE_FFAND = 0x40000000
- NOTE_FFCOPY = 0xc0000000
- NOTE_FFCTRLMASK = 0xc0000000
- NOTE_FFLAGSMASK = 0xffffff
- NOTE_FFNOP = 0x0
- NOTE_FFOR = 0x80000000
- NOTE_FORK = 0x40000000
- NOTE_LEEWAY = 0x10
- NOTE_LINK = 0x10
- NOTE_LOWAT = 0x1
- NOTE_NONE = 0x80
- NOTE_NSECONDS = 0x4
- NOTE_PCTRLMASK = -0x100000
- NOTE_PDATAMASK = 0xfffff
- NOTE_REAP = 0x10000000
- NOTE_RENAME = 0x20
- NOTE_REVOKE = 0x40
- NOTE_SECONDS = 0x1
- NOTE_SIGNAL = 0x8000000
- NOTE_TRACK = 0x1
- NOTE_TRACKERR = 0x2
- NOTE_TRIGGER = 0x1000000
- NOTE_USECONDS = 0x2
- NOTE_VM_ERROR = 0x10000000
- NOTE_VM_PRESSURE = 0x80000000
- NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000
- NOTE_VM_PRESSURE_TERMINATE = 0x40000000
- NOTE_WRITE = 0x2
- OCRNL = 0x10
- OFDEL = 0x20000
- OFILL = 0x80
- ONLCR = 0x2
- ONLRET = 0x40
- ONOCR = 0x20
- ONOEOT = 0x8
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_ALERT = 0x20000000
- O_APPEND = 0x8
- O_ASYNC = 0x40
- O_CLOEXEC = 0x1000000
- O_CREAT = 0x200
- O_DIRECTORY = 0x100000
- O_DP_GETRAWENCRYPTED = 0x1
- O_DSYNC = 0x400000
- O_EVTONLY = 0x8000
- O_EXCL = 0x800
- O_EXLOCK = 0x20
- O_FSYNC = 0x80
- O_NDELAY = 0x4
- O_NOCTTY = 0x20000
- O_NOFOLLOW = 0x100
- O_NONBLOCK = 0x4
- O_POPUP = 0x80000000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_SHLOCK = 0x10
- O_SYMLINK = 0x200000
- O_SYNC = 0x80
- O_TRUNC = 0x400
- O_WRONLY = 0x1
- PARENB = 0x1000
- PARMRK = 0x8
- PARODD = 0x2000
- PENDIN = 0x20000000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- PT_ATTACH = 0xa
- PT_ATTACHEXC = 0xe
- PT_CONTINUE = 0x7
- PT_DENY_ATTACH = 0x1f
- PT_DETACH = 0xb
- PT_FIRSTMACH = 0x20
- PT_FORCEQUOTA = 0x1e
- PT_KILL = 0x8
- PT_READ_D = 0x2
- PT_READ_I = 0x1
- PT_READ_U = 0x3
- PT_SIGEXC = 0xc
- PT_STEP = 0x9
- PT_THUPDATE = 0xd
- PT_TRACE_ME = 0x0
- PT_WRITE_D = 0x5
- PT_WRITE_I = 0x4
- PT_WRITE_U = 0x6
- RLIMIT_AS = 0x5
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_CPU_USAGE_MONITOR = 0x2
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x8
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = 0x7fffffffffffffff
- RTAX_AUTHOR = 0x6
- RTAX_BRD = 0x7
- RTAX_DST = 0x0
- RTAX_GATEWAY = 0x1
- RTAX_GENMASK = 0x3
- RTAX_IFA = 0x5
- RTAX_IFP = 0x4
- RTAX_MAX = 0x8
- RTAX_NETMASK = 0x2
- RTA_AUTHOR = 0x40
- RTA_BRD = 0x80
- RTA_DST = 0x1
- RTA_GATEWAY = 0x2
- RTA_GENMASK = 0x8
- RTA_IFA = 0x20
- RTA_IFP = 0x10
- RTA_NETMASK = 0x4
- RTF_BLACKHOLE = 0x1000
- RTF_BROADCAST = 0x400000
- RTF_CLONING = 0x100
- RTF_CONDEMNED = 0x2000000
- RTF_DELCLONE = 0x80
- RTF_DONE = 0x40
- RTF_DYNAMIC = 0x10
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_IFREF = 0x4000000
- RTF_IFSCOPE = 0x1000000
- RTF_LLINFO = 0x400
- RTF_LOCAL = 0x200000
- RTF_MODIFIED = 0x20
- RTF_MULTICAST = 0x800000
- RTF_NOIFREF = 0x2000
- RTF_PINNED = 0x100000
- RTF_PRCLONING = 0x10000
- RTF_PROTO1 = 0x8000
- RTF_PROTO2 = 0x4000
- RTF_PROTO3 = 0x40000
- RTF_PROXY = 0x8000000
- RTF_REJECT = 0x8
- RTF_ROUTER = 0x10000000
- RTF_STATIC = 0x800
- RTF_UP = 0x1
- RTF_WASCLONED = 0x20000
- RTF_XRESOLVE = 0x200
- RTM_ADD = 0x1
- RTM_CHANGE = 0x3
- RTM_DELADDR = 0xd
- RTM_DELETE = 0x2
- RTM_DELMADDR = 0x10
- RTM_GET = 0x4
- RTM_GET2 = 0x14
- RTM_IFINFO = 0xe
- RTM_IFINFO2 = 0x12
- RTM_LOCK = 0x8
- RTM_LOSING = 0x5
- RTM_MISS = 0x7
- RTM_NEWADDR = 0xc
- RTM_NEWMADDR = 0xf
- RTM_NEWMADDR2 = 0x13
- RTM_OLDADD = 0x9
- RTM_OLDDEL = 0xa
- RTM_REDIRECT = 0x6
- RTM_RESOLVE = 0xb
- RTM_RTTUNIT = 0xf4240
- RTM_VERSION = 0x5
- RTV_EXPIRE = 0x4
- RTV_HOPCOUNT = 0x2
- RTV_MTU = 0x1
- RTV_RPIPE = 0x8
- RTV_RTT = 0x40
- RTV_RTTVAR = 0x80
- RTV_SPIPE = 0x10
- RTV_SSTHRESH = 0x20
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- SCM_CREDS = 0x3
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x2
- SCM_TIMESTAMP_MONOTONIC = 0x4
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDMULTI = 0x80206931
- SIOCAIFADDR = 0x8040691a
- SIOCARPIPLL = 0xc0206928
- SIOCATMARK = 0x40047307
- SIOCAUTOADDR = 0xc0206926
- SIOCAUTONETMASK = 0x80206927
- SIOCDELMULTI = 0x80206932
- SIOCDIFADDR = 0x80206919
- SIOCDIFPHYADDR = 0x80206941
- SIOCGDRVSPEC = 0xc028697b
- SIOCGETVLAN = 0xc020697f
- SIOCGHIWAT = 0x40047301
- SIOCGIFADDR = 0xc0206921
- SIOCGIFALTMTU = 0xc0206948
- SIOCGIFASYNCMAP = 0xc020697c
- SIOCGIFBOND = 0xc0206947
- SIOCGIFBRDADDR = 0xc0206923
- SIOCGIFCAP = 0xc020695b
- SIOCGIFCONF = 0xc00c6924
- SIOCGIFDEVMTU = 0xc0206944
- SIOCGIFDSTADDR = 0xc0206922
- SIOCGIFFLAGS = 0xc0206911
- SIOCGIFGENERIC = 0xc020693a
- SIOCGIFKPI = 0xc0206987
- SIOCGIFMAC = 0xc0206982
- SIOCGIFMEDIA = 0xc02c6938
- SIOCGIFMETRIC = 0xc0206917
- SIOCGIFMTU = 0xc0206933
- SIOCGIFNETMASK = 0xc0206925
- SIOCGIFPDSTADDR = 0xc0206940
- SIOCGIFPHYS = 0xc0206935
- SIOCGIFPSRCADDR = 0xc020693f
- SIOCGIFSTATUS = 0xc331693d
- SIOCGIFVLAN = 0xc020697f
- SIOCGIFWAKEFLAGS = 0xc0206988
- SIOCGLOWAT = 0x40047303
- SIOCGPGRP = 0x40047309
- SIOCIFCREATE = 0xc0206978
- SIOCIFCREATE2 = 0xc020697a
- SIOCIFDESTROY = 0x80206979
- SIOCIFGCLONERS = 0xc0106981
- SIOCRSLVMULTI = 0xc010693b
- SIOCSDRVSPEC = 0x8028697b
- SIOCSETVLAN = 0x8020697e
- SIOCSHIWAT = 0x80047300
- SIOCSIFADDR = 0x8020690c
- SIOCSIFALTMTU = 0x80206945
- SIOCSIFASYNCMAP = 0x8020697d
- SIOCSIFBOND = 0x80206946
- SIOCSIFBRDADDR = 0x80206913
- SIOCSIFCAP = 0x8020695a
- SIOCSIFDSTADDR = 0x8020690e
- SIOCSIFFLAGS = 0x80206910
- SIOCSIFGENERIC = 0x80206939
- SIOCSIFKPI = 0x80206986
- SIOCSIFLLADDR = 0x8020693c
- SIOCSIFMAC = 0x80206983
- SIOCSIFMEDIA = 0xc0206937
- SIOCSIFMETRIC = 0x80206918
- SIOCSIFMTU = 0x80206934
- SIOCSIFNETMASK = 0x80206916
- SIOCSIFPHYADDR = 0x8040693e
- SIOCSIFPHYS = 0x80206936
- SIOCSIFVLAN = 0x8020697e
- SIOCSLOWAT = 0x80047302
- SIOCSPGRP = 0x80047308
- SOCK_DGRAM = 0x2
- SOCK_MAXADDRLEN = 0xff
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_SOCKET = 0xffff
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x2
- SO_BROADCAST = 0x20
- SO_DEBUG = 0x1
- SO_DONTROUTE = 0x10
- SO_DONTTRUNC = 0x2000
- SO_ERROR = 0x1007
- SO_KEEPALIVE = 0x8
- SO_LABEL = 0x1010
- SO_LINGER = 0x80
- SO_LINGER_SEC = 0x1080
- SO_NKE = 0x1021
- SO_NOADDRERR = 0x1023
- SO_NOSIGPIPE = 0x1022
- SO_NOTIFYCONFLICT = 0x1026
- SO_NP_EXTENSIONS = 0x1083
- SO_NREAD = 0x1020
- SO_NUMRCVPKT = 0x1112
- SO_NWRITE = 0x1024
- SO_OOBINLINE = 0x100
- SO_PEERLABEL = 0x1011
- SO_RANDOMPORT = 0x1082
- SO_RCVBUF = 0x1002
- SO_RCVLOWAT = 0x1004
- SO_RCVTIMEO = 0x1006
- SO_REUSEADDR = 0x4
- SO_REUSEPORT = 0x200
- SO_REUSESHAREUID = 0x1025
- SO_SNDBUF = 0x1001
- SO_SNDLOWAT = 0x1003
- SO_SNDTIMEO = 0x1005
- SO_TIMESTAMP = 0x400
- SO_TIMESTAMP_MONOTONIC = 0x800
- SO_TYPE = 0x1008
- SO_UPCALLCLOSEWAIT = 0x1027
- SO_USELOOPBACK = 0x40
- SO_WANTMORE = 0x4000
- SO_WANTOOBFLAG = 0x8000
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IFWHT = 0xe000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISTXT = 0x200
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TCIFLUSH = 0x1
- TCIOFLUSH = 0x3
- TCOFLUSH = 0x2
- TCP_CONNECTIONTIMEOUT = 0x20
- TCP_ENABLE_ECN = 0x104
- TCP_KEEPALIVE = 0x10
- TCP_KEEPCNT = 0x102
- TCP_KEEPINTVL = 0x101
- TCP_MAXHLEN = 0x3c
- TCP_MAXOLEN = 0x28
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_SACK = 0x4
- TCP_MAX_WINSHIFT = 0xe
- TCP_MINMSS = 0xd8
- TCP_MSS = 0x200
- TCP_NODELAY = 0x1
- TCP_NOOPT = 0x8
- TCP_NOPUSH = 0x4
- TCP_NOTSENT_LOWAT = 0x201
- TCP_RXT_CONNDROPTIME = 0x80
- TCP_RXT_FINDROP = 0x100
- TCP_SENDMOREACKS = 0x103
- TCSAFLUSH = 0x2
- TIOCCBRK = 0x2000747a
- TIOCCDTR = 0x20007478
- TIOCCONS = 0x80047462
- TIOCDCDTIMESTAMP = 0x40107458
- TIOCDRAIN = 0x2000745e
- TIOCDSIMICROCODE = 0x20007455
- TIOCEXCL = 0x2000740d
- TIOCEXT = 0x80047460
- TIOCFLUSH = 0x80047410
- TIOCGDRAINWAIT = 0x40047456
- TIOCGETA = 0x40487413
- TIOCGETD = 0x4004741a
- TIOCGPGRP = 0x40047477
- TIOCGWINSZ = 0x40087468
- TIOCIXOFF = 0x20007480
- TIOCIXON = 0x20007481
- TIOCMBIC = 0x8004746b
- TIOCMBIS = 0x8004746c
- TIOCMGDTRWAIT = 0x4004745a
- TIOCMGET = 0x4004746a
- TIOCMODG = 0x40047403
- TIOCMODS = 0x80047404
- TIOCMSDTRWAIT = 0x8004745b
- TIOCMSET = 0x8004746d
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x20007471
- TIOCNXCL = 0x2000740e
- TIOCOUTQ = 0x40047473
- TIOCPKT = 0x80047470
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCPTYGNAME = 0x40807453
- TIOCPTYGRANT = 0x20007454
- TIOCPTYUNLK = 0x20007452
- TIOCREMOTE = 0x80047469
- TIOCSBRK = 0x2000747b
- TIOCSCONS = 0x20007463
- TIOCSCTTY = 0x20007461
- TIOCSDRAINWAIT = 0x80047457
- TIOCSDTR = 0x20007479
- TIOCSETA = 0x80487414
- TIOCSETAF = 0x80487416
- TIOCSETAW = 0x80487415
- TIOCSETD = 0x8004741b
- TIOCSIG = 0x2000745f
- TIOCSPGRP = 0x80047476
- TIOCSTART = 0x2000746e
- TIOCSTAT = 0x20007465
- TIOCSTI = 0x80017472
- TIOCSTOP = 0x2000746f
- TIOCSWINSZ = 0x80087467
- TIOCTIMESTAMP = 0x40107459
- TIOCUCNTL = 0x80047466
- TOSTOP = 0x400000
- VDISCARD = 0xf
- VDSUSP = 0xb
- VEOF = 0x0
- VEOL = 0x1
- VEOL2 = 0x2
- VERASE = 0x3
- VINTR = 0x8
- VKILL = 0x5
- VLNEXT = 0xe
- VMIN = 0x10
- VQUIT = 0x9
- VREPRINT = 0x6
- VSTART = 0xc
- VSTATUS = 0x12
- VSTOP = 0xd
- VSUSP = 0xa
- VT0 = 0x0
- VT1 = 0x10000
- VTDLY = 0x10000
- VTIME = 0x11
- VWERASE = 0x4
- WCONTINUED = 0x10
- WCOREFLAG = 0x80
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOWAIT = 0x20
- WORDSIZE = 0x40
- WSTOPPED = 0x8
- WUNTRACED = 0x2
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x30)
- EADDRNOTAVAIL = syscall.Errno(0x31)
- EAFNOSUPPORT = syscall.Errno(0x2f)
- EAGAIN = syscall.Errno(0x23)
- EALREADY = syscall.Errno(0x25)
- EAUTH = syscall.Errno(0x50)
- EBADARCH = syscall.Errno(0x56)
- EBADEXEC = syscall.Errno(0x55)
- EBADF = syscall.Errno(0x9)
- EBADMACHO = syscall.Errno(0x58)
- EBADMSG = syscall.Errno(0x5e)
- EBADRPC = syscall.Errno(0x48)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x59)
- ECHILD = syscall.Errno(0xa)
- ECONNABORTED = syscall.Errno(0x35)
- ECONNREFUSED = syscall.Errno(0x3d)
- ECONNRESET = syscall.Errno(0x36)
- EDEADLK = syscall.Errno(0xb)
- EDESTADDRREQ = syscall.Errno(0x27)
- EDEVERR = syscall.Errno(0x53)
- EDOM = syscall.Errno(0x21)
- EDQUOT = syscall.Errno(0x45)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EFTYPE = syscall.Errno(0x4f)
- EHOSTDOWN = syscall.Errno(0x40)
- EHOSTUNREACH = syscall.Errno(0x41)
- EIDRM = syscall.Errno(0x5a)
- EILSEQ = syscall.Errno(0x5c)
- EINPROGRESS = syscall.Errno(0x24)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x38)
- EISDIR = syscall.Errno(0x15)
- ELAST = syscall.Errno(0x6a)
- ELOOP = syscall.Errno(0x3e)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x28)
- EMULTIHOP = syscall.Errno(0x5f)
- ENAMETOOLONG = syscall.Errno(0x3f)
- ENEEDAUTH = syscall.Errno(0x51)
- ENETDOWN = syscall.Errno(0x32)
- ENETRESET = syscall.Errno(0x34)
- ENETUNREACH = syscall.Errno(0x33)
- ENFILE = syscall.Errno(0x17)
- ENOATTR = syscall.Errno(0x5d)
- ENOBUFS = syscall.Errno(0x37)
- ENODATA = syscall.Errno(0x60)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOLCK = syscall.Errno(0x4d)
- ENOLINK = syscall.Errno(0x61)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x5b)
- ENOPOLICY = syscall.Errno(0x67)
- ENOPROTOOPT = syscall.Errno(0x2a)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x62)
- ENOSTR = syscall.Errno(0x63)
- ENOSYS = syscall.Errno(0x4e)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x39)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x42)
- ENOTRECOVERABLE = syscall.Errno(0x68)
- ENOTSOCK = syscall.Errno(0x26)
- ENOTSUP = syscall.Errno(0x2d)
- ENOTTY = syscall.Errno(0x19)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x66)
- EOVERFLOW = syscall.Errno(0x54)
- EOWNERDEAD = syscall.Errno(0x69)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x2e)
- EPIPE = syscall.Errno(0x20)
- EPROCLIM = syscall.Errno(0x43)
- EPROCUNAVAIL = syscall.Errno(0x4c)
- EPROGMISMATCH = syscall.Errno(0x4b)
- EPROGUNAVAIL = syscall.Errno(0x4a)
- EPROTO = syscall.Errno(0x64)
- EPROTONOSUPPORT = syscall.Errno(0x2b)
- EPROTOTYPE = syscall.Errno(0x29)
- EPWROFF = syscall.Errno(0x52)
- EQFULL = syscall.Errno(0x6a)
- ERANGE = syscall.Errno(0x22)
- EREMOTE = syscall.Errno(0x47)
- EROFS = syscall.Errno(0x1e)
- ERPCMISMATCH = syscall.Errno(0x49)
- ESHLIBVERS = syscall.Errno(0x57)
- ESHUTDOWN = syscall.Errno(0x3a)
- ESOCKTNOSUPPORT = syscall.Errno(0x2c)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESTALE = syscall.Errno(0x46)
- ETIME = syscall.Errno(0x65)
- ETIMEDOUT = syscall.Errno(0x3c)
- ETOOMANYREFS = syscall.Errno(0x3b)
- ETXTBSY = syscall.Errno(0x1a)
- EUSERS = syscall.Errno(0x44)
- EWOULDBLOCK = syscall.Errno(0x23)
- EXDEV = syscall.Errno(0x12)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0xa)
- SIGCHLD = syscall.Signal(0x14)
- SIGCONT = syscall.Signal(0x13)
- SIGEMT = syscall.Signal(0x7)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINFO = syscall.Signal(0x1d)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x17)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPROF = syscall.Signal(0x1b)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTOP = syscall.Signal(0x11)
- SIGSYS = syscall.Signal(0xc)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x12)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGURG = syscall.Signal(0x10)
- SIGUSR1 = syscall.Signal(0x1e)
- SIGUSR2 = syscall.Signal(0x1f)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "device not configured",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource deadlock avoided",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "resource busy",
- 17: "file exists",
- 18: "cross-device link",
- 19: "operation not supported by device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "result too large",
- 35: "resource temporarily unavailable",
- 36: "operation now in progress",
- 37: "operation already in progress",
- 38: "socket operation on non-socket",
- 39: "destination address required",
- 40: "message too long",
- 41: "protocol wrong type for socket",
- 42: "protocol not available",
- 43: "protocol not supported",
- 44: "socket type not supported",
- 45: "operation not supported",
- 46: "protocol family not supported",
- 47: "address family not supported by protocol family",
- 48: "address already in use",
- 49: "can't assign requested address",
- 50: "network is down",
- 51: "network is unreachable",
- 52: "network dropped connection on reset",
- 53: "software caused connection abort",
- 54: "connection reset by peer",
- 55: "no buffer space available",
- 56: "socket is already connected",
- 57: "socket is not connected",
- 58: "can't send after socket shutdown",
- 59: "too many references: can't splice",
- 60: "operation timed out",
- 61: "connection refused",
- 62: "too many levels of symbolic links",
- 63: "file name too long",
- 64: "host is down",
- 65: "no route to host",
- 66: "directory not empty",
- 67: "too many processes",
- 68: "too many users",
- 69: "disc quota exceeded",
- 70: "stale NFS file handle",
- 71: "too many levels of remote in path",
- 72: "RPC struct is bad",
- 73: "RPC version wrong",
- 74: "RPC prog. not avail",
- 75: "program version wrong",
- 76: "bad procedure for program",
- 77: "no locks available",
- 78: "function not implemented",
- 79: "inappropriate file type or format",
- 80: "authentication error",
- 81: "need authenticator",
- 82: "device power is off",
- 83: "device error",
- 84: "value too large to be stored in data type",
- 85: "bad executable (or shared library)",
- 86: "bad CPU type in executable",
- 87: "shared library version mismatch",
- 88: "malformed Mach-o file",
- 89: "operation canceled",
- 90: "identifier removed",
- 91: "no message of desired type",
- 92: "illegal byte sequence",
- 93: "attribute not found",
- 94: "bad message",
- 95: "EMULTIHOP (Reserved)",
- 96: "no message available on STREAM",
- 97: "ENOLINK (Reserved)",
- 98: "no STREAM resources",
- 99: "not a STREAM",
- 100: "protocol error",
- 101: "STREAM ioctl timeout",
- 102: "operation not supported on socket",
- 103: "policy not found",
- 104: "state not recoverable",
- 105: "previous owner died",
- 106: "interface output queue is full",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/BPT trap",
- 6: "abort trap",
- 7: "EMT trap",
- 8: "floating point exception",
- 9: "killed",
- 10: "bus error",
- 11: "segmentation fault",
- 12: "bad system call",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "urgent I/O condition",
- 17: "suspended (signal)",
- 18: "suspended",
- 19: "continued",
- 20: "child exited",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "I/O possible",
- 24: "cputime limit exceeded",
- 25: "filesize limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window size changes",
- 29: "information request",
- 30: "user defined signal 1",
- 31: "user defined signal 2",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go b/newt/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go
deleted file mode 100644
index 0feceee1..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go
+++ /dev/null
@@ -1,1530 +0,0 @@
-// mkerrors.sh -m64
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build amd64,dragonfly
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -m64 _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_APPLETALK = 0x10
- AF_ATM = 0x1e
- AF_BLUETOOTH = 0x21
- AF_CCITT = 0xa
- AF_CHAOS = 0x5
- AF_CNT = 0x15
- AF_COIP = 0x14
- AF_DATAKIT = 0x9
- AF_DECnet = 0xc
- AF_DLI = 0xd
- AF_E164 = 0x1a
- AF_ECMA = 0x8
- AF_HYLINK = 0xf
- AF_IEEE80211 = 0x23
- AF_IMPLINK = 0x3
- AF_INET = 0x2
- AF_INET6 = 0x1c
- AF_IPX = 0x17
- AF_ISDN = 0x1a
- AF_ISO = 0x7
- AF_LAT = 0xe
- AF_LINK = 0x12
- AF_LOCAL = 0x1
- AF_MAX = 0x24
- AF_MPLS = 0x22
- AF_NATM = 0x1d
- AF_NETGRAPH = 0x20
- AF_NS = 0x6
- AF_OSI = 0x7
- AF_PUP = 0x4
- AF_ROUTE = 0x11
- AF_SIP = 0x18
- AF_SNA = 0xb
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- B0 = 0x0
- B110 = 0x6e
- B115200 = 0x1c200
- B1200 = 0x4b0
- B134 = 0x86
- B14400 = 0x3840
- B150 = 0x96
- B1800 = 0x708
- B19200 = 0x4b00
- B200 = 0xc8
- B230400 = 0x38400
- B2400 = 0x960
- B28800 = 0x7080
- B300 = 0x12c
- B38400 = 0x9600
- B4800 = 0x12c0
- B50 = 0x32
- B57600 = 0xe100
- B600 = 0x258
- B7200 = 0x1c20
- B75 = 0x4b
- B76800 = 0x12c00
- B9600 = 0x2580
- BIOCFLUSH = 0x20004268
- BIOCGBLEN = 0x40044266
- BIOCGDLT = 0x4004426a
- BIOCGDLTLIST = 0xc0104279
- BIOCGETIF = 0x4020426b
- BIOCGHDRCMPLT = 0x40044274
- BIOCGRSIG = 0x40044272
- BIOCGRTIMEOUT = 0x4010426e
- BIOCGSEESENT = 0x40044276
- BIOCGSTATS = 0x4008426f
- BIOCIMMEDIATE = 0x80044270
- BIOCLOCK = 0x2000427a
- BIOCPROMISC = 0x20004269
- BIOCSBLEN = 0xc0044266
- BIOCSDLT = 0x80044278
- BIOCSETF = 0x80104267
- BIOCSETIF = 0x8020426c
- BIOCSETWF = 0x8010427b
- BIOCSHDRCMPLT = 0x80044275
- BIOCSRSIG = 0x80044273
- BIOCSRTIMEOUT = 0x8010426d
- BIOCSSEESENT = 0x80044277
- BIOCVERSION = 0x40044271
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALIGNMENT = 0x8
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DEFAULTBUFSIZE = 0x1000
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXBUFSIZE = 0x80000
- BPF_MAXINSNS = 0x200
- BPF_MAX_CLONES = 0x80
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINBUFSIZE = 0x20
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RELEASE = 0x30bb6
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BRKINT = 0x2
- CFLUSH = 0xf
- CLOCAL = 0x8000
- CREAD = 0x800
- CS5 = 0x0
- CS6 = 0x100
- CS7 = 0x200
- CS8 = 0x300
- CSIZE = 0x300
- CSTART = 0x11
- CSTATUS = 0x14
- CSTOP = 0x13
- CSTOPB = 0x400
- CSUSP = 0x1a
- CTL_MAXNAME = 0xc
- CTL_NET = 0x4
- DLT_A429 = 0xb8
- DLT_A653_ICM = 0xb9
- DLT_AIRONET_HEADER = 0x78
- DLT_APPLE_IP_OVER_IEEE1394 = 0x8a
- DLT_ARCNET = 0x7
- DLT_ARCNET_LINUX = 0x81
- DLT_ATM_CLIP = 0x13
- DLT_ATM_RFC1483 = 0xb
- DLT_AURORA = 0x7e
- DLT_AX25 = 0x3
- DLT_AX25_KISS = 0xca
- DLT_BACNET_MS_TP = 0xa5
- DLT_BLUETOOTH_HCI_H4 = 0xbb
- DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9
- DLT_CAN20B = 0xbe
- DLT_CHAOS = 0x5
- DLT_CHDLC = 0x68
- DLT_CISCO_IOS = 0x76
- DLT_C_HDLC = 0x68
- DLT_C_HDLC_WITH_DIR = 0xcd
- DLT_DOCSIS = 0x8f
- DLT_ECONET = 0x73
- DLT_EN10MB = 0x1
- DLT_EN3MB = 0x2
- DLT_ENC = 0x6d
- DLT_ERF = 0xc5
- DLT_ERF_ETH = 0xaf
- DLT_ERF_POS = 0xb0
- DLT_FDDI = 0xa
- DLT_FLEXRAY = 0xd2
- DLT_FRELAY = 0x6b
- DLT_FRELAY_WITH_DIR = 0xce
- DLT_GCOM_SERIAL = 0xad
- DLT_GCOM_T1E1 = 0xac
- DLT_GPF_F = 0xab
- DLT_GPF_T = 0xaa
- DLT_GPRS_LLC = 0xa9
- DLT_HHDLC = 0x79
- DLT_IBM_SN = 0x92
- DLT_IBM_SP = 0x91
- DLT_IEEE802 = 0x6
- DLT_IEEE802_11 = 0x69
- DLT_IEEE802_11_RADIO = 0x7f
- DLT_IEEE802_11_RADIO_AVS = 0xa3
- DLT_IEEE802_15_4 = 0xc3
- DLT_IEEE802_15_4_LINUX = 0xbf
- DLT_IEEE802_15_4_NONASK_PHY = 0xd7
- DLT_IEEE802_16_MAC_CPS = 0xbc
- DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1
- DLT_IPFILTER = 0x74
- DLT_IPMB = 0xc7
- DLT_IPMB_LINUX = 0xd1
- DLT_IP_OVER_FC = 0x7a
- DLT_JUNIPER_ATM1 = 0x89
- DLT_JUNIPER_ATM2 = 0x87
- DLT_JUNIPER_CHDLC = 0xb5
- DLT_JUNIPER_ES = 0x84
- DLT_JUNIPER_ETHER = 0xb2
- DLT_JUNIPER_FRELAY = 0xb4
- DLT_JUNIPER_GGSN = 0x85
- DLT_JUNIPER_ISM = 0xc2
- DLT_JUNIPER_MFR = 0x86
- DLT_JUNIPER_MLFR = 0x83
- DLT_JUNIPER_MLPPP = 0x82
- DLT_JUNIPER_MONITOR = 0xa4
- DLT_JUNIPER_PIC_PEER = 0xae
- DLT_JUNIPER_PPP = 0xb3
- DLT_JUNIPER_PPPOE = 0xa7
- DLT_JUNIPER_PPPOE_ATM = 0xa8
- DLT_JUNIPER_SERVICES = 0x88
- DLT_JUNIPER_ST = 0xc8
- DLT_JUNIPER_VP = 0xb7
- DLT_LAPB_WITH_DIR = 0xcf
- DLT_LAPD = 0xcb
- DLT_LIN = 0xd4
- DLT_LINUX_IRDA = 0x90
- DLT_LINUX_LAPD = 0xb1
- DLT_LINUX_SLL = 0x71
- DLT_LOOP = 0x6c
- DLT_LTALK = 0x72
- DLT_MFR = 0xb6
- DLT_MOST = 0xd3
- DLT_MTP2 = 0x8c
- DLT_MTP2_WITH_PHDR = 0x8b
- DLT_MTP3 = 0x8d
- DLT_NULL = 0x0
- DLT_PCI_EXP = 0x7d
- DLT_PFLOG = 0x75
- DLT_PFSYNC = 0x12
- DLT_PPI = 0xc0
- DLT_PPP = 0x9
- DLT_PPP_BSDOS = 0x10
- DLT_PPP_ETHER = 0x33
- DLT_PPP_PPPD = 0xa6
- DLT_PPP_SERIAL = 0x32
- DLT_PPP_WITH_DIR = 0xcc
- DLT_PRISM_HEADER = 0x77
- DLT_PRONET = 0x4
- DLT_RAIF1 = 0xc6
- DLT_RAW = 0xc
- DLT_REDBACK_SMARTEDGE = 0x20
- DLT_RIO = 0x7c
- DLT_SCCP = 0x8e
- DLT_SITA = 0xc4
- DLT_SLIP = 0x8
- DLT_SLIP_BSDOS = 0xf
- DLT_SUNATM = 0x7b
- DLT_SYMANTEC_FIREWALL = 0x63
- DLT_TZSP = 0x80
- DLT_USB = 0xba
- DLT_USB_LINUX = 0xbd
- DLT_X2E_SERIAL = 0xd5
- DLT_X2E_XORAYA = 0xd6
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DBF = 0xf
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x40
- ECHOE = 0x2
- ECHOK = 0x4
- ECHOKE = 0x1
- ECHONL = 0x10
- ECHOPRT = 0x20
- EVFILT_AIO = -0x3
- EVFILT_EXCEPT = -0x8
- EVFILT_MARKER = 0xf
- EVFILT_PROC = -0x5
- EVFILT_READ = -0x1
- EVFILT_SIGNAL = -0x6
- EVFILT_SYSCOUNT = 0x8
- EVFILT_TIMER = -0x7
- EVFILT_VNODE = -0x4
- EVFILT_WRITE = -0x2
- EV_ADD = 0x1
- EV_CLEAR = 0x20
- EV_DELETE = 0x2
- EV_DISABLE = 0x8
- EV_ENABLE = 0x4
- EV_EOF = 0x8000
- EV_ERROR = 0x4000
- EV_FLAG1 = 0x2000
- EV_NODATA = 0x1000
- EV_ONESHOT = 0x10
- EV_SYSFLAGS = 0xf000
- EXTA = 0x4b00
- EXTB = 0x9600
- EXTEXIT_LWP = 0x10000
- EXTEXIT_PROC = 0x0
- EXTEXIT_SETINT = 0x1
- EXTEXIT_SIMPLE = 0x0
- EXTPROC = 0x800
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FLUSHO = 0x800000
- F_DUP2FD = 0xa
- F_DUP2FD_CLOEXEC = 0x12
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x11
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLK = 0x7
- F_GETOWN = 0x5
- F_OK = 0x0
- F_RDLCK = 0x1
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLK = 0x8
- F_SETLKW = 0x9
- F_SETOWN = 0x6
- F_UNLCK = 0x2
- F_WRLCK = 0x3
- HUPCL = 0x4000
- ICANON = 0x100
- ICMP6_FILTER = 0x12
- ICRNL = 0x100
- IEXTEN = 0x400
- IFAN_ARRIVAL = 0x0
- IFAN_DEPARTURE = 0x1
- IFF_ALLMULTI = 0x200
- IFF_ALTPHYS = 0x4000
- IFF_BROADCAST = 0x2
- IFF_CANTCHANGE = 0x118e72
- IFF_DEBUG = 0x4
- IFF_LINK0 = 0x1000
- IFF_LINK1 = 0x2000
- IFF_LINK2 = 0x4000
- IFF_LOOPBACK = 0x8
- IFF_MONITOR = 0x40000
- IFF_MULTICAST = 0x8000
- IFF_NOARP = 0x80
- IFF_NPOLLING = 0x100000
- IFF_OACTIVE = 0x400
- IFF_OACTIVE_COMPAT = 0x400
- IFF_POINTOPOINT = 0x10
- IFF_POLLING = 0x10000
- IFF_POLLING_COMPAT = 0x10000
- IFF_PPROMISC = 0x20000
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SIMPLEX = 0x800
- IFF_SMART = 0x20
- IFF_STATICARP = 0x80000
- IFF_UP = 0x1
- IFNAMSIZ = 0x10
- IFT_1822 = 0x2
- IFT_A12MPPSWITCH = 0x82
- IFT_AAL2 = 0xbb
- IFT_AAL5 = 0x31
- IFT_ADSL = 0x5e
- IFT_AFLANE8023 = 0x3b
- IFT_AFLANE8025 = 0x3c
- IFT_ARAP = 0x58
- IFT_ARCNET = 0x23
- IFT_ARCNETPLUS = 0x24
- IFT_ASYNC = 0x54
- IFT_ATM = 0x25
- IFT_ATMDXI = 0x69
- IFT_ATMFUNI = 0x6a
- IFT_ATMIMA = 0x6b
- IFT_ATMLOGICAL = 0x50
- IFT_ATMRADIO = 0xbd
- IFT_ATMSUBINTERFACE = 0x86
- IFT_ATMVCIENDPT = 0xc2
- IFT_ATMVIRTUAL = 0x95
- IFT_BGPPOLICYACCOUNTING = 0xa2
- IFT_BRIDGE = 0xd1
- IFT_BSC = 0x53
- IFT_CARP = 0xf8
- IFT_CCTEMUL = 0x3d
- IFT_CEPT = 0x13
- IFT_CES = 0x85
- IFT_CHANNEL = 0x46
- IFT_CNR = 0x55
- IFT_COFFEE = 0x84
- IFT_COMPOSITELINK = 0x9b
- IFT_DCN = 0x8d
- IFT_DIGITALPOWERLINE = 0x8a
- IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
- IFT_DLSW = 0x4a
- IFT_DOCSCABLEDOWNSTREAM = 0x80
- IFT_DOCSCABLEMACLAYER = 0x7f
- IFT_DOCSCABLEUPSTREAM = 0x81
- IFT_DS0 = 0x51
- IFT_DS0BUNDLE = 0x52
- IFT_DS1FDL = 0xaa
- IFT_DS3 = 0x1e
- IFT_DTM = 0x8c
- IFT_DVBASILN = 0xac
- IFT_DVBASIOUT = 0xad
- IFT_DVBRCCDOWNSTREAM = 0x93
- IFT_DVBRCCMACLAYER = 0x92
- IFT_DVBRCCUPSTREAM = 0x94
- IFT_ENC = 0xf4
- IFT_EON = 0x19
- IFT_EPLRS = 0x57
- IFT_ESCON = 0x49
- IFT_ETHER = 0x6
- IFT_FAITH = 0xf2
- IFT_FAST = 0x7d
- IFT_FASTETHER = 0x3e
- IFT_FASTETHERFX = 0x45
- IFT_FDDI = 0xf
- IFT_FIBRECHANNEL = 0x38
- IFT_FRAMERELAYINTERCONNECT = 0x3a
- IFT_FRAMERELAYMPI = 0x5c
- IFT_FRDLCIENDPT = 0xc1
- IFT_FRELAY = 0x20
- IFT_FRELAYDCE = 0x2c
- IFT_FRF16MFRBUNDLE = 0xa3
- IFT_FRFORWARD = 0x9e
- IFT_G703AT2MB = 0x43
- IFT_G703AT64K = 0x42
- IFT_GIF = 0xf0
- IFT_GIGABITETHERNET = 0x75
- IFT_GR303IDT = 0xb2
- IFT_GR303RDT = 0xb1
- IFT_H323GATEKEEPER = 0xa4
- IFT_H323PROXY = 0xa5
- IFT_HDH1822 = 0x3
- IFT_HDLC = 0x76
- IFT_HDSL2 = 0xa8
- IFT_HIPERLAN2 = 0xb7
- IFT_HIPPI = 0x2f
- IFT_HIPPIINTERFACE = 0x39
- IFT_HOSTPAD = 0x5a
- IFT_HSSI = 0x2e
- IFT_HY = 0xe
- IFT_IBM370PARCHAN = 0x48
- IFT_IDSL = 0x9a
- IFT_IEEE1394 = 0x90
- IFT_IEEE80211 = 0x47
- IFT_IEEE80212 = 0x37
- IFT_IEEE8023ADLAG = 0xa1
- IFT_IFGSN = 0x91
- IFT_IMT = 0xbe
- IFT_INTERLEAVE = 0x7c
- IFT_IP = 0x7e
- IFT_IPFORWARD = 0x8e
- IFT_IPOVERATM = 0x72
- IFT_IPOVERCDLC = 0x6d
- IFT_IPOVERCLAW = 0x6e
- IFT_IPSWITCH = 0x4e
- IFT_ISDN = 0x3f
- IFT_ISDNBASIC = 0x14
- IFT_ISDNPRIMARY = 0x15
- IFT_ISDNS = 0x4b
- IFT_ISDNU = 0x4c
- IFT_ISO88022LLC = 0x29
- IFT_ISO88023 = 0x7
- IFT_ISO88024 = 0x8
- IFT_ISO88025 = 0x9
- IFT_ISO88025CRFPINT = 0x62
- IFT_ISO88025DTR = 0x56
- IFT_ISO88025FIBER = 0x73
- IFT_ISO88026 = 0xa
- IFT_ISUP = 0xb3
- IFT_L2VLAN = 0x87
- IFT_L3IPVLAN = 0x88
- IFT_L3IPXVLAN = 0x89
- IFT_LAPB = 0x10
- IFT_LAPD = 0x4d
- IFT_LAPF = 0x77
- IFT_LOCALTALK = 0x2a
- IFT_LOOP = 0x18
- IFT_MEDIAMAILOVERIP = 0x8b
- IFT_MFSIGLINK = 0xa7
- IFT_MIOX25 = 0x26
- IFT_MODEM = 0x30
- IFT_MPC = 0x71
- IFT_MPLS = 0xa6
- IFT_MPLSTUNNEL = 0x96
- IFT_MSDSL = 0x8f
- IFT_MVL = 0xbf
- IFT_MYRINET = 0x63
- IFT_NFAS = 0xaf
- IFT_NSIP = 0x1b
- IFT_OPTICALCHANNEL = 0xc3
- IFT_OPTICALTRANSPORT = 0xc4
- IFT_OTHER = 0x1
- IFT_P10 = 0xc
- IFT_P80 = 0xd
- IFT_PARA = 0x22
- IFT_PFLOG = 0xf5
- IFT_PFSYNC = 0xf6
- IFT_PLC = 0xae
- IFT_POS = 0xab
- IFT_PPP = 0x17
- IFT_PPPMULTILINKBUNDLE = 0x6c
- IFT_PROPBWAP2MP = 0xb8
- IFT_PROPCNLS = 0x59
- IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
- IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
- IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
- IFT_PROPMUX = 0x36
- IFT_PROPVIRTUAL = 0x35
- IFT_PROPWIRELESSP2P = 0x9d
- IFT_PTPSERIAL = 0x16
- IFT_PVC = 0xf1
- IFT_QLLC = 0x44
- IFT_RADIOMAC = 0xbc
- IFT_RADSL = 0x5f
- IFT_REACHDSL = 0xc0
- IFT_RFC1483 = 0x9f
- IFT_RS232 = 0x21
- IFT_RSRB = 0x4f
- IFT_SDLC = 0x11
- IFT_SDSL = 0x60
- IFT_SHDSL = 0xa9
- IFT_SIP = 0x1f
- IFT_SLIP = 0x1c
- IFT_SMDSDXI = 0x2b
- IFT_SMDSICIP = 0x34
- IFT_SONET = 0x27
- IFT_SONETOVERHEADCHANNEL = 0xb9
- IFT_SONETPATH = 0x32
- IFT_SONETVT = 0x33
- IFT_SRP = 0x97
- IFT_SS7SIGLINK = 0x9c
- IFT_STACKTOSTACK = 0x6f
- IFT_STARLAN = 0xb
- IFT_STF = 0xf3
- IFT_T1 = 0x12
- IFT_TDLC = 0x74
- IFT_TERMPAD = 0x5b
- IFT_TR008 = 0xb0
- IFT_TRANSPHDLC = 0x7b
- IFT_TUNNEL = 0x83
- IFT_ULTRA = 0x1d
- IFT_USB = 0xa0
- IFT_V11 = 0x40
- IFT_V35 = 0x2d
- IFT_V36 = 0x41
- IFT_V37 = 0x78
- IFT_VDSL = 0x61
- IFT_VIRTUALIPADDRESS = 0x70
- IFT_VOICEEM = 0x64
- IFT_VOICEENCAP = 0x67
- IFT_VOICEFXO = 0x65
- IFT_VOICEFXS = 0x66
- IFT_VOICEOVERATM = 0x98
- IFT_VOICEOVERFRAMERELAY = 0x99
- IFT_VOICEOVERIP = 0x68
- IFT_X213 = 0x5d
- IFT_X25 = 0x5
- IFT_X25DDN = 0x4
- IFT_X25HUNTGROUP = 0x7a
- IFT_X25MLP = 0x79
- IFT_X25PLE = 0x28
- IFT_XETHER = 0x1a
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLASSD_HOST = 0xfffffff
- IN_CLASSD_NET = 0xf0000000
- IN_CLASSD_NSHIFT = 0x1c
- IN_LOOPBACKNET = 0x7f
- IPPROTO_3PC = 0x22
- IPPROTO_ADFS = 0x44
- IPPROTO_AH = 0x33
- IPPROTO_AHIP = 0x3d
- IPPROTO_APES = 0x63
- IPPROTO_ARGUS = 0xd
- IPPROTO_AX25 = 0x5d
- IPPROTO_BHA = 0x31
- IPPROTO_BLT = 0x1e
- IPPROTO_BRSATMON = 0x4c
- IPPROTO_CARP = 0x70
- IPPROTO_CFTP = 0x3e
- IPPROTO_CHAOS = 0x10
- IPPROTO_CMTP = 0x26
- IPPROTO_CPHB = 0x49
- IPPROTO_CPNX = 0x48
- IPPROTO_DDP = 0x25
- IPPROTO_DGP = 0x56
- IPPROTO_DIVERT = 0xfe
- IPPROTO_DONE = 0x101
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_EMCON = 0xe
- IPPROTO_ENCAP = 0x62
- IPPROTO_EON = 0x50
- IPPROTO_ESP = 0x32
- IPPROTO_ETHERIP = 0x61
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GGP = 0x3
- IPPROTO_GMTP = 0x64
- IPPROTO_GRE = 0x2f
- IPPROTO_HELLO = 0x3f
- IPPROTO_HMP = 0x14
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IDPR = 0x23
- IPPROTO_IDRP = 0x2d
- IPPROTO_IGMP = 0x2
- IPPROTO_IGP = 0x55
- IPPROTO_IGRP = 0x58
- IPPROTO_IL = 0x28
- IPPROTO_INLSP = 0x34
- IPPROTO_INP = 0x20
- IPPROTO_IP = 0x0
- IPPROTO_IPCOMP = 0x6c
- IPPROTO_IPCV = 0x47
- IPPROTO_IPEIP = 0x5e
- IPPROTO_IPIP = 0x4
- IPPROTO_IPPC = 0x43
- IPPROTO_IPV4 = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_IRTP = 0x1c
- IPPROTO_KRYPTOLAN = 0x41
- IPPROTO_LARP = 0x5b
- IPPROTO_LEAF1 = 0x19
- IPPROTO_LEAF2 = 0x1a
- IPPROTO_MAX = 0x100
- IPPROTO_MAXID = 0x34
- IPPROTO_MEAS = 0x13
- IPPROTO_MHRP = 0x30
- IPPROTO_MICP = 0x5f
- IPPROTO_MOBILE = 0x37
- IPPROTO_MTP = 0x5c
- IPPROTO_MUX = 0x12
- IPPROTO_ND = 0x4d
- IPPROTO_NHRP = 0x36
- IPPROTO_NONE = 0x3b
- IPPROTO_NSP = 0x1f
- IPPROTO_NVPII = 0xb
- IPPROTO_OSPFIGP = 0x59
- IPPROTO_PFSYNC = 0xf0
- IPPROTO_PGM = 0x71
- IPPROTO_PIGP = 0x9
- IPPROTO_PIM = 0x67
- IPPROTO_PRM = 0x15
- IPPROTO_PUP = 0xc
- IPPROTO_PVP = 0x4b
- IPPROTO_RAW = 0xff
- IPPROTO_RCCMON = 0xa
- IPPROTO_RDP = 0x1b
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_RVD = 0x42
- IPPROTO_SATEXPAK = 0x40
- IPPROTO_SATMON = 0x45
- IPPROTO_SCCSP = 0x60
- IPPROTO_SCTP = 0x84
- IPPROTO_SDRP = 0x2a
- IPPROTO_SEP = 0x21
- IPPROTO_SKIP = 0x39
- IPPROTO_SRPC = 0x5a
- IPPROTO_ST = 0x7
- IPPROTO_SVMTP = 0x52
- IPPROTO_SWIPE = 0x35
- IPPROTO_TCF = 0x57
- IPPROTO_TCP = 0x6
- IPPROTO_TLSP = 0x38
- IPPROTO_TP = 0x1d
- IPPROTO_TPXX = 0x27
- IPPROTO_TRUNK1 = 0x17
- IPPROTO_TRUNK2 = 0x18
- IPPROTO_TTP = 0x54
- IPPROTO_UDP = 0x11
- IPPROTO_UNKNOWN = 0x102
- IPPROTO_VINES = 0x53
- IPPROTO_VISA = 0x46
- IPPROTO_VMTP = 0x51
- IPPROTO_WBEXPAK = 0x4f
- IPPROTO_WBMON = 0x4e
- IPPROTO_WSN = 0x4a
- IPPROTO_XNET = 0xf
- IPPROTO_XTP = 0x24
- IPV6_AUTOFLOWLABEL = 0x3b
- IPV6_BINDV6ONLY = 0x1b
- IPV6_CHECKSUM = 0x1a
- IPV6_DEFAULT_MULTICAST_HOPS = 0x1
- IPV6_DEFAULT_MULTICAST_LOOP = 0x1
- IPV6_DEFHLIM = 0x40
- IPV6_DONTFRAG = 0x3e
- IPV6_DSTOPTS = 0x32
- IPV6_FAITH = 0x1d
- IPV6_FLOWINFO_MASK = 0xffffff0f
- IPV6_FLOWLABEL_MASK = 0xffff0f00
- IPV6_FRAGTTL = 0x78
- IPV6_FW_ADD = 0x1e
- IPV6_FW_DEL = 0x1f
- IPV6_FW_FLUSH = 0x20
- IPV6_FW_GET = 0x22
- IPV6_FW_ZERO = 0x21
- IPV6_HLIMDEC = 0x1
- IPV6_HOPLIMIT = 0x2f
- IPV6_HOPOPTS = 0x31
- IPV6_IPSEC_POLICY = 0x1c
- IPV6_JOIN_GROUP = 0xc
- IPV6_LEAVE_GROUP = 0xd
- IPV6_MAXHLIM = 0xff
- IPV6_MAXPACKET = 0xffff
- IPV6_MMTU = 0x500
- IPV6_MSFILTER = 0x4a
- IPV6_MULTICAST_HOPS = 0xa
- IPV6_MULTICAST_IF = 0x9
- IPV6_MULTICAST_LOOP = 0xb
- IPV6_NEXTHOP = 0x30
- IPV6_PATHMTU = 0x2c
- IPV6_PKTINFO = 0x2e
- IPV6_PKTOPTIONS = 0x34
- IPV6_PORTRANGE = 0xe
- IPV6_PORTRANGE_DEFAULT = 0x0
- IPV6_PORTRANGE_HIGH = 0x1
- IPV6_PORTRANGE_LOW = 0x2
- IPV6_PREFER_TEMPADDR = 0x3f
- IPV6_RECVDSTOPTS = 0x28
- IPV6_RECVHOPLIMIT = 0x25
- IPV6_RECVHOPOPTS = 0x27
- IPV6_RECVPATHMTU = 0x2b
- IPV6_RECVPKTINFO = 0x24
- IPV6_RECVRTHDR = 0x26
- IPV6_RECVTCLASS = 0x39
- IPV6_RTHDR = 0x33
- IPV6_RTHDRDSTOPTS = 0x23
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_SOCKOPT_RESERVED1 = 0x3
- IPV6_TCLASS = 0x3d
- IPV6_UNICAST_HOPS = 0x4
- IPV6_USE_MIN_MTU = 0x2a
- IPV6_V6ONLY = 0x1b
- IPV6_VERSION = 0x60
- IPV6_VERSION_MASK = 0xf0
- IP_ADD_MEMBERSHIP = 0xc
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0xd
- IP_DUMMYNET_CONFIGURE = 0x3c
- IP_DUMMYNET_DEL = 0x3d
- IP_DUMMYNET_FLUSH = 0x3e
- IP_DUMMYNET_GET = 0x40
- IP_FAITH = 0x16
- IP_FW_ADD = 0x32
- IP_FW_DEL = 0x33
- IP_FW_FLUSH = 0x34
- IP_FW_GET = 0x36
- IP_FW_RESETLOG = 0x37
- IP_FW_ZERO = 0x35
- IP_HDRINCL = 0x2
- IP_IPSEC_POLICY = 0x15
- IP_MAXPACKET = 0xffff
- IP_MAX_MEMBERSHIPS = 0x14
- IP_MF = 0x2000
- IP_MINTTL = 0x42
- IP_MSS = 0x240
- IP_MULTICAST_IF = 0x9
- IP_MULTICAST_LOOP = 0xb
- IP_MULTICAST_TTL = 0xa
- IP_MULTICAST_VIF = 0xe
- IP_OFFMASK = 0x1fff
- IP_OPTIONS = 0x1
- IP_PORTRANGE = 0x13
- IP_PORTRANGE_DEFAULT = 0x0
- IP_PORTRANGE_HIGH = 0x1
- IP_PORTRANGE_LOW = 0x2
- IP_RECVDSTADDR = 0x7
- IP_RECVIF = 0x14
- IP_RECVOPTS = 0x5
- IP_RECVRETOPTS = 0x6
- IP_RECVTTL = 0x41
- IP_RETOPTS = 0x8
- IP_RF = 0x8000
- IP_RSVP_OFF = 0x10
- IP_RSVP_ON = 0xf
- IP_RSVP_VIF_OFF = 0x12
- IP_RSVP_VIF_ON = 0x11
- IP_TOS = 0x3
- IP_TTL = 0x4
- ISIG = 0x80
- ISTRIP = 0x20
- IXANY = 0x800
- IXOFF = 0x400
- IXON = 0x200
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_AUTOSYNC = 0x7
- MADV_CONTROL_END = 0xb
- MADV_CONTROL_START = 0xa
- MADV_CORE = 0x9
- MADV_DONTNEED = 0x4
- MADV_FREE = 0x5
- MADV_INVAL = 0xa
- MADV_NOCORE = 0x8
- MADV_NORMAL = 0x0
- MADV_NOSYNC = 0x6
- MADV_RANDOM = 0x1
- MADV_SEQUENTIAL = 0x2
- MADV_SETMAP = 0xb
- MADV_WILLNEED = 0x3
- MAP_ANON = 0x1000
- MAP_COPY = 0x2
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_HASSEMAPHORE = 0x200
- MAP_INHERIT = 0x80
- MAP_NOCORE = 0x20000
- MAP_NOEXTEND = 0x100
- MAP_NORESERVE = 0x40
- MAP_NOSYNC = 0x800
- MAP_PRIVATE = 0x2
- MAP_RENAME = 0x20
- MAP_SHARED = 0x1
- MAP_SIZEALIGN = 0x40000
- MAP_STACK = 0x400
- MAP_TRYFIXED = 0x10000
- MAP_VPAGETABLE = 0x2000
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MSG_CTRUNC = 0x20
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x80
- MSG_EOF = 0x100
- MSG_EOR = 0x8
- MSG_FBLOCKING = 0x10000
- MSG_FMASK = 0xffff0000
- MSG_FNONBLOCKING = 0x20000
- MSG_NOSIGNAL = 0x400
- MSG_NOTIFICATION = 0x200
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_SYNC = 0x800
- MSG_TRUNC = 0x10
- MSG_WAITALL = 0x40
- MS_ASYNC = 0x1
- MS_INVALIDATE = 0x2
- MS_SYNC = 0x0
- NAME_MAX = 0xff
- NET_RT_DUMP = 0x1
- NET_RT_FLAGS = 0x2
- NET_RT_IFLIST = 0x3
- NET_RT_MAXID = 0x4
- NOFLSH = 0x80000000
- NOTE_ATTRIB = 0x8
- NOTE_CHILD = 0x4
- NOTE_DELETE = 0x1
- NOTE_EXEC = 0x20000000
- NOTE_EXIT = 0x80000000
- NOTE_EXTEND = 0x4
- NOTE_FORK = 0x40000000
- NOTE_LINK = 0x10
- NOTE_LOWAT = 0x1
- NOTE_OOB = 0x2
- NOTE_PCTRLMASK = 0xf0000000
- NOTE_PDATAMASK = 0xfffff
- NOTE_RENAME = 0x20
- NOTE_REVOKE = 0x40
- NOTE_TRACK = 0x1
- NOTE_TRACKERR = 0x2
- NOTE_WRITE = 0x2
- OCRNL = 0x10
- ONLCR = 0x2
- ONLRET = 0x40
- ONOCR = 0x20
- ONOEOT = 0x8
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x8
- O_ASYNC = 0x40
- O_CLOEXEC = 0x20000
- O_CREAT = 0x200
- O_DIRECT = 0x10000
- O_DIRECTORY = 0x8000000
- O_EXCL = 0x800
- O_EXLOCK = 0x20
- O_FAPPEND = 0x100000
- O_FASYNCWRITE = 0x800000
- O_FBLOCKING = 0x40000
- O_FBUFFERED = 0x2000000
- O_FMASK = 0x7fc0000
- O_FNONBLOCKING = 0x80000
- O_FOFFSET = 0x200000
- O_FSYNC = 0x80
- O_FSYNCWRITE = 0x400000
- O_FUNBUFFERED = 0x1000000
- O_MAPONREAD = 0x4000000
- O_NDELAY = 0x4
- O_NOCTTY = 0x8000
- O_NOFOLLOW = 0x100
- O_NONBLOCK = 0x4
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_SHLOCK = 0x10
- O_SYNC = 0x80
- O_TRUNC = 0x400
- O_WRONLY = 0x1
- PARENB = 0x1000
- PARMRK = 0x8
- PARODD = 0x2000
- PENDIN = 0x20000000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- RLIMIT_AS = 0xa
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x8
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = 0x7fffffffffffffff
- RTAX_AUTHOR = 0x6
- RTAX_BRD = 0x7
- RTAX_DST = 0x0
- RTAX_GATEWAY = 0x1
- RTAX_GENMASK = 0x3
- RTAX_IFA = 0x5
- RTAX_IFP = 0x4
- RTAX_MAX = 0xb
- RTAX_MPLS1 = 0x8
- RTAX_MPLS2 = 0x9
- RTAX_MPLS3 = 0xa
- RTAX_NETMASK = 0x2
- RTA_AUTHOR = 0x40
- RTA_BRD = 0x80
- RTA_DST = 0x1
- RTA_GATEWAY = 0x2
- RTA_GENMASK = 0x8
- RTA_IFA = 0x20
- RTA_IFP = 0x10
- RTA_MPLS1 = 0x100
- RTA_MPLS2 = 0x200
- RTA_MPLS3 = 0x400
- RTA_NETMASK = 0x4
- RTF_BLACKHOLE = 0x1000
- RTF_BROADCAST = 0x400000
- RTF_CLONING = 0x100
- RTF_DONE = 0x40
- RTF_DYNAMIC = 0x10
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_LLINFO = 0x400
- RTF_LOCAL = 0x200000
- RTF_MODIFIED = 0x20
- RTF_MPLSOPS = 0x1000000
- RTF_MULTICAST = 0x800000
- RTF_PINNED = 0x100000
- RTF_PRCLONING = 0x10000
- RTF_PROTO1 = 0x8000
- RTF_PROTO2 = 0x4000
- RTF_PROTO3 = 0x40000
- RTF_REJECT = 0x8
- RTF_STATIC = 0x800
- RTF_UP = 0x1
- RTF_WASCLONED = 0x20000
- RTF_XRESOLVE = 0x200
- RTM_ADD = 0x1
- RTM_CHANGE = 0x3
- RTM_DELADDR = 0xd
- RTM_DELETE = 0x2
- RTM_DELMADDR = 0x10
- RTM_GET = 0x4
- RTM_IEEE80211 = 0x12
- RTM_IFANNOUNCE = 0x11
- RTM_IFINFO = 0xe
- RTM_LOCK = 0x8
- RTM_LOSING = 0x5
- RTM_MISS = 0x7
- RTM_NEWADDR = 0xc
- RTM_NEWMADDR = 0xf
- RTM_OLDADD = 0x9
- RTM_OLDDEL = 0xa
- RTM_REDIRECT = 0x6
- RTM_RESOLVE = 0xb
- RTM_RTTUNIT = 0xf4240
- RTM_VERSION = 0x6
- RTV_EXPIRE = 0x4
- RTV_HOPCOUNT = 0x2
- RTV_IWCAPSEGS = 0x400
- RTV_IWMAXSEGS = 0x200
- RTV_MSL = 0x100
- RTV_MTU = 0x1
- RTV_RPIPE = 0x8
- RTV_RTT = 0x40
- RTV_RTTVAR = 0x80
- RTV_SPIPE = 0x10
- RTV_SSTHRESH = 0x20
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- SCM_CREDS = 0x3
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x2
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDMULTI = 0x80206931
- SIOCADDRT = 0x8040720a
- SIOCAIFADDR = 0x8040691a
- SIOCALIFADDR = 0x8118691b
- SIOCATMARK = 0x40047307
- SIOCDELMULTI = 0x80206932
- SIOCDELRT = 0x8040720b
- SIOCDIFADDR = 0x80206919
- SIOCDIFPHYADDR = 0x80206949
- SIOCDLIFADDR = 0x8118691d
- SIOCGDRVSPEC = 0xc028697b
- SIOCGETSGCNT = 0xc0207210
- SIOCGETVIFCNT = 0xc028720f
- SIOCGHIWAT = 0x40047301
- SIOCGIFADDR = 0xc0206921
- SIOCGIFBRDADDR = 0xc0206923
- SIOCGIFCAP = 0xc020691f
- SIOCGIFCONF = 0xc0106924
- SIOCGIFDATA = 0xc0206926
- SIOCGIFDSTADDR = 0xc0206922
- SIOCGIFFLAGS = 0xc0206911
- SIOCGIFGENERIC = 0xc020693a
- SIOCGIFGMEMB = 0xc028698a
- SIOCGIFINDEX = 0xc0206920
- SIOCGIFMEDIA = 0xc0306938
- SIOCGIFMETRIC = 0xc0206917
- SIOCGIFMTU = 0xc0206933
- SIOCGIFNETMASK = 0xc0206925
- SIOCGIFPDSTADDR = 0xc0206948
- SIOCGIFPHYS = 0xc0206935
- SIOCGIFPOLLCPU = 0xc020697e
- SIOCGIFPSRCADDR = 0xc0206947
- SIOCGIFSTATUS = 0xc331693b
- SIOCGIFTSOLEN = 0xc0206980
- SIOCGLIFADDR = 0xc118691c
- SIOCGLIFPHYADDR = 0xc118694b
- SIOCGLOWAT = 0x40047303
- SIOCGPGRP = 0x40047309
- SIOCGPRIVATE_0 = 0xc0206950
- SIOCGPRIVATE_1 = 0xc0206951
- SIOCIFCREATE = 0xc020697a
- SIOCIFCREATE2 = 0xc020697c
- SIOCIFDESTROY = 0x80206979
- SIOCIFGCLONERS = 0xc0106978
- SIOCSDRVSPEC = 0x8028697b
- SIOCSHIWAT = 0x80047300
- SIOCSIFADDR = 0x8020690c
- SIOCSIFBRDADDR = 0x80206913
- SIOCSIFCAP = 0x8020691e
- SIOCSIFDSTADDR = 0x8020690e
- SIOCSIFFLAGS = 0x80206910
- SIOCSIFGENERIC = 0x80206939
- SIOCSIFLLADDR = 0x8020693c
- SIOCSIFMEDIA = 0xc0206937
- SIOCSIFMETRIC = 0x80206918
- SIOCSIFMTU = 0x80206934
- SIOCSIFNAME = 0x80206928
- SIOCSIFNETMASK = 0x80206916
- SIOCSIFPHYADDR = 0x80406946
- SIOCSIFPHYS = 0x80206936
- SIOCSIFPOLLCPU = 0x8020697d
- SIOCSIFTSOLEN = 0x8020697f
- SIOCSLIFPHYADDR = 0x8118694a
- SIOCSLOWAT = 0x80047302
- SIOCSPGRP = 0x80047308
- SOCK_DGRAM = 0x2
- SOCK_MAXADDRLEN = 0xff
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_SOCKET = 0xffff
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x2
- SO_ACCEPTFILTER = 0x1000
- SO_BROADCAST = 0x20
- SO_DEBUG = 0x1
- SO_DONTROUTE = 0x10
- SO_ERROR = 0x1007
- SO_KEEPALIVE = 0x8
- SO_LINGER = 0x80
- SO_NOSIGPIPE = 0x800
- SO_OOBINLINE = 0x100
- SO_RCVBUF = 0x1002
- SO_RCVLOWAT = 0x1004
- SO_RCVTIMEO = 0x1006
- SO_REUSEADDR = 0x4
- SO_REUSEPORT = 0x200
- SO_SNDBUF = 0x1001
- SO_SNDLOWAT = 0x1003
- SO_SNDSPACE = 0x100a
- SO_SNDTIMEO = 0x1005
- SO_TIMESTAMP = 0x400
- SO_TYPE = 0x1008
- SO_USELOOPBACK = 0x40
- TCIFLUSH = 0x1
- TCIOFLUSH = 0x3
- TCOFLUSH = 0x2
- TCP_FASTKEEP = 0x80
- TCP_KEEPCNT = 0x400
- TCP_KEEPIDLE = 0x100
- TCP_KEEPINIT = 0x20
- TCP_KEEPINTVL = 0x200
- TCP_MAXBURST = 0x4
- TCP_MAXHLEN = 0x3c
- TCP_MAXOLEN = 0x28
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_WINSHIFT = 0xe
- TCP_MINMSS = 0x100
- TCP_MIN_WINSHIFT = 0x5
- TCP_MSS = 0x200
- TCP_NODELAY = 0x1
- TCP_NOOPT = 0x8
- TCP_NOPUSH = 0x4
- TCP_SIGNATURE_ENABLE = 0x10
- TCSAFLUSH = 0x2
- TIOCCBRK = 0x2000747a
- TIOCCDTR = 0x20007478
- TIOCCONS = 0x80047462
- TIOCDCDTIMESTAMP = 0x40107458
- TIOCDRAIN = 0x2000745e
- TIOCEXCL = 0x2000740d
- TIOCEXT = 0x80047460
- TIOCFLUSH = 0x80047410
- TIOCGDRAINWAIT = 0x40047456
- TIOCGETA = 0x402c7413
- TIOCGETD = 0x4004741a
- TIOCGPGRP = 0x40047477
- TIOCGSID = 0x40047463
- TIOCGSIZE = 0x40087468
- TIOCGWINSZ = 0x40087468
- TIOCISPTMASTER = 0x20007455
- TIOCMBIC = 0x8004746b
- TIOCMBIS = 0x8004746c
- TIOCMGDTRWAIT = 0x4004745a
- TIOCMGET = 0x4004746a
- TIOCMODG = 0x40047403
- TIOCMODS = 0x80047404
- TIOCMSDTRWAIT = 0x8004745b
- TIOCMSET = 0x8004746d
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x20007471
- TIOCNXCL = 0x2000740e
- TIOCOUTQ = 0x40047473
- TIOCPKT = 0x80047470
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCREMOTE = 0x80047469
- TIOCSBRK = 0x2000747b
- TIOCSCTTY = 0x20007461
- TIOCSDRAINWAIT = 0x80047457
- TIOCSDTR = 0x20007479
- TIOCSETA = 0x802c7414
- TIOCSETAF = 0x802c7416
- TIOCSETAW = 0x802c7415
- TIOCSETD = 0x8004741b
- TIOCSIG = 0x2000745f
- TIOCSPGRP = 0x80047476
- TIOCSSIZE = 0x80087467
- TIOCSTART = 0x2000746e
- TIOCSTAT = 0x20007465
- TIOCSTI = 0x80017472
- TIOCSTOP = 0x2000746f
- TIOCSWINSZ = 0x80087467
- TIOCTIMESTAMP = 0x40107459
- TIOCUCNTL = 0x80047466
- TOSTOP = 0x400000
- VCHECKPT = 0x13
- VDISCARD = 0xf
- VDSUSP = 0xb
- VEOF = 0x0
- VEOL = 0x1
- VEOL2 = 0x2
- VERASE = 0x3
- VERASE2 = 0x7
- VINTR = 0x8
- VKILL = 0x5
- VLNEXT = 0xe
- VMIN = 0x10
- VQUIT = 0x9
- VREPRINT = 0x6
- VSTART = 0xc
- VSTATUS = 0x12
- VSTOP = 0xd
- VSUSP = 0xa
- VTIME = 0x11
- VWERASE = 0x4
- WCONTINUED = 0x4
- WCOREFLAG = 0x80
- WLINUXCLONE = 0x80000000
- WNOHANG = 0x1
- WSTOPPED = 0x7f
- WUNTRACED = 0x2
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x30)
- EADDRNOTAVAIL = syscall.Errno(0x31)
- EAFNOSUPPORT = syscall.Errno(0x2f)
- EAGAIN = syscall.Errno(0x23)
- EALREADY = syscall.Errno(0x25)
- EASYNC = syscall.Errno(0x63)
- EAUTH = syscall.Errno(0x50)
- EBADF = syscall.Errno(0x9)
- EBADMSG = syscall.Errno(0x59)
- EBADRPC = syscall.Errno(0x48)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x55)
- ECHILD = syscall.Errno(0xa)
- ECONNABORTED = syscall.Errno(0x35)
- ECONNREFUSED = syscall.Errno(0x3d)
- ECONNRESET = syscall.Errno(0x36)
- EDEADLK = syscall.Errno(0xb)
- EDESTADDRREQ = syscall.Errno(0x27)
- EDOM = syscall.Errno(0x21)
- EDOOFUS = syscall.Errno(0x58)
- EDQUOT = syscall.Errno(0x45)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EFTYPE = syscall.Errno(0x4f)
- EHOSTDOWN = syscall.Errno(0x40)
- EHOSTUNREACH = syscall.Errno(0x41)
- EIDRM = syscall.Errno(0x52)
- EILSEQ = syscall.Errno(0x56)
- EINPROGRESS = syscall.Errno(0x24)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x38)
- EISDIR = syscall.Errno(0x15)
- ELAST = syscall.Errno(0x63)
- ELOOP = syscall.Errno(0x3e)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x28)
- EMULTIHOP = syscall.Errno(0x5a)
- ENAMETOOLONG = syscall.Errno(0x3f)
- ENEEDAUTH = syscall.Errno(0x51)
- ENETDOWN = syscall.Errno(0x32)
- ENETRESET = syscall.Errno(0x34)
- ENETUNREACH = syscall.Errno(0x33)
- ENFILE = syscall.Errno(0x17)
- ENOATTR = syscall.Errno(0x57)
- ENOBUFS = syscall.Errno(0x37)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOLCK = syscall.Errno(0x4d)
- ENOLINK = syscall.Errno(0x5b)
- ENOMEDIUM = syscall.Errno(0x5d)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x53)
- ENOPROTOOPT = syscall.Errno(0x2a)
- ENOSPC = syscall.Errno(0x1c)
- ENOSYS = syscall.Errno(0x4e)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x39)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x42)
- ENOTSOCK = syscall.Errno(0x26)
- ENOTSUP = syscall.Errno(0x2d)
- ENOTTY = syscall.Errno(0x19)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x2d)
- EOVERFLOW = syscall.Errno(0x54)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x2e)
- EPIPE = syscall.Errno(0x20)
- EPROCLIM = syscall.Errno(0x43)
- EPROCUNAVAIL = syscall.Errno(0x4c)
- EPROGMISMATCH = syscall.Errno(0x4b)
- EPROGUNAVAIL = syscall.Errno(0x4a)
- EPROTO = syscall.Errno(0x5c)
- EPROTONOSUPPORT = syscall.Errno(0x2b)
- EPROTOTYPE = syscall.Errno(0x29)
- ERANGE = syscall.Errno(0x22)
- EREMOTE = syscall.Errno(0x47)
- EROFS = syscall.Errno(0x1e)
- ERPCMISMATCH = syscall.Errno(0x49)
- ESHUTDOWN = syscall.Errno(0x3a)
- ESOCKTNOSUPPORT = syscall.Errno(0x2c)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESTALE = syscall.Errno(0x46)
- ETIMEDOUT = syscall.Errno(0x3c)
- ETOOMANYREFS = syscall.Errno(0x3b)
- ETXTBSY = syscall.Errno(0x1a)
- EUNUSED94 = syscall.Errno(0x5e)
- EUNUSED95 = syscall.Errno(0x5f)
- EUNUSED96 = syscall.Errno(0x60)
- EUNUSED97 = syscall.Errno(0x61)
- EUNUSED98 = syscall.Errno(0x62)
- EUSERS = syscall.Errno(0x44)
- EWOULDBLOCK = syscall.Errno(0x23)
- EXDEV = syscall.Errno(0x12)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0xa)
- SIGCHLD = syscall.Signal(0x14)
- SIGCKPT = syscall.Signal(0x21)
- SIGCKPTEXIT = syscall.Signal(0x22)
- SIGCONT = syscall.Signal(0x13)
- SIGEMT = syscall.Signal(0x7)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINFO = syscall.Signal(0x1d)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x17)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPROF = syscall.Signal(0x1b)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTOP = syscall.Signal(0x11)
- SIGSYS = syscall.Signal(0xc)
- SIGTERM = syscall.Signal(0xf)
- SIGTHR = syscall.Signal(0x20)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x12)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGURG = syscall.Signal(0x10)
- SIGUSR1 = syscall.Signal(0x1e)
- SIGUSR2 = syscall.Signal(0x1f)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "device not configured",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource deadlock avoided",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device busy",
- 17: "file exists",
- 18: "cross-device link",
- 19: "operation not supported by device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "result too large",
- 35: "resource temporarily unavailable",
- 36: "operation now in progress",
- 37: "operation already in progress",
- 38: "socket operation on non-socket",
- 39: "destination address required",
- 40: "message too long",
- 41: "protocol wrong type for socket",
- 42: "protocol not available",
- 43: "protocol not supported",
- 44: "socket type not supported",
- 45: "operation not supported",
- 46: "protocol family not supported",
- 47: "address family not supported by protocol family",
- 48: "address already in use",
- 49: "can't assign requested address",
- 50: "network is down",
- 51: "network is unreachable",
- 52: "network dropped connection on reset",
- 53: "software caused connection abort",
- 54: "connection reset by peer",
- 55: "no buffer space available",
- 56: "socket is already connected",
- 57: "socket is not connected",
- 58: "can't send after socket shutdown",
- 59: "too many references: can't splice",
- 60: "operation timed out",
- 61: "connection refused",
- 62: "too many levels of symbolic links",
- 63: "file name too long",
- 64: "host is down",
- 65: "no route to host",
- 66: "directory not empty",
- 67: "too many processes",
- 68: "too many users",
- 69: "disc quota exceeded",
- 70: "stale NFS file handle",
- 71: "too many levels of remote in path",
- 72: "RPC struct is bad",
- 73: "RPC version wrong",
- 74: "RPC prog. not avail",
- 75: "program version wrong",
- 76: "bad procedure for program",
- 77: "no locks available",
- 78: "function not implemented",
- 79: "inappropriate file type or format",
- 80: "authentication error",
- 81: "need authenticator",
- 82: "identifier removed",
- 83: "no message of desired type",
- 84: "value too large to be stored in data type",
- 85: "operation canceled",
- 86: "illegal byte sequence",
- 87: "attribute not found",
- 88: "programming error",
- 89: "bad message",
- 90: "multihop attempted",
- 91: "link has been severed",
- 92: "protocol error",
- 93: "no medium found",
- 94: "unknown error: 94",
- 95: "unknown error: 95",
- 96: "unknown error: 96",
- 97: "unknown error: 97",
- 98: "unknown error: 98",
- 99: "unknown error: 99",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/BPT trap",
- 6: "abort trap",
- 7: "EMT trap",
- 8: "floating point exception",
- 9: "killed",
- 10: "bus error",
- 11: "segmentation fault",
- 12: "bad system call",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "urgent I/O condition",
- 17: "suspended (signal)",
- 18: "suspended",
- 19: "continued",
- 20: "child exited",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "I/O possible",
- 24: "cputime limit exceeded",
- 25: "filesize limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window size changes",
- 29: "information request",
- 30: "user defined signal 1",
- 31: "user defined signal 2",
- 32: "thread Scheduler",
- 33: "checkPoint",
- 34: "checkPointExit",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go b/newt/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go
deleted file mode 100644
index 7b95751c..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go
+++ /dev/null
@@ -1,1743 +0,0 @@
-// mkerrors.sh -m32
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build 386,freebsd
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -m32 _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_APPLETALK = 0x10
- AF_ARP = 0x23
- AF_ATM = 0x1e
- AF_BLUETOOTH = 0x24
- AF_CCITT = 0xa
- AF_CHAOS = 0x5
- AF_CNT = 0x15
- AF_COIP = 0x14
- AF_DATAKIT = 0x9
- AF_DECnet = 0xc
- AF_DLI = 0xd
- AF_E164 = 0x1a
- AF_ECMA = 0x8
- AF_HYLINK = 0xf
- AF_IEEE80211 = 0x25
- AF_IMPLINK = 0x3
- AF_INET = 0x2
- AF_INET6 = 0x1c
- AF_INET6_SDP = 0x2a
- AF_INET_SDP = 0x28
- AF_IPX = 0x17
- AF_ISDN = 0x1a
- AF_ISO = 0x7
- AF_LAT = 0xe
- AF_LINK = 0x12
- AF_LOCAL = 0x1
- AF_MAX = 0x2a
- AF_NATM = 0x1d
- AF_NETBIOS = 0x6
- AF_NETGRAPH = 0x20
- AF_OSI = 0x7
- AF_PUP = 0x4
- AF_ROUTE = 0x11
- AF_SCLUSTER = 0x22
- AF_SIP = 0x18
- AF_SLOW = 0x21
- AF_SNA = 0xb
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_VENDOR00 = 0x27
- AF_VENDOR01 = 0x29
- AF_VENDOR02 = 0x2b
- AF_VENDOR03 = 0x2d
- AF_VENDOR04 = 0x2f
- AF_VENDOR05 = 0x31
- AF_VENDOR06 = 0x33
- AF_VENDOR07 = 0x35
- AF_VENDOR08 = 0x37
- AF_VENDOR09 = 0x39
- AF_VENDOR10 = 0x3b
- AF_VENDOR11 = 0x3d
- AF_VENDOR12 = 0x3f
- AF_VENDOR13 = 0x41
- AF_VENDOR14 = 0x43
- AF_VENDOR15 = 0x45
- AF_VENDOR16 = 0x47
- AF_VENDOR17 = 0x49
- AF_VENDOR18 = 0x4b
- AF_VENDOR19 = 0x4d
- AF_VENDOR20 = 0x4f
- AF_VENDOR21 = 0x51
- AF_VENDOR22 = 0x53
- AF_VENDOR23 = 0x55
- AF_VENDOR24 = 0x57
- AF_VENDOR25 = 0x59
- AF_VENDOR26 = 0x5b
- AF_VENDOR27 = 0x5d
- AF_VENDOR28 = 0x5f
- AF_VENDOR29 = 0x61
- AF_VENDOR30 = 0x63
- AF_VENDOR31 = 0x65
- AF_VENDOR32 = 0x67
- AF_VENDOR33 = 0x69
- AF_VENDOR34 = 0x6b
- AF_VENDOR35 = 0x6d
- AF_VENDOR36 = 0x6f
- AF_VENDOR37 = 0x71
- AF_VENDOR38 = 0x73
- AF_VENDOR39 = 0x75
- AF_VENDOR40 = 0x77
- AF_VENDOR41 = 0x79
- AF_VENDOR42 = 0x7b
- AF_VENDOR43 = 0x7d
- AF_VENDOR44 = 0x7f
- AF_VENDOR45 = 0x81
- AF_VENDOR46 = 0x83
- AF_VENDOR47 = 0x85
- B0 = 0x0
- B110 = 0x6e
- B115200 = 0x1c200
- B1200 = 0x4b0
- B134 = 0x86
- B14400 = 0x3840
- B150 = 0x96
- B1800 = 0x708
- B19200 = 0x4b00
- B200 = 0xc8
- B230400 = 0x38400
- B2400 = 0x960
- B28800 = 0x7080
- B300 = 0x12c
- B38400 = 0x9600
- B460800 = 0x70800
- B4800 = 0x12c0
- B50 = 0x32
- B57600 = 0xe100
- B600 = 0x258
- B7200 = 0x1c20
- B75 = 0x4b
- B76800 = 0x12c00
- B921600 = 0xe1000
- B9600 = 0x2580
- BIOCFEEDBACK = 0x8004427c
- BIOCFLUSH = 0x20004268
- BIOCGBLEN = 0x40044266
- BIOCGDIRECTION = 0x40044276
- BIOCGDLT = 0x4004426a
- BIOCGDLTLIST = 0xc0084279
- BIOCGETBUFMODE = 0x4004427d
- BIOCGETIF = 0x4020426b
- BIOCGETZMAX = 0x4004427f
- BIOCGHDRCMPLT = 0x40044274
- BIOCGRSIG = 0x40044272
- BIOCGRTIMEOUT = 0x4008426e
- BIOCGSEESENT = 0x40044276
- BIOCGSTATS = 0x4008426f
- BIOCGTSTAMP = 0x40044283
- BIOCIMMEDIATE = 0x80044270
- BIOCLOCK = 0x2000427a
- BIOCPROMISC = 0x20004269
- BIOCROTZBUF = 0x400c4280
- BIOCSBLEN = 0xc0044266
- BIOCSDIRECTION = 0x80044277
- BIOCSDLT = 0x80044278
- BIOCSETBUFMODE = 0x8004427e
- BIOCSETF = 0x80084267
- BIOCSETFNR = 0x80084282
- BIOCSETIF = 0x8020426c
- BIOCSETWF = 0x8008427b
- BIOCSETZBUF = 0x800c4281
- BIOCSHDRCMPLT = 0x80044275
- BIOCSRSIG = 0x80044273
- BIOCSRTIMEOUT = 0x8008426d
- BIOCSSEESENT = 0x80044277
- BIOCSTSTAMP = 0x80044284
- BIOCVERSION = 0x40044271
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALIGNMENT = 0x4
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_BUFMODE_BUFFER = 0x1
- BPF_BUFMODE_ZBUF = 0x2
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXBUFSIZE = 0x80000
- BPF_MAXINSNS = 0x200
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINBUFSIZE = 0x20
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RELEASE = 0x30bb6
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_T_BINTIME = 0x2
- BPF_T_BINTIME_FAST = 0x102
- BPF_T_BINTIME_MONOTONIC = 0x202
- BPF_T_BINTIME_MONOTONIC_FAST = 0x302
- BPF_T_FAST = 0x100
- BPF_T_FLAG_MASK = 0x300
- BPF_T_FORMAT_MASK = 0x3
- BPF_T_MICROTIME = 0x0
- BPF_T_MICROTIME_FAST = 0x100
- BPF_T_MICROTIME_MONOTONIC = 0x200
- BPF_T_MICROTIME_MONOTONIC_FAST = 0x300
- BPF_T_MONOTONIC = 0x200
- BPF_T_MONOTONIC_FAST = 0x300
- BPF_T_NANOTIME = 0x1
- BPF_T_NANOTIME_FAST = 0x101
- BPF_T_NANOTIME_MONOTONIC = 0x201
- BPF_T_NANOTIME_MONOTONIC_FAST = 0x301
- BPF_T_NONE = 0x3
- BPF_T_NORMAL = 0x0
- BPF_W = 0x0
- BPF_X = 0x8
- BRKINT = 0x2
- CFLUSH = 0xf
- CLOCAL = 0x8000
- CLOCK_MONOTONIC = 0x4
- CLOCK_MONOTONIC_FAST = 0xc
- CLOCK_MONOTONIC_PRECISE = 0xb
- CLOCK_PROCESS_CPUTIME_ID = 0xf
- CLOCK_PROF = 0x2
- CLOCK_REALTIME = 0x0
- CLOCK_REALTIME_FAST = 0xa
- CLOCK_REALTIME_PRECISE = 0x9
- CLOCK_SECOND = 0xd
- CLOCK_THREAD_CPUTIME_ID = 0xe
- CLOCK_UPTIME = 0x5
- CLOCK_UPTIME_FAST = 0x8
- CLOCK_UPTIME_PRECISE = 0x7
- CLOCK_VIRTUAL = 0x1
- CREAD = 0x800
- CS5 = 0x0
- CS6 = 0x100
- CS7 = 0x200
- CS8 = 0x300
- CSIZE = 0x300
- CSTART = 0x11
- CSTATUS = 0x14
- CSTOP = 0x13
- CSTOPB = 0x400
- CSUSP = 0x1a
- CTL_MAXNAME = 0x18
- CTL_NET = 0x4
- DLT_A429 = 0xb8
- DLT_A653_ICM = 0xb9
- DLT_AIRONET_HEADER = 0x78
- DLT_AOS = 0xde
- DLT_APPLE_IP_OVER_IEEE1394 = 0x8a
- DLT_ARCNET = 0x7
- DLT_ARCNET_LINUX = 0x81
- DLT_ATM_CLIP = 0x13
- DLT_ATM_RFC1483 = 0xb
- DLT_AURORA = 0x7e
- DLT_AX25 = 0x3
- DLT_AX25_KISS = 0xca
- DLT_BACNET_MS_TP = 0xa5
- DLT_BLUETOOTH_HCI_H4 = 0xbb
- DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9
- DLT_CAN20B = 0xbe
- DLT_CAN_SOCKETCAN = 0xe3
- DLT_CHAOS = 0x5
- DLT_CHDLC = 0x68
- DLT_CISCO_IOS = 0x76
- DLT_C_HDLC = 0x68
- DLT_C_HDLC_WITH_DIR = 0xcd
- DLT_DBUS = 0xe7
- DLT_DECT = 0xdd
- DLT_DOCSIS = 0x8f
- DLT_DVB_CI = 0xeb
- DLT_ECONET = 0x73
- DLT_EN10MB = 0x1
- DLT_EN3MB = 0x2
- DLT_ENC = 0x6d
- DLT_ERF = 0xc5
- DLT_ERF_ETH = 0xaf
- DLT_ERF_POS = 0xb0
- DLT_FC_2 = 0xe0
- DLT_FC_2_WITH_FRAME_DELIMS = 0xe1
- DLT_FDDI = 0xa
- DLT_FLEXRAY = 0xd2
- DLT_FRELAY = 0x6b
- DLT_FRELAY_WITH_DIR = 0xce
- DLT_GCOM_SERIAL = 0xad
- DLT_GCOM_T1E1 = 0xac
- DLT_GPF_F = 0xab
- DLT_GPF_T = 0xaa
- DLT_GPRS_LLC = 0xa9
- DLT_GSMTAP_ABIS = 0xda
- DLT_GSMTAP_UM = 0xd9
- DLT_HHDLC = 0x79
- DLT_IBM_SN = 0x92
- DLT_IBM_SP = 0x91
- DLT_IEEE802 = 0x6
- DLT_IEEE802_11 = 0x69
- DLT_IEEE802_11_RADIO = 0x7f
- DLT_IEEE802_11_RADIO_AVS = 0xa3
- DLT_IEEE802_15_4 = 0xc3
- DLT_IEEE802_15_4_LINUX = 0xbf
- DLT_IEEE802_15_4_NOFCS = 0xe6
- DLT_IEEE802_15_4_NONASK_PHY = 0xd7
- DLT_IEEE802_16_MAC_CPS = 0xbc
- DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1
- DLT_IPFILTER = 0x74
- DLT_IPMB = 0xc7
- DLT_IPMB_LINUX = 0xd1
- DLT_IPNET = 0xe2
- DLT_IPOIB = 0xf2
- DLT_IPV4 = 0xe4
- DLT_IPV6 = 0xe5
- DLT_IP_OVER_FC = 0x7a
- DLT_JUNIPER_ATM1 = 0x89
- DLT_JUNIPER_ATM2 = 0x87
- DLT_JUNIPER_ATM_CEMIC = 0xee
- DLT_JUNIPER_CHDLC = 0xb5
- DLT_JUNIPER_ES = 0x84
- DLT_JUNIPER_ETHER = 0xb2
- DLT_JUNIPER_FIBRECHANNEL = 0xea
- DLT_JUNIPER_FRELAY = 0xb4
- DLT_JUNIPER_GGSN = 0x85
- DLT_JUNIPER_ISM = 0xc2
- DLT_JUNIPER_MFR = 0x86
- DLT_JUNIPER_MLFR = 0x83
- DLT_JUNIPER_MLPPP = 0x82
- DLT_JUNIPER_MONITOR = 0xa4
- DLT_JUNIPER_PIC_PEER = 0xae
- DLT_JUNIPER_PPP = 0xb3
- DLT_JUNIPER_PPPOE = 0xa7
- DLT_JUNIPER_PPPOE_ATM = 0xa8
- DLT_JUNIPER_SERVICES = 0x88
- DLT_JUNIPER_SRX_E2E = 0xe9
- DLT_JUNIPER_ST = 0xc8
- DLT_JUNIPER_VP = 0xb7
- DLT_JUNIPER_VS = 0xe8
- DLT_LAPB_WITH_DIR = 0xcf
- DLT_LAPD = 0xcb
- DLT_LIN = 0xd4
- DLT_LINUX_EVDEV = 0xd8
- DLT_LINUX_IRDA = 0x90
- DLT_LINUX_LAPD = 0xb1
- DLT_LINUX_PPP_WITHDIRECTION = 0xa6
- DLT_LINUX_SLL = 0x71
- DLT_LOOP = 0x6c
- DLT_LTALK = 0x72
- DLT_MATCHING_MAX = 0xf6
- DLT_MATCHING_MIN = 0x68
- DLT_MFR = 0xb6
- DLT_MOST = 0xd3
- DLT_MPEG_2_TS = 0xf3
- DLT_MPLS = 0xdb
- DLT_MTP2 = 0x8c
- DLT_MTP2_WITH_PHDR = 0x8b
- DLT_MTP3 = 0x8d
- DLT_MUX27010 = 0xec
- DLT_NETANALYZER = 0xf0
- DLT_NETANALYZER_TRANSPARENT = 0xf1
- DLT_NFC_LLCP = 0xf5
- DLT_NFLOG = 0xef
- DLT_NG40 = 0xf4
- DLT_NULL = 0x0
- DLT_PCI_EXP = 0x7d
- DLT_PFLOG = 0x75
- DLT_PFSYNC = 0x79
- DLT_PPI = 0xc0
- DLT_PPP = 0x9
- DLT_PPP_BSDOS = 0x10
- DLT_PPP_ETHER = 0x33
- DLT_PPP_PPPD = 0xa6
- DLT_PPP_SERIAL = 0x32
- DLT_PPP_WITH_DIR = 0xcc
- DLT_PPP_WITH_DIRECTION = 0xa6
- DLT_PRISM_HEADER = 0x77
- DLT_PRONET = 0x4
- DLT_RAIF1 = 0xc6
- DLT_RAW = 0xc
- DLT_RIO = 0x7c
- DLT_SCCP = 0x8e
- DLT_SITA = 0xc4
- DLT_SLIP = 0x8
- DLT_SLIP_BSDOS = 0xf
- DLT_STANAG_5066_D_PDU = 0xed
- DLT_SUNATM = 0x7b
- DLT_SYMANTEC_FIREWALL = 0x63
- DLT_TZSP = 0x80
- DLT_USB = 0xba
- DLT_USB_LINUX = 0xbd
- DLT_USB_LINUX_MMAPPED = 0xdc
- DLT_USER0 = 0x93
- DLT_USER1 = 0x94
- DLT_USER10 = 0x9d
- DLT_USER11 = 0x9e
- DLT_USER12 = 0x9f
- DLT_USER13 = 0xa0
- DLT_USER14 = 0xa1
- DLT_USER15 = 0xa2
- DLT_USER2 = 0x95
- DLT_USER3 = 0x96
- DLT_USER4 = 0x97
- DLT_USER5 = 0x98
- DLT_USER6 = 0x99
- DLT_USER7 = 0x9a
- DLT_USER8 = 0x9b
- DLT_USER9 = 0x9c
- DLT_WIHART = 0xdf
- DLT_X2E_SERIAL = 0xd5
- DLT_X2E_XORAYA = 0xd6
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x40
- ECHOE = 0x2
- ECHOK = 0x4
- ECHOKE = 0x1
- ECHONL = 0x10
- ECHOPRT = 0x20
- EVFILT_AIO = -0x3
- EVFILT_FS = -0x9
- EVFILT_LIO = -0xa
- EVFILT_PROC = -0x5
- EVFILT_READ = -0x1
- EVFILT_SIGNAL = -0x6
- EVFILT_SYSCOUNT = 0xb
- EVFILT_TIMER = -0x7
- EVFILT_USER = -0xb
- EVFILT_VNODE = -0x4
- EVFILT_WRITE = -0x2
- EV_ADD = 0x1
- EV_CLEAR = 0x20
- EV_DELETE = 0x2
- EV_DISABLE = 0x8
- EV_DISPATCH = 0x80
- EV_DROP = 0x1000
- EV_ENABLE = 0x4
- EV_EOF = 0x8000
- EV_ERROR = 0x4000
- EV_FLAG1 = 0x2000
- EV_ONESHOT = 0x10
- EV_RECEIPT = 0x40
- EV_SYSFLAGS = 0xf000
- EXTA = 0x4b00
- EXTATTR_NAMESPACE_EMPTY = 0x0
- EXTATTR_NAMESPACE_SYSTEM = 0x2
- EXTATTR_NAMESPACE_USER = 0x1
- EXTB = 0x9600
- EXTPROC = 0x800
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FLUSHO = 0x800000
- F_CANCEL = 0x5
- F_DUP2FD = 0xa
- F_DUP2FD_CLOEXEC = 0x12
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x11
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLK = 0xb
- F_GETOWN = 0x5
- F_OGETLK = 0x7
- F_OK = 0x0
- F_OSETLK = 0x8
- F_OSETLKW = 0x9
- F_RDAHEAD = 0x10
- F_RDLCK = 0x1
- F_READAHEAD = 0xf
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLK = 0xc
- F_SETLKW = 0xd
- F_SETLK_REMOTE = 0xe
- F_SETOWN = 0x6
- F_UNLCK = 0x2
- F_UNLCKSYS = 0x4
- F_WRLCK = 0x3
- HUPCL = 0x4000
- ICANON = 0x100
- ICMP6_FILTER = 0x12
- ICRNL = 0x100
- IEXTEN = 0x400
- IFAN_ARRIVAL = 0x0
- IFAN_DEPARTURE = 0x1
- IFF_ALLMULTI = 0x200
- IFF_ALTPHYS = 0x4000
- IFF_BROADCAST = 0x2
- IFF_CANTCHANGE = 0x218f72
- IFF_CANTCONFIG = 0x10000
- IFF_DEBUG = 0x4
- IFF_DRV_OACTIVE = 0x400
- IFF_DRV_RUNNING = 0x40
- IFF_DYING = 0x200000
- IFF_LINK0 = 0x1000
- IFF_LINK1 = 0x2000
- IFF_LINK2 = 0x4000
- IFF_LOOPBACK = 0x8
- IFF_MONITOR = 0x40000
- IFF_MULTICAST = 0x8000
- IFF_NOARP = 0x80
- IFF_OACTIVE = 0x400
- IFF_POINTOPOINT = 0x10
- IFF_PPROMISC = 0x20000
- IFF_PROMISC = 0x100
- IFF_RENAMING = 0x400000
- IFF_RUNNING = 0x40
- IFF_SIMPLEX = 0x800
- IFF_SMART = 0x20
- IFF_STATICARP = 0x80000
- IFF_UP = 0x1
- IFNAMSIZ = 0x10
- IFT_1822 = 0x2
- IFT_A12MPPSWITCH = 0x82
- IFT_AAL2 = 0xbb
- IFT_AAL5 = 0x31
- IFT_ADSL = 0x5e
- IFT_AFLANE8023 = 0x3b
- IFT_AFLANE8025 = 0x3c
- IFT_ARAP = 0x58
- IFT_ARCNET = 0x23
- IFT_ARCNETPLUS = 0x24
- IFT_ASYNC = 0x54
- IFT_ATM = 0x25
- IFT_ATMDXI = 0x69
- IFT_ATMFUNI = 0x6a
- IFT_ATMIMA = 0x6b
- IFT_ATMLOGICAL = 0x50
- IFT_ATMRADIO = 0xbd
- IFT_ATMSUBINTERFACE = 0x86
- IFT_ATMVCIENDPT = 0xc2
- IFT_ATMVIRTUAL = 0x95
- IFT_BGPPOLICYACCOUNTING = 0xa2
- IFT_BRIDGE = 0xd1
- IFT_BSC = 0x53
- IFT_CARP = 0xf8
- IFT_CCTEMUL = 0x3d
- IFT_CEPT = 0x13
- IFT_CES = 0x85
- IFT_CHANNEL = 0x46
- IFT_CNR = 0x55
- IFT_COFFEE = 0x84
- IFT_COMPOSITELINK = 0x9b
- IFT_DCN = 0x8d
- IFT_DIGITALPOWERLINE = 0x8a
- IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
- IFT_DLSW = 0x4a
- IFT_DOCSCABLEDOWNSTREAM = 0x80
- IFT_DOCSCABLEMACLAYER = 0x7f
- IFT_DOCSCABLEUPSTREAM = 0x81
- IFT_DS0 = 0x51
- IFT_DS0BUNDLE = 0x52
- IFT_DS1FDL = 0xaa
- IFT_DS3 = 0x1e
- IFT_DTM = 0x8c
- IFT_DVBASILN = 0xac
- IFT_DVBASIOUT = 0xad
- IFT_DVBRCCDOWNSTREAM = 0x93
- IFT_DVBRCCMACLAYER = 0x92
- IFT_DVBRCCUPSTREAM = 0x94
- IFT_ENC = 0xf4
- IFT_EON = 0x19
- IFT_EPLRS = 0x57
- IFT_ESCON = 0x49
- IFT_ETHER = 0x6
- IFT_FAITH = 0xf2
- IFT_FAST = 0x7d
- IFT_FASTETHER = 0x3e
- IFT_FASTETHERFX = 0x45
- IFT_FDDI = 0xf
- IFT_FIBRECHANNEL = 0x38
- IFT_FRAMERELAYINTERCONNECT = 0x3a
- IFT_FRAMERELAYMPI = 0x5c
- IFT_FRDLCIENDPT = 0xc1
- IFT_FRELAY = 0x20
- IFT_FRELAYDCE = 0x2c
- IFT_FRF16MFRBUNDLE = 0xa3
- IFT_FRFORWARD = 0x9e
- IFT_G703AT2MB = 0x43
- IFT_G703AT64K = 0x42
- IFT_GIF = 0xf0
- IFT_GIGABITETHERNET = 0x75
- IFT_GR303IDT = 0xb2
- IFT_GR303RDT = 0xb1
- IFT_H323GATEKEEPER = 0xa4
- IFT_H323PROXY = 0xa5
- IFT_HDH1822 = 0x3
- IFT_HDLC = 0x76
- IFT_HDSL2 = 0xa8
- IFT_HIPERLAN2 = 0xb7
- IFT_HIPPI = 0x2f
- IFT_HIPPIINTERFACE = 0x39
- IFT_HOSTPAD = 0x5a
- IFT_HSSI = 0x2e
- IFT_HY = 0xe
- IFT_IBM370PARCHAN = 0x48
- IFT_IDSL = 0x9a
- IFT_IEEE1394 = 0x90
- IFT_IEEE80211 = 0x47
- IFT_IEEE80212 = 0x37
- IFT_IEEE8023ADLAG = 0xa1
- IFT_IFGSN = 0x91
- IFT_IMT = 0xbe
- IFT_INFINIBAND = 0xc7
- IFT_INTERLEAVE = 0x7c
- IFT_IP = 0x7e
- IFT_IPFORWARD = 0x8e
- IFT_IPOVERATM = 0x72
- IFT_IPOVERCDLC = 0x6d
- IFT_IPOVERCLAW = 0x6e
- IFT_IPSWITCH = 0x4e
- IFT_IPXIP = 0xf9
- IFT_ISDN = 0x3f
- IFT_ISDNBASIC = 0x14
- IFT_ISDNPRIMARY = 0x15
- IFT_ISDNS = 0x4b
- IFT_ISDNU = 0x4c
- IFT_ISO88022LLC = 0x29
- IFT_ISO88023 = 0x7
- IFT_ISO88024 = 0x8
- IFT_ISO88025 = 0x9
- IFT_ISO88025CRFPINT = 0x62
- IFT_ISO88025DTR = 0x56
- IFT_ISO88025FIBER = 0x73
- IFT_ISO88026 = 0xa
- IFT_ISUP = 0xb3
- IFT_L2VLAN = 0x87
- IFT_L3IPVLAN = 0x88
- IFT_L3IPXVLAN = 0x89
- IFT_LAPB = 0x10
- IFT_LAPD = 0x4d
- IFT_LAPF = 0x77
- IFT_LOCALTALK = 0x2a
- IFT_LOOP = 0x18
- IFT_MEDIAMAILOVERIP = 0x8b
- IFT_MFSIGLINK = 0xa7
- IFT_MIOX25 = 0x26
- IFT_MODEM = 0x30
- IFT_MPC = 0x71
- IFT_MPLS = 0xa6
- IFT_MPLSTUNNEL = 0x96
- IFT_MSDSL = 0x8f
- IFT_MVL = 0xbf
- IFT_MYRINET = 0x63
- IFT_NFAS = 0xaf
- IFT_NSIP = 0x1b
- IFT_OPTICALCHANNEL = 0xc3
- IFT_OPTICALTRANSPORT = 0xc4
- IFT_OTHER = 0x1
- IFT_P10 = 0xc
- IFT_P80 = 0xd
- IFT_PARA = 0x22
- IFT_PFLOG = 0xf6
- IFT_PFSYNC = 0xf7
- IFT_PLC = 0xae
- IFT_POS = 0xab
- IFT_PPP = 0x17
- IFT_PPPMULTILINKBUNDLE = 0x6c
- IFT_PROPBWAP2MP = 0xb8
- IFT_PROPCNLS = 0x59
- IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
- IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
- IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
- IFT_PROPMUX = 0x36
- IFT_PROPVIRTUAL = 0x35
- IFT_PROPWIRELESSP2P = 0x9d
- IFT_PTPSERIAL = 0x16
- IFT_PVC = 0xf1
- IFT_QLLC = 0x44
- IFT_RADIOMAC = 0xbc
- IFT_RADSL = 0x5f
- IFT_REACHDSL = 0xc0
- IFT_RFC1483 = 0x9f
- IFT_RS232 = 0x21
- IFT_RSRB = 0x4f
- IFT_SDLC = 0x11
- IFT_SDSL = 0x60
- IFT_SHDSL = 0xa9
- IFT_SIP = 0x1f
- IFT_SLIP = 0x1c
- IFT_SMDSDXI = 0x2b
- IFT_SMDSICIP = 0x34
- IFT_SONET = 0x27
- IFT_SONETOVERHEADCHANNEL = 0xb9
- IFT_SONETPATH = 0x32
- IFT_SONETVT = 0x33
- IFT_SRP = 0x97
- IFT_SS7SIGLINK = 0x9c
- IFT_STACKTOSTACK = 0x6f
- IFT_STARLAN = 0xb
- IFT_STF = 0xd7
- IFT_T1 = 0x12
- IFT_TDLC = 0x74
- IFT_TERMPAD = 0x5b
- IFT_TR008 = 0xb0
- IFT_TRANSPHDLC = 0x7b
- IFT_TUNNEL = 0x83
- IFT_ULTRA = 0x1d
- IFT_USB = 0xa0
- IFT_V11 = 0x40
- IFT_V35 = 0x2d
- IFT_V36 = 0x41
- IFT_V37 = 0x78
- IFT_VDSL = 0x61
- IFT_VIRTUALIPADDRESS = 0x70
- IFT_VOICEEM = 0x64
- IFT_VOICEENCAP = 0x67
- IFT_VOICEFXO = 0x65
- IFT_VOICEFXS = 0x66
- IFT_VOICEOVERATM = 0x98
- IFT_VOICEOVERFRAMERELAY = 0x99
- IFT_VOICEOVERIP = 0x68
- IFT_X213 = 0x5d
- IFT_X25 = 0x5
- IFT_X25DDN = 0x4
- IFT_X25HUNTGROUP = 0x7a
- IFT_X25MLP = 0x79
- IFT_X25PLE = 0x28
- IFT_XETHER = 0x1a
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLASSD_HOST = 0xfffffff
- IN_CLASSD_NET = 0xf0000000
- IN_CLASSD_NSHIFT = 0x1c
- IN_LOOPBACKNET = 0x7f
- IN_RFC3021_MASK = 0xfffffffe
- IPPROTO_3PC = 0x22
- IPPROTO_ADFS = 0x44
- IPPROTO_AH = 0x33
- IPPROTO_AHIP = 0x3d
- IPPROTO_APES = 0x63
- IPPROTO_ARGUS = 0xd
- IPPROTO_AX25 = 0x5d
- IPPROTO_BHA = 0x31
- IPPROTO_BLT = 0x1e
- IPPROTO_BRSATMON = 0x4c
- IPPROTO_CARP = 0x70
- IPPROTO_CFTP = 0x3e
- IPPROTO_CHAOS = 0x10
- IPPROTO_CMTP = 0x26
- IPPROTO_CPHB = 0x49
- IPPROTO_CPNX = 0x48
- IPPROTO_DDP = 0x25
- IPPROTO_DGP = 0x56
- IPPROTO_DIVERT = 0x102
- IPPROTO_DONE = 0x101
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_EMCON = 0xe
- IPPROTO_ENCAP = 0x62
- IPPROTO_EON = 0x50
- IPPROTO_ESP = 0x32
- IPPROTO_ETHERIP = 0x61
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GGP = 0x3
- IPPROTO_GMTP = 0x64
- IPPROTO_GRE = 0x2f
- IPPROTO_HELLO = 0x3f
- IPPROTO_HIP = 0x8b
- IPPROTO_HMP = 0x14
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IDPR = 0x23
- IPPROTO_IDRP = 0x2d
- IPPROTO_IGMP = 0x2
- IPPROTO_IGP = 0x55
- IPPROTO_IGRP = 0x58
- IPPROTO_IL = 0x28
- IPPROTO_INLSP = 0x34
- IPPROTO_INP = 0x20
- IPPROTO_IP = 0x0
- IPPROTO_IPCOMP = 0x6c
- IPPROTO_IPCV = 0x47
- IPPROTO_IPEIP = 0x5e
- IPPROTO_IPIP = 0x4
- IPPROTO_IPPC = 0x43
- IPPROTO_IPV4 = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_IRTP = 0x1c
- IPPROTO_KRYPTOLAN = 0x41
- IPPROTO_LARP = 0x5b
- IPPROTO_LEAF1 = 0x19
- IPPROTO_LEAF2 = 0x1a
- IPPROTO_MAX = 0x100
- IPPROTO_MAXID = 0x34
- IPPROTO_MEAS = 0x13
- IPPROTO_MH = 0x87
- IPPROTO_MHRP = 0x30
- IPPROTO_MICP = 0x5f
- IPPROTO_MOBILE = 0x37
- IPPROTO_MPLS = 0x89
- IPPROTO_MTP = 0x5c
- IPPROTO_MUX = 0x12
- IPPROTO_ND = 0x4d
- IPPROTO_NHRP = 0x36
- IPPROTO_NONE = 0x3b
- IPPROTO_NSP = 0x1f
- IPPROTO_NVPII = 0xb
- IPPROTO_OLD_DIVERT = 0xfe
- IPPROTO_OSPFIGP = 0x59
- IPPROTO_PFSYNC = 0xf0
- IPPROTO_PGM = 0x71
- IPPROTO_PIGP = 0x9
- IPPROTO_PIM = 0x67
- IPPROTO_PRM = 0x15
- IPPROTO_PUP = 0xc
- IPPROTO_PVP = 0x4b
- IPPROTO_RAW = 0xff
- IPPROTO_RCCMON = 0xa
- IPPROTO_RDP = 0x1b
- IPPROTO_RESERVED_253 = 0xfd
- IPPROTO_RESERVED_254 = 0xfe
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_RVD = 0x42
- IPPROTO_SATEXPAK = 0x40
- IPPROTO_SATMON = 0x45
- IPPROTO_SCCSP = 0x60
- IPPROTO_SCTP = 0x84
- IPPROTO_SDRP = 0x2a
- IPPROTO_SEND = 0x103
- IPPROTO_SEP = 0x21
- IPPROTO_SHIM6 = 0x8c
- IPPROTO_SKIP = 0x39
- IPPROTO_SPACER = 0x7fff
- IPPROTO_SRPC = 0x5a
- IPPROTO_ST = 0x7
- IPPROTO_SVMTP = 0x52
- IPPROTO_SWIPE = 0x35
- IPPROTO_TCF = 0x57
- IPPROTO_TCP = 0x6
- IPPROTO_TLSP = 0x38
- IPPROTO_TP = 0x1d
- IPPROTO_TPXX = 0x27
- IPPROTO_TRUNK1 = 0x17
- IPPROTO_TRUNK2 = 0x18
- IPPROTO_TTP = 0x54
- IPPROTO_UDP = 0x11
- IPPROTO_UDPLITE = 0x88
- IPPROTO_VINES = 0x53
- IPPROTO_VISA = 0x46
- IPPROTO_VMTP = 0x51
- IPPROTO_WBEXPAK = 0x4f
- IPPROTO_WBMON = 0x4e
- IPPROTO_WSN = 0x4a
- IPPROTO_XNET = 0xf
- IPPROTO_XTP = 0x24
- IPV6_AUTOFLOWLABEL = 0x3b
- IPV6_BINDANY = 0x40
- IPV6_BINDV6ONLY = 0x1b
- IPV6_CHECKSUM = 0x1a
- IPV6_DEFAULT_MULTICAST_HOPS = 0x1
- IPV6_DEFAULT_MULTICAST_LOOP = 0x1
- IPV6_DEFHLIM = 0x40
- IPV6_DONTFRAG = 0x3e
- IPV6_DSTOPTS = 0x32
- IPV6_FAITH = 0x1d
- IPV6_FLOWINFO_MASK = 0xffffff0f
- IPV6_FLOWLABEL_MASK = 0xffff0f00
- IPV6_FRAGTTL = 0x78
- IPV6_FW_ADD = 0x1e
- IPV6_FW_DEL = 0x1f
- IPV6_FW_FLUSH = 0x20
- IPV6_FW_GET = 0x22
- IPV6_FW_ZERO = 0x21
- IPV6_HLIMDEC = 0x1
- IPV6_HOPLIMIT = 0x2f
- IPV6_HOPOPTS = 0x31
- IPV6_IPSEC_POLICY = 0x1c
- IPV6_JOIN_GROUP = 0xc
- IPV6_LEAVE_GROUP = 0xd
- IPV6_MAXHLIM = 0xff
- IPV6_MAXOPTHDR = 0x800
- IPV6_MAXPACKET = 0xffff
- IPV6_MAX_GROUP_SRC_FILTER = 0x200
- IPV6_MAX_MEMBERSHIPS = 0xfff
- IPV6_MAX_SOCK_SRC_FILTER = 0x80
- IPV6_MIN_MEMBERSHIPS = 0x1f
- IPV6_MMTU = 0x500
- IPV6_MSFILTER = 0x4a
- IPV6_MULTICAST_HOPS = 0xa
- IPV6_MULTICAST_IF = 0x9
- IPV6_MULTICAST_LOOP = 0xb
- IPV6_NEXTHOP = 0x30
- IPV6_PATHMTU = 0x2c
- IPV6_PKTINFO = 0x2e
- IPV6_PORTRANGE = 0xe
- IPV6_PORTRANGE_DEFAULT = 0x0
- IPV6_PORTRANGE_HIGH = 0x1
- IPV6_PORTRANGE_LOW = 0x2
- IPV6_PREFER_TEMPADDR = 0x3f
- IPV6_RECVDSTOPTS = 0x28
- IPV6_RECVHOPLIMIT = 0x25
- IPV6_RECVHOPOPTS = 0x27
- IPV6_RECVPATHMTU = 0x2b
- IPV6_RECVPKTINFO = 0x24
- IPV6_RECVRTHDR = 0x26
- IPV6_RECVTCLASS = 0x39
- IPV6_RTHDR = 0x33
- IPV6_RTHDRDSTOPTS = 0x23
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_SOCKOPT_RESERVED1 = 0x3
- IPV6_TCLASS = 0x3d
- IPV6_UNICAST_HOPS = 0x4
- IPV6_USE_MIN_MTU = 0x2a
- IPV6_V6ONLY = 0x1b
- IPV6_VERSION = 0x60
- IPV6_VERSION_MASK = 0xf0
- IP_ADD_MEMBERSHIP = 0xc
- IP_ADD_SOURCE_MEMBERSHIP = 0x46
- IP_BINDANY = 0x18
- IP_BLOCK_SOURCE = 0x48
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DONTFRAG = 0x43
- IP_DROP_MEMBERSHIP = 0xd
- IP_DROP_SOURCE_MEMBERSHIP = 0x47
- IP_DUMMYNET3 = 0x31
- IP_DUMMYNET_CONFIGURE = 0x3c
- IP_DUMMYNET_DEL = 0x3d
- IP_DUMMYNET_FLUSH = 0x3e
- IP_DUMMYNET_GET = 0x40
- IP_FAITH = 0x16
- IP_FW3 = 0x30
- IP_FW_ADD = 0x32
- IP_FW_DEL = 0x33
- IP_FW_FLUSH = 0x34
- IP_FW_GET = 0x36
- IP_FW_NAT_CFG = 0x38
- IP_FW_NAT_DEL = 0x39
- IP_FW_NAT_GET_CONFIG = 0x3a
- IP_FW_NAT_GET_LOG = 0x3b
- IP_FW_RESETLOG = 0x37
- IP_FW_TABLE_ADD = 0x28
- IP_FW_TABLE_DEL = 0x29
- IP_FW_TABLE_FLUSH = 0x2a
- IP_FW_TABLE_GETSIZE = 0x2b
- IP_FW_TABLE_LIST = 0x2c
- IP_FW_ZERO = 0x35
- IP_HDRINCL = 0x2
- IP_IPSEC_POLICY = 0x15
- IP_MAXPACKET = 0xffff
- IP_MAX_GROUP_SRC_FILTER = 0x200
- IP_MAX_MEMBERSHIPS = 0xfff
- IP_MAX_SOCK_MUTE_FILTER = 0x80
- IP_MAX_SOCK_SRC_FILTER = 0x80
- IP_MAX_SOURCE_FILTER = 0x400
- IP_MF = 0x2000
- IP_MINTTL = 0x42
- IP_MIN_MEMBERSHIPS = 0x1f
- IP_MSFILTER = 0x4a
- IP_MSS = 0x240
- IP_MULTICAST_IF = 0x9
- IP_MULTICAST_LOOP = 0xb
- IP_MULTICAST_TTL = 0xa
- IP_MULTICAST_VIF = 0xe
- IP_OFFMASK = 0x1fff
- IP_ONESBCAST = 0x17
- IP_OPTIONS = 0x1
- IP_PORTRANGE = 0x13
- IP_PORTRANGE_DEFAULT = 0x0
- IP_PORTRANGE_HIGH = 0x1
- IP_PORTRANGE_LOW = 0x2
- IP_RECVDSTADDR = 0x7
- IP_RECVIF = 0x14
- IP_RECVOPTS = 0x5
- IP_RECVRETOPTS = 0x6
- IP_RECVTOS = 0x44
- IP_RECVTTL = 0x41
- IP_RETOPTS = 0x8
- IP_RF = 0x8000
- IP_RSVP_OFF = 0x10
- IP_RSVP_ON = 0xf
- IP_RSVP_VIF_OFF = 0x12
- IP_RSVP_VIF_ON = 0x11
- IP_SENDSRCADDR = 0x7
- IP_TOS = 0x3
- IP_TTL = 0x4
- IP_UNBLOCK_SOURCE = 0x49
- ISIG = 0x80
- ISTRIP = 0x20
- IXANY = 0x800
- IXOFF = 0x400
- IXON = 0x200
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_AUTOSYNC = 0x7
- MADV_CORE = 0x9
- MADV_DONTNEED = 0x4
- MADV_FREE = 0x5
- MADV_NOCORE = 0x8
- MADV_NORMAL = 0x0
- MADV_NOSYNC = 0x6
- MADV_PROTECT = 0xa
- MADV_RANDOM = 0x1
- MADV_SEQUENTIAL = 0x2
- MADV_WILLNEED = 0x3
- MAP_ALIGNED_SUPER = 0x1000000
- MAP_ALIGNMENT_MASK = -0x1000000
- MAP_ALIGNMENT_SHIFT = 0x18
- MAP_ANON = 0x1000
- MAP_ANONYMOUS = 0x1000
- MAP_COPY = 0x2
- MAP_EXCL = 0x4000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_HASSEMAPHORE = 0x200
- MAP_NOCORE = 0x20000
- MAP_NORESERVE = 0x40
- MAP_NOSYNC = 0x800
- MAP_PREFAULT_READ = 0x40000
- MAP_PRIVATE = 0x2
- MAP_RENAME = 0x20
- MAP_RESERVED0080 = 0x80
- MAP_RESERVED0100 = 0x100
- MAP_SHARED = 0x1
- MAP_STACK = 0x400
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MSG_CMSG_CLOEXEC = 0x40000
- MSG_COMPAT = 0x8000
- MSG_CTRUNC = 0x20
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x80
- MSG_EOF = 0x100
- MSG_EOR = 0x8
- MSG_NBIO = 0x4000
- MSG_NOSIGNAL = 0x20000
- MSG_NOTIFICATION = 0x2000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_TRUNC = 0x10
- MSG_WAITALL = 0x40
- MS_ASYNC = 0x1
- MS_INVALIDATE = 0x2
- MS_SYNC = 0x0
- NAME_MAX = 0xff
- NET_RT_DUMP = 0x1
- NET_RT_FLAGS = 0x2
- NET_RT_IFLIST = 0x3
- NET_RT_IFLISTL = 0x5
- NET_RT_IFMALIST = 0x4
- NET_RT_MAXID = 0x6
- NOFLSH = 0x80000000
- NOTE_ATTRIB = 0x8
- NOTE_CHILD = 0x4
- NOTE_DELETE = 0x1
- NOTE_EXEC = 0x20000000
- NOTE_EXIT = 0x80000000
- NOTE_EXTEND = 0x4
- NOTE_FFAND = 0x40000000
- NOTE_FFCOPY = 0xc0000000
- NOTE_FFCTRLMASK = 0xc0000000
- NOTE_FFLAGSMASK = 0xffffff
- NOTE_FFNOP = 0x0
- NOTE_FFOR = 0x80000000
- NOTE_FORK = 0x40000000
- NOTE_LINK = 0x10
- NOTE_LOWAT = 0x1
- NOTE_PCTRLMASK = 0xf0000000
- NOTE_PDATAMASK = 0xfffff
- NOTE_RENAME = 0x20
- NOTE_REVOKE = 0x40
- NOTE_TRACK = 0x1
- NOTE_TRACKERR = 0x2
- NOTE_TRIGGER = 0x1000000
- NOTE_WRITE = 0x2
- OCRNL = 0x10
- ONLCR = 0x2
- ONLRET = 0x40
- ONOCR = 0x20
- ONOEOT = 0x8
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x8
- O_ASYNC = 0x40
- O_CLOEXEC = 0x100000
- O_CREAT = 0x200
- O_DIRECT = 0x10000
- O_DIRECTORY = 0x20000
- O_EXCL = 0x800
- O_EXEC = 0x40000
- O_EXLOCK = 0x20
- O_FSYNC = 0x80
- O_NDELAY = 0x4
- O_NOCTTY = 0x8000
- O_NOFOLLOW = 0x100
- O_NONBLOCK = 0x4
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_SHLOCK = 0x10
- O_SYNC = 0x80
- O_TRUNC = 0x400
- O_TTY_INIT = 0x80000
- O_WRONLY = 0x1
- PARENB = 0x1000
- PARMRK = 0x8
- PARODD = 0x2000
- PENDIN = 0x20000000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- RLIMIT_AS = 0xa
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x8
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = 0x7fffffffffffffff
- RTAX_AUTHOR = 0x6
- RTAX_BRD = 0x7
- RTAX_DST = 0x0
- RTAX_GATEWAY = 0x1
- RTAX_GENMASK = 0x3
- RTAX_IFA = 0x5
- RTAX_IFP = 0x4
- RTAX_MAX = 0x8
- RTAX_NETMASK = 0x2
- RTA_AUTHOR = 0x40
- RTA_BRD = 0x80
- RTA_DST = 0x1
- RTA_GATEWAY = 0x2
- RTA_GENMASK = 0x8
- RTA_IFA = 0x20
- RTA_IFP = 0x10
- RTA_NETMASK = 0x4
- RTF_BLACKHOLE = 0x1000
- RTF_BROADCAST = 0x400000
- RTF_DONE = 0x40
- RTF_DYNAMIC = 0x10
- RTF_FMASK = 0x1004d808
- RTF_GATEWAY = 0x2
- RTF_GWFLAG_COMPAT = 0x80000000
- RTF_HOST = 0x4
- RTF_LLDATA = 0x400
- RTF_LLINFO = 0x400
- RTF_LOCAL = 0x200000
- RTF_MODIFIED = 0x20
- RTF_MULTICAST = 0x800000
- RTF_PINNED = 0x100000
- RTF_PRCLONING = 0x10000
- RTF_PROTO1 = 0x8000
- RTF_PROTO2 = 0x4000
- RTF_PROTO3 = 0x40000
- RTF_REJECT = 0x8
- RTF_RNH_LOCKED = 0x40000000
- RTF_STATIC = 0x800
- RTF_STICKY = 0x10000000
- RTF_UP = 0x1
- RTF_XRESOLVE = 0x200
- RTM_ADD = 0x1
- RTM_CHANGE = 0x3
- RTM_DELADDR = 0xd
- RTM_DELETE = 0x2
- RTM_DELMADDR = 0x10
- RTM_GET = 0x4
- RTM_IEEE80211 = 0x12
- RTM_IFANNOUNCE = 0x11
- RTM_IFINFO = 0xe
- RTM_LOCK = 0x8
- RTM_LOSING = 0x5
- RTM_MISS = 0x7
- RTM_NEWADDR = 0xc
- RTM_NEWMADDR = 0xf
- RTM_OLDADD = 0x9
- RTM_OLDDEL = 0xa
- RTM_REDIRECT = 0x6
- RTM_RESOLVE = 0xb
- RTM_RTTUNIT = 0xf4240
- RTM_VERSION = 0x5
- RTV_EXPIRE = 0x4
- RTV_HOPCOUNT = 0x2
- RTV_MTU = 0x1
- RTV_RPIPE = 0x8
- RTV_RTT = 0x40
- RTV_RTTVAR = 0x80
- RTV_SPIPE = 0x10
- RTV_SSTHRESH = 0x20
- RTV_WEIGHT = 0x100
- RT_ALL_FIBS = -0x1
- RT_CACHING_CONTEXT = 0x1
- RT_DEFAULT_FIB = 0x0
- RT_NORTREF = 0x2
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- RUSAGE_THREAD = 0x1
- SCM_BINTIME = 0x4
- SCM_CREDS = 0x3
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x2
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDMULTI = 0x80206931
- SIOCADDRT = 0x8030720a
- SIOCAIFADDR = 0x8040691a
- SIOCAIFGROUP = 0x80246987
- SIOCALIFADDR = 0x8118691b
- SIOCATMARK = 0x40047307
- SIOCDELMULTI = 0x80206932
- SIOCDELRT = 0x8030720b
- SIOCDIFADDR = 0x80206919
- SIOCDIFGROUP = 0x80246989
- SIOCDIFPHYADDR = 0x80206949
- SIOCDLIFADDR = 0x8118691d
- SIOCGDRVSPEC = 0xc01c697b
- SIOCGETSGCNT = 0xc0147210
- SIOCGETVIFCNT = 0xc014720f
- SIOCGHIWAT = 0x40047301
- SIOCGIFADDR = 0xc0206921
- SIOCGIFBRDADDR = 0xc0206923
- SIOCGIFCAP = 0xc020691f
- SIOCGIFCONF = 0xc0086924
- SIOCGIFDESCR = 0xc020692a
- SIOCGIFDSTADDR = 0xc0206922
- SIOCGIFFIB = 0xc020695c
- SIOCGIFFLAGS = 0xc0206911
- SIOCGIFGENERIC = 0xc020693a
- SIOCGIFGMEMB = 0xc024698a
- SIOCGIFGROUP = 0xc0246988
- SIOCGIFINDEX = 0xc0206920
- SIOCGIFMAC = 0xc0206926
- SIOCGIFMEDIA = 0xc0286938
- SIOCGIFMETRIC = 0xc0206917
- SIOCGIFMTU = 0xc0206933
- SIOCGIFNETMASK = 0xc0206925
- SIOCGIFPDSTADDR = 0xc0206948
- SIOCGIFPHYS = 0xc0206935
- SIOCGIFPSRCADDR = 0xc0206947
- SIOCGIFSTATUS = 0xc331693b
- SIOCGLIFADDR = 0xc118691c
- SIOCGLIFPHYADDR = 0xc118694b
- SIOCGLOWAT = 0x40047303
- SIOCGPGRP = 0x40047309
- SIOCGPRIVATE_0 = 0xc0206950
- SIOCGPRIVATE_1 = 0xc0206951
- SIOCIFCREATE = 0xc020697a
- SIOCIFCREATE2 = 0xc020697c
- SIOCIFDESTROY = 0x80206979
- SIOCIFGCLONERS = 0xc00c6978
- SIOCSDRVSPEC = 0x801c697b
- SIOCSHIWAT = 0x80047300
- SIOCSIFADDR = 0x8020690c
- SIOCSIFBRDADDR = 0x80206913
- SIOCSIFCAP = 0x8020691e
- SIOCSIFDESCR = 0x80206929
- SIOCSIFDSTADDR = 0x8020690e
- SIOCSIFFIB = 0x8020695d
- SIOCSIFFLAGS = 0x80206910
- SIOCSIFGENERIC = 0x80206939
- SIOCSIFLLADDR = 0x8020693c
- SIOCSIFMAC = 0x80206927
- SIOCSIFMEDIA = 0xc0206937
- SIOCSIFMETRIC = 0x80206918
- SIOCSIFMTU = 0x80206934
- SIOCSIFNAME = 0x80206928
- SIOCSIFNETMASK = 0x80206916
- SIOCSIFPHYADDR = 0x80406946
- SIOCSIFPHYS = 0x80206936
- SIOCSIFRVNET = 0xc020695b
- SIOCSIFVNET = 0xc020695a
- SIOCSLIFPHYADDR = 0x8118694a
- SIOCSLOWAT = 0x80047302
- SIOCSPGRP = 0x80047308
- SOCK_CLOEXEC = 0x10000000
- SOCK_DGRAM = 0x2
- SOCK_MAXADDRLEN = 0xff
- SOCK_NONBLOCK = 0x20000000
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_SOCKET = 0xffff
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x2
- SO_ACCEPTFILTER = 0x1000
- SO_BINTIME = 0x2000
- SO_BROADCAST = 0x20
- SO_DEBUG = 0x1
- SO_DONTROUTE = 0x10
- SO_ERROR = 0x1007
- SO_KEEPALIVE = 0x8
- SO_LABEL = 0x1009
- SO_LINGER = 0x80
- SO_LISTENINCQLEN = 0x1013
- SO_LISTENQLEN = 0x1012
- SO_LISTENQLIMIT = 0x1011
- SO_NOSIGPIPE = 0x800
- SO_NO_DDP = 0x8000
- SO_NO_OFFLOAD = 0x4000
- SO_OOBINLINE = 0x100
- SO_PEERLABEL = 0x1010
- SO_PROTOCOL = 0x1016
- SO_PROTOTYPE = 0x1016
- SO_RCVBUF = 0x1002
- SO_RCVLOWAT = 0x1004
- SO_RCVTIMEO = 0x1006
- SO_REUSEADDR = 0x4
- SO_REUSEPORT = 0x200
- SO_SETFIB = 0x1014
- SO_SNDBUF = 0x1001
- SO_SNDLOWAT = 0x1003
- SO_SNDTIMEO = 0x1005
- SO_TIMESTAMP = 0x400
- SO_TYPE = 0x1008
- SO_USELOOPBACK = 0x40
- SO_USER_COOKIE = 0x1015
- SO_VENDOR = 0x80000000
- TCIFLUSH = 0x1
- TCIOFLUSH = 0x3
- TCOFLUSH = 0x2
- TCP_CA_NAME_MAX = 0x10
- TCP_CONGESTION = 0x40
- TCP_INFO = 0x20
- TCP_KEEPCNT = 0x400
- TCP_KEEPIDLE = 0x100
- TCP_KEEPINIT = 0x80
- TCP_KEEPINTVL = 0x200
- TCP_MAXBURST = 0x4
- TCP_MAXHLEN = 0x3c
- TCP_MAXOLEN = 0x28
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_SACK = 0x4
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0x10
- TCP_MINMSS = 0xd8
- TCP_MSS = 0x218
- TCP_NODELAY = 0x1
- TCP_NOOPT = 0x8
- TCP_NOPUSH = 0x4
- TCP_VENDOR = 0x80000000
- TCSAFLUSH = 0x2
- TIOCCBRK = 0x2000747a
- TIOCCDTR = 0x20007478
- TIOCCONS = 0x80047462
- TIOCDRAIN = 0x2000745e
- TIOCEXCL = 0x2000740d
- TIOCEXT = 0x80047460
- TIOCFLUSH = 0x80047410
- TIOCGDRAINWAIT = 0x40047456
- TIOCGETA = 0x402c7413
- TIOCGETD = 0x4004741a
- TIOCGPGRP = 0x40047477
- TIOCGPTN = 0x4004740f
- TIOCGSID = 0x40047463
- TIOCGWINSZ = 0x40087468
- TIOCMBIC = 0x8004746b
- TIOCMBIS = 0x8004746c
- TIOCMGDTRWAIT = 0x4004745a
- TIOCMGET = 0x4004746a
- TIOCMSDTRWAIT = 0x8004745b
- TIOCMSET = 0x8004746d
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DCD = 0x40
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x20007471
- TIOCNXCL = 0x2000740e
- TIOCOUTQ = 0x40047473
- TIOCPKT = 0x80047470
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCPTMASTER = 0x2000741c
- TIOCSBRK = 0x2000747b
- TIOCSCTTY = 0x20007461
- TIOCSDRAINWAIT = 0x80047457
- TIOCSDTR = 0x20007479
- TIOCSETA = 0x802c7414
- TIOCSETAF = 0x802c7416
- TIOCSETAW = 0x802c7415
- TIOCSETD = 0x8004741b
- TIOCSIG = 0x2004745f
- TIOCSPGRP = 0x80047476
- TIOCSTART = 0x2000746e
- TIOCSTAT = 0x20007465
- TIOCSTI = 0x80017472
- TIOCSTOP = 0x2000746f
- TIOCSWINSZ = 0x80087467
- TIOCTIMESTAMP = 0x40087459
- TIOCUCNTL = 0x80047466
- TOSTOP = 0x400000
- VDISCARD = 0xf
- VDSUSP = 0xb
- VEOF = 0x0
- VEOL = 0x1
- VEOL2 = 0x2
- VERASE = 0x3
- VERASE2 = 0x7
- VINTR = 0x8
- VKILL = 0x5
- VLNEXT = 0xe
- VMIN = 0x10
- VQUIT = 0x9
- VREPRINT = 0x6
- VSTART = 0xc
- VSTATUS = 0x12
- VSTOP = 0xd
- VSUSP = 0xa
- VTIME = 0x11
- VWERASE = 0x4
- WCONTINUED = 0x4
- WCOREFLAG = 0x80
- WEXITED = 0x10
- WLINUXCLONE = 0x80000000
- WNOHANG = 0x1
- WNOWAIT = 0x8
- WSTOPPED = 0x2
- WTRAPPED = 0x20
- WUNTRACED = 0x2
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x30)
- EADDRNOTAVAIL = syscall.Errno(0x31)
- EAFNOSUPPORT = syscall.Errno(0x2f)
- EAGAIN = syscall.Errno(0x23)
- EALREADY = syscall.Errno(0x25)
- EAUTH = syscall.Errno(0x50)
- EBADF = syscall.Errno(0x9)
- EBADMSG = syscall.Errno(0x59)
- EBADRPC = syscall.Errno(0x48)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x55)
- ECAPMODE = syscall.Errno(0x5e)
- ECHILD = syscall.Errno(0xa)
- ECONNABORTED = syscall.Errno(0x35)
- ECONNREFUSED = syscall.Errno(0x3d)
- ECONNRESET = syscall.Errno(0x36)
- EDEADLK = syscall.Errno(0xb)
- EDESTADDRREQ = syscall.Errno(0x27)
- EDOM = syscall.Errno(0x21)
- EDOOFUS = syscall.Errno(0x58)
- EDQUOT = syscall.Errno(0x45)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EFTYPE = syscall.Errno(0x4f)
- EHOSTDOWN = syscall.Errno(0x40)
- EHOSTUNREACH = syscall.Errno(0x41)
- EIDRM = syscall.Errno(0x52)
- EILSEQ = syscall.Errno(0x56)
- EINPROGRESS = syscall.Errno(0x24)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x38)
- EISDIR = syscall.Errno(0x15)
- ELAST = syscall.Errno(0x60)
- ELOOP = syscall.Errno(0x3e)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x28)
- EMULTIHOP = syscall.Errno(0x5a)
- ENAMETOOLONG = syscall.Errno(0x3f)
- ENEEDAUTH = syscall.Errno(0x51)
- ENETDOWN = syscall.Errno(0x32)
- ENETRESET = syscall.Errno(0x34)
- ENETUNREACH = syscall.Errno(0x33)
- ENFILE = syscall.Errno(0x17)
- ENOATTR = syscall.Errno(0x57)
- ENOBUFS = syscall.Errno(0x37)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOLCK = syscall.Errno(0x4d)
- ENOLINK = syscall.Errno(0x5b)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x53)
- ENOPROTOOPT = syscall.Errno(0x2a)
- ENOSPC = syscall.Errno(0x1c)
- ENOSYS = syscall.Errno(0x4e)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCAPABLE = syscall.Errno(0x5d)
- ENOTCONN = syscall.Errno(0x39)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x42)
- ENOTRECOVERABLE = syscall.Errno(0x5f)
- ENOTSOCK = syscall.Errno(0x26)
- ENOTSUP = syscall.Errno(0x2d)
- ENOTTY = syscall.Errno(0x19)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x2d)
- EOVERFLOW = syscall.Errno(0x54)
- EOWNERDEAD = syscall.Errno(0x60)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x2e)
- EPIPE = syscall.Errno(0x20)
- EPROCLIM = syscall.Errno(0x43)
- EPROCUNAVAIL = syscall.Errno(0x4c)
- EPROGMISMATCH = syscall.Errno(0x4b)
- EPROGUNAVAIL = syscall.Errno(0x4a)
- EPROTO = syscall.Errno(0x5c)
- EPROTONOSUPPORT = syscall.Errno(0x2b)
- EPROTOTYPE = syscall.Errno(0x29)
- ERANGE = syscall.Errno(0x22)
- EREMOTE = syscall.Errno(0x47)
- EROFS = syscall.Errno(0x1e)
- ERPCMISMATCH = syscall.Errno(0x49)
- ESHUTDOWN = syscall.Errno(0x3a)
- ESOCKTNOSUPPORT = syscall.Errno(0x2c)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESTALE = syscall.Errno(0x46)
- ETIMEDOUT = syscall.Errno(0x3c)
- ETOOMANYREFS = syscall.Errno(0x3b)
- ETXTBSY = syscall.Errno(0x1a)
- EUSERS = syscall.Errno(0x44)
- EWOULDBLOCK = syscall.Errno(0x23)
- EXDEV = syscall.Errno(0x12)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0xa)
- SIGCHLD = syscall.Signal(0x14)
- SIGCONT = syscall.Signal(0x13)
- SIGEMT = syscall.Signal(0x7)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINFO = syscall.Signal(0x1d)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x17)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGLIBRT = syscall.Signal(0x21)
- SIGLWP = syscall.Signal(0x20)
- SIGPIPE = syscall.Signal(0xd)
- SIGPROF = syscall.Signal(0x1b)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTOP = syscall.Signal(0x11)
- SIGSYS = syscall.Signal(0xc)
- SIGTERM = syscall.Signal(0xf)
- SIGTHR = syscall.Signal(0x20)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x12)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGURG = syscall.Signal(0x10)
- SIGUSR1 = syscall.Signal(0x1e)
- SIGUSR2 = syscall.Signal(0x1f)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "device not configured",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource deadlock avoided",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device busy",
- 17: "file exists",
- 18: "cross-device link",
- 19: "operation not supported by device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "result too large",
- 35: "resource temporarily unavailable",
- 36: "operation now in progress",
- 37: "operation already in progress",
- 38: "socket operation on non-socket",
- 39: "destination address required",
- 40: "message too long",
- 41: "protocol wrong type for socket",
- 42: "protocol not available",
- 43: "protocol not supported",
- 44: "socket type not supported",
- 45: "operation not supported",
- 46: "protocol family not supported",
- 47: "address family not supported by protocol family",
- 48: "address already in use",
- 49: "can't assign requested address",
- 50: "network is down",
- 51: "network is unreachable",
- 52: "network dropped connection on reset",
- 53: "software caused connection abort",
- 54: "connection reset by peer",
- 55: "no buffer space available",
- 56: "socket is already connected",
- 57: "socket is not connected",
- 58: "can't send after socket shutdown",
- 59: "too many references: can't splice",
- 60: "operation timed out",
- 61: "connection refused",
- 62: "too many levels of symbolic links",
- 63: "file name too long",
- 64: "host is down",
- 65: "no route to host",
- 66: "directory not empty",
- 67: "too many processes",
- 68: "too many users",
- 69: "disc quota exceeded",
- 70: "stale NFS file handle",
- 71: "too many levels of remote in path",
- 72: "RPC struct is bad",
- 73: "RPC version wrong",
- 74: "RPC prog. not avail",
- 75: "program version wrong",
- 76: "bad procedure for program",
- 77: "no locks available",
- 78: "function not implemented",
- 79: "inappropriate file type or format",
- 80: "authentication error",
- 81: "need authenticator",
- 82: "identifier removed",
- 83: "no message of desired type",
- 84: "value too large to be stored in data type",
- 85: "operation canceled",
- 86: "illegal byte sequence",
- 87: "attribute not found",
- 88: "programming error",
- 89: "bad message",
- 90: "multihop attempted",
- 91: "link has been severed",
- 92: "protocol error",
- 93: "capabilities insufficient",
- 94: "not permitted in capability mode",
- 95: "state not recoverable",
- 96: "previous owner died",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/BPT trap",
- 6: "abort trap",
- 7: "EMT trap",
- 8: "floating point exception",
- 9: "killed",
- 10: "bus error",
- 11: "segmentation fault",
- 12: "bad system call",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "urgent I/O condition",
- 17: "suspended (signal)",
- 18: "suspended",
- 19: "continued",
- 20: "child exited",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "I/O possible",
- 24: "cputime limit exceeded",
- 25: "filesize limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window size changes",
- 29: "information request",
- 30: "user defined signal 1",
- 31: "user defined signal 2",
- 32: "unknown signal",
- 33: "unknown signal",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go b/newt/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go
deleted file mode 100644
index e48e7799..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go
+++ /dev/null
@@ -1,1748 +0,0 @@
-// mkerrors.sh -m64
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build amd64,freebsd
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -m64 _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_APPLETALK = 0x10
- AF_ARP = 0x23
- AF_ATM = 0x1e
- AF_BLUETOOTH = 0x24
- AF_CCITT = 0xa
- AF_CHAOS = 0x5
- AF_CNT = 0x15
- AF_COIP = 0x14
- AF_DATAKIT = 0x9
- AF_DECnet = 0xc
- AF_DLI = 0xd
- AF_E164 = 0x1a
- AF_ECMA = 0x8
- AF_HYLINK = 0xf
- AF_IEEE80211 = 0x25
- AF_IMPLINK = 0x3
- AF_INET = 0x2
- AF_INET6 = 0x1c
- AF_INET6_SDP = 0x2a
- AF_INET_SDP = 0x28
- AF_IPX = 0x17
- AF_ISDN = 0x1a
- AF_ISO = 0x7
- AF_LAT = 0xe
- AF_LINK = 0x12
- AF_LOCAL = 0x1
- AF_MAX = 0x2a
- AF_NATM = 0x1d
- AF_NETBIOS = 0x6
- AF_NETGRAPH = 0x20
- AF_OSI = 0x7
- AF_PUP = 0x4
- AF_ROUTE = 0x11
- AF_SCLUSTER = 0x22
- AF_SIP = 0x18
- AF_SLOW = 0x21
- AF_SNA = 0xb
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_VENDOR00 = 0x27
- AF_VENDOR01 = 0x29
- AF_VENDOR02 = 0x2b
- AF_VENDOR03 = 0x2d
- AF_VENDOR04 = 0x2f
- AF_VENDOR05 = 0x31
- AF_VENDOR06 = 0x33
- AF_VENDOR07 = 0x35
- AF_VENDOR08 = 0x37
- AF_VENDOR09 = 0x39
- AF_VENDOR10 = 0x3b
- AF_VENDOR11 = 0x3d
- AF_VENDOR12 = 0x3f
- AF_VENDOR13 = 0x41
- AF_VENDOR14 = 0x43
- AF_VENDOR15 = 0x45
- AF_VENDOR16 = 0x47
- AF_VENDOR17 = 0x49
- AF_VENDOR18 = 0x4b
- AF_VENDOR19 = 0x4d
- AF_VENDOR20 = 0x4f
- AF_VENDOR21 = 0x51
- AF_VENDOR22 = 0x53
- AF_VENDOR23 = 0x55
- AF_VENDOR24 = 0x57
- AF_VENDOR25 = 0x59
- AF_VENDOR26 = 0x5b
- AF_VENDOR27 = 0x5d
- AF_VENDOR28 = 0x5f
- AF_VENDOR29 = 0x61
- AF_VENDOR30 = 0x63
- AF_VENDOR31 = 0x65
- AF_VENDOR32 = 0x67
- AF_VENDOR33 = 0x69
- AF_VENDOR34 = 0x6b
- AF_VENDOR35 = 0x6d
- AF_VENDOR36 = 0x6f
- AF_VENDOR37 = 0x71
- AF_VENDOR38 = 0x73
- AF_VENDOR39 = 0x75
- AF_VENDOR40 = 0x77
- AF_VENDOR41 = 0x79
- AF_VENDOR42 = 0x7b
- AF_VENDOR43 = 0x7d
- AF_VENDOR44 = 0x7f
- AF_VENDOR45 = 0x81
- AF_VENDOR46 = 0x83
- AF_VENDOR47 = 0x85
- B0 = 0x0
- B110 = 0x6e
- B115200 = 0x1c200
- B1200 = 0x4b0
- B134 = 0x86
- B14400 = 0x3840
- B150 = 0x96
- B1800 = 0x708
- B19200 = 0x4b00
- B200 = 0xc8
- B230400 = 0x38400
- B2400 = 0x960
- B28800 = 0x7080
- B300 = 0x12c
- B38400 = 0x9600
- B460800 = 0x70800
- B4800 = 0x12c0
- B50 = 0x32
- B57600 = 0xe100
- B600 = 0x258
- B7200 = 0x1c20
- B75 = 0x4b
- B76800 = 0x12c00
- B921600 = 0xe1000
- B9600 = 0x2580
- BIOCFEEDBACK = 0x8004427c
- BIOCFLUSH = 0x20004268
- BIOCGBLEN = 0x40044266
- BIOCGDIRECTION = 0x40044276
- BIOCGDLT = 0x4004426a
- BIOCGDLTLIST = 0xc0104279
- BIOCGETBUFMODE = 0x4004427d
- BIOCGETIF = 0x4020426b
- BIOCGETZMAX = 0x4008427f
- BIOCGHDRCMPLT = 0x40044274
- BIOCGRSIG = 0x40044272
- BIOCGRTIMEOUT = 0x4010426e
- BIOCGSEESENT = 0x40044276
- BIOCGSTATS = 0x4008426f
- BIOCGTSTAMP = 0x40044283
- BIOCIMMEDIATE = 0x80044270
- BIOCLOCK = 0x2000427a
- BIOCPROMISC = 0x20004269
- BIOCROTZBUF = 0x40184280
- BIOCSBLEN = 0xc0044266
- BIOCSDIRECTION = 0x80044277
- BIOCSDLT = 0x80044278
- BIOCSETBUFMODE = 0x8004427e
- BIOCSETF = 0x80104267
- BIOCSETFNR = 0x80104282
- BIOCSETIF = 0x8020426c
- BIOCSETWF = 0x8010427b
- BIOCSETZBUF = 0x80184281
- BIOCSHDRCMPLT = 0x80044275
- BIOCSRSIG = 0x80044273
- BIOCSRTIMEOUT = 0x8010426d
- BIOCSSEESENT = 0x80044277
- BIOCSTSTAMP = 0x80044284
- BIOCVERSION = 0x40044271
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALIGNMENT = 0x8
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_BUFMODE_BUFFER = 0x1
- BPF_BUFMODE_ZBUF = 0x2
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXBUFSIZE = 0x80000
- BPF_MAXINSNS = 0x200
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINBUFSIZE = 0x20
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RELEASE = 0x30bb6
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_T_BINTIME = 0x2
- BPF_T_BINTIME_FAST = 0x102
- BPF_T_BINTIME_MONOTONIC = 0x202
- BPF_T_BINTIME_MONOTONIC_FAST = 0x302
- BPF_T_FAST = 0x100
- BPF_T_FLAG_MASK = 0x300
- BPF_T_FORMAT_MASK = 0x3
- BPF_T_MICROTIME = 0x0
- BPF_T_MICROTIME_FAST = 0x100
- BPF_T_MICROTIME_MONOTONIC = 0x200
- BPF_T_MICROTIME_MONOTONIC_FAST = 0x300
- BPF_T_MONOTONIC = 0x200
- BPF_T_MONOTONIC_FAST = 0x300
- BPF_T_NANOTIME = 0x1
- BPF_T_NANOTIME_FAST = 0x101
- BPF_T_NANOTIME_MONOTONIC = 0x201
- BPF_T_NANOTIME_MONOTONIC_FAST = 0x301
- BPF_T_NONE = 0x3
- BPF_T_NORMAL = 0x0
- BPF_W = 0x0
- BPF_X = 0x8
- BRKINT = 0x2
- CFLUSH = 0xf
- CLOCAL = 0x8000
- CLOCK_MONOTONIC = 0x4
- CLOCK_MONOTONIC_FAST = 0xc
- CLOCK_MONOTONIC_PRECISE = 0xb
- CLOCK_PROCESS_CPUTIME_ID = 0xf
- CLOCK_PROF = 0x2
- CLOCK_REALTIME = 0x0
- CLOCK_REALTIME_FAST = 0xa
- CLOCK_REALTIME_PRECISE = 0x9
- CLOCK_SECOND = 0xd
- CLOCK_THREAD_CPUTIME_ID = 0xe
- CLOCK_UPTIME = 0x5
- CLOCK_UPTIME_FAST = 0x8
- CLOCK_UPTIME_PRECISE = 0x7
- CLOCK_VIRTUAL = 0x1
- CREAD = 0x800
- CS5 = 0x0
- CS6 = 0x100
- CS7 = 0x200
- CS8 = 0x300
- CSIZE = 0x300
- CSTART = 0x11
- CSTATUS = 0x14
- CSTOP = 0x13
- CSTOPB = 0x400
- CSUSP = 0x1a
- CTL_MAXNAME = 0x18
- CTL_NET = 0x4
- DLT_A429 = 0xb8
- DLT_A653_ICM = 0xb9
- DLT_AIRONET_HEADER = 0x78
- DLT_AOS = 0xde
- DLT_APPLE_IP_OVER_IEEE1394 = 0x8a
- DLT_ARCNET = 0x7
- DLT_ARCNET_LINUX = 0x81
- DLT_ATM_CLIP = 0x13
- DLT_ATM_RFC1483 = 0xb
- DLT_AURORA = 0x7e
- DLT_AX25 = 0x3
- DLT_AX25_KISS = 0xca
- DLT_BACNET_MS_TP = 0xa5
- DLT_BLUETOOTH_HCI_H4 = 0xbb
- DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9
- DLT_CAN20B = 0xbe
- DLT_CAN_SOCKETCAN = 0xe3
- DLT_CHAOS = 0x5
- DLT_CHDLC = 0x68
- DLT_CISCO_IOS = 0x76
- DLT_C_HDLC = 0x68
- DLT_C_HDLC_WITH_DIR = 0xcd
- DLT_DBUS = 0xe7
- DLT_DECT = 0xdd
- DLT_DOCSIS = 0x8f
- DLT_DVB_CI = 0xeb
- DLT_ECONET = 0x73
- DLT_EN10MB = 0x1
- DLT_EN3MB = 0x2
- DLT_ENC = 0x6d
- DLT_ERF = 0xc5
- DLT_ERF_ETH = 0xaf
- DLT_ERF_POS = 0xb0
- DLT_FC_2 = 0xe0
- DLT_FC_2_WITH_FRAME_DELIMS = 0xe1
- DLT_FDDI = 0xa
- DLT_FLEXRAY = 0xd2
- DLT_FRELAY = 0x6b
- DLT_FRELAY_WITH_DIR = 0xce
- DLT_GCOM_SERIAL = 0xad
- DLT_GCOM_T1E1 = 0xac
- DLT_GPF_F = 0xab
- DLT_GPF_T = 0xaa
- DLT_GPRS_LLC = 0xa9
- DLT_GSMTAP_ABIS = 0xda
- DLT_GSMTAP_UM = 0xd9
- DLT_HHDLC = 0x79
- DLT_IBM_SN = 0x92
- DLT_IBM_SP = 0x91
- DLT_IEEE802 = 0x6
- DLT_IEEE802_11 = 0x69
- DLT_IEEE802_11_RADIO = 0x7f
- DLT_IEEE802_11_RADIO_AVS = 0xa3
- DLT_IEEE802_15_4 = 0xc3
- DLT_IEEE802_15_4_LINUX = 0xbf
- DLT_IEEE802_15_4_NOFCS = 0xe6
- DLT_IEEE802_15_4_NONASK_PHY = 0xd7
- DLT_IEEE802_16_MAC_CPS = 0xbc
- DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1
- DLT_IPFILTER = 0x74
- DLT_IPMB = 0xc7
- DLT_IPMB_LINUX = 0xd1
- DLT_IPNET = 0xe2
- DLT_IPOIB = 0xf2
- DLT_IPV4 = 0xe4
- DLT_IPV6 = 0xe5
- DLT_IP_OVER_FC = 0x7a
- DLT_JUNIPER_ATM1 = 0x89
- DLT_JUNIPER_ATM2 = 0x87
- DLT_JUNIPER_ATM_CEMIC = 0xee
- DLT_JUNIPER_CHDLC = 0xb5
- DLT_JUNIPER_ES = 0x84
- DLT_JUNIPER_ETHER = 0xb2
- DLT_JUNIPER_FIBRECHANNEL = 0xea
- DLT_JUNIPER_FRELAY = 0xb4
- DLT_JUNIPER_GGSN = 0x85
- DLT_JUNIPER_ISM = 0xc2
- DLT_JUNIPER_MFR = 0x86
- DLT_JUNIPER_MLFR = 0x83
- DLT_JUNIPER_MLPPP = 0x82
- DLT_JUNIPER_MONITOR = 0xa4
- DLT_JUNIPER_PIC_PEER = 0xae
- DLT_JUNIPER_PPP = 0xb3
- DLT_JUNIPER_PPPOE = 0xa7
- DLT_JUNIPER_PPPOE_ATM = 0xa8
- DLT_JUNIPER_SERVICES = 0x88
- DLT_JUNIPER_SRX_E2E = 0xe9
- DLT_JUNIPER_ST = 0xc8
- DLT_JUNIPER_VP = 0xb7
- DLT_JUNIPER_VS = 0xe8
- DLT_LAPB_WITH_DIR = 0xcf
- DLT_LAPD = 0xcb
- DLT_LIN = 0xd4
- DLT_LINUX_EVDEV = 0xd8
- DLT_LINUX_IRDA = 0x90
- DLT_LINUX_LAPD = 0xb1
- DLT_LINUX_PPP_WITHDIRECTION = 0xa6
- DLT_LINUX_SLL = 0x71
- DLT_LOOP = 0x6c
- DLT_LTALK = 0x72
- DLT_MATCHING_MAX = 0xf6
- DLT_MATCHING_MIN = 0x68
- DLT_MFR = 0xb6
- DLT_MOST = 0xd3
- DLT_MPEG_2_TS = 0xf3
- DLT_MPLS = 0xdb
- DLT_MTP2 = 0x8c
- DLT_MTP2_WITH_PHDR = 0x8b
- DLT_MTP3 = 0x8d
- DLT_MUX27010 = 0xec
- DLT_NETANALYZER = 0xf0
- DLT_NETANALYZER_TRANSPARENT = 0xf1
- DLT_NFC_LLCP = 0xf5
- DLT_NFLOG = 0xef
- DLT_NG40 = 0xf4
- DLT_NULL = 0x0
- DLT_PCI_EXP = 0x7d
- DLT_PFLOG = 0x75
- DLT_PFSYNC = 0x79
- DLT_PPI = 0xc0
- DLT_PPP = 0x9
- DLT_PPP_BSDOS = 0x10
- DLT_PPP_ETHER = 0x33
- DLT_PPP_PPPD = 0xa6
- DLT_PPP_SERIAL = 0x32
- DLT_PPP_WITH_DIR = 0xcc
- DLT_PPP_WITH_DIRECTION = 0xa6
- DLT_PRISM_HEADER = 0x77
- DLT_PRONET = 0x4
- DLT_RAIF1 = 0xc6
- DLT_RAW = 0xc
- DLT_RIO = 0x7c
- DLT_SCCP = 0x8e
- DLT_SITA = 0xc4
- DLT_SLIP = 0x8
- DLT_SLIP_BSDOS = 0xf
- DLT_STANAG_5066_D_PDU = 0xed
- DLT_SUNATM = 0x7b
- DLT_SYMANTEC_FIREWALL = 0x63
- DLT_TZSP = 0x80
- DLT_USB = 0xba
- DLT_USB_LINUX = 0xbd
- DLT_USB_LINUX_MMAPPED = 0xdc
- DLT_USER0 = 0x93
- DLT_USER1 = 0x94
- DLT_USER10 = 0x9d
- DLT_USER11 = 0x9e
- DLT_USER12 = 0x9f
- DLT_USER13 = 0xa0
- DLT_USER14 = 0xa1
- DLT_USER15 = 0xa2
- DLT_USER2 = 0x95
- DLT_USER3 = 0x96
- DLT_USER4 = 0x97
- DLT_USER5 = 0x98
- DLT_USER6 = 0x99
- DLT_USER7 = 0x9a
- DLT_USER8 = 0x9b
- DLT_USER9 = 0x9c
- DLT_WIHART = 0xdf
- DLT_X2E_SERIAL = 0xd5
- DLT_X2E_XORAYA = 0xd6
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x40
- ECHOE = 0x2
- ECHOK = 0x4
- ECHOKE = 0x1
- ECHONL = 0x10
- ECHOPRT = 0x20
- EVFILT_AIO = -0x3
- EVFILT_FS = -0x9
- EVFILT_LIO = -0xa
- EVFILT_PROC = -0x5
- EVFILT_READ = -0x1
- EVFILT_SIGNAL = -0x6
- EVFILT_SYSCOUNT = 0xb
- EVFILT_TIMER = -0x7
- EVFILT_USER = -0xb
- EVFILT_VNODE = -0x4
- EVFILT_WRITE = -0x2
- EV_ADD = 0x1
- EV_CLEAR = 0x20
- EV_DELETE = 0x2
- EV_DISABLE = 0x8
- EV_DISPATCH = 0x80
- EV_DROP = 0x1000
- EV_ENABLE = 0x4
- EV_EOF = 0x8000
- EV_ERROR = 0x4000
- EV_FLAG1 = 0x2000
- EV_ONESHOT = 0x10
- EV_RECEIPT = 0x40
- EV_SYSFLAGS = 0xf000
- EXTA = 0x4b00
- EXTATTR_NAMESPACE_EMPTY = 0x0
- EXTATTR_NAMESPACE_SYSTEM = 0x2
- EXTATTR_NAMESPACE_USER = 0x1
- EXTB = 0x9600
- EXTPROC = 0x800
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FLUSHO = 0x800000
- F_CANCEL = 0x5
- F_DUP2FD = 0xa
- F_DUP2FD_CLOEXEC = 0x12
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x11
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLK = 0xb
- F_GETOWN = 0x5
- F_OGETLK = 0x7
- F_OK = 0x0
- F_OSETLK = 0x8
- F_OSETLKW = 0x9
- F_RDAHEAD = 0x10
- F_RDLCK = 0x1
- F_READAHEAD = 0xf
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLK = 0xc
- F_SETLKW = 0xd
- F_SETLK_REMOTE = 0xe
- F_SETOWN = 0x6
- F_UNLCK = 0x2
- F_UNLCKSYS = 0x4
- F_WRLCK = 0x3
- HUPCL = 0x4000
- ICANON = 0x100
- ICMP6_FILTER = 0x12
- ICRNL = 0x100
- IEXTEN = 0x400
- IFAN_ARRIVAL = 0x0
- IFAN_DEPARTURE = 0x1
- IFF_ALLMULTI = 0x200
- IFF_ALTPHYS = 0x4000
- IFF_BROADCAST = 0x2
- IFF_CANTCHANGE = 0x218f72
- IFF_CANTCONFIG = 0x10000
- IFF_DEBUG = 0x4
- IFF_DRV_OACTIVE = 0x400
- IFF_DRV_RUNNING = 0x40
- IFF_DYING = 0x200000
- IFF_LINK0 = 0x1000
- IFF_LINK1 = 0x2000
- IFF_LINK2 = 0x4000
- IFF_LOOPBACK = 0x8
- IFF_MONITOR = 0x40000
- IFF_MULTICAST = 0x8000
- IFF_NOARP = 0x80
- IFF_OACTIVE = 0x400
- IFF_POINTOPOINT = 0x10
- IFF_PPROMISC = 0x20000
- IFF_PROMISC = 0x100
- IFF_RENAMING = 0x400000
- IFF_RUNNING = 0x40
- IFF_SIMPLEX = 0x800
- IFF_SMART = 0x20
- IFF_STATICARP = 0x80000
- IFF_UP = 0x1
- IFNAMSIZ = 0x10
- IFT_1822 = 0x2
- IFT_A12MPPSWITCH = 0x82
- IFT_AAL2 = 0xbb
- IFT_AAL5 = 0x31
- IFT_ADSL = 0x5e
- IFT_AFLANE8023 = 0x3b
- IFT_AFLANE8025 = 0x3c
- IFT_ARAP = 0x58
- IFT_ARCNET = 0x23
- IFT_ARCNETPLUS = 0x24
- IFT_ASYNC = 0x54
- IFT_ATM = 0x25
- IFT_ATMDXI = 0x69
- IFT_ATMFUNI = 0x6a
- IFT_ATMIMA = 0x6b
- IFT_ATMLOGICAL = 0x50
- IFT_ATMRADIO = 0xbd
- IFT_ATMSUBINTERFACE = 0x86
- IFT_ATMVCIENDPT = 0xc2
- IFT_ATMVIRTUAL = 0x95
- IFT_BGPPOLICYACCOUNTING = 0xa2
- IFT_BRIDGE = 0xd1
- IFT_BSC = 0x53
- IFT_CARP = 0xf8
- IFT_CCTEMUL = 0x3d
- IFT_CEPT = 0x13
- IFT_CES = 0x85
- IFT_CHANNEL = 0x46
- IFT_CNR = 0x55
- IFT_COFFEE = 0x84
- IFT_COMPOSITELINK = 0x9b
- IFT_DCN = 0x8d
- IFT_DIGITALPOWERLINE = 0x8a
- IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
- IFT_DLSW = 0x4a
- IFT_DOCSCABLEDOWNSTREAM = 0x80
- IFT_DOCSCABLEMACLAYER = 0x7f
- IFT_DOCSCABLEUPSTREAM = 0x81
- IFT_DS0 = 0x51
- IFT_DS0BUNDLE = 0x52
- IFT_DS1FDL = 0xaa
- IFT_DS3 = 0x1e
- IFT_DTM = 0x8c
- IFT_DVBASILN = 0xac
- IFT_DVBASIOUT = 0xad
- IFT_DVBRCCDOWNSTREAM = 0x93
- IFT_DVBRCCMACLAYER = 0x92
- IFT_DVBRCCUPSTREAM = 0x94
- IFT_ENC = 0xf4
- IFT_EON = 0x19
- IFT_EPLRS = 0x57
- IFT_ESCON = 0x49
- IFT_ETHER = 0x6
- IFT_FAITH = 0xf2
- IFT_FAST = 0x7d
- IFT_FASTETHER = 0x3e
- IFT_FASTETHERFX = 0x45
- IFT_FDDI = 0xf
- IFT_FIBRECHANNEL = 0x38
- IFT_FRAMERELAYINTERCONNECT = 0x3a
- IFT_FRAMERELAYMPI = 0x5c
- IFT_FRDLCIENDPT = 0xc1
- IFT_FRELAY = 0x20
- IFT_FRELAYDCE = 0x2c
- IFT_FRF16MFRBUNDLE = 0xa3
- IFT_FRFORWARD = 0x9e
- IFT_G703AT2MB = 0x43
- IFT_G703AT64K = 0x42
- IFT_GIF = 0xf0
- IFT_GIGABITETHERNET = 0x75
- IFT_GR303IDT = 0xb2
- IFT_GR303RDT = 0xb1
- IFT_H323GATEKEEPER = 0xa4
- IFT_H323PROXY = 0xa5
- IFT_HDH1822 = 0x3
- IFT_HDLC = 0x76
- IFT_HDSL2 = 0xa8
- IFT_HIPERLAN2 = 0xb7
- IFT_HIPPI = 0x2f
- IFT_HIPPIINTERFACE = 0x39
- IFT_HOSTPAD = 0x5a
- IFT_HSSI = 0x2e
- IFT_HY = 0xe
- IFT_IBM370PARCHAN = 0x48
- IFT_IDSL = 0x9a
- IFT_IEEE1394 = 0x90
- IFT_IEEE80211 = 0x47
- IFT_IEEE80212 = 0x37
- IFT_IEEE8023ADLAG = 0xa1
- IFT_IFGSN = 0x91
- IFT_IMT = 0xbe
- IFT_INFINIBAND = 0xc7
- IFT_INTERLEAVE = 0x7c
- IFT_IP = 0x7e
- IFT_IPFORWARD = 0x8e
- IFT_IPOVERATM = 0x72
- IFT_IPOVERCDLC = 0x6d
- IFT_IPOVERCLAW = 0x6e
- IFT_IPSWITCH = 0x4e
- IFT_IPXIP = 0xf9
- IFT_ISDN = 0x3f
- IFT_ISDNBASIC = 0x14
- IFT_ISDNPRIMARY = 0x15
- IFT_ISDNS = 0x4b
- IFT_ISDNU = 0x4c
- IFT_ISO88022LLC = 0x29
- IFT_ISO88023 = 0x7
- IFT_ISO88024 = 0x8
- IFT_ISO88025 = 0x9
- IFT_ISO88025CRFPINT = 0x62
- IFT_ISO88025DTR = 0x56
- IFT_ISO88025FIBER = 0x73
- IFT_ISO88026 = 0xa
- IFT_ISUP = 0xb3
- IFT_L2VLAN = 0x87
- IFT_L3IPVLAN = 0x88
- IFT_L3IPXVLAN = 0x89
- IFT_LAPB = 0x10
- IFT_LAPD = 0x4d
- IFT_LAPF = 0x77
- IFT_LOCALTALK = 0x2a
- IFT_LOOP = 0x18
- IFT_MEDIAMAILOVERIP = 0x8b
- IFT_MFSIGLINK = 0xa7
- IFT_MIOX25 = 0x26
- IFT_MODEM = 0x30
- IFT_MPC = 0x71
- IFT_MPLS = 0xa6
- IFT_MPLSTUNNEL = 0x96
- IFT_MSDSL = 0x8f
- IFT_MVL = 0xbf
- IFT_MYRINET = 0x63
- IFT_NFAS = 0xaf
- IFT_NSIP = 0x1b
- IFT_OPTICALCHANNEL = 0xc3
- IFT_OPTICALTRANSPORT = 0xc4
- IFT_OTHER = 0x1
- IFT_P10 = 0xc
- IFT_P80 = 0xd
- IFT_PARA = 0x22
- IFT_PFLOG = 0xf6
- IFT_PFSYNC = 0xf7
- IFT_PLC = 0xae
- IFT_POS = 0xab
- IFT_PPP = 0x17
- IFT_PPPMULTILINKBUNDLE = 0x6c
- IFT_PROPBWAP2MP = 0xb8
- IFT_PROPCNLS = 0x59
- IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
- IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
- IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
- IFT_PROPMUX = 0x36
- IFT_PROPVIRTUAL = 0x35
- IFT_PROPWIRELESSP2P = 0x9d
- IFT_PTPSERIAL = 0x16
- IFT_PVC = 0xf1
- IFT_QLLC = 0x44
- IFT_RADIOMAC = 0xbc
- IFT_RADSL = 0x5f
- IFT_REACHDSL = 0xc0
- IFT_RFC1483 = 0x9f
- IFT_RS232 = 0x21
- IFT_RSRB = 0x4f
- IFT_SDLC = 0x11
- IFT_SDSL = 0x60
- IFT_SHDSL = 0xa9
- IFT_SIP = 0x1f
- IFT_SLIP = 0x1c
- IFT_SMDSDXI = 0x2b
- IFT_SMDSICIP = 0x34
- IFT_SONET = 0x27
- IFT_SONETOVERHEADCHANNEL = 0xb9
- IFT_SONETPATH = 0x32
- IFT_SONETVT = 0x33
- IFT_SRP = 0x97
- IFT_SS7SIGLINK = 0x9c
- IFT_STACKTOSTACK = 0x6f
- IFT_STARLAN = 0xb
- IFT_STF = 0xd7
- IFT_T1 = 0x12
- IFT_TDLC = 0x74
- IFT_TERMPAD = 0x5b
- IFT_TR008 = 0xb0
- IFT_TRANSPHDLC = 0x7b
- IFT_TUNNEL = 0x83
- IFT_ULTRA = 0x1d
- IFT_USB = 0xa0
- IFT_V11 = 0x40
- IFT_V35 = 0x2d
- IFT_V36 = 0x41
- IFT_V37 = 0x78
- IFT_VDSL = 0x61
- IFT_VIRTUALIPADDRESS = 0x70
- IFT_VOICEEM = 0x64
- IFT_VOICEENCAP = 0x67
- IFT_VOICEFXO = 0x65
- IFT_VOICEFXS = 0x66
- IFT_VOICEOVERATM = 0x98
- IFT_VOICEOVERFRAMERELAY = 0x99
- IFT_VOICEOVERIP = 0x68
- IFT_X213 = 0x5d
- IFT_X25 = 0x5
- IFT_X25DDN = 0x4
- IFT_X25HUNTGROUP = 0x7a
- IFT_X25MLP = 0x79
- IFT_X25PLE = 0x28
- IFT_XETHER = 0x1a
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLASSD_HOST = 0xfffffff
- IN_CLASSD_NET = 0xf0000000
- IN_CLASSD_NSHIFT = 0x1c
- IN_LOOPBACKNET = 0x7f
- IN_RFC3021_MASK = 0xfffffffe
- IPPROTO_3PC = 0x22
- IPPROTO_ADFS = 0x44
- IPPROTO_AH = 0x33
- IPPROTO_AHIP = 0x3d
- IPPROTO_APES = 0x63
- IPPROTO_ARGUS = 0xd
- IPPROTO_AX25 = 0x5d
- IPPROTO_BHA = 0x31
- IPPROTO_BLT = 0x1e
- IPPROTO_BRSATMON = 0x4c
- IPPROTO_CARP = 0x70
- IPPROTO_CFTP = 0x3e
- IPPROTO_CHAOS = 0x10
- IPPROTO_CMTP = 0x26
- IPPROTO_CPHB = 0x49
- IPPROTO_CPNX = 0x48
- IPPROTO_DDP = 0x25
- IPPROTO_DGP = 0x56
- IPPROTO_DIVERT = 0x102
- IPPROTO_DONE = 0x101
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_EMCON = 0xe
- IPPROTO_ENCAP = 0x62
- IPPROTO_EON = 0x50
- IPPROTO_ESP = 0x32
- IPPROTO_ETHERIP = 0x61
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GGP = 0x3
- IPPROTO_GMTP = 0x64
- IPPROTO_GRE = 0x2f
- IPPROTO_HELLO = 0x3f
- IPPROTO_HIP = 0x8b
- IPPROTO_HMP = 0x14
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IDPR = 0x23
- IPPROTO_IDRP = 0x2d
- IPPROTO_IGMP = 0x2
- IPPROTO_IGP = 0x55
- IPPROTO_IGRP = 0x58
- IPPROTO_IL = 0x28
- IPPROTO_INLSP = 0x34
- IPPROTO_INP = 0x20
- IPPROTO_IP = 0x0
- IPPROTO_IPCOMP = 0x6c
- IPPROTO_IPCV = 0x47
- IPPROTO_IPEIP = 0x5e
- IPPROTO_IPIP = 0x4
- IPPROTO_IPPC = 0x43
- IPPROTO_IPV4 = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_IRTP = 0x1c
- IPPROTO_KRYPTOLAN = 0x41
- IPPROTO_LARP = 0x5b
- IPPROTO_LEAF1 = 0x19
- IPPROTO_LEAF2 = 0x1a
- IPPROTO_MAX = 0x100
- IPPROTO_MAXID = 0x34
- IPPROTO_MEAS = 0x13
- IPPROTO_MH = 0x87
- IPPROTO_MHRP = 0x30
- IPPROTO_MICP = 0x5f
- IPPROTO_MOBILE = 0x37
- IPPROTO_MPLS = 0x89
- IPPROTO_MTP = 0x5c
- IPPROTO_MUX = 0x12
- IPPROTO_ND = 0x4d
- IPPROTO_NHRP = 0x36
- IPPROTO_NONE = 0x3b
- IPPROTO_NSP = 0x1f
- IPPROTO_NVPII = 0xb
- IPPROTO_OLD_DIVERT = 0xfe
- IPPROTO_OSPFIGP = 0x59
- IPPROTO_PFSYNC = 0xf0
- IPPROTO_PGM = 0x71
- IPPROTO_PIGP = 0x9
- IPPROTO_PIM = 0x67
- IPPROTO_PRM = 0x15
- IPPROTO_PUP = 0xc
- IPPROTO_PVP = 0x4b
- IPPROTO_RAW = 0xff
- IPPROTO_RCCMON = 0xa
- IPPROTO_RDP = 0x1b
- IPPROTO_RESERVED_253 = 0xfd
- IPPROTO_RESERVED_254 = 0xfe
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_RVD = 0x42
- IPPROTO_SATEXPAK = 0x40
- IPPROTO_SATMON = 0x45
- IPPROTO_SCCSP = 0x60
- IPPROTO_SCTP = 0x84
- IPPROTO_SDRP = 0x2a
- IPPROTO_SEND = 0x103
- IPPROTO_SEP = 0x21
- IPPROTO_SHIM6 = 0x8c
- IPPROTO_SKIP = 0x39
- IPPROTO_SPACER = 0x7fff
- IPPROTO_SRPC = 0x5a
- IPPROTO_ST = 0x7
- IPPROTO_SVMTP = 0x52
- IPPROTO_SWIPE = 0x35
- IPPROTO_TCF = 0x57
- IPPROTO_TCP = 0x6
- IPPROTO_TLSP = 0x38
- IPPROTO_TP = 0x1d
- IPPROTO_TPXX = 0x27
- IPPROTO_TRUNK1 = 0x17
- IPPROTO_TRUNK2 = 0x18
- IPPROTO_TTP = 0x54
- IPPROTO_UDP = 0x11
- IPPROTO_UDPLITE = 0x88
- IPPROTO_VINES = 0x53
- IPPROTO_VISA = 0x46
- IPPROTO_VMTP = 0x51
- IPPROTO_WBEXPAK = 0x4f
- IPPROTO_WBMON = 0x4e
- IPPROTO_WSN = 0x4a
- IPPROTO_XNET = 0xf
- IPPROTO_XTP = 0x24
- IPV6_AUTOFLOWLABEL = 0x3b
- IPV6_BINDANY = 0x40
- IPV6_BINDV6ONLY = 0x1b
- IPV6_CHECKSUM = 0x1a
- IPV6_DEFAULT_MULTICAST_HOPS = 0x1
- IPV6_DEFAULT_MULTICAST_LOOP = 0x1
- IPV6_DEFHLIM = 0x40
- IPV6_DONTFRAG = 0x3e
- IPV6_DSTOPTS = 0x32
- IPV6_FAITH = 0x1d
- IPV6_FLOWINFO_MASK = 0xffffff0f
- IPV6_FLOWLABEL_MASK = 0xffff0f00
- IPV6_FRAGTTL = 0x78
- IPV6_FW_ADD = 0x1e
- IPV6_FW_DEL = 0x1f
- IPV6_FW_FLUSH = 0x20
- IPV6_FW_GET = 0x22
- IPV6_FW_ZERO = 0x21
- IPV6_HLIMDEC = 0x1
- IPV6_HOPLIMIT = 0x2f
- IPV6_HOPOPTS = 0x31
- IPV6_IPSEC_POLICY = 0x1c
- IPV6_JOIN_GROUP = 0xc
- IPV6_LEAVE_GROUP = 0xd
- IPV6_MAXHLIM = 0xff
- IPV6_MAXOPTHDR = 0x800
- IPV6_MAXPACKET = 0xffff
- IPV6_MAX_GROUP_SRC_FILTER = 0x200
- IPV6_MAX_MEMBERSHIPS = 0xfff
- IPV6_MAX_SOCK_SRC_FILTER = 0x80
- IPV6_MIN_MEMBERSHIPS = 0x1f
- IPV6_MMTU = 0x500
- IPV6_MSFILTER = 0x4a
- IPV6_MULTICAST_HOPS = 0xa
- IPV6_MULTICAST_IF = 0x9
- IPV6_MULTICAST_LOOP = 0xb
- IPV6_NEXTHOP = 0x30
- IPV6_PATHMTU = 0x2c
- IPV6_PKTINFO = 0x2e
- IPV6_PORTRANGE = 0xe
- IPV6_PORTRANGE_DEFAULT = 0x0
- IPV6_PORTRANGE_HIGH = 0x1
- IPV6_PORTRANGE_LOW = 0x2
- IPV6_PREFER_TEMPADDR = 0x3f
- IPV6_RECVDSTOPTS = 0x28
- IPV6_RECVHOPLIMIT = 0x25
- IPV6_RECVHOPOPTS = 0x27
- IPV6_RECVPATHMTU = 0x2b
- IPV6_RECVPKTINFO = 0x24
- IPV6_RECVRTHDR = 0x26
- IPV6_RECVTCLASS = 0x39
- IPV6_RTHDR = 0x33
- IPV6_RTHDRDSTOPTS = 0x23
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_SOCKOPT_RESERVED1 = 0x3
- IPV6_TCLASS = 0x3d
- IPV6_UNICAST_HOPS = 0x4
- IPV6_USE_MIN_MTU = 0x2a
- IPV6_V6ONLY = 0x1b
- IPV6_VERSION = 0x60
- IPV6_VERSION_MASK = 0xf0
- IP_ADD_MEMBERSHIP = 0xc
- IP_ADD_SOURCE_MEMBERSHIP = 0x46
- IP_BINDANY = 0x18
- IP_BLOCK_SOURCE = 0x48
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DONTFRAG = 0x43
- IP_DROP_MEMBERSHIP = 0xd
- IP_DROP_SOURCE_MEMBERSHIP = 0x47
- IP_DUMMYNET3 = 0x31
- IP_DUMMYNET_CONFIGURE = 0x3c
- IP_DUMMYNET_DEL = 0x3d
- IP_DUMMYNET_FLUSH = 0x3e
- IP_DUMMYNET_GET = 0x40
- IP_FAITH = 0x16
- IP_FW3 = 0x30
- IP_FW_ADD = 0x32
- IP_FW_DEL = 0x33
- IP_FW_FLUSH = 0x34
- IP_FW_GET = 0x36
- IP_FW_NAT_CFG = 0x38
- IP_FW_NAT_DEL = 0x39
- IP_FW_NAT_GET_CONFIG = 0x3a
- IP_FW_NAT_GET_LOG = 0x3b
- IP_FW_RESETLOG = 0x37
- IP_FW_TABLE_ADD = 0x28
- IP_FW_TABLE_DEL = 0x29
- IP_FW_TABLE_FLUSH = 0x2a
- IP_FW_TABLE_GETSIZE = 0x2b
- IP_FW_TABLE_LIST = 0x2c
- IP_FW_ZERO = 0x35
- IP_HDRINCL = 0x2
- IP_IPSEC_POLICY = 0x15
- IP_MAXPACKET = 0xffff
- IP_MAX_GROUP_SRC_FILTER = 0x200
- IP_MAX_MEMBERSHIPS = 0xfff
- IP_MAX_SOCK_MUTE_FILTER = 0x80
- IP_MAX_SOCK_SRC_FILTER = 0x80
- IP_MAX_SOURCE_FILTER = 0x400
- IP_MF = 0x2000
- IP_MINTTL = 0x42
- IP_MIN_MEMBERSHIPS = 0x1f
- IP_MSFILTER = 0x4a
- IP_MSS = 0x240
- IP_MULTICAST_IF = 0x9
- IP_MULTICAST_LOOP = 0xb
- IP_MULTICAST_TTL = 0xa
- IP_MULTICAST_VIF = 0xe
- IP_OFFMASK = 0x1fff
- IP_ONESBCAST = 0x17
- IP_OPTIONS = 0x1
- IP_PORTRANGE = 0x13
- IP_PORTRANGE_DEFAULT = 0x0
- IP_PORTRANGE_HIGH = 0x1
- IP_PORTRANGE_LOW = 0x2
- IP_RECVDSTADDR = 0x7
- IP_RECVIF = 0x14
- IP_RECVOPTS = 0x5
- IP_RECVRETOPTS = 0x6
- IP_RECVTOS = 0x44
- IP_RECVTTL = 0x41
- IP_RETOPTS = 0x8
- IP_RF = 0x8000
- IP_RSVP_OFF = 0x10
- IP_RSVP_ON = 0xf
- IP_RSVP_VIF_OFF = 0x12
- IP_RSVP_VIF_ON = 0x11
- IP_SENDSRCADDR = 0x7
- IP_TOS = 0x3
- IP_TTL = 0x4
- IP_UNBLOCK_SOURCE = 0x49
- ISIG = 0x80
- ISTRIP = 0x20
- IXANY = 0x800
- IXOFF = 0x400
- IXON = 0x200
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_AUTOSYNC = 0x7
- MADV_CORE = 0x9
- MADV_DONTNEED = 0x4
- MADV_FREE = 0x5
- MADV_NOCORE = 0x8
- MADV_NORMAL = 0x0
- MADV_NOSYNC = 0x6
- MADV_PROTECT = 0xa
- MADV_RANDOM = 0x1
- MADV_SEQUENTIAL = 0x2
- MADV_WILLNEED = 0x3
- MAP_32BIT = 0x80000
- MAP_ALIGNED_SUPER = 0x1000000
- MAP_ALIGNMENT_MASK = -0x1000000
- MAP_ALIGNMENT_SHIFT = 0x18
- MAP_ANON = 0x1000
- MAP_ANONYMOUS = 0x1000
- MAP_COPY = 0x2
- MAP_EXCL = 0x4000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_HASSEMAPHORE = 0x200
- MAP_NOCORE = 0x20000
- MAP_NORESERVE = 0x40
- MAP_NOSYNC = 0x800
- MAP_PREFAULT_READ = 0x40000
- MAP_PRIVATE = 0x2
- MAP_RENAME = 0x20
- MAP_RESERVED0080 = 0x80
- MAP_RESERVED0100 = 0x100
- MAP_SHARED = 0x1
- MAP_STACK = 0x400
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MSG_CMSG_CLOEXEC = 0x40000
- MSG_COMPAT = 0x8000
- MSG_CTRUNC = 0x20
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x80
- MSG_EOF = 0x100
- MSG_EOR = 0x8
- MSG_NBIO = 0x4000
- MSG_NOSIGNAL = 0x20000
- MSG_NOTIFICATION = 0x2000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_TRUNC = 0x10
- MSG_WAITALL = 0x40
- MS_ASYNC = 0x1
- MS_INVALIDATE = 0x2
- MS_SYNC = 0x0
- NAME_MAX = 0xff
- NET_RT_DUMP = 0x1
- NET_RT_FLAGS = 0x2
- NET_RT_IFLIST = 0x3
- NET_RT_IFLISTL = 0x5
- NET_RT_IFMALIST = 0x4
- NET_RT_MAXID = 0x6
- NOFLSH = 0x80000000
- NOTE_ATTRIB = 0x8
- NOTE_CHILD = 0x4
- NOTE_DELETE = 0x1
- NOTE_EXEC = 0x20000000
- NOTE_EXIT = 0x80000000
- NOTE_EXTEND = 0x4
- NOTE_FFAND = 0x40000000
- NOTE_FFCOPY = 0xc0000000
- NOTE_FFCTRLMASK = 0xc0000000
- NOTE_FFLAGSMASK = 0xffffff
- NOTE_FFNOP = 0x0
- NOTE_FFOR = 0x80000000
- NOTE_FORK = 0x40000000
- NOTE_LINK = 0x10
- NOTE_LOWAT = 0x1
- NOTE_MSECONDS = 0x2
- NOTE_NSECONDS = 0x8
- NOTE_PCTRLMASK = 0xf0000000
- NOTE_PDATAMASK = 0xfffff
- NOTE_RENAME = 0x20
- NOTE_REVOKE = 0x40
- NOTE_SECONDS = 0x1
- NOTE_TRACK = 0x1
- NOTE_TRACKERR = 0x2
- NOTE_TRIGGER = 0x1000000
- NOTE_USECONDS = 0x4
- NOTE_WRITE = 0x2
- OCRNL = 0x10
- ONLCR = 0x2
- ONLRET = 0x40
- ONOCR = 0x20
- ONOEOT = 0x8
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x8
- O_ASYNC = 0x40
- O_CLOEXEC = 0x100000
- O_CREAT = 0x200
- O_DIRECT = 0x10000
- O_DIRECTORY = 0x20000
- O_EXCL = 0x800
- O_EXEC = 0x40000
- O_EXLOCK = 0x20
- O_FSYNC = 0x80
- O_NDELAY = 0x4
- O_NOCTTY = 0x8000
- O_NOFOLLOW = 0x100
- O_NONBLOCK = 0x4
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_SHLOCK = 0x10
- O_SYNC = 0x80
- O_TRUNC = 0x400
- O_TTY_INIT = 0x80000
- O_WRONLY = 0x1
- PARENB = 0x1000
- PARMRK = 0x8
- PARODD = 0x2000
- PENDIN = 0x20000000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- RLIMIT_AS = 0xa
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x8
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = 0x7fffffffffffffff
- RTAX_AUTHOR = 0x6
- RTAX_BRD = 0x7
- RTAX_DST = 0x0
- RTAX_GATEWAY = 0x1
- RTAX_GENMASK = 0x3
- RTAX_IFA = 0x5
- RTAX_IFP = 0x4
- RTAX_MAX = 0x8
- RTAX_NETMASK = 0x2
- RTA_AUTHOR = 0x40
- RTA_BRD = 0x80
- RTA_DST = 0x1
- RTA_GATEWAY = 0x2
- RTA_GENMASK = 0x8
- RTA_IFA = 0x20
- RTA_IFP = 0x10
- RTA_NETMASK = 0x4
- RTF_BLACKHOLE = 0x1000
- RTF_BROADCAST = 0x400000
- RTF_DONE = 0x40
- RTF_DYNAMIC = 0x10
- RTF_FMASK = 0x1004d808
- RTF_GATEWAY = 0x2
- RTF_GWFLAG_COMPAT = 0x80000000
- RTF_HOST = 0x4
- RTF_LLDATA = 0x400
- RTF_LLINFO = 0x400
- RTF_LOCAL = 0x200000
- RTF_MODIFIED = 0x20
- RTF_MULTICAST = 0x800000
- RTF_PINNED = 0x100000
- RTF_PRCLONING = 0x10000
- RTF_PROTO1 = 0x8000
- RTF_PROTO2 = 0x4000
- RTF_PROTO3 = 0x40000
- RTF_REJECT = 0x8
- RTF_RNH_LOCKED = 0x40000000
- RTF_STATIC = 0x800
- RTF_STICKY = 0x10000000
- RTF_UP = 0x1
- RTF_XRESOLVE = 0x200
- RTM_ADD = 0x1
- RTM_CHANGE = 0x3
- RTM_DELADDR = 0xd
- RTM_DELETE = 0x2
- RTM_DELMADDR = 0x10
- RTM_GET = 0x4
- RTM_IEEE80211 = 0x12
- RTM_IFANNOUNCE = 0x11
- RTM_IFINFO = 0xe
- RTM_LOCK = 0x8
- RTM_LOSING = 0x5
- RTM_MISS = 0x7
- RTM_NEWADDR = 0xc
- RTM_NEWMADDR = 0xf
- RTM_OLDADD = 0x9
- RTM_OLDDEL = 0xa
- RTM_REDIRECT = 0x6
- RTM_RESOLVE = 0xb
- RTM_RTTUNIT = 0xf4240
- RTM_VERSION = 0x5
- RTV_EXPIRE = 0x4
- RTV_HOPCOUNT = 0x2
- RTV_MTU = 0x1
- RTV_RPIPE = 0x8
- RTV_RTT = 0x40
- RTV_RTTVAR = 0x80
- RTV_SPIPE = 0x10
- RTV_SSTHRESH = 0x20
- RTV_WEIGHT = 0x100
- RT_ALL_FIBS = -0x1
- RT_CACHING_CONTEXT = 0x1
- RT_DEFAULT_FIB = 0x0
- RT_NORTREF = 0x2
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- RUSAGE_THREAD = 0x1
- SCM_BINTIME = 0x4
- SCM_CREDS = 0x3
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x2
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDMULTI = 0x80206931
- SIOCADDRT = 0x8040720a
- SIOCAIFADDR = 0x8040691a
- SIOCAIFGROUP = 0x80286987
- SIOCALIFADDR = 0x8118691b
- SIOCATMARK = 0x40047307
- SIOCDELMULTI = 0x80206932
- SIOCDELRT = 0x8040720b
- SIOCDIFADDR = 0x80206919
- SIOCDIFGROUP = 0x80286989
- SIOCDIFPHYADDR = 0x80206949
- SIOCDLIFADDR = 0x8118691d
- SIOCGDRVSPEC = 0xc028697b
- SIOCGETSGCNT = 0xc0207210
- SIOCGETVIFCNT = 0xc028720f
- SIOCGHIWAT = 0x40047301
- SIOCGIFADDR = 0xc0206921
- SIOCGIFBRDADDR = 0xc0206923
- SIOCGIFCAP = 0xc020691f
- SIOCGIFCONF = 0xc0106924
- SIOCGIFDESCR = 0xc020692a
- SIOCGIFDSTADDR = 0xc0206922
- SIOCGIFFIB = 0xc020695c
- SIOCGIFFLAGS = 0xc0206911
- SIOCGIFGENERIC = 0xc020693a
- SIOCGIFGMEMB = 0xc028698a
- SIOCGIFGROUP = 0xc0286988
- SIOCGIFINDEX = 0xc0206920
- SIOCGIFMAC = 0xc0206926
- SIOCGIFMEDIA = 0xc0306938
- SIOCGIFMETRIC = 0xc0206917
- SIOCGIFMTU = 0xc0206933
- SIOCGIFNETMASK = 0xc0206925
- SIOCGIFPDSTADDR = 0xc0206948
- SIOCGIFPHYS = 0xc0206935
- SIOCGIFPSRCADDR = 0xc0206947
- SIOCGIFSTATUS = 0xc331693b
- SIOCGLIFADDR = 0xc118691c
- SIOCGLIFPHYADDR = 0xc118694b
- SIOCGLOWAT = 0x40047303
- SIOCGPGRP = 0x40047309
- SIOCGPRIVATE_0 = 0xc0206950
- SIOCGPRIVATE_1 = 0xc0206951
- SIOCIFCREATE = 0xc020697a
- SIOCIFCREATE2 = 0xc020697c
- SIOCIFDESTROY = 0x80206979
- SIOCIFGCLONERS = 0xc0106978
- SIOCSDRVSPEC = 0x8028697b
- SIOCSHIWAT = 0x80047300
- SIOCSIFADDR = 0x8020690c
- SIOCSIFBRDADDR = 0x80206913
- SIOCSIFCAP = 0x8020691e
- SIOCSIFDESCR = 0x80206929
- SIOCSIFDSTADDR = 0x8020690e
- SIOCSIFFIB = 0x8020695d
- SIOCSIFFLAGS = 0x80206910
- SIOCSIFGENERIC = 0x80206939
- SIOCSIFLLADDR = 0x8020693c
- SIOCSIFMAC = 0x80206927
- SIOCSIFMEDIA = 0xc0206937
- SIOCSIFMETRIC = 0x80206918
- SIOCSIFMTU = 0x80206934
- SIOCSIFNAME = 0x80206928
- SIOCSIFNETMASK = 0x80206916
- SIOCSIFPHYADDR = 0x80406946
- SIOCSIFPHYS = 0x80206936
- SIOCSIFRVNET = 0xc020695b
- SIOCSIFVNET = 0xc020695a
- SIOCSLIFPHYADDR = 0x8118694a
- SIOCSLOWAT = 0x80047302
- SIOCSPGRP = 0x80047308
- SOCK_CLOEXEC = 0x10000000
- SOCK_DGRAM = 0x2
- SOCK_MAXADDRLEN = 0xff
- SOCK_NONBLOCK = 0x20000000
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_SOCKET = 0xffff
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x2
- SO_ACCEPTFILTER = 0x1000
- SO_BINTIME = 0x2000
- SO_BROADCAST = 0x20
- SO_DEBUG = 0x1
- SO_DONTROUTE = 0x10
- SO_ERROR = 0x1007
- SO_KEEPALIVE = 0x8
- SO_LABEL = 0x1009
- SO_LINGER = 0x80
- SO_LISTENINCQLEN = 0x1013
- SO_LISTENQLEN = 0x1012
- SO_LISTENQLIMIT = 0x1011
- SO_NOSIGPIPE = 0x800
- SO_NO_DDP = 0x8000
- SO_NO_OFFLOAD = 0x4000
- SO_OOBINLINE = 0x100
- SO_PEERLABEL = 0x1010
- SO_PROTOCOL = 0x1016
- SO_PROTOTYPE = 0x1016
- SO_RCVBUF = 0x1002
- SO_RCVLOWAT = 0x1004
- SO_RCVTIMEO = 0x1006
- SO_REUSEADDR = 0x4
- SO_REUSEPORT = 0x200
- SO_SETFIB = 0x1014
- SO_SNDBUF = 0x1001
- SO_SNDLOWAT = 0x1003
- SO_SNDTIMEO = 0x1005
- SO_TIMESTAMP = 0x400
- SO_TYPE = 0x1008
- SO_USELOOPBACK = 0x40
- SO_USER_COOKIE = 0x1015
- SO_VENDOR = 0x80000000
- TCIFLUSH = 0x1
- TCIOFLUSH = 0x3
- TCOFLUSH = 0x2
- TCP_CA_NAME_MAX = 0x10
- TCP_CONGESTION = 0x40
- TCP_INFO = 0x20
- TCP_KEEPCNT = 0x400
- TCP_KEEPIDLE = 0x100
- TCP_KEEPINIT = 0x80
- TCP_KEEPINTVL = 0x200
- TCP_MAXBURST = 0x4
- TCP_MAXHLEN = 0x3c
- TCP_MAXOLEN = 0x28
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_SACK = 0x4
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0x10
- TCP_MINMSS = 0xd8
- TCP_MSS = 0x218
- TCP_NODELAY = 0x1
- TCP_NOOPT = 0x8
- TCP_NOPUSH = 0x4
- TCP_VENDOR = 0x80000000
- TCSAFLUSH = 0x2
- TIOCCBRK = 0x2000747a
- TIOCCDTR = 0x20007478
- TIOCCONS = 0x80047462
- TIOCDRAIN = 0x2000745e
- TIOCEXCL = 0x2000740d
- TIOCEXT = 0x80047460
- TIOCFLUSH = 0x80047410
- TIOCGDRAINWAIT = 0x40047456
- TIOCGETA = 0x402c7413
- TIOCGETD = 0x4004741a
- TIOCGPGRP = 0x40047477
- TIOCGPTN = 0x4004740f
- TIOCGSID = 0x40047463
- TIOCGWINSZ = 0x40087468
- TIOCMBIC = 0x8004746b
- TIOCMBIS = 0x8004746c
- TIOCMGDTRWAIT = 0x4004745a
- TIOCMGET = 0x4004746a
- TIOCMSDTRWAIT = 0x8004745b
- TIOCMSET = 0x8004746d
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DCD = 0x40
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x20007471
- TIOCNXCL = 0x2000740e
- TIOCOUTQ = 0x40047473
- TIOCPKT = 0x80047470
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCPTMASTER = 0x2000741c
- TIOCSBRK = 0x2000747b
- TIOCSCTTY = 0x20007461
- TIOCSDRAINWAIT = 0x80047457
- TIOCSDTR = 0x20007479
- TIOCSETA = 0x802c7414
- TIOCSETAF = 0x802c7416
- TIOCSETAW = 0x802c7415
- TIOCSETD = 0x8004741b
- TIOCSIG = 0x2004745f
- TIOCSPGRP = 0x80047476
- TIOCSTART = 0x2000746e
- TIOCSTAT = 0x20007465
- TIOCSTI = 0x80017472
- TIOCSTOP = 0x2000746f
- TIOCSWINSZ = 0x80087467
- TIOCTIMESTAMP = 0x40107459
- TIOCUCNTL = 0x80047466
- TOSTOP = 0x400000
- VDISCARD = 0xf
- VDSUSP = 0xb
- VEOF = 0x0
- VEOL = 0x1
- VEOL2 = 0x2
- VERASE = 0x3
- VERASE2 = 0x7
- VINTR = 0x8
- VKILL = 0x5
- VLNEXT = 0xe
- VMIN = 0x10
- VQUIT = 0x9
- VREPRINT = 0x6
- VSTART = 0xc
- VSTATUS = 0x12
- VSTOP = 0xd
- VSUSP = 0xa
- VTIME = 0x11
- VWERASE = 0x4
- WCONTINUED = 0x4
- WCOREFLAG = 0x80
- WEXITED = 0x10
- WLINUXCLONE = 0x80000000
- WNOHANG = 0x1
- WNOWAIT = 0x8
- WSTOPPED = 0x2
- WTRAPPED = 0x20
- WUNTRACED = 0x2
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x30)
- EADDRNOTAVAIL = syscall.Errno(0x31)
- EAFNOSUPPORT = syscall.Errno(0x2f)
- EAGAIN = syscall.Errno(0x23)
- EALREADY = syscall.Errno(0x25)
- EAUTH = syscall.Errno(0x50)
- EBADF = syscall.Errno(0x9)
- EBADMSG = syscall.Errno(0x59)
- EBADRPC = syscall.Errno(0x48)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x55)
- ECAPMODE = syscall.Errno(0x5e)
- ECHILD = syscall.Errno(0xa)
- ECONNABORTED = syscall.Errno(0x35)
- ECONNREFUSED = syscall.Errno(0x3d)
- ECONNRESET = syscall.Errno(0x36)
- EDEADLK = syscall.Errno(0xb)
- EDESTADDRREQ = syscall.Errno(0x27)
- EDOM = syscall.Errno(0x21)
- EDOOFUS = syscall.Errno(0x58)
- EDQUOT = syscall.Errno(0x45)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EFTYPE = syscall.Errno(0x4f)
- EHOSTDOWN = syscall.Errno(0x40)
- EHOSTUNREACH = syscall.Errno(0x41)
- EIDRM = syscall.Errno(0x52)
- EILSEQ = syscall.Errno(0x56)
- EINPROGRESS = syscall.Errno(0x24)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x38)
- EISDIR = syscall.Errno(0x15)
- ELAST = syscall.Errno(0x60)
- ELOOP = syscall.Errno(0x3e)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x28)
- EMULTIHOP = syscall.Errno(0x5a)
- ENAMETOOLONG = syscall.Errno(0x3f)
- ENEEDAUTH = syscall.Errno(0x51)
- ENETDOWN = syscall.Errno(0x32)
- ENETRESET = syscall.Errno(0x34)
- ENETUNREACH = syscall.Errno(0x33)
- ENFILE = syscall.Errno(0x17)
- ENOATTR = syscall.Errno(0x57)
- ENOBUFS = syscall.Errno(0x37)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOLCK = syscall.Errno(0x4d)
- ENOLINK = syscall.Errno(0x5b)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x53)
- ENOPROTOOPT = syscall.Errno(0x2a)
- ENOSPC = syscall.Errno(0x1c)
- ENOSYS = syscall.Errno(0x4e)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCAPABLE = syscall.Errno(0x5d)
- ENOTCONN = syscall.Errno(0x39)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x42)
- ENOTRECOVERABLE = syscall.Errno(0x5f)
- ENOTSOCK = syscall.Errno(0x26)
- ENOTSUP = syscall.Errno(0x2d)
- ENOTTY = syscall.Errno(0x19)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x2d)
- EOVERFLOW = syscall.Errno(0x54)
- EOWNERDEAD = syscall.Errno(0x60)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x2e)
- EPIPE = syscall.Errno(0x20)
- EPROCLIM = syscall.Errno(0x43)
- EPROCUNAVAIL = syscall.Errno(0x4c)
- EPROGMISMATCH = syscall.Errno(0x4b)
- EPROGUNAVAIL = syscall.Errno(0x4a)
- EPROTO = syscall.Errno(0x5c)
- EPROTONOSUPPORT = syscall.Errno(0x2b)
- EPROTOTYPE = syscall.Errno(0x29)
- ERANGE = syscall.Errno(0x22)
- EREMOTE = syscall.Errno(0x47)
- EROFS = syscall.Errno(0x1e)
- ERPCMISMATCH = syscall.Errno(0x49)
- ESHUTDOWN = syscall.Errno(0x3a)
- ESOCKTNOSUPPORT = syscall.Errno(0x2c)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESTALE = syscall.Errno(0x46)
- ETIMEDOUT = syscall.Errno(0x3c)
- ETOOMANYREFS = syscall.Errno(0x3b)
- ETXTBSY = syscall.Errno(0x1a)
- EUSERS = syscall.Errno(0x44)
- EWOULDBLOCK = syscall.Errno(0x23)
- EXDEV = syscall.Errno(0x12)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0xa)
- SIGCHLD = syscall.Signal(0x14)
- SIGCONT = syscall.Signal(0x13)
- SIGEMT = syscall.Signal(0x7)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINFO = syscall.Signal(0x1d)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x17)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGLIBRT = syscall.Signal(0x21)
- SIGLWP = syscall.Signal(0x20)
- SIGPIPE = syscall.Signal(0xd)
- SIGPROF = syscall.Signal(0x1b)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTOP = syscall.Signal(0x11)
- SIGSYS = syscall.Signal(0xc)
- SIGTERM = syscall.Signal(0xf)
- SIGTHR = syscall.Signal(0x20)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x12)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGURG = syscall.Signal(0x10)
- SIGUSR1 = syscall.Signal(0x1e)
- SIGUSR2 = syscall.Signal(0x1f)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "device not configured",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource deadlock avoided",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device busy",
- 17: "file exists",
- 18: "cross-device link",
- 19: "operation not supported by device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "result too large",
- 35: "resource temporarily unavailable",
- 36: "operation now in progress",
- 37: "operation already in progress",
- 38: "socket operation on non-socket",
- 39: "destination address required",
- 40: "message too long",
- 41: "protocol wrong type for socket",
- 42: "protocol not available",
- 43: "protocol not supported",
- 44: "socket type not supported",
- 45: "operation not supported",
- 46: "protocol family not supported",
- 47: "address family not supported by protocol family",
- 48: "address already in use",
- 49: "can't assign requested address",
- 50: "network is down",
- 51: "network is unreachable",
- 52: "network dropped connection on reset",
- 53: "software caused connection abort",
- 54: "connection reset by peer",
- 55: "no buffer space available",
- 56: "socket is already connected",
- 57: "socket is not connected",
- 58: "can't send after socket shutdown",
- 59: "too many references: can't splice",
- 60: "operation timed out",
- 61: "connection refused",
- 62: "too many levels of symbolic links",
- 63: "file name too long",
- 64: "host is down",
- 65: "no route to host",
- 66: "directory not empty",
- 67: "too many processes",
- 68: "too many users",
- 69: "disc quota exceeded",
- 70: "stale NFS file handle",
- 71: "too many levels of remote in path",
- 72: "RPC struct is bad",
- 73: "RPC version wrong",
- 74: "RPC prog. not avail",
- 75: "program version wrong",
- 76: "bad procedure for program",
- 77: "no locks available",
- 78: "function not implemented",
- 79: "inappropriate file type or format",
- 80: "authentication error",
- 81: "need authenticator",
- 82: "identifier removed",
- 83: "no message of desired type",
- 84: "value too large to be stored in data type",
- 85: "operation canceled",
- 86: "illegal byte sequence",
- 87: "attribute not found",
- 88: "programming error",
- 89: "bad message",
- 90: "multihop attempted",
- 91: "link has been severed",
- 92: "protocol error",
- 93: "capabilities insufficient",
- 94: "not permitted in capability mode",
- 95: "state not recoverable",
- 96: "previous owner died",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/BPT trap",
- 6: "abort trap",
- 7: "EMT trap",
- 8: "floating point exception",
- 9: "killed",
- 10: "bus error",
- 11: "segmentation fault",
- 12: "bad system call",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "urgent I/O condition",
- 17: "suspended (signal)",
- 18: "suspended",
- 19: "continued",
- 20: "child exited",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "I/O possible",
- 24: "cputime limit exceeded",
- 25: "filesize limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window size changes",
- 29: "information request",
- 30: "user defined signal 1",
- 31: "user defined signal 2",
- 32: "unknown signal",
- 33: "unknown signal",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go b/newt/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go
deleted file mode 100644
index 2afbe2d5..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go
+++ /dev/null
@@ -1,1729 +0,0 @@
-// mkerrors.sh
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build arm,freebsd
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_APPLETALK = 0x10
- AF_ARP = 0x23
- AF_ATM = 0x1e
- AF_BLUETOOTH = 0x24
- AF_CCITT = 0xa
- AF_CHAOS = 0x5
- AF_CNT = 0x15
- AF_COIP = 0x14
- AF_DATAKIT = 0x9
- AF_DECnet = 0xc
- AF_DLI = 0xd
- AF_E164 = 0x1a
- AF_ECMA = 0x8
- AF_HYLINK = 0xf
- AF_IEEE80211 = 0x25
- AF_IMPLINK = 0x3
- AF_INET = 0x2
- AF_INET6 = 0x1c
- AF_INET6_SDP = 0x2a
- AF_INET_SDP = 0x28
- AF_IPX = 0x17
- AF_ISDN = 0x1a
- AF_ISO = 0x7
- AF_LAT = 0xe
- AF_LINK = 0x12
- AF_LOCAL = 0x1
- AF_MAX = 0x2a
- AF_NATM = 0x1d
- AF_NETBIOS = 0x6
- AF_NETGRAPH = 0x20
- AF_OSI = 0x7
- AF_PUP = 0x4
- AF_ROUTE = 0x11
- AF_SCLUSTER = 0x22
- AF_SIP = 0x18
- AF_SLOW = 0x21
- AF_SNA = 0xb
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_VENDOR00 = 0x27
- AF_VENDOR01 = 0x29
- AF_VENDOR02 = 0x2b
- AF_VENDOR03 = 0x2d
- AF_VENDOR04 = 0x2f
- AF_VENDOR05 = 0x31
- AF_VENDOR06 = 0x33
- AF_VENDOR07 = 0x35
- AF_VENDOR08 = 0x37
- AF_VENDOR09 = 0x39
- AF_VENDOR10 = 0x3b
- AF_VENDOR11 = 0x3d
- AF_VENDOR12 = 0x3f
- AF_VENDOR13 = 0x41
- AF_VENDOR14 = 0x43
- AF_VENDOR15 = 0x45
- AF_VENDOR16 = 0x47
- AF_VENDOR17 = 0x49
- AF_VENDOR18 = 0x4b
- AF_VENDOR19 = 0x4d
- AF_VENDOR20 = 0x4f
- AF_VENDOR21 = 0x51
- AF_VENDOR22 = 0x53
- AF_VENDOR23 = 0x55
- AF_VENDOR24 = 0x57
- AF_VENDOR25 = 0x59
- AF_VENDOR26 = 0x5b
- AF_VENDOR27 = 0x5d
- AF_VENDOR28 = 0x5f
- AF_VENDOR29 = 0x61
- AF_VENDOR30 = 0x63
- AF_VENDOR31 = 0x65
- AF_VENDOR32 = 0x67
- AF_VENDOR33 = 0x69
- AF_VENDOR34 = 0x6b
- AF_VENDOR35 = 0x6d
- AF_VENDOR36 = 0x6f
- AF_VENDOR37 = 0x71
- AF_VENDOR38 = 0x73
- AF_VENDOR39 = 0x75
- AF_VENDOR40 = 0x77
- AF_VENDOR41 = 0x79
- AF_VENDOR42 = 0x7b
- AF_VENDOR43 = 0x7d
- AF_VENDOR44 = 0x7f
- AF_VENDOR45 = 0x81
- AF_VENDOR46 = 0x83
- AF_VENDOR47 = 0x85
- B0 = 0x0
- B110 = 0x6e
- B115200 = 0x1c200
- B1200 = 0x4b0
- B134 = 0x86
- B14400 = 0x3840
- B150 = 0x96
- B1800 = 0x708
- B19200 = 0x4b00
- B200 = 0xc8
- B230400 = 0x38400
- B2400 = 0x960
- B28800 = 0x7080
- B300 = 0x12c
- B38400 = 0x9600
- B460800 = 0x70800
- B4800 = 0x12c0
- B50 = 0x32
- B57600 = 0xe100
- B600 = 0x258
- B7200 = 0x1c20
- B75 = 0x4b
- B76800 = 0x12c00
- B921600 = 0xe1000
- B9600 = 0x2580
- BIOCFEEDBACK = 0x8004427c
- BIOCFLUSH = 0x20004268
- BIOCGBLEN = 0x40044266
- BIOCGDIRECTION = 0x40044276
- BIOCGDLT = 0x4004426a
- BIOCGDLTLIST = 0xc0084279
- BIOCGETBUFMODE = 0x4004427d
- BIOCGETIF = 0x4020426b
- BIOCGETZMAX = 0x4004427f
- BIOCGHDRCMPLT = 0x40044274
- BIOCGRSIG = 0x40044272
- BIOCGRTIMEOUT = 0x4008426e
- BIOCGSEESENT = 0x40044276
- BIOCGSTATS = 0x4008426f
- BIOCGTSTAMP = 0x40044283
- BIOCIMMEDIATE = 0x80044270
- BIOCLOCK = 0x2000427a
- BIOCPROMISC = 0x20004269
- BIOCROTZBUF = 0x400c4280
- BIOCSBLEN = 0xc0044266
- BIOCSDIRECTION = 0x80044277
- BIOCSDLT = 0x80044278
- BIOCSETBUFMODE = 0x8004427e
- BIOCSETF = 0x80084267
- BIOCSETFNR = 0x80084282
- BIOCSETIF = 0x8020426c
- BIOCSETWF = 0x8008427b
- BIOCSETZBUF = 0x800c4281
- BIOCSHDRCMPLT = 0x80044275
- BIOCSRSIG = 0x80044273
- BIOCSRTIMEOUT = 0x8008426d
- BIOCSSEESENT = 0x80044277
- BIOCSTSTAMP = 0x80044284
- BIOCVERSION = 0x40044271
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALIGNMENT = 0x4
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_BUFMODE_BUFFER = 0x1
- BPF_BUFMODE_ZBUF = 0x2
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXBUFSIZE = 0x80000
- BPF_MAXINSNS = 0x200
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINBUFSIZE = 0x20
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RELEASE = 0x30bb6
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_T_BINTIME = 0x2
- BPF_T_BINTIME_FAST = 0x102
- BPF_T_BINTIME_MONOTONIC = 0x202
- BPF_T_BINTIME_MONOTONIC_FAST = 0x302
- BPF_T_FAST = 0x100
- BPF_T_FLAG_MASK = 0x300
- BPF_T_FORMAT_MASK = 0x3
- BPF_T_MICROTIME = 0x0
- BPF_T_MICROTIME_FAST = 0x100
- BPF_T_MICROTIME_MONOTONIC = 0x200
- BPF_T_MICROTIME_MONOTONIC_FAST = 0x300
- BPF_T_MONOTONIC = 0x200
- BPF_T_MONOTONIC_FAST = 0x300
- BPF_T_NANOTIME = 0x1
- BPF_T_NANOTIME_FAST = 0x101
- BPF_T_NANOTIME_MONOTONIC = 0x201
- BPF_T_NANOTIME_MONOTONIC_FAST = 0x301
- BPF_T_NONE = 0x3
- BPF_T_NORMAL = 0x0
- BPF_W = 0x0
- BPF_X = 0x8
- BRKINT = 0x2
- CFLUSH = 0xf
- CLOCAL = 0x8000
- CREAD = 0x800
- CS5 = 0x0
- CS6 = 0x100
- CS7 = 0x200
- CS8 = 0x300
- CSIZE = 0x300
- CSTART = 0x11
- CSTATUS = 0x14
- CSTOP = 0x13
- CSTOPB = 0x400
- CSUSP = 0x1a
- CTL_MAXNAME = 0x18
- CTL_NET = 0x4
- DLT_A429 = 0xb8
- DLT_A653_ICM = 0xb9
- DLT_AIRONET_HEADER = 0x78
- DLT_AOS = 0xde
- DLT_APPLE_IP_OVER_IEEE1394 = 0x8a
- DLT_ARCNET = 0x7
- DLT_ARCNET_LINUX = 0x81
- DLT_ATM_CLIP = 0x13
- DLT_ATM_RFC1483 = 0xb
- DLT_AURORA = 0x7e
- DLT_AX25 = 0x3
- DLT_AX25_KISS = 0xca
- DLT_BACNET_MS_TP = 0xa5
- DLT_BLUETOOTH_HCI_H4 = 0xbb
- DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9
- DLT_CAN20B = 0xbe
- DLT_CAN_SOCKETCAN = 0xe3
- DLT_CHAOS = 0x5
- DLT_CHDLC = 0x68
- DLT_CISCO_IOS = 0x76
- DLT_C_HDLC = 0x68
- DLT_C_HDLC_WITH_DIR = 0xcd
- DLT_DBUS = 0xe7
- DLT_DECT = 0xdd
- DLT_DOCSIS = 0x8f
- DLT_DVB_CI = 0xeb
- DLT_ECONET = 0x73
- DLT_EN10MB = 0x1
- DLT_EN3MB = 0x2
- DLT_ENC = 0x6d
- DLT_ERF = 0xc5
- DLT_ERF_ETH = 0xaf
- DLT_ERF_POS = 0xb0
- DLT_FC_2 = 0xe0
- DLT_FC_2_WITH_FRAME_DELIMS = 0xe1
- DLT_FDDI = 0xa
- DLT_FLEXRAY = 0xd2
- DLT_FRELAY = 0x6b
- DLT_FRELAY_WITH_DIR = 0xce
- DLT_GCOM_SERIAL = 0xad
- DLT_GCOM_T1E1 = 0xac
- DLT_GPF_F = 0xab
- DLT_GPF_T = 0xaa
- DLT_GPRS_LLC = 0xa9
- DLT_GSMTAP_ABIS = 0xda
- DLT_GSMTAP_UM = 0xd9
- DLT_HHDLC = 0x79
- DLT_IBM_SN = 0x92
- DLT_IBM_SP = 0x91
- DLT_IEEE802 = 0x6
- DLT_IEEE802_11 = 0x69
- DLT_IEEE802_11_RADIO = 0x7f
- DLT_IEEE802_11_RADIO_AVS = 0xa3
- DLT_IEEE802_15_4 = 0xc3
- DLT_IEEE802_15_4_LINUX = 0xbf
- DLT_IEEE802_15_4_NOFCS = 0xe6
- DLT_IEEE802_15_4_NONASK_PHY = 0xd7
- DLT_IEEE802_16_MAC_CPS = 0xbc
- DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1
- DLT_IPFILTER = 0x74
- DLT_IPMB = 0xc7
- DLT_IPMB_LINUX = 0xd1
- DLT_IPNET = 0xe2
- DLT_IPOIB = 0xf2
- DLT_IPV4 = 0xe4
- DLT_IPV6 = 0xe5
- DLT_IP_OVER_FC = 0x7a
- DLT_JUNIPER_ATM1 = 0x89
- DLT_JUNIPER_ATM2 = 0x87
- DLT_JUNIPER_ATM_CEMIC = 0xee
- DLT_JUNIPER_CHDLC = 0xb5
- DLT_JUNIPER_ES = 0x84
- DLT_JUNIPER_ETHER = 0xb2
- DLT_JUNIPER_FIBRECHANNEL = 0xea
- DLT_JUNIPER_FRELAY = 0xb4
- DLT_JUNIPER_GGSN = 0x85
- DLT_JUNIPER_ISM = 0xc2
- DLT_JUNIPER_MFR = 0x86
- DLT_JUNIPER_MLFR = 0x83
- DLT_JUNIPER_MLPPP = 0x82
- DLT_JUNIPER_MONITOR = 0xa4
- DLT_JUNIPER_PIC_PEER = 0xae
- DLT_JUNIPER_PPP = 0xb3
- DLT_JUNIPER_PPPOE = 0xa7
- DLT_JUNIPER_PPPOE_ATM = 0xa8
- DLT_JUNIPER_SERVICES = 0x88
- DLT_JUNIPER_SRX_E2E = 0xe9
- DLT_JUNIPER_ST = 0xc8
- DLT_JUNIPER_VP = 0xb7
- DLT_JUNIPER_VS = 0xe8
- DLT_LAPB_WITH_DIR = 0xcf
- DLT_LAPD = 0xcb
- DLT_LIN = 0xd4
- DLT_LINUX_EVDEV = 0xd8
- DLT_LINUX_IRDA = 0x90
- DLT_LINUX_LAPD = 0xb1
- DLT_LINUX_PPP_WITHDIRECTION = 0xa6
- DLT_LINUX_SLL = 0x71
- DLT_LOOP = 0x6c
- DLT_LTALK = 0x72
- DLT_MATCHING_MAX = 0xf6
- DLT_MATCHING_MIN = 0x68
- DLT_MFR = 0xb6
- DLT_MOST = 0xd3
- DLT_MPEG_2_TS = 0xf3
- DLT_MPLS = 0xdb
- DLT_MTP2 = 0x8c
- DLT_MTP2_WITH_PHDR = 0x8b
- DLT_MTP3 = 0x8d
- DLT_MUX27010 = 0xec
- DLT_NETANALYZER = 0xf0
- DLT_NETANALYZER_TRANSPARENT = 0xf1
- DLT_NFC_LLCP = 0xf5
- DLT_NFLOG = 0xef
- DLT_NG40 = 0xf4
- DLT_NULL = 0x0
- DLT_PCI_EXP = 0x7d
- DLT_PFLOG = 0x75
- DLT_PFSYNC = 0x79
- DLT_PPI = 0xc0
- DLT_PPP = 0x9
- DLT_PPP_BSDOS = 0x10
- DLT_PPP_ETHER = 0x33
- DLT_PPP_PPPD = 0xa6
- DLT_PPP_SERIAL = 0x32
- DLT_PPP_WITH_DIR = 0xcc
- DLT_PPP_WITH_DIRECTION = 0xa6
- DLT_PRISM_HEADER = 0x77
- DLT_PRONET = 0x4
- DLT_RAIF1 = 0xc6
- DLT_RAW = 0xc
- DLT_RIO = 0x7c
- DLT_SCCP = 0x8e
- DLT_SITA = 0xc4
- DLT_SLIP = 0x8
- DLT_SLIP_BSDOS = 0xf
- DLT_STANAG_5066_D_PDU = 0xed
- DLT_SUNATM = 0x7b
- DLT_SYMANTEC_FIREWALL = 0x63
- DLT_TZSP = 0x80
- DLT_USB = 0xba
- DLT_USB_LINUX = 0xbd
- DLT_USB_LINUX_MMAPPED = 0xdc
- DLT_USER0 = 0x93
- DLT_USER1 = 0x94
- DLT_USER10 = 0x9d
- DLT_USER11 = 0x9e
- DLT_USER12 = 0x9f
- DLT_USER13 = 0xa0
- DLT_USER14 = 0xa1
- DLT_USER15 = 0xa2
- DLT_USER2 = 0x95
- DLT_USER3 = 0x96
- DLT_USER4 = 0x97
- DLT_USER5 = 0x98
- DLT_USER6 = 0x99
- DLT_USER7 = 0x9a
- DLT_USER8 = 0x9b
- DLT_USER9 = 0x9c
- DLT_WIHART = 0xdf
- DLT_X2E_SERIAL = 0xd5
- DLT_X2E_XORAYA = 0xd6
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x40
- ECHOE = 0x2
- ECHOK = 0x4
- ECHOKE = 0x1
- ECHONL = 0x10
- ECHOPRT = 0x20
- EVFILT_AIO = -0x3
- EVFILT_FS = -0x9
- EVFILT_LIO = -0xa
- EVFILT_PROC = -0x5
- EVFILT_READ = -0x1
- EVFILT_SIGNAL = -0x6
- EVFILT_SYSCOUNT = 0xb
- EVFILT_TIMER = -0x7
- EVFILT_USER = -0xb
- EVFILT_VNODE = -0x4
- EVFILT_WRITE = -0x2
- EV_ADD = 0x1
- EV_CLEAR = 0x20
- EV_DELETE = 0x2
- EV_DISABLE = 0x8
- EV_DISPATCH = 0x80
- EV_DROP = 0x1000
- EV_ENABLE = 0x4
- EV_EOF = 0x8000
- EV_ERROR = 0x4000
- EV_FLAG1 = 0x2000
- EV_ONESHOT = 0x10
- EV_RECEIPT = 0x40
- EV_SYSFLAGS = 0xf000
- EXTA = 0x4b00
- EXTATTR_NAMESPACE_EMPTY = 0x0
- EXTATTR_NAMESPACE_SYSTEM = 0x2
- EXTATTR_NAMESPACE_USER = 0x1
- EXTB = 0x9600
- EXTPROC = 0x800
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FLUSHO = 0x800000
- F_CANCEL = 0x5
- F_DUP2FD = 0xa
- F_DUP2FD_CLOEXEC = 0x12
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x11
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLK = 0xb
- F_GETOWN = 0x5
- F_OGETLK = 0x7
- F_OK = 0x0
- F_OSETLK = 0x8
- F_OSETLKW = 0x9
- F_RDAHEAD = 0x10
- F_RDLCK = 0x1
- F_READAHEAD = 0xf
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLK = 0xc
- F_SETLKW = 0xd
- F_SETLK_REMOTE = 0xe
- F_SETOWN = 0x6
- F_UNLCK = 0x2
- F_UNLCKSYS = 0x4
- F_WRLCK = 0x3
- HUPCL = 0x4000
- ICANON = 0x100
- ICMP6_FILTER = 0x12
- ICRNL = 0x100
- IEXTEN = 0x400
- IFAN_ARRIVAL = 0x0
- IFAN_DEPARTURE = 0x1
- IFF_ALLMULTI = 0x200
- IFF_ALTPHYS = 0x4000
- IFF_BROADCAST = 0x2
- IFF_CANTCHANGE = 0x218f72
- IFF_CANTCONFIG = 0x10000
- IFF_DEBUG = 0x4
- IFF_DRV_OACTIVE = 0x400
- IFF_DRV_RUNNING = 0x40
- IFF_DYING = 0x200000
- IFF_LINK0 = 0x1000
- IFF_LINK1 = 0x2000
- IFF_LINK2 = 0x4000
- IFF_LOOPBACK = 0x8
- IFF_MONITOR = 0x40000
- IFF_MULTICAST = 0x8000
- IFF_NOARP = 0x80
- IFF_OACTIVE = 0x400
- IFF_POINTOPOINT = 0x10
- IFF_PPROMISC = 0x20000
- IFF_PROMISC = 0x100
- IFF_RENAMING = 0x400000
- IFF_RUNNING = 0x40
- IFF_SIMPLEX = 0x800
- IFF_SMART = 0x20
- IFF_STATICARP = 0x80000
- IFF_UP = 0x1
- IFNAMSIZ = 0x10
- IFT_1822 = 0x2
- IFT_A12MPPSWITCH = 0x82
- IFT_AAL2 = 0xbb
- IFT_AAL5 = 0x31
- IFT_ADSL = 0x5e
- IFT_AFLANE8023 = 0x3b
- IFT_AFLANE8025 = 0x3c
- IFT_ARAP = 0x58
- IFT_ARCNET = 0x23
- IFT_ARCNETPLUS = 0x24
- IFT_ASYNC = 0x54
- IFT_ATM = 0x25
- IFT_ATMDXI = 0x69
- IFT_ATMFUNI = 0x6a
- IFT_ATMIMA = 0x6b
- IFT_ATMLOGICAL = 0x50
- IFT_ATMRADIO = 0xbd
- IFT_ATMSUBINTERFACE = 0x86
- IFT_ATMVCIENDPT = 0xc2
- IFT_ATMVIRTUAL = 0x95
- IFT_BGPPOLICYACCOUNTING = 0xa2
- IFT_BRIDGE = 0xd1
- IFT_BSC = 0x53
- IFT_CARP = 0xf8
- IFT_CCTEMUL = 0x3d
- IFT_CEPT = 0x13
- IFT_CES = 0x85
- IFT_CHANNEL = 0x46
- IFT_CNR = 0x55
- IFT_COFFEE = 0x84
- IFT_COMPOSITELINK = 0x9b
- IFT_DCN = 0x8d
- IFT_DIGITALPOWERLINE = 0x8a
- IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
- IFT_DLSW = 0x4a
- IFT_DOCSCABLEDOWNSTREAM = 0x80
- IFT_DOCSCABLEMACLAYER = 0x7f
- IFT_DOCSCABLEUPSTREAM = 0x81
- IFT_DS0 = 0x51
- IFT_DS0BUNDLE = 0x52
- IFT_DS1FDL = 0xaa
- IFT_DS3 = 0x1e
- IFT_DTM = 0x8c
- IFT_DVBASILN = 0xac
- IFT_DVBASIOUT = 0xad
- IFT_DVBRCCDOWNSTREAM = 0x93
- IFT_DVBRCCMACLAYER = 0x92
- IFT_DVBRCCUPSTREAM = 0x94
- IFT_ENC = 0xf4
- IFT_EON = 0x19
- IFT_EPLRS = 0x57
- IFT_ESCON = 0x49
- IFT_ETHER = 0x6
- IFT_FAITH = 0xf2
- IFT_FAST = 0x7d
- IFT_FASTETHER = 0x3e
- IFT_FASTETHERFX = 0x45
- IFT_FDDI = 0xf
- IFT_FIBRECHANNEL = 0x38
- IFT_FRAMERELAYINTERCONNECT = 0x3a
- IFT_FRAMERELAYMPI = 0x5c
- IFT_FRDLCIENDPT = 0xc1
- IFT_FRELAY = 0x20
- IFT_FRELAYDCE = 0x2c
- IFT_FRF16MFRBUNDLE = 0xa3
- IFT_FRFORWARD = 0x9e
- IFT_G703AT2MB = 0x43
- IFT_G703AT64K = 0x42
- IFT_GIF = 0xf0
- IFT_GIGABITETHERNET = 0x75
- IFT_GR303IDT = 0xb2
- IFT_GR303RDT = 0xb1
- IFT_H323GATEKEEPER = 0xa4
- IFT_H323PROXY = 0xa5
- IFT_HDH1822 = 0x3
- IFT_HDLC = 0x76
- IFT_HDSL2 = 0xa8
- IFT_HIPERLAN2 = 0xb7
- IFT_HIPPI = 0x2f
- IFT_HIPPIINTERFACE = 0x39
- IFT_HOSTPAD = 0x5a
- IFT_HSSI = 0x2e
- IFT_HY = 0xe
- IFT_IBM370PARCHAN = 0x48
- IFT_IDSL = 0x9a
- IFT_IEEE1394 = 0x90
- IFT_IEEE80211 = 0x47
- IFT_IEEE80212 = 0x37
- IFT_IEEE8023ADLAG = 0xa1
- IFT_IFGSN = 0x91
- IFT_IMT = 0xbe
- IFT_INFINIBAND = 0xc7
- IFT_INTERLEAVE = 0x7c
- IFT_IP = 0x7e
- IFT_IPFORWARD = 0x8e
- IFT_IPOVERATM = 0x72
- IFT_IPOVERCDLC = 0x6d
- IFT_IPOVERCLAW = 0x6e
- IFT_IPSWITCH = 0x4e
- IFT_IPXIP = 0xf9
- IFT_ISDN = 0x3f
- IFT_ISDNBASIC = 0x14
- IFT_ISDNPRIMARY = 0x15
- IFT_ISDNS = 0x4b
- IFT_ISDNU = 0x4c
- IFT_ISO88022LLC = 0x29
- IFT_ISO88023 = 0x7
- IFT_ISO88024 = 0x8
- IFT_ISO88025 = 0x9
- IFT_ISO88025CRFPINT = 0x62
- IFT_ISO88025DTR = 0x56
- IFT_ISO88025FIBER = 0x73
- IFT_ISO88026 = 0xa
- IFT_ISUP = 0xb3
- IFT_L2VLAN = 0x87
- IFT_L3IPVLAN = 0x88
- IFT_L3IPXVLAN = 0x89
- IFT_LAPB = 0x10
- IFT_LAPD = 0x4d
- IFT_LAPF = 0x77
- IFT_LOCALTALK = 0x2a
- IFT_LOOP = 0x18
- IFT_MEDIAMAILOVERIP = 0x8b
- IFT_MFSIGLINK = 0xa7
- IFT_MIOX25 = 0x26
- IFT_MODEM = 0x30
- IFT_MPC = 0x71
- IFT_MPLS = 0xa6
- IFT_MPLSTUNNEL = 0x96
- IFT_MSDSL = 0x8f
- IFT_MVL = 0xbf
- IFT_MYRINET = 0x63
- IFT_NFAS = 0xaf
- IFT_NSIP = 0x1b
- IFT_OPTICALCHANNEL = 0xc3
- IFT_OPTICALTRANSPORT = 0xc4
- IFT_OTHER = 0x1
- IFT_P10 = 0xc
- IFT_P80 = 0xd
- IFT_PARA = 0x22
- IFT_PFLOG = 0xf6
- IFT_PFSYNC = 0xf7
- IFT_PLC = 0xae
- IFT_POS = 0xab
- IFT_PPP = 0x17
- IFT_PPPMULTILINKBUNDLE = 0x6c
- IFT_PROPBWAP2MP = 0xb8
- IFT_PROPCNLS = 0x59
- IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
- IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
- IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
- IFT_PROPMUX = 0x36
- IFT_PROPVIRTUAL = 0x35
- IFT_PROPWIRELESSP2P = 0x9d
- IFT_PTPSERIAL = 0x16
- IFT_PVC = 0xf1
- IFT_QLLC = 0x44
- IFT_RADIOMAC = 0xbc
- IFT_RADSL = 0x5f
- IFT_REACHDSL = 0xc0
- IFT_RFC1483 = 0x9f
- IFT_RS232 = 0x21
- IFT_RSRB = 0x4f
- IFT_SDLC = 0x11
- IFT_SDSL = 0x60
- IFT_SHDSL = 0xa9
- IFT_SIP = 0x1f
- IFT_SLIP = 0x1c
- IFT_SMDSDXI = 0x2b
- IFT_SMDSICIP = 0x34
- IFT_SONET = 0x27
- IFT_SONETOVERHEADCHANNEL = 0xb9
- IFT_SONETPATH = 0x32
- IFT_SONETVT = 0x33
- IFT_SRP = 0x97
- IFT_SS7SIGLINK = 0x9c
- IFT_STACKTOSTACK = 0x6f
- IFT_STARLAN = 0xb
- IFT_STF = 0xd7
- IFT_T1 = 0x12
- IFT_TDLC = 0x74
- IFT_TERMPAD = 0x5b
- IFT_TR008 = 0xb0
- IFT_TRANSPHDLC = 0x7b
- IFT_TUNNEL = 0x83
- IFT_ULTRA = 0x1d
- IFT_USB = 0xa0
- IFT_V11 = 0x40
- IFT_V35 = 0x2d
- IFT_V36 = 0x41
- IFT_V37 = 0x78
- IFT_VDSL = 0x61
- IFT_VIRTUALIPADDRESS = 0x70
- IFT_VOICEEM = 0x64
- IFT_VOICEENCAP = 0x67
- IFT_VOICEFXO = 0x65
- IFT_VOICEFXS = 0x66
- IFT_VOICEOVERATM = 0x98
- IFT_VOICEOVERFRAMERELAY = 0x99
- IFT_VOICEOVERIP = 0x68
- IFT_X213 = 0x5d
- IFT_X25 = 0x5
- IFT_X25DDN = 0x4
- IFT_X25HUNTGROUP = 0x7a
- IFT_X25MLP = 0x79
- IFT_X25PLE = 0x28
- IFT_XETHER = 0x1a
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLASSD_HOST = 0xfffffff
- IN_CLASSD_NET = 0xf0000000
- IN_CLASSD_NSHIFT = 0x1c
- IN_LOOPBACKNET = 0x7f
- IN_RFC3021_MASK = 0xfffffffe
- IPPROTO_3PC = 0x22
- IPPROTO_ADFS = 0x44
- IPPROTO_AH = 0x33
- IPPROTO_AHIP = 0x3d
- IPPROTO_APES = 0x63
- IPPROTO_ARGUS = 0xd
- IPPROTO_AX25 = 0x5d
- IPPROTO_BHA = 0x31
- IPPROTO_BLT = 0x1e
- IPPROTO_BRSATMON = 0x4c
- IPPROTO_CARP = 0x70
- IPPROTO_CFTP = 0x3e
- IPPROTO_CHAOS = 0x10
- IPPROTO_CMTP = 0x26
- IPPROTO_CPHB = 0x49
- IPPROTO_CPNX = 0x48
- IPPROTO_DDP = 0x25
- IPPROTO_DGP = 0x56
- IPPROTO_DIVERT = 0x102
- IPPROTO_DONE = 0x101
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_EMCON = 0xe
- IPPROTO_ENCAP = 0x62
- IPPROTO_EON = 0x50
- IPPROTO_ESP = 0x32
- IPPROTO_ETHERIP = 0x61
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GGP = 0x3
- IPPROTO_GMTP = 0x64
- IPPROTO_GRE = 0x2f
- IPPROTO_HELLO = 0x3f
- IPPROTO_HIP = 0x8b
- IPPROTO_HMP = 0x14
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IDPR = 0x23
- IPPROTO_IDRP = 0x2d
- IPPROTO_IGMP = 0x2
- IPPROTO_IGP = 0x55
- IPPROTO_IGRP = 0x58
- IPPROTO_IL = 0x28
- IPPROTO_INLSP = 0x34
- IPPROTO_INP = 0x20
- IPPROTO_IP = 0x0
- IPPROTO_IPCOMP = 0x6c
- IPPROTO_IPCV = 0x47
- IPPROTO_IPEIP = 0x5e
- IPPROTO_IPIP = 0x4
- IPPROTO_IPPC = 0x43
- IPPROTO_IPV4 = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_IRTP = 0x1c
- IPPROTO_KRYPTOLAN = 0x41
- IPPROTO_LARP = 0x5b
- IPPROTO_LEAF1 = 0x19
- IPPROTO_LEAF2 = 0x1a
- IPPROTO_MAX = 0x100
- IPPROTO_MAXID = 0x34
- IPPROTO_MEAS = 0x13
- IPPROTO_MH = 0x87
- IPPROTO_MHRP = 0x30
- IPPROTO_MICP = 0x5f
- IPPROTO_MOBILE = 0x37
- IPPROTO_MPLS = 0x89
- IPPROTO_MTP = 0x5c
- IPPROTO_MUX = 0x12
- IPPROTO_ND = 0x4d
- IPPROTO_NHRP = 0x36
- IPPROTO_NONE = 0x3b
- IPPROTO_NSP = 0x1f
- IPPROTO_NVPII = 0xb
- IPPROTO_OLD_DIVERT = 0xfe
- IPPROTO_OSPFIGP = 0x59
- IPPROTO_PFSYNC = 0xf0
- IPPROTO_PGM = 0x71
- IPPROTO_PIGP = 0x9
- IPPROTO_PIM = 0x67
- IPPROTO_PRM = 0x15
- IPPROTO_PUP = 0xc
- IPPROTO_PVP = 0x4b
- IPPROTO_RAW = 0xff
- IPPROTO_RCCMON = 0xa
- IPPROTO_RDP = 0x1b
- IPPROTO_RESERVED_253 = 0xfd
- IPPROTO_RESERVED_254 = 0xfe
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_RVD = 0x42
- IPPROTO_SATEXPAK = 0x40
- IPPROTO_SATMON = 0x45
- IPPROTO_SCCSP = 0x60
- IPPROTO_SCTP = 0x84
- IPPROTO_SDRP = 0x2a
- IPPROTO_SEND = 0x103
- IPPROTO_SEP = 0x21
- IPPROTO_SHIM6 = 0x8c
- IPPROTO_SKIP = 0x39
- IPPROTO_SPACER = 0x7fff
- IPPROTO_SRPC = 0x5a
- IPPROTO_ST = 0x7
- IPPROTO_SVMTP = 0x52
- IPPROTO_SWIPE = 0x35
- IPPROTO_TCF = 0x57
- IPPROTO_TCP = 0x6
- IPPROTO_TLSP = 0x38
- IPPROTO_TP = 0x1d
- IPPROTO_TPXX = 0x27
- IPPROTO_TRUNK1 = 0x17
- IPPROTO_TRUNK2 = 0x18
- IPPROTO_TTP = 0x54
- IPPROTO_UDP = 0x11
- IPPROTO_UDPLITE = 0x88
- IPPROTO_VINES = 0x53
- IPPROTO_VISA = 0x46
- IPPROTO_VMTP = 0x51
- IPPROTO_WBEXPAK = 0x4f
- IPPROTO_WBMON = 0x4e
- IPPROTO_WSN = 0x4a
- IPPROTO_XNET = 0xf
- IPPROTO_XTP = 0x24
- IPV6_AUTOFLOWLABEL = 0x3b
- IPV6_BINDANY = 0x40
- IPV6_BINDV6ONLY = 0x1b
- IPV6_CHECKSUM = 0x1a
- IPV6_DEFAULT_MULTICAST_HOPS = 0x1
- IPV6_DEFAULT_MULTICAST_LOOP = 0x1
- IPV6_DEFHLIM = 0x40
- IPV6_DONTFRAG = 0x3e
- IPV6_DSTOPTS = 0x32
- IPV6_FAITH = 0x1d
- IPV6_FLOWINFO_MASK = 0xffffff0f
- IPV6_FLOWLABEL_MASK = 0xffff0f00
- IPV6_FRAGTTL = 0x78
- IPV6_FW_ADD = 0x1e
- IPV6_FW_DEL = 0x1f
- IPV6_FW_FLUSH = 0x20
- IPV6_FW_GET = 0x22
- IPV6_FW_ZERO = 0x21
- IPV6_HLIMDEC = 0x1
- IPV6_HOPLIMIT = 0x2f
- IPV6_HOPOPTS = 0x31
- IPV6_IPSEC_POLICY = 0x1c
- IPV6_JOIN_GROUP = 0xc
- IPV6_LEAVE_GROUP = 0xd
- IPV6_MAXHLIM = 0xff
- IPV6_MAXOPTHDR = 0x800
- IPV6_MAXPACKET = 0xffff
- IPV6_MAX_GROUP_SRC_FILTER = 0x200
- IPV6_MAX_MEMBERSHIPS = 0xfff
- IPV6_MAX_SOCK_SRC_FILTER = 0x80
- IPV6_MIN_MEMBERSHIPS = 0x1f
- IPV6_MMTU = 0x500
- IPV6_MSFILTER = 0x4a
- IPV6_MULTICAST_HOPS = 0xa
- IPV6_MULTICAST_IF = 0x9
- IPV6_MULTICAST_LOOP = 0xb
- IPV6_NEXTHOP = 0x30
- IPV6_PATHMTU = 0x2c
- IPV6_PKTINFO = 0x2e
- IPV6_PORTRANGE = 0xe
- IPV6_PORTRANGE_DEFAULT = 0x0
- IPV6_PORTRANGE_HIGH = 0x1
- IPV6_PORTRANGE_LOW = 0x2
- IPV6_PREFER_TEMPADDR = 0x3f
- IPV6_RECVDSTOPTS = 0x28
- IPV6_RECVHOPLIMIT = 0x25
- IPV6_RECVHOPOPTS = 0x27
- IPV6_RECVPATHMTU = 0x2b
- IPV6_RECVPKTINFO = 0x24
- IPV6_RECVRTHDR = 0x26
- IPV6_RECVTCLASS = 0x39
- IPV6_RTHDR = 0x33
- IPV6_RTHDRDSTOPTS = 0x23
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_SOCKOPT_RESERVED1 = 0x3
- IPV6_TCLASS = 0x3d
- IPV6_UNICAST_HOPS = 0x4
- IPV6_USE_MIN_MTU = 0x2a
- IPV6_V6ONLY = 0x1b
- IPV6_VERSION = 0x60
- IPV6_VERSION_MASK = 0xf0
- IP_ADD_MEMBERSHIP = 0xc
- IP_ADD_SOURCE_MEMBERSHIP = 0x46
- IP_BINDANY = 0x18
- IP_BLOCK_SOURCE = 0x48
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DONTFRAG = 0x43
- IP_DROP_MEMBERSHIP = 0xd
- IP_DROP_SOURCE_MEMBERSHIP = 0x47
- IP_DUMMYNET3 = 0x31
- IP_DUMMYNET_CONFIGURE = 0x3c
- IP_DUMMYNET_DEL = 0x3d
- IP_DUMMYNET_FLUSH = 0x3e
- IP_DUMMYNET_GET = 0x40
- IP_FAITH = 0x16
- IP_FW3 = 0x30
- IP_FW_ADD = 0x32
- IP_FW_DEL = 0x33
- IP_FW_FLUSH = 0x34
- IP_FW_GET = 0x36
- IP_FW_NAT_CFG = 0x38
- IP_FW_NAT_DEL = 0x39
- IP_FW_NAT_GET_CONFIG = 0x3a
- IP_FW_NAT_GET_LOG = 0x3b
- IP_FW_RESETLOG = 0x37
- IP_FW_TABLE_ADD = 0x28
- IP_FW_TABLE_DEL = 0x29
- IP_FW_TABLE_FLUSH = 0x2a
- IP_FW_TABLE_GETSIZE = 0x2b
- IP_FW_TABLE_LIST = 0x2c
- IP_FW_ZERO = 0x35
- IP_HDRINCL = 0x2
- IP_IPSEC_POLICY = 0x15
- IP_MAXPACKET = 0xffff
- IP_MAX_GROUP_SRC_FILTER = 0x200
- IP_MAX_MEMBERSHIPS = 0xfff
- IP_MAX_SOCK_MUTE_FILTER = 0x80
- IP_MAX_SOCK_SRC_FILTER = 0x80
- IP_MAX_SOURCE_FILTER = 0x400
- IP_MF = 0x2000
- IP_MINTTL = 0x42
- IP_MIN_MEMBERSHIPS = 0x1f
- IP_MSFILTER = 0x4a
- IP_MSS = 0x240
- IP_MULTICAST_IF = 0x9
- IP_MULTICAST_LOOP = 0xb
- IP_MULTICAST_TTL = 0xa
- IP_MULTICAST_VIF = 0xe
- IP_OFFMASK = 0x1fff
- IP_ONESBCAST = 0x17
- IP_OPTIONS = 0x1
- IP_PORTRANGE = 0x13
- IP_PORTRANGE_DEFAULT = 0x0
- IP_PORTRANGE_HIGH = 0x1
- IP_PORTRANGE_LOW = 0x2
- IP_RECVDSTADDR = 0x7
- IP_RECVIF = 0x14
- IP_RECVOPTS = 0x5
- IP_RECVRETOPTS = 0x6
- IP_RECVTOS = 0x44
- IP_RECVTTL = 0x41
- IP_RETOPTS = 0x8
- IP_RF = 0x8000
- IP_RSVP_OFF = 0x10
- IP_RSVP_ON = 0xf
- IP_RSVP_VIF_OFF = 0x12
- IP_RSVP_VIF_ON = 0x11
- IP_SENDSRCADDR = 0x7
- IP_TOS = 0x3
- IP_TTL = 0x4
- IP_UNBLOCK_SOURCE = 0x49
- ISIG = 0x80
- ISTRIP = 0x20
- IXANY = 0x800
- IXOFF = 0x400
- IXON = 0x200
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_AUTOSYNC = 0x7
- MADV_CORE = 0x9
- MADV_DONTNEED = 0x4
- MADV_FREE = 0x5
- MADV_NOCORE = 0x8
- MADV_NORMAL = 0x0
- MADV_NOSYNC = 0x6
- MADV_PROTECT = 0xa
- MADV_RANDOM = 0x1
- MADV_SEQUENTIAL = 0x2
- MADV_WILLNEED = 0x3
- MAP_ALIGNED_SUPER = 0x1000000
- MAP_ALIGNMENT_MASK = -0x1000000
- MAP_ALIGNMENT_SHIFT = 0x18
- MAP_ANON = 0x1000
- MAP_ANONYMOUS = 0x1000
- MAP_COPY = 0x2
- MAP_EXCL = 0x4000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_HASSEMAPHORE = 0x200
- MAP_NOCORE = 0x20000
- MAP_NORESERVE = 0x40
- MAP_NOSYNC = 0x800
- MAP_PREFAULT_READ = 0x40000
- MAP_PRIVATE = 0x2
- MAP_RENAME = 0x20
- MAP_RESERVED0080 = 0x80
- MAP_RESERVED0100 = 0x100
- MAP_SHARED = 0x1
- MAP_STACK = 0x400
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MSG_CMSG_CLOEXEC = 0x40000
- MSG_COMPAT = 0x8000
- MSG_CTRUNC = 0x20
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x80
- MSG_EOF = 0x100
- MSG_EOR = 0x8
- MSG_NBIO = 0x4000
- MSG_NOSIGNAL = 0x20000
- MSG_NOTIFICATION = 0x2000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_TRUNC = 0x10
- MSG_WAITALL = 0x40
- MS_ASYNC = 0x1
- MS_INVALIDATE = 0x2
- MS_SYNC = 0x0
- NAME_MAX = 0xff
- NET_RT_DUMP = 0x1
- NET_RT_FLAGS = 0x2
- NET_RT_IFLIST = 0x3
- NET_RT_IFLISTL = 0x5
- NET_RT_IFMALIST = 0x4
- NET_RT_MAXID = 0x6
- NOFLSH = 0x80000000
- NOTE_ATTRIB = 0x8
- NOTE_CHILD = 0x4
- NOTE_DELETE = 0x1
- NOTE_EXEC = 0x20000000
- NOTE_EXIT = 0x80000000
- NOTE_EXTEND = 0x4
- NOTE_FFAND = 0x40000000
- NOTE_FFCOPY = 0xc0000000
- NOTE_FFCTRLMASK = 0xc0000000
- NOTE_FFLAGSMASK = 0xffffff
- NOTE_FFNOP = 0x0
- NOTE_FFOR = 0x80000000
- NOTE_FORK = 0x40000000
- NOTE_LINK = 0x10
- NOTE_LOWAT = 0x1
- NOTE_PCTRLMASK = 0xf0000000
- NOTE_PDATAMASK = 0xfffff
- NOTE_RENAME = 0x20
- NOTE_REVOKE = 0x40
- NOTE_TRACK = 0x1
- NOTE_TRACKERR = 0x2
- NOTE_TRIGGER = 0x1000000
- NOTE_WRITE = 0x2
- OCRNL = 0x10
- ONLCR = 0x2
- ONLRET = 0x40
- ONOCR = 0x20
- ONOEOT = 0x8
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x8
- O_ASYNC = 0x40
- O_CLOEXEC = 0x100000
- O_CREAT = 0x200
- O_DIRECT = 0x10000
- O_DIRECTORY = 0x20000
- O_EXCL = 0x800
- O_EXEC = 0x40000
- O_EXLOCK = 0x20
- O_FSYNC = 0x80
- O_NDELAY = 0x4
- O_NOCTTY = 0x8000
- O_NOFOLLOW = 0x100
- O_NONBLOCK = 0x4
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_SHLOCK = 0x10
- O_SYNC = 0x80
- O_TRUNC = 0x400
- O_TTY_INIT = 0x80000
- O_WRONLY = 0x1
- PARENB = 0x1000
- PARMRK = 0x8
- PARODD = 0x2000
- PENDIN = 0x20000000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- RLIMIT_AS = 0xa
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x8
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = 0x7fffffffffffffff
- RTAX_AUTHOR = 0x6
- RTAX_BRD = 0x7
- RTAX_DST = 0x0
- RTAX_GATEWAY = 0x1
- RTAX_GENMASK = 0x3
- RTAX_IFA = 0x5
- RTAX_IFP = 0x4
- RTAX_MAX = 0x8
- RTAX_NETMASK = 0x2
- RTA_AUTHOR = 0x40
- RTA_BRD = 0x80
- RTA_DST = 0x1
- RTA_GATEWAY = 0x2
- RTA_GENMASK = 0x8
- RTA_IFA = 0x20
- RTA_IFP = 0x10
- RTA_NETMASK = 0x4
- RTF_BLACKHOLE = 0x1000
- RTF_BROADCAST = 0x400000
- RTF_DONE = 0x40
- RTF_DYNAMIC = 0x10
- RTF_FMASK = 0x1004d808
- RTF_GATEWAY = 0x2
- RTF_GWFLAG_COMPAT = 0x80000000
- RTF_HOST = 0x4
- RTF_LLDATA = 0x400
- RTF_LLINFO = 0x400
- RTF_LOCAL = 0x200000
- RTF_MODIFIED = 0x20
- RTF_MULTICAST = 0x800000
- RTF_PINNED = 0x100000
- RTF_PRCLONING = 0x10000
- RTF_PROTO1 = 0x8000
- RTF_PROTO2 = 0x4000
- RTF_PROTO3 = 0x40000
- RTF_REJECT = 0x8
- RTF_RNH_LOCKED = 0x40000000
- RTF_STATIC = 0x800
- RTF_STICKY = 0x10000000
- RTF_UP = 0x1
- RTF_XRESOLVE = 0x200
- RTM_ADD = 0x1
- RTM_CHANGE = 0x3
- RTM_DELADDR = 0xd
- RTM_DELETE = 0x2
- RTM_DELMADDR = 0x10
- RTM_GET = 0x4
- RTM_IEEE80211 = 0x12
- RTM_IFANNOUNCE = 0x11
- RTM_IFINFO = 0xe
- RTM_LOCK = 0x8
- RTM_LOSING = 0x5
- RTM_MISS = 0x7
- RTM_NEWADDR = 0xc
- RTM_NEWMADDR = 0xf
- RTM_OLDADD = 0x9
- RTM_OLDDEL = 0xa
- RTM_REDIRECT = 0x6
- RTM_RESOLVE = 0xb
- RTM_RTTUNIT = 0xf4240
- RTM_VERSION = 0x5
- RTV_EXPIRE = 0x4
- RTV_HOPCOUNT = 0x2
- RTV_MTU = 0x1
- RTV_RPIPE = 0x8
- RTV_RTT = 0x40
- RTV_RTTVAR = 0x80
- RTV_SPIPE = 0x10
- RTV_SSTHRESH = 0x20
- RTV_WEIGHT = 0x100
- RT_ALL_FIBS = -0x1
- RT_CACHING_CONTEXT = 0x1
- RT_DEFAULT_FIB = 0x0
- RT_NORTREF = 0x2
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- RUSAGE_THREAD = 0x1
- SCM_BINTIME = 0x4
- SCM_CREDS = 0x3
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x2
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDMULTI = 0x80206931
- SIOCADDRT = 0x8030720a
- SIOCAIFADDR = 0x8040691a
- SIOCAIFGROUP = 0x80246987
- SIOCALIFADDR = 0x8118691b
- SIOCATMARK = 0x40047307
- SIOCDELMULTI = 0x80206932
- SIOCDELRT = 0x8030720b
- SIOCDIFADDR = 0x80206919
- SIOCDIFGROUP = 0x80246989
- SIOCDIFPHYADDR = 0x80206949
- SIOCDLIFADDR = 0x8118691d
- SIOCGDRVSPEC = 0xc01c697b
- SIOCGETSGCNT = 0xc0147210
- SIOCGETVIFCNT = 0xc014720f
- SIOCGHIWAT = 0x40047301
- SIOCGIFADDR = 0xc0206921
- SIOCGIFBRDADDR = 0xc0206923
- SIOCGIFCAP = 0xc020691f
- SIOCGIFCONF = 0xc0086924
- SIOCGIFDESCR = 0xc020692a
- SIOCGIFDSTADDR = 0xc0206922
- SIOCGIFFIB = 0xc020695c
- SIOCGIFFLAGS = 0xc0206911
- SIOCGIFGENERIC = 0xc020693a
- SIOCGIFGMEMB = 0xc024698a
- SIOCGIFGROUP = 0xc0246988
- SIOCGIFINDEX = 0xc0206920
- SIOCGIFMAC = 0xc0206926
- SIOCGIFMEDIA = 0xc0286938
- SIOCGIFMETRIC = 0xc0206917
- SIOCGIFMTU = 0xc0206933
- SIOCGIFNETMASK = 0xc0206925
- SIOCGIFPDSTADDR = 0xc0206948
- SIOCGIFPHYS = 0xc0206935
- SIOCGIFPSRCADDR = 0xc0206947
- SIOCGIFSTATUS = 0xc331693b
- SIOCGLIFADDR = 0xc118691c
- SIOCGLIFPHYADDR = 0xc118694b
- SIOCGLOWAT = 0x40047303
- SIOCGPGRP = 0x40047309
- SIOCGPRIVATE_0 = 0xc0206950
- SIOCGPRIVATE_1 = 0xc0206951
- SIOCIFCREATE = 0xc020697a
- SIOCIFCREATE2 = 0xc020697c
- SIOCIFDESTROY = 0x80206979
- SIOCIFGCLONERS = 0xc00c6978
- SIOCSDRVSPEC = 0x801c697b
- SIOCSHIWAT = 0x80047300
- SIOCSIFADDR = 0x8020690c
- SIOCSIFBRDADDR = 0x80206913
- SIOCSIFCAP = 0x8020691e
- SIOCSIFDESCR = 0x80206929
- SIOCSIFDSTADDR = 0x8020690e
- SIOCSIFFIB = 0x8020695d
- SIOCSIFFLAGS = 0x80206910
- SIOCSIFGENERIC = 0x80206939
- SIOCSIFLLADDR = 0x8020693c
- SIOCSIFMAC = 0x80206927
- SIOCSIFMEDIA = 0xc0206937
- SIOCSIFMETRIC = 0x80206918
- SIOCSIFMTU = 0x80206934
- SIOCSIFNAME = 0x80206928
- SIOCSIFNETMASK = 0x80206916
- SIOCSIFPHYADDR = 0x80406946
- SIOCSIFPHYS = 0x80206936
- SIOCSIFRVNET = 0xc020695b
- SIOCSIFVNET = 0xc020695a
- SIOCSLIFPHYADDR = 0x8118694a
- SIOCSLOWAT = 0x80047302
- SIOCSPGRP = 0x80047308
- SOCK_CLOEXEC = 0x10000000
- SOCK_DGRAM = 0x2
- SOCK_MAXADDRLEN = 0xff
- SOCK_NONBLOCK = 0x20000000
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_SOCKET = 0xffff
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x2
- SO_ACCEPTFILTER = 0x1000
- SO_BINTIME = 0x2000
- SO_BROADCAST = 0x20
- SO_DEBUG = 0x1
- SO_DONTROUTE = 0x10
- SO_ERROR = 0x1007
- SO_KEEPALIVE = 0x8
- SO_LABEL = 0x1009
- SO_LINGER = 0x80
- SO_LISTENINCQLEN = 0x1013
- SO_LISTENQLEN = 0x1012
- SO_LISTENQLIMIT = 0x1011
- SO_NOSIGPIPE = 0x800
- SO_NO_DDP = 0x8000
- SO_NO_OFFLOAD = 0x4000
- SO_OOBINLINE = 0x100
- SO_PEERLABEL = 0x1010
- SO_PROTOCOL = 0x1016
- SO_PROTOTYPE = 0x1016
- SO_RCVBUF = 0x1002
- SO_RCVLOWAT = 0x1004
- SO_RCVTIMEO = 0x1006
- SO_REUSEADDR = 0x4
- SO_REUSEPORT = 0x200
- SO_SETFIB = 0x1014
- SO_SNDBUF = 0x1001
- SO_SNDLOWAT = 0x1003
- SO_SNDTIMEO = 0x1005
- SO_TIMESTAMP = 0x400
- SO_TYPE = 0x1008
- SO_USELOOPBACK = 0x40
- SO_USER_COOKIE = 0x1015
- SO_VENDOR = 0x80000000
- TCIFLUSH = 0x1
- TCIOFLUSH = 0x3
- TCOFLUSH = 0x2
- TCP_CA_NAME_MAX = 0x10
- TCP_CONGESTION = 0x40
- TCP_INFO = 0x20
- TCP_KEEPCNT = 0x400
- TCP_KEEPIDLE = 0x100
- TCP_KEEPINIT = 0x80
- TCP_KEEPINTVL = 0x200
- TCP_MAXBURST = 0x4
- TCP_MAXHLEN = 0x3c
- TCP_MAXOLEN = 0x28
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_SACK = 0x4
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0x10
- TCP_MINMSS = 0xd8
- TCP_MSS = 0x218
- TCP_NODELAY = 0x1
- TCP_NOOPT = 0x8
- TCP_NOPUSH = 0x4
- TCP_VENDOR = 0x80000000
- TCSAFLUSH = 0x2
- TIOCCBRK = 0x2000747a
- TIOCCDTR = 0x20007478
- TIOCCONS = 0x80047462
- TIOCDRAIN = 0x2000745e
- TIOCEXCL = 0x2000740d
- TIOCEXT = 0x80047460
- TIOCFLUSH = 0x80047410
- TIOCGDRAINWAIT = 0x40047456
- TIOCGETA = 0x402c7413
- TIOCGETD = 0x4004741a
- TIOCGPGRP = 0x40047477
- TIOCGPTN = 0x4004740f
- TIOCGSID = 0x40047463
- TIOCGWINSZ = 0x40087468
- TIOCMBIC = 0x8004746b
- TIOCMBIS = 0x8004746c
- TIOCMGDTRWAIT = 0x4004745a
- TIOCMGET = 0x4004746a
- TIOCMSDTRWAIT = 0x8004745b
- TIOCMSET = 0x8004746d
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DCD = 0x40
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x20007471
- TIOCNXCL = 0x2000740e
- TIOCOUTQ = 0x40047473
- TIOCPKT = 0x80047470
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCPTMASTER = 0x2000741c
- TIOCSBRK = 0x2000747b
- TIOCSCTTY = 0x20007461
- TIOCSDRAINWAIT = 0x80047457
- TIOCSDTR = 0x20007479
- TIOCSETA = 0x802c7414
- TIOCSETAF = 0x802c7416
- TIOCSETAW = 0x802c7415
- TIOCSETD = 0x8004741b
- TIOCSIG = 0x2004745f
- TIOCSPGRP = 0x80047476
- TIOCSTART = 0x2000746e
- TIOCSTAT = 0x20007465
- TIOCSTI = 0x80017472
- TIOCSTOP = 0x2000746f
- TIOCSWINSZ = 0x80087467
- TIOCTIMESTAMP = 0x40087459
- TIOCUCNTL = 0x80047466
- TOSTOP = 0x400000
- VDISCARD = 0xf
- VDSUSP = 0xb
- VEOF = 0x0
- VEOL = 0x1
- VEOL2 = 0x2
- VERASE = 0x3
- VERASE2 = 0x7
- VINTR = 0x8
- VKILL = 0x5
- VLNEXT = 0xe
- VMIN = 0x10
- VQUIT = 0x9
- VREPRINT = 0x6
- VSTART = 0xc
- VSTATUS = 0x12
- VSTOP = 0xd
- VSUSP = 0xa
- VTIME = 0x11
- VWERASE = 0x4
- WCONTINUED = 0x4
- WCOREFLAG = 0x80
- WEXITED = 0x10
- WLINUXCLONE = 0x80000000
- WNOHANG = 0x1
- WNOWAIT = 0x8
- WSTOPPED = 0x2
- WTRAPPED = 0x20
- WUNTRACED = 0x2
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x30)
- EADDRNOTAVAIL = syscall.Errno(0x31)
- EAFNOSUPPORT = syscall.Errno(0x2f)
- EAGAIN = syscall.Errno(0x23)
- EALREADY = syscall.Errno(0x25)
- EAUTH = syscall.Errno(0x50)
- EBADF = syscall.Errno(0x9)
- EBADMSG = syscall.Errno(0x59)
- EBADRPC = syscall.Errno(0x48)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x55)
- ECAPMODE = syscall.Errno(0x5e)
- ECHILD = syscall.Errno(0xa)
- ECONNABORTED = syscall.Errno(0x35)
- ECONNREFUSED = syscall.Errno(0x3d)
- ECONNRESET = syscall.Errno(0x36)
- EDEADLK = syscall.Errno(0xb)
- EDESTADDRREQ = syscall.Errno(0x27)
- EDOM = syscall.Errno(0x21)
- EDOOFUS = syscall.Errno(0x58)
- EDQUOT = syscall.Errno(0x45)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EFTYPE = syscall.Errno(0x4f)
- EHOSTDOWN = syscall.Errno(0x40)
- EHOSTUNREACH = syscall.Errno(0x41)
- EIDRM = syscall.Errno(0x52)
- EILSEQ = syscall.Errno(0x56)
- EINPROGRESS = syscall.Errno(0x24)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x38)
- EISDIR = syscall.Errno(0x15)
- ELAST = syscall.Errno(0x60)
- ELOOP = syscall.Errno(0x3e)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x28)
- EMULTIHOP = syscall.Errno(0x5a)
- ENAMETOOLONG = syscall.Errno(0x3f)
- ENEEDAUTH = syscall.Errno(0x51)
- ENETDOWN = syscall.Errno(0x32)
- ENETRESET = syscall.Errno(0x34)
- ENETUNREACH = syscall.Errno(0x33)
- ENFILE = syscall.Errno(0x17)
- ENOATTR = syscall.Errno(0x57)
- ENOBUFS = syscall.Errno(0x37)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOLCK = syscall.Errno(0x4d)
- ENOLINK = syscall.Errno(0x5b)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x53)
- ENOPROTOOPT = syscall.Errno(0x2a)
- ENOSPC = syscall.Errno(0x1c)
- ENOSYS = syscall.Errno(0x4e)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCAPABLE = syscall.Errno(0x5d)
- ENOTCONN = syscall.Errno(0x39)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x42)
- ENOTRECOVERABLE = syscall.Errno(0x5f)
- ENOTSOCK = syscall.Errno(0x26)
- ENOTSUP = syscall.Errno(0x2d)
- ENOTTY = syscall.Errno(0x19)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x2d)
- EOVERFLOW = syscall.Errno(0x54)
- EOWNERDEAD = syscall.Errno(0x60)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x2e)
- EPIPE = syscall.Errno(0x20)
- EPROCLIM = syscall.Errno(0x43)
- EPROCUNAVAIL = syscall.Errno(0x4c)
- EPROGMISMATCH = syscall.Errno(0x4b)
- EPROGUNAVAIL = syscall.Errno(0x4a)
- EPROTO = syscall.Errno(0x5c)
- EPROTONOSUPPORT = syscall.Errno(0x2b)
- EPROTOTYPE = syscall.Errno(0x29)
- ERANGE = syscall.Errno(0x22)
- EREMOTE = syscall.Errno(0x47)
- EROFS = syscall.Errno(0x1e)
- ERPCMISMATCH = syscall.Errno(0x49)
- ESHUTDOWN = syscall.Errno(0x3a)
- ESOCKTNOSUPPORT = syscall.Errno(0x2c)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESTALE = syscall.Errno(0x46)
- ETIMEDOUT = syscall.Errno(0x3c)
- ETOOMANYREFS = syscall.Errno(0x3b)
- ETXTBSY = syscall.Errno(0x1a)
- EUSERS = syscall.Errno(0x44)
- EWOULDBLOCK = syscall.Errno(0x23)
- EXDEV = syscall.Errno(0x12)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0xa)
- SIGCHLD = syscall.Signal(0x14)
- SIGCONT = syscall.Signal(0x13)
- SIGEMT = syscall.Signal(0x7)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINFO = syscall.Signal(0x1d)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x17)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGLIBRT = syscall.Signal(0x21)
- SIGLWP = syscall.Signal(0x20)
- SIGPIPE = syscall.Signal(0xd)
- SIGPROF = syscall.Signal(0x1b)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTOP = syscall.Signal(0x11)
- SIGSYS = syscall.Signal(0xc)
- SIGTERM = syscall.Signal(0xf)
- SIGTHR = syscall.Signal(0x20)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x12)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGURG = syscall.Signal(0x10)
- SIGUSR1 = syscall.Signal(0x1e)
- SIGUSR2 = syscall.Signal(0x1f)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "device not configured",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource deadlock avoided",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device busy",
- 17: "file exists",
- 18: "cross-device link",
- 19: "operation not supported by device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "result too large",
- 35: "resource temporarily unavailable",
- 36: "operation now in progress",
- 37: "operation already in progress",
- 38: "socket operation on non-socket",
- 39: "destination address required",
- 40: "message too long",
- 41: "protocol wrong type for socket",
- 42: "protocol not available",
- 43: "protocol not supported",
- 44: "socket type not supported",
- 45: "operation not supported",
- 46: "protocol family not supported",
- 47: "address family not supported by protocol family",
- 48: "address already in use",
- 49: "can't assign requested address",
- 50: "network is down",
- 51: "network is unreachable",
- 52: "network dropped connection on reset",
- 53: "software caused connection abort",
- 54: "connection reset by peer",
- 55: "no buffer space available",
- 56: "socket is already connected",
- 57: "socket is not connected",
- 58: "can't send after socket shutdown",
- 59: "too many references: can't splice",
- 60: "operation timed out",
- 61: "connection refused",
- 62: "too many levels of symbolic links",
- 63: "file name too long",
- 64: "host is down",
- 65: "no route to host",
- 66: "directory not empty",
- 67: "too many processes",
- 68: "too many users",
- 69: "disc quota exceeded",
- 70: "stale NFS file handle",
- 71: "too many levels of remote in path",
- 72: "RPC struct is bad",
- 73: "RPC version wrong",
- 74: "RPC prog. not avail",
- 75: "program version wrong",
- 76: "bad procedure for program",
- 77: "no locks available",
- 78: "function not implemented",
- 79: "inappropriate file type or format",
- 80: "authentication error",
- 81: "need authenticator",
- 82: "identifier removed",
- 83: "no message of desired type",
- 84: "value too large to be stored in data type",
- 85: "operation canceled",
- 86: "illegal byte sequence",
- 87: "attribute not found",
- 88: "programming error",
- 89: "bad message",
- 90: "multihop attempted",
- 91: "link has been severed",
- 92: "protocol error",
- 93: "capabilities insufficient",
- 94: "not permitted in capability mode",
- 95: "state not recoverable",
- 96: "previous owner died",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/BPT trap",
- 6: "abort trap",
- 7: "EMT trap",
- 8: "floating point exception",
- 9: "killed",
- 10: "bus error",
- 11: "segmentation fault",
- 12: "bad system call",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "urgent I/O condition",
- 17: "suspended (signal)",
- 18: "suspended",
- 19: "continued",
- 20: "child exited",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "I/O possible",
- 24: "cputime limit exceeded",
- 25: "filesize limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window size changes",
- 29: "information request",
- 30: "user defined signal 1",
- 31: "user defined signal 2",
- 32: "unknown signal",
- 33: "unknown signal",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/newt/vendor/golang.org/x/sys/unix/zerrors_linux_386.go
deleted file mode 100644
index 8f920124..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_386.go
+++ /dev/null
@@ -1,1819 +0,0 @@
-// mkerrors.sh -m32
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build 386,linux
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -m32 _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_ALG = 0x26
- AF_APPLETALK = 0x5
- AF_ASH = 0x12
- AF_ATMPVC = 0x8
- AF_ATMSVC = 0x14
- AF_AX25 = 0x3
- AF_BLUETOOTH = 0x1f
- AF_BRIDGE = 0x7
- AF_CAIF = 0x25
- AF_CAN = 0x1d
- AF_DECnet = 0xc
- AF_ECONET = 0x13
- AF_FILE = 0x1
- AF_IEEE802154 = 0x24
- AF_INET = 0x2
- AF_INET6 = 0xa
- AF_IPX = 0x4
- AF_IRDA = 0x17
- AF_ISDN = 0x22
- AF_IUCV = 0x20
- AF_KEY = 0xf
- AF_LLC = 0x1a
- AF_LOCAL = 0x1
- AF_MAX = 0x28
- AF_NETBEUI = 0xd
- AF_NETLINK = 0x10
- AF_NETROM = 0x6
- AF_NFC = 0x27
- AF_PACKET = 0x11
- AF_PHONET = 0x23
- AF_PPPOX = 0x18
- AF_RDS = 0x15
- AF_ROSE = 0xb
- AF_ROUTE = 0x10
- AF_RXRPC = 0x21
- AF_SECURITY = 0xe
- AF_SNA = 0x16
- AF_TIPC = 0x1e
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_WANPIPE = 0x19
- AF_X25 = 0x9
- ARPHRD_ADAPT = 0x108
- ARPHRD_APPLETLK = 0x8
- ARPHRD_ARCNET = 0x7
- ARPHRD_ASH = 0x30d
- ARPHRD_ATM = 0x13
- ARPHRD_AX25 = 0x3
- ARPHRD_BIF = 0x307
- ARPHRD_CAIF = 0x336
- ARPHRD_CAN = 0x118
- ARPHRD_CHAOS = 0x5
- ARPHRD_CISCO = 0x201
- ARPHRD_CSLIP = 0x101
- ARPHRD_CSLIP6 = 0x103
- ARPHRD_DDCMP = 0x205
- ARPHRD_DLCI = 0xf
- ARPHRD_ECONET = 0x30e
- ARPHRD_EETHER = 0x2
- ARPHRD_ETHER = 0x1
- ARPHRD_EUI64 = 0x1b
- ARPHRD_FCAL = 0x311
- ARPHRD_FCFABRIC = 0x313
- ARPHRD_FCPL = 0x312
- ARPHRD_FCPP = 0x310
- ARPHRD_FDDI = 0x306
- ARPHRD_FRAD = 0x302
- ARPHRD_HDLC = 0x201
- ARPHRD_HIPPI = 0x30c
- ARPHRD_HWX25 = 0x110
- ARPHRD_IEEE1394 = 0x18
- ARPHRD_IEEE802 = 0x6
- ARPHRD_IEEE80211 = 0x321
- ARPHRD_IEEE80211_PRISM = 0x322
- ARPHRD_IEEE80211_RADIOTAP = 0x323
- ARPHRD_IEEE802154 = 0x324
- ARPHRD_IEEE802_TR = 0x320
- ARPHRD_INFINIBAND = 0x20
- ARPHRD_IPDDP = 0x309
- ARPHRD_IPGRE = 0x30a
- ARPHRD_IRDA = 0x30f
- ARPHRD_LAPB = 0x204
- ARPHRD_LOCALTLK = 0x305
- ARPHRD_LOOPBACK = 0x304
- ARPHRD_METRICOM = 0x17
- ARPHRD_NETROM = 0x0
- ARPHRD_NONE = 0xfffe
- ARPHRD_PHONET = 0x334
- ARPHRD_PHONET_PIPE = 0x335
- ARPHRD_PIMREG = 0x30b
- ARPHRD_PPP = 0x200
- ARPHRD_PRONET = 0x4
- ARPHRD_RAWHDLC = 0x206
- ARPHRD_ROSE = 0x10e
- ARPHRD_RSRVD = 0x104
- ARPHRD_SIT = 0x308
- ARPHRD_SKIP = 0x303
- ARPHRD_SLIP = 0x100
- ARPHRD_SLIP6 = 0x102
- ARPHRD_TUNNEL = 0x300
- ARPHRD_TUNNEL6 = 0x301
- ARPHRD_VOID = 0xffff
- ARPHRD_X25 = 0x10f
- B0 = 0x0
- B1000000 = 0x1008
- B110 = 0x3
- B115200 = 0x1002
- B1152000 = 0x1009
- B1200 = 0x9
- B134 = 0x4
- B150 = 0x5
- B1500000 = 0x100a
- B1800 = 0xa
- B19200 = 0xe
- B200 = 0x6
- B2000000 = 0x100b
- B230400 = 0x1003
- B2400 = 0xb
- B2500000 = 0x100c
- B300 = 0x7
- B3000000 = 0x100d
- B3500000 = 0x100e
- B38400 = 0xf
- B4000000 = 0x100f
- B460800 = 0x1004
- B4800 = 0xc
- B50 = 0x1
- B500000 = 0x1005
- B57600 = 0x1001
- B576000 = 0x1006
- B600 = 0x8
- B75 = 0x2
- B921600 = 0x1007
- B9600 = 0xd
- BOTHER = 0x1000
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXINSNS = 0x1000
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BRKINT = 0x2
- BS0 = 0x0
- BS1 = 0x2000
- BSDLY = 0x2000
- CBAUD = 0x100f
- CBAUDEX = 0x1000
- CFLUSH = 0xf
- CIBAUD = 0x100f0000
- CLOCAL = 0x800
- CLOCK_BOOTTIME = 0x7
- CLOCK_BOOTTIME_ALARM = 0x9
- CLOCK_DEFAULT = 0x0
- CLOCK_EXT = 0x1
- CLOCK_INT = 0x2
- CLOCK_MONOTONIC = 0x1
- CLOCK_MONOTONIC_COARSE = 0x6
- CLOCK_MONOTONIC_RAW = 0x4
- CLOCK_PROCESS_CPUTIME_ID = 0x2
- CLOCK_REALTIME = 0x0
- CLOCK_REALTIME_ALARM = 0x8
- CLOCK_REALTIME_COARSE = 0x5
- CLOCK_THREAD_CPUTIME_ID = 0x3
- CLOCK_TXFROMRX = 0x4
- CLOCK_TXINT = 0x3
- CLONE_CHILD_CLEARTID = 0x200000
- CLONE_CHILD_SETTID = 0x1000000
- CLONE_DETACHED = 0x400000
- CLONE_FILES = 0x400
- CLONE_FS = 0x200
- CLONE_IO = 0x80000000
- CLONE_NEWCGROUP = 0x2000000
- CLONE_NEWIPC = 0x8000000
- CLONE_NEWNET = 0x40000000
- CLONE_NEWNS = 0x20000
- CLONE_NEWPID = 0x20000000
- CLONE_NEWUSER = 0x10000000
- CLONE_NEWUTS = 0x4000000
- CLONE_PARENT = 0x8000
- CLONE_PARENT_SETTID = 0x100000
- CLONE_PTRACE = 0x2000
- CLONE_SETTLS = 0x80000
- CLONE_SIGHAND = 0x800
- CLONE_SYSVSEM = 0x40000
- CLONE_THREAD = 0x10000
- CLONE_UNTRACED = 0x800000
- CLONE_VFORK = 0x4000
- CLONE_VM = 0x100
- CMSPAR = 0x40000000
- CR0 = 0x0
- CR1 = 0x200
- CR2 = 0x400
- CR3 = 0x600
- CRDLY = 0x600
- CREAD = 0x80
- CRTSCTS = 0x80000000
- CS5 = 0x0
- CS6 = 0x10
- CS7 = 0x20
- CS8 = 0x30
- CSIGNAL = 0xff
- CSIZE = 0x30
- CSTART = 0x11
- CSTATUS = 0x0
- CSTOP = 0x13
- CSTOPB = 0x40
- CSUSP = 0x1a
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x200
- ECHOE = 0x10
- ECHOK = 0x20
- ECHOKE = 0x800
- ECHONL = 0x40
- ECHOPRT = 0x400
- ENCODING_DEFAULT = 0x0
- ENCODING_FM_MARK = 0x3
- ENCODING_FM_SPACE = 0x4
- ENCODING_MANCHESTER = 0x5
- ENCODING_NRZ = 0x1
- ENCODING_NRZI = 0x2
- EPOLLERR = 0x8
- EPOLLET = 0x80000000
- EPOLLHUP = 0x10
- EPOLLIN = 0x1
- EPOLLMSG = 0x400
- EPOLLONESHOT = 0x40000000
- EPOLLOUT = 0x4
- EPOLLPRI = 0x2
- EPOLLRDBAND = 0x80
- EPOLLRDHUP = 0x2000
- EPOLLRDNORM = 0x40
- EPOLLWRBAND = 0x200
- EPOLLWRNORM = 0x100
- EPOLL_CLOEXEC = 0x80000
- EPOLL_CTL_ADD = 0x1
- EPOLL_CTL_DEL = 0x2
- EPOLL_CTL_MOD = 0x3
- EPOLL_NONBLOCK = 0x800
- ETH_P_1588 = 0x88f7
- ETH_P_8021AD = 0x88a8
- ETH_P_8021AH = 0x88e7
- ETH_P_8021Q = 0x8100
- ETH_P_802_2 = 0x4
- ETH_P_802_3 = 0x1
- ETH_P_AARP = 0x80f3
- ETH_P_AF_IUCV = 0xfbfb
- ETH_P_ALL = 0x3
- ETH_P_AOE = 0x88a2
- ETH_P_ARCNET = 0x1a
- ETH_P_ARP = 0x806
- ETH_P_ATALK = 0x809b
- ETH_P_ATMFATE = 0x8884
- ETH_P_ATMMPOA = 0x884c
- ETH_P_AX25 = 0x2
- ETH_P_BPQ = 0x8ff
- ETH_P_CAIF = 0xf7
- ETH_P_CAN = 0xc
- ETH_P_CONTROL = 0x16
- ETH_P_CUST = 0x6006
- ETH_P_DDCMP = 0x6
- ETH_P_DEC = 0x6000
- ETH_P_DIAG = 0x6005
- ETH_P_DNA_DL = 0x6001
- ETH_P_DNA_RC = 0x6002
- ETH_P_DNA_RT = 0x6003
- ETH_P_DSA = 0x1b
- ETH_P_ECONET = 0x18
- ETH_P_EDSA = 0xdada
- ETH_P_FCOE = 0x8906
- ETH_P_FIP = 0x8914
- ETH_P_HDLC = 0x19
- ETH_P_IEEE802154 = 0xf6
- ETH_P_IEEEPUP = 0xa00
- ETH_P_IEEEPUPAT = 0xa01
- ETH_P_IP = 0x800
- ETH_P_IPV6 = 0x86dd
- ETH_P_IPX = 0x8137
- ETH_P_IRDA = 0x17
- ETH_P_LAT = 0x6004
- ETH_P_LINK_CTL = 0x886c
- ETH_P_LOCALTALK = 0x9
- ETH_P_LOOP = 0x60
- ETH_P_MOBITEX = 0x15
- ETH_P_MPLS_MC = 0x8848
- ETH_P_MPLS_UC = 0x8847
- ETH_P_PAE = 0x888e
- ETH_P_PAUSE = 0x8808
- ETH_P_PHONET = 0xf5
- ETH_P_PPPTALK = 0x10
- ETH_P_PPP_DISC = 0x8863
- ETH_P_PPP_MP = 0x8
- ETH_P_PPP_SES = 0x8864
- ETH_P_PUP = 0x200
- ETH_P_PUPAT = 0x201
- ETH_P_QINQ1 = 0x9100
- ETH_P_QINQ2 = 0x9200
- ETH_P_QINQ3 = 0x9300
- ETH_P_RARP = 0x8035
- ETH_P_SCA = 0x6007
- ETH_P_SLOW = 0x8809
- ETH_P_SNAP = 0x5
- ETH_P_TDLS = 0x890d
- ETH_P_TEB = 0x6558
- ETH_P_TIPC = 0x88ca
- ETH_P_TRAILER = 0x1c
- ETH_P_TR_802_2 = 0x11
- ETH_P_WAN_PPP = 0x7
- ETH_P_WCCP = 0x883e
- ETH_P_X25 = 0x805
- EXTA = 0xe
- EXTB = 0xf
- EXTPROC = 0x10000
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FF0 = 0x0
- FF1 = 0x8000
- FFDLY = 0x8000
- FLUSHO = 0x1000
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x406
- F_EXLCK = 0x4
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLEASE = 0x401
- F_GETLK = 0xc
- F_GETLK64 = 0xc
- F_GETOWN = 0x9
- F_GETOWN_EX = 0x10
- F_GETPIPE_SZ = 0x408
- F_GETSIG = 0xb
- F_LOCK = 0x1
- F_NOTIFY = 0x402
- F_OK = 0x0
- F_RDLCK = 0x0
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLEASE = 0x400
- F_SETLK = 0xd
- F_SETLK64 = 0xd
- F_SETLKW = 0xe
- F_SETLKW64 = 0xe
- F_SETOWN = 0x8
- F_SETOWN_EX = 0xf
- F_SETPIPE_SZ = 0x407
- F_SETSIG = 0xa
- F_SHLCK = 0x8
- F_TEST = 0x3
- F_TLOCK = 0x2
- F_ULOCK = 0x0
- F_UNLCK = 0x2
- F_WRLCK = 0x1
- HUPCL = 0x400
- IBSHIFT = 0x10
- ICANON = 0x2
- ICMPV6_FILTER = 0x1
- ICRNL = 0x100
- IEXTEN = 0x8000
- IFA_F_DADFAILED = 0x8
- IFA_F_DEPRECATED = 0x20
- IFA_F_HOMEADDRESS = 0x10
- IFA_F_NODAD = 0x2
- IFA_F_OPTIMISTIC = 0x4
- IFA_F_PERMANENT = 0x80
- IFA_F_SECONDARY = 0x1
- IFA_F_TEMPORARY = 0x1
- IFA_F_TENTATIVE = 0x40
- IFA_MAX = 0x7
- IFF_802_1Q_VLAN = 0x1
- IFF_ALLMULTI = 0x200
- IFF_AUTOMEDIA = 0x4000
- IFF_BONDING = 0x20
- IFF_BRIDGE_PORT = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_DISABLE_NETPOLL = 0x1000
- IFF_DONT_BRIDGE = 0x800
- IFF_DORMANT = 0x20000
- IFF_DYNAMIC = 0x8000
- IFF_EBRIDGE = 0x2
- IFF_ECHO = 0x40000
- IFF_ISATAP = 0x80
- IFF_LOOPBACK = 0x8
- IFF_LOWER_UP = 0x10000
- IFF_MACVLAN_PORT = 0x2000
- IFF_MASTER = 0x400
- IFF_MASTER_8023AD = 0x8
- IFF_MASTER_ALB = 0x10
- IFF_MASTER_ARPMON = 0x100
- IFF_MULTICAST = 0x1000
- IFF_NOARP = 0x80
- IFF_NOTRAILERS = 0x20
- IFF_NO_PI = 0x1000
- IFF_ONE_QUEUE = 0x2000
- IFF_OVS_DATAPATH = 0x8000
- IFF_POINTOPOINT = 0x10
- IFF_PORTSEL = 0x2000
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SLAVE = 0x800
- IFF_SLAVE_INACTIVE = 0x4
- IFF_SLAVE_NEEDARP = 0x40
- IFF_TAP = 0x2
- IFF_TUN = 0x1
- IFF_TUN_EXCL = 0x8000
- IFF_TX_SKB_SHARING = 0x10000
- IFF_UNICAST_FLT = 0x20000
- IFF_UP = 0x1
- IFF_VNET_HDR = 0x4000
- IFF_VOLATILE = 0x70c5a
- IFF_WAN_HDLC = 0x200
- IFF_XMIT_DST_RELEASE = 0x400
- IFNAMSIZ = 0x10
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_ACCESS = 0x1
- IN_ALL_EVENTS = 0xfff
- IN_ATTRIB = 0x4
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLOEXEC = 0x80000
- IN_CLOSE = 0x18
- IN_CLOSE_NOWRITE = 0x10
- IN_CLOSE_WRITE = 0x8
- IN_CREATE = 0x100
- IN_DELETE = 0x200
- IN_DELETE_SELF = 0x400
- IN_DONT_FOLLOW = 0x2000000
- IN_EXCL_UNLINK = 0x4000000
- IN_IGNORED = 0x8000
- IN_ISDIR = 0x40000000
- IN_LOOPBACKNET = 0x7f
- IN_MASK_ADD = 0x20000000
- IN_MODIFY = 0x2
- IN_MOVE = 0xc0
- IN_MOVED_FROM = 0x40
- IN_MOVED_TO = 0x80
- IN_MOVE_SELF = 0x800
- IN_NONBLOCK = 0x800
- IN_ONESHOT = 0x80000000
- IN_ONLYDIR = 0x1000000
- IN_OPEN = 0x20
- IN_Q_OVERFLOW = 0x4000
- IN_UNMOUNT = 0x2000
- IPPROTO_AH = 0x33
- IPPROTO_COMP = 0x6c
- IPPROTO_DCCP = 0x21
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_ENCAP = 0x62
- IPPROTO_ESP = 0x32
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GRE = 0x2f
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IGMP = 0x2
- IPPROTO_IP = 0x0
- IPPROTO_IPIP = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_MTP = 0x5c
- IPPROTO_NONE = 0x3b
- IPPROTO_PIM = 0x67
- IPPROTO_PUP = 0xc
- IPPROTO_RAW = 0xff
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_SCTP = 0x84
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_UDP = 0x11
- IPPROTO_UDPLITE = 0x88
- IPV6_2292DSTOPTS = 0x4
- IPV6_2292HOPLIMIT = 0x8
- IPV6_2292HOPOPTS = 0x3
- IPV6_2292PKTINFO = 0x2
- IPV6_2292PKTOPTIONS = 0x6
- IPV6_2292RTHDR = 0x5
- IPV6_ADDRFORM = 0x1
- IPV6_ADD_MEMBERSHIP = 0x14
- IPV6_AUTHHDR = 0xa
- IPV6_CHECKSUM = 0x7
- IPV6_DROP_MEMBERSHIP = 0x15
- IPV6_DSTOPTS = 0x3b
- IPV6_HOPLIMIT = 0x34
- IPV6_HOPOPTS = 0x36
- IPV6_IPSEC_POLICY = 0x22
- IPV6_JOIN_ANYCAST = 0x1b
- IPV6_JOIN_GROUP = 0x14
- IPV6_LEAVE_ANYCAST = 0x1c
- IPV6_LEAVE_GROUP = 0x15
- IPV6_MTU = 0x18
- IPV6_MTU_DISCOVER = 0x17
- IPV6_MULTICAST_HOPS = 0x12
- IPV6_MULTICAST_IF = 0x11
- IPV6_MULTICAST_LOOP = 0x13
- IPV6_NEXTHOP = 0x9
- IPV6_PKTINFO = 0x32
- IPV6_PMTUDISC_DO = 0x2
- IPV6_PMTUDISC_DONT = 0x0
- IPV6_PMTUDISC_PROBE = 0x3
- IPV6_PMTUDISC_WANT = 0x1
- IPV6_RECVDSTOPTS = 0x3a
- IPV6_RECVERR = 0x19
- IPV6_RECVHOPLIMIT = 0x33
- IPV6_RECVHOPOPTS = 0x35
- IPV6_RECVPKTINFO = 0x31
- IPV6_RECVRTHDR = 0x38
- IPV6_RECVTCLASS = 0x42
- IPV6_ROUTER_ALERT = 0x16
- IPV6_RTHDR = 0x39
- IPV6_RTHDRDSTOPTS = 0x37
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_RXDSTOPTS = 0x3b
- IPV6_RXHOPOPTS = 0x36
- IPV6_TCLASS = 0x43
- IPV6_UNICAST_HOPS = 0x10
- IPV6_V6ONLY = 0x1a
- IPV6_XFRM_POLICY = 0x23
- IP_ADD_MEMBERSHIP = 0x23
- IP_ADD_SOURCE_MEMBERSHIP = 0x27
- IP_BLOCK_SOURCE = 0x26
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0x24
- IP_DROP_SOURCE_MEMBERSHIP = 0x28
- IP_FREEBIND = 0xf
- IP_HDRINCL = 0x3
- IP_IPSEC_POLICY = 0x10
- IP_MAXPACKET = 0xffff
- IP_MAX_MEMBERSHIPS = 0x14
- IP_MF = 0x2000
- IP_MINTTL = 0x15
- IP_MSFILTER = 0x29
- IP_MSS = 0x240
- IP_MTU = 0xe
- IP_MTU_DISCOVER = 0xa
- IP_MULTICAST_ALL = 0x31
- IP_MULTICAST_IF = 0x20
- IP_MULTICAST_LOOP = 0x22
- IP_MULTICAST_TTL = 0x21
- IP_OFFMASK = 0x1fff
- IP_OPTIONS = 0x4
- IP_ORIGDSTADDR = 0x14
- IP_PASSSEC = 0x12
- IP_PKTINFO = 0x8
- IP_PKTOPTIONS = 0x9
- IP_PMTUDISC = 0xa
- IP_PMTUDISC_DO = 0x2
- IP_PMTUDISC_DONT = 0x0
- IP_PMTUDISC_PROBE = 0x3
- IP_PMTUDISC_WANT = 0x1
- IP_RECVERR = 0xb
- IP_RECVOPTS = 0x6
- IP_RECVORIGDSTADDR = 0x14
- IP_RECVRETOPTS = 0x7
- IP_RECVTOS = 0xd
- IP_RECVTTL = 0xc
- IP_RETOPTS = 0x7
- IP_RF = 0x8000
- IP_ROUTER_ALERT = 0x5
- IP_TOS = 0x1
- IP_TRANSPARENT = 0x13
- IP_TTL = 0x2
- IP_UNBLOCK_SOURCE = 0x25
- IP_XFRM_POLICY = 0x11
- ISIG = 0x1
- ISTRIP = 0x20
- IUCLC = 0x200
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x1000
- IXON = 0x400
- LINUX_REBOOT_CMD_CAD_OFF = 0x0
- LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
- LINUX_REBOOT_CMD_HALT = 0xcdef0123
- LINUX_REBOOT_CMD_KEXEC = 0x45584543
- LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
- LINUX_REBOOT_CMD_RESTART = 0x1234567
- LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
- LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
- LINUX_REBOOT_MAGIC1 = 0xfee1dead
- LINUX_REBOOT_MAGIC2 = 0x28121969
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_DOFORK = 0xb
- MADV_DONTFORK = 0xa
- MADV_DONTNEED = 0x4
- MADV_HUGEPAGE = 0xe
- MADV_HWPOISON = 0x64
- MADV_MERGEABLE = 0xc
- MADV_NOHUGEPAGE = 0xf
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_REMOVE = 0x9
- MADV_SEQUENTIAL = 0x2
- MADV_UNMERGEABLE = 0xd
- MADV_WILLNEED = 0x3
- MAP_32BIT = 0x40
- MAP_ANON = 0x20
- MAP_ANONYMOUS = 0x20
- MAP_DENYWRITE = 0x800
- MAP_EXECUTABLE = 0x1000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_GROWSDOWN = 0x100
- MAP_HUGETLB = 0x40000
- MAP_LOCKED = 0x2000
- MAP_NONBLOCK = 0x10000
- MAP_NORESERVE = 0x4000
- MAP_POPULATE = 0x8000
- MAP_PRIVATE = 0x2
- MAP_SHARED = 0x1
- MAP_STACK = 0x20000
- MAP_TYPE = 0xf
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MNT_DETACH = 0x2
- MNT_EXPIRE = 0x4
- MNT_FORCE = 0x1
- MSG_CMSG_CLOEXEC = 0x40000000
- MSG_CONFIRM = 0x800
- MSG_CTRUNC = 0x8
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x40
- MSG_EOR = 0x80
- MSG_ERRQUEUE = 0x2000
- MSG_FASTOPEN = 0x20000000
- MSG_FIN = 0x200
- MSG_MORE = 0x8000
- MSG_NOSIGNAL = 0x4000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_PROXY = 0x10
- MSG_RST = 0x1000
- MSG_SYN = 0x400
- MSG_TRUNC = 0x20
- MSG_TRYHARD = 0x4
- MSG_WAITALL = 0x100
- MSG_WAITFORONE = 0x10000
- MS_ACTIVE = 0x40000000
- MS_ASYNC = 0x1
- MS_BIND = 0x1000
- MS_DIRSYNC = 0x80
- MS_INVALIDATE = 0x2
- MS_I_VERSION = 0x800000
- MS_KERNMOUNT = 0x400000
- MS_MANDLOCK = 0x40
- MS_MGC_MSK = 0xffff0000
- MS_MGC_VAL = 0xc0ed0000
- MS_MOVE = 0x2000
- MS_NOATIME = 0x400
- MS_NODEV = 0x4
- MS_NODIRATIME = 0x800
- MS_NOEXEC = 0x8
- MS_NOSUID = 0x2
- MS_NOUSER = -0x80000000
- MS_POSIXACL = 0x10000
- MS_PRIVATE = 0x40000
- MS_RDONLY = 0x1
- MS_REC = 0x4000
- MS_RELATIME = 0x200000
- MS_REMOUNT = 0x20
- MS_RMT_MASK = 0x800051
- MS_SHARED = 0x100000
- MS_SILENT = 0x8000
- MS_SLAVE = 0x80000
- MS_STRICTATIME = 0x1000000
- MS_SYNC = 0x4
- MS_SYNCHRONOUS = 0x10
- MS_UNBINDABLE = 0x20000
- NAME_MAX = 0xff
- NETLINK_ADD_MEMBERSHIP = 0x1
- NETLINK_AUDIT = 0x9
- NETLINK_BROADCAST_ERROR = 0x4
- NETLINK_CONNECTOR = 0xb
- NETLINK_CRYPTO = 0x15
- NETLINK_DNRTMSG = 0xe
- NETLINK_DROP_MEMBERSHIP = 0x2
- NETLINK_ECRYPTFS = 0x13
- NETLINK_FIB_LOOKUP = 0xa
- NETLINK_FIREWALL = 0x3
- NETLINK_GENERIC = 0x10
- NETLINK_INET_DIAG = 0x4
- NETLINK_IP6_FW = 0xd
- NETLINK_ISCSI = 0x8
- NETLINK_KOBJECT_UEVENT = 0xf
- NETLINK_NETFILTER = 0xc
- NETLINK_NFLOG = 0x5
- NETLINK_NO_ENOBUFS = 0x5
- NETLINK_PKTINFO = 0x3
- NETLINK_RDMA = 0x14
- NETLINK_ROUTE = 0x0
- NETLINK_SCSITRANSPORT = 0x12
- NETLINK_SELINUX = 0x7
- NETLINK_UNUSED = 0x1
- NETLINK_USERSOCK = 0x2
- NETLINK_XFRM = 0x6
- NL0 = 0x0
- NL1 = 0x100
- NLA_ALIGNTO = 0x4
- NLA_F_NESTED = 0x8000
- NLA_F_NET_BYTEORDER = 0x4000
- NLA_HDRLEN = 0x4
- NLDLY = 0x100
- NLMSG_ALIGNTO = 0x4
- NLMSG_DONE = 0x3
- NLMSG_ERROR = 0x2
- NLMSG_HDRLEN = 0x10
- NLMSG_MIN_TYPE = 0x10
- NLMSG_NOOP = 0x1
- NLMSG_OVERRUN = 0x4
- NLM_F_ACK = 0x4
- NLM_F_APPEND = 0x800
- NLM_F_ATOMIC = 0x400
- NLM_F_CREATE = 0x400
- NLM_F_DUMP = 0x300
- NLM_F_DUMP_INTR = 0x10
- NLM_F_ECHO = 0x8
- NLM_F_EXCL = 0x200
- NLM_F_MATCH = 0x200
- NLM_F_MULTI = 0x2
- NLM_F_REPLACE = 0x100
- NLM_F_REQUEST = 0x1
- NLM_F_ROOT = 0x100
- NOFLSH = 0x80
- OCRNL = 0x8
- OFDEL = 0x80
- OFILL = 0x40
- OLCUC = 0x2
- ONLCR = 0x4
- ONLRET = 0x20
- ONOCR = 0x10
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x400
- O_ASYNC = 0x2000
- O_CLOEXEC = 0x80000
- O_CREAT = 0x40
- O_DIRECT = 0x4000
- O_DIRECTORY = 0x10000
- O_DSYNC = 0x1000
- O_EXCL = 0x80
- O_FSYNC = 0x101000
- O_LARGEFILE = 0x8000
- O_NDELAY = 0x800
- O_NOATIME = 0x40000
- O_NOCTTY = 0x100
- O_NOFOLLOW = 0x20000
- O_NONBLOCK = 0x800
- O_PATH = 0x200000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_RSYNC = 0x101000
- O_SYNC = 0x101000
- O_TMPFILE = 0x410000
- O_TRUNC = 0x200
- O_WRONLY = 0x1
- PACKET_ADD_MEMBERSHIP = 0x1
- PACKET_AUXDATA = 0x8
- PACKET_BROADCAST = 0x1
- PACKET_COPY_THRESH = 0x7
- PACKET_DROP_MEMBERSHIP = 0x2
- PACKET_FANOUT = 0x12
- PACKET_FANOUT_CPU = 0x2
- PACKET_FANOUT_FLAG_DEFRAG = 0x8000
- PACKET_FANOUT_HASH = 0x0
- PACKET_FANOUT_LB = 0x1
- PACKET_FASTROUTE = 0x6
- PACKET_HDRLEN = 0xb
- PACKET_HOST = 0x0
- PACKET_LOOPBACK = 0x5
- PACKET_LOSS = 0xe
- PACKET_MR_ALLMULTI = 0x2
- PACKET_MR_MULTICAST = 0x0
- PACKET_MR_PROMISC = 0x1
- PACKET_MR_UNICAST = 0x3
- PACKET_MULTICAST = 0x2
- PACKET_ORIGDEV = 0x9
- PACKET_OTHERHOST = 0x3
- PACKET_OUTGOING = 0x4
- PACKET_RECV_OUTPUT = 0x3
- PACKET_RESERVE = 0xc
- PACKET_RX_RING = 0x5
- PACKET_STATISTICS = 0x6
- PACKET_TIMESTAMP = 0x11
- PACKET_TX_RING = 0xd
- PACKET_TX_TIMESTAMP = 0x10
- PACKET_VERSION = 0xa
- PACKET_VNET_HDR = 0xf
- PARENB = 0x100
- PARITY_CRC16_PR0 = 0x2
- PARITY_CRC16_PR0_CCITT = 0x4
- PARITY_CRC16_PR1 = 0x3
- PARITY_CRC16_PR1_CCITT = 0x5
- PARITY_CRC32_PR0_CCITT = 0x6
- PARITY_CRC32_PR1_CCITT = 0x7
- PARITY_DEFAULT = 0x0
- PARITY_NONE = 0x1
- PARMRK = 0x8
- PARODD = 0x200
- PENDIN = 0x4000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_GROWSDOWN = 0x1000000
- PROT_GROWSUP = 0x2000000
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- PR_CAPBSET_DROP = 0x18
- PR_CAPBSET_READ = 0x17
- PR_ENDIAN_BIG = 0x0
- PR_ENDIAN_LITTLE = 0x1
- PR_ENDIAN_PPC_LITTLE = 0x2
- PR_FPEMU_NOPRINT = 0x1
- PR_FPEMU_SIGFPE = 0x2
- PR_FP_EXC_ASYNC = 0x2
- PR_FP_EXC_DISABLED = 0x0
- PR_FP_EXC_DIV = 0x10000
- PR_FP_EXC_INV = 0x100000
- PR_FP_EXC_NONRECOV = 0x1
- PR_FP_EXC_OVF = 0x20000
- PR_FP_EXC_PRECISE = 0x3
- PR_FP_EXC_RES = 0x80000
- PR_FP_EXC_SW_ENABLE = 0x80
- PR_FP_EXC_UND = 0x40000
- PR_GET_DUMPABLE = 0x3
- PR_GET_ENDIAN = 0x13
- PR_GET_FPEMU = 0x9
- PR_GET_FPEXC = 0xb
- PR_GET_KEEPCAPS = 0x7
- PR_GET_NAME = 0x10
- PR_GET_NO_NEW_PRIVS = 0x27
- PR_GET_PDEATHSIG = 0x2
- PR_GET_SECCOMP = 0x15
- PR_GET_SECUREBITS = 0x1b
- PR_GET_TIMERSLACK = 0x1e
- PR_GET_TIMING = 0xd
- PR_GET_TSC = 0x19
- PR_GET_UNALIGN = 0x5
- PR_MCE_KILL = 0x21
- PR_MCE_KILL_CLEAR = 0x0
- PR_MCE_KILL_DEFAULT = 0x2
- PR_MCE_KILL_EARLY = 0x1
- PR_MCE_KILL_GET = 0x22
- PR_MCE_KILL_LATE = 0x0
- PR_MCE_KILL_SET = 0x1
- PR_SET_DUMPABLE = 0x4
- PR_SET_ENDIAN = 0x14
- PR_SET_FPEMU = 0xa
- PR_SET_FPEXC = 0xc
- PR_SET_KEEPCAPS = 0x8
- PR_SET_MM = 0x23
- PR_SET_MM_BRK = 0x7
- PR_SET_MM_END_CODE = 0x2
- PR_SET_MM_END_DATA = 0x4
- PR_SET_MM_START_BRK = 0x6
- PR_SET_MM_START_CODE = 0x1
- PR_SET_MM_START_DATA = 0x3
- PR_SET_MM_START_STACK = 0x5
- PR_SET_NAME = 0xf
- PR_SET_NO_NEW_PRIVS = 0x26
- PR_SET_PDEATHSIG = 0x1
- PR_SET_PTRACER = 0x59616d61
- PR_SET_PTRACER_ANY = 0xffffffff
- PR_SET_SECCOMP = 0x16
- PR_SET_SECUREBITS = 0x1c
- PR_SET_TIMERSLACK = 0x1d
- PR_SET_TIMING = 0xe
- PR_SET_TSC = 0x1a
- PR_SET_UNALIGN = 0x6
- PR_TASK_PERF_EVENTS_DISABLE = 0x1f
- PR_TASK_PERF_EVENTS_ENABLE = 0x20
- PR_TIMING_STATISTICAL = 0x0
- PR_TIMING_TIMESTAMP = 0x1
- PR_TSC_ENABLE = 0x1
- PR_TSC_SIGSEGV = 0x2
- PR_UNALIGN_NOPRINT = 0x1
- PR_UNALIGN_SIGBUS = 0x2
- PTRACE_ATTACH = 0x10
- PTRACE_CONT = 0x7
- PTRACE_DETACH = 0x11
- PTRACE_EVENT_CLONE = 0x3
- PTRACE_EVENT_EXEC = 0x4
- PTRACE_EVENT_EXIT = 0x6
- PTRACE_EVENT_FORK = 0x1
- PTRACE_EVENT_SECCOMP = 0x7
- PTRACE_EVENT_STOP = 0x80
- PTRACE_EVENT_VFORK = 0x2
- PTRACE_EVENT_VFORK_DONE = 0x5
- PTRACE_GETEVENTMSG = 0x4201
- PTRACE_GETFPREGS = 0xe
- PTRACE_GETFPXREGS = 0x12
- PTRACE_GETREGS = 0xc
- PTRACE_GETREGSET = 0x4204
- PTRACE_GETSIGINFO = 0x4202
- PTRACE_GET_THREAD_AREA = 0x19
- PTRACE_INTERRUPT = 0x4207
- PTRACE_KILL = 0x8
- PTRACE_LISTEN = 0x4208
- PTRACE_OLDSETOPTIONS = 0x15
- PTRACE_O_MASK = 0xff
- PTRACE_O_TRACECLONE = 0x8
- PTRACE_O_TRACEEXEC = 0x10
- PTRACE_O_TRACEEXIT = 0x40
- PTRACE_O_TRACEFORK = 0x2
- PTRACE_O_TRACESECCOMP = 0x80
- PTRACE_O_TRACESYSGOOD = 0x1
- PTRACE_O_TRACEVFORK = 0x4
- PTRACE_O_TRACEVFORKDONE = 0x20
- PTRACE_PEEKDATA = 0x2
- PTRACE_PEEKTEXT = 0x1
- PTRACE_PEEKUSR = 0x3
- PTRACE_POKEDATA = 0x5
- PTRACE_POKETEXT = 0x4
- PTRACE_POKEUSR = 0x6
- PTRACE_SEIZE = 0x4206
- PTRACE_SEIZE_DEVEL = 0x80000000
- PTRACE_SETFPREGS = 0xf
- PTRACE_SETFPXREGS = 0x13
- PTRACE_SETOPTIONS = 0x4200
- PTRACE_SETREGS = 0xd
- PTRACE_SETREGSET = 0x4205
- PTRACE_SETSIGINFO = 0x4203
- PTRACE_SET_THREAD_AREA = 0x1a
- PTRACE_SINGLEBLOCK = 0x21
- PTRACE_SINGLESTEP = 0x9
- PTRACE_SYSCALL = 0x18
- PTRACE_SYSEMU = 0x1f
- PTRACE_SYSEMU_SINGLESTEP = 0x20
- PTRACE_TRACEME = 0x0
- RLIMIT_AS = 0x9
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x7
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = -0x1
- RTAX_ADVMSS = 0x8
- RTAX_CWND = 0x7
- RTAX_FEATURES = 0xc
- RTAX_FEATURE_ALLFRAG = 0x8
- RTAX_FEATURE_ECN = 0x1
- RTAX_FEATURE_SACK = 0x2
- RTAX_FEATURE_TIMESTAMP = 0x4
- RTAX_HOPLIMIT = 0xa
- RTAX_INITCWND = 0xb
- RTAX_INITRWND = 0xe
- RTAX_LOCK = 0x1
- RTAX_MAX = 0xe
- RTAX_MTU = 0x2
- RTAX_REORDERING = 0x9
- RTAX_RTO_MIN = 0xd
- RTAX_RTT = 0x4
- RTAX_RTTVAR = 0x5
- RTAX_SSTHRESH = 0x6
- RTAX_UNSPEC = 0x0
- RTAX_WINDOW = 0x3
- RTA_ALIGNTO = 0x4
- RTA_MAX = 0x10
- RTCF_DIRECTSRC = 0x4000000
- RTCF_DOREDIRECT = 0x1000000
- RTCF_LOG = 0x2000000
- RTCF_MASQ = 0x400000
- RTCF_NAT = 0x800000
- RTCF_VALVE = 0x200000
- RTF_ADDRCLASSMASK = 0xf8000000
- RTF_ADDRCONF = 0x40000
- RTF_ALLONLINK = 0x20000
- RTF_BROADCAST = 0x10000000
- RTF_CACHE = 0x1000000
- RTF_DEFAULT = 0x10000
- RTF_DYNAMIC = 0x10
- RTF_FLOW = 0x2000000
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_INTERFACE = 0x40000000
- RTF_IRTT = 0x100
- RTF_LINKRT = 0x100000
- RTF_LOCAL = 0x80000000
- RTF_MODIFIED = 0x20
- RTF_MSS = 0x40
- RTF_MTU = 0x40
- RTF_MULTICAST = 0x20000000
- RTF_NAT = 0x8000000
- RTF_NOFORWARD = 0x1000
- RTF_NONEXTHOP = 0x200000
- RTF_NOPMTUDISC = 0x4000
- RTF_POLICY = 0x4000000
- RTF_REINSTATE = 0x8
- RTF_REJECT = 0x200
- RTF_STATIC = 0x400
- RTF_THROW = 0x2000
- RTF_UP = 0x1
- RTF_WINDOW = 0x80
- RTF_XRESOLVE = 0x800
- RTM_BASE = 0x10
- RTM_DELACTION = 0x31
- RTM_DELADDR = 0x15
- RTM_DELADDRLABEL = 0x49
- RTM_DELLINK = 0x11
- RTM_DELNEIGH = 0x1d
- RTM_DELQDISC = 0x25
- RTM_DELROUTE = 0x19
- RTM_DELRULE = 0x21
- RTM_DELTCLASS = 0x29
- RTM_DELTFILTER = 0x2d
- RTM_F_CLONED = 0x200
- RTM_F_EQUALIZE = 0x400
- RTM_F_NOTIFY = 0x100
- RTM_F_PREFIX = 0x800
- RTM_GETACTION = 0x32
- RTM_GETADDR = 0x16
- RTM_GETADDRLABEL = 0x4a
- RTM_GETANYCAST = 0x3e
- RTM_GETDCB = 0x4e
- RTM_GETLINK = 0x12
- RTM_GETMULTICAST = 0x3a
- RTM_GETNEIGH = 0x1e
- RTM_GETNEIGHTBL = 0x42
- RTM_GETQDISC = 0x26
- RTM_GETROUTE = 0x1a
- RTM_GETRULE = 0x22
- RTM_GETTCLASS = 0x2a
- RTM_GETTFILTER = 0x2e
- RTM_MAX = 0x4f
- RTM_NEWACTION = 0x30
- RTM_NEWADDR = 0x14
- RTM_NEWADDRLABEL = 0x48
- RTM_NEWLINK = 0x10
- RTM_NEWNDUSEROPT = 0x44
- RTM_NEWNEIGH = 0x1c
- RTM_NEWNEIGHTBL = 0x40
- RTM_NEWPREFIX = 0x34
- RTM_NEWQDISC = 0x24
- RTM_NEWROUTE = 0x18
- RTM_NEWRULE = 0x20
- RTM_NEWTCLASS = 0x28
- RTM_NEWTFILTER = 0x2c
- RTM_NR_FAMILIES = 0x10
- RTM_NR_MSGTYPES = 0x40
- RTM_SETDCB = 0x4f
- RTM_SETLINK = 0x13
- RTM_SETNEIGHTBL = 0x43
- RTNH_ALIGNTO = 0x4
- RTNH_F_DEAD = 0x1
- RTNH_F_ONLINK = 0x4
- RTNH_F_PERVASIVE = 0x2
- RTN_MAX = 0xb
- RTPROT_BIRD = 0xc
- RTPROT_BOOT = 0x3
- RTPROT_DHCP = 0x10
- RTPROT_DNROUTED = 0xd
- RTPROT_GATED = 0x8
- RTPROT_KERNEL = 0x2
- RTPROT_MRT = 0xa
- RTPROT_NTK = 0xf
- RTPROT_RA = 0x9
- RTPROT_REDIRECT = 0x1
- RTPROT_STATIC = 0x4
- RTPROT_UNSPEC = 0x0
- RTPROT_XORP = 0xe
- RTPROT_ZEBRA = 0xb
- RT_CLASS_DEFAULT = 0xfd
- RT_CLASS_LOCAL = 0xff
- RT_CLASS_MAIN = 0xfe
- RT_CLASS_MAX = 0xff
- RT_CLASS_UNSPEC = 0x0
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- RUSAGE_THREAD = 0x1
- SCM_CREDENTIALS = 0x2
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x1d
- SCM_TIMESTAMPING = 0x25
- SCM_TIMESTAMPNS = 0x23
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDDLCI = 0x8980
- SIOCADDMULTI = 0x8931
- SIOCADDRT = 0x890b
- SIOCATMARK = 0x8905
- SIOCDARP = 0x8953
- SIOCDELDLCI = 0x8981
- SIOCDELMULTI = 0x8932
- SIOCDELRT = 0x890c
- SIOCDEVPRIVATE = 0x89f0
- SIOCDIFADDR = 0x8936
- SIOCDRARP = 0x8960
- SIOCGARP = 0x8954
- SIOCGIFADDR = 0x8915
- SIOCGIFBR = 0x8940
- SIOCGIFBRDADDR = 0x8919
- SIOCGIFCONF = 0x8912
- SIOCGIFCOUNT = 0x8938
- SIOCGIFDSTADDR = 0x8917
- SIOCGIFENCAP = 0x8925
- SIOCGIFFLAGS = 0x8913
- SIOCGIFHWADDR = 0x8927
- SIOCGIFINDEX = 0x8933
- SIOCGIFMAP = 0x8970
- SIOCGIFMEM = 0x891f
- SIOCGIFMETRIC = 0x891d
- SIOCGIFMTU = 0x8921
- SIOCGIFNAME = 0x8910
- SIOCGIFNETMASK = 0x891b
- SIOCGIFPFLAGS = 0x8935
- SIOCGIFSLAVE = 0x8929
- SIOCGIFTXQLEN = 0x8942
- SIOCGPGRP = 0x8904
- SIOCGRARP = 0x8961
- SIOCGSTAMP = 0x8906
- SIOCGSTAMPNS = 0x8907
- SIOCPROTOPRIVATE = 0x89e0
- SIOCRTMSG = 0x890d
- SIOCSARP = 0x8955
- SIOCSIFADDR = 0x8916
- SIOCSIFBR = 0x8941
- SIOCSIFBRDADDR = 0x891a
- SIOCSIFDSTADDR = 0x8918
- SIOCSIFENCAP = 0x8926
- SIOCSIFFLAGS = 0x8914
- SIOCSIFHWADDR = 0x8924
- SIOCSIFHWBROADCAST = 0x8937
- SIOCSIFLINK = 0x8911
- SIOCSIFMAP = 0x8971
- SIOCSIFMEM = 0x8920
- SIOCSIFMETRIC = 0x891e
- SIOCSIFMTU = 0x8922
- SIOCSIFNAME = 0x8923
- SIOCSIFNETMASK = 0x891c
- SIOCSIFPFLAGS = 0x8934
- SIOCSIFSLAVE = 0x8930
- SIOCSIFTXQLEN = 0x8943
- SIOCSPGRP = 0x8902
- SIOCSRARP = 0x8962
- SOCK_CLOEXEC = 0x80000
- SOCK_DCCP = 0x6
- SOCK_DGRAM = 0x2
- SOCK_NONBLOCK = 0x800
- SOCK_PACKET = 0xa
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_AAL = 0x109
- SOL_ATM = 0x108
- SOL_DECNET = 0x105
- SOL_ICMPV6 = 0x3a
- SOL_IP = 0x0
- SOL_IPV6 = 0x29
- SOL_IRDA = 0x10a
- SOL_PACKET = 0x107
- SOL_RAW = 0xff
- SOL_SOCKET = 0x1
- SOL_TCP = 0x6
- SOL_X25 = 0x106
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x1e
- SO_ATTACH_FILTER = 0x1a
- SO_BINDTODEVICE = 0x19
- SO_BROADCAST = 0x6
- SO_BSDCOMPAT = 0xe
- SO_DEBUG = 0x1
- SO_DETACH_FILTER = 0x1b
- SO_DOMAIN = 0x27
- SO_DONTROUTE = 0x5
- SO_ERROR = 0x4
- SO_KEEPALIVE = 0x9
- SO_LINGER = 0xd
- SO_MARK = 0x24
- SO_NO_CHECK = 0xb
- SO_OOBINLINE = 0xa
- SO_PASSCRED = 0x10
- SO_PASSSEC = 0x22
- SO_PEERCRED = 0x11
- SO_PEERNAME = 0x1c
- SO_PEERSEC = 0x1f
- SO_PRIORITY = 0xc
- SO_PROTOCOL = 0x26
- SO_RCVBUF = 0x8
- SO_RCVBUFFORCE = 0x21
- SO_RCVLOWAT = 0x12
- SO_RCVTIMEO = 0x14
- SO_REUSEADDR = 0x2
- SO_RXQ_OVFL = 0x28
- SO_SECURITY_AUTHENTICATION = 0x16
- SO_SECURITY_ENCRYPTION_NETWORK = 0x18
- SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17
- SO_SNDBUF = 0x7
- SO_SNDBUFFORCE = 0x20
- SO_SNDLOWAT = 0x13
- SO_SNDTIMEO = 0x15
- SO_TIMESTAMP = 0x1d
- SO_TIMESTAMPING = 0x25
- SO_TIMESTAMPNS = 0x23
- SO_TYPE = 0x3
- S_BLKSIZE = 0x200
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TAB0 = 0x0
- TAB1 = 0x800
- TAB2 = 0x1000
- TAB3 = 0x1800
- TABDLY = 0x1800
- TCFLSH = 0x540b
- TCGETA = 0x5405
- TCGETS = 0x5401
- TCGETS2 = 0x802c542a
- TCGETX = 0x5432
- TCIFLUSH = 0x0
- TCIOFF = 0x2
- TCIOFLUSH = 0x2
- TCION = 0x3
- TCOFLUSH = 0x1
- TCOOFF = 0x0
- TCOON = 0x1
- TCP_CONGESTION = 0xd
- TCP_CORK = 0x3
- TCP_DEFER_ACCEPT = 0x9
- TCP_INFO = 0xb
- TCP_KEEPCNT = 0x6
- TCP_KEEPIDLE = 0x4
- TCP_KEEPINTVL = 0x5
- TCP_LINGER2 = 0x8
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0xe
- TCP_MD5SIG_MAXKEYLEN = 0x50
- TCP_MSS = 0x200
- TCP_NODELAY = 0x1
- TCP_QUICKACK = 0xc
- TCP_SYNCNT = 0x7
- TCP_WINDOW_CLAMP = 0xa
- TCSAFLUSH = 0x2
- TCSBRK = 0x5409
- TCSBRKP = 0x5425
- TCSETA = 0x5406
- TCSETAF = 0x5408
- TCSETAW = 0x5407
- TCSETS = 0x5402
- TCSETS2 = 0x402c542b
- TCSETSF = 0x5404
- TCSETSF2 = 0x402c542d
- TCSETSW = 0x5403
- TCSETSW2 = 0x402c542c
- TCSETX = 0x5433
- TCSETXF = 0x5434
- TCSETXW = 0x5435
- TCXONC = 0x540a
- TIOCCBRK = 0x5428
- TIOCCONS = 0x541d
- TIOCEXCL = 0x540c
- TIOCGDEV = 0x80045432
- TIOCGETD = 0x5424
- TIOCGEXCL = 0x80045440
- TIOCGICOUNT = 0x545d
- TIOCGLCKTRMIOS = 0x5456
- TIOCGPGRP = 0x540f
- TIOCGPKT = 0x80045438
- TIOCGPTLCK = 0x80045439
- TIOCGPTN = 0x80045430
- TIOCGRS485 = 0x542e
- TIOCGSERIAL = 0x541e
- TIOCGSID = 0x5429
- TIOCGSOFTCAR = 0x5419
- TIOCGWINSZ = 0x5413
- TIOCINQ = 0x541b
- TIOCLINUX = 0x541c
- TIOCMBIC = 0x5417
- TIOCMBIS = 0x5416
- TIOCMGET = 0x5415
- TIOCMIWAIT = 0x545c
- TIOCMSET = 0x5418
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x5422
- TIOCNXCL = 0x540d
- TIOCOUTQ = 0x5411
- TIOCPKT = 0x5420
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCSBRK = 0x5427
- TIOCSCTTY = 0x540e
- TIOCSERCONFIG = 0x5453
- TIOCSERGETLSR = 0x5459
- TIOCSERGETMULTI = 0x545a
- TIOCSERGSTRUCT = 0x5458
- TIOCSERGWILD = 0x5454
- TIOCSERSETMULTI = 0x545b
- TIOCSERSWILD = 0x5455
- TIOCSER_TEMT = 0x1
- TIOCSETD = 0x5423
- TIOCSIG = 0x40045436
- TIOCSLCKTRMIOS = 0x5457
- TIOCSPGRP = 0x5410
- TIOCSPTLCK = 0x40045431
- TIOCSRS485 = 0x542f
- TIOCSSERIAL = 0x541f
- TIOCSSOFTCAR = 0x541a
- TIOCSTI = 0x5412
- TIOCSWINSZ = 0x5414
- TIOCVHANGUP = 0x5437
- TOSTOP = 0x100
- TUNATTACHFILTER = 0x400854d5
- TUNDETACHFILTER = 0x400854d6
- TUNGETFEATURES = 0x800454cf
- TUNGETIFF = 0x800454d2
- TUNGETSNDBUF = 0x800454d3
- TUNGETVNETHDRSZ = 0x800454d7
- TUNSETDEBUG = 0x400454c9
- TUNSETGROUP = 0x400454ce
- TUNSETIFF = 0x400454ca
- TUNSETLINK = 0x400454cd
- TUNSETNOCSUM = 0x400454c8
- TUNSETOFFLOAD = 0x400454d0
- TUNSETOWNER = 0x400454cc
- TUNSETPERSIST = 0x400454cb
- TUNSETSNDBUF = 0x400454d4
- TUNSETTXFILTER = 0x400454d1
- TUNSETVNETHDRSZ = 0x400454d8
- VDISCARD = 0xd
- VEOF = 0x4
- VEOL = 0xb
- VEOL2 = 0x10
- VERASE = 0x2
- VINTR = 0x0
- VKILL = 0x3
- VLNEXT = 0xf
- VMIN = 0x6
- VQUIT = 0x1
- VREPRINT = 0xc
- VSTART = 0x8
- VSTOP = 0x9
- VSUSP = 0xa
- VSWTC = 0x7
- VT0 = 0x0
- VT1 = 0x4000
- VTDLY = 0x4000
- VTIME = 0x5
- VWERASE = 0xe
- WALL = 0x40000000
- WCLONE = 0x80000000
- WCONTINUED = 0x8
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOTHREAD = 0x20000000
- WNOWAIT = 0x1000000
- WORDSIZE = 0x20
- WSTOPPED = 0x2
- WUNTRACED = 0x2
- XCASE = 0x4
- XTABS = 0x1800
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x62)
- EADDRNOTAVAIL = syscall.Errno(0x63)
- EADV = syscall.Errno(0x44)
- EAFNOSUPPORT = syscall.Errno(0x61)
- EAGAIN = syscall.Errno(0xb)
- EALREADY = syscall.Errno(0x72)
- EBADE = syscall.Errno(0x34)
- EBADF = syscall.Errno(0x9)
- EBADFD = syscall.Errno(0x4d)
- EBADMSG = syscall.Errno(0x4a)
- EBADR = syscall.Errno(0x35)
- EBADRQC = syscall.Errno(0x38)
- EBADSLT = syscall.Errno(0x39)
- EBFONT = syscall.Errno(0x3b)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x7d)
- ECHILD = syscall.Errno(0xa)
- ECHRNG = syscall.Errno(0x2c)
- ECOMM = syscall.Errno(0x46)
- ECONNABORTED = syscall.Errno(0x67)
- ECONNREFUSED = syscall.Errno(0x6f)
- ECONNRESET = syscall.Errno(0x68)
- EDEADLK = syscall.Errno(0x23)
- EDEADLOCK = syscall.Errno(0x23)
- EDESTADDRREQ = syscall.Errno(0x59)
- EDOM = syscall.Errno(0x21)
- EDOTDOT = syscall.Errno(0x49)
- EDQUOT = syscall.Errno(0x7a)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EHOSTDOWN = syscall.Errno(0x70)
- EHOSTUNREACH = syscall.Errno(0x71)
- EHWPOISON = syscall.Errno(0x85)
- EIDRM = syscall.Errno(0x2b)
- EILSEQ = syscall.Errno(0x54)
- EINPROGRESS = syscall.Errno(0x73)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x6a)
- EISDIR = syscall.Errno(0x15)
- EISNAM = syscall.Errno(0x78)
- EKEYEXPIRED = syscall.Errno(0x7f)
- EKEYREJECTED = syscall.Errno(0x81)
- EKEYREVOKED = syscall.Errno(0x80)
- EL2HLT = syscall.Errno(0x33)
- EL2NSYNC = syscall.Errno(0x2d)
- EL3HLT = syscall.Errno(0x2e)
- EL3RST = syscall.Errno(0x2f)
- ELIBACC = syscall.Errno(0x4f)
- ELIBBAD = syscall.Errno(0x50)
- ELIBEXEC = syscall.Errno(0x53)
- ELIBMAX = syscall.Errno(0x52)
- ELIBSCN = syscall.Errno(0x51)
- ELNRNG = syscall.Errno(0x30)
- ELOOP = syscall.Errno(0x28)
- EMEDIUMTYPE = syscall.Errno(0x7c)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x5a)
- EMULTIHOP = syscall.Errno(0x48)
- ENAMETOOLONG = syscall.Errno(0x24)
- ENAVAIL = syscall.Errno(0x77)
- ENETDOWN = syscall.Errno(0x64)
- ENETRESET = syscall.Errno(0x66)
- ENETUNREACH = syscall.Errno(0x65)
- ENFILE = syscall.Errno(0x17)
- ENOANO = syscall.Errno(0x37)
- ENOBUFS = syscall.Errno(0x69)
- ENOCSI = syscall.Errno(0x32)
- ENODATA = syscall.Errno(0x3d)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOKEY = syscall.Errno(0x7e)
- ENOLCK = syscall.Errno(0x25)
- ENOLINK = syscall.Errno(0x43)
- ENOMEDIUM = syscall.Errno(0x7b)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x2a)
- ENONET = syscall.Errno(0x40)
- ENOPKG = syscall.Errno(0x41)
- ENOPROTOOPT = syscall.Errno(0x5c)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x3f)
- ENOSTR = syscall.Errno(0x3c)
- ENOSYS = syscall.Errno(0x26)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x6b)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x27)
- ENOTNAM = syscall.Errno(0x76)
- ENOTRECOVERABLE = syscall.Errno(0x83)
- ENOTSOCK = syscall.Errno(0x58)
- ENOTSUP = syscall.Errno(0x5f)
- ENOTTY = syscall.Errno(0x19)
- ENOTUNIQ = syscall.Errno(0x4c)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x5f)
- EOVERFLOW = syscall.Errno(0x4b)
- EOWNERDEAD = syscall.Errno(0x82)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x60)
- EPIPE = syscall.Errno(0x20)
- EPROTO = syscall.Errno(0x47)
- EPROTONOSUPPORT = syscall.Errno(0x5d)
- EPROTOTYPE = syscall.Errno(0x5b)
- ERANGE = syscall.Errno(0x22)
- EREMCHG = syscall.Errno(0x4e)
- EREMOTE = syscall.Errno(0x42)
- EREMOTEIO = syscall.Errno(0x79)
- ERESTART = syscall.Errno(0x55)
- ERFKILL = syscall.Errno(0x84)
- EROFS = syscall.Errno(0x1e)
- ESHUTDOWN = syscall.Errno(0x6c)
- ESOCKTNOSUPPORT = syscall.Errno(0x5e)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESRMNT = syscall.Errno(0x45)
- ESTALE = syscall.Errno(0x74)
- ESTRPIPE = syscall.Errno(0x56)
- ETIME = syscall.Errno(0x3e)
- ETIMEDOUT = syscall.Errno(0x6e)
- ETOOMANYREFS = syscall.Errno(0x6d)
- ETXTBSY = syscall.Errno(0x1a)
- EUCLEAN = syscall.Errno(0x75)
- EUNATCH = syscall.Errno(0x31)
- EUSERS = syscall.Errno(0x57)
- EWOULDBLOCK = syscall.Errno(0xb)
- EXDEV = syscall.Errno(0x12)
- EXFULL = syscall.Errno(0x36)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0x7)
- SIGCHLD = syscall.Signal(0x11)
- SIGCLD = syscall.Signal(0x11)
- SIGCONT = syscall.Signal(0x12)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x1d)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPOLL = syscall.Signal(0x1d)
- SIGPROF = syscall.Signal(0x1b)
- SIGPWR = syscall.Signal(0x1e)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTKFLT = syscall.Signal(0x10)
- SIGSTOP = syscall.Signal(0x13)
- SIGSYS = syscall.Signal(0x1f)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x14)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGUNUSED = syscall.Signal(0x1f)
- SIGURG = syscall.Signal(0x17)
- SIGUSR1 = syscall.Signal(0xa)
- SIGUSR2 = syscall.Signal(0xc)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "no such device or address",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource temporarily unavailable",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device or resource busy",
- 17: "file exists",
- 18: "invalid cross-device link",
- 19: "no such device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "numerical result out of range",
- 35: "resource deadlock avoided",
- 36: "file name too long",
- 37: "no locks available",
- 38: "function not implemented",
- 39: "directory not empty",
- 40: "too many levels of symbolic links",
- 42: "no message of desired type",
- 43: "identifier removed",
- 44: "channel number out of range",
- 45: "level 2 not synchronized",
- 46: "level 3 halted",
- 47: "level 3 reset",
- 48: "link number out of range",
- 49: "protocol driver not attached",
- 50: "no CSI structure available",
- 51: "level 2 halted",
- 52: "invalid exchange",
- 53: "invalid request descriptor",
- 54: "exchange full",
- 55: "no anode",
- 56: "invalid request code",
- 57: "invalid slot",
- 59: "bad font file format",
- 60: "device not a stream",
- 61: "no data available",
- 62: "timer expired",
- 63: "out of streams resources",
- 64: "machine is not on the network",
- 65: "package not installed",
- 66: "object is remote",
- 67: "link has been severed",
- 68: "advertise error",
- 69: "srmount error",
- 70: "communication error on send",
- 71: "protocol error",
- 72: "multihop attempted",
- 73: "RFS specific error",
- 74: "bad message",
- 75: "value too large for defined data type",
- 76: "name not unique on network",
- 77: "file descriptor in bad state",
- 78: "remote address changed",
- 79: "can not access a needed shared library",
- 80: "accessing a corrupted shared library",
- 81: ".lib section in a.out corrupted",
- 82: "attempting to link in too many shared libraries",
- 83: "cannot exec a shared library directly",
- 84: "invalid or incomplete multibyte or wide character",
- 85: "interrupted system call should be restarted",
- 86: "streams pipe error",
- 87: "too many users",
- 88: "socket operation on non-socket",
- 89: "destination address required",
- 90: "message too long",
- 91: "protocol wrong type for socket",
- 92: "protocol not available",
- 93: "protocol not supported",
- 94: "socket type not supported",
- 95: "operation not supported",
- 96: "protocol family not supported",
- 97: "address family not supported by protocol",
- 98: "address already in use",
- 99: "cannot assign requested address",
- 100: "network is down",
- 101: "network is unreachable",
- 102: "network dropped connection on reset",
- 103: "software caused connection abort",
- 104: "connection reset by peer",
- 105: "no buffer space available",
- 106: "transport endpoint is already connected",
- 107: "transport endpoint is not connected",
- 108: "cannot send after transport endpoint shutdown",
- 109: "too many references: cannot splice",
- 110: "connection timed out",
- 111: "connection refused",
- 112: "host is down",
- 113: "no route to host",
- 114: "operation already in progress",
- 115: "operation now in progress",
- 116: "stale NFS file handle",
- 117: "structure needs cleaning",
- 118: "not a XENIX named type file",
- 119: "no XENIX semaphores available",
- 120: "is a named type file",
- 121: "remote I/O error",
- 122: "disk quota exceeded",
- 123: "no medium found",
- 124: "wrong medium type",
- 125: "operation canceled",
- 126: "required key not available",
- 127: "key has expired",
- 128: "key has been revoked",
- 129: "key was rejected by service",
- 130: "owner died",
- 131: "state not recoverable",
- 132: "operation not possible due to RF-kill",
- 133: "unknown error 133",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/breakpoint trap",
- 6: "aborted",
- 7: "bus error",
- 8: "floating point exception",
- 9: "killed",
- 10: "user defined signal 1",
- 11: "segmentation fault",
- 12: "user defined signal 2",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "stack fault",
- 17: "child exited",
- 18: "continued",
- 19: "stopped (signal)",
- 20: "stopped",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "urgent I/O condition",
- 24: "CPU time limit exceeded",
- 25: "file size limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window changed",
- 29: "I/O possible",
- 30: "power failure",
- 31: "bad system call",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/newt/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
deleted file mode 100644
index 49b6c354..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
+++ /dev/null
@@ -1,1820 +0,0 @@
-// mkerrors.sh -m64
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build amd64,linux
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -m64 _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_ALG = 0x26
- AF_APPLETALK = 0x5
- AF_ASH = 0x12
- AF_ATMPVC = 0x8
- AF_ATMSVC = 0x14
- AF_AX25 = 0x3
- AF_BLUETOOTH = 0x1f
- AF_BRIDGE = 0x7
- AF_CAIF = 0x25
- AF_CAN = 0x1d
- AF_DECnet = 0xc
- AF_ECONET = 0x13
- AF_FILE = 0x1
- AF_IEEE802154 = 0x24
- AF_INET = 0x2
- AF_INET6 = 0xa
- AF_IPX = 0x4
- AF_IRDA = 0x17
- AF_ISDN = 0x22
- AF_IUCV = 0x20
- AF_KEY = 0xf
- AF_LLC = 0x1a
- AF_LOCAL = 0x1
- AF_MAX = 0x28
- AF_NETBEUI = 0xd
- AF_NETLINK = 0x10
- AF_NETROM = 0x6
- AF_NFC = 0x27
- AF_PACKET = 0x11
- AF_PHONET = 0x23
- AF_PPPOX = 0x18
- AF_RDS = 0x15
- AF_ROSE = 0xb
- AF_ROUTE = 0x10
- AF_RXRPC = 0x21
- AF_SECURITY = 0xe
- AF_SNA = 0x16
- AF_TIPC = 0x1e
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_WANPIPE = 0x19
- AF_X25 = 0x9
- ARPHRD_ADAPT = 0x108
- ARPHRD_APPLETLK = 0x8
- ARPHRD_ARCNET = 0x7
- ARPHRD_ASH = 0x30d
- ARPHRD_ATM = 0x13
- ARPHRD_AX25 = 0x3
- ARPHRD_BIF = 0x307
- ARPHRD_CAIF = 0x336
- ARPHRD_CAN = 0x118
- ARPHRD_CHAOS = 0x5
- ARPHRD_CISCO = 0x201
- ARPHRD_CSLIP = 0x101
- ARPHRD_CSLIP6 = 0x103
- ARPHRD_DDCMP = 0x205
- ARPHRD_DLCI = 0xf
- ARPHRD_ECONET = 0x30e
- ARPHRD_EETHER = 0x2
- ARPHRD_ETHER = 0x1
- ARPHRD_EUI64 = 0x1b
- ARPHRD_FCAL = 0x311
- ARPHRD_FCFABRIC = 0x313
- ARPHRD_FCPL = 0x312
- ARPHRD_FCPP = 0x310
- ARPHRD_FDDI = 0x306
- ARPHRD_FRAD = 0x302
- ARPHRD_HDLC = 0x201
- ARPHRD_HIPPI = 0x30c
- ARPHRD_HWX25 = 0x110
- ARPHRD_IEEE1394 = 0x18
- ARPHRD_IEEE802 = 0x6
- ARPHRD_IEEE80211 = 0x321
- ARPHRD_IEEE80211_PRISM = 0x322
- ARPHRD_IEEE80211_RADIOTAP = 0x323
- ARPHRD_IEEE802154 = 0x324
- ARPHRD_IEEE802_TR = 0x320
- ARPHRD_INFINIBAND = 0x20
- ARPHRD_IPDDP = 0x309
- ARPHRD_IPGRE = 0x30a
- ARPHRD_IRDA = 0x30f
- ARPHRD_LAPB = 0x204
- ARPHRD_LOCALTLK = 0x305
- ARPHRD_LOOPBACK = 0x304
- ARPHRD_METRICOM = 0x17
- ARPHRD_NETROM = 0x0
- ARPHRD_NONE = 0xfffe
- ARPHRD_PHONET = 0x334
- ARPHRD_PHONET_PIPE = 0x335
- ARPHRD_PIMREG = 0x30b
- ARPHRD_PPP = 0x200
- ARPHRD_PRONET = 0x4
- ARPHRD_RAWHDLC = 0x206
- ARPHRD_ROSE = 0x10e
- ARPHRD_RSRVD = 0x104
- ARPHRD_SIT = 0x308
- ARPHRD_SKIP = 0x303
- ARPHRD_SLIP = 0x100
- ARPHRD_SLIP6 = 0x102
- ARPHRD_TUNNEL = 0x300
- ARPHRD_TUNNEL6 = 0x301
- ARPHRD_VOID = 0xffff
- ARPHRD_X25 = 0x10f
- B0 = 0x0
- B1000000 = 0x1008
- B110 = 0x3
- B115200 = 0x1002
- B1152000 = 0x1009
- B1200 = 0x9
- B134 = 0x4
- B150 = 0x5
- B1500000 = 0x100a
- B1800 = 0xa
- B19200 = 0xe
- B200 = 0x6
- B2000000 = 0x100b
- B230400 = 0x1003
- B2400 = 0xb
- B2500000 = 0x100c
- B300 = 0x7
- B3000000 = 0x100d
- B3500000 = 0x100e
- B38400 = 0xf
- B4000000 = 0x100f
- B460800 = 0x1004
- B4800 = 0xc
- B50 = 0x1
- B500000 = 0x1005
- B57600 = 0x1001
- B576000 = 0x1006
- B600 = 0x8
- B75 = 0x2
- B921600 = 0x1007
- B9600 = 0xd
- BOTHER = 0x1000
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXINSNS = 0x1000
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BRKINT = 0x2
- BS0 = 0x0
- BS1 = 0x2000
- BSDLY = 0x2000
- CBAUD = 0x100f
- CBAUDEX = 0x1000
- CFLUSH = 0xf
- CIBAUD = 0x100f0000
- CLOCAL = 0x800
- CLOCK_BOOTTIME = 0x7
- CLOCK_BOOTTIME_ALARM = 0x9
- CLOCK_DEFAULT = 0x0
- CLOCK_EXT = 0x1
- CLOCK_INT = 0x2
- CLOCK_MONOTONIC = 0x1
- CLOCK_MONOTONIC_COARSE = 0x6
- CLOCK_MONOTONIC_RAW = 0x4
- CLOCK_PROCESS_CPUTIME_ID = 0x2
- CLOCK_REALTIME = 0x0
- CLOCK_REALTIME_ALARM = 0x8
- CLOCK_REALTIME_COARSE = 0x5
- CLOCK_THREAD_CPUTIME_ID = 0x3
- CLOCK_TXFROMRX = 0x4
- CLOCK_TXINT = 0x3
- CLONE_CHILD_CLEARTID = 0x200000
- CLONE_CHILD_SETTID = 0x1000000
- CLONE_DETACHED = 0x400000
- CLONE_FILES = 0x400
- CLONE_FS = 0x200
- CLONE_IO = 0x80000000
- CLONE_NEWCGROUP = 0x2000000
- CLONE_NEWIPC = 0x8000000
- CLONE_NEWNET = 0x40000000
- CLONE_NEWNS = 0x20000
- CLONE_NEWPID = 0x20000000
- CLONE_NEWUSER = 0x10000000
- CLONE_NEWUTS = 0x4000000
- CLONE_PARENT = 0x8000
- CLONE_PARENT_SETTID = 0x100000
- CLONE_PTRACE = 0x2000
- CLONE_SETTLS = 0x80000
- CLONE_SIGHAND = 0x800
- CLONE_SYSVSEM = 0x40000
- CLONE_THREAD = 0x10000
- CLONE_UNTRACED = 0x800000
- CLONE_VFORK = 0x4000
- CLONE_VM = 0x100
- CMSPAR = 0x40000000
- CR0 = 0x0
- CR1 = 0x200
- CR2 = 0x400
- CR3 = 0x600
- CRDLY = 0x600
- CREAD = 0x80
- CRTSCTS = 0x80000000
- CS5 = 0x0
- CS6 = 0x10
- CS7 = 0x20
- CS8 = 0x30
- CSIGNAL = 0xff
- CSIZE = 0x30
- CSTART = 0x11
- CSTATUS = 0x0
- CSTOP = 0x13
- CSTOPB = 0x40
- CSUSP = 0x1a
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x200
- ECHOE = 0x10
- ECHOK = 0x20
- ECHOKE = 0x800
- ECHONL = 0x40
- ECHOPRT = 0x400
- ENCODING_DEFAULT = 0x0
- ENCODING_FM_MARK = 0x3
- ENCODING_FM_SPACE = 0x4
- ENCODING_MANCHESTER = 0x5
- ENCODING_NRZ = 0x1
- ENCODING_NRZI = 0x2
- EPOLLERR = 0x8
- EPOLLET = 0x80000000
- EPOLLHUP = 0x10
- EPOLLIN = 0x1
- EPOLLMSG = 0x400
- EPOLLONESHOT = 0x40000000
- EPOLLOUT = 0x4
- EPOLLPRI = 0x2
- EPOLLRDBAND = 0x80
- EPOLLRDHUP = 0x2000
- EPOLLRDNORM = 0x40
- EPOLLWRBAND = 0x200
- EPOLLWRNORM = 0x100
- EPOLL_CLOEXEC = 0x80000
- EPOLL_CTL_ADD = 0x1
- EPOLL_CTL_DEL = 0x2
- EPOLL_CTL_MOD = 0x3
- EPOLL_NONBLOCK = 0x800
- ETH_P_1588 = 0x88f7
- ETH_P_8021AD = 0x88a8
- ETH_P_8021AH = 0x88e7
- ETH_P_8021Q = 0x8100
- ETH_P_802_2 = 0x4
- ETH_P_802_3 = 0x1
- ETH_P_AARP = 0x80f3
- ETH_P_AF_IUCV = 0xfbfb
- ETH_P_ALL = 0x3
- ETH_P_AOE = 0x88a2
- ETH_P_ARCNET = 0x1a
- ETH_P_ARP = 0x806
- ETH_P_ATALK = 0x809b
- ETH_P_ATMFATE = 0x8884
- ETH_P_ATMMPOA = 0x884c
- ETH_P_AX25 = 0x2
- ETH_P_BPQ = 0x8ff
- ETH_P_CAIF = 0xf7
- ETH_P_CAN = 0xc
- ETH_P_CONTROL = 0x16
- ETH_P_CUST = 0x6006
- ETH_P_DDCMP = 0x6
- ETH_P_DEC = 0x6000
- ETH_P_DIAG = 0x6005
- ETH_P_DNA_DL = 0x6001
- ETH_P_DNA_RC = 0x6002
- ETH_P_DNA_RT = 0x6003
- ETH_P_DSA = 0x1b
- ETH_P_ECONET = 0x18
- ETH_P_EDSA = 0xdada
- ETH_P_FCOE = 0x8906
- ETH_P_FIP = 0x8914
- ETH_P_HDLC = 0x19
- ETH_P_IEEE802154 = 0xf6
- ETH_P_IEEEPUP = 0xa00
- ETH_P_IEEEPUPAT = 0xa01
- ETH_P_IP = 0x800
- ETH_P_IPV6 = 0x86dd
- ETH_P_IPX = 0x8137
- ETH_P_IRDA = 0x17
- ETH_P_LAT = 0x6004
- ETH_P_LINK_CTL = 0x886c
- ETH_P_LOCALTALK = 0x9
- ETH_P_LOOP = 0x60
- ETH_P_MOBITEX = 0x15
- ETH_P_MPLS_MC = 0x8848
- ETH_P_MPLS_UC = 0x8847
- ETH_P_PAE = 0x888e
- ETH_P_PAUSE = 0x8808
- ETH_P_PHONET = 0xf5
- ETH_P_PPPTALK = 0x10
- ETH_P_PPP_DISC = 0x8863
- ETH_P_PPP_MP = 0x8
- ETH_P_PPP_SES = 0x8864
- ETH_P_PUP = 0x200
- ETH_P_PUPAT = 0x201
- ETH_P_QINQ1 = 0x9100
- ETH_P_QINQ2 = 0x9200
- ETH_P_QINQ3 = 0x9300
- ETH_P_RARP = 0x8035
- ETH_P_SCA = 0x6007
- ETH_P_SLOW = 0x8809
- ETH_P_SNAP = 0x5
- ETH_P_TDLS = 0x890d
- ETH_P_TEB = 0x6558
- ETH_P_TIPC = 0x88ca
- ETH_P_TRAILER = 0x1c
- ETH_P_TR_802_2 = 0x11
- ETH_P_WAN_PPP = 0x7
- ETH_P_WCCP = 0x883e
- ETH_P_X25 = 0x805
- EXTA = 0xe
- EXTB = 0xf
- EXTPROC = 0x10000
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FF0 = 0x0
- FF1 = 0x8000
- FFDLY = 0x8000
- FLUSHO = 0x1000
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x406
- F_EXLCK = 0x4
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLEASE = 0x401
- F_GETLK = 0x5
- F_GETLK64 = 0x5
- F_GETOWN = 0x9
- F_GETOWN_EX = 0x10
- F_GETPIPE_SZ = 0x408
- F_GETSIG = 0xb
- F_LOCK = 0x1
- F_NOTIFY = 0x402
- F_OK = 0x0
- F_RDLCK = 0x0
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLEASE = 0x400
- F_SETLK = 0x6
- F_SETLK64 = 0x6
- F_SETLKW = 0x7
- F_SETLKW64 = 0x7
- F_SETOWN = 0x8
- F_SETOWN_EX = 0xf
- F_SETPIPE_SZ = 0x407
- F_SETSIG = 0xa
- F_SHLCK = 0x8
- F_TEST = 0x3
- F_TLOCK = 0x2
- F_ULOCK = 0x0
- F_UNLCK = 0x2
- F_WRLCK = 0x1
- HUPCL = 0x400
- IBSHIFT = 0x10
- ICANON = 0x2
- ICMPV6_FILTER = 0x1
- ICRNL = 0x100
- IEXTEN = 0x8000
- IFA_F_DADFAILED = 0x8
- IFA_F_DEPRECATED = 0x20
- IFA_F_HOMEADDRESS = 0x10
- IFA_F_NODAD = 0x2
- IFA_F_OPTIMISTIC = 0x4
- IFA_F_PERMANENT = 0x80
- IFA_F_SECONDARY = 0x1
- IFA_F_TEMPORARY = 0x1
- IFA_F_TENTATIVE = 0x40
- IFA_MAX = 0x7
- IFF_802_1Q_VLAN = 0x1
- IFF_ALLMULTI = 0x200
- IFF_AUTOMEDIA = 0x4000
- IFF_BONDING = 0x20
- IFF_BRIDGE_PORT = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_DISABLE_NETPOLL = 0x1000
- IFF_DONT_BRIDGE = 0x800
- IFF_DORMANT = 0x20000
- IFF_DYNAMIC = 0x8000
- IFF_EBRIDGE = 0x2
- IFF_ECHO = 0x40000
- IFF_ISATAP = 0x80
- IFF_LOOPBACK = 0x8
- IFF_LOWER_UP = 0x10000
- IFF_MACVLAN_PORT = 0x2000
- IFF_MASTER = 0x400
- IFF_MASTER_8023AD = 0x8
- IFF_MASTER_ALB = 0x10
- IFF_MASTER_ARPMON = 0x100
- IFF_MULTICAST = 0x1000
- IFF_NOARP = 0x80
- IFF_NOTRAILERS = 0x20
- IFF_NO_PI = 0x1000
- IFF_ONE_QUEUE = 0x2000
- IFF_OVS_DATAPATH = 0x8000
- IFF_POINTOPOINT = 0x10
- IFF_PORTSEL = 0x2000
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SLAVE = 0x800
- IFF_SLAVE_INACTIVE = 0x4
- IFF_SLAVE_NEEDARP = 0x40
- IFF_TAP = 0x2
- IFF_TUN = 0x1
- IFF_TUN_EXCL = 0x8000
- IFF_TX_SKB_SHARING = 0x10000
- IFF_UNICAST_FLT = 0x20000
- IFF_UP = 0x1
- IFF_VNET_HDR = 0x4000
- IFF_VOLATILE = 0x70c5a
- IFF_WAN_HDLC = 0x200
- IFF_XMIT_DST_RELEASE = 0x400
- IFNAMSIZ = 0x10
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_ACCESS = 0x1
- IN_ALL_EVENTS = 0xfff
- IN_ATTRIB = 0x4
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLOEXEC = 0x80000
- IN_CLOSE = 0x18
- IN_CLOSE_NOWRITE = 0x10
- IN_CLOSE_WRITE = 0x8
- IN_CREATE = 0x100
- IN_DELETE = 0x200
- IN_DELETE_SELF = 0x400
- IN_DONT_FOLLOW = 0x2000000
- IN_EXCL_UNLINK = 0x4000000
- IN_IGNORED = 0x8000
- IN_ISDIR = 0x40000000
- IN_LOOPBACKNET = 0x7f
- IN_MASK_ADD = 0x20000000
- IN_MODIFY = 0x2
- IN_MOVE = 0xc0
- IN_MOVED_FROM = 0x40
- IN_MOVED_TO = 0x80
- IN_MOVE_SELF = 0x800
- IN_NONBLOCK = 0x800
- IN_ONESHOT = 0x80000000
- IN_ONLYDIR = 0x1000000
- IN_OPEN = 0x20
- IN_Q_OVERFLOW = 0x4000
- IN_UNMOUNT = 0x2000
- IPPROTO_AH = 0x33
- IPPROTO_COMP = 0x6c
- IPPROTO_DCCP = 0x21
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_ENCAP = 0x62
- IPPROTO_ESP = 0x32
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GRE = 0x2f
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IGMP = 0x2
- IPPROTO_IP = 0x0
- IPPROTO_IPIP = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_MTP = 0x5c
- IPPROTO_NONE = 0x3b
- IPPROTO_PIM = 0x67
- IPPROTO_PUP = 0xc
- IPPROTO_RAW = 0xff
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_SCTP = 0x84
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_UDP = 0x11
- IPPROTO_UDPLITE = 0x88
- IPV6_2292DSTOPTS = 0x4
- IPV6_2292HOPLIMIT = 0x8
- IPV6_2292HOPOPTS = 0x3
- IPV6_2292PKTINFO = 0x2
- IPV6_2292PKTOPTIONS = 0x6
- IPV6_2292RTHDR = 0x5
- IPV6_ADDRFORM = 0x1
- IPV6_ADD_MEMBERSHIP = 0x14
- IPV6_AUTHHDR = 0xa
- IPV6_CHECKSUM = 0x7
- IPV6_DROP_MEMBERSHIP = 0x15
- IPV6_DSTOPTS = 0x3b
- IPV6_HOPLIMIT = 0x34
- IPV6_HOPOPTS = 0x36
- IPV6_IPSEC_POLICY = 0x22
- IPV6_JOIN_ANYCAST = 0x1b
- IPV6_JOIN_GROUP = 0x14
- IPV6_LEAVE_ANYCAST = 0x1c
- IPV6_LEAVE_GROUP = 0x15
- IPV6_MTU = 0x18
- IPV6_MTU_DISCOVER = 0x17
- IPV6_MULTICAST_HOPS = 0x12
- IPV6_MULTICAST_IF = 0x11
- IPV6_MULTICAST_LOOP = 0x13
- IPV6_NEXTHOP = 0x9
- IPV6_PKTINFO = 0x32
- IPV6_PMTUDISC_DO = 0x2
- IPV6_PMTUDISC_DONT = 0x0
- IPV6_PMTUDISC_PROBE = 0x3
- IPV6_PMTUDISC_WANT = 0x1
- IPV6_RECVDSTOPTS = 0x3a
- IPV6_RECVERR = 0x19
- IPV6_RECVHOPLIMIT = 0x33
- IPV6_RECVHOPOPTS = 0x35
- IPV6_RECVPKTINFO = 0x31
- IPV6_RECVRTHDR = 0x38
- IPV6_RECVTCLASS = 0x42
- IPV6_ROUTER_ALERT = 0x16
- IPV6_RTHDR = 0x39
- IPV6_RTHDRDSTOPTS = 0x37
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_RXDSTOPTS = 0x3b
- IPV6_RXHOPOPTS = 0x36
- IPV6_TCLASS = 0x43
- IPV6_UNICAST_HOPS = 0x10
- IPV6_V6ONLY = 0x1a
- IPV6_XFRM_POLICY = 0x23
- IP_ADD_MEMBERSHIP = 0x23
- IP_ADD_SOURCE_MEMBERSHIP = 0x27
- IP_BLOCK_SOURCE = 0x26
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0x24
- IP_DROP_SOURCE_MEMBERSHIP = 0x28
- IP_FREEBIND = 0xf
- IP_HDRINCL = 0x3
- IP_IPSEC_POLICY = 0x10
- IP_MAXPACKET = 0xffff
- IP_MAX_MEMBERSHIPS = 0x14
- IP_MF = 0x2000
- IP_MINTTL = 0x15
- IP_MSFILTER = 0x29
- IP_MSS = 0x240
- IP_MTU = 0xe
- IP_MTU_DISCOVER = 0xa
- IP_MULTICAST_ALL = 0x31
- IP_MULTICAST_IF = 0x20
- IP_MULTICAST_LOOP = 0x22
- IP_MULTICAST_TTL = 0x21
- IP_OFFMASK = 0x1fff
- IP_OPTIONS = 0x4
- IP_ORIGDSTADDR = 0x14
- IP_PASSSEC = 0x12
- IP_PKTINFO = 0x8
- IP_PKTOPTIONS = 0x9
- IP_PMTUDISC = 0xa
- IP_PMTUDISC_DO = 0x2
- IP_PMTUDISC_DONT = 0x0
- IP_PMTUDISC_PROBE = 0x3
- IP_PMTUDISC_WANT = 0x1
- IP_RECVERR = 0xb
- IP_RECVOPTS = 0x6
- IP_RECVORIGDSTADDR = 0x14
- IP_RECVRETOPTS = 0x7
- IP_RECVTOS = 0xd
- IP_RECVTTL = 0xc
- IP_RETOPTS = 0x7
- IP_RF = 0x8000
- IP_ROUTER_ALERT = 0x5
- IP_TOS = 0x1
- IP_TRANSPARENT = 0x13
- IP_TTL = 0x2
- IP_UNBLOCK_SOURCE = 0x25
- IP_XFRM_POLICY = 0x11
- ISIG = 0x1
- ISTRIP = 0x20
- IUCLC = 0x200
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x1000
- IXON = 0x400
- LINUX_REBOOT_CMD_CAD_OFF = 0x0
- LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
- LINUX_REBOOT_CMD_HALT = 0xcdef0123
- LINUX_REBOOT_CMD_KEXEC = 0x45584543
- LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
- LINUX_REBOOT_CMD_RESTART = 0x1234567
- LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
- LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
- LINUX_REBOOT_MAGIC1 = 0xfee1dead
- LINUX_REBOOT_MAGIC2 = 0x28121969
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_DOFORK = 0xb
- MADV_DONTFORK = 0xa
- MADV_DONTNEED = 0x4
- MADV_HUGEPAGE = 0xe
- MADV_HWPOISON = 0x64
- MADV_MERGEABLE = 0xc
- MADV_NOHUGEPAGE = 0xf
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_REMOVE = 0x9
- MADV_SEQUENTIAL = 0x2
- MADV_UNMERGEABLE = 0xd
- MADV_WILLNEED = 0x3
- MAP_32BIT = 0x40
- MAP_ANON = 0x20
- MAP_ANONYMOUS = 0x20
- MAP_DENYWRITE = 0x800
- MAP_EXECUTABLE = 0x1000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_GROWSDOWN = 0x100
- MAP_HUGETLB = 0x40000
- MAP_LOCKED = 0x2000
- MAP_NONBLOCK = 0x10000
- MAP_NORESERVE = 0x4000
- MAP_POPULATE = 0x8000
- MAP_PRIVATE = 0x2
- MAP_SHARED = 0x1
- MAP_STACK = 0x20000
- MAP_TYPE = 0xf
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MNT_DETACH = 0x2
- MNT_EXPIRE = 0x4
- MNT_FORCE = 0x1
- MSG_CMSG_CLOEXEC = 0x40000000
- MSG_CONFIRM = 0x800
- MSG_CTRUNC = 0x8
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x40
- MSG_EOR = 0x80
- MSG_ERRQUEUE = 0x2000
- MSG_FASTOPEN = 0x20000000
- MSG_FIN = 0x200
- MSG_MORE = 0x8000
- MSG_NOSIGNAL = 0x4000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_PROXY = 0x10
- MSG_RST = 0x1000
- MSG_SYN = 0x400
- MSG_TRUNC = 0x20
- MSG_TRYHARD = 0x4
- MSG_WAITALL = 0x100
- MSG_WAITFORONE = 0x10000
- MS_ACTIVE = 0x40000000
- MS_ASYNC = 0x1
- MS_BIND = 0x1000
- MS_DIRSYNC = 0x80
- MS_INVALIDATE = 0x2
- MS_I_VERSION = 0x800000
- MS_KERNMOUNT = 0x400000
- MS_MANDLOCK = 0x40
- MS_MGC_MSK = 0xffff0000
- MS_MGC_VAL = 0xc0ed0000
- MS_MOVE = 0x2000
- MS_NOATIME = 0x400
- MS_NODEV = 0x4
- MS_NODIRATIME = 0x800
- MS_NOEXEC = 0x8
- MS_NOSUID = 0x2
- MS_NOUSER = -0x80000000
- MS_POSIXACL = 0x10000
- MS_PRIVATE = 0x40000
- MS_RDONLY = 0x1
- MS_REC = 0x4000
- MS_RELATIME = 0x200000
- MS_REMOUNT = 0x20
- MS_RMT_MASK = 0x800051
- MS_SHARED = 0x100000
- MS_SILENT = 0x8000
- MS_SLAVE = 0x80000
- MS_STRICTATIME = 0x1000000
- MS_SYNC = 0x4
- MS_SYNCHRONOUS = 0x10
- MS_UNBINDABLE = 0x20000
- NAME_MAX = 0xff
- NETLINK_ADD_MEMBERSHIP = 0x1
- NETLINK_AUDIT = 0x9
- NETLINK_BROADCAST_ERROR = 0x4
- NETLINK_CONNECTOR = 0xb
- NETLINK_CRYPTO = 0x15
- NETLINK_DNRTMSG = 0xe
- NETLINK_DROP_MEMBERSHIP = 0x2
- NETLINK_ECRYPTFS = 0x13
- NETLINK_FIB_LOOKUP = 0xa
- NETLINK_FIREWALL = 0x3
- NETLINK_GENERIC = 0x10
- NETLINK_INET_DIAG = 0x4
- NETLINK_IP6_FW = 0xd
- NETLINK_ISCSI = 0x8
- NETLINK_KOBJECT_UEVENT = 0xf
- NETLINK_NETFILTER = 0xc
- NETLINK_NFLOG = 0x5
- NETLINK_NO_ENOBUFS = 0x5
- NETLINK_PKTINFO = 0x3
- NETLINK_RDMA = 0x14
- NETLINK_ROUTE = 0x0
- NETLINK_SCSITRANSPORT = 0x12
- NETLINK_SELINUX = 0x7
- NETLINK_UNUSED = 0x1
- NETLINK_USERSOCK = 0x2
- NETLINK_XFRM = 0x6
- NL0 = 0x0
- NL1 = 0x100
- NLA_ALIGNTO = 0x4
- NLA_F_NESTED = 0x8000
- NLA_F_NET_BYTEORDER = 0x4000
- NLA_HDRLEN = 0x4
- NLDLY = 0x100
- NLMSG_ALIGNTO = 0x4
- NLMSG_DONE = 0x3
- NLMSG_ERROR = 0x2
- NLMSG_HDRLEN = 0x10
- NLMSG_MIN_TYPE = 0x10
- NLMSG_NOOP = 0x1
- NLMSG_OVERRUN = 0x4
- NLM_F_ACK = 0x4
- NLM_F_APPEND = 0x800
- NLM_F_ATOMIC = 0x400
- NLM_F_CREATE = 0x400
- NLM_F_DUMP = 0x300
- NLM_F_DUMP_INTR = 0x10
- NLM_F_ECHO = 0x8
- NLM_F_EXCL = 0x200
- NLM_F_MATCH = 0x200
- NLM_F_MULTI = 0x2
- NLM_F_REPLACE = 0x100
- NLM_F_REQUEST = 0x1
- NLM_F_ROOT = 0x100
- NOFLSH = 0x80
- OCRNL = 0x8
- OFDEL = 0x80
- OFILL = 0x40
- OLCUC = 0x2
- ONLCR = 0x4
- ONLRET = 0x20
- ONOCR = 0x10
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x400
- O_ASYNC = 0x2000
- O_CLOEXEC = 0x80000
- O_CREAT = 0x40
- O_DIRECT = 0x4000
- O_DIRECTORY = 0x10000
- O_DSYNC = 0x1000
- O_EXCL = 0x80
- O_FSYNC = 0x101000
- O_LARGEFILE = 0x0
- O_NDELAY = 0x800
- O_NOATIME = 0x40000
- O_NOCTTY = 0x100
- O_NOFOLLOW = 0x20000
- O_NONBLOCK = 0x800
- O_PATH = 0x200000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_RSYNC = 0x101000
- O_SYNC = 0x101000
- O_TMPFILE = 0x410000
- O_TRUNC = 0x200
- O_WRONLY = 0x1
- PACKET_ADD_MEMBERSHIP = 0x1
- PACKET_AUXDATA = 0x8
- PACKET_BROADCAST = 0x1
- PACKET_COPY_THRESH = 0x7
- PACKET_DROP_MEMBERSHIP = 0x2
- PACKET_FANOUT = 0x12
- PACKET_FANOUT_CPU = 0x2
- PACKET_FANOUT_FLAG_DEFRAG = 0x8000
- PACKET_FANOUT_HASH = 0x0
- PACKET_FANOUT_LB = 0x1
- PACKET_FASTROUTE = 0x6
- PACKET_HDRLEN = 0xb
- PACKET_HOST = 0x0
- PACKET_LOOPBACK = 0x5
- PACKET_LOSS = 0xe
- PACKET_MR_ALLMULTI = 0x2
- PACKET_MR_MULTICAST = 0x0
- PACKET_MR_PROMISC = 0x1
- PACKET_MR_UNICAST = 0x3
- PACKET_MULTICAST = 0x2
- PACKET_ORIGDEV = 0x9
- PACKET_OTHERHOST = 0x3
- PACKET_OUTGOING = 0x4
- PACKET_RECV_OUTPUT = 0x3
- PACKET_RESERVE = 0xc
- PACKET_RX_RING = 0x5
- PACKET_STATISTICS = 0x6
- PACKET_TIMESTAMP = 0x11
- PACKET_TX_RING = 0xd
- PACKET_TX_TIMESTAMP = 0x10
- PACKET_VERSION = 0xa
- PACKET_VNET_HDR = 0xf
- PARENB = 0x100
- PARITY_CRC16_PR0 = 0x2
- PARITY_CRC16_PR0_CCITT = 0x4
- PARITY_CRC16_PR1 = 0x3
- PARITY_CRC16_PR1_CCITT = 0x5
- PARITY_CRC32_PR0_CCITT = 0x6
- PARITY_CRC32_PR1_CCITT = 0x7
- PARITY_DEFAULT = 0x0
- PARITY_NONE = 0x1
- PARMRK = 0x8
- PARODD = 0x200
- PENDIN = 0x4000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_GROWSDOWN = 0x1000000
- PROT_GROWSUP = 0x2000000
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- PR_CAPBSET_DROP = 0x18
- PR_CAPBSET_READ = 0x17
- PR_ENDIAN_BIG = 0x0
- PR_ENDIAN_LITTLE = 0x1
- PR_ENDIAN_PPC_LITTLE = 0x2
- PR_FPEMU_NOPRINT = 0x1
- PR_FPEMU_SIGFPE = 0x2
- PR_FP_EXC_ASYNC = 0x2
- PR_FP_EXC_DISABLED = 0x0
- PR_FP_EXC_DIV = 0x10000
- PR_FP_EXC_INV = 0x100000
- PR_FP_EXC_NONRECOV = 0x1
- PR_FP_EXC_OVF = 0x20000
- PR_FP_EXC_PRECISE = 0x3
- PR_FP_EXC_RES = 0x80000
- PR_FP_EXC_SW_ENABLE = 0x80
- PR_FP_EXC_UND = 0x40000
- PR_GET_DUMPABLE = 0x3
- PR_GET_ENDIAN = 0x13
- PR_GET_FPEMU = 0x9
- PR_GET_FPEXC = 0xb
- PR_GET_KEEPCAPS = 0x7
- PR_GET_NAME = 0x10
- PR_GET_NO_NEW_PRIVS = 0x27
- PR_GET_PDEATHSIG = 0x2
- PR_GET_SECCOMP = 0x15
- PR_GET_SECUREBITS = 0x1b
- PR_GET_TIMERSLACK = 0x1e
- PR_GET_TIMING = 0xd
- PR_GET_TSC = 0x19
- PR_GET_UNALIGN = 0x5
- PR_MCE_KILL = 0x21
- PR_MCE_KILL_CLEAR = 0x0
- PR_MCE_KILL_DEFAULT = 0x2
- PR_MCE_KILL_EARLY = 0x1
- PR_MCE_KILL_GET = 0x22
- PR_MCE_KILL_LATE = 0x0
- PR_MCE_KILL_SET = 0x1
- PR_SET_DUMPABLE = 0x4
- PR_SET_ENDIAN = 0x14
- PR_SET_FPEMU = 0xa
- PR_SET_FPEXC = 0xc
- PR_SET_KEEPCAPS = 0x8
- PR_SET_MM = 0x23
- PR_SET_MM_BRK = 0x7
- PR_SET_MM_END_CODE = 0x2
- PR_SET_MM_END_DATA = 0x4
- PR_SET_MM_START_BRK = 0x6
- PR_SET_MM_START_CODE = 0x1
- PR_SET_MM_START_DATA = 0x3
- PR_SET_MM_START_STACK = 0x5
- PR_SET_NAME = 0xf
- PR_SET_NO_NEW_PRIVS = 0x26
- PR_SET_PDEATHSIG = 0x1
- PR_SET_PTRACER = 0x59616d61
- PR_SET_PTRACER_ANY = -0x1
- PR_SET_SECCOMP = 0x16
- PR_SET_SECUREBITS = 0x1c
- PR_SET_TIMERSLACK = 0x1d
- PR_SET_TIMING = 0xe
- PR_SET_TSC = 0x1a
- PR_SET_UNALIGN = 0x6
- PR_TASK_PERF_EVENTS_DISABLE = 0x1f
- PR_TASK_PERF_EVENTS_ENABLE = 0x20
- PR_TIMING_STATISTICAL = 0x0
- PR_TIMING_TIMESTAMP = 0x1
- PR_TSC_ENABLE = 0x1
- PR_TSC_SIGSEGV = 0x2
- PR_UNALIGN_NOPRINT = 0x1
- PR_UNALIGN_SIGBUS = 0x2
- PTRACE_ARCH_PRCTL = 0x1e
- PTRACE_ATTACH = 0x10
- PTRACE_CONT = 0x7
- PTRACE_DETACH = 0x11
- PTRACE_EVENT_CLONE = 0x3
- PTRACE_EVENT_EXEC = 0x4
- PTRACE_EVENT_EXIT = 0x6
- PTRACE_EVENT_FORK = 0x1
- PTRACE_EVENT_SECCOMP = 0x7
- PTRACE_EVENT_STOP = 0x80
- PTRACE_EVENT_VFORK = 0x2
- PTRACE_EVENT_VFORK_DONE = 0x5
- PTRACE_GETEVENTMSG = 0x4201
- PTRACE_GETFPREGS = 0xe
- PTRACE_GETFPXREGS = 0x12
- PTRACE_GETREGS = 0xc
- PTRACE_GETREGSET = 0x4204
- PTRACE_GETSIGINFO = 0x4202
- PTRACE_GET_THREAD_AREA = 0x19
- PTRACE_INTERRUPT = 0x4207
- PTRACE_KILL = 0x8
- PTRACE_LISTEN = 0x4208
- PTRACE_OLDSETOPTIONS = 0x15
- PTRACE_O_MASK = 0xff
- PTRACE_O_TRACECLONE = 0x8
- PTRACE_O_TRACEEXEC = 0x10
- PTRACE_O_TRACEEXIT = 0x40
- PTRACE_O_TRACEFORK = 0x2
- PTRACE_O_TRACESECCOMP = 0x80
- PTRACE_O_TRACESYSGOOD = 0x1
- PTRACE_O_TRACEVFORK = 0x4
- PTRACE_O_TRACEVFORKDONE = 0x20
- PTRACE_PEEKDATA = 0x2
- PTRACE_PEEKTEXT = 0x1
- PTRACE_PEEKUSR = 0x3
- PTRACE_POKEDATA = 0x5
- PTRACE_POKETEXT = 0x4
- PTRACE_POKEUSR = 0x6
- PTRACE_SEIZE = 0x4206
- PTRACE_SEIZE_DEVEL = 0x80000000
- PTRACE_SETFPREGS = 0xf
- PTRACE_SETFPXREGS = 0x13
- PTRACE_SETOPTIONS = 0x4200
- PTRACE_SETREGS = 0xd
- PTRACE_SETREGSET = 0x4205
- PTRACE_SETSIGINFO = 0x4203
- PTRACE_SET_THREAD_AREA = 0x1a
- PTRACE_SINGLEBLOCK = 0x21
- PTRACE_SINGLESTEP = 0x9
- PTRACE_SYSCALL = 0x18
- PTRACE_SYSEMU = 0x1f
- PTRACE_SYSEMU_SINGLESTEP = 0x20
- PTRACE_TRACEME = 0x0
- RLIMIT_AS = 0x9
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x7
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = -0x1
- RTAX_ADVMSS = 0x8
- RTAX_CWND = 0x7
- RTAX_FEATURES = 0xc
- RTAX_FEATURE_ALLFRAG = 0x8
- RTAX_FEATURE_ECN = 0x1
- RTAX_FEATURE_SACK = 0x2
- RTAX_FEATURE_TIMESTAMP = 0x4
- RTAX_HOPLIMIT = 0xa
- RTAX_INITCWND = 0xb
- RTAX_INITRWND = 0xe
- RTAX_LOCK = 0x1
- RTAX_MAX = 0xe
- RTAX_MTU = 0x2
- RTAX_REORDERING = 0x9
- RTAX_RTO_MIN = 0xd
- RTAX_RTT = 0x4
- RTAX_RTTVAR = 0x5
- RTAX_SSTHRESH = 0x6
- RTAX_UNSPEC = 0x0
- RTAX_WINDOW = 0x3
- RTA_ALIGNTO = 0x4
- RTA_MAX = 0x10
- RTCF_DIRECTSRC = 0x4000000
- RTCF_DOREDIRECT = 0x1000000
- RTCF_LOG = 0x2000000
- RTCF_MASQ = 0x400000
- RTCF_NAT = 0x800000
- RTCF_VALVE = 0x200000
- RTF_ADDRCLASSMASK = 0xf8000000
- RTF_ADDRCONF = 0x40000
- RTF_ALLONLINK = 0x20000
- RTF_BROADCAST = 0x10000000
- RTF_CACHE = 0x1000000
- RTF_DEFAULT = 0x10000
- RTF_DYNAMIC = 0x10
- RTF_FLOW = 0x2000000
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_INTERFACE = 0x40000000
- RTF_IRTT = 0x100
- RTF_LINKRT = 0x100000
- RTF_LOCAL = 0x80000000
- RTF_MODIFIED = 0x20
- RTF_MSS = 0x40
- RTF_MTU = 0x40
- RTF_MULTICAST = 0x20000000
- RTF_NAT = 0x8000000
- RTF_NOFORWARD = 0x1000
- RTF_NONEXTHOP = 0x200000
- RTF_NOPMTUDISC = 0x4000
- RTF_POLICY = 0x4000000
- RTF_REINSTATE = 0x8
- RTF_REJECT = 0x200
- RTF_STATIC = 0x400
- RTF_THROW = 0x2000
- RTF_UP = 0x1
- RTF_WINDOW = 0x80
- RTF_XRESOLVE = 0x800
- RTM_BASE = 0x10
- RTM_DELACTION = 0x31
- RTM_DELADDR = 0x15
- RTM_DELADDRLABEL = 0x49
- RTM_DELLINK = 0x11
- RTM_DELNEIGH = 0x1d
- RTM_DELQDISC = 0x25
- RTM_DELROUTE = 0x19
- RTM_DELRULE = 0x21
- RTM_DELTCLASS = 0x29
- RTM_DELTFILTER = 0x2d
- RTM_F_CLONED = 0x200
- RTM_F_EQUALIZE = 0x400
- RTM_F_NOTIFY = 0x100
- RTM_F_PREFIX = 0x800
- RTM_GETACTION = 0x32
- RTM_GETADDR = 0x16
- RTM_GETADDRLABEL = 0x4a
- RTM_GETANYCAST = 0x3e
- RTM_GETDCB = 0x4e
- RTM_GETLINK = 0x12
- RTM_GETMULTICAST = 0x3a
- RTM_GETNEIGH = 0x1e
- RTM_GETNEIGHTBL = 0x42
- RTM_GETQDISC = 0x26
- RTM_GETROUTE = 0x1a
- RTM_GETRULE = 0x22
- RTM_GETTCLASS = 0x2a
- RTM_GETTFILTER = 0x2e
- RTM_MAX = 0x4f
- RTM_NEWACTION = 0x30
- RTM_NEWADDR = 0x14
- RTM_NEWADDRLABEL = 0x48
- RTM_NEWLINK = 0x10
- RTM_NEWNDUSEROPT = 0x44
- RTM_NEWNEIGH = 0x1c
- RTM_NEWNEIGHTBL = 0x40
- RTM_NEWPREFIX = 0x34
- RTM_NEWQDISC = 0x24
- RTM_NEWROUTE = 0x18
- RTM_NEWRULE = 0x20
- RTM_NEWTCLASS = 0x28
- RTM_NEWTFILTER = 0x2c
- RTM_NR_FAMILIES = 0x10
- RTM_NR_MSGTYPES = 0x40
- RTM_SETDCB = 0x4f
- RTM_SETLINK = 0x13
- RTM_SETNEIGHTBL = 0x43
- RTNH_ALIGNTO = 0x4
- RTNH_F_DEAD = 0x1
- RTNH_F_ONLINK = 0x4
- RTNH_F_PERVASIVE = 0x2
- RTN_MAX = 0xb
- RTPROT_BIRD = 0xc
- RTPROT_BOOT = 0x3
- RTPROT_DHCP = 0x10
- RTPROT_DNROUTED = 0xd
- RTPROT_GATED = 0x8
- RTPROT_KERNEL = 0x2
- RTPROT_MRT = 0xa
- RTPROT_NTK = 0xf
- RTPROT_RA = 0x9
- RTPROT_REDIRECT = 0x1
- RTPROT_STATIC = 0x4
- RTPROT_UNSPEC = 0x0
- RTPROT_XORP = 0xe
- RTPROT_ZEBRA = 0xb
- RT_CLASS_DEFAULT = 0xfd
- RT_CLASS_LOCAL = 0xff
- RT_CLASS_MAIN = 0xfe
- RT_CLASS_MAX = 0xff
- RT_CLASS_UNSPEC = 0x0
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- RUSAGE_THREAD = 0x1
- SCM_CREDENTIALS = 0x2
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x1d
- SCM_TIMESTAMPING = 0x25
- SCM_TIMESTAMPNS = 0x23
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDDLCI = 0x8980
- SIOCADDMULTI = 0x8931
- SIOCADDRT = 0x890b
- SIOCATMARK = 0x8905
- SIOCDARP = 0x8953
- SIOCDELDLCI = 0x8981
- SIOCDELMULTI = 0x8932
- SIOCDELRT = 0x890c
- SIOCDEVPRIVATE = 0x89f0
- SIOCDIFADDR = 0x8936
- SIOCDRARP = 0x8960
- SIOCGARP = 0x8954
- SIOCGIFADDR = 0x8915
- SIOCGIFBR = 0x8940
- SIOCGIFBRDADDR = 0x8919
- SIOCGIFCONF = 0x8912
- SIOCGIFCOUNT = 0x8938
- SIOCGIFDSTADDR = 0x8917
- SIOCGIFENCAP = 0x8925
- SIOCGIFFLAGS = 0x8913
- SIOCGIFHWADDR = 0x8927
- SIOCGIFINDEX = 0x8933
- SIOCGIFMAP = 0x8970
- SIOCGIFMEM = 0x891f
- SIOCGIFMETRIC = 0x891d
- SIOCGIFMTU = 0x8921
- SIOCGIFNAME = 0x8910
- SIOCGIFNETMASK = 0x891b
- SIOCGIFPFLAGS = 0x8935
- SIOCGIFSLAVE = 0x8929
- SIOCGIFTXQLEN = 0x8942
- SIOCGPGRP = 0x8904
- SIOCGRARP = 0x8961
- SIOCGSTAMP = 0x8906
- SIOCGSTAMPNS = 0x8907
- SIOCPROTOPRIVATE = 0x89e0
- SIOCRTMSG = 0x890d
- SIOCSARP = 0x8955
- SIOCSIFADDR = 0x8916
- SIOCSIFBR = 0x8941
- SIOCSIFBRDADDR = 0x891a
- SIOCSIFDSTADDR = 0x8918
- SIOCSIFENCAP = 0x8926
- SIOCSIFFLAGS = 0x8914
- SIOCSIFHWADDR = 0x8924
- SIOCSIFHWBROADCAST = 0x8937
- SIOCSIFLINK = 0x8911
- SIOCSIFMAP = 0x8971
- SIOCSIFMEM = 0x8920
- SIOCSIFMETRIC = 0x891e
- SIOCSIFMTU = 0x8922
- SIOCSIFNAME = 0x8923
- SIOCSIFNETMASK = 0x891c
- SIOCSIFPFLAGS = 0x8934
- SIOCSIFSLAVE = 0x8930
- SIOCSIFTXQLEN = 0x8943
- SIOCSPGRP = 0x8902
- SIOCSRARP = 0x8962
- SOCK_CLOEXEC = 0x80000
- SOCK_DCCP = 0x6
- SOCK_DGRAM = 0x2
- SOCK_NONBLOCK = 0x800
- SOCK_PACKET = 0xa
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_AAL = 0x109
- SOL_ATM = 0x108
- SOL_DECNET = 0x105
- SOL_ICMPV6 = 0x3a
- SOL_IP = 0x0
- SOL_IPV6 = 0x29
- SOL_IRDA = 0x10a
- SOL_PACKET = 0x107
- SOL_RAW = 0xff
- SOL_SOCKET = 0x1
- SOL_TCP = 0x6
- SOL_X25 = 0x106
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x1e
- SO_ATTACH_FILTER = 0x1a
- SO_BINDTODEVICE = 0x19
- SO_BROADCAST = 0x6
- SO_BSDCOMPAT = 0xe
- SO_DEBUG = 0x1
- SO_DETACH_FILTER = 0x1b
- SO_DOMAIN = 0x27
- SO_DONTROUTE = 0x5
- SO_ERROR = 0x4
- SO_KEEPALIVE = 0x9
- SO_LINGER = 0xd
- SO_MARK = 0x24
- SO_NO_CHECK = 0xb
- SO_OOBINLINE = 0xa
- SO_PASSCRED = 0x10
- SO_PASSSEC = 0x22
- SO_PEERCRED = 0x11
- SO_PEERNAME = 0x1c
- SO_PEERSEC = 0x1f
- SO_PRIORITY = 0xc
- SO_PROTOCOL = 0x26
- SO_RCVBUF = 0x8
- SO_RCVBUFFORCE = 0x21
- SO_RCVLOWAT = 0x12
- SO_RCVTIMEO = 0x14
- SO_REUSEADDR = 0x2
- SO_RXQ_OVFL = 0x28
- SO_SECURITY_AUTHENTICATION = 0x16
- SO_SECURITY_ENCRYPTION_NETWORK = 0x18
- SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17
- SO_SNDBUF = 0x7
- SO_SNDBUFFORCE = 0x20
- SO_SNDLOWAT = 0x13
- SO_SNDTIMEO = 0x15
- SO_TIMESTAMP = 0x1d
- SO_TIMESTAMPING = 0x25
- SO_TIMESTAMPNS = 0x23
- SO_TYPE = 0x3
- S_BLKSIZE = 0x200
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TAB0 = 0x0
- TAB1 = 0x800
- TAB2 = 0x1000
- TAB3 = 0x1800
- TABDLY = 0x1800
- TCFLSH = 0x540b
- TCGETA = 0x5405
- TCGETS = 0x5401
- TCGETS2 = 0x802c542a
- TCGETX = 0x5432
- TCIFLUSH = 0x0
- TCIOFF = 0x2
- TCIOFLUSH = 0x2
- TCION = 0x3
- TCOFLUSH = 0x1
- TCOOFF = 0x0
- TCOON = 0x1
- TCP_CONGESTION = 0xd
- TCP_CORK = 0x3
- TCP_DEFER_ACCEPT = 0x9
- TCP_INFO = 0xb
- TCP_KEEPCNT = 0x6
- TCP_KEEPIDLE = 0x4
- TCP_KEEPINTVL = 0x5
- TCP_LINGER2 = 0x8
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0xe
- TCP_MD5SIG_MAXKEYLEN = 0x50
- TCP_MSS = 0x200
- TCP_NODELAY = 0x1
- TCP_QUICKACK = 0xc
- TCP_SYNCNT = 0x7
- TCP_WINDOW_CLAMP = 0xa
- TCSAFLUSH = 0x2
- TCSBRK = 0x5409
- TCSBRKP = 0x5425
- TCSETA = 0x5406
- TCSETAF = 0x5408
- TCSETAW = 0x5407
- TCSETS = 0x5402
- TCSETS2 = 0x402c542b
- TCSETSF = 0x5404
- TCSETSF2 = 0x402c542d
- TCSETSW = 0x5403
- TCSETSW2 = 0x402c542c
- TCSETX = 0x5433
- TCSETXF = 0x5434
- TCSETXW = 0x5435
- TCXONC = 0x540a
- TIOCCBRK = 0x5428
- TIOCCONS = 0x541d
- TIOCEXCL = 0x540c
- TIOCGDEV = 0x80045432
- TIOCGETD = 0x5424
- TIOCGEXCL = 0x80045440
- TIOCGICOUNT = 0x545d
- TIOCGLCKTRMIOS = 0x5456
- TIOCGPGRP = 0x540f
- TIOCGPKT = 0x80045438
- TIOCGPTLCK = 0x80045439
- TIOCGPTN = 0x80045430
- TIOCGRS485 = 0x542e
- TIOCGSERIAL = 0x541e
- TIOCGSID = 0x5429
- TIOCGSOFTCAR = 0x5419
- TIOCGWINSZ = 0x5413
- TIOCINQ = 0x541b
- TIOCLINUX = 0x541c
- TIOCMBIC = 0x5417
- TIOCMBIS = 0x5416
- TIOCMGET = 0x5415
- TIOCMIWAIT = 0x545c
- TIOCMSET = 0x5418
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x5422
- TIOCNXCL = 0x540d
- TIOCOUTQ = 0x5411
- TIOCPKT = 0x5420
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCSBRK = 0x5427
- TIOCSCTTY = 0x540e
- TIOCSERCONFIG = 0x5453
- TIOCSERGETLSR = 0x5459
- TIOCSERGETMULTI = 0x545a
- TIOCSERGSTRUCT = 0x5458
- TIOCSERGWILD = 0x5454
- TIOCSERSETMULTI = 0x545b
- TIOCSERSWILD = 0x5455
- TIOCSER_TEMT = 0x1
- TIOCSETD = 0x5423
- TIOCSIG = 0x40045436
- TIOCSLCKTRMIOS = 0x5457
- TIOCSPGRP = 0x5410
- TIOCSPTLCK = 0x40045431
- TIOCSRS485 = 0x542f
- TIOCSSERIAL = 0x541f
- TIOCSSOFTCAR = 0x541a
- TIOCSTI = 0x5412
- TIOCSWINSZ = 0x5414
- TIOCVHANGUP = 0x5437
- TOSTOP = 0x100
- TUNATTACHFILTER = 0x401054d5
- TUNDETACHFILTER = 0x401054d6
- TUNGETFEATURES = 0x800454cf
- TUNGETIFF = 0x800454d2
- TUNGETSNDBUF = 0x800454d3
- TUNGETVNETHDRSZ = 0x800454d7
- TUNSETDEBUG = 0x400454c9
- TUNSETGROUP = 0x400454ce
- TUNSETIFF = 0x400454ca
- TUNSETLINK = 0x400454cd
- TUNSETNOCSUM = 0x400454c8
- TUNSETOFFLOAD = 0x400454d0
- TUNSETOWNER = 0x400454cc
- TUNSETPERSIST = 0x400454cb
- TUNSETSNDBUF = 0x400454d4
- TUNSETTXFILTER = 0x400454d1
- TUNSETVNETHDRSZ = 0x400454d8
- VDISCARD = 0xd
- VEOF = 0x4
- VEOL = 0xb
- VEOL2 = 0x10
- VERASE = 0x2
- VINTR = 0x0
- VKILL = 0x3
- VLNEXT = 0xf
- VMIN = 0x6
- VQUIT = 0x1
- VREPRINT = 0xc
- VSTART = 0x8
- VSTOP = 0x9
- VSUSP = 0xa
- VSWTC = 0x7
- VT0 = 0x0
- VT1 = 0x4000
- VTDLY = 0x4000
- VTIME = 0x5
- VWERASE = 0xe
- WALL = 0x40000000
- WCLONE = 0x80000000
- WCONTINUED = 0x8
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOTHREAD = 0x20000000
- WNOWAIT = 0x1000000
- WORDSIZE = 0x40
- WSTOPPED = 0x2
- WUNTRACED = 0x2
- XCASE = 0x4
- XTABS = 0x1800
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x62)
- EADDRNOTAVAIL = syscall.Errno(0x63)
- EADV = syscall.Errno(0x44)
- EAFNOSUPPORT = syscall.Errno(0x61)
- EAGAIN = syscall.Errno(0xb)
- EALREADY = syscall.Errno(0x72)
- EBADE = syscall.Errno(0x34)
- EBADF = syscall.Errno(0x9)
- EBADFD = syscall.Errno(0x4d)
- EBADMSG = syscall.Errno(0x4a)
- EBADR = syscall.Errno(0x35)
- EBADRQC = syscall.Errno(0x38)
- EBADSLT = syscall.Errno(0x39)
- EBFONT = syscall.Errno(0x3b)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x7d)
- ECHILD = syscall.Errno(0xa)
- ECHRNG = syscall.Errno(0x2c)
- ECOMM = syscall.Errno(0x46)
- ECONNABORTED = syscall.Errno(0x67)
- ECONNREFUSED = syscall.Errno(0x6f)
- ECONNRESET = syscall.Errno(0x68)
- EDEADLK = syscall.Errno(0x23)
- EDEADLOCK = syscall.Errno(0x23)
- EDESTADDRREQ = syscall.Errno(0x59)
- EDOM = syscall.Errno(0x21)
- EDOTDOT = syscall.Errno(0x49)
- EDQUOT = syscall.Errno(0x7a)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EHOSTDOWN = syscall.Errno(0x70)
- EHOSTUNREACH = syscall.Errno(0x71)
- EHWPOISON = syscall.Errno(0x85)
- EIDRM = syscall.Errno(0x2b)
- EILSEQ = syscall.Errno(0x54)
- EINPROGRESS = syscall.Errno(0x73)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x6a)
- EISDIR = syscall.Errno(0x15)
- EISNAM = syscall.Errno(0x78)
- EKEYEXPIRED = syscall.Errno(0x7f)
- EKEYREJECTED = syscall.Errno(0x81)
- EKEYREVOKED = syscall.Errno(0x80)
- EL2HLT = syscall.Errno(0x33)
- EL2NSYNC = syscall.Errno(0x2d)
- EL3HLT = syscall.Errno(0x2e)
- EL3RST = syscall.Errno(0x2f)
- ELIBACC = syscall.Errno(0x4f)
- ELIBBAD = syscall.Errno(0x50)
- ELIBEXEC = syscall.Errno(0x53)
- ELIBMAX = syscall.Errno(0x52)
- ELIBSCN = syscall.Errno(0x51)
- ELNRNG = syscall.Errno(0x30)
- ELOOP = syscall.Errno(0x28)
- EMEDIUMTYPE = syscall.Errno(0x7c)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x5a)
- EMULTIHOP = syscall.Errno(0x48)
- ENAMETOOLONG = syscall.Errno(0x24)
- ENAVAIL = syscall.Errno(0x77)
- ENETDOWN = syscall.Errno(0x64)
- ENETRESET = syscall.Errno(0x66)
- ENETUNREACH = syscall.Errno(0x65)
- ENFILE = syscall.Errno(0x17)
- ENOANO = syscall.Errno(0x37)
- ENOBUFS = syscall.Errno(0x69)
- ENOCSI = syscall.Errno(0x32)
- ENODATA = syscall.Errno(0x3d)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOKEY = syscall.Errno(0x7e)
- ENOLCK = syscall.Errno(0x25)
- ENOLINK = syscall.Errno(0x43)
- ENOMEDIUM = syscall.Errno(0x7b)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x2a)
- ENONET = syscall.Errno(0x40)
- ENOPKG = syscall.Errno(0x41)
- ENOPROTOOPT = syscall.Errno(0x5c)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x3f)
- ENOSTR = syscall.Errno(0x3c)
- ENOSYS = syscall.Errno(0x26)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x6b)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x27)
- ENOTNAM = syscall.Errno(0x76)
- ENOTRECOVERABLE = syscall.Errno(0x83)
- ENOTSOCK = syscall.Errno(0x58)
- ENOTSUP = syscall.Errno(0x5f)
- ENOTTY = syscall.Errno(0x19)
- ENOTUNIQ = syscall.Errno(0x4c)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x5f)
- EOVERFLOW = syscall.Errno(0x4b)
- EOWNERDEAD = syscall.Errno(0x82)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x60)
- EPIPE = syscall.Errno(0x20)
- EPROTO = syscall.Errno(0x47)
- EPROTONOSUPPORT = syscall.Errno(0x5d)
- EPROTOTYPE = syscall.Errno(0x5b)
- ERANGE = syscall.Errno(0x22)
- EREMCHG = syscall.Errno(0x4e)
- EREMOTE = syscall.Errno(0x42)
- EREMOTEIO = syscall.Errno(0x79)
- ERESTART = syscall.Errno(0x55)
- ERFKILL = syscall.Errno(0x84)
- EROFS = syscall.Errno(0x1e)
- ESHUTDOWN = syscall.Errno(0x6c)
- ESOCKTNOSUPPORT = syscall.Errno(0x5e)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESRMNT = syscall.Errno(0x45)
- ESTALE = syscall.Errno(0x74)
- ESTRPIPE = syscall.Errno(0x56)
- ETIME = syscall.Errno(0x3e)
- ETIMEDOUT = syscall.Errno(0x6e)
- ETOOMANYREFS = syscall.Errno(0x6d)
- ETXTBSY = syscall.Errno(0x1a)
- EUCLEAN = syscall.Errno(0x75)
- EUNATCH = syscall.Errno(0x31)
- EUSERS = syscall.Errno(0x57)
- EWOULDBLOCK = syscall.Errno(0xb)
- EXDEV = syscall.Errno(0x12)
- EXFULL = syscall.Errno(0x36)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0x7)
- SIGCHLD = syscall.Signal(0x11)
- SIGCLD = syscall.Signal(0x11)
- SIGCONT = syscall.Signal(0x12)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x1d)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPOLL = syscall.Signal(0x1d)
- SIGPROF = syscall.Signal(0x1b)
- SIGPWR = syscall.Signal(0x1e)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTKFLT = syscall.Signal(0x10)
- SIGSTOP = syscall.Signal(0x13)
- SIGSYS = syscall.Signal(0x1f)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x14)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGUNUSED = syscall.Signal(0x1f)
- SIGURG = syscall.Signal(0x17)
- SIGUSR1 = syscall.Signal(0xa)
- SIGUSR2 = syscall.Signal(0xc)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "no such device or address",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource temporarily unavailable",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device or resource busy",
- 17: "file exists",
- 18: "invalid cross-device link",
- 19: "no such device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "numerical result out of range",
- 35: "resource deadlock avoided",
- 36: "file name too long",
- 37: "no locks available",
- 38: "function not implemented",
- 39: "directory not empty",
- 40: "too many levels of symbolic links",
- 42: "no message of desired type",
- 43: "identifier removed",
- 44: "channel number out of range",
- 45: "level 2 not synchronized",
- 46: "level 3 halted",
- 47: "level 3 reset",
- 48: "link number out of range",
- 49: "protocol driver not attached",
- 50: "no CSI structure available",
- 51: "level 2 halted",
- 52: "invalid exchange",
- 53: "invalid request descriptor",
- 54: "exchange full",
- 55: "no anode",
- 56: "invalid request code",
- 57: "invalid slot",
- 59: "bad font file format",
- 60: "device not a stream",
- 61: "no data available",
- 62: "timer expired",
- 63: "out of streams resources",
- 64: "machine is not on the network",
- 65: "package not installed",
- 66: "object is remote",
- 67: "link has been severed",
- 68: "advertise error",
- 69: "srmount error",
- 70: "communication error on send",
- 71: "protocol error",
- 72: "multihop attempted",
- 73: "RFS specific error",
- 74: "bad message",
- 75: "value too large for defined data type",
- 76: "name not unique on network",
- 77: "file descriptor in bad state",
- 78: "remote address changed",
- 79: "can not access a needed shared library",
- 80: "accessing a corrupted shared library",
- 81: ".lib section in a.out corrupted",
- 82: "attempting to link in too many shared libraries",
- 83: "cannot exec a shared library directly",
- 84: "invalid or incomplete multibyte or wide character",
- 85: "interrupted system call should be restarted",
- 86: "streams pipe error",
- 87: "too many users",
- 88: "socket operation on non-socket",
- 89: "destination address required",
- 90: "message too long",
- 91: "protocol wrong type for socket",
- 92: "protocol not available",
- 93: "protocol not supported",
- 94: "socket type not supported",
- 95: "operation not supported",
- 96: "protocol family not supported",
- 97: "address family not supported by protocol",
- 98: "address already in use",
- 99: "cannot assign requested address",
- 100: "network is down",
- 101: "network is unreachable",
- 102: "network dropped connection on reset",
- 103: "software caused connection abort",
- 104: "connection reset by peer",
- 105: "no buffer space available",
- 106: "transport endpoint is already connected",
- 107: "transport endpoint is not connected",
- 108: "cannot send after transport endpoint shutdown",
- 109: "too many references: cannot splice",
- 110: "connection timed out",
- 111: "connection refused",
- 112: "host is down",
- 113: "no route to host",
- 114: "operation already in progress",
- 115: "operation now in progress",
- 116: "stale NFS file handle",
- 117: "structure needs cleaning",
- 118: "not a XENIX named type file",
- 119: "no XENIX semaphores available",
- 120: "is a named type file",
- 121: "remote I/O error",
- 122: "disk quota exceeded",
- 123: "no medium found",
- 124: "wrong medium type",
- 125: "operation canceled",
- 126: "required key not available",
- 127: "key has expired",
- 128: "key has been revoked",
- 129: "key was rejected by service",
- 130: "owner died",
- 131: "state not recoverable",
- 132: "operation not possible due to RF-kill",
- 133: "unknown error 133",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/breakpoint trap",
- 6: "aborted",
- 7: "bus error",
- 8: "floating point exception",
- 9: "killed",
- 10: "user defined signal 1",
- 11: "segmentation fault",
- 12: "user defined signal 2",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "stack fault",
- 17: "child exited",
- 18: "continued",
- 19: "stopped (signal)",
- 20: "stopped",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "urgent I/O condition",
- 24: "CPU time limit exceeded",
- 25: "file size limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window changed",
- 29: "I/O possible",
- 30: "power failure",
- 31: "bad system call",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/newt/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
deleted file mode 100644
index f036758f..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
+++ /dev/null
@@ -1,1743 +0,0 @@
-// mkerrors.sh
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build arm,linux
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_ALG = 0x26
- AF_APPLETALK = 0x5
- AF_ASH = 0x12
- AF_ATMPVC = 0x8
- AF_ATMSVC = 0x14
- AF_AX25 = 0x3
- AF_BLUETOOTH = 0x1f
- AF_BRIDGE = 0x7
- AF_CAIF = 0x25
- AF_CAN = 0x1d
- AF_DECnet = 0xc
- AF_ECONET = 0x13
- AF_FILE = 0x1
- AF_IEEE802154 = 0x24
- AF_INET = 0x2
- AF_INET6 = 0xa
- AF_IPX = 0x4
- AF_IRDA = 0x17
- AF_ISDN = 0x22
- AF_IUCV = 0x20
- AF_KEY = 0xf
- AF_LLC = 0x1a
- AF_LOCAL = 0x1
- AF_MAX = 0x27
- AF_NETBEUI = 0xd
- AF_NETLINK = 0x10
- AF_NETROM = 0x6
- AF_PACKET = 0x11
- AF_PHONET = 0x23
- AF_PPPOX = 0x18
- AF_RDS = 0x15
- AF_ROSE = 0xb
- AF_ROUTE = 0x10
- AF_RXRPC = 0x21
- AF_SECURITY = 0xe
- AF_SNA = 0x16
- AF_TIPC = 0x1e
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_WANPIPE = 0x19
- AF_X25 = 0x9
- ARPHRD_ADAPT = 0x108
- ARPHRD_APPLETLK = 0x8
- ARPHRD_ARCNET = 0x7
- ARPHRD_ASH = 0x30d
- ARPHRD_ATM = 0x13
- ARPHRD_AX25 = 0x3
- ARPHRD_BIF = 0x307
- ARPHRD_CHAOS = 0x5
- ARPHRD_CISCO = 0x201
- ARPHRD_CSLIP = 0x101
- ARPHRD_CSLIP6 = 0x103
- ARPHRD_DDCMP = 0x205
- ARPHRD_DLCI = 0xf
- ARPHRD_ECONET = 0x30e
- ARPHRD_EETHER = 0x2
- ARPHRD_ETHER = 0x1
- ARPHRD_EUI64 = 0x1b
- ARPHRD_FCAL = 0x311
- ARPHRD_FCFABRIC = 0x313
- ARPHRD_FCPL = 0x312
- ARPHRD_FCPP = 0x310
- ARPHRD_FDDI = 0x306
- ARPHRD_FRAD = 0x302
- ARPHRD_HDLC = 0x201
- ARPHRD_HIPPI = 0x30c
- ARPHRD_HWX25 = 0x110
- ARPHRD_IEEE1394 = 0x18
- ARPHRD_IEEE802 = 0x6
- ARPHRD_IEEE80211 = 0x321
- ARPHRD_IEEE80211_PRISM = 0x322
- ARPHRD_IEEE80211_RADIOTAP = 0x323
- ARPHRD_IEEE802154 = 0x324
- ARPHRD_IEEE802154_PHY = 0x325
- ARPHRD_IEEE802_TR = 0x320
- ARPHRD_INFINIBAND = 0x20
- ARPHRD_IPDDP = 0x309
- ARPHRD_IPGRE = 0x30a
- ARPHRD_IRDA = 0x30f
- ARPHRD_LAPB = 0x204
- ARPHRD_LOCALTLK = 0x305
- ARPHRD_LOOPBACK = 0x304
- ARPHRD_METRICOM = 0x17
- ARPHRD_NETROM = 0x0
- ARPHRD_NONE = 0xfffe
- ARPHRD_PIMREG = 0x30b
- ARPHRD_PPP = 0x200
- ARPHRD_PRONET = 0x4
- ARPHRD_RAWHDLC = 0x206
- ARPHRD_ROSE = 0x10e
- ARPHRD_RSRVD = 0x104
- ARPHRD_SIT = 0x308
- ARPHRD_SKIP = 0x303
- ARPHRD_SLIP = 0x100
- ARPHRD_SLIP6 = 0x102
- ARPHRD_TUNNEL = 0x300
- ARPHRD_TUNNEL6 = 0x301
- ARPHRD_VOID = 0xffff
- ARPHRD_X25 = 0x10f
- B0 = 0x0
- B1000000 = 0x1008
- B110 = 0x3
- B115200 = 0x1002
- B1152000 = 0x1009
- B1200 = 0x9
- B134 = 0x4
- B150 = 0x5
- B1500000 = 0x100a
- B1800 = 0xa
- B19200 = 0xe
- B200 = 0x6
- B2000000 = 0x100b
- B230400 = 0x1003
- B2400 = 0xb
- B2500000 = 0x100c
- B300 = 0x7
- B3000000 = 0x100d
- B3500000 = 0x100e
- B38400 = 0xf
- B4000000 = 0x100f
- B460800 = 0x1004
- B4800 = 0xc
- B50 = 0x1
- B500000 = 0x1005
- B57600 = 0x1001
- B576000 = 0x1006
- B600 = 0x8
- B75 = 0x2
- B921600 = 0x1007
- B9600 = 0xd
- BOTHER = 0x1000
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXINSNS = 0x1000
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BRKINT = 0x2
- BS0 = 0x0
- BS1 = 0x2000
- BSDLY = 0x2000
- CBAUD = 0x100f
- CBAUDEX = 0x1000
- CFLUSH = 0xf
- CIBAUD = 0x100f0000
- CLOCAL = 0x800
- CLOCK_BOOTTIME = 0x7
- CLOCK_BOOTTIME_ALARM = 0x9
- CLOCK_DEFAULT = 0x0
- CLOCK_EXT = 0x1
- CLOCK_INT = 0x2
- CLOCK_MONOTONIC = 0x1
- CLOCK_MONOTONIC_COARSE = 0x6
- CLOCK_MONOTONIC_RAW = 0x4
- CLOCK_PROCESS_CPUTIME_ID = 0x2
- CLOCK_REALTIME = 0x0
- CLOCK_REALTIME_ALARM = 0x8
- CLOCK_REALTIME_COARSE = 0x5
- CLOCK_THREAD_CPUTIME_ID = 0x3
- CLOCK_TXFROMRX = 0x4
- CLOCK_TXINT = 0x3
- CLONE_CHILD_CLEARTID = 0x200000
- CLONE_CHILD_SETTID = 0x1000000
- CLONE_DETACHED = 0x400000
- CLONE_FILES = 0x400
- CLONE_FS = 0x200
- CLONE_IO = 0x80000000
- CLONE_NEWCGROUP = 0x2000000
- CLONE_NEWIPC = 0x8000000
- CLONE_NEWNET = 0x40000000
- CLONE_NEWNS = 0x20000
- CLONE_NEWPID = 0x20000000
- CLONE_NEWUSER = 0x10000000
- CLONE_NEWUTS = 0x4000000
- CLONE_PARENT = 0x8000
- CLONE_PARENT_SETTID = 0x100000
- CLONE_PTRACE = 0x2000
- CLONE_SETTLS = 0x80000
- CLONE_SIGHAND = 0x800
- CLONE_SYSVSEM = 0x40000
- CLONE_THREAD = 0x10000
- CLONE_UNTRACED = 0x800000
- CLONE_VFORK = 0x4000
- CLONE_VM = 0x100
- CMSPAR = 0x40000000
- CR0 = 0x0
- CR1 = 0x200
- CR2 = 0x400
- CR3 = 0x600
- CRDLY = 0x600
- CREAD = 0x80
- CRTSCTS = 0x80000000
- CS5 = 0x0
- CS6 = 0x10
- CS7 = 0x20
- CS8 = 0x30
- CSIGNAL = 0xff
- CSIZE = 0x30
- CSTART = 0x11
- CSTATUS = 0x0
- CSTOP = 0x13
- CSTOPB = 0x40
- CSUSP = 0x1a
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ELF_NGREG = 0x12
- ELF_PRARGSZ = 0x50
- ECHO = 0x8
- ECHOCTL = 0x200
- ECHOE = 0x10
- ECHOK = 0x20
- ECHOKE = 0x800
- ECHONL = 0x40
- ECHOPRT = 0x400
- EPOLLERR = 0x8
- EPOLLET = -0x80000000
- EPOLLHUP = 0x10
- EPOLLIN = 0x1
- EPOLLMSG = 0x400
- EPOLLONESHOT = 0x40000000
- EPOLLOUT = 0x4
- EPOLLPRI = 0x2
- EPOLLRDBAND = 0x80
- EPOLLRDHUP = 0x2000
- EPOLLRDNORM = 0x40
- EPOLLWRBAND = 0x200
- EPOLLWRNORM = 0x100
- EPOLL_CLOEXEC = 0x80000
- EPOLL_CTL_ADD = 0x1
- EPOLL_CTL_DEL = 0x2
- EPOLL_CTL_MOD = 0x3
- EPOLL_NONBLOCK = 0x800
- ETH_P_1588 = 0x88f7
- ETH_P_8021Q = 0x8100
- ETH_P_802_2 = 0x4
- ETH_P_802_3 = 0x1
- ETH_P_AARP = 0x80f3
- ETH_P_ALL = 0x3
- ETH_P_AOE = 0x88a2
- ETH_P_ARCNET = 0x1a
- ETH_P_ARP = 0x806
- ETH_P_ATALK = 0x809b
- ETH_P_ATMFATE = 0x8884
- ETH_P_ATMMPOA = 0x884c
- ETH_P_AX25 = 0x2
- ETH_P_BPQ = 0x8ff
- ETH_P_CAIF = 0xf7
- ETH_P_CAN = 0xc
- ETH_P_CONTROL = 0x16
- ETH_P_CUST = 0x6006
- ETH_P_DDCMP = 0x6
- ETH_P_DEC = 0x6000
- ETH_P_DIAG = 0x6005
- ETH_P_DNA_DL = 0x6001
- ETH_P_DNA_RC = 0x6002
- ETH_P_DNA_RT = 0x6003
- ETH_P_DSA = 0x1b
- ETH_P_ECONET = 0x18
- ETH_P_EDSA = 0xdada
- ETH_P_FCOE = 0x8906
- ETH_P_FIP = 0x8914
- ETH_P_HDLC = 0x19
- ETH_P_IEEE802154 = 0xf6
- ETH_P_IEEEPUP = 0xa00
- ETH_P_IEEEPUPAT = 0xa01
- ETH_P_IP = 0x800
- ETH_P_IPV6 = 0x86dd
- ETH_P_IPX = 0x8137
- ETH_P_IRDA = 0x17
- ETH_P_LAT = 0x6004
- ETH_P_LINK_CTL = 0x886c
- ETH_P_LOCALTALK = 0x9
- ETH_P_LOOP = 0x60
- ETH_P_MOBITEX = 0x15
- ETH_P_MPLS_MC = 0x8848
- ETH_P_MPLS_UC = 0x8847
- ETH_P_PAE = 0x888e
- ETH_P_PAUSE = 0x8808
- ETH_P_PHONET = 0xf5
- ETH_P_PPPTALK = 0x10
- ETH_P_PPP_DISC = 0x8863
- ETH_P_PPP_MP = 0x8
- ETH_P_PPP_SES = 0x8864
- ETH_P_PUP = 0x200
- ETH_P_PUPAT = 0x201
- ETH_P_RARP = 0x8035
- ETH_P_SCA = 0x6007
- ETH_P_SLOW = 0x8809
- ETH_P_SNAP = 0x5
- ETH_P_TEB = 0x6558
- ETH_P_TIPC = 0x88ca
- ETH_P_TRAILER = 0x1c
- ETH_P_TR_802_2 = 0x11
- ETH_P_WAN_PPP = 0x7
- ETH_P_WCCP = 0x883e
- ETH_P_X25 = 0x805
- EXTA = 0xe
- EXTB = 0xf
- EXTPROC = 0x10000
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FF0 = 0x0
- FF1 = 0x8000
- FFDLY = 0x8000
- FLUSHO = 0x1000
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x406
- F_EXLCK = 0x4
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLEASE = 0x401
- F_GETLK = 0xc
- F_GETLK64 = 0xc
- F_GETOWN = 0x9
- F_GETOWN_EX = 0x10
- F_GETPIPE_SZ = 0x408
- F_GETSIG = 0xb
- F_LOCK = 0x1
- F_NOTIFY = 0x402
- F_OK = 0x0
- F_RDLCK = 0x0
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLEASE = 0x400
- F_SETLK = 0xd
- F_SETLK64 = 0xd
- F_SETLKW = 0xe
- F_SETLKW64 = 0xe
- F_SETOWN = 0x8
- F_SETOWN_EX = 0xf
- F_SETPIPE_SZ = 0x407
- F_SETSIG = 0xa
- F_SHLCK = 0x8
- F_TEST = 0x3
- F_TLOCK = 0x2
- F_ULOCK = 0x0
- F_UNLCK = 0x2
- F_WRLCK = 0x1
- HUPCL = 0x400
- IBSHIFT = 0x10
- ICANON = 0x2
- ICMPV6_FILTER = 0x1
- ICRNL = 0x100
- IEXTEN = 0x8000
- IFA_F_DADFAILED = 0x8
- IFA_F_DEPRECATED = 0x20
- IFA_F_HOMEADDRESS = 0x10
- IFA_F_NODAD = 0x2
- IFA_F_OPTIMISTIC = 0x4
- IFA_F_PERMANENT = 0x80
- IFA_F_SECONDARY = 0x1
- IFA_F_TEMPORARY = 0x1
- IFA_F_TENTATIVE = 0x40
- IFA_MAX = 0x7
- IFF_ALLMULTI = 0x200
- IFF_AUTOMEDIA = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_DYNAMIC = 0x8000
- IFF_LOOPBACK = 0x8
- IFF_MASTER = 0x400
- IFF_MULTICAST = 0x1000
- IFF_NOARP = 0x80
- IFF_NOTRAILERS = 0x20
- IFF_NO_PI = 0x1000
- IFF_ONE_QUEUE = 0x2000
- IFF_POINTOPOINT = 0x10
- IFF_PORTSEL = 0x2000
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SLAVE = 0x800
- IFF_TAP = 0x2
- IFF_TUN = 0x1
- IFF_TUN_EXCL = 0x8000
- IFF_UP = 0x1
- IFF_VNET_HDR = 0x4000
- IFNAMSIZ = 0x10
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_ACCESS = 0x1
- IN_ALL_EVENTS = 0xfff
- IN_ATTRIB = 0x4
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLOEXEC = 0x80000
- IN_CLOSE = 0x18
- IN_CLOSE_NOWRITE = 0x10
- IN_CLOSE_WRITE = 0x8
- IN_CREATE = 0x100
- IN_DELETE = 0x200
- IN_DELETE_SELF = 0x400
- IN_DONT_FOLLOW = 0x2000000
- IN_EXCL_UNLINK = 0x4000000
- IN_IGNORED = 0x8000
- IN_ISDIR = 0x40000000
- IN_LOOPBACKNET = 0x7f
- IN_MASK_ADD = 0x20000000
- IN_MODIFY = 0x2
- IN_MOVE = 0xc0
- IN_MOVED_FROM = 0x40
- IN_MOVED_TO = 0x80
- IN_MOVE_SELF = 0x800
- IN_NONBLOCK = 0x800
- IN_ONESHOT = 0x80000000
- IN_ONLYDIR = 0x1000000
- IN_OPEN = 0x20
- IN_Q_OVERFLOW = 0x4000
- IN_UNMOUNT = 0x2000
- IPPROTO_AH = 0x33
- IPPROTO_COMP = 0x6c
- IPPROTO_DCCP = 0x21
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_ENCAP = 0x62
- IPPROTO_ESP = 0x32
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GRE = 0x2f
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IGMP = 0x2
- IPPROTO_IP = 0x0
- IPPROTO_IPIP = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_MTP = 0x5c
- IPPROTO_NONE = 0x3b
- IPPROTO_PIM = 0x67
- IPPROTO_PUP = 0xc
- IPPROTO_RAW = 0xff
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_SCTP = 0x84
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_UDP = 0x11
- IPPROTO_UDPLITE = 0x88
- IPV6_2292DSTOPTS = 0x4
- IPV6_2292HOPLIMIT = 0x8
- IPV6_2292HOPOPTS = 0x3
- IPV6_2292PKTINFO = 0x2
- IPV6_2292PKTOPTIONS = 0x6
- IPV6_2292RTHDR = 0x5
- IPV6_ADDRFORM = 0x1
- IPV6_ADD_MEMBERSHIP = 0x14
- IPV6_AUTHHDR = 0xa
- IPV6_CHECKSUM = 0x7
- IPV6_DROP_MEMBERSHIP = 0x15
- IPV6_DSTOPTS = 0x3b
- IPV6_HOPLIMIT = 0x34
- IPV6_HOPOPTS = 0x36
- IPV6_IPSEC_POLICY = 0x22
- IPV6_JOIN_ANYCAST = 0x1b
- IPV6_JOIN_GROUP = 0x14
- IPV6_LEAVE_ANYCAST = 0x1c
- IPV6_LEAVE_GROUP = 0x15
- IPV6_MTU = 0x18
- IPV6_MTU_DISCOVER = 0x17
- IPV6_MULTICAST_HOPS = 0x12
- IPV6_MULTICAST_IF = 0x11
- IPV6_MULTICAST_LOOP = 0x13
- IPV6_NEXTHOP = 0x9
- IPV6_PKTINFO = 0x32
- IPV6_PMTUDISC_DO = 0x2
- IPV6_PMTUDISC_DONT = 0x0
- IPV6_PMTUDISC_PROBE = 0x3
- IPV6_PMTUDISC_WANT = 0x1
- IPV6_RECVDSTOPTS = 0x3a
- IPV6_RECVERR = 0x19
- IPV6_RECVHOPLIMIT = 0x33
- IPV6_RECVHOPOPTS = 0x35
- IPV6_RECVPKTINFO = 0x31
- IPV6_RECVRTHDR = 0x38
- IPV6_RECVTCLASS = 0x42
- IPV6_ROUTER_ALERT = 0x16
- IPV6_RTHDR = 0x39
- IPV6_RTHDRDSTOPTS = 0x37
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_RXDSTOPTS = 0x3b
- IPV6_RXHOPOPTS = 0x36
- IPV6_TCLASS = 0x43
- IPV6_UNICAST_HOPS = 0x10
- IPV6_V6ONLY = 0x1a
- IPV6_XFRM_POLICY = 0x23
- IP_ADD_MEMBERSHIP = 0x23
- IP_ADD_SOURCE_MEMBERSHIP = 0x27
- IP_BLOCK_SOURCE = 0x26
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0x24
- IP_DROP_SOURCE_MEMBERSHIP = 0x28
- IP_FREEBIND = 0xf
- IP_HDRINCL = 0x3
- IP_IPSEC_POLICY = 0x10
- IP_MAXPACKET = 0xffff
- IP_MAX_MEMBERSHIPS = 0x14
- IP_MF = 0x2000
- IP_MINTTL = 0x15
- IP_MSFILTER = 0x29
- IP_MSS = 0x240
- IP_MTU = 0xe
- IP_MTU_DISCOVER = 0xa
- IP_MULTICAST_IF = 0x20
- IP_MULTICAST_LOOP = 0x22
- IP_MULTICAST_TTL = 0x21
- IP_OFFMASK = 0x1fff
- IP_OPTIONS = 0x4
- IP_ORIGDSTADDR = 0x14
- IP_PASSSEC = 0x12
- IP_PKTINFO = 0x8
- IP_PKTOPTIONS = 0x9
- IP_PMTUDISC = 0xa
- IP_PMTUDISC_DO = 0x2
- IP_PMTUDISC_DONT = 0x0
- IP_PMTUDISC_PROBE = 0x3
- IP_PMTUDISC_WANT = 0x1
- IP_RECVERR = 0xb
- IP_RECVOPTS = 0x6
- IP_RECVORIGDSTADDR = 0x14
- IP_RECVRETOPTS = 0x7
- IP_RECVTOS = 0xd
- IP_RECVTTL = 0xc
- IP_RETOPTS = 0x7
- IP_RF = 0x8000
- IP_ROUTER_ALERT = 0x5
- IP_TOS = 0x1
- IP_TRANSPARENT = 0x13
- IP_TTL = 0x2
- IP_UNBLOCK_SOURCE = 0x25
- IP_XFRM_POLICY = 0x11
- ISIG = 0x1
- ISTRIP = 0x20
- IUCLC = 0x200
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x1000
- IXON = 0x400
- LINUX_REBOOT_CMD_CAD_OFF = 0x0
- LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
- LINUX_REBOOT_CMD_HALT = 0xcdef0123
- LINUX_REBOOT_CMD_KEXEC = 0x45584543
- LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
- LINUX_REBOOT_CMD_RESTART = 0x1234567
- LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
- LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
- LINUX_REBOOT_MAGIC1 = 0xfee1dead
- LINUX_REBOOT_MAGIC2 = 0x28121969
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_DOFORK = 0xb
- MADV_DONTFORK = 0xa
- MADV_DONTNEED = 0x4
- MADV_HUGEPAGE = 0xe
- MADV_HWPOISON = 0x64
- MADV_MERGEABLE = 0xc
- MADV_NOHUGEPAGE = 0xf
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_REMOVE = 0x9
- MADV_SEQUENTIAL = 0x2
- MADV_UNMERGEABLE = 0xd
- MADV_WILLNEED = 0x3
- MAP_ANON = 0x20
- MAP_ANONYMOUS = 0x20
- MAP_DENYWRITE = 0x800
- MAP_EXECUTABLE = 0x1000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_GROWSDOWN = 0x100
- MAP_LOCKED = 0x2000
- MAP_NONBLOCK = 0x10000
- MAP_NORESERVE = 0x4000
- MAP_POPULATE = 0x8000
- MAP_PRIVATE = 0x2
- MAP_SHARED = 0x1
- MAP_TYPE = 0xf
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MNT_DETACH = 0x2
- MNT_EXPIRE = 0x4
- MNT_FORCE = 0x1
- MSG_CMSG_CLOEXEC = 0x40000000
- MSG_CONFIRM = 0x800
- MSG_CTRUNC = 0x8
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x40
- MSG_EOR = 0x80
- MSG_ERRQUEUE = 0x2000
- MSG_FASTOPEN = 0x20000000
- MSG_FIN = 0x200
- MSG_MORE = 0x8000
- MSG_NOSIGNAL = 0x4000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_PROXY = 0x10
- MSG_RST = 0x1000
- MSG_SYN = 0x400
- MSG_TRUNC = 0x20
- MSG_TRYHARD = 0x4
- MSG_WAITALL = 0x100
- MSG_WAITFORONE = 0x10000
- MS_ACTIVE = 0x40000000
- MS_ASYNC = 0x1
- MS_BIND = 0x1000
- MS_DIRSYNC = 0x80
- MS_INVALIDATE = 0x2
- MS_I_VERSION = 0x800000
- MS_KERNMOUNT = 0x400000
- MS_MANDLOCK = 0x40
- MS_MGC_MSK = 0xffff0000
- MS_MGC_VAL = 0xc0ed0000
- MS_MOVE = 0x2000
- MS_NOATIME = 0x400
- MS_NODEV = 0x4
- MS_NODIRATIME = 0x800
- MS_NOEXEC = 0x8
- MS_NOSUID = 0x2
- MS_NOUSER = -0x80000000
- MS_POSIXACL = 0x10000
- MS_PRIVATE = 0x40000
- MS_RDONLY = 0x1
- MS_REC = 0x4000
- MS_RELATIME = 0x200000
- MS_REMOUNT = 0x20
- MS_RMT_MASK = 0x800051
- MS_SHARED = 0x100000
- MS_SILENT = 0x8000
- MS_SLAVE = 0x80000
- MS_STRICTATIME = 0x1000000
- MS_SYNC = 0x4
- MS_SYNCHRONOUS = 0x10
- MS_UNBINDABLE = 0x20000
- NAME_MAX = 0xff
- NETLINK_ADD_MEMBERSHIP = 0x1
- NETLINK_AUDIT = 0x9
- NETLINK_BROADCAST_ERROR = 0x4
- NETLINK_CONNECTOR = 0xb
- NETLINK_DNRTMSG = 0xe
- NETLINK_DROP_MEMBERSHIP = 0x2
- NETLINK_ECRYPTFS = 0x13
- NETLINK_FIB_LOOKUP = 0xa
- NETLINK_FIREWALL = 0x3
- NETLINK_GENERIC = 0x10
- NETLINK_INET_DIAG = 0x4
- NETLINK_IP6_FW = 0xd
- NETLINK_ISCSI = 0x8
- NETLINK_KOBJECT_UEVENT = 0xf
- NETLINK_NETFILTER = 0xc
- NETLINK_NFLOG = 0x5
- NETLINK_NO_ENOBUFS = 0x5
- NETLINK_PKTINFO = 0x3
- NETLINK_RDMA = 0x14
- NETLINK_ROUTE = 0x0
- NETLINK_SCSITRANSPORT = 0x12
- NETLINK_SELINUX = 0x7
- NETLINK_UNUSED = 0x1
- NETLINK_USERSOCK = 0x2
- NETLINK_XFRM = 0x6
- NL0 = 0x0
- NL1 = 0x100
- NLA_ALIGNTO = 0x4
- NLA_F_NESTED = 0x8000
- NLA_F_NET_BYTEORDER = 0x4000
- NLA_HDRLEN = 0x4
- NLDLY = 0x100
- NLMSG_ALIGNTO = 0x4
- NLMSG_DONE = 0x3
- NLMSG_ERROR = 0x2
- NLMSG_HDRLEN = 0x10
- NLMSG_MIN_TYPE = 0x10
- NLMSG_NOOP = 0x1
- NLMSG_OVERRUN = 0x4
- NLM_F_ACK = 0x4
- NLM_F_APPEND = 0x800
- NLM_F_ATOMIC = 0x400
- NLM_F_CREATE = 0x400
- NLM_F_DUMP = 0x300
- NLM_F_ECHO = 0x8
- NLM_F_EXCL = 0x200
- NLM_F_MATCH = 0x200
- NLM_F_MULTI = 0x2
- NLM_F_REPLACE = 0x100
- NLM_F_REQUEST = 0x1
- NLM_F_ROOT = 0x100
- NOFLSH = 0x80
- OCRNL = 0x8
- OFDEL = 0x80
- OFILL = 0x40
- OLCUC = 0x2
- ONLCR = 0x4
- ONLRET = 0x20
- ONOCR = 0x10
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x400
- O_ASYNC = 0x2000
- O_CLOEXEC = 0x80000
- O_CREAT = 0x40
- O_DIRECT = 0x10000
- O_DIRECTORY = 0x4000
- O_DSYNC = 0x1000
- O_EXCL = 0x80
- O_FSYNC = 0x1000
- O_LARGEFILE = 0x20000
- O_NDELAY = 0x800
- O_NOATIME = 0x40000
- O_NOCTTY = 0x100
- O_NOFOLLOW = 0x8000
- O_NONBLOCK = 0x800
- O_PATH = 0x200000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_RSYNC = 0x1000
- O_SYNC = 0x1000
- O_TRUNC = 0x200
- O_WRONLY = 0x1
- PACKET_ADD_MEMBERSHIP = 0x1
- PACKET_BROADCAST = 0x1
- PACKET_DROP_MEMBERSHIP = 0x2
- PACKET_FASTROUTE = 0x6
- PACKET_HOST = 0x0
- PACKET_LOOPBACK = 0x5
- PACKET_MR_ALLMULTI = 0x2
- PACKET_MR_MULTICAST = 0x0
- PACKET_MR_PROMISC = 0x1
- PACKET_MULTICAST = 0x2
- PACKET_OTHERHOST = 0x3
- PACKET_OUTGOING = 0x4
- PACKET_RECV_OUTPUT = 0x3
- PACKET_RX_RING = 0x5
- PACKET_STATISTICS = 0x6
- PARENB = 0x100
- PARMRK = 0x8
- PARODD = 0x200
- PENDIN = 0x4000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_GROWSDOWN = 0x1000000
- PROT_GROWSUP = 0x2000000
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- PR_CAPBSET_DROP = 0x18
- PR_CAPBSET_READ = 0x17
- PR_CLEAR_SECCOMP_FILTER = 0x25
- PR_ENDIAN_BIG = 0x0
- PR_ENDIAN_LITTLE = 0x1
- PR_ENDIAN_PPC_LITTLE = 0x2
- PR_FPEMU_NOPRINT = 0x1
- PR_FPEMU_SIGFPE = 0x2
- PR_FP_EXC_ASYNC = 0x2
- PR_FP_EXC_DISABLED = 0x0
- PR_FP_EXC_DIV = 0x10000
- PR_FP_EXC_INV = 0x100000
- PR_FP_EXC_NONRECOV = 0x1
- PR_FP_EXC_OVF = 0x20000
- PR_FP_EXC_PRECISE = 0x3
- PR_FP_EXC_RES = 0x80000
- PR_FP_EXC_SW_ENABLE = 0x80
- PR_FP_EXC_UND = 0x40000
- PR_GET_DUMPABLE = 0x3
- PR_GET_ENDIAN = 0x13
- PR_GET_FPEMU = 0x9
- PR_GET_FPEXC = 0xb
- PR_GET_KEEPCAPS = 0x7
- PR_GET_NAME = 0x10
- PR_GET_PDEATHSIG = 0x2
- PR_GET_SECCOMP = 0x15
- PR_GET_SECCOMP_FILTER = 0x23
- PR_GET_SECUREBITS = 0x1b
- PR_GET_TIMERSLACK = 0x1e
- PR_GET_TIMING = 0xd
- PR_GET_TSC = 0x19
- PR_GET_UNALIGN = 0x5
- PR_MCE_KILL = 0x21
- PR_MCE_KILL_CLEAR = 0x0
- PR_MCE_KILL_DEFAULT = 0x2
- PR_MCE_KILL_EARLY = 0x1
- PR_MCE_KILL_GET = 0x22
- PR_MCE_KILL_LATE = 0x0
- PR_MCE_KILL_SET = 0x1
- PR_SECCOMP_FILTER_EVENT = 0x1
- PR_SECCOMP_FILTER_SYSCALL = 0x0
- PR_SET_DUMPABLE = 0x4
- PR_SET_ENDIAN = 0x14
- PR_SET_FPEMU = 0xa
- PR_SET_FPEXC = 0xc
- PR_SET_KEEPCAPS = 0x8
- PR_SET_NAME = 0xf
- PR_SET_PDEATHSIG = 0x1
- PR_SET_PTRACER = 0x59616d61
- PR_SET_SECCOMP = 0x16
- PR_SET_SECCOMP_FILTER = 0x24
- PR_SET_SECUREBITS = 0x1c
- PR_SET_TIMERSLACK = 0x1d
- PR_SET_TIMING = 0xe
- PR_SET_TSC = 0x1a
- PR_SET_UNALIGN = 0x6
- PR_TASK_PERF_EVENTS_DISABLE = 0x1f
- PR_TASK_PERF_EVENTS_ENABLE = 0x20
- PR_TIMING_STATISTICAL = 0x0
- PR_TIMING_TIMESTAMP = 0x1
- PR_TSC_ENABLE = 0x1
- PR_TSC_SIGSEGV = 0x2
- PR_UNALIGN_NOPRINT = 0x1
- PR_UNALIGN_SIGBUS = 0x2
- PTRACE_ATTACH = 0x10
- PTRACE_CONT = 0x7
- PTRACE_DETACH = 0x11
- PTRACE_EVENT_CLONE = 0x3
- PTRACE_EVENT_EXEC = 0x4
- PTRACE_EVENT_EXIT = 0x6
- PTRACE_EVENT_FORK = 0x1
- PTRACE_EVENT_VFORK = 0x2
- PTRACE_EVENT_VFORK_DONE = 0x5
- PTRACE_GETCRUNCHREGS = 0x19
- PTRACE_GETEVENTMSG = 0x4201
- PTRACE_GETFPREGS = 0xe
- PTRACE_GETHBPREGS = 0x1d
- PTRACE_GETREGS = 0xc
- PTRACE_GETREGSET = 0x4204
- PTRACE_GETSIGINFO = 0x4202
- PTRACE_GETVFPREGS = 0x1b
- PTRACE_GETWMMXREGS = 0x12
- PTRACE_GET_THREAD_AREA = 0x16
- PTRACE_KILL = 0x8
- PTRACE_OLDSETOPTIONS = 0x15
- PTRACE_O_MASK = 0x7f
- PTRACE_O_TRACECLONE = 0x8
- PTRACE_O_TRACEEXEC = 0x10
- PTRACE_O_TRACEEXIT = 0x40
- PTRACE_O_TRACEFORK = 0x2
- PTRACE_O_TRACESYSGOOD = 0x1
- PTRACE_O_TRACEVFORK = 0x4
- PTRACE_O_TRACEVFORKDONE = 0x20
- PTRACE_PEEKDATA = 0x2
- PTRACE_PEEKTEXT = 0x1
- PTRACE_PEEKUSR = 0x3
- PTRACE_POKEDATA = 0x5
- PTRACE_POKETEXT = 0x4
- PTRACE_POKEUSR = 0x6
- PTRACE_SETCRUNCHREGS = 0x1a
- PTRACE_SETFPREGS = 0xf
- PTRACE_SETHBPREGS = 0x1e
- PTRACE_SETOPTIONS = 0x4200
- PTRACE_SETREGS = 0xd
- PTRACE_SETREGSET = 0x4205
- PTRACE_SETSIGINFO = 0x4203
- PTRACE_SETVFPREGS = 0x1c
- PTRACE_SETWMMXREGS = 0x13
- PTRACE_SET_SYSCALL = 0x17
- PTRACE_SINGLESTEP = 0x9
- PTRACE_SYSCALL = 0x18
- PTRACE_TRACEME = 0x0
- PT_DATA_ADDR = 0x10004
- PT_TEXT_ADDR = 0x10000
- PT_TEXT_END_ADDR = 0x10008
- RLIMIT_AS = 0x9
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x7
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = -0x1
- RTAX_ADVMSS = 0x8
- RTAX_CWND = 0x7
- RTAX_FEATURES = 0xc
- RTAX_FEATURE_ALLFRAG = 0x8
- RTAX_FEATURE_ECN = 0x1
- RTAX_FEATURE_SACK = 0x2
- RTAX_FEATURE_TIMESTAMP = 0x4
- RTAX_HOPLIMIT = 0xa
- RTAX_INITCWND = 0xb
- RTAX_INITRWND = 0xe
- RTAX_LOCK = 0x1
- RTAX_MAX = 0xe
- RTAX_MTU = 0x2
- RTAX_REORDERING = 0x9
- RTAX_RTO_MIN = 0xd
- RTAX_RTT = 0x4
- RTAX_RTTVAR = 0x5
- RTAX_SSTHRESH = 0x6
- RTAX_UNSPEC = 0x0
- RTAX_WINDOW = 0x3
- RTA_ALIGNTO = 0x4
- RTA_MAX = 0x10
- RTCF_DIRECTSRC = 0x4000000
- RTCF_DOREDIRECT = 0x1000000
- RTCF_LOG = 0x2000000
- RTCF_MASQ = 0x400000
- RTCF_NAT = 0x800000
- RTCF_VALVE = 0x200000
- RTF_ADDRCLASSMASK = 0xf8000000
- RTF_ADDRCONF = 0x40000
- RTF_ALLONLINK = 0x20000
- RTF_BROADCAST = 0x10000000
- RTF_CACHE = 0x1000000
- RTF_DEFAULT = 0x10000
- RTF_DYNAMIC = 0x10
- RTF_FLOW = 0x2000000
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_INTERFACE = 0x40000000
- RTF_IRTT = 0x100
- RTF_LINKRT = 0x100000
- RTF_LOCAL = 0x80000000
- RTF_MODIFIED = 0x20
- RTF_MSS = 0x40
- RTF_MTU = 0x40
- RTF_MULTICAST = 0x20000000
- RTF_NAT = 0x8000000
- RTF_NOFORWARD = 0x1000
- RTF_NONEXTHOP = 0x200000
- RTF_NOPMTUDISC = 0x4000
- RTF_POLICY = 0x4000000
- RTF_REINSTATE = 0x8
- RTF_REJECT = 0x200
- RTF_STATIC = 0x400
- RTF_THROW = 0x2000
- RTF_UP = 0x1
- RTF_WINDOW = 0x80
- RTF_XRESOLVE = 0x800
- RTM_BASE = 0x10
- RTM_DELACTION = 0x31
- RTM_DELADDR = 0x15
- RTM_DELADDRLABEL = 0x49
- RTM_DELLINK = 0x11
- RTM_DELNEIGH = 0x1d
- RTM_DELQDISC = 0x25
- RTM_DELROUTE = 0x19
- RTM_DELRULE = 0x21
- RTM_DELTCLASS = 0x29
- RTM_DELTFILTER = 0x2d
- RTM_F_CLONED = 0x200
- RTM_F_EQUALIZE = 0x400
- RTM_F_NOTIFY = 0x100
- RTM_F_PREFIX = 0x800
- RTM_GETACTION = 0x32
- RTM_GETADDR = 0x16
- RTM_GETADDRLABEL = 0x4a
- RTM_GETANYCAST = 0x3e
- RTM_GETDCB = 0x4e
- RTM_GETLINK = 0x12
- RTM_GETMULTICAST = 0x3a
- RTM_GETNEIGH = 0x1e
- RTM_GETNEIGHTBL = 0x42
- RTM_GETQDISC = 0x26
- RTM_GETROUTE = 0x1a
- RTM_GETRULE = 0x22
- RTM_GETTCLASS = 0x2a
- RTM_GETTFILTER = 0x2e
- RTM_MAX = 0x4f
- RTM_NEWACTION = 0x30
- RTM_NEWADDR = 0x14
- RTM_NEWADDRLABEL = 0x48
- RTM_NEWLINK = 0x10
- RTM_NEWNDUSEROPT = 0x44
- RTM_NEWNEIGH = 0x1c
- RTM_NEWNEIGHTBL = 0x40
- RTM_NEWPREFIX = 0x34
- RTM_NEWQDISC = 0x24
- RTM_NEWROUTE = 0x18
- RTM_NEWRULE = 0x20
- RTM_NEWTCLASS = 0x28
- RTM_NEWTFILTER = 0x2c
- RTM_NR_FAMILIES = 0x10
- RTM_NR_MSGTYPES = 0x40
- RTM_SETDCB = 0x4f
- RTM_SETLINK = 0x13
- RTM_SETNEIGHTBL = 0x43
- RTNH_ALIGNTO = 0x4
- RTNH_F_DEAD = 0x1
- RTNH_F_ONLINK = 0x4
- RTNH_F_PERVASIVE = 0x2
- RTN_MAX = 0xb
- RTPROT_BIRD = 0xc
- RTPROT_BOOT = 0x3
- RTPROT_DHCP = 0x10
- RTPROT_DNROUTED = 0xd
- RTPROT_GATED = 0x8
- RTPROT_KERNEL = 0x2
- RTPROT_MRT = 0xa
- RTPROT_NTK = 0xf
- RTPROT_RA = 0x9
- RTPROT_REDIRECT = 0x1
- RTPROT_STATIC = 0x4
- RTPROT_UNSPEC = 0x0
- RTPROT_XORP = 0xe
- RTPROT_ZEBRA = 0xb
- RT_CLASS_DEFAULT = 0xfd
- RT_CLASS_LOCAL = 0xff
- RT_CLASS_MAIN = 0xfe
- RT_CLASS_MAX = 0xff
- RT_CLASS_UNSPEC = 0x0
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- RUSAGE_THREAD = 0x1
- SCM_CREDENTIALS = 0x2
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x1d
- SCM_TIMESTAMPING = 0x25
- SCM_TIMESTAMPNS = 0x23
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDDLCI = 0x8980
- SIOCADDMULTI = 0x8931
- SIOCADDRT = 0x890b
- SIOCATMARK = 0x8905
- SIOCDARP = 0x8953
- SIOCDELDLCI = 0x8981
- SIOCDELMULTI = 0x8932
- SIOCDELRT = 0x890c
- SIOCDEVPRIVATE = 0x89f0
- SIOCDIFADDR = 0x8936
- SIOCDRARP = 0x8960
- SIOCGARP = 0x8954
- SIOCGIFADDR = 0x8915
- SIOCGIFBR = 0x8940
- SIOCGIFBRDADDR = 0x8919
- SIOCGIFCONF = 0x8912
- SIOCGIFCOUNT = 0x8938
- SIOCGIFDSTADDR = 0x8917
- SIOCGIFENCAP = 0x8925
- SIOCGIFFLAGS = 0x8913
- SIOCGIFHWADDR = 0x8927
- SIOCGIFINDEX = 0x8933
- SIOCGIFMAP = 0x8970
- SIOCGIFMEM = 0x891f
- SIOCGIFMETRIC = 0x891d
- SIOCGIFMTU = 0x8921
- SIOCGIFNAME = 0x8910
- SIOCGIFNETMASK = 0x891b
- SIOCGIFPFLAGS = 0x8935
- SIOCGIFSLAVE = 0x8929
- SIOCGIFTXQLEN = 0x8942
- SIOCGPGRP = 0x8904
- SIOCGRARP = 0x8961
- SIOCGSTAMP = 0x8906
- SIOCGSTAMPNS = 0x8907
- SIOCPROTOPRIVATE = 0x89e0
- SIOCRTMSG = 0x890d
- SIOCSARP = 0x8955
- SIOCSIFADDR = 0x8916
- SIOCSIFBR = 0x8941
- SIOCSIFBRDADDR = 0x891a
- SIOCSIFDSTADDR = 0x8918
- SIOCSIFENCAP = 0x8926
- SIOCSIFFLAGS = 0x8914
- SIOCSIFHWADDR = 0x8924
- SIOCSIFHWBROADCAST = 0x8937
- SIOCSIFLINK = 0x8911
- SIOCSIFMAP = 0x8971
- SIOCSIFMEM = 0x8920
- SIOCSIFMETRIC = 0x891e
- SIOCSIFMTU = 0x8922
- SIOCSIFNAME = 0x8923
- SIOCSIFNETMASK = 0x891c
- SIOCSIFPFLAGS = 0x8934
- SIOCSIFSLAVE = 0x8930
- SIOCSIFTXQLEN = 0x8943
- SIOCSPGRP = 0x8902
- SIOCSRARP = 0x8962
- SOCK_CLOEXEC = 0x80000
- SOCK_DCCP = 0x6
- SOCK_DGRAM = 0x2
- SOCK_NONBLOCK = 0x800
- SOCK_PACKET = 0xa
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_AAL = 0x109
- SOL_ATM = 0x108
- SOL_DECNET = 0x105
- SOL_ICMPV6 = 0x3a
- SOL_IP = 0x0
- SOL_IPV6 = 0x29
- SOL_IRDA = 0x10a
- SOL_PACKET = 0x107
- SOL_RAW = 0xff
- SOL_SOCKET = 0x1
- SOL_TCP = 0x6
- SOL_X25 = 0x106
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x1e
- SO_ATTACH_FILTER = 0x1a
- SO_BINDTODEVICE = 0x19
- SO_BROADCAST = 0x6
- SO_BSDCOMPAT = 0xe
- SO_DEBUG = 0x1
- SO_DETACH_FILTER = 0x1b
- SO_DOMAIN = 0x27
- SO_DONTROUTE = 0x5
- SO_ERROR = 0x4
- SO_KEEPALIVE = 0x9
- SO_LINGER = 0xd
- SO_MARK = 0x24
- SO_NO_CHECK = 0xb
- SO_OOBINLINE = 0xa
- SO_PASSCRED = 0x10
- SO_PASSSEC = 0x22
- SO_PEERCRED = 0x11
- SO_PEERNAME = 0x1c
- SO_PEERSEC = 0x1f
- SO_PRIORITY = 0xc
- SO_PROTOCOL = 0x26
- SO_RCVBUF = 0x8
- SO_RCVBUFFORCE = 0x21
- SO_RCVLOWAT = 0x12
- SO_RCVTIMEO = 0x14
- SO_REUSEADDR = 0x2
- SO_RXQ_OVFL = 0x28
- SO_SECURITY_AUTHENTICATION = 0x16
- SO_SECURITY_ENCRYPTION_NETWORK = 0x18
- SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17
- SO_SNDBUF = 0x7
- SO_SNDBUFFORCE = 0x20
- SO_SNDLOWAT = 0x13
- SO_SNDTIMEO = 0x15
- SO_TIMESTAMP = 0x1d
- SO_TIMESTAMPING = 0x25
- SO_TIMESTAMPNS = 0x23
- SO_TYPE = 0x3
- S_BLKSIZE = 0x200
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TAB0 = 0x0
- TAB1 = 0x800
- TAB2 = 0x1000
- TAB3 = 0x1800
- TABDLY = 0x1800
- TCFLSH = 0x540b
- TCGETA = 0x5405
- TCGETS = 0x5401
- TCGETS2 = 0x802c542a
- TCGETX = 0x5432
- TCIFLUSH = 0x0
- TCIOFF = 0x2
- TCIOFLUSH = 0x2
- TCION = 0x3
- TCOFLUSH = 0x1
- TCOOFF = 0x0
- TCOON = 0x1
- TCP_CONGESTION = 0xd
- TCP_CORK = 0x3
- TCP_DEFER_ACCEPT = 0x9
- TCP_INFO = 0xb
- TCP_KEEPCNT = 0x6
- TCP_KEEPIDLE = 0x4
- TCP_KEEPINTVL = 0x5
- TCP_LINGER2 = 0x8
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0xe
- TCP_MD5SIG_MAXKEYLEN = 0x50
- TCP_MSS = 0x200
- TCP_NODELAY = 0x1
- TCP_QUICKACK = 0xc
- TCP_SYNCNT = 0x7
- TCP_WINDOW_CLAMP = 0xa
- TCSAFLUSH = 0x2
- TCSBRK = 0x5409
- TCSBRKP = 0x5425
- TCSETA = 0x5406
- TCSETAF = 0x5408
- TCSETAW = 0x5407
- TCSETS = 0x5402
- TCSETS2 = 0x402c542b
- TCSETSF = 0x5404
- TCSETSF2 = 0x402c542d
- TCSETSW = 0x5403
- TCSETSW2 = 0x402c542c
- TCSETX = 0x5433
- TCSETXF = 0x5434
- TCSETXW = 0x5435
- TCXONC = 0x540a
- TIOCCBRK = 0x5428
- TIOCCONS = 0x541d
- TIOCEXCL = 0x540c
- TIOCGDEV = 0x80045432
- TIOCGETD = 0x5424
- TIOCGEXCL = 0x80045440
- TIOCGICOUNT = 0x545d
- TIOCGLCKTRMIOS = 0x5456
- TIOCGPGRP = 0x540f
- TIOCGPKT = 0x80045438
- TIOCGPTLCK = 0x80045439
- TIOCGPTN = 0x80045430
- TIOCGRS485 = 0x542e
- TIOCGSERIAL = 0x541e
- TIOCGSID = 0x5429
- TIOCGSOFTCAR = 0x5419
- TIOCGWINSZ = 0x5413
- TIOCINQ = 0x541b
- TIOCLINUX = 0x541c
- TIOCMBIC = 0x5417
- TIOCMBIS = 0x5416
- TIOCMGET = 0x5415
- TIOCMIWAIT = 0x545c
- TIOCMSET = 0x5418
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x5422
- TIOCNXCL = 0x540d
- TIOCOUTQ = 0x5411
- TIOCPKT = 0x5420
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCSBRK = 0x5427
- TIOCSCTTY = 0x540e
- TIOCSERCONFIG = 0x5453
- TIOCSERGETLSR = 0x5459
- TIOCSERGETMULTI = 0x545a
- TIOCSERGSTRUCT = 0x5458
- TIOCSERGWILD = 0x5454
- TIOCSERSETMULTI = 0x545b
- TIOCSERSWILD = 0x5455
- TIOCSER_TEMT = 0x1
- TIOCSETD = 0x5423
- TIOCSIG = 0x40045436
- TIOCSLCKTRMIOS = 0x5457
- TIOCSPGRP = 0x5410
- TIOCSPTLCK = 0x40045431
- TIOCSRS485 = 0x542f
- TIOCSSERIAL = 0x541f
- TIOCSSOFTCAR = 0x541a
- TIOCSTI = 0x5412
- TIOCSWINSZ = 0x5414
- TIOCVHANGUP = 0x5437
- TOSTOP = 0x100
- TUNATTACHFILTER = 0x400854d5
- TUNDETACHFILTER = 0x400854d6
- TUNGETFEATURES = 0x800454cf
- TUNGETIFF = 0x800454d2
- TUNGETSNDBUF = 0x800454d3
- TUNGETVNETHDRSZ = 0x800454d7
- TUNSETDEBUG = 0x400454c9
- TUNSETGROUP = 0x400454ce
- TUNSETIFF = 0x400454ca
- TUNSETLINK = 0x400454cd
- TUNSETNOCSUM = 0x400454c8
- TUNSETOFFLOAD = 0x400454d0
- TUNSETOWNER = 0x400454cc
- TUNSETPERSIST = 0x400454cb
- TUNSETSNDBUF = 0x400454d4
- TUNSETTXFILTER = 0x400454d1
- TUNSETVNETHDRSZ = 0x400454d8
- VDISCARD = 0xd
- VEOF = 0x4
- VEOL = 0xb
- VEOL2 = 0x10
- VERASE = 0x2
- VINTR = 0x0
- VKILL = 0x3
- VLNEXT = 0xf
- VMIN = 0x6
- VQUIT = 0x1
- VREPRINT = 0xc
- VSTART = 0x8
- VSTOP = 0x9
- VSUSP = 0xa
- VSWTC = 0x7
- VT0 = 0x0
- VT1 = 0x4000
- VTDLY = 0x4000
- VTIME = 0x5
- VWERASE = 0xe
- WALL = 0x40000000
- WCLONE = 0x80000000
- WCONTINUED = 0x8
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOTHREAD = 0x20000000
- WNOWAIT = 0x1000000
- WORDSIZE = 0x20
- WSTOPPED = 0x2
- WUNTRACED = 0x2
- XCASE = 0x4
- XTABS = 0x1800
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x62)
- EADDRNOTAVAIL = syscall.Errno(0x63)
- EADV = syscall.Errno(0x44)
- EAFNOSUPPORT = syscall.Errno(0x61)
- EAGAIN = syscall.Errno(0xb)
- EALREADY = syscall.Errno(0x72)
- EBADE = syscall.Errno(0x34)
- EBADF = syscall.Errno(0x9)
- EBADFD = syscall.Errno(0x4d)
- EBADMSG = syscall.Errno(0x4a)
- EBADR = syscall.Errno(0x35)
- EBADRQC = syscall.Errno(0x38)
- EBADSLT = syscall.Errno(0x39)
- EBFONT = syscall.Errno(0x3b)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x7d)
- ECHILD = syscall.Errno(0xa)
- ECHRNG = syscall.Errno(0x2c)
- ECOMM = syscall.Errno(0x46)
- ECONNABORTED = syscall.Errno(0x67)
- ECONNREFUSED = syscall.Errno(0x6f)
- ECONNRESET = syscall.Errno(0x68)
- EDEADLK = syscall.Errno(0x23)
- EDEADLOCK = syscall.Errno(0x23)
- EDESTADDRREQ = syscall.Errno(0x59)
- EDOM = syscall.Errno(0x21)
- EDOTDOT = syscall.Errno(0x49)
- EDQUOT = syscall.Errno(0x7a)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EHOSTDOWN = syscall.Errno(0x70)
- EHOSTUNREACH = syscall.Errno(0x71)
- EHWPOISON = syscall.Errno(0x85)
- EIDRM = syscall.Errno(0x2b)
- EILSEQ = syscall.Errno(0x54)
- EINPROGRESS = syscall.Errno(0x73)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x6a)
- EISDIR = syscall.Errno(0x15)
- EISNAM = syscall.Errno(0x78)
- EKEYEXPIRED = syscall.Errno(0x7f)
- EKEYREJECTED = syscall.Errno(0x81)
- EKEYREVOKED = syscall.Errno(0x80)
- EL2HLT = syscall.Errno(0x33)
- EL2NSYNC = syscall.Errno(0x2d)
- EL3HLT = syscall.Errno(0x2e)
- EL3RST = syscall.Errno(0x2f)
- ELIBACC = syscall.Errno(0x4f)
- ELIBBAD = syscall.Errno(0x50)
- ELIBEXEC = syscall.Errno(0x53)
- ELIBMAX = syscall.Errno(0x52)
- ELIBSCN = syscall.Errno(0x51)
- ELNRNG = syscall.Errno(0x30)
- ELOOP = syscall.Errno(0x28)
- EMEDIUMTYPE = syscall.Errno(0x7c)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x5a)
- EMULTIHOP = syscall.Errno(0x48)
- ENAMETOOLONG = syscall.Errno(0x24)
- ENAVAIL = syscall.Errno(0x77)
- ENETDOWN = syscall.Errno(0x64)
- ENETRESET = syscall.Errno(0x66)
- ENETUNREACH = syscall.Errno(0x65)
- ENFILE = syscall.Errno(0x17)
- ENOANO = syscall.Errno(0x37)
- ENOBUFS = syscall.Errno(0x69)
- ENOCSI = syscall.Errno(0x32)
- ENODATA = syscall.Errno(0x3d)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOKEY = syscall.Errno(0x7e)
- ENOLCK = syscall.Errno(0x25)
- ENOLINK = syscall.Errno(0x43)
- ENOMEDIUM = syscall.Errno(0x7b)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x2a)
- ENONET = syscall.Errno(0x40)
- ENOPKG = syscall.Errno(0x41)
- ENOPROTOOPT = syscall.Errno(0x5c)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x3f)
- ENOSTR = syscall.Errno(0x3c)
- ENOSYS = syscall.Errno(0x26)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x6b)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x27)
- ENOTNAM = syscall.Errno(0x76)
- ENOTRECOVERABLE = syscall.Errno(0x83)
- ENOTSOCK = syscall.Errno(0x58)
- ENOTSUP = syscall.Errno(0x5f)
- ENOTTY = syscall.Errno(0x19)
- ENOTUNIQ = syscall.Errno(0x4c)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x5f)
- EOVERFLOW = syscall.Errno(0x4b)
- EOWNERDEAD = syscall.Errno(0x82)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x60)
- EPIPE = syscall.Errno(0x20)
- EPROTO = syscall.Errno(0x47)
- EPROTONOSUPPORT = syscall.Errno(0x5d)
- EPROTOTYPE = syscall.Errno(0x5b)
- ERANGE = syscall.Errno(0x22)
- EREMCHG = syscall.Errno(0x4e)
- EREMOTE = syscall.Errno(0x42)
- EREMOTEIO = syscall.Errno(0x79)
- ERESTART = syscall.Errno(0x55)
- ERFKILL = syscall.Errno(0x84)
- EROFS = syscall.Errno(0x1e)
- ESHUTDOWN = syscall.Errno(0x6c)
- ESOCKTNOSUPPORT = syscall.Errno(0x5e)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESRMNT = syscall.Errno(0x45)
- ESTALE = syscall.Errno(0x74)
- ESTRPIPE = syscall.Errno(0x56)
- ETIME = syscall.Errno(0x3e)
- ETIMEDOUT = syscall.Errno(0x6e)
- ETOOMANYREFS = syscall.Errno(0x6d)
- ETXTBSY = syscall.Errno(0x1a)
- EUCLEAN = syscall.Errno(0x75)
- EUNATCH = syscall.Errno(0x31)
- EUSERS = syscall.Errno(0x57)
- EWOULDBLOCK = syscall.Errno(0xb)
- EXDEV = syscall.Errno(0x12)
- EXFULL = syscall.Errno(0x36)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0x7)
- SIGCHLD = syscall.Signal(0x11)
- SIGCLD = syscall.Signal(0x11)
- SIGCONT = syscall.Signal(0x12)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x1d)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPOLL = syscall.Signal(0x1d)
- SIGPROF = syscall.Signal(0x1b)
- SIGPWR = syscall.Signal(0x1e)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTKFLT = syscall.Signal(0x10)
- SIGSTOP = syscall.Signal(0x13)
- SIGSYS = syscall.Signal(0x1f)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x14)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGUNUSED = syscall.Signal(0x1f)
- SIGURG = syscall.Signal(0x17)
- SIGUSR1 = syscall.Signal(0xa)
- SIGUSR2 = syscall.Signal(0xc)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "no such device or address",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource temporarily unavailable",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device or resource busy",
- 17: "file exists",
- 18: "invalid cross-device link",
- 19: "no such device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "numerical result out of range",
- 35: "resource deadlock avoided",
- 36: "file name too long",
- 37: "no locks available",
- 38: "function not implemented",
- 39: "directory not empty",
- 40: "too many levels of symbolic links",
- 42: "no message of desired type",
- 43: "identifier removed",
- 44: "channel number out of range",
- 45: "level 2 not synchronized",
- 46: "level 3 halted",
- 47: "level 3 reset",
- 48: "link number out of range",
- 49: "protocol driver not attached",
- 50: "no CSI structure available",
- 51: "level 2 halted",
- 52: "invalid exchange",
- 53: "invalid request descriptor",
- 54: "exchange full",
- 55: "no anode",
- 56: "invalid request code",
- 57: "invalid slot",
- 59: "bad font file format",
- 60: "device not a stream",
- 61: "no data available",
- 62: "timer expired",
- 63: "out of streams resources",
- 64: "machine is not on the network",
- 65: "package not installed",
- 66: "object is remote",
- 67: "link has been severed",
- 68: "advertise error",
- 69: "srmount error",
- 70: "communication error on send",
- 71: "protocol error",
- 72: "multihop attempted",
- 73: "RFS specific error",
- 74: "bad message",
- 75: "value too large for defined data type",
- 76: "name not unique on network",
- 77: "file descriptor in bad state",
- 78: "remote address changed",
- 79: "can not access a needed shared library",
- 80: "accessing a corrupted shared library",
- 81: ".lib section in a.out corrupted",
- 82: "attempting to link in too many shared libraries",
- 83: "cannot exec a shared library directly",
- 84: "invalid or incomplete multibyte or wide character",
- 85: "interrupted system call should be restarted",
- 86: "streams pipe error",
- 87: "too many users",
- 88: "socket operation on non-socket",
- 89: "destination address required",
- 90: "message too long",
- 91: "protocol wrong type for socket",
- 92: "protocol not available",
- 93: "protocol not supported",
- 94: "socket type not supported",
- 95: "operation not supported",
- 96: "protocol family not supported",
- 97: "address family not supported by protocol",
- 98: "address already in use",
- 99: "cannot assign requested address",
- 100: "network is down",
- 101: "network is unreachable",
- 102: "network dropped connection on reset",
- 103: "software caused connection abort",
- 104: "connection reset by peer",
- 105: "no buffer space available",
- 106: "transport endpoint is already connected",
- 107: "transport endpoint is not connected",
- 108: "cannot send after transport endpoint shutdown",
- 109: "too many references: cannot splice",
- 110: "connection timed out",
- 111: "connection refused",
- 112: "host is down",
- 113: "no route to host",
- 114: "operation already in progress",
- 115: "operation now in progress",
- 116: "stale NFS file handle",
- 117: "structure needs cleaning",
- 118: "not a XENIX named type file",
- 119: "no XENIX semaphores available",
- 120: "is a named type file",
- 121: "remote I/O error",
- 122: "disk quota exceeded",
- 123: "no medium found",
- 124: "wrong medium type",
- 125: "operation canceled",
- 126: "required key not available",
- 127: "key has expired",
- 128: "key has been revoked",
- 129: "key was rejected by service",
- 130: "owner died",
- 131: "state not recoverable",
- 132: "operation not possible due to RF-kill",
- 133: "unknown error 133",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/breakpoint trap",
- 6: "aborted",
- 7: "bus error",
- 8: "floating point exception",
- 9: "killed",
- 10: "user defined signal 1",
- 11: "segmentation fault",
- 12: "user defined signal 2",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "stack fault",
- 17: "child exited",
- 18: "continued",
- 19: "stopped (signal)",
- 20: "stopped",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "urgent I/O condition",
- 24: "CPU time limit exceeded",
- 25: "file size limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window changed",
- 29: "I/O possible",
- 30: "power failure",
- 31: "bad system call",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/newt/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
deleted file mode 100644
index 16dcbc9c..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
+++ /dev/null
@@ -1,1897 +0,0 @@
-// mkerrors.sh
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build arm64,linux
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_ALG = 0x26
- AF_APPLETALK = 0x5
- AF_ASH = 0x12
- AF_ATMPVC = 0x8
- AF_ATMSVC = 0x14
- AF_AX25 = 0x3
- AF_BLUETOOTH = 0x1f
- AF_BRIDGE = 0x7
- AF_CAIF = 0x25
- AF_CAN = 0x1d
- AF_DECnet = 0xc
- AF_ECONET = 0x13
- AF_FILE = 0x1
- AF_IEEE802154 = 0x24
- AF_INET = 0x2
- AF_INET6 = 0xa
- AF_IPX = 0x4
- AF_IRDA = 0x17
- AF_ISDN = 0x22
- AF_IUCV = 0x20
- AF_KEY = 0xf
- AF_LLC = 0x1a
- AF_LOCAL = 0x1
- AF_MAX = 0x29
- AF_NETBEUI = 0xd
- AF_NETLINK = 0x10
- AF_NETROM = 0x6
- AF_NFC = 0x27
- AF_PACKET = 0x11
- AF_PHONET = 0x23
- AF_PPPOX = 0x18
- AF_RDS = 0x15
- AF_ROSE = 0xb
- AF_ROUTE = 0x10
- AF_RXRPC = 0x21
- AF_SECURITY = 0xe
- AF_SNA = 0x16
- AF_TIPC = 0x1e
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_VSOCK = 0x28
- AF_WANPIPE = 0x19
- AF_X25 = 0x9
- ARPHRD_ADAPT = 0x108
- ARPHRD_APPLETLK = 0x8
- ARPHRD_ARCNET = 0x7
- ARPHRD_ASH = 0x30d
- ARPHRD_ATM = 0x13
- ARPHRD_AX25 = 0x3
- ARPHRD_BIF = 0x307
- ARPHRD_CAIF = 0x336
- ARPHRD_CAN = 0x118
- ARPHRD_CHAOS = 0x5
- ARPHRD_CISCO = 0x201
- ARPHRD_CSLIP = 0x101
- ARPHRD_CSLIP6 = 0x103
- ARPHRD_DDCMP = 0x205
- ARPHRD_DLCI = 0xf
- ARPHRD_ECONET = 0x30e
- ARPHRD_EETHER = 0x2
- ARPHRD_ETHER = 0x1
- ARPHRD_EUI64 = 0x1b
- ARPHRD_FCAL = 0x311
- ARPHRD_FCFABRIC = 0x313
- ARPHRD_FCPL = 0x312
- ARPHRD_FCPP = 0x310
- ARPHRD_FDDI = 0x306
- ARPHRD_FRAD = 0x302
- ARPHRD_HDLC = 0x201
- ARPHRD_HIPPI = 0x30c
- ARPHRD_HWX25 = 0x110
- ARPHRD_IEEE1394 = 0x18
- ARPHRD_IEEE802 = 0x6
- ARPHRD_IEEE80211 = 0x321
- ARPHRD_IEEE80211_PRISM = 0x322
- ARPHRD_IEEE80211_RADIOTAP = 0x323
- ARPHRD_IEEE802154 = 0x324
- ARPHRD_IEEE802154_MONITOR = 0x325
- ARPHRD_IEEE802_TR = 0x320
- ARPHRD_INFINIBAND = 0x20
- ARPHRD_IP6GRE = 0x337
- ARPHRD_IPDDP = 0x309
- ARPHRD_IPGRE = 0x30a
- ARPHRD_IRDA = 0x30f
- ARPHRD_LAPB = 0x204
- ARPHRD_LOCALTLK = 0x305
- ARPHRD_LOOPBACK = 0x304
- ARPHRD_METRICOM = 0x17
- ARPHRD_NETLINK = 0x338
- ARPHRD_NETROM = 0x0
- ARPHRD_NONE = 0xfffe
- ARPHRD_PHONET = 0x334
- ARPHRD_PHONET_PIPE = 0x335
- ARPHRD_PIMREG = 0x30b
- ARPHRD_PPP = 0x200
- ARPHRD_PRONET = 0x4
- ARPHRD_RAWHDLC = 0x206
- ARPHRD_ROSE = 0x10e
- ARPHRD_RSRVD = 0x104
- ARPHRD_SIT = 0x308
- ARPHRD_SKIP = 0x303
- ARPHRD_SLIP = 0x100
- ARPHRD_SLIP6 = 0x102
- ARPHRD_TUNNEL = 0x300
- ARPHRD_TUNNEL6 = 0x301
- ARPHRD_VOID = 0xffff
- ARPHRD_X25 = 0x10f
- B0 = 0x0
- B1000000 = 0x1008
- B110 = 0x3
- B115200 = 0x1002
- B1152000 = 0x1009
- B1200 = 0x9
- B134 = 0x4
- B150 = 0x5
- B1500000 = 0x100a
- B1800 = 0xa
- B19200 = 0xe
- B200 = 0x6
- B2000000 = 0x100b
- B230400 = 0x1003
- B2400 = 0xb
- B2500000 = 0x100c
- B300 = 0x7
- B3000000 = 0x100d
- B3500000 = 0x100e
- B38400 = 0xf
- B4000000 = 0x100f
- B460800 = 0x1004
- B4800 = 0xc
- B50 = 0x1
- B500000 = 0x1005
- B57600 = 0x1001
- B576000 = 0x1006
- B600 = 0x8
- B75 = 0x2
- B921600 = 0x1007
- B9600 = 0xd
- BOTHER = 0x1000
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXINSNS = 0x1000
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MOD = 0x90
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BPF_XOR = 0xa0
- BRKINT = 0x2
- BS0 = 0x0
- BS1 = 0x2000
- BSDLY = 0x2000
- CBAUD = 0x100f
- CBAUDEX = 0x1000
- CFLUSH = 0xf
- CIBAUD = 0x100f0000
- CLOCAL = 0x800
- CLOCK_BOOTTIME = 0x7
- CLOCK_BOOTTIME_ALARM = 0x9
- CLOCK_DEFAULT = 0x0
- CLOCK_EXT = 0x1
- CLOCK_INT = 0x2
- CLOCK_MONOTONIC = 0x1
- CLOCK_MONOTONIC_COARSE = 0x6
- CLOCK_MONOTONIC_RAW = 0x4
- CLOCK_PROCESS_CPUTIME_ID = 0x2
- CLOCK_REALTIME = 0x0
- CLOCK_REALTIME_ALARM = 0x8
- CLOCK_REALTIME_COARSE = 0x5
- CLOCK_THREAD_CPUTIME_ID = 0x3
- CLOCK_TXFROMRX = 0x4
- CLOCK_TXINT = 0x3
- CLONE_CHILD_CLEARTID = 0x200000
- CLONE_CHILD_SETTID = 0x1000000
- CLONE_DETACHED = 0x400000
- CLONE_FILES = 0x400
- CLONE_FS = 0x200
- CLONE_IO = 0x80000000
- CLONE_NEWCGROUP = 0x2000000
- CLONE_NEWIPC = 0x8000000
- CLONE_NEWNET = 0x40000000
- CLONE_NEWNS = 0x20000
- CLONE_NEWPID = 0x20000000
- CLONE_NEWUSER = 0x10000000
- CLONE_NEWUTS = 0x4000000
- CLONE_PARENT = 0x8000
- CLONE_PARENT_SETTID = 0x100000
- CLONE_PTRACE = 0x2000
- CLONE_SETTLS = 0x80000
- CLONE_SIGHAND = 0x800
- CLONE_SYSVSEM = 0x40000
- CLONE_THREAD = 0x10000
- CLONE_UNTRACED = 0x800000
- CLONE_VFORK = 0x4000
- CLONE_VM = 0x100
- CMSPAR = 0x40000000
- CR0 = 0x0
- CR1 = 0x200
- CR2 = 0x400
- CR3 = 0x600
- CRDLY = 0x600
- CREAD = 0x80
- CRTSCTS = 0x80000000
- CS5 = 0x0
- CS6 = 0x10
- CS7 = 0x20
- CS8 = 0x30
- CSIGNAL = 0xff
- CSIZE = 0x30
- CSTART = 0x11
- CSTATUS = 0x0
- CSTOP = 0x13
- CSTOPB = 0x40
- CSUSP = 0x1a
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x200
- ECHOE = 0x10
- ECHOK = 0x20
- ECHOKE = 0x800
- ECHONL = 0x40
- ECHOPRT = 0x400
- ELF_NGREG = 0x22
- ELF_PRARGSZ = 0x50
- ENCODING_DEFAULT = 0x0
- ENCODING_FM_MARK = 0x3
- ENCODING_FM_SPACE = 0x4
- ENCODING_MANCHESTER = 0x5
- ENCODING_NRZ = 0x1
- ENCODING_NRZI = 0x2
- EPOLLERR = 0x8
- EPOLLET = 0x80000000
- EPOLLHUP = 0x10
- EPOLLIN = 0x1
- EPOLLMSG = 0x400
- EPOLLONESHOT = 0x40000000
- EPOLLOUT = 0x4
- EPOLLPRI = 0x2
- EPOLLRDBAND = 0x80
- EPOLLRDHUP = 0x2000
- EPOLLRDNORM = 0x40
- EPOLLWAKEUP = 0x20000000
- EPOLLWRBAND = 0x200
- EPOLLWRNORM = 0x100
- EPOLL_CLOEXEC = 0x80000
- EPOLL_CTL_ADD = 0x1
- EPOLL_CTL_DEL = 0x2
- EPOLL_CTL_MOD = 0x3
- ETH_P_1588 = 0x88f7
- ETH_P_8021AD = 0x88a8
- ETH_P_8021AH = 0x88e7
- ETH_P_8021Q = 0x8100
- ETH_P_802_2 = 0x4
- ETH_P_802_3 = 0x1
- ETH_P_802_3_MIN = 0x600
- ETH_P_802_EX1 = 0x88b5
- ETH_P_AARP = 0x80f3
- ETH_P_AF_IUCV = 0xfbfb
- ETH_P_ALL = 0x3
- ETH_P_AOE = 0x88a2
- ETH_P_ARCNET = 0x1a
- ETH_P_ARP = 0x806
- ETH_P_ATALK = 0x809b
- ETH_P_ATMFATE = 0x8884
- ETH_P_ATMMPOA = 0x884c
- ETH_P_AX25 = 0x2
- ETH_P_BATMAN = 0x4305
- ETH_P_BPQ = 0x8ff
- ETH_P_CAIF = 0xf7
- ETH_P_CAN = 0xc
- ETH_P_CANFD = 0xd
- ETH_P_CONTROL = 0x16
- ETH_P_CUST = 0x6006
- ETH_P_DDCMP = 0x6
- ETH_P_DEC = 0x6000
- ETH_P_DIAG = 0x6005
- ETH_P_DNA_DL = 0x6001
- ETH_P_DNA_RC = 0x6002
- ETH_P_DNA_RT = 0x6003
- ETH_P_DSA = 0x1b
- ETH_P_ECONET = 0x18
- ETH_P_EDSA = 0xdada
- ETH_P_FCOE = 0x8906
- ETH_P_FIP = 0x8914
- ETH_P_HDLC = 0x19
- ETH_P_IEEE802154 = 0xf6
- ETH_P_IEEEPUP = 0xa00
- ETH_P_IEEEPUPAT = 0xa01
- ETH_P_IP = 0x800
- ETH_P_IPV6 = 0x86dd
- ETH_P_IPX = 0x8137
- ETH_P_IRDA = 0x17
- ETH_P_LAT = 0x6004
- ETH_P_LINK_CTL = 0x886c
- ETH_P_LOCALTALK = 0x9
- ETH_P_LOOP = 0x60
- ETH_P_MOBITEX = 0x15
- ETH_P_MPLS_MC = 0x8848
- ETH_P_MPLS_UC = 0x8847
- ETH_P_MVRP = 0x88f5
- ETH_P_PAE = 0x888e
- ETH_P_PAUSE = 0x8808
- ETH_P_PHONET = 0xf5
- ETH_P_PPPTALK = 0x10
- ETH_P_PPP_DISC = 0x8863
- ETH_P_PPP_MP = 0x8
- ETH_P_PPP_SES = 0x8864
- ETH_P_PRP = 0x88fb
- ETH_P_PUP = 0x200
- ETH_P_PUPAT = 0x201
- ETH_P_QINQ1 = 0x9100
- ETH_P_QINQ2 = 0x9200
- ETH_P_QINQ3 = 0x9300
- ETH_P_RARP = 0x8035
- ETH_P_SCA = 0x6007
- ETH_P_SLOW = 0x8809
- ETH_P_SNAP = 0x5
- ETH_P_TDLS = 0x890d
- ETH_P_TEB = 0x6558
- ETH_P_TIPC = 0x88ca
- ETH_P_TRAILER = 0x1c
- ETH_P_TR_802_2 = 0x11
- ETH_P_WAN_PPP = 0x7
- ETH_P_WCCP = 0x883e
- ETH_P_X25 = 0x805
- EXTA = 0xe
- EXTB = 0xf
- EXTPROC = 0x10000
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FF0 = 0x0
- FF1 = 0x8000
- FFDLY = 0x8000
- FLUSHO = 0x1000
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x406
- F_EXLCK = 0x4
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLEASE = 0x401
- F_GETLK = 0x5
- F_GETLK64 = 0x5
- F_GETOWN = 0x9
- F_GETOWN_EX = 0x10
- F_GETPIPE_SZ = 0x408
- F_GETSIG = 0xb
- F_LOCK = 0x1
- F_NOTIFY = 0x402
- F_OK = 0x0
- F_RDLCK = 0x0
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLEASE = 0x400
- F_SETLK = 0x6
- F_SETLK64 = 0x6
- F_SETLKW = 0x7
- F_SETLKW64 = 0x7
- F_SETOWN = 0x8
- F_SETOWN_EX = 0xf
- F_SETPIPE_SZ = 0x407
- F_SETSIG = 0xa
- F_SHLCK = 0x8
- F_TEST = 0x3
- F_TLOCK = 0x2
- F_ULOCK = 0x0
- F_UNLCK = 0x2
- F_WRLCK = 0x1
- HUPCL = 0x400
- IBSHIFT = 0x10
- ICANON = 0x2
- ICMPV6_FILTER = 0x1
- ICRNL = 0x100
- IEXTEN = 0x8000
- IFA_F_DADFAILED = 0x8
- IFA_F_DEPRECATED = 0x20
- IFA_F_HOMEADDRESS = 0x10
- IFA_F_NODAD = 0x2
- IFA_F_OPTIMISTIC = 0x4
- IFA_F_PERMANENT = 0x80
- IFA_F_SECONDARY = 0x1
- IFA_F_TEMPORARY = 0x1
- IFA_F_TENTATIVE = 0x40
- IFA_MAX = 0x7
- IFF_802_1Q_VLAN = 0x1
- IFF_ALLMULTI = 0x200
- IFF_ATTACH_QUEUE = 0x200
- IFF_AUTOMEDIA = 0x4000
- IFF_BONDING = 0x20
- IFF_BRIDGE_PORT = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_DETACH_QUEUE = 0x400
- IFF_DISABLE_NETPOLL = 0x1000
- IFF_DONT_BRIDGE = 0x800
- IFF_DORMANT = 0x20000
- IFF_DYNAMIC = 0x8000
- IFF_EBRIDGE = 0x2
- IFF_ECHO = 0x40000
- IFF_ISATAP = 0x80
- IFF_LIVE_ADDR_CHANGE = 0x100000
- IFF_LOOPBACK = 0x8
- IFF_LOWER_UP = 0x10000
- IFF_MACVLAN = 0x200000
- IFF_MACVLAN_PORT = 0x2000
- IFF_MASTER = 0x400
- IFF_MASTER_8023AD = 0x8
- IFF_MASTER_ALB = 0x10
- IFF_MASTER_ARPMON = 0x100
- IFF_MULTICAST = 0x1000
- IFF_MULTI_QUEUE = 0x100
- IFF_NOARP = 0x80
- IFF_NOFILTER = 0x1000
- IFF_NOTRAILERS = 0x20
- IFF_NO_PI = 0x1000
- IFF_ONE_QUEUE = 0x2000
- IFF_OVS_DATAPATH = 0x8000
- IFF_PERSIST = 0x800
- IFF_POINTOPOINT = 0x10
- IFF_PORTSEL = 0x2000
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SLAVE = 0x800
- IFF_SLAVE_INACTIVE = 0x4
- IFF_SLAVE_NEEDARP = 0x40
- IFF_SUPP_NOFCS = 0x80000
- IFF_TAP = 0x2
- IFF_TEAM_PORT = 0x40000
- IFF_TUN = 0x1
- IFF_TUN_EXCL = 0x8000
- IFF_TX_SKB_SHARING = 0x10000
- IFF_UNICAST_FLT = 0x20000
- IFF_UP = 0x1
- IFF_VNET_HDR = 0x4000
- IFF_VOLATILE = 0x70c5a
- IFF_WAN_HDLC = 0x200
- IFF_XMIT_DST_RELEASE = 0x400
- IFNAMSIZ = 0x10
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_ACCESS = 0x1
- IN_ALL_EVENTS = 0xfff
- IN_ATTRIB = 0x4
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLOEXEC = 0x80000
- IN_CLOSE = 0x18
- IN_CLOSE_NOWRITE = 0x10
- IN_CLOSE_WRITE = 0x8
- IN_CREATE = 0x100
- IN_DELETE = 0x200
- IN_DELETE_SELF = 0x400
- IN_DONT_FOLLOW = 0x2000000
- IN_EXCL_UNLINK = 0x4000000
- IN_IGNORED = 0x8000
- IN_ISDIR = 0x40000000
- IN_LOOPBACKNET = 0x7f
- IN_MASK_ADD = 0x20000000
- IN_MODIFY = 0x2
- IN_MOVE = 0xc0
- IN_MOVED_FROM = 0x40
- IN_MOVED_TO = 0x80
- IN_MOVE_SELF = 0x800
- IN_NONBLOCK = 0x800
- IN_ONESHOT = 0x80000000
- IN_ONLYDIR = 0x1000000
- IN_OPEN = 0x20
- IN_Q_OVERFLOW = 0x4000
- IN_UNMOUNT = 0x2000
- IPPROTO_AH = 0x33
- IPPROTO_BEETPH = 0x5e
- IPPROTO_COMP = 0x6c
- IPPROTO_DCCP = 0x21
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_ENCAP = 0x62
- IPPROTO_ESP = 0x32
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GRE = 0x2f
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IGMP = 0x2
- IPPROTO_IP = 0x0
- IPPROTO_IPIP = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_MH = 0x87
- IPPROTO_MTP = 0x5c
- IPPROTO_NONE = 0x3b
- IPPROTO_PIM = 0x67
- IPPROTO_PUP = 0xc
- IPPROTO_RAW = 0xff
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_SCTP = 0x84
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_UDP = 0x11
- IPPROTO_UDPLITE = 0x88
- IPV6_2292DSTOPTS = 0x4
- IPV6_2292HOPLIMIT = 0x8
- IPV6_2292HOPOPTS = 0x3
- IPV6_2292PKTINFO = 0x2
- IPV6_2292PKTOPTIONS = 0x6
- IPV6_2292RTHDR = 0x5
- IPV6_ADDRFORM = 0x1
- IPV6_ADD_MEMBERSHIP = 0x14
- IPV6_AUTHHDR = 0xa
- IPV6_CHECKSUM = 0x7
- IPV6_DROP_MEMBERSHIP = 0x15
- IPV6_DSTOPTS = 0x3b
- IPV6_HOPLIMIT = 0x34
- IPV6_HOPOPTS = 0x36
- IPV6_IPSEC_POLICY = 0x22
- IPV6_JOIN_ANYCAST = 0x1b
- IPV6_JOIN_GROUP = 0x14
- IPV6_LEAVE_ANYCAST = 0x1c
- IPV6_LEAVE_GROUP = 0x15
- IPV6_MTU = 0x18
- IPV6_MTU_DISCOVER = 0x17
- IPV6_MULTICAST_HOPS = 0x12
- IPV6_MULTICAST_IF = 0x11
- IPV6_MULTICAST_LOOP = 0x13
- IPV6_NEXTHOP = 0x9
- IPV6_PKTINFO = 0x32
- IPV6_PMTUDISC_DO = 0x2
- IPV6_PMTUDISC_DONT = 0x0
- IPV6_PMTUDISC_PROBE = 0x3
- IPV6_PMTUDISC_WANT = 0x1
- IPV6_RECVDSTOPTS = 0x3a
- IPV6_RECVERR = 0x19
- IPV6_RECVHOPLIMIT = 0x33
- IPV6_RECVHOPOPTS = 0x35
- IPV6_RECVPKTINFO = 0x31
- IPV6_RECVRTHDR = 0x38
- IPV6_RECVTCLASS = 0x42
- IPV6_ROUTER_ALERT = 0x16
- IPV6_RTHDR = 0x39
- IPV6_RTHDRDSTOPTS = 0x37
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_RXDSTOPTS = 0x3b
- IPV6_RXHOPOPTS = 0x36
- IPV6_TCLASS = 0x43
- IPV6_UNICAST_HOPS = 0x10
- IPV6_V6ONLY = 0x1a
- IPV6_XFRM_POLICY = 0x23
- IP_ADD_MEMBERSHIP = 0x23
- IP_ADD_SOURCE_MEMBERSHIP = 0x27
- IP_BLOCK_SOURCE = 0x26
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0x24
- IP_DROP_SOURCE_MEMBERSHIP = 0x28
- IP_FREEBIND = 0xf
- IP_HDRINCL = 0x3
- IP_IPSEC_POLICY = 0x10
- IP_MAXPACKET = 0xffff
- IP_MAX_MEMBERSHIPS = 0x14
- IP_MF = 0x2000
- IP_MINTTL = 0x15
- IP_MSFILTER = 0x29
- IP_MSS = 0x240
- IP_MTU = 0xe
- IP_MTU_DISCOVER = 0xa
- IP_MULTICAST_ALL = 0x31
- IP_MULTICAST_IF = 0x20
- IP_MULTICAST_LOOP = 0x22
- IP_MULTICAST_TTL = 0x21
- IP_OFFMASK = 0x1fff
- IP_OPTIONS = 0x4
- IP_ORIGDSTADDR = 0x14
- IP_PASSSEC = 0x12
- IP_PKTINFO = 0x8
- IP_PKTOPTIONS = 0x9
- IP_PMTUDISC = 0xa
- IP_PMTUDISC_DO = 0x2
- IP_PMTUDISC_DONT = 0x0
- IP_PMTUDISC_PROBE = 0x3
- IP_PMTUDISC_WANT = 0x1
- IP_RECVERR = 0xb
- IP_RECVOPTS = 0x6
- IP_RECVORIGDSTADDR = 0x14
- IP_RECVRETOPTS = 0x7
- IP_RECVTOS = 0xd
- IP_RECVTTL = 0xc
- IP_RETOPTS = 0x7
- IP_RF = 0x8000
- IP_ROUTER_ALERT = 0x5
- IP_TOS = 0x1
- IP_TRANSPARENT = 0x13
- IP_TTL = 0x2
- IP_UNBLOCK_SOURCE = 0x25
- IP_UNICAST_IF = 0x32
- IP_XFRM_POLICY = 0x11
- ISIG = 0x1
- ISTRIP = 0x20
- IUCLC = 0x200
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x1000
- IXON = 0x400
- LINUX_REBOOT_CMD_CAD_OFF = 0x0
- LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
- LINUX_REBOOT_CMD_HALT = 0xcdef0123
- LINUX_REBOOT_CMD_KEXEC = 0x45584543
- LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
- LINUX_REBOOT_CMD_RESTART = 0x1234567
- LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
- LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
- LINUX_REBOOT_MAGIC1 = 0xfee1dead
- LINUX_REBOOT_MAGIC2 = 0x28121969
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_DODUMP = 0x11
- MADV_DOFORK = 0xb
- MADV_DONTDUMP = 0x10
- MADV_DONTFORK = 0xa
- MADV_DONTNEED = 0x4
- MADV_HUGEPAGE = 0xe
- MADV_HWPOISON = 0x64
- MADV_MERGEABLE = 0xc
- MADV_NOHUGEPAGE = 0xf
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_REMOVE = 0x9
- MADV_SEQUENTIAL = 0x2
- MADV_UNMERGEABLE = 0xd
- MADV_WILLNEED = 0x3
- MAP_ANON = 0x20
- MAP_ANONYMOUS = 0x20
- MAP_DENYWRITE = 0x800
- MAP_EXECUTABLE = 0x1000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_GROWSDOWN = 0x100
- MAP_HUGETLB = 0x40000
- MAP_HUGE_MASK = 0x3f
- MAP_HUGE_SHIFT = 0x1a
- MAP_LOCKED = 0x2000
- MAP_NONBLOCK = 0x10000
- MAP_NORESERVE = 0x4000
- MAP_POPULATE = 0x8000
- MAP_PRIVATE = 0x2
- MAP_SHARED = 0x1
- MAP_STACK = 0x20000
- MAP_TYPE = 0xf
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MNT_DETACH = 0x2
- MNT_EXPIRE = 0x4
- MNT_FORCE = 0x1
- MSG_CMSG_CLOEXEC = 0x40000000
- MSG_CONFIRM = 0x800
- MSG_CTRUNC = 0x8
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x40
- MSG_EOR = 0x80
- MSG_ERRQUEUE = 0x2000
- MSG_FASTOPEN = 0x20000000
- MSG_FIN = 0x200
- MSG_MORE = 0x8000
- MSG_NOSIGNAL = 0x4000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_PROXY = 0x10
- MSG_RST = 0x1000
- MSG_SYN = 0x400
- MSG_TRUNC = 0x20
- MSG_TRYHARD = 0x4
- MSG_WAITALL = 0x100
- MSG_WAITFORONE = 0x10000
- MS_ACTIVE = 0x40000000
- MS_ASYNC = 0x1
- MS_BIND = 0x1000
- MS_DIRSYNC = 0x80
- MS_INVALIDATE = 0x2
- MS_I_VERSION = 0x800000
- MS_KERNMOUNT = 0x400000
- MS_MANDLOCK = 0x40
- MS_MGC_MSK = 0xffff0000
- MS_MGC_VAL = 0xc0ed0000
- MS_MOVE = 0x2000
- MS_NOATIME = 0x400
- MS_NODEV = 0x4
- MS_NODIRATIME = 0x800
- MS_NOEXEC = 0x8
- MS_NOSUID = 0x2
- MS_NOUSER = -0x80000000
- MS_POSIXACL = 0x10000
- MS_PRIVATE = 0x40000
- MS_RDONLY = 0x1
- MS_REC = 0x4000
- MS_RELATIME = 0x200000
- MS_REMOUNT = 0x20
- MS_RMT_MASK = 0x800051
- MS_SHARED = 0x100000
- MS_SILENT = 0x8000
- MS_SLAVE = 0x80000
- MS_STRICTATIME = 0x1000000
- MS_SYNC = 0x4
- MS_SYNCHRONOUS = 0x10
- MS_UNBINDABLE = 0x20000
- NAME_MAX = 0xff
- NETLINK_ADD_MEMBERSHIP = 0x1
- NETLINK_AUDIT = 0x9
- NETLINK_BROADCAST_ERROR = 0x4
- NETLINK_CONNECTOR = 0xb
- NETLINK_CRYPTO = 0x15
- NETLINK_DNRTMSG = 0xe
- NETLINK_DROP_MEMBERSHIP = 0x2
- NETLINK_ECRYPTFS = 0x13
- NETLINK_FIB_LOOKUP = 0xa
- NETLINK_FIREWALL = 0x3
- NETLINK_GENERIC = 0x10
- NETLINK_INET_DIAG = 0x4
- NETLINK_IP6_FW = 0xd
- NETLINK_ISCSI = 0x8
- NETLINK_KOBJECT_UEVENT = 0xf
- NETLINK_NETFILTER = 0xc
- NETLINK_NFLOG = 0x5
- NETLINK_NO_ENOBUFS = 0x5
- NETLINK_PKTINFO = 0x3
- NETLINK_RDMA = 0x14
- NETLINK_ROUTE = 0x0
- NETLINK_RX_RING = 0x6
- NETLINK_SCSITRANSPORT = 0x12
- NETLINK_SELINUX = 0x7
- NETLINK_SOCK_DIAG = 0x4
- NETLINK_TX_RING = 0x7
- NETLINK_UNUSED = 0x1
- NETLINK_USERSOCK = 0x2
- NETLINK_XFRM = 0x6
- NL0 = 0x0
- NL1 = 0x100
- NLA_ALIGNTO = 0x4
- NLA_F_NESTED = 0x8000
- NLA_F_NET_BYTEORDER = 0x4000
- NLA_HDRLEN = 0x4
- NLDLY = 0x100
- NLMSG_ALIGNTO = 0x4
- NLMSG_DONE = 0x3
- NLMSG_ERROR = 0x2
- NLMSG_HDRLEN = 0x10
- NLMSG_MIN_TYPE = 0x10
- NLMSG_NOOP = 0x1
- NLMSG_OVERRUN = 0x4
- NLM_F_ACK = 0x4
- NLM_F_APPEND = 0x800
- NLM_F_ATOMIC = 0x400
- NLM_F_CREATE = 0x400
- NLM_F_DUMP = 0x300
- NLM_F_DUMP_INTR = 0x10
- NLM_F_ECHO = 0x8
- NLM_F_EXCL = 0x200
- NLM_F_MATCH = 0x200
- NLM_F_MULTI = 0x2
- NLM_F_REPLACE = 0x100
- NLM_F_REQUEST = 0x1
- NLM_F_ROOT = 0x100
- NOFLSH = 0x80
- OCRNL = 0x8
- OFDEL = 0x80
- OFILL = 0x40
- OLCUC = 0x2
- ONLCR = 0x4
- ONLRET = 0x20
- ONOCR = 0x10
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x400
- O_ASYNC = 0x2000
- O_CLOEXEC = 0x80000
- O_CREAT = 0x40
- O_DIRECT = 0x10000
- O_DIRECTORY = 0x4000
- O_DSYNC = 0x1000
- O_EXCL = 0x80
- O_FSYNC = 0x101000
- O_LARGEFILE = 0x0
- O_NDELAY = 0x800
- O_NOATIME = 0x40000
- O_NOCTTY = 0x100
- O_NOFOLLOW = 0x8000
- O_NONBLOCK = 0x800
- O_PATH = 0x200000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_RSYNC = 0x101000
- O_SYNC = 0x101000
- O_TMPFILE = 0x410000
- O_TRUNC = 0x200
- O_WRONLY = 0x1
- PACKET_ADD_MEMBERSHIP = 0x1
- PACKET_AUXDATA = 0x8
- PACKET_BROADCAST = 0x1
- PACKET_COPY_THRESH = 0x7
- PACKET_DROP_MEMBERSHIP = 0x2
- PACKET_FANOUT = 0x12
- PACKET_FANOUT_CPU = 0x2
- PACKET_FANOUT_FLAG_DEFRAG = 0x8000
- PACKET_FANOUT_FLAG_ROLLOVER = 0x1000
- PACKET_FANOUT_HASH = 0x0
- PACKET_FANOUT_LB = 0x1
- PACKET_FANOUT_RND = 0x4
- PACKET_FANOUT_ROLLOVER = 0x3
- PACKET_FASTROUTE = 0x6
- PACKET_HDRLEN = 0xb
- PACKET_HOST = 0x0
- PACKET_LOOPBACK = 0x5
- PACKET_LOSS = 0xe
- PACKET_MR_ALLMULTI = 0x2
- PACKET_MR_MULTICAST = 0x0
- PACKET_MR_PROMISC = 0x1
- PACKET_MR_UNICAST = 0x3
- PACKET_MULTICAST = 0x2
- PACKET_ORIGDEV = 0x9
- PACKET_OTHERHOST = 0x3
- PACKET_OUTGOING = 0x4
- PACKET_RECV_OUTPUT = 0x3
- PACKET_RESERVE = 0xc
- PACKET_RX_RING = 0x5
- PACKET_STATISTICS = 0x6
- PACKET_TIMESTAMP = 0x11
- PACKET_TX_HAS_OFF = 0x13
- PACKET_TX_RING = 0xd
- PACKET_TX_TIMESTAMP = 0x10
- PACKET_VERSION = 0xa
- PACKET_VNET_HDR = 0xf
- PARENB = 0x100
- PARITY_CRC16_PR0 = 0x2
- PARITY_CRC16_PR0_CCITT = 0x4
- PARITY_CRC16_PR1 = 0x3
- PARITY_CRC16_PR1_CCITT = 0x5
- PARITY_CRC32_PR0_CCITT = 0x6
- PARITY_CRC32_PR1_CCITT = 0x7
- PARITY_DEFAULT = 0x0
- PARITY_NONE = 0x1
- PARMRK = 0x8
- PARODD = 0x200
- PENDIN = 0x4000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_GROWSDOWN = 0x1000000
- PROT_GROWSUP = 0x2000000
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- PR_CAPBSET_DROP = 0x18
- PR_CAPBSET_READ = 0x17
- PR_ENDIAN_BIG = 0x0
- PR_ENDIAN_LITTLE = 0x1
- PR_ENDIAN_PPC_LITTLE = 0x2
- PR_FPEMU_NOPRINT = 0x1
- PR_FPEMU_SIGFPE = 0x2
- PR_FP_EXC_ASYNC = 0x2
- PR_FP_EXC_DISABLED = 0x0
- PR_FP_EXC_DIV = 0x10000
- PR_FP_EXC_INV = 0x100000
- PR_FP_EXC_NONRECOV = 0x1
- PR_FP_EXC_OVF = 0x20000
- PR_FP_EXC_PRECISE = 0x3
- PR_FP_EXC_RES = 0x80000
- PR_FP_EXC_SW_ENABLE = 0x80
- PR_FP_EXC_UND = 0x40000
- PR_GET_CHILD_SUBREAPER = 0x25
- PR_GET_DUMPABLE = 0x3
- PR_GET_ENDIAN = 0x13
- PR_GET_FPEMU = 0x9
- PR_GET_FPEXC = 0xb
- PR_GET_KEEPCAPS = 0x7
- PR_GET_NAME = 0x10
- PR_GET_NO_NEW_PRIVS = 0x27
- PR_GET_PDEATHSIG = 0x2
- PR_GET_SECCOMP = 0x15
- PR_GET_SECUREBITS = 0x1b
- PR_GET_TID_ADDRESS = 0x28
- PR_GET_TIMERSLACK = 0x1e
- PR_GET_TIMING = 0xd
- PR_GET_TSC = 0x19
- PR_GET_UNALIGN = 0x5
- PR_MCE_KILL = 0x21
- PR_MCE_KILL_CLEAR = 0x0
- PR_MCE_KILL_DEFAULT = 0x2
- PR_MCE_KILL_EARLY = 0x1
- PR_MCE_KILL_GET = 0x22
- PR_MCE_KILL_LATE = 0x0
- PR_MCE_KILL_SET = 0x1
- PR_SET_CHILD_SUBREAPER = 0x24
- PR_SET_DUMPABLE = 0x4
- PR_SET_ENDIAN = 0x14
- PR_SET_FPEMU = 0xa
- PR_SET_FPEXC = 0xc
- PR_SET_KEEPCAPS = 0x8
- PR_SET_MM = 0x23
- PR_SET_MM_ARG_END = 0x9
- PR_SET_MM_ARG_START = 0x8
- PR_SET_MM_AUXV = 0xc
- PR_SET_MM_BRK = 0x7
- PR_SET_MM_END_CODE = 0x2
- PR_SET_MM_END_DATA = 0x4
- PR_SET_MM_ENV_END = 0xb
- PR_SET_MM_ENV_START = 0xa
- PR_SET_MM_EXE_FILE = 0xd
- PR_SET_MM_START_BRK = 0x6
- PR_SET_MM_START_CODE = 0x1
- PR_SET_MM_START_DATA = 0x3
- PR_SET_MM_START_STACK = 0x5
- PR_SET_NAME = 0xf
- PR_SET_NO_NEW_PRIVS = 0x26
- PR_SET_PDEATHSIG = 0x1
- PR_SET_PTRACER = 0x59616d61
- PR_SET_PTRACER_ANY = -0x1
- PR_SET_SECCOMP = 0x16
- PR_SET_SECUREBITS = 0x1c
- PR_SET_TIMERSLACK = 0x1d
- PR_SET_TIMING = 0xe
- PR_SET_TSC = 0x1a
- PR_SET_UNALIGN = 0x6
- PR_TASK_PERF_EVENTS_DISABLE = 0x1f
- PR_TASK_PERF_EVENTS_ENABLE = 0x20
- PR_TIMING_STATISTICAL = 0x0
- PR_TIMING_TIMESTAMP = 0x1
- PR_TSC_ENABLE = 0x1
- PR_TSC_SIGSEGV = 0x2
- PR_UNALIGN_NOPRINT = 0x1
- PR_UNALIGN_SIGBUS = 0x2
- PTRACE_ATTACH = 0x10
- PTRACE_CONT = 0x7
- PTRACE_DETACH = 0x11
- PTRACE_EVENT_CLONE = 0x3
- PTRACE_EVENT_EXEC = 0x4
- PTRACE_EVENT_EXIT = 0x6
- PTRACE_EVENT_FORK = 0x1
- PTRACE_EVENT_SECCOMP = 0x7
- PTRACE_EVENT_STOP = 0x80
- PTRACE_EVENT_VFORK = 0x2
- PTRACE_EVENT_VFORK_DONE = 0x5
- PTRACE_GETEVENTMSG = 0x4201
- PTRACE_GETREGS = 0xc
- PTRACE_GETREGSET = 0x4204
- PTRACE_GETSIGINFO = 0x4202
- PTRACE_GETSIGMASK = 0x420a
- PTRACE_INTERRUPT = 0x4207
- PTRACE_KILL = 0x8
- PTRACE_LISTEN = 0x4208
- PTRACE_O_EXITKILL = 0x100000
- PTRACE_O_MASK = 0x1000ff
- PTRACE_O_TRACECLONE = 0x8
- PTRACE_O_TRACEEXEC = 0x10
- PTRACE_O_TRACEEXIT = 0x40
- PTRACE_O_TRACEFORK = 0x2
- PTRACE_O_TRACESECCOMP = 0x80
- PTRACE_O_TRACESYSGOOD = 0x1
- PTRACE_O_TRACEVFORK = 0x4
- PTRACE_O_TRACEVFORKDONE = 0x20
- PTRACE_PEEKDATA = 0x2
- PTRACE_PEEKSIGINFO = 0x4209
- PTRACE_PEEKSIGINFO_SHARED = 0x1
- PTRACE_PEEKTEXT = 0x1
- PTRACE_PEEKUSR = 0x3
- PTRACE_POKEDATA = 0x5
- PTRACE_POKETEXT = 0x4
- PTRACE_POKEUSR = 0x6
- PTRACE_SEIZE = 0x4206
- PTRACE_SETOPTIONS = 0x4200
- PTRACE_SETREGS = 0xd
- PTRACE_SETREGSET = 0x4205
- PTRACE_SETSIGINFO = 0x4203
- PTRACE_SETSIGMASK = 0x420b
- PTRACE_SINGLESTEP = 0x9
- PTRACE_SYSCALL = 0x18
- PTRACE_TRACEME = 0x0
- RLIMIT_AS = 0x9
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x7
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = -0x1
- RTAX_ADVMSS = 0x8
- RTAX_CWND = 0x7
- RTAX_FEATURES = 0xc
- RTAX_FEATURE_ALLFRAG = 0x8
- RTAX_FEATURE_ECN = 0x1
- RTAX_FEATURE_SACK = 0x2
- RTAX_FEATURE_TIMESTAMP = 0x4
- RTAX_HOPLIMIT = 0xa
- RTAX_INITCWND = 0xb
- RTAX_INITRWND = 0xe
- RTAX_LOCK = 0x1
- RTAX_MAX = 0xf
- RTAX_MTU = 0x2
- RTAX_QUICKACK = 0xf
- RTAX_REORDERING = 0x9
- RTAX_RTO_MIN = 0xd
- RTAX_RTT = 0x4
- RTAX_RTTVAR = 0x5
- RTAX_SSTHRESH = 0x6
- RTAX_UNSPEC = 0x0
- RTAX_WINDOW = 0x3
- RTA_ALIGNTO = 0x4
- RTA_MAX = 0x11
- RTCF_DIRECTSRC = 0x4000000
- RTCF_DOREDIRECT = 0x1000000
- RTCF_LOG = 0x2000000
- RTCF_MASQ = 0x400000
- RTCF_NAT = 0x800000
- RTCF_VALVE = 0x200000
- RTF_ADDRCLASSMASK = 0xf8000000
- RTF_ADDRCONF = 0x40000
- RTF_ALLONLINK = 0x20000
- RTF_BROADCAST = 0x10000000
- RTF_CACHE = 0x1000000
- RTF_DEFAULT = 0x10000
- RTF_DYNAMIC = 0x10
- RTF_FLOW = 0x2000000
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_INTERFACE = 0x40000000
- RTF_IRTT = 0x100
- RTF_LINKRT = 0x100000
- RTF_LOCAL = 0x80000000
- RTF_MODIFIED = 0x20
- RTF_MSS = 0x40
- RTF_MTU = 0x40
- RTF_MULTICAST = 0x20000000
- RTF_NAT = 0x8000000
- RTF_NOFORWARD = 0x1000
- RTF_NONEXTHOP = 0x200000
- RTF_NOPMTUDISC = 0x4000
- RTF_POLICY = 0x4000000
- RTF_REINSTATE = 0x8
- RTF_REJECT = 0x200
- RTF_STATIC = 0x400
- RTF_THROW = 0x2000
- RTF_UP = 0x1
- RTF_WINDOW = 0x80
- RTF_XRESOLVE = 0x800
- RTM_BASE = 0x10
- RTM_DELACTION = 0x31
- RTM_DELADDR = 0x15
- RTM_DELADDRLABEL = 0x49
- RTM_DELLINK = 0x11
- RTM_DELMDB = 0x55
- RTM_DELNEIGH = 0x1d
- RTM_DELQDISC = 0x25
- RTM_DELROUTE = 0x19
- RTM_DELRULE = 0x21
- RTM_DELTCLASS = 0x29
- RTM_DELTFILTER = 0x2d
- RTM_F_CLONED = 0x200
- RTM_F_EQUALIZE = 0x400
- RTM_F_NOTIFY = 0x100
- RTM_F_PREFIX = 0x800
- RTM_GETACTION = 0x32
- RTM_GETADDR = 0x16
- RTM_GETADDRLABEL = 0x4a
- RTM_GETANYCAST = 0x3e
- RTM_GETDCB = 0x4e
- RTM_GETLINK = 0x12
- RTM_GETMDB = 0x56
- RTM_GETMULTICAST = 0x3a
- RTM_GETNEIGH = 0x1e
- RTM_GETNEIGHTBL = 0x42
- RTM_GETNETCONF = 0x52
- RTM_GETQDISC = 0x26
- RTM_GETROUTE = 0x1a
- RTM_GETRULE = 0x22
- RTM_GETTCLASS = 0x2a
- RTM_GETTFILTER = 0x2e
- RTM_MAX = 0x57
- RTM_NEWACTION = 0x30
- RTM_NEWADDR = 0x14
- RTM_NEWADDRLABEL = 0x48
- RTM_NEWLINK = 0x10
- RTM_NEWMDB = 0x54
- RTM_NEWNDUSEROPT = 0x44
- RTM_NEWNEIGH = 0x1c
- RTM_NEWNEIGHTBL = 0x40
- RTM_NEWNETCONF = 0x50
- RTM_NEWPREFIX = 0x34
- RTM_NEWQDISC = 0x24
- RTM_NEWROUTE = 0x18
- RTM_NEWRULE = 0x20
- RTM_NEWTCLASS = 0x28
- RTM_NEWTFILTER = 0x2c
- RTM_NR_FAMILIES = 0x12
- RTM_NR_MSGTYPES = 0x48
- RTM_SETDCB = 0x4f
- RTM_SETLINK = 0x13
- RTM_SETNEIGHTBL = 0x43
- RTNH_ALIGNTO = 0x4
- RTNH_F_DEAD = 0x1
- RTNH_F_ONLINK = 0x4
- RTNH_F_PERVASIVE = 0x2
- RTN_MAX = 0xb
- RTPROT_BIRD = 0xc
- RTPROT_BOOT = 0x3
- RTPROT_DHCP = 0x10
- RTPROT_DNROUTED = 0xd
- RTPROT_GATED = 0x8
- RTPROT_KERNEL = 0x2
- RTPROT_MROUTED = 0x11
- RTPROT_MRT = 0xa
- RTPROT_NTK = 0xf
- RTPROT_RA = 0x9
- RTPROT_REDIRECT = 0x1
- RTPROT_STATIC = 0x4
- RTPROT_UNSPEC = 0x0
- RTPROT_XORP = 0xe
- RTPROT_ZEBRA = 0xb
- RT_CLASS_DEFAULT = 0xfd
- RT_CLASS_LOCAL = 0xff
- RT_CLASS_MAIN = 0xfe
- RT_CLASS_MAX = 0xff
- RT_CLASS_UNSPEC = 0x0
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- RUSAGE_THREAD = 0x1
- SCM_CREDENTIALS = 0x2
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x1d
- SCM_TIMESTAMPING = 0x25
- SCM_TIMESTAMPNS = 0x23
- SCM_WIFI_STATUS = 0x29
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDDLCI = 0x8980
- SIOCADDMULTI = 0x8931
- SIOCADDRT = 0x890b
- SIOCATMARK = 0x8905
- SIOCDARP = 0x8953
- SIOCDELDLCI = 0x8981
- SIOCDELMULTI = 0x8932
- SIOCDELRT = 0x890c
- SIOCDEVPRIVATE = 0x89f0
- SIOCDIFADDR = 0x8936
- SIOCDRARP = 0x8960
- SIOCGARP = 0x8954
- SIOCGIFADDR = 0x8915
- SIOCGIFBR = 0x8940
- SIOCGIFBRDADDR = 0x8919
- SIOCGIFCONF = 0x8912
- SIOCGIFCOUNT = 0x8938
- SIOCGIFDSTADDR = 0x8917
- SIOCGIFENCAP = 0x8925
- SIOCGIFFLAGS = 0x8913
- SIOCGIFHWADDR = 0x8927
- SIOCGIFINDEX = 0x8933
- SIOCGIFMAP = 0x8970
- SIOCGIFMEM = 0x891f
- SIOCGIFMETRIC = 0x891d
- SIOCGIFMTU = 0x8921
- SIOCGIFNAME = 0x8910
- SIOCGIFNETMASK = 0x891b
- SIOCGIFPFLAGS = 0x8935
- SIOCGIFSLAVE = 0x8929
- SIOCGIFTXQLEN = 0x8942
- SIOCGPGRP = 0x8904
- SIOCGRARP = 0x8961
- SIOCGSTAMP = 0x8906
- SIOCGSTAMPNS = 0x8907
- SIOCPROTOPRIVATE = 0x89e0
- SIOCRTMSG = 0x890d
- SIOCSARP = 0x8955
- SIOCSIFADDR = 0x8916
- SIOCSIFBR = 0x8941
- SIOCSIFBRDADDR = 0x891a
- SIOCSIFDSTADDR = 0x8918
- SIOCSIFENCAP = 0x8926
- SIOCSIFFLAGS = 0x8914
- SIOCSIFHWADDR = 0x8924
- SIOCSIFHWBROADCAST = 0x8937
- SIOCSIFLINK = 0x8911
- SIOCSIFMAP = 0x8971
- SIOCSIFMEM = 0x8920
- SIOCSIFMETRIC = 0x891e
- SIOCSIFMTU = 0x8922
- SIOCSIFNAME = 0x8923
- SIOCSIFNETMASK = 0x891c
- SIOCSIFPFLAGS = 0x8934
- SIOCSIFSLAVE = 0x8930
- SIOCSIFTXQLEN = 0x8943
- SIOCSPGRP = 0x8902
- SIOCSRARP = 0x8962
- SOCK_CLOEXEC = 0x80000
- SOCK_DCCP = 0x6
- SOCK_DGRAM = 0x2
- SOCK_NONBLOCK = 0x800
- SOCK_PACKET = 0xa
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_AAL = 0x109
- SOL_ATM = 0x108
- SOL_DECNET = 0x105
- SOL_ICMPV6 = 0x3a
- SOL_IP = 0x0
- SOL_IPV6 = 0x29
- SOL_IRDA = 0x10a
- SOL_PACKET = 0x107
- SOL_RAW = 0xff
- SOL_SOCKET = 0x1
- SOL_TCP = 0x6
- SOL_X25 = 0x106
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x1e
- SO_ATTACH_FILTER = 0x1a
- SO_BINDTODEVICE = 0x19
- SO_BROADCAST = 0x6
- SO_BSDCOMPAT = 0xe
- SO_BUSY_POLL = 0x2e
- SO_DEBUG = 0x1
- SO_DETACH_FILTER = 0x1b
- SO_DOMAIN = 0x27
- SO_DONTROUTE = 0x5
- SO_ERROR = 0x4
- SO_GET_FILTER = 0x1a
- SO_KEEPALIVE = 0x9
- SO_LINGER = 0xd
- SO_LOCK_FILTER = 0x2c
- SO_MARK = 0x24
- SO_MAX_PACING_RATE = 0x2f
- SO_NOFCS = 0x2b
- SO_NO_CHECK = 0xb
- SO_OOBINLINE = 0xa
- SO_PASSCRED = 0x10
- SO_PASSSEC = 0x22
- SO_PEEK_OFF = 0x2a
- SO_PEERCRED = 0x11
- SO_PEERNAME = 0x1c
- SO_PEERSEC = 0x1f
- SO_PRIORITY = 0xc
- SO_PROTOCOL = 0x26
- SO_RCVBUF = 0x8
- SO_RCVBUFFORCE = 0x21
- SO_RCVLOWAT = 0x12
- SO_RCVTIMEO = 0x14
- SO_REUSEADDR = 0x2
- SO_REUSEPORT = 0xf
- SO_RXQ_OVFL = 0x28
- SO_SECURITY_AUTHENTICATION = 0x16
- SO_SECURITY_ENCRYPTION_NETWORK = 0x18
- SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17
- SO_SELECT_ERR_QUEUE = 0x2d
- SO_SNDBUF = 0x7
- SO_SNDBUFFORCE = 0x20
- SO_SNDLOWAT = 0x13
- SO_SNDTIMEO = 0x15
- SO_TIMESTAMP = 0x1d
- SO_TIMESTAMPING = 0x25
- SO_TIMESTAMPNS = 0x23
- SO_TYPE = 0x3
- SO_WIFI_STATUS = 0x29
- S_BLKSIZE = 0x200
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TAB0 = 0x0
- TAB1 = 0x800
- TAB2 = 0x1000
- TAB3 = 0x1800
- TABDLY = 0x1800
- TCFLSH = 0x540b
- TCGETA = 0x5405
- TCGETS = 0x5401
- TCGETS2 = 0x802c542a
- TCGETX = 0x5432
- TCIFLUSH = 0x0
- TCIOFF = 0x2
- TCIOFLUSH = 0x2
- TCION = 0x3
- TCOFLUSH = 0x1
- TCOOFF = 0x0
- TCOON = 0x1
- TCP_CONGESTION = 0xd
- TCP_COOKIE_IN_ALWAYS = 0x1
- TCP_COOKIE_MAX = 0x10
- TCP_COOKIE_MIN = 0x8
- TCP_COOKIE_OUT_NEVER = 0x2
- TCP_COOKIE_PAIR_SIZE = 0x20
- TCP_COOKIE_TRANSACTIONS = 0xf
- TCP_CORK = 0x3
- TCP_DEFER_ACCEPT = 0x9
- TCP_FASTOPEN = 0x17
- TCP_INFO = 0xb
- TCP_KEEPCNT = 0x6
- TCP_KEEPIDLE = 0x4
- TCP_KEEPINTVL = 0x5
- TCP_LINGER2 = 0x8
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0xe
- TCP_MD5SIG_MAXKEYLEN = 0x50
- TCP_MSS = 0x200
- TCP_MSS_DEFAULT = 0x218
- TCP_MSS_DESIRED = 0x4c4
- TCP_NODELAY = 0x1
- TCP_QUEUE_SEQ = 0x15
- TCP_QUICKACK = 0xc
- TCP_REPAIR = 0x13
- TCP_REPAIR_OPTIONS = 0x16
- TCP_REPAIR_QUEUE = 0x14
- TCP_SYNCNT = 0x7
- TCP_S_DATA_IN = 0x4
- TCP_S_DATA_OUT = 0x8
- TCP_THIN_DUPACK = 0x11
- TCP_THIN_LINEAR_TIMEOUTS = 0x10
- TCP_TIMESTAMP = 0x18
- TCP_USER_TIMEOUT = 0x12
- TCP_WINDOW_CLAMP = 0xa
- TCSAFLUSH = 0x2
- TCSBRK = 0x5409
- TCSBRKP = 0x5425
- TCSETA = 0x5406
- TCSETAF = 0x5408
- TCSETAW = 0x5407
- TCSETS = 0x5402
- TCSETS2 = 0x402c542b
- TCSETSF = 0x5404
- TCSETSF2 = 0x402c542d
- TCSETSW = 0x5403
- TCSETSW2 = 0x402c542c
- TCSETX = 0x5433
- TCSETXF = 0x5434
- TCSETXW = 0x5435
- TCXONC = 0x540a
- TIOCCBRK = 0x5428
- TIOCCONS = 0x541d
- TIOCEXCL = 0x540c
- TIOCGDEV = 0x80045432
- TIOCGETD = 0x5424
- TIOCGEXCL = 0x80045440
- TIOCGICOUNT = 0x545d
- TIOCGLCKTRMIOS = 0x5456
- TIOCGPGRP = 0x540f
- TIOCGPKT = 0x80045438
- TIOCGPTLCK = 0x80045439
- TIOCGPTN = 0x80045430
- TIOCGRS485 = 0x542e
- TIOCGSERIAL = 0x541e
- TIOCGSID = 0x5429
- TIOCGSOFTCAR = 0x5419
- TIOCGWINSZ = 0x5413
- TIOCINQ = 0x541b
- TIOCLINUX = 0x541c
- TIOCMBIC = 0x5417
- TIOCMBIS = 0x5416
- TIOCMGET = 0x5415
- TIOCMIWAIT = 0x545c
- TIOCMSET = 0x5418
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x5422
- TIOCNXCL = 0x540d
- TIOCOUTQ = 0x5411
- TIOCPKT = 0x5420
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCSBRK = 0x5427
- TIOCSCTTY = 0x540e
- TIOCSERCONFIG = 0x5453
- TIOCSERGETLSR = 0x5459
- TIOCSERGETMULTI = 0x545a
- TIOCSERGSTRUCT = 0x5458
- TIOCSERGWILD = 0x5454
- TIOCSERSETMULTI = 0x545b
- TIOCSERSWILD = 0x5455
- TIOCSER_TEMT = 0x1
- TIOCSETD = 0x5423
- TIOCSIG = 0x40045436
- TIOCSLCKTRMIOS = 0x5457
- TIOCSPGRP = 0x5410
- TIOCSPTLCK = 0x40045431
- TIOCSRS485 = 0x542f
- TIOCSSERIAL = 0x541f
- TIOCSSOFTCAR = 0x541a
- TIOCSTI = 0x5412
- TIOCSWINSZ = 0x5414
- TIOCVHANGUP = 0x5437
- TOSTOP = 0x100
- TUNATTACHFILTER = 0x401054d5
- TUNDETACHFILTER = 0x401054d6
- TUNGETFEATURES = 0x800454cf
- TUNGETFILTER = 0x801054db
- TUNGETIFF = 0x800454d2
- TUNGETSNDBUF = 0x800454d3
- TUNGETVNETHDRSZ = 0x800454d7
- TUNSETDEBUG = 0x400454c9
- TUNSETGROUP = 0x400454ce
- TUNSETIFF = 0x400454ca
- TUNSETIFINDEX = 0x400454da
- TUNSETLINK = 0x400454cd
- TUNSETNOCSUM = 0x400454c8
- TUNSETOFFLOAD = 0x400454d0
- TUNSETOWNER = 0x400454cc
- TUNSETPERSIST = 0x400454cb
- TUNSETQUEUE = 0x400454d9
- TUNSETSNDBUF = 0x400454d4
- TUNSETTXFILTER = 0x400454d1
- TUNSETVNETHDRSZ = 0x400454d8
- VDISCARD = 0xd
- VEOF = 0x4
- VEOL = 0xb
- VEOL2 = 0x10
- VERASE = 0x2
- VINTR = 0x0
- VKILL = 0x3
- VLNEXT = 0xf
- VMIN = 0x6
- VQUIT = 0x1
- VREPRINT = 0xc
- VSTART = 0x8
- VSTOP = 0x9
- VSUSP = 0xa
- VSWTC = 0x7
- VT0 = 0x0
- VT1 = 0x4000
- VTDLY = 0x4000
- VTIME = 0x5
- VWERASE = 0xe
- WALL = 0x40000000
- WCLONE = 0x80000000
- WCONTINUED = 0x8
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOTHREAD = 0x20000000
- WNOWAIT = 0x1000000
- WORDSIZE = 0x40
- WSTOPPED = 0x2
- WUNTRACED = 0x2
- XCASE = 0x4
- XTABS = 0x1800
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x62)
- EADDRNOTAVAIL = syscall.Errno(0x63)
- EADV = syscall.Errno(0x44)
- EAFNOSUPPORT = syscall.Errno(0x61)
- EAGAIN = syscall.Errno(0xb)
- EALREADY = syscall.Errno(0x72)
- EBADE = syscall.Errno(0x34)
- EBADF = syscall.Errno(0x9)
- EBADFD = syscall.Errno(0x4d)
- EBADMSG = syscall.Errno(0x4a)
- EBADR = syscall.Errno(0x35)
- EBADRQC = syscall.Errno(0x38)
- EBADSLT = syscall.Errno(0x39)
- EBFONT = syscall.Errno(0x3b)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x7d)
- ECHILD = syscall.Errno(0xa)
- ECHRNG = syscall.Errno(0x2c)
- ECOMM = syscall.Errno(0x46)
- ECONNABORTED = syscall.Errno(0x67)
- ECONNREFUSED = syscall.Errno(0x6f)
- ECONNRESET = syscall.Errno(0x68)
- EDEADLK = syscall.Errno(0x23)
- EDEADLOCK = syscall.Errno(0x23)
- EDESTADDRREQ = syscall.Errno(0x59)
- EDOM = syscall.Errno(0x21)
- EDOTDOT = syscall.Errno(0x49)
- EDQUOT = syscall.Errno(0x7a)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EHOSTDOWN = syscall.Errno(0x70)
- EHOSTUNREACH = syscall.Errno(0x71)
- EHWPOISON = syscall.Errno(0x85)
- EIDRM = syscall.Errno(0x2b)
- EILSEQ = syscall.Errno(0x54)
- EINPROGRESS = syscall.Errno(0x73)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x6a)
- EISDIR = syscall.Errno(0x15)
- EISNAM = syscall.Errno(0x78)
- EKEYEXPIRED = syscall.Errno(0x7f)
- EKEYREJECTED = syscall.Errno(0x81)
- EKEYREVOKED = syscall.Errno(0x80)
- EL2HLT = syscall.Errno(0x33)
- EL2NSYNC = syscall.Errno(0x2d)
- EL3HLT = syscall.Errno(0x2e)
- EL3RST = syscall.Errno(0x2f)
- ELIBACC = syscall.Errno(0x4f)
- ELIBBAD = syscall.Errno(0x50)
- ELIBEXEC = syscall.Errno(0x53)
- ELIBMAX = syscall.Errno(0x52)
- ELIBSCN = syscall.Errno(0x51)
- ELNRNG = syscall.Errno(0x30)
- ELOOP = syscall.Errno(0x28)
- EMEDIUMTYPE = syscall.Errno(0x7c)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x5a)
- EMULTIHOP = syscall.Errno(0x48)
- ENAMETOOLONG = syscall.Errno(0x24)
- ENAVAIL = syscall.Errno(0x77)
- ENETDOWN = syscall.Errno(0x64)
- ENETRESET = syscall.Errno(0x66)
- ENETUNREACH = syscall.Errno(0x65)
- ENFILE = syscall.Errno(0x17)
- ENOANO = syscall.Errno(0x37)
- ENOBUFS = syscall.Errno(0x69)
- ENOCSI = syscall.Errno(0x32)
- ENODATA = syscall.Errno(0x3d)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOKEY = syscall.Errno(0x7e)
- ENOLCK = syscall.Errno(0x25)
- ENOLINK = syscall.Errno(0x43)
- ENOMEDIUM = syscall.Errno(0x7b)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x2a)
- ENONET = syscall.Errno(0x40)
- ENOPKG = syscall.Errno(0x41)
- ENOPROTOOPT = syscall.Errno(0x5c)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x3f)
- ENOSTR = syscall.Errno(0x3c)
- ENOSYS = syscall.Errno(0x26)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x6b)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x27)
- ENOTNAM = syscall.Errno(0x76)
- ENOTRECOVERABLE = syscall.Errno(0x83)
- ENOTSOCK = syscall.Errno(0x58)
- ENOTSUP = syscall.Errno(0x5f)
- ENOTTY = syscall.Errno(0x19)
- ENOTUNIQ = syscall.Errno(0x4c)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x5f)
- EOVERFLOW = syscall.Errno(0x4b)
- EOWNERDEAD = syscall.Errno(0x82)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x60)
- EPIPE = syscall.Errno(0x20)
- EPROTO = syscall.Errno(0x47)
- EPROTONOSUPPORT = syscall.Errno(0x5d)
- EPROTOTYPE = syscall.Errno(0x5b)
- ERANGE = syscall.Errno(0x22)
- EREMCHG = syscall.Errno(0x4e)
- EREMOTE = syscall.Errno(0x42)
- EREMOTEIO = syscall.Errno(0x79)
- ERESTART = syscall.Errno(0x55)
- ERFKILL = syscall.Errno(0x84)
- EROFS = syscall.Errno(0x1e)
- ESHUTDOWN = syscall.Errno(0x6c)
- ESOCKTNOSUPPORT = syscall.Errno(0x5e)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESRMNT = syscall.Errno(0x45)
- ESTALE = syscall.Errno(0x74)
- ESTRPIPE = syscall.Errno(0x56)
- ETIME = syscall.Errno(0x3e)
- ETIMEDOUT = syscall.Errno(0x6e)
- ETOOMANYREFS = syscall.Errno(0x6d)
- ETXTBSY = syscall.Errno(0x1a)
- EUCLEAN = syscall.Errno(0x75)
- EUNATCH = syscall.Errno(0x31)
- EUSERS = syscall.Errno(0x57)
- EWOULDBLOCK = syscall.Errno(0xb)
- EXDEV = syscall.Errno(0x12)
- EXFULL = syscall.Errno(0x36)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0x7)
- SIGCHLD = syscall.Signal(0x11)
- SIGCLD = syscall.Signal(0x11)
- SIGCONT = syscall.Signal(0x12)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x1d)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPOLL = syscall.Signal(0x1d)
- SIGPROF = syscall.Signal(0x1b)
- SIGPWR = syscall.Signal(0x1e)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTKFLT = syscall.Signal(0x10)
- SIGSTOP = syscall.Signal(0x13)
- SIGSYS = syscall.Signal(0x1f)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x14)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGUNUSED = syscall.Signal(0x1f)
- SIGURG = syscall.Signal(0x17)
- SIGUSR1 = syscall.Signal(0xa)
- SIGUSR2 = syscall.Signal(0xc)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "no such device or address",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource temporarily unavailable",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device or resource busy",
- 17: "file exists",
- 18: "invalid cross-device link",
- 19: "no such device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "numerical result out of range",
- 35: "resource deadlock avoided",
- 36: "file name too long",
- 37: "no locks available",
- 38: "function not implemented",
- 39: "directory not empty",
- 40: "too many levels of symbolic links",
- 42: "no message of desired type",
- 43: "identifier removed",
- 44: "channel number out of range",
- 45: "level 2 not synchronized",
- 46: "level 3 halted",
- 47: "level 3 reset",
- 48: "link number out of range",
- 49: "protocol driver not attached",
- 50: "no CSI structure available",
- 51: "level 2 halted",
- 52: "invalid exchange",
- 53: "invalid request descriptor",
- 54: "exchange full",
- 55: "no anode",
- 56: "invalid request code",
- 57: "invalid slot",
- 59: "bad font file format",
- 60: "device not a stream",
- 61: "no data available",
- 62: "timer expired",
- 63: "out of streams resources",
- 64: "machine is not on the network",
- 65: "package not installed",
- 66: "object is remote",
- 67: "link has been severed",
- 68: "advertise error",
- 69: "srmount error",
- 70: "communication error on send",
- 71: "protocol error",
- 72: "multihop attempted",
- 73: "RFS specific error",
- 74: "bad message",
- 75: "value too large for defined data type",
- 76: "name not unique on network",
- 77: "file descriptor in bad state",
- 78: "remote address changed",
- 79: "can not access a needed shared library",
- 80: "accessing a corrupted shared library",
- 81: ".lib section in a.out corrupted",
- 82: "attempting to link in too many shared libraries",
- 83: "cannot exec a shared library directly",
- 84: "invalid or incomplete multibyte or wide character",
- 85: "interrupted system call should be restarted",
- 86: "streams pipe error",
- 87: "too many users",
- 88: "socket operation on non-socket",
- 89: "destination address required",
- 90: "message too long",
- 91: "protocol wrong type for socket",
- 92: "protocol not available",
- 93: "protocol not supported",
- 94: "socket type not supported",
- 95: "operation not supported",
- 96: "protocol family not supported",
- 97: "address family not supported by protocol",
- 98: "address already in use",
- 99: "cannot assign requested address",
- 100: "network is down",
- 101: "network is unreachable",
- 102: "network dropped connection on reset",
- 103: "software caused connection abort",
- 104: "connection reset by peer",
- 105: "no buffer space available",
- 106: "transport endpoint is already connected",
- 107: "transport endpoint is not connected",
- 108: "cannot send after transport endpoint shutdown",
- 109: "too many references: cannot splice",
- 110: "connection timed out",
- 111: "connection refused",
- 112: "host is down",
- 113: "no route to host",
- 114: "operation already in progress",
- 115: "operation now in progress",
- 116: "stale file handle",
- 117: "structure needs cleaning",
- 118: "not a XENIX named type file",
- 119: "no XENIX semaphores available",
- 120: "is a named type file",
- 121: "remote I/O error",
- 122: "disk quota exceeded",
- 123: "no medium found",
- 124: "wrong medium type",
- 125: "operation canceled",
- 126: "required key not available",
- 127: "key has expired",
- 128: "key has been revoked",
- 129: "key was rejected by service",
- 130: "owner died",
- 131: "state not recoverable",
- 132: "operation not possible due to RF-kill",
- 133: "memory page has hardware error",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/breakpoint trap",
- 6: "aborted",
- 7: "bus error",
- 8: "floating point exception",
- 9: "killed",
- 10: "user defined signal 1",
- 11: "segmentation fault",
- 12: "user defined signal 2",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "stack fault",
- 17: "child exited",
- 18: "continued",
- 19: "stopped (signal)",
- 20: "stopped",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "urgent I/O condition",
- 24: "CPU time limit exceeded",
- 25: "file size limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window changed",
- 29: "I/O possible",
- 30: "power failure",
- 31: "bad system call",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/newt/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
deleted file mode 100644
index 36535b24..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
+++ /dev/null
@@ -1,1917 +0,0 @@
-// mkerrors.sh
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build mips64,linux
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_ALG = 0x26
- AF_APPLETALK = 0x5
- AF_ASH = 0x12
- AF_ATMPVC = 0x8
- AF_ATMSVC = 0x14
- AF_AX25 = 0x3
- AF_BLUETOOTH = 0x1f
- AF_BRIDGE = 0x7
- AF_CAIF = 0x25
- AF_CAN = 0x1d
- AF_DECnet = 0xc
- AF_ECONET = 0x13
- AF_FILE = 0x1
- AF_IB = 0x1b
- AF_IEEE802154 = 0x24
- AF_INET = 0x2
- AF_INET6 = 0xa
- AF_IPX = 0x4
- AF_IRDA = 0x17
- AF_ISDN = 0x22
- AF_IUCV = 0x20
- AF_KEY = 0xf
- AF_LLC = 0x1a
- AF_LOCAL = 0x1
- AF_MAX = 0x29
- AF_MPLS = 0x1c
- AF_NETBEUI = 0xd
- AF_NETLINK = 0x10
- AF_NETROM = 0x6
- AF_NFC = 0x27
- AF_PACKET = 0x11
- AF_PHONET = 0x23
- AF_PPPOX = 0x18
- AF_RDS = 0x15
- AF_ROSE = 0xb
- AF_ROUTE = 0x10
- AF_RXRPC = 0x21
- AF_SECURITY = 0xe
- AF_SNA = 0x16
- AF_TIPC = 0x1e
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_VSOCK = 0x28
- AF_WANPIPE = 0x19
- AF_X25 = 0x9
- ARPHRD_6LOWPAN = 0x339
- ARPHRD_ADAPT = 0x108
- ARPHRD_APPLETLK = 0x8
- ARPHRD_ARCNET = 0x7
- ARPHRD_ASH = 0x30d
- ARPHRD_ATM = 0x13
- ARPHRD_AX25 = 0x3
- ARPHRD_BIF = 0x307
- ARPHRD_CAIF = 0x336
- ARPHRD_CAN = 0x118
- ARPHRD_CHAOS = 0x5
- ARPHRD_CISCO = 0x201
- ARPHRD_CSLIP = 0x101
- ARPHRD_CSLIP6 = 0x103
- ARPHRD_DDCMP = 0x205
- ARPHRD_DLCI = 0xf
- ARPHRD_ECONET = 0x30e
- ARPHRD_EETHER = 0x2
- ARPHRD_ETHER = 0x1
- ARPHRD_EUI64 = 0x1b
- ARPHRD_FCAL = 0x311
- ARPHRD_FCFABRIC = 0x313
- ARPHRD_FCPL = 0x312
- ARPHRD_FCPP = 0x310
- ARPHRD_FDDI = 0x306
- ARPHRD_FRAD = 0x302
- ARPHRD_HDLC = 0x201
- ARPHRD_HIPPI = 0x30c
- ARPHRD_HWX25 = 0x110
- ARPHRD_IEEE1394 = 0x18
- ARPHRD_IEEE802 = 0x6
- ARPHRD_IEEE80211 = 0x321
- ARPHRD_IEEE80211_PRISM = 0x322
- ARPHRD_IEEE80211_RADIOTAP = 0x323
- ARPHRD_IEEE802154 = 0x324
- ARPHRD_IEEE802154_MONITOR = 0x325
- ARPHRD_IEEE802_TR = 0x320
- ARPHRD_INFINIBAND = 0x20
- ARPHRD_IP6GRE = 0x337
- ARPHRD_IPDDP = 0x309
- ARPHRD_IPGRE = 0x30a
- ARPHRD_IRDA = 0x30f
- ARPHRD_LAPB = 0x204
- ARPHRD_LOCALTLK = 0x305
- ARPHRD_LOOPBACK = 0x304
- ARPHRD_METRICOM = 0x17
- ARPHRD_NETLINK = 0x338
- ARPHRD_NETROM = 0x0
- ARPHRD_NONE = 0xfffe
- ARPHRD_PHONET = 0x334
- ARPHRD_PHONET_PIPE = 0x335
- ARPHRD_PIMREG = 0x30b
- ARPHRD_PPP = 0x200
- ARPHRD_PRONET = 0x4
- ARPHRD_RAWHDLC = 0x206
- ARPHRD_ROSE = 0x10e
- ARPHRD_RSRVD = 0x104
- ARPHRD_SIT = 0x308
- ARPHRD_SKIP = 0x303
- ARPHRD_SLIP = 0x100
- ARPHRD_SLIP6 = 0x102
- ARPHRD_TUNNEL = 0x300
- ARPHRD_TUNNEL6 = 0x301
- ARPHRD_VOID = 0xffff
- ARPHRD_X25 = 0x10f
- B0 = 0x0
- B1000000 = 0x1008
- B110 = 0x3
- B115200 = 0x1002
- B1152000 = 0x1009
- B1200 = 0x9
- B134 = 0x4
- B150 = 0x5
- B1500000 = 0x100a
- B1800 = 0xa
- B19200 = 0xe
- B200 = 0x6
- B2000000 = 0x100b
- B230400 = 0x1003
- B2400 = 0xb
- B2500000 = 0x100c
- B300 = 0x7
- B3000000 = 0x100d
- B3500000 = 0x100e
- B38400 = 0xf
- B4000000 = 0x100f
- B460800 = 0x1004
- B4800 = 0xc
- B50 = 0x1
- B500000 = 0x1005
- B57600 = 0x1001
- B576000 = 0x1006
- B600 = 0x8
- B75 = 0x2
- B921600 = 0x1007
- B9600 = 0xd
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LL_OFF = -0x200000
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXINSNS = 0x1000
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MOD = 0x90
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_NET_OFF = -0x100000
- BPF_OR = 0x40
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BPF_XOR = 0xa0
- BRKINT = 0x2
- CFLUSH = 0xf
- CLOCAL = 0x800
- CLOCK_BOOTTIME = 0x7
- CLOCK_BOOTTIME_ALARM = 0x9
- CLOCK_DEFAULT = 0x0
- CLOCK_EXT = 0x1
- CLOCK_INT = 0x2
- CLOCK_MONOTONIC = 0x1
- CLOCK_MONOTONIC_COARSE = 0x6
- CLOCK_MONOTONIC_RAW = 0x4
- CLOCK_PROCESS_CPUTIME_ID = 0x2
- CLOCK_REALTIME = 0x0
- CLOCK_REALTIME_ALARM = 0x8
- CLOCK_REALTIME_COARSE = 0x5
- CLOCK_TAI = 0xb
- CLOCK_THREAD_CPUTIME_ID = 0x3
- CLOCK_TXFROMRX = 0x4
- CLOCK_TXINT = 0x3
- CLONE_CHILD_CLEARTID = 0x200000
- CLONE_CHILD_SETTID = 0x1000000
- CLONE_DETACHED = 0x400000
- CLONE_FILES = 0x400
- CLONE_FS = 0x200
- CLONE_IO = 0x80000000
- CLONE_NEWCGROUP = 0x2000000
- CLONE_NEWIPC = 0x8000000
- CLONE_NEWNET = 0x40000000
- CLONE_NEWNS = 0x20000
- CLONE_NEWPID = 0x20000000
- CLONE_NEWUSER = 0x10000000
- CLONE_NEWUTS = 0x4000000
- CLONE_PARENT = 0x8000
- CLONE_PARENT_SETTID = 0x100000
- CLONE_PTRACE = 0x2000
- CLONE_SETTLS = 0x80000
- CLONE_SIGHAND = 0x800
- CLONE_SYSVSEM = 0x40000
- CLONE_THREAD = 0x10000
- CLONE_UNTRACED = 0x800000
- CLONE_VFORK = 0x4000
- CLONE_VM = 0x100
- CREAD = 0x80
- CS5 = 0x0
- CS6 = 0x10
- CS7 = 0x20
- CS8 = 0x30
- CSIGNAL = 0xff
- CSIZE = 0x30
- CSTART = 0x11
- CSTATUS = 0x0
- CSTOP = 0x13
- CSTOPB = 0x40
- CSUSP = 0x1a
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x200
- ECHOE = 0x10
- ECHOK = 0x20
- ECHOKE = 0x800
- ECHONL = 0x40
- ECHOPRT = 0x400
- ENCODING_DEFAULT = 0x0
- ENCODING_FM_MARK = 0x3
- ENCODING_FM_SPACE = 0x4
- ENCODING_MANCHESTER = 0x5
- ENCODING_NRZ = 0x1
- ENCODING_NRZI = 0x2
- EPOLLERR = 0x8
- EPOLLET = 0x80000000
- EPOLLHUP = 0x10
- EPOLLIN = 0x1
- EPOLLMSG = 0x400
- EPOLLONESHOT = 0x40000000
- EPOLLOUT = 0x4
- EPOLLPRI = 0x2
- EPOLLRDBAND = 0x80
- EPOLLRDHUP = 0x2000
- EPOLLRDNORM = 0x40
- EPOLLWAKEUP = 0x20000000
- EPOLLWRBAND = 0x200
- EPOLLWRNORM = 0x100
- EPOLL_CLOEXEC = 0x80000
- EPOLL_CTL_ADD = 0x1
- EPOLL_CTL_DEL = 0x2
- EPOLL_CTL_MOD = 0x3
- ETH_P_1588 = 0x88f7
- ETH_P_8021AD = 0x88a8
- ETH_P_8021AH = 0x88e7
- ETH_P_8021Q = 0x8100
- ETH_P_80221 = 0x8917
- ETH_P_802_2 = 0x4
- ETH_P_802_3 = 0x1
- ETH_P_802_3_MIN = 0x600
- ETH_P_802_EX1 = 0x88b5
- ETH_P_AARP = 0x80f3
- ETH_P_AF_IUCV = 0xfbfb
- ETH_P_ALL = 0x3
- ETH_P_AOE = 0x88a2
- ETH_P_ARCNET = 0x1a
- ETH_P_ARP = 0x806
- ETH_P_ATALK = 0x809b
- ETH_P_ATMFATE = 0x8884
- ETH_P_ATMMPOA = 0x884c
- ETH_P_AX25 = 0x2
- ETH_P_BATMAN = 0x4305
- ETH_P_BPQ = 0x8ff
- ETH_P_CAIF = 0xf7
- ETH_P_CAN = 0xc
- ETH_P_CANFD = 0xd
- ETH_P_CONTROL = 0x16
- ETH_P_CUST = 0x6006
- ETH_P_DDCMP = 0x6
- ETH_P_DEC = 0x6000
- ETH_P_DIAG = 0x6005
- ETH_P_DNA_DL = 0x6001
- ETH_P_DNA_RC = 0x6002
- ETH_P_DNA_RT = 0x6003
- ETH_P_DSA = 0x1b
- ETH_P_ECONET = 0x18
- ETH_P_EDSA = 0xdada
- ETH_P_FCOE = 0x8906
- ETH_P_FIP = 0x8914
- ETH_P_HDLC = 0x19
- ETH_P_IEEE802154 = 0xf6
- ETH_P_IEEEPUP = 0xa00
- ETH_P_IEEEPUPAT = 0xa01
- ETH_P_IP = 0x800
- ETH_P_IPV6 = 0x86dd
- ETH_P_IPX = 0x8137
- ETH_P_IRDA = 0x17
- ETH_P_LAT = 0x6004
- ETH_P_LINK_CTL = 0x886c
- ETH_P_LOCALTALK = 0x9
- ETH_P_LOOP = 0x60
- ETH_P_LOOPBACK = 0x9000
- ETH_P_MOBITEX = 0x15
- ETH_P_MPLS_MC = 0x8848
- ETH_P_MPLS_UC = 0x8847
- ETH_P_MVRP = 0x88f5
- ETH_P_PAE = 0x888e
- ETH_P_PAUSE = 0x8808
- ETH_P_PHONET = 0xf5
- ETH_P_PPPTALK = 0x10
- ETH_P_PPP_DISC = 0x8863
- ETH_P_PPP_MP = 0x8
- ETH_P_PPP_SES = 0x8864
- ETH_P_PRP = 0x88fb
- ETH_P_PUP = 0x200
- ETH_P_PUPAT = 0x201
- ETH_P_QINQ1 = 0x9100
- ETH_P_QINQ2 = 0x9200
- ETH_P_QINQ3 = 0x9300
- ETH_P_RARP = 0x8035
- ETH_P_SCA = 0x6007
- ETH_P_SLOW = 0x8809
- ETH_P_SNAP = 0x5
- ETH_P_TDLS = 0x890d
- ETH_P_TEB = 0x6558
- ETH_P_TIPC = 0x88ca
- ETH_P_TRAILER = 0x1c
- ETH_P_TR_802_2 = 0x11
- ETH_P_TSN = 0x22f0
- ETH_P_WAN_PPP = 0x7
- ETH_P_WCCP = 0x883e
- ETH_P_X25 = 0x805
- ETH_P_XDSA = 0xf8
- EXTA = 0xe
- EXTB = 0xf
- EXTPROC = 0x10000
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FLUSHO = 0x2000
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x406
- F_EXLCK = 0x4
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLEASE = 0x401
- F_GETLK = 0xe
- F_GETLK64 = 0xe
- F_GETOWN = 0x17
- F_GETOWN_EX = 0x10
- F_GETPIPE_SZ = 0x408
- F_GETSIG = 0xb
- F_LOCK = 0x1
- F_NOTIFY = 0x402
- F_OFD_GETLK = 0x24
- F_OFD_SETLK = 0x25
- F_OFD_SETLKW = 0x26
- F_OK = 0x0
- F_RDLCK = 0x0
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLEASE = 0x400
- F_SETLK = 0x6
- F_SETLK64 = 0x6
- F_SETLKW = 0x7
- F_SETLKW64 = 0x7
- F_SETOWN = 0x18
- F_SETOWN_EX = 0xf
- F_SETPIPE_SZ = 0x407
- F_SETSIG = 0xa
- F_SHLCK = 0x8
- F_TEST = 0x3
- F_TLOCK = 0x2
- F_ULOCK = 0x0
- F_UNLCK = 0x2
- F_WRLCK = 0x1
- HUPCL = 0x400
- ICANON = 0x2
- ICMPV6_FILTER = 0x1
- ICRNL = 0x100
- IEXTEN = 0x100
- IFA_F_DADFAILED = 0x8
- IFA_F_DEPRECATED = 0x20
- IFA_F_HOMEADDRESS = 0x10
- IFA_F_MANAGETEMPADDR = 0x100
- IFA_F_MCAUTOJOIN = 0x400
- IFA_F_NODAD = 0x2
- IFA_F_NOPREFIXROUTE = 0x200
- IFA_F_OPTIMISTIC = 0x4
- IFA_F_PERMANENT = 0x80
- IFA_F_SECONDARY = 0x1
- IFA_F_STABLE_PRIVACY = 0x800
- IFA_F_TEMPORARY = 0x1
- IFA_F_TENTATIVE = 0x40
- IFA_MAX = 0x8
- IFF_ALLMULTI = 0x200
- IFF_ATTACH_QUEUE = 0x200
- IFF_AUTOMEDIA = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_DETACH_QUEUE = 0x400
- IFF_DORMANT = 0x20000
- IFF_DYNAMIC = 0x8000
- IFF_ECHO = 0x40000
- IFF_LOOPBACK = 0x8
- IFF_LOWER_UP = 0x10000
- IFF_MASTER = 0x400
- IFF_MULTICAST = 0x1000
- IFF_MULTI_QUEUE = 0x100
- IFF_NOARP = 0x80
- IFF_NOFILTER = 0x1000
- IFF_NOTRAILERS = 0x20
- IFF_NO_PI = 0x1000
- IFF_ONE_QUEUE = 0x2000
- IFF_PERSIST = 0x800
- IFF_POINTOPOINT = 0x10
- IFF_PORTSEL = 0x2000
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SLAVE = 0x800
- IFF_TAP = 0x2
- IFF_TUN = 0x1
- IFF_TUN_EXCL = 0x8000
- IFF_UP = 0x1
- IFF_VNET_HDR = 0x4000
- IFF_VOLATILE = 0x70c5a
- IFNAMSIZ = 0x10
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_ACCESS = 0x1
- IN_ALL_EVENTS = 0xfff
- IN_ATTRIB = 0x4
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLOEXEC = 0x80000
- IN_CLOSE = 0x18
- IN_CLOSE_NOWRITE = 0x10
- IN_CLOSE_WRITE = 0x8
- IN_CREATE = 0x100
- IN_DELETE = 0x200
- IN_DELETE_SELF = 0x400
- IN_DONT_FOLLOW = 0x2000000
- IN_EXCL_UNLINK = 0x4000000
- IN_IGNORED = 0x8000
- IN_ISDIR = 0x40000000
- IN_LOOPBACKNET = 0x7f
- IN_MASK_ADD = 0x20000000
- IN_MODIFY = 0x2
- IN_MOVE = 0xc0
- IN_MOVED_FROM = 0x40
- IN_MOVED_TO = 0x80
- IN_MOVE_SELF = 0x800
- IN_NONBLOCK = 0x80
- IN_ONESHOT = 0x80000000
- IN_ONLYDIR = 0x1000000
- IN_OPEN = 0x20
- IN_Q_OVERFLOW = 0x4000
- IN_UNMOUNT = 0x2000
- IPPROTO_AH = 0x33
- IPPROTO_BEETPH = 0x5e
- IPPROTO_COMP = 0x6c
- IPPROTO_DCCP = 0x21
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_ENCAP = 0x62
- IPPROTO_ESP = 0x32
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GRE = 0x2f
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IGMP = 0x2
- IPPROTO_IP = 0x0
- IPPROTO_IPIP = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_MH = 0x87
- IPPROTO_MTP = 0x5c
- IPPROTO_NONE = 0x3b
- IPPROTO_PIM = 0x67
- IPPROTO_PUP = 0xc
- IPPROTO_RAW = 0xff
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_SCTP = 0x84
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_UDP = 0x11
- IPPROTO_UDPLITE = 0x88
- IPV6_2292DSTOPTS = 0x4
- IPV6_2292HOPLIMIT = 0x8
- IPV6_2292HOPOPTS = 0x3
- IPV6_2292PKTINFO = 0x2
- IPV6_2292PKTOPTIONS = 0x6
- IPV6_2292RTHDR = 0x5
- IPV6_ADDRFORM = 0x1
- IPV6_ADD_MEMBERSHIP = 0x14
- IPV6_AUTHHDR = 0xa
- IPV6_CHECKSUM = 0x7
- IPV6_DONTFRAG = 0x3e
- IPV6_DROP_MEMBERSHIP = 0x15
- IPV6_DSTOPTS = 0x3b
- IPV6_HOPLIMIT = 0x34
- IPV6_HOPOPTS = 0x36
- IPV6_IPSEC_POLICY = 0x22
- IPV6_JOIN_ANYCAST = 0x1b
- IPV6_JOIN_GROUP = 0x14
- IPV6_LEAVE_ANYCAST = 0x1c
- IPV6_LEAVE_GROUP = 0x15
- IPV6_MTU = 0x18
- IPV6_MTU_DISCOVER = 0x17
- IPV6_MULTICAST_HOPS = 0x12
- IPV6_MULTICAST_IF = 0x11
- IPV6_MULTICAST_LOOP = 0x13
- IPV6_NEXTHOP = 0x9
- IPV6_PATHMTU = 0x3d
- IPV6_PKTINFO = 0x32
- IPV6_PMTUDISC_DO = 0x2
- IPV6_PMTUDISC_DONT = 0x0
- IPV6_PMTUDISC_INTERFACE = 0x4
- IPV6_PMTUDISC_OMIT = 0x5
- IPV6_PMTUDISC_PROBE = 0x3
- IPV6_PMTUDISC_WANT = 0x1
- IPV6_RECVDSTOPTS = 0x3a
- IPV6_RECVERR = 0x19
- IPV6_RECVHOPLIMIT = 0x33
- IPV6_RECVHOPOPTS = 0x35
- IPV6_RECVPATHMTU = 0x3c
- IPV6_RECVPKTINFO = 0x31
- IPV6_RECVRTHDR = 0x38
- IPV6_RECVTCLASS = 0x42
- IPV6_ROUTER_ALERT = 0x16
- IPV6_RTHDR = 0x39
- IPV6_RTHDRDSTOPTS = 0x37
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_RXDSTOPTS = 0x3b
- IPV6_RXHOPOPTS = 0x36
- IPV6_TCLASS = 0x43
- IPV6_UNICAST_HOPS = 0x10
- IPV6_V6ONLY = 0x1a
- IPV6_XFRM_POLICY = 0x23
- IP_ADD_MEMBERSHIP = 0x23
- IP_ADD_SOURCE_MEMBERSHIP = 0x27
- IP_BLOCK_SOURCE = 0x26
- IP_CHECKSUM = 0x17
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0x24
- IP_DROP_SOURCE_MEMBERSHIP = 0x28
- IP_FREEBIND = 0xf
- IP_HDRINCL = 0x3
- IP_IPSEC_POLICY = 0x10
- IP_MAXPACKET = 0xffff
- IP_MAX_MEMBERSHIPS = 0x14
- IP_MF = 0x2000
- IP_MINTTL = 0x15
- IP_MSFILTER = 0x29
- IP_MSS = 0x240
- IP_MTU = 0xe
- IP_MTU_DISCOVER = 0xa
- IP_MULTICAST_ALL = 0x31
- IP_MULTICAST_IF = 0x20
- IP_MULTICAST_LOOP = 0x22
- IP_MULTICAST_TTL = 0x21
- IP_NODEFRAG = 0x16
- IP_OFFMASK = 0x1fff
- IP_OPTIONS = 0x4
- IP_ORIGDSTADDR = 0x14
- IP_PASSSEC = 0x12
- IP_PKTINFO = 0x8
- IP_PKTOPTIONS = 0x9
- IP_PMTUDISC = 0xa
- IP_PMTUDISC_DO = 0x2
- IP_PMTUDISC_DONT = 0x0
- IP_PMTUDISC_INTERFACE = 0x4
- IP_PMTUDISC_OMIT = 0x5
- IP_PMTUDISC_PROBE = 0x3
- IP_PMTUDISC_WANT = 0x1
- IP_RECVERR = 0xb
- IP_RECVOPTS = 0x6
- IP_RECVORIGDSTADDR = 0x14
- IP_RECVRETOPTS = 0x7
- IP_RECVTOS = 0xd
- IP_RECVTTL = 0xc
- IP_RETOPTS = 0x7
- IP_RF = 0x8000
- IP_ROUTER_ALERT = 0x5
- IP_TOS = 0x1
- IP_TRANSPARENT = 0x13
- IP_TTL = 0x2
- IP_UNBLOCK_SOURCE = 0x25
- IP_UNICAST_IF = 0x32
- IP_XFRM_POLICY = 0x11
- ISIG = 0x1
- ISTRIP = 0x20
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x1000
- IXON = 0x400
- LINUX_REBOOT_CMD_CAD_OFF = 0x0
- LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
- LINUX_REBOOT_CMD_HALT = 0xcdef0123
- LINUX_REBOOT_CMD_KEXEC = 0x45584543
- LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
- LINUX_REBOOT_CMD_RESTART = 0x1234567
- LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
- LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
- LINUX_REBOOT_MAGIC1 = 0xfee1dead
- LINUX_REBOOT_MAGIC2 = 0x28121969
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_DODUMP = 0x11
- MADV_DOFORK = 0xb
- MADV_DONTDUMP = 0x10
- MADV_DONTFORK = 0xa
- MADV_DONTNEED = 0x4
- MADV_HUGEPAGE = 0xe
- MADV_HWPOISON = 0x64
- MADV_MERGEABLE = 0xc
- MADV_NOHUGEPAGE = 0xf
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_REMOVE = 0x9
- MADV_SEQUENTIAL = 0x2
- MADV_UNMERGEABLE = 0xd
- MADV_WILLNEED = 0x3
- MAP_ANON = 0x800
- MAP_ANONYMOUS = 0x800
- MAP_DENYWRITE = 0x2000
- MAP_EXECUTABLE = 0x4000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_GROWSDOWN = 0x1000
- MAP_HUGETLB = 0x80000
- MAP_HUGE_MASK = 0x3f
- MAP_HUGE_SHIFT = 0x1a
- MAP_LOCKED = 0x8000
- MAP_NONBLOCK = 0x20000
- MAP_NORESERVE = 0x400
- MAP_POPULATE = 0x10000
- MAP_PRIVATE = 0x2
- MAP_RENAME = 0x800
- MAP_SHARED = 0x1
- MAP_STACK = 0x40000
- MAP_TYPE = 0xf
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MNT_DETACH = 0x2
- MNT_EXPIRE = 0x4
- MNT_FORCE = 0x1
- MSG_CMSG_CLOEXEC = 0x40000000
- MSG_CONFIRM = 0x800
- MSG_CTRUNC = 0x8
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x40
- MSG_EOR = 0x80
- MSG_ERRQUEUE = 0x2000
- MSG_FASTOPEN = 0x20000000
- MSG_FIN = 0x200
- MSG_MORE = 0x8000
- MSG_NOSIGNAL = 0x4000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_PROXY = 0x10
- MSG_RST = 0x1000
- MSG_SYN = 0x400
- MSG_TRUNC = 0x20
- MSG_TRYHARD = 0x4
- MSG_WAITALL = 0x100
- MSG_WAITFORONE = 0x10000
- MS_ACTIVE = 0x40000000
- MS_ASYNC = 0x1
- MS_BIND = 0x1000
- MS_DIRSYNC = 0x80
- MS_INVALIDATE = 0x2
- MS_I_VERSION = 0x800000
- MS_KERNMOUNT = 0x400000
- MS_LAZYTIME = 0x2000000
- MS_MANDLOCK = 0x40
- MS_MGC_MSK = 0xffff0000
- MS_MGC_VAL = 0xc0ed0000
- MS_MOVE = 0x2000
- MS_NOATIME = 0x400
- MS_NODEV = 0x4
- MS_NODIRATIME = 0x800
- MS_NOEXEC = 0x8
- MS_NOSUID = 0x2
- MS_NOUSER = -0x80000000
- MS_POSIXACL = 0x10000
- MS_PRIVATE = 0x40000
- MS_RDONLY = 0x1
- MS_REC = 0x4000
- MS_RELATIME = 0x200000
- MS_REMOUNT = 0x20
- MS_RMT_MASK = 0x2800051
- MS_SHARED = 0x100000
- MS_SILENT = 0x8000
- MS_SLAVE = 0x80000
- MS_STRICTATIME = 0x1000000
- MS_SYNC = 0x4
- MS_SYNCHRONOUS = 0x10
- MS_UNBINDABLE = 0x20000
- NAME_MAX = 0xff
- NETLINK_ADD_MEMBERSHIP = 0x1
- NETLINK_AUDIT = 0x9
- NETLINK_BROADCAST_ERROR = 0x4
- NETLINK_CAP_ACK = 0xa
- NETLINK_CONNECTOR = 0xb
- NETLINK_CRYPTO = 0x15
- NETLINK_DNRTMSG = 0xe
- NETLINK_DROP_MEMBERSHIP = 0x2
- NETLINK_ECRYPTFS = 0x13
- NETLINK_FIB_LOOKUP = 0xa
- NETLINK_FIREWALL = 0x3
- NETLINK_GENERIC = 0x10
- NETLINK_INET_DIAG = 0x4
- NETLINK_IP6_FW = 0xd
- NETLINK_ISCSI = 0x8
- NETLINK_KOBJECT_UEVENT = 0xf
- NETLINK_LISTEN_ALL_NSID = 0x8
- NETLINK_LIST_MEMBERSHIPS = 0x9
- NETLINK_NETFILTER = 0xc
- NETLINK_NFLOG = 0x5
- NETLINK_NO_ENOBUFS = 0x5
- NETLINK_PKTINFO = 0x3
- NETLINK_RDMA = 0x14
- NETLINK_ROUTE = 0x0
- NETLINK_RX_RING = 0x6
- NETLINK_SCSITRANSPORT = 0x12
- NETLINK_SELINUX = 0x7
- NETLINK_SOCK_DIAG = 0x4
- NETLINK_TX_RING = 0x7
- NETLINK_UNUSED = 0x1
- NETLINK_USERSOCK = 0x2
- NETLINK_XFRM = 0x6
- NLA_ALIGNTO = 0x4
- NLA_F_NESTED = 0x8000
- NLA_F_NET_BYTEORDER = 0x4000
- NLA_HDRLEN = 0x4
- NLMSG_ALIGNTO = 0x4
- NLMSG_DONE = 0x3
- NLMSG_ERROR = 0x2
- NLMSG_HDRLEN = 0x10
- NLMSG_MIN_TYPE = 0x10
- NLMSG_NOOP = 0x1
- NLMSG_OVERRUN = 0x4
- NLM_F_ACK = 0x4
- NLM_F_APPEND = 0x800
- NLM_F_ATOMIC = 0x400
- NLM_F_CREATE = 0x400
- NLM_F_DUMP = 0x300
- NLM_F_DUMP_INTR = 0x10
- NLM_F_ECHO = 0x8
- NLM_F_EXCL = 0x200
- NLM_F_MATCH = 0x200
- NLM_F_MULTI = 0x2
- NLM_F_REPLACE = 0x100
- NLM_F_REQUEST = 0x1
- NLM_F_ROOT = 0x100
- NOFLSH = 0x80
- OCRNL = 0x8
- OFDEL = 0x80
- OFILL = 0x40
- ONLCR = 0x4
- ONLRET = 0x20
- ONOCR = 0x10
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x8
- O_ASYNC = 0x1000
- O_CLOEXEC = 0x80000
- O_CREAT = 0x100
- O_DIRECT = 0x8000
- O_DIRECTORY = 0x10000
- O_DSYNC = 0x10
- O_EXCL = 0x400
- O_FSYNC = 0x4010
- O_LARGEFILE = 0x0
- O_NDELAY = 0x80
- O_NOATIME = 0x40000
- O_NOCTTY = 0x800
- O_NOFOLLOW = 0x20000
- O_NONBLOCK = 0x80
- O_PATH = 0x200000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_RSYNC = 0x4010
- O_SYNC = 0x4010
- O_TMPFILE = 0x410000
- O_TRUNC = 0x200
- O_WRONLY = 0x1
- PACKET_ADD_MEMBERSHIP = 0x1
- PACKET_AUXDATA = 0x8
- PACKET_BROADCAST = 0x1
- PACKET_COPY_THRESH = 0x7
- PACKET_DROP_MEMBERSHIP = 0x2
- PACKET_FANOUT = 0x12
- PACKET_FANOUT_CBPF = 0x6
- PACKET_FANOUT_CPU = 0x2
- PACKET_FANOUT_DATA = 0x16
- PACKET_FANOUT_EBPF = 0x7
- PACKET_FANOUT_FLAG_DEFRAG = 0x8000
- PACKET_FANOUT_FLAG_ROLLOVER = 0x1000
- PACKET_FANOUT_HASH = 0x0
- PACKET_FANOUT_LB = 0x1
- PACKET_FANOUT_QM = 0x5
- PACKET_FANOUT_RND = 0x4
- PACKET_FANOUT_ROLLOVER = 0x3
- PACKET_FASTROUTE = 0x6
- PACKET_HDRLEN = 0xb
- PACKET_HOST = 0x0
- PACKET_KERNEL = 0x7
- PACKET_LOOPBACK = 0x5
- PACKET_LOSS = 0xe
- PACKET_MR_ALLMULTI = 0x2
- PACKET_MR_MULTICAST = 0x0
- PACKET_MR_PROMISC = 0x1
- PACKET_MR_UNICAST = 0x3
- PACKET_MULTICAST = 0x2
- PACKET_ORIGDEV = 0x9
- PACKET_OTHERHOST = 0x3
- PACKET_OUTGOING = 0x4
- PACKET_QDISC_BYPASS = 0x14
- PACKET_RECV_OUTPUT = 0x3
- PACKET_RESERVE = 0xc
- PACKET_ROLLOVER_STATS = 0x15
- PACKET_RX_RING = 0x5
- PACKET_STATISTICS = 0x6
- PACKET_TIMESTAMP = 0x11
- PACKET_TX_HAS_OFF = 0x13
- PACKET_TX_RING = 0xd
- PACKET_TX_TIMESTAMP = 0x10
- PACKET_USER = 0x6
- PACKET_VERSION = 0xa
- PACKET_VNET_HDR = 0xf
- PARENB = 0x100
- PARITY_CRC16_PR0 = 0x2
- PARITY_CRC16_PR0_CCITT = 0x4
- PARITY_CRC16_PR1 = 0x3
- PARITY_CRC16_PR1_CCITT = 0x5
- PARITY_CRC32_PR0_CCITT = 0x6
- PARITY_CRC32_PR1_CCITT = 0x7
- PARITY_DEFAULT = 0x0
- PARITY_NONE = 0x1
- PARMRK = 0x8
- PARODD = 0x200
- PENDIN = 0x4000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_GROWSDOWN = 0x1000000
- PROT_GROWSUP = 0x2000000
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- PR_CAPBSET_DROP = 0x18
- PR_CAPBSET_READ = 0x17
- PR_CAP_AMBIENT = 0x2f
- PR_CAP_AMBIENT_CLEAR_ALL = 0x4
- PR_CAP_AMBIENT_IS_SET = 0x1
- PR_CAP_AMBIENT_LOWER = 0x3
- PR_CAP_AMBIENT_RAISE = 0x2
- PR_ENDIAN_BIG = 0x0
- PR_ENDIAN_LITTLE = 0x1
- PR_ENDIAN_PPC_LITTLE = 0x2
- PR_FPEMU_NOPRINT = 0x1
- PR_FPEMU_SIGFPE = 0x2
- PR_FP_EXC_ASYNC = 0x2
- PR_FP_EXC_DISABLED = 0x0
- PR_FP_EXC_DIV = 0x10000
- PR_FP_EXC_INV = 0x100000
- PR_FP_EXC_NONRECOV = 0x1
- PR_FP_EXC_OVF = 0x20000
- PR_FP_EXC_PRECISE = 0x3
- PR_FP_EXC_RES = 0x80000
- PR_FP_EXC_SW_ENABLE = 0x80
- PR_FP_EXC_UND = 0x40000
- PR_FP_MODE_FR = 0x1
- PR_FP_MODE_FRE = 0x2
- PR_GET_CHILD_SUBREAPER = 0x25
- PR_GET_DUMPABLE = 0x3
- PR_GET_ENDIAN = 0x13
- PR_GET_FPEMU = 0x9
- PR_GET_FPEXC = 0xb
- PR_GET_FP_MODE = 0x2e
- PR_GET_KEEPCAPS = 0x7
- PR_GET_NAME = 0x10
- PR_GET_NO_NEW_PRIVS = 0x27
- PR_GET_PDEATHSIG = 0x2
- PR_GET_SECCOMP = 0x15
- PR_GET_SECUREBITS = 0x1b
- PR_GET_THP_DISABLE = 0x2a
- PR_GET_TID_ADDRESS = 0x28
- PR_GET_TIMERSLACK = 0x1e
- PR_GET_TIMING = 0xd
- PR_GET_TSC = 0x19
- PR_GET_UNALIGN = 0x5
- PR_MCE_KILL = 0x21
- PR_MCE_KILL_CLEAR = 0x0
- PR_MCE_KILL_DEFAULT = 0x2
- PR_MCE_KILL_EARLY = 0x1
- PR_MCE_KILL_GET = 0x22
- PR_MCE_KILL_LATE = 0x0
- PR_MCE_KILL_SET = 0x1
- PR_MPX_DISABLE_MANAGEMENT = 0x2c
- PR_MPX_ENABLE_MANAGEMENT = 0x2b
- PR_SET_CHILD_SUBREAPER = 0x24
- PR_SET_DUMPABLE = 0x4
- PR_SET_ENDIAN = 0x14
- PR_SET_FPEMU = 0xa
- PR_SET_FPEXC = 0xc
- PR_SET_FP_MODE = 0x2d
- PR_SET_KEEPCAPS = 0x8
- PR_SET_MM = 0x23
- PR_SET_MM_ARG_END = 0x9
- PR_SET_MM_ARG_START = 0x8
- PR_SET_MM_AUXV = 0xc
- PR_SET_MM_BRK = 0x7
- PR_SET_MM_END_CODE = 0x2
- PR_SET_MM_END_DATA = 0x4
- PR_SET_MM_ENV_END = 0xb
- PR_SET_MM_ENV_START = 0xa
- PR_SET_MM_EXE_FILE = 0xd
- PR_SET_MM_MAP = 0xe
- PR_SET_MM_MAP_SIZE = 0xf
- PR_SET_MM_START_BRK = 0x6
- PR_SET_MM_START_CODE = 0x1
- PR_SET_MM_START_DATA = 0x3
- PR_SET_MM_START_STACK = 0x5
- PR_SET_NAME = 0xf
- PR_SET_NO_NEW_PRIVS = 0x26
- PR_SET_PDEATHSIG = 0x1
- PR_SET_PTRACER = 0x59616d61
- PR_SET_PTRACER_ANY = -0x1
- PR_SET_SECCOMP = 0x16
- PR_SET_SECUREBITS = 0x1c
- PR_SET_THP_DISABLE = 0x29
- PR_SET_TIMERSLACK = 0x1d
- PR_SET_TIMING = 0xe
- PR_SET_TSC = 0x1a
- PR_SET_UNALIGN = 0x6
- PR_TASK_PERF_EVENTS_DISABLE = 0x1f
- PR_TASK_PERF_EVENTS_ENABLE = 0x20
- PR_TIMING_STATISTICAL = 0x0
- PR_TIMING_TIMESTAMP = 0x1
- PR_TSC_ENABLE = 0x1
- PR_TSC_SIGSEGV = 0x2
- PR_UNALIGN_NOPRINT = 0x1
- PR_UNALIGN_SIGBUS = 0x2
- PTRACE_ATTACH = 0x10
- PTRACE_CONT = 0x7
- PTRACE_DETACH = 0x11
- PTRACE_EVENT_CLONE = 0x3
- PTRACE_EVENT_EXEC = 0x4
- PTRACE_EVENT_EXIT = 0x6
- PTRACE_EVENT_FORK = 0x1
- PTRACE_EVENT_SECCOMP = 0x7
- PTRACE_EVENT_STOP = 0x80
- PTRACE_EVENT_VFORK = 0x2
- PTRACE_EVENT_VFORK_DONE = 0x5
- PTRACE_GETEVENTMSG = 0x4201
- PTRACE_GETFPREGS = 0xe
- PTRACE_GETREGS = 0xc
- PTRACE_GETREGSET = 0x4204
- PTRACE_GETSIGINFO = 0x4202
- PTRACE_GETSIGMASK = 0x420a
- PTRACE_GET_THREAD_AREA = 0x19
- PTRACE_GET_THREAD_AREA_3264 = 0xc4
- PTRACE_GET_WATCH_REGS = 0xd0
- PTRACE_INTERRUPT = 0x4207
- PTRACE_KILL = 0x8
- PTRACE_LISTEN = 0x4208
- PTRACE_OLDSETOPTIONS = 0x15
- PTRACE_O_EXITKILL = 0x100000
- PTRACE_O_MASK = 0x3000ff
- PTRACE_O_SUSPEND_SECCOMP = 0x200000
- PTRACE_O_TRACECLONE = 0x8
- PTRACE_O_TRACEEXEC = 0x10
- PTRACE_O_TRACEEXIT = 0x40
- PTRACE_O_TRACEFORK = 0x2
- PTRACE_O_TRACESECCOMP = 0x80
- PTRACE_O_TRACESYSGOOD = 0x1
- PTRACE_O_TRACEVFORK = 0x4
- PTRACE_O_TRACEVFORKDONE = 0x20
- PTRACE_PEEKDATA = 0x2
- PTRACE_PEEKDATA_3264 = 0xc1
- PTRACE_PEEKSIGINFO = 0x4209
- PTRACE_PEEKSIGINFO_SHARED = 0x1
- PTRACE_PEEKTEXT = 0x1
- PTRACE_PEEKTEXT_3264 = 0xc0
- PTRACE_PEEKUSR = 0x3
- PTRACE_POKEDATA = 0x5
- PTRACE_POKEDATA_3264 = 0xc3
- PTRACE_POKETEXT = 0x4
- PTRACE_POKETEXT_3264 = 0xc2
- PTRACE_POKEUSR = 0x6
- PTRACE_SEIZE = 0x4206
- PTRACE_SETFPREGS = 0xf
- PTRACE_SETOPTIONS = 0x4200
- PTRACE_SETREGS = 0xd
- PTRACE_SETREGSET = 0x4205
- PTRACE_SETSIGINFO = 0x4203
- PTRACE_SETSIGMASK = 0x420b
- PTRACE_SET_THREAD_AREA = 0x1a
- PTRACE_SET_WATCH_REGS = 0xd1
- PTRACE_SINGLESTEP = 0x9
- PTRACE_SYSCALL = 0x18
- PTRACE_TRACEME = 0x0
- RLIMIT_AS = 0x6
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x5
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = -0x1
- RTAX_ADVMSS = 0x8
- RTAX_CC_ALGO = 0x10
- RTAX_CWND = 0x7
- RTAX_FEATURES = 0xc
- RTAX_FEATURE_ALLFRAG = 0x8
- RTAX_FEATURE_ECN = 0x1
- RTAX_FEATURE_MASK = 0xf
- RTAX_FEATURE_SACK = 0x2
- RTAX_FEATURE_TIMESTAMP = 0x4
- RTAX_HOPLIMIT = 0xa
- RTAX_INITCWND = 0xb
- RTAX_INITRWND = 0xe
- RTAX_LOCK = 0x1
- RTAX_MAX = 0x10
- RTAX_MTU = 0x2
- RTAX_QUICKACK = 0xf
- RTAX_REORDERING = 0x9
- RTAX_RTO_MIN = 0xd
- RTAX_RTT = 0x4
- RTAX_RTTVAR = 0x5
- RTAX_SSTHRESH = 0x6
- RTAX_UNSPEC = 0x0
- RTAX_WINDOW = 0x3
- RTA_ALIGNTO = 0x4
- RTA_MAX = 0x16
- RTCF_DIRECTSRC = 0x4000000
- RTCF_DOREDIRECT = 0x1000000
- RTCF_LOG = 0x2000000
- RTCF_MASQ = 0x400000
- RTCF_NAT = 0x800000
- RTCF_VALVE = 0x200000
- RTF_ADDRCLASSMASK = 0xf8000000
- RTF_ADDRCONF = 0x40000
- RTF_ALLONLINK = 0x20000
- RTF_BROADCAST = 0x10000000
- RTF_CACHE = 0x1000000
- RTF_DEFAULT = 0x10000
- RTF_DYNAMIC = 0x10
- RTF_FLOW = 0x2000000
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_INTERFACE = 0x40000000
- RTF_IRTT = 0x100
- RTF_LINKRT = 0x100000
- RTF_LOCAL = 0x80000000
- RTF_MODIFIED = 0x20
- RTF_MSS = 0x40
- RTF_MTU = 0x40
- RTF_MULTICAST = 0x20000000
- RTF_NAT = 0x8000000
- RTF_NOFORWARD = 0x1000
- RTF_NONEXTHOP = 0x200000
- RTF_NOPMTUDISC = 0x4000
- RTF_POLICY = 0x4000000
- RTF_REINSTATE = 0x8
- RTF_REJECT = 0x200
- RTF_STATIC = 0x400
- RTF_THROW = 0x2000
- RTF_UP = 0x1
- RTF_WINDOW = 0x80
- RTF_XRESOLVE = 0x800
- RTM_BASE = 0x10
- RTM_DELACTION = 0x31
- RTM_DELADDR = 0x15
- RTM_DELADDRLABEL = 0x49
- RTM_DELLINK = 0x11
- RTM_DELMDB = 0x55
- RTM_DELNEIGH = 0x1d
- RTM_DELNSID = 0x59
- RTM_DELQDISC = 0x25
- RTM_DELROUTE = 0x19
- RTM_DELRULE = 0x21
- RTM_DELTCLASS = 0x29
- RTM_DELTFILTER = 0x2d
- RTM_F_CLONED = 0x200
- RTM_F_EQUALIZE = 0x400
- RTM_F_NOTIFY = 0x100
- RTM_F_PREFIX = 0x800
- RTM_GETACTION = 0x32
- RTM_GETADDR = 0x16
- RTM_GETADDRLABEL = 0x4a
- RTM_GETANYCAST = 0x3e
- RTM_GETDCB = 0x4e
- RTM_GETLINK = 0x12
- RTM_GETMDB = 0x56
- RTM_GETMULTICAST = 0x3a
- RTM_GETNEIGH = 0x1e
- RTM_GETNEIGHTBL = 0x42
- RTM_GETNETCONF = 0x52
- RTM_GETNSID = 0x5a
- RTM_GETQDISC = 0x26
- RTM_GETROUTE = 0x1a
- RTM_GETRULE = 0x22
- RTM_GETTCLASS = 0x2a
- RTM_GETTFILTER = 0x2e
- RTM_MAX = 0x5b
- RTM_NEWACTION = 0x30
- RTM_NEWADDR = 0x14
- RTM_NEWADDRLABEL = 0x48
- RTM_NEWLINK = 0x10
- RTM_NEWMDB = 0x54
- RTM_NEWNDUSEROPT = 0x44
- RTM_NEWNEIGH = 0x1c
- RTM_NEWNEIGHTBL = 0x40
- RTM_NEWNETCONF = 0x50
- RTM_NEWNSID = 0x58
- RTM_NEWPREFIX = 0x34
- RTM_NEWQDISC = 0x24
- RTM_NEWROUTE = 0x18
- RTM_NEWRULE = 0x20
- RTM_NEWTCLASS = 0x28
- RTM_NEWTFILTER = 0x2c
- RTM_NR_FAMILIES = 0x13
- RTM_NR_MSGTYPES = 0x4c
- RTM_SETDCB = 0x4f
- RTM_SETLINK = 0x13
- RTM_SETNEIGHTBL = 0x43
- RTNH_ALIGNTO = 0x4
- RTNH_COMPARE_MASK = 0x11
- RTNH_F_DEAD = 0x1
- RTNH_F_LINKDOWN = 0x10
- RTNH_F_OFFLOAD = 0x8
- RTNH_F_ONLINK = 0x4
- RTNH_F_PERVASIVE = 0x2
- RTN_MAX = 0xb
- RTPROT_BABEL = 0x2a
- RTPROT_BIRD = 0xc
- RTPROT_BOOT = 0x3
- RTPROT_DHCP = 0x10
- RTPROT_DNROUTED = 0xd
- RTPROT_GATED = 0x8
- RTPROT_KERNEL = 0x2
- RTPROT_MROUTED = 0x11
- RTPROT_MRT = 0xa
- RTPROT_NTK = 0xf
- RTPROT_RA = 0x9
- RTPROT_REDIRECT = 0x1
- RTPROT_STATIC = 0x4
- RTPROT_UNSPEC = 0x0
- RTPROT_XORP = 0xe
- RTPROT_ZEBRA = 0xb
- RT_CLASS_DEFAULT = 0xfd
- RT_CLASS_LOCAL = 0xff
- RT_CLASS_MAIN = 0xfe
- RT_CLASS_MAX = 0xff
- RT_CLASS_UNSPEC = 0x0
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- RUSAGE_THREAD = 0x1
- SCM_CREDENTIALS = 0x2
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x1d
- SCM_TIMESTAMPING = 0x25
- SCM_TIMESTAMPNS = 0x23
- SCM_WIFI_STATUS = 0x29
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDDLCI = 0x8980
- SIOCADDMULTI = 0x8931
- SIOCADDRT = 0x890b
- SIOCATMARK = 0x40047307
- SIOCDARP = 0x8953
- SIOCDELDLCI = 0x8981
- SIOCDELMULTI = 0x8932
- SIOCDELRT = 0x890c
- SIOCDEVPRIVATE = 0x89f0
- SIOCDIFADDR = 0x8936
- SIOCDRARP = 0x8960
- SIOCGARP = 0x8954
- SIOCGIFADDR = 0x8915
- SIOCGIFBR = 0x8940
- SIOCGIFBRDADDR = 0x8919
- SIOCGIFCONF = 0x8912
- SIOCGIFCOUNT = 0x8938
- SIOCGIFDSTADDR = 0x8917
- SIOCGIFENCAP = 0x8925
- SIOCGIFFLAGS = 0x8913
- SIOCGIFHWADDR = 0x8927
- SIOCGIFINDEX = 0x8933
- SIOCGIFMAP = 0x8970
- SIOCGIFMEM = 0x891f
- SIOCGIFMETRIC = 0x891d
- SIOCGIFMTU = 0x8921
- SIOCGIFNAME = 0x8910
- SIOCGIFNETMASK = 0x891b
- SIOCGIFPFLAGS = 0x8935
- SIOCGIFSLAVE = 0x8929
- SIOCGIFTXQLEN = 0x8942
- SIOCGPGRP = 0x40047309
- SIOCGRARP = 0x8961
- SIOCGSTAMP = 0x8906
- SIOCGSTAMPNS = 0x8907
- SIOCPROTOPRIVATE = 0x89e0
- SIOCRTMSG = 0x890d
- SIOCSARP = 0x8955
- SIOCSIFADDR = 0x8916
- SIOCSIFBR = 0x8941
- SIOCSIFBRDADDR = 0x891a
- SIOCSIFDSTADDR = 0x8918
- SIOCSIFENCAP = 0x8926
- SIOCSIFFLAGS = 0x8914
- SIOCSIFHWADDR = 0x8924
- SIOCSIFHWBROADCAST = 0x8937
- SIOCSIFLINK = 0x8911
- SIOCSIFMAP = 0x8971
- SIOCSIFMEM = 0x8920
- SIOCSIFMETRIC = 0x891e
- SIOCSIFMTU = 0x8922
- SIOCSIFNAME = 0x8923
- SIOCSIFNETMASK = 0x891c
- SIOCSIFPFLAGS = 0x8934
- SIOCSIFSLAVE = 0x8930
- SIOCSIFTXQLEN = 0x8943
- SIOCSPGRP = 0x80047308
- SIOCSRARP = 0x8962
- SOCK_CLOEXEC = 0x80000
- SOCK_DCCP = 0x6
- SOCK_DGRAM = 0x1
- SOCK_NONBLOCK = 0x80
- SOCK_PACKET = 0xa
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x2
- SOL_AAL = 0x109
- SOL_ATM = 0x108
- SOL_DECNET = 0x105
- SOL_ICMPV6 = 0x3a
- SOL_IP = 0x0
- SOL_IPV6 = 0x29
- SOL_IRDA = 0x10a
- SOL_PACKET = 0x107
- SOL_RAW = 0xff
- SOL_SOCKET = 0xffff
- SOL_TCP = 0x6
- SOL_X25 = 0x106
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x1009
- SO_ATTACH_BPF = 0x32
- SO_ATTACH_FILTER = 0x1a
- SO_BINDTODEVICE = 0x19
- SO_BPF_EXTENSIONS = 0x30
- SO_BROADCAST = 0x20
- SO_BSDCOMPAT = 0xe
- SO_BUSY_POLL = 0x2e
- SO_DEBUG = 0x1
- SO_DETACH_BPF = 0x1b
- SO_DETACH_FILTER = 0x1b
- SO_DOMAIN = 0x1029
- SO_DONTROUTE = 0x10
- SO_ERROR = 0x1007
- SO_GET_FILTER = 0x1a
- SO_INCOMING_CPU = 0x31
- SO_KEEPALIVE = 0x8
- SO_LINGER = 0x80
- SO_LOCK_FILTER = 0x2c
- SO_MARK = 0x24
- SO_MAX_PACING_RATE = 0x2f
- SO_NOFCS = 0x2b
- SO_NO_CHECK = 0xb
- SO_OOBINLINE = 0x100
- SO_PASSCRED = 0x11
- SO_PASSSEC = 0x22
- SO_PEEK_OFF = 0x2a
- SO_PEERCRED = 0x12
- SO_PEERNAME = 0x1c
- SO_PEERSEC = 0x1e
- SO_PRIORITY = 0xc
- SO_PROTOCOL = 0x1028
- SO_RCVBUF = 0x1002
- SO_RCVBUFFORCE = 0x21
- SO_RCVLOWAT = 0x1004
- SO_RCVTIMEO = 0x1006
- SO_REUSEADDR = 0x4
- SO_REUSEPORT = 0x200
- SO_RXQ_OVFL = 0x28
- SO_SECURITY_AUTHENTICATION = 0x16
- SO_SECURITY_ENCRYPTION_NETWORK = 0x18
- SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17
- SO_SELECT_ERR_QUEUE = 0x2d
- SO_SNDBUF = 0x1001
- SO_SNDBUFFORCE = 0x1f
- SO_SNDLOWAT = 0x1003
- SO_SNDTIMEO = 0x1005
- SO_STYLE = 0x1008
- SO_TIMESTAMP = 0x1d
- SO_TIMESTAMPING = 0x25
- SO_TIMESTAMPNS = 0x23
- SO_TYPE = 0x1008
- SO_WIFI_STATUS = 0x29
- S_BLKSIZE = 0x200
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TCFLSH = 0x5407
- TCIFLUSH = 0x0
- TCIOFLUSH = 0x2
- TCOFLUSH = 0x1
- TCP_CONGESTION = 0xd
- TCP_COOKIE_IN_ALWAYS = 0x1
- TCP_COOKIE_MAX = 0x10
- TCP_COOKIE_MIN = 0x8
- TCP_COOKIE_OUT_NEVER = 0x2
- TCP_COOKIE_PAIR_SIZE = 0x20
- TCP_COOKIE_TRANSACTIONS = 0xf
- TCP_CORK = 0x3
- TCP_DEFER_ACCEPT = 0x9
- TCP_FASTOPEN = 0x17
- TCP_INFO = 0xb
- TCP_KEEPCNT = 0x6
- TCP_KEEPIDLE = 0x4
- TCP_KEEPINTVL = 0x5
- TCP_LINGER2 = 0x8
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0xe
- TCP_MD5SIG_MAXKEYLEN = 0x50
- TCP_MSS = 0x200
- TCP_MSS_DEFAULT = 0x218
- TCP_MSS_DESIRED = 0x4c4
- TCP_NODELAY = 0x1
- TCP_QUEUE_SEQ = 0x15
- TCP_QUICKACK = 0xc
- TCP_REPAIR = 0x13
- TCP_REPAIR_OPTIONS = 0x16
- TCP_REPAIR_QUEUE = 0x14
- TCP_SYNCNT = 0x7
- TCP_S_DATA_IN = 0x4
- TCP_S_DATA_OUT = 0x8
- TCP_THIN_DUPACK = 0x11
- TCP_THIN_LINEAR_TIMEOUTS = 0x10
- TCP_TIMESTAMP = 0x18
- TCP_USER_TIMEOUT = 0x12
- TCP_WINDOW_CLAMP = 0xa
- TCSAFLUSH = 0x5410
- TCSBRK = 0x5405
- TCXONC = 0x5406
- TIOCCBRK = 0x5428
- TIOCCONS = 0x80047478
- TIOCEXCL = 0x740d
- TIOCGDEV = 0x40045432
- TIOCGETD = 0x7400
- TIOCGETP = 0x7408
- TIOCGEXCL = 0x40045440
- TIOCGICOUNT = 0x5492
- TIOCGLCKTRMIOS = 0x548b
- TIOCGLTC = 0x7474
- TIOCGPGRP = 0x40047477
- TIOCGPKT = 0x40045438
- TIOCGPTLCK = 0x40045439
- TIOCGPTN = 0x40045430
- TIOCGRS485 = 0x4020542e
- TIOCGSERIAL = 0x5484
- TIOCGSID = 0x7416
- TIOCGSOFTCAR = 0x5481
- TIOCGWINSZ = 0x40087468
- TIOCINQ = 0x467f
- TIOCLINUX = 0x5483
- TIOCMBIC = 0x741c
- TIOCMBIS = 0x741b
- TIOCMGET = 0x741d
- TIOCMIWAIT = 0x5491
- TIOCMSET = 0x741a
- TIOCM_CAR = 0x100
- TIOCM_CD = 0x100
- TIOCM_CTS = 0x40
- TIOCM_DSR = 0x400
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x200
- TIOCM_RNG = 0x200
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x20
- TIOCM_ST = 0x10
- TIOCNOTTY = 0x5471
- TIOCNXCL = 0x740e
- TIOCOUTQ = 0x7472
- TIOCPKT = 0x5470
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCSBRK = 0x5427
- TIOCSCTTY = 0x5480
- TIOCSERCONFIG = 0x5488
- TIOCSERGETLSR = 0x548e
- TIOCSERGETMULTI = 0x548f
- TIOCSERGSTRUCT = 0x548d
- TIOCSERGWILD = 0x5489
- TIOCSERSETMULTI = 0x5490
- TIOCSERSWILD = 0x548a
- TIOCSER_TEMT = 0x1
- TIOCSETD = 0x7401
- TIOCSETN = 0x740a
- TIOCSETP = 0x7409
- TIOCSIG = 0x80045436
- TIOCSLCKTRMIOS = 0x548c
- TIOCSLTC = 0x7475
- TIOCSPGRP = 0x80047476
- TIOCSPTLCK = 0x80045431
- TIOCSRS485 = 0xc020542f
- TIOCSSERIAL = 0x5485
- TIOCSSOFTCAR = 0x5482
- TIOCSTI = 0x5472
- TIOCSWINSZ = 0x80087467
- TIOCVHANGUP = 0x5437
- TOSTOP = 0x8000
- TUNATTACHFILTER = 0x801054d5
- TUNDETACHFILTER = 0x801054d6
- TUNGETFEATURES = 0x400454cf
- TUNGETFILTER = 0x401054db
- TUNGETIFF = 0x400454d2
- TUNGETSNDBUF = 0x400454d3
- TUNGETVNETBE = 0x400454df
- TUNGETVNETHDRSZ = 0x400454d7
- TUNGETVNETLE = 0x400454dd
- TUNSETDEBUG = 0x800454c9
- TUNSETGROUP = 0x800454ce
- TUNSETIFF = 0x800454ca
- TUNSETIFINDEX = 0x800454da
- TUNSETLINK = 0x800454cd
- TUNSETNOCSUM = 0x800454c8
- TUNSETOFFLOAD = 0x800454d0
- TUNSETOWNER = 0x800454cc
- TUNSETPERSIST = 0x800454cb
- TUNSETQUEUE = 0x800454d9
- TUNSETSNDBUF = 0x800454d4
- TUNSETTXFILTER = 0x800454d1
- TUNSETVNETBE = 0x800454de
- TUNSETVNETHDRSZ = 0x800454d8
- TUNSETVNETLE = 0x800454dc
- VDISCARD = 0xd
- VEOF = 0x10
- VEOL = 0x11
- VEOL2 = 0x6
- VERASE = 0x2
- VINTR = 0x0
- VKILL = 0x3
- VLNEXT = 0xf
- VMIN = 0x4
- VQUIT = 0x1
- VREPRINT = 0xc
- VSTART = 0x8
- VSTOP = 0x9
- VSUSP = 0xa
- VSWTC = 0x7
- VSWTCH = 0x7
- VT0 = 0x0
- VT1 = 0x4000
- VTDLY = 0x4000
- VTIME = 0x5
- VWERASE = 0xe
- WALL = 0x40000000
- WCLONE = 0x80000000
- WCONTINUED = 0x8
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOTHREAD = 0x20000000
- WNOWAIT = 0x1000000
- WORDSIZE = 0x40
- WSTOPPED = 0x2
- WUNTRACED = 0x2
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x7d)
- EADDRNOTAVAIL = syscall.Errno(0x7e)
- EADV = syscall.Errno(0x44)
- EAFNOSUPPORT = syscall.Errno(0x7c)
- EAGAIN = syscall.Errno(0xb)
- EALREADY = syscall.Errno(0x95)
- EBADE = syscall.Errno(0x32)
- EBADF = syscall.Errno(0x9)
- EBADFD = syscall.Errno(0x51)
- EBADMSG = syscall.Errno(0x4d)
- EBADR = syscall.Errno(0x33)
- EBADRQC = syscall.Errno(0x36)
- EBADSLT = syscall.Errno(0x37)
- EBFONT = syscall.Errno(0x3b)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x9e)
- ECHILD = syscall.Errno(0xa)
- ECHRNG = syscall.Errno(0x25)
- ECOMM = syscall.Errno(0x46)
- ECONNABORTED = syscall.Errno(0x82)
- ECONNREFUSED = syscall.Errno(0x92)
- ECONNRESET = syscall.Errno(0x83)
- EDEADLK = syscall.Errno(0x2d)
- EDEADLOCK = syscall.Errno(0x38)
- EDESTADDRREQ = syscall.Errno(0x60)
- EDOM = syscall.Errno(0x21)
- EDOTDOT = syscall.Errno(0x49)
- EDQUOT = syscall.Errno(0x46d)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EHOSTDOWN = syscall.Errno(0x93)
- EHOSTUNREACH = syscall.Errno(0x94)
- EHWPOISON = syscall.Errno(0xa8)
- EIDRM = syscall.Errno(0x24)
- EILSEQ = syscall.Errno(0x58)
- EINIT = syscall.Errno(0x8d)
- EINPROGRESS = syscall.Errno(0x96)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x85)
- EISDIR = syscall.Errno(0x15)
- EISNAM = syscall.Errno(0x8b)
- EKEYEXPIRED = syscall.Errno(0xa2)
- EKEYREJECTED = syscall.Errno(0xa4)
- EKEYREVOKED = syscall.Errno(0xa3)
- EL2HLT = syscall.Errno(0x2c)
- EL2NSYNC = syscall.Errno(0x26)
- EL3HLT = syscall.Errno(0x27)
- EL3RST = syscall.Errno(0x28)
- ELIBACC = syscall.Errno(0x53)
- ELIBBAD = syscall.Errno(0x54)
- ELIBEXEC = syscall.Errno(0x57)
- ELIBMAX = syscall.Errno(0x56)
- ELIBSCN = syscall.Errno(0x55)
- ELNRNG = syscall.Errno(0x29)
- ELOOP = syscall.Errno(0x5a)
- EMEDIUMTYPE = syscall.Errno(0xa0)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x61)
- EMULTIHOP = syscall.Errno(0x4a)
- ENAMETOOLONG = syscall.Errno(0x4e)
- ENAVAIL = syscall.Errno(0x8a)
- ENETDOWN = syscall.Errno(0x7f)
- ENETRESET = syscall.Errno(0x81)
- ENETUNREACH = syscall.Errno(0x80)
- ENFILE = syscall.Errno(0x17)
- ENOANO = syscall.Errno(0x35)
- ENOBUFS = syscall.Errno(0x84)
- ENOCSI = syscall.Errno(0x2b)
- ENODATA = syscall.Errno(0x3d)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOKEY = syscall.Errno(0xa1)
- ENOLCK = syscall.Errno(0x2e)
- ENOLINK = syscall.Errno(0x43)
- ENOMEDIUM = syscall.Errno(0x9f)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x23)
- ENONET = syscall.Errno(0x40)
- ENOPKG = syscall.Errno(0x41)
- ENOPROTOOPT = syscall.Errno(0x63)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x3f)
- ENOSTR = syscall.Errno(0x3c)
- ENOSYS = syscall.Errno(0x59)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x86)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x5d)
- ENOTNAM = syscall.Errno(0x89)
- ENOTRECOVERABLE = syscall.Errno(0xa6)
- ENOTSOCK = syscall.Errno(0x5f)
- ENOTSUP = syscall.Errno(0x7a)
- ENOTTY = syscall.Errno(0x19)
- ENOTUNIQ = syscall.Errno(0x50)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x7a)
- EOVERFLOW = syscall.Errno(0x4f)
- EOWNERDEAD = syscall.Errno(0xa5)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x7b)
- EPIPE = syscall.Errno(0x20)
- EPROTO = syscall.Errno(0x47)
- EPROTONOSUPPORT = syscall.Errno(0x78)
- EPROTOTYPE = syscall.Errno(0x62)
- ERANGE = syscall.Errno(0x22)
- EREMCHG = syscall.Errno(0x52)
- EREMDEV = syscall.Errno(0x8e)
- EREMOTE = syscall.Errno(0x42)
- EREMOTEIO = syscall.Errno(0x8c)
- ERESTART = syscall.Errno(0x5b)
- ERFKILL = syscall.Errno(0xa7)
- EROFS = syscall.Errno(0x1e)
- ESHUTDOWN = syscall.Errno(0x8f)
- ESOCKTNOSUPPORT = syscall.Errno(0x79)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESRMNT = syscall.Errno(0x45)
- ESTALE = syscall.Errno(0x97)
- ESTRPIPE = syscall.Errno(0x5c)
- ETIME = syscall.Errno(0x3e)
- ETIMEDOUT = syscall.Errno(0x91)
- ETOOMANYREFS = syscall.Errno(0x90)
- ETXTBSY = syscall.Errno(0x1a)
- EUCLEAN = syscall.Errno(0x87)
- EUNATCH = syscall.Errno(0x2a)
- EUSERS = syscall.Errno(0x5e)
- EWOULDBLOCK = syscall.Errno(0xb)
- EXDEV = syscall.Errno(0x12)
- EXFULL = syscall.Errno(0x34)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0xa)
- SIGCHLD = syscall.Signal(0x12)
- SIGCLD = syscall.Signal(0x12)
- SIGCONT = syscall.Signal(0x19)
- SIGEMT = syscall.Signal(0x7)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x16)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPOLL = syscall.Signal(0x16)
- SIGPROF = syscall.Signal(0x1d)
- SIGPWR = syscall.Signal(0x13)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTOP = syscall.Signal(0x17)
- SIGSYS = syscall.Signal(0xc)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x18)
- SIGTTIN = syscall.Signal(0x1a)
- SIGTTOU = syscall.Signal(0x1b)
- SIGURG = syscall.Signal(0x15)
- SIGUSR1 = syscall.Signal(0x10)
- SIGUSR2 = syscall.Signal(0x11)
- SIGVTALRM = syscall.Signal(0x1c)
- SIGWINCH = syscall.Signal(0x14)
- SIGXCPU = syscall.Signal(0x1e)
- SIGXFSZ = syscall.Signal(0x1f)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "no such device or address",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource temporarily unavailable",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device or resource busy",
- 17: "file exists",
- 18: "invalid cross-device link",
- 19: "no such device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "numerical result out of range",
- 35: "no message of desired type",
- 36: "identifier removed",
- 37: "channel number out of range",
- 38: "level 2 not synchronized",
- 39: "level 3 halted",
- 40: "level 3 reset",
- 41: "link number out of range",
- 42: "protocol driver not attached",
- 43: "no CSI structure available",
- 44: "level 2 halted",
- 45: "resource deadlock avoided",
- 46: "no locks available",
- 50: "invalid exchange",
- 51: "invalid request descriptor",
- 52: "exchange full",
- 53: "no anode",
- 54: "invalid request code",
- 55: "invalid slot",
- 56: "file locking deadlock error",
- 59: "bad font file format",
- 60: "device not a stream",
- 61: "no data available",
- 62: "timer expired",
- 63: "out of streams resources",
- 64: "machine is not on the network",
- 65: "package not installed",
- 66: "object is remote",
- 67: "link has been severed",
- 68: "advertise error",
- 69: "srmount error",
- 70: "communication error on send",
- 71: "protocol error",
- 73: "RFS specific error",
- 74: "multihop attempted",
- 77: "bad message",
- 78: "file name too long",
- 79: "value too large for defined data type",
- 80: "name not unique on network",
- 81: "file descriptor in bad state",
- 82: "remote address changed",
- 83: "can not access a needed shared library",
- 84: "accessing a corrupted shared library",
- 85: ".lib section in a.out corrupted",
- 86: "attempting to link in too many shared libraries",
- 87: "cannot exec a shared library directly",
- 88: "invalid or incomplete multibyte or wide character",
- 89: "function not implemented",
- 90: "too many levels of symbolic links",
- 91: "interrupted system call should be restarted",
- 92: "streams pipe error",
- 93: "directory not empty",
- 94: "too many users",
- 95: "socket operation on non-socket",
- 96: "destination address required",
- 97: "message too long",
- 98: "protocol wrong type for socket",
- 99: "protocol not available",
- 120: "protocol not supported",
- 121: "socket type not supported",
- 122: "operation not supported",
- 123: "protocol family not supported",
- 124: "address family not supported by protocol",
- 125: "address already in use",
- 126: "cannot assign requested address",
- 127: "network is down",
- 128: "network is unreachable",
- 129: "network dropped connection on reset",
- 130: "software caused connection abort",
- 131: "connection reset by peer",
- 132: "no buffer space available",
- 133: "transport endpoint is already connected",
- 134: "transport endpoint is not connected",
- 135: "structure needs cleaning",
- 137: "not a XENIX named type file",
- 138: "no XENIX semaphores available",
- 139: "is a named type file",
- 140: "remote I/O error",
- 141: "unknown error 141",
- 142: "unknown error 142",
- 143: "cannot send after transport endpoint shutdown",
- 144: "too many references: cannot splice",
- 145: "connection timed out",
- 146: "connection refused",
- 147: "host is down",
- 148: "no route to host",
- 149: "operation already in progress",
- 150: "operation now in progress",
- 151: "stale file handle",
- 158: "operation canceled",
- 159: "no medium found",
- 160: "wrong medium type",
- 161: "required key not available",
- 162: "key has expired",
- 163: "key has been revoked",
- 164: "key was rejected by service",
- 165: "owner died",
- 166: "state not recoverable",
- 167: "operation not possible due to RF-kill",
- 168: "memory page has hardware error",
- 1133: "disk quota exceeded",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/breakpoint trap",
- 6: "aborted",
- 7: "EMT trap",
- 8: "floating point exception",
- 9: "killed",
- 10: "bus error",
- 11: "segmentation fault",
- 12: "bad system call",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "user defined signal 1",
- 17: "user defined signal 2",
- 18: "child exited",
- 19: "power failure",
- 20: "window changed",
- 21: "urgent I/O condition",
- 22: "I/O possible",
- 23: "stopped (signal)",
- 24: "stopped",
- 25: "continued",
- 26: "stopped (tty input)",
- 27: "stopped (tty output)",
- 28: "virtual timer expired",
- 29: "profiling timer expired",
- 30: "CPU time limit exceeded",
- 31: "file size limit exceeded",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/newt/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
deleted file mode 100644
index 112f05de..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
+++ /dev/null
@@ -1,1917 +0,0 @@
-// mkerrors.sh
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build mips64le,linux
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_ALG = 0x26
- AF_APPLETALK = 0x5
- AF_ASH = 0x12
- AF_ATMPVC = 0x8
- AF_ATMSVC = 0x14
- AF_AX25 = 0x3
- AF_BLUETOOTH = 0x1f
- AF_BRIDGE = 0x7
- AF_CAIF = 0x25
- AF_CAN = 0x1d
- AF_DECnet = 0xc
- AF_ECONET = 0x13
- AF_FILE = 0x1
- AF_IB = 0x1b
- AF_IEEE802154 = 0x24
- AF_INET = 0x2
- AF_INET6 = 0xa
- AF_IPX = 0x4
- AF_IRDA = 0x17
- AF_ISDN = 0x22
- AF_IUCV = 0x20
- AF_KEY = 0xf
- AF_LLC = 0x1a
- AF_LOCAL = 0x1
- AF_MAX = 0x29
- AF_MPLS = 0x1c
- AF_NETBEUI = 0xd
- AF_NETLINK = 0x10
- AF_NETROM = 0x6
- AF_NFC = 0x27
- AF_PACKET = 0x11
- AF_PHONET = 0x23
- AF_PPPOX = 0x18
- AF_RDS = 0x15
- AF_ROSE = 0xb
- AF_ROUTE = 0x10
- AF_RXRPC = 0x21
- AF_SECURITY = 0xe
- AF_SNA = 0x16
- AF_TIPC = 0x1e
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_VSOCK = 0x28
- AF_WANPIPE = 0x19
- AF_X25 = 0x9
- ARPHRD_6LOWPAN = 0x339
- ARPHRD_ADAPT = 0x108
- ARPHRD_APPLETLK = 0x8
- ARPHRD_ARCNET = 0x7
- ARPHRD_ASH = 0x30d
- ARPHRD_ATM = 0x13
- ARPHRD_AX25 = 0x3
- ARPHRD_BIF = 0x307
- ARPHRD_CAIF = 0x336
- ARPHRD_CAN = 0x118
- ARPHRD_CHAOS = 0x5
- ARPHRD_CISCO = 0x201
- ARPHRD_CSLIP = 0x101
- ARPHRD_CSLIP6 = 0x103
- ARPHRD_DDCMP = 0x205
- ARPHRD_DLCI = 0xf
- ARPHRD_ECONET = 0x30e
- ARPHRD_EETHER = 0x2
- ARPHRD_ETHER = 0x1
- ARPHRD_EUI64 = 0x1b
- ARPHRD_FCAL = 0x311
- ARPHRD_FCFABRIC = 0x313
- ARPHRD_FCPL = 0x312
- ARPHRD_FCPP = 0x310
- ARPHRD_FDDI = 0x306
- ARPHRD_FRAD = 0x302
- ARPHRD_HDLC = 0x201
- ARPHRD_HIPPI = 0x30c
- ARPHRD_HWX25 = 0x110
- ARPHRD_IEEE1394 = 0x18
- ARPHRD_IEEE802 = 0x6
- ARPHRD_IEEE80211 = 0x321
- ARPHRD_IEEE80211_PRISM = 0x322
- ARPHRD_IEEE80211_RADIOTAP = 0x323
- ARPHRD_IEEE802154 = 0x324
- ARPHRD_IEEE802154_MONITOR = 0x325
- ARPHRD_IEEE802_TR = 0x320
- ARPHRD_INFINIBAND = 0x20
- ARPHRD_IP6GRE = 0x337
- ARPHRD_IPDDP = 0x309
- ARPHRD_IPGRE = 0x30a
- ARPHRD_IRDA = 0x30f
- ARPHRD_LAPB = 0x204
- ARPHRD_LOCALTLK = 0x305
- ARPHRD_LOOPBACK = 0x304
- ARPHRD_METRICOM = 0x17
- ARPHRD_NETLINK = 0x338
- ARPHRD_NETROM = 0x0
- ARPHRD_NONE = 0xfffe
- ARPHRD_PHONET = 0x334
- ARPHRD_PHONET_PIPE = 0x335
- ARPHRD_PIMREG = 0x30b
- ARPHRD_PPP = 0x200
- ARPHRD_PRONET = 0x4
- ARPHRD_RAWHDLC = 0x206
- ARPHRD_ROSE = 0x10e
- ARPHRD_RSRVD = 0x104
- ARPHRD_SIT = 0x308
- ARPHRD_SKIP = 0x303
- ARPHRD_SLIP = 0x100
- ARPHRD_SLIP6 = 0x102
- ARPHRD_TUNNEL = 0x300
- ARPHRD_TUNNEL6 = 0x301
- ARPHRD_VOID = 0xffff
- ARPHRD_X25 = 0x10f
- B0 = 0x0
- B1000000 = 0x1008
- B110 = 0x3
- B115200 = 0x1002
- B1152000 = 0x1009
- B1200 = 0x9
- B134 = 0x4
- B150 = 0x5
- B1500000 = 0x100a
- B1800 = 0xa
- B19200 = 0xe
- B200 = 0x6
- B2000000 = 0x100b
- B230400 = 0x1003
- B2400 = 0xb
- B2500000 = 0x100c
- B300 = 0x7
- B3000000 = 0x100d
- B3500000 = 0x100e
- B38400 = 0xf
- B4000000 = 0x100f
- B460800 = 0x1004
- B4800 = 0xc
- B50 = 0x1
- B500000 = 0x1005
- B57600 = 0x1001
- B576000 = 0x1006
- B600 = 0x8
- B75 = 0x2
- B921600 = 0x1007
- B9600 = 0xd
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LL_OFF = -0x200000
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXINSNS = 0x1000
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MOD = 0x90
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_NET_OFF = -0x100000
- BPF_OR = 0x40
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BPF_XOR = 0xa0
- BRKINT = 0x2
- CFLUSH = 0xf
- CLOCAL = 0x800
- CLOCK_BOOTTIME = 0x7
- CLOCK_BOOTTIME_ALARM = 0x9
- CLOCK_DEFAULT = 0x0
- CLOCK_EXT = 0x1
- CLOCK_INT = 0x2
- CLOCK_MONOTONIC = 0x1
- CLOCK_MONOTONIC_COARSE = 0x6
- CLOCK_MONOTONIC_RAW = 0x4
- CLOCK_PROCESS_CPUTIME_ID = 0x2
- CLOCK_REALTIME = 0x0
- CLOCK_REALTIME_ALARM = 0x8
- CLOCK_REALTIME_COARSE = 0x5
- CLOCK_TAI = 0xb
- CLOCK_THREAD_CPUTIME_ID = 0x3
- CLOCK_TXFROMRX = 0x4
- CLOCK_TXINT = 0x3
- CLONE_CHILD_CLEARTID = 0x200000
- CLONE_CHILD_SETTID = 0x1000000
- CLONE_DETACHED = 0x400000
- CLONE_FILES = 0x400
- CLONE_FS = 0x200
- CLONE_IO = 0x80000000
- CLONE_NEWCGROUP = 0x2000000
- CLONE_NEWIPC = 0x8000000
- CLONE_NEWNET = 0x40000000
- CLONE_NEWNS = 0x20000
- CLONE_NEWPID = 0x20000000
- CLONE_NEWUSER = 0x10000000
- CLONE_NEWUTS = 0x4000000
- CLONE_PARENT = 0x8000
- CLONE_PARENT_SETTID = 0x100000
- CLONE_PTRACE = 0x2000
- CLONE_SETTLS = 0x80000
- CLONE_SIGHAND = 0x800
- CLONE_SYSVSEM = 0x40000
- CLONE_THREAD = 0x10000
- CLONE_UNTRACED = 0x800000
- CLONE_VFORK = 0x4000
- CLONE_VM = 0x100
- CREAD = 0x80
- CS5 = 0x0
- CS6 = 0x10
- CS7 = 0x20
- CS8 = 0x30
- CSIGNAL = 0xff
- CSIZE = 0x30
- CSTART = 0x11
- CSTATUS = 0x0
- CSTOP = 0x13
- CSTOPB = 0x40
- CSUSP = 0x1a
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x200
- ECHOE = 0x10
- ECHOK = 0x20
- ECHOKE = 0x800
- ECHONL = 0x40
- ECHOPRT = 0x400
- ENCODING_DEFAULT = 0x0
- ENCODING_FM_MARK = 0x3
- ENCODING_FM_SPACE = 0x4
- ENCODING_MANCHESTER = 0x5
- ENCODING_NRZ = 0x1
- ENCODING_NRZI = 0x2
- EPOLLERR = 0x8
- EPOLLET = 0x80000000
- EPOLLHUP = 0x10
- EPOLLIN = 0x1
- EPOLLMSG = 0x400
- EPOLLONESHOT = 0x40000000
- EPOLLOUT = 0x4
- EPOLLPRI = 0x2
- EPOLLRDBAND = 0x80
- EPOLLRDHUP = 0x2000
- EPOLLRDNORM = 0x40
- EPOLLWAKEUP = 0x20000000
- EPOLLWRBAND = 0x200
- EPOLLWRNORM = 0x100
- EPOLL_CLOEXEC = 0x80000
- EPOLL_CTL_ADD = 0x1
- EPOLL_CTL_DEL = 0x2
- EPOLL_CTL_MOD = 0x3
- ETH_P_1588 = 0x88f7
- ETH_P_8021AD = 0x88a8
- ETH_P_8021AH = 0x88e7
- ETH_P_8021Q = 0x8100
- ETH_P_80221 = 0x8917
- ETH_P_802_2 = 0x4
- ETH_P_802_3 = 0x1
- ETH_P_802_3_MIN = 0x600
- ETH_P_802_EX1 = 0x88b5
- ETH_P_AARP = 0x80f3
- ETH_P_AF_IUCV = 0xfbfb
- ETH_P_ALL = 0x3
- ETH_P_AOE = 0x88a2
- ETH_P_ARCNET = 0x1a
- ETH_P_ARP = 0x806
- ETH_P_ATALK = 0x809b
- ETH_P_ATMFATE = 0x8884
- ETH_P_ATMMPOA = 0x884c
- ETH_P_AX25 = 0x2
- ETH_P_BATMAN = 0x4305
- ETH_P_BPQ = 0x8ff
- ETH_P_CAIF = 0xf7
- ETH_P_CAN = 0xc
- ETH_P_CANFD = 0xd
- ETH_P_CONTROL = 0x16
- ETH_P_CUST = 0x6006
- ETH_P_DDCMP = 0x6
- ETH_P_DEC = 0x6000
- ETH_P_DIAG = 0x6005
- ETH_P_DNA_DL = 0x6001
- ETH_P_DNA_RC = 0x6002
- ETH_P_DNA_RT = 0x6003
- ETH_P_DSA = 0x1b
- ETH_P_ECONET = 0x18
- ETH_P_EDSA = 0xdada
- ETH_P_FCOE = 0x8906
- ETH_P_FIP = 0x8914
- ETH_P_HDLC = 0x19
- ETH_P_IEEE802154 = 0xf6
- ETH_P_IEEEPUP = 0xa00
- ETH_P_IEEEPUPAT = 0xa01
- ETH_P_IP = 0x800
- ETH_P_IPV6 = 0x86dd
- ETH_P_IPX = 0x8137
- ETH_P_IRDA = 0x17
- ETH_P_LAT = 0x6004
- ETH_P_LINK_CTL = 0x886c
- ETH_P_LOCALTALK = 0x9
- ETH_P_LOOP = 0x60
- ETH_P_LOOPBACK = 0x9000
- ETH_P_MOBITEX = 0x15
- ETH_P_MPLS_MC = 0x8848
- ETH_P_MPLS_UC = 0x8847
- ETH_P_MVRP = 0x88f5
- ETH_P_PAE = 0x888e
- ETH_P_PAUSE = 0x8808
- ETH_P_PHONET = 0xf5
- ETH_P_PPPTALK = 0x10
- ETH_P_PPP_DISC = 0x8863
- ETH_P_PPP_MP = 0x8
- ETH_P_PPP_SES = 0x8864
- ETH_P_PRP = 0x88fb
- ETH_P_PUP = 0x200
- ETH_P_PUPAT = 0x201
- ETH_P_QINQ1 = 0x9100
- ETH_P_QINQ2 = 0x9200
- ETH_P_QINQ3 = 0x9300
- ETH_P_RARP = 0x8035
- ETH_P_SCA = 0x6007
- ETH_P_SLOW = 0x8809
- ETH_P_SNAP = 0x5
- ETH_P_TDLS = 0x890d
- ETH_P_TEB = 0x6558
- ETH_P_TIPC = 0x88ca
- ETH_P_TRAILER = 0x1c
- ETH_P_TR_802_2 = 0x11
- ETH_P_TSN = 0x22f0
- ETH_P_WAN_PPP = 0x7
- ETH_P_WCCP = 0x883e
- ETH_P_X25 = 0x805
- ETH_P_XDSA = 0xf8
- EXTA = 0xe
- EXTB = 0xf
- EXTPROC = 0x10000
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FLUSHO = 0x2000
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x406
- F_EXLCK = 0x4
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLEASE = 0x401
- F_GETLK = 0xe
- F_GETLK64 = 0xe
- F_GETOWN = 0x17
- F_GETOWN_EX = 0x10
- F_GETPIPE_SZ = 0x408
- F_GETSIG = 0xb
- F_LOCK = 0x1
- F_NOTIFY = 0x402
- F_OFD_GETLK = 0x24
- F_OFD_SETLK = 0x25
- F_OFD_SETLKW = 0x26
- F_OK = 0x0
- F_RDLCK = 0x0
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLEASE = 0x400
- F_SETLK = 0x6
- F_SETLK64 = 0x6
- F_SETLKW = 0x7
- F_SETLKW64 = 0x7
- F_SETOWN = 0x18
- F_SETOWN_EX = 0xf
- F_SETPIPE_SZ = 0x407
- F_SETSIG = 0xa
- F_SHLCK = 0x8
- F_TEST = 0x3
- F_TLOCK = 0x2
- F_ULOCK = 0x0
- F_UNLCK = 0x2
- F_WRLCK = 0x1
- HUPCL = 0x400
- ICANON = 0x2
- ICMPV6_FILTER = 0x1
- ICRNL = 0x100
- IEXTEN = 0x100
- IFA_F_DADFAILED = 0x8
- IFA_F_DEPRECATED = 0x20
- IFA_F_HOMEADDRESS = 0x10
- IFA_F_MANAGETEMPADDR = 0x100
- IFA_F_MCAUTOJOIN = 0x400
- IFA_F_NODAD = 0x2
- IFA_F_NOPREFIXROUTE = 0x200
- IFA_F_OPTIMISTIC = 0x4
- IFA_F_PERMANENT = 0x80
- IFA_F_SECONDARY = 0x1
- IFA_F_STABLE_PRIVACY = 0x800
- IFA_F_TEMPORARY = 0x1
- IFA_F_TENTATIVE = 0x40
- IFA_MAX = 0x8
- IFF_ALLMULTI = 0x200
- IFF_ATTACH_QUEUE = 0x200
- IFF_AUTOMEDIA = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_DETACH_QUEUE = 0x400
- IFF_DORMANT = 0x20000
- IFF_DYNAMIC = 0x8000
- IFF_ECHO = 0x40000
- IFF_LOOPBACK = 0x8
- IFF_LOWER_UP = 0x10000
- IFF_MASTER = 0x400
- IFF_MULTICAST = 0x1000
- IFF_MULTI_QUEUE = 0x100
- IFF_NOARP = 0x80
- IFF_NOFILTER = 0x1000
- IFF_NOTRAILERS = 0x20
- IFF_NO_PI = 0x1000
- IFF_ONE_QUEUE = 0x2000
- IFF_PERSIST = 0x800
- IFF_POINTOPOINT = 0x10
- IFF_PORTSEL = 0x2000
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SLAVE = 0x800
- IFF_TAP = 0x2
- IFF_TUN = 0x1
- IFF_TUN_EXCL = 0x8000
- IFF_UP = 0x1
- IFF_VNET_HDR = 0x4000
- IFF_VOLATILE = 0x70c5a
- IFNAMSIZ = 0x10
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_ACCESS = 0x1
- IN_ALL_EVENTS = 0xfff
- IN_ATTRIB = 0x4
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLOEXEC = 0x80000
- IN_CLOSE = 0x18
- IN_CLOSE_NOWRITE = 0x10
- IN_CLOSE_WRITE = 0x8
- IN_CREATE = 0x100
- IN_DELETE = 0x200
- IN_DELETE_SELF = 0x400
- IN_DONT_FOLLOW = 0x2000000
- IN_EXCL_UNLINK = 0x4000000
- IN_IGNORED = 0x8000
- IN_ISDIR = 0x40000000
- IN_LOOPBACKNET = 0x7f
- IN_MASK_ADD = 0x20000000
- IN_MODIFY = 0x2
- IN_MOVE = 0xc0
- IN_MOVED_FROM = 0x40
- IN_MOVED_TO = 0x80
- IN_MOVE_SELF = 0x800
- IN_NONBLOCK = 0x80
- IN_ONESHOT = 0x80000000
- IN_ONLYDIR = 0x1000000
- IN_OPEN = 0x20
- IN_Q_OVERFLOW = 0x4000
- IN_UNMOUNT = 0x2000
- IPPROTO_AH = 0x33
- IPPROTO_BEETPH = 0x5e
- IPPROTO_COMP = 0x6c
- IPPROTO_DCCP = 0x21
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_ENCAP = 0x62
- IPPROTO_ESP = 0x32
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GRE = 0x2f
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IGMP = 0x2
- IPPROTO_IP = 0x0
- IPPROTO_IPIP = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_MH = 0x87
- IPPROTO_MTP = 0x5c
- IPPROTO_NONE = 0x3b
- IPPROTO_PIM = 0x67
- IPPROTO_PUP = 0xc
- IPPROTO_RAW = 0xff
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_SCTP = 0x84
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_UDP = 0x11
- IPPROTO_UDPLITE = 0x88
- IPV6_2292DSTOPTS = 0x4
- IPV6_2292HOPLIMIT = 0x8
- IPV6_2292HOPOPTS = 0x3
- IPV6_2292PKTINFO = 0x2
- IPV6_2292PKTOPTIONS = 0x6
- IPV6_2292RTHDR = 0x5
- IPV6_ADDRFORM = 0x1
- IPV6_ADD_MEMBERSHIP = 0x14
- IPV6_AUTHHDR = 0xa
- IPV6_CHECKSUM = 0x7
- IPV6_DONTFRAG = 0x3e
- IPV6_DROP_MEMBERSHIP = 0x15
- IPV6_DSTOPTS = 0x3b
- IPV6_HOPLIMIT = 0x34
- IPV6_HOPOPTS = 0x36
- IPV6_IPSEC_POLICY = 0x22
- IPV6_JOIN_ANYCAST = 0x1b
- IPV6_JOIN_GROUP = 0x14
- IPV6_LEAVE_ANYCAST = 0x1c
- IPV6_LEAVE_GROUP = 0x15
- IPV6_MTU = 0x18
- IPV6_MTU_DISCOVER = 0x17
- IPV6_MULTICAST_HOPS = 0x12
- IPV6_MULTICAST_IF = 0x11
- IPV6_MULTICAST_LOOP = 0x13
- IPV6_NEXTHOP = 0x9
- IPV6_PATHMTU = 0x3d
- IPV6_PKTINFO = 0x32
- IPV6_PMTUDISC_DO = 0x2
- IPV6_PMTUDISC_DONT = 0x0
- IPV6_PMTUDISC_INTERFACE = 0x4
- IPV6_PMTUDISC_OMIT = 0x5
- IPV6_PMTUDISC_PROBE = 0x3
- IPV6_PMTUDISC_WANT = 0x1
- IPV6_RECVDSTOPTS = 0x3a
- IPV6_RECVERR = 0x19
- IPV6_RECVHOPLIMIT = 0x33
- IPV6_RECVHOPOPTS = 0x35
- IPV6_RECVPATHMTU = 0x3c
- IPV6_RECVPKTINFO = 0x31
- IPV6_RECVRTHDR = 0x38
- IPV6_RECVTCLASS = 0x42
- IPV6_ROUTER_ALERT = 0x16
- IPV6_RTHDR = 0x39
- IPV6_RTHDRDSTOPTS = 0x37
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_RXDSTOPTS = 0x3b
- IPV6_RXHOPOPTS = 0x36
- IPV6_TCLASS = 0x43
- IPV6_UNICAST_HOPS = 0x10
- IPV6_V6ONLY = 0x1a
- IPV6_XFRM_POLICY = 0x23
- IP_ADD_MEMBERSHIP = 0x23
- IP_ADD_SOURCE_MEMBERSHIP = 0x27
- IP_BLOCK_SOURCE = 0x26
- IP_CHECKSUM = 0x17
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0x24
- IP_DROP_SOURCE_MEMBERSHIP = 0x28
- IP_FREEBIND = 0xf
- IP_HDRINCL = 0x3
- IP_IPSEC_POLICY = 0x10
- IP_MAXPACKET = 0xffff
- IP_MAX_MEMBERSHIPS = 0x14
- IP_MF = 0x2000
- IP_MINTTL = 0x15
- IP_MSFILTER = 0x29
- IP_MSS = 0x240
- IP_MTU = 0xe
- IP_MTU_DISCOVER = 0xa
- IP_MULTICAST_ALL = 0x31
- IP_MULTICAST_IF = 0x20
- IP_MULTICAST_LOOP = 0x22
- IP_MULTICAST_TTL = 0x21
- IP_NODEFRAG = 0x16
- IP_OFFMASK = 0x1fff
- IP_OPTIONS = 0x4
- IP_ORIGDSTADDR = 0x14
- IP_PASSSEC = 0x12
- IP_PKTINFO = 0x8
- IP_PKTOPTIONS = 0x9
- IP_PMTUDISC = 0xa
- IP_PMTUDISC_DO = 0x2
- IP_PMTUDISC_DONT = 0x0
- IP_PMTUDISC_INTERFACE = 0x4
- IP_PMTUDISC_OMIT = 0x5
- IP_PMTUDISC_PROBE = 0x3
- IP_PMTUDISC_WANT = 0x1
- IP_RECVERR = 0xb
- IP_RECVOPTS = 0x6
- IP_RECVORIGDSTADDR = 0x14
- IP_RECVRETOPTS = 0x7
- IP_RECVTOS = 0xd
- IP_RECVTTL = 0xc
- IP_RETOPTS = 0x7
- IP_RF = 0x8000
- IP_ROUTER_ALERT = 0x5
- IP_TOS = 0x1
- IP_TRANSPARENT = 0x13
- IP_TTL = 0x2
- IP_UNBLOCK_SOURCE = 0x25
- IP_UNICAST_IF = 0x32
- IP_XFRM_POLICY = 0x11
- ISIG = 0x1
- ISTRIP = 0x20
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x1000
- IXON = 0x400
- LINUX_REBOOT_CMD_CAD_OFF = 0x0
- LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
- LINUX_REBOOT_CMD_HALT = 0xcdef0123
- LINUX_REBOOT_CMD_KEXEC = 0x45584543
- LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
- LINUX_REBOOT_CMD_RESTART = 0x1234567
- LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
- LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
- LINUX_REBOOT_MAGIC1 = 0xfee1dead
- LINUX_REBOOT_MAGIC2 = 0x28121969
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_DODUMP = 0x11
- MADV_DOFORK = 0xb
- MADV_DONTDUMP = 0x10
- MADV_DONTFORK = 0xa
- MADV_DONTNEED = 0x4
- MADV_HUGEPAGE = 0xe
- MADV_HWPOISON = 0x64
- MADV_MERGEABLE = 0xc
- MADV_NOHUGEPAGE = 0xf
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_REMOVE = 0x9
- MADV_SEQUENTIAL = 0x2
- MADV_UNMERGEABLE = 0xd
- MADV_WILLNEED = 0x3
- MAP_ANON = 0x800
- MAP_ANONYMOUS = 0x800
- MAP_DENYWRITE = 0x2000
- MAP_EXECUTABLE = 0x4000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_GROWSDOWN = 0x1000
- MAP_HUGETLB = 0x80000
- MAP_HUGE_MASK = 0x3f
- MAP_HUGE_SHIFT = 0x1a
- MAP_LOCKED = 0x8000
- MAP_NONBLOCK = 0x20000
- MAP_NORESERVE = 0x400
- MAP_POPULATE = 0x10000
- MAP_PRIVATE = 0x2
- MAP_RENAME = 0x800
- MAP_SHARED = 0x1
- MAP_STACK = 0x40000
- MAP_TYPE = 0xf
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MNT_DETACH = 0x2
- MNT_EXPIRE = 0x4
- MNT_FORCE = 0x1
- MSG_CMSG_CLOEXEC = 0x40000000
- MSG_CONFIRM = 0x800
- MSG_CTRUNC = 0x8
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x40
- MSG_EOR = 0x80
- MSG_ERRQUEUE = 0x2000
- MSG_FASTOPEN = 0x20000000
- MSG_FIN = 0x200
- MSG_MORE = 0x8000
- MSG_NOSIGNAL = 0x4000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_PROXY = 0x10
- MSG_RST = 0x1000
- MSG_SYN = 0x400
- MSG_TRUNC = 0x20
- MSG_TRYHARD = 0x4
- MSG_WAITALL = 0x100
- MSG_WAITFORONE = 0x10000
- MS_ACTIVE = 0x40000000
- MS_ASYNC = 0x1
- MS_BIND = 0x1000
- MS_DIRSYNC = 0x80
- MS_INVALIDATE = 0x2
- MS_I_VERSION = 0x800000
- MS_KERNMOUNT = 0x400000
- MS_LAZYTIME = 0x2000000
- MS_MANDLOCK = 0x40
- MS_MGC_MSK = 0xffff0000
- MS_MGC_VAL = 0xc0ed0000
- MS_MOVE = 0x2000
- MS_NOATIME = 0x400
- MS_NODEV = 0x4
- MS_NODIRATIME = 0x800
- MS_NOEXEC = 0x8
- MS_NOSUID = 0x2
- MS_NOUSER = -0x80000000
- MS_POSIXACL = 0x10000
- MS_PRIVATE = 0x40000
- MS_RDONLY = 0x1
- MS_REC = 0x4000
- MS_RELATIME = 0x200000
- MS_REMOUNT = 0x20
- MS_RMT_MASK = 0x2800051
- MS_SHARED = 0x100000
- MS_SILENT = 0x8000
- MS_SLAVE = 0x80000
- MS_STRICTATIME = 0x1000000
- MS_SYNC = 0x4
- MS_SYNCHRONOUS = 0x10
- MS_UNBINDABLE = 0x20000
- NAME_MAX = 0xff
- NETLINK_ADD_MEMBERSHIP = 0x1
- NETLINK_AUDIT = 0x9
- NETLINK_BROADCAST_ERROR = 0x4
- NETLINK_CAP_ACK = 0xa
- NETLINK_CONNECTOR = 0xb
- NETLINK_CRYPTO = 0x15
- NETLINK_DNRTMSG = 0xe
- NETLINK_DROP_MEMBERSHIP = 0x2
- NETLINK_ECRYPTFS = 0x13
- NETLINK_FIB_LOOKUP = 0xa
- NETLINK_FIREWALL = 0x3
- NETLINK_GENERIC = 0x10
- NETLINK_INET_DIAG = 0x4
- NETLINK_IP6_FW = 0xd
- NETLINK_ISCSI = 0x8
- NETLINK_KOBJECT_UEVENT = 0xf
- NETLINK_LISTEN_ALL_NSID = 0x8
- NETLINK_LIST_MEMBERSHIPS = 0x9
- NETLINK_NETFILTER = 0xc
- NETLINK_NFLOG = 0x5
- NETLINK_NO_ENOBUFS = 0x5
- NETLINK_PKTINFO = 0x3
- NETLINK_RDMA = 0x14
- NETLINK_ROUTE = 0x0
- NETLINK_RX_RING = 0x6
- NETLINK_SCSITRANSPORT = 0x12
- NETLINK_SELINUX = 0x7
- NETLINK_SOCK_DIAG = 0x4
- NETLINK_TX_RING = 0x7
- NETLINK_UNUSED = 0x1
- NETLINK_USERSOCK = 0x2
- NETLINK_XFRM = 0x6
- NLA_ALIGNTO = 0x4
- NLA_F_NESTED = 0x8000
- NLA_F_NET_BYTEORDER = 0x4000
- NLA_HDRLEN = 0x4
- NLMSG_ALIGNTO = 0x4
- NLMSG_DONE = 0x3
- NLMSG_ERROR = 0x2
- NLMSG_HDRLEN = 0x10
- NLMSG_MIN_TYPE = 0x10
- NLMSG_NOOP = 0x1
- NLMSG_OVERRUN = 0x4
- NLM_F_ACK = 0x4
- NLM_F_APPEND = 0x800
- NLM_F_ATOMIC = 0x400
- NLM_F_CREATE = 0x400
- NLM_F_DUMP = 0x300
- NLM_F_DUMP_INTR = 0x10
- NLM_F_ECHO = 0x8
- NLM_F_EXCL = 0x200
- NLM_F_MATCH = 0x200
- NLM_F_MULTI = 0x2
- NLM_F_REPLACE = 0x100
- NLM_F_REQUEST = 0x1
- NLM_F_ROOT = 0x100
- NOFLSH = 0x80
- OCRNL = 0x8
- OFDEL = 0x80
- OFILL = 0x40
- ONLCR = 0x4
- ONLRET = 0x20
- ONOCR = 0x10
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x8
- O_ASYNC = 0x1000
- O_CLOEXEC = 0x80000
- O_CREAT = 0x100
- O_DIRECT = 0x8000
- O_DIRECTORY = 0x10000
- O_DSYNC = 0x10
- O_EXCL = 0x400
- O_FSYNC = 0x4010
- O_LARGEFILE = 0x0
- O_NDELAY = 0x80
- O_NOATIME = 0x40000
- O_NOCTTY = 0x800
- O_NOFOLLOW = 0x20000
- O_NONBLOCK = 0x80
- O_PATH = 0x200000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_RSYNC = 0x4010
- O_SYNC = 0x4010
- O_TMPFILE = 0x410000
- O_TRUNC = 0x200
- O_WRONLY = 0x1
- PACKET_ADD_MEMBERSHIP = 0x1
- PACKET_AUXDATA = 0x8
- PACKET_BROADCAST = 0x1
- PACKET_COPY_THRESH = 0x7
- PACKET_DROP_MEMBERSHIP = 0x2
- PACKET_FANOUT = 0x12
- PACKET_FANOUT_CBPF = 0x6
- PACKET_FANOUT_CPU = 0x2
- PACKET_FANOUT_DATA = 0x16
- PACKET_FANOUT_EBPF = 0x7
- PACKET_FANOUT_FLAG_DEFRAG = 0x8000
- PACKET_FANOUT_FLAG_ROLLOVER = 0x1000
- PACKET_FANOUT_HASH = 0x0
- PACKET_FANOUT_LB = 0x1
- PACKET_FANOUT_QM = 0x5
- PACKET_FANOUT_RND = 0x4
- PACKET_FANOUT_ROLLOVER = 0x3
- PACKET_FASTROUTE = 0x6
- PACKET_HDRLEN = 0xb
- PACKET_HOST = 0x0
- PACKET_KERNEL = 0x7
- PACKET_LOOPBACK = 0x5
- PACKET_LOSS = 0xe
- PACKET_MR_ALLMULTI = 0x2
- PACKET_MR_MULTICAST = 0x0
- PACKET_MR_PROMISC = 0x1
- PACKET_MR_UNICAST = 0x3
- PACKET_MULTICAST = 0x2
- PACKET_ORIGDEV = 0x9
- PACKET_OTHERHOST = 0x3
- PACKET_OUTGOING = 0x4
- PACKET_QDISC_BYPASS = 0x14
- PACKET_RECV_OUTPUT = 0x3
- PACKET_RESERVE = 0xc
- PACKET_ROLLOVER_STATS = 0x15
- PACKET_RX_RING = 0x5
- PACKET_STATISTICS = 0x6
- PACKET_TIMESTAMP = 0x11
- PACKET_TX_HAS_OFF = 0x13
- PACKET_TX_RING = 0xd
- PACKET_TX_TIMESTAMP = 0x10
- PACKET_USER = 0x6
- PACKET_VERSION = 0xa
- PACKET_VNET_HDR = 0xf
- PARENB = 0x100
- PARITY_CRC16_PR0 = 0x2
- PARITY_CRC16_PR0_CCITT = 0x4
- PARITY_CRC16_PR1 = 0x3
- PARITY_CRC16_PR1_CCITT = 0x5
- PARITY_CRC32_PR0_CCITT = 0x6
- PARITY_CRC32_PR1_CCITT = 0x7
- PARITY_DEFAULT = 0x0
- PARITY_NONE = 0x1
- PARMRK = 0x8
- PARODD = 0x200
- PENDIN = 0x4000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_GROWSDOWN = 0x1000000
- PROT_GROWSUP = 0x2000000
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- PR_CAPBSET_DROP = 0x18
- PR_CAPBSET_READ = 0x17
- PR_CAP_AMBIENT = 0x2f
- PR_CAP_AMBIENT_CLEAR_ALL = 0x4
- PR_CAP_AMBIENT_IS_SET = 0x1
- PR_CAP_AMBIENT_LOWER = 0x3
- PR_CAP_AMBIENT_RAISE = 0x2
- PR_ENDIAN_BIG = 0x0
- PR_ENDIAN_LITTLE = 0x1
- PR_ENDIAN_PPC_LITTLE = 0x2
- PR_FPEMU_NOPRINT = 0x1
- PR_FPEMU_SIGFPE = 0x2
- PR_FP_EXC_ASYNC = 0x2
- PR_FP_EXC_DISABLED = 0x0
- PR_FP_EXC_DIV = 0x10000
- PR_FP_EXC_INV = 0x100000
- PR_FP_EXC_NONRECOV = 0x1
- PR_FP_EXC_OVF = 0x20000
- PR_FP_EXC_PRECISE = 0x3
- PR_FP_EXC_RES = 0x80000
- PR_FP_EXC_SW_ENABLE = 0x80
- PR_FP_EXC_UND = 0x40000
- PR_FP_MODE_FR = 0x1
- PR_FP_MODE_FRE = 0x2
- PR_GET_CHILD_SUBREAPER = 0x25
- PR_GET_DUMPABLE = 0x3
- PR_GET_ENDIAN = 0x13
- PR_GET_FPEMU = 0x9
- PR_GET_FPEXC = 0xb
- PR_GET_FP_MODE = 0x2e
- PR_GET_KEEPCAPS = 0x7
- PR_GET_NAME = 0x10
- PR_GET_NO_NEW_PRIVS = 0x27
- PR_GET_PDEATHSIG = 0x2
- PR_GET_SECCOMP = 0x15
- PR_GET_SECUREBITS = 0x1b
- PR_GET_THP_DISABLE = 0x2a
- PR_GET_TID_ADDRESS = 0x28
- PR_GET_TIMERSLACK = 0x1e
- PR_GET_TIMING = 0xd
- PR_GET_TSC = 0x19
- PR_GET_UNALIGN = 0x5
- PR_MCE_KILL = 0x21
- PR_MCE_KILL_CLEAR = 0x0
- PR_MCE_KILL_DEFAULT = 0x2
- PR_MCE_KILL_EARLY = 0x1
- PR_MCE_KILL_GET = 0x22
- PR_MCE_KILL_LATE = 0x0
- PR_MCE_KILL_SET = 0x1
- PR_MPX_DISABLE_MANAGEMENT = 0x2c
- PR_MPX_ENABLE_MANAGEMENT = 0x2b
- PR_SET_CHILD_SUBREAPER = 0x24
- PR_SET_DUMPABLE = 0x4
- PR_SET_ENDIAN = 0x14
- PR_SET_FPEMU = 0xa
- PR_SET_FPEXC = 0xc
- PR_SET_FP_MODE = 0x2d
- PR_SET_KEEPCAPS = 0x8
- PR_SET_MM = 0x23
- PR_SET_MM_ARG_END = 0x9
- PR_SET_MM_ARG_START = 0x8
- PR_SET_MM_AUXV = 0xc
- PR_SET_MM_BRK = 0x7
- PR_SET_MM_END_CODE = 0x2
- PR_SET_MM_END_DATA = 0x4
- PR_SET_MM_ENV_END = 0xb
- PR_SET_MM_ENV_START = 0xa
- PR_SET_MM_EXE_FILE = 0xd
- PR_SET_MM_MAP = 0xe
- PR_SET_MM_MAP_SIZE = 0xf
- PR_SET_MM_START_BRK = 0x6
- PR_SET_MM_START_CODE = 0x1
- PR_SET_MM_START_DATA = 0x3
- PR_SET_MM_START_STACK = 0x5
- PR_SET_NAME = 0xf
- PR_SET_NO_NEW_PRIVS = 0x26
- PR_SET_PDEATHSIG = 0x1
- PR_SET_PTRACER = 0x59616d61
- PR_SET_PTRACER_ANY = -0x1
- PR_SET_SECCOMP = 0x16
- PR_SET_SECUREBITS = 0x1c
- PR_SET_THP_DISABLE = 0x29
- PR_SET_TIMERSLACK = 0x1d
- PR_SET_TIMING = 0xe
- PR_SET_TSC = 0x1a
- PR_SET_UNALIGN = 0x6
- PR_TASK_PERF_EVENTS_DISABLE = 0x1f
- PR_TASK_PERF_EVENTS_ENABLE = 0x20
- PR_TIMING_STATISTICAL = 0x0
- PR_TIMING_TIMESTAMP = 0x1
- PR_TSC_ENABLE = 0x1
- PR_TSC_SIGSEGV = 0x2
- PR_UNALIGN_NOPRINT = 0x1
- PR_UNALIGN_SIGBUS = 0x2
- PTRACE_ATTACH = 0x10
- PTRACE_CONT = 0x7
- PTRACE_DETACH = 0x11
- PTRACE_EVENT_CLONE = 0x3
- PTRACE_EVENT_EXEC = 0x4
- PTRACE_EVENT_EXIT = 0x6
- PTRACE_EVENT_FORK = 0x1
- PTRACE_EVENT_SECCOMP = 0x7
- PTRACE_EVENT_STOP = 0x80
- PTRACE_EVENT_VFORK = 0x2
- PTRACE_EVENT_VFORK_DONE = 0x5
- PTRACE_GETEVENTMSG = 0x4201
- PTRACE_GETFPREGS = 0xe
- PTRACE_GETREGS = 0xc
- PTRACE_GETREGSET = 0x4204
- PTRACE_GETSIGINFO = 0x4202
- PTRACE_GETSIGMASK = 0x420a
- PTRACE_GET_THREAD_AREA = 0x19
- PTRACE_GET_THREAD_AREA_3264 = 0xc4
- PTRACE_GET_WATCH_REGS = 0xd0
- PTRACE_INTERRUPT = 0x4207
- PTRACE_KILL = 0x8
- PTRACE_LISTEN = 0x4208
- PTRACE_OLDSETOPTIONS = 0x15
- PTRACE_O_EXITKILL = 0x100000
- PTRACE_O_MASK = 0x3000ff
- PTRACE_O_SUSPEND_SECCOMP = 0x200000
- PTRACE_O_TRACECLONE = 0x8
- PTRACE_O_TRACEEXEC = 0x10
- PTRACE_O_TRACEEXIT = 0x40
- PTRACE_O_TRACEFORK = 0x2
- PTRACE_O_TRACESECCOMP = 0x80
- PTRACE_O_TRACESYSGOOD = 0x1
- PTRACE_O_TRACEVFORK = 0x4
- PTRACE_O_TRACEVFORKDONE = 0x20
- PTRACE_PEEKDATA = 0x2
- PTRACE_PEEKDATA_3264 = 0xc1
- PTRACE_PEEKSIGINFO = 0x4209
- PTRACE_PEEKSIGINFO_SHARED = 0x1
- PTRACE_PEEKTEXT = 0x1
- PTRACE_PEEKTEXT_3264 = 0xc0
- PTRACE_PEEKUSR = 0x3
- PTRACE_POKEDATA = 0x5
- PTRACE_POKEDATA_3264 = 0xc3
- PTRACE_POKETEXT = 0x4
- PTRACE_POKETEXT_3264 = 0xc2
- PTRACE_POKEUSR = 0x6
- PTRACE_SEIZE = 0x4206
- PTRACE_SETFPREGS = 0xf
- PTRACE_SETOPTIONS = 0x4200
- PTRACE_SETREGS = 0xd
- PTRACE_SETREGSET = 0x4205
- PTRACE_SETSIGINFO = 0x4203
- PTRACE_SETSIGMASK = 0x420b
- PTRACE_SET_THREAD_AREA = 0x1a
- PTRACE_SET_WATCH_REGS = 0xd1
- PTRACE_SINGLESTEP = 0x9
- PTRACE_SYSCALL = 0x18
- PTRACE_TRACEME = 0x0
- RLIMIT_AS = 0x6
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x5
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = -0x1
- RTAX_ADVMSS = 0x8
- RTAX_CC_ALGO = 0x10
- RTAX_CWND = 0x7
- RTAX_FEATURES = 0xc
- RTAX_FEATURE_ALLFRAG = 0x8
- RTAX_FEATURE_ECN = 0x1
- RTAX_FEATURE_MASK = 0xf
- RTAX_FEATURE_SACK = 0x2
- RTAX_FEATURE_TIMESTAMP = 0x4
- RTAX_HOPLIMIT = 0xa
- RTAX_INITCWND = 0xb
- RTAX_INITRWND = 0xe
- RTAX_LOCK = 0x1
- RTAX_MAX = 0x10
- RTAX_MTU = 0x2
- RTAX_QUICKACK = 0xf
- RTAX_REORDERING = 0x9
- RTAX_RTO_MIN = 0xd
- RTAX_RTT = 0x4
- RTAX_RTTVAR = 0x5
- RTAX_SSTHRESH = 0x6
- RTAX_UNSPEC = 0x0
- RTAX_WINDOW = 0x3
- RTA_ALIGNTO = 0x4
- RTA_MAX = 0x16
- RTCF_DIRECTSRC = 0x4000000
- RTCF_DOREDIRECT = 0x1000000
- RTCF_LOG = 0x2000000
- RTCF_MASQ = 0x400000
- RTCF_NAT = 0x800000
- RTCF_VALVE = 0x200000
- RTF_ADDRCLASSMASK = 0xf8000000
- RTF_ADDRCONF = 0x40000
- RTF_ALLONLINK = 0x20000
- RTF_BROADCAST = 0x10000000
- RTF_CACHE = 0x1000000
- RTF_DEFAULT = 0x10000
- RTF_DYNAMIC = 0x10
- RTF_FLOW = 0x2000000
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_INTERFACE = 0x40000000
- RTF_IRTT = 0x100
- RTF_LINKRT = 0x100000
- RTF_LOCAL = 0x80000000
- RTF_MODIFIED = 0x20
- RTF_MSS = 0x40
- RTF_MTU = 0x40
- RTF_MULTICAST = 0x20000000
- RTF_NAT = 0x8000000
- RTF_NOFORWARD = 0x1000
- RTF_NONEXTHOP = 0x200000
- RTF_NOPMTUDISC = 0x4000
- RTF_POLICY = 0x4000000
- RTF_REINSTATE = 0x8
- RTF_REJECT = 0x200
- RTF_STATIC = 0x400
- RTF_THROW = 0x2000
- RTF_UP = 0x1
- RTF_WINDOW = 0x80
- RTF_XRESOLVE = 0x800
- RTM_BASE = 0x10
- RTM_DELACTION = 0x31
- RTM_DELADDR = 0x15
- RTM_DELADDRLABEL = 0x49
- RTM_DELLINK = 0x11
- RTM_DELMDB = 0x55
- RTM_DELNEIGH = 0x1d
- RTM_DELNSID = 0x59
- RTM_DELQDISC = 0x25
- RTM_DELROUTE = 0x19
- RTM_DELRULE = 0x21
- RTM_DELTCLASS = 0x29
- RTM_DELTFILTER = 0x2d
- RTM_F_CLONED = 0x200
- RTM_F_EQUALIZE = 0x400
- RTM_F_NOTIFY = 0x100
- RTM_F_PREFIX = 0x800
- RTM_GETACTION = 0x32
- RTM_GETADDR = 0x16
- RTM_GETADDRLABEL = 0x4a
- RTM_GETANYCAST = 0x3e
- RTM_GETDCB = 0x4e
- RTM_GETLINK = 0x12
- RTM_GETMDB = 0x56
- RTM_GETMULTICAST = 0x3a
- RTM_GETNEIGH = 0x1e
- RTM_GETNEIGHTBL = 0x42
- RTM_GETNETCONF = 0x52
- RTM_GETNSID = 0x5a
- RTM_GETQDISC = 0x26
- RTM_GETROUTE = 0x1a
- RTM_GETRULE = 0x22
- RTM_GETTCLASS = 0x2a
- RTM_GETTFILTER = 0x2e
- RTM_MAX = 0x5b
- RTM_NEWACTION = 0x30
- RTM_NEWADDR = 0x14
- RTM_NEWADDRLABEL = 0x48
- RTM_NEWLINK = 0x10
- RTM_NEWMDB = 0x54
- RTM_NEWNDUSEROPT = 0x44
- RTM_NEWNEIGH = 0x1c
- RTM_NEWNEIGHTBL = 0x40
- RTM_NEWNETCONF = 0x50
- RTM_NEWNSID = 0x58
- RTM_NEWPREFIX = 0x34
- RTM_NEWQDISC = 0x24
- RTM_NEWROUTE = 0x18
- RTM_NEWRULE = 0x20
- RTM_NEWTCLASS = 0x28
- RTM_NEWTFILTER = 0x2c
- RTM_NR_FAMILIES = 0x13
- RTM_NR_MSGTYPES = 0x4c
- RTM_SETDCB = 0x4f
- RTM_SETLINK = 0x13
- RTM_SETNEIGHTBL = 0x43
- RTNH_ALIGNTO = 0x4
- RTNH_COMPARE_MASK = 0x11
- RTNH_F_DEAD = 0x1
- RTNH_F_LINKDOWN = 0x10
- RTNH_F_OFFLOAD = 0x8
- RTNH_F_ONLINK = 0x4
- RTNH_F_PERVASIVE = 0x2
- RTN_MAX = 0xb
- RTPROT_BABEL = 0x2a
- RTPROT_BIRD = 0xc
- RTPROT_BOOT = 0x3
- RTPROT_DHCP = 0x10
- RTPROT_DNROUTED = 0xd
- RTPROT_GATED = 0x8
- RTPROT_KERNEL = 0x2
- RTPROT_MROUTED = 0x11
- RTPROT_MRT = 0xa
- RTPROT_NTK = 0xf
- RTPROT_RA = 0x9
- RTPROT_REDIRECT = 0x1
- RTPROT_STATIC = 0x4
- RTPROT_UNSPEC = 0x0
- RTPROT_XORP = 0xe
- RTPROT_ZEBRA = 0xb
- RT_CLASS_DEFAULT = 0xfd
- RT_CLASS_LOCAL = 0xff
- RT_CLASS_MAIN = 0xfe
- RT_CLASS_MAX = 0xff
- RT_CLASS_UNSPEC = 0x0
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- RUSAGE_THREAD = 0x1
- SCM_CREDENTIALS = 0x2
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x1d
- SCM_TIMESTAMPING = 0x25
- SCM_TIMESTAMPNS = 0x23
- SCM_WIFI_STATUS = 0x29
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDDLCI = 0x8980
- SIOCADDMULTI = 0x8931
- SIOCADDRT = 0x890b
- SIOCATMARK = 0x40047307
- SIOCDARP = 0x8953
- SIOCDELDLCI = 0x8981
- SIOCDELMULTI = 0x8932
- SIOCDELRT = 0x890c
- SIOCDEVPRIVATE = 0x89f0
- SIOCDIFADDR = 0x8936
- SIOCDRARP = 0x8960
- SIOCGARP = 0x8954
- SIOCGIFADDR = 0x8915
- SIOCGIFBR = 0x8940
- SIOCGIFBRDADDR = 0x8919
- SIOCGIFCONF = 0x8912
- SIOCGIFCOUNT = 0x8938
- SIOCGIFDSTADDR = 0x8917
- SIOCGIFENCAP = 0x8925
- SIOCGIFFLAGS = 0x8913
- SIOCGIFHWADDR = 0x8927
- SIOCGIFINDEX = 0x8933
- SIOCGIFMAP = 0x8970
- SIOCGIFMEM = 0x891f
- SIOCGIFMETRIC = 0x891d
- SIOCGIFMTU = 0x8921
- SIOCGIFNAME = 0x8910
- SIOCGIFNETMASK = 0x891b
- SIOCGIFPFLAGS = 0x8935
- SIOCGIFSLAVE = 0x8929
- SIOCGIFTXQLEN = 0x8942
- SIOCGPGRP = 0x40047309
- SIOCGRARP = 0x8961
- SIOCGSTAMP = 0x8906
- SIOCGSTAMPNS = 0x8907
- SIOCPROTOPRIVATE = 0x89e0
- SIOCRTMSG = 0x890d
- SIOCSARP = 0x8955
- SIOCSIFADDR = 0x8916
- SIOCSIFBR = 0x8941
- SIOCSIFBRDADDR = 0x891a
- SIOCSIFDSTADDR = 0x8918
- SIOCSIFENCAP = 0x8926
- SIOCSIFFLAGS = 0x8914
- SIOCSIFHWADDR = 0x8924
- SIOCSIFHWBROADCAST = 0x8937
- SIOCSIFLINK = 0x8911
- SIOCSIFMAP = 0x8971
- SIOCSIFMEM = 0x8920
- SIOCSIFMETRIC = 0x891e
- SIOCSIFMTU = 0x8922
- SIOCSIFNAME = 0x8923
- SIOCSIFNETMASK = 0x891c
- SIOCSIFPFLAGS = 0x8934
- SIOCSIFSLAVE = 0x8930
- SIOCSIFTXQLEN = 0x8943
- SIOCSPGRP = 0x80047308
- SIOCSRARP = 0x8962
- SOCK_CLOEXEC = 0x80000
- SOCK_DCCP = 0x6
- SOCK_DGRAM = 0x1
- SOCK_NONBLOCK = 0x80
- SOCK_PACKET = 0xa
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x2
- SOL_AAL = 0x109
- SOL_ATM = 0x108
- SOL_DECNET = 0x105
- SOL_ICMPV6 = 0x3a
- SOL_IP = 0x0
- SOL_IPV6 = 0x29
- SOL_IRDA = 0x10a
- SOL_PACKET = 0x107
- SOL_RAW = 0xff
- SOL_SOCKET = 0xffff
- SOL_TCP = 0x6
- SOL_X25 = 0x106
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x1009
- SO_ATTACH_BPF = 0x32
- SO_ATTACH_FILTER = 0x1a
- SO_BINDTODEVICE = 0x19
- SO_BPF_EXTENSIONS = 0x30
- SO_BROADCAST = 0x20
- SO_BSDCOMPAT = 0xe
- SO_BUSY_POLL = 0x2e
- SO_DEBUG = 0x1
- SO_DETACH_BPF = 0x1b
- SO_DETACH_FILTER = 0x1b
- SO_DOMAIN = 0x1029
- SO_DONTROUTE = 0x10
- SO_ERROR = 0x1007
- SO_GET_FILTER = 0x1a
- SO_INCOMING_CPU = 0x31
- SO_KEEPALIVE = 0x8
- SO_LINGER = 0x80
- SO_LOCK_FILTER = 0x2c
- SO_MARK = 0x24
- SO_MAX_PACING_RATE = 0x2f
- SO_NOFCS = 0x2b
- SO_NO_CHECK = 0xb
- SO_OOBINLINE = 0x100
- SO_PASSCRED = 0x11
- SO_PASSSEC = 0x22
- SO_PEEK_OFF = 0x2a
- SO_PEERCRED = 0x12
- SO_PEERNAME = 0x1c
- SO_PEERSEC = 0x1e
- SO_PRIORITY = 0xc
- SO_PROTOCOL = 0x1028
- SO_RCVBUF = 0x1002
- SO_RCVBUFFORCE = 0x21
- SO_RCVLOWAT = 0x1004
- SO_RCVTIMEO = 0x1006
- SO_REUSEADDR = 0x4
- SO_REUSEPORT = 0x200
- SO_RXQ_OVFL = 0x28
- SO_SECURITY_AUTHENTICATION = 0x16
- SO_SECURITY_ENCRYPTION_NETWORK = 0x18
- SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17
- SO_SELECT_ERR_QUEUE = 0x2d
- SO_SNDBUF = 0x1001
- SO_SNDBUFFORCE = 0x1f
- SO_SNDLOWAT = 0x1003
- SO_SNDTIMEO = 0x1005
- SO_STYLE = 0x1008
- SO_TIMESTAMP = 0x1d
- SO_TIMESTAMPING = 0x25
- SO_TIMESTAMPNS = 0x23
- SO_TYPE = 0x1008
- SO_WIFI_STATUS = 0x29
- S_BLKSIZE = 0x200
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TCFLSH = 0x5407
- TCIFLUSH = 0x0
- TCIOFLUSH = 0x2
- TCOFLUSH = 0x1
- TCP_CONGESTION = 0xd
- TCP_COOKIE_IN_ALWAYS = 0x1
- TCP_COOKIE_MAX = 0x10
- TCP_COOKIE_MIN = 0x8
- TCP_COOKIE_OUT_NEVER = 0x2
- TCP_COOKIE_PAIR_SIZE = 0x20
- TCP_COOKIE_TRANSACTIONS = 0xf
- TCP_CORK = 0x3
- TCP_DEFER_ACCEPT = 0x9
- TCP_FASTOPEN = 0x17
- TCP_INFO = 0xb
- TCP_KEEPCNT = 0x6
- TCP_KEEPIDLE = 0x4
- TCP_KEEPINTVL = 0x5
- TCP_LINGER2 = 0x8
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0xe
- TCP_MD5SIG_MAXKEYLEN = 0x50
- TCP_MSS = 0x200
- TCP_MSS_DEFAULT = 0x218
- TCP_MSS_DESIRED = 0x4c4
- TCP_NODELAY = 0x1
- TCP_QUEUE_SEQ = 0x15
- TCP_QUICKACK = 0xc
- TCP_REPAIR = 0x13
- TCP_REPAIR_OPTIONS = 0x16
- TCP_REPAIR_QUEUE = 0x14
- TCP_SYNCNT = 0x7
- TCP_S_DATA_IN = 0x4
- TCP_S_DATA_OUT = 0x8
- TCP_THIN_DUPACK = 0x11
- TCP_THIN_LINEAR_TIMEOUTS = 0x10
- TCP_TIMESTAMP = 0x18
- TCP_USER_TIMEOUT = 0x12
- TCP_WINDOW_CLAMP = 0xa
- TCSAFLUSH = 0x5410
- TCSBRK = 0x5405
- TCXONC = 0x5406
- TIOCCBRK = 0x5428
- TIOCCONS = 0x80047478
- TIOCEXCL = 0x740d
- TIOCGDEV = 0x40045432
- TIOCGETD = 0x7400
- TIOCGETP = 0x7408
- TIOCGEXCL = 0x40045440
- TIOCGICOUNT = 0x5492
- TIOCGLCKTRMIOS = 0x548b
- TIOCGLTC = 0x7474
- TIOCGPGRP = 0x40047477
- TIOCGPKT = 0x40045438
- TIOCGPTLCK = 0x40045439
- TIOCGPTN = 0x40045430
- TIOCGRS485 = 0x4020542e
- TIOCGSERIAL = 0x5484
- TIOCGSID = 0x7416
- TIOCGSOFTCAR = 0x5481
- TIOCGWINSZ = 0x40087468
- TIOCINQ = 0x467f
- TIOCLINUX = 0x5483
- TIOCMBIC = 0x741c
- TIOCMBIS = 0x741b
- TIOCMGET = 0x741d
- TIOCMIWAIT = 0x5491
- TIOCMSET = 0x741a
- TIOCM_CAR = 0x100
- TIOCM_CD = 0x100
- TIOCM_CTS = 0x40
- TIOCM_DSR = 0x400
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x200
- TIOCM_RNG = 0x200
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x20
- TIOCM_ST = 0x10
- TIOCNOTTY = 0x5471
- TIOCNXCL = 0x740e
- TIOCOUTQ = 0x7472
- TIOCPKT = 0x5470
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCSBRK = 0x5427
- TIOCSCTTY = 0x5480
- TIOCSERCONFIG = 0x5488
- TIOCSERGETLSR = 0x548e
- TIOCSERGETMULTI = 0x548f
- TIOCSERGSTRUCT = 0x548d
- TIOCSERGWILD = 0x5489
- TIOCSERSETMULTI = 0x5490
- TIOCSERSWILD = 0x548a
- TIOCSER_TEMT = 0x1
- TIOCSETD = 0x7401
- TIOCSETN = 0x740a
- TIOCSETP = 0x7409
- TIOCSIG = 0x80045436
- TIOCSLCKTRMIOS = 0x548c
- TIOCSLTC = 0x7475
- TIOCSPGRP = 0x80047476
- TIOCSPTLCK = 0x80045431
- TIOCSRS485 = 0xc020542f
- TIOCSSERIAL = 0x5485
- TIOCSSOFTCAR = 0x5482
- TIOCSTI = 0x5472
- TIOCSWINSZ = 0x80087467
- TIOCVHANGUP = 0x5437
- TOSTOP = 0x8000
- TUNATTACHFILTER = 0x801054d5
- TUNDETACHFILTER = 0x801054d6
- TUNGETFEATURES = 0x400454cf
- TUNGETFILTER = 0x401054db
- TUNGETIFF = 0x400454d2
- TUNGETSNDBUF = 0x400454d3
- TUNGETVNETBE = 0x400454df
- TUNGETVNETHDRSZ = 0x400454d7
- TUNGETVNETLE = 0x400454dd
- TUNSETDEBUG = 0x800454c9
- TUNSETGROUP = 0x800454ce
- TUNSETIFF = 0x800454ca
- TUNSETIFINDEX = 0x800454da
- TUNSETLINK = 0x800454cd
- TUNSETNOCSUM = 0x800454c8
- TUNSETOFFLOAD = 0x800454d0
- TUNSETOWNER = 0x800454cc
- TUNSETPERSIST = 0x800454cb
- TUNSETQUEUE = 0x800454d9
- TUNSETSNDBUF = 0x800454d4
- TUNSETTXFILTER = 0x800454d1
- TUNSETVNETBE = 0x800454de
- TUNSETVNETHDRSZ = 0x800454d8
- TUNSETVNETLE = 0x800454dc
- VDISCARD = 0xd
- VEOF = 0x10
- VEOL = 0x11
- VEOL2 = 0x6
- VERASE = 0x2
- VINTR = 0x0
- VKILL = 0x3
- VLNEXT = 0xf
- VMIN = 0x4
- VQUIT = 0x1
- VREPRINT = 0xc
- VSTART = 0x8
- VSTOP = 0x9
- VSUSP = 0xa
- VSWTC = 0x7
- VSWTCH = 0x7
- VT0 = 0x0
- VT1 = 0x4000
- VTDLY = 0x4000
- VTIME = 0x5
- VWERASE = 0xe
- WALL = 0x40000000
- WCLONE = 0x80000000
- WCONTINUED = 0x8
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOTHREAD = 0x20000000
- WNOWAIT = 0x1000000
- WORDSIZE = 0x40
- WSTOPPED = 0x2
- WUNTRACED = 0x2
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x7d)
- EADDRNOTAVAIL = syscall.Errno(0x7e)
- EADV = syscall.Errno(0x44)
- EAFNOSUPPORT = syscall.Errno(0x7c)
- EAGAIN = syscall.Errno(0xb)
- EALREADY = syscall.Errno(0x95)
- EBADE = syscall.Errno(0x32)
- EBADF = syscall.Errno(0x9)
- EBADFD = syscall.Errno(0x51)
- EBADMSG = syscall.Errno(0x4d)
- EBADR = syscall.Errno(0x33)
- EBADRQC = syscall.Errno(0x36)
- EBADSLT = syscall.Errno(0x37)
- EBFONT = syscall.Errno(0x3b)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x9e)
- ECHILD = syscall.Errno(0xa)
- ECHRNG = syscall.Errno(0x25)
- ECOMM = syscall.Errno(0x46)
- ECONNABORTED = syscall.Errno(0x82)
- ECONNREFUSED = syscall.Errno(0x92)
- ECONNRESET = syscall.Errno(0x83)
- EDEADLK = syscall.Errno(0x2d)
- EDEADLOCK = syscall.Errno(0x38)
- EDESTADDRREQ = syscall.Errno(0x60)
- EDOM = syscall.Errno(0x21)
- EDOTDOT = syscall.Errno(0x49)
- EDQUOT = syscall.Errno(0x46d)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EHOSTDOWN = syscall.Errno(0x93)
- EHOSTUNREACH = syscall.Errno(0x94)
- EHWPOISON = syscall.Errno(0xa8)
- EIDRM = syscall.Errno(0x24)
- EILSEQ = syscall.Errno(0x58)
- EINIT = syscall.Errno(0x8d)
- EINPROGRESS = syscall.Errno(0x96)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x85)
- EISDIR = syscall.Errno(0x15)
- EISNAM = syscall.Errno(0x8b)
- EKEYEXPIRED = syscall.Errno(0xa2)
- EKEYREJECTED = syscall.Errno(0xa4)
- EKEYREVOKED = syscall.Errno(0xa3)
- EL2HLT = syscall.Errno(0x2c)
- EL2NSYNC = syscall.Errno(0x26)
- EL3HLT = syscall.Errno(0x27)
- EL3RST = syscall.Errno(0x28)
- ELIBACC = syscall.Errno(0x53)
- ELIBBAD = syscall.Errno(0x54)
- ELIBEXEC = syscall.Errno(0x57)
- ELIBMAX = syscall.Errno(0x56)
- ELIBSCN = syscall.Errno(0x55)
- ELNRNG = syscall.Errno(0x29)
- ELOOP = syscall.Errno(0x5a)
- EMEDIUMTYPE = syscall.Errno(0xa0)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x61)
- EMULTIHOP = syscall.Errno(0x4a)
- ENAMETOOLONG = syscall.Errno(0x4e)
- ENAVAIL = syscall.Errno(0x8a)
- ENETDOWN = syscall.Errno(0x7f)
- ENETRESET = syscall.Errno(0x81)
- ENETUNREACH = syscall.Errno(0x80)
- ENFILE = syscall.Errno(0x17)
- ENOANO = syscall.Errno(0x35)
- ENOBUFS = syscall.Errno(0x84)
- ENOCSI = syscall.Errno(0x2b)
- ENODATA = syscall.Errno(0x3d)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOKEY = syscall.Errno(0xa1)
- ENOLCK = syscall.Errno(0x2e)
- ENOLINK = syscall.Errno(0x43)
- ENOMEDIUM = syscall.Errno(0x9f)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x23)
- ENONET = syscall.Errno(0x40)
- ENOPKG = syscall.Errno(0x41)
- ENOPROTOOPT = syscall.Errno(0x63)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x3f)
- ENOSTR = syscall.Errno(0x3c)
- ENOSYS = syscall.Errno(0x59)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x86)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x5d)
- ENOTNAM = syscall.Errno(0x89)
- ENOTRECOVERABLE = syscall.Errno(0xa6)
- ENOTSOCK = syscall.Errno(0x5f)
- ENOTSUP = syscall.Errno(0x7a)
- ENOTTY = syscall.Errno(0x19)
- ENOTUNIQ = syscall.Errno(0x50)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x7a)
- EOVERFLOW = syscall.Errno(0x4f)
- EOWNERDEAD = syscall.Errno(0xa5)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x7b)
- EPIPE = syscall.Errno(0x20)
- EPROTO = syscall.Errno(0x47)
- EPROTONOSUPPORT = syscall.Errno(0x78)
- EPROTOTYPE = syscall.Errno(0x62)
- ERANGE = syscall.Errno(0x22)
- EREMCHG = syscall.Errno(0x52)
- EREMDEV = syscall.Errno(0x8e)
- EREMOTE = syscall.Errno(0x42)
- EREMOTEIO = syscall.Errno(0x8c)
- ERESTART = syscall.Errno(0x5b)
- ERFKILL = syscall.Errno(0xa7)
- EROFS = syscall.Errno(0x1e)
- ESHUTDOWN = syscall.Errno(0x8f)
- ESOCKTNOSUPPORT = syscall.Errno(0x79)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESRMNT = syscall.Errno(0x45)
- ESTALE = syscall.Errno(0x97)
- ESTRPIPE = syscall.Errno(0x5c)
- ETIME = syscall.Errno(0x3e)
- ETIMEDOUT = syscall.Errno(0x91)
- ETOOMANYREFS = syscall.Errno(0x90)
- ETXTBSY = syscall.Errno(0x1a)
- EUCLEAN = syscall.Errno(0x87)
- EUNATCH = syscall.Errno(0x2a)
- EUSERS = syscall.Errno(0x5e)
- EWOULDBLOCK = syscall.Errno(0xb)
- EXDEV = syscall.Errno(0x12)
- EXFULL = syscall.Errno(0x34)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0xa)
- SIGCHLD = syscall.Signal(0x12)
- SIGCLD = syscall.Signal(0x12)
- SIGCONT = syscall.Signal(0x19)
- SIGEMT = syscall.Signal(0x7)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x16)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPOLL = syscall.Signal(0x16)
- SIGPROF = syscall.Signal(0x1d)
- SIGPWR = syscall.Signal(0x13)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTOP = syscall.Signal(0x17)
- SIGSYS = syscall.Signal(0xc)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x18)
- SIGTTIN = syscall.Signal(0x1a)
- SIGTTOU = syscall.Signal(0x1b)
- SIGURG = syscall.Signal(0x15)
- SIGUSR1 = syscall.Signal(0x10)
- SIGUSR2 = syscall.Signal(0x11)
- SIGVTALRM = syscall.Signal(0x1c)
- SIGWINCH = syscall.Signal(0x14)
- SIGXCPU = syscall.Signal(0x1e)
- SIGXFSZ = syscall.Signal(0x1f)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "no such device or address",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource temporarily unavailable",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device or resource busy",
- 17: "file exists",
- 18: "invalid cross-device link",
- 19: "no such device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "numerical result out of range",
- 35: "no message of desired type",
- 36: "identifier removed",
- 37: "channel number out of range",
- 38: "level 2 not synchronized",
- 39: "level 3 halted",
- 40: "level 3 reset",
- 41: "link number out of range",
- 42: "protocol driver not attached",
- 43: "no CSI structure available",
- 44: "level 2 halted",
- 45: "resource deadlock avoided",
- 46: "no locks available",
- 50: "invalid exchange",
- 51: "invalid request descriptor",
- 52: "exchange full",
- 53: "no anode",
- 54: "invalid request code",
- 55: "invalid slot",
- 56: "file locking deadlock error",
- 59: "bad font file format",
- 60: "device not a stream",
- 61: "no data available",
- 62: "timer expired",
- 63: "out of streams resources",
- 64: "machine is not on the network",
- 65: "package not installed",
- 66: "object is remote",
- 67: "link has been severed",
- 68: "advertise error",
- 69: "srmount error",
- 70: "communication error on send",
- 71: "protocol error",
- 73: "RFS specific error",
- 74: "multihop attempted",
- 77: "bad message",
- 78: "file name too long",
- 79: "value too large for defined data type",
- 80: "name not unique on network",
- 81: "file descriptor in bad state",
- 82: "remote address changed",
- 83: "can not access a needed shared library",
- 84: "accessing a corrupted shared library",
- 85: ".lib section in a.out corrupted",
- 86: "attempting to link in too many shared libraries",
- 87: "cannot exec a shared library directly",
- 88: "invalid or incomplete multibyte or wide character",
- 89: "function not implemented",
- 90: "too many levels of symbolic links",
- 91: "interrupted system call should be restarted",
- 92: "streams pipe error",
- 93: "directory not empty",
- 94: "too many users",
- 95: "socket operation on non-socket",
- 96: "destination address required",
- 97: "message too long",
- 98: "protocol wrong type for socket",
- 99: "protocol not available",
- 120: "protocol not supported",
- 121: "socket type not supported",
- 122: "operation not supported",
- 123: "protocol family not supported",
- 124: "address family not supported by protocol",
- 125: "address already in use",
- 126: "cannot assign requested address",
- 127: "network is down",
- 128: "network is unreachable",
- 129: "network dropped connection on reset",
- 130: "software caused connection abort",
- 131: "connection reset by peer",
- 132: "no buffer space available",
- 133: "transport endpoint is already connected",
- 134: "transport endpoint is not connected",
- 135: "structure needs cleaning",
- 137: "not a XENIX named type file",
- 138: "no XENIX semaphores available",
- 139: "is a named type file",
- 140: "remote I/O error",
- 141: "unknown error 141",
- 142: "unknown error 142",
- 143: "cannot send after transport endpoint shutdown",
- 144: "too many references: cannot splice",
- 145: "connection timed out",
- 146: "connection refused",
- 147: "host is down",
- 148: "no route to host",
- 149: "operation already in progress",
- 150: "operation now in progress",
- 151: "stale file handle",
- 158: "operation canceled",
- 159: "no medium found",
- 160: "wrong medium type",
- 161: "required key not available",
- 162: "key has expired",
- 163: "key has been revoked",
- 164: "key was rejected by service",
- 165: "owner died",
- 166: "state not recoverable",
- 167: "operation not possible due to RF-kill",
- 168: "memory page has hardware error",
- 1133: "disk quota exceeded",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/breakpoint trap",
- 6: "aborted",
- 7: "EMT trap",
- 8: "floating point exception",
- 9: "killed",
- 10: "bus error",
- 11: "segmentation fault",
- 12: "bad system call",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "user defined signal 1",
- 17: "user defined signal 2",
- 18: "child exited",
- 19: "power failure",
- 20: "window changed",
- 21: "urgent I/O condition",
- 22: "I/O possible",
- 23: "stopped (signal)",
- 24: "stopped",
- 25: "continued",
- 26: "stopped (tty input)",
- 27: "stopped (tty output)",
- 28: "virtual timer expired",
- 29: "profiling timer expired",
- 30: "CPU time limit exceeded",
- 31: "file size limit exceeded",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/newt/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
deleted file mode 100644
index 8b42ca2f..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
+++ /dev/null
@@ -1,1970 +0,0 @@
-// mkerrors.sh -m64
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build ppc64,linux
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -m64 _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_ALG = 0x26
- AF_APPLETALK = 0x5
- AF_ASH = 0x12
- AF_ATMPVC = 0x8
- AF_ATMSVC = 0x14
- AF_AX25 = 0x3
- AF_BLUETOOTH = 0x1f
- AF_BRIDGE = 0x7
- AF_CAIF = 0x25
- AF_CAN = 0x1d
- AF_DECnet = 0xc
- AF_ECONET = 0x13
- AF_FILE = 0x1
- AF_IEEE802154 = 0x24
- AF_INET = 0x2
- AF_INET6 = 0xa
- AF_IPX = 0x4
- AF_IRDA = 0x17
- AF_ISDN = 0x22
- AF_IUCV = 0x20
- AF_KEY = 0xf
- AF_LLC = 0x1a
- AF_LOCAL = 0x1
- AF_MAX = 0x29
- AF_NETBEUI = 0xd
- AF_NETLINK = 0x10
- AF_NETROM = 0x6
- AF_NFC = 0x27
- AF_PACKET = 0x11
- AF_PHONET = 0x23
- AF_PPPOX = 0x18
- AF_RDS = 0x15
- AF_ROSE = 0xb
- AF_ROUTE = 0x10
- AF_RXRPC = 0x21
- AF_SECURITY = 0xe
- AF_SNA = 0x16
- AF_TIPC = 0x1e
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_VSOCK = 0x28
- AF_WANPIPE = 0x19
- AF_X25 = 0x9
- ARPHRD_6LOWPAN = 0x339
- ARPHRD_ADAPT = 0x108
- ARPHRD_APPLETLK = 0x8
- ARPHRD_ARCNET = 0x7
- ARPHRD_ASH = 0x30d
- ARPHRD_ATM = 0x13
- ARPHRD_AX25 = 0x3
- ARPHRD_BIF = 0x307
- ARPHRD_CAIF = 0x336
- ARPHRD_CAN = 0x118
- ARPHRD_CHAOS = 0x5
- ARPHRD_CISCO = 0x201
- ARPHRD_CSLIP = 0x101
- ARPHRD_CSLIP6 = 0x103
- ARPHRD_DDCMP = 0x205
- ARPHRD_DLCI = 0xf
- ARPHRD_ECONET = 0x30e
- ARPHRD_EETHER = 0x2
- ARPHRD_ETHER = 0x1
- ARPHRD_EUI64 = 0x1b
- ARPHRD_FCAL = 0x311
- ARPHRD_FCFABRIC = 0x313
- ARPHRD_FCPL = 0x312
- ARPHRD_FCPP = 0x310
- ARPHRD_FDDI = 0x306
- ARPHRD_FRAD = 0x302
- ARPHRD_HDLC = 0x201
- ARPHRD_HIPPI = 0x30c
- ARPHRD_HWX25 = 0x110
- ARPHRD_IEEE1394 = 0x18
- ARPHRD_IEEE802 = 0x6
- ARPHRD_IEEE80211 = 0x321
- ARPHRD_IEEE80211_PRISM = 0x322
- ARPHRD_IEEE80211_RADIOTAP = 0x323
- ARPHRD_IEEE802154 = 0x324
- ARPHRD_IEEE802154_MONITOR = 0x325
- ARPHRD_IEEE802_TR = 0x320
- ARPHRD_INFINIBAND = 0x20
- ARPHRD_IP6GRE = 0x337
- ARPHRD_IPDDP = 0x309
- ARPHRD_IPGRE = 0x30a
- ARPHRD_IRDA = 0x30f
- ARPHRD_LAPB = 0x204
- ARPHRD_LOCALTLK = 0x305
- ARPHRD_LOOPBACK = 0x304
- ARPHRD_METRICOM = 0x17
- ARPHRD_NETLINK = 0x338
- ARPHRD_NETROM = 0x0
- ARPHRD_NONE = 0xfffe
- ARPHRD_PHONET = 0x334
- ARPHRD_PHONET_PIPE = 0x335
- ARPHRD_PIMREG = 0x30b
- ARPHRD_PPP = 0x200
- ARPHRD_PRONET = 0x4
- ARPHRD_RAWHDLC = 0x206
- ARPHRD_ROSE = 0x10e
- ARPHRD_RSRVD = 0x104
- ARPHRD_SIT = 0x308
- ARPHRD_SKIP = 0x303
- ARPHRD_SLIP = 0x100
- ARPHRD_SLIP6 = 0x102
- ARPHRD_TUNNEL = 0x300
- ARPHRD_TUNNEL6 = 0x301
- ARPHRD_VOID = 0xffff
- ARPHRD_X25 = 0x10f
- B0 = 0x0
- B1000000 = 0x17
- B110 = 0x3
- B115200 = 0x11
- B1152000 = 0x18
- B1200 = 0x9
- B134 = 0x4
- B150 = 0x5
- B1500000 = 0x19
- B1800 = 0xa
- B19200 = 0xe
- B200 = 0x6
- B2000000 = 0x1a
- B230400 = 0x12
- B2400 = 0xb
- B2500000 = 0x1b
- B300 = 0x7
- B3000000 = 0x1c
- B3500000 = 0x1d
- B38400 = 0xf
- B4000000 = 0x1e
- B460800 = 0x13
- B4800 = 0xc
- B50 = 0x1
- B500000 = 0x14
- B57600 = 0x10
- B576000 = 0x15
- B600 = 0x8
- B75 = 0x2
- B921600 = 0x16
- B9600 = 0xd
- BOTHER = 0x1f
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXINSNS = 0x1000
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MOD = 0x90
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BPF_XOR = 0xa0
- BRKINT = 0x2
- BS0 = 0x0
- BS1 = 0x8000
- BSDLY = 0x8000
- CBAUD = 0xff
- CBAUDEX = 0x0
- CFLUSH = 0xf
- CIBAUD = 0xff0000
- CLOCAL = 0x8000
- CLOCK_BOOTTIME = 0x7
- CLOCK_BOOTTIME_ALARM = 0x9
- CLOCK_DEFAULT = 0x0
- CLOCK_EXT = 0x1
- CLOCK_INT = 0x2
- CLOCK_MONOTONIC = 0x1
- CLOCK_MONOTONIC_COARSE = 0x6
- CLOCK_MONOTONIC_RAW = 0x4
- CLOCK_PROCESS_CPUTIME_ID = 0x2
- CLOCK_REALTIME = 0x0
- CLOCK_REALTIME_ALARM = 0x8
- CLOCK_REALTIME_COARSE = 0x5
- CLOCK_THREAD_CPUTIME_ID = 0x3
- CLOCK_TXFROMRX = 0x4
- CLOCK_TXINT = 0x3
- CLONE_CHILD_CLEARTID = 0x200000
- CLONE_CHILD_SETTID = 0x1000000
- CLONE_DETACHED = 0x400000
- CLONE_FILES = 0x400
- CLONE_FS = 0x200
- CLONE_IO = 0x80000000
- CLONE_NEWCGROUP = 0x2000000
- CLONE_NEWIPC = 0x8000000
- CLONE_NEWNET = 0x40000000
- CLONE_NEWNS = 0x20000
- CLONE_NEWPID = 0x20000000
- CLONE_NEWUSER = 0x10000000
- CLONE_NEWUTS = 0x4000000
- CLONE_PARENT = 0x8000
- CLONE_PARENT_SETTID = 0x100000
- CLONE_PTRACE = 0x2000
- CLONE_SETTLS = 0x80000
- CLONE_SIGHAND = 0x800
- CLONE_SYSVSEM = 0x40000
- CLONE_THREAD = 0x10000
- CLONE_UNTRACED = 0x800000
- CLONE_VFORK = 0x4000
- CLONE_VM = 0x100
- CMSPAR = 0x40000000
- CR0 = 0x0
- CR1 = 0x1000
- CR2 = 0x2000
- CR3 = 0x3000
- CRDLY = 0x3000
- CREAD = 0x800
- CRTSCTS = 0x80000000
- CS5 = 0x0
- CS6 = 0x100
- CS7 = 0x200
- CS8 = 0x300
- CSIGNAL = 0xff
- CSIZE = 0x300
- CSTART = 0x11
- CSTATUS = 0x0
- CSTOP = 0x13
- CSTOPB = 0x400
- CSUSP = 0x1a
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x40
- ECHOE = 0x2
- ECHOK = 0x4
- ECHOKE = 0x1
- ECHONL = 0x10
- ECHOPRT = 0x20
- ENCODING_DEFAULT = 0x0
- ENCODING_FM_MARK = 0x3
- ENCODING_FM_SPACE = 0x4
- ENCODING_MANCHESTER = 0x5
- ENCODING_NRZ = 0x1
- ENCODING_NRZI = 0x2
- EPOLLERR = 0x8
- EPOLLET = 0x80000000
- EPOLLHUP = 0x10
- EPOLLIN = 0x1
- EPOLLMSG = 0x400
- EPOLLONESHOT = 0x40000000
- EPOLLOUT = 0x4
- EPOLLPRI = 0x2
- EPOLLRDBAND = 0x80
- EPOLLRDHUP = 0x2000
- EPOLLRDNORM = 0x40
- EPOLLWAKEUP = 0x20000000
- EPOLLWRBAND = 0x200
- EPOLLWRNORM = 0x100
- EPOLL_CLOEXEC = 0x80000
- EPOLL_CTL_ADD = 0x1
- EPOLL_CTL_DEL = 0x2
- EPOLL_CTL_MOD = 0x3
- ETH_P_1588 = 0x88f7
- ETH_P_8021AD = 0x88a8
- ETH_P_8021AH = 0x88e7
- ETH_P_8021Q = 0x8100
- ETH_P_80221 = 0x8917
- ETH_P_802_2 = 0x4
- ETH_P_802_3 = 0x1
- ETH_P_802_3_MIN = 0x600
- ETH_P_802_EX1 = 0x88b5
- ETH_P_AARP = 0x80f3
- ETH_P_AF_IUCV = 0xfbfb
- ETH_P_ALL = 0x3
- ETH_P_AOE = 0x88a2
- ETH_P_ARCNET = 0x1a
- ETH_P_ARP = 0x806
- ETH_P_ATALK = 0x809b
- ETH_P_ATMFATE = 0x8884
- ETH_P_ATMMPOA = 0x884c
- ETH_P_AX25 = 0x2
- ETH_P_BATMAN = 0x4305
- ETH_P_BPQ = 0x8ff
- ETH_P_CAIF = 0xf7
- ETH_P_CAN = 0xc
- ETH_P_CANFD = 0xd
- ETH_P_CONTROL = 0x16
- ETH_P_CUST = 0x6006
- ETH_P_DDCMP = 0x6
- ETH_P_DEC = 0x6000
- ETH_P_DIAG = 0x6005
- ETH_P_DNA_DL = 0x6001
- ETH_P_DNA_RC = 0x6002
- ETH_P_DNA_RT = 0x6003
- ETH_P_DSA = 0x1b
- ETH_P_ECONET = 0x18
- ETH_P_EDSA = 0xdada
- ETH_P_FCOE = 0x8906
- ETH_P_FIP = 0x8914
- ETH_P_HDLC = 0x19
- ETH_P_IEEE802154 = 0xf6
- ETH_P_IEEEPUP = 0xa00
- ETH_P_IEEEPUPAT = 0xa01
- ETH_P_IP = 0x800
- ETH_P_IPV6 = 0x86dd
- ETH_P_IPX = 0x8137
- ETH_P_IRDA = 0x17
- ETH_P_LAT = 0x6004
- ETH_P_LINK_CTL = 0x886c
- ETH_P_LOCALTALK = 0x9
- ETH_P_LOOP = 0x60
- ETH_P_LOOPBACK = 0x9000
- ETH_P_MOBITEX = 0x15
- ETH_P_MPLS_MC = 0x8848
- ETH_P_MPLS_UC = 0x8847
- ETH_P_MVRP = 0x88f5
- ETH_P_PAE = 0x888e
- ETH_P_PAUSE = 0x8808
- ETH_P_PHONET = 0xf5
- ETH_P_PPPTALK = 0x10
- ETH_P_PPP_DISC = 0x8863
- ETH_P_PPP_MP = 0x8
- ETH_P_PPP_SES = 0x8864
- ETH_P_PRP = 0x88fb
- ETH_P_PUP = 0x200
- ETH_P_PUPAT = 0x201
- ETH_P_QINQ1 = 0x9100
- ETH_P_QINQ2 = 0x9200
- ETH_P_QINQ3 = 0x9300
- ETH_P_RARP = 0x8035
- ETH_P_SCA = 0x6007
- ETH_P_SLOW = 0x8809
- ETH_P_SNAP = 0x5
- ETH_P_TDLS = 0x890d
- ETH_P_TEB = 0x6558
- ETH_P_TIPC = 0x88ca
- ETH_P_TRAILER = 0x1c
- ETH_P_TR_802_2 = 0x11
- ETH_P_WAN_PPP = 0x7
- ETH_P_WCCP = 0x883e
- ETH_P_X25 = 0x805
- ETH_P_XDSA = 0xf8
- EXTA = 0xe
- EXTB = 0xf
- EXTPROC = 0x10000000
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FF0 = 0x0
- FF1 = 0x4000
- FFDLY = 0x4000
- FLUSHO = 0x800000
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x406
- F_EXLCK = 0x4
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLEASE = 0x401
- F_GETLK = 0x5
- F_GETLK64 = 0xc
- F_GETOWN = 0x9
- F_GETOWN_EX = 0x10
- F_GETPIPE_SZ = 0x408
- F_GETSIG = 0xb
- F_LOCK = 0x1
- F_NOTIFY = 0x402
- F_OFD_GETLK = 0x24
- F_OFD_SETLK = 0x25
- F_OFD_SETLKW = 0x26
- F_OK = 0x0
- F_RDLCK = 0x0
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLEASE = 0x400
- F_SETLK = 0x6
- F_SETLK64 = 0xd
- F_SETLKW = 0x7
- F_SETLKW64 = 0xe
- F_SETOWN = 0x8
- F_SETOWN_EX = 0xf
- F_SETPIPE_SZ = 0x407
- F_SETSIG = 0xa
- F_SHLCK = 0x8
- F_TEST = 0x3
- F_TLOCK = 0x2
- F_ULOCK = 0x0
- F_UNLCK = 0x2
- F_WRLCK = 0x1
- HUPCL = 0x4000
- IBSHIFT = 0x10
- ICANON = 0x100
- ICMPV6_FILTER = 0x1
- ICRNL = 0x100
- IEXTEN = 0x400
- IFA_F_DADFAILED = 0x8
- IFA_F_DEPRECATED = 0x20
- IFA_F_HOMEADDRESS = 0x10
- IFA_F_MANAGETEMPADDR = 0x100
- IFA_F_NODAD = 0x2
- IFA_F_NOPREFIXROUTE = 0x200
- IFA_F_OPTIMISTIC = 0x4
- IFA_F_PERMANENT = 0x80
- IFA_F_SECONDARY = 0x1
- IFA_F_TEMPORARY = 0x1
- IFA_F_TENTATIVE = 0x40
- IFA_MAX = 0x8
- IFF_ALLMULTI = 0x200
- IFF_ATTACH_QUEUE = 0x200
- IFF_AUTOMEDIA = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_DETACH_QUEUE = 0x400
- IFF_DORMANT = 0x20000
- IFF_DYNAMIC = 0x8000
- IFF_ECHO = 0x40000
- IFF_LOOPBACK = 0x8
- IFF_LOWER_UP = 0x10000
- IFF_MASTER = 0x400
- IFF_MULTICAST = 0x1000
- IFF_MULTI_QUEUE = 0x100
- IFF_NOARP = 0x80
- IFF_NOFILTER = 0x1000
- IFF_NOTRAILERS = 0x20
- IFF_NO_PI = 0x1000
- IFF_ONE_QUEUE = 0x2000
- IFF_PERSIST = 0x800
- IFF_POINTOPOINT = 0x10
- IFF_PORTSEL = 0x2000
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SLAVE = 0x800
- IFF_TAP = 0x2
- IFF_TUN = 0x1
- IFF_TUN_EXCL = 0x8000
- IFF_UP = 0x1
- IFF_VNET_HDR = 0x4000
- IFF_VOLATILE = 0x70c5a
- IFNAMSIZ = 0x10
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_ACCESS = 0x1
- IN_ALL_EVENTS = 0xfff
- IN_ATTRIB = 0x4
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLOEXEC = 0x80000
- IN_CLOSE = 0x18
- IN_CLOSE_NOWRITE = 0x10
- IN_CLOSE_WRITE = 0x8
- IN_CREATE = 0x100
- IN_DELETE = 0x200
- IN_DELETE_SELF = 0x400
- IN_DONT_FOLLOW = 0x2000000
- IN_EXCL_UNLINK = 0x4000000
- IN_IGNORED = 0x8000
- IN_ISDIR = 0x40000000
- IN_LOOPBACKNET = 0x7f
- IN_MASK_ADD = 0x20000000
- IN_MODIFY = 0x2
- IN_MOVE = 0xc0
- IN_MOVED_FROM = 0x40
- IN_MOVED_TO = 0x80
- IN_MOVE_SELF = 0x800
- IN_NONBLOCK = 0x800
- IN_ONESHOT = 0x80000000
- IN_ONLYDIR = 0x1000000
- IN_OPEN = 0x20
- IN_Q_OVERFLOW = 0x4000
- IN_UNMOUNT = 0x2000
- IPPROTO_AH = 0x33
- IPPROTO_BEETPH = 0x5e
- IPPROTO_COMP = 0x6c
- IPPROTO_DCCP = 0x21
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_ENCAP = 0x62
- IPPROTO_ESP = 0x32
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GRE = 0x2f
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IGMP = 0x2
- IPPROTO_IP = 0x0
- IPPROTO_IPIP = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_MH = 0x87
- IPPROTO_MTP = 0x5c
- IPPROTO_NONE = 0x3b
- IPPROTO_PIM = 0x67
- IPPROTO_PUP = 0xc
- IPPROTO_RAW = 0xff
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_SCTP = 0x84
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_UDP = 0x11
- IPPROTO_UDPLITE = 0x88
- IPV6_2292DSTOPTS = 0x4
- IPV6_2292HOPLIMIT = 0x8
- IPV6_2292HOPOPTS = 0x3
- IPV6_2292PKTINFO = 0x2
- IPV6_2292PKTOPTIONS = 0x6
- IPV6_2292RTHDR = 0x5
- IPV6_ADDRFORM = 0x1
- IPV6_ADD_MEMBERSHIP = 0x14
- IPV6_AUTHHDR = 0xa
- IPV6_CHECKSUM = 0x7
- IPV6_DROP_MEMBERSHIP = 0x15
- IPV6_DSTOPTS = 0x3b
- IPV6_HOPLIMIT = 0x34
- IPV6_HOPOPTS = 0x36
- IPV6_IPSEC_POLICY = 0x22
- IPV6_JOIN_ANYCAST = 0x1b
- IPV6_JOIN_GROUP = 0x14
- IPV6_LEAVE_ANYCAST = 0x1c
- IPV6_LEAVE_GROUP = 0x15
- IPV6_MTU = 0x18
- IPV6_MTU_DISCOVER = 0x17
- IPV6_MULTICAST_HOPS = 0x12
- IPV6_MULTICAST_IF = 0x11
- IPV6_MULTICAST_LOOP = 0x13
- IPV6_NEXTHOP = 0x9
- IPV6_PKTINFO = 0x32
- IPV6_PMTUDISC_DO = 0x2
- IPV6_PMTUDISC_DONT = 0x0
- IPV6_PMTUDISC_INTERFACE = 0x4
- IPV6_PMTUDISC_OMIT = 0x5
- IPV6_PMTUDISC_PROBE = 0x3
- IPV6_PMTUDISC_WANT = 0x1
- IPV6_RECVDSTOPTS = 0x3a
- IPV6_RECVERR = 0x19
- IPV6_RECVHOPLIMIT = 0x33
- IPV6_RECVHOPOPTS = 0x35
- IPV6_RECVPKTINFO = 0x31
- IPV6_RECVRTHDR = 0x38
- IPV6_RECVTCLASS = 0x42
- IPV6_ROUTER_ALERT = 0x16
- IPV6_RTHDR = 0x39
- IPV6_RTHDRDSTOPTS = 0x37
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_RXDSTOPTS = 0x3b
- IPV6_RXHOPOPTS = 0x36
- IPV6_TCLASS = 0x43
- IPV6_UNICAST_HOPS = 0x10
- IPV6_V6ONLY = 0x1a
- IPV6_XFRM_POLICY = 0x23
- IP_ADD_MEMBERSHIP = 0x23
- IP_ADD_SOURCE_MEMBERSHIP = 0x27
- IP_BLOCK_SOURCE = 0x26
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0x24
- IP_DROP_SOURCE_MEMBERSHIP = 0x28
- IP_FREEBIND = 0xf
- IP_HDRINCL = 0x3
- IP_IPSEC_POLICY = 0x10
- IP_MAXPACKET = 0xffff
- IP_MAX_MEMBERSHIPS = 0x14
- IP_MF = 0x2000
- IP_MINTTL = 0x15
- IP_MSFILTER = 0x29
- IP_MSS = 0x240
- IP_MTU = 0xe
- IP_MTU_DISCOVER = 0xa
- IP_MULTICAST_ALL = 0x31
- IP_MULTICAST_IF = 0x20
- IP_MULTICAST_LOOP = 0x22
- IP_MULTICAST_TTL = 0x21
- IP_NODEFRAG = 0x16
- IP_OFFMASK = 0x1fff
- IP_OPTIONS = 0x4
- IP_ORIGDSTADDR = 0x14
- IP_PASSSEC = 0x12
- IP_PKTINFO = 0x8
- IP_PKTOPTIONS = 0x9
- IP_PMTUDISC = 0xa
- IP_PMTUDISC_DO = 0x2
- IP_PMTUDISC_DONT = 0x0
- IP_PMTUDISC_INTERFACE = 0x4
- IP_PMTUDISC_OMIT = 0x5
- IP_PMTUDISC_PROBE = 0x3
- IP_PMTUDISC_WANT = 0x1
- IP_RECVERR = 0xb
- IP_RECVOPTS = 0x6
- IP_RECVORIGDSTADDR = 0x14
- IP_RECVRETOPTS = 0x7
- IP_RECVTOS = 0xd
- IP_RECVTTL = 0xc
- IP_RETOPTS = 0x7
- IP_RF = 0x8000
- IP_ROUTER_ALERT = 0x5
- IP_TOS = 0x1
- IP_TRANSPARENT = 0x13
- IP_TTL = 0x2
- IP_UNBLOCK_SOURCE = 0x25
- IP_UNICAST_IF = 0x32
- IP_XFRM_POLICY = 0x11
- ISIG = 0x80
- ISTRIP = 0x20
- IUCLC = 0x1000
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x400
- IXON = 0x200
- LINUX_REBOOT_CMD_CAD_OFF = 0x0
- LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
- LINUX_REBOOT_CMD_HALT = 0xcdef0123
- LINUX_REBOOT_CMD_KEXEC = 0x45584543
- LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
- LINUX_REBOOT_CMD_RESTART = 0x1234567
- LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
- LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
- LINUX_REBOOT_MAGIC1 = 0xfee1dead
- LINUX_REBOOT_MAGIC2 = 0x28121969
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_DODUMP = 0x11
- MADV_DOFORK = 0xb
- MADV_DONTDUMP = 0x10
- MADV_DONTFORK = 0xa
- MADV_DONTNEED = 0x4
- MADV_HUGEPAGE = 0xe
- MADV_HWPOISON = 0x64
- MADV_MERGEABLE = 0xc
- MADV_NOHUGEPAGE = 0xf
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_REMOVE = 0x9
- MADV_SEQUENTIAL = 0x2
- MADV_UNMERGEABLE = 0xd
- MADV_WILLNEED = 0x3
- MAP_ANON = 0x20
- MAP_ANONYMOUS = 0x20
- MAP_DENYWRITE = 0x800
- MAP_EXECUTABLE = 0x1000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_GROWSDOWN = 0x100
- MAP_HUGETLB = 0x40000
- MAP_HUGE_MASK = 0x3f
- MAP_HUGE_SHIFT = 0x1a
- MAP_LOCKED = 0x80
- MAP_NONBLOCK = 0x10000
- MAP_NORESERVE = 0x40
- MAP_POPULATE = 0x8000
- MAP_PRIVATE = 0x2
- MAP_SHARED = 0x1
- MAP_STACK = 0x20000
- MAP_TYPE = 0xf
- MCL_CURRENT = 0x2000
- MCL_FUTURE = 0x4000
- MNT_DETACH = 0x2
- MNT_EXPIRE = 0x4
- MNT_FORCE = 0x1
- MSG_CMSG_CLOEXEC = 0x40000000
- MSG_CONFIRM = 0x800
- MSG_CTRUNC = 0x8
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x40
- MSG_EOR = 0x80
- MSG_ERRQUEUE = 0x2000
- MSG_FASTOPEN = 0x20000000
- MSG_FIN = 0x200
- MSG_MORE = 0x8000
- MSG_NOSIGNAL = 0x4000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_PROXY = 0x10
- MSG_RST = 0x1000
- MSG_SYN = 0x400
- MSG_TRUNC = 0x20
- MSG_TRYHARD = 0x4
- MSG_WAITALL = 0x100
- MSG_WAITFORONE = 0x10000
- MS_ACTIVE = 0x40000000
- MS_ASYNC = 0x1
- MS_BIND = 0x1000
- MS_DIRSYNC = 0x80
- MS_INVALIDATE = 0x2
- MS_I_VERSION = 0x800000
- MS_KERNMOUNT = 0x400000
- MS_MANDLOCK = 0x40
- MS_MGC_MSK = 0xffff0000
- MS_MGC_VAL = 0xc0ed0000
- MS_MOVE = 0x2000
- MS_NOATIME = 0x400
- MS_NODEV = 0x4
- MS_NODIRATIME = 0x800
- MS_NOEXEC = 0x8
- MS_NOSUID = 0x2
- MS_NOUSER = -0x80000000
- MS_POSIXACL = 0x10000
- MS_PRIVATE = 0x40000
- MS_RDONLY = 0x1
- MS_REC = 0x4000
- MS_RELATIME = 0x200000
- MS_REMOUNT = 0x20
- MS_RMT_MASK = 0x800051
- MS_SHARED = 0x100000
- MS_SILENT = 0x8000
- MS_SLAVE = 0x80000
- MS_STRICTATIME = 0x1000000
- MS_SYNC = 0x4
- MS_SYNCHRONOUS = 0x10
- MS_UNBINDABLE = 0x20000
- NAME_MAX = 0xff
- NETLINK_ADD_MEMBERSHIP = 0x1
- NETLINK_AUDIT = 0x9
- NETLINK_BROADCAST_ERROR = 0x4
- NETLINK_CONNECTOR = 0xb
- NETLINK_CRYPTO = 0x15
- NETLINK_DNRTMSG = 0xe
- NETLINK_DROP_MEMBERSHIP = 0x2
- NETLINK_ECRYPTFS = 0x13
- NETLINK_FIB_LOOKUP = 0xa
- NETLINK_FIREWALL = 0x3
- NETLINK_GENERIC = 0x10
- NETLINK_INET_DIAG = 0x4
- NETLINK_IP6_FW = 0xd
- NETLINK_ISCSI = 0x8
- NETLINK_KOBJECT_UEVENT = 0xf
- NETLINK_NETFILTER = 0xc
- NETLINK_NFLOG = 0x5
- NETLINK_NO_ENOBUFS = 0x5
- NETLINK_PKTINFO = 0x3
- NETLINK_RDMA = 0x14
- NETLINK_ROUTE = 0x0
- NETLINK_RX_RING = 0x6
- NETLINK_SCSITRANSPORT = 0x12
- NETLINK_SELINUX = 0x7
- NETLINK_SOCK_DIAG = 0x4
- NETLINK_TX_RING = 0x7
- NETLINK_UNUSED = 0x1
- NETLINK_USERSOCK = 0x2
- NETLINK_XFRM = 0x6
- NL0 = 0x0
- NL1 = 0x100
- NL2 = 0x200
- NL3 = 0x300
- NLA_ALIGNTO = 0x4
- NLA_F_NESTED = 0x8000
- NLA_F_NET_BYTEORDER = 0x4000
- NLA_HDRLEN = 0x4
- NLDLY = 0x300
- NLMSG_ALIGNTO = 0x4
- NLMSG_DONE = 0x3
- NLMSG_ERROR = 0x2
- NLMSG_HDRLEN = 0x10
- NLMSG_MIN_TYPE = 0x10
- NLMSG_NOOP = 0x1
- NLMSG_OVERRUN = 0x4
- NLM_F_ACK = 0x4
- NLM_F_APPEND = 0x800
- NLM_F_ATOMIC = 0x400
- NLM_F_CREATE = 0x400
- NLM_F_DUMP = 0x300
- NLM_F_DUMP_INTR = 0x10
- NLM_F_ECHO = 0x8
- NLM_F_EXCL = 0x200
- NLM_F_MATCH = 0x200
- NLM_F_MULTI = 0x2
- NLM_F_REPLACE = 0x100
- NLM_F_REQUEST = 0x1
- NLM_F_ROOT = 0x100
- NOFLSH = 0x80000000
- OCRNL = 0x8
- OFDEL = 0x80
- OFILL = 0x40
- OLCUC = 0x4
- ONLCR = 0x2
- ONLRET = 0x20
- ONOCR = 0x10
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x400
- O_ASYNC = 0x2000
- O_CLOEXEC = 0x80000
- O_CREAT = 0x40
- O_DIRECT = 0x20000
- O_DIRECTORY = 0x4000
- O_DSYNC = 0x1000
- O_EXCL = 0x80
- O_FSYNC = 0x101000
- O_LARGEFILE = 0x0
- O_NDELAY = 0x800
- O_NOATIME = 0x40000
- O_NOCTTY = 0x100
- O_NOFOLLOW = 0x8000
- O_NONBLOCK = 0x800
- O_PATH = 0x200000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_RSYNC = 0x101000
- O_SYNC = 0x101000
- O_TMPFILE = 0x410000
- O_TRUNC = 0x200
- O_WRONLY = 0x1
- PACKET_ADD_MEMBERSHIP = 0x1
- PACKET_AUXDATA = 0x8
- PACKET_BROADCAST = 0x1
- PACKET_COPY_THRESH = 0x7
- PACKET_DROP_MEMBERSHIP = 0x2
- PACKET_FANOUT = 0x12
- PACKET_FANOUT_CPU = 0x2
- PACKET_FANOUT_FLAG_DEFRAG = 0x8000
- PACKET_FANOUT_FLAG_ROLLOVER = 0x1000
- PACKET_FANOUT_HASH = 0x0
- PACKET_FANOUT_LB = 0x1
- PACKET_FANOUT_QM = 0x5
- PACKET_FANOUT_RND = 0x4
- PACKET_FANOUT_ROLLOVER = 0x3
- PACKET_FASTROUTE = 0x6
- PACKET_HDRLEN = 0xb
- PACKET_HOST = 0x0
- PACKET_KERNEL = 0x7
- PACKET_LOOPBACK = 0x5
- PACKET_LOSS = 0xe
- PACKET_MR_ALLMULTI = 0x2
- PACKET_MR_MULTICAST = 0x0
- PACKET_MR_PROMISC = 0x1
- PACKET_MR_UNICAST = 0x3
- PACKET_MULTICAST = 0x2
- PACKET_ORIGDEV = 0x9
- PACKET_OTHERHOST = 0x3
- PACKET_OUTGOING = 0x4
- PACKET_QDISC_BYPASS = 0x14
- PACKET_RECV_OUTPUT = 0x3
- PACKET_RESERVE = 0xc
- PACKET_RX_RING = 0x5
- PACKET_STATISTICS = 0x6
- PACKET_TIMESTAMP = 0x11
- PACKET_TX_HAS_OFF = 0x13
- PACKET_TX_RING = 0xd
- PACKET_TX_TIMESTAMP = 0x10
- PACKET_USER = 0x6
- PACKET_VERSION = 0xa
- PACKET_VNET_HDR = 0xf
- PARENB = 0x1000
- PARITY_CRC16_PR0 = 0x2
- PARITY_CRC16_PR0_CCITT = 0x4
- PARITY_CRC16_PR1 = 0x3
- PARITY_CRC16_PR1_CCITT = 0x5
- PARITY_CRC32_PR0_CCITT = 0x6
- PARITY_CRC32_PR1_CCITT = 0x7
- PARITY_DEFAULT = 0x0
- PARITY_NONE = 0x1
- PARMRK = 0x8
- PARODD = 0x2000
- PENDIN = 0x20000000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_GROWSDOWN = 0x1000000
- PROT_GROWSUP = 0x2000000
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_SAO = 0x10
- PROT_WRITE = 0x2
- PR_CAPBSET_DROP = 0x18
- PR_CAPBSET_READ = 0x17
- PR_ENDIAN_BIG = 0x0
- PR_ENDIAN_LITTLE = 0x1
- PR_ENDIAN_PPC_LITTLE = 0x2
- PR_FPEMU_NOPRINT = 0x1
- PR_FPEMU_SIGFPE = 0x2
- PR_FP_EXC_ASYNC = 0x2
- PR_FP_EXC_DISABLED = 0x0
- PR_FP_EXC_DIV = 0x10000
- PR_FP_EXC_INV = 0x100000
- PR_FP_EXC_NONRECOV = 0x1
- PR_FP_EXC_OVF = 0x20000
- PR_FP_EXC_PRECISE = 0x3
- PR_FP_EXC_RES = 0x80000
- PR_FP_EXC_SW_ENABLE = 0x80
- PR_FP_EXC_UND = 0x40000
- PR_GET_CHILD_SUBREAPER = 0x25
- PR_GET_DUMPABLE = 0x3
- PR_GET_ENDIAN = 0x13
- PR_GET_FPEMU = 0x9
- PR_GET_FPEXC = 0xb
- PR_GET_KEEPCAPS = 0x7
- PR_GET_NAME = 0x10
- PR_GET_NO_NEW_PRIVS = 0x27
- PR_GET_PDEATHSIG = 0x2
- PR_GET_SECCOMP = 0x15
- PR_GET_SECUREBITS = 0x1b
- PR_GET_THP_DISABLE = 0x2a
- PR_GET_TID_ADDRESS = 0x28
- PR_GET_TIMERSLACK = 0x1e
- PR_GET_TIMING = 0xd
- PR_GET_TSC = 0x19
- PR_GET_UNALIGN = 0x5
- PR_MCE_KILL = 0x21
- PR_MCE_KILL_CLEAR = 0x0
- PR_MCE_KILL_DEFAULT = 0x2
- PR_MCE_KILL_EARLY = 0x1
- PR_MCE_KILL_GET = 0x22
- PR_MCE_KILL_LATE = 0x0
- PR_MCE_KILL_SET = 0x1
- PR_SET_CHILD_SUBREAPER = 0x24
- PR_SET_DUMPABLE = 0x4
- PR_SET_ENDIAN = 0x14
- PR_SET_FPEMU = 0xa
- PR_SET_FPEXC = 0xc
- PR_SET_KEEPCAPS = 0x8
- PR_SET_MM = 0x23
- PR_SET_MM_ARG_END = 0x9
- PR_SET_MM_ARG_START = 0x8
- PR_SET_MM_AUXV = 0xc
- PR_SET_MM_BRK = 0x7
- PR_SET_MM_END_CODE = 0x2
- PR_SET_MM_END_DATA = 0x4
- PR_SET_MM_ENV_END = 0xb
- PR_SET_MM_ENV_START = 0xa
- PR_SET_MM_EXE_FILE = 0xd
- PR_SET_MM_MAP = 0xe
- PR_SET_MM_MAP_SIZE = 0xf
- PR_SET_MM_START_BRK = 0x6
- PR_SET_MM_START_CODE = 0x1
- PR_SET_MM_START_DATA = 0x3
- PR_SET_MM_START_STACK = 0x5
- PR_SET_NAME = 0xf
- PR_SET_NO_NEW_PRIVS = 0x26
- PR_SET_PDEATHSIG = 0x1
- PR_SET_PTRACER = 0x59616d61
- PR_SET_PTRACER_ANY = -0x1
- PR_SET_SECCOMP = 0x16
- PR_SET_SECUREBITS = 0x1c
- PR_SET_THP_DISABLE = 0x29
- PR_SET_TIMERSLACK = 0x1d
- PR_SET_TIMING = 0xe
- PR_SET_TSC = 0x1a
- PR_SET_UNALIGN = 0x6
- PR_TASK_PERF_EVENTS_DISABLE = 0x1f
- PR_TASK_PERF_EVENTS_ENABLE = 0x20
- PR_TIMING_STATISTICAL = 0x0
- PR_TIMING_TIMESTAMP = 0x1
- PR_TSC_ENABLE = 0x1
- PR_TSC_SIGSEGV = 0x2
- PR_UNALIGN_NOPRINT = 0x1
- PR_UNALIGN_SIGBUS = 0x2
- PTRACE_ATTACH = 0x10
- PTRACE_CONT = 0x7
- PTRACE_DETACH = 0x11
- PTRACE_EVENT_CLONE = 0x3
- PTRACE_EVENT_EXEC = 0x4
- PTRACE_EVENT_EXIT = 0x6
- PTRACE_EVENT_FORK = 0x1
- PTRACE_EVENT_SECCOMP = 0x7
- PTRACE_EVENT_STOP = 0x80
- PTRACE_EVENT_VFORK = 0x2
- PTRACE_EVENT_VFORK_DONE = 0x5
- PTRACE_GETEVENTMSG = 0x4201
- PTRACE_GETEVRREGS = 0x14
- PTRACE_GETFPREGS = 0xe
- PTRACE_GETREGS = 0xc
- PTRACE_GETREGS64 = 0x16
- PTRACE_GETREGSET = 0x4204
- PTRACE_GETSIGINFO = 0x4202
- PTRACE_GETSIGMASK = 0x420a
- PTRACE_GETVRREGS = 0x12
- PTRACE_GETVSRREGS = 0x1b
- PTRACE_GET_DEBUGREG = 0x19
- PTRACE_INTERRUPT = 0x4207
- PTRACE_KILL = 0x8
- PTRACE_LISTEN = 0x4208
- PTRACE_O_EXITKILL = 0x100000
- PTRACE_O_MASK = 0x1000ff
- PTRACE_O_TRACECLONE = 0x8
- PTRACE_O_TRACEEXEC = 0x10
- PTRACE_O_TRACEEXIT = 0x40
- PTRACE_O_TRACEFORK = 0x2
- PTRACE_O_TRACESECCOMP = 0x80
- PTRACE_O_TRACESYSGOOD = 0x1
- PTRACE_O_TRACEVFORK = 0x4
- PTRACE_O_TRACEVFORKDONE = 0x20
- PTRACE_PEEKDATA = 0x2
- PTRACE_PEEKSIGINFO = 0x4209
- PTRACE_PEEKSIGINFO_SHARED = 0x1
- PTRACE_PEEKTEXT = 0x1
- PTRACE_PEEKUSR = 0x3
- PTRACE_POKEDATA = 0x5
- PTRACE_POKETEXT = 0x4
- PTRACE_POKEUSR = 0x6
- PTRACE_SEIZE = 0x4206
- PTRACE_SETEVRREGS = 0x15
- PTRACE_SETFPREGS = 0xf
- PTRACE_SETOPTIONS = 0x4200
- PTRACE_SETREGS = 0xd
- PTRACE_SETREGS64 = 0x17
- PTRACE_SETREGSET = 0x4205
- PTRACE_SETSIGINFO = 0x4203
- PTRACE_SETSIGMASK = 0x420b
- PTRACE_SETVRREGS = 0x13
- PTRACE_SETVSRREGS = 0x1c
- PTRACE_SET_DEBUGREG = 0x1a
- PTRACE_SINGLEBLOCK = 0x100
- PTRACE_SINGLESTEP = 0x9
- PTRACE_SYSCALL = 0x18
- PTRACE_TRACEME = 0x0
- PT_CCR = 0x26
- PT_CTR = 0x23
- PT_DAR = 0x29
- PT_DSCR = 0x2c
- PT_DSISR = 0x2a
- PT_FPR0 = 0x30
- PT_FPSCR = 0x50
- PT_LNK = 0x24
- PT_MSR = 0x21
- PT_NIP = 0x20
- PT_ORIG_R3 = 0x22
- PT_R0 = 0x0
- PT_R1 = 0x1
- PT_R10 = 0xa
- PT_R11 = 0xb
- PT_R12 = 0xc
- PT_R13 = 0xd
- PT_R14 = 0xe
- PT_R15 = 0xf
- PT_R16 = 0x10
- PT_R17 = 0x11
- PT_R18 = 0x12
- PT_R19 = 0x13
- PT_R2 = 0x2
- PT_R20 = 0x14
- PT_R21 = 0x15
- PT_R22 = 0x16
- PT_R23 = 0x17
- PT_R24 = 0x18
- PT_R25 = 0x19
- PT_R26 = 0x1a
- PT_R27 = 0x1b
- PT_R28 = 0x1c
- PT_R29 = 0x1d
- PT_R3 = 0x3
- PT_R30 = 0x1e
- PT_R31 = 0x1f
- PT_R4 = 0x4
- PT_R5 = 0x5
- PT_R6 = 0x6
- PT_R7 = 0x7
- PT_R8 = 0x8
- PT_R9 = 0x9
- PT_REGS_COUNT = 0x2c
- PT_RESULT = 0x2b
- PT_SOFTE = 0x27
- PT_TRAP = 0x28
- PT_VR0 = 0x52
- PT_VRSAVE = 0x94
- PT_VSCR = 0x93
- PT_VSR0 = 0x96
- PT_VSR31 = 0xd4
- PT_XER = 0x25
- RLIMIT_AS = 0x9
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x7
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = -0x1
- RTAX_ADVMSS = 0x8
- RTAX_CWND = 0x7
- RTAX_FEATURES = 0xc
- RTAX_FEATURE_ALLFRAG = 0x8
- RTAX_FEATURE_ECN = 0x1
- RTAX_FEATURE_SACK = 0x2
- RTAX_FEATURE_TIMESTAMP = 0x4
- RTAX_HOPLIMIT = 0xa
- RTAX_INITCWND = 0xb
- RTAX_INITRWND = 0xe
- RTAX_LOCK = 0x1
- RTAX_MAX = 0xf
- RTAX_MTU = 0x2
- RTAX_QUICKACK = 0xf
- RTAX_REORDERING = 0x9
- RTAX_RTO_MIN = 0xd
- RTAX_RTT = 0x4
- RTAX_RTTVAR = 0x5
- RTAX_SSTHRESH = 0x6
- RTAX_UNSPEC = 0x0
- RTAX_WINDOW = 0x3
- RTA_ALIGNTO = 0x4
- RTA_MAX = 0x11
- RTCF_DIRECTSRC = 0x4000000
- RTCF_DOREDIRECT = 0x1000000
- RTCF_LOG = 0x2000000
- RTCF_MASQ = 0x400000
- RTCF_NAT = 0x800000
- RTCF_VALVE = 0x200000
- RTF_ADDRCLASSMASK = 0xf8000000
- RTF_ADDRCONF = 0x40000
- RTF_ALLONLINK = 0x20000
- RTF_BROADCAST = 0x10000000
- RTF_CACHE = 0x1000000
- RTF_DEFAULT = 0x10000
- RTF_DYNAMIC = 0x10
- RTF_FLOW = 0x2000000
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_INTERFACE = 0x40000000
- RTF_IRTT = 0x100
- RTF_LINKRT = 0x100000
- RTF_LOCAL = 0x80000000
- RTF_MODIFIED = 0x20
- RTF_MSS = 0x40
- RTF_MTU = 0x40
- RTF_MULTICAST = 0x20000000
- RTF_NAT = 0x8000000
- RTF_NOFORWARD = 0x1000
- RTF_NONEXTHOP = 0x200000
- RTF_NOPMTUDISC = 0x4000
- RTF_POLICY = 0x4000000
- RTF_REINSTATE = 0x8
- RTF_REJECT = 0x200
- RTF_STATIC = 0x400
- RTF_THROW = 0x2000
- RTF_UP = 0x1
- RTF_WINDOW = 0x80
- RTF_XRESOLVE = 0x800
- RTM_BASE = 0x10
- RTM_DELACTION = 0x31
- RTM_DELADDR = 0x15
- RTM_DELADDRLABEL = 0x49
- RTM_DELLINK = 0x11
- RTM_DELMDB = 0x55
- RTM_DELNEIGH = 0x1d
- RTM_DELQDISC = 0x25
- RTM_DELROUTE = 0x19
- RTM_DELRULE = 0x21
- RTM_DELTCLASS = 0x29
- RTM_DELTFILTER = 0x2d
- RTM_F_CLONED = 0x200
- RTM_F_EQUALIZE = 0x400
- RTM_F_NOTIFY = 0x100
- RTM_F_PREFIX = 0x800
- RTM_GETACTION = 0x32
- RTM_GETADDR = 0x16
- RTM_GETADDRLABEL = 0x4a
- RTM_GETANYCAST = 0x3e
- RTM_GETDCB = 0x4e
- RTM_GETLINK = 0x12
- RTM_GETMDB = 0x56
- RTM_GETMULTICAST = 0x3a
- RTM_GETNEIGH = 0x1e
- RTM_GETNEIGHTBL = 0x42
- RTM_GETNETCONF = 0x52
- RTM_GETQDISC = 0x26
- RTM_GETROUTE = 0x1a
- RTM_GETRULE = 0x22
- RTM_GETTCLASS = 0x2a
- RTM_GETTFILTER = 0x2e
- RTM_MAX = 0x57
- RTM_NEWACTION = 0x30
- RTM_NEWADDR = 0x14
- RTM_NEWADDRLABEL = 0x48
- RTM_NEWLINK = 0x10
- RTM_NEWMDB = 0x54
- RTM_NEWNDUSEROPT = 0x44
- RTM_NEWNEIGH = 0x1c
- RTM_NEWNEIGHTBL = 0x40
- RTM_NEWNETCONF = 0x50
- RTM_NEWPREFIX = 0x34
- RTM_NEWQDISC = 0x24
- RTM_NEWROUTE = 0x18
- RTM_NEWRULE = 0x20
- RTM_NEWTCLASS = 0x28
- RTM_NEWTFILTER = 0x2c
- RTM_NR_FAMILIES = 0x12
- RTM_NR_MSGTYPES = 0x48
- RTM_SETDCB = 0x4f
- RTM_SETLINK = 0x13
- RTM_SETNEIGHTBL = 0x43
- RTNH_ALIGNTO = 0x4
- RTNH_F_DEAD = 0x1
- RTNH_F_ONLINK = 0x4
- RTNH_F_PERVASIVE = 0x2
- RTN_MAX = 0xb
- RTPROT_BIRD = 0xc
- RTPROT_BOOT = 0x3
- RTPROT_DHCP = 0x10
- RTPROT_DNROUTED = 0xd
- RTPROT_GATED = 0x8
- RTPROT_KERNEL = 0x2
- RTPROT_MROUTED = 0x11
- RTPROT_MRT = 0xa
- RTPROT_NTK = 0xf
- RTPROT_RA = 0x9
- RTPROT_REDIRECT = 0x1
- RTPROT_STATIC = 0x4
- RTPROT_UNSPEC = 0x0
- RTPROT_XORP = 0xe
- RTPROT_ZEBRA = 0xb
- RT_CLASS_DEFAULT = 0xfd
- RT_CLASS_LOCAL = 0xff
- RT_CLASS_MAIN = 0xfe
- RT_CLASS_MAX = 0xff
- RT_CLASS_UNSPEC = 0x0
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- RUSAGE_THREAD = 0x1
- SCM_CREDENTIALS = 0x2
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x1d
- SCM_TIMESTAMPING = 0x25
- SCM_TIMESTAMPNS = 0x23
- SCM_WIFI_STATUS = 0x29
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDDLCI = 0x8980
- SIOCADDMULTI = 0x8931
- SIOCADDRT = 0x890b
- SIOCATMARK = 0x8905
- SIOCDARP = 0x8953
- SIOCDELDLCI = 0x8981
- SIOCDELMULTI = 0x8932
- SIOCDELRT = 0x890c
- SIOCDEVPRIVATE = 0x89f0
- SIOCDIFADDR = 0x8936
- SIOCDRARP = 0x8960
- SIOCGARP = 0x8954
- SIOCGIFADDR = 0x8915
- SIOCGIFBR = 0x8940
- SIOCGIFBRDADDR = 0x8919
- SIOCGIFCONF = 0x8912
- SIOCGIFCOUNT = 0x8938
- SIOCGIFDSTADDR = 0x8917
- SIOCGIFENCAP = 0x8925
- SIOCGIFFLAGS = 0x8913
- SIOCGIFHWADDR = 0x8927
- SIOCGIFINDEX = 0x8933
- SIOCGIFMAP = 0x8970
- SIOCGIFMEM = 0x891f
- SIOCGIFMETRIC = 0x891d
- SIOCGIFMTU = 0x8921
- SIOCGIFNAME = 0x8910
- SIOCGIFNETMASK = 0x891b
- SIOCGIFPFLAGS = 0x8935
- SIOCGIFSLAVE = 0x8929
- SIOCGIFTXQLEN = 0x8942
- SIOCGPGRP = 0x8904
- SIOCGRARP = 0x8961
- SIOCGSTAMP = 0x8906
- SIOCGSTAMPNS = 0x8907
- SIOCPROTOPRIVATE = 0x89e0
- SIOCRTMSG = 0x890d
- SIOCSARP = 0x8955
- SIOCSIFADDR = 0x8916
- SIOCSIFBR = 0x8941
- SIOCSIFBRDADDR = 0x891a
- SIOCSIFDSTADDR = 0x8918
- SIOCSIFENCAP = 0x8926
- SIOCSIFFLAGS = 0x8914
- SIOCSIFHWADDR = 0x8924
- SIOCSIFHWBROADCAST = 0x8937
- SIOCSIFLINK = 0x8911
- SIOCSIFMAP = 0x8971
- SIOCSIFMEM = 0x8920
- SIOCSIFMETRIC = 0x891e
- SIOCSIFMTU = 0x8922
- SIOCSIFNAME = 0x8923
- SIOCSIFNETMASK = 0x891c
- SIOCSIFPFLAGS = 0x8934
- SIOCSIFSLAVE = 0x8930
- SIOCSIFTXQLEN = 0x8943
- SIOCSPGRP = 0x8902
- SIOCSRARP = 0x8962
- SOCK_CLOEXEC = 0x80000
- SOCK_DCCP = 0x6
- SOCK_DGRAM = 0x2
- SOCK_NONBLOCK = 0x800
- SOCK_PACKET = 0xa
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_AAL = 0x109
- SOL_ATM = 0x108
- SOL_DECNET = 0x105
- SOL_ICMPV6 = 0x3a
- SOL_IP = 0x0
- SOL_IPV6 = 0x29
- SOL_IRDA = 0x10a
- SOL_PACKET = 0x107
- SOL_RAW = 0xff
- SOL_SOCKET = 0x1
- SOL_TCP = 0x6
- SOL_X25 = 0x106
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x1e
- SO_ATTACH_FILTER = 0x1a
- SO_BINDTODEVICE = 0x19
- SO_BPF_EXTENSIONS = 0x30
- SO_BROADCAST = 0x6
- SO_BSDCOMPAT = 0xe
- SO_BUSY_POLL = 0x2e
- SO_DEBUG = 0x1
- SO_DETACH_FILTER = 0x1b
- SO_DOMAIN = 0x27
- SO_DONTROUTE = 0x5
- SO_ERROR = 0x4
- SO_GET_FILTER = 0x1a
- SO_KEEPALIVE = 0x9
- SO_LINGER = 0xd
- SO_LOCK_FILTER = 0x2c
- SO_MARK = 0x24
- SO_MAX_PACING_RATE = 0x2f
- SO_NOFCS = 0x2b
- SO_NO_CHECK = 0xb
- SO_OOBINLINE = 0xa
- SO_PASSCRED = 0x14
- SO_PASSSEC = 0x22
- SO_PEEK_OFF = 0x2a
- SO_PEERCRED = 0x15
- SO_PEERNAME = 0x1c
- SO_PEERSEC = 0x1f
- SO_PRIORITY = 0xc
- SO_PROTOCOL = 0x26
- SO_RCVBUF = 0x8
- SO_RCVBUFFORCE = 0x21
- SO_RCVLOWAT = 0x10
- SO_RCVTIMEO = 0x12
- SO_REUSEADDR = 0x2
- SO_REUSEPORT = 0xf
- SO_RXQ_OVFL = 0x28
- SO_SECURITY_AUTHENTICATION = 0x16
- SO_SECURITY_ENCRYPTION_NETWORK = 0x18
- SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17
- SO_SELECT_ERR_QUEUE = 0x2d
- SO_SNDBUF = 0x7
- SO_SNDBUFFORCE = 0x20
- SO_SNDLOWAT = 0x11
- SO_SNDTIMEO = 0x13
- SO_TIMESTAMP = 0x1d
- SO_TIMESTAMPING = 0x25
- SO_TIMESTAMPNS = 0x23
- SO_TYPE = 0x3
- SO_WIFI_STATUS = 0x29
- S_BLKSIZE = 0x200
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TAB0 = 0x0
- TAB1 = 0x400
- TAB2 = 0x800
- TAB3 = 0xc00
- TABDLY = 0xc00
- TCFLSH = 0x2000741f
- TCGETA = 0x40147417
- TCGETS = 0x402c7413
- TCIFLUSH = 0x0
- TCIOFF = 0x2
- TCIOFLUSH = 0x2
- TCION = 0x3
- TCOFLUSH = 0x1
- TCOOFF = 0x0
- TCOON = 0x1
- TCP_CONGESTION = 0xd
- TCP_COOKIE_IN_ALWAYS = 0x1
- TCP_COOKIE_MAX = 0x10
- TCP_COOKIE_MIN = 0x8
- TCP_COOKIE_OUT_NEVER = 0x2
- TCP_COOKIE_PAIR_SIZE = 0x20
- TCP_COOKIE_TRANSACTIONS = 0xf
- TCP_CORK = 0x3
- TCP_DEFER_ACCEPT = 0x9
- TCP_FASTOPEN = 0x17
- TCP_INFO = 0xb
- TCP_KEEPCNT = 0x6
- TCP_KEEPIDLE = 0x4
- TCP_KEEPINTVL = 0x5
- TCP_LINGER2 = 0x8
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0xe
- TCP_MD5SIG_MAXKEYLEN = 0x50
- TCP_MSS = 0x200
- TCP_MSS_DEFAULT = 0x218
- TCP_MSS_DESIRED = 0x4c4
- TCP_NODELAY = 0x1
- TCP_QUEUE_SEQ = 0x15
- TCP_QUICKACK = 0xc
- TCP_REPAIR = 0x13
- TCP_REPAIR_OPTIONS = 0x16
- TCP_REPAIR_QUEUE = 0x14
- TCP_SYNCNT = 0x7
- TCP_S_DATA_IN = 0x4
- TCP_S_DATA_OUT = 0x8
- TCP_THIN_DUPACK = 0x11
- TCP_THIN_LINEAR_TIMEOUTS = 0x10
- TCP_TIMESTAMP = 0x18
- TCP_USER_TIMEOUT = 0x12
- TCP_WINDOW_CLAMP = 0xa
- TCSAFLUSH = 0x2
- TCSBRK = 0x2000741d
- TCSBRKP = 0x5425
- TCSETA = 0x80147418
- TCSETAF = 0x8014741c
- TCSETAW = 0x80147419
- TCSETS = 0x802c7414
- TCSETSF = 0x802c7416
- TCSETSW = 0x802c7415
- TCXONC = 0x2000741e
- TIOCCBRK = 0x5428
- TIOCCONS = 0x541d
- TIOCEXCL = 0x540c
- TIOCGDEV = 0x40045432
- TIOCGETC = 0x40067412
- TIOCGETD = 0x5424
- TIOCGETP = 0x40067408
- TIOCGEXCL = 0x40045440
- TIOCGICOUNT = 0x545d
- TIOCGLCKTRMIOS = 0x5456
- TIOCGLTC = 0x40067474
- TIOCGPGRP = 0x40047477
- TIOCGPKT = 0x40045438
- TIOCGPTLCK = 0x40045439
- TIOCGPTN = 0x40045430
- TIOCGRS485 = 0x542e
- TIOCGSERIAL = 0x541e
- TIOCGSID = 0x5429
- TIOCGSOFTCAR = 0x5419
- TIOCGWINSZ = 0x40087468
- TIOCINQ = 0x4004667f
- TIOCLINUX = 0x541c
- TIOCMBIC = 0x5417
- TIOCMBIS = 0x5416
- TIOCMGET = 0x5415
- TIOCMIWAIT = 0x545c
- TIOCMSET = 0x5418
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_LOOP = 0x8000
- TIOCM_OUT1 = 0x2000
- TIOCM_OUT2 = 0x4000
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x5422
- TIOCNXCL = 0x540d
- TIOCOUTQ = 0x40047473
- TIOCPKT = 0x5420
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCSBRK = 0x5427
- TIOCSCTTY = 0x540e
- TIOCSERCONFIG = 0x5453
- TIOCSERGETLSR = 0x5459
- TIOCSERGETMULTI = 0x545a
- TIOCSERGSTRUCT = 0x5458
- TIOCSERGWILD = 0x5454
- TIOCSERSETMULTI = 0x545b
- TIOCSERSWILD = 0x5455
- TIOCSER_TEMT = 0x1
- TIOCSETC = 0x80067411
- TIOCSETD = 0x5423
- TIOCSETN = 0x8006740a
- TIOCSETP = 0x80067409
- TIOCSIG = 0x80045436
- TIOCSLCKTRMIOS = 0x5457
- TIOCSLTC = 0x80067475
- TIOCSPGRP = 0x80047476
- TIOCSPTLCK = 0x80045431
- TIOCSRS485 = 0x542f
- TIOCSSERIAL = 0x541f
- TIOCSSOFTCAR = 0x541a
- TIOCSTART = 0x2000746e
- TIOCSTI = 0x5412
- TIOCSTOP = 0x2000746f
- TIOCSWINSZ = 0x80087467
- TIOCVHANGUP = 0x5437
- TOSTOP = 0x400000
- TUNATTACHFILTER = 0x801054d5
- TUNDETACHFILTER = 0x801054d6
- TUNGETFEATURES = 0x400454cf
- TUNGETFILTER = 0x401054db
- TUNGETIFF = 0x400454d2
- TUNGETSNDBUF = 0x400454d3
- TUNGETVNETHDRSZ = 0x400454d7
- TUNSETDEBUG = 0x800454c9
- TUNSETGROUP = 0x800454ce
- TUNSETIFF = 0x800454ca
- TUNSETIFINDEX = 0x800454da
- TUNSETLINK = 0x800454cd
- TUNSETNOCSUM = 0x800454c8
- TUNSETOFFLOAD = 0x800454d0
- TUNSETOWNER = 0x800454cc
- TUNSETPERSIST = 0x800454cb
- TUNSETQUEUE = 0x800454d9
- TUNSETSNDBUF = 0x800454d4
- TUNSETTXFILTER = 0x800454d1
- TUNSETVNETHDRSZ = 0x800454d8
- VDISCARD = 0x10
- VEOF = 0x4
- VEOL = 0x6
- VEOL2 = 0x8
- VERASE = 0x2
- VINTR = 0x0
- VKILL = 0x3
- VLNEXT = 0xf
- VMIN = 0x5
- VQUIT = 0x1
- VREPRINT = 0xb
- VSTART = 0xd
- VSTOP = 0xe
- VSUSP = 0xc
- VSWTC = 0x9
- VT0 = 0x0
- VT1 = 0x10000
- VTDLY = 0x10000
- VTIME = 0x7
- VWERASE = 0xa
- WALL = 0x40000000
- WCLONE = 0x80000000
- WCONTINUED = 0x8
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOTHREAD = 0x20000000
- WNOWAIT = 0x1000000
- WORDSIZE = 0x40
- WSTOPPED = 0x2
- WUNTRACED = 0x2
- XCASE = 0x4000
- XTABS = 0xc00
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x62)
- EADDRNOTAVAIL = syscall.Errno(0x63)
- EADV = syscall.Errno(0x44)
- EAFNOSUPPORT = syscall.Errno(0x61)
- EAGAIN = syscall.Errno(0xb)
- EALREADY = syscall.Errno(0x72)
- EBADE = syscall.Errno(0x34)
- EBADF = syscall.Errno(0x9)
- EBADFD = syscall.Errno(0x4d)
- EBADMSG = syscall.Errno(0x4a)
- EBADR = syscall.Errno(0x35)
- EBADRQC = syscall.Errno(0x38)
- EBADSLT = syscall.Errno(0x39)
- EBFONT = syscall.Errno(0x3b)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x7d)
- ECHILD = syscall.Errno(0xa)
- ECHRNG = syscall.Errno(0x2c)
- ECOMM = syscall.Errno(0x46)
- ECONNABORTED = syscall.Errno(0x67)
- ECONNREFUSED = syscall.Errno(0x6f)
- ECONNRESET = syscall.Errno(0x68)
- EDEADLK = syscall.Errno(0x23)
- EDEADLOCK = syscall.Errno(0x3a)
- EDESTADDRREQ = syscall.Errno(0x59)
- EDOM = syscall.Errno(0x21)
- EDOTDOT = syscall.Errno(0x49)
- EDQUOT = syscall.Errno(0x7a)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EHOSTDOWN = syscall.Errno(0x70)
- EHOSTUNREACH = syscall.Errno(0x71)
- EHWPOISON = syscall.Errno(0x85)
- EIDRM = syscall.Errno(0x2b)
- EILSEQ = syscall.Errno(0x54)
- EINPROGRESS = syscall.Errno(0x73)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x6a)
- EISDIR = syscall.Errno(0x15)
- EISNAM = syscall.Errno(0x78)
- EKEYEXPIRED = syscall.Errno(0x7f)
- EKEYREJECTED = syscall.Errno(0x81)
- EKEYREVOKED = syscall.Errno(0x80)
- EL2HLT = syscall.Errno(0x33)
- EL2NSYNC = syscall.Errno(0x2d)
- EL3HLT = syscall.Errno(0x2e)
- EL3RST = syscall.Errno(0x2f)
- ELIBACC = syscall.Errno(0x4f)
- ELIBBAD = syscall.Errno(0x50)
- ELIBEXEC = syscall.Errno(0x53)
- ELIBMAX = syscall.Errno(0x52)
- ELIBSCN = syscall.Errno(0x51)
- ELNRNG = syscall.Errno(0x30)
- ELOOP = syscall.Errno(0x28)
- EMEDIUMTYPE = syscall.Errno(0x7c)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x5a)
- EMULTIHOP = syscall.Errno(0x48)
- ENAMETOOLONG = syscall.Errno(0x24)
- ENAVAIL = syscall.Errno(0x77)
- ENETDOWN = syscall.Errno(0x64)
- ENETRESET = syscall.Errno(0x66)
- ENETUNREACH = syscall.Errno(0x65)
- ENFILE = syscall.Errno(0x17)
- ENOANO = syscall.Errno(0x37)
- ENOBUFS = syscall.Errno(0x69)
- ENOCSI = syscall.Errno(0x32)
- ENODATA = syscall.Errno(0x3d)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOKEY = syscall.Errno(0x7e)
- ENOLCK = syscall.Errno(0x25)
- ENOLINK = syscall.Errno(0x43)
- ENOMEDIUM = syscall.Errno(0x7b)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x2a)
- ENONET = syscall.Errno(0x40)
- ENOPKG = syscall.Errno(0x41)
- ENOPROTOOPT = syscall.Errno(0x5c)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x3f)
- ENOSTR = syscall.Errno(0x3c)
- ENOSYS = syscall.Errno(0x26)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x6b)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x27)
- ENOTNAM = syscall.Errno(0x76)
- ENOTRECOVERABLE = syscall.Errno(0x83)
- ENOTSOCK = syscall.Errno(0x58)
- ENOTSUP = syscall.Errno(0x5f)
- ENOTTY = syscall.Errno(0x19)
- ENOTUNIQ = syscall.Errno(0x4c)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x5f)
- EOVERFLOW = syscall.Errno(0x4b)
- EOWNERDEAD = syscall.Errno(0x82)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x60)
- EPIPE = syscall.Errno(0x20)
- EPROTO = syscall.Errno(0x47)
- EPROTONOSUPPORT = syscall.Errno(0x5d)
- EPROTOTYPE = syscall.Errno(0x5b)
- ERANGE = syscall.Errno(0x22)
- EREMCHG = syscall.Errno(0x4e)
- EREMOTE = syscall.Errno(0x42)
- EREMOTEIO = syscall.Errno(0x79)
- ERESTART = syscall.Errno(0x55)
- ERFKILL = syscall.Errno(0x84)
- EROFS = syscall.Errno(0x1e)
- ESHUTDOWN = syscall.Errno(0x6c)
- ESOCKTNOSUPPORT = syscall.Errno(0x5e)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESRMNT = syscall.Errno(0x45)
- ESTALE = syscall.Errno(0x74)
- ESTRPIPE = syscall.Errno(0x56)
- ETIME = syscall.Errno(0x3e)
- ETIMEDOUT = syscall.Errno(0x6e)
- ETOOMANYREFS = syscall.Errno(0x6d)
- ETXTBSY = syscall.Errno(0x1a)
- EUCLEAN = syscall.Errno(0x75)
- EUNATCH = syscall.Errno(0x31)
- EUSERS = syscall.Errno(0x57)
- EWOULDBLOCK = syscall.Errno(0xb)
- EXDEV = syscall.Errno(0x12)
- EXFULL = syscall.Errno(0x36)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0x7)
- SIGCHLD = syscall.Signal(0x11)
- SIGCLD = syscall.Signal(0x11)
- SIGCONT = syscall.Signal(0x12)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x1d)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPOLL = syscall.Signal(0x1d)
- SIGPROF = syscall.Signal(0x1b)
- SIGPWR = syscall.Signal(0x1e)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTKFLT = syscall.Signal(0x10)
- SIGSTOP = syscall.Signal(0x13)
- SIGSYS = syscall.Signal(0x1f)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x14)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGUNUSED = syscall.Signal(0x1f)
- SIGURG = syscall.Signal(0x17)
- SIGUSR1 = syscall.Signal(0xa)
- SIGUSR2 = syscall.Signal(0xc)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "no such device or address",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource temporarily unavailable",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device or resource busy",
- 17: "file exists",
- 18: "invalid cross-device link",
- 19: "no such device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "numerical result out of range",
- 35: "resource deadlock avoided",
- 36: "file name too long",
- 37: "no locks available",
- 38: "function not implemented",
- 39: "directory not empty",
- 40: "too many levels of symbolic links",
- 42: "no message of desired type",
- 43: "identifier removed",
- 44: "channel number out of range",
- 45: "level 2 not synchronized",
- 46: "level 3 halted",
- 47: "level 3 reset",
- 48: "link number out of range",
- 49: "protocol driver not attached",
- 50: "no CSI structure available",
- 51: "level 2 halted",
- 52: "invalid exchange",
- 53: "invalid request descriptor",
- 54: "exchange full",
- 55: "no anode",
- 56: "invalid request code",
- 57: "invalid slot",
- 58: "file locking deadlock error",
- 59: "bad font file format",
- 60: "device not a stream",
- 61: "no data available",
- 62: "timer expired",
- 63: "out of streams resources",
- 64: "machine is not on the network",
- 65: "package not installed",
- 66: "object is remote",
- 67: "link has been severed",
- 68: "advertise error",
- 69: "srmount error",
- 70: "communication error on send",
- 71: "protocol error",
- 72: "multihop attempted",
- 73: "RFS specific error",
- 74: "bad message",
- 75: "value too large for defined data type",
- 76: "name not unique on network",
- 77: "file descriptor in bad state",
- 78: "remote address changed",
- 79: "can not access a needed shared library",
- 80: "accessing a corrupted shared library",
- 81: ".lib section in a.out corrupted",
- 82: "attempting to link in too many shared libraries",
- 83: "cannot exec a shared library directly",
- 84: "invalid or incomplete multibyte or wide character",
- 85: "interrupted system call should be restarted",
- 86: "streams pipe error",
- 87: "too many users",
- 88: "socket operation on non-socket",
- 89: "destination address required",
- 90: "message too long",
- 91: "protocol wrong type for socket",
- 92: "protocol not available",
- 93: "protocol not supported",
- 94: "socket type not supported",
- 95: "operation not supported",
- 96: "protocol family not supported",
- 97: "address family not supported by protocol",
- 98: "address already in use",
- 99: "cannot assign requested address",
- 100: "network is down",
- 101: "network is unreachable",
- 102: "network dropped connection on reset",
- 103: "software caused connection abort",
- 104: "connection reset by peer",
- 105: "no buffer space available",
- 106: "transport endpoint is already connected",
- 107: "transport endpoint is not connected",
- 108: "cannot send after transport endpoint shutdown",
- 109: "too many references: cannot splice",
- 110: "connection timed out",
- 111: "connection refused",
- 112: "host is down",
- 113: "no route to host",
- 114: "operation already in progress",
- 115: "operation now in progress",
- 116: "stale file handle",
- 117: "structure needs cleaning",
- 118: "not a XENIX named type file",
- 119: "no XENIX semaphores available",
- 120: "is a named type file",
- 121: "remote I/O error",
- 122: "disk quota exceeded",
- 123: "no medium found",
- 124: "wrong medium type",
- 125: "operation canceled",
- 126: "required key not available",
- 127: "key has expired",
- 128: "key has been revoked",
- 129: "key was rejected by service",
- 130: "owner died",
- 131: "state not recoverable",
- 132: "operation not possible due to RF-kill",
- 133: "memory page has hardware error",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/breakpoint trap",
- 6: "aborted",
- 7: "bus error",
- 8: "floating point exception",
- 9: "killed",
- 10: "user defined signal 1",
- 11: "segmentation fault",
- 12: "user defined signal 2",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "stack fault",
- 17: "child exited",
- 18: "continued",
- 19: "stopped (signal)",
- 20: "stopped",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "urgent I/O condition",
- 24: "CPU time limit exceeded",
- 25: "file size limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window changed",
- 29: "I/O possible",
- 30: "power failure",
- 31: "bad system call",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/newt/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
deleted file mode 100644
index e8d12b5d..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
+++ /dev/null
@@ -1,1969 +0,0 @@
-// mkerrors.sh -m64
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build ppc64le,linux
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -m64 _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_ALG = 0x26
- AF_APPLETALK = 0x5
- AF_ASH = 0x12
- AF_ATMPVC = 0x8
- AF_ATMSVC = 0x14
- AF_AX25 = 0x3
- AF_BLUETOOTH = 0x1f
- AF_BRIDGE = 0x7
- AF_CAIF = 0x25
- AF_CAN = 0x1d
- AF_DECnet = 0xc
- AF_ECONET = 0x13
- AF_FILE = 0x1
- AF_IEEE802154 = 0x24
- AF_INET = 0x2
- AF_INET6 = 0xa
- AF_IPX = 0x4
- AF_IRDA = 0x17
- AF_ISDN = 0x22
- AF_IUCV = 0x20
- AF_KEY = 0xf
- AF_LLC = 0x1a
- AF_LOCAL = 0x1
- AF_MAX = 0x29
- AF_NETBEUI = 0xd
- AF_NETLINK = 0x10
- AF_NETROM = 0x6
- AF_NFC = 0x27
- AF_PACKET = 0x11
- AF_PHONET = 0x23
- AF_PPPOX = 0x18
- AF_RDS = 0x15
- AF_ROSE = 0xb
- AF_ROUTE = 0x10
- AF_RXRPC = 0x21
- AF_SECURITY = 0xe
- AF_SNA = 0x16
- AF_TIPC = 0x1e
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_VSOCK = 0x28
- AF_WANPIPE = 0x19
- AF_X25 = 0x9
- ARPHRD_ADAPT = 0x108
- ARPHRD_APPLETLK = 0x8
- ARPHRD_ARCNET = 0x7
- ARPHRD_ASH = 0x30d
- ARPHRD_ATM = 0x13
- ARPHRD_AX25 = 0x3
- ARPHRD_BIF = 0x307
- ARPHRD_CAIF = 0x336
- ARPHRD_CAN = 0x118
- ARPHRD_CHAOS = 0x5
- ARPHRD_CISCO = 0x201
- ARPHRD_CSLIP = 0x101
- ARPHRD_CSLIP6 = 0x103
- ARPHRD_DDCMP = 0x205
- ARPHRD_DLCI = 0xf
- ARPHRD_ECONET = 0x30e
- ARPHRD_EETHER = 0x2
- ARPHRD_ETHER = 0x1
- ARPHRD_EUI64 = 0x1b
- ARPHRD_FCAL = 0x311
- ARPHRD_FCFABRIC = 0x313
- ARPHRD_FCPL = 0x312
- ARPHRD_FCPP = 0x310
- ARPHRD_FDDI = 0x306
- ARPHRD_FRAD = 0x302
- ARPHRD_HDLC = 0x201
- ARPHRD_HIPPI = 0x30c
- ARPHRD_HWX25 = 0x110
- ARPHRD_IEEE1394 = 0x18
- ARPHRD_IEEE802 = 0x6
- ARPHRD_IEEE80211 = 0x321
- ARPHRD_IEEE80211_PRISM = 0x322
- ARPHRD_IEEE80211_RADIOTAP = 0x323
- ARPHRD_IEEE802154 = 0x324
- ARPHRD_IEEE802154_MONITOR = 0x325
- ARPHRD_IEEE802_TR = 0x320
- ARPHRD_INFINIBAND = 0x20
- ARPHRD_IP6GRE = 0x337
- ARPHRD_IPDDP = 0x309
- ARPHRD_IPGRE = 0x30a
- ARPHRD_IRDA = 0x30f
- ARPHRD_LAPB = 0x204
- ARPHRD_LOCALTLK = 0x305
- ARPHRD_LOOPBACK = 0x304
- ARPHRD_METRICOM = 0x17
- ARPHRD_NETLINK = 0x338
- ARPHRD_NETROM = 0x0
- ARPHRD_NONE = 0xfffe
- ARPHRD_PHONET = 0x334
- ARPHRD_PHONET_PIPE = 0x335
- ARPHRD_PIMREG = 0x30b
- ARPHRD_PPP = 0x200
- ARPHRD_PRONET = 0x4
- ARPHRD_RAWHDLC = 0x206
- ARPHRD_ROSE = 0x10e
- ARPHRD_RSRVD = 0x104
- ARPHRD_SIT = 0x308
- ARPHRD_SKIP = 0x303
- ARPHRD_SLIP = 0x100
- ARPHRD_SLIP6 = 0x102
- ARPHRD_TUNNEL = 0x300
- ARPHRD_TUNNEL6 = 0x301
- ARPHRD_VOID = 0xffff
- ARPHRD_X25 = 0x10f
- B0 = 0x0
- B1000000 = 0x17
- B110 = 0x3
- B115200 = 0x11
- B1152000 = 0x18
- B1200 = 0x9
- B134 = 0x4
- B150 = 0x5
- B1500000 = 0x19
- B1800 = 0xa
- B19200 = 0xe
- B200 = 0x6
- B2000000 = 0x1a
- B230400 = 0x12
- B2400 = 0xb
- B2500000 = 0x1b
- B300 = 0x7
- B3000000 = 0x1c
- B3500000 = 0x1d
- B38400 = 0xf
- B4000000 = 0x1e
- B460800 = 0x13
- B4800 = 0xc
- B50 = 0x1
- B500000 = 0x14
- B57600 = 0x10
- B576000 = 0x15
- B600 = 0x8
- B75 = 0x2
- B921600 = 0x16
- B9600 = 0xd
- BOTHER = 0x1f
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXINSNS = 0x1000
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MOD = 0x90
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BPF_XOR = 0xa0
- BRKINT = 0x2
- BS0 = 0x0
- BS1 = 0x8000
- BSDLY = 0x8000
- CBAUD = 0xff
- CBAUDEX = 0x0
- CFLUSH = 0xf
- CIBAUD = 0xff0000
- CLOCAL = 0x8000
- CLOCK_BOOTTIME = 0x7
- CLOCK_BOOTTIME_ALARM = 0x9
- CLOCK_DEFAULT = 0x0
- CLOCK_EXT = 0x1
- CLOCK_INT = 0x2
- CLOCK_MONOTONIC = 0x1
- CLOCK_MONOTONIC_COARSE = 0x6
- CLOCK_MONOTONIC_RAW = 0x4
- CLOCK_PROCESS_CPUTIME_ID = 0x2
- CLOCK_REALTIME = 0x0
- CLOCK_REALTIME_ALARM = 0x8
- CLOCK_REALTIME_COARSE = 0x5
- CLOCK_THREAD_CPUTIME_ID = 0x3
- CLOCK_TXFROMRX = 0x4
- CLOCK_TXINT = 0x3
- CLONE_CHILD_CLEARTID = 0x200000
- CLONE_CHILD_SETTID = 0x1000000
- CLONE_DETACHED = 0x400000
- CLONE_FILES = 0x400
- CLONE_FS = 0x200
- CLONE_IO = 0x80000000
- CLONE_NEWCGROUP = 0x2000000
- CLONE_NEWIPC = 0x8000000
- CLONE_NEWNET = 0x40000000
- CLONE_NEWNS = 0x20000
- CLONE_NEWPID = 0x20000000
- CLONE_NEWUSER = 0x10000000
- CLONE_NEWUTS = 0x4000000
- CLONE_PARENT = 0x8000
- CLONE_PARENT_SETTID = 0x100000
- CLONE_PTRACE = 0x2000
- CLONE_SETTLS = 0x80000
- CLONE_SIGHAND = 0x800
- CLONE_SYSVSEM = 0x40000
- CLONE_THREAD = 0x10000
- CLONE_UNTRACED = 0x800000
- CLONE_VFORK = 0x4000
- CLONE_VM = 0x100
- CMSPAR = 0x40000000
- CR0 = 0x0
- CR1 = 0x1000
- CR2 = 0x2000
- CR3 = 0x3000
- CRDLY = 0x3000
- CREAD = 0x800
- CRTSCTS = 0x80000000
- CS5 = 0x0
- CS6 = 0x100
- CS7 = 0x200
- CS8 = 0x300
- CSIGNAL = 0xff
- CSIZE = 0x300
- CSTART = 0x11
- CSTATUS = 0x0
- CSTOP = 0x13
- CSTOPB = 0x400
- CSUSP = 0x1a
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x40
- ECHOE = 0x2
- ECHOK = 0x4
- ECHOKE = 0x1
- ECHONL = 0x10
- ECHOPRT = 0x20
- ENCODING_DEFAULT = 0x0
- ENCODING_FM_MARK = 0x3
- ENCODING_FM_SPACE = 0x4
- ENCODING_MANCHESTER = 0x5
- ENCODING_NRZ = 0x1
- ENCODING_NRZI = 0x2
- EPOLLERR = 0x8
- EPOLLET = 0x80000000
- EPOLLHUP = 0x10
- EPOLLIN = 0x1
- EPOLLMSG = 0x400
- EPOLLONESHOT = 0x40000000
- EPOLLOUT = 0x4
- EPOLLPRI = 0x2
- EPOLLRDBAND = 0x80
- EPOLLRDHUP = 0x2000
- EPOLLRDNORM = 0x40
- EPOLLWAKEUP = 0x20000000
- EPOLLWRBAND = 0x200
- EPOLLWRNORM = 0x100
- EPOLL_CLOEXEC = 0x80000
- EPOLL_CTL_ADD = 0x1
- EPOLL_CTL_DEL = 0x2
- EPOLL_CTL_MOD = 0x3
- ETH_P_1588 = 0x88f7
- ETH_P_8021AD = 0x88a8
- ETH_P_8021AH = 0x88e7
- ETH_P_8021Q = 0x8100
- ETH_P_802_2 = 0x4
- ETH_P_802_3 = 0x1
- ETH_P_802_3_MIN = 0x600
- ETH_P_802_EX1 = 0x88b5
- ETH_P_AARP = 0x80f3
- ETH_P_AF_IUCV = 0xfbfb
- ETH_P_ALL = 0x3
- ETH_P_AOE = 0x88a2
- ETH_P_ARCNET = 0x1a
- ETH_P_ARP = 0x806
- ETH_P_ATALK = 0x809b
- ETH_P_ATMFATE = 0x8884
- ETH_P_ATMMPOA = 0x884c
- ETH_P_AX25 = 0x2
- ETH_P_BATMAN = 0x4305
- ETH_P_BPQ = 0x8ff
- ETH_P_CAIF = 0xf7
- ETH_P_CAN = 0xc
- ETH_P_CANFD = 0xd
- ETH_P_CONTROL = 0x16
- ETH_P_CUST = 0x6006
- ETH_P_DDCMP = 0x6
- ETH_P_DEC = 0x6000
- ETH_P_DIAG = 0x6005
- ETH_P_DNA_DL = 0x6001
- ETH_P_DNA_RC = 0x6002
- ETH_P_DNA_RT = 0x6003
- ETH_P_DSA = 0x1b
- ETH_P_ECONET = 0x18
- ETH_P_EDSA = 0xdada
- ETH_P_FCOE = 0x8906
- ETH_P_FIP = 0x8914
- ETH_P_HDLC = 0x19
- ETH_P_IEEE802154 = 0xf6
- ETH_P_IEEEPUP = 0xa00
- ETH_P_IEEEPUPAT = 0xa01
- ETH_P_IP = 0x800
- ETH_P_IPV6 = 0x86dd
- ETH_P_IPX = 0x8137
- ETH_P_IRDA = 0x17
- ETH_P_LAT = 0x6004
- ETH_P_LINK_CTL = 0x886c
- ETH_P_LOCALTALK = 0x9
- ETH_P_LOOP = 0x60
- ETH_P_MOBITEX = 0x15
- ETH_P_MPLS_MC = 0x8848
- ETH_P_MPLS_UC = 0x8847
- ETH_P_MVRP = 0x88f5
- ETH_P_PAE = 0x888e
- ETH_P_PAUSE = 0x8808
- ETH_P_PHONET = 0xf5
- ETH_P_PPPTALK = 0x10
- ETH_P_PPP_DISC = 0x8863
- ETH_P_PPP_MP = 0x8
- ETH_P_PPP_SES = 0x8864
- ETH_P_PRP = 0x88fb
- ETH_P_PUP = 0x200
- ETH_P_PUPAT = 0x201
- ETH_P_QINQ1 = 0x9100
- ETH_P_QINQ2 = 0x9200
- ETH_P_QINQ3 = 0x9300
- ETH_P_RARP = 0x8035
- ETH_P_SCA = 0x6007
- ETH_P_SLOW = 0x8809
- ETH_P_SNAP = 0x5
- ETH_P_TDLS = 0x890d
- ETH_P_TEB = 0x6558
- ETH_P_TIPC = 0x88ca
- ETH_P_TRAILER = 0x1c
- ETH_P_TR_802_2 = 0x11
- ETH_P_WAN_PPP = 0x7
- ETH_P_WCCP = 0x883e
- ETH_P_X25 = 0x805
- EXTA = 0xe
- EXTB = 0xf
- EXTPROC = 0x10000000
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FF0 = 0x0
- FF1 = 0x4000
- FFDLY = 0x4000
- FLUSHO = 0x800000
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x406
- F_EXLCK = 0x4
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLEASE = 0x401
- F_GETLK = 0x5
- F_GETLK64 = 0xc
- F_GETOWN = 0x9
- F_GETOWN_EX = 0x10
- F_GETPIPE_SZ = 0x408
- F_GETSIG = 0xb
- F_LOCK = 0x1
- F_NOTIFY = 0x402
- F_OK = 0x0
- F_RDLCK = 0x0
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLEASE = 0x400
- F_SETLK = 0x6
- F_SETLK64 = 0xd
- F_SETLKW = 0x7
- F_SETLKW64 = 0xe
- F_SETOWN = 0x8
- F_SETOWN_EX = 0xf
- F_SETPIPE_SZ = 0x407
- F_SETSIG = 0xa
- F_SHLCK = 0x8
- F_TEST = 0x3
- F_TLOCK = 0x2
- F_ULOCK = 0x0
- F_UNLCK = 0x2
- F_WRLCK = 0x1
- HUPCL = 0x4000
- IBSHIFT = 0x10
- ICANON = 0x100
- ICMPV6_FILTER = 0x1
- ICRNL = 0x100
- IEXTEN = 0x400
- IFA_F_DADFAILED = 0x8
- IFA_F_DEPRECATED = 0x20
- IFA_F_HOMEADDRESS = 0x10
- IFA_F_NODAD = 0x2
- IFA_F_OPTIMISTIC = 0x4
- IFA_F_PERMANENT = 0x80
- IFA_F_SECONDARY = 0x1
- IFA_F_TEMPORARY = 0x1
- IFA_F_TENTATIVE = 0x40
- IFA_MAX = 0x7
- IFF_802_1Q_VLAN = 0x1
- IFF_ALLMULTI = 0x200
- IFF_ATTACH_QUEUE = 0x200
- IFF_AUTOMEDIA = 0x4000
- IFF_BONDING = 0x20
- IFF_BRIDGE_PORT = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_DETACH_QUEUE = 0x400
- IFF_DISABLE_NETPOLL = 0x1000
- IFF_DONT_BRIDGE = 0x800
- IFF_DORMANT = 0x20000
- IFF_DYNAMIC = 0x8000
- IFF_EBRIDGE = 0x2
- IFF_ECHO = 0x40000
- IFF_ISATAP = 0x80
- IFF_LIVE_ADDR_CHANGE = 0x100000
- IFF_LOOPBACK = 0x8
- IFF_LOWER_UP = 0x10000
- IFF_MACVLAN = 0x200000
- IFF_MACVLAN_PORT = 0x2000
- IFF_MASTER = 0x400
- IFF_MASTER_8023AD = 0x8
- IFF_MASTER_ALB = 0x10
- IFF_MASTER_ARPMON = 0x100
- IFF_MULTICAST = 0x1000
- IFF_MULTI_QUEUE = 0x100
- IFF_NOARP = 0x80
- IFF_NOFILTER = 0x1000
- IFF_NOTRAILERS = 0x20
- IFF_NO_PI = 0x1000
- IFF_ONE_QUEUE = 0x2000
- IFF_OVS_DATAPATH = 0x8000
- IFF_PERSIST = 0x800
- IFF_POINTOPOINT = 0x10
- IFF_PORTSEL = 0x2000
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SLAVE = 0x800
- IFF_SLAVE_INACTIVE = 0x4
- IFF_SLAVE_NEEDARP = 0x40
- IFF_SUPP_NOFCS = 0x80000
- IFF_TAP = 0x2
- IFF_TEAM_PORT = 0x40000
- IFF_TUN = 0x1
- IFF_TUN_EXCL = 0x8000
- IFF_TX_SKB_SHARING = 0x10000
- IFF_UNICAST_FLT = 0x20000
- IFF_UP = 0x1
- IFF_VNET_HDR = 0x4000
- IFF_VOLATILE = 0x70c5a
- IFF_WAN_HDLC = 0x200
- IFF_XMIT_DST_RELEASE = 0x400
- IFNAMSIZ = 0x10
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_ACCESS = 0x1
- IN_ALL_EVENTS = 0xfff
- IN_ATTRIB = 0x4
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLOEXEC = 0x80000
- IN_CLOSE = 0x18
- IN_CLOSE_NOWRITE = 0x10
- IN_CLOSE_WRITE = 0x8
- IN_CREATE = 0x100
- IN_DELETE = 0x200
- IN_DELETE_SELF = 0x400
- IN_DONT_FOLLOW = 0x2000000
- IN_EXCL_UNLINK = 0x4000000
- IN_IGNORED = 0x8000
- IN_ISDIR = 0x40000000
- IN_LOOPBACKNET = 0x7f
- IN_MASK_ADD = 0x20000000
- IN_MODIFY = 0x2
- IN_MOVE = 0xc0
- IN_MOVED_FROM = 0x40
- IN_MOVED_TO = 0x80
- IN_MOVE_SELF = 0x800
- IN_NONBLOCK = 0x800
- IN_ONESHOT = 0x80000000
- IN_ONLYDIR = 0x1000000
- IN_OPEN = 0x20
- IN_Q_OVERFLOW = 0x4000
- IN_UNMOUNT = 0x2000
- IPPROTO_AH = 0x33
- IPPROTO_BEETPH = 0x5e
- IPPROTO_COMP = 0x6c
- IPPROTO_DCCP = 0x21
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_ENCAP = 0x62
- IPPROTO_ESP = 0x32
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GRE = 0x2f
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IGMP = 0x2
- IPPROTO_IP = 0x0
- IPPROTO_IPIP = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_MH = 0x87
- IPPROTO_MTP = 0x5c
- IPPROTO_NONE = 0x3b
- IPPROTO_PIM = 0x67
- IPPROTO_PUP = 0xc
- IPPROTO_RAW = 0xff
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_SCTP = 0x84
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_UDP = 0x11
- IPPROTO_UDPLITE = 0x88
- IPV6_2292DSTOPTS = 0x4
- IPV6_2292HOPLIMIT = 0x8
- IPV6_2292HOPOPTS = 0x3
- IPV6_2292PKTINFO = 0x2
- IPV6_2292PKTOPTIONS = 0x6
- IPV6_2292RTHDR = 0x5
- IPV6_ADDRFORM = 0x1
- IPV6_ADD_MEMBERSHIP = 0x14
- IPV6_AUTHHDR = 0xa
- IPV6_CHECKSUM = 0x7
- IPV6_DROP_MEMBERSHIP = 0x15
- IPV6_DSTOPTS = 0x3b
- IPV6_HOPLIMIT = 0x34
- IPV6_HOPOPTS = 0x36
- IPV6_IPSEC_POLICY = 0x22
- IPV6_JOIN_ANYCAST = 0x1b
- IPV6_JOIN_GROUP = 0x14
- IPV6_LEAVE_ANYCAST = 0x1c
- IPV6_LEAVE_GROUP = 0x15
- IPV6_MTU = 0x18
- IPV6_MTU_DISCOVER = 0x17
- IPV6_MULTICAST_HOPS = 0x12
- IPV6_MULTICAST_IF = 0x11
- IPV6_MULTICAST_LOOP = 0x13
- IPV6_NEXTHOP = 0x9
- IPV6_PKTINFO = 0x32
- IPV6_PMTUDISC_DO = 0x2
- IPV6_PMTUDISC_DONT = 0x0
- IPV6_PMTUDISC_PROBE = 0x3
- IPV6_PMTUDISC_WANT = 0x1
- IPV6_RECVDSTOPTS = 0x3a
- IPV6_RECVERR = 0x19
- IPV6_RECVHOPLIMIT = 0x33
- IPV6_RECVHOPOPTS = 0x35
- IPV6_RECVPKTINFO = 0x31
- IPV6_RECVRTHDR = 0x38
- IPV6_RECVTCLASS = 0x42
- IPV6_ROUTER_ALERT = 0x16
- IPV6_RTHDR = 0x39
- IPV6_RTHDRDSTOPTS = 0x37
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_RXDSTOPTS = 0x3b
- IPV6_RXHOPOPTS = 0x36
- IPV6_TCLASS = 0x43
- IPV6_UNICAST_HOPS = 0x10
- IPV6_V6ONLY = 0x1a
- IPV6_XFRM_POLICY = 0x23
- IP_ADD_MEMBERSHIP = 0x23
- IP_ADD_SOURCE_MEMBERSHIP = 0x27
- IP_BLOCK_SOURCE = 0x26
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0x24
- IP_DROP_SOURCE_MEMBERSHIP = 0x28
- IP_FREEBIND = 0xf
- IP_HDRINCL = 0x3
- IP_IPSEC_POLICY = 0x10
- IP_MAXPACKET = 0xffff
- IP_MAX_MEMBERSHIPS = 0x14
- IP_MF = 0x2000
- IP_MINTTL = 0x15
- IP_MSFILTER = 0x29
- IP_MSS = 0x240
- IP_MTU = 0xe
- IP_MTU_DISCOVER = 0xa
- IP_MULTICAST_ALL = 0x31
- IP_MULTICAST_IF = 0x20
- IP_MULTICAST_LOOP = 0x22
- IP_MULTICAST_TTL = 0x21
- IP_OFFMASK = 0x1fff
- IP_OPTIONS = 0x4
- IP_ORIGDSTADDR = 0x14
- IP_PASSSEC = 0x12
- IP_PKTINFO = 0x8
- IP_PKTOPTIONS = 0x9
- IP_PMTUDISC = 0xa
- IP_PMTUDISC_DO = 0x2
- IP_PMTUDISC_DONT = 0x0
- IP_PMTUDISC_PROBE = 0x3
- IP_PMTUDISC_WANT = 0x1
- IP_RECVERR = 0xb
- IP_RECVOPTS = 0x6
- IP_RECVORIGDSTADDR = 0x14
- IP_RECVRETOPTS = 0x7
- IP_RECVTOS = 0xd
- IP_RECVTTL = 0xc
- IP_RETOPTS = 0x7
- IP_RF = 0x8000
- IP_ROUTER_ALERT = 0x5
- IP_TOS = 0x1
- IP_TRANSPARENT = 0x13
- IP_TTL = 0x2
- IP_UNBLOCK_SOURCE = 0x25
- IP_UNICAST_IF = 0x32
- IP_XFRM_POLICY = 0x11
- ISIG = 0x80
- ISTRIP = 0x20
- IUCLC = 0x1000
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x400
- IXON = 0x200
- LINUX_REBOOT_CMD_CAD_OFF = 0x0
- LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
- LINUX_REBOOT_CMD_HALT = 0xcdef0123
- LINUX_REBOOT_CMD_KEXEC = 0x45584543
- LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
- LINUX_REBOOT_CMD_RESTART = 0x1234567
- LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
- LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
- LINUX_REBOOT_MAGIC1 = 0xfee1dead
- LINUX_REBOOT_MAGIC2 = 0x28121969
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_DODUMP = 0x11
- MADV_DOFORK = 0xb
- MADV_DONTDUMP = 0x10
- MADV_DONTFORK = 0xa
- MADV_DONTNEED = 0x4
- MADV_HUGEPAGE = 0xe
- MADV_HWPOISON = 0x64
- MADV_MERGEABLE = 0xc
- MADV_NOHUGEPAGE = 0xf
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_REMOVE = 0x9
- MADV_SEQUENTIAL = 0x2
- MADV_UNMERGEABLE = 0xd
- MADV_WILLNEED = 0x3
- MAP_ANON = 0x20
- MAP_ANONYMOUS = 0x20
- MAP_DENYWRITE = 0x800
- MAP_EXECUTABLE = 0x1000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_GROWSDOWN = 0x100
- MAP_HUGETLB = 0x40000
- MAP_HUGE_MASK = 0x3f
- MAP_HUGE_SHIFT = 0x1a
- MAP_LOCKED = 0x80
- MAP_NONBLOCK = 0x10000
- MAP_NORESERVE = 0x40
- MAP_POPULATE = 0x8000
- MAP_PRIVATE = 0x2
- MAP_SHARED = 0x1
- MAP_STACK = 0x20000
- MAP_TYPE = 0xf
- MCL_CURRENT = 0x2000
- MCL_FUTURE = 0x4000
- MNT_DETACH = 0x2
- MNT_EXPIRE = 0x4
- MNT_FORCE = 0x1
- MSG_CMSG_CLOEXEC = 0x40000000
- MSG_CONFIRM = 0x800
- MSG_CTRUNC = 0x8
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x40
- MSG_EOR = 0x80
- MSG_ERRQUEUE = 0x2000
- MSG_FASTOPEN = 0x20000000
- MSG_FIN = 0x200
- MSG_MORE = 0x8000
- MSG_NOSIGNAL = 0x4000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_PROXY = 0x10
- MSG_RST = 0x1000
- MSG_SYN = 0x400
- MSG_TRUNC = 0x20
- MSG_TRYHARD = 0x4
- MSG_WAITALL = 0x100
- MSG_WAITFORONE = 0x10000
- MS_ACTIVE = 0x40000000
- MS_ASYNC = 0x1
- MS_BIND = 0x1000
- MS_DIRSYNC = 0x80
- MS_INVALIDATE = 0x2
- MS_I_VERSION = 0x800000
- MS_KERNMOUNT = 0x400000
- MS_MANDLOCK = 0x40
- MS_MGC_MSK = 0xffff0000
- MS_MGC_VAL = 0xc0ed0000
- MS_MOVE = 0x2000
- MS_NOATIME = 0x400
- MS_NODEV = 0x4
- MS_NODIRATIME = 0x800
- MS_NOEXEC = 0x8
- MS_NOSUID = 0x2
- MS_NOUSER = -0x80000000
- MS_POSIXACL = 0x10000
- MS_PRIVATE = 0x40000
- MS_RDONLY = 0x1
- MS_REC = 0x4000
- MS_RELATIME = 0x200000
- MS_REMOUNT = 0x20
- MS_RMT_MASK = 0x800051
- MS_SHARED = 0x100000
- MS_SILENT = 0x8000
- MS_SLAVE = 0x80000
- MS_STRICTATIME = 0x1000000
- MS_SYNC = 0x4
- MS_SYNCHRONOUS = 0x10
- MS_UNBINDABLE = 0x20000
- NAME_MAX = 0xff
- NETLINK_ADD_MEMBERSHIP = 0x1
- NETLINK_AUDIT = 0x9
- NETLINK_BROADCAST_ERROR = 0x4
- NETLINK_CONNECTOR = 0xb
- NETLINK_CRYPTO = 0x15
- NETLINK_DNRTMSG = 0xe
- NETLINK_DROP_MEMBERSHIP = 0x2
- NETLINK_ECRYPTFS = 0x13
- NETLINK_FIB_LOOKUP = 0xa
- NETLINK_FIREWALL = 0x3
- NETLINK_GENERIC = 0x10
- NETLINK_INET_DIAG = 0x4
- NETLINK_IP6_FW = 0xd
- NETLINK_ISCSI = 0x8
- NETLINK_KOBJECT_UEVENT = 0xf
- NETLINK_NETFILTER = 0xc
- NETLINK_NFLOG = 0x5
- NETLINK_NO_ENOBUFS = 0x5
- NETLINK_PKTINFO = 0x3
- NETLINK_RDMA = 0x14
- NETLINK_ROUTE = 0x0
- NETLINK_RX_RING = 0x6
- NETLINK_SCSITRANSPORT = 0x12
- NETLINK_SELINUX = 0x7
- NETLINK_SOCK_DIAG = 0x4
- NETLINK_TX_RING = 0x7
- NETLINK_UNUSED = 0x1
- NETLINK_USERSOCK = 0x2
- NETLINK_XFRM = 0x6
- NL0 = 0x0
- NL1 = 0x100
- NL2 = 0x200
- NL3 = 0x300
- NLA_ALIGNTO = 0x4
- NLA_F_NESTED = 0x8000
- NLA_F_NET_BYTEORDER = 0x4000
- NLA_HDRLEN = 0x4
- NLDLY = 0x300
- NLMSG_ALIGNTO = 0x4
- NLMSG_DONE = 0x3
- NLMSG_ERROR = 0x2
- NLMSG_HDRLEN = 0x10
- NLMSG_MIN_TYPE = 0x10
- NLMSG_NOOP = 0x1
- NLMSG_OVERRUN = 0x4
- NLM_F_ACK = 0x4
- NLM_F_APPEND = 0x800
- NLM_F_ATOMIC = 0x400
- NLM_F_CREATE = 0x400
- NLM_F_DUMP = 0x300
- NLM_F_DUMP_INTR = 0x10
- NLM_F_ECHO = 0x8
- NLM_F_EXCL = 0x200
- NLM_F_MATCH = 0x200
- NLM_F_MULTI = 0x2
- NLM_F_REPLACE = 0x100
- NLM_F_REQUEST = 0x1
- NLM_F_ROOT = 0x100
- NOFLSH = 0x80000000
- OCRNL = 0x8
- OFDEL = 0x80
- OFILL = 0x40
- OLCUC = 0x4
- ONLCR = 0x2
- ONLRET = 0x20
- ONOCR = 0x10
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x400
- O_ASYNC = 0x2000
- O_CLOEXEC = 0x80000
- O_CREAT = 0x40
- O_DIRECT = 0x20000
- O_DIRECTORY = 0x4000
- O_DSYNC = 0x1000
- O_EXCL = 0x80
- O_FSYNC = 0x101000
- O_LARGEFILE = 0x0
- O_NDELAY = 0x800
- O_NOATIME = 0x40000
- O_NOCTTY = 0x100
- O_NOFOLLOW = 0x8000
- O_NONBLOCK = 0x800
- O_PATH = 0x200000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_RSYNC = 0x101000
- O_SYNC = 0x101000
- O_TMPFILE = 0x410000
- O_TRUNC = 0x200
- O_WRONLY = 0x1
- PACKET_ADD_MEMBERSHIP = 0x1
- PACKET_AUXDATA = 0x8
- PACKET_BROADCAST = 0x1
- PACKET_COPY_THRESH = 0x7
- PACKET_DROP_MEMBERSHIP = 0x2
- PACKET_FANOUT = 0x12
- PACKET_FANOUT_CPU = 0x2
- PACKET_FANOUT_FLAG_DEFRAG = 0x8000
- PACKET_FANOUT_FLAG_ROLLOVER = 0x1000
- PACKET_FANOUT_HASH = 0x0
- PACKET_FANOUT_LB = 0x1
- PACKET_FANOUT_RND = 0x4
- PACKET_FANOUT_ROLLOVER = 0x3
- PACKET_FASTROUTE = 0x6
- PACKET_HDRLEN = 0xb
- PACKET_HOST = 0x0
- PACKET_LOOPBACK = 0x5
- PACKET_LOSS = 0xe
- PACKET_MR_ALLMULTI = 0x2
- PACKET_MR_MULTICAST = 0x0
- PACKET_MR_PROMISC = 0x1
- PACKET_MR_UNICAST = 0x3
- PACKET_MULTICAST = 0x2
- PACKET_ORIGDEV = 0x9
- PACKET_OTHERHOST = 0x3
- PACKET_OUTGOING = 0x4
- PACKET_RECV_OUTPUT = 0x3
- PACKET_RESERVE = 0xc
- PACKET_RX_RING = 0x5
- PACKET_STATISTICS = 0x6
- PACKET_TIMESTAMP = 0x11
- PACKET_TX_HAS_OFF = 0x13
- PACKET_TX_RING = 0xd
- PACKET_TX_TIMESTAMP = 0x10
- PACKET_VERSION = 0xa
- PACKET_VNET_HDR = 0xf
- PARENB = 0x1000
- PARITY_CRC16_PR0 = 0x2
- PARITY_CRC16_PR0_CCITT = 0x4
- PARITY_CRC16_PR1 = 0x3
- PARITY_CRC16_PR1_CCITT = 0x5
- PARITY_CRC32_PR0_CCITT = 0x6
- PARITY_CRC32_PR1_CCITT = 0x7
- PARITY_DEFAULT = 0x0
- PARITY_NONE = 0x1
- PARMRK = 0x8
- PARODD = 0x2000
- PENDIN = 0x20000000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_GROWSDOWN = 0x1000000
- PROT_GROWSUP = 0x2000000
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_SAO = 0x10
- PROT_WRITE = 0x2
- PR_CAPBSET_DROP = 0x18
- PR_CAPBSET_READ = 0x17
- PR_ENDIAN_BIG = 0x0
- PR_ENDIAN_LITTLE = 0x1
- PR_ENDIAN_PPC_LITTLE = 0x2
- PR_FPEMU_NOPRINT = 0x1
- PR_FPEMU_SIGFPE = 0x2
- PR_FP_EXC_ASYNC = 0x2
- PR_FP_EXC_DISABLED = 0x0
- PR_FP_EXC_DIV = 0x10000
- PR_FP_EXC_INV = 0x100000
- PR_FP_EXC_NONRECOV = 0x1
- PR_FP_EXC_OVF = 0x20000
- PR_FP_EXC_PRECISE = 0x3
- PR_FP_EXC_RES = 0x80000
- PR_FP_EXC_SW_ENABLE = 0x80
- PR_FP_EXC_UND = 0x40000
- PR_GET_CHILD_SUBREAPER = 0x25
- PR_GET_DUMPABLE = 0x3
- PR_GET_ENDIAN = 0x13
- PR_GET_FPEMU = 0x9
- PR_GET_FPEXC = 0xb
- PR_GET_KEEPCAPS = 0x7
- PR_GET_NAME = 0x10
- PR_GET_NO_NEW_PRIVS = 0x27
- PR_GET_PDEATHSIG = 0x2
- PR_GET_SECCOMP = 0x15
- PR_GET_SECUREBITS = 0x1b
- PR_GET_TID_ADDRESS = 0x28
- PR_GET_TIMERSLACK = 0x1e
- PR_GET_TIMING = 0xd
- PR_GET_TSC = 0x19
- PR_GET_UNALIGN = 0x5
- PR_MCE_KILL = 0x21
- PR_MCE_KILL_CLEAR = 0x0
- PR_MCE_KILL_DEFAULT = 0x2
- PR_MCE_KILL_EARLY = 0x1
- PR_MCE_KILL_GET = 0x22
- PR_MCE_KILL_LATE = 0x0
- PR_MCE_KILL_SET = 0x1
- PR_SET_CHILD_SUBREAPER = 0x24
- PR_SET_DUMPABLE = 0x4
- PR_SET_ENDIAN = 0x14
- PR_SET_FPEMU = 0xa
- PR_SET_FPEXC = 0xc
- PR_SET_KEEPCAPS = 0x8
- PR_SET_MM = 0x23
- PR_SET_MM_ARG_END = 0x9
- PR_SET_MM_ARG_START = 0x8
- PR_SET_MM_AUXV = 0xc
- PR_SET_MM_BRK = 0x7
- PR_SET_MM_END_CODE = 0x2
- PR_SET_MM_END_DATA = 0x4
- PR_SET_MM_ENV_END = 0xb
- PR_SET_MM_ENV_START = 0xa
- PR_SET_MM_EXE_FILE = 0xd
- PR_SET_MM_START_BRK = 0x6
- PR_SET_MM_START_CODE = 0x1
- PR_SET_MM_START_DATA = 0x3
- PR_SET_MM_START_STACK = 0x5
- PR_SET_NAME = 0xf
- PR_SET_NO_NEW_PRIVS = 0x26
- PR_SET_PDEATHSIG = 0x1
- PR_SET_PTRACER = 0x59616d61
- PR_SET_PTRACER_ANY = -0x1
- PR_SET_SECCOMP = 0x16
- PR_SET_SECUREBITS = 0x1c
- PR_SET_TIMERSLACK = 0x1d
- PR_SET_TIMING = 0xe
- PR_SET_TSC = 0x1a
- PR_SET_UNALIGN = 0x6
- PR_TASK_PERF_EVENTS_DISABLE = 0x1f
- PR_TASK_PERF_EVENTS_ENABLE = 0x20
- PR_TIMING_STATISTICAL = 0x0
- PR_TIMING_TIMESTAMP = 0x1
- PR_TSC_ENABLE = 0x1
- PR_TSC_SIGSEGV = 0x2
- PR_UNALIGN_NOPRINT = 0x1
- PR_UNALIGN_SIGBUS = 0x2
- PTRACE_ATTACH = 0x10
- PTRACE_CONT = 0x7
- PTRACE_DETACH = 0x11
- PTRACE_EVENT_CLONE = 0x3
- PTRACE_EVENT_EXEC = 0x4
- PTRACE_EVENT_EXIT = 0x6
- PTRACE_EVENT_FORK = 0x1
- PTRACE_EVENT_SECCOMP = 0x7
- PTRACE_EVENT_STOP = 0x80
- PTRACE_EVENT_VFORK = 0x2
- PTRACE_EVENT_VFORK_DONE = 0x5
- PTRACE_GETEVENTMSG = 0x4201
- PTRACE_GETEVRREGS = 0x14
- PTRACE_GETFPREGS = 0xe
- PTRACE_GETREGS = 0xc
- PTRACE_GETREGS64 = 0x16
- PTRACE_GETREGSET = 0x4204
- PTRACE_GETSIGINFO = 0x4202
- PTRACE_GETSIGMASK = 0x420a
- PTRACE_GETVRREGS = 0x12
- PTRACE_GETVSRREGS = 0x1b
- PTRACE_GET_DEBUGREG = 0x19
- PTRACE_INTERRUPT = 0x4207
- PTRACE_KILL = 0x8
- PTRACE_LISTEN = 0x4208
- PTRACE_O_EXITKILL = 0x100000
- PTRACE_O_MASK = 0x1000ff
- PTRACE_O_TRACECLONE = 0x8
- PTRACE_O_TRACEEXEC = 0x10
- PTRACE_O_TRACEEXIT = 0x40
- PTRACE_O_TRACEFORK = 0x2
- PTRACE_O_TRACESECCOMP = 0x80
- PTRACE_O_TRACESYSGOOD = 0x1
- PTRACE_O_TRACEVFORK = 0x4
- PTRACE_O_TRACEVFORKDONE = 0x20
- PTRACE_PEEKDATA = 0x2
- PTRACE_PEEKSIGINFO = 0x4209
- PTRACE_PEEKSIGINFO_SHARED = 0x1
- PTRACE_PEEKTEXT = 0x1
- PTRACE_PEEKUSR = 0x3
- PTRACE_POKEDATA = 0x5
- PTRACE_POKETEXT = 0x4
- PTRACE_POKEUSR = 0x6
- PTRACE_SEIZE = 0x4206
- PTRACE_SETEVRREGS = 0x15
- PTRACE_SETFPREGS = 0xf
- PTRACE_SETOPTIONS = 0x4200
- PTRACE_SETREGS = 0xd
- PTRACE_SETREGS64 = 0x17
- PTRACE_SETREGSET = 0x4205
- PTRACE_SETSIGINFO = 0x4203
- PTRACE_SETSIGMASK = 0x420b
- PTRACE_SETVRREGS = 0x13
- PTRACE_SETVSRREGS = 0x1c
- PTRACE_SET_DEBUGREG = 0x1a
- PTRACE_SINGLEBLOCK = 0x100
- PTRACE_SINGLESTEP = 0x9
- PTRACE_SYSCALL = 0x18
- PTRACE_TRACEME = 0x0
- PT_CCR = 0x26
- PT_CTR = 0x23
- PT_DAR = 0x29
- PT_DSCR = 0x2c
- PT_DSISR = 0x2a
- PT_FPR0 = 0x30
- PT_FPSCR = 0x50
- PT_LNK = 0x24
- PT_MSR = 0x21
- PT_NIP = 0x20
- PT_ORIG_R3 = 0x22
- PT_R0 = 0x0
- PT_R1 = 0x1
- PT_R10 = 0xa
- PT_R11 = 0xb
- PT_R12 = 0xc
- PT_R13 = 0xd
- PT_R14 = 0xe
- PT_R15 = 0xf
- PT_R16 = 0x10
- PT_R17 = 0x11
- PT_R18 = 0x12
- PT_R19 = 0x13
- PT_R2 = 0x2
- PT_R20 = 0x14
- PT_R21 = 0x15
- PT_R22 = 0x16
- PT_R23 = 0x17
- PT_R24 = 0x18
- PT_R25 = 0x19
- PT_R26 = 0x1a
- PT_R27 = 0x1b
- PT_R28 = 0x1c
- PT_R29 = 0x1d
- PT_R3 = 0x3
- PT_R30 = 0x1e
- PT_R31 = 0x1f
- PT_R4 = 0x4
- PT_R5 = 0x5
- PT_R6 = 0x6
- PT_R7 = 0x7
- PT_R8 = 0x8
- PT_R9 = 0x9
- PT_REGS_COUNT = 0x2c
- PT_RESULT = 0x2b
- PT_SOFTE = 0x27
- PT_TRAP = 0x28
- PT_VR0 = 0x52
- PT_VRSAVE = 0x94
- PT_VSCR = 0x93
- PT_VSR0 = 0x96
- PT_VSR31 = 0xd4
- PT_XER = 0x25
- RLIMIT_AS = 0x9
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x7
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = -0x1
- RTAX_ADVMSS = 0x8
- RTAX_CWND = 0x7
- RTAX_FEATURES = 0xc
- RTAX_FEATURE_ALLFRAG = 0x8
- RTAX_FEATURE_ECN = 0x1
- RTAX_FEATURE_SACK = 0x2
- RTAX_FEATURE_TIMESTAMP = 0x4
- RTAX_HOPLIMIT = 0xa
- RTAX_INITCWND = 0xb
- RTAX_INITRWND = 0xe
- RTAX_LOCK = 0x1
- RTAX_MAX = 0xf
- RTAX_MTU = 0x2
- RTAX_QUICKACK = 0xf
- RTAX_REORDERING = 0x9
- RTAX_RTO_MIN = 0xd
- RTAX_RTT = 0x4
- RTAX_RTTVAR = 0x5
- RTAX_SSTHRESH = 0x6
- RTAX_UNSPEC = 0x0
- RTAX_WINDOW = 0x3
- RTA_ALIGNTO = 0x4
- RTA_MAX = 0x11
- RTCF_DIRECTSRC = 0x4000000
- RTCF_DOREDIRECT = 0x1000000
- RTCF_LOG = 0x2000000
- RTCF_MASQ = 0x400000
- RTCF_NAT = 0x800000
- RTCF_VALVE = 0x200000
- RTF_ADDRCLASSMASK = 0xf8000000
- RTF_ADDRCONF = 0x40000
- RTF_ALLONLINK = 0x20000
- RTF_BROADCAST = 0x10000000
- RTF_CACHE = 0x1000000
- RTF_DEFAULT = 0x10000
- RTF_DYNAMIC = 0x10
- RTF_FLOW = 0x2000000
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_INTERFACE = 0x40000000
- RTF_IRTT = 0x100
- RTF_LINKRT = 0x100000
- RTF_LOCAL = 0x80000000
- RTF_MODIFIED = 0x20
- RTF_MSS = 0x40
- RTF_MTU = 0x40
- RTF_MULTICAST = 0x20000000
- RTF_NAT = 0x8000000
- RTF_NOFORWARD = 0x1000
- RTF_NONEXTHOP = 0x200000
- RTF_NOPMTUDISC = 0x4000
- RTF_POLICY = 0x4000000
- RTF_REINSTATE = 0x8
- RTF_REJECT = 0x200
- RTF_STATIC = 0x400
- RTF_THROW = 0x2000
- RTF_UP = 0x1
- RTF_WINDOW = 0x80
- RTF_XRESOLVE = 0x800
- RTM_BASE = 0x10
- RTM_DELACTION = 0x31
- RTM_DELADDR = 0x15
- RTM_DELADDRLABEL = 0x49
- RTM_DELLINK = 0x11
- RTM_DELMDB = 0x55
- RTM_DELNEIGH = 0x1d
- RTM_DELQDISC = 0x25
- RTM_DELROUTE = 0x19
- RTM_DELRULE = 0x21
- RTM_DELTCLASS = 0x29
- RTM_DELTFILTER = 0x2d
- RTM_F_CLONED = 0x200
- RTM_F_EQUALIZE = 0x400
- RTM_F_NOTIFY = 0x100
- RTM_F_PREFIX = 0x800
- RTM_GETACTION = 0x32
- RTM_GETADDR = 0x16
- RTM_GETADDRLABEL = 0x4a
- RTM_GETANYCAST = 0x3e
- RTM_GETDCB = 0x4e
- RTM_GETLINK = 0x12
- RTM_GETMDB = 0x56
- RTM_GETMULTICAST = 0x3a
- RTM_GETNEIGH = 0x1e
- RTM_GETNEIGHTBL = 0x42
- RTM_GETNETCONF = 0x52
- RTM_GETQDISC = 0x26
- RTM_GETROUTE = 0x1a
- RTM_GETRULE = 0x22
- RTM_GETTCLASS = 0x2a
- RTM_GETTFILTER = 0x2e
- RTM_MAX = 0x57
- RTM_NEWACTION = 0x30
- RTM_NEWADDR = 0x14
- RTM_NEWADDRLABEL = 0x48
- RTM_NEWLINK = 0x10
- RTM_NEWMDB = 0x54
- RTM_NEWNDUSEROPT = 0x44
- RTM_NEWNEIGH = 0x1c
- RTM_NEWNEIGHTBL = 0x40
- RTM_NEWNETCONF = 0x50
- RTM_NEWPREFIX = 0x34
- RTM_NEWQDISC = 0x24
- RTM_NEWROUTE = 0x18
- RTM_NEWRULE = 0x20
- RTM_NEWTCLASS = 0x28
- RTM_NEWTFILTER = 0x2c
- RTM_NR_FAMILIES = 0x12
- RTM_NR_MSGTYPES = 0x48
- RTM_SETDCB = 0x4f
- RTM_SETLINK = 0x13
- RTM_SETNEIGHTBL = 0x43
- RTNH_ALIGNTO = 0x4
- RTNH_F_DEAD = 0x1
- RTNH_F_ONLINK = 0x4
- RTNH_F_PERVASIVE = 0x2
- RTN_MAX = 0xb
- RTPROT_BIRD = 0xc
- RTPROT_BOOT = 0x3
- RTPROT_DHCP = 0x10
- RTPROT_DNROUTED = 0xd
- RTPROT_GATED = 0x8
- RTPROT_KERNEL = 0x2
- RTPROT_MROUTED = 0x11
- RTPROT_MRT = 0xa
- RTPROT_NTK = 0xf
- RTPROT_RA = 0x9
- RTPROT_REDIRECT = 0x1
- RTPROT_STATIC = 0x4
- RTPROT_UNSPEC = 0x0
- RTPROT_XORP = 0xe
- RTPROT_ZEBRA = 0xb
- RT_CLASS_DEFAULT = 0xfd
- RT_CLASS_LOCAL = 0xff
- RT_CLASS_MAIN = 0xfe
- RT_CLASS_MAX = 0xff
- RT_CLASS_UNSPEC = 0x0
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- RUSAGE_THREAD = 0x1
- SCM_CREDENTIALS = 0x2
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x1d
- SCM_TIMESTAMPING = 0x25
- SCM_TIMESTAMPNS = 0x23
- SCM_WIFI_STATUS = 0x29
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDDLCI = 0x8980
- SIOCADDMULTI = 0x8931
- SIOCADDRT = 0x890b
- SIOCATMARK = 0x8905
- SIOCDARP = 0x8953
- SIOCDELDLCI = 0x8981
- SIOCDELMULTI = 0x8932
- SIOCDELRT = 0x890c
- SIOCDEVPRIVATE = 0x89f0
- SIOCDIFADDR = 0x8936
- SIOCDRARP = 0x8960
- SIOCGARP = 0x8954
- SIOCGIFADDR = 0x8915
- SIOCGIFBR = 0x8940
- SIOCGIFBRDADDR = 0x8919
- SIOCGIFCONF = 0x8912
- SIOCGIFCOUNT = 0x8938
- SIOCGIFDSTADDR = 0x8917
- SIOCGIFENCAP = 0x8925
- SIOCGIFFLAGS = 0x8913
- SIOCGIFHWADDR = 0x8927
- SIOCGIFINDEX = 0x8933
- SIOCGIFMAP = 0x8970
- SIOCGIFMEM = 0x891f
- SIOCGIFMETRIC = 0x891d
- SIOCGIFMTU = 0x8921
- SIOCGIFNAME = 0x8910
- SIOCGIFNETMASK = 0x891b
- SIOCGIFPFLAGS = 0x8935
- SIOCGIFSLAVE = 0x8929
- SIOCGIFTXQLEN = 0x8942
- SIOCGPGRP = 0x8904
- SIOCGRARP = 0x8961
- SIOCGSTAMP = 0x8906
- SIOCGSTAMPNS = 0x8907
- SIOCPROTOPRIVATE = 0x89e0
- SIOCRTMSG = 0x890d
- SIOCSARP = 0x8955
- SIOCSIFADDR = 0x8916
- SIOCSIFBR = 0x8941
- SIOCSIFBRDADDR = 0x891a
- SIOCSIFDSTADDR = 0x8918
- SIOCSIFENCAP = 0x8926
- SIOCSIFFLAGS = 0x8914
- SIOCSIFHWADDR = 0x8924
- SIOCSIFHWBROADCAST = 0x8937
- SIOCSIFLINK = 0x8911
- SIOCSIFMAP = 0x8971
- SIOCSIFMEM = 0x8920
- SIOCSIFMETRIC = 0x891e
- SIOCSIFMTU = 0x8922
- SIOCSIFNAME = 0x8923
- SIOCSIFNETMASK = 0x891c
- SIOCSIFPFLAGS = 0x8934
- SIOCSIFSLAVE = 0x8930
- SIOCSIFTXQLEN = 0x8943
- SIOCSPGRP = 0x8902
- SIOCSRARP = 0x8962
- SOCK_CLOEXEC = 0x80000
- SOCK_DCCP = 0x6
- SOCK_DGRAM = 0x2
- SOCK_NONBLOCK = 0x800
- SOCK_PACKET = 0xa
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_AAL = 0x109
- SOL_ATM = 0x108
- SOL_DECNET = 0x105
- SOL_ICMPV6 = 0x3a
- SOL_IP = 0x0
- SOL_IPV6 = 0x29
- SOL_IRDA = 0x10a
- SOL_PACKET = 0x107
- SOL_RAW = 0xff
- SOL_SOCKET = 0x1
- SOL_TCP = 0x6
- SOL_X25 = 0x106
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x1e
- SO_ATTACH_FILTER = 0x1a
- SO_BINDTODEVICE = 0x19
- SO_BROADCAST = 0x6
- SO_BSDCOMPAT = 0xe
- SO_BUSY_POLL = 0x2e
- SO_DEBUG = 0x1
- SO_DETACH_FILTER = 0x1b
- SO_DOMAIN = 0x27
- SO_DONTROUTE = 0x5
- SO_ERROR = 0x4
- SO_GET_FILTER = 0x1a
- SO_KEEPALIVE = 0x9
- SO_LINGER = 0xd
- SO_LOCK_FILTER = 0x2c
- SO_MARK = 0x24
- SO_MAX_PACING_RATE = 0x2f
- SO_NOFCS = 0x2b
- SO_NO_CHECK = 0xb
- SO_OOBINLINE = 0xa
- SO_PASSCRED = 0x14
- SO_PASSSEC = 0x22
- SO_PEEK_OFF = 0x2a
- SO_PEERCRED = 0x15
- SO_PEERNAME = 0x1c
- SO_PEERSEC = 0x1f
- SO_PRIORITY = 0xc
- SO_PROTOCOL = 0x26
- SO_RCVBUF = 0x8
- SO_RCVBUFFORCE = 0x21
- SO_RCVLOWAT = 0x10
- SO_RCVTIMEO = 0x12
- SO_REUSEADDR = 0x2
- SO_REUSEPORT = 0xf
- SO_RXQ_OVFL = 0x28
- SO_SECURITY_AUTHENTICATION = 0x16
- SO_SECURITY_ENCRYPTION_NETWORK = 0x18
- SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17
- SO_SELECT_ERR_QUEUE = 0x2d
- SO_SNDBUF = 0x7
- SO_SNDBUFFORCE = 0x20
- SO_SNDLOWAT = 0x11
- SO_SNDTIMEO = 0x13
- SO_TIMESTAMP = 0x1d
- SO_TIMESTAMPING = 0x25
- SO_TIMESTAMPNS = 0x23
- SO_TYPE = 0x3
- SO_WIFI_STATUS = 0x29
- S_BLKSIZE = 0x200
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TAB0 = 0x0
- TAB1 = 0x400
- TAB2 = 0x800
- TAB3 = 0xc00
- TABDLY = 0xc00
- TCFLSH = 0x2000741f
- TCGETA = 0x40147417
- TCGETS = 0x402c7413
- TCIFLUSH = 0x0
- TCIOFF = 0x2
- TCIOFLUSH = 0x2
- TCION = 0x3
- TCOFLUSH = 0x1
- TCOOFF = 0x0
- TCOON = 0x1
- TCP_CONGESTION = 0xd
- TCP_COOKIE_IN_ALWAYS = 0x1
- TCP_COOKIE_MAX = 0x10
- TCP_COOKIE_MIN = 0x8
- TCP_COOKIE_OUT_NEVER = 0x2
- TCP_COOKIE_PAIR_SIZE = 0x20
- TCP_COOKIE_TRANSACTIONS = 0xf
- TCP_CORK = 0x3
- TCP_DEFER_ACCEPT = 0x9
- TCP_FASTOPEN = 0x17
- TCP_INFO = 0xb
- TCP_KEEPCNT = 0x6
- TCP_KEEPIDLE = 0x4
- TCP_KEEPINTVL = 0x5
- TCP_LINGER2 = 0x8
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0xe
- TCP_MD5SIG_MAXKEYLEN = 0x50
- TCP_MSS = 0x200
- TCP_MSS_DEFAULT = 0x218
- TCP_MSS_DESIRED = 0x4c4
- TCP_NODELAY = 0x1
- TCP_QUEUE_SEQ = 0x15
- TCP_QUICKACK = 0xc
- TCP_REPAIR = 0x13
- TCP_REPAIR_OPTIONS = 0x16
- TCP_REPAIR_QUEUE = 0x14
- TCP_SYNCNT = 0x7
- TCP_S_DATA_IN = 0x4
- TCP_S_DATA_OUT = 0x8
- TCP_THIN_DUPACK = 0x11
- TCP_THIN_LINEAR_TIMEOUTS = 0x10
- TCP_TIMESTAMP = 0x18
- TCP_USER_TIMEOUT = 0x12
- TCP_WINDOW_CLAMP = 0xa
- TCSAFLUSH = 0x2
- TCSBRK = 0x2000741d
- TCSBRKP = 0x5425
- TCSETA = 0x80147418
- TCSETAF = 0x8014741c
- TCSETAW = 0x80147419
- TCSETS = 0x802c7414
- TCSETSF = 0x802c7416
- TCSETSW = 0x802c7415
- TCXONC = 0x2000741e
- TIOCCBRK = 0x5428
- TIOCCONS = 0x541d
- TIOCEXCL = 0x540c
- TIOCGDEV = 0x40045432
- TIOCGETC = 0x40067412
- TIOCGETD = 0x5424
- TIOCGETP = 0x40067408
- TIOCGEXCL = 0x40045440
- TIOCGICOUNT = 0x545d
- TIOCGLCKTRMIOS = 0x5456
- TIOCGLTC = 0x40067474
- TIOCGPGRP = 0x40047477
- TIOCGPKT = 0x40045438
- TIOCGPTLCK = 0x40045439
- TIOCGPTN = 0x40045430
- TIOCGRS485 = 0x542e
- TIOCGSERIAL = 0x541e
- TIOCGSID = 0x5429
- TIOCGSOFTCAR = 0x5419
- TIOCGWINSZ = 0x40087468
- TIOCINQ = 0x4004667f
- TIOCLINUX = 0x541c
- TIOCMBIC = 0x5417
- TIOCMBIS = 0x5416
- TIOCMGET = 0x5415
- TIOCMIWAIT = 0x545c
- TIOCMSET = 0x5418
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_LOOP = 0x8000
- TIOCM_OUT1 = 0x2000
- TIOCM_OUT2 = 0x4000
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x5422
- TIOCNXCL = 0x540d
- TIOCOUTQ = 0x40047473
- TIOCPKT = 0x5420
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCSBRK = 0x5427
- TIOCSCTTY = 0x540e
- TIOCSERCONFIG = 0x5453
- TIOCSERGETLSR = 0x5459
- TIOCSERGETMULTI = 0x545a
- TIOCSERGSTRUCT = 0x5458
- TIOCSERGWILD = 0x5454
- TIOCSERSETMULTI = 0x545b
- TIOCSERSWILD = 0x5455
- TIOCSER_TEMT = 0x1
- TIOCSETC = 0x80067411
- TIOCSETD = 0x5423
- TIOCSETN = 0x8006740a
- TIOCSETP = 0x80067409
- TIOCSIG = 0x80045436
- TIOCSLCKTRMIOS = 0x5457
- TIOCSLTC = 0x80067475
- TIOCSPGRP = 0x80047476
- TIOCSPTLCK = 0x80045431
- TIOCSRS485 = 0x542f
- TIOCSSERIAL = 0x541f
- TIOCSSOFTCAR = 0x541a
- TIOCSTART = 0x2000746e
- TIOCSTI = 0x5412
- TIOCSTOP = 0x2000746f
- TIOCSWINSZ = 0x80087467
- TIOCVHANGUP = 0x5437
- TOSTOP = 0x400000
- TUNATTACHFILTER = 0x801054d5
- TUNDETACHFILTER = 0x801054d6
- TUNGETFEATURES = 0x400454cf
- TUNGETFILTER = 0x401054db
- TUNGETIFF = 0x400454d2
- TUNGETSNDBUF = 0x400454d3
- TUNGETVNETHDRSZ = 0x400454d7
- TUNSETDEBUG = 0x800454c9
- TUNSETGROUP = 0x800454ce
- TUNSETIFF = 0x800454ca
- TUNSETIFINDEX = 0x800454da
- TUNSETLINK = 0x800454cd
- TUNSETNOCSUM = 0x800454c8
- TUNSETOFFLOAD = 0x800454d0
- TUNSETOWNER = 0x800454cc
- TUNSETPERSIST = 0x800454cb
- TUNSETQUEUE = 0x800454d9
- TUNSETSNDBUF = 0x800454d4
- TUNSETTXFILTER = 0x800454d1
- TUNSETVNETHDRSZ = 0x800454d8
- VDISCARD = 0x10
- VEOF = 0x4
- VEOL = 0x6
- VEOL2 = 0x8
- VERASE = 0x2
- VINTR = 0x0
- VKILL = 0x3
- VLNEXT = 0xf
- VMIN = 0x5
- VQUIT = 0x1
- VREPRINT = 0xb
- VSTART = 0xd
- VSTOP = 0xe
- VSUSP = 0xc
- VSWTC = 0x9
- VT0 = 0x0
- VT1 = 0x10000
- VTDLY = 0x10000
- VTIME = 0x7
- VWERASE = 0xa
- WALL = 0x40000000
- WCLONE = 0x80000000
- WCONTINUED = 0x8
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOTHREAD = 0x20000000
- WNOWAIT = 0x1000000
- WORDSIZE = 0x40
- WSTOPPED = 0x2
- WUNTRACED = 0x2
- XCASE = 0x4000
- XTABS = 0xc00
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x62)
- EADDRNOTAVAIL = syscall.Errno(0x63)
- EADV = syscall.Errno(0x44)
- EAFNOSUPPORT = syscall.Errno(0x61)
- EAGAIN = syscall.Errno(0xb)
- EALREADY = syscall.Errno(0x72)
- EBADE = syscall.Errno(0x34)
- EBADF = syscall.Errno(0x9)
- EBADFD = syscall.Errno(0x4d)
- EBADMSG = syscall.Errno(0x4a)
- EBADR = syscall.Errno(0x35)
- EBADRQC = syscall.Errno(0x38)
- EBADSLT = syscall.Errno(0x39)
- EBFONT = syscall.Errno(0x3b)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x7d)
- ECHILD = syscall.Errno(0xa)
- ECHRNG = syscall.Errno(0x2c)
- ECOMM = syscall.Errno(0x46)
- ECONNABORTED = syscall.Errno(0x67)
- ECONNREFUSED = syscall.Errno(0x6f)
- ECONNRESET = syscall.Errno(0x68)
- EDEADLK = syscall.Errno(0x23)
- EDEADLOCK = syscall.Errno(0x3a)
- EDESTADDRREQ = syscall.Errno(0x59)
- EDOM = syscall.Errno(0x21)
- EDOTDOT = syscall.Errno(0x49)
- EDQUOT = syscall.Errno(0x7a)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EHOSTDOWN = syscall.Errno(0x70)
- EHOSTUNREACH = syscall.Errno(0x71)
- EHWPOISON = syscall.Errno(0x85)
- EIDRM = syscall.Errno(0x2b)
- EILSEQ = syscall.Errno(0x54)
- EINPROGRESS = syscall.Errno(0x73)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x6a)
- EISDIR = syscall.Errno(0x15)
- EISNAM = syscall.Errno(0x78)
- EKEYEXPIRED = syscall.Errno(0x7f)
- EKEYREJECTED = syscall.Errno(0x81)
- EKEYREVOKED = syscall.Errno(0x80)
- EL2HLT = syscall.Errno(0x33)
- EL2NSYNC = syscall.Errno(0x2d)
- EL3HLT = syscall.Errno(0x2e)
- EL3RST = syscall.Errno(0x2f)
- ELIBACC = syscall.Errno(0x4f)
- ELIBBAD = syscall.Errno(0x50)
- ELIBEXEC = syscall.Errno(0x53)
- ELIBMAX = syscall.Errno(0x52)
- ELIBSCN = syscall.Errno(0x51)
- ELNRNG = syscall.Errno(0x30)
- ELOOP = syscall.Errno(0x28)
- EMEDIUMTYPE = syscall.Errno(0x7c)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x5a)
- EMULTIHOP = syscall.Errno(0x48)
- ENAMETOOLONG = syscall.Errno(0x24)
- ENAVAIL = syscall.Errno(0x77)
- ENETDOWN = syscall.Errno(0x64)
- ENETRESET = syscall.Errno(0x66)
- ENETUNREACH = syscall.Errno(0x65)
- ENFILE = syscall.Errno(0x17)
- ENOANO = syscall.Errno(0x37)
- ENOBUFS = syscall.Errno(0x69)
- ENOCSI = syscall.Errno(0x32)
- ENODATA = syscall.Errno(0x3d)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOKEY = syscall.Errno(0x7e)
- ENOLCK = syscall.Errno(0x25)
- ENOLINK = syscall.Errno(0x43)
- ENOMEDIUM = syscall.Errno(0x7b)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x2a)
- ENONET = syscall.Errno(0x40)
- ENOPKG = syscall.Errno(0x41)
- ENOPROTOOPT = syscall.Errno(0x5c)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x3f)
- ENOSTR = syscall.Errno(0x3c)
- ENOSYS = syscall.Errno(0x26)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x6b)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x27)
- ENOTNAM = syscall.Errno(0x76)
- ENOTRECOVERABLE = syscall.Errno(0x83)
- ENOTSOCK = syscall.Errno(0x58)
- ENOTSUP = syscall.Errno(0x5f)
- ENOTTY = syscall.Errno(0x19)
- ENOTUNIQ = syscall.Errno(0x4c)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x5f)
- EOVERFLOW = syscall.Errno(0x4b)
- EOWNERDEAD = syscall.Errno(0x82)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x60)
- EPIPE = syscall.Errno(0x20)
- EPROTO = syscall.Errno(0x47)
- EPROTONOSUPPORT = syscall.Errno(0x5d)
- EPROTOTYPE = syscall.Errno(0x5b)
- ERANGE = syscall.Errno(0x22)
- EREMCHG = syscall.Errno(0x4e)
- EREMOTE = syscall.Errno(0x42)
- EREMOTEIO = syscall.Errno(0x79)
- ERESTART = syscall.Errno(0x55)
- ERFKILL = syscall.Errno(0x84)
- EROFS = syscall.Errno(0x1e)
- ESHUTDOWN = syscall.Errno(0x6c)
- ESOCKTNOSUPPORT = syscall.Errno(0x5e)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESRMNT = syscall.Errno(0x45)
- ESTALE = syscall.Errno(0x74)
- ESTRPIPE = syscall.Errno(0x56)
- ETIME = syscall.Errno(0x3e)
- ETIMEDOUT = syscall.Errno(0x6e)
- ETOOMANYREFS = syscall.Errno(0x6d)
- ETXTBSY = syscall.Errno(0x1a)
- EUCLEAN = syscall.Errno(0x75)
- EUNATCH = syscall.Errno(0x31)
- EUSERS = syscall.Errno(0x57)
- EWOULDBLOCK = syscall.Errno(0xb)
- EXDEV = syscall.Errno(0x12)
- EXFULL = syscall.Errno(0x36)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0x7)
- SIGCHLD = syscall.Signal(0x11)
- SIGCLD = syscall.Signal(0x11)
- SIGCONT = syscall.Signal(0x12)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x1d)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPOLL = syscall.Signal(0x1d)
- SIGPROF = syscall.Signal(0x1b)
- SIGPWR = syscall.Signal(0x1e)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTKFLT = syscall.Signal(0x10)
- SIGSTOP = syscall.Signal(0x13)
- SIGSYS = syscall.Signal(0x1f)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x14)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGUNUSED = syscall.Signal(0x1f)
- SIGURG = syscall.Signal(0x17)
- SIGUSR1 = syscall.Signal(0xa)
- SIGUSR2 = syscall.Signal(0xc)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "no such device or address",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource temporarily unavailable",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device or resource busy",
- 17: "file exists",
- 18: "invalid cross-device link",
- 19: "no such device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "numerical result out of range",
- 35: "resource deadlock avoided",
- 36: "file name too long",
- 37: "no locks available",
- 38: "function not implemented",
- 39: "directory not empty",
- 40: "too many levels of symbolic links",
- 42: "no message of desired type",
- 43: "identifier removed",
- 44: "channel number out of range",
- 45: "level 2 not synchronized",
- 46: "level 3 halted",
- 47: "level 3 reset",
- 48: "link number out of range",
- 49: "protocol driver not attached",
- 50: "no CSI structure available",
- 51: "level 2 halted",
- 52: "invalid exchange",
- 53: "invalid request descriptor",
- 54: "exchange full",
- 55: "no anode",
- 56: "invalid request code",
- 57: "invalid slot",
- 58: "file locking deadlock error",
- 59: "bad font file format",
- 60: "device not a stream",
- 61: "no data available",
- 62: "timer expired",
- 63: "out of streams resources",
- 64: "machine is not on the network",
- 65: "package not installed",
- 66: "object is remote",
- 67: "link has been severed",
- 68: "advertise error",
- 69: "srmount error",
- 70: "communication error on send",
- 71: "protocol error",
- 72: "multihop attempted",
- 73: "RFS specific error",
- 74: "bad message",
- 75: "value too large for defined data type",
- 76: "name not unique on network",
- 77: "file descriptor in bad state",
- 78: "remote address changed",
- 79: "can not access a needed shared library",
- 80: "accessing a corrupted shared library",
- 81: ".lib section in a.out corrupted",
- 82: "attempting to link in too many shared libraries",
- 83: "cannot exec a shared library directly",
- 84: "invalid or incomplete multibyte or wide character",
- 85: "interrupted system call should be restarted",
- 86: "streams pipe error",
- 87: "too many users",
- 88: "socket operation on non-socket",
- 89: "destination address required",
- 90: "message too long",
- 91: "protocol wrong type for socket",
- 92: "protocol not available",
- 93: "protocol not supported",
- 94: "socket type not supported",
- 95: "operation not supported",
- 96: "protocol family not supported",
- 97: "address family not supported by protocol",
- 98: "address already in use",
- 99: "cannot assign requested address",
- 100: "network is down",
- 101: "network is unreachable",
- 102: "network dropped connection on reset",
- 103: "software caused connection abort",
- 104: "connection reset by peer",
- 105: "no buffer space available",
- 106: "transport endpoint is already connected",
- 107: "transport endpoint is not connected",
- 108: "cannot send after transport endpoint shutdown",
- 109: "too many references: cannot splice",
- 110: "connection timed out",
- 111: "connection refused",
- 112: "host is down",
- 113: "no route to host",
- 114: "operation already in progress",
- 115: "operation now in progress",
- 116: "stale file handle",
- 117: "structure needs cleaning",
- 118: "not a XENIX named type file",
- 119: "no XENIX semaphores available",
- 120: "is a named type file",
- 121: "remote I/O error",
- 122: "disk quota exceeded",
- 123: "no medium found",
- 124: "wrong medium type",
- 125: "operation canceled",
- 126: "required key not available",
- 127: "key has expired",
- 128: "key has been revoked",
- 129: "key was rejected by service",
- 130: "owner died",
- 131: "state not recoverable",
- 132: "operation not possible due to RF-kill",
- 133: "memory page has hardware error",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/breakpoint trap",
- 6: "aborted",
- 7: "bus error",
- 8: "floating point exception",
- 9: "killed",
- 10: "user defined signal 1",
- 11: "segmentation fault",
- 12: "user defined signal 2",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "stack fault",
- 17: "child exited",
- 18: "continued",
- 19: "stopped (signal)",
- 20: "stopped",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "urgent I/O condition",
- 24: "CPU time limit exceeded",
- 25: "file size limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window changed",
- 29: "I/O possible",
- 30: "power failure",
- 31: "bad system call",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/newt/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
deleted file mode 100644
index 329f25e7..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
+++ /dev/null
@@ -1,2027 +0,0 @@
-// mkerrors.sh -m64
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build s390x,linux
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -m64 _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_ALG = 0x26
- AF_APPLETALK = 0x5
- AF_ASH = 0x12
- AF_ATMPVC = 0x8
- AF_ATMSVC = 0x14
- AF_AX25 = 0x3
- AF_BLUETOOTH = 0x1f
- AF_BRIDGE = 0x7
- AF_CAIF = 0x25
- AF_CAN = 0x1d
- AF_DECnet = 0xc
- AF_ECONET = 0x13
- AF_FILE = 0x1
- AF_IB = 0x1b
- AF_IEEE802154 = 0x24
- AF_INET = 0x2
- AF_INET6 = 0xa
- AF_IPX = 0x4
- AF_IRDA = 0x17
- AF_ISDN = 0x22
- AF_IUCV = 0x20
- AF_KEY = 0xf
- AF_LLC = 0x1a
- AF_LOCAL = 0x1
- AF_MAX = 0x29
- AF_MPLS = 0x1c
- AF_NETBEUI = 0xd
- AF_NETLINK = 0x10
- AF_NETROM = 0x6
- AF_NFC = 0x27
- AF_PACKET = 0x11
- AF_PHONET = 0x23
- AF_PPPOX = 0x18
- AF_RDS = 0x15
- AF_ROSE = 0xb
- AF_ROUTE = 0x10
- AF_RXRPC = 0x21
- AF_SECURITY = 0xe
- AF_SNA = 0x16
- AF_TIPC = 0x1e
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_VSOCK = 0x28
- AF_WANPIPE = 0x19
- AF_X25 = 0x9
- ARPHRD_6LOWPAN = 0x339
- ARPHRD_ADAPT = 0x108
- ARPHRD_APPLETLK = 0x8
- ARPHRD_ARCNET = 0x7
- ARPHRD_ASH = 0x30d
- ARPHRD_ATM = 0x13
- ARPHRD_AX25 = 0x3
- ARPHRD_BIF = 0x307
- ARPHRD_CAIF = 0x336
- ARPHRD_CAN = 0x118
- ARPHRD_CHAOS = 0x5
- ARPHRD_CISCO = 0x201
- ARPHRD_CSLIP = 0x101
- ARPHRD_CSLIP6 = 0x103
- ARPHRD_DDCMP = 0x205
- ARPHRD_DLCI = 0xf
- ARPHRD_ECONET = 0x30e
- ARPHRD_EETHER = 0x2
- ARPHRD_ETHER = 0x1
- ARPHRD_EUI64 = 0x1b
- ARPHRD_FCAL = 0x311
- ARPHRD_FCFABRIC = 0x313
- ARPHRD_FCPL = 0x312
- ARPHRD_FCPP = 0x310
- ARPHRD_FDDI = 0x306
- ARPHRD_FRAD = 0x302
- ARPHRD_HDLC = 0x201
- ARPHRD_HIPPI = 0x30c
- ARPHRD_HWX25 = 0x110
- ARPHRD_IEEE1394 = 0x18
- ARPHRD_IEEE802 = 0x6
- ARPHRD_IEEE80211 = 0x321
- ARPHRD_IEEE80211_PRISM = 0x322
- ARPHRD_IEEE80211_RADIOTAP = 0x323
- ARPHRD_IEEE802154 = 0x324
- ARPHRD_IEEE802154_MONITOR = 0x325
- ARPHRD_IEEE802_TR = 0x320
- ARPHRD_INFINIBAND = 0x20
- ARPHRD_IP6GRE = 0x337
- ARPHRD_IPDDP = 0x309
- ARPHRD_IPGRE = 0x30a
- ARPHRD_IRDA = 0x30f
- ARPHRD_LAPB = 0x204
- ARPHRD_LOCALTLK = 0x305
- ARPHRD_LOOPBACK = 0x304
- ARPHRD_METRICOM = 0x17
- ARPHRD_NETLINK = 0x338
- ARPHRD_NETROM = 0x0
- ARPHRD_NONE = 0xfffe
- ARPHRD_PHONET = 0x334
- ARPHRD_PHONET_PIPE = 0x335
- ARPHRD_PIMREG = 0x30b
- ARPHRD_PPP = 0x200
- ARPHRD_PRONET = 0x4
- ARPHRD_RAWHDLC = 0x206
- ARPHRD_ROSE = 0x10e
- ARPHRD_RSRVD = 0x104
- ARPHRD_SIT = 0x308
- ARPHRD_SKIP = 0x303
- ARPHRD_SLIP = 0x100
- ARPHRD_SLIP6 = 0x102
- ARPHRD_TUNNEL = 0x300
- ARPHRD_TUNNEL6 = 0x301
- ARPHRD_VOID = 0xffff
- ARPHRD_X25 = 0x10f
- B0 = 0x0
- B1000000 = 0x1008
- B110 = 0x3
- B115200 = 0x1002
- B1152000 = 0x1009
- B1200 = 0x9
- B134 = 0x4
- B150 = 0x5
- B1500000 = 0x100a
- B1800 = 0xa
- B19200 = 0xe
- B200 = 0x6
- B2000000 = 0x100b
- B230400 = 0x1003
- B2400 = 0xb
- B2500000 = 0x100c
- B300 = 0x7
- B3000000 = 0x100d
- B3500000 = 0x100e
- B38400 = 0xf
- B4000000 = 0x100f
- B460800 = 0x1004
- B4800 = 0xc
- B50 = 0x1
- B500000 = 0x1005
- B57600 = 0x1001
- B576000 = 0x1006
- B600 = 0x8
- B75 = 0x2
- B921600 = 0x1007
- B9600 = 0xd
- BOTHER = 0x1000
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LL_OFF = -0x200000
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXINSNS = 0x1000
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MOD = 0x90
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_NET_OFF = -0x100000
- BPF_OR = 0x40
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BPF_XOR = 0xa0
- BRKINT = 0x2
- BS0 = 0x0
- BS1 = 0x2000
- BSDLY = 0x2000
- CBAUD = 0x100f
- CBAUDEX = 0x1000
- CFLUSH = 0xf
- CIBAUD = 0x100f0000
- CLOCAL = 0x800
- CLOCK_BOOTTIME = 0x7
- CLOCK_BOOTTIME_ALARM = 0x9
- CLOCK_DEFAULT = 0x0
- CLOCK_EXT = 0x1
- CLOCK_INT = 0x2
- CLOCK_MONOTONIC = 0x1
- CLOCK_MONOTONIC_COARSE = 0x6
- CLOCK_MONOTONIC_RAW = 0x4
- CLOCK_PROCESS_CPUTIME_ID = 0x2
- CLOCK_REALTIME = 0x0
- CLOCK_REALTIME_ALARM = 0x8
- CLOCK_REALTIME_COARSE = 0x5
- CLOCK_TAI = 0xb
- CLOCK_THREAD_CPUTIME_ID = 0x3
- CLOCK_TXFROMRX = 0x4
- CLOCK_TXINT = 0x3
- CLONE_CHILD_CLEARTID = 0x200000
- CLONE_CHILD_SETTID = 0x1000000
- CLONE_DETACHED = 0x400000
- CLONE_FILES = 0x400
- CLONE_FS = 0x200
- CLONE_IO = 0x80000000
- CLONE_NEWCGROUP = 0x2000000
- CLONE_NEWIPC = 0x8000000
- CLONE_NEWNET = 0x40000000
- CLONE_NEWNS = 0x20000
- CLONE_NEWPID = 0x20000000
- CLONE_NEWUSER = 0x10000000
- CLONE_NEWUTS = 0x4000000
- CLONE_PARENT = 0x8000
- CLONE_PARENT_SETTID = 0x100000
- CLONE_PTRACE = 0x2000
- CLONE_SETTLS = 0x80000
- CLONE_SIGHAND = 0x800
- CLONE_SYSVSEM = 0x40000
- CLONE_THREAD = 0x10000
- CLONE_UNTRACED = 0x800000
- CLONE_VFORK = 0x4000
- CLONE_VM = 0x100
- CMSPAR = 0x40000000
- CR0 = 0x0
- CR1 = 0x200
- CR2 = 0x400
- CR3 = 0x600
- CRDLY = 0x600
- CREAD = 0x80
- CRTSCTS = 0x80000000
- CS5 = 0x0
- CS6 = 0x10
- CS7 = 0x20
- CS8 = 0x30
- CSIGNAL = 0xff
- CSIZE = 0x30
- CSTART = 0x11
- CSTATUS = 0x0
- CSTOP = 0x13
- CSTOPB = 0x40
- CSUSP = 0x1a
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x200
- ECHOE = 0x10
- ECHOK = 0x20
- ECHOKE = 0x800
- ECHONL = 0x40
- ECHOPRT = 0x400
- ENCODING_DEFAULT = 0x0
- ENCODING_FM_MARK = 0x3
- ENCODING_FM_SPACE = 0x4
- ENCODING_MANCHESTER = 0x5
- ENCODING_NRZ = 0x1
- ENCODING_NRZI = 0x2
- EPOLLERR = 0x8
- EPOLLET = 0x80000000
- EPOLLHUP = 0x10
- EPOLLIN = 0x1
- EPOLLMSG = 0x400
- EPOLLONESHOT = 0x40000000
- EPOLLOUT = 0x4
- EPOLLPRI = 0x2
- EPOLLRDBAND = 0x80
- EPOLLRDHUP = 0x2000
- EPOLLRDNORM = 0x40
- EPOLLWAKEUP = 0x20000000
- EPOLLWRBAND = 0x200
- EPOLLWRNORM = 0x100
- EPOLL_CLOEXEC = 0x80000
- EPOLL_CTL_ADD = 0x1
- EPOLL_CTL_DEL = 0x2
- EPOLL_CTL_MOD = 0x3
- ETH_P_1588 = 0x88f7
- ETH_P_8021AD = 0x88a8
- ETH_P_8021AH = 0x88e7
- ETH_P_8021Q = 0x8100
- ETH_P_80221 = 0x8917
- ETH_P_802_2 = 0x4
- ETH_P_802_3 = 0x1
- ETH_P_802_3_MIN = 0x600
- ETH_P_802_EX1 = 0x88b5
- ETH_P_AARP = 0x80f3
- ETH_P_AF_IUCV = 0xfbfb
- ETH_P_ALL = 0x3
- ETH_P_AOE = 0x88a2
- ETH_P_ARCNET = 0x1a
- ETH_P_ARP = 0x806
- ETH_P_ATALK = 0x809b
- ETH_P_ATMFATE = 0x8884
- ETH_P_ATMMPOA = 0x884c
- ETH_P_AX25 = 0x2
- ETH_P_BATMAN = 0x4305
- ETH_P_BPQ = 0x8ff
- ETH_P_CAIF = 0xf7
- ETH_P_CAN = 0xc
- ETH_P_CANFD = 0xd
- ETH_P_CONTROL = 0x16
- ETH_P_CUST = 0x6006
- ETH_P_DDCMP = 0x6
- ETH_P_DEC = 0x6000
- ETH_P_DIAG = 0x6005
- ETH_P_DNA_DL = 0x6001
- ETH_P_DNA_RC = 0x6002
- ETH_P_DNA_RT = 0x6003
- ETH_P_DSA = 0x1b
- ETH_P_ECONET = 0x18
- ETH_P_EDSA = 0xdada
- ETH_P_FCOE = 0x8906
- ETH_P_FIP = 0x8914
- ETH_P_HDLC = 0x19
- ETH_P_IEEE802154 = 0xf6
- ETH_P_IEEEPUP = 0xa00
- ETH_P_IEEEPUPAT = 0xa01
- ETH_P_IP = 0x800
- ETH_P_IPV6 = 0x86dd
- ETH_P_IPX = 0x8137
- ETH_P_IRDA = 0x17
- ETH_P_LAT = 0x6004
- ETH_P_LINK_CTL = 0x886c
- ETH_P_LOCALTALK = 0x9
- ETH_P_LOOP = 0x60
- ETH_P_LOOPBACK = 0x9000
- ETH_P_MOBITEX = 0x15
- ETH_P_MPLS_MC = 0x8848
- ETH_P_MPLS_UC = 0x8847
- ETH_P_MVRP = 0x88f5
- ETH_P_PAE = 0x888e
- ETH_P_PAUSE = 0x8808
- ETH_P_PHONET = 0xf5
- ETH_P_PPPTALK = 0x10
- ETH_P_PPP_DISC = 0x8863
- ETH_P_PPP_MP = 0x8
- ETH_P_PPP_SES = 0x8864
- ETH_P_PRP = 0x88fb
- ETH_P_PUP = 0x200
- ETH_P_PUPAT = 0x201
- ETH_P_QINQ1 = 0x9100
- ETH_P_QINQ2 = 0x9200
- ETH_P_QINQ3 = 0x9300
- ETH_P_RARP = 0x8035
- ETH_P_SCA = 0x6007
- ETH_P_SLOW = 0x8809
- ETH_P_SNAP = 0x5
- ETH_P_TDLS = 0x890d
- ETH_P_TEB = 0x6558
- ETH_P_TIPC = 0x88ca
- ETH_P_TRAILER = 0x1c
- ETH_P_TR_802_2 = 0x11
- ETH_P_TSN = 0x22f0
- ETH_P_WAN_PPP = 0x7
- ETH_P_WCCP = 0x883e
- ETH_P_X25 = 0x805
- ETH_P_XDSA = 0xf8
- EXTA = 0xe
- EXTB = 0xf
- EXTPROC = 0x10000
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FF0 = 0x0
- FF1 = 0x8000
- FFDLY = 0x8000
- FLUSHO = 0x1000
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x406
- F_EXLCK = 0x4
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLEASE = 0x401
- F_GETLK = 0x5
- F_GETLK64 = 0x5
- F_GETOWN = 0x9
- F_GETOWN_EX = 0x10
- F_GETPIPE_SZ = 0x408
- F_GETSIG = 0xb
- F_LOCK = 0x1
- F_NOTIFY = 0x402
- F_OFD_GETLK = 0x24
- F_OFD_SETLK = 0x25
- F_OFD_SETLKW = 0x26
- F_OK = 0x0
- F_RDLCK = 0x0
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLEASE = 0x400
- F_SETLK = 0x6
- F_SETLK64 = 0x6
- F_SETLKW = 0x7
- F_SETLKW64 = 0x7
- F_SETOWN = 0x8
- F_SETOWN_EX = 0xf
- F_SETPIPE_SZ = 0x407
- F_SETSIG = 0xa
- F_SHLCK = 0x8
- F_TEST = 0x3
- F_TLOCK = 0x2
- F_ULOCK = 0x0
- F_UNLCK = 0x2
- F_WRLCK = 0x1
- HUPCL = 0x400
- IBSHIFT = 0x10
- ICANON = 0x2
- ICMPV6_FILTER = 0x1
- ICRNL = 0x100
- IEXTEN = 0x8000
- IFA_F_DADFAILED = 0x8
- IFA_F_DEPRECATED = 0x20
- IFA_F_HOMEADDRESS = 0x10
- IFA_F_MANAGETEMPADDR = 0x100
- IFA_F_MCAUTOJOIN = 0x400
- IFA_F_NODAD = 0x2
- IFA_F_NOPREFIXROUTE = 0x200
- IFA_F_OPTIMISTIC = 0x4
- IFA_F_PERMANENT = 0x80
- IFA_F_SECONDARY = 0x1
- IFA_F_STABLE_PRIVACY = 0x800
- IFA_F_TEMPORARY = 0x1
- IFA_F_TENTATIVE = 0x40
- IFA_MAX = 0x8
- IFF_ALLMULTI = 0x200
- IFF_ATTACH_QUEUE = 0x200
- IFF_AUTOMEDIA = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_DETACH_QUEUE = 0x400
- IFF_DORMANT = 0x20000
- IFF_DYNAMIC = 0x8000
- IFF_ECHO = 0x40000
- IFF_LOOPBACK = 0x8
- IFF_LOWER_UP = 0x10000
- IFF_MASTER = 0x400
- IFF_MULTICAST = 0x1000
- IFF_MULTI_QUEUE = 0x100
- IFF_NOARP = 0x80
- IFF_NOFILTER = 0x1000
- IFF_NOTRAILERS = 0x20
- IFF_NO_PI = 0x1000
- IFF_ONE_QUEUE = 0x2000
- IFF_PERSIST = 0x800
- IFF_POINTOPOINT = 0x10
- IFF_PORTSEL = 0x2000
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SLAVE = 0x800
- IFF_TAP = 0x2
- IFF_TUN = 0x1
- IFF_TUN_EXCL = 0x8000
- IFF_UP = 0x1
- IFF_VNET_HDR = 0x4000
- IFF_VOLATILE = 0x70c5a
- IFNAMSIZ = 0x10
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_ACCESS = 0x1
- IN_ALL_EVENTS = 0xfff
- IN_ATTRIB = 0x4
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLOEXEC = 0x80000
- IN_CLOSE = 0x18
- IN_CLOSE_NOWRITE = 0x10
- IN_CLOSE_WRITE = 0x8
- IN_CREATE = 0x100
- IN_DELETE = 0x200
- IN_DELETE_SELF = 0x400
- IN_DONT_FOLLOW = 0x2000000
- IN_EXCL_UNLINK = 0x4000000
- IN_IGNORED = 0x8000
- IN_ISDIR = 0x40000000
- IN_LOOPBACKNET = 0x7f
- IN_MASK_ADD = 0x20000000
- IN_MODIFY = 0x2
- IN_MOVE = 0xc0
- IN_MOVED_FROM = 0x40
- IN_MOVED_TO = 0x80
- IN_MOVE_SELF = 0x800
- IN_NONBLOCK = 0x800
- IN_ONESHOT = 0x80000000
- IN_ONLYDIR = 0x1000000
- IN_OPEN = 0x20
- IN_Q_OVERFLOW = 0x4000
- IN_UNMOUNT = 0x2000
- IPPROTO_AH = 0x33
- IPPROTO_BEETPH = 0x5e
- IPPROTO_COMP = 0x6c
- IPPROTO_DCCP = 0x21
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_ENCAP = 0x62
- IPPROTO_ESP = 0x32
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GRE = 0x2f
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IGMP = 0x2
- IPPROTO_IP = 0x0
- IPPROTO_IPIP = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_MH = 0x87
- IPPROTO_MPLS = 0x89
- IPPROTO_MTP = 0x5c
- IPPROTO_NONE = 0x3b
- IPPROTO_PIM = 0x67
- IPPROTO_PUP = 0xc
- IPPROTO_RAW = 0xff
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_SCTP = 0x84
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_UDP = 0x11
- IPPROTO_UDPLITE = 0x88
- IPV6_2292DSTOPTS = 0x4
- IPV6_2292HOPLIMIT = 0x8
- IPV6_2292HOPOPTS = 0x3
- IPV6_2292PKTINFO = 0x2
- IPV6_2292PKTOPTIONS = 0x6
- IPV6_2292RTHDR = 0x5
- IPV6_ADDRFORM = 0x1
- IPV6_ADD_MEMBERSHIP = 0x14
- IPV6_AUTHHDR = 0xa
- IPV6_CHECKSUM = 0x7
- IPV6_DONTFRAG = 0x3e
- IPV6_DROP_MEMBERSHIP = 0x15
- IPV6_DSTOPTS = 0x3b
- IPV6_HOPLIMIT = 0x34
- IPV6_HOPOPTS = 0x36
- IPV6_IPSEC_POLICY = 0x22
- IPV6_JOIN_ANYCAST = 0x1b
- IPV6_JOIN_GROUP = 0x14
- IPV6_LEAVE_ANYCAST = 0x1c
- IPV6_LEAVE_GROUP = 0x15
- IPV6_MTU = 0x18
- IPV6_MTU_DISCOVER = 0x17
- IPV6_MULTICAST_HOPS = 0x12
- IPV6_MULTICAST_IF = 0x11
- IPV6_MULTICAST_LOOP = 0x13
- IPV6_NEXTHOP = 0x9
- IPV6_PATHMTU = 0x3d
- IPV6_PKTINFO = 0x32
- IPV6_PMTUDISC_DO = 0x2
- IPV6_PMTUDISC_DONT = 0x0
- IPV6_PMTUDISC_INTERFACE = 0x4
- IPV6_PMTUDISC_OMIT = 0x5
- IPV6_PMTUDISC_PROBE = 0x3
- IPV6_PMTUDISC_WANT = 0x1
- IPV6_RECVDSTOPTS = 0x3a
- IPV6_RECVERR = 0x19
- IPV6_RECVHOPLIMIT = 0x33
- IPV6_RECVHOPOPTS = 0x35
- IPV6_RECVPATHMTU = 0x3c
- IPV6_RECVPKTINFO = 0x31
- IPV6_RECVRTHDR = 0x38
- IPV6_RECVTCLASS = 0x42
- IPV6_ROUTER_ALERT = 0x16
- IPV6_RTHDR = 0x39
- IPV6_RTHDRDSTOPTS = 0x37
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_RXDSTOPTS = 0x3b
- IPV6_RXHOPOPTS = 0x36
- IPV6_TCLASS = 0x43
- IPV6_UNICAST_HOPS = 0x10
- IPV6_V6ONLY = 0x1a
- IPV6_XFRM_POLICY = 0x23
- IP_ADD_MEMBERSHIP = 0x23
- IP_ADD_SOURCE_MEMBERSHIP = 0x27
- IP_BIND_ADDRESS_NO_PORT = 0x18
- IP_BLOCK_SOURCE = 0x26
- IP_CHECKSUM = 0x17
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0x24
- IP_DROP_SOURCE_MEMBERSHIP = 0x28
- IP_FREEBIND = 0xf
- IP_HDRINCL = 0x3
- IP_IPSEC_POLICY = 0x10
- IP_MAXPACKET = 0xffff
- IP_MAX_MEMBERSHIPS = 0x14
- IP_MF = 0x2000
- IP_MINTTL = 0x15
- IP_MSFILTER = 0x29
- IP_MSS = 0x240
- IP_MTU = 0xe
- IP_MTU_DISCOVER = 0xa
- IP_MULTICAST_ALL = 0x31
- IP_MULTICAST_IF = 0x20
- IP_MULTICAST_LOOP = 0x22
- IP_MULTICAST_TTL = 0x21
- IP_NODEFRAG = 0x16
- IP_OFFMASK = 0x1fff
- IP_OPTIONS = 0x4
- IP_ORIGDSTADDR = 0x14
- IP_PASSSEC = 0x12
- IP_PKTINFO = 0x8
- IP_PKTOPTIONS = 0x9
- IP_PMTUDISC = 0xa
- IP_PMTUDISC_DO = 0x2
- IP_PMTUDISC_DONT = 0x0
- IP_PMTUDISC_INTERFACE = 0x4
- IP_PMTUDISC_OMIT = 0x5
- IP_PMTUDISC_PROBE = 0x3
- IP_PMTUDISC_WANT = 0x1
- IP_RECVERR = 0xb
- IP_RECVOPTS = 0x6
- IP_RECVORIGDSTADDR = 0x14
- IP_RECVRETOPTS = 0x7
- IP_RECVTOS = 0xd
- IP_RECVTTL = 0xc
- IP_RETOPTS = 0x7
- IP_RF = 0x8000
- IP_ROUTER_ALERT = 0x5
- IP_TOS = 0x1
- IP_TRANSPARENT = 0x13
- IP_TTL = 0x2
- IP_UNBLOCK_SOURCE = 0x25
- IP_UNICAST_IF = 0x32
- IP_XFRM_POLICY = 0x11
- ISIG = 0x1
- ISTRIP = 0x20
- IUCLC = 0x200
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x1000
- IXON = 0x400
- LINUX_REBOOT_CMD_CAD_OFF = 0x0
- LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
- LINUX_REBOOT_CMD_HALT = 0xcdef0123
- LINUX_REBOOT_CMD_KEXEC = 0x45584543
- LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
- LINUX_REBOOT_CMD_RESTART = 0x1234567
- LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
- LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
- LINUX_REBOOT_MAGIC1 = 0xfee1dead
- LINUX_REBOOT_MAGIC2 = 0x28121969
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_DODUMP = 0x11
- MADV_DOFORK = 0xb
- MADV_DONTDUMP = 0x10
- MADV_DONTFORK = 0xa
- MADV_DONTNEED = 0x4
- MADV_HUGEPAGE = 0xe
- MADV_HWPOISON = 0x64
- MADV_MERGEABLE = 0xc
- MADV_NOHUGEPAGE = 0xf
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_REMOVE = 0x9
- MADV_SEQUENTIAL = 0x2
- MADV_UNMERGEABLE = 0xd
- MADV_WILLNEED = 0x3
- MAP_ANON = 0x20
- MAP_ANONYMOUS = 0x20
- MAP_DENYWRITE = 0x800
- MAP_EXECUTABLE = 0x1000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_GROWSDOWN = 0x100
- MAP_HUGETLB = 0x40000
- MAP_HUGE_MASK = 0x3f
- MAP_HUGE_SHIFT = 0x1a
- MAP_LOCKED = 0x2000
- MAP_NONBLOCK = 0x10000
- MAP_NORESERVE = 0x4000
- MAP_POPULATE = 0x8000
- MAP_PRIVATE = 0x2
- MAP_SHARED = 0x1
- MAP_STACK = 0x20000
- MAP_TYPE = 0xf
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MCL_ONFAULT = 0x4
- MNT_DETACH = 0x2
- MNT_EXPIRE = 0x4
- MNT_FORCE = 0x1
- MSG_CMSG_CLOEXEC = 0x40000000
- MSG_CONFIRM = 0x800
- MSG_CTRUNC = 0x8
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x40
- MSG_EOR = 0x80
- MSG_ERRQUEUE = 0x2000
- MSG_FASTOPEN = 0x20000000
- MSG_FIN = 0x200
- MSG_MORE = 0x8000
- MSG_NOSIGNAL = 0x4000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_PROXY = 0x10
- MSG_RST = 0x1000
- MSG_SYN = 0x400
- MSG_TRUNC = 0x20
- MSG_TRYHARD = 0x4
- MSG_WAITALL = 0x100
- MSG_WAITFORONE = 0x10000
- MS_ACTIVE = 0x40000000
- MS_ASYNC = 0x1
- MS_BIND = 0x1000
- MS_DIRSYNC = 0x80
- MS_INVALIDATE = 0x2
- MS_I_VERSION = 0x800000
- MS_KERNMOUNT = 0x400000
- MS_LAZYTIME = 0x2000000
- MS_MANDLOCK = 0x40
- MS_MGC_MSK = 0xffff0000
- MS_MGC_VAL = 0xc0ed0000
- MS_MOVE = 0x2000
- MS_NOATIME = 0x400
- MS_NODEV = 0x4
- MS_NODIRATIME = 0x800
- MS_NOEXEC = 0x8
- MS_NOSUID = 0x2
- MS_NOUSER = -0x80000000
- MS_POSIXACL = 0x10000
- MS_PRIVATE = 0x40000
- MS_RDONLY = 0x1
- MS_REC = 0x4000
- MS_RELATIME = 0x200000
- MS_REMOUNT = 0x20
- MS_RMT_MASK = 0x2800051
- MS_SHARED = 0x100000
- MS_SILENT = 0x8000
- MS_SLAVE = 0x80000
- MS_STRICTATIME = 0x1000000
- MS_SYNC = 0x4
- MS_SYNCHRONOUS = 0x10
- MS_UNBINDABLE = 0x20000
- NAME_MAX = 0xff
- NETLINK_ADD_MEMBERSHIP = 0x1
- NETLINK_AUDIT = 0x9
- NETLINK_BROADCAST_ERROR = 0x4
- NETLINK_CAP_ACK = 0xa
- NETLINK_CONNECTOR = 0xb
- NETLINK_CRYPTO = 0x15
- NETLINK_DNRTMSG = 0xe
- NETLINK_DROP_MEMBERSHIP = 0x2
- NETLINK_ECRYPTFS = 0x13
- NETLINK_FIB_LOOKUP = 0xa
- NETLINK_FIREWALL = 0x3
- NETLINK_GENERIC = 0x10
- NETLINK_INET_DIAG = 0x4
- NETLINK_IP6_FW = 0xd
- NETLINK_ISCSI = 0x8
- NETLINK_KOBJECT_UEVENT = 0xf
- NETLINK_LISTEN_ALL_NSID = 0x8
- NETLINK_LIST_MEMBERSHIPS = 0x9
- NETLINK_NETFILTER = 0xc
- NETLINK_NFLOG = 0x5
- NETLINK_NO_ENOBUFS = 0x5
- NETLINK_PKTINFO = 0x3
- NETLINK_RDMA = 0x14
- NETLINK_ROUTE = 0x0
- NETLINK_RX_RING = 0x6
- NETLINK_SCSITRANSPORT = 0x12
- NETLINK_SELINUX = 0x7
- NETLINK_SOCK_DIAG = 0x4
- NETLINK_TX_RING = 0x7
- NETLINK_UNUSED = 0x1
- NETLINK_USERSOCK = 0x2
- NETLINK_XFRM = 0x6
- NL0 = 0x0
- NL1 = 0x100
- NLA_ALIGNTO = 0x4
- NLA_F_NESTED = 0x8000
- NLA_F_NET_BYTEORDER = 0x4000
- NLA_HDRLEN = 0x4
- NLDLY = 0x100
- NLMSG_ALIGNTO = 0x4
- NLMSG_DONE = 0x3
- NLMSG_ERROR = 0x2
- NLMSG_HDRLEN = 0x10
- NLMSG_MIN_TYPE = 0x10
- NLMSG_NOOP = 0x1
- NLMSG_OVERRUN = 0x4
- NLM_F_ACK = 0x4
- NLM_F_APPEND = 0x800
- NLM_F_ATOMIC = 0x400
- NLM_F_CREATE = 0x400
- NLM_F_DUMP = 0x300
- NLM_F_DUMP_FILTERED = 0x20
- NLM_F_DUMP_INTR = 0x10
- NLM_F_ECHO = 0x8
- NLM_F_EXCL = 0x200
- NLM_F_MATCH = 0x200
- NLM_F_MULTI = 0x2
- NLM_F_REPLACE = 0x100
- NLM_F_REQUEST = 0x1
- NLM_F_ROOT = 0x100
- NOFLSH = 0x80
- OCRNL = 0x8
- OFDEL = 0x80
- OFILL = 0x40
- OLCUC = 0x2
- ONLCR = 0x4
- ONLRET = 0x20
- ONOCR = 0x10
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x400
- O_ASYNC = 0x2000
- O_CLOEXEC = 0x80000
- O_CREAT = 0x40
- O_DIRECT = 0x4000
- O_DIRECTORY = 0x10000
- O_DSYNC = 0x1000
- O_EXCL = 0x80
- O_FSYNC = 0x101000
- O_LARGEFILE = 0x0
- O_NDELAY = 0x800
- O_NOATIME = 0x40000
- O_NOCTTY = 0x100
- O_NOFOLLOW = 0x20000
- O_NONBLOCK = 0x800
- O_PATH = 0x200000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_RSYNC = 0x101000
- O_SYNC = 0x101000
- O_TMPFILE = 0x410000
- O_TRUNC = 0x200
- O_WRONLY = 0x1
- PACKET_ADD_MEMBERSHIP = 0x1
- PACKET_AUXDATA = 0x8
- PACKET_BROADCAST = 0x1
- PACKET_COPY_THRESH = 0x7
- PACKET_DROP_MEMBERSHIP = 0x2
- PACKET_FANOUT = 0x12
- PACKET_FANOUT_CBPF = 0x6
- PACKET_FANOUT_CPU = 0x2
- PACKET_FANOUT_DATA = 0x16
- PACKET_FANOUT_EBPF = 0x7
- PACKET_FANOUT_FLAG_DEFRAG = 0x8000
- PACKET_FANOUT_FLAG_ROLLOVER = 0x1000
- PACKET_FANOUT_HASH = 0x0
- PACKET_FANOUT_LB = 0x1
- PACKET_FANOUT_QM = 0x5
- PACKET_FANOUT_RND = 0x4
- PACKET_FANOUT_ROLLOVER = 0x3
- PACKET_FASTROUTE = 0x6
- PACKET_HDRLEN = 0xb
- PACKET_HOST = 0x0
- PACKET_KERNEL = 0x7
- PACKET_LOOPBACK = 0x5
- PACKET_LOSS = 0xe
- PACKET_MR_ALLMULTI = 0x2
- PACKET_MR_MULTICAST = 0x0
- PACKET_MR_PROMISC = 0x1
- PACKET_MR_UNICAST = 0x3
- PACKET_MULTICAST = 0x2
- PACKET_ORIGDEV = 0x9
- PACKET_OTHERHOST = 0x3
- PACKET_OUTGOING = 0x4
- PACKET_QDISC_BYPASS = 0x14
- PACKET_RECV_OUTPUT = 0x3
- PACKET_RESERVE = 0xc
- PACKET_ROLLOVER_STATS = 0x15
- PACKET_RX_RING = 0x5
- PACKET_STATISTICS = 0x6
- PACKET_TIMESTAMP = 0x11
- PACKET_TX_HAS_OFF = 0x13
- PACKET_TX_RING = 0xd
- PACKET_TX_TIMESTAMP = 0x10
- PACKET_USER = 0x6
- PACKET_VERSION = 0xa
- PACKET_VNET_HDR = 0xf
- PARENB = 0x100
- PARITY_CRC16_PR0 = 0x2
- PARITY_CRC16_PR0_CCITT = 0x4
- PARITY_CRC16_PR1 = 0x3
- PARITY_CRC16_PR1_CCITT = 0x5
- PARITY_CRC32_PR0_CCITT = 0x6
- PARITY_CRC32_PR1_CCITT = 0x7
- PARITY_DEFAULT = 0x0
- PARITY_NONE = 0x1
- PARMRK = 0x8
- PARODD = 0x200
- PENDIN = 0x4000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_GROWSDOWN = 0x1000000
- PROT_GROWSUP = 0x2000000
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- PR_CAPBSET_DROP = 0x18
- PR_CAPBSET_READ = 0x17
- PR_CAP_AMBIENT = 0x2f
- PR_CAP_AMBIENT_CLEAR_ALL = 0x4
- PR_CAP_AMBIENT_IS_SET = 0x1
- PR_CAP_AMBIENT_LOWER = 0x3
- PR_CAP_AMBIENT_RAISE = 0x2
- PR_ENDIAN_BIG = 0x0
- PR_ENDIAN_LITTLE = 0x1
- PR_ENDIAN_PPC_LITTLE = 0x2
- PR_FPEMU_NOPRINT = 0x1
- PR_FPEMU_SIGFPE = 0x2
- PR_FP_EXC_ASYNC = 0x2
- PR_FP_EXC_DISABLED = 0x0
- PR_FP_EXC_DIV = 0x10000
- PR_FP_EXC_INV = 0x100000
- PR_FP_EXC_NONRECOV = 0x1
- PR_FP_EXC_OVF = 0x20000
- PR_FP_EXC_PRECISE = 0x3
- PR_FP_EXC_RES = 0x80000
- PR_FP_EXC_SW_ENABLE = 0x80
- PR_FP_EXC_UND = 0x40000
- PR_FP_MODE_FR = 0x1
- PR_FP_MODE_FRE = 0x2
- PR_GET_CHILD_SUBREAPER = 0x25
- PR_GET_DUMPABLE = 0x3
- PR_GET_ENDIAN = 0x13
- PR_GET_FPEMU = 0x9
- PR_GET_FPEXC = 0xb
- PR_GET_FP_MODE = 0x2e
- PR_GET_KEEPCAPS = 0x7
- PR_GET_NAME = 0x10
- PR_GET_NO_NEW_PRIVS = 0x27
- PR_GET_PDEATHSIG = 0x2
- PR_GET_SECCOMP = 0x15
- PR_GET_SECUREBITS = 0x1b
- PR_GET_THP_DISABLE = 0x2a
- PR_GET_TID_ADDRESS = 0x28
- PR_GET_TIMERSLACK = 0x1e
- PR_GET_TIMING = 0xd
- PR_GET_TSC = 0x19
- PR_GET_UNALIGN = 0x5
- PR_MCE_KILL = 0x21
- PR_MCE_KILL_CLEAR = 0x0
- PR_MCE_KILL_DEFAULT = 0x2
- PR_MCE_KILL_EARLY = 0x1
- PR_MCE_KILL_GET = 0x22
- PR_MCE_KILL_LATE = 0x0
- PR_MCE_KILL_SET = 0x1
- PR_MPX_DISABLE_MANAGEMENT = 0x2c
- PR_MPX_ENABLE_MANAGEMENT = 0x2b
- PR_SET_CHILD_SUBREAPER = 0x24
- PR_SET_DUMPABLE = 0x4
- PR_SET_ENDIAN = 0x14
- PR_SET_FPEMU = 0xa
- PR_SET_FPEXC = 0xc
- PR_SET_FP_MODE = 0x2d
- PR_SET_KEEPCAPS = 0x8
- PR_SET_MM = 0x23
- PR_SET_MM_ARG_END = 0x9
- PR_SET_MM_ARG_START = 0x8
- PR_SET_MM_AUXV = 0xc
- PR_SET_MM_BRK = 0x7
- PR_SET_MM_END_CODE = 0x2
- PR_SET_MM_END_DATA = 0x4
- PR_SET_MM_ENV_END = 0xb
- PR_SET_MM_ENV_START = 0xa
- PR_SET_MM_EXE_FILE = 0xd
- PR_SET_MM_MAP = 0xe
- PR_SET_MM_MAP_SIZE = 0xf
- PR_SET_MM_START_BRK = 0x6
- PR_SET_MM_START_CODE = 0x1
- PR_SET_MM_START_DATA = 0x3
- PR_SET_MM_START_STACK = 0x5
- PR_SET_NAME = 0xf
- PR_SET_NO_NEW_PRIVS = 0x26
- PR_SET_PDEATHSIG = 0x1
- PR_SET_PTRACER = 0x59616d61
- PR_SET_PTRACER_ANY = -0x1
- PR_SET_SECCOMP = 0x16
- PR_SET_SECUREBITS = 0x1c
- PR_SET_THP_DISABLE = 0x29
- PR_SET_TIMERSLACK = 0x1d
- PR_SET_TIMING = 0xe
- PR_SET_TSC = 0x1a
- PR_SET_UNALIGN = 0x6
- PR_TASK_PERF_EVENTS_DISABLE = 0x1f
- PR_TASK_PERF_EVENTS_ENABLE = 0x20
- PR_TIMING_STATISTICAL = 0x0
- PR_TIMING_TIMESTAMP = 0x1
- PR_TSC_ENABLE = 0x1
- PR_TSC_SIGSEGV = 0x2
- PR_UNALIGN_NOPRINT = 0x1
- PR_UNALIGN_SIGBUS = 0x2
- PTRACE_ATTACH = 0x10
- PTRACE_CONT = 0x7
- PTRACE_DETACH = 0x11
- PTRACE_DISABLE_TE = 0x5010
- PTRACE_ENABLE_TE = 0x5009
- PTRACE_EVENT_CLONE = 0x3
- PTRACE_EVENT_EXEC = 0x4
- PTRACE_EVENT_EXIT = 0x6
- PTRACE_EVENT_FORK = 0x1
- PTRACE_EVENT_SECCOMP = 0x7
- PTRACE_EVENT_STOP = 0x80
- PTRACE_EVENT_VFORK = 0x2
- PTRACE_EVENT_VFORK_DONE = 0x5
- PTRACE_GETEVENTMSG = 0x4201
- PTRACE_GETREGS = 0xc
- PTRACE_GETREGSET = 0x4204
- PTRACE_GETSIGINFO = 0x4202
- PTRACE_GETSIGMASK = 0x420a
- PTRACE_GET_LAST_BREAK = 0x5006
- PTRACE_INTERRUPT = 0x4207
- PTRACE_KILL = 0x8
- PTRACE_LISTEN = 0x4208
- PTRACE_OLDSETOPTIONS = 0x15
- PTRACE_O_EXITKILL = 0x100000
- PTRACE_O_MASK = 0x3000ff
- PTRACE_O_SUSPEND_SECCOMP = 0x200000
- PTRACE_O_TRACECLONE = 0x8
- PTRACE_O_TRACEEXEC = 0x10
- PTRACE_O_TRACEEXIT = 0x40
- PTRACE_O_TRACEFORK = 0x2
- PTRACE_O_TRACESECCOMP = 0x80
- PTRACE_O_TRACESYSGOOD = 0x1
- PTRACE_O_TRACEVFORK = 0x4
- PTRACE_O_TRACEVFORKDONE = 0x20
- PTRACE_PEEKDATA = 0x2
- PTRACE_PEEKDATA_AREA = 0x5003
- PTRACE_PEEKSIGINFO = 0x4209
- PTRACE_PEEKSIGINFO_SHARED = 0x1
- PTRACE_PEEKTEXT = 0x1
- PTRACE_PEEKTEXT_AREA = 0x5002
- PTRACE_PEEKUSR = 0x3
- PTRACE_PEEKUSR_AREA = 0x5000
- PTRACE_PEEK_SYSTEM_CALL = 0x5007
- PTRACE_POKEDATA = 0x5
- PTRACE_POKEDATA_AREA = 0x5005
- PTRACE_POKETEXT = 0x4
- PTRACE_POKETEXT_AREA = 0x5004
- PTRACE_POKEUSR = 0x6
- PTRACE_POKEUSR_AREA = 0x5001
- PTRACE_POKE_SYSTEM_CALL = 0x5008
- PTRACE_PROT = 0x15
- PTRACE_SECCOMP_GET_FILTER = 0x420c
- PTRACE_SEIZE = 0x4206
- PTRACE_SETOPTIONS = 0x4200
- PTRACE_SETREGS = 0xd
- PTRACE_SETREGSET = 0x4205
- PTRACE_SETSIGINFO = 0x4203
- PTRACE_SETSIGMASK = 0x420b
- PTRACE_SINGLEBLOCK = 0xc
- PTRACE_SINGLESTEP = 0x9
- PTRACE_SYSCALL = 0x18
- PTRACE_TE_ABORT_RAND = 0x5011
- PTRACE_TRACEME = 0x0
- PT_ACR0 = 0x90
- PT_ACR1 = 0x94
- PT_ACR10 = 0xb8
- PT_ACR11 = 0xbc
- PT_ACR12 = 0xc0
- PT_ACR13 = 0xc4
- PT_ACR14 = 0xc8
- PT_ACR15 = 0xcc
- PT_ACR2 = 0x98
- PT_ACR3 = 0x9c
- PT_ACR4 = 0xa0
- PT_ACR5 = 0xa4
- PT_ACR6 = 0xa8
- PT_ACR7 = 0xac
- PT_ACR8 = 0xb0
- PT_ACR9 = 0xb4
- PT_CR_10 = 0x168
- PT_CR_11 = 0x170
- PT_CR_9 = 0x160
- PT_ENDREGS = 0x1af
- PT_FPC = 0xd8
- PT_FPR0 = 0xe0
- PT_FPR1 = 0xe8
- PT_FPR10 = 0x130
- PT_FPR11 = 0x138
- PT_FPR12 = 0x140
- PT_FPR13 = 0x148
- PT_FPR14 = 0x150
- PT_FPR15 = 0x158
- PT_FPR2 = 0xf0
- PT_FPR3 = 0xf8
- PT_FPR4 = 0x100
- PT_FPR5 = 0x108
- PT_FPR6 = 0x110
- PT_FPR7 = 0x118
- PT_FPR8 = 0x120
- PT_FPR9 = 0x128
- PT_GPR0 = 0x10
- PT_GPR1 = 0x18
- PT_GPR10 = 0x60
- PT_GPR11 = 0x68
- PT_GPR12 = 0x70
- PT_GPR13 = 0x78
- PT_GPR14 = 0x80
- PT_GPR15 = 0x88
- PT_GPR2 = 0x20
- PT_GPR3 = 0x28
- PT_GPR4 = 0x30
- PT_GPR5 = 0x38
- PT_GPR6 = 0x40
- PT_GPR7 = 0x48
- PT_GPR8 = 0x50
- PT_GPR9 = 0x58
- PT_IEEE_IP = 0x1a8
- PT_LASTOFF = 0x1a8
- PT_ORIGGPR2 = 0xd0
- PT_PSWADDR = 0x8
- PT_PSWMASK = 0x0
- RLIMIT_AS = 0x9
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x7
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = -0x1
- RTAX_ADVMSS = 0x8
- RTAX_CC_ALGO = 0x10
- RTAX_CWND = 0x7
- RTAX_FEATURES = 0xc
- RTAX_FEATURE_ALLFRAG = 0x8
- RTAX_FEATURE_ECN = 0x1
- RTAX_FEATURE_MASK = 0xf
- RTAX_FEATURE_SACK = 0x2
- RTAX_FEATURE_TIMESTAMP = 0x4
- RTAX_HOPLIMIT = 0xa
- RTAX_INITCWND = 0xb
- RTAX_INITRWND = 0xe
- RTAX_LOCK = 0x1
- RTAX_MAX = 0x10
- RTAX_MTU = 0x2
- RTAX_QUICKACK = 0xf
- RTAX_REORDERING = 0x9
- RTAX_RTO_MIN = 0xd
- RTAX_RTT = 0x4
- RTAX_RTTVAR = 0x5
- RTAX_SSTHRESH = 0x6
- RTAX_UNSPEC = 0x0
- RTAX_WINDOW = 0x3
- RTA_ALIGNTO = 0x4
- RTA_MAX = 0x16
- RTCF_DIRECTSRC = 0x4000000
- RTCF_DOREDIRECT = 0x1000000
- RTCF_LOG = 0x2000000
- RTCF_MASQ = 0x400000
- RTCF_NAT = 0x800000
- RTCF_VALVE = 0x200000
- RTF_ADDRCLASSMASK = 0xf8000000
- RTF_ADDRCONF = 0x40000
- RTF_ALLONLINK = 0x20000
- RTF_BROADCAST = 0x10000000
- RTF_CACHE = 0x1000000
- RTF_DEFAULT = 0x10000
- RTF_DYNAMIC = 0x10
- RTF_FLOW = 0x2000000
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_INTERFACE = 0x40000000
- RTF_IRTT = 0x100
- RTF_LINKRT = 0x100000
- RTF_LOCAL = 0x80000000
- RTF_MODIFIED = 0x20
- RTF_MSS = 0x40
- RTF_MTU = 0x40
- RTF_MULTICAST = 0x20000000
- RTF_NAT = 0x8000000
- RTF_NOFORWARD = 0x1000
- RTF_NONEXTHOP = 0x200000
- RTF_NOPMTUDISC = 0x4000
- RTF_POLICY = 0x4000000
- RTF_REINSTATE = 0x8
- RTF_REJECT = 0x200
- RTF_STATIC = 0x400
- RTF_THROW = 0x2000
- RTF_UP = 0x1
- RTF_WINDOW = 0x80
- RTF_XRESOLVE = 0x800
- RTM_BASE = 0x10
- RTM_DELACTION = 0x31
- RTM_DELADDR = 0x15
- RTM_DELADDRLABEL = 0x49
- RTM_DELLINK = 0x11
- RTM_DELMDB = 0x55
- RTM_DELNEIGH = 0x1d
- RTM_DELNSID = 0x59
- RTM_DELQDISC = 0x25
- RTM_DELROUTE = 0x19
- RTM_DELRULE = 0x21
- RTM_DELTCLASS = 0x29
- RTM_DELTFILTER = 0x2d
- RTM_F_CLONED = 0x200
- RTM_F_EQUALIZE = 0x400
- RTM_F_LOOKUP_TABLE = 0x1000
- RTM_F_NOTIFY = 0x100
- RTM_F_PREFIX = 0x800
- RTM_GETACTION = 0x32
- RTM_GETADDR = 0x16
- RTM_GETADDRLABEL = 0x4a
- RTM_GETANYCAST = 0x3e
- RTM_GETDCB = 0x4e
- RTM_GETLINK = 0x12
- RTM_GETMDB = 0x56
- RTM_GETMULTICAST = 0x3a
- RTM_GETNEIGH = 0x1e
- RTM_GETNEIGHTBL = 0x42
- RTM_GETNETCONF = 0x52
- RTM_GETNSID = 0x5a
- RTM_GETQDISC = 0x26
- RTM_GETROUTE = 0x1a
- RTM_GETRULE = 0x22
- RTM_GETTCLASS = 0x2a
- RTM_GETTFILTER = 0x2e
- RTM_MAX = 0x5b
- RTM_NEWACTION = 0x30
- RTM_NEWADDR = 0x14
- RTM_NEWADDRLABEL = 0x48
- RTM_NEWLINK = 0x10
- RTM_NEWMDB = 0x54
- RTM_NEWNDUSEROPT = 0x44
- RTM_NEWNEIGH = 0x1c
- RTM_NEWNEIGHTBL = 0x40
- RTM_NEWNETCONF = 0x50
- RTM_NEWNSID = 0x58
- RTM_NEWPREFIX = 0x34
- RTM_NEWQDISC = 0x24
- RTM_NEWROUTE = 0x18
- RTM_NEWRULE = 0x20
- RTM_NEWTCLASS = 0x28
- RTM_NEWTFILTER = 0x2c
- RTM_NR_FAMILIES = 0x13
- RTM_NR_MSGTYPES = 0x4c
- RTM_SETDCB = 0x4f
- RTM_SETLINK = 0x13
- RTM_SETNEIGHTBL = 0x43
- RTNH_ALIGNTO = 0x4
- RTNH_COMPARE_MASK = 0x11
- RTNH_F_DEAD = 0x1
- RTNH_F_LINKDOWN = 0x10
- RTNH_F_OFFLOAD = 0x8
- RTNH_F_ONLINK = 0x4
- RTNH_F_PERVASIVE = 0x2
- RTN_MAX = 0xb
- RTPROT_BABEL = 0x2a
- RTPROT_BIRD = 0xc
- RTPROT_BOOT = 0x3
- RTPROT_DHCP = 0x10
- RTPROT_DNROUTED = 0xd
- RTPROT_GATED = 0x8
- RTPROT_KERNEL = 0x2
- RTPROT_MROUTED = 0x11
- RTPROT_MRT = 0xa
- RTPROT_NTK = 0xf
- RTPROT_RA = 0x9
- RTPROT_REDIRECT = 0x1
- RTPROT_STATIC = 0x4
- RTPROT_UNSPEC = 0x0
- RTPROT_XORP = 0xe
- RTPROT_ZEBRA = 0xb
- RT_CLASS_DEFAULT = 0xfd
- RT_CLASS_LOCAL = 0xff
- RT_CLASS_MAIN = 0xfe
- RT_CLASS_MAX = 0xff
- RT_CLASS_UNSPEC = 0x0
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- RUSAGE_THREAD = 0x1
- SCM_CREDENTIALS = 0x2
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x1d
- SCM_TIMESTAMPING = 0x25
- SCM_TIMESTAMPNS = 0x23
- SCM_WIFI_STATUS = 0x29
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDDLCI = 0x8980
- SIOCADDMULTI = 0x8931
- SIOCADDRT = 0x890b
- SIOCATMARK = 0x8905
- SIOCDARP = 0x8953
- SIOCDELDLCI = 0x8981
- SIOCDELMULTI = 0x8932
- SIOCDELRT = 0x890c
- SIOCDEVPRIVATE = 0x89f0
- SIOCDIFADDR = 0x8936
- SIOCDRARP = 0x8960
- SIOCGARP = 0x8954
- SIOCGIFADDR = 0x8915
- SIOCGIFBR = 0x8940
- SIOCGIFBRDADDR = 0x8919
- SIOCGIFCONF = 0x8912
- SIOCGIFCOUNT = 0x8938
- SIOCGIFDSTADDR = 0x8917
- SIOCGIFENCAP = 0x8925
- SIOCGIFFLAGS = 0x8913
- SIOCGIFHWADDR = 0x8927
- SIOCGIFINDEX = 0x8933
- SIOCGIFMAP = 0x8970
- SIOCGIFMEM = 0x891f
- SIOCGIFMETRIC = 0x891d
- SIOCGIFMTU = 0x8921
- SIOCGIFNAME = 0x8910
- SIOCGIFNETMASK = 0x891b
- SIOCGIFPFLAGS = 0x8935
- SIOCGIFSLAVE = 0x8929
- SIOCGIFTXQLEN = 0x8942
- SIOCGPGRP = 0x8904
- SIOCGRARP = 0x8961
- SIOCGSTAMP = 0x8906
- SIOCGSTAMPNS = 0x8907
- SIOCPROTOPRIVATE = 0x89e0
- SIOCRTMSG = 0x890d
- SIOCSARP = 0x8955
- SIOCSIFADDR = 0x8916
- SIOCSIFBR = 0x8941
- SIOCSIFBRDADDR = 0x891a
- SIOCSIFDSTADDR = 0x8918
- SIOCSIFENCAP = 0x8926
- SIOCSIFFLAGS = 0x8914
- SIOCSIFHWADDR = 0x8924
- SIOCSIFHWBROADCAST = 0x8937
- SIOCSIFLINK = 0x8911
- SIOCSIFMAP = 0x8971
- SIOCSIFMEM = 0x8920
- SIOCSIFMETRIC = 0x891e
- SIOCSIFMTU = 0x8922
- SIOCSIFNAME = 0x8923
- SIOCSIFNETMASK = 0x891c
- SIOCSIFPFLAGS = 0x8934
- SIOCSIFSLAVE = 0x8930
- SIOCSIFTXQLEN = 0x8943
- SIOCSPGRP = 0x8902
- SIOCSRARP = 0x8962
- SOCK_CLOEXEC = 0x80000
- SOCK_DCCP = 0x6
- SOCK_DGRAM = 0x2
- SOCK_NONBLOCK = 0x800
- SOCK_PACKET = 0xa
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_AAL = 0x109
- SOL_ATM = 0x108
- SOL_DECNET = 0x105
- SOL_ICMPV6 = 0x3a
- SOL_IP = 0x0
- SOL_IPV6 = 0x29
- SOL_IRDA = 0x10a
- SOL_PACKET = 0x107
- SOL_RAW = 0xff
- SOL_SOCKET = 0x1
- SOL_TCP = 0x6
- SOL_X25 = 0x106
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x1e
- SO_ATTACH_BPF = 0x32
- SO_ATTACH_FILTER = 0x1a
- SO_BINDTODEVICE = 0x19
- SO_BPF_EXTENSIONS = 0x30
- SO_BROADCAST = 0x6
- SO_BSDCOMPAT = 0xe
- SO_BUSY_POLL = 0x2e
- SO_DEBUG = 0x1
- SO_DETACH_BPF = 0x1b
- SO_DETACH_FILTER = 0x1b
- SO_DOMAIN = 0x27
- SO_DONTROUTE = 0x5
- SO_ERROR = 0x4
- SO_GET_FILTER = 0x1a
- SO_INCOMING_CPU = 0x31
- SO_KEEPALIVE = 0x9
- SO_LINGER = 0xd
- SO_LOCK_FILTER = 0x2c
- SO_MARK = 0x24
- SO_MAX_PACING_RATE = 0x2f
- SO_NOFCS = 0x2b
- SO_NO_CHECK = 0xb
- SO_OOBINLINE = 0xa
- SO_PASSCRED = 0x10
- SO_PASSSEC = 0x22
- SO_PEEK_OFF = 0x2a
- SO_PEERCRED = 0x11
- SO_PEERNAME = 0x1c
- SO_PEERSEC = 0x1f
- SO_PRIORITY = 0xc
- SO_PROTOCOL = 0x26
- SO_RCVBUF = 0x8
- SO_RCVBUFFORCE = 0x21
- SO_RCVLOWAT = 0x12
- SO_RCVTIMEO = 0x14
- SO_REUSEADDR = 0x2
- SO_REUSEPORT = 0xf
- SO_RXQ_OVFL = 0x28
- SO_SECURITY_AUTHENTICATION = 0x16
- SO_SECURITY_ENCRYPTION_NETWORK = 0x18
- SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17
- SO_SELECT_ERR_QUEUE = 0x2d
- SO_SNDBUF = 0x7
- SO_SNDBUFFORCE = 0x20
- SO_SNDLOWAT = 0x13
- SO_SNDTIMEO = 0x15
- SO_TIMESTAMP = 0x1d
- SO_TIMESTAMPING = 0x25
- SO_TIMESTAMPNS = 0x23
- SO_TYPE = 0x3
- SO_WIFI_STATUS = 0x29
- S_BLKSIZE = 0x200
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TAB0 = 0x0
- TAB1 = 0x800
- TAB2 = 0x1000
- TAB3 = 0x1800
- TABDLY = 0x1800
- TCFLSH = 0x540b
- TCGETA = 0x5405
- TCGETS = 0x5401
- TCGETS2 = 0x802c542a
- TCGETX = 0x5432
- TCIFLUSH = 0x0
- TCIOFF = 0x2
- TCIOFLUSH = 0x2
- TCION = 0x3
- TCOFLUSH = 0x1
- TCOOFF = 0x0
- TCOON = 0x1
- TCP_CC_INFO = 0x1a
- TCP_CONGESTION = 0xd
- TCP_COOKIE_IN_ALWAYS = 0x1
- TCP_COOKIE_MAX = 0x10
- TCP_COOKIE_MIN = 0x8
- TCP_COOKIE_OUT_NEVER = 0x2
- TCP_COOKIE_PAIR_SIZE = 0x20
- TCP_COOKIE_TRANSACTIONS = 0xf
- TCP_CORK = 0x3
- TCP_DEFER_ACCEPT = 0x9
- TCP_FASTOPEN = 0x17
- TCP_INFO = 0xb
- TCP_KEEPCNT = 0x6
- TCP_KEEPIDLE = 0x4
- TCP_KEEPINTVL = 0x5
- TCP_LINGER2 = 0x8
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0xe
- TCP_MD5SIG_MAXKEYLEN = 0x50
- TCP_MSS = 0x200
- TCP_MSS_DEFAULT = 0x218
- TCP_MSS_DESIRED = 0x4c4
- TCP_NODELAY = 0x1
- TCP_NOTSENT_LOWAT = 0x19
- TCP_QUEUE_SEQ = 0x15
- TCP_QUICKACK = 0xc
- TCP_REPAIR = 0x13
- TCP_REPAIR_OPTIONS = 0x16
- TCP_REPAIR_QUEUE = 0x14
- TCP_SAVED_SYN = 0x1c
- TCP_SAVE_SYN = 0x1b
- TCP_SYNCNT = 0x7
- TCP_S_DATA_IN = 0x4
- TCP_S_DATA_OUT = 0x8
- TCP_THIN_DUPACK = 0x11
- TCP_THIN_LINEAR_TIMEOUTS = 0x10
- TCP_TIMESTAMP = 0x18
- TCP_USER_TIMEOUT = 0x12
- TCP_WINDOW_CLAMP = 0xa
- TCSAFLUSH = 0x2
- TCSBRK = 0x5409
- TCSBRKP = 0x5425
- TCSETA = 0x5406
- TCSETAF = 0x5408
- TCSETAW = 0x5407
- TCSETS = 0x5402
- TCSETS2 = 0x402c542b
- TCSETSF = 0x5404
- TCSETSF2 = 0x402c542d
- TCSETSW = 0x5403
- TCSETSW2 = 0x402c542c
- TCSETX = 0x5433
- TCSETXF = 0x5434
- TCSETXW = 0x5435
- TCXONC = 0x540a
- TIOCCBRK = 0x5428
- TIOCCONS = 0x541d
- TIOCEXCL = 0x540c
- TIOCGDEV = 0x80045432
- TIOCGETD = 0x5424
- TIOCGEXCL = 0x80045440
- TIOCGICOUNT = 0x545d
- TIOCGLCKTRMIOS = 0x5456
- TIOCGPGRP = 0x540f
- TIOCGPKT = 0x80045438
- TIOCGPTLCK = 0x80045439
- TIOCGPTN = 0x80045430
- TIOCGRS485 = 0x542e
- TIOCGSERIAL = 0x541e
- TIOCGSID = 0x5429
- TIOCGSOFTCAR = 0x5419
- TIOCGWINSZ = 0x5413
- TIOCINQ = 0x541b
- TIOCLINUX = 0x541c
- TIOCMBIC = 0x5417
- TIOCMBIS = 0x5416
- TIOCMGET = 0x5415
- TIOCMIWAIT = 0x545c
- TIOCMSET = 0x5418
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x5422
- TIOCNXCL = 0x540d
- TIOCOUTQ = 0x5411
- TIOCPKT = 0x5420
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCSBRK = 0x5427
- TIOCSCTTY = 0x540e
- TIOCSERCONFIG = 0x5453
- TIOCSERGETLSR = 0x5459
- TIOCSERGETMULTI = 0x545a
- TIOCSERGSTRUCT = 0x5458
- TIOCSERGWILD = 0x5454
- TIOCSERSETMULTI = 0x545b
- TIOCSERSWILD = 0x5455
- TIOCSER_TEMT = 0x1
- TIOCSETD = 0x5423
- TIOCSIG = 0x40045436
- TIOCSLCKTRMIOS = 0x5457
- TIOCSPGRP = 0x5410
- TIOCSPTLCK = 0x40045431
- TIOCSRS485 = 0x542f
- TIOCSSERIAL = 0x541f
- TIOCSSOFTCAR = 0x541a
- TIOCSTI = 0x5412
- TIOCSWINSZ = 0x5414
- TIOCVHANGUP = 0x5437
- TOSTOP = 0x100
- TUNATTACHFILTER = 0x401054d5
- TUNDETACHFILTER = 0x401054d6
- TUNGETFEATURES = 0x800454cf
- TUNGETFILTER = 0x801054db
- TUNGETIFF = 0x800454d2
- TUNGETSNDBUF = 0x800454d3
- TUNGETVNETBE = 0x800454df
- TUNGETVNETHDRSZ = 0x800454d7
- TUNGETVNETLE = 0x800454dd
- TUNSETDEBUG = 0x400454c9
- TUNSETGROUP = 0x400454ce
- TUNSETIFF = 0x400454ca
- TUNSETIFINDEX = 0x400454da
- TUNSETLINK = 0x400454cd
- TUNSETNOCSUM = 0x400454c8
- TUNSETOFFLOAD = 0x400454d0
- TUNSETOWNER = 0x400454cc
- TUNSETPERSIST = 0x400454cb
- TUNSETQUEUE = 0x400454d9
- TUNSETSNDBUF = 0x400454d4
- TUNSETTXFILTER = 0x400454d1
- TUNSETVNETBE = 0x400454de
- TUNSETVNETHDRSZ = 0x400454d8
- TUNSETVNETLE = 0x400454dc
- VDISCARD = 0xd
- VEOF = 0x4
- VEOL = 0xb
- VEOL2 = 0x10
- VERASE = 0x2
- VINTR = 0x0
- VKILL = 0x3
- VLNEXT = 0xf
- VMIN = 0x6
- VQUIT = 0x1
- VREPRINT = 0xc
- VSTART = 0x8
- VSTOP = 0x9
- VSUSP = 0xa
- VSWTC = 0x7
- VT0 = 0x0
- VT1 = 0x4000
- VTDLY = 0x4000
- VTIME = 0x5
- VWERASE = 0xe
- WALL = 0x40000000
- WCLONE = 0x80000000
- WCONTINUED = 0x8
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOTHREAD = 0x20000000
- WNOWAIT = 0x1000000
- WORDSIZE = 0x40
- WSTOPPED = 0x2
- WUNTRACED = 0x2
- XCASE = 0x4
- XTABS = 0x1800
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x62)
- EADDRNOTAVAIL = syscall.Errno(0x63)
- EADV = syscall.Errno(0x44)
- EAFNOSUPPORT = syscall.Errno(0x61)
- EAGAIN = syscall.Errno(0xb)
- EALREADY = syscall.Errno(0x72)
- EBADE = syscall.Errno(0x34)
- EBADF = syscall.Errno(0x9)
- EBADFD = syscall.Errno(0x4d)
- EBADMSG = syscall.Errno(0x4a)
- EBADR = syscall.Errno(0x35)
- EBADRQC = syscall.Errno(0x38)
- EBADSLT = syscall.Errno(0x39)
- EBFONT = syscall.Errno(0x3b)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x7d)
- ECHILD = syscall.Errno(0xa)
- ECHRNG = syscall.Errno(0x2c)
- ECOMM = syscall.Errno(0x46)
- ECONNABORTED = syscall.Errno(0x67)
- ECONNREFUSED = syscall.Errno(0x6f)
- ECONNRESET = syscall.Errno(0x68)
- EDEADLK = syscall.Errno(0x23)
- EDEADLOCK = syscall.Errno(0x23)
- EDESTADDRREQ = syscall.Errno(0x59)
- EDOM = syscall.Errno(0x21)
- EDOTDOT = syscall.Errno(0x49)
- EDQUOT = syscall.Errno(0x7a)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EHOSTDOWN = syscall.Errno(0x70)
- EHOSTUNREACH = syscall.Errno(0x71)
- EHWPOISON = syscall.Errno(0x85)
- EIDRM = syscall.Errno(0x2b)
- EILSEQ = syscall.Errno(0x54)
- EINPROGRESS = syscall.Errno(0x73)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x6a)
- EISDIR = syscall.Errno(0x15)
- EISNAM = syscall.Errno(0x78)
- EKEYEXPIRED = syscall.Errno(0x7f)
- EKEYREJECTED = syscall.Errno(0x81)
- EKEYREVOKED = syscall.Errno(0x80)
- EL2HLT = syscall.Errno(0x33)
- EL2NSYNC = syscall.Errno(0x2d)
- EL3HLT = syscall.Errno(0x2e)
- EL3RST = syscall.Errno(0x2f)
- ELIBACC = syscall.Errno(0x4f)
- ELIBBAD = syscall.Errno(0x50)
- ELIBEXEC = syscall.Errno(0x53)
- ELIBMAX = syscall.Errno(0x52)
- ELIBSCN = syscall.Errno(0x51)
- ELNRNG = syscall.Errno(0x30)
- ELOOP = syscall.Errno(0x28)
- EMEDIUMTYPE = syscall.Errno(0x7c)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x5a)
- EMULTIHOP = syscall.Errno(0x48)
- ENAMETOOLONG = syscall.Errno(0x24)
- ENAVAIL = syscall.Errno(0x77)
- ENETDOWN = syscall.Errno(0x64)
- ENETRESET = syscall.Errno(0x66)
- ENETUNREACH = syscall.Errno(0x65)
- ENFILE = syscall.Errno(0x17)
- ENOANO = syscall.Errno(0x37)
- ENOBUFS = syscall.Errno(0x69)
- ENOCSI = syscall.Errno(0x32)
- ENODATA = syscall.Errno(0x3d)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOKEY = syscall.Errno(0x7e)
- ENOLCK = syscall.Errno(0x25)
- ENOLINK = syscall.Errno(0x43)
- ENOMEDIUM = syscall.Errno(0x7b)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x2a)
- ENONET = syscall.Errno(0x40)
- ENOPKG = syscall.Errno(0x41)
- ENOPROTOOPT = syscall.Errno(0x5c)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x3f)
- ENOSTR = syscall.Errno(0x3c)
- ENOSYS = syscall.Errno(0x26)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x6b)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x27)
- ENOTNAM = syscall.Errno(0x76)
- ENOTRECOVERABLE = syscall.Errno(0x83)
- ENOTSOCK = syscall.Errno(0x58)
- ENOTSUP = syscall.Errno(0x5f)
- ENOTTY = syscall.Errno(0x19)
- ENOTUNIQ = syscall.Errno(0x4c)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x5f)
- EOVERFLOW = syscall.Errno(0x4b)
- EOWNERDEAD = syscall.Errno(0x82)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x60)
- EPIPE = syscall.Errno(0x20)
- EPROTO = syscall.Errno(0x47)
- EPROTONOSUPPORT = syscall.Errno(0x5d)
- EPROTOTYPE = syscall.Errno(0x5b)
- ERANGE = syscall.Errno(0x22)
- EREMCHG = syscall.Errno(0x4e)
- EREMOTE = syscall.Errno(0x42)
- EREMOTEIO = syscall.Errno(0x79)
- ERESTART = syscall.Errno(0x55)
- ERFKILL = syscall.Errno(0x84)
- EROFS = syscall.Errno(0x1e)
- ESHUTDOWN = syscall.Errno(0x6c)
- ESOCKTNOSUPPORT = syscall.Errno(0x5e)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESRMNT = syscall.Errno(0x45)
- ESTALE = syscall.Errno(0x74)
- ESTRPIPE = syscall.Errno(0x56)
- ETIME = syscall.Errno(0x3e)
- ETIMEDOUT = syscall.Errno(0x6e)
- ETOOMANYREFS = syscall.Errno(0x6d)
- ETXTBSY = syscall.Errno(0x1a)
- EUCLEAN = syscall.Errno(0x75)
- EUNATCH = syscall.Errno(0x31)
- EUSERS = syscall.Errno(0x57)
- EWOULDBLOCK = syscall.Errno(0xb)
- EXDEV = syscall.Errno(0x12)
- EXFULL = syscall.Errno(0x36)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0x7)
- SIGCHLD = syscall.Signal(0x11)
- SIGCLD = syscall.Signal(0x11)
- SIGCONT = syscall.Signal(0x12)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x1d)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPOLL = syscall.Signal(0x1d)
- SIGPROF = syscall.Signal(0x1b)
- SIGPWR = syscall.Signal(0x1e)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTKFLT = syscall.Signal(0x10)
- SIGSTOP = syscall.Signal(0x13)
- SIGSYS = syscall.Signal(0x1f)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x14)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGUNUSED = syscall.Signal(0x1f)
- SIGURG = syscall.Signal(0x17)
- SIGUSR1 = syscall.Signal(0xa)
- SIGUSR2 = syscall.Signal(0xc)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "no such device or address",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource temporarily unavailable",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device or resource busy",
- 17: "file exists",
- 18: "invalid cross-device link",
- 19: "no such device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "numerical result out of range",
- 35: "resource deadlock avoided",
- 36: "file name too long",
- 37: "no locks available",
- 38: "function not implemented",
- 39: "directory not empty",
- 40: "too many levels of symbolic links",
- 42: "no message of desired type",
- 43: "identifier removed",
- 44: "channel number out of range",
- 45: "level 2 not synchronized",
- 46: "level 3 halted",
- 47: "level 3 reset",
- 48: "link number out of range",
- 49: "protocol driver not attached",
- 50: "no CSI structure available",
- 51: "level 2 halted",
- 52: "invalid exchange",
- 53: "invalid request descriptor",
- 54: "exchange full",
- 55: "no anode",
- 56: "invalid request code",
- 57: "invalid slot",
- 59: "bad font file format",
- 60: "device not a stream",
- 61: "no data available",
- 62: "timer expired",
- 63: "out of streams resources",
- 64: "machine is not on the network",
- 65: "package not installed",
- 66: "object is remote",
- 67: "link has been severed",
- 68: "advertise error",
- 69: "srmount error",
- 70: "communication error on send",
- 71: "protocol error",
- 72: "multihop attempted",
- 73: "RFS specific error",
- 74: "bad message",
- 75: "value too large for defined data type",
- 76: "name not unique on network",
- 77: "file descriptor in bad state",
- 78: "remote address changed",
- 79: "can not access a needed shared library",
- 80: "accessing a corrupted shared library",
- 81: ".lib section in a.out corrupted",
- 82: "attempting to link in too many shared libraries",
- 83: "cannot exec a shared library directly",
- 84: "invalid or incomplete multibyte or wide character",
- 85: "interrupted system call should be restarted",
- 86: "streams pipe error",
- 87: "too many users",
- 88: "socket operation on non-socket",
- 89: "destination address required",
- 90: "message too long",
- 91: "protocol wrong type for socket",
- 92: "protocol not available",
- 93: "protocol not supported",
- 94: "socket type not supported",
- 95: "operation not supported",
- 96: "protocol family not supported",
- 97: "address family not supported by protocol",
- 98: "address already in use",
- 99: "cannot assign requested address",
- 100: "network is down",
- 101: "network is unreachable",
- 102: "network dropped connection on reset",
- 103: "software caused connection abort",
- 104: "connection reset by peer",
- 105: "no buffer space available",
- 106: "transport endpoint is already connected",
- 107: "transport endpoint is not connected",
- 108: "cannot send after transport endpoint shutdown",
- 109: "too many references: cannot splice",
- 110: "connection timed out",
- 111: "connection refused",
- 112: "host is down",
- 113: "no route to host",
- 114: "operation already in progress",
- 115: "operation now in progress",
- 116: "stale file handle",
- 117: "structure needs cleaning",
- 118: "not a XENIX named type file",
- 119: "no XENIX semaphores available",
- 120: "is a named type file",
- 121: "remote I/O error",
- 122: "disk quota exceeded",
- 123: "no medium found",
- 124: "wrong medium type",
- 125: "operation canceled",
- 126: "required key not available",
- 127: "key has expired",
- 128: "key has been revoked",
- 129: "key was rejected by service",
- 130: "owner died",
- 131: "state not recoverable",
- 132: "operation not possible due to RF-kill",
- 133: "memory page has hardware error",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/breakpoint trap",
- 6: "aborted",
- 7: "bus error",
- 8: "floating point exception",
- 9: "killed",
- 10: "user defined signal 1",
- 11: "segmentation fault",
- 12: "user defined signal 2",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "stack fault",
- 17: "child exited",
- 18: "continued",
- 19: "stopped (signal)",
- 20: "stopped",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "urgent I/O condition",
- 24: "CPU time limit exceeded",
- 25: "file size limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window changed",
- 29: "I/O possible",
- 30: "power failure",
- 31: "bad system call",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/newt/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
deleted file mode 100644
index 766d1e61..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
+++ /dev/null
@@ -1,2077 +0,0 @@
-// mkerrors.sh -m64
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build sparc64,linux
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -m64 _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_ALG = 0x26
- AF_APPLETALK = 0x5
- AF_ASH = 0x12
- AF_ATMPVC = 0x8
- AF_ATMSVC = 0x14
- AF_AX25 = 0x3
- AF_BLUETOOTH = 0x1f
- AF_BRIDGE = 0x7
- AF_CAIF = 0x25
- AF_CAN = 0x1d
- AF_DECnet = 0xc
- AF_ECONET = 0x13
- AF_FILE = 0x1
- AF_IB = 0x1b
- AF_IEEE802154 = 0x24
- AF_INET = 0x2
- AF_INET6 = 0xa
- AF_IPX = 0x4
- AF_IRDA = 0x17
- AF_ISDN = 0x22
- AF_IUCV = 0x20
- AF_KCM = 0x29
- AF_KEY = 0xf
- AF_LLC = 0x1a
- AF_LOCAL = 0x1
- AF_MAX = 0x2a
- AF_MPLS = 0x1c
- AF_NETBEUI = 0xd
- AF_NETLINK = 0x10
- AF_NETROM = 0x6
- AF_NFC = 0x27
- AF_PACKET = 0x11
- AF_PHONET = 0x23
- AF_PPPOX = 0x18
- AF_RDS = 0x15
- AF_ROSE = 0xb
- AF_ROUTE = 0x10
- AF_RXRPC = 0x21
- AF_SECURITY = 0xe
- AF_SNA = 0x16
- AF_TIPC = 0x1e
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_VSOCK = 0x28
- AF_WANPIPE = 0x19
- AF_X25 = 0x9
- ARPHRD_6LOWPAN = 0x339
- ARPHRD_ADAPT = 0x108
- ARPHRD_APPLETLK = 0x8
- ARPHRD_ARCNET = 0x7
- ARPHRD_ASH = 0x30d
- ARPHRD_ATM = 0x13
- ARPHRD_AX25 = 0x3
- ARPHRD_BIF = 0x307
- ARPHRD_CAIF = 0x336
- ARPHRD_CAN = 0x118
- ARPHRD_CHAOS = 0x5
- ARPHRD_CISCO = 0x201
- ARPHRD_CSLIP = 0x101
- ARPHRD_CSLIP6 = 0x103
- ARPHRD_DDCMP = 0x205
- ARPHRD_DLCI = 0xf
- ARPHRD_ECONET = 0x30e
- ARPHRD_EETHER = 0x2
- ARPHRD_ETHER = 0x1
- ARPHRD_EUI64 = 0x1b
- ARPHRD_FCAL = 0x311
- ARPHRD_FCFABRIC = 0x313
- ARPHRD_FCPL = 0x312
- ARPHRD_FCPP = 0x310
- ARPHRD_FDDI = 0x306
- ARPHRD_FRAD = 0x302
- ARPHRD_HDLC = 0x201
- ARPHRD_HIPPI = 0x30c
- ARPHRD_HWX25 = 0x110
- ARPHRD_IEEE1394 = 0x18
- ARPHRD_IEEE802 = 0x6
- ARPHRD_IEEE80211 = 0x321
- ARPHRD_IEEE80211_PRISM = 0x322
- ARPHRD_IEEE80211_RADIOTAP = 0x323
- ARPHRD_IEEE802154 = 0x324
- ARPHRD_IEEE802154_MONITOR = 0x325
- ARPHRD_IEEE802_TR = 0x320
- ARPHRD_INFINIBAND = 0x20
- ARPHRD_IP6GRE = 0x337
- ARPHRD_IPDDP = 0x309
- ARPHRD_IPGRE = 0x30a
- ARPHRD_IRDA = 0x30f
- ARPHRD_LAPB = 0x204
- ARPHRD_LOCALTLK = 0x305
- ARPHRD_LOOPBACK = 0x304
- ARPHRD_METRICOM = 0x17
- ARPHRD_NETLINK = 0x338
- ARPHRD_NETROM = 0x0
- ARPHRD_NONE = 0xfffe
- ARPHRD_PHONET = 0x334
- ARPHRD_PHONET_PIPE = 0x335
- ARPHRD_PIMREG = 0x30b
- ARPHRD_PPP = 0x200
- ARPHRD_PRONET = 0x4
- ARPHRD_RAWHDLC = 0x206
- ARPHRD_ROSE = 0x10e
- ARPHRD_RSRVD = 0x104
- ARPHRD_SIT = 0x308
- ARPHRD_SKIP = 0x303
- ARPHRD_SLIP = 0x100
- ARPHRD_SLIP6 = 0x102
- ARPHRD_TUNNEL = 0x300
- ARPHRD_TUNNEL6 = 0x301
- ARPHRD_VOID = 0xffff
- ARPHRD_X25 = 0x10f
- ASI_LEON_DFLUSH = 0x11
- ASI_LEON_IFLUSH = 0x10
- ASI_LEON_MMUFLUSH = 0x18
- B0 = 0x0
- B1000000 = 0x100c
- B110 = 0x3
- B115200 = 0x1002
- B1152000 = 0x100d
- B1200 = 0x9
- B134 = 0x4
- B150 = 0x5
- B1500000 = 0x100e
- B153600 = 0x1006
- B1800 = 0xa
- B19200 = 0xe
- B200 = 0x6
- B2000000 = 0x100f
- B230400 = 0x1003
- B2400 = 0xb
- B300 = 0x7
- B307200 = 0x1007
- B38400 = 0xf
- B460800 = 0x1004
- B4800 = 0xc
- B50 = 0x1
- B500000 = 0x100a
- B57600 = 0x1001
- B576000 = 0x100b
- B600 = 0x8
- B614400 = 0x1008
- B75 = 0x2
- B76800 = 0x1005
- B921600 = 0x1009
- B9600 = 0xd
- BOTHER = 0x1000
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LL_OFF = -0x200000
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXINSNS = 0x1000
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MOD = 0x90
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_NET_OFF = -0x100000
- BPF_OR = 0x40
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BPF_XOR = 0xa0
- BRKINT = 0x2
- BS0 = 0x0
- BS1 = 0x2000
- BSDLY = 0x2000
- CBAUD = 0x100f
- CBAUDEX = 0x1000
- CFLUSH = 0xf
- CIBAUD = 0x100f0000
- CLOCAL = 0x800
- CLOCK_BOOTTIME = 0x7
- CLOCK_BOOTTIME_ALARM = 0x9
- CLOCK_DEFAULT = 0x0
- CLOCK_EXT = 0x1
- CLOCK_INT = 0x2
- CLOCK_MONOTONIC = 0x1
- CLOCK_MONOTONIC_COARSE = 0x6
- CLOCK_MONOTONIC_RAW = 0x4
- CLOCK_PROCESS_CPUTIME_ID = 0x2
- CLOCK_REALTIME = 0x0
- CLOCK_REALTIME_ALARM = 0x8
- CLOCK_REALTIME_COARSE = 0x5
- CLOCK_TAI = 0xb
- CLOCK_THREAD_CPUTIME_ID = 0x3
- CLOCK_TXFROMRX = 0x4
- CLOCK_TXINT = 0x3
- CLONE_CHILD_CLEARTID = 0x200000
- CLONE_CHILD_SETTID = 0x1000000
- CLONE_DETACHED = 0x400000
- CLONE_FILES = 0x400
- CLONE_FS = 0x200
- CLONE_IO = 0x80000000
- CLONE_NEWCGROUP = 0x2000000
- CLONE_NEWIPC = 0x8000000
- CLONE_NEWNET = 0x40000000
- CLONE_NEWNS = 0x20000
- CLONE_NEWPID = 0x20000000
- CLONE_NEWUSER = 0x10000000
- CLONE_NEWUTS = 0x4000000
- CLONE_PARENT = 0x8000
- CLONE_PARENT_SETTID = 0x100000
- CLONE_PTRACE = 0x2000
- CLONE_SETTLS = 0x80000
- CLONE_SIGHAND = 0x800
- CLONE_SYSVSEM = 0x40000
- CLONE_THREAD = 0x10000
- CLONE_UNTRACED = 0x800000
- CLONE_VFORK = 0x4000
- CLONE_VM = 0x100
- CMSPAR = 0x40000000
- CR0 = 0x0
- CR1 = 0x200
- CR2 = 0x400
- CR3 = 0x600
- CRDLY = 0x600
- CREAD = 0x80
- CRTSCTS = 0x80000000
- CS5 = 0x0
- CS6 = 0x10
- CS7 = 0x20
- CS8 = 0x30
- CSIGNAL = 0xff
- CSIZE = 0x30
- CSTART = 0x11
- CSTATUS = 0x0
- CSTOP = 0x13
- CSTOPB = 0x40
- CSUSP = 0x1a
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x200
- ECHOE = 0x10
- ECHOK = 0x20
- ECHOKE = 0x800
- ECHONL = 0x40
- ECHOPRT = 0x400
- EMT_TAGOVF = 0x1
- ENCODING_DEFAULT = 0x0
- ENCODING_FM_MARK = 0x3
- ENCODING_FM_SPACE = 0x4
- ENCODING_MANCHESTER = 0x5
- ENCODING_NRZ = 0x1
- ENCODING_NRZI = 0x2
- EPOLLERR = 0x8
- EPOLLET = 0x80000000
- EPOLLEXCLUSIVE = 0x10000000
- EPOLLHUP = 0x10
- EPOLLIN = 0x1
- EPOLLMSG = 0x400
- EPOLLONESHOT = 0x40000000
- EPOLLOUT = 0x4
- EPOLLPRI = 0x2
- EPOLLRDBAND = 0x80
- EPOLLRDHUP = 0x2000
- EPOLLRDNORM = 0x40
- EPOLLWAKEUP = 0x20000000
- EPOLLWRBAND = 0x200
- EPOLLWRNORM = 0x100
- EPOLL_CLOEXEC = 0x400000
- EPOLL_CTL_ADD = 0x1
- EPOLL_CTL_DEL = 0x2
- EPOLL_CTL_MOD = 0x3
- ETH_P_1588 = 0x88f7
- ETH_P_8021AD = 0x88a8
- ETH_P_8021AH = 0x88e7
- ETH_P_8021Q = 0x8100
- ETH_P_80221 = 0x8917
- ETH_P_802_2 = 0x4
- ETH_P_802_3 = 0x1
- ETH_P_802_3_MIN = 0x600
- ETH_P_802_EX1 = 0x88b5
- ETH_P_AARP = 0x80f3
- ETH_P_AF_IUCV = 0xfbfb
- ETH_P_ALL = 0x3
- ETH_P_AOE = 0x88a2
- ETH_P_ARCNET = 0x1a
- ETH_P_ARP = 0x806
- ETH_P_ATALK = 0x809b
- ETH_P_ATMFATE = 0x8884
- ETH_P_ATMMPOA = 0x884c
- ETH_P_AX25 = 0x2
- ETH_P_BATMAN = 0x4305
- ETH_P_BPQ = 0x8ff
- ETH_P_CAIF = 0xf7
- ETH_P_CAN = 0xc
- ETH_P_CANFD = 0xd
- ETH_P_CONTROL = 0x16
- ETH_P_CUST = 0x6006
- ETH_P_DDCMP = 0x6
- ETH_P_DEC = 0x6000
- ETH_P_DIAG = 0x6005
- ETH_P_DNA_DL = 0x6001
- ETH_P_DNA_RC = 0x6002
- ETH_P_DNA_RT = 0x6003
- ETH_P_DSA = 0x1b
- ETH_P_ECONET = 0x18
- ETH_P_EDSA = 0xdada
- ETH_P_FCOE = 0x8906
- ETH_P_FIP = 0x8914
- ETH_P_HDLC = 0x19
- ETH_P_HSR = 0x892f
- ETH_P_IEEE802154 = 0xf6
- ETH_P_IEEEPUP = 0xa00
- ETH_P_IEEEPUPAT = 0xa01
- ETH_P_IP = 0x800
- ETH_P_IPV6 = 0x86dd
- ETH_P_IPX = 0x8137
- ETH_P_IRDA = 0x17
- ETH_P_LAT = 0x6004
- ETH_P_LINK_CTL = 0x886c
- ETH_P_LOCALTALK = 0x9
- ETH_P_LOOP = 0x60
- ETH_P_LOOPBACK = 0x9000
- ETH_P_MACSEC = 0x88e5
- ETH_P_MOBITEX = 0x15
- ETH_P_MPLS_MC = 0x8848
- ETH_P_MPLS_UC = 0x8847
- ETH_P_MVRP = 0x88f5
- ETH_P_PAE = 0x888e
- ETH_P_PAUSE = 0x8808
- ETH_P_PHONET = 0xf5
- ETH_P_PPPTALK = 0x10
- ETH_P_PPP_DISC = 0x8863
- ETH_P_PPP_MP = 0x8
- ETH_P_PPP_SES = 0x8864
- ETH_P_PRP = 0x88fb
- ETH_P_PUP = 0x200
- ETH_P_PUPAT = 0x201
- ETH_P_QINQ1 = 0x9100
- ETH_P_QINQ2 = 0x9200
- ETH_P_QINQ3 = 0x9300
- ETH_P_RARP = 0x8035
- ETH_P_SCA = 0x6007
- ETH_P_SLOW = 0x8809
- ETH_P_SNAP = 0x5
- ETH_P_TDLS = 0x890d
- ETH_P_TEB = 0x6558
- ETH_P_TIPC = 0x88ca
- ETH_P_TRAILER = 0x1c
- ETH_P_TR_802_2 = 0x11
- ETH_P_TSN = 0x22f0
- ETH_P_WAN_PPP = 0x7
- ETH_P_WCCP = 0x883e
- ETH_P_X25 = 0x805
- ETH_P_XDSA = 0xf8
- EXTA = 0xe
- EXTB = 0xf
- EXTPROC = 0x10000
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FF0 = 0x0
- FF1 = 0x8000
- FFDLY = 0x8000
- FLUSHO = 0x2000
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x406
- F_EXLCK = 0x4
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLEASE = 0x401
- F_GETLK = 0x7
- F_GETLK64 = 0x7
- F_GETOWN = 0x5
- F_GETOWN_EX = 0x10
- F_GETPIPE_SZ = 0x408
- F_GETSIG = 0xb
- F_LOCK = 0x1
- F_NOTIFY = 0x402
- F_OFD_GETLK = 0x24
- F_OFD_SETLK = 0x25
- F_OFD_SETLKW = 0x26
- F_OK = 0x0
- F_RDLCK = 0x1
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLEASE = 0x400
- F_SETLK = 0x8
- F_SETLK64 = 0x8
- F_SETLKW = 0x9
- F_SETLKW64 = 0x9
- F_SETOWN = 0x6
- F_SETOWN_EX = 0xf
- F_SETPIPE_SZ = 0x407
- F_SETSIG = 0xa
- F_SHLCK = 0x8
- F_TEST = 0x3
- F_TLOCK = 0x2
- F_ULOCK = 0x0
- F_UNLCK = 0x3
- F_WRLCK = 0x2
- HUPCL = 0x400
- IBSHIFT = 0x10
- ICANON = 0x2
- ICMPV6_FILTER = 0x1
- ICRNL = 0x100
- IEXTEN = 0x8000
- IFA_F_DADFAILED = 0x8
- IFA_F_DEPRECATED = 0x20
- IFA_F_HOMEADDRESS = 0x10
- IFA_F_MANAGETEMPADDR = 0x100
- IFA_F_MCAUTOJOIN = 0x400
- IFA_F_NODAD = 0x2
- IFA_F_NOPREFIXROUTE = 0x200
- IFA_F_OPTIMISTIC = 0x4
- IFA_F_PERMANENT = 0x80
- IFA_F_SECONDARY = 0x1
- IFA_F_STABLE_PRIVACY = 0x800
- IFA_F_TEMPORARY = 0x1
- IFA_F_TENTATIVE = 0x40
- IFA_MAX = 0x8
- IFF_ALLMULTI = 0x200
- IFF_ATTACH_QUEUE = 0x200
- IFF_AUTOMEDIA = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_DETACH_QUEUE = 0x400
- IFF_DORMANT = 0x20000
- IFF_DYNAMIC = 0x8000
- IFF_ECHO = 0x40000
- IFF_LOOPBACK = 0x8
- IFF_LOWER_UP = 0x10000
- IFF_MASTER = 0x400
- IFF_MULTICAST = 0x1000
- IFF_MULTI_QUEUE = 0x100
- IFF_NOARP = 0x80
- IFF_NOFILTER = 0x1000
- IFF_NOTRAILERS = 0x20
- IFF_NO_PI = 0x1000
- IFF_ONE_QUEUE = 0x2000
- IFF_PERSIST = 0x800
- IFF_POINTOPOINT = 0x10
- IFF_PORTSEL = 0x2000
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SLAVE = 0x800
- IFF_TAP = 0x2
- IFF_TUN = 0x1
- IFF_TUN_EXCL = 0x8000
- IFF_UP = 0x1
- IFF_VNET_HDR = 0x4000
- IFF_VOLATILE = 0x70c5a
- IFNAMSIZ = 0x10
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_ACCESS = 0x1
- IN_ALL_EVENTS = 0xfff
- IN_ATTRIB = 0x4
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLOEXEC = 0x400000
- IN_CLOSE = 0x18
- IN_CLOSE_NOWRITE = 0x10
- IN_CLOSE_WRITE = 0x8
- IN_CREATE = 0x100
- IN_DELETE = 0x200
- IN_DELETE_SELF = 0x400
- IN_DONT_FOLLOW = 0x2000000
- IN_EXCL_UNLINK = 0x4000000
- IN_IGNORED = 0x8000
- IN_ISDIR = 0x40000000
- IN_LOOPBACKNET = 0x7f
- IN_MASK_ADD = 0x20000000
- IN_MODIFY = 0x2
- IN_MOVE = 0xc0
- IN_MOVED_FROM = 0x40
- IN_MOVED_TO = 0x80
- IN_MOVE_SELF = 0x800
- IN_NONBLOCK = 0x4000
- IN_ONESHOT = 0x80000000
- IN_ONLYDIR = 0x1000000
- IN_OPEN = 0x20
- IN_Q_OVERFLOW = 0x4000
- IN_UNMOUNT = 0x2000
- IPPROTO_AH = 0x33
- IPPROTO_BEETPH = 0x5e
- IPPROTO_COMP = 0x6c
- IPPROTO_DCCP = 0x21
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_ENCAP = 0x62
- IPPROTO_ESP = 0x32
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GRE = 0x2f
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IGMP = 0x2
- IPPROTO_IP = 0x0
- IPPROTO_IPIP = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_MH = 0x87
- IPPROTO_MPLS = 0x89
- IPPROTO_MTP = 0x5c
- IPPROTO_NONE = 0x3b
- IPPROTO_PIM = 0x67
- IPPROTO_PUP = 0xc
- IPPROTO_RAW = 0xff
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_SCTP = 0x84
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_UDP = 0x11
- IPPROTO_UDPLITE = 0x88
- IPV6_2292DSTOPTS = 0x4
- IPV6_2292HOPLIMIT = 0x8
- IPV6_2292HOPOPTS = 0x3
- IPV6_2292PKTINFO = 0x2
- IPV6_2292PKTOPTIONS = 0x6
- IPV6_2292RTHDR = 0x5
- IPV6_ADDRFORM = 0x1
- IPV6_ADD_MEMBERSHIP = 0x14
- IPV6_AUTHHDR = 0xa
- IPV6_CHECKSUM = 0x7
- IPV6_DONTFRAG = 0x3e
- IPV6_DROP_MEMBERSHIP = 0x15
- IPV6_DSTOPTS = 0x3b
- IPV6_HDRINCL = 0x24
- IPV6_HOPLIMIT = 0x34
- IPV6_HOPOPTS = 0x36
- IPV6_IPSEC_POLICY = 0x22
- IPV6_JOIN_ANYCAST = 0x1b
- IPV6_JOIN_GROUP = 0x14
- IPV6_LEAVE_ANYCAST = 0x1c
- IPV6_LEAVE_GROUP = 0x15
- IPV6_MTU = 0x18
- IPV6_MTU_DISCOVER = 0x17
- IPV6_MULTICAST_HOPS = 0x12
- IPV6_MULTICAST_IF = 0x11
- IPV6_MULTICAST_LOOP = 0x13
- IPV6_NEXTHOP = 0x9
- IPV6_PATHMTU = 0x3d
- IPV6_PKTINFO = 0x32
- IPV6_PMTUDISC_DO = 0x2
- IPV6_PMTUDISC_DONT = 0x0
- IPV6_PMTUDISC_INTERFACE = 0x4
- IPV6_PMTUDISC_OMIT = 0x5
- IPV6_PMTUDISC_PROBE = 0x3
- IPV6_PMTUDISC_WANT = 0x1
- IPV6_RECVDSTOPTS = 0x3a
- IPV6_RECVERR = 0x19
- IPV6_RECVHOPLIMIT = 0x33
- IPV6_RECVHOPOPTS = 0x35
- IPV6_RECVPATHMTU = 0x3c
- IPV6_RECVPKTINFO = 0x31
- IPV6_RECVRTHDR = 0x38
- IPV6_RECVTCLASS = 0x42
- IPV6_ROUTER_ALERT = 0x16
- IPV6_RTHDR = 0x39
- IPV6_RTHDRDSTOPTS = 0x37
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_RXDSTOPTS = 0x3b
- IPV6_RXHOPOPTS = 0x36
- IPV6_TCLASS = 0x43
- IPV6_UNICAST_HOPS = 0x10
- IPV6_V6ONLY = 0x1a
- IPV6_XFRM_POLICY = 0x23
- IP_ADD_MEMBERSHIP = 0x23
- IP_ADD_SOURCE_MEMBERSHIP = 0x27
- IP_BIND_ADDRESS_NO_PORT = 0x18
- IP_BLOCK_SOURCE = 0x26
- IP_CHECKSUM = 0x17
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0x24
- IP_DROP_SOURCE_MEMBERSHIP = 0x28
- IP_FREEBIND = 0xf
- IP_HDRINCL = 0x3
- IP_IPSEC_POLICY = 0x10
- IP_MAXPACKET = 0xffff
- IP_MAX_MEMBERSHIPS = 0x14
- IP_MF = 0x2000
- IP_MINTTL = 0x15
- IP_MSFILTER = 0x29
- IP_MSS = 0x240
- IP_MTU = 0xe
- IP_MTU_DISCOVER = 0xa
- IP_MULTICAST_ALL = 0x31
- IP_MULTICAST_IF = 0x20
- IP_MULTICAST_LOOP = 0x22
- IP_MULTICAST_TTL = 0x21
- IP_NODEFRAG = 0x16
- IP_OFFMASK = 0x1fff
- IP_OPTIONS = 0x4
- IP_ORIGDSTADDR = 0x14
- IP_PASSSEC = 0x12
- IP_PKTINFO = 0x8
- IP_PKTOPTIONS = 0x9
- IP_PMTUDISC = 0xa
- IP_PMTUDISC_DO = 0x2
- IP_PMTUDISC_DONT = 0x0
- IP_PMTUDISC_INTERFACE = 0x4
- IP_PMTUDISC_OMIT = 0x5
- IP_PMTUDISC_PROBE = 0x3
- IP_PMTUDISC_WANT = 0x1
- IP_RECVERR = 0xb
- IP_RECVOPTS = 0x6
- IP_RECVORIGDSTADDR = 0x14
- IP_RECVRETOPTS = 0x7
- IP_RECVTOS = 0xd
- IP_RECVTTL = 0xc
- IP_RETOPTS = 0x7
- IP_RF = 0x8000
- IP_ROUTER_ALERT = 0x5
- IP_TOS = 0x1
- IP_TRANSPARENT = 0x13
- IP_TTL = 0x2
- IP_UNBLOCK_SOURCE = 0x25
- IP_UNICAST_IF = 0x32
- IP_XFRM_POLICY = 0x11
- ISIG = 0x1
- ISTRIP = 0x20
- IUCLC = 0x200
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x1000
- IXON = 0x400
- LINUX_REBOOT_CMD_CAD_OFF = 0x0
- LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
- LINUX_REBOOT_CMD_HALT = 0xcdef0123
- LINUX_REBOOT_CMD_KEXEC = 0x45584543
- LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
- LINUX_REBOOT_CMD_RESTART = 0x1234567
- LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
- LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
- LINUX_REBOOT_MAGIC1 = 0xfee1dead
- LINUX_REBOOT_MAGIC2 = 0x28121969
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_DODUMP = 0x11
- MADV_DOFORK = 0xb
- MADV_DONTDUMP = 0x10
- MADV_DONTFORK = 0xa
- MADV_DONTNEED = 0x4
- MADV_FREE = 0x8
- MADV_HUGEPAGE = 0xe
- MADV_HWPOISON = 0x64
- MADV_MERGEABLE = 0xc
- MADV_NOHUGEPAGE = 0xf
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_REMOVE = 0x9
- MADV_SEQUENTIAL = 0x2
- MADV_UNMERGEABLE = 0xd
- MADV_WILLNEED = 0x3
- MAP_ANON = 0x20
- MAP_ANONYMOUS = 0x20
- MAP_DENYWRITE = 0x800
- MAP_EXECUTABLE = 0x1000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_GROWSDOWN = 0x200
- MAP_HUGETLB = 0x40000
- MAP_HUGE_MASK = 0x3f
- MAP_HUGE_SHIFT = 0x1a
- MAP_LOCKED = 0x100
- MAP_NONBLOCK = 0x10000
- MAP_NORESERVE = 0x40
- MAP_POPULATE = 0x8000
- MAP_PRIVATE = 0x2
- MAP_RENAME = 0x20
- MAP_SHARED = 0x1
- MAP_STACK = 0x20000
- MAP_TYPE = 0xf
- MCL_CURRENT = 0x2000
- MCL_FUTURE = 0x4000
- MCL_ONFAULT = 0x8000
- MNT_DETACH = 0x2
- MNT_EXPIRE = 0x4
- MNT_FORCE = 0x1
- MSG_BATCH = 0x40000
- MSG_CMSG_CLOEXEC = 0x40000000
- MSG_CONFIRM = 0x800
- MSG_CTRUNC = 0x8
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x40
- MSG_EOR = 0x80
- MSG_ERRQUEUE = 0x2000
- MSG_FASTOPEN = 0x20000000
- MSG_FIN = 0x200
- MSG_MORE = 0x8000
- MSG_NOSIGNAL = 0x4000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_PROXY = 0x10
- MSG_RST = 0x1000
- MSG_SYN = 0x400
- MSG_TRUNC = 0x20
- MSG_TRYHARD = 0x4
- MSG_WAITALL = 0x100
- MSG_WAITFORONE = 0x10000
- MS_ACTIVE = 0x40000000
- MS_ASYNC = 0x1
- MS_BIND = 0x1000
- MS_DIRSYNC = 0x80
- MS_INVALIDATE = 0x2
- MS_I_VERSION = 0x800000
- MS_KERNMOUNT = 0x400000
- MS_LAZYTIME = 0x2000000
- MS_MANDLOCK = 0x40
- MS_MGC_MSK = 0xffff0000
- MS_MGC_VAL = 0xc0ed0000
- MS_MOVE = 0x2000
- MS_NOATIME = 0x400
- MS_NODEV = 0x4
- MS_NODIRATIME = 0x800
- MS_NOEXEC = 0x8
- MS_NOSUID = 0x2
- MS_NOUSER = -0x80000000
- MS_POSIXACL = 0x10000
- MS_PRIVATE = 0x40000
- MS_RDONLY = 0x1
- MS_REC = 0x4000
- MS_RELATIME = 0x200000
- MS_REMOUNT = 0x20
- MS_RMT_MASK = 0x2800051
- MS_SHARED = 0x100000
- MS_SILENT = 0x8000
- MS_SLAVE = 0x80000
- MS_STRICTATIME = 0x1000000
- MS_SYNC = 0x4
- MS_SYNCHRONOUS = 0x10
- MS_UNBINDABLE = 0x20000
- NAME_MAX = 0xff
- NETLINK_ADD_MEMBERSHIP = 0x1
- NETLINK_AUDIT = 0x9
- NETLINK_BROADCAST_ERROR = 0x4
- NETLINK_CAP_ACK = 0xa
- NETLINK_CONNECTOR = 0xb
- NETLINK_CRYPTO = 0x15
- NETLINK_DNRTMSG = 0xe
- NETLINK_DROP_MEMBERSHIP = 0x2
- NETLINK_ECRYPTFS = 0x13
- NETLINK_FIB_LOOKUP = 0xa
- NETLINK_FIREWALL = 0x3
- NETLINK_GENERIC = 0x10
- NETLINK_INET_DIAG = 0x4
- NETLINK_IP6_FW = 0xd
- NETLINK_ISCSI = 0x8
- NETLINK_KOBJECT_UEVENT = 0xf
- NETLINK_LISTEN_ALL_NSID = 0x8
- NETLINK_LIST_MEMBERSHIPS = 0x9
- NETLINK_NETFILTER = 0xc
- NETLINK_NFLOG = 0x5
- NETLINK_NO_ENOBUFS = 0x5
- NETLINK_PKTINFO = 0x3
- NETLINK_RDMA = 0x14
- NETLINK_ROUTE = 0x0
- NETLINK_RX_RING = 0x6
- NETLINK_SCSITRANSPORT = 0x12
- NETLINK_SELINUX = 0x7
- NETLINK_SOCK_DIAG = 0x4
- NETLINK_TX_RING = 0x7
- NETLINK_UNUSED = 0x1
- NETLINK_USERSOCK = 0x2
- NETLINK_XFRM = 0x6
- NL0 = 0x0
- NL1 = 0x100
- NLA_ALIGNTO = 0x4
- NLA_F_NESTED = 0x8000
- NLA_F_NET_BYTEORDER = 0x4000
- NLA_HDRLEN = 0x4
- NLDLY = 0x100
- NLMSG_ALIGNTO = 0x4
- NLMSG_DONE = 0x3
- NLMSG_ERROR = 0x2
- NLMSG_HDRLEN = 0x10
- NLMSG_MIN_TYPE = 0x10
- NLMSG_NOOP = 0x1
- NLMSG_OVERRUN = 0x4
- NLM_F_ACK = 0x4
- NLM_F_APPEND = 0x800
- NLM_F_ATOMIC = 0x400
- NLM_F_CREATE = 0x400
- NLM_F_DUMP = 0x300
- NLM_F_DUMP_FILTERED = 0x20
- NLM_F_DUMP_INTR = 0x10
- NLM_F_ECHO = 0x8
- NLM_F_EXCL = 0x200
- NLM_F_MATCH = 0x200
- NLM_F_MULTI = 0x2
- NLM_F_REPLACE = 0x100
- NLM_F_REQUEST = 0x1
- NLM_F_ROOT = 0x100
- NOFLSH = 0x80
- OCRNL = 0x8
- OFDEL = 0x80
- OFILL = 0x40
- OLCUC = 0x2
- ONLCR = 0x4
- ONLRET = 0x20
- ONOCR = 0x10
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x8
- O_ASYNC = 0x40
- O_CLOEXEC = 0x400000
- O_CREAT = 0x200
- O_DIRECT = 0x100000
- O_DIRECTORY = 0x10000
- O_DSYNC = 0x2000
- O_EXCL = 0x800
- O_FSYNC = 0x802000
- O_LARGEFILE = 0x0
- O_NDELAY = 0x4004
- O_NOATIME = 0x200000
- O_NOCTTY = 0x8000
- O_NOFOLLOW = 0x20000
- O_NONBLOCK = 0x4000
- O_PATH = 0x1000000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_RSYNC = 0x802000
- O_SYNC = 0x802000
- O_TMPFILE = 0x2010000
- O_TRUNC = 0x400
- O_WRONLY = 0x1
- PACKET_ADD_MEMBERSHIP = 0x1
- PACKET_AUXDATA = 0x8
- PACKET_BROADCAST = 0x1
- PACKET_COPY_THRESH = 0x7
- PACKET_DROP_MEMBERSHIP = 0x2
- PACKET_FANOUT = 0x12
- PACKET_FANOUT_CBPF = 0x6
- PACKET_FANOUT_CPU = 0x2
- PACKET_FANOUT_DATA = 0x16
- PACKET_FANOUT_EBPF = 0x7
- PACKET_FANOUT_FLAG_DEFRAG = 0x8000
- PACKET_FANOUT_FLAG_ROLLOVER = 0x1000
- PACKET_FANOUT_HASH = 0x0
- PACKET_FANOUT_LB = 0x1
- PACKET_FANOUT_QM = 0x5
- PACKET_FANOUT_RND = 0x4
- PACKET_FANOUT_ROLLOVER = 0x3
- PACKET_FASTROUTE = 0x6
- PACKET_HDRLEN = 0xb
- PACKET_HOST = 0x0
- PACKET_KERNEL = 0x7
- PACKET_LOOPBACK = 0x5
- PACKET_LOSS = 0xe
- PACKET_MR_ALLMULTI = 0x2
- PACKET_MR_MULTICAST = 0x0
- PACKET_MR_PROMISC = 0x1
- PACKET_MR_UNICAST = 0x3
- PACKET_MULTICAST = 0x2
- PACKET_ORIGDEV = 0x9
- PACKET_OTHERHOST = 0x3
- PACKET_OUTGOING = 0x4
- PACKET_QDISC_BYPASS = 0x14
- PACKET_RECV_OUTPUT = 0x3
- PACKET_RESERVE = 0xc
- PACKET_ROLLOVER_STATS = 0x15
- PACKET_RX_RING = 0x5
- PACKET_STATISTICS = 0x6
- PACKET_TIMESTAMP = 0x11
- PACKET_TX_HAS_OFF = 0x13
- PACKET_TX_RING = 0xd
- PACKET_TX_TIMESTAMP = 0x10
- PACKET_USER = 0x6
- PACKET_VERSION = 0xa
- PACKET_VNET_HDR = 0xf
- PARENB = 0x100
- PARITY_CRC16_PR0 = 0x2
- PARITY_CRC16_PR0_CCITT = 0x4
- PARITY_CRC16_PR1 = 0x3
- PARITY_CRC16_PR1_CCITT = 0x5
- PARITY_CRC32_PR0_CCITT = 0x6
- PARITY_CRC32_PR1_CCITT = 0x7
- PARITY_DEFAULT = 0x0
- PARITY_NONE = 0x1
- PARMRK = 0x8
- PARODD = 0x200
- PENDIN = 0x4000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_GROWSDOWN = 0x1000000
- PROT_GROWSUP = 0x2000000
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- PR_CAPBSET_DROP = 0x18
- PR_CAPBSET_READ = 0x17
- PR_CAP_AMBIENT = 0x2f
- PR_CAP_AMBIENT_CLEAR_ALL = 0x4
- PR_CAP_AMBIENT_IS_SET = 0x1
- PR_CAP_AMBIENT_LOWER = 0x3
- PR_CAP_AMBIENT_RAISE = 0x2
- PR_ENDIAN_BIG = 0x0
- PR_ENDIAN_LITTLE = 0x1
- PR_ENDIAN_PPC_LITTLE = 0x2
- PR_FPEMU_NOPRINT = 0x1
- PR_FPEMU_SIGFPE = 0x2
- PR_FP_EXC_ASYNC = 0x2
- PR_FP_EXC_DISABLED = 0x0
- PR_FP_EXC_DIV = 0x10000
- PR_FP_EXC_INV = 0x100000
- PR_FP_EXC_NONRECOV = 0x1
- PR_FP_EXC_OVF = 0x20000
- PR_FP_EXC_PRECISE = 0x3
- PR_FP_EXC_RES = 0x80000
- PR_FP_EXC_SW_ENABLE = 0x80
- PR_FP_EXC_UND = 0x40000
- PR_FP_MODE_FR = 0x1
- PR_FP_MODE_FRE = 0x2
- PR_GET_CHILD_SUBREAPER = 0x25
- PR_GET_DUMPABLE = 0x3
- PR_GET_ENDIAN = 0x13
- PR_GET_FPEMU = 0x9
- PR_GET_FPEXC = 0xb
- PR_GET_FP_MODE = 0x2e
- PR_GET_KEEPCAPS = 0x7
- PR_GET_NAME = 0x10
- PR_GET_NO_NEW_PRIVS = 0x27
- PR_GET_PDEATHSIG = 0x2
- PR_GET_SECCOMP = 0x15
- PR_GET_SECUREBITS = 0x1b
- PR_GET_THP_DISABLE = 0x2a
- PR_GET_TID_ADDRESS = 0x28
- PR_GET_TIMERSLACK = 0x1e
- PR_GET_TIMING = 0xd
- PR_GET_TSC = 0x19
- PR_GET_UNALIGN = 0x5
- PR_MCE_KILL = 0x21
- PR_MCE_KILL_CLEAR = 0x0
- PR_MCE_KILL_DEFAULT = 0x2
- PR_MCE_KILL_EARLY = 0x1
- PR_MCE_KILL_GET = 0x22
- PR_MCE_KILL_LATE = 0x0
- PR_MCE_KILL_SET = 0x1
- PR_MPX_DISABLE_MANAGEMENT = 0x2c
- PR_MPX_ENABLE_MANAGEMENT = 0x2b
- PR_SET_CHILD_SUBREAPER = 0x24
- PR_SET_DUMPABLE = 0x4
- PR_SET_ENDIAN = 0x14
- PR_SET_FPEMU = 0xa
- PR_SET_FPEXC = 0xc
- PR_SET_FP_MODE = 0x2d
- PR_SET_KEEPCAPS = 0x8
- PR_SET_MM = 0x23
- PR_SET_MM_ARG_END = 0x9
- PR_SET_MM_ARG_START = 0x8
- PR_SET_MM_AUXV = 0xc
- PR_SET_MM_BRK = 0x7
- PR_SET_MM_END_CODE = 0x2
- PR_SET_MM_END_DATA = 0x4
- PR_SET_MM_ENV_END = 0xb
- PR_SET_MM_ENV_START = 0xa
- PR_SET_MM_EXE_FILE = 0xd
- PR_SET_MM_MAP = 0xe
- PR_SET_MM_MAP_SIZE = 0xf
- PR_SET_MM_START_BRK = 0x6
- PR_SET_MM_START_CODE = 0x1
- PR_SET_MM_START_DATA = 0x3
- PR_SET_MM_START_STACK = 0x5
- PR_SET_NAME = 0xf
- PR_SET_NO_NEW_PRIVS = 0x26
- PR_SET_PDEATHSIG = 0x1
- PR_SET_PTRACER = 0x59616d61
- PR_SET_PTRACER_ANY = -0x1
- PR_SET_SECCOMP = 0x16
- PR_SET_SECUREBITS = 0x1c
- PR_SET_THP_DISABLE = 0x29
- PR_SET_TIMERSLACK = 0x1d
- PR_SET_TIMING = 0xe
- PR_SET_TSC = 0x1a
- PR_SET_UNALIGN = 0x6
- PR_TASK_PERF_EVENTS_DISABLE = 0x1f
- PR_TASK_PERF_EVENTS_ENABLE = 0x20
- PR_TIMING_STATISTICAL = 0x0
- PR_TIMING_TIMESTAMP = 0x1
- PR_TSC_ENABLE = 0x1
- PR_TSC_SIGSEGV = 0x2
- PR_UNALIGN_NOPRINT = 0x1
- PR_UNALIGN_SIGBUS = 0x2
- PTRACE_ATTACH = 0x10
- PTRACE_CONT = 0x7
- PTRACE_DETACH = 0x11
- PTRACE_EVENT_CLONE = 0x3
- PTRACE_EVENT_EXEC = 0x4
- PTRACE_EVENT_EXIT = 0x6
- PTRACE_EVENT_FORK = 0x1
- PTRACE_EVENT_SECCOMP = 0x7
- PTRACE_EVENT_STOP = 0x80
- PTRACE_EVENT_VFORK = 0x2
- PTRACE_EVENT_VFORK_DONE = 0x5
- PTRACE_GETEVENTMSG = 0x4201
- PTRACE_GETFPAREGS = 0x14
- PTRACE_GETFPREGS = 0xe
- PTRACE_GETFPREGS64 = 0x19
- PTRACE_GETREGS = 0xc
- PTRACE_GETREGS64 = 0x16
- PTRACE_GETREGSET = 0x4204
- PTRACE_GETSIGINFO = 0x4202
- PTRACE_GETSIGMASK = 0x420a
- PTRACE_INTERRUPT = 0x4207
- PTRACE_KILL = 0x8
- PTRACE_LISTEN = 0x4208
- PTRACE_O_EXITKILL = 0x100000
- PTRACE_O_MASK = 0x3000ff
- PTRACE_O_SUSPEND_SECCOMP = 0x200000
- PTRACE_O_TRACECLONE = 0x8
- PTRACE_O_TRACEEXEC = 0x10
- PTRACE_O_TRACEEXIT = 0x40
- PTRACE_O_TRACEFORK = 0x2
- PTRACE_O_TRACESECCOMP = 0x80
- PTRACE_O_TRACESYSGOOD = 0x1
- PTRACE_O_TRACEVFORK = 0x4
- PTRACE_O_TRACEVFORKDONE = 0x20
- PTRACE_PEEKDATA = 0x2
- PTRACE_PEEKSIGINFO = 0x4209
- PTRACE_PEEKSIGINFO_SHARED = 0x1
- PTRACE_PEEKTEXT = 0x1
- PTRACE_PEEKUSR = 0x3
- PTRACE_POKEDATA = 0x5
- PTRACE_POKETEXT = 0x4
- PTRACE_POKEUSR = 0x6
- PTRACE_READDATA = 0x10
- PTRACE_READTEXT = 0x12
- PTRACE_SECCOMP_GET_FILTER = 0x420c
- PTRACE_SEIZE = 0x4206
- PTRACE_SETFPAREGS = 0x15
- PTRACE_SETFPREGS = 0xf
- PTRACE_SETFPREGS64 = 0x1a
- PTRACE_SETOPTIONS = 0x4200
- PTRACE_SETREGS = 0xd
- PTRACE_SETREGS64 = 0x17
- PTRACE_SETREGSET = 0x4205
- PTRACE_SETSIGINFO = 0x4203
- PTRACE_SETSIGMASK = 0x420b
- PTRACE_SINGLESTEP = 0x9
- PTRACE_SPARC_DETACH = 0xb
- PTRACE_SYSCALL = 0x18
- PTRACE_TRACEME = 0x0
- PTRACE_WRITEDATA = 0x11
- PTRACE_WRITETEXT = 0x13
- PT_FP = 0x48
- PT_G0 = 0x10
- PT_G1 = 0x14
- PT_G2 = 0x18
- PT_G3 = 0x1c
- PT_G4 = 0x20
- PT_G5 = 0x24
- PT_G6 = 0x28
- PT_G7 = 0x2c
- PT_I0 = 0x30
- PT_I1 = 0x34
- PT_I2 = 0x38
- PT_I3 = 0x3c
- PT_I4 = 0x40
- PT_I5 = 0x44
- PT_I6 = 0x48
- PT_I7 = 0x4c
- PT_NPC = 0x8
- PT_PC = 0x4
- PT_PSR = 0x0
- PT_REGS_MAGIC = 0x57ac6c00
- PT_TNPC = 0x90
- PT_TPC = 0x88
- PT_TSTATE = 0x80
- PT_V9_FP = 0x70
- PT_V9_G0 = 0x0
- PT_V9_G1 = 0x8
- PT_V9_G2 = 0x10
- PT_V9_G3 = 0x18
- PT_V9_G4 = 0x20
- PT_V9_G5 = 0x28
- PT_V9_G6 = 0x30
- PT_V9_G7 = 0x38
- PT_V9_I0 = 0x40
- PT_V9_I1 = 0x48
- PT_V9_I2 = 0x50
- PT_V9_I3 = 0x58
- PT_V9_I4 = 0x60
- PT_V9_I5 = 0x68
- PT_V9_I6 = 0x70
- PT_V9_I7 = 0x78
- PT_V9_MAGIC = 0x9c
- PT_V9_TNPC = 0x90
- PT_V9_TPC = 0x88
- PT_V9_TSTATE = 0x80
- PT_V9_Y = 0x98
- PT_WIM = 0x10
- PT_Y = 0xc
- RLIMIT_AS = 0x9
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x6
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = -0x1
- RTAX_ADVMSS = 0x8
- RTAX_CC_ALGO = 0x10
- RTAX_CWND = 0x7
- RTAX_FEATURES = 0xc
- RTAX_FEATURE_ALLFRAG = 0x8
- RTAX_FEATURE_ECN = 0x1
- RTAX_FEATURE_MASK = 0xf
- RTAX_FEATURE_SACK = 0x2
- RTAX_FEATURE_TIMESTAMP = 0x4
- RTAX_HOPLIMIT = 0xa
- RTAX_INITCWND = 0xb
- RTAX_INITRWND = 0xe
- RTAX_LOCK = 0x1
- RTAX_MAX = 0x10
- RTAX_MTU = 0x2
- RTAX_QUICKACK = 0xf
- RTAX_REORDERING = 0x9
- RTAX_RTO_MIN = 0xd
- RTAX_RTT = 0x4
- RTAX_RTTVAR = 0x5
- RTAX_SSTHRESH = 0x6
- RTAX_UNSPEC = 0x0
- RTAX_WINDOW = 0x3
- RTA_ALIGNTO = 0x4
- RTA_MAX = 0x18
- RTCF_DIRECTSRC = 0x4000000
- RTCF_DOREDIRECT = 0x1000000
- RTCF_LOG = 0x2000000
- RTCF_MASQ = 0x400000
- RTCF_NAT = 0x800000
- RTCF_VALVE = 0x200000
- RTF_ADDRCLASSMASK = 0xf8000000
- RTF_ADDRCONF = 0x40000
- RTF_ALLONLINK = 0x20000
- RTF_BROADCAST = 0x10000000
- RTF_CACHE = 0x1000000
- RTF_DEFAULT = 0x10000
- RTF_DYNAMIC = 0x10
- RTF_FLOW = 0x2000000
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_INTERFACE = 0x40000000
- RTF_IRTT = 0x100
- RTF_LINKRT = 0x100000
- RTF_LOCAL = 0x80000000
- RTF_MODIFIED = 0x20
- RTF_MSS = 0x40
- RTF_MTU = 0x40
- RTF_MULTICAST = 0x20000000
- RTF_NAT = 0x8000000
- RTF_NOFORWARD = 0x1000
- RTF_NONEXTHOP = 0x200000
- RTF_NOPMTUDISC = 0x4000
- RTF_POLICY = 0x4000000
- RTF_REINSTATE = 0x8
- RTF_REJECT = 0x200
- RTF_STATIC = 0x400
- RTF_THROW = 0x2000
- RTF_UP = 0x1
- RTF_WINDOW = 0x80
- RTF_XRESOLVE = 0x800
- RTM_BASE = 0x10
- RTM_DELACTION = 0x31
- RTM_DELADDR = 0x15
- RTM_DELADDRLABEL = 0x49
- RTM_DELLINK = 0x11
- RTM_DELMDB = 0x55
- RTM_DELNEIGH = 0x1d
- RTM_DELNSID = 0x59
- RTM_DELQDISC = 0x25
- RTM_DELROUTE = 0x19
- RTM_DELRULE = 0x21
- RTM_DELTCLASS = 0x29
- RTM_DELTFILTER = 0x2d
- RTM_F_CLONED = 0x200
- RTM_F_EQUALIZE = 0x400
- RTM_F_LOOKUP_TABLE = 0x1000
- RTM_F_NOTIFY = 0x100
- RTM_F_PREFIX = 0x800
- RTM_GETACTION = 0x32
- RTM_GETADDR = 0x16
- RTM_GETADDRLABEL = 0x4a
- RTM_GETANYCAST = 0x3e
- RTM_GETDCB = 0x4e
- RTM_GETLINK = 0x12
- RTM_GETMDB = 0x56
- RTM_GETMULTICAST = 0x3a
- RTM_GETNEIGH = 0x1e
- RTM_GETNEIGHTBL = 0x42
- RTM_GETNETCONF = 0x52
- RTM_GETNSID = 0x5a
- RTM_GETQDISC = 0x26
- RTM_GETROUTE = 0x1a
- RTM_GETRULE = 0x22
- RTM_GETSTATS = 0x5e
- RTM_GETTCLASS = 0x2a
- RTM_GETTFILTER = 0x2e
- RTM_MAX = 0x5f
- RTM_NEWACTION = 0x30
- RTM_NEWADDR = 0x14
- RTM_NEWADDRLABEL = 0x48
- RTM_NEWLINK = 0x10
- RTM_NEWMDB = 0x54
- RTM_NEWNDUSEROPT = 0x44
- RTM_NEWNEIGH = 0x1c
- RTM_NEWNEIGHTBL = 0x40
- RTM_NEWNETCONF = 0x50
- RTM_NEWNSID = 0x58
- RTM_NEWPREFIX = 0x34
- RTM_NEWQDISC = 0x24
- RTM_NEWROUTE = 0x18
- RTM_NEWRULE = 0x20
- RTM_NEWSTATS = 0x5c
- RTM_NEWTCLASS = 0x28
- RTM_NEWTFILTER = 0x2c
- RTM_NR_FAMILIES = 0x14
- RTM_NR_MSGTYPES = 0x50
- RTM_SETDCB = 0x4f
- RTM_SETLINK = 0x13
- RTM_SETNEIGHTBL = 0x43
- RTNH_ALIGNTO = 0x4
- RTNH_COMPARE_MASK = 0x11
- RTNH_F_DEAD = 0x1
- RTNH_F_LINKDOWN = 0x10
- RTNH_F_OFFLOAD = 0x8
- RTNH_F_ONLINK = 0x4
- RTNH_F_PERVASIVE = 0x2
- RTN_MAX = 0xb
- RTPROT_BABEL = 0x2a
- RTPROT_BIRD = 0xc
- RTPROT_BOOT = 0x3
- RTPROT_DHCP = 0x10
- RTPROT_DNROUTED = 0xd
- RTPROT_GATED = 0x8
- RTPROT_KERNEL = 0x2
- RTPROT_MROUTED = 0x11
- RTPROT_MRT = 0xa
- RTPROT_NTK = 0xf
- RTPROT_RA = 0x9
- RTPROT_REDIRECT = 0x1
- RTPROT_STATIC = 0x4
- RTPROT_UNSPEC = 0x0
- RTPROT_XORP = 0xe
- RTPROT_ZEBRA = 0xb
- RT_CLASS_DEFAULT = 0xfd
- RT_CLASS_LOCAL = 0xff
- RT_CLASS_MAIN = 0xfe
- RT_CLASS_MAX = 0xff
- RT_CLASS_UNSPEC = 0x0
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- RUSAGE_THREAD = 0x1
- SCM_CREDENTIALS = 0x2
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x1d
- SCM_TIMESTAMPING = 0x23
- SCM_TIMESTAMPNS = 0x21
- SCM_WIFI_STATUS = 0x25
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDDLCI = 0x8980
- SIOCADDMULTI = 0x8931
- SIOCADDRT = 0x890b
- SIOCATMARK = 0x8905
- SIOCBONDCHANGEACTIVE = 0x8995
- SIOCBONDENSLAVE = 0x8990
- SIOCBONDINFOQUERY = 0x8994
- SIOCBONDRELEASE = 0x8991
- SIOCBONDSETHWADDR = 0x8992
- SIOCBONDSLAVEINFOQUERY = 0x8993
- SIOCBRADDBR = 0x89a0
- SIOCBRADDIF = 0x89a2
- SIOCBRDELBR = 0x89a1
- SIOCBRDELIF = 0x89a3
- SIOCDARP = 0x8953
- SIOCDELDLCI = 0x8981
- SIOCDELMULTI = 0x8932
- SIOCDELRT = 0x890c
- SIOCDEVPRIVATE = 0x89f0
- SIOCDIFADDR = 0x8936
- SIOCDRARP = 0x8960
- SIOCETHTOOL = 0x8946
- SIOCGARP = 0x8954
- SIOCGHWTSTAMP = 0x89b1
- SIOCGIFADDR = 0x8915
- SIOCGIFBR = 0x8940
- SIOCGIFBRDADDR = 0x8919
- SIOCGIFCONF = 0x8912
- SIOCGIFCOUNT = 0x8938
- SIOCGIFDSTADDR = 0x8917
- SIOCGIFENCAP = 0x8925
- SIOCGIFFLAGS = 0x8913
- SIOCGIFHWADDR = 0x8927
- SIOCGIFINDEX = 0x8933
- SIOCGIFMAP = 0x8970
- SIOCGIFMEM = 0x891f
- SIOCGIFMETRIC = 0x891d
- SIOCGIFMTU = 0x8921
- SIOCGIFNAME = 0x8910
- SIOCGIFNETMASK = 0x891b
- SIOCGIFPFLAGS = 0x8935
- SIOCGIFSLAVE = 0x8929
- SIOCGIFTXQLEN = 0x8942
- SIOCGIFVLAN = 0x8982
- SIOCGMIIPHY = 0x8947
- SIOCGMIIREG = 0x8948
- SIOCGPGRP = 0x8904
- SIOCGRARP = 0x8961
- SIOCGSTAMP = 0x8906
- SIOCGSTAMPNS = 0x8907
- SIOCINQ = 0x4004667f
- SIOCOUTQ = 0x40047473
- SIOCOUTQNSD = 0x894b
- SIOCPROTOPRIVATE = 0x89e0
- SIOCRTMSG = 0x890d
- SIOCSARP = 0x8955
- SIOCSHWTSTAMP = 0x89b0
- SIOCSIFADDR = 0x8916
- SIOCSIFBR = 0x8941
- SIOCSIFBRDADDR = 0x891a
- SIOCSIFDSTADDR = 0x8918
- SIOCSIFENCAP = 0x8926
- SIOCSIFFLAGS = 0x8914
- SIOCSIFHWADDR = 0x8924
- SIOCSIFHWBROADCAST = 0x8937
- SIOCSIFLINK = 0x8911
- SIOCSIFMAP = 0x8971
- SIOCSIFMEM = 0x8920
- SIOCSIFMETRIC = 0x891e
- SIOCSIFMTU = 0x8922
- SIOCSIFNAME = 0x8923
- SIOCSIFNETMASK = 0x891c
- SIOCSIFPFLAGS = 0x8934
- SIOCSIFSLAVE = 0x8930
- SIOCSIFTXQLEN = 0x8943
- SIOCSIFVLAN = 0x8983
- SIOCSMIIREG = 0x8949
- SIOCSPGRP = 0x8902
- SIOCSRARP = 0x8962
- SIOCWANDEV = 0x894a
- SOCK_CLOEXEC = 0x400000
- SOCK_DCCP = 0x6
- SOCK_DGRAM = 0x2
- SOCK_NONBLOCK = 0x4000
- SOCK_PACKET = 0xa
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_AAL = 0x109
- SOL_ALG = 0x117
- SOL_ATM = 0x108
- SOL_CAIF = 0x116
- SOL_DCCP = 0x10d
- SOL_DECNET = 0x105
- SOL_ICMPV6 = 0x3a
- SOL_IP = 0x0
- SOL_IPV6 = 0x29
- SOL_IRDA = 0x10a
- SOL_IUCV = 0x115
- SOL_KCM = 0x119
- SOL_LLC = 0x10c
- SOL_NETBEUI = 0x10b
- SOL_NETLINK = 0x10e
- SOL_NFC = 0x118
- SOL_PACKET = 0x107
- SOL_PNPIPE = 0x113
- SOL_PPPOL2TP = 0x111
- SOL_RAW = 0xff
- SOL_RDS = 0x114
- SOL_RXRPC = 0x110
- SOL_SOCKET = 0xffff
- SOL_TCP = 0x6
- SOL_TIPC = 0x10f
- SOL_X25 = 0x106
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x8000
- SO_ATTACH_BPF = 0x34
- SO_ATTACH_FILTER = 0x1a
- SO_ATTACH_REUSEPORT_CBPF = 0x35
- SO_ATTACH_REUSEPORT_EBPF = 0x36
- SO_BINDTODEVICE = 0xd
- SO_BPF_EXTENSIONS = 0x32
- SO_BROADCAST = 0x20
- SO_BSDCOMPAT = 0x400
- SO_BUSY_POLL = 0x30
- SO_CNX_ADVICE = 0x37
- SO_DEBUG = 0x1
- SO_DETACH_BPF = 0x1b
- SO_DETACH_FILTER = 0x1b
- SO_DOMAIN = 0x1029
- SO_DONTROUTE = 0x10
- SO_ERROR = 0x1007
- SO_GET_FILTER = 0x1a
- SO_INCOMING_CPU = 0x33
- SO_KEEPALIVE = 0x8
- SO_LINGER = 0x80
- SO_LOCK_FILTER = 0x28
- SO_MARK = 0x22
- SO_MAX_PACING_RATE = 0x31
- SO_NOFCS = 0x27
- SO_NO_CHECK = 0xb
- SO_OOBINLINE = 0x100
- SO_PASSCRED = 0x2
- SO_PASSSEC = 0x1f
- SO_PEEK_OFF = 0x26
- SO_PEERCRED = 0x40
- SO_PEERNAME = 0x1c
- SO_PEERSEC = 0x1e
- SO_PRIORITY = 0xc
- SO_PROTOCOL = 0x1028
- SO_RCVBUF = 0x1002
- SO_RCVBUFFORCE = 0x100b
- SO_RCVLOWAT = 0x800
- SO_RCVTIMEO = 0x2000
- SO_REUSEADDR = 0x4
- SO_REUSEPORT = 0x200
- SO_RXQ_OVFL = 0x24
- SO_SECURITY_AUTHENTICATION = 0x5001
- SO_SECURITY_ENCRYPTION_NETWORK = 0x5004
- SO_SECURITY_ENCRYPTION_TRANSPORT = 0x5002
- SO_SELECT_ERR_QUEUE = 0x29
- SO_SNDBUF = 0x1001
- SO_SNDBUFFORCE = 0x100a
- SO_SNDLOWAT = 0x1000
- SO_SNDTIMEO = 0x4000
- SO_TIMESTAMP = 0x1d
- SO_TIMESTAMPING = 0x23
- SO_TIMESTAMPNS = 0x21
- SO_TYPE = 0x1008
- SO_WIFI_STATUS = 0x25
- S_BLKSIZE = 0x200
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TAB0 = 0x0
- TAB1 = 0x800
- TAB2 = 0x1000
- TAB3 = 0x1800
- TABDLY = 0x1800
- TCFLSH = 0x20005407
- TCGETA = 0x40125401
- TCGETS = 0x40245408
- TCGETS2 = 0x402c540c
- TCIFLUSH = 0x0
- TCIOFF = 0x2
- TCIOFLUSH = 0x2
- TCION = 0x3
- TCOFLUSH = 0x1
- TCOOFF = 0x0
- TCOON = 0x1
- TCP_CC_INFO = 0x1a
- TCP_CONGESTION = 0xd
- TCP_COOKIE_IN_ALWAYS = 0x1
- TCP_COOKIE_MAX = 0x10
- TCP_COOKIE_MIN = 0x8
- TCP_COOKIE_OUT_NEVER = 0x2
- TCP_COOKIE_PAIR_SIZE = 0x20
- TCP_COOKIE_TRANSACTIONS = 0xf
- TCP_CORK = 0x3
- TCP_DEFER_ACCEPT = 0x9
- TCP_FASTOPEN = 0x17
- TCP_INFO = 0xb
- TCP_KEEPCNT = 0x6
- TCP_KEEPIDLE = 0x4
- TCP_KEEPINTVL = 0x5
- TCP_LINGER2 = 0x8
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0xe
- TCP_MD5SIG_MAXKEYLEN = 0x50
- TCP_MSS = 0x200
- TCP_MSS_DEFAULT = 0x218
- TCP_MSS_DESIRED = 0x4c4
- TCP_NODELAY = 0x1
- TCP_NOTSENT_LOWAT = 0x19
- TCP_QUEUE_SEQ = 0x15
- TCP_QUICKACK = 0xc
- TCP_REPAIR = 0x13
- TCP_REPAIR_OPTIONS = 0x16
- TCP_REPAIR_QUEUE = 0x14
- TCP_SAVED_SYN = 0x1c
- TCP_SAVE_SYN = 0x1b
- TCP_SYNCNT = 0x7
- TCP_S_DATA_IN = 0x4
- TCP_S_DATA_OUT = 0x8
- TCP_THIN_DUPACK = 0x11
- TCP_THIN_LINEAR_TIMEOUTS = 0x10
- TCP_TIMESTAMP = 0x18
- TCP_USER_TIMEOUT = 0x12
- TCP_WINDOW_CLAMP = 0xa
- TCSAFLUSH = 0x2
- TCSBRK = 0x20005405
- TCSBRKP = 0x5425
- TCSETA = 0x80125402
- TCSETAF = 0x80125404
- TCSETAW = 0x80125403
- TCSETS = 0x80245409
- TCSETS2 = 0x802c540d
- TCSETSF = 0x8024540b
- TCSETSF2 = 0x802c540f
- TCSETSW = 0x8024540a
- TCSETSW2 = 0x802c540e
- TCXONC = 0x20005406
- TIOCCBRK = 0x2000747a
- TIOCCONS = 0x20007424
- TIOCEXCL = 0x2000740d
- TIOCGDEV = 0x40045432
- TIOCGETD = 0x40047400
- TIOCGEXCL = 0x40045440
- TIOCGICOUNT = 0x545d
- TIOCGLCKTRMIOS = 0x5456
- TIOCGPGRP = 0x40047483
- TIOCGPKT = 0x40045438
- TIOCGPTLCK = 0x40045439
- TIOCGPTN = 0x40047486
- TIOCGRS485 = 0x40205441
- TIOCGSERIAL = 0x541e
- TIOCGSID = 0x40047485
- TIOCGSOFTCAR = 0x40047464
- TIOCGWINSZ = 0x40087468
- TIOCINQ = 0x4004667f
- TIOCLINUX = 0x541c
- TIOCMBIC = 0x8004746b
- TIOCMBIS = 0x8004746c
- TIOCMGET = 0x4004746a
- TIOCMIWAIT = 0x545c
- TIOCMSET = 0x8004746d
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_LOOP = 0x8000
- TIOCM_OUT1 = 0x2000
- TIOCM_OUT2 = 0x4000
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x20007471
- TIOCNXCL = 0x2000740e
- TIOCOUTQ = 0x40047473
- TIOCPKT = 0x80047470
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCSBRK = 0x2000747b
- TIOCSCTTY = 0x20007484
- TIOCSERCONFIG = 0x5453
- TIOCSERGETLSR = 0x5459
- TIOCSERGETMULTI = 0x545a
- TIOCSERGSTRUCT = 0x5458
- TIOCSERGWILD = 0x5454
- TIOCSERSETMULTI = 0x545b
- TIOCSERSWILD = 0x5455
- TIOCSER_TEMT = 0x1
- TIOCSETD = 0x80047401
- TIOCSIG = 0x80047488
- TIOCSLCKTRMIOS = 0x5457
- TIOCSPGRP = 0x80047482
- TIOCSPTLCK = 0x80047487
- TIOCSRS485 = 0xc0205442
- TIOCSSERIAL = 0x541f
- TIOCSSOFTCAR = 0x80047465
- TIOCSTART = 0x2000746e
- TIOCSTI = 0x80017472
- TIOCSTOP = 0x2000746f
- TIOCSWINSZ = 0x80087467
- TIOCVHANGUP = 0x20005437
- TOSTOP = 0x100
- TUNATTACHFILTER = 0x801054d5
- TUNDETACHFILTER = 0x801054d6
- TUNGETFEATURES = 0x400454cf
- TUNGETFILTER = 0x401054db
- TUNGETIFF = 0x400454d2
- TUNGETSNDBUF = 0x400454d3
- TUNGETVNETBE = 0x400454df
- TUNGETVNETHDRSZ = 0x400454d7
- TUNGETVNETLE = 0x400454dd
- TUNSETDEBUG = 0x800454c9
- TUNSETGROUP = 0x800454ce
- TUNSETIFF = 0x800454ca
- TUNSETIFINDEX = 0x800454da
- TUNSETLINK = 0x800454cd
- TUNSETNOCSUM = 0x800454c8
- TUNSETOFFLOAD = 0x800454d0
- TUNSETOWNER = 0x800454cc
- TUNSETPERSIST = 0x800454cb
- TUNSETQUEUE = 0x800454d9
- TUNSETSNDBUF = 0x800454d4
- TUNSETTXFILTER = 0x800454d1
- TUNSETVNETBE = 0x800454de
- TUNSETVNETHDRSZ = 0x800454d8
- TUNSETVNETLE = 0x800454dc
- VDISCARD = 0xd
- VDSUSP = 0xb
- VEOF = 0x4
- VEOL = 0x5
- VEOL2 = 0x6
- VERASE = 0x2
- VINTR = 0x0
- VKILL = 0x3
- VLNEXT = 0xf
- VMIN = 0x4
- VQUIT = 0x1
- VREPRINT = 0xc
- VSTART = 0x8
- VSTOP = 0x9
- VSUSP = 0xa
- VSWTC = 0x7
- VT0 = 0x0
- VT1 = 0x4000
- VTDLY = 0x4000
- VTIME = 0x5
- VWERASE = 0xe
- WALL = 0x40000000
- WCLONE = 0x80000000
- WCONTINUED = 0x8
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOTHREAD = 0x20000000
- WNOWAIT = 0x1000000
- WORDSIZE = 0x40
- WRAP = 0x20000
- WSTOPPED = 0x2
- WUNTRACED = 0x2
- XCASE = 0x4
- XTABS = 0x1800
- __TIOCFLUSH = 0x80047410
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x30)
- EADDRNOTAVAIL = syscall.Errno(0x31)
- EADV = syscall.Errno(0x53)
- EAFNOSUPPORT = syscall.Errno(0x2f)
- EAGAIN = syscall.Errno(0xb)
- EALREADY = syscall.Errno(0x25)
- EBADE = syscall.Errno(0x66)
- EBADF = syscall.Errno(0x9)
- EBADFD = syscall.Errno(0x5d)
- EBADMSG = syscall.Errno(0x4c)
- EBADR = syscall.Errno(0x67)
- EBADRQC = syscall.Errno(0x6a)
- EBADSLT = syscall.Errno(0x6b)
- EBFONT = syscall.Errno(0x6d)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x7f)
- ECHILD = syscall.Errno(0xa)
- ECHRNG = syscall.Errno(0x5e)
- ECOMM = syscall.Errno(0x55)
- ECONNABORTED = syscall.Errno(0x35)
- ECONNREFUSED = syscall.Errno(0x3d)
- ECONNRESET = syscall.Errno(0x36)
- EDEADLK = syscall.Errno(0x4e)
- EDEADLOCK = syscall.Errno(0x6c)
- EDESTADDRREQ = syscall.Errno(0x27)
- EDOM = syscall.Errno(0x21)
- EDOTDOT = syscall.Errno(0x58)
- EDQUOT = syscall.Errno(0x45)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EHOSTDOWN = syscall.Errno(0x40)
- EHOSTUNREACH = syscall.Errno(0x41)
- EHWPOISON = syscall.Errno(0x87)
- EIDRM = syscall.Errno(0x4d)
- EILSEQ = syscall.Errno(0x7a)
- EINPROGRESS = syscall.Errno(0x24)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x38)
- EISDIR = syscall.Errno(0x15)
- EISNAM = syscall.Errno(0x78)
- EKEYEXPIRED = syscall.Errno(0x81)
- EKEYREJECTED = syscall.Errno(0x83)
- EKEYREVOKED = syscall.Errno(0x82)
- EL2HLT = syscall.Errno(0x65)
- EL2NSYNC = syscall.Errno(0x5f)
- EL3HLT = syscall.Errno(0x60)
- EL3RST = syscall.Errno(0x61)
- ELIBACC = syscall.Errno(0x72)
- ELIBBAD = syscall.Errno(0x70)
- ELIBEXEC = syscall.Errno(0x6e)
- ELIBMAX = syscall.Errno(0x7b)
- ELIBSCN = syscall.Errno(0x7c)
- ELNRNG = syscall.Errno(0x62)
- ELOOP = syscall.Errno(0x3e)
- EMEDIUMTYPE = syscall.Errno(0x7e)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x28)
- EMULTIHOP = syscall.Errno(0x57)
- ENAMETOOLONG = syscall.Errno(0x3f)
- ENAVAIL = syscall.Errno(0x77)
- ENETDOWN = syscall.Errno(0x32)
- ENETRESET = syscall.Errno(0x34)
- ENETUNREACH = syscall.Errno(0x33)
- ENFILE = syscall.Errno(0x17)
- ENOANO = syscall.Errno(0x69)
- ENOBUFS = syscall.Errno(0x37)
- ENOCSI = syscall.Errno(0x64)
- ENODATA = syscall.Errno(0x6f)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOKEY = syscall.Errno(0x80)
- ENOLCK = syscall.Errno(0x4f)
- ENOLINK = syscall.Errno(0x52)
- ENOMEDIUM = syscall.Errno(0x7d)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x4b)
- ENONET = syscall.Errno(0x50)
- ENOPKG = syscall.Errno(0x71)
- ENOPROTOOPT = syscall.Errno(0x2a)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x4a)
- ENOSTR = syscall.Errno(0x48)
- ENOSYS = syscall.Errno(0x5a)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x39)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x42)
- ENOTNAM = syscall.Errno(0x76)
- ENOTRECOVERABLE = syscall.Errno(0x85)
- ENOTSOCK = syscall.Errno(0x26)
- ENOTSUP = syscall.Errno(0x2d)
- ENOTTY = syscall.Errno(0x19)
- ENOTUNIQ = syscall.Errno(0x73)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x2d)
- EOVERFLOW = syscall.Errno(0x5c)
- EOWNERDEAD = syscall.Errno(0x84)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x2e)
- EPIPE = syscall.Errno(0x20)
- EPROCLIM = syscall.Errno(0x43)
- EPROTO = syscall.Errno(0x56)
- EPROTONOSUPPORT = syscall.Errno(0x2b)
- EPROTOTYPE = syscall.Errno(0x29)
- ERANGE = syscall.Errno(0x22)
- EREMCHG = syscall.Errno(0x59)
- EREMOTE = syscall.Errno(0x47)
- EREMOTEIO = syscall.Errno(0x79)
- ERESTART = syscall.Errno(0x74)
- ERFKILL = syscall.Errno(0x86)
- EROFS = syscall.Errno(0x1e)
- ERREMOTE = syscall.Errno(0x51)
- ESHUTDOWN = syscall.Errno(0x3a)
- ESOCKTNOSUPPORT = syscall.Errno(0x2c)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESRMNT = syscall.Errno(0x54)
- ESTALE = syscall.Errno(0x46)
- ESTRPIPE = syscall.Errno(0x5b)
- ETIME = syscall.Errno(0x49)
- ETIMEDOUT = syscall.Errno(0x3c)
- ETOOMANYREFS = syscall.Errno(0x3b)
- ETXTBSY = syscall.Errno(0x1a)
- EUCLEAN = syscall.Errno(0x75)
- EUNATCH = syscall.Errno(0x63)
- EUSERS = syscall.Errno(0x44)
- EWOULDBLOCK = syscall.Errno(0xb)
- EXDEV = syscall.Errno(0x12)
- EXFULL = syscall.Errno(0x68)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0xa)
- SIGCHLD = syscall.Signal(0x14)
- SIGCLD = syscall.Signal(0x14)
- SIGCONT = syscall.Signal(0x13)
- SIGEMT = syscall.Signal(0x7)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x17)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGLOST = syscall.Signal(0x1d)
- SIGPIPE = syscall.Signal(0xd)
- SIGPOLL = syscall.Signal(0x17)
- SIGPROF = syscall.Signal(0x1b)
- SIGPWR = syscall.Signal(0x1d)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTOP = syscall.Signal(0x11)
- SIGSYS = syscall.Signal(0xc)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x12)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGURG = syscall.Signal(0x10)
- SIGUSR1 = syscall.Signal(0x1e)
- SIGUSR2 = syscall.Signal(0x1f)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "no such device or address",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource temporarily unavailable",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device or resource busy",
- 17: "file exists",
- 18: "invalid cross-device link",
- 19: "no such device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "numerical result out of range",
- 36: "operation now in progress",
- 37: "operation already in progress",
- 38: "socket operation on non-socket",
- 39: "destination address required",
- 40: "message too long",
- 41: "protocol wrong type for socket",
- 42: "protocol not available",
- 43: "protocol not supported",
- 44: "socket type not supported",
- 45: "operation not supported",
- 46: "protocol family not supported",
- 47: "address family not supported by protocol",
- 48: "address already in use",
- 49: "cannot assign requested address",
- 50: "network is down",
- 51: "network is unreachable",
- 52: "network dropped connection on reset",
- 53: "software caused connection abort",
- 54: "connection reset by peer",
- 55: "no buffer space available",
- 56: "transport endpoint is already connected",
- 57: "transport endpoint is not connected",
- 58: "cannot send after transport endpoint shutdown",
- 59: "too many references: cannot splice",
- 60: "connection timed out",
- 61: "connection refused",
- 62: "too many levels of symbolic links",
- 63: "file name too long",
- 64: "host is down",
- 65: "no route to host",
- 66: "directory not empty",
- 67: "too many processes",
- 68: "too many users",
- 69: "disk quota exceeded",
- 70: "stale file handle",
- 71: "object is remote",
- 72: "device not a stream",
- 73: "timer expired",
- 74: "out of streams resources",
- 75: "no message of desired type",
- 76: "bad message",
- 77: "identifier removed",
- 78: "resource deadlock avoided",
- 79: "no locks available",
- 80: "machine is not on the network",
- 81: "unknown error 81",
- 82: "link has been severed",
- 83: "advertise error",
- 84: "srmount error",
- 85: "communication error on send",
- 86: "protocol error",
- 87: "multihop attempted",
- 88: "RFS specific error",
- 89: "remote address changed",
- 90: "function not implemented",
- 91: "streams pipe error",
- 92: "value too large for defined data type",
- 93: "file descriptor in bad state",
- 94: "channel number out of range",
- 95: "level 2 not synchronized",
- 96: "level 3 halted",
- 97: "level 3 reset",
- 98: "link number out of range",
- 99: "protocol driver not attached",
- 100: "no CSI structure available",
- 101: "level 2 halted",
- 102: "invalid exchange",
- 103: "invalid request descriptor",
- 104: "exchange full",
- 105: "no anode",
- 106: "invalid request code",
- 107: "invalid slot",
- 108: "file locking deadlock error",
- 109: "bad font file format",
- 110: "cannot exec a shared library directly",
- 111: "no data available",
- 112: "accessing a corrupted shared library",
- 113: "package not installed",
- 114: "can not access a needed shared library",
- 115: "name not unique on network",
- 116: "interrupted system call should be restarted",
- 117: "structure needs cleaning",
- 118: "not a XENIX named type file",
- 119: "no XENIX semaphores available",
- 120: "is a named type file",
- 121: "remote I/O error",
- 122: "invalid or incomplete multibyte or wide character",
- 123: "attempting to link in too many shared libraries",
- 124: ".lib section in a.out corrupted",
- 125: "no medium found",
- 126: "wrong medium type",
- 127: "operation canceled",
- 128: "required key not available",
- 129: "key has expired",
- 130: "key has been revoked",
- 131: "key was rejected by service",
- 132: "owner died",
- 133: "state not recoverable",
- 134: "operation not possible due to RF-kill",
- 135: "memory page has hardware error",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/breakpoint trap",
- 6: "aborted",
- 7: "EMT trap",
- 8: "floating point exception",
- 9: "killed",
- 10: "bus error",
- 11: "segmentation fault",
- 12: "bad system call",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "urgent I/O condition",
- 17: "stopped (signal)",
- 18: "stopped",
- 19: "continued",
- 20: "child exited",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "I/O possible",
- 24: "CPU time limit exceeded",
- 25: "file size limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window changed",
- 29: "resource lost",
- 30: "user defined signal 1",
- 31: "user defined signal 2",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go b/newt/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go
deleted file mode 100644
index ac85ca64..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go
+++ /dev/null
@@ -1,1688 +0,0 @@
-// mkerrors.sh -marm
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build arm,netbsd
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -marm _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_APPLETALK = 0x10
- AF_ARP = 0x1c
- AF_BLUETOOTH = 0x1f
- AF_CCITT = 0xa
- AF_CHAOS = 0x5
- AF_CNT = 0x15
- AF_COIP = 0x14
- AF_DATAKIT = 0x9
- AF_DECnet = 0xc
- AF_DLI = 0xd
- AF_E164 = 0x1a
- AF_ECMA = 0x8
- AF_HYLINK = 0xf
- AF_IEEE80211 = 0x20
- AF_IMPLINK = 0x3
- AF_INET = 0x2
- AF_INET6 = 0x18
- AF_IPX = 0x17
- AF_ISDN = 0x1a
- AF_ISO = 0x7
- AF_LAT = 0xe
- AF_LINK = 0x12
- AF_LOCAL = 0x1
- AF_MAX = 0x23
- AF_MPLS = 0x21
- AF_NATM = 0x1b
- AF_NS = 0x6
- AF_OROUTE = 0x11
- AF_OSI = 0x7
- AF_PUP = 0x4
- AF_ROUTE = 0x22
- AF_SNA = 0xb
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- ARPHRD_ARCNET = 0x7
- ARPHRD_ETHER = 0x1
- ARPHRD_FRELAY = 0xf
- ARPHRD_IEEE1394 = 0x18
- ARPHRD_IEEE802 = 0x6
- ARPHRD_STRIP = 0x17
- B0 = 0x0
- B110 = 0x6e
- B115200 = 0x1c200
- B1200 = 0x4b0
- B134 = 0x86
- B14400 = 0x3840
- B150 = 0x96
- B1800 = 0x708
- B19200 = 0x4b00
- B200 = 0xc8
- B230400 = 0x38400
- B2400 = 0x960
- B28800 = 0x7080
- B300 = 0x12c
- B38400 = 0x9600
- B460800 = 0x70800
- B4800 = 0x12c0
- B50 = 0x32
- B57600 = 0xe100
- B600 = 0x258
- B7200 = 0x1c20
- B75 = 0x4b
- B76800 = 0x12c00
- B921600 = 0xe1000
- B9600 = 0x2580
- BIOCFEEDBACK = 0x8004427d
- BIOCFLUSH = 0x20004268
- BIOCGBLEN = 0x40044266
- BIOCGDLT = 0x4004426a
- BIOCGDLTLIST = 0xc0084277
- BIOCGETIF = 0x4090426b
- BIOCGFEEDBACK = 0x4004427c
- BIOCGHDRCMPLT = 0x40044274
- BIOCGRTIMEOUT = 0x400c427b
- BIOCGSEESENT = 0x40044278
- BIOCGSTATS = 0x4080426f
- BIOCGSTATSOLD = 0x4008426f
- BIOCIMMEDIATE = 0x80044270
- BIOCPROMISC = 0x20004269
- BIOCSBLEN = 0xc0044266
- BIOCSDLT = 0x80044276
- BIOCSETF = 0x80084267
- BIOCSETIF = 0x8090426c
- BIOCSFEEDBACK = 0x8004427d
- BIOCSHDRCMPLT = 0x80044275
- BIOCSRTIMEOUT = 0x800c427a
- BIOCSSEESENT = 0x80044279
- BIOCSTCPF = 0x80084272
- BIOCSUDPF = 0x80084273
- BIOCVERSION = 0x40044271
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALIGNMENT = 0x4
- BPF_ALIGNMENT32 = 0x4
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DFLTBUFSIZE = 0x100000
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXBUFSIZE = 0x1000000
- BPF_MAXINSNS = 0x200
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINBUFSIZE = 0x20
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RELEASE = 0x30bb6
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BRKINT = 0x2
- CFLUSH = 0xf
- CLOCAL = 0x8000
- CREAD = 0x800
- CS5 = 0x0
- CS6 = 0x100
- CS7 = 0x200
- CS8 = 0x300
- CSIZE = 0x300
- CSTART = 0x11
- CSTATUS = 0x14
- CSTOP = 0x13
- CSTOPB = 0x400
- CSUSP = 0x1a
- CTL_MAXNAME = 0xc
- CTL_NET = 0x4
- CTL_QUERY = -0x2
- DIOCBSFLUSH = 0x20006478
- DLT_A429 = 0xb8
- DLT_A653_ICM = 0xb9
- DLT_AIRONET_HEADER = 0x78
- DLT_AOS = 0xde
- DLT_APPLE_IP_OVER_IEEE1394 = 0x8a
- DLT_ARCNET = 0x7
- DLT_ARCNET_LINUX = 0x81
- DLT_ATM_CLIP = 0x13
- DLT_ATM_RFC1483 = 0xb
- DLT_AURORA = 0x7e
- DLT_AX25 = 0x3
- DLT_AX25_KISS = 0xca
- DLT_BACNET_MS_TP = 0xa5
- DLT_BLUETOOTH_HCI_H4 = 0xbb
- DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9
- DLT_CAN20B = 0xbe
- DLT_CAN_SOCKETCAN = 0xe3
- DLT_CHAOS = 0x5
- DLT_CISCO_IOS = 0x76
- DLT_C_HDLC = 0x68
- DLT_C_HDLC_WITH_DIR = 0xcd
- DLT_DECT = 0xdd
- DLT_DOCSIS = 0x8f
- DLT_ECONET = 0x73
- DLT_EN10MB = 0x1
- DLT_EN3MB = 0x2
- DLT_ENC = 0x6d
- DLT_ERF = 0xc5
- DLT_ERF_ETH = 0xaf
- DLT_ERF_POS = 0xb0
- DLT_FC_2 = 0xe0
- DLT_FC_2_WITH_FRAME_DELIMS = 0xe1
- DLT_FDDI = 0xa
- DLT_FLEXRAY = 0xd2
- DLT_FRELAY = 0x6b
- DLT_FRELAY_WITH_DIR = 0xce
- DLT_GCOM_SERIAL = 0xad
- DLT_GCOM_T1E1 = 0xac
- DLT_GPF_F = 0xab
- DLT_GPF_T = 0xaa
- DLT_GPRS_LLC = 0xa9
- DLT_GSMTAP_ABIS = 0xda
- DLT_GSMTAP_UM = 0xd9
- DLT_HDLC = 0x10
- DLT_HHDLC = 0x79
- DLT_HIPPI = 0xf
- DLT_IBM_SN = 0x92
- DLT_IBM_SP = 0x91
- DLT_IEEE802 = 0x6
- DLT_IEEE802_11 = 0x69
- DLT_IEEE802_11_RADIO = 0x7f
- DLT_IEEE802_11_RADIO_AVS = 0xa3
- DLT_IEEE802_15_4 = 0xc3
- DLT_IEEE802_15_4_LINUX = 0xbf
- DLT_IEEE802_15_4_NONASK_PHY = 0xd7
- DLT_IEEE802_16_MAC_CPS = 0xbc
- DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1
- DLT_IPMB = 0xc7
- DLT_IPMB_LINUX = 0xd1
- DLT_IPNET = 0xe2
- DLT_IPV4 = 0xe4
- DLT_IPV6 = 0xe5
- DLT_IP_OVER_FC = 0x7a
- DLT_JUNIPER_ATM1 = 0x89
- DLT_JUNIPER_ATM2 = 0x87
- DLT_JUNIPER_CHDLC = 0xb5
- DLT_JUNIPER_ES = 0x84
- DLT_JUNIPER_ETHER = 0xb2
- DLT_JUNIPER_FRELAY = 0xb4
- DLT_JUNIPER_GGSN = 0x85
- DLT_JUNIPER_ISM = 0xc2
- DLT_JUNIPER_MFR = 0x86
- DLT_JUNIPER_MLFR = 0x83
- DLT_JUNIPER_MLPPP = 0x82
- DLT_JUNIPER_MONITOR = 0xa4
- DLT_JUNIPER_PIC_PEER = 0xae
- DLT_JUNIPER_PPP = 0xb3
- DLT_JUNIPER_PPPOE = 0xa7
- DLT_JUNIPER_PPPOE_ATM = 0xa8
- DLT_JUNIPER_SERVICES = 0x88
- DLT_JUNIPER_ST = 0xc8
- DLT_JUNIPER_VP = 0xb7
- DLT_LAPB_WITH_DIR = 0xcf
- DLT_LAPD = 0xcb
- DLT_LIN = 0xd4
- DLT_LINUX_EVDEV = 0xd8
- DLT_LINUX_IRDA = 0x90
- DLT_LINUX_LAPD = 0xb1
- DLT_LINUX_SLL = 0x71
- DLT_LOOP = 0x6c
- DLT_LTALK = 0x72
- DLT_MFR = 0xb6
- DLT_MOST = 0xd3
- DLT_MPLS = 0xdb
- DLT_MTP2 = 0x8c
- DLT_MTP2_WITH_PHDR = 0x8b
- DLT_MTP3 = 0x8d
- DLT_NULL = 0x0
- DLT_PCI_EXP = 0x7d
- DLT_PFLOG = 0x75
- DLT_PFSYNC = 0x12
- DLT_PPI = 0xc0
- DLT_PPP = 0x9
- DLT_PPP_BSDOS = 0xe
- DLT_PPP_ETHER = 0x33
- DLT_PPP_PPPD = 0xa6
- DLT_PPP_SERIAL = 0x32
- DLT_PPP_WITH_DIR = 0xcc
- DLT_PRISM_HEADER = 0x77
- DLT_PRONET = 0x4
- DLT_RAIF1 = 0xc6
- DLT_RAW = 0xc
- DLT_RAWAF_MASK = 0x2240000
- DLT_RIO = 0x7c
- DLT_SCCP = 0x8e
- DLT_SITA = 0xc4
- DLT_SLIP = 0x8
- DLT_SLIP_BSDOS = 0xd
- DLT_SUNATM = 0x7b
- DLT_SYMANTEC_FIREWALL = 0x63
- DLT_TZSP = 0x80
- DLT_USB = 0xba
- DLT_USB_LINUX = 0xbd
- DLT_USB_LINUX_MMAPPED = 0xdc
- DLT_WIHART = 0xdf
- DLT_X2E_SERIAL = 0xd5
- DLT_X2E_XORAYA = 0xd6
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x40
- ECHOE = 0x2
- ECHOK = 0x4
- ECHOKE = 0x1
- ECHONL = 0x10
- ECHOPRT = 0x20
- EMUL_LINUX = 0x1
- EMUL_LINUX32 = 0x5
- EMUL_MAXID = 0x6
- ETHERCAP_JUMBO_MTU = 0x4
- ETHERCAP_VLAN_HWTAGGING = 0x2
- ETHERCAP_VLAN_MTU = 0x1
- ETHERMIN = 0x2e
- ETHERMTU = 0x5dc
- ETHERMTU_JUMBO = 0x2328
- ETHERTYPE_8023 = 0x4
- ETHERTYPE_AARP = 0x80f3
- ETHERTYPE_ACCTON = 0x8390
- ETHERTYPE_AEONIC = 0x8036
- ETHERTYPE_ALPHA = 0x814a
- ETHERTYPE_AMBER = 0x6008
- ETHERTYPE_AMOEBA = 0x8145
- ETHERTYPE_APOLLO = 0x80f7
- ETHERTYPE_APOLLODOMAIN = 0x8019
- ETHERTYPE_APPLETALK = 0x809b
- ETHERTYPE_APPLITEK = 0x80c7
- ETHERTYPE_ARGONAUT = 0x803a
- ETHERTYPE_ARP = 0x806
- ETHERTYPE_AT = 0x809b
- ETHERTYPE_ATALK = 0x809b
- ETHERTYPE_ATOMIC = 0x86df
- ETHERTYPE_ATT = 0x8069
- ETHERTYPE_ATTSTANFORD = 0x8008
- ETHERTYPE_AUTOPHON = 0x806a
- ETHERTYPE_AXIS = 0x8856
- ETHERTYPE_BCLOOP = 0x9003
- ETHERTYPE_BOFL = 0x8102
- ETHERTYPE_CABLETRON = 0x7034
- ETHERTYPE_CHAOS = 0x804
- ETHERTYPE_COMDESIGN = 0x806c
- ETHERTYPE_COMPUGRAPHIC = 0x806d
- ETHERTYPE_COUNTERPOINT = 0x8062
- ETHERTYPE_CRONUS = 0x8004
- ETHERTYPE_CRONUSVLN = 0x8003
- ETHERTYPE_DCA = 0x1234
- ETHERTYPE_DDE = 0x807b
- ETHERTYPE_DEBNI = 0xaaaa
- ETHERTYPE_DECAM = 0x8048
- ETHERTYPE_DECCUST = 0x6006
- ETHERTYPE_DECDIAG = 0x6005
- ETHERTYPE_DECDNS = 0x803c
- ETHERTYPE_DECDTS = 0x803e
- ETHERTYPE_DECEXPER = 0x6000
- ETHERTYPE_DECLAST = 0x8041
- ETHERTYPE_DECLTM = 0x803f
- ETHERTYPE_DECMUMPS = 0x6009
- ETHERTYPE_DECNETBIOS = 0x8040
- ETHERTYPE_DELTACON = 0x86de
- ETHERTYPE_DIDDLE = 0x4321
- ETHERTYPE_DLOG1 = 0x660
- ETHERTYPE_DLOG2 = 0x661
- ETHERTYPE_DN = 0x6003
- ETHERTYPE_DOGFIGHT = 0x1989
- ETHERTYPE_DSMD = 0x8039
- ETHERTYPE_ECMA = 0x803
- ETHERTYPE_ENCRYPT = 0x803d
- ETHERTYPE_ES = 0x805d
- ETHERTYPE_EXCELAN = 0x8010
- ETHERTYPE_EXPERDATA = 0x8049
- ETHERTYPE_FLIP = 0x8146
- ETHERTYPE_FLOWCONTROL = 0x8808
- ETHERTYPE_FRARP = 0x808
- ETHERTYPE_GENDYN = 0x8068
- ETHERTYPE_HAYES = 0x8130
- ETHERTYPE_HIPPI_FP = 0x8180
- ETHERTYPE_HITACHI = 0x8820
- ETHERTYPE_HP = 0x8005
- ETHERTYPE_IEEEPUP = 0xa00
- ETHERTYPE_IEEEPUPAT = 0xa01
- ETHERTYPE_IMLBL = 0x4c42
- ETHERTYPE_IMLBLDIAG = 0x424c
- ETHERTYPE_IP = 0x800
- ETHERTYPE_IPAS = 0x876c
- ETHERTYPE_IPV6 = 0x86dd
- ETHERTYPE_IPX = 0x8137
- ETHERTYPE_IPXNEW = 0x8037
- ETHERTYPE_KALPANA = 0x8582
- ETHERTYPE_LANBRIDGE = 0x8038
- ETHERTYPE_LANPROBE = 0x8888
- ETHERTYPE_LAT = 0x6004
- ETHERTYPE_LBACK = 0x9000
- ETHERTYPE_LITTLE = 0x8060
- ETHERTYPE_LOGICRAFT = 0x8148
- ETHERTYPE_LOOPBACK = 0x9000
- ETHERTYPE_MATRA = 0x807a
- ETHERTYPE_MAX = 0xffff
- ETHERTYPE_MERIT = 0x807c
- ETHERTYPE_MICP = 0x873a
- ETHERTYPE_MOPDL = 0x6001
- ETHERTYPE_MOPRC = 0x6002
- ETHERTYPE_MOTOROLA = 0x818d
- ETHERTYPE_MPLS = 0x8847
- ETHERTYPE_MPLS_MCAST = 0x8848
- ETHERTYPE_MUMPS = 0x813f
- ETHERTYPE_NBPCC = 0x3c04
- ETHERTYPE_NBPCLAIM = 0x3c09
- ETHERTYPE_NBPCLREQ = 0x3c05
- ETHERTYPE_NBPCLRSP = 0x3c06
- ETHERTYPE_NBPCREQ = 0x3c02
- ETHERTYPE_NBPCRSP = 0x3c03
- ETHERTYPE_NBPDG = 0x3c07
- ETHERTYPE_NBPDGB = 0x3c08
- ETHERTYPE_NBPDLTE = 0x3c0a
- ETHERTYPE_NBPRAR = 0x3c0c
- ETHERTYPE_NBPRAS = 0x3c0b
- ETHERTYPE_NBPRST = 0x3c0d
- ETHERTYPE_NBPSCD = 0x3c01
- ETHERTYPE_NBPVCD = 0x3c00
- ETHERTYPE_NBS = 0x802
- ETHERTYPE_NCD = 0x8149
- ETHERTYPE_NESTAR = 0x8006
- ETHERTYPE_NETBEUI = 0x8191
- ETHERTYPE_NOVELL = 0x8138
- ETHERTYPE_NS = 0x600
- ETHERTYPE_NSAT = 0x601
- ETHERTYPE_NSCOMPAT = 0x807
- ETHERTYPE_NTRAILER = 0x10
- ETHERTYPE_OS9 = 0x7007
- ETHERTYPE_OS9NET = 0x7009
- ETHERTYPE_PACER = 0x80c6
- ETHERTYPE_PAE = 0x888e
- ETHERTYPE_PCS = 0x4242
- ETHERTYPE_PLANNING = 0x8044
- ETHERTYPE_PPP = 0x880b
- ETHERTYPE_PPPOE = 0x8864
- ETHERTYPE_PPPOEDISC = 0x8863
- ETHERTYPE_PRIMENTS = 0x7031
- ETHERTYPE_PUP = 0x200
- ETHERTYPE_PUPAT = 0x200
- ETHERTYPE_RACAL = 0x7030
- ETHERTYPE_RATIONAL = 0x8150
- ETHERTYPE_RAWFR = 0x6559
- ETHERTYPE_RCL = 0x1995
- ETHERTYPE_RDP = 0x8739
- ETHERTYPE_RETIX = 0x80f2
- ETHERTYPE_REVARP = 0x8035
- ETHERTYPE_SCA = 0x6007
- ETHERTYPE_SECTRA = 0x86db
- ETHERTYPE_SECUREDATA = 0x876d
- ETHERTYPE_SGITW = 0x817e
- ETHERTYPE_SG_BOUNCE = 0x8016
- ETHERTYPE_SG_DIAG = 0x8013
- ETHERTYPE_SG_NETGAMES = 0x8014
- ETHERTYPE_SG_RESV = 0x8015
- ETHERTYPE_SIMNET = 0x5208
- ETHERTYPE_SLOWPROTOCOLS = 0x8809
- ETHERTYPE_SNA = 0x80d5
- ETHERTYPE_SNMP = 0x814c
- ETHERTYPE_SONIX = 0xfaf5
- ETHERTYPE_SPIDER = 0x809f
- ETHERTYPE_SPRITE = 0x500
- ETHERTYPE_STP = 0x8181
- ETHERTYPE_TALARIS = 0x812b
- ETHERTYPE_TALARISMC = 0x852b
- ETHERTYPE_TCPCOMP = 0x876b
- ETHERTYPE_TCPSM = 0x9002
- ETHERTYPE_TEC = 0x814f
- ETHERTYPE_TIGAN = 0x802f
- ETHERTYPE_TRAIL = 0x1000
- ETHERTYPE_TRANSETHER = 0x6558
- ETHERTYPE_TYMSHARE = 0x802e
- ETHERTYPE_UBBST = 0x7005
- ETHERTYPE_UBDEBUG = 0x900
- ETHERTYPE_UBDIAGLOOP = 0x7002
- ETHERTYPE_UBDL = 0x7000
- ETHERTYPE_UBNIU = 0x7001
- ETHERTYPE_UBNMC = 0x7003
- ETHERTYPE_VALID = 0x1600
- ETHERTYPE_VARIAN = 0x80dd
- ETHERTYPE_VAXELN = 0x803b
- ETHERTYPE_VEECO = 0x8067
- ETHERTYPE_VEXP = 0x805b
- ETHERTYPE_VGLAB = 0x8131
- ETHERTYPE_VINES = 0xbad
- ETHERTYPE_VINESECHO = 0xbaf
- ETHERTYPE_VINESLOOP = 0xbae
- ETHERTYPE_VITAL = 0xff00
- ETHERTYPE_VLAN = 0x8100
- ETHERTYPE_VLTLMAN = 0x8080
- ETHERTYPE_VPROD = 0x805c
- ETHERTYPE_VURESERVED = 0x8147
- ETHERTYPE_WATERLOO = 0x8130
- ETHERTYPE_WELLFLEET = 0x8103
- ETHERTYPE_X25 = 0x805
- ETHERTYPE_X75 = 0x801
- ETHERTYPE_XNSSM = 0x9001
- ETHERTYPE_XTP = 0x817d
- ETHER_ADDR_LEN = 0x6
- ETHER_CRC_LEN = 0x4
- ETHER_CRC_POLY_BE = 0x4c11db6
- ETHER_CRC_POLY_LE = 0xedb88320
- ETHER_HDR_LEN = 0xe
- ETHER_MAX_LEN = 0x5ee
- ETHER_MAX_LEN_JUMBO = 0x233a
- ETHER_MIN_LEN = 0x40
- ETHER_PPPOE_ENCAP_LEN = 0x8
- ETHER_TYPE_LEN = 0x2
- ETHER_VLAN_ENCAP_LEN = 0x4
- EVFILT_AIO = 0x2
- EVFILT_PROC = 0x4
- EVFILT_READ = 0x0
- EVFILT_SIGNAL = 0x5
- EVFILT_SYSCOUNT = 0x7
- EVFILT_TIMER = 0x6
- EVFILT_VNODE = 0x3
- EVFILT_WRITE = 0x1
- EV_ADD = 0x1
- EV_CLEAR = 0x20
- EV_DELETE = 0x2
- EV_DISABLE = 0x8
- EV_ENABLE = 0x4
- EV_EOF = 0x8000
- EV_ERROR = 0x4000
- EV_FLAG1 = 0x2000
- EV_ONESHOT = 0x10
- EV_SYSFLAGS = 0xf000
- EXTA = 0x4b00
- EXTB = 0x9600
- EXTPROC = 0x800
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x100
- FLUSHO = 0x800000
- F_CLOSEM = 0xa
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0xc
- F_FSCTL = -0x80000000
- F_FSDIRMASK = 0x70000000
- F_FSIN = 0x10000000
- F_FSINOUT = 0x30000000
- F_FSOUT = 0x20000000
- F_FSPRIV = 0x8000
- F_FSVOID = 0x40000000
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLK = 0x7
- F_GETNOSIGPIPE = 0xd
- F_GETOWN = 0x5
- F_MAXFD = 0xb
- F_OK = 0x0
- F_PARAM_MASK = 0xfff
- F_PARAM_MAX = 0xfff
- F_RDLCK = 0x1
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLK = 0x8
- F_SETLKW = 0x9
- F_SETNOSIGPIPE = 0xe
- F_SETOWN = 0x6
- F_UNLCK = 0x2
- F_WRLCK = 0x3
- HUPCL = 0x4000
- ICANON = 0x100
- ICMP6_FILTER = 0x12
- ICRNL = 0x100
- IEXTEN = 0x400
- IFAN_ARRIVAL = 0x0
- IFAN_DEPARTURE = 0x1
- IFA_ROUTE = 0x1
- IFF_ALLMULTI = 0x200
- IFF_BROADCAST = 0x2
- IFF_CANTCHANGE = 0x8f52
- IFF_DEBUG = 0x4
- IFF_LINK0 = 0x1000
- IFF_LINK1 = 0x2000
- IFF_LINK2 = 0x4000
- IFF_LOOPBACK = 0x8
- IFF_MULTICAST = 0x8000
- IFF_NOARP = 0x80
- IFF_NOTRAILERS = 0x20
- IFF_OACTIVE = 0x400
- IFF_POINTOPOINT = 0x10
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SIMPLEX = 0x800
- IFF_UP = 0x1
- IFNAMSIZ = 0x10
- IFT_1822 = 0x2
- IFT_A12MPPSWITCH = 0x82
- IFT_AAL2 = 0xbb
- IFT_AAL5 = 0x31
- IFT_ADSL = 0x5e
- IFT_AFLANE8023 = 0x3b
- IFT_AFLANE8025 = 0x3c
- IFT_ARAP = 0x58
- IFT_ARCNET = 0x23
- IFT_ARCNETPLUS = 0x24
- IFT_ASYNC = 0x54
- IFT_ATM = 0x25
- IFT_ATMDXI = 0x69
- IFT_ATMFUNI = 0x6a
- IFT_ATMIMA = 0x6b
- IFT_ATMLOGICAL = 0x50
- IFT_ATMRADIO = 0xbd
- IFT_ATMSUBINTERFACE = 0x86
- IFT_ATMVCIENDPT = 0xc2
- IFT_ATMVIRTUAL = 0x95
- IFT_BGPPOLICYACCOUNTING = 0xa2
- IFT_BRIDGE = 0xd1
- IFT_BSC = 0x53
- IFT_CARP = 0xf8
- IFT_CCTEMUL = 0x3d
- IFT_CEPT = 0x13
- IFT_CES = 0x85
- IFT_CHANNEL = 0x46
- IFT_CNR = 0x55
- IFT_COFFEE = 0x84
- IFT_COMPOSITELINK = 0x9b
- IFT_DCN = 0x8d
- IFT_DIGITALPOWERLINE = 0x8a
- IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
- IFT_DLSW = 0x4a
- IFT_DOCSCABLEDOWNSTREAM = 0x80
- IFT_DOCSCABLEMACLAYER = 0x7f
- IFT_DOCSCABLEUPSTREAM = 0x81
- IFT_DOCSCABLEUPSTREAMCHANNEL = 0xcd
- IFT_DS0 = 0x51
- IFT_DS0BUNDLE = 0x52
- IFT_DS1FDL = 0xaa
- IFT_DS3 = 0x1e
- IFT_DTM = 0x8c
- IFT_DVBASILN = 0xac
- IFT_DVBASIOUT = 0xad
- IFT_DVBRCCDOWNSTREAM = 0x93
- IFT_DVBRCCMACLAYER = 0x92
- IFT_DVBRCCUPSTREAM = 0x94
- IFT_ECONET = 0xce
- IFT_EON = 0x19
- IFT_EPLRS = 0x57
- IFT_ESCON = 0x49
- IFT_ETHER = 0x6
- IFT_FAITH = 0xf2
- IFT_FAST = 0x7d
- IFT_FASTETHER = 0x3e
- IFT_FASTETHERFX = 0x45
- IFT_FDDI = 0xf
- IFT_FIBRECHANNEL = 0x38
- IFT_FRAMERELAYINTERCONNECT = 0x3a
- IFT_FRAMERELAYMPI = 0x5c
- IFT_FRDLCIENDPT = 0xc1
- IFT_FRELAY = 0x20
- IFT_FRELAYDCE = 0x2c
- IFT_FRF16MFRBUNDLE = 0xa3
- IFT_FRFORWARD = 0x9e
- IFT_G703AT2MB = 0x43
- IFT_G703AT64K = 0x42
- IFT_GIF = 0xf0
- IFT_GIGABITETHERNET = 0x75
- IFT_GR303IDT = 0xb2
- IFT_GR303RDT = 0xb1
- IFT_H323GATEKEEPER = 0xa4
- IFT_H323PROXY = 0xa5
- IFT_HDH1822 = 0x3
- IFT_HDLC = 0x76
- IFT_HDSL2 = 0xa8
- IFT_HIPERLAN2 = 0xb7
- IFT_HIPPI = 0x2f
- IFT_HIPPIINTERFACE = 0x39
- IFT_HOSTPAD = 0x5a
- IFT_HSSI = 0x2e
- IFT_HY = 0xe
- IFT_IBM370PARCHAN = 0x48
- IFT_IDSL = 0x9a
- IFT_IEEE1394 = 0x90
- IFT_IEEE80211 = 0x47
- IFT_IEEE80212 = 0x37
- IFT_IEEE8023ADLAG = 0xa1
- IFT_IFGSN = 0x91
- IFT_IMT = 0xbe
- IFT_INFINIBAND = 0xc7
- IFT_INTERLEAVE = 0x7c
- IFT_IP = 0x7e
- IFT_IPFORWARD = 0x8e
- IFT_IPOVERATM = 0x72
- IFT_IPOVERCDLC = 0x6d
- IFT_IPOVERCLAW = 0x6e
- IFT_IPSWITCH = 0x4e
- IFT_ISDN = 0x3f
- IFT_ISDNBASIC = 0x14
- IFT_ISDNPRIMARY = 0x15
- IFT_ISDNS = 0x4b
- IFT_ISDNU = 0x4c
- IFT_ISO88022LLC = 0x29
- IFT_ISO88023 = 0x7
- IFT_ISO88024 = 0x8
- IFT_ISO88025 = 0x9
- IFT_ISO88025CRFPINT = 0x62
- IFT_ISO88025DTR = 0x56
- IFT_ISO88025FIBER = 0x73
- IFT_ISO88026 = 0xa
- IFT_ISUP = 0xb3
- IFT_L2VLAN = 0x87
- IFT_L3IPVLAN = 0x88
- IFT_L3IPXVLAN = 0x89
- IFT_LAPB = 0x10
- IFT_LAPD = 0x4d
- IFT_LAPF = 0x77
- IFT_LINEGROUP = 0xd2
- IFT_LOCALTALK = 0x2a
- IFT_LOOP = 0x18
- IFT_MEDIAMAILOVERIP = 0x8b
- IFT_MFSIGLINK = 0xa7
- IFT_MIOX25 = 0x26
- IFT_MODEM = 0x30
- IFT_MPC = 0x71
- IFT_MPLS = 0xa6
- IFT_MPLSTUNNEL = 0x96
- IFT_MSDSL = 0x8f
- IFT_MVL = 0xbf
- IFT_MYRINET = 0x63
- IFT_NFAS = 0xaf
- IFT_NSIP = 0x1b
- IFT_OPTICALCHANNEL = 0xc3
- IFT_OPTICALTRANSPORT = 0xc4
- IFT_OTHER = 0x1
- IFT_P10 = 0xc
- IFT_P80 = 0xd
- IFT_PARA = 0x22
- IFT_PFLOG = 0xf5
- IFT_PFSYNC = 0xf6
- IFT_PLC = 0xae
- IFT_PON155 = 0xcf
- IFT_PON622 = 0xd0
- IFT_POS = 0xab
- IFT_PPP = 0x17
- IFT_PPPMULTILINKBUNDLE = 0x6c
- IFT_PROPATM = 0xc5
- IFT_PROPBWAP2MP = 0xb8
- IFT_PROPCNLS = 0x59
- IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
- IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
- IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
- IFT_PROPMUX = 0x36
- IFT_PROPVIRTUAL = 0x35
- IFT_PROPWIRELESSP2P = 0x9d
- IFT_PTPSERIAL = 0x16
- IFT_PVC = 0xf1
- IFT_Q2931 = 0xc9
- IFT_QLLC = 0x44
- IFT_RADIOMAC = 0xbc
- IFT_RADSL = 0x5f
- IFT_REACHDSL = 0xc0
- IFT_RFC1483 = 0x9f
- IFT_RS232 = 0x21
- IFT_RSRB = 0x4f
- IFT_SDLC = 0x11
- IFT_SDSL = 0x60
- IFT_SHDSL = 0xa9
- IFT_SIP = 0x1f
- IFT_SIPSIG = 0xcc
- IFT_SIPTG = 0xcb
- IFT_SLIP = 0x1c
- IFT_SMDSDXI = 0x2b
- IFT_SMDSICIP = 0x34
- IFT_SONET = 0x27
- IFT_SONETOVERHEADCHANNEL = 0xb9
- IFT_SONETPATH = 0x32
- IFT_SONETVT = 0x33
- IFT_SRP = 0x97
- IFT_SS7SIGLINK = 0x9c
- IFT_STACKTOSTACK = 0x6f
- IFT_STARLAN = 0xb
- IFT_STF = 0xd7
- IFT_T1 = 0x12
- IFT_TDLC = 0x74
- IFT_TELINK = 0xc8
- IFT_TERMPAD = 0x5b
- IFT_TR008 = 0xb0
- IFT_TRANSPHDLC = 0x7b
- IFT_TUNNEL = 0x83
- IFT_ULTRA = 0x1d
- IFT_USB = 0xa0
- IFT_V11 = 0x40
- IFT_V35 = 0x2d
- IFT_V36 = 0x41
- IFT_V37 = 0x78
- IFT_VDSL = 0x61
- IFT_VIRTUALIPADDRESS = 0x70
- IFT_VIRTUALTG = 0xca
- IFT_VOICEDID = 0xd5
- IFT_VOICEEM = 0x64
- IFT_VOICEEMFGD = 0xd3
- IFT_VOICEENCAP = 0x67
- IFT_VOICEFGDEANA = 0xd4
- IFT_VOICEFXO = 0x65
- IFT_VOICEFXS = 0x66
- IFT_VOICEOVERATM = 0x98
- IFT_VOICEOVERCABLE = 0xc6
- IFT_VOICEOVERFRAMERELAY = 0x99
- IFT_VOICEOVERIP = 0x68
- IFT_X213 = 0x5d
- IFT_X25 = 0x5
- IFT_X25DDN = 0x4
- IFT_X25HUNTGROUP = 0x7a
- IFT_X25MLP = 0x79
- IFT_X25PLE = 0x28
- IFT_XETHER = 0x1a
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLASSD_HOST = 0xfffffff
- IN_CLASSD_NET = 0xf0000000
- IN_CLASSD_NSHIFT = 0x1c
- IN_LOOPBACKNET = 0x7f
- IPPROTO_AH = 0x33
- IPPROTO_CARP = 0x70
- IPPROTO_DONE = 0x101
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_ENCAP = 0x62
- IPPROTO_EON = 0x50
- IPPROTO_ESP = 0x32
- IPPROTO_ETHERIP = 0x61
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GGP = 0x3
- IPPROTO_GRE = 0x2f
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IGMP = 0x2
- IPPROTO_IP = 0x0
- IPPROTO_IPCOMP = 0x6c
- IPPROTO_IPIP = 0x4
- IPPROTO_IPV4 = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_IPV6_ICMP = 0x3a
- IPPROTO_MAX = 0x100
- IPPROTO_MAXID = 0x34
- IPPROTO_MOBILE = 0x37
- IPPROTO_NONE = 0x3b
- IPPROTO_PFSYNC = 0xf0
- IPPROTO_PIM = 0x67
- IPPROTO_PUP = 0xc
- IPPROTO_RAW = 0xff
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_UDP = 0x11
- IPPROTO_VRRP = 0x70
- IPV6_CHECKSUM = 0x1a
- IPV6_DEFAULT_MULTICAST_HOPS = 0x1
- IPV6_DEFAULT_MULTICAST_LOOP = 0x1
- IPV6_DEFHLIM = 0x40
- IPV6_DONTFRAG = 0x3e
- IPV6_DSTOPTS = 0x32
- IPV6_FAITH = 0x1d
- IPV6_FLOWINFO_MASK = 0xffffff0f
- IPV6_FLOWLABEL_MASK = 0xffff0f00
- IPV6_FRAGTTL = 0x78
- IPV6_HLIMDEC = 0x1
- IPV6_HOPLIMIT = 0x2f
- IPV6_HOPOPTS = 0x31
- IPV6_IPSEC_POLICY = 0x1c
- IPV6_JOIN_GROUP = 0xc
- IPV6_LEAVE_GROUP = 0xd
- IPV6_MAXHLIM = 0xff
- IPV6_MAXPACKET = 0xffff
- IPV6_MMTU = 0x500
- IPV6_MULTICAST_HOPS = 0xa
- IPV6_MULTICAST_IF = 0x9
- IPV6_MULTICAST_LOOP = 0xb
- IPV6_NEXTHOP = 0x30
- IPV6_PATHMTU = 0x2c
- IPV6_PKTINFO = 0x2e
- IPV6_PORTRANGE = 0xe
- IPV6_PORTRANGE_DEFAULT = 0x0
- IPV6_PORTRANGE_HIGH = 0x1
- IPV6_PORTRANGE_LOW = 0x2
- IPV6_RECVDSTOPTS = 0x28
- IPV6_RECVHOPLIMIT = 0x25
- IPV6_RECVHOPOPTS = 0x27
- IPV6_RECVPATHMTU = 0x2b
- IPV6_RECVPKTINFO = 0x24
- IPV6_RECVRTHDR = 0x26
- IPV6_RECVTCLASS = 0x39
- IPV6_RTHDR = 0x33
- IPV6_RTHDRDSTOPTS = 0x23
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_SOCKOPT_RESERVED1 = 0x3
- IPV6_TCLASS = 0x3d
- IPV6_UNICAST_HOPS = 0x4
- IPV6_USE_MIN_MTU = 0x2a
- IPV6_V6ONLY = 0x1b
- IPV6_VERSION = 0x60
- IPV6_VERSION_MASK = 0xf0
- IP_ADD_MEMBERSHIP = 0xc
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0xd
- IP_EF = 0x8000
- IP_ERRORMTU = 0x15
- IP_HDRINCL = 0x2
- IP_IPSEC_POLICY = 0x16
- IP_MAXPACKET = 0xffff
- IP_MAX_MEMBERSHIPS = 0x14
- IP_MF = 0x2000
- IP_MINFRAGSIZE = 0x45
- IP_MINTTL = 0x18
- IP_MSS = 0x240
- IP_MULTICAST_IF = 0x9
- IP_MULTICAST_LOOP = 0xb
- IP_MULTICAST_TTL = 0xa
- IP_OFFMASK = 0x1fff
- IP_OPTIONS = 0x1
- IP_PORTRANGE = 0x13
- IP_PORTRANGE_DEFAULT = 0x0
- IP_PORTRANGE_HIGH = 0x1
- IP_PORTRANGE_LOW = 0x2
- IP_RECVDSTADDR = 0x7
- IP_RECVIF = 0x14
- IP_RECVOPTS = 0x5
- IP_RECVRETOPTS = 0x6
- IP_RECVTTL = 0x17
- IP_RETOPTS = 0x8
- IP_RF = 0x8000
- IP_TOS = 0x3
- IP_TTL = 0x4
- ISIG = 0x80
- ISTRIP = 0x20
- IXANY = 0x800
- IXOFF = 0x400
- IXON = 0x200
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_DONTNEED = 0x4
- MADV_FREE = 0x6
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_SEQUENTIAL = 0x2
- MADV_SPACEAVAIL = 0x5
- MADV_WILLNEED = 0x3
- MAP_ALIGNMENT_16MB = 0x18000000
- MAP_ALIGNMENT_1TB = 0x28000000
- MAP_ALIGNMENT_256TB = 0x30000000
- MAP_ALIGNMENT_4GB = 0x20000000
- MAP_ALIGNMENT_64KB = 0x10000000
- MAP_ALIGNMENT_64PB = 0x38000000
- MAP_ALIGNMENT_MASK = -0x1000000
- MAP_ALIGNMENT_SHIFT = 0x18
- MAP_ANON = 0x1000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_HASSEMAPHORE = 0x200
- MAP_INHERIT = 0x80
- MAP_INHERIT_COPY = 0x1
- MAP_INHERIT_DEFAULT = 0x1
- MAP_INHERIT_DONATE_COPY = 0x3
- MAP_INHERIT_NONE = 0x2
- MAP_INHERIT_SHARE = 0x0
- MAP_NORESERVE = 0x40
- MAP_PRIVATE = 0x2
- MAP_RENAME = 0x20
- MAP_SHARED = 0x1
- MAP_STACK = 0x2000
- MAP_TRYFIXED = 0x400
- MAP_WIRED = 0x800
- MSG_BCAST = 0x100
- MSG_CMSG_CLOEXEC = 0x800
- MSG_CONTROLMBUF = 0x2000000
- MSG_CTRUNC = 0x20
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x80
- MSG_EOR = 0x8
- MSG_IOVUSRSPACE = 0x4000000
- MSG_LENUSRSPACE = 0x8000000
- MSG_MCAST = 0x200
- MSG_NAMEMBUF = 0x1000000
- MSG_NBIO = 0x1000
- MSG_NOSIGNAL = 0x400
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_TRUNC = 0x10
- MSG_USERFLAGS = 0xffffff
- MSG_WAITALL = 0x40
- NAME_MAX = 0x1ff
- NET_RT_DUMP = 0x1
- NET_RT_FLAGS = 0x2
- NET_RT_IFLIST = 0x5
- NET_RT_MAXID = 0x6
- NET_RT_OIFLIST = 0x4
- NET_RT_OOIFLIST = 0x3
- NOFLSH = 0x80000000
- NOTE_ATTRIB = 0x8
- NOTE_CHILD = 0x4
- NOTE_DELETE = 0x1
- NOTE_EXEC = 0x20000000
- NOTE_EXIT = 0x80000000
- NOTE_EXTEND = 0x4
- NOTE_FORK = 0x40000000
- NOTE_LINK = 0x10
- NOTE_LOWAT = 0x1
- NOTE_PCTRLMASK = 0xf0000000
- NOTE_PDATAMASK = 0xfffff
- NOTE_RENAME = 0x20
- NOTE_REVOKE = 0x40
- NOTE_TRACK = 0x1
- NOTE_TRACKERR = 0x2
- NOTE_WRITE = 0x2
- OCRNL = 0x10
- OFIOGETBMAP = 0xc004667a
- ONLCR = 0x2
- ONLRET = 0x40
- ONOCR = 0x20
- ONOEOT = 0x8
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_ALT_IO = 0x40000
- O_APPEND = 0x8
- O_ASYNC = 0x40
- O_CLOEXEC = 0x400000
- O_CREAT = 0x200
- O_DIRECT = 0x80000
- O_DIRECTORY = 0x200000
- O_DSYNC = 0x10000
- O_EXCL = 0x800
- O_EXLOCK = 0x20
- O_FSYNC = 0x80
- O_NDELAY = 0x4
- O_NOCTTY = 0x8000
- O_NOFOLLOW = 0x100
- O_NONBLOCK = 0x4
- O_NOSIGPIPE = 0x1000000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_RSYNC = 0x20000
- O_SHLOCK = 0x10
- O_SYNC = 0x80
- O_TRUNC = 0x400
- O_WRONLY = 0x1
- PARENB = 0x1000
- PARMRK = 0x8
- PARODD = 0x2000
- PENDIN = 0x20000000
- PROT_EXEC = 0x4
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- PRI_IOFLUSH = 0x7c
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- RLIMIT_AS = 0xa
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x8
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = 0x7fffffffffffffff
- RTAX_AUTHOR = 0x6
- RTAX_BRD = 0x7
- RTAX_DST = 0x0
- RTAX_GATEWAY = 0x1
- RTAX_GENMASK = 0x3
- RTAX_IFA = 0x5
- RTAX_IFP = 0x4
- RTAX_MAX = 0x9
- RTAX_NETMASK = 0x2
- RTAX_TAG = 0x8
- RTA_AUTHOR = 0x40
- RTA_BRD = 0x80
- RTA_DST = 0x1
- RTA_GATEWAY = 0x2
- RTA_GENMASK = 0x8
- RTA_IFA = 0x20
- RTA_IFP = 0x10
- RTA_NETMASK = 0x4
- RTA_TAG = 0x100
- RTF_ANNOUNCE = 0x20000
- RTF_BLACKHOLE = 0x1000
- RTF_CLONED = 0x2000
- RTF_CLONING = 0x100
- RTF_DONE = 0x40
- RTF_DYNAMIC = 0x10
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_LLINFO = 0x400
- RTF_MASK = 0x80
- RTF_MODIFIED = 0x20
- RTF_PROTO1 = 0x8000
- RTF_PROTO2 = 0x4000
- RTF_REJECT = 0x8
- RTF_SRC = 0x10000
- RTF_STATIC = 0x800
- RTF_UP = 0x1
- RTF_XRESOLVE = 0x200
- RTM_ADD = 0x1
- RTM_CHANGE = 0x3
- RTM_CHGADDR = 0x15
- RTM_DELADDR = 0xd
- RTM_DELETE = 0x2
- RTM_GET = 0x4
- RTM_IEEE80211 = 0x11
- RTM_IFANNOUNCE = 0x10
- RTM_IFINFO = 0x14
- RTM_LLINFO_UPD = 0x13
- RTM_LOCK = 0x8
- RTM_LOSING = 0x5
- RTM_MISS = 0x7
- RTM_NEWADDR = 0xc
- RTM_OIFINFO = 0xf
- RTM_OLDADD = 0x9
- RTM_OLDDEL = 0xa
- RTM_OOIFINFO = 0xe
- RTM_REDIRECT = 0x6
- RTM_RESOLVE = 0xb
- RTM_RTTUNIT = 0xf4240
- RTM_SETGATE = 0x12
- RTM_VERSION = 0x4
- RTV_EXPIRE = 0x4
- RTV_HOPCOUNT = 0x2
- RTV_MTU = 0x1
- RTV_RPIPE = 0x8
- RTV_RTT = 0x40
- RTV_RTTVAR = 0x80
- RTV_SPIPE = 0x10
- RTV_SSTHRESH = 0x20
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- SCM_CREDS = 0x4
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x8
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDMULTI = 0x80906931
- SIOCADDRT = 0x8030720a
- SIOCAIFADDR = 0x8040691a
- SIOCALIFADDR = 0x8118691c
- SIOCATMARK = 0x40047307
- SIOCDELMULTI = 0x80906932
- SIOCDELRT = 0x8030720b
- SIOCDIFADDR = 0x80906919
- SIOCDIFPHYADDR = 0x80906949
- SIOCDLIFADDR = 0x8118691e
- SIOCGDRVSPEC = 0xc01c697b
- SIOCGETPFSYNC = 0xc09069f8
- SIOCGETSGCNT = 0xc0147534
- SIOCGETVIFCNT = 0xc0147533
- SIOCGHIWAT = 0x40047301
- SIOCGIFADDR = 0xc0906921
- SIOCGIFADDRPREF = 0xc0946920
- SIOCGIFALIAS = 0xc040691b
- SIOCGIFBRDADDR = 0xc0906923
- SIOCGIFCAP = 0xc0206976
- SIOCGIFCONF = 0xc0086926
- SIOCGIFDATA = 0xc0946985
- SIOCGIFDLT = 0xc0906977
- SIOCGIFDSTADDR = 0xc0906922
- SIOCGIFFLAGS = 0xc0906911
- SIOCGIFGENERIC = 0xc090693a
- SIOCGIFMEDIA = 0xc0286936
- SIOCGIFMETRIC = 0xc0906917
- SIOCGIFMTU = 0xc090697e
- SIOCGIFNETMASK = 0xc0906925
- SIOCGIFPDSTADDR = 0xc0906948
- SIOCGIFPSRCADDR = 0xc0906947
- SIOCGLIFADDR = 0xc118691d
- SIOCGLIFPHYADDR = 0xc118694b
- SIOCGLINKSTR = 0xc01c6987
- SIOCGLOWAT = 0x40047303
- SIOCGPGRP = 0x40047309
- SIOCGVH = 0xc0906983
- SIOCIFCREATE = 0x8090697a
- SIOCIFDESTROY = 0x80906979
- SIOCIFGCLONERS = 0xc00c6978
- SIOCINITIFADDR = 0xc0446984
- SIOCSDRVSPEC = 0x801c697b
- SIOCSETPFSYNC = 0x809069f7
- SIOCSHIWAT = 0x80047300
- SIOCSIFADDR = 0x8090690c
- SIOCSIFADDRPREF = 0x8094691f
- SIOCSIFBRDADDR = 0x80906913
- SIOCSIFCAP = 0x80206975
- SIOCSIFDSTADDR = 0x8090690e
- SIOCSIFFLAGS = 0x80906910
- SIOCSIFGENERIC = 0x80906939
- SIOCSIFMEDIA = 0xc0906935
- SIOCSIFMETRIC = 0x80906918
- SIOCSIFMTU = 0x8090697f
- SIOCSIFNETMASK = 0x80906916
- SIOCSIFPHYADDR = 0x80406946
- SIOCSLIFPHYADDR = 0x8118694a
- SIOCSLINKSTR = 0x801c6988
- SIOCSLOWAT = 0x80047302
- SIOCSPGRP = 0x80047308
- SIOCSVH = 0xc0906982
- SIOCZIFDATA = 0xc0946986
- SOCK_CLOEXEC = 0x10000000
- SOCK_DGRAM = 0x2
- SOCK_FLAGS_MASK = 0xf0000000
- SOCK_NONBLOCK = 0x20000000
- SOCK_NOSIGPIPE = 0x40000000
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_SOCKET = 0xffff
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x2
- SO_ACCEPTFILTER = 0x1000
- SO_BROADCAST = 0x20
- SO_DEBUG = 0x1
- SO_DONTROUTE = 0x10
- SO_ERROR = 0x1007
- SO_KEEPALIVE = 0x8
- SO_LINGER = 0x80
- SO_NOHEADER = 0x100a
- SO_NOSIGPIPE = 0x800
- SO_OOBINLINE = 0x100
- SO_OVERFLOWED = 0x1009
- SO_RCVBUF = 0x1002
- SO_RCVLOWAT = 0x1004
- SO_RCVTIMEO = 0x100c
- SO_REUSEADDR = 0x4
- SO_REUSEPORT = 0x200
- SO_SNDBUF = 0x1001
- SO_SNDLOWAT = 0x1003
- SO_SNDTIMEO = 0x100b
- SO_TIMESTAMP = 0x2000
- SO_TYPE = 0x1008
- SO_USELOOPBACK = 0x40
- SYSCTL_VERSION = 0x1000000
- SYSCTL_VERS_0 = 0x0
- SYSCTL_VERS_1 = 0x1000000
- SYSCTL_VERS_MASK = 0xff000000
- S_ARCH1 = 0x10000
- S_ARCH2 = 0x20000
- S_BLKSIZE = 0x200
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IFWHT = 0xe000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISTXT = 0x200
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TCIFLUSH = 0x1
- TCIOFLUSH = 0x3
- TCOFLUSH = 0x2
- TCP_CONGCTL = 0x20
- TCP_KEEPCNT = 0x6
- TCP_KEEPIDLE = 0x3
- TCP_KEEPINIT = 0x7
- TCP_KEEPINTVL = 0x5
- TCP_MAXBURST = 0x4
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0x10
- TCP_MINMSS = 0xd8
- TCP_MSS = 0x218
- TCP_NODELAY = 0x1
- TCSAFLUSH = 0x2
- TIOCCBRK = 0x2000747a
- TIOCCDTR = 0x20007478
- TIOCCONS = 0x80047462
- TIOCDCDTIMESTAMP = 0x400c7458
- TIOCDRAIN = 0x2000745e
- TIOCEXCL = 0x2000740d
- TIOCEXT = 0x80047460
- TIOCFLAG_CDTRCTS = 0x10
- TIOCFLAG_CLOCAL = 0x2
- TIOCFLAG_CRTSCTS = 0x4
- TIOCFLAG_MDMBUF = 0x8
- TIOCFLAG_SOFTCAR = 0x1
- TIOCFLUSH = 0x80047410
- TIOCGETA = 0x402c7413
- TIOCGETD = 0x4004741a
- TIOCGFLAGS = 0x4004745d
- TIOCGLINED = 0x40207442
- TIOCGPGRP = 0x40047477
- TIOCGQSIZE = 0x40047481
- TIOCGRANTPT = 0x20007447
- TIOCGSID = 0x40047463
- TIOCGSIZE = 0x40087468
- TIOCGWINSZ = 0x40087468
- TIOCMBIC = 0x8004746b
- TIOCMBIS = 0x8004746c
- TIOCMGET = 0x4004746a
- TIOCMSET = 0x8004746d
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x20007471
- TIOCNXCL = 0x2000740e
- TIOCOUTQ = 0x40047473
- TIOCPKT = 0x80047470
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCPTMGET = 0x48087446
- TIOCPTSNAME = 0x48087448
- TIOCRCVFRAME = 0x80047445
- TIOCREMOTE = 0x80047469
- TIOCSBRK = 0x2000747b
- TIOCSCTTY = 0x20007461
- TIOCSDTR = 0x20007479
- TIOCSETA = 0x802c7414
- TIOCSETAF = 0x802c7416
- TIOCSETAW = 0x802c7415
- TIOCSETD = 0x8004741b
- TIOCSFLAGS = 0x8004745c
- TIOCSIG = 0x2000745f
- TIOCSLINED = 0x80207443
- TIOCSPGRP = 0x80047476
- TIOCSQSIZE = 0x80047480
- TIOCSSIZE = 0x80087467
- TIOCSTART = 0x2000746e
- TIOCSTAT = 0x80047465
- TIOCSTI = 0x80017472
- TIOCSTOP = 0x2000746f
- TIOCSWINSZ = 0x80087467
- TIOCUCNTL = 0x80047466
- TIOCXMTFRAME = 0x80047444
- TOSTOP = 0x400000
- VDISCARD = 0xf
- VDSUSP = 0xb
- VEOF = 0x0
- VEOL = 0x1
- VEOL2 = 0x2
- VERASE = 0x3
- VINTR = 0x8
- VKILL = 0x5
- VLNEXT = 0xe
- VMIN = 0x10
- VQUIT = 0x9
- VREPRINT = 0x6
- VSTART = 0xc
- VSTATUS = 0x12
- VSTOP = 0xd
- VSUSP = 0xa
- VTIME = 0x11
- VWERASE = 0x4
- WALL = 0x8
- WALLSIG = 0x8
- WALTSIG = 0x4
- WCLONE = 0x4
- WCOREFLAG = 0x80
- WNOHANG = 0x1
- WNOWAIT = 0x10000
- WNOZOMBIE = 0x20000
- WOPTSCHECKED = 0x40000
- WSTOPPED = 0x7f
- WUNTRACED = 0x2
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x30)
- EADDRNOTAVAIL = syscall.Errno(0x31)
- EAFNOSUPPORT = syscall.Errno(0x2f)
- EAGAIN = syscall.Errno(0x23)
- EALREADY = syscall.Errno(0x25)
- EAUTH = syscall.Errno(0x50)
- EBADF = syscall.Errno(0x9)
- EBADMSG = syscall.Errno(0x58)
- EBADRPC = syscall.Errno(0x48)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x57)
- ECHILD = syscall.Errno(0xa)
- ECONNABORTED = syscall.Errno(0x35)
- ECONNREFUSED = syscall.Errno(0x3d)
- ECONNRESET = syscall.Errno(0x36)
- EDEADLK = syscall.Errno(0xb)
- EDESTADDRREQ = syscall.Errno(0x27)
- EDOM = syscall.Errno(0x21)
- EDQUOT = syscall.Errno(0x45)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EFTYPE = syscall.Errno(0x4f)
- EHOSTDOWN = syscall.Errno(0x40)
- EHOSTUNREACH = syscall.Errno(0x41)
- EIDRM = syscall.Errno(0x52)
- EILSEQ = syscall.Errno(0x55)
- EINPROGRESS = syscall.Errno(0x24)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x38)
- EISDIR = syscall.Errno(0x15)
- ELAST = syscall.Errno(0x60)
- ELOOP = syscall.Errno(0x3e)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x28)
- EMULTIHOP = syscall.Errno(0x5e)
- ENAMETOOLONG = syscall.Errno(0x3f)
- ENEEDAUTH = syscall.Errno(0x51)
- ENETDOWN = syscall.Errno(0x32)
- ENETRESET = syscall.Errno(0x34)
- ENETUNREACH = syscall.Errno(0x33)
- ENFILE = syscall.Errno(0x17)
- ENOATTR = syscall.Errno(0x5d)
- ENOBUFS = syscall.Errno(0x37)
- ENODATA = syscall.Errno(0x59)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOLCK = syscall.Errno(0x4d)
- ENOLINK = syscall.Errno(0x5f)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x53)
- ENOPROTOOPT = syscall.Errno(0x2a)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x5a)
- ENOSTR = syscall.Errno(0x5b)
- ENOSYS = syscall.Errno(0x4e)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x39)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x42)
- ENOTSOCK = syscall.Errno(0x26)
- ENOTSUP = syscall.Errno(0x56)
- ENOTTY = syscall.Errno(0x19)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x2d)
- EOVERFLOW = syscall.Errno(0x54)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x2e)
- EPIPE = syscall.Errno(0x20)
- EPROCLIM = syscall.Errno(0x43)
- EPROCUNAVAIL = syscall.Errno(0x4c)
- EPROGMISMATCH = syscall.Errno(0x4b)
- EPROGUNAVAIL = syscall.Errno(0x4a)
- EPROTO = syscall.Errno(0x60)
- EPROTONOSUPPORT = syscall.Errno(0x2b)
- EPROTOTYPE = syscall.Errno(0x29)
- ERANGE = syscall.Errno(0x22)
- EREMOTE = syscall.Errno(0x47)
- EROFS = syscall.Errno(0x1e)
- ERPCMISMATCH = syscall.Errno(0x49)
- ESHUTDOWN = syscall.Errno(0x3a)
- ESOCKTNOSUPPORT = syscall.Errno(0x2c)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESTALE = syscall.Errno(0x46)
- ETIME = syscall.Errno(0x5c)
- ETIMEDOUT = syscall.Errno(0x3c)
- ETOOMANYREFS = syscall.Errno(0x3b)
- ETXTBSY = syscall.Errno(0x1a)
- EUSERS = syscall.Errno(0x44)
- EWOULDBLOCK = syscall.Errno(0x23)
- EXDEV = syscall.Errno(0x12)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0xa)
- SIGCHLD = syscall.Signal(0x14)
- SIGCONT = syscall.Signal(0x13)
- SIGEMT = syscall.Signal(0x7)
- SIGFPE = syscall.Signal(0x8)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINFO = syscall.Signal(0x1d)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x17)
- SIGIOT = syscall.Signal(0x6)
- SIGKILL = syscall.Signal(0x9)
- SIGPIPE = syscall.Signal(0xd)
- SIGPROF = syscall.Signal(0x1b)
- SIGPWR = syscall.Signal(0x20)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTOP = syscall.Signal(0x11)
- SIGSYS = syscall.Signal(0xc)
- SIGTERM = syscall.Signal(0xf)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x12)
- SIGTTIN = syscall.Signal(0x15)
- SIGTTOU = syscall.Signal(0x16)
- SIGURG = syscall.Signal(0x10)
- SIGUSR1 = syscall.Signal(0x1e)
- SIGUSR2 = syscall.Signal(0x1f)
- SIGVTALRM = syscall.Signal(0x1a)
- SIGWINCH = syscall.Signal(0x1c)
- SIGXCPU = syscall.Signal(0x18)
- SIGXFSZ = syscall.Signal(0x19)
-)
-
-// Error table
-var errors = [...]string{
- 1: "operation not permitted",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "input/output error",
- 6: "device not configured",
- 7: "argument list too long",
- 8: "exec format error",
- 9: "bad file descriptor",
- 10: "no child processes",
- 11: "resource deadlock avoided",
- 12: "cannot allocate memory",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device busy",
- 17: "file exists",
- 18: "cross-device link",
- 19: "operation not supported by device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "too many open files in system",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "numerical argument out of domain",
- 34: "result too large or too small",
- 35: "resource temporarily unavailable",
- 36: "operation now in progress",
- 37: "operation already in progress",
- 38: "socket operation on non-socket",
- 39: "destination address required",
- 40: "message too long",
- 41: "protocol wrong type for socket",
- 42: "protocol option not available",
- 43: "protocol not supported",
- 44: "socket type not supported",
- 45: "operation not supported",
- 46: "protocol family not supported",
- 47: "address family not supported by protocol family",
- 48: "address already in use",
- 49: "can't assign requested address",
- 50: "network is down",
- 51: "network is unreachable",
- 52: "network dropped connection on reset",
- 53: "software caused connection abort",
- 54: "connection reset by peer",
- 55: "no buffer space available",
- 56: "socket is already connected",
- 57: "socket is not connected",
- 58: "can't send after socket shutdown",
- 59: "too many references: can't splice",
- 60: "connection timed out",
- 61: "connection refused",
- 62: "too many levels of symbolic links",
- 63: "file name too long",
- 64: "host is down",
- 65: "no route to host",
- 66: "directory not empty",
- 67: "too many processes",
- 68: "too many users",
- 69: "disc quota exceeded",
- 70: "stale NFS file handle",
- 71: "too many levels of remote in path",
- 72: "RPC struct is bad",
- 73: "RPC version wrong",
- 74: "RPC prog. not avail",
- 75: "program version wrong",
- 76: "bad procedure for program",
- 77: "no locks available",
- 78: "function not implemented",
- 79: "inappropriate file type or format",
- 80: "authentication error",
- 81: "need authenticator",
- 82: "identifier removed",
- 83: "no message of desired type",
- 84: "value too large to be stored in data type",
- 85: "illegal byte sequence",
- 86: "not supported",
- 87: "operation Canceled",
- 88: "bad or Corrupt message",
- 89: "no message available",
- 90: "no STREAM resources",
- 91: "not a STREAM",
- 92: "STREAM ioctl timeout",
- 93: "attribute not found",
- 94: "multihop attempted",
- 95: "link has been severed",
- 96: "protocol error",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal instruction",
- 5: "trace/BPT trap",
- 6: "abort trap",
- 7: "EMT trap",
- 8: "floating point exception",
- 9: "killed",
- 10: "bus error",
- 11: "segmentation fault",
- 12: "bad system call",
- 13: "broken pipe",
- 14: "alarm clock",
- 15: "terminated",
- 16: "urgent I/O condition",
- 17: "stopped (signal)",
- 18: "stopped",
- 19: "continued",
- 20: "child exited",
- 21: "stopped (tty input)",
- 22: "stopped (tty output)",
- 23: "I/O possible",
- 24: "cputime limit exceeded",
- 25: "filesize limit exceeded",
- 26: "virtual timer expired",
- 27: "profiling timer expired",
- 28: "window size changes",
- 29: "information request",
- 30: "user defined signal 1",
- 31: "user defined signal 2",
- 32: "power fail/restart",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go b/newt/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go
deleted file mode 100644
index a08922b9..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go
+++ /dev/null
@@ -1,1436 +0,0 @@
-// mkerrors.sh -m64
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build amd64,solaris
-
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -m64 _const.go
-
-package unix
-
-import "syscall"
-
-const (
- AF_802 = 0x12
- AF_APPLETALK = 0x10
- AF_CCITT = 0xa
- AF_CHAOS = 0x5
- AF_DATAKIT = 0x9
- AF_DECnet = 0xc
- AF_DLI = 0xd
- AF_ECMA = 0x8
- AF_FILE = 0x1
- AF_GOSIP = 0x16
- AF_HYLINK = 0xf
- AF_IMPLINK = 0x3
- AF_INET = 0x2
- AF_INET6 = 0x1a
- AF_INET_OFFLOAD = 0x1e
- AF_IPX = 0x17
- AF_KEY = 0x1b
- AF_LAT = 0xe
- AF_LINK = 0x19
- AF_LOCAL = 0x1
- AF_MAX = 0x20
- AF_NBS = 0x7
- AF_NCA = 0x1c
- AF_NIT = 0x11
- AF_NS = 0x6
- AF_OSI = 0x13
- AF_OSINET = 0x15
- AF_PACKET = 0x20
- AF_POLICY = 0x1d
- AF_PUP = 0x4
- AF_ROUTE = 0x18
- AF_SNA = 0xb
- AF_TRILL = 0x1f
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_X25 = 0x14
- ARPHRD_ARCNET = 0x7
- ARPHRD_ATM = 0x10
- ARPHRD_AX25 = 0x3
- ARPHRD_CHAOS = 0x5
- ARPHRD_EETHER = 0x2
- ARPHRD_ETHER = 0x1
- ARPHRD_FC = 0x12
- ARPHRD_FRAME = 0xf
- ARPHRD_HDLC = 0x11
- ARPHRD_IB = 0x20
- ARPHRD_IEEE802 = 0x6
- ARPHRD_IPATM = 0x13
- ARPHRD_METRICOM = 0x17
- ARPHRD_TUNNEL = 0x1f
- B0 = 0x0
- B110 = 0x3
- B115200 = 0x12
- B1200 = 0x9
- B134 = 0x4
- B150 = 0x5
- B153600 = 0x13
- B1800 = 0xa
- B19200 = 0xe
- B200 = 0x6
- B230400 = 0x14
- B2400 = 0xb
- B300 = 0x7
- B307200 = 0x15
- B38400 = 0xf
- B460800 = 0x16
- B4800 = 0xc
- B50 = 0x1
- B57600 = 0x10
- B600 = 0x8
- B75 = 0x2
- B76800 = 0x11
- B921600 = 0x17
- B9600 = 0xd
- BIOCFLUSH = 0x20004268
- BIOCGBLEN = 0x40044266
- BIOCGDLT = 0x4004426a
- BIOCGDLTLIST = -0x3fefbd89
- BIOCGDLTLIST32 = -0x3ff7bd89
- BIOCGETIF = 0x4020426b
- BIOCGETLIF = 0x4078426b
- BIOCGHDRCMPLT = 0x40044274
- BIOCGRTIMEOUT = 0x4010427b
- BIOCGRTIMEOUT32 = 0x4008427b
- BIOCGSEESENT = 0x40044278
- BIOCGSTATS = 0x4080426f
- BIOCGSTATSOLD = 0x4008426f
- BIOCIMMEDIATE = -0x7ffbbd90
- BIOCPROMISC = 0x20004269
- BIOCSBLEN = -0x3ffbbd9a
- BIOCSDLT = -0x7ffbbd8a
- BIOCSETF = -0x7fefbd99
- BIOCSETF32 = -0x7ff7bd99
- BIOCSETIF = -0x7fdfbd94
- BIOCSETLIF = -0x7f87bd94
- BIOCSHDRCMPLT = -0x7ffbbd8b
- BIOCSRTIMEOUT = -0x7fefbd86
- BIOCSRTIMEOUT32 = -0x7ff7bd86
- BIOCSSEESENT = -0x7ffbbd87
- BIOCSTCPF = -0x7fefbd8e
- BIOCSUDPF = -0x7fefbd8d
- BIOCVERSION = 0x40044271
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALIGNMENT = 0x4
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DFLTBUFSIZE = 0x100000
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXBUFSIZE = 0x1000000
- BPF_MAXINSNS = 0x200
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINBUFSIZE = 0x20
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_OR = 0x40
- BPF_RELEASE = 0x30bb6
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BRKINT = 0x2
- CFLUSH = 0xf
- CLOCAL = 0x800
- CLOCK_HIGHRES = 0x4
- CLOCK_LEVEL = 0xa
- CLOCK_MONOTONIC = 0x4
- CLOCK_PROCESS_CPUTIME_ID = 0x5
- CLOCK_PROF = 0x2
- CLOCK_REALTIME = 0x3
- CLOCK_THREAD_CPUTIME_ID = 0x2
- CLOCK_VIRTUAL = 0x1
- CREAD = 0x80
- CS5 = 0x0
- CS6 = 0x10
- CS7 = 0x20
- CS8 = 0x30
- CSIZE = 0x30
- CSTART = 0x11
- CSTATUS = 0x14
- CSTOP = 0x13
- CSTOPB = 0x40
- CSUSP = 0x1a
- CSWTCH = 0x1a
- DLT_AIRONET_HEADER = 0x78
- DLT_APPLE_IP_OVER_IEEE1394 = 0x8a
- DLT_ARCNET = 0x7
- DLT_ARCNET_LINUX = 0x81
- DLT_ATM_CLIP = 0x13
- DLT_ATM_RFC1483 = 0xb
- DLT_AURORA = 0x7e
- DLT_AX25 = 0x3
- DLT_BACNET_MS_TP = 0xa5
- DLT_CHAOS = 0x5
- DLT_CISCO_IOS = 0x76
- DLT_C_HDLC = 0x68
- DLT_DOCSIS = 0x8f
- DLT_ECONET = 0x73
- DLT_EN10MB = 0x1
- DLT_EN3MB = 0x2
- DLT_ENC = 0x6d
- DLT_ERF_ETH = 0xaf
- DLT_ERF_POS = 0xb0
- DLT_FDDI = 0xa
- DLT_FRELAY = 0x6b
- DLT_GCOM_SERIAL = 0xad
- DLT_GCOM_T1E1 = 0xac
- DLT_GPF_F = 0xab
- DLT_GPF_T = 0xaa
- DLT_GPRS_LLC = 0xa9
- DLT_HDLC = 0x10
- DLT_HHDLC = 0x79
- DLT_HIPPI = 0xf
- DLT_IBM_SN = 0x92
- DLT_IBM_SP = 0x91
- DLT_IEEE802 = 0x6
- DLT_IEEE802_11 = 0x69
- DLT_IEEE802_11_RADIO = 0x7f
- DLT_IEEE802_11_RADIO_AVS = 0xa3
- DLT_IPNET = 0xe2
- DLT_IPOIB = 0xa2
- DLT_IP_OVER_FC = 0x7a
- DLT_JUNIPER_ATM1 = 0x89
- DLT_JUNIPER_ATM2 = 0x87
- DLT_JUNIPER_CHDLC = 0xb5
- DLT_JUNIPER_ES = 0x84
- DLT_JUNIPER_ETHER = 0xb2
- DLT_JUNIPER_FRELAY = 0xb4
- DLT_JUNIPER_GGSN = 0x85
- DLT_JUNIPER_MFR = 0x86
- DLT_JUNIPER_MLFR = 0x83
- DLT_JUNIPER_MLPPP = 0x82
- DLT_JUNIPER_MONITOR = 0xa4
- DLT_JUNIPER_PIC_PEER = 0xae
- DLT_JUNIPER_PPP = 0xb3
- DLT_JUNIPER_PPPOE = 0xa7
- DLT_JUNIPER_PPPOE_ATM = 0xa8
- DLT_JUNIPER_SERVICES = 0x88
- DLT_LINUX_IRDA = 0x90
- DLT_LINUX_LAPD = 0xb1
- DLT_LINUX_SLL = 0x71
- DLT_LOOP = 0x6c
- DLT_LTALK = 0x72
- DLT_MTP2 = 0x8c
- DLT_MTP2_WITH_PHDR = 0x8b
- DLT_MTP3 = 0x8d
- DLT_NULL = 0x0
- DLT_PCI_EXP = 0x7d
- DLT_PFLOG = 0x75
- DLT_PFSYNC = 0x12
- DLT_PPP = 0x9
- DLT_PPP_BSDOS = 0xe
- DLT_PPP_PPPD = 0xa6
- DLT_PRISM_HEADER = 0x77
- DLT_PRONET = 0x4
- DLT_RAW = 0xc
- DLT_RAWAF_MASK = 0x2240000
- DLT_RIO = 0x7c
- DLT_SCCP = 0x8e
- DLT_SLIP = 0x8
- DLT_SLIP_BSDOS = 0xd
- DLT_SUNATM = 0x7b
- DLT_SYMANTEC_FIREWALL = 0x63
- DLT_TZSP = 0x80
- ECHO = 0x8
- ECHOCTL = 0x200
- ECHOE = 0x10
- ECHOK = 0x20
- ECHOKE = 0x800
- ECHONL = 0x40
- ECHOPRT = 0x400
- EMPTY_SET = 0x0
- EMT_CPCOVF = 0x1
- EQUALITY_CHECK = 0x0
- EXTA = 0xe
- EXTB = 0xf
- FD_CLOEXEC = 0x1
- FD_NFDBITS = 0x40
- FD_SETSIZE = 0x10000
- FLUSHALL = 0x1
- FLUSHDATA = 0x0
- FLUSHO = 0x2000
- F_ALLOCSP = 0xa
- F_ALLOCSP64 = 0xa
- F_BADFD = 0x2e
- F_BLKSIZE = 0x13
- F_BLOCKS = 0x12
- F_CHKFL = 0x8
- F_COMPAT = 0x8
- F_DUP2FD = 0x9
- F_DUP2FD_CLOEXEC = 0x24
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x25
- F_FREESP = 0xb
- F_FREESP64 = 0xb
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLK = 0xe
- F_GETLK64 = 0xe
- F_GETOWN = 0x17
- F_GETXFL = 0x2d
- F_HASREMOTELOCKS = 0x1a
- F_ISSTREAM = 0xd
- F_MANDDNY = 0x10
- F_MDACC = 0x20
- F_NODNY = 0x0
- F_NPRIV = 0x10
- F_PRIV = 0xf
- F_QUOTACTL = 0x11
- F_RDACC = 0x1
- F_RDDNY = 0x1
- F_RDLCK = 0x1
- F_REVOKE = 0x19
- F_RMACC = 0x4
- F_RMDNY = 0x4
- F_RWACC = 0x3
- F_RWDNY = 0x3
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLK = 0x6
- F_SETLK64 = 0x6
- F_SETLK64_NBMAND = 0x2a
- F_SETLKW = 0x7
- F_SETLKW64 = 0x7
- F_SETLK_NBMAND = 0x2a
- F_SETOWN = 0x18
- F_SHARE = 0x28
- F_SHARE_NBMAND = 0x2b
- F_UNLCK = 0x3
- F_UNLKSYS = 0x4
- F_UNSHARE = 0x29
- F_WRACC = 0x2
- F_WRDNY = 0x2
- F_WRLCK = 0x2
- HUPCL = 0x400
- ICANON = 0x2
- ICRNL = 0x100
- IEXTEN = 0x8000
- IFF_ADDRCONF = 0x80000
- IFF_ALLMULTI = 0x200
- IFF_ANYCAST = 0x400000
- IFF_BROADCAST = 0x2
- IFF_CANTCHANGE = 0x7f203003b5a
- IFF_COS_ENABLED = 0x200000000
- IFF_DEBUG = 0x4
- IFF_DEPRECATED = 0x40000
- IFF_DHCPRUNNING = 0x4000
- IFF_DUPLICATE = 0x4000000000
- IFF_FAILED = 0x10000000
- IFF_FIXEDMTU = 0x1000000000
- IFF_INACTIVE = 0x40000000
- IFF_INTELLIGENT = 0x400
- IFF_IPMP = 0x8000000000
- IFF_IPMP_CANTCHANGE = 0x10000000
- IFF_IPMP_INVALID = 0x1ec200080
- IFF_IPV4 = 0x1000000
- IFF_IPV6 = 0x2000000
- IFF_L3PROTECT = 0x40000000000
- IFF_LOOPBACK = 0x8
- IFF_MULTICAST = 0x800
- IFF_MULTI_BCAST = 0x1000
- IFF_NOACCEPT = 0x4000000
- IFF_NOARP = 0x80
- IFF_NOFAILOVER = 0x8000000
- IFF_NOLINKLOCAL = 0x20000000000
- IFF_NOLOCAL = 0x20000
- IFF_NONUD = 0x200000
- IFF_NORTEXCH = 0x800000
- IFF_NOTRAILERS = 0x20
- IFF_NOXMIT = 0x10000
- IFF_OFFLINE = 0x80000000
- IFF_POINTOPOINT = 0x10
- IFF_PREFERRED = 0x400000000
- IFF_PRIVATE = 0x8000
- IFF_PROMISC = 0x100
- IFF_ROUTER = 0x100000
- IFF_RUNNING = 0x40
- IFF_STANDBY = 0x20000000
- IFF_TEMPORARY = 0x800000000
- IFF_UNNUMBERED = 0x2000
- IFF_UP = 0x1
- IFF_VIRTUAL = 0x2000000000
- IFF_VRRP = 0x10000000000
- IFF_XRESOLV = 0x100000000
- IFNAMSIZ = 0x10
- IFT_1822 = 0x2
- IFT_6TO4 = 0xca
- IFT_AAL5 = 0x31
- IFT_ARCNET = 0x23
- IFT_ARCNETPLUS = 0x24
- IFT_ATM = 0x25
- IFT_CEPT = 0x13
- IFT_DS3 = 0x1e
- IFT_EON = 0x19
- IFT_ETHER = 0x6
- IFT_FDDI = 0xf
- IFT_FRELAY = 0x20
- IFT_FRELAYDCE = 0x2c
- IFT_HDH1822 = 0x3
- IFT_HIPPI = 0x2f
- IFT_HSSI = 0x2e
- IFT_HY = 0xe
- IFT_IB = 0xc7
- IFT_IPV4 = 0xc8
- IFT_IPV6 = 0xc9
- IFT_ISDNBASIC = 0x14
- IFT_ISDNPRIMARY = 0x15
- IFT_ISO88022LLC = 0x29
- IFT_ISO88023 = 0x7
- IFT_ISO88024 = 0x8
- IFT_ISO88025 = 0x9
- IFT_ISO88026 = 0xa
- IFT_LAPB = 0x10
- IFT_LOCALTALK = 0x2a
- IFT_LOOP = 0x18
- IFT_MIOX25 = 0x26
- IFT_MODEM = 0x30
- IFT_NSIP = 0x1b
- IFT_OTHER = 0x1
- IFT_P10 = 0xc
- IFT_P80 = 0xd
- IFT_PARA = 0x22
- IFT_PPP = 0x17
- IFT_PROPMUX = 0x36
- IFT_PROPVIRTUAL = 0x35
- IFT_PTPSERIAL = 0x16
- IFT_RS232 = 0x21
- IFT_SDLC = 0x11
- IFT_SIP = 0x1f
- IFT_SLIP = 0x1c
- IFT_SMDSDXI = 0x2b
- IFT_SMDSICIP = 0x34
- IFT_SONET = 0x27
- IFT_SONETPATH = 0x32
- IFT_SONETVT = 0x33
- IFT_STARLAN = 0xb
- IFT_T1 = 0x12
- IFT_ULTRA = 0x1d
- IFT_V35 = 0x2d
- IFT_X25 = 0x5
- IFT_X25DDN = 0x4
- IFT_X25PLE = 0x28
- IFT_XETHER = 0x1a
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_AUTOCONF_MASK = 0xffff0000
- IN_AUTOCONF_NET = 0xa9fe0000
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLASSD_HOST = 0xfffffff
- IN_CLASSD_NET = 0xf0000000
- IN_CLASSD_NSHIFT = 0x1c
- IN_CLASSE_NET = 0xffffffff
- IN_LOOPBACKNET = 0x7f
- IN_PRIVATE12_MASK = 0xfff00000
- IN_PRIVATE12_NET = 0xac100000
- IN_PRIVATE16_MASK = 0xffff0000
- IN_PRIVATE16_NET = 0xc0a80000
- IN_PRIVATE8_MASK = 0xff000000
- IN_PRIVATE8_NET = 0xa000000
- IPPROTO_AH = 0x33
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_ENCAP = 0x4
- IPPROTO_EON = 0x50
- IPPROTO_ESP = 0x32
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GGP = 0x3
- IPPROTO_HELLO = 0x3f
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IGMP = 0x2
- IPPROTO_IP = 0x0
- IPPROTO_IPV6 = 0x29
- IPPROTO_MAX = 0x100
- IPPROTO_ND = 0x4d
- IPPROTO_NONE = 0x3b
- IPPROTO_OSPF = 0x59
- IPPROTO_PIM = 0x67
- IPPROTO_PUP = 0xc
- IPPROTO_RAW = 0xff
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_SCTP = 0x84
- IPPROTO_TCP = 0x6
- IPPROTO_UDP = 0x11
- IPV6_ADD_MEMBERSHIP = 0x9
- IPV6_BOUND_IF = 0x41
- IPV6_CHECKSUM = 0x18
- IPV6_DONTFRAG = 0x21
- IPV6_DROP_MEMBERSHIP = 0xa
- IPV6_DSTOPTS = 0xf
- IPV6_FLOWINFO_FLOWLABEL = 0xffff0f00
- IPV6_FLOWINFO_TCLASS = 0xf00f
- IPV6_HOPLIMIT = 0xc
- IPV6_HOPOPTS = 0xe
- IPV6_JOIN_GROUP = 0x9
- IPV6_LEAVE_GROUP = 0xa
- IPV6_MULTICAST_HOPS = 0x7
- IPV6_MULTICAST_IF = 0x6
- IPV6_MULTICAST_LOOP = 0x8
- IPV6_NEXTHOP = 0xd
- IPV6_PAD1_OPT = 0x0
- IPV6_PATHMTU = 0x25
- IPV6_PKTINFO = 0xb
- IPV6_PREFER_SRC_CGA = 0x20
- IPV6_PREFER_SRC_CGADEFAULT = 0x10
- IPV6_PREFER_SRC_CGAMASK = 0x30
- IPV6_PREFER_SRC_COA = 0x2
- IPV6_PREFER_SRC_DEFAULT = 0x15
- IPV6_PREFER_SRC_HOME = 0x1
- IPV6_PREFER_SRC_MASK = 0x3f
- IPV6_PREFER_SRC_MIPDEFAULT = 0x1
- IPV6_PREFER_SRC_MIPMASK = 0x3
- IPV6_PREFER_SRC_NONCGA = 0x10
- IPV6_PREFER_SRC_PUBLIC = 0x4
- IPV6_PREFER_SRC_TMP = 0x8
- IPV6_PREFER_SRC_TMPDEFAULT = 0x4
- IPV6_PREFER_SRC_TMPMASK = 0xc
- IPV6_RECVDSTOPTS = 0x28
- IPV6_RECVHOPLIMIT = 0x13
- IPV6_RECVHOPOPTS = 0x14
- IPV6_RECVPATHMTU = 0x24
- IPV6_RECVPKTINFO = 0x12
- IPV6_RECVRTHDR = 0x16
- IPV6_RECVRTHDRDSTOPTS = 0x17
- IPV6_RECVTCLASS = 0x19
- IPV6_RTHDR = 0x10
- IPV6_RTHDRDSTOPTS = 0x11
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_SEC_OPT = 0x22
- IPV6_SRC_PREFERENCES = 0x23
- IPV6_TCLASS = 0x26
- IPV6_UNICAST_HOPS = 0x5
- IPV6_UNSPEC_SRC = 0x42
- IPV6_USE_MIN_MTU = 0x20
- IPV6_V6ONLY = 0x27
- IP_ADD_MEMBERSHIP = 0x13
- IP_ADD_SOURCE_MEMBERSHIP = 0x17
- IP_BLOCK_SOURCE = 0x15
- IP_BOUND_IF = 0x41
- IP_BROADCAST = 0x106
- IP_BROADCAST_TTL = 0x43
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DHCPINIT_IF = 0x45
- IP_DONTFRAG = 0x1b
- IP_DONTROUTE = 0x105
- IP_DROP_MEMBERSHIP = 0x14
- IP_DROP_SOURCE_MEMBERSHIP = 0x18
- IP_HDRINCL = 0x2
- IP_MAXPACKET = 0xffff
- IP_MF = 0x2000
- IP_MSS = 0x240
- IP_MULTICAST_IF = 0x10
- IP_MULTICAST_LOOP = 0x12
- IP_MULTICAST_TTL = 0x11
- IP_NEXTHOP = 0x19
- IP_OPTIONS = 0x1
- IP_PKTINFO = 0x1a
- IP_RECVDSTADDR = 0x7
- IP_RECVIF = 0x9
- IP_RECVOPTS = 0x5
- IP_RECVPKTINFO = 0x1a
- IP_RECVRETOPTS = 0x6
- IP_RECVSLLA = 0xa
- IP_RECVTTL = 0xb
- IP_RETOPTS = 0x8
- IP_REUSEADDR = 0x104
- IP_SEC_OPT = 0x22
- IP_TOS = 0x3
- IP_TTL = 0x4
- IP_UNBLOCK_SOURCE = 0x16
- IP_UNSPEC_SRC = 0x42
- ISIG = 0x1
- ISTRIP = 0x20
- IXANY = 0x800
- IXOFF = 0x1000
- IXON = 0x400
- MADV_ACCESS_DEFAULT = 0x6
- MADV_ACCESS_LWP = 0x7
- MADV_ACCESS_MANY = 0x8
- MADV_DONTNEED = 0x4
- MADV_FREE = 0x5
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_SEQUENTIAL = 0x2
- MADV_WILLNEED = 0x3
- MAP_32BIT = 0x80
- MAP_ALIGN = 0x200
- MAP_ANON = 0x100
- MAP_ANONYMOUS = 0x100
- MAP_FIXED = 0x10
- MAP_INITDATA = 0x800
- MAP_NORESERVE = 0x40
- MAP_PRIVATE = 0x2
- MAP_RENAME = 0x20
- MAP_SHARED = 0x1
- MAP_TEXT = 0x400
- MAP_TYPE = 0xf
- MCL_CURRENT = 0x1
- MCL_FUTURE = 0x2
- MSG_CTRUNC = 0x10
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x80
- MSG_DUPCTRL = 0x800
- MSG_EOR = 0x8
- MSG_MAXIOVLEN = 0x10
- MSG_NOTIFICATION = 0x100
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_TRUNC = 0x20
- MSG_WAITALL = 0x40
- MSG_XPG4_2 = 0x8000
- MS_ASYNC = 0x1
- MS_INVALIDATE = 0x2
- MS_OLDSYNC = 0x0
- MS_SYNC = 0x4
- M_FLUSH = 0x86
- NOFLSH = 0x80
- OCRNL = 0x8
- OFDEL = 0x80
- OFILL = 0x40
- ONLCR = 0x4
- ONLRET = 0x20
- ONOCR = 0x10
- OPENFAIL = -0x1
- OPOST = 0x1
- O_ACCMODE = 0x600003
- O_APPEND = 0x8
- O_CLOEXEC = 0x800000
- O_CREAT = 0x100
- O_DSYNC = 0x40
- O_EXCL = 0x400
- O_EXEC = 0x400000
- O_LARGEFILE = 0x2000
- O_NDELAY = 0x4
- O_NOCTTY = 0x800
- O_NOFOLLOW = 0x20000
- O_NOLINKS = 0x40000
- O_NONBLOCK = 0x80
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_RSYNC = 0x8000
- O_SEARCH = 0x200000
- O_SIOCGIFCONF = -0x3ff796ec
- O_SIOCGLIFCONF = -0x3fef9688
- O_SYNC = 0x10
- O_TRUNC = 0x200
- O_WRONLY = 0x1
- O_XATTR = 0x4000
- PARENB = 0x100
- PAREXT = 0x100000
- PARMRK = 0x8
- PARODD = 0x200
- PENDIN = 0x4000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- RLIMIT_AS = 0x6
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x5
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = -0x3
- RTAX_AUTHOR = 0x6
- RTAX_BRD = 0x7
- RTAX_DST = 0x0
- RTAX_GATEWAY = 0x1
- RTAX_GENMASK = 0x3
- RTAX_IFA = 0x5
- RTAX_IFP = 0x4
- RTAX_MAX = 0x9
- RTAX_NETMASK = 0x2
- RTAX_SRC = 0x8
- RTA_AUTHOR = 0x40
- RTA_BRD = 0x80
- RTA_DST = 0x1
- RTA_GATEWAY = 0x2
- RTA_GENMASK = 0x8
- RTA_IFA = 0x20
- RTA_IFP = 0x10
- RTA_NETMASK = 0x4
- RTA_NUMBITS = 0x9
- RTA_SRC = 0x100
- RTF_BLACKHOLE = 0x1000
- RTF_CLONING = 0x100
- RTF_DONE = 0x40
- RTF_DYNAMIC = 0x10
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_INDIRECT = 0x40000
- RTF_KERNEL = 0x80000
- RTF_LLINFO = 0x400
- RTF_MASK = 0x80
- RTF_MODIFIED = 0x20
- RTF_MULTIRT = 0x10000
- RTF_PRIVATE = 0x2000
- RTF_PROTO1 = 0x8000
- RTF_PROTO2 = 0x4000
- RTF_REJECT = 0x8
- RTF_SETSRC = 0x20000
- RTF_STATIC = 0x800
- RTF_UP = 0x1
- RTF_XRESOLVE = 0x200
- RTF_ZONE = 0x100000
- RTM_ADD = 0x1
- RTM_CHANGE = 0x3
- RTM_CHGADDR = 0xf
- RTM_DELADDR = 0xd
- RTM_DELETE = 0x2
- RTM_FREEADDR = 0x10
- RTM_GET = 0x4
- RTM_IFINFO = 0xe
- RTM_LOCK = 0x8
- RTM_LOSING = 0x5
- RTM_MISS = 0x7
- RTM_NEWADDR = 0xc
- RTM_OLDADD = 0x9
- RTM_OLDDEL = 0xa
- RTM_REDIRECT = 0x6
- RTM_RESOLVE = 0xb
- RTM_VERSION = 0x3
- RTV_EXPIRE = 0x4
- RTV_HOPCOUNT = 0x2
- RTV_MTU = 0x1
- RTV_RPIPE = 0x8
- RTV_RTT = 0x40
- RTV_RTTVAR = 0x80
- RTV_SPIPE = 0x10
- RTV_SSTHRESH = 0x20
- RT_AWARE = 0x1
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- SCM_RIGHTS = 0x1010
- SCM_TIMESTAMP = 0x1013
- SCM_UCRED = 0x1012
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIG2STR_MAX = 0x20
- SIOCADDMULTI = -0x7fdf96cf
- SIOCADDRT = -0x7fcf8df6
- SIOCATMARK = 0x40047307
- SIOCDARP = -0x7fdb96e0
- SIOCDELMULTI = -0x7fdf96ce
- SIOCDELRT = -0x7fcf8df5
- SIOCDXARP = -0x7fff9658
- SIOCGARP = -0x3fdb96e1
- SIOCGDSTINFO = -0x3fff965c
- SIOCGENADDR = -0x3fdf96ab
- SIOCGENPSTATS = -0x3fdf96c7
- SIOCGETLSGCNT = -0x3fef8deb
- SIOCGETNAME = 0x40107334
- SIOCGETPEER = 0x40107335
- SIOCGETPROP = -0x3fff8f44
- SIOCGETSGCNT = -0x3feb8deb
- SIOCGETSYNC = -0x3fdf96d3
- SIOCGETVIFCNT = -0x3feb8dec
- SIOCGHIWAT = 0x40047301
- SIOCGIFADDR = -0x3fdf96f3
- SIOCGIFBRDADDR = -0x3fdf96e9
- SIOCGIFCONF = -0x3ff796a4
- SIOCGIFDSTADDR = -0x3fdf96f1
- SIOCGIFFLAGS = -0x3fdf96ef
- SIOCGIFHWADDR = -0x3fdf9647
- SIOCGIFINDEX = -0x3fdf96a6
- SIOCGIFMEM = -0x3fdf96ed
- SIOCGIFMETRIC = -0x3fdf96e5
- SIOCGIFMTU = -0x3fdf96ea
- SIOCGIFMUXID = -0x3fdf96a8
- SIOCGIFNETMASK = -0x3fdf96e7
- SIOCGIFNUM = 0x40046957
- SIOCGIP6ADDRPOLICY = -0x3fff965e
- SIOCGIPMSFILTER = -0x3ffb964c
- SIOCGLIFADDR = -0x3f87968f
- SIOCGLIFBINDING = -0x3f879666
- SIOCGLIFBRDADDR = -0x3f879685
- SIOCGLIFCONF = -0x3fef965b
- SIOCGLIFDADSTATE = -0x3f879642
- SIOCGLIFDSTADDR = -0x3f87968d
- SIOCGLIFFLAGS = -0x3f87968b
- SIOCGLIFGROUPINFO = -0x3f4b9663
- SIOCGLIFGROUPNAME = -0x3f879664
- SIOCGLIFHWADDR = -0x3f879640
- SIOCGLIFINDEX = -0x3f87967b
- SIOCGLIFLNKINFO = -0x3f879674
- SIOCGLIFMETRIC = -0x3f879681
- SIOCGLIFMTU = -0x3f879686
- SIOCGLIFMUXID = -0x3f87967d
- SIOCGLIFNETMASK = -0x3f879683
- SIOCGLIFNUM = -0x3ff3967e
- SIOCGLIFSRCOF = -0x3fef964f
- SIOCGLIFSUBNET = -0x3f879676
- SIOCGLIFTOKEN = -0x3f879678
- SIOCGLIFUSESRC = -0x3f879651
- SIOCGLIFZONE = -0x3f879656
- SIOCGLOWAT = 0x40047303
- SIOCGMSFILTER = -0x3ffb964e
- SIOCGPGRP = 0x40047309
- SIOCGSTAMP = -0x3fef9646
- SIOCGXARP = -0x3fff9659
- SIOCIFDETACH = -0x7fdf96c8
- SIOCILB = -0x3ffb9645
- SIOCLIFADDIF = -0x3f879691
- SIOCLIFDELND = -0x7f879673
- SIOCLIFGETND = -0x3f879672
- SIOCLIFREMOVEIF = -0x7f879692
- SIOCLIFSETND = -0x7f879671
- SIOCLOWER = -0x7fdf96d7
- SIOCSARP = -0x7fdb96e2
- SIOCSCTPGOPT = -0x3fef9653
- SIOCSCTPPEELOFF = -0x3ffb9652
- SIOCSCTPSOPT = -0x7fef9654
- SIOCSENABLESDP = -0x3ffb9649
- SIOCSETPROP = -0x7ffb8f43
- SIOCSETSYNC = -0x7fdf96d4
- SIOCSHIWAT = -0x7ffb8d00
- SIOCSIFADDR = -0x7fdf96f4
- SIOCSIFBRDADDR = -0x7fdf96e8
- SIOCSIFDSTADDR = -0x7fdf96f2
- SIOCSIFFLAGS = -0x7fdf96f0
- SIOCSIFINDEX = -0x7fdf96a5
- SIOCSIFMEM = -0x7fdf96ee
- SIOCSIFMETRIC = -0x7fdf96e4
- SIOCSIFMTU = -0x7fdf96eb
- SIOCSIFMUXID = -0x7fdf96a7
- SIOCSIFNAME = -0x7fdf96b7
- SIOCSIFNETMASK = -0x7fdf96e6
- SIOCSIP6ADDRPOLICY = -0x7fff965d
- SIOCSIPMSFILTER = -0x7ffb964b
- SIOCSLGETREQ = -0x3fdf96b9
- SIOCSLIFADDR = -0x7f879690
- SIOCSLIFBRDADDR = -0x7f879684
- SIOCSLIFDSTADDR = -0x7f87968e
- SIOCSLIFFLAGS = -0x7f87968c
- SIOCSLIFGROUPNAME = -0x7f879665
- SIOCSLIFINDEX = -0x7f87967a
- SIOCSLIFLNKINFO = -0x7f879675
- SIOCSLIFMETRIC = -0x7f879680
- SIOCSLIFMTU = -0x7f879687
- SIOCSLIFMUXID = -0x7f87967c
- SIOCSLIFNAME = -0x3f87967f
- SIOCSLIFNETMASK = -0x7f879682
- SIOCSLIFPREFIX = -0x3f879641
- SIOCSLIFSUBNET = -0x7f879677
- SIOCSLIFTOKEN = -0x7f879679
- SIOCSLIFUSESRC = -0x7f879650
- SIOCSLIFZONE = -0x7f879655
- SIOCSLOWAT = -0x7ffb8cfe
- SIOCSLSTAT = -0x7fdf96b8
- SIOCSMSFILTER = -0x7ffb964d
- SIOCSPGRP = -0x7ffb8cf8
- SIOCSPROMISC = -0x7ffb96d0
- SIOCSQPTR = -0x3ffb9648
- SIOCSSDSTATS = -0x3fdf96d2
- SIOCSSESTATS = -0x3fdf96d1
- SIOCSXARP = -0x7fff965a
- SIOCTMYADDR = -0x3ff79670
- SIOCTMYSITE = -0x3ff7966e
- SIOCTONLINK = -0x3ff7966f
- SIOCUPPER = -0x7fdf96d8
- SIOCX25RCV = -0x3fdf96c4
- SIOCX25TBL = -0x3fdf96c3
- SIOCX25XMT = -0x3fdf96c5
- SIOCXPROTO = 0x20007337
- SOCK_CLOEXEC = 0x80000
- SOCK_DGRAM = 0x1
- SOCK_NDELAY = 0x200000
- SOCK_NONBLOCK = 0x100000
- SOCK_RAW = 0x4
- SOCK_RDM = 0x5
- SOCK_SEQPACKET = 0x6
- SOCK_STREAM = 0x2
- SOCK_TYPE_MASK = 0xffff
- SOL_FILTER = 0xfffc
- SOL_PACKET = 0xfffd
- SOL_ROUTE = 0xfffe
- SOL_SOCKET = 0xffff
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x2
- SO_ALL = 0x3f
- SO_ALLZONES = 0x1014
- SO_ANON_MLP = 0x100a
- SO_ATTACH_FILTER = 0x40000001
- SO_BAND = 0x4000
- SO_BROADCAST = 0x20
- SO_COPYOPT = 0x80000
- SO_DEBUG = 0x1
- SO_DELIM = 0x8000
- SO_DETACH_FILTER = 0x40000002
- SO_DGRAM_ERRIND = 0x200
- SO_DOMAIN = 0x100c
- SO_DONTLINGER = -0x81
- SO_DONTROUTE = 0x10
- SO_ERROPT = 0x40000
- SO_ERROR = 0x1007
- SO_EXCLBIND = 0x1015
- SO_HIWAT = 0x10
- SO_ISNTTY = 0x800
- SO_ISTTY = 0x400
- SO_KEEPALIVE = 0x8
- SO_LINGER = 0x80
- SO_LOWAT = 0x20
- SO_MAC_EXEMPT = 0x100b
- SO_MAC_IMPLICIT = 0x1016
- SO_MAXBLK = 0x100000
- SO_MAXPSZ = 0x8
- SO_MINPSZ = 0x4
- SO_MREADOFF = 0x80
- SO_MREADON = 0x40
- SO_NDELOFF = 0x200
- SO_NDELON = 0x100
- SO_NODELIM = 0x10000
- SO_OOBINLINE = 0x100
- SO_PROTOTYPE = 0x1009
- SO_RCVBUF = 0x1002
- SO_RCVLOWAT = 0x1004
- SO_RCVPSH = 0x100d
- SO_RCVTIMEO = 0x1006
- SO_READOPT = 0x1
- SO_RECVUCRED = 0x400
- SO_REUSEADDR = 0x4
- SO_SECATTR = 0x1011
- SO_SNDBUF = 0x1001
- SO_SNDLOWAT = 0x1003
- SO_SNDTIMEO = 0x1005
- SO_STRHOLD = 0x20000
- SO_TAIL = 0x200000
- SO_TIMESTAMP = 0x1013
- SO_TONSTOP = 0x2000
- SO_TOSTOP = 0x1000
- SO_TYPE = 0x1008
- SO_USELOOPBACK = 0x40
- SO_VRRP = 0x1017
- SO_WROFF = 0x2
- TCFLSH = 0x5407
- TCGETA = 0x5401
- TCGETS = 0x540d
- TCIFLUSH = 0x0
- TCIOFLUSH = 0x2
- TCOFLUSH = 0x1
- TCP_ABORT_THRESHOLD = 0x11
- TCP_ANONPRIVBIND = 0x20
- TCP_CONN_ABORT_THRESHOLD = 0x13
- TCP_CONN_NOTIFY_THRESHOLD = 0x12
- TCP_CORK = 0x18
- TCP_EXCLBIND = 0x21
- TCP_INIT_CWND = 0x15
- TCP_KEEPALIVE = 0x8
- TCP_KEEPALIVE_ABORT_THRESHOLD = 0x17
- TCP_KEEPALIVE_THRESHOLD = 0x16
- TCP_KEEPCNT = 0x23
- TCP_KEEPIDLE = 0x22
- TCP_KEEPINTVL = 0x24
- TCP_LINGER2 = 0x1c
- TCP_MAXSEG = 0x2
- TCP_MSS = 0x218
- TCP_NODELAY = 0x1
- TCP_NOTIFY_THRESHOLD = 0x10
- TCP_RECVDSTADDR = 0x14
- TCP_RTO_INITIAL = 0x19
- TCP_RTO_MAX = 0x1b
- TCP_RTO_MIN = 0x1a
- TCSAFLUSH = 0x5410
- TCSBRK = 0x5405
- TCSETA = 0x5402
- TCSETAF = 0x5404
- TCSETAW = 0x5403
- TCSETS = 0x540e
- TCSETSF = 0x5410
- TCSETSW = 0x540f
- TCXONC = 0x5406
- TIOC = 0x5400
- TIOCCBRK = 0x747a
- TIOCCDTR = 0x7478
- TIOCCILOOP = 0x746c
- TIOCEXCL = 0x740d
- TIOCFLUSH = 0x7410
- TIOCGETC = 0x7412
- TIOCGETD = 0x7400
- TIOCGETP = 0x7408
- TIOCGLTC = 0x7474
- TIOCGPGRP = 0x7414
- TIOCGPPS = 0x547d
- TIOCGPPSEV = 0x547f
- TIOCGSID = 0x7416
- TIOCGSOFTCAR = 0x5469
- TIOCGWINSZ = 0x5468
- TIOCHPCL = 0x7402
- TIOCKBOF = 0x5409
- TIOCKBON = 0x5408
- TIOCLBIC = 0x747e
- TIOCLBIS = 0x747f
- TIOCLGET = 0x747c
- TIOCLSET = 0x747d
- TIOCMBIC = 0x741c
- TIOCMBIS = 0x741b
- TIOCMGET = 0x741d
- TIOCMSET = 0x741a
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x7471
- TIOCNXCL = 0x740e
- TIOCOUTQ = 0x7473
- TIOCREMOTE = 0x741e
- TIOCSBRK = 0x747b
- TIOCSCTTY = 0x7484
- TIOCSDTR = 0x7479
- TIOCSETC = 0x7411
- TIOCSETD = 0x7401
- TIOCSETN = 0x740a
- TIOCSETP = 0x7409
- TIOCSIGNAL = 0x741f
- TIOCSILOOP = 0x746d
- TIOCSLTC = 0x7475
- TIOCSPGRP = 0x7415
- TIOCSPPS = 0x547e
- TIOCSSOFTCAR = 0x546a
- TIOCSTART = 0x746e
- TIOCSTI = 0x7417
- TIOCSTOP = 0x746f
- TIOCSWINSZ = 0x5467
- TOSTOP = 0x100
- VCEOF = 0x8
- VCEOL = 0x9
- VDISCARD = 0xd
- VDSUSP = 0xb
- VEOF = 0x4
- VEOL = 0x5
- VEOL2 = 0x6
- VERASE = 0x2
- VINTR = 0x0
- VKILL = 0x3
- VLNEXT = 0xf
- VMIN = 0x4
- VQUIT = 0x1
- VREPRINT = 0xc
- VSTART = 0x8
- VSTATUS = 0x10
- VSTOP = 0x9
- VSUSP = 0xa
- VSWTCH = 0x7
- VT0 = 0x0
- VT1 = 0x4000
- VTDLY = 0x4000
- VTIME = 0x5
- VWERASE = 0xe
- WCONTFLG = 0xffff
- WCONTINUED = 0x8
- WCOREFLG = 0x80
- WEXITED = 0x1
- WNOHANG = 0x40
- WNOWAIT = 0x80
- WOPTMASK = 0xcf
- WRAP = 0x20000
- WSIGMASK = 0x7f
- WSTOPFLG = 0x7f
- WSTOPPED = 0x4
- WTRAPPED = 0x2
- WUNTRACED = 0x4
-)
-
-// Errors
-const (
- E2BIG = syscall.Errno(0x7)
- EACCES = syscall.Errno(0xd)
- EADDRINUSE = syscall.Errno(0x7d)
- EADDRNOTAVAIL = syscall.Errno(0x7e)
- EADV = syscall.Errno(0x44)
- EAFNOSUPPORT = syscall.Errno(0x7c)
- EAGAIN = syscall.Errno(0xb)
- EALREADY = syscall.Errno(0x95)
- EBADE = syscall.Errno(0x32)
- EBADF = syscall.Errno(0x9)
- EBADFD = syscall.Errno(0x51)
- EBADMSG = syscall.Errno(0x4d)
- EBADR = syscall.Errno(0x33)
- EBADRQC = syscall.Errno(0x36)
- EBADSLT = syscall.Errno(0x37)
- EBFONT = syscall.Errno(0x39)
- EBUSY = syscall.Errno(0x10)
- ECANCELED = syscall.Errno(0x2f)
- ECHILD = syscall.Errno(0xa)
- ECHRNG = syscall.Errno(0x25)
- ECOMM = syscall.Errno(0x46)
- ECONNABORTED = syscall.Errno(0x82)
- ECONNREFUSED = syscall.Errno(0x92)
- ECONNRESET = syscall.Errno(0x83)
- EDEADLK = syscall.Errno(0x2d)
- EDEADLOCK = syscall.Errno(0x38)
- EDESTADDRREQ = syscall.Errno(0x60)
- EDOM = syscall.Errno(0x21)
- EDQUOT = syscall.Errno(0x31)
- EEXIST = syscall.Errno(0x11)
- EFAULT = syscall.Errno(0xe)
- EFBIG = syscall.Errno(0x1b)
- EHOSTDOWN = syscall.Errno(0x93)
- EHOSTUNREACH = syscall.Errno(0x94)
- EIDRM = syscall.Errno(0x24)
- EILSEQ = syscall.Errno(0x58)
- EINPROGRESS = syscall.Errno(0x96)
- EINTR = syscall.Errno(0x4)
- EINVAL = syscall.Errno(0x16)
- EIO = syscall.Errno(0x5)
- EISCONN = syscall.Errno(0x85)
- EISDIR = syscall.Errno(0x15)
- EL2HLT = syscall.Errno(0x2c)
- EL2NSYNC = syscall.Errno(0x26)
- EL3HLT = syscall.Errno(0x27)
- EL3RST = syscall.Errno(0x28)
- ELIBACC = syscall.Errno(0x53)
- ELIBBAD = syscall.Errno(0x54)
- ELIBEXEC = syscall.Errno(0x57)
- ELIBMAX = syscall.Errno(0x56)
- ELIBSCN = syscall.Errno(0x55)
- ELNRNG = syscall.Errno(0x29)
- ELOCKUNMAPPED = syscall.Errno(0x48)
- ELOOP = syscall.Errno(0x5a)
- EMFILE = syscall.Errno(0x18)
- EMLINK = syscall.Errno(0x1f)
- EMSGSIZE = syscall.Errno(0x61)
- EMULTIHOP = syscall.Errno(0x4a)
- ENAMETOOLONG = syscall.Errno(0x4e)
- ENETDOWN = syscall.Errno(0x7f)
- ENETRESET = syscall.Errno(0x81)
- ENETUNREACH = syscall.Errno(0x80)
- ENFILE = syscall.Errno(0x17)
- ENOANO = syscall.Errno(0x35)
- ENOBUFS = syscall.Errno(0x84)
- ENOCSI = syscall.Errno(0x2b)
- ENODATA = syscall.Errno(0x3d)
- ENODEV = syscall.Errno(0x13)
- ENOENT = syscall.Errno(0x2)
- ENOEXEC = syscall.Errno(0x8)
- ENOLCK = syscall.Errno(0x2e)
- ENOLINK = syscall.Errno(0x43)
- ENOMEM = syscall.Errno(0xc)
- ENOMSG = syscall.Errno(0x23)
- ENONET = syscall.Errno(0x40)
- ENOPKG = syscall.Errno(0x41)
- ENOPROTOOPT = syscall.Errno(0x63)
- ENOSPC = syscall.Errno(0x1c)
- ENOSR = syscall.Errno(0x3f)
- ENOSTR = syscall.Errno(0x3c)
- ENOSYS = syscall.Errno(0x59)
- ENOTACTIVE = syscall.Errno(0x49)
- ENOTBLK = syscall.Errno(0xf)
- ENOTCONN = syscall.Errno(0x86)
- ENOTDIR = syscall.Errno(0x14)
- ENOTEMPTY = syscall.Errno(0x5d)
- ENOTRECOVERABLE = syscall.Errno(0x3b)
- ENOTSOCK = syscall.Errno(0x5f)
- ENOTSUP = syscall.Errno(0x30)
- ENOTTY = syscall.Errno(0x19)
- ENOTUNIQ = syscall.Errno(0x50)
- ENXIO = syscall.Errno(0x6)
- EOPNOTSUPP = syscall.Errno(0x7a)
- EOVERFLOW = syscall.Errno(0x4f)
- EOWNERDEAD = syscall.Errno(0x3a)
- EPERM = syscall.Errno(0x1)
- EPFNOSUPPORT = syscall.Errno(0x7b)
- EPIPE = syscall.Errno(0x20)
- EPROTO = syscall.Errno(0x47)
- EPROTONOSUPPORT = syscall.Errno(0x78)
- EPROTOTYPE = syscall.Errno(0x62)
- ERANGE = syscall.Errno(0x22)
- EREMCHG = syscall.Errno(0x52)
- EREMOTE = syscall.Errno(0x42)
- ERESTART = syscall.Errno(0x5b)
- EROFS = syscall.Errno(0x1e)
- ESHUTDOWN = syscall.Errno(0x8f)
- ESOCKTNOSUPPORT = syscall.Errno(0x79)
- ESPIPE = syscall.Errno(0x1d)
- ESRCH = syscall.Errno(0x3)
- ESRMNT = syscall.Errno(0x45)
- ESTALE = syscall.Errno(0x97)
- ESTRPIPE = syscall.Errno(0x5c)
- ETIME = syscall.Errno(0x3e)
- ETIMEDOUT = syscall.Errno(0x91)
- ETOOMANYREFS = syscall.Errno(0x90)
- ETXTBSY = syscall.Errno(0x1a)
- EUNATCH = syscall.Errno(0x2a)
- EUSERS = syscall.Errno(0x5e)
- EWOULDBLOCK = syscall.Errno(0xb)
- EXDEV = syscall.Errno(0x12)
- EXFULL = syscall.Errno(0x34)
-)
-
-// Signals
-const (
- SIGABRT = syscall.Signal(0x6)
- SIGALRM = syscall.Signal(0xe)
- SIGBUS = syscall.Signal(0xa)
- SIGCANCEL = syscall.Signal(0x24)
- SIGCHLD = syscall.Signal(0x12)
- SIGCLD = syscall.Signal(0x12)
- SIGCONT = syscall.Signal(0x19)
- SIGEMT = syscall.Signal(0x7)
- SIGFPE = syscall.Signal(0x8)
- SIGFREEZE = syscall.Signal(0x22)
- SIGHUP = syscall.Signal(0x1)
- SIGILL = syscall.Signal(0x4)
- SIGINFO = syscall.Signal(0x29)
- SIGINT = syscall.Signal(0x2)
- SIGIO = syscall.Signal(0x16)
- SIGIOT = syscall.Signal(0x6)
- SIGJVM1 = syscall.Signal(0x27)
- SIGJVM2 = syscall.Signal(0x28)
- SIGKILL = syscall.Signal(0x9)
- SIGLOST = syscall.Signal(0x25)
- SIGLWP = syscall.Signal(0x21)
- SIGPIPE = syscall.Signal(0xd)
- SIGPOLL = syscall.Signal(0x16)
- SIGPROF = syscall.Signal(0x1d)
- SIGPWR = syscall.Signal(0x13)
- SIGQUIT = syscall.Signal(0x3)
- SIGSEGV = syscall.Signal(0xb)
- SIGSTOP = syscall.Signal(0x17)
- SIGSYS = syscall.Signal(0xc)
- SIGTERM = syscall.Signal(0xf)
- SIGTHAW = syscall.Signal(0x23)
- SIGTRAP = syscall.Signal(0x5)
- SIGTSTP = syscall.Signal(0x18)
- SIGTTIN = syscall.Signal(0x1a)
- SIGTTOU = syscall.Signal(0x1b)
- SIGURG = syscall.Signal(0x15)
- SIGUSR1 = syscall.Signal(0x10)
- SIGUSR2 = syscall.Signal(0x11)
- SIGVTALRM = syscall.Signal(0x1c)
- SIGWAITING = syscall.Signal(0x20)
- SIGWINCH = syscall.Signal(0x14)
- SIGXCPU = syscall.Signal(0x1e)
- SIGXFSZ = syscall.Signal(0x1f)
- SIGXRES = syscall.Signal(0x26)
-)
-
-// Error table
-var errors = [...]string{
- 1: "not owner",
- 2: "no such file or directory",
- 3: "no such process",
- 4: "interrupted system call",
- 5: "I/O error",
- 6: "no such device or address",
- 7: "arg list too long",
- 8: "exec format error",
- 9: "bad file number",
- 10: "no child processes",
- 11: "resource temporarily unavailable",
- 12: "not enough space",
- 13: "permission denied",
- 14: "bad address",
- 15: "block device required",
- 16: "device busy",
- 17: "file exists",
- 18: "cross-device link",
- 19: "no such device",
- 20: "not a directory",
- 21: "is a directory",
- 22: "invalid argument",
- 23: "file table overflow",
- 24: "too many open files",
- 25: "inappropriate ioctl for device",
- 26: "text file busy",
- 27: "file too large",
- 28: "no space left on device",
- 29: "illegal seek",
- 30: "read-only file system",
- 31: "too many links",
- 32: "broken pipe",
- 33: "argument out of domain",
- 34: "result too large",
- 35: "no message of desired type",
- 36: "identifier removed",
- 37: "channel number out of range",
- 38: "level 2 not synchronized",
- 39: "level 3 halted",
- 40: "level 3 reset",
- 41: "link number out of range",
- 42: "protocol driver not attached",
- 43: "no CSI structure available",
- 44: "level 2 halted",
- 45: "deadlock situation detected/avoided",
- 46: "no record locks available",
- 47: "operation canceled",
- 48: "operation not supported",
- 49: "disc quota exceeded",
- 50: "bad exchange descriptor",
- 51: "bad request descriptor",
- 52: "message tables full",
- 53: "anode table overflow",
- 54: "bad request code",
- 55: "invalid slot",
- 56: "file locking deadlock",
- 57: "bad font file format",
- 58: "owner of the lock died",
- 59: "lock is not recoverable",
- 60: "not a stream device",
- 61: "no data available",
- 62: "timer expired",
- 63: "out of stream resources",
- 64: "machine is not on the network",
- 65: "package not installed",
- 66: "object is remote",
- 67: "link has been severed",
- 68: "advertise error",
- 69: "srmount error",
- 70: "communication error on send",
- 71: "protocol error",
- 72: "locked lock was unmapped ",
- 73: "facility is not active",
- 74: "multihop attempted",
- 77: "not a data message",
- 78: "file name too long",
- 79: "value too large for defined data type",
- 80: "name not unique on network",
- 81: "file descriptor in bad state",
- 82: "remote address changed",
- 83: "can not access a needed shared library",
- 84: "accessing a corrupted shared library",
- 85: ".lib section in a.out corrupted",
- 86: "attempting to link in more shared libraries than system limit",
- 87: "can not exec a shared library directly",
- 88: "illegal byte sequence",
- 89: "operation not applicable",
- 90: "number of symbolic links encountered during path name traversal exceeds MAXSYMLINKS",
- 91: "error 91",
- 92: "error 92",
- 93: "directory not empty",
- 94: "too many users",
- 95: "socket operation on non-socket",
- 96: "destination address required",
- 97: "message too long",
- 98: "protocol wrong type for socket",
- 99: "option not supported by protocol",
- 120: "protocol not supported",
- 121: "socket type not supported",
- 122: "operation not supported on transport endpoint",
- 123: "protocol family not supported",
- 124: "address family not supported by protocol family",
- 125: "address already in use",
- 126: "cannot assign requested address",
- 127: "network is down",
- 128: "network is unreachable",
- 129: "network dropped connection because of reset",
- 130: "software caused connection abort",
- 131: "connection reset by peer",
- 132: "no buffer space available",
- 133: "transport endpoint is already connected",
- 134: "transport endpoint is not connected",
- 143: "cannot send after socket shutdown",
- 144: "too many references: cannot splice",
- 145: "connection timed out",
- 146: "connection refused",
- 147: "host is down",
- 148: "no route to host",
- 149: "operation already in progress",
- 150: "operation now in progress",
- 151: "stale NFS file handle",
-}
-
-// Signal table
-var signals = [...]string{
- 1: "hangup",
- 2: "interrupt",
- 3: "quit",
- 4: "illegal Instruction",
- 5: "trace/Breakpoint Trap",
- 6: "abort",
- 7: "emulation Trap",
- 8: "arithmetic Exception",
- 9: "killed",
- 10: "bus Error",
- 11: "segmentation Fault",
- 12: "bad System Call",
- 13: "broken Pipe",
- 14: "alarm Clock",
- 15: "terminated",
- 16: "user Signal 1",
- 17: "user Signal 2",
- 18: "child Status Changed",
- 19: "power-Fail/Restart",
- 20: "window Size Change",
- 21: "urgent Socket Condition",
- 22: "pollable Event",
- 23: "stopped (signal)",
- 24: "stopped (user)",
- 25: "continued",
- 26: "stopped (tty input)",
- 27: "stopped (tty output)",
- 28: "virtual Timer Expired",
- 29: "profiling Timer Expired",
- 30: "cpu Limit Exceeded",
- 31: "file Size Limit Exceeded",
- 32: "no runnable lwp",
- 33: "inter-lwp signal",
- 34: "checkpoint Freeze",
- 35: "checkpoint Thaw",
- 36: "thread Cancellation",
- 37: "resource Lost",
- 38: "resource Control Exceeded",
- 39: "reserved for JVM 1",
- 40: "reserved for JVM 2",
- 41: "information Request",
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go
deleted file mode 100644
index 031034a3..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go
+++ /dev/null
@@ -1,1427 +0,0 @@
-// mksyscall.pl -l32 syscall_bsd.go syscall_darwin.go syscall_darwin_386.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build 386,darwin
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
- var _p0 unsafe.Pointer
- if len(mib) > 0 {
- _p0 = unsafe.Pointer(&mib[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
- use(_p0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, timeval *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe() (r int, w int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
- r = int(r0)
- w = int(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kill(pid int, signum int, posix int) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Access(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chflags(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chmod(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exchangedata(path1 string, path2 string, options int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path1)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(path2)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), uintptr(length>>32))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdtablesize() (size int) {
- r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
- size = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
- pgrp = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Issetugid() (tainted bool) {
- r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0)
- tainted = bool(r0 != 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Link(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdir(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkfifo(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pathconf(path string, name int) (val int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
- use(unsafe.Pointer(_p0))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlink(path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rename(from string, to string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(from)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(to)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Revoke(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rmdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0)
- newoffset = int64(int64(r1)<<32 | int64(r0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setegid(egid int) (err error) {
- _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setlogin(name string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(name)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setprivexec(flag int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, stat *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlink(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), uintptr(length>>32))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Undelete(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlink(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos), uintptr(pos>>32), 0, 0)
- ret = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) {
- r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- sec = int32(r0)
- usec = int32(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go
deleted file mode 100644
index ee96f78b..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go
+++ /dev/null
@@ -1,1443 +0,0 @@
-// mksyscall.pl syscall_bsd.go syscall_darwin.go syscall_darwin_amd64.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build amd64,darwin
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
- var _p0 unsafe.Pointer
- if len(mib) > 0 {
- _p0 = unsafe.Pointer(&mib[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
- use(_p0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, timeval *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe() (r int, w int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
- r = int(r0)
- w = int(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kill(pid int, signum int, posix int) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Access(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chflags(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chmod(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exchangedata(path1 string, path2 string, options int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path1)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(path2)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdtablesize() (size int) {
- r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
- size = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
- pgrp = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Issetugid() (tainted bool) {
- r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0)
- tainted = bool(r0 != 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Link(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdir(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkfifo(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pathconf(path string, name int) (val int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
- use(unsafe.Pointer(_p0))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlink(path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rename(from string, to string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(from)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(to)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Revoke(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rmdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
- newoffset = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setegid(egid int) (err error) {
- _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setlogin(name string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(name)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setprivexec(flag int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, stat *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlink(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Undelete(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlink(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
- ret = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
- r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- sec = int64(r0)
- usec = int32(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go
deleted file mode 100644
index e52cd0d5..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go
+++ /dev/null
@@ -1,1427 +0,0 @@
-// mksyscall.pl syscall_bsd.go syscall_darwin.go syscall_darwin_arm.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build arm,darwin
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
- var _p0 unsafe.Pointer
- if len(mib) > 0 {
- _p0 = unsafe.Pointer(&mib[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
- use(_p0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, timeval *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe() (r int, w int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
- r = int(r0)
- w = int(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kill(pid int, signum int, posix int) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Access(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chflags(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chmod(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exchangedata(path1 string, path2 string, options int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path1)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(path2)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdtablesize() (size int) {
- r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
- size = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
- pgrp = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Issetugid() (tainted bool) {
- r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0)
- tainted = bool(r0 != 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Link(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdir(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkfifo(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pathconf(path string, name int) (val int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
- use(unsafe.Pointer(_p0))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlink(path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rename(from string, to string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(from)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(to)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Revoke(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rmdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
- newoffset = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setegid(egid int) (err error) {
- _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setlogin(name string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(name)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setprivexec(flag int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, stat *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlink(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Undelete(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlink(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
- ret = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) {
- r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- sec = int32(r0)
- usec = int32(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go
deleted file mode 100644
index 9863ef99..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go
+++ /dev/null
@@ -1,1427 +0,0 @@
-// mksyscall.pl syscall_bsd.go syscall_darwin.go syscall_darwin_arm64.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build arm64,darwin
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
- var _p0 unsafe.Pointer
- if len(mib) > 0 {
- _p0 = unsafe.Pointer(&mib[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
- use(_p0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, timeval *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe() (r int, w int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
- r = int(r0)
- w = int(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kill(pid int, signum int, posix int) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Access(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chflags(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chmod(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exchangedata(path1 string, path2 string, options int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path1)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(path2)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdtablesize() (size int) {
- r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
- size = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
- pgrp = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Issetugid() (tainted bool) {
- r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0)
- tainted = bool(r0 != 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Link(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdir(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkfifo(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pathconf(path string, name int) (val int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
- use(unsafe.Pointer(_p0))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlink(path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rename(from string, to string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(from)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(to)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Revoke(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rmdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
- newoffset = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setegid(egid int) (err error) {
- _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setlogin(name string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(name)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setprivexec(flag int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, stat *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlink(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Undelete(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlink(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
- ret = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
- r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- sec = int64(r0)
- usec = int32(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go
deleted file mode 100644
index 78de48dc..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go
+++ /dev/null
@@ -1,1413 +0,0 @@
-// mksyscall.pl -dragonfly syscall_bsd.go syscall_dragonfly.go syscall_dragonfly_amd64.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build amd64,dragonfly
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
- var _p0 unsafe.Pointer
- if len(mib) > 0 {
- _p0 = unsafe.Pointer(&mib[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
- use(_p0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, timeval *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe() (r int, w int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
- r = int(r0)
- w = int(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func extpread(fd int, p []byte, flags int, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_EXTPREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(offset), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_EXTPWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(offset), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Access(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chflags(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chmod(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETDIRENTRIES, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdtablesize() (size int) {
- r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
- size = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
- pgrp = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Issetugid() (tainted bool) {
- r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0)
- tainted = bool(r0 != 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, signum syscall.Signal) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Link(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdir(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkfifo(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pathconf(path string, name int) (val int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
- use(unsafe.Pointer(_p0))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlink(path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rename(from string, to string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(from)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(to)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Revoke(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rmdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, _, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(whence), 0, 0)
- newoffset = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setegid(egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setlogin(name string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(name)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, stat *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlink(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Undelete(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlink(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), 0, 0)
- ret = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go
deleted file mode 100644
index fade994d..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go
+++ /dev/null
@@ -1,1665 +0,0 @@
-// mksyscall.pl -l32 syscall_bsd.go syscall_freebsd.go syscall_freebsd_386.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build 386,freebsd
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
- var _p0 unsafe.Pointer
- if len(mib) > 0 {
- _p0 = unsafe.Pointer(&mib[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
- use(_p0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, timeval *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe() (r int, w int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
- r = int(r0)
- w = int(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Access(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chflags(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chmod(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_GET_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_SET_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_EXTATTR_DELETE_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error) {
- r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_FD, uintptr(fd), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0)
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(file)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_GET_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(file)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_SET_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(file)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_EXTATTR_DELETE_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(file)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0)
- use(unsafe.Pointer(_p0))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_GET_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_SET_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_EXTATTR_DELETE_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0)
- use(unsafe.Pointer(_p0))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fadvise(fd int, offset int64, length int64, advice int) (err error) {
- _, _, e1 := Syscall6(SYS_POSIX_FADVISE, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32), uintptr(advice))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), uintptr(length>>32))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETDIRENTRIES, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdtablesize() (size int) {
- r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
- size = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
- pgrp = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Issetugid() (tainted bool) {
- r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0)
- tainted = bool(r0 != 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, signum syscall.Signal) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Link(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdir(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkfifo(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pathconf(path string, name int) (val int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
- use(unsafe.Pointer(_p0))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlink(path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rename(from string, to string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(from)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(to)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Revoke(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rmdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0)
- newoffset = int64(int64(r1)<<32 | int64(r0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setegid(egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setlogin(name string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(name)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, stat *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlink(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), uintptr(length>>32))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Undelete(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlink(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos), uintptr(pos>>32), 0, 0)
- ret = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) {
- r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go
deleted file mode 100644
index c28281e8..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go
+++ /dev/null
@@ -1,1665 +0,0 @@
-// mksyscall.pl syscall_bsd.go syscall_freebsd.go syscall_freebsd_amd64.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build amd64,freebsd
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
- var _p0 unsafe.Pointer
- if len(mib) > 0 {
- _p0 = unsafe.Pointer(&mib[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
- use(_p0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, timeval *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe() (r int, w int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
- r = int(r0)
- w = int(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Access(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chflags(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chmod(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_GET_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_SET_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_EXTATTR_DELETE_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error) {
- r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_FD, uintptr(fd), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0)
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(file)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_GET_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(file)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_SET_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(file)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_EXTATTR_DELETE_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(file)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0)
- use(unsafe.Pointer(_p0))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_GET_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_SET_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_EXTATTR_DELETE_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0)
- use(unsafe.Pointer(_p0))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fadvise(fd int, offset int64, length int64, advice int) (err error) {
- _, _, e1 := Syscall6(SYS_POSIX_FADVISE, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETDIRENTRIES, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdtablesize() (size int) {
- r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
- size = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
- pgrp = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Issetugid() (tainted bool) {
- r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0)
- tainted = bool(r0 != 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, signum syscall.Signal) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Link(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdir(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkfifo(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pathconf(path string, name int) (val int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
- use(unsafe.Pointer(_p0))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlink(path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rename(from string, to string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(from)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(to)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Revoke(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rmdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
- newoffset = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setegid(egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setlogin(name string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(name)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, stat *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlink(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Undelete(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlink(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
- ret = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) {
- r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go
deleted file mode 100644
index a18ba5c8..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go
+++ /dev/null
@@ -1,1665 +0,0 @@
-// mksyscall.pl -l32 -arm syscall_bsd.go syscall_freebsd.go syscall_freebsd_arm.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build arm,freebsd
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
- var _p0 unsafe.Pointer
- if len(mib) > 0 {
- _p0 = unsafe.Pointer(&mib[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
- use(_p0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, timeval *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe() (r int, w int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
- r = int(r0)
- w = int(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Access(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chflags(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chmod(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_GET_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_SET_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_EXTATTR_DELETE_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error) {
- r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_FD, uintptr(fd), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0)
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(file)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_GET_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(file)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_SET_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(file)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_EXTATTR_DELETE_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(file)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0)
- use(unsafe.Pointer(_p0))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_GET_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_SET_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attrname)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_EXTATTR_DELETE_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0)
- use(unsafe.Pointer(_p0))
- ret = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fadvise(fd int, offset int64, length int64, advice int) (err error) {
- _, _, e1 := Syscall9(SYS_POSIX_FADVISE, uintptr(fd), 0, uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32), uintptr(advice), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall6(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length), uintptr(length>>32), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETDIRENTRIES, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdtablesize() (size int) {
- r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
- size = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
- pgrp = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Issetugid() (tainted bool) {
- r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0)
- tainted = bool(r0 != 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, signum syscall.Signal) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Link(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdir(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkfifo(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pathconf(path string, name int) (val int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
- use(unsafe.Pointer(_p0))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlink(path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rename(from string, to string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(from)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(to)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Revoke(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rmdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(offset>>32), uintptr(whence), 0)
- newoffset = int64(int64(r1)<<32 | int64(r0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setegid(egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setlogin(name string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(name)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, stat *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlink(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length), uintptr(length>>32), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Undelete(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlink(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), uintptr(pos>>32), 0)
- ret = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) {
- r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go
deleted file mode 100644
index fa92387b..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go
+++ /dev/null
@@ -1,1671 +0,0 @@
-// mksyscall.pl -l32 syscall_linux.go syscall_linux_386.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build 386,linux
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0)
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlinkat(dirfd int, path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, times *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getcwd(buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(arg)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(source)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- var _p2 *byte
- _p2, err = BytePtrFromString(fstype)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- use(unsafe.Pointer(_p2))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Acct(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtimex(buf *Timex) (state int, err error) {
- r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0)
- state = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ClockGettime(clockid int32, time *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(oldfd int) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup3(oldfd int, newfd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate(size int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate1(flag int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
- _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fallocate(fd int, mode uint32, off int64, len int64) (err error) {
- _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(off>>32), uintptr(len), uintptr(len>>32))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fdatasync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettid() (tid int) {
- r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0)
- tid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(dest) > 0 {
- _p2 = unsafe.Pointer(&dest[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(pathname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask))
- use(unsafe.Pointer(_p0))
- watchdesc = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit1(flags int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0)
- success = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Klogctl(typ int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listxattr(path string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(dest) > 0 {
- _p1 = unsafe.Pointer(&dest[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)))
- use(unsafe.Pointer(_p0))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdirat(dirfd int, path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func PivotRoot(newroot string, putold string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(newroot)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(putold)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) {
- _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Removexattr(path string, attr string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setdomainname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sethostname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setns(fd int, nstype int) (err error) {
- _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setxattr(path string, attr string, data []byte, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(data) > 0 {
- _p2 = unsafe.Pointer(&data[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() {
- Syscall(SYS_SYNC, 0, 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sysinfo(info *Sysinfo_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) {
- r0, r1, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0)
- n = int64(int64(r1)<<32 | int64(r0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Times(tms *Tms) (ticks uintptr, err error) {
- r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0)
- ticks = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(mask int) (oldmask int) {
- r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Uname(buf *Utsname) (err error) {
- _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(target string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unshare(flags int) (err error) {
- _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ustat(dev int, ubuf *Ustat_t) (err error) {
- _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func exitThread(code int) (err error) {
- _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Madvise(b []byte, advice int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe(p *[2]_C_int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe2(p *[2]_C_int, flags int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(oldfd int, newfd int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fadvise(fd int, offset int64, length int64, advice int) (err error) {
- _, _, e1 := Syscall6(SYS_FADVISE64_64, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32), uintptr(advice))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN32, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE64, uintptr(fd), uintptr(length), uintptr(length>>32))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID32, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (euid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID32, 0, 0, 0)
- euid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID32, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID32, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit() (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ioperm(from int, num int, on int) (err error) {
- _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Iopl(level int) (err error) {
- _, _, e1 := Syscall(SYS_IOPL, uintptr(level), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN32, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- r0, _, e1 := Syscall6(SYS_SENDFILE64, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
- written = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsgid(gid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSGID32, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsuid(uid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSUID32, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID32, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID32, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID32, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID32, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
- _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(off>>32), uintptr(n), uintptr(n>>32), uintptr(flags))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE64, uintptr(unsafe.Pointer(_p0)), uintptr(length), uintptr(length>>32))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(n int, list *_Gid_t) (nn int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS32, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- nn = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(n int, list *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS32, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
- r0, _, e1 := Syscall6(SYS__NEWSELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset))
- xaddr = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(events) > 0 {
- _p0 = unsafe.Pointer(&events[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pause() (err error) {
- _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getrlimit(resource int, rlim *rlimit32) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setrlimit(resource int, rlim *rlimit32) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Time(t *Time_t) (tt Time_t, err error) {
- r0, _, e1 := RawSyscall(SYS_TIME, uintptr(unsafe.Pointer(t)), 0, 0)
- tt = Time_t(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Utime(path string, buf *Utimbuf) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go
deleted file mode 100644
index b34d5c26..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go
+++ /dev/null
@@ -1,1865 +0,0 @@
-// mksyscall.pl syscall_linux.go syscall_linux_amd64.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build amd64,linux
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0)
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlinkat(dirfd int, path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, times *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getcwd(buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(arg)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(source)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- var _p2 *byte
- _p2, err = BytePtrFromString(fstype)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- use(unsafe.Pointer(_p2))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Acct(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtimex(buf *Timex) (state int, err error) {
- r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0)
- state = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ClockGettime(clockid int32, time *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(oldfd int) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup3(oldfd int, newfd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate(size int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate1(flag int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
- _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fallocate(fd int, mode uint32, off int64, len int64) (err error) {
- _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fdatasync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettid() (tid int) {
- r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0)
- tid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(dest) > 0 {
- _p2 = unsafe.Pointer(&dest[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(pathname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask))
- use(unsafe.Pointer(_p0))
- watchdesc = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit1(flags int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0)
- success = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Klogctl(typ int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listxattr(path string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(dest) > 0 {
- _p1 = unsafe.Pointer(&dest[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)))
- use(unsafe.Pointer(_p0))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdirat(dirfd int, path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func PivotRoot(newroot string, putold string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(newroot)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(putold)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) {
- _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Removexattr(path string, attr string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setdomainname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sethostname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setns(fd int, nstype int) (err error) {
- _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setxattr(path string, attr string, data []byte, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(data) > 0 {
- _p2 = unsafe.Pointer(&data[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() {
- Syscall(SYS_SYNC, 0, 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sysinfo(info *Sysinfo_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0)
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Times(tms *Tms) (ticks uintptr, err error) {
- r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0)
- ticks = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(mask int) (oldmask int) {
- r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Uname(buf *Utsname) (err error) {
- _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(target string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unshare(flags int) (err error) {
- _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ustat(dev int, ubuf *Ustat_t) (err error) {
- _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func exitThread(code int) (err error) {
- _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Madvise(b []byte, advice int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(oldfd int, newfd int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(events) > 0 {
- _p0 = unsafe.Pointer(&events[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fadvise(fd int, offset int64, length int64, advice int) (err error) {
- _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, buf *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (euid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- euid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit() (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ioperm(from int, num int, on int) (err error) {
- _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Iopl(level int) (err error) {
- _, _, e1 := Syscall(SYS_IOPL, uintptr(level), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, n int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pause() (err error) {
- _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (off int64, err error) {
- r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
- off = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
- written = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsgid(gid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsuid(uid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, buf *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
- _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
- r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(n int, list *_Gid_t) (nn int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- nn = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(n int, list *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset))
- xaddr = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Utime(path string, buf *Utimbuf) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe(p *[2]_C_int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe2(p *[2]_C_int, flags int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go
deleted file mode 100644
index 2e5cb398..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go
+++ /dev/null
@@ -1,1772 +0,0 @@
-// mksyscall.pl -l32 -arm syscall_linux.go syscall_linux_arm.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build arm,linux
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0)
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlinkat(dirfd int, path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, times *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getcwd(buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(arg)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(source)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- var _p2 *byte
- _p2, err = BytePtrFromString(fstype)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- use(unsafe.Pointer(_p2))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Acct(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtimex(buf *Timex) (state int, err error) {
- r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0)
- state = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ClockGettime(clockid int32, time *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(oldfd int) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup3(oldfd int, newfd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate(size int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate1(flag int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
- _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fallocate(fd int, mode uint32, off int64, len int64) (err error) {
- _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(off>>32), uintptr(len), uintptr(len>>32))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fdatasync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettid() (tid int) {
- r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0)
- tid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(dest) > 0 {
- _p2 = unsafe.Pointer(&dest[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(pathname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask))
- use(unsafe.Pointer(_p0))
- watchdesc = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit1(flags int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0)
- success = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Klogctl(typ int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listxattr(path string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(dest) > 0 {
- _p1 = unsafe.Pointer(&dest[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)))
- use(unsafe.Pointer(_p0))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdirat(dirfd int, path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func PivotRoot(newroot string, putold string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(newroot)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(putold)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) {
- _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Removexattr(path string, attr string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setdomainname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sethostname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setns(fd int, nstype int) (err error) {
- _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setxattr(path string, attr string, data []byte, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(data) > 0 {
- _p2 = unsafe.Pointer(&data[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() {
- Syscall(SYS_SYNC, 0, 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sysinfo(info *Sysinfo_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) {
- r0, r1, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0)
- n = int64(int64(r1)<<32 | int64(r0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Times(tms *Tms) (ticks uintptr, err error) {
- r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0)
- ticks = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(mask int) (oldmask int) {
- r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Uname(buf *Utsname) (err error) {
- _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(target string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unshare(flags int) (err error) {
- _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ustat(dev int, ubuf *Ustat_t) (err error) {
- _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func exitThread(code int) (err error) {
- _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Madvise(b []byte, advice int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe2(p *[2]_C_int, flags int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
- r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(n int, list *_Gid_t) (nn int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS32, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- nn = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(n int, list *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS32, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, flags int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(oldfd int, newfd int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN32, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID32, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (euid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID32, 0, 0, 0)
- euid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID32, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID32, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit() (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN32, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, n int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- r0, _, e1 := Syscall6(SYS_SENDFILE64, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
- written = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
- r0, _, e1 := Syscall6(SYS__NEWSELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsgid(gid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSGID32, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsuid(uid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSUID32, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID32, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID32, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID32, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID32, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(events) > 0 {
- _p0 = unsafe.Pointer(&events[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pause() (err error) {
- _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_TRUNCATE64, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length), uintptr(length>>32), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall6(SYS_FTRUNCATE64, uintptr(fd), 0, uintptr(length), uintptr(length>>32), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset))
- xaddr = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getrlimit(resource int, rlim *rlimit32) (err error) {
- _, _, e1 := RawSyscall(SYS_UGETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setrlimit(resource int, rlim *rlimit32) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go
deleted file mode 100644
index 0d584cc0..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go
+++ /dev/null
@@ -1,1745 +0,0 @@
-// mksyscall.pl syscall_linux.go syscall_linux_arm64.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build arm64,linux
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0)
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlinkat(dirfd int, path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, times *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getcwd(buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(arg)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(source)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- var _p2 *byte
- _p2, err = BytePtrFromString(fstype)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- use(unsafe.Pointer(_p2))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Acct(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtimex(buf *Timex) (state int, err error) {
- r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0)
- state = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ClockGettime(clockid int32, time *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(oldfd int) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup3(oldfd int, newfd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate(size int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate1(flag int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
- _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fallocate(fd int, mode uint32, off int64, len int64) (err error) {
- _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fdatasync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettid() (tid int) {
- r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0)
- tid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(dest) > 0 {
- _p2 = unsafe.Pointer(&dest[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(pathname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask))
- use(unsafe.Pointer(_p0))
- watchdesc = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit1(flags int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0)
- success = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Klogctl(typ int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listxattr(path string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(dest) > 0 {
- _p1 = unsafe.Pointer(&dest[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)))
- use(unsafe.Pointer(_p0))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdirat(dirfd int, path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func PivotRoot(newroot string, putold string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(newroot)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(putold)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) {
- _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Removexattr(path string, attr string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setdomainname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sethostname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setns(fd int, nstype int) (err error) {
- _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setxattr(path string, attr string, data []byte, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(data) > 0 {
- _p2 = unsafe.Pointer(&data[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() {
- Syscall(SYS_SYNC, 0, 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sysinfo(info *Sysinfo_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0)
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Times(tms *Tms) (ticks uintptr, err error) {
- r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0)
- ticks = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(mask int) (oldmask int) {
- r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Uname(buf *Utsname) (err error) {
- _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(target string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unshare(flags int) (err error) {
- _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ustat(dev int, ubuf *Ustat_t) (err error) {
- _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func exitThread(code int) (err error) {
- _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Madvise(b []byte, advice int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(events) > 0 {
- _p0 = unsafe.Pointer(&events[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_EPOLL_PWAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FSTATAT, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, buf *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (euid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- euid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, n int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (off int64, err error) {
- r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
- off = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
- written = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsgid(gid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsuid(uid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, buf *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
- _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
- r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(n int, list *_Gid_t) (nn int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- nn = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(n int, list *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset))
- xaddr = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe2(p *[2]_C_int, flags int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go
deleted file mode 100644
index bf6f3603..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go
+++ /dev/null
@@ -1,1814 +0,0 @@
-// mksyscall.pl syscall_linux.go syscall_linux_mips64x.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build mips64,linux
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0)
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlinkat(dirfd int, path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, times *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getcwd(buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(arg)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(source)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- var _p2 *byte
- _p2, err = BytePtrFromString(fstype)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- use(unsafe.Pointer(_p2))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Acct(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtimex(buf *Timex) (state int, err error) {
- r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0)
- state = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ClockGettime(clockid int32, time *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(oldfd int) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup3(oldfd int, newfd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate(size int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate1(flag int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
- _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fallocate(fd int, mode uint32, off int64, len int64) (err error) {
- _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fdatasync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettid() (tid int) {
- r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0)
- tid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(dest) > 0 {
- _p2 = unsafe.Pointer(&dest[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(pathname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask))
- use(unsafe.Pointer(_p0))
- watchdesc = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit1(flags int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0)
- success = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Klogctl(typ int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listxattr(path string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(dest) > 0 {
- _p1 = unsafe.Pointer(&dest[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)))
- use(unsafe.Pointer(_p0))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdirat(dirfd int, path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func PivotRoot(newroot string, putold string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(newroot)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(putold)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) {
- _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Removexattr(path string, attr string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setdomainname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sethostname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setns(fd int, nstype int) (err error) {
- _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setxattr(path string, attr string, data []byte, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(data) > 0 {
- _p2 = unsafe.Pointer(&data[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() {
- Syscall(SYS_SYNC, 0, 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sysinfo(info *Sysinfo_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0)
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Times(tms *Tms) (ticks uintptr, err error) {
- r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0)
- ticks = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(mask int) (oldmask int) {
- r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Uname(buf *Utsname) (err error) {
- _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(target string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unshare(flags int) (err error) {
- _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ustat(dev int, ubuf *Ustat_t) (err error) {
- _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func exitThread(code int) (err error) {
- _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Madvise(b []byte, advice int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(events) > 0 {
- _p0 = unsafe.Pointer(&events[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, buf *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (euid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- euid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, n int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pause() (err error) {
- _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (off int64, err error) {
- r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
- off = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
- written = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsgid(gid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsuid(uid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, buf *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
- _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
- r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(n int, list *_Gid_t) (nn int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- nn = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(n int, list *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset))
- xaddr = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Utime(path string, buf *Utimbuf) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe2(p *[2]_C_int, flags int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fstat(fd int, st *stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(st)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func lstat(path string, st *stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(st)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func stat(path string, st *stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(st)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go
deleted file mode 100644
index 8c86bd70..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go
+++ /dev/null
@@ -1,1814 +0,0 @@
-// mksyscall.pl syscall_linux.go syscall_linux_mips64x.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build mips64le,linux
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0)
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlinkat(dirfd int, path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, times *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getcwd(buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(arg)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(source)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- var _p2 *byte
- _p2, err = BytePtrFromString(fstype)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- use(unsafe.Pointer(_p2))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Acct(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtimex(buf *Timex) (state int, err error) {
- r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0)
- state = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ClockGettime(clockid int32, time *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(oldfd int) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup3(oldfd int, newfd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate(size int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate1(flag int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
- _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fallocate(fd int, mode uint32, off int64, len int64) (err error) {
- _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fdatasync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettid() (tid int) {
- r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0)
- tid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(dest) > 0 {
- _p2 = unsafe.Pointer(&dest[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(pathname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask))
- use(unsafe.Pointer(_p0))
- watchdesc = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit1(flags int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0)
- success = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Klogctl(typ int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listxattr(path string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(dest) > 0 {
- _p1 = unsafe.Pointer(&dest[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)))
- use(unsafe.Pointer(_p0))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdirat(dirfd int, path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func PivotRoot(newroot string, putold string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(newroot)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(putold)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) {
- _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Removexattr(path string, attr string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setdomainname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sethostname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setns(fd int, nstype int) (err error) {
- _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setxattr(path string, attr string, data []byte, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(data) > 0 {
- _p2 = unsafe.Pointer(&data[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() {
- Syscall(SYS_SYNC, 0, 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sysinfo(info *Sysinfo_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0)
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Times(tms *Tms) (ticks uintptr, err error) {
- r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0)
- ticks = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(mask int) (oldmask int) {
- r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Uname(buf *Utsname) (err error) {
- _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(target string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unshare(flags int) (err error) {
- _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ustat(dev int, ubuf *Ustat_t) (err error) {
- _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func exitThread(code int) (err error) {
- _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Madvise(b []byte, advice int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(events) > 0 {
- _p0 = unsafe.Pointer(&events[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, buf *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (euid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- euid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, n int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pause() (err error) {
- _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (off int64, err error) {
- r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
- off = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
- written = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsgid(gid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsuid(uid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, buf *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
- _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
- r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(n int, list *_Gid_t) (nn int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- nn = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(n int, list *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset))
- xaddr = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Utime(path string, buf *Utimbuf) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe2(p *[2]_C_int, flags int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fstat(fd int, st *stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(st)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func lstat(path string, st *stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(st)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func stat(path string, st *stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(st)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go
deleted file mode 100644
index f5d488b4..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go
+++ /dev/null
@@ -1,1876 +0,0 @@
-// mksyscall.pl syscall_linux.go syscall_linux_ppc64x.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build ppc64,linux
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0)
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlinkat(dirfd int, path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, times *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getcwd(buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(arg)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(source)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- var _p2 *byte
- _p2, err = BytePtrFromString(fstype)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- use(unsafe.Pointer(_p2))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Acct(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtimex(buf *Timex) (state int, err error) {
- r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0)
- state = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ClockGettime(clockid int32, time *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(oldfd int) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup3(oldfd int, newfd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate(size int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate1(flag int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
- _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fallocate(fd int, mode uint32, off int64, len int64) (err error) {
- _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fdatasync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettid() (tid int) {
- r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0)
- tid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(dest) > 0 {
- _p2 = unsafe.Pointer(&dest[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(pathname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask))
- use(unsafe.Pointer(_p0))
- watchdesc = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit1(flags int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0)
- success = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Klogctl(typ int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listxattr(path string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(dest) > 0 {
- _p1 = unsafe.Pointer(&dest[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)))
- use(unsafe.Pointer(_p0))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdirat(dirfd int, path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func PivotRoot(newroot string, putold string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(newroot)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(putold)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) {
- _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Removexattr(path string, attr string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setdomainname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sethostname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setns(fd int, nstype int) (err error) {
- _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setxattr(path string, attr string, data []byte, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(data) > 0 {
- _p2 = unsafe.Pointer(&data[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() {
- Syscall(SYS_SYNC, 0, 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sysinfo(info *Sysinfo_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0)
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Times(tms *Tms) (ticks uintptr, err error) {
- r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0)
- ticks = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(mask int) (oldmask int) {
- r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Uname(buf *Utsname) (err error) {
- _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(target string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unshare(flags int) (err error) {
- _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ustat(dev int, ubuf *Ustat_t) (err error) {
- _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func exitThread(code int) (err error) {
- _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Madvise(b []byte, advice int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(events) > 0 {
- _p0 = unsafe.Pointer(&events[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(oldfd int, newfd int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, buf *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (euid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- euid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_UGETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit() (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ioperm(from int, num int, on int) (err error) {
- _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Iopl(level int) (err error) {
- _, _, e1 := Syscall(SYS_IOPL, uintptr(level), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, n int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pause() (err error) {
- _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (off int64, err error) {
- r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
- off = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
- written = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsgid(gid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsuid(uid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, buf *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
- _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
- r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(n int, list *_Gid_t) (nn int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- nn = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(n int, list *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset))
- xaddr = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Time(t *Time_t) (tt Time_t, err error) {
- r0, _, e1 := RawSyscall(SYS_TIME, uintptr(unsafe.Pointer(t)), 0, 0)
- tt = Time_t(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Utime(path string, buf *Utimbuf) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe(p *[2]_C_int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe2(p *[2]_C_int, flags int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go
deleted file mode 100644
index 5183711e..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go
+++ /dev/null
@@ -1,1876 +0,0 @@
-// mksyscall.pl syscall_linux.go syscall_linux_ppc64x.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build ppc64le,linux
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0)
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlinkat(dirfd int, path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, times *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getcwd(buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(arg)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(source)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- var _p2 *byte
- _p2, err = BytePtrFromString(fstype)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- use(unsafe.Pointer(_p2))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Acct(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtimex(buf *Timex) (state int, err error) {
- r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0)
- state = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ClockGettime(clockid int32, time *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(oldfd int) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup3(oldfd int, newfd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate(size int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate1(flag int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
- _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fallocate(fd int, mode uint32, off int64, len int64) (err error) {
- _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fdatasync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettid() (tid int) {
- r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0)
- tid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(dest) > 0 {
- _p2 = unsafe.Pointer(&dest[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(pathname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask))
- use(unsafe.Pointer(_p0))
- watchdesc = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit1(flags int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0)
- success = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Klogctl(typ int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listxattr(path string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(dest) > 0 {
- _p1 = unsafe.Pointer(&dest[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)))
- use(unsafe.Pointer(_p0))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdirat(dirfd int, path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func PivotRoot(newroot string, putold string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(newroot)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(putold)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) {
- _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Removexattr(path string, attr string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setdomainname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sethostname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setns(fd int, nstype int) (err error) {
- _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setxattr(path string, attr string, data []byte, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(data) > 0 {
- _p2 = unsafe.Pointer(&data[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() {
- Syscall(SYS_SYNC, 0, 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sysinfo(info *Sysinfo_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0)
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Times(tms *Tms) (ticks uintptr, err error) {
- r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0)
- ticks = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(mask int) (oldmask int) {
- r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Uname(buf *Utsname) (err error) {
- _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(target string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unshare(flags int) (err error) {
- _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ustat(dev int, ubuf *Ustat_t) (err error) {
- _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func exitThread(code int) (err error) {
- _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Madvise(b []byte, advice int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(events) > 0 {
- _p0 = unsafe.Pointer(&events[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(oldfd int, newfd int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, buf *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (euid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- euid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_UGETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit() (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ioperm(from int, num int, on int) (err error) {
- _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Iopl(level int) (err error) {
- _, _, e1 := Syscall(SYS_IOPL, uintptr(level), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, n int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pause() (err error) {
- _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (off int64, err error) {
- r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
- off = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
- written = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsgid(gid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsuid(uid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, buf *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
- _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
- r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(n int, list *_Gid_t) (nn int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- nn = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(n int, list *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset))
- xaddr = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Time(t *Time_t) (tt Time_t, err error) {
- r0, _, e1 := RawSyscall(SYS_TIME, uintptr(unsafe.Pointer(t)), 0, 0)
- tt = Time_t(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Utime(path string, buf *Utimbuf) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe(p *[2]_C_int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe2(p *[2]_C_int, flags int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go
deleted file mode 100644
index 4c7ed08c..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go
+++ /dev/null
@@ -1,1656 +0,0 @@
-// mksyscall.pl syscall_linux.go syscall_linux_s390x.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build s390x,linux
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0)
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlinkat(dirfd int, path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, times *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getcwd(buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(arg)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(source)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- var _p2 *byte
- _p2, err = BytePtrFromString(fstype)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- use(unsafe.Pointer(_p2))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Acct(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtimex(buf *Timex) (state int, err error) {
- r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0)
- state = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ClockGettime(clockid int32, time *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(oldfd int) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup3(oldfd int, newfd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate(size int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate1(flag int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
- _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fallocate(fd int, mode uint32, off int64, len int64) (err error) {
- _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fdatasync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettid() (tid int) {
- r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0)
- tid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(dest) > 0 {
- _p2 = unsafe.Pointer(&dest[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(pathname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask))
- use(unsafe.Pointer(_p0))
- watchdesc = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit1(flags int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0)
- success = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Klogctl(typ int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listxattr(path string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(dest) > 0 {
- _p1 = unsafe.Pointer(&dest[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)))
- use(unsafe.Pointer(_p0))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdirat(dirfd int, path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func PivotRoot(newroot string, putold string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(newroot)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(putold)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) {
- _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Removexattr(path string, attr string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setdomainname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sethostname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setns(fd int, nstype int) (err error) {
- _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setxattr(path string, attr string, data []byte, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(data) > 0 {
- _p2 = unsafe.Pointer(&data[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() {
- Syscall(SYS_SYNC, 0, 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sysinfo(info *Sysinfo_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0)
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Times(tms *Tms) (ticks uintptr, err error) {
- r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0)
- ticks = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(mask int) (oldmask int) {
- r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Uname(buf *Utsname) (err error) {
- _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(target string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unshare(flags int) (err error) {
- _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ustat(dev int, ubuf *Ustat_t) (err error) {
- _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func exitThread(code int) (err error) {
- _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Madvise(b []byte, advice int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(oldfd int, newfd int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(events) > 0 {
- _p0 = unsafe.Pointer(&events[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fadvise(fd int, offset int64, length int64, advice int) (err error) {
- _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, buf *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (euid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- euid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit() (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pause() (err error) {
- _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (off int64, err error) {
- r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
- off = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
- written = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsgid(gid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsuid(uid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, buf *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
- _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(n int, list *_Gid_t) (nn int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- nn = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(n int, list *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Utime(path string, buf *Utimbuf) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe2(p *[2]_C_int, flags int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go
deleted file mode 100644
index beb83e4f..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go
+++ /dev/null
@@ -1,1845 +0,0 @@
-// mksyscall.pl syscall_linux.go syscall_linux_sparc64.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build sparc64,linux
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0)
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlinkat(dirfd int, path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, times *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getcwd(buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(arg)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(source)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- var _p2 *byte
- _p2, err = BytePtrFromString(fstype)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- use(unsafe.Pointer(_p2))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Acct(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtimex(buf *Timex) (state int, err error) {
- r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0)
- state = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func ClockGettime(clockid int32, time *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(oldfd int) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup3(oldfd int, newfd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate(size int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCreate1(flag int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
- _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fallocate(fd int, mode uint32, off int64, len int64) (err error) {
- _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fdatasync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettid() (tid int) {
- r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0)
- tid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(dest) > 0 {
- _p2 = unsafe.Pointer(&dest[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(pathname)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask))
- use(unsafe.Pointer(_p0))
- watchdesc = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit1(flags int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0)
- success = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Klogctl(typ int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listxattr(path string, dest []byte) (sz int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(dest) > 0 {
- _p1 = unsafe.Pointer(&dest[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)))
- use(unsafe.Pointer(_p0))
- sz = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdirat(dirfd int, path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func PivotRoot(newroot string, putold string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(newroot)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(putold)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) {
- _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Removexattr(path string, attr string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setdomainname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sethostname(p []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setns(fd int, nstype int) (err error) {
- _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setxattr(path string, attr string, data []byte, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(attr)
- if err != nil {
- return
- }
- var _p2 unsafe.Pointer
- if len(data) > 0 {
- _p2 = unsafe.Pointer(&data[0])
- } else {
- _p2 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() {
- Syscall(SYS_SYNC, 0, 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sysinfo(info *Sysinfo_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0)
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
- _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Times(tms *Tms) (ticks uintptr, err error) {
- r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0)
- ticks = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(mask int) (oldmask int) {
- r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Uname(buf *Utsname) (err error) {
- _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(target string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unshare(flags int) (err error) {
- _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ustat(dev int, ubuf *Ustat_t) (err error) {
- _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func exitThread(code int) (err error) {
- _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, p *byte, np int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Madvise(b []byte, advice int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(events) > 0 {
- _p0 = unsafe.Pointer(&events[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(oldfd int, newfd int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, buf *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (euid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- euid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func InotifyInit() (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, n int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pause() (err error) {
- _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (off int64, err error) {
- r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
- off = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
- written = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsgid(gid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setfsuid(uid int) (err error) {
- _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(resource int, rlim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
- r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
- n = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, buf *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
- _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
- r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(n int, list *_Gid_t) (nn int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- nn = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(n int, list *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset))
- xaddr = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Utime(path string, buf *Utimbuf) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe(p *[2]_C_int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe2(p *[2]_C_int, flags int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go
deleted file mode 100644
index b16e1d0e..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go
+++ /dev/null
@@ -1,1327 +0,0 @@
-// mksyscall.pl -l32 -netbsd syscall_bsd.go syscall_netbsd.go syscall_netbsd_386.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build 386,netbsd
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
- var _p0 unsafe.Pointer
- if len(mib) > 0 {
- _p0 = unsafe.Pointer(&mib[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
- use(_p0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, timeval *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe() (fd1 int, fd2 int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
- fd1 = int(r0)
- fd2 = int(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Access(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chflags(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chmod(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall6(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length), uintptr(length>>32), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
- pgrp = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Issetugid() (tainted bool) {
- r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0)
- tainted = bool(r0 != 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, signum syscall.Signal) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Link(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdir(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkfifo(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pathconf(path string, name int) (val int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
- use(unsafe.Pointer(_p0))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlink(path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rename(from string, to string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(from)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(to)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Revoke(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rmdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(offset>>32), uintptr(whence), 0)
- newoffset = int64(int64(r1)<<32 | int64(r0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setegid(egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlink(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length), uintptr(length>>32), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlink(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), uintptr(pos>>32), 0)
- ret = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go
deleted file mode 100644
index b63667da..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go
+++ /dev/null
@@ -1,1327 +0,0 @@
-// mksyscall.pl -netbsd syscall_bsd.go syscall_netbsd.go syscall_netbsd_amd64.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build amd64,netbsd
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
- var _p0 unsafe.Pointer
- if len(mib) > 0 {
- _p0 = unsafe.Pointer(&mib[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
- use(_p0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, timeval *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe() (fd1 int, fd2 int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
- fd1 = int(r0)
- fd2 = int(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Access(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chflags(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chmod(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
- pgrp = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Issetugid() (tainted bool) {
- r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0)
- tainted = bool(r0 != 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, signum syscall.Signal) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Link(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdir(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkfifo(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pathconf(path string, name int) (val int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
- use(unsafe.Pointer(_p0))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlink(path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rename(from string, to string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(from)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(to)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Revoke(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rmdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, _, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(whence), 0, 0)
- newoffset = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setegid(egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlink(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlink(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), 0, 0)
- ret = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go
deleted file mode 100644
index b0d19038..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go
+++ /dev/null
@@ -1,1327 +0,0 @@
-// mksyscall.pl -l32 -arm syscall_bsd.go syscall_netbsd.go syscall_netbsd_arm.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build arm,netbsd
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
- var _p0 unsafe.Pointer
- if len(mib) > 0 {
- _p0 = unsafe.Pointer(&mib[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
- use(_p0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, timeval *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe() (fd1 int, fd2 int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
- fd1 = int(r0)
- fd2 = int(r1)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Access(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chflags(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chmod(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall6(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length), uintptr(length>>32), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
- pgrp = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Issetugid() (tainted bool) {
- r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0)
- tainted = bool(r0 != 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, signum syscall.Signal) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Link(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdir(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkfifo(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pathconf(path string, name int) (val int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
- use(unsafe.Pointer(_p0))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlink(path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rename(from string, to string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(from)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(to)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Revoke(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rmdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(offset>>32), uintptr(whence), 0)
- newoffset = int64(int64(r1)<<32 | int64(r0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setegid(egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlink(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length), uintptr(length>>32), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlink(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), uintptr(pos>>32), 0)
- ret = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go
deleted file mode 100644
index f91a5b85..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go
+++ /dev/null
@@ -1,1387 +0,0 @@
-// mksyscall.pl -l32 -openbsd syscall_bsd.go syscall_openbsd.go syscall_openbsd_386.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build 386,openbsd
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
- var _p0 unsafe.Pointer
- if len(mib) > 0 {
- _p0 = unsafe.Pointer(&mib[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
- use(_p0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, timeval *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe(p *[2]_C_int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Access(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chflags(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chmod(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall6(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length), uintptr(length>>32), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
- pgrp = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Issetugid() (tainted bool) {
- r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0)
- tainted = bool(r0 != 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, signum syscall.Signal) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Link(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdir(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkfifo(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pathconf(path string, name int) (val int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
- use(unsafe.Pointer(_p0))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlink(path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rename(from string, to string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(from)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(to)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Revoke(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rmdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(offset>>32), uintptr(whence), 0)
- newoffset = int64(int64(r1)<<32 | int64(r0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setegid(egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setlogin(name string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(name)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, stat *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlink(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length), uintptr(length>>32), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlink(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), uintptr(pos>>32), 0)
- ret = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go
deleted file mode 100644
index 2e8d59d7..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go
+++ /dev/null
@@ -1,1387 +0,0 @@
-// mksyscall.pl -openbsd syscall_bsd.go syscall_openbsd.go syscall_openbsd_amd64.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build amd64,openbsd
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-var _ syscall.Errno
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
- var _p0 unsafe.Pointer
- if len(mib) > 0 {
- _p0 = unsafe.Pointer(&mib[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
- use(_p0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func utimes(path string, timeval *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func pipe(p *[2]_C_int) (err error) {
- _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func getdents(fd int, buf []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Access(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chflags(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chmod(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
- pgrp = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
- prio = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
- sid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Issetugid() (tainted bool) {
- r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0)
- tainted = bool(r0 != 0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kill(pid int, signum syscall.Signal) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Link(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkdir(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mkfifo(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlock(b []byte) (err error) {
- var _p0 unsafe.Pointer
- if len(b) > 0 {
- _p0 = unsafe.Pointer(&b[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pathconf(path string, name int) (val int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
- use(unsafe.Pointer(_p0))
- val = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Readlink(path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 unsafe.Pointer
- if len(buf) > 0 {
- _p1 = unsafe.Pointer(&buf[0])
- } else {
- _p1 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rename(from string, to string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(from)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(to)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Revoke(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Rmdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, _, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(whence), 0, 0)
- newoffset = int64(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setegid(egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setlogin(name string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(name)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresgid(rgid int, egid int, sgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setresuid(ruid int, euid int, suid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Statfs(path string, stat *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Symlink(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length))
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
- oldmask = int(r0)
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unlink(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func Unmount(path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(p) > 0 {
- _p0 = unsafe.Pointer(&p[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), 0, 0)
- ret = uintptr(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
-func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go b/newt/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go
deleted file mode 100644
index c0ecfc04..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go
+++ /dev/null
@@ -1,1599 +0,0 @@
-// mksyscall_solaris.pl syscall_solaris.go syscall_solaris_amd64.go
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-
-// +build amd64,solaris
-
-package unix
-
-import (
- "syscall"
- "unsafe"
-)
-
-//go:cgo_import_dynamic libc_pipe pipe "libc.so"
-//go:cgo_import_dynamic libc_getsockname getsockname "libsocket.so"
-//go:cgo_import_dynamic libc_getcwd getcwd "libc.so"
-//go:cgo_import_dynamic libc_getgroups getgroups "libc.so"
-//go:cgo_import_dynamic libc_setgroups setgroups "libc.so"
-//go:cgo_import_dynamic libc_wait4 wait4 "libc.so"
-//go:cgo_import_dynamic libc_gethostname gethostname "libc.so"
-//go:cgo_import_dynamic libc_utimes utimes "libc.so"
-//go:cgo_import_dynamic libc_utimensat utimensat "libc.so"
-//go:cgo_import_dynamic libc_fcntl fcntl "libc.so"
-//go:cgo_import_dynamic libc_futimesat futimesat "libc.so"
-//go:cgo_import_dynamic libc_accept accept "libsocket.so"
-//go:cgo_import_dynamic libc_recvmsg recvmsg "libsocket.so"
-//go:cgo_import_dynamic libc_sendmsg sendmsg "libsocket.so"
-//go:cgo_import_dynamic libc_acct acct "libc.so"
-//go:cgo_import_dynamic libc_ioctl ioctl "libc.so"
-//go:cgo_import_dynamic libc_access access "libc.so"
-//go:cgo_import_dynamic libc_adjtime adjtime "libc.so"
-//go:cgo_import_dynamic libc_chdir chdir "libc.so"
-//go:cgo_import_dynamic libc_chmod chmod "libc.so"
-//go:cgo_import_dynamic libc_chown chown "libc.so"
-//go:cgo_import_dynamic libc_chroot chroot "libc.so"
-//go:cgo_import_dynamic libc_close close "libc.so"
-//go:cgo_import_dynamic libc_creat creat "libc.so"
-//go:cgo_import_dynamic libc_dup dup "libc.so"
-//go:cgo_import_dynamic libc_dup2 dup2 "libc.so"
-//go:cgo_import_dynamic libc_exit exit "libc.so"
-//go:cgo_import_dynamic libc_fchdir fchdir "libc.so"
-//go:cgo_import_dynamic libc_fchmod fchmod "libc.so"
-//go:cgo_import_dynamic libc_fchmodat fchmodat "libc.so"
-//go:cgo_import_dynamic libc_fchown fchown "libc.so"
-//go:cgo_import_dynamic libc_fchownat fchownat "libc.so"
-//go:cgo_import_dynamic libc_fdatasync fdatasync "libc.so"
-//go:cgo_import_dynamic libc_fpathconf fpathconf "libc.so"
-//go:cgo_import_dynamic libc_fstat fstat "libc.so"
-//go:cgo_import_dynamic libc_getdents getdents "libc.so"
-//go:cgo_import_dynamic libc_getgid getgid "libc.so"
-//go:cgo_import_dynamic libc_getpid getpid "libc.so"
-//go:cgo_import_dynamic libc_getpgid getpgid "libc.so"
-//go:cgo_import_dynamic libc_getpgrp getpgrp "libc.so"
-//go:cgo_import_dynamic libc_geteuid geteuid "libc.so"
-//go:cgo_import_dynamic libc_getegid getegid "libc.so"
-//go:cgo_import_dynamic libc_getppid getppid "libc.so"
-//go:cgo_import_dynamic libc_getpriority getpriority "libc.so"
-//go:cgo_import_dynamic libc_getrlimit getrlimit "libc.so"
-//go:cgo_import_dynamic libc_getrusage getrusage "libc.so"
-//go:cgo_import_dynamic libc_gettimeofday gettimeofday "libc.so"
-//go:cgo_import_dynamic libc_getuid getuid "libc.so"
-//go:cgo_import_dynamic libc_kill kill "libc.so"
-//go:cgo_import_dynamic libc_lchown lchown "libc.so"
-//go:cgo_import_dynamic libc_link link "libc.so"
-//go:cgo_import_dynamic libc_listen listen "libsocket.so"
-//go:cgo_import_dynamic libc_lstat lstat "libc.so"
-//go:cgo_import_dynamic libc_madvise madvise "libc.so"
-//go:cgo_import_dynamic libc_mkdir mkdir "libc.so"
-//go:cgo_import_dynamic libc_mkdirat mkdirat "libc.so"
-//go:cgo_import_dynamic libc_mkfifo mkfifo "libc.so"
-//go:cgo_import_dynamic libc_mkfifoat mkfifoat "libc.so"
-//go:cgo_import_dynamic libc_mknod mknod "libc.so"
-//go:cgo_import_dynamic libc_mknodat mknodat "libc.so"
-//go:cgo_import_dynamic libc_mlock mlock "libc.so"
-//go:cgo_import_dynamic libc_mlockall mlockall "libc.so"
-//go:cgo_import_dynamic libc_mprotect mprotect "libc.so"
-//go:cgo_import_dynamic libc_munlock munlock "libc.so"
-//go:cgo_import_dynamic libc_munlockall munlockall "libc.so"
-//go:cgo_import_dynamic libc_nanosleep nanosleep "libc.so"
-//go:cgo_import_dynamic libc_open open "libc.so"
-//go:cgo_import_dynamic libc_openat openat "libc.so"
-//go:cgo_import_dynamic libc_pathconf pathconf "libc.so"
-//go:cgo_import_dynamic libc_pause pause "libc.so"
-//go:cgo_import_dynamic libc_pread pread "libc.so"
-//go:cgo_import_dynamic libc_pwrite pwrite "libc.so"
-//go:cgo_import_dynamic libc_read read "libc.so"
-//go:cgo_import_dynamic libc_readlink readlink "libc.so"
-//go:cgo_import_dynamic libc_rename rename "libc.so"
-//go:cgo_import_dynamic libc_renameat renameat "libc.so"
-//go:cgo_import_dynamic libc_rmdir rmdir "libc.so"
-//go:cgo_import_dynamic libc_lseek lseek "libc.so"
-//go:cgo_import_dynamic libc_setegid setegid "libc.so"
-//go:cgo_import_dynamic libc_seteuid seteuid "libc.so"
-//go:cgo_import_dynamic libc_setgid setgid "libc.so"
-//go:cgo_import_dynamic libc_sethostname sethostname "libc.so"
-//go:cgo_import_dynamic libc_setpgid setpgid "libc.so"
-//go:cgo_import_dynamic libc_setpriority setpriority "libc.so"
-//go:cgo_import_dynamic libc_setregid setregid "libc.so"
-//go:cgo_import_dynamic libc_setreuid setreuid "libc.so"
-//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so"
-//go:cgo_import_dynamic libc_setsid setsid "libc.so"
-//go:cgo_import_dynamic libc_setuid setuid "libc.so"
-//go:cgo_import_dynamic libc_shutdown shutdown "libsocket.so"
-//go:cgo_import_dynamic libc_stat stat "libc.so"
-//go:cgo_import_dynamic libc_symlink symlink "libc.so"
-//go:cgo_import_dynamic libc_sync sync "libc.so"
-//go:cgo_import_dynamic libc_times times "libc.so"
-//go:cgo_import_dynamic libc_truncate truncate "libc.so"
-//go:cgo_import_dynamic libc_fsync fsync "libc.so"
-//go:cgo_import_dynamic libc_ftruncate ftruncate "libc.so"
-//go:cgo_import_dynamic libc_umask umask "libc.so"
-//go:cgo_import_dynamic libc_uname uname "libc.so"
-//go:cgo_import_dynamic libc_umount umount "libc.so"
-//go:cgo_import_dynamic libc_unlink unlink "libc.so"
-//go:cgo_import_dynamic libc_unlinkat unlinkat "libc.so"
-//go:cgo_import_dynamic libc_ustat ustat "libc.so"
-//go:cgo_import_dynamic libc_utime utime "libc.so"
-//go:cgo_import_dynamic libc_bind bind "libsocket.so"
-//go:cgo_import_dynamic libc_connect connect "libsocket.so"
-//go:cgo_import_dynamic libc_mmap mmap "libc.so"
-//go:cgo_import_dynamic libc_munmap munmap "libc.so"
-//go:cgo_import_dynamic libc_sendto sendto "libsocket.so"
-//go:cgo_import_dynamic libc_socket socket "libsocket.so"
-//go:cgo_import_dynamic libc_socketpair socketpair "libsocket.so"
-//go:cgo_import_dynamic libc_write write "libc.so"
-//go:cgo_import_dynamic libc_getsockopt getsockopt "libsocket.so"
-//go:cgo_import_dynamic libc_getpeername getpeername "libsocket.so"
-//go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so"
-//go:cgo_import_dynamic libc_recvfrom recvfrom "libsocket.so"
-//go:cgo_import_dynamic libc_sysconf sysconf "libc.so"
-
-//go:linkname procpipe libc_pipe
-//go:linkname procgetsockname libc_getsockname
-//go:linkname procGetcwd libc_getcwd
-//go:linkname procgetgroups libc_getgroups
-//go:linkname procsetgroups libc_setgroups
-//go:linkname procwait4 libc_wait4
-//go:linkname procgethostname libc_gethostname
-//go:linkname procutimes libc_utimes
-//go:linkname procutimensat libc_utimensat
-//go:linkname procfcntl libc_fcntl
-//go:linkname procfutimesat libc_futimesat
-//go:linkname procaccept libc_accept
-//go:linkname procrecvmsg libc_recvmsg
-//go:linkname procsendmsg libc_sendmsg
-//go:linkname procacct libc_acct
-//go:linkname procioctl libc_ioctl
-//go:linkname procAccess libc_access
-//go:linkname procAdjtime libc_adjtime
-//go:linkname procChdir libc_chdir
-//go:linkname procChmod libc_chmod
-//go:linkname procChown libc_chown
-//go:linkname procChroot libc_chroot
-//go:linkname procClose libc_close
-//go:linkname procCreat libc_creat
-//go:linkname procDup libc_dup
-//go:linkname procDup2 libc_dup2
-//go:linkname procExit libc_exit
-//go:linkname procFchdir libc_fchdir
-//go:linkname procFchmod libc_fchmod
-//go:linkname procFchmodat libc_fchmodat
-//go:linkname procFchown libc_fchown
-//go:linkname procFchownat libc_fchownat
-//go:linkname procFdatasync libc_fdatasync
-//go:linkname procFpathconf libc_fpathconf
-//go:linkname procFstat libc_fstat
-//go:linkname procGetdents libc_getdents
-//go:linkname procGetgid libc_getgid
-//go:linkname procGetpid libc_getpid
-//go:linkname procGetpgid libc_getpgid
-//go:linkname procGetpgrp libc_getpgrp
-//go:linkname procGeteuid libc_geteuid
-//go:linkname procGetegid libc_getegid
-//go:linkname procGetppid libc_getppid
-//go:linkname procGetpriority libc_getpriority
-//go:linkname procGetrlimit libc_getrlimit
-//go:linkname procGetrusage libc_getrusage
-//go:linkname procGettimeofday libc_gettimeofday
-//go:linkname procGetuid libc_getuid
-//go:linkname procKill libc_kill
-//go:linkname procLchown libc_lchown
-//go:linkname procLink libc_link
-//go:linkname proclisten libc_listen
-//go:linkname procLstat libc_lstat
-//go:linkname procMadvise libc_madvise
-//go:linkname procMkdir libc_mkdir
-//go:linkname procMkdirat libc_mkdirat
-//go:linkname procMkfifo libc_mkfifo
-//go:linkname procMkfifoat libc_mkfifoat
-//go:linkname procMknod libc_mknod
-//go:linkname procMknodat libc_mknodat
-//go:linkname procMlock libc_mlock
-//go:linkname procMlockall libc_mlockall
-//go:linkname procMprotect libc_mprotect
-//go:linkname procMunlock libc_munlock
-//go:linkname procMunlockall libc_munlockall
-//go:linkname procNanosleep libc_nanosleep
-//go:linkname procOpen libc_open
-//go:linkname procOpenat libc_openat
-//go:linkname procPathconf libc_pathconf
-//go:linkname procPause libc_pause
-//go:linkname procPread libc_pread
-//go:linkname procPwrite libc_pwrite
-//go:linkname procread libc_read
-//go:linkname procReadlink libc_readlink
-//go:linkname procRename libc_rename
-//go:linkname procRenameat libc_renameat
-//go:linkname procRmdir libc_rmdir
-//go:linkname proclseek libc_lseek
-//go:linkname procSetegid libc_setegid
-//go:linkname procSeteuid libc_seteuid
-//go:linkname procSetgid libc_setgid
-//go:linkname procSethostname libc_sethostname
-//go:linkname procSetpgid libc_setpgid
-//go:linkname procSetpriority libc_setpriority
-//go:linkname procSetregid libc_setregid
-//go:linkname procSetreuid libc_setreuid
-//go:linkname procSetrlimit libc_setrlimit
-//go:linkname procSetsid libc_setsid
-//go:linkname procSetuid libc_setuid
-//go:linkname procshutdown libc_shutdown
-//go:linkname procStat libc_stat
-//go:linkname procSymlink libc_symlink
-//go:linkname procSync libc_sync
-//go:linkname procTimes libc_times
-//go:linkname procTruncate libc_truncate
-//go:linkname procFsync libc_fsync
-//go:linkname procFtruncate libc_ftruncate
-//go:linkname procUmask libc_umask
-//go:linkname procUname libc_uname
-//go:linkname procumount libc_umount
-//go:linkname procUnlink libc_unlink
-//go:linkname procUnlinkat libc_unlinkat
-//go:linkname procUstat libc_ustat
-//go:linkname procUtime libc_utime
-//go:linkname procbind libc_bind
-//go:linkname procconnect libc_connect
-//go:linkname procmmap libc_mmap
-//go:linkname procmunmap libc_munmap
-//go:linkname procsendto libc_sendto
-//go:linkname procsocket libc_socket
-//go:linkname procsocketpair libc_socketpair
-//go:linkname procwrite libc_write
-//go:linkname procgetsockopt libc_getsockopt
-//go:linkname procgetpeername libc_getpeername
-//go:linkname procsetsockopt libc_setsockopt
-//go:linkname procrecvfrom libc_recvfrom
-//go:linkname procsysconf libc_sysconf
-
-var (
- procpipe,
- procgetsockname,
- procGetcwd,
- procgetgroups,
- procsetgroups,
- procwait4,
- procgethostname,
- procutimes,
- procutimensat,
- procfcntl,
- procfutimesat,
- procaccept,
- procrecvmsg,
- procsendmsg,
- procacct,
- procioctl,
- procAccess,
- procAdjtime,
- procChdir,
- procChmod,
- procChown,
- procChroot,
- procClose,
- procCreat,
- procDup,
- procDup2,
- procExit,
- procFchdir,
- procFchmod,
- procFchmodat,
- procFchown,
- procFchownat,
- procFdatasync,
- procFpathconf,
- procFstat,
- procGetdents,
- procGetgid,
- procGetpid,
- procGetpgid,
- procGetpgrp,
- procGeteuid,
- procGetegid,
- procGetppid,
- procGetpriority,
- procGetrlimit,
- procGetrusage,
- procGettimeofday,
- procGetuid,
- procKill,
- procLchown,
- procLink,
- proclisten,
- procLstat,
- procMadvise,
- procMkdir,
- procMkdirat,
- procMkfifo,
- procMkfifoat,
- procMknod,
- procMknodat,
- procMlock,
- procMlockall,
- procMprotect,
- procMunlock,
- procMunlockall,
- procNanosleep,
- procOpen,
- procOpenat,
- procPathconf,
- procPause,
- procPread,
- procPwrite,
- procread,
- procReadlink,
- procRename,
- procRenameat,
- procRmdir,
- proclseek,
- procSetegid,
- procSeteuid,
- procSetgid,
- procSethostname,
- procSetpgid,
- procSetpriority,
- procSetregid,
- procSetreuid,
- procSetrlimit,
- procSetsid,
- procSetuid,
- procshutdown,
- procStat,
- procSymlink,
- procSync,
- procTimes,
- procTruncate,
- procFsync,
- procFtruncate,
- procUmask,
- procUname,
- procumount,
- procUnlink,
- procUnlinkat,
- procUstat,
- procUtime,
- procbind,
- procconnect,
- procmmap,
- procmunmap,
- procsendto,
- procsocket,
- procsocketpair,
- procwrite,
- procgetsockopt,
- procgetpeername,
- procsetsockopt,
- procrecvfrom,
- procsysconf syscallFunc
-)
-
-func pipe(p *[2]_C_int) (n int, err error) {
- r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procpipe)), 1, uintptr(unsafe.Pointer(p)), 0, 0, 0, 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetsockname)), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Getcwd(buf []byte) (n int, err error) {
- var _p0 *byte
- if len(buf) > 0 {
- _p0 = &buf[0]
- }
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procGetcwd)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), 0, 0, 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procgetgroups)), 2, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0, 0, 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procsetgroups)), 2, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func wait4(pid int32, statusp *_C_int, options int, rusage *Rusage) (wpid int32, err error) {
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procwait4)), 4, uintptr(pid), uintptr(unsafe.Pointer(statusp)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
- wpid = int32(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func gethostname(buf []byte) (n int, err error) {
- var _p0 *byte
- if len(buf) > 0 {
- _p0 = &buf[0]
- }
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgethostname)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), 0, 0, 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func utimes(path string, times *[2]Timeval) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procutimes)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func utimensat(fd int, path string, times *[2]Timespec, flag int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procutimensat)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flag), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0)
- val = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func futimesat(fildes int, path *byte, times *[2]Timeval) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfutimesat)), 3, uintptr(fildes), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)), 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procaccept)), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procrecvmsg)), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsendmsg)), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func acct(path *byte) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procacct)), 1, uintptr(unsafe.Pointer(path)), 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func ioctl(fd int, req int, arg uintptr) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procioctl)), 3, uintptr(fd), uintptr(req), uintptr(arg), 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Access(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procAccess)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procAdjtime)), 2, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Chdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procChdir)), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Chmod(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procChmod)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Chown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procChown)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Chroot(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procChroot)), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Close(fd int) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procClose)), 1, uintptr(fd), 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Creat(path string, mode uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procCreat)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procDup)), 1, uintptr(fd), 0, 0, 0, 0, 0)
- nfd = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Dup2(oldfd int, newfd int) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procDup2)), 2, uintptr(oldfd), uintptr(newfd), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Exit(code int) {
- sysvicall6(uintptr(unsafe.Pointer(&procExit)), 1, uintptr(code), 0, 0, 0, 0, 0)
- return
-}
-
-func Fchdir(fd int) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchdir)), 1, uintptr(fd), 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchmod)), 2, uintptr(fd), uintptr(mode), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchmodat)), 4, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchown)), 3, uintptr(fd), uintptr(uid), uintptr(gid), 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchownat)), 5, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Fdatasync(fd int) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFdatasync)), 1, uintptr(fd), 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFpathconf)), 2, uintptr(fd), uintptr(name), 0, 0, 0, 0)
- val = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFstat)), 2, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Getdents(fd int, buf []byte, basep *uintptr) (n int, err error) {
- var _p0 *byte
- if len(buf) > 0 {
- _p0 = &buf[0]
- }
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procGetdents)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Getgid() (gid int) {
- r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetgid)), 0, 0, 0, 0, 0, 0, 0)
- gid = int(r0)
- return
-}
-
-func Getpid() (pid int) {
- r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpid)), 0, 0, 0, 0, 0, 0, 0)
- pid = int(r0)
- return
-}
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpgid)), 1, uintptr(pid), 0, 0, 0, 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Getpgrp() (pgid int, err error) {
- r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpgrp)), 0, 0, 0, 0, 0, 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Geteuid() (euid int) {
- r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGeteuid)), 0, 0, 0, 0, 0, 0, 0)
- euid = int(r0)
- return
-}
-
-func Getegid() (egid int) {
- r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGetegid)), 0, 0, 0, 0, 0, 0, 0)
- egid = int(r0)
- return
-}
-
-func Getppid() (ppid int) {
- r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGetppid)), 0, 0, 0, 0, 0, 0, 0)
- ppid = int(r0)
- return
-}
-
-func Getpriority(which int, who int) (n int, err error) {
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procGetpriority)), 2, uintptr(which), uintptr(who), 0, 0, 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetrlimit)), 2, uintptr(which), uintptr(unsafe.Pointer(lim)), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetrusage)), 2, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Gettimeofday(tv *Timeval) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGettimeofday)), 1, uintptr(unsafe.Pointer(tv)), 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Getuid() (uid int) {
- r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetuid)), 0, 0, 0, 0, 0, 0, 0)
- uid = int(r0)
- return
-}
-
-func Kill(pid int, signum syscall.Signal) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procKill)), 2, uintptr(pid), uintptr(signum), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Lchown(path string, uid int, gid int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procLchown)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Link(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procLink)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Listen(s int, backlog int) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proclisten)), 2, uintptr(s), uintptr(backlog), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procLstat)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Madvise(b []byte, advice int) (err error) {
- var _p0 *byte
- if len(b) > 0 {
- _p0 = &b[0]
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMadvise)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(advice), 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Mkdir(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMkdir)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Mkdirat(dirfd int, path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMkdirat)), 3, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Mkfifo(path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMkfifo)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Mkfifoat(dirfd int, path string, mode uint32) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMkfifoat)), 3, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Mknod(path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMknod)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMknodat)), 4, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Mlock(b []byte) (err error) {
- var _p0 *byte
- if len(b) > 0 {
- _p0 = &b[0]
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMlock)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Mlockall(flags int) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMlockall)), 1, uintptr(flags), 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Mprotect(b []byte, prot int) (err error) {
- var _p0 *byte
- if len(b) > 0 {
- _p0 = &b[0]
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMprotect)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(prot), 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Munlock(b []byte) (err error) {
- var _p0 *byte
- if len(b) > 0 {
- _p0 = &b[0]
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMunlock)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Munlockall() (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMunlockall)), 0, 0, 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procNanosleep)), 2, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Open(path string, mode int, perm uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procOpen)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0, 0)
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procOpenat)), 4, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0)
- use(unsafe.Pointer(_p0))
- fd = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Pathconf(path string, name int) (val int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPathconf)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- val = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Pause() (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPause)), 0, 0, 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Pread(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 *byte
- if len(p) > 0 {
- _p0 = &p[0]
- }
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPread)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
- var _p0 *byte
- if len(p) > 0 {
- _p0 = &p[0]
- }
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPwrite)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func read(fd int, p []byte) (n int, err error) {
- var _p0 *byte
- if len(p) > 0 {
- _p0 = &p[0]
- }
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procread)), 3, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), 0, 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Readlink(path string, buf []byte) (n int, err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- if len(buf) > 0 {
- _p1 = &buf[0]
- }
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procReadlink)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(len(buf)), 0, 0, 0)
- use(unsafe.Pointer(_p0))
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Rename(from string, to string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(from)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(to)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procRename)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procRenameat)), 4, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Rmdir(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procRmdir)), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proclseek)), 3, uintptr(fd), uintptr(offset), uintptr(whence), 0, 0, 0)
- newoffset = int64(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Setegid(egid int) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetegid)), 1, uintptr(egid), 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Seteuid(euid int) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSeteuid)), 1, uintptr(euid), 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Setgid(gid int) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetgid)), 1, uintptr(gid), 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Sethostname(p []byte) (err error) {
- var _p0 *byte
- if len(p) > 0 {
- _p0 = &p[0]
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSethostname)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetpgid)), 2, uintptr(pid), uintptr(pgid), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSetpriority)), 3, uintptr(which), uintptr(who), uintptr(prio), 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetregid)), 2, uintptr(rgid), uintptr(egid), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetreuid)), 2, uintptr(ruid), uintptr(euid), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetrlimit)), 2, uintptr(which), uintptr(unsafe.Pointer(lim)), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Setsid() (pid int, err error) {
- r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetsid)), 0, 0, 0, 0, 0, 0, 0)
- pid = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Setuid(uid int) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetuid)), 1, uintptr(uid), 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Shutdown(s int, how int) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procshutdown)), 2, uintptr(s), uintptr(how), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procStat)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Symlink(path string, link string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = BytePtrFromString(link)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSymlink)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Sync() (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSync)), 0, 0, 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Times(tms *Tms) (ticks uintptr, err error) {
- r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procTimes)), 1, uintptr(unsafe.Pointer(tms)), 0, 0, 0, 0, 0)
- ticks = uintptr(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Truncate(path string, length int64) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procTruncate)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Fsync(fd int) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFsync)), 1, uintptr(fd), 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFtruncate)), 2, uintptr(fd), uintptr(length), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Umask(mask int) (oldmask int) {
- r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procUmask)), 1, uintptr(mask), 0, 0, 0, 0, 0)
- oldmask = int(r0)
- return
-}
-
-func Uname(buf *Utsname) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procUname)), 1, uintptr(unsafe.Pointer(buf)), 0, 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Unmount(target string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(target)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procumount)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Unlink(path string) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procUnlink)), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Unlinkat(dirfd int, path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procUnlinkat)), 3, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Ustat(dev int, ubuf *Ustat_t) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procUstat)), 2, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Utime(path string, buf *Utimbuf) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procUtime)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0, 0, 0, 0)
- use(unsafe.Pointer(_p0))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procbind)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procconnect)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procmmap)), 6, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
- ret = uintptr(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procmunmap)), 2, uintptr(addr), uintptr(length), 0, 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
- var _p0 *byte
- if len(buf) > 0 {
- _p0 = &buf[0]
- }
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsendto)), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsocket)), 3, uintptr(domain), uintptr(typ), uintptr(proto), 0, 0, 0)
- fd = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procsocketpair)), 4, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func write(fd int, p []byte) (n int, err error) {
- var _p0 *byte
- if len(p) > 0 {
- _p0 = &p[0]
- }
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procwrite)), 3, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), 0, 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procgetpeername)), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsetsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
- var _p0 *byte
- if len(p) > 0 {
- _p0 = &p[0]
- }
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procrecvfrom)), 6, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func sysconf(name int) (n int64, err error) {
- r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsysconf)), 1, uintptr(name), 0, 0, 0, 0, 0)
- n = int64(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go
deleted file mode 100644
index b8c9aea8..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go
+++ /dev/null
@@ -1,358 +0,0 @@
-// mksysnum_darwin.pl /usr/include/sys/syscall.h
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build arm,darwin
-
-package unix
-
-const (
- SYS_SYSCALL = 0
- SYS_EXIT = 1
- SYS_FORK = 2
- SYS_READ = 3
- SYS_WRITE = 4
- SYS_OPEN = 5
- SYS_CLOSE = 6
- SYS_WAIT4 = 7
- SYS_LINK = 9
- SYS_UNLINK = 10
- SYS_CHDIR = 12
- SYS_FCHDIR = 13
- SYS_MKNOD = 14
- SYS_CHMOD = 15
- SYS_CHOWN = 16
- SYS_GETFSSTAT = 18
- SYS_GETPID = 20
- SYS_SETUID = 23
- SYS_GETUID = 24
- SYS_GETEUID = 25
- SYS_PTRACE = 26
- SYS_RECVMSG = 27
- SYS_SENDMSG = 28
- SYS_RECVFROM = 29
- SYS_ACCEPT = 30
- SYS_GETPEERNAME = 31
- SYS_GETSOCKNAME = 32
- SYS_ACCESS = 33
- SYS_CHFLAGS = 34
- SYS_FCHFLAGS = 35
- SYS_SYNC = 36
- SYS_KILL = 37
- SYS_GETPPID = 39
- SYS_DUP = 41
- SYS_PIPE = 42
- SYS_GETEGID = 43
- SYS_SIGACTION = 46
- SYS_GETGID = 47
- SYS_SIGPROCMASK = 48
- SYS_GETLOGIN = 49
- SYS_SETLOGIN = 50
- SYS_ACCT = 51
- SYS_SIGPENDING = 52
- SYS_SIGALTSTACK = 53
- SYS_IOCTL = 54
- SYS_REBOOT = 55
- SYS_REVOKE = 56
- SYS_SYMLINK = 57
- SYS_READLINK = 58
- SYS_EXECVE = 59
- SYS_UMASK = 60
- SYS_CHROOT = 61
- SYS_MSYNC = 65
- SYS_VFORK = 66
- SYS_MUNMAP = 73
- SYS_MPROTECT = 74
- SYS_MADVISE = 75
- SYS_MINCORE = 78
- SYS_GETGROUPS = 79
- SYS_SETGROUPS = 80
- SYS_GETPGRP = 81
- SYS_SETPGID = 82
- SYS_SETITIMER = 83
- SYS_SWAPON = 85
- SYS_GETITIMER = 86
- SYS_GETDTABLESIZE = 89
- SYS_DUP2 = 90
- SYS_FCNTL = 92
- SYS_SELECT = 93
- SYS_FSYNC = 95
- SYS_SETPRIORITY = 96
- SYS_SOCKET = 97
- SYS_CONNECT = 98
- SYS_GETPRIORITY = 100
- SYS_BIND = 104
- SYS_SETSOCKOPT = 105
- SYS_LISTEN = 106
- SYS_SIGSUSPEND = 111
- SYS_GETTIMEOFDAY = 116
- SYS_GETRUSAGE = 117
- SYS_GETSOCKOPT = 118
- SYS_READV = 120
- SYS_WRITEV = 121
- SYS_SETTIMEOFDAY = 122
- SYS_FCHOWN = 123
- SYS_FCHMOD = 124
- SYS_SETREUID = 126
- SYS_SETREGID = 127
- SYS_RENAME = 128
- SYS_FLOCK = 131
- SYS_MKFIFO = 132
- SYS_SENDTO = 133
- SYS_SHUTDOWN = 134
- SYS_SOCKETPAIR = 135
- SYS_MKDIR = 136
- SYS_RMDIR = 137
- SYS_UTIMES = 138
- SYS_FUTIMES = 139
- SYS_ADJTIME = 140
- SYS_GETHOSTUUID = 142
- SYS_SETSID = 147
- SYS_GETPGID = 151
- SYS_SETPRIVEXEC = 152
- SYS_PREAD = 153
- SYS_PWRITE = 154
- SYS_NFSSVC = 155
- SYS_STATFS = 157
- SYS_FSTATFS = 158
- SYS_UNMOUNT = 159
- SYS_GETFH = 161
- SYS_QUOTACTL = 165
- SYS_MOUNT = 167
- SYS_CSOPS = 169
- SYS_CSOPS_AUDITTOKEN = 170
- SYS_WAITID = 173
- SYS_KDEBUG_TRACE = 180
- SYS_SETGID = 181
- SYS_SETEGID = 182
- SYS_SETEUID = 183
- SYS_SIGRETURN = 184
- SYS_CHUD = 185
- SYS_FDATASYNC = 187
- SYS_STAT = 188
- SYS_FSTAT = 189
- SYS_LSTAT = 190
- SYS_PATHCONF = 191
- SYS_FPATHCONF = 192
- SYS_GETRLIMIT = 194
- SYS_SETRLIMIT = 195
- SYS_GETDIRENTRIES = 196
- SYS_MMAP = 197
- SYS_LSEEK = 199
- SYS_TRUNCATE = 200
- SYS_FTRUNCATE = 201
- SYS___SYSCTL = 202
- SYS_MLOCK = 203
- SYS_MUNLOCK = 204
- SYS_UNDELETE = 205
- SYS_ATSOCKET = 206
- SYS_ATGETMSG = 207
- SYS_ATPUTMSG = 208
- SYS_ATPSNDREQ = 209
- SYS_ATPSNDRSP = 210
- SYS_ATPGETREQ = 211
- SYS_ATPGETRSP = 212
- SYS_OPEN_DPROTECTED_NP = 216
- SYS_GETATTRLIST = 220
- SYS_SETATTRLIST = 221
- SYS_GETDIRENTRIESATTR = 222
- SYS_EXCHANGEDATA = 223
- SYS_SEARCHFS = 225
- SYS_DELETE = 226
- SYS_COPYFILE = 227
- SYS_FGETATTRLIST = 228
- SYS_FSETATTRLIST = 229
- SYS_POLL = 230
- SYS_WATCHEVENT = 231
- SYS_WAITEVENT = 232
- SYS_MODWATCH = 233
- SYS_GETXATTR = 234
- SYS_FGETXATTR = 235
- SYS_SETXATTR = 236
- SYS_FSETXATTR = 237
- SYS_REMOVEXATTR = 238
- SYS_FREMOVEXATTR = 239
- SYS_LISTXATTR = 240
- SYS_FLISTXATTR = 241
- SYS_FSCTL = 242
- SYS_INITGROUPS = 243
- SYS_POSIX_SPAWN = 244
- SYS_FFSCTL = 245
- SYS_NFSCLNT = 247
- SYS_FHOPEN = 248
- SYS_MINHERIT = 250
- SYS_SEMSYS = 251
- SYS_MSGSYS = 252
- SYS_SHMSYS = 253
- SYS_SEMCTL = 254
- SYS_SEMGET = 255
- SYS_SEMOP = 256
- SYS_MSGCTL = 258
- SYS_MSGGET = 259
- SYS_MSGSND = 260
- SYS_MSGRCV = 261
- SYS_SHMAT = 262
- SYS_SHMCTL = 263
- SYS_SHMDT = 264
- SYS_SHMGET = 265
- SYS_SHM_OPEN = 266
- SYS_SHM_UNLINK = 267
- SYS_SEM_OPEN = 268
- SYS_SEM_CLOSE = 269
- SYS_SEM_UNLINK = 270
- SYS_SEM_WAIT = 271
- SYS_SEM_TRYWAIT = 272
- SYS_SEM_POST = 273
- SYS_SEM_GETVALUE = 274
- SYS_SEM_INIT = 275
- SYS_SEM_DESTROY = 276
- SYS_OPEN_EXTENDED = 277
- SYS_UMASK_EXTENDED = 278
- SYS_STAT_EXTENDED = 279
- SYS_LSTAT_EXTENDED = 280
- SYS_FSTAT_EXTENDED = 281
- SYS_CHMOD_EXTENDED = 282
- SYS_FCHMOD_EXTENDED = 283
- SYS_ACCESS_EXTENDED = 284
- SYS_SETTID = 285
- SYS_GETTID = 286
- SYS_SETSGROUPS = 287
- SYS_GETSGROUPS = 288
- SYS_SETWGROUPS = 289
- SYS_GETWGROUPS = 290
- SYS_MKFIFO_EXTENDED = 291
- SYS_MKDIR_EXTENDED = 292
- SYS_IDENTITYSVC = 293
- SYS_SHARED_REGION_CHECK_NP = 294
- SYS_VM_PRESSURE_MONITOR = 296
- SYS_PSYNCH_RW_LONGRDLOCK = 297
- SYS_PSYNCH_RW_YIELDWRLOCK = 298
- SYS_PSYNCH_RW_DOWNGRADE = 299
- SYS_PSYNCH_RW_UPGRADE = 300
- SYS_PSYNCH_MUTEXWAIT = 301
- SYS_PSYNCH_MUTEXDROP = 302
- SYS_PSYNCH_CVBROAD = 303
- SYS_PSYNCH_CVSIGNAL = 304
- SYS_PSYNCH_CVWAIT = 305
- SYS_PSYNCH_RW_RDLOCK = 306
- SYS_PSYNCH_RW_WRLOCK = 307
- SYS_PSYNCH_RW_UNLOCK = 308
- SYS_PSYNCH_RW_UNLOCK2 = 309
- SYS_GETSID = 310
- SYS_SETTID_WITH_PID = 311
- SYS_PSYNCH_CVCLRPREPOST = 312
- SYS_AIO_FSYNC = 313
- SYS_AIO_RETURN = 314
- SYS_AIO_SUSPEND = 315
- SYS_AIO_CANCEL = 316
- SYS_AIO_ERROR = 317
- SYS_AIO_READ = 318
- SYS_AIO_WRITE = 319
- SYS_LIO_LISTIO = 320
- SYS_IOPOLICYSYS = 322
- SYS_PROCESS_POLICY = 323
- SYS_MLOCKALL = 324
- SYS_MUNLOCKALL = 325
- SYS_ISSETUGID = 327
- SYS___PTHREAD_KILL = 328
- SYS___PTHREAD_SIGMASK = 329
- SYS___SIGWAIT = 330
- SYS___DISABLE_THREADSIGNAL = 331
- SYS___PTHREAD_MARKCANCEL = 332
- SYS___PTHREAD_CANCELED = 333
- SYS___SEMWAIT_SIGNAL = 334
- SYS_PROC_INFO = 336
- SYS_SENDFILE = 337
- SYS_STAT64 = 338
- SYS_FSTAT64 = 339
- SYS_LSTAT64 = 340
- SYS_STAT64_EXTENDED = 341
- SYS_LSTAT64_EXTENDED = 342
- SYS_FSTAT64_EXTENDED = 343
- SYS_GETDIRENTRIES64 = 344
- SYS_STATFS64 = 345
- SYS_FSTATFS64 = 346
- SYS_GETFSSTAT64 = 347
- SYS___PTHREAD_CHDIR = 348
- SYS___PTHREAD_FCHDIR = 349
- SYS_AUDIT = 350
- SYS_AUDITON = 351
- SYS_GETAUID = 353
- SYS_SETAUID = 354
- SYS_GETAUDIT_ADDR = 357
- SYS_SETAUDIT_ADDR = 358
- SYS_AUDITCTL = 359
- SYS_BSDTHREAD_CREATE = 360
- SYS_BSDTHREAD_TERMINATE = 361
- SYS_KQUEUE = 362
- SYS_KEVENT = 363
- SYS_LCHOWN = 364
- SYS_STACK_SNAPSHOT = 365
- SYS_BSDTHREAD_REGISTER = 366
- SYS_WORKQ_OPEN = 367
- SYS_WORKQ_KERNRETURN = 368
- SYS_KEVENT64 = 369
- SYS___OLD_SEMWAIT_SIGNAL = 370
- SYS___OLD_SEMWAIT_SIGNAL_NOCANCEL = 371
- SYS_THREAD_SELFID = 372
- SYS_LEDGER = 373
- SYS___MAC_EXECVE = 380
- SYS___MAC_SYSCALL = 381
- SYS___MAC_GET_FILE = 382
- SYS___MAC_SET_FILE = 383
- SYS___MAC_GET_LINK = 384
- SYS___MAC_SET_LINK = 385
- SYS___MAC_GET_PROC = 386
- SYS___MAC_SET_PROC = 387
- SYS___MAC_GET_FD = 388
- SYS___MAC_SET_FD = 389
- SYS___MAC_GET_PID = 390
- SYS___MAC_GET_LCID = 391
- SYS___MAC_GET_LCTX = 392
- SYS___MAC_SET_LCTX = 393
- SYS_SETLCID = 394
- SYS_GETLCID = 395
- SYS_READ_NOCANCEL = 396
- SYS_WRITE_NOCANCEL = 397
- SYS_OPEN_NOCANCEL = 398
- SYS_CLOSE_NOCANCEL = 399
- SYS_WAIT4_NOCANCEL = 400
- SYS_RECVMSG_NOCANCEL = 401
- SYS_SENDMSG_NOCANCEL = 402
- SYS_RECVFROM_NOCANCEL = 403
- SYS_ACCEPT_NOCANCEL = 404
- SYS_MSYNC_NOCANCEL = 405
- SYS_FCNTL_NOCANCEL = 406
- SYS_SELECT_NOCANCEL = 407
- SYS_FSYNC_NOCANCEL = 408
- SYS_CONNECT_NOCANCEL = 409
- SYS_SIGSUSPEND_NOCANCEL = 410
- SYS_READV_NOCANCEL = 411
- SYS_WRITEV_NOCANCEL = 412
- SYS_SENDTO_NOCANCEL = 413
- SYS_PREAD_NOCANCEL = 414
- SYS_PWRITE_NOCANCEL = 415
- SYS_WAITID_NOCANCEL = 416
- SYS_POLL_NOCANCEL = 417
- SYS_MSGSND_NOCANCEL = 418
- SYS_MSGRCV_NOCANCEL = 419
- SYS_SEM_WAIT_NOCANCEL = 420
- SYS_AIO_SUSPEND_NOCANCEL = 421
- SYS___SIGWAIT_NOCANCEL = 422
- SYS___SEMWAIT_SIGNAL_NOCANCEL = 423
- SYS___MAC_MOUNT = 424
- SYS___MAC_GET_MOUNT = 425
- SYS___MAC_GETFSSTAT = 426
- SYS_FSGETPATH = 427
- SYS_AUDIT_SESSION_SELF = 428
- SYS_AUDIT_SESSION_JOIN = 429
- SYS_FILEPORT_MAKEPORT = 430
- SYS_FILEPORT_MAKEFD = 431
- SYS_AUDIT_SESSION_PORT = 432
- SYS_PID_SUSPEND = 433
- SYS_PID_RESUME = 434
- SYS_PID_HIBERNATE = 435
- SYS_PID_SHUTDOWN_SOCKETS = 436
- SYS_SHARED_REGION_MAP_AND_SLIDE_NP = 438
- SYS_KAS_INFO = 439
- SYS_MAXSYSCALL = 440
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go
deleted file mode 100644
index 26677ebb..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go
+++ /dev/null
@@ -1,398 +0,0 @@
-// mksysnum_darwin.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk/usr/include/sys/syscall.h
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build arm64,darwin
-
-package unix
-
-const (
- SYS_SYSCALL = 0
- SYS_EXIT = 1
- SYS_FORK = 2
- SYS_READ = 3
- SYS_WRITE = 4
- SYS_OPEN = 5
- SYS_CLOSE = 6
- SYS_WAIT4 = 7
- SYS_LINK = 9
- SYS_UNLINK = 10
- SYS_CHDIR = 12
- SYS_FCHDIR = 13
- SYS_MKNOD = 14
- SYS_CHMOD = 15
- SYS_CHOWN = 16
- SYS_GETFSSTAT = 18
- SYS_GETPID = 20
- SYS_SETUID = 23
- SYS_GETUID = 24
- SYS_GETEUID = 25
- SYS_PTRACE = 26
- SYS_RECVMSG = 27
- SYS_SENDMSG = 28
- SYS_RECVFROM = 29
- SYS_ACCEPT = 30
- SYS_GETPEERNAME = 31
- SYS_GETSOCKNAME = 32
- SYS_ACCESS = 33
- SYS_CHFLAGS = 34
- SYS_FCHFLAGS = 35
- SYS_SYNC = 36
- SYS_KILL = 37
- SYS_GETPPID = 39
- SYS_DUP = 41
- SYS_PIPE = 42
- SYS_GETEGID = 43
- SYS_SIGACTION = 46
- SYS_GETGID = 47
- SYS_SIGPROCMASK = 48
- SYS_GETLOGIN = 49
- SYS_SETLOGIN = 50
- SYS_ACCT = 51
- SYS_SIGPENDING = 52
- SYS_SIGALTSTACK = 53
- SYS_IOCTL = 54
- SYS_REBOOT = 55
- SYS_REVOKE = 56
- SYS_SYMLINK = 57
- SYS_READLINK = 58
- SYS_EXECVE = 59
- SYS_UMASK = 60
- SYS_CHROOT = 61
- SYS_MSYNC = 65
- SYS_VFORK = 66
- SYS_MUNMAP = 73
- SYS_MPROTECT = 74
- SYS_MADVISE = 75
- SYS_MINCORE = 78
- SYS_GETGROUPS = 79
- SYS_SETGROUPS = 80
- SYS_GETPGRP = 81
- SYS_SETPGID = 82
- SYS_SETITIMER = 83
- SYS_SWAPON = 85
- SYS_GETITIMER = 86
- SYS_GETDTABLESIZE = 89
- SYS_DUP2 = 90
- SYS_FCNTL = 92
- SYS_SELECT = 93
- SYS_FSYNC = 95
- SYS_SETPRIORITY = 96
- SYS_SOCKET = 97
- SYS_CONNECT = 98
- SYS_GETPRIORITY = 100
- SYS_BIND = 104
- SYS_SETSOCKOPT = 105
- SYS_LISTEN = 106
- SYS_SIGSUSPEND = 111
- SYS_GETTIMEOFDAY = 116
- SYS_GETRUSAGE = 117
- SYS_GETSOCKOPT = 118
- SYS_READV = 120
- SYS_WRITEV = 121
- SYS_SETTIMEOFDAY = 122
- SYS_FCHOWN = 123
- SYS_FCHMOD = 124
- SYS_SETREUID = 126
- SYS_SETREGID = 127
- SYS_RENAME = 128
- SYS_FLOCK = 131
- SYS_MKFIFO = 132
- SYS_SENDTO = 133
- SYS_SHUTDOWN = 134
- SYS_SOCKETPAIR = 135
- SYS_MKDIR = 136
- SYS_RMDIR = 137
- SYS_UTIMES = 138
- SYS_FUTIMES = 139
- SYS_ADJTIME = 140
- SYS_GETHOSTUUID = 142
- SYS_SETSID = 147
- SYS_GETPGID = 151
- SYS_SETPRIVEXEC = 152
- SYS_PREAD = 153
- SYS_PWRITE = 154
- SYS_NFSSVC = 155
- SYS_STATFS = 157
- SYS_FSTATFS = 158
- SYS_UNMOUNT = 159
- SYS_GETFH = 161
- SYS_QUOTACTL = 165
- SYS_MOUNT = 167
- SYS_CSOPS = 169
- SYS_CSOPS_AUDITTOKEN = 170
- SYS_WAITID = 173
- SYS_KDEBUG_TRACE64 = 179
- SYS_KDEBUG_TRACE = 180
- SYS_SETGID = 181
- SYS_SETEGID = 182
- SYS_SETEUID = 183
- SYS_SIGRETURN = 184
- SYS_CHUD = 185
- SYS_FDATASYNC = 187
- SYS_STAT = 188
- SYS_FSTAT = 189
- SYS_LSTAT = 190
- SYS_PATHCONF = 191
- SYS_FPATHCONF = 192
- SYS_GETRLIMIT = 194
- SYS_SETRLIMIT = 195
- SYS_GETDIRENTRIES = 196
- SYS_MMAP = 197
- SYS_LSEEK = 199
- SYS_TRUNCATE = 200
- SYS_FTRUNCATE = 201
- SYS_SYSCTL = 202
- SYS_MLOCK = 203
- SYS_MUNLOCK = 204
- SYS_UNDELETE = 205
- SYS_OPEN_DPROTECTED_NP = 216
- SYS_GETATTRLIST = 220
- SYS_SETATTRLIST = 221
- SYS_GETDIRENTRIESATTR = 222
- SYS_EXCHANGEDATA = 223
- SYS_SEARCHFS = 225
- SYS_DELETE = 226
- SYS_COPYFILE = 227
- SYS_FGETATTRLIST = 228
- SYS_FSETATTRLIST = 229
- SYS_POLL = 230
- SYS_WATCHEVENT = 231
- SYS_WAITEVENT = 232
- SYS_MODWATCH = 233
- SYS_GETXATTR = 234
- SYS_FGETXATTR = 235
- SYS_SETXATTR = 236
- SYS_FSETXATTR = 237
- SYS_REMOVEXATTR = 238
- SYS_FREMOVEXATTR = 239
- SYS_LISTXATTR = 240
- SYS_FLISTXATTR = 241
- SYS_FSCTL = 242
- SYS_INITGROUPS = 243
- SYS_POSIX_SPAWN = 244
- SYS_FFSCTL = 245
- SYS_NFSCLNT = 247
- SYS_FHOPEN = 248
- SYS_MINHERIT = 250
- SYS_SEMSYS = 251
- SYS_MSGSYS = 252
- SYS_SHMSYS = 253
- SYS_SEMCTL = 254
- SYS_SEMGET = 255
- SYS_SEMOP = 256
- SYS_MSGCTL = 258
- SYS_MSGGET = 259
- SYS_MSGSND = 260
- SYS_MSGRCV = 261
- SYS_SHMAT = 262
- SYS_SHMCTL = 263
- SYS_SHMDT = 264
- SYS_SHMGET = 265
- SYS_SHM_OPEN = 266
- SYS_SHM_UNLINK = 267
- SYS_SEM_OPEN = 268
- SYS_SEM_CLOSE = 269
- SYS_SEM_UNLINK = 270
- SYS_SEM_WAIT = 271
- SYS_SEM_TRYWAIT = 272
- SYS_SEM_POST = 273
- SYS_SYSCTLBYNAME = 274
- SYS_OPEN_EXTENDED = 277
- SYS_UMASK_EXTENDED = 278
- SYS_STAT_EXTENDED = 279
- SYS_LSTAT_EXTENDED = 280
- SYS_FSTAT_EXTENDED = 281
- SYS_CHMOD_EXTENDED = 282
- SYS_FCHMOD_EXTENDED = 283
- SYS_ACCESS_EXTENDED = 284
- SYS_SETTID = 285
- SYS_GETTID = 286
- SYS_SETSGROUPS = 287
- SYS_GETSGROUPS = 288
- SYS_SETWGROUPS = 289
- SYS_GETWGROUPS = 290
- SYS_MKFIFO_EXTENDED = 291
- SYS_MKDIR_EXTENDED = 292
- SYS_IDENTITYSVC = 293
- SYS_SHARED_REGION_CHECK_NP = 294
- SYS_VM_PRESSURE_MONITOR = 296
- SYS_PSYNCH_RW_LONGRDLOCK = 297
- SYS_PSYNCH_RW_YIELDWRLOCK = 298
- SYS_PSYNCH_RW_DOWNGRADE = 299
- SYS_PSYNCH_RW_UPGRADE = 300
- SYS_PSYNCH_MUTEXWAIT = 301
- SYS_PSYNCH_MUTEXDROP = 302
- SYS_PSYNCH_CVBROAD = 303
- SYS_PSYNCH_CVSIGNAL = 304
- SYS_PSYNCH_CVWAIT = 305
- SYS_PSYNCH_RW_RDLOCK = 306
- SYS_PSYNCH_RW_WRLOCK = 307
- SYS_PSYNCH_RW_UNLOCK = 308
- SYS_PSYNCH_RW_UNLOCK2 = 309
- SYS_GETSID = 310
- SYS_SETTID_WITH_PID = 311
- SYS_PSYNCH_CVCLRPREPOST = 312
- SYS_AIO_FSYNC = 313
- SYS_AIO_RETURN = 314
- SYS_AIO_SUSPEND = 315
- SYS_AIO_CANCEL = 316
- SYS_AIO_ERROR = 317
- SYS_AIO_READ = 318
- SYS_AIO_WRITE = 319
- SYS_LIO_LISTIO = 320
- SYS_IOPOLICYSYS = 322
- SYS_PROCESS_POLICY = 323
- SYS_MLOCKALL = 324
- SYS_MUNLOCKALL = 325
- SYS_ISSETUGID = 327
- SYS___PTHREAD_KILL = 328
- SYS___PTHREAD_SIGMASK = 329
- SYS___SIGWAIT = 330
- SYS___DISABLE_THREADSIGNAL = 331
- SYS___PTHREAD_MARKCANCEL = 332
- SYS___PTHREAD_CANCELED = 333
- SYS___SEMWAIT_SIGNAL = 334
- SYS_PROC_INFO = 336
- SYS_SENDFILE = 337
- SYS_STAT64 = 338
- SYS_FSTAT64 = 339
- SYS_LSTAT64 = 340
- SYS_STAT64_EXTENDED = 341
- SYS_LSTAT64_EXTENDED = 342
- SYS_FSTAT64_EXTENDED = 343
- SYS_GETDIRENTRIES64 = 344
- SYS_STATFS64 = 345
- SYS_FSTATFS64 = 346
- SYS_GETFSSTAT64 = 347
- SYS___PTHREAD_CHDIR = 348
- SYS___PTHREAD_FCHDIR = 349
- SYS_AUDIT = 350
- SYS_AUDITON = 351
- SYS_GETAUID = 353
- SYS_SETAUID = 354
- SYS_GETAUDIT_ADDR = 357
- SYS_SETAUDIT_ADDR = 358
- SYS_AUDITCTL = 359
- SYS_BSDTHREAD_CREATE = 360
- SYS_BSDTHREAD_TERMINATE = 361
- SYS_KQUEUE = 362
- SYS_KEVENT = 363
- SYS_LCHOWN = 364
- SYS_STACK_SNAPSHOT = 365
- SYS_BSDTHREAD_REGISTER = 366
- SYS_WORKQ_OPEN = 367
- SYS_WORKQ_KERNRETURN = 368
- SYS_KEVENT64 = 369
- SYS___OLD_SEMWAIT_SIGNAL = 370
- SYS___OLD_SEMWAIT_SIGNAL_NOCANCEL = 371
- SYS_THREAD_SELFID = 372
- SYS_LEDGER = 373
- SYS___MAC_EXECVE = 380
- SYS___MAC_SYSCALL = 381
- SYS___MAC_GET_FILE = 382
- SYS___MAC_SET_FILE = 383
- SYS___MAC_GET_LINK = 384
- SYS___MAC_SET_LINK = 385
- SYS___MAC_GET_PROC = 386
- SYS___MAC_SET_PROC = 387
- SYS___MAC_GET_FD = 388
- SYS___MAC_SET_FD = 389
- SYS___MAC_GET_PID = 390
- SYS___MAC_GET_LCID = 391
- SYS___MAC_GET_LCTX = 392
- SYS___MAC_SET_LCTX = 393
- SYS_SETLCID = 394
- SYS_GETLCID = 395
- SYS_READ_NOCANCEL = 396
- SYS_WRITE_NOCANCEL = 397
- SYS_OPEN_NOCANCEL = 398
- SYS_CLOSE_NOCANCEL = 399
- SYS_WAIT4_NOCANCEL = 400
- SYS_RECVMSG_NOCANCEL = 401
- SYS_SENDMSG_NOCANCEL = 402
- SYS_RECVFROM_NOCANCEL = 403
- SYS_ACCEPT_NOCANCEL = 404
- SYS_MSYNC_NOCANCEL = 405
- SYS_FCNTL_NOCANCEL = 406
- SYS_SELECT_NOCANCEL = 407
- SYS_FSYNC_NOCANCEL = 408
- SYS_CONNECT_NOCANCEL = 409
- SYS_SIGSUSPEND_NOCANCEL = 410
- SYS_READV_NOCANCEL = 411
- SYS_WRITEV_NOCANCEL = 412
- SYS_SENDTO_NOCANCEL = 413
- SYS_PREAD_NOCANCEL = 414
- SYS_PWRITE_NOCANCEL = 415
- SYS_WAITID_NOCANCEL = 416
- SYS_POLL_NOCANCEL = 417
- SYS_MSGSND_NOCANCEL = 418
- SYS_MSGRCV_NOCANCEL = 419
- SYS_SEM_WAIT_NOCANCEL = 420
- SYS_AIO_SUSPEND_NOCANCEL = 421
- SYS___SIGWAIT_NOCANCEL = 422
- SYS___SEMWAIT_SIGNAL_NOCANCEL = 423
- SYS___MAC_MOUNT = 424
- SYS___MAC_GET_MOUNT = 425
- SYS___MAC_GETFSSTAT = 426
- SYS_FSGETPATH = 427
- SYS_AUDIT_SESSION_SELF = 428
- SYS_AUDIT_SESSION_JOIN = 429
- SYS_FILEPORT_MAKEPORT = 430
- SYS_FILEPORT_MAKEFD = 431
- SYS_AUDIT_SESSION_PORT = 432
- SYS_PID_SUSPEND = 433
- SYS_PID_RESUME = 434
- SYS_PID_HIBERNATE = 435
- SYS_PID_SHUTDOWN_SOCKETS = 436
- SYS_SHARED_REGION_MAP_AND_SLIDE_NP = 438
- SYS_KAS_INFO = 439
- SYS_MEMORYSTATUS_CONTROL = 440
- SYS_GUARDED_OPEN_NP = 441
- SYS_GUARDED_CLOSE_NP = 442
- SYS_GUARDED_KQUEUE_NP = 443
- SYS_CHANGE_FDGUARD_NP = 444
- SYS_PROC_RLIMIT_CONTROL = 446
- SYS_CONNECTX = 447
- SYS_DISCONNECTX = 448
- SYS_PEELOFF = 449
- SYS_SOCKET_DELEGATE = 450
- SYS_TELEMETRY = 451
- SYS_PROC_UUID_POLICY = 452
- SYS_MEMORYSTATUS_GET_LEVEL = 453
- SYS_SYSTEM_OVERRIDE = 454
- SYS_VFS_PURGE = 455
- SYS_SFI_CTL = 456
- SYS_SFI_PIDCTL = 457
- SYS_COALITION = 458
- SYS_COALITION_INFO = 459
- SYS_NECP_MATCH_POLICY = 460
- SYS_GETATTRLISTBULK = 461
- SYS_OPENAT = 463
- SYS_OPENAT_NOCANCEL = 464
- SYS_RENAMEAT = 465
- SYS_FACCESSAT = 466
- SYS_FCHMODAT = 467
- SYS_FCHOWNAT = 468
- SYS_FSTATAT = 469
- SYS_FSTATAT64 = 470
- SYS_LINKAT = 471
- SYS_UNLINKAT = 472
- SYS_READLINKAT = 473
- SYS_SYMLINKAT = 474
- SYS_MKDIRAT = 475
- SYS_GETATTRLISTAT = 476
- SYS_PROC_TRACE_LOG = 477
- SYS_BSDTHREAD_CTL = 478
- SYS_OPENBYID_NP = 479
- SYS_RECVMSG_X = 480
- SYS_SENDMSG_X = 481
- SYS_THREAD_SELFUSAGE = 482
- SYS_CSRCTL = 483
- SYS_GUARDED_OPEN_DPROTECTED_NP = 484
- SYS_GUARDED_WRITE_NP = 485
- SYS_GUARDED_PWRITE_NP = 486
- SYS_GUARDED_WRITEV_NP = 487
- SYS_RENAME_EXT = 488
- SYS_MREMAP_ENCRYPTED = 489
- SYS_MAXSYSCALL = 490
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go
deleted file mode 100644
index d6038fa9..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go
+++ /dev/null
@@ -1,304 +0,0 @@
-// mksysnum_dragonfly.pl
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build amd64,dragonfly
-
-package unix
-
-const (
- // SYS_NOSYS = 0; // { int nosys(void); } syscall nosys_args int
- SYS_EXIT = 1 // { void exit(int rval); }
- SYS_FORK = 2 // { int fork(void); }
- SYS_READ = 3 // { ssize_t read(int fd, void *buf, size_t nbyte); }
- SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, size_t nbyte); }
- SYS_OPEN = 5 // { int open(char *path, int flags, int mode); }
- SYS_CLOSE = 6 // { int close(int fd); }
- SYS_WAIT4 = 7 // { int wait4(int pid, int *status, int options, \
- SYS_LINK = 9 // { int link(char *path, char *link); }
- SYS_UNLINK = 10 // { int unlink(char *path); }
- SYS_CHDIR = 12 // { int chdir(char *path); }
- SYS_FCHDIR = 13 // { int fchdir(int fd); }
- SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); }
- SYS_CHMOD = 15 // { int chmod(char *path, int mode); }
- SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); }
- SYS_OBREAK = 17 // { int obreak(char *nsize); } break obreak_args int
- SYS_GETFSSTAT = 18 // { int getfsstat(struct statfs *buf, long bufsize, \
- SYS_GETPID = 20 // { pid_t getpid(void); }
- SYS_MOUNT = 21 // { int mount(char *type, char *path, int flags, \
- SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); }
- SYS_SETUID = 23 // { int setuid(uid_t uid); }
- SYS_GETUID = 24 // { uid_t getuid(void); }
- SYS_GETEUID = 25 // { uid_t geteuid(void); }
- SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, caddr_t addr, \
- SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, int flags); }
- SYS_SENDMSG = 28 // { int sendmsg(int s, caddr_t msg, int flags); }
- SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, size_t len, \
- SYS_ACCEPT = 30 // { int accept(int s, caddr_t name, int *anamelen); }
- SYS_GETPEERNAME = 31 // { int getpeername(int fdes, caddr_t asa, int *alen); }
- SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, caddr_t asa, int *alen); }
- SYS_ACCESS = 33 // { int access(char *path, int flags); }
- SYS_CHFLAGS = 34 // { int chflags(char *path, int flags); }
- SYS_FCHFLAGS = 35 // { int fchflags(int fd, int flags); }
- SYS_SYNC = 36 // { int sync(void); }
- SYS_KILL = 37 // { int kill(int pid, int signum); }
- SYS_GETPPID = 39 // { pid_t getppid(void); }
- SYS_DUP = 41 // { int dup(u_int fd); }
- SYS_PIPE = 42 // { int pipe(void); }
- SYS_GETEGID = 43 // { gid_t getegid(void); }
- SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \
- SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, int facs, \
- SYS_GETGID = 47 // { gid_t getgid(void); }
- SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int namelen); }
- SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); }
- SYS_ACCT = 51 // { int acct(char *path); }
- SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, stack_t *oss); }
- SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, caddr_t data); }
- SYS_REBOOT = 55 // { int reboot(int opt); }
- SYS_REVOKE = 56 // { int revoke(char *path); }
- SYS_SYMLINK = 57 // { int symlink(char *path, char *link); }
- SYS_READLINK = 58 // { int readlink(char *path, char *buf, int count); }
- SYS_EXECVE = 59 // { int execve(char *fname, char **argv, char **envv); }
- SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args int
- SYS_CHROOT = 61 // { int chroot(char *path); }
- SYS_MSYNC = 65 // { int msync(void *addr, size_t len, int flags); }
- SYS_VFORK = 66 // { pid_t vfork(void); }
- SYS_SBRK = 69 // { int sbrk(int incr); }
- SYS_SSTK = 70 // { int sstk(int incr); }
- SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); }
- SYS_MPROTECT = 74 // { int mprotect(void *addr, size_t len, int prot); }
- SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, int behav); }
- SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \
- SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, gid_t *gidset); }
- SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, gid_t *gidset); }
- SYS_GETPGRP = 81 // { int getpgrp(void); }
- SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); }
- SYS_SETITIMER = 83 // { int setitimer(u_int which, struct itimerval *itv, \
- SYS_SWAPON = 85 // { int swapon(char *name); }
- SYS_GETITIMER = 86 // { int getitimer(u_int which, struct itimerval *itv); }
- SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); }
- SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); }
- SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); }
- SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \
- SYS_FSYNC = 95 // { int fsync(int fd); }
- SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, int prio); }
- SYS_SOCKET = 97 // { int socket(int domain, int type, int protocol); }
- SYS_CONNECT = 98 // { int connect(int s, caddr_t name, int namelen); }
- SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); }
- SYS_BIND = 104 // { int bind(int s, caddr_t name, int namelen); }
- SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \
- SYS_LISTEN = 106 // { int listen(int s, int backlog); }
- SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \
- SYS_GETRUSAGE = 117 // { int getrusage(int who, struct rusage *rusage); }
- SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \
- SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, u_int iovcnt); }
- SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \
- SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \
- SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); }
- SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); }
- SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); }
- SYS_SETREGID = 127 // { int setregid(int rgid, int egid); }
- SYS_RENAME = 128 // { int rename(char *from, char *to); }
- SYS_FLOCK = 131 // { int flock(int fd, int how); }
- SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); }
- SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \
- SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); }
- SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, int protocol, \
- SYS_MKDIR = 136 // { int mkdir(char *path, int mode); }
- SYS_RMDIR = 137 // { int rmdir(char *path); }
- SYS_UTIMES = 138 // { int utimes(char *path, struct timeval *tptr); }
- SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \
- SYS_SETSID = 147 // { int setsid(void); }
- SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \
- SYS_STATFS = 157 // { int statfs(char *path, struct statfs *buf); }
- SYS_FSTATFS = 158 // { int fstatfs(int fd, struct statfs *buf); }
- SYS_GETFH = 161 // { int getfh(char *fname, struct fhandle *fhp); }
- SYS_GETDOMAINNAME = 162 // { int getdomainname(char *domainname, int len); }
- SYS_SETDOMAINNAME = 163 // { int setdomainname(char *domainname, int len); }
- SYS_UNAME = 164 // { int uname(struct utsname *name); }
- SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); }
- SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \
- SYS_EXTPREAD = 173 // { ssize_t extpread(int fd, void *buf, \
- SYS_EXTPWRITE = 174 // { ssize_t extpwrite(int fd, const void *buf, \
- SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); }
- SYS_SETGID = 181 // { int setgid(gid_t gid); }
- SYS_SETEGID = 182 // { int setegid(gid_t egid); }
- SYS_SETEUID = 183 // { int seteuid(uid_t euid); }
- SYS_PATHCONF = 191 // { int pathconf(char *path, int name); }
- SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); }
- SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \
- SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \
- SYS_MMAP = 197 // { caddr_t mmap(caddr_t addr, size_t len, int prot, \
- // SYS_NOSYS = 198; // { int nosys(void); } __syscall __syscall_args int
- SYS_LSEEK = 199 // { off_t lseek(int fd, int pad, off_t offset, \
- SYS_TRUNCATE = 200 // { int truncate(char *path, int pad, off_t length); }
- SYS_FTRUNCATE = 201 // { int ftruncate(int fd, int pad, off_t length); }
- SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, void *old, \
- SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); }
- SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); }
- SYS_UNDELETE = 205 // { int undelete(char *path); }
- SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); }
- SYS_GETPGID = 207 // { int getpgid(pid_t pid); }
- SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \
- SYS___SEMCTL = 220 // { int __semctl(int semid, int semnum, int cmd, \
- SYS_SEMGET = 221 // { int semget(key_t key, int nsems, int semflg); }
- SYS_SEMOP = 222 // { int semop(int semid, struct sembuf *sops, \
- SYS_MSGCTL = 224 // { int msgctl(int msqid, int cmd, \
- SYS_MSGGET = 225 // { int msgget(key_t key, int msgflg); }
- SYS_MSGSND = 226 // { int msgsnd(int msqid, void *msgp, size_t msgsz, \
- SYS_MSGRCV = 227 // { int msgrcv(int msqid, void *msgp, size_t msgsz, \
- SYS_SHMAT = 228 // { caddr_t shmat(int shmid, const void *shmaddr, \
- SYS_SHMCTL = 229 // { int shmctl(int shmid, int cmd, \
- SYS_SHMDT = 230 // { int shmdt(const void *shmaddr); }
- SYS_SHMGET = 231 // { int shmget(key_t key, size_t size, int shmflg); }
- SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \
- SYS_CLOCK_SETTIME = 233 // { int clock_settime(clockid_t clock_id, \
- SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \
- SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \
- SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, int inherit); }
- SYS_RFORK = 251 // { int rfork(int flags); }
- SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, u_int nfds, \
- SYS_ISSETUGID = 253 // { int issetugid(void); }
- SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); }
- SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); }
- SYS_LUTIMES = 276 // { int lutimes(char *path, struct timeval *tptr); }
- SYS_EXTPREADV = 289 // { ssize_t extpreadv(int fd, struct iovec *iovp, \
- SYS_EXTPWRITEV = 290 // { ssize_t extpwritev(int fd, struct iovec *iovp,\
- SYS_FHSTATFS = 297 // { int fhstatfs(const struct fhandle *u_fhp, struct statfs *buf); }
- SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, int flags); }
- SYS_MODNEXT = 300 // { int modnext(int modid); }
- SYS_MODSTAT = 301 // { int modstat(int modid, struct module_stat* stat); }
- SYS_MODFNEXT = 302 // { int modfnext(int modid); }
- SYS_MODFIND = 303 // { int modfind(const char *name); }
- SYS_KLDLOAD = 304 // { int kldload(const char *file); }
- SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); }
- SYS_KLDFIND = 306 // { int kldfind(const char *file); }
- SYS_KLDNEXT = 307 // { int kldnext(int fileid); }
- SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct kld_file_stat* stat); }
- SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); }
- SYS_GETSID = 310 // { int getsid(pid_t pid); }
- SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, uid_t suid); }
- SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, gid_t sgid); }
- SYS_AIO_RETURN = 314 // { int aio_return(struct aiocb *aiocbp); }
- SYS_AIO_SUSPEND = 315 // { int aio_suspend(struct aiocb * const * aiocbp, int nent, const struct timespec *timeout); }
- SYS_AIO_CANCEL = 316 // { int aio_cancel(int fd, struct aiocb *aiocbp); }
- SYS_AIO_ERROR = 317 // { int aio_error(struct aiocb *aiocbp); }
- SYS_AIO_READ = 318 // { int aio_read(struct aiocb *aiocbp); }
- SYS_AIO_WRITE = 319 // { int aio_write(struct aiocb *aiocbp); }
- SYS_LIO_LISTIO = 320 // { int lio_listio(int mode, struct aiocb * const *acb_list, int nent, struct sigevent *sig); }
- SYS_YIELD = 321 // { int yield(void); }
- SYS_MLOCKALL = 324 // { int mlockall(int how); }
- SYS_MUNLOCKALL = 325 // { int munlockall(void); }
- SYS___GETCWD = 326 // { int __getcwd(u_char *buf, u_int buflen); }
- SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, const struct sched_param *param); }
- SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct sched_param *param); }
- SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int policy, const struct sched_param *param); }
- SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); }
- SYS_SCHED_YIELD = 331 // { int sched_yield (void); }
- SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); }
- SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); }
- SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, struct timespec *interval); }
- SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); }
- SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, void *data); }
- SYS_JAIL = 338 // { int jail(struct jail *jail); }
- SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, const sigset_t *set, \
- SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); }
- SYS_SIGACTION = 342 // { int sigaction(int sig, const struct sigaction *act, \
- SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); }
- SYS_SIGRETURN = 344 // { int sigreturn(ucontext_t *sigcntxp); }
- SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set,\
- SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set,\
- SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \
- SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \
- SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, acl_type_t type, \
- SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, acl_type_t type, \
- SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \
- SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, acl_type_t type); }
- SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \
- SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, acl_type_t type, \
- SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \
- SYS_EXTATTR_SET_FILE = 356 // { int extattr_set_file(const char *path, \
- SYS_EXTATTR_GET_FILE = 357 // { int extattr_get_file(const char *path, \
- SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \
- SYS_AIO_WAITCOMPLETE = 359 // { int aio_waitcomplete(struct aiocb **aiocbp, struct timespec *timeout); }
- SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid); }
- SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); }
- SYS_KQUEUE = 362 // { int kqueue(void); }
- SYS_KEVENT = 363 // { int kevent(int fd, \
- SYS_SCTP_PEELOFF = 364 // { int sctp_peeloff(int sd, caddr_t name ); }
- SYS_LCHFLAGS = 391 // { int lchflags(char *path, int flags); }
- SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, int count); }
- SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, size_t nbytes, \
- SYS_VARSYM_SET = 450 // { int varsym_set(int level, const char *name, const char *data); }
- SYS_VARSYM_GET = 451 // { int varsym_get(int mask, const char *wild, char *buf, int bufsize); }
- SYS_VARSYM_LIST = 452 // { int varsym_list(int level, char *buf, int maxsize, int *marker); }
- SYS_EXEC_SYS_REGISTER = 465 // { int exec_sys_register(void *entry); }
- SYS_EXEC_SYS_UNREGISTER = 466 // { int exec_sys_unregister(int id); }
- SYS_SYS_CHECKPOINT = 467 // { int sys_checkpoint(int type, int fd, pid_t pid, int retval); }
- SYS_MOUNTCTL = 468 // { int mountctl(const char *path, int op, int fd, const void *ctl, int ctllen, void *buf, int buflen); }
- SYS_UMTX_SLEEP = 469 // { int umtx_sleep(volatile const int *ptr, int value, int timeout); }
- SYS_UMTX_WAKEUP = 470 // { int umtx_wakeup(volatile const int *ptr, int count); }
- SYS_JAIL_ATTACH = 471 // { int jail_attach(int jid); }
- SYS_SET_TLS_AREA = 472 // { int set_tls_area(int which, struct tls_info *info, size_t infosize); }
- SYS_GET_TLS_AREA = 473 // { int get_tls_area(int which, struct tls_info *info, size_t infosize); }
- SYS_CLOSEFROM = 474 // { int closefrom(int fd); }
- SYS_STAT = 475 // { int stat(const char *path, struct stat *ub); }
- SYS_FSTAT = 476 // { int fstat(int fd, struct stat *sb); }
- SYS_LSTAT = 477 // { int lstat(const char *path, struct stat *ub); }
- SYS_FHSTAT = 478 // { int fhstat(const struct fhandle *u_fhp, struct stat *sb); }
- SYS_GETDIRENTRIES = 479 // { int getdirentries(int fd, char *buf, u_int count, \
- SYS_GETDENTS = 480 // { int getdents(int fd, char *buf, size_t count); }
- SYS_USCHED_SET = 481 // { int usched_set(pid_t pid, int cmd, void *data, \
- SYS_EXTACCEPT = 482 // { int extaccept(int s, int flags, caddr_t name, int *anamelen); }
- SYS_EXTCONNECT = 483 // { int extconnect(int s, int flags, caddr_t name, int namelen); }
- SYS_MCONTROL = 485 // { int mcontrol(void *addr, size_t len, int behav, off_t value); }
- SYS_VMSPACE_CREATE = 486 // { int vmspace_create(void *id, int type, void *data); }
- SYS_VMSPACE_DESTROY = 487 // { int vmspace_destroy(void *id); }
- SYS_VMSPACE_CTL = 488 // { int vmspace_ctl(void *id, int cmd, \
- SYS_VMSPACE_MMAP = 489 // { int vmspace_mmap(void *id, void *addr, size_t len, \
- SYS_VMSPACE_MUNMAP = 490 // { int vmspace_munmap(void *id, void *addr, \
- SYS_VMSPACE_MCONTROL = 491 // { int vmspace_mcontrol(void *id, void *addr, \
- SYS_VMSPACE_PREAD = 492 // { ssize_t vmspace_pread(void *id, void *buf, \
- SYS_VMSPACE_PWRITE = 493 // { ssize_t vmspace_pwrite(void *id, const void *buf, \
- SYS_EXTEXIT = 494 // { void extexit(int how, int status, void *addr); }
- SYS_LWP_CREATE = 495 // { int lwp_create(struct lwp_params *params); }
- SYS_LWP_GETTID = 496 // { lwpid_t lwp_gettid(void); }
- SYS_LWP_KILL = 497 // { int lwp_kill(pid_t pid, lwpid_t tid, int signum); }
- SYS_LWP_RTPRIO = 498 // { int lwp_rtprio(int function, pid_t pid, lwpid_t tid, struct rtprio *rtp); }
- SYS_PSELECT = 499 // { int pselect(int nd, fd_set *in, fd_set *ou, \
- SYS_STATVFS = 500 // { int statvfs(const char *path, struct statvfs *buf); }
- SYS_FSTATVFS = 501 // { int fstatvfs(int fd, struct statvfs *buf); }
- SYS_FHSTATVFS = 502 // { int fhstatvfs(const struct fhandle *u_fhp, struct statvfs *buf); }
- SYS_GETVFSSTAT = 503 // { int getvfsstat(struct statfs *buf, \
- SYS_OPENAT = 504 // { int openat(int fd, char *path, int flags, int mode); }
- SYS_FSTATAT = 505 // { int fstatat(int fd, char *path, \
- SYS_FCHMODAT = 506 // { int fchmodat(int fd, char *path, int mode, \
- SYS_FCHOWNAT = 507 // { int fchownat(int fd, char *path, int uid, int gid, \
- SYS_UNLINKAT = 508 // { int unlinkat(int fd, char *path, int flags); }
- SYS_FACCESSAT = 509 // { int faccessat(int fd, char *path, int amode, \
- SYS_MQ_OPEN = 510 // { mqd_t mq_open(const char * name, int oflag, \
- SYS_MQ_CLOSE = 511 // { int mq_close(mqd_t mqdes); }
- SYS_MQ_UNLINK = 512 // { int mq_unlink(const char *name); }
- SYS_MQ_GETATTR = 513 // { int mq_getattr(mqd_t mqdes, \
- SYS_MQ_SETATTR = 514 // { int mq_setattr(mqd_t mqdes, \
- SYS_MQ_NOTIFY = 515 // { int mq_notify(mqd_t mqdes, \
- SYS_MQ_SEND = 516 // { int mq_send(mqd_t mqdes, const char *msg_ptr, \
- SYS_MQ_RECEIVE = 517 // { ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, \
- SYS_MQ_TIMEDSEND = 518 // { int mq_timedsend(mqd_t mqdes, \
- SYS_MQ_TIMEDRECEIVE = 519 // { ssize_t mq_timedreceive(mqd_t mqdes, \
- SYS_IOPRIO_SET = 520 // { int ioprio_set(int which, int who, int prio); }
- SYS_IOPRIO_GET = 521 // { int ioprio_get(int which, int who); }
- SYS_CHROOT_KERNEL = 522 // { int chroot_kernel(char *path); }
- SYS_RENAMEAT = 523 // { int renameat(int oldfd, char *old, int newfd, \
- SYS_MKDIRAT = 524 // { int mkdirat(int fd, char *path, mode_t mode); }
- SYS_MKFIFOAT = 525 // { int mkfifoat(int fd, char *path, mode_t mode); }
- SYS_MKNODAT = 526 // { int mknodat(int fd, char *path, mode_t mode, \
- SYS_READLINKAT = 527 // { int readlinkat(int fd, char *path, char *buf, \
- SYS_SYMLINKAT = 528 // { int symlinkat(char *path1, int fd, char *path2); }
- SYS_SWAPOFF = 529 // { int swapoff(char *name); }
- SYS_VQUOTACTL = 530 // { int vquotactl(const char *path, \
- SYS_LINKAT = 531 // { int linkat(int fd1, char *path1, int fd2, \
- SYS_EACCESS = 532 // { int eaccess(char *path, int flags); }
- SYS_LPATHCONF = 533 // { int lpathconf(char *path, int name); }
- SYS_VMM_GUEST_CTL = 534 // { int vmm_guest_ctl(int op, struct vmm_guest_options *options); }
- SYS_VMM_GUEST_SYNC_ADDR = 535 // { int vmm_guest_sync_addr(long *dstaddr, long *srcaddr); }
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go
deleted file mode 100644
index 262a8453..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go
+++ /dev/null
@@ -1,351 +0,0 @@
-// mksysnum_freebsd.pl
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build 386,freebsd
-
-package unix
-
-const (
- // SYS_NOSYS = 0; // { int nosys(void); } syscall nosys_args int
- SYS_EXIT = 1 // { void sys_exit(int rval); } exit \
- SYS_FORK = 2 // { int fork(void); }
- SYS_READ = 3 // { ssize_t read(int fd, void *buf, \
- SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, \
- SYS_OPEN = 5 // { int open(char *path, int flags, int mode); }
- SYS_CLOSE = 6 // { int close(int fd); }
- SYS_WAIT4 = 7 // { int wait4(int pid, int *status, \
- SYS_LINK = 9 // { int link(char *path, char *link); }
- SYS_UNLINK = 10 // { int unlink(char *path); }
- SYS_CHDIR = 12 // { int chdir(char *path); }
- SYS_FCHDIR = 13 // { int fchdir(int fd); }
- SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); }
- SYS_CHMOD = 15 // { int chmod(char *path, int mode); }
- SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); }
- SYS_OBREAK = 17 // { int obreak(char *nsize); } break \
- SYS_GETPID = 20 // { pid_t getpid(void); }
- SYS_MOUNT = 21 // { int mount(char *type, char *path, \
- SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); }
- SYS_SETUID = 23 // { int setuid(uid_t uid); }
- SYS_GETUID = 24 // { uid_t getuid(void); }
- SYS_GETEUID = 25 // { uid_t geteuid(void); }
- SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, \
- SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, \
- SYS_SENDMSG = 28 // { int sendmsg(int s, struct msghdr *msg, \
- SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, \
- SYS_ACCEPT = 30 // { int accept(int s, \
- SYS_GETPEERNAME = 31 // { int getpeername(int fdes, \
- SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, \
- SYS_ACCESS = 33 // { int access(char *path, int amode); }
- SYS_CHFLAGS = 34 // { int chflags(const char *path, u_long flags); }
- SYS_FCHFLAGS = 35 // { int fchflags(int fd, u_long flags); }
- SYS_SYNC = 36 // { int sync(void); }
- SYS_KILL = 37 // { int kill(int pid, int signum); }
- SYS_GETPPID = 39 // { pid_t getppid(void); }
- SYS_DUP = 41 // { int dup(u_int fd); }
- SYS_PIPE = 42 // { int pipe(void); }
- SYS_GETEGID = 43 // { gid_t getegid(void); }
- SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \
- SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, \
- SYS_GETGID = 47 // { gid_t getgid(void); }
- SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int \
- SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); }
- SYS_ACCT = 51 // { int acct(char *path); }
- SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, \
- SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, \
- SYS_REBOOT = 55 // { int reboot(int opt); }
- SYS_REVOKE = 56 // { int revoke(char *path); }
- SYS_SYMLINK = 57 // { int symlink(char *path, char *link); }
- SYS_READLINK = 58 // { ssize_t readlink(char *path, char *buf, \
- SYS_EXECVE = 59 // { int execve(char *fname, char **argv, \
- SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args \
- SYS_CHROOT = 61 // { int chroot(char *path); }
- SYS_MSYNC = 65 // { int msync(void *addr, size_t len, \
- SYS_VFORK = 66 // { int vfork(void); }
- SYS_SBRK = 69 // { int sbrk(int incr); }
- SYS_SSTK = 70 // { int sstk(int incr); }
- SYS_OVADVISE = 72 // { int ovadvise(int anom); } vadvise \
- SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); }
- SYS_MPROTECT = 74 // { int mprotect(const void *addr, size_t len, \
- SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, \
- SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \
- SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, \
- SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, \
- SYS_GETPGRP = 81 // { int getpgrp(void); }
- SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); }
- SYS_SETITIMER = 83 // { int setitimer(u_int which, struct \
- SYS_SWAPON = 85 // { int swapon(char *name); }
- SYS_GETITIMER = 86 // { int getitimer(u_int which, \
- SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); }
- SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); }
- SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); }
- SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \
- SYS_FSYNC = 95 // { int fsync(int fd); }
- SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, \
- SYS_SOCKET = 97 // { int socket(int domain, int type, \
- SYS_CONNECT = 98 // { int connect(int s, caddr_t name, \
- SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); }
- SYS_BIND = 104 // { int bind(int s, caddr_t name, \
- SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \
- SYS_LISTEN = 106 // { int listen(int s, int backlog); }
- SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \
- SYS_GETRUSAGE = 117 // { int getrusage(int who, \
- SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \
- SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, \
- SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \
- SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \
- SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); }
- SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); }
- SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); }
- SYS_SETREGID = 127 // { int setregid(int rgid, int egid); }
- SYS_RENAME = 128 // { int rename(char *from, char *to); }
- SYS_FLOCK = 131 // { int flock(int fd, int how); }
- SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); }
- SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \
- SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); }
- SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, \
- SYS_MKDIR = 136 // { int mkdir(char *path, int mode); }
- SYS_RMDIR = 137 // { int rmdir(char *path); }
- SYS_UTIMES = 138 // { int utimes(char *path, \
- SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \
- SYS_SETSID = 147 // { int setsid(void); }
- SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \
- SYS_LGETFH = 160 // { int lgetfh(char *fname, \
- SYS_GETFH = 161 // { int getfh(char *fname, \
- SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); }
- SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \
- SYS_FREEBSD6_PREAD = 173 // { ssize_t freebsd6_pread(int fd, void *buf, \
- SYS_FREEBSD6_PWRITE = 174 // { ssize_t freebsd6_pwrite(int fd, \
- SYS_SETFIB = 175 // { int setfib(int fibnum); }
- SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); }
- SYS_SETGID = 181 // { int setgid(gid_t gid); }
- SYS_SETEGID = 182 // { int setegid(gid_t egid); }
- SYS_SETEUID = 183 // { int seteuid(uid_t euid); }
- SYS_STAT = 188 // { int stat(char *path, struct stat *ub); }
- SYS_FSTAT = 189 // { int fstat(int fd, struct stat *sb); }
- SYS_LSTAT = 190 // { int lstat(char *path, struct stat *ub); }
- SYS_PATHCONF = 191 // { int pathconf(char *path, int name); }
- SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); }
- SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \
- SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \
- SYS_GETDIRENTRIES = 196 // { int getdirentries(int fd, char *buf, \
- SYS_FREEBSD6_MMAP = 197 // { caddr_t freebsd6_mmap(caddr_t addr, \
- SYS_FREEBSD6_LSEEK = 199 // { off_t freebsd6_lseek(int fd, int pad, \
- SYS_FREEBSD6_TRUNCATE = 200 // { int freebsd6_truncate(char *path, int pad, \
- SYS_FREEBSD6_FTRUNCATE = 201 // { int freebsd6_ftruncate(int fd, int pad, \
- SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, \
- SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); }
- SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); }
- SYS_UNDELETE = 205 // { int undelete(char *path); }
- SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); }
- SYS_GETPGID = 207 // { int getpgid(pid_t pid); }
- SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \
- SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \
- SYS_CLOCK_SETTIME = 233 // { int clock_settime( \
- SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \
- SYS_KTIMER_CREATE = 235 // { int ktimer_create(clockid_t clock_id, \
- SYS_KTIMER_DELETE = 236 // { int ktimer_delete(int timerid); }
- SYS_KTIMER_SETTIME = 237 // { int ktimer_settime(int timerid, int flags, \
- SYS_KTIMER_GETTIME = 238 // { int ktimer_gettime(int timerid, struct \
- SYS_KTIMER_GETOVERRUN = 239 // { int ktimer_getoverrun(int timerid); }
- SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \
- SYS_FFCLOCK_GETCOUNTER = 241 // { int ffclock_getcounter(ffcounter *ffcount); }
- SYS_FFCLOCK_SETESTIMATE = 242 // { int ffclock_setestimate( \
- SYS_FFCLOCK_GETESTIMATE = 243 // { int ffclock_getestimate( \
- SYS_CLOCK_GETCPUCLOCKID2 = 247 // { int clock_getcpuclockid2(id_t id,\
- SYS_NTP_GETTIME = 248 // { int ntp_gettime(struct ntptimeval *ntvp); }
- SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, \
- SYS_RFORK = 251 // { int rfork(int flags); }
- SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, \
- SYS_ISSETUGID = 253 // { int issetugid(void); }
- SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); }
- SYS_GETDENTS = 272 // { int getdents(int fd, char *buf, \
- SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); }
- SYS_LUTIMES = 276 // { int lutimes(char *path, \
- SYS_NSTAT = 278 // { int nstat(char *path, struct nstat *ub); }
- SYS_NFSTAT = 279 // { int nfstat(int fd, struct nstat *sb); }
- SYS_NLSTAT = 280 // { int nlstat(char *path, struct nstat *ub); }
- SYS_PREADV = 289 // { ssize_t preadv(int fd, struct iovec *iovp, \
- SYS_PWRITEV = 290 // { ssize_t pwritev(int fd, struct iovec *iovp, \
- SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, \
- SYS_FHSTAT = 299 // { int fhstat(const struct fhandle *u_fhp, \
- SYS_MODNEXT = 300 // { int modnext(int modid); }
- SYS_MODSTAT = 301 // { int modstat(int modid, \
- SYS_MODFNEXT = 302 // { int modfnext(int modid); }
- SYS_MODFIND = 303 // { int modfind(const char *name); }
- SYS_KLDLOAD = 304 // { int kldload(const char *file); }
- SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); }
- SYS_KLDFIND = 306 // { int kldfind(const char *file); }
- SYS_KLDNEXT = 307 // { int kldnext(int fileid); }
- SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct \
- SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); }
- SYS_GETSID = 310 // { int getsid(pid_t pid); }
- SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, \
- SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, \
- SYS_YIELD = 321 // { int yield(void); }
- SYS_MLOCKALL = 324 // { int mlockall(int how); }
- SYS_MUNLOCKALL = 325 // { int munlockall(void); }
- SYS___GETCWD = 326 // { int __getcwd(char *buf, u_int buflen); }
- SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, \
- SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct \
- SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int \
- SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); }
- SYS_SCHED_YIELD = 331 // { int sched_yield (void); }
- SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); }
- SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); }
- SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, \
- SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); }
- SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, \
- SYS_JAIL = 338 // { int jail(struct jail *jail); }
- SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, \
- SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); }
- SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); }
- SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set, \
- SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set, \
- SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \
- SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \
- SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, \
- SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, \
- SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \
- SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, \
- SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \
- SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, \
- SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \
- SYS_EXTATTR_SET_FILE = 356 // { ssize_t extattr_set_file( \
- SYS_EXTATTR_GET_FILE = 357 // { ssize_t extattr_get_file( \
- SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \
- SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, \
- SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, \
- SYS_KQUEUE = 362 // { int kqueue(void); }
- SYS_KEVENT = 363 // { int kevent(int fd, \
- SYS_EXTATTR_SET_FD = 371 // { ssize_t extattr_set_fd(int fd, \
- SYS_EXTATTR_GET_FD = 372 // { ssize_t extattr_get_fd(int fd, \
- SYS_EXTATTR_DELETE_FD = 373 // { int extattr_delete_fd(int fd, \
- SYS___SETUGID = 374 // { int __setugid(int flag); }
- SYS_EACCESS = 376 // { int eaccess(char *path, int amode); }
- SYS_NMOUNT = 378 // { int nmount(struct iovec *iovp, \
- SYS___MAC_GET_PROC = 384 // { int __mac_get_proc(struct mac *mac_p); }
- SYS___MAC_SET_PROC = 385 // { int __mac_set_proc(struct mac *mac_p); }
- SYS___MAC_GET_FD = 386 // { int __mac_get_fd(int fd, \
- SYS___MAC_GET_FILE = 387 // { int __mac_get_file(const char *path_p, \
- SYS___MAC_SET_FD = 388 // { int __mac_set_fd(int fd, \
- SYS___MAC_SET_FILE = 389 // { int __mac_set_file(const char *path_p, \
- SYS_KENV = 390 // { int kenv(int what, const char *name, \
- SYS_LCHFLAGS = 391 // { int lchflags(const char *path, \
- SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, \
- SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, \
- SYS_MAC_SYSCALL = 394 // { int mac_syscall(const char *policy, \
- SYS_GETFSSTAT = 395 // { int getfsstat(struct statfs *buf, \
- SYS_STATFS = 396 // { int statfs(char *path, \
- SYS_FSTATFS = 397 // { int fstatfs(int fd, struct statfs *buf); }
- SYS_FHSTATFS = 398 // { int fhstatfs(const struct fhandle *u_fhp, \
- SYS___MAC_GET_PID = 409 // { int __mac_get_pid(pid_t pid, \
- SYS___MAC_GET_LINK = 410 // { int __mac_get_link(const char *path_p, \
- SYS___MAC_SET_LINK = 411 // { int __mac_set_link(const char *path_p, \
- SYS_EXTATTR_SET_LINK = 412 // { ssize_t extattr_set_link( \
- SYS_EXTATTR_GET_LINK = 413 // { ssize_t extattr_get_link( \
- SYS_EXTATTR_DELETE_LINK = 414 // { int extattr_delete_link( \
- SYS___MAC_EXECVE = 415 // { int __mac_execve(char *fname, char **argv, \
- SYS_SIGACTION = 416 // { int sigaction(int sig, \
- SYS_SIGRETURN = 417 // { int sigreturn( \
- SYS_GETCONTEXT = 421 // { int getcontext(struct __ucontext *ucp); }
- SYS_SETCONTEXT = 422 // { int setcontext( \
- SYS_SWAPCONTEXT = 423 // { int swapcontext(struct __ucontext *oucp, \
- SYS_SWAPOFF = 424 // { int swapoff(const char *name); }
- SYS___ACL_GET_LINK = 425 // { int __acl_get_link(const char *path, \
- SYS___ACL_SET_LINK = 426 // { int __acl_set_link(const char *path, \
- SYS___ACL_DELETE_LINK = 427 // { int __acl_delete_link(const char *path, \
- SYS___ACL_ACLCHECK_LINK = 428 // { int __acl_aclcheck_link(const char *path, \
- SYS_SIGWAIT = 429 // { int sigwait(const sigset_t *set, \
- SYS_THR_CREATE = 430 // { int thr_create(ucontext_t *ctx, long *id, \
- SYS_THR_EXIT = 431 // { void thr_exit(long *state); }
- SYS_THR_SELF = 432 // { int thr_self(long *id); }
- SYS_THR_KILL = 433 // { int thr_kill(long id, int sig); }
- SYS__UMTX_LOCK = 434 // { int _umtx_lock(struct umtx *umtx); }
- SYS__UMTX_UNLOCK = 435 // { int _umtx_unlock(struct umtx *umtx); }
- SYS_JAIL_ATTACH = 436 // { int jail_attach(int jid); }
- SYS_EXTATTR_LIST_FD = 437 // { ssize_t extattr_list_fd(int fd, \
- SYS_EXTATTR_LIST_FILE = 438 // { ssize_t extattr_list_file( \
- SYS_EXTATTR_LIST_LINK = 439 // { ssize_t extattr_list_link( \
- SYS_THR_SUSPEND = 442 // { int thr_suspend( \
- SYS_THR_WAKE = 443 // { int thr_wake(long id); }
- SYS_KLDUNLOADF = 444 // { int kldunloadf(int fileid, int flags); }
- SYS_AUDIT = 445 // { int audit(const void *record, \
- SYS_AUDITON = 446 // { int auditon(int cmd, void *data, \
- SYS_GETAUID = 447 // { int getauid(uid_t *auid); }
- SYS_SETAUID = 448 // { int setauid(uid_t *auid); }
- SYS_GETAUDIT = 449 // { int getaudit(struct auditinfo *auditinfo); }
- SYS_SETAUDIT = 450 // { int setaudit(struct auditinfo *auditinfo); }
- SYS_GETAUDIT_ADDR = 451 // { int getaudit_addr( \
- SYS_SETAUDIT_ADDR = 452 // { int setaudit_addr( \
- SYS_AUDITCTL = 453 // { int auditctl(char *path); }
- SYS__UMTX_OP = 454 // { int _umtx_op(void *obj, int op, \
- SYS_THR_NEW = 455 // { int thr_new(struct thr_param *param, \
- SYS_SIGQUEUE = 456 // { int sigqueue(pid_t pid, int signum, void *value); }
- SYS_ABORT2 = 463 // { int abort2(const char *why, int nargs, void **args); }
- SYS_THR_SET_NAME = 464 // { int thr_set_name(long id, const char *name); }
- SYS_RTPRIO_THREAD = 466 // { int rtprio_thread(int function, \
- SYS_SCTP_PEELOFF = 471 // { int sctp_peeloff(int sd, uint32_t name); }
- SYS_SCTP_GENERIC_SENDMSG = 472 // { int sctp_generic_sendmsg(int sd, caddr_t msg, int mlen, \
- SYS_SCTP_GENERIC_SENDMSG_IOV = 473 // { int sctp_generic_sendmsg_iov(int sd, struct iovec *iov, int iovlen, \
- SYS_SCTP_GENERIC_RECVMSG = 474 // { int sctp_generic_recvmsg(int sd, struct iovec *iov, int iovlen, \
- SYS_PREAD = 475 // { ssize_t pread(int fd, void *buf, \
- SYS_PWRITE = 476 // { ssize_t pwrite(int fd, const void *buf, \
- SYS_MMAP = 477 // { caddr_t mmap(caddr_t addr, size_t len, \
- SYS_LSEEK = 478 // { off_t lseek(int fd, off_t offset, \
- SYS_TRUNCATE = 479 // { int truncate(char *path, off_t length); }
- SYS_FTRUNCATE = 480 // { int ftruncate(int fd, off_t length); }
- SYS_THR_KILL2 = 481 // { int thr_kill2(pid_t pid, long id, int sig); }
- SYS_SHM_OPEN = 482 // { int shm_open(const char *path, int flags, \
- SYS_SHM_UNLINK = 483 // { int shm_unlink(const char *path); }
- SYS_CPUSET = 484 // { int cpuset(cpusetid_t *setid); }
- SYS_CPUSET_SETID = 485 // { int cpuset_setid(cpuwhich_t which, id_t id, \
- SYS_CPUSET_GETID = 486 // { int cpuset_getid(cpulevel_t level, \
- SYS_CPUSET_GETAFFINITY = 487 // { int cpuset_getaffinity(cpulevel_t level, \
- SYS_CPUSET_SETAFFINITY = 488 // { int cpuset_setaffinity(cpulevel_t level, \
- SYS_FACCESSAT = 489 // { int faccessat(int fd, char *path, int amode, \
- SYS_FCHMODAT = 490 // { int fchmodat(int fd, char *path, mode_t mode, \
- SYS_FCHOWNAT = 491 // { int fchownat(int fd, char *path, uid_t uid, \
- SYS_FEXECVE = 492 // { int fexecve(int fd, char **argv, \
- SYS_FSTATAT = 493 // { int fstatat(int fd, char *path, \
- SYS_FUTIMESAT = 494 // { int futimesat(int fd, char *path, \
- SYS_LINKAT = 495 // { int linkat(int fd1, char *path1, int fd2, \
- SYS_MKDIRAT = 496 // { int mkdirat(int fd, char *path, mode_t mode); }
- SYS_MKFIFOAT = 497 // { int mkfifoat(int fd, char *path, mode_t mode); }
- SYS_MKNODAT = 498 // { int mknodat(int fd, char *path, mode_t mode, \
- SYS_OPENAT = 499 // { int openat(int fd, char *path, int flag, \
- SYS_READLINKAT = 500 // { int readlinkat(int fd, char *path, char *buf, \
- SYS_RENAMEAT = 501 // { int renameat(int oldfd, char *old, int newfd, \
- SYS_SYMLINKAT = 502 // { int symlinkat(char *path1, int fd, \
- SYS_UNLINKAT = 503 // { int unlinkat(int fd, char *path, int flag); }
- SYS_POSIX_OPENPT = 504 // { int posix_openpt(int flags); }
- SYS_JAIL_GET = 506 // { int jail_get(struct iovec *iovp, \
- SYS_JAIL_SET = 507 // { int jail_set(struct iovec *iovp, \
- SYS_JAIL_REMOVE = 508 // { int jail_remove(int jid); }
- SYS_CLOSEFROM = 509 // { int closefrom(int lowfd); }
- SYS_LPATHCONF = 513 // { int lpathconf(char *path, int name); }
- SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }
- SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \
- SYS_CAP_ENTER = 516 // { int cap_enter(void); }
- SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }
- SYS_PDFORK = 518 // { int pdfork(int *fdp, int flags); }
- SYS_PDKILL = 519 // { int pdkill(int fd, int signum); }
- SYS_PDGETPID = 520 // { int pdgetpid(int fd, pid_t *pidp); }
- SYS_PSELECT = 522 // { int pselect(int nd, fd_set *in, \
- SYS_GETLOGINCLASS = 523 // { int getloginclass(char *namebuf, \
- SYS_SETLOGINCLASS = 524 // { int setloginclass(const char *namebuf); }
- SYS_RCTL_GET_RACCT = 525 // { int rctl_get_racct(const void *inbufp, \
- SYS_RCTL_GET_RULES = 526 // { int rctl_get_rules(const void *inbufp, \
- SYS_RCTL_GET_LIMITS = 527 // { int rctl_get_limits(const void *inbufp, \
- SYS_RCTL_ADD_RULE = 528 // { int rctl_add_rule(const void *inbufp, \
- SYS_RCTL_REMOVE_RULE = 529 // { int rctl_remove_rule(const void *inbufp, \
- SYS_POSIX_FALLOCATE = 530 // { int posix_fallocate(int fd, \
- SYS_POSIX_FADVISE = 531 // { int posix_fadvise(int fd, off_t offset, \
- SYS_WAIT6 = 532 // { int wait6(idtype_t idtype, id_t id, \
- SYS_BINDAT = 538 // { int bindat(int fd, int s, caddr_t name, \
- SYS_CONNECTAT = 539 // { int connectat(int fd, int s, caddr_t name, \
- SYS_CHFLAGSAT = 540 // { int chflagsat(int fd, const char *path, \
- SYS_ACCEPT4 = 541 // { int accept4(int s, \
- SYS_PIPE2 = 542 // { int pipe2(int *fildes, int flags); }
- SYS_PROCCTL = 544 // { int procctl(idtype_t idtype, id_t id, \
- SYS_PPOLL = 545 // { int ppoll(struct pollfd *fds, u_int nfds, \
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go
deleted file mode 100644
index 57a60ea1..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go
+++ /dev/null
@@ -1,351 +0,0 @@
-// mksysnum_freebsd.pl
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build amd64,freebsd
-
-package unix
-
-const (
- // SYS_NOSYS = 0; // { int nosys(void); } syscall nosys_args int
- SYS_EXIT = 1 // { void sys_exit(int rval); } exit \
- SYS_FORK = 2 // { int fork(void); }
- SYS_READ = 3 // { ssize_t read(int fd, void *buf, \
- SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, \
- SYS_OPEN = 5 // { int open(char *path, int flags, int mode); }
- SYS_CLOSE = 6 // { int close(int fd); }
- SYS_WAIT4 = 7 // { int wait4(int pid, int *status, \
- SYS_LINK = 9 // { int link(char *path, char *link); }
- SYS_UNLINK = 10 // { int unlink(char *path); }
- SYS_CHDIR = 12 // { int chdir(char *path); }
- SYS_FCHDIR = 13 // { int fchdir(int fd); }
- SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); }
- SYS_CHMOD = 15 // { int chmod(char *path, int mode); }
- SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); }
- SYS_OBREAK = 17 // { int obreak(char *nsize); } break \
- SYS_GETPID = 20 // { pid_t getpid(void); }
- SYS_MOUNT = 21 // { int mount(char *type, char *path, \
- SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); }
- SYS_SETUID = 23 // { int setuid(uid_t uid); }
- SYS_GETUID = 24 // { uid_t getuid(void); }
- SYS_GETEUID = 25 // { uid_t geteuid(void); }
- SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, \
- SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, \
- SYS_SENDMSG = 28 // { int sendmsg(int s, struct msghdr *msg, \
- SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, \
- SYS_ACCEPT = 30 // { int accept(int s, \
- SYS_GETPEERNAME = 31 // { int getpeername(int fdes, \
- SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, \
- SYS_ACCESS = 33 // { int access(char *path, int amode); }
- SYS_CHFLAGS = 34 // { int chflags(const char *path, u_long flags); }
- SYS_FCHFLAGS = 35 // { int fchflags(int fd, u_long flags); }
- SYS_SYNC = 36 // { int sync(void); }
- SYS_KILL = 37 // { int kill(int pid, int signum); }
- SYS_GETPPID = 39 // { pid_t getppid(void); }
- SYS_DUP = 41 // { int dup(u_int fd); }
- SYS_PIPE = 42 // { int pipe(void); }
- SYS_GETEGID = 43 // { gid_t getegid(void); }
- SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \
- SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, \
- SYS_GETGID = 47 // { gid_t getgid(void); }
- SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int \
- SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); }
- SYS_ACCT = 51 // { int acct(char *path); }
- SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, \
- SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, \
- SYS_REBOOT = 55 // { int reboot(int opt); }
- SYS_REVOKE = 56 // { int revoke(char *path); }
- SYS_SYMLINK = 57 // { int symlink(char *path, char *link); }
- SYS_READLINK = 58 // { ssize_t readlink(char *path, char *buf, \
- SYS_EXECVE = 59 // { int execve(char *fname, char **argv, \
- SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args \
- SYS_CHROOT = 61 // { int chroot(char *path); }
- SYS_MSYNC = 65 // { int msync(void *addr, size_t len, \
- SYS_VFORK = 66 // { int vfork(void); }
- SYS_SBRK = 69 // { int sbrk(int incr); }
- SYS_SSTK = 70 // { int sstk(int incr); }
- SYS_OVADVISE = 72 // { int ovadvise(int anom); } vadvise \
- SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); }
- SYS_MPROTECT = 74 // { int mprotect(const void *addr, size_t len, \
- SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, \
- SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \
- SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, \
- SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, \
- SYS_GETPGRP = 81 // { int getpgrp(void); }
- SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); }
- SYS_SETITIMER = 83 // { int setitimer(u_int which, struct \
- SYS_SWAPON = 85 // { int swapon(char *name); }
- SYS_GETITIMER = 86 // { int getitimer(u_int which, \
- SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); }
- SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); }
- SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); }
- SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \
- SYS_FSYNC = 95 // { int fsync(int fd); }
- SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, \
- SYS_SOCKET = 97 // { int socket(int domain, int type, \
- SYS_CONNECT = 98 // { int connect(int s, caddr_t name, \
- SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); }
- SYS_BIND = 104 // { int bind(int s, caddr_t name, \
- SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \
- SYS_LISTEN = 106 // { int listen(int s, int backlog); }
- SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \
- SYS_GETRUSAGE = 117 // { int getrusage(int who, \
- SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \
- SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, \
- SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \
- SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \
- SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); }
- SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); }
- SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); }
- SYS_SETREGID = 127 // { int setregid(int rgid, int egid); }
- SYS_RENAME = 128 // { int rename(char *from, char *to); }
- SYS_FLOCK = 131 // { int flock(int fd, int how); }
- SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); }
- SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \
- SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); }
- SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, \
- SYS_MKDIR = 136 // { int mkdir(char *path, int mode); }
- SYS_RMDIR = 137 // { int rmdir(char *path); }
- SYS_UTIMES = 138 // { int utimes(char *path, \
- SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \
- SYS_SETSID = 147 // { int setsid(void); }
- SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \
- SYS_LGETFH = 160 // { int lgetfh(char *fname, \
- SYS_GETFH = 161 // { int getfh(char *fname, \
- SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); }
- SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \
- SYS_FREEBSD6_PREAD = 173 // { ssize_t freebsd6_pread(int fd, void *buf, \
- SYS_FREEBSD6_PWRITE = 174 // { ssize_t freebsd6_pwrite(int fd, \
- SYS_SETFIB = 175 // { int setfib(int fibnum); }
- SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); }
- SYS_SETGID = 181 // { int setgid(gid_t gid); }
- SYS_SETEGID = 182 // { int setegid(gid_t egid); }
- SYS_SETEUID = 183 // { int seteuid(uid_t euid); }
- SYS_STAT = 188 // { int stat(char *path, struct stat *ub); }
- SYS_FSTAT = 189 // { int fstat(int fd, struct stat *sb); }
- SYS_LSTAT = 190 // { int lstat(char *path, struct stat *ub); }
- SYS_PATHCONF = 191 // { int pathconf(char *path, int name); }
- SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); }
- SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \
- SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \
- SYS_GETDIRENTRIES = 196 // { int getdirentries(int fd, char *buf, \
- SYS_FREEBSD6_MMAP = 197 // { caddr_t freebsd6_mmap(caddr_t addr, \
- SYS_FREEBSD6_LSEEK = 199 // { off_t freebsd6_lseek(int fd, int pad, \
- SYS_FREEBSD6_TRUNCATE = 200 // { int freebsd6_truncate(char *path, int pad, \
- SYS_FREEBSD6_FTRUNCATE = 201 // { int freebsd6_ftruncate(int fd, int pad, \
- SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, \
- SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); }
- SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); }
- SYS_UNDELETE = 205 // { int undelete(char *path); }
- SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); }
- SYS_GETPGID = 207 // { int getpgid(pid_t pid); }
- SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \
- SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \
- SYS_CLOCK_SETTIME = 233 // { int clock_settime( \
- SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \
- SYS_KTIMER_CREATE = 235 // { int ktimer_create(clockid_t clock_id, \
- SYS_KTIMER_DELETE = 236 // { int ktimer_delete(int timerid); }
- SYS_KTIMER_SETTIME = 237 // { int ktimer_settime(int timerid, int flags, \
- SYS_KTIMER_GETTIME = 238 // { int ktimer_gettime(int timerid, struct \
- SYS_KTIMER_GETOVERRUN = 239 // { int ktimer_getoverrun(int timerid); }
- SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \
- SYS_FFCLOCK_GETCOUNTER = 241 // { int ffclock_getcounter(ffcounter *ffcount); }
- SYS_FFCLOCK_SETESTIMATE = 242 // { int ffclock_setestimate( \
- SYS_FFCLOCK_GETESTIMATE = 243 // { int ffclock_getestimate( \
- SYS_CLOCK_GETCPUCLOCKID2 = 247 // { int clock_getcpuclockid2(id_t id,\
- SYS_NTP_GETTIME = 248 // { int ntp_gettime(struct ntptimeval *ntvp); }
- SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, \
- SYS_RFORK = 251 // { int rfork(int flags); }
- SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, \
- SYS_ISSETUGID = 253 // { int issetugid(void); }
- SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); }
- SYS_GETDENTS = 272 // { int getdents(int fd, char *buf, \
- SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); }
- SYS_LUTIMES = 276 // { int lutimes(char *path, \
- SYS_NSTAT = 278 // { int nstat(char *path, struct nstat *ub); }
- SYS_NFSTAT = 279 // { int nfstat(int fd, struct nstat *sb); }
- SYS_NLSTAT = 280 // { int nlstat(char *path, struct nstat *ub); }
- SYS_PREADV = 289 // { ssize_t preadv(int fd, struct iovec *iovp, \
- SYS_PWRITEV = 290 // { ssize_t pwritev(int fd, struct iovec *iovp, \
- SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, \
- SYS_FHSTAT = 299 // { int fhstat(const struct fhandle *u_fhp, \
- SYS_MODNEXT = 300 // { int modnext(int modid); }
- SYS_MODSTAT = 301 // { int modstat(int modid, \
- SYS_MODFNEXT = 302 // { int modfnext(int modid); }
- SYS_MODFIND = 303 // { int modfind(const char *name); }
- SYS_KLDLOAD = 304 // { int kldload(const char *file); }
- SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); }
- SYS_KLDFIND = 306 // { int kldfind(const char *file); }
- SYS_KLDNEXT = 307 // { int kldnext(int fileid); }
- SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct \
- SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); }
- SYS_GETSID = 310 // { int getsid(pid_t pid); }
- SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, \
- SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, \
- SYS_YIELD = 321 // { int yield(void); }
- SYS_MLOCKALL = 324 // { int mlockall(int how); }
- SYS_MUNLOCKALL = 325 // { int munlockall(void); }
- SYS___GETCWD = 326 // { int __getcwd(char *buf, u_int buflen); }
- SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, \
- SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct \
- SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int \
- SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); }
- SYS_SCHED_YIELD = 331 // { int sched_yield (void); }
- SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); }
- SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); }
- SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, \
- SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); }
- SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, \
- SYS_JAIL = 338 // { int jail(struct jail *jail); }
- SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, \
- SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); }
- SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); }
- SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set, \
- SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set, \
- SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \
- SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \
- SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, \
- SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, \
- SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \
- SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, \
- SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \
- SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, \
- SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \
- SYS_EXTATTR_SET_FILE = 356 // { ssize_t extattr_set_file( \
- SYS_EXTATTR_GET_FILE = 357 // { ssize_t extattr_get_file( \
- SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \
- SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, \
- SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, \
- SYS_KQUEUE = 362 // { int kqueue(void); }
- SYS_KEVENT = 363 // { int kevent(int fd, \
- SYS_EXTATTR_SET_FD = 371 // { ssize_t extattr_set_fd(int fd, \
- SYS_EXTATTR_GET_FD = 372 // { ssize_t extattr_get_fd(int fd, \
- SYS_EXTATTR_DELETE_FD = 373 // { int extattr_delete_fd(int fd, \
- SYS___SETUGID = 374 // { int __setugid(int flag); }
- SYS_EACCESS = 376 // { int eaccess(char *path, int amode); }
- SYS_NMOUNT = 378 // { int nmount(struct iovec *iovp, \
- SYS___MAC_GET_PROC = 384 // { int __mac_get_proc(struct mac *mac_p); }
- SYS___MAC_SET_PROC = 385 // { int __mac_set_proc(struct mac *mac_p); }
- SYS___MAC_GET_FD = 386 // { int __mac_get_fd(int fd, \
- SYS___MAC_GET_FILE = 387 // { int __mac_get_file(const char *path_p, \
- SYS___MAC_SET_FD = 388 // { int __mac_set_fd(int fd, \
- SYS___MAC_SET_FILE = 389 // { int __mac_set_file(const char *path_p, \
- SYS_KENV = 390 // { int kenv(int what, const char *name, \
- SYS_LCHFLAGS = 391 // { int lchflags(const char *path, \
- SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, \
- SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, \
- SYS_MAC_SYSCALL = 394 // { int mac_syscall(const char *policy, \
- SYS_GETFSSTAT = 395 // { int getfsstat(struct statfs *buf, \
- SYS_STATFS = 396 // { int statfs(char *path, \
- SYS_FSTATFS = 397 // { int fstatfs(int fd, struct statfs *buf); }
- SYS_FHSTATFS = 398 // { int fhstatfs(const struct fhandle *u_fhp, \
- SYS___MAC_GET_PID = 409 // { int __mac_get_pid(pid_t pid, \
- SYS___MAC_GET_LINK = 410 // { int __mac_get_link(const char *path_p, \
- SYS___MAC_SET_LINK = 411 // { int __mac_set_link(const char *path_p, \
- SYS_EXTATTR_SET_LINK = 412 // { ssize_t extattr_set_link( \
- SYS_EXTATTR_GET_LINK = 413 // { ssize_t extattr_get_link( \
- SYS_EXTATTR_DELETE_LINK = 414 // { int extattr_delete_link( \
- SYS___MAC_EXECVE = 415 // { int __mac_execve(char *fname, char **argv, \
- SYS_SIGACTION = 416 // { int sigaction(int sig, \
- SYS_SIGRETURN = 417 // { int sigreturn( \
- SYS_GETCONTEXT = 421 // { int getcontext(struct __ucontext *ucp); }
- SYS_SETCONTEXT = 422 // { int setcontext( \
- SYS_SWAPCONTEXT = 423 // { int swapcontext(struct __ucontext *oucp, \
- SYS_SWAPOFF = 424 // { int swapoff(const char *name); }
- SYS___ACL_GET_LINK = 425 // { int __acl_get_link(const char *path, \
- SYS___ACL_SET_LINK = 426 // { int __acl_set_link(const char *path, \
- SYS___ACL_DELETE_LINK = 427 // { int __acl_delete_link(const char *path, \
- SYS___ACL_ACLCHECK_LINK = 428 // { int __acl_aclcheck_link(const char *path, \
- SYS_SIGWAIT = 429 // { int sigwait(const sigset_t *set, \
- SYS_THR_CREATE = 430 // { int thr_create(ucontext_t *ctx, long *id, \
- SYS_THR_EXIT = 431 // { void thr_exit(long *state); }
- SYS_THR_SELF = 432 // { int thr_self(long *id); }
- SYS_THR_KILL = 433 // { int thr_kill(long id, int sig); }
- SYS__UMTX_LOCK = 434 // { int _umtx_lock(struct umtx *umtx); }
- SYS__UMTX_UNLOCK = 435 // { int _umtx_unlock(struct umtx *umtx); }
- SYS_JAIL_ATTACH = 436 // { int jail_attach(int jid); }
- SYS_EXTATTR_LIST_FD = 437 // { ssize_t extattr_list_fd(int fd, \
- SYS_EXTATTR_LIST_FILE = 438 // { ssize_t extattr_list_file( \
- SYS_EXTATTR_LIST_LINK = 439 // { ssize_t extattr_list_link( \
- SYS_THR_SUSPEND = 442 // { int thr_suspend( \
- SYS_THR_WAKE = 443 // { int thr_wake(long id); }
- SYS_KLDUNLOADF = 444 // { int kldunloadf(int fileid, int flags); }
- SYS_AUDIT = 445 // { int audit(const void *record, \
- SYS_AUDITON = 446 // { int auditon(int cmd, void *data, \
- SYS_GETAUID = 447 // { int getauid(uid_t *auid); }
- SYS_SETAUID = 448 // { int setauid(uid_t *auid); }
- SYS_GETAUDIT = 449 // { int getaudit(struct auditinfo *auditinfo); }
- SYS_SETAUDIT = 450 // { int setaudit(struct auditinfo *auditinfo); }
- SYS_GETAUDIT_ADDR = 451 // { int getaudit_addr( \
- SYS_SETAUDIT_ADDR = 452 // { int setaudit_addr( \
- SYS_AUDITCTL = 453 // { int auditctl(char *path); }
- SYS__UMTX_OP = 454 // { int _umtx_op(void *obj, int op, \
- SYS_THR_NEW = 455 // { int thr_new(struct thr_param *param, \
- SYS_SIGQUEUE = 456 // { int sigqueue(pid_t pid, int signum, void *value); }
- SYS_ABORT2 = 463 // { int abort2(const char *why, int nargs, void **args); }
- SYS_THR_SET_NAME = 464 // { int thr_set_name(long id, const char *name); }
- SYS_RTPRIO_THREAD = 466 // { int rtprio_thread(int function, \
- SYS_SCTP_PEELOFF = 471 // { int sctp_peeloff(int sd, uint32_t name); }
- SYS_SCTP_GENERIC_SENDMSG = 472 // { int sctp_generic_sendmsg(int sd, caddr_t msg, int mlen, \
- SYS_SCTP_GENERIC_SENDMSG_IOV = 473 // { int sctp_generic_sendmsg_iov(int sd, struct iovec *iov, int iovlen, \
- SYS_SCTP_GENERIC_RECVMSG = 474 // { int sctp_generic_recvmsg(int sd, struct iovec *iov, int iovlen, \
- SYS_PREAD = 475 // { ssize_t pread(int fd, void *buf, \
- SYS_PWRITE = 476 // { ssize_t pwrite(int fd, const void *buf, \
- SYS_MMAP = 477 // { caddr_t mmap(caddr_t addr, size_t len, \
- SYS_LSEEK = 478 // { off_t lseek(int fd, off_t offset, \
- SYS_TRUNCATE = 479 // { int truncate(char *path, off_t length); }
- SYS_FTRUNCATE = 480 // { int ftruncate(int fd, off_t length); }
- SYS_THR_KILL2 = 481 // { int thr_kill2(pid_t pid, long id, int sig); }
- SYS_SHM_OPEN = 482 // { int shm_open(const char *path, int flags, \
- SYS_SHM_UNLINK = 483 // { int shm_unlink(const char *path); }
- SYS_CPUSET = 484 // { int cpuset(cpusetid_t *setid); }
- SYS_CPUSET_SETID = 485 // { int cpuset_setid(cpuwhich_t which, id_t id, \
- SYS_CPUSET_GETID = 486 // { int cpuset_getid(cpulevel_t level, \
- SYS_CPUSET_GETAFFINITY = 487 // { int cpuset_getaffinity(cpulevel_t level, \
- SYS_CPUSET_SETAFFINITY = 488 // { int cpuset_setaffinity(cpulevel_t level, \
- SYS_FACCESSAT = 489 // { int faccessat(int fd, char *path, int amode, \
- SYS_FCHMODAT = 490 // { int fchmodat(int fd, char *path, mode_t mode, \
- SYS_FCHOWNAT = 491 // { int fchownat(int fd, char *path, uid_t uid, \
- SYS_FEXECVE = 492 // { int fexecve(int fd, char **argv, \
- SYS_FSTATAT = 493 // { int fstatat(int fd, char *path, \
- SYS_FUTIMESAT = 494 // { int futimesat(int fd, char *path, \
- SYS_LINKAT = 495 // { int linkat(int fd1, char *path1, int fd2, \
- SYS_MKDIRAT = 496 // { int mkdirat(int fd, char *path, mode_t mode); }
- SYS_MKFIFOAT = 497 // { int mkfifoat(int fd, char *path, mode_t mode); }
- SYS_MKNODAT = 498 // { int mknodat(int fd, char *path, mode_t mode, \
- SYS_OPENAT = 499 // { int openat(int fd, char *path, int flag, \
- SYS_READLINKAT = 500 // { int readlinkat(int fd, char *path, char *buf, \
- SYS_RENAMEAT = 501 // { int renameat(int oldfd, char *old, int newfd, \
- SYS_SYMLINKAT = 502 // { int symlinkat(char *path1, int fd, \
- SYS_UNLINKAT = 503 // { int unlinkat(int fd, char *path, int flag); }
- SYS_POSIX_OPENPT = 504 // { int posix_openpt(int flags); }
- SYS_JAIL_GET = 506 // { int jail_get(struct iovec *iovp, \
- SYS_JAIL_SET = 507 // { int jail_set(struct iovec *iovp, \
- SYS_JAIL_REMOVE = 508 // { int jail_remove(int jid); }
- SYS_CLOSEFROM = 509 // { int closefrom(int lowfd); }
- SYS_LPATHCONF = 513 // { int lpathconf(char *path, int name); }
- SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }
- SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \
- SYS_CAP_ENTER = 516 // { int cap_enter(void); }
- SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }
- SYS_PDFORK = 518 // { int pdfork(int *fdp, int flags); }
- SYS_PDKILL = 519 // { int pdkill(int fd, int signum); }
- SYS_PDGETPID = 520 // { int pdgetpid(int fd, pid_t *pidp); }
- SYS_PSELECT = 522 // { int pselect(int nd, fd_set *in, \
- SYS_GETLOGINCLASS = 523 // { int getloginclass(char *namebuf, \
- SYS_SETLOGINCLASS = 524 // { int setloginclass(const char *namebuf); }
- SYS_RCTL_GET_RACCT = 525 // { int rctl_get_racct(const void *inbufp, \
- SYS_RCTL_GET_RULES = 526 // { int rctl_get_rules(const void *inbufp, \
- SYS_RCTL_GET_LIMITS = 527 // { int rctl_get_limits(const void *inbufp, \
- SYS_RCTL_ADD_RULE = 528 // { int rctl_add_rule(const void *inbufp, \
- SYS_RCTL_REMOVE_RULE = 529 // { int rctl_remove_rule(const void *inbufp, \
- SYS_POSIX_FALLOCATE = 530 // { int posix_fallocate(int fd, \
- SYS_POSIX_FADVISE = 531 // { int posix_fadvise(int fd, off_t offset, \
- SYS_WAIT6 = 532 // { int wait6(idtype_t idtype, id_t id, \
- SYS_BINDAT = 538 // { int bindat(int fd, int s, caddr_t name, \
- SYS_CONNECTAT = 539 // { int connectat(int fd, int s, caddr_t name, \
- SYS_CHFLAGSAT = 540 // { int chflagsat(int fd, const char *path, \
- SYS_ACCEPT4 = 541 // { int accept4(int s, \
- SYS_PIPE2 = 542 // { int pipe2(int *fildes, int flags); }
- SYS_PROCCTL = 544 // { int procctl(idtype_t idtype, id_t id, \
- SYS_PPOLL = 545 // { int ppoll(struct pollfd *fds, u_int nfds, \
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go
deleted file mode 100644
index 206b9f61..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go
+++ /dev/null
@@ -1,351 +0,0 @@
-// mksysnum_freebsd.pl
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build arm,freebsd
-
-package unix
-
-const (
- // SYS_NOSYS = 0; // { int nosys(void); } syscall nosys_args int
- SYS_EXIT = 1 // { void sys_exit(int rval); } exit \
- SYS_FORK = 2 // { int fork(void); }
- SYS_READ = 3 // { ssize_t read(int fd, void *buf, \
- SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, \
- SYS_OPEN = 5 // { int open(char *path, int flags, int mode); }
- SYS_CLOSE = 6 // { int close(int fd); }
- SYS_WAIT4 = 7 // { int wait4(int pid, int *status, \
- SYS_LINK = 9 // { int link(char *path, char *link); }
- SYS_UNLINK = 10 // { int unlink(char *path); }
- SYS_CHDIR = 12 // { int chdir(char *path); }
- SYS_FCHDIR = 13 // { int fchdir(int fd); }
- SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); }
- SYS_CHMOD = 15 // { int chmod(char *path, int mode); }
- SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); }
- SYS_OBREAK = 17 // { int obreak(char *nsize); } break \
- SYS_GETPID = 20 // { pid_t getpid(void); }
- SYS_MOUNT = 21 // { int mount(char *type, char *path, \
- SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); }
- SYS_SETUID = 23 // { int setuid(uid_t uid); }
- SYS_GETUID = 24 // { uid_t getuid(void); }
- SYS_GETEUID = 25 // { uid_t geteuid(void); }
- SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, \
- SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, \
- SYS_SENDMSG = 28 // { int sendmsg(int s, struct msghdr *msg, \
- SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, \
- SYS_ACCEPT = 30 // { int accept(int s, \
- SYS_GETPEERNAME = 31 // { int getpeername(int fdes, \
- SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, \
- SYS_ACCESS = 33 // { int access(char *path, int amode); }
- SYS_CHFLAGS = 34 // { int chflags(const char *path, u_long flags); }
- SYS_FCHFLAGS = 35 // { int fchflags(int fd, u_long flags); }
- SYS_SYNC = 36 // { int sync(void); }
- SYS_KILL = 37 // { int kill(int pid, int signum); }
- SYS_GETPPID = 39 // { pid_t getppid(void); }
- SYS_DUP = 41 // { int dup(u_int fd); }
- SYS_PIPE = 42 // { int pipe(void); }
- SYS_GETEGID = 43 // { gid_t getegid(void); }
- SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \
- SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, \
- SYS_GETGID = 47 // { gid_t getgid(void); }
- SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int \
- SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); }
- SYS_ACCT = 51 // { int acct(char *path); }
- SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, \
- SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, \
- SYS_REBOOT = 55 // { int reboot(int opt); }
- SYS_REVOKE = 56 // { int revoke(char *path); }
- SYS_SYMLINK = 57 // { int symlink(char *path, char *link); }
- SYS_READLINK = 58 // { ssize_t readlink(char *path, char *buf, \
- SYS_EXECVE = 59 // { int execve(char *fname, char **argv, \
- SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args \
- SYS_CHROOT = 61 // { int chroot(char *path); }
- SYS_MSYNC = 65 // { int msync(void *addr, size_t len, \
- SYS_VFORK = 66 // { int vfork(void); }
- SYS_SBRK = 69 // { int sbrk(int incr); }
- SYS_SSTK = 70 // { int sstk(int incr); }
- SYS_OVADVISE = 72 // { int ovadvise(int anom); } vadvise \
- SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); }
- SYS_MPROTECT = 74 // { int mprotect(const void *addr, size_t len, \
- SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, \
- SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \
- SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, \
- SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, \
- SYS_GETPGRP = 81 // { int getpgrp(void); }
- SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); }
- SYS_SETITIMER = 83 // { int setitimer(u_int which, struct \
- SYS_SWAPON = 85 // { int swapon(char *name); }
- SYS_GETITIMER = 86 // { int getitimer(u_int which, \
- SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); }
- SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); }
- SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); }
- SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \
- SYS_FSYNC = 95 // { int fsync(int fd); }
- SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, \
- SYS_SOCKET = 97 // { int socket(int domain, int type, \
- SYS_CONNECT = 98 // { int connect(int s, caddr_t name, \
- SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); }
- SYS_BIND = 104 // { int bind(int s, caddr_t name, \
- SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \
- SYS_LISTEN = 106 // { int listen(int s, int backlog); }
- SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \
- SYS_GETRUSAGE = 117 // { int getrusage(int who, \
- SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \
- SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, \
- SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \
- SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \
- SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); }
- SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); }
- SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); }
- SYS_SETREGID = 127 // { int setregid(int rgid, int egid); }
- SYS_RENAME = 128 // { int rename(char *from, char *to); }
- SYS_FLOCK = 131 // { int flock(int fd, int how); }
- SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); }
- SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \
- SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); }
- SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, \
- SYS_MKDIR = 136 // { int mkdir(char *path, int mode); }
- SYS_RMDIR = 137 // { int rmdir(char *path); }
- SYS_UTIMES = 138 // { int utimes(char *path, \
- SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \
- SYS_SETSID = 147 // { int setsid(void); }
- SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \
- SYS_LGETFH = 160 // { int lgetfh(char *fname, \
- SYS_GETFH = 161 // { int getfh(char *fname, \
- SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); }
- SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \
- SYS_FREEBSD6_PREAD = 173 // { ssize_t freebsd6_pread(int fd, void *buf, \
- SYS_FREEBSD6_PWRITE = 174 // { ssize_t freebsd6_pwrite(int fd, \
- SYS_SETFIB = 175 // { int setfib(int fibnum); }
- SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); }
- SYS_SETGID = 181 // { int setgid(gid_t gid); }
- SYS_SETEGID = 182 // { int setegid(gid_t egid); }
- SYS_SETEUID = 183 // { int seteuid(uid_t euid); }
- SYS_STAT = 188 // { int stat(char *path, struct stat *ub); }
- SYS_FSTAT = 189 // { int fstat(int fd, struct stat *sb); }
- SYS_LSTAT = 190 // { int lstat(char *path, struct stat *ub); }
- SYS_PATHCONF = 191 // { int pathconf(char *path, int name); }
- SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); }
- SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \
- SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \
- SYS_GETDIRENTRIES = 196 // { int getdirentries(int fd, char *buf, \
- SYS_FREEBSD6_MMAP = 197 // { caddr_t freebsd6_mmap(caddr_t addr, \
- SYS_FREEBSD6_LSEEK = 199 // { off_t freebsd6_lseek(int fd, int pad, \
- SYS_FREEBSD6_TRUNCATE = 200 // { int freebsd6_truncate(char *path, int pad, \
- SYS_FREEBSD6_FTRUNCATE = 201 // { int freebsd6_ftruncate(int fd, int pad, \
- SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, \
- SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); }
- SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); }
- SYS_UNDELETE = 205 // { int undelete(char *path); }
- SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); }
- SYS_GETPGID = 207 // { int getpgid(pid_t pid); }
- SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \
- SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \
- SYS_CLOCK_SETTIME = 233 // { int clock_settime( \
- SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \
- SYS_KTIMER_CREATE = 235 // { int ktimer_create(clockid_t clock_id, \
- SYS_KTIMER_DELETE = 236 // { int ktimer_delete(int timerid); }
- SYS_KTIMER_SETTIME = 237 // { int ktimer_settime(int timerid, int flags, \
- SYS_KTIMER_GETTIME = 238 // { int ktimer_gettime(int timerid, struct \
- SYS_KTIMER_GETOVERRUN = 239 // { int ktimer_getoverrun(int timerid); }
- SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \
- SYS_FFCLOCK_GETCOUNTER = 241 // { int ffclock_getcounter(ffcounter *ffcount); }
- SYS_FFCLOCK_SETESTIMATE = 242 // { int ffclock_setestimate( \
- SYS_FFCLOCK_GETESTIMATE = 243 // { int ffclock_getestimate( \
- SYS_CLOCK_GETCPUCLOCKID2 = 247 // { int clock_getcpuclockid2(id_t id,\
- SYS_NTP_GETTIME = 248 // { int ntp_gettime(struct ntptimeval *ntvp); }
- SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, \
- SYS_RFORK = 251 // { int rfork(int flags); }
- SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, \
- SYS_ISSETUGID = 253 // { int issetugid(void); }
- SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); }
- SYS_GETDENTS = 272 // { int getdents(int fd, char *buf, \
- SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); }
- SYS_LUTIMES = 276 // { int lutimes(char *path, \
- SYS_NSTAT = 278 // { int nstat(char *path, struct nstat *ub); }
- SYS_NFSTAT = 279 // { int nfstat(int fd, struct nstat *sb); }
- SYS_NLSTAT = 280 // { int nlstat(char *path, struct nstat *ub); }
- SYS_PREADV = 289 // { ssize_t preadv(int fd, struct iovec *iovp, \
- SYS_PWRITEV = 290 // { ssize_t pwritev(int fd, struct iovec *iovp, \
- SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, \
- SYS_FHSTAT = 299 // { int fhstat(const struct fhandle *u_fhp, \
- SYS_MODNEXT = 300 // { int modnext(int modid); }
- SYS_MODSTAT = 301 // { int modstat(int modid, \
- SYS_MODFNEXT = 302 // { int modfnext(int modid); }
- SYS_MODFIND = 303 // { int modfind(const char *name); }
- SYS_KLDLOAD = 304 // { int kldload(const char *file); }
- SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); }
- SYS_KLDFIND = 306 // { int kldfind(const char *file); }
- SYS_KLDNEXT = 307 // { int kldnext(int fileid); }
- SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct \
- SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); }
- SYS_GETSID = 310 // { int getsid(pid_t pid); }
- SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, \
- SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, \
- SYS_YIELD = 321 // { int yield(void); }
- SYS_MLOCKALL = 324 // { int mlockall(int how); }
- SYS_MUNLOCKALL = 325 // { int munlockall(void); }
- SYS___GETCWD = 326 // { int __getcwd(char *buf, u_int buflen); }
- SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, \
- SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct \
- SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int \
- SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); }
- SYS_SCHED_YIELD = 331 // { int sched_yield (void); }
- SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); }
- SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); }
- SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, \
- SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); }
- SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, \
- SYS_JAIL = 338 // { int jail(struct jail *jail); }
- SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, \
- SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); }
- SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); }
- SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set, \
- SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set, \
- SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \
- SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \
- SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, \
- SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, \
- SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \
- SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, \
- SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \
- SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, \
- SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \
- SYS_EXTATTR_SET_FILE = 356 // { ssize_t extattr_set_file( \
- SYS_EXTATTR_GET_FILE = 357 // { ssize_t extattr_get_file( \
- SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \
- SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, \
- SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, \
- SYS_KQUEUE = 362 // { int kqueue(void); }
- SYS_KEVENT = 363 // { int kevent(int fd, \
- SYS_EXTATTR_SET_FD = 371 // { ssize_t extattr_set_fd(int fd, \
- SYS_EXTATTR_GET_FD = 372 // { ssize_t extattr_get_fd(int fd, \
- SYS_EXTATTR_DELETE_FD = 373 // { int extattr_delete_fd(int fd, \
- SYS___SETUGID = 374 // { int __setugid(int flag); }
- SYS_EACCESS = 376 // { int eaccess(char *path, int amode); }
- SYS_NMOUNT = 378 // { int nmount(struct iovec *iovp, \
- SYS___MAC_GET_PROC = 384 // { int __mac_get_proc(struct mac *mac_p); }
- SYS___MAC_SET_PROC = 385 // { int __mac_set_proc(struct mac *mac_p); }
- SYS___MAC_GET_FD = 386 // { int __mac_get_fd(int fd, \
- SYS___MAC_GET_FILE = 387 // { int __mac_get_file(const char *path_p, \
- SYS___MAC_SET_FD = 388 // { int __mac_set_fd(int fd, \
- SYS___MAC_SET_FILE = 389 // { int __mac_set_file(const char *path_p, \
- SYS_KENV = 390 // { int kenv(int what, const char *name, \
- SYS_LCHFLAGS = 391 // { int lchflags(const char *path, \
- SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, \
- SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, \
- SYS_MAC_SYSCALL = 394 // { int mac_syscall(const char *policy, \
- SYS_GETFSSTAT = 395 // { int getfsstat(struct statfs *buf, \
- SYS_STATFS = 396 // { int statfs(char *path, \
- SYS_FSTATFS = 397 // { int fstatfs(int fd, struct statfs *buf); }
- SYS_FHSTATFS = 398 // { int fhstatfs(const struct fhandle *u_fhp, \
- SYS___MAC_GET_PID = 409 // { int __mac_get_pid(pid_t pid, \
- SYS___MAC_GET_LINK = 410 // { int __mac_get_link(const char *path_p, \
- SYS___MAC_SET_LINK = 411 // { int __mac_set_link(const char *path_p, \
- SYS_EXTATTR_SET_LINK = 412 // { ssize_t extattr_set_link( \
- SYS_EXTATTR_GET_LINK = 413 // { ssize_t extattr_get_link( \
- SYS_EXTATTR_DELETE_LINK = 414 // { int extattr_delete_link( \
- SYS___MAC_EXECVE = 415 // { int __mac_execve(char *fname, char **argv, \
- SYS_SIGACTION = 416 // { int sigaction(int sig, \
- SYS_SIGRETURN = 417 // { int sigreturn( \
- SYS_GETCONTEXT = 421 // { int getcontext(struct __ucontext *ucp); }
- SYS_SETCONTEXT = 422 // { int setcontext( \
- SYS_SWAPCONTEXT = 423 // { int swapcontext(struct __ucontext *oucp, \
- SYS_SWAPOFF = 424 // { int swapoff(const char *name); }
- SYS___ACL_GET_LINK = 425 // { int __acl_get_link(const char *path, \
- SYS___ACL_SET_LINK = 426 // { int __acl_set_link(const char *path, \
- SYS___ACL_DELETE_LINK = 427 // { int __acl_delete_link(const char *path, \
- SYS___ACL_ACLCHECK_LINK = 428 // { int __acl_aclcheck_link(const char *path, \
- SYS_SIGWAIT = 429 // { int sigwait(const sigset_t *set, \
- SYS_THR_CREATE = 430 // { int thr_create(ucontext_t *ctx, long *id, \
- SYS_THR_EXIT = 431 // { void thr_exit(long *state); }
- SYS_THR_SELF = 432 // { int thr_self(long *id); }
- SYS_THR_KILL = 433 // { int thr_kill(long id, int sig); }
- SYS__UMTX_LOCK = 434 // { int _umtx_lock(struct umtx *umtx); }
- SYS__UMTX_UNLOCK = 435 // { int _umtx_unlock(struct umtx *umtx); }
- SYS_JAIL_ATTACH = 436 // { int jail_attach(int jid); }
- SYS_EXTATTR_LIST_FD = 437 // { ssize_t extattr_list_fd(int fd, \
- SYS_EXTATTR_LIST_FILE = 438 // { ssize_t extattr_list_file( \
- SYS_EXTATTR_LIST_LINK = 439 // { ssize_t extattr_list_link( \
- SYS_THR_SUSPEND = 442 // { int thr_suspend( \
- SYS_THR_WAKE = 443 // { int thr_wake(long id); }
- SYS_KLDUNLOADF = 444 // { int kldunloadf(int fileid, int flags); }
- SYS_AUDIT = 445 // { int audit(const void *record, \
- SYS_AUDITON = 446 // { int auditon(int cmd, void *data, \
- SYS_GETAUID = 447 // { int getauid(uid_t *auid); }
- SYS_SETAUID = 448 // { int setauid(uid_t *auid); }
- SYS_GETAUDIT = 449 // { int getaudit(struct auditinfo *auditinfo); }
- SYS_SETAUDIT = 450 // { int setaudit(struct auditinfo *auditinfo); }
- SYS_GETAUDIT_ADDR = 451 // { int getaudit_addr( \
- SYS_SETAUDIT_ADDR = 452 // { int setaudit_addr( \
- SYS_AUDITCTL = 453 // { int auditctl(char *path); }
- SYS__UMTX_OP = 454 // { int _umtx_op(void *obj, int op, \
- SYS_THR_NEW = 455 // { int thr_new(struct thr_param *param, \
- SYS_SIGQUEUE = 456 // { int sigqueue(pid_t pid, int signum, void *value); }
- SYS_ABORT2 = 463 // { int abort2(const char *why, int nargs, void **args); }
- SYS_THR_SET_NAME = 464 // { int thr_set_name(long id, const char *name); }
- SYS_RTPRIO_THREAD = 466 // { int rtprio_thread(int function, \
- SYS_SCTP_PEELOFF = 471 // { int sctp_peeloff(int sd, uint32_t name); }
- SYS_SCTP_GENERIC_SENDMSG = 472 // { int sctp_generic_sendmsg(int sd, caddr_t msg, int mlen, \
- SYS_SCTP_GENERIC_SENDMSG_IOV = 473 // { int sctp_generic_sendmsg_iov(int sd, struct iovec *iov, int iovlen, \
- SYS_SCTP_GENERIC_RECVMSG = 474 // { int sctp_generic_recvmsg(int sd, struct iovec *iov, int iovlen, \
- SYS_PREAD = 475 // { ssize_t pread(int fd, void *buf, \
- SYS_PWRITE = 476 // { ssize_t pwrite(int fd, const void *buf, \
- SYS_MMAP = 477 // { caddr_t mmap(caddr_t addr, size_t len, \
- SYS_LSEEK = 478 // { off_t lseek(int fd, off_t offset, \
- SYS_TRUNCATE = 479 // { int truncate(char *path, off_t length); }
- SYS_FTRUNCATE = 480 // { int ftruncate(int fd, off_t length); }
- SYS_THR_KILL2 = 481 // { int thr_kill2(pid_t pid, long id, int sig); }
- SYS_SHM_OPEN = 482 // { int shm_open(const char *path, int flags, \
- SYS_SHM_UNLINK = 483 // { int shm_unlink(const char *path); }
- SYS_CPUSET = 484 // { int cpuset(cpusetid_t *setid); }
- SYS_CPUSET_SETID = 485 // { int cpuset_setid(cpuwhich_t which, id_t id, \
- SYS_CPUSET_GETID = 486 // { int cpuset_getid(cpulevel_t level, \
- SYS_CPUSET_GETAFFINITY = 487 // { int cpuset_getaffinity(cpulevel_t level, \
- SYS_CPUSET_SETAFFINITY = 488 // { int cpuset_setaffinity(cpulevel_t level, \
- SYS_FACCESSAT = 489 // { int faccessat(int fd, char *path, int amode, \
- SYS_FCHMODAT = 490 // { int fchmodat(int fd, char *path, mode_t mode, \
- SYS_FCHOWNAT = 491 // { int fchownat(int fd, char *path, uid_t uid, \
- SYS_FEXECVE = 492 // { int fexecve(int fd, char **argv, \
- SYS_FSTATAT = 493 // { int fstatat(int fd, char *path, \
- SYS_FUTIMESAT = 494 // { int futimesat(int fd, char *path, \
- SYS_LINKAT = 495 // { int linkat(int fd1, char *path1, int fd2, \
- SYS_MKDIRAT = 496 // { int mkdirat(int fd, char *path, mode_t mode); }
- SYS_MKFIFOAT = 497 // { int mkfifoat(int fd, char *path, mode_t mode); }
- SYS_MKNODAT = 498 // { int mknodat(int fd, char *path, mode_t mode, \
- SYS_OPENAT = 499 // { int openat(int fd, char *path, int flag, \
- SYS_READLINKAT = 500 // { int readlinkat(int fd, char *path, char *buf, \
- SYS_RENAMEAT = 501 // { int renameat(int oldfd, char *old, int newfd, \
- SYS_SYMLINKAT = 502 // { int symlinkat(char *path1, int fd, \
- SYS_UNLINKAT = 503 // { int unlinkat(int fd, char *path, int flag); }
- SYS_POSIX_OPENPT = 504 // { int posix_openpt(int flags); }
- SYS_JAIL_GET = 506 // { int jail_get(struct iovec *iovp, \
- SYS_JAIL_SET = 507 // { int jail_set(struct iovec *iovp, \
- SYS_JAIL_REMOVE = 508 // { int jail_remove(int jid); }
- SYS_CLOSEFROM = 509 // { int closefrom(int lowfd); }
- SYS_LPATHCONF = 513 // { int lpathconf(char *path, int name); }
- SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }
- SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \
- SYS_CAP_ENTER = 516 // { int cap_enter(void); }
- SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }
- SYS_PDFORK = 518 // { int pdfork(int *fdp, int flags); }
- SYS_PDKILL = 519 // { int pdkill(int fd, int signum); }
- SYS_PDGETPID = 520 // { int pdgetpid(int fd, pid_t *pidp); }
- SYS_PSELECT = 522 // { int pselect(int nd, fd_set *in, \
- SYS_GETLOGINCLASS = 523 // { int getloginclass(char *namebuf, \
- SYS_SETLOGINCLASS = 524 // { int setloginclass(const char *namebuf); }
- SYS_RCTL_GET_RACCT = 525 // { int rctl_get_racct(const void *inbufp, \
- SYS_RCTL_GET_RULES = 526 // { int rctl_get_rules(const void *inbufp, \
- SYS_RCTL_GET_LIMITS = 527 // { int rctl_get_limits(const void *inbufp, \
- SYS_RCTL_ADD_RULE = 528 // { int rctl_add_rule(const void *inbufp, \
- SYS_RCTL_REMOVE_RULE = 529 // { int rctl_remove_rule(const void *inbufp, \
- SYS_POSIX_FALLOCATE = 530 // { int posix_fallocate(int fd, \
- SYS_POSIX_FADVISE = 531 // { int posix_fadvise(int fd, off_t offset, \
- SYS_WAIT6 = 532 // { int wait6(idtype_t idtype, id_t id, \
- SYS_BINDAT = 538 // { int bindat(int fd, int s, caddr_t name, \
- SYS_CONNECTAT = 539 // { int connectat(int fd, int s, caddr_t name, \
- SYS_CHFLAGSAT = 540 // { int chflagsat(int fd, const char *path, \
- SYS_ACCEPT4 = 541 // { int accept4(int s, \
- SYS_PIPE2 = 542 // { int pipe2(int *fildes, int flags); }
- SYS_PROCCTL = 544 // { int procctl(idtype_t idtype, id_t id, \
- SYS_PPOLL = 545 // { int ppoll(struct pollfd *fds, u_int nfds, \
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go
deleted file mode 100644
index ba952c67..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go
+++ /dev/null
@@ -1,355 +0,0 @@
-// mksysnum_linux.pl /usr/include/asm/unistd_32.h
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build 386,linux
-
-package unix
-
-const (
- SYS_RESTART_SYSCALL = 0
- SYS_EXIT = 1
- SYS_FORK = 2
- SYS_READ = 3
- SYS_WRITE = 4
- SYS_OPEN = 5
- SYS_CLOSE = 6
- SYS_WAITPID = 7
- SYS_CREAT = 8
- SYS_LINK = 9
- SYS_UNLINK = 10
- SYS_EXECVE = 11
- SYS_CHDIR = 12
- SYS_TIME = 13
- SYS_MKNOD = 14
- SYS_CHMOD = 15
- SYS_LCHOWN = 16
- SYS_BREAK = 17
- SYS_OLDSTAT = 18
- SYS_LSEEK = 19
- SYS_GETPID = 20
- SYS_MOUNT = 21
- SYS_UMOUNT = 22
- SYS_SETUID = 23
- SYS_GETUID = 24
- SYS_STIME = 25
- SYS_PTRACE = 26
- SYS_ALARM = 27
- SYS_OLDFSTAT = 28
- SYS_PAUSE = 29
- SYS_UTIME = 30
- SYS_STTY = 31
- SYS_GTTY = 32
- SYS_ACCESS = 33
- SYS_NICE = 34
- SYS_FTIME = 35
- SYS_SYNC = 36
- SYS_KILL = 37
- SYS_RENAME = 38
- SYS_MKDIR = 39
- SYS_RMDIR = 40
- SYS_DUP = 41
- SYS_PIPE = 42
- SYS_TIMES = 43
- SYS_PROF = 44
- SYS_BRK = 45
- SYS_SETGID = 46
- SYS_GETGID = 47
- SYS_SIGNAL = 48
- SYS_GETEUID = 49
- SYS_GETEGID = 50
- SYS_ACCT = 51
- SYS_UMOUNT2 = 52
- SYS_LOCK = 53
- SYS_IOCTL = 54
- SYS_FCNTL = 55
- SYS_MPX = 56
- SYS_SETPGID = 57
- SYS_ULIMIT = 58
- SYS_OLDOLDUNAME = 59
- SYS_UMASK = 60
- SYS_CHROOT = 61
- SYS_USTAT = 62
- SYS_DUP2 = 63
- SYS_GETPPID = 64
- SYS_GETPGRP = 65
- SYS_SETSID = 66
- SYS_SIGACTION = 67
- SYS_SGETMASK = 68
- SYS_SSETMASK = 69
- SYS_SETREUID = 70
- SYS_SETREGID = 71
- SYS_SIGSUSPEND = 72
- SYS_SIGPENDING = 73
- SYS_SETHOSTNAME = 74
- SYS_SETRLIMIT = 75
- SYS_GETRLIMIT = 76
- SYS_GETRUSAGE = 77
- SYS_GETTIMEOFDAY = 78
- SYS_SETTIMEOFDAY = 79
- SYS_GETGROUPS = 80
- SYS_SETGROUPS = 81
- SYS_SELECT = 82
- SYS_SYMLINK = 83
- SYS_OLDLSTAT = 84
- SYS_READLINK = 85
- SYS_USELIB = 86
- SYS_SWAPON = 87
- SYS_REBOOT = 88
- SYS_READDIR = 89
- SYS_MMAP = 90
- SYS_MUNMAP = 91
- SYS_TRUNCATE = 92
- SYS_FTRUNCATE = 93
- SYS_FCHMOD = 94
- SYS_FCHOWN = 95
- SYS_GETPRIORITY = 96
- SYS_SETPRIORITY = 97
- SYS_PROFIL = 98
- SYS_STATFS = 99
- SYS_FSTATFS = 100
- SYS_IOPERM = 101
- SYS_SOCKETCALL = 102
- SYS_SYSLOG = 103
- SYS_SETITIMER = 104
- SYS_GETITIMER = 105
- SYS_STAT = 106
- SYS_LSTAT = 107
- SYS_FSTAT = 108
- SYS_OLDUNAME = 109
- SYS_IOPL = 110
- SYS_VHANGUP = 111
- SYS_IDLE = 112
- SYS_VM86OLD = 113
- SYS_WAIT4 = 114
- SYS_SWAPOFF = 115
- SYS_SYSINFO = 116
- SYS_IPC = 117
- SYS_FSYNC = 118
- SYS_SIGRETURN = 119
- SYS_CLONE = 120
- SYS_SETDOMAINNAME = 121
- SYS_UNAME = 122
- SYS_MODIFY_LDT = 123
- SYS_ADJTIMEX = 124
- SYS_MPROTECT = 125
- SYS_SIGPROCMASK = 126
- SYS_CREATE_MODULE = 127
- SYS_INIT_MODULE = 128
- SYS_DELETE_MODULE = 129
- SYS_GET_KERNEL_SYMS = 130
- SYS_QUOTACTL = 131
- SYS_GETPGID = 132
- SYS_FCHDIR = 133
- SYS_BDFLUSH = 134
- SYS_SYSFS = 135
- SYS_PERSONALITY = 136
- SYS_AFS_SYSCALL = 137
- SYS_SETFSUID = 138
- SYS_SETFSGID = 139
- SYS__LLSEEK = 140
- SYS_GETDENTS = 141
- SYS__NEWSELECT = 142
- SYS_FLOCK = 143
- SYS_MSYNC = 144
- SYS_READV = 145
- SYS_WRITEV = 146
- SYS_GETSID = 147
- SYS_FDATASYNC = 148
- SYS__SYSCTL = 149
- SYS_MLOCK = 150
- SYS_MUNLOCK = 151
- SYS_MLOCKALL = 152
- SYS_MUNLOCKALL = 153
- SYS_SCHED_SETPARAM = 154
- SYS_SCHED_GETPARAM = 155
- SYS_SCHED_SETSCHEDULER = 156
- SYS_SCHED_GETSCHEDULER = 157
- SYS_SCHED_YIELD = 158
- SYS_SCHED_GET_PRIORITY_MAX = 159
- SYS_SCHED_GET_PRIORITY_MIN = 160
- SYS_SCHED_RR_GET_INTERVAL = 161
- SYS_NANOSLEEP = 162
- SYS_MREMAP = 163
- SYS_SETRESUID = 164
- SYS_GETRESUID = 165
- SYS_VM86 = 166
- SYS_QUERY_MODULE = 167
- SYS_POLL = 168
- SYS_NFSSERVCTL = 169
- SYS_SETRESGID = 170
- SYS_GETRESGID = 171
- SYS_PRCTL = 172
- SYS_RT_SIGRETURN = 173
- SYS_RT_SIGACTION = 174
- SYS_RT_SIGPROCMASK = 175
- SYS_RT_SIGPENDING = 176
- SYS_RT_SIGTIMEDWAIT = 177
- SYS_RT_SIGQUEUEINFO = 178
- SYS_RT_SIGSUSPEND = 179
- SYS_PREAD64 = 180
- SYS_PWRITE64 = 181
- SYS_CHOWN = 182
- SYS_GETCWD = 183
- SYS_CAPGET = 184
- SYS_CAPSET = 185
- SYS_SIGALTSTACK = 186
- SYS_SENDFILE = 187
- SYS_GETPMSG = 188
- SYS_PUTPMSG = 189
- SYS_VFORK = 190
- SYS_UGETRLIMIT = 191
- SYS_MMAP2 = 192
- SYS_TRUNCATE64 = 193
- SYS_FTRUNCATE64 = 194
- SYS_STAT64 = 195
- SYS_LSTAT64 = 196
- SYS_FSTAT64 = 197
- SYS_LCHOWN32 = 198
- SYS_GETUID32 = 199
- SYS_GETGID32 = 200
- SYS_GETEUID32 = 201
- SYS_GETEGID32 = 202
- SYS_SETREUID32 = 203
- SYS_SETREGID32 = 204
- SYS_GETGROUPS32 = 205
- SYS_SETGROUPS32 = 206
- SYS_FCHOWN32 = 207
- SYS_SETRESUID32 = 208
- SYS_GETRESUID32 = 209
- SYS_SETRESGID32 = 210
- SYS_GETRESGID32 = 211
- SYS_CHOWN32 = 212
- SYS_SETUID32 = 213
- SYS_SETGID32 = 214
- SYS_SETFSUID32 = 215
- SYS_SETFSGID32 = 216
- SYS_PIVOT_ROOT = 217
- SYS_MINCORE = 218
- SYS_MADVISE = 219
- SYS_MADVISE1 = 219
- SYS_GETDENTS64 = 220
- SYS_FCNTL64 = 221
- SYS_GETTID = 224
- SYS_READAHEAD = 225
- SYS_SETXATTR = 226
- SYS_LSETXATTR = 227
- SYS_FSETXATTR = 228
- SYS_GETXATTR = 229
- SYS_LGETXATTR = 230
- SYS_FGETXATTR = 231
- SYS_LISTXATTR = 232
- SYS_LLISTXATTR = 233
- SYS_FLISTXATTR = 234
- SYS_REMOVEXATTR = 235
- SYS_LREMOVEXATTR = 236
- SYS_FREMOVEXATTR = 237
- SYS_TKILL = 238
- SYS_SENDFILE64 = 239
- SYS_FUTEX = 240
- SYS_SCHED_SETAFFINITY = 241
- SYS_SCHED_GETAFFINITY = 242
- SYS_SET_THREAD_AREA = 243
- SYS_GET_THREAD_AREA = 244
- SYS_IO_SETUP = 245
- SYS_IO_DESTROY = 246
- SYS_IO_GETEVENTS = 247
- SYS_IO_SUBMIT = 248
- SYS_IO_CANCEL = 249
- SYS_FADVISE64 = 250
- SYS_EXIT_GROUP = 252
- SYS_LOOKUP_DCOOKIE = 253
- SYS_EPOLL_CREATE = 254
- SYS_EPOLL_CTL = 255
- SYS_EPOLL_WAIT = 256
- SYS_REMAP_FILE_PAGES = 257
- SYS_SET_TID_ADDRESS = 258
- SYS_TIMER_CREATE = 259
- SYS_TIMER_SETTIME = 260
- SYS_TIMER_GETTIME = 261
- SYS_TIMER_GETOVERRUN = 262
- SYS_TIMER_DELETE = 263
- SYS_CLOCK_SETTIME = 264
- SYS_CLOCK_GETTIME = 265
- SYS_CLOCK_GETRES = 266
- SYS_CLOCK_NANOSLEEP = 267
- SYS_STATFS64 = 268
- SYS_FSTATFS64 = 269
- SYS_TGKILL = 270
- SYS_UTIMES = 271
- SYS_FADVISE64_64 = 272
- SYS_VSERVER = 273
- SYS_MBIND = 274
- SYS_GET_MEMPOLICY = 275
- SYS_SET_MEMPOLICY = 276
- SYS_MQ_OPEN = 277
- SYS_MQ_UNLINK = 278
- SYS_MQ_TIMEDSEND = 279
- SYS_MQ_TIMEDRECEIVE = 280
- SYS_MQ_NOTIFY = 281
- SYS_MQ_GETSETATTR = 282
- SYS_KEXEC_LOAD = 283
- SYS_WAITID = 284
- SYS_ADD_KEY = 286
- SYS_REQUEST_KEY = 287
- SYS_KEYCTL = 288
- SYS_IOPRIO_SET = 289
- SYS_IOPRIO_GET = 290
- SYS_INOTIFY_INIT = 291
- SYS_INOTIFY_ADD_WATCH = 292
- SYS_INOTIFY_RM_WATCH = 293
- SYS_MIGRATE_PAGES = 294
- SYS_OPENAT = 295
- SYS_MKDIRAT = 296
- SYS_MKNODAT = 297
- SYS_FCHOWNAT = 298
- SYS_FUTIMESAT = 299
- SYS_FSTATAT64 = 300
- SYS_UNLINKAT = 301
- SYS_RENAMEAT = 302
- SYS_LINKAT = 303
- SYS_SYMLINKAT = 304
- SYS_READLINKAT = 305
- SYS_FCHMODAT = 306
- SYS_FACCESSAT = 307
- SYS_PSELECT6 = 308
- SYS_PPOLL = 309
- SYS_UNSHARE = 310
- SYS_SET_ROBUST_LIST = 311
- SYS_GET_ROBUST_LIST = 312
- SYS_SPLICE = 313
- SYS_SYNC_FILE_RANGE = 314
- SYS_TEE = 315
- SYS_VMSPLICE = 316
- SYS_MOVE_PAGES = 317
- SYS_GETCPU = 318
- SYS_EPOLL_PWAIT = 319
- SYS_UTIMENSAT = 320
- SYS_SIGNALFD = 321
- SYS_TIMERFD_CREATE = 322
- SYS_EVENTFD = 323
- SYS_FALLOCATE = 324
- SYS_TIMERFD_SETTIME = 325
- SYS_TIMERFD_GETTIME = 326
- SYS_SIGNALFD4 = 327
- SYS_EVENTFD2 = 328
- SYS_EPOLL_CREATE1 = 329
- SYS_DUP3 = 330
- SYS_PIPE2 = 331
- SYS_INOTIFY_INIT1 = 332
- SYS_PREADV = 333
- SYS_PWRITEV = 334
- SYS_RT_TGSIGQUEUEINFO = 335
- SYS_PERF_EVENT_OPEN = 336
- SYS_RECVMMSG = 337
- SYS_FANOTIFY_INIT = 338
- SYS_FANOTIFY_MARK = 339
- SYS_PRLIMIT64 = 340
- SYS_NAME_TO_HANDLE_AT = 341
- SYS_OPEN_BY_HANDLE_AT = 342
- SYS_CLOCK_ADJTIME = 343
- SYS_SYNCFS = 344
- SYS_SENDMMSG = 345
- SYS_SETNS = 346
- SYS_PROCESS_VM_READV = 347
- SYS_PROCESS_VM_WRITEV = 348
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go
deleted file mode 100644
index ddac31f5..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go
+++ /dev/null
@@ -1,321 +0,0 @@
-// mksysnum_linux.pl /usr/include/asm/unistd_64.h
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build amd64,linux
-
-package unix
-
-const (
- SYS_READ = 0
- SYS_WRITE = 1
- SYS_OPEN = 2
- SYS_CLOSE = 3
- SYS_STAT = 4
- SYS_FSTAT = 5
- SYS_LSTAT = 6
- SYS_POLL = 7
- SYS_LSEEK = 8
- SYS_MMAP = 9
- SYS_MPROTECT = 10
- SYS_MUNMAP = 11
- SYS_BRK = 12
- SYS_RT_SIGACTION = 13
- SYS_RT_SIGPROCMASK = 14
- SYS_RT_SIGRETURN = 15
- SYS_IOCTL = 16
- SYS_PREAD64 = 17
- SYS_PWRITE64 = 18
- SYS_READV = 19
- SYS_WRITEV = 20
- SYS_ACCESS = 21
- SYS_PIPE = 22
- SYS_SELECT = 23
- SYS_SCHED_YIELD = 24
- SYS_MREMAP = 25
- SYS_MSYNC = 26
- SYS_MINCORE = 27
- SYS_MADVISE = 28
- SYS_SHMGET = 29
- SYS_SHMAT = 30
- SYS_SHMCTL = 31
- SYS_DUP = 32
- SYS_DUP2 = 33
- SYS_PAUSE = 34
- SYS_NANOSLEEP = 35
- SYS_GETITIMER = 36
- SYS_ALARM = 37
- SYS_SETITIMER = 38
- SYS_GETPID = 39
- SYS_SENDFILE = 40
- SYS_SOCKET = 41
- SYS_CONNECT = 42
- SYS_ACCEPT = 43
- SYS_SENDTO = 44
- SYS_RECVFROM = 45
- SYS_SENDMSG = 46
- SYS_RECVMSG = 47
- SYS_SHUTDOWN = 48
- SYS_BIND = 49
- SYS_LISTEN = 50
- SYS_GETSOCKNAME = 51
- SYS_GETPEERNAME = 52
- SYS_SOCKETPAIR = 53
- SYS_SETSOCKOPT = 54
- SYS_GETSOCKOPT = 55
- SYS_CLONE = 56
- SYS_FORK = 57
- SYS_VFORK = 58
- SYS_EXECVE = 59
- SYS_EXIT = 60
- SYS_WAIT4 = 61
- SYS_KILL = 62
- SYS_UNAME = 63
- SYS_SEMGET = 64
- SYS_SEMOP = 65
- SYS_SEMCTL = 66
- SYS_SHMDT = 67
- SYS_MSGGET = 68
- SYS_MSGSND = 69
- SYS_MSGRCV = 70
- SYS_MSGCTL = 71
- SYS_FCNTL = 72
- SYS_FLOCK = 73
- SYS_FSYNC = 74
- SYS_FDATASYNC = 75
- SYS_TRUNCATE = 76
- SYS_FTRUNCATE = 77
- SYS_GETDENTS = 78
- SYS_GETCWD = 79
- SYS_CHDIR = 80
- SYS_FCHDIR = 81
- SYS_RENAME = 82
- SYS_MKDIR = 83
- SYS_RMDIR = 84
- SYS_CREAT = 85
- SYS_LINK = 86
- SYS_UNLINK = 87
- SYS_SYMLINK = 88
- SYS_READLINK = 89
- SYS_CHMOD = 90
- SYS_FCHMOD = 91
- SYS_CHOWN = 92
- SYS_FCHOWN = 93
- SYS_LCHOWN = 94
- SYS_UMASK = 95
- SYS_GETTIMEOFDAY = 96
- SYS_GETRLIMIT = 97
- SYS_GETRUSAGE = 98
- SYS_SYSINFO = 99
- SYS_TIMES = 100
- SYS_PTRACE = 101
- SYS_GETUID = 102
- SYS_SYSLOG = 103
- SYS_GETGID = 104
- SYS_SETUID = 105
- SYS_SETGID = 106
- SYS_GETEUID = 107
- SYS_GETEGID = 108
- SYS_SETPGID = 109
- SYS_GETPPID = 110
- SYS_GETPGRP = 111
- SYS_SETSID = 112
- SYS_SETREUID = 113
- SYS_SETREGID = 114
- SYS_GETGROUPS = 115
- SYS_SETGROUPS = 116
- SYS_SETRESUID = 117
- SYS_GETRESUID = 118
- SYS_SETRESGID = 119
- SYS_GETRESGID = 120
- SYS_GETPGID = 121
- SYS_SETFSUID = 122
- SYS_SETFSGID = 123
- SYS_GETSID = 124
- SYS_CAPGET = 125
- SYS_CAPSET = 126
- SYS_RT_SIGPENDING = 127
- SYS_RT_SIGTIMEDWAIT = 128
- SYS_RT_SIGQUEUEINFO = 129
- SYS_RT_SIGSUSPEND = 130
- SYS_SIGALTSTACK = 131
- SYS_UTIME = 132
- SYS_MKNOD = 133
- SYS_USELIB = 134
- SYS_PERSONALITY = 135
- SYS_USTAT = 136
- SYS_STATFS = 137
- SYS_FSTATFS = 138
- SYS_SYSFS = 139
- SYS_GETPRIORITY = 140
- SYS_SETPRIORITY = 141
- SYS_SCHED_SETPARAM = 142
- SYS_SCHED_GETPARAM = 143
- SYS_SCHED_SETSCHEDULER = 144
- SYS_SCHED_GETSCHEDULER = 145
- SYS_SCHED_GET_PRIORITY_MAX = 146
- SYS_SCHED_GET_PRIORITY_MIN = 147
- SYS_SCHED_RR_GET_INTERVAL = 148
- SYS_MLOCK = 149
- SYS_MUNLOCK = 150
- SYS_MLOCKALL = 151
- SYS_MUNLOCKALL = 152
- SYS_VHANGUP = 153
- SYS_MODIFY_LDT = 154
- SYS_PIVOT_ROOT = 155
- SYS__SYSCTL = 156
- SYS_PRCTL = 157
- SYS_ARCH_PRCTL = 158
- SYS_ADJTIMEX = 159
- SYS_SETRLIMIT = 160
- SYS_CHROOT = 161
- SYS_SYNC = 162
- SYS_ACCT = 163
- SYS_SETTIMEOFDAY = 164
- SYS_MOUNT = 165
- SYS_UMOUNT2 = 166
- SYS_SWAPON = 167
- SYS_SWAPOFF = 168
- SYS_REBOOT = 169
- SYS_SETHOSTNAME = 170
- SYS_SETDOMAINNAME = 171
- SYS_IOPL = 172
- SYS_IOPERM = 173
- SYS_CREATE_MODULE = 174
- SYS_INIT_MODULE = 175
- SYS_DELETE_MODULE = 176
- SYS_GET_KERNEL_SYMS = 177
- SYS_QUERY_MODULE = 178
- SYS_QUOTACTL = 179
- SYS_NFSSERVCTL = 180
- SYS_GETPMSG = 181
- SYS_PUTPMSG = 182
- SYS_AFS_SYSCALL = 183
- SYS_TUXCALL = 184
- SYS_SECURITY = 185
- SYS_GETTID = 186
- SYS_READAHEAD = 187
- SYS_SETXATTR = 188
- SYS_LSETXATTR = 189
- SYS_FSETXATTR = 190
- SYS_GETXATTR = 191
- SYS_LGETXATTR = 192
- SYS_FGETXATTR = 193
- SYS_LISTXATTR = 194
- SYS_LLISTXATTR = 195
- SYS_FLISTXATTR = 196
- SYS_REMOVEXATTR = 197
- SYS_LREMOVEXATTR = 198
- SYS_FREMOVEXATTR = 199
- SYS_TKILL = 200
- SYS_TIME = 201
- SYS_FUTEX = 202
- SYS_SCHED_SETAFFINITY = 203
- SYS_SCHED_GETAFFINITY = 204
- SYS_SET_THREAD_AREA = 205
- SYS_IO_SETUP = 206
- SYS_IO_DESTROY = 207
- SYS_IO_GETEVENTS = 208
- SYS_IO_SUBMIT = 209
- SYS_IO_CANCEL = 210
- SYS_GET_THREAD_AREA = 211
- SYS_LOOKUP_DCOOKIE = 212
- SYS_EPOLL_CREATE = 213
- SYS_EPOLL_CTL_OLD = 214
- SYS_EPOLL_WAIT_OLD = 215
- SYS_REMAP_FILE_PAGES = 216
- SYS_GETDENTS64 = 217
- SYS_SET_TID_ADDRESS = 218
- SYS_RESTART_SYSCALL = 219
- SYS_SEMTIMEDOP = 220
- SYS_FADVISE64 = 221
- SYS_TIMER_CREATE = 222
- SYS_TIMER_SETTIME = 223
- SYS_TIMER_GETTIME = 224
- SYS_TIMER_GETOVERRUN = 225
- SYS_TIMER_DELETE = 226
- SYS_CLOCK_SETTIME = 227
- SYS_CLOCK_GETTIME = 228
- SYS_CLOCK_GETRES = 229
- SYS_CLOCK_NANOSLEEP = 230
- SYS_EXIT_GROUP = 231
- SYS_EPOLL_WAIT = 232
- SYS_EPOLL_CTL = 233
- SYS_TGKILL = 234
- SYS_UTIMES = 235
- SYS_VSERVER = 236
- SYS_MBIND = 237
- SYS_SET_MEMPOLICY = 238
- SYS_GET_MEMPOLICY = 239
- SYS_MQ_OPEN = 240
- SYS_MQ_UNLINK = 241
- SYS_MQ_TIMEDSEND = 242
- SYS_MQ_TIMEDRECEIVE = 243
- SYS_MQ_NOTIFY = 244
- SYS_MQ_GETSETATTR = 245
- SYS_KEXEC_LOAD = 246
- SYS_WAITID = 247
- SYS_ADD_KEY = 248
- SYS_REQUEST_KEY = 249
- SYS_KEYCTL = 250
- SYS_IOPRIO_SET = 251
- SYS_IOPRIO_GET = 252
- SYS_INOTIFY_INIT = 253
- SYS_INOTIFY_ADD_WATCH = 254
- SYS_INOTIFY_RM_WATCH = 255
- SYS_MIGRATE_PAGES = 256
- SYS_OPENAT = 257
- SYS_MKDIRAT = 258
- SYS_MKNODAT = 259
- SYS_FCHOWNAT = 260
- SYS_FUTIMESAT = 261
- SYS_NEWFSTATAT = 262
- SYS_UNLINKAT = 263
- SYS_RENAMEAT = 264
- SYS_LINKAT = 265
- SYS_SYMLINKAT = 266
- SYS_READLINKAT = 267
- SYS_FCHMODAT = 268
- SYS_FACCESSAT = 269
- SYS_PSELECT6 = 270
- SYS_PPOLL = 271
- SYS_UNSHARE = 272
- SYS_SET_ROBUST_LIST = 273
- SYS_GET_ROBUST_LIST = 274
- SYS_SPLICE = 275
- SYS_TEE = 276
- SYS_SYNC_FILE_RANGE = 277
- SYS_VMSPLICE = 278
- SYS_MOVE_PAGES = 279
- SYS_UTIMENSAT = 280
- SYS_EPOLL_PWAIT = 281
- SYS_SIGNALFD = 282
- SYS_TIMERFD_CREATE = 283
- SYS_EVENTFD = 284
- SYS_FALLOCATE = 285
- SYS_TIMERFD_SETTIME = 286
- SYS_TIMERFD_GETTIME = 287
- SYS_ACCEPT4 = 288
- SYS_SIGNALFD4 = 289
- SYS_EVENTFD2 = 290
- SYS_EPOLL_CREATE1 = 291
- SYS_DUP3 = 292
- SYS_PIPE2 = 293
- SYS_INOTIFY_INIT1 = 294
- SYS_PREADV = 295
- SYS_PWRITEV = 296
- SYS_RT_TGSIGQUEUEINFO = 297
- SYS_PERF_EVENT_OPEN = 298
- SYS_RECVMMSG = 299
- SYS_FANOTIFY_INIT = 300
- SYS_FANOTIFY_MARK = 301
- SYS_PRLIMIT64 = 302
- SYS_NAME_TO_HANDLE_AT = 303
- SYS_OPEN_BY_HANDLE_AT = 304
- SYS_CLOCK_ADJTIME = 305
- SYS_SYNCFS = 306
- SYS_SENDMMSG = 307
- SYS_SETNS = 308
- SYS_GETCPU = 309
- SYS_PROCESS_VM_READV = 310
- SYS_PROCESS_VM_WRITEV = 311
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go
deleted file mode 100644
index 45ced17f..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go
+++ /dev/null
@@ -1,356 +0,0 @@
-// mksysnum_linux.pl
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build arm,linux
-
-package unix
-
-const (
- SYS_OABI_SYSCALL_BASE = 0
- SYS_SYSCALL_BASE = 0
- SYS_RESTART_SYSCALL = 0
- SYS_EXIT = 1
- SYS_FORK = 2
- SYS_READ = 3
- SYS_WRITE = 4
- SYS_OPEN = 5
- SYS_CLOSE = 6
- SYS_CREAT = 8
- SYS_LINK = 9
- SYS_UNLINK = 10
- SYS_EXECVE = 11
- SYS_CHDIR = 12
- SYS_TIME = 13
- SYS_MKNOD = 14
- SYS_CHMOD = 15
- SYS_LCHOWN = 16
- SYS_LSEEK = 19
- SYS_GETPID = 20
- SYS_MOUNT = 21
- SYS_UMOUNT = 22
- SYS_SETUID = 23
- SYS_GETUID = 24
- SYS_STIME = 25
- SYS_PTRACE = 26
- SYS_ALARM = 27
- SYS_PAUSE = 29
- SYS_UTIME = 30
- SYS_ACCESS = 33
- SYS_NICE = 34
- SYS_SYNC = 36
- SYS_KILL = 37
- SYS_RENAME = 38
- SYS_MKDIR = 39
- SYS_RMDIR = 40
- SYS_DUP = 41
- SYS_PIPE = 42
- SYS_TIMES = 43
- SYS_BRK = 45
- SYS_SETGID = 46
- SYS_GETGID = 47
- SYS_GETEUID = 49
- SYS_GETEGID = 50
- SYS_ACCT = 51
- SYS_UMOUNT2 = 52
- SYS_IOCTL = 54
- SYS_FCNTL = 55
- SYS_SETPGID = 57
- SYS_UMASK = 60
- SYS_CHROOT = 61
- SYS_USTAT = 62
- SYS_DUP2 = 63
- SYS_GETPPID = 64
- SYS_GETPGRP = 65
- SYS_SETSID = 66
- SYS_SIGACTION = 67
- SYS_SETREUID = 70
- SYS_SETREGID = 71
- SYS_SIGSUSPEND = 72
- SYS_SIGPENDING = 73
- SYS_SETHOSTNAME = 74
- SYS_SETRLIMIT = 75
- SYS_GETRLIMIT = 76
- SYS_GETRUSAGE = 77
- SYS_GETTIMEOFDAY = 78
- SYS_SETTIMEOFDAY = 79
- SYS_GETGROUPS = 80
- SYS_SETGROUPS = 81
- SYS_SELECT = 82
- SYS_SYMLINK = 83
- SYS_READLINK = 85
- SYS_USELIB = 86
- SYS_SWAPON = 87
- SYS_REBOOT = 88
- SYS_READDIR = 89
- SYS_MMAP = 90
- SYS_MUNMAP = 91
- SYS_TRUNCATE = 92
- SYS_FTRUNCATE = 93
- SYS_FCHMOD = 94
- SYS_FCHOWN = 95
- SYS_GETPRIORITY = 96
- SYS_SETPRIORITY = 97
- SYS_STATFS = 99
- SYS_FSTATFS = 100
- SYS_SOCKETCALL = 102
- SYS_SYSLOG = 103
- SYS_SETITIMER = 104
- SYS_GETITIMER = 105
- SYS_STAT = 106
- SYS_LSTAT = 107
- SYS_FSTAT = 108
- SYS_VHANGUP = 111
- SYS_SYSCALL = 113
- SYS_WAIT4 = 114
- SYS_SWAPOFF = 115
- SYS_SYSINFO = 116
- SYS_IPC = 117
- SYS_FSYNC = 118
- SYS_SIGRETURN = 119
- SYS_CLONE = 120
- SYS_SETDOMAINNAME = 121
- SYS_UNAME = 122
- SYS_ADJTIMEX = 124
- SYS_MPROTECT = 125
- SYS_SIGPROCMASK = 126
- SYS_INIT_MODULE = 128
- SYS_DELETE_MODULE = 129
- SYS_QUOTACTL = 131
- SYS_GETPGID = 132
- SYS_FCHDIR = 133
- SYS_BDFLUSH = 134
- SYS_SYSFS = 135
- SYS_PERSONALITY = 136
- SYS_SETFSUID = 138
- SYS_SETFSGID = 139
- SYS__LLSEEK = 140
- SYS_GETDENTS = 141
- SYS__NEWSELECT = 142
- SYS_FLOCK = 143
- SYS_MSYNC = 144
- SYS_READV = 145
- SYS_WRITEV = 146
- SYS_GETSID = 147
- SYS_FDATASYNC = 148
- SYS__SYSCTL = 149
- SYS_MLOCK = 150
- SYS_MUNLOCK = 151
- SYS_MLOCKALL = 152
- SYS_MUNLOCKALL = 153
- SYS_SCHED_SETPARAM = 154
- SYS_SCHED_GETPARAM = 155
- SYS_SCHED_SETSCHEDULER = 156
- SYS_SCHED_GETSCHEDULER = 157
- SYS_SCHED_YIELD = 158
- SYS_SCHED_GET_PRIORITY_MAX = 159
- SYS_SCHED_GET_PRIORITY_MIN = 160
- SYS_SCHED_RR_GET_INTERVAL = 161
- SYS_NANOSLEEP = 162
- SYS_MREMAP = 163
- SYS_SETRESUID = 164
- SYS_GETRESUID = 165
- SYS_POLL = 168
- SYS_NFSSERVCTL = 169
- SYS_SETRESGID = 170
- SYS_GETRESGID = 171
- SYS_PRCTL = 172
- SYS_RT_SIGRETURN = 173
- SYS_RT_SIGACTION = 174
- SYS_RT_SIGPROCMASK = 175
- SYS_RT_SIGPENDING = 176
- SYS_RT_SIGTIMEDWAIT = 177
- SYS_RT_SIGQUEUEINFO = 178
- SYS_RT_SIGSUSPEND = 179
- SYS_PREAD64 = 180
- SYS_PWRITE64 = 181
- SYS_CHOWN = 182
- SYS_GETCWD = 183
- SYS_CAPGET = 184
- SYS_CAPSET = 185
- SYS_SIGALTSTACK = 186
- SYS_SENDFILE = 187
- SYS_VFORK = 190
- SYS_UGETRLIMIT = 191
- SYS_MMAP2 = 192
- SYS_TRUNCATE64 = 193
- SYS_FTRUNCATE64 = 194
- SYS_STAT64 = 195
- SYS_LSTAT64 = 196
- SYS_FSTAT64 = 197
- SYS_LCHOWN32 = 198
- SYS_GETUID32 = 199
- SYS_GETGID32 = 200
- SYS_GETEUID32 = 201
- SYS_GETEGID32 = 202
- SYS_SETREUID32 = 203
- SYS_SETREGID32 = 204
- SYS_GETGROUPS32 = 205
- SYS_SETGROUPS32 = 206
- SYS_FCHOWN32 = 207
- SYS_SETRESUID32 = 208
- SYS_GETRESUID32 = 209
- SYS_SETRESGID32 = 210
- SYS_GETRESGID32 = 211
- SYS_CHOWN32 = 212
- SYS_SETUID32 = 213
- SYS_SETGID32 = 214
- SYS_SETFSUID32 = 215
- SYS_SETFSGID32 = 216
- SYS_GETDENTS64 = 217
- SYS_PIVOT_ROOT = 218
- SYS_MINCORE = 219
- SYS_MADVISE = 220
- SYS_FCNTL64 = 221
- SYS_GETTID = 224
- SYS_READAHEAD = 225
- SYS_SETXATTR = 226
- SYS_LSETXATTR = 227
- SYS_FSETXATTR = 228
- SYS_GETXATTR = 229
- SYS_LGETXATTR = 230
- SYS_FGETXATTR = 231
- SYS_LISTXATTR = 232
- SYS_LLISTXATTR = 233
- SYS_FLISTXATTR = 234
- SYS_REMOVEXATTR = 235
- SYS_LREMOVEXATTR = 236
- SYS_FREMOVEXATTR = 237
- SYS_TKILL = 238
- SYS_SENDFILE64 = 239
- SYS_FUTEX = 240
- SYS_SCHED_SETAFFINITY = 241
- SYS_SCHED_GETAFFINITY = 242
- SYS_IO_SETUP = 243
- SYS_IO_DESTROY = 244
- SYS_IO_GETEVENTS = 245
- SYS_IO_SUBMIT = 246
- SYS_IO_CANCEL = 247
- SYS_EXIT_GROUP = 248
- SYS_LOOKUP_DCOOKIE = 249
- SYS_EPOLL_CREATE = 250
- SYS_EPOLL_CTL = 251
- SYS_EPOLL_WAIT = 252
- SYS_REMAP_FILE_PAGES = 253
- SYS_SET_TID_ADDRESS = 256
- SYS_TIMER_CREATE = 257
- SYS_TIMER_SETTIME = 258
- SYS_TIMER_GETTIME = 259
- SYS_TIMER_GETOVERRUN = 260
- SYS_TIMER_DELETE = 261
- SYS_CLOCK_SETTIME = 262
- SYS_CLOCK_GETTIME = 263
- SYS_CLOCK_GETRES = 264
- SYS_CLOCK_NANOSLEEP = 265
- SYS_STATFS64 = 266
- SYS_FSTATFS64 = 267
- SYS_TGKILL = 268
- SYS_UTIMES = 269
- SYS_ARM_FADVISE64_64 = 270
- SYS_PCICONFIG_IOBASE = 271
- SYS_PCICONFIG_READ = 272
- SYS_PCICONFIG_WRITE = 273
- SYS_MQ_OPEN = 274
- SYS_MQ_UNLINK = 275
- SYS_MQ_TIMEDSEND = 276
- SYS_MQ_TIMEDRECEIVE = 277
- SYS_MQ_NOTIFY = 278
- SYS_MQ_GETSETATTR = 279
- SYS_WAITID = 280
- SYS_SOCKET = 281
- SYS_BIND = 282
- SYS_CONNECT = 283
- SYS_LISTEN = 284
- SYS_ACCEPT = 285
- SYS_GETSOCKNAME = 286
- SYS_GETPEERNAME = 287
- SYS_SOCKETPAIR = 288
- SYS_SEND = 289
- SYS_SENDTO = 290
- SYS_RECV = 291
- SYS_RECVFROM = 292
- SYS_SHUTDOWN = 293
- SYS_SETSOCKOPT = 294
- SYS_GETSOCKOPT = 295
- SYS_SENDMSG = 296
- SYS_RECVMSG = 297
- SYS_SEMOP = 298
- SYS_SEMGET = 299
- SYS_SEMCTL = 300
- SYS_MSGSND = 301
- SYS_MSGRCV = 302
- SYS_MSGGET = 303
- SYS_MSGCTL = 304
- SYS_SHMAT = 305
- SYS_SHMDT = 306
- SYS_SHMGET = 307
- SYS_SHMCTL = 308
- SYS_ADD_KEY = 309
- SYS_REQUEST_KEY = 310
- SYS_KEYCTL = 311
- SYS_SEMTIMEDOP = 312
- SYS_VSERVER = 313
- SYS_IOPRIO_SET = 314
- SYS_IOPRIO_GET = 315
- SYS_INOTIFY_INIT = 316
- SYS_INOTIFY_ADD_WATCH = 317
- SYS_INOTIFY_RM_WATCH = 318
- SYS_MBIND = 319
- SYS_GET_MEMPOLICY = 320
- SYS_SET_MEMPOLICY = 321
- SYS_OPENAT = 322
- SYS_MKDIRAT = 323
- SYS_MKNODAT = 324
- SYS_FCHOWNAT = 325
- SYS_FUTIMESAT = 326
- SYS_FSTATAT64 = 327
- SYS_UNLINKAT = 328
- SYS_RENAMEAT = 329
- SYS_LINKAT = 330
- SYS_SYMLINKAT = 331
- SYS_READLINKAT = 332
- SYS_FCHMODAT = 333
- SYS_FACCESSAT = 334
- SYS_PSELECT6 = 335
- SYS_PPOLL = 336
- SYS_UNSHARE = 337
- SYS_SET_ROBUST_LIST = 338
- SYS_GET_ROBUST_LIST = 339
- SYS_SPLICE = 340
- SYS_ARM_SYNC_FILE_RANGE = 341
- SYS_TEE = 342
- SYS_VMSPLICE = 343
- SYS_MOVE_PAGES = 344
- SYS_GETCPU = 345
- SYS_EPOLL_PWAIT = 346
- SYS_KEXEC_LOAD = 347
- SYS_UTIMENSAT = 348
- SYS_SIGNALFD = 349
- SYS_TIMERFD_CREATE = 350
- SYS_EVENTFD = 351
- SYS_FALLOCATE = 352
- SYS_TIMERFD_SETTIME = 353
- SYS_TIMERFD_GETTIME = 354
- SYS_SIGNALFD4 = 355
- SYS_EVENTFD2 = 356
- SYS_EPOLL_CREATE1 = 357
- SYS_DUP3 = 358
- SYS_PIPE2 = 359
- SYS_INOTIFY_INIT1 = 360
- SYS_PREADV = 361
- SYS_PWRITEV = 362
- SYS_RT_TGSIGQUEUEINFO = 363
- SYS_PERF_EVENT_OPEN = 364
- SYS_RECVMMSG = 365
- SYS_ACCEPT4 = 366
- SYS_FANOTIFY_INIT = 367
- SYS_FANOTIFY_MARK = 368
- SYS_PRLIMIT64 = 369
- SYS_NAME_TO_HANDLE_AT = 370
- SYS_OPEN_BY_HANDLE_AT = 371
- SYS_CLOCK_ADJTIME = 372
- SYS_SYNCFS = 373
- SYS_SENDMMSG = 374
- SYS_SETNS = 375
- SYS_PROCESS_VM_READV = 376
- SYS_PROCESS_VM_WRITEV = 377
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go
deleted file mode 100644
index 2e9514f2..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go
+++ /dev/null
@@ -1,272 +0,0 @@
-// mksysnum_linux.pl /usr/include/asm-generic/unistd.h
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build arm64,linux
-
-package unix
-
-const (
- SYS_IO_SETUP = 0
- SYS_IO_DESTROY = 1
- SYS_IO_SUBMIT = 2
- SYS_IO_CANCEL = 3
- SYS_IO_GETEVENTS = 4
- SYS_SETXATTR = 5
- SYS_LSETXATTR = 6
- SYS_FSETXATTR = 7
- SYS_GETXATTR = 8
- SYS_LGETXATTR = 9
- SYS_FGETXATTR = 10
- SYS_LISTXATTR = 11
- SYS_LLISTXATTR = 12
- SYS_FLISTXATTR = 13
- SYS_REMOVEXATTR = 14
- SYS_LREMOVEXATTR = 15
- SYS_FREMOVEXATTR = 16
- SYS_GETCWD = 17
- SYS_LOOKUP_DCOOKIE = 18
- SYS_EVENTFD2 = 19
- SYS_EPOLL_CREATE1 = 20
- SYS_EPOLL_CTL = 21
- SYS_EPOLL_PWAIT = 22
- SYS_DUP = 23
- SYS_DUP3 = 24
- SYS_FCNTL = 25
- SYS_INOTIFY_INIT1 = 26
- SYS_INOTIFY_ADD_WATCH = 27
- SYS_INOTIFY_RM_WATCH = 28
- SYS_IOCTL = 29
- SYS_IOPRIO_SET = 30
- SYS_IOPRIO_GET = 31
- SYS_FLOCK = 32
- SYS_MKNODAT = 33
- SYS_MKDIRAT = 34
- SYS_UNLINKAT = 35
- SYS_SYMLINKAT = 36
- SYS_LINKAT = 37
- SYS_RENAMEAT = 38
- SYS_UMOUNT2 = 39
- SYS_MOUNT = 40
- SYS_PIVOT_ROOT = 41
- SYS_NFSSERVCTL = 42
- SYS_STATFS = 43
- SYS_FSTATFS = 44
- SYS_TRUNCATE = 45
- SYS_FTRUNCATE = 46
- SYS_FALLOCATE = 47
- SYS_FACCESSAT = 48
- SYS_CHDIR = 49
- SYS_FCHDIR = 50
- SYS_CHROOT = 51
- SYS_FCHMOD = 52
- SYS_FCHMODAT = 53
- SYS_FCHOWNAT = 54
- SYS_FCHOWN = 55
- SYS_OPENAT = 56
- SYS_CLOSE = 57
- SYS_VHANGUP = 58
- SYS_PIPE2 = 59
- SYS_QUOTACTL = 60
- SYS_GETDENTS64 = 61
- SYS_LSEEK = 62
- SYS_READ = 63
- SYS_WRITE = 64
- SYS_READV = 65
- SYS_WRITEV = 66
- SYS_PREAD64 = 67
- SYS_PWRITE64 = 68
- SYS_PREADV = 69
- SYS_PWRITEV = 70
- SYS_SENDFILE = 71
- SYS_PSELECT6 = 72
- SYS_PPOLL = 73
- SYS_SIGNALFD4 = 74
- SYS_VMSPLICE = 75
- SYS_SPLICE = 76
- SYS_TEE = 77
- SYS_READLINKAT = 78
- SYS_FSTATAT = 79
- SYS_FSTAT = 80
- SYS_SYNC = 81
- SYS_FSYNC = 82
- SYS_FDATASYNC = 83
- SYS_SYNC_FILE_RANGE = 84
- SYS_TIMERFD_CREATE = 85
- SYS_TIMERFD_SETTIME = 86
- SYS_TIMERFD_GETTIME = 87
- SYS_UTIMENSAT = 88
- SYS_ACCT = 89
- SYS_CAPGET = 90
- SYS_CAPSET = 91
- SYS_PERSONALITY = 92
- SYS_EXIT = 93
- SYS_EXIT_GROUP = 94
- SYS_WAITID = 95
- SYS_SET_TID_ADDRESS = 96
- SYS_UNSHARE = 97
- SYS_FUTEX = 98
- SYS_SET_ROBUST_LIST = 99
- SYS_GET_ROBUST_LIST = 100
- SYS_NANOSLEEP = 101
- SYS_GETITIMER = 102
- SYS_SETITIMER = 103
- SYS_KEXEC_LOAD = 104
- SYS_INIT_MODULE = 105
- SYS_DELETE_MODULE = 106
- SYS_TIMER_CREATE = 107
- SYS_TIMER_GETTIME = 108
- SYS_TIMER_GETOVERRUN = 109
- SYS_TIMER_SETTIME = 110
- SYS_TIMER_DELETE = 111
- SYS_CLOCK_SETTIME = 112
- SYS_CLOCK_GETTIME = 113
- SYS_CLOCK_GETRES = 114
- SYS_CLOCK_NANOSLEEP = 115
- SYS_SYSLOG = 116
- SYS_PTRACE = 117
- SYS_SCHED_SETPARAM = 118
- SYS_SCHED_SETSCHEDULER = 119
- SYS_SCHED_GETSCHEDULER = 120
- SYS_SCHED_GETPARAM = 121
- SYS_SCHED_SETAFFINITY = 122
- SYS_SCHED_GETAFFINITY = 123
- SYS_SCHED_YIELD = 124
- SYS_SCHED_GET_PRIORITY_MAX = 125
- SYS_SCHED_GET_PRIORITY_MIN = 126
- SYS_SCHED_RR_GET_INTERVAL = 127
- SYS_RESTART_SYSCALL = 128
- SYS_KILL = 129
- SYS_TKILL = 130
- SYS_TGKILL = 131
- SYS_SIGALTSTACK = 132
- SYS_RT_SIGSUSPEND = 133
- SYS_RT_SIGACTION = 134
- SYS_RT_SIGPROCMASK = 135
- SYS_RT_SIGPENDING = 136
- SYS_RT_SIGTIMEDWAIT = 137
- SYS_RT_SIGQUEUEINFO = 138
- SYS_RT_SIGRETURN = 139
- SYS_SETPRIORITY = 140
- SYS_GETPRIORITY = 141
- SYS_REBOOT = 142
- SYS_SETREGID = 143
- SYS_SETGID = 144
- SYS_SETREUID = 145
- SYS_SETUID = 146
- SYS_SETRESUID = 147
- SYS_GETRESUID = 148
- SYS_SETRESGID = 149
- SYS_GETRESGID = 150
- SYS_SETFSUID = 151
- SYS_SETFSGID = 152
- SYS_TIMES = 153
- SYS_SETPGID = 154
- SYS_GETPGID = 155
- SYS_GETSID = 156
- SYS_SETSID = 157
- SYS_GETGROUPS = 158
- SYS_SETGROUPS = 159
- SYS_UNAME = 160
- SYS_SETHOSTNAME = 161
- SYS_SETDOMAINNAME = 162
- SYS_GETRLIMIT = 163
- SYS_SETRLIMIT = 164
- SYS_GETRUSAGE = 165
- SYS_UMASK = 166
- SYS_PRCTL = 167
- SYS_GETCPU = 168
- SYS_GETTIMEOFDAY = 169
- SYS_SETTIMEOFDAY = 170
- SYS_ADJTIMEX = 171
- SYS_GETPID = 172
- SYS_GETPPID = 173
- SYS_GETUID = 174
- SYS_GETEUID = 175
- SYS_GETGID = 176
- SYS_GETEGID = 177
- SYS_GETTID = 178
- SYS_SYSINFO = 179
- SYS_MQ_OPEN = 180
- SYS_MQ_UNLINK = 181
- SYS_MQ_TIMEDSEND = 182
- SYS_MQ_TIMEDRECEIVE = 183
- SYS_MQ_NOTIFY = 184
- SYS_MQ_GETSETATTR = 185
- SYS_MSGGET = 186
- SYS_MSGCTL = 187
- SYS_MSGRCV = 188
- SYS_MSGSND = 189
- SYS_SEMGET = 190
- SYS_SEMCTL = 191
- SYS_SEMTIMEDOP = 192
- SYS_SEMOP = 193
- SYS_SHMGET = 194
- SYS_SHMCTL = 195
- SYS_SHMAT = 196
- SYS_SHMDT = 197
- SYS_SOCKET = 198
- SYS_SOCKETPAIR = 199
- SYS_BIND = 200
- SYS_LISTEN = 201
- SYS_ACCEPT = 202
- SYS_CONNECT = 203
- SYS_GETSOCKNAME = 204
- SYS_GETPEERNAME = 205
- SYS_SENDTO = 206
- SYS_RECVFROM = 207
- SYS_SETSOCKOPT = 208
- SYS_GETSOCKOPT = 209
- SYS_SHUTDOWN = 210
- SYS_SENDMSG = 211
- SYS_RECVMSG = 212
- SYS_READAHEAD = 213
- SYS_BRK = 214
- SYS_MUNMAP = 215
- SYS_MREMAP = 216
- SYS_ADD_KEY = 217
- SYS_REQUEST_KEY = 218
- SYS_KEYCTL = 219
- SYS_CLONE = 220
- SYS_EXECVE = 221
- SYS_MMAP = 222
- SYS_FADVISE64 = 223
- SYS_SWAPON = 224
- SYS_SWAPOFF = 225
- SYS_MPROTECT = 226
- SYS_MSYNC = 227
- SYS_MLOCK = 228
- SYS_MUNLOCK = 229
- SYS_MLOCKALL = 230
- SYS_MUNLOCKALL = 231
- SYS_MINCORE = 232
- SYS_MADVISE = 233
- SYS_REMAP_FILE_PAGES = 234
- SYS_MBIND = 235
- SYS_GET_MEMPOLICY = 236
- SYS_SET_MEMPOLICY = 237
- SYS_MIGRATE_PAGES = 238
- SYS_MOVE_PAGES = 239
- SYS_RT_TGSIGQUEUEINFO = 240
- SYS_PERF_EVENT_OPEN = 241
- SYS_ACCEPT4 = 242
- SYS_RECVMMSG = 243
- SYS_ARCH_SPECIFIC_SYSCALL = 244
- SYS_WAIT4 = 260
- SYS_PRLIMIT64 = 261
- SYS_FANOTIFY_INIT = 262
- SYS_FANOTIFY_MARK = 263
- SYS_NAME_TO_HANDLE_AT = 264
- SYS_OPEN_BY_HANDLE_AT = 265
- SYS_CLOCK_ADJTIME = 266
- SYS_SYNCFS = 267
- SYS_SETNS = 268
- SYS_SENDMMSG = 269
- SYS_PROCESS_VM_READV = 270
- SYS_PROCESS_VM_WRITEV = 271
- SYS_KCMP = 272
- SYS_FINIT_MODULE = 273
- SYS_SCHED_SETATTR = 274
- SYS_SCHED_GETATTR = 275
- SYS_RENAMEAT2 = 276
- SYS_SECCOMP = 277
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go
deleted file mode 100644
index 5ffe1c71..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go
+++ /dev/null
@@ -1,327 +0,0 @@
-// mksysnum_linux.pl /usr/include/asm/unistd.h
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build mips64,linux
-
-package unix
-
-const (
- SYS_READ = 5000
- SYS_WRITE = 5001
- SYS_OPEN = 5002
- SYS_CLOSE = 5003
- SYS_STAT = 5004
- SYS_FSTAT = 5005
- SYS_LSTAT = 5006
- SYS_POLL = 5007
- SYS_LSEEK = 5008
- SYS_MMAP = 5009
- SYS_MPROTECT = 5010
- SYS_MUNMAP = 5011
- SYS_BRK = 5012
- SYS_RT_SIGACTION = 5013
- SYS_RT_SIGPROCMASK = 5014
- SYS_IOCTL = 5015
- SYS_PREAD64 = 5016
- SYS_PWRITE64 = 5017
- SYS_READV = 5018
- SYS_WRITEV = 5019
- SYS_ACCESS = 5020
- SYS_PIPE = 5021
- SYS__NEWSELECT = 5022
- SYS_SCHED_YIELD = 5023
- SYS_MREMAP = 5024
- SYS_MSYNC = 5025
- SYS_MINCORE = 5026
- SYS_MADVISE = 5027
- SYS_SHMGET = 5028
- SYS_SHMAT = 5029
- SYS_SHMCTL = 5030
- SYS_DUP = 5031
- SYS_DUP2 = 5032
- SYS_PAUSE = 5033
- SYS_NANOSLEEP = 5034
- SYS_GETITIMER = 5035
- SYS_SETITIMER = 5036
- SYS_ALARM = 5037
- SYS_GETPID = 5038
- SYS_SENDFILE = 5039
- SYS_SOCKET = 5040
- SYS_CONNECT = 5041
- SYS_ACCEPT = 5042
- SYS_SENDTO = 5043
- SYS_RECVFROM = 5044
- SYS_SENDMSG = 5045
- SYS_RECVMSG = 5046
- SYS_SHUTDOWN = 5047
- SYS_BIND = 5048
- SYS_LISTEN = 5049
- SYS_GETSOCKNAME = 5050
- SYS_GETPEERNAME = 5051
- SYS_SOCKETPAIR = 5052
- SYS_SETSOCKOPT = 5053
- SYS_GETSOCKOPT = 5054
- SYS_CLONE = 5055
- SYS_FORK = 5056
- SYS_EXECVE = 5057
- SYS_EXIT = 5058
- SYS_WAIT4 = 5059
- SYS_KILL = 5060
- SYS_UNAME = 5061
- SYS_SEMGET = 5062
- SYS_SEMOP = 5063
- SYS_SEMCTL = 5064
- SYS_SHMDT = 5065
- SYS_MSGGET = 5066
- SYS_MSGSND = 5067
- SYS_MSGRCV = 5068
- SYS_MSGCTL = 5069
- SYS_FCNTL = 5070
- SYS_FLOCK = 5071
- SYS_FSYNC = 5072
- SYS_FDATASYNC = 5073
- SYS_TRUNCATE = 5074
- SYS_FTRUNCATE = 5075
- SYS_GETDENTS = 5076
- SYS_GETCWD = 5077
- SYS_CHDIR = 5078
- SYS_FCHDIR = 5079
- SYS_RENAME = 5080
- SYS_MKDIR = 5081
- SYS_RMDIR = 5082
- SYS_CREAT = 5083
- SYS_LINK = 5084
- SYS_UNLINK = 5085
- SYS_SYMLINK = 5086
- SYS_READLINK = 5087
- SYS_CHMOD = 5088
- SYS_FCHMOD = 5089
- SYS_CHOWN = 5090
- SYS_FCHOWN = 5091
- SYS_LCHOWN = 5092
- SYS_UMASK = 5093
- SYS_GETTIMEOFDAY = 5094
- SYS_GETRLIMIT = 5095
- SYS_GETRUSAGE = 5096
- SYS_SYSINFO = 5097
- SYS_TIMES = 5098
- SYS_PTRACE = 5099
- SYS_GETUID = 5100
- SYS_SYSLOG = 5101
- SYS_GETGID = 5102
- SYS_SETUID = 5103
- SYS_SETGID = 5104
- SYS_GETEUID = 5105
- SYS_GETEGID = 5106
- SYS_SETPGID = 5107
- SYS_GETPPID = 5108
- SYS_GETPGRP = 5109
- SYS_SETSID = 5110
- SYS_SETREUID = 5111
- SYS_SETREGID = 5112
- SYS_GETGROUPS = 5113
- SYS_SETGROUPS = 5114
- SYS_SETRESUID = 5115
- SYS_GETRESUID = 5116
- SYS_SETRESGID = 5117
- SYS_GETRESGID = 5118
- SYS_GETPGID = 5119
- SYS_SETFSUID = 5120
- SYS_SETFSGID = 5121
- SYS_GETSID = 5122
- SYS_CAPGET = 5123
- SYS_CAPSET = 5124
- SYS_RT_SIGPENDING = 5125
- SYS_RT_SIGTIMEDWAIT = 5126
- SYS_RT_SIGQUEUEINFO = 5127
- SYS_RT_SIGSUSPEND = 5128
- SYS_SIGALTSTACK = 5129
- SYS_UTIME = 5130
- SYS_MKNOD = 5131
- SYS_PERSONALITY = 5132
- SYS_USTAT = 5133
- SYS_STATFS = 5134
- SYS_FSTATFS = 5135
- SYS_SYSFS = 5136
- SYS_GETPRIORITY = 5137
- SYS_SETPRIORITY = 5138
- SYS_SCHED_SETPARAM = 5139
- SYS_SCHED_GETPARAM = 5140
- SYS_SCHED_SETSCHEDULER = 5141
- SYS_SCHED_GETSCHEDULER = 5142
- SYS_SCHED_GET_PRIORITY_MAX = 5143
- SYS_SCHED_GET_PRIORITY_MIN = 5144
- SYS_SCHED_RR_GET_INTERVAL = 5145
- SYS_MLOCK = 5146
- SYS_MUNLOCK = 5147
- SYS_MLOCKALL = 5148
- SYS_MUNLOCKALL = 5149
- SYS_VHANGUP = 5150
- SYS_PIVOT_ROOT = 5151
- SYS__SYSCTL = 5152
- SYS_PRCTL = 5153
- SYS_ADJTIMEX = 5154
- SYS_SETRLIMIT = 5155
- SYS_CHROOT = 5156
- SYS_SYNC = 5157
- SYS_ACCT = 5158
- SYS_SETTIMEOFDAY = 5159
- SYS_MOUNT = 5160
- SYS_UMOUNT2 = 5161
- SYS_SWAPON = 5162
- SYS_SWAPOFF = 5163
- SYS_REBOOT = 5164
- SYS_SETHOSTNAME = 5165
- SYS_SETDOMAINNAME = 5166
- SYS_CREATE_MODULE = 5167
- SYS_INIT_MODULE = 5168
- SYS_DELETE_MODULE = 5169
- SYS_GET_KERNEL_SYMS = 5170
- SYS_QUERY_MODULE = 5171
- SYS_QUOTACTL = 5172
- SYS_NFSSERVCTL = 5173
- SYS_GETPMSG = 5174
- SYS_PUTPMSG = 5175
- SYS_AFS_SYSCALL = 5176
- SYS_RESERVED177 = 5177
- SYS_GETTID = 5178
- SYS_READAHEAD = 5179
- SYS_SETXATTR = 5180
- SYS_LSETXATTR = 5181
- SYS_FSETXATTR = 5182
- SYS_GETXATTR = 5183
- SYS_LGETXATTR = 5184
- SYS_FGETXATTR = 5185
- SYS_LISTXATTR = 5186
- SYS_LLISTXATTR = 5187
- SYS_FLISTXATTR = 5188
- SYS_REMOVEXATTR = 5189
- SYS_LREMOVEXATTR = 5190
- SYS_FREMOVEXATTR = 5191
- SYS_TKILL = 5192
- SYS_RESERVED193 = 5193
- SYS_FUTEX = 5194
- SYS_SCHED_SETAFFINITY = 5195
- SYS_SCHED_GETAFFINITY = 5196
- SYS_CACHEFLUSH = 5197
- SYS_CACHECTL = 5198
- SYS_SYSMIPS = 5199
- SYS_IO_SETUP = 5200
- SYS_IO_DESTROY = 5201
- SYS_IO_GETEVENTS = 5202
- SYS_IO_SUBMIT = 5203
- SYS_IO_CANCEL = 5204
- SYS_EXIT_GROUP = 5205
- SYS_LOOKUP_DCOOKIE = 5206
- SYS_EPOLL_CREATE = 5207
- SYS_EPOLL_CTL = 5208
- SYS_EPOLL_WAIT = 5209
- SYS_REMAP_FILE_PAGES = 5210
- SYS_RT_SIGRETURN = 5211
- SYS_SET_TID_ADDRESS = 5212
- SYS_RESTART_SYSCALL = 5213
- SYS_SEMTIMEDOP = 5214
- SYS_FADVISE64 = 5215
- SYS_TIMER_CREATE = 5216
- SYS_TIMER_SETTIME = 5217
- SYS_TIMER_GETTIME = 5218
- SYS_TIMER_GETOVERRUN = 5219
- SYS_TIMER_DELETE = 5220
- SYS_CLOCK_SETTIME = 5221
- SYS_CLOCK_GETTIME = 5222
- SYS_CLOCK_GETRES = 5223
- SYS_CLOCK_NANOSLEEP = 5224
- SYS_TGKILL = 5225
- SYS_UTIMES = 5226
- SYS_MBIND = 5227
- SYS_GET_MEMPOLICY = 5228
- SYS_SET_MEMPOLICY = 5229
- SYS_MQ_OPEN = 5230
- SYS_MQ_UNLINK = 5231
- SYS_MQ_TIMEDSEND = 5232
- SYS_MQ_TIMEDRECEIVE = 5233
- SYS_MQ_NOTIFY = 5234
- SYS_MQ_GETSETATTR = 5235
- SYS_VSERVER = 5236
- SYS_WAITID = 5237
- SYS_ADD_KEY = 5239
- SYS_REQUEST_KEY = 5240
- SYS_KEYCTL = 5241
- SYS_SET_THREAD_AREA = 5242
- SYS_INOTIFY_INIT = 5243
- SYS_INOTIFY_ADD_WATCH = 5244
- SYS_INOTIFY_RM_WATCH = 5245
- SYS_MIGRATE_PAGES = 5246
- SYS_OPENAT = 5247
- SYS_MKDIRAT = 5248
- SYS_MKNODAT = 5249
- SYS_FCHOWNAT = 5250
- SYS_FUTIMESAT = 5251
- SYS_NEWFSTATAT = 5252
- SYS_UNLINKAT = 5253
- SYS_RENAMEAT = 5254
- SYS_LINKAT = 5255
- SYS_SYMLINKAT = 5256
- SYS_READLINKAT = 5257
- SYS_FCHMODAT = 5258
- SYS_FACCESSAT = 5259
- SYS_PSELECT6 = 5260
- SYS_PPOLL = 5261
- SYS_UNSHARE = 5262
- SYS_SPLICE = 5263
- SYS_SYNC_FILE_RANGE = 5264
- SYS_TEE = 5265
- SYS_VMSPLICE = 5266
- SYS_MOVE_PAGES = 5267
- SYS_SET_ROBUST_LIST = 5268
- SYS_GET_ROBUST_LIST = 5269
- SYS_KEXEC_LOAD = 5270
- SYS_GETCPU = 5271
- SYS_EPOLL_PWAIT = 5272
- SYS_IOPRIO_SET = 5273
- SYS_IOPRIO_GET = 5274
- SYS_UTIMENSAT = 5275
- SYS_SIGNALFD = 5276
- SYS_TIMERFD = 5277
- SYS_EVENTFD = 5278
- SYS_FALLOCATE = 5279
- SYS_TIMERFD_CREATE = 5280
- SYS_TIMERFD_GETTIME = 5281
- SYS_TIMERFD_SETTIME = 5282
- SYS_SIGNALFD4 = 5283
- SYS_EVENTFD2 = 5284
- SYS_EPOLL_CREATE1 = 5285
- SYS_DUP3 = 5286
- SYS_PIPE2 = 5287
- SYS_INOTIFY_INIT1 = 5288
- SYS_PREADV = 5289
- SYS_PWRITEV = 5290
- SYS_RT_TGSIGQUEUEINFO = 5291
- SYS_PERF_EVENT_OPEN = 5292
- SYS_ACCEPT4 = 5293
- SYS_RECVMMSG = 5294
- SYS_FANOTIFY_INIT = 5295
- SYS_FANOTIFY_MARK = 5296
- SYS_PRLIMIT64 = 5297
- SYS_NAME_TO_HANDLE_AT = 5298
- SYS_OPEN_BY_HANDLE_AT = 5299
- SYS_CLOCK_ADJTIME = 5300
- SYS_SYNCFS = 5301
- SYS_SENDMMSG = 5302
- SYS_SETNS = 5303
- SYS_PROCESS_VM_READV = 5304
- SYS_PROCESS_VM_WRITEV = 5305
- SYS_KCMP = 5306
- SYS_FINIT_MODULE = 5307
- SYS_GETDENTS64 = 5308
- SYS_SCHED_SETATTR = 5309
- SYS_SCHED_GETATTR = 5310
- SYS_RENAMEAT2 = 5311
- SYS_SECCOMP = 5312
- SYS_GETRANDOM = 5313
- SYS_MEMFD_CREATE = 5314
- SYS_BPF = 5315
- SYS_EXECVEAT = 5316
- SYS_USERFAULTFD = 5317
- SYS_MEMBARRIER = 5318
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go
deleted file mode 100644
index d192b940..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go
+++ /dev/null
@@ -1,327 +0,0 @@
-// mksysnum_linux.pl /usr/include/asm/unistd.h
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build mips64le,linux
-
-package unix
-
-const (
- SYS_READ = 5000
- SYS_WRITE = 5001
- SYS_OPEN = 5002
- SYS_CLOSE = 5003
- SYS_STAT = 5004
- SYS_FSTAT = 5005
- SYS_LSTAT = 5006
- SYS_POLL = 5007
- SYS_LSEEK = 5008
- SYS_MMAP = 5009
- SYS_MPROTECT = 5010
- SYS_MUNMAP = 5011
- SYS_BRK = 5012
- SYS_RT_SIGACTION = 5013
- SYS_RT_SIGPROCMASK = 5014
- SYS_IOCTL = 5015
- SYS_PREAD64 = 5016
- SYS_PWRITE64 = 5017
- SYS_READV = 5018
- SYS_WRITEV = 5019
- SYS_ACCESS = 5020
- SYS_PIPE = 5021
- SYS__NEWSELECT = 5022
- SYS_SCHED_YIELD = 5023
- SYS_MREMAP = 5024
- SYS_MSYNC = 5025
- SYS_MINCORE = 5026
- SYS_MADVISE = 5027
- SYS_SHMGET = 5028
- SYS_SHMAT = 5029
- SYS_SHMCTL = 5030
- SYS_DUP = 5031
- SYS_DUP2 = 5032
- SYS_PAUSE = 5033
- SYS_NANOSLEEP = 5034
- SYS_GETITIMER = 5035
- SYS_SETITIMER = 5036
- SYS_ALARM = 5037
- SYS_GETPID = 5038
- SYS_SENDFILE = 5039
- SYS_SOCKET = 5040
- SYS_CONNECT = 5041
- SYS_ACCEPT = 5042
- SYS_SENDTO = 5043
- SYS_RECVFROM = 5044
- SYS_SENDMSG = 5045
- SYS_RECVMSG = 5046
- SYS_SHUTDOWN = 5047
- SYS_BIND = 5048
- SYS_LISTEN = 5049
- SYS_GETSOCKNAME = 5050
- SYS_GETPEERNAME = 5051
- SYS_SOCKETPAIR = 5052
- SYS_SETSOCKOPT = 5053
- SYS_GETSOCKOPT = 5054
- SYS_CLONE = 5055
- SYS_FORK = 5056
- SYS_EXECVE = 5057
- SYS_EXIT = 5058
- SYS_WAIT4 = 5059
- SYS_KILL = 5060
- SYS_UNAME = 5061
- SYS_SEMGET = 5062
- SYS_SEMOP = 5063
- SYS_SEMCTL = 5064
- SYS_SHMDT = 5065
- SYS_MSGGET = 5066
- SYS_MSGSND = 5067
- SYS_MSGRCV = 5068
- SYS_MSGCTL = 5069
- SYS_FCNTL = 5070
- SYS_FLOCK = 5071
- SYS_FSYNC = 5072
- SYS_FDATASYNC = 5073
- SYS_TRUNCATE = 5074
- SYS_FTRUNCATE = 5075
- SYS_GETDENTS = 5076
- SYS_GETCWD = 5077
- SYS_CHDIR = 5078
- SYS_FCHDIR = 5079
- SYS_RENAME = 5080
- SYS_MKDIR = 5081
- SYS_RMDIR = 5082
- SYS_CREAT = 5083
- SYS_LINK = 5084
- SYS_UNLINK = 5085
- SYS_SYMLINK = 5086
- SYS_READLINK = 5087
- SYS_CHMOD = 5088
- SYS_FCHMOD = 5089
- SYS_CHOWN = 5090
- SYS_FCHOWN = 5091
- SYS_LCHOWN = 5092
- SYS_UMASK = 5093
- SYS_GETTIMEOFDAY = 5094
- SYS_GETRLIMIT = 5095
- SYS_GETRUSAGE = 5096
- SYS_SYSINFO = 5097
- SYS_TIMES = 5098
- SYS_PTRACE = 5099
- SYS_GETUID = 5100
- SYS_SYSLOG = 5101
- SYS_GETGID = 5102
- SYS_SETUID = 5103
- SYS_SETGID = 5104
- SYS_GETEUID = 5105
- SYS_GETEGID = 5106
- SYS_SETPGID = 5107
- SYS_GETPPID = 5108
- SYS_GETPGRP = 5109
- SYS_SETSID = 5110
- SYS_SETREUID = 5111
- SYS_SETREGID = 5112
- SYS_GETGROUPS = 5113
- SYS_SETGROUPS = 5114
- SYS_SETRESUID = 5115
- SYS_GETRESUID = 5116
- SYS_SETRESGID = 5117
- SYS_GETRESGID = 5118
- SYS_GETPGID = 5119
- SYS_SETFSUID = 5120
- SYS_SETFSGID = 5121
- SYS_GETSID = 5122
- SYS_CAPGET = 5123
- SYS_CAPSET = 5124
- SYS_RT_SIGPENDING = 5125
- SYS_RT_SIGTIMEDWAIT = 5126
- SYS_RT_SIGQUEUEINFO = 5127
- SYS_RT_SIGSUSPEND = 5128
- SYS_SIGALTSTACK = 5129
- SYS_UTIME = 5130
- SYS_MKNOD = 5131
- SYS_PERSONALITY = 5132
- SYS_USTAT = 5133
- SYS_STATFS = 5134
- SYS_FSTATFS = 5135
- SYS_SYSFS = 5136
- SYS_GETPRIORITY = 5137
- SYS_SETPRIORITY = 5138
- SYS_SCHED_SETPARAM = 5139
- SYS_SCHED_GETPARAM = 5140
- SYS_SCHED_SETSCHEDULER = 5141
- SYS_SCHED_GETSCHEDULER = 5142
- SYS_SCHED_GET_PRIORITY_MAX = 5143
- SYS_SCHED_GET_PRIORITY_MIN = 5144
- SYS_SCHED_RR_GET_INTERVAL = 5145
- SYS_MLOCK = 5146
- SYS_MUNLOCK = 5147
- SYS_MLOCKALL = 5148
- SYS_MUNLOCKALL = 5149
- SYS_VHANGUP = 5150
- SYS_PIVOT_ROOT = 5151
- SYS__SYSCTL = 5152
- SYS_PRCTL = 5153
- SYS_ADJTIMEX = 5154
- SYS_SETRLIMIT = 5155
- SYS_CHROOT = 5156
- SYS_SYNC = 5157
- SYS_ACCT = 5158
- SYS_SETTIMEOFDAY = 5159
- SYS_MOUNT = 5160
- SYS_UMOUNT2 = 5161
- SYS_SWAPON = 5162
- SYS_SWAPOFF = 5163
- SYS_REBOOT = 5164
- SYS_SETHOSTNAME = 5165
- SYS_SETDOMAINNAME = 5166
- SYS_CREATE_MODULE = 5167
- SYS_INIT_MODULE = 5168
- SYS_DELETE_MODULE = 5169
- SYS_GET_KERNEL_SYMS = 5170
- SYS_QUERY_MODULE = 5171
- SYS_QUOTACTL = 5172
- SYS_NFSSERVCTL = 5173
- SYS_GETPMSG = 5174
- SYS_PUTPMSG = 5175
- SYS_AFS_SYSCALL = 5176
- SYS_RESERVED177 = 5177
- SYS_GETTID = 5178
- SYS_READAHEAD = 5179
- SYS_SETXATTR = 5180
- SYS_LSETXATTR = 5181
- SYS_FSETXATTR = 5182
- SYS_GETXATTR = 5183
- SYS_LGETXATTR = 5184
- SYS_FGETXATTR = 5185
- SYS_LISTXATTR = 5186
- SYS_LLISTXATTR = 5187
- SYS_FLISTXATTR = 5188
- SYS_REMOVEXATTR = 5189
- SYS_LREMOVEXATTR = 5190
- SYS_FREMOVEXATTR = 5191
- SYS_TKILL = 5192
- SYS_RESERVED193 = 5193
- SYS_FUTEX = 5194
- SYS_SCHED_SETAFFINITY = 5195
- SYS_SCHED_GETAFFINITY = 5196
- SYS_CACHEFLUSH = 5197
- SYS_CACHECTL = 5198
- SYS_SYSMIPS = 5199
- SYS_IO_SETUP = 5200
- SYS_IO_DESTROY = 5201
- SYS_IO_GETEVENTS = 5202
- SYS_IO_SUBMIT = 5203
- SYS_IO_CANCEL = 5204
- SYS_EXIT_GROUP = 5205
- SYS_LOOKUP_DCOOKIE = 5206
- SYS_EPOLL_CREATE = 5207
- SYS_EPOLL_CTL = 5208
- SYS_EPOLL_WAIT = 5209
- SYS_REMAP_FILE_PAGES = 5210
- SYS_RT_SIGRETURN = 5211
- SYS_SET_TID_ADDRESS = 5212
- SYS_RESTART_SYSCALL = 5213
- SYS_SEMTIMEDOP = 5214
- SYS_FADVISE64 = 5215
- SYS_TIMER_CREATE = 5216
- SYS_TIMER_SETTIME = 5217
- SYS_TIMER_GETTIME = 5218
- SYS_TIMER_GETOVERRUN = 5219
- SYS_TIMER_DELETE = 5220
- SYS_CLOCK_SETTIME = 5221
- SYS_CLOCK_GETTIME = 5222
- SYS_CLOCK_GETRES = 5223
- SYS_CLOCK_NANOSLEEP = 5224
- SYS_TGKILL = 5225
- SYS_UTIMES = 5226
- SYS_MBIND = 5227
- SYS_GET_MEMPOLICY = 5228
- SYS_SET_MEMPOLICY = 5229
- SYS_MQ_OPEN = 5230
- SYS_MQ_UNLINK = 5231
- SYS_MQ_TIMEDSEND = 5232
- SYS_MQ_TIMEDRECEIVE = 5233
- SYS_MQ_NOTIFY = 5234
- SYS_MQ_GETSETATTR = 5235
- SYS_VSERVER = 5236
- SYS_WAITID = 5237
- SYS_ADD_KEY = 5239
- SYS_REQUEST_KEY = 5240
- SYS_KEYCTL = 5241
- SYS_SET_THREAD_AREA = 5242
- SYS_INOTIFY_INIT = 5243
- SYS_INOTIFY_ADD_WATCH = 5244
- SYS_INOTIFY_RM_WATCH = 5245
- SYS_MIGRATE_PAGES = 5246
- SYS_OPENAT = 5247
- SYS_MKDIRAT = 5248
- SYS_MKNODAT = 5249
- SYS_FCHOWNAT = 5250
- SYS_FUTIMESAT = 5251
- SYS_NEWFSTATAT = 5252
- SYS_UNLINKAT = 5253
- SYS_RENAMEAT = 5254
- SYS_LINKAT = 5255
- SYS_SYMLINKAT = 5256
- SYS_READLINKAT = 5257
- SYS_FCHMODAT = 5258
- SYS_FACCESSAT = 5259
- SYS_PSELECT6 = 5260
- SYS_PPOLL = 5261
- SYS_UNSHARE = 5262
- SYS_SPLICE = 5263
- SYS_SYNC_FILE_RANGE = 5264
- SYS_TEE = 5265
- SYS_VMSPLICE = 5266
- SYS_MOVE_PAGES = 5267
- SYS_SET_ROBUST_LIST = 5268
- SYS_GET_ROBUST_LIST = 5269
- SYS_KEXEC_LOAD = 5270
- SYS_GETCPU = 5271
- SYS_EPOLL_PWAIT = 5272
- SYS_IOPRIO_SET = 5273
- SYS_IOPRIO_GET = 5274
- SYS_UTIMENSAT = 5275
- SYS_SIGNALFD = 5276
- SYS_TIMERFD = 5277
- SYS_EVENTFD = 5278
- SYS_FALLOCATE = 5279
- SYS_TIMERFD_CREATE = 5280
- SYS_TIMERFD_GETTIME = 5281
- SYS_TIMERFD_SETTIME = 5282
- SYS_SIGNALFD4 = 5283
- SYS_EVENTFD2 = 5284
- SYS_EPOLL_CREATE1 = 5285
- SYS_DUP3 = 5286
- SYS_PIPE2 = 5287
- SYS_INOTIFY_INIT1 = 5288
- SYS_PREADV = 5289
- SYS_PWRITEV = 5290
- SYS_RT_TGSIGQUEUEINFO = 5291
- SYS_PERF_EVENT_OPEN = 5292
- SYS_ACCEPT4 = 5293
- SYS_RECVMMSG = 5294
- SYS_FANOTIFY_INIT = 5295
- SYS_FANOTIFY_MARK = 5296
- SYS_PRLIMIT64 = 5297
- SYS_NAME_TO_HANDLE_AT = 5298
- SYS_OPEN_BY_HANDLE_AT = 5299
- SYS_CLOCK_ADJTIME = 5300
- SYS_SYNCFS = 5301
- SYS_SENDMMSG = 5302
- SYS_SETNS = 5303
- SYS_PROCESS_VM_READV = 5304
- SYS_PROCESS_VM_WRITEV = 5305
- SYS_KCMP = 5306
- SYS_FINIT_MODULE = 5307
- SYS_GETDENTS64 = 5308
- SYS_SCHED_SETATTR = 5309
- SYS_SCHED_GETATTR = 5310
- SYS_RENAMEAT2 = 5311
- SYS_SECCOMP = 5312
- SYS_GETRANDOM = 5313
- SYS_MEMFD_CREATE = 5314
- SYS_BPF = 5315
- SYS_EXECVEAT = 5316
- SYS_USERFAULTFD = 5317
- SYS_MEMBARRIER = 5318
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go
deleted file mode 100644
index e1b08f00..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go
+++ /dev/null
@@ -1,360 +0,0 @@
-// mksysnum_linux.pl /usr/include/asm/unistd.h
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build ppc64,linux
-
-package unix
-
-const (
- SYS_RESTART_SYSCALL = 0
- SYS_EXIT = 1
- SYS_FORK = 2
- SYS_READ = 3
- SYS_WRITE = 4
- SYS_OPEN = 5
- SYS_CLOSE = 6
- SYS_WAITPID = 7
- SYS_CREAT = 8
- SYS_LINK = 9
- SYS_UNLINK = 10
- SYS_EXECVE = 11
- SYS_CHDIR = 12
- SYS_TIME = 13
- SYS_MKNOD = 14
- SYS_CHMOD = 15
- SYS_LCHOWN = 16
- SYS_BREAK = 17
- SYS_OLDSTAT = 18
- SYS_LSEEK = 19
- SYS_GETPID = 20
- SYS_MOUNT = 21
- SYS_UMOUNT = 22
- SYS_SETUID = 23
- SYS_GETUID = 24
- SYS_STIME = 25
- SYS_PTRACE = 26
- SYS_ALARM = 27
- SYS_OLDFSTAT = 28
- SYS_PAUSE = 29
- SYS_UTIME = 30
- SYS_STTY = 31
- SYS_GTTY = 32
- SYS_ACCESS = 33
- SYS_NICE = 34
- SYS_FTIME = 35
- SYS_SYNC = 36
- SYS_KILL = 37
- SYS_RENAME = 38
- SYS_MKDIR = 39
- SYS_RMDIR = 40
- SYS_DUP = 41
- SYS_PIPE = 42
- SYS_TIMES = 43
- SYS_PROF = 44
- SYS_BRK = 45
- SYS_SETGID = 46
- SYS_GETGID = 47
- SYS_SIGNAL = 48
- SYS_GETEUID = 49
- SYS_GETEGID = 50
- SYS_ACCT = 51
- SYS_UMOUNT2 = 52
- SYS_LOCK = 53
- SYS_IOCTL = 54
- SYS_FCNTL = 55
- SYS_MPX = 56
- SYS_SETPGID = 57
- SYS_ULIMIT = 58
- SYS_OLDOLDUNAME = 59
- SYS_UMASK = 60
- SYS_CHROOT = 61
- SYS_USTAT = 62
- SYS_DUP2 = 63
- SYS_GETPPID = 64
- SYS_GETPGRP = 65
- SYS_SETSID = 66
- SYS_SIGACTION = 67
- SYS_SGETMASK = 68
- SYS_SSETMASK = 69
- SYS_SETREUID = 70
- SYS_SETREGID = 71
- SYS_SIGSUSPEND = 72
- SYS_SIGPENDING = 73
- SYS_SETHOSTNAME = 74
- SYS_SETRLIMIT = 75
- SYS_GETRLIMIT = 76
- SYS_GETRUSAGE = 77
- SYS_GETTIMEOFDAY = 78
- SYS_SETTIMEOFDAY = 79
- SYS_GETGROUPS = 80
- SYS_SETGROUPS = 81
- SYS_SELECT = 82
- SYS_SYMLINK = 83
- SYS_OLDLSTAT = 84
- SYS_READLINK = 85
- SYS_USELIB = 86
- SYS_SWAPON = 87
- SYS_REBOOT = 88
- SYS_READDIR = 89
- SYS_MMAP = 90
- SYS_MUNMAP = 91
- SYS_TRUNCATE = 92
- SYS_FTRUNCATE = 93
- SYS_FCHMOD = 94
- SYS_FCHOWN = 95
- SYS_GETPRIORITY = 96
- SYS_SETPRIORITY = 97
- SYS_PROFIL = 98
- SYS_STATFS = 99
- SYS_FSTATFS = 100
- SYS_IOPERM = 101
- SYS_SOCKETCALL = 102
- SYS_SYSLOG = 103
- SYS_SETITIMER = 104
- SYS_GETITIMER = 105
- SYS_STAT = 106
- SYS_LSTAT = 107
- SYS_FSTAT = 108
- SYS_OLDUNAME = 109
- SYS_IOPL = 110
- SYS_VHANGUP = 111
- SYS_IDLE = 112
- SYS_VM86 = 113
- SYS_WAIT4 = 114
- SYS_SWAPOFF = 115
- SYS_SYSINFO = 116
- SYS_IPC = 117
- SYS_FSYNC = 118
- SYS_SIGRETURN = 119
- SYS_CLONE = 120
- SYS_SETDOMAINNAME = 121
- SYS_UNAME = 122
- SYS_MODIFY_LDT = 123
- SYS_ADJTIMEX = 124
- SYS_MPROTECT = 125
- SYS_SIGPROCMASK = 126
- SYS_CREATE_MODULE = 127
- SYS_INIT_MODULE = 128
- SYS_DELETE_MODULE = 129
- SYS_GET_KERNEL_SYMS = 130
- SYS_QUOTACTL = 131
- SYS_GETPGID = 132
- SYS_FCHDIR = 133
- SYS_BDFLUSH = 134
- SYS_SYSFS = 135
- SYS_PERSONALITY = 136
- SYS_AFS_SYSCALL = 137
- SYS_SETFSUID = 138
- SYS_SETFSGID = 139
- SYS__LLSEEK = 140
- SYS_GETDENTS = 141
- SYS__NEWSELECT = 142
- SYS_FLOCK = 143
- SYS_MSYNC = 144
- SYS_READV = 145
- SYS_WRITEV = 146
- SYS_GETSID = 147
- SYS_FDATASYNC = 148
- SYS__SYSCTL = 149
- SYS_MLOCK = 150
- SYS_MUNLOCK = 151
- SYS_MLOCKALL = 152
- SYS_MUNLOCKALL = 153
- SYS_SCHED_SETPARAM = 154
- SYS_SCHED_GETPARAM = 155
- SYS_SCHED_SETSCHEDULER = 156
- SYS_SCHED_GETSCHEDULER = 157
- SYS_SCHED_YIELD = 158
- SYS_SCHED_GET_PRIORITY_MAX = 159
- SYS_SCHED_GET_PRIORITY_MIN = 160
- SYS_SCHED_RR_GET_INTERVAL = 161
- SYS_NANOSLEEP = 162
- SYS_MREMAP = 163
- SYS_SETRESUID = 164
- SYS_GETRESUID = 165
- SYS_QUERY_MODULE = 166
- SYS_POLL = 167
- SYS_NFSSERVCTL = 168
- SYS_SETRESGID = 169
- SYS_GETRESGID = 170
- SYS_PRCTL = 171
- SYS_RT_SIGRETURN = 172
- SYS_RT_SIGACTION = 173
- SYS_RT_SIGPROCMASK = 174
- SYS_RT_SIGPENDING = 175
- SYS_RT_SIGTIMEDWAIT = 176
- SYS_RT_SIGQUEUEINFO = 177
- SYS_RT_SIGSUSPEND = 178
- SYS_PREAD64 = 179
- SYS_PWRITE64 = 180
- SYS_CHOWN = 181
- SYS_GETCWD = 182
- SYS_CAPGET = 183
- SYS_CAPSET = 184
- SYS_SIGALTSTACK = 185
- SYS_SENDFILE = 186
- SYS_GETPMSG = 187
- SYS_PUTPMSG = 188
- SYS_VFORK = 189
- SYS_UGETRLIMIT = 190
- SYS_READAHEAD = 191
- SYS_PCICONFIG_READ = 198
- SYS_PCICONFIG_WRITE = 199
- SYS_PCICONFIG_IOBASE = 200
- SYS_MULTIPLEXER = 201
- SYS_GETDENTS64 = 202
- SYS_PIVOT_ROOT = 203
- SYS_MADVISE = 205
- SYS_MINCORE = 206
- SYS_GETTID = 207
- SYS_TKILL = 208
- SYS_SETXATTR = 209
- SYS_LSETXATTR = 210
- SYS_FSETXATTR = 211
- SYS_GETXATTR = 212
- SYS_LGETXATTR = 213
- SYS_FGETXATTR = 214
- SYS_LISTXATTR = 215
- SYS_LLISTXATTR = 216
- SYS_FLISTXATTR = 217
- SYS_REMOVEXATTR = 218
- SYS_LREMOVEXATTR = 219
- SYS_FREMOVEXATTR = 220
- SYS_FUTEX = 221
- SYS_SCHED_SETAFFINITY = 222
- SYS_SCHED_GETAFFINITY = 223
- SYS_TUXCALL = 225
- SYS_IO_SETUP = 227
- SYS_IO_DESTROY = 228
- SYS_IO_GETEVENTS = 229
- SYS_IO_SUBMIT = 230
- SYS_IO_CANCEL = 231
- SYS_SET_TID_ADDRESS = 232
- SYS_FADVISE64 = 233
- SYS_EXIT_GROUP = 234
- SYS_LOOKUP_DCOOKIE = 235
- SYS_EPOLL_CREATE = 236
- SYS_EPOLL_CTL = 237
- SYS_EPOLL_WAIT = 238
- SYS_REMAP_FILE_PAGES = 239
- SYS_TIMER_CREATE = 240
- SYS_TIMER_SETTIME = 241
- SYS_TIMER_GETTIME = 242
- SYS_TIMER_GETOVERRUN = 243
- SYS_TIMER_DELETE = 244
- SYS_CLOCK_SETTIME = 245
- SYS_CLOCK_GETTIME = 246
- SYS_CLOCK_GETRES = 247
- SYS_CLOCK_NANOSLEEP = 248
- SYS_SWAPCONTEXT = 249
- SYS_TGKILL = 250
- SYS_UTIMES = 251
- SYS_STATFS64 = 252
- SYS_FSTATFS64 = 253
- SYS_RTAS = 255
- SYS_SYS_DEBUG_SETCONTEXT = 256
- SYS_MIGRATE_PAGES = 258
- SYS_MBIND = 259
- SYS_GET_MEMPOLICY = 260
- SYS_SET_MEMPOLICY = 261
- SYS_MQ_OPEN = 262
- SYS_MQ_UNLINK = 263
- SYS_MQ_TIMEDSEND = 264
- SYS_MQ_TIMEDRECEIVE = 265
- SYS_MQ_NOTIFY = 266
- SYS_MQ_GETSETATTR = 267
- SYS_KEXEC_LOAD = 268
- SYS_ADD_KEY = 269
- SYS_REQUEST_KEY = 270
- SYS_KEYCTL = 271
- SYS_WAITID = 272
- SYS_IOPRIO_SET = 273
- SYS_IOPRIO_GET = 274
- SYS_INOTIFY_INIT = 275
- SYS_INOTIFY_ADD_WATCH = 276
- SYS_INOTIFY_RM_WATCH = 277
- SYS_SPU_RUN = 278
- SYS_SPU_CREATE = 279
- SYS_PSELECT6 = 280
- SYS_PPOLL = 281
- SYS_UNSHARE = 282
- SYS_SPLICE = 283
- SYS_TEE = 284
- SYS_VMSPLICE = 285
- SYS_OPENAT = 286
- SYS_MKDIRAT = 287
- SYS_MKNODAT = 288
- SYS_FCHOWNAT = 289
- SYS_FUTIMESAT = 290
- SYS_NEWFSTATAT = 291
- SYS_UNLINKAT = 292
- SYS_RENAMEAT = 293
- SYS_LINKAT = 294
- SYS_SYMLINKAT = 295
- SYS_READLINKAT = 296
- SYS_FCHMODAT = 297
- SYS_FACCESSAT = 298
- SYS_GET_ROBUST_LIST = 299
- SYS_SET_ROBUST_LIST = 300
- SYS_MOVE_PAGES = 301
- SYS_GETCPU = 302
- SYS_EPOLL_PWAIT = 303
- SYS_UTIMENSAT = 304
- SYS_SIGNALFD = 305
- SYS_TIMERFD_CREATE = 306
- SYS_EVENTFD = 307
- SYS_SYNC_FILE_RANGE2 = 308
- SYS_FALLOCATE = 309
- SYS_SUBPAGE_PROT = 310
- SYS_TIMERFD_SETTIME = 311
- SYS_TIMERFD_GETTIME = 312
- SYS_SIGNALFD4 = 313
- SYS_EVENTFD2 = 314
- SYS_EPOLL_CREATE1 = 315
- SYS_DUP3 = 316
- SYS_PIPE2 = 317
- SYS_INOTIFY_INIT1 = 318
- SYS_PERF_EVENT_OPEN = 319
- SYS_PREADV = 320
- SYS_PWRITEV = 321
- SYS_RT_TGSIGQUEUEINFO = 322
- SYS_FANOTIFY_INIT = 323
- SYS_FANOTIFY_MARK = 324
- SYS_PRLIMIT64 = 325
- SYS_SOCKET = 326
- SYS_BIND = 327
- SYS_CONNECT = 328
- SYS_LISTEN = 329
- SYS_ACCEPT = 330
- SYS_GETSOCKNAME = 331
- SYS_GETPEERNAME = 332
- SYS_SOCKETPAIR = 333
- SYS_SEND = 334
- SYS_SENDTO = 335
- SYS_RECV = 336
- SYS_RECVFROM = 337
- SYS_SHUTDOWN = 338
- SYS_SETSOCKOPT = 339
- SYS_GETSOCKOPT = 340
- SYS_SENDMSG = 341
- SYS_RECVMSG = 342
- SYS_RECVMMSG = 343
- SYS_ACCEPT4 = 344
- SYS_NAME_TO_HANDLE_AT = 345
- SYS_OPEN_BY_HANDLE_AT = 346
- SYS_CLOCK_ADJTIME = 347
- SYS_SYNCFS = 348
- SYS_SENDMMSG = 349
- SYS_SETNS = 350
- SYS_PROCESS_VM_READV = 351
- SYS_PROCESS_VM_WRITEV = 352
- SYS_FINIT_MODULE = 353
- SYS_KCMP = 354
- SYS_SCHED_SETATTR = 355
- SYS_SCHED_GETATTR = 356
- SYS_RENAMEAT2 = 357
- SYS_SECCOMP = 358
- SYS_GETRANDOM = 359
- SYS_MEMFD_CREATE = 360
- SYS_BPF = 361
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go
deleted file mode 100644
index 45e63f51..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go
+++ /dev/null
@@ -1,353 +0,0 @@
-// mksysnum_linux.pl /usr/include/powerpc64le-linux-gnu/asm/unistd.h
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build ppc64le,linux
-
-package unix
-
-const (
- SYS_RESTART_SYSCALL = 0
- SYS_EXIT = 1
- SYS_FORK = 2
- SYS_READ = 3
- SYS_WRITE = 4
- SYS_OPEN = 5
- SYS_CLOSE = 6
- SYS_WAITPID = 7
- SYS_CREAT = 8
- SYS_LINK = 9
- SYS_UNLINK = 10
- SYS_EXECVE = 11
- SYS_CHDIR = 12
- SYS_TIME = 13
- SYS_MKNOD = 14
- SYS_CHMOD = 15
- SYS_LCHOWN = 16
- SYS_BREAK = 17
- SYS_OLDSTAT = 18
- SYS_LSEEK = 19
- SYS_GETPID = 20
- SYS_MOUNT = 21
- SYS_UMOUNT = 22
- SYS_SETUID = 23
- SYS_GETUID = 24
- SYS_STIME = 25
- SYS_PTRACE = 26
- SYS_ALARM = 27
- SYS_OLDFSTAT = 28
- SYS_PAUSE = 29
- SYS_UTIME = 30
- SYS_STTY = 31
- SYS_GTTY = 32
- SYS_ACCESS = 33
- SYS_NICE = 34
- SYS_FTIME = 35
- SYS_SYNC = 36
- SYS_KILL = 37
- SYS_RENAME = 38
- SYS_MKDIR = 39
- SYS_RMDIR = 40
- SYS_DUP = 41
- SYS_PIPE = 42
- SYS_TIMES = 43
- SYS_PROF = 44
- SYS_BRK = 45
- SYS_SETGID = 46
- SYS_GETGID = 47
- SYS_SIGNAL = 48
- SYS_GETEUID = 49
- SYS_GETEGID = 50
- SYS_ACCT = 51
- SYS_UMOUNT2 = 52
- SYS_LOCK = 53
- SYS_IOCTL = 54
- SYS_FCNTL = 55
- SYS_MPX = 56
- SYS_SETPGID = 57
- SYS_ULIMIT = 58
- SYS_OLDOLDUNAME = 59
- SYS_UMASK = 60
- SYS_CHROOT = 61
- SYS_USTAT = 62
- SYS_DUP2 = 63
- SYS_GETPPID = 64
- SYS_GETPGRP = 65
- SYS_SETSID = 66
- SYS_SIGACTION = 67
- SYS_SGETMASK = 68
- SYS_SSETMASK = 69
- SYS_SETREUID = 70
- SYS_SETREGID = 71
- SYS_SIGSUSPEND = 72
- SYS_SIGPENDING = 73
- SYS_SETHOSTNAME = 74
- SYS_SETRLIMIT = 75
- SYS_GETRLIMIT = 76
- SYS_GETRUSAGE = 77
- SYS_GETTIMEOFDAY = 78
- SYS_SETTIMEOFDAY = 79
- SYS_GETGROUPS = 80
- SYS_SETGROUPS = 81
- SYS_SELECT = 82
- SYS_SYMLINK = 83
- SYS_OLDLSTAT = 84
- SYS_READLINK = 85
- SYS_USELIB = 86
- SYS_SWAPON = 87
- SYS_REBOOT = 88
- SYS_READDIR = 89
- SYS_MMAP = 90
- SYS_MUNMAP = 91
- SYS_TRUNCATE = 92
- SYS_FTRUNCATE = 93
- SYS_FCHMOD = 94
- SYS_FCHOWN = 95
- SYS_GETPRIORITY = 96
- SYS_SETPRIORITY = 97
- SYS_PROFIL = 98
- SYS_STATFS = 99
- SYS_FSTATFS = 100
- SYS_IOPERM = 101
- SYS_SOCKETCALL = 102
- SYS_SYSLOG = 103
- SYS_SETITIMER = 104
- SYS_GETITIMER = 105
- SYS_STAT = 106
- SYS_LSTAT = 107
- SYS_FSTAT = 108
- SYS_OLDUNAME = 109
- SYS_IOPL = 110
- SYS_VHANGUP = 111
- SYS_IDLE = 112
- SYS_VM86 = 113
- SYS_WAIT4 = 114
- SYS_SWAPOFF = 115
- SYS_SYSINFO = 116
- SYS_IPC = 117
- SYS_FSYNC = 118
- SYS_SIGRETURN = 119
- SYS_CLONE = 120
- SYS_SETDOMAINNAME = 121
- SYS_UNAME = 122
- SYS_MODIFY_LDT = 123
- SYS_ADJTIMEX = 124
- SYS_MPROTECT = 125
- SYS_SIGPROCMASK = 126
- SYS_CREATE_MODULE = 127
- SYS_INIT_MODULE = 128
- SYS_DELETE_MODULE = 129
- SYS_GET_KERNEL_SYMS = 130
- SYS_QUOTACTL = 131
- SYS_GETPGID = 132
- SYS_FCHDIR = 133
- SYS_BDFLUSH = 134
- SYS_SYSFS = 135
- SYS_PERSONALITY = 136
- SYS_AFS_SYSCALL = 137
- SYS_SETFSUID = 138
- SYS_SETFSGID = 139
- SYS__LLSEEK = 140
- SYS_GETDENTS = 141
- SYS__NEWSELECT = 142
- SYS_FLOCK = 143
- SYS_MSYNC = 144
- SYS_READV = 145
- SYS_WRITEV = 146
- SYS_GETSID = 147
- SYS_FDATASYNC = 148
- SYS__SYSCTL = 149
- SYS_MLOCK = 150
- SYS_MUNLOCK = 151
- SYS_MLOCKALL = 152
- SYS_MUNLOCKALL = 153
- SYS_SCHED_SETPARAM = 154
- SYS_SCHED_GETPARAM = 155
- SYS_SCHED_SETSCHEDULER = 156
- SYS_SCHED_GETSCHEDULER = 157
- SYS_SCHED_YIELD = 158
- SYS_SCHED_GET_PRIORITY_MAX = 159
- SYS_SCHED_GET_PRIORITY_MIN = 160
- SYS_SCHED_RR_GET_INTERVAL = 161
- SYS_NANOSLEEP = 162
- SYS_MREMAP = 163
- SYS_SETRESUID = 164
- SYS_GETRESUID = 165
- SYS_QUERY_MODULE = 166
- SYS_POLL = 167
- SYS_NFSSERVCTL = 168
- SYS_SETRESGID = 169
- SYS_GETRESGID = 170
- SYS_PRCTL = 171
- SYS_RT_SIGRETURN = 172
- SYS_RT_SIGACTION = 173
- SYS_RT_SIGPROCMASK = 174
- SYS_RT_SIGPENDING = 175
- SYS_RT_SIGTIMEDWAIT = 176
- SYS_RT_SIGQUEUEINFO = 177
- SYS_RT_SIGSUSPEND = 178
- SYS_PREAD64 = 179
- SYS_PWRITE64 = 180
- SYS_CHOWN = 181
- SYS_GETCWD = 182
- SYS_CAPGET = 183
- SYS_CAPSET = 184
- SYS_SIGALTSTACK = 185
- SYS_SENDFILE = 186
- SYS_GETPMSG = 187
- SYS_PUTPMSG = 188
- SYS_VFORK = 189
- SYS_UGETRLIMIT = 190
- SYS_READAHEAD = 191
- SYS_PCICONFIG_READ = 198
- SYS_PCICONFIG_WRITE = 199
- SYS_PCICONFIG_IOBASE = 200
- SYS_MULTIPLEXER = 201
- SYS_GETDENTS64 = 202
- SYS_PIVOT_ROOT = 203
- SYS_MADVISE = 205
- SYS_MINCORE = 206
- SYS_GETTID = 207
- SYS_TKILL = 208
- SYS_SETXATTR = 209
- SYS_LSETXATTR = 210
- SYS_FSETXATTR = 211
- SYS_GETXATTR = 212
- SYS_LGETXATTR = 213
- SYS_FGETXATTR = 214
- SYS_LISTXATTR = 215
- SYS_LLISTXATTR = 216
- SYS_FLISTXATTR = 217
- SYS_REMOVEXATTR = 218
- SYS_LREMOVEXATTR = 219
- SYS_FREMOVEXATTR = 220
- SYS_FUTEX = 221
- SYS_SCHED_SETAFFINITY = 222
- SYS_SCHED_GETAFFINITY = 223
- SYS_TUXCALL = 225
- SYS_IO_SETUP = 227
- SYS_IO_DESTROY = 228
- SYS_IO_GETEVENTS = 229
- SYS_IO_SUBMIT = 230
- SYS_IO_CANCEL = 231
- SYS_SET_TID_ADDRESS = 232
- SYS_FADVISE64 = 233
- SYS_EXIT_GROUP = 234
- SYS_LOOKUP_DCOOKIE = 235
- SYS_EPOLL_CREATE = 236
- SYS_EPOLL_CTL = 237
- SYS_EPOLL_WAIT = 238
- SYS_REMAP_FILE_PAGES = 239
- SYS_TIMER_CREATE = 240
- SYS_TIMER_SETTIME = 241
- SYS_TIMER_GETTIME = 242
- SYS_TIMER_GETOVERRUN = 243
- SYS_TIMER_DELETE = 244
- SYS_CLOCK_SETTIME = 245
- SYS_CLOCK_GETTIME = 246
- SYS_CLOCK_GETRES = 247
- SYS_CLOCK_NANOSLEEP = 248
- SYS_SWAPCONTEXT = 249
- SYS_TGKILL = 250
- SYS_UTIMES = 251
- SYS_STATFS64 = 252
- SYS_FSTATFS64 = 253
- SYS_RTAS = 255
- SYS_SYS_DEBUG_SETCONTEXT = 256
- SYS_MIGRATE_PAGES = 258
- SYS_MBIND = 259
- SYS_GET_MEMPOLICY = 260
- SYS_SET_MEMPOLICY = 261
- SYS_MQ_OPEN = 262
- SYS_MQ_UNLINK = 263
- SYS_MQ_TIMEDSEND = 264
- SYS_MQ_TIMEDRECEIVE = 265
- SYS_MQ_NOTIFY = 266
- SYS_MQ_GETSETATTR = 267
- SYS_KEXEC_LOAD = 268
- SYS_ADD_KEY = 269
- SYS_REQUEST_KEY = 270
- SYS_KEYCTL = 271
- SYS_WAITID = 272
- SYS_IOPRIO_SET = 273
- SYS_IOPRIO_GET = 274
- SYS_INOTIFY_INIT = 275
- SYS_INOTIFY_ADD_WATCH = 276
- SYS_INOTIFY_RM_WATCH = 277
- SYS_SPU_RUN = 278
- SYS_SPU_CREATE = 279
- SYS_PSELECT6 = 280
- SYS_PPOLL = 281
- SYS_UNSHARE = 282
- SYS_SPLICE = 283
- SYS_TEE = 284
- SYS_VMSPLICE = 285
- SYS_OPENAT = 286
- SYS_MKDIRAT = 287
- SYS_MKNODAT = 288
- SYS_FCHOWNAT = 289
- SYS_FUTIMESAT = 290
- SYS_NEWFSTATAT = 291
- SYS_UNLINKAT = 292
- SYS_RENAMEAT = 293
- SYS_LINKAT = 294
- SYS_SYMLINKAT = 295
- SYS_READLINKAT = 296
- SYS_FCHMODAT = 297
- SYS_FACCESSAT = 298
- SYS_GET_ROBUST_LIST = 299
- SYS_SET_ROBUST_LIST = 300
- SYS_MOVE_PAGES = 301
- SYS_GETCPU = 302
- SYS_EPOLL_PWAIT = 303
- SYS_UTIMENSAT = 304
- SYS_SIGNALFD = 305
- SYS_TIMERFD_CREATE = 306
- SYS_EVENTFD = 307
- SYS_SYNC_FILE_RANGE2 = 308
- SYS_FALLOCATE = 309
- SYS_SUBPAGE_PROT = 310
- SYS_TIMERFD_SETTIME = 311
- SYS_TIMERFD_GETTIME = 312
- SYS_SIGNALFD4 = 313
- SYS_EVENTFD2 = 314
- SYS_EPOLL_CREATE1 = 315
- SYS_DUP3 = 316
- SYS_PIPE2 = 317
- SYS_INOTIFY_INIT1 = 318
- SYS_PERF_EVENT_OPEN = 319
- SYS_PREADV = 320
- SYS_PWRITEV = 321
- SYS_RT_TGSIGQUEUEINFO = 322
- SYS_FANOTIFY_INIT = 323
- SYS_FANOTIFY_MARK = 324
- SYS_PRLIMIT64 = 325
- SYS_SOCKET = 326
- SYS_BIND = 327
- SYS_CONNECT = 328
- SYS_LISTEN = 329
- SYS_ACCEPT = 330
- SYS_GETSOCKNAME = 331
- SYS_GETPEERNAME = 332
- SYS_SOCKETPAIR = 333
- SYS_SEND = 334
- SYS_SENDTO = 335
- SYS_RECV = 336
- SYS_RECVFROM = 337
- SYS_SHUTDOWN = 338
- SYS_SETSOCKOPT = 339
- SYS_GETSOCKOPT = 340
- SYS_SENDMSG = 341
- SYS_RECVMSG = 342
- SYS_RECVMMSG = 343
- SYS_ACCEPT4 = 344
- SYS_NAME_TO_HANDLE_AT = 345
- SYS_OPEN_BY_HANDLE_AT = 346
- SYS_CLOCK_ADJTIME = 347
- SYS_SYNCFS = 348
- SYS_SENDMMSG = 349
- SYS_SETNS = 350
- SYS_PROCESS_VM_READV = 351
- SYS_PROCESS_VM_WRITEV = 352
- SYS_FINIT_MODULE = 353
- SYS_KCMP = 354
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go
deleted file mode 100644
index 42d4f5cd..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go
+++ /dev/null
@@ -1,328 +0,0 @@
-// mksysnum_linux.pl /usr/include/asm/unistd.h
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build s390x,linux
-
-package unix
-
-const (
- SYS_EXIT = 1
- SYS_FORK = 2
- SYS_READ = 3
- SYS_WRITE = 4
- SYS_OPEN = 5
- SYS_CLOSE = 6
- SYS_RESTART_SYSCALL = 7
- SYS_CREAT = 8
- SYS_LINK = 9
- SYS_UNLINK = 10
- SYS_EXECVE = 11
- SYS_CHDIR = 12
- SYS_MKNOD = 14
- SYS_CHMOD = 15
- SYS_LSEEK = 19
- SYS_GETPID = 20
- SYS_MOUNT = 21
- SYS_UMOUNT = 22
- SYS_PTRACE = 26
- SYS_ALARM = 27
- SYS_PAUSE = 29
- SYS_UTIME = 30
- SYS_ACCESS = 33
- SYS_NICE = 34
- SYS_SYNC = 36
- SYS_KILL = 37
- SYS_RENAME = 38
- SYS_MKDIR = 39
- SYS_RMDIR = 40
- SYS_DUP = 41
- SYS_PIPE = 42
- SYS_TIMES = 43
- SYS_BRK = 45
- SYS_SIGNAL = 48
- SYS_ACCT = 51
- SYS_UMOUNT2 = 52
- SYS_IOCTL = 54
- SYS_FCNTL = 55
- SYS_SETPGID = 57
- SYS_UMASK = 60
- SYS_CHROOT = 61
- SYS_USTAT = 62
- SYS_DUP2 = 63
- SYS_GETPPID = 64
- SYS_GETPGRP = 65
- SYS_SETSID = 66
- SYS_SIGACTION = 67
- SYS_SIGSUSPEND = 72
- SYS_SIGPENDING = 73
- SYS_SETHOSTNAME = 74
- SYS_SETRLIMIT = 75
- SYS_GETRUSAGE = 77
- SYS_GETTIMEOFDAY = 78
- SYS_SETTIMEOFDAY = 79
- SYS_SYMLINK = 83
- SYS_READLINK = 85
- SYS_USELIB = 86
- SYS_SWAPON = 87
- SYS_REBOOT = 88
- SYS_READDIR = 89
- SYS_MMAP = 90
- SYS_MUNMAP = 91
- SYS_TRUNCATE = 92
- SYS_FTRUNCATE = 93
- SYS_FCHMOD = 94
- SYS_GETPRIORITY = 96
- SYS_SETPRIORITY = 97
- SYS_STATFS = 99
- SYS_FSTATFS = 100
- SYS_SOCKETCALL = 102
- SYS_SYSLOG = 103
- SYS_SETITIMER = 104
- SYS_GETITIMER = 105
- SYS_STAT = 106
- SYS_LSTAT = 107
- SYS_FSTAT = 108
- SYS_LOOKUP_DCOOKIE = 110
- SYS_VHANGUP = 111
- SYS_IDLE = 112
- SYS_WAIT4 = 114
- SYS_SWAPOFF = 115
- SYS_SYSINFO = 116
- SYS_IPC = 117
- SYS_FSYNC = 118
- SYS_SIGRETURN = 119
- SYS_CLONE = 120
- SYS_SETDOMAINNAME = 121
- SYS_UNAME = 122
- SYS_ADJTIMEX = 124
- SYS_MPROTECT = 125
- SYS_SIGPROCMASK = 126
- SYS_CREATE_MODULE = 127
- SYS_INIT_MODULE = 128
- SYS_DELETE_MODULE = 129
- SYS_GET_KERNEL_SYMS = 130
- SYS_QUOTACTL = 131
- SYS_GETPGID = 132
- SYS_FCHDIR = 133
- SYS_BDFLUSH = 134
- SYS_SYSFS = 135
- SYS_PERSONALITY = 136
- SYS_AFS_SYSCALL = 137
- SYS_GETDENTS = 141
- SYS_FLOCK = 143
- SYS_MSYNC = 144
- SYS_READV = 145
- SYS_WRITEV = 146
- SYS_GETSID = 147
- SYS_FDATASYNC = 148
- SYS__SYSCTL = 149
- SYS_MLOCK = 150
- SYS_MUNLOCK = 151
- SYS_MLOCKALL = 152
- SYS_MUNLOCKALL = 153
- SYS_SCHED_SETPARAM = 154
- SYS_SCHED_GETPARAM = 155
- SYS_SCHED_SETSCHEDULER = 156
- SYS_SCHED_GETSCHEDULER = 157
- SYS_SCHED_YIELD = 158
- SYS_SCHED_GET_PRIORITY_MAX = 159
- SYS_SCHED_GET_PRIORITY_MIN = 160
- SYS_SCHED_RR_GET_INTERVAL = 161
- SYS_NANOSLEEP = 162
- SYS_MREMAP = 163
- SYS_QUERY_MODULE = 167
- SYS_POLL = 168
- SYS_NFSSERVCTL = 169
- SYS_PRCTL = 172
- SYS_RT_SIGRETURN = 173
- SYS_RT_SIGACTION = 174
- SYS_RT_SIGPROCMASK = 175
- SYS_RT_SIGPENDING = 176
- SYS_RT_SIGTIMEDWAIT = 177
- SYS_RT_SIGQUEUEINFO = 178
- SYS_RT_SIGSUSPEND = 179
- SYS_PREAD64 = 180
- SYS_PWRITE64 = 181
- SYS_GETCWD = 183
- SYS_CAPGET = 184
- SYS_CAPSET = 185
- SYS_SIGALTSTACK = 186
- SYS_SENDFILE = 187
- SYS_GETPMSG = 188
- SYS_PUTPMSG = 189
- SYS_VFORK = 190
- SYS_PIVOT_ROOT = 217
- SYS_MINCORE = 218
- SYS_MADVISE = 219
- SYS_GETDENTS64 = 220
- SYS_READAHEAD = 222
- SYS_SETXATTR = 224
- SYS_LSETXATTR = 225
- SYS_FSETXATTR = 226
- SYS_GETXATTR = 227
- SYS_LGETXATTR = 228
- SYS_FGETXATTR = 229
- SYS_LISTXATTR = 230
- SYS_LLISTXATTR = 231
- SYS_FLISTXATTR = 232
- SYS_REMOVEXATTR = 233
- SYS_LREMOVEXATTR = 234
- SYS_FREMOVEXATTR = 235
- SYS_GETTID = 236
- SYS_TKILL = 237
- SYS_FUTEX = 238
- SYS_SCHED_SETAFFINITY = 239
- SYS_SCHED_GETAFFINITY = 240
- SYS_TGKILL = 241
- SYS_IO_SETUP = 243
- SYS_IO_DESTROY = 244
- SYS_IO_GETEVENTS = 245
- SYS_IO_SUBMIT = 246
- SYS_IO_CANCEL = 247
- SYS_EXIT_GROUP = 248
- SYS_EPOLL_CREATE = 249
- SYS_EPOLL_CTL = 250
- SYS_EPOLL_WAIT = 251
- SYS_SET_TID_ADDRESS = 252
- SYS_FADVISE64 = 253
- SYS_TIMER_CREATE = 254
- SYS_TIMER_SETTIME = 255
- SYS_TIMER_GETTIME = 256
- SYS_TIMER_GETOVERRUN = 257
- SYS_TIMER_DELETE = 258
- SYS_CLOCK_SETTIME = 259
- SYS_CLOCK_GETTIME = 260
- SYS_CLOCK_GETRES = 261
- SYS_CLOCK_NANOSLEEP = 262
- SYS_STATFS64 = 265
- SYS_FSTATFS64 = 266
- SYS_REMAP_FILE_PAGES = 267
- SYS_MBIND = 268
- SYS_GET_MEMPOLICY = 269
- SYS_SET_MEMPOLICY = 270
- SYS_MQ_OPEN = 271
- SYS_MQ_UNLINK = 272
- SYS_MQ_TIMEDSEND = 273
- SYS_MQ_TIMEDRECEIVE = 274
- SYS_MQ_NOTIFY = 275
- SYS_MQ_GETSETATTR = 276
- SYS_KEXEC_LOAD = 277
- SYS_ADD_KEY = 278
- SYS_REQUEST_KEY = 279
- SYS_KEYCTL = 280
- SYS_WAITID = 281
- SYS_IOPRIO_SET = 282
- SYS_IOPRIO_GET = 283
- SYS_INOTIFY_INIT = 284
- SYS_INOTIFY_ADD_WATCH = 285
- SYS_INOTIFY_RM_WATCH = 286
- SYS_MIGRATE_PAGES = 287
- SYS_OPENAT = 288
- SYS_MKDIRAT = 289
- SYS_MKNODAT = 290
- SYS_FCHOWNAT = 291
- SYS_FUTIMESAT = 292
- SYS_UNLINKAT = 294
- SYS_RENAMEAT = 295
- SYS_LINKAT = 296
- SYS_SYMLINKAT = 297
- SYS_READLINKAT = 298
- SYS_FCHMODAT = 299
- SYS_FACCESSAT = 300
- SYS_PSELECT6 = 301
- SYS_PPOLL = 302
- SYS_UNSHARE = 303
- SYS_SET_ROBUST_LIST = 304
- SYS_GET_ROBUST_LIST = 305
- SYS_SPLICE = 306
- SYS_SYNC_FILE_RANGE = 307
- SYS_TEE = 308
- SYS_VMSPLICE = 309
- SYS_MOVE_PAGES = 310
- SYS_GETCPU = 311
- SYS_EPOLL_PWAIT = 312
- SYS_UTIMES = 313
- SYS_FALLOCATE = 314
- SYS_UTIMENSAT = 315
- SYS_SIGNALFD = 316
- SYS_TIMERFD = 317
- SYS_EVENTFD = 318
- SYS_TIMERFD_CREATE = 319
- SYS_TIMERFD_SETTIME = 320
- SYS_TIMERFD_GETTIME = 321
- SYS_SIGNALFD4 = 322
- SYS_EVENTFD2 = 323
- SYS_INOTIFY_INIT1 = 324
- SYS_PIPE2 = 325
- SYS_DUP3 = 326
- SYS_EPOLL_CREATE1 = 327
- SYS_PREADV = 328
- SYS_PWRITEV = 329
- SYS_RT_TGSIGQUEUEINFO = 330
- SYS_PERF_EVENT_OPEN = 331
- SYS_FANOTIFY_INIT = 332
- SYS_FANOTIFY_MARK = 333
- SYS_PRLIMIT64 = 334
- SYS_NAME_TO_HANDLE_AT = 335
- SYS_OPEN_BY_HANDLE_AT = 336
- SYS_CLOCK_ADJTIME = 337
- SYS_SYNCFS = 338
- SYS_SETNS = 339
- SYS_PROCESS_VM_READV = 340
- SYS_PROCESS_VM_WRITEV = 341
- SYS_S390_RUNTIME_INSTR = 342
- SYS_KCMP = 343
- SYS_FINIT_MODULE = 344
- SYS_SCHED_SETATTR = 345
- SYS_SCHED_GETATTR = 346
- SYS_RENAMEAT2 = 347
- SYS_SECCOMP = 348
- SYS_GETRANDOM = 349
- SYS_MEMFD_CREATE = 350
- SYS_BPF = 351
- SYS_S390_PCI_MMIO_WRITE = 352
- SYS_S390_PCI_MMIO_READ = 353
- SYS_EXECVEAT = 354
- SYS_USERFAULTFD = 355
- SYS_MEMBARRIER = 356
- SYS_RECVMMSG = 357
- SYS_SENDMMSG = 358
- SYS_SOCKET = 359
- SYS_SOCKETPAIR = 360
- SYS_BIND = 361
- SYS_CONNECT = 362
- SYS_LISTEN = 363
- SYS_ACCEPT4 = 364
- SYS_GETSOCKOPT = 365
- SYS_SETSOCKOPT = 366
- SYS_GETSOCKNAME = 367
- SYS_GETPEERNAME = 368
- SYS_SENDTO = 369
- SYS_SENDMSG = 370
- SYS_RECVFROM = 371
- SYS_RECVMSG = 372
- SYS_SHUTDOWN = 373
- SYS_MLOCK2 = 374
- SYS_SELECT = 142
- SYS_GETRLIMIT = 191
- SYS_LCHOWN = 198
- SYS_GETUID = 199
- SYS_GETGID = 200
- SYS_GETEUID = 201
- SYS_GETEGID = 202
- SYS_SETREUID = 203
- SYS_SETREGID = 204
- SYS_GETGROUPS = 205
- SYS_SETGROUPS = 206
- SYS_FCHOWN = 207
- SYS_SETRESUID = 208
- SYS_GETRESUID = 209
- SYS_SETRESGID = 210
- SYS_GETRESGID = 211
- SYS_CHOWN = 212
- SYS_SETUID = 213
- SYS_SETGID = 214
- SYS_SETFSUID = 215
- SYS_SETFSGID = 216
- SYS_NEWFSTATAT = 293
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go
deleted file mode 100644
index 46b5bee1..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go
+++ /dev/null
@@ -1,348 +0,0 @@
-// mksysnum_linux.pl /usr/include/sparc64-linux-gnu/asm/unistd.h
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build sparc64,linux
-
-package unix
-
-const (
- SYS_RESTART_SYSCALL = 0
- SYS_EXIT = 1
- SYS_FORK = 2
- SYS_READ = 3
- SYS_WRITE = 4
- SYS_OPEN = 5
- SYS_CLOSE = 6
- SYS_WAIT4 = 7
- SYS_CREAT = 8
- SYS_LINK = 9
- SYS_UNLINK = 10
- SYS_EXECV = 11
- SYS_CHDIR = 12
- SYS_CHOWN = 13
- SYS_MKNOD = 14
- SYS_CHMOD = 15
- SYS_LCHOWN = 16
- SYS_BRK = 17
- SYS_PERFCTR = 18
- SYS_LSEEK = 19
- SYS_GETPID = 20
- SYS_CAPGET = 21
- SYS_CAPSET = 22
- SYS_SETUID = 23
- SYS_GETUID = 24
- SYS_VMSPLICE = 25
- SYS_PTRACE = 26
- SYS_ALARM = 27
- SYS_SIGALTSTACK = 28
- SYS_PAUSE = 29
- SYS_UTIME = 30
- SYS_ACCESS = 33
- SYS_NICE = 34
- SYS_SYNC = 36
- SYS_KILL = 37
- SYS_STAT = 38
- SYS_SENDFILE = 39
- SYS_LSTAT = 40
- SYS_DUP = 41
- SYS_PIPE = 42
- SYS_TIMES = 43
- SYS_UMOUNT2 = 45
- SYS_SETGID = 46
- SYS_GETGID = 47
- SYS_SIGNAL = 48
- SYS_GETEUID = 49
- SYS_GETEGID = 50
- SYS_ACCT = 51
- SYS_MEMORY_ORDERING = 52
- SYS_IOCTL = 54
- SYS_REBOOT = 55
- SYS_SYMLINK = 57
- SYS_READLINK = 58
- SYS_EXECVE = 59
- SYS_UMASK = 60
- SYS_CHROOT = 61
- SYS_FSTAT = 62
- SYS_FSTAT64 = 63
- SYS_GETPAGESIZE = 64
- SYS_MSYNC = 65
- SYS_VFORK = 66
- SYS_PREAD64 = 67
- SYS_PWRITE64 = 68
- SYS_MMAP = 71
- SYS_MUNMAP = 73
- SYS_MPROTECT = 74
- SYS_MADVISE = 75
- SYS_VHANGUP = 76
- SYS_MINCORE = 78
- SYS_GETGROUPS = 79
- SYS_SETGROUPS = 80
- SYS_GETPGRP = 81
- SYS_SETITIMER = 83
- SYS_SWAPON = 85
- SYS_GETITIMER = 86
- SYS_SETHOSTNAME = 88
- SYS_DUP2 = 90
- SYS_FCNTL = 92
- SYS_SELECT = 93
- SYS_FSYNC = 95
- SYS_SETPRIORITY = 96
- SYS_SOCKET = 97
- SYS_CONNECT = 98
- SYS_ACCEPT = 99
- SYS_GETPRIORITY = 100
- SYS_RT_SIGRETURN = 101
- SYS_RT_SIGACTION = 102
- SYS_RT_SIGPROCMASK = 103
- SYS_RT_SIGPENDING = 104
- SYS_RT_SIGTIMEDWAIT = 105
- SYS_RT_SIGQUEUEINFO = 106
- SYS_RT_SIGSUSPEND = 107
- SYS_SETRESUID = 108
- SYS_GETRESUID = 109
- SYS_SETRESGID = 110
- SYS_GETRESGID = 111
- SYS_RECVMSG = 113
- SYS_SENDMSG = 114
- SYS_GETTIMEOFDAY = 116
- SYS_GETRUSAGE = 117
- SYS_GETSOCKOPT = 118
- SYS_GETCWD = 119
- SYS_READV = 120
- SYS_WRITEV = 121
- SYS_SETTIMEOFDAY = 122
- SYS_FCHOWN = 123
- SYS_FCHMOD = 124
- SYS_RECVFROM = 125
- SYS_SETREUID = 126
- SYS_SETREGID = 127
- SYS_RENAME = 128
- SYS_TRUNCATE = 129
- SYS_FTRUNCATE = 130
- SYS_FLOCK = 131
- SYS_LSTAT64 = 132
- SYS_SENDTO = 133
- SYS_SHUTDOWN = 134
- SYS_SOCKETPAIR = 135
- SYS_MKDIR = 136
- SYS_RMDIR = 137
- SYS_UTIMES = 138
- SYS_STAT64 = 139
- SYS_SENDFILE64 = 140
- SYS_GETPEERNAME = 141
- SYS_FUTEX = 142
- SYS_GETTID = 143
- SYS_GETRLIMIT = 144
- SYS_SETRLIMIT = 145
- SYS_PIVOT_ROOT = 146
- SYS_PRCTL = 147
- SYS_PCICONFIG_READ = 148
- SYS_PCICONFIG_WRITE = 149
- SYS_GETSOCKNAME = 150
- SYS_INOTIFY_INIT = 151
- SYS_INOTIFY_ADD_WATCH = 152
- SYS_POLL = 153
- SYS_GETDENTS64 = 154
- SYS_INOTIFY_RM_WATCH = 156
- SYS_STATFS = 157
- SYS_FSTATFS = 158
- SYS_UMOUNT = 159
- SYS_SCHED_SET_AFFINITY = 160
- SYS_SCHED_GET_AFFINITY = 161
- SYS_GETDOMAINNAME = 162
- SYS_SETDOMAINNAME = 163
- SYS_UTRAP_INSTALL = 164
- SYS_QUOTACTL = 165
- SYS_SET_TID_ADDRESS = 166
- SYS_MOUNT = 167
- SYS_USTAT = 168
- SYS_SETXATTR = 169
- SYS_LSETXATTR = 170
- SYS_FSETXATTR = 171
- SYS_GETXATTR = 172
- SYS_LGETXATTR = 173
- SYS_GETDENTS = 174
- SYS_SETSID = 175
- SYS_FCHDIR = 176
- SYS_FGETXATTR = 177
- SYS_LISTXATTR = 178
- SYS_LLISTXATTR = 179
- SYS_FLISTXATTR = 180
- SYS_REMOVEXATTR = 181
- SYS_LREMOVEXATTR = 182
- SYS_SIGPENDING = 183
- SYS_QUERY_MODULE = 184
- SYS_SETPGID = 185
- SYS_FREMOVEXATTR = 186
- SYS_TKILL = 187
- SYS_EXIT_GROUP = 188
- SYS_UNAME = 189
- SYS_INIT_MODULE = 190
- SYS_PERSONALITY = 191
- SYS_REMAP_FILE_PAGES = 192
- SYS_EPOLL_CREATE = 193
- SYS_EPOLL_CTL = 194
- SYS_EPOLL_WAIT = 195
- SYS_IOPRIO_SET = 196
- SYS_GETPPID = 197
- SYS_SIGACTION = 198
- SYS_SGETMASK = 199
- SYS_SSETMASK = 200
- SYS_SIGSUSPEND = 201
- SYS_OLDLSTAT = 202
- SYS_USELIB = 203
- SYS_READDIR = 204
- SYS_READAHEAD = 205
- SYS_SOCKETCALL = 206
- SYS_SYSLOG = 207
- SYS_LOOKUP_DCOOKIE = 208
- SYS_FADVISE64 = 209
- SYS_FADVISE64_64 = 210
- SYS_TGKILL = 211
- SYS_WAITPID = 212
- SYS_SWAPOFF = 213
- SYS_SYSINFO = 214
- SYS_IPC = 215
- SYS_SIGRETURN = 216
- SYS_CLONE = 217
- SYS_IOPRIO_GET = 218
- SYS_ADJTIMEX = 219
- SYS_SIGPROCMASK = 220
- SYS_CREATE_MODULE = 221
- SYS_DELETE_MODULE = 222
- SYS_GET_KERNEL_SYMS = 223
- SYS_GETPGID = 224
- SYS_BDFLUSH = 225
- SYS_SYSFS = 226
- SYS_AFS_SYSCALL = 227
- SYS_SETFSUID = 228
- SYS_SETFSGID = 229
- SYS__NEWSELECT = 230
- SYS_SPLICE = 232
- SYS_STIME = 233
- SYS_STATFS64 = 234
- SYS_FSTATFS64 = 235
- SYS__LLSEEK = 236
- SYS_MLOCK = 237
- SYS_MUNLOCK = 238
- SYS_MLOCKALL = 239
- SYS_MUNLOCKALL = 240
- SYS_SCHED_SETPARAM = 241
- SYS_SCHED_GETPARAM = 242
- SYS_SCHED_SETSCHEDULER = 243
- SYS_SCHED_GETSCHEDULER = 244
- SYS_SCHED_YIELD = 245
- SYS_SCHED_GET_PRIORITY_MAX = 246
- SYS_SCHED_GET_PRIORITY_MIN = 247
- SYS_SCHED_RR_GET_INTERVAL = 248
- SYS_NANOSLEEP = 249
- SYS_MREMAP = 250
- SYS__SYSCTL = 251
- SYS_GETSID = 252
- SYS_FDATASYNC = 253
- SYS_NFSSERVCTL = 254
- SYS_SYNC_FILE_RANGE = 255
- SYS_CLOCK_SETTIME = 256
- SYS_CLOCK_GETTIME = 257
- SYS_CLOCK_GETRES = 258
- SYS_CLOCK_NANOSLEEP = 259
- SYS_SCHED_GETAFFINITY = 260
- SYS_SCHED_SETAFFINITY = 261
- SYS_TIMER_SETTIME = 262
- SYS_TIMER_GETTIME = 263
- SYS_TIMER_GETOVERRUN = 264
- SYS_TIMER_DELETE = 265
- SYS_TIMER_CREATE = 266
- SYS_IO_SETUP = 268
- SYS_IO_DESTROY = 269
- SYS_IO_SUBMIT = 270
- SYS_IO_CANCEL = 271
- SYS_IO_GETEVENTS = 272
- SYS_MQ_OPEN = 273
- SYS_MQ_UNLINK = 274
- SYS_MQ_TIMEDSEND = 275
- SYS_MQ_TIMEDRECEIVE = 276
- SYS_MQ_NOTIFY = 277
- SYS_MQ_GETSETATTR = 278
- SYS_WAITID = 279
- SYS_TEE = 280
- SYS_ADD_KEY = 281
- SYS_REQUEST_KEY = 282
- SYS_KEYCTL = 283
- SYS_OPENAT = 284
- SYS_MKDIRAT = 285
- SYS_MKNODAT = 286
- SYS_FCHOWNAT = 287
- SYS_FUTIMESAT = 288
- SYS_FSTATAT64 = 289
- SYS_UNLINKAT = 290
- SYS_RENAMEAT = 291
- SYS_LINKAT = 292
- SYS_SYMLINKAT = 293
- SYS_READLINKAT = 294
- SYS_FCHMODAT = 295
- SYS_FACCESSAT = 296
- SYS_PSELECT6 = 297
- SYS_PPOLL = 298
- SYS_UNSHARE = 299
- SYS_SET_ROBUST_LIST = 300
- SYS_GET_ROBUST_LIST = 301
- SYS_MIGRATE_PAGES = 302
- SYS_MBIND = 303
- SYS_GET_MEMPOLICY = 304
- SYS_SET_MEMPOLICY = 305
- SYS_KEXEC_LOAD = 306
- SYS_MOVE_PAGES = 307
- SYS_GETCPU = 308
- SYS_EPOLL_PWAIT = 309
- SYS_UTIMENSAT = 310
- SYS_SIGNALFD = 311
- SYS_TIMERFD_CREATE = 312
- SYS_EVENTFD = 313
- SYS_FALLOCATE = 314
- SYS_TIMERFD_SETTIME = 315
- SYS_TIMERFD_GETTIME = 316
- SYS_SIGNALFD4 = 317
- SYS_EVENTFD2 = 318
- SYS_EPOLL_CREATE1 = 319
- SYS_DUP3 = 320
- SYS_PIPE2 = 321
- SYS_INOTIFY_INIT1 = 322
- SYS_ACCEPT4 = 323
- SYS_PREADV = 324
- SYS_PWRITEV = 325
- SYS_RT_TGSIGQUEUEINFO = 326
- SYS_PERF_EVENT_OPEN = 327
- SYS_RECVMMSG = 328
- SYS_FANOTIFY_INIT = 329
- SYS_FANOTIFY_MARK = 330
- SYS_PRLIMIT64 = 331
- SYS_NAME_TO_HANDLE_AT = 332
- SYS_OPEN_BY_HANDLE_AT = 333
- SYS_CLOCK_ADJTIME = 334
- SYS_SYNCFS = 335
- SYS_SENDMMSG = 336
- SYS_SETNS = 337
- SYS_PROCESS_VM_READV = 338
- SYS_PROCESS_VM_WRITEV = 339
- SYS_KERN_FEATURES = 340
- SYS_KCMP = 341
- SYS_FINIT_MODULE = 342
- SYS_SCHED_SETATTR = 343
- SYS_SCHED_GETATTR = 344
- SYS_RENAMEAT2 = 345
- SYS_SECCOMP = 346
- SYS_GETRANDOM = 347
- SYS_MEMFD_CREATE = 348
- SYS_BPF = 349
- SYS_EXECVEAT = 350
- SYS_MEMBARRIER = 351
- SYS_USERFAULTFD = 352
- SYS_BIND = 353
- SYS_LISTEN = 354
- SYS_SETSOCKOPT = 355
- SYS_MLOCK2 = 356
- SYS_COPY_FILE_RANGE = 357
- SYS_PREADV2 = 358
- SYS_PWRITEV2 = 359
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go
deleted file mode 100644
index f60d8f98..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go
+++ /dev/null
@@ -1,273 +0,0 @@
-// mksysnum_netbsd.pl
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build 386,netbsd
-
-package unix
-
-const (
- SYS_EXIT = 1 // { void|sys||exit(int rval); }
- SYS_FORK = 2 // { int|sys||fork(void); }
- SYS_READ = 3 // { ssize_t|sys||read(int fd, void *buf, size_t nbyte); }
- SYS_WRITE = 4 // { ssize_t|sys||write(int fd, const void *buf, size_t nbyte); }
- SYS_OPEN = 5 // { int|sys||open(const char *path, int flags, ... mode_t mode); }
- SYS_CLOSE = 6 // { int|sys||close(int fd); }
- SYS_LINK = 9 // { int|sys||link(const char *path, const char *link); }
- SYS_UNLINK = 10 // { int|sys||unlink(const char *path); }
- SYS_CHDIR = 12 // { int|sys||chdir(const char *path); }
- SYS_FCHDIR = 13 // { int|sys||fchdir(int fd); }
- SYS_CHMOD = 15 // { int|sys||chmod(const char *path, mode_t mode); }
- SYS_CHOWN = 16 // { int|sys||chown(const char *path, uid_t uid, gid_t gid); }
- SYS_BREAK = 17 // { int|sys||obreak(char *nsize); }
- SYS_GETPID = 20 // { pid_t|sys||getpid_with_ppid(void); }
- SYS_UNMOUNT = 22 // { int|sys||unmount(const char *path, int flags); }
- SYS_SETUID = 23 // { int|sys||setuid(uid_t uid); }
- SYS_GETUID = 24 // { uid_t|sys||getuid_with_euid(void); }
- SYS_GETEUID = 25 // { uid_t|sys||geteuid(void); }
- SYS_PTRACE = 26 // { int|sys||ptrace(int req, pid_t pid, void *addr, int data); }
- SYS_RECVMSG = 27 // { ssize_t|sys||recvmsg(int s, struct msghdr *msg, int flags); }
- SYS_SENDMSG = 28 // { ssize_t|sys||sendmsg(int s, const struct msghdr *msg, int flags); }
- SYS_RECVFROM = 29 // { ssize_t|sys||recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlenaddr); }
- SYS_ACCEPT = 30 // { int|sys||accept(int s, struct sockaddr *name, socklen_t *anamelen); }
- SYS_GETPEERNAME = 31 // { int|sys||getpeername(int fdes, struct sockaddr *asa, socklen_t *alen); }
- SYS_GETSOCKNAME = 32 // { int|sys||getsockname(int fdes, struct sockaddr *asa, socklen_t *alen); }
- SYS_ACCESS = 33 // { int|sys||access(const char *path, int flags); }
- SYS_CHFLAGS = 34 // { int|sys||chflags(const char *path, u_long flags); }
- SYS_FCHFLAGS = 35 // { int|sys||fchflags(int fd, u_long flags); }
- SYS_SYNC = 36 // { void|sys||sync(void); }
- SYS_KILL = 37 // { int|sys||kill(pid_t pid, int signum); }
- SYS_GETPPID = 39 // { pid_t|sys||getppid(void); }
- SYS_DUP = 41 // { int|sys||dup(int fd); }
- SYS_PIPE = 42 // { int|sys||pipe(void); }
- SYS_GETEGID = 43 // { gid_t|sys||getegid(void); }
- SYS_PROFIL = 44 // { int|sys||profil(char *samples, size_t size, u_long offset, u_int scale); }
- SYS_KTRACE = 45 // { int|sys||ktrace(const char *fname, int ops, int facs, pid_t pid); }
- SYS_GETGID = 47 // { gid_t|sys||getgid_with_egid(void); }
- SYS___GETLOGIN = 49 // { int|sys||__getlogin(char *namebuf, size_t namelen); }
- SYS___SETLOGIN = 50 // { int|sys||__setlogin(const char *namebuf); }
- SYS_ACCT = 51 // { int|sys||acct(const char *path); }
- SYS_IOCTL = 54 // { int|sys||ioctl(int fd, u_long com, ... void *data); }
- SYS_REVOKE = 56 // { int|sys||revoke(const char *path); }
- SYS_SYMLINK = 57 // { int|sys||symlink(const char *path, const char *link); }
- SYS_READLINK = 58 // { ssize_t|sys||readlink(const char *path, char *buf, size_t count); }
- SYS_EXECVE = 59 // { int|sys||execve(const char *path, char * const *argp, char * const *envp); }
- SYS_UMASK = 60 // { mode_t|sys||umask(mode_t newmask); }
- SYS_CHROOT = 61 // { int|sys||chroot(const char *path); }
- SYS_VFORK = 66 // { int|sys||vfork(void); }
- SYS_SBRK = 69 // { int|sys||sbrk(intptr_t incr); }
- SYS_SSTK = 70 // { int|sys||sstk(int incr); }
- SYS_VADVISE = 72 // { int|sys||ovadvise(int anom); }
- SYS_MUNMAP = 73 // { int|sys||munmap(void *addr, size_t len); }
- SYS_MPROTECT = 74 // { int|sys||mprotect(void *addr, size_t len, int prot); }
- SYS_MADVISE = 75 // { int|sys||madvise(void *addr, size_t len, int behav); }
- SYS_MINCORE = 78 // { int|sys||mincore(void *addr, size_t len, char *vec); }
- SYS_GETGROUPS = 79 // { int|sys||getgroups(int gidsetsize, gid_t *gidset); }
- SYS_SETGROUPS = 80 // { int|sys||setgroups(int gidsetsize, const gid_t *gidset); }
- SYS_GETPGRP = 81 // { int|sys||getpgrp(void); }
- SYS_SETPGID = 82 // { int|sys||setpgid(pid_t pid, pid_t pgid); }
- SYS_DUP2 = 90 // { int|sys||dup2(int from, int to); }
- SYS_FCNTL = 92 // { int|sys||fcntl(int fd, int cmd, ... void *arg); }
- SYS_FSYNC = 95 // { int|sys||fsync(int fd); }
- SYS_SETPRIORITY = 96 // { int|sys||setpriority(int which, id_t who, int prio); }
- SYS_CONNECT = 98 // { int|sys||connect(int s, const struct sockaddr *name, socklen_t namelen); }
- SYS_GETPRIORITY = 100 // { int|sys||getpriority(int which, id_t who); }
- SYS_BIND = 104 // { int|sys||bind(int s, const struct sockaddr *name, socklen_t namelen); }
- SYS_SETSOCKOPT = 105 // { int|sys||setsockopt(int s, int level, int name, const void *val, socklen_t valsize); }
- SYS_LISTEN = 106 // { int|sys||listen(int s, int backlog); }
- SYS_GETSOCKOPT = 118 // { int|sys||getsockopt(int s, int level, int name, void *val, socklen_t *avalsize); }
- SYS_READV = 120 // { ssize_t|sys||readv(int fd, const struct iovec *iovp, int iovcnt); }
- SYS_WRITEV = 121 // { ssize_t|sys||writev(int fd, const struct iovec *iovp, int iovcnt); }
- SYS_FCHOWN = 123 // { int|sys||fchown(int fd, uid_t uid, gid_t gid); }
- SYS_FCHMOD = 124 // { int|sys||fchmod(int fd, mode_t mode); }
- SYS_SETREUID = 126 // { int|sys||setreuid(uid_t ruid, uid_t euid); }
- SYS_SETREGID = 127 // { int|sys||setregid(gid_t rgid, gid_t egid); }
- SYS_RENAME = 128 // { int|sys||rename(const char *from, const char *to); }
- SYS_FLOCK = 131 // { int|sys||flock(int fd, int how); }
- SYS_MKFIFO = 132 // { int|sys||mkfifo(const char *path, mode_t mode); }
- SYS_SENDTO = 133 // { ssize_t|sys||sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); }
- SYS_SHUTDOWN = 134 // { int|sys||shutdown(int s, int how); }
- SYS_SOCKETPAIR = 135 // { int|sys||socketpair(int domain, int type, int protocol, int *rsv); }
- SYS_MKDIR = 136 // { int|sys||mkdir(const char *path, mode_t mode); }
- SYS_RMDIR = 137 // { int|sys||rmdir(const char *path); }
- SYS_SETSID = 147 // { int|sys||setsid(void); }
- SYS_SYSARCH = 165 // { int|sys||sysarch(int op, void *parms); }
- SYS_PREAD = 173 // { ssize_t|sys||pread(int fd, void *buf, size_t nbyte, int PAD, off_t offset); }
- SYS_PWRITE = 174 // { ssize_t|sys||pwrite(int fd, const void *buf, size_t nbyte, int PAD, off_t offset); }
- SYS_NTP_ADJTIME = 176 // { int|sys||ntp_adjtime(struct timex *tp); }
- SYS_SETGID = 181 // { int|sys||setgid(gid_t gid); }
- SYS_SETEGID = 182 // { int|sys||setegid(gid_t egid); }
- SYS_SETEUID = 183 // { int|sys||seteuid(uid_t euid); }
- SYS_PATHCONF = 191 // { long|sys||pathconf(const char *path, int name); }
- SYS_FPATHCONF = 192 // { long|sys||fpathconf(int fd, int name); }
- SYS_GETRLIMIT = 194 // { int|sys||getrlimit(int which, struct rlimit *rlp); }
- SYS_SETRLIMIT = 195 // { int|sys||setrlimit(int which, const struct rlimit *rlp); }
- SYS_MMAP = 197 // { void *|sys||mmap(void *addr, size_t len, int prot, int flags, int fd, long PAD, off_t pos); }
- SYS_LSEEK = 199 // { off_t|sys||lseek(int fd, int PAD, off_t offset, int whence); }
- SYS_TRUNCATE = 200 // { int|sys||truncate(const char *path, int PAD, off_t length); }
- SYS_FTRUNCATE = 201 // { int|sys||ftruncate(int fd, int PAD, off_t length); }
- SYS___SYSCTL = 202 // { int|sys||__sysctl(const int *name, u_int namelen, void *old, size_t *oldlenp, const void *new, size_t newlen); }
- SYS_MLOCK = 203 // { int|sys||mlock(const void *addr, size_t len); }
- SYS_MUNLOCK = 204 // { int|sys||munlock(const void *addr, size_t len); }
- SYS_UNDELETE = 205 // { int|sys||undelete(const char *path); }
- SYS_GETPGID = 207 // { pid_t|sys||getpgid(pid_t pid); }
- SYS_REBOOT = 208 // { int|sys||reboot(int opt, char *bootstr); }
- SYS_POLL = 209 // { int|sys||poll(struct pollfd *fds, u_int nfds, int timeout); }
- SYS_SEMGET = 221 // { int|sys||semget(key_t key, int nsems, int semflg); }
- SYS_SEMOP = 222 // { int|sys||semop(int semid, struct sembuf *sops, size_t nsops); }
- SYS_SEMCONFIG = 223 // { int|sys||semconfig(int flag); }
- SYS_MSGGET = 225 // { int|sys||msgget(key_t key, int msgflg); }
- SYS_MSGSND = 226 // { int|sys||msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg); }
- SYS_MSGRCV = 227 // { ssize_t|sys||msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); }
- SYS_SHMAT = 228 // { void *|sys||shmat(int shmid, const void *shmaddr, int shmflg); }
- SYS_SHMDT = 230 // { int|sys||shmdt(const void *shmaddr); }
- SYS_SHMGET = 231 // { int|sys||shmget(key_t key, size_t size, int shmflg); }
- SYS_TIMER_CREATE = 235 // { int|sys||timer_create(clockid_t clock_id, struct sigevent *evp, timer_t *timerid); }
- SYS_TIMER_DELETE = 236 // { int|sys||timer_delete(timer_t timerid); }
- SYS_TIMER_GETOVERRUN = 239 // { int|sys||timer_getoverrun(timer_t timerid); }
- SYS_FDATASYNC = 241 // { int|sys||fdatasync(int fd); }
- SYS_MLOCKALL = 242 // { int|sys||mlockall(int flags); }
- SYS_MUNLOCKALL = 243 // { int|sys||munlockall(void); }
- SYS_SIGQUEUEINFO = 245 // { int|sys||sigqueueinfo(pid_t pid, const siginfo_t *info); }
- SYS_MODCTL = 246 // { int|sys||modctl(int cmd, void *arg); }
- SYS___POSIX_RENAME = 270 // { int|sys||__posix_rename(const char *from, const char *to); }
- SYS_SWAPCTL = 271 // { int|sys||swapctl(int cmd, void *arg, int misc); }
- SYS_MINHERIT = 273 // { int|sys||minherit(void *addr, size_t len, int inherit); }
- SYS_LCHMOD = 274 // { int|sys||lchmod(const char *path, mode_t mode); }
- SYS_LCHOWN = 275 // { int|sys||lchown(const char *path, uid_t uid, gid_t gid); }
- SYS___POSIX_CHOWN = 283 // { int|sys||__posix_chown(const char *path, uid_t uid, gid_t gid); }
- SYS___POSIX_FCHOWN = 284 // { int|sys||__posix_fchown(int fd, uid_t uid, gid_t gid); }
- SYS___POSIX_LCHOWN = 285 // { int|sys||__posix_lchown(const char *path, uid_t uid, gid_t gid); }
- SYS_GETSID = 286 // { pid_t|sys||getsid(pid_t pid); }
- SYS___CLONE = 287 // { pid_t|sys||__clone(int flags, void *stack); }
- SYS_FKTRACE = 288 // { int|sys||fktrace(int fd, int ops, int facs, pid_t pid); }
- SYS_PREADV = 289 // { ssize_t|sys||preadv(int fd, const struct iovec *iovp, int iovcnt, int PAD, off_t offset); }
- SYS_PWRITEV = 290 // { ssize_t|sys||pwritev(int fd, const struct iovec *iovp, int iovcnt, int PAD, off_t offset); }
- SYS___GETCWD = 296 // { int|sys||__getcwd(char *bufp, size_t length); }
- SYS_FCHROOT = 297 // { int|sys||fchroot(int fd); }
- SYS_LCHFLAGS = 304 // { int|sys||lchflags(const char *path, u_long flags); }
- SYS_ISSETUGID = 305 // { int|sys||issetugid(void); }
- SYS_UTRACE = 306 // { int|sys||utrace(const char *label, void *addr, size_t len); }
- SYS_GETCONTEXT = 307 // { int|sys||getcontext(struct __ucontext *ucp); }
- SYS_SETCONTEXT = 308 // { int|sys||setcontext(const struct __ucontext *ucp); }
- SYS__LWP_CREATE = 309 // { int|sys||_lwp_create(const struct __ucontext *ucp, u_long flags, lwpid_t *new_lwp); }
- SYS__LWP_EXIT = 310 // { int|sys||_lwp_exit(void); }
- SYS__LWP_SELF = 311 // { lwpid_t|sys||_lwp_self(void); }
- SYS__LWP_WAIT = 312 // { int|sys||_lwp_wait(lwpid_t wait_for, lwpid_t *departed); }
- SYS__LWP_SUSPEND = 313 // { int|sys||_lwp_suspend(lwpid_t target); }
- SYS__LWP_CONTINUE = 314 // { int|sys||_lwp_continue(lwpid_t target); }
- SYS__LWP_WAKEUP = 315 // { int|sys||_lwp_wakeup(lwpid_t target); }
- SYS__LWP_GETPRIVATE = 316 // { void *|sys||_lwp_getprivate(void); }
- SYS__LWP_SETPRIVATE = 317 // { void|sys||_lwp_setprivate(void *ptr); }
- SYS__LWP_KILL = 318 // { int|sys||_lwp_kill(lwpid_t target, int signo); }
- SYS__LWP_DETACH = 319 // { int|sys||_lwp_detach(lwpid_t target); }
- SYS__LWP_UNPARK = 321 // { int|sys||_lwp_unpark(lwpid_t target, const void *hint); }
- SYS__LWP_UNPARK_ALL = 322 // { ssize_t|sys||_lwp_unpark_all(const lwpid_t *targets, size_t ntargets, const void *hint); }
- SYS__LWP_SETNAME = 323 // { int|sys||_lwp_setname(lwpid_t target, const char *name); }
- SYS__LWP_GETNAME = 324 // { int|sys||_lwp_getname(lwpid_t target, char *name, size_t len); }
- SYS__LWP_CTL = 325 // { int|sys||_lwp_ctl(int features, struct lwpctl **address); }
- SYS___SIGACTION_SIGTRAMP = 340 // { int|sys||__sigaction_sigtramp(int signum, const struct sigaction *nsa, struct sigaction *osa, const void *tramp, int vers); }
- SYS_PMC_GET_INFO = 341 // { int|sys||pmc_get_info(int ctr, int op, void *args); }
- SYS_PMC_CONTROL = 342 // { int|sys||pmc_control(int ctr, int op, void *args); }
- SYS_RASCTL = 343 // { int|sys||rasctl(void *addr, size_t len, int op); }
- SYS_KQUEUE = 344 // { int|sys||kqueue(void); }
- SYS__SCHED_SETPARAM = 346 // { int|sys||_sched_setparam(pid_t pid, lwpid_t lid, int policy, const struct sched_param *params); }
- SYS__SCHED_GETPARAM = 347 // { int|sys||_sched_getparam(pid_t pid, lwpid_t lid, int *policy, struct sched_param *params); }
- SYS__SCHED_SETAFFINITY = 348 // { int|sys||_sched_setaffinity(pid_t pid, lwpid_t lid, size_t size, const cpuset_t *cpuset); }
- SYS__SCHED_GETAFFINITY = 349 // { int|sys||_sched_getaffinity(pid_t pid, lwpid_t lid, size_t size, cpuset_t *cpuset); }
- SYS_SCHED_YIELD = 350 // { int|sys||sched_yield(void); }
- SYS_FSYNC_RANGE = 354 // { int|sys||fsync_range(int fd, int flags, off_t start, off_t length); }
- SYS_UUIDGEN = 355 // { int|sys||uuidgen(struct uuid *store, int count); }
- SYS_GETVFSSTAT = 356 // { int|sys||getvfsstat(struct statvfs *buf, size_t bufsize, int flags); }
- SYS_STATVFS1 = 357 // { int|sys||statvfs1(const char *path, struct statvfs *buf, int flags); }
- SYS_FSTATVFS1 = 358 // { int|sys||fstatvfs1(int fd, struct statvfs *buf, int flags); }
- SYS_EXTATTRCTL = 360 // { int|sys||extattrctl(const char *path, int cmd, const char *filename, int attrnamespace, const char *attrname); }
- SYS_EXTATTR_SET_FILE = 361 // { int|sys||extattr_set_file(const char *path, int attrnamespace, const char *attrname, const void *data, size_t nbytes); }
- SYS_EXTATTR_GET_FILE = 362 // { ssize_t|sys||extattr_get_file(const char *path, int attrnamespace, const char *attrname, void *data, size_t nbytes); }
- SYS_EXTATTR_DELETE_FILE = 363 // { int|sys||extattr_delete_file(const char *path, int attrnamespace, const char *attrname); }
- SYS_EXTATTR_SET_FD = 364 // { int|sys||extattr_set_fd(int fd, int attrnamespace, const char *attrname, const void *data, size_t nbytes); }
- SYS_EXTATTR_GET_FD = 365 // { ssize_t|sys||extattr_get_fd(int fd, int attrnamespace, const char *attrname, void *data, size_t nbytes); }
- SYS_EXTATTR_DELETE_FD = 366 // { int|sys||extattr_delete_fd(int fd, int attrnamespace, const char *attrname); }
- SYS_EXTATTR_SET_LINK = 367 // { int|sys||extattr_set_link(const char *path, int attrnamespace, const char *attrname, const void *data, size_t nbytes); }
- SYS_EXTATTR_GET_LINK = 368 // { ssize_t|sys||extattr_get_link(const char *path, int attrnamespace, const char *attrname, void *data, size_t nbytes); }
- SYS_EXTATTR_DELETE_LINK = 369 // { int|sys||extattr_delete_link(const char *path, int attrnamespace, const char *attrname); }
- SYS_EXTATTR_LIST_FD = 370 // { ssize_t|sys||extattr_list_fd(int fd, int attrnamespace, void *data, size_t nbytes); }
- SYS_EXTATTR_LIST_FILE = 371 // { ssize_t|sys||extattr_list_file(const char *path, int attrnamespace, void *data, size_t nbytes); }
- SYS_EXTATTR_LIST_LINK = 372 // { ssize_t|sys||extattr_list_link(const char *path, int attrnamespace, void *data, size_t nbytes); }
- SYS_SETXATTR = 375 // { int|sys||setxattr(const char *path, const char *name, const void *value, size_t size, int flags); }
- SYS_LSETXATTR = 376 // { int|sys||lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags); }
- SYS_FSETXATTR = 377 // { int|sys||fsetxattr(int fd, const char *name, const void *value, size_t size, int flags); }
- SYS_GETXATTR = 378 // { int|sys||getxattr(const char *path, const char *name, void *value, size_t size); }
- SYS_LGETXATTR = 379 // { int|sys||lgetxattr(const char *path, const char *name, void *value, size_t size); }
- SYS_FGETXATTR = 380 // { int|sys||fgetxattr(int fd, const char *name, void *value, size_t size); }
- SYS_LISTXATTR = 381 // { int|sys||listxattr(const char *path, char *list, size_t size); }
- SYS_LLISTXATTR = 382 // { int|sys||llistxattr(const char *path, char *list, size_t size); }
- SYS_FLISTXATTR = 383 // { int|sys||flistxattr(int fd, char *list, size_t size); }
- SYS_REMOVEXATTR = 384 // { int|sys||removexattr(const char *path, const char *name); }
- SYS_LREMOVEXATTR = 385 // { int|sys||lremovexattr(const char *path, const char *name); }
- SYS_FREMOVEXATTR = 386 // { int|sys||fremovexattr(int fd, const char *name); }
- SYS_GETDENTS = 390 // { int|sys|30|getdents(int fd, char *buf, size_t count); }
- SYS_SOCKET = 394 // { int|sys|30|socket(int domain, int type, int protocol); }
- SYS_GETFH = 395 // { int|sys|30|getfh(const char *fname, void *fhp, size_t *fh_size); }
- SYS_MOUNT = 410 // { int|sys|50|mount(const char *type, const char *path, int flags, void *data, size_t data_len); }
- SYS_MREMAP = 411 // { void *|sys||mremap(void *old_address, size_t old_size, void *new_address, size_t new_size, int flags); }
- SYS_PSET_CREATE = 412 // { int|sys||pset_create(psetid_t *psid); }
- SYS_PSET_DESTROY = 413 // { int|sys||pset_destroy(psetid_t psid); }
- SYS_PSET_ASSIGN = 414 // { int|sys||pset_assign(psetid_t psid, cpuid_t cpuid, psetid_t *opsid); }
- SYS__PSET_BIND = 415 // { int|sys||_pset_bind(idtype_t idtype, id_t first_id, id_t second_id, psetid_t psid, psetid_t *opsid); }
- SYS_POSIX_FADVISE = 416 // { int|sys|50|posix_fadvise(int fd, int PAD, off_t offset, off_t len, int advice); }
- SYS_SELECT = 417 // { int|sys|50|select(int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timeval *tv); }
- SYS_GETTIMEOFDAY = 418 // { int|sys|50|gettimeofday(struct timeval *tp, void *tzp); }
- SYS_SETTIMEOFDAY = 419 // { int|sys|50|settimeofday(const struct timeval *tv, const void *tzp); }
- SYS_UTIMES = 420 // { int|sys|50|utimes(const char *path, const struct timeval *tptr); }
- SYS_ADJTIME = 421 // { int|sys|50|adjtime(const struct timeval *delta, struct timeval *olddelta); }
- SYS_FUTIMES = 423 // { int|sys|50|futimes(int fd, const struct timeval *tptr); }
- SYS_LUTIMES = 424 // { int|sys|50|lutimes(const char *path, const struct timeval *tptr); }
- SYS_SETITIMER = 425 // { int|sys|50|setitimer(int which, const struct itimerval *itv, struct itimerval *oitv); }
- SYS_GETITIMER = 426 // { int|sys|50|getitimer(int which, struct itimerval *itv); }
- SYS_CLOCK_GETTIME = 427 // { int|sys|50|clock_gettime(clockid_t clock_id, struct timespec *tp); }
- SYS_CLOCK_SETTIME = 428 // { int|sys|50|clock_settime(clockid_t clock_id, const struct timespec *tp); }
- SYS_CLOCK_GETRES = 429 // { int|sys|50|clock_getres(clockid_t clock_id, struct timespec *tp); }
- SYS_NANOSLEEP = 430 // { int|sys|50|nanosleep(const struct timespec *rqtp, struct timespec *rmtp); }
- SYS___SIGTIMEDWAIT = 431 // { int|sys|50|__sigtimedwait(const sigset_t *set, siginfo_t *info, struct timespec *timeout); }
- SYS__LWP_PARK = 434 // { int|sys|50|_lwp_park(const struct timespec *ts, lwpid_t unpark, const void *hint, const void *unparkhint); }
- SYS_KEVENT = 435 // { int|sys|50|kevent(int fd, const struct kevent *changelist, size_t nchanges, struct kevent *eventlist, size_t nevents, const struct timespec *timeout); }
- SYS_PSELECT = 436 // { int|sys|50|pselect(int nd, fd_set *in, fd_set *ou, fd_set *ex, const struct timespec *ts, const sigset_t *mask); }
- SYS_POLLTS = 437 // { int|sys|50|pollts(struct pollfd *fds, u_int nfds, const struct timespec *ts, const sigset_t *mask); }
- SYS_STAT = 439 // { int|sys|50|stat(const char *path, struct stat *ub); }
- SYS_FSTAT = 440 // { int|sys|50|fstat(int fd, struct stat *sb); }
- SYS_LSTAT = 441 // { int|sys|50|lstat(const char *path, struct stat *ub); }
- SYS___SEMCTL = 442 // { int|sys|50|__semctl(int semid, int semnum, int cmd, ... union __semun *arg); }
- SYS_SHMCTL = 443 // { int|sys|50|shmctl(int shmid, int cmd, struct shmid_ds *buf); }
- SYS_MSGCTL = 444 // { int|sys|50|msgctl(int msqid, int cmd, struct msqid_ds *buf); }
- SYS_GETRUSAGE = 445 // { int|sys|50|getrusage(int who, struct rusage *rusage); }
- SYS_TIMER_SETTIME = 446 // { int|sys|50|timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue); }
- SYS_TIMER_GETTIME = 447 // { int|sys|50|timer_gettime(timer_t timerid, struct itimerspec *value); }
- SYS_NTP_GETTIME = 448 // { int|sys|50|ntp_gettime(struct ntptimeval *ntvp); }
- SYS_WAIT4 = 449 // { int|sys|50|wait4(pid_t pid, int *status, int options, struct rusage *rusage); }
- SYS_MKNOD = 450 // { int|sys|50|mknod(const char *path, mode_t mode, dev_t dev); }
- SYS_FHSTAT = 451 // { int|sys|50|fhstat(const void *fhp, size_t fh_size, struct stat *sb); }
- SYS_PIPE2 = 453 // { int|sys||pipe2(int *fildes, int flags); }
- SYS_DUP3 = 454 // { int|sys||dup3(int from, int to, int flags); }
- SYS_KQUEUE1 = 455 // { int|sys||kqueue1(int flags); }
- SYS_PACCEPT = 456 // { int|sys||paccept(int s, struct sockaddr *name, socklen_t *anamelen, const sigset_t *mask, int flags); }
- SYS_LINKAT = 457 // { int|sys||linkat(int fd1, const char *name1, int fd2, const char *name2, int flags); }
- SYS_RENAMEAT = 458 // { int|sys||renameat(int fromfd, const char *from, int tofd, const char *to); }
- SYS_MKFIFOAT = 459 // { int|sys||mkfifoat(int fd, const char *path, mode_t mode); }
- SYS_MKNODAT = 460 // { int|sys||mknodat(int fd, const char *path, mode_t mode, uint32_t dev); }
- SYS_MKDIRAT = 461 // { int|sys||mkdirat(int fd, const char *path, mode_t mode); }
- SYS_FACCESSAT = 462 // { int|sys||faccessat(int fd, const char *path, int amode, int flag); }
- SYS_FCHMODAT = 463 // { int|sys||fchmodat(int fd, const char *path, mode_t mode, int flag); }
- SYS_FCHOWNAT = 464 // { int|sys||fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag); }
- SYS_FEXECVE = 465 // { int|sys||fexecve(int fd, char * const *argp, char * const *envp); }
- SYS_FSTATAT = 466 // { int|sys||fstatat(int fd, const char *path, struct stat *buf, int flag); }
- SYS_UTIMENSAT = 467 // { int|sys||utimensat(int fd, const char *path, const struct timespec *tptr, int flag); }
- SYS_OPENAT = 468 // { int|sys||openat(int fd, const char *path, int oflags, ... mode_t mode); }
- SYS_READLINKAT = 469 // { int|sys||readlinkat(int fd, const char *path, char *buf, size_t bufsize); }
- SYS_SYMLINKAT = 470 // { int|sys||symlinkat(const char *path1, int fd, const char *path2); }
- SYS_UNLINKAT = 471 // { int|sys||unlinkat(int fd, const char *path, int flag); }
- SYS_FUTIMENS = 472 // { int|sys||futimens(int fd, const struct timespec *tptr); }
- SYS___QUOTACTL = 473 // { int|sys||__quotactl(const char *path, struct quotactl_args *args); }
- SYS_POSIX_SPAWN = 474 // { int|sys||posix_spawn(pid_t *pid, const char *path, const struct posix_spawn_file_actions *file_actions, const struct posix_spawnattr *attrp, char *const *argv, char *const *envp); }
- SYS_RECVMMSG = 475 // { int|sys||recvmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags, struct timespec *timeout); }
- SYS_SENDMMSG = 476 // { int|sys||sendmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags); }
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go
deleted file mode 100644
index 48a91d46..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go
+++ /dev/null
@@ -1,273 +0,0 @@
-// mksysnum_netbsd.pl
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build amd64,netbsd
-
-package unix
-
-const (
- SYS_EXIT = 1 // { void|sys||exit(int rval); }
- SYS_FORK = 2 // { int|sys||fork(void); }
- SYS_READ = 3 // { ssize_t|sys||read(int fd, void *buf, size_t nbyte); }
- SYS_WRITE = 4 // { ssize_t|sys||write(int fd, const void *buf, size_t nbyte); }
- SYS_OPEN = 5 // { int|sys||open(const char *path, int flags, ... mode_t mode); }
- SYS_CLOSE = 6 // { int|sys||close(int fd); }
- SYS_LINK = 9 // { int|sys||link(const char *path, const char *link); }
- SYS_UNLINK = 10 // { int|sys||unlink(const char *path); }
- SYS_CHDIR = 12 // { int|sys||chdir(const char *path); }
- SYS_FCHDIR = 13 // { int|sys||fchdir(int fd); }
- SYS_CHMOD = 15 // { int|sys||chmod(const char *path, mode_t mode); }
- SYS_CHOWN = 16 // { int|sys||chown(const char *path, uid_t uid, gid_t gid); }
- SYS_BREAK = 17 // { int|sys||obreak(char *nsize); }
- SYS_GETPID = 20 // { pid_t|sys||getpid_with_ppid(void); }
- SYS_UNMOUNT = 22 // { int|sys||unmount(const char *path, int flags); }
- SYS_SETUID = 23 // { int|sys||setuid(uid_t uid); }
- SYS_GETUID = 24 // { uid_t|sys||getuid_with_euid(void); }
- SYS_GETEUID = 25 // { uid_t|sys||geteuid(void); }
- SYS_PTRACE = 26 // { int|sys||ptrace(int req, pid_t pid, void *addr, int data); }
- SYS_RECVMSG = 27 // { ssize_t|sys||recvmsg(int s, struct msghdr *msg, int flags); }
- SYS_SENDMSG = 28 // { ssize_t|sys||sendmsg(int s, const struct msghdr *msg, int flags); }
- SYS_RECVFROM = 29 // { ssize_t|sys||recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlenaddr); }
- SYS_ACCEPT = 30 // { int|sys||accept(int s, struct sockaddr *name, socklen_t *anamelen); }
- SYS_GETPEERNAME = 31 // { int|sys||getpeername(int fdes, struct sockaddr *asa, socklen_t *alen); }
- SYS_GETSOCKNAME = 32 // { int|sys||getsockname(int fdes, struct sockaddr *asa, socklen_t *alen); }
- SYS_ACCESS = 33 // { int|sys||access(const char *path, int flags); }
- SYS_CHFLAGS = 34 // { int|sys||chflags(const char *path, u_long flags); }
- SYS_FCHFLAGS = 35 // { int|sys||fchflags(int fd, u_long flags); }
- SYS_SYNC = 36 // { void|sys||sync(void); }
- SYS_KILL = 37 // { int|sys||kill(pid_t pid, int signum); }
- SYS_GETPPID = 39 // { pid_t|sys||getppid(void); }
- SYS_DUP = 41 // { int|sys||dup(int fd); }
- SYS_PIPE = 42 // { int|sys||pipe(void); }
- SYS_GETEGID = 43 // { gid_t|sys||getegid(void); }
- SYS_PROFIL = 44 // { int|sys||profil(char *samples, size_t size, u_long offset, u_int scale); }
- SYS_KTRACE = 45 // { int|sys||ktrace(const char *fname, int ops, int facs, pid_t pid); }
- SYS_GETGID = 47 // { gid_t|sys||getgid_with_egid(void); }
- SYS___GETLOGIN = 49 // { int|sys||__getlogin(char *namebuf, size_t namelen); }
- SYS___SETLOGIN = 50 // { int|sys||__setlogin(const char *namebuf); }
- SYS_ACCT = 51 // { int|sys||acct(const char *path); }
- SYS_IOCTL = 54 // { int|sys||ioctl(int fd, u_long com, ... void *data); }
- SYS_REVOKE = 56 // { int|sys||revoke(const char *path); }
- SYS_SYMLINK = 57 // { int|sys||symlink(const char *path, const char *link); }
- SYS_READLINK = 58 // { ssize_t|sys||readlink(const char *path, char *buf, size_t count); }
- SYS_EXECVE = 59 // { int|sys||execve(const char *path, char * const *argp, char * const *envp); }
- SYS_UMASK = 60 // { mode_t|sys||umask(mode_t newmask); }
- SYS_CHROOT = 61 // { int|sys||chroot(const char *path); }
- SYS_VFORK = 66 // { int|sys||vfork(void); }
- SYS_SBRK = 69 // { int|sys||sbrk(intptr_t incr); }
- SYS_SSTK = 70 // { int|sys||sstk(int incr); }
- SYS_VADVISE = 72 // { int|sys||ovadvise(int anom); }
- SYS_MUNMAP = 73 // { int|sys||munmap(void *addr, size_t len); }
- SYS_MPROTECT = 74 // { int|sys||mprotect(void *addr, size_t len, int prot); }
- SYS_MADVISE = 75 // { int|sys||madvise(void *addr, size_t len, int behav); }
- SYS_MINCORE = 78 // { int|sys||mincore(void *addr, size_t len, char *vec); }
- SYS_GETGROUPS = 79 // { int|sys||getgroups(int gidsetsize, gid_t *gidset); }
- SYS_SETGROUPS = 80 // { int|sys||setgroups(int gidsetsize, const gid_t *gidset); }
- SYS_GETPGRP = 81 // { int|sys||getpgrp(void); }
- SYS_SETPGID = 82 // { int|sys||setpgid(pid_t pid, pid_t pgid); }
- SYS_DUP2 = 90 // { int|sys||dup2(int from, int to); }
- SYS_FCNTL = 92 // { int|sys||fcntl(int fd, int cmd, ... void *arg); }
- SYS_FSYNC = 95 // { int|sys||fsync(int fd); }
- SYS_SETPRIORITY = 96 // { int|sys||setpriority(int which, id_t who, int prio); }
- SYS_CONNECT = 98 // { int|sys||connect(int s, const struct sockaddr *name, socklen_t namelen); }
- SYS_GETPRIORITY = 100 // { int|sys||getpriority(int which, id_t who); }
- SYS_BIND = 104 // { int|sys||bind(int s, const struct sockaddr *name, socklen_t namelen); }
- SYS_SETSOCKOPT = 105 // { int|sys||setsockopt(int s, int level, int name, const void *val, socklen_t valsize); }
- SYS_LISTEN = 106 // { int|sys||listen(int s, int backlog); }
- SYS_GETSOCKOPT = 118 // { int|sys||getsockopt(int s, int level, int name, void *val, socklen_t *avalsize); }
- SYS_READV = 120 // { ssize_t|sys||readv(int fd, const struct iovec *iovp, int iovcnt); }
- SYS_WRITEV = 121 // { ssize_t|sys||writev(int fd, const struct iovec *iovp, int iovcnt); }
- SYS_FCHOWN = 123 // { int|sys||fchown(int fd, uid_t uid, gid_t gid); }
- SYS_FCHMOD = 124 // { int|sys||fchmod(int fd, mode_t mode); }
- SYS_SETREUID = 126 // { int|sys||setreuid(uid_t ruid, uid_t euid); }
- SYS_SETREGID = 127 // { int|sys||setregid(gid_t rgid, gid_t egid); }
- SYS_RENAME = 128 // { int|sys||rename(const char *from, const char *to); }
- SYS_FLOCK = 131 // { int|sys||flock(int fd, int how); }
- SYS_MKFIFO = 132 // { int|sys||mkfifo(const char *path, mode_t mode); }
- SYS_SENDTO = 133 // { ssize_t|sys||sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); }
- SYS_SHUTDOWN = 134 // { int|sys||shutdown(int s, int how); }
- SYS_SOCKETPAIR = 135 // { int|sys||socketpair(int domain, int type, int protocol, int *rsv); }
- SYS_MKDIR = 136 // { int|sys||mkdir(const char *path, mode_t mode); }
- SYS_RMDIR = 137 // { int|sys||rmdir(const char *path); }
- SYS_SETSID = 147 // { int|sys||setsid(void); }
- SYS_SYSARCH = 165 // { int|sys||sysarch(int op, void *parms); }
- SYS_PREAD = 173 // { ssize_t|sys||pread(int fd, void *buf, size_t nbyte, int PAD, off_t offset); }
- SYS_PWRITE = 174 // { ssize_t|sys||pwrite(int fd, const void *buf, size_t nbyte, int PAD, off_t offset); }
- SYS_NTP_ADJTIME = 176 // { int|sys||ntp_adjtime(struct timex *tp); }
- SYS_SETGID = 181 // { int|sys||setgid(gid_t gid); }
- SYS_SETEGID = 182 // { int|sys||setegid(gid_t egid); }
- SYS_SETEUID = 183 // { int|sys||seteuid(uid_t euid); }
- SYS_PATHCONF = 191 // { long|sys||pathconf(const char *path, int name); }
- SYS_FPATHCONF = 192 // { long|sys||fpathconf(int fd, int name); }
- SYS_GETRLIMIT = 194 // { int|sys||getrlimit(int which, struct rlimit *rlp); }
- SYS_SETRLIMIT = 195 // { int|sys||setrlimit(int which, const struct rlimit *rlp); }
- SYS_MMAP = 197 // { void *|sys||mmap(void *addr, size_t len, int prot, int flags, int fd, long PAD, off_t pos); }
- SYS_LSEEK = 199 // { off_t|sys||lseek(int fd, int PAD, off_t offset, int whence); }
- SYS_TRUNCATE = 200 // { int|sys||truncate(const char *path, int PAD, off_t length); }
- SYS_FTRUNCATE = 201 // { int|sys||ftruncate(int fd, int PAD, off_t length); }
- SYS___SYSCTL = 202 // { int|sys||__sysctl(const int *name, u_int namelen, void *old, size_t *oldlenp, const void *new, size_t newlen); }
- SYS_MLOCK = 203 // { int|sys||mlock(const void *addr, size_t len); }
- SYS_MUNLOCK = 204 // { int|sys||munlock(const void *addr, size_t len); }
- SYS_UNDELETE = 205 // { int|sys||undelete(const char *path); }
- SYS_GETPGID = 207 // { pid_t|sys||getpgid(pid_t pid); }
- SYS_REBOOT = 208 // { int|sys||reboot(int opt, char *bootstr); }
- SYS_POLL = 209 // { int|sys||poll(struct pollfd *fds, u_int nfds, int timeout); }
- SYS_SEMGET = 221 // { int|sys||semget(key_t key, int nsems, int semflg); }
- SYS_SEMOP = 222 // { int|sys||semop(int semid, struct sembuf *sops, size_t nsops); }
- SYS_SEMCONFIG = 223 // { int|sys||semconfig(int flag); }
- SYS_MSGGET = 225 // { int|sys||msgget(key_t key, int msgflg); }
- SYS_MSGSND = 226 // { int|sys||msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg); }
- SYS_MSGRCV = 227 // { ssize_t|sys||msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); }
- SYS_SHMAT = 228 // { void *|sys||shmat(int shmid, const void *shmaddr, int shmflg); }
- SYS_SHMDT = 230 // { int|sys||shmdt(const void *shmaddr); }
- SYS_SHMGET = 231 // { int|sys||shmget(key_t key, size_t size, int shmflg); }
- SYS_TIMER_CREATE = 235 // { int|sys||timer_create(clockid_t clock_id, struct sigevent *evp, timer_t *timerid); }
- SYS_TIMER_DELETE = 236 // { int|sys||timer_delete(timer_t timerid); }
- SYS_TIMER_GETOVERRUN = 239 // { int|sys||timer_getoverrun(timer_t timerid); }
- SYS_FDATASYNC = 241 // { int|sys||fdatasync(int fd); }
- SYS_MLOCKALL = 242 // { int|sys||mlockall(int flags); }
- SYS_MUNLOCKALL = 243 // { int|sys||munlockall(void); }
- SYS_SIGQUEUEINFO = 245 // { int|sys||sigqueueinfo(pid_t pid, const siginfo_t *info); }
- SYS_MODCTL = 246 // { int|sys||modctl(int cmd, void *arg); }
- SYS___POSIX_RENAME = 270 // { int|sys||__posix_rename(const char *from, const char *to); }
- SYS_SWAPCTL = 271 // { int|sys||swapctl(int cmd, void *arg, int misc); }
- SYS_MINHERIT = 273 // { int|sys||minherit(void *addr, size_t len, int inherit); }
- SYS_LCHMOD = 274 // { int|sys||lchmod(const char *path, mode_t mode); }
- SYS_LCHOWN = 275 // { int|sys||lchown(const char *path, uid_t uid, gid_t gid); }
- SYS___POSIX_CHOWN = 283 // { int|sys||__posix_chown(const char *path, uid_t uid, gid_t gid); }
- SYS___POSIX_FCHOWN = 284 // { int|sys||__posix_fchown(int fd, uid_t uid, gid_t gid); }
- SYS___POSIX_LCHOWN = 285 // { int|sys||__posix_lchown(const char *path, uid_t uid, gid_t gid); }
- SYS_GETSID = 286 // { pid_t|sys||getsid(pid_t pid); }
- SYS___CLONE = 287 // { pid_t|sys||__clone(int flags, void *stack); }
- SYS_FKTRACE = 288 // { int|sys||fktrace(int fd, int ops, int facs, pid_t pid); }
- SYS_PREADV = 289 // { ssize_t|sys||preadv(int fd, const struct iovec *iovp, int iovcnt, int PAD, off_t offset); }
- SYS_PWRITEV = 290 // { ssize_t|sys||pwritev(int fd, const struct iovec *iovp, int iovcnt, int PAD, off_t offset); }
- SYS___GETCWD = 296 // { int|sys||__getcwd(char *bufp, size_t length); }
- SYS_FCHROOT = 297 // { int|sys||fchroot(int fd); }
- SYS_LCHFLAGS = 304 // { int|sys||lchflags(const char *path, u_long flags); }
- SYS_ISSETUGID = 305 // { int|sys||issetugid(void); }
- SYS_UTRACE = 306 // { int|sys||utrace(const char *label, void *addr, size_t len); }
- SYS_GETCONTEXT = 307 // { int|sys||getcontext(struct __ucontext *ucp); }
- SYS_SETCONTEXT = 308 // { int|sys||setcontext(const struct __ucontext *ucp); }
- SYS__LWP_CREATE = 309 // { int|sys||_lwp_create(const struct __ucontext *ucp, u_long flags, lwpid_t *new_lwp); }
- SYS__LWP_EXIT = 310 // { int|sys||_lwp_exit(void); }
- SYS__LWP_SELF = 311 // { lwpid_t|sys||_lwp_self(void); }
- SYS__LWP_WAIT = 312 // { int|sys||_lwp_wait(lwpid_t wait_for, lwpid_t *departed); }
- SYS__LWP_SUSPEND = 313 // { int|sys||_lwp_suspend(lwpid_t target); }
- SYS__LWP_CONTINUE = 314 // { int|sys||_lwp_continue(lwpid_t target); }
- SYS__LWP_WAKEUP = 315 // { int|sys||_lwp_wakeup(lwpid_t target); }
- SYS__LWP_GETPRIVATE = 316 // { void *|sys||_lwp_getprivate(void); }
- SYS__LWP_SETPRIVATE = 317 // { void|sys||_lwp_setprivate(void *ptr); }
- SYS__LWP_KILL = 318 // { int|sys||_lwp_kill(lwpid_t target, int signo); }
- SYS__LWP_DETACH = 319 // { int|sys||_lwp_detach(lwpid_t target); }
- SYS__LWP_UNPARK = 321 // { int|sys||_lwp_unpark(lwpid_t target, const void *hint); }
- SYS__LWP_UNPARK_ALL = 322 // { ssize_t|sys||_lwp_unpark_all(const lwpid_t *targets, size_t ntargets, const void *hint); }
- SYS__LWP_SETNAME = 323 // { int|sys||_lwp_setname(lwpid_t target, const char *name); }
- SYS__LWP_GETNAME = 324 // { int|sys||_lwp_getname(lwpid_t target, char *name, size_t len); }
- SYS__LWP_CTL = 325 // { int|sys||_lwp_ctl(int features, struct lwpctl **address); }
- SYS___SIGACTION_SIGTRAMP = 340 // { int|sys||__sigaction_sigtramp(int signum, const struct sigaction *nsa, struct sigaction *osa, const void *tramp, int vers); }
- SYS_PMC_GET_INFO = 341 // { int|sys||pmc_get_info(int ctr, int op, void *args); }
- SYS_PMC_CONTROL = 342 // { int|sys||pmc_control(int ctr, int op, void *args); }
- SYS_RASCTL = 343 // { int|sys||rasctl(void *addr, size_t len, int op); }
- SYS_KQUEUE = 344 // { int|sys||kqueue(void); }
- SYS__SCHED_SETPARAM = 346 // { int|sys||_sched_setparam(pid_t pid, lwpid_t lid, int policy, const struct sched_param *params); }
- SYS__SCHED_GETPARAM = 347 // { int|sys||_sched_getparam(pid_t pid, lwpid_t lid, int *policy, struct sched_param *params); }
- SYS__SCHED_SETAFFINITY = 348 // { int|sys||_sched_setaffinity(pid_t pid, lwpid_t lid, size_t size, const cpuset_t *cpuset); }
- SYS__SCHED_GETAFFINITY = 349 // { int|sys||_sched_getaffinity(pid_t pid, lwpid_t lid, size_t size, cpuset_t *cpuset); }
- SYS_SCHED_YIELD = 350 // { int|sys||sched_yield(void); }
- SYS_FSYNC_RANGE = 354 // { int|sys||fsync_range(int fd, int flags, off_t start, off_t length); }
- SYS_UUIDGEN = 355 // { int|sys||uuidgen(struct uuid *store, int count); }
- SYS_GETVFSSTAT = 356 // { int|sys||getvfsstat(struct statvfs *buf, size_t bufsize, int flags); }
- SYS_STATVFS1 = 357 // { int|sys||statvfs1(const char *path, struct statvfs *buf, int flags); }
- SYS_FSTATVFS1 = 358 // { int|sys||fstatvfs1(int fd, struct statvfs *buf, int flags); }
- SYS_EXTATTRCTL = 360 // { int|sys||extattrctl(const char *path, int cmd, const char *filename, int attrnamespace, const char *attrname); }
- SYS_EXTATTR_SET_FILE = 361 // { int|sys||extattr_set_file(const char *path, int attrnamespace, const char *attrname, const void *data, size_t nbytes); }
- SYS_EXTATTR_GET_FILE = 362 // { ssize_t|sys||extattr_get_file(const char *path, int attrnamespace, const char *attrname, void *data, size_t nbytes); }
- SYS_EXTATTR_DELETE_FILE = 363 // { int|sys||extattr_delete_file(const char *path, int attrnamespace, const char *attrname); }
- SYS_EXTATTR_SET_FD = 364 // { int|sys||extattr_set_fd(int fd, int attrnamespace, const char *attrname, const void *data, size_t nbytes); }
- SYS_EXTATTR_GET_FD = 365 // { ssize_t|sys||extattr_get_fd(int fd, int attrnamespace, const char *attrname, void *data, size_t nbytes); }
- SYS_EXTATTR_DELETE_FD = 366 // { int|sys||extattr_delete_fd(int fd, int attrnamespace, const char *attrname); }
- SYS_EXTATTR_SET_LINK = 367 // { int|sys||extattr_set_link(const char *path, int attrnamespace, const char *attrname, const void *data, size_t nbytes); }
- SYS_EXTATTR_GET_LINK = 368 // { ssize_t|sys||extattr_get_link(const char *path, int attrnamespace, const char *attrname, void *data, size_t nbytes); }
- SYS_EXTATTR_DELETE_LINK = 369 // { int|sys||extattr_delete_link(const char *path, int attrnamespace, const char *attrname); }
- SYS_EXTATTR_LIST_FD = 370 // { ssize_t|sys||extattr_list_fd(int fd, int attrnamespace, void *data, size_t nbytes); }
- SYS_EXTATTR_LIST_FILE = 371 // { ssize_t|sys||extattr_list_file(const char *path, int attrnamespace, void *data, size_t nbytes); }
- SYS_EXTATTR_LIST_LINK = 372 // { ssize_t|sys||extattr_list_link(const char *path, int attrnamespace, void *data, size_t nbytes); }
- SYS_SETXATTR = 375 // { int|sys||setxattr(const char *path, const char *name, const void *value, size_t size, int flags); }
- SYS_LSETXATTR = 376 // { int|sys||lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags); }
- SYS_FSETXATTR = 377 // { int|sys||fsetxattr(int fd, const char *name, const void *value, size_t size, int flags); }
- SYS_GETXATTR = 378 // { int|sys||getxattr(const char *path, const char *name, void *value, size_t size); }
- SYS_LGETXATTR = 379 // { int|sys||lgetxattr(const char *path, const char *name, void *value, size_t size); }
- SYS_FGETXATTR = 380 // { int|sys||fgetxattr(int fd, const char *name, void *value, size_t size); }
- SYS_LISTXATTR = 381 // { int|sys||listxattr(const char *path, char *list, size_t size); }
- SYS_LLISTXATTR = 382 // { int|sys||llistxattr(const char *path, char *list, size_t size); }
- SYS_FLISTXATTR = 383 // { int|sys||flistxattr(int fd, char *list, size_t size); }
- SYS_REMOVEXATTR = 384 // { int|sys||removexattr(const char *path, const char *name); }
- SYS_LREMOVEXATTR = 385 // { int|sys||lremovexattr(const char *path, const char *name); }
- SYS_FREMOVEXATTR = 386 // { int|sys||fremovexattr(int fd, const char *name); }
- SYS_GETDENTS = 390 // { int|sys|30|getdents(int fd, char *buf, size_t count); }
- SYS_SOCKET = 394 // { int|sys|30|socket(int domain, int type, int protocol); }
- SYS_GETFH = 395 // { int|sys|30|getfh(const char *fname, void *fhp, size_t *fh_size); }
- SYS_MOUNT = 410 // { int|sys|50|mount(const char *type, const char *path, int flags, void *data, size_t data_len); }
- SYS_MREMAP = 411 // { void *|sys||mremap(void *old_address, size_t old_size, void *new_address, size_t new_size, int flags); }
- SYS_PSET_CREATE = 412 // { int|sys||pset_create(psetid_t *psid); }
- SYS_PSET_DESTROY = 413 // { int|sys||pset_destroy(psetid_t psid); }
- SYS_PSET_ASSIGN = 414 // { int|sys||pset_assign(psetid_t psid, cpuid_t cpuid, psetid_t *opsid); }
- SYS__PSET_BIND = 415 // { int|sys||_pset_bind(idtype_t idtype, id_t first_id, id_t second_id, psetid_t psid, psetid_t *opsid); }
- SYS_POSIX_FADVISE = 416 // { int|sys|50|posix_fadvise(int fd, int PAD, off_t offset, off_t len, int advice); }
- SYS_SELECT = 417 // { int|sys|50|select(int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timeval *tv); }
- SYS_GETTIMEOFDAY = 418 // { int|sys|50|gettimeofday(struct timeval *tp, void *tzp); }
- SYS_SETTIMEOFDAY = 419 // { int|sys|50|settimeofday(const struct timeval *tv, const void *tzp); }
- SYS_UTIMES = 420 // { int|sys|50|utimes(const char *path, const struct timeval *tptr); }
- SYS_ADJTIME = 421 // { int|sys|50|adjtime(const struct timeval *delta, struct timeval *olddelta); }
- SYS_FUTIMES = 423 // { int|sys|50|futimes(int fd, const struct timeval *tptr); }
- SYS_LUTIMES = 424 // { int|sys|50|lutimes(const char *path, const struct timeval *tptr); }
- SYS_SETITIMER = 425 // { int|sys|50|setitimer(int which, const struct itimerval *itv, struct itimerval *oitv); }
- SYS_GETITIMER = 426 // { int|sys|50|getitimer(int which, struct itimerval *itv); }
- SYS_CLOCK_GETTIME = 427 // { int|sys|50|clock_gettime(clockid_t clock_id, struct timespec *tp); }
- SYS_CLOCK_SETTIME = 428 // { int|sys|50|clock_settime(clockid_t clock_id, const struct timespec *tp); }
- SYS_CLOCK_GETRES = 429 // { int|sys|50|clock_getres(clockid_t clock_id, struct timespec *tp); }
- SYS_NANOSLEEP = 430 // { int|sys|50|nanosleep(const struct timespec *rqtp, struct timespec *rmtp); }
- SYS___SIGTIMEDWAIT = 431 // { int|sys|50|__sigtimedwait(const sigset_t *set, siginfo_t *info, struct timespec *timeout); }
- SYS__LWP_PARK = 434 // { int|sys|50|_lwp_park(const struct timespec *ts, lwpid_t unpark, const void *hint, const void *unparkhint); }
- SYS_KEVENT = 435 // { int|sys|50|kevent(int fd, const struct kevent *changelist, size_t nchanges, struct kevent *eventlist, size_t nevents, const struct timespec *timeout); }
- SYS_PSELECT = 436 // { int|sys|50|pselect(int nd, fd_set *in, fd_set *ou, fd_set *ex, const struct timespec *ts, const sigset_t *mask); }
- SYS_POLLTS = 437 // { int|sys|50|pollts(struct pollfd *fds, u_int nfds, const struct timespec *ts, const sigset_t *mask); }
- SYS_STAT = 439 // { int|sys|50|stat(const char *path, struct stat *ub); }
- SYS_FSTAT = 440 // { int|sys|50|fstat(int fd, struct stat *sb); }
- SYS_LSTAT = 441 // { int|sys|50|lstat(const char *path, struct stat *ub); }
- SYS___SEMCTL = 442 // { int|sys|50|__semctl(int semid, int semnum, int cmd, ... union __semun *arg); }
- SYS_SHMCTL = 443 // { int|sys|50|shmctl(int shmid, int cmd, struct shmid_ds *buf); }
- SYS_MSGCTL = 444 // { int|sys|50|msgctl(int msqid, int cmd, struct msqid_ds *buf); }
- SYS_GETRUSAGE = 445 // { int|sys|50|getrusage(int who, struct rusage *rusage); }
- SYS_TIMER_SETTIME = 446 // { int|sys|50|timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue); }
- SYS_TIMER_GETTIME = 447 // { int|sys|50|timer_gettime(timer_t timerid, struct itimerspec *value); }
- SYS_NTP_GETTIME = 448 // { int|sys|50|ntp_gettime(struct ntptimeval *ntvp); }
- SYS_WAIT4 = 449 // { int|sys|50|wait4(pid_t pid, int *status, int options, struct rusage *rusage); }
- SYS_MKNOD = 450 // { int|sys|50|mknod(const char *path, mode_t mode, dev_t dev); }
- SYS_FHSTAT = 451 // { int|sys|50|fhstat(const void *fhp, size_t fh_size, struct stat *sb); }
- SYS_PIPE2 = 453 // { int|sys||pipe2(int *fildes, int flags); }
- SYS_DUP3 = 454 // { int|sys||dup3(int from, int to, int flags); }
- SYS_KQUEUE1 = 455 // { int|sys||kqueue1(int flags); }
- SYS_PACCEPT = 456 // { int|sys||paccept(int s, struct sockaddr *name, socklen_t *anamelen, const sigset_t *mask, int flags); }
- SYS_LINKAT = 457 // { int|sys||linkat(int fd1, const char *name1, int fd2, const char *name2, int flags); }
- SYS_RENAMEAT = 458 // { int|sys||renameat(int fromfd, const char *from, int tofd, const char *to); }
- SYS_MKFIFOAT = 459 // { int|sys||mkfifoat(int fd, const char *path, mode_t mode); }
- SYS_MKNODAT = 460 // { int|sys||mknodat(int fd, const char *path, mode_t mode, uint32_t dev); }
- SYS_MKDIRAT = 461 // { int|sys||mkdirat(int fd, const char *path, mode_t mode); }
- SYS_FACCESSAT = 462 // { int|sys||faccessat(int fd, const char *path, int amode, int flag); }
- SYS_FCHMODAT = 463 // { int|sys||fchmodat(int fd, const char *path, mode_t mode, int flag); }
- SYS_FCHOWNAT = 464 // { int|sys||fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag); }
- SYS_FEXECVE = 465 // { int|sys||fexecve(int fd, char * const *argp, char * const *envp); }
- SYS_FSTATAT = 466 // { int|sys||fstatat(int fd, const char *path, struct stat *buf, int flag); }
- SYS_UTIMENSAT = 467 // { int|sys||utimensat(int fd, const char *path, const struct timespec *tptr, int flag); }
- SYS_OPENAT = 468 // { int|sys||openat(int fd, const char *path, int oflags, ... mode_t mode); }
- SYS_READLINKAT = 469 // { int|sys||readlinkat(int fd, const char *path, char *buf, size_t bufsize); }
- SYS_SYMLINKAT = 470 // { int|sys||symlinkat(const char *path1, int fd, const char *path2); }
- SYS_UNLINKAT = 471 // { int|sys||unlinkat(int fd, const char *path, int flag); }
- SYS_FUTIMENS = 472 // { int|sys||futimens(int fd, const struct timespec *tptr); }
- SYS___QUOTACTL = 473 // { int|sys||__quotactl(const char *path, struct quotactl_args *args); }
- SYS_POSIX_SPAWN = 474 // { int|sys||posix_spawn(pid_t *pid, const char *path, const struct posix_spawn_file_actions *file_actions, const struct posix_spawnattr *attrp, char *const *argv, char *const *envp); }
- SYS_RECVMMSG = 475 // { int|sys||recvmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags, struct timespec *timeout); }
- SYS_SENDMMSG = 476 // { int|sys||sendmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags); }
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go b/newt/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go
deleted file mode 100644
index 612ba662..00000000
--- a/newt/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go
+++ /dev/null
@@ -1,273 +0,0 @@
-// mksysnum_netbsd.pl
-// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
-
-// +build arm,netbsd
-
-package unix
-
-const (
- SYS_EXIT = 1 // { void|sys||exit(int rval); }
- SYS_FORK = 2 // { int|sys||fork(void); }
- SYS_READ = 3 // { ssize_t|sys||read(int fd, void *buf, size_t nbyte); }
- SYS_WRITE = 4 // { ssize_t|sys||write(int fd, const void *buf, size_t nbyte); }
- SYS_OPEN = 5 // { int|sys||open(const char *path, int flags, ... mode_t mode); }
- SYS_CLOSE = 6 // { int|sys||close(int fd); }
- SYS_LINK = 9 // { int|sys||link(const char *path, const char *link); }
- SYS_UNLINK = 10 // { int|sys||unlink(const char *path); }
- SYS_CHDIR = 12 // { int|sys||chdir(const char *path); }
- SYS_FCHDIR = 13 // { int|sys||fchdir(int fd); }
- SYS_CHMOD = 15 // { int|sys||chmod(const char *path, mode_t mode); }
- SYS_CHOWN = 16 // { int|sys||chown(const char *path, uid_t uid, gid_t gid); }
- SYS_BREAK = 17 // { int|sys||obreak(char *nsize); }
- SYS_GETPID = 20 // { pid_t|sys||getpid_with_ppid(void); }
- SYS_UNMOUNT = 22 // { int|sys||unmount(const char *path, int flags); }
- SYS_SETUID = 23 // { int|sys||setuid(uid_t uid); }
- SYS_GETUID = 24 // { uid_t|sys||getuid_with_euid(void); }
- SYS_GETEUID = 25 // { uid_t|sys||geteuid(void); }
- SYS_PTRACE = 26 // { int|sys||ptrace(int req, pid_t pid, void *addr, int data); }
- SYS_RECVMSG = 27 // { ssize_t|sys||recvmsg(int s, struct msghdr *msg, int flags); }
- SYS_SENDMSG = 28 // { ssize_t|sys||sendmsg(int s, const struct msghdr *msg, int flags); }
- SYS_RECVFROM = 29 // { ssize_t|sys||recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlenaddr); }
- SYS_ACCEPT = 30 // { int|sys||accept(int s, struct sockaddr *name, socklen_t *anamelen); }
- SYS_GETPEERNAME = 31 // { int|sys||getpeername(int fdes, struct sockaddr *asa, socklen_t *alen); }
- SYS_GETSOCKNAME = 32 // { int|sys||getsockname(int fdes, struct sockaddr *asa, socklen_t *alen); }
- SYS_ACCESS = 33 // { int|sys||access(const char *path, int flags); }
- SYS_CHFLAGS = 34 // { int|sys||chflags(const char *path, u_long flags); }
- SYS_FCHFLAGS = 35 // { int|sys||fchflags(int fd, u_long flags); }
- SYS_SYNC = 36 // { void|sys||sync(void); }
- SYS_KILL = 37 // { int|sys||kill(pid_t pid, int signum); }
- SYS_GETPPID = 39 // { pid_t|sys||getppid(void); }
- SYS_DUP = 41 // { int|sys||dup(int fd); }
- SYS_PIPE = 42 // { int|sys||pipe(void); }
- SYS_GETEGID = 43 // { gid_t|sys||getegid(void); }
- SYS_PROFIL = 44 // { int|sys||profil(char *samples, size_t size, u_long offset, u_int scale); }
- SYS_KTRACE = 45 // { int|sys||ktrace(const char *fname, int ops, int facs, pid_t pid); }
- SYS_GETGID = 47 // { gid_t|sys||getgid_with_egid(void); }
- SYS___GETLOGIN = 49 // { int|sys||__getlogin(char *namebuf, size_t namelen); }
- SYS___SETLOGIN = 50 // { int|sys||__setlogin(const char *namebuf); }
- SYS_ACCT = 51 // { int|sys||acct(const char *path); }
- SYS_IOCTL = 54 // { int|sys||ioctl(int fd, u_long com, ... void *data); }
- SYS_REVOKE = 56 // { int|sys||revoke(const char *path); }
- SYS_SYMLINK = 57 // { int|sys||symlink(const char *path, const char *link); }
- SYS_READLINK = 58 // { ssize_t|sys||readlink(const char *path, char *buf, size_t count); }
- SYS_EXECVE = 59 // { int|sys||execve(const char *path, char * const *argp, char * const *envp); }
- SYS_UMASK = 60 // { mode_t|sys||umask(mode_t newmask); }
- SYS_CHROOT = 61 // { int|sys||chroot(const char *path); }
- SYS_VFORK = 66 // { int|sys||vfork(void); }
- SYS_SBRK = 69 // { int|sys||sbrk(intptr_t incr); }
- SYS_SSTK = 70 // { int|sys||sstk(int incr); }
- SYS_VADVISE = 72 // { int|sys||ovadvise(int anom); }
- SYS_MUNMAP = 73 // { int|sys||munmap(void *addr, size_t len); }
- SYS_MPROTECT = 74 // { int|sys||mprotect(void *addr, size_t len, int prot); }
- SYS_MADVISE = 75 // { int|sys||madvise(void *addr, size_t len, int behav); }
- SYS_MINCORE = 78 // { int|sys||mincore(void *addr, size_t len, char *vec); }
- SYS_GETGROUPS = 79 // { int|sys||getgroups(int gidsetsize, gid_t *gidset); }
- SYS_SETGROUPS = 80 // { int|sys||setgroups(int gidsetsize, const gid_t *gidset); }
- SYS_GETPGRP = 81 // { int|sys||getpgrp(void); }
- SYS_SETPGID = 82 // { int|sys||setpgid(pid_t pid, pid_t pgid); }
- SYS_DUP2 = 90 // { int|sys||dup2(int from, int to); }
- SYS_FCNTL = 92 // { int|sys||fcntl(int fd, int cmd, ... void *arg); }
- SYS_FSYNC = 95 // { int|sys||fsync(int fd); }
- SYS_SETPRIORITY = 96 // { int|sys||setpriority(int which, id_t who, int prio); }
- SYS_CONNECT = 98 // { int|sys||connect(int s, const struct sockaddr *name, socklen_t namelen); }
- SYS_GETPRIORITY = 100 // { int|sys||getpriority(int which, id_t who); }
- SYS_BIND = 104 // { int|sys||bind(int s, const struct sockaddr *name, socklen_t namelen); }
- SYS_SETSOCKOPT = 105 // { int|sys||setsockopt(int s, int level, int name, const void *val, socklen_t valsize); }
- SYS_LISTEN = 106 // { int|sys||listen(int s, int backlog); }
- SYS_GETSOCKOPT = 118 // { int|sys||getsockopt(int s, int level, int name, void *val, socklen_t *avalsize); }
- SYS_READV = 120 // { ssize_t|sys||readv(int fd, const struct iovec *iovp, int iovcnt); }
- SYS_WRITEV = 121 // { ssize_t|sys||writev(int fd, const struct iovec *iovp, int iovcnt); }
- SYS_FCHOWN = 123 // { int|sys||fchown(int fd, uid_t uid, gid_t gid); }
- SYS_FCHMOD = 124 // { int|sys||fchmod(int fd, mode_t mode); }
- SYS_SETREUID = 126 // { int|sys||setreuid(uid_t ruid, uid_t euid); }
- SYS_SETREGID = 127 // { int|sys||setregid(gid_t rgid, gid_t egid); }
- SYS_RENAME = 128 // { int|sys||rename(const char *from, const char *to); }
- SYS_FLOCK = 131 // { int|sys||flock(int fd, int how); }
- SYS_MKFIFO = 132 // { int|sys||mkfifo(const char *path, mode_t mode); }
- SYS_SENDTO = 133 // { ssize_t|sys||sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); }
- SYS_SHUTDOWN = 134 // { int|sys||shutdown(int s, int how); }
- SYS_SOCKETPAIR = 135 // { int|sys||socketpair(int domain, int type, int protocol, int *rsv); }
- SYS_MKDIR = 136 // { int|sys||mkdir(const char *path, mode_t mode); }
- SYS_RMDIR = 137 // { int|sys||rmdir(const char *path); }
- SYS_SETSID = 147 // { int|sys||setsid(void); }
- SYS_SYSARCH = 165 // { int|sys||sysarch(int op, void *parms); }
- SYS_PREAD = 173 // { ssize_t|sys||pread(int fd, void *buf, size_t nbyte, int PAD, off_t offset); }
- SYS_PWRITE = 174 // { ssize_t|sys||pwrite(int fd, const void *buf, size_t nbyte, int PAD, off_t offset); }
- SYS_NTP_ADJTIME = 176 // { int|sys||ntp_adjtime(struct timex *tp); }
- SYS_SETGID = 181 // { int|sys||setgid(gid_t gid); }
- SYS_SETEGID = 182 // { int|sys||setegid(gid_t egid); }
- SYS_SETEUID = 183 // { int|sys||seteuid(uid_t euid); }
- SYS_PATHCONF = 191 // { long|sys||pathconf(const char *path, int name); }
- SYS_FPATHCONF = 192 // { long|sys||fpathconf(int fd, int name); }
- SYS_GETRLIMIT = 194 // { int|sys||getrlimit(int which, struct rlimit *rlp); }
- SYS_SETRLIMIT = 195 // { int|sys||setrlimit(int which, const struct rlimit *rlp); }
- SYS_MMAP = 197 // { void *|sys||mmap(void *addr, size_t len, int prot, int flags, int fd, long PAD, off_t pos); }
- SYS_LSEEK = 199 // { off_t|sys||lseek(int fd, int PAD, off_t offset, int whence); }
- SYS_TRUNCATE = 200 // { int|sys||truncate(const char *path, int PAD, off_t length); }
- SYS_FTRUNCATE = 201 // { int|sys||ftruncate(int fd, int PAD, off_t length); }
- SYS___SYSCTL = 202 // { int|sys||__sysctl(const int *name, u_int namelen, void *old, size_t *oldlenp, const void *new, size_t newlen); }
- SYS_MLOCK = 203 // { int|sys||mlock(const void *addr, size_t len); }
- SYS_MUNLOCK = 204 // { int|sys||munlock(const void *addr, size_t len); }
- SYS_UNDELETE = 205 // { int|sys||undelete(const char *path); }
- SYS_GETPGID = 207 // { pid_t|sys||getpgid(pid_t pid); }
- SYS_REBOOT = 208 // { int|sys||reboot(int opt, char *bootstr); }
- SYS_POLL = 209 // { int|sys||poll(struct pollfd *fds, u_int nfds, int timeout); }
- SYS_SEMGET = 221 // { int|sys||semget(key_t key, int nsems, int semflg); }
- SYS_SEMOP = 222 // { int|sys||semop(int semid, struct sembuf *sops, size_t nsops); }
- SYS_SEMCONFIG = 223 // { int|sys||semconfig(int flag); }
- SYS_MSGGET = 225 // { int|sys||msgget(key_t key, int msgflg); }
- SYS_MSGSND = 226 // { int|sys||msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg); }
- SYS_MSGRCV = 227 // { ssize_t|sys||msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); }
- SYS_SHMAT = 228 // { void *|sys||shmat(int shmid, const void *shmaddr, int shmflg); }
- SYS_SHMDT = 230 // { int|sys||shmdt(const void *shmaddr); }
- SYS_SHMGET = 231 // { int|sys||shmget(key_t key, size_t size, int shmflg); }
- SYS_TIMER_CREATE = 235 // { int|sys||timer_create(clockid_t clock_id, struct sigevent *evp, timer_t *timerid); }
- SYS_TIMER_DELETE = 236 // { int|sys||timer_delete(timer_t timerid); }
- SYS_TIMER_GETOVERRUN = 239 // { int|sys||timer_getoverrun(timer_t timerid); }
- SYS_FDATASYNC = 241 // { int|sys||fdatasync(int fd); }
- SYS_MLOCKALL = 242 // { int|sys||mlockall(int flags); }
- SYS_MUNLOCKALL = 243 // { int|sys||munlockall(void); }
- SYS_SIGQUEUEINFO = 245 // { int|sys||sigqueueinfo(pid_t pid, const siginfo_t *info); }
- SYS_MODCTL = 246 // { int|sys||modctl(int cmd, void *arg); }
- SYS___POSIX_RENAME = 270 // { int|sys||__posix_rename(const char *from, const char *to); }
- SYS_SWAPCTL = 271 // { int|sys||swapctl(int cmd, void *arg, int misc); }
- SYS_MINHERIT = 273 // { int|sys||minherit(void *addr, size_t len, int inherit); }
- SYS_LCHMOD = 274 // { int|sys||lchmod(const char *path, mode_t mode); }
- SYS_LCHOWN = 275 // { int|sys||lchown(const char *path, uid_t uid, gid_t gid); }
- SYS___POSIX_CHOWN = 283 // { int|sys||__posix_chown(const char *path, uid_t uid, gid_t gid); }
- SYS___POSIX_FCHOWN = 284 // { int|sys||__posix_fchown(int fd, uid_t uid, gid_t gid); }
- SYS___POSIX_LCHOWN = 285 // { int|sys||__posix_lchown(const char *path, uid_t uid, gid_t gid); }
- SYS_GETSID = 286 // { pid_t|sys||getsid(pid_t pid); }
- SYS___CLONE = 287 // { pid_t|sys||__clone(int flags, void *stack); }
- SYS_FKTRACE = 288 // { int|sys||fktrace(int fd, int ops, int facs, pid_t pid); }
- SYS_PREADV = 289 // { ssize_t|sys||preadv(int fd, const struct iovec *iovp, int iovcnt, int PAD, off_t offset); }
- SYS_PWRITEV = 290 // { ssize_t|sys||pwritev(int fd, const struct iovec *iovp, int iovcnt, int PAD, off_t offset); }
- SYS___GETCWD = 296 // { int|sys||__getcwd(char *bufp, size_t length); }
- SYS_FCHROOT = 297 // { int|sys||fchroot(int fd); }
- SYS_LCHFLAGS = 304 // { int|sys||lchflags(const char *path, u_long flags); }
- SYS_ISSETUGID = 305 // { int|sys||issetugid(void); }
- SYS_UTRACE = 306 // { int|sys||utrace(const char *label, void *addr, size_t len); }
- SYS_GETCONTEXT = 307 // { int|sys||getcontext(struct __ucontext *ucp); }
- SYS_SETCONTEXT = 308 // { int|sys||setcontext(const struct __ucontext *ucp); }
- SYS__LWP_CREATE = 309 // { int|sys||_lwp_create(const struct __ucontext *ucp, u_long flags, lwpid_t *new_lwp); }
- SYS__LWP_EXIT = 310 // { int|sys||_lwp_exit(void); }
- SYS__LWP_SELF = 311 // { lwpid_t|sys||_lwp_self(void); }
- SYS__LWP_WAIT = 312 // { int|sys||_lwp_wait(lwpid_t wait_for, lwpid_t *departed); }
- SYS__LWP_SUSPEND = 313 // { int|sys||_lwp_suspend(lwpid_t target); }
- SYS__LWP_CONTINUE = 314 // { int|sys||_lwp_continue(lwpid_t target); }
- SYS__LWP_WAKEUP = 315 // { int|sys||_lwp_wakeup(lwpid_t target); }
- SYS__LWP_GETPRIVATE = 316 // { void *|sys||_lwp_getprivate(void); }
- SYS__LWP_SETPRIVATE = 317 // { void|sys||_lwp_setprivate(void *ptr); }
- SYS__LWP_KILL = 318 // { int|sys||_lwp_kill(lwpid_t target, int signo); }
- SYS__LWP_DETACH = 319 // { int|sys||_lwp_detach(lwpid_t target); }
- SYS__LWP_UNPARK = 321 // { int|sys||_lwp_unpark(lwpid_t target, const void *hint); }
- SYS__LWP_UNPARK_ALL = 322 // { ssize_t|sys||_lwp_unpark_all(const lwpid_t *targets, size_t ntargets, const void *hint); }
- SYS__LWP_SETNAME = 323 // { int|sys||_lwp_setname(lwpid_t target, const char *name); }
- SYS__LWP_GETNAME = 324 // { int|sys||_lwp_getname(lwpid_t target, char *name, size_t len); }
- SYS__LWP_CTL = 325 // { int|sys||_lwp_ctl(int features, struct lwpctl **address); }
- SYS___SIGACTION_SIGTRAMP = 340 // { int|sys||__sigaction_sigtramp(int signum, const struct sigaction *nsa, struct sigaction *osa, const void *tramp, int vers); }
- SYS_PMC_GET_INFO = 341 // { int|sys||pmc_get_info(int ctr, int op, void *args); }
- SYS_PMC_CONTROL = 342 // { int|sys||pmc_control(int ctr, int op, void *args); }
- SYS_RASCTL = 343 // { int|sys||rasctl(void *addr, size_t len, int op); }
- SYS_KQUEUE = 344 // { int|sys||kqueue(void); }
- SYS__SCHED_SETPARAM = 346 // { int|sys||_sched_setparam(pid_t pid, lwpid_t lid, int policy, const struct sched_param *params); }
- SYS__SCHED_GETPARAM = 347 // { int|sys||_sched_getparam(pid_t pid, lwpid_t lid, int *policy, struct sched_param *params); }
- SYS__SCHED_SETAFFINITY = 348 // { int|sys||_sched_setaffinity(pid_t pid, lwpid_t lid, size_t size, const cpuset_t *cpuset); }
- SYS__SCHED_GETAFFINITY = 349 // { int|sys||_sched_getaffinity(pid_t pid, lwpid_t lid, size_t size, cpuset_t *cpuset); }
- SYS_SCHED_YIELD = 350 // { int|sys||sched_yield(void); }
- SYS_FSYNC_RANGE = 354 // { int|sys||fsync_range(int fd, int flags, off_t start, off_t length); }
- SYS_UUIDGEN = 355 // { int|sys||uuidgen(struct uuid *store, int count); }
- SYS_GETVFSSTAT = 356 // { int|sys||getvfsstat(struct statvfs *buf, size_t bufsize, int flags); }
- SYS_STATVFS1 = 357 // { int|sys||statvfs1(const char *path, struct statvfs *buf, int flags); }
- SYS_FSTATVFS1 = 358 // { int|sys||fstatvfs1(int fd, struct statvfs *buf, int flags); }
- SYS_EXTATTRCTL = 360 // { int|sys||extattrctl(const char *path, int cmd, const char *filename, int attrnamespace, const char *attrname); }
- SYS_EXTATTR_SET_FILE = 361 // { int|sys||extattr_set_file(const char *path, int attrnamespace, const char *attrname, const void *data, size_t nbytes); }
- SYS_EXTATTR_GET_FILE = 362 // { ssize_t|sys||extattr_get_file(const char *path, int attrnamespace, const char *attrname, void *data, size_t nbytes); }
- SYS_EXTATTR_DELETE_FILE = 363 // { int|sys||extattr_delete_file(const char *path, int attrnamespace, const char *attrname); }
- SYS_EXTATTR_SET_FD = 364 // { int|sys||extattr_set_fd(int fd, int attrnamespace, const char *attrname, const void *data, size_t nbytes); }
- SYS_EXTATTR_GET_FD = 365 // { ssize_t|sys||extattr_get_fd(int fd, int attrnamespace, const char *attrname, void *data, size_t nbytes); }
- SYS_EXTATTR_DELETE_FD = 366 // { int|sys||extattr_delete_fd(int fd, int attrnamespace, const char *attrname); }
- SYS_EXTATTR_SET_LINK = 367 // { int|sys||extattr_set_link(const char *path, int attrnamespace, const char *attrname, const void *data, size_t nbytes); }
- SYS_EXTATTR_GET_LINK = 368 // { ssize_t|sys||extattr_get_link(const char *path, int attrnamespace, const char *attrname, void *data, size_t nbytes); }
- SYS_EXTATTR_DELETE_LINK = 369 // { int|sys||extattr_delete_link(const char *path, int attrnamespace, const char *attrname); }
- SYS_EXTATTR_LIST_FD = 370 // { ssize_t|sys||extattr_list_fd(int fd, int attrnamespace, void *data, size_t nbytes); }
- SYS_EXTATTR_LIST_FILE = 371 // { ssize_t|sys||extattr_list_file(const char *path, int attrnamespace, void *data, size_t nbytes); }
- SYS_EXTATTR_LIST_LINK = 372 // { ssize_t|sys||extattr_list_link(const char *path, int attrnamespace, void *data, size_t nbytes); }
- SYS_SETXATTR = 375 // { int|sys||setxattr(const char *path, const char *name, const void *value, size_t size, int flags); }
- SYS_LSETXATTR = 376 // { int|sys||lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags); }
- SYS_FSETXATTR = 377 // { int|sys||fsetxattr(int fd, const char *name, const void *value, size_t size, int flags); }
- SYS_GETXATTR = 378 // { int|sys||getxattr(const char *path, const char *name, void *value, size_t size); }
- SYS_LGETXATTR = 379 // { int|sys||lgetxattr(const char *path, const char *name, void *value, size_t size); }
- SYS_FGETXATTR = 380 // { int|sys||fgetxattr(int fd, const char *name, void *value, size_t size); }
- SYS_LISTXATTR = 381 // { int|sys||listxattr(const char *path, char *list, size_t size); }
- SYS_LLISTXATTR = 382 // { int|sys||llistxattr(const char *path, char *list, size_t size); }
- SYS_FLISTXATTR = 383 // { int|sys||flistxattr(int fd, char *list, size_t size); }
- SYS_REMOVEXATTR = 384 // { int|sys||removexattr(const char *path, const char *name); }
- SYS_LREMOVEXATTR = 385 // { int|sys||lremovexattr(const char *path, const char *name); }
- SYS_FREMOVEXATTR = 386 // { int|sys||fremovexattr(int fd, const char *name); }
- SYS_GETDENTS = 390 // { int|sys|30|getdents(int fd, char *buf, size_t count); }
- SYS_SOCKET = 394 // { int|sys|30|socket(int domain, int type, int protocol); }
- SYS_GETFH = 395 // { int|sys|30|getfh(const char *fname, void *fhp, size_t *fh_size); }
- SYS_MOUNT = 410 // { int|sys|50|mount(const char *type, const char *path, int flags, void *data, size_t data_len); }
- SYS_MREMAP = 411 // { void *|sys||mremap(void *old_address, size_t old_size, void *new_address, size_t new_size, int flags); }
- SYS_PSET_CREATE = 412 // { int|sys||pset_create(psetid_t *psid); }
- SYS_PSET_DESTROY = 413 // { int|sys||pset_destroy(psetid_t psid); }
- SYS_PSET_ASSIGN = 414 // { int|sys||pset_assign(psetid_t psid, cpuid_t cpuid, psetid_t *opsid); }
- SYS__PSET_BIND = 415 // { int|sys||_pset_bind(idtype_t idtype, id_t first_id, id_t second_id, psetid_t psid, psetid_t *opsid); }
- SYS_POSIX_FADVISE = 416 // { int|sys|50|posix_fadvise(int fd, int PAD, off_t offset, off_t len, int advice); }
- SYS_SELECT = 417 // { int|sys|50|select(int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timeval *tv); }
- SYS_GETTIMEOFDAY = 418 // { int|sys|50|gettimeofday(struct timeval *tp, void *tzp); }
- SYS_SETTIMEOFDAY = 419 // { int|sys|50|settimeofday(const struct timeval *tv, const void *tzp); }
- SYS_UTIMES = 420 // { int|sys|50|utimes(const char *path, const struct timeval *tptr); }
- SYS_ADJTIME = 421 // { int|sys|50|adjtime(const struct timeval *delta, struct timeval *olddelta); }
- SYS_FUTIMES = 423 // { int|sys|50|futimes(int fd, const struct timeval *tptr); }
- SYS_LUTIMES = 424 // { int|sys|50|lutimes(const char *path, const struct timeval *tptr); }
- SYS_SETITIMER = 425 // { int|sys|50|setitimer(int which, const struct itimerval *itv, struct itimerval *oitv); }
- SYS_GETITIMER = 426 // { int|sys|50|getitimer(int which, struct itimerval *itv); }
- SYS_CLOCK_GETTIME = 427 // { int|sys|50|clock_gettime(clockid_t clock_id, struct timespec *tp); }
- SYS_CLOCK_SETTIME = 428 // { int|sys|50|clock_settime(clockid_t clock_id, const struct timespec *tp); }
- SYS_CLOCK_GETRES = 429 // { int|sys|50|clock_getres(clockid_t clock_id, struct timespec *tp); }
- SYS_NANOSLEEP = 430 // { int|sys|50|nanosleep(const struct timespec *rqtp, struct timespec *rmtp); }
- SYS___SIGTIMEDWAIT = 431 // { int|sys|50|__sigtimedwait(const sigset_t *set, siginfo_t *info, struct timespec *timeout); }
- SYS__LWP_PARK = 434 // { int|sys|50|_lwp_park(const struct timespec *ts, lwpid_t unpark, const void *hint, const void *unparkhint); }
- SYS_KEVENT = 435 // { int|sys|50|kevent(int fd, const struct kevent *changelist, size_t nchanges, struct kevent *eventlist, size_t nevents, const struct timespec *timeout); }
- SYS_PSELECT = 436 // { int|sys|50|pselect(int nd, fd_set *in, fd_set *ou, fd_set *ex, const struct timespec *ts, const sigset_t *mask); }
- SYS_POLLTS = 437 // { int|sys|50|pollts(struct pollfd *fds, u_int nfds, const struct timespec *ts, const sigset_t *mask); }
- SYS_STAT = 439 // { int|sys|50|stat(const char *path, struct stat *ub); }
- SYS_FSTAT = 440 // { int|sys|50|fstat(int fd, struct stat *sb); }
- SYS_LSTAT = 441 // { int|sys|50|lstat(const char *path, struct stat *ub); }
- SYS___SEMCTL = 442 // { int|sys|50|__semctl(int semid, int semnum, int cmd, ... union __semun *arg); }
- SYS_SHMCTL = 443 // { int|sys|50|shmctl(int shmid, int cmd, struct shmid_ds *buf); }
- SYS_MSGCTL = 444 // { int|sys|50|msgctl(int msqid, int cmd, struct msqid_ds *buf); }
- SYS_GETRUSAGE = 445 // { int|sys|50|getrusage(int who, struct rusage *rusage); }
- SYS_TIMER_SETTIME = 446 // { int|sys|50|timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue); }
- SYS_TIMER_GETTIME = 447 // { int|sys|50|timer_gettime(timer_t timerid, struct itimerspec *value); }
- SYS_NTP_GETTIME = 448 // { int|sys|50|ntp_gettime(struct ntptimeval *ntvp); }
- SYS_WAIT4 = 449 // { int|sys|50|wait4(pid_t pid, int *status, int options, struct rusage *rusage); }
- SYS_MKNOD = 450 // { int|sys|50|mknod(const char *path, mode_t mode, dev_t dev); }
- SYS_FHSTAT = 451 // { int|sys|50|fhstat(const void *fhp, size_t fh_size, struct stat *sb); }
- SYS_PIPE2 = 453 // { int|sys||pipe2(int *fildes, int flags); }
- SYS_DUP3 = 454 // { int|sys||dup3(int from, int to, int flags); }
- SYS_KQUEUE1 = 455 // { int|sys||kqueue1(int flags); }
- SYS_PACCEPT = 456 // { int|sys||paccept(int s, struct sockaddr *name, socklen_t *anamelen, const sigset_t *mask, int flags); }
- SYS_LINKAT = 457 // { int|sys||linkat(int fd1, const char *name1, int fd2, const char *name2, int flags); }
- SYS_RENAMEAT = 458 // { int|sys||renameat(int fromfd, const char *from, int tofd, const char *to); }
- SYS_MKFIFOAT = 459 // { int|sys||mkfifoat(int fd, const char *path, mode_t mode); }
- SYS_MKNODAT = 460 // { int|sys||mknodat(int fd, const char *path, mode_t mode, uint32_t dev); }
- SYS_MKDIRAT = 461 // { int|sys||mkdirat(int fd, const char *path, mode_t mode); }
- SYS_FACCESSAT = 462 // { int|sys||faccessat(int fd, const char *path, int amode, int flag); }
- SYS_FCHMODAT = 463 // { int|sys||fchmodat(int fd, const char *path, mode_t mode, int flag); }
- SYS_FCHOWNAT = 464 // { int|sys||fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag); }
- SYS_FEXECVE = 465 // { int|sys||fexecve(int fd, char * const *argp, char * const *envp); }
- SYS_FSTATAT = 466 // { int|sys||fstatat(int fd, const char *path, struct stat *buf, int flag); }
- SYS_UTIMENSAT = 467 // { int|sys||utimensat(int fd, const char *path, const struct timespec *tptr, int flag); }
- SYS_OPENAT = 468 // { int|sys||openat(int fd, const char *path, int oflags, ... mode_t mode); }
- SYS_READLINKAT = 469 // { int|sys||readlinkat(int fd, const char *path, char *buf, size_t bufsize); }
- SYS_SYMLINKAT = 470 // { int|sys||symlinkat(const char *path1, int fd, const char *path2); }
- SYS_UNLINKAT = 471 // { int|sys||unlinkat(int fd, const char *path, int flag); }
- SYS_FUTIMENS = 472 // { int|sys||futimens(int fd, const struct timespec *tptr); }
- SYS___QUOTACTL = 473 // { int|sys||__quotactl(const char *path, struct quotactl_args *args); }
- SYS_POSIX_SPAWN = 474 // { int|sys||posix_spawn(pid_t *pid, const char *path, const struct posix_spawn_file_actions *file_actions, const struct posix_spawnattr *attrp, char *const *argv, char *const *envp); }
- SYS_RECVMMSG = 475 // { int|sys||recvmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags, struct timespec *timeout); }
- SYS_SENDMMSG = 476 // { int|sys||sendmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags); }
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go b/newt/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go
deleted file mode 100644
index 2de1d44e..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go
+++ /dev/null
@@ -1,447 +0,0 @@
-// +build 386,darwin
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_darwin.go
-
-package unix
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int32
- Nsec int32
-}
-
-type Timeval struct {
- Sec int32
- Usec int32
-}
-
-type Timeval32 struct{}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int32
- Ixrss int32
- Idrss int32
- Isrss int32
- Minflt int32
- Majflt int32
- Nswap int32
- Inblock int32
- Oublock int32
- Msgsnd int32
- Msgrcv int32
- Nsignals int32
- Nvcsw int32
- Nivcsw int32
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev int32
- Mode uint16
- Nlink uint16
- Ino uint64
- Uid uint32
- Gid uint32
- Rdev int32
- Atimespec Timespec
- Mtimespec Timespec
- Ctimespec Timespec
- Birthtimespec Timespec
- Size int64
- Blocks int64
- Blksize int32
- Flags uint32
- Gen uint32
- Lspare int32
- Qspare [2]int64
-}
-
-type Statfs_t struct {
- Bsize uint32
- Iosize int32
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Owner uint32
- Type uint32
- Flags uint32
- Fssubtype uint32
- Fstypename [16]int8
- Mntonname [1024]int8
- Mntfromname [1024]int8
- Reserved [8]uint32
-}
-
-type Flock_t struct {
- Start int64
- Len int64
- Pid int32
- Type int16
- Whence int16
-}
-
-type Fstore_t struct {
- Flags uint32
- Posmode int32
- Offset int64
- Length int64
- Bytesalloc int64
-}
-
-type Radvisory_t struct {
- Offset int64
- Count int32
-}
-
-type Fbootstraptransfer_t struct {
- Offset int64
- Length uint32
- Buffer *byte
-}
-
-type Log2phys_t struct {
- Flags uint32
- Contigbytes int64
- Devoffset int64
-}
-
-type Fsid struct {
- Val [2]int32
-}
-
-type Dirent struct {
- Ino uint64
- Seekoff uint64
- Reclen uint16
- Namlen uint16
- Type uint8
- Name [1024]int8
- Pad_cgo_0 [3]byte
-}
-
-type RawSockaddrInet4 struct {
- Len uint8
- Family uint8
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]int8
-}
-
-type RawSockaddrInet6 struct {
- Len uint8
- Family uint8
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Len uint8
- Family uint8
- Path [104]int8
-}
-
-type RawSockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [12]int8
-}
-
-type RawSockaddr struct {
- Len uint8
- Family uint8
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [92]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint32
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Iov *Iovec
- Iovlen int32
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
-}
-
-type Inet4Pktinfo struct {
- Ifindex uint32
- Spec_dst [4]byte /* in_addr */
- Addr [4]byte /* in_addr */
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Filt [8]uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x6c
- SizeofSockaddrUnix = 0x6a
- SizeofSockaddrDatalink = 0x14
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x1c
- SizeofCmsghdr = 0xc
- SizeofInet4Pktinfo = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
-)
-
-const (
- PTRACE_TRACEME = 0x0
- PTRACE_CONT = 0x7
- PTRACE_KILL = 0x8
-)
-
-type Kevent_t struct {
- Ident uint32
- Filter int16
- Flags uint16
- Fflags uint32
- Data int32
- Udata *byte
-}
-
-type FdSet struct {
- Bits [32]int32
-}
-
-const (
- SizeofIfMsghdr = 0x70
- SizeofIfData = 0x60
- SizeofIfaMsghdr = 0x14
- SizeofIfmaMsghdr = 0x10
- SizeofIfmaMsghdr2 = 0x14
- SizeofRtMsghdr = 0x5c
- SizeofRtMetrics = 0x38
-)
-
-type IfMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data IfData
-}
-
-type IfData struct {
- Type uint8
- Typelen uint8
- Physical uint8
- Addrlen uint8
- Hdrlen uint8
- Recvquota uint8
- Xmitquota uint8
- Unused1 uint8
- Mtu uint32
- Metric uint32
- Baudrate uint32
- Ipackets uint32
- Ierrors uint32
- Opackets uint32
- Oerrors uint32
- Collisions uint32
- Ibytes uint32
- Obytes uint32
- Imcasts uint32
- Omcasts uint32
- Iqdrops uint32
- Noproto uint32
- Recvtiming uint32
- Xmittiming uint32
- Lastchange Timeval
- Unused2 uint32
- Hwassist uint32
- Reserved1 uint32
- Reserved2 uint32
-}
-
-type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Metric int32
-}
-
-type IfmaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
-}
-
-type IfmaMsghdr2 struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Refcount int32
-}
-
-type RtMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Pad_cgo_0 [2]byte
- Flags int32
- Addrs int32
- Pid int32
- Seq int32
- Errno int32
- Use int32
- Inits uint32
- Rmx RtMetrics
-}
-
-type RtMetrics struct {
- Locks uint32
- Mtu uint32
- Hopcount uint32
- Expire int32
- Recvpipe uint32
- Sendpipe uint32
- Ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Pksent uint32
- Filler [4]uint32
-}
-
-const (
- SizeofBpfVersion = 0x4
- SizeofBpfStat = 0x8
- SizeofBpfProgram = 0x8
- SizeofBpfInsn = 0x8
- SizeofBpfHdr = 0x14
-)
-
-type BpfVersion struct {
- Major uint16
- Minor uint16
-}
-
-type BpfStat struct {
- Recv uint32
- Drop uint32
-}
-
-type BpfProgram struct {
- Len uint32
- Insns *BpfInsn
-}
-
-type BpfInsn struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type BpfHdr struct {
- Tstamp Timeval
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [2]byte
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed uint32
- Ospeed uint32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/newt/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go
deleted file mode 100644
index 04465787..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go
+++ /dev/null
@@ -1,462 +0,0 @@
-// +build amd64,darwin
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_darwin.go
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int32
- Pad_cgo_0 [4]byte
-}
-
-type Timeval32 struct {
- Sec int32
- Usec int32
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev int32
- Mode uint16
- Nlink uint16
- Ino uint64
- Uid uint32
- Gid uint32
- Rdev int32
- Pad_cgo_0 [4]byte
- Atimespec Timespec
- Mtimespec Timespec
- Ctimespec Timespec
- Birthtimespec Timespec
- Size int64
- Blocks int64
- Blksize int32
- Flags uint32
- Gen uint32
- Lspare int32
- Qspare [2]int64
-}
-
-type Statfs_t struct {
- Bsize uint32
- Iosize int32
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Owner uint32
- Type uint32
- Flags uint32
- Fssubtype uint32
- Fstypename [16]int8
- Mntonname [1024]int8
- Mntfromname [1024]int8
- Reserved [8]uint32
-}
-
-type Flock_t struct {
- Start int64
- Len int64
- Pid int32
- Type int16
- Whence int16
-}
-
-type Fstore_t struct {
- Flags uint32
- Posmode int32
- Offset int64
- Length int64
- Bytesalloc int64
-}
-
-type Radvisory_t struct {
- Offset int64
- Count int32
- Pad_cgo_0 [4]byte
-}
-
-type Fbootstraptransfer_t struct {
- Offset int64
- Length uint64
- Buffer *byte
-}
-
-type Log2phys_t struct {
- Flags uint32
- Pad_cgo_0 [8]byte
- Pad_cgo_1 [8]byte
-}
-
-type Fsid struct {
- Val [2]int32
-}
-
-type Dirent struct {
- Ino uint64
- Seekoff uint64
- Reclen uint16
- Namlen uint16
- Type uint8
- Name [1024]int8
- Pad_cgo_0 [3]byte
-}
-
-type RawSockaddrInet4 struct {
- Len uint8
- Family uint8
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]int8
-}
-
-type RawSockaddrInet6 struct {
- Len uint8
- Family uint8
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Len uint8
- Family uint8
- Path [104]int8
-}
-
-type RawSockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [12]int8
-}
-
-type RawSockaddr struct {
- Len uint8
- Family uint8
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [92]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Pad_cgo_0 [4]byte
- Iov *Iovec
- Iovlen int32
- Pad_cgo_1 [4]byte
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
-}
-
-type Inet4Pktinfo struct {
- Ifindex uint32
- Spec_dst [4]byte /* in_addr */
- Addr [4]byte /* in_addr */
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Filt [8]uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x6c
- SizeofSockaddrUnix = 0x6a
- SizeofSockaddrDatalink = 0x14
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x30
- SizeofCmsghdr = 0xc
- SizeofInet4Pktinfo = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
-)
-
-const (
- PTRACE_TRACEME = 0x0
- PTRACE_CONT = 0x7
- PTRACE_KILL = 0x8
-)
-
-type Kevent_t struct {
- Ident uint64
- Filter int16
- Flags uint16
- Fflags uint32
- Data int64
- Udata *byte
-}
-
-type FdSet struct {
- Bits [32]int32
-}
-
-const (
- SizeofIfMsghdr = 0x70
- SizeofIfData = 0x60
- SizeofIfaMsghdr = 0x14
- SizeofIfmaMsghdr = 0x10
- SizeofIfmaMsghdr2 = 0x14
- SizeofRtMsghdr = 0x5c
- SizeofRtMetrics = 0x38
-)
-
-type IfMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data IfData
-}
-
-type IfData struct {
- Type uint8
- Typelen uint8
- Physical uint8
- Addrlen uint8
- Hdrlen uint8
- Recvquota uint8
- Xmitquota uint8
- Unused1 uint8
- Mtu uint32
- Metric uint32
- Baudrate uint32
- Ipackets uint32
- Ierrors uint32
- Opackets uint32
- Oerrors uint32
- Collisions uint32
- Ibytes uint32
- Obytes uint32
- Imcasts uint32
- Omcasts uint32
- Iqdrops uint32
- Noproto uint32
- Recvtiming uint32
- Xmittiming uint32
- Lastchange Timeval32
- Unused2 uint32
- Hwassist uint32
- Reserved1 uint32
- Reserved2 uint32
-}
-
-type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Metric int32
-}
-
-type IfmaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
-}
-
-type IfmaMsghdr2 struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Refcount int32
-}
-
-type RtMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Pad_cgo_0 [2]byte
- Flags int32
- Addrs int32
- Pid int32
- Seq int32
- Errno int32
- Use int32
- Inits uint32
- Rmx RtMetrics
-}
-
-type RtMetrics struct {
- Locks uint32
- Mtu uint32
- Hopcount uint32
- Expire int32
- Recvpipe uint32
- Sendpipe uint32
- Ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Pksent uint32
- Filler [4]uint32
-}
-
-const (
- SizeofBpfVersion = 0x4
- SizeofBpfStat = 0x8
- SizeofBpfProgram = 0x10
- SizeofBpfInsn = 0x8
- SizeofBpfHdr = 0x14
-)
-
-type BpfVersion struct {
- Major uint16
- Minor uint16
-}
-
-type BpfStat struct {
- Recv uint32
- Drop uint32
-}
-
-type BpfProgram struct {
- Len uint32
- Pad_cgo_0 [4]byte
- Insns *BpfInsn
-}
-
-type BpfInsn struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type BpfHdr struct {
- Tstamp Timeval32
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [2]byte
-}
-
-type Termios struct {
- Iflag uint64
- Oflag uint64
- Cflag uint64
- Lflag uint64
- Cc [20]uint8
- Pad_cgo_0 [4]byte
- Ispeed uint64
- Ospeed uint64
-}
-
-const (
- AT_FDCWD = -0x2
- AT_SYMLINK_NOFOLLOW = 0x20
-)
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go b/newt/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go
deleted file mode 100644
index 66df363c..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go
+++ /dev/null
@@ -1,449 +0,0 @@
-// NOTE: cgo can't generate struct Stat_t and struct Statfs_t yet
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_darwin.go
-
-// +build arm,darwin
-
-package unix
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int32
- Nsec int32
-}
-
-type Timeval struct {
- Sec int32
- Usec int32
-}
-
-type Timeval32 [0]byte
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int32
- Ixrss int32
- Idrss int32
- Isrss int32
- Minflt int32
- Majflt int32
- Nswap int32
- Inblock int32
- Oublock int32
- Msgsnd int32
- Msgrcv int32
- Nsignals int32
- Nvcsw int32
- Nivcsw int32
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev int32
- Mode uint16
- Nlink uint16
- Ino uint64
- Uid uint32
- Gid uint32
- Rdev int32
- Atimespec Timespec
- Mtimespec Timespec
- Ctimespec Timespec
- Birthtimespec Timespec
- Size int64
- Blocks int64
- Blksize int32
- Flags uint32
- Gen uint32
- Lspare int32
- Qspare [2]int64
-}
-
-type Statfs_t struct {
- Bsize uint32
- Iosize int32
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Owner uint32
- Type uint32
- Flags uint32
- Fssubtype uint32
- Fstypename [16]int8
- Mntonname [1024]int8
- Mntfromname [1024]int8
- Reserved [8]uint32
-}
-
-type Flock_t struct {
- Start int64
- Len int64
- Pid int32
- Type int16
- Whence int16
-}
-
-type Fstore_t struct {
- Flags uint32
- Posmode int32
- Offset int64
- Length int64
- Bytesalloc int64
-}
-
-type Radvisory_t struct {
- Offset int64
- Count int32
-}
-
-type Fbootstraptransfer_t struct {
- Offset int64
- Length uint32
- Buffer *byte
-}
-
-type Log2phys_t struct {
- Flags uint32
- Contigbytes int64
- Devoffset int64
-}
-
-type Fsid struct {
- Val [2]int32
-}
-
-type Dirent struct {
- Ino uint64
- Seekoff uint64
- Reclen uint16
- Namlen uint16
- Type uint8
- Name [1024]int8
- Pad_cgo_0 [3]byte
-}
-
-type RawSockaddrInet4 struct {
- Len uint8
- Family uint8
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]int8
-}
-
-type RawSockaddrInet6 struct {
- Len uint8
- Family uint8
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Len uint8
- Family uint8
- Path [104]int8
-}
-
-type RawSockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [12]int8
-}
-
-type RawSockaddr struct {
- Len uint8
- Family uint8
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [92]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint32
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Iov *Iovec
- Iovlen int32
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
-}
-
-type Inet4Pktinfo struct {
- Ifindex uint32
- Spec_dst [4]byte /* in_addr */
- Addr [4]byte /* in_addr */
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Filt [8]uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x6c
- SizeofSockaddrUnix = 0x6a
- SizeofSockaddrDatalink = 0x14
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x1c
- SizeofCmsghdr = 0xc
- SizeofInet4Pktinfo = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
-)
-
-const (
- PTRACE_TRACEME = 0x0
- PTRACE_CONT = 0x7
- PTRACE_KILL = 0x8
-)
-
-type Kevent_t struct {
- Ident uint32
- Filter int16
- Flags uint16
- Fflags uint32
- Data int32
- Udata *byte
-}
-
-type FdSet struct {
- Bits [32]int32
-}
-
-const (
- SizeofIfMsghdr = 0x70
- SizeofIfData = 0x60
- SizeofIfaMsghdr = 0x14
- SizeofIfmaMsghdr = 0x10
- SizeofIfmaMsghdr2 = 0x14
- SizeofRtMsghdr = 0x5c
- SizeofRtMetrics = 0x38
-)
-
-type IfMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data IfData
-}
-
-type IfData struct {
- Type uint8
- Typelen uint8
- Physical uint8
- Addrlen uint8
- Hdrlen uint8
- Recvquota uint8
- Xmitquota uint8
- Unused1 uint8
- Mtu uint32
- Metric uint32
- Baudrate uint32
- Ipackets uint32
- Ierrors uint32
- Opackets uint32
- Oerrors uint32
- Collisions uint32
- Ibytes uint32
- Obytes uint32
- Imcasts uint32
- Omcasts uint32
- Iqdrops uint32
- Noproto uint32
- Recvtiming uint32
- Xmittiming uint32
- Lastchange Timeval
- Unused2 uint32
- Hwassist uint32
- Reserved1 uint32
- Reserved2 uint32
-}
-
-type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Metric int32
-}
-
-type IfmaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
-}
-
-type IfmaMsghdr2 struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Refcount int32
-}
-
-type RtMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Pad_cgo_0 [2]byte
- Flags int32
- Addrs int32
- Pid int32
- Seq int32
- Errno int32
- Use int32
- Inits uint32
- Rmx RtMetrics
-}
-
-type RtMetrics struct {
- Locks uint32
- Mtu uint32
- Hopcount uint32
- Expire int32
- Recvpipe uint32
- Sendpipe uint32
- Ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Pksent uint32
- Filler [4]uint32
-}
-
-const (
- SizeofBpfVersion = 0x4
- SizeofBpfStat = 0x8
- SizeofBpfProgram = 0x8
- SizeofBpfInsn = 0x8
- SizeofBpfHdr = 0x14
-)
-
-type BpfVersion struct {
- Major uint16
- Minor uint16
-}
-
-type BpfStat struct {
- Recv uint32
- Drop uint32
-}
-
-type BpfProgram struct {
- Len uint32
- Insns *BpfInsn
-}
-
-type BpfInsn struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type BpfHdr struct {
- Tstamp Timeval
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [2]byte
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed uint32
- Ospeed uint32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/newt/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go
deleted file mode 100644
index 85d56eab..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go
+++ /dev/null
@@ -1,457 +0,0 @@
-// +build arm64,darwin
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_darwin.go
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int32
- Pad_cgo_0 [4]byte
-}
-
-type Timeval32 struct {
- Sec int32
- Usec int32
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev int32
- Mode uint16
- Nlink uint16
- Ino uint64
- Uid uint32
- Gid uint32
- Rdev int32
- Pad_cgo_0 [4]byte
- Atimespec Timespec
- Mtimespec Timespec
- Ctimespec Timespec
- Birthtimespec Timespec
- Size int64
- Blocks int64
- Blksize int32
- Flags uint32
- Gen uint32
- Lspare int32
- Qspare [2]int64
-}
-
-type Statfs_t struct {
- Bsize uint32
- Iosize int32
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Owner uint32
- Type uint32
- Flags uint32
- Fssubtype uint32
- Fstypename [16]int8
- Mntonname [1024]int8
- Mntfromname [1024]int8
- Reserved [8]uint32
-}
-
-type Flock_t struct {
- Start int64
- Len int64
- Pid int32
- Type int16
- Whence int16
-}
-
-type Fstore_t struct {
- Flags uint32
- Posmode int32
- Offset int64
- Length int64
- Bytesalloc int64
-}
-
-type Radvisory_t struct {
- Offset int64
- Count int32
- Pad_cgo_0 [4]byte
-}
-
-type Fbootstraptransfer_t struct {
- Offset int64
- Length uint64
- Buffer *byte
-}
-
-type Log2phys_t struct {
- Flags uint32
- Pad_cgo_0 [8]byte
- Pad_cgo_1 [8]byte
-}
-
-type Fsid struct {
- Val [2]int32
-}
-
-type Dirent struct {
- Ino uint64
- Seekoff uint64
- Reclen uint16
- Namlen uint16
- Type uint8
- Name [1024]int8
- Pad_cgo_0 [3]byte
-}
-
-type RawSockaddrInet4 struct {
- Len uint8
- Family uint8
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]int8
-}
-
-type RawSockaddrInet6 struct {
- Len uint8
- Family uint8
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Len uint8
- Family uint8
- Path [104]int8
-}
-
-type RawSockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [12]int8
-}
-
-type RawSockaddr struct {
- Len uint8
- Family uint8
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [92]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Pad_cgo_0 [4]byte
- Iov *Iovec
- Iovlen int32
- Pad_cgo_1 [4]byte
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
-}
-
-type Inet4Pktinfo struct {
- Ifindex uint32
- Spec_dst [4]byte /* in_addr */
- Addr [4]byte /* in_addr */
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Filt [8]uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x6c
- SizeofSockaddrUnix = 0x6a
- SizeofSockaddrDatalink = 0x14
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x30
- SizeofCmsghdr = 0xc
- SizeofInet4Pktinfo = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
-)
-
-const (
- PTRACE_TRACEME = 0x0
- PTRACE_CONT = 0x7
- PTRACE_KILL = 0x8
-)
-
-type Kevent_t struct {
- Ident uint64
- Filter int16
- Flags uint16
- Fflags uint32
- Data int64
- Udata *byte
-}
-
-type FdSet struct {
- Bits [32]int32
-}
-
-const (
- SizeofIfMsghdr = 0x70
- SizeofIfData = 0x60
- SizeofIfaMsghdr = 0x14
- SizeofIfmaMsghdr = 0x10
- SizeofIfmaMsghdr2 = 0x14
- SizeofRtMsghdr = 0x5c
- SizeofRtMetrics = 0x38
-)
-
-type IfMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data IfData
-}
-
-type IfData struct {
- Type uint8
- Typelen uint8
- Physical uint8
- Addrlen uint8
- Hdrlen uint8
- Recvquota uint8
- Xmitquota uint8
- Unused1 uint8
- Mtu uint32
- Metric uint32
- Baudrate uint32
- Ipackets uint32
- Ierrors uint32
- Opackets uint32
- Oerrors uint32
- Collisions uint32
- Ibytes uint32
- Obytes uint32
- Imcasts uint32
- Omcasts uint32
- Iqdrops uint32
- Noproto uint32
- Recvtiming uint32
- Xmittiming uint32
- Lastchange Timeval32
- Unused2 uint32
- Hwassist uint32
- Reserved1 uint32
- Reserved2 uint32
-}
-
-type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Metric int32
-}
-
-type IfmaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
-}
-
-type IfmaMsghdr2 struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Refcount int32
-}
-
-type RtMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Pad_cgo_0 [2]byte
- Flags int32
- Addrs int32
- Pid int32
- Seq int32
- Errno int32
- Use int32
- Inits uint32
- Rmx RtMetrics
-}
-
-type RtMetrics struct {
- Locks uint32
- Mtu uint32
- Hopcount uint32
- Expire int32
- Recvpipe uint32
- Sendpipe uint32
- Ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Pksent uint32
- Filler [4]uint32
-}
-
-const (
- SizeofBpfVersion = 0x4
- SizeofBpfStat = 0x8
- SizeofBpfProgram = 0x10
- SizeofBpfInsn = 0x8
- SizeofBpfHdr = 0x14
-)
-
-type BpfVersion struct {
- Major uint16
- Minor uint16
-}
-
-type BpfStat struct {
- Recv uint32
- Drop uint32
-}
-
-type BpfProgram struct {
- Len uint32
- Pad_cgo_0 [4]byte
- Insns *BpfInsn
-}
-
-type BpfInsn struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type BpfHdr struct {
- Tstamp Timeval32
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [2]byte
-}
-
-type Termios struct {
- Iflag uint64
- Oflag uint64
- Cflag uint64
- Lflag uint64
- Cc [20]uint8
- Pad_cgo_0 [4]byte
- Ispeed uint64
- Ospeed uint64
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go b/newt/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go
deleted file mode 100644
index 8a6f4e1c..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go
+++ /dev/null
@@ -1,443 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_dragonfly.go
-
-// +build amd64,dragonfly
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur int64
- Max int64
-}
-
-type _Gid_t uint32
-
-const (
- S_IFMT = 0xf000
- S_IFIFO = 0x1000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFBLK = 0x6000
- S_IFREG = 0x8000
- S_IFLNK = 0xa000
- S_IFSOCK = 0xc000
- S_ISUID = 0x800
- S_ISGID = 0x400
- S_ISVTX = 0x200
- S_IRUSR = 0x100
- S_IWUSR = 0x80
- S_IXUSR = 0x40
-)
-
-type Stat_t struct {
- Ino uint64
- Nlink uint32
- Dev uint32
- Mode uint16
- Padding1 uint16
- Uid uint32
- Gid uint32
- Rdev uint32
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- Size int64
- Blocks int64
- Blksize uint32
- Flags uint32
- Gen uint32
- Lspare int32
- Qspare1 int64
- Qspare2 int64
-}
-
-type Statfs_t struct {
- Spare2 int64
- Bsize int64
- Iosize int64
- Blocks int64
- Bfree int64
- Bavail int64
- Files int64
- Ffree int64
- Fsid Fsid
- Owner uint32
- Type int32
- Flags int32
- Pad_cgo_0 [4]byte
- Syncwrites int64
- Asyncwrites int64
- Fstypename [16]int8
- Mntonname [80]int8
- Syncreads int64
- Asyncreads int64
- Spares1 int16
- Mntfromname [80]int8
- Spares2 int16
- Pad_cgo_1 [4]byte
- Spare [2]int64
-}
-
-type Flock_t struct {
- Start int64
- Len int64
- Pid int32
- Type int16
- Whence int16
-}
-
-type Dirent struct {
- Fileno uint64
- Namlen uint16
- Type uint8
- Unused1 uint8
- Unused2 uint32
- Name [256]int8
-}
-
-type Fsid struct {
- Val [2]int32
-}
-
-type RawSockaddrInet4 struct {
- Len uint8
- Family uint8
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]int8
-}
-
-type RawSockaddrInet6 struct {
- Len uint8
- Family uint8
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Len uint8
- Family uint8
- Path [104]int8
-}
-
-type RawSockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [12]int8
- Rcf uint16
- Route [16]uint16
-}
-
-type RawSockaddr struct {
- Len uint8
- Family uint8
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [92]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Pad_cgo_0 [4]byte
- Iov *Iovec
- Iovlen int32
- Pad_cgo_1 [4]byte
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Filt [8]uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x6c
- SizeofSockaddrUnix = 0x6a
- SizeofSockaddrDatalink = 0x36
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x30
- SizeofCmsghdr = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
-)
-
-const (
- PTRACE_TRACEME = 0x0
- PTRACE_CONT = 0x7
- PTRACE_KILL = 0x8
-)
-
-type Kevent_t struct {
- Ident uint64
- Filter int16
- Flags uint16
- Fflags uint32
- Data int64
- Udata *byte
-}
-
-type FdSet struct {
- Bits [16]uint64
-}
-
-const (
- SizeofIfMsghdr = 0xb0
- SizeofIfData = 0xa0
- SizeofIfaMsghdr = 0x14
- SizeofIfmaMsghdr = 0x10
- SizeofIfAnnounceMsghdr = 0x18
- SizeofRtMsghdr = 0x98
- SizeofRtMetrics = 0x70
-)
-
-type IfMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data IfData
-}
-
-type IfData struct {
- Type uint8
- Physical uint8
- Addrlen uint8
- Hdrlen uint8
- Recvquota uint8
- Xmitquota uint8
- Pad_cgo_0 [2]byte
- Mtu uint64
- Metric uint64
- Link_state uint64
- Baudrate uint64
- Ipackets uint64
- Ierrors uint64
- Opackets uint64
- Oerrors uint64
- Collisions uint64
- Ibytes uint64
- Obytes uint64
- Imcasts uint64
- Omcasts uint64
- Iqdrops uint64
- Noproto uint64
- Hwassist uint64
- Unused uint64
- Lastchange Timeval
-}
-
-type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Metric int32
-}
-
-type IfmaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
-}
-
-type IfAnnounceMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Name [16]int8
- What uint16
-}
-
-type RtMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Pad_cgo_0 [2]byte
- Flags int32
- Addrs int32
- Pid int32
- Seq int32
- Errno int32
- Use int32
- Inits uint64
- Rmx RtMetrics
-}
-
-type RtMetrics struct {
- Locks uint64
- Mtu uint64
- Pksent uint64
- Expire uint64
- Sendpipe uint64
- Ssthresh uint64
- Rtt uint64
- Rttvar uint64
- Recvpipe uint64
- Hopcount uint64
- Mssopt uint16
- Pad uint16
- Pad_cgo_0 [4]byte
- Msl uint64
- Iwmaxsegs uint64
- Iwcapsegs uint64
-}
-
-const (
- SizeofBpfVersion = 0x4
- SizeofBpfStat = 0x8
- SizeofBpfProgram = 0x10
- SizeofBpfInsn = 0x8
- SizeofBpfHdr = 0x20
-)
-
-type BpfVersion struct {
- Major uint16
- Minor uint16
-}
-
-type BpfStat struct {
- Recv uint32
- Drop uint32
-}
-
-type BpfProgram struct {
- Len uint32
- Pad_cgo_0 [4]byte
- Insns *BpfInsn
-}
-
-type BpfInsn struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type BpfHdr struct {
- Tstamp Timeval
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [6]byte
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed uint32
- Ospeed uint32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/newt/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go
deleted file mode 100644
index 8cf30947..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go
+++ /dev/null
@@ -1,502 +0,0 @@
-// +build 386,freebsd
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_freebsd.go
-
-package unix
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int32
- Nsec int32
-}
-
-type Timeval struct {
- Sec int32
- Usec int32
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int32
- Ixrss int32
- Idrss int32
- Isrss int32
- Minflt int32
- Majflt int32
- Nswap int32
- Inblock int32
- Oublock int32
- Msgsnd int32
- Msgrcv int32
- Nsignals int32
- Nvcsw int32
- Nivcsw int32
-}
-
-type Rlimit struct {
- Cur int64
- Max int64
-}
-
-type _Gid_t uint32
-
-const (
- S_IFMT = 0xf000
- S_IFIFO = 0x1000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFBLK = 0x6000
- S_IFREG = 0x8000
- S_IFLNK = 0xa000
- S_IFSOCK = 0xc000
- S_ISUID = 0x800
- S_ISGID = 0x400
- S_ISVTX = 0x200
- S_IRUSR = 0x100
- S_IWUSR = 0x80
- S_IXUSR = 0x40
-)
-
-type Stat_t struct {
- Dev uint32
- Ino uint32
- Mode uint16
- Nlink uint16
- Uid uint32
- Gid uint32
- Rdev uint32
- Atimespec Timespec
- Mtimespec Timespec
- Ctimespec Timespec
- Size int64
- Blocks int64
- Blksize uint32
- Flags uint32
- Gen uint32
- Lspare int32
- Birthtimespec Timespec
- Pad_cgo_0 [8]byte
-}
-
-type Statfs_t struct {
- Version uint32
- Type uint32
- Flags uint64
- Bsize uint64
- Iosize uint64
- Blocks uint64
- Bfree uint64
- Bavail int64
- Files uint64
- Ffree int64
- Syncwrites uint64
- Asyncwrites uint64
- Syncreads uint64
- Asyncreads uint64
- Spare [10]uint64
- Namemax uint32
- Owner uint32
- Fsid Fsid
- Charspare [80]int8
- Fstypename [16]int8
- Mntfromname [88]int8
- Mntonname [88]int8
-}
-
-type Flock_t struct {
- Start int64
- Len int64
- Pid int32
- Type int16
- Whence int16
- Sysid int32
-}
-
-type Dirent struct {
- Fileno uint32
- Reclen uint16
- Type uint8
- Namlen uint8
- Name [256]int8
-}
-
-type Fsid struct {
- Val [2]int32
-}
-
-const (
- FADV_NORMAL = 0x0
- FADV_RANDOM = 0x1
- FADV_SEQUENTIAL = 0x2
- FADV_WILLNEED = 0x3
- FADV_DONTNEED = 0x4
- FADV_NOREUSE = 0x5
-)
-
-type RawSockaddrInet4 struct {
- Len uint8
- Family uint8
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]int8
-}
-
-type RawSockaddrInet6 struct {
- Len uint8
- Family uint8
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Len uint8
- Family uint8
- Path [104]int8
-}
-
-type RawSockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [46]int8
-}
-
-type RawSockaddr struct {
- Len uint8
- Family uint8
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [92]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint32
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPMreqn struct {
- Multiaddr [4]byte /* in_addr */
- Address [4]byte /* in_addr */
- Ifindex int32
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Iov *Iovec
- Iovlen int32
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Filt [8]uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x6c
- SizeofSockaddrUnix = 0x6a
- SizeofSockaddrDatalink = 0x36
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPMreqn = 0xc
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x1c
- SizeofCmsghdr = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
-)
-
-const (
- PTRACE_TRACEME = 0x0
- PTRACE_CONT = 0x7
- PTRACE_KILL = 0x8
-)
-
-type Kevent_t struct {
- Ident uint32
- Filter int16
- Flags uint16
- Fflags uint32
- Data int32
- Udata *byte
-}
-
-type FdSet struct {
- X__fds_bits [32]uint32
-}
-
-const (
- sizeofIfMsghdr = 0x64
- SizeofIfMsghdr = 0x60
- sizeofIfData = 0x54
- SizeofIfData = 0x50
- SizeofIfaMsghdr = 0x14
- SizeofIfmaMsghdr = 0x10
- SizeofIfAnnounceMsghdr = 0x18
- SizeofRtMsghdr = 0x5c
- SizeofRtMetrics = 0x38
-)
-
-type ifMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data ifData
-}
-
-type IfMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data IfData
-}
-
-type ifData struct {
- Type uint8
- Physical uint8
- Addrlen uint8
- Hdrlen uint8
- Link_state uint8
- Vhid uint8
- Baudrate_pf uint8
- Datalen uint8
- Mtu uint32
- Metric uint32
- Baudrate uint32
- Ipackets uint32
- Ierrors uint32
- Opackets uint32
- Oerrors uint32
- Collisions uint32
- Ibytes uint32
- Obytes uint32
- Imcasts uint32
- Omcasts uint32
- Iqdrops uint32
- Noproto uint32
- Hwassist uint64
- Epoch int32
- Lastchange Timeval
-}
-
-type IfData struct {
- Type uint8
- Physical uint8
- Addrlen uint8
- Hdrlen uint8
- Link_state uint8
- Spare_char1 uint8
- Spare_char2 uint8
- Datalen uint8
- Mtu uint32
- Metric uint32
- Baudrate uint32
- Ipackets uint32
- Ierrors uint32
- Opackets uint32
- Oerrors uint32
- Collisions uint32
- Ibytes uint32
- Obytes uint32
- Imcasts uint32
- Omcasts uint32
- Iqdrops uint32
- Noproto uint32
- Hwassist uint32
- Epoch int32
- Lastchange Timeval
-}
-
-type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Metric int32
-}
-
-type IfmaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
-}
-
-type IfAnnounceMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Name [16]int8
- What uint16
-}
-
-type RtMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Pad_cgo_0 [2]byte
- Flags int32
- Addrs int32
- Pid int32
- Seq int32
- Errno int32
- Fmask int32
- Inits uint32
- Rmx RtMetrics
-}
-
-type RtMetrics struct {
- Locks uint32
- Mtu uint32
- Hopcount uint32
- Expire uint32
- Recvpipe uint32
- Sendpipe uint32
- Ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Pksent uint32
- Weight uint32
- Filler [3]uint32
-}
-
-const (
- SizeofBpfVersion = 0x4
- SizeofBpfStat = 0x8
- SizeofBpfZbuf = 0xc
- SizeofBpfProgram = 0x8
- SizeofBpfInsn = 0x8
- SizeofBpfHdr = 0x14
- SizeofBpfZbufHeader = 0x20
-)
-
-type BpfVersion struct {
- Major uint16
- Minor uint16
-}
-
-type BpfStat struct {
- Recv uint32
- Drop uint32
-}
-
-type BpfZbuf struct {
- Bufa *byte
- Bufb *byte
- Buflen uint32
-}
-
-type BpfProgram struct {
- Len uint32
- Insns *BpfInsn
-}
-
-type BpfInsn struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type BpfHdr struct {
- Tstamp Timeval
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [2]byte
-}
-
-type BpfZbufHeader struct {
- Kernel_gen uint32
- Kernel_len uint32
- User_gen uint32
- X_bzh_pad [5]uint32
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed uint32
- Ospeed uint32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/newt/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go
deleted file mode 100644
index e5feb207..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go
+++ /dev/null
@@ -1,505 +0,0 @@
-// +build amd64,freebsd
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_freebsd.go
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur int64
- Max int64
-}
-
-type _Gid_t uint32
-
-const (
- S_IFMT = 0xf000
- S_IFIFO = 0x1000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFBLK = 0x6000
- S_IFREG = 0x8000
- S_IFLNK = 0xa000
- S_IFSOCK = 0xc000
- S_ISUID = 0x800
- S_ISGID = 0x400
- S_ISVTX = 0x200
- S_IRUSR = 0x100
- S_IWUSR = 0x80
- S_IXUSR = 0x40
-)
-
-type Stat_t struct {
- Dev uint32
- Ino uint32
- Mode uint16
- Nlink uint16
- Uid uint32
- Gid uint32
- Rdev uint32
- Atimespec Timespec
- Mtimespec Timespec
- Ctimespec Timespec
- Size int64
- Blocks int64
- Blksize uint32
- Flags uint32
- Gen uint32
- Lspare int32
- Birthtimespec Timespec
-}
-
-type Statfs_t struct {
- Version uint32
- Type uint32
- Flags uint64
- Bsize uint64
- Iosize uint64
- Blocks uint64
- Bfree uint64
- Bavail int64
- Files uint64
- Ffree int64
- Syncwrites uint64
- Asyncwrites uint64
- Syncreads uint64
- Asyncreads uint64
- Spare [10]uint64
- Namemax uint32
- Owner uint32
- Fsid Fsid
- Charspare [80]int8
- Fstypename [16]int8
- Mntfromname [88]int8
- Mntonname [88]int8
-}
-
-type Flock_t struct {
- Start int64
- Len int64
- Pid int32
- Type int16
- Whence int16
- Sysid int32
- Pad_cgo_0 [4]byte
-}
-
-type Dirent struct {
- Fileno uint32
- Reclen uint16
- Type uint8
- Namlen uint8
- Name [256]int8
-}
-
-type Fsid struct {
- Val [2]int32
-}
-
-const (
- FADV_NORMAL = 0x0
- FADV_RANDOM = 0x1
- FADV_SEQUENTIAL = 0x2
- FADV_WILLNEED = 0x3
- FADV_DONTNEED = 0x4
- FADV_NOREUSE = 0x5
-)
-
-type RawSockaddrInet4 struct {
- Len uint8
- Family uint8
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]int8
-}
-
-type RawSockaddrInet6 struct {
- Len uint8
- Family uint8
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Len uint8
- Family uint8
- Path [104]int8
-}
-
-type RawSockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [46]int8
-}
-
-type RawSockaddr struct {
- Len uint8
- Family uint8
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [92]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPMreqn struct {
- Multiaddr [4]byte /* in_addr */
- Address [4]byte /* in_addr */
- Ifindex int32
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Pad_cgo_0 [4]byte
- Iov *Iovec
- Iovlen int32
- Pad_cgo_1 [4]byte
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Filt [8]uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x6c
- SizeofSockaddrUnix = 0x6a
- SizeofSockaddrDatalink = 0x36
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPMreqn = 0xc
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x30
- SizeofCmsghdr = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
-)
-
-const (
- PTRACE_TRACEME = 0x0
- PTRACE_CONT = 0x7
- PTRACE_KILL = 0x8
-)
-
-type Kevent_t struct {
- Ident uint64
- Filter int16
- Flags uint16
- Fflags uint32
- Data int64
- Udata *byte
-}
-
-type FdSet struct {
- X__fds_bits [16]uint64
-}
-
-const (
- sizeofIfMsghdr = 0xa8
- SizeofIfMsghdr = 0xa8
- sizeofIfData = 0x98
- SizeofIfData = 0x98
- SizeofIfaMsghdr = 0x14
- SizeofIfmaMsghdr = 0x10
- SizeofIfAnnounceMsghdr = 0x18
- SizeofRtMsghdr = 0x98
- SizeofRtMetrics = 0x70
-)
-
-type ifMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data ifData
-}
-
-type IfMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data IfData
-}
-
-type ifData struct {
- Type uint8
- Physical uint8
- Addrlen uint8
- Hdrlen uint8
- Link_state uint8
- Vhid uint8
- Baudrate_pf uint8
- Datalen uint8
- Mtu uint64
- Metric uint64
- Baudrate uint64
- Ipackets uint64
- Ierrors uint64
- Opackets uint64
- Oerrors uint64
- Collisions uint64
- Ibytes uint64
- Obytes uint64
- Imcasts uint64
- Omcasts uint64
- Iqdrops uint64
- Noproto uint64
- Hwassist uint64
- Epoch int64
- Lastchange Timeval
-}
-
-type IfData struct {
- Type uint8
- Physical uint8
- Addrlen uint8
- Hdrlen uint8
- Link_state uint8
- Spare_char1 uint8
- Spare_char2 uint8
- Datalen uint8
- Mtu uint64
- Metric uint64
- Baudrate uint64
- Ipackets uint64
- Ierrors uint64
- Opackets uint64
- Oerrors uint64
- Collisions uint64
- Ibytes uint64
- Obytes uint64
- Imcasts uint64
- Omcasts uint64
- Iqdrops uint64
- Noproto uint64
- Hwassist uint64
- Epoch int64
- Lastchange Timeval
-}
-
-type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Metric int32
-}
-
-type IfmaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
-}
-
-type IfAnnounceMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Name [16]int8
- What uint16
-}
-
-type RtMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Pad_cgo_0 [2]byte
- Flags int32
- Addrs int32
- Pid int32
- Seq int32
- Errno int32
- Fmask int32
- Inits uint64
- Rmx RtMetrics
-}
-
-type RtMetrics struct {
- Locks uint64
- Mtu uint64
- Hopcount uint64
- Expire uint64
- Recvpipe uint64
- Sendpipe uint64
- Ssthresh uint64
- Rtt uint64
- Rttvar uint64
- Pksent uint64
- Weight uint64
- Filler [3]uint64
-}
-
-const (
- SizeofBpfVersion = 0x4
- SizeofBpfStat = 0x8
- SizeofBpfZbuf = 0x18
- SizeofBpfProgram = 0x10
- SizeofBpfInsn = 0x8
- SizeofBpfHdr = 0x20
- SizeofBpfZbufHeader = 0x20
-)
-
-type BpfVersion struct {
- Major uint16
- Minor uint16
-}
-
-type BpfStat struct {
- Recv uint32
- Drop uint32
-}
-
-type BpfZbuf struct {
- Bufa *byte
- Bufb *byte
- Buflen uint64
-}
-
-type BpfProgram struct {
- Len uint32
- Pad_cgo_0 [4]byte
- Insns *BpfInsn
-}
-
-type BpfInsn struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type BpfHdr struct {
- Tstamp Timeval
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [6]byte
-}
-
-type BpfZbufHeader struct {
- Kernel_gen uint32
- Kernel_len uint32
- User_gen uint32
- X_bzh_pad [5]uint32
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed uint32
- Ospeed uint32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/newt/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go
deleted file mode 100644
index 5472b542..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go
+++ /dev/null
@@ -1,497 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -fsigned-char types_freebsd.go
-
-// +build arm,freebsd
-
-package unix
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int32
- Pad_cgo_0 [4]byte
-}
-
-type Timeval struct {
- Sec int64
- Usec int32
- Pad_cgo_0 [4]byte
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int32
- Ixrss int32
- Idrss int32
- Isrss int32
- Minflt int32
- Majflt int32
- Nswap int32
- Inblock int32
- Oublock int32
- Msgsnd int32
- Msgrcv int32
- Nsignals int32
- Nvcsw int32
- Nivcsw int32
-}
-
-type Rlimit struct {
- Cur int64
- Max int64
-}
-
-type _Gid_t uint32
-
-const (
- S_IFMT = 0xf000
- S_IFIFO = 0x1000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFBLK = 0x6000
- S_IFREG = 0x8000
- S_IFLNK = 0xa000
- S_IFSOCK = 0xc000
- S_ISUID = 0x800
- S_ISGID = 0x400
- S_ISVTX = 0x200
- S_IRUSR = 0x100
- S_IWUSR = 0x80
- S_IXUSR = 0x40
-)
-
-type Stat_t struct {
- Dev uint32
- Ino uint32
- Mode uint16
- Nlink uint16
- Uid uint32
- Gid uint32
- Rdev uint32
- Atimespec Timespec
- Mtimespec Timespec
- Ctimespec Timespec
- Size int64
- Blocks int64
- Blksize uint32
- Flags uint32
- Gen uint32
- Lspare int32
- Birthtimespec Timespec
-}
-
-type Statfs_t struct {
- Version uint32
- Type uint32
- Flags uint64
- Bsize uint64
- Iosize uint64
- Blocks uint64
- Bfree uint64
- Bavail int64
- Files uint64
- Ffree int64
- Syncwrites uint64
- Asyncwrites uint64
- Syncreads uint64
- Asyncreads uint64
- Spare [10]uint64
- Namemax uint32
- Owner uint32
- Fsid Fsid
- Charspare [80]int8
- Fstypename [16]int8
- Mntfromname [88]int8
- Mntonname [88]int8
-}
-
-type Flock_t struct {
- Start int64
- Len int64
- Pid int32
- Type int16
- Whence int16
- Sysid int32
- Pad_cgo_0 [4]byte
-}
-
-type Dirent struct {
- Fileno uint32
- Reclen uint16
- Type uint8
- Namlen uint8
- Name [256]int8
-}
-
-type Fsid struct {
- Val [2]int32
-}
-
-type RawSockaddrInet4 struct {
- Len uint8
- Family uint8
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]int8
-}
-
-type RawSockaddrInet6 struct {
- Len uint8
- Family uint8
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Len uint8
- Family uint8
- Path [104]int8
-}
-
-type RawSockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [46]int8
-}
-
-type RawSockaddr struct {
- Len uint8
- Family uint8
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [92]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint32
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPMreqn struct {
- Multiaddr [4]byte /* in_addr */
- Address [4]byte /* in_addr */
- Ifindex int32
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Iov *Iovec
- Iovlen int32
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Filt [8]uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x6c
- SizeofSockaddrUnix = 0x6a
- SizeofSockaddrDatalink = 0x36
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPMreqn = 0xc
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x1c
- SizeofCmsghdr = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
-)
-
-const (
- PTRACE_TRACEME = 0x0
- PTRACE_CONT = 0x7
- PTRACE_KILL = 0x8
-)
-
-type Kevent_t struct {
- Ident uint32
- Filter int16
- Flags uint16
- Fflags uint32
- Data int32
- Udata *byte
-}
-
-type FdSet struct {
- X__fds_bits [32]uint32
-}
-
-const (
- sizeofIfMsghdr = 0x70
- SizeofIfMsghdr = 0x70
- sizeofIfData = 0x60
- SizeofIfData = 0x60
- SizeofIfaMsghdr = 0x14
- SizeofIfmaMsghdr = 0x10
- SizeofIfAnnounceMsghdr = 0x18
- SizeofRtMsghdr = 0x5c
- SizeofRtMetrics = 0x38
-)
-
-type ifMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data ifData
-}
-
-type IfMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data IfData
-}
-
-type ifData struct {
- Type uint8
- Physical uint8
- Addrlen uint8
- Hdrlen uint8
- Link_state uint8
- Vhid uint8
- Baudrate_pf uint8
- Datalen uint8
- Mtu uint32
- Metric uint32
- Baudrate uint32
- Ipackets uint32
- Ierrors uint32
- Opackets uint32
- Oerrors uint32
- Collisions uint32
- Ibytes uint32
- Obytes uint32
- Imcasts uint32
- Omcasts uint32
- Iqdrops uint32
- Noproto uint32
- Hwassist uint64
- Epoch int64
- Lastchange Timeval
-}
-
-type IfData struct {
- Type uint8
- Physical uint8
- Addrlen uint8
- Hdrlen uint8
- Link_state uint8
- Spare_char1 uint8
- Spare_char2 uint8
- Datalen uint8
- Mtu uint32
- Metric uint32
- Baudrate uint32
- Ipackets uint32
- Ierrors uint32
- Opackets uint32
- Oerrors uint32
- Collisions uint32
- Ibytes uint32
- Obytes uint32
- Imcasts uint32
- Omcasts uint32
- Iqdrops uint32
- Noproto uint32
- Hwassist uint32
- Pad_cgo_0 [4]byte
- Epoch int64
- Lastchange Timeval
-}
-
-type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Metric int32
-}
-
-type IfmaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
-}
-
-type IfAnnounceMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Name [16]int8
- What uint16
-}
-
-type RtMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Pad_cgo_0 [2]byte
- Flags int32
- Addrs int32
- Pid int32
- Seq int32
- Errno int32
- Fmask int32
- Inits uint32
- Rmx RtMetrics
-}
-
-type RtMetrics struct {
- Locks uint32
- Mtu uint32
- Hopcount uint32
- Expire uint32
- Recvpipe uint32
- Sendpipe uint32
- Ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Pksent uint32
- Weight uint32
- Filler [3]uint32
-}
-
-const (
- SizeofBpfVersion = 0x4
- SizeofBpfStat = 0x8
- SizeofBpfZbuf = 0xc
- SizeofBpfProgram = 0x8
- SizeofBpfInsn = 0x8
- SizeofBpfHdr = 0x20
- SizeofBpfZbufHeader = 0x20
-)
-
-type BpfVersion struct {
- Major uint16
- Minor uint16
-}
-
-type BpfStat struct {
- Recv uint32
- Drop uint32
-}
-
-type BpfZbuf struct {
- Bufa *byte
- Bufb *byte
- Buflen uint32
-}
-
-type BpfProgram struct {
- Len uint32
- Insns *BpfInsn
-}
-
-type BpfInsn struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type BpfHdr struct {
- Tstamp Timeval
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [6]byte
-}
-
-type BpfZbufHeader struct {
- Kernel_gen uint32
- Kernel_len uint32
- User_gen uint32
- X_bzh_pad [5]uint32
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed uint32
- Ospeed uint32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/newt/vendor/golang.org/x/sys/unix/ztypes_linux_386.go
deleted file mode 100644
index f3ddf534..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_386.go
+++ /dev/null
@@ -1,627 +0,0 @@
-// +build 386,linux
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go
-
-package unix
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
- PathMax = 0x1000
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int32
- Nsec int32
-}
-
-type Timeval struct {
- Sec int32
- Usec int32
-}
-
-type Timex struct {
- Modes uint32
- Offset int32
- Freq int32
- Maxerror int32
- Esterror int32
- Status int32
- Constant int32
- Precision int32
- Tolerance int32
- Time Timeval
- Tick int32
- Ppsfreq int32
- Jitter int32
- Shift int32
- Stabil int32
- Jitcnt int32
- Calcnt int32
- Errcnt int32
- Stbcnt int32
- Tai int32
- Pad_cgo_0 [44]byte
-}
-
-type Time_t int32
-
-type Tms struct {
- Utime int32
- Stime int32
- Cutime int32
- Cstime int32
-}
-
-type Utimbuf struct {
- Actime int32
- Modtime int32
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int32
- Ixrss int32
- Idrss int32
- Isrss int32
- Minflt int32
- Majflt int32
- Nswap int32
- Inblock int32
- Oublock int32
- Msgsnd int32
- Msgrcv int32
- Nsignals int32
- Nvcsw int32
- Nivcsw int32
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev uint64
- X__pad1 uint16
- Pad_cgo_0 [2]byte
- X__st_ino uint32
- Mode uint32
- Nlink uint32
- Uid uint32
- Gid uint32
- Rdev uint64
- X__pad2 uint16
- Pad_cgo_1 [2]byte
- Size int64
- Blksize int32
- Blocks int64
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- Ino uint64
-}
-
-type Statfs_t struct {
- Type int32
- Bsize int32
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Namelen int32
- Frsize int32
- Flags int32
- Spare [4]int32
-}
-
-type Dirent struct {
- Ino uint64
- Off int64
- Reclen uint16
- Type uint8
- Name [256]int8
- Pad_cgo_0 [1]byte
-}
-
-type Fsid struct {
- X__val [2]int32
-}
-
-type Flock_t struct {
- Type int16
- Whence int16
- Start int64
- Len int64
- Pid int32
-}
-
-const (
- FADV_NORMAL = 0x0
- FADV_RANDOM = 0x1
- FADV_SEQUENTIAL = 0x2
- FADV_WILLNEED = 0x3
- FADV_DONTNEED = 0x4
- FADV_NOREUSE = 0x5
-)
-
-type RawSockaddrInet4 struct {
- Family uint16
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]uint8
-}
-
-type RawSockaddrInet6 struct {
- Family uint16
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Family uint16
- Path [108]int8
-}
-
-type RawSockaddrLinklayer struct {
- Family uint16
- Protocol uint16
- Ifindex int32
- Hatype uint16
- Pkttype uint8
- Halen uint8
- Addr [8]uint8
-}
-
-type RawSockaddrNetlink struct {
- Family uint16
- Pad uint16
- Pid uint32
- Groups uint32
-}
-
-type RawSockaddrHCI struct {
- Family uint16
- Dev uint16
- Channel uint16
-}
-
-type RawSockaddr struct {
- Family uint16
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [96]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint32
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPMreqn struct {
- Multiaddr [4]byte /* in_addr */
- Address [4]byte /* in_addr */
- Ifindex int32
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Iov *Iovec
- Iovlen uint32
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
- X__cmsg_data [0]uint8
-}
-
-type Inet4Pktinfo struct {
- Ifindex int32
- Spec_dst [4]byte /* in_addr */
- Addr [4]byte /* in_addr */
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Data [8]uint32
-}
-
-type Ucred struct {
- Pid int32
- Uid uint32
- Gid uint32
-}
-
-type TCPInfo struct {
- State uint8
- Ca_state uint8
- Retransmits uint8
- Probes uint8
- Backoff uint8
- Options uint8
- Pad_cgo_0 [2]byte
- Rto uint32
- Ato uint32
- Snd_mss uint32
- Rcv_mss uint32
- Unacked uint32
- Sacked uint32
- Lost uint32
- Retrans uint32
- Fackets uint32
- Last_data_sent uint32
- Last_ack_sent uint32
- Last_data_recv uint32
- Last_ack_recv uint32
- Pmtu uint32
- Rcv_ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Snd_ssthresh uint32
- Snd_cwnd uint32
- Advmss uint32
- Reordering uint32
- Rcv_rtt uint32
- Rcv_space uint32
- Total_retrans uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x70
- SizeofSockaddrUnix = 0x6e
- SizeofSockaddrLinklayer = 0x14
- SizeofSockaddrNetlink = 0xc
- SizeofSockaddrHCI = 0x6
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPMreqn = 0xc
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x1c
- SizeofCmsghdr = 0xc
- SizeofInet4Pktinfo = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
- SizeofUcred = 0xc
- SizeofTCPInfo = 0x68
-)
-
-const (
- IFA_UNSPEC = 0x0
- IFA_ADDRESS = 0x1
- IFA_LOCAL = 0x2
- IFA_LABEL = 0x3
- IFA_BROADCAST = 0x4
- IFA_ANYCAST = 0x5
- IFA_CACHEINFO = 0x6
- IFA_MULTICAST = 0x7
- IFLA_UNSPEC = 0x0
- IFLA_ADDRESS = 0x1
- IFLA_BROADCAST = 0x2
- IFLA_IFNAME = 0x3
- IFLA_MTU = 0x4
- IFLA_LINK = 0x5
- IFLA_QDISC = 0x6
- IFLA_STATS = 0x7
- IFLA_COST = 0x8
- IFLA_PRIORITY = 0x9
- IFLA_MASTER = 0xa
- IFLA_WIRELESS = 0xb
- IFLA_PROTINFO = 0xc
- IFLA_TXQLEN = 0xd
- IFLA_MAP = 0xe
- IFLA_WEIGHT = 0xf
- IFLA_OPERSTATE = 0x10
- IFLA_LINKMODE = 0x11
- IFLA_LINKINFO = 0x12
- IFLA_NET_NS_PID = 0x13
- IFLA_IFALIAS = 0x14
- IFLA_MAX = 0x1d
- RT_SCOPE_UNIVERSE = 0x0
- RT_SCOPE_SITE = 0xc8
- RT_SCOPE_LINK = 0xfd
- RT_SCOPE_HOST = 0xfe
- RT_SCOPE_NOWHERE = 0xff
- RT_TABLE_UNSPEC = 0x0
- RT_TABLE_COMPAT = 0xfc
- RT_TABLE_DEFAULT = 0xfd
- RT_TABLE_MAIN = 0xfe
- RT_TABLE_LOCAL = 0xff
- RT_TABLE_MAX = 0xffffffff
- RTA_UNSPEC = 0x0
- RTA_DST = 0x1
- RTA_SRC = 0x2
- RTA_IIF = 0x3
- RTA_OIF = 0x4
- RTA_GATEWAY = 0x5
- RTA_PRIORITY = 0x6
- RTA_PREFSRC = 0x7
- RTA_METRICS = 0x8
- RTA_MULTIPATH = 0x9
- RTA_FLOW = 0xb
- RTA_CACHEINFO = 0xc
- RTA_TABLE = 0xf
- RTN_UNSPEC = 0x0
- RTN_UNICAST = 0x1
- RTN_LOCAL = 0x2
- RTN_BROADCAST = 0x3
- RTN_ANYCAST = 0x4
- RTN_MULTICAST = 0x5
- RTN_BLACKHOLE = 0x6
- RTN_UNREACHABLE = 0x7
- RTN_PROHIBIT = 0x8
- RTN_THROW = 0x9
- RTN_NAT = 0xa
- RTN_XRESOLVE = 0xb
- RTNLGRP_NONE = 0x0
- RTNLGRP_LINK = 0x1
- RTNLGRP_NOTIFY = 0x2
- RTNLGRP_NEIGH = 0x3
- RTNLGRP_TC = 0x4
- RTNLGRP_IPV4_IFADDR = 0x5
- RTNLGRP_IPV4_MROUTE = 0x6
- RTNLGRP_IPV4_ROUTE = 0x7
- RTNLGRP_IPV4_RULE = 0x8
- RTNLGRP_IPV6_IFADDR = 0x9
- RTNLGRP_IPV6_MROUTE = 0xa
- RTNLGRP_IPV6_ROUTE = 0xb
- RTNLGRP_IPV6_IFINFO = 0xc
- RTNLGRP_IPV6_PREFIX = 0x12
- RTNLGRP_IPV6_RULE = 0x13
- RTNLGRP_ND_USEROPT = 0x14
- SizeofNlMsghdr = 0x10
- SizeofNlMsgerr = 0x14
- SizeofRtGenmsg = 0x1
- SizeofNlAttr = 0x4
- SizeofRtAttr = 0x4
- SizeofIfInfomsg = 0x10
- SizeofIfAddrmsg = 0x8
- SizeofRtMsg = 0xc
- SizeofRtNexthop = 0x8
-)
-
-type NlMsghdr struct {
- Len uint32
- Type uint16
- Flags uint16
- Seq uint32
- Pid uint32
-}
-
-type NlMsgerr struct {
- Error int32
- Msg NlMsghdr
-}
-
-type RtGenmsg struct {
- Family uint8
-}
-
-type NlAttr struct {
- Len uint16
- Type uint16
-}
-
-type RtAttr struct {
- Len uint16
- Type uint16
-}
-
-type IfInfomsg struct {
- Family uint8
- X__ifi_pad uint8
- Type uint16
- Index int32
- Flags uint32
- Change uint32
-}
-
-type IfAddrmsg struct {
- Family uint8
- Prefixlen uint8
- Flags uint8
- Scope uint8
- Index uint32
-}
-
-type RtMsg struct {
- Family uint8
- Dst_len uint8
- Src_len uint8
- Tos uint8
- Table uint8
- Protocol uint8
- Scope uint8
- Type uint8
- Flags uint32
-}
-
-type RtNexthop struct {
- Len uint16
- Flags uint8
- Hops uint8
- Ifindex int32
-}
-
-const (
- SizeofSockFilter = 0x8
- SizeofSockFprog = 0x8
-)
-
-type SockFilter struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type SockFprog struct {
- Len uint16
- Pad_cgo_0 [2]byte
- Filter *SockFilter
-}
-
-type InotifyEvent struct {
- Wd int32
- Mask uint32
- Cookie uint32
- Len uint32
- Name [0]int8
-}
-
-const SizeofInotifyEvent = 0x10
-
-type PtraceRegs struct {
- Ebx int32
- Ecx int32
- Edx int32
- Esi int32
- Edi int32
- Ebp int32
- Eax int32
- Xds int32
- Xes int32
- Xfs int32
- Xgs int32
- Orig_eax int32
- Eip int32
- Xcs int32
- Eflags int32
- Esp int32
- Xss int32
-}
-
-type FdSet struct {
- Bits [32]int32
-}
-
-type Sysinfo_t struct {
- Uptime int32
- Loads [3]uint32
- Totalram uint32
- Freeram uint32
- Sharedram uint32
- Bufferram uint32
- Totalswap uint32
- Freeswap uint32
- Procs uint16
- Pad uint16
- Totalhigh uint32
- Freehigh uint32
- Unit uint32
- X_f [8]int8
-}
-
-type Utsname struct {
- Sysname [65]int8
- Nodename [65]int8
- Release [65]int8
- Version [65]int8
- Machine [65]int8
- Domainname [65]int8
-}
-
-type Ustat_t struct {
- Tfree int32
- Tinode uint32
- Fname [6]int8
- Fpack [6]int8
-}
-
-type EpollEvent struct {
- Events uint32
- Fd int32
- Pad int32
-}
-
-const (
- AT_FDCWD = -0x64
- AT_REMOVEDIR = 0x200
- AT_SYMLINK_FOLLOW = 0x400
- AT_SYMLINK_NOFOLLOW = 0x100
-)
-
-type PollFd struct {
- Fd int32
- Events int16
- Revents int16
-}
-
-const (
- POLLIN = 0x1
- POLLPRI = 0x2
- POLLOUT = 0x4
- POLLRDHUP = 0x2000
- POLLERR = 0x8
- POLLHUP = 0x10
- POLLNVAL = 0x20
-)
-
-type Sigset_t struct {
- X__val [16]uint64
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Line uint8
- Cc [19]uint8
- Ispeed uint32
- Ospeed uint32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/newt/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go
deleted file mode 100644
index a923bef3..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go
+++ /dev/null
@@ -1,645 +0,0 @@
-// +build amd64,linux
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- PathMax = 0x1000
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Timex struct {
- Modes uint32
- Pad_cgo_0 [4]byte
- Offset int64
- Freq int64
- Maxerror int64
- Esterror int64
- Status int32
- Pad_cgo_1 [4]byte
- Constant int64
- Precision int64
- Tolerance int64
- Time Timeval
- Tick int64
- Ppsfreq int64
- Jitter int64
- Shift int32
- Pad_cgo_2 [4]byte
- Stabil int64
- Jitcnt int64
- Calcnt int64
- Errcnt int64
- Stbcnt int64
- Tai int32
- Pad_cgo_3 [44]byte
-}
-
-type Time_t int64
-
-type Tms struct {
- Utime int64
- Stime int64
- Cutime int64
- Cstime int64
-}
-
-type Utimbuf struct {
- Actime int64
- Modtime int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev uint64
- Ino uint64
- Nlink uint64
- Mode uint32
- Uid uint32
- Gid uint32
- X__pad0 int32
- Rdev uint64
- Size int64
- Blksize int64
- Blocks int64
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- X__unused [3]int64
-}
-
-type Statfs_t struct {
- Type int64
- Bsize int64
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Namelen int64
- Frsize int64
- Flags int64
- Spare [4]int64
-}
-
-type Dirent struct {
- Ino uint64
- Off int64
- Reclen uint16
- Type uint8
- Name [256]int8
- Pad_cgo_0 [5]byte
-}
-
-type Fsid struct {
- X__val [2]int32
-}
-
-type Flock_t struct {
- Type int16
- Whence int16
- Pad_cgo_0 [4]byte
- Start int64
- Len int64
- Pid int32
- Pad_cgo_1 [4]byte
-}
-
-const (
- FADV_NORMAL = 0x0
- FADV_RANDOM = 0x1
- FADV_SEQUENTIAL = 0x2
- FADV_WILLNEED = 0x3
- FADV_DONTNEED = 0x4
- FADV_NOREUSE = 0x5
-)
-
-type RawSockaddrInet4 struct {
- Family uint16
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]uint8
-}
-
-type RawSockaddrInet6 struct {
- Family uint16
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Family uint16
- Path [108]int8
-}
-
-type RawSockaddrLinklayer struct {
- Family uint16
- Protocol uint16
- Ifindex int32
- Hatype uint16
- Pkttype uint8
- Halen uint8
- Addr [8]uint8
-}
-
-type RawSockaddrNetlink struct {
- Family uint16
- Pad uint16
- Pid uint32
- Groups uint32
-}
-
-type RawSockaddrHCI struct {
- Family uint16
- Dev uint16
- Channel uint16
-}
-
-type RawSockaddr struct {
- Family uint16
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [96]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPMreqn struct {
- Multiaddr [4]byte /* in_addr */
- Address [4]byte /* in_addr */
- Ifindex int32
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Pad_cgo_0 [4]byte
- Iov *Iovec
- Iovlen uint64
- Control *byte
- Controllen uint64
- Flags int32
- Pad_cgo_1 [4]byte
-}
-
-type Cmsghdr struct {
- Len uint64
- Level int32
- Type int32
- X__cmsg_data [0]uint8
-}
-
-type Inet4Pktinfo struct {
- Ifindex int32
- Spec_dst [4]byte /* in_addr */
- Addr [4]byte /* in_addr */
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Data [8]uint32
-}
-
-type Ucred struct {
- Pid int32
- Uid uint32
- Gid uint32
-}
-
-type TCPInfo struct {
- State uint8
- Ca_state uint8
- Retransmits uint8
- Probes uint8
- Backoff uint8
- Options uint8
- Pad_cgo_0 [2]byte
- Rto uint32
- Ato uint32
- Snd_mss uint32
- Rcv_mss uint32
- Unacked uint32
- Sacked uint32
- Lost uint32
- Retrans uint32
- Fackets uint32
- Last_data_sent uint32
- Last_ack_sent uint32
- Last_data_recv uint32
- Last_ack_recv uint32
- Pmtu uint32
- Rcv_ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Snd_ssthresh uint32
- Snd_cwnd uint32
- Advmss uint32
- Reordering uint32
- Rcv_rtt uint32
- Rcv_space uint32
- Total_retrans uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x70
- SizeofSockaddrUnix = 0x6e
- SizeofSockaddrLinklayer = 0x14
- SizeofSockaddrNetlink = 0xc
- SizeofSockaddrHCI = 0x6
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPMreqn = 0xc
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x38
- SizeofCmsghdr = 0x10
- SizeofInet4Pktinfo = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
- SizeofUcred = 0xc
- SizeofTCPInfo = 0x68
-)
-
-const (
- IFA_UNSPEC = 0x0
- IFA_ADDRESS = 0x1
- IFA_LOCAL = 0x2
- IFA_LABEL = 0x3
- IFA_BROADCAST = 0x4
- IFA_ANYCAST = 0x5
- IFA_CACHEINFO = 0x6
- IFA_MULTICAST = 0x7
- IFLA_UNSPEC = 0x0
- IFLA_ADDRESS = 0x1
- IFLA_BROADCAST = 0x2
- IFLA_IFNAME = 0x3
- IFLA_MTU = 0x4
- IFLA_LINK = 0x5
- IFLA_QDISC = 0x6
- IFLA_STATS = 0x7
- IFLA_COST = 0x8
- IFLA_PRIORITY = 0x9
- IFLA_MASTER = 0xa
- IFLA_WIRELESS = 0xb
- IFLA_PROTINFO = 0xc
- IFLA_TXQLEN = 0xd
- IFLA_MAP = 0xe
- IFLA_WEIGHT = 0xf
- IFLA_OPERSTATE = 0x10
- IFLA_LINKMODE = 0x11
- IFLA_LINKINFO = 0x12
- IFLA_NET_NS_PID = 0x13
- IFLA_IFALIAS = 0x14
- IFLA_MAX = 0x1d
- RT_SCOPE_UNIVERSE = 0x0
- RT_SCOPE_SITE = 0xc8
- RT_SCOPE_LINK = 0xfd
- RT_SCOPE_HOST = 0xfe
- RT_SCOPE_NOWHERE = 0xff
- RT_TABLE_UNSPEC = 0x0
- RT_TABLE_COMPAT = 0xfc
- RT_TABLE_DEFAULT = 0xfd
- RT_TABLE_MAIN = 0xfe
- RT_TABLE_LOCAL = 0xff
- RT_TABLE_MAX = 0xffffffff
- RTA_UNSPEC = 0x0
- RTA_DST = 0x1
- RTA_SRC = 0x2
- RTA_IIF = 0x3
- RTA_OIF = 0x4
- RTA_GATEWAY = 0x5
- RTA_PRIORITY = 0x6
- RTA_PREFSRC = 0x7
- RTA_METRICS = 0x8
- RTA_MULTIPATH = 0x9
- RTA_FLOW = 0xb
- RTA_CACHEINFO = 0xc
- RTA_TABLE = 0xf
- RTN_UNSPEC = 0x0
- RTN_UNICAST = 0x1
- RTN_LOCAL = 0x2
- RTN_BROADCAST = 0x3
- RTN_ANYCAST = 0x4
- RTN_MULTICAST = 0x5
- RTN_BLACKHOLE = 0x6
- RTN_UNREACHABLE = 0x7
- RTN_PROHIBIT = 0x8
- RTN_THROW = 0x9
- RTN_NAT = 0xa
- RTN_XRESOLVE = 0xb
- RTNLGRP_NONE = 0x0
- RTNLGRP_LINK = 0x1
- RTNLGRP_NOTIFY = 0x2
- RTNLGRP_NEIGH = 0x3
- RTNLGRP_TC = 0x4
- RTNLGRP_IPV4_IFADDR = 0x5
- RTNLGRP_IPV4_MROUTE = 0x6
- RTNLGRP_IPV4_ROUTE = 0x7
- RTNLGRP_IPV4_RULE = 0x8
- RTNLGRP_IPV6_IFADDR = 0x9
- RTNLGRP_IPV6_MROUTE = 0xa
- RTNLGRP_IPV6_ROUTE = 0xb
- RTNLGRP_IPV6_IFINFO = 0xc
- RTNLGRP_IPV6_PREFIX = 0x12
- RTNLGRP_IPV6_RULE = 0x13
- RTNLGRP_ND_USEROPT = 0x14
- SizeofNlMsghdr = 0x10
- SizeofNlMsgerr = 0x14
- SizeofRtGenmsg = 0x1
- SizeofNlAttr = 0x4
- SizeofRtAttr = 0x4
- SizeofIfInfomsg = 0x10
- SizeofIfAddrmsg = 0x8
- SizeofRtMsg = 0xc
- SizeofRtNexthop = 0x8
-)
-
-type NlMsghdr struct {
- Len uint32
- Type uint16
- Flags uint16
- Seq uint32
- Pid uint32
-}
-
-type NlMsgerr struct {
- Error int32
- Msg NlMsghdr
-}
-
-type RtGenmsg struct {
- Family uint8
-}
-
-type NlAttr struct {
- Len uint16
- Type uint16
-}
-
-type RtAttr struct {
- Len uint16
- Type uint16
-}
-
-type IfInfomsg struct {
- Family uint8
- X__ifi_pad uint8
- Type uint16
- Index int32
- Flags uint32
- Change uint32
-}
-
-type IfAddrmsg struct {
- Family uint8
- Prefixlen uint8
- Flags uint8
- Scope uint8
- Index uint32
-}
-
-type RtMsg struct {
- Family uint8
- Dst_len uint8
- Src_len uint8
- Tos uint8
- Table uint8
- Protocol uint8
- Scope uint8
- Type uint8
- Flags uint32
-}
-
-type RtNexthop struct {
- Len uint16
- Flags uint8
- Hops uint8
- Ifindex int32
-}
-
-const (
- SizeofSockFilter = 0x8
- SizeofSockFprog = 0x10
-)
-
-type SockFilter struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type SockFprog struct {
- Len uint16
- Pad_cgo_0 [6]byte
- Filter *SockFilter
-}
-
-type InotifyEvent struct {
- Wd int32
- Mask uint32
- Cookie uint32
- Len uint32
- Name [0]int8
-}
-
-const SizeofInotifyEvent = 0x10
-
-type PtraceRegs struct {
- R15 uint64
- R14 uint64
- R13 uint64
- R12 uint64
- Rbp uint64
- Rbx uint64
- R11 uint64
- R10 uint64
- R9 uint64
- R8 uint64
- Rax uint64
- Rcx uint64
- Rdx uint64
- Rsi uint64
- Rdi uint64
- Orig_rax uint64
- Rip uint64
- Cs uint64
- Eflags uint64
- Rsp uint64
- Ss uint64
- Fs_base uint64
- Gs_base uint64
- Ds uint64
- Es uint64
- Fs uint64
- Gs uint64
-}
-
-type FdSet struct {
- Bits [16]int64
-}
-
-type Sysinfo_t struct {
- Uptime int64
- Loads [3]uint64
- Totalram uint64
- Freeram uint64
- Sharedram uint64
- Bufferram uint64
- Totalswap uint64
- Freeswap uint64
- Procs uint16
- Pad uint16
- Pad_cgo_0 [4]byte
- Totalhigh uint64
- Freehigh uint64
- Unit uint32
- X_f [0]int8
- Pad_cgo_1 [4]byte
-}
-
-type Utsname struct {
- Sysname [65]int8
- Nodename [65]int8
- Release [65]int8
- Version [65]int8
- Machine [65]int8
- Domainname [65]int8
-}
-
-type Ustat_t struct {
- Tfree int32
- Pad_cgo_0 [4]byte
- Tinode uint64
- Fname [6]int8
- Fpack [6]int8
- Pad_cgo_1 [4]byte
-}
-
-type EpollEvent struct {
- Events uint32
- Fd int32
- Pad int32
-}
-
-const (
- AT_FDCWD = -0x64
- AT_REMOVEDIR = 0x200
- AT_SYMLINK_FOLLOW = 0x400
- AT_SYMLINK_NOFOLLOW = 0x100
-)
-
-type PollFd struct {
- Fd int32
- Events int16
- Revents int16
-}
-
-const (
- POLLIN = 0x1
- POLLPRI = 0x2
- POLLOUT = 0x4
- POLLRDHUP = 0x2000
- POLLERR = 0x8
- POLLHUP = 0x10
- POLLNVAL = 0x20
-)
-
-type Sigset_t struct {
- X__val [16]uint64
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Line uint8
- Cc [19]uint8
- Ispeed uint32
- Ospeed uint32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/newt/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go
deleted file mode 100644
index 35f11bd1..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go
+++ /dev/null
@@ -1,616 +0,0 @@
-// +build arm,linux
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go | go run mkpost.go
-
-package unix
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
- PathMax = 0x1000
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int32
- Nsec int32
-}
-
-type Timeval struct {
- Sec int32
- Usec int32
-}
-
-type Timex struct {
- Modes uint32
- Offset int32
- Freq int32
- Maxerror int32
- Esterror int32
- Status int32
- Constant int32
- Precision int32
- Tolerance int32
- Time Timeval
- Tick int32
- Ppsfreq int32
- Jitter int32
- Shift int32
- Stabil int32
- Jitcnt int32
- Calcnt int32
- Errcnt int32
- Stbcnt int32
- Tai int32
- Pad_cgo_0 [44]byte
-}
-
-type Time_t int32
-
-type Tms struct {
- Utime int32
- Stime int32
- Cutime int32
- Cstime int32
-}
-
-type Utimbuf struct {
- Actime int32
- Modtime int32
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int32
- Ixrss int32
- Idrss int32
- Isrss int32
- Minflt int32
- Majflt int32
- Nswap int32
- Inblock int32
- Oublock int32
- Msgsnd int32
- Msgrcv int32
- Nsignals int32
- Nvcsw int32
- Nivcsw int32
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev uint64
- X__pad1 uint16
- Pad_cgo_0 [2]byte
- X__st_ino uint32
- Mode uint32
- Nlink uint32
- Uid uint32
- Gid uint32
- Rdev uint64
- X__pad2 uint16
- Pad_cgo_1 [6]byte
- Size int64
- Blksize int32
- Pad_cgo_2 [4]byte
- Blocks int64
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- Ino uint64
-}
-
-type Statfs_t struct {
- Type int32
- Bsize int32
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Namelen int32
- Frsize int32
- Flags int32
- Spare [4]int32
- Pad_cgo_0 [4]byte
-}
-
-type Dirent struct {
- Ino uint64
- Off int64
- Reclen uint16
- Type uint8
- Name [256]uint8
- Pad_cgo_0 [5]byte
-}
-
-type Fsid struct {
- X__val [2]int32
-}
-
-type Flock_t struct {
- Type int16
- Whence int16
- Pad_cgo_0 [4]byte
- Start int64
- Len int64
- Pid int32
- Pad_cgo_1 [4]byte
-}
-
-const (
- FADV_NORMAL = 0x0
- FADV_RANDOM = 0x1
- FADV_SEQUENTIAL = 0x2
- FADV_WILLNEED = 0x3
- FADV_DONTNEED = 0x4
- FADV_NOREUSE = 0x5
-)
-
-type RawSockaddrInet4 struct {
- Family uint16
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]uint8
-}
-
-type RawSockaddrInet6 struct {
- Family uint16
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Family uint16
- Path [108]int8
-}
-
-type RawSockaddrLinklayer struct {
- Family uint16
- Protocol uint16
- Ifindex int32
- Hatype uint16
- Pkttype uint8
- Halen uint8
- Addr [8]uint8
-}
-
-type RawSockaddrNetlink struct {
- Family uint16
- Pad uint16
- Pid uint32
- Groups uint32
-}
-
-type RawSockaddrHCI struct {
- Family uint16
- Dev uint16
- Channel uint16
-}
-
-type RawSockaddr struct {
- Family uint16
- Data [14]uint8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [96]uint8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint32
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPMreqn struct {
- Multiaddr [4]byte /* in_addr */
- Address [4]byte /* in_addr */
- Ifindex int32
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Iov *Iovec
- Iovlen uint32
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
- X__cmsg_data [0]uint8
-}
-
-type Inet4Pktinfo struct {
- Ifindex int32
- Spec_dst [4]byte /* in_addr */
- Addr [4]byte /* in_addr */
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Data [8]uint32
-}
-
-type Ucred struct {
- Pid int32
- Uid uint32
- Gid uint32
-}
-
-type TCPInfo struct {
- State uint8
- Ca_state uint8
- Retransmits uint8
- Probes uint8
- Backoff uint8
- Options uint8
- Pad_cgo_0 [2]byte
- Rto uint32
- Ato uint32
- Snd_mss uint32
- Rcv_mss uint32
- Unacked uint32
- Sacked uint32
- Lost uint32
- Retrans uint32
- Fackets uint32
- Last_data_sent uint32
- Last_ack_sent uint32
- Last_data_recv uint32
- Last_ack_recv uint32
- Pmtu uint32
- Rcv_ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Snd_ssthresh uint32
- Snd_cwnd uint32
- Advmss uint32
- Reordering uint32
- Rcv_rtt uint32
- Rcv_space uint32
- Total_retrans uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x70
- SizeofSockaddrUnix = 0x6e
- SizeofSockaddrLinklayer = 0x14
- SizeofSockaddrNetlink = 0xc
- SizeofSockaddrHCI = 0x6
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPMreqn = 0xc
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x1c
- SizeofCmsghdr = 0xc
- SizeofInet4Pktinfo = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
- SizeofUcred = 0xc
- SizeofTCPInfo = 0x68
-)
-
-const (
- IFA_UNSPEC = 0x0
- IFA_ADDRESS = 0x1
- IFA_LOCAL = 0x2
- IFA_LABEL = 0x3
- IFA_BROADCAST = 0x4
- IFA_ANYCAST = 0x5
- IFA_CACHEINFO = 0x6
- IFA_MULTICAST = 0x7
- IFLA_UNSPEC = 0x0
- IFLA_ADDRESS = 0x1
- IFLA_BROADCAST = 0x2
- IFLA_IFNAME = 0x3
- IFLA_MTU = 0x4
- IFLA_LINK = 0x5
- IFLA_QDISC = 0x6
- IFLA_STATS = 0x7
- IFLA_COST = 0x8
- IFLA_PRIORITY = 0x9
- IFLA_MASTER = 0xa
- IFLA_WIRELESS = 0xb
- IFLA_PROTINFO = 0xc
- IFLA_TXQLEN = 0xd
- IFLA_MAP = 0xe
- IFLA_WEIGHT = 0xf
- IFLA_OPERSTATE = 0x10
- IFLA_LINKMODE = 0x11
- IFLA_LINKINFO = 0x12
- IFLA_NET_NS_PID = 0x13
- IFLA_IFALIAS = 0x14
- IFLA_MAX = 0x1d
- RT_SCOPE_UNIVERSE = 0x0
- RT_SCOPE_SITE = 0xc8
- RT_SCOPE_LINK = 0xfd
- RT_SCOPE_HOST = 0xfe
- RT_SCOPE_NOWHERE = 0xff
- RT_TABLE_UNSPEC = 0x0
- RT_TABLE_COMPAT = 0xfc
- RT_TABLE_DEFAULT = 0xfd
- RT_TABLE_MAIN = 0xfe
- RT_TABLE_LOCAL = 0xff
- RT_TABLE_MAX = 0xffffffff
- RTA_UNSPEC = 0x0
- RTA_DST = 0x1
- RTA_SRC = 0x2
- RTA_IIF = 0x3
- RTA_OIF = 0x4
- RTA_GATEWAY = 0x5
- RTA_PRIORITY = 0x6
- RTA_PREFSRC = 0x7
- RTA_METRICS = 0x8
- RTA_MULTIPATH = 0x9
- RTA_FLOW = 0xb
- RTA_CACHEINFO = 0xc
- RTA_TABLE = 0xf
- RTN_UNSPEC = 0x0
- RTN_UNICAST = 0x1
- RTN_LOCAL = 0x2
- RTN_BROADCAST = 0x3
- RTN_ANYCAST = 0x4
- RTN_MULTICAST = 0x5
- RTN_BLACKHOLE = 0x6
- RTN_UNREACHABLE = 0x7
- RTN_PROHIBIT = 0x8
- RTN_THROW = 0x9
- RTN_NAT = 0xa
- RTN_XRESOLVE = 0xb
- RTNLGRP_NONE = 0x0
- RTNLGRP_LINK = 0x1
- RTNLGRP_NOTIFY = 0x2
- RTNLGRP_NEIGH = 0x3
- RTNLGRP_TC = 0x4
- RTNLGRP_IPV4_IFADDR = 0x5
- RTNLGRP_IPV4_MROUTE = 0x6
- RTNLGRP_IPV4_ROUTE = 0x7
- RTNLGRP_IPV4_RULE = 0x8
- RTNLGRP_IPV6_IFADDR = 0x9
- RTNLGRP_IPV6_MROUTE = 0xa
- RTNLGRP_IPV6_ROUTE = 0xb
- RTNLGRP_IPV6_IFINFO = 0xc
- RTNLGRP_IPV6_PREFIX = 0x12
- RTNLGRP_IPV6_RULE = 0x13
- RTNLGRP_ND_USEROPT = 0x14
- SizeofNlMsghdr = 0x10
- SizeofNlMsgerr = 0x14
- SizeofRtGenmsg = 0x1
- SizeofNlAttr = 0x4
- SizeofRtAttr = 0x4
- SizeofIfInfomsg = 0x10
- SizeofIfAddrmsg = 0x8
- SizeofRtMsg = 0xc
- SizeofRtNexthop = 0x8
-)
-
-type NlMsghdr struct {
- Len uint32
- Type uint16
- Flags uint16
- Seq uint32
- Pid uint32
-}
-
-type NlMsgerr struct {
- Error int32
- Msg NlMsghdr
-}
-
-type RtGenmsg struct {
- Family uint8
-}
-
-type NlAttr struct {
- Len uint16
- Type uint16
-}
-
-type RtAttr struct {
- Len uint16
- Type uint16
-}
-
-type IfInfomsg struct {
- Family uint8
- X__ifi_pad uint8
- Type uint16
- Index int32
- Flags uint32
- Change uint32
-}
-
-type IfAddrmsg struct {
- Family uint8
- Prefixlen uint8
- Flags uint8
- Scope uint8
- Index uint32
-}
-
-type RtMsg struct {
- Family uint8
- Dst_len uint8
- Src_len uint8
- Tos uint8
- Table uint8
- Protocol uint8
- Scope uint8
- Type uint8
- Flags uint32
-}
-
-type RtNexthop struct {
- Len uint16
- Flags uint8
- Hops uint8
- Ifindex int32
-}
-
-const (
- SizeofSockFilter = 0x8
- SizeofSockFprog = 0x8
-)
-
-type SockFilter struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type SockFprog struct {
- Len uint16
- Pad_cgo_0 [2]byte
- Filter *SockFilter
-}
-
-type InotifyEvent struct {
- Wd int32
- Mask uint32
- Cookie uint32
- Len uint32
- Name [0]uint8
-}
-
-const SizeofInotifyEvent = 0x10
-
-type PtraceRegs struct {
- Uregs [18]uint32
-}
-
-type FdSet struct {
- Bits [32]int32
-}
-
-type Sysinfo_t struct {
- Uptime int32
- Loads [3]uint32
- Totalram uint32
- Freeram uint32
- Sharedram uint32
- Bufferram uint32
- Totalswap uint32
- Freeswap uint32
- Procs uint16
- Pad uint16
- Totalhigh uint32
- Freehigh uint32
- Unit uint32
- X_f [8]uint8
-}
-
-type Utsname struct {
- Sysname [65]uint8
- Nodename [65]uint8
- Release [65]uint8
- Version [65]uint8
- Machine [65]uint8
- Domainname [65]uint8
-}
-
-type Ustat_t struct {
- Tfree int32
- Tinode uint32
- Fname [6]uint8
- Fpack [6]uint8
-}
-
-type EpollEvent struct {
- Events uint32
- PadFd int32
- Fd int32
- Pad int32
-}
-
-const (
- AT_FDCWD = -0x64
- AT_REMOVEDIR = 0x200
- AT_SYMLINK_FOLLOW = 0x400
- AT_SYMLINK_NOFOLLOW = 0x100
-)
-
-type PollFd struct {
- Fd int32
- Events int16
- Revents int16
-}
-
-const (
- POLLIN = 0x1
- POLLPRI = 0x2
- POLLOUT = 0x4
- POLLRDHUP = 0x2000
- POLLERR = 0x8
- POLLHUP = 0x10
- POLLNVAL = 0x20
-)
-
-type Sigset_t struct {
- X__val [16]uint64
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Line uint8
- Cc [19]uint8
- Ispeed uint32
- Ospeed uint32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/newt/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go
deleted file mode 100644
index e786addf..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go
+++ /dev/null
@@ -1,624 +0,0 @@
-// +build arm64,linux
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -fsigned-char types_linux.go
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- PathMax = 0x1000
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Timex struct {
- Modes uint32
- Pad_cgo_0 [4]byte
- Offset int64
- Freq int64
- Maxerror int64
- Esterror int64
- Status int32
- Pad_cgo_1 [4]byte
- Constant int64
- Precision int64
- Tolerance int64
- Time Timeval
- Tick int64
- Ppsfreq int64
- Jitter int64
- Shift int32
- Pad_cgo_2 [4]byte
- Stabil int64
- Jitcnt int64
- Calcnt int64
- Errcnt int64
- Stbcnt int64
- Tai int32
- Pad_cgo_3 [44]byte
-}
-
-type Time_t int64
-
-type Tms struct {
- Utime int64
- Stime int64
- Cutime int64
- Cstime int64
-}
-
-type Utimbuf struct {
- Actime int64
- Modtime int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev uint64
- Ino uint64
- Mode uint32
- Nlink uint32
- Uid uint32
- Gid uint32
- Rdev uint64
- X__pad1 uint64
- Size int64
- Blksize int32
- X__pad2 int32
- Blocks int64
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- X__glibc_reserved [2]int32
-}
-
-type Statfs_t struct {
- Type int64
- Bsize int64
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Namelen int64
- Frsize int64
- Flags int64
- Spare [4]int64
-}
-
-type Dirent struct {
- Ino uint64
- Off int64
- Reclen uint16
- Type uint8
- Name [256]int8
- Pad_cgo_0 [5]byte
-}
-
-type Fsid struct {
- X__val [2]int32
-}
-
-type Flock_t struct {
- Type int16
- Whence int16
- Pad_cgo_0 [4]byte
- Start int64
- Len int64
- Pid int32
- Pad_cgo_1 [4]byte
-}
-
-const (
- FADV_NORMAL = 0x0
- FADV_RANDOM = 0x1
- FADV_SEQUENTIAL = 0x2
- FADV_WILLNEED = 0x3
- FADV_DONTNEED = 0x4
- FADV_NOREUSE = 0x5
-)
-
-type RawSockaddrInet4 struct {
- Family uint16
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]uint8
-}
-
-type RawSockaddrInet6 struct {
- Family uint16
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Family uint16
- Path [108]int8
-}
-
-type RawSockaddrLinklayer struct {
- Family uint16
- Protocol uint16
- Ifindex int32
- Hatype uint16
- Pkttype uint8
- Halen uint8
- Addr [8]uint8
-}
-
-type RawSockaddrNetlink struct {
- Family uint16
- Pad uint16
- Pid uint32
- Groups uint32
-}
-
-type RawSockaddrHCI struct {
- Family uint16
- Dev uint16
- Channel uint16
-}
-
-type RawSockaddr struct {
- Family uint16
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [96]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPMreqn struct {
- Multiaddr [4]byte /* in_addr */
- Address [4]byte /* in_addr */
- Ifindex int32
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Pad_cgo_0 [4]byte
- Iov *Iovec
- Iovlen uint64
- Control *byte
- Controllen uint64
- Flags int32
- Pad_cgo_1 [4]byte
-}
-
-type Cmsghdr struct {
- Len uint64
- Level int32
- Type int32
- X__cmsg_data [0]uint8
-}
-
-type Inet4Pktinfo struct {
- Ifindex int32
- Spec_dst [4]byte /* in_addr */
- Addr [4]byte /* in_addr */
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Data [8]uint32
-}
-
-type Ucred struct {
- Pid int32
- Uid uint32
- Gid uint32
-}
-
-type TCPInfo struct {
- State uint8
- Ca_state uint8
- Retransmits uint8
- Probes uint8
- Backoff uint8
- Options uint8
- Pad_cgo_0 [2]byte
- Rto uint32
- Ato uint32
- Snd_mss uint32
- Rcv_mss uint32
- Unacked uint32
- Sacked uint32
- Lost uint32
- Retrans uint32
- Fackets uint32
- Last_data_sent uint32
- Last_ack_sent uint32
- Last_data_recv uint32
- Last_ack_recv uint32
- Pmtu uint32
- Rcv_ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Snd_ssthresh uint32
- Snd_cwnd uint32
- Advmss uint32
- Reordering uint32
- Rcv_rtt uint32
- Rcv_space uint32
- Total_retrans uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x70
- SizeofSockaddrUnix = 0x6e
- SizeofSockaddrLinklayer = 0x14
- SizeofSockaddrNetlink = 0xc
- SizeofSockaddrHCI = 0x6
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPMreqn = 0xc
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x38
- SizeofCmsghdr = 0x10
- SizeofInet4Pktinfo = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
- SizeofUcred = 0xc
- SizeofTCPInfo = 0x68
-)
-
-const (
- IFA_UNSPEC = 0x0
- IFA_ADDRESS = 0x1
- IFA_LOCAL = 0x2
- IFA_LABEL = 0x3
- IFA_BROADCAST = 0x4
- IFA_ANYCAST = 0x5
- IFA_CACHEINFO = 0x6
- IFA_MULTICAST = 0x7
- IFLA_UNSPEC = 0x0
- IFLA_ADDRESS = 0x1
- IFLA_BROADCAST = 0x2
- IFLA_IFNAME = 0x3
- IFLA_MTU = 0x4
- IFLA_LINK = 0x5
- IFLA_QDISC = 0x6
- IFLA_STATS = 0x7
- IFLA_COST = 0x8
- IFLA_PRIORITY = 0x9
- IFLA_MASTER = 0xa
- IFLA_WIRELESS = 0xb
- IFLA_PROTINFO = 0xc
- IFLA_TXQLEN = 0xd
- IFLA_MAP = 0xe
- IFLA_WEIGHT = 0xf
- IFLA_OPERSTATE = 0x10
- IFLA_LINKMODE = 0x11
- IFLA_LINKINFO = 0x12
- IFLA_NET_NS_PID = 0x13
- IFLA_IFALIAS = 0x14
- IFLA_MAX = 0x22
- RT_SCOPE_UNIVERSE = 0x0
- RT_SCOPE_SITE = 0xc8
- RT_SCOPE_LINK = 0xfd
- RT_SCOPE_HOST = 0xfe
- RT_SCOPE_NOWHERE = 0xff
- RT_TABLE_UNSPEC = 0x0
- RT_TABLE_COMPAT = 0xfc
- RT_TABLE_DEFAULT = 0xfd
- RT_TABLE_MAIN = 0xfe
- RT_TABLE_LOCAL = 0xff
- RT_TABLE_MAX = 0xffffffff
- RTA_UNSPEC = 0x0
- RTA_DST = 0x1
- RTA_SRC = 0x2
- RTA_IIF = 0x3
- RTA_OIF = 0x4
- RTA_GATEWAY = 0x5
- RTA_PRIORITY = 0x6
- RTA_PREFSRC = 0x7
- RTA_METRICS = 0x8
- RTA_MULTIPATH = 0x9
- RTA_FLOW = 0xb
- RTA_CACHEINFO = 0xc
- RTA_TABLE = 0xf
- RTN_UNSPEC = 0x0
- RTN_UNICAST = 0x1
- RTN_LOCAL = 0x2
- RTN_BROADCAST = 0x3
- RTN_ANYCAST = 0x4
- RTN_MULTICAST = 0x5
- RTN_BLACKHOLE = 0x6
- RTN_UNREACHABLE = 0x7
- RTN_PROHIBIT = 0x8
- RTN_THROW = 0x9
- RTN_NAT = 0xa
- RTN_XRESOLVE = 0xb
- RTNLGRP_NONE = 0x0
- RTNLGRP_LINK = 0x1
- RTNLGRP_NOTIFY = 0x2
- RTNLGRP_NEIGH = 0x3
- RTNLGRP_TC = 0x4
- RTNLGRP_IPV4_IFADDR = 0x5
- RTNLGRP_IPV4_MROUTE = 0x6
- RTNLGRP_IPV4_ROUTE = 0x7
- RTNLGRP_IPV4_RULE = 0x8
- RTNLGRP_IPV6_IFADDR = 0x9
- RTNLGRP_IPV6_MROUTE = 0xa
- RTNLGRP_IPV6_ROUTE = 0xb
- RTNLGRP_IPV6_IFINFO = 0xc
- RTNLGRP_IPV6_PREFIX = 0x12
- RTNLGRP_IPV6_RULE = 0x13
- RTNLGRP_ND_USEROPT = 0x14
- SizeofNlMsghdr = 0x10
- SizeofNlMsgerr = 0x14
- SizeofRtGenmsg = 0x1
- SizeofNlAttr = 0x4
- SizeofRtAttr = 0x4
- SizeofIfInfomsg = 0x10
- SizeofIfAddrmsg = 0x8
- SizeofRtMsg = 0xc
- SizeofRtNexthop = 0x8
-)
-
-type NlMsghdr struct {
- Len uint32
- Type uint16
- Flags uint16
- Seq uint32
- Pid uint32
-}
-
-type NlMsgerr struct {
- Error int32
- Msg NlMsghdr
-}
-
-type RtGenmsg struct {
- Family uint8
-}
-
-type NlAttr struct {
- Len uint16
- Type uint16
-}
-
-type RtAttr struct {
- Len uint16
- Type uint16
-}
-
-type IfInfomsg struct {
- Family uint8
- X__ifi_pad uint8
- Type uint16
- Index int32
- Flags uint32
- Change uint32
-}
-
-type IfAddrmsg struct {
- Family uint8
- Prefixlen uint8
- Flags uint8
- Scope uint8
- Index uint32
-}
-
-type RtMsg struct {
- Family uint8
- Dst_len uint8
- Src_len uint8
- Tos uint8
- Table uint8
- Protocol uint8
- Scope uint8
- Type uint8
- Flags uint32
-}
-
-type RtNexthop struct {
- Len uint16
- Flags uint8
- Hops uint8
- Ifindex int32
-}
-
-const (
- SizeofSockFilter = 0x8
- SizeofSockFprog = 0x10
-)
-
-type SockFilter struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type SockFprog struct {
- Len uint16
- Pad_cgo_0 [6]byte
- Filter *SockFilter
-}
-
-type InotifyEvent struct {
- Wd int32
- Mask uint32
- Cookie uint32
- Len uint32
- Name [0]int8
-}
-
-const SizeofInotifyEvent = 0x10
-
-type PtraceRegs struct {
- Regs [31]uint64
- Sp uint64
- Pc uint64
- Pstate uint64
-}
-
-type FdSet struct {
- Bits [16]int64
-}
-
-type Sysinfo_t struct {
- Uptime int64
- Loads [3]uint64
- Totalram uint64
- Freeram uint64
- Sharedram uint64
- Bufferram uint64
- Totalswap uint64
- Freeswap uint64
- Procs uint16
- Pad uint16
- Pad_cgo_0 [4]byte
- Totalhigh uint64
- Freehigh uint64
- Unit uint32
- X_f [0]int8
- Pad_cgo_1 [4]byte
-}
-
-type Utsname struct {
- Sysname [65]int8
- Nodename [65]int8
- Release [65]int8
- Version [65]int8
- Machine [65]int8
- Domainname [65]int8
-}
-
-type Ustat_t struct {
- Tfree int32
- Pad_cgo_0 [4]byte
- Tinode uint64
- Fname [6]int8
- Fpack [6]int8
- Pad_cgo_1 [4]byte
-}
-
-type EpollEvent struct {
- Events uint32
- PadFd int32
- Fd int32
- Pad int32
-}
-
-const (
- AT_FDCWD = -0x64
- AT_REMOVEDIR = 0x200
- AT_SYMLINK_FOLLOW = 0x400
- AT_SYMLINK_NOFOLLOW = 0x100
-)
-
-type PollFd struct {
- Fd int32
- Events int16
- Revents int16
-}
-
-const (
- POLLIN = 0x1
- POLLPRI = 0x2
- POLLOUT = 0x4
- POLLRDHUP = 0x2000
- POLLERR = 0x8
- POLLHUP = 0x10
- POLLNVAL = 0x20
-)
-
-type Sigset_t struct {
- X__val [16]uint64
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Line uint8
- Cc [19]uint8
- Ispeed uint32
- Ospeed uint32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/newt/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go
deleted file mode 100644
index b29894de..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go
+++ /dev/null
@@ -1,627 +0,0 @@
-// +build mips64,linux
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- PathMax = 0x1000
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Timex struct {
- Modes uint32
- Pad_cgo_0 [4]byte
- Offset int64
- Freq int64
- Maxerror int64
- Esterror int64
- Status int32
- Pad_cgo_1 [4]byte
- Constant int64
- Precision int64
- Tolerance int64
- Time Timeval
- Tick int64
- Ppsfreq int64
- Jitter int64
- Shift int32
- Pad_cgo_2 [4]byte
- Stabil int64
- Jitcnt int64
- Calcnt int64
- Errcnt int64
- Stbcnt int64
- Tai int32
- Pad_cgo_3 [44]byte
-}
-
-type Time_t int64
-
-type Tms struct {
- Utime int64
- Stime int64
- Cutime int64
- Cstime int64
-}
-
-type Utimbuf struct {
- Actime int64
- Modtime int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev uint32
- Pad1 [3]int32
- Ino uint64
- Mode uint32
- Nlink uint32
- Uid uint32
- Gid uint32
- Rdev uint32
- Pad2 [3]uint32
- Size int64
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- Blksize uint32
- Pad4 uint32
- Blocks int64
-}
-
-type Statfs_t struct {
- Type int64
- Bsize int64
- Frsize int64
- Blocks uint64
- Bfree uint64
- Files uint64
- Ffree uint64
- Bavail uint64
- Fsid Fsid
- Namelen int64
- Flags int64
- Spare [5]int64
-}
-
-type Dirent struct {
- Ino uint64
- Off int64
- Reclen uint16
- Type uint8
- Name [256]int8
- Pad_cgo_0 [5]byte
-}
-
-type Fsid struct {
- X__val [2]int32
-}
-
-type Flock_t struct {
- Type int16
- Whence int16
- Pad_cgo_0 [4]byte
- Start int64
- Len int64
- Pid int32
- Pad_cgo_1 [4]byte
-}
-
-const (
- FADV_NORMAL = 0x0
- FADV_RANDOM = 0x1
- FADV_SEQUENTIAL = 0x2
- FADV_WILLNEED = 0x3
- FADV_DONTNEED = 0x4
- FADV_NOREUSE = 0x5
-)
-
-type RawSockaddrInet4 struct {
- Family uint16
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]uint8
-}
-
-type RawSockaddrInet6 struct {
- Family uint16
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Family uint16
- Path [108]int8
-}
-
-type RawSockaddrLinklayer struct {
- Family uint16
- Protocol uint16
- Ifindex int32
- Hatype uint16
- Pkttype uint8
- Halen uint8
- Addr [8]uint8
-}
-
-type RawSockaddrNetlink struct {
- Family uint16
- Pad uint16
- Pid uint32
- Groups uint32
-}
-
-type RawSockaddrHCI struct {
- Family uint16
- Dev uint16
- Channel uint16
-}
-
-type RawSockaddr struct {
- Family uint16
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [96]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPMreqn struct {
- Multiaddr [4]byte /* in_addr */
- Address [4]byte /* in_addr */
- Ifindex int32
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Pad_cgo_0 [4]byte
- Iov *Iovec
- Iovlen uint64
- Control *byte
- Controllen uint64
- Flags int32
- Pad_cgo_1 [4]byte
-}
-
-type Cmsghdr struct {
- Len uint64
- Level int32
- Type int32
-}
-
-type Inet4Pktinfo struct {
- Ifindex int32
- Spec_dst [4]byte /* in_addr */
- Addr [4]byte /* in_addr */
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Data [8]uint32
-}
-
-type Ucred struct {
- Pid int32
- Uid uint32
- Gid uint32
-}
-
-type TCPInfo struct {
- State uint8
- Ca_state uint8
- Retransmits uint8
- Probes uint8
- Backoff uint8
- Options uint8
- Pad_cgo_0 [2]byte
- Rto uint32
- Ato uint32
- Snd_mss uint32
- Rcv_mss uint32
- Unacked uint32
- Sacked uint32
- Lost uint32
- Retrans uint32
- Fackets uint32
- Last_data_sent uint32
- Last_ack_sent uint32
- Last_data_recv uint32
- Last_ack_recv uint32
- Pmtu uint32
- Rcv_ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Snd_ssthresh uint32
- Snd_cwnd uint32
- Advmss uint32
- Reordering uint32
- Rcv_rtt uint32
- Rcv_space uint32
- Total_retrans uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x70
- SizeofSockaddrUnix = 0x6e
- SizeofSockaddrLinklayer = 0x14
- SizeofSockaddrNetlink = 0xc
- SizeofSockaddrHCI = 0x6
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPMreqn = 0xc
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x38
- SizeofCmsghdr = 0x10
- SizeofInet4Pktinfo = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
- SizeofUcred = 0xc
- SizeofTCPInfo = 0x68
-)
-
-const (
- IFA_UNSPEC = 0x0
- IFA_ADDRESS = 0x1
- IFA_LOCAL = 0x2
- IFA_LABEL = 0x3
- IFA_BROADCAST = 0x4
- IFA_ANYCAST = 0x5
- IFA_CACHEINFO = 0x6
- IFA_MULTICAST = 0x7
- IFLA_UNSPEC = 0x0
- IFLA_ADDRESS = 0x1
- IFLA_BROADCAST = 0x2
- IFLA_IFNAME = 0x3
- IFLA_MTU = 0x4
- IFLA_LINK = 0x5
- IFLA_QDISC = 0x6
- IFLA_STATS = 0x7
- IFLA_COST = 0x8
- IFLA_PRIORITY = 0x9
- IFLA_MASTER = 0xa
- IFLA_WIRELESS = 0xb
- IFLA_PROTINFO = 0xc
- IFLA_TXQLEN = 0xd
- IFLA_MAP = 0xe
- IFLA_WEIGHT = 0xf
- IFLA_OPERSTATE = 0x10
- IFLA_LINKMODE = 0x11
- IFLA_LINKINFO = 0x12
- IFLA_NET_NS_PID = 0x13
- IFLA_IFALIAS = 0x14
- IFLA_MAX = 0x27
- RT_SCOPE_UNIVERSE = 0x0
- RT_SCOPE_SITE = 0xc8
- RT_SCOPE_LINK = 0xfd
- RT_SCOPE_HOST = 0xfe
- RT_SCOPE_NOWHERE = 0xff
- RT_TABLE_UNSPEC = 0x0
- RT_TABLE_COMPAT = 0xfc
- RT_TABLE_DEFAULT = 0xfd
- RT_TABLE_MAIN = 0xfe
- RT_TABLE_LOCAL = 0xff
- RT_TABLE_MAX = 0xffffffff
- RTA_UNSPEC = 0x0
- RTA_DST = 0x1
- RTA_SRC = 0x2
- RTA_IIF = 0x3
- RTA_OIF = 0x4
- RTA_GATEWAY = 0x5
- RTA_PRIORITY = 0x6
- RTA_PREFSRC = 0x7
- RTA_METRICS = 0x8
- RTA_MULTIPATH = 0x9
- RTA_FLOW = 0xb
- RTA_CACHEINFO = 0xc
- RTA_TABLE = 0xf
- RTN_UNSPEC = 0x0
- RTN_UNICAST = 0x1
- RTN_LOCAL = 0x2
- RTN_BROADCAST = 0x3
- RTN_ANYCAST = 0x4
- RTN_MULTICAST = 0x5
- RTN_BLACKHOLE = 0x6
- RTN_UNREACHABLE = 0x7
- RTN_PROHIBIT = 0x8
- RTN_THROW = 0x9
- RTN_NAT = 0xa
- RTN_XRESOLVE = 0xb
- RTNLGRP_NONE = 0x0
- RTNLGRP_LINK = 0x1
- RTNLGRP_NOTIFY = 0x2
- RTNLGRP_NEIGH = 0x3
- RTNLGRP_TC = 0x4
- RTNLGRP_IPV4_IFADDR = 0x5
- RTNLGRP_IPV4_MROUTE = 0x6
- RTNLGRP_IPV4_ROUTE = 0x7
- RTNLGRP_IPV4_RULE = 0x8
- RTNLGRP_IPV6_IFADDR = 0x9
- RTNLGRP_IPV6_MROUTE = 0xa
- RTNLGRP_IPV6_ROUTE = 0xb
- RTNLGRP_IPV6_IFINFO = 0xc
- RTNLGRP_IPV6_PREFIX = 0x12
- RTNLGRP_IPV6_RULE = 0x13
- RTNLGRP_ND_USEROPT = 0x14
- SizeofNlMsghdr = 0x10
- SizeofNlMsgerr = 0x14
- SizeofRtGenmsg = 0x1
- SizeofNlAttr = 0x4
- SizeofRtAttr = 0x4
- SizeofIfInfomsg = 0x10
- SizeofIfAddrmsg = 0x8
- SizeofRtMsg = 0xc
- SizeofRtNexthop = 0x8
-)
-
-type NlMsghdr struct {
- Len uint32
- Type uint16
- Flags uint16
- Seq uint32
- Pid uint32
-}
-
-type NlMsgerr struct {
- Error int32
- Msg NlMsghdr
-}
-
-type RtGenmsg struct {
- Family uint8
-}
-
-type NlAttr struct {
- Len uint16
- Type uint16
-}
-
-type RtAttr struct {
- Len uint16
- Type uint16
-}
-
-type IfInfomsg struct {
- Family uint8
- X__ifi_pad uint8
- Type uint16
- Index int32
- Flags uint32
- Change uint32
-}
-
-type IfAddrmsg struct {
- Family uint8
- Prefixlen uint8
- Flags uint8
- Scope uint8
- Index uint32
-}
-
-type RtMsg struct {
- Family uint8
- Dst_len uint8
- Src_len uint8
- Tos uint8
- Table uint8
- Protocol uint8
- Scope uint8
- Type uint8
- Flags uint32
-}
-
-type RtNexthop struct {
- Len uint16
- Flags uint8
- Hops uint8
- Ifindex int32
-}
-
-const (
- SizeofSockFilter = 0x8
- SizeofSockFprog = 0x10
-)
-
-type SockFilter struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type SockFprog struct {
- Len uint16
- Pad_cgo_0 [6]byte
- Filter *SockFilter
-}
-
-type InotifyEvent struct {
- Wd int32
- Mask uint32
- Cookie uint32
- Len uint32
-}
-
-const SizeofInotifyEvent = 0x10
-
-type PtraceRegs struct {
- Regs [102]uint64
- U_tsize uint64
- U_dsize uint64
- U_ssize uint64
- Start_code uint64
- Start_data uint64
- Start_stack uint64
- Signal int64
- U_ar0 uint64
- Magic uint64
- U_comm [32]int8
-}
-
-type FdSet struct {
- Bits [16]int64
-}
-
-type Sysinfo_t struct {
- Uptime int64
- Loads [3]uint64
- Totalram uint64
- Freeram uint64
- Sharedram uint64
- Bufferram uint64
- Totalswap uint64
- Freeswap uint64
- Procs uint16
- Pad uint16
- Pad_cgo_0 [4]byte
- Totalhigh uint64
- Freehigh uint64
- Unit uint32
- X_f [0]int8
- Pad_cgo_1 [4]byte
-}
-
-type Utsname struct {
- Sysname [65]int8
- Nodename [65]int8
- Release [65]int8
- Version [65]int8
- Machine [65]int8
- Domainname [65]int8
-}
-
-type Ustat_t struct {
- Tfree int32
- Pad_cgo_0 [4]byte
- Tinode uint64
- Fname [6]int8
- Fpack [6]int8
- Pad_cgo_1 [4]byte
-}
-
-type EpollEvent struct {
- Events uint32
- Fd int32
- Pad int32
-}
-
-const (
- AT_FDCWD = -0x64
- AT_REMOVEDIR = 0x200
- AT_SYMLINK_FOLLOW = 0x400
- AT_SYMLINK_NOFOLLOW = 0x100
-)
-
-type PollFd struct {
- Fd int32
- Events int16
- Revents int16
-}
-
-const (
- POLLIN = 0x1
- POLLPRI = 0x2
- POLLOUT = 0x4
- POLLRDHUP = 0x2000
- POLLERR = 0x8
- POLLHUP = 0x10
- POLLNVAL = 0x20
-)
-
-type Sigset_t struct {
- X__val [16]uint64
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Line uint8
- Cc [32]uint8
- Pad_cgo_0 [3]byte
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/newt/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go
deleted file mode 100644
index d9af71b6..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go
+++ /dev/null
@@ -1,627 +0,0 @@
-// +build mips64le,linux
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- PathMax = 0x1000
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Timex struct {
- Modes uint32
- Pad_cgo_0 [4]byte
- Offset int64
- Freq int64
- Maxerror int64
- Esterror int64
- Status int32
- Pad_cgo_1 [4]byte
- Constant int64
- Precision int64
- Tolerance int64
- Time Timeval
- Tick int64
- Ppsfreq int64
- Jitter int64
- Shift int32
- Pad_cgo_2 [4]byte
- Stabil int64
- Jitcnt int64
- Calcnt int64
- Errcnt int64
- Stbcnt int64
- Tai int32
- Pad_cgo_3 [44]byte
-}
-
-type Time_t int64
-
-type Tms struct {
- Utime int64
- Stime int64
- Cutime int64
- Cstime int64
-}
-
-type Utimbuf struct {
- Actime int64
- Modtime int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev uint32
- Pad1 [3]int32
- Ino uint64
- Mode uint32
- Nlink uint32
- Uid uint32
- Gid uint32
- Rdev uint32
- Pad2 [3]uint32
- Size int64
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- Blksize uint32
- Pad4 uint32
- Blocks int64
-}
-
-type Statfs_t struct {
- Type int64
- Bsize int64
- Frsize int64
- Blocks uint64
- Bfree uint64
- Files uint64
- Ffree uint64
- Bavail uint64
- Fsid Fsid
- Namelen int64
- Flags int64
- Spare [5]int64
-}
-
-type Dirent struct {
- Ino uint64
- Off int64
- Reclen uint16
- Type uint8
- Name [256]int8
- Pad_cgo_0 [5]byte
-}
-
-type Fsid struct {
- X__val [2]int32
-}
-
-type Flock_t struct {
- Type int16
- Whence int16
- Pad_cgo_0 [4]byte
- Start int64
- Len int64
- Pid int32
- Pad_cgo_1 [4]byte
-}
-
-const (
- FADV_NORMAL = 0x0
- FADV_RANDOM = 0x1
- FADV_SEQUENTIAL = 0x2
- FADV_WILLNEED = 0x3
- FADV_DONTNEED = 0x4
- FADV_NOREUSE = 0x5
-)
-
-type RawSockaddrInet4 struct {
- Family uint16
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]uint8
-}
-
-type RawSockaddrInet6 struct {
- Family uint16
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Family uint16
- Path [108]int8
-}
-
-type RawSockaddrLinklayer struct {
- Family uint16
- Protocol uint16
- Ifindex int32
- Hatype uint16
- Pkttype uint8
- Halen uint8
- Addr [8]uint8
-}
-
-type RawSockaddrNetlink struct {
- Family uint16
- Pad uint16
- Pid uint32
- Groups uint32
-}
-
-type RawSockaddrHCI struct {
- Family uint16
- Dev uint16
- Channel uint16
-}
-
-type RawSockaddr struct {
- Family uint16
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [96]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPMreqn struct {
- Multiaddr [4]byte /* in_addr */
- Address [4]byte /* in_addr */
- Ifindex int32
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Pad_cgo_0 [4]byte
- Iov *Iovec
- Iovlen uint64
- Control *byte
- Controllen uint64
- Flags int32
- Pad_cgo_1 [4]byte
-}
-
-type Cmsghdr struct {
- Len uint64
- Level int32
- Type int32
-}
-
-type Inet4Pktinfo struct {
- Ifindex int32
- Spec_dst [4]byte /* in_addr */
- Addr [4]byte /* in_addr */
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Data [8]uint32
-}
-
-type Ucred struct {
- Pid int32
- Uid uint32
- Gid uint32
-}
-
-type TCPInfo struct {
- State uint8
- Ca_state uint8
- Retransmits uint8
- Probes uint8
- Backoff uint8
- Options uint8
- Pad_cgo_0 [2]byte
- Rto uint32
- Ato uint32
- Snd_mss uint32
- Rcv_mss uint32
- Unacked uint32
- Sacked uint32
- Lost uint32
- Retrans uint32
- Fackets uint32
- Last_data_sent uint32
- Last_ack_sent uint32
- Last_data_recv uint32
- Last_ack_recv uint32
- Pmtu uint32
- Rcv_ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Snd_ssthresh uint32
- Snd_cwnd uint32
- Advmss uint32
- Reordering uint32
- Rcv_rtt uint32
- Rcv_space uint32
- Total_retrans uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x70
- SizeofSockaddrUnix = 0x6e
- SizeofSockaddrLinklayer = 0x14
- SizeofSockaddrNetlink = 0xc
- SizeofSockaddrHCI = 0x6
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPMreqn = 0xc
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x38
- SizeofCmsghdr = 0x10
- SizeofInet4Pktinfo = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
- SizeofUcred = 0xc
- SizeofTCPInfo = 0x68
-)
-
-const (
- IFA_UNSPEC = 0x0
- IFA_ADDRESS = 0x1
- IFA_LOCAL = 0x2
- IFA_LABEL = 0x3
- IFA_BROADCAST = 0x4
- IFA_ANYCAST = 0x5
- IFA_CACHEINFO = 0x6
- IFA_MULTICAST = 0x7
- IFLA_UNSPEC = 0x0
- IFLA_ADDRESS = 0x1
- IFLA_BROADCAST = 0x2
- IFLA_IFNAME = 0x3
- IFLA_MTU = 0x4
- IFLA_LINK = 0x5
- IFLA_QDISC = 0x6
- IFLA_STATS = 0x7
- IFLA_COST = 0x8
- IFLA_PRIORITY = 0x9
- IFLA_MASTER = 0xa
- IFLA_WIRELESS = 0xb
- IFLA_PROTINFO = 0xc
- IFLA_TXQLEN = 0xd
- IFLA_MAP = 0xe
- IFLA_WEIGHT = 0xf
- IFLA_OPERSTATE = 0x10
- IFLA_LINKMODE = 0x11
- IFLA_LINKINFO = 0x12
- IFLA_NET_NS_PID = 0x13
- IFLA_IFALIAS = 0x14
- IFLA_MAX = 0x27
- RT_SCOPE_UNIVERSE = 0x0
- RT_SCOPE_SITE = 0xc8
- RT_SCOPE_LINK = 0xfd
- RT_SCOPE_HOST = 0xfe
- RT_SCOPE_NOWHERE = 0xff
- RT_TABLE_UNSPEC = 0x0
- RT_TABLE_COMPAT = 0xfc
- RT_TABLE_DEFAULT = 0xfd
- RT_TABLE_MAIN = 0xfe
- RT_TABLE_LOCAL = 0xff
- RT_TABLE_MAX = 0xffffffff
- RTA_UNSPEC = 0x0
- RTA_DST = 0x1
- RTA_SRC = 0x2
- RTA_IIF = 0x3
- RTA_OIF = 0x4
- RTA_GATEWAY = 0x5
- RTA_PRIORITY = 0x6
- RTA_PREFSRC = 0x7
- RTA_METRICS = 0x8
- RTA_MULTIPATH = 0x9
- RTA_FLOW = 0xb
- RTA_CACHEINFO = 0xc
- RTA_TABLE = 0xf
- RTN_UNSPEC = 0x0
- RTN_UNICAST = 0x1
- RTN_LOCAL = 0x2
- RTN_BROADCAST = 0x3
- RTN_ANYCAST = 0x4
- RTN_MULTICAST = 0x5
- RTN_BLACKHOLE = 0x6
- RTN_UNREACHABLE = 0x7
- RTN_PROHIBIT = 0x8
- RTN_THROW = 0x9
- RTN_NAT = 0xa
- RTN_XRESOLVE = 0xb
- RTNLGRP_NONE = 0x0
- RTNLGRP_LINK = 0x1
- RTNLGRP_NOTIFY = 0x2
- RTNLGRP_NEIGH = 0x3
- RTNLGRP_TC = 0x4
- RTNLGRP_IPV4_IFADDR = 0x5
- RTNLGRP_IPV4_MROUTE = 0x6
- RTNLGRP_IPV4_ROUTE = 0x7
- RTNLGRP_IPV4_RULE = 0x8
- RTNLGRP_IPV6_IFADDR = 0x9
- RTNLGRP_IPV6_MROUTE = 0xa
- RTNLGRP_IPV6_ROUTE = 0xb
- RTNLGRP_IPV6_IFINFO = 0xc
- RTNLGRP_IPV6_PREFIX = 0x12
- RTNLGRP_IPV6_RULE = 0x13
- RTNLGRP_ND_USEROPT = 0x14
- SizeofNlMsghdr = 0x10
- SizeofNlMsgerr = 0x14
- SizeofRtGenmsg = 0x1
- SizeofNlAttr = 0x4
- SizeofRtAttr = 0x4
- SizeofIfInfomsg = 0x10
- SizeofIfAddrmsg = 0x8
- SizeofRtMsg = 0xc
- SizeofRtNexthop = 0x8
-)
-
-type NlMsghdr struct {
- Len uint32
- Type uint16
- Flags uint16
- Seq uint32
- Pid uint32
-}
-
-type NlMsgerr struct {
- Error int32
- Msg NlMsghdr
-}
-
-type RtGenmsg struct {
- Family uint8
-}
-
-type NlAttr struct {
- Len uint16
- Type uint16
-}
-
-type RtAttr struct {
- Len uint16
- Type uint16
-}
-
-type IfInfomsg struct {
- Family uint8
- X__ifi_pad uint8
- Type uint16
- Index int32
- Flags uint32
- Change uint32
-}
-
-type IfAddrmsg struct {
- Family uint8
- Prefixlen uint8
- Flags uint8
- Scope uint8
- Index uint32
-}
-
-type RtMsg struct {
- Family uint8
- Dst_len uint8
- Src_len uint8
- Tos uint8
- Table uint8
- Protocol uint8
- Scope uint8
- Type uint8
- Flags uint32
-}
-
-type RtNexthop struct {
- Len uint16
- Flags uint8
- Hops uint8
- Ifindex int32
-}
-
-const (
- SizeofSockFilter = 0x8
- SizeofSockFprog = 0x10
-)
-
-type SockFilter struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type SockFprog struct {
- Len uint16
- Pad_cgo_0 [6]byte
- Filter *SockFilter
-}
-
-type InotifyEvent struct {
- Wd int32
- Mask uint32
- Cookie uint32
- Len uint32
-}
-
-const SizeofInotifyEvent = 0x10
-
-type PtraceRegs struct {
- Regs [102]uint64
- U_tsize uint64
- U_dsize uint64
- U_ssize uint64
- Start_code uint64
- Start_data uint64
- Start_stack uint64
- Signal int64
- U_ar0 uint64
- Magic uint64
- U_comm [32]int8
-}
-
-type FdSet struct {
- Bits [16]int64
-}
-
-type Sysinfo_t struct {
- Uptime int64
- Loads [3]uint64
- Totalram uint64
- Freeram uint64
- Sharedram uint64
- Bufferram uint64
- Totalswap uint64
- Freeswap uint64
- Procs uint16
- Pad uint16
- Pad_cgo_0 [4]byte
- Totalhigh uint64
- Freehigh uint64
- Unit uint32
- X_f [0]int8
- Pad_cgo_1 [4]byte
-}
-
-type Utsname struct {
- Sysname [65]int8
- Nodename [65]int8
- Release [65]int8
- Version [65]int8
- Machine [65]int8
- Domainname [65]int8
-}
-
-type Ustat_t struct {
- Tfree int32
- Pad_cgo_0 [4]byte
- Tinode uint64
- Fname [6]int8
- Fpack [6]int8
- Pad_cgo_1 [4]byte
-}
-
-type EpollEvent struct {
- Events uint32
- Fd int32
- Pad int32
-}
-
-const (
- AT_FDCWD = -0x64
- AT_REMOVEDIR = 0x200
- AT_SYMLINK_FOLLOW = 0x400
- AT_SYMLINK_NOFOLLOW = 0x100
-)
-
-type PollFd struct {
- Fd int32
- Events int16
- Revents int16
-}
-
-const (
- POLLIN = 0x1
- POLLPRI = 0x2
- POLLOUT = 0x4
- POLLRDHUP = 0x2000
- POLLERR = 0x8
- POLLHUP = 0x10
- POLLNVAL = 0x20
-)
-
-type Sigset_t struct {
- X__val [16]uint64
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Line uint8
- Cc [32]uint8
- Pad_cgo_0 [3]byte
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/newt/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go
deleted file mode 100644
index 4218170a..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go
+++ /dev/null
@@ -1,634 +0,0 @@
-// +build ppc64,linux
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- PathMax = 0x1000
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Timex struct {
- Modes uint32
- Pad_cgo_0 [4]byte
- Offset int64
- Freq int64
- Maxerror int64
- Esterror int64
- Status int32
- Pad_cgo_1 [4]byte
- Constant int64
- Precision int64
- Tolerance int64
- Time Timeval
- Tick int64
- Ppsfreq int64
- Jitter int64
- Shift int32
- Pad_cgo_2 [4]byte
- Stabil int64
- Jitcnt int64
- Calcnt int64
- Errcnt int64
- Stbcnt int64
- Tai int32
- Pad_cgo_3 [44]byte
-}
-
-type Time_t int64
-
-type Tms struct {
- Utime int64
- Stime int64
- Cutime int64
- Cstime int64
-}
-
-type Utimbuf struct {
- Actime int64
- Modtime int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev uint64
- Ino uint64
- Nlink uint64
- Mode uint32
- Uid uint32
- Gid uint32
- X__pad2 int32
- Rdev uint64
- Size int64
- Blksize int64
- Blocks int64
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- X__glibc_reserved4 uint64
- X__glibc_reserved5 uint64
- X__glibc_reserved6 uint64
-}
-
-type Statfs_t struct {
- Type int64
- Bsize int64
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Namelen int64
- Frsize int64
- Flags int64
- Spare [4]int64
-}
-
-type Dirent struct {
- Ino uint64
- Off int64
- Reclen uint16
- Type uint8
- Name [256]uint8
- Pad_cgo_0 [5]byte
-}
-
-type Fsid struct {
- X__val [2]int32
-}
-
-type Flock_t struct {
- Type int16
- Whence int16
- Pad_cgo_0 [4]byte
- Start int64
- Len int64
- Pid int32
- Pad_cgo_1 [4]byte
-}
-
-const (
- FADV_NORMAL = 0x0
- FADV_RANDOM = 0x1
- FADV_SEQUENTIAL = 0x2
- FADV_WILLNEED = 0x3
- FADV_DONTNEED = 0x4
- FADV_NOREUSE = 0x5
-)
-
-type RawSockaddrInet4 struct {
- Family uint16
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]uint8
-}
-
-type RawSockaddrInet6 struct {
- Family uint16
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Family uint16
- Path [108]int8
-}
-
-type RawSockaddrLinklayer struct {
- Family uint16
- Protocol uint16
- Ifindex int32
- Hatype uint16
- Pkttype uint8
- Halen uint8
- Addr [8]uint8
-}
-
-type RawSockaddrNetlink struct {
- Family uint16
- Pad uint16
- Pid uint32
- Groups uint32
-}
-
-type RawSockaddrHCI struct {
- Family uint16
- Dev uint16
- Channel uint16
-}
-
-type RawSockaddr struct {
- Family uint16
- Data [14]uint8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [96]uint8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPMreqn struct {
- Multiaddr [4]byte /* in_addr */
- Address [4]byte /* in_addr */
- Ifindex int32
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Pad_cgo_0 [4]byte
- Iov *Iovec
- Iovlen uint64
- Control *byte
- Controllen uint64
- Flags int32
- Pad_cgo_1 [4]byte
-}
-
-type Cmsghdr struct {
- Len uint64
- Level int32
- Type int32
- X__cmsg_data [0]uint8
-}
-
-type Inet4Pktinfo struct {
- Ifindex int32
- Spec_dst [4]byte /* in_addr */
- Addr [4]byte /* in_addr */
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Data [8]uint32
-}
-
-type Ucred struct {
- Pid int32
- Uid uint32
- Gid uint32
-}
-
-type TCPInfo struct {
- State uint8
- Ca_state uint8
- Retransmits uint8
- Probes uint8
- Backoff uint8
- Options uint8
- Pad_cgo_0 [2]byte
- Rto uint32
- Ato uint32
- Snd_mss uint32
- Rcv_mss uint32
- Unacked uint32
- Sacked uint32
- Lost uint32
- Retrans uint32
- Fackets uint32
- Last_data_sent uint32
- Last_ack_sent uint32
- Last_data_recv uint32
- Last_ack_recv uint32
- Pmtu uint32
- Rcv_ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Snd_ssthresh uint32
- Snd_cwnd uint32
- Advmss uint32
- Reordering uint32
- Rcv_rtt uint32
- Rcv_space uint32
- Total_retrans uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x70
- SizeofSockaddrUnix = 0x6e
- SizeofSockaddrLinklayer = 0x14
- SizeofSockaddrNetlink = 0xc
- SizeofSockaddrHCI = 0x6
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPMreqn = 0xc
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x38
- SizeofCmsghdr = 0x10
- SizeofInet4Pktinfo = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
- SizeofUcred = 0xc
- SizeofTCPInfo = 0x68
-)
-
-const (
- IFA_UNSPEC = 0x0
- IFA_ADDRESS = 0x1
- IFA_LOCAL = 0x2
- IFA_LABEL = 0x3
- IFA_BROADCAST = 0x4
- IFA_ANYCAST = 0x5
- IFA_CACHEINFO = 0x6
- IFA_MULTICAST = 0x7
- IFLA_UNSPEC = 0x0
- IFLA_ADDRESS = 0x1
- IFLA_BROADCAST = 0x2
- IFLA_IFNAME = 0x3
- IFLA_MTU = 0x4
- IFLA_LINK = 0x5
- IFLA_QDISC = 0x6
- IFLA_STATS = 0x7
- IFLA_COST = 0x8
- IFLA_PRIORITY = 0x9
- IFLA_MASTER = 0xa
- IFLA_WIRELESS = 0xb
- IFLA_PROTINFO = 0xc
- IFLA_TXQLEN = 0xd
- IFLA_MAP = 0xe
- IFLA_WEIGHT = 0xf
- IFLA_OPERSTATE = 0x10
- IFLA_LINKMODE = 0x11
- IFLA_LINKINFO = 0x12
- IFLA_NET_NS_PID = 0x13
- IFLA_IFALIAS = 0x14
- IFLA_MAX = 0x23
- RT_SCOPE_UNIVERSE = 0x0
- RT_SCOPE_SITE = 0xc8
- RT_SCOPE_LINK = 0xfd
- RT_SCOPE_HOST = 0xfe
- RT_SCOPE_NOWHERE = 0xff
- RT_TABLE_UNSPEC = 0x0
- RT_TABLE_COMPAT = 0xfc
- RT_TABLE_DEFAULT = 0xfd
- RT_TABLE_MAIN = 0xfe
- RT_TABLE_LOCAL = 0xff
- RT_TABLE_MAX = 0xffffffff
- RTA_UNSPEC = 0x0
- RTA_DST = 0x1
- RTA_SRC = 0x2
- RTA_IIF = 0x3
- RTA_OIF = 0x4
- RTA_GATEWAY = 0x5
- RTA_PRIORITY = 0x6
- RTA_PREFSRC = 0x7
- RTA_METRICS = 0x8
- RTA_MULTIPATH = 0x9
- RTA_FLOW = 0xb
- RTA_CACHEINFO = 0xc
- RTA_TABLE = 0xf
- RTN_UNSPEC = 0x0
- RTN_UNICAST = 0x1
- RTN_LOCAL = 0x2
- RTN_BROADCAST = 0x3
- RTN_ANYCAST = 0x4
- RTN_MULTICAST = 0x5
- RTN_BLACKHOLE = 0x6
- RTN_UNREACHABLE = 0x7
- RTN_PROHIBIT = 0x8
- RTN_THROW = 0x9
- RTN_NAT = 0xa
- RTN_XRESOLVE = 0xb
- RTNLGRP_NONE = 0x0
- RTNLGRP_LINK = 0x1
- RTNLGRP_NOTIFY = 0x2
- RTNLGRP_NEIGH = 0x3
- RTNLGRP_TC = 0x4
- RTNLGRP_IPV4_IFADDR = 0x5
- RTNLGRP_IPV4_MROUTE = 0x6
- RTNLGRP_IPV4_ROUTE = 0x7
- RTNLGRP_IPV4_RULE = 0x8
- RTNLGRP_IPV6_IFADDR = 0x9
- RTNLGRP_IPV6_MROUTE = 0xa
- RTNLGRP_IPV6_ROUTE = 0xb
- RTNLGRP_IPV6_IFINFO = 0xc
- RTNLGRP_IPV6_PREFIX = 0x12
- RTNLGRP_IPV6_RULE = 0x13
- RTNLGRP_ND_USEROPT = 0x14
- SizeofNlMsghdr = 0x10
- SizeofNlMsgerr = 0x14
- SizeofRtGenmsg = 0x1
- SizeofNlAttr = 0x4
- SizeofRtAttr = 0x4
- SizeofIfInfomsg = 0x10
- SizeofIfAddrmsg = 0x8
- SizeofRtMsg = 0xc
- SizeofRtNexthop = 0x8
-)
-
-type NlMsghdr struct {
- Len uint32
- Type uint16
- Flags uint16
- Seq uint32
- Pid uint32
-}
-
-type NlMsgerr struct {
- Error int32
- Msg NlMsghdr
-}
-
-type RtGenmsg struct {
- Family uint8
-}
-
-type NlAttr struct {
- Len uint16
- Type uint16
-}
-
-type RtAttr struct {
- Len uint16
- Type uint16
-}
-
-type IfInfomsg struct {
- Family uint8
- X__ifi_pad uint8
- Type uint16
- Index int32
- Flags uint32
- Change uint32
-}
-
-type IfAddrmsg struct {
- Family uint8
- Prefixlen uint8
- Flags uint8
- Scope uint8
- Index uint32
-}
-
-type RtMsg struct {
- Family uint8
- Dst_len uint8
- Src_len uint8
- Tos uint8
- Table uint8
- Protocol uint8
- Scope uint8
- Type uint8
- Flags uint32
-}
-
-type RtNexthop struct {
- Len uint16
- Flags uint8
- Hops uint8
- Ifindex int32
-}
-
-const (
- SizeofSockFilter = 0x8
- SizeofSockFprog = 0x10
-)
-
-type SockFilter struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type SockFprog struct {
- Len uint16
- Pad_cgo_0 [6]byte
- Filter *SockFilter
-}
-
-type InotifyEvent struct {
- Wd int32
- Mask uint32
- Cookie uint32
- Len uint32
- Name [0]uint8
-}
-
-const SizeofInotifyEvent = 0x10
-
-type PtraceRegs struct {
- Gpr [32]uint64
- Nip uint64
- Msr uint64
- Orig_gpr3 uint64
- Ctr uint64
- Link uint64
- Xer uint64
- Ccr uint64
- Softe uint64
- Trap uint64
- Dar uint64
- Dsisr uint64
- Result uint64
-}
-
-type FdSet struct {
- Bits [16]int64
-}
-
-type Sysinfo_t struct {
- Uptime int64
- Loads [3]uint64
- Totalram uint64
- Freeram uint64
- Sharedram uint64
- Bufferram uint64
- Totalswap uint64
- Freeswap uint64
- Procs uint16
- Pad uint16
- Pad_cgo_0 [4]byte
- Totalhigh uint64
- Freehigh uint64
- Unit uint32
- X_f [0]uint8
- Pad_cgo_1 [4]byte
-}
-
-type Utsname struct {
- Sysname [65]uint8
- Nodename [65]uint8
- Release [65]uint8
- Version [65]uint8
- Machine [65]uint8
- Domainname [65]uint8
-}
-
-type Ustat_t struct {
- Tfree int32
- Pad_cgo_0 [4]byte
- Tinode uint64
- Fname [6]uint8
- Fpack [6]uint8
- Pad_cgo_1 [4]byte
-}
-
-type EpollEvent struct {
- Events uint32
- X_padFd int32
- Fd int32
- Pad int32
-}
-
-const (
- AT_FDCWD = -0x64
- AT_REMOVEDIR = 0x200
- AT_SYMLINK_FOLLOW = 0x400
- AT_SYMLINK_NOFOLLOW = 0x100
-)
-
-type PollFd struct {
- Fd int32
- Events int16
- Revents int16
-}
-
-const (
- POLLIN = 0x1
- POLLPRI = 0x2
- POLLOUT = 0x4
- POLLRDHUP = 0x2000
- POLLERR = 0x8
- POLLHUP = 0x10
- POLLNVAL = 0x20
-)
-
-type Sigset_t struct {
- X__val [16]uint64
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [19]uint8
- Line uint8
- Ispeed uint32
- Ospeed uint32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/newt/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go
deleted file mode 100644
index 7db4c78c..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go
+++ /dev/null
@@ -1,634 +0,0 @@
-// +build ppc64le,linux
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- PathMax = 0x1000
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Timex struct {
- Modes uint32
- Pad_cgo_0 [4]byte
- Offset int64
- Freq int64
- Maxerror int64
- Esterror int64
- Status int32
- Pad_cgo_1 [4]byte
- Constant int64
- Precision int64
- Tolerance int64
- Time Timeval
- Tick int64
- Ppsfreq int64
- Jitter int64
- Shift int32
- Pad_cgo_2 [4]byte
- Stabil int64
- Jitcnt int64
- Calcnt int64
- Errcnt int64
- Stbcnt int64
- Tai int32
- Pad_cgo_3 [44]byte
-}
-
-type Time_t int64
-
-type Tms struct {
- Utime int64
- Stime int64
- Cutime int64
- Cstime int64
-}
-
-type Utimbuf struct {
- Actime int64
- Modtime int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev uint64
- Ino uint64
- Nlink uint64
- Mode uint32
- Uid uint32
- Gid uint32
- X__pad2 int32
- Rdev uint64
- Size int64
- Blksize int64
- Blocks int64
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- X__glibc_reserved4 uint64
- X__glibc_reserved5 uint64
- X__glibc_reserved6 uint64
-}
-
-type Statfs_t struct {
- Type int64
- Bsize int64
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Namelen int64
- Frsize int64
- Flags int64
- Spare [4]int64
-}
-
-type Dirent struct {
- Ino uint64
- Off int64
- Reclen uint16
- Type uint8
- Name [256]uint8
- Pad_cgo_0 [5]byte
-}
-
-type Fsid struct {
- X__val [2]int32
-}
-
-type Flock_t struct {
- Type int16
- Whence int16
- Pad_cgo_0 [4]byte
- Start int64
- Len int64
- Pid int32
- Pad_cgo_1 [4]byte
-}
-
-const (
- FADV_NORMAL = 0x0
- FADV_RANDOM = 0x1
- FADV_SEQUENTIAL = 0x2
- FADV_WILLNEED = 0x3
- FADV_DONTNEED = 0x4
- FADV_NOREUSE = 0x5
-)
-
-type RawSockaddrInet4 struct {
- Family uint16
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]uint8
-}
-
-type RawSockaddrInet6 struct {
- Family uint16
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Family uint16
- Path [108]int8
-}
-
-type RawSockaddrLinklayer struct {
- Family uint16
- Protocol uint16
- Ifindex int32
- Hatype uint16
- Pkttype uint8
- Halen uint8
- Addr [8]uint8
-}
-
-type RawSockaddrNetlink struct {
- Family uint16
- Pad uint16
- Pid uint32
- Groups uint32
-}
-
-type RawSockaddrHCI struct {
- Family uint16
- Dev uint16
- Channel uint16
-}
-
-type RawSockaddr struct {
- Family uint16
- Data [14]uint8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [96]uint8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPMreqn struct {
- Multiaddr [4]byte /* in_addr */
- Address [4]byte /* in_addr */
- Ifindex int32
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Pad_cgo_0 [4]byte
- Iov *Iovec
- Iovlen uint64
- Control *byte
- Controllen uint64
- Flags int32
- Pad_cgo_1 [4]byte
-}
-
-type Cmsghdr struct {
- Len uint64
- Level int32
- Type int32
- X__cmsg_data [0]uint8
-}
-
-type Inet4Pktinfo struct {
- Ifindex int32
- Spec_dst [4]byte /* in_addr */
- Addr [4]byte /* in_addr */
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Data [8]uint32
-}
-
-type Ucred struct {
- Pid int32
- Uid uint32
- Gid uint32
-}
-
-type TCPInfo struct {
- State uint8
- Ca_state uint8
- Retransmits uint8
- Probes uint8
- Backoff uint8
- Options uint8
- Pad_cgo_0 [2]byte
- Rto uint32
- Ato uint32
- Snd_mss uint32
- Rcv_mss uint32
- Unacked uint32
- Sacked uint32
- Lost uint32
- Retrans uint32
- Fackets uint32
- Last_data_sent uint32
- Last_ack_sent uint32
- Last_data_recv uint32
- Last_ack_recv uint32
- Pmtu uint32
- Rcv_ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Snd_ssthresh uint32
- Snd_cwnd uint32
- Advmss uint32
- Reordering uint32
- Rcv_rtt uint32
- Rcv_space uint32
- Total_retrans uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x70
- SizeofSockaddrUnix = 0x6e
- SizeofSockaddrLinklayer = 0x14
- SizeofSockaddrNetlink = 0xc
- SizeofSockaddrHCI = 0x6
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPMreqn = 0xc
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x38
- SizeofCmsghdr = 0x10
- SizeofInet4Pktinfo = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
- SizeofUcred = 0xc
- SizeofTCPInfo = 0x68
-)
-
-const (
- IFA_UNSPEC = 0x0
- IFA_ADDRESS = 0x1
- IFA_LOCAL = 0x2
- IFA_LABEL = 0x3
- IFA_BROADCAST = 0x4
- IFA_ANYCAST = 0x5
- IFA_CACHEINFO = 0x6
- IFA_MULTICAST = 0x7
- IFLA_UNSPEC = 0x0
- IFLA_ADDRESS = 0x1
- IFLA_BROADCAST = 0x2
- IFLA_IFNAME = 0x3
- IFLA_MTU = 0x4
- IFLA_LINK = 0x5
- IFLA_QDISC = 0x6
- IFLA_STATS = 0x7
- IFLA_COST = 0x8
- IFLA_PRIORITY = 0x9
- IFLA_MASTER = 0xa
- IFLA_WIRELESS = 0xb
- IFLA_PROTINFO = 0xc
- IFLA_TXQLEN = 0xd
- IFLA_MAP = 0xe
- IFLA_WEIGHT = 0xf
- IFLA_OPERSTATE = 0x10
- IFLA_LINKMODE = 0x11
- IFLA_LINKINFO = 0x12
- IFLA_NET_NS_PID = 0x13
- IFLA_IFALIAS = 0x14
- IFLA_MAX = 0x22
- RT_SCOPE_UNIVERSE = 0x0
- RT_SCOPE_SITE = 0xc8
- RT_SCOPE_LINK = 0xfd
- RT_SCOPE_HOST = 0xfe
- RT_SCOPE_NOWHERE = 0xff
- RT_TABLE_UNSPEC = 0x0
- RT_TABLE_COMPAT = 0xfc
- RT_TABLE_DEFAULT = 0xfd
- RT_TABLE_MAIN = 0xfe
- RT_TABLE_LOCAL = 0xff
- RT_TABLE_MAX = 0xffffffff
- RTA_UNSPEC = 0x0
- RTA_DST = 0x1
- RTA_SRC = 0x2
- RTA_IIF = 0x3
- RTA_OIF = 0x4
- RTA_GATEWAY = 0x5
- RTA_PRIORITY = 0x6
- RTA_PREFSRC = 0x7
- RTA_METRICS = 0x8
- RTA_MULTIPATH = 0x9
- RTA_FLOW = 0xb
- RTA_CACHEINFO = 0xc
- RTA_TABLE = 0xf
- RTN_UNSPEC = 0x0
- RTN_UNICAST = 0x1
- RTN_LOCAL = 0x2
- RTN_BROADCAST = 0x3
- RTN_ANYCAST = 0x4
- RTN_MULTICAST = 0x5
- RTN_BLACKHOLE = 0x6
- RTN_UNREACHABLE = 0x7
- RTN_PROHIBIT = 0x8
- RTN_THROW = 0x9
- RTN_NAT = 0xa
- RTN_XRESOLVE = 0xb
- RTNLGRP_NONE = 0x0
- RTNLGRP_LINK = 0x1
- RTNLGRP_NOTIFY = 0x2
- RTNLGRP_NEIGH = 0x3
- RTNLGRP_TC = 0x4
- RTNLGRP_IPV4_IFADDR = 0x5
- RTNLGRP_IPV4_MROUTE = 0x6
- RTNLGRP_IPV4_ROUTE = 0x7
- RTNLGRP_IPV4_RULE = 0x8
- RTNLGRP_IPV6_IFADDR = 0x9
- RTNLGRP_IPV6_MROUTE = 0xa
- RTNLGRP_IPV6_ROUTE = 0xb
- RTNLGRP_IPV6_IFINFO = 0xc
- RTNLGRP_IPV6_PREFIX = 0x12
- RTNLGRP_IPV6_RULE = 0x13
- RTNLGRP_ND_USEROPT = 0x14
- SizeofNlMsghdr = 0x10
- SizeofNlMsgerr = 0x14
- SizeofRtGenmsg = 0x1
- SizeofNlAttr = 0x4
- SizeofRtAttr = 0x4
- SizeofIfInfomsg = 0x10
- SizeofIfAddrmsg = 0x8
- SizeofRtMsg = 0xc
- SizeofRtNexthop = 0x8
-)
-
-type NlMsghdr struct {
- Len uint32
- Type uint16
- Flags uint16
- Seq uint32
- Pid uint32
-}
-
-type NlMsgerr struct {
- Error int32
- Msg NlMsghdr
-}
-
-type RtGenmsg struct {
- Family uint8
-}
-
-type NlAttr struct {
- Len uint16
- Type uint16
-}
-
-type RtAttr struct {
- Len uint16
- Type uint16
-}
-
-type IfInfomsg struct {
- Family uint8
- X__ifi_pad uint8
- Type uint16
- Index int32
- Flags uint32
- Change uint32
-}
-
-type IfAddrmsg struct {
- Family uint8
- Prefixlen uint8
- Flags uint8
- Scope uint8
- Index uint32
-}
-
-type RtMsg struct {
- Family uint8
- Dst_len uint8
- Src_len uint8
- Tos uint8
- Table uint8
- Protocol uint8
- Scope uint8
- Type uint8
- Flags uint32
-}
-
-type RtNexthop struct {
- Len uint16
- Flags uint8
- Hops uint8
- Ifindex int32
-}
-
-const (
- SizeofSockFilter = 0x8
- SizeofSockFprog = 0x10
-)
-
-type SockFilter struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type SockFprog struct {
- Len uint16
- Pad_cgo_0 [6]byte
- Filter *SockFilter
-}
-
-type InotifyEvent struct {
- Wd int32
- Mask uint32
- Cookie uint32
- Len uint32
- Name [0]uint8
-}
-
-const SizeofInotifyEvent = 0x10
-
-type PtraceRegs struct {
- Gpr [32]uint64
- Nip uint64
- Msr uint64
- Orig_gpr3 uint64
- Ctr uint64
- Link uint64
- Xer uint64
- Ccr uint64
- Softe uint64
- Trap uint64
- Dar uint64
- Dsisr uint64
- Result uint64
-}
-
-type FdSet struct {
- Bits [16]int64
-}
-
-type Sysinfo_t struct {
- Uptime int64
- Loads [3]uint64
- Totalram uint64
- Freeram uint64
- Sharedram uint64
- Bufferram uint64
- Totalswap uint64
- Freeswap uint64
- Procs uint16
- Pad uint16
- Pad_cgo_0 [4]byte
- Totalhigh uint64
- Freehigh uint64
- Unit uint32
- X_f [0]uint8
- Pad_cgo_1 [4]byte
-}
-
-type Utsname struct {
- Sysname [65]uint8
- Nodename [65]uint8
- Release [65]uint8
- Version [65]uint8
- Machine [65]uint8
- Domainname [65]uint8
-}
-
-type Ustat_t struct {
- Tfree int32
- Pad_cgo_0 [4]byte
- Tinode uint64
- Fname [6]uint8
- Fpack [6]uint8
- Pad_cgo_1 [4]byte
-}
-
-type EpollEvent struct {
- Events uint32
- X_padFd int32
- Fd int32
- Pad int32
-}
-
-const (
- AT_FDCWD = -0x64
- AT_REMOVEDIR = 0x200
- AT_SYMLINK_FOLLOW = 0x400
- AT_SYMLINK_NOFOLLOW = 0x100
-)
-
-type PollFd struct {
- Fd int32
- Events int16
- Revents int16
-}
-
-const (
- POLLIN = 0x1
- POLLPRI = 0x2
- POLLOUT = 0x4
- POLLRDHUP = 0x2000
- POLLERR = 0x8
- POLLHUP = 0x10
- POLLNVAL = 0x20
-)
-
-type Sigset_t struct {
- X__val [16]uint64
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [19]uint8
- Line uint8
- Ispeed uint32
- Ospeed uint32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/newt/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go
deleted file mode 100644
index 76ee57cb..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go
+++ /dev/null
@@ -1,649 +0,0 @@
-// +build s390x,linux
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -fsigned-char types_linux.go
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- PathMax = 0x1000
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Timex struct {
- Modes uint32
- _ [4]byte
- Offset int64
- Freq int64
- Maxerror int64
- Esterror int64
- Status int32
- _ [4]byte
- Constant int64
- Precision int64
- Tolerance int64
- Time Timeval
- Tick int64
- Ppsfreq int64
- Jitter int64
- Shift int32
- _ [4]byte
- Stabil int64
- Jitcnt int64
- Calcnt int64
- Errcnt int64
- Stbcnt int64
- Tai int32
- _ [44]byte
-}
-
-type Time_t int64
-
-type Tms struct {
- Utime int64
- Stime int64
- Cutime int64
- Cstime int64
-}
-
-type Utimbuf struct {
- Actime int64
- Modtime int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev uint64
- Ino uint64
- Nlink uint64
- Mode uint32
- Uid uint32
- Gid uint32
- _ int32
- Rdev uint64
- Size int64
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- Blksize int64
- Blocks int64
- _ [3]int64
-}
-
-type Statfs_t struct {
- Type uint32
- Bsize uint32
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Namelen uint32
- Frsize uint32
- Flags uint32
- Spare [4]uint32
- _ [4]byte
-}
-
-type Dirent struct {
- Ino uint64
- Off int64
- Reclen uint16
- Type uint8
- Name [256]int8
- _ [5]byte
-}
-
-type Fsid struct {
- _ [2]int32
-}
-
-type Flock_t struct {
- Type int16
- Whence int16
- _ [4]byte
- Start int64
- Len int64
- Pid int32
- _ [4]byte
-}
-
-const (
- FADV_NORMAL = 0x0
- FADV_RANDOM = 0x1
- FADV_SEQUENTIAL = 0x2
- FADV_WILLNEED = 0x3
- FADV_DONTNEED = 0x6
- FADV_NOREUSE = 0x7
-)
-
-type RawSockaddrInet4 struct {
- Family uint16
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]uint8
-}
-
-type RawSockaddrInet6 struct {
- Family uint16
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Family uint16
- Path [108]int8
-}
-
-type RawSockaddrLinklayer struct {
- Family uint16
- Protocol uint16
- Ifindex int32
- Hatype uint16
- Pkttype uint8
- Halen uint8
- Addr [8]uint8
-}
-
-type RawSockaddrNetlink struct {
- Family uint16
- Pad uint16
- Pid uint32
- Groups uint32
-}
-
-type RawSockaddrHCI struct {
- Family uint16
- Dev uint16
- Channel uint16
-}
-
-type RawSockaddr struct {
- Family uint16
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [96]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPMreqn struct {
- Multiaddr [4]byte /* in_addr */
- Address [4]byte /* in_addr */
- Ifindex int32
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- _ [4]byte
- Iov *Iovec
- Iovlen uint64
- Control *byte
- Controllen uint64
- Flags int32
- _ [4]byte
-}
-
-type Cmsghdr struct {
- Len uint64
- Level int32
- Type int32
-}
-
-type Inet4Pktinfo struct {
- Ifindex int32
- Spec_dst [4]byte /* in_addr */
- Addr [4]byte /* in_addr */
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Data [8]uint32
-}
-
-type Ucred struct {
- Pid int32
- Uid uint32
- Gid uint32
-}
-
-type TCPInfo struct {
- State uint8
- Ca_state uint8
- Retransmits uint8
- Probes uint8
- Backoff uint8
- Options uint8
- _ [2]byte
- Rto uint32
- Ato uint32
- Snd_mss uint32
- Rcv_mss uint32
- Unacked uint32
- Sacked uint32
- Lost uint32
- Retrans uint32
- Fackets uint32
- Last_data_sent uint32
- Last_ack_sent uint32
- Last_data_recv uint32
- Last_ack_recv uint32
- Pmtu uint32
- Rcv_ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Snd_ssthresh uint32
- Snd_cwnd uint32
- Advmss uint32
- Reordering uint32
- Rcv_rtt uint32
- Rcv_space uint32
- Total_retrans uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x70
- SizeofSockaddrUnix = 0x6e
- SizeofSockaddrLinklayer = 0x14
- SizeofSockaddrNetlink = 0xc
- SizeofSockaddrHCI = 0x6
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPMreqn = 0xc
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x38
- SizeofCmsghdr = 0x10
- SizeofInet4Pktinfo = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
- SizeofUcred = 0xc
- SizeofTCPInfo = 0x68
-)
-
-const (
- IFA_UNSPEC = 0x0
- IFA_ADDRESS = 0x1
- IFA_LOCAL = 0x2
- IFA_LABEL = 0x3
- IFA_BROADCAST = 0x4
- IFA_ANYCAST = 0x5
- IFA_CACHEINFO = 0x6
- IFA_MULTICAST = 0x7
- IFLA_UNSPEC = 0x0
- IFLA_ADDRESS = 0x1
- IFLA_BROADCAST = 0x2
- IFLA_IFNAME = 0x3
- IFLA_MTU = 0x4
- IFLA_LINK = 0x5
- IFLA_QDISC = 0x6
- IFLA_STATS = 0x7
- IFLA_COST = 0x8
- IFLA_PRIORITY = 0x9
- IFLA_MASTER = 0xa
- IFLA_WIRELESS = 0xb
- IFLA_PROTINFO = 0xc
- IFLA_TXQLEN = 0xd
- IFLA_MAP = 0xe
- IFLA_WEIGHT = 0xf
- IFLA_OPERSTATE = 0x10
- IFLA_LINKMODE = 0x11
- IFLA_LINKINFO = 0x12
- IFLA_NET_NS_PID = 0x13
- IFLA_IFALIAS = 0x14
- IFLA_MAX = 0x27
- RT_SCOPE_UNIVERSE = 0x0
- RT_SCOPE_SITE = 0xc8
- RT_SCOPE_LINK = 0xfd
- RT_SCOPE_HOST = 0xfe
- RT_SCOPE_NOWHERE = 0xff
- RT_TABLE_UNSPEC = 0x0
- RT_TABLE_COMPAT = 0xfc
- RT_TABLE_DEFAULT = 0xfd
- RT_TABLE_MAIN = 0xfe
- RT_TABLE_LOCAL = 0xff
- RT_TABLE_MAX = 0xffffffff
- RTA_UNSPEC = 0x0
- RTA_DST = 0x1
- RTA_SRC = 0x2
- RTA_IIF = 0x3
- RTA_OIF = 0x4
- RTA_GATEWAY = 0x5
- RTA_PRIORITY = 0x6
- RTA_PREFSRC = 0x7
- RTA_METRICS = 0x8
- RTA_MULTIPATH = 0x9
- RTA_FLOW = 0xb
- RTA_CACHEINFO = 0xc
- RTA_TABLE = 0xf
- RTN_UNSPEC = 0x0
- RTN_UNICAST = 0x1
- RTN_LOCAL = 0x2
- RTN_BROADCAST = 0x3
- RTN_ANYCAST = 0x4
- RTN_MULTICAST = 0x5
- RTN_BLACKHOLE = 0x6
- RTN_UNREACHABLE = 0x7
- RTN_PROHIBIT = 0x8
- RTN_THROW = 0x9
- RTN_NAT = 0xa
- RTN_XRESOLVE = 0xb
- RTNLGRP_NONE = 0x0
- RTNLGRP_LINK = 0x1
- RTNLGRP_NOTIFY = 0x2
- RTNLGRP_NEIGH = 0x3
- RTNLGRP_TC = 0x4
- RTNLGRP_IPV4_IFADDR = 0x5
- RTNLGRP_IPV4_MROUTE = 0x6
- RTNLGRP_IPV4_ROUTE = 0x7
- RTNLGRP_IPV4_RULE = 0x8
- RTNLGRP_IPV6_IFADDR = 0x9
- RTNLGRP_IPV6_MROUTE = 0xa
- RTNLGRP_IPV6_ROUTE = 0xb
- RTNLGRP_IPV6_IFINFO = 0xc
- RTNLGRP_IPV6_PREFIX = 0x12
- RTNLGRP_IPV6_RULE = 0x13
- RTNLGRP_ND_USEROPT = 0x14
- SizeofNlMsghdr = 0x10
- SizeofNlMsgerr = 0x14
- SizeofRtGenmsg = 0x1
- SizeofNlAttr = 0x4
- SizeofRtAttr = 0x4
- SizeofIfInfomsg = 0x10
- SizeofIfAddrmsg = 0x8
- SizeofRtMsg = 0xc
- SizeofRtNexthop = 0x8
-)
-
-type NlMsghdr struct {
- Len uint32
- Type uint16
- Flags uint16
- Seq uint32
- Pid uint32
-}
-
-type NlMsgerr struct {
- Error int32
- Msg NlMsghdr
-}
-
-type RtGenmsg struct {
- Family uint8
-}
-
-type NlAttr struct {
- Len uint16
- Type uint16
-}
-
-type RtAttr struct {
- Len uint16
- Type uint16
-}
-
-type IfInfomsg struct {
- Family uint8
- _ uint8
- Type uint16
- Index int32
- Flags uint32
- Change uint32
-}
-
-type IfAddrmsg struct {
- Family uint8
- Prefixlen uint8
- Flags uint8
- Scope uint8
- Index uint32
-}
-
-type RtMsg struct {
- Family uint8
- Dst_len uint8
- Src_len uint8
- Tos uint8
- Table uint8
- Protocol uint8
- Scope uint8
- Type uint8
- Flags uint32
-}
-
-type RtNexthop struct {
- Len uint16
- Flags uint8
- Hops uint8
- Ifindex int32
-}
-
-const (
- SizeofSockFilter = 0x8
- SizeofSockFprog = 0x10
-)
-
-type SockFilter struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type SockFprog struct {
- Len uint16
- _ [6]byte
- Filter *SockFilter
-}
-
-type InotifyEvent struct {
- Wd int32
- Mask uint32
- Cookie uint32
- Len uint32
-}
-
-const SizeofInotifyEvent = 0x10
-
-type PtraceRegs struct {
- Psw PtracePsw
- Gprs [16]uint64
- Acrs [16]uint32
- Orig_gpr2 uint64
- Fp_regs PtraceFpregs
- Per_info PtracePer
- Ieee_instruction_pointer uint64
-}
-
-type PtracePsw struct {
- Mask uint64
- Addr uint64
-}
-
-type PtraceFpregs struct {
- Fpc uint32
- _ [4]byte
- Fprs [16]float64
-}
-
-type PtracePer struct {
- _ [0]uint64
- _ [24]byte
- _ [8]byte
- Starting_addr uint64
- Ending_addr uint64
- Perc_atmid uint16
- _ [6]byte
- Address uint64
- Access_id uint8
- _ [7]byte
-}
-
-type FdSet struct {
- Bits [16]int64
-}
-
-type Sysinfo_t struct {
- Uptime int64
- Loads [3]uint64
- Totalram uint64
- Freeram uint64
- Sharedram uint64
- Bufferram uint64
- Totalswap uint64
- Freeswap uint64
- Procs uint16
- Pad uint16
- _ [4]byte
- Totalhigh uint64
- Freehigh uint64
- Unit uint32
- _ [0]int8
- _ [4]byte
-}
-
-type Utsname struct {
- Sysname [65]int8
- Nodename [65]int8
- Release [65]int8
- Version [65]int8
- Machine [65]int8
- Domainname [65]int8
-}
-
-type Ustat_t struct {
- Tfree int32
- _ [4]byte
- Tinode uint64
- Fname [6]int8
- Fpack [6]int8
- _ [4]byte
-}
-
-type EpollEvent struct {
- Events uint32
- _ int32
- Fd int32
- Pad int32
-}
-
-const (
- AT_FDCWD = -0x64
- AT_REMOVEDIR = 0x200
- AT_SYMLINK_FOLLOW = 0x400
- AT_SYMLINK_NOFOLLOW = 0x100
-)
-
-type PollFd struct {
- Fd int32
- Events int16
- Revents int16
-}
-
-const (
- POLLIN = 0x1
- POLLPRI = 0x2
- POLLOUT = 0x4
- POLLRDHUP = 0x2000
- POLLERR = 0x8
- POLLHUP = 0x10
- POLLNVAL = 0x20
-)
-
-type Sigset_t struct {
- X__val [16]uint64
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Line uint8
- Cc [19]uint8
- Ispeed uint32
- Ospeed uint32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go b/newt/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go
deleted file mode 100644
index 7d18b704..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go
+++ /dev/null
@@ -1,640 +0,0 @@
-// +build sparc64,linux
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go | go run mkpost.go
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- PathMax = 0x1000
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int32
- Pad_cgo_0 [4]byte
-}
-
-type Timex struct {
- Modes uint32
- Pad_cgo_0 [4]byte
- Offset int64
- Freq int64
- Maxerror int64
- Esterror int64
- Status int32
- Pad_cgo_1 [4]byte
- Constant int64
- Precision int64
- Tolerance int64
- Time Timeval
- Tick int64
- Ppsfreq int64
- Jitter int64
- Shift int32
- Pad_cgo_2 [4]byte
- Stabil int64
- Jitcnt int64
- Calcnt int64
- Errcnt int64
- Stbcnt int64
- Tai int32
- Pad_cgo_3 [44]byte
-}
-
-type Time_t int64
-
-type Tms struct {
- Utime int64
- Stime int64
- Cutime int64
- Cstime int64
-}
-
-type Utimbuf struct {
- Actime int64
- Modtime int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev uint64
- X__pad1 uint16
- Pad_cgo_0 [6]byte
- Ino uint64
- Mode uint32
- Nlink uint32
- Uid uint32
- Gid uint32
- Rdev uint64
- X__pad2 uint16
- Pad_cgo_1 [6]byte
- Size int64
- Blksize int64
- Blocks int64
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- X__glibc_reserved4 uint64
- X__glibc_reserved5 uint64
-}
-
-type Statfs_t struct {
- Type int64
- Bsize int64
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Namelen int64
- Frsize int64
- Flags int64
- Spare [4]int64
-}
-
-type Dirent struct {
- Ino uint64
- Off int64
- Reclen uint16
- Type uint8
- Name [256]int8
- Pad_cgo_0 [5]byte
-}
-
-type Fsid struct {
- X__val [2]int32
-}
-
-type Flock_t struct {
- Type int16
- Whence int16
- Pad_cgo_0 [4]byte
- Start int64
- Len int64
- Pid int32
- X__glibc_reserved int16
- Pad_cgo_1 [2]byte
-}
-
-const (
- FADV_NORMAL = 0x0
- FADV_RANDOM = 0x1
- FADV_SEQUENTIAL = 0x2
- FADV_WILLNEED = 0x3
- FADV_DONTNEED = 0x4
- FADV_NOREUSE = 0x5
-)
-
-type RawSockaddrInet4 struct {
- Family uint16
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]uint8
-}
-
-type RawSockaddrInet6 struct {
- Family uint16
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Family uint16
- Path [108]int8
-}
-
-type RawSockaddrLinklayer struct {
- Family uint16
- Protocol uint16
- Ifindex int32
- Hatype uint16
- Pkttype uint8
- Halen uint8
- Addr [8]uint8
-}
-
-type RawSockaddrNetlink struct {
- Family uint16
- Pad uint16
- Pid uint32
- Groups uint32
-}
-
-type RawSockaddrHCI struct {
- Family uint16
- Dev uint16
- Channel uint16
-}
-
-type RawSockaddr struct {
- Family uint16
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [96]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPMreqn struct {
- Multiaddr [4]byte /* in_addr */
- Address [4]byte /* in_addr */
- Ifindex int32
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Pad_cgo_0 [4]byte
- Iov *Iovec
- Iovlen uint64
- Control *byte
- Controllen uint64
- Flags int32
- Pad_cgo_1 [4]byte
-}
-
-type Cmsghdr struct {
- Len uint64
- Level int32
- Type int32
-}
-
-type Inet4Pktinfo struct {
- Ifindex int32
- Spec_dst [4]byte /* in_addr */
- Addr [4]byte /* in_addr */
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Data [8]uint32
-}
-
-type Ucred struct {
- Pid int32
- Uid uint32
- Gid uint32
-}
-
-type TCPInfo struct {
- State uint8
- Ca_state uint8
- Retransmits uint8
- Probes uint8
- Backoff uint8
- Options uint8
- Pad_cgo_0 [2]byte
- Rto uint32
- Ato uint32
- Snd_mss uint32
- Rcv_mss uint32
- Unacked uint32
- Sacked uint32
- Lost uint32
- Retrans uint32
- Fackets uint32
- Last_data_sent uint32
- Last_ack_sent uint32
- Last_data_recv uint32
- Last_ack_recv uint32
- Pmtu uint32
- Rcv_ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Snd_ssthresh uint32
- Snd_cwnd uint32
- Advmss uint32
- Reordering uint32
- Rcv_rtt uint32
- Rcv_space uint32
- Total_retrans uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x70
- SizeofSockaddrUnix = 0x6e
- SizeofSockaddrLinklayer = 0x14
- SizeofSockaddrNetlink = 0xc
- SizeofSockaddrHCI = 0x6
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPMreqn = 0xc
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x38
- SizeofCmsghdr = 0x10
- SizeofInet4Pktinfo = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
- SizeofUcred = 0xc
- SizeofTCPInfo = 0x68
-)
-
-const (
- IFA_UNSPEC = 0x0
- IFA_ADDRESS = 0x1
- IFA_LOCAL = 0x2
- IFA_LABEL = 0x3
- IFA_BROADCAST = 0x4
- IFA_ANYCAST = 0x5
- IFA_CACHEINFO = 0x6
- IFA_MULTICAST = 0x7
- IFLA_UNSPEC = 0x0
- IFLA_ADDRESS = 0x1
- IFLA_BROADCAST = 0x2
- IFLA_IFNAME = 0x3
- IFLA_MTU = 0x4
- IFLA_LINK = 0x5
- IFLA_QDISC = 0x6
- IFLA_STATS = 0x7
- IFLA_COST = 0x8
- IFLA_PRIORITY = 0x9
- IFLA_MASTER = 0xa
- IFLA_WIRELESS = 0xb
- IFLA_PROTINFO = 0xc
- IFLA_TXQLEN = 0xd
- IFLA_MAP = 0xe
- IFLA_WEIGHT = 0xf
- IFLA_OPERSTATE = 0x10
- IFLA_LINKMODE = 0x11
- IFLA_LINKINFO = 0x12
- IFLA_NET_NS_PID = 0x13
- IFLA_IFALIAS = 0x14
- IFLA_MAX = 0x2a
- RT_SCOPE_UNIVERSE = 0x0
- RT_SCOPE_SITE = 0xc8
- RT_SCOPE_LINK = 0xfd
- RT_SCOPE_HOST = 0xfe
- RT_SCOPE_NOWHERE = 0xff
- RT_TABLE_UNSPEC = 0x0
- RT_TABLE_COMPAT = 0xfc
- RT_TABLE_DEFAULT = 0xfd
- RT_TABLE_MAIN = 0xfe
- RT_TABLE_LOCAL = 0xff
- RT_TABLE_MAX = 0xffffffff
- RTA_UNSPEC = 0x0
- RTA_DST = 0x1
- RTA_SRC = 0x2
- RTA_IIF = 0x3
- RTA_OIF = 0x4
- RTA_GATEWAY = 0x5
- RTA_PRIORITY = 0x6
- RTA_PREFSRC = 0x7
- RTA_METRICS = 0x8
- RTA_MULTIPATH = 0x9
- RTA_FLOW = 0xb
- RTA_CACHEINFO = 0xc
- RTA_TABLE = 0xf
- RTN_UNSPEC = 0x0
- RTN_UNICAST = 0x1
- RTN_LOCAL = 0x2
- RTN_BROADCAST = 0x3
- RTN_ANYCAST = 0x4
- RTN_MULTICAST = 0x5
- RTN_BLACKHOLE = 0x6
- RTN_UNREACHABLE = 0x7
- RTN_PROHIBIT = 0x8
- RTN_THROW = 0x9
- RTN_NAT = 0xa
- RTN_XRESOLVE = 0xb
- RTNLGRP_NONE = 0x0
- RTNLGRP_LINK = 0x1
- RTNLGRP_NOTIFY = 0x2
- RTNLGRP_NEIGH = 0x3
- RTNLGRP_TC = 0x4
- RTNLGRP_IPV4_IFADDR = 0x5
- RTNLGRP_IPV4_MROUTE = 0x6
- RTNLGRP_IPV4_ROUTE = 0x7
- RTNLGRP_IPV4_RULE = 0x8
- RTNLGRP_IPV6_IFADDR = 0x9
- RTNLGRP_IPV6_MROUTE = 0xa
- RTNLGRP_IPV6_ROUTE = 0xb
- RTNLGRP_IPV6_IFINFO = 0xc
- RTNLGRP_IPV6_PREFIX = 0x12
- RTNLGRP_IPV6_RULE = 0x13
- RTNLGRP_ND_USEROPT = 0x14
- SizeofNlMsghdr = 0x10
- SizeofNlMsgerr = 0x14
- SizeofRtGenmsg = 0x1
- SizeofNlAttr = 0x4
- SizeofRtAttr = 0x4
- SizeofIfInfomsg = 0x10
- SizeofIfAddrmsg = 0x8
- SizeofRtMsg = 0xc
- SizeofRtNexthop = 0x8
-)
-
-type NlMsghdr struct {
- Len uint32
- Type uint16
- Flags uint16
- Seq uint32
- Pid uint32
-}
-
-type NlMsgerr struct {
- Error int32
- Msg NlMsghdr
-}
-
-type RtGenmsg struct {
- Family uint8
-}
-
-type NlAttr struct {
- Len uint16
- Type uint16
-}
-
-type RtAttr struct {
- Len uint16
- Type uint16
-}
-
-type IfInfomsg struct {
- Family uint8
- X__ifi_pad uint8
- Type uint16
- Index int32
- Flags uint32
- Change uint32
-}
-
-type IfAddrmsg struct {
- Family uint8
- Prefixlen uint8
- Flags uint8
- Scope uint8
- Index uint32
-}
-
-type RtMsg struct {
- Family uint8
- Dst_len uint8
- Src_len uint8
- Tos uint8
- Table uint8
- Protocol uint8
- Scope uint8
- Type uint8
- Flags uint32
-}
-
-type RtNexthop struct {
- Len uint16
- Flags uint8
- Hops uint8
- Ifindex int32
-}
-
-const (
- SizeofSockFilter = 0x8
- SizeofSockFprog = 0x10
-)
-
-type SockFilter struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type SockFprog struct {
- Len uint16
- Pad_cgo_0 [6]byte
- Filter *SockFilter
-}
-
-type InotifyEvent struct {
- Wd int32
- Mask uint32
- Cookie uint32
- Len uint32
-}
-
-const SizeofInotifyEvent = 0x10
-
-type PtraceRegs struct {
- Regs [16]uint64
- Tstate uint64
- Tpc uint64
- Tnpc uint64
- Y uint32
- Magic uint32
-}
-
-type ptracePsw struct {
-}
-
-type ptraceFpregs struct {
-}
-
-type ptracePer struct {
-}
-
-type FdSet struct {
- Bits [16]int64
-}
-
-type Sysinfo_t struct {
- Uptime int64
- Loads [3]uint64
- Totalram uint64
- Freeram uint64
- Sharedram uint64
- Bufferram uint64
- Totalswap uint64
- Freeswap uint64
- Procs uint16
- Pad uint16
- Pad_cgo_0 [4]byte
- Totalhigh uint64
- Freehigh uint64
- Unit uint32
- X_f [0]int8
- Pad_cgo_1 [4]byte
-}
-
-type Utsname struct {
- Sysname [65]int8
- Nodename [65]int8
- Release [65]int8
- Version [65]int8
- Machine [65]int8
- Domainname [65]int8
-}
-
-type Ustat_t struct {
- Tfree int32
- Pad_cgo_0 [4]byte
- Tinode uint64
- Fname [6]int8
- Fpack [6]int8
- Pad_cgo_1 [4]byte
-}
-
-type EpollEvent struct {
- Events uint32
- X_padFd int32
- Fd int32
- Pad int32
-}
-
-const (
- AT_FDCWD = -0x64
- AT_REMOVEDIR = 0x200
- AT_SYMLINK_FOLLOW = 0x400
- AT_SYMLINK_NOFOLLOW = 0x100
-)
-
-type PollFd struct {
- Fd int32
- Events int16
- Revents int16
-}
-
-const (
- POLLIN = 0x1
- POLLPRI = 0x2
- POLLOUT = 0x4
- POLLRDHUP = 0x800
- POLLERR = 0x8
- POLLHUP = 0x10
- POLLNVAL = 0x20
-)
-
-type Sigset_t struct {
- X__val [16]uint64
-}
-
-const _SC_PAGESIZE = 0x1e
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Line uint8
- Cc [19]uint8
- Ispeed uint32
- Ospeed uint32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go b/newt/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go
deleted file mode 100644
index caf755fb..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go
+++ /dev/null
@@ -1,396 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_netbsd.go
-
-// +build 386,netbsd
-
-package unix
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int32
-}
-
-type Timeval struct {
- Sec int64
- Usec int32
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int32
- Ixrss int32
- Idrss int32
- Isrss int32
- Minflt int32
- Majflt int32
- Nswap int32
- Inblock int32
- Oublock int32
- Msgsnd int32
- Msgrcv int32
- Nsignals int32
- Nvcsw int32
- Nivcsw int32
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev uint64
- Mode uint32
- Ino uint64
- Nlink uint32
- Uid uint32
- Gid uint32
- Rdev uint64
- Atimespec Timespec
- Mtimespec Timespec
- Ctimespec Timespec
- Birthtimespec Timespec
- Size int64
- Blocks int64
- Blksize uint32
- Flags uint32
- Gen uint32
- Spare [2]uint32
-}
-
-type Statfs_t [0]byte
-
-type Flock_t struct {
- Start int64
- Len int64
- Pid int32
- Type int16
- Whence int16
-}
-
-type Dirent struct {
- Fileno uint64
- Reclen uint16
- Namlen uint16
- Type uint8
- Name [512]int8
- Pad_cgo_0 [3]byte
-}
-
-type Fsid struct {
- X__fsid_val [2]int32
-}
-
-type RawSockaddrInet4 struct {
- Len uint8
- Family uint8
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]int8
-}
-
-type RawSockaddrInet6 struct {
- Len uint8
- Family uint8
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Len uint8
- Family uint8
- Path [104]int8
-}
-
-type RawSockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [12]int8
-}
-
-type RawSockaddr struct {
- Len uint8
- Family uint8
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [92]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint32
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Iov *Iovec
- Iovlen int32
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Filt [8]uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x6c
- SizeofSockaddrUnix = 0x6a
- SizeofSockaddrDatalink = 0x14
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x1c
- SizeofCmsghdr = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
-)
-
-const (
- PTRACE_TRACEME = 0x0
- PTRACE_CONT = 0x7
- PTRACE_KILL = 0x8
-)
-
-type Kevent_t struct {
- Ident uint32
- Filter uint32
- Flags uint32
- Fflags uint32
- Data int64
- Udata int32
-}
-
-type FdSet struct {
- Bits [8]uint32
-}
-
-const (
- SizeofIfMsghdr = 0x98
- SizeofIfData = 0x84
- SizeofIfaMsghdr = 0x18
- SizeofIfAnnounceMsghdr = 0x18
- SizeofRtMsghdr = 0x78
- SizeofRtMetrics = 0x50
-)
-
-type IfMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data IfData
- Pad_cgo_1 [4]byte
-}
-
-type IfData struct {
- Type uint8
- Addrlen uint8
- Hdrlen uint8
- Pad_cgo_0 [1]byte
- Link_state int32
- Mtu uint64
- Metric uint64
- Baudrate uint64
- Ipackets uint64
- Ierrors uint64
- Opackets uint64
- Oerrors uint64
- Collisions uint64
- Ibytes uint64
- Obytes uint64
- Imcasts uint64
- Omcasts uint64
- Iqdrops uint64
- Noproto uint64
- Lastchange Timespec
-}
-
-type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Metric int32
- Index uint16
- Pad_cgo_0 [6]byte
-}
-
-type IfAnnounceMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Name [16]int8
- What uint16
-}
-
-type RtMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Pad_cgo_0 [2]byte
- Flags int32
- Addrs int32
- Pid int32
- Seq int32
- Errno int32
- Use int32
- Inits int32
- Pad_cgo_1 [4]byte
- Rmx RtMetrics
-}
-
-type RtMetrics struct {
- Locks uint64
- Mtu uint64
- Hopcount uint64
- Recvpipe uint64
- Sendpipe uint64
- Ssthresh uint64
- Rtt uint64
- Rttvar uint64
- Expire int64
- Pksent int64
-}
-
-type Mclpool [0]byte
-
-const (
- SizeofBpfVersion = 0x4
- SizeofBpfStat = 0x80
- SizeofBpfProgram = 0x8
- SizeofBpfInsn = 0x8
- SizeofBpfHdr = 0x14
-)
-
-type BpfVersion struct {
- Major uint16
- Minor uint16
-}
-
-type BpfStat struct {
- Recv uint64
- Drop uint64
- Capt uint64
- Padding [13]uint64
-}
-
-type BpfProgram struct {
- Len uint32
- Insns *BpfInsn
-}
-
-type BpfInsn struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type BpfHdr struct {
- Tstamp BpfTimeval
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [2]byte
-}
-
-type BpfTimeval struct {
- Sec int32
- Usec int32
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed int32
- Ospeed int32
-}
-
-type Sysctlnode struct {
- Flags uint32
- Num int32
- Name [32]int8
- Ver uint32
- X__rsvd uint32
- Un [16]byte
- X_sysctl_size [8]byte
- X_sysctl_func [8]byte
- X_sysctl_parent [8]byte
- X_sysctl_desc [8]byte
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go b/newt/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go
deleted file mode 100644
index 91b4a530..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go
+++ /dev/null
@@ -1,403 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_netbsd.go
-
-// +build amd64,netbsd
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int32
- Pad_cgo_0 [4]byte
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev uint64
- Mode uint32
- Pad_cgo_0 [4]byte
- Ino uint64
- Nlink uint32
- Uid uint32
- Gid uint32
- Pad_cgo_1 [4]byte
- Rdev uint64
- Atimespec Timespec
- Mtimespec Timespec
- Ctimespec Timespec
- Birthtimespec Timespec
- Size int64
- Blocks int64
- Blksize uint32
- Flags uint32
- Gen uint32
- Spare [2]uint32
- Pad_cgo_2 [4]byte
-}
-
-type Statfs_t [0]byte
-
-type Flock_t struct {
- Start int64
- Len int64
- Pid int32
- Type int16
- Whence int16
-}
-
-type Dirent struct {
- Fileno uint64
- Reclen uint16
- Namlen uint16
- Type uint8
- Name [512]int8
- Pad_cgo_0 [3]byte
-}
-
-type Fsid struct {
- X__fsid_val [2]int32
-}
-
-type RawSockaddrInet4 struct {
- Len uint8
- Family uint8
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]int8
-}
-
-type RawSockaddrInet6 struct {
- Len uint8
- Family uint8
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Len uint8
- Family uint8
- Path [104]int8
-}
-
-type RawSockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [12]int8
-}
-
-type RawSockaddr struct {
- Len uint8
- Family uint8
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [92]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Pad_cgo_0 [4]byte
- Iov *Iovec
- Iovlen int32
- Pad_cgo_1 [4]byte
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Filt [8]uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x6c
- SizeofSockaddrUnix = 0x6a
- SizeofSockaddrDatalink = 0x14
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x30
- SizeofCmsghdr = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
-)
-
-const (
- PTRACE_TRACEME = 0x0
- PTRACE_CONT = 0x7
- PTRACE_KILL = 0x8
-)
-
-type Kevent_t struct {
- Ident uint64
- Filter uint32
- Flags uint32
- Fflags uint32
- Pad_cgo_0 [4]byte
- Data int64
- Udata int64
-}
-
-type FdSet struct {
- Bits [8]uint32
-}
-
-const (
- SizeofIfMsghdr = 0x98
- SizeofIfData = 0x88
- SizeofIfaMsghdr = 0x18
- SizeofIfAnnounceMsghdr = 0x18
- SizeofRtMsghdr = 0x78
- SizeofRtMetrics = 0x50
-)
-
-type IfMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data IfData
-}
-
-type IfData struct {
- Type uint8
- Addrlen uint8
- Hdrlen uint8
- Pad_cgo_0 [1]byte
- Link_state int32
- Mtu uint64
- Metric uint64
- Baudrate uint64
- Ipackets uint64
- Ierrors uint64
- Opackets uint64
- Oerrors uint64
- Collisions uint64
- Ibytes uint64
- Obytes uint64
- Imcasts uint64
- Omcasts uint64
- Iqdrops uint64
- Noproto uint64
- Lastchange Timespec
-}
-
-type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Metric int32
- Index uint16
- Pad_cgo_0 [6]byte
-}
-
-type IfAnnounceMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Name [16]int8
- What uint16
-}
-
-type RtMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Pad_cgo_0 [2]byte
- Flags int32
- Addrs int32
- Pid int32
- Seq int32
- Errno int32
- Use int32
- Inits int32
- Pad_cgo_1 [4]byte
- Rmx RtMetrics
-}
-
-type RtMetrics struct {
- Locks uint64
- Mtu uint64
- Hopcount uint64
- Recvpipe uint64
- Sendpipe uint64
- Ssthresh uint64
- Rtt uint64
- Rttvar uint64
- Expire int64
- Pksent int64
-}
-
-type Mclpool [0]byte
-
-const (
- SizeofBpfVersion = 0x4
- SizeofBpfStat = 0x80
- SizeofBpfProgram = 0x10
- SizeofBpfInsn = 0x8
- SizeofBpfHdr = 0x20
-)
-
-type BpfVersion struct {
- Major uint16
- Minor uint16
-}
-
-type BpfStat struct {
- Recv uint64
- Drop uint64
- Capt uint64
- Padding [13]uint64
-}
-
-type BpfProgram struct {
- Len uint32
- Pad_cgo_0 [4]byte
- Insns *BpfInsn
-}
-
-type BpfInsn struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type BpfHdr struct {
- Tstamp BpfTimeval
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [6]byte
-}
-
-type BpfTimeval struct {
- Sec int64
- Usec int64
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed int32
- Ospeed int32
-}
-
-type Sysctlnode struct {
- Flags uint32
- Num int32
- Name [32]int8
- Ver uint32
- X__rsvd uint32
- Un [16]byte
- X_sysctl_size [8]byte
- X_sysctl_func [8]byte
- X_sysctl_parent [8]byte
- X_sysctl_desc [8]byte
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go b/newt/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go
deleted file mode 100644
index c0758f9d..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go
+++ /dev/null
@@ -1,401 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_netbsd.go
-
-// +build arm,netbsd
-
-package unix
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int32
- Pad_cgo_0 [4]byte
-}
-
-type Timeval struct {
- Sec int64
- Usec int32
- Pad_cgo_0 [4]byte
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int32
- Ixrss int32
- Idrss int32
- Isrss int32
- Minflt int32
- Majflt int32
- Nswap int32
- Inblock int32
- Oublock int32
- Msgsnd int32
- Msgrcv int32
- Nsignals int32
- Nvcsw int32
- Nivcsw int32
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-type Stat_t struct {
- Dev uint64
- Mode uint32
- Pad_cgo_0 [4]byte
- Ino uint64
- Nlink uint32
- Uid uint32
- Gid uint32
- Pad_cgo_1 [4]byte
- Rdev uint64
- Atimespec Timespec
- Mtimespec Timespec
- Ctimespec Timespec
- Birthtimespec Timespec
- Size int64
- Blocks int64
- Blksize uint32
- Flags uint32
- Gen uint32
- Spare [2]uint32
- Pad_cgo_2 [4]byte
-}
-
-type Statfs_t [0]byte
-
-type Flock_t struct {
- Start int64
- Len int64
- Pid int32
- Type int16
- Whence int16
-}
-
-type Dirent struct {
- Fileno uint64
- Reclen uint16
- Namlen uint16
- Type uint8
- Name [512]int8
- Pad_cgo_0 [3]byte
-}
-
-type Fsid struct {
- X__fsid_val [2]int32
-}
-
-type RawSockaddrInet4 struct {
- Len uint8
- Family uint8
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]int8
-}
-
-type RawSockaddrInet6 struct {
- Len uint8
- Family uint8
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Len uint8
- Family uint8
- Path [104]int8
-}
-
-type RawSockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [12]int8
-}
-
-type RawSockaddr struct {
- Len uint8
- Family uint8
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [92]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint32
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Iov *Iovec
- Iovlen int32
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Filt [8]uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x6c
- SizeofSockaddrUnix = 0x6a
- SizeofSockaddrDatalink = 0x14
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x1c
- SizeofCmsghdr = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
-)
-
-const (
- PTRACE_TRACEME = 0x0
- PTRACE_CONT = 0x7
- PTRACE_KILL = 0x8
-)
-
-type Kevent_t struct {
- Ident uint32
- Filter uint32
- Flags uint32
- Fflags uint32
- Data int64
- Udata int32
- Pad_cgo_0 [4]byte
-}
-
-type FdSet struct {
- Bits [8]uint32
-}
-
-const (
- SizeofIfMsghdr = 0x98
- SizeofIfData = 0x88
- SizeofIfaMsghdr = 0x18
- SizeofIfAnnounceMsghdr = 0x18
- SizeofRtMsghdr = 0x78
- SizeofRtMetrics = 0x50
-)
-
-type IfMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data IfData
-}
-
-type IfData struct {
- Type uint8
- Addrlen uint8
- Hdrlen uint8
- Pad_cgo_0 [1]byte
- Link_state int32
- Mtu uint64
- Metric uint64
- Baudrate uint64
- Ipackets uint64
- Ierrors uint64
- Opackets uint64
- Oerrors uint64
- Collisions uint64
- Ibytes uint64
- Obytes uint64
- Imcasts uint64
- Omcasts uint64
- Iqdrops uint64
- Noproto uint64
- Lastchange Timespec
-}
-
-type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Metric int32
- Index uint16
- Pad_cgo_0 [6]byte
-}
-
-type IfAnnounceMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Name [16]int8
- What uint16
-}
-
-type RtMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Pad_cgo_0 [2]byte
- Flags int32
- Addrs int32
- Pid int32
- Seq int32
- Errno int32
- Use int32
- Inits int32
- Pad_cgo_1 [4]byte
- Rmx RtMetrics
-}
-
-type RtMetrics struct {
- Locks uint64
- Mtu uint64
- Hopcount uint64
- Recvpipe uint64
- Sendpipe uint64
- Ssthresh uint64
- Rtt uint64
- Rttvar uint64
- Expire int64
- Pksent int64
-}
-
-type Mclpool [0]byte
-
-const (
- SizeofBpfVersion = 0x4
- SizeofBpfStat = 0x80
- SizeofBpfProgram = 0x8
- SizeofBpfInsn = 0x8
- SizeofBpfHdr = 0x14
-)
-
-type BpfVersion struct {
- Major uint16
- Minor uint16
-}
-
-type BpfStat struct {
- Recv uint64
- Drop uint64
- Capt uint64
- Padding [13]uint64
-}
-
-type BpfProgram struct {
- Len uint32
- Insns *BpfInsn
-}
-
-type BpfInsn struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type BpfHdr struct {
- Tstamp BpfTimeval
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [2]byte
-}
-
-type BpfTimeval struct {
- Sec int32
- Usec int32
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed int32
- Ospeed int32
-}
-
-type Sysctlnode struct {
- Flags uint32
- Num int32
- Name [32]int8
- Ver uint32
- X__rsvd uint32
- Un [16]byte
- X_sysctl_size [8]byte
- X_sysctl_func [8]byte
- X_sysctl_parent [8]byte
- X_sysctl_desc [8]byte
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go b/newt/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go
deleted file mode 100644
index 860a4697..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go
+++ /dev/null
@@ -1,441 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_openbsd.go
-
-// +build 386,openbsd
-
-package unix
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int32
-}
-
-type Timeval struct {
- Sec int64
- Usec int32
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int32
- Ixrss int32
- Idrss int32
- Isrss int32
- Minflt int32
- Majflt int32
- Nswap int32
- Inblock int32
- Oublock int32
- Msgsnd int32
- Msgrcv int32
- Nsignals int32
- Nvcsw int32
- Nivcsw int32
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-const (
- S_IFMT = 0xf000
- S_IFIFO = 0x1000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFBLK = 0x6000
- S_IFREG = 0x8000
- S_IFLNK = 0xa000
- S_IFSOCK = 0xc000
- S_ISUID = 0x800
- S_ISGID = 0x400
- S_ISVTX = 0x200
- S_IRUSR = 0x100
- S_IWUSR = 0x80
- S_IXUSR = 0x40
-)
-
-type Stat_t struct {
- Mode uint32
- Dev int32
- Ino uint64
- Nlink uint32
- Uid uint32
- Gid uint32
- Rdev int32
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- Size int64
- Blocks int64
- Blksize uint32
- Flags uint32
- Gen uint32
- X__st_birthtim Timespec
-}
-
-type Statfs_t struct {
- F_flags uint32
- F_bsize uint32
- F_iosize uint32
- F_blocks uint64
- F_bfree uint64
- F_bavail int64
- F_files uint64
- F_ffree uint64
- F_favail int64
- F_syncwrites uint64
- F_syncreads uint64
- F_asyncwrites uint64
- F_asyncreads uint64
- F_fsid Fsid
- F_namemax uint32
- F_owner uint32
- F_ctime uint64
- F_fstypename [16]int8
- F_mntonname [90]int8
- F_mntfromname [90]int8
- F_mntfromspec [90]int8
- Pad_cgo_0 [2]byte
- Mount_info [160]byte
-}
-
-type Flock_t struct {
- Start int64
- Len int64
- Pid int32
- Type int16
- Whence int16
-}
-
-type Dirent struct {
- Fileno uint64
- Off int64
- Reclen uint16
- Type uint8
- Namlen uint8
- X__d_padding [4]uint8
- Name [256]int8
-}
-
-type Fsid struct {
- Val [2]int32
-}
-
-type RawSockaddrInet4 struct {
- Len uint8
- Family uint8
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]int8
-}
-
-type RawSockaddrInet6 struct {
- Len uint8
- Family uint8
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Len uint8
- Family uint8
- Path [104]int8
-}
-
-type RawSockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [24]int8
-}
-
-type RawSockaddr struct {
- Len uint8
- Family uint8
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [92]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint32
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Iov *Iovec
- Iovlen uint32
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Filt [8]uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x6c
- SizeofSockaddrUnix = 0x6a
- SizeofSockaddrDatalink = 0x20
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x1c
- SizeofCmsghdr = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
-)
-
-const (
- PTRACE_TRACEME = 0x0
- PTRACE_CONT = 0x7
- PTRACE_KILL = 0x8
-)
-
-type Kevent_t struct {
- Ident uint32
- Filter int16
- Flags uint16
- Fflags uint32
- Data int64
- Udata *byte
-}
-
-type FdSet struct {
- Bits [32]uint32
-}
-
-const (
- SizeofIfMsghdr = 0xec
- SizeofIfData = 0xd4
- SizeofIfaMsghdr = 0x18
- SizeofIfAnnounceMsghdr = 0x1a
- SizeofRtMsghdr = 0x60
- SizeofRtMetrics = 0x38
-)
-
-type IfMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Hdrlen uint16
- Index uint16
- Tableid uint16
- Pad1 uint8
- Pad2 uint8
- Addrs int32
- Flags int32
- Xflags int32
- Data IfData
-}
-
-type IfData struct {
- Type uint8
- Addrlen uint8
- Hdrlen uint8
- Link_state uint8
- Mtu uint32
- Metric uint32
- Pad uint32
- Baudrate uint64
- Ipackets uint64
- Ierrors uint64
- Opackets uint64
- Oerrors uint64
- Collisions uint64
- Ibytes uint64
- Obytes uint64
- Imcasts uint64
- Omcasts uint64
- Iqdrops uint64
- Noproto uint64
- Capabilities uint32
- Lastchange Timeval
- Mclpool [7]Mclpool
-}
-
-type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Hdrlen uint16
- Index uint16
- Tableid uint16
- Pad1 uint8
- Pad2 uint8
- Addrs int32
- Flags int32
- Metric int32
-}
-
-type IfAnnounceMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Hdrlen uint16
- Index uint16
- What uint16
- Name [16]int8
-}
-
-type RtMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Hdrlen uint16
- Index uint16
- Tableid uint16
- Priority uint8
- Mpls uint8
- Addrs int32
- Flags int32
- Fmask int32
- Pid int32
- Seq int32
- Errno int32
- Inits uint32
- Rmx RtMetrics
-}
-
-type RtMetrics struct {
- Pksent uint64
- Expire int64
- Locks uint32
- Mtu uint32
- Refcnt uint32
- Hopcount uint32
- Recvpipe uint32
- Sendpipe uint32
- Ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Pad uint32
-}
-
-type Mclpool struct {
- Grown int32
- Alive uint16
- Hwm uint16
- Cwm uint16
- Lwm uint16
-}
-
-const (
- SizeofBpfVersion = 0x4
- SizeofBpfStat = 0x8
- SizeofBpfProgram = 0x8
- SizeofBpfInsn = 0x8
- SizeofBpfHdr = 0x14
-)
-
-type BpfVersion struct {
- Major uint16
- Minor uint16
-}
-
-type BpfStat struct {
- Recv uint32
- Drop uint32
-}
-
-type BpfProgram struct {
- Len uint32
- Insns *BpfInsn
-}
-
-type BpfInsn struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type BpfHdr struct {
- Tstamp BpfTimeval
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [2]byte
-}
-
-type BpfTimeval struct {
- Sec uint32
- Usec uint32
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed int32
- Ospeed int32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go b/newt/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go
deleted file mode 100644
index 23c52727..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go
+++ /dev/null
@@ -1,448 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_openbsd.go
-
-// +build amd64,openbsd
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-const (
- S_IFMT = 0xf000
- S_IFIFO = 0x1000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFBLK = 0x6000
- S_IFREG = 0x8000
- S_IFLNK = 0xa000
- S_IFSOCK = 0xc000
- S_ISUID = 0x800
- S_ISGID = 0x400
- S_ISVTX = 0x200
- S_IRUSR = 0x100
- S_IWUSR = 0x80
- S_IXUSR = 0x40
-)
-
-type Stat_t struct {
- Mode uint32
- Dev int32
- Ino uint64
- Nlink uint32
- Uid uint32
- Gid uint32
- Rdev int32
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- Size int64
- Blocks int64
- Blksize uint32
- Flags uint32
- Gen uint32
- Pad_cgo_0 [4]byte
- X__st_birthtim Timespec
-}
-
-type Statfs_t struct {
- F_flags uint32
- F_bsize uint32
- F_iosize uint32
- Pad_cgo_0 [4]byte
- F_blocks uint64
- F_bfree uint64
- F_bavail int64
- F_files uint64
- F_ffree uint64
- F_favail int64
- F_syncwrites uint64
- F_syncreads uint64
- F_asyncwrites uint64
- F_asyncreads uint64
- F_fsid Fsid
- F_namemax uint32
- F_owner uint32
- F_ctime uint64
- F_fstypename [16]int8
- F_mntonname [90]int8
- F_mntfromname [90]int8
- F_mntfromspec [90]int8
- Pad_cgo_1 [2]byte
- Mount_info [160]byte
-}
-
-type Flock_t struct {
- Start int64
- Len int64
- Pid int32
- Type int16
- Whence int16
-}
-
-type Dirent struct {
- Fileno uint64
- Off int64
- Reclen uint16
- Type uint8
- Namlen uint8
- X__d_padding [4]uint8
- Name [256]int8
-}
-
-type Fsid struct {
- Val [2]int32
-}
-
-type RawSockaddrInet4 struct {
- Len uint8
- Family uint8
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]int8
-}
-
-type RawSockaddrInet6 struct {
- Len uint8
- Family uint8
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
-}
-
-type RawSockaddrUnix struct {
- Len uint8
- Family uint8
- Path [104]int8
-}
-
-type RawSockaddrDatalink struct {
- Len uint8
- Family uint8
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [24]int8
-}
-
-type RawSockaddr struct {
- Len uint8
- Family uint8
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [92]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *byte
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Pad_cgo_0 [4]byte
- Iov *Iovec
- Iovlen uint32
- Pad_cgo_1 [4]byte
- Control *byte
- Controllen uint32
- Flags int32
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- Filt [8]uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x1c
- SizeofSockaddrAny = 0x6c
- SizeofSockaddrUnix = 0x6a
- SizeofSockaddrDatalink = 0x20
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x30
- SizeofCmsghdr = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x20
- SizeofICMPv6Filter = 0x20
-)
-
-const (
- PTRACE_TRACEME = 0x0
- PTRACE_CONT = 0x7
- PTRACE_KILL = 0x8
-)
-
-type Kevent_t struct {
- Ident uint64
- Filter int16
- Flags uint16
- Fflags uint32
- Data int64
- Udata *byte
-}
-
-type FdSet struct {
- Bits [32]uint32
-}
-
-const (
- SizeofIfMsghdr = 0xf8
- SizeofIfData = 0xe0
- SizeofIfaMsghdr = 0x18
- SizeofIfAnnounceMsghdr = 0x1a
- SizeofRtMsghdr = 0x60
- SizeofRtMetrics = 0x38
-)
-
-type IfMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Hdrlen uint16
- Index uint16
- Tableid uint16
- Pad1 uint8
- Pad2 uint8
- Addrs int32
- Flags int32
- Xflags int32
- Data IfData
-}
-
-type IfData struct {
- Type uint8
- Addrlen uint8
- Hdrlen uint8
- Link_state uint8
- Mtu uint32
- Metric uint32
- Pad uint32
- Baudrate uint64
- Ipackets uint64
- Ierrors uint64
- Opackets uint64
- Oerrors uint64
- Collisions uint64
- Ibytes uint64
- Obytes uint64
- Imcasts uint64
- Omcasts uint64
- Iqdrops uint64
- Noproto uint64
- Capabilities uint32
- Pad_cgo_0 [4]byte
- Lastchange Timeval
- Mclpool [7]Mclpool
- Pad_cgo_1 [4]byte
-}
-
-type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Hdrlen uint16
- Index uint16
- Tableid uint16
- Pad1 uint8
- Pad2 uint8
- Addrs int32
- Flags int32
- Metric int32
-}
-
-type IfAnnounceMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Hdrlen uint16
- Index uint16
- What uint16
- Name [16]int8
-}
-
-type RtMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Hdrlen uint16
- Index uint16
- Tableid uint16
- Priority uint8
- Mpls uint8
- Addrs int32
- Flags int32
- Fmask int32
- Pid int32
- Seq int32
- Errno int32
- Inits uint32
- Rmx RtMetrics
-}
-
-type RtMetrics struct {
- Pksent uint64
- Expire int64
- Locks uint32
- Mtu uint32
- Refcnt uint32
- Hopcount uint32
- Recvpipe uint32
- Sendpipe uint32
- Ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Pad uint32
-}
-
-type Mclpool struct {
- Grown int32
- Alive uint16
- Hwm uint16
- Cwm uint16
- Lwm uint16
-}
-
-const (
- SizeofBpfVersion = 0x4
- SizeofBpfStat = 0x8
- SizeofBpfProgram = 0x10
- SizeofBpfInsn = 0x8
- SizeofBpfHdr = 0x14
-)
-
-type BpfVersion struct {
- Major uint16
- Minor uint16
-}
-
-type BpfStat struct {
- Recv uint32
- Drop uint32
-}
-
-type BpfProgram struct {
- Len uint32
- Pad_cgo_0 [4]byte
- Insns *BpfInsn
-}
-
-type BpfInsn struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type BpfHdr struct {
- Tstamp BpfTimeval
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [2]byte
-}
-
-type BpfTimeval struct {
- Sec uint32
- Usec uint32
-}
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed int32
- Ospeed int32
-}
diff --git a/newt/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go b/newt/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go
deleted file mode 100644
index 02777e4d..00000000
--- a/newt/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go
+++ /dev/null
@@ -1,423 +0,0 @@
-// +build amd64,solaris
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_solaris.go | go run mkpost.go
-
-package unix
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- PathMax = 0x400
- MaxHostNameLen = 0x100
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Timeval32 struct {
- Sec int32
- Usec int32
-}
-
-type Tms struct {
- Utime int64
- Stime int64
- Cutime int64
- Cstime int64
-}
-
-type Utimbuf struct {
- Actime int64
- Modtime int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type _Gid_t uint32
-
-const (
- S_IFMT = 0xf000
- S_IFIFO = 0x1000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFBLK = 0x6000
- S_IFREG = 0x8000
- S_IFLNK = 0xa000
- S_IFSOCK = 0xc000
- S_ISUID = 0x800
- S_ISGID = 0x400
- S_ISVTX = 0x200
- S_IRUSR = 0x100
- S_IWUSR = 0x80
- S_IXUSR = 0x40
-)
-
-type Stat_t struct {
- Dev uint64
- Ino uint64
- Mode uint32
- Nlink uint32
- Uid uint32
- Gid uint32
- Rdev uint64
- Size int64
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- Blksize int32
- Pad_cgo_0 [4]byte
- Blocks int64
- Fstype [16]int8
-}
-
-type Flock_t struct {
- Type int16
- Whence int16
- Pad_cgo_0 [4]byte
- Start int64
- Len int64
- Sysid int32
- Pid int32
- Pad [4]int64
-}
-
-type Dirent struct {
- Ino uint64
- Off int64
- Reclen uint16
- Name [1]int8
- Pad_cgo_0 [5]byte
-}
-
-type RawSockaddrInet4 struct {
- Family uint16
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]int8
-}
-
-type RawSockaddrInet6 struct {
- Family uint16
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
- X__sin6_src_id uint32
-}
-
-type RawSockaddrUnix struct {
- Family uint16
- Path [108]int8
-}
-
-type RawSockaddrDatalink struct {
- Family uint16
- Index uint16
- Type uint8
- Nlen uint8
- Alen uint8
- Slen uint8
- Data [244]int8
-}
-
-type RawSockaddr struct {
- Family uint16
- Data [14]int8
-}
-
-type RawSockaddrAny struct {
- Addr RawSockaddr
- Pad [236]int8
-}
-
-type _Socklen uint32
-
-type Linger struct {
- Onoff int32
- Linger int32
-}
-
-type Iovec struct {
- Base *int8
- Len uint64
-}
-
-type IPMreq struct {
- Multiaddr [4]byte /* in_addr */
- Interface [4]byte /* in_addr */
-}
-
-type IPv6Mreq struct {
- Multiaddr [16]byte /* in6_addr */
- Interface uint32
-}
-
-type Msghdr struct {
- Name *byte
- Namelen uint32
- Pad_cgo_0 [4]byte
- Iov *Iovec
- Iovlen int32
- Pad_cgo_1 [4]byte
- Accrights *int8
- Accrightslen int32
- Pad_cgo_2 [4]byte
-}
-
-type Cmsghdr struct {
- Len uint32
- Level int32
- Type int32
-}
-
-type Inet6Pktinfo struct {
- Addr [16]byte /* in6_addr */
- Ifindex uint32
-}
-
-type IPv6MTUInfo struct {
- Addr RawSockaddrInet6
- Mtu uint32
-}
-
-type ICMPv6Filter struct {
- X__icmp6_filt [8]uint32
-}
-
-const (
- SizeofSockaddrInet4 = 0x10
- SizeofSockaddrInet6 = 0x20
- SizeofSockaddrAny = 0xfc
- SizeofSockaddrUnix = 0x6e
- SizeofSockaddrDatalink = 0xfc
- SizeofLinger = 0x8
- SizeofIPMreq = 0x8
- SizeofIPv6Mreq = 0x14
- SizeofMsghdr = 0x30
- SizeofCmsghdr = 0xc
- SizeofInet6Pktinfo = 0x14
- SizeofIPv6MTUInfo = 0x24
- SizeofICMPv6Filter = 0x20
-)
-
-type FdSet struct {
- Bits [1024]int64
-}
-
-type Utsname struct {
- Sysname [257]int8
- Nodename [257]int8
- Release [257]int8
- Version [257]int8
- Machine [257]int8
-}
-
-type Ustat_t struct {
- Tfree int64
- Tinode uint64
- Fname [6]int8
- Fpack [6]int8
- Pad_cgo_0 [4]byte
-}
-
-const (
- AT_FDCWD = 0xffd19553
- AT_SYMLINK_NOFOLLOW = 0x1000
- AT_SYMLINK_FOLLOW = 0x2000
- AT_REMOVEDIR = 0x1
- AT_EACCESS = 0x4
-)
-
-const (
- SizeofIfMsghdr = 0x54
- SizeofIfData = 0x44
- SizeofIfaMsghdr = 0x14
- SizeofRtMsghdr = 0x4c
- SizeofRtMetrics = 0x28
-)
-
-type IfMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Data IfData
-}
-
-type IfData struct {
- Type uint8
- Addrlen uint8
- Hdrlen uint8
- Pad_cgo_0 [1]byte
- Mtu uint32
- Metric uint32
- Baudrate uint32
- Ipackets uint32
- Ierrors uint32
- Opackets uint32
- Oerrors uint32
- Collisions uint32
- Ibytes uint32
- Obytes uint32
- Imcasts uint32
- Omcasts uint32
- Iqdrops uint32
- Noproto uint32
- Lastchange Timeval32
-}
-
-type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- Pad_cgo_0 [2]byte
- Metric int32
-}
-
-type RtMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Index uint16
- Pad_cgo_0 [2]byte
- Flags int32
- Addrs int32
- Pid int32
- Seq int32
- Errno int32
- Use int32
- Inits uint32
- Rmx RtMetrics
-}
-
-type RtMetrics struct {
- Locks uint32
- Mtu uint32
- Hopcount uint32
- Expire uint32
- Recvpipe uint32
- Sendpipe uint32
- Ssthresh uint32
- Rtt uint32
- Rttvar uint32
- Pksent uint32
-}
-
-const (
- SizeofBpfVersion = 0x4
- SizeofBpfStat = 0x80
- SizeofBpfProgram = 0x10
- SizeofBpfInsn = 0x8
- SizeofBpfHdr = 0x14
-)
-
-type BpfVersion struct {
- Major uint16
- Minor uint16
-}
-
-type BpfStat struct {
- Recv uint64
- Drop uint64
- Capt uint64
- Padding [13]uint64
-}
-
-type BpfProgram struct {
- Len uint32
- Pad_cgo_0 [4]byte
- Insns *BpfInsn
-}
-
-type BpfInsn struct {
- Code uint16
- Jt uint8
- Jf uint8
- K uint32
-}
-
-type BpfTimeval struct {
- Sec int32
- Usec int32
-}
-
-type BpfHdr struct {
- Tstamp BpfTimeval
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [2]byte
-}
-
-const _SC_PAGESIZE = 0xb
-
-type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [19]uint8
- Pad_cgo_0 [1]byte
-}
-
-type Termio struct {
- Iflag uint16
- Oflag uint16
- Cflag uint16
- Lflag uint16
- Line int8
- Cc [8]uint8
- Pad_cgo_0 [1]byte
-}
-
-type Winsize struct {
- Row uint16
- Col uint16
- Xpixel uint16
- Ypixel uint16
-}
diff --git a/newt/vendor/mynewt.apache.org/newt/util/util.go b/newt/vendor/mynewt.apache.org/newt/util/util.go
deleted file mode 100644
index 261762e7..00000000
--- a/newt/vendor/mynewt.apache.org/newt/util/util.go
+++ /dev/null
@@ -1,672 +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 util
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "os/exec"
- "os/signal"
- "path/filepath"
- "runtime"
- "sort"
- "strconv"
- "strings"
- "syscall"
- "time"
-
- log "github.com/Sirupsen/logrus"
-
- "mynewt.apache.org/newt/viper"
-)
-
-var Verbosity int
-var PrintShellCmds bool
-var ExecuteShell bool
-var logFile *os.File
-
-func ParseEqualsPair(v string) (string, string, error) {
- s := strings.Split(v, "=")
- return s[0], s[1], nil
-}
-
-type NewtError struct {
- Parent error
- Text string
- StackTrace []byte
-}
-
-const (
- VERBOSITY_SILENT = 0
- VERBOSITY_QUIET = 1
- VERBOSITY_DEFAULT = 2
- VERBOSITY_VERBOSE = 3
-)
-
-func (se *NewtError) Error() string {
- return se.Text
-}
-
-func NewNewtError(msg string) *NewtError {
- err := &NewtError{
- Text: msg,
- StackTrace: make([]byte, 65536),
- }
-
- stackLen := runtime.Stack(err.StackTrace, true)
- err.StackTrace = err.StackTrace[:stackLen]
-
- return err
-}
-
-func FmtNewtError(format string, args ...interface{}) *NewtError {
- return NewNewtError(fmt.Sprintf(format, args...))
-}
-
-func PreNewtError(err error, format string, args ...interface{}) *NewtError {
- baseErr := err.(*NewtError)
- baseErr.Text = fmt.Sprintf(format, args...) + "; " + baseErr.Text
-
- return baseErr
-}
-
-func ChildNewtError(parent error) *NewtError {
- for {
- newtErr, ok := parent.(*NewtError)
- if !ok || newtErr == nil || newtErr.Parent == nil {
- break
- }
- parent = newtErr.Parent
- }
-
- newtErr := NewNewtError(parent.Error())
- newtErr.Parent = parent
- return newtErr
-}
-
-// Print Silent, Quiet and Verbose aware status messages to stdout.
-func WriteMessage(f *os.File, level int, message string,
- args ...interface{}) {
-
- if Verbosity >= level {
- str := fmt.Sprintf(message, args...)
- f.WriteString(str)
- f.Sync()
-
- if logFile != nil {
- logFile.WriteString(str)
- }
- }
-}
-
-// Print Silent, Quiet and Verbose aware status messages to stdout.
-func StatusMessage(level int, message string, args ...interface{}) {
- WriteMessage(os.Stdout, level, message, args...)
-}
-
-// Print Silent, Quiet and Verbose aware status messages to stderr.
-func ErrorMessage(level int, message string, args ...interface{}) {
- WriteMessage(os.Stderr, level, message, args...)
-}
-
-func NodeExist(path string) bool {
- if _, err := os.Stat(path); err == nil {
- return true
- } else {
- return false
- }
-}
-
-// Check whether the node (either dir or file) specified by path exists
-func NodeNotExist(path string) bool {
- if _, err := os.Stat(path); os.IsNotExist(err) {
- return true
- } else {
- return false
- }
-}
-
-func FileModificationTime(path string) (time.Time, error) {
- fileInfo, err := os.Stat(path)
- if err != nil {
- epoch := time.Unix(0, 0)
- if os.IsNotExist(err) {
- return epoch, nil
- } else {
- return epoch, NewNewtError(err.Error())
- }
- }
-
- return fileInfo.ModTime(), nil
-}
-
-func ChildDirs(path string) ([]string, error) {
- children, err := ioutil.ReadDir(path)
- if err != nil {
- return nil, NewNewtError(err.Error())
- }
-
- childDirs := []string{}
- for _, child := range children {
- name := child.Name()
- if !filepath.HasPrefix(name, ".") &&
- !filepath.HasPrefix(name, "..") &&
- child.IsDir() {
-
- childDirs = append(childDirs, name)
- }
- }
-
- return childDirs, nil
-}
-
-func Min(x, y int) int {
- if x < y {
- return x
- }
- return y
-}
-
-func Max(x, y int) int {
- if x > y {
- return x
- }
- return y
-}
-
-type logFormatter struct{}
-
-func (f *logFormatter) Format(entry *log.Entry) ([]byte, error) {
- // 2016/03/16 12:50:47 [DEBUG]
-
- b := &bytes.Buffer{}
-
- b.WriteString(entry.Time.Format("2006/01/02 15:04:05.000 "))
- b.WriteString("[" + strings.ToUpper(entry.Level.String()) + "] ")
- b.WriteString(entry.Message)
- b.WriteByte('\n')
-
- return b.Bytes(), nil
-}
-
-func initLog(level log.Level, logFilename string) error {
- log.SetLevel(level)
-
- var writer io.Writer
- if logFilename == "" {
- writer = os.Stderr
- } else {
- var err error
- logFile, err = os.Create(logFilename)
- if err != nil {
- return NewNewtError(err.Error())
- }
-
- writer = io.MultiWriter(os.Stderr, logFile)
- }
-
- log.SetOutput(writer)
- log.SetFormatter(&logFormatter{})
-
- return nil
-}
-
-// Initialize the util module
-func Init(logLevel log.Level, logFile string, verbosity int) error {
- // Configure logging twice. First just configure the filter for stderr;
- // second configure the logfile if there is one. This needs to happen in
- // two steps so that the log level is configured prior to the attempt to
- // open the log file. The correct log level needs to be applied to file
- // error messages.
- if err := initLog(logLevel, ""); err != nil {
- return err
- }
- if logFile != "" {
- if err := initLog(logLevel, logFile); err != nil {
- return err
- }
- }
-
- Verbosity = verbosity
- PrintShellCmds = false
- ExecuteShell = false
-
- return nil
-}
-
-// Read in the configuration file specified by name, in path
-// return a new viper config object if successful, and error if not
-func ReadConfig(path string, name string) (*viper.Viper, error) {
- v := viper.New()
- v.SetConfigType("yaml")
- v.SetConfigName(name)
- v.AddConfigPath(path)
-
- err := v.ReadInConfig()
- if err != nil {
- return nil, NewNewtError(fmt.Sprintf("Error reading %s.yml: %s",
- filepath.Join(path, name), err.Error()))
- } else {
- return v, nil
- }
-}
-
-func LogShellCmd(cmdStrs []string, env []string) {
- envLogStr := ""
- if len(env) > 0 {
- envLogStr = strings.Join(env, " ") + " "
- }
- log.Debugf("%s%s", envLogStr, strings.Join(cmdStrs, " "))
-
- if PrintShellCmds {
- StatusMessage(VERBOSITY_DEFAULT, "%s\n", strings.Join(cmdStrs, " "))
- }
-}
-
-// Execute the specified process and block until it completes. Additionally,
-// the amount of combined stdout+stderr output to be logged to the debug log
-// can be restricted to a maximum number of characters.
-//
-// @param cmdStrs The "argv" strings of the command to execute.
-// @param env Additional key=value pairs to inject into the
-// child process's environment. Specify null
-// to just inherit the parent environment.
-// @param logCmd Whether to log the command being executed.
-// @param maxDbgOutputChrs The maximum number of combined stdout+stderr
-// characters to write to the debug log.
-// Specify -1 for no limit; 0 for no output.
-//
-// @return []byte Combined stdout and stderr output of process.
-// @return error NewtError on failure.
-func ShellCommandLimitDbgOutput(
- cmdStrs []string, env []string, logCmd bool, maxDbgOutputChrs int) (
- []byte, error) {
-
- var name string
- var args []string
-
- if logCmd {
- LogShellCmd(cmdStrs, env)
- }
-
- if ExecuteShell && (runtime.GOOS == "linux" || runtime.GOOS == "darwin") {
- cmd := strings.Join(cmdStrs, " ")
- name = "/bin/sh"
- args = []string{"-c", strings.Replace(cmd, "\"", "\\\"", -1)}
- } else {
- name = cmdStrs[0]
- args = cmdStrs[1:]
- }
- cmd := exec.Command(name, args...)
-
- if env != nil {
- cmd.Env = append(env, os.Environ()...)
- }
-
- o, err := cmd.CombinedOutput()
-
- if maxDbgOutputChrs < 0 || len(o) <= maxDbgOutputChrs {
- dbgStr := string(o)
- log.Debugf("o=%s", dbgStr)
- } else if maxDbgOutputChrs != 0 {
- dbgStr := string(o[:maxDbgOutputChrs]) + "[...]"
- log.Debugf("o=%s", dbgStr)
- }
-
- if err != nil {
- log.Debugf("err=%s", err.Error())
- if len(o) > 0 {
- return o, NewNewtError(string(o))
- } else {
- return o, NewNewtError(err.Error())
- }
- } else {
- return o, nil
- }
-}
-
-// Execute the specified process and block until it completes.
-//
-// @param cmdStrs The "argv" strings of the command to execute.
-// @param env Additional key=value pairs to inject into the
-// child process's environment. Specify null
-// to just inherit the parent environment.
-//
-// @return []byte Combined stdout and stderr output of process.
-// @return error NewtError on failure.
-func ShellCommand(cmdStrs []string, env []string) ([]byte, error) {
- return ShellCommandLimitDbgOutput(cmdStrs, env, true, -1)
-}
-
-// Run interactive shell command
-func ShellInteractiveCommand(cmdStr []string, env []string) error {
- log.Print("[VERBOSE] " + cmdStr[0])
-
- //
- // Block SIGINT, at least.
- // Otherwise Ctrl-C meant for gdb would kill newt.
- //
- c := make(chan os.Signal, 1)
- signal.Notify(c, os.Interrupt)
- signal.Notify(c, syscall.SIGTERM)
- go func() {
- <-c
- }()
-
- if env != nil {
- env = append(env, os.Environ()...)
- }
-
- // Transfer stdin, stdout, and stderr to the new process
- // and also set target directory for the shell to start in.
- // and set the additional environment variables
- pa := os.ProcAttr{
- Env: env,
- Files: []*os.File{os.Stdin, os.Stdout, os.Stderr},
- }
-
- // Start up a new shell.
- proc, err := os.StartProcess(cmdStr[0], cmdStr, &pa)
- if err != nil {
- signal.Stop(c)
- return NewNewtError(err.Error())
- }
-
- // Release and exit
- _, err = proc.Wait()
- if err != nil {
- signal.Stop(c)
- return NewNewtError(err.Error())
- }
- signal.Stop(c)
- return nil
-}
-
-func CopyFile(srcFile string, dstFile string) error {
- in, err := os.Open(srcFile)
- if err != nil {
- return ChildNewtError(err)
- }
- defer in.Close()
-
- info, err := in.Stat()
- if err != nil {
- return ChildNewtError(err)
- }
-
- dstDir := filepath.Dir(dstFile)
- if err := os.MkdirAll(dstDir, os.ModePerm); err != nil {
- return ChildNewtError(err)
- }
-
- out, err := os.OpenFile(dstFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC,
- info.Mode())
- if err != nil {
- return ChildNewtError(err)
- }
- defer out.Close()
-
- if _, err = io.Copy(out, in); err != nil {
- return ChildNewtError(err)
- }
-
- return nil
-}
-
-func CopyDir(srcDirStr, dstDirStr string) error {
- srcDir, err := os.Open(srcDirStr)
- if err != nil {
- return ChildNewtError(err)
- }
-
- info, err := srcDir.Stat()
- if err != nil {
- return ChildNewtError(err)
- }
-
- if err := os.MkdirAll(filepath.Dir(dstDirStr), info.Mode()); err != nil {
- return ChildNewtError(err)
- }
-
- infos, err := srcDir.Readdir(-1)
- if err != nil {
- return ChildNewtError(err)
- }
-
- for _, info := range infos {
- src := srcDirStr + "/" + info.Name()
- dst := dstDirStr + "/" + info.Name()
- if info.IsDir() {
- if err := CopyDir(src, dst); err != nil {
- return err
- }
- } else {
- if err := CopyFile(src, dst); err != nil {
- return err
- }
- }
- }
-
- return nil
-}
-
-func MoveFile(srcFile string, destFile string) error {
- if err := CopyFile(srcFile, destFile); err != nil {
- return err
- }
-
- if err := os.RemoveAll(srcFile); err != nil {
- return ChildNewtError(err)
- }
-
- return nil
-}
-
-func MoveDir(srcDir string, destDir string) error {
- if err := CopyDir(srcDir, destDir); err != nil {
- return err
- }
-
- if err := os.RemoveAll(srcDir); err != nil {
- return ChildNewtError(err)
- }
-
- return nil
-}
-
-// Reads each line from the specified text file into an array of strings. If a
-// line ends with a backslash, it is concatenated with the following line.
-func ReadLines(path string) ([]string, error) {
- file, err := os.Open(path)
- if err != nil {
- return nil, NewNewtError(err.Error())
- }
- defer file.Close()
-
- lines := []string{}
- scanner := bufio.NewScanner(file)
-
- for scanner.Scan() {
- line := scanner.Text()
- concatted := false
-
- if len(lines) != 0 {
- prevLine := lines[len(lines)-1]
- if len(prevLine) > 0 && prevLine[len(prevLine)-1:] == "\\" {
- prevLine = prevLine[:len(prevLine)-1]
- prevLine += line
- lines[len(lines)-1] = prevLine
-
- concatted = true
- }
- }
-
- if !concatted {
- lines = append(lines, line)
- }
- }
-
- if scanner.Err() != nil {
- return lines, NewNewtError(scanner.Err().Error())
- }
-
- return lines, nil
-}
-
-// Removes all duplicate strings from the specified array, while preserving
-// order.
-func UniqueStrings(elems []string) []string {
- set := make(map[string]bool)
- result := make([]string, 0)
-
- for _, elem := range elems {
- if !set[elem] {
- result = append(result, elem)
- set[elem] = true
- }
- }
-
- return result
-}
-
-// Sorts whitespace-delimited lists of strings.
-//
-// @param wsSepStrings A list of strings; each string contains one or
-// more whitespace-delimited tokens.
-//
-// @return A slice containing all the input tokens, sorted
-// alphabetically.
-func SortFields(wsSepStrings ...string) []string {
- slice := []string{}
-
- for _, s := range wsSepStrings {
- slice = append(slice, strings.Fields(s)...)
- }
-
- slice = UniqueStrings(slice)
- sort.Strings(slice)
- return slice
-}
-
-// Converts the specified string to an integer. The string can be in base-10
-// or base-16. This is equivalent to the "0" base used in the standard
-// conversion functions, except octal is not supported (a leading zero implies
-// decimal).
-//
-// The second return value is true on success.
-func AtoiNoOctTry(s string) (int, bool) {
- var runLen int
- for runLen = 0; runLen < len(s)-1; runLen++ {
- if s[runLen] != '0' || s[runLen+1] == 'x' {
- break
- }
- }
-
- if runLen > 0 {
- s = s[runLen:]
- }
-
- i, err := strconv.ParseInt(s, 0, 0)
- if err != nil {
- return 0, false
- }
-
- return int(i), true
-}
-
-// Converts the specified string to an integer. The string can be in base-10
-// or base-16. This is equivalent to the "0" base used in the standard
-// conversion functions, except octal is not supported (a leading zero implies
-// decimal).
-func AtoiNoOct(s string) (int, error) {
- val, success := AtoiNoOctTry(s)
- if !success {
- return 0, FmtNewtError("Invalid number: \"%s\"", s)
- }
-
- return val, nil
-}
-
-func IsNotExist(err error) bool {
- newtErr, ok := err.(*NewtError)
- if ok {
- err = newtErr.Parent
- }
-
- return os.IsNotExist(err)
-}
-
-func FileContentsChanged(path string, newContents []byte) (bool, error) {
- oldContents, err := ioutil.ReadFile(path)
- if err != nil {
- if os.IsNotExist(err) {
- // File doesn't exist; write required.
- return true, nil
- }
-
- return true, NewNewtError(err.Error())
- }
-
- rc := bytes.Compare(oldContents, newContents)
- return rc != 0, nil
-}
-
-func CIdentifier(s string) string {
- s = strings.Replace(s, "/", "_", -1)
- s = strings.Replace(s, "-", "_", -1)
- s = strings.Replace(s, " ", "_", -1)
-
- return s
-}
-
-func FilenameFromPath(s string) string {
- s = strings.Replace(s, "/", "_", -1)
- s = strings.Replace(s, " ", "_", -1)
- s = strings.Replace(s, "\t", "_", -1)
- s = strings.Replace(s, "\n", "_", -1)
-
- return s
-}
-
-func IntMax(a, b int) int {
- if a > b {
- return a
- } else {
- return b
- }
-}
-
-func IntMin(a, b int) int {
- if a < b {
- return a
- } else {
- return b
- }
-}
-
-func PrintStacks() {
- buf := make([]byte, 1024*1024)
- stacklen := runtime.Stack(buf, true)
- fmt.Printf("*** goroutine dump\n%s\n*** end\n", buf[:stacklen])
-}
diff --git a/newt/vendor/mynewt.apache.org/newt/viper/LICENSE b/newt/vendor/mynewt.apache.org/newt/viper/LICENSE
deleted file mode 100644
index 4527efb9..00000000
--- a/newt/vendor/mynewt.apache.org/newt/viper/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2014 Steve Francia
-
-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.
\ No newline at end of file
diff --git a/newt/vendor/mynewt.apache.org/newt/viper/README.md b/newt/vendor/mynewt.apache.org/newt/viper/README.md
deleted file mode 100644
index cad242d1..00000000
--- a/newt/vendor/mynewt.apache.org/newt/viper/README.md
+++ /dev/null
@@ -1,620 +0,0 @@
-![viper logo](https://cloud.githubusercontent.com/assets/173412/10886745/998df88a-8151-11e5-9448-4736db51020d.png)
-
-Go configuration with fangs!
-
-Many Go projects are built using Viper including:
-
-* [Hugo](http://gohugo.io)
-* [EMC RexRay](http://rexray.readthedocs.org/en/stable/)
-* [Imgur's Incus](https://github.com/Imgur/incus)
-* [Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack)
-* [Docker Notary](https://github.com/docker/Notary)
-* [BloomApi](https://www.bloomapi.com/)
-* [DOIt](https://github.com/bryanl/doit)
-
- [![Build Status](https://travis-ci.org/spf13/viper.svg)](https://travis-ci.org/spf13/viper) [![Join the chat at https://gitter.im/spf13/viper](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/spf13/viper?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-
-
-## What is Viper?
-
-Viper is a complete configuration solution for go applications including 12 factor apps. It is designed
-to work within an application, and can handle all types of configuration needs
-and formats. It supports:
-
-* setting defaults
-* reading from JSON, TOML, YAML, HCL, and Java properties config files
-* live watching and re-reading of config files (optional)
-* reading from environment variables
-* reading from remote config systems (etcd or Consul), and watching changes
-* reading from command line flags
-* reading from buffer
-* setting explicit values
-
-Viper can be thought of as a registry for all of your applications
-configuration needs.
-
-## Why Viper?
-
-When building a modern application, you don?t want to worry about
-configuration file formats; you want to focus on building awesome software.
-Viper is here to help with that.
-
-Viper does the following for you:
-
-1. Find, load, and unmarshal a configuration file in JSON, TOML, YAML, HCL, or Java properties formats.
-2. Provide a mechanism to set default values for your different
- configuration options.
-3. Provide a mechanism to set override values for options specified through
- command line flags.
-4. Provide an alias system to easily rename parameters without breaking existing
- code.
-5. Make it easy to tell the difference between when a user has provided a
- command line or config file which is the same as the default.
-
-Viper uses the following precedence order. Each item takes precedence over the
-item below it:
-
- * explicit call to Set
- * flag
- * env
- * config
- * key/value store
- * default
-
-Viper configuration keys are case insensitive.
-
-## Putting Values into Viper
-
-### Establishing Defaults
-
-A good configuration system will support default values. A default value is not
-required for a key, but it's useful in the event that a key hasn?t been set via
-config file, environment variable, remote configuration or flag.
-
-Examples:
-
-```go
-viper.SetDefault("ContentDir", "content")
-viper.SetDefault("LayoutDir", "layouts")
-viper.SetDefault("Taxonomies", map[string]string{"tag": "tags", "category": "categories"})
-```
-
-### Reading Config Files
-
-Viper requires minimal configuration so it knows where to look for config files.
-Viper supports JSON, TOML, YAML, HCL, and Java Properties files. Viper can search multiple paths, but
-currently a single Viper instance only supports a single configuration file.
-Viper does not default to any configuration search paths leaving defaults decision
-to an application.
-
-Here is an example of how to use Viper to search for and read a configuration file.
-None of the specific paths are required, but at least one path should be provided
-where a configuration file is expected.
-
-```go
-viper.SetConfigName("config") // name of config file (without extension)
-viper.AddConfigPath("/etc/appname/") // path to look for the config file in
-viper.AddConfigPath("$HOME/.appname") // call multiple times to add many search paths
-viper.AddConfigPath(".") // optionally look for config in the working directory
-err := viper.ReadInConfig() // Find and read the config file
-if err != nil { // Handle errors reading the config file
- panic(fmt.Errorf("Fatal error config file: %s \n", err))
-}
-```
-
-### Watching and re-reading config files
-
-Viper supports the ability to have your application live read a config file while running.
-
-Gone are the days of needing to restart a server to have a config take effect,
-viper powered applications can read an update to a config file while running and
-not miss a beat.
-
-Simply tell the viper instance to watchConfig.
-Optionally you can provide a function for Viper to run each time a change occurs.
-
-**Make sure you add all of the configPaths prior to calling `WatchConfig()`**
-
-```go
- viper.WatchConfig()
- viper.OnConfigChange(func(e fsnotify.Event) {
- fmt.Println("Config file changed:", e.Name)
- })
-```
-
-### Reading Config from io.Reader
-
-Viper predefines many configuration sources such as files, environment
-variables, flags, and remote K/V store, but you are not bound to them. You can
-also implement your own required configuration source and feed it to viper.
-
-```go
-viper.SetConfigType("yaml") // or viper.SetConfigType("YAML")
-
-// any approach to require this configuration into your program.
-var yamlExample = []byte(`
-Hacker: true
-name: steve
-hobbies:
-- skateboarding
-- snowboarding
-- go
-clothing:
- jacket: leather
- trousers: denim
-age: 35
-eyes : brown
-beard: true
-`)
-
-viper.ReadConfig(bytes.NewBuffer(yamlExample))
-
-viper.Get("name") // this would be "steve"
-```
-
-### Setting Overrides
-
-These could be from a command line flag, or from your own application logic.
-
-```go
-viper.Set("Verbose", true)
-viper.Set("LogFile", LogFile)
-```
-
-### Registering and Using Aliases
-
-Aliases permit a single value to be referenced by multiple keys
-
-```go
-viper.RegisterAlias("loud", "Verbose")
-
-viper.Set("verbose", true) // same result as next line
-viper.Set("loud", true) // same result as prior line
-
-viper.GetBool("loud") // true
-viper.GetBool("verbose") // true
-```
-
-### Working with Environment Variables
-
-Viper has full support for environment variables. This enables 12 factor
-applications out of the box. There are four methods that exist to aid working
-with ENV:
-
- * `AutomaticEnv()`
- * `BindEnv(string...) : error`
- * `SetEnvPrefix(string)`
- * `SetEnvReplacer(string...) *strings.Replacer`
-
-_When working with ENV variables, it?s important to recognize that Viper
-treats ENV variables as case sensitive._
-
-Viper provides a mechanism to try to ensure that ENV variables are unique. By
-using `SetEnvPrefix`, you can tell Viper to use add a prefix while reading from
-the environment variables. Both `BindEnv` and `AutomaticEnv` will use this
-prefix.
-
-`BindEnv` takes one or two parameters. The first parameter is the key name, the
-second is the name of the environment variable. The name of the environment
-variable is case sensitive. If the ENV variable name is not provided, then
-Viper will automatically assume that the key name matches the ENV variable name,
-but the ENV variable is IN ALL CAPS. When you explicitly provide the ENV
-variable name, it **does not** automatically add the prefix.
-
-One important thing to recognize when working with ENV variables is that the
-value will be read each time it is accessed. Viper does not fix the value when
-the `BindEnv` is called.
-
-`AutomaticEnv` is a powerful helper especially when combined with
-`SetEnvPrefix`. When called, Viper will check for an environment variable any
-time a `viper.Get` request is made. It will apply the following rules. It will
-check for a environment variable with a name matching the key uppercased and
-prefixed with the `EnvPrefix` if set.
-
-`SetEnvReplacer` allows you to use a `strings.Replacer` object to rewrite Env
-keys to an extent. This is useful if you want to use `-` or something in your
-`Get()` calls, but want your environmental variables to use `_` delimiters. An
-example of using it can be found in `viper_test.go`.
-
-#### Env example
-
-```go
-SetEnvPrefix("spf") // will be uppercased automatically
-BindEnv("id")
-
-os.Setenv("SPF_ID", "13") // typically done outside of the app
-
-id := Get("id") // 13
-```
-
-### Working with Flags
-
-Viper has the ability to bind to flags. Specifically, Viper supports `Pflags`
-as used in the [Cobra](https://github.com/spf13/cobra) library.
-
-Like `BindEnv`, the value is not set when the binding method is called, but when
-it is accessed. This means you can bind as early as you want, even in an
-`init()` function.
-
-The `BindPFlag()` method provides this functionality.
-
-Example:
-
-```go
-serverCmd.Flags().Int("port", 1138, "Port to run Application server on")
-viper.BindPFlag("port", serverCmd.Flags().Lookup("port"))
-```
-
-The use of [pflag](https://github.com/spf13/pflag/) in Viper does not preclude
-the use of other packages that use the [flag](https://golang.org/pkg/flag/)
-package from the standard library. The pflag package can handle the flags
-defined for the flag package by importing these flags. This is accomplished
-by a calling a convenience function provided by the pflag package called
-AddGoFlagSet().
-
-Example:
-
-```go
-package main
-
-import (
- "flag"
- "github.com/spf13/pflag"
-)
-
-func main() {
- pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
- pflag.Parse()
- ...
-}
-```
-
-#### Flag interfaces
-
-Viper provides two Go interfaces to bind other flag systems if you don't use `Pflags`.
-
-`FlagValue` represents a single flag. This is a very simple example on how to implement this interface:
-
-```go
-type myFlag struct {}
-func (f myFlag) IsChanged() { return false }
-func (f myFlag) Name() { return "my-flag-name" }
-func (f myFlag) ValueString() { return "my-flag-value" }
-func (f myFlag) ValueType() { return "string" }
-```
-
-Once your flag implements this interface, you can simply tell Viper to bind it:
-
-```go
-viper.BindFlagValue("my-flag-name", myFlag{})
-```
-
-`FlagValueSet` represents a group of flags. This is a very simple example on how to implement this interface:
-
-```go
-type myFlagSet struct {
- flags []myFlag
-}
-
-func (f myFlagSet) VisitAll(fn func(FlagValue)) {
- for _, flag := range flags {
- fn(flag)
- }
-}
-```
-
-Once your flag set implements this interface, you can simply tell Viper to bind it:
-
-```go
-fSet := myFlagSet{
- flags: []myFlag{myFlag{}, myFlag{}},
-}
-viper.BindFlagValues("my-flags", fSet)
-```
-
-### Remote Key/Value Store Support
-
-To enable remote support in Viper, do a blank import of the `viper/remote`
-package:
-
-`import _ "github.com/spf13/viper/remote"`
-
-Viper will read a config string (as JSON, TOML, YAML or HCL) retrieved from a path
-in a Key/Value store such as etcd or Consul. These values take precedence over
-default values, but are overridden by configuration values retrieved from disk,
-flags, or environment variables.
-
-Viper uses [crypt](https://github.com/xordataexchange/crypt) to retrieve
-configuration from the K/V store, which means that you can store your
-configuration values encrypted and have them automatically decrypted if you have
-the correct gpg keyring. Encryption is optional.
-
-You can use remote configuration in conjunction with local configuration, or
-independently of it.
-
-`crypt` has a command-line helper that you can use to put configurations in your
-K/V store. `crypt` defaults to etcd on http://127.0.0.1:4001.
-
-```bash
-$ go get github.com/xordataexchange/crypt/bin/crypt
-$ crypt set -plaintext /config/hugo.json /Users/hugo/settings/config.json
-```
-
-Confirm that your value was set:
-
-```bash
-$ crypt get -plaintext /config/hugo.json
-```
-
-See the `crypt` documentation for examples of how to set encrypted values, or
-how to use Consul.
-
-### Remote Key/Value Store Example - Unencrypted
-
-```go
-viper.AddRemoteProvider("etcd", "http://127.0.0.1:4001","/config/hugo.json")
-viper.SetConfigType("json") // because there is no file extension in a stream of bytes, supported extensions are "json", "toml", "yaml", "yml", "properties", "props", "prop"
-err := viper.ReadRemoteConfig()
-```
-
-### Remote Key/Value Store Example - Encrypted
-
-```go
-viper.AddSecureRemoteProvider("etcd","http://127.0.0.1:4001","/config/hugo.json","/etc/secrets/mykeyring.gpg")
-viper.SetConfigType("json") // because there is no file extension in a stream of bytes, supported extensions are "json", "toml", "yaml", "yml", "properties", "props", "prop"
-err := viper.ReadRemoteConfig()
-```
-
-### Watching Changes in etcd - Unencrypted
-
-```go
-// alternatively, you can create a new viper instance.
-var runtime_viper = viper.New()
-
-runtime_viper.AddRemoteProvider("etcd", "http://127.0.0.1:4001", "/config/hugo.yml")
-runtime_viper.SetConfigType("yaml") // because there is no file extension in a stream of bytes, supported extensions are "json", "toml", "yaml", "yml", "properties", "props", "prop"
-
-// read from remote config the first time.
-err := runtime_viper.ReadRemoteConfig()
-
-// unmarshal config
-runtime_viper.Unmarshal(&runtime_conf)
-
-// open a goroutine to watch remote changes forever
-go func(){
- for {
- time.Sleep(time.Second * 5) // delay after each request
-
- // currently, only tested with etcd support
- err := runtime_viper.WatchRemoteConfig()
- if err != nil {
- log.Errorf("unable to read remote config: %v", err)
- continue
- }
-
- // unmarshal new config into our runtime config struct. you can also use channel
- // to implement a signal to notify the system of the changes
- runtime_viper.Unmarshal(&runtime_conf)
- }
-}()
-```
-
-## Getting Values From Viper
-
-In Viper, there are a few ways to get a value depending on the value's type.
-The following functions and methods exist:
-
- * `Get(key string) : interface{}`
- * `GetBool(key string) : bool`
- * `GetFloat64(key string) : float64`
- * `GetInt(key string) : int`
- * `GetString(key string) : string`
- * `GetStringMap(key string) : map[string]interface{}`
- * `GetStringMapString(key string) : map[string]string`
- * `GetStringSlice(key string) : []string`
- * `GetTime(key string) : time.Time`
- * `GetDuration(key string) : time.Duration`
- * `IsSet(key string) : bool`
-
-One important thing to recognize is that each Get function will return a zero
-value if it?s not found. To check if a given key exists, the `IsSet()` method
-has been provided.
-
-Example:
-```go
-viper.GetString("logfile") // case-insensitive Setting & Getting
-if viper.GetBool("verbose") {
- fmt.Println("verbose enabled")
-}
-```
-### Accessing nested keys
-
-The accessor methods also accept formatted paths to deeply nested keys. For
-example, if the following JSON file is loaded:
-
-```json
-{
- "host": {
- "address": "localhost",
- "port": 5799
- },
- "datastore": {
- "metric": {
- "host": "127.0.0.1",
- "port": 3099
- },
- "warehouse": {
- "host": "198.0.0.1",
- "port": 2112
- }
- }
-}
-
-```
-
-Viper can access a nested field by passing a `.` delimited path of keys:
-
-```go
-GetString("datastore.metric.host") // (returns "127.0.0.1")
-```
-
-This obeys the precedence rules established above; the search for the root key
-(in this example, `datastore`) will cascade through the remaining configuration
-registries until found. The search for the sub-keys (`metric` and `host`),
-however, will not.
-
-For example, if the `metric` key was not defined in the configuration loaded
-from file, but was defined in the defaults, Viper would return the zero value.
-
-On the other hand, if the primary key was not defined, Viper would go through
-the remaining registries looking for it.
-
-Lastly, if there exists a key that matches the delimited key path, its value
-will be returned instead. E.g.
-
-```json
-{
- "datastore.metric.host": "0.0.0.0",
- "host": {
- "address": "localhost",
- "port": 5799
- },
- "datastore": {
- "metric": {
- "host": "127.0.0.1",
- "port": 3099
- },
- "warehouse": {
- "host": "198.0.0.1",
- "port": 2112
- }
- }
-}
-
-GetString("datastore.metric.host") //returns "0.0.0.0"
-```
-
-### Extract sub-tree
-
-Extract sub-tree from Viper.
-
-For example, `viper` represents:
-
-```json
-app:
- cache1:
- max-items: 100
- item-size: 64
- cache2:
- max-items: 200
- item-size: 80
-```
-
-After executing:
-
-```go
-subv := viper.Sub("app.cache1")
-```
-
-`subv` represents:
-
-```json
-max-items: 100
-item-size: 64
-```
-
-Suppose we have:
-
-```go
-func NewCache(cfg *Viper) *Cache {...}
-```
-
-which creates a cache based on config information formatted as `subv`.
-Now it's easy to create these 2 caches separately as:
-
-```go
-cfg1 := viper.Sub("app.cache1")
-cache1 := NewCache(cfg1)
-
-cfg2 := viper.Sub("app.cache2")
-cache2 := NewCache(cfg2)
-```
-
-### Unmarshaling
-
-You also have the option of Unmarshaling all or a specific value to a struct, map,
-etc.
-
-There are two methods to do this:
-
- * `Unmarshal(rawVal interface{}) : error`
- * `UnmarshalKey(key string, rawVal interface{}) : error`
-
-Example:
-
-```go
-type config struct {
- Port int
- Name string
- PathMap string `mapstructure:"path_map"`
-}
-
-var C config
-
-err := Unmarshal(&C)
-if err != nil {
- t.Fatalf("unable to decode into struct, %v", err)
-}
-```
-
-## Viper or Vipers?
-
-Viper comes ready to use out of the box. There is no configuration or
-initialization needed to begin using Viper. Since most applications will want
-to use a single central repository for their configuration, the viper package
-provides this. It is similar to a singleton.
-
-In all of the examples above, they demonstrate using viper in it's singleton
-style approach.
-
-### Working with multiple vipers
-
-You can also create many different vipers for use in your application. Each will
-have it?s own unique set of configurations and values. Each can read from a
-different config file, key value store, etc. All of the functions that viper
-package supports are mirrored as methods on a viper.
-
-Example:
-
-```go
-x := viper.New()
-y := viper.New()
-
-x.SetDefault("ContentDir", "content")
-y.SetDefault("ContentDir", "foobar")
-
-//...
-```
-
-When working with multiple vipers, it is up to the user to keep track of the
-different vipers.
-
-## Q & A
-
-Q: Why not INI files?
-
-A: Ini files are pretty awful. There?s no standard format, and they are hard to
-validate. Viper is designed to work with JSON, TOML or YAML files. If someone
-really wants to add this feature, I?d be happy to merge it. It?s easy to specify
-which formats your application will permit.
-
-Q: Why is it called ?Viper??
-
-A: Viper is designed to be a [companion](http://en.wikipedia.org/wiki/Viper_(G.I._Joe))
-to [Cobra](https://github.com/spf13/cobra). While both can operate completely
-independently, together they make a powerful pair to handle much of your
-application foundation needs.
-
-Q: Why is it called ?Cobra??
-
-A: Is there a better name for a [commander](http://en.wikipedia.org/wiki/Cobra_Commander)?
diff --git a/newt/vendor/mynewt.apache.org/newt/viper/flags.go b/newt/vendor/mynewt.apache.org/newt/viper/flags.go
deleted file mode 100644
index dd32f4e1..00000000
--- a/newt/vendor/mynewt.apache.org/newt/viper/flags.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package viper
-
-import "github.com/spf13/pflag"
-
-// FlagValueSet is an interface that users can implement
-// to bind a set of flags to viper.
-type FlagValueSet interface {
- VisitAll(fn func(FlagValue))
-}
-
-// FlagValue is an interface that users can implement
-// to bind different flags to viper.
-type FlagValue interface {
- HasChanged() bool
- Name() string
- ValueString() string
- ValueType() string
-}
-
-// pflagValueSet is a wrapper around *pflag.ValueSet
-// that implements FlagValueSet.
-type pflagValueSet struct {
- flags *pflag.FlagSet
-}
-
-// VisitAll iterates over all *pflag.Flag inside the *pflag.FlagSet.
-func (p pflagValueSet) VisitAll(fn func(flag FlagValue)) {
- p.flags.VisitAll(func(flag *pflag.Flag) {
- fn(pflagValue{flag})
- })
-}
-
-// pflagValue is a wrapper aroung *pflag.flag
-// that implements FlagValue
-type pflagValue struct {
- flag *pflag.Flag
-}
-
-// HasChanges returns whether the flag has changes or not.
-func (p pflagValue) HasChanged() bool {
- return p.flag.Changed
-}
-
-// Name returns the name of the flag.
-func (p pflagValue) Name() string {
- return p.flag.Name
-}
-
-// ValueString returns the value of the flag as a string.
-func (p pflagValue) ValueString() string {
- return p.flag.Value.String()
-}
-
-// ValueType returns the type of the flag as a string.
-func (p pflagValue) ValueType() string {
- return p.flag.Value.Type()
-}
diff --git a/newt/vendor/mynewt.apache.org/newt/viper/util.go b/newt/vendor/mynewt.apache.org/newt/viper/util.go
deleted file mode 100644
index 0f52fc10..00000000
--- a/newt/vendor/mynewt.apache.org/newt/viper/util.go
+++ /dev/null
@@ -1,195 +0,0 @@
-// This file has been changed slightly from the original. The change is to use
-// the mynewt yaml library rather than yaml.v2. This file retains the original
-// copyright and license.
-//
-// Copyright ? 2014 Steve Francia <sp...@spf13.com>.
-//
-// Use of this source code is governed by an MIT-style license that can be
-// found in the LICENSE file.
-
-// Viper is a application configuration system.
-// It believes that applications can be configured a variety of ways
-// via flags, ENVIRONMENT variables, configuration files retrieved
-// from the file system, or a remote key/value store.
-
-package viper
-
-import (
- "bytes"
- "encoding/json"
- "fmt"
- "io"
- "os"
- "path/filepath"
- "runtime"
- "strings"
- "unicode"
-
- "github.com/spf13/cast"
- jww "github.com/spf13/jwalterweatherman"
- "mynewt.apache.org/newt/yaml"
-)
-
-// Denotes failing to parse configuration file.
-type ConfigParseError struct {
- err error
-}
-
-// Returns the formatted configuration error.
-func (pe ConfigParseError) Error() string {
- return fmt.Sprintf("While parsing config: %s", pe.err.Error())
-}
-
-func insensitiviseMap(m map[string]interface{}) {
- for key, val := range m {
- lower := strings.ToLower(key)
- if key != lower {
- delete(m, key)
- m[lower] = val
- }
- }
-}
-
-func absPathify(inPath string) string {
- jww.INFO.Println("Trying to resolve absolute path to", inPath)
-
- if strings.HasPrefix(inPath, "$HOME") {
- inPath = userHomeDir() + inPath[5:]
- }
-
- if strings.HasPrefix(inPath, "$") {
- end := strings.Index(inPath, string(os.PathSeparator))
- inPath = os.Getenv(inPath[1:end]) + inPath[end:]
- }
-
- if filepath.IsAbs(inPath) {
- return filepath.Clean(inPath)
- }
-
- p, err := filepath.Abs(inPath)
- if err == nil {
- return filepath.Clean(p)
- } else {
- jww.ERROR.Println("Couldn't discover absolute path")
- jww.ERROR.Println(err)
- }
- return ""
-}
-
-// Check if File / Directory Exists
-func exists(path string) (bool, error) {
- _, err := os.Stat(path)
- if err == nil {
- return true, nil
- }
- if os.IsNotExist(err) {
- return false, nil
- }
- return false, err
-}
-
-func stringInSlice(a string, list []string) bool {
- for _, b := range list {
- if b == a {
- return true
- }
- }
- return false
-}
-
-func userHomeDir() string {
- if runtime.GOOS == "windows" {
- home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
- if home == "" {
- home = os.Getenv("USERPROFILE")
- }
- return home
- }
- return os.Getenv("HOME")
-}
-
-func findCWD() (string, error) {
- serverFile, err := filepath.Abs(os.Args[0])
-
- if err != nil {
- return "", fmt.Errorf("Can't get absolute path for executable: %v", err)
- }
-
- path := filepath.Dir(serverFile)
- realFile, err := filepath.EvalSymlinks(serverFile)
-
- if err != nil {
- if _, err = os.Stat(serverFile + ".exe"); err == nil {
- realFile = filepath.Clean(serverFile + ".exe")
- }
- }
-
- if err == nil && realFile != serverFile {
- path = filepath.Dir(realFile)
- }
-
- return path, nil
-}
-
-func unmarshallConfigReader(in io.Reader, c map[string]interface{}, configType string) error {
- buf := new(bytes.Buffer)
- buf.ReadFrom(in)
-
- switch strings.ToLower(configType) {
- case "yaml", "yml":
- if err := yaml.Unmarshal(buf.Bytes(), &c); err != nil {
- return ConfigParseError{err}
- }
-
- case "json":
- if err := json.Unmarshal(buf.Bytes(), &c); err != nil {
- return ConfigParseError{err}
- }
- }
-
- insensitiviseMap(c)
- return nil
-}
-
-func safeMul(a, b uint) uint {
- c := a * b
- if a > 1 && b > 1 && c/b != a {
- return 0
- }
- return c
-}
-
-// parseSizeInBytes converts strings like 1GB or 12 mb into an unsigned integer number of bytes
-func parseSizeInBytes(sizeStr string) uint {
- sizeStr = strings.TrimSpace(sizeStr)
- lastChar := len(sizeStr) - 1
- multiplier := uint(1)
-
- if lastChar > 0 {
- if sizeStr[lastChar] == 'b' || sizeStr[lastChar] == 'B' {
- if lastChar > 1 {
- switch unicode.ToLower(rune(sizeStr[lastChar-1])) {
- case 'k':
- multiplier = 1 << 10
- sizeStr = strings.TrimSpace(sizeStr[:lastChar-1])
- case 'm':
- multiplier = 1 << 20
- sizeStr = strings.TrimSpace(sizeStr[:lastChar-1])
- case 'g':
- multiplier = 1 << 30
- sizeStr = strings.TrimSpace(sizeStr[:lastChar-1])
- default:
- multiplier = 1
- sizeStr = strings.TrimSpace(sizeStr[:lastChar])
- }
- }
- }
- }
-
- size := cast.ToInt(sizeStr)
- if size < 0 {
- size = 0
- }
-
- return safeMul(uint(size), multiplier)
-}
diff --git a/newt/vendor/mynewt.apache.org/newt/viper/viper.go b/newt/vendor/mynewt.apache.org/newt/viper/viper.go
deleted file mode 100644
index 7a49a0a9..00000000
--- a/newt/vendor/mynewt.apache.org/newt/viper/viper.go
+++ /dev/null
@@ -1,1300 +0,0 @@
-// Copyright ? 2014 Steve Francia <sp...@spf13.com>.
-//
-// Use of this source code is governed by an MIT-style
-// license that can be found in the LICENSE file.
-
-// Viper is a application configuration system.
-// It believes that applications can be configured a variety of ways
-// via flags, ENVIRONMENT variables, configuration files retrieved
-// from the file system, or a remote key/value store.
-
-// Each item takes precedence over the item below it:
-
-// overrides
-// flag
-// env
-// config
-// key/value store
-// default
-
-package viper
-
-import (
- "bytes"
- "fmt"
- "io"
- "io/ioutil"
- "log"
- "os"
- "path/filepath"
- "reflect"
- "strings"
- "time"
-
- "github.com/kr/pretty"
- "github.com/mitchellh/mapstructure"
- "github.com/spf13/cast"
- jww "github.com/spf13/jwalterweatherman"
- "github.com/spf13/pflag"
- "gopkg.in/fsnotify.v1"
-)
-
-var v *Viper
-
-func init() {
- v = New()
-}
-
-type remoteConfigFactory interface {
- Get(rp RemoteProvider) (io.Reader, error)
- Watch(rp RemoteProvider) (io.Reader, error)
-}
-
-// RemoteConfig is optional, see the remote package
-var RemoteConfig remoteConfigFactory
-
-// Denotes encountering an unsupported
-// configuration filetype.
-type UnsupportedConfigError string
-
-// Returns the formatted configuration error.
-func (str UnsupportedConfigError) Error() string {
- return fmt.Sprintf("Unsupported Config Type %q", string(str))
-}
-
-// Denotes encountering an unsupported remote
-// provider. Currently only etcd and Consul are
-// supported.
-type UnsupportedRemoteProviderError string
-
-// Returns the formatted remote provider error.
-func (str UnsupportedRemoteProviderError) Error() string {
- return fmt.Sprintf("Unsupported Remote Provider Type %q", string(str))
-}
-
-// Denotes encountering an error while trying to
-// pull the configuration from the remote provider.
-type RemoteConfigError string
-
-// Returns the formatted remote provider error
-func (rce RemoteConfigError) Error() string {
- return fmt.Sprintf("Remote Configurations Error: %s", string(rce))
-}
-
-// Denotes failing to find configuration file.
-type ConfigFileNotFoundError struct {
- name, locations string
-}
-
-// Returns the formatted configuration error.
-func (fnfe ConfigFileNotFoundError) Error() string {
- return fmt.Sprintf("Config File %q Not Found in %q", fnfe.name, fnfe.locations)
-}
-
-// Viper is a prioritized configuration registry. It
-// maintains a set of configuration sources, fetches
-// values to populate those, and provides them according
-// to the source's priority.
-// The priority of the sources is the following:
-// 1. overrides
-// 2. flags
-// 3. env. variables
-// 4. config file
-// 5. key/value store
-// 6. defaults
-//
-// For example, if values from the following sources were loaded:
-//
-// Defaults : {
-// "secret": "",
-// "user": "default",
-// "endpoint": "https://localhost"
-// }
-// Config : {
-// "user": "root"
-// "secret": "defaultsecret"
-// }
-// Env : {
-// "secret": "somesecretkey"
-// }
-//
-// The resulting config will have the following values:
-//
-// {
-// "secret": "somesecretkey",
-// "user": "root",
-// "endpoint": "https://localhost"
-// }
-type Viper struct {
- // Delimiter that separates a list of keys
- // used to access a nested value in one go
- keyDelim string
-
- // A set of paths to look for the config file in
- configPaths []string
-
- // A set of remote providers to search for the configuration
- remoteProviders []*defaultRemoteProvider
-
- // Name of file to look for inside the path
- configName string
- configFile string
- configType string
- envPrefix string
-
- automaticEnvApplied bool
- envKeyReplacer *strings.Replacer
-
- config map[string]interface{}
- override map[string]interface{}
- defaults map[string]interface{}
- kvstore map[string]interface{}
- pflags map[string]FlagValue
- env map[string]string
- aliases map[string]string
- typeByDefValue bool
-
- onConfigChange func(fsnotify.Event)
-}
-
-// Returns an initialized Viper instance.
-func New() *Viper {
- v := new(Viper)
- v.keyDelim = "."
- v.configName = "config"
- v.config = make(map[string]interface{})
- v.override = make(map[string]interface{})
- v.defaults = make(map[string]interface{})
- v.kvstore = make(map[string]interface{})
- v.pflags = make(map[string]FlagValue)
- v.env = make(map[string]string)
- v.aliases = make(map[string]string)
- v.typeByDefValue = false
-
- return v
-}
-
-// Intended for testing, will reset all to default settings.
-// In the public interface for the viper package so applications
-// can use it in their testing as well.
-func Reset() {
- v = New()
- SupportedExts = []string{"json", "toml", "yaml", "yml", "hcl"}
- SupportedRemoteProviders = []string{"etcd", "consul"}
-}
-
-type defaultRemoteProvider struct {
- provider string
- endpoint string
- path string
- secretKeyring string
-}
-
-func (rp defaultRemoteProvider) Provider() string {
- return rp.provider
-}
-
-func (rp defaultRemoteProvider) Endpoint() string {
- return rp.endpoint
-}
-
-func (rp defaultRemoteProvider) Path() string {
- return rp.path
-}
-
-func (rp defaultRemoteProvider) SecretKeyring() string {
- return rp.secretKeyring
-}
-
-// RemoteProvider stores the configuration necessary
-// to connect to a remote key/value store.
-// Optional secretKeyring to unencrypt encrypted values
-// can be provided.
-type RemoteProvider interface {
- Provider() string
- Endpoint() string
- Path() string
- SecretKeyring() string
-}
-
-// Universally supported extensions.
-var SupportedExts []string = []string{"json", "toml", "yaml", "yml", "properties", "props", "prop", "hcl"}
-
-// Universally supported remote providers.
-var SupportedRemoteProviders []string = []string{"etcd", "consul"}
-
-func OnConfigChange(run func(in fsnotify.Event)) { v.OnConfigChange(run) }
-func (v *Viper) OnConfigChange(run func(in fsnotify.Event)) {
- v.onConfigChange = run
-}
-
-func WatchConfig() { v.WatchConfig() }
-func (v *Viper) WatchConfig() {
- go func() {
- watcher, err := fsnotify.NewWatcher()
- if err != nil {
- log.Fatal(err)
- }
- defer watcher.Close()
-
- // we have to watch the entire directory to pick up renames/atomic saves in a cross-platform way
- configFile := filepath.Clean(v.getConfigFile())
- configDir, _ := filepath.Split(configFile)
-
- done := make(chan bool)
- go func() {
- for {
- select {
- case event := <-watcher.Events:
- // we only care about the config file
- if filepath.Clean(event.Name) == configFile {
- if event.Op&fsnotify.Write == fsnotify.Write || event.Op&fsnotify.Create == fsnotify.Create {
- err := v.ReadInConfig()
- if err != nil {
- log.Println("error:", err)
- }
- v.onConfigChange(event)
- }
- }
- case err := <-watcher.Errors:
- log.Println("error:", err)
- }
- }
- }()
-
- watcher.Add(configDir)
- <-done
- }()
-}
-
-// Explicitly define the path, name and extension of the config file
-// Viper will use this and not check any of the config paths
-func SetConfigFile(in string) { v.SetConfigFile(in) }
-func (v *Viper) SetConfigFile(in string) {
- if in != "" {
- v.configFile = in
- }
-}
-
-// Define a prefix that ENVIRONMENT variables will use.
-// E.g. if your prefix is "spf", the env registry
-// will look for env. variables that start with "SPF_"
-func SetEnvPrefix(in string) { v.SetEnvPrefix(in) }
-func (v *Viper) SetEnvPrefix(in string) {
- if in != "" {
- v.envPrefix = in
- }
-}
-
-func (v *Viper) mergeWithEnvPrefix(in string) string {
- if v.envPrefix != "" {
- return strings.ToUpper(v.envPrefix + "_" + in)
- }
-
- return strings.ToUpper(in)
-}
-
-// TODO: should getEnv logic be moved into find(). Can generalize the use of
-// rewriting keys many things, Ex: Get('someKey') -> some_key
-// (cammel case to snake case for JSON keys perhaps)
-
-// getEnv s a wrapper around os.Getenv which replaces characters in the original
-// key. This allows env vars which have different keys then the config object
-// keys
-func (v *Viper) getEnv(key string) string {
- if v.envKeyReplacer != nil {
- key = v.envKeyReplacer.Replace(key)
- }
- return os.Getenv(key)
-}
-
-// Return the file used to populate the config registry
-func ConfigFileUsed() string { return v.ConfigFileUsed() }
-func (v *Viper) ConfigFileUsed() string { return v.configFile }
-
-// Add a path for Viper to search for the config file in.
-// Can be called multiple times to define multiple search paths.
-func AddConfigPath(in string) { v.AddConfigPath(in) }
-func (v *Viper) AddConfigPath(in string) {
- if in != "" {
- absin := absPathify(in)
- jww.INFO.Println("adding", absin, "to paths to search")
- if !stringInSlice(absin, v.configPaths) {
- v.configPaths = append(v.configPaths, absin)
- }
- }
-}
-
-// AddRemoteProvider adds a remote configuration source.
-// Remote Providers are searched in the order they are added.
-// provider is a string value, "etcd" or "consul" are currently supported.
-// endpoint is the url. etcd requires http://ip:port consul requires ip:port
-// path is the path in the k/v store to retrieve configuration
-// To retrieve a config file called myapp.json from /configs/myapp.json
-// you should set path to /configs and set config name (SetConfigName()) to
-// "myapp"
-func AddRemoteProvider(provider, endpoint, path string) error {
- return v.AddRemoteProvider(provider, endpoint, path)
-}
-func (v *Viper) AddRemoteProvider(provider, endpoint, path string) error {
- if !stringInSlice(provider, SupportedRemoteProviders) {
- return UnsupportedRemoteProviderError(provider)
- }
- if provider != "" && endpoint != "" {
- jww.INFO.Printf("adding %s:%s to remote provider list", provider, endpoint)
- rp := &defaultRemoteProvider{
- endpoint: endpoint,
- provider: provider,
- path: path,
- }
- if !v.providerPathExists(rp) {
- v.remoteProviders = append(v.remoteProviders, rp)
- }
- }
- return nil
-}
-
-// AddSecureRemoteProvider adds a remote configuration source.
-// Secure Remote Providers are searched in the order they are added.
-// provider is a string value, "etcd" or "consul" are currently supported.
-// endpoint is the url. etcd requires http://ip:port consul requires ip:port
-// secretkeyring is the filepath to your openpgp secret keyring. e.g. /etc/secrets/myring.gpg
-// path is the path in the k/v store to retrieve configuration
-// To retrieve a config file called myapp.json from /configs/myapp.json
-// you should set path to /configs and set config name (SetConfigName()) to
-// "myapp"
-// Secure Remote Providers are implemented with github.com/xordataexchange/crypt
-func AddSecureRemoteProvider(provider, endpoint, path, secretkeyring string) error {
- return v.AddSecureRemoteProvider(provider, endpoint, path, secretkeyring)
-}
-
-func (v *Viper) AddSecureRemoteProvider(provider, endpoint, path, secretkeyring string) error {
- if !stringInSlice(provider, SupportedRemoteProviders) {
- return UnsupportedRemoteProviderError(provider)
- }
- if provider != "" && endpoint != "" {
- jww.INFO.Printf("adding %s:%s to remote provider list", provider, endpoint)
- rp := &defaultRemoteProvider{
- endpoint: endpoint,
- provider: provider,
- path: path,
- secretKeyring: secretkeyring,
- }
- if !v.providerPathExists(rp) {
- v.remoteProviders = append(v.remoteProviders, rp)
- }
- }
- return nil
-}
-
-func (v *Viper) providerPathExists(p *defaultRemoteProvider) bool {
- for _, y := range v.remoteProviders {
- if reflect.DeepEqual(y, p) {
- return true
- }
- }
- return false
-}
-
-func (v *Viper) searchMap(source map[string]interface{}, path []string) interface{} {
-
- if len(path) == 0 {
- return source
- }
-
- var ok bool
- var next interface{}
- for k, v := range source {
- if strings.ToLower(k) == strings.ToLower(path[0]) {
- ok = true
- next = v
- break
- }
- }
-
- if ok {
- switch next.(type) {
- case map[interface{}]interface{}:
- return v.searchMap(cast.ToStringMap(next), path[1:])
- case map[string]interface{}:
- // Type assertion is safe here since it is only reached
- // if the type of `next` is the same as the type being asserted
- return v.searchMap(next.(map[string]interface{}), path[1:])
- default:
- return next
- }
- } else {
- return nil
- }
-}
-
-// SetTypeByDefaultValue enables or disables the inference of a key value's
-// type when the Get function is used based upon a key's default value as
-// opposed to the value returned based on the normal fetch logic.
-//
-// For example, if a key has a default value of []string{} and the same key
-// is set via an environment variable to "a b c", a call to the Get function
-// would return a string slice for the key if the key's type is inferred by
-// the default value and the Get function would return:
-//
-// []string {"a", "b", "c"}
-//
-// Otherwise the Get function would return:
-//
-// "a b c"
-func SetTypeByDefaultValue(enable bool) { v.SetTypeByDefaultValue(enable) }
-func (v *Viper) SetTypeByDefaultValue(enable bool) {
- v.typeByDefValue = enable
-}
-
-// Viper is essentially repository for configurations
-// Get can retrieve any value given the key to use
-// Get has the behavior of returning the value associated with the first
-// place from where it is set. Viper will check in the following order:
-// override, flag, env, config file, key/value store, default
-//
-// Get returns an interface. For a specific value use one of the Get____ methods.
-func Get(key string) interface{} { return v.Get(key) }
-func (v *Viper) Get(key string) interface{} {
- path := strings.Split(key, v.keyDelim)
-
- lcaseKey := strings.ToLower(key)
- val := v.find(lcaseKey)
-
- if val == nil {
- source := v.find(strings.ToLower(path[0]))
- if source != nil {
- if reflect.TypeOf(source).Kind() == reflect.Map {
- val = v.searchMap(cast.ToStringMap(source), path[1:])
- }
- }
- }
-
- // if no other value is returned and a flag does exist for the value,
- // get the flag's value even if the flag's value has not changed
- if val == nil {
- if flag, exists := v.pflags[lcaseKey]; exists {
- jww.TRACE.Println(key, "get pflag default", val)
- switch flag.ValueType() {
- case "int", "int8", "int16", "int32", "int64":
- val = cast.ToInt(flag.ValueString())
- case "bool":
- val = cast.ToBool(flag.ValueString())
- default:
- val = flag.ValueString()
- }
- }
- }
-
- if val == nil {
- return nil
- }
-
- var valType interface{}
- if !v.typeByDefValue {
- valType = val
- } else {
- defVal, defExists := v.defaults[lcaseKey]
- if defExists {
- valType = defVal
- } else {
- valType = val
- }
- }
-
- switch valType.(type) {
- case bool:
- return cast.ToBool(val)
- case string:
- return cast.ToString(val)
- case int64, int32, int16, int8, int:
- return cast.ToInt(val)
- case float64, float32:
- return cast.ToFloat64(val)
- case time.Time:
- return cast.ToTime(val)
- case time.Duration:
- return cast.ToDuration(val)
- case []string:
- return cast.ToStringSlice(val)
- }
- return val
-}
-
-// Returns new Viper instance representing a sub tree of this instance
-func Sub(key string) *Viper { return v.Sub(key) }
-func (v *Viper) Sub(key string) *Viper {
- subv := New()
- data := v.Get(key)
- if reflect.TypeOf(data).Kind() == reflect.Map {
- subv.config = cast.ToStringMap(data)
- return subv
- } else {
- return nil
- }
-}
-
-// Returns the value associated with the key as a string
-func GetString(key string) string { return v.GetString(key) }
-func (v *Viper) GetString(key string) string {
- return cast.ToString(v.Get(key))
-}
-
-// Returns the value associated with the key asa boolean
-func GetBool(key string) bool { return v.GetBool(key) }
-func (v *Viper) GetBool(key string) bool {
- return cast.ToBool(v.Get(key))
-}
-
-// Returns the value associated with the key as an integer
-func GetInt(key string) int { return v.GetInt(key) }
-func (v *Viper) GetInt(key string) int {
- return cast.ToInt(v.Get(key))
-}
-
-// Returns the value associated with the key as a float64
-func GetFloat64(key string) float64 { return v.GetFloat64(key) }
-func (v *Viper) GetFloat64(key string) float64 {
- return cast.ToFloat64(v.Get(key))
-}
-
-// Returns the value associated with the key as time
-func GetTime(key string) time.Time { return v.GetTime(key) }
-func (v *Viper) GetTime(key string) time.Time {
- return cast.ToTime(v.Get(key))
-}
-
-// Returns the value associated with the key as a duration
-func GetDuration(key string) time.Duration { return v.GetDuration(key) }
-func (v *Viper) GetDuration(key string) time.Duration {
- return cast.ToDuration(v.Get(key))
-}
-
-// Returns the value associated with the key as a slice of strings
-func GetStringSlice(key string) []string { return v.GetStringSlice(key) }
-func (v *Viper) GetStringSlice(key string) []string {
- return cast.ToStringSlice(v.Get(key))
-}
-
-// Returns the value associated with the key as a map of interfaces
-func GetStringMap(key string) map[string]interface{} { return v.GetStringMap(key) }
-func (v *Viper) GetStringMap(key string) map[string]interface{} {
- return cast.ToStringMap(v.Get(key))
-}
-
-// Returns the value associated with the key as a map of strings
-func GetStringMapString(key string) map[string]string { return v.GetStringMapString(key) }
-func (v *Viper) GetStringMapString(key string) map[string]string {
- return cast.ToStringMapString(v.Get(key))
-}
-
-// Returns the value associated with the key as a map to a slice of strings.
-func GetStringMapStringSlice(key string) map[string][]string { return v.GetStringMapStringSlice(key) }
-func (v *Viper) GetStringMapStringSlice(key string) map[string][]string {
- return cast.ToStringMapStringSlice(v.Get(key))
-}
-
-// Returns the size of the value associated with the given key
-// in bytes.
-func GetSizeInBytes(key string) uint { return v.GetSizeInBytes(key) }
-func (v *Viper) GetSizeInBytes(key string) uint {
- sizeStr := cast.ToString(v.Get(key))
- return parseSizeInBytes(sizeStr)
-}
-
-// Takes a single key and unmarshals it into a Struct
-func UnmarshalKey(key string, rawVal interface{}) error { return v.UnmarshalKey(key, rawVal) }
-func (v *Viper) UnmarshalKey(key string, rawVal interface{}) error {
- return mapstructure.Decode(v.Get(key), rawVal)
-}
-
-// Unmarshals the config into a Struct. Make sure that the tags
-// on the fields of the structure are properly set.
-func Unmarshal(rawVal interface{}) error { return v.Unmarshal(rawVal) }
-func (v *Viper) Unmarshal(rawVal interface{}) error {
- err := mapstructure.WeakDecode(v.AllSettings(), rawVal)
-
- if err != nil {
- return err
- }
-
- v.insensitiviseMaps()
-
- return nil
-}
-
-// A wrapper around mapstructure.Decode that mimics the WeakDecode functionality
-// while erroring on non existing vals in the destination struct
-func weakDecodeExact(input, output interface{}) error {
- config := &mapstructure.DecoderConfig{
- ErrorUnused: true,
- Metadata: nil,
- Result: output,
- WeaklyTypedInput: true,
- }
-
- decoder, err := mapstructure.NewDecoder(config)
- if err != nil {
- return err
- }
- return decoder.Decode(input)
-}
-
-// Unmarshals the config into a Struct, erroring if a field is non-existant
-// in the destination struct
-func (v *Viper) UnmarshalExact(rawVal interface{}) error {
- err := weakDecodeExact(v.AllSettings(), rawVal)
-
- if err != nil {
- return err
- }
-
- v.insensitiviseMaps()
-
- return nil
-}
-
-// Bind a full flag set to the configuration, using each flag's long
-// name as the config key.
-func BindPFlags(flags *pflag.FlagSet) (err error) { return v.BindPFlags(flags) }
-func (v *Viper) BindPFlags(flags *pflag.FlagSet) (err error) {
- return v.BindFlagValues(pflagValueSet{flags})
-}
-
-// Bind a specific key to a pflag (as used by cobra)
-// Example(where serverCmd is a Cobra instance):
-//
-// serverCmd.Flags().Int("port", 1138, "Port to run Application server on")
-// Viper.BindPFlag("port", serverCmd.Flags().Lookup("port"))
-//
-func BindPFlag(key string, flag *pflag.Flag) (err error) { return v.BindPFlag(key, flag) }
-func (v *Viper) BindPFlag(key string, flag *pflag.Flag) (err error) {
- return v.BindFlagValue(key, pflagValue{flag})
-}
-
-// Bind a full FlagValue set to the configuration, using each flag's long
-// name as the config key.
-func BindFlagValues(flags FlagValueSet) (err error) { return v.BindFlagValues(flags) }
-func (v *Viper) BindFlagValues(flags FlagValueSet) (err error) {
- flags.VisitAll(func(flag FlagValue) {
- if err = v.BindFlagValue(flag.Name(), flag); err != nil {
- return
- }
- })
- return nil
-}
-
-// Bind a specific key to a FlagValue.
-// Example(where serverCmd is a Cobra instance):
-//
-// serverCmd.Flags().Int("port", 1138, "Port to run Application server on")
-// Viper.BindFlagValue("port", serverCmd.Flags().Lookup("port"))
-//
-func BindFlagValue(key string, flag FlagValue) (err error) { return v.BindFlagValue(key, flag) }
-func (v *Viper) BindFlagValue(key string, flag FlagValue) (err error) {
- if flag == nil {
- return fmt.Errorf("flag for %q is nil", key)
- }
- v.pflags[strings.ToLower(key)] = flag
- return nil
-}
-
-// Binds a Viper key to a ENV variable
-// ENV variables are case sensitive
-// If only a key is provided, it will use the env key matching the key, uppercased.
-// EnvPrefix will be used when set when env name is not provided.
-func BindEnv(input ...string) (err error) { return v.BindEnv(input...) }
-func (v *Viper) BindEnv(input ...string) (err error) {
- var key, envkey string
- if len(input) == 0 {
- return fmt.Errorf("BindEnv missing key to bind to")
- }
-
- key = strings.ToLower(input[0])
-
- if len(input) == 1 {
- envkey = v.mergeWithEnvPrefix(key)
- } else {
- envkey = input[1]
- }
-
- v.env[key] = envkey
-
- return nil
-}
-
-// Given a key, find the value
-// Viper will check in the following order:
-// flag, env, config file, key/value store, default
-// Viper will check to see if an alias exists first
-func (v *Viper) find(key string) interface{} {
- var val interface{}
- var exists bool
-
- // if the requested key is an alias, then return the proper key
- key = v.realKey(key)
-
- // PFlag Override first
- flag, exists := v.pflags[key]
- if exists && flag.HasChanged() {
- jww.TRACE.Println(key, "found in override (via pflag):", flag.ValueString())
- switch flag.ValueType() {
- case "int", "int8", "int16", "int32", "int64":
- return cast.ToInt(flag.ValueString())
- case "bool":
- return cast.ToBool(flag.ValueString())
- default:
- return flag.ValueString()
- }
- }
-
- val, exists = v.override[key]
- if exists {
- jww.TRACE.Println(key, "found in override:", val)
- return val
- }
-
- if v.automaticEnvApplied {
- // even if it hasn't been registered, if automaticEnv is used,
- // check any Get request
- if val = v.getEnv(v.mergeWithEnvPrefix(key)); val != "" {
- jww.TRACE.Println(key, "found in environment with val:", val)
- return val
- }
- }
-
- envkey, exists := v.env[key]
- if exists {
- jww.TRACE.Println(key, "registered as env var", envkey)
- if val = v.getEnv(envkey); val != "" {
- jww.TRACE.Println(envkey, "found in environment with val:", val)
- return val
- } else {
- jww.TRACE.Println(envkey, "env value unset:")
- }
- }
-
- val, exists = v.config[key]
- if exists {
- jww.TRACE.Println(key, "found in config:", val)
- return val
- }
-
- // Test for nested config parameter
- if strings.Contains(key, v.keyDelim) {
- path := strings.Split(key, v.keyDelim)
-
- source := v.find(path[0])
- if source != nil {
- if reflect.TypeOf(source).Kind() == reflect.Map {
- val := v.searchMap(cast.ToStringMap(source), path[1:])
- jww.TRACE.Println(key, "found in nested config:", val)
- return val
- }
- }
- }
-
- val, exists = v.kvstore[key]
- if exists {
- jww.TRACE.Println(key, "found in key/value store:", val)
- return val
- }
-
- val, exists = v.defaults[key]
- if exists {
- jww.TRACE.Println(key, "found in defaults:", val)
- return val
- }
-
- return nil
-}
-
-// Check to see if the key has been set in any of the data locations
-func IsSet(key string) bool { return v.IsSet(key) }
-func (v *Viper) IsSet(key string) bool {
- path := strings.Split(key, v.keyDelim)
-
- lcaseKey := strings.ToLower(key)
- val := v.find(lcaseKey)
-
- if val == nil {
- source := v.find(strings.ToLower(path[0]))
- if source != nil {
- if reflect.TypeOf(source).Kind() == reflect.Map {
- val = v.searchMap(cast.ToStringMap(source), path[1:])
- }
- }
- }
-
- return val != nil
-}
-
-// Have Viper check ENV variables for all
-// keys set in config, default & flags
-func AutomaticEnv() { v.AutomaticEnv() }
-func (v *Viper) AutomaticEnv() {
- v.automaticEnvApplied = true
-}
-
-// SetEnvKeyReplacer sets the strings.Replacer on the viper object
-// Useful for mapping an environmental variable to a key that does
-// not match it.
-func SetEnvKeyReplacer(r *strings.Replacer) { v.SetEnvKeyReplacer(r) }
-func (v *Viper) SetEnvKeyReplacer(r *strings.Replacer) {
- v.envKeyReplacer = r
-}
-
-// Aliases provide another accessor for the same key.
-// This enables one to change a name without breaking the application
-func RegisterAlias(alias string, key string) { v.RegisterAlias(alias, key) }
-func (v *Viper) RegisterAlias(alias string, key string) {
- v.registerAlias(alias, strings.ToLower(key))
-}
-
-func (v *Viper) registerAlias(alias string, key string) {
- alias = strings.ToLower(alias)
- if alias != key && alias != v.realKey(key) {
- _, exists := v.aliases[alias]
-
- if !exists {
- // if we alias something that exists in one of the maps to another
- // name, we'll never be able to get that value using the original
- // name, so move the config value to the new realkey.
- if val, ok := v.config[alias]; ok {
- delete(v.config, alias)
- v.config[key] = val
- }
- if val, ok := v.kvstore[alias]; ok {
- delete(v.kvstore, alias)
- v.kvstore[key] = val
- }
- if val, ok := v.defaults[alias]; ok {
- delete(v.defaults, alias)
- v.defaults[key] = val
- }
- if val, ok := v.override[alias]; ok {
- delete(v.override, alias)
- v.override[key] = val
- }
- v.aliases[alias] = key
- }
- } else {
- jww.WARN.Println("Creating circular reference alias", alias, key, v.realKey(key))
- }
-}
-
-func (v *Viper) realKey(key string) string {
- newkey, exists := v.aliases[key]
- if exists {
- jww.DEBUG.Println("Alias", key, "to", newkey)
- return v.realKey(newkey)
- } else {
- return key
- }
-}
-
-// Check to see if the given key (or an alias) is in the config file
-func InConfig(key string) bool { return v.InConfig(key) }
-func (v *Viper) InConfig(key string) bool {
- // if the requested key is an alias, then return the proper key
- key = v.realKey(key)
-
- _, exists := v.config[key]
- return exists
-}
-
-// Set the default value for this key.
-// Default only used when no value is provided by the user via flag, config or ENV.
-func SetDefault(key string, value interface{}) { v.SetDefault(key, value) }
-func (v *Viper) SetDefault(key string, value interface{}) {
- // If alias passed in, then set the proper default
- key = v.realKey(strings.ToLower(key))
- v.defaults[key] = value
-}
-
-// Sets the value for the key in the override regiser.
-// Will be used instead of values obtained via
-// flags, config file, ENV, default, or key/value store
-func Set(key string, value interface{}) { v.Set(key, value) }
-func (v *Viper) Set(key string, value interface{}) {
- // If alias passed in, then set the proper override
- key = v.realKey(strings.ToLower(key))
- v.override[key] = value
-}
-
-// Viper will discover and load the configuration file from disk
-// and key/value stores, searching in one of the defined paths.
-func ReadInConfig() error { return v.ReadInConfig() }
-func (v *Viper) ReadInConfig() error {
- jww.INFO.Println("Attempting to read in config file")
- if !stringInSlice(v.getConfigType(), SupportedExts) {
- return UnsupportedConfigError(v.getConfigType())
- }
-
- file, err := ioutil.ReadFile(v.getConfigFile())
- if err != nil {
- return err
- }
-
- v.config = make(map[string]interface{})
-
- return v.unmarshalReader(bytes.NewReader(file), v.config)
-}
-
-// MergeInConfig merges a new configuration with an existing config.
-func MergeInConfig() error { return v.MergeInConfig() }
-func (v *Viper) MergeInConfig() error {
- jww.INFO.Println("Attempting to merge in config file")
- if !stringInSlice(v.getConfigType(), SupportedExts) {
- return UnsupportedConfigError(v.getConfigType())
- }
-
- file, err := ioutil.ReadFile(v.getConfigFile())
- if err != nil {
- return err
- }
-
- return v.MergeConfig(bytes.NewReader(file))
-}
-
-// Viper will read a configuration file, setting existing keys to nil if the
-// key does not exist in the file.
-func ReadConfig(in io.Reader) error { return v.ReadConfig(in) }
-func (v *Viper) ReadConfig(in io.Reader) error {
- v.config = make(map[string]interface{})
- return v.unmarshalReader(in, v.config)
-}
-
-// MergeConfig merges a new configuration with an existing config.
-func MergeConfig(in io.Reader) error { return v.MergeConfig(in) }
-func (v *Viper) MergeConfig(in io.Reader) error {
- if v.config == nil {
- v.config = make(map[string]interface{})
- }
- cfg := make(map[string]interface{})
- if err := v.unmarshalReader(in, cfg); err != nil {
- return err
- }
- mergeMaps(cfg, v.config, nil)
- return nil
-}
-
-func keyExists(k string, m map[string]interface{}) string {
- lk := strings.ToLower(k)
- for mk := range m {
- lmk := strings.ToLower(mk)
- if lmk == lk {
- return mk
- }
- }
- return ""
-}
-
-func castToMapStringInterface(
- src map[interface{}]interface{}) map[string]interface{} {
- tgt := map[string]interface{}{}
- for k, v := range src {
- tgt[fmt.Sprintf("%v", k)] = v
- }
- return tgt
-}
-
-// mergeMaps merges two maps. The `itgt` parameter is for handling go-yaml's
-// insistence on parsing nested structures as `map[interface{}]interface{}`
-// instead of using a `string` as the key for nest structures beyond one level
-// deep. Both map types are supported as there is a go-yaml fork that uses
-// `map[string]interface{}` instead.
-func mergeMaps(
- src, tgt map[string]interface{}, itgt map[interface{}]interface{}) {
- for sk, sv := range src {
- tk := keyExists(sk, tgt)
- if tk == "" {
- jww.TRACE.Printf("tk=\"\", tgt[%s]=%v", sk, sv)
- tgt[sk] = sv
- if itgt != nil {
- itgt[sk] = sv
- }
- continue
- }
-
- tv, ok := tgt[tk]
- if !ok {
- jww.TRACE.Printf("tgt[%s] != ok, tgt[%s]=%v", tk, sk, sv)
- tgt[sk] = sv
- if itgt != nil {
- itgt[sk] = sv
- }
- continue
- }
-
- svType := reflect.TypeOf(sv)
- tvType := reflect.TypeOf(tv)
- if svType != tvType {
- jww.ERROR.Printf(
- "svType != tvType; key=%s, st=%v, tt=%v, sv=%v, tv=%v",
- sk, svType, tvType, sv, tv)
- continue
- }
-
- jww.TRACE.Printf("processing key=%s, st=%v, tt=%v, sv=%v, tv=%v",
- sk, svType, tvType, sv, tv)
-
- switch ttv := tv.(type) {
- case map[interface{}]interface{}:
- jww.TRACE.Printf("merging maps (must convert)")
- tsv := sv.(map[interface{}]interface{})
- ssv := castToMapStringInterface(tsv)
- stv := castToMapStringInterface(ttv)
- mergeMaps(ssv, stv, ttv)
- case map[string]interface{}:
- jww.TRACE.Printf("merging maps")
- mergeMaps(sv.(map[string]interface{}), ttv, nil)
- default:
- jww.TRACE.Printf("setting value")
- tgt[tk] = sv
- if itgt != nil {
- itgt[tk] = sv
- }
- }
- }
-}
-
-// func ReadBufConfig(buf *bytes.Buffer) error { return v.ReadBufConfig(buf) }
-// func (v *Viper) ReadBufConfig(buf *bytes.Buffer) error {
-// v.config = make(map[string]interface{})
-// return v.unmarshalReader(buf, v.config)
-// }
-
-// Attempts to get configuration from a remote source
-// and read it in the remote configuration registry.
-func ReadRemoteConfig() error { return v.ReadRemoteConfig() }
-func (v *Viper) ReadRemoteConfig() error {
- err := v.getKeyValueConfig()
- if err != nil {
- return err
- }
- return nil
-}
-
-func WatchRemoteConfig() error { return v.WatchRemoteConfig() }
-func (v *Viper) WatchRemoteConfig() error {
- err := v.watchKeyValueConfig()
- if err != nil {
- return err
- }
- return nil
-}
-
-// Unmarshall a Reader into a map
-// Should probably be an unexported function
-func unmarshalReader(in io.Reader, c map[string]interface{}) error {
- return v.unmarshalReader(in, c)
-}
-
-func (v *Viper) unmarshalReader(in io.Reader, c map[string]interface{}) error {
- return unmarshallConfigReader(in, c, v.getConfigType())
-}
-
-func (v *Viper) insensitiviseMaps() {
- insensitiviseMap(v.config)
- insensitiviseMap(v.defaults)
- insensitiviseMap(v.override)
- insensitiviseMap(v.kvstore)
-}
-
-// retrieve the first found remote configuration
-func (v *Viper) getKeyValueConfig() error {
- if RemoteConfig == nil {
- return RemoteConfigError("Enable the remote features by doing a blank import of the viper/remote package: '_ github.com/spf13/viper/remote'")
- }
-
- for _, rp := range v.remoteProviders {
- val, err := v.getRemoteConfig(rp)
- if err != nil {
- continue
- }
- v.kvstore = val
- return nil
- }
- return RemoteConfigError("No Files Found")
-}
-
-func (v *Viper) getRemoteConfig(provider *defaultRemoteProvider) (map[string]interface{}, error) {
-
- reader, err := RemoteConfig.Get(provider)
- if err != nil {
- return nil, err
- }
- err = v.unmarshalReader(reader, v.kvstore)
- return v.kvstore, err
-}
-
-// retrieve the first found remote configuration
-func (v *Viper) watchKeyValueConfig() error {
- for _, rp := range v.remoteProviders {
- val, err := v.watchRemoteConfig(rp)
- if err != nil {
- continue
- }
- v.kvstore = val
- return nil
- }
- return RemoteConfigError("No Files Found")
-}
-
-func (v *Viper) watchRemoteConfig(provider *defaultRemoteProvider) (map[string]interface{}, error) {
- reader, err := RemoteConfig.Watch(provider)
- if err != nil {
- return nil, err
- }
- err = v.unmarshalReader(reader, v.kvstore)
- return v.kvstore, err
-}
-
-// Return all keys regardless where they are set
-func AllKeys() []string { return v.AllKeys() }
-func (v *Viper) AllKeys() []string {
- m := map[string]struct{}{}
-
- for key, _ := range v.defaults {
- m[strings.ToLower(key)] = struct{}{}
- }
-
- for key, _ := range v.pflags {
- m[strings.ToLower(key)] = struct{}{}
- }
-
- for key, _ := range v.env {
- m[strings.ToLower(key)] = struct{}{}
- }
-
- for key, _ := range v.config {
- m[strings.ToLower(key)] = struct{}{}
- }
-
- for key, _ := range v.kvstore {
- m[strings.ToLower(key)] = struct{}{}
- }
-
- for key, _ := range v.override {
- m[strings.ToLower(key)] = struct{}{}
- }
-
- for key, _ := range v.aliases {
- m[strings.ToLower(key)] = struct{}{}
- }
-
- a := []string{}
- for x, _ := range m {
- a = append(a, x)
- }
-
- return a
-}
-
-// Return all settings as a map[string]interface{}
-func AllSettings() map[string]interface{} { return v.AllSettings() }
-func (v *Viper) AllSettings() map[string]interface{} {
- m := map[string]interface{}{}
- for _, x := range v.AllKeys() {
- m[x] = v.Get(x)
- }
-
- return m
-}
-
-// Name for the config file.
-// Does not include extension.
-func SetConfigName(in string) { v.SetConfigName(in) }
-func (v *Viper) SetConfigName(in string) {
- if in != "" {
- v.configName = in
- }
-}
-
-// Sets the type of the configuration returned by the
-// remote source, e.g. "json".
-func SetConfigType(in string) { v.SetConfigType(in) }
-func (v *Viper) SetConfigType(in string) {
- if in != "" {
- v.configType = in
- }
-}
-
-func (v *Viper) getConfigType() string {
- if v.configType != "" {
- return v.configType
- }
-
- cf := v.getConfigFile()
- ext := filepath.Ext(cf)
-
- if len(ext) > 1 {
- return ext[1:]
- } else {
- return ""
- }
-}
-
-func (v *Viper) getConfigFile() string {
- // if explicitly set, then use it
- if v.configFile != "" {
- return v.configFile
- }
-
- cf, err := v.findConfigFile()
- if err != nil {
- return ""
- }
-
- v.configFile = cf
- return v.getConfigFile()
-}
-
-func (v *Viper) searchInPath(in string) (filename string) {
- jww.DEBUG.Println("Searching for config in ", in)
- for _, ext := range SupportedExts {
- jww.DEBUG.Println("Checking for", filepath.Join(in, v.configName+"."+ext))
- if b, _ := exists(filepath.Join(in, v.configName+"."+ext)); b {
- jww.DEBUG.Println("Found: ", filepath.Join(in, v.configName+"."+ext))
- return filepath.Join(in, v.configName+"."+ext)
- }
- }
-
- return ""
-}
-
-// search all configPaths for any config file.
-// Returns the first path that exists (and is a config file)
-func (v *Viper) findConfigFile() (string, error) {
-
- jww.INFO.Println("Searching for config in ", v.configPaths)
-
- for _, cp := range v.configPaths {
- file := v.searchInPath(cp)
- if file != "" {
- return file, nil
- }
- }
- return "", ConfigFileNotFoundError{v.configName, fmt.Sprintf("%s", v.configPaths)}
-}
-
-// Prints all configuration registries for debugging
-// purposes.
-func Debug() { v.Debug() }
-func (v *Viper) Debug() {
- fmt.Println("Aliases:")
- pretty.Println(v.aliases)
- fmt.Println("Override:")
- pretty.Println(v.override)
- fmt.Println("PFlags")
- pretty.Println(v.pflags)
- fmt.Println("Env:")
- pretty.Println(v.env)
- fmt.Println("Key/Value Store:")
- pretty.Println(v.kvstore)
- fmt.Println("Config:")
- pretty.Println(v.config)
- fmt.Println("Defaults:")
- pretty.Println(v.defaults)
-}
diff --git a/newt/vendor/mynewt.apache.org/newt/yaml/apic.go b/newt/vendor/mynewt.apache.org/newt/yaml/apic.go
deleted file mode 100644
index 12847fd9..00000000
--- a/newt/vendor/mynewt.apache.org/newt/yaml/apic.go
+++ /dev/null
@@ -1,767 +0,0 @@
-/**
- * This file is a Go port of its corresponding C file in libyaml. This port
- * was was copied from the yaml.v2 library. This file is licensed as follows:
- *
- * Copyright (c) 2006 Kirill Simonov
- *
- * 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.
- */
-
-package yaml
-
-import (
- "io"
- "os"
-)
-
-func yaml_insert_token(parser *yaml_parser_t, pos int, token *yaml_token_t) {
- //fmt.Println("yaml_insert_token", "pos:", pos, "typ:", token.typ, "head:", parser.tokens_head, "len:", len(parser.tokens))
-
- // Check if we can move the queue at the beginning of the buffer.
- if parser.tokens_head > 0 && len(parser.tokens) == cap(parser.tokens) {
- if parser.tokens_head != len(parser.tokens) {
- copy(parser.tokens, parser.tokens[parser.tokens_head:])
- }
- parser.tokens = parser.tokens[:len(parser.tokens)-parser.tokens_head]
- parser.tokens_head = 0
- }
- parser.tokens = append(parser.tokens, *token)
- if pos < 0 {
- return
- }
- copy(parser.tokens[parser.tokens_head+pos+1:], parser.tokens[parser.tokens_head+pos:])
- parser.tokens[parser.tokens_head+pos] = *token
-}
-
-// Create a new parser object.
-func yaml_parser_initialize(parser *yaml_parser_t) bool {
- *parser = yaml_parser_t{
- raw_buffer: make([]byte, 0, input_raw_buffer_size),
- buffer: make([]byte, 0, input_buffer_size),
- }
- return true
-}
-
-// Destroy a parser object.
-func yaml_parser_delete(parser *yaml_parser_t) {
- *parser = yaml_parser_t{}
-}
-
-// String read handler.
-func yaml_string_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) {
- if parser.input_pos == len(parser.input) {
- return 0, io.EOF
- }
- n = copy(buffer, parser.input[parser.input_pos:])
- parser.input_pos += n
- return n, nil
-}
-
-// File read handler.
-func yaml_file_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) {
- return parser.input_file.Read(buffer)
-}
-
-// Set a string input.
-func yaml_parser_set_input_string(parser *yaml_parser_t, input []byte) {
- if parser.read_handler != nil {
- panic("must set the input source only once")
- }
- parser.read_handler = yaml_string_read_handler
- parser.input = input
- parser.input_pos = 0
-}
-
-// Set a file input.
-func yaml_parser_set_input_file(parser *yaml_parser_t, file *os.File) {
- if parser.read_handler != nil {
- panic("must set the input source only once")
- }
- parser.read_handler = yaml_file_read_handler
- parser.input_file = file
-}
-
-// Set the source encoding.
-func yaml_parser_set_encoding(parser *yaml_parser_t, encoding yaml_encoding_t) {
- if parser.encoding != yaml_ANY_ENCODING {
- panic("must set the encoding only once")
- }
- parser.encoding = encoding
-}
-
-// Create a new emitter object.
-func yaml_emitter_initialize(emitter *yaml_emitter_t) bool {
- *emitter = yaml_emitter_t{
- buffer: make([]byte, output_buffer_size),
- raw_buffer: make([]byte, 0, output_raw_buffer_size),
- states: make([]yaml_emitter_state_t, 0, initial_stack_size),
- events: make([]yaml_event_t, 0, initial_queue_size),
- }
- return true
-}
-
-// Destroy an emitter object.
-func yaml_emitter_delete(emitter *yaml_emitter_t) {
- *emitter = yaml_emitter_t{}
-}
-
-// String write handler.
-func yaml_string_write_handler(emitter *yaml_emitter_t, buffer []byte) error {
- *emitter.output_buffer = append(*emitter.output_buffer, buffer...)
- return nil
-}
-
-// File write handler.
-func yaml_file_write_handler(emitter *yaml_emitter_t, buffer []byte) error {
- _, err := emitter.output_file.Write(buffer)
- return err
-}
-
-// Set a string output.
-func yaml_emitter_set_output_string(emitter *yaml_emitter_t, output_buffer *[]byte) {
- if emitter.write_handler != nil {
- panic("must set the output target only once")
- }
- emitter.write_handler = yaml_string_write_handler
- emitter.output_buffer = output_buffer
-}
-
-// Set a file output.
-func yaml_emitter_set_output_file(emitter *yaml_emitter_t, file io.Writer) {
- if emitter.write_handler != nil {
- panic("must set the output target only once")
- }
- emitter.write_handler = yaml_file_write_handler
- emitter.output_file = file
-}
-
-// Set the output encoding.
-func yaml_emitter_set_encoding(emitter *yaml_emitter_t, encoding yaml_encoding_t) {
- if emitter.encoding != yaml_ANY_ENCODING {
- panic("must set the output encoding only once")
- }
- emitter.encoding = encoding
-}
-
-// Set the canonical output style.
-func yaml_emitter_set_canonical(emitter *yaml_emitter_t, canonical bool) {
- emitter.canonical = canonical
-}
-
-//// Set the indentation increment.
-func yaml_emitter_set_indent(emitter *yaml_emitter_t, indent int) {
- if indent < 2 || indent > 9 {
- indent = 2
- }
- emitter.best_indent = indent
-}
-
-// Set the preferred line width.
-func yaml_emitter_set_width(emitter *yaml_emitter_t, width int) {
- if width < 0 {
- width = -1
- }
- emitter.best_width = width
-}
-
-// Set if unescaped non-ASCII characters are allowed.
-func yaml_emitter_set_unicode(emitter *yaml_emitter_t, unicode bool) {
- emitter.unicode = unicode
-}
-
-// Set the preferred line break character.
-func yaml_emitter_set_break(emitter *yaml_emitter_t, line_break yaml_break_t) {
- emitter.line_break = line_break
-}
-
-///*
-// * Destroy a token object.
-// */
-//
-//YAML_DECLARE(void)
-//yaml_token_delete(yaml_token_t *token)
-//{
-// assert(token); // Non-NULL token object expected.
-//
-// switch (token.type)
-// {
-// case YAML_TAG_DIRECTIVE_TOKEN:
-// yaml_free(token.data.tag_directive.handle);
-// yaml_free(token.data.tag_directive.prefix);
-// break;
-//
-// case YAML_ALIAS_TOKEN:
-// yaml_free(token.data.alias.value);
-// break;
-//
-// case YAML_ANCHOR_TOKEN:
-// yaml_free(token.data.anchor.value);
-// break;
-//
-// case YAML_TAG_TOKEN:
-// yaml_free(token.data.tag.handle);
-// yaml_free(token.data.tag.suffix);
-// break;
-//
-// case YAML_SCALAR_TOKEN:
-// yaml_free(token.data.scalar.value);
-// break;
-//
-// default:
-// break;
-// }
-//
-// memset(token, 0, sizeof(yaml_token_t));
-//}
-//
-///*
-// * Check if a string is a valid UTF-8 sequence.
-// *
-// * Check 'reader.c' for more details on UTF-8 encoding.
-// */
-//
-//static int
-//yaml_check_utf8(yaml_char_t *start, size_t length)
-//{
-// yaml_char_t *end = start+length;
-// yaml_char_t *pointer = start;
-//
-// while (pointer < end) {
-// unsigned char octet;
-// unsigned int width;
-// unsigned int value;
-// size_t k;
-//
-// octet = pointer[0];
-// width = (octet & 0x80) == 0x00 ? 1 :
-// (octet & 0xE0) == 0xC0 ? 2 :
-// (octet & 0xF0) == 0xE0 ? 3 :
-// (octet & 0xF8) == 0xF0 ? 4 : 0;
-// value = (octet & 0x80) == 0x00 ? octet & 0x7F :
-// (octet & 0xE0) == 0xC0 ? octet & 0x1F :
-// (octet & 0xF0) == 0xE0 ? octet & 0x0F :
-// (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0;
-// if (!width) return 0;
-// if (pointer+width > end) return 0;
-// for (k = 1; k < width; k ++) {
-// octet = pointer[k];
-// if ((octet & 0xC0) != 0x80) return 0;
-// value = (value << 6) + (octet & 0x3F);
-// }
-// if (!((width == 1) ||
-// (width == 2 && value >= 0x80) ||
-// (width == 3 && value >= 0x800) ||
-// (width == 4 && value >= 0x10000))) return 0;
-//
-// pointer += width;
-// }
-//
-// return 1;
-//}
-//
-
-// Create STREAM-START.
-func yaml_stream_start_event_initialize(event *yaml_event_t, encoding yaml_encoding_t) bool {
- *event = yaml_event_t{
- typ: yaml_STREAM_START_EVENT,
- encoding: encoding,
- }
- return true
-}
-
-// Create STREAM-END.
-func yaml_stream_end_event_initialize(event *yaml_event_t) bool {
- *event = yaml_event_t{
- typ: yaml_STREAM_END_EVENT,
- }
- return true
-}
-
-// Create DOCUMENT-START.
-func yaml_document_start_event_initialize(event *yaml_event_t, version_directive *yaml_version_directive_t,
- tag_directives []yaml_tag_directive_t, implicit bool) bool {
- *event = yaml_event_t{
- typ: yaml_DOCUMENT_START_EVENT,
- version_directive: version_directive,
- tag_directives: tag_directives,
- implicit: implicit,
- }
- return true
-}
-
-// Create DOCUMENT-END.
-func yaml_document_end_event_initialize(event *yaml_event_t, implicit bool) bool {
- *event = yaml_event_t{
- typ: yaml_DOCUMENT_END_EVENT,
- implicit: implicit,
- }
- return true
-}
-
-///*
-// * Create ALIAS.
-// */
-//
-//YAML_DECLARE(int)
-//yaml_alias_event_initialize(event *yaml_event_t, anchor *yaml_char_t)
-//{
-// mark yaml_mark_t = { 0, 0, 0 }
-// anchor_copy *yaml_char_t = NULL
-//
-// assert(event) // Non-NULL event object is expected.
-// assert(anchor) // Non-NULL anchor is expected.
-//
-// if (!yaml_check_utf8(anchor, strlen((char *)anchor))) return 0
-//
-// anchor_copy = yaml_strdup(anchor)
-// if (!anchor_copy)
-// return 0
-//
-// ALIAS_EVENT_INIT(*event, anchor_copy, mark, mark)
-//
-// return 1
-//}
-
-// Create SCALAR.
-func yaml_scalar_event_initialize(event *yaml_event_t, anchor, tag, value []byte, plain_implicit, quoted_implicit bool, style yaml_scalar_style_t) bool {
- *event = yaml_event_t{
- typ: yaml_SCALAR_EVENT,
- anchor: anchor,
- tag: tag,
- value: value,
- implicit: plain_implicit,
- quoted_implicit: quoted_implicit,
- style: yaml_style_t(style),
- }
- return true
-}
-
-// Create SEQUENCE-START.
-func yaml_sequence_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_sequence_style_t) bool {
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_START_EVENT,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- style: yaml_style_t(style),
- }
- return true
-}
-
-// Create SEQUENCE-END.
-func yaml_sequence_end_event_initialize(event *yaml_event_t) bool {
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_END_EVENT,
- }
- return true
-}
-
-// Create MAPPING-START.
-func yaml_mapping_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_mapping_style_t) bool {
- *event = yaml_event_t{
- typ: yaml_MAPPING_START_EVENT,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- style: yaml_style_t(style),
- }
- return true
-}
-
-// Create MAPPING-END.
-func yaml_mapping_end_event_initialize(event *yaml_event_t) bool {
- *event = yaml_event_t{
- typ: yaml_MAPPING_END_EVENT,
- }
- return true
-}
-
-// Destroy an event object.
-func yaml_event_delete(event *yaml_event_t) {
- *event = yaml_event_t{}
-}
-
-///*
-// * Create a document object.
-// */
-//
-//YAML_DECLARE(int)
-//yaml_document_initialize(document *yaml_document_t,
-// version_directive *yaml_version_directive_t,
-// tag_directives_start *yaml_tag_directive_t,
-// tag_directives_end *yaml_tag_directive_t,
-// start_implicit int, end_implicit int)
-//{
-// struct {
-// error yaml_error_type_t
-// } context
-// struct {
-// start *yaml_node_t
-// end *yaml_node_t
-// top *yaml_node_t
-// } nodes = { NULL, NULL, NULL }
-// version_directive_copy *yaml_version_directive_t = NULL
-// struct {
-// start *yaml_tag_directive_t
-// end *yaml_tag_directive_t
-// top *yaml_tag_directive_t
-// } tag_directives_copy = { NULL, NULL, NULL }
-// value yaml_tag_directive_t = { NULL, NULL }
-// mark yaml_mark_t = { 0, 0, 0 }
-//
-// assert(document) // Non-NULL document object is expected.
-// assert((tag_directives_start && tag_directives_end) ||
-// (tag_directives_start == tag_directives_end))
-// // Valid tag directives are expected.
-//
-// if (!STACK_INIT(&context, nodes, INITIAL_STACK_SIZE)) goto error
-//
-// if (version_directive) {
-// version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t))
-// if (!version_directive_copy) goto error
-// version_directive_copy.major = version_directive.major
-// version_directive_copy.minor = version_directive.minor
-// }
-//
-// if (tag_directives_start != tag_directives_end) {
-// tag_directive *yaml_tag_directive_t
-// if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE))
-// goto error
-// for (tag_directive = tag_directives_start
-// tag_directive != tag_directives_end; tag_directive ++) {
-// assert(tag_directive.handle)
-// assert(tag_directive.prefix)
-// if (!yaml_check_utf8(tag_directive.handle,
-// strlen((char *)tag_directive.handle)))
-// goto error
-// if (!yaml_check_utf8(tag_directive.prefix,
-// strlen((char *)tag_directive.prefix)))
-// goto error
-// value.handle = yaml_strdup(tag_directive.handle)
-// value.prefix = yaml_strdup(tag_directive.prefix)
-// if (!value.handle || !value.prefix) goto error
-// if (!PUSH(&context, tag_directives_copy, value))
-// goto error
-// value.handle = NULL
-// value.prefix = NULL
-// }
-// }
-//
-// DOCUMENT_INIT(*document, nodes.start, nodes.end, version_directive_copy,
-// tag_directives_copy.start, tag_directives_copy.top,
-// start_implicit, end_implicit, mark, mark)
-//
-// return 1
-//
-//error:
-// STACK_DEL(&context, nodes)
-// yaml_free(version_directive_copy)
-// while (!STACK_EMPTY(&context, tag_directives_copy)) {
-// value yaml_tag_directive_t = POP(&context, tag_directives_copy)
-// yaml_free(value.handle)
-// yaml_free(value.prefix)
-// }
-// STACK_DEL(&context, tag_directives_copy)
-// yaml_free(value.handle)
-// yaml_free(value.prefix)
-//
-// return 0
-//}
-//
-///*
-// * Destroy a document object.
-// */
-//
-//YAML_DECLARE(void)
-//yaml_document_delete(document *yaml_document_t)
-//{
-// struct {
-// error yaml_error_type_t
-// } context
-// tag_directive *yaml_tag_directive_t
-//
-// context.error = YAML_NO_ERROR // Eliminate a compliler warning.
-//
-// assert(document) // Non-NULL document object is expected.
-//
-// while (!STACK_EMPTY(&context, document.nodes)) {
-// node yaml_node_t = POP(&context, document.nodes)
-// yaml_free(node.tag)
-// switch (node.type) {
-// case YAML_SCALAR_NODE:
-// yaml_free(node.data.scalar.value)
-// break
-// case YAML_SEQUENCE_NODE:
-// STACK_DEL(&context, node.data.sequence.items)
-// break
-// case YAML_MAPPING_NODE:
-// STACK_DEL(&context, node.data.mapping.pairs)
-// break
-// default:
-// assert(0) // Should not happen.
-// }
-// }
-// STACK_DEL(&context, document.nodes)
-//
-// yaml_free(document.version_directive)
-// for (tag_directive = document.tag_directives.start
-// tag_directive != document.tag_directives.end
-// tag_directive++) {
-// yaml_free(tag_directive.handle)
-// yaml_free(tag_directive.prefix)
-// }
-// yaml_free(document.tag_directives.start)
-//
-// memset(document, 0, sizeof(yaml_document_t))
-//}
-//
-///**
-// * Get a document node.
-// */
-//
-//YAML_DECLARE(yaml_node_t *)
-//yaml_document_get_node(document *yaml_document_t, index int)
-//{
-// assert(document) // Non-NULL document object is expected.
-//
-// if (index > 0 && document.nodes.start + index <= document.nodes.top) {
-// return document.nodes.start + index - 1
-// }
-// return NULL
-//}
-//
-///**
-// * Get the root object.
-// */
-//
-//YAML_DECLARE(yaml_node_t *)
-//yaml_document_get_root_node(document *yaml_document_t)
-//{
-// assert(document) // Non-NULL document object is expected.
-//
-// if (document.nodes.top != document.nodes.start) {
-// return document.nodes.start
-// }
-// return NULL
-//}
-//
-///*
-// * Add a scalar node to a document.
-// */
-//
-//YAML_DECLARE(int)
-//yaml_document_add_scalar(document *yaml_document_t,
-// tag *yaml_char_t, value *yaml_char_t, length int,
-// style yaml_scalar_style_t)
-//{
-// struct {
-// error yaml_error_type_t
-// } context
-// mark yaml_mark_t = { 0, 0, 0 }
-// tag_copy *yaml_char_t = NULL
-// value_copy *yaml_char_t = NULL
-// node yaml_node_t
-//
-// assert(document) // Non-NULL document object is expected.
-// assert(value) // Non-NULL value is expected.
-//
-// if (!tag) {
-// tag = (yaml_char_t *)YAML_DEFAULT_SCALAR_TAG
-// }
-//
-// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error
-// tag_copy = yaml_strdup(tag)
-// if (!tag_copy) goto error
-//
-// if (length < 0) {
-// length = strlen((char *)value)
-// }
-//
-// if (!yaml_check_utf8(value, length)) goto error
-// value_copy = yaml_malloc(length+1)
-// if (!value_copy) goto error
-// memcpy(value_copy, value, length)
-// value_copy[length] = '\0'
-//
-// SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark)
-// if (!PUSH(&context, document.nodes, node)) goto error
-//
-// return document.nodes.top - document.nodes.start
-//
-//error:
-// yaml_free(tag_copy)
-// yaml_free(value_copy)
-//
-// return 0
-//}
-//
-///*
-// * Add a sequence node to a document.
-// */
-//
-//YAML_DECLARE(int)
-//yaml_document_add_sequence(document *yaml_document_t,
-// tag *yaml_char_t, style yaml_sequence_style_t)
-//{
-// struct {
-// error yaml_error_type_t
-// } context
-// mark yaml_mark_t = { 0, 0, 0 }
-// tag_copy *yaml_char_t = NULL
-// struct {
-// start *yaml_node_item_t
-// end *yaml_node_item_t
-// top *yaml_node_item_t
-// } items = { NULL, NULL, NULL }
-// node yaml_node_t
-//
-// assert(document) // Non-NULL document object is expected.
-//
-// if (!tag) {
-// tag = (yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG
-// }
-//
-// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error
-// tag_copy = yaml_strdup(tag)
-// if (!tag_copy) goto error
-//
-// if (!STACK_INIT(&context, items, INITIAL_STACK_SIZE)) goto error
-//
-// SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end,
-// style, mark, mark)
-// if (!PUSH(&context, document.nodes, node)) goto error
-//
-// return document.nodes.top - document.nodes.start
-//
-//error:
-// STACK_DEL(&context, items)
-// yaml_free(tag_copy)
-//
-// return 0
-//}
-//
-///*
-// * Add a mapping node to a document.
-// */
-//
-//YAML_DECLARE(int)
-//yaml_document_add_mapping(document *yaml_document_t,
-// tag *yaml_char_t, style yaml_mapping_style_t)
-//{
-// struct {
-// error yaml_error_type_t
-// } context
-// mark yaml_mark_t = { 0, 0, 0 }
-// tag_copy *yaml_char_t = NULL
-// struct {
-// start *yaml_node_pair_t
-// end *yaml_node_pair_t
-// top *yaml_node_pair_t
-// } pairs = { NULL, NULL, NULL }
-// node yaml_node_t
-//
-// assert(document) // Non-NULL document object is expected.
-//
-// if (!tag) {
-// tag = (yaml_char_t *)YAML_DEFAULT_MAPPING_TAG
-// }
-//
-// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error
-// tag_copy = yaml_strdup(tag)
-// if (!tag_copy) goto error
-//
-// if (!STACK_INIT(&context, pairs, INITIAL_STACK_SIZE)) goto error
-//
-// MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end,
-// style, mark, mark)
-// if (!PUSH(&context, document.nodes, node)) goto error
-//
-// return document.nodes.top - document.nodes.start
-//
-//error:
-// STACK_DEL(&context, pairs)
-// yaml_free(tag_copy)
-//
-// return 0
-//}
-//
-///*
-// * Append an item to a sequence node.
-// */
-//
-//YAML_DECLARE(int)
-//yaml_document_append_sequence_item(document *yaml_document_t,
-// sequence int, item int)
-//{
-// struct {
-// error yaml_error_type_t
-// } context
-//
-// assert(document) // Non-NULL document is required.
-// assert(sequence > 0
-// && document.nodes.start + sequence <= document.nodes.top)
-// // Valid sequence id is required.
-// assert(document.nodes.start[sequence-1].type == YAML_SEQUENCE_NODE)
-// // A sequence node is required.
-// assert(item > 0 && document.nodes.start + item <= document.nodes.top)
-// // Valid item id is required.
-//
-// if (!PUSH(&context,
-// document.nodes.start[sequence-1].data.sequence.items, item))
-// return 0
-//
-// return 1
-//}
-//
-///*
-// * Append a pair of a key and a value to a mapping node.
-// */
-//
-//YAML_DECLARE(int)
-//yaml_document_append_mapping_pair(document *yaml_document_t,
-// mapping int, key int, value int)
-//{
-// struct {
-// error yaml_error_type_t
-// } context
-//
-// pair yaml_node_pair_t
-//
-// assert(document) // Non-NULL document is required.
-// assert(mapping > 0
-// && document.nodes.start + mapping <= document.nodes.top)
-// // Valid mapping id is required.
-// assert(document.nodes.start[mapping-1].type == YAML_MAPPING_NODE)
-// // A mapping node is required.
-// assert(key > 0 && document.nodes.start + key <= document.nodes.top)
-// // Valid key id is required.
-// assert(value > 0 && document.nodes.start + value <= document.nodes.top)
-// // Valid value id is required.
-//
-// pair.key = key
-// pair.value = value
-//
-// if (!PUSH(&context,
-// document.nodes.start[mapping-1].data.mapping.pairs, pair))
-// return 0
-//
-// return 1
-//}
-//
-//
diff --git a/newt/vendor/mynewt.apache.org/newt/yaml/decode.go b/newt/vendor/mynewt.apache.org/newt/yaml/decode.go
deleted file mode 100644
index 46588fe2..00000000
--- a/newt/vendor/mynewt.apache.org/newt/yaml/decode.go
+++ /dev/null
@@ -1,308 +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 yaml
-
-import (
- "errors"
- "fmt"
- "strconv"
-)
-
-type decodeState int
-
-const (
- CTXT_STATE_NONE decodeState = iota
- CTXT_STATE_SCALAR decodeState = iota
- CTXT_STATE_MAPPING decodeState = iota
- CTXT_STATE_SEQUENCE decodeState = iota
- CTXT_STATE_DONE decodeState = iota
-)
-
-type decodeCtxt struct {
- state decodeState
- value interface{}
-}
-
-type YamlDispatchFn func(*yaml_parser_t, *yaml_event_t,
- *decodeCtxt) (decodeCtxt, error)
-
-var decodeFilename string
-var decodeDispatch map[yaml_event_type_t]YamlDispatchFn
-
-// Fills in the decodeDispatch table. This function is necessary because
-// statically initializing the table triggers a spurious "initialization loop"
-// error.
-func initDecodeDispatch() {
- if decodeDispatch != nil {
- return
- }
-
- decodeDispatch = map[yaml_event_type_t]YamlDispatchFn{
- yaml_STREAM_START_EVENT: decodeNoOp,
- yaml_DOCUMENT_START_EVENT: decodeNoOp,
- yaml_DOCUMENT_END_EVENT: decodeNoOp,
- yaml_ALIAS_EVENT: decodeNoOp,
- yaml_STREAM_END_EVENT: decodeStreamEnd,
- yaml_SCALAR_EVENT: decodeScalar,
- yaml_SEQUENCE_START_EVENT: decodeSequenceStart,
- yaml_SEQUENCE_END_EVENT: decodeSequenceEnd,
- yaml_MAPPING_START_EVENT: decodeMappingStart,
- yaml_MAPPING_END_EVENT: decodeMappingEnd,
- }
-}
-
-func decodeError(parser *yaml_parser_t, format string,
- sprintfArgs ...interface{}) error {
-
- prefix := fmt.Sprintf("[%s:%d]: ", decodeFilename, parser.mark.line+1)
- msg := prefix + fmt.Sprintf(format, sprintfArgs...)
- return errors.New(msg)
-}
-
-// Appends the specified value to the end of a sequence-context's value slice.
-func sequenceAdd(ctxt *decodeCtxt, value interface{}) {
- if ctxt.value == nil {
- ctxt.value = []interface{}{}
- }
- ctxt.value = append(ctxt.value.([]interface{}), value)
-}
-
-// Inserts the specified value into a mapping-context's value map.
-func mappingAdd(ctxt *decodeCtxt, key string, value interface{}) {
- if ctxt.value == nil {
- ctxt.value = map[interface{}]interface{}{}
- }
-
- ctxt.value.(map[interface{}]interface{})[key] = value
-}
-
-func genValue(strVal string) interface{} {
- intVal, err := strconv.Atoi(strVal)
- if err == nil {
- return intVal
- }
-
- boolVal, err := strconv.ParseBool(strVal)
- if err == nil {
- return boolVal
- }
-
- return strVal
-}
-
-func stringValue(value interface{}) string {
- switch value.(type) {
- case int:
- return strconv.FormatInt(int64(value.(int)), 10)
-
- case bool:
- return strconv.FormatBool(value.(bool))
-
- case string:
- return value.(string)
-
- default:
- panic("unexpected type")
- }
-}
-
-func decodeNoOp(parser *yaml_parser_t, event *yaml_event_t,
- parentCtxt *decodeCtxt) (decodeCtxt, error) {
-
- return decodeCtxt{state: CTXT_STATE_NONE}, nil
-}
-
-func decodeStreamEnd(parser *yaml_parser_t, event *yaml_event_t,
- parentCtxt *decodeCtxt) (decodeCtxt, error) {
-
- return decodeCtxt{state: CTXT_STATE_DONE}, nil
-}
-
-func decodeNextValue(parser *yaml_parser_t,
- parentCtxt *decodeCtxt) (decodeCtxt, error) {
- for {
- ctxt, err := decodeEvent(parser, parentCtxt)
- if err != nil {
- return ctxt, err
- }
-
- if ctxt.state != CTXT_STATE_NONE {
- return ctxt, nil
- }
- }
-}
-
-func decodeSequenceStart(parser *yaml_parser_t, event *yaml_event_t,
- parentCtxt *decodeCtxt) (decodeCtxt, error) {
-
- ctxt := decodeCtxt{state: CTXT_STATE_SEQUENCE}
-
- // For each element in the sequence, decode it and append it to the
- // seqeunce-context's value slice.
- for {
- subCtxt, err := decodeNextValue(parser, &ctxt)
- if err != nil {
- return ctxt, err
- }
-
- if subCtxt.state == CTXT_STATE_DONE {
- break
- }
-
- sequenceAdd(&ctxt, subCtxt.value)
- }
-
- return ctxt, nil
-}
-
-func decodeSequenceEnd(parser *yaml_parser_t, event *yaml_event_t,
- parentCtxt *decodeCtxt) (decodeCtxt, error) {
-
- ctxt := decodeCtxt{state: CTXT_STATE_DONE}
- if parentCtxt.state != CTXT_STATE_SEQUENCE {
- return ctxt, decodeError(parser, "sequence end without start")
- }
-
- return ctxt, nil
-}
-
-func decodeMappingKey(parser *yaml_parser_t,
- parentCtxt *decodeCtxt) (decodeCtxt, error) {
-
- ctxt, err := decodeNextValue(parser, parentCtxt)
- if err != nil {
- return ctxt, err
- }
-
- switch ctxt.state {
- case CTXT_STATE_DONE, CTXT_STATE_SCALAR:
- // Mapping complete or key decoded.
- return ctxt, nil
-
- default:
- return ctxt, decodeError(parser, "mapping lacks scalar key")
- }
-}
-
-func decodeMappingStart(parser *yaml_parser_t, event *yaml_event_t,
- parentCtxt *decodeCtxt) (decodeCtxt, error) {
-
- ctxt := decodeCtxt{state: CTXT_STATE_MAPPING}
-
- for {
- subCtxt, err := decodeMappingKey(parser, &ctxt)
- if err != nil || subCtxt.state == CTXT_STATE_DONE {
- return ctxt, err
- }
- key := stringValue(subCtxt.value)
-
- subCtxt, err = decodeNextValue(parser, &ctxt)
- if err != nil {
- return ctxt, err
- }
- if subCtxt.state == CTXT_STATE_DONE {
- return ctxt, decodeError(parser, "mapping lacks value")
- }
- mappingAdd(&ctxt, key, subCtxt.value)
- }
-
- return ctxt, nil
-}
-
-func decodeMappingEnd(parser *yaml_parser_t, event *yaml_event_t,
- parentCtxt *decodeCtxt) (decodeCtxt, error) {
-
- ctxt := decodeCtxt{state: CTXT_STATE_DONE}
- if parentCtxt.state != CTXT_STATE_MAPPING {
- return ctxt, decodeError(parser, "mapping end without start")
- }
-
- return ctxt, nil
-}
-
-func decodeScalar(parser *yaml_parser_t, event *yaml_event_t,
- parentCtxt *decodeCtxt) (decodeCtxt, error) {
-
- ctxt := decodeCtxt{state: CTXT_STATE_SCALAR}
- strVal := string(event.value)
- ctxt.value = genValue(strVal)
-
- return ctxt, nil
-}
-
-func decodeEvent(parser *yaml_parser_t,
- parentCtxt *decodeCtxt) (decodeCtxt, error) {
-
- event := yaml_event_t{}
- defer yaml_event_delete(&event)
-
- ctxt := decodeCtxt{state: CTXT_STATE_NONE}
-
- rc := yaml_parser_parse(parser, &event)
- if !rc {
- return ctxt, decodeError(parser, "%s", parser.problem)
- }
-
- fn := decodeDispatch[event.typ]
- if fn == nil {
- return ctxt, decodeError(parser, "Invalid event type: %s (%d)",
- constNames[event.typ], event.typ)
- }
-
- ctxt, err := fn(parser, &event, parentCtxt)
- return ctxt, err
-}
-
-func DecodeStream(b []byte, values map[string]interface{}) error {
- parser := yaml_parser_t{}
-
- initDecodeDispatch()
-
- yaml_parser_initialize(&parser)
- yaml_parser_set_input_string(&parser, b)
-
- // Decode YAML events until we get a valid mapping.
- for {
- ctxt := decodeCtxt{state: CTXT_STATE_NONE}
- subCtxt, err := decodeEvent(&parser, &ctxt)
- if err != nil {
- return err
- }
-
- switch subCtxt.state {
- case CTXT_STATE_MAPPING:
- // Copy mapping to input variable.
- for k, v := range subCtxt.value.(map[interface{}]interface{}) {
- values[k.(string)] = v
- }
-
- case CTXT_STATE_DONE:
- return nil
-
- default:
- // Unneeded metadata; proceed to next event.
- break
- }
- }
-}
-
-func SetFilename(filename string) {
- decodeFilename = filename
-}
diff --git a/newt/vendor/mynewt.apache.org/newt/yaml/emitterc.go b/newt/vendor/mynewt.apache.org/newt/yaml/emitterc.go
deleted file mode 100644
index bd63a4a1..00000000
--- a/newt/vendor/mynewt.apache.org/newt/yaml/emitterc.go
+++ /dev/null
@@ -1,1710 +0,0 @@
-/**
- * This file is a Go port of its corresponding C file in libyaml. This port
- * was was copied from the yaml.v2 library. This file is licensed as follows:
- *
- * Copyright (c) 2006 Kirill Simonov
- *
- * 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.
- */
-
-package yaml
-
-import (
- "bytes"
-)
-
-// Flush the buffer if needed.
-func flush(emitter *yaml_emitter_t) bool {
- if emitter.buffer_pos+5 >= len(emitter.buffer) {
- return yaml_emitter_flush(emitter)
- }
- return true
-}
-
-// Put a character to the output buffer.
-func put(emitter *yaml_emitter_t, value byte) bool {
- if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {
- return false
- }
- emitter.buffer[emitter.buffer_pos] = value
- emitter.buffer_pos++
- emitter.column++
- return true
-}
-
-// Put a line break to the output buffer.
-func put_break(emitter *yaml_emitter_t) bool {
- if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {
- return false
- }
- switch emitter.line_break {
- case yaml_CR_BREAK:
- emitter.buffer[emitter.buffer_pos] = '\r'
- emitter.buffer_pos += 1
- case yaml_LN_BREAK:
- emitter.buffer[emitter.buffer_pos] = '\n'
- emitter.buffer_pos += 1
- case yaml_CRLN_BREAK:
- emitter.buffer[emitter.buffer_pos+0] = '\r'
- emitter.buffer[emitter.buffer_pos+1] = '\n'
- emitter.buffer_pos += 2
- default:
- panic("unknown line break setting")
- }
- emitter.column = 0
- emitter.line++
- return true
-}
-
-// Copy a character from a string into buffer.
-func write(emitter *yaml_emitter_t, s []byte, i *int) bool {
- if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {
- return false
- }
- p := emitter.buffer_pos
- w := width(s[*i])
- switch w {
- case 4:
- emitter.buffer[p+3] = s[*i+3]
- fallthrough
- case 3:
- emitter.buffer[p+2] = s[*i+2]
- fallthrough
- case 2:
- emitter.buffer[p+1] = s[*i+1]
- fallthrough
- case 1:
- emitter.buffer[p+0] = s[*i+0]
- default:
- panic("unknown character width")
- }
- emitter.column++
- emitter.buffer_pos += w
- *i += w
- return true
-}
-
-// Write a whole string into buffer.
-func write_all(emitter *yaml_emitter_t, s []byte) bool {
- for i := 0; i < len(s); {
- if !write(emitter, s, &i) {
- return false
- }
- }
- return true
-}
-
-// Copy a line break character from a string into buffer.
-func write_break(emitter *yaml_emitter_t, s []byte, i *int) bool {
- if s[*i] == '\n' {
- if !put_break(emitter) {
- return false
- }
- *i++
- } else {
- if !write(emitter, s, i) {
- return false
- }
- emitter.column = 0
- emitter.line++
- }
- return true
-}
-
-// Set an emitter error and return false.
-func yaml_emitter_set_emitter_error(emitter *yaml_emitter_t, problem string) bool {
- emitter.error = yaml_EMITTER_ERROR
- emitter.problem = problem
- return false
-}
-
-// Emit an event.
-func yaml_emitter_emit(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- emitter.events = append(emitter.events, *event)
- for !yaml_emitter_need_more_events(emitter) {
- event := &emitter.events[emitter.events_head]
- if !yaml_emitter_analyze_event(emitter, event) {
- return false
- }
- if !yaml_emitter_state_machine(emitter, event) {
- return false
- }
- yaml_event_delete(event)
- emitter.events_head++
- }
- return true
-}
-
-// Check if we need to accumulate more events before emitting.
-//
-// We accumulate extra
-// - 1 event for DOCUMENT-START
-// - 2 events for SEQUENCE-START
-// - 3 events for MAPPING-START
-//
-func yaml_emitter_need_more_events(emitter *yaml_emitter_t) bool {
- if emitter.events_head == len(emitter.events) {
- return true
- }
- var accumulate int
- switch emitter.events[emitter.events_head].typ {
- case yaml_DOCUMENT_START_EVENT:
- accumulate = 1
- break
- case yaml_SEQUENCE_START_EVENT:
- accumulate = 2
- break
- case yaml_MAPPING_START_EVENT:
- accumulate = 3
- break
- default:
- return false
- }
- if len(emitter.events)-emitter.events_head > accumulate {
- return false
- }
- var level int
- for i := emitter.events_head; i < len(emitter.events); i++ {
- switch emitter.events[i].typ {
- case yaml_STREAM_START_EVENT, yaml_DOCUMENT_START_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT:
- level++
- case yaml_STREAM_END_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_END_EVENT, yaml_MAPPING_END_EVENT:
- level--
- }
- if level == 0 {
- return false
- }
- }
- return true
-}
-
-// Append a directive to the directives stack.
-func yaml_emitter_append_tag_directive(emitter *yaml_emitter_t, value *yaml_tag_directive_t, allow_duplicates bool) bool {
- for i := 0; i < len(emitter.tag_directives); i++ {
- if bytes.Equal(value.handle, emitter.tag_directives[i].handle) {
- if allow_duplicates {
- return true
- }
- return yaml_emitter_set_emitter_error(emitter, "duplicate %TAG directive")
- }
- }
-
- // [Go] Do we actually need to copy this given garbage collection
- // and the lack of deallocating destructors?
- tag_copy := yaml_tag_directive_t{
- handle: make([]byte, len(value.handle)),
- prefix: make([]byte, len(value.prefix)),
- }
- copy(tag_copy.handle, value.handle)
- copy(tag_copy.prefix, value.prefix)
- emitter.tag_directives = append(emitter.tag_directives, tag_copy)
- return true
-}
-
-// Increase the indentation level.
-func yaml_emitter_increase_indent(emitter *yaml_emitter_t, flow, indentless bool) bool {
- emitter.indents = append(emitter.indents, emitter.indent)
- if emitter.indent < 0 {
- if flow {
- emitter.indent = emitter.best_indent
- } else {
- emitter.indent = 0
- }
- } else if !indentless {
- emitter.indent += emitter.best_indent
- }
- return true
-}
-
-// State dispatcher.
-func yaml_emitter_state_machine(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- switch emitter.state {
- default:
- case yaml_EMIT_STREAM_START_STATE:
- return yaml_emitter_emit_stream_start(emitter, event)
-
- case yaml_EMIT_FIRST_DOCUMENT_START_STATE:
- return yaml_emitter_emit_document_start(emitter, event, true)
-
- case yaml_EMIT_DOCUMENT_START_STATE:
- return yaml_emitter_emit_document_start(emitter, event, false)
-
- case yaml_EMIT_DOCUMENT_CONTENT_STATE:
- return yaml_emitter_emit_document_content(emitter, event)
-
- case yaml_EMIT_DOCUMENT_END_STATE:
- return yaml_emitter_emit_document_end(emitter, event)
-
- case yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE:
- return yaml_emitter_emit_flow_sequence_item(emitter, event, true)
-
- case yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE:
- return yaml_emitter_emit_flow_sequence_item(emitter, event, false)
-
- case yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE:
- return yaml_emitter_emit_flow_mapping_key(emitter, event, true)
-
- case yaml_EMIT_FLOW_MAPPING_KEY_STATE:
- return yaml_emitter_emit_flow_mapping_key(emitter, event, false)
-
- case yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE:
- return yaml_emitter_emit_flow_mapping_value(emitter, event, true)
-
- case yaml_EMIT_FLOW_MAPPING_VALUE_STATE:
- return yaml_emitter_emit_flow_mapping_value(emitter, event, false)
-
- case yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE:
- return yaml_emitter_emit_block_sequence_item(emitter, event, true)
-
- case yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE:
- return yaml_emitter_emit_block_sequence_item(emitter, event, false)
-
- case yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE:
- return yaml_emitter_emit_block_mapping_key(emitter, event, true)
-
- case yaml_EMIT_BLOCK_MAPPING_KEY_STATE:
- return yaml_emitter_emit_block_mapping_key(emitter, event, false)
-
- case yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE:
- return yaml_emitter_emit_block_mapping_value(emitter, event, true)
-
- case yaml_EMIT_BLOCK_MAPPING_VALUE_STATE:
- return yaml_emitter_emit_block_mapping_value(emitter, event, false)
-
- case yaml_EMIT_END_STATE:
- return yaml_emitter_set_emitter_error(emitter, "expected nothing after STREAM-END")
- }
- panic("invalid emitter state")
-}
-
-// Expect STREAM-START.
-func yaml_emitter_emit_stream_start(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- if event.typ != yaml_STREAM_START_EVENT {
- return yaml_emitter_set_emitter_error(emitter, "expected STREAM-START")
- }
- if emitter.encoding == yaml_ANY_ENCODING {
- emitter.encoding = event.encoding
- if emitter.encoding == yaml_ANY_ENCODING {
- emitter.encoding = yaml_UTF8_ENCODING
- }
- }
- if emitter.best_indent < 2 || emitter.best_indent > 9 {
- emitter.best_indent = 2
- }
- if emitter.best_width >= 0 && emitter.best_width <= emitter.best_indent*2 {
- emitter.best_width = 80
- }
- if emitter.best_width < 0 {
- emitter.best_width = 1<<31 - 1
- }
- if emitter.line_break == yaml_ANY_BREAK {
- emitter.line_break = yaml_LN_BREAK
- }
-
- emitter.indent = -1
- emitter.line = 0
- emitter.column = 0
- emitter.whitespace = true
- emitter.indention = true
-
- if emitter.encoding != yaml_UTF8_ENCODING {
- if !yaml_emitter_write_bom(emitter) {
- return false
- }
- }
- emitter.state = yaml_EMIT_FIRST_DOCUMENT_START_STATE
- return true
-}
-
-// Expect DOCUMENT-START or STREAM-END.
-func yaml_emitter_emit_document_start(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {
-
- if event.typ == yaml_DOCUMENT_START_EVENT {
-
- if event.version_directive != nil {
- if !yaml_emitter_analyze_version_directive(emitter, event.version_directive) {
- return false
- }
- }
-
- for i := 0; i < len(event.tag_directives); i++ {
- tag_directive := &event.tag_directives[i]
- if !yaml_emitter_analyze_tag_directive(emitter, tag_directive) {
- return false
- }
- if !yaml_emitter_append_tag_directive(emitter, tag_directive, false) {
- return false
- }
- }
-
- for i := 0; i < len(default_tag_directives); i++ {
- tag_directive := &default_tag_directives[i]
- if !yaml_emitter_append_tag_directive(emitter, tag_directive, true) {
- return false
- }
- }
-
- implicit := event.implicit
- if !first || emitter.canonical {
- implicit = false
- }
-
- if emitter.open_ended && (event.version_directive != nil || len(event.tag_directives) > 0) {
- if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) {
- return false
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
-
- if event.version_directive != nil {
- implicit = false
- if !yaml_emitter_write_indicator(emitter, []byte("%YAML"), true, false, false) {
- return false
- }
- if !yaml_emitter_write_indicator(emitter, []byte("1.1"), true, false, false) {
- return false
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
-
- if len(event.tag_directives) > 0 {
- implicit = false
- for i := 0; i < len(event.tag_directives); i++ {
- tag_directive := &event.tag_directives[i]
- if !yaml_emitter_write_indicator(emitter, []byte("%TAG"), true, false, false) {
- return false
- }
- if !yaml_emitter_write_tag_handle(emitter, tag_directive.handle) {
- return false
- }
- if !yaml_emitter_write_tag_content(emitter, tag_directive.prefix, true) {
- return false
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- }
-
- if yaml_emitter_check_empty_document(emitter) {
- implicit = false
- }
- if !implicit {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if !yaml_emitter_write_indicator(emitter, []byte("---"), true, false, false) {
- return false
- }
- if emitter.canonical {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- }
-
- emitter.state = yaml_EMIT_DOCUMENT_CONTENT_STATE
- return true
- }
-
- if event.typ == yaml_STREAM_END_EVENT {
- if emitter.open_ended {
- if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) {
- return false
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if !yaml_emitter_flush(emitter) {
- return false
- }
- emitter.state = yaml_EMIT_END_STATE
- return true
- }
-
- return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-START or STREAM-END")
-}
-
-// Expect the root node.
-func yaml_emitter_emit_document_content(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- emitter.states = append(emitter.states, yaml_EMIT_DOCUMENT_END_STATE)
- return yaml_emitter_emit_node(emitter, event, true, false, false, false)
-}
-
-// Expect DOCUMENT-END.
-func yaml_emitter_emit_document_end(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- if event.typ != yaml_DOCUMENT_END_EVENT {
- return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-END")
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if !event.implicit {
- // [Go] Allocate the slice elsewhere.
- if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) {
- return false
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if !yaml_emitter_flush(emitter) {
- return false
- }
- emitter.state = yaml_EMIT_DOCUMENT_START_STATE
- emitter.tag_directives = emitter.tag_directives[:0]
- return true
-}
-
-// Expect a flow item node.
-func yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {
- if first {
- if !yaml_emitter_write_indicator(emitter, []byte{'['}, true, true, false) {
- return false
- }
- if !yaml_emitter_increase_indent(emitter, true, false) {
- return false
- }
- emitter.flow_level++
- }
-
- if event.typ == yaml_SEQUENCE_END_EVENT {
- emitter.flow_level--
- emitter.indent = emitter.indents[len(emitter.indents)-1]
- emitter.indents = emitter.indents[:len(emitter.indents)-1]
- if emitter.canonical && !first {
- if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
- return false
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if !yaml_emitter_write_indicator(emitter, []byte{']'}, false, false, false) {
- return false
- }
- emitter.state = emitter.states[len(emitter.states)-1]
- emitter.states = emitter.states[:len(emitter.states)-1]
-
- return true
- }
-
- if !first {
- if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
- return false
- }
- }
-
- if emitter.canonical || emitter.column > emitter.best_width {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- emitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE)
- return yaml_emitter_emit_node(emitter, event, false, true, false, false)
-}
-
-// Expect a flow key node.
-func yaml_emitter_emit_flow_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {
- if first {
- if !yaml_emitter_write_indicator(emitter, []byte{'{'}, true, true, false) {
- return false
- }
- if !yaml_emitter_increase_indent(emitter, true, false) {
- return false
- }
- emitter.flow_level++
- }
-
- if event.typ == yaml_MAPPING_END_EVENT {
- emitter.flow_level--
- emitter.indent = emitter.indents[len(emitter.indents)-1]
- emitter.indents = emitter.indents[:len(emitter.indents)-1]
- if emitter.canonical && !first {
- if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
- return false
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if !yaml_emitter_write_indicator(emitter, []byte{'}'}, false, false, false) {
- return false
- }
- emitter.state = emitter.states[len(emitter.states)-1]
- emitter.states = emitter.states[:len(emitter.states)-1]
- return true
- }
-
- if !first {
- if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
- return false
- }
- }
- if emitter.canonical || emitter.column > emitter.best_width {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
-
- if !emitter.canonical && yaml_emitter_check_simple_key(emitter) {
- emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE)
- return yaml_emitter_emit_node(emitter, event, false, false, true, true)
- }
- if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, false) {
- return false
- }
- emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_VALUE_STATE)
- return yaml_emitter_emit_node(emitter, event, false, false, true, false)
-}
-
-// Expect a flow value node.
-func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool {
- if simple {
- if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) {
- return false
- }
- } else {
- if emitter.canonical || emitter.column > emitter.best_width {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, false) {
- return false
- }
- }
- emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_KEY_STATE)
- return yaml_emitter_emit_node(emitter, event, false, false, true, false)
-}
-
-// Expect a block item node.
-func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {
- if first {
- if !yaml_emitter_increase_indent(emitter, false, emitter.mapping_context && !emitter.indention) {
- return false
- }
- }
- if event.typ == yaml_SEQUENCE_END_EVENT {
- emitter.indent = emitter.indents[len(emitter.indents)-1]
- emitter.indents = emitter.indents[:len(emitter.indents)-1]
- emitter.state = emitter.states[len(emitter.states)-1]
- emitter.states = emitter.states[:len(emitter.states)-1]
- return true
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if !yaml_emitter_write_indicator(emitter, []byte{'-'}, true, false, true) {
- return false
- }
- emitter.states = append(emitter.states, yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE)
- return yaml_emitter_emit_node(emitter, event, false, true, false, false)
-}
-
-// Expect a block key node.
-func yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {
- if first {
- if !yaml_emitter_increase_indent(emitter, false, false) {
- return false
- }
- }
- if event.typ == yaml_MAPPING_END_EVENT {
- emitter.indent = emitter.indents[len(emitter.indents)-1]
- emitter.indents = emitter.indents[:len(emitter.indents)-1]
- emitter.state = emitter.states[len(emitter.states)-1]
- emitter.states = emitter.states[:len(emitter.states)-1]
- return true
- }
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if yaml_emitter_check_simple_key(emitter) {
- emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE)
- return yaml_emitter_emit_node(emitter, event, false, false, true, true)
- }
- if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, true) {
- return false
- }
- emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_VALUE_STATE)
- return yaml_emitter_emit_node(emitter, event, false, false, true, false)
-}
-
-// Expect a block value node.
-func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool {
- if simple {
- if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) {
- return false
- }
- } else {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, true) {
- return false
- }
- }
- emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_KEY_STATE)
- return yaml_emitter_emit_node(emitter, event, false, false, true, false)
-}
-
-// Expect a node.
-func yaml_emitter_emit_node(emitter *yaml_emitter_t, event *yaml_event_t,
- root bool, sequence bool, mapping bool, simple_key bool) bool {
-
- emitter.root_context = root
- emitter.sequence_context = sequence
- emitter.mapping_context = mapping
- emitter.simple_key_context = simple_key
-
- switch event.typ {
- case yaml_ALIAS_EVENT:
- return yaml_emitter_emit_alias(emitter, event)
- case yaml_SCALAR_EVENT:
- return yaml_emitter_emit_scalar(emitter, event)
- case yaml_SEQUENCE_START_EVENT:
- return yaml_emitter_emit_sequence_start(emitter, event)
- case yaml_MAPPING_START_EVENT:
- return yaml_emitter_emit_mapping_start(emitter, event)
- default:
- return yaml_emitter_set_emitter_error(emitter,
- "expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS")
- }
- return false
-}
-
-// Expect ALIAS.
-func yaml_emitter_emit_alias(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- if !yaml_emitter_process_anchor(emitter) {
- return false
- }
- emitter.state = emitter.states[len(emitter.states)-1]
- emitter.states = emitter.states[:len(emitter.states)-1]
- return true
-}
-
-// Expect SCALAR.
-func yaml_emitter_emit_scalar(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- if !yaml_emitter_select_scalar_style(emitter, event) {
- return false
- }
- if !yaml_emitter_process_anchor(emitter) {
- return false
- }
- if !yaml_emitter_process_tag(emitter) {
- return false
- }
- if !yaml_emitter_increase_indent(emitter, true, false) {
- return false
- }
- if !yaml_emitter_process_scalar(emitter) {
- return false
- }
- emitter.indent = emitter.indents[len(emitter.indents)-1]
- emitter.indents = emitter.indents[:len(emitter.indents)-1]
- emitter.state = emitter.states[len(emitter.states)-1]
- emitter.states = emitter.states[:len(emitter.states)-1]
- return true
-}
-
-// Expect SEQUENCE-START.
-func yaml_emitter_emit_sequence_start(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- if !yaml_emitter_process_anchor(emitter) {
- return false
- }
- if !yaml_emitter_process_tag(emitter) {
- return false
- }
- if emitter.flow_level > 0 || emitter.canonical || event.sequence_style() == yaml_FLOW_SEQUENCE_STYLE ||
- yaml_emitter_check_empty_sequence(emitter) {
- emitter.state = yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE
- } else {
- emitter.state = yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE
- }
- return true
-}
-
-// Expect MAPPING-START.
-func yaml_emitter_emit_mapping_start(emitter *yaml_emitter_t, event *yaml_event_t) bool {
- if !yaml_emitter_process_anchor(emitter) {
- return false
- }
- if !yaml_emitter_process_tag(emitter) {
- return false
- }
- if emitter.flow_level > 0 || emitter.canonical || event.mapping_style() == yaml_FLOW_MAPPING_STYLE ||
- yaml_emitter_check_empty_mapping(emitter) {
- emitter.state = yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE
- } else {
- emitter.state = yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE
- }
- return true
-}
-
-// Check if the document content is an empty scalar.
-func yaml_emitter_check_empty_document(emitter *yaml_emitter_t) bool {
- return false // [Go] Huh?
-}
-
-// Check if the next events represent an empty sequence.
-func yaml_emitter_check_empty_sequence(emitter *yaml_emitter_t) bool {
- if len(emitter.events)-emitter.events_head < 2 {
- return false
- }
- return emitter.events[emitter.events_head].typ == yaml_SEQUENCE_START_EVENT &&
- emitter.events[emitter.events_head+1].typ == yaml_SEQUENCE_END_EVENT
-}
-
-// Check if the next events represent an empty mapping.
-func yaml_emitter_check_empty_mapping(emitter *yaml_emitter_t) bool {
- if len(emitter.events)-emitter.events_head < 2 {
- return false
- }
- return emitter.events[emitter.events_head].typ == yaml_MAPPING_START_EVENT &&
- emitter.events[emitter.events_head+1].typ == yaml_MAPPING_END_EVENT
-}
-
-// Check if the next node can be expressed as a simple key.
-func yaml_emitter_check_simple_key(emitter *yaml_emitter_t) bool {
- length := 0
- switch emitter.events[emitter.events_head].typ {
- case yaml_ALIAS_EVENT:
- length += len(emitter.anchor_data.anchor)
- case yaml_SCALAR_EVENT:
- if emitter.scalar_data.multiline {
- return false
- }
- length += len(emitter.anchor_data.anchor) +
- len(emitter.tag_data.handle) +
- len(emitter.tag_data.suffix) +
- len(emitter.scalar_data.value)
- case yaml_SEQUENCE_START_EVENT:
- if !yaml_emitter_check_empty_sequence(emitter) {
- return false
- }
- length += len(emitter.anchor_data.anchor) +
- len(emitter.tag_data.handle) +
- len(emitter.tag_data.suffix)
- case yaml_MAPPING_START_EVENT:
- if !yaml_emitter_check_empty_mapping(emitter) {
- return false
- }
- length += len(emitter.anchor_data.anchor) +
- len(emitter.tag_data.handle) +
- len(emitter.tag_data.suffix)
- default:
- return false
- }
- return length <= 128
-}
-
-// Determine an acceptable scalar style.
-func yaml_emitter_select_scalar_style(emitter *yaml_emitter_t, event *yaml_event_t) bool {
-
- no_tag := len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0
- if no_tag && !event.implicit && !event.quoted_implicit {
- return yaml_emitter_set_emitter_error(emitter, "neither tag nor implicit flags are specified")
- }
-
- style := event.scalar_style()
- if style == yaml_ANY_SCALAR_STYLE {
- style = yaml_PLAIN_SCALAR_STYLE
- }
- if emitter.canonical {
- style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
- }
- if emitter.simple_key_context && emitter.scalar_data.multiline {
- style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
- }
-
- if style == yaml_PLAIN_SCALAR_STYLE {
- if emitter.flow_level > 0 && !emitter.scalar_data.flow_plain_allowed ||
- emitter.flow_level == 0 && !emitter.scalar_data.block_plain_allowed {
- style = yaml_SINGLE_QUOTED_SCALAR_STYLE
- }
- if len(emitter.scalar_data.value) == 0 && (emitter.flow_level > 0 || emitter.simple_key_context) {
- style = yaml_SINGLE_QUOTED_SCALAR_STYLE
- }
- if no_tag && !event.implicit {
- style = yaml_SINGLE_QUOTED_SCALAR_STYLE
- }
- }
- if style == yaml_SINGLE_QUOTED_SCALAR_STYLE {
- if !emitter.scalar_data.single_quoted_allowed {
- style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
- }
- }
- if style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE {
- if !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context {
- style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
- }
- }
-
- if no_tag && !event.quoted_implicit && style != yaml_PLAIN_SCALAR_STYLE {
- emitter.tag_data.handle = []byte{'!'}
- }
- emitter.scalar_data.style = style
- return true
-}
-
-// Write an achor.
-func yaml_emitter_process_anchor(emitter *yaml_emitter_t) bool {
- if emitter.anchor_data.anchor == nil {
- return true
- }
- c := []byte{'&'}
- if emitter.anchor_data.alias {
- c[0] = '*'
- }
- if !yaml_emitter_write_indicator(emitter, c, true, false, false) {
- return false
- }
- return yaml_emitter_write_anchor(emitter, emitter.anchor_data.anchor)
-}
-
-// Write a tag.
-func yaml_emitter_process_tag(emitter *yaml_emitter_t) bool {
- if len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 {
- return true
- }
- if len(emitter.tag_data.handle) > 0 {
- if !yaml_emitter_write_tag_handle(emitter, emitter.tag_data.handle) {
- return false
- }
- if len(emitter.tag_data.suffix) > 0 {
- if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) {
- return false
- }
- }
- } else {
- // [Go] Allocate these slices elsewhere.
- if !yaml_emitter_write_indicator(emitter, []byte("!<"), true, false, false) {
- return false
- }
- if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) {
- return false
- }
- if !yaml_emitter_write_indicator(emitter, []byte{'>'}, false, false, false) {
- return false
- }
- }
- return true
-}
-
-// Write a scalar.
-func yaml_emitter_process_scalar(emitter *yaml_emitter_t) bool {
- switch emitter.scalar_data.style {
- case yaml_PLAIN_SCALAR_STYLE:
- return yaml_emitter_write_plain_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context)
-
- case yaml_SINGLE_QUOTED_SCALAR_STYLE:
- return yaml_emitter_write_single_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context)
-
- case yaml_DOUBLE_QUOTED_SCALAR_STYLE:
- return yaml_emitter_write_double_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context)
-
- case yaml_LITERAL_SCALAR_STYLE:
- return yaml_emitter_write_literal_scalar(emitter, emitter.scalar_data.value)
-
- case yaml_FOLDED_SCALAR_STYLE:
- return yaml_emitter_write_folded_scalar(emitter, emitter.scalar_data.value)
- }
- panic("unknown scalar style")
-}
-
-// Check if a %YAML directive is valid.
-func yaml_emitter_analyze_version_directive(emitter *yaml_emitter_t, version_directive *yaml_version_directive_t) bool {
- if version_directive.major != 1 || version_directive.minor != 1 {
- return yaml_emitter_set_emitter_error(emitter, "incompatible %YAML directive")
- }
- return true
-}
-
-// Check if a %TAG directive is valid.
-func yaml_emitter_analyze_tag_directive(emitter *yaml_emitter_t, tag_directive *yaml_tag_directive_t) bool {
- handle := tag_directive.handle
- prefix := tag_directive.prefix
- if len(handle) == 0 {
- return yaml_emitter_set_emitter_error(emitter, "tag handle must not be empty")
- }
- if handle[0] != '!' {
- return yaml_emitter_set_emitter_error(emitter, "tag handle must start with '!'")
- }
- if handle[len(handle)-1] != '!' {
- return yaml_emitter_set_emitter_error(emitter, "tag handle must end with '!'")
- }
- for i := 1; i < len(handle)-1; i += width(handle[i]) {
- if !is_alpha(handle, i) {
- return yaml_emitter_set_emitter_error(emitter, "tag handle must contain alphanumerical characters only")
- }
- }
- if len(prefix) == 0 {
- return yaml_emitter_set_emitter_error(emitter, "tag prefix must not be empty")
- }
- return true
-}
-
-// Check if an anchor is valid.
-func yaml_emitter_analyze_anchor(emitter *yaml_emitter_t, anchor []byte, alias bool) bool {
- if len(anchor) == 0 {
- problem := "anchor value must not be empty"
- if alias {
- problem = "alias value must not be empty"
- }
- return yaml_emitter_set_emitter_error(emitter, problem)
- }
- for i := 0; i < len(anchor); i += width(anchor[i]) {
- if !is_alpha(anchor, i) {
- problem := "anchor value must contain alphanumerical characters only"
- if alias {
- problem = "alias value must contain alphanumerical characters only"
- }
- return yaml_emitter_set_emitter_error(emitter, problem)
- }
- }
- emitter.anchor_data.anchor = anchor
- emitter.anchor_data.alias = alias
- return true
-}
-
-// Check if a tag is valid.
-func yaml_emitter_analyze_tag(emitter *yaml_emitter_t, tag []byte) bool {
- if len(tag) == 0 {
- return yaml_emitter_set_emitter_error(emitter, "tag value must not be empty")
- }
- for i := 0; i < len(emitter.tag_directives); i++ {
- tag_directive := &emitter.tag_directives[i]
- if bytes.HasPrefix(tag, tag_directive.prefix) {
- emitter.tag_data.handle = tag_directive.handle
- emitter.tag_data.suffix = tag[len(tag_directive.prefix):]
- return true
- }
- }
- emitter.tag_data.suffix = tag
- return true
-}
-
-// Check if a scalar is valid.
-func yaml_emitter_analyze_scalar(emitter *yaml_emitter_t, value []byte) bool {
- var (
- block_indicators = false
- flow_indicators = false
- line_breaks = false
- special_characters = false
-
- leading_space = false
- leading_break = false
- trailing_space = false
- trailing_break = false
- break_space = false
- space_break = false
-
- preceeded_by_whitespace = false
- followed_by_whitespace = false
- previous_space = false
- previous_break = false
- )
-
- emitter.scalar_data.value = value
-
- if len(value) == 0 {
- emitter.scalar_data.multiline = false
- emitter.scalar_data.flow_plain_allowed = false
- emitter.scalar_data.block_plain_allowed = true
- emitter.scalar_data.single_quoted_allowed = true
- emitter.scalar_data.block_allowed = false
- return true
- }
-
- if len(value) >= 3 && ((value[0] == '-' && value[1] == '-' && value[2] == '-') || (value[0] == '.' && value[1] == '.' && value[2] == '.')) {
- block_indicators = true
- flow_indicators = true
- }
-
- preceeded_by_whitespace = true
- for i, w := 0, 0; i < len(value); i += w {
- w = width(value[i])
- followed_by_whitespace = i+w >= len(value) || is_blank(value, i+w)
-
- if i == 0 {
- switch value[i] {
- case '#', ',', '[', ']', '{', '}', '&', '*', '!', '|', '>', '\'', '"', '%', '@', '`':
- flow_indicators = true
- block_indicators = true
- case '?', ':':
- flow_indicators = true
- if followed_by_whitespace {
- block_indicators = true
- }
- case '-':
- if followed_by_whitespace {
- flow_indicators = true
- block_indicators = true
- }
- }
- } else {
- switch value[i] {
- case ',', '?', '[', ']', '{', '}':
- flow_indicators = true
- case ':':
- flow_indicators = true
- if followed_by_whitespace {
- block_indicators = true
- }
- case '#':
- if preceeded_by_whitespace {
- flow_indicators = true
- block_indicators = true
- }
- }
- }
-
- if !is_printable(value, i) || !is_ascii(value, i) && !emitter.unicode {
- special_characters = true
- }
- if is_space(value, i) {
- if i == 0 {
- leading_space = true
- }
- if i+width(value[i]) == len(value) {
- trailing_space = true
- }
- if previous_break {
- break_space = true
- }
- previous_space = true
- previous_break = false
- } else if is_break(value, i) {
- line_breaks = true
- if i == 0 {
- leading_break = true
- }
- if i+width(value[i]) == len(value) {
- trailing_break = true
- }
- if previous_space {
- space_break = true
- }
- previous_space = false
- previous_break = true
- } else {
- previous_space = false
- previous_break = false
- }
-
- // [Go]: Why 'z'? Couldn't be the end of the string as that's the loop condition.
- preceeded_by_whitespace = is_blankz(value, i)
- }
-
- emitter.scalar_data.multiline = line_breaks
- emitter.scalar_data.flow_plain_allowed = true
- emitter.scalar_data.block_plain_allowed = true
- emitter.scalar_data.single_quoted_allowed = true
- emitter.scalar_data.block_allowed = true
-
- if leading_space || leading_break || trailing_space || trailing_break {
- emitter.scalar_data.flow_plain_allowed = false
- emitter.scalar_data.block_plain_allowed = false
- }
- if trailing_space {
- emitter.scalar_data.block_allowed = false
- }
- if break_space {
- emitter.scalar_data.flow_plain_allowed = false
- emitter.scalar_data.block_plain_allowed = false
- emitter.scalar_data.single_quoted_allowed = false
- }
- if space_break || special_characters {
- emitter.scalar_data.flow_plain_allowed = false
- emitter.scalar_data.block_plain_allowed = false
- emitter.scalar_data.single_quoted_allowed = false
- emitter.scalar_data.block_allowed = false
- }
- if line_breaks {
- emitter.scalar_data.flow_plain_allowed = false
- emitter.scalar_data.block_plain_allowed = false
- }
- if flow_indicators {
- emitter.scalar_data.flow_plain_allowed = false
- }
- if block_indicators {
- emitter.scalar_data.block_plain_allowed = false
- }
- return true
-}
-
-// Check if the event data is valid.
-func yaml_emitter_analyze_event(emitter *yaml_emitter_t, event *yaml_event_t) bool {
-
- emitter.anchor_data.anchor = nil
- emitter.tag_data.handle = nil
- emitter.tag_data.suffix = nil
- emitter.scalar_data.value = nil
-
- switch event.typ {
- case yaml_ALIAS_EVENT:
- if !yaml_emitter_analyze_anchor(emitter, event.anchor, true) {
- return false
- }
-
- case yaml_SCALAR_EVENT:
- if len(event.anchor) > 0 {
- if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) {
- return false
- }
- }
- if len(event.tag) > 0 && (emitter.canonical || (!event.implicit && !event.quoted_implicit)) {
- if !yaml_emitter_analyze_tag(emitter, event.tag) {
- return false
- }
- }
- if !yaml_emitter_analyze_scalar(emitter, event.value) {
- return false
- }
-
- case yaml_SEQUENCE_START_EVENT:
- if len(event.anchor) > 0 {
- if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) {
- return false
- }
- }
- if len(event.tag) > 0 && (emitter.canonical || !event.implicit) {
- if !yaml_emitter_analyze_tag(emitter, event.tag) {
- return false
- }
- }
-
- case yaml_MAPPING_START_EVENT:
- if len(event.anchor) > 0 {
- if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) {
- return false
- }
- }
- if len(event.tag) > 0 && (emitter.canonical || !event.implicit) {
- if !yaml_emitter_analyze_tag(emitter, event.tag) {
- return false
- }
- }
- }
- return true
-}
-
-// Write the BOM character.
-func yaml_emitter_write_bom(emitter *yaml_emitter_t) bool {
- if !flush(emitter) {
- return false
- }
- pos := emitter.buffer_pos
- emitter.buffer[pos+0] = '\xEF'
- emitter.buffer[pos+1] = '\xBB'
- emitter.buffer[pos+2] = '\xBF'
- emitter.buffer_pos += 3
- return true
-}
-
-func yaml_emitter_write_indent(emitter *yaml_emitter_t) bool {
- indent := emitter.indent
- if indent < 0 {
- indent = 0
- }
- if !emitter.indention || emitter.column > indent || (emitter.column == indent && !emitter.whitespace) {
- if !put_break(emitter) {
- return false
- }
- }
- for emitter.column < indent {
- if !put(emitter, ' ') {
- return false
- }
- }
- emitter.whitespace = true
- emitter.indention = true
- return true
-}
-
-func yaml_emitter_write_indicator(emitter *yaml_emitter_t, indicator []byte, need_whitespace, is_whitespace, is_indention bool) bool {
- if need_whitespace && !emitter.whitespace {
- if !put(emitter, ' ') {
- return false
- }
- }
- if !write_all(emitter, indicator) {
- return false
- }
- emitter.whitespace = is_whitespace
- emitter.indention = (emitter.indention && is_indention)
- emitter.open_ended = false
- return true
-}
-
-func yaml_emitter_write_anchor(emitter *yaml_emitter_t, value []byte) bool {
- if !write_all(emitter, value) {
- return false
- }
- emitter.whitespace = false
- emitter.indention = false
- return true
-}
-
-func yaml_emitter_write_tag_handle(emitter *yaml_emitter_t, value []byte) bool {
- if !emitter.whitespace {
- if !put(emitter, ' ') {
- return false
- }
- }
- if !write_all(emitter, value) {
- return false
- }
- emitter.whitespace = false
- emitter.indention = false
- return true
-}
-
-func yaml_emitter_write_tag_content(emitter *yaml_emitter_t, value []byte, need_whitespace bool) bool {
- if need_whitespace && !emitter.whitespace {
- if !put(emitter, ' ') {
- return false
- }
- }
- for i := 0; i < len(value); {
- var must_write bool
- switch value[i] {
- case ';', '/', '?', ':', '@', '&', '=', '+', '$', ',', '_', '.', '~', '*', '\'', '(', ')', '[', ']':
- must_write = true
- default:
- must_write = is_alpha(value, i)
- }
- if must_write {
- if !write(emitter, value, &i) {
- return false
- }
- } else {
- w := width(value[i])
- for k := 0; k < w; k++ {
- octet := value[i]
- i++
- if !put(emitter, '%') {
- return false
- }
-
- c := octet >> 4
- if c < 10 {
- c += '0'
- } else {
- c += 'A' - 10
- }
- if !put(emitter, c) {
- return false
- }
-
- c = octet & 0x0f
- if c < 10 {
- c += '0'
- } else {
- c += 'A' - 10
- }
- if !put(emitter, c) {
- return false
- }
- }
- }
- }
- emitter.whitespace = false
- emitter.indention = false
- return true
-}
-
-func yaml_emitter_write_plain_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool {
- if !emitter.whitespace {
- if !put(emitter, ' ') {
- return false
- }
- }
-
- spaces := false
- breaks := false
- for i := 0; i < len(value); {
- if is_space(value, i) {
- if allow_breaks && !spaces && emitter.column > emitter.best_width && !is_space(value, i+1) {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- i += width(value[i])
- } else {
- if !write(emitter, value, &i) {
- return false
- }
- }
- spaces = true
- } else if is_break(value, i) {
- if !breaks && value[i] == '\n' {
- if !put_break(emitter) {
- return false
- }
- }
- if !write_break(emitter, value, &i) {
- return false
- }
- emitter.indention = true
- breaks = true
- } else {
- if breaks {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if !write(emitter, value, &i) {
- return false
- }
- emitter.indention = false
- spaces = false
- breaks = false
- }
- }
-
- emitter.whitespace = false
- emitter.indention = false
- if emitter.root_context {
- emitter.open_ended = true
- }
-
- return true
-}
-
-func yaml_emitter_write_single_quoted_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool {
-
- if !yaml_emitter_write_indicator(emitter, []byte{'\''}, true, false, false) {
- return false
- }
-
- spaces := false
- breaks := false
- for i := 0; i < len(value); {
- if is_space(value, i) {
- if allow_breaks && !spaces && emitter.column > emitter.best_width && i > 0 && i < len(value)-1 && !is_space(value, i+1) {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- i += width(value[i])
- } else {
- if !write(emitter, value, &i) {
- return false
- }
- }
- spaces = true
- } else if is_break(value, i) {
- if !breaks && value[i] == '\n' {
- if !put_break(emitter) {
- return false
- }
- }
- if !write_break(emitter, value, &i) {
- return false
- }
- emitter.indention = true
- breaks = true
- } else {
- if breaks {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if value[i] == '\'' {
- if !put(emitter, '\'') {
- return false
- }
- }
- if !write(emitter, value, &i) {
- return false
- }
- emitter.indention = false
- spaces = false
- breaks = false
- }
- }
- if !yaml_emitter_write_indicator(emitter, []byte{'\''}, false, false, false) {
- return false
- }
- emitter.whitespace = false
- emitter.indention = false
- return true
-}
-
-func yaml_emitter_write_double_quoted_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool {
- spaces := false
- if !yaml_emitter_write_indicator(emitter, []byte{'"'}, true, false, false) {
- return false
- }
-
- for i := 0; i < len(value); {
- if !is_printable(value, i) || (!emitter.unicode && !is_ascii(value, i)) ||
- is_bom(value, i) || is_break(value, i) ||
- value[i] == '"' || value[i] == '\\' {
-
- octet := value[i]
-
- var w int
- var v rune
- switch {
- case octet&0x80 == 0x00:
- w, v = 1, rune(octet&0x7F)
- case octet&0xE0 == 0xC0:
- w, v = 2, rune(octet&0x1F)
- case octet&0xF0 == 0xE0:
- w, v = 3, rune(octet&0x0F)
- case octet&0xF8 == 0xF0:
- w, v = 4, rune(octet&0x07)
- }
- for k := 1; k < w; k++ {
- octet = value[i+k]
- v = (v << 6) + (rune(octet) & 0x3F)
- }
- i += w
-
- if !put(emitter, '\\') {
- return false
- }
-
- var ok bool
- switch v {
- case 0x00:
- ok = put(emitter, '0')
- case 0x07:
- ok = put(emitter, 'a')
- case 0x08:
- ok = put(emitter, 'b')
- case 0x09:
- ok = put(emitter, 't')
- case 0x0A:
- ok = put(emitter, 'n')
- case 0x0b:
- ok = put(emitter, 'v')
- case 0x0c:
- ok = put(emitter, 'f')
- case 0x0d:
- ok = put(emitter, 'r')
- case 0x1b:
- ok = put(emitter, 'e')
- case 0x22:
- ok = put(emitter, '"')
- case 0x5c:
- ok = put(emitter, '\\')
- case 0x85:
- ok = put(emitter, 'N')
- case 0xA0:
- ok = put(emitter, '_')
- case 0x2028:
- ok = put(emitter, 'L')
- case 0x2029:
- ok = put(emitter, 'P')
- default:
- if v <= 0xFF {
- ok = put(emitter, 'x')
- w = 2
- } else if v <= 0xFFFF {
- ok = put(emitter, 'u')
- w = 4
- } else {
- ok = put(emitter, 'U')
- w = 8
- }
- for k := (w - 1) * 4; ok && k >= 0; k -= 4 {
- digit := byte((v >> uint(k)) & 0x0F)
- if digit < 10 {
- ok = put(emitter, digit+'0')
- } else {
- ok = put(emitter, digit+'A'-10)
- }
- }
- }
- if !ok {
- return false
- }
- spaces = false
- } else if is_space(value, i) {
- if allow_breaks && !spaces && emitter.column > emitter.best_width && i > 0 && i < len(value)-1 {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- if is_space(value, i+1) {
- if !put(emitter, '\\') {
- return false
- }
- }
- i += width(value[i])
- } else if !write(emitter, value, &i) {
- return false
- }
- spaces = true
- } else {
- if !write(emitter, value, &i) {
- return false
- }
- spaces = false
- }
- }
- if !yaml_emitter_write_indicator(emitter, []byte{'"'}, false, false, false) {
- return false
- }
- emitter.whitespace = false
- emitter.indention = false
- return true
-}
-
-func yaml_emitter_write_block_scalar_hints(emitter *yaml_emitter_t, value []byte) bool {
- if is_space(value, 0) || is_break(value, 0) {
- indent_hint := []byte{'0' + byte(emitter.best_indent)}
- if !yaml_emitter_write_indicator(emitter, indent_hint, false, false, false) {
- return false
- }
- }
-
- emitter.open_ended = false
-
- var chomp_hint [1]byte
- if len(value) == 0 {
- chomp_hint[0] = '-'
- } else {
- i := len(value) - 1
- for value[i]&0xC0 == 0x80 {
- i--
- }
- if !is_break(value, i) {
- chomp_hint[0] = '-'
- } else if i == 0 {
- chomp_hint[0] = '+'
- emitter.open_ended = true
- } else {
- i--
- for value[i]&0xC0 == 0x80 {
- i--
- }
- if is_break(value, i) {
- chomp_hint[0] = '+'
- emitter.open_ended = true
- }
- }
- }
- if chomp_hint[0] != 0 {
- if !yaml_emitter_write_indicator(emitter, chomp_hint[:], false, false, false) {
- return false
- }
- }
- return true
-}
-
-func yaml_emitter_write_literal_scalar(emitter *yaml_emitter_t, value []byte) bool {
- if !yaml_emitter_write_indicator(emitter, []byte{'|'}, true, false, false) {
- return false
- }
- if !yaml_emitter_write_block_scalar_hints(emitter, value) {
- return false
- }
- if !put_break(emitter) {
- return false
- }
- emitter.indention = true
- emitter.whitespace = true
- breaks := true
- for i := 0; i < len(value); {
- if is_break(value, i) {
- if !write_break(emitter, value, &i) {
- return false
- }
- emitter.indention = true
- breaks = true
- } else {
- if breaks {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- }
- if !write(emitter, value, &i) {
- return false
- }
- emitter.indention = false
- breaks = false
- }
- }
-
- return true
-}
-
-func yaml_emitter_write_folded_scalar(emitter *yaml_emitter_t, value []byte) bool {
- if !yaml_emitter_write_indicator(emitter, []byte{'>'}, true, false, false) {
- return false
- }
- if !yaml_emitter_write_block_scalar_hints(emitter, value) {
- return false
- }
-
- if !put_break(emitter) {
- return false
- }
- emitter.indention = true
- emitter.whitespace = true
-
- breaks := true
- leading_spaces := true
- for i := 0; i < len(value); {
- if is_break(value, i) {
- if !breaks && !leading_spaces && value[i] == '\n' {
- k := 0
- for is_break(value, k) {
- k += width(value[k])
- }
- if !is_blankz(value, k) {
- if !put_break(emitter) {
- return false
- }
- }
- }
- if !write_break(emitter, value, &i) {
- return false
- }
- emitter.indention = true
- breaks = true
- } else {
- if breaks {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- leading_spaces = is_blank(value, i)
- }
- if !breaks && is_space(value, i) && !is_space(value, i+1) && emitter.column > emitter.best_width {
- if !yaml_emitter_write_indent(emitter) {
- return false
- }
- i += width(value[i])
- } else {
- if !write(emitter, value, &i) {
- return false
- }
- }
- emitter.indention = false
- breaks = false
- }
- }
- return true
-}
diff --git a/newt/vendor/mynewt.apache.org/newt/yaml/misc.go b/newt/vendor/mynewt.apache.org/newt/yaml/misc.go
deleted file mode 100644
index 3b270fa7..00000000
--- a/newt/vendor/mynewt.apache.org/newt/yaml/misc.go
+++ /dev/null
@@ -1,32 +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 yaml
-
-import (
- "strings"
-)
-
-func EscapeString(s string) string {
- if s == "" {
- return ""
- } else {
- return "\"" + strings.Replace(s, "\"", "\\\"", -1) + "\""
- }
-}
diff --git a/newt/vendor/mynewt.apache.org/newt/yaml/parserc.go b/newt/vendor/mynewt.apache.org/newt/yaml/parserc.go
deleted file mode 100644
index 5defcae9..00000000
--- a/newt/vendor/mynewt.apache.org/newt/yaml/parserc.go
+++ /dev/null
@@ -1,1121 +0,0 @@
-/**
- * This file is a Go port of its corresponding C file in libyaml. This port
- * was was copied from the yaml.v2 library. This file is licensed as follows:
- *
- * Copyright (c) 2006 Kirill Simonov
- *
- * 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.
- */
-
-package yaml
-
-import (
- "bytes"
-)
-
-// The parser implements the following grammar:
-//
-// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END
-// implicit_document ::= block_node DOCUMENT-END*
-// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
-// block_node_or_indentless_sequence ::=
-// ALIAS
-// | properties (block_content | indentless_block_sequence)?
-// | block_content
-// | indentless_block_sequence
-// block_node ::= ALIAS
-// | properties block_content?
-// | block_content
-// flow_node ::= ALIAS
-// | properties flow_content?
-// | flow_content
-// properties ::= TAG ANCHOR? | ANCHOR TAG?
-// block_content ::= block_collection | flow_collection | SCALAR
-// flow_content ::= flow_collection | SCALAR
-// block_collection ::= block_sequence | block_mapping
-// flow_collection ::= flow_sequence | flow_mapping
-// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END
-// indentless_sequence ::= (BLOCK-ENTRY block_node?)+
-// block_mapping ::= BLOCK-MAPPING_START
-// ((KEY block_node_or_indentless_sequence?)?
-// (VALUE block_node_or_indentless_sequence?)?)*
-// BLOCK-END
-// flow_sequence ::= FLOW-SEQUENCE-START
-// (flow_sequence_entry FLOW-ENTRY)*
-// flow_sequence_entry?
-// FLOW-SEQUENCE-END
-// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-// flow_mapping ::= FLOW-MAPPING-START
-// (flow_mapping_entry FLOW-ENTRY)*
-// flow_mapping_entry?
-// FLOW-MAPPING-END
-// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-
-// Peek the next token in the token queue.
-func peek_token(parser *yaml_parser_t) *yaml_token_t {
- if parser.token_available || yaml_parser_fetch_more_tokens(parser) {
- return &parser.tokens[parser.tokens_head]
- }
- return nil
-}
-
-// Remove the next token from the queue (must be called after peek_token).
-func skip_token(parser *yaml_parser_t) {
- parser.token_available = false
- parser.tokens_parsed++
- parser.stream_end_produced = parser.tokens[parser.tokens_head].typ == yaml_STREAM_END_TOKEN
- parser.tokens_head++
-}
-
-// Get the next event.
-func yaml_parser_parse(parser *yaml_parser_t, event *yaml_event_t) bool {
- // Erase the event object.
- *event = yaml_event_t{}
-
- // No events after the end of the stream or error.
- if parser.stream_end_produced || parser.error != yaml_NO_ERROR || parser.state == yaml_PARSE_END_STATE {
- return true
- }
-
- // Generate the next event.
- return yaml_parser_state_machine(parser, event)
-}
-
-// Set parser error.
-func yaml_parser_set_parser_error(parser *yaml_parser_t, problem string, problem_mark yaml_mark_t) bool {
- parser.error = yaml_PARSER_ERROR
- parser.problem = problem
- parser.problem_mark = problem_mark
- return false
-}
-
-func yaml_parser_set_parser_error_context(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string, problem_mark yaml_mark_t) bool {
- parser.error = yaml_PARSER_ERROR
- parser.context = context
- parser.context_mark = context_mark
- parser.problem = problem
- parser.problem_mark = problem_mark
- return false
-}
-
-// State dispatcher.
-func yaml_parser_state_machine(parser *yaml_parser_t, event *yaml_event_t) bool {
- //trace("yaml_parser_state_machine", "state:", parser.state.String())
-
- switch parser.state {
- case yaml_PARSE_STREAM_START_STATE:
- return yaml_parser_parse_stream_start(parser, event)
-
- case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE:
- return yaml_parser_parse_document_start(parser, event, true)
-
- case yaml_PARSE_DOCUMENT_START_STATE:
- return yaml_parser_parse_document_start(parser, event, false)
-
- case yaml_PARSE_DOCUMENT_CONTENT_STATE:
- return yaml_parser_parse_document_content(parser, event)
-
- case yaml_PARSE_DOCUMENT_END_STATE:
- return yaml_parser_parse_document_end(parser, event)
-
- case yaml_PARSE_BLOCK_NODE_STATE:
- return yaml_parser_parse_node(parser, event, true, false)
-
- case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE:
- return yaml_parser_parse_node(parser, event, true, true)
-
- case yaml_PARSE_FLOW_NODE_STATE:
- return yaml_parser_parse_node(parser, event, false, false)
-
- case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE:
- return yaml_parser_parse_block_sequence_entry(parser, event, true)
-
- case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE:
- return yaml_parser_parse_block_sequence_entry(parser, event, false)
-
- case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE:
- return yaml_parser_parse_indentless_sequence_entry(parser, event)
-
- case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE:
- return yaml_parser_parse_block_mapping_key(parser, event, true)
-
- case yaml_PARSE_BLOCK_MAPPING_KEY_STATE:
- return yaml_parser_parse_block_mapping_key(parser, event, false)
-
- case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE:
- return yaml_parser_parse_block_mapping_value(parser, event)
-
- case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE:
- return yaml_parser_parse_flow_sequence_entry(parser, event, true)
-
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE:
- return yaml_parser_parse_flow_sequence_entry(parser, event, false)
-
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE:
- return yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event)
-
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE:
- return yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event)
-
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE:
- return yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event)
-
- case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE:
- return yaml_parser_parse_flow_mapping_key(parser, event, true)
-
- case yaml_PARSE_FLOW_MAPPING_KEY_STATE:
- return yaml_parser_parse_flow_mapping_key(parser, event, false)
-
- case yaml_PARSE_FLOW_MAPPING_VALUE_STATE:
- return yaml_parser_parse_flow_mapping_value(parser, event, false)
-
- case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE:
- return yaml_parser_parse_flow_mapping_value(parser, event, true)
-
- default:
- panic("invalid parser state")
- }
- return false
-}
-
-// Parse the production:
-// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END
-// ************
-func yaml_parser_parse_stream_start(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_STREAM_START_TOKEN {
- return yaml_parser_set_parser_error(parser, "did not find expected <stream-start>", token.start_mark)
- }
- parser.state = yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE
- *event = yaml_event_t{
- typ: yaml_STREAM_START_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- encoding: token.encoding,
- }
- skip_token(parser)
- return true
-}
-
-// Parse the productions:
-// implicit_document ::= block_node DOCUMENT-END*
-// *
-// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
-// *************************
-func yaml_parser_parse_document_start(parser *yaml_parser_t, event *yaml_event_t, implicit bool) bool {
-
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- // Parse extra document end indicators.
- if !implicit {
- for token.typ == yaml_DOCUMENT_END_TOKEN {
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- }
- }
-
- if implicit && token.typ != yaml_VERSION_DIRECTIVE_TOKEN &&
- token.typ != yaml_TAG_DIRECTIVE_TOKEN &&
- token.typ != yaml_DOCUMENT_START_TOKEN &&
- token.typ != yaml_STREAM_END_TOKEN {
- // Parse an implicit document.
- if !yaml_parser_process_directives(parser, nil, nil) {
- return false
- }
- parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE)
- parser.state = yaml_PARSE_BLOCK_NODE_STATE
-
- *event = yaml_event_t{
- typ: yaml_DOCUMENT_START_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- }
-
- } else if token.typ != yaml_STREAM_END_TOKEN {
- // Parse an explicit document.
- var version_directive *yaml_version_directive_t
- var tag_directives []yaml_tag_directive_t
- start_mark := token.start_mark
- if !yaml_parser_process_directives(parser, &version_directive, &tag_directives) {
- return false
- }
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_DOCUMENT_START_TOKEN {
- yaml_parser_set_parser_error(parser,
- "did not find expected <document start>", token.start_mark)
- return false
- }
- parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE)
- parser.state = yaml_PARSE_DOCUMENT_CONTENT_STATE
- end_mark := token.end_mark
-
- *event = yaml_event_t{
- typ: yaml_DOCUMENT_START_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- version_directive: version_directive,
- tag_directives: tag_directives,
- implicit: false,
- }
- skip_token(parser)
-
- } else {
- // Parse the stream end.
- parser.state = yaml_PARSE_END_STATE
- *event = yaml_event_t{
- typ: yaml_STREAM_END_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- }
- skip_token(parser)
- }
-
- return true
-}
-
-// Parse the productions:
-// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
-// ***********
-//
-func yaml_parser_parse_document_content(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ == yaml_VERSION_DIRECTIVE_TOKEN ||
- token.typ == yaml_TAG_DIRECTIVE_TOKEN ||
- token.typ == yaml_DOCUMENT_START_TOKEN ||
- token.typ == yaml_DOCUMENT_END_TOKEN ||
- token.typ == yaml_STREAM_END_TOKEN {
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
- return yaml_parser_process_empty_scalar(parser, event,
- token.start_mark)
- }
- return yaml_parser_parse_node(parser, event, true, false)
-}
-
-// Parse the productions:
-// implicit_document ::= block_node DOCUMENT-END*
-// *************
-// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
-//
-func yaml_parser_parse_document_end(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- start_mark := token.start_mark
- end_mark := token.start_mark
-
- implicit := true
- if token.typ == yaml_DOCUMENT_END_TOKEN {
- end_mark = token.end_mark
- skip_token(parser)
- implicit = false
- }
-
- parser.tag_directives = parser.tag_directives[:0]
-
- parser.state = yaml_PARSE_DOCUMENT_START_STATE
- *event = yaml_event_t{
- typ: yaml_DOCUMENT_END_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- implicit: implicit,
- }
- return true
-}
-
-// Parse the productions:
-// block_node_or_indentless_sequence ::=
-// ALIAS
-// *****
-// | properties (block_content | indentless_block_sequence)?
-// ********** *
-// | block_content | indentless_block_sequence
-// *
-// block_node ::= ALIAS
-// *****
-// | properties block_content?
-// ********** *
-// | block_content
-// *
-// flow_node ::= ALIAS
-// *****
-// | properties flow_content?
-// ********** *
-// | flow_content
-// *
-// properties ::= TAG ANCHOR? | ANCHOR TAG?
-// *************************
-// block_content ::= block_collection | flow_collection | SCALAR
-// ******
-// flow_content ::= flow_collection | SCALAR
-// ******
-func yaml_parser_parse_node(parser *yaml_parser_t, event *yaml_event_t, block, indentless_sequence bool) bool {
- //defer trace("yaml_parser_parse_node", "block:", block, "indentless_sequence:", indentless_sequence)()
-
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- if token.typ == yaml_ALIAS_TOKEN {
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
- *event = yaml_event_t{
- typ: yaml_ALIAS_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- anchor: token.value,
- }
- skip_token(parser)
- return true
- }
-
- start_mark := token.start_mark
- end_mark := token.start_mark
-
- var tag_token bool
- var tag_handle, tag_suffix, anchor []byte
- var tag_mark yaml_mark_t
- if token.typ == yaml_ANCHOR_TOKEN {
- anchor = token.value
- start_mark = token.start_mark
- end_mark = token.end_mark
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ == yaml_TAG_TOKEN {
- tag_token = true
- tag_handle = token.value
- tag_suffix = token.suffix
- tag_mark = token.start_mark
- end_mark = token.end_mark
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- }
- } else if token.typ == yaml_TAG_TOKEN {
- tag_token = true
- tag_handle = token.value
- tag_suffix = token.suffix
- start_mark = token.start_mark
- tag_mark = token.start_mark
- end_mark = token.end_mark
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ == yaml_ANCHOR_TOKEN {
- anchor = token.value
- end_mark = token.end_mark
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- }
- }
-
- var tag []byte
- if tag_token {
- if len(tag_handle) == 0 {
- tag = tag_suffix
- tag_suffix = nil
- } else {
- for i := range parser.tag_directives {
- if bytes.Equal(parser.tag_directives[i].handle, tag_handle) {
- tag = append([]byte(nil), parser.tag_directives[i].prefix...)
- tag = append(tag, tag_suffix...)
- break
- }
- }
- if len(tag) == 0 {
- yaml_parser_set_parser_error_context(parser,
- "while parsing a node", start_mark,
- "found undefined tag handle", tag_mark)
- return false
- }
- }
- }
-
- implicit := len(tag) == 0
- if indentless_sequence && token.typ == yaml_BLOCK_ENTRY_TOKEN {
- end_mark = token.end_mark
- parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_START_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE),
- }
- return true
- }
- if token.typ == yaml_SCALAR_TOKEN {
- var plain_implicit, quoted_implicit bool
- end_mark = token.end_mark
- if (len(tag) == 0 && token.style == yaml_PLAIN_SCALAR_STYLE) || (len(tag) == 1 && tag[0] == '!') {
- plain_implicit = true
- } else if len(tag) == 0 {
- quoted_implicit = true
- }
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
-
- *event = yaml_event_t{
- typ: yaml_SCALAR_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- anchor: anchor,
- tag: tag,
- value: token.value,
- implicit: plain_implicit,
- quoted_implicit: quoted_implicit,
- style: yaml_style_t(token.style),
- }
- skip_token(parser)
- return true
- }
- if token.typ == yaml_FLOW_SEQUENCE_START_TOKEN {
- // [Go] Some of the events below can be merged as they differ only on style.
- end_mark = token.end_mark
- parser.state = yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_START_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- style: yaml_style_t(yaml_FLOW_SEQUENCE_STYLE),
- }
- return true
- }
- if token.typ == yaml_FLOW_MAPPING_START_TOKEN {
- end_mark = token.end_mark
- parser.state = yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE
- *event = yaml_event_t{
- typ: yaml_MAPPING_START_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- style: yaml_style_t(yaml_FLOW_MAPPING_STYLE),
- }
- return true
- }
- if block && token.typ == yaml_BLOCK_SEQUENCE_START_TOKEN {
- end_mark = token.end_mark
- parser.state = yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_START_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE),
- }
- return true
- }
- if block && token.typ == yaml_BLOCK_MAPPING_START_TOKEN {
- end_mark = token.end_mark
- parser.state = yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE
- *event = yaml_event_t{
- typ: yaml_MAPPING_START_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- style: yaml_style_t(yaml_BLOCK_MAPPING_STYLE),
- }
- return true
- }
- if len(anchor) > 0 || len(tag) > 0 {
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
-
- *event = yaml_event_t{
- typ: yaml_SCALAR_EVENT,
- start_mark: start_mark,
- end_mark: end_mark,
- anchor: anchor,
- tag: tag,
- implicit: implicit,
- quoted_implicit: false,
- style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE),
- }
- return true
- }
-
- context := "while parsing a flow node"
- if block {
- context = "while parsing a block node"
- }
- yaml_parser_set_parser_error_context(parser, context, start_mark,
- "did not find expected node content", token.start_mark)
- return false
-}
-
-// Parse the productions:
-// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END
-// ******************** *********** * *********
-//
-func yaml_parser_parse_block_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool {
- if first {
- token := peek_token(parser)
- parser.marks = append(parser.marks, token.start_mark)
- skip_token(parser)
- }
-
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- if token.typ == yaml_BLOCK_ENTRY_TOKEN {
- mark := token.end_mark
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_BLOCK_ENTRY_TOKEN && token.typ != yaml_BLOCK_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE)
- return yaml_parser_parse_node(parser, event, true, false)
- } else {
- parser.state = yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE
- return yaml_parser_process_empty_scalar(parser, event, mark)
- }
- }
- if token.typ == yaml_BLOCK_END_TOKEN {
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
-
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_END_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- }
-
- skip_token(parser)
- return true
- }
-
- context_mark := parser.marks[len(parser.marks)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
- return yaml_parser_set_parser_error_context(parser,
- "while parsing a block collection", context_mark,
- "did not find expected '-' indicator", token.start_mark)
-}
-
-// Parse the productions:
-// indentless_sequence ::= (BLOCK-ENTRY block_node?)+
-// *********** *
-func yaml_parser_parse_indentless_sequence_entry(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- if token.typ == yaml_BLOCK_ENTRY_TOKEN {
- mark := token.end_mark
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_BLOCK_ENTRY_TOKEN &&
- token.typ != yaml_KEY_TOKEN &&
- token.typ != yaml_VALUE_TOKEN &&
- token.typ != yaml_BLOCK_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE)
- return yaml_parser_parse_node(parser, event, true, false)
- }
- parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE
- return yaml_parser_process_empty_scalar(parser, event, mark)
- }
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
-
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_END_EVENT,
- start_mark: token.start_mark,
- end_mark: token.start_mark, // [Go] Shouldn't this be token.end_mark?
- }
- return true
-}
-
-// Parse the productions:
-// block_mapping ::= BLOCK-MAPPING_START
-// *******************
-// ((KEY block_node_or_indentless_sequence?)?
-// *** *
-// (VALUE block_node_or_indentless_sequence?)?)*
-//
-// BLOCK-END
-// *********
-//
-func yaml_parser_parse_block_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool {
- if first {
- token := peek_token(parser)
- parser.marks = append(parser.marks, token.start_mark)
- skip_token(parser)
- }
-
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- if token.typ == yaml_KEY_TOKEN {
- mark := token.end_mark
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_KEY_TOKEN &&
- token.typ != yaml_VALUE_TOKEN &&
- token.typ != yaml_BLOCK_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_VALUE_STATE)
- return yaml_parser_parse_node(parser, event, true, true)
- } else {
- parser.state = yaml_PARSE_BLOCK_MAPPING_VALUE_STATE
- return yaml_parser_process_empty_scalar(parser, event, mark)
- }
- } else if token.typ == yaml_BLOCK_END_TOKEN {
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
- *event = yaml_event_t{
- typ: yaml_MAPPING_END_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- }
- skip_token(parser)
- return true
- }
-
- context_mark := parser.marks[len(parser.marks)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
- return yaml_parser_set_parser_error_context(parser,
- "while parsing a block mapping", context_mark,
- "did not find expected key", token.start_mark)
-}
-
-// Parse the productions:
-// block_mapping ::= BLOCK-MAPPING_START
-//
-// ((KEY block_node_or_indentless_sequence?)?
-//
-// (VALUE block_node_or_indentless_sequence?)?)*
-// ***** *
-// BLOCK-END
-//
-//
-func yaml_parser_parse_block_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ == yaml_VALUE_TOKEN {
- mark := token.end_mark
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_KEY_TOKEN &&
- token.typ != yaml_VALUE_TOKEN &&
- token.typ != yaml_BLOCK_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_KEY_STATE)
- return yaml_parser_parse_node(parser, event, true, true)
- }
- parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE
- return yaml_parser_process_empty_scalar(parser, event, mark)
- }
- parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE
- return yaml_parser_process_empty_scalar(parser, event, token.start_mark)
-}
-
-// Parse the productions:
-// flow_sequence ::= FLOW-SEQUENCE-START
-// *******************
-// (flow_sequence_entry FLOW-ENTRY)*
-// * **********
-// flow_sequence_entry?
-// *
-// FLOW-SEQUENCE-END
-// *****************
-// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-// *
-//
-func yaml_parser_parse_flow_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool {
- if first {
- token := peek_token(parser)
- parser.marks = append(parser.marks, token.start_mark)
- skip_token(parser)
- }
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN {
- if !first {
- if token.typ == yaml_FLOW_ENTRY_TOKEN {
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- } else {
- context_mark := parser.marks[len(parser.marks)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
- return yaml_parser_set_parser_error_context(parser,
- "while parsing a flow sequence", context_mark,
- "did not find expected ',' or ']'", token.start_mark)
- }
- }
-
- if token.typ == yaml_KEY_TOKEN {
- parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE
- *event = yaml_event_t{
- typ: yaml_MAPPING_START_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- implicit: true,
- style: yaml_style_t(yaml_FLOW_MAPPING_STYLE),
- }
- skip_token(parser)
- return true
- } else if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE)
- return yaml_parser_parse_node(parser, event, false, false)
- }
- }
-
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
-
- *event = yaml_event_t{
- typ: yaml_SEQUENCE_END_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- }
-
- skip_token(parser)
- return true
-}
-
-//
-// Parse the productions:
-// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-// *** *
-//
-func yaml_parser_parse_flow_sequence_entry_mapping_key(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_VALUE_TOKEN &&
- token.typ != yaml_FLOW_ENTRY_TOKEN &&
- token.typ != yaml_FLOW_SEQUENCE_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE)
- return yaml_parser_parse_node(parser, event, false, false)
- }
- mark := token.end_mark
- skip_token(parser)
- parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE
- return yaml_parser_process_empty_scalar(parser, event, mark)
-}
-
-// Parse the productions:
-// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-// ***** *
-//
-func yaml_parser_parse_flow_sequence_entry_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ == yaml_VALUE_TOKEN {
- skip_token(parser)
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_SEQUENCE_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE)
- return yaml_parser_parse_node(parser, event, false, false)
- }
- }
- parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE
- return yaml_parser_process_empty_scalar(parser, event, token.start_mark)
-}
-
-// Parse the productions:
-// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-// *
-//
-func yaml_parser_parse_flow_sequence_entry_mapping_end(parser *yaml_parser_t, event *yaml_event_t) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE
- *event = yaml_event_t{
- typ: yaml_MAPPING_END_EVENT,
- start_mark: token.start_mark,
- end_mark: token.start_mark, // [Go] Shouldn't this be end_mark?
- }
- return true
-}
-
-// Parse the productions:
-// flow_mapping ::= FLOW-MAPPING-START
-// ******************
-// (flow_mapping_entry FLOW-ENTRY)*
-// * **********
-// flow_mapping_entry?
-// ******************
-// FLOW-MAPPING-END
-// ****************
-// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-// * *** *
-//
-func yaml_parser_parse_flow_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool {
- if first {
- token := peek_token(parser)
- parser.marks = append(parser.marks, token.start_mark)
- skip_token(parser)
- }
-
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- if token.typ != yaml_FLOW_MAPPING_END_TOKEN {
- if !first {
- if token.typ == yaml_FLOW_ENTRY_TOKEN {
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- } else {
- context_mark := parser.marks[len(parser.marks)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
- return yaml_parser_set_parser_error_context(parser,
- "while parsing a flow mapping", context_mark,
- "did not find expected ',' or '}'", token.start_mark)
- }
- }
-
- if token.typ == yaml_KEY_TOKEN {
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_VALUE_TOKEN &&
- token.typ != yaml_FLOW_ENTRY_TOKEN &&
- token.typ != yaml_FLOW_MAPPING_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_VALUE_STATE)
- return yaml_parser_parse_node(parser, event, false, false)
- } else {
- parser.state = yaml_PARSE_FLOW_MAPPING_VALUE_STATE
- return yaml_parser_process_empty_scalar(parser, event, token.start_mark)
- }
- } else if token.typ != yaml_FLOW_MAPPING_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE)
- return yaml_parser_parse_node(parser, event, false, false)
- }
- }
-
- parser.state = parser.states[len(parser.states)-1]
- parser.states = parser.states[:len(parser.states)-1]
- parser.marks = parser.marks[:len(parser.marks)-1]
- *event = yaml_event_t{
- typ: yaml_MAPPING_END_EVENT,
- start_mark: token.start_mark,
- end_mark: token.end_mark,
- }
- skip_token(parser)
- return true
-}
-
-// Parse the productions:
-// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-// * ***** *
-//
-func yaml_parser_parse_flow_mapping_value(parser *yaml_parser_t, event *yaml_event_t, empty bool) bool {
- token := peek_token(parser)
- if token == nil {
- return false
- }
- if empty {
- parser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE
- return yaml_parser_process_empty_scalar(parser, event, token.start_mark)
- }
- if token.typ == yaml_VALUE_TOKEN {
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- if token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_MAPPING_END_TOKEN {
- parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_KEY_STATE)
- return yaml_parser_parse_node(parser, event, false, false)
- }
- }
- parser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE
- return yaml_parser_process_empty_scalar(parser, event, token.start_mark)
-}
-
-// Generate an empty scalar event.
-func yaml_parser_process_empty_scalar(parser *yaml_parser_t, event *yaml_event_t, mark yaml_mark_t) bool {
- *event = yaml_event_t{
- typ: yaml_SCALAR_EVENT,
- start_mark: mark,
- end_mark: mark,
- value: nil, // Empty
- implicit: true,
- style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE),
- }
- return true
-}
-
-var default_tag_directives = []yaml_tag_directive_t{
- {[]byte("!"), []byte("!")},
- {[]byte("!!"), []byte("tag:yaml.org,2002:")},
-}
-
-// Parse directives.
-func yaml_parser_process_directives(parser *yaml_parser_t,
- version_directive_ref **yaml_version_directive_t,
- tag_directives_ref *[]yaml_tag_directive_t) bool {
-
- var version_directive *yaml_version_directive_t
- var tag_directives []yaml_tag_directive_t
-
- token := peek_token(parser)
- if token == nil {
- return false
- }
-
- for token.typ == yaml_VERSION_DIRECTIVE_TOKEN || token.typ == yaml_TAG_DIRECTIVE_TOKEN {
- if token.typ == yaml_VERSION_DIRECTIVE_TOKEN {
- if version_directive != nil {
- yaml_parser_set_parser_error(parser,
- "found duplicate %YAML directive", token.start_mark)
- return false
- }
- if token.major != 1 || token.minor != 1 {
- yaml_parser_set_parser_error(parser,
- "found incompatible YAML document", token.start_mark)
- return false
- }
- version_directive = &yaml_version_directive_t{
- major: token.major,
- minor: token.minor,
- }
- } else if token.typ == yaml_TAG_DIRECTIVE_TOKEN {
- value := yaml_tag_directive_t{
- handle: token.value,
- prefix: token.prefix,
- }
- if !yaml_parser_append_tag_directive(parser, value, false, token.start_mark) {
- return false
- }
- tag_directives = append(tag_directives, value)
- }
-
- skip_token(parser)
- token = peek_token(parser)
- if token == nil {
- return false
- }
- }
-
- for i := range default_tag_directives {
- if !yaml_parser_append_tag_directive(parser, default_tag_directives[i], true, token.start_mark) {
- return false
- }
- }
-
- if version_directive_ref != nil {
- *version_directive_ref = version_directive
- }
- if tag_directives_ref != nil {
- *tag_directives_ref = tag_directives
- }
- return true
-}
-
-// Append a tag directive to the directives stack.
-func yaml_parser_append_tag_directive(parser *yaml_parser_t, value yaml_tag_directive_t, allow_duplicates bool, mark yaml_mark_t) bool {
- for i := range parser.tag_directives {
- if bytes.Equal(value.handle, parser.tag_directives[i].handle) {
- if allow_duplicates {
- return true
- }
- return yaml_parser_set_parser_error(parser, "found duplicate %TAG directive", mark)
- }
- }
-
- // [Go] I suspect the copy is unnecessary. This was likely done
- // because there was no way to track ownership of the data.
- value_copy := yaml_tag_directive_t{
- handle: make([]byte, len(value.handle)),
- prefix: make([]byte, len(value.prefix)),
- }
- copy(value_copy.handle, value.handle)
- copy(value_copy.prefix, value.prefix)
- parser.tag_directives = append(parser.tag_directives, value_copy)
- return true
-}
diff --git a/newt/vendor/mynewt.apache.org/newt/yaml/readerc.go b/newt/vendor/mynewt.apache.org/newt/yaml/readerc.go
deleted file mode 100644
index eaf59074..00000000
--- a/newt/vendor/mynewt.apache.org/newt/yaml/readerc.go
+++ /dev/null
@@ -1,419 +0,0 @@
-/**
- * This file is a Go port of its corresponding C file in libyaml. This port
- * was was copied from the yaml.v2 library. This file is licensed as follows:
- *
- * Copyright (c) 2006 Kirill Simonov
- *
- * 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.
- */
-
-package yaml
-
-import (
- "io"
-)
-
-// Set the reader error and return 0.
-func yaml_parser_set_reader_error(parser *yaml_parser_t, problem string, offset int, value int) bool {
- parser.error = yaml_READER_ERROR
- parser.problem = problem
- parser.problem_offset = offset
- parser.problem_value = value
- return false
-}
-
-// Byte order marks.
-const (
- bom_UTF8 = "\xef\xbb\xbf"
- bom_UTF16LE = "\xff\xfe"
- bom_UTF16BE = "\xfe\xff"
-)
-
-// Determine the input stream encoding by checking the BOM symbol. If no BOM is
-// found, the UTF-8 encoding is assumed. Return 1 on success, 0 on failure.
-func yaml_parser_determine_encoding(parser *yaml_parser_t) bool {
- // Ensure that we had enough bytes in the raw buffer.
- for !parser.eof && len(parser.raw_buffer)-parser.raw_buffer_pos < 3 {
- if !yaml_parser_update_raw_buffer(parser) {
- return false
- }
- }
-
- // Determine the encoding.
- buf := parser.raw_buffer
- pos := parser.raw_buffer_pos
- avail := len(buf) - pos
- if avail >= 2 && buf[pos] == bom_UTF16LE[0] && buf[pos+1] == bom_UTF16LE[1] {
- parser.encoding = yaml_UTF16LE_ENCODING
- parser.raw_buffer_pos += 2
- parser.offset += 2
- } else if avail >= 2 && buf[pos] == bom_UTF16BE[0] && buf[pos+1] == bom_UTF16BE[1] {
- parser.encoding = yaml_UTF16BE_ENCODING
- parser.raw_buffer_pos += 2
- parser.offset += 2
- } else if avail >= 3 && buf[pos] == bom_UTF8[0] && buf[pos+1] == bom_UTF8[1] && buf[pos+2] == bom_UTF8[2] {
- parser.encoding = yaml_UTF8_ENCODING
- parser.raw_buffer_pos += 3
- parser.offset += 3
- } else {
- parser.encoding = yaml_UTF8_ENCODING
- }
- return true
-}
-
-// Update the raw buffer.
-func yaml_parser_update_raw_buffer(parser *yaml_parser_t) bool {
- size_read := 0
-
- // Return if the raw buffer is full.
- if parser.raw_buffer_pos == 0 && len(parser.raw_buffer) == cap(parser.raw_buffer) {
- return true
- }
-
- // Return on EOF.
- if parser.eof {
- return true
- }
-
- // Move the remaining bytes in the raw buffer to the beginning.
- if parser.raw_buffer_pos > 0 && parser.raw_buffer_pos < len(parser.raw_buffer) {
- copy(parser.raw_buffer, parser.raw_buffer[parser.raw_buffer_pos:])
- }
- parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)-parser.raw_buffer_pos]
- parser.raw_buffer_pos = 0
-
- // Call the read handler to fill the buffer.
- size_read, err := parser.read_handler(parser, parser.raw_buffer[len(parser.raw_buffer):cap(parser.raw_buffer)])
- parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)+size_read]
- if err == io.EOF {
- parser.eof = true
- } else if err != nil {
- return yaml_parser_set_reader_error(parser, "input error: "+err.Error(), parser.offset, -1)
- }
- return true
-}
-
-// Ensure that the buffer contains at least `length` characters.
-// Return true on success, false on failure.
-//
-// The length is supposed to be significantly less that the buffer size.
-func yaml_parser_update_buffer(parser *yaml_parser_t, length int) bool {
- if parser.read_handler == nil {
- panic("read handler must be set")
- }
-
- // If the EOF flag is set and the raw buffer is empty, do nothing.
- if parser.eof && parser.raw_buffer_pos == len(parser.raw_buffer) {
- return true
- }
-
- // Return if the buffer contains enough characters.
- if parser.unread >= length {
- return true
- }
-
- // Determine the input encoding if it is not known yet.
- if parser.encoding == yaml_ANY_ENCODING {
- if !yaml_parser_determine_encoding(parser) {
- return false
- }
- }
-
- // Move the unread characters to the beginning of the buffer.
- buffer_len := len(parser.buffer)
- if parser.buffer_pos > 0 && parser.buffer_pos < buffer_len {
- copy(parser.buffer, parser.buffer[parser.buffer_pos:])
- buffer_len -= parser.buffer_pos
- parser.buffer_pos = 0
- } else if parser.buffer_pos == buffer_len {
- buffer_len = 0
- parser.buffer_pos = 0
- }
-
- // Open the whole buffer for writing, and cut it before returning.
- parser.buffer = parser.buffer[:cap(parser.buffer)]
-
- // Fill the buffer until it has enough characters.
- first := true
- for parser.unread < length {
-
- // Fill the raw buffer if necessary.
- if !first || parser.raw_buffer_pos == len(parser.raw_buffer) {
- if !yaml_parser_update_raw_buffer(parser) {
- parser.buffer = parser.buffer[:buffer_len]
- return false
- }
- }
- first = false
-
- // Decode the raw buffer.
- inner:
- for parser.raw_buffer_pos != len(parser.raw_buffer) {
- var value rune
- var width int
-
- raw_unread := len(parser.raw_buffer) - parser.raw_buffer_pos
-
- // Decode the next character.
- switch parser.encoding {
- case yaml_UTF8_ENCODING:
- // Decode a UTF-8 character. Check RFC 3629
- // (http://www.ietf.org/rfc/rfc3629.txt) for more details.
- //
- // The following table (taken from the RFC) is used for
- // decoding.
- //
- // Char. number range | UTF-8 octet sequence
- // (hexadecimal) | (binary)
- // --------------------+------------------------------------
- // 0000 0000-0000 007F | 0xxxxxxx
- // 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
- // 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
- // 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- //
- // Additionally, the characters in the range 0xD800-0xDFFF
- // are prohibited as they are reserved for use with UTF-16
- // surrogate pairs.
-
- // Determine the length of the UTF-8 sequence.
- octet := parser.raw_buffer[parser.raw_buffer_pos]
- switch {
- case octet&0x80 == 0x00:
- width = 1
- case octet&0xE0 == 0xC0:
- width = 2
- case octet&0xF0 == 0xE0:
- width = 3
- case octet&0xF8 == 0xF0:
- width = 4
- default:
- // The leading octet is invalid.
- return yaml_parser_set_reader_error(parser,
- "invalid leading UTF-8 octet",
- parser.offset, int(octet))
- }
-
- // Check if the raw buffer contains an incomplete character.
- if width > raw_unread {
- if parser.eof {
- return yaml_parser_set_reader_error(parser,
- "incomplete UTF-8 octet sequence",
- parser.offset, -1)
- }
- break inner
- }
-
- // Decode the leading octet.
- switch {
- case octet&0x80 == 0x00:
- value = rune(octet & 0x7F)
- case octet&0xE0 == 0xC0:
- value = rune(octet & 0x1F)
- case octet&0xF0 == 0xE0:
- value = rune(octet & 0x0F)
- case octet&0xF8 == 0xF0:
- value = rune(octet & 0x07)
- default:
- value = 0
- }
-
- // Check and decode the trailing octets.
- for k := 1; k < width; k++ {
- octet = parser.raw_buffer[parser.raw_buffer_pos+k]
-
- // Check if the octet is valid.
- if (octet & 0xC0) != 0x80 {
- return yaml_parser_set_reader_error(parser,
- "invalid trailing UTF-8 octet",
- parser.offset+k, int(octet))
- }
-
- // Decode the octet.
- value = (value << 6) + rune(octet&0x3F)
- }
-
- // Check the length of the sequence against the value.
- switch {
- case width == 1:
- case width == 2 && value >= 0x80:
- case width == 3 && value >= 0x800:
- case width == 4 && value >= 0x10000:
- default:
- return yaml_parser_set_reader_error(parser,
- "invalid length of a UTF-8 sequence",
- parser.offset, -1)
- }
-
- // Check the range of the value.
- if value >= 0xD800 && value <= 0xDFFF || value > 0x10FFFF {
- return yaml_parser_set_reader_error(parser,
- "invalid Unicode character",
- parser.offset, int(value))
- }
-
- case yaml_UTF16LE_ENCODING, yaml_UTF16BE_ENCODING:
- var low, high int
- if parser.encoding == yaml_UTF16LE_ENCODING {
- low, high = 0, 1
- } else {
- low, high = 1, 0
- }
-
- // The UTF-16 encoding is not as simple as one might
- // naively think. Check RFC 2781
- // (http://www.ietf.org/rfc/rfc2781.txt).
- //
- // Normally, two subsequent bytes describe a Unicode
- // character. However a special technique (called a
- // surrogate pair) is used for specifying character
- // values larger than 0xFFFF.
- //
- // A surrogate pair consists of two pseudo-characters:
- // high surrogate area (0xD800-0xDBFF)
- // low surrogate area (0xDC00-0xDFFF)
- //
- // The following formulas are used for decoding
- // and encoding characters using surrogate pairs:
- //
- // U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF)
- // U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF)
- // W1 = 110110yyyyyyyyyy
- // W2 = 110111xxxxxxxxxx
- //
- // where U is the character value, W1 is the high surrogate
- // area, W2 is the low surrogate area.
-
- // Check for incomplete UTF-16 character.
- if raw_unread < 2 {
- if parser.eof {
- return yaml_parser_set_reader_error(parser,
- "incomplete UTF-16 character",
- parser.offset, -1)
- }
- break inner
- }
-
- // Get the character.
- value = rune(parser.raw_buffer[parser.raw_buffer_pos+low]) +
- (rune(parser.raw_buffer[parser.raw_buffer_pos+high]) << 8)
-
- // Check for unexpected low surrogate area.
- if value&0xFC00 == 0xDC00 {
- return yaml_parser_set_reader_error(parser,
- "unexpected low surrogate area",
- parser.offset, int(value))
- }
-
- // Check for a high surrogate area.
- if value&0xFC00 == 0xD800 {
- width = 4
-
- // Check for incomplete surrogate pair.
- if raw_unread < 4 {
- if parser.eof {
- return yaml_parser_set_reader_error(parser,
- "incomplete UTF-16 surrogate pair",
- parser.offset, -1)
- }
- break inner
- }
-
- // Get the next character.
- value2 := rune(parser.raw_buffer[parser.raw_buffer_pos+low+2]) +
- (rune(parser.raw_buffer[parser.raw_buffer_pos+high+2]) << 8)
-
- // Check for a low surrogate area.
- if value2&0xFC00 != 0xDC00 {
- return yaml_parser_set_reader_error(parser,
- "expected low surrogate area",
- parser.offset+2, int(value2))
- }
-
- // Generate the value of the surrogate pair.
- value = 0x10000 + ((value & 0x3FF) << 10) + (value2 & 0x3FF)
- } else {
- width = 2
- }
-
- default:
- panic("impossible")
- }
-
- // Check if the character is in the allowed range:
- // #x9 | #xA | #xD | [#x20-#x7E] (8 bit)
- // | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD] (16 bit)
- // | [#x10000-#x10FFFF] (32 bit)
- switch {
- case value == 0x09:
- case value == 0x0A:
- case value == 0x0D:
- case value >= 0x20 && value <= 0x7E:
- case value == 0x85:
- case value >= 0xA0 && value <= 0xD7FF:
- case value >= 0xE000 && value <= 0xFFFD:
- case value >= 0x10000 && value <= 0x10FFFF:
- default:
- return yaml_parser_set_reader_error(parser,
- "control characters are not allowed",
- parser.offset, int(value))
- }
-
- // Move the raw pointers.
- parser.raw_buffer_pos += width
- parser.offset += width
-
- // Finally put the character into the buffer.
- if value <= 0x7F {
- // 0000 0000-0000 007F . 0xxxxxxx
- parser.buffer[buffer_len+0] = byte(value)
- buffer_len += 1
- } else if value <= 0x7FF {
- // 0000 0080-0000 07FF . 110xxxxx 10xxxxxx
- parser.buffer[buffer_len+0] = byte(0xC0 + (value >> 6))
- parser.buffer[buffer_len+1] = byte(0x80 + (value & 0x3F))
- buffer_len += 2
- } else if value <= 0xFFFF {
- // 0000 0800-0000 FFFF . 1110xxxx 10xxxxxx 10xxxxxx
- parser.buffer[buffer_len+0] = byte(0xE0 + (value >> 12))
- parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 6) & 0x3F))
- parser.buffer[buffer_len+2] = byte(0x80 + (value & 0x3F))
- buffer_len += 3
- } else {
- // 0001 0000-0010 FFFF . 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- parser.buffer[buffer_len+0] = byte(0xF0 + (value >> 18))
- parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 12) & 0x3F))
- parser.buffer[buffer_len+2] = byte(0x80 + ((value >> 6) & 0x3F))
- parser.buffer[buffer_len+3] = byte(0x80 + (value & 0x3F))
- buffer_len += 4
- }
-
- parser.unread++
- }
-
- // On EOF, put NUL into the buffer and return.
- if parser.eof {
- parser.buffer[buffer_len] = 0
- buffer_len++
- parser.unread++
- break
- }
- }
- parser.buffer = parser.buffer[:buffer_len]
- return true
-}
diff --git a/newt/vendor/mynewt.apache.org/newt/yaml/scannerc.go b/newt/vendor/mynewt.apache.org/newt/yaml/scannerc.go
deleted file mode 100644
index 0413a0d0..00000000
--- a/newt/vendor/mynewt.apache.org/newt/yaml/scannerc.go
+++ /dev/null
@@ -1,2735 +0,0 @@
-/**
- * This file is a Go port of its corresponding C file in libyaml. This port
- * was was copied from the yaml.v2 library. This file is licensed as follows:
- *
- * Copyright (c) 2006 Kirill Simonov
- *
- * 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.
- */
-
-package yaml
-
-import (
- "bytes"
- "fmt"
-)
-
-// Introduction
-// ************
-//
-// The following notes assume that you are familiar with the YAML specification
-// (http://yaml.org/spec/cvs/current.html). We mostly follow it, although in
-// some cases we are less restrictive that it requires.
-//
-// The process of transforming a YAML stream into a sequence of events is
-// divided on two steps: Scanning and Parsing.
-//
-// The Scanner transforms the input stream into a sequence of tokens, while the
-// parser transform the sequence of tokens produced by the Scanner into a
-// sequence of parsing events.
-//
-// The Scanner is rather clever and complicated. The Parser, on the contrary,
-// is a straightforward implementation of a recursive-descendant parser (or,
-// LL(1) parser, as it is usually called).
-//
-// Actually there are two issues of Scanning that might be called "clever", the
-// rest is quite straightforward. The issues are "block collection start" and
-// "simple keys". Both issues are explained below in details.
-//
-// Here the Scanning step is explained and implemented. We start with the list
-// of all the tokens produced by the Scanner together with short descriptions.
-//
-// Now, tokens:
-//
-// STREAM-START(encoding) # The stream start.
-// STREAM-END # The stream end.
-// VERSION-DIRECTIVE(major,minor) # The '%YAML' directive.
-// TAG-DIRECTIVE(handle,prefix) # The '%TAG' directive.
-// DOCUMENT-START # '---'
-// DOCUMENT-END # '...'
-// BLOCK-SEQUENCE-START # Indentation increase denoting a block
-// BLOCK-MAPPING-START # sequence or a block mapping.
-// BLOCK-END # Indentation decrease.
-// FLOW-SEQUENCE-START # '['
-// FLOW-SEQUENCE-END # ']'
-// BLOCK-SEQUENCE-START # '{'
-// BLOCK-SEQUENCE-END # '}'
-// BLOCK-ENTRY # '-'
-// FLOW-ENTRY # ','
-// KEY # '?' or nothing (simple keys).
-// VALUE # ':'
-// ALIAS(anchor) # '*anchor'
-// ANCHOR(anchor) # '&anchor'
-// TAG(handle,suffix) # '!handle!suffix'
-// SCALAR(value,style) # A scalar.
-//
-// The following two tokens are "virtual" tokens denoting the beginning and the
-// end of the stream:
-//
-// STREAM-START(encoding)
-// STREAM-END
-//
-// We pass the information about the input stream encoding with the
-// STREAM-START token.
-//
-// The next two tokens are responsible for tags:
-//
-// VERSION-DIRECTIVE(major,minor)
-// TAG-DIRECTIVE(handle,prefix)
-//
-// Example:
-//
-// %YAML 1.1
-// %TAG ! !foo
-// %TAG !yaml! tag:yaml.org,2002:
-// ---
-//
-// The correspoding sequence of tokens:
-//
-// STREAM-START(utf-8)
-// VERSION-DIRECTIVE(1,1)
-// TAG-DIRECTIVE("!","!foo")
-// TAG-DIRECTIVE("!yaml","tag:yaml.org,2002:")
-// DOCUMENT-START
-// STREAM-END
-//
-// Note that the VERSION-DIRECTIVE and TAG-DIRECTIVE tokens occupy a whole
-// line.
-//
-// The document start and end indicators are represented by:
-//
-// DOCUMENT-START
-// DOCUMENT-END
-//
-// Note that if a YAML stream contains an implicit document (without '---'
-// and '...' indicators), no DOCUMENT-START and DOCUMENT-END tokens will be
-// produced.
-//
-// In the following examples, we present whole documents together with the
-// produced tokens.
-//
-// 1. An implicit document:
-//
-// 'a scalar'
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// SCALAR("a scalar",single-quoted)
-// STREAM-END
-//
-// 2. An explicit document:
-//
-// ---
-// 'a scalar'
-// ...
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// DOCUMENT-START
-// SCALAR("a scalar",single-quoted)
-// DOCUMENT-END
-// STREAM-END
-//
-// 3. Several documents in a stream:
-//
-// 'a scalar'
-// ---
-// 'another scalar'
-// ---
-// 'yet another scalar'
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// SCALAR("a scalar",single-quoted)
-// DOCUMENT-START
-// SCALAR("another scalar",single-quoted)
-// DOCUMENT-START
-// SCALAR("yet another scalar",single-quoted)
-// STREAM-END
-//
-// We have already introduced the SCALAR token above. The following tokens are
-// used to describe aliases, anchors, tag, and scalars:
-//
-// ALIAS(anchor)
-// ANCHOR(anchor)
-// TAG(handle,suffix)
-// SCALAR(value,style)
-//
-// The following series of examples illustrate the usage of these tokens:
-//
-// 1. A recursive sequence:
-//
-// &A [ *A ]
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// ANCHOR("A")
-// FLOW-SEQUENCE-START
-// ALIAS("A")
-// FLOW-SEQUENCE-END
-// STREAM-END
-//
-// 2. A tagged scalar:
-//
-// !!float "3.14" # A good approximation.
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// TAG("!!","float")
-// SCALAR("3.14",double-quoted)
-// STREAM-END
-//
-// 3. Various scalar styles:
-//
-// --- # Implicit empty plain scalars do not produce tokens.
-// --- a plain scalar
-// --- 'a single-quoted scalar'
-// --- "a double-quoted scalar"
-// --- |-
-// a literal scalar
-// --- >-
-// a folded
-// scalar
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// DOCUMENT-START
-// DOCUMENT-START
-// SCALAR("a plain scalar",plain)
-// DOCUMENT-START
-// SCALAR("a single-quoted scalar",single-quoted)
-// DOCUMENT-START
-// SCALAR("a double-quoted scalar",double-quoted)
-// DOCUMENT-START
-// SCALAR("a literal scalar",literal)
-// DOCUMENT-START
-// SCALAR("a folded scalar",folded)
-// STREAM-END
-//
-// Now it's time to review collection-related tokens. We will start with
-// flow collections:
-//
-// FLOW-SEQUENCE-START
-// FLOW-SEQUENCE-END
-// FLOW-MAPPING-START
-// FLOW-MAPPING-END
-// FLOW-ENTRY
-// KEY
-// VALUE
-//
-// The tokens FLOW-SEQUENCE-START, FLOW-SEQUENCE-END, FLOW-MAPPING-START, and
-// FLOW-MAPPING-END represent the indicators '[', ']', '{', and '}'
-// correspondingly. FLOW-ENTRY represent the ',' indicator. Finally the
-// indicators '?' and ':', which are used for denoting mapping keys and values,
-// are represented by the KEY and VALUE tokens.
-//
-// The following examples show flow collections:
-//
-// 1. A flow sequence:
-//
-// [item 1, item 2, item 3]
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// FLOW-SEQUENCE-START
-// SCALAR("item 1",plain)
-// FLOW-ENTRY
-// SCALAR("item 2",plain)
-// FLOW-ENTRY
-// SCALAR("item 3",plain)
-// FLOW-SEQUENCE-END
-// STREAM-END
-//
-// 2. A flow mapping:
-//
-// {
-// a simple key: a value, # Note that the KEY token is produced.
-// ? a complex key: another value,
-// }
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// FLOW-MAPPING-START
-// KEY
-// SCALAR("a simple key",plain)
-// VALUE
-// SCALAR("a value",plain)
-// FLOW-ENTRY
-// KEY
-// SCALAR("a complex key",plain)
-// VALUE
-// SCALAR("another value",plain)
-// FLOW-ENTRY
-// FLOW-MAPPING-END
-// STREAM-END
-//
-// A simple key is a key which is not denoted by the '?' indicator. Note that
-// the Scanner still produce the KEY token whenever it encounters a simple key.
-//
-// For scanning block collections, the following tokens are used (note that we
-// repeat KEY and VALUE here):
-//
-// BLOCK-SEQUENCE-START
-// BLOCK-MAPPING-START
-// BLOCK-END
-// BLOCK-ENTRY
-// KEY
-// VALUE
-//
-// The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation
-// increase that precedes a block collection (cf. the INDENT token in Python).
-// The token BLOCK-END denote indentation decrease that ends a block collection
-// (cf. the DEDENT token in Python). However YAML has some syntax pecularities
-// that makes detections of these tokens more complex.
-//
-// The tokens BLOCK-ENTRY, KEY, and VALUE are used to represent the indicators
-// '-', '?', and ':' correspondingly.
-//
-// The following examples show how the tokens BLOCK-SEQUENCE-START,
-// BLOCK-MAPPING-START, and BLOCK-END are emitted by the Scanner:
-//
-// 1. Block sequences:
-//
-// - item 1
-// - item 2
-// -
-// - item 3.1
-// - item 3.2
-// -
-// key 1: value 1
-// key 2: value 2
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// BLOCK-SEQUENCE-START
-// BLOCK-ENTRY
-// SCALAR("item 1",plain)
-// BLOCK-ENTRY
-// SCALAR("item 2",plain)
-// BLOCK-ENTRY
-// BLOCK-SEQUENCE-START
-// BLOCK-ENTRY
-// SCALAR("item 3.1",plain)
-// BLOCK-ENTRY
-// SCALAR("item 3.2",plain)
-// BLOCK-END
-// BLOCK-ENTRY
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("key 1",plain)
-// VALUE
-// SCALAR("value 1",plain)
-// KEY
-// SCALAR("key 2",plain)
-// VALUE
-// SCALAR("value 2",plain)
-// BLOCK-END
-// BLOCK-END
-// STREAM-END
-//
-// 2. Block mappings:
-//
-// a simple key: a value # The KEY token is produced here.
-// ? a complex key
-// : another value
-// a mapping:
-// key 1: value 1
-// key 2: value 2
-// a sequence:
-// - item 1
-// - item 2
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("a simple key",plain)
-// VALUE
-// SCALAR("a value",plain)
-// KEY
-// SCALAR("a complex key",plain)
-// VALUE
-// SCALAR("another value",plain)
-// KEY
-// SCALAR("a mapping",plain)
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("key 1",plain)
-// VALUE
-// SCALAR("value 1",plain)
-// KEY
-// SCALAR("key 2",plain)
-// VALUE
-// SCALAR("value 2",plain)
-// BLOCK-END
-// KEY
-// SCALAR("a sequence",plain)
-// VALUE
-// BLOCK-SEQUENCE-START
-// BLOCK-ENTRY
-// SCALAR("item 1",plain)
-// BLOCK-ENTRY
-// SCALAR("item 2",plain)
-// BLOCK-END
-// BLOCK-END
-// STREAM-END
-//
-// YAML does not always require to start a new block collection from a new
-// line. If the current line contains only '-', '?', and ':' indicators, a new
-// block collection may start at the current line. The following examples
-// illustrate this case:
-//
-// 1. Collections in a sequence:
-//
-// - - item 1
-// - item 2
-// - key 1: value 1
-// key 2: value 2
-// - ? complex key
-// : complex value
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// BLOCK-SEQUENCE-START
-// BLOCK-ENTRY
-// BLOCK-SEQUENCE-START
-// BLOCK-ENTRY
-// SCALAR("item 1",plain)
-// BLOCK-ENTRY
-// SCALAR("item 2",plain)
-// BLOCK-END
-// BLOCK-ENTRY
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("key 1",plain)
-// VALUE
-// SCALAR("value 1",plain)
-// KEY
-// SCALAR("key 2",plain)
-// VALUE
-// SCALAR("value 2",plain)
-// BLOCK-END
-// BLOCK-ENTRY
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("complex key")
-// VALUE
-// SCALAR("complex value")
-// BLOCK-END
-// BLOCK-END
-// STREAM-END
-//
-// 2. Collections in a mapping:
-//
-// ? a sequence
-// : - item 1
-// - item 2
-// ? a mapping
-// : key 1: value 1
-// key 2: value 2
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("a sequence",plain)
-// VALUE
-// BLOCK-SEQUENCE-START
-// BLOCK-ENTRY
-// SCALAR("item 1",plain)
-// BLOCK-ENTRY
-// SCALAR("item 2",plain)
-// BLOCK-END
-// KEY
-// SCALAR("a mapping",plain)
-// VALUE
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("key 1",plain)
-// VALUE
-// SCALAR("value 1",plain)
-// KEY
-// SCALAR("key 2",plain)
-// VALUE
-// SCALAR("value 2",plain)
-// BLOCK-END
-// BLOCK-END
-// STREAM-END
-//
-// YAML also permits non-indented sequences if they are included into a block
-// mapping. In this case, the token BLOCK-SEQUENCE-START is not produced:
-//
-// key:
-// - item 1 # BLOCK-SEQUENCE-START is NOT produced here.
-// - item 2
-//
-// Tokens:
-//
-// STREAM-START(utf-8)
-// BLOCK-MAPPING-START
-// KEY
-// SCALAR("key",plain)
-// VALUE
-// BLOCK-ENTRY
-// SCALAR("item 1",plain)
-// BLOCK-ENTRY
-// SCALAR("item 2",plain)
-// BLOCK-END
-//
-
-// Ensure that the buffer contains the required number of characters.
-// Return true on success, false on failure (reader error or memory error).
-func cache(parser *yaml_parser_t, length int) bool {
- // [Go] This was inlined: !cache(A, B) -> unread < B && !update(A, B)
- return parser.unread >= length || yaml_parser_update_buffer(parser, length)
-}
-
-// Advance the buffer pointer.
-func skip(parser *yaml_parser_t) {
- parser.mark.index++
- parser.mark.column++
- parser.unread--
- parser.buffer_pos += width(parser.buffer[parser.buffer_pos])
-}
-
-func skip_line(parser *yaml_parser_t) {
- if is_crlf(parser.buffer, parser.buffer_pos) {
- parser.mark.index += 2
- parser.mark.column = 0
- parser.mark.line++
- parser.unread -= 2
- parser.buffer_pos += 2
- } else if is_break(parser.buffer, parser.buffer_pos) {
- parser.mark.index++
- parser.mark.column = 0
- parser.mark.line++
- parser.unread--
- parser.buffer_pos += width(parser.buffer[parser.buffer_pos])
- }
-}
-
-// Copy a character to a string buffer and advance pointers.
-func read(parser *yaml_parser_t, s []byte) []byte {
- w := width(parser.buffer[parser.buffer_pos])
- if w == 0 {
- panic("invalid character sequence")
- }
- if len(s) == 0 {
- s = make([]byte, 0, 32)
- }
- if w == 1 && len(s)+w <= cap(s) {
- s = s[:len(s)+1]
- s[len(s)-1] = parser.buffer[parser.buffer_pos]
- parser.buffer_pos++
- } else {
- s = append(s, parser.buffer[parser.buffer_pos:parser.buffer_pos+w]...)
- parser.buffer_pos += w
- }
- parser.mark.index++
- parser.mark.column++
- parser.unread--
- return s
-}
-
-// Copy a line break character to a string buffer and advance pointers.
-func read_line(parser *yaml_parser_t, s []byte) []byte {
- buf := parser.buffer
- pos := parser.buffer_pos
- switch {
- case buf[pos] == '\r' && buf[pos+1] == '\n':
- // CR LF . LF
- s = append(s, '\n')
- parser.buffer_pos += 2
- parser.mark.index++
- parser.unread--
- case buf[pos] == '\r' || buf[pos] == '\n':
- // CR|LF . LF
- s = append(s, '\n')
- parser.buffer_pos += 1
- case buf[pos] == '\xC2' && buf[pos+1] == '\x85':
- // NEL . LF
- s = append(s, '\n')
- parser.buffer_pos += 2
- case buf[pos] == '\xE2' && buf[pos+1] == '\x80' && (buf[pos+2] == '\xA8' || buf[pos+2] == '\xA9'):
- // LS|PS . LS|PS
- s = append(s, buf[parser.buffer_pos:pos+3]...)
- parser.buffer_pos += 3
- default:
- return s
- }
- parser.mark.index++
- parser.mark.column = 0
- parser.mark.line++
- parser.unread--
- return s
-}
-
-// Get the next token.
-func yaml_parser_scan(parser *yaml_parser_t, token *yaml_token_t) bool {
- // Erase the token object.
- *token = yaml_token_t{} // [Go] Is this necessary?
-
- // No tokens after STREAM-END or error.
- if parser.stream_end_produced || parser.error != yaml_NO_ERROR {
- return true
- }
-
- // Ensure that the tokens queue contains enough tokens.
- if !parser.token_available {
- if !yaml_parser_fetch_more_tokens(parser) {
- return false
- }
- }
-
- // Fetch the next token from the queue.
- *token = parser.tokens[parser.tokens_head]
- parser.tokens_head++
- parser.tokens_parsed++
- parser.token_available = false
-
- if token.typ == yaml_STREAM_END_TOKEN {
- parser.stream_end_produced = true
- }
- return true
-}
-
-// Set the scanner error and return false.
-func yaml_parser_set_scanner_error(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string) bool {
- parser.error = yaml_SCANNER_ERROR
- parser.context = context
- parser.context_mark = context_mark
- parser.problem = problem
- parser.problem_mark = parser.mark
- return false
-}
-
-func yaml_parser_set_scanner_tag_error(parser *yaml_parser_t, directive bool, context_mark yaml_mark_t, problem string) bool {
- context := "while parsing a tag"
- if directive {
- context = "while parsing a %TAG directive"
- }
- return yaml_parser_set_scanner_error(parser, context, context_mark, "did not find URI escaped octet")
-}
-
-func trace(args ...interface{}) func() {
- pargs := append([]interface{}{"+++"}, args...)
- fmt.Println(pargs...)
- pargs = append([]interface{}{"---"}, args...)
- return func() { fmt.Println(pargs...) }
-}
-
-// Ensure that the tokens queue contains at least one token which can be
-// returned to the Parser.
-func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool {
- // While we need more tokens to fetch, do it.
- for {
- // Check if we really need to fetch more tokens.
- need_more_tokens := false
-
- if parser.tokens_head == len(parser.tokens) {
- // Queue is empty.
- need_more_tokens = true
- } else {
- // Check if any potential simple key may occupy the head position.
- if !yaml_parser_stale_simple_keys(parser) {
- return false
- }
-
- for i := range parser.simple_keys {
- simple_key := &parser.simple_keys[i]
- if simple_key.possible && simple_key.token_number == parser.tokens_parsed {
- need_more_tokens = true
- break
- }
- }
- }
-
- // We are finished.
- if !need_more_tokens {
- break
- }
- // Fetch the next token.
- if !yaml_parser_fetch_next_token(parser) {
- return false
- }
- }
-
- parser.token_available = true
- return true
-}
-
-// The dispatcher for token fetchers.
-func yaml_parser_fetch_next_token(parser *yaml_parser_t) bool {
- // Ensure that the buffer is initialized.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- // Check if we just started scanning. Fetch STREAM-START then.
- if !parser.stream_start_produced {
- return yaml_parser_fetch_stream_start(parser)
- }
-
- // Eat whitespaces and comments until we reach the next token.
- if !yaml_parser_scan_to_next_token(parser) {
- return false
- }
-
- // Remove obsolete potential simple keys.
- if !yaml_parser_stale_simple_keys(parser) {
- return false
- }
-
- // Check the indentation level against the current column.
- if !yaml_parser_unroll_indent(parser, parser.mark.column) {
- return false
- }
-
- // Ensure that the buffer contains at least 4 characters. 4 is the length
- // of the longest indicators ('--- ' and '... ').
- if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) {
- return false
- }
-
- // Is it the end of the stream?
- if is_z(parser.buffer, parser.buffer_pos) {
- return yaml_parser_fetch_stream_end(parser)
- }
-
- // Is it a directive?
- if parser.mark.column == 0 && parser.buffer[parser.buffer_pos] == '%' {
- return yaml_parser_fetch_directive(parser)
- }
-
- buf := parser.buffer
- pos := parser.buffer_pos
-
- // Is it the document start indicator?
- if parser.mark.column == 0 && buf[pos] == '-' && buf[pos+1] == '-' && buf[pos+2] == '-' && is_blankz(buf, pos+3) {
- return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_START_TOKEN)
- }
-
- // Is it the document end indicator?
- if parser.mark.column == 0 && buf[pos] == '.' && buf[pos+1] == '.' && buf[pos+2] == '.' && is_blankz(buf, pos+3) {
- return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_END_TOKEN)
- }
-
- // Is it the flow sequence start indicator?
- if buf[pos] == '[' {
- return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_SEQUENCE_START_TOKEN)
- }
-
- // Is it the flow mapping start indicator?
- if parser.buffer[parser.buffer_pos] == '{' {
- return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_MAPPING_START_TOKEN)
- }
-
- // Is it the flow sequence end indicator?
- if parser.buffer[parser.buffer_pos] == ']' {
- return yaml_parser_fetch_flow_collection_end(parser,
- yaml_FLOW_SEQUENCE_END_TOKEN)
- }
-
- // Is it the flow mapping end indicator?
- if parser.buffer[parser.buffer_pos] == '}' {
- return yaml_parser_fetch_flow_collection_end(parser,
- yaml_FLOW_MAPPING_END_TOKEN)
- }
-
- // Is it the flow entry indicator?
- if parser.buffer[parser.buffer_pos] == ',' {
- return yaml_parser_fetch_flow_entry(parser)
- }
-
- // Is it the block entry indicator?
- if parser.buffer[parser.buffer_pos] == '-' && is_blankz(parser.buffer, parser.buffer_pos+1) {
- return yaml_parser_fetch_block_entry(parser)
- }
-
- // Is it the key indicator?
- if parser.buffer[parser.buffer_pos] == '?' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) {
- return yaml_parser_fetch_key(parser)
- }
-
- // Is it the value indicator?
- if parser.buffer[parser.buffer_pos] == ':' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) {
- return yaml_parser_fetch_value(parser)
- }
-
- // Is it an alias?
- if parser.buffer[parser.buffer_pos] == '*' {
- return yaml_parser_fetch_anchor(parser, yaml_ALIAS_TOKEN)
- }
-
- // Is it an anchor?
- if parser.buffer[parser.buffer_pos] == '&' {
- return yaml_parser_fetch_anchor(parser, yaml_ANCHOR_TOKEN)
- }
-
- // Is it a tag?
- if parser.buffer[parser.buffer_pos] == '!' {
- return yaml_parser_fetch_tag(parser)
- }
-
- // Is it a literal scalar?
- if parser.buffer[parser.buffer_pos] == '|' && parser.flow_level == 0 {
- return yaml_parser_fetch_block_scalar(parser, true)
- }
-
- // Is it a folded scalar?
- if parser.buffer[parser.buffer_pos] == '>' && parser.flow_level == 0 {
- return yaml_parser_fetch_block_scalar(parser, false)
- }
-
- // Is it a single-quoted scalar?
- if parser.buffer[parser.buffer_pos] == '\'' {
- return yaml_parser_fetch_flow_scalar(parser, true)
- }
-
- // Is it a double-quoted scalar?
- if parser.buffer[parser.buffer_pos] == '"' {
- return yaml_parser_fetch_flow_scalar(parser, false)
- }
-
- // Is it a plain scalar?
- //
- // A plain scalar may start with any non-blank characters except
- //
- // '-', '?', ':', ',', '[', ']', '{', '}',
- // '#', '&', '*', '!', '|', '>', '\'', '\"',
- // '%', '@', '`'.
- //
- // In the block context (and, for the '-' indicator, in the flow context
- // too), it may also start with the characters
- //
- // '-', '?', ':'
- //
- // if it is followed by a non-space character.
- //
- // The last rule is more restrictive than the specification requires.
- // [Go] Make this logic more reasonable.
- //switch parser.buffer[parser.buffer_pos] {
- //case '-', '?', ':', ',', '?', '-', ',', ':', ']', '[', '}', '{', '&', '#', '!', '*', '>', '|', '"', '\'', '@', '%', '-', '`':
- //}
- if !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '-' ||
- parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':' ||
- parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '[' ||
- parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' ||
- parser.buffer[parser.buffer_pos] == '}' || parser.buffer[parser.buffer_pos] == '#' ||
- parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '*' ||
- parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '|' ||
- parser.buffer[parser.buffer_pos] == '>' || parser.buffer[parser.buffer_pos] == '\'' ||
- parser.buffer[parser.buffer_pos] == '"' || parser.buffer[parser.buffer_pos] == '%' ||
- parser.buffer[parser.buffer_pos] == '@' || parser.buffer[parser.buffer_pos] == '`') ||
- (parser.buffer[parser.buffer_pos] == '-' && !is_blank(parser.buffer, parser.buffer_pos+1)) ||
- (parser.flow_level == 0 &&
- (parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':') &&
- !is_blankz(parser.buffer, parser.buffer_pos+1)) {
- return yaml_parser_fetch_plain_scalar(parser)
- }
-
- // If we don't determine the token type so far, it is an error.
- return yaml_parser_set_scanner_error(parser,
- "while scanning for the next token", parser.mark,
- "found character that cannot start any token")
-}
-
-// Check the list of potential simple keys and remove the positions that
-// cannot contain simple keys anymore.
-func yaml_parser_stale_simple_keys(parser *yaml_parser_t) bool {
- // Check for a potential simple key for each flow level.
- for i := range parser.simple_keys {
- simple_key := &parser.simple_keys[i]
-
- // The specification requires that a simple key
- //
- // - is limited to a single line,
- // - is shorter than 1024 characters.
- if simple_key.possible && (simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index) {
-
- // Check if the potential simple key to be removed is required.
- if simple_key.required {
- return yaml_parser_set_scanner_error(parser,
- "while scanning a simple key", simple_key.mark,
- "could not find expected ':'")
- }
- simple_key.possible = false
- }
- }
- return true
-}
-
-// Check if a simple key may start at the current position and add it if
-// needed.
-func yaml_parser_save_simple_key(parser *yaml_parser_t) bool {
- // A simple key is required at the current position if the scanner is in
- // the block context and the current column coincides with the indentation
- // level.
-
- required := parser.flow_level == 0 && parser.indent == parser.mark.column
-
- // A simple key is required only when it is the first token in the current
- // line. Therefore it is always allowed. But we add a check anyway.
- if required && !parser.simple_key_allowed {
- panic("should not happen")
- }
-
- //
- // If the current position may start a simple key, save it.
- //
- if parser.simple_key_allowed {
- simple_key := yaml_simple_key_t{
- possible: true,
- required: required,
- token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head),
- }
- simple_key.mark = parser.mark
-
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
- parser.simple_keys[len(parser.simple_keys)-1] = simple_key
- }
- return true
-}
-
-// Remove a potential simple key at the current flow level.
-func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool {
- i := len(parser.simple_keys) - 1
- if parser.simple_keys[i].possible {
- // If the key is required, it is an error.
- if parser.simple_keys[i].required {
- return yaml_parser_set_scanner_error(parser,
- "while scanning a simple key", parser.simple_keys[i].mark,
- "could not find expected ':'")
- }
- }
- // Remove the key from the stack.
- parser.simple_keys[i].possible = false
- return true
-}
-
-// Increase the flow level and resize the simple key list if needed.
-func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool {
- // Reset the simple key on the next level.
- parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{})
-
- // Increase the flow level.
- parser.flow_level++
- return true
-}
-
-// Decrease the flow level.
-func yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool {
- if parser.flow_level > 0 {
- parser.flow_level--
- parser.simple_keys = parser.simple_keys[:len(parser.simple_keys)-1]
- }
- return true
-}
-
-// Push the current indentation level to the stack and set the new level
-// the current column is greater than the indentation level. In this case,
-// append or insert the specified token into the token queue.
-func yaml_parser_roll_indent(parser *yaml_parser_t, column, number int, typ yaml_token_type_t, mark yaml_mark_t) bool {
- // In the flow context, do nothing.
- if parser.flow_level > 0 {
- return true
- }
-
- if parser.indent < column {
- // Push the current indentation level to the stack and set the new
- // indentation level.
- parser.indents = append(parser.indents, parser.indent)
- parser.indent = column
-
- // Create a token and insert it into the queue.
- token := yaml_token_t{
- typ: typ,
- start_mark: mark,
- end_mark: mark,
- }
- if number > -1 {
- number -= parser.tokens_parsed
- }
- yaml_insert_token(parser, number, &token)
- }
- return true
-}
-
-// Pop indentation levels from the indents stack until the current level
-// becomes less or equal to the column. For each indentation level, append
-// the BLOCK-END token.
-func yaml_parser_unroll_indent(parser *yaml_parser_t, column int) bool {
- // In the flow context, do nothing.
- if parser.flow_level > 0 {
- return true
- }
-
- // Loop through the indentation levels in the stack.
- for parser.indent > column {
- // Create a token and append it to the queue.
- token := yaml_token_t{
- typ: yaml_BLOCK_END_TOKEN,
- start_mark: parser.mark,
- end_mark: parser.mark,
- }
- yaml_insert_token(parser, -1, &token)
-
- // Pop the indentation level.
- parser.indent = parser.indents[len(parser.indents)-1]
- parser.indents = parser.indents[:len(parser.indents)-1]
- }
- return true
-}
-
-// Initialize the scanner and produce the STREAM-START token.
-func yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool {
-
- // Set the initial indentation.
- parser.indent = -1
-
- // Initialize the simple key stack.
- parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{})
-
- // A simple key is allowed at the beginning of the stream.
- parser.simple_key_allowed = true
-
- // We have started.
- parser.stream_start_produced = true
-
- // Create the STREAM-START token and append it to the queue.
- token := yaml_token_t{
- typ: yaml_STREAM_START_TOKEN,
- start_mark: parser.mark,
- end_mark: parser.mark,
- encoding: parser.encoding,
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the STREAM-END token and shut down the scanner.
-func yaml_parser_fetch_stream_end(parser *yaml_parser_t) bool {
-
- // Force new line.
- if parser.mark.column != 0 {
- parser.mark.column = 0
- parser.mark.line++
- }
-
- // Reset the indentation level.
- if !yaml_parser_unroll_indent(parser, -1) {
- return false
- }
-
- // Reset simple keys.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- parser.simple_key_allowed = false
-
- // Create the STREAM-END token and append it to the queue.
- token := yaml_token_t{
- typ: yaml_STREAM_END_TOKEN,
- start_mark: parser.mark,
- end_mark: parser.mark,
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce a VERSION-DIRECTIVE or TAG-DIRECTIVE token.
-func yaml_parser_fetch_directive(parser *yaml_parser_t) bool {
- // Reset the indentation level.
- if !yaml_parser_unroll_indent(parser, -1) {
- return false
- }
-
- // Reset simple keys.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- parser.simple_key_allowed = false
-
- // Create the YAML-DIRECTIVE or TAG-DIRECTIVE token.
- token := yaml_token_t{}
- if !yaml_parser_scan_directive(parser, &token) {
- return false
- }
- // Append the token to the queue.
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the DOCUMENT-START or DOCUMENT-END token.
-func yaml_parser_fetch_document_indicator(parser *yaml_parser_t, typ yaml_token_type_t) bool {
- // Reset the indentation level.
- if !yaml_parser_unroll_indent(parser, -1) {
- return false
- }
-
- // Reset simple keys.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- parser.simple_key_allowed = false
-
- // Consume the token.
- start_mark := parser.mark
-
- skip(parser)
- skip(parser)
- skip(parser)
-
- end_mark := parser.mark
-
- // Create the DOCUMENT-START or DOCUMENT-END token.
- token := yaml_token_t{
- typ: typ,
- start_mark: start_mark,
- end_mark: end_mark,
- }
- // Append the token to the queue.
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the FLOW-SEQUENCE-START or FLOW-MAPPING-START token.
-func yaml_parser_fetch_flow_collection_start(parser *yaml_parser_t, typ yaml_token_type_t) bool {
- // The indicators '[' and '{' may start a simple key.
- if !yaml_parser_save_simple_key(parser) {
- return false
- }
-
- // Increase the flow level.
- if !yaml_parser_increase_flow_level(parser) {
- return false
- }
-
- // A simple key may follow the indicators '[' and '{'.
- parser.simple_key_allowed = true
-
- // Consume the token.
- start_mark := parser.mark
- skip(parser)
- end_mark := parser.mark
-
- // Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token.
- token := yaml_token_t{
- typ: typ,
- start_mark: start_mark,
- end_mark: end_mark,
- }
- // Append the token to the queue.
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the FLOW-SEQUENCE-END or FLOW-MAPPING-END token.
-func yaml_parser_fetch_flow_collection_end(parser *yaml_parser_t, typ yaml_token_type_t) bool {
- // Reset any potential simple key on the current flow level.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- // Decrease the flow level.
- if !yaml_parser_decrease_flow_level(parser) {
- return false
- }
-
- // No simple keys after the indicators ']' and '}'.
- parser.simple_key_allowed = false
-
- // Consume the token.
-
- start_mark := parser.mark
- skip(parser)
- end_mark := parser.mark
-
- // Create the FLOW-SEQUENCE-END of FLOW-MAPPING-END token.
- token := yaml_token_t{
- typ: typ,
- start_mark: start_mark,
- end_mark: end_mark,
- }
- // Append the token to the queue.
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the FLOW-ENTRY token.
-func yaml_parser_fetch_flow_entry(parser *yaml_parser_t) bool {
- // Reset any potential simple keys on the current flow level.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- // Simple keys are allowed after ','.
- parser.simple_key_allowed = true
-
- // Consume the token.
- start_mark := parser.mark
- skip(parser)
- end_mark := parser.mark
-
- // Create the FLOW-ENTRY token and append it to the queue.
- token := yaml_token_t{
- typ: yaml_FLOW_ENTRY_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the BLOCK-ENTRY token.
-func yaml_parser_fetch_block_entry(parser *yaml_parser_t) bool {
- // Check if the scanner is in the block context.
- if parser.flow_level == 0 {
- // Check if we are allowed to start a new entry.
- if !parser.simple_key_allowed {
- return yaml_parser_set_scanner_error(parser, "", parser.mark,
- "block sequence entries are not allowed in this context")
- }
- // Add the BLOCK-SEQUENCE-START token if needed.
- if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_SEQUENCE_START_TOKEN, parser.mark) {
- return false
- }
- } else {
- // It is an error for the '-' indicator to occur in the flow context,
- // but we let the Parser detect and report about it because the Parser
- // is able to point to the context.
- }
-
- // Reset any potential simple keys on the current flow level.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- // Simple keys are allowed after '-'.
- parser.simple_key_allowed = true
-
- // Consume the token.
- start_mark := parser.mark
- skip(parser)
- end_mark := parser.mark
-
- // Create the BLOCK-ENTRY token and append it to the queue.
- token := yaml_token_t{
- typ: yaml_BLOCK_ENTRY_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the KEY token.
-func yaml_parser_fetch_key(parser *yaml_parser_t) bool {
-
- // In the block context, additional checks are required.
- if parser.flow_level == 0 {
- // Check if we are allowed to start a new key (not nessesary simple).
- if !parser.simple_key_allowed {
- return yaml_parser_set_scanner_error(parser, "", parser.mark,
- "mapping keys are not allowed in this context")
- }
- // Add the BLOCK-MAPPING-START token if needed.
- if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) {
- return false
- }
- }
-
- // Reset any potential simple keys on the current flow level.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- // Simple keys are allowed after '?' in the block context.
- parser.simple_key_allowed = parser.flow_level == 0
-
- // Consume the token.
- start_mark := parser.mark
- skip(parser)
- end_mark := parser.mark
-
- // Create the KEY token and append it to the queue.
- token := yaml_token_t{
- typ: yaml_KEY_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the VALUE token.
-func yaml_parser_fetch_value(parser *yaml_parser_t) bool {
-
- simple_key := &parser.simple_keys[len(parser.simple_keys)-1]
-
- // Have we found a simple key?
- if simple_key.possible {
- // Create the KEY token and insert it into the queue.
- token := yaml_token_t{
- typ: yaml_KEY_TOKEN,
- start_mark: simple_key.mark,
- end_mark: simple_key.mark,
- }
- yaml_insert_token(parser, simple_key.token_number-parser.tokens_parsed, &token)
-
- // In the block context, we may need to add the BLOCK-MAPPING-START token.
- if !yaml_parser_roll_indent(parser, simple_key.mark.column,
- simple_key.token_number,
- yaml_BLOCK_MAPPING_START_TOKEN, simple_key.mark) {
- return false
- }
-
- // Remove the simple key.
- simple_key.possible = false
-
- // A simple key cannot follow another simple key.
- parser.simple_key_allowed = false
-
- } else {
- // The ':' indicator follows a complex key.
-
- // In the block context, extra checks are required.
- if parser.flow_level == 0 {
-
- // Check if we are allowed to start a complex value.
- if !parser.simple_key_allowed {
- return yaml_parser_set_scanner_error(parser, "", parser.mark,
- "mapping values are not allowed in this context")
- }
-
- // Add the BLOCK-MAPPING-START token if needed.
- if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) {
- return false
- }
- }
-
- // Simple keys after ':' are allowed in the block context.
- parser.simple_key_allowed = parser.flow_level == 0
- }
-
- // Consume the token.
- start_mark := parser.mark
- skip(parser)
- end_mark := parser.mark
-
- // Create the VALUE token and append it to the queue.
- token := yaml_token_t{
- typ: yaml_VALUE_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the ALIAS or ANCHOR token.
-func yaml_parser_fetch_anchor(parser *yaml_parser_t, typ yaml_token_type_t) bool {
- // An anchor or an alias could be a simple key.
- if !yaml_parser_save_simple_key(parser) {
- return false
- }
-
- // A simple key cannot follow an anchor or an alias.
- parser.simple_key_allowed = false
-
- // Create the ALIAS or ANCHOR token and append it to the queue.
- var token yaml_token_t
- if !yaml_parser_scan_anchor(parser, &token, typ) {
- return false
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the TAG token.
-func yaml_parser_fetch_tag(parser *yaml_parser_t) bool {
- // A tag could be a simple key.
- if !yaml_parser_save_simple_key(parser) {
- return false
- }
-
- // A simple key cannot follow a tag.
- parser.simple_key_allowed = false
-
- // Create the TAG token and append it to the queue.
- var token yaml_token_t
- if !yaml_parser_scan_tag(parser, &token) {
- return false
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the SCALAR(...,literal) or SCALAR(...,folded) tokens.
-func yaml_parser_fetch_block_scalar(parser *yaml_parser_t, literal bool) bool {
- // Remove any potential simple keys.
- if !yaml_parser_remove_simple_key(parser) {
- return false
- }
-
- // A simple key may follow a block scalar.
- parser.simple_key_allowed = true
-
- // Create the SCALAR token and append it to the queue.
- var token yaml_token_t
- if !yaml_parser_scan_block_scalar(parser, &token, literal) {
- return false
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the SCALAR(...,single-quoted) or SCALAR(...,double-quoted) tokens.
-func yaml_parser_fetch_flow_scalar(parser *yaml_parser_t, single bool) bool {
- // A plain scalar could be a simple key.
- if !yaml_parser_save_simple_key(parser) {
- return false
- }
-
- // A simple key cannot follow a flow scalar.
- parser.simple_key_allowed = false
-
- // Create the SCALAR token and append it to the queue.
- var token yaml_token_t
- if !yaml_parser_scan_flow_scalar(parser, &token, single) {
- return false
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Produce the SCALAR(...,plain) token.
-func yaml_parser_fetch_plain_scalar(parser *yaml_parser_t) bool {
- // A plain scalar could be a simple key.
- if !yaml_parser_save_simple_key(parser) {
- return false
- }
-
- // A simple key cannot follow a flow scalar.
- parser.simple_key_allowed = false
-
- // Create the SCALAR token and append it to the queue.
- var token yaml_token_t
- if !yaml_parser_scan_plain_scalar(parser, &token) {
- return false
- }
- yaml_insert_token(parser, -1, &token)
- return true
-}
-
-// Eat whitespaces and comments until the next token is found.
-func yaml_parser_scan_to_next_token(parser *yaml_parser_t) bool {
-
- // Until the next token is not found.
- for {
- // Allow the BOM mark to start a line.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if parser.mark.column == 0 && is_bom(parser.buffer, parser.buffer_pos) {
- skip(parser)
- }
-
- // Eat whitespaces.
- // Tabs are allowed:
- // - in the flow context
- // - in the block context, but not at the beginning of the line or
- // after '-', '?', or ':' (complex value).
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- for parser.buffer[parser.buffer_pos] == ' ' || ((parser.flow_level > 0 || !parser.simple_key_allowed) && parser.buffer[parser.buffer_pos] == '\t') {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Eat a comment until a line break.
- if parser.buffer[parser.buffer_pos] == '#' {
- for !is_breakz(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
- }
-
- // If it is a line break, eat it.
- if is_break(parser.buffer, parser.buffer_pos) {
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
- skip_line(parser)
-
- // In the block context, a new line may start a simple key.
- if parser.flow_level == 0 {
- parser.simple_key_allowed = true
- }
- } else {
- break // We have found a token.
- }
- }
-
- return true
-}
-
-// Scan a YAML-DIRECTIVE or TAG-DIRECTIVE token.
-//
-// Scope:
-// %YAML 1.1 # a comment \n
-// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-// %TAG !yaml! tag:yaml.org,2002: \n
-// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-//
-func yaml_parser_scan_directive(parser *yaml_parser_t, token *yaml_token_t) bool {
- // Eat '%'.
- start_mark := parser.mark
- skip(parser)
-
- // Scan the directive name.
- var name []byte
- if !yaml_parser_scan_directive_name(parser, start_mark, &name) {
- return false
- }
-
- // Is it a YAML directive?
- if bytes.Equal(name, []byte("YAML")) {
- // Scan the VERSION directive value.
- var major, minor int8
- if !yaml_parser_scan_version_directive_value(parser, start_mark, &major, &minor) {
- return false
- }
- end_mark := parser.mark
-
- // Create a VERSION-DIRECTIVE token.
- *token = yaml_token_t{
- typ: yaml_VERSION_DIRECTIVE_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- major: major,
- minor: minor,
- }
-
- // Is it a TAG directive?
- } else if bytes.Equal(name, []byte("TAG")) {
- // Scan the TAG directive value.
- var handle, prefix []byte
- if !yaml_parser_scan_tag_directive_value(parser, start_mark, &handle, &prefix) {
- return false
- }
- end_mark := parser.mark
-
- // Create a TAG-DIRECTIVE token.
- *token = yaml_token_t{
- typ: yaml_TAG_DIRECTIVE_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- value: handle,
- prefix: prefix,
- }
-
- // Unknown directive.
- } else {
- yaml_parser_set_scanner_error(parser, "while scanning a directive",
- start_mark, "found uknown directive name")
- return false
- }
-
- // Eat the rest of the line including any comments.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- for is_blank(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- if parser.buffer[parser.buffer_pos] == '#' {
- for !is_breakz(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
- }
-
- // Check if we are at the end of the line.
- if !is_breakz(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a directive",
- start_mark, "did not find expected comment or line break")
- return false
- }
-
- // Eat a line break.
- if is_break(parser.buffer, parser.buffer_pos) {
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
- skip_line(parser)
- }
-
- return true
-}
-
-// Scan the directive name.
-//
-// Scope:
-// %YAML 1.1 # a comment \n
-// ^^^^
-// %TAG !yaml! tag:yaml.org,2002: \n
-// ^^^
-//
-func yaml_parser_scan_directive_name(parser *yaml_parser_t, start_mark yaml_mark_t, name *[]byte) bool {
- // Consume the directive name.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- var s []byte
- for is_alpha(parser.buffer, parser.buffer_pos) {
- s = read(parser, s)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Check if the name is empty.
- if len(s) == 0 {
- yaml_parser_set_scanner_error(parser, "while scanning a directive",
- start_mark, "could not find expected directive name")
- return false
- }
-
- // Check for an blank character after the name.
- if !is_blankz(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a directive",
- start_mark, "found unexpected non-alphabetical character")
- return false
- }
- *name = s
- return true
-}
-
-// Scan the value of VERSION-DIRECTIVE.
-//
-// Scope:
-// %YAML 1.1 # a comment \n
-// ^^^^^^
-func yaml_parser_scan_version_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, major, minor *int8) bool {
- // Eat whitespaces.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- for is_blank(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Consume the major version number.
- if !yaml_parser_scan_version_directive_number(parser, start_mark, major) {
- return false
- }
-
- // Eat '.'.
- if parser.buffer[parser.buffer_pos] != '.' {
- return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
- start_mark, "did not find expected digit or '.' character")
- }
-
- skip(parser)
-
- // Consume the minor version number.
- if !yaml_parser_scan_version_directive_number(parser, start_mark, minor) {
- return false
- }
- return true
-}
-
-const max_number_length = 2
-
-// Scan the version number of VERSION-DIRECTIVE.
-//
-// Scope:
-// %YAML 1.1 # a comment \n
-// ^
-// %YAML 1.1 # a comment \n
-// ^
-func yaml_parser_scan_version_directive_number(parser *yaml_parser_t, start_mark yaml_mark_t, number *int8) bool {
-
- // Repeat while the next character is digit.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- var value, length int8
- for is_digit(parser.buffer, parser.buffer_pos) {
- // Check if the number is too long.
- length++
- if length > max_number_length {
- return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
- start_mark, "found extremely long version number")
- }
- value = value*10 + int8(as_digit(parser.buffer, parser.buffer_pos))
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Check if the number was present.
- if length == 0 {
- return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
- start_mark, "did not find expected version number")
- }
- *number = value
- return true
-}
-
-// Scan the value of a TAG-DIRECTIVE token.
-//
-// Scope:
-// %TAG !yaml! tag:yaml.org,2002: \n
-// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-//
-func yaml_parser_scan_tag_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, handle, prefix *[]byte) bool {
- var handle_value, prefix_value []byte
-
- // Eat whitespaces.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- for is_blank(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Scan a handle.
- if !yaml_parser_scan_tag_handle(parser, true, start_mark, &handle_value) {
- return false
- }
-
- // Expect a whitespace.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if !is_blank(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive",
- start_mark, "did not find expected whitespace")
- return false
- }
-
- // Eat whitespaces.
- for is_blank(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Scan a prefix.
- if !yaml_parser_scan_tag_uri(parser, true, nil, start_mark, &prefix_value) {
- return false
- }
-
- // Expect a whitespace or line break.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if !is_blankz(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive",
- start_mark, "did not find expected whitespace or line break")
- return false
- }
-
- *handle = handle_value
- *prefix = prefix_value
- return true
-}
-
-func yaml_parser_scan_anchor(parser *yaml_parser_t, token *yaml_token_t, typ yaml_token_type_t) bool {
- var s []byte
-
- // Eat the indicator character.
- start_mark := parser.mark
- skip(parser)
-
- // Consume the value.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- for is_alpha(parser.buffer, parser.buffer_pos) {
- s = read(parser, s)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- end_mark := parser.mark
-
- /*
- * Check if length of the anchor is greater than 0 and it is followed by
- * a whitespace character or one of the indicators:
- *
- * '?', ':', ',', ']', '}', '%', '@', '`'.
- */
-
- if len(s) == 0 ||
- !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '?' ||
- parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == ',' ||
- parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '}' ||
- parser.buffer[parser.buffer_pos] == '%' || parser.buffer[parser.buffer_pos] == '@' ||
- parser.buffer[parser.buffer_pos] == '`') {
- context := "while scanning an alias"
- if typ == yaml_ANCHOR_TOKEN {
- context = "while scanning an anchor"
- }
- yaml_parser_set_scanner_error(parser, context, start_mark,
- "did not find expected alphabetic or numeric character")
- return false
- }
-
- // Create a token.
- *token = yaml_token_t{
- typ: typ,
- start_mark: start_mark,
- end_mark: end_mark,
- value: s,
- }
-
- return true
-}
-
-/*
- * Scan a TAG token.
- */
-
-func yaml_parser_scan_tag(parser *yaml_parser_t, token *yaml_token_t) bool {
- var handle, suffix []byte
-
- start_mark := parser.mark
-
- // Check if the tag is in the canonical form.
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
-
- if parser.buffer[parser.buffer_pos+1] == '<' {
- // Keep the handle as ''
-
- // Eat '!<'
- skip(parser)
- skip(parser)
-
- // Consume the tag value.
- if !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) {
- return false
- }
-
- // Check for '>' and eat it.
- if parser.buffer[parser.buffer_pos] != '>' {
- yaml_parser_set_scanner_error(parser, "while scanning a tag",
- start_mark, "did not find the expected '>'")
- return false
- }
-
- skip(parser)
- } else {
- // The tag has either the '!suffix' or the '!handle!suffix' form.
-
- // First, try to scan a handle.
- if !yaml_parser_scan_tag_handle(parser, false, start_mark, &handle) {
- return false
- }
-
- // Check if it is, indeed, handle.
- if handle[0] == '!' && len(handle) > 1 && handle[len(handle)-1] == '!' {
- // Scan the suffix now.
- if !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) {
- return false
- }
- } else {
- // It wasn't a handle after all. Scan the rest of the tag.
- if !yaml_parser_scan_tag_uri(parser, false, handle, start_mark, &suffix) {
- return false
- }
-
- // Set the handle to '!'.
- handle = []byte{'!'}
-
- // A special case: the '!' tag. Set the handle to '' and the
- // suffix to '!'.
- if len(suffix) == 0 {
- handle, suffix = suffix, handle
- }
- }
- }
-
- // Check the character which ends the tag.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if !is_blankz(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a tag",
- start_mark, "did not find expected whitespace or line break")
- return false
- }
-
- end_mark := parser.mark
-
- // Create a token.
- *token = yaml_token_t{
- typ: yaml_TAG_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- value: handle,
- suffix: suffix,
- }
- return true
-}
-
-// Scan a tag handle.
-func yaml_parser_scan_tag_handle(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, handle *[]byte) bool {
- // Check the initial '!' character.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if parser.buffer[parser.buffer_pos] != '!' {
- yaml_parser_set_scanner_tag_error(parser, directive,
- start_mark, "did not find expected '!'")
- return false
- }
-
- var s []byte
-
- // Copy the '!' character.
- s = read(parser, s)
-
- // Copy all subsequent alphabetical and numerical characters.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- for is_alpha(parser.buffer, parser.buffer_pos) {
- s = read(parser, s)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Check if the trailing character is '!' and copy it.
- if parser.buffer[parser.buffer_pos] == '!' {
- s = read(parser, s)
- } else {
- // It's either the '!' tag or not really a tag handle. If it's a %TAG
- // directive, it's an error. If it's a tag token, it must be a part of URI.
- if directive && !(s[0] == '!' && s[1] == 0) {
- yaml_parser_set_scanner_tag_error(parser, directive,
- start_mark, "did not find expected '!'")
- return false
- }
- }
-
- *handle = s
- return true
-}
-
-// Scan a tag.
-func yaml_parser_scan_tag_uri(parser *yaml_parser_t, directive bool, head []byte, start_mark yaml_mark_t, uri *[]byte) bool {
- //size_t length = head ? strlen((char *)head) : 0
- var s []byte
-
- // Copy the head if needed.
- //
- // Note that we don't copy the leading '!' character.
- if len(head) > 1 {
- s = append(s, head[1:]...)
- }
-
- // Scan the tag.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- // The set of characters that may appear in URI is as follows:
- //
- // '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&',
- // '=', '+', '$', ',', '.', '!', '~', '*', '\'', '(', ')', '[', ']',
- // '%'.
- // [Go] Convert this into more reasonable logic.
- for is_alpha(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == ';' ||
- parser.buffer[parser.buffer_pos] == '/' || parser.buffer[parser.buffer_pos] == '?' ||
- parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == '@' ||
- parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '=' ||
- parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '$' ||
- parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '.' ||
- parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '~' ||
- parser.buffer[parser.buffer_pos] == '*' || parser.buffer[parser.buffer_pos] == '\'' ||
- parser.buffer[parser.buffer_pos] == '(' || parser.buffer[parser.buffer_pos] == ')' ||
- parser.buffer[parser.buffer_pos] == '[' || parser.buffer[parser.buffer_pos] == ']' ||
- parser.buffer[parser.buffer_pos] == '%' {
- // Check if it is a URI-escape sequence.
- if parser.buffer[parser.buffer_pos] == '%' {
- if !yaml_parser_scan_uri_escapes(parser, directive, start_mark, &s) {
- return false
- }
- } else {
- s = read(parser, s)
- }
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Check if the tag is non-empty.
- if len(s) == 0 {
- yaml_parser_set_scanner_tag_error(parser, directive,
- start_mark, "did not find expected tag URI")
- return false
- }
- *uri = s
- return true
-}
-
-// Decode an URI-escape sequence corresponding to a single UTF-8 character.
-func yaml_parser_scan_uri_escapes(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, s *[]byte) bool {
-
- // Decode the required number of characters.
- w := 1024
- for w > 0 {
- // Check for a URI-escaped octet.
- if parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) {
- return false
- }
-
- if !(parser.buffer[parser.buffer_pos] == '%' &&
- is_hex(parser.buffer, parser.buffer_pos+1) &&
- is_hex(parser.buffer, parser.buffer_pos+2)) {
- return yaml_parser_set_scanner_tag_error(parser, directive,
- start_mark, "did not find URI escaped octet")
- }
-
- // Get the octet.
- octet := byte((as_hex(parser.buffer, parser.buffer_pos+1) << 4) + as_hex(parser.buffer, parser.buffer_pos+2))
-
- // If it is the leading octet, determine the length of the UTF-8 sequence.
- if w == 1024 {
- w = width(octet)
- if w == 0 {
- return yaml_parser_set_scanner_tag_error(parser, directive,
- start_mark, "found an incorrect leading UTF-8 octet")
- }
- } else {
- // Check if the trailing octet is correct.
- if octet&0xC0 != 0x80 {
- return yaml_parser_set_scanner_tag_error(parser, directive,
- start_mark, "found an incorrect trailing UTF-8 octet")
- }
- }
-
- // Copy the octet and move the pointers.
- *s = append(*s, octet)
- skip(parser)
- skip(parser)
- skip(parser)
- w--
- }
- return true
-}
-
-// Scan a block scalar.
-func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, literal bool) bool {
- // Eat the indicator '|' or '>'.
- start_mark := parser.mark
- skip(parser)
-
- // Scan the additional block scalar indicators.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- // Check for a chomping indicator.
- var chomping, increment int
- if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' {
- // Set the chomping method and eat the indicator.
- if parser.buffer[parser.buffer_pos] == '+' {
- chomping = +1
- } else {
- chomping = -1
- }
- skip(parser)
-
- // Check for an indentation indicator.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if is_digit(parser.buffer, parser.buffer_pos) {
- // Check that the indentation is greater than 0.
- if parser.buffer[parser.buffer_pos] == '0' {
- yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
- start_mark, "found an indentation indicator equal to 0")
- return false
- }
-
- // Get the indentation level and eat the indicator.
- increment = as_digit(parser.buffer, parser.buffer_pos)
- skip(parser)
- }
-
- } else if is_digit(parser.buffer, parser.buffer_pos) {
- // Do the same as above, but in the opposite order.
-
- if parser.buffer[parser.buffer_pos] == '0' {
- yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
- start_mark, "found an indentation indicator equal to 0")
- return false
- }
- increment = as_digit(parser.buffer, parser.buffer_pos)
- skip(parser)
-
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' {
- if parser.buffer[parser.buffer_pos] == '+' {
- chomping = +1
- } else {
- chomping = -1
- }
- skip(parser)
- }
- }
-
- // Eat whitespaces and comments to the end of the line.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- for is_blank(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
- if parser.buffer[parser.buffer_pos] == '#' {
- for !is_breakz(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
- }
-
- // Check if we are at the end of the line.
- if !is_breakz(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
- start_mark, "did not find expected comment or line break")
- return false
- }
-
- // Eat a line break.
- if is_break(parser.buffer, parser.buffer_pos) {
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
- skip_line(parser)
- }
-
- end_mark := parser.mark
-
- // Set the indentation level if it was specified.
- var indent int
- if increment > 0 {
- if parser.indent >= 0 {
- indent = parser.indent + increment
- } else {
- indent = increment
- }
- }
-
- // Scan the leading line breaks and determine the indentation level if needed.
- var s, leading_break, trailing_breaks []byte
- if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) {
- return false
- }
-
- // Scan the block scalar content.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- var leading_blank, trailing_blank bool
- for parser.mark.column == indent && !is_z(parser.buffer, parser.buffer_pos) {
- // We are at the beginning of a non-empty line.
-
- // Is it a trailing whitespace?
- trailing_blank = is_blank(parser.buffer, parser.buffer_pos)
-
- // Check if we need to fold the leading line break.
- if !literal && !leading_blank && !trailing_blank && len(leading_break) > 0 && leading_break[0] == '\n' {
- // Do we need to join the lines by space?
- if len(trailing_breaks) == 0 {
- s = append(s, ' ')
- }
- } else {
- s = append(s, leading_break...)
- }
- leading_break = leading_break[:0]
-
- // Append the remaining line breaks.
- s = append(s, trailing_breaks...)
- trailing_breaks = trailing_breaks[:0]
-
- // Is it a leading whitespace?
- leading_blank = is_blank(parser.buffer, parser.buffer_pos)
-
- // Consume the current line.
- for !is_breakz(parser.buffer, parser.buffer_pos) {
- s = read(parser, s)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Consume the line break.
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
-
- leading_break = read_line(parser, leading_break)
-
- // Eat the following indentation spaces and line breaks.
- if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) {
- return false
- }
- }
-
- // Chomp the tail.
- if chomping != -1 {
- s = append(s, leading_break...)
- }
- if chomping == 1 {
- s = append(s, trailing_breaks...)
- }
-
- // Create a token.
- *token = yaml_token_t{
- typ: yaml_SCALAR_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- value: s,
- style: yaml_LITERAL_SCALAR_STYLE,
- }
- if !literal {
- token.style = yaml_FOLDED_SCALAR_STYLE
- }
- return true
-}
-
-// Scan indentation spaces and line breaks for a block scalar. Determine the
-// indentation level if needed.
-func yaml_parser_scan_block_scalar_breaks(parser *yaml_parser_t, indent *int, breaks *[]byte, start_mark yaml_mark_t, end_mark *yaml_mark_t) bool {
- *end_mark = parser.mark
-
- // Eat the indentation spaces and line breaks.
- max_indent := 0
- for {
- // Eat the indentation spaces.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- for (*indent == 0 || parser.mark.column < *indent) && is_space(parser.buffer, parser.buffer_pos) {
- skip(parser)
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
- if parser.mark.column > max_indent {
- max_indent = parser.mark.column
- }
-
- // Check for a tab character messing the indentation.
- if (*indent == 0 || parser.mark.column < *indent) && is_tab(parser.buffer, parser.buffer_pos) {
- return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
- start_mark, "found a tab character where an indentation space is expected")
- }
-
- // Have we found a non-empty line?
- if !is_break(parser.buffer, parser.buffer_pos) {
- break
- }
-
- // Consume the line break.
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
- // [Go] Should really be returning breaks instead.
- *breaks = read_line(parser, *breaks)
- *end_mark = parser.mark
- }
-
- // Determine the indentation level if needed.
- if *indent == 0 {
- *indent = max_indent
- if *indent < parser.indent+1 {
- *indent = parser.indent + 1
- }
- if *indent < 1 {
- *indent = 1
- }
- }
- return true
-}
-
-// Scan a quoted scalar.
-func yaml_parser_scan_flow_scalar(parser *yaml_parser_t, token *yaml_token_t, single bool) bool {
- // Eat the left quote.
- start_mark := parser.mark
- skip(parser)
-
- // Consume the content of the quoted scalar.
- var s, leading_break, trailing_breaks, whitespaces []byte
- for {
- // Check that there are no document indicators at the beginning of the line.
- if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) {
- return false
- }
-
- if parser.mark.column == 0 &&
- ((parser.buffer[parser.buffer_pos+0] == '-' &&
- parser.buffer[parser.buffer_pos+1] == '-' &&
- parser.buffer[parser.buffer_pos+2] == '-') ||
- (parser.buffer[parser.buffer_pos+0] == '.' &&
- parser.buffer[parser.buffer_pos+1] == '.' &&
- parser.buffer[parser.buffer_pos+2] == '.')) &&
- is_blankz(parser.buffer, parser.buffer_pos+3) {
- yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar",
- start_mark, "found unexpected document indicator")
- return false
- }
-
- // Check for EOF.
- if is_z(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar",
- start_mark, "found unexpected end of stream")
- return false
- }
-
- // Consume non-blank characters.
- leading_blanks := false
- for !is_blankz(parser.buffer, parser.buffer_pos) {
- if single && parser.buffer[parser.buffer_pos] == '\'' && parser.buffer[parser.buffer_pos+1] == '\'' {
- // Is is an escaped single quote.
- s = append(s, '\'')
- skip(parser)
- skip(parser)
-
- } else if single && parser.buffer[parser.buffer_pos] == '\'' {
- // It is a right single quote.
- break
- } else if !single && parser.buffer[parser.buffer_pos] == '"' {
- // It is a right double quote.
- break
-
- } else if !single && parser.buffer[parser.buffer_pos] == '\\' && is_break(parser.buffer, parser.buffer_pos+1) {
- // It is an escaped line break.
- if parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) {
- return false
- }
- skip(parser)
- skip_line(parser)
- leading_blanks = true
- break
-
- } else if !single && parser.buffer[parser.buffer_pos] == '\\' {
- // It is an escape sequence.
- code_length := 0
-
- // Check the escape character.
- switch parser.buffer[parser.buffer_pos+1] {
- case '0':
- s = append(s, 0)
- case 'a':
- s = append(s, '\x07')
- case 'b':
- s = append(s, '\x08')
- case 't', '\t':
- s = append(s, '\x09')
- case 'n':
- s = append(s, '\x0A')
- case 'v':
- s = append(s, '\x0B')
- case 'f':
- s = append(s, '\x0C')
- case 'r':
- s = append(s, '\x0D')
- case 'e':
- s = append(s, '\x1B')
- case ' ':
- s = append(s, '\x20')
- case '"':
- s = append(s, '"')
- case '\'':
- s = append(s, '\'')
- case '\\':
- s = append(s, '\\')
- case 'N': // NEL (#x85)
- s = append(s, '\xC2')
- s = append(s, '\x85')
- case '_': // #xA0
- s = append(s, '\xC2')
- s = append(s, '\xA0')
- case 'L': // LS (#x2028)
- s = append(s, '\xE2')
- s = append(s, '\x80')
- s = append(s, '\xA8')
- case 'P': // PS (#x2029)
- s = append(s, '\xE2')
- s = append(s, '\x80')
- s = append(s, '\xA9')
- case 'x':
- code_length = 2
- case 'u':
- code_length = 4
- case 'U':
- code_length = 8
- default:
- yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
- start_mark, "found unknown escape character")
- return false
- }
-
- skip(parser)
- skip(parser)
-
- // Consume an arbitrary escape code.
- if code_length > 0 {
- var value int
-
- // Scan the character value.
- if parser.unread < code_length && !yaml_parser_update_buffer(parser, code_length) {
- return false
- }
- for k := 0; k < code_length; k++ {
- if !is_hex(parser.buffer, parser.buffer_pos+k) {
- yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
- start_mark, "did not find expected hexdecimal number")
- return false
- }
- value = (value << 4) + as_hex(parser.buffer, parser.buffer_pos+k)
- }
-
- // Check the value and write the character.
- if (value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF {
- yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
- start_mark, "found invalid Unicode character escape code")
- return false
- }
- if value <= 0x7F {
- s = append(s, byte(value))
- } else if value <= 0x7FF {
- s = append(s, byte(0xC0+(value>>6)))
- s = append(s, byte(0x80+(value&0x3F)))
- } else if value <= 0xFFFF {
- s = append(s, byte(0xE0+(value>>12)))
- s = append(s, byte(0x80+((value>>6)&0x3F)))
- s = append(s, byte(0x80+(value&0x3F)))
- } else {
- s = append(s, byte(0xF0+(value>>18)))
- s = append(s, byte(0x80+((value>>12)&0x3F)))
- s = append(s, byte(0x80+((value>>6)&0x3F)))
- s = append(s, byte(0x80+(value&0x3F)))
- }
-
- // Advance the pointer.
- for k := 0; k < code_length; k++ {
- skip(parser)
- }
- }
- } else {
- // It is a non-escaped non-blank character.
- s = read(parser, s)
- }
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
- }
-
- // Check if we are at the end of the scalar.
- if single {
- if parser.buffer[parser.buffer_pos] == '\'' {
- break
- }
- } else {
- if parser.buffer[parser.buffer_pos] == '"' {
- break
- }
- }
-
- // Consume blank characters.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) {
- if is_blank(parser.buffer, parser.buffer_pos) {
- // Consume a space or a tab character.
- if !leading_blanks {
- whitespaces = read(parser, whitespaces)
- } else {
- skip(parser)
- }
- } else {
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
-
- // Check if it is a first line break.
- if !leading_blanks {
- whitespaces = whitespaces[:0]
- leading_break = read_line(parser, leading_break)
- leading_blanks = true
- } else {
- trailing_breaks = read_line(parser, trailing_breaks)
- }
- }
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Join the whitespaces or fold line breaks.
- if leading_blanks {
- // Do we need to fold line breaks?
- if len(leading_break) > 0 && leading_break[0] == '\n' {
- if len(trailing_breaks) == 0 {
- s = append(s, ' ')
- } else {
- s = append(s, trailing_breaks...)
- }
- } else {
- s = append(s, leading_break...)
- s = append(s, trailing_breaks...)
- }
- trailing_breaks = trailing_breaks[:0]
- leading_break = leading_break[:0]
- } else {
- s = append(s, whitespaces...)
- whitespaces = whitespaces[:0]
- }
- }
-
- // Eat the right quote.
- skip(parser)
- end_mark := parser.mark
-
- // Create a token.
- *token = yaml_token_t{
- typ: yaml_SCALAR_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- value: s,
- style: yaml_SINGLE_QUOTED_SCALAR_STYLE,
- }
- if !single {
- token.style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
- }
- return true
-}
-
-// Scan a plain scalar.
-func yaml_parser_scan_plain_scalar(parser *yaml_parser_t, token *yaml_token_t) bool {
-
- var s, leading_break, trailing_breaks, whitespaces []byte
- var leading_blanks bool
- var indent = parser.indent + 1
-
- start_mark := parser.mark
- end_mark := parser.mark
-
- // Consume the content of the plain scalar.
- for {
- // Check for a document indicator.
- if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) {
- return false
- }
- if parser.mark.column == 0 &&
- ((parser.buffer[parser.buffer_pos+0] == '-' &&
- parser.buffer[parser.buffer_pos+1] == '-' &&
- parser.buffer[parser.buffer_pos+2] == '-') ||
- (parser.buffer[parser.buffer_pos+0] == '.' &&
- parser.buffer[parser.buffer_pos+1] == '.' &&
- parser.buffer[parser.buffer_pos+2] == '.')) &&
- is_blankz(parser.buffer, parser.buffer_pos+3) {
- break
- }
-
- // Check for a comment.
- if parser.buffer[parser.buffer_pos] == '#' {
- break
- }
-
- // Consume non-blank characters.
- for !is_blankz(parser.buffer, parser.buffer_pos) {
-
- // Check for 'x:x' in the flow context. TODO: Fix the test "spec-08-13".
- if parser.flow_level > 0 &&
- parser.buffer[parser.buffer_pos] == ':' &&
- !is_blankz(parser.buffer, parser.buffer_pos+1) {
- yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
- start_mark, "found unexpected ':'")
- return false
- }
-
- // Check for indicators that may end a plain scalar.
- if (parser.buffer[parser.buffer_pos] == ':' && is_blankz(parser.buffer, parser.buffer_pos+1)) ||
- (parser.flow_level > 0 &&
- (parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == ':' ||
- parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == '[' ||
- parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' ||
- parser.buffer[parser.buffer_pos] == '}')) {
- break
- }
-
- // Check if we need to join whitespaces and breaks.
- if leading_blanks || len(whitespaces) > 0 {
- if leading_blanks {
- // Do we need to fold line breaks?
- if leading_break[0] == '\n' {
- if len(trailing_breaks) == 0 {
- s = append(s, ' ')
- } else {
- s = append(s, trailing_breaks...)
- }
- } else {
- s = append(s, leading_break...)
- s = append(s, trailing_breaks...)
- }
- trailing_breaks = trailing_breaks[:0]
- leading_break = leading_break[:0]
- leading_blanks = false
- } else {
- s = append(s, whitespaces...)
- whitespaces = whitespaces[:0]
- }
- }
-
- // Copy the character.
- s = read(parser, s)
-
- end_mark = parser.mark
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
- }
-
- // Is it the end?
- if !(is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos)) {
- break
- }
-
- // Consume blank characters.
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
-
- for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) {
- if is_blank(parser.buffer, parser.buffer_pos) {
-
- // Check for tab character that abuse indentation.
- if leading_blanks && parser.mark.column < indent && is_tab(parser.buffer, parser.buffer_pos) {
- yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
- start_mark, "found a tab character that violate indentation")
- return false
- }
-
- // Consume a space or a tab character.
- if !leading_blanks {
- whitespaces = read(parser, whitespaces)
- } else {
- skip(parser)
- }
- } else {
- if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
- return false
- }
-
- // Check if it is a first line break.
- if !leading_blanks {
- whitespaces = whitespaces[:0]
- leading_break = read_line(parser, leading_break)
- leading_blanks = true
- } else {
- trailing_breaks = read_line(parser, trailing_breaks)
- }
- }
- if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
- return false
- }
- }
-
- // Check indentation level.
- if parser.flow_level == 0 && parser.mark.column < indent {
- break
- }
- }
-
- // Create a token.
- *token = yaml_token_t{
- typ: yaml_SCALAR_TOKEN,
- start_mark: start_mark,
- end_mark: end_mark,
- value: s,
- style: yaml_PLAIN_SCALAR_STYLE,
- }
-
- // Note that we change the 'simple_key_allowed' flag.
- if leading_blanks {
- parser.simple_key_allowed = true
- }
- return true
-}
diff --git a/newt/vendor/mynewt.apache.org/newt/yaml/shim.go b/newt/vendor/mynewt.apache.org/newt/yaml/shim.go
deleted file mode 100644
index b26c1cac..00000000
--- a/newt/vendor/mynewt.apache.org/newt/yaml/shim.go
+++ /dev/null
@@ -1,42 +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 yaml
-
-import (
- "errors"
-)
-
-// This function just wraps DecodeStream with the name "Unmarshal." This
-// allows this library to be used in place of other YAML decoding libraries.
-func Unmarshal(src []byte, dst interface{}) error {
- // The destination type must be a string->interface{} map or a pointer to
- // one. If the destination is something else, return an error.
- mapping, ok := dst.(map[string]interface{})
- if !ok {
- mPtr, ok := dst.(*map[string]interface{})
- if !ok {
- return errors.New("invalid dst type; expected " +
- "map[string]interface{} or *map[string]interface{}")
- }
- mapping = *mPtr
- }
-
- return DecodeStream(src, mapping)
-}
diff --git a/newt/vendor/mynewt.apache.org/newt/yaml/writerc.go b/newt/vendor/mynewt.apache.org/newt/yaml/writerc.go
deleted file mode 100644
index bc043120..00000000
--- a/newt/vendor/mynewt.apache.org/newt/yaml/writerc.go
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * This file is a Go port of its corresponding C file in libyaml. This port
- * was was copied from the yaml.v2 library. This file is licensed as follows:
- *
- * Copyright (c) 2006 Kirill Simonov
- *
- * 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.
- */
-
-package yaml
-
-// Set the writer error and return false.
-func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool {
- emitter.error = yaml_WRITER_ERROR
- emitter.problem = problem
- return false
-}
-
-// Flush the output buffer.
-func yaml_emitter_flush(emitter *yaml_emitter_t) bool {
- if emitter.write_handler == nil {
- panic("write handler not set")
- }
-
- // Check if the buffer is empty.
- if emitter.buffer_pos == 0 {
- return true
- }
-
- // If the output encoding is UTF-8, we don't need to recode the buffer.
- if emitter.encoding == yaml_UTF8_ENCODING {
- if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil {
- return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error())
- }
- emitter.buffer_pos = 0
- return true
- }
-
- // Recode the buffer into the raw buffer.
- var low, high int
- if emitter.encoding == yaml_UTF16LE_ENCODING {
- low, high = 0, 1
- } else {
- high, low = 1, 0
- }
-
- pos := 0
- for pos < emitter.buffer_pos {
- // See the "reader.c" code for more details on UTF-8 encoding. Note
- // that we assume that the buffer contains a valid UTF-8 sequence.
-
- // Read the next UTF-8 character.
- octet := emitter.buffer[pos]
-
- var w int
- var value rune
- switch {
- case octet&0x80 == 0x00:
- w, value = 1, rune(octet&0x7F)
- case octet&0xE0 == 0xC0:
- w, value = 2, rune(octet&0x1F)
- case octet&0xF0 == 0xE0:
- w, value = 3, rune(octet&0x0F)
- case octet&0xF8 == 0xF0:
- w, value = 4, rune(octet&0x07)
- }
- for k := 1; k < w; k++ {
- octet = emitter.buffer[pos+k]
- value = (value << 6) + (rune(octet) & 0x3F)
- }
- pos += w
-
- // Write the character.
- if value < 0x10000 {
- var b [2]byte
- b[high] = byte(value >> 8)
- b[low] = byte(value & 0xFF)
- emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1])
- } else {
- // Write the character using a surrogate pair (check "reader.c").
- var b [4]byte
- value -= 0x10000
- b[high] = byte(0xD8 + (value >> 18))
- b[low] = byte((value >> 10) & 0xFF)
- b[high+2] = byte(0xDC + ((value >> 8) & 0xFF))
- b[low+2] = byte(value & 0xFF)
- emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1], b[2], b[3])
- }
- }
-
- // Write the raw buffer.
- if err := emitter.write_handler(emitter, emitter.raw_buffer); err != nil {
- return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error())
- }
- emitter.buffer_pos = 0
- emitter.raw_buffer = emitter.raw_buffer[:0]
- return true
-}
diff --git a/newt/vendor/mynewt.apache.org/newt/yaml/yamlh.go b/newt/vendor/mynewt.apache.org/newt/yaml/yamlh.go
deleted file mode 100644
index 892061c1..00000000
--- a/newt/vendor/mynewt.apache.org/newt/yaml/yamlh.go
+++ /dev/null
@@ -1,754 +0,0 @@
-/**
- * This file is a Go port of its corresponding C file in libyaml. This port
- * was was copied from the yaml.v2 library. This file is licensed as follows:
- *
- * Copyright (c) 2006 Kirill Simonov
- *
- * 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.
- */
-
-package yaml
-
-import (
- "io"
-)
-
-// The version directive data.
-type yaml_version_directive_t struct {
- major int8 // The major version number.
- minor int8 // The minor version number.
-}
-
-// The tag directive data.
-type yaml_tag_directive_t struct {
- handle []byte // The tag handle.
- prefix []byte // The tag prefix.
-}
-
-type yaml_encoding_t int
-
-// The stream encoding.
-const (
- // Let the parser choose the encoding.
- yaml_ANY_ENCODING yaml_encoding_t = iota
-
- yaml_UTF8_ENCODING // The default UTF-8 encoding.
- yaml_UTF16LE_ENCODING // The UTF-16-LE encoding with BOM.
- yaml_UTF16BE_ENCODING // The UTF-16-BE encoding with BOM.
-)
-
-type yaml_break_t int
-
-// Line break types.
-const (
- // Let the parser choose the break type.
- yaml_ANY_BREAK yaml_break_t = iota
-
- yaml_CR_BREAK // Use CR for line breaks (Mac style).
- yaml_LN_BREAK // Use LN for line breaks (Unix style).
- yaml_CRLN_BREAK // Use CR LN for line breaks (DOS style).
-)
-
-type yaml_error_type_t int
-
-// Many bad things could happen with the parser and emitter.
-const (
- // No error is produced.
- yaml_NO_ERROR yaml_error_type_t = iota
-
- yaml_MEMORY_ERROR // Cannot allocate or reallocate a block of memory.
- yaml_READER_ERROR // Cannot read or decode the input stream.
- yaml_SCANNER_ERROR // Cannot scan the input stream.
- yaml_PARSER_ERROR // Cannot parse the input stream.
- yaml_COMPOSER_ERROR // Cannot compose a YAML document.
- yaml_WRITER_ERROR // Cannot write to the output stream.
- yaml_EMITTER_ERROR // Cannot emit a YAML stream.
-)
-
-// The pointer position.
-type yaml_mark_t struct {
- index int // The position index.
- line int // The position line.
- column int // The position column.
-}
-
-// Node Styles
-
-type yaml_style_t int8
-
-type yaml_scalar_style_t yaml_style_t
-
-// Scalar styles.
-const (
- // Let the emitter choose the style.
- yaml_ANY_SCALAR_STYLE yaml_scalar_style_t = iota
-
- yaml_PLAIN_SCALAR_STYLE // The plain scalar style.
- yaml_SINGLE_QUOTED_SCALAR_STYLE // The single-quoted scalar style.
- yaml_DOUBLE_QUOTED_SCALAR_STYLE // The double-quoted scalar style.
- yaml_LITERAL_SCALAR_STYLE // The literal scalar style.
- yaml_FOLDED_SCALAR_STYLE // The folded scalar style.
-)
-
-type yaml_sequence_style_t yaml_style_t
-
-// Sequence styles.
-const (
- // Let the emitter choose the style.
- yaml_ANY_SEQUENCE_STYLE yaml_sequence_style_t = iota
-
- yaml_BLOCK_SEQUENCE_STYLE // The block sequence style.
- yaml_FLOW_SEQUENCE_STYLE // The flow sequence style.
-)
-
-type yaml_mapping_style_t yaml_style_t
-
-// Mapping styles.
-const (
- // Let the emitter choose the style.
- yaml_ANY_MAPPING_STYLE yaml_mapping_style_t = iota
-
- yaml_BLOCK_MAPPING_STYLE // The block mapping style.
- yaml_FLOW_MAPPING_STYLE // The flow mapping style.
-)
-
-// Tokens
-
-type yaml_token_type_t int
-
-// Token types.
-const (
- // An empty token.
- yaml_NO_TOKEN yaml_token_type_t = iota
-
- yaml_STREAM_START_TOKEN // A STREAM-START token.
- yaml_STREAM_END_TOKEN // A STREAM-END token.
-
- yaml_VERSION_DIRECTIVE_TOKEN // A VERSION-DIRECTIVE token.
- yaml_TAG_DIRECTIVE_TOKEN // A TAG-DIRECTIVE token.
- yaml_DOCUMENT_START_TOKEN // A DOCUMENT-START token.
- yaml_DOCUMENT_END_TOKEN // A DOCUMENT-END token.
-
- yaml_BLOCK_SEQUENCE_START_TOKEN // A BLOCK-SEQUENCE-START token.
- yaml_BLOCK_MAPPING_START_TOKEN // A BLOCK-SEQUENCE-END token.
- yaml_BLOCK_END_TOKEN // A BLOCK-END token.
-
- yaml_FLOW_SEQUENCE_START_TOKEN // A FLOW-SEQUENCE-START token.
- yaml_FLOW_SEQUENCE_END_TOKEN // A FLOW-SEQUENCE-END token.
- yaml_FLOW_MAPPING_START_TOKEN // A FLOW-MAPPING-START token.
- yaml_FLOW_MAPPING_END_TOKEN // A FLOW-MAPPING-END token.
-
- yaml_BLOCK_ENTRY_TOKEN // A BLOCK-ENTRY token.
- yaml_FLOW_ENTRY_TOKEN // A FLOW-ENTRY token.
- yaml_KEY_TOKEN // A KEY token.
- yaml_VALUE_TOKEN // A VALUE token.
-
- yaml_ALIAS_TOKEN // An ALIAS token.
- yaml_ANCHOR_TOKEN // An ANCHOR token.
- yaml_TAG_TOKEN // A TAG token.
- yaml_SCALAR_TOKEN // A SCALAR token.
-)
-
-func (tt yaml_token_type_t) String() string {
- switch tt {
- case yaml_NO_TOKEN:
- return "yaml_NO_TOKEN"
- case yaml_STREAM_START_TOKEN:
- return "yaml_STREAM_START_TOKEN"
- case yaml_STREAM_END_TOKEN:
- return "yaml_STREAM_END_TOKEN"
- case yaml_VERSION_DIRECTIVE_TOKEN:
- return "yaml_VERSION_DIRECTIVE_TOKEN"
- case yaml_TAG_DIRECTIVE_TOKEN:
- return "yaml_TAG_DIRECTIVE_TOKEN"
- case yaml_DOCUMENT_START_TOKEN:
- return "yaml_DOCUMENT_START_TOKEN"
- case yaml_DOCUMENT_END_TOKEN:
- return "yaml_DOCUMENT_END_TOKEN"
- case yaml_BLOCK_SEQUENCE_START_TOKEN:
- return "yaml_BLOCK_SEQUENCE_START_TOKEN"
- case yaml_BLOCK_MAPPING_START_TOKEN:
- return "yaml_BLOCK_MAPPING_START_TOKEN"
- case yaml_BLOCK_END_TOKEN:
- return "yaml_BLOCK_END_TOKEN"
- case yaml_FLOW_SEQUENCE_START_TOKEN:
- return "yaml_FLOW_SEQUENCE_START_TOKEN"
- case yaml_FLOW_SEQUENCE_END_TOKEN:
- return "yaml_FLOW_SEQUENCE_END_TOKEN"
- case yaml_FLOW_MAPPING_START_TOKEN:
- return "yaml_FLOW_MAPPING_START_TOKEN"
- case yaml_FLOW_MAPPING_END_TOKEN:
- return "yaml_FLOW_MAPPING_END_TOKEN"
- case yaml_BLOCK_ENTRY_TOKEN:
- return "yaml_BLOCK_ENTRY_TOKEN"
- case yaml_FLOW_ENTRY_TOKEN:
- return "yaml_FLOW_ENTRY_TOKEN"
- case yaml_KEY_TOKEN:
- return "yaml_KEY_TOKEN"
- case yaml_VALUE_TOKEN:
- return "yaml_VALUE_TOKEN"
- case yaml_ALIAS_TOKEN:
- return "yaml_ALIAS_TOKEN"
- case yaml_ANCHOR_TOKEN:
- return "yaml_ANCHOR_TOKEN"
- case yaml_TAG_TOKEN:
- return "yaml_TAG_TOKEN"
- case yaml_SCALAR_TOKEN:
- return "yaml_SCALAR_TOKEN"
- }
- return "<unknown token>"
-}
-
-// The token structure.
-type yaml_token_t struct {
- // The token type.
- typ yaml_token_type_t
-
- // The start/end of the token.
- start_mark, end_mark yaml_mark_t
-
- // The stream encoding (for yaml_STREAM_START_TOKEN).
- encoding yaml_encoding_t
-
- // The alias/anchor/scalar value or tag/tag directive handle
- // (for yaml_ALIAS_TOKEN, yaml_ANCHOR_TOKEN, yaml_SCALAR_TOKEN, yaml_TAG_TOKEN, yaml_TAG_DIRECTIVE_TOKEN).
- value []byte
-
- // The tag suffix (for yaml_TAG_TOKEN).
- suffix []byte
-
- // The tag directive prefix (for yaml_TAG_DIRECTIVE_TOKEN).
- prefix []byte
-
- // The scalar style (for yaml_SCALAR_TOKEN).
- style yaml_scalar_style_t
-
- // The version directive major/minor (for yaml_VERSION_DIRECTIVE_TOKEN).
- major, minor int8
-}
-
-// Events
-
-type yaml_event_type_t int8
-
-// Event types.
-const (
- // An empty event.
- yaml_NO_EVENT yaml_event_type_t = iota
-
- yaml_STREAM_START_EVENT // A STREAM-START event.
- yaml_STREAM_END_EVENT // A STREAM-END event.
- yaml_DOCUMENT_START_EVENT // A DOCUMENT-START event.
- yaml_DOCUMENT_END_EVENT // A DOCUMENT-END event.
- yaml_ALIAS_EVENT // An ALIAS event.
- yaml_SCALAR_EVENT // A SCALAR event.
- yaml_SEQUENCE_START_EVENT // A SEQUENCE-START event.
- yaml_SEQUENCE_END_EVENT // A SEQUENCE-END event.
- yaml_MAPPING_START_EVENT // A MAPPING-START event.
- yaml_MAPPING_END_EVENT // A MAPPING-END event.
-)
-
-var constNames = map[yaml_event_type_t]string{
- yaml_STREAM_START_EVENT: "yaml_STREAM_START_EVENT",
- yaml_STREAM_END_EVENT: "yaml_STREAM_END_EVENT",
- yaml_DOCUMENT_START_EVENT: "yaml_DOCUMENT_START_EVENT",
- yaml_DOCUMENT_END_EVENT: "yaml_DOCUMENT_END_EVENT",
- yaml_ALIAS_EVENT: "yaml_ALIAS_EVENT",
- yaml_SCALAR_EVENT: "yaml_SCALAR_EVENT",
- yaml_SEQUENCE_START_EVENT: "yaml_SEQUENCE_START_EVENT",
- yaml_SEQUENCE_END_EVENT: "yaml_SEQUENCE_END_EVENT",
- yaml_MAPPING_START_EVENT: "yaml_MAPPING_START_EVENT",
- yaml_MAPPING_END_EVENT: "yaml_MAPPING_END_EVENT",
-}
-
-// The event structure.
-type yaml_event_t struct {
-
- // The event type.
- typ yaml_event_type_t
-
- // The start and end of the event.
- start_mark, end_mark yaml_mark_t
-
- // The document encoding (for yaml_STREAM_START_EVENT).
- encoding yaml_encoding_t
-
- // The version directive (for yaml_DOCUMENT_START_EVENT).
- version_directive *yaml_version_directive_t
-
- // The list of tag directives (for yaml_DOCUMENT_START_EVENT).
- tag_directives []yaml_tag_directive_t
-
- // The anchor (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_ALIAS_EVENT).
- anchor []byte
-
- // The tag (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT).
- tag []byte
-
- // The scalar value (for yaml_SCALAR_EVENT).
- value []byte
-
- // Is the document start/end indicator implicit, or the tag optional?
- // (for yaml_DOCUMENT_START_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_SCALAR_EVENT).
- implicit bool
-
- // Is the tag optional for any non-plain style? (for yaml_SCALAR_EVENT).
- quoted_implicit bool
-
- // The style (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT).
- style yaml_style_t
-}
-
-func (e *yaml_event_t) scalar_style() yaml_scalar_style_t { return yaml_scalar_style_t(e.style) }
-func (e *yaml_event_t) sequence_style() yaml_sequence_style_t { return yaml_sequence_style_t(e.style) }
-func (e *yaml_event_t) mapping_style() yaml_mapping_style_t { return yaml_mapping_style_t(e.style) }
-
-// Nodes
-
-const (
- yaml_NULL_TAG = "tag:yaml.org,2002:null" // The tag !!null with the only possible value: null.
- yaml_BOOL_TAG = "tag:yaml.org,2002:bool" // The tag !!bool with the values: true and false.
- yaml_STR_TAG = "tag:yaml.org,2002:str" // The tag !!str for string values.
- yaml_INT_TAG = "tag:yaml.org,2002:int" // The tag !!int for integer values.
- yaml_FLOAT_TAG = "tag:yaml.org,2002:float" // The tag !!float for float values.
- yaml_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp" // The tag !!timestamp for date and time values.
-
- yaml_SEQ_TAG = "tag:yaml.org,2002:seq" // The tag !!seq is used to denote sequences.
- yaml_MAP_TAG = "tag:yaml.org,2002:map" // The tag !!map is used to denote mapping.
-
- // Not in original libyaml.
- yaml_BINARY_TAG = "tag:yaml.org,2002:binary"
- yaml_MERGE_TAG = "tag:yaml.org,2002:merge"
-
- yaml_DEFAULT_SCALAR_TAG = yaml_STR_TAG // The default scalar tag is !!str.
- yaml_DEFAULT_SEQUENCE_TAG = yaml_SEQ_TAG // The default sequence tag is !!seq.
- yaml_DEFAULT_MAPPING_TAG = yaml_MAP_TAG // The default mapping tag is !!map.
-)
-
-type yaml_node_type_t int
-
-// Node types.
-const (
- // An empty node.
- yaml_NO_NODE yaml_node_type_t = iota
-
- yaml_SCALAR_NODE // A scalar node.
- yaml_SEQUENCE_NODE // A sequence node.
- yaml_MAPPING_NODE // A mapping node.
-)
-
-// An element of a sequence node.
-type yaml_node_item_t int
-
-// An element of a mapping node.
-type yaml_node_pair_t struct {
- key int // The key of the element.
- value int // The value of the element.
-}
-
-// The node structure.
-type yaml_node_t struct {
- typ yaml_node_type_t // The node type.
- tag []byte // The node tag.
-
- // The node data.
-
- // The scalar parameters (for yaml_SCALAR_NODE).
- scalar struct {
- value []byte // The scalar value.
- length int // The length of the scalar value.
- style yaml_scalar_style_t // The scalar style.
- }
-
- // The sequence parameters (for YAML_SEQUENCE_NODE).
- sequence struct {
- items_data []yaml_node_item_t // The stack of sequence items.
- style yaml_sequence_style_t // The sequence style.
- }
-
- // The mapping parameters (for yaml_MAPPING_NODE).
- mapping struct {
- pairs_data []yaml_node_pair_t // The stack of mapping pairs (key, value).
- pairs_start *yaml_node_pair_t // The beginning of the stack.
- pairs_end *yaml_node_pair_t // The end of the stack.
- pairs_top *yaml_node_pair_t // The top of the stack.
- style yaml_mapping_style_t // The mapping style.
- }
-
- start_mark yaml_mark_t // The beginning of the node.
- end_mark yaml_mark_t // The end of the node.
-
-}
-
-// The document structure.
-type yaml_document_t struct {
-
- // The document nodes.
- nodes []yaml_node_t
-
- // The version directive.
- version_directive *yaml_version_directive_t
-
- // The list of tag directives.
- tag_directives_data []yaml_tag_directive_t
- tag_directives_start int // The beginning of the tag directives list.
- tag_directives_end int // The end of the tag directives list.
-
- start_implicit int // Is the document start indicator implicit?
- end_implicit int // Is the document end indicator implicit?
-
- // The start/end of the document.
- start_mark, end_mark yaml_mark_t
-}
-
-// The prototype of a read handler.
-//
-// The read handler is called when the parser needs to read more bytes from the
-// source. The handler should write not more than size bytes to the buffer.
-// The number of written bytes should be set to the size_read variable.
-//
-// [in,out] data A pointer to an application data specified by
-// yaml_parser_set_input().
-// [out] buffer The buffer to write the data from the source.
-// [in] size The size of the buffer.
-// [out] size_read The actual number of bytes read from the source.
-//
-// On success, the handler should return 1. If the handler failed,
-// the returned value should be 0. On EOF, the handler should set the
-// size_read to 0 and return 1.
-type yaml_read_handler_t func(parser *yaml_parser_t, buffer []byte) (n int, err error)
-
-// This structure holds information about a potential simple key.
-type yaml_simple_key_t struct {
- possible bool // Is a simple key possible?
- required bool // Is a simple key required?
- token_number int // The number of the token.
- mark yaml_mark_t // The position mark.
-}
-
-// The states of the parser.
-type yaml_parser_state_t int
-
-const (
- yaml_PARSE_STREAM_START_STATE yaml_parser_state_t = iota
-
- yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE // Expect the beginning of an implicit document.
- yaml_PARSE_DOCUMENT_START_STATE // Expect DOCUMENT-START.
- yaml_PARSE_DOCUMENT_CONTENT_STATE // Expect the content of a document.
- yaml_PARSE_DOCUMENT_END_STATE // Expect DOCUMENT-END.
- yaml_PARSE_BLOCK_NODE_STATE // Expect a block node.
- yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE // Expect a block node or indentless sequence.
- yaml_PARSE_FLOW_NODE_STATE // Expect a flow node.
- yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a block sequence.
- yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE // Expect an entry of a block sequence.
- yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE // Expect an entry of an indentless sequence.
- yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping.
- yaml_PARSE_BLOCK_MAPPING_KEY_STATE // Expect a block mapping key.
- yaml_PARSE_BLOCK_MAPPING_VALUE_STATE // Expect a block mapping value.
- yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a flow sequence.
- yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE // Expect an entry of a flow sequence.
- yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE // Expect a key of an ordered mapping.
- yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE // Expect a value of an ordered mapping.
- yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE // Expect the and of an ordered mapping entry.
- yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping.
- yaml_PARSE_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping.
- yaml_PARSE_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping.
- yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE // Expect an empty value of a flow mapping.
- yaml_PARSE_END_STATE // Expect nothing.
-)
-
-func (ps yaml_parser_state_t) String() string {
- switch ps {
- case yaml_PARSE_STREAM_START_STATE:
- return "yaml_PARSE_STREAM_START_STATE"
- case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE:
- return "yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE"
- case yaml_PARSE_DOCUMENT_START_STATE:
- return "yaml_PARSE_DOCUMENT_START_STATE"
- case yaml_PARSE_DOCUMENT_CONTENT_STATE:
- return "yaml_PARSE_DOCUMENT_CONTENT_STATE"
- case yaml_PARSE_DOCUMENT_END_STATE:
- return "yaml_PARSE_DOCUMENT_END_STATE"
- case yaml_PARSE_BLOCK_NODE_STATE:
- return "yaml_PARSE_BLOCK_NODE_STATE"
- case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE:
- return "yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE"
- case yaml_PARSE_FLOW_NODE_STATE:
- return "yaml_PARSE_FLOW_NODE_STATE"
- case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE:
- return "yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE"
- case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE:
- return "yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE"
- case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE:
- return "yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE"
- case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE:
- return "yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE"
- case yaml_PARSE_BLOCK_MAPPING_KEY_STATE:
- return "yaml_PARSE_BLOCK_MAPPING_KEY_STATE"
- case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE:
- return "yaml_PARSE_BLOCK_MAPPING_VALUE_STATE"
- case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE:
- return "yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE"
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE:
- return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE"
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE:
- return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE"
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE:
- return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE"
- case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE:
- return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE"
- case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE:
- return "yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE"
- case yaml_PARSE_FLOW_MAPPING_KEY_STATE:
- return "yaml_PARSE_FLOW_MAPPING_KEY_STATE"
- case yaml_PARSE_FLOW_MAPPING_VALUE_STATE:
- return "yaml_PARSE_FLOW_MAPPING_VALUE_STATE"
- case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE:
- return "yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE"
- case yaml_PARSE_END_STATE:
- return "yaml_PARSE_END_STATE"
- }
- return "<unknown parser state>"
-}
-
-// This structure holds aliases data.
-type yaml_alias_data_t struct {
- anchor []byte // The anchor.
- index int // The node id.
- mark yaml_mark_t // The anchor mark.
-}
-
-// The parser structure.
-//
-// All members are internal. Manage the structure using the
-// yaml_parser_ family of functions.
-type yaml_parser_t struct {
-
- // Error handling
-
- error yaml_error_type_t // Error type.
-
- problem string // Error description.
-
- // The byte about which the problem occured.
- problem_offset int
- problem_value int
- problem_mark yaml_mark_t
-
- // The error context.
- context string
- context_mark yaml_mark_t
-
- // Reader stuff
-
- read_handler yaml_read_handler_t // Read handler.
-
- input_file io.Reader // File input data.
- input []byte // String input data.
- input_pos int
-
- eof bool // EOF flag
-
- buffer []byte // The working buffer.
- buffer_pos int // The current position of the buffer.
-
- unread int // The number of unread characters in the buffer.
-
- raw_buffer []byte // The raw buffer.
- raw_buffer_pos int // The current position of the buffer.
-
- encoding yaml_encoding_t // The input encoding.
-
- offset int // The offset of the current position (in bytes).
- mark yaml_mark_t // The mark of the current position.
-
- // Scanner stuff
-
- stream_start_produced bool // Have we started to scan the input stream?
- stream_end_produced bool // Have we reached the end of the input stream?
-
- flow_level int // The number of unclosed '[' and '{' indicators.
-
- tokens []yaml_token_t // The tokens queue.
- tokens_head int // The head of the tokens queue.
- tokens_parsed int // The number of tokens fetched from the queue.
- token_available bool // Does the tokens queue contain a token ready for dequeueing.
-
- indent int // The current indentation level.
- indents []int // The indentation levels stack.
-
- simple_key_allowed bool // May a simple key occur at the current position?
- simple_keys []yaml_simple_key_t // The stack of simple keys.
-
- // Parser stuff
-
- state yaml_parser_state_t // The current parser state.
- states []yaml_parser_state_t // The parser states stack.
- marks []yaml_mark_t // The stack of marks.
- tag_directives []yaml_tag_directive_t // The list of TAG directives.
-
- // Dumper stuff
-
- aliases []yaml_alias_data_t // The alias data.
-
- document *yaml_document_t // The currently parsed document.
-}
-
-// Emitter Definitions
-
-// The prototype of a write handler.
-//
-// The write handler is called when the emitter needs to flush the accumulated
-// characters to the output. The handler should write @a size bytes of the
-// @a buffer to the output.
-//
-// @param[in,out] data A pointer to an application data specified by
-// yaml_emitter_set_output().
-// @param[in] buffer The buffer with bytes to be written.
-// @param[in] size The size of the buffer.
-//
-// @returns On success, the handler should return @c 1. If the handler failed,
-// the returned value should be @c 0.
-//
-type yaml_write_handler_t func(emitter *yaml_emitter_t, buffer []byte) error
-
-type yaml_emitter_state_t int
-
-// The emitter states.
-const (
- // Expect STREAM-START.
- yaml_EMIT_STREAM_START_STATE yaml_emitter_state_t = iota
-
- yaml_EMIT_FIRST_DOCUMENT_START_STATE // Expect the first DOCUMENT-START or STREAM-END.
- yaml_EMIT_DOCUMENT_START_STATE // Expect DOCUMENT-START or STREAM-END.
- yaml_EMIT_DOCUMENT_CONTENT_STATE // Expect the content of a document.
- yaml_EMIT_DOCUMENT_END_STATE // Expect DOCUMENT-END.
- yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a flow sequence.
- yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE // Expect an item of a flow sequence.
- yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping.
- yaml_EMIT_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping.
- yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a flow mapping.
- yaml_EMIT_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping.
- yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a block sequence.
- yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE // Expect an item of a block sequence.
- yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping.
- yaml_EMIT_BLOCK_MAPPING_KEY_STATE // Expect the key of a block mapping.
- yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a block mapping.
- yaml_EMIT_BLOCK_MAPPING_VALUE_STATE // Expect a value of a block mapping.
- yaml_EMIT_END_STATE // Expect nothing.
-)
-
-// The emitter structure.
-//
-// All members are internal. Manage the structure using the @c yaml_emitter_
-// family of functions.
-type yaml_emitter_t struct {
-
- // Error handling
-
- error yaml_error_type_t // Error type.
- problem string // Error description.
-
- // Writer stuff
-
- write_handler yaml_write_handler_t // Write handler.
-
- output_buffer *[]byte // String output data.
- output_file io.Writer // File output data.
-
- buffer []byte // The working buffer.
- buffer_pos int // The current position of the buffer.
-
- raw_buffer []byte // The raw buffer.
- raw_buffer_pos int // The current position of the buffer.
-
- encoding yaml_encoding_t // The stream encoding.
-
- // Emitter stuff
-
- canonical bool // If the output is in the canonical style?
- best_indent int // The number of indentation spaces.
- best_width int // The preferred width of the output lines.
- unicode bool // Allow unescaped non-ASCII characters?
- line_break yaml_break_t // The preferred line break.
-
- state yaml_emitter_state_t // The current emitter state.
- states []yaml_emitter_state_t // The stack of states.
-
- events []yaml_event_t // The event queue.
- events_head int // The head of the event queue.
-
- indents []int // The stack of indentation levels.
-
- tag_directives []yaml_tag_directive_t // The list of tag directives.
-
- indent int // The current indentation level.
-
- flow_level int // The current flow level.
-
- root_context bool // Is it the document root context?
- sequence_context bool // Is it a sequence context?
- mapping_context bool // Is it a mapping context?
- simple_key_context bool // Is it a simple mapping key context?
-
- line int // The current line.
- column int // The current column.
- whitespace bool // If the last character was a whitespace?
- indention bool // If the last character was an indentation character (' ', '-', '?', ':')?
- open_ended bool // If an explicit document end is required?
-
- // Anchor analysis.
- anchor_data struct {
- anchor []byte // The anchor value.
- alias bool // Is it an alias?
- }
-
- // Tag analysis.
- tag_data struct {
- handle []byte // The tag handle.
- suffix []byte // The tag suffix.
- }
-
- // Scalar analysis.
- scalar_data struct {
- value []byte // The scalar value.
- multiline bool // Does the scalar contain line breaks?
- flow_plain_allowed bool // Can the scalar be expessed in the flow plain style?
- block_plain_allowed bool // Can the scalar be expressed in the block plain style?
- single_quoted_allowed bool // Can the scalar be expressed in the single quoted style?
- block_allowed bool // Can the scalar be expressed in the literal or folded styles?
- style yaml_scalar_style_t // The output style.
- }
-
- // Dumper stuff
-
- opened bool // If the stream was already opened?
- closed bool // If the stream was already closed?
-
- // The information associated with the document nodes.
- anchors *struct {
- references int // The number of references.
- anchor int // The anchor id.
- serialized bool // If the node has been emitted?
- }
-
- last_anchor_id int // The last assigned anchor id.
-
- document *yaml_document_t // The currently emitted document.
-}
diff --git a/newt/vendor/mynewt.apache.org/newt/yaml/yamlprivateh.go b/newt/vendor/mynewt.apache.org/newt/yaml/yamlprivateh.go
deleted file mode 100644
index 38c4cbe7..00000000
--- a/newt/vendor/mynewt.apache.org/newt/yaml/yamlprivateh.go
+++ /dev/null
@@ -1,198 +0,0 @@
-/**
- * This file is a Go port of its corresponding C file in libyaml. This port
- * was was copied from the yaml.v2 library. This file is licensed as follows:
- *
- * Copyright (c) 2006 Kirill Simonov
- *
- * 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.
- */
-
-package yaml
-
-const (
- // The size of the input raw buffer.
- input_raw_buffer_size = 512
-
- // The size of the input buffer.
- // It should be possible to decode the whole raw buffer.
- input_buffer_size = input_raw_buffer_size * 3
-
- // The size of the output buffer.
- output_buffer_size = 128
-
- // The size of the output raw buffer.
- // It should be possible to encode the whole output buffer.
- output_raw_buffer_size = (output_buffer_size*2 + 2)
-
- // The size of other stacks and queues.
- initial_stack_size = 16
- initial_queue_size = 16
- initial_string_size = 16
-)
-
-// Check if the character at the specified position is an alphabetical
-// character, a digit, '_', or '-'.
-func is_alpha(b []byte, i int) bool {
- return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-'
-}
-
-// Check if the character at the specified position is a digit.
-func is_digit(b []byte, i int) bool {
- return b[i] >= '0' && b[i] <= '9'
-}
-
-// Get the value of a digit.
-func as_digit(b []byte, i int) int {
- return int(b[i]) - '0'
-}
-
-// Check if the character at the specified position is a hex-digit.
-func is_hex(b []byte, i int) bool {
- return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f'
-}
-
-// Get the value of a hex-digit.
-func as_hex(b []byte, i int) int {
- bi := b[i]
- if bi >= 'A' && bi <= 'F' {
- return int(bi) - 'A' + 10
- }
- if bi >= 'a' && bi <= 'f' {
- return int(bi) - 'a' + 10
- }
- return int(bi) - '0'
-}
-
-// Check if the character is ASCII.
-func is_ascii(b []byte, i int) bool {
- return b[i] <= 0x7F
-}
-
-// Check if the character at the start of the buffer can be printed unescaped.
-func is_printable(b []byte, i int) bool {
- return ((b[i] == 0x0A) || // . == #x0A
- (b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E
- (b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF
- (b[i] > 0xC2 && b[i] < 0xED) ||
- (b[i] == 0xED && b[i+1] < 0xA0) ||
- (b[i] == 0xEE) ||
- (b[i] == 0xEF && // #xE000 <= . <= #xFFFD
- !(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF
- !(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF))))
-}
-
-// Check if the character at the specified position is NUL.
-func is_z(b []byte, i int) bool {
- return b[i] == 0x00
-}
-
-// Check if the beginning of the buffer is a BOM.
-func is_bom(b []byte, i int) bool {
- return b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF
-}
-
-// Check if the character at the specified position is space.
-func is_space(b []byte, i int) bool {
- return b[i] == ' '
-}
-
-// Check if the character at the specified position is tab.
-func is_tab(b []byte, i int) bool {
- return b[i] == '\t'
-}
-
-// Check if the character at the specified position is blank (space or tab).
-func is_blank(b []byte, i int) bool {
- //return is_space(b, i) || is_tab(b, i)
- return b[i] == ' ' || b[i] == '\t'
-}
-
-// Check if the character at the specified position is a line break.
-func is_break(b []byte, i int) bool {
- return (b[i] == '\r' || // CR (#xD)
- b[i] == '\n' || // LF (#xA)
- b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029)
-}
-
-func is_crlf(b []byte, i int) bool {
- return b[i] == '\r' && b[i+1] == '\n'
-}
-
-// Check if the character is a line break or NUL.
-func is_breakz(b []byte, i int) bool {
- //return is_break(b, i) || is_z(b, i)
- return ( // is_break:
- b[i] == '\r' || // CR (#xD)
- b[i] == '\n' || // LF (#xA)
- b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)
- // is_z:
- b[i] == 0)
-}
-
-// Check if the character is a line break, space, or NUL.
-func is_spacez(b []byte, i int) bool {
- //return is_space(b, i) || is_breakz(b, i)
- return ( // is_space:
- b[i] == ' ' ||
- // is_breakz:
- b[i] == '\r' || // CR (#xD)
- b[i] == '\n' || // LF (#xA)
- b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)
- b[i] == 0)
-}
-
-// Check if the character is a line break, space, tab, or NUL.
-func is_blankz(b []byte, i int) bool {
- //return is_blank(b, i) || is_breakz(b, i)
- return ( // is_blank:
- b[i] == ' ' || b[i] == '\t' ||
- // is_breakz:
- b[i] == '\r' || // CR (#xD)
- b[i] == '\n' || // LF (#xA)
- b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
- b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)
- b[i] == 0)
-}
-
-// Determine the width of the character.
-func width(b byte) int {
- // Don't replace these by a switch without first
- // confirming that it is being inlined.
- if b&0x80 == 0x00 {
- return 1
- }
- if b&0xE0 == 0xC0 {
- return 2
- }
- if b&0xF0 == 0xE0 {
- return 3
- }
- if b&0xF8 == 0xF0 {
- return 4
- }
- return 0
-
-}
diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go
index c671644d..31473cbb 100644
--- a/newtmgr/cli/image.go
+++ b/newtmgr/cli/image.go
@@ -558,7 +558,6 @@ func imageEraseCmd(cmd *cobra.Command, args []string) {
}
}
-
func imageCmd() *cobra.Command {
imageCmd := &cobra.Command{
Use: "image",
diff --git a/newtmgr/protocol/imagedefs.go b/newtmgr/protocol/imagedefs.go
index 5820ce78..8a7a6b26 100644
--- a/newtmgr/protocol/imagedefs.go
+++ b/newtmgr/protocol/imagedefs.go
@@ -32,7 +32,7 @@ const (
IMGMGR_NMGR_ID_UPLOAD = 1
IMGMGR_NMGR_ID_CORELIST = 3
IMGMGR_NMGR_ID_CORELOAD = 4
- IMGMGR_NMGR_ID_ERASE = 5
+ IMGMGR_NMGR_ID_ERASE = 5
)
type SplitStatus int
diff --git a/newtmgr/protocol/runtest.go b/newtmgr/protocol/runtest.go
index 218ef866..09ea2671 100644
--- a/newtmgr/protocol/runtest.go
+++ b/newtmgr/protocol/runtest.go
@@ -27,8 +27,8 @@ import (
)
const (
- RUN_NMGR_OP_TEST = 0
- RUN_NMGR_OP_LIST = 1
+ RUN_NMGR_OP_TEST = 0
+ RUN_NMGR_OP_LIST = 1
)
/*
@@ -40,18 +40,18 @@ const (
* test infrastructure.
*/
type RunTestReq struct {
- Testname string `codec:"testname"`
- Token string `codec:"token"`
+ Testname string `codec:"testname"`
+ Token string `codec:"token"`
}
func NewRunTestReq() (*RunTestReq, error) {
- s := &RunTestReq{}
+ s := &RunTestReq{}
- return s, nil
+ return s, nil
}
func (sr *RunTestReq) Encode() (*NmgrReq, error) {
- nmr, err := NewNmgrReq()
+ nmr, err := NewNmgrReq()
if err != nil {
return nil, err
}
@@ -59,34 +59,34 @@ func (sr *RunTestReq) Encode() (*NmgrReq, error) {
nmr.Op = NMGR_OP_WRITE
nmr.Flags = 0
nmr.Group = NMGR_GROUP_ID_RUN
- nmr.Id = RUN_NMGR_OP_TEST
- req := &RunTestReq{
- Testname: sr.Testname,
- Token: sr.Token,
- }
+ nmr.Id = RUN_NMGR_OP_TEST
+ req := &RunTestReq{
+ Testname: sr.Testname,
+ Token: sr.Token,
+ }
- data := make([]byte, 0)
+ data := make([]byte, 0)
enc := codec.NewEncoderBytes(&data, new(codec.CborHandle))
enc.Encode(req)
nmr.Data = data
nmr.Len = uint16(len(data))
- return nmr, nil
+ return nmr, nil
}
type RunTestRsp struct {
- ReturnCode int `codec:"rc"`
+ ReturnCode int `codec:"rc"`
}
func DecodeRunTestResponse(data []byte) (*RunTestRsp, error) {
- var resp RunTestRsp
+ var resp RunTestRsp
dec := codec.NewDecoderBytes(data, new(codec.CborHandle))
err := dec.Decode(&resp)
if err != nil {
return nil, util.NewNewtError(fmt.Sprintf("Invalid response: %s",
- err.Error()))
+ err.Error()))
}
return &resp, nil
@@ -100,49 +100,49 @@ type RunListReq struct {
}
type RunListRsp struct {
- ReturnCode int `codec:"rc"`
- List []string `codec:"run_list"`
+ ReturnCode int `codec:"rc"`
+ List []string `codec:"run_list"`
}
func NewRunListReq() (*RunListReq, error) {
- s := &RunListReq{}
+ s := &RunListReq{}
- return s, nil
+ return s, nil
}
func (sr *RunListReq) Encode() (*NmgrReq, error) {
- nmr, err := NewNmgrReq()
- if err != nil {
- return nil, err
- }
+ nmr, err := NewNmgrReq()
+ if err != nil {
+ return nil, err
+ }
- nmr.Op = NMGR_OP_READ
- nmr.Flags = 0
- nmr.Group = NMGR_GROUP_ID_RUN
- nmr.Id = RUN_NMGR_OP_LIST
+ nmr.Op = NMGR_OP_READ
+ nmr.Flags = 0
+ nmr.Group = NMGR_GROUP_ID_RUN
+ nmr.Id = RUN_NMGR_OP_LIST
- req := &RunListReq{}
+ req := &RunListReq{}
- data := make([]byte, 0)
- enc := codec.NewEncoderBytes(&data, new(codec.CborHandle))
- enc.Encode(req)
+ data := make([]byte, 0)
+ enc := codec.NewEncoderBytes(&data, new(codec.CborHandle))
+ enc.Encode(req)
- nmr.Data = data
- nmr.Len = uint16(len(data))
+ nmr.Data = data
+ nmr.Len = uint16(len(data))
- return nmr, nil
+ return nmr, nil
}
func DecodeRunListResponse(data []byte) (*RunListRsp, error) {
- var resp RunListRsp
+ var resp RunListRsp
- dec := codec.NewDecoderBytes(data, new(codec.CborHandle))
- err := dec.Decode(&resp)
- if err != nil {
- return nil,
- util.NewNewtError(fmt.Sprintf("Invalid incoming cbor: %s",
- err.Error()))
- }
+ dec := codec.NewDecoderBytes(data, new(codec.CborHandle))
+ err := dec.Decode(&resp)
+ if err != nil {
+ return nil,
+ util.NewNewtError(fmt.Sprintf("Invalid incoming cbor: %s",
+ err.Error()))
+ }
- return &resp, nil
+ return &resp, nil
}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/.gitignore b/vendor/github.com/Sirupsen/logrus/.gitignore
similarity index 100%
rename from newt/vendor/github.com/Sirupsen/logrus/.gitignore
rename to vendor/github.com/Sirupsen/logrus/.gitignore
diff --git a/vendor/github.com/Sirupsen/logrus/.travis.yml b/vendor/github.com/Sirupsen/logrus/.travis.yml
new file mode 100644
index 00000000..a23296a5
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/.travis.yml
@@ -0,0 +1,15 @@
+language: go
+go:
+ - 1.6.x
+ - 1.7.x
+ - 1.8.x
+ - tip
+env:
+ - GOMAXPROCS=4 GORACE=halt_on_error=1
+install:
+ - go get github.com/stretchr/testify/assert
+ - go get gopkg.in/gemnasium/logrus-airbrake-hook.v2
+ - go get golang.org/x/sys/unix
+ - go get golang.org/x/sys/windows
+script:
+ - go test -race -v ./...
diff --git a/vendor/github.com/Sirupsen/logrus/CHANGELOG.md b/vendor/github.com/Sirupsen/logrus/CHANGELOG.md
new file mode 100644
index 00000000..8236d8b6
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/CHANGELOG.md
@@ -0,0 +1,113 @@
+# 1.0.3
+
+* Replace example files with testable examples
+
+# 1.0.2
+
+* bug: quote non-string values in text formatter (#583)
+* Make (*Logger) SetLevel a public method
+
+# 1.0.1
+
+* bug: fix escaping in text formatter (#575)
+
+# 1.0.0
+
+* Officially changed name to lower-case
+* bug: colors on Windows 10 (#541)
+* bug: fix race in accessing level (#512)
+
+# 0.11.5
+
+* feature: add writer and writerlevel to entry (#372)
+
+# 0.11.4
+
+* bug: fix undefined variable on solaris (#493)
+
+# 0.11.3
+
+* formatter: configure quoting of empty values (#484)
+* formatter: configure quoting character (default is `"`) (#484)
+* bug: fix not importing io correctly in non-linux environments (#481)
+
+# 0.11.2
+
+* bug: fix windows terminal detection (#476)
+
+# 0.11.1
+
+* bug: fix tty detection with custom out (#471)
+
+# 0.11.0
+
+* performance: Use bufferpool to allocate (#370)
+* terminal: terminal detection for app-engine (#343)
+* feature: exit handler (#375)
+
+# 0.10.0
+
+* feature: Add a test hook (#180)
+* feature: `ParseLevel` is now case-insensitive (#326)
+* feature: `FieldLogger` interface that generalizes `Logger` and `Entry` (#308)
+* performance: avoid re-allocations on `WithFields` (#335)
+
+# 0.9.0
+
+* logrus/text_formatter: don't emit empty msg
+* logrus/hooks/airbrake: move out of main repository
+* logrus/hooks/sentry: move out of main repository
+* logrus/hooks/papertrail: move out of main repository
+* logrus/hooks/bugsnag: move out of main repository
+* logrus/core: run tests with `-race`
+* logrus/core: detect TTY based on `stderr`
+* logrus/core: support `WithError` on logger
+* logrus/core: Solaris support
+
+# 0.8.7
+
+* logrus/core: fix possible race (#216)
+* logrus/doc: small typo fixes and doc improvements
+
+
+# 0.8.6
+
+* hooks/raven: allow passing an initialized client
+
+# 0.8.5
+
+* logrus/core: revert #208
+
+# 0.8.4
+
+* formatter/text: fix data race (#218)
+
+# 0.8.3
+
+* logrus/core: fix entry log level (#208)
+* logrus/core: improve performance of text formatter by 40%
+* logrus/core: expose `LevelHooks` type
+* logrus/core: add support for DragonflyBSD and NetBSD
+* formatter/text: print structs more verbosely
+
+# 0.8.2
+
+* logrus: fix more Fatal family functions
+
+# 0.8.1
+
+* logrus: fix not exiting on `Fatalf` and `Fatalln`
+
+# 0.8.0
+
+* logrus: defaults to stderr instead of stdout
+* hooks/sentry: add special field for `*http.Request`
+* formatter/text: ignore Windows for colors
+
+# 0.7.3
+
+* formatter/\*: allow configuration of timestamp layout
+
+# 0.7.2
+
+* formatter/text: Add configuration option for time format (#158)
diff --git a/newt/vendor/github.com/Sirupsen/logrus/LICENSE b/vendor/github.com/Sirupsen/logrus/LICENSE
similarity index 100%
rename from newt/vendor/github.com/Sirupsen/logrus/LICENSE
rename to vendor/github.com/Sirupsen/logrus/LICENSE
diff --git a/vendor/github.com/Sirupsen/logrus/README.md b/vendor/github.com/Sirupsen/logrus/README.md
new file mode 100644
index 00000000..4f5ce576
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/README.md
@@ -0,0 +1,505 @@
+# Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/> [![Build Status](https://travis-ci.org/sirupsen/logrus.svg?branch=master)](https://travis-ci.org/sirupsen/logrus) [![GoDoc](https://godoc.org/github.com/sirupsen/logrus?status.svg)](https://godoc.org/github.com/sirupsen/logrus)
+
+Logrus is a structured logger for Go (golang), completely API compatible with
+the standard library logger.
+
+**Seeing weird case-sensitive problems?** It's in the past been possible to
+import Logrus as both upper- and lower-case. Due to the Go package environment,
+this caused issues in the community and we needed a standard. Some environments
+experienced problems with the upper-case variant, so the lower-case was decided.
+Everything using `logrus` will need to use the lower-case:
+`github.com/sirupsen/logrus`. Any package that isn't, should be changed.
+
+To fix Glide, see [these
+comments](https://github.com/sirupsen/logrus/issues/553#issuecomment-306591437).
+For an in-depth explanation of the casing issue, see [this
+comment](https://github.com/sirupsen/logrus/issues/570#issuecomment-313933276).
+
+**Are you interested in assisting in maintaining Logrus?** Currently I have a
+lot of obligations, and I am unable to provide Logrus with the maintainership it
+needs. If you'd like to help, please reach out to me at `simon at author's
+username dot com`.
+
+Nicely color-coded in development (when a TTY is attached, otherwise just
+plain text):
+
+![Colored](http://i.imgur.com/PY7qMwd.png)
+
+With `log.SetFormatter(&log.JSONFormatter{})`, for easy parsing by logstash
+or Splunk:
+
+```json
+{"animal":"walrus","level":"info","msg":"A group of walrus emerges from the
+ocean","size":10,"time":"2014-03-10 19:57:38.562264131 -0400 EDT"}
+
+{"level":"warning","msg":"The group's number increased tremendously!",
+"number":122,"omg":true,"time":"2014-03-10 19:57:38.562471297 -0400 EDT"}
+
+{"animal":"walrus","level":"info","msg":"A giant walrus appears!",
+"size":10,"time":"2014-03-10 19:57:38.562500591 -0400 EDT"}
+
+{"animal":"walrus","level":"info","msg":"Tremendously sized cow enters the ocean.",
+"size":9,"time":"2014-03-10 19:57:38.562527896 -0400 EDT"}
+
+{"level":"fatal","msg":"The ice breaks!","number":100,"omg":true,
+"time":"2014-03-10 19:57:38.562543128 -0400 EDT"}
+```
+
+With the default `log.SetFormatter(&log.TextFormatter{})` when a TTY is not
+attached, the output is compatible with the
+[logfmt](http://godoc.org/github.com/kr/logfmt) format:
+
+```text
+time="2015-03-26T01:27:38-04:00" level=debug msg="Started observing beach" animal=walrus number=8
+time="2015-03-26T01:27:38-04:00" level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10
+time="2015-03-26T01:27:38-04:00" level=warning msg="The group's number increased tremendously!" number=122 omg=true
+time="2015-03-26T01:27:38-04:00" level=debug msg="Temperature changes" temperature=-4
+time="2015-03-26T01:27:38-04:00" level=panic msg="It's over 9000!" animal=orca size=9009
+time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x2082280c0 map[animal:orca size:9009] 2015-03-26 01:27:38.441574009 -0400 EDT panic It's over 9000!} number=100 omg=true
+exit status 1
+```
+
+#### Case-sensitivity
+
+The organization's name was changed to lower-case--and this will not be changed
+back. If you are getting import conflicts due to case sensitivity, please use
+the lower-case import: `github.com/sirupsen/logrus`.
+
+#### Example
+
+The simplest way to use Logrus is simply the package-level exported logger:
+
+```go
+package main
+
+import (
+ log "github.com/sirupsen/logrus"
+)
+
+func main() {
+ log.WithFields(log.Fields{
+ "animal": "walrus",
+ }).Info("A walrus appears")
+}
+```
+
+Note that it's completely api-compatible with the stdlib logger, so you can
+replace your `log` imports everywhere with `log "github.com/sirupsen/logrus"`
+and you'll now have the flexibility of Logrus. You can customize it all you
+want:
+
+```go
+package main
+
+import (
+ "os"
+ log "github.com/sirupsen/logrus"
+)
+
+func init() {
+ // Log as JSON instead of the default ASCII formatter.
+ log.SetFormatter(&log.JSONFormatter{})
+
+ // Output to stdout instead of the default stderr
+ // Can be any io.Writer, see below for File example
+ log.SetOutput(os.Stdout)
+
+ // Only log the warning severity or above.
+ log.SetLevel(log.WarnLevel)
+}
+
+func main() {
+ log.WithFields(log.Fields{
+ "animal": "walrus",
+ "size": 10,
+ }).Info("A group of walrus emerges from the ocean")
+
+ log.WithFields(log.Fields{
+ "omg": true,
+ "number": 122,
+ }).Warn("The group's number increased tremendously!")
+
+ log.WithFields(log.Fields{
+ "omg": true,
+ "number": 100,
+ }).Fatal("The ice breaks!")
+
+ // A common pattern is to re-use fields between logging statements by re-using
+ // the logrus.Entry returned from WithFields()
+ contextLogger := log.WithFields(log.Fields{
+ "common": "this is a common field",
+ "other": "I also should be logged always",
+ })
+
+ contextLogger.Info("I'll be logged with common and other field")
+ contextLogger.Info("Me too")
+}
+```
+
+For more advanced usage such as logging to multiple locations from the same
+application, you can also create an instance of the `logrus` Logger:
+
+```go
+package main
+
+import (
+ "os"
+ "github.com/sirupsen/logrus"
+)
+
+// Create a new instance of the logger. You can have any number of instances.
+var log = logrus.New()
+
+func main() {
+ // The API for setting attributes is a little different than the package level
+ // exported logger. See Godoc.
+ log.Out = os.Stdout
+
+ // You could set this to any `io.Writer` such as a file
+ // file, err := os.OpenFile("logrus.log", os.O_CREATE|os.O_WRONLY, 0666)
+ // if err == nil {
+ // log.Out = file
+ // } else {
+ // log.Info("Failed to log to file, using default stderr")
+ // }
+
+ log.WithFields(logrus.Fields{
+ "animal": "walrus",
+ "size": 10,
+ }).Info("A group of walrus emerges from the ocean")
+}
+```
+
+#### Fields
+
+Logrus encourages careful, structured logging through logging fields instead of
+long, unparseable error messages. For example, instead of: `log.Fatalf("Failed
+to send event %s to topic %s with key %d")`, you should log the much more
+discoverable:
+
+```go
+log.WithFields(log.Fields{
+ "event": event,
+ "topic": topic,
+ "key": key,
+}).Fatal("Failed to send event")
+```
+
+We've found this API forces you to think about logging in a way that produces
+much more useful logging messages. We've been in countless situations where just
+a single added field to a log statement that was already there would've saved us
+hours. The `WithFields` call is optional.
+
+In general, with Logrus using any of the `printf`-family functions should be
+seen as a hint you should add a field, however, you can still use the
+`printf`-family functions with Logrus.
+
+#### Default Fields
+
+Often it's helpful to have fields _always_ attached to log statements in an
+application or parts of one. For example, you may want to always log the
+`request_id` and `user_ip` in the context of a request. Instead of writing
+`log.WithFields(log.Fields{"request_id": request_id, "user_ip": user_ip})` on
+every line, you can create a `logrus.Entry` to pass around instead:
+
+```go
+requestLogger := log.WithFields(log.Fields{"request_id": request_id, "user_ip": user_ip})
+requestLogger.Info("something happened on that request") # will log request_id and user_ip
+requestLogger.Warn("something not great happened")
+```
+
+#### Hooks
+
+You can add hooks for logging levels. For example to send errors to an exception
+tracking service on `Error`, `Fatal` and `Panic`, info to StatsD or log to
+multiple places simultaneously, e.g. syslog.
+
+Logrus comes with [built-in hooks](hooks/). Add those, or your custom hook, in
+`init`:
+
+```go
+import (
+ log "github.com/sirupsen/logrus"
+ "gopkg.in/gemnasium/logrus-airbrake-hook.v2" // the package is named "aibrake"
+ logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
+ "log/syslog"
+)
+
+func init() {
+
+ // Use the Airbrake hook to report errors that have Error severity or above to
+ // an exception tracker. You can create custom hooks, see the Hooks section.
+ log.AddHook(airbrake.NewHook(123, "xyz", "production"))
+
+ hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
+ if err != nil {
+ log.Error("Unable to connect to local syslog daemon")
+ } else {
+ log.AddHook(hook)
+ }
+}
+```
+Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). For the detail, please check the [syslog hook README](hooks/syslog/README.md).
+
+| Hook | Description |
+| ----- | ----------- |
+| [Airbrake "legacy"](https://github.com/gemnasium/logrus-airbrake-legacy-hook) | Send errors to an exception tracking service compatible with the Airbrake API V2. Uses [`airbrake-go`](https://github.com/tobi/airbrake-go) behind the scenes. |
+| [Airbrake](https://github.com/gemnasium/logrus-airbrake-hook) | Send errors to the Airbrake API V3. Uses the official [`gobrake`](https://github.com/airbrake/gobrake) behind the scenes. |
+| [Amazon Kinesis](https://github.com/evalphobia/logrus_kinesis) | Hook for logging to [Amazon Kinesis](https://aws.amazon.com/kinesis/) |
+| [Amqp-Hook](https://github.com/vladoatanasov/logrus_amqp) | Hook for logging to Amqp broker (Like RabbitMQ) |
+| [Bugsnag](https://github.com/Shopify/logrus-bugsnag/blob/master/bugsnag.go) | Send errors to the Bugsnag exception tracking service. |
+| [DeferPanic](https://github.com/deferpanic/dp-logrus) | Hook for logging to DeferPanic |
+| [Discordrus](https://github.com/kz/discordrus) | Hook for logging to [Discord](https://discordapp.com/) |
+| [ElasticSearch](https://github.com/sohlich/elogrus) | Hook for logging to ElasticSearch|
+| [Firehose](https://github.com/beaubrewer/logrus_firehose) | Hook for logging to [Amazon Firehose](https://aws.amazon.com/kinesis/firehose/)
+| [Fluentd](https://github.com/evalphobia/logrus_fluent) | Hook for logging to fluentd |
+| [Go-Slack](https://github.com/multiplay/go-slack) | Hook for logging to [Slack](https://slack.com) |
+| [Graylog](https://github.com/gemnasium/logrus-graylog-hook) | Hook for logging to [Graylog](http://graylog2.org/) |
+| [Hiprus](https://github.com/nubo/hiprus) | Send errors to a channel in hipchat. |
+| [Honeybadger](https://github.com/agonzalezro/logrus_honeybadger) | Hook for sending exceptions to Honeybadger |
+| [InfluxDB](https://github.com/Abramovic/logrus_influxdb) | Hook for logging to influxdb |
+| [Influxus](http://github.com/vlad-doru/influxus) | Hook for concurrently logging to [InfluxDB](http://influxdata.com/) |
+| [Journalhook](https://github.com/wercker/journalhook) | Hook for logging to `systemd-journald` |
+| [KafkaLogrus](https://github.com/goibibo/KafkaLogrus) | Hook for logging to kafka |
+| [LFShook](https://github.com/rifflock/lfshook) | Hook for logging to the local filesystem |
+| [Logentries](https://github.com/jcftang/logentriesrus) | Hook for logging to [Logentries](https://logentries.com/) |
+| [Logentrus](https://github.com/puddingfactory/logentrus) | Hook for logging to [Logentries](https://logentries.com/) |
+| [Logmatic.io](https://github.com/logmatic/logmatic-go) | Hook for logging to [Logmatic.io](http://logmatic.io/) |
+| [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) |
+| [Logstash](https://github.com/bshuster-repo/logrus-logstash-hook) | Hook for logging to [Logstash](https://www.elastic.co/products/logstash) |
+| [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail |
+| [Mattermost](https://github.com/shuLhan/mattermost-integration/tree/master/hooks/logrus) | Hook for logging to [Mattermost](https://mattermost.com/) |
+| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb |
+| [NATS-Hook](https://github.com/rybit/nats_logrus_hook) | Hook for logging to [NATS](https://nats.io) |
+| [Octokit](https://github.com/dorajistyle/logrus-octokit-hook) | Hook for logging to github via octokit |
+| [Papertrail](https://github.com/polds/logrus-papertrail-hook) | Send errors to the [Papertrail](https://papertrailapp.com) hosted logging service via UDP. |
+| [PostgreSQL](https://github.com/gemnasium/logrus-postgresql-hook) | Send logs to [PostgreSQL](http://postgresql.org) |
+| [Pushover](https://github.com/toorop/logrus_pushover) | Send error via [Pushover](https://pushover.net) |
+| [Raygun](https://github.com/squirkle/logrus-raygun-hook) | Hook for logging to [Raygun.io](http://raygun.io/) |
+| [Redis-Hook](https://github.com/rogierlommers/logrus-redis-hook) | Hook for logging to a ELK stack (through Redis) |
+| [Rollrus](https://github.com/heroku/rollrus) | Hook for sending errors to rollbar |
+| [Scribe](https://github.com/sagar8192/logrus-scribe-hook) | Hook for logging to [Scribe](https://github.com/facebookarchive/scribe)|
+| [Sentry](https://github.com/evalphobia/logrus_sentry) | Send errors to the Sentry error logging and aggregation service. |
+| [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. |
+| [Stackdriver](https://github.com/knq/sdhook) | Hook for logging to [Google Stackdriver](https://cloud.google.com/logging/) |
+| [Sumorus](https://github.com/doublefree/sumorus) | Hook for logging to [SumoLogic](https://www.sumologic.com/)|
+| [Syslog](https://github.com/sirupsen/logrus/blob/master/hooks/syslog/syslog.go) | Send errors to remote syslog server. Uses standard library `log/syslog` behind the scenes. |
+| [Syslog TLS](https://github.com/shinji62/logrus-syslog-ng) | Send errors to remote syslog server with TLS support. |
+| [TraceView](https://github.com/evalphobia/logrus_appneta) | Hook for logging to [AppNeta TraceView](https://www.appneta.com/products/traceview/) |
+| [Typetalk](https://github.com/dragon3/logrus-typetalk-hook) | Hook for logging to [Typetalk](https://www.typetalk.in/) |
+| [logz.io](https://github.com/ripcurld00d/logrus-logzio-hook) | Hook for logging to [logz.io](https://logz.io), a Log as a Service using Logstash |
+| [SQS-Hook](https://github.com/tsarpaul/logrus_sqs) | Hook for logging to [Amazon Simple Queue Service (SQS)](https://aws.amazon.com/sqs/) |
+
+#### Level logging
+
+Logrus has six logging levels: Debug, Info, Warning, Error, Fatal and Panic.
+
+```go
+log.Debug("Useful debugging information.")
+log.Info("Something noteworthy happened!")
+log.Warn("You should probably take a look at this.")
+log.Error("Something failed but I'm not quitting.")
+// Calls os.Exit(1) after logging
+log.Fatal("Bye.")
+// Calls panic() after logging
+log.Panic("I'm bailing.")
+```
+
+You can set the logging level on a `Logger`, then it will only log entries with
+that severity or anything above it:
+
+```go
+// Will log anything that is info or above (warn, error, fatal, panic). Default.
+log.SetLevel(log.InfoLevel)
+```
+
+It may be useful to set `log.Level = logrus.DebugLevel` in a debug or verbose
+environment if your application has that.
+
+#### Entries
+
+Besides the fields added with `WithField` or `WithFields` some fields are
+automatically added to all logging events:
+
+1. `time`. The timestamp when the entry was created.
+2. `msg`. The logging message passed to `{Info,Warn,Error,Fatal,Panic}` after
+ the `AddFields` call. E.g. `Failed to send event.`
+3. `level`. The logging level. E.g. `info`.
+
+#### Environments
+
+Logrus has no notion of environment.
+
+If you wish for hooks and formatters to only be used in specific environments,
+you should handle that yourself. For example, if your application has a global
+variable `Environment`, which is a string representation of the environment you
+could do:
+
+```go
+import (
+ log "github.com/sirupsen/logrus"
+)
+
+init() {
+ // do something here to set environment depending on an environment variable
+ // or command-line flag
+ if Environment == "production" {
+ log.SetFormatter(&log.JSONFormatter{})
+ } else {
+ // The TextFormatter is default, you don't actually have to do this.
+ log.SetFormatter(&log.TextFormatter{})
+ }
+}
+```
+
+This configuration is how `logrus` was intended to be used, but JSON in
+production is mostly only useful if you do log aggregation with tools like
+Splunk or Logstash.
+
+#### Formatters
+
+The built-in logging formatters are:
+
+* `logrus.TextFormatter`. Logs the event in colors if stdout is a tty, otherwise
+ without colors.
+ * *Note:* to force colored output when there is no TTY, set the `ForceColors`
+ field to `true`. To force no colored output even if there is a TTY set the
+ `DisableColors` field to `true`. For Windows, see
+ [github.com/mattn/go-colorable](https://github.com/mattn/go-colorable).
+ * All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#TextFormatter).
+* `logrus.JSONFormatter`. Logs fields as JSON.
+ * All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#JSONFormatter).
+
+Third party logging formatters:
+
+* [`FluentdFormatter`](https://github.com/joonix/log). Formats entries that can by parsed by Kubernetes and Google Container Engine.
+* [`logstash`](https://github.com/bshuster-repo/logrus-logstash-hook). Logs fields as [Logstash](http://logstash.net) Events.
+* [`prefixed`](https://github.com/x-cray/logrus-prefixed-formatter). Displays log entry source along with alternative layout.
+* [`zalgo`](https://github.com/aybabtme/logzalgo). Invoking the P??o???w????e????r???? ??????????f??? ?????Z?????a????l??g??o???!?????? ?????.
+
+You can define your formatter by implementing the `Formatter` interface,
+requiring a `Format` method. `Format` takes an `*Entry`. `entry.Data` is a
+`Fields` type (`map[string]interface{}`) with all your fields as well as the
+default ones (see Entries section above):
+
+```go
+type MyJSONFormatter struct {
+}
+
+log.SetFormatter(new(MyJSONFormatter))
+
+func (f *MyJSONFormatter) Format(entry *Entry) ([]byte, error) {
+ // Note this doesn't include Time, Level and Message which are available on
+ // the Entry. Consult `godoc` on information about those fields or read the
+ // source of the official loggers.
+ serialized, err := json.Marshal(entry.Data)
+ if err != nil {
+ return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
+ }
+ return append(serialized, '\n'), nil
+}
+```
+
+#### Logger as an `io.Writer`
+
+Logrus can be transformed into an `io.Writer`. That writer is the end of an `io.Pipe` and it is your responsibility to close it.
+
+```go
+w := logger.Writer()
+defer w.Close()
+
+srv := http.Server{
+ // create a stdlib log.Logger that writes to
+ // logrus.Logger.
+ ErrorLog: log.New(w, "", 0),
+}
+```
+
+Each line written to that writer will be printed the usual way, using formatters
+and hooks. The level for those entries is `info`.
+
+This means that we can override the standard library logger easily:
+
+```go
+logger := logrus.New()
+logger.Formatter = &logrus.JSONFormatter{}
+
+// Use logrus for standard log output
+// Note that `log` here references stdlib's log
+// Not logrus imported under the name `log`.
+log.SetOutput(logger.Writer())
+```
+
+#### Rotation
+
+Log rotation is not provided with Logrus. Log rotation should be done by an
+external program (like `logrotate(8)`) that can compress and delete old log
+entries. It should not be a feature of the application-level logger.
+
+#### Tools
+
+| Tool | Description |
+| ---- | ----------- |
+|[Logrus Mate](https://github.com/gogap/logrus_mate)|Logrus mate is a tool for Logrus to manage loggers, you can initial logger's level, hook and formatter by config file, the logger will generated with different config at different environment.|
+|[Logrus Viper Helper](https://github.com/heirko/go-contrib/tree/master/logrusHelper)|An Helper around Logrus to wrap with spf13/Viper to load configuration with fangs! And to simplify Logrus configuration use some behavior of [Logrus Mate](https://github.com/gogap/logrus_mate). [sample](https://github.com/heirko/iris-contrib/blob/master/middleware/logrus-logger/example) |
+
+#### Testing
+
+Logrus has a built in facility for asserting the presence of log messages. This is implemented through the `test` hook and provides:
+
+* decorators for existing logger (`test.NewLocal` and `test.NewGlobal`) which basically just add the `test` hook
+* a test logger (`test.NewNullLogger`) that just records log messages (and does not output any):
+
+```go
+import(
+ "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus/hooks/test"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestSomething(t*testing.T){
+ logger, hook := test.NewNullLogger()
+ logger.Error("Helloerror")
+
+ assert.Equal(t, 1, len(hook.Entries))
+ assert.Equal(t, logrus.ErrorLevel, hook.LastEntry().Level)
+ assert.Equal(t, "Helloerror", hook.LastEntry().Message)
+
+ hook.Reset()
+ assert.Nil(t, hook.LastEntry())
+}
+```
+
+#### Fatal handlers
+
+Logrus can register one or more functions that will be called when any `fatal`
+level message is logged. The registered handlers will be executed before
+logrus performs a `os.Exit(1)`. This behavior may be helpful if callers need
+to gracefully shutdown. Unlike a `panic("Something went wrong...")` call which can be intercepted with a deferred `recover` a call to `os.Exit(1)` can not be intercepted.
+
+```
+...
+handler := func() {
+ // gracefully shutdown something...
+}
+logrus.RegisterExitHandler(handler)
+...
+```
+
+#### Thread safety
+
+By default Logger is protected by mutex for concurrent writes, this mutex is invoked when calling hooks and writing logs.
+If you are sure such locking is not needed, you can call logger.SetNoLock() to disable the locking.
+
+Situation when locking is not needed includes:
+
+* You have no hooks registered, or hooks calling is already thread-safe.
+
+* Writing to logger.Out is already thread-safe, for example:
+
+ 1) logger.Out is protected by locks.
+
+ 2) logger.Out is a os.File handler opened with `O_APPEND` flag, and every write is smaller than 4k. (This allow multi-thread/multi-process writing)
+
+ (Refer to http://www.notthewizard.com/2014/06/17/are-files-appends-really-atomic/)
diff --git a/vendor/github.com/Sirupsen/logrus/alt_exit.go b/vendor/github.com/Sirupsen/logrus/alt_exit.go
new file mode 100644
index 00000000..8af90637
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/alt_exit.go
@@ -0,0 +1,64 @@
+package logrus
+
+// The following code was sourced and modified from the
+// https://github.com/tebeka/atexit package governed by the following license:
+//
+// Copyright (c) 2012 Miki Tebeka <mi...@gmail.com>.
+//
+// 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.
+
+import (
+ "fmt"
+ "os"
+)
+
+var handlers = []func(){}
+
+func runHandler(handler func()) {
+ defer func() {
+ if err := recover(); err != nil {
+ fmt.Fprintln(os.Stderr, "Error: Logrus exit handler error:", err)
+ }
+ }()
+
+ handler()
+}
+
+func runHandlers() {
+ for _, handler := range handlers {
+ runHandler(handler)
+ }
+}
+
+// Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code)
+func Exit(code int) {
+ runHandlers()
+ os.Exit(code)
+}
+
+// RegisterExitHandler adds a Logrus Exit handler, call logrus.Exit to invoke
+// all handlers. The handlers will also be invoked when any Fatal log entry is
+// made.
+//
+// This method is useful when a caller wishes to use logrus to log a fatal
+// message but also needs to gracefully shutdown. An example usecase could be
+// closing database connections, or sending a alert that the application is
+// closing.
+func RegisterExitHandler(handler func()) {
+ handlers = append(handlers, handler)
+}
diff --git a/vendor/github.com/Sirupsen/logrus/alt_exit_test.go b/vendor/github.com/Sirupsen/logrus/alt_exit_test.go
new file mode 100644
index 00000000..a08b1a89
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/alt_exit_test.go
@@ -0,0 +1,83 @@
+package logrus
+
+import (
+ "io/ioutil"
+ "log"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "testing"
+ "time"
+)
+
+func TestRegister(t *testing.T) {
+ current := len(handlers)
+ RegisterExitHandler(func() {})
+ if len(handlers) != current+1 {
+ t.Fatalf("expected %d handlers, got %d", current+1, len(handlers))
+ }
+}
+
+func TestHandler(t *testing.T) {
+ tempDir, err := ioutil.TempDir("", "test_handler")
+ if err != nil {
+ log.Fatalf("can't create temp dir. %q", err)
+ }
+ defer os.RemoveAll(tempDir)
+
+ gofile := filepath.Join(tempDir, "gofile.go")
+ if err := ioutil.WriteFile(gofile, testprog, 0666); err != nil {
+ t.Fatalf("can't create go file. %q", err)
+ }
+
+ outfile := filepath.Join(tempDir, "outfile.out")
+ arg := time.Now().UTC().String()
+ err = exec.Command("go", "run", gofile, outfile, arg).Run()
+ if err == nil {
+ t.Fatalf("completed normally, should have failed")
+ }
+
+ data, err := ioutil.ReadFile(outfile)
+ if err != nil {
+ t.Fatalf("can't read output file %s. %q", outfile, err)
+ }
+
+ if string(data) != arg {
+ t.Fatalf("bad data. Expected %q, got %q", data, arg)
+ }
+}
+
+var testprog = []byte(`
+// Test program for atexit, gets output file and data as arguments and writes
+// data to output file in atexit handler.
+package main
+
+import (
+ "github.com/sirupsen/logrus"
+ "flag"
+ "fmt"
+ "io/ioutil"
+)
+
+var outfile = ""
+var data = ""
+
+func handler() {
+ ioutil.WriteFile(outfile, []byte(data), 0666)
+}
+
+func badHandler() {
+ n := 0
+ fmt.Println(1/n)
+}
+
+func main() {
+ flag.Parse()
+ outfile = flag.Arg(0)
+ data = flag.Arg(1)
+
+ logrus.RegisterExitHandler(handler)
+ logrus.RegisterExitHandler(badHandler)
+ logrus.Fatal("Bye bye")
+}
+`)
diff --git a/vendor/github.com/Sirupsen/logrus/appveyor.yml b/vendor/github.com/Sirupsen/logrus/appveyor.yml
new file mode 100644
index 00000000..96c2ce15
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/appveyor.yml
@@ -0,0 +1,14 @@
+version: "{build}"
+platform: x64
+clone_folder: c:\gopath\src\github.com\sirupsen\logrus
+environment:
+ GOPATH: c:\gopath
+branches:
+ only:
+ - master
+install:
+ - set PATH=%GOPATH%\bin;c:\go\bin;%PATH%
+ - go version
+build_script:
+ - go get -t
+ - go test
diff --git a/vendor/github.com/Sirupsen/logrus/doc.go b/vendor/github.com/Sirupsen/logrus/doc.go
new file mode 100644
index 00000000..da67aba0
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/doc.go
@@ -0,0 +1,26 @@
+/*
+Package logrus is a structured logger for Go, completely API compatible with the standard library logger.
+
+
+The simplest way to use Logrus is simply the package-level exported logger:
+
+ package main
+
+ import (
+ log "github.com/sirupsen/logrus"
+ )
+
+ func main() {
+ log.WithFields(log.Fields{
+ "animal": "walrus",
+ "number": 1,
+ "size": 10,
+ }).Info("A walrus appears")
+ }
+
+Output:
+ time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10
+
+For a full guide visit https://github.com/sirupsen/logrus
+*/
+package logrus
diff --git a/vendor/github.com/Sirupsen/logrus/entry.go b/vendor/github.com/Sirupsen/logrus/entry.go
new file mode 100644
index 00000000..5bf582ef
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/entry.go
@@ -0,0 +1,276 @@
+package logrus
+
+import (
+ "bytes"
+ "fmt"
+ "os"
+ "sync"
+ "time"
+)
+
+var bufferPool *sync.Pool
+
+func init() {
+ bufferPool = &sync.Pool{
+ New: func() interface{} {
+ return new(bytes.Buffer)
+ },
+ }
+}
+
+// Defines the key when adding errors using WithError.
+var ErrorKey = "error"
+
+// An entry is the final or intermediate Logrus logging entry. It contains all
+// the fields passed with WithField{,s}. It's finally logged when Debug, Info,
+// Warn, Error, Fatal or Panic is called on it. These objects can be reused and
+// passed around as much as you wish to avoid field duplication.
+type Entry struct {
+ Logger *Logger
+
+ // Contains all the fields set by the user.
+ Data Fields
+
+ // Time at which the log entry was created
+ Time time.Time
+
+ // Level the log entry was logged at: Debug, Info, Warn, Error, Fatal or Panic
+ // This field will be set on entry firing and the value will be equal to the one in Logger struct field.
+ Level Level
+
+ // Message passed to Debug, Info, Warn, Error, Fatal or Panic
+ Message string
+
+ // When formatter is called in entry.log(), an Buffer may be set to entry
+ Buffer *bytes.Buffer
+}
+
+func NewEntry(logger *Logger) *Entry {
+ return &Entry{
+ Logger: logger,
+ // Default is three fields, give a little extra room
+ Data: make(Fields, 5),
+ }
+}
+
+// Returns the string representation from the reader and ultimately the
+// formatter.
+func (entry *Entry) String() (string, error) {
+ serialized, err := entry.Logger.Formatter.Format(entry)
+ if err != nil {
+ return "", err
+ }
+ str := string(serialized)
+ return str, nil
+}
+
+// Add an error as single field (using the key defined in ErrorKey) to the Entry.
+func (entry *Entry) WithError(err error) *Entry {
+ return entry.WithField(ErrorKey, err)
+}
+
+// Add a single field to the Entry.
+func (entry *Entry) WithField(key string, value interface{}) *Entry {
+ return entry.WithFields(Fields{key: value})
+}
+
+// Add a map of fields to the Entry.
+func (entry *Entry) WithFields(fields Fields) *Entry {
+ data := make(Fields, len(entry.Data)+len(fields))
+ for k, v := range entry.Data {
+ data[k] = v
+ }
+ for k, v := range fields {
+ data[k] = v
+ }
+ return &Entry{Logger: entry.Logger, Data: data}
+}
+
+// This function is not declared with a pointer value because otherwise
+// race conditions will occur when using multiple goroutines
+func (entry Entry) log(level Level, msg string) {
+ var buffer *bytes.Buffer
+ entry.Time = time.Now()
+ entry.Level = level
+ entry.Message = msg
+
+ if err := entry.Logger.Hooks.Fire(level, &entry); err != nil {
+ entry.Logger.mu.Lock()
+ fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err)
+ entry.Logger.mu.Unlock()
+ }
+ buffer = bufferPool.Get().(*bytes.Buffer)
+ buffer.Reset()
+ defer bufferPool.Put(buffer)
+ entry.Buffer = buffer
+ serialized, err := entry.Logger.Formatter.Format(&entry)
+ entry.Buffer = nil
+ if err != nil {
+ entry.Logger.mu.Lock()
+ fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err)
+ entry.Logger.mu.Unlock()
+ } else {
+ entry.Logger.mu.Lock()
+ _, err = entry.Logger.Out.Write(serialized)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
+ }
+ entry.Logger.mu.Unlock()
+ }
+
+ // To avoid Entry#log() returning a value that only would make sense for
+ // panic() to use in Entry#Panic(), we avoid the allocation by checking
+ // directly here.
+ if level <= PanicLevel {
+ panic(&entry)
+ }
+}
+
+func (entry *Entry) Debug(args ...interface{}) {
+ if entry.Logger.level() >= DebugLevel {
+ entry.log(DebugLevel, fmt.Sprint(args...))
+ }
+}
+
+func (entry *Entry) Print(args ...interface{}) {
+ entry.Info(args...)
+}
+
+func (entry *Entry) Info(args ...interface{}) {
+ if entry.Logger.level() >= InfoLevel {
+ entry.log(InfoLevel, fmt.Sprint(args...))
+ }
+}
+
+func (entry *Entry) Warn(args ...interface{}) {
+ if entry.Logger.level() >= WarnLevel {
+ entry.log(WarnLevel, fmt.Sprint(args...))
+ }
+}
+
+func (entry *Entry) Warning(args ...interface{}) {
+ entry.Warn(args...)
+}
+
+func (entry *Entry) Error(args ...interface{}) {
+ if entry.Logger.level() >= ErrorLevel {
+ entry.log(ErrorLevel, fmt.Sprint(args...))
+ }
+}
+
+func (entry *Entry) Fatal(args ...interface{}) {
+ if entry.Logger.level() >= FatalLevel {
+ entry.log(FatalLevel, fmt.Sprint(args...))
+ }
+ Exit(1)
+}
+
+func (entry *Entry) Panic(args ...interface{}) {
+ if entry.Logger.level() >= PanicLevel {
+ entry.log(PanicLevel, fmt.Sprint(args...))
+ }
+ panic(fmt.Sprint(args...))
+}
+
+// Entry Printf family functions
+
+func (entry *Entry) Debugf(format string, args ...interface{}) {
+ if entry.Logger.level() >= DebugLevel {
+ entry.Debug(fmt.Sprintf(format, args...))
+ }
+}
+
+func (entry *Entry) Infof(format string, args ...interface{}) {
+ if entry.Logger.level() >= InfoLevel {
+ entry.Info(fmt.Sprintf(format, args...))
+ }
+}
+
+func (entry *Entry) Printf(format string, args ...interface{}) {
+ entry.Infof(format, args...)
+}
+
+func (entry *Entry) Warnf(format string, args ...interface{}) {
+ if entry.Logger.level() >= WarnLevel {
+ entry.Warn(fmt.Sprintf(format, args...))
+ }
+}
+
+func (entry *Entry) Warningf(format string, args ...interface{}) {
+ entry.Warnf(format, args...)
+}
+
+func (entry *Entry) Errorf(format string, args ...interface{}) {
+ if entry.Logger.level() >= ErrorLevel {
+ entry.Error(fmt.Sprintf(format, args...))
+ }
+}
+
+func (entry *Entry) Fatalf(format string, args ...interface{}) {
+ if entry.Logger.level() >= FatalLevel {
+ entry.Fatal(fmt.Sprintf(format, args...))
+ }
+ Exit(1)
+}
+
+func (entry *Entry) Panicf(format string, args ...interface{}) {
+ if entry.Logger.level() >= PanicLevel {
+ entry.Panic(fmt.Sprintf(format, args...))
+ }
+}
+
+// Entry Println family functions
+
+func (entry *Entry) Debugln(args ...interface{}) {
+ if entry.Logger.level() >= DebugLevel {
+ entry.Debug(entry.sprintlnn(args...))
+ }
+}
+
+func (entry *Entry) Infoln(args ...interface{}) {
+ if entry.Logger.level() >= InfoLevel {
+ entry.Info(entry.sprintlnn(args...))
+ }
+}
+
+func (entry *Entry) Println(args ...interface{}) {
+ entry.Infoln(args...)
+}
+
+func (entry *Entry) Warnln(args ...interface{}) {
+ if entry.Logger.level() >= WarnLevel {
+ entry.Warn(entry.sprintlnn(args...))
+ }
+}
+
+func (entry *Entry) Warningln(args ...interface{}) {
+ entry.Warnln(args...)
+}
+
+func (entry *Entry) Errorln(args ...interface{}) {
+ if entry.Logger.level() >= ErrorLevel {
+ entry.Error(entry.sprintlnn(args...))
+ }
+}
+
+func (entry *Entry) Fatalln(args ...interface{}) {
+ if entry.Logger.level() >= FatalLevel {
+ entry.Fatal(entry.sprintlnn(args...))
+ }
+ Exit(1)
+}
+
+func (entry *Entry) Panicln(args ...interface{}) {
+ if entry.Logger.level() >= PanicLevel {
+ entry.Panic(entry.sprintlnn(args...))
+ }
+}
+
+// Sprintlnn => Sprint no newline. This is to get the behavior of how
+// fmt.Sprintln where spaces are always added between operands, regardless of
+// their type. Instead of vendoring the Sprintln implementation to spare a
+// string allocation, we do the simplest thing.
+func (entry *Entry) sprintlnn(args ...interface{}) string {
+ msg := fmt.Sprintln(args...)
+ return msg[:len(msg)-1]
+}
diff --git a/vendor/github.com/Sirupsen/logrus/entry_test.go b/vendor/github.com/Sirupsen/logrus/entry_test.go
new file mode 100644
index 00000000..99c3b41d
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/entry_test.go
@@ -0,0 +1,77 @@
+package logrus
+
+import (
+ "bytes"
+ "fmt"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestEntryWithError(t *testing.T) {
+
+ assert := assert.New(t)
+
+ defer func() {
+ ErrorKey = "error"
+ }()
+
+ err := fmt.Errorf("kaboom at layer %d", 4711)
+
+ assert.Equal(err, WithError(err).Data["error"])
+
+ logger := New()
+ logger.Out = &bytes.Buffer{}
+ entry := NewEntry(logger)
+
+ assert.Equal(err, entry.WithError(err).Data["error"])
+
+ ErrorKey = "err"
+
+ assert.Equal(err, entry.WithError(err).Data["err"])
+
+}
+
+func TestEntryPanicln(t *testing.T) {
+ errBoom := fmt.Errorf("boom time")
+
+ defer func() {
+ p := recover()
+ assert.NotNil(t, p)
+
+ switch pVal := p.(type) {
+ case *Entry:
+ assert.Equal(t, "kaboom", pVal.Message)
+ assert.Equal(t, errBoom, pVal.Data["err"])
+ default:
+ t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal)
+ }
+ }()
+
+ logger := New()
+ logger.Out = &bytes.Buffer{}
+ entry := NewEntry(logger)
+ entry.WithField("err", errBoom).Panicln("kaboom")
+}
+
+func TestEntryPanicf(t *testing.T) {
+ errBoom := fmt.Errorf("boom again")
+
+ defer func() {
+ p := recover()
+ assert.NotNil(t, p)
+
+ switch pVal := p.(type) {
+ case *Entry:
+ assert.Equal(t, "kaboom true", pVal.Message)
+ assert.Equal(t, errBoom, pVal.Data["err"])
+ default:
+ t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal)
+ }
+ }()
+
+ logger := New()
+ logger.Out = &bytes.Buffer{}
+ entry := NewEntry(logger)
+ entry.WithField("err", errBoom).Panicf("kaboom %v", true)
+}
diff --git a/vendor/github.com/Sirupsen/logrus/example_basic_test.go b/vendor/github.com/Sirupsen/logrus/example_basic_test.go
new file mode 100644
index 00000000..a2acf550
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/example_basic_test.go
@@ -0,0 +1,69 @@
+package logrus_test
+
+import (
+ "github.com/sirupsen/logrus"
+ "os"
+)
+
+func Example_basic() {
+ var log = logrus.New()
+ log.Formatter = new(logrus.JSONFormatter)
+ log.Formatter = new(logrus.TextFormatter) //default
+ log.Formatter.(*logrus.TextFormatter).DisableTimestamp = true // remove timestamp from test output
+ log.Level = logrus.DebugLevel
+ log.Out = os.Stdout
+
+ // file, err := os.OpenFile("logrus.log", os.O_CREATE|os.O_WRONLY, 0666)
+ // if err == nil {
+ // log.Out = file
+ // } else {
+ // log.Info("Failed to log to file, using default stderr")
+ // }
+
+ defer func() {
+ err := recover()
+ if err != nil {
+ entry := err.(*logrus.Entry)
+ log.WithFields(logrus.Fields{
+ "omg": true,
+ "err_animal": entry.Data["animal"],
+ "err_size": entry.Data["size"],
+ "err_level": entry.Level,
+ "err_message": entry.Message,
+ "number": 100,
+ }).Error("The ice breaks!") // or use Fatal() to force the process to exit with a nonzero code
+ }
+ }()
+
+ log.WithFields(logrus.Fields{
+ "animal": "walrus",
+ "number": 8,
+ }).Debug("Started observing beach")
+
+ log.WithFields(logrus.Fields{
+ "animal": "walrus",
+ "size": 10,
+ }).Info("A group of walrus emerges from the ocean")
+
+ log.WithFields(logrus.Fields{
+ "omg": true,
+ "number": 122,
+ }).Warn("The group's number increased tremendously!")
+
+ log.WithFields(logrus.Fields{
+ "temperature": -4,
+ }).Debug("Temperature changes")
+
+ log.WithFields(logrus.Fields{
+ "animal": "orca",
+ "size": 9009,
+ }).Panic("It's over 9000!")
+
+ // Output:
+ // level=debug msg="Started observing beach" animal=walrus number=8
+ // level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10
+ // level=warning msg="The group's number increased tremendously!" number=122 omg=true
+ // level=debug msg="Temperature changes" temperature=-4
+ // level=panic msg="It's over 9000!" animal=orca size=9009
+ // level=error msg="The ice breaks!" err_animal=orca err_level=panic err_message="It's over 9000!" err_size=9009 number=100 omg=true
+}
diff --git a/vendor/github.com/Sirupsen/logrus/example_hook_test.go b/vendor/github.com/Sirupsen/logrus/example_hook_test.go
new file mode 100644
index 00000000..d4ddffca
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/example_hook_test.go
@@ -0,0 +1,35 @@
+package logrus_test
+
+import (
+ "github.com/sirupsen/logrus"
+ "gopkg.in/gemnasium/logrus-airbrake-hook.v2"
+ "os"
+)
+
+func Example_hook() {
+ var log = logrus.New()
+ log.Formatter = new(logrus.TextFormatter) // default
+ log.Formatter.(*logrus.TextFormatter).DisableTimestamp = true // remove timestamp from test output
+ log.Hooks.Add(airbrake.NewHook(123, "xyz", "development"))
+ log.Out = os.Stdout
+
+ log.WithFields(logrus.Fields{
+ "animal": "walrus",
+ "size": 10,
+ }).Info("A group of walrus emerges from the ocean")
+
+ log.WithFields(logrus.Fields{
+ "omg": true,
+ "number": 122,
+ }).Warn("The group's number increased tremendously!")
+
+ log.WithFields(logrus.Fields{
+ "omg": true,
+ "number": 100,
+ }).Error("The ice breaks!")
+
+ // Output:
+ // level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10
+ // level=warning msg="The group's number increased tremendously!" number=122 omg=true
+ // level=error msg="The ice breaks!" number=100 omg=true
+}
diff --git a/vendor/github.com/Sirupsen/logrus/exported.go b/vendor/github.com/Sirupsen/logrus/exported.go
new file mode 100644
index 00000000..013183ed
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/exported.go
@@ -0,0 +1,193 @@
+package logrus
+
+import (
+ "io"
+)
+
+var (
+ // std is the name of the standard logger in stdlib `log`
+ std = New()
+)
+
+func StandardLogger() *Logger {
+ return std
+}
+
+// SetOutput sets the standard logger output.
+func SetOutput(out io.Writer) {
+ std.mu.Lock()
+ defer std.mu.Unlock()
+ std.Out = out
+}
+
+// SetFormatter sets the standard logger formatter.
+func SetFormatter(formatter Formatter) {
+ std.mu.Lock()
+ defer std.mu.Unlock()
+ std.Formatter = formatter
+}
+
+// SetLevel sets the standard logger level.
+func SetLevel(level Level) {
+ std.mu.Lock()
+ defer std.mu.Unlock()
+ std.SetLevel(level)
+}
+
+// GetLevel returns the standard logger level.
+func GetLevel() Level {
+ std.mu.Lock()
+ defer std.mu.Unlock()
+ return std.level()
+}
+
+// AddHook adds a hook to the standard logger hooks.
+func AddHook(hook Hook) {
+ std.mu.Lock()
+ defer std.mu.Unlock()
+ std.Hooks.Add(hook)
+}
+
+// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key.
+func WithError(err error) *Entry {
+ return std.WithField(ErrorKey, err)
+}
+
+// WithField creates an entry from the standard logger and adds a field to
+// it. If you want multiple fields, use `WithFields`.
+//
+// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
+// or Panic on the Entry it returns.
+func WithField(key string, value interface{}) *Entry {
+ return std.WithField(key, value)
+}
+
+// WithFields creates an entry from the standard logger and adds multiple
+// fields to it. This is simply a helper for `WithField`, invoking it
+// once for each field.
+//
+// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
+// or Panic on the Entry it returns.
+func WithFields(fields Fields) *Entry {
+ return std.WithFields(fields)
+}
+
+// Debug logs a message at level Debug on the standard logger.
+func Debug(args ...interface{}) {
+ std.Debug(args...)
+}
+
+// Print logs a message at level Info on the standard logger.
+func Print(args ...interface{}) {
+ std.Print(args...)
+}
+
+// Info logs a message at level Info on the standard logger.
+func Info(args ...interface{}) {
+ std.Info(args...)
+}
+
+// Warn logs a message at level Warn on the standard logger.
+func Warn(args ...interface{}) {
+ std.Warn(args...)
+}
+
+// Warning logs a message at level Warn on the standard logger.
+func Warning(args ...interface{}) {
+ std.Warning(args...)
+}
+
+// Error logs a message at level Error on the standard logger.
+func Error(args ...interface{}) {
+ std.Error(args...)
+}
+
+// Panic logs a message at level Panic on the standard logger.
+func Panic(args ...interface{}) {
+ std.Panic(args...)
+}
+
+// Fatal logs a message at level Fatal on the standard logger.
+func Fatal(args ...interface{}) {
+ std.Fatal(args...)
+}
+
+// Debugf logs a message at level Debug on the standard logger.
+func Debugf(format string, args ...interface{}) {
+ std.Debugf(format, args...)
+}
+
+// Printf logs a message at level Info on the standard logger.
+func Printf(format string, args ...interface{}) {
+ std.Printf(format, args...)
+}
+
+// Infof logs a message at level Info on the standard logger.
+func Infof(format string, args ...interface{}) {
+ std.Infof(format, args...)
+}
+
+// Warnf logs a message at level Warn on the standard logger.
+func Warnf(format string, args ...interface{}) {
+ std.Warnf(format, args...)
+}
+
+// Warningf logs a message at level Warn on the standard logger.
+func Warningf(format string, args ...interface{}) {
+ std.Warningf(format, args...)
+}
+
+// Errorf logs a message at level Error on the standard logger.
+func Errorf(format string, args ...interface{}) {
+ std.Errorf(format, args...)
+}
+
+// Panicf logs a message at level Panic on the standard logger.
+func Panicf(format string, args ...interface{}) {
+ std.Panicf(format, args...)
+}
+
+// Fatalf logs a message at level Fatal on the standard logger.
+func Fatalf(format string, args ...interface{}) {
+ std.Fatalf(format, args...)
+}
+
+// Debugln logs a message at level Debug on the standard logger.
+func Debugln(args ...interface{}) {
+ std.Debugln(args...)
+}
+
+// Println logs a message at level Info on the standard logger.
+func Println(args ...interface{}) {
+ std.Println(args...)
+}
+
+// Infoln logs a message at level Info on the standard logger.
+func Infoln(args ...interface{}) {
+ std.Infoln(args...)
+}
+
+// Warnln logs a message at level Warn on the standard logger.
+func Warnln(args ...interface{}) {
+ std.Warnln(args...)
+}
+
+// Warningln logs a message at level Warn on the standard logger.
+func Warningln(args ...interface{}) {
+ std.Warningln(args...)
+}
+
+// Errorln logs a message at level Error on the standard logger.
+func Errorln(args ...interface{}) {
+ std.Errorln(args...)
+}
+
+// Panicln logs a message at level Panic on the standard logger.
+func Panicln(args ...interface{}) {
+ std.Panicln(args...)
+}
+
+// Fatalln logs a message at level Fatal on the standard logger.
+func Fatalln(args ...interface{}) {
+ std.Fatalln(args...)
+}
diff --git a/vendor/github.com/Sirupsen/logrus/formatter.go b/vendor/github.com/Sirupsen/logrus/formatter.go
new file mode 100644
index 00000000..b183ff5b
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/formatter.go
@@ -0,0 +1,45 @@
+package logrus
+
+import "time"
+
+const defaultTimestampFormat = time.RFC3339
+
+// The Formatter interface is used to implement a custom Formatter. It takes an
+// `Entry`. It exposes all the fields, including the default ones:
+//
+// * `entry.Data["msg"]`. The message passed from Info, Warn, Error ..
+// * `entry.Data["time"]`. The timestamp.
+// * `entry.Data["level"]. The level the entry was logged at.
+//
+// Any additional fields added with `WithField` or `WithFields` are also in
+// `entry.Data`. Format is expected to return an array of bytes which are then
+// logged to `logger.Out`.
+type Formatter interface {
+ Format(*Entry) ([]byte, error)
+}
+
+// This is to not silently overwrite `time`, `msg` and `level` fields when
+// dumping it. If this code wasn't there doing:
+//
+// logrus.WithField("level", 1).Info("hello")
+//
+// Would just silently drop the user provided level. Instead with this code
+// it'll logged as:
+//
+// {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."}
+//
+// It's not exported because it's still using Data in an opinionated way. It's to
+// avoid code duplication between the two default formatters.
+func prefixFieldClashes(data Fields) {
+ if t, ok := data["time"]; ok {
+ data["fields.time"] = t
+ }
+
+ if m, ok := data["msg"]; ok {
+ data["fields.msg"] = m
+ }
+
+ if l, ok := data["level"]; ok {
+ data["fields.level"] = l
+ }
+}
diff --git a/vendor/github.com/Sirupsen/logrus/formatter_bench_test.go b/vendor/github.com/Sirupsen/logrus/formatter_bench_test.go
new file mode 100644
index 00000000..d9481589
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/formatter_bench_test.go
@@ -0,0 +1,101 @@
+package logrus
+
+import (
+ "fmt"
+ "testing"
+ "time"
+)
+
+// smallFields is a small size data set for benchmarking
+var smallFields = Fields{
+ "foo": "bar",
+ "baz": "qux",
+ "one": "two",
+ "three": "four",
+}
+
+// largeFields is a large size data set for benchmarking
+var largeFields = Fields{
+ "foo": "bar",
+ "baz": "qux",
+ "one": "two",
+ "three": "four",
+ "five": "six",
+ "seven": "eight",
+ "nine": "ten",
+ "eleven": "twelve",
+ "thirteen": "fourteen",
+ "fifteen": "sixteen",
+ "seventeen": "eighteen",
+ "nineteen": "twenty",
+ "a": "b",
+ "c": "d",
+ "e": "f",
+ "g": "h",
+ "i": "j",
+ "k": "l",
+ "m": "n",
+ "o": "p",
+ "q": "r",
+ "s": "t",
+ "u": "v",
+ "w": "x",
+ "y": "z",
+ "this": "will",
+ "make": "thirty",
+ "entries": "yeah",
+}
+
+var errorFields = Fields{
+ "foo": fmt.Errorf("bar"),
+ "baz": fmt.Errorf("qux"),
+}
+
+func BenchmarkErrorTextFormatter(b *testing.B) {
+ doBenchmark(b, &TextFormatter{DisableColors: true}, errorFields)
+}
+
+func BenchmarkSmallTextFormatter(b *testing.B) {
+ doBenchmark(b, &TextFormatter{DisableColors: true}, smallFields)
+}
+
+func BenchmarkLargeTextFormatter(b *testing.B) {
+ doBenchmark(b, &TextFormatter{DisableColors: true}, largeFields)
+}
+
+func BenchmarkSmallColoredTextFormatter(b *testing.B) {
+ doBenchmark(b, &TextFormatter{ForceColors: true}, smallFields)
+}
+
+func BenchmarkLargeColoredTextFormatter(b *testing.B) {
+ doBenchmark(b, &TextFormatter{ForceColors: true}, largeFields)
+}
+
+func BenchmarkSmallJSONFormatter(b *testing.B) {
+ doBenchmark(b, &JSONFormatter{}, smallFields)
+}
+
+func BenchmarkLargeJSONFormatter(b *testing.B) {
+ doBenchmark(b, &JSONFormatter{}, largeFields)
+}
+
+func doBenchmark(b *testing.B, formatter Formatter, fields Fields) {
+ logger := New()
+
+ entry := &Entry{
+ Time: time.Time{},
+ Level: InfoLevel,
+ Message: "message",
+ Data: fields,
+ Logger: logger,
+ }
+ var d []byte
+ var err error
+ for i := 0; i < b.N; i++ {
+ d, err = formatter.Format(entry)
+ if err != nil {
+ b.Fatal(err)
+ }
+ b.SetBytes(int64(len(d)))
+ }
+}
diff --git a/vendor/github.com/Sirupsen/logrus/hook_test.go b/vendor/github.com/Sirupsen/logrus/hook_test.go
new file mode 100644
index 00000000..13f34cb6
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/hook_test.go
@@ -0,0 +1,122 @@
+package logrus
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+type TestHook struct {
+ Fired bool
+}
+
+func (hook *TestHook) Fire(entry *Entry) error {
+ hook.Fired = true
+ return nil
+}
+
+func (hook *TestHook) Levels() []Level {
+ return []Level{
+ DebugLevel,
+ InfoLevel,
+ WarnLevel,
+ ErrorLevel,
+ FatalLevel,
+ PanicLevel,
+ }
+}
+
+func TestHookFires(t *testing.T) {
+ hook := new(TestHook)
+
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.Hooks.Add(hook)
+ assert.Equal(t, hook.Fired, false)
+
+ log.Print("test")
+ }, func(fields Fields) {
+ assert.Equal(t, hook.Fired, true)
+ })
+}
+
+type ModifyHook struct {
+}
+
+func (hook *ModifyHook) Fire(entry *Entry) error {
+ entry.Data["wow"] = "whale"
+ return nil
+}
+
+func (hook *ModifyHook) Levels() []Level {
+ return []Level{
+ DebugLevel,
+ InfoLevel,
+ WarnLevel,
+ ErrorLevel,
+ FatalLevel,
+ PanicLevel,
+ }
+}
+
+func TestHookCanModifyEntry(t *testing.T) {
+ hook := new(ModifyHook)
+
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.Hooks.Add(hook)
+ log.WithField("wow", "elephant").Print("test")
+ }, func(fields Fields) {
+ assert.Equal(t, fields["wow"], "whale")
+ })
+}
+
+func TestCanFireMultipleHooks(t *testing.T) {
+ hook1 := new(ModifyHook)
+ hook2 := new(TestHook)
+
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.Hooks.Add(hook1)
+ log.Hooks.Add(hook2)
+
+ log.WithField("wow", "elephant").Print("test")
+ }, func(fields Fields) {
+ assert.Equal(t, fields["wow"], "whale")
+ assert.Equal(t, hook2.Fired, true)
+ })
+}
+
+type ErrorHook struct {
+ Fired bool
+}
+
+func (hook *ErrorHook) Fire(entry *Entry) error {
+ hook.Fired = true
+ return nil
+}
+
+func (hook *ErrorHook) Levels() []Level {
+ return []Level{
+ ErrorLevel,
+ }
+}
+
+func TestErrorHookShouldntFireOnInfo(t *testing.T) {
+ hook := new(ErrorHook)
+
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.Hooks.Add(hook)
+ log.Info("test")
+ }, func(fields Fields) {
+ assert.Equal(t, hook.Fired, false)
+ })
+}
+
+func TestErrorHookShouldFireOnError(t *testing.T) {
+ hook := new(ErrorHook)
+
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.Hooks.Add(hook)
+ log.Error("test")
+ }, func(fields Fields) {
+ assert.Equal(t, hook.Fired, true)
+ })
+}
diff --git a/newt/vendor/github.com/Sirupsen/logrus/hooks.go b/vendor/github.com/Sirupsen/logrus/hooks.go
similarity index 100%
rename from newt/vendor/github.com/Sirupsen/logrus/hooks.go
rename to vendor/github.com/Sirupsen/logrus/hooks.go
diff --git a/vendor/github.com/Sirupsen/logrus/hooks/syslog/README.md b/vendor/github.com/Sirupsen/logrus/hooks/syslog/README.md
new file mode 100644
index 00000000..1bbc0f72
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/hooks/syslog/README.md
@@ -0,0 +1,39 @@
+# Syslog Hooks for Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/>
+
+## Usage
+
+```go
+import (
+ "log/syslog"
+ "github.com/sirupsen/logrus"
+ lSyslog "github.com/sirupsen/logrus/hooks/syslog"
+)
+
+func main() {
+ log := logrus.New()
+ hook, err := lSyslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
+
+ if err == nil {
+ log.Hooks.Add(hook)
+ }
+}
+```
+
+If you want to connect to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). Just assign empty string to the first two parameters of `NewSyslogHook`. It should look like the following.
+
+```go
+import (
+ "log/syslog"
+ "github.com/sirupsen/logrus"
+ lSyslog "github.com/sirupsen/logrus/hooks/syslog"
+)
+
+func main() {
+ log := logrus.New()
+ hook, err := lSyslog.NewSyslogHook("", "", syslog.LOG_INFO, "")
+
+ if err == nil {
+ log.Hooks.Add(hook)
+ }
+}
+```
diff --git a/vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog.go b/vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog.go
new file mode 100644
index 00000000..329ce0d6
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog.go
@@ -0,0 +1,55 @@
+// +build !windows,!nacl,!plan9
+
+package syslog
+
+import (
+ "fmt"
+ "log/syslog"
+ "os"
+
+ "github.com/sirupsen/logrus"
+)
+
+// SyslogHook to send logs via syslog.
+type SyslogHook struct {
+ Writer *syslog.Writer
+ SyslogNetwork string
+ SyslogRaddr string
+}
+
+// Creates a hook to be added to an instance of logger. This is called with
+// `hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_DEBUG, "")`
+// `if err == nil { log.Hooks.Add(hook) }`
+func NewSyslogHook(network, raddr string, priority syslog.Priority, tag string) (*SyslogHook, error) {
+ w, err := syslog.Dial(network, raddr, priority, tag)
+ return &SyslogHook{w, network, raddr}, err
+}
+
+func (hook *SyslogHook) Fire(entry *logrus.Entry) error {
+ line, err := entry.String()
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Unable to read entry, %v", err)
+ return err
+ }
+
+ switch entry.Level {
+ case logrus.PanicLevel:
+ return hook.Writer.Crit(line)
+ case logrus.FatalLevel:
+ return hook.Writer.Crit(line)
+ case logrus.ErrorLevel:
+ return hook.Writer.Err(line)
+ case logrus.WarnLevel:
+ return hook.Writer.Warning(line)
+ case logrus.InfoLevel:
+ return hook.Writer.Info(line)
+ case logrus.DebugLevel:
+ return hook.Writer.Debug(line)
+ default:
+ return nil
+ }
+}
+
+func (hook *SyslogHook) Levels() []logrus.Level {
+ return logrus.AllLevels
+}
diff --git a/vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog_test.go b/vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog_test.go
new file mode 100644
index 00000000..5ec3a444
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog_test.go
@@ -0,0 +1,27 @@
+package syslog
+
+import (
+ "log/syslog"
+ "testing"
+
+ "github.com/sirupsen/logrus"
+)
+
+func TestLocalhostAddAndPrint(t *testing.T) {
+ log := logrus.New()
+ hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
+
+ if err != nil {
+ t.Errorf("Unable to connect to local syslog.")
+ }
+
+ log.Hooks.Add(hook)
+
+ for _, level := range hook.Levels() {
+ if len(log.Hooks[level]) != 1 {
+ t.Errorf("SyslogHook was not added. The length of log.Hooks[%v]: %v", level, len(log.Hooks[level]))
+ }
+ }
+
+ log.Info("Congratulations!")
+}
diff --git a/vendor/github.com/Sirupsen/logrus/hooks/test/test.go b/vendor/github.com/Sirupsen/logrus/hooks/test/test.go
new file mode 100644
index 00000000..62c4845d
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/hooks/test/test.go
@@ -0,0 +1,95 @@
+// The Test package is used for testing logrus. It is here for backwards
+// compatibility from when logrus' organization was upper-case. Please use
+// lower-case logrus and the `null` package instead of this one.
+package test
+
+import (
+ "io/ioutil"
+ "sync"
+
+ "github.com/sirupsen/logrus"
+)
+
+// Hook is a hook designed for dealing with logs in test scenarios.
+type Hook struct {
+ // Entries is an array of all entries that have been received by this hook.
+ // For safe access, use the AllEntries() method, rather than reading this
+ // value directly.
+ Entries []*logrus.Entry
+ mu sync.RWMutex
+}
+
+// NewGlobal installs a test hook for the global logger.
+func NewGlobal() *Hook {
+
+ hook := new(Hook)
+ logrus.AddHook(hook)
+
+ return hook
+
+}
+
+// NewLocal installs a test hook for a given local logger.
+func NewLocal(logger *logrus.Logger) *Hook {
+
+ hook := new(Hook)
+ logger.Hooks.Add(hook)
+
+ return hook
+
+}
+
+// NewNullLogger creates a discarding logger and installs the test hook.
+func NewNullLogger() (*logrus.Logger, *Hook) {
+
+ logger := logrus.New()
+ logger.Out = ioutil.Discard
+
+ return logger, NewLocal(logger)
+
+}
+
+func (t *Hook) Fire(e *logrus.Entry) error {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ t.Entries = append(t.Entries, e)
+ return nil
+}
+
+func (t *Hook) Levels() []logrus.Level {
+ return logrus.AllLevels
+}
+
+// LastEntry returns the last entry that was logged or nil.
+func (t *Hook) LastEntry() *logrus.Entry {
+ t.mu.RLock()
+ defer t.mu.RUnlock()
+ i := len(t.Entries) - 1
+ if i < 0 {
+ return nil
+ }
+ // Make a copy, for safety
+ e := *t.Entries[i]
+ return &e
+}
+
+// AllEntries returns all entries that were logged.
+func (t *Hook) AllEntries() []*logrus.Entry {
+ t.mu.RLock()
+ defer t.mu.RUnlock()
+ // Make a copy so the returned value won't race with future log requests
+ entries := make([]*logrus.Entry, len(t.Entries))
+ for i, entry := range t.Entries {
+ // Make a copy, for safety
+ e := *entry
+ entries[i] = &e
+ }
+ return entries
+}
+
+// Reset removes all Entries from this test hook.
+func (t *Hook) Reset() {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ t.Entries = make([]*logrus.Entry, 0)
+}
diff --git a/vendor/github.com/Sirupsen/logrus/hooks/test/test_test.go b/vendor/github.com/Sirupsen/logrus/hooks/test/test_test.go
new file mode 100644
index 00000000..3f55cfe3
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/hooks/test/test_test.go
@@ -0,0 +1,39 @@
+package test
+
+import (
+ "testing"
+
+ "github.com/sirupsen/logrus"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestAllHooks(t *testing.T) {
+
+ assert := assert.New(t)
+
+ logger, hook := NewNullLogger()
+ assert.Nil(hook.LastEntry())
+ assert.Equal(0, len(hook.Entries))
+
+ logger.Error("Hello error")
+ assert.Equal(logrus.ErrorLevel, hook.LastEntry().Level)
+ assert.Equal("Hello error", hook.LastEntry().Message)
+ assert.Equal(1, len(hook.Entries))
+
+ logger.Warn("Hello warning")
+ assert.Equal(logrus.WarnLevel, hook.LastEntry().Level)
+ assert.Equal("Hello warning", hook.LastEntry().Message)
+ assert.Equal(2, len(hook.Entries))
+
+ hook.Reset()
+ assert.Nil(hook.LastEntry())
+ assert.Equal(0, len(hook.Entries))
+
+ hook = NewGlobal()
+
+ logrus.Error("Hello error")
+ assert.Equal(logrus.ErrorLevel, hook.LastEntry().Level)
+ assert.Equal("Hello error", hook.LastEntry().Message)
+ assert.Equal(1, len(hook.Entries))
+
+}
diff --git a/vendor/github.com/Sirupsen/logrus/json_formatter.go b/vendor/github.com/Sirupsen/logrus/json_formatter.go
new file mode 100644
index 00000000..fb01c1b1
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/json_formatter.go
@@ -0,0 +1,79 @@
+package logrus
+
+import (
+ "encoding/json"
+ "fmt"
+)
+
+type fieldKey string
+
+// FieldMap allows customization of the key names for default fields.
+type FieldMap map[fieldKey]string
+
+// Default key names for the default fields
+const (
+ FieldKeyMsg = "msg"
+ FieldKeyLevel = "level"
+ FieldKeyTime = "time"
+)
+
+func (f FieldMap) resolve(key fieldKey) string {
+ if k, ok := f[key]; ok {
+ return k
+ }
+
+ return string(key)
+}
+
+// JSONFormatter formats logs into parsable json
+type JSONFormatter struct {
+ // TimestampFormat sets the format used for marshaling timestamps.
+ TimestampFormat string
+
+ // DisableTimestamp allows disabling automatic timestamps in output
+ DisableTimestamp bool
+
+ // FieldMap allows users to customize the names of keys for default fields.
+ // As an example:
+ // formatter := &JSONFormatter{
+ // FieldMap: FieldMap{
+ // FieldKeyTime: "@timestamp",
+ // FieldKeyLevel: "@level",
+ // FieldKeyMsg: "@message",
+ // },
+ // }
+ FieldMap FieldMap
+}
+
+// Format renders a single log entry
+func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
+ data := make(Fields, len(entry.Data)+3)
+ for k, v := range entry.Data {
+ switch v := v.(type) {
+ case error:
+ // Otherwise errors are ignored by `encoding/json`
+ // https://github.com/sirupsen/logrus/issues/137
+ data[k] = v.Error()
+ default:
+ data[k] = v
+ }
+ }
+ prefixFieldClashes(data)
+
+ timestampFormat := f.TimestampFormat
+ if timestampFormat == "" {
+ timestampFormat = defaultTimestampFormat
+ }
+
+ if !f.DisableTimestamp {
+ data[f.FieldMap.resolve(FieldKeyTime)] = entry.Time.Format(timestampFormat)
+ }
+ data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message
+ data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String()
+
+ serialized, err := json.Marshal(data)
+ if err != nil {
+ return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
+ }
+ return append(serialized, '\n'), nil
+}
diff --git a/vendor/github.com/Sirupsen/logrus/json_formatter_test.go b/vendor/github.com/Sirupsen/logrus/json_formatter_test.go
new file mode 100644
index 00000000..51093a79
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/json_formatter_test.go
@@ -0,0 +1,199 @@
+package logrus
+
+import (
+ "encoding/json"
+ "errors"
+ "strings"
+ "testing"
+)
+
+func TestErrorNotLost(t *testing.T) {
+ formatter := &JSONFormatter{}
+
+ b, err := formatter.Format(WithField("error", errors.New("wild walrus")))
+ if err != nil {
+ t.Fatal("Unable to format entry: ", err)
+ }
+
+ entry := make(map[string]interface{})
+ err = json.Unmarshal(b, &entry)
+ if err != nil {
+ t.Fatal("Unable to unmarshal formatted entry: ", err)
+ }
+
+ if entry["error"] != "wild walrus" {
+ t.Fatal("Error field not set")
+ }
+}
+
+func TestErrorNotLostOnFieldNotNamedError(t *testing.T) {
+ formatter := &JSONFormatter{}
+
+ b, err := formatter.Format(WithField("omg", errors.New("wild walrus")))
+ if err != nil {
+ t.Fatal("Unable to format entry: ", err)
+ }
+
+ entry := make(map[string]interface{})
+ err = json.Unmarshal(b, &entry)
+ if err != nil {
+ t.Fatal("Unable to unmarshal formatted entry: ", err)
+ }
+
+ if entry["omg"] != "wild walrus" {
+ t.Fatal("Error field not set")
+ }
+}
+
+func TestFieldClashWithTime(t *testing.T) {
+ formatter := &JSONFormatter{}
+
+ b, err := formatter.Format(WithField("time", "right now!"))
+ if err != nil {
+ t.Fatal("Unable to format entry: ", err)
+ }
+
+ entry := make(map[string]interface{})
+ err = json.Unmarshal(b, &entry)
+ if err != nil {
+ t.Fatal("Unable to unmarshal formatted entry: ", err)
+ }
+
+ if entry["fields.time"] != "right now!" {
+ t.Fatal("fields.time not set to original time field")
+ }
+
+ if entry["time"] != "0001-01-01T00:00:00Z" {
+ t.Fatal("time field not set to current time, was: ", entry["time"])
+ }
+}
+
+func TestFieldClashWithMsg(t *testing.T) {
+ formatter := &JSONFormatter{}
+
+ b, err := formatter.Format(WithField("msg", "something"))
+ if err != nil {
+ t.Fatal("Unable to format entry: ", err)
+ }
+
+ entry := make(map[string]interface{})
+ err = json.Unmarshal(b, &entry)
+ if err != nil {
+ t.Fatal("Unable to unmarshal formatted entry: ", err)
+ }
+
+ if entry["fields.msg"] != "something" {
+ t.Fatal("fields.msg not set to original msg field")
+ }
+}
+
+func TestFieldClashWithLevel(t *testing.T) {
+ formatter := &JSONFormatter{}
+
+ b, err := formatter.Format(WithField("level", "something"))
+ if err != nil {
+ t.Fatal("Unable to format entry: ", err)
+ }
+
+ entry := make(map[string]interface{})
+ err = json.Unmarshal(b, &entry)
+ if err != nil {
+ t.Fatal("Unable to unmarshal formatted entry: ", err)
+ }
+
+ if entry["fields.level"] != "something" {
+ t.Fatal("fields.level not set to original level field")
+ }
+}
+
+func TestJSONEntryEndsWithNewline(t *testing.T) {
+ formatter := &JSONFormatter{}
+
+ b, err := formatter.Format(WithField("level", "something"))
+ if err != nil {
+ t.Fatal("Unable to format entry: ", err)
+ }
+
+ if b[len(b)-1] != '\n' {
+ t.Fatal("Expected JSON log entry to end with a newline")
+ }
+}
+
+func TestJSONMessageKey(t *testing.T) {
+ formatter := &JSONFormatter{
+ FieldMap: FieldMap{
+ FieldKeyMsg: "message",
+ },
+ }
+
+ b, err := formatter.Format(&Entry{Message: "oh hai"})
+ if err != nil {
+ t.Fatal("Unable to format entry: ", err)
+ }
+ s := string(b)
+ if !(strings.Contains(s, "message") && strings.Contains(s, "oh hai")) {
+ t.Fatal("Expected JSON to format message key")
+ }
+}
+
+func TestJSONLevelKey(t *testing.T) {
+ formatter := &JSONFormatter{
+ FieldMap: FieldMap{
+ FieldKeyLevel: "somelevel",
+ },
+ }
+
+ b, err := formatter.Format(WithField("level", "something"))
+ if err != nil {
+ t.Fatal("Unable to format entry: ", err)
+ }
+ s := string(b)
+ if !strings.Contains(s, "somelevel") {
+ t.Fatal("Expected JSON to format level key")
+ }
+}
+
+func TestJSONTimeKey(t *testing.T) {
+ formatter := &JSONFormatter{
+ FieldMap: FieldMap{
+ FieldKeyTime: "timeywimey",
+ },
+ }
+
+ b, err := formatter.Format(WithField("level", "something"))
+ if err != nil {
+ t.Fatal("Unable to format entry: ", err)
+ }
+ s := string(b)
+ if !strings.Contains(s, "timeywimey") {
+ t.Fatal("Expected JSON to format time key")
+ }
+}
+
+func TestJSONDisableTimestamp(t *testing.T) {
+ formatter := &JSONFormatter{
+ DisableTimestamp: true,
+ }
+
+ b, err := formatter.Format(WithField("level", "something"))
+ if err != nil {
+ t.Fatal("Unable to format entry: ", err)
+ }
+ s := string(b)
+ if strings.Contains(s, FieldKeyTime) {
+ t.Error("Did not prevent timestamp", s)
+ }
+}
+
+func TestJSONEnableTimestamp(t *testing.T) {
+ formatter := &JSONFormatter{}
+
+ b, err := formatter.Format(WithField("level", "something"))
+ if err != nil {
+ t.Fatal("Unable to format entry: ", err)
+ }
+ s := string(b)
+ if !strings.Contains(s, FieldKeyTime) {
+ t.Error("Timestamp not present", s)
+ }
+}
diff --git a/vendor/github.com/Sirupsen/logrus/logger.go b/vendor/github.com/Sirupsen/logrus/logger.go
new file mode 100644
index 00000000..2acab050
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/logger.go
@@ -0,0 +1,317 @@
+package logrus
+
+import (
+ "io"
+ "os"
+ "sync"
+ "sync/atomic"
+)
+
+type Logger struct {
+ // The logs are `io.Copy`'d to this in a mutex. It's common to set this to a
+ // file, or leave it default which is `os.Stderr`. You can also set this to
+ // something more adventorous, such as logging to Kafka.
+ Out io.Writer
+ // Hooks for the logger instance. These allow firing events based on logging
+ // levels and log entries. For example, to send errors to an error tracking
+ // service, log to StatsD or dump the core on fatal errors.
+ Hooks LevelHooks
+ // All log entries pass through the formatter before logged to Out. The
+ // included formatters are `TextFormatter` and `JSONFormatter` for which
+ // TextFormatter is the default. In development (when a TTY is attached) it
+ // logs with colors, but to a file it wouldn't. You can easily implement your
+ // own that implements the `Formatter` interface, see the `README` or included
+ // formatters for examples.
+ Formatter Formatter
+ // The logging level the logger should log at. This is typically (and defaults
+ // to) `logrus.Info`, which allows Info(), Warn(), Error() and Fatal() to be
+ // logged.
+ Level Level
+ // Used to sync writing to the log. Locking is enabled by Default
+ mu MutexWrap
+ // Reusable empty entry
+ entryPool sync.Pool
+}
+
+type MutexWrap struct {
+ lock sync.Mutex
+ disabled bool
+}
+
+func (mw *MutexWrap) Lock() {
+ if !mw.disabled {
+ mw.lock.Lock()
+ }
+}
+
+func (mw *MutexWrap) Unlock() {
+ if !mw.disabled {
+ mw.lock.Unlock()
+ }
+}
+
+func (mw *MutexWrap) Disable() {
+ mw.disabled = true
+}
+
+// Creates a new logger. Configuration should be set by changing `Formatter`,
+// `Out` and `Hooks` directly on the default logger instance. You can also just
+// instantiate your own:
+//
+// var log = &Logger{
+// Out: os.Stderr,
+// Formatter: new(JSONFormatter),
+// Hooks: make(LevelHooks),
+// Level: logrus.DebugLevel,
+// }
+//
+// It's recommended to make this a global instance called `log`.
+func New() *Logger {
+ return &Logger{
+ Out: os.Stderr,
+ Formatter: new(TextFormatter),
+ Hooks: make(LevelHooks),
+ Level: InfoLevel,
+ }
+}
+
+func (logger *Logger) newEntry() *Entry {
+ entry, ok := logger.entryPool.Get().(*Entry)
+ if ok {
+ return entry
+ }
+ return NewEntry(logger)
+}
+
+func (logger *Logger) releaseEntry(entry *Entry) {
+ logger.entryPool.Put(entry)
+}
+
+// Adds a field to the log entry, note that it doesn't log until you call
+// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry.
+// If you want multiple fields, use `WithFields`.
+func (logger *Logger) WithField(key string, value interface{}) *Entry {
+ entry := logger.newEntry()
+ defer logger.releaseEntry(entry)
+ return entry.WithField(key, value)
+}
+
+// Adds a struct of fields to the log entry. All it does is call `WithField` for
+// each `Field`.
+func (logger *Logger) WithFields(fields Fields) *Entry {
+ entry := logger.newEntry()
+ defer logger.releaseEntry(entry)
+ return entry.WithFields(fields)
+}
+
+// Add an error as single field to the log entry. All it does is call
+// `WithError` for the given `error`.
+func (logger *Logger) WithError(err error) *Entry {
+ entry := logger.newEntry()
+ defer logger.releaseEntry(entry)
+ return entry.WithError(err)
+}
+
+func (logger *Logger) Debugf(format string, args ...interface{}) {
+ if logger.level() >= DebugLevel {
+ entry := logger.newEntry()
+ entry.Debugf(format, args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Infof(format string, args ...interface{}) {
+ if logger.level() >= InfoLevel {
+ entry := logger.newEntry()
+ entry.Infof(format, args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Printf(format string, args ...interface{}) {
+ entry := logger.newEntry()
+ entry.Printf(format, args...)
+ logger.releaseEntry(entry)
+}
+
+func (logger *Logger) Warnf(format string, args ...interface{}) {
+ if logger.level() >= WarnLevel {
+ entry := logger.newEntry()
+ entry.Warnf(format, args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Warningf(format string, args ...interface{}) {
+ if logger.level() >= WarnLevel {
+ entry := logger.newEntry()
+ entry.Warnf(format, args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Errorf(format string, args ...interface{}) {
+ if logger.level() >= ErrorLevel {
+ entry := logger.newEntry()
+ entry.Errorf(format, args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Fatalf(format string, args ...interface{}) {
+ if logger.level() >= FatalLevel {
+ entry := logger.newEntry()
+ entry.Fatalf(format, args...)
+ logger.releaseEntry(entry)
+ }
+ Exit(1)
+}
+
+func (logger *Logger) Panicf(format string, args ...interface{}) {
+ if logger.level() >= PanicLevel {
+ entry := logger.newEntry()
+ entry.Panicf(format, args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Debug(args ...interface{}) {
+ if logger.level() >= DebugLevel {
+ entry := logger.newEntry()
+ entry.Debug(args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Info(args ...interface{}) {
+ if logger.level() >= InfoLevel {
+ entry := logger.newEntry()
+ entry.Info(args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Print(args ...interface{}) {
+ entry := logger.newEntry()
+ entry.Info(args...)
+ logger.releaseEntry(entry)
+}
+
+func (logger *Logger) Warn(args ...interface{}) {
+ if logger.level() >= WarnLevel {
+ entry := logger.newEntry()
+ entry.Warn(args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Warning(args ...interface{}) {
+ if logger.level() >= WarnLevel {
+ entry := logger.newEntry()
+ entry.Warn(args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Error(args ...interface{}) {
+ if logger.level() >= ErrorLevel {
+ entry := logger.newEntry()
+ entry.Error(args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Fatal(args ...interface{}) {
+ if logger.level() >= FatalLevel {
+ entry := logger.newEntry()
+ entry.Fatal(args...)
+ logger.releaseEntry(entry)
+ }
+ Exit(1)
+}
+
+func (logger *Logger) Panic(args ...interface{}) {
+ if logger.level() >= PanicLevel {
+ entry := logger.newEntry()
+ entry.Panic(args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Debugln(args ...interface{}) {
+ if logger.level() >= DebugLevel {
+ entry := logger.newEntry()
+ entry.Debugln(args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Infoln(args ...interface{}) {
+ if logger.level() >= InfoLevel {
+ entry := logger.newEntry()
+ entry.Infoln(args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Println(args ...interface{}) {
+ entry := logger.newEntry()
+ entry.Println(args...)
+ logger.releaseEntry(entry)
+}
+
+func (logger *Logger) Warnln(args ...interface{}) {
+ if logger.level() >= WarnLevel {
+ entry := logger.newEntry()
+ entry.Warnln(args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Warningln(args ...interface{}) {
+ if logger.level() >= WarnLevel {
+ entry := logger.newEntry()
+ entry.Warnln(args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Errorln(args ...interface{}) {
+ if logger.level() >= ErrorLevel {
+ entry := logger.newEntry()
+ entry.Errorln(args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+func (logger *Logger) Fatalln(args ...interface{}) {
+ if logger.level() >= FatalLevel {
+ entry := logger.newEntry()
+ entry.Fatalln(args...)
+ logger.releaseEntry(entry)
+ }
+ Exit(1)
+}
+
+func (logger *Logger) Panicln(args ...interface{}) {
+ if logger.level() >= PanicLevel {
+ entry := logger.newEntry()
+ entry.Panicln(args...)
+ logger.releaseEntry(entry)
+ }
+}
+
+//When file is opened with appending mode, it's safe to
+//write concurrently to a file (within 4k message on Linux).
+//In these cases user can choose to disable the lock.
+func (logger *Logger) SetNoLock() {
+ logger.mu.Disable()
+}
+
+func (logger *Logger) level() Level {
+ return Level(atomic.LoadUint32((*uint32)(&logger.Level)))
+}
+
+func (logger *Logger) SetLevel(level Level) {
+ atomic.StoreUint32((*uint32)(&logger.Level), uint32(level))
+}
diff --git a/vendor/github.com/Sirupsen/logrus/logger_bench_test.go b/vendor/github.com/Sirupsen/logrus/logger_bench_test.go
new file mode 100644
index 00000000..dd23a353
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/logger_bench_test.go
@@ -0,0 +1,61 @@
+package logrus
+
+import (
+ "os"
+ "testing"
+)
+
+// smallFields is a small size data set for benchmarking
+var loggerFields = Fields{
+ "foo": "bar",
+ "baz": "qux",
+ "one": "two",
+ "three": "four",
+}
+
+func BenchmarkDummyLogger(b *testing.B) {
+ nullf, err := os.OpenFile("/dev/null", os.O_WRONLY, 0666)
+ if err != nil {
+ b.Fatalf("%v", err)
+ }
+ defer nullf.Close()
+ doLoggerBenchmark(b, nullf, &TextFormatter{DisableColors: true}, smallFields)
+}
+
+func BenchmarkDummyLoggerNoLock(b *testing.B) {
+ nullf, err := os.OpenFile("/dev/null", os.O_WRONLY|os.O_APPEND, 0666)
+ if err != nil {
+ b.Fatalf("%v", err)
+ }
+ defer nullf.Close()
+ doLoggerBenchmarkNoLock(b, nullf, &TextFormatter{DisableColors: true}, smallFields)
+}
+
+func doLoggerBenchmark(b *testing.B, out *os.File, formatter Formatter, fields Fields) {
+ logger := Logger{
+ Out: out,
+ Level: InfoLevel,
+ Formatter: formatter,
+ }
+ entry := logger.WithFields(fields)
+ b.RunParallel(func(pb *testing.PB) {
+ for pb.Next() {
+ entry.Info("aaa")
+ }
+ })
+}
+
+func doLoggerBenchmarkNoLock(b *testing.B, out *os.File, formatter Formatter, fields Fields) {
+ logger := Logger{
+ Out: out,
+ Level: InfoLevel,
+ Formatter: formatter,
+ }
+ logger.SetNoLock()
+ entry := logger.WithFields(fields)
+ b.RunParallel(func(pb *testing.PB) {
+ for pb.Next() {
+ entry.Info("aaa")
+ }
+ })
+}
diff --git a/vendor/github.com/Sirupsen/logrus/logrus.go b/vendor/github.com/Sirupsen/logrus/logrus.go
new file mode 100644
index 00000000..dd389997
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/logrus.go
@@ -0,0 +1,143 @@
+package logrus
+
+import (
+ "fmt"
+ "log"
+ "strings"
+)
+
+// Fields type, used to pass to `WithFields`.
+type Fields map[string]interface{}
+
+// Level type
+type Level uint32
+
+// Convert the Level to a string. E.g. PanicLevel becomes "panic".
+func (level Level) String() string {
+ switch level {
+ case DebugLevel:
+ return "debug"
+ case InfoLevel:
+ return "info"
+ case WarnLevel:
+ return "warning"
+ case ErrorLevel:
+ return "error"
+ case FatalLevel:
+ return "fatal"
+ case PanicLevel:
+ return "panic"
+ }
+
+ return "unknown"
+}
+
+// ParseLevel takes a string level and returns the Logrus log level constant.
+func ParseLevel(lvl string) (Level, error) {
+ switch strings.ToLower(lvl) {
+ case "panic":
+ return PanicLevel, nil
+ case "fatal":
+ return FatalLevel, nil
+ case "error":
+ return ErrorLevel, nil
+ case "warn", "warning":
+ return WarnLevel, nil
+ case "info":
+ return InfoLevel, nil
+ case "debug":
+ return DebugLevel, nil
+ }
+
+ var l Level
+ return l, fmt.Errorf("not a valid logrus Level: %q", lvl)
+}
+
+// A constant exposing all logging levels
+var AllLevels = []Level{
+ PanicLevel,
+ FatalLevel,
+ ErrorLevel,
+ WarnLevel,
+ InfoLevel,
+ DebugLevel,
+}
+
+// These are the different logging levels. You can set the logging level to log
+// on your instance of logger, obtained with `logrus.New()`.
+const (
+ // PanicLevel level, highest level of severity. Logs and then calls panic with the
+ // message passed to Debug, Info, ...
+ PanicLevel Level = iota
+ // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the
+ // logging level is set to Panic.
+ FatalLevel
+ // ErrorLevel level. Logs. Used for errors that should definitely be noted.
+ // Commonly used for hooks to send errors to an error tracking service.
+ ErrorLevel
+ // WarnLevel level. Non-critical entries that deserve eyes.
+ WarnLevel
+ // InfoLevel level. General operational entries about what's going on inside the
+ // application.
+ InfoLevel
+ // DebugLevel level. Usually only enabled when debugging. Very verbose logging.
+ DebugLevel
+)
+
+// Won't compile if StdLogger can't be realized by a log.Logger
+var (
+ _ StdLogger = &log.Logger{}
+ _ StdLogger = &Entry{}
+ _ StdLogger = &Logger{}
+)
+
+// StdLogger is what your logrus-enabled library should take, that way
+// it'll accept a stdlib logger and a logrus logger. There's no standard
+// interface, this is the closest we get, unfortunately.
+type StdLogger interface {
+ Print(...interface{})
+ Printf(string, ...interface{})
+ Println(...interface{})
+
+ Fatal(...interface{})
+ Fatalf(string, ...interface{})
+ Fatalln(...interface{})
+
+ Panic(...interface{})
+ Panicf(string, ...interface{})
+ Panicln(...interface{})
+}
+
+// The FieldLogger interface generalizes the Entry and Logger types
+type FieldLogger interface {
+ WithField(key string, value interface{}) *Entry
+ WithFields(fields Fields) *Entry
+ WithError(err error) *Entry
+
+ Debugf(format string, args ...interface{})
+ Infof(format string, args ...interface{})
+ Printf(format string, args ...interface{})
+ Warnf(format string, args ...interface{})
+ Warningf(format string, args ...interface{})
+ Errorf(format string, args ...interface{})
+ Fatalf(format string, args ...interface{})
+ Panicf(format string, args ...interface{})
+
+ Debug(args ...interface{})
+ Info(args ...interface{})
+ Print(args ...interface{})
+ Warn(args ...interface{})
+ Warning(args ...interface{})
+ Error(args ...interface{})
+ Fatal(args ...interface{})
+ Panic(args ...interface{})
+
+ Debugln(args ...interface{})
+ Infoln(args ...interface{})
+ Println(args ...interface{})
+ Warnln(args ...interface{})
+ Warningln(args ...interface{})
+ Errorln(args ...interface{})
+ Fatalln(args ...interface{})
+ Panicln(args ...interface{})
+}
diff --git a/vendor/github.com/Sirupsen/logrus/logrus_test.go b/vendor/github.com/Sirupsen/logrus/logrus_test.go
new file mode 100644
index 00000000..78cbc282
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/logrus_test.go
@@ -0,0 +1,386 @@
+package logrus
+
+import (
+ "bytes"
+ "encoding/json"
+ "strconv"
+ "strings"
+ "sync"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func LogAndAssertJSON(t *testing.T, log func(*Logger), assertions func(fields Fields)) {
+ var buffer bytes.Buffer
+ var fields Fields
+
+ logger := New()
+ logger.Out = &buffer
+ logger.Formatter = new(JSONFormatter)
+
+ log(logger)
+
+ err := json.Unmarshal(buffer.Bytes(), &fields)
+ assert.Nil(t, err)
+
+ assertions(fields)
+}
+
+func LogAndAssertText(t *testing.T, log func(*Logger), assertions func(fields map[string]string)) {
+ var buffer bytes.Buffer
+
+ logger := New()
+ logger.Out = &buffer
+ logger.Formatter = &TextFormatter{
+ DisableColors: true,
+ }
+
+ log(logger)
+
+ fields := make(map[string]string)
+ for _, kv := range strings.Split(buffer.String(), " ") {
+ if !strings.Contains(kv, "=") {
+ continue
+ }
+ kvArr := strings.Split(kv, "=")
+ key := strings.TrimSpace(kvArr[0])
+ val := kvArr[1]
+ if kvArr[1][0] == '"' {
+ var err error
+ val, err = strconv.Unquote(val)
+ assert.NoError(t, err)
+ }
+ fields[key] = val
+ }
+ assertions(fields)
+}
+
+func TestPrint(t *testing.T) {
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.Print("test")
+ }, func(fields Fields) {
+ assert.Equal(t, fields["msg"], "test")
+ assert.Equal(t, fields["level"], "info")
+ })
+}
+
+func TestInfo(t *testing.T) {
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.Info("test")
+ }, func(fields Fields) {
+ assert.Equal(t, fields["msg"], "test")
+ assert.Equal(t, fields["level"], "info")
+ })
+}
+
+func TestWarn(t *testing.T) {
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.Warn("test")
+ }, func(fields Fields) {
+ assert.Equal(t, fields["msg"], "test")
+ assert.Equal(t, fields["level"], "warning")
+ })
+}
+
+func TestInfolnShouldAddSpacesBetweenStrings(t *testing.T) {
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.Infoln("test", "test")
+ }, func(fields Fields) {
+ assert.Equal(t, fields["msg"], "test test")
+ })
+}
+
+func TestInfolnShouldAddSpacesBetweenStringAndNonstring(t *testing.T) {
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.Infoln("test", 10)
+ }, func(fields Fields) {
+ assert.Equal(t, fields["msg"], "test 10")
+ })
+}
+
+func TestInfolnShouldAddSpacesBetweenTwoNonStrings(t *testing.T) {
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.Infoln(10, 10)
+ }, func(fields Fields) {
+ assert.Equal(t, fields["msg"], "10 10")
+ })
+}
+
+func TestInfoShouldAddSpacesBetweenTwoNonStrings(t *testing.T) {
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.Infoln(10, 10)
+ }, func(fields Fields) {
+ assert.Equal(t, fields["msg"], "10 10")
+ })
+}
+
+func TestInfoShouldNotAddSpacesBetweenStringAndNonstring(t *testing.T) {
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.Info("test", 10)
+ }, func(fields Fields) {
+ assert.Equal(t, fields["msg"], "test10")
+ })
+}
+
+func TestInfoShouldNotAddSpacesBetweenStrings(t *testing.T) {
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.Info("test", "test")
+ }, func(fields Fields) {
+ assert.Equal(t, fields["msg"], "testtest")
+ })
+}
+
+func TestWithFieldsShouldAllowAssignments(t *testing.T) {
+ var buffer bytes.Buffer
+ var fields Fields
+
+ logger := New()
+ logger.Out = &buffer
+ logger.Formatter = new(JSONFormatter)
+
+ localLog := logger.WithFields(Fields{
+ "key1": "value1",
+ })
+
+ localLog.WithField("key2", "value2").Info("test")
+ err := json.Unmarshal(buffer.Bytes(), &fields)
+ assert.Nil(t, err)
+
+ assert.Equal(t, "value2", fields["key2"])
+ assert.Equal(t, "value1", fields["key1"])
+
+ buffer = bytes.Buffer{}
+ fields = Fields{}
+ localLog.Info("test")
+ err = json.Unmarshal(buffer.Bytes(), &fields)
+ assert.Nil(t, err)
+
+ _, ok := fields["key2"]
+ assert.Equal(t, false, ok)
+ assert.Equal(t, "value1", fields["key1"])
+}
+
+func TestUserSuppliedFieldDoesNotOverwriteDefaults(t *testing.T) {
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.WithField("msg", "hello").Info("test")
+ }, func(fields Fields) {
+ assert.Equal(t, fields["msg"], "test")
+ })
+}
+
+func TestUserSuppliedMsgFieldHasPrefix(t *testing.T) {
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.WithField("msg", "hello").Info("test")
+ }, func(fields Fields) {
+ assert.Equal(t, fields["msg"], "test")
+ assert.Equal(t, fields["fields.msg"], "hello")
+ })
+}
+
+func TestUserSuppliedTimeFieldHasPrefix(t *testing.T) {
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.WithField("time", "hello").Info("test")
+ }, func(fields Fields) {
+ assert.Equal(t, fields["fields.time"], "hello")
+ })
+}
+
+func TestUserSuppliedLevelFieldHasPrefix(t *testing.T) {
+ LogAndAssertJSON(t, func(log *Logger) {
+ log.WithField("level", 1).Info("test")
+ }, func(fields Fields) {
+ assert.Equal(t, fields["level"], "info")
+ assert.Equal(t, fields["fields.level"], 1.0) // JSON has floats only
+ })
+}
+
+func TestDefaultFieldsAreNotPrefixed(t *testing.T) {
+ LogAndAssertText(t, func(log *Logger) {
+ ll := log.WithField("herp", "derp")
+ ll.Info("hello")
+ ll.Info("bye")
+ }, func(fields map[string]string) {
+ for _, fieldName := range []string{"fields.level", "fields.time", "fields.msg"} {
+ if _, ok := fields[fieldName]; ok {
+ t.Fatalf("should not have prefixed %q: %v", fieldName, fields)
+ }
+ }
+ })
+}
+
+func TestDoubleLoggingDoesntPrefixPreviousFields(t *testing.T) {
+
+ var buffer bytes.Buffer
+ var fields Fields
+
+ logger := New()
+ logger.Out = &buffer
+ logger.Formatter = new(JSONFormatter)
+
+ llog := logger.WithField("context", "eating raw fish")
+
+ llog.Info("looks delicious")
+
+ err := json.Unmarshal(buffer.Bytes(), &fields)
+ assert.NoError(t, err, "should have decoded first message")
+ assert.Equal(t, len(fields), 4, "should only have msg/time/level/context fields")
+ assert.Equal(t, fields["msg"], "looks delicious")
+ assert.Equal(t, fields["context"], "eating raw fish")
+
+ buffer.Reset()
+
+ llog.Warn("omg it is!")
+
+ err = json.Unmarshal(buffer.Bytes(), &fields)
+ assert.NoError(t, err, "should have decoded second message")
+ assert.Equal(t, len(fields), 4, "should only have msg/time/level/context fields")
+ assert.Equal(t, fields["msg"], "omg it is!")
+ assert.Equal(t, fields["context"], "eating raw fish")
+ assert.Nil(t, fields["fields.msg"], "should not have prefixed previous `msg` entry")
+
+}
+
+func TestConvertLevelToString(t *testing.T) {
+ assert.Equal(t, "debug", DebugLevel.String())
+ assert.Equal(t, "info", InfoLevel.String())
+ assert.Equal(t, "warning", WarnLevel.String())
+ assert.Equal(t, "error", ErrorLevel.String())
+ assert.Equal(t, "fatal", FatalLevel.String())
+ assert.Equal(t, "panic", PanicLevel.String())
+}
+
+func TestParseLevel(t *testing.T) {
+ l, err := ParseLevel("panic")
+ assert.Nil(t, err)
+ assert.Equal(t, PanicLevel, l)
+
+ l, err = ParseLevel("PANIC")
+ assert.Nil(t, err)
+ assert.Equal(t, PanicLevel, l)
+
+ l, err = ParseLevel("fatal")
+ assert.Nil(t, err)
+ assert.Equal(t, FatalLevel, l)
+
+ l, err = ParseLevel("FATAL")
+ assert.Nil(t, err)
+ assert.Equal(t, FatalLevel, l)
+
+ l, err = ParseLevel("error")
+ assert.Nil(t, err)
+ assert.Equal(t, ErrorLevel, l)
+
+ l, err = ParseLevel("ERROR")
+ assert.Nil(t, err)
+ assert.Equal(t, ErrorLevel, l)
+
+ l, err = ParseLevel("warn")
+ assert.Nil(t, err)
+ assert.Equal(t, WarnLevel, l)
+
+ l, err = ParseLevel("WARN")
+ assert.Nil(t, err)
+ assert.Equal(t, WarnLevel, l)
+
+ l, err = ParseLevel("warning")
+ assert.Nil(t, err)
+ assert.Equal(t, WarnLevel, l)
+
+ l, err = ParseLevel("WARNING")
+ assert.Nil(t, err)
+ assert.Equal(t, WarnLevel, l)
+
+ l, err = ParseLevel("info")
+ assert.Nil(t, err)
+ assert.Equal(t, InfoLevel, l)
+
+ l, err = ParseLevel("INFO")
+ assert.Nil(t, err)
+ assert.Equal(t, InfoLevel, l)
+
+ l, err = ParseLevel("debug")
+ assert.Nil(t, err)
+ assert.Equal(t, DebugLevel, l)
+
+ l, err = ParseLevel("DEBUG")
+ assert.Nil(t, err)
+ assert.Equal(t, DebugLevel, l)
+
+ l, err = ParseLevel("invalid")
+ assert.Equal(t, "not a valid logrus Level: \"invalid\"", err.Error())
+}
+
+func TestGetSetLevelRace(t *testing.T) {
+ wg := sync.WaitGroup{}
+ for i := 0; i < 100; i++ {
+ wg.Add(1)
+ go func(i int) {
+ defer wg.Done()
+ if i%2 == 0 {
+ SetLevel(InfoLevel)
+ } else {
+ GetLevel()
+ }
+ }(i)
+
+ }
+ wg.Wait()
+}
+
+func TestLoggingRace(t *testing.T) {
+ logger := New()
+
+ var wg sync.WaitGroup
+ wg.Add(100)
+
+ for i := 0; i < 100; i++ {
+ go func() {
+ logger.Info("info")
+ wg.Done()
+ }()
+ }
+ wg.Wait()
+}
+
+// Compile test
+func TestLogrusInterface(t *testing.T) {
+ var buffer bytes.Buffer
+ fn := func(l FieldLogger) {
+ b := l.WithField("key", "value")
+ b.Debug("Test")
+ }
+ // test logger
+ logger := New()
+ logger.Out = &buffer
+ fn(logger)
+
+ // test Entry
+ e := logger.WithField("another", "value")
+ fn(e)
+}
+
+// Implements io.Writer using channels for synchronization, so we can wait on
+// the Entry.Writer goroutine to write in a non-racey way. This does assume that
+// there is a single call to Logger.Out for each message.
+type channelWriter chan []byte
+
+func (cw channelWriter) Write(p []byte) (int, error) {
+ cw <- p
+ return len(p), nil
+}
+
+func TestEntryWriter(t *testing.T) {
+ cw := channelWriter(make(chan []byte, 1))
+ log := New()
+ log.Out = cw
+ log.Formatter = new(JSONFormatter)
+ log.WithField("foo", "bar").WriterLevel(WarnLevel).Write([]byte("hello\n"))
+
+ bs := <-cw
+ var fields Fields
+ err := json.Unmarshal(bs, &fields)
+ assert.Nil(t, err)
+ assert.Equal(t, fields["foo"], "bar")
+ assert.Equal(t, fields["level"], "warning")
+}
diff --git a/vendor/github.com/Sirupsen/logrus/terminal_bsd.go b/vendor/github.com/Sirupsen/logrus/terminal_bsd.go
new file mode 100644
index 00000000..d7b3893f
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/terminal_bsd.go
@@ -0,0 +1,10 @@
+// +build darwin freebsd openbsd netbsd dragonfly
+// +build !appengine
+
+package logrus
+
+import "golang.org/x/sys/unix"
+
+const ioctlReadTermios = unix.TIOCGETA
+
+type Termios unix.Termios
diff --git a/vendor/github.com/Sirupsen/logrus/terminal_linux.go b/vendor/github.com/Sirupsen/logrus/terminal_linux.go
new file mode 100644
index 00000000..88d7298e
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/terminal_linux.go
@@ -0,0 +1,14 @@
+// Based on ssh/terminal:
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !appengine
+
+package logrus
+
+import "golang.org/x/sys/unix"
+
+const ioctlReadTermios = unix.TCGETS
+
+type Termios unix.Termios
diff --git a/vendor/github.com/Sirupsen/logrus/text_formatter.go b/vendor/github.com/Sirupsen/logrus/text_formatter.go
new file mode 100644
index 00000000..be412aa9
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/text_formatter.go
@@ -0,0 +1,191 @@
+package logrus
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "os"
+ "sort"
+ "strings"
+ "sync"
+ "time"
+
+ "golang.org/x/crypto/ssh/terminal"
+)
+
+const (
+ nocolor = 0
+ red = 31
+ green = 32
+ yellow = 33
+ blue = 36
+ gray = 37
+)
+
+var (
+ baseTimestamp time.Time
+)
+
+func init() {
+ baseTimestamp = time.Now()
+}
+
+// TextFormatter formats logs into text
+type TextFormatter struct {
+ // Set to true to bypass checking for a TTY before outputting colors.
+ ForceColors bool
+
+ // Force disabling colors.
+ DisableColors bool
+
+ // Disable timestamp logging. useful when output is redirected to logging
+ // system that already adds timestamps.
+ DisableTimestamp bool
+
+ // Enable logging the full timestamp when a TTY is attached instead of just
+ // the time passed since beginning of execution.
+ FullTimestamp bool
+
+ // TimestampFormat to use for display when a full timestamp is printed
+ TimestampFormat string
+
+ // The fields are sorted by default for a consistent output. For applications
+ // that log extremely frequently and don't use the JSON formatter this may not
+ // be desired.
+ DisableSorting bool
+
+ // QuoteEmptyFields will wrap empty fields in quotes if true
+ QuoteEmptyFields bool
+
+ // Whether the logger's out is to a terminal
+ isTerminal bool
+
+ sync.Once
+}
+
+func (f *TextFormatter) init(entry *Entry) {
+ if entry.Logger != nil {
+ f.isTerminal = f.checkIfTerminal(entry.Logger.Out)
+ }
+}
+
+func (f *TextFormatter) checkIfTerminal(w io.Writer) bool {
+ switch v := w.(type) {
+ case *os.File:
+ return terminal.IsTerminal(int(v.Fd()))
+ default:
+ return false
+ }
+}
+
+// Format renders a single log entry
+func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
+ var b *bytes.Buffer
+ keys := make([]string, 0, len(entry.Data))
+ for k := range entry.Data {
+ keys = append(keys, k)
+ }
+
+ if !f.DisableSorting {
+ sort.Strings(keys)
+ }
+ if entry.Buffer != nil {
+ b = entry.Buffer
+ } else {
+ b = &bytes.Buffer{}
+ }
+
+ prefixFieldClashes(entry.Data)
+
+ f.Do(func() { f.init(entry) })
+
+ isColored := (f.ForceColors || f.isTerminal) && !f.DisableColors
+
+ timestampFormat := f.TimestampFormat
+ if timestampFormat == "" {
+ timestampFormat = defaultTimestampFormat
+ }
+ if isColored {
+ f.printColored(b, entry, keys, timestampFormat)
+ } else {
+ if !f.DisableTimestamp {
+ f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat))
+ }
+ f.appendKeyValue(b, "level", entry.Level.String())
+ if entry.Message != "" {
+ f.appendKeyValue(b, "msg", entry.Message)
+ }
+ for _, key := range keys {
+ f.appendKeyValue(b, key, entry.Data[key])
+ }
+ }
+
+ b.WriteByte('\n')
+ return b.Bytes(), nil
+}
+
+func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, timestampFormat string) {
+ var levelColor int
+ switch entry.Level {
+ case DebugLevel:
+ levelColor = gray
+ case WarnLevel:
+ levelColor = yellow
+ case ErrorLevel, FatalLevel, PanicLevel:
+ levelColor = red
+ default:
+ levelColor = blue
+ }
+
+ levelText := strings.ToUpper(entry.Level.String())[0:4]
+
+ if f.DisableTimestamp {
+ fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m %-44s ", levelColor, levelText, entry.Message)
+ } else if !f.FullTimestamp {
+ fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, int(entry.Time.Sub(baseTimestamp)/time.Second), entry.Message)
+ } else {
+ fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message)
+ }
+ for _, k := range keys {
+ v := entry.Data[k]
+ fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=", levelColor, k)
+ f.appendValue(b, v)
+ }
+}
+
+func (f *TextFormatter) needsQuoting(text string) bool {
+ if f.QuoteEmptyFields && len(text) == 0 {
+ return true
+ }
+ for _, ch := range text {
+ if !((ch >= 'a' && ch <= 'z') ||
+ (ch >= 'A' && ch <= 'Z') ||
+ (ch >= '0' && ch <= '9') ||
+ ch == '-' || ch == '.' || ch == '_' || ch == '/' || ch == '@' || ch == '^' || ch == '+') {
+ return true
+ }
+ }
+ return false
+}
+
+func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) {
+ if b.Len() > 0 {
+ b.WriteByte(' ')
+ }
+ b.WriteString(key)
+ b.WriteByte('=')
+ f.appendValue(b, value)
+}
+
+func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) {
+ stringVal, ok := value.(string)
+ if !ok {
+ stringVal = fmt.Sprint(value)
+ }
+
+ if !f.needsQuoting(stringVal) {
+ b.WriteString(stringVal)
+ } else {
+ b.WriteString(fmt.Sprintf("%q", stringVal))
+ }
+}
diff --git a/vendor/github.com/Sirupsen/logrus/text_formatter_test.go b/vendor/github.com/Sirupsen/logrus/text_formatter_test.go
new file mode 100644
index 00000000..d93b931e
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/text_formatter_test.go
@@ -0,0 +1,141 @@
+package logrus
+
+import (
+ "bytes"
+ "errors"
+ "fmt"
+ "strings"
+ "testing"
+ "time"
+)
+
+func TestFormatting(t *testing.T) {
+ tf := &TextFormatter{DisableColors: true}
+
+ testCases := []struct {
+ value string
+ expected string
+ }{
+ {`foo`, "time=\"0001-01-01T00:00:00Z\" level=panic test=foo\n"},
+ }
+
+ for _, tc := range testCases {
+ b, _ := tf.Format(WithField("test", tc.value))
+
+ if string(b) != tc.expected {
+ t.Errorf("formatting expected for %q (result was %q instead of %q)", tc.value, string(b), tc.expected)
+ }
+ }
+}
+
+func TestQuoting(t *testing.T) {
+ tf := &TextFormatter{DisableColors: true}
+
+ checkQuoting := func(q bool, value interface{}) {
+ b, _ := tf.Format(WithField("test", value))
+ idx := bytes.Index(b, ([]byte)("test="))
+ cont := bytes.Contains(b[idx+5:], []byte("\""))
+ if cont != q {
+ if q {
+ t.Errorf("quoting expected for: %#v", value)
+ } else {
+ t.Errorf("quoting not expected for: %#v", value)
+ }
+ }
+ }
+
+ checkQuoting(false, "")
+ checkQuoting(false, "abcd")
+ checkQuoting(false, "v1.0")
+ checkQuoting(false, "1234567890")
+ checkQuoting(false, "/foobar")
+ checkQuoting(false, "foo_bar")
+ checkQuoting(false, "foo@bar")
+ checkQuoting(false, "foobar^")
+ checkQuoting(false, "+/-_^@f.oobar")
+ checkQuoting(true, "foobar$")
+ checkQuoting(true, "&foobar")
+ checkQuoting(true, "x y")
+ checkQuoting(true, "x,y")
+ checkQuoting(false, errors.New("invalid"))
+ checkQuoting(true, errors.New("invalid argument"))
+
+ // Test for quoting empty fields.
+ tf.QuoteEmptyFields = true
+ checkQuoting(true, "")
+ checkQuoting(false, "abcd")
+ checkQuoting(true, errors.New("invalid argument"))
+}
+
+func TestEscaping(t *testing.T) {
+ tf := &TextFormatter{DisableColors: true}
+
+ testCases := []struct {
+ value string
+ expected string
+ }{
+ {`ba"r`, `ba\"r`},
+ {`ba'r`, `ba'r`},
+ }
+
+ for _, tc := range testCases {
+ b, _ := tf.Format(WithField("test", tc.value))
+ if !bytes.Contains(b, []byte(tc.expected)) {
+ t.Errorf("escaping expected for %q (result was %q instead of %q)", tc.value, string(b), tc.expected)
+ }
+ }
+}
+
+func TestEscaping_Interface(t *testing.T) {
+ tf := &TextFormatter{DisableColors: true}
+
+ ts := time.Now()
+
+ testCases := []struct {
+ value interface{}
+ expected string
+ }{
+ {ts, fmt.Sprintf("\"%s\"", ts.String())},
+ {errors.New("error: something went wrong"), "\"error: something went wrong\""},
+ }
+
+ for _, tc := range testCases {
+ b, _ := tf.Format(WithField("test", tc.value))
+ if !bytes.Contains(b, []byte(tc.expected)) {
+ t.Errorf("escaping expected for %q (result was %q instead of %q)", tc.value, string(b), tc.expected)
+ }
+ }
+}
+
+func TestTimestampFormat(t *testing.T) {
+ checkTimeStr := func(format string) {
+ customFormatter := &TextFormatter{DisableColors: true, TimestampFormat: format}
+ customStr, _ := customFormatter.Format(WithField("test", "test"))
+ timeStart := bytes.Index(customStr, ([]byte)("time="))
+ timeEnd := bytes.Index(customStr, ([]byte)("level="))
+ timeStr := customStr[timeStart+5+len("\"") : timeEnd-1-len("\"")]
+ if format == "" {
+ format = time.RFC3339
+ }
+ _, e := time.Parse(format, (string)(timeStr))
+ if e != nil {
+ t.Errorf("time string \"%s\" did not match provided time format \"%s\": %s", timeStr, format, e)
+ }
+ }
+
+ checkTimeStr("2006-01-02T15:04:05.000000000Z07:00")
+ checkTimeStr("Mon Jan _2 15:04:05 2006")
+ checkTimeStr("")
+}
+
+func TestDisableTimestampWithColoredOutput(t *testing.T) {
+ tf := &TextFormatter{DisableTimestamp: true, ForceColors: true}
+
+ b, _ := tf.Format(WithField("test", "test"))
+ if strings.Contains(string(b), "[0000]") {
+ t.Error("timestamp not expected when DisableTimestamp is true")
+ }
+}
+
+// TODO add tests for sorting etc., this requires a parser for the text
+// formatter output.
diff --git a/vendor/github.com/Sirupsen/logrus/writer.go b/vendor/github.com/Sirupsen/logrus/writer.go
new file mode 100644
index 00000000..7bdebedc
--- /dev/null
+++ b/vendor/github.com/Sirupsen/logrus/writer.go
@@ -0,0 +1,62 @@
+package logrus
+
+import (
+ "bufio"
+ "io"
+ "runtime"
+)
+
+func (logger *Logger) Writer() *io.PipeWriter {
+ return logger.WriterLevel(InfoLevel)
+}
+
+func (logger *Logger) WriterLevel(level Level) *io.PipeWriter {
+ return NewEntry(logger).WriterLevel(level)
+}
+
+func (entry *Entry) Writer() *io.PipeWriter {
+ return entry.WriterLevel(InfoLevel)
+}
+
+func (entry *Entry) WriterLevel(level Level) *io.PipeWriter {
+ reader, writer := io.Pipe()
+
+ var printFunc func(args ...interface{})
+
+ switch level {
+ case DebugLevel:
+ printFunc = entry.Debug
+ case InfoLevel:
+ printFunc = entry.Info
+ case WarnLevel:
+ printFunc = entry.Warn
+ case ErrorLevel:
+ printFunc = entry.Error
+ case FatalLevel:
+ printFunc = entry.Fatal
+ case PanicLevel:
+ printFunc = entry.Panic
+ default:
+ printFunc = entry.Print
+ }
+
+ go entry.writerScanner(reader, printFunc)
+ runtime.SetFinalizer(writer, writerFinalizer)
+
+ return writer
+}
+
+func (entry *Entry) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) {
+ scanner := bufio.NewScanner(reader)
+ for scanner.Scan() {
+ printFunc(scanner.Text())
+ }
+ if err := scanner.Err(); err != nil {
+ entry.Errorf("Error while reading from Writer: %s", err)
+ }
+ reader.Close()
+}
+
+func writerFinalizer(writer *io.PipeWriter) {
+ writer.Close()
+}
diff --git a/vendor/github.com/armon/consul-api/.gitignore b/vendor/github.com/armon/consul-api/.gitignore
new file mode 100644
index 00000000..83656241
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/.gitignore
@@ -0,0 +1,23 @@
+# Compiled Object files, Static and Dynamic libs (Shared Objects)
+*.o
+*.a
+*.so
+
+# Folders
+_obj
+_test
+
+# Architecture specific extensions/prefixes
+*.[568vq]
+[568vq].out
+
+*.cgo1.go
+*.cgo2.c
+_cgo_defun.c
+_cgo_gotypes.go
+_cgo_export.*
+
+_testmain.go
+
+*.exe
+*.test
diff --git a/vendor/github.com/armon/consul-api/LICENSE b/vendor/github.com/armon/consul-api/LICENSE
new file mode 100644
index 00000000..f0e5c79e
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/LICENSE
@@ -0,0 +1,362 @@
+Mozilla Public License, version 2.0
+
+1. Definitions
+
+1.1. "Contributor"
+
+ means each individual or legal entity that creates, contributes to the
+ creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+
+ means the combination of the Contributions of others (if any) used by a
+ Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+
+ means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+
+ means Source Code Form to which the initial Contributor has attached the
+ notice in Exhibit A, the Executable Form of such Source Code Form, and
+ Modifications of such Source Code Form, in each case including portions
+ thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+ means
+
+ a. that the initial Contributor has attached the notice described in
+ Exhibit B to the Covered Software; or
+
+ b. that the Covered Software was made available under the terms of
+ version 1.1 or earlier of the License, but not also under the terms of
+ a Secondary License.
+
+1.6. "Executable Form"
+
+ means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+
+ means a work that combines Covered Software with other material, in a
+ separate file or files, that is not Covered Software.
+
+1.8. "License"
+
+ means this document.
+
+1.9. "Licensable"
+
+ means having the right to grant, to the maximum extent possible, whether
+ at the time of the initial grant or subsequently, any and all of the
+ rights conveyed by this License.
+
+1.10. "Modifications"
+
+ means any of the following:
+
+ a. any file in Source Code Form that results from an addition to,
+ deletion from, or modification of the contents of Covered Software; or
+
+ b. any new file in Source Code Form that contains any Covered Software.
+
+1.11. "Patent Claims" of a Contributor
+
+ means any patent claim(s), including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by such
+ Contributor that would be infringed, but for the grant of the License,
+ by the making, using, selling, offering for sale, having made, import,
+ or transfer of either its Contributions or its Contributor Version.
+
+1.12. "Secondary License"
+
+ means either the GNU General Public License, Version 2.0, the GNU Lesser
+ General Public License, Version 2.1, the GNU Affero General Public
+ License, Version 3.0, or any later versions of those licenses.
+
+1.13. "Source Code Form"
+
+ means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, "You" includes any entity that controls, is
+ controlled by, or is under common control with You. For purposes of this
+ definition, "control" means (a) the power, direct or indirect, to cause
+ the direction or management of such entity, whether by contract or
+ otherwise, or (b) ownership of more than fifty percent (50%) of the
+ outstanding shares or beneficial ownership of such entity.
+
+
+2. License Grants and Conditions
+
+2.1. Grants
+
+ Each Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ a. under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or
+ as part of a Larger Work; and
+
+ b. under Patent Claims of such Contributor to make, use, sell, offer for
+ sale, have made, import, and otherwise transfer either its
+ Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+ The licenses granted in Section 2.1 with respect to any Contribution
+ become effective for each Contribution on the date the Contributor first
+ distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+ The licenses granted in this Section 2 are the only rights granted under
+ this License. No additional rights or licenses will be implied from the
+ distribution or licensing of Covered Software under this License.
+ Notwithstanding Section 2.1(b) above, no patent license is granted by a
+ Contributor:
+
+ a. for any code that a Contributor has removed from Covered Software; or
+
+ b. for infringements caused by: (i) Your and any other third party's
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+
+ c. under Patent Claims infringed by Covered Software in the absence of
+ its Contributions.
+
+ This License does not grant any rights in the trademarks, service marks,
+ or logos of any Contributor (except as may be necessary to comply with
+ the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+ No Contributor makes additional grants as a result of Your choice to
+ distribute the Covered Software under a subsequent version of this
+ License (see Section 10.2) or under the terms of a Secondary License (if
+ permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+ Each Contributor represents that the Contributor believes its
+ Contributions are its original creation(s) or it has sufficient rights to
+ grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+ This License is not intended to limit any rights You have under
+ applicable copyright doctrines of fair use, fair dealing, or other
+ equivalents.
+
+2.7. Conditions
+
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
+ Section 2.1.
+
+
+3. Responsibilities
+
+3.1. Distribution of Source Form
+
+ All distribution of Covered Software in Source Code Form, including any
+ Modifications that You create or to which You contribute, must be under
+ the terms of this License. You must inform recipients that the Source
+ Code Form of the Covered Software is governed by the terms of this
+ License, and how they can obtain a copy of this License. You may not
+ attempt to alter or restrict the recipients' rights in the Source Code
+ Form.
+
+3.2. Distribution of Executable Form
+
+ If You distribute Covered Software in Executable Form then:
+
+ a. such Covered Software must also be made available in Source Code Form,
+ as described in Section 3.1, and You must inform recipients of the
+ Executable Form how they can obtain a copy of such Source Code Form by
+ reasonable means in a timely manner, at a charge no more than the cost
+ of distribution to the recipient; and
+
+ b. You may distribute such Executable Form under the terms of this
+ License, or sublicense it under different terms, provided that the
+ license for the Executable Form does not attempt to limit or alter the
+ recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+ You may create and distribute a Larger Work under terms of Your choice,
+ provided that You also comply with the requirements of this License for
+ the Covered Software. If the Larger Work is a combination of Covered
+ Software with a work governed by one or more Secondary Licenses, and the
+ Covered Software is not Incompatible With Secondary Licenses, this
+ License permits You to additionally distribute such Covered Software
+ under the terms of such Secondary License(s), so that the recipient of
+ the Larger Work may, at their option, further distribute the Covered
+ Software under the terms of either this License or such Secondary
+ License(s).
+
+3.4. Notices
+
+ You may not remove or alter the substance of any license notices
+ (including copyright notices, patent notices, disclaimers of warranty, or
+ limitations of liability) contained within the Source Code Form of the
+ Covered Software, except that You may alter any license notices to the
+ extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+ You may choose to offer, and to charge a fee for, warranty, support,
+ indemnity or liability obligations to one or more recipients of Covered
+ Software. However, You may do so only on Your own behalf, and not on
+ behalf of any Contributor. You must make it absolutely clear that any
+ such warranty, support, indemnity, or liability obligation is offered by
+ You alone, and You hereby agree to indemnify every Contributor for any
+ liability incurred by such Contributor as a result of warranty, support,
+ indemnity or liability terms You offer. You may include additional
+ disclaimers of warranty and limitations of liability specific to any
+ jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+
+ If it is impossible for You to comply with any of the terms of this License
+ with respect to some or all of the Covered Software due to statute,
+ judicial order, or regulation then You must: (a) comply with the terms of
+ this License to the maximum extent possible; and (b) describe the
+ limitations and the code they affect. Such description must be placed in a
+ text file included with all distributions of the Covered Software under
+ this License. Except to the extent prohibited by statute or regulation,
+ such description must be sufficiently detailed for a recipient of ordinary
+ skill to be able to understand it.
+
+5. Termination
+
+5.1. The rights granted under this License will terminate automatically if You
+ fail to comply with any of its terms. However, if You become compliant,
+ then the rights granted under this License from a particular Contributor
+ are reinstated (a) provisionally, unless and until such Contributor
+ explicitly and finally terminates Your grants, and (b) on an ongoing
+ basis, if such Contributor fails to notify You of the non-compliance by
+ some reasonable means prior to 60 days after You have come back into
+ compliance. Moreover, Your grants from a particular Contributor are
+ reinstated on an ongoing basis if such Contributor notifies You of the
+ non-compliance by some reasonable means, this is the first time You have
+ received notice of non-compliance with this License from such
+ Contributor, and You become compliant prior to 30 days after Your receipt
+ of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+ infringement claim (excluding declaratory judgment actions,
+ counter-claims, and cross-claims) alleging that a Contributor Version
+ directly or indirectly infringes any patent, then the rights granted to
+ You by any and all Contributors for the Covered Software under Section
+ 2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
+ license agreements (excluding distributors and resellers) which have been
+ validly granted by You or Your distributors under this License prior to
+ termination shall survive termination.
+
+6. Disclaimer of Warranty
+
+ Covered Software is provided under this License on an "as is" basis,
+ without warranty of any kind, either expressed, implied, or statutory,
+ including, without limitation, warranties that the Covered Software is free
+ of defects, merchantable, fit for a particular purpose or non-infringing.
+ The entire risk as to the quality and performance of the Covered Software
+ is with You. Should any Covered Software prove defective in any respect,
+ You (not any Contributor) assume the cost of any necessary servicing,
+ repair, or correction. This disclaimer of warranty constitutes an essential
+ part of this License. No use of any Covered Software is authorized under
+ this License except under this disclaimer.
+
+7. Limitation of Liability
+
+ Under no circumstances and under no legal theory, whether tort (including
+ negligence), contract, or otherwise, shall any Contributor, or anyone who
+ distributes Covered Software as permitted above, be liable to You for any
+ direct, indirect, special, incidental, or consequential damages of any
+ character including, without limitation, damages for lost profits, loss of
+ goodwill, work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses, even if such party shall have been
+ informed of the possibility of such damages. This limitation of liability
+ shall not apply to liability for death or personal injury resulting from
+ such party's negligence to the extent applicable law prohibits such
+ limitation. Some jurisdictions do not allow the exclusion or limitation of
+ incidental or consequential damages, so this exclusion and limitation may
+ not apply to You.
+
+8. Litigation
+
+ Any litigation relating to this License may be brought only in the courts
+ of a jurisdiction where the defendant maintains its principal place of
+ business and such litigation shall be governed by laws of that
+ jurisdiction, without reference to its conflict-of-law provisions. Nothing
+ in this Section shall prevent a party's ability to bring cross-claims or
+ counter-claims.
+
+9. Miscellaneous
+
+ This License represents the complete agreement concerning the subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the extent
+ necessary to make it enforceable. Any law or regulation which provides that
+ the language of a contract shall be construed against the drafter shall not
+ be used to construe this License against a Contributor.
+
+
+10. Versions of the License
+
+10.1. New Versions
+
+ Mozilla Foundation is the license steward. Except as provided in Section
+ 10.3, no one other than the license steward has the right to modify or
+ publish new versions of this License. Each version will be given a
+ distinguishing version number.
+
+10.2. Effect of New Versions
+
+ You may distribute the Covered Software under the terms of the version
+ of the License under which You originally received the Covered Software,
+ or under the terms of any subsequent version published by the license
+ steward.
+
+10.3. Modified Versions
+
+ If you create software not governed by this License, and you want to
+ create a new license for such software, you may create and use a
+ modified version of this License if you rename the license and remove
+ any references to the name of the license steward (except to note that
+ such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+ Licenses If You choose to distribute Source Code Form that is
+ Incompatible With Secondary Licenses under the terms of this version of
+ the License, the notice described in Exhibit B of this License must be
+ attached.
+
+Exhibit A - Source Code Form License Notice
+
+ This Source Code Form is subject to the
+ terms of the Mozilla Public License, v.
+ 2.0. If a copy of the MPL was not
+ distributed with this file, You can
+ obtain one at
+ http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular file,
+then You may include the notice in a location (such as a LICENSE file in a
+relevant directory) where a recipient would be likely to look for such a
+notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+
+ This Source Code Form is "Incompatible
+ With Secondary Licenses", as defined by
+ the Mozilla Public License, v. 2.0.
\ No newline at end of file
diff --git a/vendor/github.com/armon/consul-api/README.md b/vendor/github.com/armon/consul-api/README.md
new file mode 100644
index 00000000..c95d9dee
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/README.md
@@ -0,0 +1,42 @@
+consul-api
+==========
+
+*DEPRECATED* Please use [consul api package](https://github.com/hashicorp/consul/tree/master/api) instead.
+Godocs for that package [are here](http://godoc.org/github.com/hashicorp/consul/api).
+
+This package provides the `consulapi` package which attempts to
+provide programmatic access to the full Consul API.
+
+Currently, all of the Consul APIs included in version 0.4 are supported.
+
+Documentation
+=============
+
+The full documentation is available on [Godoc](http://godoc.org/github.com/armon/consul-api)
+
+Usage
+=====
+
+Below is an example of using the Consul client:
+
+```go
+// Get a new client, with KV endpoints
+client, _ := consulapi.NewClient(consulapi.DefaultConfig())
+kv := client.KV()
+
+// PUT a new KV pair
+p := &consulapi.KVPair{Key: "foo", Value: []byte("test")}
+_, err := kv.Put(p, nil)
+if err != nil {
+ panic(err)
+}
+
+// Lookup the pair
+pair, _, err := kv.Get("foo", nil)
+if err != nil {
+ panic(err)
+}
+fmt.Printf("KV: %v", pair)
+
+```
+
diff --git a/vendor/github.com/armon/consul-api/acl.go b/vendor/github.com/armon/consul-api/acl.go
new file mode 100644
index 00000000..e0179f54
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/acl.go
@@ -0,0 +1,140 @@
+package consulapi
+
+const (
+ // ACLCLientType is the client type token
+ ACLClientType = "client"
+
+ // ACLManagementType is the management type token
+ ACLManagementType = "management"
+)
+
+// ACLEntry is used to represent an ACL entry
+type ACLEntry struct {
+ CreateIndex uint64
+ ModifyIndex uint64
+ ID string
+ Name string
+ Type string
+ Rules string
+}
+
+// ACL can be used to query the ACL endpoints
+type ACL struct {
+ c *Client
+}
+
+// ACL returns a handle to the ACL endpoints
+func (c *Client) ACL() *ACL {
+ return &ACL{c}
+}
+
+// Create is used to generate a new token with the given parameters
+func (a *ACL) Create(acl *ACLEntry, q *WriteOptions) (string, *WriteMeta, error) {
+ r := a.c.newRequest("PUT", "/v1/acl/create")
+ r.setWriteOptions(q)
+ r.obj = acl
+ rtt, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return "", nil, err
+ }
+ defer resp.Body.Close()
+
+ wm := &WriteMeta{RequestTime: rtt}
+ var out struct{ ID string }
+ if err := decodeBody(resp, &out); err != nil {
+ return "", nil, err
+ }
+ return out.ID, wm, nil
+}
+
+// Update is used to update the rules of an existing token
+func (a *ACL) Update(acl *ACLEntry, q *WriteOptions) (*WriteMeta, error) {
+ r := a.c.newRequest("PUT", "/v1/acl/update")
+ r.setWriteOptions(q)
+ r.obj = acl
+ rtt, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ wm := &WriteMeta{RequestTime: rtt}
+ return wm, nil
+}
+
+// Destroy is used to destroy a given ACL token ID
+func (a *ACL) Destroy(id string, q *WriteOptions) (*WriteMeta, error) {
+ r := a.c.newRequest("PUT", "/v1/acl/destroy/"+id)
+ r.setWriteOptions(q)
+ rtt, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ resp.Body.Close()
+
+ wm := &WriteMeta{RequestTime: rtt}
+ return wm, nil
+}
+
+// Clone is used to return a new token cloned from an existing one
+func (a *ACL) Clone(id string, q *WriteOptions) (string, *WriteMeta, error) {
+ r := a.c.newRequest("PUT", "/v1/acl/clone/"+id)
+ r.setWriteOptions(q)
+ rtt, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return "", nil, err
+ }
+ defer resp.Body.Close()
+
+ wm := &WriteMeta{RequestTime: rtt}
+ var out struct{ ID string }
+ if err := decodeBody(resp, &out); err != nil {
+ return "", nil, err
+ }
+ return out.ID, wm, nil
+}
+
+// Info is used to query for information about an ACL token
+func (a *ACL) Info(id string, q *QueryOptions) (*ACLEntry, *QueryMeta, error) {
+ r := a.c.newRequest("GET", "/v1/acl/info/"+id)
+ r.setQueryOptions(q)
+ rtt, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var entries []*ACLEntry
+ if err := decodeBody(resp, &entries); err != nil {
+ return nil, nil, err
+ }
+ if len(entries) > 0 {
+ return entries[0], qm, nil
+ }
+ return nil, qm, nil
+}
+
+// List is used to get all the ACL tokens
+func (a *ACL) List(q *QueryOptions) ([]*ACLEntry, *QueryMeta, error) {
+ r := a.c.newRequest("GET", "/v1/acl/list")
+ r.setQueryOptions(q)
+ rtt, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var entries []*ACLEntry
+ if err := decodeBody(resp, &entries); err != nil {
+ return nil, nil, err
+ }
+ return entries, qm, nil
+}
diff --git a/vendor/github.com/armon/consul-api/acl_test.go b/vendor/github.com/armon/consul-api/acl_test.go
new file mode 100644
index 00000000..7932c590
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/acl_test.go
@@ -0,0 +1,140 @@
+package consulapi
+
+import (
+ "os"
+ "testing"
+)
+
+// ROOT is a management token for the tests
+var CONSUL_ROOT string
+
+func init() {
+ CONSUL_ROOT = os.Getenv("CONSUL_ROOT")
+}
+
+func TestACL_CreateDestroy(t *testing.T) {
+ if CONSUL_ROOT == "" {
+ t.SkipNow()
+ }
+ c := makeClient(t)
+ c.config.Token = CONSUL_ROOT
+ acl := c.ACL()
+
+ ae := ACLEntry{
+ Name: "API test",
+ Type: ACLClientType,
+ Rules: `key "" { policy = "deny" }`,
+ }
+
+ id, wm, err := acl.Create(&ae, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if wm.RequestTime == 0 {
+ t.Fatalf("bad: %v", wm)
+ }
+
+ if id == "" {
+ t.Fatalf("invalid: %v", id)
+ }
+
+ ae2, _, err := acl.Info(id, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if ae2.Name != ae.Name || ae2.Type != ae.Type || ae2.Rules != ae.Rules {
+ t.Fatalf("Bad: %#v", ae2)
+ }
+
+ wm, err = acl.Destroy(id, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if wm.RequestTime == 0 {
+ t.Fatalf("bad: %v", wm)
+ }
+}
+
+func TestACL_CloneDestroy(t *testing.T) {
+ if CONSUL_ROOT == "" {
+ t.SkipNow()
+ }
+ c := makeClient(t)
+ c.config.Token = CONSUL_ROOT
+ acl := c.ACL()
+
+ id, wm, err := acl.Clone(CONSUL_ROOT, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if wm.RequestTime == 0 {
+ t.Fatalf("bad: %v", wm)
+ }
+
+ if id == "" {
+ t.Fatalf("invalid: %v", id)
+ }
+
+ wm, err = acl.Destroy(id, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if wm.RequestTime == 0 {
+ t.Fatalf("bad: %v", wm)
+ }
+}
+
+func TestACL_Info(t *testing.T) {
+ if CONSUL_ROOT == "" {
+ t.SkipNow()
+ }
+ c := makeClient(t)
+ c.config.Token = CONSUL_ROOT
+ acl := c.ACL()
+
+ ae, qm, err := acl.Info(CONSUL_ROOT, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if qm.LastIndex == 0 {
+ t.Fatalf("bad: %v", qm)
+ }
+ if !qm.KnownLeader {
+ t.Fatalf("bad: %v", qm)
+ }
+
+ if ae == nil || ae.ID != CONSUL_ROOT || ae.Type != ACLManagementType {
+ t.Fatalf("bad: %#v", ae)
+ }
+}
+
+func TestACL_List(t *testing.T) {
+ if CONSUL_ROOT == "" {
+ t.SkipNow()
+ }
+ c := makeClient(t)
+ c.config.Token = CONSUL_ROOT
+ acl := c.ACL()
+
+ acls, qm, err := acl.List(nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if len(acls) < 2 {
+ t.Fatalf("bad: %v", acls)
+ }
+
+ if qm.LastIndex == 0 {
+ t.Fatalf("bad: %v", qm)
+ }
+ if !qm.KnownLeader {
+ t.Fatalf("bad: %v", qm)
+ }
+}
diff --git a/vendor/github.com/armon/consul-api/agent.go b/vendor/github.com/armon/consul-api/agent.go
new file mode 100644
index 00000000..eec93cb9
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/agent.go
@@ -0,0 +1,272 @@
+package consulapi
+
+import (
+ "fmt"
+)
+
+// AgentCheck represents a check known to the agent
+type AgentCheck struct {
+ Node string
+ CheckID string
+ Name string
+ Status string
+ Notes string
+ Output string
+ ServiceID string
+ ServiceName string
+}
+
+// AgentService represents a service known to the agent
+type AgentService struct {
+ ID string
+ Service string
+ Tags []string
+ Port int
+}
+
+// AgentMember represents a cluster member known to the agent
+type AgentMember struct {
+ Name string
+ Addr string
+ Port uint16
+ Tags map[string]string
+ Status int
+ ProtocolMin uint8
+ ProtocolMax uint8
+ ProtocolCur uint8
+ DelegateMin uint8
+ DelegateMax uint8
+ DelegateCur uint8
+}
+
+// AgentServiceRegistration is used to register a new service
+type AgentServiceRegistration struct {
+ ID string `json:",omitempty"`
+ Name string `json:",omitempty"`
+ Tags []string `json:",omitempty"`
+ Port int `json:",omitempty"`
+ Check *AgentServiceCheck
+}
+
+// AgentCheckRegistration is used to register a new check
+type AgentCheckRegistration struct {
+ ID string `json:",omitempty"`
+ Name string `json:",omitempty"`
+ Notes string `json:",omitempty"`
+ AgentServiceCheck
+}
+
+// AgentServiceCheck is used to create an associated
+// check for a service
+type AgentServiceCheck struct {
+ Script string `json:",omitempty"`
+ Interval string `json:",omitempty"`
+ TTL string `json:",omitempty"`
+}
+
+// Agent can be used to query the Agent endpoints
+type Agent struct {
+ c *Client
+
+ // cache the node name
+ nodeName string
+}
+
+// Agent returns a handle to the agent endpoints
+func (c *Client) Agent() *Agent {
+ return &Agent{c: c}
+}
+
+// Self is used to query the agent we are speaking to for
+// information about itself
+func (a *Agent) Self() (map[string]map[string]interface{}, error) {
+ r := a.c.newRequest("GET", "/v1/agent/self")
+ _, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ var out map[string]map[string]interface{}
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// NodeName is used to get the node name of the agent
+func (a *Agent) NodeName() (string, error) {
+ if a.nodeName != "" {
+ return a.nodeName, nil
+ }
+ info, err := a.Self()
+ if err != nil {
+ return "", err
+ }
+ name := info["Config"]["NodeName"].(string)
+ a.nodeName = name
+ return name, nil
+}
+
+// Checks returns the locally registered checks
+func (a *Agent) Checks() (map[string]*AgentCheck, error) {
+ r := a.c.newRequest("GET", "/v1/agent/checks")
+ _, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ var out map[string]*AgentCheck
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// Services returns the locally registered services
+func (a *Agent) Services() (map[string]*AgentService, error) {
+ r := a.c.newRequest("GET", "/v1/agent/services")
+ _, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ var out map[string]*AgentService
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// Members returns the known gossip members. The WAN
+// flag can be used to query a server for WAN members.
+func (a *Agent) Members(wan bool) ([]*AgentMember, error) {
+ r := a.c.newRequest("GET", "/v1/agent/members")
+ if wan {
+ r.params.Set("wan", "1")
+ }
+ _, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ var out []*AgentMember
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// ServiceRegister is used to register a new service with
+// the local agent
+func (a *Agent) ServiceRegister(service *AgentServiceRegistration) error {
+ r := a.c.newRequest("PUT", "/v1/agent/service/register")
+ r.obj = service
+ _, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return err
+ }
+ resp.Body.Close()
+ return nil
+}
+
+// ServiceDeregister is used to deregister a service with
+// the local agent
+func (a *Agent) ServiceDeregister(serviceID string) error {
+ r := a.c.newRequest("PUT", "/v1/agent/service/deregister/"+serviceID)
+ _, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return err
+ }
+ resp.Body.Close()
+ return nil
+}
+
+// PassTTL is used to set a TTL check to the passing state
+func (a *Agent) PassTTL(checkID, note string) error {
+ return a.UpdateTTL(checkID, note, "pass")
+}
+
+// WarnTTL is used to set a TTL check to the warning state
+func (a *Agent) WarnTTL(checkID, note string) error {
+ return a.UpdateTTL(checkID, note, "warn")
+}
+
+// FailTTL is used to set a TTL check to the failing state
+func (a *Agent) FailTTL(checkID, note string) error {
+ return a.UpdateTTL(checkID, note, "fail")
+}
+
+// UpdateTTL is used to update the TTL of a check
+func (a *Agent) UpdateTTL(checkID, note, status string) error {
+ switch status {
+ case "pass":
+ case "warn":
+ case "fail":
+ default:
+ return fmt.Errorf("Invalid status: %s", status)
+ }
+ endpoint := fmt.Sprintf("/v1/agent/check/%s/%s", status, checkID)
+ r := a.c.newRequest("PUT", endpoint)
+ r.params.Set("note", note)
+ _, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return err
+ }
+ resp.Body.Close()
+ return nil
+}
+
+// CheckRegister is used to register a new check with
+// the local agent
+func (a *Agent) CheckRegister(check *AgentCheckRegistration) error {
+ r := a.c.newRequest("PUT", "/v1/agent/check/register")
+ r.obj = check
+ _, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return err
+ }
+ resp.Body.Close()
+ return nil
+}
+
+// CheckDeregister is used to deregister a check with
+// the local agent
+func (a *Agent) CheckDeregister(checkID string) error {
+ r := a.c.newRequest("PUT", "/v1/agent/check/deregister/"+checkID)
+ _, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return err
+ }
+ resp.Body.Close()
+ return nil
+}
+
+// Join is used to instruct the agent to attempt a join to
+// another cluster member
+func (a *Agent) Join(addr string, wan bool) error {
+ r := a.c.newRequest("PUT", "/v1/agent/join/"+addr)
+ if wan {
+ r.params.Set("wan", "1")
+ }
+ _, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return err
+ }
+ resp.Body.Close()
+ return nil
+}
+
+// ForceLeave is used to have the agent eject a failed node
+func (a *Agent) ForceLeave(node string) error {
+ r := a.c.newRequest("PUT", "/v1/agent/force-leave/"+node)
+ _, resp, err := requireOK(a.c.doRequest(r))
+ if err != nil {
+ return err
+ }
+ resp.Body.Close()
+ return nil
+}
diff --git a/vendor/github.com/armon/consul-api/agent_test.go b/vendor/github.com/armon/consul-api/agent_test.go
new file mode 100644
index 00000000..8d97af4a
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/agent_test.go
@@ -0,0 +1,162 @@
+package consulapi
+
+import (
+ "testing"
+)
+
+func TestAgent_Self(t *testing.T) {
+ c := makeClient(t)
+ agent := c.Agent()
+
+ info, err := agent.Self()
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ name := info["Config"]["NodeName"]
+ if name == "" {
+ t.Fatalf("bad: %v", info)
+ }
+}
+
+func TestAgent_Members(t *testing.T) {
+ c := makeClient(t)
+ agent := c.Agent()
+
+ members, err := agent.Members(false)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if len(members) != 1 {
+ t.Fatalf("bad: %v", members)
+ }
+}
+
+func TestAgent_Services(t *testing.T) {
+ c := makeClient(t)
+ agent := c.Agent()
+
+ reg := &AgentServiceRegistration{
+ Name: "foo",
+ Tags: []string{"bar", "baz"},
+ Port: 8000,
+ Check: &AgentServiceCheck{
+ TTL: "15s",
+ },
+ }
+ if err := agent.ServiceRegister(reg); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ services, err := agent.Services()
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if _, ok := services["foo"]; !ok {
+ t.Fatalf("missing service: %v", services)
+ }
+
+ checks, err := agent.Checks()
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if _, ok := checks["service:foo"]; !ok {
+ t.Fatalf("missing check: %v", checks)
+ }
+
+ if err := agent.ServiceDeregister("foo"); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+}
+
+func TestAgent_SetTTLStatus(t *testing.T) {
+ c := makeClient(t)
+ agent := c.Agent()
+
+ reg := &AgentServiceRegistration{
+ Name: "foo",
+ Check: &AgentServiceCheck{
+ TTL: "15s",
+ },
+ }
+ if err := agent.ServiceRegister(reg); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if err := agent.WarnTTL("service:foo", "test"); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ checks, err := agent.Checks()
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ chk, ok := checks["service:foo"]
+ if !ok {
+ t.Fatalf("missing check: %v", checks)
+ }
+ if chk.Status != "warning" {
+ t.Fatalf("Bad: %#v", chk)
+ }
+ if chk.Output != "test" {
+ t.Fatalf("Bad: %#v", chk)
+ }
+
+ if err := agent.ServiceDeregister("foo"); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+}
+
+func TestAgent_Checks(t *testing.T) {
+ c := makeClient(t)
+ agent := c.Agent()
+
+ reg := &AgentCheckRegistration{
+ Name: "foo",
+ }
+ reg.TTL = "15s"
+ if err := agent.CheckRegister(reg); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ checks, err := agent.Checks()
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if _, ok := checks["foo"]; !ok {
+ t.Fatalf("missing check: %v", checks)
+ }
+
+ if err := agent.CheckDeregister("foo"); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+}
+
+func TestAgent_Join(t *testing.T) {
+ c := makeClient(t)
+ agent := c.Agent()
+
+ info, err := agent.Self()
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ // Join ourself
+ addr := info["Config"]["AdvertiseAddr"].(string)
+ err = agent.Join(addr, false)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+}
+
+func TestAgent_ForceLeave(t *testing.T) {
+ c := makeClient(t)
+ agent := c.Agent()
+
+ // Eject somebody
+ err := agent.ForceLeave("foo")
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+}
diff --git a/vendor/github.com/armon/consul-api/api.go b/vendor/github.com/armon/consul-api/api.go
new file mode 100644
index 00000000..e1335769
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/api.go
@@ -0,0 +1,323 @@
+package consulapi
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+ "net/url"
+ "strconv"
+ "time"
+)
+
+// QueryOptions are used to parameterize a query
+type QueryOptions struct {
+ // Providing a datacenter overwrites the DC provided
+ // by the Config
+ Datacenter string
+
+ // AllowStale allows any Consul server (non-leader) to service
+ // a read. This allows for lower latency and higher throughput
+ AllowStale bool
+
+ // RequireConsistent forces the read to be fully consistent.
+ // This is more expensive but prevents ever performing a stale
+ // read.
+ RequireConsistent bool
+
+ // WaitIndex is used to enable a blocking query. Waits
+ // until the timeout or the next index is reached
+ WaitIndex uint64
+
+ // WaitTime is used to bound the duration of a wait.
+ // Defaults to that of the Config, but can be overriden.
+ WaitTime time.Duration
+
+ // Token is used to provide a per-request ACL token
+ // which overrides the agent's default token.
+ Token string
+}
+
+// WriteOptions are used to parameterize a write
+type WriteOptions struct {
+ // Providing a datacenter overwrites the DC provided
+ // by the Config
+ Datacenter string
+
+ // Token is used to provide a per-request ACL token
+ // which overrides the agent's default token.
+ Token string
+}
+
+// QueryMeta is used to return meta data about a query
+type QueryMeta struct {
+ // LastIndex. This can be used as a WaitIndex to perform
+ // a blocking query
+ LastIndex uint64
+
+ // Time of last contact from the leader for the
+ // server servicing the request
+ LastContact time.Duration
+
+ // Is there a known leader
+ KnownLeader bool
+
+ // How long did the request take
+ RequestTime time.Duration
+}
+
+// WriteMeta is used to return meta data about a write
+type WriteMeta struct {
+ // How long did the request take
+ RequestTime time.Duration
+}
+
+// HttpBasicAuth is used to authenticate http client with HTTP Basic Authentication
+type HttpBasicAuth struct {
+ // Username to use for HTTP Basic Authentication
+ Username string
+
+ // Password to use for HTTP Basic Authentication
+ Password string
+}
+
+// Config is used to configure the creation of a client
+type Config struct {
+ // Address is the address of the Consul server
+ Address string
+
+ // Scheme is the URI scheme for the Consul server
+ Scheme string
+
+ // Datacenter to use. If not provided, the default agent datacenter is used.
+ Datacenter string
+
+ // HttpClient is the client to use. Default will be
+ // used if not provided.
+ HttpClient *http.Client
+
+ // HttpAuth is the auth info to use for http access.
+ HttpAuth *HttpBasicAuth
+
+ // WaitTime limits how long a Watch will block. If not provided,
+ // the agent default values will be used.
+ WaitTime time.Duration
+
+ // Token is used to provide a per-request ACL token
+ // which overrides the agent's default token.
+ Token string
+}
+
+// DefaultConfig returns a default configuration for the client
+func DefaultConfig() *Config {
+ return &Config{
+ Address: "127.0.0.1:8500",
+ Scheme: "http",
+ HttpClient: http.DefaultClient,
+ }
+}
+
+// Client provides a client to the Consul API
+type Client struct {
+ config Config
+}
+
+// NewClient returns a new client
+func NewClient(config *Config) (*Client, error) {
+ // bootstrap the config
+ defConfig := DefaultConfig()
+
+ if len(config.Address) == 0 {
+ config.Address = defConfig.Address
+ }
+
+ if len(config.Scheme) == 0 {
+ config.Scheme = defConfig.Scheme
+ }
+
+ if config.HttpClient == nil {
+ config.HttpClient = defConfig.HttpClient
+ }
+
+ client := &Client{
+ config: *config,
+ }
+ return client, nil
+}
+
+// request is used to help build up a request
+type request struct {
+ config *Config
+ method string
+ url *url.URL
+ params url.Values
+ body io.Reader
+ obj interface{}
+}
+
+// setQueryOptions is used to annotate the request with
+// additional query options
+func (r *request) setQueryOptions(q *QueryOptions) {
+ if q == nil {
+ return
+ }
+ if q.Datacenter != "" {
+ r.params.Set("dc", q.Datacenter)
+ }
+ if q.AllowStale {
+ r.params.Set("stale", "")
+ }
+ if q.RequireConsistent {
+ r.params.Set("consistent", "")
+ }
+ if q.WaitIndex != 0 {
+ r.params.Set("index", strconv.FormatUint(q.WaitIndex, 10))
+ }
+ if q.WaitTime != 0 {
+ r.params.Set("wait", durToMsec(q.WaitTime))
+ }
+ if q.Token != "" {
+ r.params.Set("token", q.Token)
+ }
+}
+
+// durToMsec converts a duration to a millisecond specified string
+func durToMsec(dur time.Duration) string {
+ return fmt.Sprintf("%dms", dur/time.Millisecond)
+}
+
+// setWriteOptions is used to annotate the request with
+// additional write options
+func (r *request) setWriteOptions(q *WriteOptions) {
+ if q == nil {
+ return
+ }
+ if q.Datacenter != "" {
+ r.params.Set("dc", q.Datacenter)
+ }
+ if q.Token != "" {
+ r.params.Set("token", q.Token)
+ }
+}
+
+// toHTTP converts the request to an HTTP request
+func (r *request) toHTTP() (*http.Request, error) {
+ // Encode the query parameters
+ r.url.RawQuery = r.params.Encode()
+
+ // Get the url sring
+ urlRaw := r.url.String()
+
+ // Check if we should encode the body
+ if r.body == nil && r.obj != nil {
+ if b, err := encodeBody(r.obj); err != nil {
+ return nil, err
+ } else {
+ r.body = b
+ }
+ }
+
+ // Create the HTTP request
+ req, err := http.NewRequest(r.method, urlRaw, r.body)
+
+ // Setup auth
+ if err == nil && r.config.HttpAuth != nil {
+ req.SetBasicAuth(r.config.HttpAuth.Username, r.config.HttpAuth.Password)
+ }
+
+ return req, err
+}
+
+// newRequest is used to create a new request
+func (c *Client) newRequest(method, path string) *request {
+ r := &request{
+ config: &c.config,
+ method: method,
+ url: &url.URL{
+ Scheme: c.config.Scheme,
+ Host: c.config.Address,
+ Path: path,
+ },
+ params: make(map[string][]string),
+ }
+ if c.config.Datacenter != "" {
+ r.params.Set("dc", c.config.Datacenter)
+ }
+ if c.config.WaitTime != 0 {
+ r.params.Set("wait", durToMsec(r.config.WaitTime))
+ }
+ if c.config.Token != "" {
+ r.params.Set("token", r.config.Token)
+ }
+ return r
+}
+
+// doRequest runs a request with our client
+func (c *Client) doRequest(r *request) (time.Duration, *http.Response, error) {
+ req, err := r.toHTTP()
+ if err != nil {
+ return 0, nil, err
+ }
+ start := time.Now()
+ resp, err := c.config.HttpClient.Do(req)
+ diff := time.Now().Sub(start)
+ return diff, resp, err
+}
+
+// parseQueryMeta is used to help parse query meta-data
+func parseQueryMeta(resp *http.Response, q *QueryMeta) error {
+ header := resp.Header
+
+ // Parse the X-Consul-Index
+ index, err := strconv.ParseUint(header.Get("X-Consul-Index"), 10, 64)
+ if err != nil {
+ return fmt.Errorf("Failed to parse X-Consul-Index: %v", err)
+ }
+ q.LastIndex = index
+
+ // Parse the X-Consul-LastContact
+ last, err := strconv.ParseUint(header.Get("X-Consul-LastContact"), 10, 64)
+ if err != nil {
+ return fmt.Errorf("Failed to parse X-Consul-LastContact: %v", err)
+ }
+ q.LastContact = time.Duration(last) * time.Millisecond
+
+ // Parse the X-Consul-KnownLeader
+ switch header.Get("X-Consul-KnownLeader") {
+ case "true":
+ q.KnownLeader = true
+ default:
+ q.KnownLeader = false
+ }
+ return nil
+}
+
+// decodeBody is used to JSON decode a body
+func decodeBody(resp *http.Response, out interface{}) error {
+ dec := json.NewDecoder(resp.Body)
+ return dec.Decode(out)
+}
+
+// encodeBody is used to encode a request body
+func encodeBody(obj interface{}) (io.Reader, error) {
+ buf := bytes.NewBuffer(nil)
+ enc := json.NewEncoder(buf)
+ if err := enc.Encode(obj); err != nil {
+ return nil, err
+ }
+ return buf, nil
+}
+
+// requireOK is used to wrap doRequest and check for a 200
+func requireOK(d time.Duration, resp *http.Response, e error) (time.Duration, *http.Response, error) {
+ if e != nil {
+ return d, resp, e
+ }
+ if resp.StatusCode != 200 {
+ var buf bytes.Buffer
+ io.Copy(&buf, resp.Body)
+ return d, resp, fmt.Errorf("Unexpected response code: %d (%s)", resp.StatusCode, buf.Bytes())
+ }
+ return d, resp, e
+}
diff --git a/vendor/github.com/armon/consul-api/api_test.go b/vendor/github.com/armon/consul-api/api_test.go
new file mode 100644
index 00000000..3a608c53
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/api_test.go
@@ -0,0 +1,126 @@
+package consulapi
+
+import (
+ crand "crypto/rand"
+ "fmt"
+ "net/http"
+ "testing"
+ "time"
+)
+
+func makeClient(t *testing.T) *Client {
+ conf := DefaultConfig()
+ client, err := NewClient(conf)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ return client
+}
+
+func testKey() string {
+ buf := make([]byte, 16)
+ if _, err := crand.Read(buf); err != nil {
+ panic(fmt.Errorf("Failed to read random bytes: %v", err))
+ }
+
+ return fmt.Sprintf("%08x-%04x-%04x-%04x-%12x",
+ buf[0:4],
+ buf[4:6],
+ buf[6:8],
+ buf[8:10],
+ buf[10:16])
+}
+
+func TestSetQueryOptions(t *testing.T) {
+ c := makeClient(t)
+ r := c.newRequest("GET", "/v1/kv/foo")
+ q := &QueryOptions{
+ Datacenter: "foo",
+ AllowStale: true,
+ RequireConsistent: true,
+ WaitIndex: 1000,
+ WaitTime: 100 * time.Second,
+ Token: "12345",
+ }
+ r.setQueryOptions(q)
+
+ if r.params.Get("dc") != "foo" {
+ t.Fatalf("bad: %v", r.params)
+ }
+ if _, ok := r.params["stale"]; !ok {
+ t.Fatalf("bad: %v", r.params)
+ }
+ if _, ok := r.params["consistent"]; !ok {
+ t.Fatalf("bad: %v", r.params)
+ }
+ if r.params.Get("index") != "1000" {
+ t.Fatalf("bad: %v", r.params)
+ }
+ if r.params.Get("wait") != "100000ms" {
+ t.Fatalf("bad: %v", r.params)
+ }
+ if r.params.Get("token") != "12345" {
+ t.Fatalf("bad: %v", r.params)
+ }
+}
+
+func TestSetWriteOptions(t *testing.T) {
+ c := makeClient(t)
+ r := c.newRequest("GET", "/v1/kv/foo")
+ q := &WriteOptions{
+ Datacenter: "foo",
+ Token: "23456",
+ }
+ r.setWriteOptions(q)
+
+ if r.params.Get("dc") != "foo" {
+ t.Fatalf("bad: %v", r.params)
+ }
+ if r.params.Get("token") != "23456" {
+ t.Fatalf("bad: %v", r.params)
+ }
+}
+
+func TestRequestToHTTP(t *testing.T) {
+ c := makeClient(t)
+ r := c.newRequest("DELETE", "/v1/kv/foo")
+ q := &QueryOptions{
+ Datacenter: "foo",
+ }
+ r.setQueryOptions(q)
+ req, err := r.toHTTP()
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if req.Method != "DELETE" {
+ t.Fatalf("bad: %v", req)
+ }
+ if req.URL.String() != "http://127.0.0.1:8500/v1/kv/foo?dc=foo" {
+ t.Fatalf("bad: %v", req)
+ }
+}
+
+func TestParseQueryMeta(t *testing.T) {
+ resp := &http.Response{
+ Header: make(map[string][]string),
+ }
+ resp.Header.Set("X-Consul-Index", "12345")
+ resp.Header.Set("X-Consul-LastContact", "80")
+ resp.Header.Set("X-Consul-KnownLeader", "true")
+
+ qm := &QueryMeta{}
+ if err := parseQueryMeta(resp, qm); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if qm.LastIndex != 12345 {
+ t.Fatalf("Bad: %v", qm)
+ }
+ if qm.LastContact != 80*time.Millisecond {
+ t.Fatalf("Bad: %v", qm)
+ }
+ if !qm.KnownLeader {
+ t.Fatalf("Bad: %v", qm)
+ }
+}
diff --git a/vendor/github.com/armon/consul-api/catalog.go b/vendor/github.com/armon/consul-api/catalog.go
new file mode 100644
index 00000000..8080e2a9
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/catalog.go
@@ -0,0 +1,181 @@
+package consulapi
+
+type Node struct {
+ Node string
+ Address string
+}
+
+type CatalogService struct {
+ Node string
+ Address string
+ ServiceID string
+ ServiceName string
+ ServiceTags []string
+ ServicePort int
+}
+
+type CatalogNode struct {
+ Node *Node
+ Services map[string]*AgentService
+}
+
+type CatalogRegistration struct {
+ Node string
+ Address string
+ Datacenter string
+ Service *AgentService
+ Check *AgentCheck
+}
+
+type CatalogDeregistration struct {
+ Node string
+ Address string
+ Datacenter string
+ ServiceID string
+ CheckID string
+}
+
+// Catalog can be used to query the Catalog endpoints
+type Catalog struct {
+ c *Client
+}
+
+// Catalog returns a handle to the catalog endpoints
+func (c *Client) Catalog() *Catalog {
+ return &Catalog{c}
+}
+
+func (c *Catalog) Register(reg *CatalogRegistration, q *WriteOptions) (*WriteMeta, error) {
+ r := c.c.newRequest("PUT", "/v1/catalog/register")
+ r.setWriteOptions(q)
+ r.obj = reg
+ rtt, resp, err := requireOK(c.c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ resp.Body.Close()
+
+ wm := &WriteMeta{}
+ wm.RequestTime = rtt
+
+ return wm, nil
+}
+
+func (c *Catalog) Deregister(dereg *CatalogDeregistration, q *WriteOptions) (*WriteMeta, error) {
+ r := c.c.newRequest("PUT", "/v1/catalog/deregister")
+ r.setWriteOptions(q)
+ r.obj = dereg
+ rtt, resp, err := requireOK(c.c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ resp.Body.Close()
+
+ wm := &WriteMeta{}
+ wm.RequestTime = rtt
+
+ return wm, nil
+}
+
+// Datacenters is used to query for all the known datacenters
+func (c *Catalog) Datacenters() ([]string, error) {
+ r := c.c.newRequest("GET", "/v1/catalog/datacenters")
+ _, resp, err := requireOK(c.c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ var out []string
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// Nodes is used to query all the known nodes
+func (c *Catalog) Nodes(q *QueryOptions) ([]*Node, *QueryMeta, error) {
+ r := c.c.newRequest("GET", "/v1/catalog/nodes")
+ r.setQueryOptions(q)
+ rtt, resp, err := requireOK(c.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var out []*Node
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, nil, err
+ }
+ return out, qm, nil
+}
+
+// Services is used to query for all known services
+func (c *Catalog) Services(q *QueryOptions) (map[string][]string, *QueryMeta, error) {
+ r := c.c.newRequest("GET", "/v1/catalog/services")
+ r.setQueryOptions(q)
+ rtt, resp, err := requireOK(c.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var out map[string][]string
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, nil, err
+ }
+ return out, qm, nil
+}
+
+// Service is used to query catalog entries for a given service
+func (c *Catalog) Service(service, tag string, q *QueryOptions) ([]*CatalogService, *QueryMeta, error) {
+ r := c.c.newRequest("GET", "/v1/catalog/service/"+service)
+ r.setQueryOptions(q)
+ if tag != "" {
+ r.params.Set("tag", tag)
+ }
+ rtt, resp, err := requireOK(c.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var out []*CatalogService
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, nil, err
+ }
+ return out, qm, nil
+}
+
+// Node is used to query for service information about a single node
+func (c *Catalog) Node(node string, q *QueryOptions) (*CatalogNode, *QueryMeta, error) {
+ r := c.c.newRequest("GET", "/v1/catalog/node/"+node)
+ r.setQueryOptions(q)
+ rtt, resp, err := requireOK(c.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var out *CatalogNode
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, nil, err
+ }
+ return out, qm, nil
+}
diff --git a/vendor/github.com/armon/consul-api/catalog_test.go b/vendor/github.com/armon/consul-api/catalog_test.go
new file mode 100644
index 00000000..7ed6cfc2
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/catalog_test.go
@@ -0,0 +1,219 @@
+package consulapi
+
+import (
+ "testing"
+)
+
+func TestCatalog_Datacenters(t *testing.T) {
+ c := makeClient(t)
+ catalog := c.Catalog()
+
+ datacenters, err := catalog.Datacenters()
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if len(datacenters) == 0 {
+ t.Fatalf("Bad: %v", datacenters)
+ }
+}
+
+func TestCatalog_Nodes(t *testing.T) {
+ c := makeClient(t)
+ catalog := c.Catalog()
+
+ nodes, meta, err := catalog.Nodes(nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if meta.LastIndex == 0 {
+ t.Fatalf("Bad: %v", meta)
+ }
+
+ if len(nodes) == 0 {
+ t.Fatalf("Bad: %v", nodes)
+ }
+}
+
+func TestCatalog_Services(t *testing.T) {
+ c := makeClient(t)
+ catalog := c.Catalog()
+
+ services, meta, err := catalog.Services(nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if meta.LastIndex == 0 {
+ t.Fatalf("Bad: %v", meta)
+ }
+
+ if len(services) == 0 {
+ t.Fatalf("Bad: %v", services)
+ }
+}
+
+func TestCatalog_Service(t *testing.T) {
+ c := makeClient(t)
+ catalog := c.Catalog()
+
+ services, meta, err := catalog.Service("consul", "", nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if meta.LastIndex == 0 {
+ t.Fatalf("Bad: %v", meta)
+ }
+
+ if len(services) == 0 {
+ t.Fatalf("Bad: %v", services)
+ }
+}
+
+func TestCatalog_Node(t *testing.T) {
+ c := makeClient(t)
+ catalog := c.Catalog()
+
+ name, _ := c.Agent().NodeName()
+ info, meta, err := catalog.Node(name, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if meta.LastIndex == 0 {
+ t.Fatalf("Bad: %v", meta)
+ }
+ if len(info.Services) == 0 {
+ t.Fatalf("Bad: %v", info)
+ }
+}
+
+func TestCatalog_Registration(t *testing.T) {
+ c := makeClient(t)
+ catalog := c.Catalog()
+
+ service := &AgentService{
+ ID: "redis1",
+ Service: "redis",
+ Tags: []string{"master", "v1"},
+ Port: 8000,
+ }
+
+ check := &AgentCheck{
+ Node: "foobar",
+ CheckID: "service:redis1",
+ Name: "Redis health check",
+ Notes: "Script based health check",
+ Status: "passing",
+ ServiceID: "redis1",
+ }
+
+ reg := &CatalogRegistration{
+ Datacenter: "dc1",
+ Node: "foobar",
+ Address: "192.168.10.10",
+ Service: service,
+ Check: check,
+ }
+
+ _, err := catalog.Register(reg, nil)
+
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ node, _, err := catalog.Node("foobar", nil)
+
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if _, ok := node.Services["redis1"]; !ok {
+ t.Fatalf("missing service: redis1")
+ }
+
+ health, _, err := c.Health().Node("foobar", nil)
+
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if health[0].CheckID != "service:redis1" {
+ t.Fatalf("missing checkid service:redis1")
+ }
+}
+
+func TestCatalog_Deregistration(t *testing.T) {
+ c := makeClient(t)
+ catalog := c.Catalog()
+
+ dereg := &CatalogDeregistration{
+ Datacenter: "dc1",
+ Node: "foobar",
+ Address: "192.168.10.10",
+ ServiceID: "redis1",
+ }
+
+ _, err := catalog.Deregister(dereg, nil)
+
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ node, _, err := catalog.Node("foobar", nil)
+
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if _, ok := node.Services["redis1"]; ok {
+ t.Fatalf("ServiceID:redis1 is not deregistered")
+ }
+
+ dereg = &CatalogDeregistration{
+ Datacenter: "dc1",
+ Node: "foobar",
+ Address: "192.168.10.10",
+ CheckID: "service:redis1",
+ }
+
+ _, err = catalog.Deregister(dereg, nil)
+
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ health, _, err := c.Health().Node("foobar", nil)
+
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if len(health) != 0 {
+ t.Fatalf("CheckID:service:redis1 is not deregistered")
+ }
+
+ dereg = &CatalogDeregistration{
+ Datacenter: "dc1",
+ Node: "foobar",
+ Address: "192.168.10.10",
+ }
+
+ _, err = catalog.Deregister(dereg, nil)
+
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ node, _, err = catalog.Node("foobar", nil)
+
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if node != nil {
+ t.Fatalf("node is not deregistered: %v", node)
+ }
+}
diff --git a/vendor/github.com/armon/consul-api/event.go b/vendor/github.com/armon/consul-api/event.go
new file mode 100644
index 00000000..59813d40
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/event.go
@@ -0,0 +1,104 @@
+package consulapi
+
+import (
+ "bytes"
+ "strconv"
+)
+
+// Event can be used to query the Event endpoints
+type Event struct {
+ c *Client
+}
+
+// UserEvent represents an event that was fired by the user
+type UserEvent struct {
+ ID string
+ Name string
+ Payload []byte
+ NodeFilter string
+ ServiceFilter string
+ TagFilter string
+ Version int
+ LTime uint64
+}
+
+// Event returns a handle to the event endpoints
+func (c *Client) Event() *Event {
+ return &Event{c}
+}
+
+// Fire is used to fire a new user event. Only the Name, Payload and Filters
+// are respected. This returns the ID or an associated error. Cross DC requests
+// are supported.
+func (e *Event) Fire(params *UserEvent, q *WriteOptions) (string, *WriteMeta, error) {
+ r := e.c.newRequest("PUT", "/v1/event/fire/"+params.Name)
+ r.setWriteOptions(q)
+ if params.NodeFilter != "" {
+ r.params.Set("node", params.NodeFilter)
+ }
+ if params.ServiceFilter != "" {
+ r.params.Set("service", params.ServiceFilter)
+ }
+ if params.TagFilter != "" {
+ r.params.Set("tag", params.TagFilter)
+ }
+ if params.Payload != nil {
+ r.body = bytes.NewReader(params.Payload)
+ }
+
+ rtt, resp, err := requireOK(e.c.doRequest(r))
+ if err != nil {
+ return "", nil, err
+ }
+ defer resp.Body.Close()
+
+ wm := &WriteMeta{RequestTime: rtt}
+ var out UserEvent
+ if err := decodeBody(resp, &out); err != nil {
+ return "", nil, err
+ }
+ return out.ID, wm, nil
+}
+
+// List is used to get the most recent events an agent has received.
+// This list can be optionally filtered by the name. This endpoint supports
+// quasi-blocking queries. The index is not monotonic, nor does it provide provide
+// LastContact or KnownLeader.
+func (e *Event) List(name string, q *QueryOptions) ([]*UserEvent, *QueryMeta, error) {
+ r := e.c.newRequest("GET", "/v1/event/list")
+ r.setQueryOptions(q)
+ if name != "" {
+ r.params.Set("name", name)
+ }
+ rtt, resp, err := requireOK(e.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var entries []*UserEvent
+ if err := decodeBody(resp, &entries); err != nil {
+ return nil, nil, err
+ }
+ return entries, qm, nil
+}
+
+// IDToIndex is a bit of a hack. This simulates the index generation to
+// convert an event ID into a WaitIndex.
+func (e *Event) IDToIndex(uuid string) uint64 {
+ lower := uuid[0:8] + uuid[9:13] + uuid[14:18]
+ upper := uuid[19:23] + uuid[24:36]
+ lowVal, err := strconv.ParseUint(lower, 16, 64)
+ if err != nil {
+ panic("Failed to convert " + lower)
+ }
+ highVal, err := strconv.ParseUint(upper, 16, 64)
+ if err != nil {
+ panic("Failed to convert " + upper)
+ }
+ return lowVal ^ highVal
+}
diff --git a/vendor/github.com/armon/consul-api/event_test.go b/vendor/github.com/armon/consul-api/event_test.go
new file mode 100644
index 00000000..f2be010a
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/event_test.go
@@ -0,0 +1,37 @@
+package consulapi
+
+import (
+ "testing"
+)
+
+func TestEvent_FireList(t *testing.T) {
+ c := makeClient(t)
+ event := c.Event()
+
+ params := &UserEvent{Name: "foo"}
+ id, meta, err := event.Fire(params, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if meta.RequestTime == 0 {
+ t.Fatalf("bad: %v", meta)
+ }
+
+ if id == "" {
+ t.Fatalf("invalid: %v", id)
+ }
+
+ events, qm, err := event.List("", nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if qm.LastIndex != event.IDToIndex(id) {
+ t.Fatalf("Bad: %#v", qm)
+ }
+
+ if events[len(events)-1].ID != id {
+ t.Fatalf("bad: %#v", events)
+ }
+}
diff --git a/vendor/github.com/armon/consul-api/health.go b/vendor/github.com/armon/consul-api/health.go
new file mode 100644
index 00000000..574801e2
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/health.go
@@ -0,0 +1,136 @@
+package consulapi
+
+import (
+ "fmt"
+)
+
+// HealthCheck is used to represent a single check
+type HealthCheck struct {
+ Node string
+ CheckID string
+ Name string
+ Status string
+ Notes string
+ Output string
+ ServiceID string
+ ServiceName string
+}
+
+// ServiceEntry is used for the health service endpoint
+type ServiceEntry struct {
+ Node *Node
+ Service *AgentService
+ Checks []*HealthCheck
+}
+
+// Health can be used to query the Health endpoints
+type Health struct {
+ c *Client
+}
+
+// Health returns a handle to the health endpoints
+func (c *Client) Health() *Health {
+ return &Health{c}
+}
+
+// Node is used to query for checks belonging to a given node
+func (h *Health) Node(node string, q *QueryOptions) ([]*HealthCheck, *QueryMeta, error) {
+ r := h.c.newRequest("GET", "/v1/health/node/"+node)
+ r.setQueryOptions(q)
+ rtt, resp, err := requireOK(h.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var out []*HealthCheck
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, nil, err
+ }
+ return out, qm, nil
+}
+
+// Checks is used to return the checks associated with a service
+func (h *Health) Checks(service string, q *QueryOptions) ([]*HealthCheck, *QueryMeta, error) {
+ r := h.c.newRequest("GET", "/v1/health/checks/"+service)
+ r.setQueryOptions(q)
+ rtt, resp, err := requireOK(h.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var out []*HealthCheck
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, nil, err
+ }
+ return out, qm, nil
+}
+
+// Service is used to query health information along with service info
+// for a given service. It can optionally do server-side filtering on a tag
+// or nodes with passing health checks only.
+func (h *Health) Service(service, tag string, passingOnly bool, q *QueryOptions) ([]*ServiceEntry, *QueryMeta, error) {
+ r := h.c.newRequest("GET", "/v1/health/service/"+service)
+ r.setQueryOptions(q)
+ if tag != "" {
+ r.params.Set("tag", tag)
+ }
+ if passingOnly {
+ r.params.Set("passing", "1")
+ }
+ rtt, resp, err := requireOK(h.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var out []*ServiceEntry
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, nil, err
+ }
+ return out, qm, nil
+}
+
+// State is used to retreive all the checks in a given state.
+// The wildcard "any" state can also be used for all checks.
+func (h *Health) State(state string, q *QueryOptions) ([]*HealthCheck, *QueryMeta, error) {
+ switch state {
+ case "any":
+ case "warning":
+ case "critical":
+ case "passing":
+ case "unknown":
+ default:
+ return nil, nil, fmt.Errorf("Unsupported state: %v", state)
+ }
+ r := h.c.newRequest("GET", "/v1/health/state/"+state)
+ r.setQueryOptions(q)
+ rtt, resp, err := requireOK(h.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var out []*HealthCheck
+ if err := decodeBody(resp, &out); err != nil {
+ return nil, nil, err
+ }
+ return out, qm, nil
+}
diff --git a/vendor/github.com/armon/consul-api/health_test.go b/vendor/github.com/armon/consul-api/health_test.go
new file mode 100644
index 00000000..d2b3da2e
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/health_test.go
@@ -0,0 +1,98 @@
+package consulapi
+
+import (
+ "testing"
+ "time"
+)
+
+func TestHealth_Node(t *testing.T) {
+ c := makeClient(t)
+ agent := c.Agent()
+ health := c.Health()
+
+ info, err := agent.Self()
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ name := info["Config"]["NodeName"].(string)
+
+ checks, meta, err := health.Node(name, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if meta.LastIndex == 0 {
+ t.Fatalf("bad: %v", meta)
+ }
+ if len(checks) == 0 {
+ t.Fatalf("Bad: %v", checks)
+ }
+}
+
+func TestHealth_Checks(t *testing.T) {
+ c := makeClient(t)
+ agent := c.Agent()
+ health := c.Health()
+
+ // Make a service with a check
+ reg := &AgentServiceRegistration{
+ Name: "foo",
+ Check: &AgentServiceCheck{
+ TTL: "15s",
+ },
+ }
+ if err := agent.ServiceRegister(reg); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ defer agent.ServiceDeregister("foo")
+
+ // Wait for the register...
+ time.Sleep(20 * time.Millisecond)
+
+ checks, meta, err := health.Checks("foo", nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if meta.LastIndex == 0 {
+ t.Fatalf("bad: %v", meta)
+ }
+ if len(checks) == 0 {
+ t.Fatalf("Bad: %v", checks)
+ }
+}
+
+func TestHealth_Service(t *testing.T) {
+ c := makeClient(t)
+ health := c.Health()
+
+ // consul service should always exist...
+ checks, meta, err := health.Service("consul", "", true, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if meta.LastIndex == 0 {
+ t.Fatalf("bad: %v", meta)
+ }
+ if len(checks) == 0 {
+ t.Fatalf("Bad: %v", checks)
+ }
+}
+
+func TestHealth_State(t *testing.T) {
+ c := makeClient(t)
+ health := c.Health()
+
+ checks, meta, err := health.State("any", nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if meta.LastIndex == 0 {
+ t.Fatalf("bad: %v", meta)
+ }
+ if len(checks) == 0 {
+ t.Fatalf("Bad: %v", checks)
+ }
+}
diff --git a/vendor/github.com/armon/consul-api/kv.go b/vendor/github.com/armon/consul-api/kv.go
new file mode 100644
index 00000000..98c3b1a0
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/kv.go
@@ -0,0 +1,219 @@
+package consulapi
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "net/http"
+ "strconv"
+ "strings"
+)
+
+// KVPair is used to represent a single K/V entry
+type KVPair struct {
+ Key string
+ CreateIndex uint64
+ ModifyIndex uint64
+ LockIndex uint64
+ Flags uint64
+ Value []byte
+ Session string
+}
+
+// KVPairs is a list of KVPair objects
+type KVPairs []*KVPair
+
+// KV is used to manipulate the K/V API
+type KV struct {
+ c *Client
+}
+
+// KV is used to return a handle to the K/V apis
+func (c *Client) KV() *KV {
+ return &KV{c}
+}
+
+// Get is used to lookup a single key
+func (k *KV) Get(key string, q *QueryOptions) (*KVPair, *QueryMeta, error) {
+ resp, qm, err := k.getInternal(key, nil, q)
+ if err != nil {
+ return nil, nil, err
+ }
+ if resp == nil {
+ return nil, qm, nil
+ }
+ defer resp.Body.Close()
+
+ var entries []*KVPair
+ if err := decodeBody(resp, &entries); err != nil {
+ return nil, nil, err
+ }
+ if len(entries) > 0 {
+ return entries[0], qm, nil
+ }
+ return nil, qm, nil
+}
+
+// List is used to lookup all keys under a prefix
+func (k *KV) List(prefix string, q *QueryOptions) (KVPairs, *QueryMeta, error) {
+ resp, qm, err := k.getInternal(prefix, map[string]string{"recurse": ""}, q)
+ if err != nil {
+ return nil, nil, err
+ }
+ if resp == nil {
+ return nil, qm, nil
+ }
+ defer resp.Body.Close()
+
+ var entries []*KVPair
+ if err := decodeBody(resp, &entries); err != nil {
+ return nil, nil, err
+ }
+ return entries, qm, nil
+}
+
+// Keys is used to list all the keys under a prefix. Optionally,
+// a separator can be used to limit the responses.
+func (k *KV) Keys(prefix, separator string, q *QueryOptions) ([]string, *QueryMeta, error) {
+ params := map[string]string{"keys": ""}
+ if separator != "" {
+ params["separator"] = separator
+ }
+ resp, qm, err := k.getInternal(prefix, params, q)
+ if err != nil {
+ return nil, nil, err
+ }
+ if resp == nil {
+ return nil, qm, nil
+ }
+ defer resp.Body.Close()
+
+ var entries []string
+ if err := decodeBody(resp, &entries); err != nil {
+ return nil, nil, err
+ }
+ return entries, qm, nil
+}
+
+func (k *KV) getInternal(key string, params map[string]string, q *QueryOptions) (*http.Response, *QueryMeta, error) {
+ r := k.c.newRequest("GET", "/v1/kv/"+key)
+ r.setQueryOptions(q)
+ for param, val := range params {
+ r.params.Set(param, val)
+ }
+ rtt, resp, err := k.c.doRequest(r)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ if resp.StatusCode == 404 {
+ resp.Body.Close()
+ return nil, qm, nil
+ } else if resp.StatusCode != 200 {
+ resp.Body.Close()
+ return nil, nil, fmt.Errorf("Unexpected response code: %d", resp.StatusCode)
+ }
+ return resp, qm, nil
+}
+
+// Put is used to write a new value. Only the
+// Key, Flags and Value is respected.
+func (k *KV) Put(p *KVPair, q *WriteOptions) (*WriteMeta, error) {
+ params := make(map[string]string, 1)
+ if p.Flags != 0 {
+ params["flags"] = strconv.FormatUint(p.Flags, 10)
+ }
+ _, wm, err := k.put(p.Key, params, p.Value, q)
+ return wm, err
+}
+
+// CAS is used for a Check-And-Set operation. The Key,
+// ModifyIndex, Flags and Value are respected. Returns true
+// on success or false on failures.
+func (k *KV) CAS(p *KVPair, q *WriteOptions) (bool, *WriteMeta, error) {
+ params := make(map[string]string, 2)
+ if p.Flags != 0 {
+ params["flags"] = strconv.FormatUint(p.Flags, 10)
+ }
+ params["cas"] = strconv.FormatUint(p.ModifyIndex, 10)
+ return k.put(p.Key, params, p.Value, q)
+}
+
+// Acquire is used for a lock acquisiiton operation. The Key,
+// Flags, Value and Session are respected. Returns true
+// on success or false on failures.
+func (k *KV) Acquire(p *KVPair, q *WriteOptions) (bool, *WriteMeta, error) {
+ params := make(map[string]string, 2)
+ if p.Flags != 0 {
+ params["flags"] = strconv.FormatUint(p.Flags, 10)
+ }
+ params["acquire"] = p.Session
+ return k.put(p.Key, params, p.Value, q)
+}
+
+// Release is used for a lock release operation. The Key,
+// Flags, Value and Session are respected. Returns true
+// on success or false on failures.
+func (k *KV) Release(p *KVPair, q *WriteOptions) (bool, *WriteMeta, error) {
+ params := make(map[string]string, 2)
+ if p.Flags != 0 {
+ params["flags"] = strconv.FormatUint(p.Flags, 10)
+ }
+ params["release"] = p.Session
+ return k.put(p.Key, params, p.Value, q)
+}
+
+func (k *KV) put(key string, params map[string]string, body []byte, q *WriteOptions) (bool, *WriteMeta, error) {
+ r := k.c.newRequest("PUT", "/v1/kv/"+key)
+ r.setWriteOptions(q)
+ for param, val := range params {
+ r.params.Set(param, val)
+ }
+ r.body = bytes.NewReader(body)
+ rtt, resp, err := requireOK(k.c.doRequest(r))
+ if err != nil {
+ return false, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &WriteMeta{}
+ qm.RequestTime = rtt
+
+ var buf bytes.Buffer
+ if _, err := io.Copy(&buf, resp.Body); err != nil {
+ return false, nil, fmt.Errorf("Failed to read response: %v", err)
+ }
+ res := strings.Contains(string(buf.Bytes()), "true")
+ return res, qm, nil
+}
+
+// Delete is used to delete a single key
+func (k *KV) Delete(key string, w *WriteOptions) (*WriteMeta, error) {
+ return k.deleteInternal(key, nil, w)
+}
+
+// DeleteTree is used to delete all keys under a prefix
+func (k *KV) DeleteTree(prefix string, w *WriteOptions) (*WriteMeta, error) {
+ return k.deleteInternal(prefix, []string{"recurse"}, w)
+}
+
+func (k *KV) deleteInternal(key string, params []string, q *WriteOptions) (*WriteMeta, error) {
+ r := k.c.newRequest("DELETE", "/v1/kv/"+key)
+ r.setWriteOptions(q)
+ for _, param := range params {
+ r.params.Set(param, "")
+ }
+ rtt, resp, err := requireOK(k.c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ resp.Body.Close()
+
+ qm := &WriteMeta{}
+ qm.RequestTime = rtt
+ return qm, nil
+}
diff --git a/vendor/github.com/armon/consul-api/kv_test.go b/vendor/github.com/armon/consul-api/kv_test.go
new file mode 100644
index 00000000..2d92d69f
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/kv_test.go
@@ -0,0 +1,374 @@
+package consulapi
+
+import (
+ "bytes"
+ "path"
+ "testing"
+ "time"
+)
+
+func TestClientPutGetDelete(t *testing.T) {
+ c := makeClient(t)
+ kv := c.KV()
+
+ // Get a get without a key
+ key := testKey()
+ pair, _, err := kv.Get(key, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if pair != nil {
+ t.Fatalf("unexpected value: %#v", pair)
+ }
+
+ // Put the key
+ value := []byte("test")
+ p := &KVPair{Key: key, Flags: 42, Value: value}
+ if _, err := kv.Put(p, nil); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ // Get should work
+ pair, meta, err := kv.Get(key, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if pair == nil {
+ t.Fatalf("expected value: %#v", pair)
+ }
+ if !bytes.Equal(pair.Value, value) {
+ t.Fatalf("unexpected value: %#v", pair)
+ }
+ if pair.Flags != 42 {
+ t.Fatalf("unexpected value: %#v", pair)
+ }
+ if meta.LastIndex == 0 {
+ t.Fatalf("unexpected value: %#v", meta)
+ }
+
+ // Delete
+ if _, err := kv.Delete(key, nil); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ // Get should fail
+ pair, _, err = kv.Get(key, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if pair != nil {
+ t.Fatalf("unexpected value: %#v", pair)
+ }
+}
+
+func TestClient_List_DeleteRecurse(t *testing.T) {
+ c := makeClient(t)
+ kv := c.KV()
+
+ // Generate some test keys
+ prefix := testKey()
+ var keys []string
+ for i := 0; i < 100; i++ {
+ keys = append(keys, path.Join(prefix, testKey()))
+ }
+
+ // Set values
+ value := []byte("test")
+ for _, key := range keys {
+ p := &KVPair{Key: key, Value: value}
+ if _, err := kv.Put(p, nil); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ }
+
+ // List the values
+ pairs, meta, err := kv.List(prefix, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if len(pairs) != len(keys) {
+ t.Fatalf("got %d keys", len(pairs))
+ }
+ for _, pair := range pairs {
+ if !bytes.Equal(pair.Value, value) {
+ t.Fatalf("unexpected value: %#v", pair)
+ }
+ }
+ if meta.LastIndex == 0 {
+ t.Fatalf("unexpected value: %#v", meta)
+ }
+
+ // Delete all
+ if _, err := kv.DeleteTree(prefix, nil); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ // List the values
+ pairs, _, err = kv.List(prefix, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if len(pairs) != 0 {
+ t.Fatalf("got %d keys", len(pairs))
+ }
+}
+
+func TestClient_CAS(t *testing.T) {
+ c := makeClient(t)
+ kv := c.KV()
+
+ // Put the key
+ key := testKey()
+ value := []byte("test")
+ p := &KVPair{Key: key, Value: value}
+ if work, _, err := kv.CAS(p, nil); err != nil {
+ t.Fatalf("err: %v", err)
+ } else if !work {
+ t.Fatalf("CAS failure")
+ }
+
+ // Get should work
+ pair, meta, err := kv.Get(key, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if pair == nil {
+ t.Fatalf("expected value: %#v", pair)
+ }
+ if meta.LastIndex == 0 {
+ t.Fatalf("unexpected value: %#v", meta)
+ }
+
+ // CAS update with bad index
+ newVal := []byte("foo")
+ p.Value = newVal
+ p.ModifyIndex = 1
+ if work, _, err := kv.CAS(p, nil); err != nil {
+ t.Fatalf("err: %v", err)
+ } else if work {
+ t.Fatalf("unexpected CAS")
+ }
+
+ // CAS update with valid index
+ p.ModifyIndex = meta.LastIndex
+ if work, _, err := kv.CAS(p, nil); err != nil {
+ t.Fatalf("err: %v", err)
+ } else if !work {
+ t.Fatalf("unexpected CAS failure")
+ }
+}
+
+func TestClient_WatchGet(t *testing.T) {
+ c := makeClient(t)
+ kv := c.KV()
+
+ // Get a get without a key
+ key := testKey()
+ pair, meta, err := kv.Get(key, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if pair != nil {
+ t.Fatalf("unexpected value: %#v", pair)
+ }
+ if meta.LastIndex == 0 {
+ t.Fatalf("unexpected value: %#v", meta)
+ }
+
+ // Put the key
+ value := []byte("test")
+ go func() {
+ c := makeClient(t)
+ kv := c.KV()
+
+ time.Sleep(100 * time.Millisecond)
+ p := &KVPair{Key: key, Flags: 42, Value: value}
+ if _, err := kv.Put(p, nil); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ }()
+
+ // Get should work
+ options := &QueryOptions{WaitIndex: meta.LastIndex}
+ pair, meta2, err := kv.Get(key, options)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if pair == nil {
+ t.Fatalf("expected value: %#v", pair)
+ }
+ if !bytes.Equal(pair.Value, value) {
+ t.Fatalf("unexpected value: %#v", pair)
+ }
+ if pair.Flags != 42 {
+ t.Fatalf("unexpected value: %#v", pair)
+ }
+ if meta2.LastIndex <= meta.LastIndex {
+ t.Fatalf("unexpected value: %#v", meta2)
+ }
+}
+
+func TestClient_WatchList(t *testing.T) {
+ c := makeClient(t)
+ kv := c.KV()
+
+ // Get a get without a key
+ prefix := testKey()
+ key := path.Join(prefix, testKey())
+ pairs, meta, err := kv.List(prefix, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if len(pairs) != 0 {
+ t.Fatalf("unexpected value: %#v", pairs)
+ }
+ if meta.LastIndex == 0 {
+ t.Fatalf("unexpected value: %#v", meta)
+ }
+
+ // Put the key
+ value := []byte("test")
+ go func() {
+ c := makeClient(t)
+ kv := c.KV()
+
+ time.Sleep(100 * time.Millisecond)
+ p := &KVPair{Key: key, Flags: 42, Value: value}
+ if _, err := kv.Put(p, nil); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ }()
+
+ // Get should work
+ options := &QueryOptions{WaitIndex: meta.LastIndex}
+ pairs, meta2, err := kv.List(prefix, options)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if len(pairs) != 1 {
+ t.Fatalf("expected value: %#v", pairs)
+ }
+ if !bytes.Equal(pairs[0].Value, value) {
+ t.Fatalf("unexpected value: %#v", pairs)
+ }
+ if pairs[0].Flags != 42 {
+ t.Fatalf("unexpected value: %#v", pairs)
+ }
+ if meta2.LastIndex <= meta.LastIndex {
+ t.Fatalf("unexpected value: %#v", meta2)
+ }
+
+}
+
+func TestClient_Keys_DeleteRecurse(t *testing.T) {
+ c := makeClient(t)
+ kv := c.KV()
+
+ // Generate some test keys
+ prefix := testKey()
+ var keys []string
+ for i := 0; i < 100; i++ {
+ keys = append(keys, path.Join(prefix, testKey()))
+ }
+
+ // Set values
+ value := []byte("test")
+ for _, key := range keys {
+ p := &KVPair{Key: key, Value: value}
+ if _, err := kv.Put(p, nil); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ }
+
+ // List the values
+ out, meta, err := kv.Keys(prefix, "", nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if len(out) != len(keys) {
+ t.Fatalf("got %d keys", len(out))
+ }
+ if meta.LastIndex == 0 {
+ t.Fatalf("unexpected value: %#v", meta)
+ }
+
+ // Delete all
+ if _, err := kv.DeleteTree(prefix, nil); err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ // List the values
+ out, _, err = kv.Keys(prefix, "", nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if len(out) != 0 {
+ t.Fatalf("got %d keys", len(out))
+ }
+}
+
+func TestClient_AcquireRelease(t *testing.T) {
+ c := makeClient(t)
+ session := c.Session()
+ kv := c.KV()
+
+ // Make a session
+ id, _, err := session.CreateNoChecks(nil, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ defer session.Destroy(id, nil)
+
+ // Acquire the key
+ key := testKey()
+ value := []byte("test")
+ p := &KVPair{Key: key, Value: value, Session: id}
+ if work, _, err := kv.Acquire(p, nil); err != nil {
+ t.Fatalf("err: %v", err)
+ } else if !work {
+ t.Fatalf("Lock failure")
+ }
+
+ // Get should work
+ pair, meta, err := kv.Get(key, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if pair == nil {
+ t.Fatalf("expected value: %#v", pair)
+ }
+ if pair.LockIndex != 1 {
+ t.Fatalf("Expected lock: %v", pair)
+ }
+ if pair.Session != id {
+ t.Fatalf("Expected lock: %v", pair)
+ }
+ if meta.LastIndex == 0 {
+ t.Fatalf("unexpected value: %#v", meta)
+ }
+
+ // Release
+ if work, _, err := kv.Release(p, nil); err != nil {
+ t.Fatalf("err: %v", err)
+ } else if !work {
+ t.Fatalf("Release fail")
+ }
+
+ // Get should work
+ pair, meta, err = kv.Get(key, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if pair == nil {
+ t.Fatalf("expected value: %#v", pair)
+ }
+ if pair.LockIndex != 1 {
+ t.Fatalf("Expected lock: %v", pair)
+ }
+ if pair.Session != "" {
+ t.Fatalf("Expected unlock: %v", pair)
+ }
+ if meta.LastIndex == 0 {
+ t.Fatalf("unexpected value: %#v", meta)
+ }
+}
diff --git a/vendor/github.com/armon/consul-api/session.go b/vendor/github.com/armon/consul-api/session.go
new file mode 100644
index 00000000..4fbfc5ee
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/session.go
@@ -0,0 +1,204 @@
+package consulapi
+
+import (
+ "time"
+)
+
+// SessionEntry represents a session in consul
+type SessionEntry struct {
+ CreateIndex uint64
+ ID string
+ Name string
+ Node string
+ Checks []string
+ LockDelay time.Duration
+ Behavior string
+ TTL string
+}
+
+// Session can be used to query the Session endpoints
+type Session struct {
+ c *Client
+}
+
+// Session returns a handle to the session endpoints
+func (c *Client) Session() *Session {
+ return &Session{c}
+}
+
+// CreateNoChecks is like Create but is used specifically to create
+// a session with no associated health checks.
+func (s *Session) CreateNoChecks(se *SessionEntry, q *WriteOptions) (string, *WriteMeta, error) {
+ body := make(map[string]interface{})
+ body["Checks"] = []string{}
+ if se != nil {
+ if se.Name != "" {
+ body["Name"] = se.Name
+ }
+ if se.Node != "" {
+ body["Node"] = se.Node
+ }
+ if se.LockDelay != 0 {
+ body["LockDelay"] = durToMsec(se.LockDelay)
+ }
+ if se.Behavior != "" {
+ body["Behavior"] = se.Behavior
+ }
+ if se.TTL != "" {
+ body["TTL"] = se.TTL
+ }
+ }
+ return s.create(body, q)
+
+}
+
+// Create makes a new session. Providing a session entry can
+// customize the session. It can also be nil to use defaults.
+func (s *Session) Create(se *SessionEntry, q *WriteOptions) (string, *WriteMeta, error) {
+ var obj interface{}
+ if se != nil {
+ body := make(map[string]interface{})
+ obj = body
+ if se.Name != "" {
+ body["Name"] = se.Name
+ }
+ if se.Node != "" {
+ body["Node"] = se.Node
+ }
+ if se.LockDelay != 0 {
+ body["LockDelay"] = durToMsec(se.LockDelay)
+ }
+ if len(se.Checks) > 0 {
+ body["Checks"] = se.Checks
+ }
+ if se.Behavior != "" {
+ body["Behavior"] = se.Behavior
+ }
+ if se.TTL != "" {
+ body["TTL"] = se.TTL
+ }
+ }
+ return s.create(obj, q)
+}
+
+func (s *Session) create(obj interface{}, q *WriteOptions) (string, *WriteMeta, error) {
+ r := s.c.newRequest("PUT", "/v1/session/create")
+ r.setWriteOptions(q)
+ r.obj = obj
+ rtt, resp, err := requireOK(s.c.doRequest(r))
+ if err != nil {
+ return "", nil, err
+ }
+ defer resp.Body.Close()
+
+ wm := &WriteMeta{RequestTime: rtt}
+ var out struct{ ID string }
+ if err := decodeBody(resp, &out); err != nil {
+ return "", nil, err
+ }
+ return out.ID, wm, nil
+}
+
+// Destroy invalides a given session
+func (s *Session) Destroy(id string, q *WriteOptions) (*WriteMeta, error) {
+ r := s.c.newRequest("PUT", "/v1/session/destroy/"+id)
+ r.setWriteOptions(q)
+ rtt, resp, err := requireOK(s.c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ resp.Body.Close()
+
+ wm := &WriteMeta{RequestTime: rtt}
+ return wm, nil
+}
+
+// Renew renews the TTL on a given session
+func (s *Session) Renew(id string, q *WriteOptions) (*SessionEntry, *WriteMeta, error) {
+ r := s.c.newRequest("PUT", "/v1/session/renew/"+id)
+ r.setWriteOptions(q)
+ rtt, resp, err := requireOK(s.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ wm := &WriteMeta{RequestTime: rtt}
+
+ var entries []*SessionEntry
+ if err := decodeBody(resp, &entries); err != nil {
+ return nil, wm, err
+ }
+
+ if len(entries) > 0 {
+ return entries[0], wm, nil
+ }
+ return nil, wm, nil
+}
+
+// Info looks up a single session
+func (s *Session) Info(id string, q *QueryOptions) (*SessionEntry, *QueryMeta, error) {
+ r := s.c.newRequest("GET", "/v1/session/info/"+id)
+ r.setQueryOptions(q)
+ rtt, resp, err := requireOK(s.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var entries []*SessionEntry
+ if err := decodeBody(resp, &entries); err != nil {
+ return nil, nil, err
+ }
+
+ if len(entries) > 0 {
+ return entries[0], qm, nil
+ }
+ return nil, qm, nil
+}
+
+// List gets sessions for a node
+func (s *Session) Node(node string, q *QueryOptions) ([]*SessionEntry, *QueryMeta, error) {
+ r := s.c.newRequest("GET", "/v1/session/node/"+node)
+ r.setQueryOptions(q)
+ rtt, resp, err := requireOK(s.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var entries []*SessionEntry
+ if err := decodeBody(resp, &entries); err != nil {
+ return nil, nil, err
+ }
+ return entries, qm, nil
+}
+
+// List gets all active sessions
+func (s *Session) List(q *QueryOptions) ([]*SessionEntry, *QueryMeta, error) {
+ r := s.c.newRequest("GET", "/v1/session/list")
+ r.setQueryOptions(q)
+ rtt, resp, err := requireOK(s.c.doRequest(r))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer resp.Body.Close()
+
+ qm := &QueryMeta{}
+ parseQueryMeta(resp, qm)
+ qm.RequestTime = rtt
+
+ var entries []*SessionEntry
+ if err := decodeBody(resp, &entries); err != nil {
+ return nil, nil, err
+ }
+ return entries, qm, nil
+}
diff --git a/vendor/github.com/armon/consul-api/session_test.go b/vendor/github.com/armon/consul-api/session_test.go
new file mode 100644
index 00000000..9351c999
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/session_test.go
@@ -0,0 +1,190 @@
+package consulapi
+
+import (
+ "testing"
+)
+
+func TestSession_CreateDestroy(t *testing.T) {
+ c := makeClient(t)
+ session := c.Session()
+
+ id, meta, err := session.Create(nil, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if meta.RequestTime == 0 {
+ t.Fatalf("bad: %v", meta)
+ }
+
+ if id == "" {
+ t.Fatalf("invalid: %v", id)
+ }
+
+ meta, err = session.Destroy(id, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if meta.RequestTime == 0 {
+ t.Fatalf("bad: %v", meta)
+ }
+}
+
+func TestSession_CreateRenewDestroy(t *testing.T) {
+ c := makeClient(t)
+ session := c.Session()
+
+ se := &SessionEntry{
+ TTL: "10s",
+ }
+
+ id, meta, err := session.Create(se, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ defer session.Destroy(id, nil)
+
+ if meta.RequestTime == 0 {
+ t.Fatalf("bad: %v", meta)
+ }
+
+ if id == "" {
+ t.Fatalf("invalid: %v", id)
+ }
+
+ if meta.RequestTime == 0 {
+ t.Fatalf("bad: %v", meta)
+ }
+
+ renew, meta, err := session.Renew(id, nil)
+
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if meta.RequestTime == 0 {
+ t.Fatalf("bad: %v", meta)
+ }
+
+ if renew == nil {
+ t.Fatalf("should get session")
+ }
+
+ if renew.ID != id {
+ t.Fatalf("should have matching id")
+ }
+
+ if renew.TTL != "10s" {
+ t.Fatalf("should get session with TTL")
+ }
+}
+
+func TestSession_Info(t *testing.T) {
+ c := makeClient(t)
+ session := c.Session()
+
+ id, _, err := session.Create(nil, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ defer session.Destroy(id, nil)
+
+ info, qm, err := session.Info(id, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if qm.LastIndex == 0 {
+ t.Fatalf("bad: %v", qm)
+ }
+ if !qm.KnownLeader {
+ t.Fatalf("bad: %v", qm)
+ }
+
+ if info == nil {
+ t.Fatalf("should get session")
+ }
+ if info.CreateIndex == 0 {
+ t.Fatalf("bad: %v", info)
+ }
+ if info.ID != id {
+ t.Fatalf("bad: %v", info)
+ }
+ if info.Name != "" {
+ t.Fatalf("bad: %v", info)
+ }
+ if info.Node == "" {
+ t.Fatalf("bad: %v", info)
+ }
+ if len(info.Checks) == 0 {
+ t.Fatalf("bad: %v", info)
+ }
+ if info.LockDelay == 0 {
+ t.Fatalf("bad: %v", info)
+ }
+ if info.Behavior != "release" {
+ t.Fatalf("bad: %v", info)
+ }
+ if info.TTL != "" {
+ t.Fatalf("bad: %v", info)
+ }
+}
+
+func TestSession_Node(t *testing.T) {
+ c := makeClient(t)
+ session := c.Session()
+
+ id, _, err := session.Create(nil, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ defer session.Destroy(id, nil)
+
+ info, qm, err := session.Info(id, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ sessions, qm, err := session.Node(info.Node, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if len(sessions) != 1 {
+ t.Fatalf("bad: %v", sessions)
+ }
+
+ if qm.LastIndex == 0 {
+ t.Fatalf("bad: %v", qm)
+ }
+ if !qm.KnownLeader {
+ t.Fatalf("bad: %v", qm)
+ }
+}
+
+func TestSession_List(t *testing.T) {
+ c := makeClient(t)
+ session := c.Session()
+
+ id, _, err := session.Create(nil, nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ defer session.Destroy(id, nil)
+
+ sessions, qm, err := session.List(nil)
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+
+ if len(sessions) != 1 {
+ t.Fatalf("bad: %v", sessions)
+ }
+
+ if qm.LastIndex == 0 {
+ t.Fatalf("bad: %v", qm)
+ }
+ if !qm.KnownLeader {
+ t.Fatalf("bad: %v", qm)
+ }
+}
diff --git a/vendor/github.com/armon/consul-api/status.go b/vendor/github.com/armon/consul-api/status.go
new file mode 100644
index 00000000..21c31982
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/status.go
@@ -0,0 +1,43 @@
+package consulapi
+
+// Status can be used to query the Status endpoints
+type Status struct {
+ c *Client
+}
+
+// Status returns a handle to the status endpoints
+func (c *Client) Status() *Status {
+ return &Status{c}
+}
+
+// Leader is used to query for a known leader
+func (s *Status) Leader() (string, error) {
+ r := s.c.newRequest("GET", "/v1/status/leader")
+ _, resp, err := requireOK(s.c.doRequest(r))
+ if err != nil {
+ return "", err
+ }
+ defer resp.Body.Close()
+
+ var leader string
+ if err := decodeBody(resp, &leader); err != nil {
+ return "", err
+ }
+ return leader, nil
+}
+
+// Peers is used to query for a known raft peers
+func (s *Status) Peers() ([]string, error) {
+ r := s.c.newRequest("GET", "/v1/status/peers")
+ _, resp, err := requireOK(s.c.doRequest(r))
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ var peers []string
+ if err := decodeBody(resp, &peers); err != nil {
+ return nil, err
+ }
+ return peers, nil
+}
diff --git a/vendor/github.com/armon/consul-api/status_test.go b/vendor/github.com/armon/consul-api/status_test.go
new file mode 100644
index 00000000..ab9b42f5
--- /dev/null
+++ b/vendor/github.com/armon/consul-api/status_test.go
@@ -0,0 +1,31 @@
+package consulapi
+
+import (
+ "testing"
+)
+
+func TestStatusLeader(t *testing.T) {
+ c := makeClient(t)
+ status := c.Status()
+
+ leader, err := status.Leader()
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if leader == "" {
+ t.Fatalf("Expected leader")
+ }
+}
+
+func TestStatusPeers(t *testing.T) {
+ c := makeClient(t)
+ status := c.Status()
+
+ peers, err := status.Peers()
+ if err != nil {
+ t.Fatalf("err: %v", err)
+ }
+ if len(peers) == 0 {
+ t.Fatalf("Expected peers ")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/.dockerignore b/vendor/github.com/coreos/etcd/.dockerignore
new file mode 100644
index 00000000..6b8710a7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/.dockerignore
@@ -0,0 +1 @@
+.git
diff --git a/vendor/github.com/coreos/etcd/.github/ISSUE_TEMPLATE.md b/vendor/github.com/coreos/etcd/.github/ISSUE_TEMPLATE.md
new file mode 100644
index 00000000..c8c894c2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/.github/ISSUE_TEMPLATE.md
@@ -0,0 +1,7 @@
+# Bug reporting
+
+A good bug report has some very specific qualities, so please read over our short document on [reporting bugs][report_bugs] before submitting a bug report.
+
+To ask a question, go ahead and ignore this.
+
+[report_bugs]: https://github.com/coreos/etcd/blob/master/Documentation/reporting_bugs.md
diff --git a/vendor/github.com/coreos/etcd/.github/PULL_REQUEST_TEMPLATE.md b/vendor/github.com/coreos/etcd/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 00000000..4fa34e9b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,5 @@
+# Contributing guidelines
+
+Please read our [contribution workflow][contributing] before submitting a pull request.
+
+[contributing]: https://github.com/coreos/etcd/blob/master/CONTRIBUTING.md#contribution-flow
diff --git a/vendor/github.com/coreos/etcd/.gitignore b/vendor/github.com/coreos/etcd/.gitignore
new file mode 100644
index 00000000..210be6fe
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/.gitignore
@@ -0,0 +1,15 @@
+/coverage
+/gopath
+/gopath.proto
+/go-bindata
+/machine*
+/bin
+.vagrant
+*.etcd
+/etcd
+*.swp
+/hack/insta-discovery/.env
+*.test
+tools/functional-tester/docker/bin
+hack/tls-setup/certs
+.idea
diff --git a/vendor/github.com/coreos/etcd/.godir b/vendor/github.com/coreos/etcd/.godir
new file mode 100644
index 00000000..00ff6aa8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/.godir
@@ -0,0 +1 @@
+github.com/coreos/etcd
diff --git a/vendor/github.com/coreos/etcd/.header b/vendor/github.com/coreos/etcd/.header
new file mode 100644
index 00000000..0446af6d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/.header
@@ -0,0 +1,13 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
diff --git a/vendor/github.com/coreos/etcd/.travis.yml b/vendor/github.com/coreos/etcd/.travis.yml
new file mode 100644
index 00000000..fb8e9b83
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/.travis.yml
@@ -0,0 +1,83 @@
+dist: trusty
+language: go
+go_import_path: github.com/coreos/etcd
+sudo: false
+
+go:
+ - 1.8.3
+ - tip
+
+notifications:
+ on_success: never
+ on_failure: never
+
+env:
+ matrix:
+ - TARGET=amd64
+ - TARGET=darwin-amd64
+ - TARGET=windows-amd64
+ - TARGET=arm64
+ - TARGET=arm
+ - TARGET=386
+ - TARGET=ppc64le
+
+matrix:
+ fast_finish: true
+ allow_failures:
+ - go: tip
+ exclude:
+ - go: tip
+ env: TARGET=darwin-amd64
+ - go: tip
+ env: TARGET=windows-amd64
+ - go: tip
+ env: TARGET=arm
+ - go: tip
+ env: TARGET=arm64
+ - go: tip
+ env: TARGET=386
+ - go: tip
+ env: TARGET=ppc64le
+
+addons:
+ apt:
+ sources:
+ - debian-sid
+ packages:
+ - libpcap-dev
+ - libaspell-dev
+ - libhunspell-dev
+ - shellcheck
+
+before_install:
+ - go get -v -u github.com/chzchzchz/goword
+ - go get -v -u github.com/coreos/license-bill-of-materials
+ - go get -v -u honnef.co/go/tools/cmd/gosimple
+ - go get -v -u honnef.co/go/tools/cmd/unused
+ - go get -v -u honnef.co/go/tools/cmd/staticcheck
+ - ./scripts/install-marker.sh amd64
+
+# disable godep restore override
+install:
+ - pushd cmd/etcd && go get -t -v ./... && popd
+
+script:
+ - >
+ case "${TARGET}" in
+ amd64)
+ GOARCH=amd64 ./test
+ ;;
+ darwin-amd64)
+ GO_BUILD_FLAGS="-a -v" GOPATH="" GOOS=darwin GOARCH=amd64 ./build
+ ;;
+ windows-amd64)
+ GO_BUILD_FLAGS="-a -v" GOPATH="" GOOS=windows GOARCH=amd64 ./build
+ ;;
+ 386)
+ GOARCH=386 PASSES="build unit" ./test
+ ;;
+ *)
+ # test building out of gopath
+ GO_BUILD_FLAGS="-a -v" GOPATH="" GOARCH="${TARGET}" ./build
+ ;;
+ esac
diff --git a/vendor/github.com/coreos/etcd/CONTRIBUTING.md b/vendor/github.com/coreos/etcd/CONTRIBUTING.md
new file mode 100644
index 00000000..635f73a3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/CONTRIBUTING.md
@@ -0,0 +1,62 @@
+# How to contribute
+
+etcd is Apache 2.0 licensed and accepts contributions via GitHub pull requests. This document outlines some of the conventions on commit message formatting, contact points for developers, and other resources to help get contributions into etcd.
+
+# Email and chat
+
+- Email: [etcd-dev](https://groups.google.com/forum/?hl=en#!forum/etcd-dev)
+- IRC: #[coreos](irc://irc.freenode.org:6667/#coreos) IRC channel on freenode.org
+
+## Getting started
+
+- Fork the repository on GitHub
+- Read the README.md for build instructions
+
+## Reporting bugs and creating issues
+
+Reporting bugs is one of the best ways to contribute. However, a good bug report has some very specific qualities, so please read over our short document on [reporting bugs](https://github.com/coreos/etcd/blob/master/Documentation/reporting_bugs.md) before submitting a bug report. This document might contain links to known issues, another good reason to take a look there before reporting a bug.
+
+## Contribution flow
+
+This is a rough outline of what a contributor's workflow looks like:
+
+- Create a topic branch from where to base the contribution. This is usually master.
+- Make commits of logical units.
+- Make sure commit messages are in the proper format (see below).
+- Push changes in a topic branch to a personal fork of the repository.
+- Submit a pull request to coreos/etcd.
+- The PR must receive a LGTM from two maintainers found in the MAINTAINERS file.
+
+Thanks for contributing!
+
+### Code style
+
+The coding style suggested by the Golang community is used in etcd. See the [style doc](https://github.com/golang/go/wiki/CodeReviewComments) for details.
+
+Please follow this style to make etcd easy to review, maintain and develop.
+
+### Format of the commit message
+
+We follow a rough convention for commit messages that is designed to answer two
+questions: what changed and why. The subject line should feature the what and
+the body of the commit should describe the why.
+
+```
+scripts: add the test-cluster command
+
+this uses tmux to setup a test cluster that can easily be killed and started for debugging.
+
+Fixes #38
+```
+
+The format can be described more formally as follows:
+
+```
+<subsystem>: <what changed>
+<BLANK LINE>
+<why this change was made>
+<BLANK LINE>
+<footer>
+```
+
+The first line is the subject and should be no longer than 70 characters, the second line is always blank, and other lines should be wrapped at 80 characters. This allows the message to be easier to read on GitHub as well as in various git tools.
diff --git a/vendor/github.com/coreos/etcd/DCO b/vendor/github.com/coreos/etcd/DCO
new file mode 100644
index 00000000..716561d5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/DCO
@@ -0,0 +1,36 @@
+Developer Certificate of Origin
+Version 1.1
+
+Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
+660 York Street, Suite 102,
+San Francisco, CA 94110 USA
+
+Everyone is permitted to copy and distribute verbatim copies of this
+license document, but changing it is not allowed.
+
+
+Developer's Certificate of Origin 1.1
+
+By making a contribution to this project, I certify that:
+
+(a) The contribution was created in whole or in part by me and I
+ have the right to submit it under the open source license
+ indicated in the file; or
+
+(b) The contribution is based upon previous work that, to the best
+ of my knowledge, is covered under an appropriate open source
+ license and I have the right under that license to submit that
+ work with modifications, whether created in whole or in part
+ by me, under the same open source license (unless I am
+ permitted to submit under a different license), as indicated
+ in the file; or
+
+(c) The contribution was provided directly to me by some other
+ person who certified (a), (b) or (c) and I have not modified
+ it.
+
+(d) I understand and agree that this project and the contribution
+ are public and that a record of the contribution (including all
+ personal information I submit with it, including my sign-off) is
+ maintained indefinitely and may be redistributed consistent with
+ this project or the open source license(s) involved.
diff --git a/vendor/github.com/coreos/etcd/Dockerfile b/vendor/github.com/coreos/etcd/Dockerfile
new file mode 100644
index 00000000..c653734f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Dockerfile
@@ -0,0 +1,6 @@
+FROM golang
+ADD . /go/src/github.com/coreos/etcd
+ADD cmd/vendor /go/src/github.com/coreos/etcd/vendor
+RUN go install github.com/coreos/etcd
+EXPOSE 2379 2380
+ENTRYPOINT ["etcd"]
diff --git a/vendor/github.com/coreos/etcd/Dockerfile-release b/vendor/github.com/coreos/etcd/Dockerfile-release
new file mode 100644
index 00000000..736445fc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Dockerfile-release
@@ -0,0 +1,17 @@
+FROM alpine:latest
+
+ADD etcd /usr/local/bin/
+ADD etcdctl /usr/local/bin/
+RUN mkdir -p /var/etcd/
+RUN mkdir -p /var/lib/etcd/
+
+# Alpine Linux doesn't use pam, which means that there is no /etc/nsswitch.conf,
+# but Golang relies on /etc/nsswitch.conf to check the order of DNS resolving
+# (see https://github.com/golang/go/commit/9dee7771f561cf6aee081c0af6658cc81fac3918)
+# To fix this we just create /etc/nsswitch.conf and add the following line:
+RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
+
+EXPOSE 2379 2380
+
+# Define default command.
+CMD ["/usr/local/bin/etcd"]
diff --git a/vendor/github.com/coreos/etcd/Dockerfile-release.arm64 b/vendor/github.com/coreos/etcd/Dockerfile-release.arm64
new file mode 100644
index 00000000..d8816e58
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Dockerfile-release.arm64
@@ -0,0 +1,11 @@
+FROM aarch64/ubuntu:16.04
+
+ADD etcd /usr/local/bin/
+ADD etcdctl /usr/local/bin/
+ADD var/etcd /var/etcd
+ADD var/lib/etcd /var/lib/etcd
+
+EXPOSE 2379 2380
+
+# Define default command.
+CMD ["/usr/local/bin/etcd"]
diff --git a/vendor/github.com/coreos/etcd/Dockerfile-release.ppc64le b/vendor/github.com/coreos/etcd/Dockerfile-release.ppc64le
new file mode 100644
index 00000000..2fb02c41
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Dockerfile-release.ppc64le
@@ -0,0 +1,11 @@
+FROM ppc64le/ubuntu:16.04
+
+ADD etcd /usr/local/bin/
+ADD etcdctl /usr/local/bin/
+ADD var/etcd /var/etcd
+ADD var/lib/etcd /var/lib/etcd
+
+EXPOSE 2379 2380
+
+# Define default command.
+CMD ["/usr/local/bin/etcd"]
diff --git a/vendor/github.com/coreos/etcd/Documentation/README.md b/vendor/github.com/coreos/etcd/Documentation/README.md
new file mode 120000
index 00000000..8828313f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/README.md
@@ -0,0 +1 @@
+docs.md
\ No newline at end of file
diff --git a/vendor/github.com/coreos/etcd/Documentation/benchmarks/README.md b/vendor/github.com/coreos/etcd/Documentation/benchmarks/README.md
new file mode 100644
index 00000000..897112f3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/benchmarks/README.md
@@ -0,0 +1,18 @@
+# Benchmarks
+
+etcd benchmarks will be published regularly and tracked for each release below:
+
+- [etcd v2.1.0-alpha][2.1]
+- [etcd v2.2.0-rc][2.2]
+- [etcd v3 demo][3.0]
+
+# Memory Usage Benchmarks
+
+It records expected memory usage in different scenarios.
+
+- [etcd v2.2.0-rc][2.2-mem]
+
+[2.1]: etcd-2-1-0-alpha-benchmarks.md
+[2.2]: etcd-2-2-0-rc-benchmarks.md
+[2.2-mem]: etcd-2-2-0-rc-memory-benchmarks.md
+[3.0]: etcd-3-demo-benchmarks.md
diff --git a/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-2-1-0-alpha-benchmarks.md b/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-2-1-0-alpha-benchmarks.md
new file mode 100644
index 00000000..c1a19bdd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-2-1-0-alpha-benchmarks.md
@@ -0,0 +1,52 @@
+## Physical machines
+
+GCE n1-highcpu-2 machine type
+
+- 1x dedicated local SSD mounted under /var/lib/etcd
+- 1x dedicated slow disk for the OS
+- 1.8 GB memory
+- 2x CPUs
+- etcd version 2.1.0 alpha
+
+## etcd Cluster
+
+3 etcd members, each runs on a single machine
+
+## Testing
+
+Bootstrap another machine and use the [hey HTTP benchmark tool][hey] to send requests to each etcd member. Check the [benchmark hacking guide][hack-benchmark] for detailed instructions.
+
+## Performance
+
+### reading one single key
+
+| key size in bytes | number of clients | target etcd server | read QPS | 90th Percentile Latency (ms) |
+|-------------------|-------------------|--------------------|----------|---------------|
+| 64 | 1 | leader only | 1534 | 0.7 |
+| 64 | 64 | leader only | 10125 | 9.1 |
+| 64 | 256 | leader only | 13892 | 27.1 |
+| 256 | 1 | leader only | 1530 | 0.8 |
+| 256 | 64 | leader only | 10106 | 10.1 |
+| 256 | 256 | leader only | 14667 | 27.0 |
+| 64 | 64 | all servers | 24200 | 3.9 |
+| 64 | 256 | all servers | 33300 | 11.8 |
+| 256 | 64 | all servers | 24800 | 3.9 |
+| 256 | 256 | all servers | 33000 | 11.5 |
+
+### writing one single key
+
+| key size in bytes | number of clients | target etcd server | write QPS | 90th Percentile Latency (ms) |
+|-------------------|-------------------|--------------------|-----------|---------------|
+| 64 | 1 | leader only | 60 | 21.4 |
+| 64 | 64 | leader only | 1742 | 46.8 |
+| 64 | 256 | leader only | 3982 | 90.5 |
+| 256 | 1 | leader only | 58 | 20.3 |
+| 256 | 64 | leader only | 1770 | 47.8 |
+| 256 | 256 | leader only | 4157 | 105.3 |
+| 64 | 64 | all servers | 1028 | 123.4 |
+| 64 | 256 | all servers | 3260 | 123.8 |
+| 256 | 64 | all servers | 1033 | 121.5 |
+| 256 | 256 | all servers | 3061 | 119.3 |
+
+[hey]: https://github.com/rakyll/hey
+[hack-benchmark]: https://github.com/coreos/etcd/tree/master/hack/benchmark
diff --git a/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-2-2-0-benchmarks.md b/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-2-2-0-benchmarks.md
new file mode 100644
index 00000000..e9b0178d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-2-2-0-benchmarks.md
@@ -0,0 +1,69 @@
+# Benchmarking etcd v2.2.0
+
+## Physical Machines
+
+GCE n1-highcpu-2 machine type
+
+- 1x dedicated local SSD mounted as etcd data directory
+- 1x dedicated slow disk for the OS
+- 1.8 GB memory
+- 2x CPUs
+
+## etcd Cluster
+
+3 etcd 2.2.0 members, each runs on a single machine.
+
+Detailed versions:
+
+```
+etcd Version: 2.2.0
+Git SHA: e4561dd
+Go Version: go1.5
+Go OS/Arch: linux/amd64
+```
+
+## Testing
+
+Bootstrap another machine, outside of the etcd cluster, and run the [`hey` HTTP benchmark tool](https://github.com/rakyll/hey) with a connection reuse patch to send requests to each etcd cluster member. See the [benchmark instructions](../../hack/benchmark/) for the patch and the steps to reproduce our procedures.
+
+The performance is calulated through results of 100 benchmark rounds.
+
+## Performance
+
+### Single Key Read Performance
+
+| key size in bytes | number of clients | target etcd server | average read QPS | read QPS stddev | average 90th Percentile Latency (ms) | latency stddev |
+|-------------------|-------------------|--------------------|------------------|-----------------|--------------------------------------|----------------|
+| 64 | 1 | leader only | 2303 | 200 | 0.49 | 0.06 |
+| 64 | 64 | leader only | 15048 | 685 | 7.60 | 0.46 |
+| 64 | 256 | leader only | 14508 | 434 | 29.76 | 1.05 |
+| 256 | 1 | leader only | 2162 | 214 | 0.52 | 0.06 |
+| 256 | 64 | leader only | 14789 | 792 | 7.69| 0.48 |
+| 256 | 256 | leader only | 14424 | 512 | 29.92 | 1.42 |
+| 64 | 64 | all servers | 45752 | 2048 | 2.47 | 0.14 |
+| 64 | 256 | all servers | 46592 | 1273 | 10.14 | 0.59 |
+| 256 | 64 | all servers | 45332 | 1847 | 2.48| 0.12 |
+| 256 | 256 | all servers | 46485 | 1340 | 10.18 | 0.74 |
+
+### Single Key Write Performance
+
+| key size in bytes | number of clients | target etcd server | average write QPS | write QPS stddev | average 90th Percentile Latency (ms) | latency stddev |
+|-------------------|-------------------|--------------------|------------------|-----------------|--------------------------------------|----------------|
+| 64 | 1 | leader only | 55 | 4 | 24.51 | 13.26 |
+| 64 | 64 | leader only | 2139 | 125 | 35.23 | 3.40 |
+| 64 | 256 | leader only | 4581 | 581 | 70.53 | 10.22 |
+| 256 | 1 | leader only | 56 | 4 | 22.37| 4.33 |
+| 256 | 64 | leader only | 2052 | 151 | 36.83 | 4.20 |
+| 256 | 256 | leader only | 4442 | 560 | 71.59 | 10.03 |
+| 64 | 64 | all servers | 1625 | 85 | 58.51 | 5.14 |
+| 64 | 256 | all servers | 4461 | 298 | 89.47 | 36.48 |
+| 256 | 64 | all servers | 1599 | 94 | 60.11| 6.43 |
+| 256 | 256 | all servers | 4315 | 193 | 88.98 | 7.01 |
+
+## Performance Changes
+
+- Because etcd now records metrics for each API call, read QPS performance seems to see a minor decrease in most scenarios. This minimal performance impact was judged a reasonable investment for the breadth of monitoring and debugging information returned.
+
+- Write QPS to cluster leaders seems to be increased by a small margin. This is because the main loop and entry apply loops were decoupled in the etcd raft logic, eliminating several blocks between them.
+
+- Write QPS to all members seems to be increased by a significant margin, because followers now receive the latest commit index sooner, and commit proposals more quickly.
diff --git a/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-2-2-0-rc-benchmarks.md b/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-2-2-0-rc-benchmarks.md
new file mode 100644
index 00000000..ca18f6eb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-2-2-0-rc-benchmarks.md
@@ -0,0 +1,72 @@
+## Physical machines
+
+GCE n1-highcpu-2 machine type
+
+- 1x dedicated local SSD mounted under /var/lib/etcd
+- 1x dedicated slow disk for the OS
+- 1.8 GB memory
+- 2x CPUs
+
+## etcd Cluster
+
+3 etcd 2.2.0-rc members, each runs on a single machine.
+
+Detailed versions:
+
+```
+etcd Version: 2.2.0-alpha.1+git
+Git SHA: 59a5a7e
+Go Version: go1.4.2
+Go OS/Arch: linux/amd64
+```
+
+Also, we use 3 etcd 2.1.0 alpha-stage members to form cluster to get base performance. etcd's commit head is at [c7146bd5][c7146bd5], which is the same as the one that we use in [etcd 2.1 benchmark][etcd-2.1-benchmark].
+
+## Testing
+
+Bootstrap another machine and use the [hey HTTP benchmark tool][hey] to send requests to each etcd member. Check the [benchmark hacking guide][hack-benchmark] for detailed instructions.
+
+## Performance
+
+### reading one single key
+
+| key size in bytes | number of clients | target etcd server | read QPS | 90th Percentile Latency (ms) |
+|-------------------|-------------------|--------------------|----------|---------------|
+| 64 | 1 | leader only | 2804 (-5%) | 0.4 (+0%) |
+| 64 | 64 | leader only | 17816 (+0%) | 5.7 (-6%) |
+| 64 | 256 | leader only | 18667 (-6%) | 20.4 (+2%) |
+| 256 | 1 | leader only | 2181 (-15%) | 0.5 (+25%) |
+| 256 | 64 | leader only | 17435 (-7%) | 6.0 (+9%) |
+| 256 | 256 | leader only | 18180 (-8%) | 21.3 (+3%) |
+| 64 | 64 | all servers | 46965 (-4%) | 2.1 (+0%) |
+| 64 | 256 | all servers | 55286 (-6%) | 7.4 (+6%) |
+| 256 | 64 | all servers | 46603 (-6%) | 2.1 (+5%) |
+| 256 | 256 | all servers | 55291 (-6%) | 7.3 (+4%) |
+
+### writing one single key
+
+| key size in bytes | number of clients | target etcd server | write QPS | 90th Percentile Latency (ms) |
+|-------------------|-------------------|--------------------|-----------|---------------|
+| 64 | 1 | leader only | 76 (+22%) | 19.4 (-15%) |
+| 64 | 64 | leader only | 2461 (+45%) | 31.8 (-32%) |
+| 64 | 256 | leader only | 4275 (+1%) | 69.6 (-10%) |
+| 256 | 1 | leader only | 64 (+20%) | 16.7 (-30%) |
+| 256 | 64 | leader only | 2385 (+30%) | 31.5 (-19%) |
+| 256 | 256 | leader only | 4353 (-3%) | 74.0 (+9%) |
+| 64 | 64 | all servers | 2005 (+81%) | 49.8 (-55%) |
+| 64 | 256 | all servers | 4868 (+35%) | 81.5 (-40%) |
+| 256 | 64 | all servers | 1925 (+72%) | 47.7 (-59%) |
+| 256 | 256 | all servers | 4975 (+36%) | 70.3 (-36%) |
+
+### performance changes explanation
+
+- read QPS in most scenarios is decreased by 5~8%. The reason is that etcd records store metrics for each store operation. The metrics is important for monitoring and debugging, so this is acceptable.
+
+- write QPS to leader is increased by 20~30%. This is because we decouple raft main loop and entry apply loop, which avoids them blocking each other.
+
+- write QPS to all servers is increased by 30~80% because follower could receive latest commit index earlier and commit proposals faster.
+
+[hey]: https://github.com/rakyll/hey
+[c7146bd5]: https://github.com/coreos/etcd/commits/c7146bd5f2c73716091262edc638401bb8229144
+[etcd-2.1-benchmark]: etcd-2-1-0-alpha-benchmarks.md
+[hack-benchmark]: ../../hack/benchmark/
diff --git a/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-2-2-0-rc-memory-benchmarks.md b/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-2-2-0-rc-memory-benchmarks.md
new file mode 100644
index 00000000..ef9ed6f3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-2-2-0-rc-memory-benchmarks.md
@@ -0,0 +1,47 @@
+## Physical machine
+
+GCE n1-standard-2 machine type
+
+- 1x dedicated local SSD mounted under /var/lib/etcd
+- 1x dedicated slow disk for the OS
+- 7.5 GB memory
+- 2x CPUs
+
+## etcd
+
+```
+etcd Version: 2.2.0-rc.0+git
+Git SHA: 103cb5c
+Go Version: go1.5
+Go OS/Arch: linux/amd64
+```
+
+## Testing
+
+Start 3-member etcd cluster, each of which uses 2 cores.
+
+The length of key name is always 64 bytes, which is a reasonable length of average key bytes.
+
+## Memory Maximal Usage
+
+- etcd may use maximal memory if one follower is dead and the leader keeps sending snapshots.
+- `max RSS` is the maximal memory usage recorded in 3 runs.
+
+| value bytes | key number | data size(MB) | max RSS(MB) | max RSS/data rate on leader |
+|-------------|-------------|---------------|-------------|-----------------------------|
+| 128 | 50000 | 6 | 433 | 72x |
+| 128 | 100000 | 12 | 659 | 54x |
+| 128 | 200000 | 24 | 1466 | 61x |
+| 1024 | 50000 | 48 | 1253 | 26x |
+| 1024 | 100000 | 96 | 2344 | 24x |
+| 1024 | 200000 | 192 | 4361 | 22x |
+
+## Data Size Threshold
+
+- When etcd reaches data size threshold, it may trigger leader election easily and drop part of proposals.
+- For most cases, the etcd cluster should work smoothly if it doesn't hit the threshold. If it doesn't work well due to insufficient resources, decrease its data size.
+
+| value bytes | key number limitation | suggested data size threshold(MB) | consumed RSS(MB) |
+|-------------|-----------------------|-----------------------------------|------------------|
+| 128 | 400K | 48 | 2400 |
+| 1024 | 300K | 292 | 6500 |
diff --git a/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-3-demo-benchmarks.md b/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-3-demo-benchmarks.md
new file mode 100644
index 00000000..ae78f917
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-3-demo-benchmarks.md
@@ -0,0 +1,42 @@
+## Physical machines
+
+GCE n1-highcpu-2 machine type
+
+- 1x dedicated local SSD mounted under /var/lib/etcd
+- 1x dedicated slow disk for the OS
+- 1.8 GB memory
+- 2x CPUs
+- etcd version 2.2.0
+
+## etcd Cluster
+
+1 etcd member running in v3 demo mode
+
+## Testing
+
+Use [etcd v3 benchmark tool][etcd-v3-benchmark].
+
+## Performance
+
+### reading one single key
+
+| key size in bytes | number of clients | read QPS | 90th Percentile Latency (ms) |
+|-------------------|-------------------|----------|---------------|
+| 256 | 1 | 2716 | 0.4 |
+| 256 | 64 | 16623 | 6.1 |
+| 256 | 256 | 16622 | 21.7 |
+
+The performance is nearly the same as the one with empty server handler.
+
+### reading one single key after putting
+
+| key size in bytes | number of clients | read QPS | 90th Percentile Latency (ms) |
+|-------------------|-------------------|----------|---------------|
+| 256 | 1 | 2269 | 0.5 |
+| 256 | 64 | 13582 | 8.6 |
+| 256 | 256 | 13262 | 47.5 |
+
+The performance with empty server handler is not affected by one put. So the
+performance downgrade should be caused by storage package.
+
+[etcd-v3-benchmark]: ../../tools/benchmark/
diff --git a/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-3-watch-memory-benchmark.md b/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-3-watch-memory-benchmark.md
new file mode 100644
index 00000000..c02a8d62
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-3-watch-memory-benchmark.md
@@ -0,0 +1,77 @@
+# Watch Memory Usage Benchmark
+
+*NOTE*: The watch features are under active development, and their memory usage may change as that development progresses. We do not expect it to significantly increase beyond the figures stated below.
+
+A primary goal of etcd is supporting a very large number of watchers doing a massively large amount of watching. etcd aims to support O(10k) clients, O(100K) watch streams (O(10) streams per client) and O(10M) total watchings (O(100) watching per stream). The memory consumed by each individual watching accounts for the largest portion of etcd's overall usage, and is therefore the focus of current and future optimizations.
+
+
+Three related components of etcd watch consume physical memory: each `grpc.Conn`, each watch stream, and each instance of the watching activity. `grpc.Conn` maintains the actual TCP connection and other gRPC connection state. Each `grpc.Conn` consumes O(10kb) of memory, and might have multiple watch streams attached.
+
+Each watch stream is an independent HTTP2 connection which consumes another O(10kb) of memory.
+Multiple watchings might share one watch stream.
+
+Watching is the actual struct that tracks the changes on the key-value store. Each watching should only consume < O(1kb).
+
+```
+ +-------+
+ | watch |
+ +---------> | foo |
+ | +-------+
+ +------+-----+
+ | stream |
+ +--------------> | |
+ | +------+-----+ +-------+
+ | | | watch |
+ | +---------> | bar |
++-----+------+ +-------+
+| | +------------+
+| conn +-------> | stream |
+| | | |
++-----+------+ +------------+
+ |
+ |
+ |
+ | +------------+
+ +--------------> | stream |
+ | |
+ +------------+
+```
+
+The theoretical memory consumption of watch can be approximated with the formula:
+`memory = c1 * number_of_conn + c2 * avg_number_of_stream_per_conn + c3 * avg_number_of_watch_stream`
+
+## Testing Environment
+
+etcd version
+- git head https://github.com/coreos/etcd/commit/185097ffaa627b909007e772c175e8fefac17af3
+
+GCE n1-standard-2 machine type
+- 7.5 GB memory
+- 2x CPUs
+
+## Overall memory usage
+
+The overall memory usage captures how much [RSS][rss] etcd consumes with the client watchers. While the result may vary by as much as 10%, it is still meaningful, since the goal is to learn about the rough memory usage and the pattern of allocations.
+
+With the benchmark result, we can calculate roughly that `c1 = 17kb`, `c2 = 18kb` and `c3 = 350bytes`. So each additional client connection consumes 17kb of memory and each additional stream consumes 18kb of memory, and each additional watching only cause 350bytes. A single etcd server can maintain millions of watchings with a few GB of memory in normal case.
+
+
+| clients | streams per client | watchings per stream | total watching | memory usage |
+|---------|---------|-----------|----------------|--------------|
+| 1k | 1 | 1 | 1k | 50MB |
+| 2k | 1 | 1 | 2k | 90MB |
+| 5k | 1 | 1 | 5k | 200MB |
+| 1k | 10 | 1 | 10k | 217MB |
+| 2k | 10 | 1 | 20k | 417MB |
+| 5k | 10 | 1 | 50k | 980MB |
+| 1k | 50 | 1 | 50k | 1001MB |
+| 2k | 50 | 1 | 100k | 1960MB |
+| 5k | 50 | 1 | 250k | 4700MB |
+| 1k | 50 | 10 | 500k | 1171MB |
+| 2k | 50 | 10 | 1M | 2371MB |
+| 5k | 50 | 10 | 2.5M | 5710MB |
+| 1k | 50 | 100 | 5M | 2380MB |
+| 2k | 50 | 100 | 10M | 4672MB |
+| 5k | 50 | 100 | 25M | *OOM* |
+
+[rss]: https://en.wikipedia.org/wiki/Resident_set_size
diff --git a/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-storage-memory-benchmark.md b/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-storage-memory-benchmark.md
new file mode 100644
index 00000000..3834a192
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/benchmarks/etcd-storage-memory-benchmark.md
@@ -0,0 +1,98 @@
+# Storage Memory Usage Benchmark
+
+<!---todo: link storage to storage design doc-->
+Two components of etcd storage consume physical memory. The etcd process allocates an *in-memory index* to speed key lookup. The process's *page cache*, managed by the operating system, stores recently-accessed data from disk for quick re-use.
+
+The in-memory index holds all the keys in a [B-tree][btree] data structure, along with pointers to the on-disk data (the values). Each key in the B-tree may contain multiple pointers, pointing to different versions of its values. The theoretical memory consumption of the in-memory index can hence be approximated with the formula:
+
+`N * (c1 + avg_key_size) + N * (avg_versions_of_key) * (c2 + size_of_pointer)`
+
+where `c1` is the key metadata overhead and `c2` is the version metadata overhead.
+
+The graph shows the detailed structure of the in-memory index B-tree.
+
+```
+
+
+ In mem index
+
+ +------------+
+ | key || ... |
+ +--------------+ | || |
+ | | +------------+
+ | | | v1 || ... |
+ | disk <----------------| || | Tree Node
+ | | +------------+
+ | | | v2 || ... |
+ | <----------------+ || |
+ | | +------------+
+ +--------------+ +-----+ | | |
+ | | | | |
+ | +------------+
+ |
+ |
+ ^
+ ------+
+ | ... |
+ | |
+ +-----+
+ | ... | Tree Node
+ | |
+ +-----+
+ | ... |
+ | |
+ ------+
+```
+
+[Page cache memory][pagecache] is managed by the operating system and is not covered in detail in this document.
+
+## Testing Environment
+
+etcd version
+- git head https://github.com/coreos/etcd/commit/776e9fb7be7eee5e6b58ab977c8887b4fe4d48db
+
+GCE n1-standard-2 machine type
+
+- 7.5 GB memory
+- 2x CPUs
+
+## In-memory index memory usage
+
+In this test, we only benchmark the memory usage of the in-memory index. The goal is to find `c1` and `c2` mentioned above and to understand the hard limit of memory consumption of the storage.
+
+We calculate the memory usage consumption via the Go runtime.ReadMemStats. We calculate the total allocated bytes difference before creating the index and after creating the index. It cannot perfectly reflect the memory usage of the in-memory index itself but can show the rough consumption pattern.
+
+| N | versions | key size | memory usage |
+|------|----------|----------|--------------|
+| 100K | 1 | 64bytes | 22MB |
+| 100K | 5 | 64bytes | 39MB |
+| 1M | 1 | 64bytes | 218MB |
+| 1M | 5 | 64bytes | 432MB |
+| 100K | 1 | 256bytes | 41MB |
+| 100K | 5 | 256bytes | 65MB |
+| 1M | 1 | 256bytes | 409MB |
+| 1M | 5 | 256bytes | 506MB |
+
+
+Based on the result, we can calculate `c1=120bytes`, `c2=30bytes`. We only need two sets of data to calculate `c1` and `c2`, since they are the only unknown variable in the formula. The `c1=120bytes` and `c2=30bytes` are the average value of the 4 sets of `c1` and `c2` we calculated. The key metadata overhead is still relatively nontrivial (50%) for small key-value pairs. However, this is a significant improvement over the old store, which had at least 1000% overhead.
+
+## Overall memory usage
+
+The overall memory usage captures how much RSS etcd consumes with the storage. The value size should have very little impact on the overall memory usage of etcd, since we keep values on disk and only retain hot values in memory, managed by the OS page cache.
+
+| N | versions | key size | value size | memory usage |
+|------|----------|----------|------------|--------------|
+| 100K | 1 | 64bytes | 256bytes | 40MB |
+| 100K | 5 | 64bytes | 256bytes | 89MB |
+| 1M | 1 | 64bytes | 256bytes | 470MB |
+| 1M | 5 | 64bytes | 256bytes | 880MB |
+| 100K | 1 | 64bytes | 1KB | 102MB |
+| 100K | 5 | 64bytes | 1KB | 164MB |
+| 1M | 1 | 64bytes | 1KB | 587MB |
+| 1M | 5 | 64bytes | 1KB | 836MB |
+
+Based on the result, we know the value size does not significantly impact the memory consumption. There is some minor increase due to more data held in the OS page cache.
+
+[btree]: https://en.wikipedia.org/wiki/B-tree
+[pagecache]: https://en.wikipedia.org/wiki/Page_cache
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/branch_management.md b/vendor/github.com/coreos/etcd/Documentation/branch_management.md
new file mode 100644
index 00000000..c209d4d6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/branch_management.md
@@ -0,0 +1,26 @@
+# Branch management
+
+## Guide
+
+* New development occurs on the [master branch][master].
+* Master branch should always have a green build!
+* Backwards-compatible bug fixes should target the master branch and subsequently be ported to stable branches.
+* Once the master branch is ready for release, it will be tagged and become the new stable branch.
+
+The etcd team has adopted a *rolling release model* and supports one stable version of etcd.
+
+### Master branch
+
+The `master` branch is our development branch. All new features land here first.
+
+To try new and experimental features, pull `master` and play with it. Note that `master` may not be stable because new features may introduce bugs.
+
+Before the release of the next stable version, feature PRs will be frozen. We will focus on the testing, bug-fix and documentation for one to two weeks.
+
+### Stable branches
+
+All branches with prefix `release-` are considered _stable_ branches.
+
+After every minor release (http://semver.org/), we will have a new stable branch for that release. We will keep fixing the backwards-compatible bugs for the latest stable release, but not previous releases. The _patch_ release, incorporating any bug fixes, will be once every two weeks, given any patches.
+
+[master]: https://github.com/coreos/etcd/tree/master
diff --git a/vendor/github.com/coreos/etcd/Documentation/demo.md b/vendor/github.com/coreos/etcd/Documentation/demo.md
new file mode 100644
index 00000000..8d86f7a9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/demo.md
@@ -0,0 +1,454 @@
+# Demo
+
+This series of examples shows the basic procedures for working with an etcd cluster.
+
+## Set up a cluster
+
+<img src="https://storage.googleapis.com/etcd/demo/01_etcd_clustering_2016051001.gif" alt="01_etcd_clustering_2016050601"/>
+
+On each etcd node, specify the cluster members:
+
+```
+TOKEN=token-01
+CLUSTER_STATE=new
+NAME_1=machine-1
+NAME_2=machine-2
+NAME_3=machine-3
+HOST_1=10.240.0.17
+HOST_2=10.240.0.18
+HOST_3=10.240.0.19
+CLUSTER=${NAME_1}=http://${HOST_1}:2380,${NAME_2}=http://${HOST_2}:2380,${NAME_3}=http://${HOST_3}:2380
+```
+
+Run this on each machine:
+
+```
+# For machine 1
+THIS_NAME=${NAME_1}
+THIS_IP=${HOST_1}
+etcd --data-dir=data.etcd --name ${THIS_NAME} \
+ --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
+ --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
+ --initial-cluster ${CLUSTER} \
+ --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
+
+# For machine 2
+THIS_NAME=${NAME_2}
+THIS_IP=${HOST_2}
+etcd --data-dir=data.etcd --name ${THIS_NAME} \
+ --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
+ --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
+ --initial-cluster ${CLUSTER} \
+ --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
+
+# For machine 3
+THIS_NAME=${NAME_3}
+THIS_IP=${HOST_3}
+etcd --data-dir=data.etcd --name ${THIS_NAME} \
+ --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
+ --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
+ --initial-cluster ${CLUSTER} \
+ --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
+```
+
+Or use our public discovery service:
+
+```
+curl https://discovery.etcd.io/new?size=3
+https://discovery.etcd.io/a81b5818e67a6ea83e9d4daea5ecbc92
+
+# grab this token
+TOKEN=token-01
+CLUSTER_STATE=new
+NAME_1=machine-1
+NAME_2=machine-2
+NAME_3=machine-3
+HOST_1=10.240.0.17
+HOST_2=10.240.0.18
+HOST_3=10.240.0.19
+DISCOVERY=https://discovery.etcd.io/a81b5818e67a6ea83e9d4daea5ecbc92
+
+THIS_NAME=${NAME_1}
+THIS_IP=${HOST_1}
+etcd --data-dir=data.etcd --name ${THIS_NAME} \
+ --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
+ --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
+ --discovery ${DISCOVERY} \
+ --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
+
+THIS_NAME=${NAME_2}
+THIS_IP=${HOST_2}
+etcd --data-dir=data.etcd --name ${THIS_NAME} \
+ --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
+ --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
+ --discovery ${DISCOVERY} \
+ --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
+
+THIS_NAME=${NAME_3}
+THIS_IP=${HOST_3}
+etcd --data-dir=data.etcd --name ${THIS_NAME} \
+ --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
+ --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
+ --discovery ${DISCOVERY} \
+ --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
+```
+
+Now etcd is ready! To connect to etcd with etcdctl:
+
+```
+export ETCDCTL_API=3
+HOST_1=10.240.0.17
+HOST_2=10.240.0.18
+HOST_3=10.240.0.19
+ENDPOINTS=$HOST_1:2379,$HOST_2:2379,$HOST_3:2379
+
+etcdctl --endpoints=$ENDPOINTS member list
+```
+
+
+## Access etcd
+
+<img src="https://storage.googleapis.com/etcd/demo/02_etcdctl_access_etcd_2016051001.gif" alt="02_etcdctl_access_etcd_2016051001"/>
+
+`put` command to write:
+
+```
+etcdctl --endpoints=$ENDPOINTS put foo "Hello World!"
+```
+
+`get` to read from etcd:
+
+```
+etcdctl --endpoints=$ENDPOINTS get foo
+etcdctl --endpoints=$ENDPOINTS --write-out="json" get foo
+```
+
+
+## Get by prefix
+
+<img src="https://storage.googleapis.com/etcd/demo/03_etcdctl_get_by_prefix_2016050501.gif" alt="03_etcdctl_get_by_prefix_2016050501"/>
+
+```
+etcdctl --endpoints=$ENDPOINTS put web1 value1
+etcdctl --endpoints=$ENDPOINTS put web2 value2
+etcdctl --endpoints=$ENDPOINTS put web3 value3
+
+etcdctl --endpoints=$ENDPOINTS get web --prefix
+```
+
+
+## Delete
+
+<img src="https://storage.googleapis.com/etcd/demo/04_etcdctl_delete_2016050601.gif" alt="04_etcdctl_delete_2016050601"/>
+
+```
+etcdctl --endpoints=$ENDPOINTS put key myvalue
+etcdctl --endpoints=$ENDPOINTS del key
+
+etcdctl --endpoints=$ENDPOINTS put k1 value1
+etcdctl --endpoints=$ENDPOINTS put k2 value2
+etcdctl --endpoints=$ENDPOINTS del k --prefix
+```
+
+
+## Transactional write
+
+`txn` to wrap multiple requests into one transaction:
+
+<img src="https://storage.googleapis.com/etcd/demo/05_etcdctl_transaction_2016050501.gif" alt="05_etcdctl_transaction_2016050501"/>
+
+```
+etcdctl --endpoints=$ENDPOINTS put user1 bad
+etcdctl --endpoints=$ENDPOINTS txn --interactive
+
+compares:
+value("user1") = "bad"
+
+success requests (get, put, delete):
+del user1
+
+failure requests (get, put, delete):
+put user1 good
+```
+
+
+## Watch
+
+`watch` to get notified of future changes:
+
+<img src="https://storage.googleapis.com/etcd/demo/06_etcdctl_watch_2016050501.gif" alt="06_etcdctl_watch_2016050501"/>
+
+```
+etcdctl --endpoints=$ENDPOINTS watch stock1
+etcdctl --endpoints=$ENDPOINTS put stock1 1000
+
+etcdctl --endpoints=$ENDPOINTS watch stock --prefix
+etcdctl --endpoints=$ENDPOINTS put stock1 10
+etcdctl --endpoints=$ENDPOINTS put stock2 20
+```
+
+
+## Lease
+
+`lease` to write with TTL:
+
+<img src="https://storage.googleapis.com/etcd/demo/07_etcdctl_lease_2016050501.gif" alt="07_etcdctl_lease_2016050501"/>
+
+```
+etcdctl --endpoints=$ENDPOINTS lease grant 300
+# lease 2be7547fbc6a5afa granted with TTL(300s)
+
+etcdctl --endpoints=$ENDPOINTS put sample value --lease=2be7547fbc6a5afa
+etcdctl --endpoints=$ENDPOINTS get sample
+
+etcdctl --endpoints=$ENDPOINTS lease keep-alive 2be7547fbc6a5afa
+etcdctl --endpoints=$ENDPOINTS lease revoke 2be7547fbc6a5afa
+# or after 300 seconds
+etcdctl --endpoints=$ENDPOINTS get sample
+```
+
+
+## Distributed locks
+
+`lock` for distributed lock:
+
+<img src="https://storage.googleapis.com/etcd/demo/08_etcdctl_lock_2016050501.gif" alt="08_etcdctl_lock_2016050501"/>
+
+```
+etcdctl --endpoints=$ENDPOINTS lock mutex1
+
+# another client with the same name blocks
+etcdctl --endpoints=$ENDPOINTS lock mutex1
+```
+
+
+## Elections
+
+`elect` for leader election:
+
+<img src="https://storage.googleapis.com/etcd/demo/09_etcdctl_elect_2016050501.gif" alt="09_etcdctl_elect_2016050501"/>
+
+```
+etcdctl --endpoints=$ENDPOINTS elect one p1
+
+# another client with the same name blocks
+etcdctl --endpoints=$ENDPOINTS elect one p2
+```
+
+
+## Cluster status
+
+Specify the initial cluster configuration for each machine:
+
+<img src="https://storage.googleapis.com/etcd/demo/10_etcdctl_endpoint_2016050501.gif" alt="10_etcdctl_endpoint_2016050501"/>
+
+```
+etcdctl --write-out=table --endpoints=$ENDPOINTS endpoint status
+
++------------------+------------------+---------+---------+-----------+-----------+------------+
+| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | RAFT TERM | RAFT INDEX |
++------------------+------------------+---------+---------+-----------+-----------+------------+
+| 10.240.0.17:2379 | 4917a7ab173fabe7 | 3.0.0 | 45 kB | true | 4 | 16726 |
+| 10.240.0.18:2379 | 59796ba9cd1bcd72 | 3.0.0 | 45 kB | false | 4 | 16726 |
+| 10.240.0.19:2379 | 94df724b66343e6c | 3.0.0 | 45 kB | false | 4 | 16726 |
++------------------+------------------+---------+---------+-----------+-----------+------------+
+```
+
+```
+etcdctl --endpoints=$ENDPOINTS endpoint health
+
+10.240.0.17:2379 is healthy: successfully committed proposal: took = 3.345431ms
+10.240.0.19:2379 is healthy: successfully committed proposal: took = 3.767967ms
+10.240.0.18:2379 is healthy: successfully committed proposal: took = 4.025451ms
+```
+
+
+## Snapshot
+
+`snapshot` to save point-in-time snapshot of etcd database:
+
+<img src="https://storage.googleapis.com/etcd/demo/11_etcdctl_snapshot_2016051001.gif" alt="11_etcdctl_snapshot_2016051001"/>
+
+```
+etcdctl --endpoints=$ENDPOINTS snapshot save my.db
+
+Snapshot saved at my.db
+```
+
+```
+etcdctl --write-out=table --endpoints=$ENDPOINTS snapshot status my.db
+
++---------+----------+------------+------------+
+| HASH | REVISION | TOTAL KEYS | TOTAL SIZE |
++---------+----------+------------+------------+
+| c55e8b8 | 9 | 13 | 25 kB |
++---------+----------+------------+------------+
+```
+
+
+## Migrate
+
+`migrate` to transform etcd v2 to v3 data:
+
+<img src="https://storage.googleapis.com/etcd/demo/12_etcdctl_migrate_2016061602.gif" alt="12_etcdctl_migrate_2016061602"/>
+
+```
+# write key in etcd version 2 store
+export ETCDCTL_API=2
+etcdctl --endpoints=http://$ENDPOINT set foo bar
+
+# read key in etcd v2
+etcdctl --endpoints=$ENDPOINTS --output="json" get foo
+
+# stop etcd node to migrate, one by one
+
+# migrate v2 data
+export ETCDCTL_API=3
+etcdctl --endpoints=$ENDPOINT migrate --data-dir="default.etcd" --wal-dir="default.etcd/member/wal"
+
+# restart etcd node after migrate, one by one
+
+# confirm that the key got migrated
+etcdctl --endpoints=$ENDPOINTS get /foo
+```
+
+
+## Member
+
+`member` to add,remove,update membership:
+
+<img src="https://storage.googleapis.com/etcd/demo/13_etcdctl_member_2016062301.gif" alt="13_etcdctl_member_2016062301"/>
+
+```
+# For each machine
+TOKEN=my-etcd-token-1
+CLUSTER_STATE=new
+NAME_1=etcd-node-1
+NAME_2=etcd-node-2
+NAME_3=etcd-node-3
+HOST_1=10.240.0.13
+HOST_2=10.240.0.14
+HOST_3=10.240.0.15
+CLUSTER=${NAME_1}=http://${HOST_1}:2380,${NAME_2}=http://${HOST_2}:2380,${NAME_3}=http://${HOST_3}:2380
+
+# For node 1
+THIS_NAME=${NAME_1}
+THIS_IP=${HOST_1}
+etcd --data-dir=data.etcd --name ${THIS_NAME} \
+ --initial-advertise-peer-urls http://${THIS_IP}:2380 \
+ --listen-peer-urls http://${THIS_IP}:2380 \
+ --advertise-client-urls http://${THIS_IP}:2379 \
+ --listen-client-urls http://${THIS_IP}:2379 \
+ --initial-cluster ${CLUSTER} \
+ --initial-cluster-state ${CLUSTER_STATE} \
+ --initial-cluster-token ${TOKEN}
+
+# For node 2
+THIS_NAME=${NAME_2}
+THIS_IP=${HOST_2}
+etcd --data-dir=data.etcd --name ${THIS_NAME} \
+ --initial-advertise-peer-urls http://${THIS_IP}:2380 \
+ --listen-peer-urls http://${THIS_IP}:2380 \
+ --advertise-client-urls http://${THIS_IP}:2379 \
+ --listen-client-urls http://${THIS_IP}:2379 \
+ --initial-cluster ${CLUSTER} \
+ --initial-cluster-state ${CLUSTER_STATE} \
+ --initial-cluster-token ${TOKEN}
+
+# For node 3
+THIS_NAME=${NAME_3}
+THIS_IP=${HOST_3}
+etcd --data-dir=data.etcd --name ${THIS_NAME} \
+ --initial-advertise-peer-urls http://${THIS_IP}:2380 \
+ --listen-peer-urls http://${THIS_IP}:2380 \
+ --advertise-client-urls http://${THIS_IP}:2379 \
+ --listen-client-urls http://${THIS_IP}:2379 \
+ --initial-cluster ${CLUSTER} \
+ --initial-cluster-state ${CLUSTER_STATE} \
+ --initial-cluster-token ${TOKEN}
+```
+
+Then replace a member with `member remove` and `member add` commands:
+
+```
+# get member ID
+export ETCDCTL_API=3
+HOST_1=10.240.0.13
+HOST_2=10.240.0.14
+HOST_3=10.240.0.15
+etcdctl --endpoints=${HOST_1}:2379,${HOST_2}:2379,${HOST_3}:2379 member list
+
+# remove the member
+MEMBER_ID=278c654c9a6dfd3b
+etcdctl --endpoints=${HOST_1}:2379,${HOST_2}:2379,${HOST_3}:2379 \
+ member remove ${MEMBER_ID}
+
+# add a new member (node 4)
+export ETCDCTL_API=3
+NAME_1=etcd-node-1
+NAME_2=etcd-node-2
+NAME_4=etcd-node-4
+HOST_1=10.240.0.13
+HOST_2=10.240.0.14
+HOST_4=10.240.0.16 # new member
+etcdctl --endpoints=${HOST_1}:2379,${HOST_2}:2379 \
+ member add ${NAME_4} \
+ --peer-urls=http://${HOST_4}:2380
+```
+
+Next, start the new member with `--initial-cluster-state existing` flag:
+
+```
+# [WARNING] If the new member starts from the same disk space,
+# make sure to remove the data directory of the old member
+#
+# restart with 'existing' flag
+TOKEN=my-etcd-token-1
+CLUSTER_STATE=existing
+NAME_1=etcd-node-1
+NAME_2=etcd-node-2
+NAME_4=etcd-node-4
+HOST_1=10.240.0.13
+HOST_2=10.240.0.14
+HOST_4=10.240.0.16 # new member
+CLUSTER=${NAME_1}=http://${HOST_1}:2380,${NAME_2}=http://${HOST_2}:2380,${NAME_4}=http://${HOST_4}:2380
+
+THIS_NAME=${NAME_4}
+THIS_IP=${HOST_4}
+etcd --data-dir=data.etcd --name ${THIS_NAME} \
+ --initial-advertise-peer-urls http://${THIS_IP}:2380 \
+ --listen-peer-urls http://${THIS_IP}:2380 \
+ --advertise-client-urls http://${THIS_IP}:2379 \
+ --listen-client-urls http://${THIS_IP}:2379 \
+ --initial-cluster ${CLUSTER} \
+ --initial-cluster-state ${CLUSTER_STATE} \
+ --initial-cluster-token ${TOKEN}
+```
+
+
+## Auth
+
+`auth`,`user`,`role` for authentication:
+
+<img src="https://storage.googleapis.com/etcd/demo/14_etcdctl_auth_2016062301.gif" alt="14_etcdctl_auth_2016062301"/>
+
+```
+export ETCDCTL_API=3
+ENDPOINTS=localhost:2379
+
+etcdctl --endpoints=${ENDPOINTS} role add root
+etcdctl --endpoints=${ENDPOINTS} role grant-permission root readwrite foo
+etcdctl --endpoints=${ENDPOINTS} role get root
+
+etcdctl --endpoints=${ENDPOINTS} user add root
+etcdctl --endpoints=${ENDPOINTS} user grant-role root root
+etcdctl --endpoints=${ENDPOINTS} user get root
+
+etcdctl --endpoints=${ENDPOINTS} auth enable
+# now all client requests go through auth
+
+etcdctl --endpoints=${ENDPOINTS} --user=root:123 put foo bar
+etcdctl --endpoints=${ENDPOINTS} get foo
+etcdctl --endpoints=${ENDPOINTS} --user=root:123 get foo
+etcdctl --endpoints=${ENDPOINTS} --user=root:123 get foo1
+```
diff --git a/vendor/github.com/coreos/etcd/Documentation/dev-guide/api_concurrency_reference_v3.md b/vendor/github.com/coreos/etcd/Documentation/dev-guide/api_concurrency_reference_v3.md
new file mode 100644
index 00000000..9ae1dab7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dev-guide/api_concurrency_reference_v3.md
@@ -0,0 +1,168 @@
+### etcd concurrency API Reference
+
+
+This is a generated documentation. Please read the proto files for more.
+
+
+##### service `Lock` (etcdserver/api/v3lock/v3lockpb/v3lock.proto)
+
+The lock service exposes client-side locking facilities as a gRPC interface.
+
+| Method | Request Type | Response Type | Description |
+| ------ | ------------ | ------------- | ----------- |
+| Lock | LockRequest | LockResponse | Lock acquires a distributed shared lock on a given named lock. On success, it will return a unique key that exists so long as the lock is held by the caller. This key can be used in conjunction with transactions to safely ensure updates to etcd only occur while holding lock ownership. The lock is held until Unlock is called on the key or the lease associate with the owner expires. |
+| Unlock | UnlockRequest | UnlockResponse | Unlock takes a key returned by Lock and releases the hold on lock. The next Lock caller waiting for the lock will then be woken up and given ownership of the lock. |
+
+
+
+##### message `LockRequest` (etcdserver/api/v3lock/v3lockpb/v3lock.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| name | name is the identifier for the distributed shared lock to be acquired. | bytes |
+| lease | lease is the ID of the lease that will be attached to ownership of the lock. If the lease expires or is revoked and currently holds the lock, the lock is automatically released. Calls to Lock with the same lease will be treated as a single acquistion; locking twice with the same lease is a no-op. | int64 |
+
+
+
+##### message `LockResponse` (etcdserver/api/v3lock/v3lockpb/v3lock.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | etcdserverpb.ResponseHeader |
+| key | key is a key that will exist on etcd for the duration that the Lock caller owns the lock. Users should not modify this key or the lock may exhibit undefined behavior. | bytes |
+
+
+
+##### message `UnlockRequest` (etcdserver/api/v3lock/v3lockpb/v3lock.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| key | key is the lock ownership key granted by Lock. | bytes |
+
+
+
+##### message `UnlockResponse` (etcdserver/api/v3lock/v3lockpb/v3lock.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | etcdserverpb.ResponseHeader |
+
+
+
+##### service `Election` (etcdserver/api/v3election/v3electionpb/v3election.proto)
+
+The election service exposes client-side election facilities as a gRPC interface.
+
+| Method | Request Type | Response Type | Description |
+| ------ | ------------ | ------------- | ----------- |
+| Campaign | CampaignRequest | CampaignResponse | Campaign waits to acquire leadership in an election, returning a LeaderKey representing the leadership if successful. The LeaderKey can then be used to issue new values on the election, transactionally guard API requests on leadership still being held, and resign from the election. |
+| Proclaim | ProclaimRequest | ProclaimResponse | Proclaim updates the leader's posted value with a new value. |
+| Leader | LeaderRequest | LeaderResponse | Leader returns the current election proclamation, if any. |
+| Observe | LeaderRequest | LeaderResponse | Observe streams election proclamations in-order as made by the election's elected leaders. |
+| Resign | ResignRequest | ResignResponse | Resign releases election leadership so other campaigners may acquire leadership on the election. |
+
+
+
+##### message `CampaignRequest` (etcdserver/api/v3election/v3electionpb/v3election.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| name | name is the election's identifier for the campaign. | bytes |
+| lease | lease is the ID of the lease attached to leadership of the election. If the lease expires or is revoked before resigning leadership, then the leadership is transferred to the next campaigner, if any. | int64 |
+| value | value is the initial proclaimed value set when the campaigner wins the election. | bytes |
+
+
+
+##### message `CampaignResponse` (etcdserver/api/v3election/v3electionpb/v3election.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | etcdserverpb.ResponseHeader |
+| leader | leader describes the resources used for holding leadereship of the election. | LeaderKey |
+
+
+
+##### message `LeaderKey` (etcdserver/api/v3election/v3electionpb/v3election.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| name | name is the election identifier that correponds to the leadership key. | bytes |
+| key | key is an opaque key representing the ownership of the election. If the key is deleted, then leadership is lost. | bytes |
+| rev | rev is the creation revision of the key. It can be used to test for ownership of an election during transactions by testing the key's creation revision matches rev. | int64 |
+| lease | lease is the lease ID of the election leader. | int64 |
+
+
+
+##### message `LeaderRequest` (etcdserver/api/v3election/v3electionpb/v3election.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| name | name is the election identifier for the leadership information. | bytes |
+
+
+
+##### message `LeaderResponse` (etcdserver/api/v3election/v3electionpb/v3election.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | etcdserverpb.ResponseHeader |
+| kv | kv is the key-value pair representing the latest leader update. | mvccpb.KeyValue |
+
+
+
+##### message `ProclaimRequest` (etcdserver/api/v3election/v3electionpb/v3election.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| leader | leader is the leadership hold on the election. | LeaderKey |
+| value | value is an update meant to overwrite the leader's current value. | bytes |
+
+
+
+##### message `ProclaimResponse` (etcdserver/api/v3election/v3electionpb/v3election.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | etcdserverpb.ResponseHeader |
+
+
+
+##### message `ResignRequest` (etcdserver/api/v3election/v3electionpb/v3election.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| leader | leader is the leadership to relinquish by resignation. | LeaderKey |
+
+
+
+##### message `ResignResponse` (etcdserver/api/v3election/v3electionpb/v3election.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | etcdserverpb.ResponseHeader |
+
+
+
+##### message `Event` (mvcc/mvccpb/kv.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| type | type is the kind of event. If type is a PUT, it indicates new data has been stored to the key. If type is a DELETE, it indicates the key was deleted. | EventType |
+| kv | kv holds the KeyValue for the event. A PUT event contains current kv pair. A PUT event with kv.Version=1 indicates the creation of a key. A DELETE/EXPIRE event contains the deleted key with its modification revision set to the revision of deletion. | KeyValue |
+| prev_kv | prev_kv holds the key-value pair before the event happens. | KeyValue |
+
+
+
+##### message `KeyValue` (mvcc/mvccpb/kv.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| key | key is the key in bytes. An empty key is not allowed. | bytes |
+| create_revision | create_revision is the revision of last creation on this key. | int64 |
+| mod_revision | mod_revision is the revision of last modification on this key. | int64 |
+| version | version is the version of the key. A deletion resets the version to zero and any modification of the key increases its version. | int64 |
+| value | value is the value held by the key, in bytes. | bytes |
+| lease | lease is the ID of the lease that attached to key. When the attached lease expires, the key will be deleted. If lease is 0, then no lease is attached to the key. | int64 |
+
+
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/dev-guide/api_grpc_gateway.md b/vendor/github.com/coreos/etcd/Documentation/dev-guide/api_grpc_gateway.md
new file mode 100644
index 00000000..a9629efc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dev-guide/api_grpc_gateway.md
@@ -0,0 +1,67 @@
+
+## Why grpc-gateway
+
+etcd v3 uses [gRPC][grpc] for its messaging protocol. The etcd project includes a gRPC-based [Go client][go-client] and a command line utility, [etcdctl][etcdctl], for communicating with an etcd cluster through gRPC. For languages with no gRPC support, etcd provides a JSON [grpc-gateway][grpc-gateway]. This gateway serves a RESTful proxy that translates HTTP/JSON requests into gRPC messages.
+
+
+## Using grpc-gateway
+
+The gateway accepts a [JSON mapping][json-mapping] for etcd's [protocol buffer][api-ref] message definitions. Note that `key` and `value` fields are defined as byte arrays and therefore must be base64 encoded in JSON.
+
+Use `curl` to put and get a key:
+
+```bash
+<<COMMENT
+https://www.base64encode.org/
+foo is 'Zm9v' in Base64
+bar is 'YmFy'
+COMMENT
+
+curl -L http://localhost:2379/v3alpha/kv/put \
+ -X POST -d '{"key": "Zm9v", "value": "YmFy"}'
+# {"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"2","raft_term":"3"}}
+
+curl -L http://localhost:2379/v3alpha/kv/range \
+ -X POST -d '{"key": "Zm9v"}'
+# {"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"2","raft_term":"3"},"kvs":[{"key":"Zm9v","create_revision":"2","mod_revision":"2","version":"1","value":"YmFy"}],"count":"1"}
+
+# get all keys prefixed with "foo"
+curl -L http://localhost:2379/v3alpha/kv/range \
+ -X POST -d '{"key": "Zm9v", "range_end": "Zm9w"}'
+# {"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"2","raft_term":"3"},"kvs":[{"key":"Zm9v","create_revision":"2","mod_revision":"2","version":"1","value":"YmFy"}],"count":"1"}
+```
+
+Use `curl` to watch a key:
+
+```bash
+curl http://localhost:2379/v3alpha/watch \
+ -X POST -d '{"create_request": {"key":"Zm9v"} }' &
+# {"result":{"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"1","raft_term":"2"},"created":true}}
+
+curl -L http://localhost:2379/v3alpha/kv/put \
+ -X POST -d '{"key": "Zm9v", "value": "YmFy"}' >/dev/null 2>&1
+# {"result":{"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"2","raft_term":"2"},"events":[{"kv":{"key":"Zm9v","create_revision":"2","mod_revision":"2","version":"1","value":"YmFy"}}]}}
+```
+
+Use `curl` to issue a transaction:
+
+```bash
+curl -L http://localhost:2379/v3alpha/kv/txn \
+ -X POST \
+ -d '{"compare":[{"target":"CREATE","key":"Zm9v","createRevision":"2"}],"success":[{"requestPut":{"key":"Zm9v","value":"YmFy"}}]}'
+# {"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"3","raft_term":"2"},"succeeded":true,"responses":[{"response_put":{"header":{"revision":"3"}}}]}
+```
+
+## Swagger
+
+Generated [Swagger][swagger] API definitions can be found at [rpc.swagger.json][swagger-doc].
+
+[api-ref]: ./api_reference_v3.md
+[go-client]: https://github.com/coreos/etcd/tree/master/clientv3
+[etcdctl]: https://github.com/coreos/etcd/tree/master/etcdctl
+[grpc]: http://www.grpc.io/
+[grpc-gateway]: https://github.com/grpc-ecosystem/grpc-gateway
+[json-mapping]: https://developers.google.com/protocol-buffers/docs/proto3#json
+[swagger]: http://swagger.io/
+[swagger-doc]: apispec/swagger/rpc.swagger.json
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/dev-guide/api_reference_v3.md b/vendor/github.com/coreos/etcd/Documentation/dev-guide/api_reference_v3.md
new file mode 100644
index 00000000..b99797e5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dev-guide/api_reference_v3.md
@@ -0,0 +1,880 @@
+### etcd API Reference
+
+
+This is a generated documentation. Please read the proto files for more.
+
+
+##### service `Auth` (etcdserver/etcdserverpb/rpc.proto)
+
+| Method | Request Type | Response Type | Description |
+| ------ | ------------ | ------------- | ----------- |
+| AuthEnable | AuthEnableRequest | AuthEnableResponse | AuthEnable enables authentication. |
+| AuthDisable | AuthDisableRequest | AuthDisableResponse | AuthDisable disables authentication. |
+| Authenticate | AuthenticateRequest | AuthenticateResponse | Authenticate processes an authenticate request. |
+| UserAdd | AuthUserAddRequest | AuthUserAddResponse | UserAdd adds a new user. |
+| UserGet | AuthUserGetRequest | AuthUserGetResponse | UserGet gets detailed user information. |
+| UserList | AuthUserListRequest | AuthUserListResponse | UserList gets a list of all users. |
+| UserDelete | AuthUserDeleteRequest | AuthUserDeleteResponse | UserDelete deletes a specified user. |
+| UserChangePassword | AuthUserChangePasswordRequest | AuthUserChangePasswordResponse | UserChangePassword changes the password of a specified user. |
+| UserGrantRole | AuthUserGrantRoleRequest | AuthUserGrantRoleResponse | UserGrant grants a role to a specified user. |
+| UserRevokeRole | AuthUserRevokeRoleRequest | AuthUserRevokeRoleResponse | UserRevokeRole revokes a role of specified user. |
+| RoleAdd | AuthRoleAddRequest | AuthRoleAddResponse | RoleAdd adds a new role. |
+| RoleGet | AuthRoleGetRequest | AuthRoleGetResponse | RoleGet gets detailed role information. |
+| RoleList | AuthRoleListRequest | AuthRoleListResponse | RoleList gets lists of all roles. |
+| RoleDelete | AuthRoleDeleteRequest | AuthRoleDeleteResponse | RoleDelete deletes a specified role. |
+| RoleGrantPermission | AuthRoleGrantPermissionRequest | AuthRoleGrantPermissionResponse | RoleGrantPermission grants a permission of a specified key or range to a specified role. |
+| RoleRevokePermission | AuthRoleRevokePermissionRequest | AuthRoleRevokePermissionResponse | RoleRevokePermission revokes a key or range permission of a specified role. |
+
+
+
+##### service `Cluster` (etcdserver/etcdserverpb/rpc.proto)
+
+| Method | Request Type | Response Type | Description |
+| ------ | ------------ | ------------- | ----------- |
+| MemberAdd | MemberAddRequest | MemberAddResponse | MemberAdd adds a member into the cluster. |
+| MemberRemove | MemberRemoveRequest | MemberRemoveResponse | MemberRemove removes an existing member from the cluster. |
+| MemberUpdate | MemberUpdateRequest | MemberUpdateResponse | MemberUpdate updates the member configuration. |
+| MemberList | MemberListRequest | MemberListResponse | MemberList lists all the members in the cluster. |
+
+
+
+##### service `KV` (etcdserver/etcdserverpb/rpc.proto)
+
+| Method | Request Type | Response Type | Description |
+| ------ | ------------ | ------------- | ----------- |
+| Range | RangeRequest | RangeResponse | Range gets the keys in the range from the key-value store. |
+| Put | PutRequest | PutResponse | Put puts the given key into the key-value store. A put request increments the revision of the key-value store and generates one event in the event history. |
+| DeleteRange | DeleteRangeRequest | DeleteRangeResponse | DeleteRange deletes the given range from the key-value store. A delete request increments the revision of the key-value store and generates a delete event in the event history for every deleted key. |
+| Txn | TxnRequest | TxnResponse | Txn processes multiple requests in a single transaction. A txn request increments the revision of the key-value store and generates events with the same revision for every completed request. It is not allowed to modify the same key several times within one txn. |
+| Compact | CompactionRequest | CompactionResponse | Compact compacts the event history in the etcd key-value store. The key-value store should be periodically compacted or the event history will continue to grow indefinitely. |
+
+
+
+##### service `Lease` (etcdserver/etcdserverpb/rpc.proto)
+
+| Method | Request Type | Response Type | Description |
+| ------ | ------------ | ------------- | ----------- |
+| LeaseGrant | LeaseGrantRequest | LeaseGrantResponse | LeaseGrant creates a lease which expires if the server does not receive a keepAlive within a given time to live period. All keys attached to the lease will be expired and deleted if the lease expires. Each expired key generates a delete event in the event history. |
+| LeaseRevoke | LeaseRevokeRequest | LeaseRevokeResponse | LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted. |
+| LeaseKeepAlive | LeaseKeepAliveRequest | LeaseKeepAliveResponse | LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client to the server and streaming keep alive responses from the server to the client. |
+| LeaseTimeToLive | LeaseTimeToLiveRequest | LeaseTimeToLiveResponse | LeaseTimeToLive retrieves lease information. |
+
+
+
+##### service `Maintenance` (etcdserver/etcdserverpb/rpc.proto)
+
+| Method | Request Type | Response Type | Description |
+| ------ | ------------ | ------------- | ----------- |
+| Alarm | AlarmRequest | AlarmResponse | Alarm activates, deactivates, and queries alarms regarding cluster health. |
+| Status | StatusRequest | StatusResponse | Status gets the status of the member. |
+| Defragment | DefragmentRequest | DefragmentResponse | Defragment defragments a member's backend database to recover storage space. |
+| Hash | HashRequest | HashResponse | Hash returns the hash of the local KV state for consistency checking purpose. This is designed for testing; do not use this in production when there are ongoing transactions. |
+| Snapshot | SnapshotRequest | SnapshotResponse | Snapshot sends a snapshot of the entire backend from a member over a stream to a client. |
+
+
+
+##### service `Watch` (etcdserver/etcdserverpb/rpc.proto)
+
+| Method | Request Type | Response Type | Description |
+| ------ | ------------ | ------------- | ----------- |
+| Watch | WatchRequest | WatchResponse | Watch watches for events happening or that have happened. Both input and output are streams; the input stream is for creating and canceling watchers and the output stream sends events. One watch RPC can watch on multiple key ranges, streaming events for several watches at once. The entire event history can be watched starting from the last compaction revision. |
+
+
+
+##### message `AlarmMember` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| memberID | memberID is the ID of the member associated with the raised alarm. | uint64 |
+| alarm | alarm is the type of alarm which has been raised. | AlarmType |
+
+
+
+##### message `AlarmRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| action | action is the kind of alarm request to issue. The action may GET alarm statuses, ACTIVATE an alarm, or DEACTIVATE a raised alarm. | AlarmAction |
+| memberID | memberID is the ID of the member associated with the alarm. If memberID is 0, the alarm request covers all members. | uint64 |
+| alarm | alarm is the type of alarm to consider for this request. | AlarmType |
+
+
+
+##### message `AlarmResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| alarms | alarms is a list of alarms associated with the alarm request. | (slice of) AlarmMember |
+
+
+
+##### message `AuthDisableRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+Empty field.
+
+
+
+##### message `AuthDisableResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+
+
+
+##### message `AuthEnableRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+Empty field.
+
+
+
+##### message `AuthEnableResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+
+
+
+##### message `AuthRoleAddRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| name | name is the name of the role to add to the authentication system. | string |
+
+
+
+##### message `AuthRoleAddResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+
+
+
+##### message `AuthRoleDeleteRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| role | | string |
+
+
+
+##### message `AuthRoleDeleteResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+
+
+
+##### message `AuthRoleGetRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| role | | string |
+
+
+
+##### message `AuthRoleGetResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| perm | | (slice of) authpb.Permission |
+
+
+
+##### message `AuthRoleGrantPermissionRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| name | name is the name of the role which will be granted the permission. | string |
+| perm | perm is the permission to grant to the role. | authpb.Permission |
+
+
+
+##### message `AuthRoleGrantPermissionResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+
+
+
+##### message `AuthRoleListRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+Empty field.
+
+
+
+##### message `AuthRoleListResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| roles | | (slice of) string |
+
+
+
+##### message `AuthRoleRevokePermissionRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| role | | string |
+| key | | string |
+| range_end | | string |
+
+
+
+##### message `AuthRoleRevokePermissionResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+
+
+
+##### message `AuthUserAddRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| name | | string |
+| password | | string |
+
+
+
+##### message `AuthUserAddResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+
+
+
+##### message `AuthUserChangePasswordRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| name | name is the name of the user whose password is being changed. | string |
+| password | password is the new password for the user. | string |
+
+
+
+##### message `AuthUserChangePasswordResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+
+
+
+##### message `AuthUserDeleteRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| name | name is the name of the user to delete. | string |
+
+
+
+##### message `AuthUserDeleteResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+
+
+
+##### message `AuthUserGetRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| name | | string |
+
+
+
+##### message `AuthUserGetResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| roles | | (slice of) string |
+
+
+
+##### message `AuthUserGrantRoleRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| user | user is the name of the user which should be granted a given role. | string |
+| role | role is the name of the role to grant to the user. | string |
+
+
+
+##### message `AuthUserGrantRoleResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+
+
+
+##### message `AuthUserListRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+Empty field.
+
+
+
+##### message `AuthUserListResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| users | | (slice of) string |
+
+
+
+##### message `AuthUserRevokeRoleRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| name | | string |
+| role | | string |
+
+
+
+##### message `AuthUserRevokeRoleResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+
+
+
+##### message `AuthenticateRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| name | | string |
+| password | | string |
+
+
+
+##### message `AuthenticateResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| token | token is an authorized token that can be used in succeeding RPCs | string |
+
+
+
+##### message `CompactionRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+CompactionRequest compacts the key-value store up to a given revision. All superseded keys with a revision less than the compaction revision will be removed.
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| revision | revision is the key-value store revision for the compaction operation. | int64 |
+| physical | physical is set so the RPC will wait until the compaction is physically applied to the local database such that compacted entries are totally removed from the backend database. | bool |
+
+
+
+##### message `CompactionResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+
+
+
+##### message `Compare` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| result | result is logical comparison operation for this comparison. | CompareResult |
+| target | target is the key-value field to inspect for the comparison. | CompareTarget |
+| key | key is the subject key for the comparison operation. | bytes |
+| target_union | | oneof |
+| version | version is the version of the given key | int64 |
+| create_revision | create_revision is the creation revision of the given key | int64 |
+| mod_revision | mod_revision is the last modified revision of the given key. | int64 |
+| value | value is the value of the given key, in bytes. | bytes |
+
+
+
+##### message `DefragmentRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+Empty field.
+
+
+
+##### message `DefragmentResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+
+
+
+##### message `DeleteRangeRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| key | key is the first key to delete in the range. | bytes |
+| range_end | range_end is the key following the last key to delete for the range [key, range_end). If range_end is not given, the range is defined to contain only the key argument. If range_end is one bit larger than the given key, then the range is all the keys with the prefix (the given key). If range_end is '\0', the range is all keys greater than or equal to the key argument. | bytes |
+| prev_kv | If prev_kv is set, etcd gets the previous key-value pairs before deleting it. The previous key-value pairs will be returned in the delete response. | bool |
+
+
+
+##### message `DeleteRangeResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| deleted | deleted is the number of keys deleted by the delete range request. | int64 |
+| prev_kvs | if prev_kv is set in the request, the previous key-value pairs will be returned. | (slice of) mvccpb.KeyValue |
+
+
+
+##### message `HashRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+Empty field.
+
+
+
+##### message `HashResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| hash | hash is the hash value computed from the responding member's key-value store. | uint32 |
+
+
+
+##### message `LeaseGrantRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| TTL | TTL is the advisory time-to-live in seconds. | int64 |
+| ID | ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID. | int64 |
+
+
+
+##### message `LeaseGrantResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| ID | ID is the lease ID for the granted lease. | int64 |
+| TTL | TTL is the server chosen lease time-to-live in seconds. | int64 |
+| error | | string |
+
+
+
+##### message `LeaseKeepAliveRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| ID | ID is the lease ID for the lease to keep alive. | int64 |
+
+
+
+##### message `LeaseKeepAliveResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| ID | ID is the lease ID from the keep alive request. | int64 |
+| TTL | TTL is the new time-to-live for the lease. | int64 |
+
+
+
+##### message `LeaseRevokeRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| ID | ID is the lease ID to revoke. When the ID is revoked, all associated keys will be deleted. | int64 |
+
+
+
+##### message `LeaseRevokeResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+
+
+
+##### message `LeaseTimeToLiveRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| ID | ID is the lease ID for the lease. | int64 |
+| keys | keys is true to query all the keys attached to this lease. | bool |
+
+
+
+##### message `LeaseTimeToLiveResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| ID | ID is the lease ID from the keep alive request. | int64 |
+| TTL | TTL is the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds. | int64 |
+| grantedTTL | GrantedTTL is the initial granted time in seconds upon lease creation/renewal. | int64 |
+| keys | Keys is the list of keys attached to this lease. | (slice of) bytes |
+
+
+
+##### message `Member` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| ID | ID is the member ID for this member. | uint64 |
+| name | name is the human-readable name of the member. If the member is not started, the name will be an empty string. | string |
+| peerURLs | peerURLs is the list of URLs the member exposes to the cluster for communication. | (slice of) string |
+| clientURLs | clientURLs is the list of URLs the member exposes to clients for communication. If the member is not started, clientURLs will be empty. | (slice of) string |
+
+
+
+##### message `MemberAddRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| peerURLs | peerURLs is the list of URLs the added member will use to communicate with the cluster. | (slice of) string |
+
+
+
+##### message `MemberAddResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| member | member is the member information for the added member. | Member |
+| members | members is a list of all members after adding the new member. | (slice of) Member |
+
+
+
+##### message `MemberListRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+Empty field.
+
+
+
+##### message `MemberListResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| members | members is a list of all members associated with the cluster. | (slice of) Member |
+
+
+
+##### message `MemberRemoveRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| ID | ID is the member ID of the member to remove. | uint64 |
+
+
+
+##### message `MemberRemoveResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| members | members is a list of all members after removing the member. | (slice of) Member |
+
+
+
+##### message `MemberUpdateRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| ID | ID is the member ID of the member to update. | uint64 |
+| peerURLs | peerURLs is the new list of URLs the member will use to communicate with the cluster. | (slice of) string |
+
+
+
+##### message `MemberUpdateResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| members | members is a list of all members after updating the member. | (slice of) Member |
+
+
+
+##### message `PutRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| key | key is the key, in bytes, to put into the key-value store. | bytes |
+| value | value is the value, in bytes, to associate with the key in the key-value store. | bytes |
+| lease | lease is the lease ID to associate with the key in the key-value store. A lease value of 0 indicates no lease. | int64 |
+| prev_kv | If prev_kv is set, etcd gets the previous key-value pair before changing it. The previous key-value pair will be returned in the put response. | bool |
+| ignore_value | If ignore_value is set, etcd updates the key using its current value. Returns an error if the key does not exist. | bool |
+| ignore_lease | If ignore_lease is set, etcd updates the key using its current lease. Returns an error if the key does not exist. | bool |
+
+
+
+##### message `PutResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| prev_kv | if prev_kv is set in the request, the previous key-value pair will be returned. | mvccpb.KeyValue |
+
+
+
+##### message `RangeRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| key | key is the first key for the range. If range_end is not given, the request only looks up key. | bytes |
+| range_end | range_end is the upper bound on the requested range [key, range_end). If range_end is '\0', the range is all keys >= key. If range_end is key plus one (e.g., "aa"+1 == "ab", "a\xff"+1 == "b"), then the range request gets all keys prefixed with key. If both key and range_end are '\0', then the range request returns all keys. | bytes |
+| limit | limit is a limit on the number of keys returned for the request. When limit is set to 0, it is treated as no limit. | int64 |
+| revision | revision is the point-in-time of the key-value store to use for the range. If revision is less or equal to zero, the range is over the newest key-value store. If the revision has been compacted, ErrCompacted is returned as a response. | int64 |
+| sort_order | sort_order is the order for returned sorted results. | SortOrder |
+| sort_target | sort_target is the key-value field to use for sorting. | SortTarget |
+| serializable | serializable sets the range request to use serializable member-local reads. Range requests are linearizable by default; linearizable requests have higher latency and lower throughput than serializable requests but reflect the current consensus of the cluster. For better performance, in exchange for possible stale reads, a serializable range request is served locally without needing to reach consensus with other nodes in the cluster. | bool |
+| keys_only | keys_only when set returns only the keys and not the values. | bool |
+| count_only | count_only when set returns only the count of the keys in the range. | bool |
+| min_mod_revision | min_mod_revision is the lower bound for returned key mod revisions; all keys with lesser mod revisions will be filtered away. | int64 |
+| max_mod_revision | max_mod_revision is the upper bound for returned key mod revisions; all keys with greater mod revisions will be filtered away. | int64 |
+| min_create_revision | min_create_revision is the lower bound for returned key create revisions; all keys with lesser create trevisions will be filtered away. | int64 |
+| max_create_revision | max_create_revision is the upper bound for returned key create revisions; all keys with greater create revisions will be filtered away. | int64 |
+
+
+
+##### message `RangeResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| kvs | kvs is the list of key-value pairs matched by the range request. kvs is empty when count is requested. | (slice of) mvccpb.KeyValue |
+| more | more indicates if there are more keys to return in the requested range. | bool |
+| count | count is set to the number of keys within the range when requested. | int64 |
+
+
+
+##### message `RequestOp` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| request | request is a union of request types accepted by a transaction. | oneof |
+| request_range | | RangeRequest |
+| request_put | | PutRequest |
+| request_delete_range | | DeleteRangeRequest |
+
+
+
+##### message `ResponseHeader` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| cluster_id | cluster_id is the ID of the cluster which sent the response. | uint64 |
+| member_id | member_id is the ID of the member which sent the response. | uint64 |
+| revision | revision is the key-value store revision when the request was applied. | int64 |
+| raft_term | raft_term is the raft term when the request was applied. | uint64 |
+
+
+
+##### message `ResponseOp` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| response | response is a union of response types returned by a transaction. | oneof |
+| response_range | | RangeResponse |
+| response_put | | PutResponse |
+| response_delete_range | | DeleteRangeResponse |
+
+
+
+##### message `SnapshotRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+Empty field.
+
+
+
+##### message `SnapshotResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | header has the current key-value store information. The first header in the snapshot stream indicates the point in time of the snapshot. | ResponseHeader |
+| remaining_bytes | remaining_bytes is the number of blob bytes to be sent after this message | uint64 |
+| blob | blob contains the next chunk of the snapshot in the snapshot stream. | bytes |
+
+
+
+##### message `StatusRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+Empty field.
+
+
+
+##### message `StatusResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| version | version is the cluster protocol version used by the responding member. | string |
+| dbSize | dbSize is the size of the backend database, in bytes, of the responding member. | int64 |
+| leader | leader is the member ID which the responding member believes is the current leader. | uint64 |
+| raftIndex | raftIndex is the current raft index of the responding member. | uint64 |
+| raftTerm | raftTerm is the current raft term of the responding member. | uint64 |
+
+
+
+##### message `TxnRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+From google paxosdb paper: Our implementation hinges around a powerful primitive which we call MultiOp. All other database operations except for iteration are implemented as a single call to MultiOp. A MultiOp is applied atomically and consists of three components: 1. A list of tests called guard. Each test in guard checks a single entry in the database. It may check for the absence or presence of a value, or compare with a given value. Two different tests in the guard may apply to the same or different entries in the database. All tests in the guard are applied and MultiOp returns the results. If all tests are true, MultiOp executes t op (see item 2 below), otherwise it executes f op (see item 3 below). 2. A list of database operations called t op. Each operation in the list is either an insert, delete, or lookup operation, and applies to a single database entry. Two different operations in the list may apply to the same or different entries in the database. These operations are executed if guard evaluates to true. 3. A list of database operations called f op. Like t op, but executed if guard evaluates to false.
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| compare | compare is a list of predicates representing a conjunction of terms. If the comparisons succeed, then the success requests will be processed in order, and the response will contain their respective responses in order. If the comparisons fail, then the failure requests will be processed in order, and the response will contain their respective responses in order. | (slice of) Compare |
+| success | success is a list of requests which will be applied when compare evaluates to true. | (slice of) RequestOp |
+| failure | failure is a list of requests which will be applied when compare evaluates to false. | (slice of) RequestOp |
+
+
+
+##### message `TxnResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| succeeded | succeeded is set to true if the compare evaluated to true or false otherwise. | bool |
+| responses | responses is a list of responses corresponding to the results from applying success if succeeded is true or failure if succeeded is false. | (slice of) ResponseOp |
+
+
+
+##### message `WatchCancelRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| watch_id | watch_id is the watcher id to cancel so that no more events are transmitted. | int64 |
+
+
+
+##### message `WatchCreateRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| key | key is the key to register for watching. | bytes |
+| range_end | range_end is the end of the range [key, range_end) to watch. If range_end is not given, only the key argument is watched. If range_end is equal to '\0', all keys greater than or equal to the key argument are watched. If the range_end is one bit larger than the given key, then all keys with the prefix (the given key) will be watched. | bytes |
+| start_revision | start_revision is an optional revision to watch from (inclusive). No start_revision is "now". | int64 |
+| progress_notify | progress_notify is set so that the etcd server will periodically send a WatchResponse with no events to the new watcher if there are no recent events. It is useful when clients wish to recover a disconnected watcher starting from a recent known revision. The etcd server may decide how often it will send notifications based on current load. | bool |
+| filters | filters filter the events at server side before it sends back to the watcher. | (slice of) FilterType |
+| prev_kv | If prev_kv is set, created watcher gets the previous KV before the event happens. If the previous KV is already compacted, nothing will be returned. | bool |
+
+
+
+##### message `WatchRequest` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| request_union | request_union is a request to either create a new watcher or cancel an existing watcher. | oneof |
+| create_request | | WatchCreateRequest |
+| cancel_request | | WatchCancelRequest |
+
+
+
+##### message `WatchResponse` (etcdserver/etcdserverpb/rpc.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| header | | ResponseHeader |
+| watch_id | watch_id is the ID of the watcher that corresponds to the response. | int64 |
+| created | created is set to true if the response is for a create watch request. The client should record the watch_id and expect to receive events for the created watcher from the same stream. All events sent to the created watcher will attach with the same watch_id. | bool |
+| canceled | canceled is set to true if the response is for a cancel watch request. No further events will be sent to the canceled watcher. | bool |
+| compact_revision | compact_revision is set to the minimum index if a watcher tries to watch at a compacted index. This happens when creating a watcher at a compacted revision or the watcher cannot catch up with the progress of the key-value store. The client should treat the watcher as canceled and should not try to create any watcher with the same start_revision again. | int64 |
+| cancel_reason | cancel_reason indicates the reason for canceling the watcher. | string |
+| events | | (slice of) mvccpb.Event |
+
+
+
+##### message `Event` (mvcc/mvccpb/kv.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| type | type is the kind of event. If type is a PUT, it indicates new data has been stored to the key. If type is a DELETE, it indicates the key was deleted. | EventType |
+| kv | kv holds the KeyValue for the event. A PUT event contains current kv pair. A PUT event with kv.Version=1 indicates the creation of a key. A DELETE/EXPIRE event contains the deleted key with its modification revision set to the revision of deletion. | KeyValue |
+| prev_kv | prev_kv holds the key-value pair before the event happens. | KeyValue |
+
+
+
+##### message `KeyValue` (mvcc/mvccpb/kv.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| key | key is the key in bytes. An empty key is not allowed. | bytes |
+| create_revision | create_revision is the revision of last creation on this key. | int64 |
+| mod_revision | mod_revision is the revision of last modification on this key. | int64 |
+| version | version is the version of the key. A deletion resets the version to zero and any modification of the key increases its version. | int64 |
+| value | value is the value held by the key, in bytes. | bytes |
+| lease | lease is the ID of the lease that attached to key. When the attached lease expires, the key will be deleted. If lease is 0, then no lease is attached to the key. | int64 |
+
+
+
+##### message `Lease` (lease/leasepb/lease.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| ID | | int64 |
+| TTL | | int64 |
+
+
+
+##### message `LeaseInternalRequest` (lease/leasepb/lease.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| LeaseTimeToLiveRequest | | etcdserverpb.LeaseTimeToLiveRequest |
+
+
+
+##### message `LeaseInternalResponse` (lease/leasepb/lease.proto)
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| LeaseTimeToLiveResponse | | etcdserverpb.LeaseTimeToLiveResponse |
+
+
+
+##### message `Permission` (auth/authpb/auth.proto)
+
+Permission is a single entity
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| permType | | Type |
+| key | | bytes |
+| range_end | | bytes |
+
+
+
+##### message `Role` (auth/authpb/auth.proto)
+
+Role is a single entry in the bucket authRoles
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| name | | bytes |
+| keyPermission | | (slice of) Permission |
+
+
+
+##### message `User` (auth/authpb/auth.proto)
+
+User is a single entry in the bucket authUsers
+
+| Field | Description | Type |
+| ----- | ----------- | ---- |
+| name | | bytes |
+| password | | bytes |
+| roles | | (slice of) string |
+
+
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/dev-guide/apispec/swagger/rpc.swagger.json b/vendor/github.com/coreos/etcd/Documentation/dev-guide/apispec/swagger/rpc.swagger.json
new file mode 100644
index 00000000..a162a00e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dev-guide/apispec/swagger/rpc.swagger.json
@@ -0,0 +1,2247 @@
+{
+ "swagger": "2.0",
+ "info": {
+ "title": "etcdserver/etcdserverpb/rpc.proto",
+ "version": "version not set"
+ },
+ "schemes": [
+ "http",
+ "https"
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "paths": {
+ "/v3alpha/auth/authenticate": {
+ "post": {
+ "summary": "Authenticate processes an authenticate request.",
+ "operationId": "Authenticate",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthenticateResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthenticateRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/disable": {
+ "post": {
+ "summary": "AuthDisable disables authentication.",
+ "operationId": "AuthDisable",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthDisableResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthDisableRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/enable": {
+ "post": {
+ "summary": "AuthEnable enables authentication.",
+ "operationId": "AuthEnable",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthEnableResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthEnableRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/role/add": {
+ "post": {
+ "summary": "RoleAdd adds a new role.",
+ "operationId": "RoleAdd",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthRoleAddResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthRoleAddRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/role/delete": {
+ "post": {
+ "summary": "RoleDelete deletes a specified role.",
+ "operationId": "RoleDelete",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthRoleDeleteResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthRoleDeleteRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/role/get": {
+ "post": {
+ "summary": "RoleGet gets detailed role information.",
+ "operationId": "RoleGet",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthRoleGetResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthRoleGetRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/role/grant": {
+ "post": {
+ "summary": "RoleGrantPermission grants a permission of a specified key or range to a specified role.",
+ "operationId": "RoleGrantPermission",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthRoleGrantPermissionResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthRoleGrantPermissionRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/role/list": {
+ "post": {
+ "summary": "RoleList gets lists of all roles.",
+ "operationId": "RoleList",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthRoleListResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthRoleListRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/role/revoke": {
+ "post": {
+ "summary": "RoleRevokePermission revokes a key or range permission of a specified role.",
+ "operationId": "RoleRevokePermission",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthRoleRevokePermissionResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthRoleRevokePermissionRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/user/add": {
+ "post": {
+ "summary": "UserAdd adds a new user.",
+ "operationId": "UserAdd",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthUserAddResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthUserAddRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/user/changepw": {
+ "post": {
+ "summary": "UserChangePassword changes the password of a specified user.",
+ "operationId": "UserChangePassword",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthUserChangePasswordResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthUserChangePasswordRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/user/delete": {
+ "post": {
+ "summary": "UserDelete deletes a specified user.",
+ "operationId": "UserDelete",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthUserDeleteResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthUserDeleteRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/user/get": {
+ "post": {
+ "summary": "UserGet gets detailed user information.",
+ "operationId": "UserGet",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthUserGetResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthUserGetRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/user/grant": {
+ "post": {
+ "summary": "UserGrant grants a role to a specified user.",
+ "operationId": "UserGrantRole",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthUserGrantRoleResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthUserGrantRoleRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/user/list": {
+ "post": {
+ "summary": "UserList gets a list of all users.",
+ "operationId": "UserList",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthUserListResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthUserListRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/auth/user/revoke": {
+ "post": {
+ "summary": "UserRevokeRole revokes a role of specified user.",
+ "operationId": "UserRevokeRole",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthUserRevokeRoleResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAuthUserRevokeRoleRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Auth"
+ ]
+ }
+ },
+ "/v3alpha/cluster/member/add": {
+ "post": {
+ "summary": "MemberAdd adds a member into the cluster.",
+ "operationId": "MemberAdd",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbMemberAddResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbMemberAddRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Cluster"
+ ]
+ }
+ },
+ "/v3alpha/cluster/member/list": {
+ "post": {
+ "summary": "MemberList lists all the members in the cluster.",
+ "operationId": "MemberList",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbMemberListResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbMemberListRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Cluster"
+ ]
+ }
+ },
+ "/v3alpha/cluster/member/remove": {
+ "post": {
+ "summary": "MemberRemove removes an existing member from the cluster.",
+ "operationId": "MemberRemove",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbMemberRemoveResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbMemberRemoveRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Cluster"
+ ]
+ }
+ },
+ "/v3alpha/cluster/member/update": {
+ "post": {
+ "summary": "MemberUpdate updates the member configuration.",
+ "operationId": "MemberUpdate",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbMemberUpdateResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbMemberUpdateRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Cluster"
+ ]
+ }
+ },
+ "/v3alpha/kv/compaction": {
+ "post": {
+ "summary": "Compact compacts the event history in the etcd key-value store. The key-value\nstore should be periodically compacted or the event history will continue to grow\nindefinitely.",
+ "operationId": "Compact",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbCompactionResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbCompactionRequest"
+ }
+ }
+ ],
+ "tags": [
+ "KV"
+ ]
+ }
+ },
+ "/v3alpha/kv/deleterange": {
+ "post": {
+ "summary": "DeleteRange deletes the given range from the key-value store.\nA delete request increments the revision of the key-value store\nand generates a delete event in the event history for every deleted key.",
+ "operationId": "DeleteRange",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbDeleteRangeResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbDeleteRangeRequest"
+ }
+ }
+ ],
+ "tags": [
+ "KV"
+ ]
+ }
+ },
+ "/v3alpha/kv/lease/revoke": {
+ "post": {
+ "summary": "LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.",
+ "operationId": "LeaseRevoke",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbLeaseRevokeResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbLeaseRevokeRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Lease"
+ ]
+ }
+ },
+ "/v3alpha/kv/lease/timetolive": {
+ "post": {
+ "summary": "LeaseTimeToLive retrieves lease information.",
+ "operationId": "LeaseTimeToLive",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbLeaseTimeToLiveResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbLeaseTimeToLiveRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Lease"
+ ]
+ }
+ },
+ "/v3alpha/kv/put": {
+ "post": {
+ "summary": "Put puts the given key into the key-value store.\nA put request increments the revision of the key-value store\nand generates one event in the event history.",
+ "operationId": "Put",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbPutResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbPutRequest"
+ }
+ }
+ ],
+ "tags": [
+ "KV"
+ ]
+ }
+ },
+ "/v3alpha/kv/range": {
+ "post": {
+ "summary": "Range gets the keys in the range from the key-value store.",
+ "operationId": "Range",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbRangeResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbRangeRequest"
+ }
+ }
+ ],
+ "tags": [
+ "KV"
+ ]
+ }
+ },
+ "/v3alpha/kv/txn": {
+ "post": {
+ "summary": "Txn processes multiple requests in a single transaction.\nA txn request increments the revision of the key-value store\nand generates events with the same revision for every completed request.\nIt is not allowed to modify the same key several times within one txn.",
+ "operationId": "Txn",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbTxnResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbTxnRequest"
+ }
+ }
+ ],
+ "tags": [
+ "KV"
+ ]
+ }
+ },
+ "/v3alpha/lease/grant": {
+ "post": {
+ "summary": "LeaseGrant creates a lease which expires if the server does not receive a keepAlive\nwithin a given time to live period. All keys attached to the lease will be expired and\ndeleted if the lease expires. Each expired key generates a delete event in the event history.",
+ "operationId": "LeaseGrant",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbLeaseGrantResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbLeaseGrantRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Lease"
+ ]
+ }
+ },
+ "/v3alpha/lease/keepalive": {
+ "post": {
+ "summary": "LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client\nto the server and streaming keep alive responses from the server to the client.",
+ "operationId": "LeaseKeepAlive",
+ "responses": {
+ "200": {
+ "description": "(streaming responses)",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbLeaseKeepAliveResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "description": "(streaming inputs)",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbLeaseKeepAliveRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Lease"
+ ]
+ }
+ },
+ "/v3alpha/maintenance/alarm": {
+ "post": {
+ "summary": "Alarm activates, deactivates, and queries alarms regarding cluster health.",
+ "operationId": "Alarm",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAlarmResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbAlarmRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Maintenance"
+ ]
+ }
+ },
+ "/v3alpha/maintenance/defragment": {
+ "post": {
+ "summary": "Defragment defragments a member's backend database to recover storage space.",
+ "operationId": "Defragment",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbDefragmentResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbDefragmentRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Maintenance"
+ ]
+ }
+ },
+ "/v3alpha/maintenance/hash": {
+ "post": {
+ "summary": "Hash returns the hash of the local KV state for consistency checking purpose.\nThis is designed for testing; do not use this in production when there\nare ongoing transactions.",
+ "operationId": "Hash",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbHashResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbHashRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Maintenance"
+ ]
+ }
+ },
+ "/v3alpha/maintenance/snapshot": {
+ "post": {
+ "summary": "Snapshot sends a snapshot of the entire backend from a member over a stream to a client.",
+ "operationId": "Snapshot",
+ "responses": {
+ "200": {
+ "description": "(streaming responses)",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbSnapshotResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbSnapshotRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Maintenance"
+ ]
+ }
+ },
+ "/v3alpha/maintenance/status": {
+ "post": {
+ "summary": "Status gets the status of the member.",
+ "operationId": "Status",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbStatusResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbStatusRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Maintenance"
+ ]
+ }
+ },
+ "/v3alpha/watch": {
+ "post": {
+ "summary": "Watch watches for events happening or that have happened. Both input and output\nare streams; the input stream is for creating and canceling watchers and the output\nstream sends events. One watch RPC can watch on multiple key ranges, streaming events\nfor several watches at once. The entire event history can be watched starting from the\nlast compaction revision.",
+ "operationId": "Watch",
+ "responses": {
+ "200": {
+ "description": "(streaming responses)",
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbWatchResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "description": "(streaming inputs)",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/etcdserverpbWatchRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Watch"
+ ]
+ }
+ }
+ },
+ "definitions": {
+ "AlarmRequestAlarmAction": {
+ "type": "string",
+ "enum": [
+ "GET",
+ "ACTIVATE",
+ "DEACTIVATE"
+ ],
+ "default": "GET"
+ },
+ "CompareCompareResult": {
+ "type": "string",
+ "enum": [
+ "EQUAL",
+ "GREATER",
+ "LESS",
+ "NOT_EQUAL"
+ ],
+ "default": "EQUAL"
+ },
+ "CompareCompareTarget": {
+ "type": "string",
+ "enum": [
+ "VERSION",
+ "CREATE",
+ "MOD",
+ "VALUE"
+ ],
+ "default": "VERSION"
+ },
+ "EventEventType": {
+ "type": "string",
+ "enum": [
+ "PUT",
+ "DELETE"
+ ],
+ "default": "PUT"
+ },
+ "RangeRequestSortOrder": {
+ "type": "string",
+ "enum": [
+ "NONE",
+ "ASCEND",
+ "DESCEND"
+ ],
+ "default": "NONE"
+ },
+ "RangeRequestSortTarget": {
+ "type": "string",
+ "enum": [
+ "KEY",
+ "VERSION",
+ "CREATE",
+ "MOD",
+ "VALUE"
+ ],
+ "default": "KEY"
+ },
+ "WatchCreateRequestFilterType": {
+ "type": "string",
+ "enum": [
+ "NOPUT",
+ "NODELETE"
+ ],
+ "default": "NOPUT",
+ "description": " - NOPUT: filter out put event.\n - NODELETE: filter out delete event."
+ },
+ "authpbPermission": {
+ "type": "object",
+ "properties": {
+ "permType": {
+ "$ref": "#/definitions/authpbPermissionType"
+ },
+ "key": {
+ "type": "string",
+ "format": "byte"
+ },
+ "range_end": {
+ "type": "string",
+ "format": "byte"
+ }
+ },
+ "title": "Permission is a single entity"
+ },
+ "authpbPermissionType": {
+ "type": "string",
+ "enum": [
+ "READ",
+ "WRITE",
+ "READWRITE"
+ ],
+ "default": "READ"
+ },
+ "etcdserverpbAlarmMember": {
+ "type": "object",
+ "properties": {
+ "memberID": {
+ "type": "string",
+ "format": "uint64",
+ "description": "memberID is the ID of the member associated with the raised alarm."
+ },
+ "alarm": {
+ "$ref": "#/definitions/etcdserverpbAlarmType",
+ "description": "alarm is the type of alarm which has been raised."
+ }
+ }
+ },
+ "etcdserverpbAlarmRequest": {
+ "type": "object",
+ "properties": {
+ "action": {
+ "$ref": "#/definitions/AlarmRequestAlarmAction",
+ "description": "action is the kind of alarm request to issue. The action\nmay GET alarm statuses, ACTIVATE an alarm, or DEACTIVATE a\nraised alarm."
+ },
+ "memberID": {
+ "type": "string",
+ "format": "uint64",
+ "description": "memberID is the ID of the member associated with the alarm. If memberID is 0, the\nalarm request covers all members."
+ },
+ "alarm": {
+ "$ref": "#/definitions/etcdserverpbAlarmType",
+ "description": "alarm is the type of alarm to consider for this request."
+ }
+ }
+ },
+ "etcdserverpbAlarmResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "alarms": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/etcdserverpbAlarmMember"
+ },
+ "description": "alarms is a list of alarms associated with the alarm request."
+ }
+ }
+ },
+ "etcdserverpbAlarmType": {
+ "type": "string",
+ "enum": [
+ "NONE",
+ "NOSPACE"
+ ],
+ "default": "NONE"
+ },
+ "etcdserverpbAuthDisableRequest": {
+ "type": "object"
+ },
+ "etcdserverpbAuthDisableResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "etcdserverpbAuthEnableRequest": {
+ "type": "object"
+ },
+ "etcdserverpbAuthEnableResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "etcdserverpbAuthRoleAddRequest": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "name is the name of the role to add to the authentication system."
+ }
+ }
+ },
+ "etcdserverpbAuthRoleAddResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "etcdserverpbAuthRoleDeleteRequest": {
+ "type": "object",
+ "properties": {
+ "role": {
+ "type": "string"
+ }
+ }
+ },
+ "etcdserverpbAuthRoleDeleteResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "etcdserverpbAuthRoleGetRequest": {
+ "type": "object",
+ "properties": {
+ "role": {
+ "type": "string"
+ }
+ }
+ },
+ "etcdserverpbAuthRoleGetResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "perm": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/authpbPermission"
+ }
+ }
+ }
+ },
+ "etcdserverpbAuthRoleGrantPermissionRequest": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "name is the name of the role which will be granted the permission."
+ },
+ "perm": {
+ "$ref": "#/definitions/authpbPermission",
+ "description": "perm is the permission to grant to the role."
+ }
+ }
+ },
+ "etcdserverpbAuthRoleGrantPermissionResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "etcdserverpbAuthRoleListRequest": {
+ "type": "object"
+ },
+ "etcdserverpbAuthRoleListResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "roles": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "etcdserverpbAuthRoleRevokePermissionRequest": {
+ "type": "object",
+ "properties": {
+ "role": {
+ "type": "string"
+ },
+ "key": {
+ "type": "string"
+ },
+ "range_end": {
+ "type": "string"
+ }
+ }
+ },
+ "etcdserverpbAuthRoleRevokePermissionResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "etcdserverpbAuthUserAddRequest": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "password": {
+ "type": "string"
+ }
+ }
+ },
+ "etcdserverpbAuthUserAddResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "etcdserverpbAuthUserChangePasswordRequest": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "name is the name of the user whose password is being changed."
+ },
+ "password": {
+ "type": "string",
+ "description": "password is the new password for the user."
+ }
+ }
+ },
+ "etcdserverpbAuthUserChangePasswordResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "etcdserverpbAuthUserDeleteRequest": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "name is the name of the user to delete."
+ }
+ }
+ },
+ "etcdserverpbAuthUserDeleteResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "etcdserverpbAuthUserGetRequest": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "etcdserverpbAuthUserGetResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "roles": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "etcdserverpbAuthUserGrantRoleRequest": {
+ "type": "object",
+ "properties": {
+ "user": {
+ "type": "string",
+ "description": "user is the name of the user which should be granted a given role."
+ },
+ "role": {
+ "type": "string",
+ "description": "role is the name of the role to grant to the user."
+ }
+ }
+ },
+ "etcdserverpbAuthUserGrantRoleResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "etcdserverpbAuthUserListRequest": {
+ "type": "object"
+ },
+ "etcdserverpbAuthUserListResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "users": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "etcdserverpbAuthUserRevokeRoleRequest": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "role": {
+ "type": "string"
+ }
+ }
+ },
+ "etcdserverpbAuthUserRevokeRoleResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "etcdserverpbAuthenticateRequest": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "password": {
+ "type": "string"
+ }
+ }
+ },
+ "etcdserverpbAuthenticateResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "token": {
+ "type": "string",
+ "title": "token is an authorized token that can be used in succeeding RPCs"
+ }
+ }
+ },
+ "etcdserverpbCompactionRequest": {
+ "type": "object",
+ "properties": {
+ "revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "revision is the key-value store revision for the compaction operation."
+ },
+ "physical": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "physical is set so the RPC will wait until the compaction is physically\napplied to the local database such that compacted entries are totally\nremoved from the backend database."
+ }
+ },
+ "description": "CompactionRequest compacts the key-value store up to a given revision. All superseded keys\nwith a revision less than the compaction revision will be removed."
+ },
+ "etcdserverpbCompactionResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "etcdserverpbCompare": {
+ "type": "object",
+ "properties": {
+ "result": {
+ "$ref": "#/definitions/CompareCompareResult",
+ "description": "result is logical comparison operation for this comparison."
+ },
+ "target": {
+ "$ref": "#/definitions/CompareCompareTarget",
+ "description": "target is the key-value field to inspect for the comparison."
+ },
+ "key": {
+ "type": "string",
+ "format": "byte",
+ "description": "key is the subject key for the comparison operation."
+ },
+ "version": {
+ "type": "string",
+ "format": "int64",
+ "title": "version is the version of the given key"
+ },
+ "create_revision": {
+ "type": "string",
+ "format": "int64",
+ "title": "create_revision is the creation revision of the given key"
+ },
+ "mod_revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "mod_revision is the last modified revision of the given key."
+ },
+ "value": {
+ "type": "string",
+ "format": "byte",
+ "description": "value is the value of the given key, in bytes."
+ }
+ }
+ },
+ "etcdserverpbDefragmentRequest": {
+ "type": "object"
+ },
+ "etcdserverpbDefragmentResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "etcdserverpbDeleteRangeRequest": {
+ "type": "object",
+ "properties": {
+ "key": {
+ "type": "string",
+ "format": "byte",
+ "description": "key is the first key to delete in the range."
+ },
+ "range_end": {
+ "type": "string",
+ "format": "byte",
+ "description": "range_end is the key following the last key to delete for the range [key, range_end).\nIf range_end is not given, the range is defined to contain only the key argument.\nIf range_end is one bit larger than the given key, then the range is all the keys\nwith the prefix (the given key).\nIf range_end is '\\0', the range is all keys greater than or equal to the key argument."
+ },
+ "prev_kv": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "If prev_kv is set, etcd gets the previous key-value pairs before deleting it.\nThe previous key-value pairs will be returned in the delete response."
+ }
+ }
+ },
+ "etcdserverpbDeleteRangeResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "deleted": {
+ "type": "string",
+ "format": "int64",
+ "description": "deleted is the number of keys deleted by the delete range request."
+ },
+ "prev_kvs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/mvccpbKeyValue"
+ },
+ "description": "if prev_kv is set in the request, the previous key-value pairs will be returned."
+ }
+ }
+ },
+ "etcdserverpbHashRequest": {
+ "type": "object"
+ },
+ "etcdserverpbHashResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "hash": {
+ "type": "integer",
+ "format": "int64",
+ "description": "hash is the hash value computed from the responding member's key-value store."
+ }
+ }
+ },
+ "etcdserverpbLeaseGrantRequest": {
+ "type": "object",
+ "properties": {
+ "TTL": {
+ "type": "string",
+ "format": "int64",
+ "description": "TTL is the advisory time-to-live in seconds."
+ },
+ "ID": {
+ "type": "string",
+ "format": "int64",
+ "description": "ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID."
+ }
+ }
+ },
+ "etcdserverpbLeaseGrantResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "ID": {
+ "type": "string",
+ "format": "int64",
+ "description": "ID is the lease ID for the granted lease."
+ },
+ "TTL": {
+ "type": "string",
+ "format": "int64",
+ "description": "TTL is the server chosen lease time-to-live in seconds."
+ },
+ "error": {
+ "type": "string"
+ }
+ }
+ },
+ "etcdserverpbLeaseKeepAliveRequest": {
+ "type": "object",
+ "properties": {
+ "ID": {
+ "type": "string",
+ "format": "int64",
+ "description": "ID is the lease ID for the lease to keep alive."
+ }
+ }
+ },
+ "etcdserverpbLeaseKeepAliveResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "ID": {
+ "type": "string",
+ "format": "int64",
+ "description": "ID is the lease ID from the keep alive request."
+ },
+ "TTL": {
+ "type": "string",
+ "format": "int64",
+ "description": "TTL is the new time-to-live for the lease."
+ }
+ }
+ },
+ "etcdserverpbLeaseRevokeRequest": {
+ "type": "object",
+ "properties": {
+ "ID": {
+ "type": "string",
+ "format": "int64",
+ "description": "ID is the lease ID to revoke. When the ID is revoked, all associated keys will be deleted."
+ }
+ }
+ },
+ "etcdserverpbLeaseRevokeResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "etcdserverpbLeaseTimeToLiveRequest": {
+ "type": "object",
+ "properties": {
+ "ID": {
+ "type": "string",
+ "format": "int64",
+ "description": "ID is the lease ID for the lease."
+ },
+ "keys": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "keys is true to query all the keys attached to this lease."
+ }
+ }
+ },
+ "etcdserverpbLeaseTimeToLiveResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "ID": {
+ "type": "string",
+ "format": "int64",
+ "description": "ID is the lease ID from the keep alive request."
+ },
+ "TTL": {
+ "type": "string",
+ "format": "int64",
+ "description": "TTL is the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds."
+ },
+ "grantedTTL": {
+ "type": "string",
+ "format": "int64",
+ "description": "GrantedTTL is the initial granted time in seconds upon lease creation/renewal."
+ },
+ "keys": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "format": "byte"
+ },
+ "description": "Keys is the list of keys attached to this lease."
+ }
+ }
+ },
+ "etcdserverpbMember": {
+ "type": "object",
+ "properties": {
+ "ID": {
+ "type": "string",
+ "format": "uint64",
+ "description": "ID is the member ID for this member."
+ },
+ "name": {
+ "type": "string",
+ "description": "name is the human-readable name of the member. If the member is not started, the name will be an empty string."
+ },
+ "peerURLs": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "peerURLs is the list of URLs the member exposes to the cluster for communication."
+ },
+ "clientURLs": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "clientURLs is the list of URLs the member exposes to clients for communication. If the member is not started, clientURLs will be empty."
+ }
+ }
+ },
+ "etcdserverpbMemberAddRequest": {
+ "type": "object",
+ "properties": {
+ "peerURLs": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "peerURLs is the list of URLs the added member will use to communicate with the cluster."
+ }
+ }
+ },
+ "etcdserverpbMemberAddResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "member": {
+ "$ref": "#/definitions/etcdserverpbMember",
+ "description": "member is the member information for the added member."
+ },
+ "members": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/etcdserverpbMember"
+ },
+ "description": "members is a list of all members after adding the new member."
+ }
+ }
+ },
+ "etcdserverpbMemberListRequest": {
+ "type": "object"
+ },
+ "etcdserverpbMemberListResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "members": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/etcdserverpbMember"
+ },
+ "description": "members is a list of all members associated with the cluster."
+ }
+ }
+ },
+ "etcdserverpbMemberRemoveRequest": {
+ "type": "object",
+ "properties": {
+ "ID": {
+ "type": "string",
+ "format": "uint64",
+ "description": "ID is the member ID of the member to remove."
+ }
+ }
+ },
+ "etcdserverpbMemberRemoveResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "members": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/etcdserverpbMember"
+ },
+ "description": "members is a list of all members after removing the member."
+ }
+ }
+ },
+ "etcdserverpbMemberUpdateRequest": {
+ "type": "object",
+ "properties": {
+ "ID": {
+ "type": "string",
+ "format": "uint64",
+ "description": "ID is the member ID of the member to update."
+ },
+ "peerURLs": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "peerURLs is the new list of URLs the member will use to communicate with the cluster."
+ }
+ }
+ },
+ "etcdserverpbMemberUpdateResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "members": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/etcdserverpbMember"
+ },
+ "description": "members is a list of all members after updating the member."
+ }
+ }
+ },
+ "etcdserverpbPutRequest": {
+ "type": "object",
+ "properties": {
+ "key": {
+ "type": "string",
+ "format": "byte",
+ "description": "key is the key, in bytes, to put into the key-value store."
+ },
+ "value": {
+ "type": "string",
+ "format": "byte",
+ "description": "value is the value, in bytes, to associate with the key in the key-value store."
+ },
+ "lease": {
+ "type": "string",
+ "format": "int64",
+ "description": "lease is the lease ID to associate with the key in the key-value store. A lease\nvalue of 0 indicates no lease."
+ },
+ "prev_kv": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "If prev_kv is set, etcd gets the previous key-value pair before changing it.\nThe previous key-value pair will be returned in the put response."
+ },
+ "ignore_value": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "If ignore_value is set, etcd updates the key using its current value.\nReturns an error if the key does not exist."
+ },
+ "ignore_lease": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "If ignore_lease is set, etcd updates the key using its current lease.\nReturns an error if the key does not exist."
+ }
+ }
+ },
+ "etcdserverpbPutResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "prev_kv": {
+ "$ref": "#/definitions/mvccpbKeyValue",
+ "description": "if prev_kv is set in the request, the previous key-value pair will be returned."
+ }
+ }
+ },
+ "etcdserverpbRangeRequest": {
+ "type": "object",
+ "properties": {
+ "key": {
+ "type": "string",
+ "format": "byte",
+ "description": "key is the first key for the range. If range_end is not given, the request only looks up key."
+ },
+ "range_end": {
+ "type": "string",
+ "format": "byte",
+ "description": "range_end is the upper bound on the requested range [key, range_end).\nIf range_end is '\\0', the range is all keys \u003e= key.\nIf range_end is key plus one (e.g., \"aa\"+1 == \"ab\", \"a\\xff\"+1 == \"b\"),\nthen the range request gets all keys prefixed with key.\nIf both key and range_end are '\\0', then the range request returns all keys."
+ },
+ "limit": {
+ "type": "string",
+ "format": "int64",
+ "description": "limit is a limit on the number of keys returned for the request. When limit is set to 0,\nit is treated as no limit."
+ },
+ "revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "revision is the point-in-time of the key-value store to use for the range.\nIf revision is less or equal to zero, the range is over the newest key-value store.\nIf the revision has been compacted, ErrCompacted is returned as a response."
+ },
+ "sort_order": {
+ "$ref": "#/definitions/RangeRequestSortOrder",
+ "description": "sort_order is the order for returned sorted results."
+ },
+ "sort_target": {
+ "$ref": "#/definitions/RangeRequestSortTarget",
+ "description": "sort_target is the key-value field to use for sorting."
+ },
+ "serializable": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "serializable sets the range request to use serializable member-local reads.\nRange requests are linearizable by default; linearizable requests have higher\nlatency and lower throughput than serializable requests but reflect the current\nconsensus of the cluster. For better performance, in exchange for possible stale reads,\na serializable range request is served locally without needing to reach consensus\nwith other nodes in the cluster."
+ },
+ "keys_only": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "keys_only when set returns only the keys and not the values."
+ },
+ "count_only": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "count_only when set returns only the count of the keys in the range."
+ },
+ "min_mod_revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "min_mod_revision is the lower bound for returned key mod revisions; all keys with\nlesser mod revisions will be filtered away."
+ },
+ "max_mod_revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "max_mod_revision is the upper bound for returned key mod revisions; all keys with\ngreater mod revisions will be filtered away."
+ },
+ "min_create_revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "min_create_revision is the lower bound for returned key create revisions; all keys with\nlesser create trevisions will be filtered away."
+ },
+ "max_create_revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "max_create_revision is the upper bound for returned key create revisions; all keys with\ngreater create revisions will be filtered away."
+ }
+ }
+ },
+ "etcdserverpbRangeResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "kvs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/mvccpbKeyValue"
+ },
+ "description": "kvs is the list of key-value pairs matched by the range request.\nkvs is empty when count is requested."
+ },
+ "more": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "more indicates if there are more keys to return in the requested range."
+ },
+ "count": {
+ "type": "string",
+ "format": "int64",
+ "description": "count is set to the number of keys within the range when requested."
+ }
+ }
+ },
+ "etcdserverpbRequestOp": {
+ "type": "object",
+ "properties": {
+ "request_range": {
+ "$ref": "#/definitions/etcdserverpbRangeRequest"
+ },
+ "request_put": {
+ "$ref": "#/definitions/etcdserverpbPutRequest"
+ },
+ "request_delete_range": {
+ "$ref": "#/definitions/etcdserverpbDeleteRangeRequest"
+ }
+ }
+ },
+ "etcdserverpbResponseHeader": {
+ "type": "object",
+ "properties": {
+ "cluster_id": {
+ "type": "string",
+ "format": "uint64",
+ "description": "cluster_id is the ID of the cluster which sent the response."
+ },
+ "member_id": {
+ "type": "string",
+ "format": "uint64",
+ "description": "member_id is the ID of the member which sent the response."
+ },
+ "revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "revision is the key-value store revision when the request was applied."
+ },
+ "raft_term": {
+ "type": "string",
+ "format": "uint64",
+ "description": "raft_term is the raft term when the request was applied."
+ }
+ }
+ },
+ "etcdserverpbResponseOp": {
+ "type": "object",
+ "properties": {
+ "response_range": {
+ "$ref": "#/definitions/etcdserverpbRangeResponse"
+ },
+ "response_put": {
+ "$ref": "#/definitions/etcdserverpbPutResponse"
+ },
+ "response_delete_range": {
+ "$ref": "#/definitions/etcdserverpbDeleteRangeResponse"
+ }
+ }
+ },
+ "etcdserverpbSnapshotRequest": {
+ "type": "object"
+ },
+ "etcdserverpbSnapshotResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader",
+ "description": "header has the current key-value store information. The first header in the snapshot\nstream indicates the point in time of the snapshot."
+ },
+ "remaining_bytes": {
+ "type": "string",
+ "format": "uint64",
+ "title": "remaining_bytes is the number of blob bytes to be sent after this message"
+ },
+ "blob": {
+ "type": "string",
+ "format": "byte",
+ "description": "blob contains the next chunk of the snapshot in the snapshot stream."
+ }
+ }
+ },
+ "etcdserverpbStatusRequest": {
+ "type": "object"
+ },
+ "etcdserverpbStatusResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "version": {
+ "type": "string",
+ "description": "version is the cluster protocol version used by the responding member."
+ },
+ "dbSize": {
+ "type": "string",
+ "format": "int64",
+ "description": "dbSize is the size of the backend database, in bytes, of the responding member."
+ },
+ "leader": {
+ "type": "string",
+ "format": "uint64",
+ "description": "leader is the member ID which the responding member believes is the current leader."
+ },
+ "raftIndex": {
+ "type": "string",
+ "format": "uint64",
+ "description": "raftIndex is the current raft index of the responding member."
+ },
+ "raftTerm": {
+ "type": "string",
+ "format": "uint64",
+ "description": "raftTerm is the current raft term of the responding member."
+ }
+ }
+ },
+ "etcdserverpbTxnRequest": {
+ "type": "object",
+ "properties": {
+ "compare": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/etcdserverpbCompare"
+ },
+ "description": "compare is a list of predicates representing a conjunction of terms.\nIf the comparisons succeed, then the success requests will be processed in order,\nand the response will contain their respective responses in order.\nIf the comparisons fail, then the failure requests will be processed in order,\nand the response will contain their respective responses in order."
+ },
+ "success": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/etcdserverpbRequestOp"
+ },
+ "description": "success is a list of requests which will be applied when compare evaluates to true."
+ },
+ "failure": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/etcdserverpbRequestOp"
+ },
+ "description": "failure is a list of requests which will be applied when compare evaluates to false."
+ }
+ },
+ "description": "From google paxosdb paper:\nOur implementation hinges around a powerful primitive which we call MultiOp. All other database\noperations except for iteration are implemented as a single call to MultiOp. A MultiOp is applied atomically\nand consists of three components:\n1. A list of tests called guard. Each test in guard checks a single entry in the database. It may check\nfor the absence or presence of a value, or compare with a given value. Two different tests in the guard\nmay apply to the same or different entries in the database. All tests in the guard are applied and\nMultiOp returns the results. If all tests are true, MultiOp executes t op (see item 2 below), otherwise\nit executes f op (see item 3 below).\n2. A list of database operations called t op. Each operation in the list is either an insert, delete, or\nlookup operation, and applies to a single database entry. Two different operations in the list may apply\nto the same or different entries in the database. These operations are executed\nif guard evaluates to\ntrue.\n3. A list of database operations called f op. Like t op, but executed if guard evaluates to false."
+ },
+ "etcdserverpbTxnResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "succeeded": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "succeeded is set to true if the compare evaluated to true or false otherwise."
+ },
+ "responses": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/etcdserverpbResponseOp"
+ },
+ "description": "responses is a list of responses corresponding to the results from applying\nsuccess if succeeded is true or failure if succeeded is false."
+ }
+ }
+ },
+ "etcdserverpbWatchCancelRequest": {
+ "type": "object",
+ "properties": {
+ "watch_id": {
+ "type": "string",
+ "format": "int64",
+ "description": "watch_id is the watcher id to cancel so that no more events are transmitted."
+ }
+ }
+ },
+ "etcdserverpbWatchCreateRequest": {
+ "type": "object",
+ "properties": {
+ "key": {
+ "type": "string",
+ "format": "byte",
+ "description": "key is the key to register for watching."
+ },
+ "range_end": {
+ "type": "string",
+ "format": "byte",
+ "description": "range_end is the end of the range [key, range_end) to watch. If range_end is not given,\nonly the key argument is watched. If range_end is equal to '\\0', all keys greater than\nor equal to the key argument are watched.\nIf the range_end is one bit larger than the given key,\nthen all keys with the prefix (the given key) will be watched."
+ },
+ "start_revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "start_revision is an optional revision to watch from (inclusive). No start_revision is \"now\"."
+ },
+ "progress_notify": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "progress_notify is set so that the etcd server will periodically send a WatchResponse with\nno events to the new watcher if there are no recent events. It is useful when clients\nwish to recover a disconnected watcher starting from a recent known revision.\nThe etcd server may decide how often it will send notifications based on current load."
+ },
+ "filters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/WatchCreateRequestFilterType"
+ },
+ "description": "filters filter the events at server side before it sends back to the watcher."
+ },
+ "prev_kv": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "If prev_kv is set, created watcher gets the previous KV before the event happens.\nIf the previous KV is already compacted, nothing will be returned."
+ }
+ }
+ },
+ "etcdserverpbWatchRequest": {
+ "type": "object",
+ "properties": {
+ "create_request": {
+ "$ref": "#/definitions/etcdserverpbWatchCreateRequest"
+ },
+ "cancel_request": {
+ "$ref": "#/definitions/etcdserverpbWatchCancelRequest"
+ }
+ }
+ },
+ "etcdserverpbWatchResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "watch_id": {
+ "type": "string",
+ "format": "int64",
+ "description": "watch_id is the ID of the watcher that corresponds to the response."
+ },
+ "created": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "created is set to true if the response is for a create watch request.\nThe client should record the watch_id and expect to receive events for\nthe created watcher from the same stream.\nAll events sent to the created watcher will attach with the same watch_id."
+ },
+ "canceled": {
+ "type": "boolean",
+ "format": "boolean",
+ "description": "canceled is set to true if the response is for a cancel watch request.\nNo further events will be sent to the canceled watcher."
+ },
+ "compact_revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "compact_revision is set to the minimum index if a watcher tries to watch\nat a compacted index.\n\nThis happens when creating a watcher at a compacted revision or the watcher cannot\ncatch up with the progress of the key-value store. \n\nThe client should treat the watcher as canceled and should not try to create any\nwatcher with the same start_revision again."
+ },
+ "cancel_reason": {
+ "type": "string",
+ "description": "cancel_reason indicates the reason for canceling the watcher."
+ },
+ "events": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/mvccpbEvent"
+ }
+ }
+ }
+ },
+ "mvccpbEvent": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "$ref": "#/definitions/EventEventType",
+ "description": "type is the kind of event. If type is a PUT, it indicates\nnew data has been stored to the key. If type is a DELETE,\nit indicates the key was deleted."
+ },
+ "kv": {
+ "$ref": "#/definitions/mvccpbKeyValue",
+ "description": "kv holds the KeyValue for the event.\nA PUT event contains current kv pair.\nA PUT event with kv.Version=1 indicates the creation of a key.\nA DELETE/EXPIRE event contains the deleted key with\nits modification revision set to the revision of deletion."
+ },
+ "prev_kv": {
+ "$ref": "#/definitions/mvccpbKeyValue",
+ "description": "prev_kv holds the key-value pair before the event happens."
+ }
+ }
+ },
+ "mvccpbKeyValue": {
+ "type": "object",
+ "properties": {
+ "key": {
+ "type": "string",
+ "format": "byte",
+ "description": "key is the key in bytes. An empty key is not allowed."
+ },
+ "create_revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "create_revision is the revision of last creation on this key."
+ },
+ "mod_revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "mod_revision is the revision of last modification on this key."
+ },
+ "version": {
+ "type": "string",
+ "format": "int64",
+ "description": "version is the version of the key. A deletion resets\nthe version to zero and any modification of the key\nincreases its version."
+ },
+ "value": {
+ "type": "string",
+ "format": "byte",
+ "description": "value is the value held by the key, in bytes."
+ },
+ "lease": {
+ "type": "string",
+ "format": "int64",
+ "description": "lease is the ID of the lease that attached to key.\nWhen the attached lease expires, the key will be deleted.\nIf lease is 0, then no lease is attached to the key."
+ }
+ }
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/Documentation/dev-guide/apispec/swagger/v3election.swagger.json b/vendor/github.com/coreos/etcd/Documentation/dev-guide/apispec/swagger/v3election.swagger.json
new file mode 100644
index 00000000..fa9a6bbc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dev-guide/apispec/swagger/v3election.swagger.json
@@ -0,0 +1,334 @@
+{
+ "swagger": "2.0",
+ "info": {
+ "title": "etcdserver/api/v3election/v3electionpb/v3election.proto",
+ "version": "version not set"
+ },
+ "schemes": [
+ "http",
+ "https"
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "paths": {
+ "/v3alpha/election/campaign": {
+ "post": {
+ "summary": "Campaign waits to acquire leadership in an election, returning a LeaderKey\nrepresenting the leadership if successful. The LeaderKey can then be used\nto issue new values on the election, transactionally guard API requests on\nleadership still being held, and resign from the election.",
+ "operationId": "Campaign",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/v3electionpbCampaignResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/v3electionpbCampaignRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Election"
+ ]
+ }
+ },
+ "/v3alpha/election/leader": {
+ "post": {
+ "summary": "Leader returns the current election proclamation, if any.",
+ "operationId": "Leader",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/v3electionpbLeaderResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/v3electionpbLeaderRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Election"
+ ]
+ }
+ },
+ "/v3alpha/election/observe": {
+ "post": {
+ "summary": "Observe streams election proclamations in-order as made by the election's\nelected leaders.",
+ "operationId": "Observe",
+ "responses": {
+ "200": {
+ "description": "(streaming responses)",
+ "schema": {
+ "$ref": "#/definitions/v3electionpbLeaderResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/v3electionpbLeaderRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Election"
+ ]
+ }
+ },
+ "/v3alpha/election/proclaim": {
+ "post": {
+ "summary": "Proclaim updates the leader's posted value with a new value.",
+ "operationId": "Proclaim",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/v3electionpbProclaimResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/v3electionpbProclaimRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Election"
+ ]
+ }
+ },
+ "/v3alpha/election/resign": {
+ "post": {
+ "summary": "Resign releases election leadership so other campaigners may acquire\nleadership on the election.",
+ "operationId": "Resign",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/v3electionpbResignResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/v3electionpbResignRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Election"
+ ]
+ }
+ }
+ },
+ "definitions": {
+ "etcdserverpbResponseHeader": {
+ "type": "object",
+ "properties": {
+ "cluster_id": {
+ "type": "string",
+ "format": "uint64",
+ "description": "cluster_id is the ID of the cluster which sent the response."
+ },
+ "member_id": {
+ "type": "string",
+ "format": "uint64",
+ "description": "member_id is the ID of the member which sent the response."
+ },
+ "revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "revision is the key-value store revision when the request was applied."
+ },
+ "raft_term": {
+ "type": "string",
+ "format": "uint64",
+ "description": "raft_term is the raft term when the request was applied."
+ }
+ }
+ },
+ "mvccpbKeyValue": {
+ "type": "object",
+ "properties": {
+ "key": {
+ "type": "string",
+ "format": "byte",
+ "description": "key is the key in bytes. An empty key is not allowed."
+ },
+ "create_revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "create_revision is the revision of last creation on this key."
+ },
+ "mod_revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "mod_revision is the revision of last modification on this key."
+ },
+ "version": {
+ "type": "string",
+ "format": "int64",
+ "description": "version is the version of the key. A deletion resets\nthe version to zero and any modification of the key\nincreases its version."
+ },
+ "value": {
+ "type": "string",
+ "format": "byte",
+ "description": "value is the value held by the key, in bytes."
+ },
+ "lease": {
+ "type": "string",
+ "format": "int64",
+ "description": "lease is the ID of the lease that attached to key.\nWhen the attached lease expires, the key will be deleted.\nIf lease is 0, then no lease is attached to the key."
+ }
+ }
+ },
+ "v3electionpbCampaignRequest": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "format": "byte",
+ "description": "name is the election's identifier for the campaign."
+ },
+ "lease": {
+ "type": "string",
+ "format": "int64",
+ "description": "lease is the ID of the lease attached to leadership of the election. If the\nlease expires or is revoked before resigning leadership, then the\nleadership is transferred to the next campaigner, if any."
+ },
+ "value": {
+ "type": "string",
+ "format": "byte",
+ "description": "value is the initial proclaimed value set when the campaigner wins the\nelection."
+ }
+ }
+ },
+ "v3electionpbCampaignResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "leader": {
+ "$ref": "#/definitions/v3electionpbLeaderKey",
+ "description": "leader describes the resources used for holding leadereship of the election."
+ }
+ }
+ },
+ "v3electionpbLeaderKey": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "format": "byte",
+ "description": "name is the election identifier that correponds to the leadership key."
+ },
+ "key": {
+ "type": "string",
+ "format": "byte",
+ "description": "key is an opaque key representing the ownership of the election. If the key\nis deleted, then leadership is lost."
+ },
+ "rev": {
+ "type": "string",
+ "format": "int64",
+ "description": "rev is the creation revision of the key. It can be used to test for ownership\nof an election during transactions by testing the key's creation revision\nmatches rev."
+ },
+ "lease": {
+ "type": "string",
+ "format": "int64",
+ "description": "lease is the lease ID of the election leader."
+ }
+ }
+ },
+ "v3electionpbLeaderRequest": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "format": "byte",
+ "description": "name is the election identifier for the leadership information."
+ }
+ }
+ },
+ "v3electionpbLeaderResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "kv": {
+ "$ref": "#/definitions/mvccpbKeyValue",
+ "description": "kv is the key-value pair representing the latest leader update."
+ }
+ }
+ },
+ "v3electionpbProclaimRequest": {
+ "type": "object",
+ "properties": {
+ "leader": {
+ "$ref": "#/definitions/v3electionpbLeaderKey",
+ "description": "leader is the leadership hold on the election."
+ },
+ "value": {
+ "type": "string",
+ "format": "byte",
+ "description": "value is an update meant to overwrite the leader's current value."
+ }
+ }
+ },
+ "v3electionpbProclaimResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ },
+ "v3electionpbResignRequest": {
+ "type": "object",
+ "properties": {
+ "leader": {
+ "$ref": "#/definitions/v3electionpbLeaderKey",
+ "description": "leader is the leadership to relinquish by resignation."
+ }
+ }
+ },
+ "v3electionpbResignResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/Documentation/dev-guide/apispec/swagger/v3lock.swagger.json b/vendor/github.com/coreos/etcd/Documentation/dev-guide/apispec/swagger/v3lock.swagger.json
new file mode 100644
index 00000000..29cec570
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dev-guide/apispec/swagger/v3lock.swagger.json
@@ -0,0 +1,146 @@
+{
+ "swagger": "2.0",
+ "info": {
+ "title": "etcdserver/api/v3lock/v3lockpb/v3lock.proto",
+ "version": "version not set"
+ },
+ "schemes": [
+ "http",
+ "https"
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "paths": {
+ "/v3alpha/lock/lock": {
+ "post": {
+ "summary": "Lock acquires a distributed shared lock on a given named lock.\nOn success, it will return a unique key that exists so long as the\nlock is held by the caller. This key can be used in conjunction with\ntransactions to safely ensure updates to etcd only occur while holding\nlock ownership. The lock is held until Unlock is called on the key or the\nlease associate with the owner expires.",
+ "operationId": "Lock",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/v3lockpbLockResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/v3lockpbLockRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Lock"
+ ]
+ }
+ },
+ "/v3alpha/lock/unlock": {
+ "post": {
+ "summary": "Unlock takes a key returned by Lock and releases the hold on lock. The\nnext Lock caller waiting for the lock will then be woken up and given\nownership of the lock.",
+ "operationId": "Unlock",
+ "responses": {
+ "200": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/v3lockpbUnlockResponse"
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/v3lockpbUnlockRequest"
+ }
+ }
+ ],
+ "tags": [
+ "Lock"
+ ]
+ }
+ }
+ },
+ "definitions": {
+ "etcdserverpbResponseHeader": {
+ "type": "object",
+ "properties": {
+ "cluster_id": {
+ "type": "string",
+ "format": "uint64",
+ "description": "cluster_id is the ID of the cluster which sent the response."
+ },
+ "member_id": {
+ "type": "string",
+ "format": "uint64",
+ "description": "member_id is the ID of the member which sent the response."
+ },
+ "revision": {
+ "type": "string",
+ "format": "int64",
+ "description": "revision is the key-value store revision when the request was applied."
+ },
+ "raft_term": {
+ "type": "string",
+ "format": "uint64",
+ "description": "raft_term is the raft term when the request was applied."
+ }
+ }
+ },
+ "v3lockpbLockRequest": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "format": "byte",
+ "description": "name is the identifier for the distributed shared lock to be acquired."
+ },
+ "lease": {
+ "type": "string",
+ "format": "int64",
+ "description": "lease is the ID of the lease that will be attached to ownership of the\nlock. If the lease expires or is revoked and currently holds the lock,\nthe lock is automatically released. Calls to Lock with the same lease will\nbe treated as a single acquistion; locking twice with the same lease is a\nno-op."
+ }
+ }
+ },
+ "v3lockpbLockResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ },
+ "key": {
+ "type": "string",
+ "format": "byte",
+ "description": "key is a key that will exist on etcd for the duration that the Lock caller\nowns the lock. Users should not modify this key or the lock may exhibit\nundefined behavior."
+ }
+ }
+ },
+ "v3lockpbUnlockRequest": {
+ "type": "object",
+ "properties": {
+ "key": {
+ "type": "string",
+ "format": "byte",
+ "description": "key is the lock ownership key granted by Lock."
+ }
+ }
+ },
+ "v3lockpbUnlockResponse": {
+ "type": "object",
+ "properties": {
+ "header": {
+ "$ref": "#/definitions/etcdserverpbResponseHeader"
+ }
+ }
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/Documentation/dev-guide/experimental_apis.md b/vendor/github.com/coreos/etcd/Documentation/dev-guide/experimental_apis.md
new file mode 100644
index 00000000..aefaeebc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dev-guide/experimental_apis.md
@@ -0,0 +1,7 @@
+# Experimental APIs and features
+
+For the most part, the etcd project is stable, but we are still moving fast! We believe in the release fast philosophy. We want to get early feedback on features still in development and stabilizing. Thus, there are, and will be more, experimental features and APIs. We plan to improve these features based on the early feedback from the community, or abandon them if there is little interest, in the next few releases. Please do not rely on any experimental features or APIs in production environment.
+
+## The current experimental API/features are:
+
+(none currently)
diff --git a/vendor/github.com/coreos/etcd/Documentation/dev-guide/grpc_naming.md b/vendor/github.com/coreos/etcd/Documentation/dev-guide/grpc_naming.md
new file mode 100644
index 00000000..4662d6ee
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dev-guide/grpc_naming.md
@@ -0,0 +1,65 @@
+# gRPC naming and discovery
+
+etcd provides a gRPC resolver to support an alternative name system that fetches endpoints from etcd for discovering gRPC services. The underlying mechanism is based on watching updates to keys prefixed with the service name.
+
+## Using etcd discovery with go-grpc
+
+The etcd client provides a gRPC resolver for resolving gRPC endpoints with an etcd backend. The resolver is initialized with an etcd client and given a target for resolution:
+
+```go
+import (
+ "github.com/coreos/etcd/clientv3"
+ etcdnaming "github.com/coreos/etcd/clientv3/naming"
+
+ "google.golang.org/grpc"
+)
+
+...
+
+cli, cerr := clientv3.NewFromURL("http://localhost:2379")
+r := &etcdnaming.GRPCResolver{Client: cli}
+b := grpc.RoundRobin(r)
+conn, gerr := grpc.Dial("my-service", grpc.WithBalancer(b))
+```
+
+## Managing service endpoints
+
+The etcd resolver treats all keys under the prefix of the resolution target following a "/" (e.g., "my-service/") with JSON-encoded go-grpc `naming.Update` values as potential service endpoints. Endpoints are added to the service by creating new keys and removed from the service by deleting keys.
+
+### Adding an endpoint
+
+New endpoints can be added to the service through `etcdctl`:
+
+```sh
+ETCDCTL_API=3 etcdctl put my-service/1.2.3.4 '{"Addr":"1.2.3.4","Metadata":"..."}'
+```
+
+The etcd client's `GRPCResolver.Update` method can also register new endpoints with a key matching the `Addr`:
+
+```go
+r.Update(context.TODO(), "my-service", naming.Update{Op: naming.Add, Addr: "1.2.3.4", Metadata: "..."})
+```
+
+### Deleting an endpoint
+
+Hosts can be deleted from the service through `etcdctl`:
+
+```sh
+ETCDCTL_API=3 etcdctl del my-service/1.2.3.4
+```
+
+The etcd client's `GRPCResolver.Update` method also supports deleting endpoints:
+
+```go
+r.Update(context.TODO(), "my-service", naming.Update{Op: naming.Delete, Addr: "1.2.3.4"})
+```
+
+### Registering an endpoint with a lease
+
+Registering an endpoint with a lease ensures that if the host can't maintain a keepalive heartbeat (e.g., its machine fails), it will be removed from the service:
+
+```sh
+lease=`ETCDCTL_API=3 etcdctl lease grant 5 | cut -f2 -d' '`
+ETCDCTL_API=3 etcdctl put --lease=$lease my-service/1.2.3.4 '{"Addr":"1.2.3.4","Metadata":"..."}'
+ETCDCTL_API=3 etcdctl lease keep-alive $lease
+```
diff --git a/vendor/github.com/coreos/etcd/Documentation/dev-guide/interacting_v3.md b/vendor/github.com/coreos/etcd/Documentation/dev-guide/interacting_v3.md
new file mode 100644
index 00000000..dd794213
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dev-guide/interacting_v3.md
@@ -0,0 +1,475 @@
+# Interacting with etcd
+
+Users mostly interact with etcd by putting or getting the value of a key. This section describes how to do that by using etcdctl, a command line tool for interacting with etcd server. The concepts described here should apply to the gRPC APIs or client library APIs.
+
+By default, etcdctl talks to the etcd server with the v2 API for backward compatibility. For etcdctl to speak to etcd using the v3 API, the API version must be set to version 3 via the `ETCDCTL_API` environment variable.
+
+```bash
+export ETCDCTL_API=3
+```
+
+## Find versions
+
+etcdctl version and Server API version can be useful in finding the appropriate commands to be used for performing various operations on etcd.
+
+Here is the command to find the versions:
+
+```bash
+$ etcdctl version
+etcdctl version: 3.1.0-alpha.0+git
+API version: 3.1
+```
+
+## Write a key
+
+Applications store keys into the etcd cluster by writing to keys. Every stored key is replicated to all etcd cluster members through the Raft protocol to achieve consistency and reliability.
+
+Here is the command to set the value of key `foo` to `bar`:
+
+```bash
+$ etcdctl put foo bar
+OK
+```
+
+Also a key can be set for a specified interval of time by attaching lease to it.
+
+Here is the command to set the value of key `foo1` to `bar1` for 10s.
+
+```bash
+$ etcdctl put foo1 bar1 --lease=1234abcd
+OK
+```
+
+Note: The lease id `1234abcd` in the above command refers to id returned on creating the lease of 10s. This id can then be attached to the key.
+
+## Read keys
+
+Applications can read values of keys from an etcd cluster. Queries may read a single key, or a range of keys.
+
+Suppose the etcd cluster has stored the following keys:
+
+```bash
+foo = bar
+foo1 = bar1
+foo2 = bar2
+foo3 = bar3
+```
+
+Here is the command to read the value of key `foo`:
+
+```bash
+$ etcdctl get foo
+foo
+bar
+```
+
+Here is the command to read the value of key `foo` in hex format:
+
+```bash
+$ etcdctl get foo --hex
+\x66\x6f\x6f # Key
+\x62\x61\x72 # Value
+```
+
+Here is the command to read only the value of key `foo`:
+
+```bash
+$ etcdctl get foo --print-value-only
+bar
+```
+
+Here is the command to range over the keys from `foo` to `foo3`:
+
+```bash
+$ etcdctl get foo foo3
+foo
+bar
+foo1
+bar1
+foo2
+bar2
+```
+
+Note that `foo3` is excluded since the range is over the half-open interval `[foo, foo3)`, excluding `foo3`.
+
+Here is the command to range over all keys prefixed with `foo`:
+
+```bash
+$ etcdctl get --prefix foo
+foo
+bar
+foo1
+bar1
+foo2
+bar2
+foo3
+bar3
+```
+
+Here is the command to range over all keys prefixed with `foo`, limiting the number of results to 2:
+
+```bash
+$ etcdctl get --prefix --limit=2 foo
+foo
+bar
+foo1
+bar1
+```
+
+## Read past version of keys
+
+Applications may want to read superseded versions of a key. For example, an application may wish to roll back to an old configuration by accessing an earlier version of a key. Alternatively, an application may want a consistent view over multiple keys through multiple requests by accessing key history.
+Since every modification to the etcd cluster key-value store increments the global revision of an etcd cluster, an application can read superseded keys by providing an older etcd revision.
+
+Suppose an etcd cluster already has the following keys:
+
+```bash
+foo = bar # revision = 2
+foo1 = bar1 # revision = 3
+foo = bar_new # revision = 4
+foo1 = bar1_new # revision = 5
+```
+
+Here are an example to access the past versions of keys:
+
+```bash
+$ etcdctl get --prefix foo # access the most recent versions of keys
+foo
+bar_new
+foo1
+bar1_new
+
+$ etcdctl get --prefix --rev=4 foo # access the versions of keys at revision 4
+foo
+bar_new
+foo1
+bar1
+
+$ etcdctl get --prefix --rev=3 foo # access the versions of keys at revision 3
+foo
+bar
+foo1
+bar1
+
+$ etcdctl get --prefix --rev=2 foo # access the versions of keys at revision 2
+foo
+bar
+
+$ etcdctl get --prefix --rev=1 foo # access the versions of keys at revision 1
+```
+
+## Read keys which are greater than or equal to the byte value of the specified key
+
+Applications may want to read keys which are greater than or equal to the byte value of the specified key.
+
+Suppose an etcd cluster already has the following keys:
+
+```bash
+a = 123
+b = 456
+z = 789
+```
+
+Here is the command to read keys which are greater than or equal to the byte value of key `b` :
+
+```bash
+$ etcdctl get --from-key b
+b
+456
+z
+789
+```
+
+## Delete keys
+
+Applications can delete a key or a range of keys from an etcd cluster.
+
+Suppose an etcd cluster already has the following keys:
+
+```bash
+foo = bar
+foo1 = bar1
+foo3 = bar3
+zoo = val
+zoo1 = val1
+zoo2 = val2
+a = 123
+b = 456
+z = 789
+```
+
+Here is the command to delete key `foo`:
+
+```bash
+$ etcdctl del foo
+1 # one key is deleted
+```
+
+Here is the command to delete keys ranging from `foo` to `foo9`:
+
+```bash
+$ etcdctl del foo foo9
+2 # two keys are deleted
+```
+
+Here is the command to delete key `zoo` with the deleted key value pair returned:
+
+```bash
+$ etcdctl del --prev-kv zoo
+1 # one key is deleted
+zoo # deleted key
+val # the value of the deleted key
+```
+
+Here is the command to delete keys having prefix as `zoo`:
+
+```bash
+$ etcdctl del --prefix zoo
+2 # two keys are deleted
+```
+
+Here is the command to delete keys which are greater than or equal to the byte value of key `b` :
+
+```bash
+$ etcdctl del --from-key b
+2 # two keys are deleted
+```
+
+## Watch key changes
+
+Applications can watch on a key or a range of keys to monitor for any updates.
+
+Here is the command to watch on key `foo`:
+
+```bash
+$ etcdctl watch foo
+# in another terminal: etcdctl put foo bar
+PUT
+foo
+bar
+```
+
+Here is the command to watch on key `foo` in hex format:
+
+```bash
+$ etcdctl watch foo --hex
+# in another terminal: etcdctl put foo bar
+PUT
+\x66\x6f\x6f # Key
+\x62\x61\x72 # Value
+```
+
+Here is the command to watch on a range key from `foo` to `foo9`:
+
+```bash
+$ etcdctl watch foo foo9
+# in another terminal: etcdctl put foo bar
+PUT
+foo
+bar
+# in another terminal: etcdctl put foo1 bar1
+PUT
+foo1
+bar1
+```
+
+Here is the command to watch on keys having prefix `foo`:
+
+```bash
+$ etcdctl watch --prefix foo
+# in another terminal: etcdctl put foo bar
+PUT
+foo
+bar
+# in another terminal: etcdctl put fooz1 barz1
+PUT
+fooz1
+barz1
+```
+
+Here is the command to watch on multiple keys `foo` and `zoo`:
+
+```bash
+$ etcdctl watch -i
+$ watch foo
+$ watch zoo
+# in another terminal: etcdctl put foo bar
+PUT
+foo
+bar
+# in another terminal: etcdctl put zoo val
+PUT
+zoo
+val
+```
+
+## Watch historical changes of keys
+
+Applications may want to watch for historical changes of keys in etcd. For example, an application may wish to receive all the modifications of a key; if the application stays connected to etcd, then `watch` is good enough. However, if the application or etcd fails, a change may happen during the failure, and the application will not receive the update in real time. To guarantee the update is delivered, the application must be able to watch for historical changes to keys. To do this, an application can specify a historical revision on a watch, just like reading past version of keys.
+
+Suppose we finished the following sequence of operations:
+
+```bash
+$ etcdctl put foo bar # revision = 2
+OK
+$ etcdctl put foo1 bar1 # revision = 3
+OK
+$ etcdctl put foo bar_new # revision = 4
+OK
+$ etcdctl put foo1 bar1_new # revision = 5
+OK
+```
+
+Here is an example to watch the historical changes:
+
+```bash
+# watch for changes on key `foo` since revision 2
+$ etcdctl watch --rev=2 foo
+PUT
+foo
+bar
+PUT
+foo
+bar_new
+```
+
+```bash
+# watch for changes on key `foo` since revision 3
+$ etcdctl watch --rev=3 foo
+PUT
+foo
+bar_new
+```
+
+Here is an example to watch only from the last historical change:
+
+```bash
+# watch for changes on key `foo` and return last revision value along with modified value
+$ etcdctl watch --prev-kv foo
+# in another terminal: etcdctl put foo bar_latest
+PUT
+foo # key
+bar_new # last value of foo key before modification
+foo # key
+bar_latest # value of foo key after modification
+```
+
+## Compacted revisions
+
+As we mentioned, etcd keeps revisions so that applications can read past versions of keys. However, to avoid accumulating an unbounded amount of history, it is important to compact past revisions. After compacting, etcd removes historical revisions, releasing resources for future use. All superseded data with revisions before the compacted revision will be unavailable.
+
+Here is the command to compact the revisions:
+
+```bash
+$ etcdctl compact 5
+compacted revision 5
+
+# any revisions before the compacted one are not accessible
+$ etcdctl get --rev=4 foo
+Error: rpc error: code = 11 desc = etcdserver: mvcc: required revision has been compacted
+```
+
+Note: The current revision of etcd server can be found using get command on any key (existent or non-existent) in json format. Example is shown below for mykey which does not exist in etcd server:
+
+```bash
+$ etcdctl get mykey -w=json
+{"header":{"cluster_id":14841639068965178418,"member_id":10276657743932975437,"revision":15,"raft_term":4}}
+```
+
+## Grant leases
+
+Applications can grant leases for keys from an etcd cluster. When a key is attached to a lease, its lifetime is bound to the lease's lifetime which in turn is governed by a time-to-live (TTL). Each lease has a minimum time-to-live (TTL) value specified by the application at grant time. The lease's actual TTL value is at least the minimum TTL and is chosen by the etcd cluster. Once a lease's TTL elapses, the lease expires and all attached keys are deleted.
+
+Here is the command to grant a lease:
+
+```bash
+# grant a lease with 10 second TTL
+$ etcdctl lease grant 10
+lease 32695410dcc0ca06 granted with TTL(10s)
+
+# attach key foo to lease 32695410dcc0ca06
+$ etcdctl put --lease=32695410dcc0ca06 foo bar
+OK
+```
+
+## Revoke leases
+
+Applications revoke leases by lease ID. Revoking a lease deletes all of its attached keys.
+
+Suppose we finished the following sequence of operations:
+
+```bash
+$ etcdctl lease grant 10
+lease 32695410dcc0ca06 granted with TTL(10s)
+$ etcdctl put --lease=32695410dcc0ca06 foo bar
+OK
+```
+
+Here is the command to revoke the same lease:
+
+```bash
+$ etcdctl lease revoke 32695410dcc0ca06
+lease 32695410dcc0ca06 revoked
+
+$ etcdctl get foo
+# empty response since foo is deleted due to lease revocation
+```
+
+## Keep leases alive
+
+Applications can keep a lease alive by refreshing its TTL so it does not expire.
+
+Suppose we finished the following sequence of operations:
+
+```bash
+$ etcdctl lease grant 10
+lease 32695410dcc0ca06 granted with TTL(10s)
+```
+
+Here is the command to keep the same lease alive:
+
+```bash
+$ etcdctl lease keep-alive 32695410dcc0ca06
+lease 32695410dcc0ca06 keepalived with TTL(100)
+lease 32695410dcc0ca06 keepalived with TTL(100)
+lease 32695410dcc0ca06 keepalived with TTL(100)
+...
+```
+
+## Get lease information
+
+Applications may want to know about lease information, so that they can be renewed or to check if the lease still exists or it has expired. Applications may also want to know the keys to which a particular lease is attached.
+
+Suppose we finished the following sequence of operations:
+
+```bash
+# grant a lease with 500 second TTL
+$ etcdctl lease grant 500
+lease 694d5765fc71500b granted with TTL(500s)
+
+# attach key zoo1 to lease 694d5765fc71500b
+$ etcdctl put zoo1 val1 --lease=694d5765fc71500b
+OK
+
+# attach key zoo2 to lease 694d5765fc71500b
+$ etcdctl put zoo2 val2 --lease=694d5765fc71500b
+OK
+```
+
+Here is the command to get information about the lease:
+
+```bash
+$ etcdctl lease timetolive 694d5765fc71500b
+lease 694d5765fc71500b granted with TTL(500s), remaining(258s)
+```
+
+Here is the command to get information about the lease along with the keys attached with the lease:
+
+```bash
+$ etcdctl lease timetolive --keys 694d5765fc71500b
+lease 694d5765fc71500b granted with TTL(500s), remaining(132s), attached keys([zoo2 zoo1])
+
+# if the lease has expired or does not exist it will give the below response:
+Error: etcdserver: requested lease not found
+```
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/dev-guide/limit.md b/vendor/github.com/coreos/etcd/Documentation/dev-guide/limit.md
new file mode 100644
index 00000000..9452b536
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dev-guide/limit.md
@@ -0,0 +1,10 @@
+# System limits
+
+## Request size limit
+
+etcd is designed to handle small key value pairs typical for metadata. Larger requests will work, but may increase the latency of other requests. For the time being, etcd guarantees to support RPC requests with up to 1MB of data. In the future, the size limit may be loosened or made configurable.
+
+## Storage size limit
+
+The default storage size limit is 2GB, configurable with `--quota-backend-bytes` flag; supports up to 8GB.
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/dev-guide/local_cluster.md b/vendor/github.com/coreos/etcd/Documentation/dev-guide/local_cluster.md
new file mode 100644
index 00000000..cbd1f070
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dev-guide/local_cluster.md
@@ -0,0 +1,90 @@
+# Setup a local cluster
+
+For testing and development deployments, the quickest and easiest way is to set up a local cluster. For a production deployment, refer to the [clustering][clustering] section.
+
+## Local standalone cluster
+
+Deploying an etcd cluster as a standalone cluster is straightforward. Start it with just one command:
+
+```
+$ ./etcd
+...
+```
+
+The started etcd member listens on `localhost:2379` for client requests.
+
+To interact with the started cluster by using etcdctl:
+
+```
+# use API version 3
+$ export ETCDCTL_API=3
+
+$ ./etcdctl put foo bar
+OK
+
+$ ./etcdctl get foo
+bar
+```
+
+## Local multi-member cluster
+
+A `Procfile` at the base of this git repo is provided to easily set up a local multi-member cluster. To start a multi-member cluster go to the root of an etcd source tree and run:
+
+```
+# install goreman program to control Profile-based applications.
+$ go get github.com/mattn/goreman
+$ goreman -f Procfile start
+...
+```
+
+The started members listen on `localhost:2379`, `localhost:22379`, and `localhost:32379` for client requests respectively.
+
+To interact with the started cluster by using etcdctl:
+
+```
+# use API version 3
+$ export ETCDCTL_API=3
+
+$ etcdctl --write-out=table --endpoints=localhost:2379 member list
++------------------+---------+--------+------------------------+------------------------+
+| ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS |
++------------------+---------+--------+------------------------+------------------------+
+| 8211f1d0f64f3269 | started | infra1 | http://127.0.0.1:2380 | http://127.0.0.1:2379 |
+| 91bc3c398fb3c146 | started | infra2 | http://127.0.0.1:22380 | http://127.0.0.1:22379 |
+| fd422379fda50e48 | started | infra3 | http://127.0.0.1:32380 | http://127.0.0.1:32379 |
++------------------+---------+--------+------------------------+------------------------+
+
+$ etcdctl put foo bar
+OK
+```
+
+To exercise etcd's fault tolerance, kill a member:
+
+```
+# kill etcd2
+$ goreman run stop etcd2
+
+$ etcdctl put key hello
+OK
+
+$ etcdctl get key
+hello
+
+# try to get key from the killed member
+$ etcdctl --endpoints=localhost:22379 get key
+2016/04/18 23:07:35 grpc: Conn.resetTransport failed to create client transport: connection error: desc = "transport: dial tcp 127.0.0.1:22379: getsockopt: connection refused"; Reconnecting to "localhost:22379"
+Error: grpc: timed out trying to connect
+
+# restart the killed member
+$ goreman run restart etcd2
+
+# get the key from restarted member
+$ etcdctl --endpoints=localhost:22379 get key
+hello
+```
+
+To learn more about interacting with etcd, read [interacting with etcd section][interacting].
+
+[interacting]: ./interacting_v3.md
+[clustering]: ../op-guide/clustering.md
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/dev-internal/discovery_protocol.md b/vendor/github.com/coreos/etcd/Documentation/dev-internal/discovery_protocol.md
new file mode 100644
index 00000000..34da2b2c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dev-internal/discovery_protocol.md
@@ -0,0 +1,113 @@
+# Discovery service protocol
+
+Discovery service protocol helps new etcd member to discover all other members in cluster bootstrap phase using a shared discovery URL.
+
+Discovery service protocol is _only_ used in cluster bootstrap phase, and cannot be used for runtime reconfiguration or cluster monitoring.
+
+The protocol uses a new discovery token to bootstrap one _unique_ etcd cluster. Remember that one discovery token can represent only one etcd cluster. As long as discovery protocol on this token starts, even if it fails halfway, it must not be used to bootstrap another etcd cluster.
+
+The rest of this article will walk through the discovery process with examples that correspond to a self-hosted discovery cluster. The public discovery service, discovery.etcd.io, functions the same way, but with a layer of polish to abstract away ugly URLs, generate UUIDs automatically, and provide some protections against excessive requests. At its core, the public discovery service still uses an etcd cluster as the data store as described in this document.
+
+## Protocol workflow
+
+The idea of discovery protocol is to use an internal etcd cluster to coordinate bootstrap of a new cluster. First, all new members interact with discovery service and help to generate the expected member list. Then each new member bootstraps its server using this list, which performs the same functionality as -initial-cluster flag.
+
+In the following example workflow, we will list each step of protocol in curl format for ease of understanding.
+
+By convention the etcd discovery protocol uses the key prefix `_etcd/registry`. If `http://example.com` hosts an etcd cluster for discovery service, a full URL to discovery keyspace will be `http://example.com/v2/keys/_etcd/registry`. We will use this as the URL prefix in the example.
+
+### Creating a new discovery token
+
+Generate a unique token that will identify the new cluster. This will be used as a unique prefix in discovery keyspace in the following steps. An easy way to do this is to use `uuidgen`:
+
+```
+UUID=$(uuidgen)
+```
+
+### Specifying the expected cluster size
+
+The discovery token expects a cluster size that must be specified. The size is used by the discovery service to know when it has found all members that will initially form the cluster.
+
+```
+curl -X PUT http://example.com/v2/keys/_etcd/registry/${UUID}/_config/size -d value=${cluster_size}
+```
+
+Usually the cluster size is 3, 5 or 7. Check [optimal cluster size][cluster-size] for more details.
+
+### Bringing up etcd processes
+
+Given the discovery URL, use it as `-discovery` flag and bring up etcd processes. Every etcd process will follow this next few steps internally if given a `-discovery` flag.
+
+### Registering itself
+
+The first thing for etcd process is to register itself into the discovery URL as a member. This is done by creating member ID as a key in the discovery URL.
+
+```
+curl -X PUT http://example.com/v2/keys/_etcd/registry/${UUID}/${member_id}?prevExist=false -d value="${member_name}=${member_peer_url_1}&${member_name}=${member_peer_url_2}"
+```
+
+### Checking the status
+
+It checks the expected cluster size and registration status in discovery URL, and decides what the next action is.
+
+```
+curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID}/_config/size
+curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID}
+```
+
+If registered members are still not enough, it will wait for left members to appear.
+
+If the number of registered members is bigger than the expected size N, it treats the first N registered members as the member list for the cluster. If the member itself is in the member list, the discovery procedure succeeds and it fetches all peers through the member list. If it is not in the member list, the discovery procedure finishes with the failure that the cluster has been full.
+
+In etcd implementation, the member may check the cluster status even before registering itself. So it could fail quickly if the cluster has been full.
+
+### Waiting for all members
+
+The wait process is described in detail in the [etcd API documentation][api].
+
+```
+curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID}?wait=true&waitIndex=${current_etcd_index}
+```
+
+It keeps waiting until finding all members.
+
+## Public discovery service
+
+CoreOS Inc. hosts a public discovery service at https://discovery.etcd.io/ , which provides some nice features for ease of use.
+
+### Mask key prefix
+
+Public discovery service will redirect `https://discovery.etcd.io/${UUID}` to etcd cluster behind for the key at `/v2/keys/_etcd/registry`. It masks register key prefix for short and readable discovery url.
+
+### Get new token
+
+```
+GET /new
+
+Sent query:
+ size=${cluster_size}
+Possible status codes:
+ 200 OK
+ 400 Bad Request
+200 Body:
+ generated discovery url
+```
+
+The generation process in the service follows the steps from [Creating a New Discovery Token][new-discovery-token] to [Specifying the Expected Cluster Size][expected-cluster-size].
+
+### Check discovery status
+
+```
+GET /${UUID}
+```
+
+The status for this discovery token, including the machines that have been registered, can be checked by requesting the value of the UUID.
+
+### Open-source repository
+
+The repository is located at https://github.com/coreos/discovery.etcd.io. It could be used to build a custom discovery service.
+
+[api]: ../v2/api.md#waiting-for-a-change
+[cluster-size]: ../v2/admin_guide.md#optimal-cluster-size
+[expected-cluster-size]: #specifying-the-expected-cluster-size
+[new-discovery-token]: #creating-a-new-discovery-token
diff --git a/vendor/github.com/coreos/etcd/Documentation/dev-internal/logging.md b/vendor/github.com/coreos/etcd/Documentation/dev-internal/logging.md
new file mode 100644
index 00000000..aa97dc2b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dev-internal/logging.md
@@ -0,0 +1,29 @@
+# Logging conventions
+
+etcd uses the [capnslog][capnslog] library for logging application output categorized into *levels*. A log message's level is determined according to these conventions:
+
+* Error: Data has been lost, a request has failed for a bad reason, or a required resource has been lost
+ * Examples:
+ * A failure to allocate disk space for WAL
+
+* Warning: (Hopefully) Temporary conditions that may cause errors, but may work fine. A replica disappearing (that may reconnect) is a warning.
+ * Examples:
+ * Failure to send raft message to a remote peer
+ * Failure to receive heartbeat message within the configured election timeout
+
+* Notice: Normal, but important (uncommon) log information.
+ * Examples:
+ * Add a new node into the cluster
+ * Add a new user into auth subsystem
+
+* Info: Normal, working log information, everything is fine, but helpful notices for auditing or common operations.
+ * Examples:
+ * Startup configuration
+ * Start to do snapshot
+
+* Debug: Everything is still fine, but even common operations may be logged, and less helpful but more quantity of notices.
+ * Examples:
+ * Send a normal message to a remote peer
+ * Write a log entry to disk
+
+[capnslog]: https://github.com/coreos/pkg/tree/master/capnslog
diff --git a/vendor/github.com/coreos/etcd/Documentation/dev-internal/release.md b/vendor/github.com/coreos/etcd/Documentation/dev-internal/release.md
new file mode 100644
index 00000000..19153a0c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dev-internal/release.md
@@ -0,0 +1,118 @@
+# etcd release guide
+
+The guide talks about how to release a new version of etcd.
+
+The procedure includes some manual steps for sanity checking, but it can probably be further scripted. Please keep this document up-to-date if making changes to the release process.
+
+## Prepare release
+
+Set desired version as environment variable for following steps. Here is an example to release 2.3.0:
+
+```
+export VERSION=v2.3.0
+export PREV_VERSION=v2.2.5
+```
+
+All releases version numbers follow the format of [semantic versioning 2.0.0](http://semver.org/).
+
+### Major, minor version release, or its pre-release
+
+- Ensure the relevant milestone on GitHub is complete. All referenced issues should be closed, or moved elsewhere.
+- Remove this release from [roadmap](https://github.com/coreos/etcd/blob/master/ROADMAP.md), if necessary.
+- Ensure the latest upgrade documentation is available.
+- Bump [hardcoded MinClusterVerion in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L29), if necessary.
+- Add feature capability maps for the new version, if necessary.
+
+### Patch version release
+
+- Discuss about commits that are backported to the patch release. The commits should not include merge commits.
+- Cherry-pick these commits starting from the oldest one into stable branch.
+
+## Write release note
+
+- Write introduction for the new release. For example, what major bug we fix, what new features we introduce or what performance improvement we make.
+- Put `[GH XXXX]` at the head of change line to reference Pull Request that introduces the change. Moreover, add a link on it to jump to the Pull Request.
+- Find PRs with `release-note` label and explain them in `NEWS` file, as a straightforward summary of changes for end-users.
+
+## Tag version
+
+- Bump [hardcoded Version in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L30) to the latest version `${VERSION}`.
+- Ensure all tests on CI system are passed.
+- Manually check etcd is buildable in Linux, Darwin and Windows.
+- Manually check upgrade etcd cluster of previous minor version works well.
+- Manually check new features work well.
+- Add a signed tag through `git tag -s ${VERSION}`.
+- Sanity check tag correctness through `git show tags/$VERSION`.
+- Push the tag to GitHub through `git push origin tags/$VERSION`. This assumes `origin` corresponds to "https://github.com/coreos/etcd".
+
+## Build release binaries and images
+
+- Ensure `acbuild` is available.
+- Ensure `docker` is available.
+
+Run release script in root directory:
+
+```
+./scripts/release.sh ${VERSION}
+```
+
+It generates all release binaries and images under directory ./release.
+
+## Sign binaries, images, and source code
+
+etcd project key must be used to sign the generated binaries and images.`$SUBKEYID` is the key ID of etcd project Yubikey. Connect the key and run `gpg2 --card-status` to get the ID.
+
+The following commands are used for public release sign:
+
+```
+cd release
+for i in etcd-*{.zip,.tar.gz}; do gpg2 --default-key $SUBKEYID --armor --output ${i}.asc --detach-sign ${i}; done
+for i in etcd-*{.zip,.tar.gz}; do gpg2 --verify ${i}.asc ${i}; done
+
+# sign zipped source code files
+wget https://github.com/coreos/etcd/archive/${VERSION}.zip
+gpg2 --armor --default-key $SUBKEYID --output ${VERSION}.zip.asc --detach-sign ${VERSION}.zip
+gpg2 --verify ${VERSION}.zip.asc ${VERSION}.zip
+
+wget https://github.com/coreos/etcd/archive/${VERSION}.tar.gz
+gpg2 --armor --default-key $SUBKEYID --output ${VERSION}.tar.gz.asc --detach-sign ${VERSION}.tar.gz
+gpg2 --verify ${VERSION}.tar.gz.asc ${VERSION}.tar.gz
+```
+
+The public key for GPG signing can be found at [CoreOS Application Signing Key](https://coreos.com/security/app-signing-key)
+
+
+## Publish release page in GitHub
+
+- Set release title as the version name.
+- Follow the format of previous release pages.
+- Attach the generated binaries, aci image and signatures.
+- Select whether it is a pre-release.
+- Publish the release!
+
+## Publish docker image in Quay.io
+
+- Push docker image:
+
+```
+docker login quay.io
+docker push quay.io/coreos/etcd:${VERSION}
+```
+
+- Add `latest` tag to the new image on [quay.io](https://quay.io/repository/coreos/etcd?tag=latest&tab=tags) if this is a stable release.
+
+## Announce to the etcd-dev Googlegroup
+
+- Follow the format of [previous release emails](https://groups.google.com/forum/#!forum/etcd-dev).
+- Make sure to include a list of authors that contributed since the previous release - something like the following might be handy:
+
+```
+git log ...${PREV_VERSION} --pretty=format:"%an" | sort | uniq | tr '\n' ',' | sed -e 's#,#, #g' -e 's#, $##'
+```
+
+- Send email to etcd-dev@googlegroups.com
+
+## Post release
+
+- Create new stable branch through `git push origin ${VERSION_MAJOR}.${VERSION_MINOR}` if this is a major stable release. This assumes `origin` corresponds to "https://github.com/coreos/etcd".
+- Bump [hardcoded Version in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L30) to the version `${VERSION}+git`.
diff --git a/vendor/github.com/coreos/etcd/Documentation/dl_build.md b/vendor/github.com/coreos/etcd/Documentation/dl_build.md
new file mode 100644
index 00000000..3600d5c2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/dl_build.md
@@ -0,0 +1,67 @@
+# Download and build
+
+## System requirements
+
+The etcd performance benchmarks run etcd on 8 vCPU, 16GB RAM, 50GB SSD GCE instances, but any relatively modern machine with low latency storage and a few gigabytes of memory should suffice for most use cases. Applications with large v2 data stores will require more memory than a large v3 data store since data is kept in anonymous memory instead of memory mapped from a file. than For running etcd on a cloud provider, we suggest at least a medium instance on AWS or a standard-1 instance on GCE.
+
+## Download the pre-built binary
+
+The easiest way to get etcd is to use one of the pre-built release binaries which are available for OSX, Linux, Windows, appc, and Docker. Instructions for using these binaries are on the [GitHub releases page][github-release].
+
+## Build the latest version
+
+For those wanting to try the very latest version, build etcd from the `master` branch. [Go](https://golang.org/) version 1.8+ is required to build the latest version of etcd. To ensure etcd is built against well-tested libraries, etcd vendors its dependencies for official release binaries. However, etcd's vendoring is also optional to avoid potential import conflicts when embedding the etcd server or using the etcd client.
+
+To build `etcd` from the `master` branch without a `GOPATH` using the official `build` script:
+
+```sh
+$ git clone https://github.com/coreos/etcd.git
+$ cd etcd
+$ ./build
+$ ./bin/etcd
+```
+
+To build a vendored `etcd` from the `master` branch via `go get`:
+
+```sh
+# GOPATH should be set
+$ echo $GOPATH
+/Users/example/go
+$ go get github.com/coreos/etcd/cmd/etcd
+$ $GOPATH/bin/etcd
+```
+
+To build `etcd` from the `master` branch without vendoring (may not build due to upstream conflicts):
+
+```sh
+# GOPATH should be set
+$ echo $GOPATH
+/Users/example/go
+$ go get github.com/coreos/etcd
+$ $GOPATH/bin/etcd
+```
+
+## Test the installation
+
+Check the etcd binary is built correctly by starting etcd and setting a key.
+
+Start etcd:
+
+```
+$ ./bin/etcd
+```
+
+Set a key:
+
+```
+$ ETCDCTL_API=3 ./bin/etcdctl put foo bar
+OK
+```
+
+If OK is printed, then etcd is working!
+
+[github-release]: https://github.com/coreos/etcd/releases/
+[go]: https://golang.org/doc/install
+[build-script]: ../build
+[cmd-directory]: ../cmd
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/docs.md b/vendor/github.com/coreos/etcd/Documentation/docs.md
new file mode 100644
index 00000000..b39a6eac
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/docs.md
@@ -0,0 +1,113 @@
+# Documentation
+
+etcd is a distributed key-value store designed to reliably and quickly preserve and provide access to critical data. It enables reliable distributed coordination through distributed locking, leader elections, and write barriers. An etcd cluster is intended for high availability and permanent data storage and retrieval.
+
+## Getting started
+
+New etcd users and developers should get started by [downloading and building][download_build] etcd. After getting etcd, follow this [quick demo][demo] to see the basics of creating and working with an etcd cluster.
+
+## Developing with etcd
+
+The easiest way to get started using etcd as a distributed key-value store is to [set up a local cluster][local_cluster].
+
+ - [Setting up local clusters][local_cluster]
+ - [Interacting with etcd][interacting]
+ - gRPC [etcd core][api_ref] and [etcd concurrency][api_concurrency_ref] API references
+ - [HTTP JSON API through the gRPC gateway][api_grpc_gateway]
+ - [gRPC naming and discovery][grpc_naming]
+ - [Client][namespace_client] and [proxy][namespace_proxy] namespacing
+ - [Embedding etcd][embed_etcd]
+ - [Experimental features and APIs][experimental]
+ - [System limits][system-limit]
+
+## Operating etcd clusters
+
+Administrators who need to create reliable and scalable key-value stores for the developers they support should begin with a [cluster on multiple machines][clustering].
+
+ - [Setting up etcd clusters][clustering]
+ - [Setting up etcd gateways][gateway]
+ - [Setting up etcd gRPC proxy][grpc_proxy]
+ - [Hardware recommendations][hardware]
+ - [Configuration][conf]
+ - [Security][security]
+ - [Authentication][authentication]
+ - [Monitoring][monitoring]
+ - [Maintenance][maintenance]
+ - [Understand failures][failures]
+ - [Disaster recovery][recovery]
+ - [Performance][performance]
+ - [Versioning][versioning]
+
+### Platform guides
+
+ - [Supported systems][supported_platforms]
+ - [Docker container][container_docker]
+ - [Container Linux, systemd][container_linux_platform]
+ - [rkt container][container_rkt]
+ - [Amazon Web Services][aws_platform]
+ - [FreeBSD][freebsd_platform]
+
+### Upgrading and compatibility
+
+ - [Migrate applications from using API v2 to API v3][v2_migration]
+ - [Upgrading a v2.3 cluster to v3.0][v3_upgrade]
+ - [Upgrading a v3.0 cluster to v3.1][v31_upgrade]
+ - [Upgrading a v3.1 cluster to v3.2][v32_upgrade]
+
+## Learning
+
+To learn more about the concepts and internals behind etcd, read the following pages:
+
+ - [Why etcd?][why]
+ - [Understand data model][data_model]
+ - [Understand APIs][understand_apis]
+ - [Glossary][glossary]
+ - Internals
+ - [Auth subsystem][auth_design]
+
+## Frequently Asked Questions (FAQ)
+
+Answers to [common questions] about etcd.
+
+[api_ref]: dev-guide/api_reference_v3.md
+[api_concurrency_ref]: dev-guide/api_concurrency_reference_v3.md
+[api_grpc_gateway]: dev-guide/api_grpc_gateway.md
+[clustering]: op-guide/clustering.md
+[conf]: op-guide/configuration.md
+[system-limit]: dev-guide/limit.md
+[common questions]: faq.md
+[why]: learning/why.md
+[data_model]: learning/data_model.md
+[demo]: demo.md
+[download_build]: dl_build.md
+[embed_etcd]: https://godoc.org/github.com/coreos/etcd/embed
+[grpc_naming]: dev-guide/grpc_naming.md
+[failures]: op-guide/failures.md
+[gateway]: op-guide/gateway.md
+[glossary]: learning/glossary.md
+[namespace_client]: https://godoc.org/github.com/coreos/etcd/clientv3/namespace
+[namespace_proxy]: op-guide/grpc_proxy.md#namespacing
+[grpc_proxy]: op-guide/grpc_proxy.md
+[hardware]: op-guide/hardware.md
+[interacting]: dev-guide/interacting_v3.md
+[local_cluster]: dev-guide/local_cluster.md
+[performance]: op-guide/performance.md
+[recovery]: op-guide/recovery.md
+[maintenance]: op-guide/maintenance.md
+[security]: op-guide/security.md
+[monitoring]: op-guide/monitoring.md
+[v2_migration]: op-guide/v2-migration.md
+[container_rkt]: op-guide/container.md#rkt
+[container_docker]: op-guide/container.md#docker
+[understand_apis]: learning/api.md
+[versioning]: op-guide/versioning.md
+[supported_platforms]: op-guide/supported-platform.md
+[container_linux_platform]: platforms/container-linux-systemd.md
+[freebsd_platform]: platforms/freebsd.md
+[aws_platform]: platforms/aws.md
+[experimental]: dev-guide/experimental_apis.md
+[v3_upgrade]: upgrades/upgrade_3_0.md
+[v31_upgrade]: upgrades/upgrade_3_1.md
+[v32_upgrade]: upgrades/upgrade_3_2.md
+[authentication]: op-guide/authentication.md
+[auth_design]: learning/auth_design.md
diff --git a/vendor/github.com/coreos/etcd/Documentation/faq.md b/vendor/github.com/coreos/etcd/Documentation/faq.md
new file mode 100644
index 00000000..83071381
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/faq.md
@@ -0,0 +1,151 @@
+## Frequently Asked Questions (FAQ)
+
+### etcd, general
+
+#### Do clients have to send requests to the etcd leader?
+
+[Raft][raft] is leader-based; the leader handles all client requests which need cluster consensus. However, the client does not need to know which node is the leader. Any request that requires consensus sent to a follower is automatically forwarded to the leader. Requests that do not require consensus (e.g., serialized reads) can be processed by any cluster member.
+
+### Configuration
+
+#### What is the difference between listen-<client,peer>-urls, advertise-client-urls or initial-advertise-peer-urls?
+
+`listen-client-urls` and `listen-peer-urls` specify the local addresses etcd server binds to for accepting incoming connections. To listen on a port for all interfaces, specify `0.0.0.0` as the listen IP address.
+
+`advertise-client-urls` and `initial-advertise-peer-urls` specify the addresses etcd clients or other etcd members should use to contact the etcd server. The advertise addresses must be reachable from the remote machines. Do not advertise addresses like `localhost` or `0.0.0.0` for a production setup since these addresses are unreachable from remote machines.
+
+### Deployment
+
+#### System requirements
+
+Since etcd writes data to disk, SSD is highly recommended. To prevent performance degradation or unintentionally overloading the key-value store, etcd enforces a 2GB default storage size quota, configurable up to 8GB. To avoid swapping or running out of memory, the machine should have at least as much RAM to cover the quota. At CoreOS, an etcd cluster is usually deployed on dedicated CoreOS Container Linux machines with dual-core processors, 2GB of RAM, and 80GB of SSD *at the very least*. **Note that performance is intrinsically workload dependent; please test before production deployment**. See [hardware][hardware-setup] for more recommendations.
+
+Most stable production environment is Linux operating system with amd64 architecture; see [supported platform][supported-platform] for more.
+
+#### Why an odd number of cluster members?
+
+An etcd cluster needs a majority of nodes, a quorum, to agree on updates to the cluster state. For a cluster with n members, quorum is (n/2)+1. For any odd-sized cluster, adding one node will always increase the number of nodes necessary for quorum. Although adding a node to an odd-sized cluster appears better since there are more machines, the fault tolerance is worse since exactly the same number of nodes may fail without losing quorum but there are more nodes that can fail. If the cluster is in a state where it can't tolerate any more failures, adding a node before removing nodes is dangerous because if the new node fails to register with the cluster (e.g., the address is misconfigured), quorum will be permanently lost.
+
+#### What is maximum cluster size?
+
+Theoretically, there is no hard limit. However, an etcd cluster probably should have no more than seven nodes. [Google Chubby lock service][chubby], similar to etcd and widely deployed within Google for many years, suggests running five nodes. A 5-member etcd cluster can tolerate two member failures, which is enough in most cases. Although larger clusters provide better fault tolerance, the write performance suffers because data must be replicated across more machines.
+
+#### What is failure tolerance?
+
+An etcd cluster operates so long as a member quorum can be established. If quorum is lost through transient network failures (e.g., partitions), etcd automatically and safely resumes once the network recovers and restores quorum; Raft enforces cluster consistency. For power loss, etcd persists the Raft log to disk; etcd replays the log to the point of failure and resumes cluster participation. For permanent hardware failure, the node may be removed from the cluster through [runtime reconfiguration][runtime reconfiguration].
+
+It is recommended to have an odd number of members in a cluster. An odd-size cluster tolerates the same number of failures as an even-size cluster but with fewer nodes. The difference can be seen by comparing even and odd sized clusters:
+
+| Cluster Size | Majority | Failure Tolerance |
+|:-:|:-:|:-:|
+| 1 | 1 | 0 |
+| 2 | 2 | 0 |
+| 3 | 2 | 1 |
+| 4 | 3 | 1 |
+| 5 | 3 | 2 |
+| 6 | 4 | 2 |
+| 7 | 4 | 3 |
+| 8 | 5 | 3 |
+| 9 | 5 | 4 |
+
+Adding a member to bring the size of cluster up to an even number doesn't buy additional fault tolerance. Likewise, during a network partition, an odd number of members guarantees that there will always be a majority partition that can continue to operate and be the source of truth when the partition ends.
+
+#### Does etcd work in cross-region or cross data center deployments?
+
+Deploying etcd across regions improves etcd's fault tolerance since members are in separate failure domains. The cost is higher consensus request latency from crossing data center boundaries. Since etcd relies on a member quorum for consensus, the latency from crossing data centers will be somewhat pronounced because at least a majority of cluster members must respond to consensus requests. Additionally, cluster data must be replicated across all peers, so there will be bandwidth cost as well.
+
+With longer latencies, the default etcd configuration may cause frequent elections or heartbeat timeouts. See [tuning] for adjusting timeouts for high latency deployments.
+
+### Operation
+
+#### How to backup a etcd cluster?
+
+etcdctl provides a `snapshot` command to create backups. See [backup][backup] for more details.
+
+#### Should I add a member before removing an unhealthy member?
+
+When replacing an etcd node, it's important to remove the member first and then add its replacement.
+
+etcd employs distributed consensus based on a quorum model; (n+1)/2 members, a majority, must agree on a proposal before it can be committed to the cluster. These proposals include key-value updates and membership changes. This model totally avoids any possibility of split brain inconsistency. The downside is permanent quorum loss is catastrophic.
+
+How this applies to membership: If a 3-member cluster has 1 downed member, it can still make forward progress because the quorum is 2 and 2 members are still live. However, adding a new member to a 3-member cluster will increase the quorum to 3 because 3 votes are required for a majority of 4 members. Since the quorum increased, this extra member buys nothing in terms of fault tolerance; the cluster is still one node failure away from being unrecoverable.
+
+Additionally, that new member is risky because it may turn out to be misconfigured or incapable of joining the cluster. In that case, there's no way to recover quorum because the cluster has two members down and two members up, but needs three votes to change membership to undo the botched membership addition. etcd will by default reject member add attempts that could take down the cluster in this manner.
+
+On the other hand, if the downed member is removed from cluster membership first, the number of members becomes 2 and the quorum remains at 2. Following that removal by adding a new member will also keep the quorum steady at 2. So, even if the new node can't be brought up, it's still possible to remove the new member through quorum on the remaining live members.
+
+#### Why won't etcd accept my membership changes?
+
+etcd sets `strict-reconfig-check` in order to reject reconfiguration requests that would cause quorum loss. Abandoning quorum is really risky (especially when the cluster is already unhealthy). Although it may be tempting to disable quorum checking if there's quorum loss to add a new member, this could lead to full fledged cluster inconsistency. For many applications, this will make the problem even worse ("disk geometry corruption" being a candidate for most terrifying).
+
+#### Why does etcd lose its leader from disk latency spikes?
+
+This is intentional; disk latency is part of leader liveness. Suppose the cluster leader takes a minute to fsync a raft log update to disk, but the etcd cluster has a one second election timeout. Even though the leader can process network messages within the election interval (e.g., send heartbeats), it's effectively unavailable because it can't commit any new proposals; it's waiting on the slow disk. If the cluster frequently loses its leader due to disk latencies, try [tuning][tuning] the disk settings or etcd time parameters.
+
+#### What does the etcd warning "request ignored (cluster ID mismatch)" mean?
+
+Every new etcd cluster generates a new cluster ID based on the initial cluster configuration and a user-provided unique `initial-cluster-token` value. By having unique cluster ID's, etcd is protected from cross-cluster interaction which could corrupt the cluster.
+
+Usually this warning happens after tearing down an old cluster, then reusing some of the peer addresses for the new cluster. If any etcd process from the old cluster is still running it will try to contact the new cluster. The new cluster will recognize a cluster ID mismatch, then ignore the request and emit this warning. This warning is often cleared by ensuring peer addresses among distinct clusters are disjoint.
+
+#### What does "mvcc: database space exceeded" mean and how do I fix it?
+
+The [multi-version concurrency control][api-mvcc] data model in etcd keeps an exact history of the keyspace. Without periodically compacting this history (e.g., by setting `--auto-compaction`), etcd will eventually exhaust its storage space. If etcd runs low on storage space, it raises a space quota alarm to protect the cluster from further writes. So long as the alarm is raised, etcd responds to write requests with the error `mvcc: database space exceeded`.
+
+To recover from the low space quota alarm:
+
+1. [Compact][maintenance-compact] etcd's history.
+2. [Defragment][maintenance-defragment] every etcd endpoint.
+3. [Disarm][maintenance-disarm] the alarm.
+
+### Performance
+
+#### How should I benchmark etcd?
+
+Try the [benchmark] tool. Current [benchmark results][benchmark-result] are available for comparison.
+
+#### What does the etcd warning "apply entries took too long" mean?
+
+After a majority of etcd members agree to commit a request, each etcd server applies the request to its data store and persists the result to disk. Even with a slow mechanical disk or a virtualized network disk, such as Amazon?s EBS or Google?s PD, applying a request should normally take fewer than 50 milliseconds. If the average apply duration exceeds 100 milliseconds, etcd will warn that entries are taking too long to apply.
+
+Usually this issue is caused by a slow disk. The disk could be experiencing contention among etcd and other applications, or the disk is too simply slow (e.g., a shared virtualized disk). To rule out a slow disk from causing this warning, monitor [backend_commit_duration_seconds][backend_commit_metrics] (p99 duration should be less than 25ms) to confirm the disk is reasonably fast. If the disk is too slow, assigning a dedicated disk to etcd or using faster disk will typically solve the problem.
+
+The second most common cause is CPU starvation. If monitoring of the machine?s CPU usage shows heavy utilization, there may not be enough compute capacity for etcd. Moving etcd to dedicated machine, increasing process resource isolation cgroups, or renicing the etcd server process into a higher priority can usually solve the problem.
+
+Expensive user requests which access too many keys (e.g., fetching the entire keyspace) can also cause long apply latencies. Accessing fewer than a several hundred keys per request, however, should always be performant.
+
+If none of the above suggestions clear the warnings, please [open an issue][new_issue] with detailed logging, monitoring, metrics and optionally workload information.
+
+#### What does the etcd warning "failed to send out heartbeat on time" mean?
+
+etcd uses a leader-based consensus protocol for consistent data replication and log execution. Cluster members elect a single leader, all other members become followers. The elected leader must periodically send heartbeats to its followers to maintain its leadership. Followers infer leader failure if no heartbeats are received within an election interval and trigger an election. If a leader doesn?t send its heartbeats in time but is still running, the election is spurious and likely caused by insufficient resources. To catch these soft failures, if the leader skips two heartbeat intervals, etcd will warn it failed to send a heartbeat on time.
+
+Usually this issue is caused by a slow disk. Before the leader sends heartbeats attached with metadata, it may need to persist the metadata to disk. The disk could be experiencing contention among etcd and other applications, or the disk is too simply slow (e.g., a shared virtualized disk). To rule out a slow disk from causing this warning, monitor [wal_fsync_duration_seconds][wal_fsync_duration_seconds] (p99 duration should be less than 10ms) to confirm the disk is reasonably fast. If the disk is too slow, assigning a dedicated disk to etcd or using faster disk will typically solve the problem.
+
+The second most common cause is CPU starvation. If monitoring of the machine?s CPU usage shows heavy utilization, there may not be enough compute capacity for etcd. Moving etcd to dedicated machine, increasing process resource isolation with cgroups, or renicing the etcd server process into a higher priority can usually solve the problem.
+
+A slow network can also cause this issue. If network metrics among the etcd machines shows long latencies or high drop rate, there may not be enough network capacity for etcd. Moving etcd members to a less congested network will typically solve the problem. However, if the etcd cluster is deployed across data centers, long latency between members is expected. For such deployments, tune the `heartbeat-interval` configuration to roughly match the round trip time between the machines, and the `election-timeout` configuration to be at least 5 * `heartbeat-interval`. See [tuning documentation][tuning] for detailed information.
+
+If none of the above suggestions clear the warnings, please [open an issue][new_issue] with detailed logging, monitoring, metrics and optionally workload information.
+
+#### What does the etcd warning "snapshotting is taking more than x seconds to finish ..." mean?
+
+etcd sends a snapshot of its complete key-value store to refresh slow followers and for [backups][backup]. Slow snapshot transfer times increase MTTR; if the cluster is ingesting data with high throughput, slow followers may livelock by needing a new snapshot before finishing receiving a snapshot. To catch slow snapshot performance, etcd warns when sending a snapshot takes more than thirty seconds and exceeds the expected transfer time for a 1Gbps connection.
+
+
+[hardware-setup]: ./op-guide/hardware.md
+[supported-platform]: ./op-guide/supported-platform.md
+[wal_fsync_duration_seconds]: ./metrics.md#disk
+[tuning]: ./tuning.md
+[new_issue]: https://github.com/coreos/etcd/issues/new
+[backend_commit_metrics]: ./metrics.md#disk
+[raft]: https://raft.github.io/raft.pdf
+[backup]: https://github.com/coreos/etcd/blob/master/Documentation/op-guide/recovery.md#snapshotting-the-keyspace
+[chubby]: http://static.googleusercontent.com/media/research.google.com/en//archive/chubby-osdi06.pdf
+[runtime reconfiguration]: https://github.com/coreos/etcd/blob/master/Documentation/op-guide/runtime-configuration.md
+[benchmark]: https://github.com/coreos/etcd/tree/master/tools/benchmark
+[benchmark-result]: https://github.com/coreos/etcd/blob/master/Documentation/op-guide/performance.md
+[api-mvcc]: learning/api.md#revisions
+[maintenance-compact]: op-guide/maintenance.md#history-compaction
+[maintenance-defragment]: op-guide/maintenance.md#defragmentation
+[maintenance-disarm]: ../etcdctl/README.md#alarm-disarm
diff --git a/vendor/github.com/coreos/etcd/Documentation/integrations.md b/vendor/github.com/coreos/etcd/Documentation/integrations.md
new file mode 100644
index 00000000..7c9bb210
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/integrations.md
@@ -0,0 +1,158 @@
+# Libraries and tools
+
+**Tools**
+
+- [etcdctl](https://github.com/coreos/etcd/tree/master/etcdctl) - A command line client for etcd
+- [etcd-backup](https://github.com/fanhattan/etcd-backup) - A powerful command line utility for dumping/restoring etcd - Supports v2
+- [etcd-dump](https://npmjs.org/package/etcd-dump) - Command line utility for dumping/restoring etcd.
+- [etcd-fs](https://github.com/xetorthio/etcd-fs) - FUSE filesystem for etcd
+- [etcddir](https://github.com/rekby/etcddir) - Realtime sync etcd and local directory. Work with windows and linux.
+- [etcd-browser](https://github.com/henszey/etcd-browser) - A web-based key/value editor for etcd using AngularJS
+- [etcd-lock](https://github.com/datawisesystems/etcd-lock) - Master election & distributed r/w lock implementation using etcd - Supports v2
+- [etcd-console](https://github.com/matishsiao/etcd-console) - A web-base key/value editor for etcd using PHP
+- [etcd-viewer](https://github.com/nikfoundas/etcd-viewer) - An etcd key-value store editor/viewer written in Java
+- [etcdtool](https://github.com/mickep76/etcdtool) - Export/Import/Edit etcd directory as JSON/YAML/TOML and Validate directory using JSON schema
+- [etcd-rest](https://github.com/mickep76/etcd-rest) - Create generic REST API in Go using etcd as a backend with validation using JSON schema
+- [etcdsh](https://github.com/kamilhark/etcdsh) - A command line client with support of command history and tab completion. Supports v2
+- [etcdloadtest](https://github.com/sinsharat/etcdloadtest) - A command line load test client for etcd version 3.0 and above.
+
+**Go libraries**
+
+- [etcd/clientv3](https://github.com/coreos/etcd/blob/master/clientv3) - the officially maintained Go client for v3
+- [etcd/client](https://github.com/coreos/etcd/blob/master/client) - the officially maintained Go client for v2
+- [go-etcd](https://github.com/coreos/go-etcd) - the deprecated official client. May be useful for older (<2.0.0) versions of etcd.
+- [encWrapper](https://github.com/lumjjb/etcd/tree/enc_wrapper/clientwrap/encwrapper) - encWrapper is an encryption wrapper for the etcd client Keys API/KV.
+
+**Java libraries**
+
+- [coreos/jetcd](https://github.com/coreos/jetcd) - Supports v3
+- [boonproject/etcd](https://github.com/boonproject/boon/blob/master/etcd/README.md) - Supports v2, Async/Sync and waits
+- [justinsb/jetcd](https://github.com/justinsb/jetcd)
+- [diwakergupta/jetcd](https://github.com/diwakergupta/jetcd) - Supports v2
+- [jurmous/etcd4j](https://github.com/jurmous/etcd4j) - Supports v2, Async/Sync, waits and SSL
+- [AdoHe/etcd4j](http://github.com/AdoHe/etcd4j) - Supports v2 (enhance for real production cluster)
+- [cdancy/etcd-rest](https://github.com/cdancy/etcd-rest) - Uses jclouds to provide a complete implementation of v2 API.
+
+**Scala libraries**
+
+- [maciej/etcd-client](https://github.com/maciej/etcd-client) - Supports v2. Akka HTTP-based fully async client
+- [eiipii/etcdhttpclient](https://bitbucket.org/eiipii/etcdhttpclient) - Supports v2. Async HTTP client based on Netty and Scala Futures.
+
+**Python libraries**
+
+- [kragniz/python-etcd3](https://github.com/kragniz/python-etcd3) - Work in progress client for v3
+- [jplana/python-etcd](https://github.com/jplana/python-etcd) - Supports v2
+- [russellhaering/txetcd](https://github.com/russellhaering/txetcd) - a Twisted Python library
+- [cholcombe973/autodock](https://github.com/cholcombe973/autodock) - A docker deployment automation tool
+- [lisael/aioetcd](https://github.com/lisael/aioetcd) - (Python 3.4+) Asyncio coroutines client (Supports v2)
+- [txaio-etcd](https://github.com/crossbario/txaio-etcd) - Asynchronous etcd v3-only client library for Twisted (today) and asyncio (future)
+- [dims/etcd3-gateway](https://github.com/dims/etcd3-gateway) - etcd v3 API library using the HTTP grpc gateway
+
+**Node libraries**
+
+- [stianeikeland/node-etcd](https://github.com/stianeikeland/node-etcd) - Supports v2 (w Coffeescript)
+- [lavagetto/nodejs-etcd](https://github.com/lavagetto/nodejs-etcd) - Supports v2
+- [deedubs/node-etcd-config](https://github.com/deedubs/node-etcd-config) - Supports v2
+
+**Ruby libraries**
+
+- [iconara/etcd-rb](https://github.com/iconara/etcd-rb)
+- [jpfuentes2/etcd-ruby](https://github.com/jpfuentes2/etcd-ruby)
+- [ranjib/etcd-ruby](https://github.com/ranjib/etcd-ruby) - Supports v2
+- [davissp14/etcdv3-ruby](https://github.com/davissp14/etcdv3-ruby) - Supports v3
+
+**C libraries**
+
+- [apache/celix/etcdlib](https://github.com/apache/celix/tree/develop/etcdlib) - Supports v2
+- [jdarcy/etcd-api](https://github.com/jdarcy/etcd-api) - Supports v2
+- [shafreeck/cetcd](https://github.com/shafreeck/cetcd) - Supports v2
+
+**C++ libraries**
+- [edwardcapriolo/etcdcpp](https://github.com/edwardcapriolo/etcdcpp) - Supports v2
+- [suryanathan/etcdcpp](https://github.com/suryanathan/etcdcpp) - Supports v2 (with waits)
+- [nokia/etcd-cpp-api](https://github.com/nokia/etcd-cpp-api) - Supports v2
+- [nokia/etcd-cpp-apiv3](https://github.com/nokia/etcd-cpp-apiv3) - Supports v3
+
+**Clojure libraries**
+
+- [aterreno/etcd-clojure](https://github.com/aterreno/etcd-clojure)
+- [dwwoelfel/cetcd](https://github.com/dwwoelfel/cetcd) - Supports v2
+- [rthomas/clj-etcd](https://github.com/rthomas/clj-etcd) - Supports v2
+
+**Erlang libraries**
+
+- [marshall-lee/etcd.erl](https://github.com/marshall-lee/etcd.erl)
+
+**.Net Libraries**
+
+- [wangjia184/etcdnet](https://github.com/wangjia184/etcdnet) - Supports v2
+- [drusellers/etcetera](https://github.com/drusellers/etcetera)
+
+**PHP Libraries**
+
+- [linkorb/etcd-php](https://github.com/linkorb/etcd-php)
+- [activecollab/etcd](https://github.com/activecollab/etcd)
+
+**Haskell libraries**
+
+- [wereHamster/etcd-hs](https://github.com/wereHamster/etcd-hs)
+
+**R libraries**
+
+- [ropensci/etseed](https://github.com/ropensci/etseed)
+
+**Nim libraries**
+
+- [etcd_client](https://github.com/FedericoCeratto/nim-etcd-client)
+
+**Tcl libraries**
+
+- [efrecon/etcd-tcl](https://github.com/efrecon/etcd-tcl) - Supports v2, except wait.
+
+**Rust libraries**
+
+- [jimmycuadra/rust-etcd](https://github.com/jimmycuadra/rust-etcd) - Supports v2
+
+**Gradle Plugins**
+
+- [gradle-etcd-rest-plugin](https://github.com/cdancy/gradle-etcd-rest-plugin) - Supports v2
+
+**Chef Integration**
+
+- [coderanger/etcd-chef](https://github.com/coderanger/etcd-chef)
+
+**Chef Cookbook**
+
+- [spheromak/etcd-cookbook](https://github.com/spheromak/etcd-cookbook)
+
+**BOSH Releases**
+
+- [cloudfoundry-community/etcd-boshrelease](https://github.com/cloudfoundry-community/etcd-boshrelease)
+- [cloudfoundry/cf-release](https://github.com/cloudfoundry/cf-release/tree/master/jobs/etcd)
+
+**Projects using etcd**
+
+- [apache/celix](https://github.com/apache/celix) - an implementation of the OSGi specification adapted to C and C++
+- [binocarlos/yoda](https://github.com/binocarlos/yoda) - etcd + ZeroMQ
+- [blox/blox](https://github.com/blox/blox) - a collection of open source projects for container management and orchestration with AWS ECS
+- [calavera/active-proxy](https://github.com/calavera/active-proxy) - HTTP Proxy configured with etcd
+- [chain/chain](https://github.com/chain/chain) - software designed to operate and connect to highly scalable permissioned blockchain networks
+- [derekchiang/etcdplus](https://github.com/derekchiang/etcdplus) - A set of distributed synchronization primitives built upon etcd
+- [go-discover](https://github.com/flynn/go-discover) - service discovery in Go
+- [gleicon/goreman](https://github.com/gleicon/goreman/tree/etcd) - Branch of the Go Foreman clone with etcd support
+- [garethr/hiera-etcd](https://github.com/garethr/hiera-etcd) - Puppet hiera backend using etcd
+- [mattn/etcd-vim](https://github.com/mattn/etcd-vim) - SET and GET keys from inside vim
+- [mattn/etcdenv](https://github.com/mattn/etcdenv) - "env" shebang with etcd integration
+- [kelseyhightower/confd](https://github.com/kelseyhightower/confd) - Manage local app config files using templates and data from etcd
+- [configdb](https://git.autistici.org/ai/configdb/tree/master) - A REST relational abstraction on top of arbitrary database backends, aimed at storing configs and inventories.
+- [fleet](https://github.com/coreos/fleet) - Distributed init system
+- [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes) - Container cluster manager introduced by Google.
+- [mailgun/vulcand](https://github.com/mailgun/vulcand) - HTTP proxy that uses etcd as a configuration backend.
+- [duedil-ltd/discodns](https://github.com/duedil-ltd/discodns) - Simple DNS nameserver using etcd as a database for names and records.
+- [skynetservices/skydns](https://github.com/skynetservices/skydns) - RFC compliant DNS server
+- [xordataexchange/crypt](https://github.com/xordataexchange/crypt) - Securely store values in etcd using GPG encryption
+- [spf13/viper](https://github.com/spf13/viper) - Go configuration library, reads values from ENV, pflags, files, and etcd with optional encryption
+- [lytics/metafora](https://github.com/lytics/metafora) - Go distributed task library
+- [ryandoyle/nss-etcd](https://github.com/ryandoyle/nss-etcd) - A GNU libc NSS module for resolving names from etcd.
+- [Gru](https://github.com/dnaeon/gru) - Orchestration made easy with Go
+- [Vitess](http://vitess.io/) - Vitess is a database clustering system for horizontal scaling of MySQL.
diff --git a/vendor/github.com/coreos/etcd/Documentation/learning/api.md b/vendor/github.com/coreos/etcd/Documentation/learning/api.md
new file mode 100644
index 00000000..a0efaa1e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/learning/api.md
@@ -0,0 +1,481 @@
+# etcd3 API
+
+This document is meant to give an overview of the etcd3 API's central design. It is by no means all encompassing, but intended to focus on the basic ideas needed to understand etcd without the distraction of less common API calls. All etcd3 API's are defined in [gRPC services][grpc-service], which categorize remote procedure calls (RPCs) understood by the etcd server. A full listing of all etcd RPCs are documented in markdown in the [gRPC API listing][grpc-api].
+
+## gRPC Services
+
+Every API request sent to an etcd server is a gRPC remote procedure call. RPCs in etcd3 are categorized based on functionality into services.
+
+Services important for dealing with etcd's key space include:
+* KV - Creates, updates, fetches, and deletes key-value pairs.
+* Watch - Monitors changes to keys.
+* Lease - Primitives for consuming client keep-alive messages.
+
+Services which manage the cluster itself include:
+* Auth - Role based authentication mechanism for authenticating users.
+* Cluster - Provides membership information and configuration facilities.
+* Maintenance - Takes recovery snapshots, defragments the store, and returns per-member status information.
+
+### Requests and Responses
+
+All RPCs in etcd3 follow the same format. Each RPC has a function `Name` which takes `NameRequest` as an argument and returns `NameResponse` as a response. For example, here is the `Range` RPC description:
+
+```protobuf
+service KV {
+ Range(RangeRequest) returns (RangeResponse)
+ ...
+}
+```
+
+### Response header
+
+All Responses from etcd API have an attached response header which includes cluster metadata for the response:
+
+```proto
+message ResponseHeader {
+ uint64 cluster_id = 1;
+ uint64 member_id = 2;
+ int64 revision = 3;
+ uint64 raft_term = 4;
+}
+```
+
+* Cluster_ID - the ID of the cluster generating the response.
+* Member_ID - the ID of the member generating the response.
+* Revision - the revision of the key-value store when generating the response.
+* Raft_Term - the Raft term of the member when generating the response.
+
+An application may read the Cluster_ID (Member_ID) field to ensure it is communicating with the intended cluster (member).
+
+Applications can use the `Revision` to know the latest revision of the key-value store. This is especially useful when applications specify a historical revision to make time `travel query` and wishes to know the latest revision at the time of the request.
+
+Applications can use `Raft_Term` to detect when the cluster completes a new leader election.
+
+## Key-Value API
+
+The Key-Value API manipulates key-value pairs stored inside etcd. The majority of requests made to etcd are usually key-value requests.
+
+### System primitives
+
+### Key-Value pair
+
+A key-value pair is the smallest unit that the key-value API can manipulate. Each key-value pair has a number of fields, defined in [protobuf format][kv-proto]:
+
+```protobuf
+message KeyValue {
+ bytes key = 1;
+ int64 create_revision = 2;
+ int64 mod_revision = 3;
+ int64 version = 4;
+ bytes value = 5;
+ int64 lease = 6;
+}
+```
+
+* Key - key in bytes. An empty key is not allowed.
+* Value - value in bytes.
+* Version - version is the version of the key. A deletion resets the version to zero and any modification of the key increases its version.
+* Create_Revision - revision of the last creation on the key.
+* Mod_Revision - revision of the last modification on the key.
+* Lease - the ID of the lease attached to the key. If lease is 0, then no lease is attached to the key.
+
+
+In addition to just the key and value, etcd attaches additional revision metadata as part of the key message. This revision information orders keys by time of creation and modification, which is useful for managing concurrency for distributed synchronization. The etcd client's [distributed shared locks][locks] use the creation revision to wait for lock ownership. Similarly, the modification revision is used for detecting [software transactional memory][STM] read set conflicts and waiting on [leader election][elections] updates.
+
+#### Revisions
+
+etcd maintains a 64-bit cluster-wide counter, the store revision, that is incremented each time the key space is modified. The revision serves as a global logical clock, sequentially ordering all updates to the store. The change represented by a new revisions is incremental; the data associated with a revision is the data that changed the store. Internally, a new revision means writing the changes to the backend's B+tree, keyed by the incremented revision.
+
+Revisions become more valuable when taking considering etcd3's [multi-version concurrency control][mvcc] backend. The MVCC model means that the key-value store can be viewed from past revisions since historical key revisions are retained. The retention policy for this history can be configured by cluster administrators for fine-grained storage management; usually etcd3 discards old revisions of keys on a timer. A typical etcd3 cluster retains superseded key data for hours. This also buys reliable handling for long client disconnection, not just transient network disruptions: watchers simply resume from the last observed historical revision. Similarly, to read from the store at a particular point-in-time, read requests can be tagged with a revision to return keys from a view of the key space at the point in time that revision was committed.
+
+#### Key ranges
+
+The etcd3 data model indexes all keys over a flat binary key space. This differs from other key-value store systems that use a hierarchical system of organizing keys into directories. Instead of listing keys by directory, keys are listed by key intervals `[a, b)`.
+
+These intervals are often referred to as "ranges" in etcd3. Operations over ranges are more powerful than operations on directories. Like a hierarchical store, intervals support single key lookups via `[a, a+1)` (e.g., ['a', 'a\x00') looks up 'a') and directory lookups by encoding keys by directory depth. In addition to those operations, intervals can also encode prefixes; for example the interval `['a', 'b')` looks up all keys prefixed by the string 'a'.
+
+By convention, ranges for a Request are denoted by the fields `key` and `range_end`. The `key` field is the first key of the range and should be non-empty. The `range_end` is the key following the last key of the range. If `range_end` is not given or empty, the range is defined to contain only the key argument. If `range_end` is `key` plus one (e.g., "aa"+1 == "ab", "a\xff"+1 == "b"), then the range represents all keys prefixed with key. If both `key` and `range_end` are '\0', then range represents all keys. If `range_end` is '\0', the range is all keys greater than or equal to the key argument.
+
+### Range
+
+Keys are fetched from the key-value store using the `Range` API call, which takes a `RangeRequest`:
+
+```protobuf
+message RangeRequest {
+ enum SortOrder {
+ NONE = 0; // default, no sorting
+ ASCEND = 1; // lowest target value first
+ DESCEND = 2; // highest target value first
+ }
+ enum SortTarget {
+ KEY = 0;
+ VERSION = 1;
+ CREATE = 2;
+ MOD = 3;
+ VALUE = 4;
+ }
+
+ bytes key = 1;
+ bytes range_end = 2;
+ int64 limit = 3;
+ int64 revision = 4;
+ SortOrder sort_order = 5;
+ SortTarget sort_target = 6;
+ bool serializable = 7;
+ bool keys_only = 8;
+ bool count_only = 9;
+ int64 min_mod_revision = 10;
+ int64 max_mod_revision = 11;
+ int64 min_create_revision = 12;
+ int64 max_create_revision = 13;
+}
+```
+
+* Key, Range_End - The key range to fetch.
+* Limit - the maximum number of keys returned for the request. When limit is set to 0, it is treated as no limit.
+* Revision - the point-in-time of the key-value store to use for the range. If revision is less or equal to zero, the range is over the latest key-value store If the revision is compacted, ErrCompacted is returned as a response.
+* Sort_Order - the ordering for sorted requests.
+* Sort_Target - the key-value field to sort.
+* Serializable - sets the range request to use serializable member-local reads. By default, Range is linearizable; it reflects the current consensus of the cluster. For better performance and availability, in exchange for possible stale reads, a serializable range request is served locally without needing to reach consensus with other nodes in the cluster.
+* Keys_Only - return only the keys and not the values.
+* Count_Only - return only the count of the keys in the range.
+* Min_Mod_Revision - the lower bound for key mod revisions; filters out lesser mod revisions.
+* Max_Mod_Revision - the upper bound for key mod revisions; filters out greater mod revisions.
+* Min_Create_Revision - the lower bound for key create revisions; filters out lesser create revisions.
+* Max_Create_Revision - the upper bound for key create revisions; filters out greater create revisions.
+
+The client receives a `RangeResponse` message from the `Range` call:
+
+```protobuf
+message RangeResponse {
+ ResponseHeader header = 1;
+ repeated mvccpb.KeyValue kvs = 2;
+ bool more = 3;
+ int64 count = 4;
+}
+```
+
+* Kvs - the list of key-value pairs matched by the range request. When `Count_Only` is set, `Kvs` is empty.
+* More - indicates if there are more keys to return in the requested range if `limit` is set.
+* Count - the total number of keys satisfying the range request.
+
+### Put
+
+Keys are saved into the key-value store by issuing a `Put` call, which takes a `PutRequest`:
+
+```protobuf
+message PutRequest {
+ bytes key = 1;
+ bytes value = 2;
+ int64 lease = 3;
+ bool prev_kv = 4;
+ bool ignore_value = 5;
+ bool ignore_lease = 6;
+}
+```
+
+* Key - the name of the key to put into the key-value store.
+* Value - the value, in bytes, to associate with the key in the key-value store.
+* Lease - the lease ID to associate with the key in the key-value store. A lease value of 0 indicates no lease.
+* Prev_Kv - when set, responds with the key-value pair data before the update from this `Put` request.
+* Ignore_Value - when set, update the key without changing its current value. Returns an error if the key does not exist.
+* Ignore_Lease - when set, update the key without changing its current lease. Returns an error if the key does not exist.
+
+The client receives a `PutResponse` message from the `Put` call:
+
+```protobuf
+message PutResponse {
+ ResponseHeader header = 1;
+ mvccpb.KeyValue prev_kv = 2;
+}
+```
+
+* Prev_Kv - the key-value pair overwritten by the `Put`, if `Prev_Kv` was set in the `PutRequest`.
+
+### Delete Range
+
+Ranges of keys are deleted using the `DeleteRange` call, which takes a `DeleteRangeRequest`:
+
+```protobuf
+message DeleteRangeRequest {
+ bytes key = 1;
+ bytes range_end = 2;
+ bool prev_kv = 3;
+}
+```
+
+* Key, Range_End - The key range to delete.
+* Prev_Kv - when set, return the contents of the deleted key-value pairs.
+
+The client receives a `DeleteRangeResponse` message from the `DeleteRange` call:
+
+```protobuf
+message DeleteRangeResponse {
+ ResponseHeader header = 1;
+ int64 deleted = 2;
+ repeated mvccpb.KeyValue prev_kvs = 3;
+}
+```
+
+* Deleted - number of keys deleted.
+* Prev_Kv - a list of all key-value pairs deleted by the DeleteRange operation.
+
+### Transaction
+
+A transaction is an atomic If/Then/Else construct over the key-value store. It provides a primitive for grouping requests together in atomic blocks (i.e., then/else) whose execution is guarded (i.e., if) based on the contents of the key-value store. Transactions can be used for protecting keys from unintended concurrent updates, building compare-and-swap operations, and developing higher-level concurrency control.
+
+A transaction can atomically process multiple requests in a single request. For modifications to the key-value store, this means the store's revision is incremented only once for the transaction and all events generated by the transaction will have the same revision. However, modifications to the same key multiple times within a single transaction are forbidden.
+
+All transactions are guarded by a conjunction of comparisons, similar to an "If" statement. Each comparison checks a single key in the store. It may check for the absence or presence of a value, compare with a given value, or check a key's revision or version. Two different comparisons may apply to the same or different keys. All comparisons are applied atomically; if all comparisons are true, the transaction is said to succeed and etcd applies the transaction's then / `success` request block, otherwise it is said to fail and applies the else / `failure` request block.
+
+Each comparison is encoded as a `Compare` message:
+
+```protobuf
+message Compare {
+ enum CompareResult {
+ EQUAL = 0;
+ GREATER = 1;
+ LESS = 2;
+ NOT_EQUAL = 3;
+ }
+ enum CompareTarget {
+ VERSION = 0;
+ CREATE = 1;
+ MOD = 2;
+ VALUE= 3;
+ }
+ CompareResult result = 1;
+ // target is the key-value field to inspect for the comparison.
+ CompareTarget target = 2;
+ // key is the subject key for the comparison operation.
+ bytes key = 3;
+ oneof target_union {
+ int64 version = 4;
+ int64 create_revision = 5;
+ int64 mod_revision = 6;
+ bytes value = 7;
+ }
+}
+```
+
+* Result - the kind of logical comparison operation (e.g., equal, less than, etc).
+* Target - the key-value field to be compared. Either the key's version, create revision, modification revision, or value.
+* Key - the key for the comparison.
+* Target_Union - the user-specified data for the comparison.
+
+After processing the comparison block, the transaction applies a block of requests. A block is a list of `RequestOp` messages:
+
+```protobuf
+message RequestOp {
+ // request is a union of request types accepted by a transaction.
+ oneof request {
+ RangeRequest request_range = 1;
+ PutRequest request_put = 2;
+ DeleteRangeRequest request_delete_range = 3;
+ }
+}
+```
+
+* Request_Range - a `RangeRequest`.
+* Request_Put - a `PutRequest`. The keys must be unique. It may not share keys with any other Puts or Deletes.
+* Request_Delete_Range - a `DeleteRangeRequest`. It may not share keys with any Puts or Deletes requests.
+
+All together, a transaction is issued with a `Txn` API call, which takes a `TxnRequest`:
+
+```protobuf
+message TxnRequest {
+ repeated Compare compare = 1;
+ repeated RequestOp success = 2;
+ repeated RequestOp failure = 3;
+}
+```
+
+* Compare - A list of predicates representing a conjunction of terms for guarding the transaction.
+* Success - A list of requests to process if all compare tests evaluate to true.
+* Failure - A list of requests to process if any compare test evaluates to false.
+
+The client receives a `TxnResponse` message from the `Txn` call:
+
+```protobuf
+message TxnResponse {
+ ResponseHeader header = 1;
+ bool succeeded = 2;
+ repeated ResponseOp responses = 3;
+}
+```
+
+* Succeeded - Whether `Compare` evaluated to true or false.
+* Responses - A list of responses corresponding to the results from applying the `Success` block if succeeded is true or the `Failure` if succeeded is false.
+
+The `Responses` list corresponds to the results from the applied `RequestOp` list, with each response encoded as a `ResponseOp`:
+
+```protobuf
+message ResponseOp {
+ oneof response {
+ RangeResponse response_range = 1;
+ PutResponse response_put = 2;
+ DeleteRangeResponse response_delete_range = 3;
+ }
+}
+```
+
+## Watch API
+
+The Watch API provides an event-based interface for asynchronously monitoring changes to keys. An etcd3 watch waits for changes to keys by continuously watching from a given revision, either current or historical, and streams key updates back to the client.
+
+### Events
+
+Every change to every key is represented with `Event` messages. An `Event` message provides both the update's data and the type of update:
+
+```protobuf
+message Event {
+ enum EventType {
+ PUT = 0;
+ DELETE = 1;
+ }
+ EventType type = 1;
+ KeyValue kv = 2;
+ KeyValue prev_kv = 3;
+}
+```
+
+* Type - The kind of event. A PUT type indicates new data has been stored to the key. A DELETE indicates the key was deleted.
+* KV - The KeyValue associated with the event. A PUT event contains current kv pair. A PUT event with kv.Version=1 indicates the creation of a key. A DELETE event contains the deleted key with its modification revision set to the revision of deletion.
+* Prev_KV - The key-value pair for the key from the revision immediately before the event. To save bandwidth, it is only filled out if the watch has explicitly enabled it.
+
+### Watch streams
+
+Watches are long-running requests and use gRPC streams to stream event data. A watch stream is bi-directional; the client writes to the stream to establish watches and reads to receive watch event. A single watch stream can multiplex many distinct watches by tagging events with per-watch identifiers. This multiplexing helps reducing the memory footprint and connection overhead on the core etcd cluster.
+
+Watches make three guarantees about events:
+* Ordered - events are ordered by revision; an event will never appear on a watch if it precedes an event in time that has already been posted.
+* Reliable - a sequence of events will never drop any subsequence of events; if there are events ordered in time as a < b < c, then if the watch receives events a and c, it is guaranteed to receive b.
+* Atomic - a list of events is guaranteed to encompass complete revisions; updates in the same revision over multiple keys will not be split over several lists of events.
+
+A client creates a watch by sending a `WatchCreateRequest` over a stream returned by `Watch`:
+
+```protobuf
+message WatchCreateRequest {
+ bytes key = 1;
+ bytes range_end = 2;
+ int64 start_revision = 3;
+ bool progress_notify = 4;
+
+ enum FilterType {
+ NOPUT = 0;
+ NODELETE = 1;
+ }
+ repeated FilterType filters = 5;
+ bool prev_kv = 6;
+}
+```
+
+* Key, Range_End - The key range to watch.
+* Start_Revision - An optional revision for where to inclusively begin watching. If not given, it will stream events following the revision of the watch creation response header revision. The entire available event history can be watched starting from the last compaction revision.
+* Progress_Notify - When set, the watch will periodically receive a WatchResponse with no events, if there are no recent events. It is useful when clients wish to recover a disconnected watcher starting from a recent known revision. The etcd server decides how often to send notifications based on current server load.
+* Filters - A list of event types to filter away at server side.
+* Prev_Kv - When set, the watch receives the key-value data from before the event happens. This is useful for knowing what data has been overwritten.
+
+In response to a `WatchCreateRequest` or if there is a new event for some established watch, the client receives a `WatchResponse`:
+
+```protobuf
+message WatchResponse {
+ ResponseHeader header = 1;
+ int64 watch_id = 2;
+ bool created = 3;
+ bool canceled = 4;
+ int64 compact_revision = 5;
+
+ repeated mvccpb.Event events = 11;
+}
+```
+
+* Watch_ID - the ID of the watch that corresponds to the response.
+* Created - set to true if the response is for a create watch request. The client should record ID and expect to receive events for the watch on the stream. All events sent to the created watcher will have the same watch_id.
+* Canceled - set to true if the response is for a cancel watch request. No further events will be sent to the canceled watcher.
+* Compact_Revision - set to the minimum historical revision available to etcd if a watcher tries watching at a compacted revision. This happens when creating a watcher at a compacted revision or the watcher cannot catch up with the progress of the key-value store. The watcher will be canceled; creating new watches with the same start_revision will fail.
+* Events - a list of new events in sequence corresponding to the given watch ID.
+
+If the client wishes to stop receiving events for a watch, it issues a `WatchCancelRequest`:
+
+```protobuf
+message WatchCancelRequest {
+ int64 watch_id = 1;
+}
+```
+
+* Watch_ID - the ID of the watch to cancel so that no more events are transmitted.
+
+## Lease API
+
+Leases are a mechanism for detecting client liveness. The cluster grants leases with a time-to-live. A lease expires if the etcd cluster does not receive a keepAlive within a given TTL period.
+
+To tie leases into the key-value store, each key may be attached to at most one lease. When a lease expires or is revoked, all keys attached to that lease will be deleted. Each expired key generates a delete event in the event history.
+
+### Obtaining leases
+
+Leases are obtained through the `LeaseGrant` API call, which takes a `LeaseGrantRequest`:
+
+```protobuf
+message LeaseGrantRequest {
+ int64 TTL = 1;
+ int64 ID = 2;
+}
+```
+
+* TTL - the advisory time-to-live, in seconds.
+* ID - the requested ID for the lease. If ID is set to 0, etcd will choose an ID.
+
+The client receives a `LeaseGrantResponse` from the `LeaseGrant` call:
+
+```protobuf
+message LeaseGrantResponse {
+ ResponseHeader header = 1;
+ int64 ID = 2;
+ int64 TTL = 3;
+}
+```
+
+* ID - the lease ID for the granted lease.
+* TTL - is the server selected time-to-live, in seconds, for the lease.
+
+```protobuf
+message LeaseRevokeRequest {
+ int64 ID = 1;
+}
+```
+
+* ID - the lease ID to revoke. When the lease is revoked, all attached keys are deleted.
+
+### Keep alives
+
+Leases are refreshed using a bi-directional stream created with the `LeaseKeepAlive` API call. When the client wishes to refresh a lease, it sends a `LeaseKeepAliveRequest` over the stream:
+
+```protobuf
+message LeaseKeepAliveRequest {
+ int64 ID = 1;
+}
+```
+
+* ID - the lease ID for the lease to keep alive.
+
+The keep alive stream responds with a `LeaseKeepAliveResponse`:
+
+```protobuf
+message LeaseKeepAliveResponse {
+ ResponseHeader header = 1;
+ int64 ID = 2;
+ int64 TTL = 3;
+}
+```
+
+* ID - the lease that was refreshed with a new TTL.
+* TTL - the new time-to-live, in seconds, that the lease has remaining.
+
+[elections]: https://github.com/coreos/etcd/blob/master/clientv3/concurrency/election.go
+[kv-proto]: https://github.com/coreos/etcd/blob/master/mvcc/mvccpb/kv.proto
+[grpc-api]: ../dev-guide/api_reference_v3.md
+[grpc-service]: https://github.com/coreos/etcd/blob/master/etcdserver/etcdserverpb/rpc.proto
+[locks]: https://github.com/coreos/etcd/blob/master/clientv3/concurrency/mutex.go
+[mvcc]: https://en.wikipedia.org/wiki/Multiversion_concurrency_control
+[stm]: https://github.com/coreos/etcd/blob/master/clientv3/concurrency/stm.go
diff --git a/vendor/github.com/coreos/etcd/Documentation/learning/api_guarantees.md b/vendor/github.com/coreos/etcd/Documentation/learning/api_guarantees.md
new file mode 100644
index 00000000..936e7413
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/learning/api_guarantees.md
@@ -0,0 +1,64 @@
+# KV API guarantees
+
+etcd is a consistent and durable key value store with [mini-transaction][txn] support. The key value store is exposed through the KV APIs. etcd tries to ensure the strongest consistency and durability guarantees for a distributed system. This specification enumerates the KV API guarantees made by etcd.
+
+### APIs to consider
+
+* Read APIs
+ * range
+ * watch
+* Write APIs
+ * put
+ * delete
+* Combination (read-modify-write) APIs
+ * txn
+
+### etcd specific definitions
+
+#### Operation completed
+
+An etcd operation is considered complete when it is committed through consensus, and therefore ?executed? -- permanently stored -- by the etcd storage engine. The client knows an operation is completed when it receives a response from the etcd server. Note that the client may be uncertain about the status of an operation if it times out, or there is a network disruption between the client and the etcd member. etcd may also abort operations when there is a leader election. etcd does not send `abort` responses to clients? outstanding requests in this event.
+
+#### Revision
+
+An etcd operation that modifies the key value store is assigned a single increasing revision. A transaction operation might modify the key value store multiple times, but only one revision is assigned. The revision attribute of a key value pair that was modified by the operation has the same value as the revision of the operation. The revision can be used as a logical clock for key value store. A key value pair that has a larger revision is modified after a key value pair with a smaller revision. Two key value pairs that have the same revision are modified by an operation "concurrently".
+
+### Guarantees provided
+
+#### Atomicity
+
+All API requests are atomic; an operation either completes entirely or not at all. For watch requests, all events generated by one operation will be in one watch response. Watch never observes partial events for a single operation.
+
+#### Consistency
+
+All API calls ensure [sequential consistency][seq_consistency], the strongest consistency guarantee available from distributed systems. No matter which etcd member server a client makes requests to, a client reads the same events in the same order. If two members complete the same number of operations, the state of the two members is consistent.
+
+For watch operations, etcd guarantees to return the same value for the same key across all members for the same revision. For range operations, etcd has a similar guarantee for [linearized][Linearizability] access; serialized access may be behind the quorum state, so that the later revision is not yet available.
+
+As with all distributed systems, it is impossible for etcd to ensure [strict consistency][strict_consistency]. etcd does not guarantee that it will return to a read the ?most recent? value (as measured by a wall clock when a request is completed) available on any cluster member.
+
+#### Isolation
+
+etcd ensures [serializable isolation][serializable_isolation], which is the highest isolation level available in distributed systems. Read operations will never observe any intermediate data.
+
+#### Durability
+
+Any completed operations are durable. All accessible data is also durable data. A read will never return data that has not been made durable.
+
+#### Linearizability
+
+Linearizability (also known as Atomic Consistency or External Consistency) is a consistency level between strict consistency and sequential consistency.
+
+For linearizability, suppose each operation receives a timestamp from a loosely synchronized global clock. Operations are linearized if and only if they always complete as though they were executed in a sequential order and each operation appears to complete in the order specified by the program. Likewise, if an operation?s timestamp precedes another, that operation must also precede the other operation in the sequence.
+
+For example, consider a client completing a write at time point 1 (*t1*). A client issuing a read at *t2* (for *t2* > *t1*) should receive a value at least as recent as the previous write, completed at *t1*. However, the read might actually complete only by *t3*, and the returned value, current at *t2* when the read began, might be "stale" by *t3*.
+
+etcd does not ensure linearizability for watch operations. Users are expected to verify the revision of watch responses to ensure correct ordering.
+
+etcd ensures linearizability for all other operations by default. Linearizability comes with a cost, however, because linearized requests must go through the Raft consensus process. To obtain lower latencies and higher throughput for read requests, clients can configure a request?s consistency mode to `serializable`, which may access stale data with respect to quorum, but removes the performance penalty of linearized accesses' reliance on live consensus.
+
+[seq_consistency]: https://en.wikipedia.org/wiki/Consistency_model#Sequential_consistency
+[strict_consistency]: https://en.wikipedia.org/wiki/Consistency_model#Strict_consistency
+[serializable_isolation]: https://en.wikipedia.org/wiki/Isolation_(database_systems)#Serializable
+[Linearizability]: #Linearizability
+[txn]: api.md#transactions
diff --git a/vendor/github.com/coreos/etcd/Documentation/learning/auth_design.md b/vendor/github.com/coreos/etcd/Documentation/learning/auth_design.md
new file mode 100644
index 00000000..192f4b21
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/learning/auth_design.md
@@ -0,0 +1,77 @@
+?# etcd v3 authentication design
+
+## Why not reuse the v2 auth system?
+
+The v3 protocol uses gRPC as its transport instead of a RESTful interface like v2. This new protocol provides an opportunity to iterate on and improve the v2 design. For example, v3 auth has connection based authentication, rather than v2's slower per-request authentication. Additionally, v2 auth's semantics tend to be unwieldy in practice with respect to reasoning about consistency, which will be described in the next sections. For v3, there is a well-defined description and implementation of the authentication mechanism which fixes the deficiencies in the v2 auth system.
+
+### Functionality requirements
+
+* Per connection authentication, not per request
+ * User ID + password based authentication implemented for the gRPC API
+ * Authentication must be refreshed after auth policy changes
+* Its functionality should be as simple and useful as v2
+ * v3 provides a flat key space, unlike the directory structure of v2. Permission checking will be provided as interval matching.
+* It should have stronger consistency guarantees than v2 auth
+
+### Main required changes
+
+* A client must create a dedicated connection only for authentication before sending authenticated requests
+* Add permission information (user ID and authorized revision) to the Raft commands (`etcdserverpb.InternalRaftRequest`)
+* Every request is permission checked in the state machine layer, rather than API layer
+
+### Permission metadata consistency
+
+The metadata for auth should also be stored and managed in the storage controlled by etcd's Raft protocol like other data stored in etcd. It is required for not sacrificing availability and consistency of the entire etcd cluster. If reading or writing the metadata (e.g. permission information) needs an agreement of every node (more than quorum), single node failure can stop the entire cluster. Requiring all nodes to agree at once means that checking ordinary read/write requests cannot be completed if any cluster member is down, even if the cluster has an available quorum. This unanimous scheme ultimately degrades cluster availability; quorum based consensus from raft should suffice since agreement follows from consistent ordering.
+
+The authentication mechanism in the etcd v2 protocol has a tricky part because the metadata consistency should work as in the above, but does not: each permission check is processed by the etcd member that receives the client request (etcdserver/api/v2http/client.go), including follower members. Therefore, it's possible the check may be based on stale metadata.
+
+
+This staleness means that auth configuration cannot be reflected as soon as operators execute etcdctl. Therefore there is no way to know how long the stale metadata is active. Practically, the configuration change is reflected immediately after the command execution. However, in some cases of heavy load, the inconsistent state can be prolonged and it might result in counter-intuitive situations for users and developers. It requires a workaround like this: https://github.com/coreos/etcd/pull/4317#issuecomment-179037582
+
+### Inconsistent permissions are unsafe for linearized requests
+
+Inconsistent authentication state is most serious for writes. Even if an operator disables write on a user, if the write is only ordered with respect to the key value store but not the authentication system, it's possible the write will complete successfully. Without ordering on both the auth store and the key-value store, the system will be susceptible to stale permission attacks.
+
+Therefore, the permission checking logic should be added to the state machine of etcd. Each state machine should check the requests based on its permission information in the apply phase (so the auth information must not be stale).
+
+## Design and implementation
+
+### Authentication
+
+At first, a client must create a gRPC connection only to authenticate its user ID and password. An etcd server will respond with an authentication reply. The reponse will be an authentication token on success or an error on failure. The client can use its authentication token to present its credentials to etcd when making API requests.
+
+The client connection used to request the authentication token is typically thrown away; it cannot carry the new token's credentials. This is because gRPC doesn't provide a way for adding per RPC credential after creation of the connection (calling `grpc.Dial()`). Therefore, a client cannot assign a token to its connection that is obtained through the connection. The client needs a new connection for using the token.
+
+#### Notes on the implementation of `Authenticate()` RPC
+
+`Authenticate()` RPC generates an authentication token based on a given user name and password. etcd saves and checks a configured password and a given password using Go's `bcrypt` package. By design, `bcrypt`'s password checking mechanism is computationally expensive, taking nearly 100ms on an ordinary x64 server. Therefore, performing this check in the state machine apply phase would cause performance trouble: the entire etcd cluster can only serve almost 10 `Authenticate()` requests per second.
+
+For good performance, the v3 auth mechanism checks passwords in etcd's API layer, where it can be parallelized outside of raft. However, this can lead to potential time-of-check/time-of-use (TOCTOU) permission lapses:
+1. client A sends a request `Authenticate()`
+1. the API layer processes the password checking part of `Authenticate()`
+1. another client B sends a request of `ChangePassword()` and the server completes it
+1. the state machine layer processes the part of getting a revision number for the `Authenticate()` from A
+1. the server returns a success to A
+1. now A is authenticated on an obsolete password
+
+For avoiding such a situation, the API layer performs *version number validation* based on the revision number of the auth store. During password checking, the API layer saves the revision number of auth store. After successful password checking, the API layer compares the saved revision number and the latest revision number. If the numbers differ, it means someone else updated the auth metadata. So it retries the checking. With this mechanism, the successful password checking based on the obsolete password can be avoided.
+
+### Resolving a token in the API layer
+
+After authenticating with `Authenticate()`, a client can create a gRPC connection as it would without auth. In addition to the existing initialization process, the client must associate the token with the newly created connection. `grpc.WithPerRPCCredentials()` provides the functionality for this purpose.
+
+Every authenticated request from the client has a token. The token can be obtained with `grpc.metadata.FromContext()` in the server side. The server can obtain who is issuing the request and when the user was authorized. The information will be filled by the API layer in the header (`etcdserverpb.RequestHeader.Username` and `etcdserverpb.RequestHeader.AuthRevision`) of a raft log entry (`etcdserverpb.InternalRaftRequest`).
+
+### Checking permission in the state machine
+
+The auth info in `etcdserverpb.RequestHeader` is checked in the apply phase of the state machine. This step checks the user is granted permission to requested keys on the latest revision of auth store.
+
+### Two types of tokens: simple and JWT
+
+There are two kinds of token types: simple and JWT. The simple token isn't designed for production use cases. Its tokens aren't cryptographically signed and servers must statefully track token-user correspondence; it is meant for development testing. JWT tokens should be used for production deployments since it is cryptographically signed and verified. From the implementation perspective, JWT is stateless. Its token can include metadata including username and revision, so servers don't need to remember correspondence between tokens and the metadata.
+
+## Notes on the difference between KVS models and file system models
+
+etcd v3 is a KVS, not a file system. So the permissions can be granted to the users in form of an exact key name or a key range like `["start key", "end key")`. It means that granting a permission of a nonexistent key is possible. Users should care about unintended permission granting. In a case of file system like system (e.g. Chubby or ZooKeeper), an inode like data structure can include the permission information. So granting permission to a nonexist key won't be possible (except the case of sticky bits).
+
+The etcd v3 model requires multiple lookup of the metadata unlike the file system like systems. The worst case lookup cost will be sum the user's total granted keys and intervals. The cost cannot be avoided because v3's flat key space is completely different from Unix's file system model (every inode includes permission metadata). Practically the cost won?t be a serious problem because the metadata is small enough to benefit from caching.
diff --git a/vendor/github.com/coreos/etcd/Documentation/learning/data_model.md b/vendor/github.com/coreos/etcd/Documentation/learning/data_model.md
new file mode 100644
index 00000000..c2986a6f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/learning/data_model.md
@@ -0,0 +1,25 @@
+# Data model
+
+etcd is designed to reliably store infrequently updated data and provide reliable watch queries. etcd exposes previous versions of key-value pairs to support inexpensive snapshots and watch history events (?time travel queries?). A persistent, multi-version, concurrency-control data model is a good fit for these use cases.
+
+etcd stores data in a multiversion [persistent][persistent-ds] key-value store. The persistent key-value store preserves the previous version of a key-value pair when its value is superseded with new data. The key-value store is effectively immutable; its operations do not update the structure in-place, but instead always generates a new updated structure. All past versions of keys are still accessible and watchable after modification. To prevent the data store from growing indefinitely over time from maintaining old versions, the store may be compacted to shed the oldest versions of superseded data.
+
+### Logical view
+
+The store?s logical view is a flat binary key space. The key space has a lexically sorted index on byte string keys so range queries are inexpensive.
+
+The key space maintains multiple revisions. Each atomic mutative operation (e.g., a transaction operation may contain multiple operations) creates a new revision on the key space. All data held by previous revisions remains unchanged. Old versions of key can still be accessed through previous revisions. Likewise, revisions are indexed as well; ranging over revisions with watchers is efficient. If the store is compacted to recover space, revisions before the compact revision will be removed.
+
+A key?s lifetime spans a generation. Each key may have one or multiple generations. Creating a key increments the generation of that key, starting at 1 if the key never existed. Deleting a key generates a key tombstone, concluding the key?s current generation. Each modification of a key creates a new version of the key. Once a compaction happens, any generation ended before the given revision will be removed and values set before the compaction revision except the latest one will be removed.
+
+### Physical view
+
+etcd stores the physical data as key-value pairs in a persistent [b+tree][b+tree]. Each revision of the store?s state only contains the delta from its previous revision to be efficient. A single revision may correspond to multiple keys in the tree.
+
+The key of key-value pair is a 3-tuple (major, sub, type). Major is the store revision holding the key. Sub differentiates among keys within the same revision. Type is an optional suffix for special value (e.g., `t` if the value contains a tombstone). The value of the key-value pair contains the modification from previous revision, thus one delta from previous revision. The b+tree is ordered by key in lexical byte-order. Ranged lookups over revision deltas are fast; this enables quickly finding modifications from one specific revision to another. Compaction removes out-of-date keys-value pairs.
+
+etcd also keeps a secondary in-memory [btree][btree] index to speed up range queries over keys. The keys in the btree index are the keys of the store exposed to user. The value is a pointer to the modification of the persistent b+tree. Compaction removes dead pointers.
+
+[persistent-ds]: https://en.wikipedia.org/wiki/Persistent_data_structure
+[btree]: https://en.wikipedia.org/wiki/B-tree
+[b+tree]: https://en.wikipedia.org/wiki/B%2B_tree
diff --git a/vendor/github.com/coreos/etcd/Documentation/learning/glossary.md b/vendor/github.com/coreos/etcd/Documentation/learning/glossary.md
new file mode 100644
index 00000000..876cb55e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/learning/glossary.md
@@ -0,0 +1,97 @@
+# Glossary
+
+This document defines the various terms used in etcd documentation, command line and source code.
+
+## Alarm
+
+The etcd server raises an alarm whenever the cluster needs operator intervention to remain reliable.
+
+## Authentication
+
+Authentication manages user access permissions for etcd resources.
+
+## Client
+
+A client connects to the etcd cluster to issue service requests such as fetching key-value pairs, writing data, or watching for updates.
+
+## Cluster
+
+Cluster consists of several members.
+
+The node in each member follows raft consensus protocol to replicate logs. Cluster receives proposals from members, commits them and apply to local store.
+
+## Compaction
+
+Compaction discards all etcd event history and superseded keys prior to a given revision. It is used to reclaim storage space in the etcd backend database.
+
+## Election
+
+The etcd cluster holds elections among its members to choose a leader as part of the raft consensus protocol.
+
+## Endpoint
+
+A URL pointing to an etcd service or resource.
+
+## Key
+
+A user-defined identifier for storing and retrieving user-defined values in etcd.
+
+## Key range
+
+A set of keys containing either an individual key, a lexical interval for all x such that a < x <= b, or all keys greater than a given key.
+
+## Keyspace
+
+The set of all keys in an etcd cluster.
+
+## Lease
+
+A short-lived renewable contract that deletes keys associated with it on its expiry.
+
+## Member
+
+A logical etcd server that participates in serving an etcd cluster.
+
+## Modification Revision
+
+The first revision to hold the last write to a given key.
+
+## Peer
+
+Peer is another member of the same cluster.
+
+## Proposal
+
+A proposal is a request (for example a write request, a configuration change request) that needs to go through raft protocol.
+
+## Quorum
+
+The number of active members needed for consensus to modify the cluster state. etcd requires a member majority to reach quorum.
+
+## Revision
+
+A 64-bit cluster-wide counter that is incremented each time the keyspace is modified.
+
+## Role
+
+A unit of permissions over a set of key ranges which may be granted to a set of users for access control.
+
+## Snapshot
+
+A point-in-time backup of the etcd cluster state.
+
+## Store
+
+The physical storage backing the cluster keyspace.
+
+## Transaction
+
+An atomically executed set of operations. All modified keys in a transaction share the same modification revision.
+
+## Key Version
+
+The number of writes to a key since it was created, starting at 1. The version of a nonexistent or deleted key is 0.
+
+## Watcher
+
+A client opens a watcher to observe updates on a given key range.
diff --git a/vendor/github.com/coreos/etcd/Documentation/learning/why.md b/vendor/github.com/coreos/etcd/Documentation/learning/why.md
new file mode 100644
index 00000000..ac61a583
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/learning/why.md
@@ -0,0 +1,116 @@
+# Why etcd
+
+The name "etcd" originated from two ideas, the unix "/etc" folder and "d"istibuted systems. The "/etc" folder is a place to store configuration data for a single system whereas etcd stores configuration information for large scale distributed systems. Hence, a "d"istributed "/etc" is "etcd".
+
+etcd stores metadata in a consistent and fault-tolerant way. Distributed systems use etcd as a consistent key-value store for configuration management, service discovery, and coordinating distributed work. Common distributed patterns using etcd include [leader election][etcd-etcdctl-elect], [distributed locks][etcd-etcdctl-lock], and monitoring machine liveness.
+
+## Use cases
+
+- Container Linux by CoreOS: Application running on [Container Linux][container-linux] gets automatic, zero-downtime Linux kernel updates. Container Linux uses [locksmith] to coordinate updates. locksmith implements a distributed semaphore over etcd to ensure only a subset of a cluster is rebooting at any given time.
+- [Kubernetes][kubernetes] stores configuration data into etcd for service discovery and cluster management; etcd's consistency is crucial for correctly scheduling and operating services. The Kubernetes API server persists cluster state into etcd. It uses etcd's watch API to monitor the cluster and roll out critical configuration changes.
+
+## etcd versus other key-value stores
+
+When deciding whether to use etcd as a key-value store, it?s worth keeping in mind etcd?s main goal. Namely, etcd is designed as a general substrate for large scale distributed systems. These are systems that will never tolerate split-brain operation and are willing to sacrifice availability to achieve this end. An etcd cluster is meant to provide consistent key-value storage with best of class stability, reliability, scalability and performance. The upshot of this focus is many [organizations][production-users] already use etcd to implement production systems such as container schedulers, service discovery services, distributed data storage, and more.
+
+Perhaps etcd already seems like a good fit, but as with all technological decisions, proceed with caution. Please note this documentation is written by the etcd team. Although the ideal is a disinterested comparison of technology and features, the authors? expertise and biases obviously favor etcd. Use only as directed.
+
+The table below is a handy quick reference for spotting the differences among etcd and its most popular alternatives at a glance. Further commentary and details for each column are in the sections following the table.
+
+| | etcd | ZooKeeper | Consul | NewSQL (Cloud Spanner, CockroachDB, TiDB) |
+| --- | --- | --- | --- | --- |
+| Concurrency Primitives | [Lock RPCs][etcd-v3lock], [Election RPCs][etcd-v3election], [command line locks][etcd-etcdctl-lock], [command line elections][etcd-etcdctl-elect], [recipes][etcd-recipe] in go | External [curator recipes][curator] in Java | [Native lock API][consul-lock] | [Rare][newsql-leader], if any |
+| Linearizable Reads | [Yes][etcd-linread] | No | [Yes][consul-linread] | Sometimes |
+| Multi-version Concurrency Control | [Yes][etcd-mvcc] | No | No | Sometimes |
+| Transactions | [Field compares, Read, Write][etcd-txn] | [Version checks, Write][zk-txn] | [Field compare, Lock, Read, Write][consul-txn] | SQL-style |
+| Change Notification | [Historical and current key intervals][etcd-watch] | [Current keys and directories][zk-watch] | [Current keys and prefixes][consul-watch] | Triggers (sometimes) |
+| User permissions | [Role based][etcd-rbac] | [ACLs][zk-acl] | [ACLs][consul-acl] | Varies (per-table [GRANT][cockroach-grant], per-database [roles][spanner-roles]) |
+| HTTP/JSON API | [Yes][etcd-json] | No | [Yes][consul-json] | Rarely |
+| Membership Reconfiguration | [Yes][etcd-reconfig] | [>3.5.0][zk-reconfig] | [Yes][consul-reconfig] | Yes |
+| Maximum reliable database size | Several gigabytes | Hundreds of megabytes (sometimes several gigabytes) | Hundreds of MBs | Terabytes+ |
+| Minimum read linearization latency | Network RTT | No read linearization | RTT + fsync | Clock barriers (atomic, NTP) |
+
+### ZooKeeper
+
+ZooKeeper solves the same problem as etcd: distributed system coordination and metadata storage. However, etcd has the luxury of hindsight taken from engineering and operational experience with ZooKeeper?s design and implementation. The lessons learned from Zookeeper certainly informed etcd?s design, helping it support large scale systems like Kubernetes. The improvements etcd made over Zookeeper include:
+
+* Dynamic cluster membership reconfiguration
+* Stable read/write under high load
+* A multi-version concurrency control data model
+* Reliable key monitoring which never silently drop events
+* Lease primitives decoupling connections from sessions
+* APIs for safe distributed shared locks
+
+Furthermore, etcd supports a wide range of languages and frameworks out of the box. Whereas Zookeeper has its own custom Jute RPC protocol, which is totally unique to Zookeeper and limits its [supported language bindings][zk-bindings], etcd?s client protocol is built from [gRPC][grpc], a popular RPC framework with language bindings for go, C++, Java, and more. Likewise, gRPC can be serialized into JSON over HTTP, so even general command line utilities like `curl` can talk to it. Since systems can select from a variety of choices, they are built on etcd with native tooling rather than around etcd with a single fixed set of technologies.
+
+When considering features, support, and stability, new applications planning to use Zookeeper for a consistent key value store would do well to choose etcd instead.
+
+### Consul
+
+Consul bills itself as an end-to-end service discovery framework. To wit, it includes services such as health checking, failure detection, and DNS. Incidentally, Consul also exposes a key value store with mediocre performance and an intricate API. As it stands in Consul 0.7, the storage system does not scales well; systems requiring millions of keys will suffer from high latencies and memory pressure. The key value API is missing, most notably, multi-version keys, conditional transactions, and reliable streaming watches.
+
+etcd and Consul solve different problems. If looking for a distributed consistent key value store, etcd is a better choice over Consul. If looking for end-to-end cluster service discovery, etcd will not have enough features; choose Kubernetes, Consul, or SmartStack.
+
+### NewSQL (Cloud Spanner, CockroachDB, TiDB)
+
+Both etcd and NewSQL databases (e.g., [Cockroach][cockroach], [TiDB][tidb], [Google Spanner][spanner]) provide strong data consistency guarantees with high availability. However, the significantly different system design parameters lead to significantly different client APIs and performance characteristics.
+
+NewSQL databases are meant to horizontally scale across data centers. These systems typically partition data across multiple consistent replication groups (shards), potentially distant, storing data sets on the order of terabytes and above. This sort of scaling makes them poor candidates for distributed coordination as they have long latencies from waiting on clocks and expect updates with mostly localized dependency graphs. The data is organized into tables, including SQL-style query facilities with richer semantics than etcd, but at the cost of additional complexity for processing, planning, and optimizing queries.
+
+In short, choose etcd for storing metadata or coordinating distributed applications. If storing more than a few GB of data or if full SQL queries are needed, choose a NewSQL database.
+
+## Using etcd for metadata
+
+etcd replicates all data within a single consistent replication group. For storing up to a few GB of data with consistent ordering, this is the most efficient approach. Each modification of cluster state, which may change multiple keys, is assigned a global unique ID, called a revision in etcd, from a monotonically increasing counter for reasoning over ordering. Since there?s only a single replication group, the modification request only needs to go through the raft protocol to commit. By limiting consensus to one replication group, etcd gets distributed consistency with a simple protocol while achieving low latency and high throughput.
+
+The replication behind etcd cannot horizontally scale because it lacks data sharding. In contrast, NewSQL databases usually shard data across multiple consistent replication groups, storing data sets on the order of terabytes and above. However, to assign each modification a global unique and increasing ID, each request must go through an additional coordination protocol among replication groups. This extra coordination step may potentially conflict on the global ID, forcing ordered requests to retry. The result is a more complicated approach with typically worse performance than etcd for strict ordering.
+
+If an application reasons primarily about metadata or metadata ordering, such as to coordinate processes, choose etcd. If the application needs a large data store spanning multiple data centers and does not heavily depend on strong global ordering properties, choose a NewSQL database.
+
+## Using etcd for distributed coordination
+
+etcd has distributed coordination primitives such as event watches, leases, elections, and distributed shared locks out of the box. These primitives are both maintained and supported by the etcd developers; leaving these primitives to external libraries shirks the responsibility of developing foundational distributed software, essentially leaving the system incomplete. NewSQL databases usually expect these distributed coordination primitives to be authored by third parties. Likewise, ZooKeeper famously has a separate and independent [library][curator] of coordination recipes. Consul, which provides a native locking API, goes so far as to apologize that it?s ?[not a bulletproof method][consul-bulletproof]?.
+
+In theory, it?s possible to build these primitives atop any storage systems providing strong consistency. However, the algorithms tend to be subtle; it is easy to develop a locking algorithm that appears to work, only to suddenly break due to thundering herd and timing skew. Furthermore, other primitives supported by etcd, such as transactional memory depend on etcd?s MVCC data model; simple strong consistency is not enough.
+
+For distributed coordination, choosing etcd can help prevent operational headaches and save engineering effort.
+
+[production-users]: ../production-users.md
+[grpc]: http://www.grpc.io
+[consul-bulletproof]: https://www.consul.io/docs/internals/sessions.html
+[curator]: http://curator.apache.org/
+[cockroach]: https://github.com/cockroachdb/cockroach
+[spanner]: https://cloud.google.com/spanner/
+[tidb]: https://github.com/pingcap/tidb
+[etcd-v3lock]: https://godoc.org/github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb
+[etcd-v3election]: https://godoc.org/github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb
+[etcd-etcdctl-lock]: ../../etcdctl/README.md#lock-lockname
+[etcd-etcdctl-elect]: ../../etcdctl/README.md#elect-options-election-name-proposal
+[etcd-mvcc]: data_model.md
+[etcd-recipe]: https://godoc.org/github.com/coreos/etcd/contrib/recipes
+[consul-lock]: https://www.consul.io/docs/commands/lock.html
+[newsql-leader]: http://dl.acm.org/citation.cfm?id=2960999
+[etcd-reconfig]: ../op-guide/runtime-configuration.md
+[zk-reconfig]: https://zookeeper.apache.org/doc/trunk/zookeeperReconfig.html
+[consul-reconfig]: https://www.consul.io/docs/guides/servers.html
+[etcd-linread]: api_guarantees.md#linearizability
+[consul-linread]: https://www.consul.io/docs/agent/http.html#consistency
+[etcd-json]: ../dev-guide/api_grpc_gateway.md
+[consul-json]: https://www.consul.io/docs/agent/http.html#formatted-json-output
+[etcd-txn]: api.md#transaction
+[zk-txn]: https://zookeeper.apache.org/doc/r3.4.3/api/org/apache/zookeeper/ZooKeeper.html#multi(java.lang.Iterable)
+[consul-txn]: https://www.consul.io/docs/agent/http/kv.html#txn
+[etcd-watch]: api.md#watch-streams
+[zk-watch]: https://zookeeper.apache.org/doc/trunk/zookeeperProgrammers.html#ch_zkWatches
+[consul-watch]: https://www.consul.io/docs/agent/watches.html
+[etcd-commonname]: ../op-guide/authentication.md#using-tls-common-name
+[etcd-rbac]: ../op-guide/authentication.md#working-with-roles
+[zk-acl]: https://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html#sc_ZooKeeperAccessControl
+[consul-acl]: https://www.consul.io/docs/internals/acl.html
+[cockroach-grant]: https://www.cockroachlabs.com/docs/grant.html
+[spanner-roles]: https://cloud.google.com/spanner/docs/iam#roles
+[zk-bindings]: https://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html#ch_bindings
+[container-linux]: https://coreos.com/why
+[locksmith]: https://github.com/coreos/locksmith
+[kubernetes]: http://kubernetes.io/docs/whatisk8s
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/metrics.md b/vendor/github.com/coreos/etcd/Documentation/metrics.md
new file mode 100644
index 00000000..58e52639
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/metrics.md
@@ -0,0 +1,116 @@
+# Metrics
+
+etcd uses [Prometheus][prometheus] for metrics reporting. The metrics can be used for real-time monitoring and debugging. etcd does not persist its metrics; if a member restarts, the metrics will be reset.
+
+The simplest way to see the available metrics is to cURL the metrics endpoint `/metrics`. The format is described [here](http://prometheus.io/docs/instrumenting/exposition_formats/).
+
+Follow the [Prometheus getting started doc][prometheus-getting-started] to spin up a Prometheus server to collect etcd metrics.
+
+The naming of metrics follows the suggested [Prometheus best practices][prometheus-naming]. A metric name has an `etcd` or `etcd_debugging` prefix as its namespace and a subsystem prefix (for example `wal` and `etcdserver`).
+
+## etcd namespace metrics
+
+The metrics under the `etcd` prefix are for monitoring and alerting. They are stable high level metrics. If there is any change of these metrics, it will be included in release notes.
+
+Metrics that are etcd2 related are documented [v2 metrics guide][v2-http-metrics].
+
+### Server
+
+These metrics describe the status of the etcd server. In order to detect outages or problems for troubleshooting, the server metrics of every production etcd cluster should be closely monitored.
+
+All these metrics are prefixed with `etcd_server_`
+
+| Name | Description | Type |
+|---------------------------|----------------------------------------------------------|---------|
+| has_leader | Whether or not a leader exists. 1 is existence, 0 is not.| Gauge |
+| leader_changes_seen_total | The number of leader changes seen. | Counter |
+| proposals_committed_total | The total number of consensus proposals committed. | Gauge |
+| proposals_applied_total | The total number of consensus proposals applied. | Gauge |
+| proposals_pending | The current number of pending proposals. | Gauge |
+| proposals_failed_total | The total number of failed proposals seen. | Counter |
+
+`has_leader` indicates whether the member has a leader. If a member does not have a leader, it is
+totally unavailable. If all the members in the cluster do not have any leader, the entire cluster
+is totally unavailable.
+
+`leader_changes_seen_total` counts the number of leader changes the member has seen since its start. Rapid leadership changes impact the performance of etcd significantly. It also signals that the leader is unstable, perhaps due to network connectivity issues or excessive load hitting the etcd cluster.
+
+`proposals_committed_total` records the total number of consensus proposals committed. This gauge should increase over time if the cluster is healthy. Several healthy members of an etcd cluster may have different total committed proposals at once. This discrepancy may be due to recovering from peers after starting, lagging behind the leader, or being the leader and therefore having the most commits. It is important to monitor this metric across all the members in the cluster; a consistently large lag between a single member and its leader indicates that member is slow or unhealthy.
+
+`proposals_applied_total` records the total number of consensus proposals applied. The etcd server applies every committed proposal asynchronously. The difference between `proposals_committed_total` and `proposals_applied_total` should usually be small (within a few thousands even under high load). If the difference between them continues to rise, it indicates that the etcd server is overloaded. This might happen when applying expensive queries like heavy range queries or large txn operations.
+
+`proposals_pending` indicates how many proposals are queued to commit. Rising pending proposals suggests there is a high client load or the member cannot commit proposals.
+
+`proposals_failed_total` are normally related to two issues: temporary failures related to a leader election or longer downtime caused by a loss of quorum in the cluster.
+
+### Disk
+
+These metrics describe the status of the disk operations.
+
+All these metrics are prefixed with `etcd_disk_`.
+
+| Name | Description | Type |
+|------------------------------------|-------------------------------------------------------|-----------|
+| wal_fsync_duration_seconds | The latency distributions of fsync called by wal | Histogram |
+| backend_commit_duration_seconds | The latency distributions of commit called by backend.| Histogram |
+
+A `wal_fsync` is called when etcd persists its log entries to disk before applying them.
+
+A `backend_commit` is called when etcd commits an incremental snapshot of its most recent changes to disk.
+
+High disk operation latencies (`wal_fsync_duration_seconds` or `backend_commit_duration_seconds`) often indicate disk issues. It may cause high request latency or make the cluster unstable.
+
+### Network
+
+These metrics describe the status of the network.
+
+All these metrics are prefixed with `etcd_network_`
+
+| Name | Description | Type |
+|---------------------------|--------------------------------------------------------------------|---------------|
+| peer_sent_bytes_total | The total number of bytes sent to the peer with ID `To`. | Counter(To) |
+| peer_received_bytes_total | The total number of bytes received from the peer with ID `From`. | Counter(From) |
+| peer_sent_failures_total | The total number of send failures from the peer with ID `To`. | Counter(To) |
+| peer_received_failures_total | The total number of receive failures from the peer with ID `From`. | Counter(From) |
+| peer_round_trip_time_seconds | Round-Trip-Time histogram between peers. | Histogram(To) |
+| client_grpc_sent_bytes_total | The total number of bytes sent to grpc clients. | Counter |
+| client_grpc_received_bytes_total| The total number of bytes received to grpc clients. | Counter |
+
+`peer_sent_bytes_total` counts the total number of bytes sent to a specific peer. Usually the leader member sends more data than other members since it is responsible for transmitting replicated data.
+
+`peer_received_bytes_total` counts the total number of bytes received from a specific peer. Usually follower members receive data only from the leader member.
+
+### gRPC requests
+
+These metrics are exposed via [go-grpc-prometheus][go-grpc-prometheus].
+
+## etcd_debugging namespace metrics
+
+The metrics under the `etcd_debugging` prefix are for debugging. They are very implementation dependent and volatile. They might be changed or removed without any warning in new etcd releases. Some of the metrics might be moved to the `etcd` prefix when they become more stable.
+
+
+### Snapshot
+
+| Name | Description | Type |
+|--------------------------------------------|------------------------------------------------------------|-----------|
+| snapshot_save_total_duration_seconds | The total latency distributions of save called by snapshot | Histogram |
+
+Abnormally high snapshot duration (`snapshot_save_total_duration_seconds`) indicates disk issues and might cause the cluster to be unstable.
+
+## Prometheus supplied metrics
+
+The Prometheus client library provides a number of metrics under the `go` and `process` namespaces. There are a few that are particlarly interesting.
+
+| Name | Description | Type |
+|-----------------------------------|--------------------------------------------|--------------|
+| process_open_fds | Number of open file descriptors. | Gauge |
+| process_max_fds | Maximum number of open file descriptors. | Gauge |
+
+Heavy file descriptor (`process_open_fds`) usage (i.e., near the process's file descriptor limit, `process_max_fds`) indicates a potential file descriptor exhaustion issue. If the file descriptors are exhausted, etcd may panic because it cannot create new WAL files.
+
+[glossary-proposal]: learning/glossary.md#proposal
+[prometheus]: http://prometheus.io/
+[prometheus-getting-started]: http://prometheus.io/docs/introduction/getting_started/
+[prometheus-naming]: http://prometheus.io/docs/practices/naming/
+[v2-http-metrics]: v2/metrics.md#http-requests
+[go-grpc-prometheus]: https://github.com/grpc-ecosystem/go-grpc-prometheus
\ No newline at end of file
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/authentication.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/authentication.md
new file mode 100644
index 00000000..9fd8f0f9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/authentication.md
@@ -0,0 +1,164 @@
+# Authentication Guide
+
+## Overview
+
+Authentication was added in etcd 2.1. The etcd v3 API slightly modified the authentication feature's API and user interface to better fit the new data model. This guide is intended to help users set up basic authentication in etcd v3.
+
+## Special users and roles
+
+There is one special user, `root`, and one special role, `root`.
+
+### User `root`
+
+The `root` user, which has full access to etcd, must be created before activating authentication. The idea behind the `root` user is for administrative purposes: managing roles and ordinary users. The `root` user must have the `root` role and is allowed to change anything inside etcd.
+
+### Role `root`
+
+The role `root` may be granted to any user, in addition to the root user. A user with the `root` role has both global read-write access and permission to update the cluster's authentication configuration. Furthermore, the `root` role grants privileges for general cluster maintenance, including modifying cluster membership, defragmenting the store, and taking snapshots.
+
+## Working with users
+
+The `user` subcommand for `etcdctl` handles all things having to do with user accounts.
+
+A listing of users can be found with:
+
+```
+$ etcdctl user list
+```
+
+Creating a user is as easy as
+
+```
+$ etcdctl user add myusername
+```
+
+Creating a new user will prompt for a new password. The password can be supplied from standard input when an option `--interactive=false` is given.
+
+Roles can be granted and revoked for a user with:
+
+```
+$ etcdctl user grant-role myusername foo
+$ etcdctl user revoke-role myusername bar
+```
+
+The user's settings can be inspected with:
+
+```
+$ etcdctl user get myusername
+```
+
+And the password for a user can be changed with
+
+```
+$ etcdctl user passwd myusername
+```
+
+Changing the password will prompt again for a new password. The password can be supplied from standard input when an option `--interactive=false` is given.
+
+Delete an account with:
+```
+$ etcdctl user delete myusername
+```
+
+
+## Working with roles
+
+The `role` subcommand for `etcdctl` handles all things having to do with access controls for particular roles, as were granted to individual users.
+
+List roles with:
+
+```
+$ etcdctl role list
+```
+
+Create a new role with:
+
+```
+$ etcdctl role add myrolename
+```
+
+A role has no password; it merely defines a new set of access rights.
+
+Roles are granted access to a single key or a range of keys.
+
+The range can be specified as an interval [start-key, end-key) where start-key should be lexically less than end-key in an alphabetical manner.
+
+Access can be granted as either read, write, or both, as in the following examples:
+
+```
+# Give read access to a key /foo
+$ etcdctl role grant-permission myrolename read /foo
+
+# Give read access to keys with a prefix /foo/. The prefix is equal to the range [/foo/, /foo0)
+$ etcdctl role grant-permission myrolename --prefix=true read /foo/
+
+# Give write-only access to the key at /foo/bar
+$ etcdctl role grant-permission myrolename write /foo/bar
+
+# Give full access to keys in a range of [key1, key5)
+$ etcdctl role grant-permission myrolename readwrite key1 key5
+
+# Give full access to keys with a prefix /pub/
+$ etcdctl role grant-permission myrolename --prefix=true readwrite /pub/
+```
+
+To see what's granted, we can look at the role at any time:
+
+```
+$ etcdctl role get myrolename
+```
+
+Revocation of permissions is done the same logical way:
+
+```
+$ etcdctl role revoke-permission myrolename /foo/bar
+```
+
+As is removing a role entirely:
+
+```
+$ etcdctl role remove myrolename
+```
+
+## Enabling authentication
+
+The minimal steps to enabling auth are as follows. The administrator can set up users and roles before or after enabling authentication, as a matter of preference.
+
+Make sure the root user is created:
+
+```
+$ etcdctl user add root
+Password of root:
+```
+
+Enable authentication:
+
+```
+$ etcdctl auth enable
+```
+
+After this, etcd is running with authentication enabled. To disable it for any reason, use the reciprocal command:
+
+```
+$ etcdctl --user root:rootpw auth disable
+```
+
+## Using `etcdctl` to authenticate
+
+`etcdctl` supports a similar flag as `curl` for authentication.
+
+```
+$ etcdctl --user user:password get foo
+```
+
+The password can be taken from a prompt:
+
+```
+$ etcdctl --user user get foo
+```
+
+Otherwise, all `etcdctl` commands remain the same. Users and roles can still be created and modified, but require authentication by a user with the root role.
+
+## Using TLS Common Name
+
+If an etcd server is launched with the option `--client-cert-auth=true`, the field of Common Name (CN) in the client's TLS cert will be used as an etcd user. In this case, the common name authenticates the user and the client does not need a password.
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/clustering.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/clustering.md
new file mode 100644
index 00000000..e058b797
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/clustering.md
@@ -0,0 +1,479 @@
+# Clustering Guide
+
+## Overview
+
+Starting an etcd cluster statically requires that each member knows another in the cluster. In a number of cases, the IPs of the cluster members may be unknown ahead of time. In these cases, the etcd cluster can be bootstrapped with the help of a discovery service.
+
+Once an etcd cluster is up and running, adding or removing members is done via [runtime reconfiguration][runtime-conf]. To better understand the design behind runtime reconfiguration, we suggest reading [the runtime configuration design document][runtime-reconf-design].
+
+This guide will cover the following mechanisms for bootstrapping an etcd cluster:
+
+* [Static](#static)
+* [etcd Discovery](#etcd-discovery)
+* [DNS Discovery](#dns-discovery)
+
+Each of the bootstrapping mechanisms will be used to create a three machine etcd cluster with the following details:
+
+|Name|Address|Hostname|
+|------|---------|------------------|
+|infra0|10.0.1.10|infra0.example.com|
+|infra1|10.0.1.11|infra1.example.com|
+|infra2|10.0.1.12|infra2.example.com|
+
+## Static
+
+As we know the cluster members, their addresses and the size of the cluster before starting, we can use an offline bootstrap configuration by setting the `initial-cluster` flag. Each machine will get either the following environment variables or command line:
+
+```
+ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380"
+ETCD_INITIAL_CLUSTER_STATE=new
+```
+
+```
+--initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
+--initial-cluster-state new
+```
+
+Note that the URLs specified in `initial-cluster` are the _advertised peer URLs_, i.e. they should match the value of `initial-advertise-peer-urls` on the respective nodes.
+
+If spinning up multiple clusters (or creating and destroying a single cluster) with same configuration for testing purpose, it is highly recommended that each cluster is given a unique `initial-cluster-token`. By doing this, etcd can generate unique cluster IDs and member IDs for the clusters even if they otherwise have the exact same configuration. This can protect etcd from cross-cluster-interaction, which might corrupt the clusters.
+
+etcd listens on [`listen-client-urls`][conf-listen-client] to accept client traffic. etcd member advertises the URLs specified in [`advertise-client-urls`][conf-adv-client] to other members, proxies, clients. Please make sure the `advertise-client-urls` are reachable from intended clients. A common mistake is setting `advertise-client-urls` to localhost or leave it as default if the remote clients should reach etcd.
+
+On each machine, start etcd with these flags:
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \
+ --listen-peer-urls http://10.0.1.10:2380 \
+ --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.10:2379 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
+ --initial-cluster-state new
+```
+```
+$ etcd --name infra1 --initial-advertise-peer-urls http://10.0.1.11:2380 \
+ --listen-peer-urls http://10.0.1.11:2380 \
+ --listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.11:2379 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
+ --initial-cluster-state new
+```
+```
+$ etcd --name infra2 --initial-advertise-peer-urls http://10.0.1.12:2380 \
+ --listen-peer-urls http://10.0.1.12:2380 \
+ --listen-client-urls http://10.0.1.12:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.12:2379 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
+ --initial-cluster-state new
+```
+
+The command line parameters starting with `--initial-cluster` will be ignored on subsequent runs of etcd. Feel free to remove the environment variables or command line flags after the initial bootstrap process. If the configuration needs changes later (for example, adding or removing members to/from the cluster), see the [runtime configuration][runtime-conf] guide.
+
+### TLS
+
+etcd supports encrypted communication through the TLS protocol. TLS channels can be used for encrypted internal cluster communication between peers as well as encrypted client traffic. This section provides examples for setting up a cluster with peer and client TLS. Additional information detailing etcd's TLS support can be found in the [security guide][security-guide].
+
+#### Self-signed certificates
+
+A cluster using self-signed certificates both encrypts traffic and authenticates its connections. To start a cluster with self-signed certificates, each cluster member should have a unique key pair (`member.crt`, `member.key`) signed by a shared cluster CA certificate (`ca.crt`) for both peer connections and client connections. Certificates may be generated by following the etcd [TLS setup][tls-setup] example.
+
+On each machine, etcd would be started with these flags:
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls https://10.0.1.10:2380 \
+ --listen-peer-urls https://10.0.1.10:2380 \
+ --listen-client-urls https://10.0.1.10:2379,https://127.0.0.1:2379 \
+ --advertise-client-urls https://10.0.1.10:2379 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-cluster infra0=https://10.0.1.10:2380,infra1=https://10.0.1.11:2380,infra2=https://10.0.1.12:2380 \
+ --initial-cluster-state new \
+ --client-cert-auth --trusted-ca-file=/path/to/ca-client.crt \
+ --cert-file=/path/to/infra0-client.crt --key-file=/path/to/infra0-client.key \
+ --peer-client-cert-auth --peer-trusted-ca-file=ca-peer.crt \
+ --peer-cert-file=/path/to/infra0-peer.crt --peer-key-file=/path/to/infra0-peer.key
+```
+```
+$ etcd --name infra1 --initial-advertise-peer-urls https://10.0.1.11:2380 \
+ --listen-peer-urls https://10.0.1.11:2380 \
+ --listen-client-urls https://10.0.1.11:2379,https://127.0.0.1:2379 \
+ --advertise-client-urls https://10.0.1.11:2379 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-cluster infra0=https://10.0.1.10:2380,infra1=https://10.0.1.11:2380,infra2=https://10.0.1.12:2380 \
+ --initial-cluster-state new \
+ --client-cert-auth --trusted-ca-file=/path/to/ca-client.crt \
+ --cert-file=/path/to/infra1-client.crt --key-file=/path/to/infra1-client.key \
+ --peer-client-cert-auth --peer-trusted-ca-file=ca-peer.crt \
+ --peer-cert-file=/path/to/infra1-peer.crt --peer-key-file=/path/to/infra1-peer.key
+```
+```
+$ etcd --name infra2 --initial-advertise-peer-urls https://10.0.1.12:2380 \
+ --listen-peer-urls https://10.0.1.12:2380 \
+ --listen-client-urls https://10.0.1.12:2379,https://127.0.0.1:2379 \
+ --advertise-client-urls https://10.0.1.12:2379 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-cluster infra0=https://10.0.1.10:2380,infra1=https://10.0.1.11:2380,infra2=https://10.0.1.12:2380 \
+ --initial-cluster-state new \
+ --client-cert-auth --trusted-ca-file=/path/to/ca-client.crt \
+ --cert-file=/path/to/infra2-client.crt --key-file=/path/to/infra2-client.key \
+ --peer-client-cert-auth --peer-trusted-ca-file=ca-peer.crt \
+ --peer-cert-file=/path/to/infra2-peer.crt --peer-key-file=/path/to/infra2-peer.key
+```
+
+#### Automatic certificates
+
+If the cluster needs encrypted communication but does not require authenticated connections, etcd can be configured to automatically generate its keys. On initialization, each member creates its own set of keys based on its advertised IP addresses and hosts.
+
+On each machine, etcd would be started with these flags:
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls https://10.0.1.10:2380 \
+ --listen-peer-urls https://10.0.1.10:2380 \
+ --listen-client-urls https://10.0.1.10:2379,https://127.0.0.1:2379 \
+ --advertise-client-urls https://10.0.1.10:2379 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-cluster infra0=https://10.0.1.10:2380,infra1=https://10.0.1.11:2380,infra2=https://10.0.1.12:2380 \
+ --initial-cluster-state new \
+ --auto-tls \
+ --peer-auto-tls
+```
+```
+$ etcd --name infra1 --initial-advertise-peer-urls https://10.0.1.11:2380 \
+ --listen-peer-urls https://10.0.1.11:2380 \
+ --listen-client-urls https://10.0.1.11:2379,https://127.0.0.1:2379 \
+ --advertise-client-urls https://10.0.1.11:2379 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-cluster infra0=https://10.0.1.10:2380,infra1=https://10.0.1.11:2380,infra2=https://10.0.1.12:2380 \
+ --initial-cluster-state new \
+ --auto-tls \
+ --peer-auto-tls
+```
+```
+$ etcd --name infra2 --initial-advertise-peer-urls https://10.0.1.12:2380 \
+ --listen-peer-urls https://10.0.1.12:2380 \
+ --listen-client-urls https://10.0.1.12:2379,https://127.0.0.1:2379 \
+ --advertise-client-urls https://10.0.1.12:2379 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-cluster infra0=https://10.0.1.10:2380,infra1=https://10.0.1.11:2380,infra2=https://10.0.1.12:2380 \
+ --initial-cluster-state new \
+ --auto-tls \
+ --peer-auto-tls
+```
+
+### Error cases
+
+In the following example, we have not included our new host in the list of enumerated nodes. If this is a new cluster, the node _must_ be added to the list of initial cluster members.
+
+```
+$ etcd --name infra1 --initial-advertise-peer-urls http://10.0.1.11:2380 \
+ --listen-peer-urls https://10.0.1.11:2380 \
+ --listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.11:2379 \
+ --initial-cluster infra0=http://10.0.1.10:2380 \
+ --initial-cluster-state new
+etcd: infra1 not listed in the initial cluster config
+exit 1
+```
+
+In this example, we are attempting to map a node (infra0) on a different address (127.0.0.1:2380) than its enumerated address in the cluster list (10.0.1.10:2380). If this node is to listen on multiple addresses, all addresses _must_ be reflected in the "initial-cluster" configuration directive.
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls http://127.0.0.1:2380 \
+ --listen-peer-urls http://10.0.1.10:2380 \
+ --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.10:2379 \
+ --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
+ --initial-cluster-state=new
+etcd: error setting up initial cluster: infra0 has different advertised URLs in the cluster and advertised peer URLs list
+exit 1
+```
+
+If a peer is configured with a different set of configuration arguments and attempts to join this cluster, etcd will report a cluster ID mismatch will exit.
+
+```
+$ etcd --name infra3 --initial-advertise-peer-urls http://10.0.1.13:2380 \
+ --listen-peer-urls http://10.0.1.13:2380 \
+ --listen-client-urls http://10.0.1.13:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.13:2379 \
+ --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra3=http://10.0.1.13:2380 \
+ --initial-cluster-state=new
+etcd: conflicting cluster ID to the target cluster (c6ab534d07e8fcc4 != bc25ea2a74fb18b0). Exiting.
+exit 1
+```
+
+## Discovery
+
+In a number of cases, the IPs of the cluster peers may not be known ahead of time. This is common when utilizing cloud providers or when the network uses DHCP. In these cases, rather than specifying a static configuration, use an existing etcd cluster to bootstrap a new one. This process is called "discovery".
+
+There two methods that can be used for discovery:
+
+* etcd discovery service
+* DNS SRV records
+
+### etcd discovery
+
+To better understand the design of the discovery service protocol, we suggest reading the discovery service protocol [documentation][discovery-proto].
+
+#### Lifetime of a discovery URL
+
+A discovery URL identifies a unique etcd cluster. Instead of reusing an existing discovery URL, each etcd instance shares a new discovery URL to bootstrap the new cluster.
+
+Moreover, discovery URLs should ONLY be used for the initial bootstrapping of a cluster. To change cluster membership after the cluster is already running, see the [runtime reconfiguration][runtime-conf] guide.
+
+#### Custom etcd discovery service
+
+Discovery uses an existing cluster to bootstrap itself. If using a private etcd cluster, create a URL like so:
+
+```
+$ curl -X PUT https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83/_config/size -d value=3
+```
+
+By setting the size key to the URL, a discovery URL is created with an expected cluster size of 3.
+
+The URL to use in this case will be `https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83` and the etcd members will use the `https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83` directory for registration as they start.
+
+**Each member must have a different name flag specified. `Hostname` or `machine-id` can be a good choice. Or discovery will fail due to duplicated name.**
+
+Now we start etcd with those relevant flags for each member:
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \
+ --listen-peer-urls http://10.0.1.10:2380 \
+ --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.10:2379 \
+ --discovery https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83
+```
+```
+$ etcd --name infra1 --initial-advertise-peer-urls http://10.0.1.11:2380 \
+ --listen-peer-urls http://10.0.1.11:2380 \
+ --listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.11:2379 \
+ --discovery https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83
+```
+```
+$ etcd --name infra2 --initial-advertise-peer-urls http://10.0.1.12:2380 \
+ --listen-peer-urls http://10.0.1.12:2380 \
+ --listen-client-urls http://10.0.1.12:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.12:2379 \
+ --discovery https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83
+```
+
+This will cause each member to register itself with the custom etcd discovery service and begin the cluster once all machines have been registered.
+
+#### Public etcd discovery service
+
+If no exiting cluster is available, use the public discovery service hosted at `discovery.etcd.io`. To create a private discovery URL using the "new" endpoint, use the command:
+
+```
+$ curl https://discovery.etcd.io/new?size=3
+https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+```
+
+This will create the cluster with an initial size of 3 members. If no size is specified, a default of 3 is used.
+
+```
+ETCD_DISCOVERY=https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+```
+
+```
+--discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+```
+
+**Each member must have a different name flag specified or else discovery will fail due to duplicated names. `Hostname` or `machine-id` can be a good choice. **
+
+Now we start etcd with those relevant flags for each member:
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \
+ --listen-peer-urls http://10.0.1.10:2380 \
+ --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.10:2379 \
+ --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+```
+```
+$ etcd --name infra1 --initial-advertise-peer-urls http://10.0.1.11:2380 \
+ --listen-peer-urls http://10.0.1.11:2380 \
+ --listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.11:2379 \
+ --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+```
+```
+$ etcd --name infra2 --initial-advertise-peer-urls http://10.0.1.12:2380 \
+ --listen-peer-urls http://10.0.1.12:2380 \
+ --listen-client-urls http://10.0.1.12:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.12:2379 \
+ --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+```
+
+This will cause each member to register itself with the discovery service and begin the cluster once all members have been registered.
+
+Use the environment variable `ETCD_DISCOVERY_PROXY` to cause etcd to use an HTTP proxy to connect to the discovery service.
+
+#### Error and warning cases
+
+##### Discovery server errors
+
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \
+ --listen-peer-urls http://10.0.1.10:2380 \
+ --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.10:2379 \
+ --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+etcd: error: the cluster doesn?t have a size configuration value in https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de/_config
+exit 1
+```
+
+##### Warnings
+
+This is a harmless warning indicating the discovery URL will be ignored on this machine.
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \
+ --listen-peer-urls http://10.0.1.10:2380 \
+ --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.10:2379 \
+ --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+etcdserver: discovery token ignored since a cluster has already been initialized. Valid log found at /var/lib/etcd
+```
+
+### DNS discovery
+
+DNS [SRV records][rfc-srv] can be used as a discovery mechanism.
+The `-discovery-srv` flag can be used to set the DNS domain name where the discovery SRV records can be found.
+The following DNS SRV records are looked up in the listed order:
+
+* _etcd-server-ssl._tcp.example.com
+* _etcd-server._tcp.example.com
+
+If `_etcd-server-ssl._tcp.example.com` is found then etcd will attempt the bootstrapping process over TLS.
+
+To help clients discover the etcd cluster, the following DNS SRV records are looked up in the listed order:
+
+* _etcd-client._tcp.example.com
+* _etcd-client-ssl._tcp.example.com
+
+If `_etcd-client-ssl._tcp.example.com` is found, clients will attempt to communicate with the etcd cluster over SSL/TLS.
+
+If etcd is using TLS without a custom certificate authority, the discovery domain (e.g., example.com) must match the SRV record domain (e.g., infra1.example.com). This is to mitigate attacks that forge SRV records to point to a different domain; the domain would have a valid certificate under PKI but be controlled by an unknown third party.
+
+#### Create DNS SRV records
+
+```
+$ dig +noall +answer SRV _etcd-server._tcp.example.com
+_etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra0.example.com.
+_etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra1.example.com.
+_etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra2.example.com.
+```
+
+```
+$ dig +noall +answer SRV _etcd-client._tcp.example.com
+_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra0.example.com.
+_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra1.example.com.
+_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra2.example.com.
+```
+
+```
+$ dig +noall +answer infra0.example.com infra1.example.com infra2.example.com
+infra0.example.com. 300 IN A 10.0.1.10
+infra1.example.com. 300 IN A 10.0.1.11
+infra2.example.com. 300 IN A 10.0.1.12
+```
+
+#### Bootstrap the etcd cluster using DNS
+
+etcd cluster members can listen on domain names or IP address, the bootstrap process will resolve DNS A records.
+
+The resolved address in `--initial-advertise-peer-urls` *must match* one of the resolved addresses in the SRV targets. The etcd member reads the resolved address to find out if it belongs to the cluster defined in the SRV records.
+
+```
+$ etcd --name infra0 \
+--discovery-srv example.com \
+--initial-advertise-peer-urls http://infra0.example.com:2380 \
+--initial-cluster-token etcd-cluster-1 \
+--initial-cluster-state new \
+--advertise-client-urls http://infra0.example.com:2379 \
+--listen-client-urls http://infra0.example.com:2379 \
+--listen-peer-urls http://infra0.example.com:2380
+```
+
+```
+$ etcd --name infra1 \
+--discovery-srv example.com \
+--initial-advertise-peer-urls http://infra1.example.com:2380 \
+--initial-cluster-token etcd-cluster-1 \
+--initial-cluster-state new \
+--advertise-client-urls http://infra1.example.com:2379 \
+--listen-client-urls http://infra1.example.com:2379 \
+--listen-peer-urls http://infra1.example.com:2380
+```
+
+```
+$ etcd --name infra2 \
+--discovery-srv example.com \
+--initial-advertise-peer-urls http://infra2.example.com:2380 \
+--initial-cluster-token etcd-cluster-1 \
+--initial-cluster-state new \
+--advertise-client-urls http://infra2.example.com:2379 \
+--listen-client-urls http://infra2.example.com:2379 \
+--listen-peer-urls http://infra2.example.com:2380
+```
+
+The cluster can also bootstrap using IP addresses instead of domain names:
+
+```
+$ etcd --name infra0 \
+--discovery-srv example.com \
+--initial-advertise-peer-urls http://10.0.1.10:2380 \
+--initial-cluster-token etcd-cluster-1 \
+--initial-cluster-state new \
+--advertise-client-urls http://10.0.1.10:2379 \
+--listen-client-urls http://10.0.1.10:2379 \
+--listen-peer-urls http://10.0.1.10:2380
+```
+
+```
+$ etcd --name infra1 \
+--discovery-srv example.com \
+--initial-advertise-peer-urls http://10.0.1.11:2380 \
+--initial-cluster-token etcd-cluster-1 \
+--initial-cluster-state new \
+--advertise-client-urls http://10.0.1.11:2379 \
+--listen-client-urls http://10.0.1.11:2379 \
+--listen-peer-urls http://10.0.1.11:2380
+```
+
+```
+$ etcd --name infra2 \
+--discovery-srv example.com \
+--initial-advertise-peer-urls http://10.0.1.12:2380 \
+--initial-cluster-token etcd-cluster-1 \
+--initial-cluster-state new \
+--advertise-client-urls http://10.0.1.12:2379 \
+--listen-client-urls http://10.0.1.12:2379 \
+--listen-peer-urls http://10.0.1.12:2380
+```
+
+### Gateway
+
+etcd gateway is a simple TCP proxy that forwards network data to the etcd cluster. Please read [gateway guide][gateway] for more information.
+
+### Proxy
+
+When the `--proxy` flag is set, etcd runs in [proxy mode][proxy]. This proxy mode only supports the etcd v2 API; there are no plans to support the v3 API. Instead, for v3 API support, there will be a new proxy with enhanced features following the etcd 3.0 release.
+
+To setup an etcd cluster with proxies of v2 API, please read the the [clustering doc in etcd 2.3 release][clustering_etcd2].
+
+[conf-adv-client]: configuration.md#--advertise-client-urls
+[conf-listen-client]: configuration.md#--listen-client-urls
+[discovery-proto]: ../dev-internal/discovery_protocol.md
+[rfc-srv]: http://www.ietf.org/rfc/rfc2052.txt
+[runtime-conf]: runtime-configuration.md
+[runtime-reconf-design]: runtime-reconf-design.md
+[proxy]: https://github.com/coreos/etcd/blob/release-2.3/Documentation/proxy.md
+[clustering_etcd2]: https://github.com/coreos/etcd/blob/release-2.3/Documentation/clustering.md
+[security-guide]: security.md
+[tls-setup]: ../../hack/tls-setup
+[gateway]: gateway.md
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/configuration.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/configuration.md
new file mode 100644
index 00000000..8dadd317
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/configuration.md
@@ -0,0 +1,313 @@
+# Configuration flags
+
+etcd is configurable through command-line flags and environment variables. Options set on the command line take precedence over those from the environment.
+
+The format of environment variable for flag `--my-flag` is `ETCD_MY_FLAG`. It applies to all flags.
+
+The [official etcd ports][iana-ports] are 2379 for client requests and 2380 for peer communication. The etcd ports can be set to accept TLS traffic, non-TLS traffic, or both TLS and non-TLS traffic.
+
+To start etcd automatically using custom settings at startup in Linux, using a [systemd][systemd-intro] unit is highly recommended.
+
+## Member flags
+
+### --name
++ Human-readable name for this member.
++ default: "default"
++ env variable: ETCD_NAME
++ This value is referenced as this node's own entries listed in the `--initial-cluster` flag (e.g., `default=http://localhost:2380`). This needs to match the key used in the flag if using [static bootstrapping][build-cluster]. When using discovery, each member must have a unique name. `Hostname` or `machine-id` can be a good choice.
+
+### --data-dir
++ Path to the data directory.
++ default: "${name}.etcd"
++ env variable: ETCD_DATA_DIR
+
+### --wal-dir
++ Path to the dedicated wal directory. If this flag is set, etcd will write the WAL files to the walDir rather than the dataDir. This allows a dedicated disk to be used, and helps avoid io competition between logging and other IO operations.
++ default: ""
++ env variable: ETCD_WAL_DIR
+
+### --snapshot-count
++ Number of committed transactions to trigger a snapshot to disk.
++ default: "100000"
++ env variable: ETCD_SNAPSHOT_COUNT
+
+### --heartbeat-interval
++ Time (in milliseconds) of a heartbeat interval.
++ default: "100"
++ env variable: ETCD_HEARTBEAT_INTERVAL
+
+### --election-timeout
++ Time (in milliseconds) for an election to timeout. See [Documentation/tuning.md][tuning] for details.
++ default: "1000"
++ env variable: ETCD_ELECTION_TIMEOUT
+
+### --listen-peer-urls
++ List of URLs to listen on for peer traffic. This flag tells the etcd to accept incoming requests from its peers on the specified scheme://IP:port combinations. Scheme can be either http or https.If 0.0.0.0 is specified as the IP, etcd listens to the given port on all interfaces. If an IP address is given as well as a port, etcd will listen on the given port and interface. Multiple URLs may be used to specify a number of addresses and ports to listen on. The etcd will respond to requests from any of the listed addresses and ports.
++ default: "http://localhost:2380"
++ env variable: ETCD_LISTEN_PEER_URLS
++ example: "http://10.0.0.1:2380"
++ invalid example: "http://example.com:2380" (domain name is invalid for binding)
+
+### --listen-client-urls
++ List of URLs to listen on for client traffic. This flag tells the etcd to accept incoming requests from the clients on the specified scheme://IP:port combinations. Scheme can be either http or https. If 0.0.0.0 is specified as the IP, etcd listens to the given port on all interfaces. If an IP address is given as well as a port, etcd will listen on the given port and interface. Multiple URLs may be used to specify a number of addresses and ports to listen on. The etcd will respond to requests from any of the listed addresses and ports.
++ default: "http://localhost:2379"
++ env variable: ETCD_LISTEN_CLIENT_URLS
++ example: "http://10.0.0.1:2379"
++ invalid example: "http://example.com:2379" (domain name is invalid for binding)
+
+### --max-snapshots
++ Maximum number of snapshot files to retain (0 is unlimited)
++ default: 5
++ env variable: ETCD_MAX_SNAPSHOTS
++ The default for users on Windows is unlimited, and manual purging down to 5 (or some preference for safety) is recommended.
+
+### --max-wals
++ Maximum number of wal files to retain (0 is unlimited)
++ default: 5
++ env variable: ETCD_MAX_WALS
++ The default for users on Windows is unlimited, and manual purging down to 5 (or some preference for safety) is recommended.
+
+### --cors
++ Comma-separated white list of origins for CORS (cross-origin resource sharing).
++ default: none
++ env variable: ETCD_CORS
+
+## Clustering flags
+
+`--initial` prefix flags are used in bootstrapping ([static bootstrap][build-cluster], [discovery-service bootstrap][discovery] or [runtime reconfiguration][reconfig]) a new member, and ignored when restarting an existing member.
+
+`--discovery` prefix flags need to be set when using [discovery service][discovery].
+
+### --initial-advertise-peer-urls
+
++ List of this member's peer URLs to advertise to the rest of the cluster. These addresses are used for communicating etcd data around the cluster. At least one must be routable to all cluster members. These URLs can contain domain names.
++ default: "http://localhost:2380"
++ env variable: ETCD_INITIAL_ADVERTISE_PEER_URLS
++ example: "http://example.com:2380, http://10.0.0.1:2380"
+
+### --initial-cluster
++ Initial cluster configuration for bootstrapping.
++ default: "default=http://localhost:2380"
++ env variable: ETCD_INITIAL_CLUSTER
++ The key is the value of the `--name` flag for each node provided. The default uses `default` for the key because this is the default for the `--name` flag.
+
+### --initial-cluster-state
++ Initial cluster state ("new" or "existing"). Set to `new` for all members present during initial static or DNS bootstrapping. If this option is set to `existing`, etcd will attempt to join the existing cluster. If the wrong value is set, etcd will attempt to start but fail safely.
++ default: "new"
++ env variable: ETCD_INITIAL_CLUSTER_STATE
+
+[static bootstrap]: clustering.md#static
+
+### --initial-cluster-token
++ Initial cluster token for the etcd cluster during bootstrap.
++ default: "etcd-cluster"
++ env variable: ETCD_INITIAL_CLUSTER_TOKEN
+
+### --advertise-client-urls
++ List of this member's client URLs to advertise to the rest of the cluster. These URLs can contain domain names.
++ default: "http://localhost:2379"
++ env variable: ETCD_ADVERTISE_CLIENT_URLS
++ example: "http://example.com:2379, http://10.0.0.1:2379"
++ Be careful if advertising URLs such as http://localhost:2379 from a cluster member and are using the proxy feature of etcd. This will cause loops, because the proxy will be forwarding requests to itself until its resources (memory, file descriptors) are eventually depleted.
+
+### --discovery
++ Discovery URL used to bootstrap the cluster.
++ default: none
++ env variable: ETCD_DISCOVERY
+
+### --discovery-srv
++ DNS srv domain used to bootstrap the cluster.
++ default: none
++ env variable: ETCD_DISCOVERY_SRV
+
+### --discovery-fallback
++ Expected behavior ("exit" or "proxy") when discovery services fails. "proxy" supports v2 API only.
++ default: "proxy"
++ env variable: ETCD_DISCOVERY_FALLBACK
+
+### --discovery-proxy
++ HTTP proxy to use for traffic to discovery service.
++ default: none
++ env variable: ETCD_DISCOVERY_PROXY
+
+### --strict-reconfig-check
++ Reject reconfiguration requests that would cause quorum loss.
++ default: false
++ env variable: ETCD_STRICT_RECONFIG_CHECK
+
+### --auto-compaction-retention
++ Auto compaction retention for mvcc key value store in hour. 0 means disable auto compaction.
++ default: 0
++ env variable: ETCD_AUTO_COMPACTION_RETENTION
+
+
+### --enable-v2
++ Accept etcd V2 client requests
++ default: true
++ env variable: ETCD_ENABLE_V2
+
+## Proxy flags
+
+`--proxy` prefix flags configures etcd to run in [proxy mode][proxy]. "proxy" supports v2 API only.
+
+### --proxy
++ Proxy mode setting ("off", "readonly" or "on").
++ default: "off"
++ env variable: ETCD_PROXY
+
+### --proxy-failure-wait
++ Time (in milliseconds) an endpoint will be held in a failed state before being reconsidered for proxied requests.
++ default: 5000
++ env variable: ETCD_PROXY_FAILURE_WAIT
+
+### --proxy-refresh-interval
++ Time (in milliseconds) of the endpoints refresh interval.
++ default: 30000
++ env variable: ETCD_PROXY_REFRESH_INTERVAL
+
+### --proxy-dial-timeout
++ Time (in milliseconds) for a dial to timeout or 0 to disable the timeout
++ default: 1000
++ env variable: ETCD_PROXY_DIAL_TIMEOUT
+
+### --proxy-write-timeout
++ Time (in milliseconds) for a write to timeout or 0 to disable the timeout.
++ default: 5000
++ env variable: ETCD_PROXY_WRITE_TIMEOUT
+
+### --proxy-read-timeout
++ Time (in milliseconds) for a read to timeout or 0 to disable the timeout.
++ Don't change this value if using watches because use long polling requests.
++ default: 0
++ env variable: ETCD_PROXY_READ_TIMEOUT
+
+## Security flags
+
+The security flags help to [build a secure etcd cluster][security].
+
+### --ca-file
+
+**DEPRECATED**
+
++ Path to the client server TLS CA file. `--ca-file ca.crt` could be replaced by `--trusted-ca-file ca.crt --client-cert-auth` and etcd will perform the same.
++ default: none
++ env variable: ETCD_CA_FILE
+
+### --cert-file
++ Path to the client server TLS cert file.
++ default: none
++ env variable: ETCD_CERT_FILE
+
+### --key-file
++ Path to the client server TLS key file.
++ default: none
++ env variable: ETCD_KEY_FILE
+
+### --client-cert-auth
++ Enable client cert authentication.
++ default: false
++ env variable: ETCD_CLIENT_CERT_AUTH
+
+### --trusted-ca-file
++ Path to the client server TLS trusted CA key file.
++ default: none
++ env variable: ETCD_TRUSTED_CA_FILE
+
+### --auto-tls
++ Client TLS using generated certificates
++ default: false
++ env variable: ETCD_AUTO_TLS
+
+### --peer-ca-file
+
+**DEPRECATED**
+
++ Path to the peer server TLS CA file. `--peer-ca-file ca.crt` could be replaced by `--peer-trusted-ca-file ca.crt --peer-client-cert-auth` and etcd will perform the same.
++ default: none
++ env variable: ETCD_PEER_CA_FILE
+
+### --peer-cert-file
++ Path to the peer server TLS cert file.
++ default: none
++ env variable: ETCD_PEER_CERT_FILE
+
+### --peer-key-file
++ Path to the peer server TLS key file.
++ default: none
++ env variable: ETCD_PEER_KEY_FILE
+
+### --peer-client-cert-auth
++ Enable peer client cert authentication.
++ default: false
++ env variable: ETCD_PEER_CLIENT_CERT_AUTH
+
+### --peer-trusted-ca-file
++ Path to the peer server TLS trusted CA file.
++ default: none
++ env variable: ETCD_PEER_TRUSTED_CA_FILE
+
+### --peer-auto-tls
++ Peer TLS using generated certificates
++ default: false
++ env variable: ETCD_PEER_AUTO_TLS
+
+## Logging flags
+
+### --debug
++ Drop the default log level to DEBUG for all subpackages.
++ default: false (INFO for all packages)
++ env variable: ETCD_DEBUG
+
+### --log-package-levels
++ Set individual etcd subpackages to specific log levels. An example being `etcdserver=WARNING,security=DEBUG`
++ default: none (INFO for all packages)
++ env variable: ETCD_LOG_PACKAGE_LEVELS
+
+
+## Unsafe flags
+
+Please be CAUTIOUS when using unsafe flags because it will break the guarantees given by the consensus protocol.
+For example, it may panic if other members in the cluster are still alive.
+Follow the instructions when using these flags.
+
+### --force-new-cluster
++ Force to create a new one-member cluster. It commits configuration changes forcing to remove all existing members in the cluster and add itself. It needs to be set to [restore a backup][restore].
++ default: false
++ env variable: ETCD_FORCE_NEW_CLUSTER
+
+## Miscellaneous flags
+
+### --version
++ Print the version and exit.
++ default: false
+
+### --config-file
++ Load server configuration from a file.
++ default: none
+
+## Profiling flags
+
+### --enable-pprof
++ Enable runtime profiling data via HTTP server. Address is at client URL + "/debug/pprof/"
++ default: false
+
+### --metrics
++ Set level of detail for exported metrics, specify 'extensive' to include histogram metrics.
++ default: basic
+
+## Auth flags
+
+### --auth-token
++ Specify a token type and token specific options, especially for JWT. Its format is "type,var1=val1,var2=val2,...". Possible type is 'simple' or 'jwt'. Possible variables are 'sign-method' for specifying a sign method of jwt (its possible values are 'ES256', 'ES384', 'ES512', 'HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512', 'PS256', 'PS384', or 'PS512'), 'pub-key' for specifying a path to a public key for verifying jwt, and 'priv-key' for specifying a path to a private key for signing jwt.
++ Example option of JWT: '--auth-token jwt,pub-key=app.rsa.pub,priv-key=app.rsa,sign-method=RS512'
++ default: "simple"
+
+[build-cluster]: clustering.md#static
+[reconfig]: runtime-configuration.md
+[discovery]: clustering.md#discovery
+[iana-ports]: http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt
+[proxy]: ../v2/proxy.md
+[restore]: ../v2/admin_guide.md#restoring-a-backup
+[security]: security.md
+[systemd-intro]: http://freedesktop.org/wiki/Software/systemd/
+[tuning]: ../tuning.md#time-parameters
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/container.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/container.md
new file mode 100644
index 00000000..bed9c08f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/container.md
@@ -0,0 +1,196 @@
+# Run etcd clusters inside containers
+
+The following guide shows how to run etcd with rkt and Docker using the [static bootstrap process](clustering.md#static).
+
+## rkt
+
+### Running a single node etcd
+
+The following rkt run command will expose the etcd client API on port 2379 and expose the peer API on port 2380.
+
+Use the host IP address when configuring etcd.
+
+```
+export NODE1=192.168.1.21
+```
+
+Trust the CoreOS [App Signing Key](https://coreos.com/security/app-signing-key/).
+
+```
+sudo rkt trust --prefix coreos.com/etcd
+# gpg key fingerprint is: 18AD 5014 C99E F7E3 BA5F 6CE9 50BD D3E0 FC8A 365E
+```
+
+Run the `v3.1.2` version of etcd or specify another release version.
+
+```
+sudo rkt run --net=default:IP=${NODE1} coreos.com/etcd:v3.1.2 -- -name=node1 -advertise-client-urls=http://${NODE1}:2379 -initial-advertise-peer-urls=http://${NODE1}:2380 -listen-client-urls=http://0.0.0.0:2379 -listen-peer-urls=http://${NODE1}:2380 -initial-cluster=node1=http://${NODE1}:2380
+```
+
+List the cluster member.
+
+```
+etcdctl --endpoints=http://192.168.1.21:2379 member list
+```
+
+### Running a 3 node etcd cluster
+
+Setup a 3 node cluster with rkt locally, using the `-initial-cluster` flag.
+
+```sh
+export NODE1=172.16.28.21
+export NODE2=172.16.28.22
+export NODE3=172.16.28.23
+```
+
+```
+# node 1
+sudo rkt run --net=default:IP=${NODE1} coreos.com/etcd:v3.1.2 -- -name=node1 -advertise-client-urls=http://${NODE1}:2379 -initial-advertise-peer-urls=http://${NODE1}:2380 -listen-client-urls=http://0.0.0.0:2379 -listen-peer-urls=http://${NODE1}:2380 -initial-cluster=node1=http://${NODE1}:2380,node2=http://${NODE2}:2380,node3=http://${NODE3}:2380
+
+# node 2
+sudo rkt run --net=default:IP=${NODE2} coreos.com/etcd:v3.1.2 -- -name=node2 -advertise-client-urls=http://${NODE2}:2379 -initial-advertise-peer-urls=http://${NODE2}:2380 -listen-client-urls=http://0.0.0.0:2379 -listen-peer-urls=http://${NODE2}:2380 -initial-cluster=node1=http://${NODE1}:2380,node2=http://${NODE2}:2380,node3=http://${NODE3}:2380
+
+# node 3
+sudo rkt run --net=default:IP=${NODE3} coreos.com/etcd:v3.1.2 -- -name=node3 -advertise-client-urls=http://${NODE3}:2379 -initial-advertise-peer-urls=http://${NODE3}:2380 -listen-client-urls=http://0.0.0.0:2379 -listen-peer-urls=http://${NODE3}:2380 -initial-cluster=node1=http://${NODE1}:2380,node2=http://${NODE2}:2380,node3=http://${NODE3}:2380
+```
+
+Verify the cluster is healthy and can be reached.
+
+```
+ETCDCTL_API=3 etcdctl --endpoints=http://172.16.28.21:2379,http://172.16.28.22:2379,http://172.16.28.23:2379 endpoint health
+```
+
+### DNS
+
+Production clusters which refer to peers by DNS name known to the local resolver must mount the [host's DNS configuration](https://coreos.com/kubernetes/docs/latest/kubelet-wrapper.html#customizing-rkt-options).
+
+## Docker
+
+In order to expose the etcd API to clients outside of Docker host, use the host IP address of the container. Please see [`docker inspect`](https://docs.docker.com/engine/reference/commandline/inspect) for more detail on how to get the IP address. Alternatively, specify `--net=host` flag to `docker run` command to skip placing the container inside of a separate network stack.
+
+### Running a single node etcd
+
+Use the host IP address when configuring etcd:
+
+```
+export NODE1=192.168.1.21
+```
+
+Run the latest version of etcd:
+
+```
+docker run \
+ -p 2379:2379 \
+ -p 2380:2380 \
+ --volume=${DATA_DIR}:/etcd-data \
+ --name etcd quay.io/coreos/etcd:latest \
+ /usr/local/bin/etcd \
+ --data-dir=/etcd-data --name node1 \
+ --initial-advertise-peer-urls http://${NODE1}:2380 --listen-peer-urls http://${NODE1}:2380 \
+ --advertise-client-urls http://${NODE1}:2379 --listen-client-urls http://${NODE1}:2379 \
+ --initial-cluster node1=http://${NODE1}:2380
+```
+
+List the cluster member:
+
+```
+etcdctl --endpoints=http://${NODE1}:2379 member list
+```
+
+### Running a 3 node etcd cluster
+
+```
+# For each machine
+ETCD_VERSION=latest
+TOKEN=my-etcd-token
+CLUSTER_STATE=new
+NAME_1=etcd-node-0
+NAME_2=etcd-node-1
+NAME_3=etcd-node-2
+HOST_1=10.20.30.1
+HOST_2=10.20.30.2
+HOST_3=10.20.30.3
+CLUSTER=${NAME_1}=http://${HOST_1}:2380,${NAME_2}=http://${HOST_2}:2380,${NAME_3}=http://${HOST_3}:2380
+DATA_DIR=/var/lib/etcd
+
+# For node 1
+THIS_NAME=${NAME_1}
+THIS_IP=${HOST_1}
+docker run \
+ -p 2379:2379 \
+ -p 2380:2380 \
+ --volume=${DATA_DIR}:/etcd-data \
+ --name etcd quay.io/coreos/etcd:${ETCD_VERSION} \
+ /usr/local/bin/etcd \
+ --data-dir=/etcd-data --name ${THIS_NAME} \
+ --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
+ --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
+ --initial-cluster ${CLUSTER} \
+ --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
+
+# For node 2
+THIS_NAME=${NAME_2}
+THIS_IP=${HOST_2}
+docker run \
+ -p 2379:2379 \
+ -p 2380:2380 \
+ --volume=${DATA_DIR}:/etcd-data \
+ --name etcd quay.io/coreos/etcd:${ETCD_VERSION} \
+ /usr/local/bin/etcd \
+ --data-dir=/etcd-data --name ${THIS_NAME} \
+ --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
+ --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
+ --initial-cluster ${CLUSTER} \
+ --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
+
+# For node 3
+THIS_NAME=${NAME_3}
+THIS_IP=${HOST_3}
+docker run \
+ -p 2379:2379 \
+ -p 2380:2380 \
+ --volume=${DATA_DIR}:/etcd-data \
+ --name etcd quay.io/coreos/etcd:${ETCD_VERSION} \
+ /usr/local/bin/etcd \
+ --data-dir=/etcd-data --name ${THIS_NAME} \
+ --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
+ --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
+ --initial-cluster ${CLUSTER} \
+ --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
+```
+
+To run `etcdctl` using API version 3:
+
+```
+docker exec etcd /bin/sh -c "export ETCDCTL_API=3 && /usr/local/bin/etcdctl put foo bar"
+```
+
+## Bare Metal
+
+To provision a 3 node etcd cluster on bare-metal, the examples in the [baremetal repo](https://github.com/coreos/coreos-baremetal/tree/master/examples) may be useful.
+
+## Mounting a certificate volume
+
+The etcd release container does not include default root certificates. To use HTTPS with certificates trusted by a root authority (e.g., for discovery), mount a certificate directory into the etcd container:
+
+```
+rkt run \
+ --volume etcd-ssl-certs-bundle,kind=host,source=/etc/ssl/certs/ca-certificates.crt \
+ --mount volume=etcd-ssl-certs-bundle,target=/etc/ssl/certs/ca-certificates.crt \
+ quay.io/coreos/etcd:latest -- --name my-name \
+ --initial-advertise-peer-urls http://localhost:2380 --listen-peer-urls http://localhost:2380 \
+ --advertise-client-urls http://localhost:2379 --listen-client-urls http://localhost:2379 \
+ --discovery https://discovery.etcd.io/c11fbcdc16972e45253491a24fcf45e1
+```
+
+```
+docker run \
+ -p 2379:2379 \
+ -p 2380:2380 \
+ --volume=/etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt \
+ quay.io/coreos/etcd:latest \
+ /usr/local/bin/etcd --name my-name \
+ --initial-advertise-peer-urls http://localhost:2380 --listen-peer-urls http://localhost:2380 \
+ --advertise-client-urls http://localhost:2379 --listen-client-urls http://localhost:2379 \
+ --discovery https://discovery.etcd.io/86a9ff6c8cb8b4c4544c1a2f88f8b801
+```
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/etcd-sample-grafana.png b/vendor/github.com/coreos/etcd/Documentation/op-guide/etcd-sample-grafana.png
new file mode 100644
index 00000000..47896030
Binary files /dev/null and b/vendor/github.com/coreos/etcd/Documentation/op-guide/etcd-sample-grafana.png differ
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/etcd3_alert.rules b/vendor/github.com/coreos/etcd/Documentation/op-guide/etcd3_alert.rules
new file mode 100644
index 00000000..90c3770e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/etcd3_alert.rules
@@ -0,0 +1,206 @@
+# general cluster availability
+
+# alert if another failed member will result in an unavailable cluster
+ALERT InsufficientMembers
+IF count(up{job="etcd"} == 0) > (count(up{job="etcd"}) / 2 - 1)
+FOR 3m
+LABELS {
+ severity = "critical"
+}
+ANNOTATIONS {
+ summary = "etcd cluster insufficient members",
+ description = "If one more etcd member goes down the cluster will be unavailable",
+}
+
+# etcd leader alerts
+# ==================
+
+# alert if any etcd instance has no leader
+ALERT NoLeader
+IF etcd_server_has_leader{job="etcd"} == 0
+FOR 1m
+LABELS {
+ severity = "critical"
+}
+ANNOTATIONS {
+ summary = "etcd member has no leader",
+ description = "etcd member {{ $labels.instance }} has no leader",
+}
+
+# alert if there are lots of leader changes
+ALERT HighNumberOfLeaderChanges
+IF increase(etcd_server_leader_changes_seen_total{job="etcd"}[1h]) > 3
+LABELS {
+ severity = "warning"
+}
+ANNOTATIONS {
+ summary = "a high number of leader changes within the etcd cluster are happening",
+ description = "etcd instance {{ $labels.instance }} has seen {{ $value }} leader changes within the last hour",
+}
+
+# gRPC request alerts
+# ===================
+
+# alert if more than 1% of gRPC method calls have failed within the last 5 minutes
+ALERT HighNumberOfFailedGRPCRequests
+IF sum by(grpc_method) (rate(etcd_grpc_requests_failed_total{job="etcd"}[5m]))
+ / sum by(grpc_method) (rate(etcd_grpc_total{job="etcd"}[5m])) > 0.01
+FOR 10m
+LABELS {
+ severity = "warning"
+}
+ANNOTATIONS {
+ summary = "a high number of gRPC requests are failing",
+ description = "{{ $value }}% of requests for {{ $labels.grpc_method }} failed on etcd instance {{ $labels.instance }}",
+}
+
+# alert if more than 5% of gRPC method calls have failed within the last 5 minutes
+ALERT HighNumberOfFailedGRPCRequests
+IF sum by(grpc_method) (rate(etcd_grpc_requests_failed_total{job="etcd"}[5m]))
+ / sum by(grpc_method) (rate(etcd_grpc_total{job="etcd"}[5m])) > 0.05
+FOR 5m
+LABELS {
+ severity = "critical"
+}
+ANNOTATIONS {
+ summary = "a high number of gRPC requests are failing",
+ description = "{{ $value }}% of requests for {{ $labels.grpc_method }} failed on etcd instance {{ $labels.instance }}",
+}
+
+# alert if the 99th percentile of gRPC method calls take more than 150ms
+ALERT GRPCRequestsSlow
+IF histogram_quantile(0.99, rate(etcd_grpc_unary_requests_duration_seconds_bucket[5m])) > 0.15
+FOR 10m
+LABELS {
+ severity = "critical"
+}
+ANNOTATIONS {
+ summary = "slow gRPC requests",
+ description = "on etcd instance {{ $labels.instance }} gRPC requests to {{ $label.grpc_method }} are slow",
+}
+
+# HTTP requests alerts
+# ====================
+
+# alert if more than 1% of requests to an HTTP endpoint have failed within the last 5 minutes
+ALERT HighNumberOfFailedHTTPRequests
+IF sum by(method) (rate(etcd_http_failed_total{job="etcd"}[5m]))
+ / sum by(method) (rate(etcd_http_received_total{job="etcd"}[5m])) > 0.01
+FOR 10m
+LABELS {
+ severity = "warning"
+}
+ANNOTATIONS {
+ summary = "a high number of HTTP requests are failing",
+ description = "{{ $value }}% of requests for {{ $labels.method }} failed on etcd instance {{ $labels.instance }}",
+}
+
+# alert if more than 5% of requests to an HTTP endpoint have failed within the last 5 minutes
+ALERT HighNumberOfFailedHTTPRequests
+IF sum by(method) (rate(etcd_http_failed_total{job="etcd"}[5m]))
+ / sum by(method) (rate(etcd_http_received_total{job="etcd"}[5m])) > 0.05
+FOR 5m
+LABELS {
+ severity = "critical"
+}
+ANNOTATIONS {
+ summary = "a high number of HTTP requests are failing",
+ description = "{{ $value }}% of requests for {{ $labels.method }} failed on etcd instance {{ $labels.instance }}",
+}
+
+# alert if the 99th percentile of HTTP requests take more than 150ms
+ALERT HTTPRequestsSlow
+IF histogram_quantile(0.99, rate(etcd_http_successful_duration_seconds_bucket[5m])) > 0.15
+FOR 10m
+LABELS {
+ severity = "warning"
+}
+ANNOTATIONS {
+ summary = "slow HTTP requests",
+ description = "on etcd instance {{ $labels.instance }} HTTP requests to {{ $label.method }} are slow",
+}
+
+# file descriptor alerts
+# ======================
+
+instance:fd_utilization = process_open_fds / process_max_fds
+
+# alert if file descriptors are likely to exhaust within the next 4 hours
+ALERT FdExhaustionClose
+IF predict_linear(instance:fd_utilization[1h], 3600 * 4) > 1
+FOR 10m
+LABELS {
+ severity = "warning"
+}
+ANNOTATIONS {
+ summary = "file descriptors soon exhausted",
+ description = "{{ $labels.job }} instance {{ $labels.instance }} will exhaust its file descriptors soon",
+}
+
+# alert if file descriptors are likely to exhaust within the next hour
+ALERT FdExhaustionClose
+IF predict_linear(instance:fd_utilization[10m], 3600) > 1
+FOR 10m
+LABELS {
+ severity = "critical"
+}
+ANNOTATIONS {
+ summary = "file descriptors soon exhausted",
+ description = "{{ $labels.job }} instance {{ $labels.instance }} will exhaust its file descriptors soon",
+}
+
+# etcd member communication alerts
+# ================================
+
+# alert if 99th percentile of round trips take 150ms
+ALERT EtcdMemberCommunicationSlow
+IF histogram_quantile(0.99, rate(etcd_network_member_round_trip_time_seconds_bucket[5m])) > 0.15
+FOR 10m
+LABELS {
+ severity = "warning"
+}
+ANNOTATIONS {
+ summary = "etcd member communication is slow",
+ description = "etcd instance {{ $labels.instance }} member communication with {{ $label.To }} is slow",
+}
+
+# etcd proposal alerts
+# ====================
+
+# alert if there are several failed proposals within an hour
+ALERT HighNumberOfFailedProposals
+IF increase(etcd_server_proposals_failed_total{job="etcd"}[1h]) > 5
+LABELS {
+ severity = "warning"
+}
+ANNOTATIONS {
+ summary = "a high number of proposals within the etcd cluster are failing",
+ description = "etcd instance {{ $labels.instance }} has seen {{ $value }} proposal failures within the last hour",
+}
+
+# etcd disk io latency alerts
+# ===========================
+
+# alert if 99th percentile of fsync durations is higher than 500ms
+ALERT HighFsyncDurations
+IF histogram_quantile(0.99, rate(etcd_disk_wal_fsync_duration_seconds_bucket[5m])) > 0.5
+FOR 10m
+LABELS {
+ severity = "warning"
+}
+ANNOTATIONS {
+ summary = "high fsync durations",
+ description = "etcd instance {{ $labels.instance }} fync durations are high",
+}
+
+# alert if 99th percentile of commit durations is higher than 250ms
+ALERT HighCommitDurations
+IF histogram_quantile(0.99, rate(etcd_disk_backend_commit_duration_seconds_bucket[5m])) > 0.25
+FOR 10m
+LABELS {
+ severity = "warning"
+}
+ANNOTATIONS {
+ summary = "high commit durations",
+ description = "etcd instance {{ $labels.instance }} commit durations are high",
+}
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/failures.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/failures.md
new file mode 100644
index 00000000..ce2bd6ca
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/failures.md
@@ -0,0 +1,44 @@
+# Understand failures
+
+Failures are common in a large deployment of machines. A machine fails when its hardware or software malfunctions. Multiple machines fail together when there are power failures or network issues. Multiple kinds of failures can also happen at once; it is almost impossible to enumerate all possible failure cases.
+
+In this section, we catalog kinds of failures and discuss how etcd is designed to tolerate these failures. Most users, if not all, can map a particular failure into one kind of failure. To prepare for rare or [unrecoverable failures][unrecoverable], always [back up][backup] the etcd cluster.
+
+## Minor followers failure
+
+When fewer than half of the followers fail, the etcd cluster can still accept requests and make progress without any major disruption. For example, two follower failures will not affect a five member etcd cluster?s operation. However, clients will lose connectivity to the failed members. Client libraries should hide these interruptions from users for read requests by automatically reconnecting to other members. Operators should expect the system load on the other members to increase due to the reconnections.
+
+## Leader failure
+
+When a leader fails, the etcd cluster automatically elects a new leader. The election does not happen instantly once the leader fails. It takes about an election timeout to elect a new leader since the failure detection model is timeout based.
+
+During the leader election the cluster cannot process any writes. Write requests sent during the election are queued for processing until a new leader is elected.
+
+Writes already sent to the old leader but not yet committed may be lost. The new leader has the power to rewrite any uncommitted entries from the previous leader. From the user perspective, some write requests might time out after a new leader election. However, no committed writes are ever lost.
+
+The new leader extends timeouts automatically for all leases. This mechanism ensures a lease will not expire before the granted TTL even if it was granted by the old leader.
+
+## Majority failure
+
+When the majority members of the cluster fail, the etcd cluster fails and cannot accept more writes.
+
+The etcd cluster can only recover from a majority failure once the majority of members become available. If a majority of members cannot come back online, then the operator must start [disaster recovery][unrecoverable] to recover the cluster.
+
+Once a majority of members works, the etcd cluster elects a new leader automatically and returns to a healthy state. The new leader extends timeouts automatically for all leases. This mechanism ensures no lease expires due to server side unavailability.
+
+## Network partition
+
+A network partition is similar to a minor followers failure or a leader failure. A network partition divides the etcd cluster into two parts; one with a member majority and the other with a member minority. The majority side becomes the available cluster and the minority side is unavailable; there is no ?split-brain? in etcd.
+
+If the leader is on the majority side, then from the majority point of view the failure is a minority follower failure. If the leader is on the minority side, then it is a leader failure. The leader on the minority side steps down and the majority side elects a new leader.
+
+Once the network partition clears, the minority side automatically recognizes the leader from the majority side and recovers its state.
+
+## Failure during bootstrapping
+
+A cluster bootstrap is only successful if all required members successfully start. If any failure happens during bootstrapping, remove the data directories on all members and re-bootstrap the cluster with a new cluster-token or new discovery token.
+
+Of course, it is possible to recover a failed bootstrapped cluster like recovering a running cluster. However, it almost always takes more time and resources to recover that cluster than bootstrapping a new one, since there is no data to recover.
+
+[backup]: maintenance.md#snapshot-backup
+[unrecoverable]: recovery.md#disaster-recovery
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/gateway.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/gateway.md
new file mode 100644
index 00000000..10fe5d0c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/gateway.md
@@ -0,0 +1,105 @@
+# etcd gateway
+
+## What is etcd gateway
+
+etcd gateway is a simple TCP proxy that forwards network data to the etcd cluster. The gateway is stateless and transparent; it neither inspects client requests nor interferes with cluster responses.
+
+The gateway supports multiple etcd server endpoints and works on a simple round-robin policy. It only routes to available enpoints and hides failures from its clients. Other retry policies, such as weighted round-robin, may be supported in the future.
+
+## When to use etcd gateway
+
+Every application that accesses etcd must first have the address of an etcd cluster client endpoint. If multiple applications on the same server access the same etcd cluster, every application still needs to know the advertised client endpoints of the etcd cluster. If the etcd cluster is reconfigured to have different endpoints, every application may also need to update its endpoint list. This wide-scale reconfiguration is both tedious and error prone.
+
+etcd gateway solves this problem by serving as a stable local endpoint. A typical etcd gateway configuration has each machine running a gateway listening on a local address and every etcd application connecting to its local gateway. The upshot is only the gateway needs to update its endpoints instead of updating each and every application.
+
+In summary, to automatically propagate cluster endpoint changes, the etcd gateway runs on every machine serving multiple applications accessing the same etcd cluster.
+
+## When not to use etcd gateway
+
+- Improving performance
+
+The gateway is not designed for improving etcd cluster performance. It does not provide caching, watch coalescing or batching. The etcd team is developing a caching proxy designed for improving cluster scalability.
+
+- Running on a cluster management system
+
+Advanced cluster management systems like Kubernetes natively support service discovery. Applications can access an etcd cluster with a DNS name or a virtual IP address managed by the system. For example, kube-proxy is equivalent to etcd gateway.
+
+## Start etcd gateway
+
+Consider an etcd cluster with the following static endpoints:
+
+|Name|Address|Hostname|
+|------|---------|------------------|
+|infra0|10.0.1.10|infra0.example.com|
+|infra1|10.0.1.11|infra1.example.com|
+|infra2|10.0.1.12|infra2.example.com|
+
+Start the etcd gateway to use these static endpoints with the command:
+
+```bash
+$ etcd gateway start --endpoints=infra0.example.com,infra1.example.com,infra2.example.com
+2016-08-16 11:21:18.867350 I | tcpproxy: ready to proxy client requests to [...]
+```
+
+Alternatively, if using DNS for service discovery, consider the DNS SRV entries:
+
+```bash
+$ dig +noall +answer SRV _etcd-client._tcp.example.com
+_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra0.example.com.
+_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra1.example.com.
+_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra2.example.com.
+```
+
+```bash
+$ dig +noall +answer infra0.example.com infra1.example.com infra2.example.com
+infra0.example.com. 300 IN A 10.0.1.10
+infra1.example.com. 300 IN A 10.0.1.11
+infra2.example.com. 300 IN A 10.0.1.12
+```
+
+Start the etcd gateway to fetch the endpoints from the DNS SRV entries with the command:
+
+```bash
+$ etcd gateway --discovery-srv=example.com
+2016-08-16 11:21:18.867350 I | tcpproxy: ready to proxy client requests to [...]
+```
+
+## Configuration flags
+
+### etcd cluster
+
+#### --endpoints
+
+ * Comma-separated list of etcd server targets for forwarding client connections.
+ * Default: `127.0.0.1:2379`
+ * Invalid example: `https://127.0.0.1:2379` (gateway does not terminate TLS)
+
+#### --discovery-srv
+
+ * DNS domain used to bootstrap cluster endpoints through SRV recrods.
+ * Default: (not set)
+
+### Network
+
+#### --listen-addr
+
+ * Interface and port to bind for accepting client requests.
+ * Default: `127.0.0.1:23790`
+
+#### --retry-delay
+
+ * Duration of delay before retrying to connect to failed endpoints.
+ * Default: 1m0s
+ * Invalid example: "123" (expects time unit in format)
+
+### Security
+
+#### --insecure-discovery
+
+ * Accept SRV records that are insecure or susceptible to man-in-the-middle attacks.
+ * Default: `false`
+
+#### --trusted-ca-file
+
+ * Path to the client TLS CA file for the etcd cluster. Used to authenticate endpoints.
+ * Default: (not set)
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/grafana.json b/vendor/github.com/coreos/etcd/Documentation/op-guide/grafana.json
new file mode 100644
index 00000000..c5493253
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/grafana.json
@@ -0,0 +1,1015 @@
+{
+ "id": 6,
+ "title": "test-etcd",
+ "description": "etcd sample Grafana dashboard with Prometheus",
+ "tags": [],
+ "style": "dark",
+ "timezone": "browser",
+ "editable": true,
+ "hideControls": false,
+ "sharedCrosshair": false,
+ "rows": [{
+ "collapse": false,
+ "editable": true,
+ "height": "250px",
+ "panels": [{
+ "cacheTimeout": null,
+ "colorBackground": false,
+ "colorValue": false,
+ "colors": [
+ "rgba(245, 54, 54, 0.9)",
+ "rgba(237, 129, 40, 0.89)",
+ "rgba(50, 172, 45, 0.97)"
+ ],
+ "datasource": "test-etcd",
+ "editable": true,
+ "error": false,
+ "format": "none",
+ "gauge": {
+ "maxValue": 100,
+ "minValue": 0,
+ "show": false,
+ "thresholdLabels": false,
+ "thresholdMarkers": true
+ },
+ "id": 28,
+ "interval": null,
+ "isNew": true,
+ "links": [],
+ "mappingType": 1,
+ "mappingTypes": [{
+ "name": "value to text",
+ "value": 1
+ },
+ {
+ "name": "range to text",
+ "value": 2
+ }
+ ],
+ "maxDataPoints": 100,
+ "nullPointMode": "connected",
+ "nullText": null,
+ "postfix": "",
+ "postfixFontSize": "50%",
+ "prefix": "",
+ "prefixFontSize": "50%",
+ "rangeMaps": [{
+ "from": "null",
+ "text": "N/A",
+ "to": "null"
+ }],
+ "span": 3,
+ "sparkline": {
+ "fillColor": "rgba(31, 118, 189, 0.18)",
+ "full": false,
+ "lineColor": "rgb(31, 120, 193)",
+ "show": false
+ },
+ "targets": [{
+ "expr": "sum(etcd_server_has_leader)",
+ "intervalFactor": 2,
+ "legendFormat": "",
+ "metric": "etcd_server_has_leader",
+ "refId": "A",
+ "step": 20
+ }],
+ "thresholds": "",
+ "title": "Up",
+ "type": "singlestat",
+ "valueFontSize": "200%",
+ "valueMaps": [{
+ "op": "=",
+ "text": "N/A",
+ "value": "null"
+ }],
+ "valueName": "avg"
+ },
+ {
+ "aliasColors": {},
+ "bars": false,
+ "datasource": "test-etcd",
+ "editable": true,
+ "error": false,
+ "fill": 0,
+ "id": 23,
+ "isNew": true,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "show": false,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 2,
+ "links": [],
+ "nullPointMode": "connected",
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "span": 5,
+ "stack": false,
+ "steppedLine": false,
+ "targets": [
+ {
+ "expr": "sum(rate(grpc_server_started_total{grpc_type=\"unary\"}[5m]))",
+ "format": "time_series",
+ "intervalFactor": 2,
+ "legendFormat": "RPC Rate",
+ "metric": "grpc_server_started_total",
+ "refId": "A",
+ "step": 2
+ },
+ {
+ "expr": "sum(rate(grpc_server_handled_total{grpc_type=\"unary\",grpc_code!=\"OK\"}[5m]))",
+ "format": "time_series",
+ "intervalFactor": 2,
+ "legendFormat": "RPC Failed Rate",
+ "metric": "grpc_server_handled_total",
+ "refId": "B",
+ "step": 2
+ }
+ ],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeShift": null,
+ "title": "RPC Rate",
+ "tooltip": {
+ "msResolution": false,
+ "shared": true,
+ "sort": 0,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [{
+ "format": "ops",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ]
+ },
+ {
+ "aliasColors": {},
+ "bars": false,
+ "datasource": "test-etcd",
+ "editable": true,
+ "error": false,
+ "fill": 0,
+ "id": 41,
+ "isNew": true,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "show": false,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 2,
+ "links": [],
+ "nullPointMode": "connected",
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "span": 4,
+ "stack": true,
+ "steppedLine": false,
+ "targets": [{
+ "expr": "sum(grpc_server_started_total{grpc_service=\"etcdserverpb.Watch\",grpc_type=\"bidi_stream\"}) - sum(grpc_server_handled_total{grpc_service=\"etcdserverpb.Watch\",grpc_type=\"bidi_stream\"})",
+ "intervalFactor": 2,
+ "legendFormat": "Watch Streams",
+ "metric": "grpc_server_handled_total",
+ "refId": "A",
+ "step": 4
+ },
+ {
+ "expr": "sum(grpc_server_started_total{grpc_service=\"etcdserverpb.Lease\",grpc_type=\"bidi_stream\"}) - sum(grpc_server_handled_total{grpc_service=\"etcdserverpb.Lease\",grpc_type=\"bidi_stream\"})",
+ "intervalFactor": 2,
+ "legendFormat": "Lease Streams",
+ "metric": "grpc_server_handled_total",
+ "refId": "B",
+ "step": 4
+ }
+ ],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeShift": null,
+ "title": "Active Streams",
+ "tooltip": {
+ "msResolution": false,
+ "shared": true,
+ "sort": 0,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [{
+ "format": "short",
+ "label": "",
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ]
+ }
+ ],
+ "showTitle": false,
+ "title": "Row"
+ },
+ {
+ "collapse": false,
+ "editable": true,
+ "height": "250px",
+ "panels": [{
+ "aliasColors": {},
+ "bars": false,
+ "datasource": "test-etcd",
+ "decimals": null,
+ "editable": true,
+ "error": false,
+ "fill": 0,
+ "grid": {},
+ "id": 1,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "show": false,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 2,
+ "links": [],
+ "nullPointMode": "connected",
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "span": 4,
+ "stack": false,
+ "steppedLine": false,
+ "targets": [{
+ "expr": "etcd_debugging_mvcc_db_total_size_in_bytes",
+ "hide": false,
+ "interval": "",
+ "intervalFactor": 2,
+ "legendFormat": "{{instance}} DB Size",
+ "metric": "",
+ "refId": "A",
+ "step": 4
+ }],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeShift": null,
+ "title": "DB Size",
+ "tooltip": {
+ "msResolution": false,
+ "shared": true,
+ "sort": 0,
+ "value_type": "cumulative"
+ },
+ "type": "graph",
+ "xaxis": {
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [{
+ "format": "bytes",
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": false
+ }
+ ]
+ },
+ {
+ "aliasColors": {},
+ "bars": false,
+ "datasource": "test-etcd",
+ "editable": true,
+ "error": false,
+ "fill": 0,
+ "grid": {},
+ "id": 3,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "show": false,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 2,
+ "links": [],
+ "nullPointMode": "connected",
+ "percentage": false,
+ "pointradius": 1,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "span": 4,
+ "stack": false,
+ "steppedLine": true,
+ "targets": [{
+ "expr": "histogram_quantile(0.99, sum(rate(etcd_disk_wal_fsync_duration_seconds_bucket[5m])) by (instance, le))",
+ "hide": false,
+ "intervalFactor": 2,
+ "legendFormat": "{{instance}} WAL fsync",
+ "metric": "etcd_disk_wal_fsync_duration_seconds_bucket",
+ "refId": "A",
+ "step": 4
+ },
+ {
+ "expr": "histogram_quantile(0.99, sum(rate(etcd_disk_backend_commit_duration_seconds_bucket[5m])) by (instance, le))",
+ "intervalFactor": 2,
+ "legendFormat": "{{instance}} DB fsync",
+ "metric": "etcd_disk_backend_commit_duration_seconds_bucket",
+ "refId": "B",
+ "step": 4
+ }
+ ],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeShift": null,
+ "title": "Disk Sync Duration",
+ "tooltip": {
+ "msResolution": false,
+ "shared": true,
+ "sort": 0,
+ "value_type": "cumulative"
+ },
+ "type": "graph",
+ "xaxis": {
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [{
+ "format": "s",
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": false
+ }
+ ]
+ },
+ {
+ "aliasColors": {},
+ "bars": false,
+ "datasource": "test-etcd",
+ "editable": true,
+ "error": false,
+ "fill": 0,
+ "id": 29,
+ "isNew": true,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "show": false,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 2,
+ "links": [],
+ "nullPointMode": "connected",
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "span": 4,
+ "stack": false,
+ "steppedLine": false,
+ "targets": [{
+ "expr": "process_resident_memory_bytes",
+ "intervalFactor": 2,
+ "legendFormat": "{{instance}} Resident Memory",
+ "metric": "process_resident_memory_bytes",
+ "refId": "A",
+ "step": 4
+ }],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeShift": null,
+ "title": "Memory",
+ "tooltip": {
+ "msResolution": false,
+ "shared": true,
+ "sort": 0,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [{
+ "format": "bytes",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ]
+ }
+ ],
+ "title": "New row"
+ },
+ {
+ "collapse": false,
+ "editable": true,
+ "height": "250px",
+ "panels": [{
+ "aliasColors": {},
+ "bars": false,
+ "datasource": "test-etcd",
+ "editable": true,
+ "error": false,
+ "fill": 5,
+ "id": 22,
+ "isNew": true,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "show": false,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 2,
+ "links": [],
+ "nullPointMode": "connected",
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "span": 3,
+ "stack": true,
+ "steppedLine": false,
+ "targets": [{
+ "expr": "rate(etcd_network_client_grpc_received_bytes_total[5m])",
+ "intervalFactor": 2,
+ "legendFormat": "{{instance}} Client Traffic In",
+ "metric": "etcd_network_client_grpc_received_bytes_total",
+ "refId": "A",
+ "step": 4
+ }],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeShift": null,
+ "title": "Client Traffic In",
+ "tooltip": {
+ "msResolution": false,
+ "shared": true,
+ "sort": 0,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [{
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ]
+ },
+ {
+ "aliasColors": {},
+ "bars": false,
+ "datasource": "test-etcd",
+ "editable": true,
+ "error": false,
+ "fill": 5,
+ "id": 21,
+ "isNew": true,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "show": false,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 2,
+ "links": [],
+ "nullPointMode": "connected",
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "span": 3,
+ "stack": true,
+ "steppedLine": false,
+ "targets": [{
+ "expr": "rate(etcd_network_client_grpc_sent_bytes_total[5m])",
+ "intervalFactor": 2,
+ "legendFormat": "{{instance}} Client Traffic Out",
+ "metric": "etcd_network_client_grpc_sent_bytes_total",
+ "refId": "A",
+ "step": 4
+ }],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeShift": null,
+ "title": "Client Traffic Out",
+ "tooltip": {
+ "msResolution": false,
+ "shared": true,
+ "sort": 0,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [{
+ "format": "Bps",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ]
+ },
+ {
+ "aliasColors": {},
+ "bars": false,
+ "datasource": "test-etcd",
+ "editable": true,
+ "error": false,
+ "fill": 0,
+ "id": 20,
+ "isNew": true,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "show": false,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 2,
+ "links": [],
+ "nullPointMode": "connected",
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "span": 3,
+ "stack": false,
+ "steppedLine": false,
+ "targets": [{
+ "expr": "sum(rate(etcd_network_peer_received_bytes_total[5m])) by (instance)",
+ "intervalFactor": 2,
+ "legendFormat": "{{instance}} Peer Traffic In",
+ "metric": "etcd_network_peer_received_bytes_total",
+ "refId": "A",
+ "step": 4
+ }],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeShift": null,
+ "title": "Peer Traffic In",
+ "tooltip": {
+ "msResolution": false,
+ "shared": true,
+ "sort": 0,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [{
+ "format": "Bps",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ]
+ },
+ {
+ "aliasColors": {},
+ "bars": false,
+ "datasource": "test-etcd",
+ "decimals": null,
+ "editable": true,
+ "error": false,
+ "fill": 0,
+ "grid": {},
+ "id": 16,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "show": false,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 2,
+ "links": [],
+ "nullPointMode": "connected",
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "span": 3,
+ "stack": false,
+ "steppedLine": false,
+ "targets": [{
+ "expr": "sum(rate(etcd_network_peer_sent_bytes_total[5m])) by (instance)",
+ "hide": false,
+ "interval": "",
+ "intervalFactor": 2,
+ "legendFormat": "{{instance}} Peer Traffic Out",
+ "metric": "etcd_network_peer_sent_bytes_total",
+ "refId": "A",
+ "step": 4
+ }],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeShift": null,
+ "title": "Peer Traffic Out",
+ "tooltip": {
+ "msResolution": false,
+ "shared": true,
+ "sort": 0,
+ "value_type": "cumulative"
+ },
+ "type": "graph",
+ "xaxis": {
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [{
+ "format": "Bps",
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ]
+ }
+ ],
+ "title": "New row"
+ },
+ {
+ "collapse": false,
+ "editable": true,
+ "height": "250px",
+ "panels": [{
+ "aliasColors": {},
+ "bars": false,
+ "datasource": "test-etcd",
+ "editable": true,
+ "error": false,
+ "fill": 0,
+ "id": 40,
+ "isNew": true,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "show": false,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 2,
+ "links": [],
+ "nullPointMode": "connected",
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "span": 6,
+ "stack": false,
+ "steppedLine": false,
+ "targets": [{
+ "expr": "sum(rate(etcd_server_proposals_failed_total[5m]))",
+ "intervalFactor": 2,
+ "legendFormat": "Proposal Failure Rate",
+ "metric": "etcd_server_proposals_failed_total",
+ "refId": "A",
+ "step": 2
+ },
+ {
+ "expr": "sum(etcd_server_proposals_pending)",
+ "intervalFactor": 2,
+ "legendFormat": "Proposal Pending Total",
+ "metric": "etcd_server_proposals_pending",
+ "refId": "B",
+ "step": 2
+ },
+ {
+ "expr": "sum(rate(etcd_server_proposals_committed_total[5m]))",
+ "intervalFactor": 2,
+ "legendFormat": "Proposal Commit Rate",
+ "metric": "etcd_server_proposals_committed_total",
+ "refId": "C",
+ "step": 2
+ },
+ {
+ "expr": "sum(rate(etcd_server_proposals_applied_total[5m]))",
+ "intervalFactor": 2,
+ "legendFormat": "Proposal Apply Rate",
+ "refId": "D",
+ "step": 2
+ }
+ ],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeShift": null,
+ "title": "Raft Proposals",
+ "tooltip": {
+ "msResolution": false,
+ "shared": true,
+ "sort": 0,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [{
+ "format": "short",
+ "label": "",
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ]
+ },
+ {
+ "aliasColors": {},
+ "bars": false,
+ "datasource": "test-etcd",
+ "decimals": 0,
+ "editable": true,
+ "error": false,
+ "fill": 0,
+ "id": 19,
+ "isNew": true,
+ "legend": {
+ "alignAsTable": false,
+ "avg": false,
+ "current": false,
+ "max": false,
+ "min": false,
+ "rightSide": false,
+ "show": false,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 2,
+ "links": [],
+ "nullPointMode": "connected",
+ "percentage": false,
+ "pointradius": 5,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "span": 6,
+ "stack": false,
+ "steppedLine": false,
+ "targets": [{
+ "expr": "changes(etcd_server_leader_changes_seen_total[1d])",
+ "intervalFactor": 2,
+ "legendFormat": "{{instance}} Total Leader Elections Per Day",
+ "metric": "etcd_server_leader_changes_seen_total",
+ "refId": "A",
+ "step": 2
+ }],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeShift": null,
+ "title": "Total Leader Elections Per Day",
+ "tooltip": {
+ "msResolution": false,
+ "shared": true,
+ "sort": 0,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [{
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ]
+ }
+ ],
+ "title": "New row"
+ }
+ ],
+ "time": {
+ "from": "now-15m",
+ "to": "now"
+ },
+ "timepicker": {
+ "now": true,
+ "refresh_intervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "time_options": [
+ "5m",
+ "15m",
+ "1h",
+ "6h",
+ "12h",
+ "24h",
+ "2d",
+ "7d",
+ "30d"
+ ]
+ },
+ "templating": {
+ "list": []
+ },
+ "annotations": {
+ "list": []
+ },
+ "refresh": false,
+ "schemaVersion": 13,
+ "version": 215,
+ "links": [],
+ "gnetId": null
+}
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/grpc_proxy.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/grpc_proxy.md
new file mode 100644
index 00000000..4a2a6ca4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/grpc_proxy.md
@@ -0,0 +1,193 @@
+# gRPC proxy
+
+The gRPC proxy is a stateless etcd reverse proxy operating at the gRPC layer (L7). The proxy is designed to reduce the total processing load on the core etcd cluster. For horizontal scalability, it coalesces watch and lease API requests. To protect the cluster against abusive clients, it caches key range requests.
+
+The gRPC proxy supports multiple etcd server endpoints. When the proxy starts, it randomly picks one etcd server endpoint to use. This endpoint serves all requests until the proxy detects an endpoint failure. If the gRPC proxy detects an endpoint failure, it switches to a different endpoint, if available, to hide failures from its clients. Other retry policies, such as weighted round-robin, may be supported in the future.
+
+## Scalable watch API
+
+The gRPC proxy coalesces multiple client watchers (`c-watchers`) on the same key or range into a single watcher (`s-watcher`) connected to an etcd server. The proxy broadcasts all events from the `s-watcher` to its `c-watchers`.
+
+Assuming N clients watch the same key, one gRPC proxy can reduce the watch load on the etcd server from N to 1. Users can deploy multiple gRPC proxies to further distribute server load.
+
+In the following example, three clients watch on key A. The gRPC proxy coalesces the three watchers, creating a single watcher attached to the etcd server.
+
+```
+ +-------------+
+ | etcd server |
+ +------+------+
+ ^ watch key A (s-watcher)
+ |
+ +-------+-----+
+ | gRPC proxy | <-------+
+ | | |
+ ++-----+------+ |watch key A (c-watcher)
+watch key A ^ ^ watch key A |
+(c-watcher) | | (c-watcher) |
+ +-------+-+ ++--------+ +----+----+
+ | client | | client | | client |
+ | | | | | |
+ +---------+ +---------+ +---------+
+```
+
+### Limitations
+
+To effectively coalesce multiple client watchers into a single watcher, the gRPC proxy coalesces new `c-watchers` into an existing `s-watcher` when possible. This coalesced `s-watcher` may be out of sync with the etcd server due to network delays or buffered undelivered events. When the watch revision is unspecified, the gRPC proxy will not guarantee the `c-watcher` will start watching from the most recent store revision. For example, if a client watches from an etcd server with revision 1000, that watcher will begin at revision 1000. If a client watches from the gRPC proxy, may begin watching from revision 990.
+
+Similar limitations apply to cancellation. When the watcher is cancelled, the etcd server?s revision may be greater than the cancellation response revision.
+
+These two limitations should not cause problems for most use cases. In the future, there may be additional options to force the watcher to bypass the gRPC proxy for more accurate revision responses.
+
+## Scalable lease API
+
+To keep its leases alive, a client must establish at least one gRPC stream to an etcd server for sending periodic heartbeats. If an etcd workload involves heavy lease activity spread over many clients, these streams may contribute to excessive CPU utilization. To reduce the total number of streams on the core cluster, the proxy supports lease stream coalescing.
+
+Assuming N clients are updating leases, a single gRPC proxy reduces the stream load on the etcd server from N to 1. Deployments may have additional gRPC proxies to further distribute streams across multiple proxies.
+
+In the following example, three clients update three independent leases (`L1`, `L2`, and `L3`). The gRPC proxy coalesces the three client lease streams (`c-streams`) into a single lease keep alive stream (`s-stream`) attached to an etcd server. The proxy forwards client-side lease heartbeats from the c-streams to the s-stream, then returns the responses to the corresponding c-streams.
+
+```
+ +-------------+
+ | etcd server |
+ +------+------+
+ ^
+ | heartbeat L1, L2, L3
+ | (s-stream)
+ v
+ +-------+-----+
+ | gRPC proxy +<-----------+
+ +---+------+--+ | heartbeat L3
+ ^ ^ | (c-stream)
+heartbeat L1 | | heartbeat L2 |
+(c-stream) v v (c-stream) v
+ +------+-+ +-+------+ +-----+--+
+ | client | | client | | client |
+ +--------+ +--------+ +--------+
+```
+
+## Abusive clients protection
+
+The gRPC proxy caches responses for requests when it does not break consistency requirements. This can protect the etcd server from abusive clients in tight for loops.
+
+## Start etcd gRPC proxy
+
+Consider an etcd cluster with the following static endpoints:
+
+|Name|Address|Hostname|
+|------|---------|------------------|
+|infra0|10.0.1.10|infra0.example.com|
+|infra1|10.0.1.11|infra1.example.com|
+|infra2|10.0.1.12|infra2.example.com|
+
+Start the etcd gRPC proxy to use these static endpoints with the command:
+
+```bash
+$ etcd grpc-proxy start --endpoints=infra0.example.com,infra1.example.com,infra2.example.com --listen-addr=127.0.0.1:2379
+```
+
+The etcd gRPC proxy starts and listens on port 8080. It forwards client requests to one of the three endpoints provided above.
+
+Sending requests through the proxy:
+
+```bash
+$ ETCDCTL_API=3 ./etcdctl --endpoints=127.0.0.1:2379 put foo bar
+OK
+$ ETCDCTL_API=3 ./etcdctl --endpoints=127.0.0.1:2379 get foo
+foo
+bar
+```
+
+## Client endpoint synchronization and name resolution
+
+The proxy supports registering its endpoints for discovery by writing to a user-defined endpoint. This serves two purposes. First, it allows clients to synchronize their endpoints against a set of proxy endpoints for high availability. Second, it is an endpoint provider for etcd [gRPC naming](../dev-guide/grpc_naming.md).
+
+Register proxy(s) by providing a user-defined prefix:
+
+```bash
+$ etcd grpc-proxy start --endpoints=localhost:2379 \
+ --listen-addr=127.0.0.1:23790 \
+ --advertise-client-url=127.0.0.1:23790 \
+ --resolver-prefix="___grpc_proxy_endpoint" \
+ --resolver-ttl=60
+
+$ etcd grpc-proxy start --endpoints=localhost:2379 \
+ --listen-addr=127.0.0.1:23791 \
+ --advertise-client-url=127.0.0.1:23791 \
+ --resolver-prefix="___grpc_proxy_endpoint" \
+ --resolver-ttl=60
+```
+
+The proxy will list all its members for member list:
+
+```bash
+ETCDCTL_API=3 ./bin/etcdctl --endpoints=http://localhost:23790 member list --write-out table
+
++----+---------+--------------------------------+------------+-----------------+
+| ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS |
++----+---------+--------------------------------+------------+-----------------+
+| 0 | started | Gyu-Hos-MBP.sfo.coreos.systems | | 127.0.0.1:23791 |
+| 0 | started | Gyu-Hos-MBP.sfo.coreos.systems | | 127.0.0.1:23790 |
++----+---------+--------------------------------+------------+-----------------+
+```
+
+This lets clients automatically discover proxy endpoints through Sync:
+
+```go
+cli, err := clientv3.New(clientv3.Config{
+ Endpoints: []string{"http://localhost:23790"},
+})
+if err != nil {
+ log.Fatal(err)
+}
+defer cli.Close()
+
+// fetch registered grpc-proxy endpoints
+if err := cli.Sync(context.Background()); err != nil {
+ log.Fatal(err)
+}
+```
+
+Note that if a proxy is configured without a resolver prefix,
+
+```bash
+$ etcd grpc-proxy start --endpoints=localhost:2379 \
+ --listen-addr=127.0.0.1:23792 \
+ --advertise-client-url=127.0.0.1:23792
+```
+
+the member list API to the grpc-proxy returns its own `advertise-client-url`:
+
+```bash
+ETCDCTL_API=3 ./bin/etcdctl --endpoints=http://localhost:23792 member list --write-out table
+
++----+---------+--------------------------------+------------+-----------------+
+| ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS |
++----+---------+--------------------------------+------------+-----------------+
+| 0 | started | Gyu-Hos-MBP.sfo.coreos.systems | | 127.0.0.1:23792 |
++----+---------+--------------------------------+------------+-----------------+
+```
+
+## Namespacing
+
+Suppose an application expects full control over the entire key space, but the etcd cluster is shared with other applications. To let all appications run without interfering with each other, the proxy can partition the etcd keyspace so clients appear to have access to the complete keyspace. When the proxy is given the flag `--namespace`, all client requests going into the proxy are translated to have a user-defined prefix on the keys. Accesses to the etcd cluster will be under the prefix and responses from the proxy will strip away the prefix; to the client, it appears as if there is no prefix at all.
+
+To namespace a proxy, start it with `--namespace`:
+
+```bash
+$ etcd grpc-proxy start --endpoints=localhost:2379 \
+ --listen-addr=127.0.0.1:23790 \
+ --namespace=my-prefix/
+```
+
+Accesses to the proxy are now transparently prefixed on the etcd cluster:
+
+```bash
+$ ETCDCTL_API=3 ./bin/etcdctl --endpoints=localhost:23790 put my-key abc
+# OK
+$ ETCDCTL_API=3 ./bin/etcdctl --endpoints=localhost:23790 get my-key
+# my-key
+# abc
+$ ETCDCTL_API=3 ./bin/etcdctl --endpoints=localhost:2379 get my-prefix/my-key
+# my-prefix/my-key
+# abc
+```
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/hardware.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/hardware.md
new file mode 100644
index 00000000..c004cb63
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/hardware.md
@@ -0,0 +1,93 @@
+# Hardware recommendations
+
+etcd usually runs well with limited resources for development or testing purposes; it?s common to develop with etcd on a laptop or a cheap cloud machine. However, when running etcd clusters in production, some hardware guidelines are useful for proper administration. These suggestions are not hard rules; they serve as a good starting point for a robust production deployment. As always, deployments should be tested with simulated workloads before running in production.
+
+## CPUs
+
+Few etcd deployments require a lot of CPU capacity. Typical clusters need two to four cores to run smoothly.
+Heavily loaded etcd deployments, serving thousands of clients or tens of thousands of requests per second, tend to be CPU bound since etcd can serve requests from memory. Such heavy deployments usually need eight to sixteen dedicated cores.
+
+
+## Memory
+
+etcd has a relatively small memory footprint but its performance still depends on having enough memory. An etcd server will aggressively cache key-value data and spends most of the rest of its memory tracking watchers. Typically 8GB is enough. For heavy deployments with thousands of watchers and millions of keys, allocate 16GB to 64GB memory accordingly.
+
+
+## Disks
+
+Fast disks are the most critical factor for etcd deployment performance and stability.
+
+A slow disk will increase etcd request latency and potentially hurt cluster stability. Since etcd?s consensus protocol depends on persistently storing metadata to a log, a majority of etcd cluster members must write every request down to disk. Additionally, etcd will also incrementally checkpoint its state to disk so it can truncate this log. If these writes take too long, heartbeats may time out and trigger an election, undermining the stability of the cluster.
+
+etcd is very sensitive to disk write latency. Typically 50 sequential IOPS (e.g., a 7200 RPM disk) is required. For heavily loaded clusters, 500 sequential IOPS (e.g., a typical local SSD or a high performance virtualized block device) is recommended. Note that most cloud providers publish concurrent IOPS rather than sequential IOPS; the published concurrent IOPS can be 10x greater than the sequential IOPS. To measure actual sequential IOPS, we suggest using a disk benchmarking tool such as [diskbench][diskbench] or [fio][fio].
+
+etcd requires only modest disk bandwidth but more disk bandwidth buys faster recovery times when a failed member has to catch up with the cluster. Typically 10MB/s will recover 100MB data within 15 seconds. For large clusters, 100MB/s or higher is suggested for recovering 1GB data within 15 seconds.
+
+When possible, back etcd?s storage with a SSD. A SSD usually provides lower write latencies and with less variance than a spinning disk, thus improving the stability and reliability of etcd. If using spinning disk, get the fastest disks possible (15,000 RPM). Using RAID 0 is also an effective way to increase disk speed, for both spinning disks and SSD. With at least three cluster members, mirroring and/or parity variants of RAID are unnecessary; etcd's consistent replication already gets high availability.
+
+
+## Network
+
+Multi-member etcd deployments benefit from a fast and reliable network. In order for etcd to be both consistent and partition tolerant, an unreliable network with partitioning outages will lead to poor availability. Low latency ensures etcd members can communicate fast. High bandwidth can reduce the time to recover a failed etcd member. 1GbE is sufficient for common etcd deployments. For large etcd clusters, a 10GbE network will reduce mean time to recovery.
+
+Deploy etcd members within a single data center when possible to avoid latency overheads and lessen the possibility of partitioning events. If a failure domain in another data center is required, choose a data center closer to the existing one. Please also read the [tuning][tuning] documentation for more information on cross data center deployment.
+
+
+## Example hardware configurations
+
+Here are a few example hardware setups on AWS and GCE environments. As mentioned before, but must be stressed regardless, administrators should test an etcd deployment with a simulated workload before putting it into production.
+
+Note that these configurations assume these machines are totally dedicated to etcd. Running other applications along with etcd on these machines may cause resource contentions and lead to cluster instability.
+
+### Small cluster
+
+A small cluster serves fewer than 100 clients, fewer than 200 of requests per second, and stores no more than 100MB of data.
+
+Example application workload: A 50-node Kubernetes cluster
+
+| Provider | Type | vCPUs | Memory (GB) | Max concurrent IOPS | Disk bandwidth (MB/s) |
+|----------|------|-------|--------|------|----------------|
+| AWS | m4.large | 2 | 8 | 3600 | 56.25 |
+| GCE | n1-standard-1 + 50GB PD SSD | 2 | 7.5 | 1500 | 25 |
+
+
+### Medium cluster
+
+A medium cluster serves fewer than 500 clients, fewer than 1,000 of requests per second, and stores no more than 500MB of data.
+
+Example application workload: A 250-node Kubernetes cluster
+
+| Provider | Type | vCPUs | Memory (GB) | Max concurrent IOPS | Disk bandwidth (MB/s) |
+|----------|------|-------|--------|------|----------------|
+| AWS | m4.xlarge | 4 | 16 | 6000 | 93.75 |
+| GCE | n1-standard-4 + 150GB PD SSD | 4 | 15 | 4500 | 75 |
+
+
+### Large cluster
+
+A large cluster serves fewer than 1,500 clients, fewer than 10,000 of requests per second, and stores no more than 1GB of data.
+
+Example application workload: A 1,000-node Kubernetes cluster
+
+| Provider | Type | vCPUs | Memory (GB) | Max concurrent IOPS | Disk bandwidth (MB/s) |
+|----------|------|-------|--------|------|----------------|
+| AWS | m4.2xlarge | 8 | 32 | 8000 | 125 |
+| GCE | n1-standard-8 + 250GB PD SSD | 8 | 30 | 7500 | 125 |
+
+
+### xLarge cluster
+
+An xLarge cluster serves more than 1,500 clients, more than 10,000 of requests per second, and stores more than 1GB data.
+
+Example application workload: A 3,000 node Kubernetes cluster
+
+| Provider | Type | vCPUs | Memory (GB) | Max concurrent IOPS | Disk bandwidth (MB/s) |
+|----------|------|-------|--------|------|----------------|
+| AWS | m4.4xlarge | 16 | 64 | 16,000 | 250 |
+| GCE | n1-standard-16 + 500GB PD SSD | 16 | 60 | 15,000 | 250 |
+
+
+[diskbench]: https://github.com/ongardie/diskbenchmark
+[fio]: https://github.com/axboe/fio
+[tuning]: ../tuning.md
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/maintenance.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/maintenance.md
new file mode 100644
index 00000000..ea917141
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/maintenance.md
@@ -0,0 +1,114 @@
+# Maintenance
+
+## Overview
+
+An etcd cluster needs periodic maintenance to remain reliable. Depending on an etcd application's needs, this maintenance can usually be automated and performed without downtime or significantly degraded performance.
+
+All etcd maintenance manages storage resources consumed by the etcd keyspace. Failure to adequately control the keyspace size is guarded by storage space quotas; if an etcd member runs low on space, a quota will trigger cluster-wide alarms which will put the system into a limited-operation maintenance mode. To avoid running out of space for writes to the keyspace, the etcd keyspace history must be compacted. Storage space itself may be reclaimed by defragmenting etcd members. Finally, periodic snapshot backups of etcd member state makes it possible to recover any unintended logical data loss or corruption caused by operational error.
+
+## History compaction
+
+Since etcd keeps an exact history of its keyspace, this history should be periodically compacted to avoid performance degradation and eventual storage space exhaustion. Compacting the keyspace history drops all information about keys superseded prior to a given keyspace revision. The space used by these keys then becomes available for additional writes to the keyspace.
+
+The keyspace can be compacted automatically with `etcd`'s time windowed history retention policy, or manually with `etcdctl`. The `etcdctl` method provides fine-grained control over the compacting process whereas automatic compacting fits applications that only need key history for some length of time.
+
+`etcd` can be set to automatically compact the keyspace with the `--auto-compaction` option with a period of hours:
+
+```sh
+# keep one hour of history
+$ etcd --auto-compaction-retention=1
+```
+
+An `etcdctl` initiated compaction works as follows:
+
+```sh
+# compact up to revision 3
+$ etcdctl compact 3
+
+```
+
+Revisions prior to the compaction revision become inaccessible:
+
+```sh
+$ etcdctl get --rev=2 somekey
+Error: rpc error: code = 11 desc = etcdserver: mvcc: required revision has been compacted
+```
+
+## Defragmentation
+
+After compacting the keyspace, the backend database may exhibit internal fragmentation. Any internal fragmentation is space that is free to use by the backend but still consumes storage space. The process of defragmentation releases this storage space back to the file system. Defragmentation is issued on a per-member so that cluster-wide latency spikes may be avoided.
+
+Compacting old revisions internally fragments `etcd` by leaving gaps in backend database. Fragmented space is available for use by `etcd` but unavailable to the host filesystem.
+
+To defragment an etcd member, use the `etcdctl defrag` command:
+
+```sh
+$ etcdctl defrag
+Finished defragmenting etcd member[127.0.0.1:2379]
+```
+
+## Space quota
+
+The space quota in `etcd` ensures the cluster operates in a reliable fashion. Without a space quota, `etcd` may suffer from poor performance if the keyspace grows excessively large, or it may simply run out of storage space, leading to unpredictable cluster behavior. If the keyspace's backend database for any member exceeds the space quota, `etcd` raises a cluster-wide alarm that puts the cluster into a maintenance mode which only accepts key reads and deletes. Only after freeing enough space in the keyspace and defragmenting the backend database, along with clearing the space quota alarm can the cluster resume normal operation.
+
+By default, `etcd` sets a conservative space quota suitable for most applications, but it may be configured on the command line, in bytes:
+
+```sh
+# set a very small 16MB quota
+$ etcd --quota-backend-bytes=$((16*1024*1024))
+```
+
+The space quota can be triggered with a loop:
+
+```sh
+# fill keyspace
+$ while [ 1 ]; do dd if=/dev/urandom bs=1024 count=1024 | ETCDCTL_API=3 etcdctl put key || break; done
+...
+Error: rpc error: code = 8 desc = etcdserver: mvcc: database space exceeded
+# confirm quota space is exceeded
+$ ETCDCTL_API=3 etcdctl --write-out=table endpoint status
++----------------+------------------+-----------+---------+-----------+-----------+------------+
+| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | RAFT TERM | RAFT INDEX |
++----------------+------------------+-----------+---------+-----------+-----------+------------+
+| 127.0.0.1:2379 | bf9071f4639c75cc | 2.3.0+git | 18 MB | true | 2 | 3332 |
++----------------+------------------+-----------+---------+-----------+-----------+------------+
+# confirm alarm is raised
+$ ETCDCTL_API=3 etcdctl alarm list
+memberID:13803658152347727308 alarm:NOSPACE
+```
+
+Removing excessive keyspace data and defragmenting the backend database will put the cluster back within the quota limits:
+
+```sh
+# get current revision
+$ rev=$(ETCDCTL_API=3 etcdctl --endpoints=:2379 endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9]*')
+# compact away all old revisions
+$ ETCDCTL_API=3 etcdctl compact $rev
+compacted revision 1516
+# defragment away excessive space
+$ ETCDCTL_API=3 etcdctl defrag
+Finished defragmenting etcd member[127.0.0.1:2379]
+# disarm alarm
+$ ETCDCTL_API=3 etcdctl alarm disarm
+memberID:13803658152347727308 alarm:NOSPACE
+# test puts are allowed again
+$ ETCDCTL_API=3 etcdctl put newkey 123
+OK
+```
+
+## Snapshot backup
+
+Snapshotting the `etcd` cluster on a regular basis serves as a durable backup for an etcd keyspace. By taking periodic snapshots of an etcd member's backend database, an `etcd` cluster can be recovered to a point in time with a known good state.
+
+A snapshot is taken with `etcdctl`:
+
+```sh
+$ etcdctl snapshot save backup.db
+$ etcdctl --write-out=table snapshot status backup.db
++----------+----------+------------+------------+
+| HASH | REVISION | TOTAL KEYS | TOTAL SIZE |
++----------+----------+------------+------------+
+| fe01cf57 | 10 | 7 | 2.1 MB |
++----------+----------+------------+------------+
+
+```
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/monitoring.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/monitoring.md
new file mode 100644
index 00000000..7a981270
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/monitoring.md
@@ -0,0 +1,88 @@
+# Monitoring etcd
+
+Each etcd server exports metrics under the `/metrics` path on its client port.
+
+The metrics can be fetched with `curl`:
+
+```sh
+$ curl -L http://localhost:2379/metrics
+
+# HELP etcd_debugging_mvcc_keys_total Total number of keys.
+# TYPE etcd_debugging_mvcc_keys_total gauge
+etcd_debugging_mvcc_keys_total 0
+# HELP etcd_debugging_mvcc_pending_events_total Total number of pending events to be sent.
+# TYPE etcd_debugging_mvcc_pending_events_total gauge
+etcd_debugging_mvcc_pending_events_total 0
+...
+```
+
+
+## Prometheus
+
+Running a [Prometheus][prometheus] monitoring service is the easiest way to ingest and record etcd's metrics.
+
+First, install Prometheus:
+
+```sh
+PROMETHEUS_VERSION="1.3.1"
+wget https://github.com/prometheus/prometheus/releases/download/v$PROMETHEUS_VERSION/prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz -O /tmp/prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz
+tar -xvzf /tmp/prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz --directory /tmp/ --strip-components=1
+/tmp/prometheus -version
+```
+
+Set Prometheus's scraper to target the etcd cluster endpoints:
+
+```sh
+cat > /tmp/test-etcd.yaml <<EOF
+global:
+ scrape_interval: 10s
+scrape_configs:
+ - job_name: test-etcd
+ static_configs:
+ - targets: ['10.240.0.32:2379','10.240.0.33:2379','10.240.0.34:2379']
+EOF
+cat /tmp/test-etcd.yaml
+```
+
+Set up the Prometheus handler:
+
+```sh
+nohup /tmp/prometheus \
+ -config.file /tmp/test-etcd.yaml \
+ -web.listen-address ":9090" \
+ -storage.local.path "test-etcd.data" >> /tmp/test-etcd.log 2>&1 &
+```
+
+Now Prometheus will scrape etcd metrics every 10 seconds.
+
+
+## Alerting
+
+There is a [set of default alerts for etcd v3 clusters](./etcd3_alert.rules).
+
+> Note: `job` labels may need to be adjusted to fit a particular need. The rules were written to apply to a single cluster so it is recommended to choose labels unique to a cluster.
+
+## Grafana
+
+[Grafana][grafana] has built-in Prometheus support; just add a Prometheus data source:
+
+```
+Name: test-etcd
+Type: Prometheus
+Url: http://localhost:9090
+Access: proxy
+```
+
+Then import the default [etcd dashboard template][template] and customize. For instance, if Prometheus data source name is `my-etcd`, the `datasource` field values in JSON also need to be `my-etcd`.
+
+See the [demo][demo].
+
+Sample dashboard:
+
+![](./etcd-sample-grafana.png)
+
+
+[prometheus]: https://prometheus.io/
+[grafana]: http://grafana.org/
+[template]: ./grafana.json
+[demo]: http://dash.etcd.io/dashboard/db/test-etcd
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/performance.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/performance.md
new file mode 100644
index 00000000..926caf32
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/performance.md
@@ -0,0 +1,70 @@
+# Performance
+
+## Understanding performance
+
+etcd provides stable, sustained high performance. Two factors define performance: latency and throughput. Latency is the time taken to complete an operation. Throughput is the total operations completed within some time period. Usually average latency increases as the overall throughput increases when etcd accepts concurrent client requests. In common cloud environments, like a standard `n-4` on Google Compute Engine (GCE) or a comparable machine type on AWS, a three member etcd cluster finishes a request in less than one millisecond under light load, and can complete more than 30,000 requests per second under heavy load.
+
+etcd uses the Raft consensus algorithm to replicate requests among members and reach agreement. Consensus performance, especially commit latency, is limited by two physical constraints: network IO latency and disk IO latency. The minimum time to finish an etcd request is the network Round Trip Time (RTT) between members, plus the time `fdatasync` requires to commit the data to permanant storage. The RTT within a datacenter may be as long as several hundred microseconds. A typical RTT within the United States is around 50ms, and can be as slow as 400ms between continents. The typical fdatasync latency for a spinning disk is about 10ms. For SSDs, the latency is often lower than 1ms. To increase throughput, etcd batches multiple requests together and submits them to Raft. This batching policy lets etcd attain high throughput despite heavy load.
+
+There are other sub-systems which impact the overall performance of etcd. Each serialized etcd request must run through etcd?s boltdb-backed MVCC storage engine, which usually takes tens of microseconds to finish. Periodically etcd incrementally snapshots its recently applied requests, merging them back with the previous on-disk snapshot. This process may lead to a latency spike. Although this is usually not a problem on SSDs, it may double the observed latency on HDD. Likewise, inflight compactions can impact etcd?s performance. Fortunately, the impact is often insignificant since the compaction is staggered so it does not compete for resources with regular requests. The RPC system, gRPC, gives etcd a well-defined, extensible API, but it also introduces additional latency, especially for local reads.
+
+## Benchmarks
+
+Benchmarking etcd performance can be done with the [benchmark](https://github.com/coreos/etcd/tree/master/tools/benchmark) CLI tool included with etcd.
+
+For some baseline performance numbers, we consider a three member etcd cluster with the following hardware configuration:
+
+- Google Cloud Compute Engine
+- 3 machines of 8 vCPUs + 16GB Memory + 50GB SSD
+- 1 machine(client) of 16 vCPUs + 30GB Memory + 50GB SSD
+- Ubuntu 17.04
+- etcd 3.2.0, go 1.8.3
+
+With this configuration, etcd can approximately write:
+
+| Number of keys | Key size in bytes | Value size in bytes | Number of connections | Number of clients | Target etcd server | Average write QPS | Average latency per request | Average server RSS |
+|---------------:|------------------:|--------------------:|----------------------:|------------------:|--------------------|------------------:|----------------------------:|-------------------:|
+| 10,000 | 8 | 256 | 1 | 1 | leader only | 583 | 1.6ms | 48 MB |
+| 100,000 | 8 | 256 | 100 | 1000 | leader only | 44,341 | 22ms | 124MB |
+| 100,000 | 8 | 256 | 100 | 1000 | all members | 50,104 | 20ms | 126MB |
+
+Sample commands are:
+
+```sh
+# write to leader
+benchmark --endpoints=${HOST_1} --target-leader --conns=1 --clients=1 \
+ put --key-size=8 --sequential-keys --total=10000 --val-size=256
+benchmark --endpoints=${HOST_1} --target-leader --conns=100 --clients=1000 \
+ put --key-size=8 --sequential-keys --total=100000 --val-size=256
+
+# write to all members
+benchmark --endpoints=${HOST_1},${HOST_2},${HOST_3} --conns=100 --clients=1000 \
+ put --key-size=8 --sequential-keys --total=100000 --val-size=256
+```
+
+Linearizable read requests go through a quorum of cluster members for consensus to fetch the most recent data. Serializable read requests are cheaper than linearizable reads since they are served by any single etcd member, instead of a quorum of members, in exchange for possibly serving stale data. etcd can read:
+
+| Number of requests | Key size in bytes | Value size in bytes | Number of connections | Number of clients | Consistency | Average read QPS | Average latency per request |
+|-------------------:|------------------:|--------------------:|----------------------:|------------------:|-------------|-----------------:|----------------------------:|
+| 10,000 | 8 | 256 | 1 | 1 | Linearizable | 1,353 | 0.7ms |
+| 10,000 | 8 | 256 | 1 | 1 | Serializable | 2,909 | 0.3ms |
+| 100,000 | 8 | 256 | 100 | 1000 | Linearizable | 141,578 | 5.5ms |
+| 100,000 | 8 | 256 | 100 | 1000 | Serializable | 185,758 | 2.2ms |
+
+Sample commands are:
+
+```sh
+# Single connection read requests
+benchmark --endpoints=${HOST_1},${HOST_2},${HOST_3} --conns=1 --clients=1 \
+ range YOUR_KEY --consistency=l --total=10000
+benchmark --endpoints=${HOST_1},${HOST_2},${HOST_3} --conns=1 --clients=1 \
+ range YOUR_KEY --consistency=s --total=10000
+
+# Many concurrent read requests
+benchmark --endpoints=${HOST_1},${HOST_2},${HOST_3} --conns=100 --clients=1000 \
+ range YOUR_KEY --consistency=l --total=100000
+benchmark --endpoints=${HOST_1},${HOST_2},${HOST_3} --conns=100 --clients=1000 \
+ range YOUR_KEY --consistency=s --total=100000
+```
+
+We encourage running the benchmark test when setting up an etcd cluster for the first time in a new environment to ensure the cluster achieves adequate performance; cluster latency and throughput can be sensitive to minor environment differences.
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/recovery.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/recovery.md
new file mode 100644
index 00000000..b6678189
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/recovery.md
@@ -0,0 +1,63 @@
+## Disaster recovery
+
+etcd is designed to withstand machine failures. An etcd cluster automatically recovers from temporary failures (e.g., machine reboots) and tolerates up to *(N-1)/2* permanent failures for a cluster of N members. When a member permanently fails, whether due to hardware failure or disk corruption, it loses access to the cluster. If the cluster permanently loses more than *(N-1)/2* members then it disastrously fails, irrevocably losing quorum. Once quorum is lost, the cluster cannot reach consensus and therefore cannot continue accepting updates.
+
+To recover from disastrous failure, etcd v3 provides snapshot and restore facilities to recreate the cluster without v3 key data loss. To recover v2 keys, refer to the [v2 admin guide][v2_recover].
+
+[v2_recover]: ../v2/admin_guide.md#disaster-recovery
+
+### Snapshotting the keyspace
+
+Recovering a cluster first needs a snapshot of the keyspace from an etcd member. A snapshot may either be taken from a live member with the `etcdctl snapshot save` command or by copying the `member/snap/db` file from an etcd data directory. For example, the following command snapshots the keyspace served by `$ENDPOINT` to the file `snapshot.db`:
+
+```sh
+$ ETCDCTL_API=3 etcdctl --endpoints $ENDPOINT snapshot save snapshot.db
+```
+
+### Restoring a cluster
+
+To restore a cluster, all that is needed is a single snapshot "db" file. A cluster restore with `etcdctl snapshot restore` creates new etcd data directories; all members should restore using the same snapshot. Restoring overwrites some snapshot metadata (specifically, the member ID and cluster ID); the member loses its former identity. This metadata overwrite prevents the new member from inadvertently joining an existing cluster. Therefore in order to start a cluster from a snapshot, the restore must start a new logical cluster.
+
+Snapshot integrity may be optionally verified at restore time. If the snapshot is taken with `etcdctl snapshot save`, it will have an integrity hash that is checked by `etcdctl snapshot restore`. If the snapshot is copied from the data directory, there is no integrity hash and it will only restore by using `--skip-hash-check`.
+
+A restore initializes a new member of a new cluster, with a fresh cluster configuration using `etcd`'s cluster configuration flags, but preserves the contents of the etcd keyspace. Continuing from the previous example, the following creates new etcd data directories (`m1.etcd`, `m2.etcd`, `m3.etcd`) for a three member cluster:
+
+```sh
+$ ETCDCTL_API=3 etcdctl snapshot restore snapshot.db \
+ --name m1 \
+ --initial-cluster m1=http://host1:2380,m2=http://host2:2380,m3=http://host3:2380 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-advertise-peer-urls http://host1:2380
+$ ETCDCTL_API=3 etcdctl snapshot restore snapshot.db \
+ --name m2 \
+ --initial-cluster m1=http://host1:2380,m2=http://host2:2380,m3=http://host3:2380 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-advertise-peer-urls http://host2:2380
+$ ETCDCTL_API=3 etcdctl snapshot restore snapshot.db \
+ --name m3 \
+ --initial-cluster m1=http://host1:2380,m2=http://host2:2380,m3=http://host3:2380 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-advertise-peer-urls http://host3:2380
+```
+
+Next, start `etcd` with the new data directories:
+
+```sh
+$ etcd \
+ --name m1 \
+ --listen-client-urls http://host1:2379 \
+ --advertise-client-urls http://host1:2379 \
+ --listen-peer-urls http://host1:2380 &
+$ etcd \
+ --name m2 \
+ --listen-client-urls http://host2:2379 \
+ --advertise-client-urls http://host2:2379 \
+ --listen-peer-urls http://host2:2380 &
+$ etcd \
+ --name m3 \
+ --listen-client-urls http://host3:2379 \
+ --advertise-client-urls http://host3:2379 \
+ --listen-peer-urls http://host3:2380 &
+```
+
+Now the restored etcd cluster should be available and serving the keyspace given by the snapshot.
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/runtime-configuration.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/runtime-configuration.md
new file mode 100644
index 00000000..89e660a4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/runtime-configuration.md
@@ -0,0 +1,173 @@
+# Runtime reconfiguration
+
+etcd comes with support for incremental runtime reconfiguration, which allows users to update the membership of the cluster at run time.
+
+Reconfiguration requests can only be processed when a majority of cluster members are functioning. It is **highly recommended** to always have a cluster size greater than two in production. It is unsafe to remove a member from a two member cluster. The majority of a two member cluster is also two. If there is a failure during the removal process, the cluster might not able to make progress and need to [restart from majority failure][majority failure].
+
+To better understand the design behind runtime reconfiguration, please read [the runtime reconfiguration document][runtime-reconf].
+
+## Reconfiguration use cases
+
+This section will walk through some common reasons for reconfiguring a cluster. Most of these reasons just involve combinations of adding or removing a member, which are explained below under [Cluster Reconfiguration Operations][cluster-reconf].
+
+### Cycle or upgrade multiple machines
+
+If multiple cluster members need to move due to planned maintenance (hardware upgrades, network downtime, etc.), it is recommended to modify members one at a time.
+
+It is safe to remove the leader, however there is a brief period of downtime while the election process takes place. If the cluster holds more than 50MB of v2 data, it is recommended to [migrate the member's data directory][member migration].
+
+### Change the cluster size
+
+Increasing the cluster size can enhance [failure tolerance][fault tolerance table] and provide better read performance. Since clients can read from any member, increasing the number of members increases the overall serialized read throughput.
+
+Decreasing the cluster size can improve the write performance of a cluster, with a trade-off of decreased resilience. Writes into the cluster are replicated to a majority of members of the cluster before considered committed. Decreasing the cluster size lowers the majority, and each write is committed more quickly.
+
+### Replace a failed machine
+
+If a machine fails due to hardware failure, data directory corruption, or some other fatal situation, it should be replaced as soon as possible. Machines that have failed but haven't been removed adversely affect the quorum and reduce the tolerance for an additional failure.
+
+To replace the machine, follow the instructions for [removing the member][remove member] from the cluster, and then [add a new member][add member] in its place. If the cluster holds more than 50MB, it is recommended to [migrate the failed member's data directory][member migration] if it is still accessible.
+
+### Restart cluster from majority failure
+
+If the majority of the cluster is lost or all of the nodes have changed IP addresses, then manual action is necessary to recover safely. The basic steps in the recovery process include [creating a new cluster using the old data][disaster recovery], forcing a single member to act as the leader, and finally using runtime configuration to [add new members][add member] to this new cluster one at a time.
+
+## Cluster reconfiguration operations
+
+With these use cases in mind, the involved operations can be described for each.
+
+Before making any change, a simple majority (quorum) of etcd members must be available. This is essentially the same requirement for any kind of write to etcd.
+
+All changes to the cluster must be done sequentially:
+
+* To update a single member peerURLs, issue an update operation
+* To replace a healthy single member, add a new member then remove the old member
+* To increase from 3 to 5 members, issue two add operations
+* To decrease from 5 to 3, issue two remove operations
+
+All of these examples use the `etcdctl` command line tool that ships with etcd. To change membership without `etcdctl`, use the [v2 HTTP members API][member-api] or the [v3 gRPC members API][member-api-grpc].
+
+### Update a member
+
+#### Update advertise client URLs
+
+To update the advertise client URLs of a member, simply restart that member with updated client urls flag (`--advertise-client-urls`) or environment variable (`ETCD_ADVERTISE_CLIENT_URLS`). The restarted member will self publish the updated URLs. A wrongly updated client URL will not affect the health of the etcd cluster.
+
+#### Update advertise peer URLs
+
+To update the advertise peer URLs of a member, first update it explicitly via member command and then restart the member. The additional action is required since updating peer URLs changes the cluster wide configuration and can affect the health of the etcd cluster.
+
+To update the peer URLs, first find the target member's ID. To list all members with `etcdctl`:
+
+```sh
+$ etcdctl member list
+6e3bd23ae5f1eae0: name=node2 peerURLs=http://localhost:23802 clientURLs=http://127.0.0.1:23792
+924e2e83e93f2560: name=node3 peerURLs=http://localhost:23803 clientURLs=http://127.0.0.1:23793
+a8266ecf031671f3: name=node1 peerURLs=http://localhost:23801 clientURLs=http://127.0.0.1:23791
+```
+
+This example will `update` a8266ecf031671f3 member ID and change its peerURLs value to `http://10.0.1.10:2380`:
+
+```sh
+$ etcdctl member update a8266ecf031671f3 http://10.0.1.10:2380
+Updated member with ID a8266ecf031671f3 in cluster
+```
+
+### Remove a member
+
+Suppose the member ID to remove is a8266ecf031671f3. Use the `remove` command to perform the removal:
+
+```sh
+$ etcdctl member remove a8266ecf031671f3
+Removed member a8266ecf031671f3 from cluster
+```
+
+The target member will stop itself at this point and print out the removal in the log:
+
+```
+etcd: this member has been permanently removed from the cluster. Exiting.
+```
+
+It is safe to remove the leader, however the cluster will be inactive while a new leader is elected. This duration is normally the period of election timeout plus the voting process.
+
+### Add a new member
+
+Adding a member is a two step process:
+
+ * Add the new member to the cluster via the [HTTP members API][member-api], the [gRPC members API][member-api-grpc], or the `etcdctl member add` command.
+ * Start the new member with the new cluster configuration, including a list of the updated members (existing members + the new member).
+
+`etcdctl` adds a new member to the cluster by specifying the member's [name][conf-name] and [advertised peer URLs][conf-adv-peer]:
+
+```sh
+$ etcdctl member add infra3 http://10.0.1.13:2380
+added member 9bf1b35fc7761a23 to cluster
+
+ETCD_NAME="infra3"
+ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380,infra3=http://10.0.1.13:2380"
+ETCD_INITIAL_CLUSTER_STATE=existing
+```
+
+`etcdctl` has informed the cluster about the new member and printed out the environment variables needed to successfully start it. Now start the new etcd process with the relevant flags for the new member:
+
+```sh
+$ export ETCD_NAME="infra3"
+$ export ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380,infra3=http://10.0.1.13:2380"
+$ export ETCD_INITIAL_CLUSTER_STATE=existing
+$ etcd --listen-client-urls http://10.0.1.13:2379 --advertise-client-urls http://10.0.1.13:2379 --listen-peer-urls http://10.0.1.13:2380 --initial-advertise-peer-urls http://10.0.1.13:2380 --data-dir %data_dir%
+```
+
+The new member will run as a part of the cluster and immediately begin catching up with the rest of the cluster.
+
+If adding multiple members the best practice is to configure a single member at a time and verify it starts correctly before adding more new members. If adding a new member to a 1-node cluster, the cluster cannot make progress before the new member starts because it needs two members as majority to agree on the consensus. This behavior only happens between the time `etcdctl member add` informs the cluster about the new member and the new member successfully establishing a connection to the existing one.
+
+#### Error cases when adding members
+
+In the following case a new host is not included in the list of enumerated nodes. If this is a new cluster, the node must be added to the list of initial cluster members.
+
+```sh
+$ etcd --name infra3 \
+ --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
+ --initial-cluster-state existing
+etcdserver: assign ids error: the member count is unequal
+exit 1
+```
+
+In this case, give a different address (10.0.1.14:2380) from the one used to join the cluster (10.0.1.13:2380):
+
+```sh
+$ etcd --name infra4 \
+ --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380,infra4=http://10.0.1.14:2380 \
+ --initial-cluster-state existing
+etcdserver: assign ids error: unmatched member while checking PeerURLs
+exit 1
+```
+
+If etcd starts using the data directory of a removed member, etcd automatically exits if it connects to any active member in the cluster:
+
+```sh
+$ etcd
+etcd: this member has been permanently removed from the cluster. Exiting.
+exit 1
+```
+
+### Strict reconfiguration check mode (`-strict-reconfig-check`)
+
+As described in the above, the best practice of adding new members is to configure a single member at a time and verify it starts correctly before adding more new members. This step by step approach is very important because if newly added members is not configured correctly (for example the peer URLs are incorrect), the cluster can lose quorum. The quorum loss happens since the newly added member are counted in the quorum even if that member is not reachable from other existing members. Also quorum loss might happen if there is a connectivity issue or there are operational issues.
+
+For avoiding this problem, etcd provides an option `-strict-reconfig-check`. If this option is passed to etcd, etcd rejects reconfiguration requests if the number of started members will be less than a quorum of the reconfigured cluster.
+
+It is enabled by default.
+
+[add member]: #add-a-new-member
+[cluster-reconf]: #cluster-reconfiguration-operations
+[conf-adv-peer]: configuration.md#-initial-advertise-peer-urls
+[conf-name]: configuration.md#-name
+[disaster recovery]: recovery.md
+[fault tolerance table]: ../v2/admin_guide.md#fault-tolerance-table
+[majority failure]: #restart-cluster-from-majority-failure
+[member-api]: ../v2/members_api.md
+[member-api-grpc]: ../dev-guide/api_reference_v3.md#service-cluster-etcdserveretcdserverpbrpcproto
+[member migration]: ../v2/admin_guide.md#member-migration
+[remove member]: #remove-a-member
+[runtime-reconf]: runtime-reconf-design.md
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/runtime-reconf-design.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/runtime-reconf-design.md
new file mode 100644
index 00000000..80b01174
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/runtime-reconf-design.md
@@ -0,0 +1,50 @@
+# Design of runtime reconfiguration
+
+Runtime reconfiguration is one of the hardest and most error prone features in a distributed system, especially in a consensus based system like etcd.
+
+Read on to learn about the design of etcd's runtime reconfiguration commands and how we tackled these problems.
+
+## Two phase config changes keep the cluster safe
+
+In etcd, every runtime reconfiguration has to go through [two phases][add-member] for safety reasons. For example, to add a member, first inform cluster of new configuration and then start the new member.
+
+Phase 1 - Inform cluster of new configuration
+
+To add a member into etcd cluster, make an API call to request a new member to be added to the cluster. This is only way to add a new member into an existing cluster. The API call returns when the cluster agrees on the configuration change.
+
+Phase 2 - Start new member
+
+To join the etcd member into the existing cluster, specify the correct `initial-cluster` and set `initial-cluster-state` to `existing`. When the member starts, it will contact the existing cluster first and verify the current cluster configuration matches the expected one specified in `initial-cluster`. When the new member successfully starts, the cluster has reached the expected configuration.
+
+By splitting the process into two discrete phases users are forced to be explicit regarding cluster membership changes. This actually gives users more flexibility and makes things easier to reason about. For example, if there is an attempt to add a new member with the same ID as an existing member in an etcd cluster, the action will fail immediately during phase one without impacting the running cluster. Similar protection is provided to prevent adding new members by mistake. If a new etcd member attempts to join the cluster before the cluster has accepted the configuration change,, it will not be accepted by the cluster.
+
+Without the explicit workflow around cluster membership etcd would be vulnerable to unexpected cluster membership changes. For example, if etcd is running under an init system such as systemd, etcd would be restarted after being removed via the membership API, and attempt to rejoin the cluster on startup. This cycle would continue every time a member is removed via the API and systemd is set to restart etcd after failing, which is unexpected.
+
+We expect runtime reconfiguration to be an infrequent operation. We decided to keep it explicit and user-driven to ensure configuration safety and keep the cluster always running smoothly under explicit control.
+
+## Permanent loss of quorum requires new cluster
+
+If a cluster permanently loses a majority of its members, a new cluster will need to be started from an old data directory to recover the previous state.
+
+It is entirely possible to force removing the failed members from the existing cluster to recover. However, we decided not to support this method since it bypasses the normal consensus committing phase, which is unsafe. If the member to remove is not actually dead or force removed through different members in the same cluster, etcd will end up with a diverged cluster with same clusterID. This is very dangerous and hard to debug/fix afterwards.
+
+With a correct deployment, the possibility of permanent majority lose is very low. But it is a severe enough problem that worth special care. We strongly suggest reading the [disaster recovery documentation][disaster-recovery] and prepare for permanent majority lose before putting etcd into production.
+
+## Do not use public discovery service for runtime reconfiguration
+
+The public discovery service should only be used for bootstrapping a cluster. To join member into an existing cluster, use runtime reconfiguration API.
+
+Discovery service is designed for bootstrapping an etcd cluster in the cloud environment, when the IP addresses of all the members are not known beforehand. After successfully bootstrapping a cluster, the IP addresses of all the members are known. Technically, the discovery service should no longer be needed.
+
+It seems that using public discovery service is a convenient way to do runtime reconfiguration, after all discovery service already has all the cluster configuration information. However relying on public discovery service brings troubles:
+
+1. it introduces external dependencies for the entire life-cycle of the cluster, not just bootstrap time. If there is a network issue between the cluster and public discovery service, the cluster will suffer from it.
+
+2. public discovery service must reflect correct runtime configuration of the cluster during it life-cycle. It has to provide security mechanism to avoid bad actions, and it is hard.
+
+3. public discovery service has to keep tens of thousands of cluster configurations. Our public discovery service backend is not ready for that workload.
+
+To have a discovery service that supports runtime reconfiguration, the best choice is to build a private one.
+
+[add-member]: runtime-configuration.md#add-a-new-member
+[disaster-recovery]: recovery.md
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/security.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/security.md
new file mode 100644
index 00000000..60da143b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/security.md
@@ -0,0 +1,225 @@
+# Security model
+
+etcd supports automatic TLS as well as authentication through client certificates for both clients to server as well as peer (server to server / cluster) communication.
+
+To get up and running, first have a CA certificate and a signed key pair for one member. It is recommended to create and sign a new key pair for every member in a cluster.
+
+For convenience, the [cfssl] tool provides an easy interface to certificate generation, and we provide an example using the tool [here][tls-setup]. Alternatively, try this [guide to generating self-signed key pairs][tls-guide].
+
+## Basic setup
+
+etcd takes several certificate related configuration options, either through command-line flags or environment variables:
+
+**Client-to-server communication:**
+
+`--cert-file=<path>`: Certificate used for SSL/TLS connections **to** etcd. When this option is set, advertise-client-urls can use the HTTPS schema.
+
+`--key-file=<path>`: Key for the certificate. Must be unencrypted.
+
+`--client-cert-auth`: When this is set etcd will check all incoming HTTPS requests for a client certificate signed by the trusted CA, requests that don't supply a valid client certificate will fail. If [authentication][auth] is enabled, the certificate provides credentials for the user name given by the Common Name field.
+
+`--trusted-ca-file=<path>`: Trusted certificate authority.
+
+`--auto-tls`: Use automatically generated self-signed certificates for TLS connections with clients.
+
+**Peer (server-to-server / cluster) communication:**
+
+The peer options work the same way as the client-to-server options:
+
+`--peer-cert-file=<path>`: Certificate used for SSL/TLS connections between peers. This will be used both for listening on the peer address as well as sending requests to other peers.
+
+`--peer-key-file=<path>`: Key for the certificate. Must be unencrypted.
+
+`--peer-client-cert-auth`: When set, etcd will check all incoming peer requests from the cluster for valid client certificates signed by the supplied CA.
+
+`--peer-trusted-ca-file=<path>`: Trusted certificate authority.
+
+`--peer-auto-tls`: Use automatically generated self-signed certificates for TLS connections between peers.
+
+If either a client-to-server or peer certificate is supplied the key must also be set. All of these configuration options are also available through the environment variables, `ETCD_CA_FILE`, `ETCD_PEER_CA_FILE` and so on.
+
+## Example 1: Client-to-server transport security with HTTPS
+
+For this, have a CA certificate (`ca.crt`) and signed key pair (`server.crt`, `server.key`) ready.
+
+Let us configure etcd to provide simple HTTPS transport security step by step:
+
+```sh
+$ etcd --name infra0 --data-dir infra0 \
+ --cert-file=/path/to/server.crt --key-file=/path/to/server.key \
+ --advertise-client-urls=https://127.0.0.1:2379 --listen-client-urls=https://127.0.0.1:2379
+```
+
+This should start up fine and it will be possible to test the configuration by speaking HTTPS to etcd:
+
+```sh
+$ curl --cacert /path/to/ca.crt https://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -v
+```
+
+The command should show that the handshake succeed. Since we use self-signed certificates with our own certificate authority, the CA must be passed to curl using the `--cacert` option. Another possibility would be to add the CA certificate to the system's trusted certificates directory (usually in `/etc/pki/tls/certs` or `/etc/ssl/certs`).
+
+**OSX 10.9+ Users**: curl 7.30.0 on OSX 10.9+ doesn't understand certificates passed in on the command line.
+Instead, import the dummy ca.crt directly into the keychain or add the `-k` flag to curl to ignore errors.
+To test without the `-k` flag, run `open ./fixtures/ca/ca.crt` and follow the prompts.
+Please remove this certificate after testing!
+If there is a workaround, let us know.
+
+## Example 2: Client-to-server authentication with HTTPS client certificates
+
+For now we've given the etcd client the ability to verify the server identity and provide transport security. We can however also use client certificates to prevent unauthorized access to etcd.
+
+The clients will provide their certificates to the server and the server will check whether the cert is signed by the supplied CA and decide whether to serve the request.
+
+The same files mentioned in the first example are needed for this, as well as a key pair for the client (`client.crt`, `client.key`) signed by the same certificate authority.
+
+```sh
+$ etcd --name infra0 --data-dir infra0 \
+ --client-cert-auth --trusted-ca-file=/path/to/ca.crt --cert-file=/path/to/server.crt --key-file=/path/to/server.key \
+ --advertise-client-urls https://127.0.0.1:2379 --listen-client-urls https://127.0.0.1:2379
+```
+
+Now try the same request as above to this server:
+
+```sh
+$ curl --cacert /path/to/ca.crt https://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -v
+```
+
+The request should be rejected by the server:
+
+```
+...
+routines:SSL3_READ_BYTES:sslv3 alert bad certificate
+...
+```
+
+To make it succeed, we need to give the CA signed client certificate to the server:
+
+```sh
+$ curl --cacert /path/to/ca.crt --cert /path/to/client.crt --key /path/to/client.key \
+ -L https://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -v
+```
+
+The output should include:
+
+```
+...
+SSLv3, TLS handshake, CERT verify (15):
+...
+TLS handshake, Finished (20)
+```
+
+And also the response from the server:
+
+```json
+{
+ "action": "set",
+ "node": {
+ "createdIndex": 12,
+ "key": "/foo",
+ "modifiedIndex": 12,
+ "value": "bar"
+ }
+}
+```
+
+## Example 3: Transport security & client certificates in a cluster
+
+etcd supports the same model as above for **peer communication**, that means the communication between etcd members in a cluster.
+
+Assuming we have our `ca.crt` and two members with their own keypairs (`member1.crt` & `member1.key`, `member2.crt` & `member2.key`) signed by this CA, we launch etcd as follows:
+
+
+```sh
+DISCOVERY_URL=... # from https://discovery.etcd.io/new
+
+# member1
+$ etcd --name infra1 --data-dir infra1 \
+ --peer-client-cert-auth --peer-trusted-ca-file=/path/to/ca.crt --peer-cert-file=/path/to/member1.crt --peer-key-file=/path/to/member1.key \
+ --initial-advertise-peer-urls=https://10.0.1.10:2380 --listen-peer-urls=https://10.0.1.10:2380 \
+ --discovery ${DISCOVERY_URL}
+
+# member2
+$ etcd --name infra2 --data-dir infra2 \
+ --peer-client-cert-auth --peer-trusted-ca-file=/path/to/ca.crt --peer-cert-file=/path/to/member2.crt --peer-key-file=/path/to/member2.key \
+ --initial-advertise-peer-urls=https://10.0.1.11:2380 --listen-peer-urls=https://10.0.1.11:2380 \
+ --discovery ${DISCOVERY_URL}
+```
+
+The etcd members will form a cluster and all communication between members in the cluster will be encrypted and authenticated using the client certificates. The output of etcd will show that the addresses it connects to use HTTPS.
+
+## Example 4: Automatic self-signed transport security
+
+For cases where communication encryption, but not authentication, is needed, etcd supports encrypting its messages with automatically generated self-signed certificates. This simplifies deployment because there is no need for managing certificates and keys outside of etcd.
+
+Configure etcd to use self-signed certificates for client and peer connections with the flags `--auto-tls` and `--peer-auto-tls`:
+
+```sh
+DISCOVERY_URL=... # from https://discovery.etcd.io/new
+
+# member1
+$ etcd --name infra1 --data-dir infra1 \
+ --auto-tls --peer-auto-tls \
+ --initial-advertise-peer-urls=https://10.0.1.10:2380 --listen-peer-urls=https://10.0.1.10:2380 \
+ --discovery ${DISCOVERY_URL}
+
+# member2
+$ etcd --name infra2 --data-dir infra2 \
+ --auto-tls --peer-auto-tls \
+ --initial-advertise-peer-urls=https://10.0.1.11:2380 --listen-peer-urls=https://10.0.1.11:2380 \
+ --discovery ${DISCOVERY_URL}
+```
+
+Self-signed certificates do not authenticate identity so curl will return an error:
+
+```sh
+curl: (60) SSL certificate problem: Invalid certificate chain
+```
+
+To disable certificate chain checking, invoke curl with the `-k` flag:
+
+```sh
+$ curl -k https://127.0.0.1:2379/v2/keys/foo -Xput -d value=bar -v
+```
+
+## Notes for etcd proxy
+
+etcd proxy terminates the TLS from its client if the connection is secure, and uses proxy's own key/cert specified in `--peer-key-file` and `--peer-cert-file` to communicate with etcd members.
+
+The proxy communicates with etcd members through both the `--advertise-client-urls` and `--advertise-peer-urls` of a given member. It forwards client requests to etcd members? advertised client urls, and it syncs the initial cluster configuration through etcd members? advertised peer urls.
+
+When client authentication is enabled for an etcd member, the administrator must ensure that the peer certificate specified in the proxy's `--peer-cert-file` option is valid for that authentication. The proxy's peer certificate must also be valid for peer authentication if peer authentication is enabled.
+
+## Frequently asked questions
+
+### I'm seeing a SSLv3 alert handshake failure when using TLS client authentication?
+
+The `crypto/tls` package of `golang` checks the key usage of the certificate public key before using it.
+To use the certificate public key to do client auth, we need to add `clientAuth` to `Extended Key Usage` when creating the certificate public key.
+
+Here is how to do it:
+
+Add the following section to openssl.cnf:
+
+```
+[ ssl_client ]
+...
+ extendedKeyUsage = clientAuth
+...
+```
+
+When creating the cert be sure to reference it in the `-extensions` flag:
+
+```
+$ openssl ca -config openssl.cnf -policy policy_anything -extensions ssl_client -out certs/machine.crt -infiles machine.csr
+```
+
+### With peer certificate authentication I receive "certificate is valid for 127.0.0.1, not $MY_IP"
+Make sure to sign the certificates with a Subject Name the member's public IP address. The `etcd-ca` tool for example provides an `--ip=` option for its `new-cert` command.
+
+The certificate needs to be signed for the member's FQDN in its Subject Name, use Subject Alternative Names (short IP SANs) to add the IP address. The `etcd-ca` tool provides `--domain=` option for its `new-cert` command, and openssl can make [it][alt-name] too.
+
+[cfssl]: https://github.com/cloudflare/cfssl
+[tls-setup]: ../../hack/tls-setup
+[tls-guide]: https://github.com/coreos/docs/blob/master/os/generate-self-signed-certificates.md
+[alt-name]: http://wiki.cacert.org/FAQ/subjectAltName
+[auth]: authentication.md
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/supported-platform.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/supported-platform.md
new file mode 100644
index 00000000..d42418da
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/supported-platform.md
@@ -0,0 +1,40 @@
+## Supported platforms
+
+### Current support
+
+The following table lists etcd support status for common architectures and operating systems,
+
+| Architecture | Operating System | Status | Maintainers |
+| ------------ | ---------------- | ------------ | --------------------------- |
+| amd64 | Darwin | Experimental | etcd maintainers |
+| amd64 | Linux | Stable | etcd maintainers |
+| amd64 | Windows | Experimental | |
+| arm64 | Linux | Experimental | @glevand |
+| arm | Linux | Unstable | |
+| 386 | Linux | Unstable | |
+| ppc64le | Linux | Stable | etcd maintainers, @mkumatag |
+
+* etcd-maintainers are listed in https://github.com/coreos/etcd/blob/master/MAINTAINERS.
+
+Experimental platforms appear to work in practice and have some platform specific code in etcd, but do not fully conform to the stable support policy. Unstable platforms have been lightly tested, but less than experimental. Unlisted architecture and operating system pairs are currently unsupported; caveat emptor.
+
+### Supporting a new platform
+
+For etcd to officially support a new platform as stable, a few requirements are necessary to ensure acceptable quality:
+
+1. An "official" maintainer for the platform with clear motivation; someone must be responsible for taking care of the platform.
+2. Set up CI for build; etcd must compile.
+3. Set up CI for running unit tests; etcd must pass simple tests.
+4. Set up CI (TravisCI, SemaphoreCI or Jenkins) for running integration tests; etcd must pass intensive tests.
+5. (Optional) Set up a functional testing cluster; an etcd cluster should survive stress testing.
+
+### 32-bit and other unsupported systems
+
+etcd has known issues on 32-bit systems due to a bug in the Go runtime. See the [Go issue][go-issue] and [atomic package][go-atomic] for more information.
+
+To avoid inadvertently running a possibly unstable etcd server, `etcd` on unstable or unsupported architectures will print a warning message and immediately exit if the environment variable `ETCD_UNSUPPORTED_ARCH` is not set to the target architecture.
+
+Currently amd64 and ppc64le architectures are officially supported by `etcd`.
+
+[go-issue]: https://github.com/golang/go/issues/599
+[go-atomic]: https://golang.org/pkg/sync/atomic/#pkg-note-BUG
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/v2-migration.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/v2-migration.md
new file mode 100644
index 00000000..c03a41a3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/v2-migration.md
@@ -0,0 +1,53 @@
+# Migrate applications from using API v2 to API v3
+
+The data store v2 is still accessible from the API v2 after upgrading to etcd3. Thus, it will work as before and require no application changes. With etcd 3, applications use the new grpc API v3 to access the mvcc store, which provides more features and improved performance. The mvcc store and the old store v2 are separate and isolated; writes to the store v2 will not affect the mvcc store and, similarly, writes to the mvcc store will not affect the store v2.
+
+Migrating an application from the API v2 to the API v3 involves two steps: 1) migrate the client library and, 2) migrate the data. If the application can rebuild the data, then migrating the data is unnecessary.
+
+## Migrate client library
+
+API v3 is different from API v2, thus application developers need to use a new client library to send requests to etcd API v3. The documentation of the client v3 is available at https://godoc.org/github.com/coreos/etcd/clientv3.
+
+There are some notable differences between API v2 and API v3:
+
+- Transaction: In v3, etcd provides multi-key conditional transactions. Applications should use transactions in place of `Compare-And-Swap` operations.
+
+- Flat key space: There are no directories in API v3, only keys. For example, "/a/b/c/" is a key. Range queries support getting all keys matching a given prefix.
+
+- Compacted responses: Operations like `Delete` no longer return previous values. To get the deleted value, a transaction can be used to atomically get the key and then delete its value.
+
+- Leases: A replacement for v2 TTLs; the TTL is bound to a lease and keys attach to the lease. When the TTL expires, the lease is revoked and all attached keys are removed.
+
+## Migrate data
+
+Application data can be migrated either offline or online. Offline migration is much simpler than online migration and is recommended.
+
+Sometimes an etcd cluster will possibly have v3 data which should not be overwritten. In this case, the migration process may want to confirm no v3 data is committed before proceeding. One way to check the cluster has no v3 keys is to issue the following `etcdctl` command, which scans the entire v3 keyspace for any key, expecting `0` as output:
+
+```sh
+ETCDCTL_API=3 etcdctl get "" --from-key --keys-only --limit 1 | wc -l
+```
+
+### Offline migration
+
+Offline migration is very simple but requires etcd downtime. If an etcd downtime window spanning from seconds to minutes is acceptable, offline migration is a good choice and is easy to automate.
+
+First, all members in the etcd cluster must converge to the same state. This can be achieved by stopping all applications that write keys to etcd. Alternatively, if the applications must remain running, configure etcd to listen on a different client URL and restart all etcd members. To check if the states converged, within a few seconds, use the `ETCDCTL_API=3 etcdctl endpoint status` command to confirm that the `raft index` of all members match (or differ by at most 1 due to an internal sync raft command).
+
+Second, migrate the v2 keys into v3 with the [migrate][migrate_command] (`ETCDCTL_API=3 etcdctl migrate`) command. The migrate command writes keys in the v2 store to a user-provided transformer program and reads back transformed keys. It then writes transformed keys into the mvcc store. This usually takes at most tens of seconds.
+
+Restart the etcd members and everything should just work.
+
+### Online migration
+
+If the application cannot tolerate any downtime, then it must migrate online. The implementation of online migration will vary from application to application but the overall idea is the same.
+
+First, write application code using the v3 API. The application must support two modes: a migration mode and a normal mode. The application starts in migration mode. When running in migration mode, the application reads keys using the v3 API first, and, if it cannot find the key, it retries with the API v2. In normal mode, the application only reads keys using the v3 API. The application writes keys over the API v3 in both modes. To acknowledge a switch from migration mode to normal mode, the application watches on a switch mode key. When switch key?s value turns to `true`, the application switches over from migration mode to normal mode.
+
+Second, start a background job to migrate data from the store v2 to the mvcc store by reading keys from the API v2 and writing keys to the API v3.
+
+After finishing data migration, the background job writes `true` into the switch mode key to notify the application that it may switch modes.
+
+Online migration can be difficult when the application logic depends on store v2 indexes. Applications will need additional logic to convert mvcc store revisions to store v2 indexes.
+
+[migrate_command]: ../../etcdctl/README.md#migrate-options
diff --git a/vendor/github.com/coreos/etcd/Documentation/op-guide/versioning.md b/vendor/github.com/coreos/etcd/Documentation/op-guide/versioning.md
new file mode 100644
index 00000000..90c95a0e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/op-guide/versioning.md
@@ -0,0 +1,17 @@
+## Versioning
+
+### Service versioning
+
+etcd uses [semantic versioning](http://semver.org)
+New minor versions may add additional features to the API.
+
+Get the running etcd cluster version with `etcdctl`:
+
+```sh
+ETCDCTL_API=3 etcdctl --endpoints=127.0.0.1:2379 endpoint status
+```
+
+### API versioning
+
+The `v3` API responses should not change after the 3.0.0 release but new features will be added over time.
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/platforms/aws.md b/vendor/github.com/coreos/etcd/Documentation/platforms/aws.md
new file mode 100644
index 00000000..debb176b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/platforms/aws.md
@@ -0,0 +1,77 @@
+## Introduction
+
+This guide assumes operational knowledge of Amazon Web Services (AWS), specifically Amazon Elastic Compute Cloud (EC2). This guide provides an introduction to design considerations when designing an etcd deployment on AWS EC2 and how AWS specific features may be utilized in that context.
+
+## Capacity planning
+
+As a critical building block for distributed systems it is crucial to perform adequate capacity planning in order to support the intended cluster workload. As a highly available and strongly consistent data store increasing the number of nodes in an etcd cluster will generally affect performance adversely. This makes sense intuitively, as more nodes means more members for the leader to coordinate state across. The most direct way to increase throughput and decrease latency of an etcd cluster is allocate more disk I/O, network I/O, CPU, and memory to cluster members. In the event it is impossible to temporarily divert incoming requests to the cluster, scaling the EC2 instances which comprise the etcd cluster members one at a time may improve performance. It is, however, best to avoid bottlenecks through capacity planning.
+
+The etcd team has produced a [hardware recommendation guide]( ../op-guide/hardware.md) which is very useful for ?ballparking? how many nodes and what instance type are necessary for a cluster.
+
+AWS provides a service for creating groups of EC2 instances which are dynamically sized to match load on the instances. Using an Auto Scaling Group ([ASG](http://docs.aws.amazon.com/autoscaling/latest/userguide/AutoScalingGroup.html)) to dynamically scale an etcd cluster is not recommended for several reasons including:
+
+* etcd performance is generally inversely proportional to the number of members in a cluster due to the synchronous replication which provides strong consistency of data stored in etcd
+* the operational complexity of adding [lifecycle hooks](http://docs.aws.amazon.com/autoscaling/latest/userguide/lifecycle-hooks.html) to properly add and remove members from an etcd cluster by modifying the [runtime configuration](../op-guide/runtime-configuration.md)
+
+Auto Scaling Groups do provide a number of benefits besides cluster scaling which include:
+
+* distribution of EC2 instances across Availability Zones (AZs)
+* EC2 instance fail over across AZs
+* consolidated monitoring and life cycle control of instances within an ASG
+
+The use of an ASG to create a [self healing etcd cluster](#self-healing) is one of the design considerations when deploying an etcd cluster to AWS.
+
+## Cluster design
+
+The purpose of this section is to provide foundational guidance for deploying etcd on AWS. The discussion will be framed by the following three critical design criteria about the etcd cluster itself:
+
+* block device provider: limited to the tradeoffs between EBS or instance storage (InstanceStore)
+* cluster topology: how many nodes should make up an etcd cluster; should these nodes be distributed over multiple AZs
+* managing etcd members: creating a static cluster of EC2 instances or using an ASG.
+
+The intended cluster workload should dictate the cluster design. A configuration store for microservices may require different design considerations than a distributed lock service, a secrets store, or a Kubernetes control plane. Cluster design tradeoffs include considerations such as:
+
+* availability
+* data durability after member failure
+* performance/throughput
+* self healing
+
+### Availability
+
+Instance availability on AWS is ultimately determined by the Amazon EC2 Region Service Level Agreement ([SLA](https://aws.amazon.com/ec2/sla/)) which is the policy by which Amazon describes their precise definition of a regional outage.
+
+In the context of an etcd cluster this means a cluster must contain a minimum of three members where EC2 instances are spread across at least two AZs in order for an etcd cluster to be considered highly available at a Regional level.
+
+For most use cases the additional latency associated with a cluster spanning across Availability Zones will introduce a negligible performance impact.
+
+Availability considerations apply to all components of an application; if the application which accesses the etcd cluster will only be deployed to a single Availability Zone it may not make sense to make the etcd cluster highly available across zones.
+
+### Data durability after member failure
+
+A highly available etcd cluster is resilient to member loss, however, it is important to consider data durability in the event of disaster when designing an etcd deployment. Deploying etcd on AWS supports multiple mechanisms for data durability.
+
+* replication: etcd replicates all data to all members of the etcd cluster. Therefore, given more members in the cluster and more independent failure domains, the less likely that data stored in an etcd cluster will be permanently lost in the event of disaster.
+* Point in time etcd snapshotting: the etcd v3 API introduced support for snapshotting clusters. The operation is cheap enough (completing in the order of minutes) to run quite frequently and the resulting archives can be archived in a storage service like Amazon Simple Storage Service (S3).
+* Amazon Elastic Block Storage (EBS): an EBS volume is a replicated network attached block device which have stronger storage safety guarantees than InstanceStore which has a life cycle associated with the life cycle of the attached EC2 instance. The life cycle of an EBS volume is not necessarily tied to an EC2 instance and can be detached and snapshotted independently which means that a single node etcd cluster backed by an EBS volume can provide a fairly reasonable level of data durability.
+
+### Performance/Throughput
+
+The performance of an etcd cluster is roughly quantifiable through latency and throughput metrics which are primarily affected by disk and network performance. Detailed performance planning information is provided in the [performance section](../op-guide/performance.md) of the etcd operations guide.
+
+#### Network
+
+AWS offers EC2 Placement Groups which allow the collocation of EC2 instances within a single Availability Zone which can be utilized in order to minimize network latency between etcd members in the cluster. It is important to remember that collocation of etcd nodes within a single AZ will provide weaker fault tolerance than distributing members across multiple AZs. [Enhanced networking for EC2 instances](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html) may also improve network performance of individual EC2 instances.
+
+#### Disk
+
+AWS provides two basic types of block storage: [EBS volumes](https://aws.amazon.com/ebs/) and [EC2 Instance Store](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html). As mentioned, an EBS volume is a network attached block device while instance storage is directly attached to the hypervisor of the EC2 host. EBS volumes will generally have higher latency, lower throughput, and greater performance variance than Instance Store volumes. If performance, rather than data safety, is the primary concern it is highly recommended that instance storage on the EC2 instances be utilized. Remember that the amount of available instance storage varies by EC2 [instance types](https://aws.amazon.com/ec2/instance-types/) which may impose additional performance considerations.
+
+Inconsistent EBS volume performance can introduce etcd cluster instability. [Provisioned IOPS](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html#EBSVolumeTypes_piops) can provide more consistent performance than general purpose SSD EBS volumes. More information about EBS volume performance is available [from AWS](https://aws.amazon.com/ebs/details/) and Datadog has shared their experience with [getting optimal performance with AWS EBS Provisioned IOPS](https://www.datadoghq.com/blog/aws-ebs-provisioned-iops-getting-optimal-performance/) in their engineering blog.
+
+### Self healing
+
+While using an ASG to scale the size of an etcd cluster is not recommended, an ASG can be used effectively to maintain the desired number of nodes in the event of node failure. The maintenance of a stable number of etcd nodes will provide the etcd cluster with a measure of self healing.
+
+### Next steps
+
+The operational life cycle of an etcd cluster can be greatly simplified through the use of the etcd-operator. The open source etcd operator is a Kubernetes control plane operator which deploys and manages etcd clusters atop Kubernetes. While still in its early stages the etcd-operator already offers periodic backups to S3, detection and replacement of failed nodes, and automated disaster recovery from backups in the event of permanent quorum loss.
diff --git a/vendor/github.com/coreos/etcd/Documentation/platforms/container-linux-systemd.md b/vendor/github.com/coreos/etcd/Documentation/platforms/container-linux-systemd.md
new file mode 100644
index 00000000..b8234e86
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/platforms/container-linux-systemd.md
@@ -0,0 +1,203 @@
+# Run etcd on Container Linux with systemd
+
+The following guide shows how to run etcd with [systemd][systemd-docs] under [Container Linux][container-linux-docs].
+
+## Provisioning an etcd cluster
+
+Cluster bootstrapping in Container Linux is simplest with [Ignition][container-linux-ignition]; `coreos-metadata.service` dynamically fetches the machine's IP for discovery. Note that etcd's discovery service protocol is only meant for bootstrapping, and cannot be used with runtime reconfiguration or cluster monitoring.
+
+The [Container Linux Config Transpiler][container-linux-ct] compiles etcd configuration files into Ignition configuration files:
+
+```yaml container-linux-config:norender
+etcd:
+ version: 3.2.0
+ name: s1
+ data_dir: /var/lib/etcd
+ advertise_client_urls: http://{PUBLIC_IPV4}:2379
+ initial_advertise_peer_urls: http://{PRIVATE_IPV4}:2380
+ listen_client_urls: http://0.0.0.0:2379
+ listen_peer_urls: http://{PRIVATE_IPV4}:2380
+ discovery: https://discovery.etcd.io/<token>
+```
+
+`ct` would produce the following Ignition Config:
+
+```
+$ ct --platform=gce --in-file /tmp/ct-etcd.cnf
+{"ignition":{"version":"2.0.0","config"...
+```
+
+```json ignition-config
+{
+ "ignition":{"version":"2.0.0","config":{}},
+ "storage":{},
+ "systemd":{
+ "units":[{
+ "name":"etcd-member.service",
+ "enable":true,
+ "dropins":[{
+ "name":"20-clct-etcd-member.conf",
+ "contents":"[Unit]\nRequires=coreos-metadata.service\nAfter=coreos-metadata.service\n\n[Service]\nEnvironmentFile=/run/metadata/coreos\nEnvironment=\"ETCD_IMAGE_TAG=v3.1.8\"\nExecStart=\nExecStart=/usr/lib/coreos/etcd-wrapper $ETCD_OPTS \\\n --name=\"s1\" \\\n --data-dir=\"/var/lib/etcd\" \\\n --listen-peer-urls=\"http://${COREOS_GCE_IP_LOCAL_0}:2380\" \\\n --listen-client-urls=\"http://0.0.0.0:2379\" \\\n --initial-advertise-peer-urls=\"http://${COREOS_GCE_IP_LOCAL_0}:2380\" \\\n --advertise-client-urls=\"http://${COREOS_GCE_IP_EXTERNAL_0}:2379\" \\\n --discovery=\"https://discovery.etcd.io/\u003ctoken\u003e\""}]}]},
+ "networkd":{},
+ "passwd":{}}
+```
+
+To avoid accidental misconfiguration, the transpiler helpfully verifies etcd configurations when generating Ignition files:
+
+```yaml container-linux-config:norender
+etcd:
+ version: 3.2.0
+ name: s1
+ data_dir_x: /var/lib/etcd
+ advertise_client_urls: http://{PUBLIC_IPV4}:2379
+ initial_advertise_peer_urls: http://{PRIVATE_IPV4}:2380
+ listen_client_urls: http://0.0.0.0:2379
+ listen_peer_urls: http://{PRIVATE_IPV4}:2380
+ discovery: https://discovery.etcd.io/<token>
+```
+
+```
+$ ct --platform=gce --in-file /tmp/ct-etcd.cnf
+warning at line 3, column 2
+Config has unrecognized key: data_dir_x
+```
+
+See [Container Linux Provisioning][container-linux-provision] for more details.
+
+## etcd 3.x service
+
+[Container Linux][container-linux-docs] does not include etcd 3.x binaries by default. Different versions of etcd 3.x can be fetched via `etcd-member.service`.
+
+Confirm unit file exists:
+
+```
+systemctl cat etcd-member.service
+```
+
+Check if the etcd service is running:
+
+```
+systemctl status etcd-member.service
+```
+
+Example systemd drop-in unit to override the default service settings:
+
+```bash
+cat > /tmp/20-cl-etcd-member.conf <<EOF
+[Service]
+Environment="ETCD_IMAGE_TAG=v3.2.0"
+Environment="ETCD_DATA_DIR=/var/lib/etcd"
+Environment="ETCD_SSL_DIR=/etc/ssl/certs"
+Environment="ETCD_OPTS=--name s1 \
+ --listen-client-urls https://10.240.0.1:2379 \
+ --advertise-client-urls https://10.240.0.1:2379 \
+ --listen-peer-urls https://10.240.0.1:2380 \
+ --initial-advertise-peer-urls https://10.240.0.1:2380 \
+ --initial-cluster s1=https://10.240.0.1:2380,s2=https://10.240.0.2:2380,s3=https://10.240.0.3:2380 \
+ --initial-cluster-token mytoken \
+ --initial-cluster-state new \
+ --client-cert-auth \
+ --trusted-ca-file /etc/ssl/certs/etcd-root-ca.pem \
+ --cert-file /etc/ssl/certs/s1.pem \
+ --key-file /etc/ssl/certs/s1-key.pem \
+ --peer-client-cert-auth \
+ --peer-trusted-ca-file /etc/ssl/certs/etcd-root-ca.pem \
+ --peer-cert-file /etc/ssl/certs/s1.pem \
+ --peer-key-file /etc/ssl/certs/s1-key.pem \
+ --auto-compaction-retention 1"
+EOF
+mv /tmp/20-cl-etcd-member.conf /etc/systemd/system/etcd-member.service.d/20-cl-etcd-member.conf
+```
+
+Or use a Container Linux Config:
+
+```yaml container-linux-config:norender
+systemd:
+ units:
+ - name: etcd-member.service
+ dropins:
+ - name: conf1.conf
+ contents: |
+ [Service]
+ Environment="ETCD_SSL_DIR=/etc/ssl/certs"
+
+etcd:
+ version: 3.2.0
+ name: s1
+ data_dir: /var/lib/etcd
+ listen_client_urls: https://0.0.0.0:2379
+ advertise_client_urls: https://{PUBLIC_IPV4}:2379
+ listen_peer_urls: https://{PRIVATE_IPV4}:2380
+ initial_advertise_peer_urls: https://{PRIVATE_IPV4}:2380
+ initial_cluster: s1=https://{PRIVATE_IPV4}:2380,s2=https://10.240.0.2:2380,s3=https://10.240.0.3:2380
+ initial_cluster_token: mytoken
+ initial_cluster_state: new
+ client_cert_auth: true
+ trusted_ca_file: /etc/ssl/certs/etcd-root-ca.pem
+ cert-file: /etc/ssl/certs/s1.pem
+ key-file: /etc/ssl/certs/s1-key.pem
+ peer-client-cert-auth: true
+ peer-trusted-ca-file: /etc/ssl/certs/etcd-root-ca.pem
+ peer-cert-file: /etc/ssl/certs/s1.pem
+ peer-key-file: /etc/ssl/certs/s1-key.pem
+ auto-compaction-retention: 1
+```
+
+```
+$ ct --platform=gce --in-file /tmp/ct-etcd.cnf
+{"ignition":{"version":"2.0.0","config"...
+```
+
+To see all runtime drop-in changes for system units:
+
+```
+systemd-delta --type=extended
+```
+
+To enable and start:
+
+```
+systemctl daemon-reload
+systemctl enable --now etcd-member.service
+```
+
+To see the logs:
+
+```
+journalctl --unit etcd-member.service --lines 10
+```
+
+To stop and disable the service:
+
+```
+systemctl disable --now etcd-member.service
+```
+
+## etcd 2.x service
+
+[Container Linux][container-linux-docs] includes a unit file `etcd2.service` for etcd 2.x, which will be removed in the near future. See [Container Linux FAQ][container-linux-faq] for more details.
+
+Confirm unit file is installed:
+
+```
+systemctl cat etcd2.service
+```
+
+Check if the etcd service is running:
+
+```
+systemctl status etcd2.service
+```
+
+To stop and disable:
+
+```
+systemctl disable --now etcd2.service
+```
+
+[systemd-docs]: https://github.com/systemd/systemd
+[container-linux-docs]: https://coreos.com/os/docs/latest
+[container-linux-faq]: https://github.com/coreos/docs/blob/master/etcd/os-faq.md
+[container-linux-provision]: https://github.com/coreos/docs/blob/master/os/provisioning.md
+[container-linux-ignition]: https://github.com/coreos/docs/blob/master/ignition/what-is-ignition.md
+[container-linux-ct]: https://github.com/coreos/container-linux-config-transpiler
diff --git a/vendor/github.com/coreos/etcd/Documentation/platforms/freebsd.md b/vendor/github.com/coreos/etcd/Documentation/platforms/freebsd.md
new file mode 100644
index 00000000..f781a96a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/platforms/freebsd.md
@@ -0,0 +1,48 @@
+# FreeBSD
+
+Starting?with?version?0.1.2?both?etcd?and?etcdctl?have?been?ported?to?FreeBSD?and?can be?installed?either?via?packages?or?ports?system.?Their?versions?have?been?recently updated?to?0.2.0?so?now?etcd and etcdctl can be enjoyed?on?FreeBSD?10.0?(RC4?as of?now)?and?9.x,?where?they?have?been?tested.?They?might?also?work?when?installed?from ports?on?earlier?versions?of?FreeBSD,?but?it is untested; caveat emptor.
+
+## Installation
+
+### Using?pkgng?package?system
+
+1.?If?pkg?ng is not?installed,?install?it?with?command?`pkg`?and?answering?'Y' when?asked.
+
+2.?Update?the repository?data?with?`pkg?update`.
+
+3.?Install?etcd?with?`pkg?install?coreos-etcd?coreos-etcdctl`.
+
+4.?Verify?successful?installation?by confirming `pkg?info?|?grep?etcd`?matches:
+
+```
+r@fbsd?10:/?#?pkg?info?|?grep?etcd
+coreos?etcd?0.2.0??????????????Highly?available?key?value?store and?service?discovery
+coreos?etcdctl?0.2.0???????????Simple?commandline?client?for?etcd
+r@fbsd?10:/?#
+```
+
+5.?etcd?and?etcdctl are ready to use!?For?more?information?about?using?pkgng,?please see:?http://www.freebsd.org/doc/handbook/pkgng?intro.html
+?
+### Using?ports?system
+
+1.?If?ports is not installed,?install?with?`portsnap?fetch?extract`?(it may?take?some?time?depending?on?hardware?and?network?connection).
+
+2.?Build?etcd?with?`cd?/usr/ports/devel/etcd?&&?make?install?clean`. There will be an?option?to?build?and?install?documentation?and?etcdctl?with?it.
+
+3.?If?etcd wasn't?installed?with?etcdctl,?it can be built later with?`cd?/usr/ports/devel/etcdctl?&&?make?install?clean`.
+
+4.?Verify?successful?installation?by confirming `pkg?info?|?grep?etcd`?matches:
+?
+
+```
+r@fbsd?10:/?#?pkg?info?|?grep?etcd
+coreos?etcd?0.2.0??????????????Highly?available?key?value?store and?service?discovery
+coreos?etcdctl?0.2.0???????????Simple?commandline?client?for?etcd
+r@fbsd?10:/?#
+```
+
+5.?etcd?and?etcdctl are ready to use!?For?more?information?about?using?ports?system, please?see:?https://www.freebsd.org/doc/handbook/ports?using.html
+
+## Issues
+
+If?there are any?issues?with?the?build/install?procedure?or?there's a?problem?that is?local?to?FreeBSD?only?(for?example,?by?not?being?able?to reproduce?it on any other?platform,?like OSX or Linux),?please?send a problem?report?using this?page for more information:?http://www.freebsd.org/send?pr.html
diff --git a/vendor/github.com/coreos/etcd/Documentation/production-users.md b/vendor/github.com/coreos/etcd/Documentation/production-users.md
new file mode 100644
index 00000000..a299522d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/production-users.md
@@ -0,0 +1,239 @@
+# Production users
+
+This document tracks people and use cases for etcd in production. By creating a list of production use cases we hope to build a community of advisors that we can reach out to with experience using various etcd applications, operation environments, and cluster sizes. The etcd development team may reach out periodically to check-in on how etcd is working in the field and update this list.
+
+## All Kubernetes Users
+
+- *Application*: https://kubernetes.io/
+- *Environments*: AWS, OpenStack, Azure, Google Cloud, Huawei Cloud, Bare Metal, etc
+
+**This is a meta user; please feel free to document specific Kubernetes clusters!**
+
+All Kubernetes clusters use etcd as their primary data store. This means etcd's users include such companies as [Niantic, Inc Pokemon Go](https://cloudplatform.googleblog.com/2016/09/bringing-Pokemon-GO-to-life-on-Google-Cloud.html), [Box](https://blog.box.com/blog/kubernetes-box-microservices-maximum-velocity/), [CoreOS](https://coreos.com/tectonic), [Ticketmaster](https://www.youtube.com/watch?v=wqXVKneP0Hg), [Salesforce](https://www.salesforce.com) and many many more.
+
+## discovery.etcd.io
+
+- *Application*: https://github.com/coreos/discovery.etcd.io
+- *Launched*: Feb. 2014
+- *Cluster Size*: 5 members, 5 discovery proxies
+- *Order of Data Size*: 100s of Megabytes
+- *Operator*: CoreOS, brandon.philips@coreos.com
+- *Environment*: AWS
+- *Backups*: Periodic async to S3
+
+discovery.etcd.io is the longest continuously running etcd backed service that we know about. It is the basis of automatic cluster bootstrap and was launched in Feb. 2014: https://coreos.com/blog/etcd-0.3.0-released/.
+
+## OpenTable
+
+- *Application*: OpenTable internal service discovery and cluster configuration management
+- *Launched*: May 2014
+- *Cluster Size*: 3 members each in 6 independent clusters; approximately 50 nodes reading / writing
+- *Order of Data Size*: 10s of MB
+- *Operator*: OpenTable, Inc; sschlansker@opentable.com
+- *Environment*: AWS, VMWare
+- *Backups*: None, all data can be re-created if necessary.
+
+## cycoresys.com
+
+- *Application*: multiple
+- *Launched*: Jul. 2014
+- *Cluster Size*: 3 members, _n_ proxies
+- *Order of Data Size*: 100s of kilobytes
+- *Operator*: CyCore Systems, Inc, sys@cycoresys.com
+- *Environment*: Baremetal
+- *Backups*: Periodic sync to Ceph RadosGW and DigitalOcean VM
+
+CyCore Systems provides architecture and engineering for computing systems. This cluster provides microservices, virtual machines, databases, storage clusters to a number of clients. It is built on CoreOS machines, with each machine in the cluster running etcd as a peer or proxy.
+
+## Radius Intelligence
+
+- *Application*: multiple internal tools, Kubernetes clusters, bootstrappable system configs
+- *Launched*: June 2015
+- *Cluster Size*: 2 clusters of 5 and 3 members; approximately a dozen nodes read/write
+- *Order of Data Size*: 100s of kilobytes
+- *Operator*: Radius Intelligence; jcderr@radius.com
+- *Environment*: AWS, CoreOS, Kubernetes
+- *Backups*: None, all data can be recreated if necessary.
+
+Radius Intelligence uses Kubernetes running CoreOS to containerize and scale internal toolsets. Examples include running [JetBrains TeamCity][teamcity] and internal AWS security and cost reporting tools. etcd clusters back these clusters as well as provide some basic environment bootstrapping configuration keys.
+
+## Vonage
+
+- *Application*: kubernetes, vault backend, system configuration for microservices, scheduling, locks (future - service discovery)
+- *Launched*: August 2015
+- *Cluster Size*: 2 clusters of 5 members in 2 DCs, n local proxies 1-to-1 with microservice, (ssl and SRV look up)
+- *Order of Data Size*: kilobytes
+- *Operator*: Vonage [devAdmin][raoofm]
+- *Environment*: VMWare, AWS
+- *Backups*: Daily snapshots on VMs. Backups done for upgrades.
+
+## PD
+
+- *Application*: embed etcd
+- *Launched*: Mar 2016
+- *Cluster Size*: 3 or 5 members
+- *Order of Data Size*: megabytes
+- *Operator*: PingCAP, Inc.
+- *Environment*: Bare Metal, AWS, etc.
+- *Backups*: None.
+
+PD(Placement Driver) is the central controller in the TiDB cluster. It saves the cluster meta information, schedule the data, allocate the global unique timestamp for the distributed transaction, etc. It embeds etcd to supply high availability and auto failover.
+
+## Canal
+
+- *Application*: system configuration for overlay network
+- *Launched*: June 2016
+- *Cluster Size*: 3 members for each cluster
+- *Order of Data Size*: kilobytes
+- *Operator*: Huawei Euler Department
+- *Environment*: [Huawei Cloud](http://www.hwclouds.com/product/cce.html)
+- *Backups*: None, all data can be recreated if necessary.
+
+[teamcity]: https://www.jetbrains.com/teamcity/
+[raoofm]:https://github.com/raoofm
+
+## Qiniu Cloud
+
+- *Application*: system configuration for microservices, distributed locks
+- *Launched*: Jan. 2016
+- *Cluster Size*: 3 members each with several clusters
+- *Order of Data Size*: kilobytes
+- *Operator*: Pandora, chenchao@qiniu.com
+- *Environment*: Baremetal
+- *Backups*: None, all data can be recreated if necessary
+
+## QingCloud
+
+- *Application*: [QingCloud][qingcloud] appcenter cluster for service discovery as [metad][metad] backend.
+- *Launched*: December 2016
+- *Cluster Size*: 1 cluster of 3 members per user.
+- *Order of Data Size*: kilobytes
+- *Operator*: [yunify][yunify]
+- *Environment*: QingCloud IaaS
+- *Backups*: None, all data can be recreated if necessary.
+
+[metad]:https://github.com/yunify/metad
+[yunify]:https://github.com/yunify
+[qingcloud]:https://qingcloud.com/
+
+
+## Yandex
+
+- *Application*: system configuration for services, service discovery
+- *Launched*: March 2016
+- *Cluster Size*: 3 clusters of 5 members
+- *Order of Data Size*: several gigabytes
+- *Operator*: Yandex; [nekto0n][nekto0n]
+- *Environment*: Bare Metal
+- *Backups*: None
+
+[nekto0n]:https://github.com/nekto0n
+
+## Tencent Games
+
+- *Application*: Meta data and configuration data for service discovery, Kubernetes, etc.
+- *Launched*: Jan. 2015
+- *Cluster Size*: 3 members each with 10s of clusters
+- *Order of Data Size*: 10s of Megabytes
+- *Operator*: Tencent Game Operations Department
+- *Environment*: Baremetal
+- *Backups*: Periodic sync to backup server
+
+In Tencent games, we use Docker and Kubernetes to deploy and run our applications, and use etcd to save meta data for service discovery, Kubernetes, etc.
+
+## Hyper.sh
+
+- *Application*: Kubernetes, distributed locks, etc.
+- *Launched*: April 2016
+- *Cluster Size*: 1 cluster of 3 members
+- *Order of Data Size*: 10s of MB
+- *Operator*: Hyper.sh
+- *Environment*: Baremetal
+- *Backups*: None, all data can be recreated if necessary.
+
+In [hyper.sh][hyper.sh], the container service is backed by [hypernetes][hypernetes], a multi-tenant kubernetes distro. Moreover, we use etcd to coordinate the multiple manage services and store global meta data.
+
+[hypernetes]:https://github.com/hyperhq/hypernetes
+[Hyper.sh]:https://www.hyper.sh
+
+## Meitu
+- *Application*: system configuration for services, service discovery, kubernetes in test environment
+- *Launched*: October 2015
+- *Cluster Size*: 1 cluster of 3 members
+- *Order of Data Size*: megabytes
+- *Operator*: Meitu, hxj@meitu.com, [shafreeck][shafreeck]
+- *Environment*: Bare Metal
+- *Backups*: None, all data can be recreated if necessary.
+
+[shafreeck]:https://github.com/shafreeck
+
+## Grab
+- *Application*: system configuration for services, service discovery
+- *Launched*: June 2016
+- *Cluster Size*: 1 cluster of 7 members
+- *Order of Data Size*: megabytes
+- *Operator*: Grab, [taxitan][taxitan], [reterVision][reterVision]
+- *Environment*: AWS
+- *Backups*: None, all data can be recreated if necessary.
+
+[taxitan]:https://github.com/taxitan
+[reterVision]:https://github.com/reterVision
+
+## DaoCloud.io
+
+- *Application*: container management
+- *Launched*: Sep. 2015
+- *Cluster Size*: 1000+ deployments, each deployment contains a 3 node cluster.
+- *Order of Data Size*: 100s of Megabytes
+- *Operator*: daocloud.io
+- *Environment*: Baremetal and virtual machines
+- *Backups*: None, all data can be recreated if necessary.
+
+In [DaoCloud][DaoCloud], we use Docker and Swarm to deploy and run our applications, and we use etcd to save metadata for service discovery.
+
+[DaoCloud]:https://www.daocloud.io
+
+## Branch.io
+
+- *Application*: Kubernetes
+- *Launched*: April 2016
+- *Cluster Size*: Multiple clusters, multiple sizes
+- *Order of Data Size*: 100s of Megabytes
+- *Operator*: branch.io
+- *Environment*: AWS, Kubernetes
+- *Backups*: EBS volume backups
+
+At [Branch][branch], we use kubernetes heavily as our core microservice platform for staging and production.
+
+[branch]: https://branch.io
+
+## Baidu Waimai
+
+- *Application*: SkyDNS, Kubernetes, UDC, CMDB and other distributed systems
+- *Launched*: April. 2016
+- *Cluster Size*: 3 clusters of 5 members
+- *Order of Data Size*: several gigabytes
+- *Operator*: Baidu Waimai Operations Department
+- *Environment*: CentOS 6.5
+- *Backups*: backup scripts
+
+## Salesforce.com
+
+- *Application*: Kubernetes
+- *Launched*: Jan 2017
+- *Cluster Size*: Multiple clusters of 3 members
+- *Order of Data Size*: 100s of Megabytes
+- *Operator*: Salesforce.com (krmayankk@github)
+- *Environment*: BareMetal
+- *Backups*: None, all data can be recreated
+
+## Hosted Graphite
+
+- *Application*: Service discovery, locking, ephemeral application data
+- *Launched*: January 2017
+- *Cluster Size*: 2 clusters of 7 members
+- *Order of Data Size*: Megabytes
+- *Operator*: Hosted Graphite (sre@hostedgraphite.com)
+- *Environment*: Bare Metal
+- *Backups*: None, all data is considered ephemeral.
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/reporting_bugs.md b/vendor/github.com/coreos/etcd/Documentation/reporting_bugs.md
new file mode 100644
index 00000000..d9284368
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/reporting_bugs.md
@@ -0,0 +1,45 @@
+# Reporting bugs
+
+If any part of the etcd project has bugs or documentation mistakes, please let us know by [opening an issue][etcd-issue]. We treat bugs and mistakes very seriously and believe no issue is too small. Before creating a bug report, please check that an issue reporting the same problem does not already exist.
+
+To make the bug report accurate and easy to understand, please try to create bug reports that are:
+
+- Specific. Include as much details as possible: which version, what environment, what configuration, etc. If the bug is related to running the etcd server, please attach the etcd log (the starting log with etcd configuration is especially important).
+
+- Reproducible. Include the steps to reproduce the problem. We understand some issues might be hard to reproduce, please includes the steps that might lead to the problem. If possible, please attach the affected etcd data dir and stack strace to the bug report.
+
+- Isolated. Please try to isolate and reproduce the bug with minimum dependencies. It would significantly slow down the speed to fix a bug if too many dependencies are involved in a bug report. Debugging external systems that rely on etcd is out of scope, but we are happy to provide guidance in the right direction or help with using etcd itself.
+
+- Unique. Do not duplicate existing bug report.
+
+- Scoped. One bug per report. Do not follow up with another bug inside one report.
+
+It may be worthwhile to read [Elika Etemad?s article on filing good bug reports][filing-good-bugs] before creating a bug report.
+
+We might ask for further information to locate a bug. A duplicated bug report will be closed.
+
+## Frequently asked questions
+
+### How to get a stack trace
+
+``` bash
+$ kill -QUIT $PID
+```
+
+### How to get etcd version
+
+``` bash
+$ etcd --version
+```
+
+### How to get etcd configuration and log when it runs as systemd service ?etcd2.service?
+
+``` bash
+$ sudo systemctl cat etcd2
+$ sudo journalctl -u etcd2
+```
+
+Due to an upstream systemd bug, journald may miss the last few log lines when its processes exit. If journalctl says etcd stopped without fatal or panic message, try `sudo journalctl -f -t etcd2` to get full log.
+
+[etcd-issue]: https://github.com/coreos/etcd/issues/new
+[filing-good-bugs]: http://fantasai.inkedblade.net/style/talks/filing-good-bugs/
diff --git a/vendor/github.com/coreos/etcd/Documentation/rfc/v3api.md b/vendor/github.com/coreos/etcd/Documentation/rfc/v3api.md
new file mode 100644
index 00000000..1371347e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/rfc/v3api.md
@@ -0,0 +1,211 @@
+# Overview
+
+The etcd v3 API is designed to give users a more efficient and cleaner abstraction compared to etcd v2. There are a number of semantic and protocol changes in this new API. For an overview [see Xiang Li's video](https://youtu.be/J5AioGtEPeQ?t=211).
+
+To prove out the design of the v3 API the team has also built [a number of example recipes](https://github.com/coreos/etcd/tree/master/contrib/recipes), there is a [video discussing these recipes too](https://www.youtube.com/watch?v=fj-2RY-3yVU&feature=youtu.be&t=590).
+
+# Design
+
+1. Flatten binary key-value space
+
+2. Keep the event history until compaction
+ - access to old version of keys
+ - user controlled history compaction
+
+3. Support range query
+ - Pagination support with limit argument
+ - Support consistency guarantee across multiple range queries
+
+4. Replace TTL key with Lease
+ - more efficient/ low cost keep alive
+ - a logical group of TTL keys
+
+5. Replace CAS/CAD with multi-object Txn
+ - MUCH MORE powerful and flexible
+
+6. Support efficient watching with multiple ranges
+
+7. RPC API supports the completed set of APIs.
+ - more efficient than JSON/HTTP
+ - additional txn/lease support
+
+8. HTTP API supports a subset of APIs.
+ - easy for people to try out etcd
+ - easy for people to write simple etcd application
+
+
+## Notes
+
+### Request Size Limitation
+
+The max request size is around 1MB. Since etcd replicates requests in a streaming fashion, a very large
+request might block other requests for a long time. The use case for etcd is to store small configuration
+values, so we prevent user from submitting large requests. This also applies to Txn requests. We might loosen
+the size in the future a little bit or make it configurable.
+
+## Protobuf Defined API
+
+[api protobuf][api-protobuf]
+
+[kv protobuf][kv-protobuf]
+
+## Examples
+
+### Put a key (foo=bar)
+```
+// A put is always successful
+Put( PutRequest { key = foo, value = bar } )
+
+PutResponse {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 1,
+ raft_term = 0x1,
+}
+```
+
+### Get a key (assume we have foo=bar)
+```
+Get ( RangeRequest { key = foo } )
+
+RangeResponse {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 1,
+ raft_term = 0x1,
+ kvs = {
+ {
+ key = foo,
+ value = bar,
+ create_revision = 1,
+ mod_revision = 1,
+ version = 1;
+ },
+ },
+}
+```
+
+### Range over a key space (assume we have foo0=bar0? foo100=bar100)
+```
+Range ( RangeRequest { key = foo, end_key = foo80, limit = 30 } )
+
+RangeResponse {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 100,
+ raft_term = 0x1,
+ kvs = {
+ {
+ key = foo0,
+ value = bar0,
+ create_revision = 1,
+ mod_revision = 1,
+ version = 1;
+ },
+ ...,
+ {
+ key = foo30,
+ value = bar30,
+ create_revision = 30,
+ mod_revision = 30,
+ version = 1;
+ },
+ },
+}
+```
+
+### Finish a txn (assume we have foo0=bar0, foo1=bar1)
+```
+Txn(TxnRequest {
+ // mod_revision of foo0 is equal to 1, mod_revision of foo1 is greater than 1
+ compare = {
+ {compareType = equal, key = foo0, mod_revision = 1},
+ {compareType = greater, key = foo1, mod_revision = 1}}
+ },
+ // if the comparison succeeds, put foo2 = bar2
+ success = {PutRequest { key = foo2, value = success }},
+ // if the comparison fails, put foo2=fail
+ failure = {PutRequest { key = foo2, value = failure }},
+)
+
+TxnResponse {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 3,
+ raft_term = 0x1,
+ succeeded = true,
+ responses = {
+ // response of PUT foo2=success
+ {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 3,
+ raft_term = 0x1,
+ }
+ }
+}
+```
+
+### Watch on a key/range
+
+```
+Watch( WatchRequest{
+ key = foo,
+ end_key = fop, // prefix foo
+ start_revision = 20,
+ end_revision = 10000,
+ // server decided notification frequency
+ progress_notification = true,
+ }
+ ? // this can be a watch request stream
+ )
+
+// put (foo0=bar0) event at 3
+WatchResponse {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 3,
+ raft_term = 0x1,
+ event_type = put,
+ kv = {
+ key = foo0,
+ value = bar0,
+ create_revision = 1,
+ mod_revision = 1,
+ version = 1;
+ },
+ }
+ ?
+
+ // a notification at 2000
+ WatchResponse {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 2000,
+ raft_term = 0x1,
+ // nil event as notification
+ }
+
+ ?
+
+ // put (foo0=bar3000) event at 3000
+ WatchResponse {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 3000,
+ raft_term = 0x1,
+ event_type = put,
+ kv = {
+ key = foo0,
+ value = bar3000,
+ create_revision = 1,
+ mod_revision = 3000,
+ version = 2;
+ },
+ }
+ ?
+
+```
+
+[api-protobuf]: https://github.com/coreos/etcd/blob/master/etcdserver/etcdserverpb/rpc.proto
+[kv-protobuf]: https://github.com/coreos/etcd/blob/master/mvcc/mvccpb/kv.proto
diff --git a/vendor/github.com/coreos/etcd/Documentation/tuning.md b/vendor/github.com/coreos/etcd/Documentation/tuning.md
new file mode 100644
index 00000000..087d39d1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/tuning.md
@@ -0,0 +1,82 @@
+# Tuning
+
+The default settings in etcd should work well for installations on a local network where the average network latency is low. However, when using etcd across multiple data centers or over networks with high latency, the heartbeat interval and election timeout settings may need tuning.
+
+The network isn't the only source of latency. Each request and response may be impacted by slow disks on both the leader and follower. Each of these timeouts represents the total time from request to successful response from the other machine.
+
+## Time parameters
+
+The underlying distributed consensus protocol relies on two separate time parameters to ensure that nodes can handoff leadership if one stalls or goes offline. The first parameter is called the *Heartbeat Interval*. This is the frequency with which the leader will notify followers that it is still the leader.
+For best practices, the parameter should be set around round-trip time between members. By default, etcd uses a `100ms` heartbeat interval.
+
+The second parameter is the *Election Timeout*. This timeout is how long a follower node will go without hearing a heartbeat before attempting to become leader itself. By default, etcd uses a `1000ms` election timeout.
+
+Adjusting these values is a trade off. The value of heartbeat interval is recommended to be around the maximum of average round-trip time (RTT) between members, normally around 0.5-1.5x the round-trip time. If heartbeat interval is too low, etcd will send unnecessary messages that increase the usage of CPU and network resources. On the other side, a too high heartbeat interval leads to high election timeout. Higher election timeout takes longer time to detect a leader failure. The easiest way to measure round-trip time (RTT) is to use [PING utility][ping].
+
+The election timeout should be set based on the heartbeat interval and average round-trip time between members. Election timeouts must be at least 10 times the round-trip time so it can account for variance in the network. For example, if the round-trip time between members is 10ms then the election timeout should be at least 100ms.
+
+The upper limit of election timeout is 50000ms (50s), which should only be used when deploying a globally-distributed etcd cluster. A reasonable round-trip time for the continental United States is 130ms, and the time between US and Japan is around 350-400ms. If the network has uneven performance or regular packet delays/loss then it is possible that a couple of retries may be necessary to successfully send a packet. So 5s is a safe upper limit of global round-trip time. As the election timeout should be an order of magnitude bigger than broadcast time, in the case of ~5s for a globally distributed cluster, then 50 seconds becomes a reasonable maximum.
+
+The heartbeat interval and election timeout value should be the same for all members in one cluster. Setting different values for etcd members may disrupt cluster stability.
+
+The default values can be overridden on the command line:
+
+```sh
+# Command line arguments:
+$ etcd --heartbeat-interval=100 --election-timeout=500
+
+# Environment variables:
+$ ETCD_HEARTBEAT_INTERVAL=100 ETCD_ELECTION_TIMEOUT=500 etcd
+```
+
+The values are specified in milliseconds.
+
+## Snapshots
+
+etcd appends all key changes to a log file. This log grows forever and is a complete linear history of every change made to the keys. A complete history works well for lightly used clusters but clusters that are heavily used would carry around a large log.
+
+To avoid having a huge log etcd makes periodic snapshots. These snapshots provide a way for etcd to compact the log by saving the current state of the system and removing old logs.
+
+### Snapshot tuning
+
+Creating snapshots with the V2 backend can be expensive, so snapshots are only created after a given number of changes to etcd. By default, snapshots will be made after every 10,000 changes. If etcd's memory usage and disk usage are too high, try lowering the snapshot threshold by setting the following on the command line:
+
+```sh
+# Command line arguments:
+$ etcd --snapshot-count=5000
+
+# Environment variables:
+$ ETCD_SNAPSHOT_COUNT=5000 etcd
+```
+
+## Disk
+
+An etcd cluster is very sensitive to disk latencies. Since etcd must persist proposals to its log, disk activity from other processes may cause long `fsync` latencies. The upshot is etcd may miss heartbeats, causing request timeouts and temporary leader loss. An etcd server can sometimes stably run alongside these processes when given a high disk priority.
+
+On Linux, etcd's disk priority can be configured with `ionice`:
+
+```sh
+# best effort, highest priority
+$ sudo ionice -c2 -n0 -p `pgrep etcd`
+```
+
+## Network
+
+If the etcd leader serves a large number of concurrent client requests, it may delay processing follower peer requests due to network congestion. This manifests as send buffer error messages on the follower nodes:
+
+```
+dropped MsgProp to 247ae21ff9436b2d since streamMsg's sending buffer is full
+dropped MsgAppResp to 247ae21ff9436b2d since streamMsg's sending buffer is full
+```
+
+These errors may be resolved by prioritizing etcd's peer traffic over its client traffic. On Linux, peer traffic can be prioritized by using the traffic control mechanism:
+
+```
+tc qdisc add dev eth0 root handle 1: prio bands 3
+tc filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip sport 2380 0xffff flowid 1:1
+tc filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip dport 2380 0xffff flowid 1:1
+tc filter add dev eth0 parent 1: protocol ip prio 2 u32 match ip sport 2739 0xffff flowid 1:1
+tc filter add dev eth0 parent 1: protocol ip prio 2 u32 match ip dport 2739 0xffff flowid 1:1
+```
+
+[ping]: https://en.wikipedia.org/wiki/Ping_(networking_utility)
diff --git a/vendor/github.com/coreos/etcd/Documentation/upgrades/upgrade_3_0.md b/vendor/github.com/coreos/etcd/Documentation/upgrades/upgrade_3_0.md
new file mode 100644
index 00000000..57c11791
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/upgrades/upgrade_3_0.md
@@ -0,0 +1,129 @@
+## Upgrade etcd from 2.3 to 3.0
+
+In the general case, upgrading from etcd 2.3 to 3.0 can be a zero-downtime, rolling upgrade:
+ - one by one, stop the etcd v2.3 processes and replace them with etcd v3.0 processes
+ - after running all v3.0 processes, new features in v3.0 are available to the cluster
+
+Before [starting an upgrade](#upgrade-procedure), read through the rest of this guide to prepare.
+
+### Upgrade checklists
+
+#### Upgrade requirements
+
+To upgrade an existing etcd deployment to 3.0, the running cluster must be 2.3 or greater. If it's before 2.3, please upgrade to [2.3](https://github.com/coreos/etcd/releases/tag/v2.3.8) before upgrading to 3.0.
+
+Also, to ensure a smooth rolling upgrade, the running cluster must be healthy. Check the health of the cluster by using the `etcdctl cluster-health` command before proceeding.
+
+#### Preparation
+
+Before upgrading etcd, always test the services relying on etcd in a staging environment before deploying the upgrade to the production environment.
+
+Before beginning, [backup the etcd data directory](../v2/admin_guide.md#backing-up-the-datastore). Should something go wrong with the upgrade, it is possible to use this backup to [downgrade](#downgrade) back to existing etcd version.
+
+#### Mixed versions
+
+While upgrading, an etcd cluster supports mixed versions of etcd members, and operates with the protocol of the lowest common version. The cluster is only considered upgraded once all of its members are upgraded to version 3.0. Internally, etcd members negotiate with each other to determine the overall cluster version, which controls the reported version and the supported features.
+
+#### Limitations
+
+It might take up to 2 minutes for the newly upgraded member to catch up with the existing cluster when the total data size is larger than 50MB. Check the size of a recent snapshot to estimate the total data size. In other words, it is safest to wait for 2 minutes between upgrading each member.
+
+For a much larger total data size, 100MB or more , this one-time process might take even more time. Administrators of very large etcd clusters of this magnitude can feel free to contact the [etcd team][etcd-contact] before upgrading, and we?ll be happy to provide advice on the procedure.
+
+#### Downgrade
+
+If all members have been upgraded to v3.0, the cluster will be upgraded to v3.0, and downgrade from this completed state is **not possible**. If any single member is still v2.3, however, the cluster and its operations remains ?v2.3?, and it is possible from this mixed cluster state to return to using a v2.3 etcd binary on all members.
+
+Please [backup the data directory](../v2/admin_guide.md#backing-up-the-datastore) of all etcd members to make downgrading the cluster possible even after it has been completely upgraded.
+
+### Upgrade procedure
+
+This example details the upgrade of a three-member v2.3 ectd cluster running on a local machine.
+
+#### 1. Check upgrade requirements.
+
+Is the cluster healthy and running v.2.3.x?
+
+```
+$ etcdctl cluster-health
+member 6e3bd23ae5f1eae0 is healthy: got healthy result from http://localhost:22379
+member 924e2e83e93f2560 is healthy: got healthy result from http://localhost:32379
+member 8211f1d0f64f3269 is healthy: got healthy result from http://localhost:12379
+cluster is healthy
+
+$ curl http://localhost:2379/version
+{"etcdserver":"2.3.x","etcdcluster":"2.3.8"}
+```
+
+#### 2. Stop the existing etcd process
+
+When each etcd process is stopped, expected errors will be logged by other cluster members. This is normal since a cluster member connection has been (temporarily) broken:
+
+```
+2016-06-27 15:21:48.624124 E | rafthttp: failed to dial 8211f1d0f64f3269 on stream Message (dial tcp 127.0.0.1:12380: getsockopt: connection refused)
+2016-06-27 15:21:48.624175 I | rafthttp: the connection with 8211f1d0f64f3269 became inactive
+```
+
+It?s a good idea at this point to [backup the etcd data directory](../v2/admin_guide.md#backing-up-the-datastore) to provide a downgrade path should any problems occur:
+
+```
+$ etcdctl backup \
+ --data-dir /var/lib/etcd \
+ --backup-dir /tmp/etcd_backup
+```
+
+#### 3. Drop-in etcd v3.0 binary and start the new etcd process
+
+The new v3.0 etcd will publish its information to the cluster:
+
+```
+09:58:25.938673 I | etcdserver: published {Name:infra1 ClientURLs:[http://localhost:12379]} to cluster 524400597fb1d5f6
+```
+
+Verify that each member, and then the entire cluster, becomes healthy with the new v3.0 etcd binary:
+
+```
+$ etcdctl cluster-health
+member 6e3bd23ae5f1eae0 is healthy: got healthy result from http://localhost:22379
+member 924e2e83e93f2560 is healthy: got healthy result from http://localhost:32379
+member 8211f1d0f64f3269 is healthy: got healthy result from http://localhost:12379
+cluster is healthy
+```
+
+
+Upgraded members will log warnings like the following until the entire cluster is upgraded. This is expected and will cease after all etcd cluster members are upgraded to v3.0:
+
+```
+2016-06-27 15:22:05.679644 W | etcdserver: the local etcd version 2.3.7 is not up-to-date
+2016-06-27 15:22:05.679660 W | etcdserver: member 8211f1d0f64f3269 has a higher version 3.0.0
+```
+
+#### 4. Repeat step 2 to step 3 for all other members
+
+#### 5. Finish
+
+When all members are upgraded, the cluster will report upgrading to 3.0 successfully:
+
+```
+2016-06-27 15:22:19.873751 N | membership: updated the cluster version from 2.3 to 3.0
+2016-06-27 15:22:19.914574 I | api: enabled capabilities for version 3.0.0
+```
+
+```
+$ ETCDCTL_API=3 etcdctl endpoint health
+127.0.0.1:12379 is healthy: successfully committed proposal: took = 18.440155ms
+127.0.0.1:32379 is healthy: successfully committed proposal: took = 13.651368ms
+127.0.0.1:22379 is healthy: successfully committed proposal: took = 18.513301ms
+```
+
+## Further considerations
+
+- etcdctl environment variables have been updated. If `ETCDCTL_API=2 etcdctl cluster-health` works properly but `ETCDCTL_API=3 etcdctl endpoints health` responds with `Error: grpc: timed out when dialing`, be sure to use the [new variable names](https://github.com/coreos/etcd/tree/master/etcdctl#etcdctl).
+
+## Known Issues
+
+- etcd < v3.1 does not work properly if built with Go > v1.7. See [Issue 6951](https://github.com/coreos/etcd/issues/6951) for additional information.
+- If an error such as `transport: http2Client.notifyError got notified that the client transport was broken unexpected EOF.` shows up in the etcd server logs, be sure etcd is a pre-built release or built with (etcd v3.1+ & go v1.7+) or (etcd <v3.1 & go v1.6.x).
+- Adding a v3 node to v2.3 cluster during upgrades is not supported and could trigger panics. See [Issue 7249](https://github.com/coreos/etcd/issues/7429) for additional information. Mixed versions of etcd members are only allowed during v3 migration. Finish upgrades before making any membership changes.
+
+[etcd-contact]: https://groups.google.com/forum/#!forum/etcd-dev
diff --git a/vendor/github.com/coreos/etcd/Documentation/upgrades/upgrade_3_1.md b/vendor/github.com/coreos/etcd/Documentation/upgrades/upgrade_3_1.md
new file mode 100644
index 00000000..7eabd9ab
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/upgrades/upgrade_3_1.md
@@ -0,0 +1,123 @@
+## Upgrade etcd from 3.0 to 3.1
+
+In the general case, upgrading from etcd 3.0 to 3.1 can be a zero-downtime, rolling upgrade:
+ - one by one, stop the etcd v3.0 processes and replace them with etcd v3.1 processes
+ - after running all v3.1 processes, new features in v3.1 are available to the cluster
+
+Before [starting an upgrade](#upgrade-procedure), read through the rest of this guide to prepare.
+
+### Upgrade checklists
+
+#### Upgrade requirements
+
+To upgrade an existing etcd deployment to 3.1, the running cluster must be 3.0 or greater. If it's before 3.0, please [upgrade to 3.0](upgrade_3_0.md) before upgrading to 3.1.
+
+Also, to ensure a smooth rolling upgrade, the running cluster must be healthy. Check the health of the cluster by using the `etcdctl endpoint health` command before proceeding.
+
+#### Preparation
+
+Before upgrading etcd, always test the services relying on etcd in a staging environment before deploying the upgrade to the production environment.
+
+Before beginning, [backup the etcd data](../op-guide/maintenance.md#snapshot-backup). Should something go wrong with the upgrade, it is possible to use this backup to [downgrade](#downgrade) back to existing etcd version. Please note that the `snapshot` command only backs up the v3 data. For v2 data, see [backing up v2 datastore](../v2/admin_guide.md#backing-up-the-datastore).
+
+#### Mixed versions
+
+While upgrading, an etcd cluster supports mixed versions of etcd members, and operates with the protocol of the lowest common version. The cluster is only considered upgraded once all of its members are upgraded to version 3.1. Internally, etcd members negotiate with each other to determine the overall cluster version, which controls the reported version and the supported features.
+
+#### Limitations
+
+Note: If the cluster only has v3 data and no v2 data, it is not subject to this limitation.
+
+If the cluster is serving a v2 data set larger than 50MB, each newly upgraded member may take up to two minutes to catch up with the existing cluster. Check the size of a recent snapshot to estimate the total data size. In other words, it is safest to wait for 2 minutes between upgrading each member.
+
+For a much larger total data size, 100MB or more , this one-time process might take even more time. Administrators of very large etcd clusters of this magnitude can feel free to contact the [etcd team][etcd-contact] before upgrading, and we'll be happy to provide advice on the procedure.
+
+#### Downgrade
+
+If all members have been upgraded to v3.1, the cluster will be upgraded to v3.1, and downgrade from this completed state is **not possible**. If any single member is still v3.0, however, the cluster and its operations remains "v3.0", and it is possible from this mixed cluster state to return to using a v3.0 etcd binary on all members.
+
+Please [backup the data directory](../op-guide/maintenance.md#snapshot-backup) of all etcd members to make downgrading the cluster possible even after it has been completely upgraded.
+
+### Upgrade procedure
+
+This example shows how to upgrade a 3-member v3.0 ectd cluster running on a local machine.
+
+#### 1. Check upgrade requirements
+
+Is the cluster healthy and running v3.0.x?
+
+```
+$ ETCDCTL_API=3 etcdctl endpoint health --endpoints=localhost:2379,localhost:22379,localhost:32379
+localhost:2379 is healthy: successfully committed proposal: took = 6.600684ms
+localhost:22379 is healthy: successfully committed proposal: took = 8.540064ms
+localhost:32379 is healthy: successfully committed proposal: took = 8.763432ms
+
+$ curl http://localhost:2379/version
+{"etcdserver":"3.0.16","etcdcluster":"3.0.0"}
+```
+
+#### 2. Stop the existing etcd process
+
+When each etcd process is stopped, expected errors will be logged by other cluster members. This is normal since a cluster member connection has been (temporarily) broken:
+
+```
+2017-01-17 09:34:18.352662 I | raft: raft.node: 1640829d9eea5cfb elected leader 1640829d9eea5cfb at term 5
+2017-01-17 09:34:18.359630 W | etcdserver: failed to reach the peerURL(http://localhost:2380) of member fd32987dcd0511e0 (Get http://localhost:2380/version: dial tcp 127.0.0.1:2380: getsockopt: connection refused)
+2017-01-17 09:34:18.359679 W | etcdserver: cannot get the version of member fd32987dcd0511e0 (Get http://localhost:2380/version: dial tcp 127.0.0.1:2380: getsockopt: connection refused)
+2017-01-17 09:34:18.548116 W | rafthttp: lost the TCP streaming connection with peer fd32987dcd0511e0 (stream Message writer)
+2017-01-17 09:34:19.147816 W | rafthttp: lost the TCP streaming connection with peer fd32987dcd0511e0 (stream MsgApp v2 writer)
+2017-01-17 09:34:34.364907 W | etcdserver: failed to reach the peerURL(http://localhost:2380) of member fd32987dcd0511e0 (Get http://localhost:2380/version: dial tcp 127.0.0.1:2380: getsockopt: connection refused)
+```
+
+It's a good idea at this point to [backup the etcd data](../op-guide/maintenance.md#snapshot-backup) to provide a downgrade path should any problems occur:
+
+```
+$ etcdctl snapshot save backup.db
+```
+
+#### 3. Drop-in etcd v3.1 binary and start the new etcd process
+
+The new v3.1 etcd will publish its information to the cluster:
+
+```
+2017-01-17 09:36:00.996590 I | etcdserver: published {Name:my-etcd-1 ClientURLs:[http://localhost:2379]} to cluster 46bc3ce73049e678
+```
+
+Verify that each member, and then the entire cluster, becomes healthy with the new v3.1 etcd binary:
+
+```
+$ ETCDCTL_API=3 /etcdctl endpoint health --endpoints=localhost:2379,localhost:22379,localhost:32379
+localhost:22379 is healthy: successfully committed proposal: took = 5.540129ms
+localhost:32379 is healthy: successfully committed proposal: took = 7.321671ms
+localhost:2379 is healthy: successfully committed proposal: took = 10.629901ms
+```
+
+Upgraded members will log warnings like the following until the entire cluster is upgraded. This is expected and will cease after all etcd cluster members are upgraded to v3.1:
+
+```
+2017-01-17 09:36:38.406268 W | etcdserver: the local etcd version 3.0.16 is not up-to-date
+2017-01-17 09:36:38.406295 W | etcdserver: member fd32987dcd0511e0 has a higher version 3.1.0
+2017-01-17 09:36:42.407695 W | etcdserver: the local etcd version 3.0.16 is not up-to-date
+2017-01-17 09:36:42.407730 W | etcdserver: member fd32987dcd0511e0 has a higher version 3.1.0
+```
+
+#### 4. Repeat step 2 to step 3 for all other members
+
+#### 5. Finish
+
+When all members are upgraded, the cluster will report upgrading to 3.1 successfully:
+
+```
+2017-01-17 09:37:03.100015 I | etcdserver: updating the cluster version from 3.0 to 3.1
+2017-01-17 09:37:03.104263 N | etcdserver/membership: updated the cluster version from 3.0 to 3.1
+2017-01-17 09:37:03.104374 I | etcdserver/api: enabled capabilities for version 3.1
+```
+
+```
+$ ETCDCTL_API=3 /etcdctl endpoint health --endpoints=localhost:2379,localhost:22379,localhost:32379
+localhost:2379 is healthy: successfully committed proposal: took = 2.312897ms
+localhost:22379 is healthy: successfully committed proposal: took = 2.553476ms
+localhost:32379 is healthy: successfully committed proposal: took = 2.516902ms
+```
+
+[etcd-contact]: https://groups.google.com/forum/#!forum/etcd-dev
diff --git a/vendor/github.com/coreos/etcd/Documentation/upgrades/upgrade_3_2.md b/vendor/github.com/coreos/etcd/Documentation/upgrades/upgrade_3_2.md
new file mode 100644
index 00000000..1252ed36
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/upgrades/upgrade_3_2.md
@@ -0,0 +1,172 @@
+## Upgrade etcd from 3.1 to 3.2
+
+In the general case, upgrading from etcd 3.1 to 3.2 can be a zero-downtime, rolling upgrade:
+ - one by one, stop the etcd v3.1 processes and replace them with etcd v3.2 processes
+ - after running all v3.2 processes, new features in v3.2 are available to the cluster
+
+Before [starting an upgrade](#upgrade-procedure), read through the rest of this guide to prepare.
+
+### Client upgrade checklists
+
+3.2 introduces two breaking changes.
+
+Previously, `clientv3.Lease.TimeToLive` API returned `lease.ErrLeaseNotFound` on non-existent lease ID. 3.2 instead returns TTL=-1 in its response and no error (see [#7305](https://github.com/coreos/etcd/pull/7305)).
+
+Before
+
+```go
+// when leaseID does not exist
+resp, err := TimeToLive(ctx, leaseID)
+resp == nil
+err == lease.ErrLeaseNotFound
+```
+
+After
+
+```go
+// when leaseID does not exist
+resp, err := TimeToLive(ctx, leaseID)
+resp.TTL == -1
+err == nil
+```
+
+`clientv3.NewFromConfigFile` is moved to `yaml.NewConfig`.
+
+Before
+
+```go
+import "github.com/coreos/etcd/clientv3"
+clientv3.NewFromConfigFile
+```
+
+After
+
+```go
+import clientv3yaml "github.com/coreos/etcd/clientv3/yaml"
+clientv3yaml.NewConfig
+```
+
+### Server upgrade checklists
+
+#### Upgrade requirements
+
+To upgrade an existing etcd deployment to 3.2, the running cluster must be 3.1 or greater. If it's before 3.1, please [upgrade to 3.1](upgrade_3_1.md) before upgrading to 3.2.
+
+Also, to ensure a smooth rolling upgrade, the running cluster must be healthy. Check the health of the cluster by using the `etcdctl endpoint health` command before proceeding.
+
+#### Preparation
+
+Before upgrading etcd, always test the services relying on etcd in a staging environment before deploying the upgrade to the production environment.
+
+Before beginning, [backup the etcd data](../op-guide/maintenance.md#snapshot-backup). Should something go wrong with the upgrade, it is possible to use this backup to [downgrade](#downgrade) back to existing etcd version. Please note that the `snapshot` command only backs up the v3 data. For v2 data, see [backing up v2 datastore](../v2/admin_guide.md#backing-up-the-datastore).
+
+#### Mixed versions
+
+While upgrading, an etcd cluster supports mixed versions of etcd members, and operates with the protocol of the lowest common version. The cluster is only considered upgraded once all of its members are upgraded to version 3.2. Internally, etcd members negotiate with each other to determine the overall cluster version, which controls the reported version and the supported features.
+
+#### Limitations
+
+Note: If the cluster only has v3 data and no v2 data, it is not subject to this limitation.
+
+If the cluster is serving a v2 data set larger than 50MB, each newly upgraded member may take up to two minutes to catch up with the existing cluster. Check the size of a recent snapshot to estimate the total data size. In other words, it is safest to wait for 2 minutes between upgrading each member.
+
+For a much larger total data size, 100MB or more , this one-time process might take even more time. Administrators of very large etcd clusters of this magnitude can feel free to contact the [etcd team][etcd-contact] before upgrading, and we'll be happy to provide advice on the procedure.
+
+#### Downgrade
+
+If all members have been upgraded to v3.2, the cluster will be upgraded to v3.2, and downgrade from this completed state is **not possible**. If any single member is still v3.1, however, the cluster and its operations remains "v3.1", and it is possible from this mixed cluster state to return to using a v3.1 etcd binary on all members.
+
+Please [backup the data directory](../op-guide/maintenance.md#snapshot-backup) of all etcd members to make downgrading the cluster possible even after it has been completely upgraded.
+
+### Upgrade procedure
+
+This example shows how to upgrade a 3-member v3.1 ectd cluster running on a local machine.
+
+#### 1. Check upgrade requirements
+
+Is the cluster healthy and running v3.1.x?
+
+```
+$ ETCDCTL_API=3 etcdctl endpoint health --endpoints=localhost:2379,localhost:22379,localhost:32379
+localhost:2379 is healthy: successfully committed proposal: took = 6.600684ms
+localhost:22379 is healthy: successfully committed proposal: took = 8.540064ms
+localhost:32379 is healthy: successfully committed proposal: took = 8.763432ms
+
+$ curl http://localhost:2379/version
+{"etcdserver":"3.1.7","etcdcluster":"3.1.0"}
+```
+
+#### 2. Stop the existing etcd process
+
+When each etcd process is stopped, expected errors will be logged by other cluster members. This is normal since a cluster member connection has been (temporarily) broken:
+
+```
+2017-04-27 14:13:31.491746 I | raft: c89feb932daef420 [term 3] received MsgTimeoutNow from 6d4f535bae3ab960 and starts an election to get leadership.
+2017-04-27 14:13:31.491769 I | raft: c89feb932daef420 became candidate at term 4
+2017-04-27 14:13:31.491788 I | raft: c89feb932daef420 received MsgVoteResp from c89feb932daef420 at term 4
+2017-04-27 14:13:31.491797 I | raft: c89feb932daef420 [logterm: 3, index: 9] sent MsgVote request to 6d4f535bae3ab960 at term 4
+2017-04-27 14:13:31.491805 I | raft: c89feb932daef420 [logterm: 3, index: 9] sent MsgVote request to 9eda174c7df8a033 at term 4
+2017-04-27 14:13:31.491815 I | raft: raft.node: c89feb932daef420 lost leader 6d4f535bae3ab960 at term 4
+2017-04-27 14:13:31.524084 I | raft: c89feb932daef420 received MsgVoteResp from 6d4f535bae3ab960 at term 4
+2017-04-27 14:13:31.524108 I | raft: c89feb932daef420 [quorum:2] has received 2 MsgVoteResp votes and 0 vote rejections
+2017-04-27 14:13:31.524123 I | raft: c89feb932daef420 became leader at term 4
+2017-04-27 14:13:31.524136 I | raft: raft.node: c89feb932daef420 elected leader c89feb932daef420 at term 4
+2017-04-27 14:13:31.592650 W | rafthttp: lost the TCP streaming connection with peer 6d4f535bae3ab960 (stream MsgApp v2 reader)
+2017-04-27 14:13:31.592825 W | rafthttp: lost the TCP streaming connection with peer 6d4f535bae3ab960 (stream Message reader)
+2017-04-27 14:13:31.693275 E | rafthttp: failed to dial 6d4f535bae3ab960 on stream Message (dial tcp [::1]:2380: getsockopt: connection refused)
+2017-04-27 14:13:31.693289 I | rafthttp: peer 6d4f535bae3ab960 became inactive
+2017-04-27 14:13:31.936678 W | rafthttp: lost the TCP streaming connection with peer 6d4f535bae3ab960 (stream Message writer)
+```
+
+It's a good idea at this point to [backup the etcd data](../op-guide/maintenance.md#snapshot-backup) to provide a downgrade path should any problems occur:
+
+```
+$ etcdctl snapshot save backup.db
+```
+
+#### 3. Drop-in etcd v3.2 binary and start the new etcd process
+
+The new v3.2 etcd will publish its information to the cluster:
+
+```
+2017-04-27 14:14:25.363225 I | etcdserver: published {Name:s1 ClientURLs:[http://localhost:2379]} to cluster a9ededbffcb1b1f1
+```
+
+Verify that each member, and then the entire cluster, becomes healthy with the new v3.2 etcd binary:
+
+```
+$ ETCDCTL_API=3 /etcdctl endpoint health --endpoints=localhost:2379,localhost:22379,localhost:32379
+localhost:22379 is healthy: successfully committed proposal: took = 5.540129ms
+localhost:32379 is healthy: successfully committed proposal: took = 7.321771ms
+localhost:2379 is healthy: successfully committed proposal: took = 10.629901ms
+```
+
+Upgraded members will log warnings like the following until the entire cluster is upgraded. This is expected and will cease after all etcd cluster members are upgraded to v3.2:
+
+```
+2017-04-27 14:15:17.071804 W | etcdserver: member c89feb932daef420 has a higher version 3.2.0
+2017-04-27 14:15:21.073110 W | etcdserver: the local etcd version 3.1.7 is not up-to-date
+2017-04-27 14:15:21.073142 W | etcdserver: member 6d4f535bae3ab960 has a higher version 3.2.0
+2017-04-27 14:15:21.073157 W | etcdserver: the local etcd version 3.1.7 is not up-to-date
+2017-04-27 14:15:21.073164 W | etcdserver: member c89feb932daef420 has a higher version 3.2.0
+```
+
+#### 4. Repeat step 2 to step 3 for all other members
+
+#### 5. Finish
+
+When all members are upgraded, the cluster will report upgrading to 3.2 successfully:
+
+```
+2017-04-27 14:15:54.536901 N | etcdserver/membership: updated the cluster version from 3.1 to 3.2
+2017-04-27 14:15:54.537035 I | etcdserver/api: enabled capabilities for version 3.2
+```
+
+```
+$ ETCDCTL_API=3 /etcdctl endpoint health --endpoints=localhost:2379,localhost:22379,localhost:32379
+localhost:2379 is healthy: successfully committed proposal: took = 2.312897ms
+localhost:22379 is healthy: successfully committed proposal: took = 2.553476ms
+localhost:32379 is healthy: successfully committed proposal: took = 2.517902ms
+```
+
+[etcd-contact]: https://groups.google.com/forum/#!forum/etcd-dev
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/04_to_2_snapshot_migration.md b/vendor/github.com/coreos/etcd/Documentation/v2/04_to_2_snapshot_migration.md
new file mode 100644
index 00000000..28e17495
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/04_to_2_snapshot_migration.md
@@ -0,0 +1,36 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Snapshot Migration
+
+You can migrate a snapshot of your data from a v0.4.9+ cluster into a new etcd 2.2 cluster using a snapshot migration. After snapshot migration, the etcd indexes of your data will change. Many etcd applications rely on these indexes to behave correctly. This operation should only be done while all etcd applications are stopped.
+
+To get started get the newest data snapshot from the 0.4.9+ cluster:
+
+```
+curl http://cluster.example.com:4001/v2/migration/snapshot > backup.snap
+```
+
+Now, import the snapshot into your new cluster:
+
+```
+etcdctl --endpoint new_cluster.example.com import --snap backup.snap
+```
+
+If you have a large amount of data, you can specify more concurrent works to copy data in parallel by using `-c` flag.
+If you have hidden keys to copy, you can use `--hidden` flag to specify. For example fleet uses `/_coreos.com/fleet` so to import those keys use `--hidden /_coreos.com`.
+
+And the data will quickly copy into the new cluster:
+
+```
+entering dir: /
+entering dir: /foo
+entering dir: /foo/bar
+copying key: /foo/bar/1 1
+entering dir: /
+entering dir: /foo2
+entering dir: /foo2/bar2
+copying key: /foo2/bar2/2 2
+```
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/README.md b/vendor/github.com/coreos/etcd/Documentation/v2/README.md
new file mode 100644
index 00000000..9ead8780
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/README.md
@@ -0,0 +1,170 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# etcd2
+
+[![Go Report Card](https://goreportcard.com/badge/github.com/coreos/etcd)](https://goreportcard.com/report/github.com/coreos/etcd)
+[![Build Status](https://travis-ci.org/coreos/etcd.svg?branch=master)](https://travis-ci.org/coreos/etcd)
+[![Build Status](https://semaphoreci.com/api/v1/coreos/etcd/branches/master/shields_badge.svg)](https://semaphoreci.com/coreos/etcd)
+[![Docker Repository on Quay.io](https://quay.io/repository/coreos/etcd-git/status "Docker Repository on Quay.io")](https://quay.io/repository/coreos/etcd-git)
+
+**Note**: The `master` branch may be in an *unstable or even broken state* during development. Please use [releases][github-release] instead of the `master` branch in order to get stable binaries.
+
+![etcd Logo](../../logos/etcd-horizontal-color.png)
+
+etcd is a distributed, consistent key-value store for shared configuration and service discovery, with a focus on being:
+
+* *Simple*: curl'able user-facing API (HTTP+JSON)
+* *Secure*: optional SSL client cert authentication
+* *Fast*: benchmarked 1000s of writes/s per instance
+* *Reliable*: properly distributed using Raft
+
+etcd is written in Go and uses the [Raft][raft] consensus algorithm to manage a highly-available replicated log.
+
+etcd is used [in production by many companies](./production-users.md), and the development team stands behind it in critical deployment scenarios, where etcd is frequently teamed with applications such as [Kubernetes][k8s], [fleet][fleet], [locksmith][locksmith], [vulcand][vulcand], and many others.
+
+See [etcdctl][etcdctl] for a simple command line client.
+Or feel free to just use `curl`, as in the examples below.
+
+[raft]: https://raft.github.io/
+[k8s]: http://kubernetes.io/
+[fleet]: https://github.com/coreos/fleet
+[locksmith]: https://github.com/coreos/locksmith
+[vulcand]: https://github.com/vulcand/vulcand
+[etcdctl]: https://github.com/coreos/etcd/tree/master/etcdctl
+
+## Getting Started
+
+### Getting etcd
+
+The easiest way to get etcd is to use one of the pre-built release binaries which are available for OSX, Linux, Windows, AppC (ACI), and Docker. Instructions for using these binaries are on the [GitHub releases page][github-release].
+
+For those wanting to try the very latest version, you can build the latest version of etcd from the `master` branch.
+You will first need [*Go*](https://golang.org/) installed on your machine (version 1.5+ is required).
+All development occurs on `master`, including new features and bug fixes.
+Bug fixes are first targeted at `master` and subsequently ported to release branches, as described in the [branch management][branch-management] guide.
+
+[github-release]: https://github.com/coreos/etcd/releases/
+[branch-management]: branch_management.md
+
+### Running etcd
+
+First start a single-member cluster of etcd:
+
+```sh
+./bin/etcd
+```
+
+This will bring up etcd listening on port 2379 for client communication and on port 2380 for server-to-server communication.
+
+Next, let's set a single key, and then retrieve it:
+
+```
+curl -L http://127.0.0.1:2379/v2/keys/mykey -XPUT -d value="this is awesome"
+curl -L http://127.0.0.1:2379/v2/keys/mykey
+```
+
+You have successfully started an etcd and written a key to the store.
+
+### etcd TCP ports
+
+The [official etcd ports][iana-ports] are 2379 for client requests, and 2380 for peer communication. To maintain compatibility, some etcd configuration and documentation continues to refer to the legacy ports 4001 and 7001, but all new etcd use and discussion should adopt the IANA-assigned ports. The legacy ports 4001 and 7001 will be fully deprecated, and support for their use removed, in future etcd releases.
+
+[iana-ports]: http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt
+
+### Running local etcd cluster
+
+First install [goreman](https://github.com/mattn/goreman), which manages Procfile-based applications.
+
+Our [Procfile script](../../V2Procfile) will set up a local example cluster. You can start it with:
+
+```sh
+goreman start
+```
+
+This will bring up 3 etcd members `infra1`, `infra2` and `infra3` and etcd proxy `proxy`, which runs locally and composes a cluster.
+
+You can write a key to the cluster and retrieve the value back from any member or proxy.
+
+### Next Steps
+
+Now it's time to dig into the full etcd API and other guides.
+
+- Explore the full [API][api].
+- Set up a [multi-machine cluster][clustering].
+- Learn the [config format, env variables and flags][configuration].
+- Find [language bindings and tools][libraries-and-tools].
+- Use TLS to [secure an etcd cluster][security].
+- [Tune etcd][tuning].
+- [Upgrade from 0.4.9+ to 2.2.0][upgrade].
+
+[api]: ./api.md
+[clustering]: ./clustering.md
+[configuration]: ./configuration.md
+[libraries-and-tools]: ./libraries-and-tools.md
+[security]: ./security.md
+[tuning]: ./tuning.md
+[upgrade]: ./04_to_2_snapshot_migration.md
+
+## Contact
+
+- Mailing list: [etcd-dev](https://groups.google.com/forum/?hl=en#!forum/etcd-dev)
+- IRC: #[etcd](irc://irc.freenode.org:6667/#etcd) on freenode.org
+- Planning/Roadmap: [milestones](https://github.com/coreos/etcd/milestones), [roadmap](../../ROADMAP.md)
+- Bugs: [issues](https://github.com/coreos/etcd/issues)
+
+## Contributing
+
+See [CONTRIBUTING](../../CONTRIBUTING.md) for details on submitting patches and the contribution workflow.
+
+## Reporting bugs
+
+See [reporting bugs](reporting_bugs.md) for details about reporting any issue you may encounter.
+
+## Known bugs
+
+[GH518](https://github.com/coreos/etcd/issues/518) is a known bug. Issue is that:
+
+```
+curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar
+curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d dir=true -d prevExist=true
+```
+
+If the previous node is a key and client tries to overwrite it with `dir=true`, it does not give warnings such as `Not a directory`. Instead, the key is set to empty value.
+
+## Project Details
+
+### Versioning
+
+#### Service Versioning
+
+etcd uses [semantic versioning](http://semver.org)
+New minor versions may add additional features to the API.
+
+You can get the version of etcd by issuing a request to /version:
+
+```sh
+curl -L http://127.0.0.1:2379/version
+```
+
+#### API Versioning
+
+The `v2` API responses should not change after the 2.0.0 release but new features will be added over time.
+
+#### 32-bit and other unsupported systems
+
+etcd has known issues on 32-bit systems due to a bug in the Go runtime. See #[358][358] for more information.
+
+To avoid inadvertently running a possibly unstable etcd server, `etcd` on unsupported architectures will print
+a warning message and immediately exit if the environment variable `ETCD_UNSUPPORTED_ARCH` is not set to
+the target architecture.
+
+Currently only the amd64 architecture is officially supported by `etcd`.
+
+[358]: https://github.com/coreos/etcd/issues/358
+
+### License
+
+etcd is under the Apache 2.0 license. See the [LICENSE](../../LICENSE) file for details.
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/admin_guide.md b/vendor/github.com/coreos/etcd/Documentation/v2/admin_guide.md
new file mode 100644
index 00000000..f3f4431e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/admin_guide.md
@@ -0,0 +1,317 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Administration
+
+## Data Directory
+
+### Lifecycle
+
+When first started, etcd stores its configuration into a data directory specified by the data-dir configuration parameter.
+Configuration is stored in the write ahead log and includes: the local member ID, cluster ID, and initial cluster configuration.
+The write ahead log and snapshot files are used during member operation and to recover after a restart.
+
+Having a dedicated disk to store wal files can improve the throughput and stabilize the cluster.
+It is highly recommended to dedicate a wal disk and set `--wal-dir` to point to a directory on that device for a production cluster deployment.
+
+If a member?s data directory is ever lost or corrupted then the user should [remove][remove-a-member] the etcd member from the cluster using `etcdctl` tool.
+
+A user should avoid restarting an etcd member with a data directory from an out-of-date backup.
+Using an out-of-date data directory can lead to inconsistency as the member had agreed to store information via raft then re-joins saying it needs that information again.
+For maximum safety, if an etcd member suffers any sort of data corruption or loss, it must be removed from the cluster.
+Once removed the member can be re-added with an empty data directory.
+
+### Contents
+
+The data directory has two sub-directories in it:
+
+1. wal: write ahead log files are stored here. For details see the [wal package documentation][wal-pkg]
+2. snap: log snapshots are stored here. For details see the [snap package documentation][snap-pkg]
+
+If `--wal-dir` flag is set, etcd will write the write ahead log files to the specified directory instead of data directory.
+
+## Cluster Management
+
+### Lifecycle
+
+If you are spinning up multiple clusters for testing it is recommended that you specify a unique initial-cluster-token for the different clusters.
+This can protect you from cluster corruption in case of mis-configuration because two members started with different cluster tokens will refuse members from each other.
+
+### Monitoring
+
+It is important to monitor your production etcd cluster for healthy information and runtime metrics.
+
+#### Health Monitoring
+
+At lowest level, etcd exposes health information via HTTP at `/health` in JSON format. If it returns `{"health": "true"}`, then the cluster is healthy. Please note the `/health` endpoint is still an experimental one as in etcd 2.2.
+
+```
+$ curl -L http://127.0.0.1:2379/health
+
+{"health": "true"}
+```
+
+You can also use etcdctl to check the cluster-wide health information. It will contact all the members of the cluster and collect the health information for you.
+
+```
+$./etcdctl cluster-health
+member 8211f1d0f64f3269 is healthy: got healthy result from http://127.0.0.1:12379
+member 91bc3c398fb3c146 is healthy: got healthy result from http://127.0.0.1:22379
+member fd422379fda50e48 is healthy: got healthy result from http://127.0.0.1:32379
+cluster is healthy
+```
+
+#### Runtime Metrics
+
+etcd uses [Prometheus][prometheus] for metrics reporting in the server. You can read more through the runtime metrics [doc][metrics].
+
+### Debugging
+
+Debugging a distributed system can be difficult. etcd provides several ways to make debug
+easier.
+
+#### Enabling Debug Logging
+
+When you want to debug etcd without stopping it, you can enable debug logging at runtime.
+etcd exposes logging configuration at `/config/local/log`.
+
+```
+$ curl http://127.0.0.1:2379/config/local/log -XPUT -d '{"Level":"DEBUG"}'
+$ # debug logging enabled
+$
+$ curl http://127.0.0.1:2379/config/local/log -XPUT -d '{"Level":"INFO"}'
+$ # debug logging disabled
+```
+
+#### Debugging Variables
+
+Debug variables are exposed for real-time debugging purposes. Developers who are familiar with etcd can utilize these variables to debug unexpected behavior. etcd exposes debug variables via HTTP at `/debug/vars` in JSON format. The debug variables contains
+`cmdline`, `file_descriptor_limit`, `memstats` and `raft.status`.
+
+`cmdline` is the command line arguments passed into etcd.
+
+`file_descriptor_limit` is the max number of file descriptors etcd can utilize.
+
+`memstats` is explained in detail in the [Go runtime documentation][golang-memstats].
+
+`raft.status` is useful when you want to debug low level raft issues if you are familiar with raft internals. In most cases, you do not need to check `raft.status`.
+
+```json
+{
+"cmdline": ["./etcd"],
+"file_descriptor_limit": 0,
+"memstats": {"Alloc":4105744,"TotalAlloc":42337320,"Sys":12560632,"...":"..."},
+"raft.status": {"id":"ce2a822cea30bfca","term":5,"vote":"ce2a822cea30bfca","commit":23509,"lead":"ce2a822cea30bfca","raftState":"StateLeader","progress":{"ce2a822cea30bfca":{"match":23509,"next":23510,"state":"ProgressStateProbe"}}}
+}
+```
+
+### Optimal Cluster Size
+
+The recommended etcd cluster size is 3, 5 or 7, which is decided by the fault tolerance requirement. A 7-member cluster can provide enough fault tolerance in most cases. While larger cluster provides better fault tolerance the write performance reduces since data needs to be replicated to more machines.
+
+#### Fault Tolerance Table
+
+It is recommended to have an odd number of members in a cluster. Having an odd cluster size doesn't change the number needed for majority, but you gain a higher tolerance for failure by adding the extra member. You can see this in practice when comparing even and odd sized clusters:
+
+| Cluster Size | Majority | Failure Tolerance |
+|--------------|------------|-------------------|
+| 1 | 1 | 0 |
+| 2 | 2 | 0 |
+| 3 | 2 | **1** |
+| 4 | 3 | 1 |
+| 5 | 3 | **2** |
+| 6 | 4 | 2 |
+| 7 | 4 | **3** |
+| 8 | 5 | 3 |
+| 9 | 5 | **4** |
+
+As you can see, adding another member to bring the size of cluster up to an odd size is always worth it. During a network partition, an odd number of members also guarantees that there will almost always be a majority of the cluster that can continue to operate and be the source of truth when the partition ends.
+
+#### Changing Cluster Size
+
+After your cluster is up and running, adding or removing members is done via [runtime reconfiguration][runtime-reconfig], which allows the cluster to be modified without downtime. The `etcdctl` tool has `member list`, `member add` and `member remove` commands to complete this process.
+
+### Member Migration
+
+When there is a scheduled machine maintenance or retirement, you might want to migrate an etcd member to another machine without losing the data and changing the member ID.
+
+The data directory contains all the data to recover a member to its point-in-time state. To migrate a member:
+
+* Stop the member process.
+* Copy the data directory of the now-idle member to the new machine.
+* Update the peer URLs for the replaced member to reflect the new machine according to the [runtime reconfiguration instructions][update-a-member].
+* Start etcd on the new machine, using the same configuration and the copy of the data directory.
+
+This example will walk you through the process of migrating the infra1 member to a new machine:
+
+|Name|Peer URL|
+|------|--------------|
+|infra0|10.0.1.10:2380|
+|infra1|10.0.1.11:2380|
+|infra2|10.0.1.12:2380|
+
+```sh
+$ export ETCDCTL_ENDPOINT=http://10.0.1.10:2379,http://10.0.1.11:2379,http://10.0.1.12:2379
+```
+
+```sh
+$ etcdctl member list
+84194f7c5edd8b37: name=infra0 peerURLs=http://10.0.1.10:2380 clientURLs=http://127.0.0.1:2379,http://10.0.1.10:2379
+b4db3bf5e495e255: name=infra1 peerURLs=http://10.0.1.11:2380 clientURLs=http://127.0.0.1:2379,http://10.0.1.11:2379
+bc1083c870280d44: name=infra2 peerURLs=http://10.0.1.12:2380 clientURLs=http://127.0.0.1:2379,http://10.0.1.12:2379
+```
+
+#### Stop the member etcd process
+
+```sh
+$ ssh 10.0.1.11
+```
+
+```sh
+$ kill `pgrep etcd`
+```
+
+#### Copy the data directory of the now-idle member to the new machine
+
+```
+$ tar -cvzf infra1.etcd.tar.gz %data_dir%
+```
+
+```sh
+$ scp infra1.etcd.tar.gz 10.0.1.13:~/
+```
+
+#### Update the peer URLs for that member to reflect the new machine
+
+```sh
+$ curl http://10.0.1.10:2379/v2/members/b4db3bf5e495e255 -XPUT \
+-H "Content-Type: application/json" -d '{"peerURLs":["http://10.0.1.13:2380"]}'
+```
+
+Or use `etcdctl member update` command
+
+```sh
+$ etcdctl member update b4db3bf5e495e255 http://10.0.1.13:2380
+```
+
+#### Start etcd on the new machine, using the same configuration and the copy of the data directory
+
+```sh
+$ ssh 10.0.1.13
+```
+
+```sh
+$ tar -xzvf infra1.etcd.tar.gz -C %data_dir%
+```
+
+```
+etcd -name infra1 \
+-listen-peer-urls http://10.0.1.13:2380 \
+-listen-client-urls http://10.0.1.13:2379,http://127.0.0.1:2379 \
+-advertise-client-urls http://10.0.1.13:2379,http://127.0.0.1:2379
+```
+
+### Disaster Recovery
+
+etcd is designed to be resilient to machine failures. An etcd cluster can automatically recover from any number of temporary failures (for example, machine reboots), and a cluster of N members can tolerate up to _(N-1)/2_ permanent failures (where a member can no longer access the cluster, due to hardware failure or disk corruption). However, in extreme circumstances, a cluster might permanently lose enough members such that quorum is irrevocably lost. For example, if a three-node cluster suffered two simultaneous and unrecoverable machine failures, it would be normally impossible for the cluster to restore quorum and continue functioning.
+
+To recover from such scenarios, etcd provides functionality to backup and restore the datastore and recreate the cluster without data loss.
+
+#### Backing up the datastore
+
+**Note:** Windows users must stop etcd before running the backup command.
+
+The first step of the recovery is to backup the data directory and wal directory, if stored separately, on a functioning etcd node. To do this, use the `etcdctl backup` command, passing in the original data (and wal) directory used by etcd. For example:
+
+```sh
+ etcdctl backup \
+ --data-dir %data_dir% \
+ [--wal-dir %wal_dir%] \
+ --backup-dir %backup_data_dir%
+ [--backup-wal-dir %backup_wal_dir%]
+```
+
+This command will rewrite some of the metadata contained in the backup (specifically, the node ID and cluster ID), which means that the node will lose its former identity. In order to recreate a cluster from the backup, you will need to start a new, single-node cluster. The metadata is rewritten to prevent the new node from inadvertently being joined onto an existing cluster.
+
+#### Restoring a backup
+
+To restore a backup using the procedure created above, start etcd with the `-force-new-cluster` option and pointing to the backup directory. This will initialize a new, single-member cluster with the default advertised peer URLs, but preserve the entire contents of the etcd data store. Continuing from the previous example:
+
+```sh
+ etcd \
+ -data-dir=%backup_data_dir% \
+ [-wal-dir=%backup_wal_dir%] \
+ -force-new-cluster \
+ ...
+```
+
+Now etcd should be available on this node and serving the original datastore.
+
+Once you have verified that etcd has started successfully, shut it down and move the data and wal, if stored separately, back to the previous location (you may wish to make another copy as well to be safe):
+
+```sh
+ pkill etcd
+ rm -fr %data_dir%
+ rm -fr %wal_dir%
+ mv %backup_data_dir% %data_dir%
+ mv %backup_wal_dir% %wal_dir%
+ etcd \
+ -data-dir=%data_dir% \
+ [-wal-dir=%wal_dir%] \
+ ...
+```
+
+#### Restoring the cluster
+
+Now that the node is running successfully, [change its advertised peer URLs][update-a-member], as the `--force-new-cluster` option has set the peer URL to the default listening on localhost.
+
+You can then add more nodes to the cluster and restore resiliency. See the [add a new member][add-a-member] guide for more details.
+
+**Note:** If you are trying to restore your cluster using old failed etcd nodes, please make sure you have stopped old etcd instances and removed their old data directories specified by the data-dir configuration parameter.
+
+### Client Request Timeout
+
+etcd sets different timeouts for various types of client requests. The timeout value is not tunable now, which will be improved soon (https://github.com/coreos/etcd/issues/2038).
+
+#### Get requests
+
+Timeout is not set for get requests, because etcd serves the result locally in a non-blocking way.
+
+**Note**: QuorumGet request is a different type, which is mentioned in the following sections.
+
+#### Watch requests
+
+Timeout is not set for watch requests. etcd will not stop a watch request until client cancels it, or the connection is broken.
+
+#### Delete, Put, Post, QuorumGet requests
+
+The default timeout is 5 seconds. It should be large enough to allow all key modifications if the majority of cluster is functioning.
+
+If the request times out, it indicates two possibilities:
+
+1. the server the request sent to was not functioning at that time.
+2. the majority of the cluster is not functioning.
+
+If timeout happens several times continuously, administrators should check status of cluster and resolve it as soon as possible.
+
+### Best Practices
+
+#### Maximum OS threads
+
+By default, etcd uses the default configuration of the Go 1.4 runtime, which means that at most one operating system thread will be used to execute code simultaneously. (Note that this default behavior [has changed in Go 1.5][golang1.5-runtime]).
+
+When using etcd in heavy-load scenarios on machines with multiple cores it will usually be desirable to increase the number of threads that etcd can utilize. To do this, simply set the environment variable GOMAXPROCS to the desired number when starting etcd. For more information on this variable, see the [Go runtime documentation][golang-runtime].
+
+[add-a-member]: runtime-configuration.md#add-a-new-member
+[golang1.5-runtime]: https://golang.org/doc/go1.5#runtime
+[golang-memstats]: https://golang.org/pkg/runtime/#MemStats
+[golang-runtime]: https://golang.org/pkg/runtime
+[metrics]: metrics.md
+[prometheus]: http://prometheus.io/
+[remove-a-member]: runtime-configuration.md#remove-a-member
+[runtime-reconfig]: runtime-configuration.md#cluster-reconfiguration-operations
+[snap-pkg]: http://godoc.org/github.com/coreos/etcd/snap
+[update-a-member]: runtime-configuration.md#update-a-member
+[wal-pkg]: http://godoc.org/github.com/coreos/etcd/wal
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/api.md b/vendor/github.com/coreos/etcd/Documentation/v2/api.md
new file mode 100644
index 00000000..367873df
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/api.md
@@ -0,0 +1,1155 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# etcd API
+
+## Running a Single Machine Cluster
+
+These examples will use a single member cluster to show you the basics of the etcd REST API.
+Let's start etcd:
+
+```sh
+./bin/etcd
+```
+
+This will bring up etcd listening on the IANA assigned ports and listening on localhost.
+The IANA assigned ports for etcd are 2379 for client communication and 2380 for server-to-server communication.
+
+## Getting the etcd version
+
+The etcd version of a specific instance can be obtained from the `/version` endpoint.
+
+```sh
+curl -L http://127.0.0.1:2379/version
+```
+
+## Key Space Operations
+
+The primary API of etcd is a hierarchical key space.
+The key space consists of directories and keys which are generically referred to as "nodes".
+
+### Setting the value of a key
+
+Let's set the first key-value pair in the datastore.
+In this case the key is `/message` and the value is `Hello world`.
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/message -XPUT -d value="Hello world"
+```
+
+```json
+{
+ "action": "set",
+ "node": {
+ "createdIndex": 2,
+ "key": "/message",
+ "modifiedIndex": 2,
+ "value": "Hello world"
+ }
+}
+```
+
+The response object contains several attributes:
+
+1. `action`: the action of the request that was just made.
+The request attempted to modify `node.value` via a `PUT` HTTP request, thus the value of action is `set`.
+
+2. `node.key`: the HTTP path to which the request was made.
+We set `/message` to `Hello world`, so the key field is `/message`.
+etcd uses a file-system-like structure to represent the key-value pairs, therefore all keys start with `/`.
+
+3. `node.value`: the value of the key after resolving the request.
+In this case, a successful request was made that attempted to change the node's value to `Hello world`.
+
+4. `node.createdIndex`: an index is a unique, monotonically-incrementing integer created for each change to etcd.
+This specific index reflects the point in the etcd state member at which a given key was created.
+You may notice that in this example the index is `2` even though it is the first request you sent to the server.
+This is because there are internal commands that also change the state behind the scenes, like adding and syncing servers.
+
+5. `node.modifiedIndex`: like `node.createdIndex`, this attribute is also an etcd index.
+Actions that cause the value to change include `set`, `delete`, `update`, `create`, `compareAndSwap` and `compareAndDelete`.
+Since the `get` and `watch` commands do not change state in the store, they do not change the value of `node.modifiedIndex`.
+
+
+### Response Headers
+
+etcd includes a few HTTP headers in responses that provide global information about the etcd cluster that serviced a request:
+
+```
+X-Etcd-Index: 35
+X-Raft-Index: 5398
+X-Raft-Term: 1
+```
+
+* `X-Etcd-Index` is the current etcd index as explained above. When request is a watch on key space, `X-Etcd-Index` is the current etcd index when the watch starts, which means that the watched event may happen after `X-Etcd-Index`.
+* `X-Raft-Index` is similar to the etcd index but is for the underlying raft protocol.
+* `X-Raft-Term` is an integer that will increase whenever an etcd master election happens in the cluster. If this number is increasing rapidly, you may need to tune the election timeout. See the [tuning][tuning] section for details.
+
+### Get the value of a key
+
+We can get the value that we just set in `/message` by issuing a `GET` request:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/message
+```
+
+```json
+{
+ "action": "get",
+ "node": {
+ "createdIndex": 2,
+ "key": "/message",
+ "modifiedIndex": 2,
+ "value": "Hello world"
+ }
+}
+```
+
+
+### Changing the value of a key
+
+You can change the value of `/message` from `Hello world` to `Hello etcd` with another `PUT` request to the key:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/message -XPUT -d value="Hello etcd"
+```
+
+```json
+{
+ "action": "set",
+ "node": {
+ "createdIndex": 3,
+ "key": "/message",
+ "modifiedIndex": 3,
+ "value": "Hello etcd"
+ },
+ "prevNode": {
+ "createdIndex": 2,
+ "key": "/message",
+ "value": "Hello world",
+ "modifiedIndex": 2
+ }
+}
+```
+
+Here we introduce a new field: `prevNode`. The `prevNode` field represents what the state of a given node was before resolving the request at hand. The `prevNode` field follows the same format as the `node`, and is omitted in the event that there was no previous state for a given node.
+
+### Deleting a key
+
+You can remove the `/message` key with a `DELETE` request:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/message -XDELETE
+```
+
+```json
+{
+ "action": "delete",
+ "node": {
+ "createdIndex": 3,
+ "key": "/message",
+ "modifiedIndex": 4
+ },
+ "prevNode": {
+ "key": "/message",
+ "value": "Hello etcd",
+ "modifiedIndex": 3,
+ "createdIndex": 3
+ }
+}
+```
+
+
+### Using key TTL
+
+Keys in etcd can be set to expire after a specified number of seconds.
+You can do this by setting a TTL (time to live) on the key when sending a `PUT` request:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -d ttl=5
+```
+
+```json
+{
+ "action": "set",
+ "node": {
+ "createdIndex": 5,
+ "expiration": "2013-12-04T12:01:21.874888581-08:00",
+ "key": "/foo",
+ "modifiedIndex": 5,
+ "ttl": 5,
+ "value": "bar"
+ }
+}
+```
+
+Note the two new fields in response:
+
+1. The `expiration` is the time at which this key will expire and be deleted.
+
+2. The `ttl` is the specified time to live for the key, in seconds.
+
+_NOTE_: Keys can only be expired by a cluster leader, so if a member gets disconnected from the cluster, its keys will not expire until it rejoins.
+
+Now you can try to get the key by sending a `GET` request:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo
+```
+
+If the TTL has expired, the key will have been deleted, and you will be returned a 100.
+
+```json
+{
+ "cause": "/foo",
+ "errorCode": 100,
+ "index": 6,
+ "message": "Key not found"
+}
+```
+
+The TTL can be unset to avoid expiration through update operation:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -d ttl= -d prevExist=true
+```
+
+```json
+{
+ "action": "update",
+ "node": {
+ "createdIndex": 5,
+ "key": "/foo",
+ "modifiedIndex": 6,
+ "value": "bar"
+ },
+ "prevNode": {
+ "createdIndex": 5,
+ "expiration": "2013-12-04T12:01:21.874888581-08:00",
+ "key": "/foo",
+ "modifiedIndex": 5,
+ "ttl": 3,
+ "value": "bar"
+ }
+}
+```
+
+### Refreshing key TTL
+
+Keys in etcd can be refreshed without notifying current watchers.
+
+This can be achieved by setting the refresh to true when updating a TTL.
+
+You cannot update the value of a key when refreshing it.
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -d ttl=5
+curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d ttl=5 -d refresh=true -d prevExist=true
+```
+
+```json
+{
+ "action": "set",
+ "node": {
+ "createdIndex": 5,
+ "expiration": "2013-12-04T12:01:21.874888581-08:00",
+ "key": "/foo",
+ "modifiedIndex": 5,
+ "ttl": 5,
+ "value": "bar"
+ }
+}
+{
+ "action":"update",
+ "node":{
+ "key":"/foo",
+ "value":"bar",
+ "expiration": "2013-12-04T12:01:26.874888581-08:00",
+ "ttl":5,
+ "modifiedIndex":6,
+ "createdIndex":5
+ },
+ "prevNode":{
+ "key":"/foo",
+ "value":"bar",
+ "expiration":"2013-12-04T12:01:21.874888581-08:00",
+ "ttl":3,
+ "modifiedIndex":5,
+ "createdIndex":5
+ }
+}
+```
+
+### Waiting for a change
+
+We can watch for a change on a key and receive a notification by using long polling.
+This also works for child keys by passing `recursive=true` in curl.
+
+In one terminal, we send a `GET` with `wait=true` :
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo?wait=true
+```
+
+Now we are waiting for any changes at path `/foo`.
+
+In another terminal, we set a key `/foo` with value `bar`:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar
+```
+
+The first terminal should get the notification and return with the same response as the set request:
+
+```json
+{
+ "action": "set",
+ "node": {
+ "createdIndex": 7,
+ "key": "/foo",
+ "modifiedIndex": 7,
+ "value": "bar"
+ },
+ "prevNode": {
+ "createdIndex": 6,
+ "key": "/foo",
+ "modifiedIndex": 6,
+ "value": "bar"
+ }
+}
+```
+
+However, the watch command can do more than this.
+Using the index, we can watch for commands that have happened in the past.
+This is useful for ensuring you don't miss events between watch commands.
+Typically, we watch again from the `modifiedIndex` + 1 of the node we got.
+
+Let's try to watch for the set command of index 7 again:
+
+```sh
+curl 'http://127.0.0.1:2379/v2/keys/foo?wait=true&waitIndex=7'
+```
+
+The watch command returns immediately with the same response as previously.
+
+If we were to restart the watch from index 8 with:
+
+```sh
+curl 'http://127.0.0.1:2379/v2/keys/foo?wait=true&waitIndex=8'
+```
+
+Then even if etcd is on index 9 or 800, the first event to occur to the `/foo`
+key between 8 and the current index will be returned.
+
+**Note**: etcd only keeps the responses of the most recent 1000 events across all etcd keys.
+It is recommended to send the response to another thread to process immediately
+instead of blocking the watch while processing the result.
+
+#### Watch from cleared event index
+
+If we miss all the 1000 events, we need to recover the current state of the
+watching key space through a get and then start to watch from the
+`X-Etcd-Index` + 1.
+
+For example, we set `/other="bar"` for 2000 times and try to wait from index 8.
+
+```sh
+curl 'http://127.0.0.1:2379/v2/keys/foo?wait=true&waitIndex=8'
+```
+
+We get the index is outdated response, since we miss the 1000 events kept in etcd.
+
+```
+{"errorCode":401,"message":"The event in requested index is outdated and cleared","cause":"the requested history has been cleared [1008/8]","index":2007}
+```
+
+To start watch, first we need to fetch the current state of key `/foo`:
+
+```sh
+curl 'http://127.0.0.1:2379/v2/keys/foo' -vv
+```
+
+```
+< HTTP/1.1 200 OK
+< Content-Type: application/json
+< X-Etcd-Cluster-Id: 7e27652122e8b2ae
+< X-Etcd-Index: 2007
+< X-Raft-Index: 2615
+< X-Raft-Term: 2
+< Date: Mon, 05 Jan 2015 18:54:43 GMT
+< Transfer-Encoding: chunked
+<
+{"action":"get","node":{"key":"/foo","value":"bar","modifiedIndex":7,"createdIndex":7}}
+```
+
+Unlike watches we use the `X-Etcd-Index` + 1 of the response as a `waitIndex`
+instead of the node's `modifiedIndex` + 1 for two reasons:
+
+1. The `X-Etcd-Index` is always greater than or equal to the `modifiedIndex` when
+ getting a key because `X-Etcd-Index` is the current etcd index, and the `modifiedIndex`
+ is the index of an event already stored in etcd.
+2. None of the events represented by indexes between `modifiedIndex` and
+ `X-Etcd-Index` will be related to the key being fetched.
+
+Using the `modifiedIndex` + 1 is functionally equivalent for subsequent
+watches, but since it is smaller than the `X-Etcd-Index` + 1, we may receive a
+`401 EventIndexCleared` error immediately.
+
+So the first watch after the get should be:
+
+```sh
+curl 'http://127.0.0.1:2379/v2/keys/foo?wait=true&waitIndex=2008'
+```
+
+#### Connection being closed prematurely
+
+The server may close a long polling connection before emitting any events.
+This can happen due to a timeout or the server being shutdown.
+Since the HTTP header is sent immediately upon accepting the connection, the response will be seen as empty: `200 OK` and empty body.
+The clients should be prepared to deal with this scenario and retry the watch.
+
+### Atomically Creating In-Order Keys
+
+Using `POST` on a directory, you can create keys with key names that are created in-order.
+This can be used in a variety of useful patterns, like implementing queues of keys which need to be processed in strict order.
+An example use case would be ensuring clients get fair access to a mutex.
+
+Creating an in-order key is easy:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/queue -XPOST -d value=Job1
+```
+
+```json
+{
+ "action": "create",
+ "node": {
+ "createdIndex": 6,
+ "key": "/queue/00000000000000000006",
+ "modifiedIndex": 6,
+ "value": "Job1"
+ }
+}
+```
+
+If you create another entry some time later, it is guaranteed to have a key name that is greater than the previous key.
+Also note the key names use the global etcd index, so the next key can be more than `previous + 1`.
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/queue -XPOST -d value=Job2
+```
+
+```json
+{
+ "action": "create",
+ "node": {
+ "createdIndex": 29,
+ "key": "/queue/00000000000000000029",
+ "modifiedIndex": 29,
+ "value": "Job2"
+ }
+}
+```
+
+To enumerate the in-order keys as a sorted list, use the "sorted" parameter.
+
+```sh
+curl -s 'http://127.0.0.1:2379/v2/keys/queue?recursive=true&sorted=true'
+```
+
+```json
+{
+ "action": "get",
+ "node": {
+ "createdIndex": 2,
+ "dir": true,
+ "key": "/queue",
+ "modifiedIndex": 2,
+ "nodes": [
+ {
+ "createdIndex": 2,
+ "key": "/queue/00000000000000000002",
+ "modifiedIndex": 2,
+ "value": "Job1"
+ },
+ {
+ "createdIndex": 3,
+ "key": "/queue/00000000000000000003",
+ "modifiedIndex": 3,
+ "value": "Job2"
+ }
+ ]
+ }
+}
+```
+
+
+### Using a directory TTL
+
+Like keys, directories in etcd can be set to expire after a specified number of seconds.
+You can do this by setting a TTL (time to live) on a directory when it is created with a `PUT`:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/dir -XPUT -d ttl=30 -d dir=true
+```
+
+```json
+{
+ "action": "set",
+ "node": {
+ "createdIndex": 17,
+ "dir": true,
+ "expiration": "2013-12-11T10:37:33.689275857-08:00",
+ "key": "/dir",
+ "modifiedIndex": 17,
+ "ttl": 30
+ }
+}
+```
+
+The directory's TTL can be refreshed by making an update.
+You can do this by making a PUT with `prevExist=true` and a new TTL.
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/dir -XPUT -d ttl=30 -d dir=true -d prevExist=true
+```
+
+Keys that are under this directory work as usual, but when the directory expires, a watcher on a key under the directory will get an expire event:
+
+```sh
+curl 'http://127.0.0.1:2379/v2/keys/dir?wait=true'
+```
+
+```json
+{
+ "action": "expire",
+ "node": {
+ "createdIndex": 8,
+ "key": "/dir",
+ "modifiedIndex": 15
+ },
+ "prevNode": {
+ "createdIndex": 8,
+ "key": "/dir",
+ "dir":true,
+ "modifiedIndex": 17,
+ "expiration": "2013-12-11T10:39:35.689275857-08:00"
+ }
+}
+```
+
+
+### Atomic Compare-and-Swap
+
+etcd can be used as a centralized coordination service in a cluster, and `CompareAndSwap` (CAS) is the most basic operation used to build a distributed lock service.
+
+This command will set the value of a key only if the client-provided conditions are equal to the current conditions.
+
+*Note that `CompareAndSwap` does not work with [directories][directories]. If an attempt is made to `CompareAndSwap` a directory, a 102 "Not a file" error will be returned.*
+
+The current comparable conditions are:
+
+1. `prevValue` - checks the previous value of the key.
+
+2. `prevIndex` - checks the previous modifiedIndex of the key.
+
+3. `prevExist` - checks existence of the key: if `prevExist` is true, it is an `update` request; if `prevExist` is `false`, it is a `create` request.
+
+Here is a simple example.
+Let's create a key-value pair first: `foo=one`.
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=one
+```
+
+```json
+{
+ "action":"set",
+ "node":{
+ "key":"/foo",
+ "value":"one",
+ "modifiedIndex":4,
+ "createdIndex":4
+ }
+}
+```
+
+Specifying `noValueOnSuccess` option skips returning the node as value.
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo?noValueOnSuccess=true -XPUT -d value=one
+# {"action":"set"}
+```
+
+Now let's try some invalid `CompareAndSwap` commands.
+
+Trying to set this existing key with `prevExist=false` fails as expected:
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo?prevExist=false -XPUT -d value=three
+```
+
+The error code explains the problem:
+
+```json
+{
+ "cause": "/foo",
+ "errorCode": 105,
+ "index": 39776,
+ "message": "Key already exists"
+}
+```
+
+Now let's provide a `prevValue` parameter:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo?prevValue=two -XPUT -d value=three
+```
+
+This will try to compare the previous value of the key and the previous value we provided. If they are equal, the value of the key will change to three.
+
+```json
+{
+ "cause": "[two != one]",
+ "errorCode": 101,
+ "index": 8,
+ "message": "Compare failed"
+}
+```
+
+which means `CompareAndSwap` failed. `cause` explains why the test failed.
+Note: the condition prevIndex=0 always passes.
+
+Let's try a valid condition:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo?prevValue=one -XPUT -d value=two
+```
+
+The response should be:
+
+```json
+{
+ "action": "compareAndSwap",
+ "node": {
+ "createdIndex": 8,
+ "key": "/foo",
+ "modifiedIndex": 9,
+ "value": "two"
+ },
+ "prevNode": {
+ "createdIndex": 8,
+ "key": "/foo",
+ "modifiedIndex": 8,
+ "value": "one"
+ }
+}
+```
+
+We successfully changed the value from "one" to "two" since we gave the correct previous value.
+
+### Atomic Compare-and-Delete
+
+This command will delete a key only if the client-provided conditions are equal to the current conditions.
+
+*Note that `CompareAndDelete` does not work with [directories]. If an attempt is made to `CompareAndDelete` a directory, a 102 "Not a file" error will be returned.*
+
+The current comparable conditions are:
+
+1. `prevValue` - checks the previous value of the key.
+
+2. `prevIndex` - checks the previous modifiedIndex of the key.
+
+Here is a simple example. Let's first create a key: `foo=one`.
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo -XPUT -d value=one
+```
+
+Now let's try some `CompareAndDelete` commands.
+
+Trying to delete the key with `prevValue=two` fails as expected:
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo?prevValue=two -XDELETE
+```
+
+The error code explains the problem:
+
+```json
+{
+ "errorCode": 101,
+ "message": "Compare failed",
+ "cause": "[two != one]",
+ "index": 8
+}
+```
+
+As does a `CompareAndDelete` with a mismatched `prevIndex`:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo?prevIndex=1 -XDELETE
+```
+
+```json
+{
+ "errorCode": 101,
+ "message": "Compare failed",
+ "cause": "[1 != 8]",
+ "index": 8
+}
+```
+
+And now a valid `prevValue` condition:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo?prevValue=one -XDELETE
+```
+
+The successful response will look something like:
+
+```json
+{
+ "action": "compareAndDelete",
+ "node": {
+ "key": "/foo",
+ "modifiedIndex": 9,
+ "createdIndex": 8
+ },
+ "prevNode": {
+ "key": "/foo",
+ "value": "one",
+ "modifiedIndex": 8,
+ "createdIndex": 8
+ }
+}
+```
+
+### Creating Directories
+
+In most cases, directories for a key are automatically created.
+But there are cases where you will want to create a directory or remove one.
+
+Creating a directory is just like a key except you cannot provide a value and must add the `dir=true` parameter.
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/dir -XPUT -d dir=true
+```
+```json
+{
+ "action": "set",
+ "node": {
+ "createdIndex": 30,
+ "dir": true,
+ "key": "/dir",
+ "modifiedIndex": 30
+ }
+}
+```
+
+
+### Listing a directory
+
+In etcd we can store two types of things: keys and directories.
+Keys store a single string value.
+Directories store a set of keys and/or other directories.
+
+In this example, let's first create some keys:
+
+We already have `/foo=two` so now we'll create another one called `/foo_dir/foo` with the value of `bar`:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/foo_dir/foo -XPUT -d value=bar
+```
+
+```json
+{
+ "action": "set",
+ "node": {
+ "createdIndex": 2,
+ "key": "/foo_dir/foo",
+ "modifiedIndex": 2,
+ "value": "bar"
+ }
+}
+```
+
+Now we can list the keys under root `/`:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/
+```
+
+We should see the response as an array of items:
+
+```json
+{
+ "action": "get",
+ "node": {
+ "key": "/",
+ "dir": true,
+ "nodes": [
+ {
+ "key": "/foo_dir",
+ "dir": true,
+ "modifiedIndex": 2,
+ "createdIndex": 2
+ },
+ {
+ "key": "/foo",
+ "value": "two",
+ "modifiedIndex": 1,
+ "createdIndex": 1
+ }
+ ]
+ }
+}
+```
+
+Here we can see `/foo` is a key-value pair under `/` and `/foo_dir` is a directory.
+We can also recursively get all the contents under a directory by adding `recursive=true`.
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/?recursive=true
+```
+
+```json
+{
+ "action": "get",
+ "node": {
+ "key": "/",
+ "dir": true,
+ "nodes": [
+ {
+ "key": "/foo_dir",
+ "dir": true,
+ "nodes": [
+ {
+ "key": "/foo_dir/foo",
+ "value": "bar",
+ "modifiedIndex": 2,
+ "createdIndex": 2
+ }
+ ],
+ "modifiedIndex": 2,
+ "createdIndex": 2
+ },
+ {
+ "key": "/foo",
+ "value": "two",
+ "modifiedIndex": 1,
+ "createdIndex": 1
+ }
+ ]
+ }
+}
+```
+
+
+### Deleting a Directory
+
+Now let's try to delete the directory `/foo_dir`.
+
+You can remove an empty directory using the `DELETE` verb and the `dir=true` parameter.
+
+```sh
+curl 'http://127.0.0.1:2379/v2/keys/foo_dir?dir=true' -XDELETE
+```
+```json
+{
+ "action": "delete",
+ "node": {
+ "createdIndex": 30,
+ "dir": true,
+ "key": "/foo_dir",
+ "modifiedIndex": 31
+ },
+ "prevNode": {
+ "createdIndex": 30,
+ "key": "/foo_dir",
+ "dir": true,
+ "modifiedIndex": 30
+ }
+}
+```
+
+To delete a directory that holds keys, you must add `recursive=true`.
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/dir?recursive=true -XDELETE
+```
+
+```json
+{
+ "action": "delete",
+ "node": {
+ "createdIndex": 10,
+ "dir": true,
+ "key": "/dir",
+ "modifiedIndex": 11
+ },
+ "prevNode": {
+ "createdIndex": 10,
+ "dir": true,
+ "key": "/dir",
+ "modifiedIndex": 10
+ }
+}
+```
+
+
+### Creating a hidden node
+
+We can create a hidden key-value pair or directory by add a `_` prefix.
+The hidden item will not be listed when sending a `GET` request for a directory.
+
+First we'll add a hidden key named `/_message`:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/_message -XPUT -d value="Hello hidden world"
+```
+
+```json
+{
+ "action": "set",
+ "node": {
+ "createdIndex": 3,
+ "key": "/_message",
+ "modifiedIndex": 3,
+ "value": "Hello hidden world"
+ }
+}
+```
+
+Next we'll add a regular key named `/message`:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/message -XPUT -d value="Hello world"
+```
+
+```json
+{
+ "action": "set",
+ "node": {
+ "createdIndex": 4,
+ "key": "/message",
+ "modifiedIndex": 4,
+ "value": "Hello world"
+ }
+}
+```
+
+Now let's try to get a listing of keys under the root directory, `/`:
+
+```sh
+curl http://127.0.0.1:2379/v2/keys/
+```
+
+```json
+{
+ "action": "get",
+ "node": {
+ "dir": true,
+ "key": "/",
+ "nodes": [
+ {
+ "createdIndex": 2,
+ "dir": true,
+ "key": "/foo_dir",
+ "modifiedIndex": 2
+ },
+ {
+ "createdIndex": 4,
+ "key": "/message",
+ "modifiedIndex": 4,
+ "value": "Hello world"
+ }
+ ]
+ }
+}
+```
+
+Here we see the `/message` key but our hidden `/_message` key is not returned.
+
+### Setting a key from a file
+
+You can also use etcd to store small configuration files, JSON documents, XML documents, etc directly.
+For example you can use curl to upload a simple text file and encode it:
+
+```
+echo "Hello\nWorld" > afile.txt
+curl http://127.0.0.1:2379/v2/keys/afile -XPUT --data-urlencode value@afile.txt
+```
+
+```json
+{
+ "action": "get",
+ "node": {
+ "createdIndex": 2,
+ "key": "/afile",
+ "modifiedIndex": 2,
+ "value": "Hello\nWorld\n"
+ }
+}
+```
+
+### Read Linearization
+
+If you want a read that is fully linearized you can use a `quorum=true` GET.
+The read will take a very similar path to a write and will have a similar
+speed. If you are unsure if you need this feature feel free to email etcd-dev
+for advice.
+
+## Statistics
+
+An etcd cluster keeps track of a number of statistics including latency, bandwidth and uptime.
+These are exposed via the statistics endpoint to understand the internal health of a cluster.
+
+### Leader Statistics
+
+The leader has a view of the entire cluster and keeps track of two interesting statistics: latency to each peer in the cluster, and the number of failed and successful Raft RPC requests.
+You can grab these statistics from the `/v2/stats/leader` endpoint:
+
+```sh
+curl http://127.0.0.1:2379/v2/stats/leader
+```
+
+```json
+{
+ "followers": {
+ "6e3bd23ae5f1eae0": {
+ "counts": {
+ "fail": 0,
+ "success": 745
+ },
+ "latency": {
+ "average": 0.017039507382550306,
+ "current": 0.000138,
+ "maximum": 1.007649,
+ "minimum": 0,
+ "standardDeviation": 0.05289178277920594
+ }
+ },
+ "a8266ecf031671f3": {
+ "counts": {
+ "fail": 0,
+ "success": 735
+ },
+ "latency": {
+ "average": 0.012124141496598642,
+ "current": 0.000559,
+ "maximum": 0.791547,
+ "minimum": 0,
+ "standardDeviation": 0.04187900156583733
+ }
+ }
+ },
+ "leader": "924e2e83e93f2560"
+}
+```
+
+
+### Self Statistics
+
+Each node keeps a number of internal statistics:
+
+- `id`: the unique identifier for the member
+- `leaderInfo.leader`: id of the current leader member
+- `leaderInfo.uptime`: amount of time the leader has been leader
+- `name`: this member's name
+- `recvAppendRequestCnt`: number of append requests this node has processed
+- `recvBandwidthRate`: number of bytes per second this node is receiving (follower only)
+- `recvPkgRate`: number of requests per second this node is receiving (follower only)
+- `sendAppendRequestCnt`: number of requests that this node has sent
+- `sendBandwidthRate`: number of bytes per second this node is sending (leader only). This value is undefined on single member clusters.
+- `sendPkgRate`: number of requests per second this node is sending (leader only). This value is undefined on single member clusters.
+- `state`: either leader or follower
+- `startTime`: the time when this node was started
+
+This is an example response from a follower member:
+
+```sh
+curl http://127.0.0.1:2379/v2/stats/self
+```
+
+```json
+{
+ "id": "eca0338f4ea31566",
+ "leaderInfo": {
+ "leader": "8a69d5f6b7814500",
+ "startTime": "2014-10-24T13:15:51.186620747-07:00",
+ "uptime": "10m59.322358947s"
+ },
+ "name": "node3",
+ "recvAppendRequestCnt": 5944,
+ "recvBandwidthRate": 570.6254930219969,
+ "recvPkgRate": 9.00892789741075,
+ "sendAppendRequestCnt": 0,
+ "startTime": "2014-10-24T13:15:50.072007085-07:00",
+ "state": "StateFollower"
+}
+```
+
+And this is an example response from a leader member:
+
+```sh
+curl http://127.0.0.1:2379/v2/stats/self
+```
+
+```json
+{
+ "id": "924e2e83e93f2560",
+ "leaderInfo": {
+ "leader": "924e2e83e93f2560",
+ "startTime": "2015-02-09T11:38:30.177534688-08:00",
+ "uptime": "9m33.891343412s"
+ },
+ "name": "infra3",
+ "recvAppendRequestCnt": 0,
+ "sendAppendRequestCnt": 6535,
+ "sendBandwidthRate": 824.1758351191694,
+ "sendPkgRate": 11.111234716807138,
+ "startTime": "2015-02-09T11:38:28.972034204-08:00",
+ "state": "StateLeader"
+}
+```
+
+
+### Store Statistics
+
+The store statistics include information about the operations that this node has handled.
+Note that v2 `store Statistics` is stored in-memory. When a member stops, store statistics will reset on restart.
+
+Operations that modify the store's state like create, delete, set and update are seen by the entire cluster and the number will increase on all nodes.
+Operations like get and watch are node local and will only be seen on this node.
+
+```sh
+curl http://127.0.0.1:2379/v2/stats/store
+```
+
+```json
+{
+ "compareAndSwapFail": 0,
+ "compareAndSwapSuccess": 0,
+ "createFail": 0,
+ "createSuccess": 2,
+ "deleteFail": 0,
+ "deleteSuccess": 0,
+ "expireCount": 0,
+ "getsFail": 4,
+ "getsSuccess": 75,
+ "setsFail": 2,
+ "setsSuccess": 4,
+ "updateFail": 0,
+ "updateSuccess": 0,
+ "watchers": 0
+}
+```
+
+## Cluster Config
+
+See the [members API][members-api] for details on the cluster management.
+
+[directories]: #listing-a-directory
+[members-api]: members_api.md
+[tuning]: tuning.md
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/api_v3.md b/vendor/github.com/coreos/etcd/Documentation/v2/api_v3.md
new file mode 100644
index 00000000..e59a04e7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/api_v3.md
@@ -0,0 +1,97 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# etcd3 API
+
+TODO: API doc
+
+## Data Model
+
+etcd is designed to reliably store infrequently updated data and provide reliable watch queries. etcd exposes previous versions of key-value pairs to support inexpensive snapshots and watch history events (?time travel queries?). A persistent, multi-version, concurrency-control data model is a good fit for these use cases.
+
+etcd stores data in a multiversion [persistent][persistent-ds] key-value store. The persistent key-value store preserves the previous version of a key-value pair when its value is superseded with new data. The key-value store is effectively immutable; its operations do not update the structure in-place, but instead always generates a new updated structure. All past versions of keys are still accessible and watchable after modification. To prevent the data store from growing indefinitely over time from maintaining old versions, the store may be compacted to shed the oldest versions of superseded data.
+
+### Logical View
+
+The store?s logical view is a flat binary key space. The key space has a lexically sorted index on byte string keys so range queries are inexpensive.
+
+The key space maintains multiple revisions. Each atomic mutative operation (e.g., a transaction operation may contain multiple operations) creates a new revision on the key space. All data held by previous revisions remains unchanged. Old versions of key can still be accessed through previous revisions. Likewise, revisions are indexed as well; ranging over revisions with watchers is efficient. If the store is compacted to recover space, revisions before the compact revision will be removed.
+
+A key?s lifetime spans a generation. Each key may have one or multiple generations. Creating a key increments the generation of that key, starting at 1 if the key never existed. Deleting a key generates a key tombstone, concluding the key?s current generation. Each modification of a key creates a new version of the key. Once a compaction happens, any generation ended before the given revision will be removed and values set before the compaction revision except the latest one will be removed.
+
+### Physical View
+
+etcd stores the physical data as key-value pairs in a persistent [b+tree][b+tree]. Each revision of the store?s state only contains the delta from its previous revision to be efficient. A single revision may correspond to multiple keys in the tree.
+
+The key of key-value pair is a 3-tuple (major, sub, type). Major is the store revision holding the key. Sub differentiates among keys within the same revision. Type is an optional suffix for special value (e.g., `t` if the value contains a tombstone). The value of the key-value pair contains the modification from previous revision, thus one delta from previous revision. The b+tree is ordered by key in lexical byte-order. Ranged lookups over revision deltas are fast; this enables quickly finding modifications from one specific revision to another. Compaction removes out-of-date keys-value pairs.
+
+etcd also keeps a secondary in-memory [btree][btree] index to speed up range queries over keys. The keys in the btree index are the keys of the store exposed to user. The value is a pointer to the modification of the persistent b+tree. Compaction removes dead pointers.
+
+## KV API Guarantees
+
+etcd is a consistent and durable key value store with mini-transaction(TODO: link to txn doc when we have it) support. The key value store is exposed through the KV APIs. etcd tries to ensure the strongest consistency and durability guarantees for a distributed system. This specification enumerates the KV API guarantees made by etcd.
+
+### APIs to consider
+
+* Read APIs
+ * range
+ * watch
+* Write APIs
+ * put
+ * delete
+* Combination (read-modify-write) APIs
+ * txn
+
+### etcd Specific Definitions
+
+#### operation completed
+
+An etcd operation is considered complete when it is committed through consensus, and therefore ?executed? -- permanently stored -- by the etcd storage engine. The client knows an operation is completed when it receives a response from the etcd server. Note that the client may be uncertain about the status of an operation if it times out, or there is a network disruption between the client and the etcd member. etcd may also abort operations when there is a leader election. etcd does not send `abort` responses to clients? outstanding requests in this event.
+
+#### revision
+
+An etcd operation that modifies the key value store is assigned with a single increasing revision. A transaction operation might modify the key value store multiple times, but only one revision is assigned. The revision attribute of a key value pair that modified by the operation has the same value as the revision of the operation. The revision can be used as a logical clock for key value store. A key value pair that has a larger revision is modified after a key value pair with a smaller revision. Two key value pairs that have the same revision are modified by an operation "concurrently".
+
+### Guarantees Provided
+
+#### Atomicity
+
+All API requests are atomic; an operation either completes entirely or not at all. For watch requests, all events generated by one operation will be in one watch response. Watch never observes partial events for a single operation.
+
+#### Consistency
+
+All API calls ensure [sequential consistency][seq_consistency], the strongest consistency guarantee available from distributed systems. No matter which etcd member server a client makes requests to, a client reads the same events in the same order. If two members complete the same number of operations, the state of the two members is consistent.
+
+For watch operations, etcd guarantees to return the same value for the same key across all members for the same revision. For range operations, etcd has a similar guarantee for [linearized][Linearizability] access; serialized access may be behind the quorum state, so that the later revision is not yet available.
+
+As with all distributed systems, it is impossible for etcd to ensure [strict consistency][strict_consistency]. etcd does not guarantee that it will return to a read the ?most recent? value (as measured by a wall clock when a request is completed) available on any cluster member.
+
+#### Isolation
+
+etcd ensures [serializable isolation][serializable_isolation], which is the highest isolation level available in distributed systems. Read operations will never observe any intermediate data.
+
+#### Durability
+
+Any completed operations are durable. All accessible data is also durable data. A read will never return data that has not been made durable.
+
+#### Linearizability
+
+Linearizability (also known as Atomic Consistency or External Consistency) is a consistency level between strict consistency and sequential consistency.
+
+For linearizability, suppose each operation receives a timestamp from a loosely synchronized global clock. Operations are linearized if and only if they always complete as though they were executed in a sequential order and each operation appears to complete in the order specified by the program. Likewise, if an operation?s timestamp precedes another, that operation must also precede the other operation in the sequence.
+
+For example, consider a client completing a write at time point 1 (*t1*). A client issuing a read at *t2* (for *t2* > *t1*) should receive a value at least as recent as the previous write, completed at *t1*. However, the read might actually complete only by *t3*, and the returned value, current at *t2* when the read began, might be "stale" by *t3*.
+
+etcd does not ensure linearizability for watch operations. Users are expected to verify the revision of watch responses to ensure correct ordering.
+
+etcd ensures linearizability for all other operations by default. Linearizability comes with a cost, however, because linearized requests must go through the Raft consensus process. To obtain lower latencies and higher throughput for read requests, clients can configure a request?s consistency mode to `serializable`, which may access stale data with respect to quorum, but removes the performance penalty of linearized accesses' reliance on live consensus.
+
+[persistent-ds]: https://en.wikipedia.org/wiki/Persistent_data_structure
+[btree]: https://en.wikipedia.org/wiki/B-tree
+[b+tree]: https://en.wikipedia.org/wiki/B%2B_tree
+[seq_consistency]: https://en.wikipedia.org/wiki/Consistency_model#Sequential_consistency
+[strict_consistency]: https://en.wikipedia.org/wiki/Consistency_model#Strict_consistency
+[serializable_isolation]: https://en.wikipedia.org/wiki/Isolation_(database_systems)#Serializable
+[Linearizability]: #linearizability
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/auth_api.md b/vendor/github.com/coreos/etcd/Documentation/v2/auth_api.md
new file mode 100644
index 00000000..225ba3a6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/auth_api.md
@@ -0,0 +1,516 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# v2 Auth and Security
+
+## etcd Resources
+There are three types of resources in etcd
+
+1. permission resources: users and roles in the user store
+2. key-value resources: key-value pairs in the key-value store
+3. settings resources: security settings, auth settings, and dynamic etcd cluster settings (election/heartbeat)
+
+### Permission Resources
+
+#### Users
+A user is an identity to be authenticated. Each user can have multiple roles. The user has a capability (such as reading or writing) on the resource if one of the roles has that capability.
+
+A user named `root` is required before authentication can be enabled, and it always has the ROOT role. The ROOT role can be granted to multiple users, but `root` is required for recovery purposes.
+
+#### Roles
+Each role has exact one associated Permission List. An permission list exists for each permission on key-value resources.
+
+The special static ROOT (named `root`) role has a full permissions on all key-value resources, the permission to manage user resources and settings resources. Only the ROOT role has the permission to manage user resources and modify settings resources. The ROOT role is built-in and does not need to be created.
+
+There is also a special GUEST role, named 'guest'. These are the permissions given to unauthenticated requests to etcd. This role will be created automatically, and by default allows access to the full keyspace due to backward compatibility. (etcd did not previously authenticate any actions.). This role can be modified by a ROOT role holder at any time, to reduce the capabilities of unauthenticated users.
+
+#### Permissions
+
+There are two types of permissions, `read` and `write`. All management and settings require the ROOT role.
+
+A Permission List is a list of allowed patterns for that particular permission (read or write). Only ALLOW prefixes are supported. DENY becomes more complicated and is TBD.
+
+### Key-Value Resources
+A key-value resource is a key-value pairs in the store. Given a list of matching patterns, permission for any given key in a request is granted if any of the patterns in the list match.
+
+Only prefixes or exact keys are supported. A prefix permission string ends in `*`.
+A permission on `/foo` is for that exact key or directory, not its children or recursively. `/foo*` is a prefix that matches `/foo` recursively, and all keys thereunder, and keys with that prefix (eg. `/foobar`. Contrast to the prefix `/foo/*`). `*` alone is permission on the full keyspace.
+
+### Settings Resources
+
+Specific settings for the cluster as a whole. This can include adding and removing cluster members, enabling or disabling authentication, replacing certificates, and any other dynamic configuration by the administrator (holder of the ROOT role).
+
+## v2 Auth
+
+### Basic Auth
+We only support [Basic Auth][basic-auth] for the first version. Client needs to attach the basic auth to the HTTP Authorization Header.
+
+### Authorization field for operations
+Added to requests to /v2/keys, /v2/auth
+Add code 401 Unauthorized to the set of responses from the v2 API
+Authorization: Basic {encoded string}
+
+### Future Work
+Other types of auth can be considered for the future (eg, signed certs, public keys) but the `Authorization:` header allows for other such types
+
+### Things out of Scope for etcd Permissions
+
+* Pluggable AUTH backends like LDAP (other Authorization tokens generated by LDAP et al may be a possibility)
+* Very fine-grained access controls (eg: users modifying keys outside work hours)
+
+
+
+## API endpoints
+
+An Error JSON corresponds to:
+{
+ "name": "ErrErrorName",
+ "description" : "The longer helpful description of the error."
+}
+
+#### Enable and Disable Authentication
+
+**Get auth status**
+
+GET /v2/auth/enable
+
+ Sent Headers:
+ Possible Status Codes:
+ 200 OK
+ 200 Body:
+ {
+ "enabled": true
+ }
+
+
+**Enable auth**
+
+PUT /v2/auth/enable
+
+ Sent Headers:
+ Put Body: (empty)
+ Possible Status Codes:
+ 200 OK
+ 400 Bad Request (if root user has not been created)
+ 409 Conflict (already enabled)
+ 200 Body: (empty)
+
+**Disable auth**
+
+DELETE /v2/auth/enable
+
+ Sent Headers:
+ Authorization: Basic <RootAuthString>
+ Possible Status Codes:
+ 200 OK
+ 401 Unauthorized (if not a root user)
+ 409 Conflict (already disabled)
+ 200 Body: (empty)
+
+
+#### Users
+
+The User JSON object is formed as follows:
+
+```
+{
+ "user": "userName",
+ "password": "password",
+ "roles": [
+ "role1",
+ "role2"
+ ],
+ "grant": [],
+ "revoke": []
+}
+```
+
+Password is only passed when necessary.
+
+**Get a List of Users**
+
+GET/HEAD /v2/auth/users
+
+ Sent Headers:
+ Authorization: Basic <BasicAuthString>
+ Possible Status Codes:
+ 200 OK
+ 401 Unauthorized
+ 200 Headers:
+ Content-type: application/json
+ 200 Body:
+ {
+ "users": [
+ {
+ "user": "alice",
+ "roles": [
+ {
+ "role": "root",
+ "permissions": {
+ "kv": {
+ "read": ["/*"],
+ "write": ["/*"]
+ }
+ }
+ }
+ ]
+ },
+ {
+ "user": "bob",
+ "roles": [
+ {
+ "role": "guest",
+ "permissions": {
+ "kv": {
+ "read": ["/*"],
+ "write": ["/*"]
+ }
+ }
+ }
+ ]
+ }
+ ]
+ }
+
+**Get User Details**
+
+GET/HEAD /v2/auth/users/alice
+
+ Sent Headers:
+ Authorization: Basic <BasicAuthString>
+ Possible Status Codes:
+ 200 OK
+ 401 Unauthorized
+ 404 Not Found
+ 200 Headers:
+ Content-type: application/json
+ 200 Body:
+ {
+ "user" : "alice",
+ "roles" : [
+ {
+ "role": "fleet",
+ "permissions" : {
+ "kv" : {
+ "read": [ "/fleet/" ],
+ "write": [ "/fleet/" ]
+ }
+ }
+ },
+ {
+ "role": "etcd",
+ "permissions" : {
+ "kv" : {
+ "read": [ "/*" ],
+ "write": [ "/*" ]
+ }
+ }
+ }
+ ]
+ }
+
+**Create Or Update A User**
+
+A user can be created with initial roles, if filled in. However, no roles are required; only the username and password fields
+
+PUT /v2/auth/users/charlie
+
+ Sent Headers:
+ Authorization: Basic <BasicAuthString>
+ Put Body:
+ JSON struct, above, matching the appropriate name
+ * Starting password and roles when creating.
+ * Grant/Revoke/Password filled in when updating (to grant roles, revoke roles, or change the password).
+ Possible Status Codes:
+ 200 OK
+ 201 Created
+ 400 Bad Request
+ 401 Unauthorized
+ 404 Not Found (update non-existent users)
+ 409 Conflict (when granting duplicated roles or revoking non-existent roles)
+ 200 Headers:
+ Content-type: application/json
+ 200 Body:
+ JSON state of the user
+
+**Remove A User**
+
+DELETE /v2/auth/users/charlie
+
+ Sent Headers:
+ Authorization: Basic <BasicAuthString>
+ Possible Status Codes:
+ 200 OK
+ 401 Unauthorized
+ 403 Forbidden (remove root user when auth is enabled)
+ 404 Not Found
+ 200 Headers:
+ 200 Body: (empty)
+
+#### Roles
+
+A full role structure may look like this. A Permission List structure is used for the "permissions", "grant", and "revoke" keys.
+```
+{
+ "role" : "fleet",
+ "permissions" : {
+ "kv" : {
+ "read" : [ "/fleet/" ],
+ "write": [ "/fleet/" ]
+ }
+ },
+ "grant" : {"kv": {...}},
+ "revoke": {"kv": {...}}
+}
+```
+
+**Get Role Details**
+
+GET/HEAD /v2/auth/roles/fleet
+
+ Sent Headers:
+ Authorization: Basic <BasicAuthString>
+ Possible Status Codes:
+ 200 OK
+ 401 Unauthorized
+ 404 Not Found
+ 200 Headers:
+ Content-type: application/json
+ 200 Body:
+ {
+ "role" : "fleet",
+ "permissions" : {
+ "kv" : {
+ "read": [ "/fleet/" ],
+ "write": [ "/fleet/" ]
+ }
+ }
+ }
+
+**Get a list of Roles**
+
+GET/HEAD /v2/auth/roles
+
+ Sent Headers:
+ Authorization: Basic <BasicAuthString>
+ Possible Status Codes:
+ 200 OK
+ 401 Unauthorized
+ 200 Headers:
+ Content-type: application/json
+ 200 Body:
+ {
+ "roles": [
+ {
+ "role": "fleet",
+ "permissions": {
+ "kv": {
+ "read": ["/fleet/"],
+ "write": ["/fleet/"]
+ }
+ }
+ },
+ {
+ "role": "etcd",
+ "permissions": {
+ "kv": {
+ "read": ["/*"],
+ "write": ["/*"]
+ }
+ }
+ },
+ {
+ "role": "quay",
+ "permissions": {
+ "kv": {
+ "read": ["/*"],
+ "write": ["/*"]
+ }
+ }
+ }
+ ]
+ }
+
+**Create Or Update A Role**
+
+PUT /v2/auth/roles/rkt
+
+ Sent Headers:
+ Authorization: Basic <BasicAuthString>
+ Put Body:
+ Initial desired JSON state, including the role name for verification and:
+ * Starting permission set if creating
+ * Granted/Revoked permission set if updating
+ Possible Status Codes:
+ 200 OK
+ 201 Created
+ 400 Bad Request
+ 401 Unauthorized
+ 404 Not Found (update non-existent roles)
+ 409 Conflict (when granting duplicated permission or revoking non-existent permission)
+ 200 Body:
+ JSON state of the role
+
+**Remove A Role**
+
+DELETE /v2/auth/roles/rkt
+
+ Sent Headers:
+ Authorization: Basic <BasicAuthString>
+ Possible Status Codes:
+ 200 OK
+ 401 Unauthorized
+ 403 Forbidden (remove root)
+ 404 Not Found
+ 200 Headers:
+ 200 Body: (empty)
+
+
+## Example Workflow
+
+Let's walk through an example to show two tenants (applications, in our case) using etcd permissions.
+
+### Create root role
+
+```
+PUT /v2/auth/users/root
+ Put Body:
+ {"user" : "root", "password": "betterRootPW!"}
+```
+
+### Enable auth
+
+```
+PUT /v2/auth/enable
+```
+
+### Modify guest role (revoke write permission)
+
+```
+PUT /v2/auth/roles/guest
+ Headers:
+ Authorization: Basic <root:betterRootPW!>
+ Put Body:
+ {
+ "role" : "guest",
+ "revoke" : {
+ "kv" : {
+ "write": [
+ "/*"
+ ]
+ }
+ }
+ }
+```
+
+
+### Create Roles for the Applications
+
+Create the rkt role fully specified:
+
+```
+PUT /v2/auth/roles/rkt
+ Headers:
+ Authorization: Basic <root:betterRootPW!>
+ Body:
+ {
+ "role" : "rkt",
+ "permissions" : {
+ "kv": {
+ "read": [
+ "/rkt/*"
+ ],
+ "write": [
+ "/rkt/*"
+ ]
+ }
+ }
+ }
+```
+
+But let's make fleet just a basic role for now:
+
+```
+PUT /v2/auth/roles/fleet
+ Headers:
+ Authorization: Basic <root:betterRootPW!>
+ Body:
+ {
+ "role" : "fleet"
+ }
+```
+
+### Optional: Grant some permissions to the roles
+
+Well, we finally figured out where we want fleet to live. Let's fix it.
+(Note that we avoided this in the rkt case. So this step is optional.)
+
+
+```
+PUT /v2/auth/roles/fleet
+ Headers:
+ Authorization: Basic <root:betterRootPW!>
+ Put Body:
+ {
+ "role" : "fleet",
+ "grant" : {
+ "kv" : {
+ "read": [
+ "/rkt/fleet",
+ "/fleet/*"
+ ]
+ }
+ }
+ }
+```
+
+### Create Users
+
+Same as before, let's use rocket all at once and fleet separately
+
+```
+PUT /v2/auth/users/rktuser
+ Headers:
+ Authorization: Basic <root:betterRootPW!>
+ Body:
+ {"user" : "rktuser", "password" : "rktpw", "roles" : ["rkt"]}
+```
+
+```
+PUT /v2/auth/users/fleetuser
+ Headers:
+ Authorization: Basic <root:betterRootPW!>
+ Body:
+ {"user" : "fleetuser", "password" : "fleetpw"}
+```
+
+### Optional: Grant Roles to Users
+
+Likewise, let's explicitly grant fleetuser access.
+
+```
+PUT /v2/auth/users/fleetuser
+ Headers:
+ Authorization: Basic <root:betterRootPW!>
+ Body:
+ {"user": "fleetuser", "grant": ["fleet"]}
+```
+
+#### Start to use fleetuser and rktuser
+
+
+For example:
+
+```
+PUT /v2/keys/rkt/RktData
+ Headers:
+ Authorization: Basic <rktuser:rktpw>
+ Body:
+ value=launch
+```
+
+Reads and writes outside the prefixes granted will fail with a 401 Unauthorized.
+
+[basic-auth]: https://en.wikipedia.org/wiki/Basic_access_authentication
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/authentication.md b/vendor/github.com/coreos/etcd/Documentation/v2/authentication.md
new file mode 100644
index 00000000..05adf060
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/authentication.md
@@ -0,0 +1,185 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Authentication Guide
+
+## Overview
+
+Authentication -- having users and roles in etcd -- was added in etcd 2.1. This guide will help you set up basic authentication in etcd.
+
+etcd before 2.1 was a completely open system; anyone with access to the API could change keys. In order to preserve backward compatibility and upgradability, this feature is off by default.
+
+For a full discussion of the RESTful API, see [the authentication API documentation][auth-api]
+
+## Special Users and Roles
+
+There is one special user, `root`, and there are two special roles, `root` and `guest`.
+
+### User `root`
+
+User `root` must be created before security can be activated. It has the `root` role and allows for the changing of anything inside etcd. The idea behind the `root` user is for recovery purposes -- a password is generated and stored somewhere -- and the root role is granted to the administrator accounts on the system. In the future, for troubleshooting and recovery, we will need to assume some access to the system, and future documentation will assume this root user (though anyone with the role will suffice).
+
+### Role `root`
+
+Role `root` cannot be modified, but it may be granted to any user. Having access via the root role not only allows global read-write access (as was the case before 2.1) but allows modification of the authentication policy and all administrative things, like modifying the cluster membership.
+
+### Role `guest`
+
+The `guest` role defines the permissions granted to any request that does not provide an authentication. This will be created on security activation (if it doesn't already exist) to have full access to all keys, as was true in etcd 2.0. It may be modified at any time, and cannot be removed.
+
+## Working with users
+
+The `user` subcommand for `etcdctl` handles all things having to do with user accounts.
+
+A listing of users can be found with
+
+```
+$ etcdctl user list
+```
+
+Creating a user is as easy as
+
+```
+$ etcdctl user add myusername
+```
+
+And there will be prompt for a new password.
+
+Roles can be granted and revoked for a user with
+
+```
+$ etcdctl user grant myusername -roles foo,bar,baz
+$ etcdctl user revoke myusername -roles bar,baz
+```
+
+We can look at this user with
+
+```
+$ etcdctl user get myusername
+```
+
+And the password for a user can be changed with
+
+```
+$ etcdctl user passwd myusername
+```
+
+Which will prompt again for a new password.
+
+To delete an account, there's always
+```
+$ etcdctl user remove myusername
+```
+
+
+## Working with roles
+
+The `role` subcommand for `etcdctl` handles all things having to do with access controls for particular roles, as were granted to individual users.
+
+A listing of roles can be found with
+
+```
+$ etcdctl role list
+```
+
+A new role can be created with
+
+```
+$ etcdctl role add myrolename
+```
+
+A role has no password; we are merely defining a new set of access rights.
+
+Roles are granted access to various parts of the keyspace, a single path at a time.
+
+Reading a path is simple; if the path ends in `*`, that key **and all keys prefixed with it**, are granted to holders of this role. If it does not end in `*`, only that key and that key alone is granted.
+
+Access can be granted as either read, write, or both, as in the following examples:
+
+```
+# Give read access to keys under the /foo directory
+$ etcdctl role grant myrolename -path '/foo/*' -read
+
+# Give write-only access to the key at /foo/bar
+$ etcdctl role grant myrolename -path '/foo/bar' -write
+
+# Give full access to keys under /pub
+$ etcdctl role grant myrolename -path '/pub/*' -readwrite
+```
+
+Beware that
+
+```
+# Give full access to keys under /pub??
+$ etcdctl role grant myrolename -path '/pub*' -readwrite
+```
+
+Without the slash may include keys under `/publishing`, for example. To do both, grant `/pub` and `/pub/*`
+
+To see what's granted, we can look at the role at any time:
+
+```
+$ etcdctl role get myrolename
+```
+
+Revocation of permissions is done the same logical way:
+
+```
+$ etcdctl role revoke myrolename -path '/foo/bar' -write
+```
+
+As is removing a role entirely
+
+```
+$ etcdctl role remove myrolename
+```
+
+## Enabling authentication
+
+The minimal steps to enabling auth are as follows. The administrator can set up users and roles before or after enabling authentication, as a matter of preference.
+
+Make sure the root user is created:
+
+```
+$ etcdctl user add root
+New password:
+```
+
+And enable authentication
+
+```
+$ etcdctl auth enable
+```
+
+After this, etcd is running with authentication enabled. To disable it for any reason, use the reciprocal command:
+
+```
+$ etcdctl -u root:rootpw auth disable
+```
+
+It would also be good to check what guests (unauthenticated users) are allowed to do:
+```
+$ etcdctl -u root:rootpw role get guest
+```
+
+And modify this role appropriately, depending on your policies.
+
+## Using `etcdctl` to authenticate
+
+`etcdctl` supports a similar flag as `curl` for authentication.
+
+```
+$ etcdctl -u user:password get foo
+```
+
+or if you prefer to be prompted:
+
+```
+$ etcdctl -u user get foo
+```
+
+Otherwise, all `etcdctl` commands remain the same. Users and roles can still be created and modified, but require authentication by a user with the root role.
+
+[auth-api]: auth_api.md
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/backward_compatibility.md b/vendor/github.com/coreos/etcd/Documentation/v2/backward_compatibility.md
new file mode 100644
index 00000000..3704325e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/backward_compatibility.md
@@ -0,0 +1,77 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Backward Compatibility
+
+The main goal of etcd 2.0 release is to improve cluster safety around bootstrapping and dynamic reconfiguration. To do this, we deprecated the old error-prone APIs and provide a new set of APIs.
+
+The other main focus of this release was a more reliable Raft implementation, but as this change is internal it should not have any notable effects to users.
+
+## Command Line Flags Changes
+
+The major flag changes are to mostly related to bootstrapping. The `initial-*` flags provide an improved way to specify the required criteria to start the cluster. The advertised URLs now support a list of values instead of a single value, which allows etcd users to gracefully migrate to the new set of IANA-assigned ports (2379/client and 2380/peers) while maintaining backward compatibility with the old ports.
+
+ - `-addr` is replaced by `-advertise-client-urls`.
+ - `-bind-addr` is replaced by `-listen-client-urls`.
+ - `-peer-addr` is replaced by `-initial-advertise-peer-urls`.
+ - `-peer-bind-addr` is replaced by `-listen-peer-urls`.
+ - `-peers` is replaced by `-initial-cluster`.
+ - `-peers-file` is replaced by `-initial-cluster`.
+ - `-peer-heartbeat-interval` is replaced by `-heartbeat-interval`.
+ - `-peer-election-timeout` is replaced by `-election-timeout`.
+
+The documentation of new command line flags can be found at
+https://github.com/coreos/etcd/blob/master/Documentation/v2/configuration.md.
+
+## Data Directory Naming
+
+The default data dir location has changed from {$hostname}.etcd to {name}.etcd.
+
+## Key-Value API
+
+### Read consistency flag
+
+The consistent flag for read operations is removed in etcd 2.0.0. The normal read operations provides the same consistency guarantees with the 0.4.6 read operations with consistent flag set.
+
+The read consistency guarantees are:
+
+The consistent read guarantees the sequential consistency within one client that talks to one etcd server. Read/Write from one client to one etcd member should be observed in order. If one client write a value to an etcd server successfully, it should be able to get the value out of the server immediately.
+
+Each etcd member will proxy the request to leader and only return the result to user after the result is applied on the local member. Thus after the write succeed, the user is guaranteed to see the value on the member it sent the request to.
+
+Reads do not provide linearizability. If you want linearizable read, you need to set quorum option to true.
+
+**Previous behavior**
+
+We added an option for a consistent read in the old version of etcd since etcd 0.x redirects the write request to the leader. When the user get back the result from the leader, the member it sent the request to originally might not apply the write request yet. With the consistent flag set to true, the client will always send read request to the leader. So one client should be able to see its last write when consistent=true is enabled. There is no order guarantees among different clients.
+
+
+## Standby
+
+etcd 0.4?s standby mode has been deprecated. [Proxy mode][proxymode] is introduced to solve a subset of problems standby was solving.
+
+Standby mode was intended for large clusters that had a subset of the members acting in the consensus process. Overall this process was too magical and allowed for operators to back themselves into a corner.
+
+Proxy mode in 2.0 will provide similar functionality, and with improved control over which machines act as proxies due to the operator specifically configuring them. Proxies also support read only or read/write modes for increased security and durability.
+
+[proxymode]: proxy.md
+
+## Discovery Service
+
+A size key needs to be provided inside a [discovery token][discoverytoken].
+
+[discoverytoken]: clustering.md#custom-etcd-discovery-service
+
+## HTTP Admin API
+
+`v2/admin` on peer url and `v2/keys/_etcd` are unified under the new [v2/members API][members-api] to better explain which machines are part of an etcd cluster, and to simplify the keyspace for all your use cases.
+
+[members-api]: members_api.md
+
+## HTTP Key Value API
+- The follower can now transparently proxy write requests to the leader. Clients will no longer see 307 redirections to the leader from etcd.
+
+- Expiration time is in UTC instead of local time.
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/README.md b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/README.md
new file mode 100644
index 00000000..881641a7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/README.md
@@ -0,0 +1,23 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../../docs.md#documentation
+
+
+# Benchmarks
+
+etcd benchmarks will be published regularly and tracked for each release below:
+
+- [etcd v2.1.0-alpha][2.1]
+- [etcd v2.2.0-rc][2.2]
+- [etcd v3 demo][3.0]
+
+# Memory Usage Benchmarks
+
+It records expected memory usage in different scenarios.
+
+- [etcd v2.2.0-rc][2.2-mem]
+
+[2.1]: etcd-2-1-0-alpha-benchmarks.md
+[2.2]: etcd-2-2-0-rc-benchmarks.md
+[2.2-mem]: etcd-2-2-0-rc-memory-benchmarks.md
+[3.0]: etcd-3-demo-benchmarks.md
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-2-1-0-alpha-benchmarks.md b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-2-1-0-alpha-benchmarks.md
new file mode 100644
index 00000000..1fc808ec
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-2-1-0-alpha-benchmarks.md
@@ -0,0 +1,57 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../../docs.md#documentation
+
+
+## Physical machines
+
+GCE n1-highcpu-2 machine type
+
+- 1x dedicated local SSD mounted under /var/lib/etcd
+- 1x dedicated slow disk for the OS
+- 1.8 GB memory
+- 2x CPUs
+- etcd version 2.1.0 alpha
+
+## etcd Cluster
+
+3 etcd members, each runs on a single machine
+
+## Testing
+
+Bootstrap another machine and use the [boom HTTP benchmark tool][boom] to send requests to each etcd member. Check the [benchmark hacking guide][hack-benchmark] for detailed instructions.
+
+## Performance
+
+### reading one single key
+
+| key size in bytes | number of clients | target etcd server | read QPS | 90th Percentile Latency (ms) |
+|-------------------|-------------------|--------------------|----------|---------------|
+| 64 | 1 | leader only | 1534 | 0.7 |
+| 64 | 64 | leader only | 10125 | 9.1 |
+| 64 | 256 | leader only | 13892 | 27.1 |
+| 256 | 1 | leader only | 1530 | 0.8 |
+| 256 | 64 | leader only | 10106 | 10.1 |
+| 256 | 256 | leader only | 14667 | 27.0 |
+| 64 | 64 | all servers | 24200 | 3.9 |
+| 64 | 256 | all servers | 33300 | 11.8 |
+| 256 | 64 | all servers | 24800 | 3.9 |
+| 256 | 256 | all servers | 33000 | 11.5 |
+
+### writing one single key
+
+| key size in bytes | number of clients | target etcd server | write QPS | 90th Percentile Latency (ms) |
+|-------------------|-------------------|--------------------|-----------|---------------|
+| 64 | 1 | leader only | 60 | 21.4 |
+| 64 | 64 | leader only | 1742 | 46.8 |
+| 64 | 256 | leader only | 3982 | 90.5 |
+| 256 | 1 | leader only | 58 | 20.3 |
+| 256 | 64 | leader only | 1770 | 47.8 |
+| 256 | 256 | leader only | 4157 | 105.3 |
+| 64 | 64 | all servers | 1028 | 123.4 |
+| 64 | 256 | all servers | 3260 | 123.8 |
+| 256 | 64 | all servers | 1033 | 121.5 |
+| 256 | 256 | all servers | 3061 | 119.3 |
+
+[boom]: https://github.com/rakyll/boom
+[hack-benchmark]: ../../../hack/benchmark/
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-2-2-0-benchmarks.md b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-2-2-0-benchmarks.md
new file mode 100644
index 00000000..2989c1a7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-2-2-0-benchmarks.md
@@ -0,0 +1,77 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../../docs.md#documentation
+
+
+# Benchmarking etcd v2.2.0
+
+## Physical Machines
+
+GCE n1-highcpu-2 machine type
+
+- 1x dedicated local SSD mounted as etcd data directory
+- 1x dedicated slow disk for the OS
+- 1.8 GB memory
+- 2x CPUs
+
+## etcd Cluster
+
+3 etcd 2.2.0 members, each runs on a single machine.
+
+Detailed versions:
+
+```
+etcd Version: 2.2.0
+Git SHA: e4561dd
+Go Version: go1.5
+Go OS/Arch: linux/amd64
+```
+
+## Testing
+
+Bootstrap another machine, outside of the etcd cluster, and run the [`boom` HTTP benchmark tool][boom] with a connection reuse patch to send requests to each etcd cluster member. See the [benchmark instructions][hack] for the patch and the steps to reproduce our procedures.
+
+The performance is calulated through results of 100 benchmark rounds.
+
+## Performance
+
+### Single Key Read Performance
+
+| key size in bytes | number of clients | target etcd server | average read QPS | read QPS stddev | average 90th Percentile Latency (ms) | latency stddev |
+|-------------------|-------------------|--------------------|------------------|-----------------|--------------------------------------|----------------|
+| 64 | 1 | leader only | 2303 | 200 | 0.49 | 0.06 |
+| 64 | 64 | leader only | 15048 | 685 | 7.60 | 0.46 |
+| 64 | 256 | leader only | 14508 | 434 | 29.76 | 1.05 |
+| 256 | 1 | leader only | 2162 | 214 | 0.52 | 0.06 |
+| 256 | 64 | leader only | 14789 | 792 | 7.69| 0.48 |
+| 256 | 256 | leader only | 14424 | 512 | 29.92 | 1.42 |
+| 64 | 64 | all servers | 45752 | 2048 | 2.47 | 0.14 |
+| 64 | 256 | all servers | 46592 | 1273 | 10.14 | 0.59 |
+| 256 | 64 | all servers | 45332 | 1847 | 2.48| 0.12 |
+| 256 | 256 | all servers | 46485 | 1340 | 10.18 | 0.74 |
+
+### Single Key Write Performance
+
+| key size in bytes | number of clients | target etcd server | average write QPS | write QPS stddev | average 90th Percentile Latency (ms) | latency stddev |
+|-------------------|-------------------|--------------------|------------------|-----------------|--------------------------------------|----------------|
+| 64 | 1 | leader only | 55 | 4 | 24.51 | 13.26 |
+| 64 | 64 | leader only | 2139 | 125 | 35.23 | 3.40 |
+| 64 | 256 | leader only | 4581 | 581 | 70.53 | 10.22 |
+| 256 | 1 | leader only | 56 | 4 | 22.37| 4.33 |
+| 256 | 64 | leader only | 2052 | 151 | 36.83 | 4.20 |
+| 256 | 256 | leader only | 4442 | 560 | 71.59 | 10.03 |
+| 64 | 64 | all servers | 1625 | 85 | 58.51 | 5.14 |
+| 64 | 256 | all servers | 4461 | 298 | 89.47 | 36.48 |
+| 256 | 64 | all servers | 1599 | 94 | 60.11| 6.43 |
+| 256 | 256 | all servers | 4315 | 193 | 88.98 | 7.01 |
+
+## Performance Changes
+
+- Because etcd now records metrics for each API call, read QPS performance seems to see a minor decrease in most scenarios. This minimal performance impact was judged a reasonable investment for the breadth of monitoring and debugging information returned.
+
+- Write QPS to cluster leaders seems to be increased by a small margin. This is because the main loop and entry apply loops were decoupled in the etcd raft logic, eliminating several blocks between them.
+
+- Write QPS to all members seems to be increased by a significant margin, because followers now receive the latest commit index sooner, and commit proposals more quickly.
+
+[boom]: https://github.com/rakyll/boom
+[hack]: ../../../hack/benchmark/
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-2-2-0-rc-benchmarks.md b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-2-2-0-rc-benchmarks.md
new file mode 100644
index 00000000..9170a644
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-2-2-0-rc-benchmarks.md
@@ -0,0 +1,77 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../../docs.md#documentation
+
+
+## Physical machines
+
+GCE n1-highcpu-2 machine type
+
+- 1x dedicated local SSD mounted under /var/lib/etcd
+- 1x dedicated slow disk for the OS
+- 1.8 GB memory
+- 2x CPUs
+
+## etcd Cluster
+
+3 etcd 2.2.0-rc members, each runs on a single machine.
+
+Detailed versions:
+
+```
+etcd Version: 2.2.0-alpha.1+git
+Git SHA: 59a5a7e
+Go Version: go1.4.2
+Go OS/Arch: linux/amd64
+```
+
+Also, we use 3 etcd 2.1.0 alpha-stage members to form cluster to get base performance. etcd's commit head is at [c7146bd5][c7146bd5], which is the same as the one that we use in [etcd 2.1 benchmark][etcd-2.1-benchmark].
+
+## Testing
+
+Bootstrap another machine and use the [boom HTTP benchmark tool][boom] to send requests to each etcd member. Check the [benchmark hacking guide][hack-benchmark] for detailed instructions.
+
+## Performance
+
+### reading one single key
+
+| key size in bytes | number of clients | target etcd server | read QPS | 90th Percentile Latency (ms) |
+|-------------------|-------------------|--------------------|----------|---------------|
+| 64 | 1 | leader only | 2804 (-5%) | 0.4 (+0%) |
+| 64 | 64 | leader only | 17816 (+0%) | 5.7 (-6%) |
+| 64 | 256 | leader only | 18667 (-6%) | 20.4 (+2%) |
+| 256 | 1 | leader only | 2181 (-15%) | 0.5 (+25%) |
+| 256 | 64 | leader only | 17435 (-7%) | 6.0 (+9%) |
+| 256 | 256 | leader only | 18180 (-8%) | 21.3 (+3%) |
+| 64 | 64 | all servers | 46965 (-4%) | 2.1 (+0%) |
+| 64 | 256 | all servers | 55286 (-6%) | 7.4 (+6%) |
+| 256 | 64 | all servers | 46603 (-6%) | 2.1 (+5%) |
+| 256 | 256 | all servers | 55291 (-6%) | 7.3 (+4%) |
+
+### writing one single key
+
+| key size in bytes | number of clients | target etcd server | write QPS | 90th Percentile Latency (ms) |
+|-------------------|-------------------|--------------------|-----------|---------------|
+| 64 | 1 | leader only | 76 (+22%) | 19.4 (-15%) |
+| 64 | 64 | leader only | 2461 (+45%) | 31.8 (-32%) |
+| 64 | 256 | leader only | 4275 (+1%) | 69.6 (-10%) |
+| 256 | 1 | leader only | 64 (+20%) | 16.7 (-30%) |
+| 256 | 64 | leader only | 2385 (+30%) | 31.5 (-19%) |
+| 256 | 256 | leader only | 4353 (-3%) | 74.0 (+9%) |
+| 64 | 64 | all servers | 2005 (+81%) | 49.8 (-55%) |
+| 64 | 256 | all servers | 4868 (+35%) | 81.5 (-40%) |
+| 256 | 64 | all servers | 1925 (+72%) | 47.7 (-59%) |
+| 256 | 256 | all servers | 4975 (+36%) | 70.3 (-36%) |
+
+### performance changes explanation
+
+- read QPS in most scenarios is decreased by 5~8%. The reason is that etcd records store metrics for each store operation. The metrics is important for monitoring and debugging, so this is acceptable.
+
+- write QPS to leader is increased by 20~30%. This is because we decouple raft main loop and entry apply loop, which avoids them blocking each other.
+
+- write QPS to all servers is increased by 30~80% because follower could receive latest commit index earlier and commit proposals faster.
+
+[boom]: https://github.com/rakyll/boom
+[c7146bd5]: https://github.com/coreos/etcd/commits/c7146bd5f2c73716091262edc638401bb8229144
+[etcd-2.1-benchmark]: etcd-2-1-0-alpha-benchmarks.md
+[hack-benchmark]: ../../../hack/benchmark/
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-2-2-0-rc-memory-benchmarks.md b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-2-2-0-rc-memory-benchmarks.md
new file mode 100644
index 00000000..40c220ea
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-2-2-0-rc-memory-benchmarks.md
@@ -0,0 +1,52 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../../docs.md#documentation
+
+
+## Physical machine
+
+GCE n1-standard-2 machine type
+
+- 1x dedicated local SSD mounted under /var/lib/etcd
+- 1x dedicated slow disk for the OS
+- 7.5 GB memory
+- 2x CPUs
+
+## etcd
+
+```
+etcd Version: 2.2.0-rc.0+git
+Git SHA: 103cb5c
+Go Version: go1.5
+Go OS/Arch: linux/amd64
+```
+
+## Testing
+
+Start 3-member etcd cluster, each of which uses 2 cores.
+
+The length of key name is always 64 bytes, which is a reasonable length of average key bytes.
+
+## Memory Maximal Usage
+
+- etcd may use maximal memory if one follower is dead and the leader keeps sending snapshots.
+- `max RSS` is the maximal memory usage recorded in 3 runs.
+
+| value bytes | key number | data size(MB) | max RSS(MB) | max RSS/data rate on leader |
+|-------------|-------------|---------------|-------------|-----------------------------|
+| 128 | 50000 | 6 | 433 | 72x |
+| 128 | 100000 | 12 | 659 | 54x |
+| 128 | 200000 | 24 | 1466 | 61x |
+| 1024 | 50000 | 48 | 1253 | 26x |
+| 1024 | 100000 | 96 | 2344 | 24x |
+| 1024 | 200000 | 192 | 4361 | 22x |
+
+## Data Size Threshold
+
+- When etcd reaches data size threshold, it may trigger leader election easily and drop part of proposals.
+- At most cases, etcd cluster should work smoothly if it doesn't hit the threshold. If it doesn't work well due to insufficient resources, you need to decrease its data size.
+
+| value bytes | key number limitation | suggested data size threshold(MB) | consumed RSS(MB) |
+|-------------|-----------------------|-----------------------------------|------------------|
+| 128 | 400K | 48 | 2400 |
+| 1024 | 300K | 292 | 6500 |
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-3-demo-benchmarks.md b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-3-demo-benchmarks.md
new file mode 100644
index 00000000..cb59d173
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-3-demo-benchmarks.md
@@ -0,0 +1,47 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../../docs.md#documentation
+
+
+## Physical machines
+
+GCE n1-highcpu-2 machine type
+
+- 1x dedicated local SSD mounted under /var/lib/etcd
+- 1x dedicated slow disk for the OS
+- 1.8 GB memory
+- 2x CPUs
+- etcd version 2.2.0
+
+## etcd Cluster
+
+1 etcd member running in v3 demo mode
+
+## Testing
+
+Use [etcd v3 benchmark tool][etcd-v3-benchmark].
+
+## Performance
+
+### reading one single key
+
+| key size in bytes | number of clients | read QPS | 90th Percentile Latency (ms) |
+|-------------------|-------------------|----------|---------------|
+| 256 | 1 | 2716 | 0.4 |
+| 256 | 64 | 16623 | 6.1 |
+| 256 | 256 | 16622 | 21.7 |
+
+The performance is nearly the same as the one with empty server handler.
+
+### reading one single key after putting
+
+| key size in bytes | number of clients | read QPS | 90th Percentile Latency (ms) |
+|-------------------|-------------------|----------|---------------|
+| 256 | 1 | 2269 | 0.5 |
+| 256 | 64 | 13582 | 8.6 |
+| 256 | 256 | 13262 | 47.5 |
+
+The performance with empty server handler is not affected by one put. So the
+performance downgrade should be caused by storage package.
+
+[etcd-v3-benchmark]: ../../../tools/benchmark/
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-3-watch-memory-benchmark.md b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-3-watch-memory-benchmark.md
new file mode 100644
index 00000000..56ae1a23
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-3-watch-memory-benchmark.md
@@ -0,0 +1,82 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../../docs.md#documentation
+
+
+# Watch Memory Usage Benchmark
+
+*NOTE*: The watch features are under active development, and their memory usage may change as that development progresses. We do not expect it to significantly increase beyond the figures stated below.
+
+A primary goal of etcd is supporting a very large number of watchers doing a massively large amount of watching. etcd aims to support O(10k) clients, O(100K) watch streams (O(10) streams per client) and O(10M) total watchings (O(100) watching per stream). The memory consumed by each individual watching accounts for the largest portion of etcd's overall usage, and is therefore the focus of current and future optimizations.
+
+
+Three related components of etcd watch consume physical memory: each `grpc.Conn`, each watch stream, and each instance of the watching activity. `grpc.Conn` maintains the actual TCP connection and other gRPC connection state. Each `grpc.Conn` consumes O(10kb) of memory, and might have multiple watch streams attached.
+
+Each watch stream is an independent HTTP2 connection which consumes another O(10kb) of memory.
+Multiple watchings might share one watch stream.
+
+Watching is the actual struct that tracks the changes on the key-value store. Each watching should only consume < O(1kb).
+
+```
+ +-------+
+ | watch |
+ +---------> | foo |
+ | +-------+
+ +------+-----+
+ | stream |
+ +--------------> | |
+ | +------+-----+ +-------+
+ | | | watch |
+ | +---------> | bar |
++-----+------+ +-------+
+| | +------------+
+| conn +-------> | stream |
+| | | |
++-----+------+ +------------+
+ |
+ |
+ |
+ | +------------+
+ +--------------> | stream |
+ | |
+ +------------+
+```
+
+The theoretical memory consumption of watch can be approximated with the formula:
+`memory = c1 * number_of_conn + c2 * avg_number_of_stream_per_conn + c3 * avg_number_of_watch_stream`
+
+## Testing Environment
+
+etcd version
+- git head https://github.com/coreos/etcd/commit/185097ffaa627b909007e772c175e8fefac17af3
+
+GCE n1-standard-2 machine type
+- 7.5 GB memory
+- 2x CPUs
+
+## Overall memory usage
+
+The overall memory usage captures how much [RSS][rss] etcd consumes with the client watchers. While the result may vary by as much as 10%, it is still meaningful, since the goal is to learn about the rough memory usage and the pattern of allocations.
+
+With the benchmark result, we can calculate roughly that `c1 = 17kb`, `c2 = 18kb` and `c3 = 350bytes`. So each additional client connection consumes 17kb of memory and each additional stream consumes 18kb of memory, and each additional watching only cause 350bytes. A single etcd server can maintain millions of watchings with a few GB of memory in normal case.
+
+
+| clients | streams per client | watchings per stream | total watching | memory usage |
+|---------|---------|-----------|----------------|--------------|
+| 1k | 1 | 1 | 1k | 50MB |
+| 2k | 1 | 1 | 2k | 90MB |
+| 5k | 1 | 1 | 5k | 200MB |
+| 1k | 10 | 1 | 10k | 217MB |
+| 2k | 10 | 1 | 20k | 417MB |
+| 5k | 10 | 1 | 50k | 980MB |
+| 1k | 50 | 1 | 50k | 1001MB |
+| 2k | 50 | 1 | 100k | 1960MB |
+| 5k | 50 | 1 | 250k | 4700MB |
+| 1k | 50 | 10 | 500k | 1171MB |
+| 2k | 50 | 10 | 1M | 2371MB |
+| 5k | 50 | 10 | 2.5M | 5710MB |
+| 1k | 50 | 100 | 5M | 2380MB |
+| 2k | 50 | 100 | 10M | 4672MB |
+| 5k | 50 | 100 | 50M | *OOM* |
+
+[rss]: https://en.wikipedia.org/wiki/Resident_set_size
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-storage-memory-benchmark.md b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-storage-memory-benchmark.md
new file mode 100644
index 00000000..3f75b792
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/benchmarks/etcd-storage-memory-benchmark.md
@@ -0,0 +1,103 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../../docs.md#documentation
+
+
+# Storage Memory Usage Benchmark
+
+<!---todo: link storage to storage design doc-->
+Two components of etcd storage consume physical memory. The etcd process allocates an *in-memory index* to speed key lookup. The process's *page cache*, managed by the operating system, stores recently-accessed data from disk for quick re-use.
+
+The in-memory index holds all the keys in a [B-tree][btree] data structure, along with pointers to the on-disk data (the values). Each key in the B-tree may contain multiple pointers, pointing to different versions of its values. The theoretical memory consumption of the in-memory index can hence be approximated with the formula:
+
+`N * (c1 + avg_key_size) + N * (avg_versions_of_key) * (c2 + size_of_pointer)`
+
+where `c1` is the key metadata overhead and `c2` is the version metadata overhead.
+
+The graph shows the detailed structure of the in-memory index B-tree.
+
+```
+
+
+ In mem index
+
+ +------------+
+ | key || ... |
+ +--------------+ | || |
+ | | +------------+
+ | | | v1 || ... |
+ | disk <----------------| || | Tree Node
+ | | +------------+
+ | | | v2 || ... |
+ | <----------------+ || |
+ | | +------------+
+ +--------------+ +-----+ | | |
+ | | | | |
+ | +------------+
+ |
+ |
+ ^
+ ------+
+ | ... |
+ | |
+ +-----+
+ | ... | Tree Node
+ | |
+ +-----+
+ | ... |
+ | |
+ ------+
+```
+
+[Page cache memory][pagecache] is managed by the operating system and is not covered in detail in this document.
+
+## Testing Environment
+
+etcd version
+- git head https://github.com/coreos/etcd/commit/776e9fb7be7eee5e6b58ab977c8887b4fe4d48db
+
+GCE n1-standard-2 machine type
+
+- 7.5 GB memory
+- 2x CPUs
+
+## In-memory index memory usage
+
+In this test, we only benchmark the memory usage of the in-memory index. The goal is to find `c1` and `c2` mentioned above and to understand the hard limit of memory consumption of the storage.
+
+We calculate the memory usage consumption via the Go runtime.ReadMemStats. We calculate the total allocated bytes difference before creating the index and after creating the index. It cannot perfectly reflect the memory usage of the in-memory index itself but can show the rough consumption pattern.
+
+| N | versions | key size | memory usage |
+|------|----------|----------|--------------|
+| 100K | 1 | 64bytes | 22MB |
+| 100K | 5 | 64bytes | 39MB |
+| 1M | 1 | 64bytes | 218MB |
+| 1M | 5 | 64bytes | 432MB |
+| 100K | 1 | 256bytes | 41MB |
+| 100K | 5 | 256bytes | 65MB |
+| 1M | 1 | 256bytes | 409MB |
+| 1M | 5 | 256bytes | 506MB |
+
+
+Based on the result, we can calculate `c1=120bytes`, `c2=30bytes`. We only need two sets of data to calculate `c1` and `c2`, since they are the only unknown variable in the formula. The `c1=120bytes` and `c2=30bytes` are the average value of the 4 sets of `c1` and `c2` we calculated. The key metadata overhead is still relatively nontrivial (50%) for small key-value pairs. However, this is a significant improvement over the old store, which had at least 1000% overhead.
+
+## Overall memory usage
+
+The overall memory usage captures how much RSS etcd consumes with the storage. The value size should have very little impact on the overall memory usage of etcd, since we keep values on disk and only retain hot values in memory, managed by the OS page cache.
+
+| N | versions | key size | value size | memory usage |
+|------|----------|----------|------------|--------------|
+| 100K | 1 | 64bytes | 256bytes | 40MB |
+| 100K | 5 | 64bytes | 256bytes | 89MB |
+| 1M | 1 | 64bytes | 256bytes | 470MB |
+| 1M | 5 | 64bytes | 256bytes | 880MB |
+| 100K | 1 | 64bytes | 1KB | 102MB |
+| 100K | 5 | 64bytes | 1KB | 164MB |
+| 1M | 1 | 64bytes | 1KB | 587MB |
+| 1M | 5 | 64bytes | 1KB | 836MB |
+
+Based on the result, we know the value size does not significantly impact the memory consumption. There is some minor increase due to more data held in the OS page cache.
+
+[btree]: https://en.wikipedia.org/wiki/B-tree
+[pagecache]: https://en.wikipedia.org/wiki/Page_cache
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/branch_management.md b/vendor/github.com/coreos/etcd/Documentation/v2/branch_management.md
new file mode 100644
index 00000000..45b27354
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/branch_management.md
@@ -0,0 +1,31 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Branch Management
+
+## Guide
+
+* New development occurs on the [master branch][master].
+* Master branch should always have a green build!
+* Backwards-compatible bug fixes should target the master branch and subsequently be ported to stable branches.
+* Once the master branch is ready for release, it will be tagged and become the new stable branch.
+
+The etcd team has adopted a *rolling release model* and supports one stable version of etcd.
+
+### Master branch
+
+The `master` branch is our development branch. All new features land here first.
+
+If you want to try new features, pull `master` and play with it. Note that `master` may not be stable because new features may introduce bugs.
+
+Before the release of the next stable version, feature PRs will be frozen. We will focus on the testing, bug-fix and documentation for one to two weeks.
+
+### Stable branches
+
+All branches with prefix `release-` are considered _stable_ branches.
+
+After every minor release (http://semver.org/), we will have a new stable branch for that release. We will keep fixing the backwards-compatible bugs for the latest stable release, but not previous releases. The _patch_ release, incorporating any bug fixes, will be once every two weeks, given any patches.
+
+[master]: https://github.com/coreos/etcd/tree/master
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/clustering.md b/vendor/github.com/coreos/etcd/Documentation/v2/clustering.md
new file mode 100644
index 00000000..f9c3e08f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/clustering.md
@@ -0,0 +1,440 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Clustering Guide
+
+## Overview
+
+Starting an etcd cluster statically requires that each member knows another in the cluster. In a number of cases, you might not know the IPs of your cluster members ahead of time. In these cases, you can bootstrap an etcd cluster with the help of a discovery service.
+
+Once an etcd cluster is up and running, adding or removing members is done via [runtime reconfiguration][runtime-conf]. To better understand the design behind runtime reconfiguration, we suggest you read [the runtime configuration design document][runtime-reconf-design].
+
+This guide will cover the following mechanisms for bootstrapping an etcd cluster:
+
+* [Static](#static)
+* [etcd Discovery](#etcd-discovery)
+* [DNS Discovery](#dns-discovery)
+
+Each of the bootstrapping mechanisms will be used to create a three machine etcd cluster with the following details:
+
+|Name|Address|Hostname|
+|------|---------|------------------|
+|infra0|10.0.1.10|infra0.example.com|
+|infra1|10.0.1.11|infra1.example.com|
+|infra2|10.0.1.12|infra2.example.com|
+
+## Static
+
+As we know the cluster members, their addresses and the size of the cluster before starting, we can use an offline bootstrap configuration by setting the `initial-cluster` flag. Each machine will get either the following command line or environment variables:
+
+```
+ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380"
+ETCD_INITIAL_CLUSTER_STATE=new
+```
+
+```
+--initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
+--initial-cluster-state new
+```
+
+Note that the URLs specified in `initial-cluster` are the _advertised peer URLs_, i.e. they should match the value of `initial-advertise-peer-urls` on the respective nodes.
+
+If you are spinning up multiple clusters (or creating and destroying a single cluster) with same configuration for testing purpose, it is highly recommended that you specify a unique `initial-cluster-token` for the different clusters. By doing this, etcd can generate unique cluster IDs and member IDs for the clusters even if they otherwise have the exact same configuration. This can protect you from cross-cluster-interaction, which might corrupt your clusters.
+
+etcd listens on [`listen-client-urls`][conf-listen-client] to accept client traffic. etcd member advertises the URLs specified in [`advertise-client-urls`][conf-adv-client] to other members, proxies, clients. Please make sure the `advertise-client-urls` are reachable from intended clients. A common mistake is setting `advertise-client-urls` to localhost or leave it as default when you want the remote clients to reach etcd.
+
+On each machine you would start etcd with these flags:
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \
+ --listen-peer-urls http://10.0.1.10:2380 \
+ --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.10:2379 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
+ --initial-cluster-state new
+```
+```
+$ etcd --name infra1 --initial-advertise-peer-urls http://10.0.1.11:2380 \
+ --listen-peer-urls http://10.0.1.11:2380 \
+ --listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.11:2379 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
+ --initial-cluster-state new
+```
+```
+$ etcd --name infra2 --initial-advertise-peer-urls http://10.0.1.12:2380 \
+ --listen-peer-urls http://10.0.1.12:2380 \
+ --listen-client-urls http://10.0.1.12:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.12:2379 \
+ --initial-cluster-token etcd-cluster-1 \
+ --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
+ --initial-cluster-state new
+```
+
+The command line parameters starting with `--initial-cluster` will be ignored on subsequent runs of etcd. You are free to remove the environment variables or command line flags after the initial bootstrap process. If you need to make changes to the configuration later (for example, adding or removing members to/from the cluster), see the [runtime configuration][runtime-conf] guide.
+
+### Error Cases
+
+In the following example, we have not included our new host in the list of enumerated nodes. If this is a new cluster, the node _must_ be added to the list of initial cluster members.
+
+```
+$ etcd --name infra1 --initial-advertise-peer-urls http://10.0.1.11:2380 \
+ --listen-peer-urls https://10.0.1.11:2380 \
+ --listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.11:2379 \
+ --initial-cluster infra0=http://10.0.1.10:2380 \
+ --initial-cluster-state new
+etcd: infra1 not listed in the initial cluster config
+exit 1
+```
+
+In this example, we are attempting to map a node (infra0) on a different address (127.0.0.1:2380) than its enumerated address in the cluster list (10.0.1.10:2380). If this node is to listen on multiple addresses, all addresses _must_ be reflected in the "initial-cluster" configuration directive.
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls http://127.0.0.1:2380 \
+ --listen-peer-urls http://10.0.1.10:2380 \
+ --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.10:2379 \
+ --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
+ --initial-cluster-state=new
+etcd: error setting up initial cluster: infra0 has different advertised URLs in the cluster and advertised peer URLs list
+exit 1
+```
+
+If you configure a peer with a different set of configuration and attempt to join this cluster you will get a cluster ID mismatch and etcd will exit.
+
+```
+$ etcd --name infra3 --initial-advertise-peer-urls http://10.0.1.13:2380 \
+ --listen-peer-urls http://10.0.1.13:2380 \
+ --listen-client-urls http://10.0.1.13:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.13:2379 \
+ --initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra3=http://10.0.1.13:2380 \
+ --initial-cluster-state=new
+etcd: conflicting cluster ID to the target cluster (c6ab534d07e8fcc4 != bc25ea2a74fb18b0). Exiting.
+exit 1
+```
+
+## Discovery
+
+In a number of cases, you might not know the IPs of your cluster peers ahead of time. This is common when utilizing cloud providers or when your network uses DHCP. In these cases, rather than specifying a static configuration, you can use an existing etcd cluster to bootstrap a new one. We call this process "discovery".
+
+There two methods that can be used for discovery:
+
+* etcd discovery service
+* DNS SRV records
+
+### etcd Discovery
+
+To better understand the design about discovery service protocol, we suggest you read [this][discovery-proto].
+
+#### Lifetime of a Discovery URL
+
+A discovery URL identifies a unique etcd cluster. Instead of reusing a discovery URL, you should always create discovery URLs for new clusters.
+
+Moreover, discovery URLs should ONLY be used for the initial bootstrapping of a cluster. To change cluster membership after the cluster is already running, see the [runtime reconfiguration][runtime-conf] guide.
+
+#### Custom etcd Discovery Service
+
+Discovery uses an existing cluster to bootstrap itself. If you are using your own etcd cluster you can create a URL like so:
+
+```
+$ curl -X PUT https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83/_config/size -d value=3
+```
+
+By setting the size key to the URL, you create a discovery URL with an expected cluster size of 3.
+
+If you bootstrap an etcd cluster using discovery service with more than the expected number of etcd members, the extra etcd processes will [fall back][fall-back] to being [proxies][proxy] by default.
+
+The URL you will use in this case will be `https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83` and the etcd members will use the `https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83` directory for registration as they start.
+
+**Each member must have a different name flag specified. `Hostname` or `machine-id` can be a good choice. Or discovery will fail due to duplicated name.**
+
+Now we start etcd with those relevant flags for each member:
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \
+ --listen-peer-urls http://10.0.1.10:2380 \
+ --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.10:2379 \
+ --discovery https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83
+```
+```
+$ etcd --name infra1 --initial-advertise-peer-urls http://10.0.1.11:2380 \
+ --listen-peer-urls http://10.0.1.11:2380 \
+ --listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.11:2379 \
+ --discovery https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83
+```
+```
+$ etcd --name infra2 --initial-advertise-peer-urls http://10.0.1.12:2380 \
+ --listen-peer-urls http://10.0.1.12:2380 \
+ --listen-client-urls http://10.0.1.12:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.12:2379 \
+ --discovery https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83
+```
+
+This will cause each member to register itself with the custom etcd discovery service and begin the cluster once all machines have been registered.
+
+#### Public etcd Discovery Service
+
+If you do not have access to an existing cluster, you can use the public discovery service hosted at `discovery.etcd.io`. You can create a private discovery URL using the "new" endpoint like so:
+
+```
+$ curl https://discovery.etcd.io/new?size=3
+https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+```
+
+This will create the cluster with an initial expected size of 3 members. If you do not specify a size, a default of 3 will be used.
+
+If you bootstrap an etcd cluster using discovery service with more than the expected number of etcd members, the extra etcd processes will [fall back][fall-back] to being [proxies][proxy] by default.
+
+```
+ETCD_DISCOVERY=https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+```
+
+```
+-discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+```
+
+**Each member must have a different name flag specified. `Hostname` or `machine-id` can be a good choice. Or discovery will fail due to duplicated name.**
+
+Now we start etcd with those relevant flags for each member:
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \
+ --listen-peer-urls http://10.0.1.10:2380 \
+ --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.10:2379 \
+ --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+```
+```
+$ etcd --name infra1 --initial-advertise-peer-urls http://10.0.1.11:2380 \
+ --listen-peer-urls http://10.0.1.11:2380 \
+ --listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.11:2379 \
+ --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+```
+```
+$ etcd --name infra2 --initial-advertise-peer-urls http://10.0.1.12:2380 \
+ --listen-peer-urls http://10.0.1.12:2380 \
+ --listen-client-urls http://10.0.1.12:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.12:2379 \
+ --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+```
+
+This will cause each member to register itself with the discovery service and begin the cluster once all members have been registered.
+
+You can use the environment variable `ETCD_DISCOVERY_PROXY` to cause etcd to use an HTTP proxy to connect to the discovery service.
+
+#### Error and Warning Cases
+
+##### Discovery Server Errors
+
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \
+ --listen-peer-urls http://10.0.1.10:2380 \
+ --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.10:2379 \
+ --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+etcd: error: the cluster doesn?t have a size configuration value in https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de/_config
+exit 1
+```
+
+##### User Errors
+
+This error will occur if the discovery cluster already has the configured number of members, and `discovery-fallback` is explicitly disabled
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \
+ --listen-peer-urls http://10.0.1.10:2380 \
+ --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.10:2379 \
+ --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de \
+ --discovery-fallback exit
+etcd: discovery: cluster is full
+exit 1
+```
+
+##### Warnings
+
+This is a harmless warning notifying you that the discovery URL will be
+ignored on this machine.
+
+```
+$ etcd --name infra0 --initial-advertise-peer-urls http://10.0.1.10:2380 \
+ --listen-peer-urls http://10.0.1.10:2380 \
+ --listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
+ --advertise-client-urls http://10.0.1.10:2379 \
+ --discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
+etcdserver: discovery token ignored since a cluster has already been initialized. Valid log found at /var/lib/etcd
+```
+
+### DNS Discovery
+
+DNS [SRV records][rfc-srv] can be used as a discovery mechanism.
+The `-discovery-srv` flag can be used to set the DNS domain name where the discovery SRV records can be found.
+The following DNS SRV records are looked up in the listed order:
+
+* _etcd-server-ssl._tcp.example.com
+* _etcd-server._tcp.example.com
+
+If `_etcd-server-ssl._tcp.example.com` is found then etcd will attempt the bootstrapping process over SSL.
+
+To help clients discover the etcd cluster, the following DNS SRV records are looked up in the listed order:
+
+* _etcd-client._tcp.example.com
+* _etcd-client-ssl._tcp.example.com
+
+If `_etcd-client-ssl._tcp.example.com` is found, clients will attempt to communicate with the etcd cluster over SSL.
+
+#### Create DNS SRV records
+
+```
+$ dig +noall +answer SRV _etcd-server._tcp.example.com
+_etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra0.example.com.
+_etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra1.example.com.
+_etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra2.example.com.
+```
+
+```
+$ dig +noall +answer SRV _etcd-client._tcp.example.com
+_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra0.example.com.
+_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra1.example.com.
+_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra2.example.com.
+```
+
+```
+$ dig +noall +answer infra0.example.com infra1.example.com infra2.example.com
+infra0.example.com. 300 IN A 10.0.1.10
+infra1.example.com. 300 IN A 10.0.1.11
+infra2.example.com. 300 IN A 10.0.1.12
+```
+
+#### Bootstrap the etcd cluster using DNS
+
+etcd cluster members can listen on domain names or IP address, the bootstrap process will resolve DNS A records.
+
+The resolved address in `--initial-advertise-peer-urls` *must match* one of the resolved addresses in the SRV targets. The etcd member reads the resolved address to find out if it belongs to the cluster defined in the SRV records.
+
+```
+$ etcd --name infra0 \
+--discovery-srv example.com \
+--initial-advertise-peer-urls http://infra0.example.com:2380 \
+--initial-cluster-token etcd-cluster-1 \
+--initial-cluster-state new \
+--advertise-client-urls http://infra0.example.com:2379 \
+--listen-client-urls http://infra0.example.com:2379 \
+--listen-peer-urls http://infra0.example.com:2380
+```
+
+```
+$ etcd --name infra1 \
+--discovery-srv example.com \
+--initial-advertise-peer-urls http://infra1.example.com:2380 \
+--initial-cluster-token etcd-cluster-1 \
+--initial-cluster-state new \
+--advertise-client-urls http://infra1.example.com:2379 \
+--listen-client-urls http://infra1.example.com:2379 \
+--listen-peer-urls http://infra1.example.com:2380
+```
+
+```
+$ etcd --name infra2 \
+--discovery-srv example.com \
+--initial-advertise-peer-urls http://infra2.example.com:2380 \
+--initial-cluster-token etcd-cluster-1 \
+--initial-cluster-state new \
+--advertise-client-urls http://infra2.example.com:2379 \
+--listen-client-urls http://infra2.example.com:2379 \
+--listen-peer-urls http://infra2.example.com:2380
+```
+
+You can also bootstrap the cluster using IP addresses instead of domain names:
+
+```
+$ etcd --name infra0 \
+--discovery-srv example.com \
+--initial-advertise-peer-urls http://10.0.1.10:2380 \
+--initial-cluster-token etcd-cluster-1 \
+--initial-cluster-state new \
+--advertise-client-urls http://10.0.1.10:2379 \
+--listen-client-urls http://10.0.1.10:2379 \
+--listen-peer-urls http://10.0.1.10:2380
+```
+
+```
+$ etcd --name infra1 \
+--discovery-srv example.com \
+--initial-advertise-peer-urls http://10.0.1.11:2380 \
+--initial-cluster-token etcd-cluster-1 \
+--initial-cluster-state new \
+--advertise-client-urls http://10.0.1.11:2379 \
+--listen-client-urls http://10.0.1.11:2379 \
+--listen-peer-urls http://10.0.1.11:2380
+```
+
+```
+$ etcd --name infra2 \
+--discovery-srv example.com \
+--initial-advertise-peer-urls http://10.0.1.12:2380 \
+--initial-cluster-token etcd-cluster-1 \
+--initial-cluster-state new \
+--advertise-client-urls http://10.0.1.12:2379 \
+--listen-client-urls http://10.0.1.12:2379 \
+--listen-peer-urls http://10.0.1.12:2380
+```
+
+#### etcd proxy configuration
+
+DNS SRV records can also be used to configure the list of peers for an etcd server running in proxy mode:
+
+```
+$ etcd --proxy on --discovery-srv example.com
+```
+
+#### etcd client configuration
+
+DNS SRV records can also be used to help clients discover the etcd cluster.
+
+The official [etcd/client][client] supports [DNS Discovery][client-discoverer].
+
+`etcdctl` also supports DNS Discovery by specifying the `--discovery-srv` option.
+
+```
+$ etcdctl --discovery-srv example.com set foo bar
+```
+
+#### Error Cases
+
+You might see an error like `cannot find local etcd $name from SRV records.`. That means the etcd member fails to find itself from the cluster defined in SRV records. The resolved address in `--initial-advertise-peer-urls` *must match* one of the resolved addresses in the SRV targets.
+
+# 0.4 to 2.0+ Migration Guide
+
+In etcd 2.0 we introduced the ability to listen on more than one address and to advertise multiple addresses. This makes using etcd easier when you have complex networking, such as private and public networks on various cloud providers.
+
+To make understanding this feature easier, we changed the naming of some flags, but we support the old flags to make the migration from the old to new version easier.
+
+|Old Flag |New Flag |Migration Behavior |
+|-----------------------|-----------------------|---------------------------------------------------------------------------------------|
+|-peer-addr |--initial-advertise-peer-urls |If specified, peer-addr will be used as the only peer URL. Error if both flags specified.|
+|-addr |--advertise-client-urls |If specified, addr will be used as the only client URL. Error if both flags specified.|
+|-peer-bind-addr |--listen-peer-urls |If specified, peer-bind-addr will be used as the only peer bind URL. Error if both flags specified.|
+|-bind-addr |--listen-client-urls |If specified, bind-addr will be used as the only client bind URL. Error if both flags specified.|
+|-peers |none |Deprecated. The --initial-cluster flag provides a similar concept with different semantics. Please read this guide on cluster startup.|
+|-peers-file |none |Deprecated. The --initial-cluster flag provides a similar concept with different semantics. Please read this guide on cluster startup.|
+
+[client]: ../../client
+[client-discoverer]: https://godoc.org/github.com/coreos/etcd/client#Discoverer
+[conf-adv-client]: configuration.md#-advertise-client-urls
+[conf-listen-client]: configuration.md#-listen-client-urls
+[discovery-proto]: discovery_protocol.md
+[fall-back]: proxy.md#fallback-to-proxy-mode-with-discovery-service
+[proxy]: proxy.md
+[rfc-srv]: http://www.ietf.org/rfc/rfc2052.txt
+[runtime-conf]: runtime-configuration.md
+[runtime-reconf-design]: runtime-reconf-design.md
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/configuration.md b/vendor/github.com/coreos/etcd/Documentation/v2/configuration.md
new file mode 100644
index 00000000..0cc146dc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/configuration.md
@@ -0,0 +1,293 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Configuration Flags
+
+etcd is configurable through command-line flags and environment variables. Options set on the command line take precedence over those from the environment.
+
+The format of environment variable for flag `--my-flag` is `ETCD_MY_FLAG`. It applies to all flags.
+
+The [official etcd ports][iana-ports] are 2379 for client requests, and 2380 for peer communication. Some legacy code and documentation still references ports 4001 and 7001, but all new etcd use and discussion should adopt the assigned ports.
+
+To start etcd automatically using custom settings at startup in Linux, using a [systemd][systemd-intro] unit is highly recommended.
+
+[systemd-intro]: http://freedesktop.org/wiki/Software/systemd/
+
+## Member Flags
+
+### --name
++ Human-readable name for this member.
++ default: "default"
++ env variable: ETCD_NAME
++ This value is referenced as this node's own entries listed in the `--initial-cluster` flag (Ex: `default=http://localhost:2380` or `default=http://localhost:2380,default=http://localhost:7001`). This needs to match the key used in the flag if you're using [static bootstrapping][build-cluster]. When using discovery, each member must have a unique name. `Hostname` or `machine-id` can be a good choice.
+
+### --data-dir
++ Path to the data directory.
++ default: "${name}.etcd"
++ env variable: ETCD_DATA_DIR
+
+### --wal-dir
++ Path to the dedicated wal directory. If this flag is set, etcd will write the WAL files to the walDir rather than the dataDir. This allows a dedicated disk to be used, and helps avoid io competition between logging and other IO operations.
++ default: ""
++ env variable: ETCD_WAL_DIR
+
+### --snapshot-count
++ Number of committed transactions to trigger a snapshot to disk.
++ default: "10000"
++ env variable: ETCD_SNAPSHOT_COUNT
+
+### --heartbeat-interval
++ Time (in milliseconds) of a heartbeat interval.
++ default: "100"
++ env variable: ETCD_HEARTBEAT_INTERVAL
+
+### --election-timeout
++ Time (in milliseconds) for an election to timeout. See [tuning.md](tuning.md#time-parameters) for details.
++ default: "1000"
++ env variable: ETCD_ELECTION_TIMEOUT
+
+### --listen-peer-urls
++ List of URLs to listen on for peer traffic. This flag tells the etcd to accept incoming requests from its peers on the specified scheme://IP:port combinations. Scheme can be either http or https.If 0.0.0.0 is specified as the IP, etcd listens to the given port on all interfaces. If an IP address is given as well as a port, etcd will listen on the given port and interface. Multiple URLs may be used to specify a number of addresses and ports to listen on. The etcd will respond to requests from any of the listed addresses and ports.
++ default: "http://localhost:2380,http://localhost:7001"
++ env variable: ETCD_LISTEN_PEER_URLS
++ example: "http://10.0.0.1:2380"
++ invalid example: "http://example.com:2380" (domain name is invalid for binding)
+
+### --listen-client-urls
++ List of URLs to listen on for client traffic. This flag tells the etcd to accept incoming requests from the clients on the specified scheme://IP:port combinations. Scheme can be either http or https. If 0.0.0.0 is specified as the IP, etcd listens to the given port on all interfaces. If an IP address is given as well as a port, etcd will listen on the given port and interface. Multiple URLs may be used to specify a number of addresses and ports to listen on. The etcd will respond to requests from any of the listed addresses and ports.
++ default: "http://localhost:2379,http://localhost:4001"
++ env variable: ETCD_LISTEN_CLIENT_URLS
++ example: "http://10.0.0.1:2379"
++ invalid example: "http://example.com:2379" (domain name is invalid for binding)
+
+### --max-snapshots
++ Maximum number of snapshot files to retain (0 is unlimited)
++ default: 5
++ env variable: ETCD_MAX_SNAPSHOTS
++ The default for users on Windows is unlimited, and manual purging down to 5 (or your preference for safety) is recommended.
+
+### --max-wals
++ Maximum number of wal files to retain (0 is unlimited)
++ default: 5
++ env variable: ETCD_MAX_WALS
++ The default for users on Windows is unlimited, and manual purging down to 5 (or your preference for safety) is recommended.
+
+### --cors
++ Comma-separated white list of origins for CORS (cross-origin resource sharing).
++ default: none
++ env variable: ETCD_CORS
+
+## Clustering Flags
+
+`--initial` prefix flags are used in bootstrapping ([static bootstrap][build-cluster], [discovery-service bootstrap][discovery] or [runtime reconfiguration][reconfig]) a new member, and ignored when restarting an existing member.
+
+`--discovery` prefix flags need to be set when using [discovery service][discovery].
+
+### --initial-advertise-peer-urls
+
++ List of this member's peer URLs to advertise to the rest of the cluster. These addresses are used for communicating etcd data around the cluster. At least one must be routable to all cluster members. These URLs can contain domain names.
++ default: "http://localhost:2380,http://localhost:7001"
++ env variable: ETCD_INITIAL_ADVERTISE_PEER_URLS
++ example: "http://example.com:2380, http://10.0.0.1:2380"
+
+### --initial-cluster
++ Initial cluster configuration for bootstrapping.
++ default: "default=http://localhost:2380,default=http://localhost:7001"
++ env variable: ETCD_INITIAL_CLUSTER
++ The key is the value of the `--name` flag for each node provided. The default uses `default` for the key because this is the default for the `--name` flag.
+
+### --initial-cluster-state
++ Initial cluster state ("new" or "existing"). Set to `new` for all members present during initial static or DNS bootstrapping. If this option is set to `existing`, etcd will attempt to join the existing cluster. If the wrong value is set, etcd will attempt to start but fail safely.
++ default: "new"
++ env variable: ETCD_INITIAL_CLUSTER_STATE
+
+[static bootstrap]: clustering.md#static
+
+### --initial-cluster-token
++ Initial cluster token for the etcd cluster during bootstrap.
++ default: "etcd-cluster"
++ env variable: ETCD_INITIAL_CLUSTER_TOKEN
+
+### --advertise-client-urls
++ List of this member's client URLs to advertise to the rest of the cluster. These URLs can contain domain names.
++ default: "http://localhost:2379,http://localhost:4001"
++ env variable: ETCD_ADVERTISE_CLIENT_URLS
++ example: "http://example.com:2379, http://10.0.0.1:2379"
++ Be careful if you are advertising URLs such as http://localhost:2379 from a cluster member and are using the proxy feature of etcd. This will cause loops, because the proxy will be forwarding requests to itself until its resources (memory, file descriptors) are eventually depleted.
+
+### --discovery
++ Discovery URL used to bootstrap the cluster.
++ default: none
++ env variable: ETCD_DISCOVERY
+
+### --discovery-srv
++ DNS srv domain used to bootstrap the cluster.
++ default: none
++ env variable: ETCD_DISCOVERY_SRV
+
+### --discovery-fallback
++ Expected behavior ("exit" or "proxy") when discovery services fails.
++ default: "proxy"
++ env variable: ETCD_DISCOVERY_FALLBACK
+
+### --discovery-proxy
++ HTTP proxy to use for traffic to discovery service.
++ default: none
++ env variable: ETCD_DISCOVERY_PROXY
+
+### --strict-reconfig-check
++ Reject reconfiguration requests that would cause quorum loss.
++ default: false
++ env variable: ETCD_STRICT_RECONFIG_CHECK
+
+## Proxy Flags
+
+`--proxy` prefix flags configures etcd to run in [proxy mode][proxy].
+
+### --proxy
++ Proxy mode setting ("off", "readonly" or "on").
++ default: "off"
++ env variable: ETCD_PROXY
+
+### --proxy-failure-wait
++ Time (in milliseconds) an endpoint will be held in a failed state before being reconsidered for proxied requests.
++ default: 5000
++ env variable: ETCD_PROXY_FAILURE_WAIT
+
+### --proxy-refresh-interval
++ Time (in milliseconds) of the endpoints refresh interval.
++ default: 30000
++ env variable: ETCD_PROXY_REFRESH_INTERVAL
+
+### --proxy-dial-timeout
++ Time (in milliseconds) for a dial to timeout or 0 to disable the timeout
++ default: 1000
++ env variable: ETCD_PROXY_DIAL_TIMEOUT
+
+### --proxy-write-timeout
++ Time (in milliseconds) for a write to timeout or 0 to disable the timeout.
++ default: 5000
++ env variable: ETCD_PROXY_WRITE_TIMEOUT
+
+### --proxy-read-timeout
++ Time (in milliseconds) for a read to timeout or 0 to disable the timeout.
++ Don't change this value if you use watches because they are using long polling requests.
++ default: 0
++ env variable: ETCD_PROXY_READ_TIMEOUT
+
+## Security Flags
+
+The security flags help to [build a secure etcd cluster][security].
+
+### --ca-file
+
+**DEPRECATED**
+
++ Path to the client server TLS CA file. `--ca-file ca.crt` could be replaced by `--trusted-ca-file ca.crt --client-cert-auth` and etcd will perform the same.
++ default: none
++ env variable: ETCD_CA_FILE
+
+### --cert-file
++ Path to the client server TLS cert file.
++ default: none
++ env variable: ETCD_CERT_FILE
+
+### --key-file
++ Path to the client server TLS key file.
++ default: none
++ env variable: ETCD_KEY_FILE
+
+### --client-cert-auth
++ Enable client cert authentication.
++ default: false
++ env variable: ETCD_CLIENT_CERT_AUTH
+
+### --trusted-ca-file
++ Path to the client server TLS trusted CA key file.
++ default: none
++ env variable: ETCD_TRUSTED_CA_FILE
+
+### --peer-ca-file
+
+**DEPRECATED**
+
++ Path to the peer server TLS CA file. `--peer-ca-file ca.crt` could be replaced by `--peer-trusted-ca-file ca.crt --peer-client-cert-auth` and etcd will perform the same.
++ default: none
++ env variable: ETCD_PEER_CA_FILE
+
+### --peer-cert-file
++ Path to the peer server TLS cert file.
++ default: none
++ env variable: ETCD_PEER_CERT_FILE
+
+### --peer-key-file
++ Path to the peer server TLS key file.
++ default: none
++ env variable: ETCD_PEER_KEY_FILE
+
+### --peer-client-cert-auth
++ Enable peer client cert authentication.
++ default: false
++ env variable: ETCD_PEER_CLIENT_CERT_AUTH
+
+### --peer-trusted-ca-file
++ Path to the peer server TLS trusted CA file.
++ default: none
++ env variable: ETCD_PEER_TRUSTED_CA_FILE
+
+## Logging Flags
+
+### --debug
++ Drop the default log level to DEBUG for all subpackages.
++ default: false (INFO for all packages)
++ env variable: ETCD_DEBUG
+
+### --log-package-levels
++ Set individual etcd subpackages to specific log levels. An example being `etcdserver=WARNING,security=DEBUG`
++ default: none (INFO for all packages)
++ env variable: ETCD_LOG_PACKAGE_LEVELS
+
+
+## Unsafe Flags
+
+Please be CAUTIOUS when using unsafe flags because it will break the guarantees given by the consensus protocol.
+For example, it may panic if other members in the cluster are still alive.
+Follow the instructions when using these flags.
+
+### --force-new-cluster
++ Force to create a new one-member cluster. It commits configuration changes forcing to remove all existing members in the cluster and add itself. It needs to be set to [restore a backup][restore].
++ default: false
++ env variable: ETCD_FORCE_NEW_CLUSTER
+
+## Experimental Flags
+
+### --experimental-v3demo
++ Enable experimental [v3 demo API][rfc-v3].
++ default: false
++ env variable: ETCD_EXPERIMENTAL_V3DEMO
+
+## Miscellaneous Flags
+
+### --version
++ Print the version and exit.
++ default: false
+
+## Profiling flags
+
+### --enable-pprof
++ Enable runtime profiling data via HTTP server. Address is at client URL + "/debug/pprof/"
++ default: false
+
+[build-cluster]: clustering.md#static
+[reconfig]: runtime-configuration.md
+[discovery]: clustering.md#discovery
+[iana-ports]: http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt
+[proxy]: proxy.md
+[reconfig]: runtime-configuration.md
+[restore]: admin_guide.md#restoring-a-backup
+[rfc-v3]: rfc/v3api.md
+[security]: security.md
+[systemd-intro]: http://freedesktop.org/wiki/Software/systemd/
+[tuning]: tuning.md#time-parameters
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/dev/release.md b/vendor/github.com/coreos/etcd/Documentation/v2/dev/release.md
new file mode 100644
index 00000000..bbf061da
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/dev/release.md
@@ -0,0 +1,115 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../../docs.md#documentation
+
+
+# etcd release guide
+
+The guide talks about how to release a new version of etcd.
+
+The procedure includes some manual steps for sanity checking but it can probably be further scripted. Please keep this document up-to-date if you want to make changes to the release process.
+
+## Prepare Release
+
+Set desired version as environment variable for following steps. Here is an example to release 2.1.3:
+
+```
+export VERSION=v2.1.3
+export PREV_VERSION=v2.1.2
+```
+
+All releases version numbers follow the format of [semantic versioning 2.0.0](http://semver.org/).
+
+### Major, Minor Version Release, or its Pre-release
+
+- Ensure the relevant milestone on GitHub is complete. All referenced issues should be closed, or moved elsewhere.
+- Remove this release from [roadmap](https://github.com/coreos/etcd/blob/master/ROADMAP.md), if necessary.
+- Ensure the latest upgrade documentation is available.
+- Bump [hardcoded MinClusterVerion in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L29), if necessary.
+- Add feature capability maps for the new version, if necessary.
+
+### Patch Version Release
+
+- Discuss about commits that are backported to the patch release. The commits should not include merge commits.
+- Cherry-pick these commits starting from the oldest one into stable branch.
+
+## Write Release Note
+
+
+- Write introduction for the new release. For example, what major bug we fix, what new features we introduce or what performance improvement we make.
+- Write changelog for the last release. ChangeLog should be straightforward and easy to understand for the end-user.
+- Put `[GH XXXX]` at the head of change line to reference Pull Request that introduces the change. Moreover, add a link on it to jump to the Pull Request.
+
+## Tag Version
+
+- Bump [hardcoded Version in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L30) to the latest version `${VERSION}`.
+- Ensure all tests on CI system are passed.
+- Manually check etcd is buildable in Linux, Darwin and Windows.
+- Manually check upgrade etcd cluster of previous minor version works well.
+- Manually check new features work well.
+- Add a signed tag through `git tag -s ${VERSION}`.
+- Sanity check tag correctness through `git show tags/$VERSION`.
+- Push the tag to GitHub through `git push origin tags/$VERSION`. This assumes `origin` corresponds to "https://github.com/coreos/etcd".
+
+## Build Release Binaries and Images
+
+- Ensure `acbuild` is available.
+- Ensure `docker` is available.
+
+Run release script in root directory:
+
+```
+./scripts/release.sh ${VERSION}
+```
+
+It generates all release binaries and images under directory ./release.
+
+## Sign Binaries and Images
+
+Choose appropriate private key to sign the generated binaries and images.
+
+The following commands are used for public release sign:
+
+```
+cd release
+# personal GPG is okay for now
+for i in etcd-*{.zip,.tar.gz}; do gpg --sign ${i}; done
+# use `CoreOS ACI Builder <re...@coreos.com>` secret key
+for aci in etcd-${VERSION}.*.aci; do gpg -u 88182190 -a --output ${aci}.asc --detach-sig ${aci}; done
+```
+
+## Publish Release Page in GitHub
+
+- Set release title as the version name.
+- Follow the format of previous release pages.
+- Attach the generated binaries, aci image and signatures.
+- Select whether it is a pre-release.
+- Publish the release!
+
+## Publish Docker Image in Quay.io
+
+- Push docker image:
+
+```
+docker login quay.io
+docker push quay.io/coreos/etcd:${VERSION}
+docker push quay.io/coreos/etcd:${VERSION}-${arch}
+```
+
+- Add `latest` tag to the new image on [quay.io](https://quay.io/repository/coreos/etcd?tag=latest&tab=tags) if this is a stable release.
+
+## Announce to etcd-dev Googlegroup
+
+- Follow the format of [previous release emails](https://groups.google.com/forum/#!forum/etcd-dev).
+- Make sure to include a list of authors that contributed since the previous release - something like the following might be handy:
+
+```
+git log ...${PREV_VERSION} --pretty=format:"%an" | sort | uniq | tr '\n' ',' | sed -e 's#,#, #g' -e 's#, $##'
+```
+
+- Send email to etcd-dev@googlegroups.com
+
+## Post Release
+
+- Create new stable branch through `git push origin ${VERSION_MAJOR}.${VERSION_MINOR}` if this is a major stable release. This assumes `origin` corresponds to "https://github.com/coreos/etcd".
+- Bump [hardcoded Version in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L30) to the version `${VERSION}+git`.
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/discovery_protocol.md b/vendor/github.com/coreos/etcd/Documentation/v2/discovery_protocol.md
new file mode 100644
index 00000000..b9479ac3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/discovery_protocol.md
@@ -0,0 +1,119 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Discovery Service Protocol
+
+Discovery service protocol helps new etcd member to discover all other members in cluster bootstrap phase using a shared discovery URL.
+
+Discovery service protocol is _only_ used in cluster bootstrap phase, and cannot be used for runtime reconfiguration or cluster monitoring.
+
+The protocol uses a new discovery token to bootstrap one _unique_ etcd cluster. Remember that one discovery token can represent only one etcd cluster. As long as discovery protocol on this token starts, even if it fails halfway, it must not be used to bootstrap another etcd cluster.
+
+The rest of this article will walk through the discovery process with examples that correspond to a self-hosted discovery cluster. The public discovery service, discovery.etcd.io, functions the same way, but with a layer of polish to abstract away ugly URLs, generate UUIDs automatically, and provide some protections against excessive requests. At its core, the public discovery service still uses an etcd cluster as the data store as described in this document.
+
+## The Protocol Workflow
+
+The idea of discovery protocol is to use an internal etcd cluster to coordinate bootstrap of a new cluster. First, all new members interact with discovery service and help to generate the expected member list. Then each new member bootstraps its server using this list, which performs the same functionality as -initial-cluster flag.
+
+In the following example workflow, we will list each step of protocol in curl format for ease of understanding.
+
+By convention the etcd discovery protocol uses the key prefix `_etcd/registry`. If `http://example.com` hosts an etcd cluster for discovery service, a full URL to discovery keyspace will be `http://example.com/v2/keys/_etcd/registry`. We will use this as the URL prefix in the example.
+
+### Creating a New Discovery Token
+
+Generate a unique token that will identify the new cluster. This will be used as a unique prefix in discovery keyspace in the following steps. An easy way to do this is to use `uuidgen`:
+
+```
+UUID=$(uuidgen)
+```
+
+### Specifying the Expected Cluster Size
+
+You need to specify the expected cluster size for this discovery token. The size is used by the discovery service to know when it has found all members that will initially form the cluster.
+
+```
+curl -X PUT http://example.com/v2/keys/_etcd/registry/${UUID}/_config/size -d value=${cluster_size}
+```
+
+Usually the cluster size is 3, 5 or 7. Check [optimal cluster size][cluster-size] for more details.
+
+### Bringing up etcd Processes
+
+Now that you have your discovery URL, you can use it as `-discovery` flag and bring up etcd processes. Every etcd process will follow this next few steps internally if given a `-discovery` flag.
+
+### Registering itself
+
+The first thing for etcd process is to register itself into the discovery URL as a member. This is done by creating member ID as a key in the discovery URL.
+
+```
+curl -X PUT http://example.com/v2/keys/_etcd/registry/${UUID}/${member_id}?prevExist=false -d value="${member_name}=${member_peer_url_1}&${member_name}=${member_peer_url_2}"
+```
+
+### Checking the Status
+
+It checks the expected cluster size and registration status in discovery URL, and decides what the next action is.
+
+```
+curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID}/_config/size
+curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID}
+```
+
+If registered members are still not enough, it will wait for left members to appear.
+
+If the number of registered members is bigger than the expected size N, it treats the first N registered members as the member list for the cluster. If the member itself is in the member list, the discovery procedure succeeds and it fetches all peers through the member list. If it is not in the member list, the discovery procedure finishes with the failure that the cluster has been full.
+
+In etcd implementation, the member may check the cluster status even before registering itself. So it could fail quickly if the cluster has been full.
+
+### Waiting for All Members
+
+
+The wait process is described in detail in the [etcd API documentation][api].
+
+```
+curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID}?wait=true&waitIndex=${current_etcd_index}
+```
+
+It keeps waiting until finding all members.
+
+## Public Discovery Service
+
+CoreOS Inc. hosts a public discovery service at https://discovery.etcd.io/ , which provides some nice features for ease of use.
+
+### Mask Key Prefix
+
+Public discovery service will redirect `https://discovery.etcd.io/${UUID}` to etcd cluster behind for the key at `/v2/keys/_etcd/registry`. It masks register key prefix for short and readable discovery url.
+
+### Get new token
+
+```
+GET /new
+
+Sent query:
+ size=${cluster_size}
+Possible status codes:
+ 200 OK
+ 400 Bad Request
+200 Body:
+ generated discovery url
+```
+
+The generation process in the service follows the steps from [Creating a New Discovery Token][new-discovery-token] to [Specifying the Expected Cluster Size][expected-cluster-size].
+
+### Check Discovery Status
+
+```
+GET /${UUID}
+```
+
+You can check the status for this discovery token, including the machines that have been registered, by requesting the value of the UUID.
+
+### Open-source repository
+
+The repository is located at https://github.com/coreos/discovery.etcd.io. You could use it to build your own public discovery service.
+
+[api]: api.md#waiting-for-a-change
+[cluster-size]: admin_guide.md#optimal-cluster-size
+[expected-cluster-size]: #specifying-the-expected-cluster-size
+[new-discovery-token]: #creating-a-new-discovery-token
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/docker_guide.md b/vendor/github.com/coreos/etcd/Documentation/v2/docker_guide.md
new file mode 100644
index 00000000..74dd9068
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/docker_guide.md
@@ -0,0 +1,101 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Running etcd under Docker
+
+The following guide will show you how to run etcd under Docker using the [static bootstrap process](clustering.md#static).
+
+## Running etcd in standalone mode
+
+In order to expose the etcd API to clients outside of the Docker host you'll need use the host IP address when configuring etcd.
+
+```
+export HostIP="192.168.12.50"
+```
+
+The following `docker run` command will expose the etcd client API over ports 4001 and 2379, and expose the peer port over 2380.
+
+This will run the latest release version of etcd. You can specify version if needed (e.g. `quay.io/coreos/etcd:v2.2.0`).
+
+```
+docker run -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \
+ --name etcd quay.io/coreos/etcd:v2.3.8 \
+ -name etcd0 \
+ -advertise-client-urls http://${HostIP}:2379,http://${HostIP}:4001 \
+ -listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
+ -initial-advertise-peer-urls http://${HostIP}:2380 \
+ -listen-peer-urls http://0.0.0.0:2380 \
+ -initial-cluster-token etcd-cluster-1 \
+ -initial-cluster etcd0=http://${HostIP}:2380 \
+ -initial-cluster-state new
+```
+
+Configure etcd clients to use the Docker host IP and one of the listening ports from above.
+
+```
+etcdctl -C http://192.168.12.50:2379 member list
+```
+
+```
+etcdctl -C http://192.168.12.50:4001 member list
+```
+
+## Running a 3 node etcd cluster
+
+Using Docker to setup a multi-node cluster is very similar to the standalone mode configuration.
+The main difference being the value used for the `-initial-cluster` flag, which must contain the peer urls for each etcd member in the cluster.
+
+**Although the following commands look very similar, note that `-name`, `-advertise-client-urls` and `-initial-advertise-peer-urls` differ for each cluster member**
+
+### etcd0
+
+```
+docker run -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \
+ --name etcd quay.io/coreos/etcd:v2.3.8 \
+ -name etcd0 \
+ -advertise-client-urls http://192.168.12.50:2379,http://192.168.12.50:4001 \
+ -listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
+ -initial-advertise-peer-urls http://192.168.12.50:2380 \
+ -listen-peer-urls http://0.0.0.0:2380 \
+ -initial-cluster-token etcd-cluster-1 \
+ -initial-cluster etcd0=http://192.168.12.50:2380,etcd1=http://192.168.12.51:2380,etcd2=http://192.168.12.52:2380 \
+ -initial-cluster-state new
+```
+
+### etcd1
+
+```
+docker run -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \
+ --name etcd quay.io/coreos/etcd:v2.3.8 \
+ -name etcd1 \
+ -advertise-client-urls http://192.168.12.51:2379,http://192.168.12.51:4001 \
+ -listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
+ -initial-advertise-peer-urls http://192.168.12.51:2380 \
+ -listen-peer-urls http://0.0.0.0:2380 \
+ -initial-cluster-token etcd-cluster-1 \
+ -initial-cluster etcd0=http://192.168.12.50:2380,etcd1=http://192.168.12.51:2380,etcd2=http://192.168.12.52:2380 \
+ -initial-cluster-state new
+```
+
+### etcd2
+
+```
+docker run -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \
+ --name etcd quay.io/coreos/etcd:v2.3.8 \
+ -name etcd2 \
+ -advertise-client-urls http://192.168.12.52:2379,http://192.168.12.52:4001 \
+ -listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
+ -initial-advertise-peer-urls http://192.168.12.52:2380 \
+ -listen-peer-urls http://0.0.0.0:2380 \
+ -initial-cluster-token etcd-cluster-1 \
+ -initial-cluster etcd0=http://192.168.12.50:2380,etcd1=http://192.168.12.51:2380,etcd2=http://192.168.12.52:2380 \
+ -initial-cluster-state new
+```
+
+Once the cluster has been bootstrapped etcd clients can be configured with a list of etcd members:
+
+```
+etcdctl -C http://192.168.12.50:2379,http://192.168.12.51:2379,http://192.168.12.52:2379 member list
+```
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/errorcode.md b/vendor/github.com/coreos/etcd/Documentation/v2/errorcode.md
new file mode 100644
index 00000000..4caf22a5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/errorcode.md
@@ -0,0 +1,47 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Error Code
+======
+
+This document describes the error code used in key space '/v2/keys'. Feel free to import 'github.com/coreos/etcd/error' to use.
+
+It's categorized into four groups:
+
+- Command Related Error
+
+| name | code | strerror |
+|----------------------|------|-----------------------|
+| EcodeKeyNotFound | 100 | "Key not found" |
+| EcodeTestFailed | 101 | "Compare failed" |
+| EcodeNotFile | 102 | "Not a file" |
+| EcodeNotDir | 104 | "Not a directory" |
+| EcodeNodeExist | 105 | "Key already exists" |
+| EcodeRootROnly | 107 | "Root is read only" |
+| EcodeDirNotEmpty | 108 | "Directory not empty" |
+
+- Post Form Related Error
+
+| name | code | strerror |
+|--------------------------|------|------------------------------------------------|
+| EcodePrevValueRequired | 201 | "PrevValue is Required in POST form" |
+| EcodeTTLNaN | 202 | "The given TTL in POST form is not a number" |
+| EcodeIndexNaN | 203 | "The given index in POST form is not a number" |
+| EcodeInvalidField | 209 | "Invalid field" |
+| EcodeInvalidForm | 210 | "Invalid POST form" |
+
+- Raft Related Error
+
+| name | code | strerror |
+|-------------------|------|--------------------------|
+| EcodeRaftInternal | 300 | "Raft Internal Error" |
+| EcodeLeaderElect | 301 | "During Leader Election" |
+
+- Etcd Related Error
+
+| name | code | strerror |
+|-------------------------|------|--------------------------------------------------------|
+| EcodeWatcherCleared | 400 | "watcher is cleared due to etcd recovery" |
+| EcodeEventIndexCleared | 401 | "The event in requested index is outdated and cleared" |
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/etcd_alert.rules b/vendor/github.com/coreos/etcd/Documentation/v2/etcd_alert.rules
new file mode 100644
index 00000000..1793cad4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/etcd_alert.rules
@@ -0,0 +1,121 @@
+### General cluster availability ###
+
+# alert if another failed member will result in an unavailable cluster
+ALERT InsufficientMembers
+ IF count(up{job="etcd"} == 0) > (count(up{job="etcd"}) / 2 - 1)
+ FOR 3m
+ LABELS {
+ severity = "critical"
+ }
+ ANNOTATIONS {
+ summary = "etcd cluster insufficient members",
+ description = "If one more etcd member goes down the cluster will be unavailable",
+ }
+
+### HTTP requests alerts ###
+
+# alert if more than 1% of requests to an HTTP endpoint have failed with a non 4xx response
+ALERT HighNumberOfFailedHTTPRequests
+ IF sum by(method) (rate(etcd_http_failed_total{job="etcd", code!~"4[0-9]{2}"}[5m]))
+ / sum by(method) (rate(etcd_http_received_total{job="etcd"}[5m])) > 0.01
+ FOR 10m
+ LABELS {
+ severity = "warning"
+ }
+ ANNOTATIONS {
+ summary = "a high number of HTTP requests are failing",
+ description = "{{ $value }}% of requests for {{ $labels.method }} failed on etcd instance {{ $labels.instance }}",
+ }
+
+# alert if more than 5% of requests to an HTTP endpoint have failed with a non 4xx response
+ALERT HighNumberOfFailedHTTPRequests
+ IF sum by(method) (rate(etcd_http_failed_total{job="etcd", code!~"4[0-9]{2}"}[5m]))
+ / sum by(method) (rate(etcd_http_received_total{job="etcd"}[5m])) > 0.05
+ FOR 5m
+ LABELS {
+ severity = "critical"
+ }
+ ANNOTATIONS {
+ summary = "a high number of HTTP requests are failing",
+ description = "{{ $value }}% of requests for {{ $labels.method }} failed on etcd instance {{ $labels.instance }}",
+ }
+
+# alert if 50% of requests get a 4xx response
+ALERT HighNumberOfFailedHTTPRequests
+ IF sum by(method) (rate(etcd_http_failed_total{job="etcd", code=~"4[0-9]{2}"}[5m]))
+ / sum by(method) (rate(etcd_http_received_total{job="etcd"}[5m])) > 0.5
+ FOR 10m
+ LABELS {
+ severity = "critical"
+ }
+ ANNOTATIONS {
+ summary = "a high number of HTTP requests are failing",
+ description = "{{ $value }}% of requests for {{ $labels.method }} failed with 4xx responses on etcd instance {{ $labels.instance }}",
+ }
+
+# alert if the 99th percentile of HTTP requests take more than 150ms
+ALERT HTTPRequestsSlow
+ IF histogram_quantile(0.99, rate(etcd_http_successful_duration_second_bucket[5m])) > 0.15
+ FOR 10m
+ LABELS {
+ severity = "warning"
+ }
+ ANNOTATIONS {
+ summary = "slow HTTP requests",
+ description = "on etcd instance {{ $labels.instance }} HTTP requests to {{ $label.method }} are slow",
+ }
+
+### File descriptor alerts ###
+
+instance:fd_utilization = process_open_fds / process_max_fds
+
+# alert if file descriptors are likely to exhaust within the next 4 hours
+ALERT FdExhaustionClose
+ IF predict_linear(instance:fd_utilization[1h], 3600 * 4) > 1
+ FOR 10m
+ LABELS {
+ severity = "warning"
+ }
+ ANNOTATIONS {
+ summary = "file descriptors soon exhausted",
+ description = "{{ $labels.job }} instance {{ $labels.instance }} will exhaust its file descriptors soon",
+ }
+
+# alert if file descriptors are likely to exhaust within the next hour
+ALERT FdExhaustionClose
+ IF predict_linear(instance:fd_utilization[10m], 3600) > 1
+ FOR 10m
+ LABELS {
+ severity = "critical"
+ }
+ ANNOTATIONS {
+ summary = "file descriptors soon exhausted",
+ description = "{{ $labels.job }} instance {{ $labels.instance }} will exhaust its file descriptors soon",
+ }
+
+### etcd proposal alerts ###
+
+# alert if there are several failed proposals within an hour
+ALERT HighNumberOfFailedProposals
+ IF increase(etcd_server_proposal_failed_total{job="etcd"}[1h]) > 5
+ LABELS {
+ severity = "warning"
+ }
+ ANNOTATIONS {
+ summary = "a high number of proposals within the etcd cluster are failing",
+ description = "etcd instance {{ $labels.instance }} has seen {{ $value }} proposal failures within the last hour",
+ }
+
+### etcd disk io latency alerts ###
+
+# alert if 99th percentile of fsync durations is higher than 500ms
+ALERT HighFsyncDurations
+ IF histogram_quantile(0.99, rate(etcd_wal_fsync_durations_seconds_bucket[5m])) > 0.5
+ FOR 10m
+ LABELS {
+ severity = "warning"
+ }
+ ANNOTATIONS {
+ summary = "high fsync durations",
+ description = "etcd instance {{ $labels.instance }} fync durations are high",
+ }
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/faq.md b/vendor/github.com/coreos/etcd/Documentation/v2/faq.md
new file mode 100644
index 00000000..c0faa41e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/faq.md
@@ -0,0 +1,89 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# FAQ
+
+## 1) Why can an etcd client read an old version of data when a majority of the etcd cluster members are down?
+
+In situations where a client connects to a minority, etcd
+favors by default availability over consistency. This means that even though
+data might be ?out of date?, it is still better to return something versus
+nothing.
+
+In order to confirm that a read is up to date with a majority of the cluster,
+the client can use the `quorum=true` parameter on reads of keys. This means
+that a majority of the cluster is checked on reads before returning the data,
+otherwise the read will timeout and fail.
+
+## 2) With quorum=false, doesn?t this mean that if my client switched the member it was connected to, that it could experience a logical ordering where the cluster goes backwards in time?
+
+Yes, but this could be handled at the etcd client implementation via
+remembering the last seen index. The ?index? is the cluster's single
+irrevocable sequence of the entire modification history. The client could
+remember the last seen index, and determine via comparing the index returned on
+the GET whether or not the state of the key-value pair is before or after its
+last seen state.
+
+## 3) What happens if a watch is registered on a minority member?
+
+The watch will stay untriggered, even as modifications are occurring in the
+majority quorum. This is an open issue, and is being addressed in v3. There are
+multiple ways to work around the watch trigger not firing.
+
+1) build a signaling mechanism independent of etcd. This could be as simple as
+a ?pulse? to the client to reissue a GET with quorum=true for the most recent
+version of the data.
+
+2) poll on the `/v2/keys` endpoint and check that the raft-index is increasing every
+timeout.
+
+## 4) What is a proxy used for?
+
+A proxy is a redirection server to the etcd cluster. The proxy handles the
+redirection of a client to the current configuration of the etcd cluster. A
+typical use case is to start a proxy on a machine, and on first boot up of the
+proxy specify both the `--proxy` flag and the `--initial-cluster` flag.
+
+From there, any etcdctl client that starts up automatically speaks to the local
+proxy and the proxy redirects operations to the current configuration of the
+cluster it was originally paired with.
+
+In the v2 spec of etcd, proxies cannot be promoted to members of the cluster.
+They also cannot be promoted to followers or at any point become part of the
+replication of the etcd cluster itself.
+
+## 5) How is cluster membership and health handled in etcd v2?
+
+The design goal of etcd is that reconfiguration is simply an API, and health
+monitoring and addition/removal of members is up to the individual application
+and their integration with the reconfiguration API.
+
+Thus, a member that is down, even infinitely, will never be automatically
+removed from the etcd cluster member list.
+
+This makes sense because it's usually an application level / administrative
+action to determine whether a reconfiguration should happen based on health.
+
+For more information, refer to the [runtime reconfiguration design document][runtime-reconf-design].
+
+## 6) how does --endpoint work with etcdctl?
+
+The `--endpoint` flag can specify any number of etcd cluster members in a comma
+separated list. This list might be a subset, equal to, or more than the actual
+etcd cluster member list itself.
+
+If only one peer is specified via the `--endpoint` flag, the etcdctl discovers the
+rest of the cluster via the member list of that one peer, and then it randomly
+chooses a member to use. Again, the client can use the `quorum=true` flag on
+reads, which will always fail when using a member in the minority.
+
+If peers from multiple clusters are specified via the `--endpoint` flag, etcdctl
+will randomly choose a peer, and the request will simply get routed to one of
+the clusters. This is probably not what you want.
+
+Note: --peers flag is now deprecated and --endpoint should be used instead,
+as it might confuse users to give etcdctl a peerURL.
+
+[runtime-reconf-design]: runtime-reconf-design.md
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/glossary.md b/vendor/github.com/coreos/etcd/Documentation/v2/glossary.md
new file mode 100644
index 00000000..70c2d40e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/glossary.md
@@ -0,0 +1,40 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Glossary
+
+This document defines the various terms used in etcd documentation, command line and source code.
+
+## Node
+
+Node is an instance of raft state machine.
+
+It has a unique identification, and records other nodes' progress internally when it is the leader.
+
+## Member
+
+Member is an instance of etcd. It hosts a node, and provides service to clients.
+
+## Cluster
+
+Cluster consists of several members.
+
+The node in each member follows raft consensus protocol to replicate logs. Cluster receives proposals from members, commits them and apply to local store.
+
+## Peer
+
+Peer is another member of the same cluster.
+
+## Proposal
+
+A proposal is a request (for example a write request, a configuration change request) that needs to go through raft protocol.
+
+## Client
+
+Client is a caller of the cluster's HTTP API.
+
+## Machine (deprecated)
+
+The alternative of Member in etcd before 2.0
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/implementation-faq.md b/vendor/github.com/coreos/etcd/Documentation/v2/implementation-faq.md
new file mode 100644
index 00000000..027c47aa
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/implementation-faq.md
@@ -0,0 +1,70 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# FAQ
+
+## Initial Bootstrapping UX
+
+etcd initial bootstrapping is done via command line flags such as
+`--initial-cluster` or `--discovery`. These flags can safely be left on the
+command line after your cluster is running but they will be ignored if you have
+a non-empty data dir. So, why did we decide to have this sort of odd UX?
+
+One of the design goals of etcd is easy bringup of clusters using a one-shot
+static configuration like AWS Cloud Formation, PXE booting, etc. Essentially we
+want to describe several virtual machines and bring them all up at once into an
+etcd cluster.
+
+To achieve this sort of hands-free cluster bootstrap we had two other options:
+
+**API to bootstrap**
+
+This is problematic because it cannot be coordinated from a single service file
+and we didn't want to have the etcd socket listening but unresponsive to
+clients for an unbound period of time.
+
+It would look something like this:
+
+```
+ExecStart=/usr/bin/etcd
+ExecStartPost/usr/bin/etcd init localhost:2379 --cluster=
+```
+
+**etcd init subcommand**
+
+```
+etcd init --cluster='default=http://localhost:2380,default=http://localhost:7001'...
+etcd init --discovery https://discovery-example.etcd.io/193e4
+```
+
+Then after running an init step you would execute `etcd`. This however
+introduced problems: we now have to define a hand-off protocol between the etcd
+init process and the etcd binary itself. This is hard to coordinate in a single
+service file such as:
+
+```
+ExecStartPre=/usr/bin/etcd init --cluster=....
+ExecStart=/usr/bin/etcd
+```
+
+There are several error cases:
+
+0) Init has already run and the data directory is already configured
+1) Discovery fails because of network timeout, etc
+2) Discovery fails because the cluster is already full and etcd needs to fall back to proxy
+3) Static cluster configuration fails because of conflict, misconfiguration or timeout
+
+In hindsight we could have made this work by doing:
+
+```
+rc status
+0 Init already ran
+1 Discovery fails on network timeout, etc
+0 Discovery fails for cluster full, coordinate via proxy state file
+1 Static cluster configuration failed
+```
+
+Perhaps we can add the init command in a future version and deprecate if the UX
+continues to confuse people.
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/internal-protocol-versioning.md b/vendor/github.com/coreos/etcd/Documentation/v2/internal-protocol-versioning.md
new file mode 100644
index 00000000..68d716e5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/internal-protocol-versioning.md
@@ -0,0 +1,66 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Versioning
+
+Goal: We want to be able to upgrade an individual peer in an etcd cluster to a newer version of etcd.
+The process will take the form of individual followers upgrading to the latest version until the entire cluster is on the new version.
+
+Immediate need: etcd is moving too fast to version the internal API right now.
+But, we need to keep mixed version clusters from being started by a rolling upgrade process (e.g. the CoreOS developer alpha).
+
+Longer term need: Having a mixed version cluster where all peers are not running the exact same version of etcd itself but are able to speak one version of the internal protocol.
+
+Solution: The internal protocol needs to be versioned just as the client protocol is.
+Initially during the 0.\*.\* series of etcd releases we won't allow mixed versions at all.
+
+## Join Control
+
+We will add a version field to the join command.
+But, who decides whether a newly upgraded follower should be able to join a cluster?
+
+### Leader Controlled
+
+If the leader controls the version of followers joining the cluster then it compares its version to the version number presented by the follower in the JoinCommand and rejects the join if the number is less than the leader's version number.
+
+Advantages
+
+- Leader controls all cluster decisions still
+
+Disadvantages
+
+- Follower knows better what versions of the internal protocol it can talk than the leader
+
+
+### Follower Controlled
+
+A newly upgraded follower should be able to figure out the leaders internal version from a defined internal backwards compatible API endpoint and figure out if it can join the cluster.
+If it cannot join the cluster then it simply exits.
+
+Advantages
+
+- The follower is running newer code and knows better if it can talk older protocols
+
+Disadvantages
+
+- This cluster decision isn't made by the leader
+
+## Recommendation
+
+To solve the immediate need and to plan for the future lets do the following:
+
+- Add Version field to JoinCommand
+- Have a joining follower read the Version field of the leader and if its own version doesn't match the leader then sleep for some random interval and retry later to see if the leader has upgraded.
+
+# Research
+
+## Zookeeper versioning
+
+Zookeeper very recently added versioning into the protocol and it doesn't seem to have seen any use yet.
+https://issues.apache.org/jira/browse/ZOOKEEPER-1633
+
+## doozerd
+
+doozerd stores the version number of the peers in the datastore for other clients to check, no decisions are made off of this number currently.
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/libraries-and-tools.md b/vendor/github.com/coreos/etcd/Documentation/v2/libraries-and-tools.md
new file mode 100644
index 00000000..806a5d90
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/libraries-and-tools.md
@@ -0,0 +1,131 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Libraries and Tools
+
+**Tools**
+
+- [etcdctl](https://github.com/coreos/etcd/tree/master/etcdctl) - A command line client for etcd
+- [etcd-backup](https://github.com/fanhattan/etcd-backup) - A powerful command line utility for dumping/restoring etcd - Supports v2
+- [etcd-dump](https://npmjs.org/package/etcd-dump) - Command line utility for dumping/restoring etcd.
+- [etcd-fs](https://github.com/xetorthio/etcd-fs) - FUSE filesystem for etcd
+- [etcddir](https://github.com/rekby/etcddir) - Realtime sync etcd and local directory. Work with windows and linux.
+- [etcd-browser](https://github.com/henszey/etcd-browser) - A web-based key/value editor for etcd using AngularJS
+- [etcd-lock](https://github.com/datawisesystems/etcd-lock) - Master election & distributed r/w lock implementation using etcd - Supports v2
+- [etcd-console](https://github.com/matishsiao/etcd-console) - A web-base key/value editor for etcd using PHP
+- [etcd-viewer](https://github.com/nikfoundas/etcd-viewer) - An etcd key-value store editor/viewer written in Java
+- [etcdtool](https://github.com/mickep76/etcdtool) - Export/Import/Edit etcd directory as JSON/YAML/TOML and Validate directory using JSON schema
+- [etcd-rest](https://github.com/mickep76/etcd-rest) - Create generic REST API in Go using etcd as a backend with validation using JSON schema
+- [etcdsh](https://github.com/kamilhark/etcdsh) - A command line client with support of command history and tab completion. Supports v2
+
+**Go libraries**
+
+- [etcd/client](https://github.com/coreos/etcd/blob/master/client) - the officially maintained Go client
+- [go-etcd](https://github.com/coreos/go-etcd) - the deprecated official client. May be useful for older (<2.0.0) versions of etcd.
+
+**Java libraries**
+
+- [boonproject/etcd](https://github.com/boonproject/boon/blob/master/etcd/README.md) - Supports v2, Async/Sync and waits
+- [justinsb/jetcd](https://github.com/justinsb/jetcd)
+- [diwakergupta/jetcd](https://github.com/diwakergupta/jetcd) - Supports v2
+- [jurmous/etcd4j](https://github.com/jurmous/etcd4j) - Supports v2, Async/Sync, waits and SSL
+- [AdoHe/etcd4j](http://github.com/AdoHe/etcd4j) - Supports v2 (enhance for real production cluster)
+
+**Python libraries**
+
+- [jplana/python-etcd](https://github.com/jplana/python-etcd) - Supports v2
+- [russellhaering/txetcd](https://github.com/russellhaering/txetcd) - a Twisted Python library
+- [cholcombe973/autodock](https://github.com/cholcombe973/autodock) - A docker deployment automation tool
+- [lisael/aioetcd](https://github.com/lisael/aioetcd) - (Python 3.4+) Asyncio coroutines client (Supports v2)
+
+**Node libraries**
+
+- [stianeikeland/node-etcd](https://github.com/stianeikeland/node-etcd) - Supports v2 (w Coffeescript)
+- [lavagetto/nodejs-etcd](https://github.com/lavagetto/nodejs-etcd) - Supports v2
+- [deedubs/node-etcd-config](https://github.com/deedubs/node-etcd-config) - Supports v2
+
+**Ruby libraries**
+
+- [iconara/etcd-rb](https://github.com/iconara/etcd-rb)
+- [jpfuentes2/etcd-ruby](https://github.com/jpfuentes2/etcd-ruby)
+- [ranjib/etcd-ruby](https://github.com/ranjib/etcd-ruby) - Supports v2
+
+**C libraries**
+
+- [jdarcy/etcd-api](https://github.com/jdarcy/etcd-api) - Supports v2
+- [shafreeck/cetcd](https://github.com/shafreeck/cetcd) - Supports v2
+
+**C++ libraries**
+
+- [edwardcapriolo/etcdcpp](https://github.com/edwardcapriolo/etcdcpp) - Supports v2
+- [suryanathan/etcdcpp](https://github.com/suryanathan/etcdcpp) - Supports v2 (with waits)
+- [nokia/etcd-cpp-api](https://github.com/nokia/etcd-cpp-api) - Supports v2
+- [nokia/etcd-cpp-apiv3](https://github.com/nokia/etcd-cpp-apiv3)
+
+**Clojure libraries**
+
+- [aterreno/etcd-clojure](https://github.com/aterreno/etcd-clojure)
+- [dwwoelfel/cetcd](https://github.com/dwwoelfel/cetcd) - Supports v2
+- [rthomas/clj-etcd](https://github.com/rthomas/clj-etcd) - Supports v2
+
+**Erlang libraries**
+
+- [marshall-lee/etcd.erl](https://github.com/marshall-lee/etcd.erl)
+
+**.Net Libraries**
+
+- [wangjia184/etcdnet](https://github.com/wangjia184/etcdnet) - Supports v2
+- [drusellers/etcetera](https://github.com/drusellers/etcetera)
+
+**PHP Libraries**
+
+- [linkorb/etcd-php](https://github.com/linkorb/etcd-php)
+
+**Haskell libraries**
+
+- [wereHamster/etcd-hs](https://github.com/wereHamster/etcd-hs)
+
+**R libraries**
+
+- [ropensci/etseed](https://github.com/ropensci/etseed)
+
+**Tcl libraries**
+
+- [efrecon/etcd-tcl](https://github.com/efrecon/etcd-tcl) - Supports v2, except wait.
+
+**Chef Integration**
+
+- [coderanger/etcd-chef](https://github.com/coderanger/etcd-chef)
+
+**Chef Cookbook**
+
+- [spheromak/etcd-cookbook](https://github.com/spheromak/etcd-cookbook)
+
+**BOSH Releases**
+
+- [cloudfoundry-community/etcd-boshrelease](https://github.com/cloudfoundry-community/etcd-boshrelease)
+- [cloudfoundry/cf-release](https://github.com/cloudfoundry/cf-release/tree/master/jobs/etcd)
+
+**Projects using etcd**
+
+- [binocarlos/yoda](https://github.com/binocarlos/yoda) - etcd + ZeroMQ
+- [calavera/active-proxy](https://github.com/calavera/active-proxy) - HTTP Proxy configured with etcd
+- [derekchiang/etcdplus](https://github.com/derekchiang/etcdplus) - A set of distributed synchronization primitives built upon etcd
+- [go-discover](https://github.com/flynn/go-discover) - service discovery in Go
+- [gleicon/goreman](https://github.com/gleicon/goreman/tree/etcd) - Branch of the Go Foreman clone with etcd support
+- [garethr/hiera-etcd](https://github.com/garethr/hiera-etcd) - Puppet hiera backend using etcd
+- [mattn/etcd-vim](https://github.com/mattn/etcd-vim) - SET and GET keys from inside vim
+- [mattn/etcdenv](https://github.com/mattn/etcdenv) - "env" shebang with etcd integration
+- [kelseyhightower/confd](https://github.com/kelseyhightower/confd) - Manage local app config files using templates and data from etcd
+- [configdb](https://git.autistici.org/ai/configdb/tree/master) - A REST relational abstraction on top of arbitrary database backends, aimed at storing configs and inventories.
+- [fleet](https://github.com/coreos/fleet) - Distributed init system
+- [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes) - Container cluster manager introduced by Google.
+- [mailgun/vulcand](https://github.com/mailgun/vulcand) - HTTP proxy that uses etcd as a configuration backend.
+- [duedil-ltd/discodns](https://github.com/duedil-ltd/discodns) - Simple DNS nameserver using etcd as a database for names and records.
+- [skynetservices/skydns](https://github.com/skynetservices/skydns) - RFC compliant DNS server
+- [xordataexchange/crypt](https://github.com/xordataexchange/crypt) - Securely store values in etcd using GPG encryption
+- [spf13/viper](https://github.com/spf13/viper) - Go configuration library, reads values from ENV, pflags, files, and etcd with optional encryption
+- [lytics/metafora](https://github.com/lytics/metafora) - Go distributed task library
+- [ryandoyle/nss-etcd](https://github.com/ryandoyle/nss-etcd) - A GNU libc NSS module for resolving names from etcd.
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/members_api.md b/vendor/github.com/coreos/etcd/Documentation/v2/members_api.md
new file mode 100644
index 00000000..a9ff6a04
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/members_api.md
@@ -0,0 +1,125 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Members API
+
+* [List members](#list-members)
+* [Add a member](#add-a-member)
+* [Delete a member](#delete-a-member)
+* [Change the peer urls of a member](#change-the-peer-urls-of-a-member)
+
+## List members
+
+Return an HTTP 200 OK response code and a representation of all members in the etcd cluster.
+
+### Request
+
+```
+GET /v2/members HTTP/1.1
+```
+
+### Example
+
+```sh
+curl http://10.0.0.10:2379/v2/members
+```
+
+```json
+{
+ "members": [
+ {
+ "id": "272e204152",
+ "name": "infra1",
+ "peerURLs": [
+ "http://10.0.0.10:2380"
+ ],
+ "clientURLs": [
+ "http://10.0.0.10:2379"
+ ]
+ },
+ {
+ "id": "2225373f43",
+ "name": "infra2",
+ "peerURLs": [
+ "http://10.0.0.11:2380"
+ ],
+ "clientURLs": [
+ "http://10.0.0.11:2379"
+ ]
+ },
+ ]
+}
+```
+
+## Add a member
+
+Returns an HTTP 201 response code and the representation of added member with a newly generated a memberID when successful. Returns a string describing the failure condition when unsuccessful.
+
+If the POST body is malformed an HTTP 400 will be returned. If the member exists in the cluster or existed in the cluster at some point in the past an HTTP 409 will be returned. If any of the given peerURLs exists in the cluster an HTTP 409 will be returned. If the cluster fails to process the request within timeout an HTTP 500 will be returned, though the request may be processed later.
+
+### Request
+
+```
+POST /v2/members HTTP/1.1
+
+{"peerURLs": ["http://10.0.0.10:2380"]}
+```
+
+### Example
+
+```sh
+curl http://10.0.0.10:2379/v2/members -XPOST \
+-H "Content-Type: application/json" -d '{"peerURLs":["http://10.0.0.10:2380"]}'
+```
+
+```json
+{
+ "id": "3777296169",
+ "peerURLs": [
+ "http://10.0.0.10:2380"
+ ]
+}
+```
+
+## Delete a member
+
+Remove a member from the cluster. The member ID must be a hex-encoded uint64.
+Returns 204 with empty content when successful. Returns a string describing the failure condition when unsuccessful.
+
+If the member does not exist in the cluster an HTTP 500(TODO: fix this) will be returned. If the cluster fails to process the request within timeout an HTTP 500 will be returned, though the request may be processed later.
+
+### Request
+
+```
+DELETE /v2/members/<id> HTTP/1.1
+```
+
+### Example
+
+```sh
+curl http://10.0.0.10:2379/v2/members/272e204152 -XDELETE
+```
+
+## Change the peer urls of a member
+
+Change the peer urls of a given member. The member ID must be a hex-encoded uint64. Returns 204 with empty content when successful. Returns a string describing the failure condition when unsuccessful.
+
+If the POST body is malformed an HTTP 400 will be returned. If the member does not exist in the cluster an HTTP 404 will be returned. If any of the given peerURLs exists in the cluster an HTTP 409 will be returned. If the cluster fails to process the request within timeout an HTTP 500 will be returned, though the request may be processed later.
+
+### Request
+
+```
+PUT /v2/members/<id> HTTP/1.1
+
+{"peerURLs": ["http://10.0.0.10:2380"]}
+```
+
+### Example
+
+```sh
+curl http://10.0.0.10:2379/v2/members/272e204152 -XPUT \
+-H "Content-Type: application/json" -d '{"peerURLs":["http://10.0.0.10:2380"]}'
+```
+
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/metrics.md b/vendor/github.com/coreos/etcd/Documentation/v2/metrics.md
new file mode 100644
index 00000000..596c14b6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/metrics.md
@@ -0,0 +1,148 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Metrics
+
+etcd uses [Prometheus][prometheus] for metrics reporting. The metrics can be used for real-time monitoring and debugging. etcd does not persist its metrics; if a member restarts, the metrics will be reset.
+
+The simplest way to see the available metrics is to cURL the metrics endpoint `/metrics`. The format is described [here](http://prometheus.io/docs/instrumenting/exposition_formats/).
+
+Follow the [Prometheus getting started doc][prometheus-getting-started] to spin up a Prometheus server to collect etcd metrics.
+
+The naming of metrics follows the suggested [Prometheus best practices][prometheus-naming]. A metric name has an `etcd` or `etcd_debugging` prefix as its namespace and a subsystem prefix (for example `wal` and `etcdserver`).
+
+## etcd namespace metrics
+
+The metrics under the `etcd` prefix are for monitoring and alerting. They are stable high level metrics. If there is any change of these metrics, it will be included in release notes.
+
+### http requests
+
+These metrics describe the serving of requests (non-watch events) served by etcd members in non-proxy mode: total
+incoming requests, request failures and processing latency (inc. raft rounds for storage). They are useful for tracking
+ user-generated traffic hitting the etcd cluster .
+
+All these metrics are prefixed with `etcd_http_`
+
+| Name | Description | Type |
+|--------------------------------|-----------------------------------------------------------------------------------------|--------------------|
+| received_total | Total number of events after parsing and auth. | Counter(method) |
+| failed_total | Total number of failed events. ? | Counter(method,error) |
+| successful_duration_seconds | Bucketed handling times of the requests, including raft rounds for writes. | Histogram(method) |
+
+
+Example Prometheus queries that may be useful from these metrics (across all etcd members):
+
+ * `sum(rate(etcd_http_failed_total{job="etcd"}[1m]) by (method) / sum(rate(etcd_http_events_received_total{job="etcd"})[1m]) by (method)`
+
+ Shows the fraction of events that failed by HTTP method across all members, across a time window of `1m`.
+
+ * `sum(rate(etcd_http_received_total{job="etcd",method="GET})[1m]) by (method)`
+ `sum(rate(etcd_http_received_total{job="etcd",method~="GET})[1m]) by (method)`
+
+ Shows the rate of successful readonly/write queries across all servers, across a time window of `1m`.
+
+ * `histogram_quantile(0.9, sum(rate(etcd_http_successful_duration_seconds{job="etcd",method="GET"}[5m]) ) by (le))`
+ `histogram_quantile(0.9, sum(rate(etcd_http_successful_duration_seconds{job="etcd",method!="GET"}[5m]) ) by (le))`
+
+ Show the 0.90-tile latency (in seconds) of read/write (respectively) event handling across all members, with a window of `5m`.
+
+### proxy
+
+etcd members operating in proxy mode do not directly perform store operations. They forward all requests to cluster instances.
+
+Tracking the rate of requests coming from a proxy allows one to pin down which machine is performing most reads/writes.
+
+All these metrics are prefixed with `etcd_proxy_`
+
+| Name | Description | Type |
+|---------------------------|-----------------------------------------------------------------------------------------|--------------------|
+| requests_total | Total number of requests by this proxy instance. | Counter(method) |
+| handled_total | Total number of fully handled requests, with responses from etcd members. | Counter(method) |
+| dropped_total | Total number of dropped requests due to forwarding errors to etcd members.? | Counter(method,error) |
+| handling_duration_seconds | Bucketed handling times by HTTP method, including round trip to member instances. | Histogram(method) |
+
+Example Prometheus queries that may be useful from these metrics (across all etcd servers):
+
+ * `sum(rate(etcd_proxy_handled_total{job="etcd"}[1m])) by (method)`
+
+ Rate of requests (by HTTP method) handled by all proxies, across a window of `1m`.
+
+ * `histogram_quantile(0.9, sum(rate(handling_duration_seconds{job="etcd",method="GET"}[5m])) by (le))`
+ `histogram_quantile(0.9, sum(rate(handling_duration_seconds{job="etcd",method!="GET"}[5m])) by (le))`
+
+ Show the 0.90-tile latency (in seconds) of handling of user requests across all proxy machines, with a window of `5m`.
+
+ * `sum(rate(etcd_proxy_dropped_total{job="etcd"}[1m])) by (proxying_error)`
+
+ Number of failed request on the proxy. This should be 0, spikes here indicate connectivity issues to the etcd cluster.
+
+## etcd_debugging namespace metrics
+
+The metrics under the `etcd_debugging` prefix are for debugging. They are very implementation dependent and volatile. They might be changed or removed without any warning in new etcd releases. Some of the metrics might be moved to the `etcd` prefix when they become more stable.
+
+### etcdserver
+
+| Name | Description | Type |
+|-----------------------------------------|--------------------------------------------------|-----------|
+| proposal_duration_seconds | The latency distributions of committing proposal | Histogram |
+| proposals_pending | The current number of pending proposals | Gauge |
+| proposals_failed_total | The total number of failed proposals | Counter |
+
+[Proposal][glossary-proposal] duration (`proposal_duration_seconds`) provides a proposal commit latency histogram. The reported latency reflects network and disk IO delays in etcd.
+
+Proposals pending (`proposals_pending`) indicates how many proposals are queued for commit. Rising pending proposals suggests there is a high client load or the cluster is unstable.
+
+Failed proposals (`proposals_failed_total`) are normally related to two issues: temporary failures related to a leader election or longer duration downtime caused by a loss of quorum in the cluster.
+
+### wal
+
+| Name | Description | Type |
+|------------------------------------|--------------------------------------------------|-----------|
+| fsync_duration_seconds | The latency distributions of fsync called by wal | Histogram |
+| last_index_saved | The index of the last entry saved by wal | Gauge |
+
+Abnormally high fsync duration (`fsync_duration_seconds`) indicates disk issues and might cause the cluster to be unstable.
+
+### snapshot
+
+| Name | Description | Type |
+|--------------------------------------------|------------------------------------------------------------|-----------|
+| snapshot_save_total_duration_seconds | The total latency distributions of save called by snapshot | Histogram |
+
+Abnormally high snapshot duration (`snapshot_save_total_duration_seconds`) indicates disk issues and might cause the cluster to be unstable.
+
+### rafthttp
+
+| Name | Description | Type | Labels |
+|-----------------------------------|--------------------------------------------|--------------|--------------------------------|
+| message_sent_latency_seconds | The latency distributions of messages sent | HistogramVec | sendingType, msgType, remoteID |
+| message_sent_failed_total | The total number of failed messages sent | Summary | sendingType, msgType, remoteID |
+
+
+Abnormally high message duration (`message_sent_latency_seconds`) indicates network issues and might cause the cluster to be unstable.
+
+An increase in message failures (`message_sent_failed_total`) indicates more severe network issues and might cause the cluster to be unstable.
+
+Label `sendingType` is the connection type to send messages. `message`, `msgapp` and `msgappv2` use HTTP streaming, while `pipeline` does HTTP request for each message.
+
+Label `msgType` is the type of raft message. `MsgApp` is log replication messages; `MsgSnap` is snapshot install messages; `MsgProp` is proposal forward messages; the others maintain internal raft status. Given large snapshots, a lengthy msgSnap transmission latency should be expected. For other types of messages, given enough network bandwidth, latencies comparable to ping latency should be expected.
+
+Label `remoteID` is the member ID of the message destination.
+
+## Prometheus supplied metrics
+
+The Prometheus client library provides a number of metrics under the `go` and `process` namespaces. There are a few that are particlarly interesting.
+
+| Name | Description | Type |
+|-----------------------------------|--------------------------------------------|--------------|
+| process_open_fds | Number of open file descriptors. | Gauge |
+| process_max_fds | Maximum number of open file descriptors. | Gauge |
+
+Heavy file descriptor (`process_open_fds`) usage (i.e., near the process's file descriptor limit, `process_max_fds`) indicates a potential file descriptor exhaustion issue. If the file descriptors are exhausted, etcd may panic because it cannot create new WAL files.
+
+[glossary-proposal]: glossary.md#proposal
+[prometheus]: http://prometheus.io/
+[prometheus-getting-started]: http://prometheus.io/docs/introduction/getting_started/
+[prometheus-naming]: http://prometheus.io/docs/practices/naming/
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/other_apis.md b/vendor/github.com/coreos/etcd/Documentation/v2/other_apis.md
new file mode 100644
index 00000000..339d9f8e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/other_apis.md
@@ -0,0 +1,33 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Miscellaneous APIs
+
+* [Getting the etcd version](#getting-the-etcd-version)
+* [Checking health of an etcd member node](#checking-health-of-an-etcd-member-node)
+
+## Getting the etcd version
+
+The etcd version of a specific instance can be obtained from the `/version` endpoint.
+
+```sh
+curl -L http://127.0.0.1:2379/version
+```
+
+```
+etcd 2.0.12
+```
+
+## Checking health of an etcd member node
+
+etcd provides a `/health` endpoint to verify the health of a particular member.
+
+```sh
+curl http://10.0.0.10:2379/health
+```
+
+```json
+{"health": "true"}
+```
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/platforms/freebsd.md b/vendor/github.com/coreos/etcd/Documentation/v2/platforms/freebsd.md
new file mode 100644
index 00000000..891ea6f5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/platforms/freebsd.md
@@ -0,0 +1,67 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../../docs.md#documentation
+
+
+# FreeBSD
+
+Starting?with?version?0.1.2?both?etcd?and?etcdctl?have?been?ported?to?FreeBSD?and?can
+be?installed?either?via?packages?or?ports?system.?Their?versions?have?been?recently
+updated?to?0.2.0?so?now?you?can?enjoy?using?etcd?and?etcdctl?on?FreeBSD?10.0?(RC4?as
+of?now)?and?9.x?where?they?have?been?tested.?They?might?also?work?when?installed?from
+ports?on?earlier?versions?of?FreeBSD,?but?your?mileage?may?vary.
+
+## Installation
+
+### Using?pkgng?package?system
+
+1.?If?you?do?not?have?pkg?ng?installed,?install?it?with?command?`pkg`?and?answering?'Y'
+when?asked
+
+2.?Update?your?repository?data?with?`pkg?update`
+
+3.?Install?etcd?with?`pkg?install?coreos-etcd?coreos-etcdctl`
+
+4.?Verify?successful?installation?with?`pkg?info?|?grep?etcd`?and?you?should?get:
+
+```
+r@fbsd?10:/?#?pkg?info?|?grep?etcd
+coreos?etcd?0.2.0??????????????Highly?available?key?value?store and?service?discovery
+coreos?etcdctl?0.2.0???????????Simple?commandline?client?for?etcd
+r@fbsd?10:/?#
+```
+
+5.?You?re?ready?to?use?etcd?and?etcdctl!?For?more?information?about?using?pkgng,?please
+see:?http://www.freebsd.org/doc/handbook/pkgng?intro.html
+?
+### Using?ports?system
+
+1.?If?you?do?not?have?ports?installed,?install?with?with?`portsnap?fetch?extract`?(it
+may?take?some?time?depending?on?your?hardware?and?network?connection)
+
+2.?Build?etcd?with?`cd?/usr/ports/devel/etcd?&&?make?install?clean`,?you
+will?get?an?option?to?build?and?install?documentation?and?etcdctl?with?it.
+
+3.?If?you?haven't?installed?it?with?etcdctl,?and?you?would?like?to?install?it?later,?you?can?build?it
+with?`cd?/usr/ports/devel/etcdctl?&&?make?install?clean`
+
+4.?Verify?successful?installation?with?`pkg?info?|?grep?etcd`?and?you?should?get:
+?
+
+```
+r@fbsd?10:/?#?pkg?info?|?grep?etcd
+coreos?etcd?0.2.0??????????????Highly?available?key?value?store and?service?discovery
+coreos?etcdctl?0.2.0???????????Simple?commandline?client?for?etcd
+r@fbsd?10:/?#
+```
+
+5.?You?re?ready?to?use?etcd?and?etcdctl!?For?more?information?about?using?ports?system,
+please?see:?https://www.freebsd.org/doc/handbook/ports?using.html
+
+## Issues
+
+If?you?find?any?issues?with?the?build/install?procedure?or?you've?found?a?problem?that
+you've?verified?is?local?to?FreeBSD?version?only?(for?example,?by?not?being?able?to
+reproduce?it on any other?platform,?like OSX or Linux),?please?sent a
+problem?report?using this?page for more
+information:?http://www.freebsd.org/send?pr.html
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/production-users.md b/vendor/github.com/coreos/etcd/Documentation/v2/production-users.md
new file mode 100644
index 00000000..addef2a9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/production-users.md
@@ -0,0 +1,56 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Production Users
+
+This document tracks people and use cases for etcd in production. By creating a list of production use cases we hope to build a community of advisors that we can reach out to with experience using various etcd applications, operation environments, and cluster sizes. The etcd development team may reach out periodically to check-in on your experience and update this list.
+
+## discovery.etcd.io
+
+- *Application*: https://github.com/coreos/discovery.etcd.io
+- *Launched*: Feb. 2014
+- *Cluster Size*: 5 members, 5 discovery proxies
+- *Order of Data Size*: 100s of Megabytes
+- *Operator*: CoreOS, brandon.philips@coreos.com
+- *Environment*: AWS
+- *Backups*: Periodic async to S3
+
+discovery.etcd.io is the longest continuously running etcd backed service that we know about. It is the basis of automatic cluster bootstrap and was launched in Feb. 2014: https://coreos.com/blog/etcd-0.3.0-released/.
+
+## OpenTable
+
+- *Application*: OpenTable internal service discovery and cluster configuration management
+- *Launched*: May 2014
+- *Cluster Size*: 3 members each in 6 independent clusters; approximately 50 nodes reading / writing
+- *Order of Data Size*: 10s of MB
+- *Operator*: OpenTable, Inc; sschlansker@opentable.com
+- *Environment*: AWS, VMWare
+- *Backups*: None, all data can be re-created if necessary.
+
+## cycoresys.com
+
+- *Application*: multiple
+- *Launched*: Jul. 2014
+- *Cluster Size*: 3 members, _n_ proxies
+- *Order of Data Size*: 100s of kilobytes
+- *Operator*: CyCore Systems, Inc, sys@cycoresys.com
+- *Environment*: Baremetal
+- *Backups*: Periodic sync to Ceph RadosGW and DigitalOcean VM
+
+CyCore Systems provides architecture and engineering for computing systems. This cluster provides microservices, virtual machines, databases, storage clusters to a number of clients. It is built on CoreOS machines, with each machine in the cluster running etcd as a peer or proxy.
+
+## Radius Intelligence
+
+- *Application*: multiple internal tools, Kubernetes clusters, bootstrappable system configs
+- *Launched*: June 2015
+- *Cluster Size*: 2 clusters of 5 and 3 members; approximately a dozen nodes read/write
+- *Order of Data Size*: 100s of kilobytes
+- *Operator*: Radius Intelligence; jcderr@radius.com
+- *Environment*: AWS, CoreOS, Kubernetes
+- *Backups*: None, all data can be recreated if necessary.
+
+Radius Intelligence uses Kubernetes running CoreOS to containerize and scale internal toolsets. Examples include running [JetBrains TeamCity][teamcity] and internal AWS security and cost reporting tools. etcd clusters back these clusters as well as provide some basic environment bootstrapping configuration keys.
+
+[teamcity]: https://www.jetbrains.com/teamcity/
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/proxy.md b/vendor/github.com/coreos/etcd/Documentation/v2/proxy.md
new file mode 100644
index 00000000..1489b015
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/proxy.md
@@ -0,0 +1,158 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Proxy
+
+etcd can run as a transparent proxy. Doing so allows for easy discovery of etcd within your infrastructure, since it can run on each machine as a local service. In this mode, etcd acts as a reverse proxy and forwards client requests to an active etcd cluster. The etcd proxy does not participate in the consensus replication of the etcd cluster, thus it neither increases the resilience nor decreases the write performance of the etcd cluster.
+
+etcd currently supports two proxy modes: `readwrite` and `readonly`. The default mode is `readwrite`, which forwards both read and write requests to the etcd cluster. A `readonly` etcd proxy only forwards read requests to the etcd cluster, and returns `HTTP 501` to all write requests.
+
+The proxy will shuffle the list of cluster members periodically to avoid sending all connections to a single member.
+
+The member list used by an etcd proxy consists of all client URLs advertised in the cluster. These client URLs are specified in each etcd cluster member's `advertise-client-urls` option.
+
+An etcd proxy examines several command-line options to discover its peer URLs. In order of precedence, these options are `discovery`, `discovery-srv`, and `initial-cluster`. The `initial-cluster` option is set to a comma-separated list of one or more etcd peer URLs used temporarily in order to discover the permanent cluster.
+
+After establishing a list of peer URLs in this manner, the proxy retrieves the list of client URLs from the first reachable peer. These client URLs are specified by the `advertise-client-urls` option to etcd peers. The proxy then continues to connect to the first reachable etcd cluster member every thirty seconds to refresh the list of client URLs.
+
+While etcd proxies therefore do not need to be given the `advertise-client-urls` option, as they retrieve this configuration from the cluster, this implies that `initial-cluster` must be set correctly for every proxy, and the `advertise-client-urls` option must be set correctly for every non-proxy, first-order cluster peer. Otherwise, requests to any etcd proxy would be forwarded improperly. Take special care not to set the `advertise-client-urls` option to URLs that point to the proxy itself, as such a configuration will cause the proxy to enter a loop, forwarding requests to itself until resources are exhausted. To correct either case, stop etcd and restart it with the correct URLs.
+
+[This example Procfile][procfile] illustrates the difference in the etcd peer and proxy command lines used to configure and start a cluster with one proxy under the [goreman process management utility][goreman].
+
+To summarize etcd proxy startup and peer discovery:
+
+1. etcd proxies execute the following steps in order until the cluster *peer-urls* are known:
+ 1. If `discovery` is set for the proxy, ask the given discovery service for
+ the *peer-urls*. The *peer-urls* will be the combined
+ `initial-advertise-peer-urls` of all first-order, non-proxy cluster
+ members.
+ 2. If `discovery-srv` is set for the proxy, the *peer-urls* are discovered
+ from DNS.
+ 3. If `initial-cluster` is set for the proxy, that will become the value of
+ *peer-urls*.
+ 4. Otherwise use the default value of
+ `http://localhost:2380,http://localhost:7001`.
+2. These *peer-urls* are used to contact the (non-proxy) members of the cluster
+ to find their *client-urls*. The *client-urls* will thus be the combined
+ `advertise-client-urls` of all cluster members (i.e. non-proxies).
+3. Request of clients of the proxy will be forwarded (proxied) to these
+ *client-urls*.
+
+Always start the first-order etcd cluster members first, then any proxies. A proxy must be able to reach the cluster members to retrieve its configuration, and will attempt connections somewhat aggressively in the absence of such a channel. Starting the members before any proxy ensures the proxy can discover the client URLs when it later starts.
+
+## Using an etcd proxy
+To start etcd in proxy mode, you need to provide three flags: `proxy`, `listen-client-urls`, and `initial-cluster` (or `discovery`).
+
+To start a readwrite proxy, set `-proxy on`; To start a readonly proxy, set `-proxy readonly`.
+
+The proxy will be listening on `listen-client-urls` and forward requests to the etcd cluster discovered from in `initial-cluster` or `discovery` url.
+
+### Start an etcd proxy with a static configuration
+To start a proxy that will connect to a statically defined etcd cluster, specify the `initial-cluster` flag:
+
+```
+etcd --proxy on \
+--listen-client-urls http://127.0.0.1:2379 \
+--initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380
+```
+
+### Start an etcd proxy with the discovery service
+If you bootstrap an etcd cluster using the [discovery service][discovery-service], you can also start the proxy with the same `discovery`.
+
+To start a proxy using the discovery service, specify the `discovery` flag. The proxy will wait until the etcd cluster defined at the `discovery` url finishes bootstrapping, and then start to forward the requests.
+
+```
+etcd --proxy on \
+--listen-client-urls http://127.0.0.1:2379 \
+--discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de \
+```
+
+## Fallback to proxy mode with discovery service
+
+If you bootstrap an etcd cluster using [discovery service][discovery-service] with more than the expected number of etcd members, the extra etcd processes will fall back to being `readwrite` proxies by default. They will forward the requests to the cluster as described above. For example, if you create a discovery url with `size=5`, and start ten etcd processes using that same discovery url, the result will be a cluster with five etcd members and five proxies. Note that this behaviour can be disabled with the `discovery-fallback='exit'` flag.
+
+## Promote a proxy to a member of etcd cluster
+
+A Proxy is in the part of etcd cluster that does not participate in consensus. A proxy will not promote itself to an etcd member that participates in consensus automatically in any case.
+
+If you want to promote a proxy to an etcd member, there are four steps you need to follow:
+
+- use etcdctl to add the proxy node as an etcd member into the existing cluster
+- stop the etcd proxy process or service
+- remove the existing proxy data directory
+- restart the etcd process with new member configuration
+
+## Example
+
+We assume you have a one member etcd cluster with one proxy. The cluster information is listed below:
+
+|Name|Address|
+|------|---------|
+|infra0|10.0.1.10|
+|proxy0|10.0.1.11|
+
+This example walks you through a case that you promote one proxy to an etcd member. The cluster will become a two member cluster after finishing the four steps.
+
+### Add a new member into the existing cluster
+
+First, use etcdctl to add the member to the cluster, which will output the environment variables need to correctly configure the new member:
+
+``` bash
+$ etcdctl -endpoint http://10.0.1.10:2379 member add infra1 http://10.0.1.11:2380
+added member 9bf1b35fc7761a23 to cluster
+
+ETCD_NAME="infra1"
+ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380"
+ETCD_INITIAL_CLUSTER_STATE=existing
+```
+
+### Stop the proxy process
+
+Stop the existing proxy so we can wipe its state on disk and reload it with the new configuration:
+
+``` bash
+ps aux | grep etcd
+kill %etcd_proxy_pid%
+```
+
+or (if you are running etcd proxy as etcd service under systemd)
+
+``` bash
+sudo systemctl stop etcd
+```
+
+### Remove the existing proxy data dir
+
+``` bash
+rm -rf %data_dir%/proxy
+```
+
+### Start etcd as a new member
+
+Finally, start the reconfigured member and make sure it joins the cluster correctly:
+
+``` bash
+$ export ETCD_NAME="infra1"
+$ export ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380"
+$ export ETCD_INITIAL_CLUSTER_STATE=existing
+$ etcd --listen-client-urls http://10.0.1.11:2379 \
+--advertise-client-urls http://10.0.1.11:2379 \
+--listen-peer-urls http://10.0.1.11:2380 \
+--initial-advertise-peer-urls http://10.0.1.11:2380 \
+--data-dir %data_dir%
+```
+
+If you are running etcd under systemd, you should modify the service file with correct configuration and restart the service:
+
+``` bash
+sudo systemd restart etcd
+```
+
+If an error occurs, check the [add member troubleshooting doc][runtime-configuration].
+
+[discovery-service]: clustering.md#discovery
+[goreman]: https://github.com/mattn/goreman
+[procfile]: https://github.com/coreos/etcd/blob/master/Procfile
+[runtime-configuration]: runtime-configuration.md#error-cases-when-adding-members
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/reporting_bugs.md b/vendor/github.com/coreos/etcd/Documentation/v2/reporting_bugs.md
new file mode 100644
index 00000000..1f5880fa
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/reporting_bugs.md
@@ -0,0 +1,50 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Reporting Bugs
+
+If you find bugs or documentation mistakes in the etcd project, please let us know by [opening an issue][etcd-issue]. We treat bugs and mistakes very seriously and believe no issue is too small. Before creating a bug report, please check that an issue reporting the same problem does not already exist.
+
+To make your bug report accurate and easy to understand, please try to create bug reports that are:
+
+- Specific. Include as much details as possible: which version, what environment, what configuration, etc. You can also attach etcd log (the starting log with etcd configuration is especially important).
+
+- Reproducible. Include the steps to reproduce the problem. We understand some issues might be hard to reproduce, please includes the steps that might lead to the problem. You can also attach the affected etcd data dir and stack strace to the bug report.
+
+- Isolated. Please try to isolate and reproduce the bug with minimum dependencies. It would significantly slow down the speed to fix a bug if too many dependencies are involved in a bug report. Debugging external systems that rely on etcd is out of scope, but we are happy to point you in the right direction or help you interact with etcd in the correct manner.
+
+- Unique. Do not duplicate existing bug report.
+
+- Scoped. One bug per report. Do not follow up with another bug inside one report.
+
+You might also want to read [Elika Etemad?s article on filing good bug reports][filing-good-bugs] before creating a bug report.
+
+We might ask you for further information to locate a bug. A duplicated bug report will be closed.
+
+## Frequently Asked Questions
+
+### How to get a stack trace
+
+``` bash
+$ kill -QUIT $PID
+```
+
+### How to get etcd version
+
+``` bash
+$ etcd --version
+```
+
+### How to get etcd configuration and log when it runs as systemd service ?etcd2.service?
+
+``` bash
+$ sudo systemctl cat etcd2
+$ sudo journalctl -u etcd2
+```
+
+Due to an upstream systemd bug, journald may miss the last few log lines when its process exit. If journalctl tells you that etcd stops without fatal or panic message, you could try `sudo journalctl -f -t etcd2` to get full log.
+
+[etcd-issue]: https://github.com/coreos/etcd/issues/new
+[filing-good-bugs]: http://fantasai.inkedblade.net/style/talks/filing-good-bugs/
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/rfc/v3api.md b/vendor/github.com/coreos/etcd/Documentation/v2/rfc/v3api.md
new file mode 100644
index 00000000..18567d36
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/rfc/v3api.md
@@ -0,0 +1,216 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../../docs.md#documentation
+
+
+# Overview
+
+The etcd v3 API is designed to give users a more efficient and cleaner abstraction compared to etcd v2. There are a number of semantic and protocol changes in this new API. For an overview [see Xiang Li's video](https://youtu.be/J5AioGtEPeQ?t=211).
+
+To prove out the design of the v3 API the team has also built [a number of example recipes](https://github.com/coreos/etcd/tree/master/contrib/recipes), there is a [video discussing these recipes too](https://www.youtube.com/watch?v=fj-2RY-3yVU&feature=youtu.be&t=590).
+
+# Design
+
+1. Flatten binary key-value space
+
+2. Keep the event history until compaction
+ - access to old version of keys
+ - user controlled history compaction
+
+3. Support range query
+ - Pagination support with limit argument
+ - Support consistency guarantee across multiple range queries
+
+4. Replace TTL key with Lease
+ - more efficient/ low cost keep alive
+ - a logical group of TTL keys
+
+5. Replace CAS/CAD with multi-object Txn
+ - MUCH MORE powerful and flexible
+
+6. Support efficient watching with multiple ranges
+
+7. RPC API supports the completed set of APIs.
+ - more efficient than JSON/HTTP
+ - additional txn/lease support
+
+8. HTTP API supports a subset of APIs.
+ - easy for people to try out etcd
+ - easy for people to write simple etcd application
+
+
+## Notes
+
+### Request Size Limitation
+
+The max request size is around 1MB. Since etcd replicates requests in a streaming fashion, a very large
+request might block other requests for a long time. The use case for etcd is to store small configuration
+values, so we prevent user from submitting large requests. This also applies to Txn requests. We might loosen
+the size in the future a little bit or make it configurable.
+
+## Protobuf Defined API
+
+[api protobuf][api-protobuf]
+
+[kv protobuf][kv-protobuf]
+
+## Examples
+
+### Put a key (foo=bar)
+```
+// A put is always successful
+Put( PutRequest { key = foo, value = bar } )
+
+PutResponse {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 1,
+ raft_term = 0x1,
+}
+```
+
+### Get a key (assume we have foo=bar)
+```
+Get ( RangeRequest { key = foo } )
+
+RangeResponse {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 1,
+ raft_term = 0x1,
+ kvs = {
+ {
+ key = foo,
+ value = bar,
+ create_revision = 1,
+ mod_revision = 1,
+ version = 1;
+ },
+ },
+}
+```
+
+### Range over a key space (assume we have foo0=bar0? foo100=bar100)
+```
+Range ( RangeRequest { key = foo, end_key = foo80, limit = 30 } )
+
+RangeResponse {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 100,
+ raft_term = 0x1,
+ kvs = {
+ {
+ key = foo0,
+ value = bar0,
+ create_revision = 1,
+ mod_revision = 1,
+ version = 1;
+ },
+ ...,
+ {
+ key = foo30,
+ value = bar30,
+ create_revision = 30,
+ mod_revision = 30,
+ version = 1;
+ },
+ },
+}
+```
+
+### Finish a txn (assume we have foo0=bar0, foo1=bar1)
+```
+Txn(TxnRequest {
+ // mod_revision of foo0 is equal to 1, mod_revision of foo1 is greater than 1
+ compare = {
+ {compareType = equal, key = foo0, mod_revision = 1},
+ {compareType = greater, key = foo1, mod_revision = 1}}
+ },
+ // if the comparison succeeds, put foo2 = bar2
+ success = {PutRequest { key = foo2, value = success }},
+ // if the comparison fails, put foo2=fail
+ failure = {PutRequest { key = foo2, value = failure }},
+)
+
+TxnResponse {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 3,
+ raft_term = 0x1,
+ succeeded = true,
+ responses = {
+ // response of PUT foo2=success
+ {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 3,
+ raft_term = 0x1,
+ }
+ }
+}
+```
+
+### Watch on a key/range
+
+```
+Watch( WatchRequest{
+ key = foo,
+ end_key = fop, // prefix foo
+ start_revision = 20,
+ end_revision = 10000,
+ // server decided notification frequency
+ progress_notification = true,
+ }
+ ? // this can be a watch request stream
+ )
+
+// put (foo0=bar0) event at 3
+WatchResponse {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 3,
+ raft_term = 0x1,
+ event_type = put,
+ kv = {
+ key = foo0,
+ value = bar0,
+ create_revision = 1,
+ mod_revision = 1,
+ version = 1;
+ },
+ }
+ ?
+
+ // a notification at 2000
+ WatchResponse {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 2000,
+ raft_term = 0x1,
+ // nil event as notification
+ }
+
+ ?
+
+ // put (foo0=bar3000) event at 3000
+ WatchResponse {
+ cluster_id = 0x1000,
+ member_id = 0x1,
+ revision = 3000,
+ raft_term = 0x1,
+ event_type = put,
+ kv = {
+ key = foo0,
+ value = bar3000,
+ create_revision = 1,
+ mod_revision = 3000,
+ version = 2;
+ },
+ }
+ ?
+
+```
+
+[api-protobuf]: https://github.com/coreos/etcd/blob/release-2.3/etcdserver/etcdserverpb/rpc.proto
+[kv-protobuf]: https://github.com/coreos/etcd/blob/release-2.3/storage/storagepb/kv.proto
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/runtime-configuration.md b/vendor/github.com/coreos/etcd/Documentation/v2/runtime-configuration.md
new file mode 100644
index 00000000..a6b57b91
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/runtime-configuration.md
@@ -0,0 +1,189 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Runtime Reconfiguration
+
+etcd comes with support for incremental runtime reconfiguration, which allows users to update the membership of the cluster at run time.
+
+Reconfiguration requests can only be processed when the majority of the cluster members are functioning. It is **highly recommended** to always have a cluster size greater than two in production. It is unsafe to remove a member from a two member cluster. The majority of a two member cluster is also two. If there is a failure during the removal process, the cluster might not able to make progress and need to [restart from majority failure][majority failure].
+
+To better understand the design behind runtime reconfiguration, we suggest you read [the runtime reconfiguration document][runtime-reconf].
+
+## Reconfiguration Use Cases
+
+Let's walk through some common reasons for reconfiguring a cluster. Most of these just involve combinations of adding or removing a member, which are explained below under [Cluster Reconfiguration Operations][cluster-reconf].
+
+### Cycle or Upgrade Multiple Machines
+
+If you need to move multiple members of your cluster due to planned maintenance (hardware upgrades, network downtime, etc.), it is recommended to modify members one at a time.
+
+It is safe to remove the leader, however there is a brief period of downtime while the election process takes place. If your cluster holds more than 50MB, it is recommended to [migrate the member's data directory][member migration].
+
+### Change the Cluster Size
+
+Increasing the cluster size can enhance [failure tolerance][fault tolerance table] and provide better read performance. Since clients can read from any member, increasing the number of members increases the overall read throughput.
+
+Decreasing the cluster size can improve the write performance of a cluster, with a trade-off of decreased resilience. Writes into the cluster are replicated to a majority of members of the cluster before considered committed. Decreasing the cluster size lowers the majority, and each write is committed more quickly.
+
+### Replace A Failed Machine
+
+If a machine fails due to hardware failure, data directory corruption, or some other fatal situation, it should be replaced as soon as possible. Machines that have failed but haven't been removed adversely affect your quorum and reduce the tolerance for an additional failure.
+
+To replace the machine, follow the instructions for [removing the member][remove member] from the cluster, and then [add a new member][add member] in its place. If your cluster holds more than 50MB, it is recommended to [migrate the failed member's data directory][member migration] if you can still access it.
+
+### Restart Cluster from Majority Failure
+
+If the majority of your cluster is lost or all of your nodes have changed IP addresses, then you need to take manual action in order to recover safely.
+The basic steps in the recovery process include [creating a new cluster using the old data][disaster recovery], forcing a single member to act as the leader, and finally using runtime configuration to [add new members][add member] to this new cluster one at a time.
+
+## Cluster Reconfiguration Operations
+
+Now that we have the use cases in mind, let us lay out the operations involved in each.
+
+Before making any change, the simple majority (quorum) of etcd members must be available.
+This is essentially the same requirement as for any other write to etcd.
+
+All changes to the cluster are done one at a time:
+
+* To update a single member peerURLs you will make an update operation
+* To replace a single member you will make an add then a remove operation
+* To increase from 3 to 5 members you will make two add operations
+* To decrease from 5 to 3 you will make two remove operations
+
+All of these examples will use the `etcdctl` command line tool that ships with etcd.
+If you want to use the members API directly you can find the documentation [here][member-api].
+
+### Update a Member
+
+#### Update advertise client URLs
+
+If you would like to update the advertise client URLs of a member, you can simply restart
+that member with updated client urls flag (`--advertise-client-urls`) or environment variable
+(`ETCD_ADVERTISE_CLIENT_URLS`). The restarted member will self publish the updated URLs.
+A wrongly updated client URL will not affect the health of the etcd cluster.
+
+#### Update advertise peer URLs
+
+If you would like to update the advertise peer URLs of a member, you have to first update
+it explicitly via member command and then restart the member. The additional action is required
+since updating peer URLs changes the cluster wide configuration and can affect the health of the etcd cluster.
+
+To update the peer URLs, first, we need to find the target member's ID. You can list all members with `etcdctl`:
+
+```sh
+$ etcdctl member list
+6e3bd23ae5f1eae0: name=node2 peerURLs=http://localhost:23802 clientURLs=http://127.0.0.1:23792
+924e2e83e93f2560: name=node3 peerURLs=http://localhost:23803 clientURLs=http://127.0.0.1:23793
+a8266ecf031671f3: name=node1 peerURLs=http://localhost:23801 clientURLs=http://127.0.0.1:23791
+```
+
+In this example let's `update` a8266ecf031671f3 member ID and change its peerURLs value to http://10.0.1.10:2380
+
+```sh
+$ etcdctl member update a8266ecf031671f3 http://10.0.1.10:2380
+Updated member with ID a8266ecf031671f3 in cluster
+```
+
+### Remove a Member
+
+Let us say the member ID we want to remove is a8266ecf031671f3.
+We then use the `remove` command to perform the removal:
+
+```sh
+$ etcdctl member remove a8266ecf031671f3
+Removed member a8266ecf031671f3 from cluster
+```
+
+The target member will stop itself at this point and print out the removal in the log:
+
+```
+etcd: this member has been permanently removed from the cluster. Exiting.
+```
+
+It is safe to remove the leader, however the cluster will be inactive while a new leader is elected. This duration is normally the period of election timeout plus the voting process.
+
+### Add a New Member
+
+Adding a member is a two step process:
+
+ * Add the new member to the cluster via the [members API][member-api] or the `etcdctl member add` command.
+ * Start the new member with the new cluster configuration, including a list of the updated members (existing members + the new member).
+
+Using `etcdctl` let's add the new member to the cluster by specifying its [name][conf-name] and [advertised peer URLs][conf-adv-peer]:
+
+```sh
+$ etcdctl member add infra3 http://10.0.1.13:2380
+added member 9bf1b35fc7761a23 to cluster
+
+ETCD_NAME="infra3"
+ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380,infra3=http://10.0.1.13:2380"
+ETCD_INITIAL_CLUSTER_STATE=existing
+```
+
+`etcdctl` has informed the cluster about the new member and printed out the environment variables needed to successfully start it.
+Now start the new etcd process with the relevant flags for the new member:
+
+```sh
+$ export ETCD_NAME="infra3"
+$ export ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380,infra3=http://10.0.1.13:2380"
+$ export ETCD_INITIAL_CLUSTER_STATE=existing
+$ etcd -listen-client-urls http://10.0.1.13:2379 -advertise-client-urls http://10.0.1.13:2379 -listen-peer-urls http://10.0.1.13:2380 -initial-advertise-peer-urls http://10.0.1.13:2380 -data-dir %data_dir%
+```
+
+The new member will run as a part of the cluster and immediately begin catching up with the rest of the cluster.
+
+If you are adding multiple members the best practice is to configure a single member at a time and verify it starts correctly before adding more new members.
+If you add a new member to a 1-node cluster, the cluster cannot make progress before the new member starts because it needs two members as majority to agree on the consensus. You will only see this behavior between the time `etcdctl member add` informs the cluster about the new member and the new member successfully establishing a connection to the existing one.
+
+#### Error Cases When Adding Members
+
+In the following case we have not included our new host in the list of enumerated nodes.
+If this is a new cluster, the node must be added to the list of initial cluster members.
+
+```sh
+$ etcd -name infra3 \
+ -initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
+ -initial-cluster-state existing
+etcdserver: assign ids error: the member count is unequal
+exit 1
+```
+
+In this case we give a different address (10.0.1.14:2380) to the one that we used to join the cluster (10.0.1.13:2380).
+
+```sh
+$ etcd -name infra4 \
+ -initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380,infra4=http://10.0.1.14:2380 \
+ -initial-cluster-state existing
+etcdserver: assign ids error: unmatched member while checking PeerURLs
+exit 1
+```
+
+When we start etcd using the data directory of a removed member, etcd will exit automatically if it connects to any active member in the cluster:
+
+```sh
+$ etcd
+etcd: this member has been permanently removed from the cluster. Exiting.
+exit 1
+```
+
+### Strict Reconfiguration Check Mode (`-strict-reconfig-check`)
+
+As described in the above, the best practice of adding new members is to configure a single member at a time and verify it starts correctly before adding more new members. This step by step approach is very important because if newly added members is not configured correctly (for example the peer URLs are incorrect), the cluster can lose quorum. The quorum loss happens since the newly added member are counted in the quorum even if that member is not reachable from other existing members. Also quorum loss might happen if there is a connectivity issue or there are operational issues.
+
+For avoiding this problem, etcd provides an option `-strict-reconfig-check`. If this option is passed to etcd, etcd rejects reconfiguration requests if the number of started members will be less than a quorum of the reconfigured cluster.
+
+It is recommended to enable this option. However, it is disabled by default because of keeping compatibility.
+
+[add member]: #add-a-new-member
+[cluster-reconf]: #cluster-reconfiguration-operations
+[conf-adv-peer]: configuration.md#-initial-advertise-peer-urls
+[conf-name]: configuration.md#-name
+[disaster recovery]: admin_guide.md#disaster-recovery
+[fault tolerance table]: admin_guide.md#fault-tolerance-table
+[majority failure]: #restart-cluster-from-majority-failure
+[member-api]: members_api.md
+[member migration]: admin_guide.md#member-migration
+[remove member]: #remove-a-member
+[runtime-reconf]: runtime-reconf-design.md
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/runtime-reconf-design.md b/vendor/github.com/coreos/etcd/Documentation/v2/runtime-reconf-design.md
new file mode 100644
index 00000000..8232d11d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/runtime-reconf-design.md
@@ -0,0 +1,55 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Design of Runtime Reconfiguration
+
+Runtime reconfiguration is one of the hardest and most error prone features in a distributed system, especially in a consensus based system like etcd.
+
+Read on to learn about the design of etcd's runtime reconfiguration commands and how we tackled these problems.
+
+## Two Phase Config Changes Keep you Safe
+
+In etcd, every runtime reconfiguration has to go through [two phases][add-member] for safety reasons. For example, to add a member you need to first inform cluster of new configuration and then start the new member.
+
+Phase 1 - Inform cluster of new configuration
+
+To add a member into etcd cluster, you need to make an API call to request a new member to be added to the cluster. And this is only way that you can add a new member into an existing cluster. The API call returns when the cluster agrees on the configuration change.
+
+Phase 2 - Start new member
+
+To join the etcd member into the existing cluster, you need to specify the correct `initial-cluster` and set `initial-cluster-state` to `existing`. When the member starts, it will contact the existing cluster first and verify the current cluster configuration matches the expected one specified in `initial-cluster`. When the new member successfully starts, you know your cluster reached the expected configuration.
+
+By splitting the process into two discrete phases users are forced to be explicit regarding cluster membership changes. This actually gives users more flexibility and makes things easier to reason about. For example, if there is an attempt to add a new member with the same ID as an existing member in an etcd cluster, the action will fail immediately during phase one without impacting the running cluster. Similar protection is provided to prevent adding new members by mistake. If a new etcd member attempts to join the cluster before the cluster has accepted the configuration change,, it will not be accepted by the cluster.
+
+Without the explicit workflow around cluster membership etcd would be vulnerable to unexpected cluster membership changes. For example, if etcd is running under an init system such as systemd, etcd would be restarted after being removed via the membership API, and attempt to rejoin the cluster on startup. This cycle would continue every time a member is removed via the API and systemd is set to restart etcd after failing, which is unexpected.
+
+We think runtime reconfiguration should be a low frequent operation. We made the decision to keep it explicit and user-driven to ensure configuration safety and keep your cluster always running smoothly under your control.
+
+## Permanent Loss of Quorum Requires New Cluster
+
+If a cluster permanently loses a majority of its members, a new cluster will need to be started from an old data directory to recover the previous state.
+
+It is entirely possible to force removing the failed members from the existing cluster to recover. However, we decided not to support this method since it bypasses the normal consensus committing phase, which is unsafe. If the member to remove is not actually dead or you force to remove different members through different members in the same cluster, you will end up with diverged cluster with same clusterID. This is very dangerous and hard to debug/fix afterwards.
+
+If you have a correct deployment, the possibility of permanent majority lose is very low. But it is a severe enough problem that worth special care. We strongly suggest you to read the [disaster recovery documentation][disaster-recovery] and prepare for permanent majority lose before you put etcd into production.
+
+## Do Not Use Public Discovery Service For Runtime Reconfiguration
+
+The public discovery service should only be used for bootstrapping a cluster. To join member into an existing cluster, you should use runtime reconfiguration API.
+
+Discovery service is designed for bootstrapping an etcd cluster in the cloud environment, when you do not know the IP addresses of all the members beforehand. After you successfully bootstrap a cluster, the IP addresses of all the members are known. Technically, you should not need the discovery service any more.
+
+It seems that using public discovery service is a convenient way to do runtime reconfiguration, after all discovery service already has all the cluster configuration information. However relying on public discovery service brings troubles:
+
+1. it introduces external dependencies for the entire life-cycle of your cluster, not just bootstrap time. If there is a network issue between your cluster and public discovery service, your cluster will suffer from it.
+
+2. public discovery service must reflect correct runtime configuration of your cluster during it life-cycle. It has to provide security mechanism to avoid bad actions, and it is hard.
+
+3. public discovery service has to keep tens of thousands of cluster configurations. Our public discovery service backend is not ready for that workload.
+
+If you want to have a discovery service that supports runtime reconfiguration, the best choice is to build your private one.
+
+[add-member]: runtime-configuration.md#add-a-new-member
+[disaster-recovery]: admin_guide.md#disaster-recovery
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/security.md b/vendor/github.com/coreos/etcd/Documentation/v2/security.md
new file mode 100644
index 00000000..2fd196fd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/security.md
@@ -0,0 +1,199 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Security Model
+
+etcd supports SSL/TLS as well as authentication through client certificates, both for clients to server as well as peer (server to server / cluster) communication.
+
+To get up and running you first need to have a CA certificate and a signed key pair for one member. It is recommended to create and sign a new key pair for every member in a cluster.
+
+For convenience, the [cfssl] tool provides an easy interface to certificate generation, and we provide an example using the tool [here][tls-setup]. You can also examine this [alternative guide to generating self-signed key pairs][tls-guide].
+
+## Basic setup
+
+etcd takes several certificate related configuration options, either through command-line flags or environment variables:
+
+**Client-to-server communication:**
+
+`--cert-file=<path>`: Certificate used for SSL/TLS connections **to** etcd. When this option is set, you can set advertise-client-urls using HTTPS schema.
+
+`--key-file=<path>`: Key for the certificate. Must be unencrypted.
+
+`--client-cert-auth`: When this is set etcd will check all incoming HTTPS requests for a client certificate signed by the trusted CA, requests that don't supply a valid client certificate will fail. If [authentication][auth] is enabled, the certificate provides credentials for the user name given by the Common Name field.
+
+`--trusted-ca-file=<path>`: Trusted certificate authority.
+
+**Peer (server-to-server / cluster) communication:**
+
+The peer options work the same way as the client-to-server options:
+
+`--peer-cert-file=<path>`: Certificate used for SSL/TLS connections between peers. This will be used both for listening on the peer address as well as sending requests to other peers.
+
+`--peer-key-file=<path>`: Key for the certificate. Must be unencrypted.
+
+`--peer-client-cert-auth`: When set, etcd will check all incoming peer requests from the cluster for valid client certificates signed by the supplied CA.
+
+`--peer-trusted-ca-file=<path>`: Trusted certificate authority.
+
+If either a client-to-server or peer certificate is supplied the key must also be set. All of these configuration options are also available through the environment variables, `ETCD_CA_FILE`, `ETCD_PEER_CA_FILE` and so on.
+
+## Example 1: Client-to-server transport security with HTTPS
+
+For this you need your CA certificate (`ca.crt`) and signed key pair (`server.crt`, `server.key`) ready.
+
+Let us configure etcd to provide simple HTTPS transport security step by step:
+
+```sh
+$ etcd -name infra0 -data-dir infra0 \
+ -cert-file=/path/to/server.crt -key-file=/path/to/server.key \
+ -advertise-client-urls=https://127.0.0.1:2379 -listen-client-urls=https://127.0.0.1:2379
+```
+
+This should start up fine and you can now test the configuration by speaking HTTPS to etcd:
+
+```sh
+$ curl --cacert /path/to/ca.crt https://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -v
+```
+
+You should be able to see the handshake succeed. Because we use self-signed certificates with our own certificate authorities you need to provide the CA to curl using the `--cacert` option. Another possibility would be to add your CA certificate to the trusted certificates on your system (usually in `/etc/ssl/certs`).
+
+**OSX 10.9+ Users**: curl 7.30.0 on OSX 10.9+ doesn't understand certificates passed in on the command line.
+Instead you must import the dummy ca.crt directly into the keychain or add the `-k` flag to curl to ignore errors.
+If you want to test without the `-k` flag run `open ./fixtures/ca/ca.crt` and follow the prompts.
+Please remove this certificate after you are done testing!
+If you know of a workaround let us know.
+
+## Example 2: Client-to-server authentication with HTTPS client certificates
+
+For now we've given the etcd client the ability to verify the server identity and provide transport security. We can however also use client certificates to prevent unauthorized access to etcd.
+
+The clients will provide their certificates to the server and the server will check whether the cert is signed by the supplied CA and decide whether to serve the request.
+
+You need the same files mentioned in the first example for this, as well as a key pair for the client (`client.crt`, `client.key`) signed by the same certificate authority.
+
+```sh
+$ etcd -name infra0 -data-dir infra0 \
+ -client-cert-auth -trusted-ca-file=/path/to/ca.crt -cert-file=/path/to/server.crt -key-file=/path/to/server.key \
+ -advertise-client-urls https://127.0.0.1:2379 -listen-client-urls https://127.0.0.1:2379
+```
+
+Now try the same request as above to this server:
+
+```sh
+$ curl --cacert /path/to/ca.crt https://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -v
+```
+
+The request should be rejected by the server:
+
+```
+...
+routines:SSL3_READ_BYTES:sslv3 alert bad certificate
+...
+```
+
+To make it succeed, we need to give the CA signed client certificate to the server:
+
+```sh
+$ curl --cacert /path/to/ca.crt --cert /path/to/client.crt --key /path/to/client.key \
+ -L https://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -v
+```
+
+You should be able to see:
+
+```
+...
+SSLv3, TLS handshake, CERT verify (15):
+...
+TLS handshake, Finished (20)
+```
+
+And also the response from the server:
+
+```json
+{
+ "action": "set",
+ "node": {
+ "createdIndex": 12,
+ "key": "/foo",
+ "modifiedIndex": 12,
+ "value": "bar"
+ }
+}
+```
+
+## Example 3: Transport security & client certificates in a cluster
+
+etcd supports the same model as above for **peer communication**, that means the communication between etcd members in a cluster.
+
+Assuming we have our `ca.crt` and two members with their own keypairs (`member1.crt` & `member1.key`, `member2.crt` & `member2.key`) signed by this CA, we launch etcd as follows:
+
+
+```sh
+DISCOVERY_URL=... # from https://discovery.etcd.io/new
+
+# member1
+$ etcd -name infra1 -data-dir infra1 \
+ -peer-client-cert-auth -peer-trusted-ca-file=/path/to/ca.crt -peer-cert-file=/path/to/member1.crt -peer-key-file=/path/to/member1.key \
+ -initial-advertise-peer-urls=https://10.0.1.10:2380 -listen-peer-urls=https://10.0.1.10:2380 \
+ -discovery ${DISCOVERY_URL}
+
+# member2
+$ etcd -name infra2 -data-dir infra2 \
+ -peer-client-cert-auth -peer-trusted-ca-file=/path/to/ca.crt -peer-cert-file=/path/to/member2.crt -peer-key-file=/path/to/member2.key \
+ -initial-advertise-peer-urls=https://10.0.1.11:2380 -listen-peer-urls=https://10.0.1.11:2380 \
+ -discovery ${DISCOVERY_URL}
+```
+
+The etcd members will form a cluster and all communication between members in the cluster will be encrypted and authenticated using the client certificates. You will see in the output of etcd that the addresses it connects to use HTTPS.
+
+## Notes For etcd Proxy
+
+etcd proxy terminates the TLS from its client if the connection is secure, and uses proxy's own key/cert specified in `--peer-key-file` and `--peer-cert-file` to communicate with etcd members.
+
+The proxy communicates with etcd members through both the `--advertise-client-urls` and `--advertise-peer-urls` of a given member. It forwards client requests to etcd members? advertised client urls, and it syncs the initial cluster configuration through etcd members? advertised peer urls.
+
+When client authentication is enabled for an etcd member, the administrator must ensure that the peer certificate specified in the proxy's `--peer-cert-file` option is valid for that authentication. The proxy's peer certificate must also be valid for peer authentication if peer authentication is enabled.
+
+## Frequently Asked Questions
+
+### My cluster is not working with peer tls configuration?
+
+The internal protocol of etcd v2.0.x uses a lot of short-lived HTTP connections.
+So, when enabling TLS you may need to increase the heartbeat interval and election timeouts to reduce internal cluster connection churn.
+A reasonable place to start are these values: ` --heartbeat-interval 500 --election-timeout 2500`.
+These issues are resolved in the etcd v2.1.x series of releases which uses fewer connections.
+
+### I'm seeing a SSLv3 alert handshake failure when using SSL client authentication?
+
+The `crypto/tls` package of `golang` checks the key usage of the certificate public key before using it.
+To use the certificate public key to do client auth, we need to add `clientAuth` to `Extended Key Usage` when creating the certificate public key.
+
+Here is how to do it:
+
+Add the following section to your openssl.cnf:
+
+```
+[ ssl_client ]
+...
+ extendedKeyUsage = clientAuth
+...
+```
+
+When creating the cert be sure to reference it in the `-extensions` flag:
+
+```
+$ openssl ca -config openssl.cnf -policy policy_anything -extensions ssl_client -out certs/machine.crt -infiles machine.csr
+```
+
+### With peer certificate authentication I receive "certificate is valid for 127.0.0.1, not $MY_IP"
+Make sure that you sign your certificates with a Subject Name your member's public IP address. The `etcd-ca` tool for example provides an `--ip=` option for its `new-cert` command.
+
+If you need your certificate to be signed for your member's FQDN in its Subject Name then you could use Subject Alternative Names (short IP SANs) to add your IP address. The `etcd-ca` tool provides `--domain=` option for its `new-cert` command, and openssl can make [it][alt-name] too.
+
+[cfssl]: https://github.com/cloudflare/cfssl
+[tls-setup]: ../../hack/tls-setup
+[tls-guide]: https://github.com/coreos/docs/blob/master/os/generate-self-signed-certificates.md
+[alt-name]: http://wiki.cacert.org/FAQ/subjectAltName
+[auth]: authentication.md
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/tuning.md b/vendor/github.com/coreos/etcd/Documentation/v2/tuning.md
new file mode 100644
index 00000000..290e887c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/tuning.md
@@ -0,0 +1,80 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Tuning
+
+The default settings in etcd should work well for installations on a local network where the average network latency is low.
+However, when using etcd across multiple data centers or over networks with high latency you may need to tweak the heartbeat interval and election timeout settings.
+
+The network isn't the only source of latency. Each request and response may be impacted by slow disks on both the leader and follower. Each of these timeouts represents the total time from request to successful response from the other machine.
+
+## Time Parameters
+
+The underlying distributed consensus protocol relies on two separate time parameters to ensure that nodes can handoff leadership if one stalls or goes offline.
+The first parameter is called the *Heartbeat Interval*.
+This is the frequency with which the leader will notify followers that it is still the leader.
+For best practices, the parameter should be set around round-trip time between members.
+By default, etcd uses a `100ms` heartbeat interval.
+
+The second parameter is the *Election Timeout*.
+This timeout is how long a follower node will go without hearing a heartbeat before attempting to become leader itself.
+By default, etcd uses a `1000ms` election timeout.
+
+Adjusting these values is a trade off.
+The value of heartbeat interval is recommended to be around the maximum of average round-trip time (RTT) between members, normally around 0.5-1.5x the round-trip time.
+If heartbeat interval is too low, etcd will send unnecessary messages that increase the usage of CPU and network resources.
+On the other side, a too high heartbeat interval leads to high election timeout. Higher election timeout takes longer time to detect a leader failure.
+The easiest way to measure round-trip time (RTT) is to use [PING utility][ping].
+
+The election timeout should be set based on the heartbeat interval and average round-trip time between members.
+Election timeouts must be at least 10 times the round-trip time so it can account for variance in your network.
+For example, if the round-trip time between your members is 10ms then you should have at least a 100ms election timeout.
+
+You should also set your election timeout to at least 5 to 10 times your heartbeat interval to account for variance in leader replication.
+For a heartbeat interval of 50ms you should set your election timeout to at least 250ms - 500ms.
+
+The upper limit of election timeout is 50000ms (50s), which should only be used when deploying a globally-distributed etcd cluster.
+A reasonable round-trip time for the continental United States is 130ms, and the time between US and Japan is around 350-400ms.
+If your network has uneven performance or regular packet delays/loss then it is possible that a couple of retries may be necessary to successfully send a packet. So 5s is a safe upper limit of global round-trip time.
+As the election timeout should be an order of magnitude bigger than broadcast time, in the case of ~5s for a globally distributed cluster, then 50 seconds becomes a reasonable maximum.
+
+The heartbeat interval and election timeout value should be the same for all members in one cluster. Setting different values for etcd members may disrupt cluster stability.
+
+You can override the default values on the command line:
+
+```sh
+# Command line arguments:
+$ etcd -heartbeat-interval=100 -election-timeout=500
+
+# Environment variables:
+$ ETCD_HEARTBEAT_INTERVAL=100 ETCD_ELECTION_TIMEOUT=500 etcd
+```
+
+The values are specified in milliseconds.
+
+## Snapshots
+
+etcd appends all key changes to a log file.
+This log grows forever and is a complete linear history of every change made to the keys.
+A complete history works well for lightly used clusters but clusters that are heavily used would carry around a large log.
+
+To avoid having a huge log etcd makes periodic snapshots.
+These snapshots provide a way for etcd to compact the log by saving the current state of the system and removing old logs.
+
+### Snapshot Tuning
+
+Creating snapshots can be expensive so they're only created after a given number of changes to etcd.
+By default, snapshots will be made after every 10,000 changes.
+If etcd's memory usage and disk usage are too high, you can lower the snapshot threshold by setting the following on the command line:
+
+```sh
+# Command line arguments:
+$ etcd -snapshot-count=5000
+
+# Environment variables:
+$ ETCD_SNAPSHOT_COUNT=5000 etcd
+```
+
+[ping]: https://en.wikipedia.org/wiki/Ping_(networking_utility)
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/upgrade_2_1.md b/vendor/github.com/coreos/etcd/Documentation/v2/upgrade_2_1.md
new file mode 100644
index 00000000..07ce3577
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/upgrade_2_1.md
@@ -0,0 +1,121 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Upgrade etcd to 2.1
+
+In the general case, upgrading from etcd 2.0 to 2.1 can be a zero-downtime, rolling upgrade:
+ - one by one, stop the etcd v2.0 processes and replace them with etcd v2.1 processes
+ - after you are running all v2.1 processes, new features in v2.1 are available to the cluster
+
+Before [starting an upgrade](#upgrade-procedure), read through the rest of this guide to prepare.
+
+## Upgrade Checklists
+
+### Upgrade Requirements
+
+To upgrade an existing etcd deployment to 2.1, you must be running 2.0. If you?re running a version of etcd before 2.0, you must upgrade to [2.0][v2.0] before upgrading to 2.1.
+
+Also, to ensure a smooth rolling upgrade, your running cluster must be healthy. You can check the health of the cluster by using `etcdctl cluster-health` command.
+
+### Preparedness
+
+Before upgrading etcd, always test the services relying on etcd in a staging environment before deploying the upgrade to the production environment.
+
+You might also want to [backup your data directory][backup-datastore] for a potential [downgrade](#downgrade).
+
+etcd 2.1 introduces a new [authentication][auth] feature, which is disabled by default. If your deployment depends on these, you may want to test the auth features before enabling them in production.
+
+### Mixed Versions
+
+While upgrading, an etcd cluster supports mixed versions of etcd members. The cluster is only considered upgraded once all its members are upgraded to 2.1.
+
+Internally, etcd members negotiate with each other to determine the overall etcd cluster version, which controls the reported cluster version and the supported features. For example, if you are mid-upgrade, any 2.1 features (such as the the authentication feature mentioned above) won?t be available.
+
+### Limitations
+
+If you encounter any issues during the upgrade, you can attempt to restart the etcd process in trouble using a newer v2.1 binary to solve the problem. One known issue is that etcd v2.0.0 and v2.0.2 may panic during rolling upgrades due to an existing bug, which has been fixed since etcd v2.0.3.
+
+It might take up to 2 minutes for the newly upgraded member to catch up with the existing cluster when the total data size is larger than 50MB (You can check the size of the existing snapshot to know about the rough data size). In other words, it is safest to wait for 2 minutes before upgrading the next member.
+
+If you have even more data, this might take more time. If you have a data size larger than 100MB you should contact us before upgrading, so we can make sure the upgrades work smoothly.
+
+### Downgrade
+
+If all members have been upgraded to v2.1, the cluster will be upgraded to v2.1, and downgrade is **not possible**. If any member is still v2.0, the cluster will remain in v2.0, and you can go back to use v2.0 binary.
+
+Please [backup your data directory][backup-datastore] of all etcd members if you want to downgrade the cluster, even if it is upgraded.
+
+### Upgrade Procedure
+
+#### 1. Check upgrade requirements.
+
+```
+$ etcdctl cluster-health
+cluster is healthy
+member 6e3bd23ae5f1eae0 is healthy
+member 924e2e83e93f2560 is healthy
+member a8266ecf031671f3 is healthy
+
+$ curl http://127.0.0.1:4001/version
+etcd 2.0.x
+```
+
+#### 2. Stop the existing etcd process
+
+You will see similar error logging from other etcd processes in your cluster. This is normal, since you just shut down a member.
+
+```
+2015/06/23 15:45:09 sender: error posting to 6e3bd23ae5f1eae0: dial tcp 127.0.0.1:7002: connection refused
+2015/06/23 15:45:09 sender: the connection with 6e3bd23ae5f1eae0 became inactive
+2015/06/23 15:45:11 rafthttp: encountered error writing to server log stream: write tcp 127.0.0.1:53783: broken pipe
+2015/06/23 15:45:11 rafthttp: server streaming to 6e3bd23ae5f1eae0 at term 2 has been stopped
+2015/06/23 15:45:11 stream: error sending message: stopped
+2015/06/23 15:45:11 stream: stopping the stream server...
+```
+
+You could [backup your data directory][backup-datastore] for data safety.
+
+```
+$ etcdctl backup \
+ --data-dir /var/lib/etcd \
+ --backup-dir /tmp/etcd_backup
+```
+
+#### 3. Drop-in etcd v2.1 binary and start the new etcd process
+
+You will see the etcd publish its information to the cluster.
+
+```
+2015/06/23 15:45:39 etcdserver: published {Name:infra2 ClientURLs:[http://localhost:4002]} to cluster e9c7614f68f35fb2
+```
+
+You could verify the cluster becomes healthy.
+
+```
+$ etcdctl cluster-health
+cluster is healthy
+member 6e3bd23ae5f1eae0 is healthy
+member 924e2e83e93f2560 is healthy
+member a8266ecf031671f3 is healthy
+```
+
+#### 4. Repeat step 2 to step 3 for all other members
+
+#### 5. Finish
+
+When all members are upgraded, you will see the cluster is upgraded to 2.1 successfully:
+
+```
+2015/06/23 15:46:35 etcdserver: updated the cluster version from 2.0.0 to 2.1.0
+```
+
+```
+$ curl http://127.0.0.1:4001/version
+{"etcdserver":"2.1.x","etcdcluster":"2.1.0"}
+```
+
+[auth]: auth_api.md
+[backup-datastore]: admin_guide.md#backing-up-the-datastore
+[v2.0]: https://github.com/coreos/etcd/releases/tag/v2.0.13
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/upgrade_2_2.md b/vendor/github.com/coreos/etcd/Documentation/v2/upgrade_2_2.md
new file mode 100644
index 00000000..76fcf811
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/upgrade_2_2.md
@@ -0,0 +1,137 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+# Upgrade etcd from 2.1 to 2.2
+
+In the general case, upgrading from etcd 2.1 to 2.2 can be a zero-downtime, rolling upgrade:
+
+ - one by one, stop the etcd v2.1 processes and replace them with etcd v2.2 processes
+ - after you are running all v2.2 processes, new features in v2.2 are available to the cluster
+
+Before [starting an upgrade](#upgrade-procedure), read through the rest of this guide to prepare.
+
+## Upgrade Checklists
+
+### Upgrade Requirement
+
+To upgrade an existing etcd deployment to 2.2, you must be running 2.1. If you?re running a version of etcd before 2.1, you must upgrade to [2.1][v2.1] before upgrading to 2.2.
+
+Also, to ensure a smooth rolling upgrade, your running cluster must be healthy. You can check the health of the cluster by using `etcdctl cluster-health` command.
+
+### Preparedness
+
+Before upgrading etcd, always test the services relying on etcd in a staging environment before deploying the upgrade to the production environment.
+
+You might also want to [backup the data directory][backup-datastore] for a potential [downgrade].
+
+### Mixed Versions
+
+While upgrading, an etcd cluster supports mixed versions of etcd members. The cluster is only considered upgraded once all its members are upgraded to 2.2.
+
+Internally, etcd members negotiate with each other to determine the overall etcd cluster version, which controls the reported cluster version and the supported features.
+
+### Limitations
+
+If you have a data size larger than 100MB you should contact us before upgrading, so we can make sure the upgrades work smoothly.
+
+Every etcd 2.2 member will do health checking across the cluster periodically. etcd 2.1 member does not support health checking. During the upgrade, etcd 2.2 member will log warning about the unhealthy state of etcd 2.1 member. You can ignore the warning.
+
+### Downgrade
+
+If all members have been upgraded to v2.2, the cluster will be upgraded to v2.2, and downgrade is **not possible**. If any member is still v2.1, the cluster will remain in v2.1, and you can go back to use v2.1 binary.
+
+Please [backup the data directory][backup-datastore] of all etcd members if you want to downgrade the cluster, even if it is upgraded.
+
+### Upgrade Procedure
+
+In the example, we upgrade a three member v2.1 cluster running on local machine.
+
+#### 1. Check upgrade requirements.
+
+```
+$ etcdctl cluster-health
+member 6e3bd23ae5f1eae0 is healthy: got healthy result from http://localhost:22379
+member 924e2e83e93f2560 is healthy: got healthy result from http://localhost:32379
+member a8266ecf031671f3 is healthy: got healthy result from http://localhost:12379
+cluster is healthy
+
+$ curl http://localhost:4001/version
+{"etcdserver":"2.1.x","etcdcluster":"2.1.0"}
+```
+
+#### 2. Stop the existing etcd process
+
+You will see similar error logging from other etcd processes in your cluster. This is normal, since you just shut down a member and the connection is broken.
+
+```
+2015/09/2 09:48:35 etcdserver: failed to reach the peerURL(http://localhost:12380) of member a8266ecf031671f3 (Get http://localhost:12380/version: dial tcp [::1]:12380: getsockopt: connection refused)
+2015/09/2 09:48:35 etcdserver: cannot get the version of member a8266ecf031671f3 (Get http://localhost:12380/version: dial tcp [::1]:12380: getsockopt: connection refused)
+2015/09/2 09:48:35 rafthttp: failed to write a8266ecf031671f3 on stream Message (write tcp 127.0.0.1:32380->127.0.0.1:64394: write: broken pipe)
+2015/09/2 09:48:35 rafthttp: failed to write a8266ecf031671f3 on pipeline (dial tcp [::1]:12380: getsockopt: connection refused)
+2015/09/2 09:48:40 etcdserver: failed to reach the peerURL(http://localhost:7001) of member a8266ecf031671f3 (Get http://localhost:7001/version: dial tcp [::1]:12380: getsockopt: connection refused)
+2015/09/2 09:48:40 etcdserver: cannot get the version of member a8266ecf031671f3 (Get http://localhost:12380/version: dial tcp [::1]:12380: getsockopt: connection refused)
+2015/09/2 09:48:40 rafthttp: failed to heartbeat a8266ecf031671f3 on stream MsgApp v2 (write tcp 127.0.0.1:32380->127.0.0.1:64393: write: broken pipe)
+```
+
+You will see logging output like this from ungraded member due to a mixed version cluster. You can ignore this while upgrading.
+
+```
+2015/09/2 09:48:45 etcdserver: the etcd version 2.1.2+git is not up-to-date
+2015/09/2 09:48:45 etcdserver: member a8266ecf031671f3 has a higher version &{2.2.0-rc.0+git 2.1.0}
+```
+
+You will also see logging output like this from the newly upgraded member, since etcd 2.1 member does not support health checking. You can ignore this while upgrading.
+
+```
+2015-09-02 09:55:42.691384 W | rafthttp: the connection to peer 6e3bd23ae5f1eae0 is unhealthy
+2015-09-02 09:55:42.705626 W | rafthttp: the connection to peer 924e2e83e93f2560 is unhealthy
+
+```
+
+[Backup your data directory][backup-datastore] for data safety.
+
+```
+$ etcdctl backup \
+ --data-dir /var/lib/etcd \
+ --backup-dir /tmp/etcd_backup
+```
+
+#### 3. Drop-in etcd v2.2 binary and start the new etcd process
+
+Now, you can start the etcd v2.2 binary with the previous configuration.
+You will see the etcd start and publish its information to the cluster.
+
+```
+2015-09-02 09:56:46.117609 I | etcdserver: published {Name:infra2 ClientURLs:[http://localhost:22380]} to cluster e9c7614f68f35fb2
+```
+
+You could verify the cluster becomes healthy.
+
+```
+$ etcdctl cluster-health
+member 6e3bd23ae5f1eae0 is healthy: got healthy result from http://localhost:22379
+member 924e2e83e93f2560 is healthy: got healthy result from http://localhost:32379
+member a8266ecf031671f3 is healthy: got healthy result from http://localhost:12379
+cluster is healthy
+```
+
+#### 4. Repeat step 2 to step 3 for all other members
+
+#### 5. Finish
+
+When all members are upgraded, you will see the cluster is upgraded to 2.2 successfully:
+
+```
+2015-09-02 09:56:54.896848 N | etcdserver: updated the cluster version from 2.1 to 2.2
+```
+
+```
+$ curl http://127.0.0.1:4001/version
+{"etcdserver":"2.2.x","etcdcluster":"2.2.0"}
+```
+
+[backup-datastore]: admin_guide.md#backing-up-the-datastore
+[downgrade]: #downgrade
+[v2.1]: https://github.com/coreos/etcd/releases/tag/v2.1.2
diff --git a/vendor/github.com/coreos/etcd/Documentation/v2/upgrade_2_3.md b/vendor/github.com/coreos/etcd/Documentation/v2/upgrade_2_3.md
new file mode 100644
index 00000000..95ddbbf4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Documentation/v2/upgrade_2_3.md
@@ -0,0 +1,126 @@
+**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
+
+[v3-docs]: ../docs.md#documentation
+
+
+## Upgrade etcd from 2.2 to 2.3
+
+In the general case, upgrading from etcd 2.2 to 2.3 can be a zero-downtime, rolling upgrade:
+ - one by one, stop the etcd v2.2 processes and replace them with etcd v2.3 processes
+ - after running all v2.3 processes, new features in v2.3 are available to the cluster
+
+Before [starting an upgrade](#upgrade-procedure), read through the rest of this guide to prepare.
+
+### Upgrade Checklists
+
+#### Upgrade Requirements
+
+To upgrade an existing etcd deployment to 2.3, the running cluster must be 2.2 or greater. If it's before 2.2, please upgrade to [2.2](https://github.com/coreos/etcd/releases/tag/v2.2.0) before upgrading to 2.3.
+
+Also, to ensure a smooth rolling upgrade, the running cluster must be healthy. You can check the health of the cluster by using the `etcdctl cluster-health` command.
+
+#### Preparation
+
+Before upgrading etcd, always test the services relying on etcd in a staging environment before deploying the upgrade to the production environment.
+
+Before beginning, [backup the etcd data directory](admin_guide.md#backing-up-the-datastore). Should something go wrong with the upgrade, it is possible to use this backup to[downgrade](#downgrade) back to existing etcd version.
+
+#### Mixed Versions
+
+While upgrading, an etcd cluster supports mixed versions of etcd members, and operates with the protocol of the lowest common version. The cluster is only considered upgraded once all of its members are upgraded to version 2.3. Internally, etcd members negotiate with each other to determine the overall cluster version, which controls the reported version and the supported features.
+
+#### Limitations
+
+It might take up to 2 minutes for the newly upgraded member to catch up with the existing cluster when the total data size is larger than 50MB. Check the size of a recent snapshot to estimate the total data size. In other words, it is safest to wait for 2 minutes between upgrading each member.
+
+For a much larger total data size, 100MB or more , this one-time process might take even more time. Administrators of very large etcd clusters of this magnitude can feel free to contact the [etcd team][etcd-contact] before upgrading, and we?ll be happy to provide advice on the procedure.
+
+#### Downgrade
+
+If all members have been upgraded to v2.3, the cluster will be upgraded to v2.3, and downgrade from this completed state is **not possible**. If any single member is still v2.2, however, the cluster and its operations remains ?v2.2?, and it is possible from this mixed cluster state to return to using a v2.2 etcd binary on all members.
+
+Please [backup the data directory](admin_guide.md#backing-up-the-datastore) of all etcd members to make downgrading the cluster possible even after it has been completely upgraded.
+
+### Upgrade Procedure
+
+
+This example details the upgrade of a three-member v2.2 ectd cluster running on a local machine.
+
+#### 1. Check upgrade requirements.
+
+Is the the cluster healthy and running v.2.2.x?
+
+```
+$ etcdctl cluster-health
+member 6e3bd23ae5f1eae0 is healthy: got healthy result from http://localhost:22379
+member 924e2e83e93f2560 is healthy: got healthy result from http://localhost:32379
+member a8266ecf031671f3 is healthy: got healthy result from http://localhost:12379
+cluster is healthy
+
+$ curl http://localhost:4001/version
+{"etcdserver":"2.2.x","etcdcluster":"2.2.0"}
+```
+
+#### 2. Stop the existing etcd process
+
+When each etcd process is stopped, expected errors will be logged by other cluster members. This is normal since a cluster member connection has been (temporarily) broken:
+
+```
+2016-03-11 09:50:49.860319 E | rafthttp: failed to read 8211f1d0f64f3269 on stream Message (unexpected EOF)
+2016-03-11 09:50:49.860335 I | rafthttp: the connection with 8211f1d0f64f3269 became inactive
+2016-03-11 09:50:51.023804 W | etcdserver: failed to reach the peerURL(http://127.0.0.1:12380) of member 8211f1d0f64f3269 (Get http://127.0.0.1:12380/version: dial tcp 127.0.0.1:12380: getsockopt: connection refused)
+2016-03-11 09:50:51.023821 W | etcdserver: cannot get the version of member 8211f1d0f64f3269 (Get http://127.0.0.1:12380/version: dial tcp 127.0.0.1:12380: getsockopt: connection refused)
+```
+
+It?s a good idea at this point to [backup the etcd data directory](https://github.com/coreos/etcd/blob/7f7e2cc79d9c5c342a6eb1e48c386b0223cf934e/Documentation/admin_guide.md#backing-up-the-datastore) to provide a downgrade path should any problems occur:
+
+```
+$ etcdctl backup \
+ --data-dir /var/lib/etcd \
+ --backup-dir /tmp/etcd_backup
+```
+
+#### 3. Drop-in etcd v2.3 binary and start the new etcd process
+
+The new v2.3 etcd will publish its information to the cluster:
+
+```
+09:58:25.938673 I | etcdserver: published {Name:infra1 ClientURLs:[http://localhost:12379]} to cluster 524400597fb1d5f6
+```
+
+Verify that each member, and then the entire cluster, becomes healthy with the new v2.3 etcd binary:
+
+```
+$ etcdctl cluster-health
+member 6e3bd23ae5f1eae0 is healthy: got healthy result from http://localhost:22379
+member 924e2e83e93f2560 is healthy: got healthy result from http://localhost:32379
+member a8266ecf031671f3 is healthy: got healthy result from http://localhost:12379
+cluster is healthy
+```
+
+
+Upgraded members will log warnings like the following until the entire cluster is upgraded. This is expected and will cease after all etcd cluster members are upgraded to v2.3:
+
+```
+2016-03-11 09:58:26.851837 W | etcdserver: the local etcd version 2.2.0 is not up-to-date
+2016-03-11 09:58:26.851854 W | etcdserver: member c02c70ede158499f has a higher version 2.3.0
+```
+
+#### 4. Repeat step 2 to step 3 for all other members
+
+#### 5. Finish
+
+When all members are upgraded, the cluster will report upgrading to 2.3 successfully:
+
+```
+2016-03-11 10:03:01.583392 N | etcdserver: updated the cluster version from 2.2 to 2.3
+```
+
+```
+$ curl http://127.0.0.1:4001/version
+{"etcdserver":"2.3.x","etcdcluster":"2.3.0"}
+```
+
+
+[etcd-contact]: https://coreos.com/etcd/?
+
diff --git a/vendor/github.com/coreos/etcd/LICENSE b/vendor/github.com/coreos/etcd/LICENSE
new file mode 100644
index 00000000..d6456956
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
diff --git a/vendor/github.com/coreos/etcd/MAINTAINERS b/vendor/github.com/coreos/etcd/MAINTAINERS
new file mode 100644
index 00000000..9983e3c5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/MAINTAINERS
@@ -0,0 +1,8 @@
+Anthony Romano <an...@coreos.com> (@heyitsanthony) pkg:*
+Brandon Philips <br...@coreos.com> (@philips) pkg:*
+Fanmin Shi <fa...@coreos.com> (@fanminshi) pkg:*
+Gyu-Ho Lee <gy...@coreos.com> (@gyuho) pkg:*
+Xiang Li <xi...@coreos.com> (@xiang90) pkg:*
+
+Ben Darnell <be...@cockroachlabs.com> (@bdarnell) pkg:github.com/coreos/etcd/raft
+Hitoshi Mitake <mi...@lab.ntt.co.jp> (@mitake) pkg:github.com/coreos/etcd/auth
diff --git a/vendor/github.com/coreos/etcd/NEWS b/vendor/github.com/coreos/etcd/NEWS
new file mode 100644
index 00000000..b11975f3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/NEWS
@@ -0,0 +1,106 @@
+etcd v3.1.6 (2017-04-19)
+- remove auth check in Status API
+- fill in Auth API response header
+
+etcd v3.1.5 (2017-03-27)
+- add '/etc/nsswitch.conf' file to alpine-based Docker image
+- fix raft memory leak issue
+- fix Windows file path issues
+
+etcd v3.1.4 (2017-03-22)
+
+etcd v3.1.3 (2017-03-10)
+- use machine default host when advertise URLs are default
+ values(localhost:2379,2380) AND if listen URL is 0.0.0.0
+- fix 'etcd gateway' schema handling in DNS discovery
+- fix sd_notify behaviors in gateway, grpc-proxy
+
+etcd v3.1.2 (2017-02-24)
+- use IPv4 default host, by default (when IPv4 and IPv6 are available)
+- fix 'etcd gateway' with multiple endpoints
+
+etcd v3.1.1 (2017-02-17)
+
+etcd v2.3.8 (2017-02-17)
+
+etcd v3.1.0 (2017-01-20)
+- faster linearizable reads (implements Raft read-index)
+- automatic leadership transfer when leader steps down
+- etcd uses default route IP if advertise URL is not given
+- cluster rejects removing members if quorum will be lost
+- SRV records (e.g., infra1.example.com) must match the discovery domain
+ (i.e., example.com) if no custom certificate authority is given
+ - TLSConfig ServerName is ignored with user-provided certificates
+ for backwards compatibility; to be deprecated in 3.2
+- discovery now has upper limit for waiting on retries
+- etcd flags
+ - --strict-reconfig-check flag is set by default
+ - add --log-output flag
+ - add --metrics flag
+- v3 authentication API is now stable
+- v3 client
+ - add SetEndpoints method; update endpoints at runtime
+ - add Sync method; auto-update endpoints at runtime
+ - add Lease TimeToLive API; fetch lease information
+ - replace Config.Logger field with global logger
+ - Get API responses are sorted in ascending order by default
+- v3 etcdctl
+ - add lease timetolive command
+ - add --print-value-only flag to get command
+ - add --dest-prefix flag to make-mirror command
+ - command get responses are sorted in ascending order by default
+- recipes now conform to sessions defined in clientv3/concurrency
+- ACI has symlinks to /usr/local/bin/etcd*
+- warn on binding listeners through domain names; to be deprecated in 3.2
+- experimental gRPC proxy feature
+
+etcd v3.0.16 (2017-01-13)
+
+etcd v3.0.15 (2016-11-11)
+- fix cancel watch request with wrong range end
+
+etcd v3.0.14 (2016-11-04)
+- v3 etcdctl migrate command now supports --no-ttl flag to discard keys on transform
+
+etcd v3.0.13 (2016-10-24)
+
+etcd v3.0.12 (2016-10-07)
+
+etcd v3.0.11 (2016-10-07)
+- server returns previous key-value (optional)
+ - clientv3 WithPrevKV option
+ - v3 etcdctl put,watch,del --prev-kv flag
+
+etcd v3.0.10 (2016-09-23)
+
+etcd v3.0.9 (2016-09-15)
+- warn on domain names on listen URLs (v3.2 will reject domain names)
+
+etcd v3.0.8 (2016-09-09)
+- allow only IP addresses in listen URLs (domain names are rejected)
+
+etcd v3.0.7 (2016-08-31)
+- SRV records only allow A records (RFC 2052)
+
+etcd v3.0.6 (2016-08-19)
+
+etcd v3.0.5 (2016-08-19)
+- SRV records (e.g., infra1.example.com) must match the discovery domain
+ (i.e., example.com) if no custom certificate authority is given
+
+etcd v3.0.4 (2016-07-27)
+- v2 auth can now use common name from TLS certificate when --client-cert-auth is enabled
+- v2 etcdctl ls command now supports --output=json
+- Add /var/lib/etcd directory to etcd official Docker image
+
+etcd v3.0.3 (2016-07-15)
+- Revert Dockerfile to use CMD, instead of ENTRYPOINT, to support etcdctl run
+- Docker commands for v3.0.2 won't work without specifying executable binary paths
+- v3 etcdctl default endpoints are now 127.0.0.1:2379
+
+etcd v3.0.2 (2016-07-08)
+- Dockerfile uses ENTRYPOINT, instead of CMD, to run etcd without binary path specified
+
+etcd v3.0.1 (2016-07-01)
+
+etcd v3.0.0 (2016-06-30)
diff --git a/vendor/github.com/coreos/etcd/NOTICE b/vendor/github.com/coreos/etcd/NOTICE
new file mode 100644
index 00000000..b39ddfa5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/NOTICE
@@ -0,0 +1,5 @@
+CoreOS Project
+Copyright 2014 CoreOS, Inc
+
+This product includes software developed at CoreOS, Inc.
+(http://www.coreos.com/).
diff --git a/vendor/github.com/coreos/etcd/Procfile b/vendor/github.com/coreos/etcd/Procfile
new file mode 100644
index 00000000..41dd49f1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/Procfile
@@ -0,0 +1,6 @@
+# Use goreman to run `go get github.com/mattn/goreman`
+etcd1: bin/etcd --name infra1 --listen-client-urls http://127.0.0.1:2379 --advertise-client-urls http://127.0.0.1:2379 --listen-peer-urls http://127.0.0.1:12380 --initial-advertise-peer-urls http://127.0.0.1:12380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof
+etcd2: bin/etcd --name infra2 --listen-client-urls http://127.0.0.1:22379 --advertise-client-urls http://127.0.0.1:22379 --listen-peer-urls http://127.0.0.1:22380 --initial-advertise-peer-urls http://127.0.0.1:22380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof
+etcd3: bin/etcd --name infra3 --listen-client-urls http://127.0.0.1:32379 --advertise-client-urls http://127.0.0.1:32379 --listen-peer-urls http://127.0.0.1:32380 --initial-advertise-peer-urls http://127.0.0.1:32380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof
+# in future, use proxy to listen on 2379
+#proxy: bin/etcd --name infra-proxy1 --proxy=on --listen-client-urls http://127.0.0.1:2378 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --enable-pprof
diff --git a/vendor/github.com/coreos/etcd/README.md b/vendor/github.com/coreos/etcd/README.md
new file mode 100644
index 00000000..8ab28492
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/README.md
@@ -0,0 +1,135 @@
+# etcd
+
+[![Go Report Card](https://goreportcard.com/badge/github.com/coreos/etcd)](https://goreportcard.com/report/github.com/coreos/etcd)
+[![Build Status](https://travis-ci.org/coreos/etcd.svg?branch=master)](https://travis-ci.org/coreos/etcd)
+[![Build Status](https://semaphoreci.com/api/v1/coreos/etcd/branches/master/shields_badge.svg)](https://semaphoreci.com/coreos/etcd)
+[![Docker Repository on Quay.io](https://quay.io/repository/coreos/etcd-git/status "Docker Repository on Quay.io")](https://quay.io/repository/coreos/etcd-git)
+
+**Note**: The `master` branch may be in an *unstable or even broken state* during development. Please use [releases][github-release] instead of the `master` branch in order to get stable binaries.
+
+*the etcd v2 [documentation](Documentation/v2/README.md) has moved*
+
+![etcd Logo](logos/etcd-horizontal-color.png)
+
+etcd is a distributed reliable key-value store for the most critical data of a distributed system, with a focus on being:
+
+* *Simple*: well-defined, user-facing API (gRPC)
+* *Secure*: automatic TLS with optional client cert authentication
+* *Fast*: benchmarked 10,000 writes/sec
+* *Reliable*: properly distributed using Raft
+
+etcd is written in Go and uses the [Raft][raft] consensus algorithm to manage a highly-available replicated log.
+
+etcd is used [in production by many companies](./Documentation/production-users.md), and the development team stands behind it in critical deployment scenarios, where etcd is frequently teamed with applications such as [Kubernetes][k8s], [fleet][fleet], [locksmith][locksmith], [vulcand][vulcand], [Doorman][doorman], and many others. Reliability is further ensured by rigorous [testing][etcd-tests].
+
+See [etcdctl][etcdctl] for a simple command line client.
+
+[raft]: https://raft.github.io/
+[k8s]: http://kubernetes.io/
+[doorman]: https://github.com/youtube/doorman
+[fleet]: https://github.com/coreos/fleet
+[locksmith]: https://github.com/coreos/locksmith
+[vulcand]: https://github.com/vulcand/vulcand
+[etcdctl]: https://github.com/coreos/etcd/tree/master/etcdctl
+[etcd-tests]: http://dash.etcd.io
+
+## Getting started
+
+### Getting etcd
+
+The easiest way to get etcd is to use one of the pre-built release binaries which are available for OSX, Linux, Windows, [rkt][rkt], and Docker. Instructions for using these binaries are on the [GitHub releases page][github-release].
+
+For those wanting to try the very latest version, [build the latest version of etcd][dl-build] from the `master` branch. This first needs [*Go*](https://golang.org/) installed (version 1.8+ is required). All development occurs on `master`, including new features and bug fixes. Bug fixes are first targeted at `master` and subsequently ported to release branches, as described in the [branch management][branch-management] guide.
+
+[rkt]: https://github.com/rkt/rkt/releases/
+[github-release]: https://github.com/coreos/etcd/releases/
+[branch-management]: ./Documentation/branch_management.md
+[dl-build]: ./Documentation/dl_build.md#build-the-latest-version
+
+### Running etcd
+
+First start a single-member cluster of etcd:
+
+```sh
+./bin/etcd
+```
+
+This will bring up etcd listening on port 2379 for client communication and on port 2380 for server-to-server communication.
+
+Next, let's set a single key, and then retrieve it:
+
+```
+ETCDCTL_API=3 etcdctl put mykey "this is awesome"
+ETCDCTL_API=3 etcdctl get mykey
+```
+
+That's it! etcd is now running and serving client requests. For more
+
+- [Animated quick demo][demo-gif]
+- [Interactive etcd playground][etcd-play]
+
+[demo-gif]: ./Documentation/demo.md
+[etcd-play]: http://play.etcd.io/
+
+### etcd TCP ports
+
+The [official etcd ports][iana-ports] are 2379 for client requests, and 2380 for peer communication.
+
+[iana-ports]: http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt
+
+### Running a local etcd cluster
+
+First install [goreman](https://github.com/mattn/goreman), which manages Procfile-based applications.
+
+Our [Procfile script](./Procfile) will set up a local example cluster. Start it with:
+
+```sh
+goreman start
+```
+
+This will bring up 3 etcd members `infra1`, `infra2` and `infra3` and etcd proxy `proxy`, which runs locally and composes a cluster.
+
+Every cluster member and proxy accepts key value reads and key value writes.
+
+### Running etcd on Kubernetes
+
+To run an etcd cluster on Kubernetes, try [etcd operator](https://github.com/coreos/etcd-operator).
+
+### Next steps
+
+Now it's time to dig into the full etcd API and other guides.
+
+- Read the full [documentation][fulldoc].
+- Explore the full gRPC [API][api].
+- Set up a [multi-machine cluster][clustering].
+- Learn the [config format, env variables and flags][configuration].
+- Find [language bindings and tools][integrations].
+- Use TLS to [secure an etcd cluster][security].
+- [Tune etcd][tuning].
+
+[fulldoc]: ./Documentation/docs.md
+[api]: ./Documentation/dev-guide/api_reference_v3.md
+[clustering]: ./Documentation/op-guide/clustering.md
+[configuration]: ./Documentation/op-guide/configuration.md
+[integrations]: ./Documentation/integrations.md
+[security]: ./Documentation/op-guide/security.md
+[tuning]: ./Documentation/tuning.md
+
+## Contact
+
+- Mailing list: [etcd-dev](https://groups.google.com/forum/?hl=en#!forum/etcd-dev)
+- IRC: #[etcd](irc://irc.freenode.org:6667/#etcd) on freenode.org
+- Planning/Roadmap: [milestones](https://github.com/coreos/etcd/milestones), [roadmap](./ROADMAP.md)
+- Bugs: [issues](https://github.com/coreos/etcd/issues)
+
+## Contributing
+
+See [CONTRIBUTING](CONTRIBUTING.md) for details on submitting patches and the contribution workflow.
+
+## Reporting bugs
+
+See [reporting bugs](Documentation/reporting_bugs.md) for details about reporting any issues.
+
+### License
+
+etcd is under the Apache 2.0 license. See the [LICENSE](LICENSE) file for details.
diff --git a/vendor/github.com/coreos/etcd/ROADMAP.md b/vendor/github.com/coreos/etcd/ROADMAP.md
new file mode 100644
index 00000000..f7ae890d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/ROADMAP.md
@@ -0,0 +1,23 @@
+# etcd roadmap
+
+**work in progress**
+
+This document defines a high level roadmap for etcd development.
+
+The dates below should not be considered authoritative, but rather indicative of the projected timeline of the project. The [milestones defined in GitHub](https://github.com/coreos/etcd/milestones) represent the most up-to-date and issue-for-issue plans.
+
+etcd 3.2 is our current stable branch. The roadmap below outlines new features that will be added to etcd, and while subject to change, define what future stable will look like.
+
+### etcd 3.2 (2017-May)
+- Stable scalable proxy
+- Proxy-as-client interface passthrough
+- Lock service
+- Namespacing proxy
+- TLS Command Name and JWT token based authentication
+- Read-modify-write V3 Put
+- Improved watch performance
+- Support non-blocking concurrent read
+
+### etcd 3.3 (?)
+- TBD
+
diff --git a/vendor/github.com/coreos/etcd/V2Procfile b/vendor/github.com/coreos/etcd/V2Procfile
new file mode 100644
index 00000000..925910f2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/V2Procfile
@@ -0,0 +1,5 @@
+# Use goreman to run `go get github.com/mattn/goreman`
+etcd1: bin/etcd --name infra1 --listen-client-urls http://127.0.0.1:12379 --advertise-client-urls http://127.0.0.1:12379 --listen-peer-urls http://127.0.0.1:12380 --initial-advertise-peer-urls http://127.0.0.1:12380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof
+etcd2: bin/etcd --name infra2 --listen-client-urls http://127.0.0.1:22379 --advertise-client-urls http://127.0.0.1:22379 --listen-peer-urls http://127.0.0.1:22380 --initial-advertise-peer-urls http://127.0.0.1:22380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof
+etcd3: bin/etcd --name infra3 --listen-client-urls http://127.0.0.1:32379 --advertise-client-urls http://127.0.0.1:32379 --listen-peer-urls http://127.0.0.1:32380 --initial-advertise-peer-urls http://127.0.0.1:32380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof
+proxy: bin/etcd --name infra-proxy1 --proxy=on --listen-client-urls http://127.0.0.1:2379 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --enable-pprof
diff --git a/vendor/github.com/coreos/etcd/alarm/alarms.go b/vendor/github.com/coreos/etcd/alarm/alarms.go
new file mode 100644
index 00000000..4f0ebe93
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/alarm/alarms.go
@@ -0,0 +1,152 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 alarm manages health status alarms in etcd.
+package alarm
+
+import (
+ "sync"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/pkg/capnslog"
+)
+
+var (
+ alarmBucketName = []byte("alarm")
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "alarm")
+)
+
+type BackendGetter interface {
+ Backend() backend.Backend
+}
+
+type alarmSet map[types.ID]*pb.AlarmMember
+
+// AlarmStore persists alarms to the backend.
+type AlarmStore struct {
+ mu sync.Mutex
+ types map[pb.AlarmType]alarmSet
+
+ bg BackendGetter
+}
+
+func NewAlarmStore(bg BackendGetter) (*AlarmStore, error) {
+ ret := &AlarmStore{types: make(map[pb.AlarmType]alarmSet), bg: bg}
+ err := ret.restore()
+ return ret, err
+}
+
+func (a *AlarmStore) Activate(id types.ID, at pb.AlarmType) *pb.AlarmMember {
+ a.mu.Lock()
+ defer a.mu.Unlock()
+
+ newAlarm := &pb.AlarmMember{MemberID: uint64(id), Alarm: at}
+ if m := a.addToMap(newAlarm); m != newAlarm {
+ return m
+ }
+
+ v, err := newAlarm.Marshal()
+ if err != nil {
+ plog.Panicf("failed to marshal alarm member")
+ }
+
+ b := a.bg.Backend()
+ b.BatchTx().Lock()
+ b.BatchTx().UnsafePut(alarmBucketName, v, nil)
+ b.BatchTx().Unlock()
+
+ return newAlarm
+}
+
+func (a *AlarmStore) Deactivate(id types.ID, at pb.AlarmType) *pb.AlarmMember {
+ a.mu.Lock()
+ defer a.mu.Unlock()
+
+ t := a.types[at]
+ if t == nil {
+ t = make(alarmSet)
+ a.types[at] = t
+ }
+ m := t[id]
+ if m == nil {
+ return nil
+ }
+
+ delete(t, id)
+
+ v, err := m.Marshal()
+ if err != nil {
+ plog.Panicf("failed to marshal alarm member")
+ }
+
+ b := a.bg.Backend()
+ b.BatchTx().Lock()
+ b.BatchTx().UnsafeDelete(alarmBucketName, v)
+ b.BatchTx().Unlock()
+
+ return m
+}
+
+func (a *AlarmStore) Get(at pb.AlarmType) (ret []*pb.AlarmMember) {
+ a.mu.Lock()
+ defer a.mu.Unlock()
+ if at == pb.AlarmType_NONE {
+ for _, t := range a.types {
+ for _, m := range t {
+ ret = append(ret, m)
+ }
+ }
+ return ret
+ }
+ for _, m := range a.types[at] {
+ ret = append(ret, m)
+ }
+ return ret
+}
+
+func (a *AlarmStore) restore() error {
+ b := a.bg.Backend()
+ tx := b.BatchTx()
+
+ tx.Lock()
+ tx.UnsafeCreateBucket(alarmBucketName)
+ err := tx.UnsafeForEach(alarmBucketName, func(k, v []byte) error {
+ var m pb.AlarmMember
+ if err := m.Unmarshal(k); err != nil {
+ return err
+ }
+ a.addToMap(&m)
+ return nil
+ })
+ tx.Unlock()
+
+ b.ForceCommit()
+ return err
+}
+
+func (a *AlarmStore) addToMap(newAlarm *pb.AlarmMember) *pb.AlarmMember {
+ t := a.types[newAlarm.Alarm]
+ if t == nil {
+ t = make(alarmSet)
+ a.types[newAlarm.Alarm] = t
+ }
+ m := t[types.ID(newAlarm.MemberID)]
+ if m != nil {
+ return m
+ }
+ t[types.ID(newAlarm.MemberID)] = newAlarm
+ return newAlarm
+}
diff --git a/vendor/github.com/coreos/etcd/auth/authpb/auth.pb.go b/vendor/github.com/coreos/etcd/auth/authpb/auth.pb.go
new file mode 100644
index 00000000..009ebda7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/auth/authpb/auth.pb.go
@@ -0,0 +1,824 @@
+// Code generated by protoc-gen-gogo.
+// source: auth.proto
+// DO NOT EDIT!
+
+/*
+ Package authpb is a generated protocol buffer package.
+
+ It is generated from these files:
+ auth.proto
+
+ It has these top-level messages:
+ User
+ Permission
+ Role
+*/
+package authpb
+
+import (
+ "fmt"
+
+ proto "github.com/golang/protobuf/proto"
+
+ math "math"
+
+ io "io"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+type Permission_Type int32
+
+const (
+ READ Permission_Type = 0
+ WRITE Permission_Type = 1
+ READWRITE Permission_Type = 2
+)
+
+var Permission_Type_name = map[int32]string{
+ 0: "READ",
+ 1: "WRITE",
+ 2: "READWRITE",
+}
+var Permission_Type_value = map[string]int32{
+ "READ": 0,
+ "WRITE": 1,
+ "READWRITE": 2,
+}
+
+func (x Permission_Type) String() string {
+ return proto.EnumName(Permission_Type_name, int32(x))
+}
+func (Permission_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptorAuth, []int{1, 0} }
+
+// User is a single entry in the bucket authUsers
+type User struct {
+ Name []byte `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ Password []byte `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
+ Roles []string `protobuf:"bytes,3,rep,name=roles" json:"roles,omitempty"`
+}
+
+func (m *User) Reset() { *m = User{} }
+func (m *User) String() string { return proto.CompactTextString(m) }
+func (*User) ProtoMessage() {}
+func (*User) Descriptor() ([]byte, []int) { return fileDescriptorAuth, []int{0} }
+
+// Permission is a single entity
+type Permission struct {
+ PermType Permission_Type `protobuf:"varint,1,opt,name=permType,proto3,enum=authpb.Permission_Type" json:"permType,omitempty"`
+ Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
+ RangeEnd []byte `protobuf:"bytes,3,opt,name=range_end,json=rangeEnd,proto3" json:"range_end,omitempty"`
+}
+
+func (m *Permission) Reset() { *m = Permission{} }
+func (m *Permission) String() string { return proto.CompactTextString(m) }
+func (*Permission) ProtoMessage() {}
+func (*Permission) Descriptor() ([]byte, []int) { return fileDescriptorAuth, []int{1} }
+
+// Role is a single entry in the bucket authRoles
+type Role struct {
+ Name []byte `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ KeyPermission []*Permission `protobuf:"bytes,2,rep,name=keyPermission" json:"keyPermission,omitempty"`
+}
+
+func (m *Role) Reset() { *m = Role{} }
+func (m *Role) String() string { return proto.CompactTextString(m) }
+func (*Role) ProtoMessage() {}
+func (*Role) Descriptor() ([]byte, []int) { return fileDescriptorAuth, []int{2} }
+
+func init() {
+ proto.RegisterType((*User)(nil), "authpb.User")
+ proto.RegisterType((*Permission)(nil), "authpb.Permission")
+ proto.RegisterType((*Role)(nil), "authpb.Role")
+ proto.RegisterEnum("authpb.Permission_Type", Permission_Type_name, Permission_Type_value)
+}
+func (m *User) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *User) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ if len(m.Password) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Password)))
+ i += copy(dAtA[i:], m.Password)
+ }
+ if len(m.Roles) > 0 {
+ for _, s := range m.Roles {
+ dAtA[i] = 0x1a
+ i++
+ l = len(s)
+ for l >= 1<<7 {
+ dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
+ l >>= 7
+ i++
+ }
+ dAtA[i] = uint8(l)
+ i++
+ i += copy(dAtA[i:], s)
+ }
+ }
+ return i, nil
+}
+
+func (m *Permission) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *Permission) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.PermType != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintAuth(dAtA, i, uint64(m.PermType))
+ }
+ if len(m.Key) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Key)))
+ i += copy(dAtA[i:], m.Key)
+ }
+ if len(m.RangeEnd) > 0 {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.RangeEnd)))
+ i += copy(dAtA[i:], m.RangeEnd)
+ }
+ return i, nil
+}
+
+func (m *Role) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *Role) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ if len(m.KeyPermission) > 0 {
+ for _, msg := range m.KeyPermission {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintAuth(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ return i, nil
+}
+
+func encodeFixed64Auth(dAtA []byte, offset int, v uint64) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ dAtA[offset+4] = uint8(v >> 32)
+ dAtA[offset+5] = uint8(v >> 40)
+ dAtA[offset+6] = uint8(v >> 48)
+ dAtA[offset+7] = uint8(v >> 56)
+ return offset + 8
+}
+func encodeFixed32Auth(dAtA []byte, offset int, v uint32) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ return offset + 4
+}
+func encodeVarintAuth(dAtA []byte, offset int, v uint64) int {
+ for v >= 1<<7 {
+ dAtA[offset] = uint8(v&0x7f | 0x80)
+ v >>= 7
+ offset++
+ }
+ dAtA[offset] = uint8(v)
+ return offset + 1
+}
+func (m *User) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ l = len(m.Password)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ if len(m.Roles) > 0 {
+ for _, s := range m.Roles {
+ l = len(s)
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *Permission) Size() (n int) {
+ var l int
+ _ = l
+ if m.PermType != 0 {
+ n += 1 + sovAuth(uint64(m.PermType))
+ }
+ l = len(m.Key)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ l = len(m.RangeEnd)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ return n
+}
+
+func (m *Role) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ if len(m.KeyPermission) > 0 {
+ for _, e := range m.KeyPermission {
+ l = e.Size()
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ }
+ return n
+}
+
+func sovAuth(x uint64) (n int) {
+ for {
+ n++
+ x >>= 7
+ if x == 0 {
+ break
+ }
+ }
+ return n
+}
+func sozAuth(x uint64) (n int) {
+ return sovAuth(uint64((x << 1) ^ uint64((int64(x) >> 63))))
+}
+func (m *User) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: User: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: User: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...)
+ if m.Name == nil {
+ m.Name = []byte{}
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Password", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Password = append(m.Password[:0], dAtA[iNdEx:postIndex]...)
+ if m.Password == nil {
+ m.Password = []byte{}
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Roles", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Roles = append(m.Roles, string(dAtA[iNdEx:postIndex]))
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipAuth(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *Permission) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: Permission: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: Permission: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PermType", wireType)
+ }
+ m.PermType = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.PermType |= (Permission_Type(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
+ if m.Key == nil {
+ m.Key = []byte{}
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field RangeEnd", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.RangeEnd = append(m.RangeEnd[:0], dAtA[iNdEx:postIndex]...)
+ if m.RangeEnd == nil {
+ m.RangeEnd = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipAuth(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *Role) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: Role: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: Role: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...)
+ if m.Name == nil {
+ m.Name = []byte{}
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field KeyPermission", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.KeyPermission = append(m.KeyPermission, &Permission{})
+ if err := m.KeyPermission[len(m.KeyPermission)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipAuth(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func skipAuth(dAtA []byte) (n int, err error) {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ wireType := int(wire & 0x7)
+ switch wireType {
+ case 0:
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ iNdEx++
+ if dAtA[iNdEx-1] < 0x80 {
+ break
+ }
+ }
+ return iNdEx, nil
+ case 1:
+ iNdEx += 8
+ return iNdEx, nil
+ case 2:
+ var length int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ length |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ iNdEx += length
+ if length < 0 {
+ return 0, ErrInvalidLengthAuth
+ }
+ return iNdEx, nil
+ case 3:
+ for {
+ var innerWire uint64
+ var start int = iNdEx
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ innerWire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ innerWireType := int(innerWire & 0x7)
+ if innerWireType == 4 {
+ break
+ }
+ next, err := skipAuth(dAtA[start:])
+ if err != nil {
+ return 0, err
+ }
+ iNdEx = start + next
+ }
+ return iNdEx, nil
+ case 4:
+ return iNdEx, nil
+ case 5:
+ iNdEx += 4
+ return iNdEx, nil
+ default:
+ return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
+ }
+ }
+ panic("unreachable")
+}
+
+var (
+ ErrInvalidLengthAuth = fmt.Errorf("proto: negative length found during unmarshaling")
+ ErrIntOverflowAuth = fmt.Errorf("proto: integer overflow")
+)
+
+func init() { proto.RegisterFile("auth.proto", fileDescriptorAuth) }
+
+var fileDescriptorAuth = []byte{
+ // 288 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xc1, 0x4a, 0xc3, 0x30,
+ 0x1c, 0xc6, 0x9b, 0xb6, 0x1b, 0xed, 0x5f, 0x27, 0x25, 0x0c, 0x0c, 0x13, 0x42, 0xe9, 0xa9, 0x78,
+ 0xa8, 0xb0, 0x5d, 0xbc, 0x2a, 0xf6, 0x20, 0x78, 0x90, 0x50, 0xf1, 0x28, 0x1d, 0x0d, 0x75, 0x6c,
+ 0x6d, 0x4a, 0x32, 0x91, 0xbe, 0x89, 0x07, 0x1f, 0x68, 0xc7, 0x3d, 0x82, 0xab, 0x2f, 0x22, 0x4d,
+ 0x64, 0x43, 0xdc, 0xed, 0xfb, 0xbe, 0xff, 0x97, 0xe4, 0x97, 0x3f, 0x40, 0xfe, 0xb6, 0x7e, 0x4d,
+ 0x1a, 0x29, 0xd6, 0x02, 0x0f, 0x7b, 0xdd, 0xcc, 0x27, 0xe3, 0x52, 0x94, 0x42, 0x47, 0x57, 0xbd,
+ 0x32, 0xd3, 0xe8, 0x01, 0xdc, 0x27, 0xc5, 0x25, 0xc6, 0xe0, 0xd6, 0x79, 0xc5, 0x09, 0x0a, 0x51,
+ 0x7c, 0xca, 0xb4, 0xc6, 0x13, 0xf0, 0x9a, 0x5c, 0xa9, 0x77, 0x21, 0x0b, 0x62, 0xeb, 0x7c, 0xef,
+ 0xf1, 0x18, 0x06, 0x52, 0xac, 0xb8, 0x22, 0x4e, 0xe8, 0xc4, 0x3e, 0x33, 0x26, 0xfa, 0x44, 0x00,
+ 0x8f, 0x5c, 0x56, 0x0b, 0xa5, 0x16, 0xa2, 0xc6, 0x33, 0xf0, 0x1a, 0x2e, 0xab, 0xac, 0x6d, 0xcc,
+ 0xc5, 0x67, 0xd3, 0xf3, 0xc4, 0xd0, 0x24, 0x87, 0x56, 0xd2, 0x8f, 0xd9, 0xbe, 0x88, 0x03, 0x70,
+ 0x96, 0xbc, 0xfd, 0x7d, 0xb0, 0x97, 0xf8, 0x02, 0x7c, 0x99, 0xd7, 0x25, 0x7f, 0xe1, 0x75, 0x41,
+ 0x1c, 0x03, 0xa2, 0x83, 0xb4, 0x2e, 0xa2, 0x4b, 0x70, 0xf5, 0x31, 0x0f, 0x5c, 0x96, 0xde, 0xdc,
+ 0x05, 0x16, 0xf6, 0x61, 0xf0, 0xcc, 0xee, 0xb3, 0x34, 0x40, 0x78, 0x04, 0x7e, 0x1f, 0x1a, 0x6b,
+ 0x47, 0x19, 0xb8, 0x4c, 0xac, 0xf8, 0xd1, 0xcf, 0x5e, 0xc3, 0x68, 0xc9, 0xdb, 0x03, 0x16, 0xb1,
+ 0x43, 0x27, 0x3e, 0x99, 0xe2, 0xff, 0xc0, 0xec, 0x6f, 0xf1, 0x96, 0x6c, 0x76, 0xd4, 0xda, 0xee,
+ 0xa8, 0xb5, 0xe9, 0x28, 0xda, 0x76, 0x14, 0x7d, 0x75, 0x14, 0x7d, 0x7c, 0x53, 0x6b, 0x3e, 0xd4,
+ 0x3b, 0x9e, 0xfd, 0x04, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x76, 0x8d, 0x4f, 0x8f, 0x01, 0x00, 0x00,
+}
diff --git a/vendor/github.com/coreos/etcd/auth/authpb/auth.proto b/vendor/github.com/coreos/etcd/auth/authpb/auth.proto
new file mode 100644
index 00000000..001d3343
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/auth/authpb/auth.proto
@@ -0,0 +1,37 @@
+syntax = "proto3";
+package authpb;
+
+import "gogoproto/gogo.proto";
+
+option (gogoproto.marshaler_all) = true;
+option (gogoproto.sizer_all) = true;
+option (gogoproto.unmarshaler_all) = true;
+option (gogoproto.goproto_getters_all) = false;
+option (gogoproto.goproto_enum_prefix_all) = false;
+
+// User is a single entry in the bucket authUsers
+message User {
+ bytes name = 1;
+ bytes password = 2;
+ repeated string roles = 3;
+}
+
+// Permission is a single entity
+message Permission {
+ enum Type {
+ READ = 0;
+ WRITE = 1;
+ READWRITE = 2;
+ }
+ Type permType = 1;
+
+ bytes key = 2;
+ bytes range_end = 3;
+}
+
+// Role is a single entry in the bucket authRoles
+message Role {
+ bytes name = 1;
+
+ repeated Permission keyPermission = 2;
+}
diff --git a/vendor/github.com/coreos/etcd/auth/doc.go b/vendor/github.com/coreos/etcd/auth/doc.go
new file mode 100644
index 00000000..72741a10
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/auth/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 auth provides client role authentication for accessing keys in etcd.
+package auth
diff --git a/vendor/github.com/coreos/etcd/auth/jwt.go b/vendor/github.com/coreos/etcd/auth/jwt.go
new file mode 100644
index 00000000..214ae48c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/auth/jwt.go
@@ -0,0 +1,137 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 auth
+
+import (
+ "crypto/rsa"
+ "io/ioutil"
+
+ jwt "github.com/dgrijalva/jwt-go"
+ "golang.org/x/net/context"
+)
+
+type tokenJWT struct {
+ signMethod string
+ signKey *rsa.PrivateKey
+ verifyKey *rsa.PublicKey
+}
+
+func (t *tokenJWT) enable() {}
+func (t *tokenJWT) disable() {}
+func (t *tokenJWT) invalidateUser(string) {}
+func (t *tokenJWT) genTokenPrefix() (string, error) { return "", nil }
+
+func (t *tokenJWT) info(ctx context.Context, token string, rev uint64) (*AuthInfo, bool) {
+ // rev isn't used in JWT, it is only used in simple token
+ var (
+ username string
+ revision uint64
+ )
+
+ parsed, err := jwt.Parse(token, func(token *jwt.Token) (interface{}, error) {
+ return t.verifyKey, nil
+ })
+
+ switch err.(type) {
+ case nil:
+ if !parsed.Valid {
+ plog.Warningf("invalid jwt token: %s", token)
+ return nil, false
+ }
+
+ claims := parsed.Claims.(jwt.MapClaims)
+
+ username = claims["username"].(string)
+ revision = uint64(claims["revision"].(float64))
+ default:
+ plog.Warningf("failed to parse jwt token: %s", err)
+ return nil, false
+ }
+
+ return &AuthInfo{Username: username, Revision: revision}, true
+}
+
+func (t *tokenJWT) assign(ctx context.Context, username string, revision uint64) (string, error) {
+ // Future work: let a jwt token include permission information would be useful for
+ // permission checking in proxy side.
+ tk := jwt.NewWithClaims(jwt.GetSigningMethod(t.signMethod),
+ jwt.MapClaims{
+ "username": username,
+ "revision": revision,
+ })
+
+ token, err := tk.SignedString(t.signKey)
+ if err != nil {
+ plog.Debugf("failed to sign jwt token: %s", err)
+ return "", err
+ }
+
+ plog.Debugf("jwt token: %s", token)
+
+ return token, err
+}
+
+func prepareOpts(opts map[string]string) (jwtSignMethod, jwtPubKeyPath, jwtPrivKeyPath string, err error) {
+ for k, v := range opts {
+ switch k {
+ case "sign-method":
+ jwtSignMethod = v
+ case "pub-key":
+ jwtPubKeyPath = v
+ case "priv-key":
+ jwtPrivKeyPath = v
+ default:
+ plog.Errorf("unknown token specific option: %s", k)
+ return "", "", "", ErrInvalidAuthOpts
+ }
+ }
+
+ return jwtSignMethod, jwtPubKeyPath, jwtPrivKeyPath, nil
+}
+
+func newTokenProviderJWT(opts map[string]string) (*tokenJWT, error) {
+ jwtSignMethod, jwtPubKeyPath, jwtPrivKeyPath, err := prepareOpts(opts)
+ if err != nil {
+ return nil, ErrInvalidAuthOpts
+ }
+
+ t := &tokenJWT{}
+
+ t.signMethod = jwtSignMethod
+
+ verifyBytes, err := ioutil.ReadFile(jwtPubKeyPath)
+ if err != nil {
+ plog.Errorf("failed to read public key (%s) for jwt: %s", jwtPubKeyPath, err)
+ return nil, err
+ }
+ t.verifyKey, err = jwt.ParseRSAPublicKeyFromPEM(verifyBytes)
+ if err != nil {
+ plog.Errorf("failed to parse public key (%s): %s", jwtPubKeyPath, err)
+ return nil, err
+ }
+
+ signBytes, err := ioutil.ReadFile(jwtPrivKeyPath)
+ if err != nil {
+ plog.Errorf("failed to read private key (%s) for jwt: %s", jwtPrivKeyPath, err)
+ return nil, err
+ }
+ t.signKey, err = jwt.ParseRSAPrivateKeyFromPEM(signBytes)
+ if err != nil {
+ plog.Errorf("failed to parse private key (%s): %s", jwtPrivKeyPath, err)
+ return nil, err
+ }
+
+ return t, nil
+}
diff --git a/vendor/github.com/coreos/etcd/auth/range_perm_cache.go b/vendor/github.com/coreos/etcd/auth/range_perm_cache.go
new file mode 100644
index 00000000..691b65ba
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/auth/range_perm_cache.go
@@ -0,0 +1,133 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 auth
+
+import (
+ "github.com/coreos/etcd/auth/authpb"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/pkg/adt"
+)
+
+func getMergedPerms(tx backend.BatchTx, userName string) *unifiedRangePermissions {
+ user := getUser(tx, userName)
+ if user == nil {
+ plog.Errorf("invalid user name %s", userName)
+ return nil
+ }
+
+ readPerms := &adt.IntervalTree{}
+ writePerms := &adt.IntervalTree{}
+
+ for _, roleName := range user.Roles {
+ role := getRole(tx, roleName)
+ if role == nil {
+ continue
+ }
+
+ for _, perm := range role.KeyPermission {
+ var ivl adt.Interval
+ var rangeEnd []byte
+
+ if len(perm.RangeEnd) != 1 || perm.RangeEnd[0] != 0 {
+ rangeEnd = perm.RangeEnd
+ }
+
+ if len(perm.RangeEnd) != 0 {
+ ivl = adt.NewBytesAffineInterval(perm.Key, rangeEnd)
+ } else {
+ ivl = adt.NewBytesAffinePoint(perm.Key)
+ }
+
+ switch perm.PermType {
+ case authpb.READWRITE:
+ readPerms.Insert(ivl, struct{}{})
+ writePerms.Insert(ivl, struct{}{})
+
+ case authpb.READ:
+ readPerms.Insert(ivl, struct{}{})
+
+ case authpb.WRITE:
+ writePerms.Insert(ivl, struct{}{})
+ }
+ }
+ }
+
+ return &unifiedRangePermissions{
+ readPerms: readPerms,
+ writePerms: writePerms,
+ }
+}
+
+func checkKeyInterval(cachedPerms *unifiedRangePermissions, key, rangeEnd []byte, permtyp authpb.Permission_Type) bool {
+ if len(rangeEnd) == 1 && rangeEnd[0] == 0 {
+ rangeEnd = nil
+ }
+
+ ivl := adt.NewBytesAffineInterval(key, rangeEnd)
+ switch permtyp {
+ case authpb.READ:
+ return cachedPerms.readPerms.Contains(ivl)
+ case authpb.WRITE:
+ return cachedPerms.writePerms.Contains(ivl)
+ default:
+ plog.Panicf("unknown auth type: %v", permtyp)
+ }
+ return false
+}
+
+func checkKeyPoint(cachedPerms *unifiedRangePermissions, key []byte, permtyp authpb.Permission_Type) bool {
+ pt := adt.NewBytesAffinePoint(key)
+ switch permtyp {
+ case authpb.READ:
+ return cachedPerms.readPerms.Intersects(pt)
+ case authpb.WRITE:
+ return cachedPerms.writePerms.Intersects(pt)
+ default:
+ plog.Panicf("unknown auth type: %v", permtyp)
+ }
+ return false
+}
+
+func (as *authStore) isRangeOpPermitted(tx backend.BatchTx, userName string, key, rangeEnd []byte, permtyp authpb.Permission_Type) bool {
+ // assumption: tx is Lock()ed
+ _, ok := as.rangePermCache[userName]
+ if !ok {
+ perms := getMergedPerms(tx, userName)
+ if perms == nil {
+ plog.Errorf("failed to create a unified permission of user %s", userName)
+ return false
+ }
+ as.rangePermCache[userName] = perms
+ }
+
+ if len(rangeEnd) == 0 {
+ return checkKeyPoint(as.rangePermCache[userName], key, permtyp)
+ }
+
+ return checkKeyInterval(as.rangePermCache[userName], key, rangeEnd, permtyp)
+}
+
+func (as *authStore) clearCachedPerm() {
+ as.rangePermCache = make(map[string]*unifiedRangePermissions)
+}
+
+func (as *authStore) invalidateCachedPerm(userName string) {
+ delete(as.rangePermCache, userName)
+}
+
+type unifiedRangePermissions struct {
+ readPerms *adt.IntervalTree
+ writePerms *adt.IntervalTree
+}
diff --git a/vendor/github.com/coreos/etcd/auth/range_perm_cache_test.go b/vendor/github.com/coreos/etcd/auth/range_perm_cache_test.go
new file mode 100644
index 00000000..fd8df6a9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/auth/range_perm_cache_test.go
@@ -0,0 +1,59 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 auth
+
+import (
+ "testing"
+
+ "github.com/coreos/etcd/auth/authpb"
+ "github.com/coreos/etcd/pkg/adt"
+)
+
+func TestRangePermission(t *testing.T) {
+ tests := []struct {
+ perms []adt.Interval
+ begin []byte
+ end []byte
+ want bool
+ }{
+ {
+ []adt.Interval{adt.NewBytesAffineInterval([]byte("a"), []byte("c")), adt.NewBytesAffineInterval([]byte("x"), []byte("z"))},
+ []byte("a"), []byte("z"),
+ false,
+ },
+ {
+ []adt.Interval{adt.NewBytesAffineInterval([]byte("a"), []byte("f")), adt.NewBytesAffineInterval([]byte("c"), []byte("d")), adt.NewBytesAffineInterval([]byte("f"), []byte("z"))},
+ []byte("a"), []byte("z"),
+ true,
+ },
+ {
+ []adt.Interval{adt.NewBytesAffineInterval([]byte("a"), []byte("d")), adt.NewBytesAffineInterval([]byte("a"), []byte("b")), adt.NewBytesAffineInterval([]byte("c"), []byte("f"))},
+ []byte("a"), []byte("f"),
+ true,
+ },
+ }
+
+ for i, tt := range tests {
+ readPerms := &adt.IntervalTree{}
+ for _, p := range tt.perms {
+ readPerms.Insert(p, struct{}{})
+ }
+
+ result := checkKeyInterval(&unifiedRangePermissions{readPerms: readPerms}, tt.begin, tt.end, authpb.READ)
+ if result != tt.want {
+ t.Errorf("#%d: result=%t, want=%t", i, result, tt.want)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/auth/simple_token.go b/vendor/github.com/coreos/etcd/auth/simple_token.go
new file mode 100644
index 00000000..94d92a11
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/auth/simple_token.go
@@ -0,0 +1,220 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 auth
+
+// CAUTION: This randum number based token mechanism is only for testing purpose.
+// JWT based mechanism will be added in the near future.
+
+import (
+ "crypto/rand"
+ "fmt"
+ "math/big"
+ "strconv"
+ "strings"
+ "sync"
+ "time"
+
+ "golang.org/x/net/context"
+)
+
+const (
+ letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ defaultSimpleTokenLength = 16
+)
+
+// var for testing purposes
+var (
+ simpleTokenTTL = 5 * time.Minute
+ simpleTokenTTLResolution = 1 * time.Second
+)
+
+type simpleTokenTTLKeeper struct {
+ tokens map[string]time.Time
+ donec chan struct{}
+ stopc chan struct{}
+ deleteTokenFunc func(string)
+ mu *sync.Mutex
+}
+
+func (tm *simpleTokenTTLKeeper) stop() {
+ select {
+ case tm.stopc <- struct{}{}:
+ case <-tm.donec:
+ }
+ <-tm.donec
+}
+
+func (tm *simpleTokenTTLKeeper) addSimpleToken(token string) {
+ tm.tokens[token] = time.Now().Add(simpleTokenTTL)
+}
+
+func (tm *simpleTokenTTLKeeper) resetSimpleToken(token string) {
+ if _, ok := tm.tokens[token]; ok {
+ tm.tokens[token] = time.Now().Add(simpleTokenTTL)
+ }
+}
+
+func (tm *simpleTokenTTLKeeper) deleteSimpleToken(token string) {
+ delete(tm.tokens, token)
+}
+
+func (tm *simpleTokenTTLKeeper) run() {
+ tokenTicker := time.NewTicker(simpleTokenTTLResolution)
+ defer func() {
+ tokenTicker.Stop()
+ close(tm.donec)
+ }()
+ for {
+ select {
+ case <-tokenTicker.C:
+ nowtime := time.Now()
+ tm.mu.Lock()
+ for t, tokenendtime := range tm.tokens {
+ if nowtime.After(tokenendtime) {
+ tm.deleteTokenFunc(t)
+ delete(tm.tokens, t)
+ }
+ }
+ tm.mu.Unlock()
+ case <-tm.stopc:
+ return
+ }
+ }
+}
+
+type tokenSimple struct {
+ indexWaiter func(uint64) <-chan struct{}
+ simpleTokenKeeper *simpleTokenTTLKeeper
+ simpleTokensMu sync.Mutex
+ simpleTokens map[string]string // token -> username
+}
+
+func (t *tokenSimple) genTokenPrefix() (string, error) {
+ ret := make([]byte, defaultSimpleTokenLength)
+
+ for i := 0; i < defaultSimpleTokenLength; i++ {
+ bInt, err := rand.Int(rand.Reader, big.NewInt(int64(len(letters))))
+ if err != nil {
+ return "", err
+ }
+
+ ret[i] = letters[bInt.Int64()]
+ }
+
+ return string(ret), nil
+}
+
+func (t *tokenSimple) assignSimpleTokenToUser(username, token string) {
+ t.simpleTokensMu.Lock()
+ _, ok := t.simpleTokens[token]
+ if ok {
+ plog.Panicf("token %s is alredy used", token)
+ }
+
+ t.simpleTokens[token] = username
+ t.simpleTokenKeeper.addSimpleToken(token)
+ t.simpleTokensMu.Unlock()
+}
+
+func (t *tokenSimple) invalidateUser(username string) {
+ if t.simpleTokenKeeper == nil {
+ return
+ }
+ t.simpleTokensMu.Lock()
+ for token, name := range t.simpleTokens {
+ if strings.Compare(name, username) == 0 {
+ delete(t.simpleTokens, token)
+ t.simpleTokenKeeper.deleteSimpleToken(token)
+ }
+ }
+ t.simpleTokensMu.Unlock()
+}
+
+func (t *tokenSimple) enable() {
+ delf := func(tk string) {
+ if username, ok := t.simpleTokens[tk]; ok {
+ plog.Infof("deleting token %s for user %s", tk, username)
+ delete(t.simpleTokens, tk)
+ }
+ }
+ t.simpleTokenKeeper = &simpleTokenTTLKeeper{
+ tokens: make(map[string]time.Time),
+ donec: make(chan struct{}),
+ stopc: make(chan struct{}),
+ deleteTokenFunc: delf,
+ mu: &t.simpleTokensMu,
+ }
+ go t.simpleTokenKeeper.run()
+}
+
+func (t *tokenSimple) disable() {
+ t.simpleTokensMu.Lock()
+ tk := t.simpleTokenKeeper
+ t.simpleTokenKeeper = nil
+ t.simpleTokens = make(map[string]string) // invalidate all tokens
+ t.simpleTokensMu.Unlock()
+ if tk != nil {
+ tk.stop()
+ }
+}
+
+func (t *tokenSimple) info(ctx context.Context, token string, revision uint64) (*AuthInfo, bool) {
+ if !t.isValidSimpleToken(ctx, token) {
+ return nil, false
+ }
+ t.simpleTokensMu.Lock()
+ username, ok := t.simpleTokens[token]
+ if ok && t.simpleTokenKeeper != nil {
+ t.simpleTokenKeeper.resetSimpleToken(token)
+ }
+ t.simpleTokensMu.Unlock()
+ return &AuthInfo{Username: username, Revision: revision}, ok
+}
+
+func (t *tokenSimple) assign(ctx context.Context, username string, rev uint64) (string, error) {
+ // rev isn't used in simple token, it is only used in JWT
+ index := ctx.Value("index").(uint64)
+ simpleToken := ctx.Value("simpleToken").(string)
+ token := fmt.Sprintf("%s.%d", simpleToken, index)
+ t.assignSimpleTokenToUser(username, token)
+
+ return token, nil
+}
+
+func (t *tokenSimple) isValidSimpleToken(ctx context.Context, token string) bool {
+ splitted := strings.Split(token, ".")
+ if len(splitted) != 2 {
+ return false
+ }
+ index, err := strconv.Atoi(splitted[1])
+ if err != nil {
+ return false
+ }
+
+ select {
+ case <-t.indexWaiter(uint64(index)):
+ return true
+ case <-ctx.Done():
+ }
+
+ return false
+}
+
+func newTokenProviderSimple(indexWaiter func(uint64) <-chan struct{}) *tokenSimple {
+ return &tokenSimple{
+ simpleTokens: make(map[string]string),
+ indexWaiter: indexWaiter,
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/auth/store.go b/vendor/github.com/coreos/etcd/auth/store.go
new file mode 100644
index 00000000..20b57f28
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/auth/store.go
@@ -0,0 +1,1059 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 auth
+
+import (
+ "bytes"
+ "encoding/binary"
+ "errors"
+ "sort"
+ "strings"
+ "sync"
+ "sync/atomic"
+
+ "github.com/coreos/etcd/auth/authpb"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/pkg/capnslog"
+ "golang.org/x/crypto/bcrypt"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc/credentials"
+ "google.golang.org/grpc/metadata"
+ "google.golang.org/grpc/peer"
+)
+
+var (
+ enableFlagKey = []byte("authEnabled")
+ authEnabled = []byte{1}
+ authDisabled = []byte{0}
+
+ revisionKey = []byte("authRevision")
+
+ authBucketName = []byte("auth")
+ authUsersBucketName = []byte("authUsers")
+ authRolesBucketName = []byte("authRoles")
+
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "auth")
+
+ ErrRootUserNotExist = errors.New("auth: root user does not exist")
+ ErrRootRoleNotExist = errors.New("auth: root user does not have root role")
+ ErrUserAlreadyExist = errors.New("auth: user already exists")
+ ErrUserEmpty = errors.New("auth: user name is empty")
+ ErrUserNotFound = errors.New("auth: user not found")
+ ErrRoleAlreadyExist = errors.New("auth: role already exists")
+ ErrRoleNotFound = errors.New("auth: role not found")
+ ErrAuthFailed = errors.New("auth: authentication failed, invalid user ID or password")
+ ErrPermissionDenied = errors.New("auth: permission denied")
+ ErrRoleNotGranted = errors.New("auth: role is not granted to the user")
+ ErrPermissionNotGranted = errors.New("auth: permission is not granted to the role")
+ ErrAuthNotEnabled = errors.New("auth: authentication is not enabled")
+ ErrAuthOldRevision = errors.New("auth: revision in header is old")
+ ErrInvalidAuthToken = errors.New("auth: invalid auth token")
+ ErrInvalidAuthOpts = errors.New("auth: invalid auth options")
+ ErrInvalidAuthMgmt = errors.New("auth: invalid auth management")
+
+ // BcryptCost is the algorithm cost / strength for hashing auth passwords
+ BcryptCost = bcrypt.DefaultCost
+)
+
+const (
+ rootUser = "root"
+ rootRole = "root"
+
+ revBytesLen = 8
+)
+
+type AuthInfo struct {
+ Username string
+ Revision uint64
+}
+
+type AuthStore interface {
+ // AuthEnable turns on the authentication feature
+ AuthEnable() error
+
+ // AuthDisable turns off the authentication feature
+ AuthDisable()
+
+ // Authenticate does authentication based on given user name and password
+ Authenticate(ctx context.Context, username, password string) (*pb.AuthenticateResponse, error)
+
+ // Recover recovers the state of auth store from the given backend
+ Recover(b backend.Backend)
+
+ // UserAdd adds a new user
+ UserAdd(r *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error)
+
+ // UserDelete deletes a user
+ UserDelete(r *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error)
+
+ // UserChangePassword changes a password of a user
+ UserChangePassword(r *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error)
+
+ // UserGrantRole grants a role to the user
+ UserGrantRole(r *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error)
+
+ // UserGet gets the detailed information of a users
+ UserGet(r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error)
+
+ // UserRevokeRole revokes a role of a user
+ UserRevokeRole(r *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error)
+
+ // RoleAdd adds a new role
+ RoleAdd(r *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error)
+
+ // RoleGrantPermission grants a permission to a role
+ RoleGrantPermission(r *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error)
+
+ // RoleGet gets the detailed information of a role
+ RoleGet(r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error)
+
+ // RoleRevokePermission gets the detailed information of a role
+ RoleRevokePermission(r *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error)
+
+ // RoleDelete gets the detailed information of a role
+ RoleDelete(r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error)
+
+ // UserList gets a list of all users
+ UserList(r *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error)
+
+ // RoleList gets a list of all roles
+ RoleList(r *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error)
+
+ // IsPutPermitted checks put permission of the user
+ IsPutPermitted(authInfo *AuthInfo, key []byte) error
+
+ // IsRangePermitted checks range permission of the user
+ IsRangePermitted(authInfo *AuthInfo, key, rangeEnd []byte) error
+
+ // IsDeleteRangePermitted checks delete-range permission of the user
+ IsDeleteRangePermitted(authInfo *AuthInfo, key, rangeEnd []byte) error
+
+ // IsAdminPermitted checks admin permission of the user
+ IsAdminPermitted(authInfo *AuthInfo) error
+
+ // GenTokenPrefix produces a random string in a case of simple token
+ // in a case of JWT, it produces an empty string
+ GenTokenPrefix() (string, error)
+
+ // Revision gets current revision of authStore
+ Revision() uint64
+
+ // CheckPassword checks a given pair of username and password is correct
+ CheckPassword(username, password string) (uint64, error)
+
+ // Close does cleanup of AuthStore
+ Close() error
+
+ // AuthInfoFromCtx gets AuthInfo from gRPC's context
+ AuthInfoFromCtx(ctx context.Context) (*AuthInfo, error)
+
+ // AuthInfoFromTLS gets AuthInfo from TLS info of gRPC's context
+ AuthInfoFromTLS(ctx context.Context) *AuthInfo
+}
+
+type TokenProvider interface {
+ info(ctx context.Context, token string, revision uint64) (*AuthInfo, bool)
+ assign(ctx context.Context, username string, revision uint64) (string, error)
+ enable()
+ disable()
+
+ invalidateUser(string)
+ genTokenPrefix() (string, error)
+}
+
+type authStore struct {
+ // atomic operations; need 64-bit align, or 32-bit tests will crash
+ revision uint64
+
+ be backend.Backend
+ enabled bool
+ enabledMu sync.RWMutex
+
+ rangePermCache map[string]*unifiedRangePermissions // username -> unifiedRangePermissions
+
+ tokenProvider TokenProvider
+}
+
+func (as *authStore) AuthEnable() error {
+ as.enabledMu.Lock()
+ defer as.enabledMu.Unlock()
+ if as.enabled {
+ plog.Noticef("Authentication already enabled")
+ return nil
+ }
+ b := as.be
+ tx := b.BatchTx()
+ tx.Lock()
+ defer func() {
+ tx.Unlock()
+ b.ForceCommit()
+ }()
+
+ u := getUser(tx, rootUser)
+ if u == nil {
+ return ErrRootUserNotExist
+ }
+
+ if !hasRootRole(u) {
+ return ErrRootRoleNotExist
+ }
+
+ tx.UnsafePut(authBucketName, enableFlagKey, authEnabled)
+
+ as.enabled = true
+ as.tokenProvider.enable()
+
+ as.rangePermCache = make(map[string]*unifiedRangePermissions)
+
+ as.setRevision(getRevision(tx))
+
+ plog.Noticef("Authentication enabled")
+
+ return nil
+}
+
+func (as *authStore) AuthDisable() {
+ as.enabledMu.Lock()
+ defer as.enabledMu.Unlock()
+ if !as.enabled {
+ return
+ }
+ b := as.be
+ tx := b.BatchTx()
+ tx.Lock()
+ tx.UnsafePut(authBucketName, enableFlagKey, authDisabled)
+ as.commitRevision(tx)
+ tx.Unlock()
+ b.ForceCommit()
+
+ as.enabled = false
+ as.tokenProvider.disable()
+
+ plog.Noticef("Authentication disabled")
+}
+
+func (as *authStore) Close() error {
+ as.enabledMu.Lock()
+ defer as.enabledMu.Unlock()
+ if !as.enabled {
+ return nil
+ }
+ as.tokenProvider.disable()
+ return nil
+}
+
+func (as *authStore) Authenticate(ctx context.Context, username, password string) (*pb.AuthenticateResponse, error) {
+ if !as.isAuthEnabled() {
+ return nil, ErrAuthNotEnabled
+ }
+
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ user := getUser(tx, username)
+ if user == nil {
+ return nil, ErrAuthFailed
+ }
+
+ // Password checking is already performed in the API layer, so we don't need to check for now.
+ // Staleness of password can be detected with OCC in the API layer, too.
+
+ token, err := as.tokenProvider.assign(ctx, username, as.Revision())
+ if err != nil {
+ return nil, err
+ }
+
+ plog.Debugf("authorized %s, token is %s", username, token)
+ return &pb.AuthenticateResponse{Token: token}, nil
+}
+
+func (as *authStore) CheckPassword(username, password string) (uint64, error) {
+ if !as.isAuthEnabled() {
+ return 0, ErrAuthNotEnabled
+ }
+
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ user := getUser(tx, username)
+ if user == nil {
+ return 0, ErrAuthFailed
+ }
+
+ if bcrypt.CompareHashAndPassword(user.Password, []byte(password)) != nil {
+ plog.Noticef("authentication failed, invalid password for user %s", username)
+ return 0, ErrAuthFailed
+ }
+
+ return getRevision(tx), nil
+}
+
+func (as *authStore) Recover(be backend.Backend) {
+ enabled := false
+ as.be = be
+ tx := be.BatchTx()
+ tx.Lock()
+ _, vs := tx.UnsafeRange(authBucketName, enableFlagKey, nil, 0)
+ if len(vs) == 1 {
+ if bytes.Equal(vs[0], authEnabled) {
+ enabled = true
+ }
+ }
+
+ as.setRevision(getRevision(tx))
+
+ tx.Unlock()
+
+ as.enabledMu.Lock()
+ as.enabled = enabled
+ as.enabledMu.Unlock()
+}
+
+func (as *authStore) UserAdd(r *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error) {
+ if len(r.Name) == 0 {
+ return nil, ErrUserEmpty
+ }
+
+ hashed, err := bcrypt.GenerateFromPassword([]byte(r.Password), BcryptCost)
+ if err != nil {
+ plog.Errorf("failed to hash password: %s", err)
+ return nil, err
+ }
+
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ user := getUser(tx, r.Name)
+ if user != nil {
+ return nil, ErrUserAlreadyExist
+ }
+
+ newUser := &authpb.User{
+ Name: []byte(r.Name),
+ Password: hashed,
+ }
+
+ putUser(tx, newUser)
+
+ as.commitRevision(tx)
+
+ plog.Noticef("added a new user: %s", r.Name)
+
+ return &pb.AuthUserAddResponse{}, nil
+}
+
+func (as *authStore) UserDelete(r *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error) {
+ if as.enabled && strings.Compare(r.Name, rootUser) == 0 {
+ plog.Errorf("the user root must not be deleted")
+ return nil, ErrInvalidAuthMgmt
+ }
+
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ user := getUser(tx, r.Name)
+ if user == nil {
+ return nil, ErrUserNotFound
+ }
+
+ delUser(tx, r.Name)
+
+ as.commitRevision(tx)
+
+ as.invalidateCachedPerm(r.Name)
+ as.tokenProvider.invalidateUser(r.Name)
+
+ plog.Noticef("deleted a user: %s", r.Name)
+
+ return &pb.AuthUserDeleteResponse{}, nil
+}
+
+func (as *authStore) UserChangePassword(r *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error) {
+ // TODO(mitake): measure the cost of bcrypt.GenerateFromPassword()
+ // If the cost is too high, we should move the encryption to outside of the raft
+ hashed, err := bcrypt.GenerateFromPassword([]byte(r.Password), BcryptCost)
+ if err != nil {
+ plog.Errorf("failed to hash password: %s", err)
+ return nil, err
+ }
+
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ user := getUser(tx, r.Name)
+ if user == nil {
+ return nil, ErrUserNotFound
+ }
+
+ updatedUser := &authpb.User{
+ Name: []byte(r.Name),
+ Roles: user.Roles,
+ Password: hashed,
+ }
+
+ putUser(tx, updatedUser)
+
+ as.commitRevision(tx)
+
+ as.invalidateCachedPerm(r.Name)
+ as.tokenProvider.invalidateUser(r.Name)
+
+ plog.Noticef("changed a password of a user: %s", r.Name)
+
+ return &pb.AuthUserChangePasswordResponse{}, nil
+}
+
+func (as *authStore) UserGrantRole(r *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error) {
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ user := getUser(tx, r.User)
+ if user == nil {
+ return nil, ErrUserNotFound
+ }
+
+ if r.Role != rootRole {
+ role := getRole(tx, r.Role)
+ if role == nil {
+ return nil, ErrRoleNotFound
+ }
+ }
+
+ idx := sort.SearchStrings(user.Roles, r.Role)
+ if idx < len(user.Roles) && strings.Compare(user.Roles[idx], r.Role) == 0 {
+ plog.Warningf("user %s is already granted role %s", r.User, r.Role)
+ return &pb.AuthUserGrantRoleResponse{}, nil
+ }
+
+ user.Roles = append(user.Roles, r.Role)
+ sort.Sort(sort.StringSlice(user.Roles))
+
+ putUser(tx, user)
+
+ as.invalidateCachedPerm(r.User)
+
+ as.commitRevision(tx)
+
+ plog.Noticef("granted role %s to user %s", r.Role, r.User)
+ return &pb.AuthUserGrantRoleResponse{}, nil
+}
+
+func (as *authStore) UserGet(r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error) {
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ var resp pb.AuthUserGetResponse
+
+ user := getUser(tx, r.Name)
+ if user == nil {
+ return nil, ErrUserNotFound
+ }
+ resp.Roles = append(resp.Roles, user.Roles...)
+ return &resp, nil
+}
+
+func (as *authStore) UserList(r *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error) {
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ var resp pb.AuthUserListResponse
+
+ users := getAllUsers(tx)
+
+ for _, u := range users {
+ resp.Users = append(resp.Users, string(u.Name))
+ }
+
+ return &resp, nil
+}
+
+func (as *authStore) UserRevokeRole(r *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error) {
+ if as.enabled && strings.Compare(r.Name, rootUser) == 0 && strings.Compare(r.Role, rootRole) == 0 {
+ plog.Errorf("the role root must not be revoked from the user root")
+ return nil, ErrInvalidAuthMgmt
+ }
+
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ user := getUser(tx, r.Name)
+ if user == nil {
+ return nil, ErrUserNotFound
+ }
+
+ updatedUser := &authpb.User{
+ Name: user.Name,
+ Password: user.Password,
+ }
+
+ for _, role := range user.Roles {
+ if strings.Compare(role, r.Role) != 0 {
+ updatedUser.Roles = append(updatedUser.Roles, role)
+ }
+ }
+
+ if len(updatedUser.Roles) == len(user.Roles) {
+ return nil, ErrRoleNotGranted
+ }
+
+ putUser(tx, updatedUser)
+
+ as.invalidateCachedPerm(r.Name)
+
+ as.commitRevision(tx)
+
+ plog.Noticef("revoked role %s from user %s", r.Role, r.Name)
+ return &pb.AuthUserRevokeRoleResponse{}, nil
+}
+
+func (as *authStore) RoleGet(r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error) {
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ var resp pb.AuthRoleGetResponse
+
+ role := getRole(tx, r.Role)
+ if role == nil {
+ return nil, ErrRoleNotFound
+ }
+ resp.Perm = append(resp.Perm, role.KeyPermission...)
+ return &resp, nil
+}
+
+func (as *authStore) RoleList(r *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error) {
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ var resp pb.AuthRoleListResponse
+
+ roles := getAllRoles(tx)
+
+ for _, r := range roles {
+ resp.Roles = append(resp.Roles, string(r.Name))
+ }
+
+ return &resp, nil
+}
+
+func (as *authStore) RoleRevokePermission(r *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error) {
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ role := getRole(tx, r.Role)
+ if role == nil {
+ return nil, ErrRoleNotFound
+ }
+
+ updatedRole := &authpb.Role{
+ Name: role.Name,
+ }
+
+ for _, perm := range role.KeyPermission {
+ if !bytes.Equal(perm.Key, []byte(r.Key)) || !bytes.Equal(perm.RangeEnd, []byte(r.RangeEnd)) {
+ updatedRole.KeyPermission = append(updatedRole.KeyPermission, perm)
+ }
+ }
+
+ if len(role.KeyPermission) == len(updatedRole.KeyPermission) {
+ return nil, ErrPermissionNotGranted
+ }
+
+ putRole(tx, updatedRole)
+
+ // TODO(mitake): currently single role update invalidates every cache
+ // It should be optimized.
+ as.clearCachedPerm()
+
+ as.commitRevision(tx)
+
+ plog.Noticef("revoked key %s from role %s", r.Key, r.Role)
+ return &pb.AuthRoleRevokePermissionResponse{}, nil
+}
+
+func (as *authStore) RoleDelete(r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error) {
+ if as.enabled && strings.Compare(r.Role, rootRole) == 0 {
+ plog.Errorf("the role root must not be deleted")
+ return nil, ErrInvalidAuthMgmt
+ }
+
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ role := getRole(tx, r.Role)
+ if role == nil {
+ return nil, ErrRoleNotFound
+ }
+
+ delRole(tx, r.Role)
+
+ users := getAllUsers(tx)
+ for _, user := range users {
+ updatedUser := &authpb.User{
+ Name: user.Name,
+ Password: user.Password,
+ }
+
+ for _, role := range user.Roles {
+ if strings.Compare(role, r.Role) != 0 {
+ updatedUser.Roles = append(updatedUser.Roles, role)
+ }
+ }
+
+ if len(updatedUser.Roles) == len(user.Roles) {
+ continue
+ }
+
+ putUser(tx, updatedUser)
+
+ as.invalidateCachedPerm(string(user.Name))
+ }
+
+ as.commitRevision(tx)
+
+ plog.Noticef("deleted role %s", r.Role)
+ return &pb.AuthRoleDeleteResponse{}, nil
+}
+
+func (as *authStore) RoleAdd(r *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error) {
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ role := getRole(tx, r.Name)
+ if role != nil {
+ return nil, ErrRoleAlreadyExist
+ }
+
+ newRole := &authpb.Role{
+ Name: []byte(r.Name),
+ }
+
+ putRole(tx, newRole)
+
+ as.commitRevision(tx)
+
+ plog.Noticef("Role %s is created", r.Name)
+
+ return &pb.AuthRoleAddResponse{}, nil
+}
+
+func (as *authStore) authInfoFromToken(ctx context.Context, token string) (*AuthInfo, bool) {
+ return as.tokenProvider.info(ctx, token, as.Revision())
+}
+
+type permSlice []*authpb.Permission
+
+func (perms permSlice) Len() int {
+ return len(perms)
+}
+
+func (perms permSlice) Less(i, j int) bool {
+ return bytes.Compare(perms[i].Key, perms[j].Key) < 0
+}
+
+func (perms permSlice) Swap(i, j int) {
+ perms[i], perms[j] = perms[j], perms[i]
+}
+
+func (as *authStore) RoleGrantPermission(r *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error) {
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ role := getRole(tx, r.Name)
+ if role == nil {
+ return nil, ErrRoleNotFound
+ }
+
+ idx := sort.Search(len(role.KeyPermission), func(i int) bool {
+ return bytes.Compare(role.KeyPermission[i].Key, []byte(r.Perm.Key)) >= 0
+ })
+
+ if idx < len(role.KeyPermission) && bytes.Equal(role.KeyPermission[idx].Key, r.Perm.Key) && bytes.Equal(role.KeyPermission[idx].RangeEnd, r.Perm.RangeEnd) {
+ // update existing permission
+ role.KeyPermission[idx].PermType = r.Perm.PermType
+ } else {
+ // append new permission to the role
+ newPerm := &authpb.Permission{
+ Key: []byte(r.Perm.Key),
+ RangeEnd: []byte(r.Perm.RangeEnd),
+ PermType: r.Perm.PermType,
+ }
+
+ role.KeyPermission = append(role.KeyPermission, newPerm)
+ sort.Sort(permSlice(role.KeyPermission))
+ }
+
+ putRole(tx, role)
+
+ // TODO(mitake): currently single role update invalidates every cache
+ // It should be optimized.
+ as.clearCachedPerm()
+
+ as.commitRevision(tx)
+
+ plog.Noticef("role %s's permission of key %s is updated as %s", r.Name, r.Perm.Key, authpb.Permission_Type_name[int32(r.Perm.PermType)])
+
+ return &pb.AuthRoleGrantPermissionResponse{}, nil
+}
+
+func (as *authStore) isOpPermitted(userName string, revision uint64, key, rangeEnd []byte, permTyp authpb.Permission_Type) error {
+ // TODO(mitake): this function would be costly so we need a caching mechanism
+ if !as.isAuthEnabled() {
+ return nil
+ }
+
+ // only gets rev == 0 when passed AuthInfo{}; no user given
+ if revision == 0 {
+ return ErrUserEmpty
+ }
+
+ if revision < as.Revision() {
+ return ErrAuthOldRevision
+ }
+
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ user := getUser(tx, userName)
+ if user == nil {
+ plog.Errorf("invalid user name %s for permission checking", userName)
+ return ErrPermissionDenied
+ }
+
+ // root role should have permission on all ranges
+ if hasRootRole(user) {
+ return nil
+ }
+
+ if as.isRangeOpPermitted(tx, userName, key, rangeEnd, permTyp) {
+ return nil
+ }
+
+ return ErrPermissionDenied
+}
+
+func (as *authStore) IsPutPermitted(authInfo *AuthInfo, key []byte) error {
+ return as.isOpPermitted(authInfo.Username, authInfo.Revision, key, nil, authpb.WRITE)
+}
+
+func (as *authStore) IsRangePermitted(authInfo *AuthInfo, key, rangeEnd []byte) error {
+ return as.isOpPermitted(authInfo.Username, authInfo.Revision, key, rangeEnd, authpb.READ)
+}
+
+func (as *authStore) IsDeleteRangePermitted(authInfo *AuthInfo, key, rangeEnd []byte) error {
+ return as.isOpPermitted(authInfo.Username, authInfo.Revision, key, rangeEnd, authpb.WRITE)
+}
+
+func (as *authStore) IsAdminPermitted(authInfo *AuthInfo) error {
+ if !as.isAuthEnabled() {
+ return nil
+ }
+ if authInfo == nil {
+ return ErrUserEmpty
+ }
+
+ tx := as.be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ u := getUser(tx, authInfo.Username)
+ if u == nil {
+ return ErrUserNotFound
+ }
+
+ if !hasRootRole(u) {
+ return ErrPermissionDenied
+ }
+
+ return nil
+}
+
+func getUser(tx backend.BatchTx, username string) *authpb.User {
+ _, vs := tx.UnsafeRange(authUsersBucketName, []byte(username), nil, 0)
+ if len(vs) == 0 {
+ return nil
+ }
+
+ user := &authpb.User{}
+ err := user.Unmarshal(vs[0])
+ if err != nil {
+ plog.Panicf("failed to unmarshal user struct (name: %s): %s", username, err)
+ }
+ return user
+}
+
+func getAllUsers(tx backend.BatchTx) []*authpb.User {
+ _, vs := tx.UnsafeRange(authUsersBucketName, []byte{0}, []byte{0xff}, -1)
+ if len(vs) == 0 {
+ return nil
+ }
+
+ var users []*authpb.User
+
+ for _, v := range vs {
+ user := &authpb.User{}
+ err := user.Unmarshal(v)
+ if err != nil {
+ plog.Panicf("failed to unmarshal user struct: %s", err)
+ }
+
+ users = append(users, user)
+ }
+
+ return users
+}
+
+func putUser(tx backend.BatchTx, user *authpb.User) {
+ b, err := user.Marshal()
+ if err != nil {
+ plog.Panicf("failed to marshal user struct (name: %s): %s", user.Name, err)
+ }
+ tx.UnsafePut(authUsersBucketName, user.Name, b)
+}
+
+func delUser(tx backend.BatchTx, username string) {
+ tx.UnsafeDelete(authUsersBucketName, []byte(username))
+}
+
+func getRole(tx backend.BatchTx, rolename string) *authpb.Role {
+ _, vs := tx.UnsafeRange(authRolesBucketName, []byte(rolename), nil, 0)
+ if len(vs) == 0 {
+ return nil
+ }
+
+ role := &authpb.Role{}
+ err := role.Unmarshal(vs[0])
+ if err != nil {
+ plog.Panicf("failed to unmarshal role struct (name: %s): %s", rolename, err)
+ }
+ return role
+}
+
+func getAllRoles(tx backend.BatchTx) []*authpb.Role {
+ _, vs := tx.UnsafeRange(authRolesBucketName, []byte{0}, []byte{0xff}, -1)
+ if len(vs) == 0 {
+ return nil
+ }
+
+ var roles []*authpb.Role
+
+ for _, v := range vs {
+ role := &authpb.Role{}
+ err := role.Unmarshal(v)
+ if err != nil {
+ plog.Panicf("failed to unmarshal role struct: %s", err)
+ }
+
+ roles = append(roles, role)
+ }
+
+ return roles
+}
+
+func putRole(tx backend.BatchTx, role *authpb.Role) {
+ b, err := role.Marshal()
+ if err != nil {
+ plog.Panicf("failed to marshal role struct (name: %s): %s", role.Name, err)
+ }
+
+ tx.UnsafePut(authRolesBucketName, []byte(role.Name), b)
+}
+
+func delRole(tx backend.BatchTx, rolename string) {
+ tx.UnsafeDelete(authRolesBucketName, []byte(rolename))
+}
+
+func (as *authStore) isAuthEnabled() bool {
+ as.enabledMu.RLock()
+ defer as.enabledMu.RUnlock()
+ return as.enabled
+}
+
+func NewAuthStore(be backend.Backend, tp TokenProvider) *authStore {
+ tx := be.BatchTx()
+ tx.Lock()
+
+ tx.UnsafeCreateBucket(authBucketName)
+ tx.UnsafeCreateBucket(authUsersBucketName)
+ tx.UnsafeCreateBucket(authRolesBucketName)
+
+ enabled := false
+ _, vs := tx.UnsafeRange(authBucketName, enableFlagKey, nil, 0)
+ if len(vs) == 1 {
+ if bytes.Equal(vs[0], authEnabled) {
+ enabled = true
+ }
+ }
+
+ as := &authStore{
+ be: be,
+ revision: getRevision(tx),
+ enabled: enabled,
+ rangePermCache: make(map[string]*unifiedRangePermissions),
+ tokenProvider: tp,
+ }
+
+ if enabled {
+ as.tokenProvider.enable()
+ }
+
+ if as.Revision() == 0 {
+ as.commitRevision(tx)
+ }
+
+ tx.Unlock()
+ be.ForceCommit()
+
+ return as
+}
+
+func hasRootRole(u *authpb.User) bool {
+ for _, r := range u.Roles {
+ if r == rootRole {
+ return true
+ }
+ }
+ return false
+}
+
+func (as *authStore) commitRevision(tx backend.BatchTx) {
+ atomic.AddUint64(&as.revision, 1)
+ revBytes := make([]byte, revBytesLen)
+ binary.BigEndian.PutUint64(revBytes, as.Revision())
+ tx.UnsafePut(authBucketName, revisionKey, revBytes)
+}
+
+func getRevision(tx backend.BatchTx) uint64 {
+ _, vs := tx.UnsafeRange(authBucketName, []byte(revisionKey), nil, 0)
+ if len(vs) != 1 {
+ // this can happen in the initialization phase
+ return 0
+ }
+
+ return binary.BigEndian.Uint64(vs[0])
+}
+
+func (as *authStore) setRevision(rev uint64) {
+ atomic.StoreUint64(&as.revision, rev)
+}
+
+func (as *authStore) Revision() uint64 {
+ return atomic.LoadUint64(&as.revision)
+}
+
+func (as *authStore) AuthInfoFromTLS(ctx context.Context) *AuthInfo {
+ peer, ok := peer.FromContext(ctx)
+ if !ok || peer == nil || peer.AuthInfo == nil {
+ return nil
+ }
+
+ tlsInfo := peer.AuthInfo.(credentials.TLSInfo)
+ for _, chains := range tlsInfo.State.VerifiedChains {
+ for _, chain := range chains {
+ cn := chain.Subject.CommonName
+ plog.Debugf("found common name %s", cn)
+
+ return &AuthInfo{
+ Username: cn,
+ Revision: as.Revision(),
+ }
+ }
+ }
+
+ return nil
+}
+
+func (as *authStore) AuthInfoFromCtx(ctx context.Context) (*AuthInfo, error) {
+ md, ok := metadata.FromContext(ctx)
+ if !ok {
+ return nil, nil
+ }
+
+ ts, tok := md["token"]
+ if !tok {
+ return nil, nil
+ }
+
+ token := ts[0]
+ authInfo, uok := as.authInfoFromToken(ctx, token)
+ if !uok {
+ plog.Warningf("invalid auth token: %s", token)
+ return nil, ErrInvalidAuthToken
+ }
+ return authInfo, nil
+}
+
+func (as *authStore) GenTokenPrefix() (string, error) {
+ return as.tokenProvider.genTokenPrefix()
+}
+
+func decomposeOpts(optstr string) (string, map[string]string, error) {
+ opts := strings.Split(optstr, ",")
+ tokenType := opts[0]
+
+ typeSpecificOpts := make(map[string]string)
+ for i := 1; i < len(opts); i++ {
+ pair := strings.Split(opts[i], "=")
+
+ if len(pair) != 2 {
+ plog.Errorf("invalid token specific option: %s", optstr)
+ return "", nil, ErrInvalidAuthOpts
+ }
+
+ if _, ok := typeSpecificOpts[pair[0]]; ok {
+ plog.Errorf("invalid token specific option, duplicated parameters (%s): %s", pair[0], optstr)
+ return "", nil, ErrInvalidAuthOpts
+ }
+
+ typeSpecificOpts[pair[0]] = pair[1]
+ }
+
+ return tokenType, typeSpecificOpts, nil
+
+}
+
+func NewTokenProvider(tokenOpts string, indexWaiter func(uint64) <-chan struct{}) (TokenProvider, error) {
+ tokenType, typeSpecificOpts, err := decomposeOpts(tokenOpts)
+ if err != nil {
+ return nil, ErrInvalidAuthOpts
+ }
+
+ switch tokenType {
+ case "simple":
+ plog.Warningf("simple token is not cryptographically signed")
+ return newTokenProviderSimple(indexWaiter), nil
+ case "jwt":
+ return newTokenProviderJWT(typeSpecificOpts)
+ default:
+ plog.Errorf("unknown token type: %s", tokenType)
+ return nil, ErrInvalidAuthOpts
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/auth/store_test.go b/vendor/github.com/coreos/etcd/auth/store_test.go
new file mode 100644
index 00000000..bf0a4fc9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/auth/store_test.go
@@ -0,0 +1,655 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 auth
+
+import (
+ "fmt"
+ "os"
+ "reflect"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/auth/authpb"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/mvcc/backend"
+
+ "golang.org/x/crypto/bcrypt"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc/metadata"
+)
+
+func init() { BcryptCost = bcrypt.MinCost }
+
+func dummyIndexWaiter(index uint64) <-chan struct{} {
+ ch := make(chan struct{})
+ go func() {
+ ch <- struct{}{}
+ }()
+ return ch
+}
+
+// TestNewAuthStoreRevision ensures newly auth store
+// keeps the old revision when there are no changes.
+func TestNewAuthStoreRevision(t *testing.T) {
+ b, tPath := backend.NewDefaultTmpBackend()
+ defer os.Remove(tPath)
+
+ tp, err := NewTokenProvider("simple", dummyIndexWaiter)
+ if err != nil {
+ t.Fatal(err)
+ }
+ as := NewAuthStore(b, tp)
+ err = enableAuthAndCreateRoot(as)
+ if err != nil {
+ t.Fatal(err)
+ }
+ old := as.Revision()
+ b.Close()
+ as.Close()
+
+ // no changes to commit
+ b2 := backend.NewDefaultBackend(tPath)
+ as = NewAuthStore(b2, tp)
+ new := as.Revision()
+ b2.Close()
+ as.Close()
+
+ if old != new {
+ t.Fatalf("expected revision %d, got %d", old, new)
+ }
+}
+
+func setupAuthStore(t *testing.T) (store *authStore, teardownfunc func(t *testing.T)) {
+ b, tPath := backend.NewDefaultTmpBackend()
+
+ tp, err := NewTokenProvider("simple", dummyIndexWaiter)
+ if err != nil {
+ t.Fatal(err)
+ }
+ as := NewAuthStore(b, tp)
+ err = enableAuthAndCreateRoot(as)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // adds a new role
+ _, err = as.RoleAdd(&pb.AuthRoleAddRequest{Name: "role-test"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ ua := &pb.AuthUserAddRequest{Name: "foo", Password: "bar"}
+ _, err = as.UserAdd(ua) // add a non-existing user
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ tearDown := func(t *testing.T) {
+ b.Close()
+ os.Remove(tPath)
+ as.Close()
+ }
+ return as, tearDown
+}
+
+func enableAuthAndCreateRoot(as *authStore) error {
+ _, err := as.UserAdd(&pb.AuthUserAddRequest{Name: "root", Password: "root"})
+ if err != nil {
+ return err
+ }
+
+ _, err = as.RoleAdd(&pb.AuthRoleAddRequest{Name: "root"})
+ if err != nil {
+ return err
+ }
+
+ _, err = as.UserGrantRole(&pb.AuthUserGrantRoleRequest{User: "root", Role: "root"})
+ if err != nil {
+ return err
+ }
+
+ return as.AuthEnable()
+}
+
+func TestUserAdd(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ ua := &pb.AuthUserAddRequest{Name: "foo"}
+ _, err := as.UserAdd(ua) // add an existing user
+ if err == nil {
+ t.Fatalf("expected %v, got %v", ErrUserAlreadyExist, err)
+ }
+ if err != ErrUserAlreadyExist {
+ t.Fatalf("expected %v, got %v", ErrUserAlreadyExist, err)
+ }
+
+ ua = &pb.AuthUserAddRequest{Name: ""}
+ _, err = as.UserAdd(ua) // add a user with empty name
+ if err != ErrUserEmpty {
+ t.Fatal(err)
+ }
+}
+
+func TestCheckPassword(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ // auth a non-existing user
+ _, err := as.CheckPassword("foo-test", "bar")
+ if err == nil {
+ t.Fatalf("expected %v, got %v", ErrAuthFailed, err)
+ }
+ if err != ErrAuthFailed {
+ t.Fatalf("expected %v, got %v", ErrAuthFailed, err)
+ }
+
+ // auth an existing user with correct password
+ _, err = as.CheckPassword("foo", "bar")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // auth an existing user but with wrong password
+ _, err = as.CheckPassword("foo", "")
+ if err == nil {
+ t.Fatalf("expected %v, got %v", ErrAuthFailed, err)
+ }
+ if err != ErrAuthFailed {
+ t.Fatalf("expected %v, got %v", ErrAuthFailed, err)
+ }
+}
+
+func TestUserDelete(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ // delete an existing user
+ ud := &pb.AuthUserDeleteRequest{Name: "foo"}
+ _, err := as.UserDelete(ud)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // delete a non-existing user
+ _, err = as.UserDelete(ud)
+ if err == nil {
+ t.Fatalf("expected %v, got %v", ErrUserNotFound, err)
+ }
+ if err != ErrUserNotFound {
+ t.Fatalf("expected %v, got %v", ErrUserNotFound, err)
+ }
+}
+
+func TestUserChangePassword(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ ctx1 := context.WithValue(context.WithValue(context.TODO(), "index", uint64(1)), "simpleToken", "dummy")
+ _, err := as.Authenticate(ctx1, "foo", "bar")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ _, err = as.UserChangePassword(&pb.AuthUserChangePasswordRequest{Name: "foo", Password: "baz"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ ctx2 := context.WithValue(context.WithValue(context.TODO(), "index", uint64(2)), "simpleToken", "dummy")
+ _, err = as.Authenticate(ctx2, "foo", "baz")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // change a non-existing user
+ _, err = as.UserChangePassword(&pb.AuthUserChangePasswordRequest{Name: "foo-test", Password: "bar"})
+ if err == nil {
+ t.Fatalf("expected %v, got %v", ErrUserNotFound, err)
+ }
+ if err != ErrUserNotFound {
+ t.Fatalf("expected %v, got %v", ErrUserNotFound, err)
+ }
+}
+
+func TestRoleAdd(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ // adds a new role
+ _, err := as.RoleAdd(&pb.AuthRoleAddRequest{Name: "role-test-1"})
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestUserGrant(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ // grants a role to the user
+ _, err := as.UserGrantRole(&pb.AuthUserGrantRoleRequest{User: "foo", Role: "role-test"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // grants a role to a non-existing user
+ _, err = as.UserGrantRole(&pb.AuthUserGrantRoleRequest{User: "foo-test", Role: "role-test"})
+ if err == nil {
+ t.Errorf("expected %v, got %v", ErrUserNotFound, err)
+ }
+ if err != ErrUserNotFound {
+ t.Errorf("expected %v, got %v", ErrUserNotFound, err)
+ }
+}
+
+func TestGetUser(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ _, err := as.UserGrantRole(&pb.AuthUserGrantRoleRequest{User: "foo", Role: "role-test"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ u, err := as.UserGet(&pb.AuthUserGetRequest{Name: "foo"})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if u == nil {
+ t.Fatal("expect user not nil, got nil")
+ }
+ expected := []string{"role-test"}
+ if !reflect.DeepEqual(expected, u.Roles) {
+ t.Errorf("expected %v, got %v", expected, u.Roles)
+ }
+}
+
+func TestListUsers(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ ua := &pb.AuthUserAddRequest{Name: "user1", Password: "pwd1"}
+ _, err := as.UserAdd(ua) // add a non-existing user
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ ul, err := as.UserList(&pb.AuthUserListRequest{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !contains(ul.Users, "root") {
+ t.Errorf("expected %v in %v", "root", ul.Users)
+ }
+ if !contains(ul.Users, "user1") {
+ t.Errorf("expected %v in %v", "user1", ul.Users)
+ }
+}
+
+func TestRoleGrantPermission(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ _, err := as.RoleAdd(&pb.AuthRoleAddRequest{Name: "role-test-1"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ perm := &authpb.Permission{
+ PermType: authpb.WRITE,
+ Key: []byte("Keys"),
+ RangeEnd: []byte("RangeEnd"),
+ }
+ _, err = as.RoleGrantPermission(&pb.AuthRoleGrantPermissionRequest{
+ Name: "role-test-1",
+ Perm: perm,
+ })
+
+ if err != nil {
+ t.Error(err)
+ }
+
+ r, err := as.RoleGet(&pb.AuthRoleGetRequest{Role: "role-test-1"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if !reflect.DeepEqual(perm, r.Perm[0]) {
+ t.Errorf("expected %v, got %v", perm, r.Perm[0])
+ }
+}
+
+func TestRoleRevokePermission(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ _, err := as.RoleAdd(&pb.AuthRoleAddRequest{Name: "role-test-1"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ perm := &authpb.Permission{
+ PermType: authpb.WRITE,
+ Key: []byte("Keys"),
+ RangeEnd: []byte("RangeEnd"),
+ }
+ _, err = as.RoleGrantPermission(&pb.AuthRoleGrantPermissionRequest{
+ Name: "role-test-1",
+ Perm: perm,
+ })
+
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ _, err = as.RoleGet(&pb.AuthRoleGetRequest{Role: "role-test-1"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ _, err = as.RoleRevokePermission(&pb.AuthRoleRevokePermissionRequest{
+ Role: "role-test-1",
+ Key: "Keys",
+ RangeEnd: "RangeEnd",
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ var r *pb.AuthRoleGetResponse
+ r, err = as.RoleGet(&pb.AuthRoleGetRequest{Role: "role-test-1"})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(r.Perm) != 0 {
+ t.Errorf("expected %v, got %v", 0, len(r.Perm))
+ }
+}
+
+func TestUserRevokePermission(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ _, err := as.RoleAdd(&pb.AuthRoleAddRequest{Name: "role-test-1"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ _, err = as.UserGrantRole(&pb.AuthUserGrantRoleRequest{User: "foo", Role: "role-test"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ _, err = as.UserGrantRole(&pb.AuthUserGrantRoleRequest{User: "foo", Role: "role-test-1"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ u, err := as.UserGet(&pb.AuthUserGetRequest{Name: "foo"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ expected := []string{"role-test", "role-test-1"}
+ if !reflect.DeepEqual(expected, u.Roles) {
+ t.Fatalf("expected %v, got %v", expected, u.Roles)
+ }
+
+ _, err = as.UserRevokeRole(&pb.AuthUserRevokeRoleRequest{Name: "foo", Role: "role-test-1"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ u, err = as.UserGet(&pb.AuthUserGetRequest{Name: "foo"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ expected = []string{"role-test"}
+ if !reflect.DeepEqual(expected, u.Roles) {
+ t.Errorf("expected %v, got %v", expected, u.Roles)
+ }
+}
+
+func TestRoleDelete(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ _, err := as.RoleDelete(&pb.AuthRoleDeleteRequest{Role: "role-test"})
+ if err != nil {
+ t.Fatal(err)
+ }
+ rl, err := as.RoleList(&pb.AuthRoleListRequest{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ expected := []string{"root"}
+ if !reflect.DeepEqual(expected, rl.Roles) {
+ t.Errorf("expected %v, got %v", expected, rl.Roles)
+ }
+}
+
+func TestAuthInfoFromCtx(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ ctx := context.Background()
+ ai, err := as.AuthInfoFromCtx(ctx)
+ if err != nil && ai != nil {
+ t.Errorf("expected (nil, nil), got (%v, %v)", ai, err)
+ }
+
+ ctx = metadata.NewContext(context.Background(), metadata.New(map[string]string{"tokens": "dummy"}))
+ ai, err = as.AuthInfoFromCtx(ctx)
+ if err != nil && ai != nil {
+ t.Errorf("expected (nil, nil), got (%v, %v)", ai, err)
+ }
+
+ ctx = context.WithValue(context.WithValue(context.TODO(), "index", uint64(1)), "simpleToken", "dummy")
+ resp, err := as.Authenticate(ctx, "foo", "bar")
+ if err != nil {
+ t.Error(err)
+ }
+
+ ctx = metadata.NewContext(context.Background(), metadata.New(map[string]string{"token": "Invalid Token"}))
+ _, err = as.AuthInfoFromCtx(ctx)
+ if err != ErrInvalidAuthToken {
+ t.Errorf("expected %v, got %v", ErrInvalidAuthToken, err)
+ }
+
+ ctx = metadata.NewContext(context.Background(), metadata.New(map[string]string{"token": "Invalid.Token"}))
+ _, err = as.AuthInfoFromCtx(ctx)
+ if err != ErrInvalidAuthToken {
+ t.Errorf("expected %v, got %v", ErrInvalidAuthToken, err)
+ }
+
+ ctx = metadata.NewContext(context.Background(), metadata.New(map[string]string{"token": resp.Token}))
+ ai, err = as.AuthInfoFromCtx(ctx)
+ if err != nil {
+ t.Error(err)
+ }
+ if ai.Username != "foo" {
+ t.Errorf("expected %v, got %v", "foo", ai.Username)
+ }
+}
+
+func TestAuthDisable(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ as.AuthDisable()
+ ctx := context.WithValue(context.WithValue(context.TODO(), "index", uint64(2)), "simpleToken", "dummy")
+ _, err := as.Authenticate(ctx, "foo", "bar")
+ if err != ErrAuthNotEnabled {
+ t.Errorf("expected %v, got %v", ErrAuthNotEnabled, err)
+ }
+
+ // Disabling disabled auth to make sure it can return safely if store is already disabled.
+ as.AuthDisable()
+ _, err = as.Authenticate(ctx, "foo", "bar")
+ if err != ErrAuthNotEnabled {
+ t.Errorf("expected %v, got %v", ErrAuthNotEnabled, err)
+ }
+}
+
+// TestAuthRevisionRace ensures that access to authStore.revision is thread-safe.
+func TestAuthInfoFromCtxRace(t *testing.T) {
+ b, tPath := backend.NewDefaultTmpBackend()
+ defer os.Remove(tPath)
+
+ tp, err := NewTokenProvider("simple", dummyIndexWaiter)
+ if err != nil {
+ t.Fatal(err)
+ }
+ as := NewAuthStore(b, tp)
+ defer as.Close()
+
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ ctx := metadata.NewContext(context.Background(), metadata.New(map[string]string{"token": "test"}))
+ as.AuthInfoFromCtx(ctx)
+ }()
+ as.UserAdd(&pb.AuthUserAddRequest{Name: "test"})
+ <-donec
+}
+
+func TestIsAdminPermitted(t *testing.T) {
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ err := as.IsAdminPermitted(&AuthInfo{Username: "root", Revision: 1})
+ if err != nil {
+ t.Errorf("expected nil, got %v", err)
+ }
+
+ // invalid user
+ err = as.IsAdminPermitted(&AuthInfo{Username: "rooti", Revision: 1})
+ if err != ErrUserNotFound {
+ t.Errorf("expected %v, got %v", ErrUserNotFound, err)
+ }
+
+ // non-admin user
+ err = as.IsAdminPermitted(&AuthInfo{Username: "foo", Revision: 1})
+ if err != ErrPermissionDenied {
+ t.Errorf("expected %v, got %v", ErrPermissionDenied, err)
+ }
+
+ // disabled auth should return nil
+ as.AuthDisable()
+ err = as.IsAdminPermitted(&AuthInfo{Username: "root", Revision: 1})
+ if err != nil {
+ t.Errorf("expected nil, got %v", err)
+ }
+}
+
+func TestRecoverFromSnapshot(t *testing.T) {
+ as, _ := setupAuthStore(t)
+
+ ua := &pb.AuthUserAddRequest{Name: "foo"}
+ _, err := as.UserAdd(ua) // add an existing user
+ if err == nil {
+ t.Fatalf("expected %v, got %v", ErrUserAlreadyExist, err)
+ }
+ if err != ErrUserAlreadyExist {
+ t.Fatalf("expected %v, got %v", ErrUserAlreadyExist, err)
+ }
+
+ ua = &pb.AuthUserAddRequest{Name: ""}
+ _, err = as.UserAdd(ua) // add a user with empty name
+ if err != ErrUserEmpty {
+ t.Fatal(err)
+ }
+
+ as.Close()
+
+ tp, err := NewTokenProvider("simple", dummyIndexWaiter)
+ if err != nil {
+ t.Fatal(err)
+ }
+ as2 := NewAuthStore(as.be, tp)
+ defer func(a *authStore) {
+ a.Close()
+ }(as2)
+
+ if !as2.isAuthEnabled() {
+ t.Fatal("recovering authStore from existing backend failed")
+ }
+
+ ul, err := as.UserList(&pb.AuthUserListRequest{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !contains(ul.Users, "root") {
+ t.Errorf("expected %v in %v", "root", ul.Users)
+ }
+}
+
+func contains(array []string, str string) bool {
+ for _, s := range array {
+ if s == str {
+ return true
+ }
+ }
+ return false
+}
+
+func TestHammerSimpleAuthenticate(t *testing.T) {
+ // set TTL values low to try to trigger races
+ oldTTL, oldTTLRes := simpleTokenTTL, simpleTokenTTLResolution
+ defer func() {
+ simpleTokenTTL = oldTTL
+ simpleTokenTTLResolution = oldTTLRes
+ }()
+ simpleTokenTTL = 10 * time.Millisecond
+ simpleTokenTTLResolution = simpleTokenTTL
+ users := make(map[string]struct{})
+
+ as, tearDown := setupAuthStore(t)
+ defer tearDown(t)
+
+ // create lots of users
+ for i := 0; i < 50; i++ {
+ u := fmt.Sprintf("user-%d", i)
+ ua := &pb.AuthUserAddRequest{Name: u, Password: "123"}
+ if _, err := as.UserAdd(ua); err != nil {
+ t.Fatal(err)
+ }
+ users[u] = struct{}{}
+ }
+
+ // hammer on authenticate with lots of users
+ for i := 0; i < 10; i++ {
+ var wg sync.WaitGroup
+ wg.Add(len(users))
+ for u := range users {
+ go func(user string) {
+ defer wg.Done()
+ token := fmt.Sprintf("%s(%d)", user, i)
+ ctx := context.WithValue(context.WithValue(context.TODO(), "index", uint64(1)), "simpleToken", token)
+ if _, err := as.Authenticate(ctx, user, "123"); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := as.AuthInfoFromCtx(ctx); err != nil {
+ t.Fatal(err)
+ }
+ }(u)
+ }
+ time.Sleep(time.Millisecond)
+ wg.Wait()
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/bill-of-materials.json b/vendor/github.com/coreos/etcd/bill-of-materials.json
new file mode 100644
index 00000000..0a0f98a9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/bill-of-materials.json
@@ -0,0 +1,379 @@
+[
+ {
+ "project": "bitbucket.org/ww/goautoneg",
+ "licenses": [
+ {
+ "type": "BSD 3-clause \"New\" or \"Revised\" License",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/beorn7/perks/quantile",
+ "licenses": [
+ {
+ "type": "MIT License",
+ "confidence": 0.9891304347826086
+ }
+ ]
+ },
+ {
+ "project": "github.com/bgentry/speakeasy",
+ "licenses": [
+ {
+ "type": "MIT License",
+ "confidence": 0.9441624365482234
+ }
+ ]
+ },
+ {
+ "project": "github.com/boltdb/bolt",
+ "licenses": [
+ {
+ "type": "MIT License",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/cockroachdb/cmux",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/coreos/etcd",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/coreos/go-semver/semver",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/coreos/go-systemd",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 0.9966703662597114
+ }
+ ]
+ },
+ {
+ "project": "github.com/coreos/pkg",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/cpuguy83/go-md2man/md2man",
+ "licenses": [
+ {
+ "type": "MIT License",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/dgrijalva/jwt-go",
+ "licenses": [
+ {
+ "type": "MIT License",
+ "confidence": 0.9891304347826086
+ }
+ ]
+ },
+ {
+ "project": "github.com/dustin/go-humanize",
+ "licenses": [
+ {
+ "type": "MIT License",
+ "confidence": 0.96875
+ }
+ ]
+ },
+ {
+ "project": "github.com/ghodss/yaml",
+ "licenses": [
+ {
+ "type": "MIT License and BSD 3-clause \"New\" or \"Revised\" License",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/gogo/protobuf/proto",
+ "licenses": [
+ {
+ "type": "BSD 3-clause \"New\" or \"Revised\" License",
+ "confidence": 0.9090909090909091
+ }
+ ]
+ },
+ {
+ "project": "github.com/golang/groupcache/lru",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 0.9966703662597114
+ }
+ ]
+ },
+ {
+ "project": "github.com/golang/protobuf",
+ "licenses": [
+ {
+ "type": "BSD 3-clause \"New\" or \"Revised\" License",
+ "confidence": 0.92
+ }
+ ]
+ },
+ {
+ "project": "github.com/google/btree",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/grpc-ecosystem/go-grpc-prometheus",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/grpc-ecosystem/grpc-gateway",
+ "licenses": [
+ {
+ "type": "BSD 3-clause \"New\" or \"Revised\" License",
+ "confidence": 0.979253112033195
+ }
+ ]
+ },
+ {
+ "project": "github.com/inconshreveable/mousetrap",
+ "licenses": [
+ {
+ "type": "MIT License and BSD 3-clause \"New\" or \"Revised\" License",
+ "confidence": 1
+ },
+ {
+ "type": "Apache License 2.0",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/jonboulle/clockwork",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/mattn/go-runewidth",
+ "licenses": [
+ {
+ "type": "MIT License",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/matttproud/golang_protobuf_extensions/pbutil",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/olekukonko/tablewriter",
+ "licenses": [
+ {
+ "type": "MIT License",
+ "confidence": 0.9891304347826086
+ }
+ ]
+ },
+ {
+ "project": "github.com/prometheus/client_golang/prometheus",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/prometheus/client_model/go",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/prometheus/common",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/prometheus/procfs",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/russross/blackfriday",
+ "licenses": [
+ {
+ "type": "BSD 2-clause \"Simplified\" License",
+ "confidence": 0.9626168224299065
+ }
+ ]
+ },
+ {
+ "project": "github.com/spf13/cobra",
+ "licenses": [
+ {
+ "type": "Apache License 2.0",
+ "confidence": 0.9573241061130334
+ }
+ ]
+ },
+ {
+ "project": "github.com/spf13/pflag",
+ "licenses": [
+ {
+ "type": "BSD 3-clause \"New\" or \"Revised\" License",
+ "confidence": 0.9663865546218487
+ }
+ ]
+ },
+ {
+ "project": "github.com/ugorji/go/codec",
+ "licenses": [
+ {
+ "type": "MIT License",
+ "confidence": 0.9946524064171123
+ }
+ ]
+ },
+ {
+ "project": "github.com/urfave/cli",
+ "licenses": [
+ {
+ "type": "MIT License",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "github.com/xiang90/probing",
+ "licenses": [
+ {
+ "type": "MIT License",
+ "confidence": 1
+ }
+ ]
+ },
+ {
+ "project": "golang.org/x/crypto",
+ "licenses": [
+ {
+ "type": "BSD 3-clause \"New\" or \"Revised\" License",
+ "confidence": 0.9663865546218487
+ }
+ ]
+ },
+ {
+ "project": "golang.org/x/net",
+ "licenses": [
+ {
+ "type": "BSD 3-clause \"New\" or \"Revised\" License",
+ "confidence": 0.9663865546218487
+ }
+ ]
+ },
+ {
+ "project": "golang.org/x/text",
+ "licenses": [
+ {
+ "type": "BSD 3-clause \"New\" or \"Revised\" License",
+ "confidence": 0.9663865546218487
+ }
+ ]
+ },
+ {
+ "project": "golang.org/x/time/rate",
+ "licenses": [
+ {
+ "type": "BSD 3-clause \"New\" or \"Revised\" License",
+ "confidence": 0.9663865546218487
+ }
+ ]
+ },
+ {
+ "project": "google.golang.org/grpc",
+ "licenses": [
+ {
+ "type": "BSD 3-clause \"New\" or \"Revised\" License",
+ "confidence": 0.979253112033195
+ }
+ ]
+ },
+ {
+ "project": "gopkg.in/cheggaaa/pb.v1",
+ "licenses": [
+ {
+ "type": "BSD 3-clause \"New\" or \"Revised\" License",
+ "confidence": 0.9916666666666667
+ }
+ ]
+ },
+ {
+ "project": "gopkg.in/yaml.v2",
+ "licenses": [
+ {
+ "type": "The Unlicense",
+ "confidence": 0.35294117647058826
+ },
+ {
+ "type": "MIT License",
+ "confidence": 0.8975609756097561
+ }
+ ]
+ }
+]
diff --git a/vendor/github.com/coreos/etcd/bill-of-materials.override.json b/vendor/github.com/coreos/etcd/bill-of-materials.override.json
new file mode 100644
index 00000000..34de90e7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/bill-of-materials.override.json
@@ -0,0 +1,26 @@
+[
+ {
+ "project": "bitbucket.org/ww/goautoneg",
+ "licenses": [
+ {
+ "type": "BSD 3-clause \"New\" or \"Revised\" License"
+ }
+ ]
+ },
+ {
+ "project": "github.com/ghodss/yaml",
+ "licenses": [
+ {
+ "type": "MIT License and BSD 3-clause \"New\" or \"Revised\" License"
+ }
+ ]
+ },
+ {
+ "project": "github.com/inconshreveable/mousetrap",
+ "licenses": [
+ {
+ "type": "Apache License 2.0"
+ }
+ ]
+ }
+]
diff --git a/vendor/github.com/coreos/etcd/build b/vendor/github.com/coreos/etcd/build
new file mode 100755
index 00000000..36be42eb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/build
@@ -0,0 +1,64 @@
+#!/bin/sh -e
+
+# set some environment variables
+ORG_PATH="github.com/coreos"
+REPO_PATH="${ORG_PATH}/etcd"
+
+GIT_SHA=`git rev-parse --short HEAD || echo "GitNotFound"`
+if [ ! -z "$FAILPOINTS" ]; then
+ GIT_SHA="$GIT_SHA"-FAILPOINTS
+fi
+
+# Set GO_LDFLAGS="-s" for building without symbols for debugging.
+GO_LDFLAGS="$GO_LDFLAGS -X ${REPO_PATH}/cmd/vendor/${REPO_PATH}/version.GitSHA=${GIT_SHA}"
+
+# enable/disable failpoints
+toggle_failpoints() {
+ FAILPKGS="etcdserver/ mvcc/backend/"
+ mode="$1"
+ if which gofail >/dev/null 2>&1; then
+ gofail "$mode" $FAILPKGS
+ elif [ "$mode" != "disable" ]; then
+ echo "FAILPOINTS set but gofail not found"
+ exit 1
+ fi
+}
+
+toggle_failpoints_default() {
+ mode="disable"
+ if [ ! -z "$FAILPOINTS" ]; then mode="enable"; fi
+ toggle_failpoints "$mode"
+}
+
+etcd_build() {
+ out="bin"
+ if [ -n "${BINDIR}" ]; then out="${BINDIR}"; fi
+ toggle_failpoints_default
+ # Static compilation is useful when etcd is run in a container
+ CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o ${out}/etcd ${REPO_PATH}/cmd/etcd || return
+ CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o ${out}/etcdctl ${REPO_PATH}/cmd/etcdctl || return
+}
+
+etcd_setup_gopath() {
+ d=$(dirname "$0")
+ CDIR=$(cd "$d" && pwd)
+ cd "$CDIR"
+ etcdGOPATH="${CDIR}/gopath"
+ # preserve old gopath to support building with unvendored tooling deps (e.g., gofail)
+ if [ -n "$GOPATH" ]; then
+ GOPATH=":$GOPATH"
+ fi
+ export GOPATH=${etcdGOPATH}$GOPATH
+ rm -rf ${etcdGOPATH}/src
+ mkdir -p ${etcdGOPATH}
+ ln -s ${CDIR}/cmd/vendor ${etcdGOPATH}/src
+}
+
+toggle_failpoints_default
+
+# only build when called directly, not sourced
+if echo "$0" | grep "build$" >/dev/null; then
+ # force new gopath so builds outside of gopath work
+ etcd_setup_gopath
+ etcd_build
+fi
diff --git a/vendor/github.com/coreos/etcd/build.bat b/vendor/github.com/coreos/etcd/build.bat
new file mode 100755
index 00000000..ff9b209a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/build.bat
@@ -0,0 +1 @@
+powershell -ExecutionPolicy Bypass -File build.ps1
diff --git a/vendor/github.com/coreos/etcd/build.ps1 b/vendor/github.com/coreos/etcd/build.ps1
new file mode 100644
index 00000000..455d37d2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/build.ps1
@@ -0,0 +1,81 @@
+$ORG_PATH="github.com/coreos"
+$REPO_PATH="$ORG_PATH/etcd"
+$PWD = $((Get-Item -Path ".\" -Verbose).FullName)
+$FSROOT = $((Get-Location).Drive.Name+":")
+$FSYS = $((Get-WMIObject win32_logicaldisk -filter "DeviceID = '$FSROOT'").filesystem)
+
+if ($FSYS.StartsWith("FAT","CurrentCultureIgnoreCase")) {
+ echo "Error: Cannot build etcd using the $FSYS filesystem (use NTFS instead)"
+ exit 1
+}
+
+# Set $Env:GO_LDFLAGS="-s" for building without symbols.
+$GO_LDFLAGS="$Env:GO_LDFLAGS -X $REPO_PATH/cmd/vendor/$REPO_PATH/version.GitSHA=$GIT_SHA"
+
+# rebuild symlinks
+git ls-files -s cmd | select-string -pattern 120000 | ForEach {
+ $l = $_.ToString()
+ $lnkname = $l.Split(' ')[1]
+ $target = "$(git log -p HEAD -- $lnkname | select -last 2 | select -first 1)"
+ $target = $target.SubString(1,$target.Length-1).Replace("/","\")
+ $lnkname = $lnkname.Replace("/","\")
+
+ $terms = $lnkname.Split("\")
+ $dirname = $terms[0..($terms.length-2)] -join "\"
+ $lnkname = "$PWD\$lnkname"
+ $targetAbs = "$((Get-Item -Path "$dirname\$target").FullName)"
+ $targetAbs = $targetAbs.Replace("/", "\")
+
+ if (test-path -pathtype container "$targetAbs") {
+ if (Test-Path "$lnkname") {
+ if ((Get-Item "$lnkname") -is [System.IO.DirectoryInfo]) {
+ # rd so deleting junction doesn't take files with it
+ cmd /c rd "$lnkname"
+ }
+ }
+ if (Test-Path "$lnkname") {
+ if (!((Get-Item "$lnkname") -is [System.IO.DirectoryInfo])) {
+ cmd /c del /A /F "$lnkname"
+ }
+ }
+ cmd /c mklink /J "$lnkname" "$targetAbs" ">NUL"
+ } else {
+ # Remove file with symlink data (first run)
+ if (Test-Path "$lnkname") {
+ cmd /c del /A /F "$lnkname"
+ }
+ cmd /c mklink /H "$lnkname" "$targetAbs" ">NUL"
+ }
+}
+
+if (-not $env:GOPATH) {
+ $orgpath="$PWD\gopath\src\" + $ORG_PATH.Replace("/", "\")
+ if (Test-Path "$orgpath\etcd") {
+ if ((Get-Item "$orgpath\etcd") -is [System.IO.DirectoryInfo]) {
+ # rd so deleting junction doesn't take files with it
+ cmd /c rd "$orgpath\etcd"
+ }
+ }
+ if (Test-Path "$orgpath") {
+ if ((Get-Item "$orgpath") -is [System.IO.DirectoryInfo]) {
+ # rd so deleting junction doesn't take files with it
+ cmd /c rd "$orgpath"
+ }
+ }
+ if (Test-Path "$orgpath") {
+ if (!((Get-Item "$orgpath") -is [System.IO.DirectoryInfo])) {
+ # Remove file with symlink data (first run)
+ cmd /c del /A /F "$orgpath"
+ }
+ }
+ cmd /c mkdir "$orgpath"
+ cmd /c mklink /J "$orgpath\etcd" "$PWD" ">NUL"
+ $env:GOPATH = "$PWD\gopath"
+}
+
+# Static compilation is useful when etcd is run in a container
+$env:CGO_ENABLED = 0
+$env:GO15VENDOREXPERIMENT = 1
+$GIT_SHA="$(git rev-parse --short HEAD)"
+go build -a -installsuffix cgo -ldflags $GO_LDFLAGS -o bin\etcd.exe "$REPO_PATH\cmd\etcd"
+go build -a -installsuffix cgo -ldflags $GO_LDFLAGS -o bin\etcdctl.exe "$REPO_PATH\cmd\etcdctl"
diff --git a/vendor/github.com/coreos/etcd/client/README.md b/vendor/github.com/coreos/etcd/client/README.md
new file mode 100644
index 00000000..c0ec8190
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/README.md
@@ -0,0 +1,117 @@
+# etcd/client
+
+etcd/client is the Go client library for etcd.
+
+[![GoDoc](https://godoc.org/github.com/coreos/etcd/client?status.png)](https://godoc.org/github.com/coreos/etcd/client)
+
+etcd uses `cmd/vendor` directory to store external dependencies, which are
+to be compiled into etcd release binaries. `client` can be imported without
+vendoring. For full compatibility, it is recommended to vendor builds using
+etcd's vendored packages, using tools like godep, as in
+[vendor directories](https://golang.org/cmd/go/#hdr-Vendor_Directories).
+For more detail, please read [Go vendor design](https://golang.org/s/go15vendor).
+
+## Install
+
+```bash
+go get github.com/coreos/etcd/client
+```
+
+## Usage
+
+```go
+package main
+
+import (
+ "log"
+ "time"
+
+ "golang.org/x/net/context"
+ "github.com/coreos/etcd/client"
+)
+
+func main() {
+ cfg := client.Config{
+ Endpoints: []string{"http://127.0.0.1:2379"},
+ Transport: client.DefaultTransport,
+ // set timeout per request to fail fast when the target endpoint is unavailable
+ HeaderTimeoutPerRequest: time.Second,
+ }
+ c, err := client.New(cfg)
+ if err != nil {
+ log.Fatal(err)
+ }
+ kapi := client.NewKeysAPI(c)
+ // set "/foo" key with "bar" value
+ log.Print("Setting '/foo' key with 'bar' value")
+ resp, err := kapi.Set(context.Background(), "/foo", "bar", nil)
+ if err != nil {
+ log.Fatal(err)
+ } else {
+ // print common key info
+ log.Printf("Set is done. Metadata is %q\n", resp)
+ }
+ // get "/foo" key's value
+ log.Print("Getting '/foo' key value")
+ resp, err = kapi.Get(context.Background(), "/foo", nil)
+ if err != nil {
+ log.Fatal(err)
+ } else {
+ // print common key info
+ log.Printf("Get is done. Metadata is %q\n", resp)
+ // print value
+ log.Printf("%q key has %q value\n", resp.Node.Key, resp.Node.Value)
+ }
+}
+```
+
+## Error Handling
+
+etcd client might return three types of errors.
+
+- context error
+
+Each API call has its first parameter as `context`. A context can be canceled or have an attached deadline. If the context is canceled or reaches its deadline, the responding context error will be returned no matter what internal errors the API call has already encountered.
+
+- cluster error
+
+Each API call tries to send request to the cluster endpoints one by one until it successfully gets a response. If a requests to an endpoint fails, due to exceeding per request timeout or connection issues, the error will be added into a list of errors. If all possible endpoints fail, a cluster error that includes all encountered errors will be returned.
+
+- response error
+
+If the response gets from the cluster is invalid, a plain string error will be returned. For example, it might be a invalid JSON error.
+
+Here is the example code to handle client errors:
+
+```go
+cfg := client.Config{Endpoints: []string{"http://etcd1:2379","http://etcd2:2379","http://etcd3:2379"}}
+c, err := client.New(cfg)
+if err != nil {
+ log.Fatal(err)
+}
+
+kapi := client.NewKeysAPI(c)
+resp, err := kapi.Set(ctx, "test", "bar", nil)
+if err != nil {
+ if err == context.Canceled {
+ // ctx is canceled by another routine
+ } else if err == context.DeadlineExceeded {
+ // ctx is attached with a deadline and it exceeded
+ } else if cerr, ok := err.(*client.ClusterError); ok {
+ // process (cerr.Errors)
+ } else {
+ // bad cluster endpoints, which are not etcd servers
+ }
+}
+```
+
+
+## Caveat
+
+1. etcd/client prefers to use the same endpoint as long as the endpoint continues to work well. This saves socket resources, and improves efficiency for both client and server side. This preference doesn't remove consistency from the data consumed by the client because data replicated to each etcd member has already passed through the consensus process.
+
+2. etcd/client does round-robin rotation on other available endpoints if the preferred endpoint isn't functioning properly. For example, if the member that etcd/client connects to is hard killed, etcd/client will fail on the first attempt with the killed member, and succeed on the second attempt with another member. If it fails to talk to all available endpoints, it will return all errors happened.
+
+3. Default etcd/client cannot handle the case that the remote server is SIGSTOPed now. TCP keepalive mechanism doesn't help in this scenario because operating system may still send TCP keep-alive packets. Over time we'd like to improve this functionality, but solving this issue isn't high priority because a real-life case in which a server is stopped, but the connection is kept alive, hasn't been brought to our attention.
+
+4. etcd/client cannot detect whether a member is healthy with watches and non-quorum read requests. If the member is isolated from the cluster, etcd/client may retrieve outdated data. Instead, users can either issue quorum read requests or monitor the /health endpoint for member health information.
diff --git a/vendor/github.com/coreos/etcd/client/auth_role.go b/vendor/github.com/coreos/etcd/client/auth_role.go
new file mode 100644
index 00000000..d15e00dd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/auth_role.go
@@ -0,0 +1,237 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client
+
+import (
+ "bytes"
+ "encoding/json"
+ "net/http"
+ "net/url"
+
+ "golang.org/x/net/context"
+)
+
+type Role struct {
+ Role string `json:"role"`
+ Permissions Permissions `json:"permissions"`
+ Grant *Permissions `json:"grant,omitempty"`
+ Revoke *Permissions `json:"revoke,omitempty"`
+}
+
+type Permissions struct {
+ KV rwPermission `json:"kv"`
+}
+
+type rwPermission struct {
+ Read []string `json:"read"`
+ Write []string `json:"write"`
+}
+
+type PermissionType int
+
+const (
+ ReadPermission PermissionType = iota
+ WritePermission
+ ReadWritePermission
+)
+
+// NewAuthRoleAPI constructs a new AuthRoleAPI that uses HTTP to
+// interact with etcd's role creation and modification features.
+func NewAuthRoleAPI(c Client) AuthRoleAPI {
+ return &httpAuthRoleAPI{
+ client: c,
+ }
+}
+
+type AuthRoleAPI interface {
+ // AddRole adds a role.
+ AddRole(ctx context.Context, role string) error
+
+ // RemoveRole removes a role.
+ RemoveRole(ctx context.Context, role string) error
+
+ // GetRole retrieves role details.
+ GetRole(ctx context.Context, role string) (*Role, error)
+
+ // GrantRoleKV grants a role some permission prefixes for the KV store.
+ GrantRoleKV(ctx context.Context, role string, prefixes []string, permType PermissionType) (*Role, error)
+
+ // RevokeRoleKV revokes some permission prefixes for a role on the KV store.
+ RevokeRoleKV(ctx context.Context, role string, prefixes []string, permType PermissionType) (*Role, error)
+
+ // ListRoles lists roles.
+ ListRoles(ctx context.Context) ([]string, error)
+}
+
+type httpAuthRoleAPI struct {
+ client httpClient
+}
+
+type authRoleAPIAction struct {
+ verb string
+ name string
+ role *Role
+}
+
+type authRoleAPIList struct{}
+
+func (list *authRoleAPIList) HTTPRequest(ep url.URL) *http.Request {
+ u := v2AuthURL(ep, "roles", "")
+ req, _ := http.NewRequest("GET", u.String(), nil)
+ req.Header.Set("Content-Type", "application/json")
+ return req
+}
+
+func (l *authRoleAPIAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2AuthURL(ep, "roles", l.name)
+ if l.role == nil {
+ req, _ := http.NewRequest(l.verb, u.String(), nil)
+ return req
+ }
+ b, err := json.Marshal(l.role)
+ if err != nil {
+ panic(err)
+ }
+ body := bytes.NewReader(b)
+ req, _ := http.NewRequest(l.verb, u.String(), body)
+ req.Header.Set("Content-Type", "application/json")
+ return req
+}
+
+func (r *httpAuthRoleAPI) ListRoles(ctx context.Context) ([]string, error) {
+ resp, body, err := r.client.Do(ctx, &authRoleAPIList{})
+ if err != nil {
+ return nil, err
+ }
+ if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
+ return nil, err
+ }
+ var roleList struct {
+ Roles []Role `json:"roles"`
+ }
+ if err = json.Unmarshal(body, &roleList); err != nil {
+ return nil, err
+ }
+ ret := make([]string, 0, len(roleList.Roles))
+ for _, r := range roleList.Roles {
+ ret = append(ret, r.Role)
+ }
+ return ret, nil
+}
+
+func (r *httpAuthRoleAPI) AddRole(ctx context.Context, rolename string) error {
+ role := &Role{
+ Role: rolename,
+ }
+ return r.addRemoveRole(ctx, &authRoleAPIAction{
+ verb: "PUT",
+ name: rolename,
+ role: role,
+ })
+}
+
+func (r *httpAuthRoleAPI) RemoveRole(ctx context.Context, rolename string) error {
+ return r.addRemoveRole(ctx, &authRoleAPIAction{
+ verb: "DELETE",
+ name: rolename,
+ })
+}
+
+func (r *httpAuthRoleAPI) addRemoveRole(ctx context.Context, req *authRoleAPIAction) error {
+ resp, body, err := r.client.Do(ctx, req)
+ if err != nil {
+ return err
+ }
+ if err := assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil {
+ var sec authError
+ err := json.Unmarshal(body, &sec)
+ if err != nil {
+ return err
+ }
+ return sec
+ }
+ return nil
+}
+
+func (r *httpAuthRoleAPI) GetRole(ctx context.Context, rolename string) (*Role, error) {
+ return r.modRole(ctx, &authRoleAPIAction{
+ verb: "GET",
+ name: rolename,
+ })
+}
+
+func buildRWPermission(prefixes []string, permType PermissionType) rwPermission {
+ var out rwPermission
+ switch permType {
+ case ReadPermission:
+ out.Read = prefixes
+ case WritePermission:
+ out.Write = prefixes
+ case ReadWritePermission:
+ out.Read = prefixes
+ out.Write = prefixes
+ }
+ return out
+}
+
+func (r *httpAuthRoleAPI) GrantRoleKV(ctx context.Context, rolename string, prefixes []string, permType PermissionType) (*Role, error) {
+ rwp := buildRWPermission(prefixes, permType)
+ role := &Role{
+ Role: rolename,
+ Grant: &Permissions{
+ KV: rwp,
+ },
+ }
+ return r.modRole(ctx, &authRoleAPIAction{
+ verb: "PUT",
+ name: rolename,
+ role: role,
+ })
+}
+
+func (r *httpAuthRoleAPI) RevokeRoleKV(ctx context.Context, rolename string, prefixes []string, permType PermissionType) (*Role, error) {
+ rwp := buildRWPermission(prefixes, permType)
+ role := &Role{
+ Role: rolename,
+ Revoke: &Permissions{
+ KV: rwp,
+ },
+ }
+ return r.modRole(ctx, &authRoleAPIAction{
+ verb: "PUT",
+ name: rolename,
+ role: role,
+ })
+}
+
+func (r *httpAuthRoleAPI) modRole(ctx context.Context, req *authRoleAPIAction) (*Role, error) {
+ resp, body, err := r.client.Do(ctx, req)
+ if err != nil {
+ return nil, err
+ }
+ if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
+ var sec authError
+ err = json.Unmarshal(body, &sec)
+ if err != nil {
+ return nil, err
+ }
+ return nil, sec
+ }
+ var role Role
+ if err = json.Unmarshal(body, &role); err != nil {
+ return nil, err
+ }
+ return &role, nil
+}
diff --git a/vendor/github.com/coreos/etcd/client/auth_user.go b/vendor/github.com/coreos/etcd/client/auth_user.go
new file mode 100644
index 00000000..97c3f318
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/auth_user.go
@@ -0,0 +1,320 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client
+
+import (
+ "bytes"
+ "encoding/json"
+ "net/http"
+ "net/url"
+ "path"
+
+ "golang.org/x/net/context"
+)
+
+var (
+ defaultV2AuthPrefix = "/v2/auth"
+)
+
+type User struct {
+ User string `json:"user"`
+ Password string `json:"password,omitempty"`
+ Roles []string `json:"roles"`
+ Grant []string `json:"grant,omitempty"`
+ Revoke []string `json:"revoke,omitempty"`
+}
+
+// userListEntry is the user representation given by the server for ListUsers
+type userListEntry struct {
+ User string `json:"user"`
+ Roles []Role `json:"roles"`
+}
+
+type UserRoles struct {
+ User string `json:"user"`
+ Roles []Role `json:"roles"`
+}
+
+func v2AuthURL(ep url.URL, action string, name string) *url.URL {
+ if name != "" {
+ ep.Path = path.Join(ep.Path, defaultV2AuthPrefix, action, name)
+ return &ep
+ }
+ ep.Path = path.Join(ep.Path, defaultV2AuthPrefix, action)
+ return &ep
+}
+
+// NewAuthAPI constructs a new AuthAPI that uses HTTP to
+// interact with etcd's general auth features.
+func NewAuthAPI(c Client) AuthAPI {
+ return &httpAuthAPI{
+ client: c,
+ }
+}
+
+type AuthAPI interface {
+ // Enable auth.
+ Enable(ctx context.Context) error
+
+ // Disable auth.
+ Disable(ctx context.Context) error
+}
+
+type httpAuthAPI struct {
+ client httpClient
+}
+
+func (s *httpAuthAPI) Enable(ctx context.Context) error {
+ return s.enableDisable(ctx, &authAPIAction{"PUT"})
+}
+
+func (s *httpAuthAPI) Disable(ctx context.Context) error {
+ return s.enableDisable(ctx, &authAPIAction{"DELETE"})
+}
+
+func (s *httpAuthAPI) enableDisable(ctx context.Context, req httpAction) error {
+ resp, body, err := s.client.Do(ctx, req)
+ if err != nil {
+ return err
+ }
+ if err = assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil {
+ var sec authError
+ err = json.Unmarshal(body, &sec)
+ if err != nil {
+ return err
+ }
+ return sec
+ }
+ return nil
+}
+
+type authAPIAction struct {
+ verb string
+}
+
+func (l *authAPIAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2AuthURL(ep, "enable", "")
+ req, _ := http.NewRequest(l.verb, u.String(), nil)
+ return req
+}
+
+type authError struct {
+ Message string `json:"message"`
+ Code int `json:"-"`
+}
+
+func (e authError) Error() string {
+ return e.Message
+}
+
+// NewAuthUserAPI constructs a new AuthUserAPI that uses HTTP to
+// interact with etcd's user creation and modification features.
+func NewAuthUserAPI(c Client) AuthUserAPI {
+ return &httpAuthUserAPI{
+ client: c,
+ }
+}
+
+type AuthUserAPI interface {
+ // AddUser adds a user.
+ AddUser(ctx context.Context, username string, password string) error
+
+ // RemoveUser removes a user.
+ RemoveUser(ctx context.Context, username string) error
+
+ // GetUser retrieves user details.
+ GetUser(ctx context.Context, username string) (*User, error)
+
+ // GrantUser grants a user some permission roles.
+ GrantUser(ctx context.Context, username string, roles []string) (*User, error)
+
+ // RevokeUser revokes some permission roles from a user.
+ RevokeUser(ctx context.Context, username string, roles []string) (*User, error)
+
+ // ChangePassword changes the user's password.
+ ChangePassword(ctx context.Context, username string, password string) (*User, error)
+
+ // ListUsers lists the users.
+ ListUsers(ctx context.Context) ([]string, error)
+}
+
+type httpAuthUserAPI struct {
+ client httpClient
+}
+
+type authUserAPIAction struct {
+ verb string
+ username string
+ user *User
+}
+
+type authUserAPIList struct{}
+
+func (list *authUserAPIList) HTTPRequest(ep url.URL) *http.Request {
+ u := v2AuthURL(ep, "users", "")
+ req, _ := http.NewRequest("GET", u.String(), nil)
+ req.Header.Set("Content-Type", "application/json")
+ return req
+}
+
+func (l *authUserAPIAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2AuthURL(ep, "users", l.username)
+ if l.user == nil {
+ req, _ := http.NewRequest(l.verb, u.String(), nil)
+ return req
+ }
+ b, err := json.Marshal(l.user)
+ if err != nil {
+ panic(err)
+ }
+ body := bytes.NewReader(b)
+ req, _ := http.NewRequest(l.verb, u.String(), body)
+ req.Header.Set("Content-Type", "application/json")
+ return req
+}
+
+func (u *httpAuthUserAPI) ListUsers(ctx context.Context) ([]string, error) {
+ resp, body, err := u.client.Do(ctx, &authUserAPIList{})
+ if err != nil {
+ return nil, err
+ }
+ if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
+ var sec authError
+ err = json.Unmarshal(body, &sec)
+ if err != nil {
+ return nil, err
+ }
+ return nil, sec
+ }
+
+ var userList struct {
+ Users []userListEntry `json:"users"`
+ }
+
+ if err = json.Unmarshal(body, &userList); err != nil {
+ return nil, err
+ }
+
+ ret := make([]string, 0, len(userList.Users))
+ for _, u := range userList.Users {
+ ret = append(ret, u.User)
+ }
+ return ret, nil
+}
+
+func (u *httpAuthUserAPI) AddUser(ctx context.Context, username string, password string) error {
+ user := &User{
+ User: username,
+ Password: password,
+ }
+ return u.addRemoveUser(ctx, &authUserAPIAction{
+ verb: "PUT",
+ username: username,
+ user: user,
+ })
+}
+
+func (u *httpAuthUserAPI) RemoveUser(ctx context.Context, username string) error {
+ return u.addRemoveUser(ctx, &authUserAPIAction{
+ verb: "DELETE",
+ username: username,
+ })
+}
+
+func (u *httpAuthUserAPI) addRemoveUser(ctx context.Context, req *authUserAPIAction) error {
+ resp, body, err := u.client.Do(ctx, req)
+ if err != nil {
+ return err
+ }
+ if err = assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil {
+ var sec authError
+ err = json.Unmarshal(body, &sec)
+ if err != nil {
+ return err
+ }
+ return sec
+ }
+ return nil
+}
+
+func (u *httpAuthUserAPI) GetUser(ctx context.Context, username string) (*User, error) {
+ return u.modUser(ctx, &authUserAPIAction{
+ verb: "GET",
+ username: username,
+ })
+}
+
+func (u *httpAuthUserAPI) GrantUser(ctx context.Context, username string, roles []string) (*User, error) {
+ user := &User{
+ User: username,
+ Grant: roles,
+ }
+ return u.modUser(ctx, &authUserAPIAction{
+ verb: "PUT",
+ username: username,
+ user: user,
+ })
+}
+
+func (u *httpAuthUserAPI) RevokeUser(ctx context.Context, username string, roles []string) (*User, error) {
+ user := &User{
+ User: username,
+ Revoke: roles,
+ }
+ return u.modUser(ctx, &authUserAPIAction{
+ verb: "PUT",
+ username: username,
+ user: user,
+ })
+}
+
+func (u *httpAuthUserAPI) ChangePassword(ctx context.Context, username string, password string) (*User, error) {
+ user := &User{
+ User: username,
+ Password: password,
+ }
+ return u.modUser(ctx, &authUserAPIAction{
+ verb: "PUT",
+ username: username,
+ user: user,
+ })
+}
+
+func (u *httpAuthUserAPI) modUser(ctx context.Context, req *authUserAPIAction) (*User, error) {
+ resp, body, err := u.client.Do(ctx, req)
+ if err != nil {
+ return nil, err
+ }
+ if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
+ var sec authError
+ err = json.Unmarshal(body, &sec)
+ if err != nil {
+ return nil, err
+ }
+ return nil, sec
+ }
+ var user User
+ if err = json.Unmarshal(body, &user); err != nil {
+ var userR UserRoles
+ if urerr := json.Unmarshal(body, &userR); urerr != nil {
+ return nil, err
+ }
+ user.User = userR.User
+ for _, r := range userR.Roles {
+ user.Roles = append(user.Roles, r.Role)
+ }
+ }
+ return &user, nil
+}
diff --git a/vendor/github.com/coreos/etcd/client/cancelreq.go b/vendor/github.com/coreos/etcd/client/cancelreq.go
new file mode 100644
index 00000000..76d1f040
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/cancelreq.go
@@ -0,0 +1,18 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// borrowed from golang/net/context/ctxhttp/cancelreq.go
+
+package client
+
+import "net/http"
+
+func requestCanceler(tr CancelableTransport, req *http.Request) func() {
+ ch := make(chan struct{})
+ req.Cancel = ch
+
+ return func() {
+ close(ch)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/client/client.go b/vendor/github.com/coreos/etcd/client/client.go
new file mode 100644
index 00000000..498dfbcc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/client.go
@@ -0,0 +1,703 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io/ioutil"
+ "math/rand"
+ "net"
+ "net/http"
+ "net/url"
+ "sort"
+ "strconv"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/version"
+
+ "golang.org/x/net/context"
+)
+
+var (
+ ErrNoEndpoints = errors.New("client: no endpoints available")
+ ErrTooManyRedirects = errors.New("client: too many redirects")
+ ErrClusterUnavailable = errors.New("client: etcd cluster is unavailable or misconfigured")
+ ErrNoLeaderEndpoint = errors.New("client: no leader endpoint available")
+ errTooManyRedirectChecks = errors.New("client: too many redirect checks")
+
+ // oneShotCtxValue is set on a context using WithValue(&oneShotValue) so
+ // that Do() will not retry a request
+ oneShotCtxValue interface{}
+)
+
+var DefaultRequestTimeout = 5 * time.Second
+
+var DefaultTransport CancelableTransport = &http.Transport{
+ Proxy: http.ProxyFromEnvironment,
+ Dial: (&net.Dialer{
+ Timeout: 30 * time.Second,
+ KeepAlive: 30 * time.Second,
+ }).Dial,
+ TLSHandshakeTimeout: 10 * time.Second,
+}
+
+type EndpointSelectionMode int
+
+const (
+ // EndpointSelectionRandom is the default value of the 'SelectionMode'.
+ // As the name implies, the client object will pick a node from the members
+ // of the cluster in a random fashion. If the cluster has three members, A, B,
+ // and C, the client picks any node from its three members as its request
+ // destination.
+ EndpointSelectionRandom EndpointSelectionMode = iota
+
+ // If 'SelectionMode' is set to 'EndpointSelectionPrioritizeLeader',
+ // requests are sent directly to the cluster leader. This reduces
+ // forwarding roundtrips compared to making requests to etcd followers
+ // who then forward them to the cluster leader. In the event of a leader
+ // failure, however, clients configured this way cannot prioritize among
+ // the remaining etcd followers. Therefore, when a client sets 'SelectionMode'
+ // to 'EndpointSelectionPrioritizeLeader', it must use 'client.AutoSync()' to
+ // maintain its knowledge of current cluster state.
+ //
+ // This mode should be used with Client.AutoSync().
+ EndpointSelectionPrioritizeLeader
+)
+
+type Config struct {
+ // Endpoints defines a set of URLs (schemes, hosts and ports only)
+ // that can be used to communicate with a logical etcd cluster. For
+ // example, a three-node cluster could be provided like so:
+ //
+ // Endpoints: []string{
+ // "http://node1.example.com:2379",
+ // "http://node2.example.com:2379",
+ // "http://node3.example.com:2379",
+ // }
+ //
+ // If multiple endpoints are provided, the Client will attempt to
+ // use them all in the event that one or more of them are unusable.
+ //
+ // If Client.Sync is ever called, the Client may cache an alternate
+ // set of endpoints to continue operation.
+ Endpoints []string
+
+ // Transport is used by the Client to drive HTTP requests. If not
+ // provided, DefaultTransport will be used.
+ Transport CancelableTransport
+
+ // CheckRedirect specifies the policy for handling HTTP redirects.
+ // If CheckRedirect is not nil, the Client calls it before
+ // following an HTTP redirect. The sole argument is the number of
+ // requests that have already been made. If CheckRedirect returns
+ // an error, Client.Do will not make any further requests and return
+ // the error back it to the caller.
+ //
+ // If CheckRedirect is nil, the Client uses its default policy,
+ // which is to stop after 10 consecutive requests.
+ CheckRedirect CheckRedirectFunc
+
+ // Username specifies the user credential to add as an authorization header
+ Username string
+
+ // Password is the password for the specified user to add as an authorization header
+ // to the request.
+ Password string
+
+ // HeaderTimeoutPerRequest specifies the time limit to wait for response
+ // header in a single request made by the Client. The timeout includes
+ // connection time, any redirects, and header wait time.
+ //
+ // For non-watch GET request, server returns the response body immediately.
+ // For PUT/POST/DELETE request, server will attempt to commit request
+ // before responding, which is expected to take `100ms + 2 * RTT`.
+ // For watch request, server returns the header immediately to notify Client
+ // watch start. But if server is behind some kind of proxy, the response
+ // header may be cached at proxy, and Client cannot rely on this behavior.
+ //
+ // Especially, wait request will ignore this timeout.
+ //
+ // One API call may send multiple requests to different etcd servers until it
+ // succeeds. Use context of the API to specify the overall timeout.
+ //
+ // A HeaderTimeoutPerRequest of zero means no timeout.
+ HeaderTimeoutPerRequest time.Duration
+
+ // SelectionMode is an EndpointSelectionMode enum that specifies the
+ // policy for choosing the etcd cluster node to which requests are sent.
+ SelectionMode EndpointSelectionMode
+}
+
+func (cfg *Config) transport() CancelableTransport {
+ if cfg.Transport == nil {
+ return DefaultTransport
+ }
+ return cfg.Transport
+}
+
+func (cfg *Config) checkRedirect() CheckRedirectFunc {
+ if cfg.CheckRedirect == nil {
+ return DefaultCheckRedirect
+ }
+ return cfg.CheckRedirect
+}
+
+// CancelableTransport mimics net/http.Transport, but requires that
+// the object also support request cancellation.
+type CancelableTransport interface {
+ http.RoundTripper
+ CancelRequest(req *http.Request)
+}
+
+type CheckRedirectFunc func(via int) error
+
+// DefaultCheckRedirect follows up to 10 redirects, but no more.
+var DefaultCheckRedirect CheckRedirectFunc = func(via int) error {
+ if via > 10 {
+ return ErrTooManyRedirects
+ }
+ return nil
+}
+
+type Client interface {
+ // Sync updates the internal cache of the etcd cluster's membership.
+ Sync(context.Context) error
+
+ // AutoSync periodically calls Sync() every given interval.
+ // The recommended sync interval is 10 seconds to 1 minute, which does
+ // not bring too much overhead to server and makes client catch up the
+ // cluster change in time.
+ //
+ // The example to use it:
+ //
+ // for {
+ // err := client.AutoSync(ctx, 10*time.Second)
+ // if err == context.DeadlineExceeded || err == context.Canceled {
+ // break
+ // }
+ // log.Print(err)
+ // }
+ AutoSync(context.Context, time.Duration) error
+
+ // Endpoints returns a copy of the current set of API endpoints used
+ // by Client to resolve HTTP requests. If Sync has ever been called,
+ // this may differ from the initial Endpoints provided in the Config.
+ Endpoints() []string
+
+ // SetEndpoints sets the set of API endpoints used by Client to resolve
+ // HTTP requests. If the given endpoints are not valid, an error will be
+ // returned
+ SetEndpoints(eps []string) error
+
+ // GetVersion retrieves the current etcd server and cluster version
+ GetVersion(ctx context.Context) (*version.Versions, error)
+
+ httpClient
+}
+
+func New(cfg Config) (Client, error) {
+ c := &httpClusterClient{
+ clientFactory: newHTTPClientFactory(cfg.transport(), cfg.checkRedirect(), cfg.HeaderTimeoutPerRequest),
+ rand: rand.New(rand.NewSource(int64(time.Now().Nanosecond()))),
+ selectionMode: cfg.SelectionMode,
+ }
+ if cfg.Username != "" {
+ c.credentials = &credentials{
+ username: cfg.Username,
+ password: cfg.Password,
+ }
+ }
+ if err := c.SetEndpoints(cfg.Endpoints); err != nil {
+ return nil, err
+ }
+ return c, nil
+}
+
+type httpClient interface {
+ Do(context.Context, httpAction) (*http.Response, []byte, error)
+}
+
+func newHTTPClientFactory(tr CancelableTransport, cr CheckRedirectFunc, headerTimeout time.Duration) httpClientFactory {
+ return func(ep url.URL) httpClient {
+ return &redirectFollowingHTTPClient{
+ checkRedirect: cr,
+ client: &simpleHTTPClient{
+ transport: tr,
+ endpoint: ep,
+ headerTimeout: headerTimeout,
+ },
+ }
+ }
+}
+
+type credentials struct {
+ username string
+ password string
+}
+
+type httpClientFactory func(url.URL) httpClient
+
+type httpAction interface {
+ HTTPRequest(url.URL) *http.Request
+}
+
+type httpClusterClient struct {
+ clientFactory httpClientFactory
+ endpoints []url.URL
+ pinned int
+ credentials *credentials
+ sync.RWMutex
+ rand *rand.Rand
+ selectionMode EndpointSelectionMode
+}
+
+func (c *httpClusterClient) getLeaderEndpoint(ctx context.Context, eps []url.URL) (string, error) {
+ ceps := make([]url.URL, len(eps))
+ copy(ceps, eps)
+
+ // To perform a lookup on the new endpoint list without using the current
+ // client, we'll copy it
+ clientCopy := &httpClusterClient{
+ clientFactory: c.clientFactory,
+ credentials: c.credentials,
+ rand: c.rand,
+
+ pinned: 0,
+ endpoints: ceps,
+ }
+
+ mAPI := NewMembersAPI(clientCopy)
+ leader, err := mAPI.Leader(ctx)
+ if err != nil {
+ return "", err
+ }
+ if len(leader.ClientURLs) == 0 {
+ return "", ErrNoLeaderEndpoint
+ }
+
+ return leader.ClientURLs[0], nil // TODO: how to handle multiple client URLs?
+}
+
+func (c *httpClusterClient) parseEndpoints(eps []string) ([]url.URL, error) {
+ if len(eps) == 0 {
+ return []url.URL{}, ErrNoEndpoints
+ }
+
+ neps := make([]url.URL, len(eps))
+ for i, ep := range eps {
+ u, err := url.Parse(ep)
+ if err != nil {
+ return []url.URL{}, err
+ }
+ neps[i] = *u
+ }
+ return neps, nil
+}
+
+func (c *httpClusterClient) SetEndpoints(eps []string) error {
+ neps, err := c.parseEndpoints(eps)
+ if err != nil {
+ return err
+ }
+
+ c.Lock()
+ defer c.Unlock()
+
+ c.endpoints = shuffleEndpoints(c.rand, neps)
+ // We're not doing anything for PrioritizeLeader here. This is
+ // due to not having a context meaning we can't call getLeaderEndpoint
+ // However, if you're using PrioritizeLeader, you've already been told
+ // to regularly call sync, where we do have a ctx, and can figure the
+ // leader. PrioritizeLeader is also quite a loose guarantee, so deal
+ // with it
+ c.pinned = 0
+
+ return nil
+}
+
+func (c *httpClusterClient) Do(ctx context.Context, act httpAction) (*http.Response, []byte, error) {
+ action := act
+ c.RLock()
+ leps := len(c.endpoints)
+ eps := make([]url.URL, leps)
+ n := copy(eps, c.endpoints)
+ pinned := c.pinned
+
+ if c.credentials != nil {
+ action = &authedAction{
+ act: act,
+ credentials: *c.credentials,
+ }
+ }
+ c.RUnlock()
+
+ if leps == 0 {
+ return nil, nil, ErrNoEndpoints
+ }
+
+ if leps != n {
+ return nil, nil, errors.New("unable to pick endpoint: copy failed")
+ }
+
+ var resp *http.Response
+ var body []byte
+ var err error
+ cerr := &ClusterError{}
+ isOneShot := ctx.Value(&oneShotCtxValue) != nil
+
+ for i := pinned; i < leps+pinned; i++ {
+ k := i % leps
+ hc := c.clientFactory(eps[k])
+ resp, body, err = hc.Do(ctx, action)
+ if err != nil {
+ cerr.Errors = append(cerr.Errors, err)
+ if err == ctx.Err() {
+ return nil, nil, ctx.Err()
+ }
+ if err == context.Canceled || err == context.DeadlineExceeded {
+ return nil, nil, err
+ }
+ if isOneShot {
+ return nil, nil, err
+ }
+ continue
+ }
+ if resp.StatusCode/100 == 5 {
+ switch resp.StatusCode {
+ case http.StatusInternalServerError, http.StatusServiceUnavailable:
+ // TODO: make sure this is a no leader response
+ cerr.Errors = append(cerr.Errors, fmt.Errorf("client: etcd member %s has no leader", eps[k].String()))
+ default:
+ cerr.Errors = append(cerr.Errors, fmt.Errorf("client: etcd member %s returns server error [%s]", eps[k].String(), http.StatusText(resp.StatusCode)))
+ }
+ if isOneShot {
+ return nil, nil, cerr.Errors[0]
+ }
+ continue
+ }
+ if k != pinned {
+ c.Lock()
+ c.pinned = k
+ c.Unlock()
+ }
+ return resp, body, nil
+ }
+
+ return nil, nil, cerr
+}
+
+func (c *httpClusterClient) Endpoints() []string {
+ c.RLock()
+ defer c.RUnlock()
+
+ eps := make([]string, len(c.endpoints))
+ for i, ep := range c.endpoints {
+ eps[i] = ep.String()
+ }
+
+ return eps
+}
+
+func (c *httpClusterClient) Sync(ctx context.Context) error {
+ mAPI := NewMembersAPI(c)
+ ms, err := mAPI.List(ctx)
+ if err != nil {
+ return err
+ }
+
+ var eps []string
+ for _, m := range ms {
+ eps = append(eps, m.ClientURLs...)
+ }
+
+ neps, err := c.parseEndpoints(eps)
+ if err != nil {
+ return err
+ }
+
+ npin := 0
+
+ switch c.selectionMode {
+ case EndpointSelectionRandom:
+ c.RLock()
+ eq := endpointsEqual(c.endpoints, neps)
+ c.RUnlock()
+
+ if eq {
+ return nil
+ }
+ // When items in the endpoint list changes, we choose a new pin
+ neps = shuffleEndpoints(c.rand, neps)
+ case EndpointSelectionPrioritizeLeader:
+ nle, err := c.getLeaderEndpoint(ctx, neps)
+ if err != nil {
+ return ErrNoLeaderEndpoint
+ }
+
+ for i, n := range neps {
+ if n.String() == nle {
+ npin = i
+ break
+ }
+ }
+ default:
+ return fmt.Errorf("invalid endpoint selection mode: %d", c.selectionMode)
+ }
+
+ c.Lock()
+ defer c.Unlock()
+ c.endpoints = neps
+ c.pinned = npin
+
+ return nil
+}
+
+func (c *httpClusterClient) AutoSync(ctx context.Context, interval time.Duration) error {
+ ticker := time.NewTicker(interval)
+ defer ticker.Stop()
+ for {
+ err := c.Sync(ctx)
+ if err != nil {
+ return err
+ }
+ select {
+ case <-ctx.Done():
+ return ctx.Err()
+ case <-ticker.C:
+ }
+ }
+}
+
+func (c *httpClusterClient) GetVersion(ctx context.Context) (*version.Versions, error) {
+ act := &getAction{Prefix: "/version"}
+
+ resp, body, err := c.Do(ctx, act)
+ if err != nil {
+ return nil, err
+ }
+
+ switch resp.StatusCode {
+ case http.StatusOK:
+ if len(body) == 0 {
+ return nil, ErrEmptyBody
+ }
+ var vresp version.Versions
+ if err := json.Unmarshal(body, &vresp); err != nil {
+ return nil, ErrInvalidJSON
+ }
+ return &vresp, nil
+ default:
+ var etcdErr Error
+ if err := json.Unmarshal(body, &etcdErr); err != nil {
+ return nil, ErrInvalidJSON
+ }
+ return nil, etcdErr
+ }
+}
+
+type roundTripResponse struct {
+ resp *http.Response
+ err error
+}
+
+type simpleHTTPClient struct {
+ transport CancelableTransport
+ endpoint url.URL
+ headerTimeout time.Duration
+}
+
+func (c *simpleHTTPClient) Do(ctx context.Context, act httpAction) (*http.Response, []byte, error) {
+ req := act.HTTPRequest(c.endpoint)
+
+ if err := printcURL(req); err != nil {
+ return nil, nil, err
+ }
+
+ isWait := false
+ if req != nil && req.URL != nil {
+ ws := req.URL.Query().Get("wait")
+ if len(ws) != 0 {
+ var err error
+ isWait, err = strconv.ParseBool(ws)
+ if err != nil {
+ return nil, nil, fmt.Errorf("wrong wait value %s (%v for %+v)", ws, err, req)
+ }
+ }
+ }
+
+ var hctx context.Context
+ var hcancel context.CancelFunc
+ if !isWait && c.headerTimeout > 0 {
+ hctx, hcancel = context.WithTimeout(ctx, c.headerTimeout)
+ } else {
+ hctx, hcancel = context.WithCancel(ctx)
+ }
+ defer hcancel()
+
+ reqcancel := requestCanceler(c.transport, req)
+
+ rtchan := make(chan roundTripResponse, 1)
+ go func() {
+ resp, err := c.transport.RoundTrip(req)
+ rtchan <- roundTripResponse{resp: resp, err: err}
+ close(rtchan)
+ }()
+
+ var resp *http.Response
+ var err error
+
+ select {
+ case rtresp := <-rtchan:
+ resp, err = rtresp.resp, rtresp.err
+ case <-hctx.Done():
+ // cancel and wait for request to actually exit before continuing
+ reqcancel()
+ rtresp := <-rtchan
+ resp = rtresp.resp
+ switch {
+ case ctx.Err() != nil:
+ err = ctx.Err()
+ case hctx.Err() != nil:
+ err = fmt.Errorf("client: endpoint %s exceeded header timeout", c.endpoint.String())
+ default:
+ panic("failed to get error from context")
+ }
+ }
+
+ // always check for resp nil-ness to deal with possible
+ // race conditions between channels above
+ defer func() {
+ if resp != nil {
+ resp.Body.Close()
+ }
+ }()
+
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var body []byte
+ done := make(chan struct{})
+ go func() {
+ body, err = ioutil.ReadAll(resp.Body)
+ done <- struct{}{}
+ }()
+
+ select {
+ case <-ctx.Done():
+ resp.Body.Close()
+ <-done
+ return nil, nil, ctx.Err()
+ case <-done:
+ }
+
+ return resp, body, err
+}
+
+type authedAction struct {
+ act httpAction
+ credentials credentials
+}
+
+func (a *authedAction) HTTPRequest(url url.URL) *http.Request {
+ r := a.act.HTTPRequest(url)
+ r.SetBasicAuth(a.credentials.username, a.credentials.password)
+ return r
+}
+
+type redirectFollowingHTTPClient struct {
+ client httpClient
+ checkRedirect CheckRedirectFunc
+}
+
+func (r *redirectFollowingHTTPClient) Do(ctx context.Context, act httpAction) (*http.Response, []byte, error) {
+ next := act
+ for i := 0; i < 100; i++ {
+ if i > 0 {
+ if err := r.checkRedirect(i); err != nil {
+ return nil, nil, err
+ }
+ }
+ resp, body, err := r.client.Do(ctx, next)
+ if err != nil {
+ return nil, nil, err
+ }
+ if resp.StatusCode/100 == 3 {
+ hdr := resp.Header.Get("Location")
+ if hdr == "" {
+ return nil, nil, fmt.Errorf("Location header not set")
+ }
+ loc, err := url.Parse(hdr)
+ if err != nil {
+ return nil, nil, fmt.Errorf("Location header not valid URL: %s", hdr)
+ }
+ next = &redirectedHTTPAction{
+ action: act,
+ location: *loc,
+ }
+ continue
+ }
+ return resp, body, nil
+ }
+
+ return nil, nil, errTooManyRedirectChecks
+}
+
+type redirectedHTTPAction struct {
+ action httpAction
+ location url.URL
+}
+
+func (r *redirectedHTTPAction) HTTPRequest(ep url.URL) *http.Request {
+ orig := r.action.HTTPRequest(ep)
+ orig.URL = &r.location
+ return orig
+}
+
+func shuffleEndpoints(r *rand.Rand, eps []url.URL) []url.URL {
+ p := r.Perm(len(eps))
+ neps := make([]url.URL, len(eps))
+ for i, k := range p {
+ neps[i] = eps[k]
+ }
+ return neps
+}
+
+func endpointsEqual(left, right []url.URL) bool {
+ if len(left) != len(right) {
+ return false
+ }
+
+ sLeft := make([]string, len(left))
+ sRight := make([]string, len(right))
+ for i, l := range left {
+ sLeft[i] = l.String()
+ }
+ for i, r := range right {
+ sRight[i] = r.String()
+ }
+
+ sort.Strings(sLeft)
+ sort.Strings(sRight)
+ for i := range sLeft {
+ if sLeft[i] != sRight[i] {
+ return false
+ }
+ }
+ return true
+}
diff --git a/vendor/github.com/coreos/etcd/client/client_test.go b/vendor/github.com/coreos/etcd/client/client_test.go
new file mode 100644
index 00000000..4ab54d88
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/client_test.go
@@ -0,0 +1,1053 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client
+
+import (
+ "errors"
+ "io"
+ "io/ioutil"
+ "math/rand"
+ "net/http"
+ "net/url"
+ "reflect"
+ "sort"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/version"
+ "golang.org/x/net/context"
+)
+
+type actionAssertingHTTPClient struct {
+ t *testing.T
+ num int
+ act httpAction
+
+ resp http.Response
+ body []byte
+ err error
+}
+
+func (a *actionAssertingHTTPClient) Do(_ context.Context, act httpAction) (*http.Response, []byte, error) {
+ if !reflect.DeepEqual(a.act, act) {
+ a.t.Errorf("#%d: unexpected httpAction: want=%#v got=%#v", a.num, a.act, act)
+ }
+
+ return &a.resp, a.body, a.err
+}
+
+type staticHTTPClient struct {
+ resp http.Response
+ body []byte
+ err error
+}
+
+func (s *staticHTTPClient) Do(context.Context, httpAction) (*http.Response, []byte, error) {
+ return &s.resp, s.body, s.err
+}
+
+type staticHTTPAction struct {
+ request http.Request
+}
+
+func (s *staticHTTPAction) HTTPRequest(url.URL) *http.Request {
+ return &s.request
+}
+
+type staticHTTPResponse struct {
+ resp http.Response
+ body []byte
+ err error
+}
+
+type multiStaticHTTPClient struct {
+ responses []staticHTTPResponse
+ cur int
+}
+
+func (s *multiStaticHTTPClient) Do(context.Context, httpAction) (*http.Response, []byte, error) {
+ r := s.responses[s.cur]
+ s.cur++
+ return &r.resp, r.body, r.err
+}
+
+func newStaticHTTPClientFactory(responses []staticHTTPResponse) httpClientFactory {
+ var cur int
+ return func(url.URL) httpClient {
+ r := responses[cur]
+ cur++
+ return &staticHTTPClient{resp: r.resp, body: r.body, err: r.err}
+ }
+}
+
+type fakeTransport struct {
+ respchan chan *http.Response
+ errchan chan error
+ startCancel chan struct{}
+ finishCancel chan struct{}
+}
+
+func newFakeTransport() *fakeTransport {
+ return &fakeTransport{
+ respchan: make(chan *http.Response, 1),
+ errchan: make(chan error, 1),
+ startCancel: make(chan struct{}, 1),
+ finishCancel: make(chan struct{}, 1),
+ }
+}
+
+func (t *fakeTransport) CancelRequest(*http.Request) {
+ t.startCancel <- struct{}{}
+}
+
+type fakeAction struct{}
+
+func (a *fakeAction) HTTPRequest(url.URL) *http.Request {
+ return &http.Request{}
+}
+
+func TestSimpleHTTPClientDoSuccess(t *testing.T) {
+ tr := newFakeTransport()
+ c := &simpleHTTPClient{transport: tr}
+
+ tr.respchan <- &http.Response{
+ StatusCode: http.StatusTeapot,
+ Body: ioutil.NopCloser(strings.NewReader("foo")),
+ }
+
+ resp, body, err := c.Do(context.Background(), &fakeAction{})
+ if err != nil {
+ t.Fatalf("incorrect error value: want=nil got=%v", err)
+ }
+
+ wantCode := http.StatusTeapot
+ if wantCode != resp.StatusCode {
+ t.Fatalf("invalid response code: want=%d got=%d", wantCode, resp.StatusCode)
+ }
+
+ wantBody := []byte("foo")
+ if !reflect.DeepEqual(wantBody, body) {
+ t.Fatalf("invalid response body: want=%q got=%q", wantBody, body)
+ }
+}
+
+func TestSimpleHTTPClientDoError(t *testing.T) {
+ tr := newFakeTransport()
+ c := &simpleHTTPClient{transport: tr}
+
+ tr.errchan <- errors.New("fixture")
+
+ _, _, err := c.Do(context.Background(), &fakeAction{})
+ if err == nil {
+ t.Fatalf("expected non-nil error, got nil")
+ }
+}
+
+func TestSimpleHTTPClientDoCancelContext(t *testing.T) {
+ tr := newFakeTransport()
+ c := &simpleHTTPClient{transport: tr}
+
+ tr.startCancel <- struct{}{}
+ tr.finishCancel <- struct{}{}
+
+ _, _, err := c.Do(context.Background(), &fakeAction{})
+ if err == nil {
+ t.Fatalf("expected non-nil error, got nil")
+ }
+}
+
+type checkableReadCloser struct {
+ io.ReadCloser
+ closed bool
+}
+
+func (c *checkableReadCloser) Close() error {
+ if !c.closed {
+ c.closed = true
+ return c.ReadCloser.Close()
+ }
+ return nil
+}
+
+func TestSimpleHTTPClientDoCancelContextResponseBodyClosed(t *testing.T) {
+ tr := newFakeTransport()
+ c := &simpleHTTPClient{transport: tr}
+
+ // create an already-cancelled context
+ ctx, cancel := context.WithCancel(context.Background())
+ cancel()
+
+ body := &checkableReadCloser{ReadCloser: ioutil.NopCloser(strings.NewReader("foo"))}
+ go func() {
+ // wait that simpleHTTPClient knows the context is already timed out,
+ // and calls CancelRequest
+ testutil.WaitSchedule()
+
+ // response is returned before cancel effects
+ tr.respchan <- &http.Response{Body: body}
+ }()
+
+ _, _, err := c.Do(ctx, &fakeAction{})
+ if err == nil {
+ t.Fatalf("expected non-nil error, got nil")
+ }
+
+ if !body.closed {
+ t.Fatalf("expected closed body")
+ }
+}
+
+type blockingBody struct {
+ c chan struct{}
+}
+
+func (bb *blockingBody) Read(p []byte) (n int, err error) {
+ <-bb.c
+ return 0, errors.New("closed")
+}
+
+func (bb *blockingBody) Close() error {
+ close(bb.c)
+ return nil
+}
+
+func TestSimpleHTTPClientDoCancelContextResponseBodyClosedWithBlockingBody(t *testing.T) {
+ tr := newFakeTransport()
+ c := &simpleHTTPClient{transport: tr}
+
+ ctx, cancel := context.WithCancel(context.Background())
+ body := &checkableReadCloser{ReadCloser: &blockingBody{c: make(chan struct{})}}
+ go func() {
+ tr.respchan <- &http.Response{Body: body}
+ time.Sleep(2 * time.Millisecond)
+ // cancel after the body is received
+ cancel()
+ }()
+
+ _, _, err := c.Do(ctx, &fakeAction{})
+ if err != context.Canceled {
+ t.Fatalf("expected %+v, got %+v", context.Canceled, err)
+ }
+
+ if !body.closed {
+ t.Fatalf("expected closed body")
+ }
+}
+
+func TestSimpleHTTPClientDoCancelContextWaitForRoundTrip(t *testing.T) {
+ tr := newFakeTransport()
+ c := &simpleHTTPClient{transport: tr}
+
+ donechan := make(chan struct{})
+ ctx, cancel := context.WithCancel(context.Background())
+ go func() {
+ c.Do(ctx, &fakeAction{})
+ close(donechan)
+ }()
+
+ // This should call CancelRequest and begin the cancellation process
+ cancel()
+
+ select {
+ case <-donechan:
+ t.Fatalf("simpleHTTPClient.Do should not have exited yet")
+ default:
+ }
+
+ tr.finishCancel <- struct{}{}
+
+ select {
+ case <-donechan:
+ //expected behavior
+ return
+ case <-time.After(time.Second):
+ t.Fatalf("simpleHTTPClient.Do did not exit within 1s")
+ }
+}
+
+func TestSimpleHTTPClientDoHeaderTimeout(t *testing.T) {
+ tr := newFakeTransport()
+ tr.finishCancel <- struct{}{}
+ c := &simpleHTTPClient{transport: tr, headerTimeout: time.Millisecond}
+
+ errc := make(chan error)
+ go func() {
+ _, _, err := c.Do(context.Background(), &fakeAction{})
+ errc <- err
+ }()
+
+ select {
+ case err := <-errc:
+ if err == nil {
+ t.Fatalf("expected non-nil error, got nil")
+ }
+ case <-time.After(time.Second):
+ t.Fatalf("unexpected timeout when waiting for the test to finish")
+ }
+}
+
+func TestHTTPClusterClientDo(t *testing.T) {
+ fakeErr := errors.New("fake!")
+ fakeURL := url.URL{}
+ tests := []struct {
+ client *httpClusterClient
+ wantCode int
+ wantErr error
+ wantPinned int
+ }{
+ // first good response short-circuits Do
+ {
+ client: &httpClusterClient{
+ endpoints: []url.URL{fakeURL, fakeURL},
+ clientFactory: newStaticHTTPClientFactory(
+ []staticHTTPResponse{
+ {resp: http.Response{StatusCode: http.StatusTeapot}},
+ {err: fakeErr},
+ },
+ ),
+ rand: rand.New(rand.NewSource(0)),
+ },
+ wantCode: http.StatusTeapot,
+ },
+
+ // fall through to good endpoint if err is arbitrary
+ {
+ client: &httpClusterClient{
+ endpoints: []url.URL{fakeURL, fakeURL},
+ clientFactory: newStaticHTTPClientFactory(
+ []staticHTTPResponse{
+ {err: fakeErr},
+ {resp: http.Response{StatusCode: http.StatusTeapot}},
+ },
+ ),
+ rand: rand.New(rand.NewSource(0)),
+ },
+ wantCode: http.StatusTeapot,
+ wantPinned: 1,
+ },
+
+ // context.Canceled short-circuits Do
+ {
+ client: &httpClusterClient{
+ endpoints: []url.URL{fakeURL, fakeURL},
+ clientFactory: newStaticHTTPClientFactory(
+ []staticHTTPResponse{
+ {err: context.Canceled},
+ {resp: http.Response{StatusCode: http.StatusTeapot}},
+ },
+ ),
+ rand: rand.New(rand.NewSource(0)),
+ },
+ wantErr: context.Canceled,
+ },
+
+ // return err if there are no endpoints
+ {
+ client: &httpClusterClient{
+ endpoints: []url.URL{},
+ clientFactory: newHTTPClientFactory(nil, nil, 0),
+ rand: rand.New(rand.NewSource(0)),
+ },
+ wantErr: ErrNoEndpoints,
+ },
+
+ // return err if all endpoints return arbitrary errors
+ {
+ client: &httpClusterClient{
+ endpoints: []url.URL{fakeURL, fakeURL},
+ clientFactory: newStaticHTTPClientFactory(
+ []staticHTTPResponse{
+ {err: fakeErr},
+ {err: fakeErr},
+ },
+ ),
+ rand: rand.New(rand.NewSource(0)),
+ },
+ wantErr: &ClusterError{Errors: []error{fakeErr, fakeErr}},
+ },
+
+ // 500-level errors cause Do to fallthrough to next endpoint
+ {
+ client: &httpClusterClient{
+ endpoints: []url.URL{fakeURL, fakeURL},
+ clientFactory: newStaticHTTPClientFactory(
+ []staticHTTPResponse{
+ {resp: http.Response{StatusCode: http.StatusBadGateway}},
+ {resp: http.Response{StatusCode: http.StatusTeapot}},
+ },
+ ),
+ rand: rand.New(rand.NewSource(0)),
+ },
+ wantCode: http.StatusTeapot,
+ wantPinned: 1,
+ },
+ }
+
+ for i, tt := range tests {
+ resp, _, err := tt.client.Do(context.Background(), nil)
+ if !reflect.DeepEqual(tt.wantErr, err) {
+ t.Errorf("#%d: got err=%v, want=%v", i, err, tt.wantErr)
+ continue
+ }
+
+ if resp == nil {
+ if tt.wantCode != 0 {
+ t.Errorf("#%d: resp is nil, want=%d", i, tt.wantCode)
+ }
+ continue
+ }
+
+ if resp.StatusCode != tt.wantCode {
+ t.Errorf("#%d: resp code=%d, want=%d", i, resp.StatusCode, tt.wantCode)
+ continue
+ }
+
+ if tt.client.pinned != tt.wantPinned {
+ t.Errorf("#%d: pinned=%d, want=%d", i, tt.client.pinned, tt.wantPinned)
+ }
+ }
+}
+
+func TestHTTPClusterClientDoDeadlineExceedContext(t *testing.T) {
+ fakeURL := url.URL{}
+ tr := newFakeTransport()
+ tr.finishCancel <- struct{}{}
+ c := &httpClusterClient{
+ clientFactory: newHTTPClientFactory(tr, DefaultCheckRedirect, 0),
+ endpoints: []url.URL{fakeURL},
+ }
+
+ errc := make(chan error)
+ go func() {
+ ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)
+ defer cancel()
+ _, _, err := c.Do(ctx, &fakeAction{})
+ errc <- err
+ }()
+
+ select {
+ case err := <-errc:
+ if err != context.DeadlineExceeded {
+ t.Errorf("err = %+v, want %+v", err, context.DeadlineExceeded)
+ }
+ case <-time.After(time.Second):
+ t.Fatalf("unexpected timeout when waiting for request to deadline exceed")
+ }
+}
+
+type fakeCancelContext struct{}
+
+var fakeCancelContextError = errors.New("fake context canceled")
+
+func (f fakeCancelContext) Deadline() (time.Time, bool) { return time.Time{}, false }
+func (f fakeCancelContext) Done() <-chan struct{} {
+ d := make(chan struct{}, 1)
+ d <- struct{}{}
+ return d
+}
+func (f fakeCancelContext) Err() error { return fakeCancelContextError }
+func (f fakeCancelContext) Value(key interface{}) interface{} { return 1 }
+
+func withTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc) {
+ return parent, func() { parent = nil }
+}
+
+func TestHTTPClusterClientDoCanceledContext(t *testing.T) {
+ fakeURL := url.URL{}
+ tr := newFakeTransport()
+ tr.finishCancel <- struct{}{}
+ c := &httpClusterClient{
+ clientFactory: newHTTPClientFactory(tr, DefaultCheckRedirect, 0),
+ endpoints: []url.URL{fakeURL},
+ }
+
+ errc := make(chan error)
+ go func() {
+ ctx, cancel := withTimeout(fakeCancelContext{}, time.Millisecond)
+ cancel()
+ _, _, err := c.Do(ctx, &fakeAction{})
+ errc <- err
+ }()
+
+ select {
+ case err := <-errc:
+ if err != fakeCancelContextError {
+ t.Errorf("err = %+v, want %+v", err, fakeCancelContextError)
+ }
+ case <-time.After(time.Second):
+ t.Fatalf("unexpected timeout when waiting for request to fake context canceled")
+ }
+}
+
+func TestRedirectedHTTPAction(t *testing.T) {
+ act := &redirectedHTTPAction{
+ action: &staticHTTPAction{
+ request: http.Request{
+ Method: "DELETE",
+ URL: &url.URL{
+ Scheme: "https",
+ Host: "foo.example.com",
+ Path: "/ping",
+ },
+ },
+ },
+ location: url.URL{
+ Scheme: "https",
+ Host: "bar.example.com",
+ Path: "/pong",
+ },
+ }
+
+ want := &http.Request{
+ Method: "DELETE",
+ URL: &url.URL{
+ Scheme: "https",
+ Host: "bar.example.com",
+ Path: "/pong",
+ },
+ }
+ got := act.HTTPRequest(url.URL{Scheme: "http", Host: "baz.example.com", Path: "/pang"})
+
+ if !reflect.DeepEqual(want, got) {
+ t.Fatalf("HTTPRequest is %#v, want %#v", want, got)
+ }
+}
+
+func TestRedirectFollowingHTTPClient(t *testing.T) {
+ tests := []struct {
+ checkRedirect CheckRedirectFunc
+ client httpClient
+ wantCode int
+ wantErr error
+ }{
+ // errors bubbled up
+ {
+ checkRedirect: func(int) error { return ErrTooManyRedirects },
+ client: &multiStaticHTTPClient{
+ responses: []staticHTTPResponse{
+ {
+ err: errors.New("fail!"),
+ },
+ },
+ },
+ wantErr: errors.New("fail!"),
+ },
+
+ // no need to follow redirect if none given
+ {
+ checkRedirect: func(int) error { return ErrTooManyRedirects },
+ client: &multiStaticHTTPClient{
+ responses: []staticHTTPResponse{
+ {
+ resp: http.Response{
+ StatusCode: http.StatusTeapot,
+ },
+ },
+ },
+ },
+ wantCode: http.StatusTeapot,
+ },
+
+ // redirects if less than max
+ {
+ checkRedirect: func(via int) error {
+ if via >= 2 {
+ return ErrTooManyRedirects
+ }
+ return nil
+ },
+ client: &multiStaticHTTPClient{
+ responses: []staticHTTPResponse{
+ {
+ resp: http.Response{
+ StatusCode: http.StatusTemporaryRedirect,
+ Header: http.Header{"Location": []string{"http://example.com"}},
+ },
+ },
+ {
+ resp: http.Response{
+ StatusCode: http.StatusTeapot,
+ },
+ },
+ },
+ },
+ wantCode: http.StatusTeapot,
+ },
+
+ // succeed after reaching max redirects
+ {
+ checkRedirect: func(via int) error {
+ if via >= 3 {
+ return ErrTooManyRedirects
+ }
+ return nil
+ },
+ client: &multiStaticHTTPClient{
+ responses: []staticHTTPResponse{
+ {
+ resp: http.Response{
+ StatusCode: http.StatusTemporaryRedirect,
+ Header: http.Header{"Location": []string{"http://example.com"}},
+ },
+ },
+ {
+ resp: http.Response{
+ StatusCode: http.StatusTemporaryRedirect,
+ Header: http.Header{"Location": []string{"http://example.com"}},
+ },
+ },
+ {
+ resp: http.Response{
+ StatusCode: http.StatusTeapot,
+ },
+ },
+ },
+ },
+ wantCode: http.StatusTeapot,
+ },
+
+ // fail if too many redirects
+ {
+ checkRedirect: func(via int) error {
+ if via >= 2 {
+ return ErrTooManyRedirects
+ }
+ return nil
+ },
+ client: &multiStaticHTTPClient{
+ responses: []staticHTTPResponse{
+ {
+ resp: http.Response{
+ StatusCode: http.StatusTemporaryRedirect,
+ Header: http.Header{"Location": []string{"http://example.com"}},
+ },
+ },
+ {
+ resp: http.Response{
+ StatusCode: http.StatusTemporaryRedirect,
+ Header: http.Header{"Location": []string{"http://example.com"}},
+ },
+ },
+ {
+ resp: http.Response{
+ StatusCode: http.StatusTeapot,
+ },
+ },
+ },
+ },
+ wantErr: ErrTooManyRedirects,
+ },
+
+ // fail if Location header not set
+ {
+ checkRedirect: func(int) error { return ErrTooManyRedirects },
+ client: &multiStaticHTTPClient{
+ responses: []staticHTTPResponse{
+ {
+ resp: http.Response{
+ StatusCode: http.StatusTemporaryRedirect,
+ },
+ },
+ },
+ },
+ wantErr: errors.New("Location header not set"),
+ },
+
+ // fail if Location header is invalid
+ {
+ checkRedirect: func(int) error { return ErrTooManyRedirects },
+ client: &multiStaticHTTPClient{
+ responses: []staticHTTPResponse{
+ {
+ resp: http.Response{
+ StatusCode: http.StatusTemporaryRedirect,
+ Header: http.Header{"Location": []string{":"}},
+ },
+ },
+ },
+ },
+ wantErr: errors.New("Location header not valid URL: :"),
+ },
+
+ // fail if redirects checked way too many times
+ {
+ checkRedirect: func(int) error { return nil },
+ client: &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusTemporaryRedirect,
+ Header: http.Header{"Location": []string{"http://example.com"}},
+ },
+ },
+ wantErr: errTooManyRedirectChecks,
+ },
+ }
+
+ for i, tt := range tests {
+ client := &redirectFollowingHTTPClient{client: tt.client, checkRedirect: tt.checkRedirect}
+ resp, _, err := client.Do(context.Background(), nil)
+ if !reflect.DeepEqual(tt.wantErr, err) {
+ t.Errorf("#%d: got err=%v, want=%v", i, err, tt.wantErr)
+ continue
+ }
+
+ if resp == nil {
+ if tt.wantCode != 0 {
+ t.Errorf("#%d: resp is nil, want=%d", i, tt.wantCode)
+ }
+ continue
+ }
+
+ if resp.StatusCode != tt.wantCode {
+ t.Errorf("#%d: resp code=%d, want=%d", i, resp.StatusCode, tt.wantCode)
+ continue
+ }
+ }
+}
+
+func TestDefaultCheckRedirect(t *testing.T) {
+ tests := []struct {
+ num int
+ err error
+ }{
+ {0, nil},
+ {5, nil},
+ {10, nil},
+ {11, ErrTooManyRedirects},
+ {29, ErrTooManyRedirects},
+ }
+
+ for i, tt := range tests {
+ err := DefaultCheckRedirect(tt.num)
+ if !reflect.DeepEqual(tt.err, err) {
+ t.Errorf("#%d: want=%#v got=%#v", i, tt.err, err)
+ }
+ }
+}
+
+func TestHTTPClusterClientSync(t *testing.T) {
+ cf := newStaticHTTPClientFactory([]staticHTTPResponse{
+ {
+ resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
+ body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
+ },
+ })
+
+ hc := &httpClusterClient{
+ clientFactory: cf,
+ rand: rand.New(rand.NewSource(0)),
+ }
+ err := hc.SetEndpoints([]string{"http://127.0.0.1:2379"})
+ if err != nil {
+ t.Fatalf("unexpected error during setup: %#v", err)
+ }
+
+ want := []string{"http://127.0.0.1:2379"}
+ got := hc.Endpoints()
+ if !reflect.DeepEqual(want, got) {
+ t.Fatalf("incorrect endpoints: want=%#v got=%#v", want, got)
+ }
+
+ err = hc.Sync(context.Background())
+ if err != nil {
+ t.Fatalf("unexpected error during Sync: %#v", err)
+ }
+
+ want = []string{"http://127.0.0.1:2379", "http://127.0.0.1:4001", "http://127.0.0.1:4002", "http://127.0.0.1:4003"}
+ got = hc.Endpoints()
+ sort.Sort(sort.StringSlice(got))
+ if !reflect.DeepEqual(want, got) {
+ t.Fatalf("incorrect endpoints post-Sync: want=%#v got=%#v", want, got)
+ }
+
+ err = hc.SetEndpoints([]string{"http://127.0.0.1:4009"})
+ if err != nil {
+ t.Fatalf("unexpected error during reset: %#v", err)
+ }
+
+ want = []string{"http://127.0.0.1:4009"}
+ got = hc.Endpoints()
+ if !reflect.DeepEqual(want, got) {
+ t.Fatalf("incorrect endpoints post-reset: want=%#v got=%#v", want, got)
+ }
+}
+
+func TestHTTPClusterClientSyncFail(t *testing.T) {
+ cf := newStaticHTTPClientFactory([]staticHTTPResponse{
+ {err: errors.New("fail!")},
+ })
+
+ hc := &httpClusterClient{
+ clientFactory: cf,
+ rand: rand.New(rand.NewSource(0)),
+ }
+ err := hc.SetEndpoints([]string{"http://127.0.0.1:2379"})
+ if err != nil {
+ t.Fatalf("unexpected error during setup: %#v", err)
+ }
+
+ want := []string{"http://127.0.0.1:2379"}
+ got := hc.Endpoints()
+ if !reflect.DeepEqual(want, got) {
+ t.Fatalf("incorrect endpoints: want=%#v got=%#v", want, got)
+ }
+
+ err = hc.Sync(context.Background())
+ if err == nil {
+ t.Fatalf("got nil error during Sync")
+ }
+
+ got = hc.Endpoints()
+ if !reflect.DeepEqual(want, got) {
+ t.Fatalf("incorrect endpoints after failed Sync: want=%#v got=%#v", want, got)
+ }
+}
+
+func TestHTTPClusterClientAutoSyncCancelContext(t *testing.T) {
+ cf := newStaticHTTPClientFactory([]staticHTTPResponse{
+ {
+ resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
+ body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
+ },
+ })
+
+ hc := &httpClusterClient{
+ clientFactory: cf,
+ rand: rand.New(rand.NewSource(0)),
+ }
+ err := hc.SetEndpoints([]string{"http://127.0.0.1:2379"})
+ if err != nil {
+ t.Fatalf("unexpected error during setup: %#v", err)
+ }
+ ctx, cancel := context.WithCancel(context.Background())
+ cancel()
+
+ err = hc.AutoSync(ctx, time.Hour)
+ if err != context.Canceled {
+ t.Fatalf("incorrect error value: want=%v got=%v", context.Canceled, err)
+ }
+}
+
+func TestHTTPClusterClientAutoSyncFail(t *testing.T) {
+ cf := newStaticHTTPClientFactory([]staticHTTPResponse{
+ {err: errors.New("fail!")},
+ })
+
+ hc := &httpClusterClient{
+ clientFactory: cf,
+ rand: rand.New(rand.NewSource(0)),
+ }
+ err := hc.SetEndpoints([]string{"http://127.0.0.1:2379"})
+ if err != nil {
+ t.Fatalf("unexpected error during setup: %#v", err)
+ }
+
+ err = hc.AutoSync(context.Background(), time.Hour)
+ if !strings.HasPrefix(err.Error(), ErrClusterUnavailable.Error()) {
+ t.Fatalf("incorrect error value: want=%v got=%v", ErrClusterUnavailable, err)
+ }
+}
+
+func TestHTTPClusterClientGetVersion(t *testing.T) {
+ body := []byte(`{"etcdserver":"2.3.2","etcdcluster":"2.3.0"}`)
+ cf := newStaticHTTPClientFactory([]staticHTTPResponse{
+ {
+ resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Length": []string{"44"}}},
+ body: body,
+ },
+ })
+
+ hc := &httpClusterClient{
+ clientFactory: cf,
+ rand: rand.New(rand.NewSource(0)),
+ }
+ err := hc.SetEndpoints([]string{"http://127.0.0.1:4003", "http://127.0.0.1:2379", "http://127.0.0.1:4001", "http://127.0.0.1:4002"})
+ if err != nil {
+ t.Fatalf("unexpected error during setup: %#v", err)
+ }
+
+ actual, err := hc.GetVersion(context.Background())
+ if err != nil {
+ t.Errorf("non-nil error: %#v", err)
+ }
+ expected := version.Versions{Server: "2.3.2", Cluster: "2.3.0"}
+ if !reflect.DeepEqual(&expected, actual) {
+ t.Errorf("incorrect Response: want=%#v got=%#v", expected, actual)
+ }
+}
+
+// TestHTTPClusterClientSyncPinEndpoint tests that Sync() pins the endpoint when
+// it gets the exactly same member list as before.
+func TestHTTPClusterClientSyncPinEndpoint(t *testing.T) {
+ cf := newStaticHTTPClientFactory([]staticHTTPResponse{
+ {
+ resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
+ body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
+ },
+ {
+ resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
+ body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
+ },
+ {
+ resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
+ body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
+ },
+ })
+
+ hc := &httpClusterClient{
+ clientFactory: cf,
+ rand: rand.New(rand.NewSource(0)),
+ }
+ err := hc.SetEndpoints([]string{"http://127.0.0.1:4003", "http://127.0.0.1:2379", "http://127.0.0.1:4001", "http://127.0.0.1:4002"})
+ if err != nil {
+ t.Fatalf("unexpected error during setup: %#v", err)
+ }
+ pinnedEndpoint := hc.endpoints[hc.pinned]
+
+ for i := 0; i < 3; i++ {
+ err = hc.Sync(context.Background())
+ if err != nil {
+ t.Fatalf("#%d: unexpected error during Sync: %#v", i, err)
+ }
+
+ if g := hc.endpoints[hc.pinned]; g != pinnedEndpoint {
+ t.Errorf("#%d: pinned endpoint = %v, want %v", i, g, pinnedEndpoint)
+ }
+ }
+}
+
+// TestHTTPClusterClientSyncUnpinEndpoint tests that Sync() unpins the endpoint when
+// it gets a different member list than before.
+func TestHTTPClusterClientSyncUnpinEndpoint(t *testing.T) {
+ cf := newStaticHTTPClientFactory([]staticHTTPResponse{
+ {
+ resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
+ body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
+ },
+ {
+ resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
+ body: []byte(`{"members":[{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
+ },
+ {
+ resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
+ body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
+ },
+ })
+
+ hc := &httpClusterClient{
+ clientFactory: cf,
+ rand: rand.New(rand.NewSource(0)),
+ }
+ err := hc.SetEndpoints([]string{"http://127.0.0.1:4003", "http://127.0.0.1:2379", "http://127.0.0.1:4001", "http://127.0.0.1:4002"})
+ if err != nil {
+ t.Fatalf("unexpected error during setup: %#v", err)
+ }
+ wants := []string{"http://127.0.0.1:2379", "http://127.0.0.1:4001", "http://127.0.0.1:4002"}
+
+ for i := 0; i < 3; i++ {
+ err = hc.Sync(context.Background())
+ if err != nil {
+ t.Fatalf("#%d: unexpected error during Sync: %#v", i, err)
+ }
+
+ if g := hc.endpoints[hc.pinned]; g.String() != wants[i] {
+ t.Errorf("#%d: pinned endpoint = %v, want %v", i, g, wants[i])
+ }
+ }
+}
+
+// TestHTTPClusterClientSyncPinLeaderEndpoint tests that Sync() pins the leader
+// when the selection mode is EndpointSelectionPrioritizeLeader
+func TestHTTPClusterClientSyncPinLeaderEndpoint(t *testing.T) {
+ cf := newStaticHTTPClientFactory([]staticHTTPResponse{
+ {
+ resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
+ body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
+ },
+ {
+ resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
+ body: []byte(`{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]}`),
+ },
+ {
+ resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
+ body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
+ },
+ {
+ resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
+ body: []byte(`{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}`),
+ },
+ })
+
+ hc := &httpClusterClient{
+ clientFactory: cf,
+ rand: rand.New(rand.NewSource(0)),
+ selectionMode: EndpointSelectionPrioritizeLeader,
+ endpoints: []url.URL{{}}, // Need somewhere to pretend to send to initially
+ }
+
+ wants := []string{"http://127.0.0.1:4003", "http://127.0.0.1:4002"}
+
+ for i, want := range wants {
+ err := hc.Sync(context.Background())
+ if err != nil {
+ t.Fatalf("#%d: unexpected error during Sync: %#v", i, err)
+ }
+
+ pinned := hc.endpoints[hc.pinned].String()
+ if pinned != want {
+ t.Errorf("#%d: pinned endpoint = %v, want %v", i, pinned, want)
+ }
+ }
+}
+
+func TestHTTPClusterClientResetFail(t *testing.T) {
+ tests := [][]string{
+ // need at least one endpoint
+ {},
+
+ // urls must be valid
+ {":"},
+ }
+
+ for i, tt := range tests {
+ hc := &httpClusterClient{rand: rand.New(rand.NewSource(0))}
+ err := hc.SetEndpoints(tt)
+ if err == nil {
+ t.Errorf("#%d: expected non-nil error", i)
+ }
+ }
+}
+
+func TestHTTPClusterClientResetPinRandom(t *testing.T) {
+ round := 2000
+ pinNum := 0
+ for i := 0; i < round; i++ {
+ hc := &httpClusterClient{rand: rand.New(rand.NewSource(int64(i)))}
+ err := hc.SetEndpoints([]string{"http://127.0.0.1:4001", "http://127.0.0.1:4002", "http://127.0.0.1:4003"})
+ if err != nil {
+ t.Fatalf("#%d: reset error (%v)", i, err)
+ }
+ if hc.endpoints[hc.pinned].String() == "http://127.0.0.1:4001" {
+ pinNum++
+ }
+ }
+
+ min := 1.0/3.0 - 0.05
+ max := 1.0/3.0 + 0.05
+ if ratio := float64(pinNum) / float64(round); ratio > max || ratio < min {
+ t.Errorf("pinned ratio = %v, want [%v, %v]", ratio, min, max)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/client/cluster_error.go b/vendor/github.com/coreos/etcd/client/cluster_error.go
new file mode 100644
index 00000000..34618cdb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/cluster_error.go
@@ -0,0 +1,37 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client
+
+import "fmt"
+
+type ClusterError struct {
+ Errors []error
+}
+
+func (ce *ClusterError) Error() string {
+ s := ErrClusterUnavailable.Error()
+ for i, e := range ce.Errors {
+ s += fmt.Sprintf("; error #%d: %s\n", i, e)
+ }
+ return s
+}
+
+func (ce *ClusterError) Detail() string {
+ s := ""
+ for i, e := range ce.Errors {
+ s += fmt.Sprintf("error #%d: %s\n", i, e)
+ }
+ return s
+}
diff --git a/vendor/github.com/coreos/etcd/client/curl.go b/vendor/github.com/coreos/etcd/client/curl.go
new file mode 100644
index 00000000..c8bc9fba
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/curl.go
@@ -0,0 +1,70 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client
+
+import (
+ "bytes"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "os"
+)
+
+var (
+ cURLDebug = false
+)
+
+func EnablecURLDebug() {
+ cURLDebug = true
+}
+
+func DisablecURLDebug() {
+ cURLDebug = false
+}
+
+// printcURL prints the cURL equivalent request to stderr.
+// It returns an error if the body of the request cannot
+// be read.
+// The caller MUST cancel the request if there is an error.
+func printcURL(req *http.Request) error {
+ if !cURLDebug {
+ return nil
+ }
+ var (
+ command string
+ b []byte
+ err error
+ )
+
+ if req.URL != nil {
+ command = fmt.Sprintf("curl -X %s %s", req.Method, req.URL.String())
+ }
+
+ if req.Body != nil {
+ b, err = ioutil.ReadAll(req.Body)
+ if err != nil {
+ return err
+ }
+ command += fmt.Sprintf(" -d %q", string(b))
+ }
+
+ fmt.Fprintf(os.Stderr, "cURL Command: %s\n", command)
+
+ // reset body
+ body := bytes.NewBuffer(b)
+ req.Body = ioutil.NopCloser(body)
+
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/client/discover.go b/vendor/github.com/coreos/etcd/client/discover.go
new file mode 100644
index 00000000..442e35fe
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/discover.go
@@ -0,0 +1,40 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client
+
+import (
+ "github.com/coreos/etcd/pkg/srv"
+)
+
+// Discoverer is an interface that wraps the Discover method.
+type Discoverer interface {
+ // Discover looks up the etcd servers for the domain.
+ Discover(domain string) ([]string, error)
+}
+
+type srvDiscover struct{}
+
+// NewSRVDiscover constructs a new Discoverer that uses the stdlib to lookup SRV records.
+func NewSRVDiscover() Discoverer {
+ return &srvDiscover{}
+}
+
+func (d *srvDiscover) Discover(domain string) ([]string, error) {
+ srvs, err := srv.GetClient("etcd-client", domain)
+ if err != nil {
+ return nil, err
+ }
+ return srvs.Endpoints, nil
+}
diff --git a/vendor/github.com/coreos/etcd/client/doc.go b/vendor/github.com/coreos/etcd/client/doc.go
new file mode 100644
index 00000000..32fdfb52
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/doc.go
@@ -0,0 +1,73 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client provides bindings for the etcd APIs.
+
+Create a Config and exchange it for a Client:
+
+ import (
+ "net/http"
+
+ "github.com/coreos/etcd/client"
+ "golang.org/x/net/context"
+ )
+
+ cfg := client.Config{
+ Endpoints: []string{"http://127.0.0.1:2379"},
+ Transport: DefaultTransport,
+ }
+
+ c, err := client.New(cfg)
+ if err != nil {
+ // handle error
+ }
+
+Clients are safe for concurrent use by multiple goroutines.
+
+Create a KeysAPI using the Client, then use it to interact with etcd:
+
+ kAPI := client.NewKeysAPI(c)
+
+ // create a new key /foo with the value "bar"
+ _, err = kAPI.Create(context.Background(), "/foo", "bar")
+ if err != nil {
+ // handle error
+ }
+
+ // delete the newly created key only if the value is still "bar"
+ _, err = kAPI.Delete(context.Background(), "/foo", &DeleteOptions{PrevValue: "bar"})
+ if err != nil {
+ // handle error
+ }
+
+Use a custom context to set timeouts on your operations:
+
+ import "time"
+
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
+
+ // set a new key, ignoring it's previous state
+ _, err := kAPI.Set(ctx, "/ping", "pong", nil)
+ if err != nil {
+ if err == context.DeadlineExceeded {
+ // request took longer than 5s
+ } else {
+ // handle error
+ }
+ }
+
+*/
+package client
diff --git a/vendor/github.com/coreos/etcd/client/fake_transport_test.go b/vendor/github.com/coreos/etcd/client/fake_transport_test.go
new file mode 100644
index 00000000..7a725c17
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/fake_transport_test.go
@@ -0,0 +1,40 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client
+
+import (
+ "errors"
+ "net/http"
+)
+
+func (t *fakeTransport) RoundTrip(req *http.Request) (*http.Response, error) {
+ select {
+ case resp := <-t.respchan:
+ return resp, nil
+ case err := <-t.errchan:
+ return nil, err
+ case <-t.startCancel:
+ case <-req.Cancel:
+ }
+ select {
+ // this simulates that the request is finished before cancel effects
+ case resp := <-t.respchan:
+ return resp, nil
+ // wait on finishCancel to simulate taking some amount of
+ // time while calling CancelRequest
+ case <-t.finishCancel:
+ return nil, errors.New("cancelled")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/client/integration/client_test.go b/vendor/github.com/coreos/etcd/client/integration/client_test.go
new file mode 100644
index 00000000..490990b6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/integration/client_test.go
@@ -0,0 +1,133 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "strings"
+ "sync/atomic"
+ "testing"
+
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/client"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+// TestV2NoRetryEOF tests destructive api calls won't retry on a disconnection.
+func TestV2NoRetryEOF(t *testing.T) {
+ defer testutil.AfterTest(t)
+ // generate an EOF response; specify address so appears first in sorted ep list
+ lEOF := integration.NewListenerWithAddr(t, fmt.Sprintf("127.0.0.1:%05d", os.Getpid()))
+ defer lEOF.Close()
+ tries := uint32(0)
+ go func() {
+ for {
+ conn, err := lEOF.Accept()
+ if err != nil {
+ return
+ }
+ atomic.AddUint32(&tries, 1)
+ conn.Close()
+ }
+ }()
+ eofURL := integration.UrlScheme + "://" + lEOF.Addr().String()
+ cli := integration.MustNewHTTPClient(t, []string{eofURL, eofURL}, nil)
+ kapi := client.NewKeysAPI(cli)
+ for i, f := range noRetryList(kapi) {
+ startTries := atomic.LoadUint32(&tries)
+ if err := f(); err == nil {
+ t.Errorf("#%d: expected EOF error, got nil", i)
+ }
+ endTries := atomic.LoadUint32(&tries)
+ if startTries+1 != endTries {
+ t.Errorf("#%d: expected 1 try, got %d", i, endTries-startTries)
+ }
+ }
+}
+
+// TestV2NoRetryNoLeader tests destructive api calls won't retry if given an error code.
+func TestV2NoRetryNoLeader(t *testing.T) {
+ defer testutil.AfterTest(t)
+ lHttp := integration.NewListenerWithAddr(t, fmt.Sprintf("127.0.0.1:%05d", os.Getpid()))
+ eh := &errHandler{errCode: http.StatusServiceUnavailable}
+ srv := httptest.NewUnstartedServer(eh)
+ defer lHttp.Close()
+ defer srv.Close()
+ srv.Listener = lHttp
+ go srv.Start()
+ lHttpURL := integration.UrlScheme + "://" + lHttp.Addr().String()
+
+ cli := integration.MustNewHTTPClient(t, []string{lHttpURL, lHttpURL}, nil)
+ kapi := client.NewKeysAPI(cli)
+ // test error code
+ for i, f := range noRetryList(kapi) {
+ reqs := eh.reqs
+ if err := f(); err == nil || !strings.Contains(err.Error(), "no leader") {
+ t.Errorf("#%d: expected \"no leader\", got %v", i, err)
+ }
+ if eh.reqs != reqs+1 {
+ t.Errorf("#%d: expected 1 request, got %d", i, eh.reqs-reqs)
+ }
+ }
+}
+
+// TestV2RetryRefuse tests destructive api calls will retry if a connection is refused.
+func TestV2RetryRefuse(t *testing.T) {
+ defer testutil.AfterTest(t)
+ cl := integration.NewCluster(t, 1)
+ cl.Launch(t)
+ defer cl.Terminate(t)
+ // test connection refused; expect no error failover
+ cli := integration.MustNewHTTPClient(t, []string{integration.UrlScheme + "://refuseconn:123", cl.URL(0)}, nil)
+ kapi := client.NewKeysAPI(cli)
+ if _, err := kapi.Set(context.Background(), "/delkey", "def", nil); err != nil {
+ t.Fatal(err)
+ }
+ for i, f := range noRetryList(kapi) {
+ if err := f(); err != nil {
+ t.Errorf("#%d: unexpected retry failure (%v)", i, err)
+ }
+ }
+}
+
+type errHandler struct {
+ errCode int
+ reqs int
+}
+
+func (eh *errHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
+ req.Body.Close()
+ eh.reqs++
+ w.WriteHeader(eh.errCode)
+}
+
+func noRetryList(kapi client.KeysAPI) []func() error {
+ return []func() error{
+ func() error {
+ opts := &client.SetOptions{PrevExist: client.PrevNoExist}
+ _, err := kapi.Set(context.Background(), "/setkey", "bar", opts)
+ return err
+ },
+ func() error {
+ _, err := kapi.Delete(context.Background(), "/delkey", nil)
+ return err
+ },
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/client/integration/doc.go b/vendor/github.com/coreos/etcd/client/integration/doc.go
new file mode 100644
index 00000000..e9c58d67
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/integration/doc.go
@@ -0,0 +1,17 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration implements tests built upon embedded etcd, focusing on
+// the correctness of the etcd v2 client.
+package integration
diff --git a/vendor/github.com/coreos/etcd/client/integration/main_test.go b/vendor/github.com/coreos/etcd/client/integration/main_test.go
new file mode 100644
index 00000000..2913ce51
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/integration/main_test.go
@@ -0,0 +1,20 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package integration
+
+import (
+ "os"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestMain(m *testing.M) {
+ v := m.Run()
+ if v == 0 && testutil.CheckLeakedGoroutine() {
+ os.Exit(1)
+ }
+ os.Exit(v)
+}
diff --git a/vendor/github.com/coreos/etcd/client/keys.generated.go b/vendor/github.com/coreos/etcd/client/keys.generated.go
new file mode 100644
index 00000000..216139c9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/keys.generated.go
@@ -0,0 +1,1087 @@
+// ************************************************************
+// DO NOT EDIT.
+// THIS FILE IS AUTO-GENERATED BY codecgen.
+// ************************************************************
+
+package client
+
+import (
+ "errors"
+ "fmt"
+ codec1978 "github.com/ugorji/go/codec"
+ "reflect"
+ "runtime"
+ time "time"
+)
+
+const (
+ // ----- content types ----
+ codecSelferC_UTF81819 = 1
+ codecSelferC_RAW1819 = 0
+ // ----- value types used ----
+ codecSelferValueTypeArray1819 = 10
+ codecSelferValueTypeMap1819 = 9
+ // ----- containerStateValues ----
+ codecSelfer_containerMapKey1819 = 2
+ codecSelfer_containerMapValue1819 = 3
+ codecSelfer_containerMapEnd1819 = 4
+ codecSelfer_containerArrayElem1819 = 6
+ codecSelfer_containerArrayEnd1819 = 7
+)
+
+var (
+ codecSelferBitsize1819 = uint8(reflect.TypeOf(uint(0)).Bits())
+ codecSelferOnlyMapOrArrayEncodeToStructErr1819 = errors.New(`only encoded map or array can be decoded into a struct`)
+)
+
+type codecSelfer1819 struct{}
+
+func init() {
+ if codec1978.GenVersion != 5 {
+ _, file, _, _ := runtime.Caller(0)
+ err := fmt.Errorf("codecgen version mismatch: current: %v, need %v. Re-generate file: %v",
+ 5, codec1978.GenVersion, file)
+ panic(err)
+ }
+ if false { // reference the types, but skip this branch at build/run time
+ var v0 time.Time
+ _ = v0
+ }
+}
+
+func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer1819
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ var yyq2 [3]bool
+ _, _, _ = yysep2, yyq2, yy2arr2
+ const yyr2 bool = false
+ var yynn2 int
+ if yyr2 || yy2arr2 {
+ r.EncodeArrayStart(3)
+ } else {
+ yynn2 = 3
+ for _, b := range yyq2 {
+ if b {
+ yynn2++
+ }
+ }
+ r.EncodeMapStart(yynn2)
+ yynn2 = 0
+ }
+ if yyr2 || yy2arr2 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1819)
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF81819, string(x.Action))
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1819)
+ r.EncodeString(codecSelferC_UTF81819, string("action"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1819)
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF81819, string(x.Action))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1819)
+ if x.Node == nil {
+ r.EncodeNil()
+ } else {
+ x.Node.CodecEncodeSelf(e)
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1819)
+ r.EncodeString(codecSelferC_UTF81819, string("node"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1819)
+ if x.Node == nil {
+ r.EncodeNil()
+ } else {
+ x.Node.CodecEncodeSelf(e)
+ }
+ }
+ if yyr2 || yy2arr2 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1819)
+ if x.PrevNode == nil {
+ r.EncodeNil()
+ } else {
+ x.PrevNode.CodecEncodeSelf(e)
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1819)
+ r.EncodeString(codecSelferC_UTF81819, string("prevNode"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1819)
+ if x.PrevNode == nil {
+ r.EncodeNil()
+ } else {
+ x.PrevNode.CodecEncodeSelf(e)
+ }
+ }
+ if yyr2 || yy2arr2 {
+ z.EncSendContainerState(codecSelfer_containerArrayEnd1819)
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapEnd1819)
+ }
+ }
+ }
+}
+
+func (x *Response) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer1819
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap1819 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ z.DecSendContainerState(codecSelfer_containerMapEnd1819)
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray1819 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr1819)
+ }
+ }
+}
+
+func (x *Response) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer1819
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ z.DecSendContainerState(codecSelfer_containerMapKey1819)
+ yys3Slc = r.DecodeBytes(yys3Slc, true, true)
+ yys3 := string(yys3Slc)
+ z.DecSendContainerState(codecSelfer_containerMapValue1819)
+ switch yys3 {
+ case "action":
+ if r.TryDecodeAsNil() {
+ x.Action = ""
+ } else {
+ yyv4 := &x.Action
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else {
+ *((*string)(yyv4)) = r.DecodeString()
+ }
+ }
+ case "node":
+ if r.TryDecodeAsNil() {
+ if x.Node != nil {
+ x.Node = nil
+ }
+ } else {
+ if x.Node == nil {
+ x.Node = new(Node)
+ }
+ x.Node.CodecDecodeSelf(d)
+ }
+ case "prevNode":
+ if r.TryDecodeAsNil() {
+ if x.PrevNode != nil {
+ x.PrevNode = nil
+ }
+ } else {
+ if x.PrevNode == nil {
+ x.PrevNode = new(Node)
+ }
+ x.PrevNode.CodecDecodeSelf(d)
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ z.DecSendContainerState(codecSelfer_containerMapEnd1819)
+}
+
+func (x *Response) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer1819
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj8 int
+ var yyb8 bool
+ var yyhl8 bool = l >= 0
+ yyj8++
+ if yyhl8 {
+ yyb8 = yyj8 > l
+ } else {
+ yyb8 = r.CheckBreak()
+ }
+ if yyb8 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1819)
+ if r.TryDecodeAsNil() {
+ x.Action = ""
+ } else {
+ yyv9 := &x.Action
+ yym10 := z.DecBinary()
+ _ = yym10
+ if false {
+ } else {
+ *((*string)(yyv9)) = r.DecodeString()
+ }
+ }
+ yyj8++
+ if yyhl8 {
+ yyb8 = yyj8 > l
+ } else {
+ yyb8 = r.CheckBreak()
+ }
+ if yyb8 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1819)
+ if r.TryDecodeAsNil() {
+ if x.Node != nil {
+ x.Node = nil
+ }
+ } else {
+ if x.Node == nil {
+ x.Node = new(Node)
+ }
+ x.Node.CodecDecodeSelf(d)
+ }
+ yyj8++
+ if yyhl8 {
+ yyb8 = yyj8 > l
+ } else {
+ yyb8 = r.CheckBreak()
+ }
+ if yyb8 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1819)
+ if r.TryDecodeAsNil() {
+ if x.PrevNode != nil {
+ x.PrevNode = nil
+ }
+ } else {
+ if x.PrevNode == nil {
+ x.PrevNode = new(Node)
+ }
+ x.PrevNode.CodecDecodeSelf(d)
+ }
+ for {
+ yyj8++
+ if yyhl8 {
+ yyb8 = yyj8 > l
+ } else {
+ yyb8 = r.CheckBreak()
+ }
+ if yyb8 {
+ break
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1819)
+ z.DecStructFieldNotFound(yyj8-1, "")
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+}
+
+func (x *Node) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer1819
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep2 := !z.EncBinary()
+ yy2arr2 := z.EncBasicHandle().StructToArray
+ var yyq2 [8]bool
+ _, _, _ = yysep2, yyq2, yy2arr2
+ const yyr2 bool = false
+ yyq2[1] = x.Dir != false
+ yyq2[6] = x.Expiration != nil
+ yyq2[7] = x.TTL != 0
+ var yynn2 int
+ if yyr2 || yy2arr2 {
+ r.EncodeArrayStart(8)
+ } else {
+ yynn2 = 5
+ for _, b := range yyq2 {
+ if b {
+ yynn2++
+ }
+ }
+ r.EncodeMapStart(yynn2)
+ yynn2 = 0
+ }
+ if yyr2 || yy2arr2 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1819)
+ yym4 := z.EncBinary()
+ _ = yym4
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF81819, string(x.Key))
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1819)
+ r.EncodeString(codecSelferC_UTF81819, string("key"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1819)
+ yym5 := z.EncBinary()
+ _ = yym5
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF81819, string(x.Key))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1819)
+ if yyq2[1] {
+ yym7 := z.EncBinary()
+ _ = yym7
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Dir))
+ }
+ } else {
+ r.EncodeBool(false)
+ }
+ } else {
+ if yyq2[1] {
+ z.EncSendContainerState(codecSelfer_containerMapKey1819)
+ r.EncodeString(codecSelferC_UTF81819, string("dir"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1819)
+ yym8 := z.EncBinary()
+ _ = yym8
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Dir))
+ }
+ }
+ }
+ if yyr2 || yy2arr2 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1819)
+ yym10 := z.EncBinary()
+ _ = yym10
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF81819, string(x.Value))
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1819)
+ r.EncodeString(codecSelferC_UTF81819, string("value"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1819)
+ yym11 := z.EncBinary()
+ _ = yym11
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF81819, string(x.Value))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1819)
+ if x.Nodes == nil {
+ r.EncodeNil()
+ } else {
+ x.Nodes.CodecEncodeSelf(e)
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1819)
+ r.EncodeString(codecSelferC_UTF81819, string("nodes"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1819)
+ if x.Nodes == nil {
+ r.EncodeNil()
+ } else {
+ x.Nodes.CodecEncodeSelf(e)
+ }
+ }
+ if yyr2 || yy2arr2 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1819)
+ yym16 := z.EncBinary()
+ _ = yym16
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.CreatedIndex))
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1819)
+ r.EncodeString(codecSelferC_UTF81819, string("createdIndex"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1819)
+ yym17 := z.EncBinary()
+ _ = yym17
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.CreatedIndex))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1819)
+ yym19 := z.EncBinary()
+ _ = yym19
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.ModifiedIndex))
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1819)
+ r.EncodeString(codecSelferC_UTF81819, string("modifiedIndex"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1819)
+ yym20 := z.EncBinary()
+ _ = yym20
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.ModifiedIndex))
+ }
+ }
+ if yyr2 || yy2arr2 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1819)
+ if yyq2[6] {
+ if x.Expiration == nil {
+ r.EncodeNil()
+ } else {
+ yym22 := z.EncBinary()
+ _ = yym22
+ if false {
+ } else if yym23 := z.TimeRtidIfBinc(); yym23 != 0 {
+ r.EncodeBuiltin(yym23, x.Expiration)
+ } else if z.HasExtensions() && z.EncExt(x.Expiration) {
+ } else if yym22 {
+ z.EncBinaryMarshal(x.Expiration)
+ } else if !yym22 && z.IsJSONHandle() {
+ z.EncJSONMarshal(x.Expiration)
+ } else {
+ z.EncFallback(x.Expiration)
+ }
+ }
+ } else {
+ r.EncodeNil()
+ }
+ } else {
+ if yyq2[6] {
+ z.EncSendContainerState(codecSelfer_containerMapKey1819)
+ r.EncodeString(codecSelferC_UTF81819, string("expiration"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1819)
+ if x.Expiration == nil {
+ r.EncodeNil()
+ } else {
+ yym24 := z.EncBinary()
+ _ = yym24
+ if false {
+ } else if yym25 := z.TimeRtidIfBinc(); yym25 != 0 {
+ r.EncodeBuiltin(yym25, x.Expiration)
+ } else if z.HasExtensions() && z.EncExt(x.Expiration) {
+ } else if yym24 {
+ z.EncBinaryMarshal(x.Expiration)
+ } else if !yym24 && z.IsJSONHandle() {
+ z.EncJSONMarshal(x.Expiration)
+ } else {
+ z.EncFallback(x.Expiration)
+ }
+ }
+ }
+ }
+ if yyr2 || yy2arr2 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1819)
+ if yyq2[7] {
+ yym27 := z.EncBinary()
+ _ = yym27
+ if false {
+ } else {
+ r.EncodeInt(int64(x.TTL))
+ }
+ } else {
+ r.EncodeInt(0)
+ }
+ } else {
+ if yyq2[7] {
+ z.EncSendContainerState(codecSelfer_containerMapKey1819)
+ r.EncodeString(codecSelferC_UTF81819, string("ttl"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1819)
+ yym28 := z.EncBinary()
+ _ = yym28
+ if false {
+ } else {
+ r.EncodeInt(int64(x.TTL))
+ }
+ }
+ }
+ if yyr2 || yy2arr2 {
+ z.EncSendContainerState(codecSelfer_containerArrayEnd1819)
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapEnd1819)
+ }
+ }
+ }
+}
+
+func (x *Node) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer1819
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct2 := r.ContainerType()
+ if yyct2 == codecSelferValueTypeMap1819 {
+ yyl2 := r.ReadMapStart()
+ if yyl2 == 0 {
+ z.DecSendContainerState(codecSelfer_containerMapEnd1819)
+ } else {
+ x.codecDecodeSelfFromMap(yyl2, d)
+ }
+ } else if yyct2 == codecSelferValueTypeArray1819 {
+ yyl2 := r.ReadArrayStart()
+ if yyl2 == 0 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+ } else {
+ x.codecDecodeSelfFromArray(yyl2, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr1819)
+ }
+ }
+}
+
+func (x *Node) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer1819
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys3Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys3Slc
+ var yyhl3 bool = l >= 0
+ for yyj3 := 0; ; yyj3++ {
+ if yyhl3 {
+ if yyj3 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ z.DecSendContainerState(codecSelfer_containerMapKey1819)
+ yys3Slc = r.DecodeBytes(yys3Slc, true, true)
+ yys3 := string(yys3Slc)
+ z.DecSendContainerState(codecSelfer_containerMapValue1819)
+ switch yys3 {
+ case "key":
+ if r.TryDecodeAsNil() {
+ x.Key = ""
+ } else {
+ yyv4 := &x.Key
+ yym5 := z.DecBinary()
+ _ = yym5
+ if false {
+ } else {
+ *((*string)(yyv4)) = r.DecodeString()
+ }
+ }
+ case "dir":
+ if r.TryDecodeAsNil() {
+ x.Dir = false
+ } else {
+ yyv6 := &x.Dir
+ yym7 := z.DecBinary()
+ _ = yym7
+ if false {
+ } else {
+ *((*bool)(yyv6)) = r.DecodeBool()
+ }
+ }
+ case "value":
+ if r.TryDecodeAsNil() {
+ x.Value = ""
+ } else {
+ yyv8 := &x.Value
+ yym9 := z.DecBinary()
+ _ = yym9
+ if false {
+ } else {
+ *((*string)(yyv8)) = r.DecodeString()
+ }
+ }
+ case "nodes":
+ if r.TryDecodeAsNil() {
+ x.Nodes = nil
+ } else {
+ yyv10 := &x.Nodes
+ yyv10.CodecDecodeSelf(d)
+ }
+ case "createdIndex":
+ if r.TryDecodeAsNil() {
+ x.CreatedIndex = 0
+ } else {
+ yyv11 := &x.CreatedIndex
+ yym12 := z.DecBinary()
+ _ = yym12
+ if false {
+ } else {
+ *((*uint64)(yyv11)) = uint64(r.DecodeUint(64))
+ }
+ }
+ case "modifiedIndex":
+ if r.TryDecodeAsNil() {
+ x.ModifiedIndex = 0
+ } else {
+ yyv13 := &x.ModifiedIndex
+ yym14 := z.DecBinary()
+ _ = yym14
+ if false {
+ } else {
+ *((*uint64)(yyv13)) = uint64(r.DecodeUint(64))
+ }
+ }
+ case "expiration":
+ if r.TryDecodeAsNil() {
+ if x.Expiration != nil {
+ x.Expiration = nil
+ }
+ } else {
+ if x.Expiration == nil {
+ x.Expiration = new(time.Time)
+ }
+ yym16 := z.DecBinary()
+ _ = yym16
+ if false {
+ } else if yym17 := z.TimeRtidIfBinc(); yym17 != 0 {
+ r.DecodeBuiltin(yym17, x.Expiration)
+ } else if z.HasExtensions() && z.DecExt(x.Expiration) {
+ } else if yym16 {
+ z.DecBinaryUnmarshal(x.Expiration)
+ } else if !yym16 && z.IsJSONHandle() {
+ z.DecJSONUnmarshal(x.Expiration)
+ } else {
+ z.DecFallback(x.Expiration, false)
+ }
+ }
+ case "ttl":
+ if r.TryDecodeAsNil() {
+ x.TTL = 0
+ } else {
+ yyv18 := &x.TTL
+ yym19 := z.DecBinary()
+ _ = yym19
+ if false {
+ } else {
+ *((*int64)(yyv18)) = int64(r.DecodeInt(64))
+ }
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys3)
+ } // end switch yys3
+ } // end for yyj3
+ z.DecSendContainerState(codecSelfer_containerMapEnd1819)
+}
+
+func (x *Node) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer1819
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj20 int
+ var yyb20 bool
+ var yyhl20 bool = l >= 0
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1819)
+ if r.TryDecodeAsNil() {
+ x.Key = ""
+ } else {
+ yyv21 := &x.Key
+ yym22 := z.DecBinary()
+ _ = yym22
+ if false {
+ } else {
+ *((*string)(yyv21)) = r.DecodeString()
+ }
+ }
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1819)
+ if r.TryDecodeAsNil() {
+ x.Dir = false
+ } else {
+ yyv23 := &x.Dir
+ yym24 := z.DecBinary()
+ _ = yym24
+ if false {
+ } else {
+ *((*bool)(yyv23)) = r.DecodeBool()
+ }
+ }
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1819)
+ if r.TryDecodeAsNil() {
+ x.Value = ""
+ } else {
+ yyv25 := &x.Value
+ yym26 := z.DecBinary()
+ _ = yym26
+ if false {
+ } else {
+ *((*string)(yyv25)) = r.DecodeString()
+ }
+ }
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1819)
+ if r.TryDecodeAsNil() {
+ x.Nodes = nil
+ } else {
+ yyv27 := &x.Nodes
+ yyv27.CodecDecodeSelf(d)
+ }
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1819)
+ if r.TryDecodeAsNil() {
+ x.CreatedIndex = 0
+ } else {
+ yyv28 := &x.CreatedIndex
+ yym29 := z.DecBinary()
+ _ = yym29
+ if false {
+ } else {
+ *((*uint64)(yyv28)) = uint64(r.DecodeUint(64))
+ }
+ }
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1819)
+ if r.TryDecodeAsNil() {
+ x.ModifiedIndex = 0
+ } else {
+ yyv30 := &x.ModifiedIndex
+ yym31 := z.DecBinary()
+ _ = yym31
+ if false {
+ } else {
+ *((*uint64)(yyv30)) = uint64(r.DecodeUint(64))
+ }
+ }
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1819)
+ if r.TryDecodeAsNil() {
+ if x.Expiration != nil {
+ x.Expiration = nil
+ }
+ } else {
+ if x.Expiration == nil {
+ x.Expiration = new(time.Time)
+ }
+ yym33 := z.DecBinary()
+ _ = yym33
+ if false {
+ } else if yym34 := z.TimeRtidIfBinc(); yym34 != 0 {
+ r.DecodeBuiltin(yym34, x.Expiration)
+ } else if z.HasExtensions() && z.DecExt(x.Expiration) {
+ } else if yym33 {
+ z.DecBinaryUnmarshal(x.Expiration)
+ } else if !yym33 && z.IsJSONHandle() {
+ z.DecJSONUnmarshal(x.Expiration)
+ } else {
+ z.DecFallback(x.Expiration, false)
+ }
+ }
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1819)
+ if r.TryDecodeAsNil() {
+ x.TTL = 0
+ } else {
+ yyv35 := &x.TTL
+ yym36 := z.DecBinary()
+ _ = yym36
+ if false {
+ } else {
+ *((*int64)(yyv35)) = int64(r.DecodeInt(64))
+ }
+ }
+ for {
+ yyj20++
+ if yyhl20 {
+ yyb20 = yyj20 > l
+ } else {
+ yyb20 = r.CheckBreak()
+ }
+ if yyb20 {
+ break
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1819)
+ z.DecStructFieldNotFound(yyj20-1, "")
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1819)
+}
+
+func (x Nodes) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer1819
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ h.encNodes((Nodes)(x), e)
+ }
+ }
+}
+
+func (x *Nodes) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer1819
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym1 := z.DecBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ h.decNodes((*Nodes)(x), d)
+ }
+}
+
+func (x codecSelfer1819) encNodes(v Nodes, e *codec1978.Encoder) {
+ var h codecSelfer1819
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ r.EncodeArrayStart(len(v))
+ for _, yyv1 := range v {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1819)
+ if yyv1 == nil {
+ r.EncodeNil()
+ } else {
+ yyv1.CodecEncodeSelf(e)
+ }
+ }
+ z.EncSendContainerState(codecSelfer_containerArrayEnd1819)
+}
+
+func (x codecSelfer1819) decNodes(v *Nodes, d *codec1978.Decoder) {
+ var h codecSelfer1819
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+
+ yyv1 := *v
+ yyh1, yyl1 := z.DecSliceHelperStart()
+ var yyc1 bool
+ _ = yyc1
+ if yyl1 == 0 {
+ if yyv1 == nil {
+ yyv1 = []*Node{}
+ yyc1 = true
+ } else if len(yyv1) != 0 {
+ yyv1 = yyv1[:0]
+ yyc1 = true
+ }
+ } else if yyl1 > 0 {
+ var yyrr1, yyrl1 int
+ var yyrt1 bool
+ _, _ = yyrl1, yyrt1
+ yyrr1 = yyl1 // len(yyv1)
+ if yyl1 > cap(yyv1) {
+
+ yyrg1 := len(yyv1) > 0
+ yyv21 := yyv1
+ yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8)
+ if yyrt1 {
+ if yyrl1 <= cap(yyv1) {
+ yyv1 = yyv1[:yyrl1]
+ } else {
+ yyv1 = make([]*Node, yyrl1)
+ }
+ } else {
+ yyv1 = make([]*Node, yyrl1)
+ }
+ yyc1 = true
+ yyrr1 = len(yyv1)
+ if yyrg1 {
+ copy(yyv1, yyv21)
+ }
+ } else if yyl1 != len(yyv1) {
+ yyv1 = yyv1[:yyl1]
+ yyc1 = true
+ }
+ yyj1 := 0
+ for ; yyj1 < yyrr1; yyj1++ {
+ yyh1.ElemContainerState(yyj1)
+ if r.TryDecodeAsNil() {
+ if yyv1[yyj1] != nil {
+ *yyv1[yyj1] = Node{}
+ }
+ } else {
+ if yyv1[yyj1] == nil {
+ yyv1[yyj1] = new(Node)
+ }
+ yyw2 := yyv1[yyj1]
+ yyw2.CodecDecodeSelf(d)
+ }
+
+ }
+ if yyrt1 {
+ for ; yyj1 < yyl1; yyj1++ {
+ yyv1 = append(yyv1, nil)
+ yyh1.ElemContainerState(yyj1)
+ if r.TryDecodeAsNil() {
+ if yyv1[yyj1] != nil {
+ *yyv1[yyj1] = Node{}
+ }
+ } else {
+ if yyv1[yyj1] == nil {
+ yyv1[yyj1] = new(Node)
+ }
+ yyw3 := yyv1[yyj1]
+ yyw3.CodecDecodeSelf(d)
+ }
+
+ }
+ }
+
+ } else {
+ yyj1 := 0
+ for ; !r.CheckBreak(); yyj1++ {
+
+ if yyj1 >= len(yyv1) {
+ yyv1 = append(yyv1, nil) // var yyz1 *Node
+ yyc1 = true
+ }
+ yyh1.ElemContainerState(yyj1)
+ if yyj1 < len(yyv1) {
+ if r.TryDecodeAsNil() {
+ if yyv1[yyj1] != nil {
+ *yyv1[yyj1] = Node{}
+ }
+ } else {
+ if yyv1[yyj1] == nil {
+ yyv1[yyj1] = new(Node)
+ }
+ yyw4 := yyv1[yyj1]
+ yyw4.CodecDecodeSelf(d)
+ }
+
+ } else {
+ z.DecSwallow()
+ }
+
+ }
+ if yyj1 < len(yyv1) {
+ yyv1 = yyv1[:yyj1]
+ yyc1 = true
+ } else if yyj1 == 0 && yyv1 == nil {
+ yyv1 = []*Node{}
+ yyc1 = true
+ }
+ }
+ yyh1.End()
+ if yyc1 {
+ *v = yyv1
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/client/keys.go b/vendor/github.com/coreos/etcd/client/keys.go
new file mode 100644
index 00000000..4a6c41a7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/keys.go
@@ -0,0 +1,682 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client
+
+//go:generate codecgen -d 1819 -r "Node|Response|Nodes" -o keys.generated.go keys.go
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+ "net/http"
+ "net/url"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/coreos/etcd/pkg/pathutil"
+ "github.com/ugorji/go/codec"
+ "golang.org/x/net/context"
+)
+
+const (
+ ErrorCodeKeyNotFound = 100
+ ErrorCodeTestFailed = 101
+ ErrorCodeNotFile = 102
+ ErrorCodeNotDir = 104
+ ErrorCodeNodeExist = 105
+ ErrorCodeRootROnly = 107
+ ErrorCodeDirNotEmpty = 108
+ ErrorCodeUnauthorized = 110
+
+ ErrorCodePrevValueRequired = 201
+ ErrorCodeTTLNaN = 202
+ ErrorCodeIndexNaN = 203
+ ErrorCodeInvalidField = 209
+ ErrorCodeInvalidForm = 210
+
+ ErrorCodeRaftInternal = 300
+ ErrorCodeLeaderElect = 301
+
+ ErrorCodeWatcherCleared = 400
+ ErrorCodeEventIndexCleared = 401
+)
+
+type Error struct {
+ Code int `json:"errorCode"`
+ Message string `json:"message"`
+ Cause string `json:"cause"`
+ Index uint64 `json:"index"`
+}
+
+func (e Error) Error() string {
+ return fmt.Sprintf("%v: %v (%v) [%v]", e.Code, e.Message, e.Cause, e.Index)
+}
+
+var (
+ ErrInvalidJSON = errors.New("client: response is invalid json. The endpoint is probably not valid etcd cluster endpoint.")
+ ErrEmptyBody = errors.New("client: response body is empty")
+)
+
+// PrevExistType is used to define an existence condition when setting
+// or deleting Nodes.
+type PrevExistType string
+
+const (
+ PrevIgnore = PrevExistType("")
+ PrevExist = PrevExistType("true")
+ PrevNoExist = PrevExistType("false")
+)
+
+var (
+ defaultV2KeysPrefix = "/v2/keys"
+)
+
+// NewKeysAPI builds a KeysAPI that interacts with etcd's key-value
+// API over HTTP.
+func NewKeysAPI(c Client) KeysAPI {
+ return NewKeysAPIWithPrefix(c, defaultV2KeysPrefix)
+}
+
+// NewKeysAPIWithPrefix acts like NewKeysAPI, but allows the caller
+// to provide a custom base URL path. This should only be used in
+// very rare cases.
+func NewKeysAPIWithPrefix(c Client, p string) KeysAPI {
+ return &httpKeysAPI{
+ client: c,
+ prefix: p,
+ }
+}
+
+type KeysAPI interface {
+ // Get retrieves a set of Nodes from etcd
+ Get(ctx context.Context, key string, opts *GetOptions) (*Response, error)
+
+ // Set assigns a new value to a Node identified by a given key. The caller
+ // may define a set of conditions in the SetOptions. If SetOptions.Dir=true
+ // then value is ignored.
+ Set(ctx context.Context, key, value string, opts *SetOptions) (*Response, error)
+
+ // Delete removes a Node identified by the given key, optionally destroying
+ // all of its children as well. The caller may define a set of required
+ // conditions in an DeleteOptions object.
+ Delete(ctx context.Context, key string, opts *DeleteOptions) (*Response, error)
+
+ // Create is an alias for Set w/ PrevExist=false
+ Create(ctx context.Context, key, value string) (*Response, error)
+
+ // CreateInOrder is used to atomically create in-order keys within the given directory.
+ CreateInOrder(ctx context.Context, dir, value string, opts *CreateInOrderOptions) (*Response, error)
+
+ // Update is an alias for Set w/ PrevExist=true
+ Update(ctx context.Context, key, value string) (*Response, error)
+
+ // Watcher builds a new Watcher targeted at a specific Node identified
+ // by the given key. The Watcher may be configured at creation time
+ // through a WatcherOptions object. The returned Watcher is designed
+ // to emit events that happen to a Node, and optionally to its children.
+ Watcher(key string, opts *WatcherOptions) Watcher
+}
+
+type WatcherOptions struct {
+ // AfterIndex defines the index after-which the Watcher should
+ // start emitting events. For example, if a value of 5 is
+ // provided, the first event will have an index >= 6.
+ //
+ // Setting AfterIndex to 0 (default) means that the Watcher
+ // should start watching for events starting at the current
+ // index, whatever that may be.
+ AfterIndex uint64
+
+ // Recursive specifies whether or not the Watcher should emit
+ // events that occur in children of the given keyspace. If set
+ // to false (default), events will be limited to those that
+ // occur for the exact key.
+ Recursive bool
+}
+
+type CreateInOrderOptions struct {
+ // TTL defines a period of time after-which the Node should
+ // expire and no longer exist. Values <= 0 are ignored. Given
+ // that the zero-value is ignored, TTL cannot be used to set
+ // a TTL of 0.
+ TTL time.Duration
+}
+
+type SetOptions struct {
+ // PrevValue specifies what the current value of the Node must
+ // be in order for the Set operation to succeed.
+ //
+ // Leaving this field empty means that the caller wishes to
+ // ignore the current value of the Node. This cannot be used
+ // to compare the Node's current value to an empty string.
+ //
+ // PrevValue is ignored if Dir=true
+ PrevValue string
+
+ // PrevIndex indicates what the current ModifiedIndex of the
+ // Node must be in order for the Set operation to succeed.
+ //
+ // If PrevIndex is set to 0 (default), no comparison is made.
+ PrevIndex uint64
+
+ // PrevExist specifies whether the Node must currently exist
+ // (PrevExist) or not (PrevNoExist). If the caller does not
+ // care about existence, set PrevExist to PrevIgnore, or simply
+ // leave it unset.
+ PrevExist PrevExistType
+
+ // TTL defines a period of time after-which the Node should
+ // expire and no longer exist. Values <= 0 are ignored. Given
+ // that the zero-value is ignored, TTL cannot be used to set
+ // a TTL of 0.
+ TTL time.Duration
+
+ // Refresh set to true means a TTL value can be updated
+ // without firing a watch or changing the node value. A
+ // value must not be provided when refreshing a key.
+ Refresh bool
+
+ // Dir specifies whether or not this Node should be created as a directory.
+ Dir bool
+
+ // NoValueOnSuccess specifies whether the response contains the current value of the Node.
+ // If set, the response will only contain the current value when the request fails.
+ NoValueOnSuccess bool
+}
+
+type GetOptions struct {
+ // Recursive defines whether or not all children of the Node
+ // should be returned.
+ Recursive bool
+
+ // Sort instructs the server whether or not to sort the Nodes.
+ // If true, the Nodes are sorted alphabetically by key in
+ // ascending order (A to z). If false (default), the Nodes will
+ // not be sorted and the ordering used should not be considered
+ // predictable.
+ Sort bool
+
+ // Quorum specifies whether it gets the latest committed value that
+ // has been applied in quorum of members, which ensures external
+ // consistency (or linearizability).
+ Quorum bool
+}
+
+type DeleteOptions struct {
+ // PrevValue specifies what the current value of the Node must
+ // be in order for the Delete operation to succeed.
+ //
+ // Leaving this field empty means that the caller wishes to
+ // ignore the current value of the Node. This cannot be used
+ // to compare the Node's current value to an empty string.
+ PrevValue string
+
+ // PrevIndex indicates what the current ModifiedIndex of the
+ // Node must be in order for the Delete operation to succeed.
+ //
+ // If PrevIndex is set to 0 (default), no comparison is made.
+ PrevIndex uint64
+
+ // Recursive defines whether or not all children of the Node
+ // should be deleted. If set to true, all children of the Node
+ // identified by the given key will be deleted. If left unset
+ // or explicitly set to false, only a single Node will be
+ // deleted.
+ Recursive bool
+
+ // Dir specifies whether or not this Node should be removed as a directory.
+ Dir bool
+}
+
+type Watcher interface {
+ // Next blocks until an etcd event occurs, then returns a Response
+ // representing that event. The behavior of Next depends on the
+ // WatcherOptions used to construct the Watcher. Next is designed to
+ // be called repeatedly, each time blocking until a subsequent event
+ // is available.
+ //
+ // If the provided context is cancelled, Next will return a non-nil
+ // error. Any other failures encountered while waiting for the next
+ // event (connection issues, deserialization failures, etc) will
+ // also result in a non-nil error.
+ Next(context.Context) (*Response, error)
+}
+
+type Response struct {
+ // Action is the name of the operation that occurred. Possible values
+ // include get, set, delete, update, create, compareAndSwap,
+ // compareAndDelete and expire.
+ Action string `json:"action"`
+
+ // Node represents the state of the relevant etcd Node.
+ Node *Node `json:"node"`
+
+ // PrevNode represents the previous state of the Node. PrevNode is non-nil
+ // only if the Node existed before the action occurred and the action
+ // caused a change to the Node.
+ PrevNode *Node `json:"prevNode"`
+
+ // Index holds the cluster-level index at the time the Response was generated.
+ // This index is not tied to the Node(s) contained in this Response.
+ Index uint64 `json:"-"`
+
+ // ClusterID holds the cluster-level ID reported by the server. This
+ // should be different for different etcd clusters.
+ ClusterID string `json:"-"`
+}
+
+type Node struct {
+ // Key represents the unique location of this Node (e.g. "/foo/bar").
+ Key string `json:"key"`
+
+ // Dir reports whether node describes a directory.
+ Dir bool `json:"dir,omitempty"`
+
+ // Value is the current data stored on this Node. If this Node
+ // is a directory, Value will be empty.
+ Value string `json:"value"`
+
+ // Nodes holds the children of this Node, only if this Node is a directory.
+ // This slice of will be arbitrarily deep (children, grandchildren, great-
+ // grandchildren, etc.) if a recursive Get or Watch request were made.
+ Nodes Nodes `json:"nodes"`
+
+ // CreatedIndex is the etcd index at-which this Node was created.
+ CreatedIndex uint64 `json:"createdIndex"`
+
+ // ModifiedIndex is the etcd index at-which this Node was last modified.
+ ModifiedIndex uint64 `json:"modifiedIndex"`
+
+ // Expiration is the server side expiration time of the key.
+ Expiration *time.Time `json:"expiration,omitempty"`
+
+ // TTL is the time to live of the key in second.
+ TTL int64 `json:"ttl,omitempty"`
+}
+
+func (n *Node) String() string {
+ return fmt.Sprintf("{Key: %s, CreatedIndex: %d, ModifiedIndex: %d, TTL: %d}", n.Key, n.CreatedIndex, n.ModifiedIndex, n.TTL)
+}
+
+// TTLDuration returns the Node's TTL as a time.Duration object
+func (n *Node) TTLDuration() time.Duration {
+ return time.Duration(n.TTL) * time.Second
+}
+
+type Nodes []*Node
+
+// interfaces for sorting
+
+func (ns Nodes) Len() int { return len(ns) }
+func (ns Nodes) Less(i, j int) bool { return ns[i].Key < ns[j].Key }
+func (ns Nodes) Swap(i, j int) { ns[i], ns[j] = ns[j], ns[i] }
+
+type httpKeysAPI struct {
+ client httpClient
+ prefix string
+}
+
+func (k *httpKeysAPI) Set(ctx context.Context, key, val string, opts *SetOptions) (*Response, error) {
+ act := &setAction{
+ Prefix: k.prefix,
+ Key: key,
+ Value: val,
+ }
+
+ if opts != nil {
+ act.PrevValue = opts.PrevValue
+ act.PrevIndex = opts.PrevIndex
+ act.PrevExist = opts.PrevExist
+ act.TTL = opts.TTL
+ act.Refresh = opts.Refresh
+ act.Dir = opts.Dir
+ act.NoValueOnSuccess = opts.NoValueOnSuccess
+ }
+
+ doCtx := ctx
+ if act.PrevExist == PrevNoExist {
+ doCtx = context.WithValue(doCtx, &oneShotCtxValue, &oneShotCtxValue)
+ }
+ resp, body, err := k.client.Do(doCtx, act)
+ if err != nil {
+ return nil, err
+ }
+
+ return unmarshalHTTPResponse(resp.StatusCode, resp.Header, body)
+}
+
+func (k *httpKeysAPI) Create(ctx context.Context, key, val string) (*Response, error) {
+ return k.Set(ctx, key, val, &SetOptions{PrevExist: PrevNoExist})
+}
+
+func (k *httpKeysAPI) CreateInOrder(ctx context.Context, dir, val string, opts *CreateInOrderOptions) (*Response, error) {
+ act := &createInOrderAction{
+ Prefix: k.prefix,
+ Dir: dir,
+ Value: val,
+ }
+
+ if opts != nil {
+ act.TTL = opts.TTL
+ }
+
+ resp, body, err := k.client.Do(ctx, act)
+ if err != nil {
+ return nil, err
+ }
+
+ return unmarshalHTTPResponse(resp.StatusCode, resp.Header, body)
+}
+
+func (k *httpKeysAPI) Update(ctx context.Context, key, val string) (*Response, error) {
+ return k.Set(ctx, key, val, &SetOptions{PrevExist: PrevExist})
+}
+
+func (k *httpKeysAPI) Delete(ctx context.Context, key string, opts *DeleteOptions) (*Response, error) {
+ act := &deleteAction{
+ Prefix: k.prefix,
+ Key: key,
+ }
+
+ if opts != nil {
+ act.PrevValue = opts.PrevValue
+ act.PrevIndex = opts.PrevIndex
+ act.Dir = opts.Dir
+ act.Recursive = opts.Recursive
+ }
+
+ doCtx := context.WithValue(ctx, &oneShotCtxValue, &oneShotCtxValue)
+ resp, body, err := k.client.Do(doCtx, act)
+ if err != nil {
+ return nil, err
+ }
+
+ return unmarshalHTTPResponse(resp.StatusCode, resp.Header, body)
+}
+
+func (k *httpKeysAPI) Get(ctx context.Context, key string, opts *GetOptions) (*Response, error) {
+ act := &getAction{
+ Prefix: k.prefix,
+ Key: key,
+ }
+
+ if opts != nil {
+ act.Recursive = opts.Recursive
+ act.Sorted = opts.Sort
+ act.Quorum = opts.Quorum
+ }
+
+ resp, body, err := k.client.Do(ctx, act)
+ if err != nil {
+ return nil, err
+ }
+
+ return unmarshalHTTPResponse(resp.StatusCode, resp.Header, body)
+}
+
+func (k *httpKeysAPI) Watcher(key string, opts *WatcherOptions) Watcher {
+ act := waitAction{
+ Prefix: k.prefix,
+ Key: key,
+ }
+
+ if opts != nil {
+ act.Recursive = opts.Recursive
+ if opts.AfterIndex > 0 {
+ act.WaitIndex = opts.AfterIndex + 1
+ }
+ }
+
+ return &httpWatcher{
+ client: k.client,
+ nextWait: act,
+ }
+}
+
+type httpWatcher struct {
+ client httpClient
+ nextWait waitAction
+}
+
+func (hw *httpWatcher) Next(ctx context.Context) (*Response, error) {
+ for {
+ httpresp, body, err := hw.client.Do(ctx, &hw.nextWait)
+ if err != nil {
+ return nil, err
+ }
+
+ resp, err := unmarshalHTTPResponse(httpresp.StatusCode, httpresp.Header, body)
+ if err != nil {
+ if err == ErrEmptyBody {
+ continue
+ }
+ return nil, err
+ }
+
+ hw.nextWait.WaitIndex = resp.Node.ModifiedIndex + 1
+ return resp, nil
+ }
+}
+
+// v2KeysURL forms a URL representing the location of a key.
+// The endpoint argument represents the base URL of an etcd
+// server. The prefix is the path needed to route from the
+// provided endpoint's path to the root of the keys API
+// (typically "/v2/keys").
+func v2KeysURL(ep url.URL, prefix, key string) *url.URL {
+ // We concatenate all parts together manually. We cannot use
+ // path.Join because it does not reserve trailing slash.
+ // We call CanonicalURLPath to further cleanup the path.
+ if prefix != "" && prefix[0] != '/' {
+ prefix = "/" + prefix
+ }
+ if key != "" && key[0] != '/' {
+ key = "/" + key
+ }
+ ep.Path = pathutil.CanonicalURLPath(ep.Path + prefix + key)
+ return &ep
+}
+
+type getAction struct {
+ Prefix string
+ Key string
+ Recursive bool
+ Sorted bool
+ Quorum bool
+}
+
+func (g *getAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2KeysURL(ep, g.Prefix, g.Key)
+
+ params := u.Query()
+ params.Set("recursive", strconv.FormatBool(g.Recursive))
+ params.Set("sorted", strconv.FormatBool(g.Sorted))
+ params.Set("quorum", strconv.FormatBool(g.Quorum))
+ u.RawQuery = params.Encode()
+
+ req, _ := http.NewRequest("GET", u.String(), nil)
+ return req
+}
+
+type waitAction struct {
+ Prefix string
+ Key string
+ WaitIndex uint64
+ Recursive bool
+}
+
+func (w *waitAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2KeysURL(ep, w.Prefix, w.Key)
+
+ params := u.Query()
+ params.Set("wait", "true")
+ params.Set("waitIndex", strconv.FormatUint(w.WaitIndex, 10))
+ params.Set("recursive", strconv.FormatBool(w.Recursive))
+ u.RawQuery = params.Encode()
+
+ req, _ := http.NewRequest("GET", u.String(), nil)
+ return req
+}
+
+type setAction struct {
+ Prefix string
+ Key string
+ Value string
+ PrevValue string
+ PrevIndex uint64
+ PrevExist PrevExistType
+ TTL time.Duration
+ Refresh bool
+ Dir bool
+ NoValueOnSuccess bool
+}
+
+func (a *setAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2KeysURL(ep, a.Prefix, a.Key)
+
+ params := u.Query()
+ form := url.Values{}
+
+ // we're either creating a directory or setting a key
+ if a.Dir {
+ params.Set("dir", strconv.FormatBool(a.Dir))
+ } else {
+ // These options are only valid for setting a key
+ if a.PrevValue != "" {
+ params.Set("prevValue", a.PrevValue)
+ }
+ form.Add("value", a.Value)
+ }
+
+ // Options which apply to both setting a key and creating a dir
+ if a.PrevIndex != 0 {
+ params.Set("prevIndex", strconv.FormatUint(a.PrevIndex, 10))
+ }
+ if a.PrevExist != PrevIgnore {
+ params.Set("prevExist", string(a.PrevExist))
+ }
+ if a.TTL > 0 {
+ form.Add("ttl", strconv.FormatUint(uint64(a.TTL.Seconds()), 10))
+ }
+
+ if a.Refresh {
+ form.Add("refresh", "true")
+ }
+ if a.NoValueOnSuccess {
+ params.Set("noValueOnSuccess", strconv.FormatBool(a.NoValueOnSuccess))
+ }
+
+ u.RawQuery = params.Encode()
+ body := strings.NewReader(form.Encode())
+
+ req, _ := http.NewRequest("PUT", u.String(), body)
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+
+ return req
+}
+
+type deleteAction struct {
+ Prefix string
+ Key string
+ PrevValue string
+ PrevIndex uint64
+ Dir bool
+ Recursive bool
+}
+
+func (a *deleteAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2KeysURL(ep, a.Prefix, a.Key)
+
+ params := u.Query()
+ if a.PrevValue != "" {
+ params.Set("prevValue", a.PrevValue)
+ }
+ if a.PrevIndex != 0 {
+ params.Set("prevIndex", strconv.FormatUint(a.PrevIndex, 10))
+ }
+ if a.Dir {
+ params.Set("dir", "true")
+ }
+ if a.Recursive {
+ params.Set("recursive", "true")
+ }
+ u.RawQuery = params.Encode()
+
+ req, _ := http.NewRequest("DELETE", u.String(), nil)
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+
+ return req
+}
+
+type createInOrderAction struct {
+ Prefix string
+ Dir string
+ Value string
+ TTL time.Duration
+}
+
+func (a *createInOrderAction) HTTPRequest(ep url.URL) *http.Request {
+ u := v2KeysURL(ep, a.Prefix, a.Dir)
+
+ form := url.Values{}
+ form.Add("value", a.Value)
+ if a.TTL > 0 {
+ form.Add("ttl", strconv.FormatUint(uint64(a.TTL.Seconds()), 10))
+ }
+ body := strings.NewReader(form.Encode())
+
+ req, _ := http.NewRequest("POST", u.String(), body)
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ return req
+}
+
+func unmarshalHTTPResponse(code int, header http.Header, body []byte) (res *Response, err error) {
+ switch code {
+ case http.StatusOK, http.StatusCreated:
+ if len(body) == 0 {
+ return nil, ErrEmptyBody
+ }
+ res, err = unmarshalSuccessfulKeysResponse(header, body)
+ default:
+ err = unmarshalFailedKeysResponse(body)
+ }
+
+ return
+}
+
+func unmarshalSuccessfulKeysResponse(header http.Header, body []byte) (*Response, error) {
+ var res Response
+ err := codec.NewDecoderBytes(body, new(codec.JsonHandle)).Decode(&res)
+ if err != nil {
+ return nil, ErrInvalidJSON
+ }
+ if header.Get("X-Etcd-Index") != "" {
+ res.Index, err = strconv.ParseUint(header.Get("X-Etcd-Index"), 10, 64)
+ if err != nil {
+ return nil, err
+ }
+ }
+ res.ClusterID = header.Get("X-Etcd-Cluster-ID")
+ return &res, nil
+}
+
+func unmarshalFailedKeysResponse(body []byte) error {
+ var etcdErr Error
+ if err := json.Unmarshal(body, &etcdErr); err != nil {
+ return ErrInvalidJSON
+ }
+ return etcdErr
+}
diff --git a/vendor/github.com/coreos/etcd/client/keys_bench_test.go b/vendor/github.com/coreos/etcd/client/keys_bench_test.go
new file mode 100644
index 00000000..f8ca3ea3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/keys_bench_test.go
@@ -0,0 +1,87 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client
+
+import (
+ "encoding/json"
+ "net/http"
+ "reflect"
+ "strings"
+ "testing"
+)
+
+func createTestNode(size int) *Node {
+ return &Node{
+ Key: strings.Repeat("a", 30),
+ Value: strings.Repeat("a", size),
+ CreatedIndex: 123456,
+ ModifiedIndex: 123456,
+ TTL: 123456789,
+ }
+}
+
+func createTestNodeWithChildren(children, size int) *Node {
+ node := createTestNode(size)
+ for i := 0; i < children; i++ {
+ node.Nodes = append(node.Nodes, createTestNode(size))
+ }
+ return node
+}
+
+func createTestResponse(children, size int) *Response {
+ return &Response{
+ Action: "aaaaa",
+ Node: createTestNodeWithChildren(children, size),
+ PrevNode: nil,
+ }
+}
+
+func benchmarkResponseUnmarshalling(b *testing.B, children, size int) {
+ header := http.Header{}
+ header.Add("X-Etcd-Index", "123456")
+ response := createTestResponse(children, size)
+ body, err := json.Marshal(response)
+ if err != nil {
+ b.Fatal(err)
+ }
+
+ b.ResetTimer()
+ newResponse := new(Response)
+ for i := 0; i < b.N; i++ {
+ if newResponse, err = unmarshalSuccessfulKeysResponse(header, body); err != nil {
+ b.Errorf("error unmarshaling response (%v)", err)
+ }
+
+ }
+ if !reflect.DeepEqual(response.Node, newResponse.Node) {
+ b.Errorf("Unexpected difference in a parsed response: \n%+v\n%+v", response, newResponse)
+ }
+}
+
+func BenchmarkSmallResponseUnmarshal(b *testing.B) {
+ benchmarkResponseUnmarshalling(b, 30, 20)
+}
+
+func BenchmarkManySmallResponseUnmarshal(b *testing.B) {
+ benchmarkResponseUnmarshalling(b, 3000, 20)
+}
+
+func BenchmarkMediumResponseUnmarshal(b *testing.B) {
+ benchmarkResponseUnmarshalling(b, 300, 200)
+}
+
+func BenchmarkLargeResponseUnmarshal(b *testing.B) {
+ benchmarkResponseUnmarshalling(b, 3000, 2000)
+}
diff --git a/vendor/github.com/coreos/etcd/client/keys_test.go b/vendor/github.com/coreos/etcd/client/keys_test.go
new file mode 100644
index 00000000..253fa9b8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/keys_test.go
@@ -0,0 +1,1429 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client
+
+import (
+ "errors"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "net/url"
+ "reflect"
+ "testing"
+ "time"
+
+ "golang.org/x/net/context"
+)
+
+func TestV2KeysURLHelper(t *testing.T) {
+ tests := []struct {
+ endpoint url.URL
+ prefix string
+ key string
+ want url.URL
+ }{
+ // key is empty, no problem
+ {
+ endpoint: url.URL{Scheme: "http", Host: "example.com", Path: "/v2/keys"},
+ prefix: "",
+ key: "",
+ want: url.URL{Scheme: "http", Host: "example.com", Path: "/v2/keys"},
+ },
+
+ // key is joined to path
+ {
+ endpoint: url.URL{Scheme: "http", Host: "example.com", Path: "/v2/keys"},
+ prefix: "",
+ key: "/foo/bar",
+ want: url.URL{Scheme: "http", Host: "example.com", Path: "/v2/keys/foo/bar"},
+ },
+
+ // key is joined to path when path is empty
+ {
+ endpoint: url.URL{Scheme: "http", Host: "example.com", Path: ""},
+ prefix: "",
+ key: "/foo/bar",
+ want: url.URL{Scheme: "http", Host: "example.com", Path: "/foo/bar"},
+ },
+
+ // Host field carries through with port
+ {
+ endpoint: url.URL{Scheme: "http", Host: "example.com:8080", Path: "/v2/keys"},
+ prefix: "",
+ key: "",
+ want: url.URL{Scheme: "http", Host: "example.com:8080", Path: "/v2/keys"},
+ },
+
+ // Scheme carries through
+ {
+ endpoint: url.URL{Scheme: "https", Host: "example.com", Path: "/v2/keys"},
+ prefix: "",
+ key: "",
+ want: url.URL{Scheme: "https", Host: "example.com", Path: "/v2/keys"},
+ },
+ // Prefix is applied
+ {
+ endpoint: url.URL{Scheme: "https", Host: "example.com", Path: "/foo"},
+ prefix: "/bar",
+ key: "/baz",
+ want: url.URL{Scheme: "https", Host: "example.com", Path: "/foo/bar/baz"},
+ },
+ // Prefix is joined to path
+ {
+ endpoint: url.URL{Scheme: "https", Host: "example.com", Path: "/foo"},
+ prefix: "/bar",
+ key: "",
+ want: url.URL{Scheme: "https", Host: "example.com", Path: "/foo/bar"},
+ },
+ // Keep trailing slash
+ {
+ endpoint: url.URL{Scheme: "https", Host: "example.com", Path: "/foo"},
+ prefix: "/bar",
+ key: "/baz/",
+ want: url.URL{Scheme: "https", Host: "example.com", Path: "/foo/bar/baz/"},
+ },
+ }
+
+ for i, tt := range tests {
+ got := v2KeysURL(tt.endpoint, tt.prefix, tt.key)
+ if tt.want != *got {
+ t.Errorf("#%d: want=%#v, got=%#v", i, tt.want, *got)
+ }
+ }
+}
+
+func TestGetAction(t *testing.T) {
+ ep := url.URL{Scheme: "http", Host: "example.com", Path: "/v2/keys"}
+ baseWantURL := &url.URL{
+ Scheme: "http",
+ Host: "example.com",
+ Path: "/v2/keys/foo/bar",
+ }
+ wantHeader := http.Header{}
+
+ tests := []struct {
+ recursive bool
+ sorted bool
+ quorum bool
+ wantQuery string
+ }{
+ {
+ recursive: false,
+ sorted: false,
+ quorum: false,
+ wantQuery: "quorum=false&recursive=false&sorted=false",
+ },
+ {
+ recursive: true,
+ sorted: false,
+ quorum: false,
+ wantQuery: "quorum=false&recursive=true&sorted=false",
+ },
+ {
+ recursive: false,
+ sorted: true,
+ quorum: false,
+ wantQuery: "quorum=false&recursive=false&sorted=true",
+ },
+ {
+ recursive: true,
+ sorted: true,
+ quorum: false,
+ wantQuery: "quorum=false&recursive=true&sorted=true",
+ },
+ {
+ recursive: false,
+ sorted: false,
+ quorum: true,
+ wantQuery: "quorum=true&recursive=false&sorted=false",
+ },
+ }
+
+ for i, tt := range tests {
+ f := getAction{
+ Key: "/foo/bar",
+ Recursive: tt.recursive,
+ Sorted: tt.sorted,
+ Quorum: tt.quorum,
+ }
+ got := *f.HTTPRequest(ep)
+
+ wantURL := baseWantURL
+ wantURL.RawQuery = tt.wantQuery
+
+ err := assertRequest(got, "GET", wantURL, wantHeader, nil)
+ if err != nil {
+ t.Errorf("#%d: %v", i, err)
+ }
+ }
+}
+
+func TestWaitAction(t *testing.T) {
+ ep := url.URL{Scheme: "http", Host: "example.com", Path: "/v2/keys"}
+ baseWantURL := &url.URL{
+ Scheme: "http",
+ Host: "example.com",
+ Path: "/v2/keys/foo/bar",
+ }
+ wantHeader := http.Header{}
+
+ tests := []struct {
+ waitIndex uint64
+ recursive bool
+ wantQuery string
+ }{
+ {
+ recursive: false,
+ waitIndex: uint64(0),
+ wantQuery: "recursive=false&wait=true&waitIndex=0",
+ },
+ {
+ recursive: false,
+ waitIndex: uint64(12),
+ wantQuery: "recursive=false&wait=true&waitIndex=12",
+ },
+ {
+ recursive: true,
+ waitIndex: uint64(12),
+ wantQuery: "recursive=true&wait=true&waitIndex=12",
+ },
+ }
+
+ for i, tt := range tests {
+ f := waitAction{
+ Key: "/foo/bar",
+ WaitIndex: tt.waitIndex,
+ Recursive: tt.recursive,
+ }
+ got := *f.HTTPRequest(ep)
+
+ wantURL := baseWantURL
+ wantURL.RawQuery = tt.wantQuery
+
+ err := assertRequest(got, "GET", wantURL, wantHeader, nil)
+ if err != nil {
+ t.Errorf("#%d: unexpected error: %#v", i, err)
+ }
+ }
+}
+
+func TestSetAction(t *testing.T) {
+ wantHeader := http.Header(map[string][]string{
+ "Content-Type": {"application/x-www-form-urlencoded"},
+ })
+
+ tests := []struct {
+ act setAction
+ wantURL string
+ wantBody string
+ }{
+ // default prefix
+ {
+ act: setAction{
+ Prefix: defaultV2KeysPrefix,
+ Key: "foo",
+ },
+ wantURL: "http://example.com/v2/keys/foo",
+ wantBody: "value=",
+ },
+
+ // non-default prefix
+ {
+ act: setAction{
+ Prefix: "/pfx",
+ Key: "foo",
+ },
+ wantURL: "http://example.com/pfx/foo",
+ wantBody: "value=",
+ },
+
+ // no prefix
+ {
+ act: setAction{
+ Key: "foo",
+ },
+ wantURL: "http://example.com/foo",
+ wantBody: "value=",
+ },
+
+ // Key with path separators
+ {
+ act: setAction{
+ Prefix: defaultV2KeysPrefix,
+ Key: "foo/bar/baz",
+ },
+ wantURL: "http://example.com/v2/keys/foo/bar/baz",
+ wantBody: "value=",
+ },
+
+ // Key with leading slash, Prefix with trailing slash
+ {
+ act: setAction{
+ Prefix: "/foo/",
+ Key: "/bar",
+ },
+ wantURL: "http://example.com/foo/bar",
+ wantBody: "value=",
+ },
+
+ // Key with trailing slash
+ {
+ act: setAction{
+ Key: "/foo/",
+ },
+ wantURL: "http://example.com/foo/",
+ wantBody: "value=",
+ },
+
+ // Value is set
+ {
+ act: setAction{
+ Key: "foo",
+ Value: "baz",
+ },
+ wantURL: "http://example.com/foo",
+ wantBody: "value=baz",
+ },
+
+ // PrevExist set, but still ignored
+ {
+ act: setAction{
+ Key: "foo",
+ PrevExist: PrevIgnore,
+ },
+ wantURL: "http://example.com/foo",
+ wantBody: "value=",
+ },
+
+ // PrevExist set to true
+ {
+ act: setAction{
+ Key: "foo",
+ PrevExist: PrevExist,
+ },
+ wantURL: "http://example.com/foo?prevExist=true",
+ wantBody: "value=",
+ },
+
+ // PrevExist set to false
+ {
+ act: setAction{
+ Key: "foo",
+ PrevExist: PrevNoExist,
+ },
+ wantURL: "http://example.com/foo?prevExist=false",
+ wantBody: "value=",
+ },
+
+ // PrevValue is urlencoded
+ {
+ act: setAction{
+ Key: "foo",
+ PrevValue: "bar baz",
+ },
+ wantURL: "http://example.com/foo?prevValue=bar+baz",
+ wantBody: "value=",
+ },
+
+ // PrevIndex is set
+ {
+ act: setAction{
+ Key: "foo",
+ PrevIndex: uint64(12),
+ },
+ wantURL: "http://example.com/foo?prevIndex=12",
+ wantBody: "value=",
+ },
+
+ // TTL is set
+ {
+ act: setAction{
+ Key: "foo",
+ TTL: 3 * time.Minute,
+ },
+ wantURL: "http://example.com/foo",
+ wantBody: "ttl=180&value=",
+ },
+
+ // Refresh is set
+ {
+ act: setAction{
+ Key: "foo",
+ TTL: 3 * time.Minute,
+ Refresh: true,
+ },
+ wantURL: "http://example.com/foo",
+ wantBody: "refresh=true&ttl=180&value=",
+ },
+
+ // Dir is set
+ {
+ act: setAction{
+ Key: "foo",
+ Dir: true,
+ },
+ wantURL: "http://example.com/foo?dir=true",
+ wantBody: "",
+ },
+ // Dir is set with a value
+ {
+ act: setAction{
+ Key: "foo",
+ Value: "bar",
+ Dir: true,
+ },
+ wantURL: "http://example.com/foo?dir=true",
+ wantBody: "",
+ },
+ // Dir is set with PrevExist set to true
+ {
+ act: setAction{
+ Key: "foo",
+ PrevExist: PrevExist,
+ Dir: true,
+ },
+ wantURL: "http://example.com/foo?dir=true&prevExist=true",
+ wantBody: "",
+ },
+ // Dir is set with PrevValue
+ {
+ act: setAction{
+ Key: "foo",
+ PrevValue: "bar",
+ Dir: true,
+ },
+ wantURL: "http://example.com/foo?dir=true",
+ wantBody: "",
+ },
+ // NoValueOnSuccess is set
+ {
+ act: setAction{
+ Key: "foo",
+ NoValueOnSuccess: true,
+ },
+ wantURL: "http://example.com/foo?noValueOnSuccess=true",
+ wantBody: "value=",
+ },
+ }
+
+ for i, tt := range tests {
+ u, err := url.Parse(tt.wantURL)
+ if err != nil {
+ t.Errorf("#%d: unable to use wantURL fixture: %v", i, err)
+ }
+
+ got := tt.act.HTTPRequest(url.URL{Scheme: "http", Host: "example.com"})
+ if err := assertRequest(*got, "PUT", u, wantHeader, []byte(tt.wantBody)); err != nil {
+ t.Errorf("#%d: %v", i, err)
+ }
+ }
+}
+
+func TestCreateInOrderAction(t *testing.T) {
+ wantHeader := http.Header(map[string][]string{
+ "Content-Type": {"application/x-www-form-urlencoded"},
+ })
+
+ tests := []struct {
+ act createInOrderAction
+ wantURL string
+ wantBody string
+ }{
+ // default prefix
+ {
+ act: createInOrderAction{
+ Prefix: defaultV2KeysPrefix,
+ Dir: "foo",
+ },
+ wantURL: "http://example.com/v2/keys/foo",
+ wantBody: "value=",
+ },
+
+ // non-default prefix
+ {
+ act: createInOrderAction{
+ Prefix: "/pfx",
+ Dir: "foo",
+ },
+ wantURL: "http://example.com/pfx/foo",
+ wantBody: "value=",
+ },
+
+ // no prefix
+ {
+ act: createInOrderAction{
+ Dir: "foo",
+ },
+ wantURL: "http://example.com/foo",
+ wantBody: "value=",
+ },
+
+ // Key with path separators
+ {
+ act: createInOrderAction{
+ Prefix: defaultV2KeysPrefix,
+ Dir: "foo/bar/baz",
+ },
+ wantURL: "http://example.com/v2/keys/foo/bar/baz",
+ wantBody: "value=",
+ },
+
+ // Key with leading slash, Prefix with trailing slash
+ {
+ act: createInOrderAction{
+ Prefix: "/foo/",
+ Dir: "/bar",
+ },
+ wantURL: "http://example.com/foo/bar",
+ wantBody: "value=",
+ },
+
+ // Key with trailing slash
+ {
+ act: createInOrderAction{
+ Dir: "/foo/",
+ },
+ wantURL: "http://example.com/foo/",
+ wantBody: "value=",
+ },
+
+ // Value is set
+ {
+ act: createInOrderAction{
+ Dir: "foo",
+ Value: "baz",
+ },
+ wantURL: "http://example.com/foo",
+ wantBody: "value=baz",
+ },
+ // TTL is set
+ {
+ act: createInOrderAction{
+ Dir: "foo",
+ TTL: 3 * time.Minute,
+ },
+ wantURL: "http://example.com/foo",
+ wantBody: "ttl=180&value=",
+ },
+ }
+
+ for i, tt := range tests {
+ u, err := url.Parse(tt.wantURL)
+ if err != nil {
+ t.Errorf("#%d: unable to use wantURL fixture: %v", i, err)
+ }
+
+ got := tt.act.HTTPRequest(url.URL{Scheme: "http", Host: "example.com"})
+ if err := assertRequest(*got, "POST", u, wantHeader, []byte(tt.wantBody)); err != nil {
+ t.Errorf("#%d: %v", i, err)
+ }
+ }
+}
+
+func TestDeleteAction(t *testing.T) {
+ wantHeader := http.Header(map[string][]string{
+ "Content-Type": {"application/x-www-form-urlencoded"},
+ })
+
+ tests := []struct {
+ act deleteAction
+ wantURL string
+ }{
+ // default prefix
+ {
+ act: deleteAction{
+ Prefix: defaultV2KeysPrefix,
+ Key: "foo",
+ },
+ wantURL: "http://example.com/v2/keys/foo",
+ },
+
+ // non-default prefix
+ {
+ act: deleteAction{
+ Prefix: "/pfx",
+ Key: "foo",
+ },
+ wantURL: "http://example.com/pfx/foo",
+ },
+
+ // no prefix
+ {
+ act: deleteAction{
+ Key: "foo",
+ },
+ wantURL: "http://example.com/foo",
+ },
+
+ // Key with path separators
+ {
+ act: deleteAction{
+ Prefix: defaultV2KeysPrefix,
+ Key: "foo/bar/baz",
+ },
+ wantURL: "http://example.com/v2/keys/foo/bar/baz",
+ },
+
+ // Key with leading slash, Prefix with trailing slash
+ {
+ act: deleteAction{
+ Prefix: "/foo/",
+ Key: "/bar",
+ },
+ wantURL: "http://example.com/foo/bar",
+ },
+
+ // Key with trailing slash
+ {
+ act: deleteAction{
+ Key: "/foo/",
+ },
+ wantURL: "http://example.com/foo/",
+ },
+
+ // Recursive set to true
+ {
+ act: deleteAction{
+ Key: "foo",
+ Recursive: true,
+ },
+ wantURL: "http://example.com/foo?recursive=true",
+ },
+
+ // PrevValue is urlencoded
+ {
+ act: deleteAction{
+ Key: "foo",
+ PrevValue: "bar baz",
+ },
+ wantURL: "http://example.com/foo?prevValue=bar+baz",
+ },
+
+ // PrevIndex is set
+ {
+ act: deleteAction{
+ Key: "foo",
+ PrevIndex: uint64(12),
+ },
+ wantURL: "http://example.com/foo?prevIndex=12",
+ },
+ }
+
+ for i, tt := range tests {
+ u, err := url.Parse(tt.wantURL)
+ if err != nil {
+ t.Errorf("#%d: unable to use wantURL fixture: %v", i, err)
+ }
+
+ got := tt.act.HTTPRequest(url.URL{Scheme: "http", Host: "example.com"})
+ if err := assertRequest(*got, "DELETE", u, wantHeader, nil); err != nil {
+ t.Errorf("#%d: %v", i, err)
+ }
+ }
+}
+
+func assertRequest(got http.Request, wantMethod string, wantURL *url.URL, wantHeader http.Header, wantBody []byte) error {
+ if wantMethod != got.Method {
+ return fmt.Errorf("want.Method=%#v got.Method=%#v", wantMethod, got.Method)
+ }
+
+ if !reflect.DeepEqual(wantURL, got.URL) {
+ return fmt.Errorf("want.URL=%#v got.URL=%#v", wantURL, got.URL)
+ }
+
+ if !reflect.DeepEqual(wantHeader, got.Header) {
+ return fmt.Errorf("want.Header=%#v got.Header=%#v", wantHeader, got.Header)
+ }
+
+ if got.Body == nil {
+ if wantBody != nil {
+ return fmt.Errorf("want.Body=%v got.Body=%v", wantBody, got.Body)
+ }
+ } else {
+ if wantBody == nil {
+ return fmt.Errorf("want.Body=%v got.Body=%s", wantBody, got.Body)
+ }
+ gotBytes, err := ioutil.ReadAll(got.Body)
+ if err != nil {
+ return err
+ }
+
+ if !reflect.DeepEqual(wantBody, gotBytes) {
+ return fmt.Errorf("want.Body=%s got.Body=%s", wantBody, gotBytes)
+ }
+ }
+
+ return nil
+}
+
+func TestUnmarshalSuccessfulResponse(t *testing.T) {
+ var expiration time.Time
+ expiration.UnmarshalText([]byte("2015-04-07T04:40:23.044979686Z"))
+
+ tests := []struct {
+ indexHdr string
+ clusterIDHdr string
+ body string
+ wantRes *Response
+ wantErr bool
+ }{
+ // Neither PrevNode or Node
+ {
+ indexHdr: "1",
+ body: `{"action":"delete"}`,
+ wantRes: &Response{Action: "delete", Index: 1},
+ wantErr: false,
+ },
+
+ // PrevNode
+ {
+ indexHdr: "15",
+ body: `{"action":"delete", "prevNode": {"key": "/foo", "value": "bar", "modifiedIndex": 12, "createdIndex": 10}}`,
+ wantRes: &Response{
+ Action: "delete",
+ Index: 15,
+ Node: nil,
+ PrevNode: &Node{
+ Key: "/foo",
+ Value: "bar",
+ ModifiedIndex: 12,
+ CreatedIndex: 10,
+ },
+ },
+ wantErr: false,
+ },
+
+ // Node
+ {
+ indexHdr: "15",
+ body: `{"action":"get", "node": {"key": "/foo", "value": "bar", "modifiedIndex": 12, "createdIndex": 10, "ttl": 10, "expiration": "2015-04-07T04:40:23.044979686Z"}}`,
+ wantRes: &Response{
+ Action: "get",
+ Index: 15,
+ Node: &Node{
+ Key: "/foo",
+ Value: "bar",
+ ModifiedIndex: 12,
+ CreatedIndex: 10,
+ TTL: 10,
+ Expiration: &expiration,
+ },
+ PrevNode: nil,
+ },
+ wantErr: false,
+ },
+
+ // Node Dir
+ {
+ indexHdr: "15",
+ clusterIDHdr: "abcdef",
+ body: `{"action":"get", "node": {"key": "/foo", "dir": true, "modifiedIndex": 12, "createdIndex": 10}}`,
+ wantRes: &Response{
+ Action: "get",
+ Index: 15,
+ Node: &Node{
+ Key: "/foo",
+ Dir: true,
+ ModifiedIndex: 12,
+ CreatedIndex: 10,
+ },
+ PrevNode: nil,
+ ClusterID: "abcdef",
+ },
+ wantErr: false,
+ },
+
+ // PrevNode and Node
+ {
+ indexHdr: "15",
+ body: `{"action":"update", "prevNode": {"key": "/foo", "value": "baz", "modifiedIndex": 10, "createdIndex": 10}, "node": {"key": "/foo", "value": "bar", "modifiedIndex": 12, "createdIndex": 10}}`,
+ wantRes: &Response{
+ Action: "update",
+ Index: 15,
+ PrevNode: &Node{
+ Key: "/foo",
+ Value: "baz",
+ ModifiedIndex: 10,
+ CreatedIndex: 10,
+ },
+ Node: &Node{
+ Key: "/foo",
+ Value: "bar",
+ ModifiedIndex: 12,
+ CreatedIndex: 10,
+ },
+ },
+ wantErr: false,
+ },
+
+ // Garbage in body
+ {
+ indexHdr: "",
+ body: `garbage`,
+ wantRes: nil,
+ wantErr: true,
+ },
+
+ // non-integer index
+ {
+ indexHdr: "poo",
+ body: `{}`,
+ wantRes: nil,
+ wantErr: true,
+ },
+ }
+
+ for i, tt := range tests {
+ h := make(http.Header)
+ h.Add("X-Etcd-Index", tt.indexHdr)
+ res, err := unmarshalSuccessfulKeysResponse(h, []byte(tt.body))
+ if tt.wantErr != (err != nil) {
+ t.Errorf("#%d: wantErr=%t, err=%v", i, tt.wantErr, err)
+ }
+
+ if (res == nil) != (tt.wantRes == nil) {
+ t.Errorf("#%d: received res=%#v, but expected res=%#v", i, res, tt.wantRes)
+ continue
+ } else if tt.wantRes == nil {
+ // expected and successfully got nil response
+ continue
+ }
+
+ if res.Action != tt.wantRes.Action {
+ t.Errorf("#%d: Action=%s, expected %s", i, res.Action, tt.wantRes.Action)
+ }
+ if res.Index != tt.wantRes.Index {
+ t.Errorf("#%d: Index=%d, expected %d", i, res.Index, tt.wantRes.Index)
+ }
+ if !reflect.DeepEqual(res.Node, tt.wantRes.Node) {
+ t.Errorf("#%d: Node=%v, expected %v", i, res.Node, tt.wantRes.Node)
+ }
+ }
+}
+
+func TestUnmarshalFailedKeysResponse(t *testing.T) {
+ body := []byte(`{"errorCode":100,"message":"Key not found","cause":"/foo","index":18}`)
+
+ wantErr := Error{
+ Code: 100,
+ Message: "Key not found",
+ Cause: "/foo",
+ Index: uint64(18),
+ }
+
+ gotErr := unmarshalFailedKeysResponse(body)
+ if !reflect.DeepEqual(wantErr, gotErr) {
+ t.Errorf("unexpected error: want=%#v got=%#v", wantErr, gotErr)
+ }
+}
+
+func TestUnmarshalFailedKeysResponseBadJSON(t *testing.T) {
+ err := unmarshalFailedKeysResponse([]byte(`{"er`))
+ if err == nil {
+ t.Errorf("got nil error")
+ } else if _, ok := err.(Error); ok {
+ t.Errorf("error is of incorrect type *Error: %#v", err)
+ }
+}
+
+func TestHTTPWatcherNextWaitAction(t *testing.T) {
+ initAction := waitAction{
+ Prefix: "/pants",
+ Key: "/foo/bar",
+ Recursive: true,
+ WaitIndex: 19,
+ }
+
+ client := &actionAssertingHTTPClient{
+ t: t,
+ act: &initAction,
+ resp: http.Response{
+ StatusCode: http.StatusOK,
+ Header: http.Header{"X-Etcd-Index": []string{"42"}},
+ },
+ body: []byte(`{"action":"update","node":{"key":"/pants/foo/bar/baz","value":"snarf","modifiedIndex":21,"createdIndex":19},"prevNode":{"key":"/pants/foo/bar/baz","value":"snazz","modifiedIndex":20,"createdIndex":19}}`),
+ }
+
+ wantResponse := &Response{
+ Action: "update",
+ Node: &Node{Key: "/pants/foo/bar/baz", Value: "snarf", CreatedIndex: uint64(19), ModifiedIndex: uint64(21)},
+ PrevNode: &Node{Key: "/pants/foo/bar/baz", Value: "snazz", CreatedIndex: uint64(19), ModifiedIndex: uint64(20)},
+ Index: uint64(42),
+ }
+
+ wantNextWait := waitAction{
+ Prefix: "/pants",
+ Key: "/foo/bar",
+ Recursive: true,
+ WaitIndex: 22,
+ }
+
+ watcher := &httpWatcher{
+ client: client,
+ nextWait: initAction,
+ }
+
+ resp, err := watcher.Next(context.Background())
+ if err != nil {
+ t.Errorf("non-nil error: %#v", err)
+ }
+
+ if !reflect.DeepEqual(wantResponse, resp) {
+ t.Errorf("received incorrect Response: want=%#v got=%#v", wantResponse, resp)
+ }
+
+ if !reflect.DeepEqual(wantNextWait, watcher.nextWait) {
+ t.Errorf("nextWait incorrect: want=%#v got=%#v", wantNextWait, watcher.nextWait)
+ }
+}
+
+func TestHTTPWatcherNextFail(t *testing.T) {
+ tests := []httpClient{
+ // generic HTTP client failure
+ &staticHTTPClient{
+ err: errors.New("fail!"),
+ },
+
+ // unusable status code
+ &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusTeapot,
+ },
+ },
+
+ // etcd Error response
+ &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusNotFound,
+ },
+ body: []byte(`{"errorCode":100,"message":"Key not found","cause":"/foo","index":18}`),
+ },
+ }
+
+ for i, tt := range tests {
+ act := waitAction{
+ Prefix: "/pants",
+ Key: "/foo/bar",
+ Recursive: true,
+ WaitIndex: 19,
+ }
+
+ watcher := &httpWatcher{
+ client: tt,
+ nextWait: act,
+ }
+
+ resp, err := watcher.Next(context.Background())
+ if err == nil {
+ t.Errorf("#%d: expected non-nil error", i)
+ }
+ if resp != nil {
+ t.Errorf("#%d: expected nil Response, got %#v", i, resp)
+ }
+ if !reflect.DeepEqual(act, watcher.nextWait) {
+ t.Errorf("#%d: nextWait changed: want=%#v got=%#v", i, act, watcher.nextWait)
+ }
+ }
+}
+
+func TestHTTPKeysAPIWatcherAction(t *testing.T) {
+ tests := []struct {
+ key string
+ opts *WatcherOptions
+ want waitAction
+ }{
+ {
+ key: "/foo",
+ opts: nil,
+ want: waitAction{
+ Key: "/foo",
+ Recursive: false,
+ WaitIndex: 0,
+ },
+ },
+
+ {
+ key: "/foo",
+ opts: &WatcherOptions{
+ Recursive: false,
+ AfterIndex: 0,
+ },
+ want: waitAction{
+ Key: "/foo",
+ Recursive: false,
+ WaitIndex: 0,
+ },
+ },
+
+ {
+ key: "/foo",
+ opts: &WatcherOptions{
+ Recursive: true,
+ AfterIndex: 0,
+ },
+ want: waitAction{
+ Key: "/foo",
+ Recursive: true,
+ WaitIndex: 0,
+ },
+ },
+
+ {
+ key: "/foo",
+ opts: &WatcherOptions{
+ Recursive: false,
+ AfterIndex: 19,
+ },
+ want: waitAction{
+ Key: "/foo",
+ Recursive: false,
+ WaitIndex: 20,
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ kAPI := &httpKeysAPI{
+ client: &staticHTTPClient{err: errors.New("fail!")},
+ }
+
+ want := &httpWatcher{
+ client: &staticHTTPClient{err: errors.New("fail!")},
+ nextWait: tt.want,
+ }
+
+ got := kAPI.Watcher(tt.key, tt.opts)
+ if !reflect.DeepEqual(want, got) {
+ t.Errorf("#%d: incorrect watcher: want=%#v got=%#v", i, want, got)
+ }
+ }
+}
+
+func TestHTTPKeysAPISetAction(t *testing.T) {
+ tests := []struct {
+ key string
+ value string
+ opts *SetOptions
+ wantAction httpAction
+ }{
+ // nil SetOptions
+ {
+ key: "/foo",
+ value: "bar",
+ opts: nil,
+ wantAction: &setAction{
+ Key: "/foo",
+ Value: "bar",
+ PrevValue: "",
+ PrevIndex: 0,
+ PrevExist: PrevIgnore,
+ TTL: 0,
+ },
+ },
+ // empty SetOptions
+ {
+ key: "/foo",
+ value: "bar",
+ opts: &SetOptions{},
+ wantAction: &setAction{
+ Key: "/foo",
+ Value: "bar",
+ PrevValue: "",
+ PrevIndex: 0,
+ PrevExist: PrevIgnore,
+ TTL: 0,
+ },
+ },
+ // populated SetOptions
+ {
+ key: "/foo",
+ value: "bar",
+ opts: &SetOptions{
+ PrevValue: "baz",
+ PrevIndex: 13,
+ PrevExist: PrevExist,
+ TTL: time.Minute,
+ Dir: true,
+ },
+ wantAction: &setAction{
+ Key: "/foo",
+ Value: "bar",
+ PrevValue: "baz",
+ PrevIndex: 13,
+ PrevExist: PrevExist,
+ TTL: time.Minute,
+ Dir: true,
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ client := &actionAssertingHTTPClient{t: t, num: i, act: tt.wantAction}
+ kAPI := httpKeysAPI{client: client}
+ kAPI.Set(context.Background(), tt.key, tt.value, tt.opts)
+ }
+}
+
+func TestHTTPKeysAPISetError(t *testing.T) {
+ tests := []httpClient{
+ // generic HTTP client failure
+ &staticHTTPClient{
+ err: errors.New("fail!"),
+ },
+
+ // unusable status code
+ &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusTeapot,
+ },
+ },
+
+ // etcd Error response
+ &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusInternalServerError,
+ },
+ body: []byte(`{"errorCode":300,"message":"Raft internal error","cause":"/foo","index":18}`),
+ },
+ }
+
+ for i, tt := range tests {
+ kAPI := httpKeysAPI{client: tt}
+ resp, err := kAPI.Set(context.Background(), "/foo", "bar", nil)
+ if err == nil {
+ t.Errorf("#%d: received nil error", i)
+ }
+ if resp != nil {
+ t.Errorf("#%d: received non-nil Response: %#v", i, resp)
+ }
+ }
+}
+
+func TestHTTPKeysAPISetResponse(t *testing.T) {
+ client := &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusOK,
+ Header: http.Header{"X-Etcd-Index": []string{"21"}},
+ },
+ body: []byte(`{"action":"set","node":{"key":"/pants/foo/bar/baz","value":"snarf","modifiedIndex":21,"createdIndex":21},"prevNode":{"key":"/pants/foo/bar/baz","value":"snazz","modifiedIndex":20,"createdIndex":19}}`),
+ }
+
+ wantResponse := &Response{
+ Action: "set",
+ Node: &Node{Key: "/pants/foo/bar/baz", Value: "snarf", CreatedIndex: uint64(21), ModifiedIndex: uint64(21)},
+ PrevNode: &Node{Key: "/pants/foo/bar/baz", Value: "snazz", CreatedIndex: uint64(19), ModifiedIndex: uint64(20)},
+ Index: uint64(21),
+ }
+
+ kAPI := &httpKeysAPI{client: client, prefix: "/pants"}
+ resp, err := kAPI.Set(context.Background(), "/foo/bar/baz", "snarf", nil)
+ if err != nil {
+ t.Errorf("non-nil error: %#v", err)
+ }
+ if !reflect.DeepEqual(wantResponse, resp) {
+ t.Errorf("incorrect Response: want=%#v got=%#v", wantResponse, resp)
+ }
+}
+
+func TestHTTPKeysAPIGetAction(t *testing.T) {
+ tests := []struct {
+ key string
+ opts *GetOptions
+ wantAction httpAction
+ }{
+ // nil GetOptions
+ {
+ key: "/foo",
+ opts: nil,
+ wantAction: &getAction{
+ Key: "/foo",
+ Sorted: false,
+ Recursive: false,
+ },
+ },
+ // empty GetOptions
+ {
+ key: "/foo",
+ opts: &GetOptions{},
+ wantAction: &getAction{
+ Key: "/foo",
+ Sorted: false,
+ Recursive: false,
+ },
+ },
+ // populated GetOptions
+ {
+ key: "/foo",
+ opts: &GetOptions{
+ Sort: true,
+ Recursive: true,
+ Quorum: true,
+ },
+ wantAction: &getAction{
+ Key: "/foo",
+ Sorted: true,
+ Recursive: true,
+ Quorum: true,
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ client := &actionAssertingHTTPClient{t: t, num: i, act: tt.wantAction}
+ kAPI := httpKeysAPI{client: client}
+ kAPI.Get(context.Background(), tt.key, tt.opts)
+ }
+}
+
+func TestHTTPKeysAPIGetError(t *testing.T) {
+ tests := []httpClient{
+ // generic HTTP client failure
+ &staticHTTPClient{
+ err: errors.New("fail!"),
+ },
+
+ // unusable status code
+ &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusTeapot,
+ },
+ },
+
+ // etcd Error response
+ &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusInternalServerError,
+ },
+ body: []byte(`{"errorCode":300,"message":"Raft internal error","cause":"/foo","index":18}`),
+ },
+ }
+
+ for i, tt := range tests {
+ kAPI := httpKeysAPI{client: tt}
+ resp, err := kAPI.Get(context.Background(), "/foo", nil)
+ if err == nil {
+ t.Errorf("#%d: received nil error", i)
+ }
+ if resp != nil {
+ t.Errorf("#%d: received non-nil Response: %#v", i, resp)
+ }
+ }
+}
+
+func TestHTTPKeysAPIGetResponse(t *testing.T) {
+ client := &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusOK,
+ Header: http.Header{"X-Etcd-Index": []string{"42"}},
+ },
+ body: []byte(`{"action":"get","node":{"key":"/pants/foo/bar","modifiedIndex":25,"createdIndex":19,"nodes":[{"key":"/pants/foo/bar/baz","value":"snarf","createdIndex":21,"modifiedIndex":25}]}}`),
+ }
+
+ wantResponse := &Response{
+ Action: "get",
+ Node: &Node{
+ Key: "/pants/foo/bar",
+ Nodes: []*Node{
+ {Key: "/pants/foo/bar/baz", Value: "snarf", CreatedIndex: 21, ModifiedIndex: 25},
+ },
+ CreatedIndex: uint64(19),
+ ModifiedIndex: uint64(25),
+ },
+ Index: uint64(42),
+ }
+
+ kAPI := &httpKeysAPI{client: client, prefix: "/pants"}
+ resp, err := kAPI.Get(context.Background(), "/foo/bar", &GetOptions{Recursive: true})
+ if err != nil {
+ t.Errorf("non-nil error: %#v", err)
+ }
+ if !reflect.DeepEqual(wantResponse, resp) {
+ t.Errorf("incorrect Response: want=%#v got=%#v", wantResponse, resp)
+ }
+}
+
+func TestHTTPKeysAPIDeleteAction(t *testing.T) {
+ tests := []struct {
+ key string
+ opts *DeleteOptions
+ wantAction httpAction
+ }{
+ // nil DeleteOptions
+ {
+ key: "/foo",
+ opts: nil,
+ wantAction: &deleteAction{
+ Key: "/foo",
+ PrevValue: "",
+ PrevIndex: 0,
+ Recursive: false,
+ },
+ },
+ // empty DeleteOptions
+ {
+ key: "/foo",
+ opts: &DeleteOptions{},
+ wantAction: &deleteAction{
+ Key: "/foo",
+ PrevValue: "",
+ PrevIndex: 0,
+ Recursive: false,
+ },
+ },
+ // populated DeleteOptions
+ {
+ key: "/foo",
+ opts: &DeleteOptions{
+ PrevValue: "baz",
+ PrevIndex: 13,
+ Recursive: true,
+ },
+ wantAction: &deleteAction{
+ Key: "/foo",
+ PrevValue: "baz",
+ PrevIndex: 13,
+ Recursive: true,
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ client := &actionAssertingHTTPClient{t: t, num: i, act: tt.wantAction}
+ kAPI := httpKeysAPI{client: client}
+ kAPI.Delete(context.Background(), tt.key, tt.opts)
+ }
+}
+
+func TestHTTPKeysAPIDeleteError(t *testing.T) {
+ tests := []httpClient{
+ // generic HTTP client failure
+ &staticHTTPClient{
+ err: errors.New("fail!"),
+ },
+
+ // unusable status code
+ &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusTeapot,
+ },
+ },
+
+ // etcd Error response
+ &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusInternalServerError,
+ },
+ body: []byte(`{"errorCode":300,"message":"Raft internal error","cause":"/foo","index":18}`),
+ },
+ }
+
+ for i, tt := range tests {
+ kAPI := httpKeysAPI{client: tt}
+ resp, err := kAPI.Delete(context.Background(), "/foo", nil)
+ if err == nil {
+ t.Errorf("#%d: received nil error", i)
+ }
+ if resp != nil {
+ t.Errorf("#%d: received non-nil Response: %#v", i, resp)
+ }
+ }
+}
+
+func TestHTTPKeysAPIDeleteResponse(t *testing.T) {
+ client := &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusOK,
+ Header: http.Header{"X-Etcd-Index": []string{"22"}},
+ },
+ body: []byte(`{"action":"delete","node":{"key":"/pants/foo/bar/baz","value":"snarf","modifiedIndex":22,"createdIndex":19},"prevNode":{"key":"/pants/foo/bar/baz","value":"snazz","modifiedIndex":20,"createdIndex":19}}`),
+ }
+
+ wantResponse := &Response{
+ Action: "delete",
+ Node: &Node{Key: "/pants/foo/bar/baz", Value: "snarf", CreatedIndex: uint64(19), ModifiedIndex: uint64(22)},
+ PrevNode: &Node{Key: "/pants/foo/bar/baz", Value: "snazz", CreatedIndex: uint64(19), ModifiedIndex: uint64(20)},
+ Index: uint64(22),
+ }
+
+ kAPI := &httpKeysAPI{client: client, prefix: "/pants"}
+ resp, err := kAPI.Delete(context.Background(), "/foo/bar/baz", nil)
+ if err != nil {
+ t.Errorf("non-nil error: %#v", err)
+ }
+ if !reflect.DeepEqual(wantResponse, resp) {
+ t.Errorf("incorrect Response: want=%#v got=%#v", wantResponse, resp)
+ }
+}
+
+func TestHTTPKeysAPICreateAction(t *testing.T) {
+ act := &setAction{
+ Key: "/foo",
+ Value: "bar",
+ PrevExist: PrevNoExist,
+ PrevIndex: 0,
+ PrevValue: "",
+ TTL: 0,
+ }
+
+ kAPI := httpKeysAPI{client: &actionAssertingHTTPClient{t: t, act: act}}
+ kAPI.Create(context.Background(), "/foo", "bar")
+}
+
+func TestHTTPKeysAPICreateInOrderAction(t *testing.T) {
+ act := &createInOrderAction{
+ Dir: "/foo",
+ Value: "bar",
+ TTL: 0,
+ }
+ kAPI := httpKeysAPI{client: &actionAssertingHTTPClient{t: t, act: act}}
+ kAPI.CreateInOrder(context.Background(), "/foo", "bar", nil)
+}
+
+func TestHTTPKeysAPIUpdateAction(t *testing.T) {
+ act := &setAction{
+ Key: "/foo",
+ Value: "bar",
+ PrevExist: PrevExist,
+ PrevIndex: 0,
+ PrevValue: "",
+ TTL: 0,
+ }
+
+ kAPI := httpKeysAPI{client: &actionAssertingHTTPClient{t: t, act: act}}
+ kAPI.Update(context.Background(), "/foo", "bar")
+}
+
+func TestNodeTTLDuration(t *testing.T) {
+ tests := []struct {
+ node *Node
+ want time.Duration
+ }{
+ {
+ node: &Node{TTL: 0},
+ want: 0,
+ },
+ {
+ node: &Node{TTL: 97},
+ want: 97 * time.Second,
+ },
+ }
+
+ for i, tt := range tests {
+ got := tt.node.TTLDuration()
+ if tt.want != got {
+ t.Errorf("#%d: incorrect duration: want=%v got=%v", i, tt.want, got)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/client/members.go b/vendor/github.com/coreos/etcd/client/members.go
new file mode 100644
index 00000000..23adf07a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/members.go
@@ -0,0 +1,304 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/url"
+ "path"
+
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/pkg/types"
+)
+
+var (
+ defaultV2MembersPrefix = "/v2/members"
+ defaultLeaderSuffix = "/leader"
+)
+
+type Member struct {
+ // ID is the unique identifier of this Member.
+ ID string `json:"id"`
+
+ // Name is a human-readable, non-unique identifier of this Member.
+ Name string `json:"name"`
+
+ // PeerURLs represents the HTTP(S) endpoints this Member uses to
+ // participate in etcd's consensus protocol.
+ PeerURLs []string `json:"peerURLs"`
+
+ // ClientURLs represents the HTTP(S) endpoints on which this Member
+ // serves it's client-facing APIs.
+ ClientURLs []string `json:"clientURLs"`
+}
+
+type memberCollection []Member
+
+func (c *memberCollection) UnmarshalJSON(data []byte) error {
+ d := struct {
+ Members []Member
+ }{}
+
+ if err := json.Unmarshal(data, &d); err != nil {
+ return err
+ }
+
+ if d.Members == nil {
+ *c = make([]Member, 0)
+ return nil
+ }
+
+ *c = d.Members
+ return nil
+}
+
+type memberCreateOrUpdateRequest struct {
+ PeerURLs types.URLs
+}
+
+func (m *memberCreateOrUpdateRequest) MarshalJSON() ([]byte, error) {
+ s := struct {
+ PeerURLs []string `json:"peerURLs"`
+ }{
+ PeerURLs: make([]string, len(m.PeerURLs)),
+ }
+
+ for i, u := range m.PeerURLs {
+ s.PeerURLs[i] = u.String()
+ }
+
+ return json.Marshal(&s)
+}
+
+// NewMembersAPI constructs a new MembersAPI that uses HTTP to
+// interact with etcd's membership API.
+func NewMembersAPI(c Client) MembersAPI {
+ return &httpMembersAPI{
+ client: c,
+ }
+}
+
+type MembersAPI interface {
+ // List enumerates the current cluster membership.
+ List(ctx context.Context) ([]Member, error)
+
+ // Add instructs etcd to accept a new Member into the cluster.
+ Add(ctx context.Context, peerURL string) (*Member, error)
+
+ // Remove demotes an existing Member out of the cluster.
+ Remove(ctx context.Context, mID string) error
+
+ // Update instructs etcd to update an existing Member in the cluster.
+ Update(ctx context.Context, mID string, peerURLs []string) error
+
+ // Leader gets current leader of the cluster
+ Leader(ctx context.Context) (*Member, error)
+}
+
+type httpMembersAPI struct {
+ client httpClient
+}
+
+func (m *httpMembersAPI) List(ctx context.Context) ([]Member, error) {
+ req := &membersAPIActionList{}
+ resp, body, err := m.client.Do(ctx, req)
+ if err != nil {
+ return nil, err
+ }
+
+ if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
+ return nil, err
+ }
+
+ var mCollection memberCollection
+ if err := json.Unmarshal(body, &mCollection); err != nil {
+ return nil, err
+ }
+
+ return []Member(mCollection), nil
+}
+
+func (m *httpMembersAPI) Add(ctx context.Context, peerURL string) (*Member, error) {
+ urls, err := types.NewURLs([]string{peerURL})
+ if err != nil {
+ return nil, err
+ }
+
+ req := &membersAPIActionAdd{peerURLs: urls}
+ resp, body, err := m.client.Do(ctx, req)
+ if err != nil {
+ return nil, err
+ }
+
+ if err := assertStatusCode(resp.StatusCode, http.StatusCreated, http.StatusConflict); err != nil {
+ return nil, err
+ }
+
+ if resp.StatusCode != http.StatusCreated {
+ var merr membersError
+ if err := json.Unmarshal(body, &merr); err != nil {
+ return nil, err
+ }
+ return nil, merr
+ }
+
+ var memb Member
+ if err := json.Unmarshal(body, &memb); err != nil {
+ return nil, err
+ }
+
+ return &memb, nil
+}
+
+func (m *httpMembersAPI) Update(ctx context.Context, memberID string, peerURLs []string) error {
+ urls, err := types.NewURLs(peerURLs)
+ if err != nil {
+ return err
+ }
+
+ req := &membersAPIActionUpdate{peerURLs: urls, memberID: memberID}
+ resp, body, err := m.client.Do(ctx, req)
+ if err != nil {
+ return err
+ }
+
+ if err := assertStatusCode(resp.StatusCode, http.StatusNoContent, http.StatusNotFound, http.StatusConflict); err != nil {
+ return err
+ }
+
+ if resp.StatusCode != http.StatusNoContent {
+ var merr membersError
+ if err := json.Unmarshal(body, &merr); err != nil {
+ return err
+ }
+ return merr
+ }
+
+ return nil
+}
+
+func (m *httpMembersAPI) Remove(ctx context.Context, memberID string) error {
+ req := &membersAPIActionRemove{memberID: memberID}
+ resp, _, err := m.client.Do(ctx, req)
+ if err != nil {
+ return err
+ }
+
+ return assertStatusCode(resp.StatusCode, http.StatusNoContent, http.StatusGone)
+}
+
+func (m *httpMembersAPI) Leader(ctx context.Context) (*Member, error) {
+ req := &membersAPIActionLeader{}
+ resp, body, err := m.client.Do(ctx, req)
+ if err != nil {
+ return nil, err
+ }
+
+ if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
+ return nil, err
+ }
+
+ var leader Member
+ if err := json.Unmarshal(body, &leader); err != nil {
+ return nil, err
+ }
+
+ return &leader, nil
+}
+
+type membersAPIActionList struct{}
+
+func (l *membersAPIActionList) HTTPRequest(ep url.URL) *http.Request {
+ u := v2MembersURL(ep)
+ req, _ := http.NewRequest("GET", u.String(), nil)
+ return req
+}
+
+type membersAPIActionRemove struct {
+ memberID string
+}
+
+func (d *membersAPIActionRemove) HTTPRequest(ep url.URL) *http.Request {
+ u := v2MembersURL(ep)
+ u.Path = path.Join(u.Path, d.memberID)
+ req, _ := http.NewRequest("DELETE", u.String(), nil)
+ return req
+}
+
+type membersAPIActionAdd struct {
+ peerURLs types.URLs
+}
+
+func (a *membersAPIActionAdd) HTTPRequest(ep url.URL) *http.Request {
+ u := v2MembersURL(ep)
+ m := memberCreateOrUpdateRequest{PeerURLs: a.peerURLs}
+ b, _ := json.Marshal(&m)
+ req, _ := http.NewRequest("POST", u.String(), bytes.NewReader(b))
+ req.Header.Set("Content-Type", "application/json")
+ return req
+}
+
+type membersAPIActionUpdate struct {
+ memberID string
+ peerURLs types.URLs
+}
+
+func (a *membersAPIActionUpdate) HTTPRequest(ep url.URL) *http.Request {
+ u := v2MembersURL(ep)
+ m := memberCreateOrUpdateRequest{PeerURLs: a.peerURLs}
+ u.Path = path.Join(u.Path, a.memberID)
+ b, _ := json.Marshal(&m)
+ req, _ := http.NewRequest("PUT", u.String(), bytes.NewReader(b))
+ req.Header.Set("Content-Type", "application/json")
+ return req
+}
+
+func assertStatusCode(got int, want ...int) (err error) {
+ for _, w := range want {
+ if w == got {
+ return nil
+ }
+ }
+ return fmt.Errorf("unexpected status code %d", got)
+}
+
+type membersAPIActionLeader struct{}
+
+func (l *membersAPIActionLeader) HTTPRequest(ep url.URL) *http.Request {
+ u := v2MembersURL(ep)
+ u.Path = path.Join(u.Path, defaultLeaderSuffix)
+ req, _ := http.NewRequest("GET", u.String(), nil)
+ return req
+}
+
+// v2MembersURL add the necessary path to the provided endpoint
+// to route requests to the default v2 members API.
+func v2MembersURL(ep url.URL) *url.URL {
+ ep.Path = path.Join(ep.Path, defaultV2MembersPrefix)
+ return &ep
+}
+
+type membersError struct {
+ Message string `json:"message"`
+ Code int `json:"-"`
+}
+
+func (e membersError) Error() string {
+ return e.Message
+}
diff --git a/vendor/github.com/coreos/etcd/client/members_test.go b/vendor/github.com/coreos/etcd/client/members_test.go
new file mode 100644
index 00000000..f199db2c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/members_test.go
@@ -0,0 +1,599 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client
+
+import (
+ "encoding/json"
+ "errors"
+ "net/http"
+ "net/url"
+ "reflect"
+ "testing"
+
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/pkg/types"
+)
+
+func TestMembersAPIActionList(t *testing.T) {
+ ep := url.URL{Scheme: "http", Host: "example.com"}
+ act := &membersAPIActionList{}
+
+ wantURL := &url.URL{
+ Scheme: "http",
+ Host: "example.com",
+ Path: "/v2/members",
+ }
+
+ got := *act.HTTPRequest(ep)
+ err := assertRequest(got, "GET", wantURL, http.Header{}, nil)
+ if err != nil {
+ t.Error(err.Error())
+ }
+}
+
+func TestMembersAPIActionAdd(t *testing.T) {
+ ep := url.URL{Scheme: "http", Host: "example.com"}
+ act := &membersAPIActionAdd{
+ peerURLs: types.URLs([]url.URL{
+ {Scheme: "https", Host: "127.0.0.1:8081"},
+ {Scheme: "http", Host: "127.0.0.1:8080"},
+ }),
+ }
+
+ wantURL := &url.URL{
+ Scheme: "http",
+ Host: "example.com",
+ Path: "/v2/members",
+ }
+ wantHeader := http.Header{
+ "Content-Type": []string{"application/json"},
+ }
+ wantBody := []byte(`{"peerURLs":["https://127.0.0.1:8081","http://127.0.0.1:8080"]}`)
+
+ got := *act.HTTPRequest(ep)
+ err := assertRequest(got, "POST", wantURL, wantHeader, wantBody)
+ if err != nil {
+ t.Error(err.Error())
+ }
+}
+
+func TestMembersAPIActionUpdate(t *testing.T) {
+ ep := url.URL{Scheme: "http", Host: "example.com"}
+ act := &membersAPIActionUpdate{
+ memberID: "0xabcd",
+ peerURLs: types.URLs([]url.URL{
+ {Scheme: "https", Host: "127.0.0.1:8081"},
+ {Scheme: "http", Host: "127.0.0.1:8080"},
+ }),
+ }
+
+ wantURL := &url.URL{
+ Scheme: "http",
+ Host: "example.com",
+ Path: "/v2/members/0xabcd",
+ }
+ wantHeader := http.Header{
+ "Content-Type": []string{"application/json"},
+ }
+ wantBody := []byte(`{"peerURLs":["https://127.0.0.1:8081","http://127.0.0.1:8080"]}`)
+
+ got := *act.HTTPRequest(ep)
+ err := assertRequest(got, "PUT", wantURL, wantHeader, wantBody)
+ if err != nil {
+ t.Error(err.Error())
+ }
+}
+
+func TestMembersAPIActionRemove(t *testing.T) {
+ ep := url.URL{Scheme: "http", Host: "example.com"}
+ act := &membersAPIActionRemove{memberID: "XXX"}
+
+ wantURL := &url.URL{
+ Scheme: "http",
+ Host: "example.com",
+ Path: "/v2/members/XXX",
+ }
+
+ got := *act.HTTPRequest(ep)
+ err := assertRequest(got, "DELETE", wantURL, http.Header{}, nil)
+ if err != nil {
+ t.Error(err.Error())
+ }
+}
+
+func TestMembersAPIActionLeader(t *testing.T) {
+ ep := url.URL{Scheme: "http", Host: "example.com"}
+ act := &membersAPIActionLeader{}
+
+ wantURL := &url.URL{
+ Scheme: "http",
+ Host: "example.com",
+ Path: "/v2/members/leader",
+ }
+
+ got := *act.HTTPRequest(ep)
+ err := assertRequest(got, "GET", wantURL, http.Header{}, nil)
+ if err != nil {
+ t.Error(err.Error())
+ }
+}
+
+func TestAssertStatusCode(t *testing.T) {
+ if err := assertStatusCode(404, 400); err == nil {
+ t.Errorf("assertStatusCode failed to detect conflict in 400 vs 404")
+ }
+
+ if err := assertStatusCode(404, 400, 404); err != nil {
+ t.Errorf("assertStatusCode found conflict in (404,400) vs 400: %v", err)
+ }
+}
+
+func TestV2MembersURL(t *testing.T) {
+ got := v2MembersURL(url.URL{
+ Scheme: "http",
+ Host: "foo.example.com:4002",
+ Path: "/pants",
+ })
+ want := &url.URL{
+ Scheme: "http",
+ Host: "foo.example.com:4002",
+ Path: "/pants/v2/members",
+ }
+
+ if !reflect.DeepEqual(want, got) {
+ t.Fatalf("v2MembersURL got %#v, want %#v", got, want)
+ }
+}
+
+func TestMemberUnmarshal(t *testing.T) {
+ tests := []struct {
+ body []byte
+ wantMember Member
+ wantError bool
+ }{
+ // no URLs, just check ID & Name
+ {
+ body: []byte(`{"id": "c", "name": "dungarees"}`),
+ wantMember: Member{ID: "c", Name: "dungarees", PeerURLs: nil, ClientURLs: nil},
+ },
+
+ // both client and peer URLs
+ {
+ body: []byte(`{"peerURLs": ["http://127.0.0.1:2379"], "clientURLs": ["http://127.0.0.1:2379"]}`),
+ wantMember: Member{
+ PeerURLs: []string{
+ "http://127.0.0.1:2379",
+ },
+ ClientURLs: []string{
+ "http://127.0.0.1:2379",
+ },
+ },
+ },
+
+ // multiple peer URLs
+ {
+ body: []byte(`{"peerURLs": ["http://127.0.0.1:2379", "https://example.com"]}`),
+ wantMember: Member{
+ PeerURLs: []string{
+ "http://127.0.0.1:2379",
+ "https://example.com",
+ },
+ ClientURLs: nil,
+ },
+ },
+
+ // multiple client URLs
+ {
+ body: []byte(`{"clientURLs": ["http://127.0.0.1:2379", "https://example.com"]}`),
+ wantMember: Member{
+ PeerURLs: nil,
+ ClientURLs: []string{
+ "http://127.0.0.1:2379",
+ "https://example.com",
+ },
+ },
+ },
+
+ // invalid JSON
+ {
+ body: []byte(`{"peerU`),
+ wantError: true,
+ },
+ }
+
+ for i, tt := range tests {
+ got := Member{}
+ err := json.Unmarshal(tt.body, &got)
+ if tt.wantError != (err != nil) {
+ t.Errorf("#%d: want error %t, got %v", i, tt.wantError, err)
+ continue
+ }
+
+ if !reflect.DeepEqual(tt.wantMember, got) {
+ t.Errorf("#%d: incorrect output: want=%#v, got=%#v", i, tt.wantMember, got)
+ }
+ }
+}
+
+func TestMemberCollectionUnmarshalFail(t *testing.T) {
+ mc := &memberCollection{}
+ if err := mc.UnmarshalJSON([]byte(`{`)); err == nil {
+ t.Errorf("got nil error")
+ }
+}
+
+func TestMemberCollectionUnmarshal(t *testing.T) {
+ tests := []struct {
+ body []byte
+ want memberCollection
+ }{
+ {
+ body: []byte(`{}`),
+ want: memberCollection([]Member{}),
+ },
+ {
+ body: []byte(`{"members":[]}`),
+ want: memberCollection([]Member{}),
+ },
+ {
+ body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
+ want: memberCollection(
+ []Member{
+ {
+ ID: "2745e2525fce8fe",
+ Name: "node3",
+ PeerURLs: []string{
+ "http://127.0.0.1:7003",
+ },
+ ClientURLs: []string{
+ "http://127.0.0.1:4003",
+ },
+ },
+ {
+ ID: "42134f434382925",
+ Name: "node1",
+ PeerURLs: []string{
+ "http://127.0.0.1:2380",
+ "http://127.0.0.1:7001",
+ },
+ ClientURLs: []string{
+ "http://127.0.0.1:2379",
+ "http://127.0.0.1:4001",
+ },
+ },
+ {
+ ID: "94088180e21eb87b",
+ Name: "node2",
+ PeerURLs: []string{
+ "http://127.0.0.1:7002",
+ },
+ ClientURLs: []string{
+ "http://127.0.0.1:4002",
+ },
+ },
+ },
+ ),
+ },
+ }
+
+ for i, tt := range tests {
+ var got memberCollection
+ err := json.Unmarshal(tt.body, &got)
+ if err != nil {
+ t.Errorf("#%d: unexpected error: %v", i, err)
+ continue
+ }
+
+ if !reflect.DeepEqual(tt.want, got) {
+ t.Errorf("#%d: incorrect output: want=%#v, got=%#v", i, tt.want, got)
+ }
+ }
+}
+
+func TestMemberCreateRequestMarshal(t *testing.T) {
+ req := memberCreateOrUpdateRequest{
+ PeerURLs: types.URLs([]url.URL{
+ {Scheme: "http", Host: "127.0.0.1:8081"},
+ {Scheme: "https", Host: "127.0.0.1:8080"},
+ }),
+ }
+ want := []byte(`{"peerURLs":["http://127.0.0.1:8081","https://127.0.0.1:8080"]}`)
+
+ got, err := json.Marshal(&req)
+ if err != nil {
+ t.Fatalf("Marshal returned unexpected err=%v", err)
+ }
+
+ if !reflect.DeepEqual(want, got) {
+ t.Fatalf("Failed to marshal memberCreateRequest: want=%s, got=%s", want, got)
+ }
+}
+
+func TestHTTPMembersAPIAddSuccess(t *testing.T) {
+ wantAction := &membersAPIActionAdd{
+ peerURLs: types.URLs([]url.URL{
+ {Scheme: "http", Host: "127.0.0.1:7002"},
+ }),
+ }
+
+ mAPI := &httpMembersAPI{
+ client: &actionAssertingHTTPClient{
+ t: t,
+ act: wantAction,
+ resp: http.Response{
+ StatusCode: http.StatusCreated,
+ },
+ body: []byte(`{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"]}`),
+ },
+ }
+
+ wantResponseMember := &Member{
+ ID: "94088180e21eb87b",
+ PeerURLs: []string{"http://127.0.0.1:7002"},
+ }
+
+ m, err := mAPI.Add(context.Background(), "http://127.0.0.1:7002")
+ if err != nil {
+ t.Errorf("got non-nil err: %#v", err)
+ }
+ if !reflect.DeepEqual(wantResponseMember, m) {
+ t.Errorf("incorrect Member: want=%#v got=%#v", wantResponseMember, m)
+ }
+}
+
+func TestHTTPMembersAPIAddError(t *testing.T) {
+ okPeer := "http://example.com:2379"
+ tests := []struct {
+ peerURL string
+ client httpClient
+
+ // if wantErr == nil, assert that the returned error is non-nil
+ // if wantErr != nil, assert that the returned error matches
+ wantErr error
+ }{
+ // malformed peer URL
+ {
+ peerURL: ":",
+ },
+
+ // generic httpClient failure
+ {
+ peerURL: okPeer,
+ client: &staticHTTPClient{err: errors.New("fail!")},
+ },
+
+ // unrecognized HTTP status code
+ {
+ peerURL: okPeer,
+ client: &staticHTTPClient{
+ resp: http.Response{StatusCode: http.StatusTeapot},
+ },
+ },
+
+ // unmarshal body into membersError on StatusConflict
+ {
+ peerURL: okPeer,
+ client: &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusConflict,
+ },
+ body: []byte(`{"message":"fail!"}`),
+ },
+ wantErr: membersError{Message: "fail!"},
+ },
+
+ // fail to unmarshal body on StatusConflict
+ {
+ peerURL: okPeer,
+ client: &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusConflict,
+ },
+ body: []byte(`{"`),
+ },
+ },
+
+ // fail to unmarshal body on StatusCreated
+ {
+ peerURL: okPeer,
+ client: &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusCreated,
+ },
+ body: []byte(`{"id":"XX`),
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ mAPI := &httpMembersAPI{client: tt.client}
+ m, err := mAPI.Add(context.Background(), tt.peerURL)
+ if err == nil {
+ t.Errorf("#%d: got nil err", i)
+ }
+ if tt.wantErr != nil && !reflect.DeepEqual(tt.wantErr, err) {
+ t.Errorf("#%d: incorrect error: want=%#v got=%#v", i, tt.wantErr, err)
+ }
+ if m != nil {
+ t.Errorf("#%d: got non-nil Member", i)
+ }
+ }
+}
+
+func TestHTTPMembersAPIRemoveSuccess(t *testing.T) {
+ wantAction := &membersAPIActionRemove{
+ memberID: "94088180e21eb87b",
+ }
+
+ mAPI := &httpMembersAPI{
+ client: &actionAssertingHTTPClient{
+ t: t,
+ act: wantAction,
+ resp: http.Response{
+ StatusCode: http.StatusNoContent,
+ },
+ },
+ }
+
+ if err := mAPI.Remove(context.Background(), "94088180e21eb87b"); err != nil {
+ t.Errorf("got non-nil err: %#v", err)
+ }
+}
+
+func TestHTTPMembersAPIRemoveFail(t *testing.T) {
+ tests := []httpClient{
+ // generic error
+ &staticHTTPClient{
+ err: errors.New("fail!"),
+ },
+
+ // unexpected HTTP status code
+ &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusInternalServerError,
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ mAPI := &httpMembersAPI{client: tt}
+ if err := mAPI.Remove(context.Background(), "94088180e21eb87b"); err == nil {
+ t.Errorf("#%d: got nil err", i)
+ }
+ }
+}
+
+func TestHTTPMembersAPIListSuccess(t *testing.T) {
+ wantAction := &membersAPIActionList{}
+ mAPI := &httpMembersAPI{
+ client: &actionAssertingHTTPClient{
+ t: t,
+ act: wantAction,
+ resp: http.Response{
+ StatusCode: http.StatusOK,
+ },
+ body: []byte(`{"members":[{"id":"94088180e21eb87b","name":"node2","peerURLs":["http://127.0.0.1:7002"],"clientURLs":["http://127.0.0.1:4002"]}]}`),
+ },
+ }
+
+ wantResponseMembers := []Member{
+ {
+ ID: "94088180e21eb87b",
+ Name: "node2",
+ PeerURLs: []string{"http://127.0.0.1:7002"},
+ ClientURLs: []string{"http://127.0.0.1:4002"},
+ },
+ }
+
+ m, err := mAPI.List(context.Background())
+ if err != nil {
+ t.Errorf("got non-nil err: %#v", err)
+ }
+ if !reflect.DeepEqual(wantResponseMembers, m) {
+ t.Errorf("incorrect Members: want=%#v got=%#v", wantResponseMembers, m)
+ }
+}
+
+func TestHTTPMembersAPIListError(t *testing.T) {
+ tests := []httpClient{
+ // generic httpClient failure
+ &staticHTTPClient{err: errors.New("fail!")},
+
+ // unrecognized HTTP status code
+ &staticHTTPClient{
+ resp: http.Response{StatusCode: http.StatusTeapot},
+ },
+
+ // fail to unmarshal body on StatusOK
+ &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusOK,
+ },
+ body: []byte(`[{"id":"XX`),
+ },
+ }
+
+ for i, tt := range tests {
+ mAPI := &httpMembersAPI{client: tt}
+ ms, err := mAPI.List(context.Background())
+ if err == nil {
+ t.Errorf("#%d: got nil err", i)
+ }
+ if ms != nil {
+ t.Errorf("#%d: got non-nil Member slice", i)
+ }
+ }
+}
+
+func TestHTTPMembersAPILeaderSuccess(t *testing.T) {
+ wantAction := &membersAPIActionLeader{}
+ mAPI := &httpMembersAPI{
+ client: &actionAssertingHTTPClient{
+ t: t,
+ act: wantAction,
+ resp: http.Response{
+ StatusCode: http.StatusOK,
+ },
+ body: []byte(`{"id":"94088180e21eb87b","name":"node2","peerURLs":["http://127.0.0.1:7002"],"clientURLs":["http://127.0.0.1:4002"]}`),
+ },
+ }
+
+ wantResponseMember := &Member{
+ ID: "94088180e21eb87b",
+ Name: "node2",
+ PeerURLs: []string{"http://127.0.0.1:7002"},
+ ClientURLs: []string{"http://127.0.0.1:4002"},
+ }
+
+ m, err := mAPI.Leader(context.Background())
+ if err != nil {
+ t.Errorf("err = %v, want %v", err, nil)
+ }
+ if !reflect.DeepEqual(wantResponseMember, m) {
+ t.Errorf("incorrect member: member = %v, want %v", wantResponseMember, m)
+ }
+}
+
+func TestHTTPMembersAPILeaderError(t *testing.T) {
+ tests := []httpClient{
+ // generic httpClient failure
+ &staticHTTPClient{err: errors.New("fail!")},
+
+ // unrecognized HTTP status code
+ &staticHTTPClient{
+ resp: http.Response{StatusCode: http.StatusTeapot},
+ },
+
+ // fail to unmarshal body on StatusOK
+ &staticHTTPClient{
+ resp: http.Response{
+ StatusCode: http.StatusOK,
+ },
+ body: []byte(`[{"id":"XX`),
+ },
+ }
+
+ for i, tt := range tests {
+ mAPI := &httpMembersAPI{client: tt}
+ m, err := mAPI.Leader(context.Background())
+ if err == nil {
+ t.Errorf("#%d: err = nil, want not nil", i)
+ }
+ if m != nil {
+ t.Errorf("member slice = %v, want nil", m)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/client/util.go b/vendor/github.com/coreos/etcd/client/util.go
new file mode 100644
index 00000000..15a8babf
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/client/util.go
@@ -0,0 +1,53 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 client
+
+import (
+ "regexp"
+)
+
+var (
+ roleNotFoundRegExp *regexp.Regexp
+ userNotFoundRegExp *regexp.Regexp
+)
+
+func init() {
+ roleNotFoundRegExp = regexp.MustCompile("auth: Role .* does not exist.")
+ userNotFoundRegExp = regexp.MustCompile("auth: User .* does not exist.")
+}
+
+// IsKeyNotFound returns true if the error code is ErrorCodeKeyNotFound.
+func IsKeyNotFound(err error) bool {
+ if cErr, ok := err.(Error); ok {
+ return cErr.Code == ErrorCodeKeyNotFound
+ }
+ return false
+}
+
+// IsRoleNotFound returns true if the error means role not found of v2 API.
+func IsRoleNotFound(err error) bool {
+ if ae, ok := err.(authError); ok {
+ return roleNotFoundRegExp.MatchString(ae.Message)
+ }
+ return false
+}
+
+// IsUserNotFound returns true if the error means user not found of v2 API.
+func IsUserNotFound(err error) bool {
+ if ae, ok := err.(authError); ok {
+ return userNotFoundRegExp.MatchString(ae.Message)
+ }
+ return false
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/README.md b/vendor/github.com/coreos/etcd/clientv3/README.md
new file mode 100644
index 00000000..643d0e2f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/README.md
@@ -0,0 +1,85 @@
+# etcd/clientv3
+
+[![Godoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://godoc.org/github.com/coreos/etcd/clientv3)
+
+`etcd/clientv3` is the official Go etcd client for v3.
+
+## Install
+
+```bash
+go get github.com/coreos/etcd/clientv3
+```
+
+## Get started
+
+Create client using `clientv3.New`:
+
+```go
+cli, err := clientv3.New(clientv3.Config{
+ Endpoints: []string{"localhost:2379", "localhost:22379", "localhost:32379"},
+ DialTimeout: 5 * time.Second,
+})
+if err != nil {
+ // handle error!
+}
+defer cli.Close()
+```
+
+etcd v3 uses [`gRPC`](http://www.grpc.io) for remote procedure calls. And `clientv3` uses
+[`grpc-go`](https://github.com/grpc/grpc-go) to connect to etcd. Make sure to close the client after using it.
+If the client is not closed, the connection will have leaky goroutines. To specify client request timeout,
+pass `context.WithTimeout` to APIs:
+
+```go
+ctx, cancel := context.WithTimeout(context.Background(), timeout)
+resp, err := cli.Put(ctx, "sample_key", "sample_value")
+cancel()
+if err != nil {
+ // handle error!
+}
+// use the response
+```
+
+etcd uses `cmd/vendor` directory to store external dependencies, which are
+to be compiled into etcd release binaries. `client` can be imported without
+vendoring. For full compatibility, it is recommended to vendor builds using
+etcd's vendored packages, using tools like godep, as in
+[vendor directories](https://golang.org/cmd/go/#hdr-Vendor_Directories).
+For more detail, please read [Go vendor design](https://golang.org/s/go15vendor).
+
+## Error Handling
+
+etcd client returns 2 types of errors:
+
+1. context error: canceled or deadline exceeded.
+2. gRPC error: see [api/v3rpc/rpctypes](https://godoc.org/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes).
+
+Here is the example code to handle client errors:
+
+```go
+resp, err := cli.Put(ctx, "", "")
+if err != nil {
+ switch err {
+ case context.Canceled:
+ log.Fatalf("ctx is canceled by another routine: %v", err)
+ case context.DeadlineExceeded:
+ log.Fatalf("ctx is attached with a deadline is exceeded: %v", err)
+ case rpctypes.ErrEmptyKey:
+ log.Fatalf("client-side error: %v", err)
+ default:
+ log.Fatalf("bad cluster endpoints, which are not etcd servers: %v", err)
+ }
+}
+```
+
+## Metrics
+
+The etcd client optionally exposes RPC metrics through [go-grpc-prometheus](https://github.com/grpc-ecosystem/go-grpc-prometheus). See the [examples](https://github.com/coreos/etcd/blob/master/clientv3/example_metrics_test.go).
+
+## Namespacing
+
+The [namespace](https://godoc.org/github.com/coreos/etcd/clientv3/namespace) package provides `clientv3` interface wrappers to transparently isolate client requests to a user-defined prefix.
+
+## Examples
+
+More code examples can be found at [GoDoc](https://godoc.org/github.com/coreos/etcd/clientv3).
diff --git a/vendor/github.com/coreos/etcd/clientv3/auth.go b/vendor/github.com/coreos/etcd/clientv3/auth.go
new file mode 100644
index 00000000..18f1f5b0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/auth.go
@@ -0,0 +1,222 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/coreos/etcd/auth/authpb"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+type (
+ AuthEnableResponse pb.AuthEnableResponse
+ AuthDisableResponse pb.AuthDisableResponse
+ AuthenticateResponse pb.AuthenticateResponse
+ AuthUserAddResponse pb.AuthUserAddResponse
+ AuthUserDeleteResponse pb.AuthUserDeleteResponse
+ AuthUserChangePasswordResponse pb.AuthUserChangePasswordResponse
+ AuthUserGrantRoleResponse pb.AuthUserGrantRoleResponse
+ AuthUserGetResponse pb.AuthUserGetResponse
+ AuthUserRevokeRoleResponse pb.AuthUserRevokeRoleResponse
+ AuthRoleAddResponse pb.AuthRoleAddResponse
+ AuthRoleGrantPermissionResponse pb.AuthRoleGrantPermissionResponse
+ AuthRoleGetResponse pb.AuthRoleGetResponse
+ AuthRoleRevokePermissionResponse pb.AuthRoleRevokePermissionResponse
+ AuthRoleDeleteResponse pb.AuthRoleDeleteResponse
+ AuthUserListResponse pb.AuthUserListResponse
+ AuthRoleListResponse pb.AuthRoleListResponse
+
+ PermissionType authpb.Permission_Type
+ Permission authpb.Permission
+)
+
+const (
+ PermRead = authpb.READ
+ PermWrite = authpb.WRITE
+ PermReadWrite = authpb.READWRITE
+)
+
+type Auth interface {
+ // AuthEnable enables auth of an etcd cluster.
+ AuthEnable(ctx context.Context) (*AuthEnableResponse, error)
+
+ // AuthDisable disables auth of an etcd cluster.
+ AuthDisable(ctx context.Context) (*AuthDisableResponse, error)
+
+ // UserAdd adds a new user to an etcd cluster.
+ UserAdd(ctx context.Context, name string, password string) (*AuthUserAddResponse, error)
+
+ // UserDelete deletes a user from an etcd cluster.
+ UserDelete(ctx context.Context, name string) (*AuthUserDeleteResponse, error)
+
+ // UserChangePassword changes a password of a user.
+ UserChangePassword(ctx context.Context, name string, password string) (*AuthUserChangePasswordResponse, error)
+
+ // UserGrantRole grants a role to a user.
+ UserGrantRole(ctx context.Context, user string, role string) (*AuthUserGrantRoleResponse, error)
+
+ // UserGet gets a detailed information of a user.
+ UserGet(ctx context.Context, name string) (*AuthUserGetResponse, error)
+
+ // UserList gets a list of all users.
+ UserList(ctx context.Context) (*AuthUserListResponse, error)
+
+ // UserRevokeRole revokes a role of a user.
+ UserRevokeRole(ctx context.Context, name string, role string) (*AuthUserRevokeRoleResponse, error)
+
+ // RoleAdd adds a new role to an etcd cluster.
+ RoleAdd(ctx context.Context, name string) (*AuthRoleAddResponse, error)
+
+ // RoleGrantPermission grants a permission to a role.
+ RoleGrantPermission(ctx context.Context, name string, key, rangeEnd string, permType PermissionType) (*AuthRoleGrantPermissionResponse, error)
+
+ // RoleGet gets a detailed information of a role.
+ RoleGet(ctx context.Context, role string) (*AuthRoleGetResponse, error)
+
+ // RoleList gets a list of all roles.
+ RoleList(ctx context.Context) (*AuthRoleListResponse, error)
+
+ // RoleRevokePermission revokes a permission from a role.
+ RoleRevokePermission(ctx context.Context, role string, key, rangeEnd string) (*AuthRoleRevokePermissionResponse, error)
+
+ // RoleDelete deletes a role.
+ RoleDelete(ctx context.Context, role string) (*AuthRoleDeleteResponse, error)
+}
+
+type auth struct {
+ remote pb.AuthClient
+}
+
+func NewAuth(c *Client) Auth {
+ return &auth{remote: pb.NewAuthClient(c.ActiveConnection())}
+}
+
+func (auth *auth) AuthEnable(ctx context.Context) (*AuthEnableResponse, error) {
+ resp, err := auth.remote.AuthEnable(ctx, &pb.AuthEnableRequest{}, grpc.FailFast(false))
+ return (*AuthEnableResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *auth) AuthDisable(ctx context.Context) (*AuthDisableResponse, error) {
+ resp, err := auth.remote.AuthDisable(ctx, &pb.AuthDisableRequest{}, grpc.FailFast(false))
+ return (*AuthDisableResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *auth) UserAdd(ctx context.Context, name string, password string) (*AuthUserAddResponse, error) {
+ resp, err := auth.remote.UserAdd(ctx, &pb.AuthUserAddRequest{Name: name, Password: password})
+ return (*AuthUserAddResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *auth) UserDelete(ctx context.Context, name string) (*AuthUserDeleteResponse, error) {
+ resp, err := auth.remote.UserDelete(ctx, &pb.AuthUserDeleteRequest{Name: name})
+ return (*AuthUserDeleteResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *auth) UserChangePassword(ctx context.Context, name string, password string) (*AuthUserChangePasswordResponse, error) {
+ resp, err := auth.remote.UserChangePassword(ctx, &pb.AuthUserChangePasswordRequest{Name: name, Password: password})
+ return (*AuthUserChangePasswordResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *auth) UserGrantRole(ctx context.Context, user string, role string) (*AuthUserGrantRoleResponse, error) {
+ resp, err := auth.remote.UserGrantRole(ctx, &pb.AuthUserGrantRoleRequest{User: user, Role: role})
+ return (*AuthUserGrantRoleResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *auth) UserGet(ctx context.Context, name string) (*AuthUserGetResponse, error) {
+ resp, err := auth.remote.UserGet(ctx, &pb.AuthUserGetRequest{Name: name}, grpc.FailFast(false))
+ return (*AuthUserGetResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *auth) UserList(ctx context.Context) (*AuthUserListResponse, error) {
+ resp, err := auth.remote.UserList(ctx, &pb.AuthUserListRequest{}, grpc.FailFast(false))
+ return (*AuthUserListResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *auth) UserRevokeRole(ctx context.Context, name string, role string) (*AuthUserRevokeRoleResponse, error) {
+ resp, err := auth.remote.UserRevokeRole(ctx, &pb.AuthUserRevokeRoleRequest{Name: name, Role: role})
+ return (*AuthUserRevokeRoleResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *auth) RoleAdd(ctx context.Context, name string) (*AuthRoleAddResponse, error) {
+ resp, err := auth.remote.RoleAdd(ctx, &pb.AuthRoleAddRequest{Name: name})
+ return (*AuthRoleAddResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *auth) RoleGrantPermission(ctx context.Context, name string, key, rangeEnd string, permType PermissionType) (*AuthRoleGrantPermissionResponse, error) {
+ perm := &authpb.Permission{
+ Key: []byte(key),
+ RangeEnd: []byte(rangeEnd),
+ PermType: authpb.Permission_Type(permType),
+ }
+ resp, err := auth.remote.RoleGrantPermission(ctx, &pb.AuthRoleGrantPermissionRequest{Name: name, Perm: perm})
+ return (*AuthRoleGrantPermissionResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *auth) RoleGet(ctx context.Context, role string) (*AuthRoleGetResponse, error) {
+ resp, err := auth.remote.RoleGet(ctx, &pb.AuthRoleGetRequest{Role: role}, grpc.FailFast(false))
+ return (*AuthRoleGetResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *auth) RoleList(ctx context.Context) (*AuthRoleListResponse, error) {
+ resp, err := auth.remote.RoleList(ctx, &pb.AuthRoleListRequest{}, grpc.FailFast(false))
+ return (*AuthRoleListResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *auth) RoleRevokePermission(ctx context.Context, role string, key, rangeEnd string) (*AuthRoleRevokePermissionResponse, error) {
+ resp, err := auth.remote.RoleRevokePermission(ctx, &pb.AuthRoleRevokePermissionRequest{Role: role, Key: key, RangeEnd: rangeEnd})
+ return (*AuthRoleRevokePermissionResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *auth) RoleDelete(ctx context.Context, role string) (*AuthRoleDeleteResponse, error) {
+ resp, err := auth.remote.RoleDelete(ctx, &pb.AuthRoleDeleteRequest{Role: role})
+ return (*AuthRoleDeleteResponse)(resp), toErr(ctx, err)
+}
+
+func StrToPermissionType(s string) (PermissionType, error) {
+ val, ok := authpb.Permission_Type_value[strings.ToUpper(s)]
+ if ok {
+ return PermissionType(val), nil
+ }
+ return PermissionType(-1), fmt.Errorf("invalid permission type: %s", s)
+}
+
+type authenticator struct {
+ conn *grpc.ClientConn // conn in-use
+ remote pb.AuthClient
+}
+
+func (auth *authenticator) authenticate(ctx context.Context, name string, password string) (*AuthenticateResponse, error) {
+ resp, err := auth.remote.Authenticate(ctx, &pb.AuthenticateRequest{Name: name, Password: password}, grpc.FailFast(false))
+ return (*AuthenticateResponse)(resp), toErr(ctx, err)
+}
+
+func (auth *authenticator) close() {
+ auth.conn.Close()
+}
+
+func newAuthenticator(endpoint string, opts []grpc.DialOption) (*authenticator, error) {
+ conn, err := grpc.Dial(endpoint, opts...)
+ if err != nil {
+ return nil, err
+ }
+
+ return &authenticator{
+ conn: conn,
+ remote: pb.NewAuthClient(conn),
+ }, nil
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/balancer.go b/vendor/github.com/coreos/etcd/clientv3/balancer.go
new file mode 100644
index 00000000..6ae047e9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/balancer.go
@@ -0,0 +1,356 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "net/url"
+ "strings"
+ "sync"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+)
+
+// ErrNoAddrAvilable is returned by Get() when the balancer does not have
+// any active connection to endpoints at the time.
+// This error is returned only when opts.BlockingWait is true.
+var ErrNoAddrAvilable = grpc.Errorf(codes.Unavailable, "there is no address available")
+
+// simpleBalancer does the bare minimum to expose multiple eps
+// to the grpc reconnection code path
+type simpleBalancer struct {
+ // addrs are the client's endpoints for grpc
+ addrs []grpc.Address
+ // notifyCh notifies grpc of the set of addresses for connecting
+ notifyCh chan []grpc.Address
+
+ // readyc closes once the first connection is up
+ readyc chan struct{}
+ readyOnce sync.Once
+
+ // mu protects upEps, pinAddr, and connectingAddr
+ mu sync.RWMutex
+
+ // upc closes when upEps transitions from empty to non-zero or the balancer closes.
+ upc chan struct{}
+
+ // downc closes when grpc calls down() on pinAddr
+ downc chan struct{}
+
+ // stopc is closed to signal updateNotifyLoop should stop.
+ stopc chan struct{}
+
+ // donec closes when all goroutines are exited
+ donec chan struct{}
+
+ // updateAddrsC notifies updateNotifyLoop to update addrs.
+ updateAddrsC chan struct{}
+
+ // grpc issues TLS cert checks using the string passed into dial so
+ // that string must be the host. To recover the full scheme://host URL,
+ // have a map from hosts to the original endpoint.
+ host2ep map[string]string
+
+ // pinAddr is the currently pinned address; set to the empty string on
+ // intialization and shutdown.
+ pinAddr string
+
+ closed bool
+}
+
+func newSimpleBalancer(eps []string) *simpleBalancer {
+ notifyCh := make(chan []grpc.Address, 1)
+ addrs := make([]grpc.Address, len(eps))
+ for i := range eps {
+ addrs[i].Addr = getHost(eps[i])
+ }
+ sb := &simpleBalancer{
+ addrs: addrs,
+ notifyCh: notifyCh,
+ readyc: make(chan struct{}),
+ upc: make(chan struct{}),
+ stopc: make(chan struct{}),
+ downc: make(chan struct{}),
+ donec: make(chan struct{}),
+ updateAddrsC: make(chan struct{}, 1),
+ host2ep: getHost2ep(eps),
+ }
+ close(sb.downc)
+ go sb.updateNotifyLoop()
+ return sb
+}
+
+func (b *simpleBalancer) Start(target string, config grpc.BalancerConfig) error { return nil }
+
+func (b *simpleBalancer) ConnectNotify() <-chan struct{} {
+ b.mu.Lock()
+ defer b.mu.Unlock()
+ return b.upc
+}
+
+func (b *simpleBalancer) getEndpoint(host string) string {
+ b.mu.Lock()
+ defer b.mu.Unlock()
+ return b.host2ep[host]
+}
+
+func getHost2ep(eps []string) map[string]string {
+ hm := make(map[string]string, len(eps))
+ for i := range eps {
+ _, host, _ := parseEndpoint(eps[i])
+ hm[host] = eps[i]
+ }
+ return hm
+}
+
+func (b *simpleBalancer) updateAddrs(eps []string) {
+ np := getHost2ep(eps)
+
+ b.mu.Lock()
+
+ match := len(np) == len(b.host2ep)
+ for k, v := range np {
+ if b.host2ep[k] != v {
+ match = false
+ break
+ }
+ }
+ if match {
+ // same endpoints, so no need to update address
+ b.mu.Unlock()
+ return
+ }
+
+ b.host2ep = np
+
+ addrs := make([]grpc.Address, 0, len(eps))
+ for i := range eps {
+ addrs = append(addrs, grpc.Address{Addr: getHost(eps[i])})
+ }
+ b.addrs = addrs
+
+ // updating notifyCh can trigger new connections,
+ // only update addrs if all connections are down
+ // or addrs does not include pinAddr.
+ update := !hasAddr(addrs, b.pinAddr)
+ b.mu.Unlock()
+
+ if update {
+ select {
+ case b.updateAddrsC <- struct{}{}:
+ case <-b.stopc:
+ }
+ }
+}
+
+func hasAddr(addrs []grpc.Address, targetAddr string) bool {
+ for _, addr := range addrs {
+ if targetAddr == addr.Addr {
+ return true
+ }
+ }
+ return false
+}
+
+func (b *simpleBalancer) updateNotifyLoop() {
+ defer close(b.donec)
+
+ for {
+ b.mu.RLock()
+ upc, downc, addr := b.upc, b.downc, b.pinAddr
+ b.mu.RUnlock()
+ // downc or upc should be closed
+ select {
+ case <-downc:
+ downc = nil
+ default:
+ }
+ select {
+ case <-upc:
+ upc = nil
+ default:
+ }
+ switch {
+ case downc == nil && upc == nil:
+ // stale
+ select {
+ case <-b.stopc:
+ return
+ default:
+ }
+ case downc == nil:
+ b.notifyAddrs()
+ select {
+ case <-upc:
+ case <-b.updateAddrsC:
+ b.notifyAddrs()
+ case <-b.stopc:
+ return
+ }
+ case upc == nil:
+ select {
+ // close connections that are not the pinned address
+ case b.notifyCh <- []grpc.Address{{Addr: addr}}:
+ case <-downc:
+ case <-b.stopc:
+ return
+ }
+ select {
+ case <-downc:
+ case <-b.updateAddrsC:
+ case <-b.stopc:
+ return
+ }
+ b.notifyAddrs()
+ }
+ }
+}
+
+func (b *simpleBalancer) notifyAddrs() {
+ b.mu.RLock()
+ addrs := b.addrs
+ b.mu.RUnlock()
+ select {
+ case b.notifyCh <- addrs:
+ case <-b.stopc:
+ }
+}
+
+func (b *simpleBalancer) Up(addr grpc.Address) func(error) {
+ b.mu.Lock()
+ defer b.mu.Unlock()
+
+ // gRPC might call Up after it called Close. We add this check
+ // to "fix" it up at application layer. Or our simplerBalancer
+ // might panic since b.upc is closed.
+ if b.closed {
+ return func(err error) {}
+ }
+ // gRPC might call Up on a stale address.
+ // Prevent updating pinAddr with a stale address.
+ if !hasAddr(b.addrs, addr.Addr) {
+ return func(err error) {}
+ }
+ if b.pinAddr != "" {
+ return func(err error) {}
+ }
+ // notify waiting Get()s and pin first connected address
+ close(b.upc)
+ b.downc = make(chan struct{})
+ b.pinAddr = addr.Addr
+ // notify client that a connection is up
+ b.readyOnce.Do(func() { close(b.readyc) })
+ return func(err error) {
+ b.mu.Lock()
+ b.upc = make(chan struct{})
+ close(b.downc)
+ b.pinAddr = ""
+ b.mu.Unlock()
+ }
+}
+
+func (b *simpleBalancer) Get(ctx context.Context, opts grpc.BalancerGetOptions) (grpc.Address, func(), error) {
+ var (
+ addr string
+ closed bool
+ )
+
+ // If opts.BlockingWait is false (for fail-fast RPCs), it should return
+ // an address it has notified via Notify immediately instead of blocking.
+ if !opts.BlockingWait {
+ b.mu.RLock()
+ closed = b.closed
+ addr = b.pinAddr
+ b.mu.RUnlock()
+ if closed {
+ return grpc.Address{Addr: ""}, nil, grpc.ErrClientConnClosing
+ }
+ if addr == "" {
+ return grpc.Address{Addr: ""}, nil, ErrNoAddrAvilable
+ }
+ return grpc.Address{Addr: addr}, func() {}, nil
+ }
+
+ for {
+ b.mu.RLock()
+ ch := b.upc
+ b.mu.RUnlock()
+ select {
+ case <-ch:
+ case <-b.donec:
+ return grpc.Address{Addr: ""}, nil, grpc.ErrClientConnClosing
+ case <-ctx.Done():
+ return grpc.Address{Addr: ""}, nil, ctx.Err()
+ }
+ b.mu.RLock()
+ closed = b.closed
+ addr = b.pinAddr
+ b.mu.RUnlock()
+ // Close() which sets b.closed = true can be called before Get(), Get() must exit if balancer is closed.
+ if closed {
+ return grpc.Address{Addr: ""}, nil, grpc.ErrClientConnClosing
+ }
+ if addr != "" {
+ break
+ }
+ }
+ return grpc.Address{Addr: addr}, func() {}, nil
+}
+
+func (b *simpleBalancer) Notify() <-chan []grpc.Address { return b.notifyCh }
+
+func (b *simpleBalancer) Close() error {
+ b.mu.Lock()
+ // In case gRPC calls close twice. TODO: remove the checking
+ // when we are sure that gRPC wont call close twice.
+ if b.closed {
+ b.mu.Unlock()
+ <-b.donec
+ return nil
+ }
+ b.closed = true
+ close(b.stopc)
+ b.pinAddr = ""
+
+ // In the case of following scenario:
+ // 1. upc is not closed; no pinned address
+ // 2. client issues an rpc, calling invoke(), which calls Get(), enters for loop, blocks
+ // 3. clientconn.Close() calls balancer.Close(); closed = true
+ // 4. for loop in Get() never exits since ctx is the context passed in by the client and may not be canceled
+ // we must close upc so Get() exits from blocking on upc
+ select {
+ case <-b.upc:
+ default:
+ // terminate all waiting Get()s
+ close(b.upc)
+ }
+
+ b.mu.Unlock()
+
+ // wait for updateNotifyLoop to finish
+ <-b.donec
+ close(b.notifyCh)
+
+ return nil
+}
+
+func getHost(ep string) string {
+ url, uerr := url.Parse(ep)
+ if uerr != nil || !strings.Contains(ep, "://") {
+ return ep
+ }
+ return url.Host
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/balancer_test.go b/vendor/github.com/coreos/etcd/clientv3/balancer_test.go
new file mode 100644
index 00000000..5245b69a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/balancer_test.go
@@ -0,0 +1,239 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "errors"
+ "net"
+ "sync"
+ "testing"
+ "time"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/testutil"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+var (
+ endpoints = []string{"localhost:2379", "localhost:22379", "localhost:32379"}
+)
+
+func TestBalancerGetUnblocking(t *testing.T) {
+ sb := newSimpleBalancer(endpoints)
+ defer sb.Close()
+ if addrs := <-sb.Notify(); len(addrs) != len(endpoints) {
+ t.Errorf("Initialize newSimpleBalancer should have triggered Notify() chan, but it didn't")
+ }
+ unblockingOpts := grpc.BalancerGetOptions{BlockingWait: false}
+
+ _, _, err := sb.Get(context.Background(), unblockingOpts)
+ if err != ErrNoAddrAvilable {
+ t.Errorf("Get() with no up endpoints should return ErrNoAddrAvailable, got: %v", err)
+ }
+
+ down1 := sb.Up(grpc.Address{Addr: endpoints[1]})
+ if addrs := <-sb.Notify(); len(addrs) != 1 {
+ t.Errorf("first Up() should have triggered balancer to send the first connected address via Notify chan so that other connections can be closed")
+ }
+ down2 := sb.Up(grpc.Address{Addr: endpoints[2]})
+ addrFirst, putFun, err := sb.Get(context.Background(), unblockingOpts)
+ if err != nil {
+ t.Errorf("Get() with up endpoints should success, got %v", err)
+ }
+ if addrFirst.Addr != endpoints[1] {
+ t.Errorf("Get() didn't return expected address, got %v", addrFirst)
+ }
+ if putFun == nil {
+ t.Errorf("Get() returned unexpected nil put function")
+ }
+ addrSecond, _, _ := sb.Get(context.Background(), unblockingOpts)
+ if addrFirst.Addr != addrSecond.Addr {
+ t.Errorf("Get() didn't return the same address as previous call, got %v and %v", addrFirst, addrSecond)
+ }
+
+ down1(errors.New("error"))
+ if addrs := <-sb.Notify(); len(addrs) != len(endpoints) {
+ t.Errorf("closing the only connection should triggered balancer to send the all endpoints via Notify chan so that we can establish a connection")
+ }
+ down2(errors.New("error"))
+ _, _, err = sb.Get(context.Background(), unblockingOpts)
+ if err != ErrNoAddrAvilable {
+ t.Errorf("Get() with no up endpoints should return ErrNoAddrAvailable, got: %v", err)
+ }
+}
+
+func TestBalancerGetBlocking(t *testing.T) {
+ sb := newSimpleBalancer(endpoints)
+ defer sb.Close()
+ if addrs := <-sb.Notify(); len(addrs) != len(endpoints) {
+ t.Errorf("Initialize newSimpleBalancer should have triggered Notify() chan, but it didn't")
+ }
+ blockingOpts := grpc.BalancerGetOptions{BlockingWait: true}
+
+ ctx, _ := context.WithTimeout(context.Background(), time.Millisecond*100)
+ _, _, err := sb.Get(ctx, blockingOpts)
+ if err != context.DeadlineExceeded {
+ t.Errorf("Get() with no up endpoints should timeout, got %v", err)
+ }
+
+ downC := make(chan func(error), 1)
+
+ go func() {
+ // ensure sb.Up() will be called after sb.Get() to see if Up() releases blocking Get()
+ time.Sleep(time.Millisecond * 100)
+ f := sb.Up(grpc.Address{Addr: endpoints[1]})
+ if addrs := <-sb.Notify(); len(addrs) != 1 {
+ t.Errorf("first Up() should have triggered balancer to send the first connected address via Notify chan so that other connections can be closed")
+ }
+ downC <- f
+ }()
+ addrFirst, putFun, err := sb.Get(context.Background(), blockingOpts)
+ if err != nil {
+ t.Errorf("Get() with up endpoints should success, got %v", err)
+ }
+ if addrFirst.Addr != endpoints[1] {
+ t.Errorf("Get() didn't return expected address, got %v", addrFirst)
+ }
+ if putFun == nil {
+ t.Errorf("Get() returned unexpected nil put function")
+ }
+ down1 := <-downC
+
+ down2 := sb.Up(grpc.Address{Addr: endpoints[2]})
+ addrSecond, _, _ := sb.Get(context.Background(), blockingOpts)
+ if addrFirst.Addr != addrSecond.Addr {
+ t.Errorf("Get() didn't return the same address as previous call, got %v and %v", addrFirst, addrSecond)
+ }
+
+ down1(errors.New("error"))
+ if addrs := <-sb.Notify(); len(addrs) != len(endpoints) {
+ t.Errorf("closing the only connection should triggered balancer to send the all endpoints via Notify chan so that we can establish a connection")
+ }
+ down2(errors.New("error"))
+ ctx, _ = context.WithTimeout(context.Background(), time.Millisecond*100)
+ _, _, err = sb.Get(ctx, blockingOpts)
+ if err != context.DeadlineExceeded {
+ t.Errorf("Get() with no up endpoints should timeout, got %v", err)
+ }
+}
+
+// TestBalancerDoNotBlockOnClose ensures that balancer and grpc don't deadlock each other
+// due to rapid open/close conn. The deadlock causes balancer.Close() to block forever.
+// See issue: https://github.com/coreos/etcd/issues/7283 for more detail.
+func TestBalancerDoNotBlockOnClose(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ kcl := newKillConnListener(t, 3)
+ defer kcl.close()
+
+ for i := 0; i < 5; i++ {
+ sb := newSimpleBalancer(kcl.endpoints())
+ conn, err := grpc.Dial("", grpc.WithInsecure(), grpc.WithBalancer(sb))
+ if err != nil {
+ t.Fatal(err)
+ }
+ kvc := pb.NewKVClient(conn)
+ <-sb.readyc
+
+ var wg sync.WaitGroup
+ wg.Add(100)
+ cctx, cancel := context.WithCancel(context.TODO())
+ for j := 0; j < 100; j++ {
+ go func() {
+ defer wg.Done()
+ kvc.Range(cctx, &pb.RangeRequest{}, grpc.FailFast(false))
+ }()
+ }
+ // balancer.Close() might block
+ // if balancer and grpc deadlock each other.
+ bclosec, cclosec := make(chan struct{}), make(chan struct{})
+ go func() {
+ defer close(bclosec)
+ sb.Close()
+ }()
+ go func() {
+ defer close(cclosec)
+ conn.Close()
+ }()
+ select {
+ case <-bclosec:
+ case <-time.After(3 * time.Second):
+ testutil.FatalStack(t, "balancer close timeout")
+ }
+ select {
+ case <-cclosec:
+ case <-time.After(3 * time.Second):
+ t.Fatal("grpc conn close timeout")
+ }
+
+ cancel()
+ wg.Wait()
+ }
+}
+
+// killConnListener listens incoming conn and kills it immediately.
+type killConnListener struct {
+ wg sync.WaitGroup
+ eps []string
+ stopc chan struct{}
+ t *testing.T
+}
+
+func newKillConnListener(t *testing.T, size int) *killConnListener {
+ kcl := &killConnListener{stopc: make(chan struct{}), t: t}
+
+ for i := 0; i < size; i++ {
+ ln, err := net.Listen("tcp", ":0")
+ if err != nil {
+ t.Fatal(err)
+ }
+ kcl.eps = append(kcl.eps, ln.Addr().String())
+ kcl.wg.Add(1)
+ go kcl.listen(ln)
+ }
+ return kcl
+}
+
+func (kcl *killConnListener) endpoints() []string {
+ return kcl.eps
+}
+
+func (kcl *killConnListener) listen(l net.Listener) {
+ go func() {
+ defer kcl.wg.Done()
+ for {
+ conn, err := l.Accept()
+ select {
+ case <-kcl.stopc:
+ return
+ default:
+ }
+ if err != nil {
+ kcl.t.Fatal(err)
+ }
+ time.Sleep(1 * time.Millisecond)
+ conn.Close()
+ }
+ }()
+ <-kcl.stopc
+ l.Close()
+}
+
+func (kcl *killConnListener) close() {
+ close(kcl.stopc)
+ kcl.wg.Wait()
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/client.go b/vendor/github.com/coreos/etcd/clientv3/client.go
new file mode 100644
index 00000000..f220a895
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/client.go
@@ -0,0 +1,515 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "crypto/tls"
+ "errors"
+ "fmt"
+ "net"
+ "net/url"
+ "strconv"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/credentials"
+ "google.golang.org/grpc/metadata"
+)
+
+var (
+ ErrNoAvailableEndpoints = errors.New("etcdclient: no available endpoints")
+ ErrOldCluster = errors.New("etcdclient: old cluster version")
+)
+
+// Client provides and manages an etcd v3 client session.
+type Client struct {
+ Cluster
+ KV
+ Lease
+ Watcher
+ Auth
+ Maintenance
+
+ conn *grpc.ClientConn
+ dialerrc chan error
+
+ cfg Config
+ creds *credentials.TransportCredentials
+ balancer *simpleBalancer
+ retryWrapper retryRpcFunc
+ retryAuthWrapper retryRpcFunc
+
+ ctx context.Context
+ cancel context.CancelFunc
+
+ // Username is a username for authentication
+ Username string
+ // Password is a password for authentication
+ Password string
+ // tokenCred is an instance of WithPerRPCCredentials()'s argument
+ tokenCred *authTokenCredential
+}
+
+// New creates a new etcdv3 client from a given configuration.
+func New(cfg Config) (*Client, error) {
+ if len(cfg.Endpoints) == 0 {
+ return nil, ErrNoAvailableEndpoints
+ }
+
+ return newClient(&cfg)
+}
+
+// NewCtxClient creates a client with a context but no underlying grpc
+// connection. This is useful for embedded cases that override the
+// service interface implementations and do not need connection management.
+func NewCtxClient(ctx context.Context) *Client {
+ cctx, cancel := context.WithCancel(ctx)
+ return &Client{ctx: cctx, cancel: cancel}
+}
+
+// NewFromURL creates a new etcdv3 client from a URL.
+func NewFromURL(url string) (*Client, error) {
+ return New(Config{Endpoints: []string{url}})
+}
+
+// Close shuts down the client's etcd connections.
+func (c *Client) Close() error {
+ c.cancel()
+ c.Watcher.Close()
+ c.Lease.Close()
+ if c.conn != nil {
+ return toErr(c.ctx, c.conn.Close())
+ }
+ return c.ctx.Err()
+}
+
+// Ctx is a context for "out of band" messages (e.g., for sending
+// "clean up" message when another context is canceled). It is
+// canceled on client Close().
+func (c *Client) Ctx() context.Context { return c.ctx }
+
+// Endpoints lists the registered endpoints for the client.
+func (c *Client) Endpoints() (eps []string) {
+ // copy the slice; protect original endpoints from being changed
+ eps = make([]string, len(c.cfg.Endpoints))
+ copy(eps, c.cfg.Endpoints)
+ return
+}
+
+// SetEndpoints updates client's endpoints.
+func (c *Client) SetEndpoints(eps ...string) {
+ c.cfg.Endpoints = eps
+ c.balancer.updateAddrs(eps)
+}
+
+// Sync synchronizes client's endpoints with the known endpoints from the etcd membership.
+func (c *Client) Sync(ctx context.Context) error {
+ mresp, err := c.MemberList(ctx)
+ if err != nil {
+ return err
+ }
+ var eps []string
+ for _, m := range mresp.Members {
+ eps = append(eps, m.ClientURLs...)
+ }
+ c.SetEndpoints(eps...)
+ return nil
+}
+
+func (c *Client) autoSync() {
+ if c.cfg.AutoSyncInterval == time.Duration(0) {
+ return
+ }
+
+ for {
+ select {
+ case <-c.ctx.Done():
+ return
+ case <-time.After(c.cfg.AutoSyncInterval):
+ ctx, _ := context.WithTimeout(c.ctx, 5*time.Second)
+ if err := c.Sync(ctx); err != nil && err != c.ctx.Err() {
+ logger.Println("Auto sync endpoints failed:", err)
+ }
+ }
+ }
+}
+
+type authTokenCredential struct {
+ token string
+ tokenMu *sync.RWMutex
+}
+
+func (cred authTokenCredential) RequireTransportSecurity() bool {
+ return false
+}
+
+func (cred authTokenCredential) GetRequestMetadata(ctx context.Context, s ...string) (map[string]string, error) {
+ cred.tokenMu.RLock()
+ defer cred.tokenMu.RUnlock()
+ return map[string]string{
+ "token": cred.token,
+ }, nil
+}
+
+func parseEndpoint(endpoint string) (proto string, host string, scheme string) {
+ proto = "tcp"
+ host = endpoint
+ url, uerr := url.Parse(endpoint)
+ if uerr != nil || !strings.Contains(endpoint, "://") {
+ return
+ }
+ scheme = url.Scheme
+
+ // strip scheme:// prefix since grpc dials by host
+ host = url.Host
+ switch url.Scheme {
+ case "http", "https":
+ case "unix", "unixs":
+ proto = "unix"
+ host = url.Host + url.Path
+ default:
+ proto, host = "", ""
+ }
+ return
+}
+
+func (c *Client) processCreds(scheme string) (creds *credentials.TransportCredentials) {
+ creds = c.creds
+ switch scheme {
+ case "unix":
+ case "http":
+ creds = nil
+ case "https", "unixs":
+ if creds != nil {
+ break
+ }
+ tlsconfig := &tls.Config{}
+ emptyCreds := credentials.NewTLS(tlsconfig)
+ creds = &emptyCreds
+ default:
+ creds = nil
+ }
+ return
+}
+
+// dialSetupOpts gives the dial opts prior to any authentication
+func (c *Client) dialSetupOpts(endpoint string, dopts ...grpc.DialOption) (opts []grpc.DialOption) {
+ if c.cfg.DialTimeout > 0 {
+ opts = []grpc.DialOption{grpc.WithTimeout(c.cfg.DialTimeout)}
+ }
+ opts = append(opts, dopts...)
+
+ f := func(host string, t time.Duration) (net.Conn, error) {
+ proto, host, _ := parseEndpoint(c.balancer.getEndpoint(host))
+ if host == "" && endpoint != "" {
+ // dialing an endpoint not in the balancer; use
+ // endpoint passed into dial
+ proto, host, _ = parseEndpoint(endpoint)
+ }
+ if proto == "" {
+ return nil, fmt.Errorf("unknown scheme for %q", host)
+ }
+ select {
+ case <-c.ctx.Done():
+ return nil, c.ctx.Err()
+ default:
+ }
+ dialer := &net.Dialer{Timeout: t}
+ conn, err := dialer.DialContext(c.ctx, proto, host)
+ if err != nil {
+ select {
+ case c.dialerrc <- err:
+ default:
+ }
+ }
+ return conn, err
+ }
+ opts = append(opts, grpc.WithDialer(f))
+
+ creds := c.creds
+ if _, _, scheme := parseEndpoint(endpoint); len(scheme) != 0 {
+ creds = c.processCreds(scheme)
+ }
+ if creds != nil {
+ opts = append(opts, grpc.WithTransportCredentials(*creds))
+ } else {
+ opts = append(opts, grpc.WithInsecure())
+ }
+
+ return opts
+}
+
+// Dial connects to a single endpoint using the client's config.
+func (c *Client) Dial(endpoint string) (*grpc.ClientConn, error) {
+ return c.dial(endpoint)
+}
+
+func (c *Client) getToken(ctx context.Context) error {
+ var err error // return last error in a case of fail
+ var auth *authenticator
+
+ for i := 0; i < len(c.cfg.Endpoints); i++ {
+ endpoint := c.cfg.Endpoints[i]
+ host := getHost(endpoint)
+ // use dial options without dopts to avoid reusing the client balancer
+ auth, err = newAuthenticator(host, c.dialSetupOpts(endpoint))
+ if err != nil {
+ continue
+ }
+ defer auth.close()
+
+ var resp *AuthenticateResponse
+ resp, err = auth.authenticate(ctx, c.Username, c.Password)
+ if err != nil {
+ continue
+ }
+
+ c.tokenCred.tokenMu.Lock()
+ c.tokenCred.token = resp.Token
+ c.tokenCred.tokenMu.Unlock()
+
+ return nil
+ }
+
+ return err
+}
+
+func (c *Client) dial(endpoint string, dopts ...grpc.DialOption) (*grpc.ClientConn, error) {
+ opts := c.dialSetupOpts(endpoint, dopts...)
+ host := getHost(endpoint)
+ if c.Username != "" && c.Password != "" {
+ c.tokenCred = &authTokenCredential{
+ tokenMu: &sync.RWMutex{},
+ }
+
+ ctx := c.ctx
+ if c.cfg.DialTimeout > 0 {
+ cctx, cancel := context.WithTimeout(ctx, c.cfg.DialTimeout)
+ defer cancel()
+ ctx = cctx
+ }
+
+ err := c.getToken(ctx)
+ if err != nil {
+ if toErr(ctx, err) != rpctypes.ErrAuthNotEnabled {
+ if err == ctx.Err() && ctx.Err() != c.ctx.Err() {
+ err = grpc.ErrClientConnTimeout
+ }
+ return nil, err
+ }
+ } else {
+ opts = append(opts, grpc.WithPerRPCCredentials(c.tokenCred))
+ }
+ }
+
+ opts = append(opts, c.cfg.DialOptions...)
+
+ conn, err := grpc.DialContext(c.ctx, host, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return conn, nil
+}
+
+// WithRequireLeader requires client requests to only succeed
+// when the cluster has a leader.
+func WithRequireLeader(ctx context.Context) context.Context {
+ md := metadata.Pairs(rpctypes.MetadataRequireLeaderKey, rpctypes.MetadataHasLeader)
+ return metadata.NewContext(ctx, md)
+}
+
+func newClient(cfg *Config) (*Client, error) {
+ if cfg == nil {
+ cfg = &Config{}
+ }
+ var creds *credentials.TransportCredentials
+ if cfg.TLS != nil {
+ c := credentials.NewTLS(cfg.TLS)
+ creds = &c
+ }
+
+ // use a temporary skeleton client to bootstrap first connection
+ baseCtx := context.TODO()
+ if cfg.Context != nil {
+ baseCtx = cfg.Context
+ }
+
+ ctx, cancel := context.WithCancel(baseCtx)
+ client := &Client{
+ conn: nil,
+ dialerrc: make(chan error, 1),
+ cfg: *cfg,
+ creds: creds,
+ ctx: ctx,
+ cancel: cancel,
+ }
+ if cfg.Username != "" && cfg.Password != "" {
+ client.Username = cfg.Username
+ client.Password = cfg.Password
+ }
+
+ client.balancer = newSimpleBalancer(cfg.Endpoints)
+ // use Endpoints[0] so that for https:// without any tls config given, then
+ // grpc will assume the ServerName is in the endpoint.
+ conn, err := client.dial(cfg.Endpoints[0], grpc.WithBalancer(client.balancer))
+ if err != nil {
+ client.cancel()
+ client.balancer.Close()
+ return nil, err
+ }
+ client.conn = conn
+ client.retryWrapper = client.newRetryWrapper()
+ client.retryAuthWrapper = client.newAuthRetryWrapper()
+
+ // wait for a connection
+ if cfg.DialTimeout > 0 {
+ hasConn := false
+ waitc := time.After(cfg.DialTimeout)
+ select {
+ case <-client.balancer.readyc:
+ hasConn = true
+ case <-ctx.Done():
+ case <-waitc:
+ }
+ if !hasConn {
+ err := grpc.ErrClientConnTimeout
+ select {
+ case err = <-client.dialerrc:
+ default:
+ }
+ client.cancel()
+ client.balancer.Close()
+ conn.Close()
+ return nil, err
+ }
+ }
+
+ client.Cluster = NewCluster(client)
+ client.KV = NewKV(client)
+ client.Lease = NewLease(client)
+ client.Watcher = NewWatcher(client)
+ client.Auth = NewAuth(client)
+ client.Maintenance = NewMaintenance(client)
+
+ if cfg.RejectOldCluster {
+ if err := client.checkVersion(); err != nil {
+ client.Close()
+ return nil, err
+ }
+ }
+
+ go client.autoSync()
+ return client, nil
+}
+
+func (c *Client) checkVersion() (err error) {
+ var wg sync.WaitGroup
+ errc := make(chan error, len(c.cfg.Endpoints))
+ ctx, cancel := context.WithCancel(c.ctx)
+ if c.cfg.DialTimeout > 0 {
+ ctx, _ = context.WithTimeout(ctx, c.cfg.DialTimeout)
+ }
+ wg.Add(len(c.cfg.Endpoints))
+ for _, ep := range c.cfg.Endpoints {
+ // if cluster is current, any endpoint gives a recent version
+ go func(e string) {
+ defer wg.Done()
+ resp, rerr := c.Status(ctx, e)
+ if rerr != nil {
+ errc <- rerr
+ return
+ }
+ vs := strings.Split(resp.Version, ".")
+ maj, min := 0, 0
+ if len(vs) >= 2 {
+ maj, rerr = strconv.Atoi(vs[0])
+ min, rerr = strconv.Atoi(vs[1])
+ }
+ if maj < 3 || (maj == 3 && min < 2) {
+ rerr = ErrOldCluster
+ }
+ errc <- rerr
+ }(ep)
+ }
+ // wait for success
+ for i := 0; i < len(c.cfg.Endpoints); i++ {
+ if err = <-errc; err == nil {
+ break
+ }
+ }
+ cancel()
+ wg.Wait()
+ return err
+}
+
+// ActiveConnection returns the current in-use connection
+func (c *Client) ActiveConnection() *grpc.ClientConn { return c.conn }
+
+// isHaltErr returns true if the given error and context indicate no forward
+// progress can be made, even after reconnecting.
+func isHaltErr(ctx context.Context, err error) bool {
+ if ctx != nil && ctx.Err() != nil {
+ return true
+ }
+ if err == nil {
+ return false
+ }
+ code := grpc.Code(err)
+ // Unavailable codes mean the system will be right back.
+ // (e.g., can't connect, lost leader)
+ // Treat Internal codes as if something failed, leaving the
+ // system in an inconsistent state, but retrying could make progress.
+ // (e.g., failed in middle of send, corrupted frame)
+ // TODO: are permanent Internal errors possible from grpc?
+ return code != codes.Unavailable && code != codes.Internal
+}
+
+func toErr(ctx context.Context, err error) error {
+ if err == nil {
+ return nil
+ }
+ err = rpctypes.Error(err)
+ if _, ok := err.(rpctypes.EtcdError); ok {
+ return err
+ }
+ code := grpc.Code(err)
+ switch code {
+ case codes.DeadlineExceeded:
+ fallthrough
+ case codes.Canceled:
+ if ctx.Err() != nil {
+ err = ctx.Err()
+ }
+ case codes.Unavailable:
+ err = ErrNoAvailableEndpoints
+ case codes.FailedPrecondition:
+ err = grpc.ErrClientConnClosing
+ }
+ return err
+}
+
+func canceledByCaller(stopCtx context.Context, err error) bool {
+ if stopCtx.Err() == nil || err == nil {
+ return false
+ }
+
+ return err == context.Canceled || err == context.DeadlineExceeded
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/client_test.go b/vendor/github.com/coreos/etcd/clientv3/client_test.go
new file mode 100644
index 00000000..dd3e144b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/client_test.go
@@ -0,0 +1,154 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "fmt"
+ "net"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ "github.com/coreos/etcd/pkg/testutil"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+func TestDialCancel(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ // accept first connection so client is created with dial timeout
+ ln, err := net.Listen("unix", "dialcancel:12345")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer ln.Close()
+
+ ep := "unix://dialcancel:12345"
+ cfg := Config{
+ Endpoints: []string{ep},
+ DialTimeout: 30 * time.Second}
+ c, err := New(cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // connect to ipv4 blackhole so dial blocks
+ c.SetEndpoints("http://254.0.0.1:12345")
+
+ // issue Get to force redial attempts
+ getc := make(chan struct{})
+ go func() {
+ defer close(getc)
+ // Get may hang forever on grpc's Stream.Header() if its
+ // context is never canceled.
+ c.Get(c.Ctx(), "abc")
+ }()
+
+ // wait a little bit so client close is after dial starts
+ time.Sleep(100 * time.Millisecond)
+
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ c.Close()
+ }()
+
+ select {
+ case <-time.After(5 * time.Second):
+ t.Fatalf("failed to close")
+ case <-donec:
+ }
+ select {
+ case <-time.After(5 * time.Second):
+ t.Fatalf("get failed to exit")
+ case <-getc:
+ }
+}
+
+func TestDialTimeout(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ testCfgs := []Config{
+ {
+ Endpoints: []string{"http://254.0.0.1:12345"},
+ DialTimeout: 2 * time.Second,
+ },
+ {
+ Endpoints: []string{"http://254.0.0.1:12345"},
+ DialTimeout: time.Second,
+ Username: "abc",
+ Password: "def",
+ },
+ }
+
+ for i, cfg := range testCfgs {
+ donec := make(chan error)
+ go func() {
+ // without timeout, dial continues forever on ipv4 blackhole
+ c, err := New(cfg)
+ if c != nil || err == nil {
+ t.Errorf("#%d: new client should fail", i)
+ }
+ donec <- err
+ }()
+
+ time.Sleep(10 * time.Millisecond)
+
+ select {
+ case err := <-donec:
+ t.Errorf("#%d: dial didn't wait (%v)", i, err)
+ default:
+ }
+
+ select {
+ case <-time.After(5 * time.Second):
+ t.Errorf("#%d: failed to timeout dial on time", i)
+ case err := <-donec:
+ if err != grpc.ErrClientConnTimeout {
+ t.Errorf("#%d: unexpected error %v, want %v", i, err, grpc.ErrClientConnTimeout)
+ }
+ }
+ }
+}
+
+func TestDialNoTimeout(t *testing.T) {
+ cfg := Config{Endpoints: []string{"127.0.0.1:12345"}}
+ c, err := New(cfg)
+ if c == nil || err != nil {
+ t.Fatalf("new client with DialNoWait should succeed, got %v", err)
+ }
+ c.Close()
+}
+
+func TestIsHaltErr(t *testing.T) {
+ if !isHaltErr(nil, fmt.Errorf("etcdserver: some etcdserver error")) {
+ t.Errorf(`error prefixed with "etcdserver: " should be Halted by default`)
+ }
+ if isHaltErr(nil, rpctypes.ErrGRPCStopped) {
+ t.Errorf("error %v should not halt", rpctypes.ErrGRPCStopped)
+ }
+ if isHaltErr(nil, rpctypes.ErrGRPCNoLeader) {
+ t.Errorf("error %v should not halt", rpctypes.ErrGRPCNoLeader)
+ }
+ ctx, cancel := context.WithCancel(context.TODO())
+ if isHaltErr(ctx, nil) {
+ t.Errorf("no error and active context should not be Halted")
+ }
+ cancel()
+ if !isHaltErr(ctx, nil) {
+ t.Errorf("cancel on context should be Halted")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/clientv3util/example_key_test.go b/vendor/github.com/coreos/etcd/clientv3/clientv3util/example_key_test.go
new file mode 100644
index 00000000..ed6d0f69
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/clientv3util/example_key_test.go
@@ -0,0 +1,66 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 clientv3util_test
+
+import (
+ "context"
+ "log"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/clientv3util"
+)
+
+func ExampleKeyExists_put() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: []string{"127.0.0.1:2379"},
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+ kvc := clientv3.NewKV(cli)
+
+ // perform a put only if key is missing
+ // It is useful to do the check (transactionally) to avoid overwriting
+ // the existing key which would generate potentially unwanted events,
+ // unless of course you wanted to do an overwrite no matter what.
+ _, err = kvc.Txn(context.Background()).
+ If(clientv3util.KeyMissing("purpleidea")).
+ Then(clientv3.OpPut("purpleidea", "hello world")).
+ Commit()
+ if err != nil {
+ log.Fatal(err)
+ }
+}
+
+func ExampleKeyExists_delete() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: []string{"127.0.0.1:2379"},
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+ kvc := clientv3.NewKV(cli)
+
+ // perform a delete only if key already exists
+ _, err = kvc.Txn(context.Background()).
+ If(clientv3util.KeyExists("purpleidea")).
+ Then(clientv3.OpDelete("purpleidea")).
+ Commit()
+ if err != nil {
+ log.Fatal(err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/clientv3util/util.go b/vendor/github.com/coreos/etcd/clientv3/clientv3util/util.go
new file mode 100644
index 00000000..3b296343
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/clientv3util/util.go
@@ -0,0 +1,33 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 clientv3util contains utility functions derived from clientv3.
+package clientv3util
+
+import (
+ "github.com/coreos/etcd/clientv3"
+)
+
+// KeyExists returns a comparison operation that evaluates to true iff the given
+// key exists. It does this by checking if the key `Version` is greater than 0.
+// It is a useful guard in transaction delete operations.
+func KeyExists(key string) clientv3.Cmp {
+ return clientv3.Compare(clientv3.Version(key), ">", 0)
+}
+
+// KeyMissing returns a comparison operation that evaluates to true iff the
+// given key does not exist.
+func KeyMissing(key string) clientv3.Cmp {
+ return clientv3.Compare(clientv3.Version(key), "=", 0)
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/cluster.go b/vendor/github.com/coreos/etcd/clientv3/cluster.go
new file mode 100644
index 00000000..922d900e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/cluster.go
@@ -0,0 +1,100 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+type (
+ Member pb.Member
+ MemberListResponse pb.MemberListResponse
+ MemberAddResponse pb.MemberAddResponse
+ MemberRemoveResponse pb.MemberRemoveResponse
+ MemberUpdateResponse pb.MemberUpdateResponse
+)
+
+type Cluster interface {
+ // MemberList lists the current cluster membership.
+ MemberList(ctx context.Context) (*MemberListResponse, error)
+
+ // MemberAdd adds a new member into the cluster.
+ MemberAdd(ctx context.Context, peerAddrs []string) (*MemberAddResponse, error)
+
+ // MemberRemove removes an existing member from the cluster.
+ MemberRemove(ctx context.Context, id uint64) (*MemberRemoveResponse, error)
+
+ // MemberUpdate updates the peer addresses of the member.
+ MemberUpdate(ctx context.Context, id uint64, peerAddrs []string) (*MemberUpdateResponse, error)
+}
+
+type cluster struct {
+ remote pb.ClusterClient
+}
+
+func NewCluster(c *Client) Cluster {
+ return &cluster{remote: RetryClusterClient(c)}
+}
+
+func NewClusterFromClusterClient(remote pb.ClusterClient) Cluster {
+ return &cluster{remote: remote}
+}
+
+func (c *cluster) MemberAdd(ctx context.Context, peerAddrs []string) (*MemberAddResponse, error) {
+ r := &pb.MemberAddRequest{PeerURLs: peerAddrs}
+ resp, err := c.remote.MemberAdd(ctx, r)
+ if err != nil {
+ return nil, toErr(ctx, err)
+ }
+ return (*MemberAddResponse)(resp), nil
+}
+
+func (c *cluster) MemberRemove(ctx context.Context, id uint64) (*MemberRemoveResponse, error) {
+ r := &pb.MemberRemoveRequest{ID: id}
+ resp, err := c.remote.MemberRemove(ctx, r)
+ if err != nil {
+ return nil, toErr(ctx, err)
+ }
+ return (*MemberRemoveResponse)(resp), nil
+}
+
+func (c *cluster) MemberUpdate(ctx context.Context, id uint64, peerAddrs []string) (*MemberUpdateResponse, error) {
+ // it is safe to retry on update.
+ for {
+ r := &pb.MemberUpdateRequest{ID: id, PeerURLs: peerAddrs}
+ resp, err := c.remote.MemberUpdate(ctx, r, grpc.FailFast(false))
+ if err == nil {
+ return (*MemberUpdateResponse)(resp), nil
+ }
+ if isHaltErr(ctx, err) {
+ return nil, toErr(ctx, err)
+ }
+ }
+}
+
+func (c *cluster) MemberList(ctx context.Context) (*MemberListResponse, error) {
+ // it is safe to retry on list.
+ for {
+ resp, err := c.remote.MemberList(ctx, &pb.MemberListRequest{}, grpc.FailFast(false))
+ if err == nil {
+ return (*MemberListResponse)(resp), nil
+ }
+ if isHaltErr(ctx, err) {
+ return nil, toErr(ctx, err)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/compact_op.go b/vendor/github.com/coreos/etcd/clientv3/compact_op.go
new file mode 100644
index 00000000..32d97eb0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/compact_op.go
@@ -0,0 +1,53 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+// CompactOp represents a compact operation.
+type CompactOp struct {
+ revision int64
+ physical bool
+}
+
+// CompactOption configures compact operation.
+type CompactOption func(*CompactOp)
+
+func (op *CompactOp) applyCompactOpts(opts []CompactOption) {
+ for _, opt := range opts {
+ opt(op)
+ }
+}
+
+// OpCompact wraps slice CompactOption to create a CompactOp.
+func OpCompact(rev int64, opts ...CompactOption) CompactOp {
+ ret := CompactOp{revision: rev}
+ ret.applyCompactOpts(opts)
+ return ret
+}
+
+func (op CompactOp) toRequest() *pb.CompactionRequest {
+ return &pb.CompactionRequest{Revision: op.revision, Physical: op.physical}
+}
+
+// WithCompactPhysical makes compact RPC call wait until
+// the compaction is physically applied to the local database
+// such that compacted entries are totally removed from the
+// backend database.
+func WithCompactPhysical() CompactOption {
+ return func(op *CompactOp) { op.physical = true }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/compact_op_test.go b/vendor/github.com/coreos/etcd/clientv3/compact_op_test.go
new file mode 100644
index 00000000..6c91d3ab
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/compact_op_test.go
@@ -0,0 +1,30 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+func TestCompactOp(t *testing.T) {
+ req1 := OpCompact(100, WithCompactPhysical()).toRequest()
+ req2 := &etcdserverpb.CompactionRequest{Revision: 100, Physical: true}
+ if !reflect.DeepEqual(req1, req2) {
+ t.Fatalf("expected %+v, got %+v", req2, req1)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/compare.go b/vendor/github.com/coreos/etcd/clientv3/compare.go
new file mode 100644
index 00000000..c55228cc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/compare.go
@@ -0,0 +1,110 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+type CompareTarget int
+type CompareResult int
+
+const (
+ CompareVersion CompareTarget = iota
+ CompareCreated
+ CompareModified
+ CompareValue
+)
+
+type Cmp pb.Compare
+
+func Compare(cmp Cmp, result string, v interface{}) Cmp {
+ var r pb.Compare_CompareResult
+
+ switch result {
+ case "=":
+ r = pb.Compare_EQUAL
+ case "!=":
+ r = pb.Compare_NOT_EQUAL
+ case ">":
+ r = pb.Compare_GREATER
+ case "<":
+ r = pb.Compare_LESS
+ default:
+ panic("Unknown result op")
+ }
+
+ cmp.Result = r
+ switch cmp.Target {
+ case pb.Compare_VALUE:
+ val, ok := v.(string)
+ if !ok {
+ panic("bad compare value")
+ }
+ cmp.TargetUnion = &pb.Compare_Value{Value: []byte(val)}
+ case pb.Compare_VERSION:
+ cmp.TargetUnion = &pb.Compare_Version{Version: mustInt64(v)}
+ case pb.Compare_CREATE:
+ cmp.TargetUnion = &pb.Compare_CreateRevision{CreateRevision: mustInt64(v)}
+ case pb.Compare_MOD:
+ cmp.TargetUnion = &pb.Compare_ModRevision{ModRevision: mustInt64(v)}
+ default:
+ panic("Unknown compare type")
+ }
+ return cmp
+}
+
+func Value(key string) Cmp {
+ return Cmp{Key: []byte(key), Target: pb.Compare_VALUE}
+}
+
+func Version(key string) Cmp {
+ return Cmp{Key: []byte(key), Target: pb.Compare_VERSION}
+}
+
+func CreateRevision(key string) Cmp {
+ return Cmp{Key: []byte(key), Target: pb.Compare_CREATE}
+}
+
+func ModRevision(key string) Cmp {
+ return Cmp{Key: []byte(key), Target: pb.Compare_MOD}
+}
+
+// KeyBytes returns the byte slice holding with the comparison key.
+func (cmp *Cmp) KeyBytes() []byte { return cmp.Key }
+
+// WithKeyBytes sets the byte slice for the comparison key.
+func (cmp *Cmp) WithKeyBytes(key []byte) { cmp.Key = key }
+
+// ValueBytes returns the byte slice holding the comparison value, if any.
+func (cmp *Cmp) ValueBytes() []byte {
+ if tu, ok := cmp.TargetUnion.(*pb.Compare_Value); ok {
+ return tu.Value
+ }
+ return nil
+}
+
+// WithValueBytes sets the byte slice for the comparison's value.
+func (cmp *Cmp) WithValueBytes(v []byte) { cmp.TargetUnion.(*pb.Compare_Value).Value = v }
+
+func mustInt64(val interface{}) int64 {
+ if v, ok := val.(int64); ok {
+ return v
+ }
+ if v, ok := val.(int); ok {
+ return int64(v)
+ }
+ panic("bad value")
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/concurrency/doc.go b/vendor/github.com/coreos/etcd/clientv3/concurrency/doc.go
new file mode 100644
index 00000000..dcdbf511
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/concurrency/doc.go
@@ -0,0 +1,17 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 concurrency implements concurrency operations on top of
+// etcd such as distributed locks, barriers, and elections.
+package concurrency
diff --git a/vendor/github.com/coreos/etcd/clientv3/concurrency/election.go b/vendor/github.com/coreos/etcd/clientv3/concurrency/election.go
new file mode 100644
index 00000000..1d75dde3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/concurrency/election.go
@@ -0,0 +1,243 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 concurrency
+
+import (
+ "errors"
+ "fmt"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "golang.org/x/net/context"
+)
+
+var (
+ ErrElectionNotLeader = errors.New("election: not leader")
+ ErrElectionNoLeader = errors.New("election: no leader")
+)
+
+type Election struct {
+ session *Session
+
+ keyPrefix string
+
+ leaderKey string
+ leaderRev int64
+ leaderSession *Session
+ hdr *pb.ResponseHeader
+}
+
+// NewElection returns a new election on a given key prefix.
+func NewElection(s *Session, pfx string) *Election {
+ return &Election{session: s, keyPrefix: pfx + "/"}
+}
+
+// ResumeElection initializes an election with a known leader.
+func ResumeElection(s *Session, pfx string, leaderKey string, leaderRev int64) *Election {
+ return &Election{
+ session: s,
+ leaderKey: leaderKey,
+ leaderRev: leaderRev,
+ leaderSession: s,
+ }
+}
+
+// Campaign puts a value as eligible for the election. It blocks until
+// it is elected, an error occurs, or the context is cancelled.
+func (e *Election) Campaign(ctx context.Context, val string) error {
+ s := e.session
+ client := e.session.Client()
+
+ k := fmt.Sprintf("%s%x", e.keyPrefix, s.Lease())
+ txn := client.Txn(ctx).If(v3.Compare(v3.CreateRevision(k), "=", 0))
+ txn = txn.Then(v3.OpPut(k, val, v3.WithLease(s.Lease())))
+ txn = txn.Else(v3.OpGet(k))
+ resp, err := txn.Commit()
+ if err != nil {
+ return err
+ }
+ e.leaderKey, e.leaderRev, e.leaderSession = k, resp.Header.Revision, s
+ if !resp.Succeeded {
+ kv := resp.Responses[0].GetResponseRange().Kvs[0]
+ e.leaderRev = kv.CreateRevision
+ if string(kv.Value) != val {
+ if err = e.Proclaim(ctx, val); err != nil {
+ e.Resign(ctx)
+ return err
+ }
+ }
+ }
+
+ _, err = waitDeletes(ctx, client, e.keyPrefix, e.leaderRev-1)
+ if err != nil {
+ // clean up in case of context cancel
+ select {
+ case <-ctx.Done():
+ e.Resign(client.Ctx())
+ default:
+ e.leaderSession = nil
+ }
+ return err
+ }
+ e.hdr = resp.Header
+
+ return nil
+}
+
+// Proclaim lets the leader announce a new value without another election.
+func (e *Election) Proclaim(ctx context.Context, val string) error {
+ if e.leaderSession == nil {
+ return ErrElectionNotLeader
+ }
+ client := e.session.Client()
+ cmp := v3.Compare(v3.CreateRevision(e.leaderKey), "=", e.leaderRev)
+ txn := client.Txn(ctx).If(cmp)
+ txn = txn.Then(v3.OpPut(e.leaderKey, val, v3.WithLease(e.leaderSession.Lease())))
+ tresp, terr := txn.Commit()
+ if terr != nil {
+ return terr
+ }
+ if !tresp.Succeeded {
+ e.leaderKey = ""
+ return ErrElectionNotLeader
+ }
+
+ e.hdr = tresp.Header
+ return nil
+}
+
+// Resign lets a leader start a new election.
+func (e *Election) Resign(ctx context.Context) (err error) {
+ if e.leaderSession == nil {
+ return nil
+ }
+ client := e.session.Client()
+ cmp := v3.Compare(v3.CreateRevision(e.leaderKey), "=", e.leaderRev)
+ resp, err := client.Txn(ctx).If(cmp).Then(v3.OpDelete(e.leaderKey)).Commit()
+ if err == nil {
+ e.hdr = resp.Header
+ }
+ e.leaderKey = ""
+ e.leaderSession = nil
+ return err
+}
+
+// Leader returns the leader value for the current election.
+func (e *Election) Leader(ctx context.Context) (*v3.GetResponse, error) {
+ client := e.session.Client()
+ resp, err := client.Get(ctx, e.keyPrefix, v3.WithFirstCreate()...)
+ if err != nil {
+ return nil, err
+ } else if len(resp.Kvs) == 0 {
+ // no leader currently elected
+ return nil, ErrElectionNoLeader
+ }
+ return resp, nil
+}
+
+// Observe returns a channel that reliably observes ordered leader proposals
+// as GetResponse values on every current elected leader key. It will not
+// necessarily fetch all historical leader updates, but will always post the
+// most recent leader value.
+//
+// The channel closes when the context is canceled or the underlying watcher
+// is otherwise disrupted.
+func (e *Election) Observe(ctx context.Context) <-chan v3.GetResponse {
+ retc := make(chan v3.GetResponse)
+ go e.observe(ctx, retc)
+ return retc
+}
+
+func (e *Election) observe(ctx context.Context, ch chan<- v3.GetResponse) {
+ client := e.session.Client()
+
+ defer close(ch)
+ for {
+ resp, err := client.Get(ctx, e.keyPrefix, v3.WithFirstCreate()...)
+ if err != nil {
+ return
+ }
+
+ var kv *mvccpb.KeyValue
+ var hdr *pb.ResponseHeader
+
+ if len(resp.Kvs) == 0 {
+ cctx, cancel := context.WithCancel(ctx)
+ // wait for first key put on prefix
+ opts := []v3.OpOption{v3.WithRev(resp.Header.Revision), v3.WithPrefix()}
+ wch := client.Watch(cctx, e.keyPrefix, opts...)
+ for kv == nil {
+ wr, ok := <-wch
+ if !ok || wr.Err() != nil {
+ cancel()
+ return
+ }
+ // only accept PUTs; a DELETE will make observe() spin
+ for _, ev := range wr.Events {
+ if ev.Type == mvccpb.PUT {
+ hdr, kv = &wr.Header, ev.Kv
+ // may have multiple revs; hdr.rev = the last rev
+ // set to kv's rev in case batch has multiple PUTs
+ hdr.Revision = kv.ModRevision
+ break
+ }
+ }
+ }
+ cancel()
+ } else {
+ hdr, kv = resp.Header, resp.Kvs[0]
+ }
+
+ select {
+ case ch <- v3.GetResponse{Header: hdr, Kvs: []*mvccpb.KeyValue{kv}}:
+ case <-ctx.Done():
+ return
+ }
+
+ cctx, cancel := context.WithCancel(ctx)
+ wch := client.Watch(cctx, string(kv.Key), v3.WithRev(hdr.Revision+1))
+ keyDeleted := false
+ for !keyDeleted {
+ wr, ok := <-wch
+ if !ok {
+ return
+ }
+ for _, ev := range wr.Events {
+ if ev.Type == mvccpb.DELETE {
+ keyDeleted = true
+ break
+ }
+ resp.Header = &wr.Header
+ resp.Kvs = []*mvccpb.KeyValue{ev.Kv}
+ select {
+ case ch <- *resp:
+ case <-cctx.Done():
+ return
+ }
+ }
+ }
+ cancel()
+ }
+}
+
+// Key returns the leader key if elected, empty string otherwise.
+func (e *Election) Key() string { return e.leaderKey }
+
+// Rev returns the leader key's creation revision, if elected.
+func (e *Election) Rev() int64 { return e.leaderRev }
+
+// Header is the response header from the last successful election proposal.
+func (m *Election) Header() *pb.ResponseHeader { return m.hdr }
diff --git a/vendor/github.com/coreos/etcd/clientv3/concurrency/key.go b/vendor/github.com/coreos/etcd/clientv3/concurrency/key.go
new file mode 100644
index 00000000..cf006d70
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/concurrency/key.go
@@ -0,0 +1,65 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 concurrency
+
+import (
+ "fmt"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "golang.org/x/net/context"
+)
+
+func waitDelete(ctx context.Context, client *v3.Client, key string, rev int64) error {
+ cctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+
+ var wr v3.WatchResponse
+ wch := client.Watch(cctx, key, v3.WithRev(rev))
+ for wr = range wch {
+ for _, ev := range wr.Events {
+ if ev.Type == mvccpb.DELETE {
+ return nil
+ }
+ }
+ }
+ if err := wr.Err(); err != nil {
+ return err
+ }
+ if err := ctx.Err(); err != nil {
+ return err
+ }
+ return fmt.Errorf("lost watcher waiting for delete")
+}
+
+// waitDeletes efficiently waits until all keys matching the prefix and no greater
+// than the create revision.
+func waitDeletes(ctx context.Context, client *v3.Client, pfx string, maxCreateRev int64) (*pb.ResponseHeader, error) {
+ getOpts := append(v3.WithLastCreate(), v3.WithMaxCreateRev(maxCreateRev))
+ for {
+ resp, err := client.Get(ctx, pfx, getOpts...)
+ if err != nil {
+ return nil, err
+ }
+ if len(resp.Kvs) == 0 {
+ return resp.Header, nil
+ }
+ lastKey := string(resp.Kvs[0].Key)
+ if err = waitDelete(ctx, client, lastKey, resp.Header.Revision); err != nil {
+ return nil, err
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/concurrency/mutex.go b/vendor/github.com/coreos/etcd/clientv3/concurrency/mutex.go
new file mode 100644
index 00000000..cee15db7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/concurrency/mutex.go
@@ -0,0 +1,110 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 concurrency
+
+import (
+ "fmt"
+ "sync"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "golang.org/x/net/context"
+)
+
+// Mutex implements the sync Locker interface with etcd
+type Mutex struct {
+ s *Session
+
+ pfx string
+ myKey string
+ myRev int64
+ hdr *pb.ResponseHeader
+}
+
+func NewMutex(s *Session, pfx string) *Mutex {
+ return &Mutex{s, pfx + "/", "", -1, nil}
+}
+
+// Lock locks the mutex with a cancelable context. If the context is canceled
+// while trying to acquire the lock, the mutex tries to clean its stale lock entry.
+func (m *Mutex) Lock(ctx context.Context) error {
+ s := m.s
+ client := m.s.Client()
+
+ m.myKey = fmt.Sprintf("%s%x", m.pfx, s.Lease())
+ cmp := v3.Compare(v3.CreateRevision(m.myKey), "=", 0)
+ // put self in lock waiters via myKey; oldest waiter holds lock
+ put := v3.OpPut(m.myKey, "", v3.WithLease(s.Lease()))
+ // reuse key in case this session already holds the lock
+ get := v3.OpGet(m.myKey)
+ resp, err := client.Txn(ctx).If(cmp).Then(put).Else(get).Commit()
+ if err != nil {
+ return err
+ }
+ m.myRev = resp.Header.Revision
+ if !resp.Succeeded {
+ m.myRev = resp.Responses[0].GetResponseRange().Kvs[0].CreateRevision
+ }
+
+ // wait for deletion revisions prior to myKey
+ hdr, werr := waitDeletes(ctx, client, m.pfx, m.myRev-1)
+ // release lock key if cancelled
+ select {
+ case <-ctx.Done():
+ m.Unlock(client.Ctx())
+ default:
+ m.hdr = hdr
+ }
+ return werr
+}
+
+func (m *Mutex) Unlock(ctx context.Context) error {
+ client := m.s.Client()
+ if _, err := client.Delete(ctx, m.myKey); err != nil {
+ return err
+ }
+ m.myKey = "\x00"
+ m.myRev = -1
+ return nil
+}
+
+func (m *Mutex) IsOwner() v3.Cmp {
+ return v3.Compare(v3.CreateRevision(m.myKey), "=", m.myRev)
+}
+
+func (m *Mutex) Key() string { return m.myKey }
+
+// Header is the response header received from etcd on acquiring the lock.
+func (m *Mutex) Header() *pb.ResponseHeader { return m.hdr }
+
+type lockerMutex struct{ *Mutex }
+
+func (lm *lockerMutex) Lock() {
+ client := lm.s.Client()
+ if err := lm.Mutex.Lock(client.Ctx()); err != nil {
+ panic(err)
+ }
+}
+func (lm *lockerMutex) Unlock() {
+ client := lm.s.Client()
+ if err := lm.Mutex.Unlock(client.Ctx()); err != nil {
+ panic(err)
+ }
+}
+
+// NewLocker creates a sync.Locker backed by an etcd mutex.
+func NewLocker(s *Session, pfx string) sync.Locker {
+ return &lockerMutex{NewMutex(s, pfx)}
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/concurrency/session.go b/vendor/github.com/coreos/etcd/clientv3/concurrency/session.go
new file mode 100644
index 00000000..0cb5ea7c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/concurrency/session.go
@@ -0,0 +1,140 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 concurrency
+
+import (
+ "time"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "golang.org/x/net/context"
+)
+
+const defaultSessionTTL = 60
+
+// Session represents a lease kept alive for the lifetime of a client.
+// Fault-tolerant applications may use sessions to reason about liveness.
+type Session struct {
+ client *v3.Client
+ opts *sessionOptions
+ id v3.LeaseID
+
+ cancel context.CancelFunc
+ donec <-chan struct{}
+}
+
+// NewSession gets the leased session for a client.
+func NewSession(client *v3.Client, opts ...SessionOption) (*Session, error) {
+ ops := &sessionOptions{ttl: defaultSessionTTL, ctx: client.Ctx()}
+ for _, opt := range opts {
+ opt(ops)
+ }
+
+ id := ops.leaseID
+ if id == v3.NoLease {
+ resp, err := client.Grant(ops.ctx, int64(ops.ttl))
+ if err != nil {
+ return nil, err
+ }
+ id = v3.LeaseID(resp.ID)
+ }
+
+ ctx, cancel := context.WithCancel(ops.ctx)
+ keepAlive, err := client.KeepAlive(ctx, id)
+ if err != nil || keepAlive == nil {
+ return nil, err
+ }
+
+ donec := make(chan struct{})
+ s := &Session{client: client, opts: ops, id: id, cancel: cancel, donec: donec}
+
+ // keep the lease alive until client error or cancelled context
+ go func() {
+ defer close(donec)
+ for range keepAlive {
+ // eat messages until keep alive channel closes
+ }
+ }()
+
+ return s, nil
+}
+
+// Client is the etcd client that is attached to the session.
+func (s *Session) Client() *v3.Client {
+ return s.client
+}
+
+// Lease is the lease ID for keys bound to the session.
+func (s *Session) Lease() v3.LeaseID { return s.id }
+
+// Done returns a channel that closes when the lease is orphaned, expires, or
+// is otherwise no longer being refreshed.
+func (s *Session) Done() <-chan struct{} { return s.donec }
+
+// Orphan ends the refresh for the session lease. This is useful
+// in case the state of the client connection is indeterminate (revoke
+// would fail) or when transferring lease ownership.
+func (s *Session) Orphan() {
+ s.cancel()
+ <-s.donec
+}
+
+// Close orphans the session and revokes the session lease.
+func (s *Session) Close() error {
+ s.Orphan()
+ // if revoke takes longer than the ttl, lease is expired anyway
+ ctx, cancel := context.WithTimeout(s.opts.ctx, time.Duration(s.opts.ttl)*time.Second)
+ _, err := s.client.Revoke(ctx, s.id)
+ cancel()
+ return err
+}
+
+type sessionOptions struct {
+ ttl int
+ leaseID v3.LeaseID
+ ctx context.Context
+}
+
+// SessionOption configures Session.
+type SessionOption func(*sessionOptions)
+
+// WithTTL configures the session's TTL in seconds.
+// If TTL is <= 0, the default 60 seconds TTL will be used.
+func WithTTL(ttl int) SessionOption {
+ return func(so *sessionOptions) {
+ if ttl > 0 {
+ so.ttl = ttl
+ }
+ }
+}
+
+// WithLease specifies the existing leaseID to be used for the session.
+// This is useful in process restart scenario, for example, to reclaim
+// leadership from an election prior to restart.
+func WithLease(leaseID v3.LeaseID) SessionOption {
+ return func(so *sessionOptions) {
+ so.leaseID = leaseID
+ }
+}
+
+// WithContext assigns a context to the session instead of defaulting to
+// using the client context. This is useful for canceling NewSession and
+// Close operations immediately without having to close the client. If the
+// context is canceled before Close() completes, the session's lease will be
+// abandoned and left to expire instead of being revoked.
+func WithContext(ctx context.Context) SessionOption {
+ return func(so *sessionOptions) {
+ so.ctx = ctx
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/concurrency/stm.go b/vendor/github.com/coreos/etcd/clientv3/concurrency/stm.go
new file mode 100644
index 00000000..bba05866
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/concurrency/stm.go
@@ -0,0 +1,386 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 concurrency
+
+import (
+ "math"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "golang.org/x/net/context"
+)
+
+// STM is an interface for software transactional memory.
+type STM interface {
+ // Get returns the value for a key and inserts the key in the txn's read set.
+ // If Get fails, it aborts the transaction with an error, never returning.
+ Get(key ...string) string
+ // Put adds a value for a key to the write set.
+ Put(key, val string, opts ...v3.OpOption)
+ // Rev returns the revision of a key in the read set.
+ Rev(key string) int64
+ // Del deletes a key.
+ Del(key string)
+
+ // commit attempts to apply the txn's changes to the server.
+ commit() *v3.TxnResponse
+ reset()
+}
+
+// Isolation is an enumeration of transactional isolation levels which
+// describes how transactions should interfere and conflict.
+type Isolation int
+
+const (
+ // SerializableSnapshot provides serializable isolation and also checks
+ // for write conflicts.
+ SerializableSnapshot Isolation = iota
+ // Serializable reads within the same transactiona attempt return data
+ // from the at the revision of the first read.
+ Serializable
+ // RepeatableReads reads within the same transaction attempt always
+ // return the same data.
+ RepeatableReads
+ // ReadCommitted reads keys from any committed revision.
+ ReadCommitted
+)
+
+// stmError safely passes STM errors through panic to the STM error channel.
+type stmError struct{ err error }
+
+type stmOptions struct {
+ iso Isolation
+ ctx context.Context
+ prefetch []string
+}
+
+type stmOption func(*stmOptions)
+
+// WithIsolation specifies the transaction isolation level.
+func WithIsolation(lvl Isolation) stmOption {
+ return func(so *stmOptions) { so.iso = lvl }
+}
+
+// WithAbortContext specifies the context for permanently aborting the transaction.
+func WithAbortContext(ctx context.Context) stmOption {
+ return func(so *stmOptions) { so.ctx = ctx }
+}
+
+// WithPrefetch is a hint to prefetch a list of keys before trying to apply.
+// If an STM transaction will unconditionally fetch a set of keys, prefetching
+// those keys will save the round-trip cost from requesting each key one by one
+// with Get().
+func WithPrefetch(keys ...string) stmOption {
+ return func(so *stmOptions) { so.prefetch = append(so.prefetch, keys...) }
+}
+
+// NewSTM initiates a new STM instance, using snapshot isolation by default.
+func NewSTM(c *v3.Client, apply func(STM) error, so ...stmOption) (*v3.TxnResponse, error) {
+ opts := &stmOptions{ctx: c.Ctx()}
+ for _, f := range so {
+ f(opts)
+ }
+ if len(opts.prefetch) != 0 {
+ f := apply
+ apply = func(s STM) error {
+ s.Get(opts.prefetch...)
+ return f(s)
+ }
+ }
+ return runSTM(mkSTM(c, opts), apply)
+}
+
+func mkSTM(c *v3.Client, opts *stmOptions) STM {
+ switch opts.iso {
+ case SerializableSnapshot:
+ s := &stmSerializable{
+ stm: stm{client: c, ctx: opts.ctx},
+ prefetch: make(map[string]*v3.GetResponse),
+ }
+ s.conflicts = func() []v3.Cmp {
+ return append(s.rset.cmps(), s.wset.cmps(s.rset.first()+1)...)
+ }
+ return s
+ case Serializable:
+ s := &stmSerializable{
+ stm: stm{client: c, ctx: opts.ctx},
+ prefetch: make(map[string]*v3.GetResponse),
+ }
+ s.conflicts = func() []v3.Cmp { return s.rset.cmps() }
+ return s
+ case RepeatableReads:
+ s := &stm{client: c, ctx: opts.ctx, getOpts: []v3.OpOption{v3.WithSerializable()}}
+ s.conflicts = func() []v3.Cmp { return s.rset.cmps() }
+ return s
+ case ReadCommitted:
+ s := &stm{client: c, ctx: opts.ctx, getOpts: []v3.OpOption{v3.WithSerializable()}}
+ s.conflicts = func() []v3.Cmp { return nil }
+ return s
+ default:
+ panic("unsupported stm")
+ }
+}
+
+type stmResponse struct {
+ resp *v3.TxnResponse
+ err error
+}
+
+func runSTM(s STM, apply func(STM) error) (*v3.TxnResponse, error) {
+ outc := make(chan stmResponse, 1)
+ go func() {
+ defer func() {
+ if r := recover(); r != nil {
+ e, ok := r.(stmError)
+ if !ok {
+ // client apply panicked
+ panic(r)
+ }
+ outc <- stmResponse{nil, e.err}
+ }
+ }()
+ var out stmResponse
+ for {
+ s.reset()
+ if out.err = apply(s); out.err != nil {
+ break
+ }
+ if out.resp = s.commit(); out.resp != nil {
+ break
+ }
+ }
+ outc <- out
+ }()
+ r := <-outc
+ return r.resp, r.err
+}
+
+// stm implements repeatable-read software transactional memory over etcd
+type stm struct {
+ client *v3.Client
+ ctx context.Context
+ // rset holds read key values and revisions
+ rset readSet
+ // wset holds overwritten keys and their values
+ wset writeSet
+ // getOpts are the opts used for gets
+ getOpts []v3.OpOption
+ // conflicts computes the current conflicts on the txn
+ conflicts func() []v3.Cmp
+}
+
+type stmPut struct {
+ val string
+ op v3.Op
+}
+
+type readSet map[string]*v3.GetResponse
+
+func (rs readSet) add(keys []string, txnresp *v3.TxnResponse) {
+ for i, resp := range txnresp.Responses {
+ rs[keys[i]] = (*v3.GetResponse)(resp.GetResponseRange())
+ }
+}
+
+func (rs readSet) first() int64 {
+ ret := int64(math.MaxInt64 - 1)
+ for _, resp := range rs {
+ if len(resp.Kvs) > 0 && resp.Kvs[0].ModRevision < ret {
+ ret = resp.Kvs[0].ModRevision
+ }
+ }
+ return ret
+}
+
+// cmps guards the txn from updates to read set
+func (rs readSet) cmps() []v3.Cmp {
+ cmps := make([]v3.Cmp, 0, len(rs))
+ for k, rk := range rs {
+ cmps = append(cmps, isKeyCurrent(k, rk))
+ }
+ return cmps
+}
+
+type writeSet map[string]stmPut
+
+func (ws writeSet) get(keys ...string) *stmPut {
+ for _, key := range keys {
+ if wv, ok := ws[key]; ok {
+ return &wv
+ }
+ }
+ return nil
+}
+
+// cmps returns a cmp list testing no writes have happened past rev
+func (ws writeSet) cmps(rev int64) []v3.Cmp {
+ cmps := make([]v3.Cmp, 0, len(ws))
+ for key := range ws {
+ cmps = append(cmps, v3.Compare(v3.ModRevision(key), "<", rev))
+ }
+ return cmps
+}
+
+// puts is the list of ops for all pending writes
+func (ws writeSet) puts() []v3.Op {
+ puts := make([]v3.Op, 0, len(ws))
+ for _, v := range ws {
+ puts = append(puts, v.op)
+ }
+ return puts
+}
+
+func (s *stm) Get(keys ...string) string {
+ if wv := s.wset.get(keys...); wv != nil {
+ return wv.val
+ }
+ return respToValue(s.fetch(keys...))
+}
+
+func (s *stm) Put(key, val string, opts ...v3.OpOption) {
+ s.wset[key] = stmPut{val, v3.OpPut(key, val, opts...)}
+}
+
+func (s *stm) Del(key string) { s.wset[key] = stmPut{"", v3.OpDelete(key)} }
+
+func (s *stm) Rev(key string) int64 {
+ if resp := s.fetch(key); resp != nil && len(resp.Kvs) != 0 {
+ return resp.Kvs[0].ModRevision
+ }
+ return 0
+}
+
+func (s *stm) commit() *v3.TxnResponse {
+ txnresp, err := s.client.Txn(s.ctx).If(s.conflicts()...).Then(s.wset.puts()...).Commit()
+ if err != nil {
+ panic(stmError{err})
+ }
+ if txnresp.Succeeded {
+ return txnresp
+ }
+ return nil
+}
+
+func (s *stm) fetch(keys ...string) *v3.GetResponse {
+ if len(keys) == 0 {
+ return nil
+ }
+ ops := make([]v3.Op, len(keys))
+ for i, key := range keys {
+ if resp, ok := s.rset[key]; ok {
+ return resp
+ }
+ ops[i] = v3.OpGet(key, s.getOpts...)
+ }
+ txnresp, err := s.client.Txn(s.ctx).Then(ops...).Commit()
+ if err != nil {
+ panic(stmError{err})
+ }
+ s.rset.add(keys, txnresp)
+ return (*v3.GetResponse)(txnresp.Responses[0].GetResponseRange())
+}
+
+func (s *stm) reset() {
+ s.rset = make(map[string]*v3.GetResponse)
+ s.wset = make(map[string]stmPut)
+}
+
+type stmSerializable struct {
+ stm
+ prefetch map[string]*v3.GetResponse
+}
+
+func (s *stmSerializable) Get(keys ...string) string {
+ if wv := s.wset.get(keys...); wv != nil {
+ return wv.val
+ }
+ firstRead := len(s.rset) == 0
+ for _, key := range keys {
+ if resp, ok := s.prefetch[key]; ok {
+ delete(s.prefetch, key)
+ s.rset[key] = resp
+ }
+ }
+ resp := s.stm.fetch(keys...)
+ if firstRead {
+ // txn's base revision is defined by the first read
+ s.getOpts = []v3.OpOption{
+ v3.WithRev(resp.Header.Revision),
+ v3.WithSerializable(),
+ }
+ }
+ return respToValue(resp)
+}
+
+func (s *stmSerializable) Rev(key string) int64 {
+ s.Get(key)
+ return s.stm.Rev(key)
+}
+
+func (s *stmSerializable) gets() ([]string, []v3.Op) {
+ keys := make([]string, 0, len(s.rset))
+ ops := make([]v3.Op, 0, len(s.rset))
+ for k := range s.rset {
+ keys = append(keys, k)
+ ops = append(ops, v3.OpGet(k))
+ }
+ return keys, ops
+}
+
+func (s *stmSerializable) commit() *v3.TxnResponse {
+ keys, getops := s.gets()
+ txn := s.client.Txn(s.ctx).If(s.conflicts()...).Then(s.wset.puts()...)
+ // use Else to prefetch keys in case of conflict to save a round trip
+ txnresp, err := txn.Else(getops...).Commit()
+ if err != nil {
+ panic(stmError{err})
+ }
+ if txnresp.Succeeded {
+ return txnresp
+ }
+ // load prefetch with Else data
+ s.rset.add(keys, txnresp)
+ s.prefetch = s.rset
+ s.getOpts = nil
+ return nil
+}
+
+func isKeyCurrent(k string, r *v3.GetResponse) v3.Cmp {
+ if len(r.Kvs) != 0 {
+ return v3.Compare(v3.ModRevision(k), "=", r.Kvs[0].ModRevision)
+ }
+ return v3.Compare(v3.ModRevision(k), "=", 0)
+}
+
+func respToValue(resp *v3.GetResponse) string {
+ if resp == nil || len(resp.Kvs) == 0 {
+ return ""
+ }
+ return string(resp.Kvs[0].Value)
+}
+
+// NewSTMRepeatable is deprecated.
+func NewSTMRepeatable(ctx context.Context, c *v3.Client, apply func(STM) error) (*v3.TxnResponse, error) {
+ return NewSTM(c, apply, WithAbortContext(ctx), WithIsolation(RepeatableReads))
+}
+
+// NewSTMSerializable is deprecated.
+func NewSTMSerializable(ctx context.Context, c *v3.Client, apply func(STM) error) (*v3.TxnResponse, error) {
+ return NewSTM(c, apply, WithAbortContext(ctx), WithIsolation(Serializable))
+}
+
+// NewSTMReadCommitted is deprecated.
+func NewSTMReadCommitted(ctx context.Context, c *v3.Client, apply func(STM) error) (*v3.TxnResponse, error) {
+ return NewSTM(c, apply, WithAbortContext(ctx), WithIsolation(ReadCommitted))
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/config.go b/vendor/github.com/coreos/etcd/clientv3/config.go
new file mode 100644
index 00000000..dda72a74
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/config.go
@@ -0,0 +1,54 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "crypto/tls"
+ "time"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+type Config struct {
+ // Endpoints is a list of URLs.
+ Endpoints []string `json:"endpoints"`
+
+ // AutoSyncInterval is the interval to update endpoints with its latest members.
+ // 0 disables auto-sync. By default auto-sync is disabled.
+ AutoSyncInterval time.Duration `json:"auto-sync-interval"`
+
+ // DialTimeout is the timeout for failing to establish a connection.
+ DialTimeout time.Duration `json:"dial-timeout"`
+
+ // TLS holds the client secure credentials, if any.
+ TLS *tls.Config
+
+ // Username is a username for authentication.
+ Username string `json:"username"`
+
+ // Password is a password for authentication.
+ Password string `json:"password"`
+
+ // RejectOldCluster when set will refuse to create a client against an outdated cluster.
+ RejectOldCluster bool `json:"reject-old-cluster"`
+
+ // DialOptions is a list of dial options for the grpc client (e.g., for interceptors).
+ DialOptions []grpc.DialOption
+
+ // Context is the default client context; it can be used to cancel grpc dial out and
+ // other operations that do not have an explicit context.
+ Context context.Context
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/doc.go b/vendor/github.com/coreos/etcd/clientv3/doc.go
new file mode 100644
index 00000000..470ca4dc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/doc.go
@@ -0,0 +1,64 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3 implements the official Go etcd client for v3.
+//
+// Create client using `clientv3.New`:
+//
+// cli, err := clientv3.New(clientv3.Config{
+// Endpoints: []string{"localhost:2379", "localhost:22379", "localhost:32379"},
+// DialTimeout: 5 * time.Second,
+// })
+// if err != nil {
+// // handle error!
+// }
+// defer cli.Close()
+//
+// Make sure to close the client after using it. If the client is not closed, the
+// connection will have leaky goroutines.
+//
+// To specify client request timeout, pass context.WithTimeout to APIs:
+//
+// ctx, cancel := context.WithTimeout(context.Background(), timeout)
+// resp, err := kvc.Put(ctx, "sample_key", "sample_value")
+// cancel()
+// if err != nil {
+// // handle error!
+// }
+// // use the response
+//
+// The Client has internal state (watchers and leases), so Clients should be reused instead of created as needed.
+// Clients are safe for concurrent use by multiple goroutines.
+//
+// etcd client returns 2 types of errors:
+//
+// 1. context error: canceled or deadline exceeded.
+// 2. gRPC error: see https://github.com/coreos/etcd/blob/master/etcdserver/api/v3rpc/rpctypes/error.go
+//
+// Here is the example code to handle client errors:
+//
+// resp, err := kvc.Put(ctx, "", "")
+// if err != nil {
+// if err == context.Canceled {
+// // ctx is canceled by another routine
+// } else if err == context.DeadlineExceeded {
+// // ctx is attached with a deadline and it exceeded
+// } else if verr, ok := err.(*v3rpc.ErrEmptyKey); ok {
+// // process (verr.Errors)
+// } else {
+// // bad cluster endpoints, which are not etcd servers
+// }
+// }
+//
+package clientv3
diff --git a/vendor/github.com/coreos/etcd/clientv3/example_auth_test.go b/vendor/github.com/coreos/etcd/clientv3/example_auth_test.go
new file mode 100644
index 00000000..f07e5095
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/example_auth_test.go
@@ -0,0 +1,113 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3_test
+
+import (
+ "fmt"
+ "log"
+
+ "github.com/coreos/etcd/clientv3"
+ "golang.org/x/net/context"
+)
+
+func ExampleAuth() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ if _, err = cli.RoleAdd(context.TODO(), "root"); err != nil {
+ log.Fatal(err)
+ }
+ if _, err = cli.UserAdd(context.TODO(), "root", "123"); err != nil {
+ log.Fatal(err)
+ }
+ if _, err = cli.UserGrantRole(context.TODO(), "root", "root"); err != nil {
+ log.Fatal(err)
+ }
+
+ if _, err = cli.RoleAdd(context.TODO(), "r"); err != nil {
+ log.Fatal(err)
+ }
+
+ if _, err = cli.RoleGrantPermission(
+ context.TODO(),
+ "r", // role name
+ "foo", // key
+ "zoo", // range end
+ clientv3.PermissionType(clientv3.PermReadWrite),
+ ); err != nil {
+ log.Fatal(err)
+ }
+ if _, err = cli.UserAdd(context.TODO(), "u", "123"); err != nil {
+ log.Fatal(err)
+ }
+ if _, err = cli.UserGrantRole(context.TODO(), "u", "r"); err != nil {
+ log.Fatal(err)
+ }
+ if _, err = cli.AuthEnable(context.TODO()); err != nil {
+ log.Fatal(err)
+ }
+
+ cliAuth, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ Username: "u",
+ Password: "123",
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cliAuth.Close()
+
+ if _, err = cliAuth.Put(context.TODO(), "foo1", "bar"); err != nil {
+ log.Fatal(err)
+ }
+
+ _, err = cliAuth.Txn(context.TODO()).
+ If(clientv3.Compare(clientv3.Value("zoo1"), ">", "abc")).
+ Then(clientv3.OpPut("zoo1", "XYZ")).
+ Else(clientv3.OpPut("zoo1", "ABC")).
+ Commit()
+ fmt.Println(err)
+
+ // now check the permission with the root account
+ rootCli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ Username: "root",
+ Password: "123",
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer rootCli.Close()
+
+ resp, err := rootCli.RoleGet(context.TODO(), "r")
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Printf("user u permission: key %q, range end %q\n", resp.Perm[0].Key, resp.Perm[0].RangeEnd)
+
+ if _, err = rootCli.AuthDisable(context.TODO()); err != nil {
+ log.Fatal(err)
+ }
+ // Output: etcdserver: permission denied
+ // user u permission: key "foo", range end "zoo"
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/example_cluster_test.go b/vendor/github.com/coreos/etcd/clientv3/example_cluster_test.go
new file mode 100644
index 00000000..e9e516ba
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/example_cluster_test.go
@@ -0,0 +1,103 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3_test
+
+import (
+ "fmt"
+ "log"
+
+ "github.com/coreos/etcd/clientv3"
+ "golang.org/x/net/context"
+)
+
+func ExampleCluster_memberList() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ resp, err := cli.MemberList(context.Background())
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println("members:", len(resp.Members))
+ // Output: members: 3
+}
+
+func ExampleCluster_memberAdd() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints[:2],
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ peerURLs := endpoints[2:]
+ mresp, err := cli.MemberAdd(context.Background(), peerURLs)
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println("added member.PeerURLs:", mresp.Member.PeerURLs)
+ // added member.PeerURLs: [http://localhost:32380]
+}
+
+func ExampleCluster_memberRemove() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints[1:],
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ resp, err := cli.MemberList(context.Background())
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ _, err = cli.MemberRemove(context.Background(), resp.Members[0].ID)
+ if err != nil {
+ log.Fatal(err)
+ }
+}
+
+func ExampleCluster_memberUpdate() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ resp, err := cli.MemberList(context.Background())
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ peerURLs := []string{"http://localhost:12380"}
+ _, err = cli.MemberUpdate(context.Background(), resp.Members[0].ID, peerURLs)
+ if err != nil {
+ log.Fatal(err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/example_kv_test.go b/vendor/github.com/coreos/etcd/clientv3/example_kv_test.go
new file mode 100644
index 00000000..340b0781
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/example_kv_test.go
@@ -0,0 +1,279 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3_test
+
+import (
+ "fmt"
+ "log"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ "golang.org/x/net/context"
+)
+
+func ExampleKV_put() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ _, err = cli.Put(ctx, "sample_key", "sample_value")
+ cancel()
+ if err != nil {
+ log.Fatal(err)
+ }
+}
+
+func ExampleKV_putErrorHandling() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ _, err = cli.Put(ctx, "", "sample_value")
+ cancel()
+ if err != nil {
+ switch err {
+ case context.Canceled:
+ fmt.Printf("ctx is canceled by another routine: %v\n", err)
+ case context.DeadlineExceeded:
+ fmt.Printf("ctx is attached with a deadline is exceeded: %v\n", err)
+ case rpctypes.ErrEmptyKey:
+ fmt.Printf("client-side error: %v\n", err)
+ default:
+ fmt.Printf("bad cluster endpoints, which are not etcd servers: %v\n", err)
+ }
+ }
+ // Output: client-side error: etcdserver: key is not provided
+}
+
+func ExampleKV_get() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ _, err = cli.Put(context.TODO(), "foo", "bar")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ resp, err := cli.Get(ctx, "foo")
+ cancel()
+ if err != nil {
+ log.Fatal(err)
+ }
+ for _, ev := range resp.Kvs {
+ fmt.Printf("%s : %s\n", ev.Key, ev.Value)
+ }
+ // Output: foo : bar
+}
+
+func ExampleKV_getWithRev() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ presp, err := cli.Put(context.TODO(), "foo", "bar1")
+ if err != nil {
+ log.Fatal(err)
+ }
+ _, err = cli.Put(context.TODO(), "foo", "bar2")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ resp, err := cli.Get(ctx, "foo", clientv3.WithRev(presp.Header.Revision))
+ cancel()
+ if err != nil {
+ log.Fatal(err)
+ }
+ for _, ev := range resp.Kvs {
+ fmt.Printf("%s : %s\n", ev.Key, ev.Value)
+ }
+ // Output: foo : bar1
+}
+
+func ExampleKV_getSortedPrefix() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ for i := range make([]int, 3) {
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ _, err = cli.Put(ctx, fmt.Sprintf("key_%d", i), "value")
+ cancel()
+ if err != nil {
+ log.Fatal(err)
+ }
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ resp, err := cli.Get(ctx, "key", clientv3.WithPrefix(), clientv3.WithSort(clientv3.SortByKey, clientv3.SortDescend))
+ cancel()
+ if err != nil {
+ log.Fatal(err)
+ }
+ for _, ev := range resp.Kvs {
+ fmt.Printf("%s : %s\n", ev.Key, ev.Value)
+ }
+ // Output:
+ // key_2 : value
+ // key_1 : value
+ // key_0 : value
+}
+
+func ExampleKV_delete() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ defer cancel()
+
+ // count keys about to be deleted
+ gresp, err := cli.Get(ctx, "key", clientv3.WithPrefix())
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ // delete the keys
+ dresp, err := cli.Delete(ctx, "key", clientv3.WithPrefix())
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Println("Deleted all keys:", int64(len(gresp.Kvs)) == dresp.Deleted)
+ // Output:
+ // Deleted all keys: true
+}
+
+func ExampleKV_compact() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ resp, err := cli.Get(ctx, "foo")
+ cancel()
+ if err != nil {
+ log.Fatal(err)
+ }
+ compRev := resp.Header.Revision // specify compact revision of your choice
+
+ ctx, cancel = context.WithTimeout(context.Background(), requestTimeout)
+ _, err = cli.Compact(ctx, compRev)
+ cancel()
+ if err != nil {
+ log.Fatal(err)
+ }
+}
+
+func ExampleKV_txn() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ kvc := clientv3.NewKV(cli)
+
+ _, err = kvc.Put(context.TODO(), "key", "xyz")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ _, err = kvc.Txn(ctx).
+ If(clientv3.Compare(clientv3.Value("key"), ">", "abc")). // txn value comparisons are lexical
+ Then(clientv3.OpPut("key", "XYZ")). // this runs, since 'xyz' > 'abc'
+ Else(clientv3.OpPut("key", "ABC")).
+ Commit()
+ cancel()
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ gresp, err := kvc.Get(context.TODO(), "key")
+ cancel()
+ if err != nil {
+ log.Fatal(err)
+ }
+ for _, ev := range gresp.Kvs {
+ fmt.Printf("%s : %s\n", ev.Key, ev.Value)
+ }
+ // Output: key : XYZ
+}
+
+func ExampleKV_do() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ ops := []clientv3.Op{
+ clientv3.OpPut("put-key", "123"),
+ clientv3.OpGet("put-key"),
+ clientv3.OpPut("put-key", "456")}
+
+ for _, op := range ops {
+ if _, err := cli.Do(context.TODO(), op); err != nil {
+ log.Fatal(err)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/example_lease_test.go b/vendor/github.com/coreos/etcd/clientv3/example_lease_test.go
new file mode 100644
index 00000000..e1bd57a1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/example_lease_test.go
@@ -0,0 +1,141 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3_test
+
+import (
+ "fmt"
+ "log"
+
+ "github.com/coreos/etcd/clientv3"
+ "golang.org/x/net/context"
+)
+
+func ExampleLease_grant() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ // minimum lease TTL is 5-second
+ resp, err := cli.Grant(context.TODO(), 5)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ // after 5 seconds, the key 'foo' will be removed
+ _, err = cli.Put(context.TODO(), "foo", "bar", clientv3.WithLease(resp.ID))
+ if err != nil {
+ log.Fatal(err)
+ }
+}
+
+func ExampleLease_revoke() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ resp, err := cli.Grant(context.TODO(), 5)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ _, err = cli.Put(context.TODO(), "foo", "bar", clientv3.WithLease(resp.ID))
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ // revoking lease expires the key attached to its lease ID
+ _, err = cli.Revoke(context.TODO(), resp.ID)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ gresp, err := cli.Get(context.TODO(), "foo")
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println("number of keys:", len(gresp.Kvs))
+ // Output: number of keys: 0
+}
+
+func ExampleLease_keepAlive() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ resp, err := cli.Grant(context.TODO(), 5)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ _, err = cli.Put(context.TODO(), "foo", "bar", clientv3.WithLease(resp.ID))
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ // the key 'foo' will be kept forever
+ ch, kaerr := cli.KeepAlive(context.TODO(), resp.ID)
+ if kaerr != nil {
+ log.Fatal(kaerr)
+ }
+
+ ka := <-ch
+ fmt.Println("ttl:", ka.TTL)
+ // Output: ttl: 5
+}
+
+func ExampleLease_keepAliveOnce() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ resp, err := cli.Grant(context.TODO(), 5)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ _, err = cli.Put(context.TODO(), "foo", "bar", clientv3.WithLease(resp.ID))
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ // to renew the lease only once
+ ka, kaerr := cli.KeepAliveOnce(context.TODO(), resp.ID)
+ if kaerr != nil {
+ log.Fatal(kaerr)
+ }
+
+ fmt.Println("ttl:", ka.TTL)
+ // Output: ttl: 5
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/example_maintenence_test.go b/vendor/github.com/coreos/etcd/clientv3/example_maintenence_test.go
new file mode 100644
index 00000000..9753176a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/example_maintenence_test.go
@@ -0,0 +1,68 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3_test
+
+import (
+ "fmt"
+ "log"
+
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/clientv3"
+)
+
+func ExampleMaintenance_status() {
+ for _, ep := range endpoints {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: []string{ep},
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ // resp, err := cli.Status(context.Background(), ep)
+ //
+ // or
+ //
+ mapi := clientv3.NewMaintenance(cli)
+ resp, err := mapi.Status(context.Background(), ep)
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Printf("endpoint: %s / IsLeader: %v\n", ep, resp.Header.MemberId == resp.Leader)
+ }
+ // endpoint: localhost:2379 / IsLeader: false
+ // endpoint: localhost:22379 / IsLeader: false
+ // endpoint: localhost:32379 / IsLeader: true
+}
+
+func ExampleMaintenance_defragment() {
+ for _, ep := range endpoints {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: []string{ep},
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ if _, err = cli.Defragment(context.TODO(), ep); err != nil {
+ log.Fatal(err)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/example_metrics_test.go b/vendor/github.com/coreos/etcd/clientv3/example_metrics_test.go
new file mode 100644
index 00000000..6e5fd5e0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/example_metrics_test.go
@@ -0,0 +1,84 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3_test
+
+import (
+ "fmt"
+ "io/ioutil"
+ "log"
+ "net"
+ "net/http"
+ "strings"
+
+ "github.com/coreos/etcd/clientv3"
+
+ grpcprom "github.com/grpc-ecosystem/go-grpc-prometheus"
+ "github.com/prometheus/client_golang/prometheus"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+func ExampleClient_metrics() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialOptions: []grpc.DialOption{
+ grpc.WithUnaryInterceptor(grpcprom.UnaryClientInterceptor),
+ grpc.WithStreamInterceptor(grpcprom.StreamClientInterceptor),
+ },
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ // get a key so it shows up in the metrics as a range rpc
+ cli.Get(context.TODO(), "test_key")
+
+ // listen for all prometheus metrics
+ ln, err := net.Listen("tcp", ":0")
+ if err != nil {
+ log.Fatal(err)
+ }
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ http.Serve(ln, prometheus.Handler())
+ }()
+ defer func() {
+ ln.Close()
+ <-donec
+ }()
+
+ // make an http request to fetch all prometheus metrics
+ url := "http://" + ln.Addr().String() + "/metrics"
+ resp, err := http.Get(url)
+ if err != nil {
+ log.Fatalf("fetch error: %v", err)
+ }
+ b, err := ioutil.ReadAll(resp.Body)
+ resp.Body.Close()
+ if err != nil {
+ log.Fatalf("fetch error: reading %s: %v", url, err)
+ }
+
+ // confirm range request in metrics
+ for _, l := range strings.Split(string(b), "\n") {
+ if strings.Contains(l, `grpc_client_started_total{grpc_method="Range"`) {
+ fmt.Println(l)
+ break
+ }
+ }
+ // Output: grpc_client_started_total{grpc_method="Range",grpc_service="etcdserverpb.KV",grpc_type="unary"} 1
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/example_test.go b/vendor/github.com/coreos/etcd/clientv3/example_test.go
new file mode 100644
index 00000000..4e9b5042
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/example_test.go
@@ -0,0 +1,76 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3_test
+
+import (
+ "log"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/pkg/transport"
+ "github.com/coreos/pkg/capnslog"
+ "golang.org/x/net/context"
+)
+
+var (
+ dialTimeout = 5 * time.Second
+ requestTimeout = 10 * time.Second
+ endpoints = []string{"localhost:2379", "localhost:22379", "localhost:32379"}
+)
+
+func Example() {
+ var plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "clientv3")
+ clientv3.SetLogger(plog)
+
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close() // make sure to close the client
+
+ _, err = cli.Put(context.TODO(), "foo", "bar")
+ if err != nil {
+ log.Fatal(err)
+ }
+}
+
+func ExampleConfig_withTLS() {
+ tlsInfo := transport.TLSInfo{
+ CertFile: "/tmp/test-certs/test-name-1.pem",
+ KeyFile: "/tmp/test-certs/test-name-1-key.pem",
+ TrustedCAFile: "/tmp/test-certs/trusted-ca.pem",
+ }
+ tlsConfig, err := tlsInfo.ClientConfig()
+ if err != nil {
+ log.Fatal(err)
+ }
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ TLS: tlsConfig,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close() // make sure to close the client
+
+ _, err = cli.Put(context.TODO(), "foo", "bar")
+ if err != nil {
+ log.Fatal(err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/example_watch_test.go b/vendor/github.com/coreos/etcd/clientv3/example_watch_test.go
new file mode 100644
index 00000000..b3a0f1dd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/example_watch_test.go
@@ -0,0 +1,100 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3_test
+
+import (
+ "fmt"
+ "log"
+
+ "github.com/coreos/etcd/clientv3"
+ "golang.org/x/net/context"
+)
+
+func ExampleWatcher_watch() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ rch := cli.Watch(context.Background(), "foo")
+ for wresp := range rch {
+ for _, ev := range wresp.Events {
+ fmt.Printf("%s %q : %q\n", ev.Type, ev.Kv.Key, ev.Kv.Value)
+ }
+ }
+ // PUT "foo" : "bar"
+}
+
+func ExampleWatcher_watchWithPrefix() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ rch := cli.Watch(context.Background(), "foo", clientv3.WithPrefix())
+ for wresp := range rch {
+ for _, ev := range wresp.Events {
+ fmt.Printf("%s %q : %q\n", ev.Type, ev.Kv.Key, ev.Kv.Value)
+ }
+ }
+ // PUT "foo1" : "bar"
+}
+
+func ExampleWatcher_watchWithRange() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer cli.Close()
+
+ // watches within ['foo1', 'foo4'), in lexicographical order
+ rch := cli.Watch(context.Background(), "foo1", clientv3.WithRange("foo4"))
+ for wresp := range rch {
+ for _, ev := range wresp.Events {
+ fmt.Printf("%s %q : %q\n", ev.Type, ev.Kv.Key, ev.Kv.Value)
+ }
+ }
+ // PUT "foo1" : "bar"
+ // PUT "foo2" : "bar"
+ // PUT "foo3" : "bar"
+}
+
+func ExampleWatcher_watchWithProgressNotify() {
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ rch := cli.Watch(context.Background(), "foo", clientv3.WithProgressNotify())
+ wresp := <-rch
+ fmt.Printf("wresp.Header.Revision: %d\n", wresp.Header.Revision)
+ fmt.Println("wresp.IsProgressNotify:", wresp.IsProgressNotify())
+ // wresp.Header.Revision: 0
+ // wresp.IsProgressNotify: true
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/integration/cluster_test.go b/vendor/github.com/coreos/etcd/clientv3/integration/cluster_test.go
new file mode 100644
index 00000000..6397f8a8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/integration/cluster_test.go
@@ -0,0 +1,128 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/pkg/types"
+ "golang.org/x/net/context"
+)
+
+func TestMemberList(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ capi := clus.RandClient()
+
+ resp, err := capi.MemberList(context.Background())
+ if err != nil {
+ t.Fatalf("failed to list member %v", err)
+ }
+
+ if len(resp.Members) != 3 {
+ t.Errorf("number of members = %d, want %d", len(resp.Members), 3)
+ }
+}
+
+func TestMemberAdd(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ capi := clus.RandClient()
+
+ urls := []string{"http://127.0.0.1:1234"}
+ resp, err := capi.MemberAdd(context.Background(), urls)
+ if err != nil {
+ t.Fatalf("failed to add member %v", err)
+ }
+
+ if !reflect.DeepEqual(resp.Member.PeerURLs, urls) {
+ t.Errorf("urls = %v, want %v", urls, resp.Member.PeerURLs)
+ }
+}
+
+func TestMemberRemove(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ capi := clus.Client(1)
+ resp, err := capi.MemberList(context.Background())
+ if err != nil {
+ t.Fatalf("failed to list member %v", err)
+ }
+
+ rmvID := resp.Members[0].ID
+ // indexes in capi member list don't necessarily match cluster member list;
+ // find member that is not the client to remove
+ for _, m := range resp.Members {
+ mURLs, _ := types.NewURLs(m.PeerURLs)
+ if !reflect.DeepEqual(mURLs, clus.Members[1].ServerConfig.PeerURLs) {
+ rmvID = m.ID
+ break
+ }
+ }
+
+ _, err = capi.MemberRemove(context.Background(), rmvID)
+ if err != nil {
+ t.Fatalf("failed to remove member %v", err)
+ }
+
+ resp, err = capi.MemberList(context.Background())
+ if err != nil {
+ t.Fatalf("failed to list member %v", err)
+ }
+
+ if len(resp.Members) != 2 {
+ t.Errorf("number of members = %d, want %d", len(resp.Members), 2)
+ }
+}
+
+func TestMemberUpdate(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ capi := clus.RandClient()
+ resp, err := capi.MemberList(context.Background())
+ if err != nil {
+ t.Fatalf("failed to list member %v", err)
+ }
+
+ urls := []string{"http://127.0.0.1:1234"}
+ _, err = capi.MemberUpdate(context.Background(), resp.Members[0].ID, urls)
+ if err != nil {
+ t.Fatalf("failed to update member %v", err)
+ }
+
+ resp, err = capi.MemberList(context.Background())
+ if err != nil {
+ t.Fatalf("failed to list member %v", err)
+ }
+
+ if !reflect.DeepEqual(resp.Members[0].PeerURLs, urls) {
+ t.Errorf("urls = %v, want %v", urls, resp.Members[0].PeerURLs)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/integration/dial_test.go b/vendor/github.com/coreos/etcd/clientv3/integration/dial_test.go
new file mode 100644
index 00000000..4d8075de
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/integration/dial_test.go
@@ -0,0 +1,191 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "math/rand"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/pkg/transport"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+var (
+ testTLSInfo = transport.TLSInfo{
+ KeyFile: "../../integration/fixtures/server.key.insecure",
+ CertFile: "../../integration/fixtures/server.crt",
+ TrustedCAFile: "../../integration/fixtures/ca.crt",
+ ClientCertAuth: true,
+ }
+
+ testTLSInfoExpired = transport.TLSInfo{
+ KeyFile: "../../integration/fixtures-expired/server-key.pem",
+ CertFile: "../../integration/fixtures-expired/server.pem",
+ TrustedCAFile: "../../integration/fixtures-expired/etcd-root-ca.pem",
+ ClientCertAuth: true,
+ }
+)
+
+// TestDialTLSExpired tests client with expired certs fails to dial.
+func TestDialTLSExpired(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1, PeerTLS: &testTLSInfo, ClientTLS: &testTLSInfo})
+ defer clus.Terminate(t)
+
+ tls, err := testTLSInfoExpired.ClientConfig()
+ if err != nil {
+ t.Fatal(err)
+ }
+ // expect remote errors 'tls: bad certificate'
+ _, err = clientv3.New(clientv3.Config{
+ Endpoints: []string{clus.Members[0].GRPCAddr()},
+ DialTimeout: 3 * time.Second,
+ TLS: tls,
+ })
+ if err != grpc.ErrClientConnTimeout {
+ t.Fatalf("expected %v, got %v", grpc.ErrClientConnTimeout, err)
+ }
+}
+
+// TestDialTLSNoConfig ensures the client fails to dial / times out
+// when TLS endpoints (https, unixs) are given but no tls config.
+func TestDialTLSNoConfig(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1, ClientTLS: &testTLSInfo})
+ defer clus.Terminate(t)
+ // expect 'signed by unknown authority'
+ _, err := clientv3.New(clientv3.Config{
+ Endpoints: []string{clus.Members[0].GRPCAddr()},
+ DialTimeout: time.Second,
+ })
+ if err != grpc.ErrClientConnTimeout {
+ t.Fatalf("expected %v, got %v", grpc.ErrClientConnTimeout, err)
+ }
+}
+
+// TestDialSetEndpoints ensures SetEndpoints can replace unavailable endpoints with available ones.
+func TestDialSetEndpointsBeforeFail(t *testing.T) {
+ testDialSetEndpoints(t, true)
+}
+
+func TestDialSetEndpointsAfterFail(t *testing.T) {
+ testDialSetEndpoints(t, false)
+}
+
+// testDialSetEndpoints ensures SetEndpoints can replace unavailable endpoints with available ones.
+func testDialSetEndpoints(t *testing.T, setBefore bool) {
+ defer testutil.AfterTest(t)
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ // get endpoint list
+ eps := make([]string, 3)
+ for i := range eps {
+ eps[i] = clus.Members[i].GRPCAddr()
+ }
+ toKill := rand.Intn(len(eps))
+
+ cfg := clientv3.Config{Endpoints: []string{eps[toKill]}, DialTimeout: 1 * time.Second}
+ cli, err := clientv3.New(cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer cli.Close()
+
+ if setBefore {
+ cli.SetEndpoints(eps[toKill%3], eps[(toKill+1)%3])
+ }
+ // make a dead node
+ clus.Members[toKill].Stop(t)
+ clus.WaitLeader(t)
+
+ if !setBefore {
+ cli.SetEndpoints(eps[toKill%3], eps[(toKill+1)%3])
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
+ if _, err = cli.Get(ctx, "foo", clientv3.WithSerializable()); err != nil {
+ t.Fatal(err)
+ }
+ cancel()
+}
+
+// TestSwitchSetEndpoints ensures SetEndpoints can switch one endpoint
+// with a new one that doesn't include original endpoint.
+func TestSwitchSetEndpoints(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ // get non partitioned members endpoints
+ eps := []string{clus.Members[1].GRPCAddr(), clus.Members[2].GRPCAddr()}
+
+ cli := clus.Client(0)
+ clus.Members[0].InjectPartition(t, clus.Members[1:])
+
+ cli.SetEndpoints(eps...)
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ if _, err := cli.Get(ctx, "foo"); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestRejectOldCluster(t *testing.T) {
+ defer testutil.AfterTest(t)
+ // 2 endpoints to test multi-endpoint Status
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 2})
+ defer clus.Terminate(t)
+
+ cfg := clientv3.Config{
+ Endpoints: []string{clus.Members[0].GRPCAddr(), clus.Members[1].GRPCAddr()},
+ DialTimeout: 5 * time.Second,
+ RejectOldCluster: true,
+ }
+ cli, err := clientv3.New(cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ cli.Close()
+}
+
+// TestDialForeignEndpoint checks an endpoint that is not registered
+// with the balancer can be dialed.
+func TestDialForeignEndpoint(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 2})
+ defer clus.Terminate(t)
+
+ conn, err := clus.Client(0).Dial(clus.Client(1).Endpoints()[0])
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer conn.Close()
+
+ // grpc can return a lazy connection that's not connected yet; confirm
+ // that it can communicate with the cluster.
+ kvc := clientv3.NewKVFromKVClient(pb.NewKVClient(conn))
+ ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
+ defer cancel()
+ if _, gerr := kvc.Get(ctx, "abc"); gerr != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/integration/doc.go b/vendor/github.com/coreos/etcd/clientv3/integration/doc.go
new file mode 100644
index 00000000..52dbe41c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/integration/doc.go
@@ -0,0 +1,17 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration implements tests built upon embedded etcd, and focuses on
+// correctness of etcd client.
+package integration
diff --git a/vendor/github.com/coreos/etcd/clientv3/integration/kv_test.go b/vendor/github.com/coreos/etcd/clientv3/integration/kv_test.go
new file mode 100644
index 00000000..49f107f7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/integration/kv_test.go
@@ -0,0 +1,897 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "bytes"
+ "math/rand"
+ "os"
+ "reflect"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/coreos/etcd/pkg/testutil"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+func TestKVPutError(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ var (
+ maxReqBytes = 1.5 * 1024 * 1024 // hard coded max in v3_server.go
+ quota = int64(int(maxReqBytes) + 8*os.Getpagesize())
+ )
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1, QuotaBackendBytes: quota})
+ defer clus.Terminate(t)
+
+ kv := clus.RandClient()
+ ctx := context.TODO()
+
+ _, err := kv.Put(ctx, "", "bar")
+ if err != rpctypes.ErrEmptyKey {
+ t.Fatalf("expected %v, got %v", rpctypes.ErrEmptyKey, err)
+ }
+
+ _, err = kv.Put(ctx, "key", strings.Repeat("a", int(maxReqBytes+100)))
+ if err != rpctypes.ErrRequestTooLarge {
+ t.Fatalf("expected %v, got %v", rpctypes.ErrRequestTooLarge, err)
+ }
+
+ _, err = kv.Put(ctx, "foo1", strings.Repeat("a", int(maxReqBytes-50)))
+ if err != nil { // below quota
+ t.Fatal(err)
+ }
+
+ time.Sleep(1 * time.Second) // give enough time for commit
+
+ _, err = kv.Put(ctx, "foo2", strings.Repeat("a", int(maxReqBytes-50)))
+ if err != rpctypes.ErrNoSpace { // over quota
+ t.Fatalf("expected %v, got %v", rpctypes.ErrNoSpace, err)
+ }
+}
+
+func TestKVPut(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ lapi := clus.RandClient()
+
+ kv := clus.RandClient()
+ ctx := context.TODO()
+
+ resp, err := lapi.Grant(context.Background(), 10)
+ if err != nil {
+ t.Fatalf("failed to create lease %v", err)
+ }
+
+ tests := []struct {
+ key, val string
+ leaseID clientv3.LeaseID
+ }{
+ {"foo", "bar", clientv3.NoLease},
+ {"hello", "world", resp.ID},
+ }
+
+ for i, tt := range tests {
+ if _, err := kv.Put(ctx, tt.key, tt.val, clientv3.WithLease(tt.leaseID)); err != nil {
+ t.Fatalf("#%d: couldn't put %q (%v)", i, tt.key, err)
+ }
+ resp, err := kv.Get(ctx, tt.key)
+ if err != nil {
+ t.Fatalf("#%d: couldn't get key (%v)", i, err)
+ }
+ if len(resp.Kvs) != 1 {
+ t.Fatalf("#%d: expected 1 key, got %d", i, len(resp.Kvs))
+ }
+ if !bytes.Equal([]byte(tt.val), resp.Kvs[0].Value) {
+ t.Errorf("#%d: val = %s, want %s", i, tt.val, resp.Kvs[0].Value)
+ }
+ if tt.leaseID != clientv3.LeaseID(resp.Kvs[0].Lease) {
+ t.Errorf("#%d: val = %d, want %d", i, tt.leaseID, resp.Kvs[0].Lease)
+ }
+ }
+}
+
+// TestKVPutWithIgnoreValue ensures that Put with WithIgnoreValue does not clobber the old value.
+func TestKVPutWithIgnoreValue(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kv := clus.RandClient()
+
+ _, err := kv.Put(context.TODO(), "foo", "", clientv3.WithIgnoreValue())
+ if err != rpctypes.ErrKeyNotFound {
+ t.Fatalf("err expected %v, got %v", rpctypes.ErrKeyNotFound, err)
+ }
+
+ if _, err := kv.Put(context.TODO(), "foo", "bar"); err != nil {
+ t.Fatal(err)
+ }
+
+ if _, err := kv.Put(context.TODO(), "foo", "", clientv3.WithIgnoreValue()); err != nil {
+ t.Fatal(err)
+ }
+ rr, rerr := kv.Get(context.TODO(), "foo")
+ if rerr != nil {
+ t.Fatal(rerr)
+ }
+ if len(rr.Kvs) != 1 {
+ t.Fatalf("len(rr.Kvs) expected 1, got %d", len(rr.Kvs))
+ }
+ if !bytes.Equal(rr.Kvs[0].Value, []byte("bar")) {
+ t.Fatalf("value expected 'bar', got %q", rr.Kvs[0].Value)
+ }
+}
+
+// TestKVPutWithIgnoreLease ensures that Put with WithIgnoreLease does not affect the existing lease for the key.
+func TestKVPutWithIgnoreLease(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kv := clus.RandClient()
+
+ lapi := clus.RandClient()
+
+ resp, err := lapi.Grant(context.Background(), 10)
+ if err != nil {
+ t.Errorf("failed to create lease %v", err)
+ }
+
+ if _, err := kv.Put(context.TODO(), "zoo", "bar", clientv3.WithIgnoreLease()); err != rpctypes.ErrKeyNotFound {
+ t.Fatalf("err expected %v, got %v", rpctypes.ErrKeyNotFound, err)
+ }
+
+ if _, err := kv.Put(context.TODO(), "zoo", "bar", clientv3.WithLease(resp.ID)); err != nil {
+ t.Fatal(err)
+ }
+
+ if _, err := kv.Put(context.TODO(), "zoo", "bar1", clientv3.WithIgnoreLease()); err != nil {
+ t.Fatal(err)
+ }
+
+ rr, rerr := kv.Get(context.TODO(), "zoo")
+ if rerr != nil {
+ t.Fatal(rerr)
+ }
+ if len(rr.Kvs) != 1 {
+ t.Fatalf("len(rr.Kvs) expected 1, got %d", len(rr.Kvs))
+ }
+ if rr.Kvs[0].Lease != int64(resp.ID) {
+ t.Fatalf("lease expected %v, got %v", resp.ID, rr.Kvs[0].Lease)
+ }
+}
+
+func TestKVPutWithRequireLeader(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ clus.Members[1].Stop(t)
+ clus.Members[2].Stop(t)
+
+ // wait for election timeout, then member[0] will not have a leader.
+ var (
+ electionTicks = 10
+ tickDuration = 10 * time.Millisecond
+ )
+ time.Sleep(time.Duration(3*electionTicks) * tickDuration)
+
+ kv := clus.Client(0)
+ _, err := kv.Put(clientv3.WithRequireLeader(context.Background()), "foo", "bar")
+ if err != rpctypes.ErrNoLeader {
+ t.Fatal(err)
+ }
+
+ // clients may give timeout errors since the members are stopped; take
+ // the clients so that terminating the cluster won't complain
+ clus.Client(1).Close()
+ clus.Client(2).Close()
+ clus.TakeClient(1)
+ clus.TakeClient(2)
+}
+
+func TestKVRange(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kv := clus.RandClient()
+ ctx := context.TODO()
+
+ keySet := []string{"a", "b", "c", "c", "c", "foo", "foo/abc", "fop"}
+ for i, key := range keySet {
+ if _, err := kv.Put(ctx, key, ""); err != nil {
+ t.Fatalf("#%d: couldn't put %q (%v)", i, key, err)
+ }
+ }
+ resp, err := kv.Get(ctx, keySet[0])
+ if err != nil {
+ t.Fatalf("couldn't get key (%v)", err)
+ }
+ wheader := resp.Header
+
+ tests := []struct {
+ begin, end string
+ rev int64
+ opts []clientv3.OpOption
+
+ wantSet []*mvccpb.KeyValue
+ }{
+ // range first two
+ {
+ "a", "c",
+ 0,
+ nil,
+
+ []*mvccpb.KeyValue{
+ {Key: []byte("a"), Value: nil, CreateRevision: 2, ModRevision: 2, Version: 1},
+ {Key: []byte("b"), Value: nil, CreateRevision: 3, ModRevision: 3, Version: 1},
+ },
+ },
+ // range first two with serializable
+ {
+ "a", "c",
+ 0,
+ []clientv3.OpOption{clientv3.WithSerializable()},
+
+ []*mvccpb.KeyValue{
+ {Key: []byte("a"), Value: nil, CreateRevision: 2, ModRevision: 2, Version: 1},
+ {Key: []byte("b"), Value: nil, CreateRevision: 3, ModRevision: 3, Version: 1},
+ },
+ },
+ // range all with rev
+ {
+ "a", "x",
+ 2,
+ nil,
+
+ []*mvccpb.KeyValue{
+ {Key: []byte("a"), Value: nil, CreateRevision: 2, ModRevision: 2, Version: 1},
+ },
+ },
+ // range all with countOnly
+ {
+ "a", "x",
+ 2,
+ []clientv3.OpOption{clientv3.WithCountOnly()},
+
+ nil,
+ },
+ // range all with SortByKey, SortAscend
+ {
+ "a", "x",
+ 0,
+ []clientv3.OpOption{clientv3.WithSort(clientv3.SortByKey, clientv3.SortAscend)},
+
+ []*mvccpb.KeyValue{
+ {Key: []byte("a"), Value: nil, CreateRevision: 2, ModRevision: 2, Version: 1},
+ {Key: []byte("b"), Value: nil, CreateRevision: 3, ModRevision: 3, Version: 1},
+ {Key: []byte("c"), Value: nil, CreateRevision: 4, ModRevision: 6, Version: 3},
+ {Key: []byte("foo"), Value: nil, CreateRevision: 7, ModRevision: 7, Version: 1},
+ {Key: []byte("foo/abc"), Value: nil, CreateRevision: 8, ModRevision: 8, Version: 1},
+ {Key: []byte("fop"), Value: nil, CreateRevision: 9, ModRevision: 9, Version: 1},
+ },
+ },
+ // range all with SortByKey, missing sorting order (ASCEND by default)
+ {
+ "a", "x",
+ 0,
+ []clientv3.OpOption{clientv3.WithSort(clientv3.SortByKey, clientv3.SortNone)},
+
+ []*mvccpb.KeyValue{
+ {Key: []byte("a"), Value: nil, CreateRevision: 2, ModRevision: 2, Version: 1},
+ {Key: []byte("b"), Value: nil, CreateRevision: 3, ModRevision: 3, Version: 1},
+ {Key: []byte("c"), Value: nil, CreateRevision: 4, ModRevision: 6, Version: 3},
+ {Key: []byte("foo"), Value: nil, CreateRevision: 7, ModRevision: 7, Version: 1},
+ {Key: []byte("foo/abc"), Value: nil, CreateRevision: 8, ModRevision: 8, Version: 1},
+ {Key: []byte("fop"), Value: nil, CreateRevision: 9, ModRevision: 9, Version: 1},
+ },
+ },
+ // range all with SortByCreateRevision, SortDescend
+ {
+ "a", "x",
+ 0,
+ []clientv3.OpOption{clientv3.WithSort(clientv3.SortByCreateRevision, clientv3.SortDescend)},
+
+ []*mvccpb.KeyValue{
+ {Key: []byte("fop"), Value: nil, CreateRevision: 9, ModRevision: 9, Version: 1},
+ {Key: []byte("foo/abc"), Value: nil, CreateRevision: 8, ModRevision: 8, Version: 1},
+ {Key: []byte("foo"), Value: nil, CreateRevision: 7, ModRevision: 7, Version: 1},
+ {Key: []byte("c"), Value: nil, CreateRevision: 4, ModRevision: 6, Version: 3},
+ {Key: []byte("b"), Value: nil, CreateRevision: 3, ModRevision: 3, Version: 1},
+ {Key: []byte("a"), Value: nil, CreateRevision: 2, ModRevision: 2, Version: 1},
+ },
+ },
+ // range all with SortByCreateRevision, missing sorting order (ASCEND by default)
+ {
+ "a", "x",
+ 0,
+ []clientv3.OpOption{clientv3.WithSort(clientv3.SortByCreateRevision, clientv3.SortNone)},
+
+ []*mvccpb.KeyValue{
+ {Key: []byte("a"), Value: nil, CreateRevision: 2, ModRevision: 2, Version: 1},
+ {Key: []byte("b"), Value: nil, CreateRevision: 3, ModRevision: 3, Version: 1},
+ {Key: []byte("c"), Value: nil, CreateRevision: 4, ModRevision: 6, Version: 3},
+ {Key: []byte("foo"), Value: nil, CreateRevision: 7, ModRevision: 7, Version: 1},
+ {Key: []byte("foo/abc"), Value: nil, CreateRevision: 8, ModRevision: 8, Version: 1},
+ {Key: []byte("fop"), Value: nil, CreateRevision: 9, ModRevision: 9, Version: 1},
+ },
+ },
+ // range all with SortByModRevision, SortDescend
+ {
+ "a", "x",
+ 0,
+ []clientv3.OpOption{clientv3.WithSort(clientv3.SortByModRevision, clientv3.SortDescend)},
+
+ []*mvccpb.KeyValue{
+ {Key: []byte("fop"), Value: nil, CreateRevision: 9, ModRevision: 9, Version: 1},
+ {Key: []byte("foo/abc"), Value: nil, CreateRevision: 8, ModRevision: 8, Version: 1},
+ {Key: []byte("foo"), Value: nil, CreateRevision: 7, ModRevision: 7, Version: 1},
+ {Key: []byte("c"), Value: nil, CreateRevision: 4, ModRevision: 6, Version: 3},
+ {Key: []byte("b"), Value: nil, CreateRevision: 3, ModRevision: 3, Version: 1},
+ {Key: []byte("a"), Value: nil, CreateRevision: 2, ModRevision: 2, Version: 1},
+ },
+ },
+ // WithPrefix
+ {
+ "foo", "",
+ 0,
+ []clientv3.OpOption{clientv3.WithPrefix()},
+
+ []*mvccpb.KeyValue{
+ {Key: []byte("foo"), Value: nil, CreateRevision: 7, ModRevision: 7, Version: 1},
+ {Key: []byte("foo/abc"), Value: nil, CreateRevision: 8, ModRevision: 8, Version: 1},
+ },
+ },
+ // WithFromKey
+ {
+ "fo", "",
+ 0,
+ []clientv3.OpOption{clientv3.WithFromKey()},
+
+ []*mvccpb.KeyValue{
+ {Key: []byte("foo"), Value: nil, CreateRevision: 7, ModRevision: 7, Version: 1},
+ {Key: []byte("foo/abc"), Value: nil, CreateRevision: 8, ModRevision: 8, Version: 1},
+ {Key: []byte("fop"), Value: nil, CreateRevision: 9, ModRevision: 9, Version: 1},
+ },
+ },
+ // fetch entire keyspace using WithFromKey
+ {
+ "\x00", "",
+ 0,
+ []clientv3.OpOption{clientv3.WithFromKey(), clientv3.WithSort(clientv3.SortByKey, clientv3.SortAscend)},
+
+ []*mvccpb.KeyValue{
+ {Key: []byte("a"), Value: nil, CreateRevision: 2, ModRevision: 2, Version: 1},
+ {Key: []byte("b"), Value: nil, CreateRevision: 3, ModRevision: 3, Version: 1},
+ {Key: []byte("c"), Value: nil, CreateRevision: 4, ModRevision: 6, Version: 3},
+ {Key: []byte("foo"), Value: nil, CreateRevision: 7, ModRevision: 7, Version: 1},
+ {Key: []byte("foo/abc"), Value: nil, CreateRevision: 8, ModRevision: 8, Version: 1},
+ {Key: []byte("fop"), Value: nil, CreateRevision: 9, ModRevision: 9, Version: 1},
+ },
+ },
+ // fetch entire keyspace using WithPrefix
+ {
+ "", "",
+ 0,
+ []clientv3.OpOption{clientv3.WithPrefix(), clientv3.WithSort(clientv3.SortByKey, clientv3.SortAscend)},
+
+ []*mvccpb.KeyValue{
+ {Key: []byte("a"), Value: nil, CreateRevision: 2, ModRevision: 2, Version: 1},
+ {Key: []byte("b"), Value: nil, CreateRevision: 3, ModRevision: 3, Version: 1},
+ {Key: []byte("c"), Value: nil, CreateRevision: 4, ModRevision: 6, Version: 3},
+ {Key: []byte("foo"), Value: nil, CreateRevision: 7, ModRevision: 7, Version: 1},
+ {Key: []byte("foo/abc"), Value: nil, CreateRevision: 8, ModRevision: 8, Version: 1},
+ {Key: []byte("fop"), Value: nil, CreateRevision: 9, ModRevision: 9, Version: 1},
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ opts := []clientv3.OpOption{clientv3.WithRange(tt.end), clientv3.WithRev(tt.rev)}
+ opts = append(opts, tt.opts...)
+ resp, err := kv.Get(ctx, tt.begin, opts...)
+ if err != nil {
+ t.Fatalf("#%d: couldn't range (%v)", i, err)
+ }
+ if !reflect.DeepEqual(wheader, resp.Header) {
+ t.Fatalf("#%d: wheader expected %+v, got %+v", i, wheader, resp.Header)
+ }
+ if !reflect.DeepEqual(tt.wantSet, resp.Kvs) {
+ t.Fatalf("#%d: resp.Kvs expected %+v, got %+v", i, tt.wantSet, resp.Kvs)
+ }
+ }
+}
+
+func TestKVGetErrConnClosed(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ _, err := cli.Get(context.TODO(), "foo")
+ if err != nil && err != grpc.ErrClientConnClosing {
+ t.Fatalf("expected %v, got %v", grpc.ErrClientConnClosing, err)
+ }
+ }()
+
+ if err := cli.Close(); err != nil {
+ t.Fatal(err)
+ }
+ clus.TakeClient(0)
+
+ select {
+ case <-time.After(3 * time.Second):
+ t.Fatal("kv.Get took too long")
+ case <-donec:
+ }
+}
+
+func TestKVNewAfterClose(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+ clus.TakeClient(0)
+ if err := cli.Close(); err != nil {
+ t.Fatal(err)
+ }
+
+ donec := make(chan struct{})
+ go func() {
+ if _, err := cli.Get(context.TODO(), "foo"); err != grpc.ErrClientConnClosing {
+ t.Fatalf("expected %v, got %v", grpc.ErrClientConnClosing, err)
+ }
+ close(donec)
+ }()
+ select {
+ case <-time.After(3 * time.Second):
+ t.Fatal("kv.Get took too long")
+ case <-donec:
+ }
+}
+
+func TestKVDeleteRange(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kv := clus.RandClient()
+ ctx := context.TODO()
+
+ tests := []struct {
+ key string
+ opts []clientv3.OpOption
+
+ wkeys []string
+ }{
+ // [a, c)
+ {
+ key: "a",
+ opts: []clientv3.OpOption{clientv3.WithRange("c")},
+
+ wkeys: []string{"c", "c/abc", "d"},
+ },
+ // >= c
+ {
+ key: "c",
+ opts: []clientv3.OpOption{clientv3.WithFromKey()},
+
+ wkeys: []string{"a", "b"},
+ },
+ // c*
+ {
+ key: "c",
+ opts: []clientv3.OpOption{clientv3.WithPrefix()},
+
+ wkeys: []string{"a", "b", "d"},
+ },
+ // *
+ {
+ key: "\x00",
+ opts: []clientv3.OpOption{clientv3.WithFromKey()},
+
+ wkeys: []string{},
+ },
+ }
+
+ for i, tt := range tests {
+ keySet := []string{"a", "b", "c", "c/abc", "d"}
+ for j, key := range keySet {
+ if _, err := kv.Put(ctx, key, ""); err != nil {
+ t.Fatalf("#%d: couldn't put %q (%v)", j, key, err)
+ }
+ }
+
+ _, err := kv.Delete(ctx, tt.key, tt.opts...)
+ if err != nil {
+ t.Fatalf("#%d: couldn't delete range (%v)", i, err)
+ }
+
+ resp, err := kv.Get(ctx, "a", clientv3.WithFromKey())
+ if err != nil {
+ t.Fatalf("#%d: couldn't get keys (%v)", i, err)
+ }
+ keys := []string{}
+ for _, kv := range resp.Kvs {
+ keys = append(keys, string(kv.Key))
+ }
+ if !reflect.DeepEqual(tt.wkeys, keys) {
+ t.Errorf("#%d: resp.Kvs got %v, expected %v", i, keys, tt.wkeys)
+ }
+ }
+}
+
+func TestKVDelete(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kv := clus.RandClient()
+ ctx := context.TODO()
+
+ presp, err := kv.Put(ctx, "foo", "")
+ if err != nil {
+ t.Fatalf("couldn't put 'foo' (%v)", err)
+ }
+ if presp.Header.Revision != 2 {
+ t.Fatalf("presp.Header.Revision got %d, want %d", presp.Header.Revision, 2)
+ }
+ resp, err := kv.Delete(ctx, "foo")
+ if err != nil {
+ t.Fatalf("couldn't delete key (%v)", err)
+ }
+ if resp.Header.Revision != 3 {
+ t.Fatalf("resp.Header.Revision got %d, want %d", resp.Header.Revision, 3)
+ }
+ gresp, err := kv.Get(ctx, "foo")
+ if err != nil {
+ t.Fatalf("couldn't get key (%v)", err)
+ }
+ if len(gresp.Kvs) > 0 {
+ t.Fatalf("gresp.Kvs got %+v, want none", gresp.Kvs)
+ }
+}
+
+func TestKVCompactError(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kv := clus.RandClient()
+ ctx := context.TODO()
+
+ for i := 0; i < 5; i++ {
+ if _, err := kv.Put(ctx, "foo", "bar"); err != nil {
+ t.Fatalf("couldn't put 'foo' (%v)", err)
+ }
+ }
+ _, err := kv.Compact(ctx, 6)
+ if err != nil {
+ t.Fatalf("couldn't compact 6 (%v)", err)
+ }
+
+ _, err = kv.Compact(ctx, 6)
+ if err != rpctypes.ErrCompacted {
+ t.Fatalf("expected %v, got %v", rpctypes.ErrCompacted, err)
+ }
+
+ _, err = kv.Compact(ctx, 100)
+ if err != rpctypes.ErrFutureRev {
+ t.Fatalf("expected %v, got %v", rpctypes.ErrFutureRev, err)
+ }
+}
+
+func TestKVCompact(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kv := clus.RandClient()
+ ctx := context.TODO()
+
+ for i := 0; i < 10; i++ {
+ if _, err := kv.Put(ctx, "foo", "bar"); err != nil {
+ t.Fatalf("couldn't put 'foo' (%v)", err)
+ }
+ }
+
+ _, err := kv.Compact(ctx, 7)
+ if err != nil {
+ t.Fatalf("couldn't compact kv space (%v)", err)
+ }
+ _, err = kv.Compact(ctx, 7)
+ if err == nil || err != rpctypes.ErrCompacted {
+ t.Fatalf("error got %v, want %v", err, rpctypes.ErrCompacted)
+ }
+
+ wcli := clus.RandClient()
+ // new watcher could precede receiving the compaction without quorum first
+ wcli.Get(ctx, "quorum-get")
+
+ wchan := wcli.Watch(ctx, "foo", clientv3.WithRev(3))
+
+ if wr := <-wchan; wr.CompactRevision != 7 {
+ t.Fatalf("wchan CompactRevision got %v, want 7", wr.CompactRevision)
+ }
+ if wr, ok := <-wchan; ok {
+ t.Fatalf("wchan got %v, expected closed", wr)
+ }
+
+ _, err = kv.Compact(ctx, 1000)
+ if err == nil || err != rpctypes.ErrFutureRev {
+ t.Fatalf("error got %v, want %v", err, rpctypes.ErrFutureRev)
+ }
+}
+
+// TestKVGetRetry ensures get will retry on disconnect.
+func TestKVGetRetry(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clusterSize := 3
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: clusterSize})
+ defer clus.Terminate(t)
+
+ // because killing leader and following election
+ // could give no other endpoints for client reconnection
+ fIdx := (clus.WaitLeader(t) + 1) % clusterSize
+
+ kv := clus.Client(fIdx)
+ ctx := context.TODO()
+
+ if _, err := kv.Put(ctx, "foo", "bar"); err != nil {
+ t.Fatal(err)
+ }
+
+ clus.Members[fIdx].Stop(t)
+
+ donec := make(chan struct{})
+ go func() {
+ // Get will fail, but reconnect will trigger
+ gresp, gerr := kv.Get(ctx, "foo")
+ if gerr != nil {
+ t.Fatal(gerr)
+ }
+ wkvs := []*mvccpb.KeyValue{
+ {
+ Key: []byte("foo"),
+ Value: []byte("bar"),
+ CreateRevision: 2,
+ ModRevision: 2,
+ Version: 1,
+ },
+ }
+ if !reflect.DeepEqual(gresp.Kvs, wkvs) {
+ t.Fatalf("bad get: got %v, want %v", gresp.Kvs, wkvs)
+ }
+ donec <- struct{}{}
+ }()
+
+ time.Sleep(100 * time.Millisecond)
+ clus.Members[fIdx].Restart(t)
+
+ select {
+ case <-time.After(5 * time.Second):
+ t.Fatalf("timed out waiting for get")
+ case <-donec:
+ }
+}
+
+// TestKVPutFailGetRetry ensures a get will retry following a failed put.
+func TestKVPutFailGetRetry(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kv := clus.Client(0)
+ clus.Members[0].Stop(t)
+
+ ctx, cancel := context.WithTimeout(context.TODO(), time.Second)
+ defer cancel()
+ _, err := kv.Put(ctx, "foo", "bar")
+ if err == nil {
+ t.Fatalf("got success on disconnected put, wanted error")
+ }
+
+ donec := make(chan struct{})
+ go func() {
+ // Get will fail, but reconnect will trigger
+ gresp, gerr := kv.Get(context.TODO(), "foo")
+ if gerr != nil {
+ t.Fatal(gerr)
+ }
+ if len(gresp.Kvs) != 0 {
+ t.Fatalf("bad get kvs: got %+v, want empty", gresp.Kvs)
+ }
+ donec <- struct{}{}
+ }()
+
+ time.Sleep(100 * time.Millisecond)
+ clus.Members[0].Restart(t)
+
+ select {
+ case <-time.After(5 * time.Second):
+ t.Fatalf("timed out waiting for get")
+ case <-donec:
+ }
+}
+
+// TestKVGetCancel tests that a context cancel on a Get terminates as expected.
+func TestKVGetCancel(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ oldconn := clus.Client(0).ActiveConnection()
+ kv := clus.Client(0)
+
+ ctx, cancel := context.WithCancel(context.TODO())
+ cancel()
+
+ resp, err := kv.Get(ctx, "abc")
+ if err == nil {
+ t.Fatalf("cancel on get response %v, expected context error", resp)
+ }
+ newconn := clus.Client(0).ActiveConnection()
+ if oldconn != newconn {
+ t.Fatalf("cancel on get broke client connection")
+ }
+}
+
+// TestKVGetStoppedServerAndClose ensures closing after a failed Get works.
+func TestKVGetStoppedServerAndClose(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+ clus.Members[0].Stop(t)
+ ctx, cancel := context.WithTimeout(context.TODO(), time.Second)
+ // this Get fails and triggers an asynchronous connection retry
+ _, err := cli.Get(ctx, "abc")
+ cancel()
+ if !strings.Contains(err.Error(), "context deadline") {
+ t.Fatal(err)
+ }
+}
+
+// TestKVPutStoppedServerAndClose ensures closing after a failed Put works.
+func TestKVPutStoppedServerAndClose(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+ clus.Members[0].Stop(t)
+
+ ctx, cancel := context.WithTimeout(context.TODO(), time.Second)
+ // get retries on all errors.
+ // so here we use it to eat the potential broken pipe error for the next put.
+ // grpc client might see a broken pipe error when we issue the get request before
+ // grpc finds out the original connection is down due to the member shutdown.
+ _, err := cli.Get(ctx, "abc")
+ cancel()
+ if !strings.Contains(err.Error(), "context deadline") {
+ t.Fatal(err)
+ }
+
+ // this Put fails and triggers an asynchronous connection retry
+ _, err = cli.Put(ctx, "abc", "123")
+ cancel()
+ if !strings.Contains(err.Error(), "context deadline") {
+ t.Fatal(err)
+ }
+}
+
+// TestKVGetOneEndpointDown ensures a client can connect and get if one endpoint is down
+func TestKVPutOneEndpointDown(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ // get endpoint list
+ eps := make([]string, 3)
+ for i := range eps {
+ eps[i] = clus.Members[i].GRPCAddr()
+ }
+
+ // make a dead node
+ clus.Members[rand.Intn(len(eps))].Stop(t)
+
+ // try to connect with dead node in the endpoint list
+ cfg := clientv3.Config{Endpoints: eps, DialTimeout: 1 * time.Second}
+ cli, err := clientv3.New(cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer cli.Close()
+ ctx, cancel := context.WithTimeout(context.TODO(), 3*time.Second)
+ if _, err := cli.Get(ctx, "abc", clientv3.WithSerializable()); err != nil {
+ t.Fatal(err)
+ }
+ cancel()
+}
+
+// TestKVGetResetLoneEndpoint ensures that if an endpoint resets and all other
+// endpoints are down, then it will reconnect.
+func TestKVGetResetLoneEndpoint(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 2})
+ defer clus.Terminate(t)
+
+ // get endpoint list
+ eps := make([]string, 2)
+ for i := range eps {
+ eps[i] = clus.Members[i].GRPCAddr()
+ }
+
+ cfg := clientv3.Config{Endpoints: eps, DialTimeout: 500 * time.Millisecond}
+ cli, err := clientv3.New(cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer cli.Close()
+
+ // disconnect everything
+ clus.Members[0].Stop(t)
+ clus.Members[1].Stop(t)
+
+ // have Get try to reconnect
+ donec := make(chan struct{})
+ go func() {
+ ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
+ if _, err := cli.Get(ctx, "abc", clientv3.WithSerializable()); err != nil {
+ t.Fatal(err)
+ }
+ cancel()
+ close(donec)
+ }()
+ time.Sleep(500 * time.Millisecond)
+ clus.Members[0].Restart(t)
+ select {
+ case <-time.After(10 * time.Second):
+ t.Fatalf("timed out waiting for Get")
+ case <-donec:
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/integration/lease_test.go b/vendor/github.com/coreos/etcd/clientv3/integration/lease_test.go
new file mode 100644
index 00000000..ef176fdd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/integration/lease_test.go
@@ -0,0 +1,755 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "reflect"
+ "sort"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/concurrency"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/pkg/testutil"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+func TestLeaseNotFoundError(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kv := clus.RandClient()
+
+ _, err := kv.Put(context.TODO(), "foo", "bar", clientv3.WithLease(clientv3.LeaseID(500)))
+ if err != rpctypes.ErrLeaseNotFound {
+ t.Fatalf("expected %v, got %v", rpctypes.ErrLeaseNotFound, err)
+ }
+}
+
+func TestLeaseGrant(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ lapi := clus.RandClient()
+
+ kv := clus.RandClient()
+
+ resp, err := lapi.Grant(context.Background(), 10)
+ if err != nil {
+ t.Errorf("failed to create lease %v", err)
+ }
+
+ _, err = kv.Put(context.TODO(), "foo", "bar", clientv3.WithLease(resp.ID))
+ if err != nil {
+ t.Fatalf("failed to create key with lease %v", err)
+ }
+}
+
+func TestLeaseRevoke(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ lapi := clus.RandClient()
+
+ kv := clus.RandClient()
+
+ resp, err := lapi.Grant(context.Background(), 10)
+ if err != nil {
+ t.Errorf("failed to create lease %v", err)
+ }
+
+ _, err = lapi.Revoke(context.Background(), clientv3.LeaseID(resp.ID))
+ if err != nil {
+ t.Errorf("failed to revoke lease %v", err)
+ }
+
+ _, err = kv.Put(context.TODO(), "foo", "bar", clientv3.WithLease(resp.ID))
+ if err != rpctypes.ErrLeaseNotFound {
+ t.Fatalf("err = %v, want %v", err, rpctypes.ErrLeaseNotFound)
+ }
+}
+
+func TestLeaseKeepAliveOnce(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ lapi := clus.RandClient()
+
+ resp, err := lapi.Grant(context.Background(), 10)
+ if err != nil {
+ t.Errorf("failed to create lease %v", err)
+ }
+
+ _, err = lapi.KeepAliveOnce(context.Background(), resp.ID)
+ if err != nil {
+ t.Errorf("failed to keepalive lease %v", err)
+ }
+
+ _, err = lapi.KeepAliveOnce(context.Background(), clientv3.LeaseID(0))
+ if err != rpctypes.ErrLeaseNotFound {
+ t.Errorf("expected %v, got %v", rpctypes.ErrLeaseNotFound, err)
+ }
+}
+
+func TestLeaseKeepAlive(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ lapi := clus.Client(0)
+ clus.TakeClient(0)
+
+ resp, err := lapi.Grant(context.Background(), 10)
+ if err != nil {
+ t.Errorf("failed to create lease %v", err)
+ }
+
+ rc, kerr := lapi.KeepAlive(context.Background(), resp.ID)
+ if kerr != nil {
+ t.Errorf("failed to keepalive lease %v", kerr)
+ }
+
+ kresp, ok := <-rc
+ if !ok {
+ t.Errorf("chan is closed, want not closed")
+ }
+
+ if kresp.ID != resp.ID {
+ t.Errorf("ID = %x, want %x", kresp.ID, resp.ID)
+ }
+
+ lapi.Close()
+
+ _, ok = <-rc
+ if ok {
+ t.Errorf("chan is not closed, want lease Close() closes chan")
+ }
+}
+
+func TestLeaseKeepAliveOneSecond(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+
+ resp, err := cli.Grant(context.Background(), 1)
+ if err != nil {
+ t.Errorf("failed to create lease %v", err)
+ }
+ rc, kerr := cli.KeepAlive(context.Background(), resp.ID)
+ if kerr != nil {
+ t.Errorf("failed to keepalive lease %v", kerr)
+ }
+
+ for i := 0; i < 3; i++ {
+ if _, ok := <-rc; !ok {
+ t.Errorf("chan is closed, want not closed")
+ }
+ }
+}
+
+// TODO: add a client that can connect to all the members of cluster via unix sock.
+// TODO: test handle more complicated failures.
+func TestLeaseKeepAliveHandleFailure(t *testing.T) {
+ t.Skip("test it when we have a cluster client")
+
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ // TODO: change this line to get a cluster client
+ lapi := clus.RandClient()
+
+ resp, err := lapi.Grant(context.Background(), 10)
+ if err != nil {
+ t.Errorf("failed to create lease %v", err)
+ }
+
+ rc, kerr := lapi.KeepAlive(context.Background(), resp.ID)
+ if kerr != nil {
+ t.Errorf("failed to keepalive lease %v", kerr)
+ }
+
+ kresp := <-rc
+ if kresp.ID != resp.ID {
+ t.Errorf("ID = %x, want %x", kresp.ID, resp.ID)
+ }
+
+ // restart the connected member.
+ clus.Members[0].Stop(t)
+
+ select {
+ case <-rc:
+ t.Fatalf("unexpected keepalive")
+ case <-time.After(10*time.Second/3 + 1):
+ }
+
+ // recover the member.
+ clus.Members[0].Restart(t)
+
+ kresp = <-rc
+ if kresp.ID != resp.ID {
+ t.Errorf("ID = %x, want %x", kresp.ID, resp.ID)
+ }
+
+ lapi.Close()
+
+ _, ok := <-rc
+ if ok {
+ t.Errorf("chan is not closed, want lease Close() closes chan")
+ }
+}
+
+type leaseCh struct {
+ lid clientv3.LeaseID
+ ch <-chan *clientv3.LeaseKeepAliveResponse
+}
+
+// TestLeaseKeepAliveNotFound ensures a revoked lease won't stop other keep alives
+func TestLeaseKeepAliveNotFound(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.RandClient()
+ lchs := []leaseCh{}
+ for i := 0; i < 3; i++ {
+ resp, rerr := cli.Grant(context.TODO(), 5)
+ if rerr != nil {
+ t.Fatal(rerr)
+ }
+ kach, kaerr := cli.KeepAlive(context.Background(), resp.ID)
+ if kaerr != nil {
+ t.Fatal(kaerr)
+ }
+ lchs = append(lchs, leaseCh{resp.ID, kach})
+ }
+
+ if _, err := cli.Revoke(context.TODO(), lchs[1].lid); err != nil {
+ t.Fatal(err)
+ }
+
+ <-lchs[0].ch
+ if _, ok := <-lchs[0].ch; !ok {
+ t.Fatalf("closed keepalive on wrong lease")
+ }
+
+ timec := time.After(5 * time.Second)
+ for range lchs[1].ch {
+ select {
+ case <-timec:
+ t.Fatalf("revoke did not close keep alive")
+ default:
+ }
+ }
+}
+
+func TestLeaseGrantErrConnClosed(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+ clus.TakeClient(0)
+
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ _, err := cli.Grant(context.TODO(), 5)
+ if err != nil && err != grpc.ErrClientConnClosing {
+ t.Fatalf("expected %v, got %v", grpc.ErrClientConnClosing, err)
+ }
+ }()
+
+ if err := cli.Close(); err != nil {
+ t.Fatal(err)
+ }
+
+ select {
+ case <-time.After(3 * time.Second):
+ t.Fatal("le.Grant took too long")
+ case <-donec:
+ }
+}
+
+func TestLeaseGrantNewAfterClose(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+ clus.TakeClient(0)
+ if err := cli.Close(); err != nil {
+ t.Fatal(err)
+ }
+
+ donec := make(chan struct{})
+ go func() {
+ if _, err := cli.Grant(context.TODO(), 5); err != grpc.ErrClientConnClosing {
+ t.Fatalf("expected %v, got %v", grpc.ErrClientConnClosing, err)
+ }
+ close(donec)
+ }()
+ select {
+ case <-time.After(3 * time.Second):
+ t.Fatal("le.Grant took too long")
+ case <-donec:
+ }
+}
+
+func TestLeaseRevokeNewAfterClose(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+ resp, err := cli.Grant(context.TODO(), 5)
+ if err != nil {
+ t.Fatal(err)
+ }
+ leaseID := resp.ID
+
+ clus.TakeClient(0)
+ if err := cli.Close(); err != nil {
+ t.Fatal(err)
+ }
+
+ donec := make(chan struct{})
+ go func() {
+ if _, err := cli.Revoke(context.TODO(), leaseID); err != grpc.ErrClientConnClosing {
+ t.Fatalf("expected %v, got %v", grpc.ErrClientConnClosing, err)
+ }
+ close(donec)
+ }()
+ select {
+ case <-time.After(3 * time.Second):
+ t.Fatal("le.Revoke took too long")
+ case <-donec:
+ }
+}
+
+// TestLeaseKeepAliveCloseAfterDisconnectExpire ensures the keep alive channel is closed
+// following a disconnection, lease revoke, then reconnect.
+func TestLeaseKeepAliveCloseAfterDisconnectRevoke(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+
+ // setup lease and do a keepalive
+ resp, err := cli.Grant(context.Background(), 10)
+ if err != nil {
+ t.Fatal(err)
+ }
+ rc, kerr := cli.KeepAlive(context.Background(), resp.ID)
+ if kerr != nil {
+ t.Fatal(kerr)
+ }
+ kresp := <-rc
+ if kresp.ID != resp.ID {
+ t.Fatalf("ID = %x, want %x", kresp.ID, resp.ID)
+ }
+
+ // keep client disconnected
+ clus.Members[0].Stop(t)
+ time.Sleep(time.Second)
+ clus.WaitLeader(t)
+
+ if _, err := clus.Client(1).Revoke(context.TODO(), resp.ID); err != nil {
+ t.Fatal(err)
+ }
+
+ clus.Members[0].Restart(t)
+
+ // some keep-alives may still be buffered; drain until close
+ timer := time.After(time.Duration(kresp.TTL) * time.Second)
+ for kresp != nil {
+ select {
+ case kresp = <-rc:
+ case <-timer:
+ t.Fatalf("keepalive channel did not close")
+ }
+ }
+}
+
+// TestLeaseKeepAliveInitTimeout ensures the keep alive channel closes if
+// the initial keep alive request never gets a response.
+func TestLeaseKeepAliveInitTimeout(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+
+ // setup lease and do a keepalive
+ resp, err := cli.Grant(context.Background(), 5)
+ if err != nil {
+ t.Fatal(err)
+ }
+ // keep client disconnected
+ clus.Members[0].Stop(t)
+ rc, kerr := cli.KeepAlive(context.Background(), resp.ID)
+ if kerr != nil {
+ t.Fatal(kerr)
+ }
+ select {
+ case ka, ok := <-rc:
+ if ok {
+ t.Fatalf("unexpected keepalive %v, expected closed channel", ka)
+ }
+ case <-time.After(10 * time.Second):
+ t.Fatalf("keepalive channel did not close")
+ }
+
+ clus.Members[0].Restart(t)
+}
+
+// TestLeaseKeepAliveInitTimeout ensures the keep alive channel closes if
+// a keep alive request after the first never gets a response.
+func TestLeaseKeepAliveTTLTimeout(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+
+ // setup lease and do a keepalive
+ resp, err := cli.Grant(context.Background(), 5)
+ if err != nil {
+ t.Fatal(err)
+ }
+ rc, kerr := cli.KeepAlive(context.Background(), resp.ID)
+ if kerr != nil {
+ t.Fatal(kerr)
+ }
+ if kresp := <-rc; kresp.ID != resp.ID {
+ t.Fatalf("ID = %x, want %x", kresp.ID, resp.ID)
+ }
+
+ // keep client disconnected
+ clus.Members[0].Stop(t)
+ select {
+ case ka, ok := <-rc:
+ if ok {
+ t.Fatalf("unexpected keepalive %v, expected closed channel", ka)
+ }
+ case <-time.After(10 * time.Second):
+ t.Fatalf("keepalive channel did not close")
+ }
+
+ clus.Members[0].Restart(t)
+}
+
+func TestLeaseTimeToLive(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ lapi := clus.RandClient()
+
+ resp, err := lapi.Grant(context.Background(), 10)
+ if err != nil {
+ t.Errorf("failed to create lease %v", err)
+ }
+
+ kv := clus.RandClient()
+ keys := []string{"foo1", "foo2"}
+ for i := range keys {
+ if _, err = kv.Put(context.TODO(), keys[i], "bar", clientv3.WithLease(resp.ID)); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ lresp, lerr := lapi.TimeToLive(context.Background(), resp.ID, clientv3.WithAttachedKeys())
+ if lerr != nil {
+ t.Fatal(lerr)
+ }
+ if lresp.ID != resp.ID {
+ t.Fatalf("leaseID expected %d, got %d", resp.ID, lresp.ID)
+ }
+ if lresp.GrantedTTL != int64(10) {
+ t.Fatalf("GrantedTTL expected %d, got %d", 10, lresp.GrantedTTL)
+ }
+ if lresp.TTL == 0 || lresp.TTL > lresp.GrantedTTL {
+ t.Fatalf("unexpected TTL %d (granted %d)", lresp.TTL, lresp.GrantedTTL)
+ }
+ ks := make([]string, len(lresp.Keys))
+ for i := range lresp.Keys {
+ ks[i] = string(lresp.Keys[i])
+ }
+ sort.Strings(ks)
+ if !reflect.DeepEqual(ks, keys) {
+ t.Fatalf("keys expected %v, got %v", keys, ks)
+ }
+
+ lresp, lerr = lapi.TimeToLive(context.Background(), resp.ID)
+ if lerr != nil {
+ t.Fatal(lerr)
+ }
+ if len(lresp.Keys) != 0 {
+ t.Fatalf("unexpected keys %+v", lresp.Keys)
+ }
+}
+
+func TestLeaseTimeToLiveLeaseNotFound(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.RandClient()
+ resp, err := cli.Grant(context.Background(), 10)
+ if err != nil {
+ t.Errorf("failed to create lease %v", err)
+ }
+ _, err = cli.Revoke(context.Background(), resp.ID)
+ if err != nil {
+ t.Errorf("failed to Revoke lease %v", err)
+ }
+
+ lresp, err := cli.TimeToLive(context.Background(), resp.ID)
+ // TimeToLive() doesn't return LeaseNotFound error
+ // but return a response with TTL to be -1
+ if err != nil {
+ t.Fatalf("expected err to be nil")
+ }
+ if lresp == nil {
+ t.Fatalf("expected lresp not to be nil")
+ }
+ if lresp.ResponseHeader == nil {
+ t.Fatalf("expected ResponseHeader not to be nil")
+ }
+ if lresp.ID != resp.ID {
+ t.Fatalf("expected Lease ID %v, but got %v", resp.ID, lresp.ID)
+ }
+ if lresp.TTL != -1 {
+ t.Fatalf("expected TTL %v, but got %v", lresp.TTL, lresp.TTL)
+ }
+}
+
+// TestLeaseRenewLostQuorum ensures keepalives work after losing quorum
+// for a while.
+func TestLeaseRenewLostQuorum(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+ r, err := cli.Grant(context.TODO(), 4)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ kctx, kcancel := context.WithCancel(context.Background())
+ defer kcancel()
+ ka, err := cli.KeepAlive(kctx, r.ID)
+ if err != nil {
+ t.Fatal(err)
+ }
+ // consume first keepalive so next message sends when cluster is down
+ <-ka
+ lastKa := time.Now()
+
+ // force keepalive stream message to timeout
+ clus.Members[1].Stop(t)
+ clus.Members[2].Stop(t)
+ // Use TTL-2 since the client closes the keepalive channel if no
+ // keepalive arrives before the lease deadline; the client will
+ // try to resend a keepalive after TTL/3 seconds, so for a TTL of 4,
+ // sleeping for 2s should be sufficient time for issuing a retry.
+ // The cluster has two seconds to recover and reply to the keepalive.
+ time.Sleep(time.Duration(r.TTL-2) * time.Second)
+ clus.Members[1].Restart(t)
+ clus.Members[2].Restart(t)
+
+ if time.Since(lastKa) > time.Duration(r.TTL)*time.Second {
+ t.Skip("waited too long for server stop and restart")
+ }
+
+ select {
+ case _, ok := <-ka:
+ if !ok {
+ t.Fatalf("keepalive closed")
+ }
+ case <-time.After(time.Duration(r.TTL) * time.Second):
+ t.Fatalf("timed out waiting for keepalive")
+ }
+}
+
+func TestLeaseKeepAliveLoopExit(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ ctx := context.Background()
+ cli := clus.Client(0)
+ clus.TakeClient(0)
+
+ resp, err := cli.Grant(ctx, 5)
+ if err != nil {
+ t.Fatal(err)
+ }
+ cli.Close()
+
+ _, err = cli.KeepAlive(ctx, resp.ID)
+ if _, ok := err.(clientv3.ErrKeepAliveHalted); !ok {
+ t.Fatalf("expected %T, got %v(%T)", clientv3.ErrKeepAliveHalted{}, err, err)
+ }
+}
+
+// TestV3LeaseFailureOverlap issues Grant and Keepalive requests to a cluster
+// before, during, and after quorum loss to confirm Grant/Keepalive tolerates
+// transient cluster failure.
+func TestV3LeaseFailureOverlap(t *testing.T) {
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 2})
+ defer clus.Terminate(t)
+
+ numReqs := 5
+ cli := clus.Client(0)
+
+ // bring up a session, tear it down
+ updown := func(i int) error {
+ sess, err := concurrency.NewSession(cli)
+ if err != nil {
+ return err
+ }
+ ch := make(chan struct{})
+ go func() {
+ defer close(ch)
+ sess.Close()
+ }()
+ select {
+ case <-ch:
+ case <-time.After(time.Minute / 4):
+ t.Fatalf("timeout %d", i)
+ }
+ return nil
+ }
+
+ var wg sync.WaitGroup
+ mkReqs := func(n int) {
+ wg.Add(numReqs)
+ for i := 0; i < numReqs; i++ {
+ go func() {
+ defer wg.Done()
+ err := updown(n)
+ if err == nil || err == rpctypes.ErrTimeoutDueToConnectionLost {
+ return
+ }
+ t.Fatal(err)
+ }()
+ }
+ }
+
+ mkReqs(1)
+ clus.Members[1].Stop(t)
+ mkReqs(2)
+ time.Sleep(time.Second)
+ mkReqs(3)
+ clus.Members[1].Restart(t)
+ mkReqs(4)
+ wg.Wait()
+}
+
+// TestLeaseWithRequireLeader checks keep-alive channel close when no leader.
+func TestLeaseWithRequireLeader(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 2})
+ defer clus.Terminate(t)
+
+ c := clus.Client(0)
+ lid1, err1 := c.Grant(context.TODO(), 60)
+ if err1 != nil {
+ t.Fatal(err1)
+ }
+ lid2, err2 := c.Grant(context.TODO(), 60)
+ if err2 != nil {
+ t.Fatal(err2)
+ }
+ // kaReqLeader close if the leader is lost
+ kaReqLeader, kerr1 := c.KeepAlive(clientv3.WithRequireLeader(context.TODO()), lid1.ID)
+ if kerr1 != nil {
+ t.Fatal(kerr1)
+ }
+ // kaWait will wait even if the leader is lost
+ kaWait, kerr2 := c.KeepAlive(context.TODO(), lid2.ID)
+ if kerr2 != nil {
+ t.Fatal(kerr2)
+ }
+
+ select {
+ case <-kaReqLeader:
+ case <-time.After(5 * time.Second):
+ t.Fatalf("require leader first keep-alive timed out")
+ }
+ select {
+ case <-kaWait:
+ case <-time.After(5 * time.Second):
+ t.Fatalf("leader not required first keep-alive timed out")
+ }
+
+ clus.Members[1].Stop(t)
+ // kaReqLeader may issue multiple requests while waiting for the first
+ // response from proxy server; drain any stray keepalive responses
+ time.Sleep(100 * time.Millisecond)
+ for len(kaReqLeader) > 0 {
+ <-kaReqLeader
+ }
+
+ select {
+ case resp, ok := <-kaReqLeader:
+ if ok {
+ t.Fatalf("expected closed require leader, got response %+v", resp)
+ }
+ case <-time.After(5 * time.Second):
+ t.Fatal("keepalive with require leader took too long to close")
+ }
+ select {
+ case _, ok := <-kaWait:
+ if !ok {
+ t.Fatalf("got closed channel with no require leader, expected non-closed")
+ }
+ case <-time.After(10 * time.Millisecond):
+ // wait some to detect any closes happening soon after kaReqLeader closing
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/integration/logger_test.go b/vendor/github.com/coreos/etcd/clientv3/integration/logger_test.go
new file mode 100644
index 00000000..71922da3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/integration/logger_test.go
@@ -0,0 +1,21 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import "github.com/coreos/pkg/capnslog"
+
+func init() {
+ capnslog.SetGlobalLogLevel(capnslog.INFO)
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/integration/main_test.go b/vendor/github.com/coreos/etcd/clientv3/integration/main_test.go
new file mode 100644
index 00000000..2913ce51
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/integration/main_test.go
@@ -0,0 +1,20 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package integration
+
+import (
+ "os"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestMain(m *testing.M) {
+ v := m.Run()
+ if v == 0 && testutil.CheckLeakedGoroutine() {
+ os.Exit(1)
+ }
+ os.Exit(v)
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/integration/metrics_test.go b/vendor/github.com/coreos/etcd/clientv3/integration/metrics_test.go
new file mode 100644
index 00000000..6311fe0d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/integration/metrics_test.go
@@ -0,0 +1,177 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "bufio"
+ "io"
+ "net"
+ "net/http"
+ "strconv"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/pkg/transport"
+
+ grpcprom "github.com/grpc-ecosystem/go-grpc-prometheus"
+ "github.com/prometheus/client_golang/prometheus"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+func TestV3ClientMetrics(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ var (
+ addr string = "localhost:27989"
+ ln net.Listener
+ err error
+ )
+
+ // listen for all prometheus metrics
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+
+ srv := &http.Server{Handler: prometheus.Handler()}
+ srv.SetKeepAlivesEnabled(false)
+
+ ln, err = transport.NewUnixListener(addr)
+ if err != nil {
+ t.Fatalf("Error: %v occurred while listening on addr: %v", err, addr)
+ }
+
+ err = srv.Serve(ln)
+ if err != nil && !transport.IsClosedConnError(err) {
+ t.Fatalf("Err serving http requests: %v", err)
+ }
+ }()
+
+ url := "unix://" + addr + "/metrics"
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cfg := clientv3.Config{
+ Endpoints: []string{clus.Members[0].GRPCAddr()},
+ DialOptions: []grpc.DialOption{
+ grpc.WithUnaryInterceptor(grpcprom.UnaryClientInterceptor),
+ grpc.WithStreamInterceptor(grpcprom.StreamClientInterceptor),
+ },
+ }
+ cli, cerr := clientv3.New(cfg)
+ if cerr != nil {
+ t.Fatal(cerr)
+ }
+ defer cli.Close()
+
+ wc := cli.Watch(context.Background(), "foo")
+
+ wBefore := sumCountersForMetricAndLabels(t, url, "grpc_client_msg_received_total", "Watch", "bidi_stream")
+
+ pBefore := sumCountersForMetricAndLabels(t, url, "grpc_client_started_total", "Put", "unary")
+
+ _, err = cli.Put(context.Background(), "foo", "bar")
+ if err != nil {
+ t.Errorf("Error putting value in key store")
+ }
+
+ pAfter := sumCountersForMetricAndLabels(t, url, "grpc_client_started_total", "Put", "unary")
+ if pBefore+1 != pAfter {
+ t.Errorf("grpc_client_started_total expected %d, got %d", 1, pAfter-pBefore)
+ }
+
+ // consume watch response
+ select {
+ case <-wc:
+ case <-time.After(10 * time.Second):
+ t.Error("Timeout occurred for getting watch response")
+ }
+
+ wAfter := sumCountersForMetricAndLabels(t, url, "grpc_client_msg_received_total", "Watch", "bidi_stream")
+ if wBefore+1 != wAfter {
+ t.Errorf("grpc_client_msg_received_total expected %d, got %d", 1, wAfter-wBefore)
+ }
+
+ ln.Close()
+ <-donec
+}
+
+func sumCountersForMetricAndLabels(t *testing.T, url string, metricName string, matchingLabelValues ...string) int {
+ count := 0
+ for _, line := range getHTTPBodyAsLines(t, url) {
+ ok := true
+ if !strings.HasPrefix(line, metricName) {
+ continue
+ }
+
+ for _, labelValue := range matchingLabelValues {
+ if !strings.Contains(line, `"`+labelValue+`"`) {
+ ok = false
+ break
+ }
+ }
+
+ if !ok {
+ continue
+ }
+
+ valueString := line[strings.LastIndex(line, " ")+1 : len(line)-1]
+ valueFloat, err := strconv.ParseFloat(valueString, 32)
+ if err != nil {
+ t.Fatalf("failed parsing value for line: %v and matchingLabelValues: %v", line, matchingLabelValues)
+ }
+ count += int(valueFloat)
+ }
+ return count
+}
+
+func getHTTPBodyAsLines(t *testing.T, url string) []string {
+ cfgtls := transport.TLSInfo{}
+ tr, err := transport.NewTransport(cfgtls, time.Second)
+ if err != nil {
+ t.Fatalf("Error getting transport: %v", err)
+ }
+
+ tr.MaxIdleConns = -1
+ tr.DisableKeepAlives = true
+
+ cli := &http.Client{Transport: tr}
+
+ resp, err := cli.Get(url)
+ if err != nil {
+ t.Fatalf("Error fetching: %v", err)
+ }
+
+ reader := bufio.NewReader(resp.Body)
+ lines := []string{}
+ for {
+ line, err := reader.ReadString('\n')
+ if err != nil {
+ if err == io.EOF {
+ break
+ } else {
+ t.Fatalf("error reading: %v", err)
+ }
+ }
+ lines = append(lines, line)
+ }
+ resp.Body.Close()
+ return lines
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/integration/mirror_test.go b/vendor/github.com/coreos/etcd/clientv3/integration/mirror_test.go
new file mode 100644
index 00000000..df9911ef
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/integration/mirror_test.go
@@ -0,0 +1,125 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "fmt"
+ "reflect"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3/mirror"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/coreos/etcd/pkg/testutil"
+ "golang.org/x/net/context"
+)
+
+func TestMirrorSync(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ c := clus.Client(0)
+ _, err := c.KV.Put(context.TODO(), "foo", "bar")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ syncer := mirror.NewSyncer(c, "", 0)
+ gch, ech := syncer.SyncBase(context.TODO())
+ wkvs := []*mvccpb.KeyValue{{Key: []byte("foo"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1}}
+
+ for g := range gch {
+ if !reflect.DeepEqual(g.Kvs, wkvs) {
+ t.Fatalf("kv = %v, want %v", g.Kvs, wkvs)
+ }
+ }
+
+ for e := range ech {
+ t.Fatalf("unexpected error %v", e)
+ }
+
+ wch := syncer.SyncUpdates(context.TODO())
+
+ _, err = c.KV.Put(context.TODO(), "foo", "bar")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ select {
+ case r := <-wch:
+ wkv := &mvccpb.KeyValue{Key: []byte("foo"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 3, Version: 2}
+ if !reflect.DeepEqual(r.Events[0].Kv, wkv) {
+ t.Fatalf("kv = %v, want %v", r.Events[0].Kv, wkv)
+ }
+ case <-time.After(time.Second):
+ t.Fatal("failed to receive update in one second")
+ }
+}
+
+func TestMirrorSyncBase(t *testing.T) {
+ cluster := integration.NewClusterV3(nil, &integration.ClusterConfig{Size: 1})
+ defer cluster.Terminate(nil)
+
+ cli := cluster.Client(0)
+ ctx := context.TODO()
+
+ keyCh := make(chan string)
+ var wg sync.WaitGroup
+
+ for i := 0; i < 50; i++ {
+ wg.Add(1)
+
+ go func() {
+ defer wg.Done()
+
+ for key := range keyCh {
+ if _, err := cli.Put(ctx, key, "test"); err != nil {
+ t.Fatal(err)
+ }
+ }
+ }()
+ }
+
+ for i := 0; i < 2000; i++ {
+ keyCh <- fmt.Sprintf("test%d", i)
+ }
+
+ close(keyCh)
+ wg.Wait()
+
+ syncer := mirror.NewSyncer(cli, "test", 0)
+ respCh, errCh := syncer.SyncBase(ctx)
+
+ count := 0
+
+ for resp := range respCh {
+ count = count + len(resp.Kvs)
+ if !resp.More {
+ break
+ }
+ }
+
+ for err := range errCh {
+ t.Fatalf("unexpected error %v", err)
+ }
+
+ if count != 2000 {
+ t.Errorf("unexpected kv count: %d", count)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/integration/namespace_test.go b/vendor/github.com/coreos/etcd/clientv3/integration/namespace_test.go
new file mode 100644
index 00000000..b952d333
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/integration/namespace_test.go
@@ -0,0 +1,86 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "context"
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/namespace"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestNamespacePutGet(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ c := clus.Client(0)
+ nsKV := namespace.NewKV(c.KV, "foo/")
+
+ if _, err := nsKV.Put(context.TODO(), "abc", "bar"); err != nil {
+ t.Fatal(err)
+ }
+ resp, err := nsKV.Get(context.TODO(), "abc")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if string(resp.Kvs[0].Key) != "abc" {
+ t.Errorf("expected key=%q, got key=%q", "abc", resp.Kvs[0].Key)
+ }
+
+ resp, err = c.Get(context.TODO(), "foo/abc")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if string(resp.Kvs[0].Value) != "bar" {
+ t.Errorf("expected value=%q, got value=%q", "bar", resp.Kvs[0].Value)
+ }
+}
+
+func TestNamespaceWatch(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ c := clus.Client(0)
+ nsKV := namespace.NewKV(c.KV, "foo/")
+ nsWatcher := namespace.NewWatcher(c.Watcher, "foo/")
+
+ if _, err := nsKV.Put(context.TODO(), "abc", "bar"); err != nil {
+ t.Fatal(err)
+ }
+
+ nsWch := nsWatcher.Watch(context.TODO(), "abc", clientv3.WithRev(1))
+ wkv := &mvccpb.KeyValue{Key: []byte("abc"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1}
+ if wr := <-nsWch; len(wr.Events) != 1 || !reflect.DeepEqual(wr.Events[0].Kv, wkv) {
+ t.Errorf("expected namespaced event %+v, got %+v", wkv, wr.Events[0].Kv)
+ }
+
+ wch := c.Watch(context.TODO(), "foo/abc", clientv3.WithRev(1))
+ wkv = &mvccpb.KeyValue{Key: []byte("foo/abc"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1}
+ if wr := <-wch; len(wr.Events) != 1 || !reflect.DeepEqual(wr.Events[0].Kv, wkv) {
+ t.Errorf("expected unnamespaced event %+v, got %+v", wkv, wr)
+ }
+
+ // let client close teardown namespace watch
+ c.Watcher = nsWatcher
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/integration/role_test.go b/vendor/github.com/coreos/etcd/clientv3/integration/role_test.go
new file mode 100644
index 00000000..7814db5e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/integration/role_test.go
@@ -0,0 +1,43 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "testing"
+
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/pkg/testutil"
+ "golang.org/x/net/context"
+)
+
+func TestRoleError(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ authapi := clus.RandClient()
+
+ _, err := authapi.RoleAdd(context.TODO(), "test-role")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ _, err = authapi.RoleAdd(context.TODO(), "test-role")
+ if err != rpctypes.ErrRoleAlreadyExist {
+ t.Fatalf("expected %v, got %v", rpctypes.ErrRoleAlreadyExist, err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/integration/txn_test.go b/vendor/github.com/coreos/etcd/clientv3/integration/txn_test.go
new file mode 100644
index 00000000..b5cdea7e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/integration/txn_test.go
@@ -0,0 +1,154 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "fmt"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/pkg/testutil"
+ "golang.org/x/net/context"
+)
+
+func TestTxnError(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kv := clus.RandClient()
+ ctx := context.TODO()
+
+ _, err := kv.Txn(ctx).Then(clientv3.OpPut("foo", "bar1"), clientv3.OpPut("foo", "bar2")).Commit()
+ if err != rpctypes.ErrDuplicateKey {
+ t.Fatalf("expected %v, got %v", rpctypes.ErrDuplicateKey, err)
+ }
+
+ ops := make([]clientv3.Op, v3rpc.MaxOpsPerTxn+10)
+ for i := range ops {
+ ops[i] = clientv3.OpPut(fmt.Sprintf("foo%d", i), "")
+ }
+ _, err = kv.Txn(ctx).Then(ops...).Commit()
+ if err != rpctypes.ErrTooManyOps {
+ t.Fatalf("expected %v, got %v", rpctypes.ErrTooManyOps, err)
+ }
+}
+
+func TestTxnWriteFail(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kv := clus.Client(0)
+
+ clus.Members[0].Stop(t)
+
+ txnc, getc := make(chan struct{}), make(chan struct{})
+ go func() {
+ ctx, cancel := context.WithTimeout(context.TODO(), time.Second)
+ defer cancel()
+ resp, err := kv.Txn(ctx).Then(clientv3.OpPut("foo", "bar")).Commit()
+ if err == nil {
+ t.Fatalf("expected error, got response %v", resp)
+ }
+ close(txnc)
+ }()
+
+ go func() {
+ defer close(getc)
+ select {
+ case <-time.After(5 * time.Second):
+ t.Fatalf("timed out waiting for txn fail")
+ case <-txnc:
+ }
+ // and ensure the put didn't take
+ gresp, gerr := clus.Client(1).Get(context.TODO(), "foo")
+ if gerr != nil {
+ t.Fatal(gerr)
+ }
+ if len(gresp.Kvs) != 0 {
+ t.Fatalf("expected no keys, got %v", gresp.Kvs)
+ }
+ }()
+
+ select {
+ case <-time.After(2 * clus.Members[1].ServerConfig.ReqTimeout()):
+ t.Fatalf("timed out waiting for get")
+ case <-getc:
+ }
+
+ // reconnect so terminate doesn't complain about double-close
+ clus.Members[0].Restart(t)
+}
+
+func TestTxnReadRetry(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kv := clus.Client(0)
+ clus.Members[0].Stop(t)
+ <-clus.Members[0].StopNotify()
+
+ donec := make(chan struct{})
+ go func() {
+ ctx := context.TODO()
+ _, err := kv.Txn(ctx).Then(clientv3.OpGet("foo")).Commit()
+ if err != nil {
+ t.Fatalf("expected response, got error %v", err)
+ }
+ donec <- struct{}{}
+ }()
+ // wait for txn to fail on disconnect
+ time.Sleep(100 * time.Millisecond)
+
+ // restart node; client should resume
+ clus.Members[0].Restart(t)
+ select {
+ case <-donec:
+ case <-time.After(2 * clus.Members[1].ServerConfig.ReqTimeout()):
+ t.Fatalf("waited too long")
+ }
+}
+
+func TestTxnSuccess(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kv := clus.Client(0)
+ ctx := context.TODO()
+
+ _, err := kv.Txn(ctx).Then(clientv3.OpPut("foo", "bar")).Commit()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ resp, err := kv.Get(ctx, "foo")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(resp.Kvs) != 1 || string(resp.Kvs[0].Key) != "foo" {
+ t.Fatalf("unexpected Get response %v", resp)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/integration/user_test.go b/vendor/github.com/coreos/etcd/clientv3/integration/user_test.go
new file mode 100644
index 00000000..09f352be
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/integration/user_test.go
@@ -0,0 +1,106 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "testing"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/pkg/testutil"
+ "golang.org/x/net/context"
+)
+
+func TestUserError(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ authapi := clus.RandClient()
+
+ _, err := authapi.UserAdd(context.TODO(), "foo", "bar")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ _, err = authapi.UserAdd(context.TODO(), "foo", "bar")
+ if err != rpctypes.ErrUserAlreadyExist {
+ t.Fatalf("expected %v, got %v", rpctypes.ErrUserAlreadyExist, err)
+ }
+
+ _, err = authapi.UserDelete(context.TODO(), "not-exist-user")
+ if err != rpctypes.ErrUserNotFound {
+ t.Fatalf("expected %v, got %v", rpctypes.ErrUserNotFound, err)
+ }
+
+ _, err = authapi.UserGrantRole(context.TODO(), "foo", "test-role-does-not-exist")
+ if err != rpctypes.ErrRoleNotFound {
+ t.Fatalf("expected %v, got %v", rpctypes.ErrRoleNotFound, err)
+ }
+}
+
+func TestUserErrorAuth(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ authapi := clus.RandClient()
+ authSetupRoot(t, authapi.Auth)
+
+ // un-authenticated client
+ if _, err := authapi.UserAdd(context.TODO(), "foo", "bar"); err != rpctypes.ErrUserNotFound {
+ t.Fatalf("expected %v, got %v", rpctypes.ErrUserNotFound, err)
+ }
+
+ // wrong id or password
+ cfg := clientv3.Config{Endpoints: authapi.Endpoints()}
+ cfg.Username, cfg.Password = "wrong-id", "123"
+ if _, err := clientv3.New(cfg); err != rpctypes.ErrAuthFailed {
+ t.Fatalf("expected %v, got %v", rpctypes.ErrAuthFailed, err)
+ }
+ cfg.Username, cfg.Password = "root", "wrong-pass"
+ if _, err := clientv3.New(cfg); err != rpctypes.ErrAuthFailed {
+ t.Fatalf("expected %v, got %v", rpctypes.ErrAuthFailed, err)
+ }
+
+ cfg.Username, cfg.Password = "root", "123"
+ authed, err := clientv3.New(cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer authed.Close()
+
+ if _, err := authed.UserList(context.TODO()); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func authSetupRoot(t *testing.T, auth clientv3.Auth) {
+ if _, err := auth.UserAdd(context.TODO(), "root", "123"); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := auth.RoleAdd(context.TODO(), "root"); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := auth.UserGrantRole(context.TODO(), "root", "root"); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := auth.AuthEnable(context.TODO()); err != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/integration/watch_test.go b/vendor/github.com/coreos/etcd/clientv3/integration/watch_test.go
new file mode 100644
index 00000000..4b2fa188
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/integration/watch_test.go
@@ -0,0 +1,1042 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "fmt"
+ "math/rand"
+ "reflect"
+ "sort"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ "github.com/coreos/etcd/integration"
+ mvccpb "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/coreos/etcd/pkg/testutil"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+type watcherTest func(*testing.T, *watchctx)
+
+type watchctx struct {
+ clus *integration.ClusterV3
+ w clientv3.Watcher
+ kv clientv3.KV
+ wclientMember int
+ kvMember int
+ ch clientv3.WatchChan
+}
+
+func runWatchTest(t *testing.T, f watcherTest) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ wclientMember := rand.Intn(3)
+ w := clus.Client(wclientMember).Watcher
+ // select a different client from wclient so puts succeed if
+ // a test knocks out the watcher client
+ kvMember := rand.Intn(3)
+ for kvMember == wclientMember {
+ kvMember = rand.Intn(3)
+ }
+ kv := clus.Client(kvMember).KV
+
+ wctx := &watchctx{clus, w, kv, wclientMember, kvMember, nil}
+ f(t, wctx)
+}
+
+// TestWatchMultiWatcher modifies multiple keys and observes the changes.
+func TestWatchMultiWatcher(t *testing.T) {
+ runWatchTest(t, testWatchMultiWatcher)
+}
+
+func testWatchMultiWatcher(t *testing.T, wctx *watchctx) {
+ numKeyUpdates := 4
+ keys := []string{"foo", "bar", "baz"}
+
+ donec := make(chan struct{})
+ readyc := make(chan struct{})
+ for _, k := range keys {
+ // key watcher
+ go func(key string) {
+ ch := wctx.w.Watch(context.TODO(), key)
+ if ch == nil {
+ t.Fatalf("expected watcher channel, got nil")
+ }
+ readyc <- struct{}{}
+ for i := 0; i < numKeyUpdates; i++ {
+ resp, ok := <-ch
+ if !ok {
+ t.Fatalf("watcher unexpectedly closed")
+ }
+ v := fmt.Sprintf("%s-%d", key, i)
+ gotv := string(resp.Events[0].Kv.Value)
+ if gotv != v {
+ t.Errorf("#%d: got %s, wanted %s", i, gotv, v)
+ }
+ }
+ donec <- struct{}{}
+ }(k)
+ }
+ // prefix watcher on "b" (bar and baz)
+ go func() {
+ prefixc := wctx.w.Watch(context.TODO(), "b", clientv3.WithPrefix())
+ if prefixc == nil {
+ t.Fatalf("expected watcher channel, got nil")
+ }
+ readyc <- struct{}{}
+ evs := []*clientv3.Event{}
+ for i := 0; i < numKeyUpdates*2; i++ {
+ resp, ok := <-prefixc
+ if !ok {
+ t.Fatalf("watcher unexpectedly closed")
+ }
+ evs = append(evs, resp.Events...)
+ }
+
+ // check response
+ expected := []string{}
+ bkeys := []string{"bar", "baz"}
+ for _, k := range bkeys {
+ for i := 0; i < numKeyUpdates; i++ {
+ expected = append(expected, fmt.Sprintf("%s-%d", k, i))
+ }
+ }
+ got := []string{}
+ for _, ev := range evs {
+ got = append(got, string(ev.Kv.Value))
+ }
+ sort.Strings(got)
+ if !reflect.DeepEqual(expected, got) {
+ t.Errorf("got %v, expected %v", got, expected)
+ }
+
+ // ensure no extra data
+ select {
+ case resp, ok := <-prefixc:
+ if !ok {
+ t.Fatalf("watcher unexpectedly closed")
+ }
+ t.Fatalf("unexpected event %+v", resp)
+ case <-time.After(time.Second):
+ }
+ donec <- struct{}{}
+ }()
+
+ // wait for watcher bring up
+ for i := 0; i < len(keys)+1; i++ {
+ <-readyc
+ }
+ // generate events
+ ctx := context.TODO()
+ for i := 0; i < numKeyUpdates; i++ {
+ for _, k := range keys {
+ v := fmt.Sprintf("%s-%d", k, i)
+ if _, err := wctx.kv.Put(ctx, k, v); err != nil {
+ t.Fatal(err)
+ }
+ }
+ }
+ // wait for watcher shutdown
+ for i := 0; i < len(keys)+1; i++ {
+ <-donec
+ }
+}
+
+// TestWatchRange tests watcher creates ranges
+func TestWatchRange(t *testing.T) {
+ runWatchTest(t, testWatchRange)
+}
+
+func testWatchRange(t *testing.T, wctx *watchctx) {
+ if wctx.ch = wctx.w.Watch(context.TODO(), "a", clientv3.WithRange("c")); wctx.ch == nil {
+ t.Fatalf("expected non-nil channel")
+ }
+ putAndWatch(t, wctx, "a", "a")
+ putAndWatch(t, wctx, "b", "b")
+ putAndWatch(t, wctx, "bar", "bar")
+}
+
+// TestWatchReconnRequest tests the send failure path when requesting a watcher.
+func TestWatchReconnRequest(t *testing.T) {
+ runWatchTest(t, testWatchReconnRequest)
+}
+
+func testWatchReconnRequest(t *testing.T, wctx *watchctx) {
+ donec, stopc := make(chan struct{}), make(chan struct{}, 1)
+ go func() {
+ timer := time.After(2 * time.Second)
+ defer close(donec)
+ // take down watcher connection
+ for {
+ wctx.clus.Members[wctx.wclientMember].DropConnections()
+ select {
+ case <-timer:
+ // spinning on close may live lock reconnection
+ return
+ case <-stopc:
+ return
+ default:
+ }
+ }
+ }()
+ // should reconnect when requesting watch
+ if wctx.ch = wctx.w.Watch(context.TODO(), "a"); wctx.ch == nil {
+ t.Fatalf("expected non-nil channel")
+ }
+
+ // wait for disconnections to stop
+ stopc <- struct{}{}
+ <-donec
+
+ // spinning on dropping connections may trigger a leader election
+ // due to resource starvation; l-read to ensure the cluster is stable
+ ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
+ if _, err := wctx.kv.Get(ctx, "_"); err != nil {
+ t.Fatal(err)
+ }
+ cancel()
+
+ // ensure watcher works
+ putAndWatch(t, wctx, "a", "a")
+}
+
+// TestWatchReconnInit tests watcher resumes correctly if connection lost
+// before any data was sent.
+func TestWatchReconnInit(t *testing.T) {
+ runWatchTest(t, testWatchReconnInit)
+}
+
+func testWatchReconnInit(t *testing.T, wctx *watchctx) {
+ if wctx.ch = wctx.w.Watch(context.TODO(), "a"); wctx.ch == nil {
+ t.Fatalf("expected non-nil channel")
+ }
+ wctx.clus.Members[wctx.wclientMember].DropConnections()
+ // watcher should recover
+ putAndWatch(t, wctx, "a", "a")
+}
+
+// TestWatchReconnRunning tests watcher resumes correctly if connection lost
+// after data was sent.
+func TestWatchReconnRunning(t *testing.T) {
+ runWatchTest(t, testWatchReconnRunning)
+}
+
+func testWatchReconnRunning(t *testing.T, wctx *watchctx) {
+ if wctx.ch = wctx.w.Watch(context.TODO(), "a"); wctx.ch == nil {
+ t.Fatalf("expected non-nil channel")
+ }
+ putAndWatch(t, wctx, "a", "a")
+ // take down watcher connection
+ wctx.clus.Members[wctx.wclientMember].DropConnections()
+ // watcher should recover
+ putAndWatch(t, wctx, "a", "b")
+}
+
+// TestWatchCancelImmediate ensures a closed channel is returned
+// if the context is cancelled.
+func TestWatchCancelImmediate(t *testing.T) {
+ runWatchTest(t, testWatchCancelImmediate)
+}
+
+func testWatchCancelImmediate(t *testing.T, wctx *watchctx) {
+ ctx, cancel := context.WithCancel(context.Background())
+ cancel()
+ wch := wctx.w.Watch(ctx, "a")
+ select {
+ case wresp, ok := <-wch:
+ if ok {
+ t.Fatalf("read wch got %v; expected closed channel", wresp)
+ }
+ default:
+ t.Fatalf("closed watcher channel should not block")
+ }
+}
+
+// TestWatchCancelInit tests watcher closes correctly after no events.
+func TestWatchCancelInit(t *testing.T) {
+ runWatchTest(t, testWatchCancelInit)
+}
+
+func testWatchCancelInit(t *testing.T, wctx *watchctx) {
+ ctx, cancel := context.WithCancel(context.Background())
+ if wctx.ch = wctx.w.Watch(ctx, "a"); wctx.ch == nil {
+ t.Fatalf("expected non-nil watcher channel")
+ }
+ cancel()
+ select {
+ case <-time.After(time.Second):
+ t.Fatalf("took too long to cancel")
+ case _, ok := <-wctx.ch:
+ if ok {
+ t.Fatalf("expected watcher channel to close")
+ }
+ }
+}
+
+// TestWatchCancelRunning tests watcher closes correctly after events.
+func TestWatchCancelRunning(t *testing.T) {
+ runWatchTest(t, testWatchCancelRunning)
+}
+
+func testWatchCancelRunning(t *testing.T, wctx *watchctx) {
+ ctx, cancel := context.WithCancel(context.Background())
+ if wctx.ch = wctx.w.Watch(ctx, "a"); wctx.ch == nil {
+ t.Fatalf("expected non-nil watcher channel")
+ }
+ if _, err := wctx.kv.Put(ctx, "a", "a"); err != nil {
+ t.Fatal(err)
+ }
+ cancel()
+ select {
+ case <-time.After(time.Second):
+ t.Fatalf("took too long to cancel")
+ case v, ok := <-wctx.ch:
+ if !ok {
+ // closed before getting put; OK
+ break
+ }
+ // got the PUT; should close next
+ select {
+ case <-time.After(time.Second):
+ t.Fatalf("took too long to close")
+ case v, ok = <-wctx.ch:
+ if ok {
+ t.Fatalf("expected watcher channel to close, got %v", v)
+ }
+ }
+ }
+}
+
+func putAndWatch(t *testing.T, wctx *watchctx, key, val string) {
+ if _, err := wctx.kv.Put(context.TODO(), key, val); err != nil {
+ t.Fatal(err)
+ }
+ select {
+ case <-time.After(5 * time.Second):
+ t.Fatalf("watch timed out")
+ case v, ok := <-wctx.ch:
+ if !ok {
+ t.Fatalf("unexpected watch close")
+ }
+ if string(v.Events[0].Kv.Value) != val {
+ t.Fatalf("bad value got %v, wanted %v", v.Events[0].Kv.Value, val)
+ }
+ }
+}
+
+func TestWatchResumeInitRev(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+ if _, err := cli.Put(context.TODO(), "b", "2"); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := cli.Put(context.TODO(), "a", "3"); err != nil {
+ t.Fatal(err)
+ }
+ // if resume is broken, it'll pick up this key first instead of a=3
+ if _, err := cli.Put(context.TODO(), "a", "4"); err != nil {
+ t.Fatal(err)
+ }
+
+ wch := clus.Client(0).Watch(context.Background(), "a", clientv3.WithRev(1), clientv3.WithCreatedNotify())
+ if resp, ok := <-wch; !ok || resp.Header.Revision != 4 {
+ t.Fatalf("got (%v, %v), expected create notification rev=4", resp, ok)
+ }
+ // pause wch
+ clus.Members[0].DropConnections()
+ clus.Members[0].PauseConnections()
+
+ select {
+ case resp, ok := <-wch:
+ t.Skipf("wch should block, got (%+v, %v); drop not fast enough", resp, ok)
+ case <-time.After(100 * time.Millisecond):
+ }
+
+ // resume wch
+ clus.Members[0].UnpauseConnections()
+
+ select {
+ case resp, ok := <-wch:
+ if !ok {
+ t.Fatal("unexpected watch close")
+ }
+ if len(resp.Events) == 0 {
+ t.Fatal("expected event on watch")
+ }
+ if string(resp.Events[0].Kv.Value) != "3" {
+ t.Fatalf("expected value=3, got event %+v", resp.Events[0])
+ }
+ case <-time.After(5 * time.Second):
+ t.Fatal("watch timed out")
+ }
+}
+
+// TestWatchResumeCompacted checks that the watcher gracefully closes in case
+// that it tries to resume to a revision that's been compacted out of the store.
+// Since the watcher's server restarts with stale data, the watcher will receive
+// either a compaction error or all keys by staying in sync before the compaction
+// is finally applied.
+func TestWatchResumeCompacted(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ // create a waiting watcher at rev 1
+ w := clus.Client(0)
+ wch := w.Watch(context.Background(), "foo", clientv3.WithRev(1))
+ select {
+ case w := <-wch:
+ t.Errorf("unexpected message from wch %v", w)
+ default:
+ }
+ clus.Members[0].Stop(t)
+
+ ticker := time.After(time.Second * 10)
+ for clus.WaitLeader(t) <= 0 {
+ select {
+ case <-ticker:
+ t.Fatalf("failed to wait for new leader")
+ default:
+ time.Sleep(10 * time.Millisecond)
+ }
+ }
+
+ // put some data and compact away
+ numPuts := 5
+ kv := clus.Client(1)
+ for i := 0; i < numPuts; i++ {
+ if _, err := kv.Put(context.TODO(), "foo", "bar"); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if _, err := kv.Compact(context.TODO(), 3); err != nil {
+ t.Fatal(err)
+ }
+
+ clus.Members[0].Restart(t)
+
+ // since watch's server isn't guaranteed to be synced with the cluster when
+ // the watch resumes, there is a window where the watch can stay synced and
+ // read off all events; if the watcher misses the window, it will go out of
+ // sync and get a compaction error.
+ wRev := int64(2)
+ for int(wRev) <= numPuts+1 {
+ var wresp clientv3.WatchResponse
+ var ok bool
+ select {
+ case wresp, ok = <-wch:
+ if !ok {
+ t.Fatalf("expected wresp, but got closed channel")
+ }
+ case <-time.After(5 * time.Second):
+ t.Fatalf("compacted watch timed out")
+ }
+ for _, ev := range wresp.Events {
+ if ev.Kv.ModRevision != wRev {
+ t.Fatalf("expected modRev %v, got %+v", wRev, ev)
+ }
+ wRev++
+ }
+ if wresp.Err() == nil {
+ continue
+ }
+ if wresp.Err() != rpctypes.ErrCompacted {
+ t.Fatalf("wresp.Err() expected %v, got %+v", rpctypes.ErrCompacted, wresp.Err())
+ }
+ break
+ }
+ if int(wRev) > numPuts+1 {
+ // got data faster than the compaction
+ return
+ }
+ // received compaction error; ensure the channel closes
+ select {
+ case wresp, ok := <-wch:
+ if ok {
+ t.Fatalf("expected closed channel, but got %v", wresp)
+ }
+ case <-time.After(5 * time.Second):
+ t.Fatalf("timed out waiting for channel close")
+ }
+}
+
+// TestWatchCompactRevision ensures the CompactRevision error is given on a
+// compaction event ahead of a watcher.
+func TestWatchCompactRevision(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ // set some keys
+ kv := clus.RandClient()
+ for i := 0; i < 5; i++ {
+ if _, err := kv.Put(context.TODO(), "foo", "bar"); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ w := clus.RandClient()
+
+ if _, err := kv.Compact(context.TODO(), 4); err != nil {
+ t.Fatal(err)
+ }
+ wch := w.Watch(context.Background(), "foo", clientv3.WithRev(2))
+
+ // get compacted error message
+ wresp, ok := <-wch
+ if !ok {
+ t.Fatalf("expected wresp, but got closed channel")
+ }
+ if wresp.Err() != rpctypes.ErrCompacted {
+ t.Fatalf("wresp.Err() expected %v, but got %v", rpctypes.ErrCompacted, wresp.Err())
+ }
+
+ // ensure the channel is closed
+ if wresp, ok = <-wch; ok {
+ t.Fatalf("expected closed channel, but got %v", wresp)
+ }
+}
+
+func TestWatchWithProgressNotify(t *testing.T) { testWatchWithProgressNotify(t, true) }
+func TestWatchWithProgressNotifyNoEvent(t *testing.T) { testWatchWithProgressNotify(t, false) }
+
+func testWatchWithProgressNotify(t *testing.T, watchOnPut bool) {
+ defer testutil.AfterTest(t)
+
+ // accelerate report interval so test terminates quickly
+ oldpi := v3rpc.GetProgressReportInterval()
+ // using atomics to avoid race warnings
+ v3rpc.SetProgressReportInterval(3 * time.Second)
+ pi := 3 * time.Second
+ defer func() { v3rpc.SetProgressReportInterval(oldpi) }()
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ wc := clus.RandClient()
+
+ opts := []clientv3.OpOption{clientv3.WithProgressNotify()}
+ if watchOnPut {
+ opts = append(opts, clientv3.WithPrefix())
+ }
+ rch := wc.Watch(context.Background(), "foo", opts...)
+
+ select {
+ case resp := <-rch: // wait for notification
+ if len(resp.Events) != 0 {
+ t.Fatalf("resp.Events expected none, got %+v", resp.Events)
+ }
+ case <-time.After(2 * pi):
+ t.Fatalf("watch response expected in %v, but timed out", pi)
+ }
+
+ kvc := clus.RandClient()
+ if _, err := kvc.Put(context.TODO(), "foox", "bar"); err != nil {
+ t.Fatal(err)
+ }
+
+ select {
+ case resp := <-rch:
+ if resp.Header.Revision != 2 {
+ t.Fatalf("resp.Header.Revision expected 2, got %d", resp.Header.Revision)
+ }
+ if watchOnPut { // wait for put if watch on the put key
+ ev := []*clientv3.Event{{Type: clientv3.EventTypePut,
+ Kv: &mvccpb.KeyValue{Key: []byte("foox"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1}}}
+ if !reflect.DeepEqual(ev, resp.Events) {
+ t.Fatalf("expected %+v, got %+v", ev, resp.Events)
+ }
+ } else if len(resp.Events) != 0 { // wait for notification otherwise
+ t.Fatalf("expected no events, but got %+v", resp.Events)
+ }
+ case <-time.After(time.Duration(1.5 * float64(pi))):
+ t.Fatalf("watch response expected in %v, but timed out", pi)
+ }
+}
+
+func TestWatchEventType(t *testing.T) {
+ cluster := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer cluster.Terminate(t)
+
+ client := cluster.RandClient()
+ ctx := context.Background()
+ watchChan := client.Watch(ctx, "/", clientv3.WithPrefix())
+
+ if _, err := client.Put(ctx, "/toDelete", "foo"); err != nil {
+ t.Fatalf("Put failed: %v", err)
+ }
+ if _, err := client.Put(ctx, "/toDelete", "bar"); err != nil {
+ t.Fatalf("Put failed: %v", err)
+ }
+ if _, err := client.Delete(ctx, "/toDelete"); err != nil {
+ t.Fatalf("Delete failed: %v", err)
+ }
+ lcr, err := client.Lease.Grant(ctx, 1)
+ if err != nil {
+ t.Fatalf("lease create failed: %v", err)
+ }
+ if _, err := client.Put(ctx, "/toExpire", "foo", clientv3.WithLease(lcr.ID)); err != nil {
+ t.Fatalf("Put failed: %v", err)
+ }
+
+ tests := []struct {
+ et mvccpb.Event_EventType
+ isCreate bool
+ isModify bool
+ }{{
+ et: clientv3.EventTypePut,
+ isCreate: true,
+ }, {
+ et: clientv3.EventTypePut,
+ isModify: true,
+ }, {
+ et: clientv3.EventTypeDelete,
+ }, {
+ et: clientv3.EventTypePut,
+ isCreate: true,
+ }, {
+ et: clientv3.EventTypeDelete,
+ }}
+
+ var res []*clientv3.Event
+
+ for {
+ select {
+ case wres := <-watchChan:
+ res = append(res, wres.Events...)
+ case <-time.After(10 * time.Second):
+ t.Fatalf("Should receive %d events and then break out loop", len(tests))
+ }
+ if len(res) == len(tests) {
+ break
+ }
+ }
+
+ for i, tt := range tests {
+ ev := res[i]
+ if tt.et != ev.Type {
+ t.Errorf("#%d: event type want=%s, get=%s", i, tt.et, ev.Type)
+ }
+ if tt.isCreate && !ev.IsCreate() {
+ t.Errorf("#%d: event should be CreateEvent", i)
+ }
+ if tt.isModify && !ev.IsModify() {
+ t.Errorf("#%d: event should be ModifyEvent", i)
+ }
+ }
+}
+
+func TestWatchErrConnClosed(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ ch := cli.Watch(context.TODO(), "foo")
+ if wr := <-ch; grpc.ErrorDesc(wr.Err()) != grpc.ErrClientConnClosing.Error() {
+ t.Fatalf("expected %v, got %v", grpc.ErrClientConnClosing, grpc.ErrorDesc(wr.Err()))
+ }
+ }()
+
+ if err := cli.ActiveConnection().Close(); err != nil {
+ t.Fatal(err)
+ }
+ clus.TakeClient(0)
+
+ select {
+ case <-time.After(3 * time.Second):
+ t.Fatal("wc.Watch took too long")
+ case <-donec:
+ }
+}
+
+func TestWatchAfterClose(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+ clus.TakeClient(0)
+ if err := cli.Close(); err != nil {
+ t.Fatal(err)
+ }
+
+ donec := make(chan struct{})
+ go func() {
+ cli.Watch(context.TODO(), "foo")
+ if err := cli.Close(); err != nil && err != grpc.ErrClientConnClosing {
+ t.Fatalf("expected %v, got %v", grpc.ErrClientConnClosing, err)
+ }
+ close(donec)
+ }()
+ select {
+ case <-time.After(3 * time.Second):
+ t.Fatal("wc.Watch took too long")
+ case <-donec:
+ }
+}
+
+// TestWatchWithRequireLeader checks the watch channel closes when no leader.
+func TestWatchWithRequireLeader(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ // Put a key for the non-require leader watch to read as an event.
+ // The watchers will be on member[0]; put key through member[0] to
+ // ensure that it receives the update so watching after killing quorum
+ // is guaranteed to have the key.
+ liveClient := clus.Client(0)
+ if _, err := liveClient.Put(context.TODO(), "foo", "bar"); err != nil {
+ t.Fatal(err)
+ }
+
+ clus.Members[1].Stop(t)
+ clus.Members[2].Stop(t)
+ clus.Client(1).Close()
+ clus.Client(2).Close()
+ clus.TakeClient(1)
+ clus.TakeClient(2)
+
+ // wait for election timeout, then member[0] will not have a leader.
+ tickDuration := 10 * time.Millisecond
+ // existing streams need three elections before they're torn down; wait until 5 elections cycle
+ // so proxy tests receive a leader loss event on its existing watch before creating a new watch.
+ time.Sleep(time.Duration(5*clus.Members[0].ElectionTicks) * tickDuration)
+
+ chLeader := liveClient.Watch(clientv3.WithRequireLeader(context.TODO()), "foo", clientv3.WithRev(1))
+ chNoLeader := liveClient.Watch(context.TODO(), "foo", clientv3.WithRev(1))
+
+ select {
+ case resp, ok := <-chLeader:
+ if !ok {
+ t.Fatalf("expected %v watch channel, got closed channel", rpctypes.ErrNoLeader)
+ }
+ if resp.Err() != rpctypes.ErrNoLeader {
+ t.Fatalf("expected %v watch response error, got %+v", rpctypes.ErrNoLeader, resp)
+ }
+ case <-time.After(3 * time.Second):
+ t.Fatal("watch without leader took too long to close")
+ }
+
+ select {
+ case resp, ok := <-chLeader:
+ if ok {
+ t.Fatalf("expected closed channel, got response %v", resp)
+ }
+ case <-time.After(3 * time.Second):
+ t.Fatal("waited too long for channel to close")
+ }
+
+ if _, ok := <-chNoLeader; !ok {
+ t.Fatalf("expected response, got closed channel")
+ }
+}
+
+// TestWatchWithFilter checks that watch filtering works.
+func TestWatchWithFilter(t *testing.T) {
+ cluster := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer cluster.Terminate(t)
+
+ client := cluster.RandClient()
+ ctx := context.Background()
+
+ wcNoPut := client.Watch(ctx, "a", clientv3.WithFilterPut())
+ wcNoDel := client.Watch(ctx, "a", clientv3.WithFilterDelete())
+
+ if _, err := client.Put(ctx, "a", "abc"); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := client.Delete(ctx, "a"); err != nil {
+ t.Fatal(err)
+ }
+
+ npResp := <-wcNoPut
+ if len(npResp.Events) != 1 || npResp.Events[0].Type != clientv3.EventTypeDelete {
+ t.Fatalf("expected delete event, got %+v", npResp.Events)
+ }
+ ndResp := <-wcNoDel
+ if len(ndResp.Events) != 1 || ndResp.Events[0].Type != clientv3.EventTypePut {
+ t.Fatalf("expected put event, got %+v", ndResp.Events)
+ }
+
+ select {
+ case resp := <-wcNoPut:
+ t.Fatalf("unexpected event on filtered put (%+v)", resp)
+ case resp := <-wcNoDel:
+ t.Fatalf("unexpected event on filtered delete (%+v)", resp)
+ case <-time.After(100 * time.Millisecond):
+ }
+}
+
+// TestWatchWithCreatedNotification checks that createdNotification works.
+func TestWatchWithCreatedNotification(t *testing.T) {
+ cluster := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer cluster.Terminate(t)
+
+ client := cluster.RandClient()
+
+ ctx := context.Background()
+
+ createC := client.Watch(ctx, "a", clientv3.WithCreatedNotify())
+
+ resp := <-createC
+
+ if !resp.Created {
+ t.Fatalf("expected created event, got %v", resp)
+ }
+}
+
+// TestWatchWithCreatedNotificationDropConn ensures that
+// a watcher with created notify does not post duplicate
+// created events from disconnect.
+func TestWatchWithCreatedNotificationDropConn(t *testing.T) {
+ cluster := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer cluster.Terminate(t)
+
+ client := cluster.RandClient()
+
+ wch := client.Watch(context.Background(), "a", clientv3.WithCreatedNotify())
+
+ resp := <-wch
+
+ if !resp.Created {
+ t.Fatalf("expected created event, got %v", resp)
+ }
+
+ cluster.Members[0].DropConnections()
+
+ // try to receive from watch channel again
+ // ensure it doesn't post another createNotify
+ select {
+ case wresp := <-wch:
+ t.Fatalf("got unexpected watch response: %+v\n", wresp)
+ case <-time.After(time.Second):
+ // watcher may not reconnect by the time it hits the select,
+ // so it wouldn't have a chance to filter out the second create event
+ }
+}
+
+// TestWatchCancelOnServer ensures client watcher cancels propagate back to the server.
+func TestWatchCancelOnServer(t *testing.T) {
+ cluster := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer cluster.Terminate(t)
+
+ client := cluster.RandClient()
+ numWatches := 10
+
+ cancels := make([]context.CancelFunc, numWatches)
+ for i := 0; i < numWatches; i++ {
+ // use WithTimeout to force separate streams in client
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+ cancels[i] = cancel
+ w := client.Watch(ctx, fmt.Sprintf("%d", i), clientv3.WithCreatedNotify())
+ <-w
+ }
+
+ // get max watches; proxy tests have leadership watches, so total may be >numWatches
+ maxWatches, _ := cluster.Members[0].Metric("etcd_debugging_mvcc_watcher_total")
+
+ // cancel all and wait for cancels to propagate to etcd server
+ for i := 0; i < numWatches; i++ {
+ cancels[i]()
+ }
+ time.Sleep(time.Second)
+
+ minWatches, err := cluster.Members[0].Metric("etcd_debugging_mvcc_watcher_total")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ maxWatchV, minWatchV := 0, 0
+ n, serr := fmt.Sscanf(maxWatches+" "+minWatches, "%d %d", &maxWatchV, &minWatchV)
+ if n != 2 || serr != nil {
+ t.Fatalf("expected n=2 and err=nil, got n=%d and err=%v", n, serr)
+ }
+
+ if maxWatchV-minWatchV != numWatches {
+ t.Fatalf("expected %d canceled watchers, got %d", numWatches, maxWatchV-minWatchV)
+ }
+}
+
+// TestWatchOverlapContextCancel stresses the watcher stream teardown path by
+// creating/canceling watchers to ensure that new watchers are not taken down
+// by a torn down watch stream. The sort of race that's being detected:
+// 1. create w1 using a cancelable ctx with %v as "ctx"
+// 2. cancel ctx
+// 3. watcher client begins tearing down watcher grpc stream since no more watchers
+// 3. start creating watcher w2 using a new "ctx" (not canceled), attaches to old grpc stream
+// 4. watcher client finishes tearing down stream on "ctx"
+// 5. w2 comes back canceled
+func TestWatchOverlapContextCancel(t *testing.T) {
+ f := func(clus *integration.ClusterV3) {}
+ testWatchOverlapContextCancel(t, f)
+}
+
+func TestWatchOverlapDropConnContextCancel(t *testing.T) {
+ f := func(clus *integration.ClusterV3) {
+ clus.Members[0].DropConnections()
+ }
+ testWatchOverlapContextCancel(t, f)
+}
+
+func testWatchOverlapContextCancel(t *testing.T, f func(*integration.ClusterV3)) {
+ defer testutil.AfterTest(t)
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ // each unique context "%v" has a unique grpc stream
+ n := 100
+ ctxs, ctxc := make([]context.Context, 5), make([]chan struct{}, 5)
+ for i := range ctxs {
+ // make "%v" unique
+ ctxs[i] = context.WithValue(context.TODO(), "key", i)
+ // limits the maximum number of outstanding watchers per stream
+ ctxc[i] = make(chan struct{}, 2)
+ }
+
+ // issue concurrent watches on "abc" with cancel
+ cli := clus.RandClient()
+ if _, err := cli.Put(context.TODO(), "abc", "def"); err != nil {
+ t.Fatal(err)
+ }
+ ch := make(chan struct{}, n)
+ for i := 0; i < n; i++ {
+ go func() {
+ defer func() { ch <- struct{}{} }()
+ idx := rand.Intn(len(ctxs))
+ ctx, cancel := context.WithCancel(ctxs[idx])
+ ctxc[idx] <- struct{}{}
+ wch := cli.Watch(ctx, "abc", clientv3.WithRev(1))
+ f(clus)
+ select {
+ case _, ok := <-wch:
+ if !ok {
+ t.Fatalf("unexpected closed channel %p", wch)
+ }
+ // may take a second or two to reestablish a watcher because of
+ // grpc backoff policies for disconnects
+ case <-time.After(5 * time.Second):
+ t.Errorf("timed out waiting for watch on %p", wch)
+ }
+ // randomize how cancel overlaps with watch creation
+ if rand.Intn(2) == 0 {
+ <-ctxc[idx]
+ cancel()
+ } else {
+ cancel()
+ <-ctxc[idx]
+ }
+ }()
+ }
+ // join on watches
+ for i := 0; i < n; i++ {
+ select {
+ case <-ch:
+ case <-time.After(5 * time.Second):
+ t.Fatalf("timed out waiting for completed watch")
+ }
+ }
+}
+
+// TestWatchCanelAndCloseClient ensures that canceling a watcher then immediately
+// closing the client does not return a client closing error.
+func TestWatchCancelAndCloseClient(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+ cli := clus.Client(0)
+ ctx, cancel := context.WithCancel(context.Background())
+ wch := cli.Watch(ctx, "abc")
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ select {
+ case wr, ok := <-wch:
+ if ok {
+ t.Fatalf("expected closed watch after cancel(), got resp=%+v err=%v", wr, wr.Err())
+ }
+ case <-time.After(5 * time.Second):
+ t.Fatal("timed out waiting for closed channel")
+ }
+ }()
+ cancel()
+ if err := cli.Close(); err != nil {
+ t.Fatal(err)
+ }
+ <-donec
+ clus.TakeClient(0)
+}
+
+// TestWatchStressResumeClose establishes a bunch of watchers, disconnects
+// to put them in resuming mode, cancels them so some resumes by cancel fail,
+// then closes the watcher interface to ensure correct clean up.
+func TestWatchStressResumeClose(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+ cli := clus.Client(0)
+
+ ctx, cancel := context.WithCancel(context.Background())
+ // add more watches than can be resumed before the cancel
+ wchs := make([]clientv3.WatchChan, 2000)
+ for i := range wchs {
+ wchs[i] = cli.Watch(ctx, "abc")
+ }
+ clus.Members[0].DropConnections()
+ cancel()
+ if err := cli.Close(); err != nil {
+ t.Fatal(err)
+ }
+ clus.TakeClient(0)
+}
+
+// TestWatchCancelDisconnected ensures canceling a watcher works when
+// its grpc stream is disconnected / reconnecting.
+func TestWatchCancelDisconnected(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+ cli := clus.Client(0)
+ ctx, cancel := context.WithCancel(context.Background())
+ // add more watches than can be resumed before the cancel
+ wch := cli.Watch(ctx, "abc")
+ clus.Members[0].Stop(t)
+ cancel()
+ select {
+ case <-wch:
+ case <-time.After(time.Second):
+ t.Fatal("took too long to cancel disconnected watcher")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/kv.go b/vendor/github.com/coreos/etcd/clientv3/kv.go
new file mode 100644
index 00000000..dc45fa4a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/kv.go
@@ -0,0 +1,162 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+type (
+ CompactResponse pb.CompactionResponse
+ PutResponse pb.PutResponse
+ GetResponse pb.RangeResponse
+ DeleteResponse pb.DeleteRangeResponse
+ TxnResponse pb.TxnResponse
+)
+
+type KV interface {
+ // Put puts a key-value pair into etcd.
+ // Note that key,value can be plain bytes array and string is
+ // an immutable representation of that bytes array.
+ // To get a string of bytes, do string([]byte{0x10, 0x20}).
+ Put(ctx context.Context, key, val string, opts ...OpOption) (*PutResponse, error)
+
+ // Get retrieves keys.
+ // By default, Get will return the value for "key", if any.
+ // When passed WithRange(end), Get will return the keys in the range [key, end).
+ // When passed WithFromKey(), Get returns keys greater than or equal to key.
+ // When passed WithRev(rev) with rev > 0, Get retrieves keys at the given revision;
+ // if the required revision is compacted, the request will fail with ErrCompacted .
+ // When passed WithLimit(limit), the number of returned keys is bounded by limit.
+ // When passed WithSort(), the keys will be sorted.
+ Get(ctx context.Context, key string, opts ...OpOption) (*GetResponse, error)
+
+ // Delete deletes a key, or optionally using WithRange(end), [key, end).
+ Delete(ctx context.Context, key string, opts ...OpOption) (*DeleteResponse, error)
+
+ // Compact compacts etcd KV history before the given rev.
+ Compact(ctx context.Context, rev int64, opts ...CompactOption) (*CompactResponse, error)
+
+ // Do applies a single Op on KV without a transaction.
+ // Do is useful when creating arbitrary operations to be issued at a
+ // later time; the user can range over the operations, calling Do to
+ // execute them. Get/Put/Delete, on the other hand, are best suited
+ // for when the operation should be issued at the time of declaration.
+ Do(ctx context.Context, op Op) (OpResponse, error)
+
+ // Txn creates a transaction.
+ Txn(ctx context.Context) Txn
+}
+
+type OpResponse struct {
+ put *PutResponse
+ get *GetResponse
+ del *DeleteResponse
+}
+
+func (op OpResponse) Put() *PutResponse { return op.put }
+func (op OpResponse) Get() *GetResponse { return op.get }
+func (op OpResponse) Del() *DeleteResponse { return op.del }
+
+type kv struct {
+ remote pb.KVClient
+}
+
+func NewKV(c *Client) KV {
+ return &kv{remote: RetryKVClient(c)}
+}
+
+func NewKVFromKVClient(remote pb.KVClient) KV {
+ return &kv{remote: remote}
+}
+
+func (kv *kv) Put(ctx context.Context, key, val string, opts ...OpOption) (*PutResponse, error) {
+ r, err := kv.Do(ctx, OpPut(key, val, opts...))
+ return r.put, toErr(ctx, err)
+}
+
+func (kv *kv) Get(ctx context.Context, key string, opts ...OpOption) (*GetResponse, error) {
+ r, err := kv.Do(ctx, OpGet(key, opts...))
+ return r.get, toErr(ctx, err)
+}
+
+func (kv *kv) Delete(ctx context.Context, key string, opts ...OpOption) (*DeleteResponse, error) {
+ r, err := kv.Do(ctx, OpDelete(key, opts...))
+ return r.del, toErr(ctx, err)
+}
+
+func (kv *kv) Compact(ctx context.Context, rev int64, opts ...CompactOption) (*CompactResponse, error) {
+ resp, err := kv.remote.Compact(ctx, OpCompact(rev, opts...).toRequest())
+ if err != nil {
+ return nil, toErr(ctx, err)
+ }
+ return (*CompactResponse)(resp), err
+}
+
+func (kv *kv) Txn(ctx context.Context) Txn {
+ return &txn{
+ kv: kv,
+ ctx: ctx,
+ }
+}
+
+func (kv *kv) Do(ctx context.Context, op Op) (OpResponse, error) {
+ for {
+ resp, err := kv.do(ctx, op)
+ if err == nil {
+ return resp, nil
+ }
+
+ if isHaltErr(ctx, err) {
+ return resp, toErr(ctx, err)
+ }
+ // do not retry on modifications
+ if op.isWrite() {
+ return resp, toErr(ctx, err)
+ }
+ }
+}
+
+func (kv *kv) do(ctx context.Context, op Op) (OpResponse, error) {
+ var err error
+ switch op.t {
+ // TODO: handle other ops
+ case tRange:
+ var resp *pb.RangeResponse
+ resp, err = kv.remote.Range(ctx, op.toRangeRequest(), grpc.FailFast(false))
+ if err == nil {
+ return OpResponse{get: (*GetResponse)(resp)}, nil
+ }
+ case tPut:
+ var resp *pb.PutResponse
+ r := &pb.PutRequest{Key: op.key, Value: op.val, Lease: int64(op.leaseID), PrevKv: op.prevKV, IgnoreValue: op.ignoreValue, IgnoreLease: op.ignoreLease}
+ resp, err = kv.remote.Put(ctx, r)
+ if err == nil {
+ return OpResponse{put: (*PutResponse)(resp)}, nil
+ }
+ case tDeleteRange:
+ var resp *pb.DeleteRangeResponse
+ r := &pb.DeleteRangeRequest{Key: op.key, RangeEnd: op.end, PrevKv: op.prevKV}
+ resp, err = kv.remote.DeleteRange(ctx, r)
+ if err == nil {
+ return OpResponse{del: (*DeleteResponse)(resp)}, nil
+ }
+ default:
+ panic("Unknown op")
+ }
+ return OpResponse{}, err
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/lease.go b/vendor/github.com/coreos/etcd/clientv3/lease.go
new file mode 100644
index 00000000..6e7ea1f8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/lease.go
@@ -0,0 +1,547 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/metadata"
+)
+
+type (
+ LeaseRevokeResponse pb.LeaseRevokeResponse
+ LeaseID int64
+)
+
+// LeaseGrantResponse is used to convert the protobuf grant response.
+type LeaseGrantResponse struct {
+ *pb.ResponseHeader
+ ID LeaseID
+ TTL int64
+ Error string
+}
+
+// LeaseKeepAliveResponse is used to convert the protobuf keepalive response.
+type LeaseKeepAliveResponse struct {
+ *pb.ResponseHeader
+ ID LeaseID
+ TTL int64
+}
+
+// LeaseTimeToLiveResponse is used to convert the protobuf lease timetolive response.
+type LeaseTimeToLiveResponse struct {
+ *pb.ResponseHeader
+ ID LeaseID `json:"id"`
+
+ // TTL is the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds.
+ TTL int64 `json:"ttl"`
+
+ // GrantedTTL is the initial granted time in seconds upon lease creation/renewal.
+ GrantedTTL int64 `json:"granted-ttl"`
+
+ // Keys is the list of keys attached to this lease.
+ Keys [][]byte `json:"keys"`
+}
+
+const (
+ // defaultTTL is the assumed lease TTL used for the first keepalive
+ // deadline before the actual TTL is known to the client.
+ defaultTTL = 5 * time.Second
+ // a small buffer to store unsent lease responses.
+ leaseResponseChSize = 16
+ // NoLease is a lease ID for the absence of a lease.
+ NoLease LeaseID = 0
+
+ // retryConnWait is how long to wait before retrying request due to an error
+ retryConnWait = 500 * time.Millisecond
+)
+
+// ErrKeepAliveHalted is returned if client keep alive loop halts with an unexpected error.
+//
+// This usually means that automatic lease renewal via KeepAlive is broken, but KeepAliveOnce will still work as expected.
+type ErrKeepAliveHalted struct {
+ Reason error
+}
+
+func (e ErrKeepAliveHalted) Error() string {
+ s := "etcdclient: leases keep alive halted"
+ if e.Reason != nil {
+ s += ": " + e.Reason.Error()
+ }
+ return s
+}
+
+type Lease interface {
+ // Grant creates a new lease.
+ Grant(ctx context.Context, ttl int64) (*LeaseGrantResponse, error)
+
+ // Revoke revokes the given lease.
+ Revoke(ctx context.Context, id LeaseID) (*LeaseRevokeResponse, error)
+
+ // TimeToLive retrieves the lease information of the given lease ID.
+ TimeToLive(ctx context.Context, id LeaseID, opts ...LeaseOption) (*LeaseTimeToLiveResponse, error)
+
+ // KeepAlive keeps the given lease alive forever.
+ KeepAlive(ctx context.Context, id LeaseID) (<-chan *LeaseKeepAliveResponse, error)
+
+ // KeepAliveOnce renews the lease once. In most of the cases, Keepalive
+ // should be used instead of KeepAliveOnce.
+ KeepAliveOnce(ctx context.Context, id LeaseID) (*LeaseKeepAliveResponse, error)
+
+ // Close releases all resources Lease keeps for efficient communication
+ // with the etcd server.
+ Close() error
+}
+
+type lessor struct {
+ mu sync.Mutex // guards all fields
+
+ // donec is closed and loopErr is set when recvKeepAliveLoop stops
+ donec chan struct{}
+ loopErr error
+
+ remote pb.LeaseClient
+
+ stream pb.Lease_LeaseKeepAliveClient
+ streamCancel context.CancelFunc
+
+ stopCtx context.Context
+ stopCancel context.CancelFunc
+
+ keepAlives map[LeaseID]*keepAlive
+
+ // firstKeepAliveTimeout is the timeout for the first keepalive request
+ // before the actual TTL is known to the lease client
+ firstKeepAliveTimeout time.Duration
+
+ // firstKeepAliveOnce ensures stream starts after first KeepAlive call.
+ firstKeepAliveOnce sync.Once
+}
+
+// keepAlive multiplexes a keepalive for a lease over multiple channels
+type keepAlive struct {
+ chs []chan<- *LeaseKeepAliveResponse
+ ctxs []context.Context
+ // deadline is the time the keep alive channels close if no response
+ deadline time.Time
+ // nextKeepAlive is when to send the next keep alive message
+ nextKeepAlive time.Time
+ // donec is closed on lease revoke, expiration, or cancel.
+ donec chan struct{}
+}
+
+func NewLease(c *Client) Lease {
+ return NewLeaseFromLeaseClient(RetryLeaseClient(c), c.cfg.DialTimeout+time.Second)
+}
+
+func NewLeaseFromLeaseClient(remote pb.LeaseClient, keepAliveTimeout time.Duration) Lease {
+ l := &lessor{
+ donec: make(chan struct{}),
+ keepAlives: make(map[LeaseID]*keepAlive),
+ remote: remote,
+ firstKeepAliveTimeout: keepAliveTimeout,
+ }
+ if l.firstKeepAliveTimeout == time.Second {
+ l.firstKeepAliveTimeout = defaultTTL
+ }
+ reqLeaderCtx := WithRequireLeader(context.Background())
+ l.stopCtx, l.stopCancel = context.WithCancel(reqLeaderCtx)
+ return l
+}
+
+func (l *lessor) Grant(ctx context.Context, ttl int64) (*LeaseGrantResponse, error) {
+ for {
+ r := &pb.LeaseGrantRequest{TTL: ttl}
+ resp, err := l.remote.LeaseGrant(ctx, r)
+ if err == nil {
+ gresp := &LeaseGrantResponse{
+ ResponseHeader: resp.GetHeader(),
+ ID: LeaseID(resp.ID),
+ TTL: resp.TTL,
+ Error: resp.Error,
+ }
+ return gresp, nil
+ }
+ if isHaltErr(ctx, err) {
+ return nil, toErr(ctx, err)
+ }
+ }
+}
+
+func (l *lessor) Revoke(ctx context.Context, id LeaseID) (*LeaseRevokeResponse, error) {
+ for {
+ r := &pb.LeaseRevokeRequest{ID: int64(id)}
+ resp, err := l.remote.LeaseRevoke(ctx, r)
+
+ if err == nil {
+ return (*LeaseRevokeResponse)(resp), nil
+ }
+ if isHaltErr(ctx, err) {
+ return nil, toErr(ctx, err)
+ }
+ }
+}
+
+func (l *lessor) TimeToLive(ctx context.Context, id LeaseID, opts ...LeaseOption) (*LeaseTimeToLiveResponse, error) {
+ for {
+ r := toLeaseTimeToLiveRequest(id, opts...)
+ resp, err := l.remote.LeaseTimeToLive(ctx, r, grpc.FailFast(false))
+ if err == nil {
+ gresp := &LeaseTimeToLiveResponse{
+ ResponseHeader: resp.GetHeader(),
+ ID: LeaseID(resp.ID),
+ TTL: resp.TTL,
+ GrantedTTL: resp.GrantedTTL,
+ Keys: resp.Keys,
+ }
+ return gresp, nil
+ }
+ if isHaltErr(ctx, err) {
+ return nil, toErr(ctx, err)
+ }
+ }
+}
+
+func (l *lessor) KeepAlive(ctx context.Context, id LeaseID) (<-chan *LeaseKeepAliveResponse, error) {
+ ch := make(chan *LeaseKeepAliveResponse, leaseResponseChSize)
+
+ l.mu.Lock()
+ // ensure that recvKeepAliveLoop is still running
+ select {
+ case <-l.donec:
+ err := l.loopErr
+ l.mu.Unlock()
+ close(ch)
+ return ch, ErrKeepAliveHalted{Reason: err}
+ default:
+ }
+ ka, ok := l.keepAlives[id]
+ if !ok {
+ // create fresh keep alive
+ ka = &keepAlive{
+ chs: []chan<- *LeaseKeepAliveResponse{ch},
+ ctxs: []context.Context{ctx},
+ deadline: time.Now().Add(l.firstKeepAliveTimeout),
+ nextKeepAlive: time.Now(),
+ donec: make(chan struct{}),
+ }
+ l.keepAlives[id] = ka
+ } else {
+ // add channel and context to existing keep alive
+ ka.ctxs = append(ka.ctxs, ctx)
+ ka.chs = append(ka.chs, ch)
+ }
+ l.mu.Unlock()
+
+ go l.keepAliveCtxCloser(id, ctx, ka.donec)
+ l.firstKeepAliveOnce.Do(func() {
+ go l.recvKeepAliveLoop()
+ go l.deadlineLoop()
+ })
+
+ return ch, nil
+}
+
+func (l *lessor) KeepAliveOnce(ctx context.Context, id LeaseID) (*LeaseKeepAliveResponse, error) {
+ for {
+ resp, err := l.keepAliveOnce(ctx, id)
+ if err == nil {
+ if resp.TTL <= 0 {
+ err = rpctypes.ErrLeaseNotFound
+ }
+ return resp, err
+ }
+ if isHaltErr(ctx, err) {
+ return nil, toErr(ctx, err)
+ }
+ }
+}
+
+func (l *lessor) Close() error {
+ l.stopCancel()
+ // close for synchronous teardown if stream goroutines never launched
+ l.firstKeepAliveOnce.Do(func() { close(l.donec) })
+ <-l.donec
+ return nil
+}
+
+func (l *lessor) keepAliveCtxCloser(id LeaseID, ctx context.Context, donec <-chan struct{}) {
+ select {
+ case <-donec:
+ return
+ case <-l.donec:
+ return
+ case <-ctx.Done():
+ }
+
+ l.mu.Lock()
+ defer l.mu.Unlock()
+
+ ka, ok := l.keepAlives[id]
+ if !ok {
+ return
+ }
+
+ // close channel and remove context if still associated with keep alive
+ for i, c := range ka.ctxs {
+ if c == ctx {
+ close(ka.chs[i])
+ ka.ctxs = append(ka.ctxs[:i], ka.ctxs[i+1:]...)
+ ka.chs = append(ka.chs[:i], ka.chs[i+1:]...)
+ break
+ }
+ }
+ // remove if no one more listeners
+ if len(ka.chs) == 0 {
+ delete(l.keepAlives, id)
+ }
+}
+
+// closeRequireLeader scans all keep alives for ctxs that have require leader
+// and closes the associated channels.
+func (l *lessor) closeRequireLeader() {
+ l.mu.Lock()
+ defer l.mu.Unlock()
+ for _, ka := range l.keepAlives {
+ reqIdxs := 0
+ // find all required leader channels, close, mark as nil
+ for i, ctx := range ka.ctxs {
+ md, ok := metadata.FromContext(ctx)
+ if !ok {
+ continue
+ }
+ ks := md[rpctypes.MetadataRequireLeaderKey]
+ if len(ks) < 1 || ks[0] != rpctypes.MetadataHasLeader {
+ continue
+ }
+ close(ka.chs[i])
+ ka.chs[i] = nil
+ reqIdxs++
+ }
+ if reqIdxs == 0 {
+ continue
+ }
+ // remove all channels that required a leader from keepalive
+ newChs := make([]chan<- *LeaseKeepAliveResponse, len(ka.chs)-reqIdxs)
+ newCtxs := make([]context.Context, len(newChs))
+ newIdx := 0
+ for i := range ka.chs {
+ if ka.chs[i] == nil {
+ continue
+ }
+ newChs[newIdx], newCtxs[newIdx] = ka.chs[i], ka.ctxs[newIdx]
+ newIdx++
+ }
+ ka.chs, ka.ctxs = newChs, newCtxs
+ }
+}
+
+func (l *lessor) keepAliveOnce(ctx context.Context, id LeaseID) (*LeaseKeepAliveResponse, error) {
+ cctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+
+ stream, err := l.remote.LeaseKeepAlive(cctx, grpc.FailFast(false))
+ if err != nil {
+ return nil, toErr(ctx, err)
+ }
+
+ err = stream.Send(&pb.LeaseKeepAliveRequest{ID: int64(id)})
+ if err != nil {
+ return nil, toErr(ctx, err)
+ }
+
+ resp, rerr := stream.Recv()
+ if rerr != nil {
+ return nil, toErr(ctx, rerr)
+ }
+
+ karesp := &LeaseKeepAliveResponse{
+ ResponseHeader: resp.GetHeader(),
+ ID: LeaseID(resp.ID),
+ TTL: resp.TTL,
+ }
+ return karesp, nil
+}
+
+func (l *lessor) recvKeepAliveLoop() (gerr error) {
+ defer func() {
+ l.mu.Lock()
+ close(l.donec)
+ l.loopErr = gerr
+ for _, ka := range l.keepAlives {
+ ka.Close()
+ }
+ l.keepAlives = make(map[LeaseID]*keepAlive)
+ l.mu.Unlock()
+ }()
+
+ for {
+ stream, err := l.resetRecv()
+ if err != nil {
+ if canceledByCaller(l.stopCtx, err) {
+ return err
+ }
+ } else {
+ for {
+ resp, err := stream.Recv()
+
+ if err != nil {
+ if canceledByCaller(l.stopCtx, err) {
+ return err
+ }
+
+ if toErr(l.stopCtx, err) == rpctypes.ErrNoLeader {
+ l.closeRequireLeader()
+ }
+ break
+ }
+
+ l.recvKeepAlive(resp)
+ }
+ }
+
+ select {
+ case <-time.After(retryConnWait):
+ continue
+ case <-l.stopCtx.Done():
+ return l.stopCtx.Err()
+ }
+ }
+}
+
+// resetRecv opens a new lease stream and starts sending LeaseKeepAliveRequests
+func (l *lessor) resetRecv() (pb.Lease_LeaseKeepAliveClient, error) {
+ sctx, cancel := context.WithCancel(l.stopCtx)
+ stream, err := l.remote.LeaseKeepAlive(sctx, grpc.FailFast(false))
+ if err != nil {
+ cancel()
+ return nil, err
+ }
+
+ l.mu.Lock()
+ defer l.mu.Unlock()
+ if l.stream != nil && l.streamCancel != nil {
+ l.streamCancel()
+ }
+
+ l.streamCancel = cancel
+ l.stream = stream
+
+ go l.sendKeepAliveLoop(stream)
+ return stream, nil
+}
+
+// recvKeepAlive updates a lease based on its LeaseKeepAliveResponse
+func (l *lessor) recvKeepAlive(resp *pb.LeaseKeepAliveResponse) {
+ karesp := &LeaseKeepAliveResponse{
+ ResponseHeader: resp.GetHeader(),
+ ID: LeaseID(resp.ID),
+ TTL: resp.TTL,
+ }
+
+ l.mu.Lock()
+ defer l.mu.Unlock()
+
+ ka, ok := l.keepAlives[karesp.ID]
+ if !ok {
+ return
+ }
+
+ if karesp.TTL <= 0 {
+ // lease expired; close all keep alive channels
+ delete(l.keepAlives, karesp.ID)
+ ka.Close()
+ return
+ }
+
+ // send update to all channels
+ nextKeepAlive := time.Now().Add((time.Duration(karesp.TTL) * time.Second) / 3.0)
+ ka.deadline = time.Now().Add(time.Duration(karesp.TTL) * time.Second)
+ for _, ch := range ka.chs {
+ select {
+ case ch <- karesp:
+ ka.nextKeepAlive = nextKeepAlive
+ default:
+ }
+ }
+}
+
+// deadlineLoop reaps any keep alive channels that have not received a response
+// within the lease TTL
+func (l *lessor) deadlineLoop() {
+ for {
+ select {
+ case <-time.After(time.Second):
+ case <-l.donec:
+ return
+ }
+ now := time.Now()
+ l.mu.Lock()
+ for id, ka := range l.keepAlives {
+ if ka.deadline.Before(now) {
+ // waited too long for response; lease may be expired
+ ka.Close()
+ delete(l.keepAlives, id)
+ }
+ }
+ l.mu.Unlock()
+ }
+}
+
+// sendKeepAliveLoop sends LeaseKeepAliveRequests for the lifetime of a lease stream
+func (l *lessor) sendKeepAliveLoop(stream pb.Lease_LeaseKeepAliveClient) {
+ for {
+ var tosend []LeaseID
+
+ now := time.Now()
+ l.mu.Lock()
+ for id, ka := range l.keepAlives {
+ if ka.nextKeepAlive.Before(now) {
+ tosend = append(tosend, id)
+ }
+ }
+ l.mu.Unlock()
+
+ for _, id := range tosend {
+ r := &pb.LeaseKeepAliveRequest{ID: int64(id)}
+ if err := stream.Send(r); err != nil {
+ // TODO do something with this error?
+ return
+ }
+ }
+
+ select {
+ case <-time.After(500 * time.Millisecond):
+ case <-stream.Context().Done():
+ return
+ case <-l.donec:
+ return
+ case <-l.stopCtx.Done():
+ return
+ }
+ }
+}
+
+func (ka *keepAlive) Close() {
+ close(ka.donec)
+ for _, ch := range ka.chs {
+ close(ch)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/logger.go b/vendor/github.com/coreos/etcd/clientv3/logger.go
new file mode 100644
index 00000000..519db45d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/logger.go
@@ -0,0 +1,82 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "io/ioutil"
+ "log"
+ "sync"
+
+ "google.golang.org/grpc/grpclog"
+)
+
+// Logger is the logger used by client library.
+// It implements grpclog.Logger interface.
+type Logger grpclog.Logger
+
+var (
+ logger settableLogger
+)
+
+type settableLogger struct {
+ l grpclog.Logger
+ mu sync.RWMutex
+}
+
+func init() {
+ // disable client side logs by default
+ logger.mu.Lock()
+ logger.l = log.New(ioutil.Discard, "", 0)
+
+ // logger has to override the grpclog at initialization so that
+ // any changes to the grpclog go through logger with locking
+ // instead of through SetLogger
+ //
+ // now updates only happen through settableLogger.set
+ grpclog.SetLogger(&logger)
+ logger.mu.Unlock()
+}
+
+// SetLogger sets client-side Logger. By default, logs are disabled.
+func SetLogger(l Logger) {
+ logger.set(l)
+}
+
+// GetLogger returns the current logger.
+func GetLogger() Logger {
+ return logger.get()
+}
+
+func (s *settableLogger) set(l Logger) {
+ s.mu.Lock()
+ logger.l = l
+ s.mu.Unlock()
+}
+
+func (s *settableLogger) get() Logger {
+ s.mu.RLock()
+ l := logger.l
+ s.mu.RUnlock()
+ return l
+}
+
+// implement the grpclog.Logger interface
+
+func (s *settableLogger) Fatal(args ...interface{}) { s.get().Fatal(args...) }
+func (s *settableLogger) Fatalf(format string, args ...interface{}) { s.get().Fatalf(format, args...) }
+func (s *settableLogger) Fatalln(args ...interface{}) { s.get().Fatalln(args...) }
+func (s *settableLogger) Print(args ...interface{}) { s.get().Print(args...) }
+func (s *settableLogger) Printf(format string, args ...interface{}) { s.get().Printf(format, args...) }
+func (s *settableLogger) Println(args ...interface{}) { s.get().Println(args...) }
diff --git a/vendor/github.com/coreos/etcd/clientv3/main_test.go b/vendor/github.com/coreos/etcd/clientv3/main_test.go
new file mode 100644
index 00000000..eb5a7135
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/main_test.go
@@ -0,0 +1,67 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3_test
+
+import (
+ "fmt"
+ "os"
+ "regexp"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/auth"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/pkg/testutil"
+ "golang.org/x/crypto/bcrypt"
+)
+
+func init() { auth.BcryptCost = bcrypt.MinCost }
+
+// TestMain sets up an etcd cluster if running the examples.
+func TestMain(m *testing.M) {
+ useCluster := true // default to running all tests
+ for _, arg := range os.Args {
+ if strings.HasPrefix(arg, "-test.run=") {
+ exp := strings.Split(arg, "=")[1]
+ match, err := regexp.MatchString(exp, "Example")
+ useCluster = (err == nil && match) || strings.Contains(exp, "Example")
+ break
+ }
+ }
+
+ v := 0
+ if useCluster {
+ cfg := integration.ClusterConfig{Size: 3}
+ clus := integration.NewClusterV3(nil, &cfg)
+ endpoints = make([]string, 3)
+ for i := range endpoints {
+ endpoints[i] = clus.Client(i).Endpoints()[0]
+ }
+ v = m.Run()
+ clus.Terminate(nil)
+ if err := testutil.CheckAfterTest(time.Second); err != nil {
+ fmt.Fprintf(os.Stderr, "%v", err)
+ os.Exit(1)
+ }
+ } else {
+ v = m.Run()
+ }
+
+ if v == 0 && testutil.CheckLeakedGoroutine() {
+ os.Exit(1)
+ }
+ os.Exit(v)
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/maintenance.go b/vendor/github.com/coreos/etcd/clientv3/maintenance.go
new file mode 100644
index 00000000..2a75b7e9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/maintenance.go
@@ -0,0 +1,182 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "io"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+type (
+ DefragmentResponse pb.DefragmentResponse
+ AlarmResponse pb.AlarmResponse
+ AlarmMember pb.AlarmMember
+ StatusResponse pb.StatusResponse
+)
+
+type Maintenance interface {
+ // AlarmList gets all active alarms.
+ AlarmList(ctx context.Context) (*AlarmResponse, error)
+
+ // AlarmDisarm disarms a given alarm.
+ AlarmDisarm(ctx context.Context, m *AlarmMember) (*AlarmResponse, error)
+
+ // Defragment defragments storage backend of the etcd member with given endpoint.
+ // Defragment is only needed when deleting a large number of keys and want to reclaim
+ // the resources.
+ // Defragment is an expensive operation. User should avoid defragmenting multiple members
+ // at the same time.
+ // To defragment multiple members in the cluster, user need to call defragment multiple
+ // times with different endpoints.
+ Defragment(ctx context.Context, endpoint string) (*DefragmentResponse, error)
+
+ // Status gets the status of the endpoint.
+ Status(ctx context.Context, endpoint string) (*StatusResponse, error)
+
+ // Snapshot provides a reader for a snapshot of a backend.
+ Snapshot(ctx context.Context) (io.ReadCloser, error)
+}
+
+type maintenance struct {
+ dial func(endpoint string) (pb.MaintenanceClient, func(), error)
+ remote pb.MaintenanceClient
+}
+
+func NewMaintenance(c *Client) Maintenance {
+ return &maintenance{
+ dial: func(endpoint string) (pb.MaintenanceClient, func(), error) {
+ conn, err := c.dial(endpoint)
+ if err != nil {
+ return nil, nil, err
+ }
+ cancel := func() { conn.Close() }
+ return pb.NewMaintenanceClient(conn), cancel, nil
+ },
+ remote: pb.NewMaintenanceClient(c.conn),
+ }
+}
+
+func NewMaintenanceFromMaintenanceClient(remote pb.MaintenanceClient) Maintenance {
+ return &maintenance{
+ dial: func(string) (pb.MaintenanceClient, func(), error) {
+ return remote, func() {}, nil
+ },
+ remote: remote,
+ }
+}
+
+func (m *maintenance) AlarmList(ctx context.Context) (*AlarmResponse, error) {
+ req := &pb.AlarmRequest{
+ Action: pb.AlarmRequest_GET,
+ MemberID: 0, // all
+ Alarm: pb.AlarmType_NONE, // all
+ }
+ for {
+ resp, err := m.remote.Alarm(ctx, req, grpc.FailFast(false))
+ if err == nil {
+ return (*AlarmResponse)(resp), nil
+ }
+ if isHaltErr(ctx, err) {
+ return nil, toErr(ctx, err)
+ }
+ }
+}
+
+func (m *maintenance) AlarmDisarm(ctx context.Context, am *AlarmMember) (*AlarmResponse, error) {
+ req := &pb.AlarmRequest{
+ Action: pb.AlarmRequest_DEACTIVATE,
+ MemberID: am.MemberID,
+ Alarm: am.Alarm,
+ }
+
+ if req.MemberID == 0 && req.Alarm == pb.AlarmType_NONE {
+ ar, err := m.AlarmList(ctx)
+ if err != nil {
+ return nil, toErr(ctx, err)
+ }
+ ret := AlarmResponse{}
+ for _, am := range ar.Alarms {
+ dresp, derr := m.AlarmDisarm(ctx, (*AlarmMember)(am))
+ if derr != nil {
+ return nil, toErr(ctx, derr)
+ }
+ ret.Alarms = append(ret.Alarms, dresp.Alarms...)
+ }
+ return &ret, nil
+ }
+
+ resp, err := m.remote.Alarm(ctx, req, grpc.FailFast(false))
+ if err == nil {
+ return (*AlarmResponse)(resp), nil
+ }
+ return nil, toErr(ctx, err)
+}
+
+func (m *maintenance) Defragment(ctx context.Context, endpoint string) (*DefragmentResponse, error) {
+ remote, cancel, err := m.dial(endpoint)
+ if err != nil {
+ return nil, toErr(ctx, err)
+ }
+ defer cancel()
+ resp, err := remote.Defragment(ctx, &pb.DefragmentRequest{}, grpc.FailFast(false))
+ if err != nil {
+ return nil, toErr(ctx, err)
+ }
+ return (*DefragmentResponse)(resp), nil
+}
+
+func (m *maintenance) Status(ctx context.Context, endpoint string) (*StatusResponse, error) {
+ remote, cancel, err := m.dial(endpoint)
+ if err != nil {
+ return nil, toErr(ctx, err)
+ }
+ defer cancel()
+ resp, err := remote.Status(ctx, &pb.StatusRequest{}, grpc.FailFast(false))
+ if err != nil {
+ return nil, toErr(ctx, err)
+ }
+ return (*StatusResponse)(resp), nil
+}
+
+func (m *maintenance) Snapshot(ctx context.Context) (io.ReadCloser, error) {
+ ss, err := m.remote.Snapshot(ctx, &pb.SnapshotRequest{}, grpc.FailFast(false))
+ if err != nil {
+ return nil, toErr(ctx, err)
+ }
+
+ pr, pw := io.Pipe()
+ go func() {
+ for {
+ resp, err := ss.Recv()
+ if err != nil {
+ pw.CloseWithError(err)
+ return
+ }
+ if resp == nil && err == nil {
+ break
+ }
+ if _, werr := pw.Write(resp.Blob); werr != nil {
+ pw.CloseWithError(werr)
+ return
+ }
+ }
+ pw.Close()
+ }()
+ return pr, nil
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/mirror/syncer.go b/vendor/github.com/coreos/etcd/clientv3/mirror/syncer.go
new file mode 100644
index 00000000..f2a8f107
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/mirror/syncer.go
@@ -0,0 +1,110 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 mirror implements etcd mirroring operations.
+package mirror
+
+import (
+ "github.com/coreos/etcd/clientv3"
+ "golang.org/x/net/context"
+)
+
+const (
+ batchLimit = 1000
+)
+
+// Syncer syncs with the key-value state of an etcd cluster.
+type Syncer interface {
+ // SyncBase syncs the base state of the key-value state.
+ // The key-value state are sent through the returned chan.
+ SyncBase(ctx context.Context) (<-chan clientv3.GetResponse, chan error)
+ // SyncUpdates syncs the updates of the key-value state.
+ // The update events are sent through the returned chan.
+ SyncUpdates(ctx context.Context) clientv3.WatchChan
+}
+
+// NewSyncer creates a Syncer.
+func NewSyncer(c *clientv3.Client, prefix string, rev int64) Syncer {
+ return &syncer{c: c, prefix: prefix, rev: rev}
+}
+
+type syncer struct {
+ c *clientv3.Client
+ rev int64
+ prefix string
+}
+
+func (s *syncer) SyncBase(ctx context.Context) (<-chan clientv3.GetResponse, chan error) {
+ respchan := make(chan clientv3.GetResponse, 1024)
+ errchan := make(chan error, 1)
+
+ // if rev is not specified, we will choose the most recent revision.
+ if s.rev == 0 {
+ resp, err := s.c.Get(ctx, "foo")
+ if err != nil {
+ errchan <- err
+ close(respchan)
+ close(errchan)
+ return respchan, errchan
+ }
+ s.rev = resp.Header.Revision
+ }
+
+ go func() {
+ defer close(respchan)
+ defer close(errchan)
+
+ var key string
+
+ opts := []clientv3.OpOption{clientv3.WithLimit(batchLimit), clientv3.WithRev(s.rev)}
+
+ if len(s.prefix) == 0 {
+ // If len(s.prefix) == 0, we will sync the entire key-value space.
+ // We then range from the smallest key (0x00) to the end.
+ opts = append(opts, clientv3.WithFromKey())
+ key = "\x00"
+ } else {
+ // If len(s.prefix) != 0, we will sync key-value space with given prefix.
+ // We then range from the prefix to the next prefix if exists. Or we will
+ // range from the prefix to the end if the next prefix does not exists.
+ opts = append(opts, clientv3.WithRange(clientv3.GetPrefixRangeEnd(s.prefix)))
+ key = s.prefix
+ }
+
+ for {
+ resp, err := s.c.Get(ctx, key, opts...)
+ if err != nil {
+ errchan <- err
+ return
+ }
+
+ respchan <- (clientv3.GetResponse)(*resp)
+
+ if !resp.More {
+ return
+ }
+ // move to next key
+ key = string(append(resp.Kvs[len(resp.Kvs)-1].Key, 0))
+ }
+ }()
+
+ return respchan, errchan
+}
+
+func (s *syncer) SyncUpdates(ctx context.Context) clientv3.WatchChan {
+ if s.rev == 0 {
+ panic("unexpected revision = 0. Calling SyncUpdates before SyncBase finishes?")
+ }
+ return s.c.Watch(ctx, s.prefix, clientv3.WithPrefix(), clientv3.WithRev(s.rev+1))
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/namespace/doc.go b/vendor/github.com/coreos/etcd/clientv3/namespace/doc.go
new file mode 100644
index 00000000..3f883320
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/namespace/doc.go
@@ -0,0 +1,43 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 namespace is a clientv3 wrapper that translates all keys to begin
+// with a given prefix.
+//
+// First, create a client:
+//
+// cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"localhost:2379"}})
+// if err != nil {
+// // handle error!
+// }
+//
+// Next, override the client interfaces:
+//
+// unprefixedKV := cli.KV
+// cli.KV = namespace.NewKV(cli.KV, "my-prefix/")
+// cli.Watcher = namespace.NewWatcher(cli.Watcher, "my-prefix/")
+// cli.Lease = namespace.NewLease(cli.Lease, "my-prefix/")
+//
+// Now calls using 'cli' will namespace / prefix all keys with "my-prefix/":
+//
+// cli.Put(context.TODO(), "abc", "123")
+// resp, _ := unprefixedKV.Get(context.TODO(), "my-prefix/abc")
+// fmt.Printf("%s\n", resp.Kvs[0].Value)
+// // Output: 123
+// unprefixedKV.Put(context.TODO(), "my-prefix/abc", "456")
+// resp, _ = cli.Get("abc")
+// fmt.Printf("%s\n", resp.Kvs[0].Value)
+// // Output: 456
+//
+package namespace
diff --git a/vendor/github.com/coreos/etcd/clientv3/namespace/kv.go b/vendor/github.com/coreos/etcd/clientv3/namespace/kv.go
new file mode 100644
index 00000000..f3e82d6b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/namespace/kv.go
@@ -0,0 +1,189 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 namespace
+
+import (
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+type kvPrefix struct {
+ clientv3.KV
+ pfx string
+}
+
+// NewKV wraps a KV instance so that all requests
+// are prefixed with a given string.
+func NewKV(kv clientv3.KV, prefix string) clientv3.KV {
+ return &kvPrefix{kv, prefix}
+}
+
+func (kv *kvPrefix) Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error) {
+ if len(key) == 0 {
+ return nil, rpctypes.ErrEmptyKey
+ }
+ op := kv.prefixOp(clientv3.OpPut(key, val, opts...))
+ r, err := kv.KV.Do(ctx, op)
+ if err != nil {
+ return nil, err
+ }
+ put := r.Put()
+ kv.unprefixPutResponse(put)
+ return put, nil
+}
+
+func (kv *kvPrefix) Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error) {
+ if len(key) == 0 {
+ return nil, rpctypes.ErrEmptyKey
+ }
+ r, err := kv.KV.Do(ctx, kv.prefixOp(clientv3.OpGet(key, opts...)))
+ if err != nil {
+ return nil, err
+ }
+ get := r.Get()
+ kv.unprefixGetResponse(get)
+ return get, nil
+}
+
+func (kv *kvPrefix) Delete(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error) {
+ if len(key) == 0 {
+ return nil, rpctypes.ErrEmptyKey
+ }
+ r, err := kv.KV.Do(ctx, kv.prefixOp(clientv3.OpDelete(key, opts...)))
+ if err != nil {
+ return nil, err
+ }
+ del := r.Del()
+ kv.unprefixDeleteResponse(del)
+ return del, nil
+}
+
+func (kv *kvPrefix) Do(ctx context.Context, op clientv3.Op) (clientv3.OpResponse, error) {
+ if len(op.KeyBytes()) == 0 {
+ return clientv3.OpResponse{}, rpctypes.ErrEmptyKey
+ }
+ r, err := kv.KV.Do(ctx, kv.prefixOp(op))
+ if err != nil {
+ return r, err
+ }
+ switch {
+ case r.Get() != nil:
+ kv.unprefixGetResponse(r.Get())
+ case r.Put() != nil:
+ kv.unprefixPutResponse(r.Put())
+ case r.Del() != nil:
+ kv.unprefixDeleteResponse(r.Del())
+ }
+ return r, nil
+}
+
+type txnPrefix struct {
+ clientv3.Txn
+ kv *kvPrefix
+}
+
+func (kv *kvPrefix) Txn(ctx context.Context) clientv3.Txn {
+ return &txnPrefix{kv.KV.Txn(ctx), kv}
+}
+
+func (txn *txnPrefix) If(cs ...clientv3.Cmp) clientv3.Txn {
+ newCmps := make([]clientv3.Cmp, len(cs))
+ for i := range cs {
+ newCmps[i] = cs[i]
+ pfxKey, _ := txn.kv.prefixInterval(cs[i].KeyBytes(), nil)
+ newCmps[i].WithKeyBytes(pfxKey)
+ }
+ txn.Txn = txn.Txn.If(newCmps...)
+ return txn
+}
+
+func (txn *txnPrefix) Then(ops ...clientv3.Op) clientv3.Txn {
+ newOps := make([]clientv3.Op, len(ops))
+ for i := range ops {
+ newOps[i] = txn.kv.prefixOp(ops[i])
+ }
+ txn.Txn = txn.Txn.Then(newOps...)
+ return txn
+}
+
+func (txn *txnPrefix) Else(ops ...clientv3.Op) clientv3.Txn {
+ newOps := make([]clientv3.Op, len(ops))
+ for i := range ops {
+ newOps[i] = txn.kv.prefixOp(ops[i])
+ }
+ txn.Txn = txn.Txn.Else(newOps...)
+ return txn
+}
+
+func (txn *txnPrefix) Commit() (*clientv3.TxnResponse, error) {
+ resp, err := txn.Txn.Commit()
+ if err != nil {
+ return nil, err
+ }
+ txn.kv.unprefixTxnResponse(resp)
+ return resp, nil
+}
+
+func (kv *kvPrefix) prefixOp(op clientv3.Op) clientv3.Op {
+ begin, end := kv.prefixInterval(op.KeyBytes(), op.RangeBytes())
+ op.WithKeyBytes(begin)
+ op.WithRangeBytes(end)
+ return op
+}
+
+func (kv *kvPrefix) unprefixGetResponse(resp *clientv3.GetResponse) {
+ for i := range resp.Kvs {
+ resp.Kvs[i].Key = resp.Kvs[i].Key[len(kv.pfx):]
+ }
+}
+
+func (kv *kvPrefix) unprefixPutResponse(resp *clientv3.PutResponse) {
+ if resp.PrevKv != nil {
+ resp.PrevKv.Key = resp.PrevKv.Key[len(kv.pfx):]
+ }
+}
+
+func (kv *kvPrefix) unprefixDeleteResponse(resp *clientv3.DeleteResponse) {
+ for i := range resp.PrevKvs {
+ resp.PrevKvs[i].Key = resp.PrevKvs[i].Key[len(kv.pfx):]
+ }
+}
+
+func (kv *kvPrefix) unprefixTxnResponse(resp *clientv3.TxnResponse) {
+ for _, r := range resp.Responses {
+ switch tv := r.Response.(type) {
+ case *pb.ResponseOp_ResponseRange:
+ if tv.ResponseRange != nil {
+ kv.unprefixGetResponse((*clientv3.GetResponse)(tv.ResponseRange))
+ }
+ case *pb.ResponseOp_ResponsePut:
+ if tv.ResponsePut != nil {
+ kv.unprefixPutResponse((*clientv3.PutResponse)(tv.ResponsePut))
+ }
+ case *pb.ResponseOp_ResponseDeleteRange:
+ if tv.ResponseDeleteRange != nil {
+ kv.unprefixDeleteResponse((*clientv3.DeleteResponse)(tv.ResponseDeleteRange))
+ }
+ default:
+ }
+ }
+}
+
+func (p *kvPrefix) prefixInterval(key, end []byte) (pfxKey []byte, pfxEnd []byte) {
+ return prefixInterval(p.pfx, key, end)
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/namespace/lease.go b/vendor/github.com/coreos/etcd/clientv3/namespace/lease.go
new file mode 100644
index 00000000..fc7c2286
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/namespace/lease.go
@@ -0,0 +1,58 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 namespace
+
+import (
+ "bytes"
+
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/clientv3"
+)
+
+type leasePrefix struct {
+ clientv3.Lease
+ pfx []byte
+}
+
+// NewLease wraps a Lease interface to filter for only keys with a prefix
+// and remove that prefix when fetching attached keys through TimeToLive.
+func NewLease(l clientv3.Lease, prefix string) clientv3.Lease {
+ return &leasePrefix{l, []byte(prefix)}
+}
+
+func (l *leasePrefix) TimeToLive(ctx context.Context, id clientv3.LeaseID, opts ...clientv3.LeaseOption) (*clientv3.LeaseTimeToLiveResponse, error) {
+ resp, err := l.Lease.TimeToLive(ctx, id, opts...)
+ if err != nil {
+ return nil, err
+ }
+ if len(resp.Keys) > 0 {
+ var outKeys [][]byte
+ for i := range resp.Keys {
+ if len(resp.Keys[i]) < len(l.pfx) {
+ // too short
+ continue
+ }
+ if !bytes.Equal(resp.Keys[i][:len(l.pfx)], l.pfx) {
+ // doesn't match prefix
+ continue
+ }
+ // strip prefix
+ outKeys = append(outKeys, resp.Keys[i][len(l.pfx):])
+ }
+ resp.Keys = outKeys
+ }
+ return resp, nil
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/namespace/util.go b/vendor/github.com/coreos/etcd/clientv3/namespace/util.go
new file mode 100644
index 00000000..ecf04046
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/namespace/util.go
@@ -0,0 +1,42 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 namespace
+
+func prefixInterval(pfx string, key, end []byte) (pfxKey []byte, pfxEnd []byte) {
+ pfxKey = make([]byte, len(pfx)+len(key))
+ copy(pfxKey[copy(pfxKey, pfx):], key)
+
+ if len(end) == 1 && end[0] == 0 {
+ // the edge of the keyspace
+ pfxEnd = make([]byte, len(pfx))
+ copy(pfxEnd, pfx)
+ ok := false
+ for i := len(pfxEnd) - 1; i >= 0; i-- {
+ if pfxEnd[i]++; pfxEnd[i] != 0 {
+ ok = true
+ break
+ }
+ }
+ if !ok {
+ // 0xff..ff => 0x00
+ pfxEnd = []byte{0}
+ }
+ } else if len(end) >= 1 {
+ pfxEnd = make([]byte, len(pfx)+len(end))
+ copy(pfxEnd[copy(pfxEnd, pfx):], end)
+ }
+
+ return pfxKey, pfxEnd
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/namespace/util_test.go b/vendor/github.com/coreos/etcd/clientv3/namespace/util_test.go
new file mode 100644
index 00000000..9ba472b0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/namespace/util_test.go
@@ -0,0 +1,75 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 namespace
+
+import (
+ "bytes"
+ "testing"
+)
+
+func TestPrefixInterval(t *testing.T) {
+ tests := []struct {
+ pfx string
+ key []byte
+ end []byte
+
+ wKey []byte
+ wEnd []byte
+ }{
+ // single key
+ {
+ pfx: "pfx/",
+ key: []byte("a"),
+
+ wKey: []byte("pfx/a"),
+ },
+ // range
+ {
+ pfx: "pfx/",
+ key: []byte("abc"),
+ end: []byte("def"),
+
+ wKey: []byte("pfx/abc"),
+ wEnd: []byte("pfx/def"),
+ },
+ // one-sided range
+ {
+ pfx: "pfx/",
+ key: []byte("abc"),
+ end: []byte{0},
+
+ wKey: []byte("pfx/abc"),
+ wEnd: []byte("pfx0"),
+ },
+ // one-sided range, end of keyspace
+ {
+ pfx: "\xff\xff",
+ key: []byte("abc"),
+ end: []byte{0},
+
+ wKey: []byte("\xff\xffabc"),
+ wEnd: []byte{0},
+ },
+ }
+ for i, tt := range tests {
+ pfxKey, pfxEnd := prefixInterval(tt.pfx, tt.key, tt.end)
+ if !bytes.Equal(pfxKey, tt.wKey) {
+ t.Errorf("#%d: expected key=%q, got key=%q", i, tt.wKey, pfxKey)
+ }
+ if !bytes.Equal(pfxEnd, tt.wEnd) {
+ t.Errorf("#%d: expected end=%q, got end=%q", i, tt.wEnd, pfxEnd)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/namespace/watch.go b/vendor/github.com/coreos/etcd/clientv3/namespace/watch.go
new file mode 100644
index 00000000..6257e296
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/namespace/watch.go
@@ -0,0 +1,84 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 namespace
+
+import (
+ "sync"
+
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/clientv3"
+)
+
+type watcherPrefix struct {
+ clientv3.Watcher
+ pfx string
+
+ wg sync.WaitGroup
+ stopc chan struct{}
+ stopOnce sync.Once
+}
+
+// NewWatcher wraps a Watcher instance so that all Watch requests
+// are prefixed with a given string and all Watch responses have
+// the prefix removed.
+func NewWatcher(w clientv3.Watcher, prefix string) clientv3.Watcher {
+ return &watcherPrefix{Watcher: w, pfx: prefix, stopc: make(chan struct{})}
+}
+
+func (w *watcherPrefix) Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan {
+ // since OpOption is opaque, determine range for prefixing through an OpGet
+ op := clientv3.OpGet(key, opts...)
+ end := op.RangeBytes()
+ pfxBegin, pfxEnd := prefixInterval(w.pfx, []byte(key), end)
+ if pfxEnd != nil {
+ opts = append(opts, clientv3.WithRange(string(pfxEnd)))
+ }
+
+ wch := w.Watcher.Watch(ctx, string(pfxBegin), opts...)
+
+ // translate watch events from prefixed to unprefixed
+ pfxWch := make(chan clientv3.WatchResponse)
+ w.wg.Add(1)
+ go func() {
+ defer func() {
+ close(pfxWch)
+ w.wg.Done()
+ }()
+ for wr := range wch {
+ for i := range wr.Events {
+ wr.Events[i].Kv.Key = wr.Events[i].Kv.Key[len(w.pfx):]
+ if wr.Events[i].PrevKv != nil {
+ wr.Events[i].PrevKv.Key = wr.Events[i].Kv.Key
+ }
+ }
+ select {
+ case pfxWch <- wr:
+ case <-ctx.Done():
+ return
+ case <-w.stopc:
+ return
+ }
+ }
+ }()
+ return pfxWch
+}
+
+func (w *watcherPrefix) Close() error {
+ err := w.Watcher.Close()
+ w.stopOnce.Do(func() { close(w.stopc) })
+ w.wg.Wait()
+ return err
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/naming/doc.go b/vendor/github.com/coreos/etcd/clientv3/naming/doc.go
new file mode 100644
index 00000000..71608cc7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/naming/doc.go
@@ -0,0 +1,56 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 naming provides an etcd-backed gRPC resolver for discovering gRPC services.
+//
+// To use, first import the packages:
+//
+// import (
+// "github.com/coreos/etcd/clientv3"
+// etcdnaming "github.com/coreos/etcd/clientv3/naming"
+//
+// "google.golang.org/grpc"
+// "google.golang.org/grpc/naming"
+// )
+//
+// First, register new endpoint addresses for a service:
+//
+// func etcdAdd(c *clientv3.Client, service, addr string) error {
+// r := &etcdnaming.GRPCResolver{Client: c}
+// return r.Update(c.Ctx(), service, naming.Update{Op: naming.Add, Addr: addr})
+// }
+//
+// Dial an RPC service using the etcd gRPC resolver and a gRPC Balancer:
+//
+// func etcdDial(c *clientv3.Client, service string) (*grpc.ClientConn, error) {
+// r := &etcdnaming.GRPCResolver{Client: c}
+// b := grpc.RoundRobin(r)
+// return grpc.Dial(service, grpc.WithBalancer(b))
+// }
+//
+// Optionally, force delete an endpoint:
+//
+// func etcdDelete(c *clientv3, service, addr string) error {
+// r := &etcdnaming.GRPCResolver{Client: c}
+// return r.Update(c.Ctx(), "my-service", naming.Update{Op: naming.Delete, Addr: "1.2.3.4"})
+// }
+//
+// Or register an expiring endpoint with a lease:
+//
+// func etcdLeaseAdd(c *clientv3.Client, lid clientv3.LeaseID, service, addr string) error {
+// r := &etcdnaming.GRPCResolver{Client: c}
+// return r.Update(c.Ctx(), service, naming.Update{Op: naming.Add, Addr: addr}, clientv3.WithLease(lid))
+// }
+//
+package naming
diff --git a/vendor/github.com/coreos/etcd/clientv3/naming/grpc.go b/vendor/github.com/coreos/etcd/clientv3/naming/grpc.go
new file mode 100644
index 00000000..9bb92ea6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/naming/grpc.go
@@ -0,0 +1,131 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 naming
+
+import (
+ "encoding/json"
+ "fmt"
+
+ etcd "github.com/coreos/etcd/clientv3"
+ "golang.org/x/net/context"
+
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/naming"
+)
+
+var ErrWatcherClosed = fmt.Errorf("naming: watch closed")
+
+// GRPCResolver creates a grpc.Watcher for a target to track its resolution changes.
+type GRPCResolver struct {
+ // Client is an initialized etcd client.
+ Client *etcd.Client
+}
+
+func (gr *GRPCResolver) Update(ctx context.Context, target string, nm naming.Update, opts ...etcd.OpOption) (err error) {
+ switch nm.Op {
+ case naming.Add:
+ var v []byte
+ if v, err = json.Marshal(nm); err != nil {
+ return grpc.Errorf(codes.InvalidArgument, err.Error())
+ }
+ _, err = gr.Client.KV.Put(ctx, target+"/"+nm.Addr, string(v), opts...)
+ case naming.Delete:
+ _, err = gr.Client.Delete(ctx, target+"/"+nm.Addr, opts...)
+ default:
+ return grpc.Errorf(codes.InvalidArgument, "naming: bad naming op")
+ }
+ return err
+}
+
+func (gr *GRPCResolver) Resolve(target string) (naming.Watcher, error) {
+ ctx, cancel := context.WithCancel(context.Background())
+ w := &gRPCWatcher{c: gr.Client, target: target + "/", ctx: ctx, cancel: cancel}
+ return w, nil
+}
+
+type gRPCWatcher struct {
+ c *etcd.Client
+ target string
+ ctx context.Context
+ cancel context.CancelFunc
+ wch etcd.WatchChan
+ err error
+}
+
+// Next gets the next set of updates from the etcd resolver.
+// Calls to Next should be serialized; concurrent calls are not safe since
+// there is no way to reconcile the update ordering.
+func (gw *gRPCWatcher) Next() ([]*naming.Update, error) {
+ if gw.wch == nil {
+ // first Next() returns all addresses
+ return gw.firstNext()
+ }
+ if gw.err != nil {
+ return nil, gw.err
+ }
+
+ // process new events on target/*
+ wr, ok := <-gw.wch
+ if !ok {
+ gw.err = grpc.Errorf(codes.Unavailable, "%s", ErrWatcherClosed)
+ return nil, gw.err
+ }
+ if gw.err = wr.Err(); gw.err != nil {
+ return nil, gw.err
+ }
+
+ updates := make([]*naming.Update, 0, len(wr.Events))
+ for _, e := range wr.Events {
+ var jupdate naming.Update
+ var err error
+ switch e.Type {
+ case etcd.EventTypePut:
+ err = json.Unmarshal(e.Kv.Value, &jupdate)
+ jupdate.Op = naming.Add
+ case etcd.EventTypeDelete:
+ err = json.Unmarshal(e.PrevKv.Value, &jupdate)
+ jupdate.Op = naming.Delete
+ }
+ if err == nil {
+ updates = append(updates, &jupdate)
+ }
+ }
+ return updates, nil
+}
+
+func (gw *gRPCWatcher) firstNext() ([]*naming.Update, error) {
+ // Use serialized request so resolution still works if the target etcd
+ // server is partitioned away from the quorum.
+ resp, err := gw.c.Get(gw.ctx, gw.target, etcd.WithPrefix(), etcd.WithSerializable())
+ if gw.err = err; err != nil {
+ return nil, err
+ }
+
+ updates := make([]*naming.Update, 0, len(resp.Kvs))
+ for _, kv := range resp.Kvs {
+ var jupdate naming.Update
+ if err := json.Unmarshal(kv.Value, &jupdate); err != nil {
+ continue
+ }
+ updates = append(updates, &jupdate)
+ }
+
+ opts := []etcd.OpOption{etcd.WithRev(resp.Header.Revision + 1), etcd.WithPrefix(), etcd.WithPrevKV()}
+ gw.wch = gw.c.Watch(gw.ctx, gw.target, opts...)
+ return updates, nil
+}
+
+func (gw *gRPCWatcher) Close() { gw.cancel() }
diff --git a/vendor/github.com/coreos/etcd/clientv3/naming/grpc_test.go b/vendor/github.com/coreos/etcd/clientv3/naming/grpc_test.go
new file mode 100644
index 00000000..ad2d2066
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/naming/grpc_test.go
@@ -0,0 +1,135 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 naming
+
+import (
+ "encoding/json"
+ "reflect"
+ "testing"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc/naming"
+
+ etcd "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestGRPCResolver(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ r := GRPCResolver{
+ Client: clus.RandClient(),
+ }
+
+ w, err := r.Resolve("foo")
+ if err != nil {
+ t.Fatal("failed to resolve foo", err)
+ }
+ defer w.Close()
+
+ addOp := naming.Update{Op: naming.Add, Addr: "127.0.0.1", Metadata: "metadata"}
+ err = r.Update(context.TODO(), "foo", addOp)
+ if err != nil {
+ t.Fatal("failed to add foo", err)
+ }
+
+ us, err := w.Next()
+ if err != nil {
+ t.Fatal("failed to get udpate", err)
+ }
+
+ wu := &naming.Update{
+ Op: naming.Add,
+ Addr: "127.0.0.1",
+ Metadata: "metadata",
+ }
+
+ if !reflect.DeepEqual(us[0], wu) {
+ t.Fatalf("up = %#v, want %#v", us[0], wu)
+ }
+
+ delOp := naming.Update{Op: naming.Delete, Addr: "127.0.0.1"}
+ err = r.Update(context.TODO(), "foo", delOp)
+
+ us, err = w.Next()
+ if err != nil {
+ t.Fatal("failed to get udpate", err)
+ }
+
+ wu = &naming.Update{
+ Op: naming.Delete,
+ Addr: "127.0.0.1",
+ Metadata: "metadata",
+ }
+
+ if !reflect.DeepEqual(us[0], wu) {
+ t.Fatalf("up = %#v, want %#v", us[0], wu)
+ }
+}
+
+// TestGRPCResolverMultiInit ensures the resolver will initialize
+// correctly with multiple hosts and correctly receive multiple
+// updates in a single revision.
+func TestGRPCResolverMulti(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+ c := clus.RandClient()
+
+ v, verr := json.Marshal(naming.Update{Addr: "127.0.0.1", Metadata: "md"})
+ if verr != nil {
+ t.Fatal(verr)
+ }
+ if _, err := c.Put(context.TODO(), "foo/host", string(v)); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := c.Put(context.TODO(), "foo/host2", string(v)); err != nil {
+ t.Fatal(err)
+ }
+
+ r := GRPCResolver{c}
+
+ w, err := r.Resolve("foo")
+ if err != nil {
+ t.Fatal("failed to resolve foo", err)
+ }
+ defer w.Close()
+
+ updates, nerr := w.Next()
+ if nerr != nil {
+ t.Fatal(nerr)
+ }
+ if len(updates) != 2 {
+ t.Fatalf("expected two updates, got %+v", updates)
+ }
+
+ _, err = c.Txn(context.TODO()).Then(etcd.OpDelete("foo/host"), etcd.OpDelete("foo/host2")).Commit()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ updates, nerr = w.Next()
+ if nerr != nil {
+ t.Fatal(nerr)
+ }
+ if len(updates) != 2 || (updates[0].Op != naming.Delete && updates[1].Op != naming.Delete) {
+ t.Fatalf("expected two updates, got %+v", updates)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/op.go b/vendor/github.com/coreos/etcd/clientv3/op.go
new file mode 100644
index 00000000..63b99501
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/op.go
@@ -0,0 +1,437 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+
+type opType int
+
+const (
+ // A default Op has opType 0, which is invalid.
+ tRange opType = iota + 1
+ tPut
+ tDeleteRange
+)
+
+var (
+ noPrefixEnd = []byte{0}
+)
+
+// Op represents an Operation that kv can execute.
+type Op struct {
+ t opType
+ key []byte
+ end []byte
+
+ // for range
+ limit int64
+ sort *SortOption
+ serializable bool
+ keysOnly bool
+ countOnly bool
+ minModRev int64
+ maxModRev int64
+ minCreateRev int64
+ maxCreateRev int64
+
+ // for range, watch
+ rev int64
+
+ // for watch, put, delete
+ prevKV bool
+
+ // for put
+ ignoreValue bool
+ ignoreLease bool
+
+ // progressNotify is for progress updates.
+ progressNotify bool
+ // createdNotify is for created event
+ createdNotify bool
+ // filters for watchers
+ filterPut bool
+ filterDelete bool
+
+ // for put
+ val []byte
+ leaseID LeaseID
+}
+
+// accesors / mutators
+
+// KeyBytes returns the byte slice holding the Op's key.
+func (op Op) KeyBytes() []byte { return op.key }
+
+// WithKeyBytes sets the byte slice for the Op's key.
+func (op *Op) WithKeyBytes(key []byte) { op.key = key }
+
+// RangeBytes returns the byte slice holding with the Op's range end, if any.
+func (op Op) RangeBytes() []byte { return op.end }
+
+// WithRangeBytes sets the byte slice for the Op's range end.
+func (op *Op) WithRangeBytes(end []byte) { op.end = end }
+
+// ValueBytes returns the byte slice holding the Op's value, if any.
+func (op Op) ValueBytes() []byte { return op.val }
+
+// WithValueBytes sets the byte slice for the Op's value.
+func (op *Op) WithValueBytes(v []byte) { op.val = v }
+
+func (op Op) toRangeRequest() *pb.RangeRequest {
+ if op.t != tRange {
+ panic("op.t != tRange")
+ }
+ r := &pb.RangeRequest{
+ Key: op.key,
+ RangeEnd: op.end,
+ Limit: op.limit,
+ Revision: op.rev,
+ Serializable: op.serializable,
+ KeysOnly: op.keysOnly,
+ CountOnly: op.countOnly,
+ MinModRevision: op.minModRev,
+ MaxModRevision: op.maxModRev,
+ MinCreateRevision: op.minCreateRev,
+ MaxCreateRevision: op.maxCreateRev,
+ }
+ if op.sort != nil {
+ r.SortOrder = pb.RangeRequest_SortOrder(op.sort.Order)
+ r.SortTarget = pb.RangeRequest_SortTarget(op.sort.Target)
+ }
+ return r
+}
+
+func (op Op) toRequestOp() *pb.RequestOp {
+ switch op.t {
+ case tRange:
+ return &pb.RequestOp{Request: &pb.RequestOp_RequestRange{RequestRange: op.toRangeRequest()}}
+ case tPut:
+ r := &pb.PutRequest{Key: op.key, Value: op.val, Lease: int64(op.leaseID), PrevKv: op.prevKV, IgnoreValue: op.ignoreValue, IgnoreLease: op.ignoreLease}
+ return &pb.RequestOp{Request: &pb.RequestOp_RequestPut{RequestPut: r}}
+ case tDeleteRange:
+ r := &pb.DeleteRangeRequest{Key: op.key, RangeEnd: op.end, PrevKv: op.prevKV}
+ return &pb.RequestOp{Request: &pb.RequestOp_RequestDeleteRange{RequestDeleteRange: r}}
+ default:
+ panic("Unknown Op")
+ }
+}
+
+func (op Op) isWrite() bool {
+ return op.t != tRange
+}
+
+func OpGet(key string, opts ...OpOption) Op {
+ ret := Op{t: tRange, key: []byte(key)}
+ ret.applyOpts(opts)
+ return ret
+}
+
+func OpDelete(key string, opts ...OpOption) Op {
+ ret := Op{t: tDeleteRange, key: []byte(key)}
+ ret.applyOpts(opts)
+ switch {
+ case ret.leaseID != 0:
+ panic("unexpected lease in delete")
+ case ret.limit != 0:
+ panic("unexpected limit in delete")
+ case ret.rev != 0:
+ panic("unexpected revision in delete")
+ case ret.sort != nil:
+ panic("unexpected sort in delete")
+ case ret.serializable:
+ panic("unexpected serializable in delete")
+ case ret.countOnly:
+ panic("unexpected countOnly in delete")
+ case ret.minModRev != 0, ret.maxModRev != 0:
+ panic("unexpected mod revision filter in delete")
+ case ret.minCreateRev != 0, ret.maxCreateRev != 0:
+ panic("unexpected create revision filter in delete")
+ case ret.filterDelete, ret.filterPut:
+ panic("unexpected filter in delete")
+ case ret.createdNotify:
+ panic("unexpected createdNotify in delete")
+ }
+ return ret
+}
+
+func OpPut(key, val string, opts ...OpOption) Op {
+ ret := Op{t: tPut, key: []byte(key), val: []byte(val)}
+ ret.applyOpts(opts)
+ switch {
+ case ret.end != nil:
+ panic("unexpected range in put")
+ case ret.limit != 0:
+ panic("unexpected limit in put")
+ case ret.rev != 0:
+ panic("unexpected revision in put")
+ case ret.sort != nil:
+ panic("unexpected sort in put")
+ case ret.serializable:
+ panic("unexpected serializable in put")
+ case ret.countOnly:
+ panic("unexpected countOnly in put")
+ case ret.minModRev != 0, ret.maxModRev != 0:
+ panic("unexpected mod revision filter in put")
+ case ret.minCreateRev != 0, ret.maxCreateRev != 0:
+ panic("unexpected create revision filter in put")
+ case ret.filterDelete, ret.filterPut:
+ panic("unexpected filter in put")
+ case ret.createdNotify:
+ panic("unexpected createdNotify in put")
+ }
+ return ret
+}
+
+func opWatch(key string, opts ...OpOption) Op {
+ ret := Op{t: tRange, key: []byte(key)}
+ ret.applyOpts(opts)
+ switch {
+ case ret.leaseID != 0:
+ panic("unexpected lease in watch")
+ case ret.limit != 0:
+ panic("unexpected limit in watch")
+ case ret.sort != nil:
+ panic("unexpected sort in watch")
+ case ret.serializable:
+ panic("unexpected serializable in watch")
+ case ret.countOnly:
+ panic("unexpected countOnly in watch")
+ case ret.minModRev != 0, ret.maxModRev != 0:
+ panic("unexpected mod revision filter in watch")
+ case ret.minCreateRev != 0, ret.maxCreateRev != 0:
+ panic("unexpected create revision filter in watch")
+ }
+ return ret
+}
+
+func (op *Op) applyOpts(opts []OpOption) {
+ for _, opt := range opts {
+ opt(op)
+ }
+}
+
+// OpOption configures Operations like Get, Put, Delete.
+type OpOption func(*Op)
+
+// WithLease attaches a lease ID to a key in 'Put' request.
+func WithLease(leaseID LeaseID) OpOption {
+ return func(op *Op) { op.leaseID = leaseID }
+}
+
+// WithLimit limits the number of results to return from 'Get' request.
+// If WithLimit is given a 0 limit, it is treated as no limit.
+func WithLimit(n int64) OpOption { return func(op *Op) { op.limit = n } }
+
+// WithRev specifies the store revision for 'Get' request.
+// Or the start revision of 'Watch' request.
+func WithRev(rev int64) OpOption { return func(op *Op) { op.rev = rev } }
+
+// WithSort specifies the ordering in 'Get' request. It requires
+// 'WithRange' and/or 'WithPrefix' to be specified too.
+// 'target' specifies the target to sort by: key, version, revisions, value.
+// 'order' can be either 'SortNone', 'SortAscend', 'SortDescend'.
+func WithSort(target SortTarget, order SortOrder) OpOption {
+ return func(op *Op) {
+ if target == SortByKey && order == SortAscend {
+ // If order != SortNone, server fetches the entire key-space,
+ // and then applies the sort and limit, if provided.
+ // Since current mvcc.Range implementation returns results
+ // sorted by keys in lexicographically ascending order,
+ // client should ignore SortOrder if the target is SortByKey.
+ order = SortNone
+ }
+ op.sort = &SortOption{target, order}
+ }
+}
+
+// GetPrefixRangeEnd gets the range end of the prefix.
+// 'Get(foo, WithPrefix())' is equal to 'Get(foo, WithRange(GetPrefixRangeEnd(foo))'.
+func GetPrefixRangeEnd(prefix string) string {
+ return string(getPrefix([]byte(prefix)))
+}
+
+func getPrefix(key []byte) []byte {
+ end := make([]byte, len(key))
+ copy(end, key)
+ for i := len(end) - 1; i >= 0; i-- {
+ if end[i] < 0xff {
+ end[i] = end[i] + 1
+ end = end[:i+1]
+ return end
+ }
+ }
+ // next prefix does not exist (e.g., 0xffff);
+ // default to WithFromKey policy
+ return noPrefixEnd
+}
+
+// WithPrefix enables 'Get', 'Delete', or 'Watch' requests to operate
+// on the keys with matching prefix. For example, 'Get(foo, WithPrefix())'
+// can return 'foo1', 'foo2', and so on.
+func WithPrefix() OpOption {
+ return func(op *Op) {
+ if len(op.key) == 0 {
+ op.key, op.end = []byte{0}, []byte{0}
+ return
+ }
+ op.end = getPrefix(op.key)
+ }
+}
+
+// WithRange specifies the range of 'Get', 'Delete', 'Watch' requests.
+// For example, 'Get' requests with 'WithRange(end)' returns
+// the keys in the range [key, end).
+// endKey must be lexicographically greater than start key.
+func WithRange(endKey string) OpOption {
+ return func(op *Op) { op.end = []byte(endKey) }
+}
+
+// WithFromKey specifies the range of 'Get', 'Delete', 'Watch' requests
+// to be equal or greater than the key in the argument.
+func WithFromKey() OpOption { return WithRange("\x00") }
+
+// WithSerializable makes 'Get' request serializable. By default,
+// it's linearizable. Serializable requests are better for lower latency
+// requirement.
+func WithSerializable() OpOption {
+ return func(op *Op) { op.serializable = true }
+}
+
+// WithKeysOnly makes the 'Get' request return only the keys and the corresponding
+// values will be omitted.
+func WithKeysOnly() OpOption {
+ return func(op *Op) { op.keysOnly = true }
+}
+
+// WithCountOnly makes the 'Get' request return only the count of keys.
+func WithCountOnly() OpOption {
+ return func(op *Op) { op.countOnly = true }
+}
+
+// WithMinModRev filters out keys for Get with modification revisions less than the given revision.
+func WithMinModRev(rev int64) OpOption { return func(op *Op) { op.minModRev = rev } }
+
+// WithMaxModRev filters out keys for Get with modification revisions greater than the given revision.
+func WithMaxModRev(rev int64) OpOption { return func(op *Op) { op.maxModRev = rev } }
+
+// WithMinCreateRev filters out keys for Get with creation revisions less than the given revision.
+func WithMinCreateRev(rev int64) OpOption { return func(op *Op) { op.minCreateRev = rev } }
+
+// WithMaxCreateRev filters out keys for Get with creation revisions greater than the given revision.
+func WithMaxCreateRev(rev int64) OpOption { return func(op *Op) { op.maxCreateRev = rev } }
+
+// WithFirstCreate gets the key with the oldest creation revision in the request range.
+func WithFirstCreate() []OpOption { return withTop(SortByCreateRevision, SortAscend) }
+
+// WithLastCreate gets the key with the latest creation revision in the request range.
+func WithLastCreate() []OpOption { return withTop(SortByCreateRevision, SortDescend) }
+
+// WithFirstKey gets the lexically first key in the request range.
+func WithFirstKey() []OpOption { return withTop(SortByKey, SortAscend) }
+
+// WithLastKey gets the lexically last key in the request range.
+func WithLastKey() []OpOption { return withTop(SortByKey, SortDescend) }
+
+// WithFirstRev gets the key with the oldest modification revision in the request range.
+func WithFirstRev() []OpOption { return withTop(SortByModRevision, SortAscend) }
+
+// WithLastRev gets the key with the latest modification revision in the request range.
+func WithLastRev() []OpOption { return withTop(SortByModRevision, SortDescend) }
+
+// withTop gets the first key over the get's prefix given a sort order
+func withTop(target SortTarget, order SortOrder) []OpOption {
+ return []OpOption{WithPrefix(), WithSort(target, order), WithLimit(1)}
+}
+
+// WithProgressNotify makes watch server send periodic progress updates
+// every 10 minutes when there is no incoming events.
+// Progress updates have zero events in WatchResponse.
+func WithProgressNotify() OpOption {
+ return func(op *Op) {
+ op.progressNotify = true
+ }
+}
+
+// WithCreatedNotify makes watch server sends the created event.
+func WithCreatedNotify() OpOption {
+ return func(op *Op) {
+ op.createdNotify = true
+ }
+}
+
+// WithFilterPut discards PUT events from the watcher.
+func WithFilterPut() OpOption {
+ return func(op *Op) { op.filterPut = true }
+}
+
+// WithFilterDelete discards DELETE events from the watcher.
+func WithFilterDelete() OpOption {
+ return func(op *Op) { op.filterDelete = true }
+}
+
+// WithPrevKV gets the previous key-value pair before the event happens. If the previous KV is already compacted,
+// nothing will be returned.
+func WithPrevKV() OpOption {
+ return func(op *Op) {
+ op.prevKV = true
+ }
+}
+
+// WithIgnoreValue updates the key using its current value.
+// Empty value should be passed when ignore_value is set.
+// Returns an error if the key does not exist.
+func WithIgnoreValue() OpOption {
+ return func(op *Op) {
+ op.ignoreValue = true
+ }
+}
+
+// WithIgnoreLease updates the key using its current lease.
+// Empty lease should be passed when ignore_lease is set.
+// Returns an error if the key does not exist.
+func WithIgnoreLease() OpOption {
+ return func(op *Op) {
+ op.ignoreLease = true
+ }
+}
+
+// LeaseOp represents an Operation that lease can execute.
+type LeaseOp struct {
+ id LeaseID
+
+ // for TimeToLive
+ attachedKeys bool
+}
+
+// LeaseOption configures lease operations.
+type LeaseOption func(*LeaseOp)
+
+func (op *LeaseOp) applyOpts(opts []LeaseOption) {
+ for _, opt := range opts {
+ opt(op)
+ }
+}
+
+// WithAttachedKeys requests lease timetolive API to return
+// attached keys of given lease ID.
+func WithAttachedKeys() LeaseOption {
+ return func(op *LeaseOp) { op.attachedKeys = true }
+}
+
+func toLeaseTimeToLiveRequest(id LeaseID, opts ...LeaseOption) *pb.LeaseTimeToLiveRequest {
+ ret := &LeaseOp{id: id}
+ ret.applyOpts(opts)
+ return &pb.LeaseTimeToLiveRequest{ID: int64(id), Keys: ret.attachedKeys}
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/op_test.go b/vendor/github.com/coreos/etcd/clientv3/op_test.go
new file mode 100644
index 00000000..de533f95
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/op_test.go
@@ -0,0 +1,38 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "reflect"
+ "testing"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+// TestOpWithSort tests if WithSort(ASCEND, KEY) and WithLimit are specified,
+// RangeRequest ignores the SortOption to avoid unnecessarily fetching
+// the entire key-space.
+func TestOpWithSort(t *testing.T) {
+ opReq := OpGet("foo", WithSort(SortByKey, SortAscend), WithLimit(10)).toRequestOp().Request
+ q, ok := opReq.(*pb.RequestOp_RequestRange)
+ if !ok {
+ t.Fatalf("expected range request, got %v", reflect.TypeOf(opReq))
+ }
+ req := q.RequestRange
+ wreq := &pb.RangeRequest{Key: []byte("foo"), SortOrder: pb.RangeRequest_NONE, Limit: 10}
+ if !reflect.DeepEqual(req, wreq) {
+ t.Fatalf("expected %+v, got %+v", wreq, req)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/retry.go b/vendor/github.com/coreos/etcd/clientv3/retry.go
new file mode 100644
index 00000000..78f31a8c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/retry.go
@@ -0,0 +1,293 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+)
+
+type rpcFunc func(ctx context.Context) error
+type retryRpcFunc func(context.Context, rpcFunc) error
+
+func (c *Client) newRetryWrapper() retryRpcFunc {
+ return func(rpcCtx context.Context, f rpcFunc) error {
+ for {
+ err := f(rpcCtx)
+ if err == nil {
+ return nil
+ }
+
+ eErr := rpctypes.Error(err)
+ // always stop retry on etcd errors
+ if _, ok := eErr.(rpctypes.EtcdError); ok {
+ return err
+ }
+
+ // only retry if unavailable
+ if grpc.Code(err) != codes.Unavailable {
+ return err
+ }
+
+ select {
+ case <-c.balancer.ConnectNotify():
+ case <-rpcCtx.Done():
+ return rpcCtx.Err()
+ case <-c.ctx.Done():
+ return c.ctx.Err()
+ }
+ }
+ }
+}
+
+func (c *Client) newAuthRetryWrapper() retryRpcFunc {
+ return func(rpcCtx context.Context, f rpcFunc) error {
+ for {
+ err := f(rpcCtx)
+ if err == nil {
+ return nil
+ }
+
+ // always stop retry on etcd errors other than invalid auth token
+ if rpctypes.Error(err) == rpctypes.ErrInvalidAuthToken {
+ gterr := c.getToken(rpcCtx)
+ if gterr != nil {
+ return err // return the original error for simplicity
+ }
+ continue
+ }
+
+ return err
+ }
+ }
+}
+
+// RetryKVClient implements a KVClient that uses the client's FailFast retry policy.
+func RetryKVClient(c *Client) pb.KVClient {
+ retryWrite := &retryWriteKVClient{pb.NewKVClient(c.conn), c.retryWrapper}
+ return &retryKVClient{&retryWriteKVClient{retryWrite, c.retryAuthWrapper}}
+}
+
+type retryKVClient struct {
+ *retryWriteKVClient
+}
+
+func (rkv *retryKVClient) Range(ctx context.Context, in *pb.RangeRequest, opts ...grpc.CallOption) (resp *pb.RangeResponse, err error) {
+ err = rkv.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rkv.retryWriteKVClient.Range(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+type retryWriteKVClient struct {
+ pb.KVClient
+ retryf retryRpcFunc
+}
+
+func (rkv *retryWriteKVClient) Put(ctx context.Context, in *pb.PutRequest, opts ...grpc.CallOption) (resp *pb.PutResponse, err error) {
+ err = rkv.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rkv.KVClient.Put(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rkv *retryWriteKVClient) DeleteRange(ctx context.Context, in *pb.DeleteRangeRequest, opts ...grpc.CallOption) (resp *pb.DeleteRangeResponse, err error) {
+ err = rkv.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rkv.KVClient.DeleteRange(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rkv *retryWriteKVClient) Txn(ctx context.Context, in *pb.TxnRequest, opts ...grpc.CallOption) (resp *pb.TxnResponse, err error) {
+ err = rkv.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rkv.KVClient.Txn(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rkv *retryWriteKVClient) Compact(ctx context.Context, in *pb.CompactionRequest, opts ...grpc.CallOption) (resp *pb.CompactionResponse, err error) {
+ err = rkv.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rkv.KVClient.Compact(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+type retryLeaseClient struct {
+ pb.LeaseClient
+ retryf retryRpcFunc
+}
+
+// RetryLeaseClient implements a LeaseClient that uses the client's FailFast retry policy.
+func RetryLeaseClient(c *Client) pb.LeaseClient {
+ retry := &retryLeaseClient{pb.NewLeaseClient(c.conn), c.retryWrapper}
+ return &retryLeaseClient{retry, c.retryAuthWrapper}
+}
+
+func (rlc *retryLeaseClient) LeaseGrant(ctx context.Context, in *pb.LeaseGrantRequest, opts ...grpc.CallOption) (resp *pb.LeaseGrantResponse, err error) {
+ err = rlc.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rlc.LeaseClient.LeaseGrant(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+
+}
+
+func (rlc *retryLeaseClient) LeaseRevoke(ctx context.Context, in *pb.LeaseRevokeRequest, opts ...grpc.CallOption) (resp *pb.LeaseRevokeResponse, err error) {
+ err = rlc.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rlc.LeaseClient.LeaseRevoke(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+type retryClusterClient struct {
+ pb.ClusterClient
+ retryf retryRpcFunc
+}
+
+// RetryClusterClient implements a ClusterClient that uses the client's FailFast retry policy.
+func RetryClusterClient(c *Client) pb.ClusterClient {
+ return &retryClusterClient{pb.NewClusterClient(c.conn), c.retryWrapper}
+}
+
+func (rcc *retryClusterClient) MemberAdd(ctx context.Context, in *pb.MemberAddRequest, opts ...grpc.CallOption) (resp *pb.MemberAddResponse, err error) {
+ err = rcc.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rcc.ClusterClient.MemberAdd(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rcc *retryClusterClient) MemberRemove(ctx context.Context, in *pb.MemberRemoveRequest, opts ...grpc.CallOption) (resp *pb.MemberRemoveResponse, err error) {
+ err = rcc.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rcc.ClusterClient.MemberRemove(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rcc *retryClusterClient) MemberUpdate(ctx context.Context, in *pb.MemberUpdateRequest, opts ...grpc.CallOption) (resp *pb.MemberUpdateResponse, err error) {
+ err = rcc.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rcc.ClusterClient.MemberUpdate(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+type retryAuthClient struct {
+ pb.AuthClient
+ retryf retryRpcFunc
+}
+
+// RetryAuthClient implements a AuthClient that uses the client's FailFast retry policy.
+func RetryAuthClient(c *Client) pb.AuthClient {
+ return &retryAuthClient{pb.NewAuthClient(c.conn), c.retryWrapper}
+}
+
+func (rac *retryAuthClient) AuthEnable(ctx context.Context, in *pb.AuthEnableRequest, opts ...grpc.CallOption) (resp *pb.AuthEnableResponse, err error) {
+ err = rac.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rac.AuthClient.AuthEnable(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rac *retryAuthClient) AuthDisable(ctx context.Context, in *pb.AuthDisableRequest, opts ...grpc.CallOption) (resp *pb.AuthDisableResponse, err error) {
+ err = rac.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rac.AuthClient.AuthDisable(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rac *retryAuthClient) UserAdd(ctx context.Context, in *pb.AuthUserAddRequest, opts ...grpc.CallOption) (resp *pb.AuthUserAddResponse, err error) {
+ err = rac.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rac.AuthClient.UserAdd(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rac *retryAuthClient) UserDelete(ctx context.Context, in *pb.AuthUserDeleteRequest, opts ...grpc.CallOption) (resp *pb.AuthUserDeleteResponse, err error) {
+ err = rac.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rac.AuthClient.UserDelete(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rac *retryAuthClient) UserChangePassword(ctx context.Context, in *pb.AuthUserChangePasswordRequest, opts ...grpc.CallOption) (resp *pb.AuthUserChangePasswordResponse, err error) {
+ err = rac.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rac.AuthClient.UserChangePassword(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rac *retryAuthClient) UserGrantRole(ctx context.Context, in *pb.AuthUserGrantRoleRequest, opts ...grpc.CallOption) (resp *pb.AuthUserGrantRoleResponse, err error) {
+ err = rac.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rac.AuthClient.UserGrantRole(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rac *retryAuthClient) UserRevokeRole(ctx context.Context, in *pb.AuthUserRevokeRoleRequest, opts ...grpc.CallOption) (resp *pb.AuthUserRevokeRoleResponse, err error) {
+ err = rac.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rac.AuthClient.UserRevokeRole(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rac *retryAuthClient) RoleAdd(ctx context.Context, in *pb.AuthRoleAddRequest, opts ...grpc.CallOption) (resp *pb.AuthRoleAddResponse, err error) {
+ err = rac.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rac.AuthClient.RoleAdd(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rac *retryAuthClient) RoleDelete(ctx context.Context, in *pb.AuthRoleDeleteRequest, opts ...grpc.CallOption) (resp *pb.AuthRoleDeleteResponse, err error) {
+ err = rac.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rac.AuthClient.RoleDelete(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rac *retryAuthClient) RoleGrantPermission(ctx context.Context, in *pb.AuthRoleGrantPermissionRequest, opts ...grpc.CallOption) (resp *pb.AuthRoleGrantPermissionResponse, err error) {
+ err = rac.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rac.AuthClient.RoleGrantPermission(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
+
+func (rac *retryAuthClient) RoleRevokePermission(ctx context.Context, in *pb.AuthRoleRevokePermissionRequest, opts ...grpc.CallOption) (resp *pb.AuthRoleRevokePermissionResponse, err error) {
+ err = rac.retryf(ctx, func(rctx context.Context) error {
+ resp, err = rac.AuthClient.RoleRevokePermission(rctx, in, opts...)
+ return err
+ })
+ return resp, err
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/sort.go b/vendor/github.com/coreos/etcd/clientv3/sort.go
new file mode 100644
index 00000000..2bb9d9a1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/sort.go
@@ -0,0 +1,37 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+type SortTarget int
+type SortOrder int
+
+const (
+ SortNone SortOrder = iota
+ SortAscend
+ SortDescend
+)
+
+const (
+ SortByKey SortTarget = iota
+ SortByVersion
+ SortByCreateRevision
+ SortByModRevision
+ SortByValue
+)
+
+type SortOption struct {
+ Target SortTarget
+ Order SortOrder
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/txn.go b/vendor/github.com/coreos/etcd/clientv3/txn.go
new file mode 100644
index 00000000..7bde6fd7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/txn.go
@@ -0,0 +1,164 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "sync"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+// Txn is the interface that wraps mini-transactions.
+//
+// Tx.If(
+// Compare(Value(k1), ">", v1),
+// Compare(Version(k1), "=", 2)
+// ).Then(
+// OpPut(k2,v2), OpPut(k3,v3)
+// ).Else(
+// OpPut(k4,v4), OpPut(k5,v5)
+// ).Commit()
+//
+type Txn interface {
+ // If takes a list of comparison. If all comparisons passed in succeed,
+ // the operations passed into Then() will be executed. Or the operations
+ // passed into Else() will be executed.
+ If(cs ...Cmp) Txn
+
+ // Then takes a list of operations. The Ops list will be executed, if the
+ // comparisons passed in If() succeed.
+ Then(ops ...Op) Txn
+
+ // Else takes a list of operations. The Ops list will be executed, if the
+ // comparisons passed in If() fail.
+ Else(ops ...Op) Txn
+
+ // Commit tries to commit the transaction.
+ Commit() (*TxnResponse, error)
+}
+
+type txn struct {
+ kv *kv
+ ctx context.Context
+
+ mu sync.Mutex
+ cif bool
+ cthen bool
+ celse bool
+
+ isWrite bool
+
+ cmps []*pb.Compare
+
+ sus []*pb.RequestOp
+ fas []*pb.RequestOp
+}
+
+func (txn *txn) If(cs ...Cmp) Txn {
+ txn.mu.Lock()
+ defer txn.mu.Unlock()
+
+ if txn.cif {
+ panic("cannot call If twice!")
+ }
+
+ if txn.cthen {
+ panic("cannot call If after Then!")
+ }
+
+ if txn.celse {
+ panic("cannot call If after Else!")
+ }
+
+ txn.cif = true
+
+ for i := range cs {
+ txn.cmps = append(txn.cmps, (*pb.Compare)(&cs[i]))
+ }
+
+ return txn
+}
+
+func (txn *txn) Then(ops ...Op) Txn {
+ txn.mu.Lock()
+ defer txn.mu.Unlock()
+
+ if txn.cthen {
+ panic("cannot call Then twice!")
+ }
+ if txn.celse {
+ panic("cannot call Then after Else!")
+ }
+
+ txn.cthen = true
+
+ for _, op := range ops {
+ txn.isWrite = txn.isWrite || op.isWrite()
+ txn.sus = append(txn.sus, op.toRequestOp())
+ }
+
+ return txn
+}
+
+func (txn *txn) Else(ops ...Op) Txn {
+ txn.mu.Lock()
+ defer txn.mu.Unlock()
+
+ if txn.celse {
+ panic("cannot call Else twice!")
+ }
+
+ txn.celse = true
+
+ for _, op := range ops {
+ txn.isWrite = txn.isWrite || op.isWrite()
+ txn.fas = append(txn.fas, op.toRequestOp())
+ }
+
+ return txn
+}
+
+func (txn *txn) Commit() (*TxnResponse, error) {
+ txn.mu.Lock()
+ defer txn.mu.Unlock()
+ for {
+ resp, err := txn.commit()
+ if err == nil {
+ return resp, err
+ }
+ if isHaltErr(txn.ctx, err) {
+ return nil, toErr(txn.ctx, err)
+ }
+ if txn.isWrite {
+ return nil, toErr(txn.ctx, err)
+ }
+ }
+}
+
+func (txn *txn) commit() (*TxnResponse, error) {
+ r := &pb.TxnRequest{Compare: txn.cmps, Success: txn.sus, Failure: txn.fas}
+
+ var opts []grpc.CallOption
+ if !txn.isWrite {
+ opts = []grpc.CallOption{grpc.FailFast(false)}
+ }
+ resp, err := txn.kv.remote.Txn(txn.ctx, r, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return (*TxnResponse)(resp), nil
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/txn_test.go b/vendor/github.com/coreos/etcd/clientv3/txn_test.go
new file mode 100644
index 00000000..d4815161
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/txn_test.go
@@ -0,0 +1,105 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestTxnPanics(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ kv := &kv{}
+
+ errc := make(chan string)
+ df := func() {
+ if s := recover(); s != nil {
+ errc <- s.(string)
+ }
+ }
+
+ cmp := Compare(CreateRevision("foo"), "=", 0)
+ op := OpPut("foo", "bar")
+
+ tests := []struct {
+ f func()
+
+ err string
+ }{
+ {
+ f: func() {
+ defer df()
+ kv.Txn(nil).If(cmp).If(cmp)
+ },
+
+ err: "cannot call If twice!",
+ },
+ {
+ f: func() {
+ defer df()
+ kv.Txn(nil).Then(op).If(cmp)
+ },
+
+ err: "cannot call If after Then!",
+ },
+ {
+ f: func() {
+ defer df()
+ kv.Txn(nil).Else(op).If(cmp)
+ },
+
+ err: "cannot call If after Else!",
+ },
+ {
+ f: func() {
+ defer df()
+ kv.Txn(nil).Then(op).Then(op)
+ },
+
+ err: "cannot call Then twice!",
+ },
+ {
+ f: func() {
+ defer df()
+ kv.Txn(nil).Else(op).Then(op)
+ },
+
+ err: "cannot call Then after Else!",
+ },
+ {
+ f: func() {
+ defer df()
+ kv.Txn(nil).Else(op).Else(op)
+ },
+
+ err: "cannot call Else twice!",
+ },
+ }
+
+ for i, tt := range tests {
+ go tt.f()
+ select {
+ case err := <-errc:
+ if err != tt.err {
+ t.Errorf("#%d: got %s, wanted %s", i, err, tt.err)
+ }
+ case <-time.After(time.Second):
+ t.Errorf("#%d: did not panic, wanted panic %s", i, tt.err)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/watch.go b/vendor/github.com/coreos/etcd/clientv3/watch.go
new file mode 100644
index 00000000..a707f744
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/watch.go
@@ -0,0 +1,797 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "fmt"
+ "sync"
+ "time"
+
+ v3rpc "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ mvccpb "github.com/coreos/etcd/mvcc/mvccpb"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+)
+
+const (
+ EventTypeDelete = mvccpb.DELETE
+ EventTypePut = mvccpb.PUT
+
+ closeSendErrTimeout = 250 * time.Millisecond
+)
+
+type Event mvccpb.Event
+
+type WatchChan <-chan WatchResponse
+
+type Watcher interface {
+ // Watch watches on a key or prefix. The watched events will be returned
+ // through the returned channel.
+ // If the watch is slow or the required rev is compacted, the watch request
+ // might be canceled from the server-side and the chan will be closed.
+ // 'opts' can be: 'WithRev' and/or 'WithPrefix'.
+ Watch(ctx context.Context, key string, opts ...OpOption) WatchChan
+
+ // Close closes the watcher and cancels all watch requests.
+ Close() error
+}
+
+type WatchResponse struct {
+ Header pb.ResponseHeader
+ Events []*Event
+
+ // CompactRevision is the minimum revision the watcher may receive.
+ CompactRevision int64
+
+ // Canceled is used to indicate watch failure.
+ // If the watch failed and the stream was about to close, before the channel is closed,
+ // the channel sends a final response that has Canceled set to true with a non-nil Err().
+ Canceled bool
+
+ // Created is used to indicate the creation of the watcher.
+ Created bool
+
+ closeErr error
+
+ // cancelReason is a reason of canceling watch
+ cancelReason string
+}
+
+// IsCreate returns true if the event tells that the key is newly created.
+func (e *Event) IsCreate() bool {
+ return e.Type == EventTypePut && e.Kv.CreateRevision == e.Kv.ModRevision
+}
+
+// IsModify returns true if the event tells that a new value is put on existing key.
+func (e *Event) IsModify() bool {
+ return e.Type == EventTypePut && e.Kv.CreateRevision != e.Kv.ModRevision
+}
+
+// Err is the error value if this WatchResponse holds an error.
+func (wr *WatchResponse) Err() error {
+ switch {
+ case wr.closeErr != nil:
+ return v3rpc.Error(wr.closeErr)
+ case wr.CompactRevision != 0:
+ return v3rpc.ErrCompacted
+ case wr.Canceled:
+ if len(wr.cancelReason) != 0 {
+ return v3rpc.Error(grpc.Errorf(codes.FailedPrecondition, "%s", wr.cancelReason))
+ }
+ return v3rpc.ErrFutureRev
+ }
+ return nil
+}
+
+// IsProgressNotify returns true if the WatchResponse is progress notification.
+func (wr *WatchResponse) IsProgressNotify() bool {
+ return len(wr.Events) == 0 && !wr.Canceled && !wr.Created && wr.CompactRevision == 0 && wr.Header.Revision != 0
+}
+
+// watcher implements the Watcher interface
+type watcher struct {
+ remote pb.WatchClient
+
+ // mu protects the grpc streams map
+ mu sync.RWMutex
+
+ // streams holds all the active grpc streams keyed by ctx value.
+ streams map[string]*watchGrpcStream
+}
+
+// watchGrpcStream tracks all watch resources attached to a single grpc stream.
+type watchGrpcStream struct {
+ owner *watcher
+ remote pb.WatchClient
+
+ // ctx controls internal remote.Watch requests
+ ctx context.Context
+ // ctxKey is the key used when looking up this stream's context
+ ctxKey string
+ cancel context.CancelFunc
+
+ // substreams holds all active watchers on this grpc stream
+ substreams map[int64]*watcherStream
+ // resuming holds all resuming watchers on this grpc stream
+ resuming []*watcherStream
+
+ // reqc sends a watch request from Watch() to the main goroutine
+ reqc chan *watchRequest
+ // respc receives data from the watch client
+ respc chan *pb.WatchResponse
+ // donec closes to broadcast shutdown
+ donec chan struct{}
+ // errc transmits errors from grpc Recv to the watch stream reconn logic
+ errc chan error
+ // closingc gets the watcherStream of closing watchers
+ closingc chan *watcherStream
+ // wg is Done when all substream goroutines have exited
+ wg sync.WaitGroup
+
+ // resumec closes to signal that all substreams should begin resuming
+ resumec chan struct{}
+ // closeErr is the error that closed the watch stream
+ closeErr error
+}
+
+// watchRequest is issued by the subscriber to start a new watcher
+type watchRequest struct {
+ ctx context.Context
+ key string
+ end string
+ rev int64
+ // send created notification event if this field is true
+ createdNotify bool
+ // progressNotify is for progress updates
+ progressNotify bool
+ // filters is the list of events to filter out
+ filters []pb.WatchCreateRequest_FilterType
+ // get the previous key-value pair before the event happens
+ prevKV bool
+ // retc receives a chan WatchResponse once the watcher is established
+ retc chan chan WatchResponse
+}
+
+// watcherStream represents a registered watcher
+type watcherStream struct {
+ // initReq is the request that initiated this request
+ initReq watchRequest
+
+ // outc publishes watch responses to subscriber
+ outc chan WatchResponse
+ // recvc buffers watch responses before publishing
+ recvc chan *WatchResponse
+ // donec closes when the watcherStream goroutine stops.
+ donec chan struct{}
+ // closing is set to true when stream should be scheduled to shutdown.
+ closing bool
+ // id is the registered watch id on the grpc stream
+ id int64
+
+ // buf holds all events received from etcd but not yet consumed by the client
+ buf []*WatchResponse
+}
+
+func NewWatcher(c *Client) Watcher {
+ return NewWatchFromWatchClient(pb.NewWatchClient(c.conn))
+}
+
+func NewWatchFromWatchClient(wc pb.WatchClient) Watcher {
+ return &watcher{
+ remote: wc,
+ streams: make(map[string]*watchGrpcStream),
+ }
+}
+
+// never closes
+var valCtxCh = make(chan struct{})
+var zeroTime = time.Unix(0, 0)
+
+// ctx with only the values; never Done
+type valCtx struct{ context.Context }
+
+func (vc *valCtx) Deadline() (time.Time, bool) { return zeroTime, false }
+func (vc *valCtx) Done() <-chan struct{} { return valCtxCh }
+func (vc *valCtx) Err() error { return nil }
+
+func (w *watcher) newWatcherGrpcStream(inctx context.Context) *watchGrpcStream {
+ ctx, cancel := context.WithCancel(&valCtx{inctx})
+ wgs := &watchGrpcStream{
+ owner: w,
+ remote: w.remote,
+ ctx: ctx,
+ ctxKey: fmt.Sprintf("%v", inctx),
+ cancel: cancel,
+ substreams: make(map[int64]*watcherStream),
+
+ respc: make(chan *pb.WatchResponse),
+ reqc: make(chan *watchRequest),
+ donec: make(chan struct{}),
+ errc: make(chan error, 1),
+ closingc: make(chan *watcherStream),
+ resumec: make(chan struct{}),
+ }
+ go wgs.run()
+ return wgs
+}
+
+// Watch posts a watch request to run() and waits for a new watcher channel
+func (w *watcher) Watch(ctx context.Context, key string, opts ...OpOption) WatchChan {
+ ow := opWatch(key, opts...)
+
+ var filters []pb.WatchCreateRequest_FilterType
+ if ow.filterPut {
+ filters = append(filters, pb.WatchCreateRequest_NOPUT)
+ }
+ if ow.filterDelete {
+ filters = append(filters, pb.WatchCreateRequest_NODELETE)
+ }
+
+ wr := &watchRequest{
+ ctx: ctx,
+ createdNotify: ow.createdNotify,
+ key: string(ow.key),
+ end: string(ow.end),
+ rev: ow.rev,
+ progressNotify: ow.progressNotify,
+ filters: filters,
+ prevKV: ow.prevKV,
+ retc: make(chan chan WatchResponse, 1),
+ }
+
+ ok := false
+ ctxKey := fmt.Sprintf("%v", ctx)
+
+ // find or allocate appropriate grpc watch stream
+ w.mu.Lock()
+ if w.streams == nil {
+ // closed
+ w.mu.Unlock()
+ ch := make(chan WatchResponse)
+ close(ch)
+ return ch
+ }
+ wgs := w.streams[ctxKey]
+ if wgs == nil {
+ wgs = w.newWatcherGrpcStream(ctx)
+ w.streams[ctxKey] = wgs
+ }
+ donec := wgs.donec
+ reqc := wgs.reqc
+ w.mu.Unlock()
+
+ // couldn't create channel; return closed channel
+ closeCh := make(chan WatchResponse, 1)
+
+ // submit request
+ select {
+ case reqc <- wr:
+ ok = true
+ case <-wr.ctx.Done():
+ case <-donec:
+ if wgs.closeErr != nil {
+ closeCh <- WatchResponse{closeErr: wgs.closeErr}
+ break
+ }
+ // retry; may have dropped stream from no ctxs
+ return w.Watch(ctx, key, opts...)
+ }
+
+ // receive channel
+ if ok {
+ select {
+ case ret := <-wr.retc:
+ return ret
+ case <-ctx.Done():
+ case <-donec:
+ if wgs.closeErr != nil {
+ closeCh <- WatchResponse{closeErr: wgs.closeErr}
+ break
+ }
+ // retry; may have dropped stream from no ctxs
+ return w.Watch(ctx, key, opts...)
+ }
+ }
+
+ close(closeCh)
+ return closeCh
+}
+
+func (w *watcher) Close() (err error) {
+ w.mu.Lock()
+ streams := w.streams
+ w.streams = nil
+ w.mu.Unlock()
+ for _, wgs := range streams {
+ if werr := wgs.Close(); werr != nil {
+ err = werr
+ }
+ }
+ return err
+}
+
+func (w *watchGrpcStream) Close() (err error) {
+ w.cancel()
+ <-w.donec
+ select {
+ case err = <-w.errc:
+ default:
+ }
+ return toErr(w.ctx, err)
+}
+
+func (w *watcher) closeStream(wgs *watchGrpcStream) {
+ w.mu.Lock()
+ close(wgs.donec)
+ wgs.cancel()
+ if w.streams != nil {
+ delete(w.streams, wgs.ctxKey)
+ }
+ w.mu.Unlock()
+}
+
+func (w *watchGrpcStream) addSubstream(resp *pb.WatchResponse, ws *watcherStream) {
+ if resp.WatchId == -1 {
+ // failed; no channel
+ close(ws.recvc)
+ return
+ }
+ ws.id = resp.WatchId
+ w.substreams[ws.id] = ws
+}
+
+func (w *watchGrpcStream) sendCloseSubstream(ws *watcherStream, resp *WatchResponse) {
+ select {
+ case ws.outc <- *resp:
+ case <-ws.initReq.ctx.Done():
+ case <-time.After(closeSendErrTimeout):
+ }
+ close(ws.outc)
+}
+
+func (w *watchGrpcStream) closeSubstream(ws *watcherStream) {
+ // send channel response in case stream was never established
+ select {
+ case ws.initReq.retc <- ws.outc:
+ default:
+ }
+ // close subscriber's channel
+ if closeErr := w.closeErr; closeErr != nil && ws.initReq.ctx.Err() == nil {
+ go w.sendCloseSubstream(ws, &WatchResponse{closeErr: w.closeErr})
+ } else if ws.outc != nil {
+ close(ws.outc)
+ }
+ if ws.id != -1 {
+ delete(w.substreams, ws.id)
+ return
+ }
+ for i := range w.resuming {
+ if w.resuming[i] == ws {
+ w.resuming[i] = nil
+ return
+ }
+ }
+}
+
+// run is the root of the goroutines for managing a watcher client
+func (w *watchGrpcStream) run() {
+ var wc pb.Watch_WatchClient
+ var closeErr error
+
+ // substreams marked to close but goroutine still running; needed for
+ // avoiding double-closing recvc on grpc stream teardown
+ closing := make(map[*watcherStream]struct{})
+
+ defer func() {
+ w.closeErr = closeErr
+ // shutdown substreams and resuming substreams
+ for _, ws := range w.substreams {
+ if _, ok := closing[ws]; !ok {
+ close(ws.recvc)
+ closing[ws] = struct{}{}
+ }
+ }
+ for _, ws := range w.resuming {
+ if _, ok := closing[ws]; ws != nil && !ok {
+ close(ws.recvc)
+ closing[ws] = struct{}{}
+ }
+ }
+ w.joinSubstreams()
+ for range closing {
+ w.closeSubstream(<-w.closingc)
+ }
+ w.wg.Wait()
+ w.owner.closeStream(w)
+ }()
+
+ // start a stream with the etcd grpc server
+ if wc, closeErr = w.newWatchClient(); closeErr != nil {
+ return
+ }
+
+ cancelSet := make(map[int64]struct{})
+
+ for {
+ select {
+ // Watch() requested
+ case wreq := <-w.reqc:
+ outc := make(chan WatchResponse, 1)
+ ws := &watcherStream{
+ initReq: *wreq,
+ id: -1,
+ outc: outc,
+ // unbufffered so resumes won't cause repeat events
+ recvc: make(chan *WatchResponse),
+ }
+
+ ws.donec = make(chan struct{})
+ w.wg.Add(1)
+ go w.serveSubstream(ws, w.resumec)
+
+ // queue up for watcher creation/resume
+ w.resuming = append(w.resuming, ws)
+ if len(w.resuming) == 1 {
+ // head of resume queue, can register a new watcher
+ wc.Send(ws.initReq.toPB())
+ }
+ // New events from the watch client
+ case pbresp := <-w.respc:
+ switch {
+ case pbresp.Created:
+ // response to head of queue creation
+ if ws := w.resuming[0]; ws != nil {
+ w.addSubstream(pbresp, ws)
+ w.dispatchEvent(pbresp)
+ w.resuming[0] = nil
+ }
+ if ws := w.nextResume(); ws != nil {
+ wc.Send(ws.initReq.toPB())
+ }
+ case pbresp.Canceled:
+ delete(cancelSet, pbresp.WatchId)
+ if ws, ok := w.substreams[pbresp.WatchId]; ok {
+ // signal to stream goroutine to update closingc
+ close(ws.recvc)
+ closing[ws] = struct{}{}
+ }
+ default:
+ // dispatch to appropriate watch stream
+ if ok := w.dispatchEvent(pbresp); ok {
+ break
+ }
+ // watch response on unexpected watch id; cancel id
+ if _, ok := cancelSet[pbresp.WatchId]; ok {
+ break
+ }
+ cancelSet[pbresp.WatchId] = struct{}{}
+ cr := &pb.WatchRequest_CancelRequest{
+ CancelRequest: &pb.WatchCancelRequest{
+ WatchId: pbresp.WatchId,
+ },
+ }
+ req := &pb.WatchRequest{RequestUnion: cr}
+ wc.Send(req)
+ }
+ // watch client failed to recv; spawn another if possible
+ case err := <-w.errc:
+ if isHaltErr(w.ctx, err) || toErr(w.ctx, err) == v3rpc.ErrNoLeader {
+ closeErr = err
+ return
+ }
+ if wc, closeErr = w.newWatchClient(); closeErr != nil {
+ return
+ }
+ if ws := w.nextResume(); ws != nil {
+ wc.Send(ws.initReq.toPB())
+ }
+ cancelSet = make(map[int64]struct{})
+ case <-w.ctx.Done():
+ return
+ case ws := <-w.closingc:
+ w.closeSubstream(ws)
+ delete(closing, ws)
+ if len(w.substreams)+len(w.resuming) == 0 {
+ // no more watchers on this stream, shutdown
+ return
+ }
+ }
+ }
+}
+
+// nextResume chooses the next resuming to register with the grpc stream. Abandoned
+// streams are marked as nil in the queue since the head must wait for its inflight registration.
+func (w *watchGrpcStream) nextResume() *watcherStream {
+ for len(w.resuming) != 0 {
+ if w.resuming[0] != nil {
+ return w.resuming[0]
+ }
+ w.resuming = w.resuming[1:len(w.resuming)]
+ }
+ return nil
+}
+
+// dispatchEvent sends a WatchResponse to the appropriate watcher stream
+func (w *watchGrpcStream) dispatchEvent(pbresp *pb.WatchResponse) bool {
+ events := make([]*Event, len(pbresp.Events))
+ for i, ev := range pbresp.Events {
+ events[i] = (*Event)(ev)
+ }
+ wr := &WatchResponse{
+ Header: *pbresp.Header,
+ Events: events,
+ CompactRevision: pbresp.CompactRevision,
+ Created: pbresp.Created,
+ Canceled: pbresp.Canceled,
+ cancelReason: pbresp.CancelReason,
+ }
+ ws, ok := w.substreams[pbresp.WatchId]
+ if !ok {
+ return false
+ }
+ select {
+ case ws.recvc <- wr:
+ case <-ws.donec:
+ return false
+ }
+ return true
+}
+
+// serveWatchClient forwards messages from the grpc stream to run()
+func (w *watchGrpcStream) serveWatchClient(wc pb.Watch_WatchClient) {
+ for {
+ resp, err := wc.Recv()
+ if err != nil {
+ select {
+ case w.errc <- err:
+ case <-w.donec:
+ }
+ return
+ }
+ select {
+ case w.respc <- resp:
+ case <-w.donec:
+ return
+ }
+ }
+}
+
+// serveSubstream forwards watch responses from run() to the subscriber
+func (w *watchGrpcStream) serveSubstream(ws *watcherStream, resumec chan struct{}) {
+ if ws.closing {
+ panic("created substream goroutine but substream is closing")
+ }
+
+ // nextRev is the minimum expected next revision
+ nextRev := ws.initReq.rev
+ resuming := false
+ defer func() {
+ if !resuming {
+ ws.closing = true
+ }
+ close(ws.donec)
+ if !resuming {
+ w.closingc <- ws
+ }
+ w.wg.Done()
+ }()
+
+ emptyWr := &WatchResponse{}
+ for {
+ curWr := emptyWr
+ outc := ws.outc
+
+ if len(ws.buf) > 0 {
+ curWr = ws.buf[0]
+ } else {
+ outc = nil
+ }
+ select {
+ case outc <- *curWr:
+ if ws.buf[0].Err() != nil {
+ return
+ }
+ ws.buf[0] = nil
+ ws.buf = ws.buf[1:]
+ case wr, ok := <-ws.recvc:
+ if !ok {
+ // shutdown from closeSubstream
+ return
+ }
+
+ if wr.Created {
+ if ws.initReq.retc != nil {
+ ws.initReq.retc <- ws.outc
+ // to prevent next write from taking the slot in buffered channel
+ // and posting duplicate create events
+ ws.initReq.retc = nil
+
+ // send first creation event only if requested
+ if ws.initReq.createdNotify {
+ ws.outc <- *wr
+ }
+ // once the watch channel is returned, a current revision
+ // watch must resume at the store revision. This is necessary
+ // for the following case to work as expected:
+ // wch := m1.Watch("a")
+ // m2.Put("a", "b")
+ // <-wch
+ // If the revision is only bound on the first observed event,
+ // if wch is disconnected before the Put is issued, then reconnects
+ // after it is committed, it'll miss the Put.
+ if ws.initReq.rev == 0 {
+ nextRev = wr.Header.Revision
+ }
+ }
+ } else {
+ // current progress of watch; <= store revision
+ nextRev = wr.Header.Revision
+ }
+
+ if len(wr.Events) > 0 {
+ nextRev = wr.Events[len(wr.Events)-1].Kv.ModRevision + 1
+ }
+ ws.initReq.rev = nextRev
+
+ // created event is already sent above,
+ // watcher should not post duplicate events
+ if wr.Created {
+ continue
+ }
+
+ // TODO pause channel if buffer gets too large
+ ws.buf = append(ws.buf, wr)
+ case <-w.ctx.Done():
+ return
+ case <-ws.initReq.ctx.Done():
+ return
+ case <-resumec:
+ resuming = true
+ return
+ }
+ }
+ // lazily send cancel message if events on missing id
+}
+
+func (w *watchGrpcStream) newWatchClient() (pb.Watch_WatchClient, error) {
+ // mark all substreams as resuming
+ close(w.resumec)
+ w.resumec = make(chan struct{})
+ w.joinSubstreams()
+ for _, ws := range w.substreams {
+ ws.id = -1
+ w.resuming = append(w.resuming, ws)
+ }
+ // strip out nils, if any
+ var resuming []*watcherStream
+ for _, ws := range w.resuming {
+ if ws != nil {
+ resuming = append(resuming, ws)
+ }
+ }
+ w.resuming = resuming
+ w.substreams = make(map[int64]*watcherStream)
+
+ // connect to grpc stream while accepting watcher cancelation
+ stopc := make(chan struct{})
+ donec := w.waitCancelSubstreams(stopc)
+ wc, err := w.openWatchClient()
+ close(stopc)
+ <-donec
+
+ // serve all non-closing streams, even if there's a client error
+ // so that the teardown path can shutdown the streams as expected.
+ for _, ws := range w.resuming {
+ if ws.closing {
+ continue
+ }
+ ws.donec = make(chan struct{})
+ w.wg.Add(1)
+ go w.serveSubstream(ws, w.resumec)
+ }
+
+ if err != nil {
+ return nil, v3rpc.Error(err)
+ }
+
+ // receive data from new grpc stream
+ go w.serveWatchClient(wc)
+ return wc, nil
+}
+
+func (w *watchGrpcStream) waitCancelSubstreams(stopc <-chan struct{}) <-chan struct{} {
+ var wg sync.WaitGroup
+ wg.Add(len(w.resuming))
+ donec := make(chan struct{})
+ for i := range w.resuming {
+ go func(ws *watcherStream) {
+ defer wg.Done()
+ if ws.closing {
+ if ws.initReq.ctx.Err() != nil && ws.outc != nil {
+ close(ws.outc)
+ ws.outc = nil
+ }
+ return
+ }
+ select {
+ case <-ws.initReq.ctx.Done():
+ // closed ws will be removed from resuming
+ ws.closing = true
+ close(ws.outc)
+ ws.outc = nil
+ w.wg.Add(1)
+ go func() {
+ defer w.wg.Done()
+ w.closingc <- ws
+ }()
+ case <-stopc:
+ }
+ }(w.resuming[i])
+ }
+ go func() {
+ defer close(donec)
+ wg.Wait()
+ }()
+ return donec
+}
+
+// joinSubstream waits for all substream goroutines to complete
+func (w *watchGrpcStream) joinSubstreams() {
+ for _, ws := range w.substreams {
+ <-ws.donec
+ }
+ for _, ws := range w.resuming {
+ if ws != nil {
+ <-ws.donec
+ }
+ }
+}
+
+// openWatchClient retries opening a watchclient until retryConnection fails
+func (w *watchGrpcStream) openWatchClient() (ws pb.Watch_WatchClient, err error) {
+ for {
+ select {
+ case <-w.ctx.Done():
+ if err == nil {
+ return nil, w.ctx.Err()
+ }
+ return nil, err
+ default:
+ }
+ if ws, err = w.remote.Watch(w.ctx, grpc.FailFast(false)); ws != nil && err == nil {
+ break
+ }
+ if isHaltErr(w.ctx, err) {
+ return nil, v3rpc.Error(err)
+ }
+ }
+ return ws, nil
+}
+
+// toPB converts an internal watch request structure to its protobuf messagefunc (wr *watchRequest)
+func (wr *watchRequest) toPB() *pb.WatchRequest {
+ req := &pb.WatchCreateRequest{
+ StartRevision: wr.rev,
+ Key: []byte(wr.key),
+ RangeEnd: []byte(wr.end),
+ ProgressNotify: wr.progressNotify,
+ Filters: wr.filters,
+ PrevKv: wr.prevKV,
+ }
+ cr := &pb.WatchRequest_CreateRequest{CreateRequest: req}
+ return &pb.WatchRequest{RequestUnion: cr}
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/watch_test.go b/vendor/github.com/coreos/etcd/clientv3/watch_test.go
new file mode 100644
index 00000000..8d338052
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/watch_test.go
@@ -0,0 +1,55 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 clientv3
+
+import (
+ "testing"
+
+ "github.com/coreos/etcd/mvcc/mvccpb"
+)
+
+func TestEvent(t *testing.T) {
+ tests := []struct {
+ ev *Event
+ isCreate bool
+ isModify bool
+ }{{
+ ev: &Event{
+ Type: EventTypePut,
+ Kv: &mvccpb.KeyValue{
+ CreateRevision: 3,
+ ModRevision: 3,
+ },
+ },
+ isCreate: true,
+ }, {
+ ev: &Event{
+ Type: EventTypePut,
+ Kv: &mvccpb.KeyValue{
+ CreateRevision: 3,
+ ModRevision: 4,
+ },
+ },
+ isModify: true,
+ }}
+ for i, tt := range tests {
+ if tt.isCreate && !tt.ev.IsCreate() {
+ t.Errorf("#%d: event should be Create event", i)
+ }
+ if tt.isModify && !tt.ev.IsModify() {
+ t.Errorf("#%d: event should be Modify event", i)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/yaml/config.go b/vendor/github.com/coreos/etcd/clientv3/yaml/config.go
new file mode 100644
index 00000000..aa6df1c1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/yaml/config.go
@@ -0,0 +1,87 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 yaml handles yaml-formatted clientv3 configuration data.
+package yaml
+
+import (
+ "crypto/tls"
+ "crypto/x509"
+ "io/ioutil"
+
+ "github.com/ghodss/yaml"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/pkg/tlsutil"
+)
+
+type yamlConfig struct {
+ clientv3.Config
+
+ InsecureTransport bool `json:"insecure-transport"`
+ InsecureSkipTLSVerify bool `json:"insecure-skip-tls-verify"`
+ Certfile string `json:"cert-file"`
+ Keyfile string `json:"key-file"`
+ CAfile string `json:"ca-file"`
+}
+
+// NewConfig creates a new clientv3.Config from a yaml file.
+func NewConfig(fpath string) (*clientv3.Config, error) {
+ b, err := ioutil.ReadFile(fpath)
+ if err != nil {
+ return nil, err
+ }
+
+ yc := &yamlConfig{}
+
+ err = yaml.Unmarshal(b, yc)
+ if err != nil {
+ return nil, err
+ }
+
+ if yc.InsecureTransport {
+ return &yc.Config, nil
+ }
+
+ var (
+ cert *tls.Certificate
+ cp *x509.CertPool
+ )
+
+ if yc.Certfile != "" && yc.Keyfile != "" {
+ cert, err = tlsutil.NewCert(yc.Certfile, yc.Keyfile, nil)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ if yc.CAfile != "" {
+ cp, err = tlsutil.NewCertPool([]string{yc.CAfile})
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ tlscfg := &tls.Config{
+ MinVersion: tls.VersionTLS12,
+ InsecureSkipVerify: yc.InsecureSkipTLSVerify,
+ RootCAs: cp,
+ }
+ if cert != nil {
+ tlscfg.Certificates = []tls.Certificate{*cert}
+ }
+ yc.Config.TLS = tlscfg
+
+ return &yc.Config, nil
+}
diff --git a/vendor/github.com/coreos/etcd/clientv3/yaml/config_test.go b/vendor/github.com/coreos/etcd/clientv3/yaml/config_test.go
new file mode 100644
index 00000000..3dc221fd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/clientv3/yaml/config_test.go
@@ -0,0 +1,126 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 yaml
+
+import (
+ "io/ioutil"
+ "log"
+ "os"
+ "reflect"
+ "testing"
+
+ "github.com/ghodss/yaml"
+)
+
+var (
+ certPath = "../../integration/fixtures/server.crt"
+ privateKeyPath = "../../integration/fixtures/server.key.insecure"
+ caPath = "../../integration/fixtures/ca.crt"
+)
+
+func TestConfigFromFile(t *testing.T) {
+ tests := []struct {
+ ym *yamlConfig
+
+ werr bool
+ }{
+ {
+ &yamlConfig{},
+ false,
+ },
+ {
+ &yamlConfig{
+ InsecureTransport: true,
+ },
+ false,
+ },
+ {
+ &yamlConfig{
+ Keyfile: privateKeyPath,
+ Certfile: certPath,
+ CAfile: caPath,
+ InsecureSkipTLSVerify: true,
+ },
+ false,
+ },
+ {
+ &yamlConfig{
+ Keyfile: "bad",
+ Certfile: "bad",
+ },
+ true,
+ },
+ {
+ &yamlConfig{
+ Keyfile: privateKeyPath,
+ Certfile: certPath,
+ CAfile: "bad",
+ },
+ true,
+ },
+ }
+
+ for i, tt := range tests {
+ tmpfile, err := ioutil.TempFile("", "clientcfg")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ b, err := yaml.Marshal(tt.ym)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ _, err = tmpfile.Write(b)
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = tmpfile.Close()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ cfg, cerr := NewConfig(tmpfile.Name())
+ if cerr != nil && !tt.werr {
+ t.Errorf("#%d: err = %v, want %v", i, cerr, tt.werr)
+ continue
+ }
+ if cerr != nil {
+ continue
+ }
+
+ if !reflect.DeepEqual(cfg.Endpoints, tt.ym.Endpoints) {
+ t.Errorf("#%d: endpoint = %v, want %v", i, cfg.Endpoints, tt.ym.Endpoints)
+ }
+
+ if tt.ym.InsecureTransport != (cfg.TLS == nil) {
+ t.Errorf("#%d: insecureTransport = %v, want %v", i, cfg.TLS == nil, tt.ym.InsecureTransport)
+ }
+
+ if !tt.ym.InsecureTransport {
+ if tt.ym.Certfile != "" && len(cfg.TLS.Certificates) == 0 {
+ t.Errorf("#%d: failed to load in cert", i)
+ }
+ if tt.ym.CAfile != "" && cfg.TLS.RootCAs == nil {
+ t.Errorf("#%d: failed to load in ca cert", i)
+ }
+ if cfg.TLS.InsecureSkipVerify != tt.ym.InsecureSkipTLSVerify {
+ t.Errorf("#%d: skipTLSVeify = %v, want %v", i, cfg.TLS.InsecureSkipVerify, tt.ym.InsecureSkipTLSVerify)
+ }
+ }
+
+ os.Remove(tmpfile.Name())
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/cmd/README.md b/vendor/github.com/coreos/etcd/cmd/README.md
new file mode 100644
index 00000000..c45dabc1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/cmd/README.md
@@ -0,0 +1,4 @@
+## cmd
+
+This directory is meant to enforce vendoring for etcd binaries without polluting
+the etcd client libraries with vendored dependencies.
diff --git a/vendor/github.com/coreos/etcd/cmd/etcd b/vendor/github.com/coreos/etcd/cmd/etcd
new file mode 120000
index 00000000..b870225a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/cmd/etcd
@@ -0,0 +1 @@
+../
\ No newline at end of file
diff --git a/vendor/github.com/coreos/etcd/cmd/etcdctl b/vendor/github.com/coreos/etcd/cmd/etcdctl
new file mode 120000
index 00000000..05bb269d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/cmd/etcdctl
@@ -0,0 +1 @@
+../etcdctl
\ No newline at end of file
diff --git a/vendor/github.com/coreos/etcd/cmd/tools b/vendor/github.com/coreos/etcd/cmd/tools
new file mode 120000
index 00000000..4887d6e0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/cmd/tools
@@ -0,0 +1 @@
+../tools
\ No newline at end of file
diff --git a/vendor/github.com/coreos/etcd/compactor/compactor.go b/vendor/github.com/coreos/etcd/compactor/compactor.go
new file mode 100644
index 00000000..27028707
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/compactor/compactor.go
@@ -0,0 +1,137 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 compactor
+
+import (
+ "sync"
+ "time"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/mvcc"
+ "github.com/coreos/pkg/capnslog"
+ "github.com/jonboulle/clockwork"
+ "golang.org/x/net/context"
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "compactor")
+)
+
+const (
+ checkCompactionInterval = 5 * time.Minute
+ executeCompactionInterval = time.Hour
+)
+
+type Compactable interface {
+ Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error)
+}
+
+type RevGetter interface {
+ Rev() int64
+}
+
+// Periodic compacts the log by purging revisions older than
+// the configured retention time. Compaction happens hourly.
+type Periodic struct {
+ clock clockwork.Clock
+ periodInHour int
+
+ rg RevGetter
+ c Compactable
+
+ revs []int64
+ ctx context.Context
+ cancel context.CancelFunc
+
+ mu sync.Mutex
+ paused bool
+}
+
+func NewPeriodic(h int, rg RevGetter, c Compactable) *Periodic {
+ return &Periodic{
+ clock: clockwork.NewRealClock(),
+ periodInHour: h,
+ rg: rg,
+ c: c,
+ }
+}
+
+func (t *Periodic) Run() {
+ t.ctx, t.cancel = context.WithCancel(context.Background())
+ t.revs = make([]int64, 0)
+ clock := t.clock
+
+ go func() {
+ last := clock.Now()
+ for {
+ t.revs = append(t.revs, t.rg.Rev())
+ select {
+ case <-t.ctx.Done():
+ return
+ case <-clock.After(checkCompactionInterval):
+ t.mu.Lock()
+ p := t.paused
+ t.mu.Unlock()
+ if p {
+ continue
+ }
+ }
+
+ if clock.Now().Sub(last) < executeCompactionInterval {
+ continue
+ }
+
+ rev, remaining := t.getRev(t.periodInHour)
+ if rev < 0 {
+ continue
+ }
+
+ plog.Noticef("Starting auto-compaction at revision %d", rev)
+ _, err := t.c.Compact(t.ctx, &pb.CompactionRequest{Revision: rev})
+ if err == nil || err == mvcc.ErrCompacted {
+ t.revs = remaining
+ last = clock.Now()
+ plog.Noticef("Finished auto-compaction at revision %d", rev)
+ } else {
+ plog.Noticef("Failed auto-compaction at revision %d (%v)", err, rev)
+ plog.Noticef("Retry after %v", checkCompactionInterval)
+ }
+ }
+ }()
+}
+
+func (t *Periodic) Stop() {
+ t.cancel()
+}
+
+func (t *Periodic) Pause() {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ t.paused = true
+}
+
+func (t *Periodic) Resume() {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ t.paused = false
+}
+
+func (t *Periodic) getRev(h int) (int64, []int64) {
+ i := len(t.revs) - int(time.Duration(h)*time.Hour/checkCompactionInterval)
+ if i < 0 {
+ return -1, t.revs
+ }
+ return t.revs[i], t.revs[i+1:]
+}
diff --git a/vendor/github.com/coreos/etcd/compactor/compactor_test.go b/vendor/github.com/coreos/etcd/compactor/compactor_test.go
new file mode 100644
index 00000000..ccc3a809
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/compactor/compactor_test.go
@@ -0,0 +1,138 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 compactor
+
+import (
+ "reflect"
+ "testing"
+ "time"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/jonboulle/clockwork"
+ "golang.org/x/net/context"
+)
+
+func TestPeriodic(t *testing.T) {
+ retentionHours := 2
+
+ fc := clockwork.NewFakeClock()
+ rg := &fakeRevGetter{testutil.NewRecorderStream(), 0}
+ compactable := &fakeCompactable{testutil.NewRecorderStream()}
+ tb := &Periodic{
+ clock: fc,
+ periodInHour: retentionHours,
+ rg: rg,
+ c: compactable,
+ }
+
+ tb.Run()
+ defer tb.Stop()
+
+ n := int(time.Hour / checkCompactionInterval)
+ // collect 5 hours of revisions
+ for i := 0; i < 5; i++ {
+ // advance one hour, one revision for each interval
+ for j := 0; j < n; j++ {
+ rg.Wait(1)
+ fc.Advance(checkCompactionInterval)
+ }
+
+ // compaction doesn't happen til 2 hours elapses
+ if i+1 < retentionHours {
+ continue
+ }
+
+ a, err := compactable.Wait(1)
+ if err != nil {
+ t.Fatal(err)
+ }
+ expectedRevision := int64(1 + (i+1)*n - retentionHours*n)
+ if !reflect.DeepEqual(a[0].Params[0], &pb.CompactionRequest{Revision: expectedRevision}) {
+ t.Errorf("compact request = %v, want %v", a[0].Params[0], &pb.CompactionRequest{Revision: expectedRevision})
+ }
+ }
+
+ // unblock the rev getter, so we can stop the compactor routine.
+ _, err := rg.Wait(1)
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestPeriodicPause(t *testing.T) {
+ fc := clockwork.NewFakeClock()
+ compactable := &fakeCompactable{testutil.NewRecorderStream()}
+ rg := &fakeRevGetter{testutil.NewRecorderStream(), 0}
+ tb := &Periodic{
+ clock: fc,
+ periodInHour: 1,
+ rg: rg,
+ c: compactable,
+ }
+
+ tb.Run()
+ tb.Pause()
+
+ // tb will collect 3 hours of revisions but not compact since paused
+ n := int(time.Hour / checkCompactionInterval)
+ for i := 0; i < 3*n; i++ {
+ rg.Wait(1)
+ fc.Advance(checkCompactionInterval)
+ }
+ // tb ends up waiting for the clock
+
+ select {
+ case a := <-compactable.Chan():
+ t.Fatalf("unexpected action %v", a)
+ case <-time.After(10 * time.Millisecond):
+ }
+
+ // tb resumes to being blocked on the clock
+ tb.Resume()
+
+ // unblock clock, will kick off a compaction at hour 3:05
+ rg.Wait(1)
+ fc.Advance(checkCompactionInterval)
+ a, err := compactable.Wait(1)
+ if err != nil {
+ t.Fatal(err)
+ }
+ // compact the revision from hour 2:05
+ wreq := &pb.CompactionRequest{Revision: int64(1 + 2*n + 1)}
+ if !reflect.DeepEqual(a[0].Params[0], wreq) {
+ t.Errorf("compact request = %v, want %v", a[0].Params[0], wreq.Revision)
+ }
+}
+
+type fakeCompactable struct {
+ testutil.Recorder
+}
+
+func (fc *fakeCompactable) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) {
+ fc.Record(testutil.Action{Name: "c", Params: []interface{}{r}})
+ return &pb.CompactionResponse{}, nil
+}
+
+type fakeRevGetter struct {
+ testutil.Recorder
+ rev int64
+}
+
+func (fr *fakeRevGetter) Rev() int64 {
+ fr.Record(testutil.Action{Name: "g"})
+ fr.rev++
+ return fr.rev
+}
diff --git a/vendor/github.com/coreos/etcd/compactor/doc.go b/vendor/github.com/coreos/etcd/compactor/doc.go
new file mode 100644
index 00000000..cb158340
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/compactor/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 compactor implements automated policies for compacting etcd's mvcc storage.
+package compactor
diff --git a/vendor/github.com/coreos/etcd/contrib/README.md b/vendor/github.com/coreos/etcd/contrib/README.md
new file mode 100644
index 00000000..b8cf4660
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/README.md
@@ -0,0 +1,8 @@
+## Contrib
+
+Scripts and files which may be useful but aren't part of the core etcd project.
+
+* [systemd](systemd) - an example unit file for deploying etcd on systemd-based distributions
+* [raftexample](raftexample) - an example distributed key-value store using raft
+* [systemd/etcd2-backup-coreos](systemd/etcd2-backup-coreos) - remote backup and restore procedures for etcd2 clusters on CoreOS Linux
+* [systemd/etcd3-multinode](systemd/etcd3-multinode) - multi-node cluster setup with systemd
diff --git a/vendor/github.com/coreos/etcd/contrib/raftexample/Procfile b/vendor/github.com/coreos/etcd/contrib/raftexample/Procfile
new file mode 100644
index 00000000..6b2f7ccf
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/raftexample/Procfile
@@ -0,0 +1,4 @@
+# Use goreman to run `go get github.com/mattn/goreman`
+raftexample1: ./raftexample --id 1 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 12380
+raftexample2: ./raftexample --id 2 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 22380
+raftexample3: ./raftexample --id 3 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 32380
diff --git a/vendor/github.com/coreos/etcd/contrib/raftexample/README.md b/vendor/github.com/coreos/etcd/contrib/raftexample/README.md
new file mode 100644
index 00000000..312adeb9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/raftexample/README.md
@@ -0,0 +1,115 @@
+# raftexample
+
+raftexample is an example usage of etcd's [raft library](../../raft). It provides a simple REST API for a key-value store cluster backed by the [Raft][raft] consensus algorithm.
+
+[raft]: http://raftconsensus.github.io/
+
+## Getting Started
+
+### Running single node raftexample
+
+First start a single-member cluster of raftexample:
+
+```sh
+raftexample --id 1 --cluster http://127.0.0.1:12379 --port 12380
+```
+
+Each raftexample process maintains a single raft instance and a key-value server.
+The process's list of comma separated peers (--cluster), its raft ID index into the peer list (--id), and http key-value server port (--port) are passed through the command line.
+
+Next, store a value ("hello") to a key ("my-key"):
+
+```
+curl -L http://127.0.0.1:12380/my-key -XPUT -d hello
+```
+
+Finally, retrieve the stored key:
+
+```
+curl -L http://127.0.0.1:12380/my-key
+```
+
+### Running a local cluster
+
+First install [goreman](https://github.com/mattn/goreman), which manages Procfile-based applications.
+
+The [Procfile script](./Procfile) will set up a local example cluster. Start it with:
+
+```sh
+goreman start
+```
+
+This will bring up three raftexample instances.
+
+Now it's possible to write a key-value pair to any member of the cluster and likewise retrieve it from any member.
+
+### Fault Tolerance
+
+To test cluster recovery, first start a cluster and write a value "foo":
+```sh
+goreman start
+curl -L http://127.0.0.1:12380/my-key -XPUT -d foo
+```
+
+Next, remove a node and replace the value with "bar" to check cluster availability:
+
+```sh
+goreman run stop raftexample2
+curl -L http://127.0.0.1:12380/my-key -XPUT -d bar
+curl -L http://127.0.0.1:32380/my-key
+```
+
+Finally, bring the node back up and verify it recovers with the updated value "bar":
+```sh
+goreman run start raftexample2
+curl -L http://127.0.0.1:22380/my-key
+```
+
+### Dynamic cluster reconfiguration
+
+Nodes can be added to or removed from a running cluster using requests to the REST API.
+
+For example, suppose we have a 3-node cluster that was started with the commands:
+```sh
+raftexample --id 1 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 12380
+raftexample --id 2 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 22380
+raftexample --id 3 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 32380
+```
+
+A fourth node with ID 4 can be added by issuing a POST:
+```sh
+curl -L http://127.0.0.1:12380/4 -XPOST -d http://127.0.0.1:42379
+```
+
+Then the new node can be started as the others were, using the --join option:
+```sh
+raftexample --id 4 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379,http://127.0.0.1:42379 --port 42380 --join
+```
+
+The new node should join the cluster and be able to service key/value requests.
+
+We can remove a node using a DELETE request:
+```sh
+curl -L http://127.0.0.1:12380/3 -XDELETE
+```
+
+Node 3 should shut itself down once the cluster has processed this request.
+
+## Design
+
+The raftexample consists of three components: a raft-backed key-value store, a REST API server, and a raft consensus server based on etcd's raft implementation.
+
+The raft-backed key-value store is a key-value map that holds all committed key-values.
+The store bridges communication between the raft server and the REST server.
+Key-value updates are issued through the store to the raft server.
+The store updates its map once raft reports the updates are committed.
+
+The REST server exposes the current raft consensus by accessing the raft-backed key-value store.
+A GET command looks up a key in the store and returns the value, if any.
+A key-value PUT command issues an update proposal to the store.
+
+The raft server participates in consensus with its cluster peers.
+When the REST server submits a proposal, the raft server transmits the proposal to its peers.
+When raft reaches a consensus, the server publishes all committed updates over a commit channel.
+For raftexample, this commit channel is consumed by the key-value store.
+
diff --git a/vendor/github.com/coreos/etcd/contrib/raftexample/doc.go b/vendor/github.com/coreos/etcd/contrib/raftexample/doc.go
new file mode 100644
index 00000000..b2dc8416
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/raftexample/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// raftexample is a simple KV store using the raft and rafthttp libraries.
+package main
diff --git a/vendor/github.com/coreos/etcd/contrib/raftexample/httpapi.go b/vendor/github.com/coreos/etcd/contrib/raftexample/httpapi.go
new file mode 100644
index 00000000..10d3a5d9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/raftexample/httpapi.go
@@ -0,0 +1,122 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "io/ioutil"
+ "log"
+ "net/http"
+ "strconv"
+
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+// Handler for a http based key-value store backed by raft
+type httpKVAPI struct {
+ store *kvstore
+ confChangeC chan<- raftpb.ConfChange
+}
+
+func (h *httpKVAPI) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ key := r.RequestURI
+ switch {
+ case r.Method == "PUT":
+ v, err := ioutil.ReadAll(r.Body)
+ if err != nil {
+ log.Printf("Failed to read on PUT (%v)\n", err)
+ http.Error(w, "Failed on PUT", http.StatusBadRequest)
+ return
+ }
+
+ h.store.Propose(key, string(v))
+
+ // Optimistic-- no waiting for ack from raft. Value is not yet
+ // committed so a subsequent GET on the key may return old value
+ w.WriteHeader(http.StatusNoContent)
+ case r.Method == "GET":
+ if v, ok := h.store.Lookup(key); ok {
+ w.Write([]byte(v))
+ } else {
+ http.Error(w, "Failed to GET", http.StatusNotFound)
+ }
+ case r.Method == "POST":
+ url, err := ioutil.ReadAll(r.Body)
+ if err != nil {
+ log.Printf("Failed to read on POST (%v)\n", err)
+ http.Error(w, "Failed on POST", http.StatusBadRequest)
+ return
+ }
+
+ nodeId, err := strconv.ParseUint(key[1:], 0, 64)
+ if err != nil {
+ log.Printf("Failed to convert ID for conf change (%v)\n", err)
+ http.Error(w, "Failed on POST", http.StatusBadRequest)
+ return
+ }
+
+ cc := raftpb.ConfChange{
+ Type: raftpb.ConfChangeAddNode,
+ NodeID: nodeId,
+ Context: url,
+ }
+ h.confChangeC <- cc
+
+ // As above, optimistic that raft will apply the conf change
+ w.WriteHeader(http.StatusNoContent)
+ case r.Method == "DELETE":
+ nodeId, err := strconv.ParseUint(key[1:], 0, 64)
+ if err != nil {
+ log.Printf("Failed to convert ID for conf change (%v)\n", err)
+ http.Error(w, "Failed on DELETE", http.StatusBadRequest)
+ return
+ }
+
+ cc := raftpb.ConfChange{
+ Type: raftpb.ConfChangeRemoveNode,
+ NodeID: nodeId,
+ }
+ h.confChangeC <- cc
+
+ // As above, optimistic that raft will apply the conf change
+ w.WriteHeader(http.StatusNoContent)
+ default:
+ w.Header().Set("Allow", "PUT")
+ w.Header().Add("Allow", "GET")
+ w.Header().Add("Allow", "POST")
+ w.Header().Add("Allow", "DELETE")
+ http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
+ }
+}
+
+// serveHttpKVAPI starts a key-value server with a GET/PUT API and listens.
+func serveHttpKVAPI(kv *kvstore, port int, confChangeC chan<- raftpb.ConfChange, errorC <-chan error) {
+ srv := http.Server{
+ Addr: ":" + strconv.Itoa(port),
+ Handler: &httpKVAPI{
+ store: kv,
+ confChangeC: confChangeC,
+ },
+ }
+ go func() {
+ if err := srv.ListenAndServe(); err != nil {
+ log.Fatal(err)
+ }
+ }()
+
+ // exit when raft goes down
+ if err, ok := <-errorC; ok {
+ log.Fatal(err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/contrib/raftexample/kvstore.go b/vendor/github.com/coreos/etcd/contrib/raftexample/kvstore.go
new file mode 100644
index 00000000..d877bc7a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/raftexample/kvstore.go
@@ -0,0 +1,112 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "bytes"
+ "encoding/gob"
+ "encoding/json"
+ "log"
+ "sync"
+
+ "github.com/coreos/etcd/snap"
+)
+
+// a key-value store backed by raft
+type kvstore struct {
+ proposeC chan<- string // channel for proposing updates
+ mu sync.RWMutex
+ kvStore map[string]string // current committed key-value pairs
+ snapshotter *snap.Snapshotter
+}
+
+type kv struct {
+ Key string
+ Val string
+}
+
+func newKVStore(snapshotter *snap.Snapshotter, proposeC chan<- string, commitC <-chan *string, errorC <-chan error) *kvstore {
+ s := &kvstore{proposeC: proposeC, kvStore: make(map[string]string), snapshotter: snapshotter}
+ // replay log into key-value map
+ s.readCommits(commitC, errorC)
+ // read commits from raft into kvStore map until error
+ go s.readCommits(commitC, errorC)
+ return s
+}
+
+func (s *kvstore) Lookup(key string) (string, bool) {
+ s.mu.RLock()
+ v, ok := s.kvStore[key]
+ s.mu.RUnlock()
+ return v, ok
+}
+
+func (s *kvstore) Propose(k string, v string) {
+ var buf bytes.Buffer
+ if err := gob.NewEncoder(&buf).Encode(kv{k, v}); err != nil {
+ log.Fatal(err)
+ }
+ s.proposeC <- buf.String()
+}
+
+func (s *kvstore) readCommits(commitC <-chan *string, errorC <-chan error) {
+ for data := range commitC {
+ if data == nil {
+ // done replaying log; new data incoming
+ // OR signaled to load snapshot
+ snapshot, err := s.snapshotter.Load()
+ if err == snap.ErrNoSnapshot {
+ return
+ }
+ if err != nil && err != snap.ErrNoSnapshot {
+ log.Panic(err)
+ }
+ log.Printf("loading snapshot at term %d and index %d", snapshot.Metadata.Term, snapshot.Metadata.Index)
+ if err := s.recoverFromSnapshot(snapshot.Data); err != nil {
+ log.Panic(err)
+ }
+ continue
+ }
+
+ var dataKv kv
+ dec := gob.NewDecoder(bytes.NewBufferString(*data))
+ if err := dec.Decode(&dataKv); err != nil {
+ log.Fatalf("raftexample: could not decode message (%v)", err)
+ }
+ s.mu.Lock()
+ s.kvStore[dataKv.Key] = dataKv.Val
+ s.mu.Unlock()
+ }
+ if err, ok := <-errorC; ok {
+ log.Fatal(err)
+ }
+}
+
+func (s *kvstore) getSnapshot() ([]byte, error) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ return json.Marshal(s.kvStore)
+}
+
+func (s *kvstore) recoverFromSnapshot(snapshot []byte) error {
+ var store map[string]string
+ if err := json.Unmarshal(snapshot, &store); err != nil {
+ return err
+ }
+ s.mu.Lock()
+ s.kvStore = store
+ s.mu.Unlock()
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/contrib/raftexample/kvstore_test.go b/vendor/github.com/coreos/etcd/contrib/raftexample/kvstore_test.go
new file mode 100644
index 00000000..231f778f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/raftexample/kvstore_test.go
@@ -0,0 +1,47 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 (
+ "reflect"
+ "testing"
+)
+
+func Test_kvstore_snapshot(t *testing.T) {
+ tm := map[string]string{"foo": "bar"}
+ s := &kvstore{kvStore: tm}
+
+ v, _ := s.Lookup("foo")
+ if v != "bar" {
+ t.Fatalf("foo has unexpected value, got %s", v)
+ }
+
+ data, err := s.getSnapshot()
+ if err != nil {
+ t.Fatal(err)
+ }
+ s.kvStore = nil
+
+ if err := s.recoverFromSnapshot(data); err != nil {
+ t.Fatal(err)
+ }
+ v, _ = s.Lookup("foo")
+ if v != "bar" {
+ t.Fatalf("foo has unexpected value, got %s", v)
+ }
+ if !reflect.DeepEqual(s.kvStore, tm) {
+ t.Fatalf("store expected %+v, got %+v", tm, s.kvStore)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/contrib/raftexample/listener.go b/vendor/github.com/coreos/etcd/contrib/raftexample/listener.go
new file mode 100644
index 00000000..d67e16f5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/raftexample/listener.go
@@ -0,0 +1,59 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "errors"
+ "net"
+ "time"
+)
+
+// stoppableListener sets TCP keep-alive timeouts on accepted
+// connections and waits on stopc message
+type stoppableListener struct {
+ *net.TCPListener
+ stopc <-chan struct{}
+}
+
+func newStoppableListener(addr string, stopc <-chan struct{}) (*stoppableListener, error) {
+ ln, err := net.Listen("tcp", addr)
+ if err != nil {
+ return nil, err
+ }
+ return &stoppableListener{ln.(*net.TCPListener), stopc}, nil
+}
+
+func (ln stoppableListener) Accept() (c net.Conn, err error) {
+ connc := make(chan *net.TCPConn, 1)
+ errc := make(chan error, 1)
+ go func() {
+ tc, err := ln.AcceptTCP()
+ if err != nil {
+ errc <- err
+ return
+ }
+ connc <- tc
+ }()
+ select {
+ case <-ln.stopc:
+ return nil, errors.New("server stopped")
+ case err := <-errc:
+ return nil, err
+ case tc := <-connc:
+ tc.SetKeepAlive(true)
+ tc.SetKeepAlivePeriod(3 * time.Minute)
+ return tc, nil
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/contrib/raftexample/main.go b/vendor/github.com/coreos/etcd/contrib/raftexample/main.go
new file mode 100644
index 00000000..58269246
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/raftexample/main.go
@@ -0,0 +1,45 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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"
+ "strings"
+
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+func main() {
+ cluster := flag.String("cluster", "http://127.0.0.1:9021", "comma separated cluster peers")
+ id := flag.Int("id", 1, "node ID")
+ kvport := flag.Int("port", 9121, "key-value server port")
+ join := flag.Bool("join", false, "join an existing cluster")
+ flag.Parse()
+
+ proposeC := make(chan string)
+ defer close(proposeC)
+ confChangeC := make(chan raftpb.ConfChange)
+ defer close(confChangeC)
+
+ // raft provides a commit stream for the proposals from the http api
+ var kvs *kvstore
+ getSnapshot := func() ([]byte, error) { return kvs.getSnapshot() }
+ commitC, errorC, snapshotterReady := newRaftNode(*id, strings.Split(*cluster, ","), *join, getSnapshot, proposeC, confChangeC)
+
+ kvs = newKVStore(<-snapshotterReady, proposeC, commitC, errorC)
+
+ // the key-value http handler will propose updates to raft
+ serveHttpKVAPI(kvs, *kvport, confChangeC, errorC)
+}
diff --git a/vendor/github.com/coreos/etcd/contrib/raftexample/raft.go b/vendor/github.com/coreos/etcd/contrib/raftexample/raft.go
new file mode 100644
index 00000000..84c8ffda
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/raftexample/raft.go
@@ -0,0 +1,476 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "log"
+ "os"
+ "strconv"
+ "time"
+
+ "net/http"
+ "net/url"
+
+ "github.com/coreos/etcd/etcdserver/stats"
+ "github.com/coreos/etcd/pkg/fileutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/rafthttp"
+ "github.com/coreos/etcd/snap"
+ "github.com/coreos/etcd/wal"
+ "github.com/coreos/etcd/wal/walpb"
+ "golang.org/x/net/context"
+)
+
+// A key-value stream backed by raft
+type raftNode struct {
+ proposeC <-chan string // proposed messages (k,v)
+ confChangeC <-chan raftpb.ConfChange // proposed cluster config changes
+ commitC chan<- *string // entries committed to log (k,v)
+ errorC chan<- error // errors from raft session
+
+ id int // client ID for raft session
+ peers []string // raft peer URLs
+ join bool // node is joining an existing cluster
+ waldir string // path to WAL directory
+ snapdir string // path to snapshot directory
+ getSnapshot func() ([]byte, error)
+ lastIndex uint64 // index of log at start
+
+ confState raftpb.ConfState
+ snapshotIndex uint64
+ appliedIndex uint64
+
+ // raft backing for the commit/error channel
+ node raft.Node
+ raftStorage *raft.MemoryStorage
+ wal *wal.WAL
+
+ snapshotter *snap.Snapshotter
+ snapshotterReady chan *snap.Snapshotter // signals when snapshotter is ready
+
+ snapCount uint64
+ transport *rafthttp.Transport
+ stopc chan struct{} // signals proposal channel closed
+ httpstopc chan struct{} // signals http server to shutdown
+ httpdonec chan struct{} // signals http server shutdown complete
+}
+
+var defaultSnapCount uint64 = 10000
+
+// newRaftNode initiates a raft instance and returns a committed log entry
+// channel and error channel. Proposals for log updates are sent over the
+// provided the proposal channel. All log entries are replayed over the
+// commit channel, followed by a nil message (to indicate the channel is
+// current), then new log entries. To shutdown, close proposeC and read errorC.
+func newRaftNode(id int, peers []string, join bool, getSnapshot func() ([]byte, error), proposeC <-chan string,
+ confChangeC <-chan raftpb.ConfChange) (<-chan *string, <-chan error, <-chan *snap.Snapshotter) {
+
+ commitC := make(chan *string)
+ errorC := make(chan error)
+
+ rc := &raftNode{
+ proposeC: proposeC,
+ confChangeC: confChangeC,
+ commitC: commitC,
+ errorC: errorC,
+ id: id,
+ peers: peers,
+ join: join,
+ waldir: fmt.Sprintf("raftexample-%d", id),
+ snapdir: fmt.Sprintf("raftexample-%d-snap", id),
+ getSnapshot: getSnapshot,
+ snapCount: defaultSnapCount,
+ stopc: make(chan struct{}),
+ httpstopc: make(chan struct{}),
+ httpdonec: make(chan struct{}),
+
+ snapshotterReady: make(chan *snap.Snapshotter, 1),
+ // rest of structure populated after WAL replay
+ }
+ go rc.startRaft()
+ return commitC, errorC, rc.snapshotterReady
+}
+
+func (rc *raftNode) saveSnap(snap raftpb.Snapshot) error {
+ if err := rc.snapshotter.SaveSnap(snap); err != nil {
+ return err
+ }
+ walSnap := walpb.Snapshot{
+ Index: snap.Metadata.Index,
+ Term: snap.Metadata.Term,
+ }
+ if err := rc.wal.SaveSnapshot(walSnap); err != nil {
+ return err
+ }
+ return rc.wal.ReleaseLockTo(snap.Metadata.Index)
+}
+
+func (rc *raftNode) entriesToApply(ents []raftpb.Entry) (nents []raftpb.Entry) {
+ if len(ents) == 0 {
+ return
+ }
+ firstIdx := ents[0].Index
+ if firstIdx > rc.appliedIndex+1 {
+ log.Fatalf("first index of committed entry[%d] should <= progress.appliedIndex[%d] 1", firstIdx, rc.appliedIndex)
+ }
+ if rc.appliedIndex-firstIdx+1 < uint64(len(ents)) {
+ nents = ents[rc.appliedIndex-firstIdx+1:]
+ }
+ return
+}
+
+// publishEntries writes committed log entries to commit channel and returns
+// whether all entries could be published.
+func (rc *raftNode) publishEntries(ents []raftpb.Entry) bool {
+ for i := range ents {
+ switch ents[i].Type {
+ case raftpb.EntryNormal:
+ if len(ents[i].Data) == 0 {
+ // ignore empty messages
+ break
+ }
+ s := string(ents[i].Data)
+ select {
+ case rc.commitC <- &s:
+ case <-rc.stopc:
+ return false
+ }
+
+ case raftpb.EntryConfChange:
+ var cc raftpb.ConfChange
+ cc.Unmarshal(ents[i].Data)
+ rc.confState = *rc.node.ApplyConfChange(cc)
+ switch cc.Type {
+ case raftpb.ConfChangeAddNode:
+ if len(cc.Context) > 0 {
+ rc.transport.AddPeer(types.ID(cc.NodeID), []string{string(cc.Context)})
+ }
+ case raftpb.ConfChangeRemoveNode:
+ if cc.NodeID == uint64(rc.id) {
+ log.Println("I've been removed from the cluster! Shutting down.")
+ return false
+ }
+ rc.transport.RemovePeer(types.ID(cc.NodeID))
+ }
+ }
+
+ // after commit, update appliedIndex
+ rc.appliedIndex = ents[i].Index
+
+ // special nil commit to signal replay has finished
+ if ents[i].Index == rc.lastIndex {
+ select {
+ case rc.commitC <- nil:
+ case <-rc.stopc:
+ return false
+ }
+ }
+ }
+ return true
+}
+
+func (rc *raftNode) loadSnapshot() *raftpb.Snapshot {
+ snapshot, err := rc.snapshotter.Load()
+ if err != nil && err != snap.ErrNoSnapshot {
+ log.Fatalf("raftexample: error loading snapshot (%v)", err)
+ }
+ return snapshot
+}
+
+// openWAL returns a WAL ready for reading.
+func (rc *raftNode) openWAL(snapshot *raftpb.Snapshot) *wal.WAL {
+ if !wal.Exist(rc.waldir) {
+ if err := os.Mkdir(rc.waldir, 0750); err != nil {
+ log.Fatalf("raftexample: cannot create dir for wal (%v)", err)
+ }
+
+ w, err := wal.Create(rc.waldir, nil)
+ if err != nil {
+ log.Fatalf("raftexample: create wal error (%v)", err)
+ }
+ w.Close()
+ }
+
+ walsnap := walpb.Snapshot{}
+ if snapshot != nil {
+ walsnap.Index, walsnap.Term = snapshot.Metadata.Index, snapshot.Metadata.Term
+ }
+ log.Printf("loading WAL at term %d and index %d", walsnap.Term, walsnap.Index)
+ w, err := wal.Open(rc.waldir, walsnap)
+ if err != nil {
+ log.Fatalf("raftexample: error loading wal (%v)", err)
+ }
+
+ return w
+}
+
+// replayWAL replays WAL entries into the raft instance.
+func (rc *raftNode) replayWAL() *wal.WAL {
+ log.Printf("replaying WAL of member %d", rc.id)
+ snapshot := rc.loadSnapshot()
+ w := rc.openWAL(snapshot)
+ _, st, ents, err := w.ReadAll()
+ if err != nil {
+ log.Fatalf("raftexample: failed to read WAL (%v)", err)
+ }
+ rc.raftStorage = raft.NewMemoryStorage()
+ if snapshot != nil {
+ rc.raftStorage.ApplySnapshot(*snapshot)
+ }
+ rc.raftStorage.SetHardState(st)
+
+ // append to storage so raft starts at the right place in log
+ rc.raftStorage.Append(ents)
+ // send nil once lastIndex is published so client knows commit channel is current
+ if len(ents) > 0 {
+ rc.lastIndex = ents[len(ents)-1].Index
+ } else {
+ rc.commitC <- nil
+ }
+ return w
+}
+
+func (rc *raftNode) writeError(err error) {
+ rc.stopHTTP()
+ close(rc.commitC)
+ rc.errorC <- err
+ close(rc.errorC)
+ rc.node.Stop()
+}
+
+func (rc *raftNode) startRaft() {
+ if !fileutil.Exist(rc.snapdir) {
+ if err := os.Mkdir(rc.snapdir, 0750); err != nil {
+ log.Fatalf("raftexample: cannot create dir for snapshot (%v)", err)
+ }
+ }
+ rc.snapshotter = snap.New(rc.snapdir)
+ rc.snapshotterReady <- rc.snapshotter
+
+ oldwal := wal.Exist(rc.waldir)
+ rc.wal = rc.replayWAL()
+
+ rpeers := make([]raft.Peer, len(rc.peers))
+ for i := range rpeers {
+ rpeers[i] = raft.Peer{ID: uint64(i + 1)}
+ }
+ c := &raft.Config{
+ ID: uint64(rc.id),
+ ElectionTick: 10,
+ HeartbeatTick: 1,
+ Storage: rc.raftStorage,
+ MaxSizePerMsg: 1024 * 1024,
+ MaxInflightMsgs: 256,
+ }
+
+ if oldwal {
+ rc.node = raft.RestartNode(c)
+ } else {
+ startPeers := rpeers
+ if rc.join {
+ startPeers = nil
+ }
+ rc.node = raft.StartNode(c, startPeers)
+ }
+
+ rc.transport = &rafthttp.Transport{
+ ID: types.ID(rc.id),
+ ClusterID: 0x1000,
+ Raft: rc,
+ ServerStats: stats.NewServerStats("", ""),
+ LeaderStats: stats.NewLeaderStats(strconv.Itoa(rc.id)),
+ ErrorC: make(chan error),
+ }
+
+ rc.transport.Start()
+ for i := range rc.peers {
+ if i+1 != rc.id {
+ rc.transport.AddPeer(types.ID(i+1), []string{rc.peers[i]})
+ }
+ }
+
+ go rc.serveRaft()
+ go rc.serveChannels()
+}
+
+// stop closes http, closes all channels, and stops raft.
+func (rc *raftNode) stop() {
+ rc.stopHTTP()
+ close(rc.commitC)
+ close(rc.errorC)
+ rc.node.Stop()
+}
+
+func (rc *raftNode) stopHTTP() {
+ rc.transport.Stop()
+ close(rc.httpstopc)
+ <-rc.httpdonec
+}
+
+func (rc *raftNode) publishSnapshot(snapshotToSave raftpb.Snapshot) {
+ if raft.IsEmptySnap(snapshotToSave) {
+ return
+ }
+
+ log.Printf("publishing snapshot at index %d", rc.snapshotIndex)
+ defer log.Printf("finished publishing snapshot at index %d", rc.snapshotIndex)
+
+ if snapshotToSave.Metadata.Index <= rc.appliedIndex {
+ log.Fatalf("snapshot index [%d] should > progress.appliedIndex [%d] + 1", snapshotToSave.Metadata.Index, rc.appliedIndex)
+ }
+ rc.commitC <- nil // trigger kvstore to load snapshot
+
+ rc.confState = snapshotToSave.Metadata.ConfState
+ rc.snapshotIndex = snapshotToSave.Metadata.Index
+ rc.appliedIndex = snapshotToSave.Metadata.Index
+}
+
+var snapshotCatchUpEntriesN uint64 = 10000
+
+func (rc *raftNode) maybeTriggerSnapshot() {
+ if rc.appliedIndex-rc.snapshotIndex <= rc.snapCount {
+ return
+ }
+
+ log.Printf("start snapshot [applied index: %d | last snapshot index: %d]", rc.appliedIndex, rc.snapshotIndex)
+ data, err := rc.getSnapshot()
+ if err != nil {
+ log.Panic(err)
+ }
+ snap, err := rc.raftStorage.CreateSnapshot(rc.appliedIndex, &rc.confState, data)
+ if err != nil {
+ panic(err)
+ }
+ if err := rc.saveSnap(snap); err != nil {
+ panic(err)
+ }
+
+ compactIndex := uint64(1)
+ if rc.appliedIndex > snapshotCatchUpEntriesN {
+ compactIndex = rc.appliedIndex - snapshotCatchUpEntriesN
+ }
+ if err := rc.raftStorage.Compact(compactIndex); err != nil {
+ panic(err)
+ }
+
+ log.Printf("compacted log at index %d", compactIndex)
+ rc.snapshotIndex = rc.appliedIndex
+}
+
+func (rc *raftNode) serveChannels() {
+ snap, err := rc.raftStorage.Snapshot()
+ if err != nil {
+ panic(err)
+ }
+ rc.confState = snap.Metadata.ConfState
+ rc.snapshotIndex = snap.Metadata.Index
+ rc.appliedIndex = snap.Metadata.Index
+
+ defer rc.wal.Close()
+
+ ticker := time.NewTicker(100 * time.Millisecond)
+ defer ticker.Stop()
+
+ // send proposals over raft
+ go func() {
+ var confChangeCount uint64 = 0
+
+ for rc.proposeC != nil && rc.confChangeC != nil {
+ select {
+ case prop, ok := <-rc.proposeC:
+ if !ok {
+ rc.proposeC = nil
+ } else {
+ // blocks until accepted by raft state machine
+ rc.node.Propose(context.TODO(), []byte(prop))
+ }
+
+ case cc, ok := <-rc.confChangeC:
+ if !ok {
+ rc.confChangeC = nil
+ } else {
+ confChangeCount += 1
+ cc.ID = confChangeCount
+ rc.node.ProposeConfChange(context.TODO(), cc)
+ }
+ }
+ }
+ // client closed channel; shutdown raft if not already
+ close(rc.stopc)
+ }()
+
+ // event loop on raft state machine updates
+ for {
+ select {
+ case <-ticker.C:
+ rc.node.Tick()
+
+ // store raft entries to wal, then publish over commit channel
+ case rd := <-rc.node.Ready():
+ rc.wal.Save(rd.HardState, rd.Entries)
+ if !raft.IsEmptySnap(rd.Snapshot) {
+ rc.saveSnap(rd.Snapshot)
+ rc.raftStorage.ApplySnapshot(rd.Snapshot)
+ rc.publishSnapshot(rd.Snapshot)
+ }
+ rc.raftStorage.Append(rd.Entries)
+ rc.transport.Send(rd.Messages)
+ if ok := rc.publishEntries(rc.entriesToApply(rd.CommittedEntries)); !ok {
+ rc.stop()
+ return
+ }
+ rc.maybeTriggerSnapshot()
+ rc.node.Advance()
+
+ case err := <-rc.transport.ErrorC:
+ rc.writeError(err)
+ return
+
+ case <-rc.stopc:
+ rc.stop()
+ return
+ }
+ }
+}
+
+func (rc *raftNode) serveRaft() {
+ url, err := url.Parse(rc.peers[rc.id-1])
+ if err != nil {
+ log.Fatalf("raftexample: Failed parsing URL (%v)", err)
+ }
+
+ ln, err := newStoppableListener(url.Host, rc.httpstopc)
+ if err != nil {
+ log.Fatalf("raftexample: Failed to listen rafthttp (%v)", err)
+ }
+
+ err = (&http.Server{Handler: rc.transport.Handler()}).Serve(ln)
+ select {
+ case <-rc.httpstopc:
+ default:
+ log.Fatalf("raftexample: Failed to serve rafthttp (%v)", err)
+ }
+ close(rc.httpdonec)
+}
+
+func (rc *raftNode) Process(ctx context.Context, m raftpb.Message) error {
+ return rc.node.Step(ctx, m)
+}
+func (rc *raftNode) IsIDRemoved(id uint64) bool { return false }
+func (rc *raftNode) ReportUnreachable(id uint64) {}
+func (rc *raftNode) ReportSnapshot(id uint64, status raft.SnapshotStatus) {}
diff --git a/vendor/github.com/coreos/etcd/contrib/raftexample/raftexample_test.go b/vendor/github.com/coreos/etcd/contrib/raftexample/raftexample_test.go
new file mode 100644
index 00000000..16b5a4e7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/raftexample/raftexample_test.go
@@ -0,0 +1,159 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "os"
+ "testing"
+
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+type cluster struct {
+ peers []string
+ commitC []<-chan *string
+ errorC []<-chan error
+ proposeC []chan string
+ confChangeC []chan raftpb.ConfChange
+}
+
+// newCluster creates a cluster of n nodes
+func newCluster(n int) *cluster {
+ peers := make([]string, n)
+ for i := range peers {
+ peers[i] = fmt.Sprintf("http://127.0.0.1:%d", 10000+i)
+ }
+
+ clus := &cluster{
+ peers: peers,
+ commitC: make([]<-chan *string, len(peers)),
+ errorC: make([]<-chan error, len(peers)),
+ proposeC: make([]chan string, len(peers)),
+ confChangeC: make([]chan raftpb.ConfChange, len(peers)),
+ }
+
+ for i := range clus.peers {
+ os.RemoveAll(fmt.Sprintf("raftexample-%d", i+1))
+ os.RemoveAll(fmt.Sprintf("raftexample-%d-snap", i+1))
+ clus.proposeC[i] = make(chan string, 1)
+ clus.confChangeC[i] = make(chan raftpb.ConfChange, 1)
+ clus.commitC[i], clus.errorC[i], _ = newRaftNode(i+1, clus.peers, false, nil, clus.proposeC[i], clus.confChangeC[i])
+ }
+
+ return clus
+}
+
+// sinkReplay reads all commits in each node's local log.
+func (clus *cluster) sinkReplay() {
+ for i := range clus.peers {
+ for s := range clus.commitC[i] {
+ if s == nil {
+ break
+ }
+ }
+ }
+}
+
+// Close closes all cluster nodes and returns an error if any failed.
+func (clus *cluster) Close() (err error) {
+ for i := range clus.peers {
+ close(clus.proposeC[i])
+ for range clus.commitC[i] {
+ // drain pending commits
+ }
+ // wait for channel to close
+ if erri := <-clus.errorC[i]; erri != nil {
+ err = erri
+ }
+ // clean intermediates
+ os.RemoveAll(fmt.Sprintf("raftexample-%d", i+1))
+ os.RemoveAll(fmt.Sprintf("raftexample-%d-snap", i+1))
+ }
+ return err
+}
+
+func (clus *cluster) closeNoErrors(t *testing.T) {
+ if err := clus.Close(); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// TestProposeOnCommit starts three nodes and feeds commits back into the proposal
+// channel. The intent is to ensure blocking on a proposal won't block raft progress.
+func TestProposeOnCommit(t *testing.T) {
+ clus := newCluster(3)
+ defer clus.closeNoErrors(t)
+
+ clus.sinkReplay()
+
+ donec := make(chan struct{})
+ for i := range clus.peers {
+ // feedback for "n" committed entries, then update donec
+ go func(pC chan<- string, cC <-chan *string, eC <-chan error) {
+ for n := 0; n < 100; n++ {
+ s, ok := <-cC
+ if !ok {
+ pC = nil
+ }
+ select {
+ case pC <- *s:
+ continue
+ case err := <-eC:
+ t.Fatalf("eC message (%v)", err)
+ }
+ }
+ donec <- struct{}{}
+ for range cC {
+ // acknowledge the commits from other nodes so
+ // raft continues to make progress
+ }
+ }(clus.proposeC[i], clus.commitC[i], clus.errorC[i])
+
+ // one message feedback per node
+ go func(i int) { clus.proposeC[i] <- "foo" }(i)
+ }
+
+ for range clus.peers {
+ <-donec
+ }
+}
+
+// TestCloseProposerBeforeReplay tests closing the producer before raft starts.
+func TestCloseProposerBeforeReplay(t *testing.T) {
+ clus := newCluster(1)
+ // close before replay so raft never starts
+ defer clus.closeNoErrors(t)
+}
+
+// TestCloseProposerInflight tests closing the producer while
+// committed messages are being published to the client.
+func TestCloseProposerInflight(t *testing.T) {
+ clus := newCluster(1)
+ defer clus.closeNoErrors(t)
+
+ clus.sinkReplay()
+
+ // some inflight ops
+ go func() {
+ clus.proposeC[0] <- "foo"
+ clus.proposeC[0] <- "bar"
+ }()
+
+ // wait for one message
+ if c, ok := <-clus.commitC[0]; *c != "foo" || !ok {
+ t.Fatalf("Commit failed")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/contrib/recipes/barrier.go b/vendor/github.com/coreos/etcd/contrib/recipes/barrier.go
new file mode 100644
index 00000000..33aedf6c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/recipes/barrier.go
@@ -0,0 +1,65 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 recipe
+
+import (
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "golang.org/x/net/context"
+)
+
+// Barrier creates a key in etcd to block processes, then deletes the key to
+// release all blocked processes.
+type Barrier struct {
+ client *v3.Client
+ ctx context.Context
+
+ key string
+}
+
+func NewBarrier(client *v3.Client, key string) *Barrier {
+ return &Barrier{client, context.TODO(), key}
+}
+
+// Hold creates the barrier key causing processes to block on Wait.
+func (b *Barrier) Hold() error {
+ _, err := newKey(b.client, b.key, 0)
+ return err
+}
+
+// Release deletes the barrier key to unblock all waiting processes.
+func (b *Barrier) Release() error {
+ _, err := b.client.Delete(b.ctx, b.key)
+ return err
+}
+
+// Wait blocks on the barrier key until it is deleted. If there is no key, Wait
+// assumes Release has already been called and returns immediately.
+func (b *Barrier) Wait() error {
+ resp, err := b.client.Get(b.ctx, b.key, v3.WithFirstKey()...)
+ if err != nil {
+ return err
+ }
+ if len(resp.Kvs) == 0 {
+ // key already removed
+ return nil
+ }
+ _, err = WaitEvents(
+ b.client,
+ b.key,
+ resp.Header.Revision,
+ []mvccpb.Event_EventType{mvccpb.PUT, mvccpb.DELETE})
+ return err
+}
diff --git a/vendor/github.com/coreos/etcd/contrib/recipes/client.go b/vendor/github.com/coreos/etcd/contrib/recipes/client.go
new file mode 100644
index 00000000..30d7389c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/recipes/client.go
@@ -0,0 +1,55 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 recipe
+
+import (
+ "errors"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ spb "github.com/coreos/etcd/mvcc/mvccpb"
+ "golang.org/x/net/context"
+)
+
+var (
+ ErrKeyExists = errors.New("key already exists")
+ ErrWaitMismatch = errors.New("unexpected wait result")
+ ErrTooManyClients = errors.New("too many clients")
+ ErrNoWatcher = errors.New("no watcher channel")
+)
+
+// deleteRevKey deletes a key by revision, returning false if key is missing
+func deleteRevKey(kv v3.KV, key string, rev int64) (bool, error) {
+ cmp := v3.Compare(v3.ModRevision(key), "=", rev)
+ req := v3.OpDelete(key)
+ txnresp, err := kv.Txn(context.TODO()).If(cmp).Then(req).Commit()
+ if err != nil {
+ return false, err
+ } else if !txnresp.Succeeded {
+ return false, nil
+ }
+ return true, nil
+}
+
+func claimFirstKey(kv v3.KV, kvs []*spb.KeyValue) (*spb.KeyValue, error) {
+ for _, k := range kvs {
+ ok, err := deleteRevKey(kv, string(k.Key), k.ModRevision)
+ if err != nil {
+ return nil, err
+ } else if ok {
+ return k, nil
+ }
+ }
+ return nil, nil
+}
diff --git a/vendor/github.com/coreos/etcd/contrib/recipes/doc.go b/vendor/github.com/coreos/etcd/contrib/recipes/doc.go
new file mode 100644
index 00000000..386be975
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/recipes/doc.go
@@ -0,0 +1,17 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 recipe contains experimental client-side distributed
+// synchronization primitives.
+package recipe
diff --git a/vendor/github.com/coreos/etcd/contrib/recipes/double_barrier.go b/vendor/github.com/coreos/etcd/contrib/recipes/double_barrier.go
new file mode 100644
index 00000000..7690ba1d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/recipes/double_barrier.go
@@ -0,0 +1,137 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 recipe
+
+import (
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/concurrency"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "golang.org/x/net/context"
+)
+
+// DoubleBarrier blocks processes on Enter until an expected count enters, then
+// blocks again on Leave until all processes have left.
+type DoubleBarrier struct {
+ s *concurrency.Session
+ ctx context.Context
+
+ key string // key for the collective barrier
+ count int
+ myKey *EphemeralKV // current key for this process on the barrier
+}
+
+func NewDoubleBarrier(s *concurrency.Session, key string, count int) *DoubleBarrier {
+ return &DoubleBarrier{
+ s: s,
+ ctx: context.TODO(),
+ key: key,
+ count: count,
+ }
+}
+
+// Enter waits for "count" processes to enter the barrier then returns
+func (b *DoubleBarrier) Enter() error {
+ client := b.s.Client()
+ ek, err := newUniqueEphemeralKey(b.s, b.key+"/waiters")
+ if err != nil {
+ return err
+ }
+ b.myKey = ek
+
+ resp, err := client.Get(b.ctx, b.key+"/waiters", clientv3.WithPrefix())
+ if err != nil {
+ return err
+ }
+
+ if len(resp.Kvs) > b.count {
+ return ErrTooManyClients
+ }
+
+ if len(resp.Kvs) == b.count {
+ // unblock waiters
+ _, err = client.Put(b.ctx, b.key+"/ready", "")
+ return err
+ }
+
+ _, err = WaitEvents(
+ client,
+ b.key+"/ready",
+ ek.Revision(),
+ []mvccpb.Event_EventType{mvccpb.PUT})
+ return err
+}
+
+// Leave waits for "count" processes to leave the barrier then returns
+func (b *DoubleBarrier) Leave() error {
+ client := b.s.Client()
+ resp, err := client.Get(b.ctx, b.key+"/waiters", clientv3.WithPrefix())
+ if err != nil {
+ return err
+ }
+ if len(resp.Kvs) == 0 {
+ return nil
+ }
+
+ lowest, highest := resp.Kvs[0], resp.Kvs[0]
+ for _, k := range resp.Kvs {
+ if k.ModRevision < lowest.ModRevision {
+ lowest = k
+ }
+ if k.ModRevision > highest.ModRevision {
+ highest = k
+ }
+ }
+ isLowest := string(lowest.Key) == b.myKey.Key()
+
+ if len(resp.Kvs) == 1 {
+ // this is the only node in the barrier; finish up
+ if _, err = client.Delete(b.ctx, b.key+"/ready"); err != nil {
+ return err
+ }
+ return b.myKey.Delete()
+ }
+
+ // this ensures that if a process fails, the ephemeral lease will be
+ // revoked, its barrier key is removed, and the barrier can resume
+
+ // lowest process in node => wait on highest process
+ if isLowest {
+ _, err = WaitEvents(
+ client,
+ string(highest.Key),
+ highest.ModRevision,
+ []mvccpb.Event_EventType{mvccpb.DELETE})
+ if err != nil {
+ return err
+ }
+ return b.Leave()
+ }
+
+ // delete self and wait on lowest process
+ if err = b.myKey.Delete(); err != nil {
+ return err
+ }
+
+ key := string(lowest.Key)
+ _, err = WaitEvents(
+ client,
+ key,
+ lowest.ModRevision,
+ []mvccpb.Event_EventType{mvccpb.DELETE})
+ if err != nil {
+ return err
+ }
+ return b.Leave()
+}
diff --git a/vendor/github.com/coreos/etcd/contrib/recipes/key.go b/vendor/github.com/coreos/etcd/contrib/recipes/key.go
new file mode 100644
index 00000000..b6df5323
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/recipes/key.go
@@ -0,0 +1,163 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 recipe
+
+import (
+ "fmt"
+ "strings"
+ "time"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/concurrency"
+ "golang.org/x/net/context"
+)
+
+// RemoteKV is a key/revision pair created by the client and stored on etcd
+type RemoteKV struct {
+ kv v3.KV
+ key string
+ rev int64
+ val string
+}
+
+func newKey(kv v3.KV, key string, leaseID v3.LeaseID) (*RemoteKV, error) {
+ return newKV(kv, key, "", leaseID)
+}
+
+func newKV(kv v3.KV, key, val string, leaseID v3.LeaseID) (*RemoteKV, error) {
+ rev, err := putNewKV(kv, key, val, leaseID)
+ if err != nil {
+ return nil, err
+ }
+ return &RemoteKV{kv, key, rev, val}, nil
+}
+
+func newUniqueKV(kv v3.KV, prefix string, val string) (*RemoteKV, error) {
+ for {
+ newKey := fmt.Sprintf("%s/%v", prefix, time.Now().UnixNano())
+ rev, err := putNewKV(kv, newKey, val, 0)
+ if err == nil {
+ return &RemoteKV{kv, newKey, rev, val}, nil
+ }
+ if err != ErrKeyExists {
+ return nil, err
+ }
+ }
+}
+
+// putNewKV attempts to create the given key, only succeeding if the key did
+// not yet exist.
+func putNewKV(kv v3.KV, key, val string, leaseID v3.LeaseID) (int64, error) {
+ cmp := v3.Compare(v3.Version(key), "=", 0)
+ req := v3.OpPut(key, val, v3.WithLease(leaseID))
+ txnresp, err := kv.Txn(context.TODO()).If(cmp).Then(req).Commit()
+ if err != nil {
+ return 0, err
+ }
+ if !txnresp.Succeeded {
+ return 0, ErrKeyExists
+ }
+ return txnresp.Header.Revision, nil
+}
+
+// newSequentialKV allocates a new sequential key <prefix>/nnnnn with a given
+// prefix and value. Note: a bookkeeping node __<prefix> is also allocated.
+func newSequentialKV(kv v3.KV, prefix, val string) (*RemoteKV, error) {
+ resp, err := kv.Get(context.TODO(), prefix, v3.WithLastKey()...)
+ if err != nil {
+ return nil, err
+ }
+
+ // add 1 to last key, if any
+ newSeqNum := 0
+ if len(resp.Kvs) != 0 {
+ fields := strings.Split(string(resp.Kvs[0].Key), "/")
+ _, serr := fmt.Sscanf(fields[len(fields)-1], "%d", &newSeqNum)
+ if serr != nil {
+ return nil, serr
+ }
+ newSeqNum++
+ }
+ newKey := fmt.Sprintf("%s/%016d", prefix, newSeqNum)
+
+ // base prefix key must be current (i.e., <=) with the server update;
+ // the base key is important to avoid the following:
+ // N1: LastKey() == 1, start txn.
+ // N2: new Key 2, new Key 3, Delete Key 2
+ // N1: txn succeeds allocating key 2 when it shouldn't
+ baseKey := "__" + prefix
+
+ // current revision might contain modification so +1
+ cmp := v3.Compare(v3.ModRevision(baseKey), "<", resp.Header.Revision+1)
+ reqPrefix := v3.OpPut(baseKey, "")
+ reqnewKey := v3.OpPut(newKey, val)
+
+ txn := kv.Txn(context.TODO())
+ txnresp, err := txn.If(cmp).Then(reqPrefix, reqnewKey).Commit()
+ if err != nil {
+ return nil, err
+ }
+ if !txnresp.Succeeded {
+ return newSequentialKV(kv, prefix, val)
+ }
+ return &RemoteKV{kv, newKey, txnresp.Header.Revision, val}, nil
+}
+
+func (rk *RemoteKV) Key() string { return rk.key }
+func (rk *RemoteKV) Revision() int64 { return rk.rev }
+func (rk *RemoteKV) Value() string { return rk.val }
+
+func (rk *RemoteKV) Delete() error {
+ if rk.kv == nil {
+ return nil
+ }
+ _, err := rk.kv.Delete(context.TODO(), rk.key)
+ rk.kv = nil
+ return err
+}
+
+func (rk *RemoteKV) Put(val string) error {
+ _, err := rk.kv.Put(context.TODO(), rk.key, val)
+ return err
+}
+
+// EphemeralKV is a new key associated with a session lease
+type EphemeralKV struct{ RemoteKV }
+
+// newEphemeralKV creates a new key/value pair associated with a session lease
+func newEphemeralKV(s *concurrency.Session, key, val string) (*EphemeralKV, error) {
+ k, err := newKV(s.Client(), key, val, s.Lease())
+ if err != nil {
+ return nil, err
+ }
+ return &EphemeralKV{*k}, nil
+}
+
+// newUniqueEphemeralKey creates a new unique valueless key associated with a session lease
+func newUniqueEphemeralKey(s *concurrency.Session, prefix string) (*EphemeralKV, error) {
+ return newUniqueEphemeralKV(s, prefix, "")
+}
+
+// newUniqueEphemeralKV creates a new unique key/value pair associated with a session lease
+func newUniqueEphemeralKV(s *concurrency.Session, prefix, val string) (ek *EphemeralKV, err error) {
+ for {
+ newKey := fmt.Sprintf("%s/%v", prefix, time.Now().UnixNano())
+ ek, err = newEphemeralKV(s, newKey, val)
+ if err == nil || err != ErrKeyExists {
+ break
+ }
+ }
+ return ek, err
+}
diff --git a/vendor/github.com/coreos/etcd/contrib/recipes/priority_queue.go b/vendor/github.com/coreos/etcd/contrib/recipes/priority_queue.go
new file mode 100644
index 00000000..a62fb02a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/recipes/priority_queue.go
@@ -0,0 +1,80 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 recipe
+
+import (
+ "fmt"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "golang.org/x/net/context"
+)
+
+// PriorityQueue implements a multi-reader, multi-writer distributed queue.
+type PriorityQueue struct {
+ client *v3.Client
+ ctx context.Context
+ key string
+}
+
+// NewPriorityQueue creates an etcd priority queue.
+func NewPriorityQueue(client *v3.Client, key string) *PriorityQueue {
+ return &PriorityQueue{client, context.TODO(), key + "/"}
+}
+
+// Enqueue puts a value into a queue with a given priority.
+func (q *PriorityQueue) Enqueue(val string, pr uint16) error {
+ prefix := fmt.Sprintf("%s%05d", q.key, pr)
+ _, err := newSequentialKV(q.client, prefix, val)
+ return err
+}
+
+// Dequeue returns Enqueue()'d items in FIFO order. If the
+// queue is empty, Dequeue blocks until items are available.
+func (q *PriorityQueue) Dequeue() (string, error) {
+ // TODO: fewer round trips by fetching more than one key
+ resp, err := q.client.Get(q.ctx, q.key, v3.WithFirstKey()...)
+ if err != nil {
+ return "", err
+ }
+
+ kv, err := claimFirstKey(q.client, resp.Kvs)
+ if err != nil {
+ return "", err
+ } else if kv != nil {
+ return string(kv.Value), nil
+ } else if resp.More {
+ // missed some items, retry to read in more
+ return q.Dequeue()
+ }
+
+ // nothing to dequeue; wait on items
+ ev, err := WaitPrefixEvents(
+ q.client,
+ q.key,
+ resp.Header.Revision,
+ []mvccpb.Event_EventType{mvccpb.PUT})
+ if err != nil {
+ return "", err
+ }
+
+ ok, err := deleteRevKey(q.client, string(ev.Kv.Key), ev.Kv.ModRevision)
+ if err != nil {
+ return "", err
+ } else if !ok {
+ return q.Dequeue()
+ }
+ return string(ev.Kv.Value), err
+}
diff --git a/vendor/github.com/coreos/etcd/contrib/recipes/queue.go b/vendor/github.com/coreos/etcd/contrib/recipes/queue.go
new file mode 100644
index 00000000..714c4060
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/recipes/queue.go
@@ -0,0 +1,76 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 recipe
+
+import (
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "golang.org/x/net/context"
+)
+
+// Queue implements a multi-reader, multi-writer distributed queue.
+type Queue struct {
+ client *v3.Client
+ ctx context.Context
+
+ keyPrefix string
+}
+
+func NewQueue(client *v3.Client, keyPrefix string) *Queue {
+ return &Queue{client, context.TODO(), keyPrefix}
+}
+
+func (q *Queue) Enqueue(val string) error {
+ _, err := newUniqueKV(q.client, q.keyPrefix, val)
+ return err
+}
+
+// Dequeue returns Enqueue()'d elements in FIFO order. If the
+// queue is empty, Dequeue blocks until elements are available.
+func (q *Queue) Dequeue() (string, error) {
+ // TODO: fewer round trips by fetching more than one key
+ resp, err := q.client.Get(q.ctx, q.keyPrefix, v3.WithFirstRev()...)
+ if err != nil {
+ return "", err
+ }
+
+ kv, err := claimFirstKey(q.client, resp.Kvs)
+ if err != nil {
+ return "", err
+ } else if kv != nil {
+ return string(kv.Value), nil
+ } else if resp.More {
+ // missed some items, retry to read in more
+ return q.Dequeue()
+ }
+
+ // nothing yet; wait on elements
+ ev, err := WaitPrefixEvents(
+ q.client,
+ q.keyPrefix,
+ resp.Header.Revision,
+ []mvccpb.Event_EventType{mvccpb.PUT})
+ if err != nil {
+ return "", err
+ }
+
+ ok, err := deleteRevKey(q.client, string(ev.Kv.Key), ev.Kv.ModRevision)
+ if err != nil {
+ return "", err
+ } else if !ok {
+ return q.Dequeue()
+ }
+ return string(ev.Kv.Value), err
+}
diff --git a/vendor/github.com/coreos/etcd/contrib/recipes/rwmutex.go b/vendor/github.com/coreos/etcd/contrib/recipes/rwmutex.go
new file mode 100644
index 00000000..2714305d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/recipes/rwmutex.go
@@ -0,0 +1,88 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 recipe
+
+import (
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/concurrency"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "golang.org/x/net/context"
+)
+
+type RWMutex struct {
+ s *concurrency.Session
+ ctx context.Context
+
+ pfx string
+ myKey *EphemeralKV
+}
+
+func NewRWMutex(s *concurrency.Session, prefix string) *RWMutex {
+ return &RWMutex{s, context.TODO(), prefix + "/", nil}
+}
+
+func (rwm *RWMutex) RLock() error {
+ rk, err := newUniqueEphemeralKey(rwm.s, rwm.pfx+"read")
+ if err != nil {
+ return err
+ }
+ rwm.myKey = rk
+ // wait until nodes with "write-" and a lower revision number than myKey are gone
+ for {
+ if done, werr := rwm.waitOnLastRev(rwm.pfx + "write"); done || werr != nil {
+ return werr
+ }
+ }
+}
+
+func (rwm *RWMutex) Lock() error {
+ rk, err := newUniqueEphemeralKey(rwm.s, rwm.pfx+"write")
+ if err != nil {
+ return err
+ }
+ rwm.myKey = rk
+ // wait until all keys of lower revision than myKey are gone
+ for {
+ if done, werr := rwm.waitOnLastRev(rwm.pfx); done || werr != nil {
+ return werr
+ }
+ // get the new lowest key until this is the only one left
+ }
+}
+
+// waitOnLowest will wait on the last key with a revision < rwm.myKey.Revision with a
+// given prefix. If there are no keys left to wait on, return true.
+func (rwm *RWMutex) waitOnLastRev(pfx string) (bool, error) {
+ client := rwm.s.Client()
+ // get key that's blocking myKey
+ opts := append(v3.WithLastRev(), v3.WithMaxModRev(rwm.myKey.Revision()-1))
+ lastKey, err := client.Get(rwm.ctx, pfx, opts...)
+ if err != nil {
+ return false, err
+ }
+ if len(lastKey.Kvs) == 0 {
+ return true, nil
+ }
+ // wait for release on blocking key
+ _, err = WaitEvents(
+ client,
+ string(lastKey.Kvs[0].Key),
+ rwm.myKey.Revision(),
+ []mvccpb.Event_EventType{mvccpb.DELETE})
+ return false, err
+}
+
+func (rwm *RWMutex) RUnlock() error { return rwm.myKey.Delete() }
+func (rwm *RWMutex) Unlock() error { return rwm.myKey.Delete() }
diff --git a/vendor/github.com/coreos/etcd/contrib/recipes/watch.go b/vendor/github.com/coreos/etcd/contrib/recipes/watch.go
new file mode 100644
index 00000000..1c4619d3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/recipes/watch.go
@@ -0,0 +1,53 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 recipe
+
+import (
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "golang.org/x/net/context"
+)
+
+// WaitEvents waits on a key until it observes the given events and returns the final one.
+func WaitEvents(c *clientv3.Client, key string, rev int64, evs []mvccpb.Event_EventType) (*clientv3.Event, error) {
+ wc := c.Watch(context.Background(), key, clientv3.WithRev(rev))
+ if wc == nil {
+ return nil, ErrNoWatcher
+ }
+ return waitEvents(wc, evs), nil
+}
+
+func WaitPrefixEvents(c *clientv3.Client, prefix string, rev int64, evs []mvccpb.Event_EventType) (*clientv3.Event, error) {
+ wc := c.Watch(context.Background(), prefix, clientv3.WithPrefix(), clientv3.WithRev(rev))
+ if wc == nil {
+ return nil, ErrNoWatcher
+ }
+ return waitEvents(wc, evs), nil
+}
+
+func waitEvents(wc clientv3.WatchChan, evs []mvccpb.Event_EventType) *clientv3.Event {
+ i := 0
+ for wresp := range wc {
+ for _, ev := range wresp.Events {
+ if ev.Type == evs[i] {
+ i++
+ if i == len(evs) {
+ return ev
+ }
+ }
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/contrib/systemd/etcd.service b/vendor/github.com/coreos/etcd/contrib/systemd/etcd.service
new file mode 100644
index 00000000..3550f3d7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/systemd/etcd.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=etcd key-value store
+Documentation=https://github.com/coreos/etcd
+After=network.target
+
+[Service]
+User=etcd
+Type=notify
+Environment=ETCD_DATA_DIR=/var/lib/etcd
+Environment=ETCD_NAME=%m
+ExecStart=/usr/bin/etcd
+Restart=always
+RestartSec=10s
+LimitNOFILE=40000
+
+[Install]
+WantedBy=multi-user.target
diff --git a/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/.gitignore b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/.gitignore
new file mode 100644
index 00000000..3f3c6fba
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/.gitignore
@@ -0,0 +1,4 @@
+rclone.conf
+bin
+etcd2-backup.tgz
+*~
diff --git a/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/30-etcd2-backup-restore.conf b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/30-etcd2-backup-restore.conf
new file mode 100644
index 00000000..1bba94ae
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/30-etcd2-backup-restore.conf
@@ -0,0 +1,9 @@
+[Service]
+Environment="ETCD_RESTORE_MASTER_ADV_PEER_URLS=http://172.17.4.51:2379"
+Environment="RCLONE_ENDPOINT=s3-chom-testing-backups:chom-testing-backups/mytest"
+Environment="RCLONE_CONFIG_PATH=/etc/rclone.conf"
+Environment="ETCD_DATA_DIR=/var/lib/etcd2"
+Environment="ETCD_BACKUP_DIR=/var/lib/etcd2-backup"
+Environment="ETCD_RESTORE_DIR=/var/lib/etcd2-restore"
+Environment="RCLONE_CHECKSUM=true"
+
diff --git a/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/README.md b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/README.md
new file mode 100644
index 00000000..bd4b2298
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/README.md
@@ -0,0 +1,251 @@
+# etcd2-backup-coreos
+
+Remote backup and multi-node restore services for etcd2 clusters on CoreOS Linux.
+
+**Warning:** This package is only intended for use on CoreOS Linux.
+
+## Terminology
+
+**Founding member** : The node which is the first member of the new recovered cluster. It is this node's rclone backup data (only) that will be used to restore the cluster. The rest of the nodes will join the cluster with no data, and simply catch up with the **founding member**.
+
+## Configuration
+
+Before installing etcd2-backup, configure `30-etcd2-backup-restore.conf`:
+
+```
+[Service]
+Environment="ETCD_RESTORE_MASTER_ADV_PEER_URLS=<http://host:port>"
+Environment="RCLONE_ENDPOINT=remote-name:path/to/backups"
+```
+
+Assuming a deployment to CoreOS with etcd2, only change:
+
+* `ETCD_RESTORE_MASTER_ADV_PEER_URLS`
+ This is the new advertised peer url of the new etcd2 node that will be the founding member of the new restored cluster. We will call this node the **founding member**.
+
+* `RCLONE_ENDPOINT`
+ The rclone endpoint to which backups will be stored.
+
+ Feel free to point any number of machines at the same RCLONE_ENDPOINT, path and all. Backups for each machine are stored in a sub-folder named with the machine ID (%m in systemd parlance)
+
+* `./rclone.conf`
+ The rclone configuration file which will be installed. Must list a `[section]` which matches `RCLONE_ENDPOINT`'s remote-name component.
+
+ An easy way to generate this config file is to [install rclone](http://rclone.org/install/) on a local machine. Then follow the [configuration instructions](http://rclone.org/docs/) to generate an `rclone.conf` file.
+
+To adjust backup frequency, edit `./etcd2-backup.timer`
+
+## Installation
+
+Once those things are configured, run `./build`.
+
+The `build` script generates a tarball for copying to CoreOS instances. The tarball contains the `etcd2-backup-install` script.
+
+After extracting the contents of the tar file and running the install script, three new systemd services are added. One service, `etcd2-backup`, performs periodic etcd backups, while the other two services, `etcd2-restore` and `etcd2-join`, handle restore procedures.
+
+* `etcd2-backup.service`
+ A oneshot service which calls `etcdctl backup` and syncs the backups to the rclone endpoint (using an rclone container, of course). `etcd2-backup.timer` is responsible for periodically running this service.
+
+* `etcd2-restore.service`
+ A oneshot service which wipes all etcd2 data and restores a single-node cluster from the rclone backup. This is for restoring the **founding member** only.
+
+* `etcd2-join.service`
+ A oneshot service which wipes all etcd2 data and re-joins the new cluster. This is for adding members **after** the **founding member** has succesfully established the new cluster via `etcd2-restore.service`
+
+## Recovery
+
+This assumes that the cluster has lost quorum and is not recoverable. Otherwise try to heal the cluster first.
+
+### Backup Freshness
+
+Two factors contribute to the relative freshness or staleness of a backup. The `etcd2-backup.timer` takes a backup every 30 seconds by default, and the etcd `snapshot-count` option controls how many transactions are committed between each write of the snapshot to permanent storage. Given those parameters, we can compute the upper bound on the outdatedness of a backup.
+Assumptions:
+* transaction rate is a constant `1000 transactions / second`
+* `etcd2-backup.timer` is configured for a 30 second interval
+* `etcd2 snapshot-count=10000`
+
+```
+max-missed-seconds= (10000 transactions / (1000 transactions / second)) + 30 seconds = 40 seconds
+```
+
+### Recovery Procedure
+
+1. Make sure `etcd2.service` and `etcd2-backup.timer` are stopped on all nodes in the cluster
+
+2. Restore the **founding member** by starting `etcd2-restore.service` and then, if successful, `etcd2.service`
+
+3. Restore the rest of the cluster **one at a time**. Start `etcd2-join.service`, and then, if successful, `etcd2.service`. Please verify with `etcdctl cluster-health` that the expected set of nodes is present and healthy after each node joins.
+
+4. Verify that the data is sane (enough). If so, kick off `etcd2-backup.timer` on all nodes and, hopefully, go back to bed.
+
+## Retroactively change the founding member
+
+It is necessary to change the cluster's founding member in order to restore a cluster from any other node's data.
+
+Change the value of `ETCD_RESTORE_MASTER_ADV_PEER_URLS` in `30-etcd2-backup-restore.conf` to the advertised peer url of the new founding member. Repeat the install process above on all nodes in the cluster, then proceed with the [recovery procedure](README.md#recovery-procedure).
+
+## Example
+
+Let's pretend that we have an initial 3 node CoreOS cluster that we want to back up to S3.
+
+
+| ETCD_NAME | ETCD_ADVERTISED_PEER_URL |
+| ------------- |:-------------:|
+| e1 | http://172.17.4.51:2379 |
+| e2 | http://172.17.4.52:2379 |
+| e3 | http://172.17.4.53:2379 |
+
+In the event that the cluster fails, we want to restore from `e1`'s backup
+
+## Configuration
+
+```
+[Service]
+Environment="ETCD_RESTORE_MASTER_ADV_PEER_URLS=http://172.17.4.51:2379"
+Environment="RCLONE_ENDPOINT=s3-testing-conf:s3://etcd2-backup-bucket/backups"
+```
+
+The `./rclone.conf` file must contain a `[section]` matching `RCLONE_ENDPOINTS`'s remote-name component.
+
+```
+[s3-testing-conf]
+type = s3
+access_key_id = xxxxxxxx
+secret_access_key = xxxxxx
+region = us-west-1
+endpoint =
+location_constraint =
+```
+
+## Installation
+
+```sh
+cd etcd2-backup
+./build
+scp etcd2-backup.tgz core@e1:~/
+ssh core@e1
+e1 $ mkdir -p ~/etcd2-backup
+e1 $ mv etcd2-backup.tgz etcd2-backup/
+e1 $ cd etcd2-backup
+e1 $ tar zxvf ~/etcd2-backup.tgz
+e1 $ ./etcd2-backup-install
+# Only do the following two commands if this node should generate backups
+e1 $ sudo systemctl enable etcd2-backup.timer
+e1 $ sudo systemctl start etcd2-backup.timer
+
+e1 $ exit
+```
+
+Now `e1`'s etcd data will be backed up to `s3://etcd2-backup-bucket/backups/<e1-machine-id>/` according to the schedule described in `etcd2-backup.timer`.
+
+Repeat the process for `e2` and `e3`. To stop a node from generating backups, omit enabling and starting `etcd2-backup.timer`.
+
+## Restore the cluster
+
+Let's assume that a mischievous friend decided it would be a good idea to corrupt the etcd2 data-dir on ALL of the nodes (`e1`,`e2`,`e3`). Simply restore the cluster from `e1`'s backup.
+
+Here's how to recover:
+
+```sh
+# First, ENSURE etcd2 and etcd2-backup are not running on any nodes
+for node in e{1..3};do
+ ssh core@$node "sudo systemctl stop etcd2.service etcd2-backup.{timer,service}"
+done
+
+ssh core@e1 "sudo systemctl start etcd2-restore.service && sudo systemctl start etcd2.service"
+
+for node in e{2..3};do
+ ssh core@$node "sudo systemctl start etcd2-join.service && sudo systemctl start etcd2.service"
+ sleep 10
+done
+```
+
+After e2 and e3 finish catching up, the cluster should be back to normal.
+
+## Migrate the cluster
+
+The same friend who corrupted the etcd2 data-dirs decided that to have more fun. This time, the friend dumps coffee on the machines hosting `e1`, `e2` and `e3`. There is a horrible smell, and the machines are dead.
+
+Luckily, there's a new 3-node etcd2 cluster ready to go, along with the S3 backup for `e1` from the old cluster.
+
+The new cluster configuration looks like this. Assume that etcd2-backup is not installed. (If it is, make sure it's not running on any nodes)
+
+| ETCD_NAME | ETCD_ADVERTISED_PEER_URL |
+| ------------- |:-------------:|
+| q1 | http://172.17.8.201:2379 |
+| q2 | http://172.17.8.202:2379 |
+| q3 | http://172.17.8.203:2379 |
+
+We will assume `q1` is the chosen founding member, though picking any node is fine.
+
+## Migrate the remote backup
+
+First, copy the backup from `e1`'s backup folder to `q1`'s backup folder. I will show the S3 example.
+
+```sh
+# Make sure to remove q1's backup directory, if it exists already
+aws s3 rm --recursive s3://etcd2-backup-bucket/backups/<q1-machine-id>
+aws s3 cp --recursive s3://etcd2-backup-bucket/backups/<e1-machine-id> s3://etcd2-backup-bucket/backups/<q1-machine-id>
+```
+
+## Configure the New Cluster
+
+```
+[Service]
+Environment="ETCD_RESTORE_MASTER_ADV_PEER_URLS=http://172.17.8.201:2379"
+Environment="RCLONE_ENDPOINT=s3-testing-conf:s3://etcd2-backup-bucket/backups"
+```
+
+Since this is a new cluster, each new node will have a new `machine-id` and will not clobber the backups from the old cluster, even though `RCLONE_ENDPOINT` is the same for both the old `e` cluster and the new `q` cluster.
+
+## Installation
+
+We first want to install the configured etcd2-backup package on all nodes, but not start any services yet.
+
+```sh
+cd etcd2-backup
+./build
+for node in q{1..3};do
+ scp etcd2-backup.tgz core@$node:~/
+ ssh core@$node "mkdir -p ~/etcd2-backup"
+ ssh core@$node "mv etcd2-backup.tgz etcd2-backup/"
+ ssh core@$node " cd etcd2-backup"
+ ssh core@$node " tar zxvf ~/etcd2-backup.tgz"
+ ssh core@$node " ./etcd2-backup-install"
+done
+```
+
+## Migrate the Cluster
+
+With `q1` as the founding member.
+
+```sh
+# First, make SURE etcd2 and etcd2-backup are not running on any nodes
+
+for node in q{1..3};do
+ ssh core@$node "sudo systemctl stop etcd2.service"
+done
+
+ssh core@q1 "sudo systemctl start etcd2-restore.service && sudo systemctl start etcd2.service"
+
+for node in q{2..3};do
+ ssh core@$node "sudo systemctl start etcd2-join.service && sudo systemctl start etcd2.service"
+ sleep 10
+done
+```
+
+After confirming the cluster has migrated properly, start and enable `etcd2-backup.timer` on at least one node.
+
+```sh
+ssh core@q1 "sudo systemctl enable etcd2-backup.service && sudo systemctl start etcd2-backup.service"
+```
+
+There should now be periodic backups going to: `s3://etcd2-backup-bucket/backups/<q1-machine-id>`
+
+## Words of caution
+
+1. Notice the `sleep 10` commands that follow starting `etcd2-join.service` and then `etcd2.service`. This sleep is there to allow the member that joined to cluster time to catch up on the cluster state before we attempt to add the next member. This involves sending the entire snapshot over the network. If the dataset is large, the network between nodes is slow, disks are already bogged down, or the system is otherwise overutilized, try increasing the sleep.
+
+ In the case of large data sets, it is recommended to copy the data directory produced by `etcd2-restore` on the founding member to the other nodes before running `etcd2-join` on them. This will avoid etcd transferring the entire snapshot to every node after it joins the cluster.
+
+2. It is not recommended clients be allowed to access the etcd2 cluster **until** all members have been added and finished catching up.
diff --git a/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/build b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/build
new file mode 100755
index 00000000..144f9bdd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/build
@@ -0,0 +1,25 @@
+#!/bin/bash -e
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+cd "${SCRIPT_DIR}"
+
+if [ ! -f "./rclone.conf" ];then
+ echo "Could not find $(pwd)/rclone.conf"
+ exit 1
+fi
+
+mkdir -p ./bin
+
+GOPATH=$(pwd) go build -o ./bin/etcd2-restore etcd2-restore.go
+
+tar cfz ./etcd2-backup.tgz \
+ *.{service,timer,conf} \
+ etcd2-join \
+ bin/etcd2-restore \
+ rclone.conf \
+ etcd2-backup-install
+
+printf "Install package saved at\n\t -> $(pwd)/etcd2-backup.tgz\n\n"
+
+printf "Copy to target machine and deploy.\n $> tar zxvf etcd2-backup.tgz && ./etcd2-backup-install\n\n"
+echo "WARNING: this tarball contains your rclone secrets. Be careful!"
diff --git a/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-backup-install b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-backup-install
new file mode 100755
index 00000000..50afbf5f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-backup-install
@@ -0,0 +1,33 @@
+#!/bin/bash -e
+
+if [ ! -f /etc/os-release ];then
+ echo "Could not find /etc/os-release. This is not CoreOS Linux"
+ exit 1
+fi
+. /etc/os-release
+if [ ! "$ID" == "coreos" ];then
+ echo "os-release error: Detected ID=$ID: this is not CoreOS Linux"
+ exit 1
+fi
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+cd "${SCRIPT_DIR}"
+
+sudo cp ./rclone.conf /etc/
+
+sudo mkdir -p /opt/bin
+
+sudo mv etcd2-join bin/etcd2-restore /opt/bin
+sudo mv *.{service,timer} /etc/systemd/system
+
+sudo systemctl daemon-reload
+
+for jobtype in restore backup join;do
+ sudo mkdir -p /var/run/systemd/system/etcd2-${jobtype}.service.d
+ sudo cp 30-etcd2-backup-restore.conf /var/run/systemd/system/etcd2-${jobtype}.service.d/
+ sudo ln -sf /var/run/systemd/system/etcd2{,-${jobtype}}.service.d/20-cloudinit.conf
+done
+
+sudo systemctl daemon-reload
+
+echo "etcd2-backup install complete!"
diff --git a/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-backup.service b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-backup.service
new file mode 100644
index 00000000..2aa2b5f2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-backup.service
@@ -0,0 +1,29 @@
+[Unit]
+Description=rclone powered etcd2 backup service
+After=etcd2.service
+
+[Service]
+Type=oneshot
+
+ExecStartPre=/usr/bin/rm -rf ${ETCD_BACKUP_DIR}
+ExecStartPre=/usr/bin/mkdir -p ${ETCD_BACKUP_DIR}/member/snap
+ExecStartPre=/usr/bin/echo ETCD_DATA_DIR: ${ETCD_DATA_DIR}
+ExecStartPre=/usr/bin/echo ETCD_BACKUP_DIR: ${ETCD_BACKUP_DIR}
+ExecStartPre=/usr/bin/etcdctl backup --data-dir=${ETCD_DATA_DIR} --backup-dir=${ETCD_BACKUP_DIR}
+ExecStartPre=/usr/bin/touch ${ETCD_BACKUP_DIR}/member/snap/iamhere.txt
+
+# Copy the last backup, in case the new upload gets corrupted
+ExecStartPre=-/usr/bin/docker run --rm \
+ -v ${RCLONE_CONFIG_PATH}:/etc/rclone.conf \
+ quay.io/coreos/rclone:latest --config /etc/rclone.conf --checksum=${RCLONE_CHECKSUM} \
+ copy ${RCLONE_ENDPOINT}/%m ${RCLONE_ENDPOINT}/%m_backup
+
+# Upload new backup
+ExecStart=/usr/bin/docker run --rm \
+ -v ${ETCD_BACKUP_DIR}:/etcd2backup \
+ -v ${RCLONE_CONFIG_PATH}:/etc/rclone.conf \
+ quay.io/coreos/rclone:latest --config ${RCLONE_CONFIG_PATH} --checksum=${RCLONE_CHECKSUM} \
+ copy /etcd2backup/ ${RCLONE_ENDPOINT}/%m/
+
+[Install]
+WantedBy=multi-user.target
diff --git a/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-backup.timer b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-backup.timer
new file mode 100644
index 00000000..8d2feff9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-backup.timer
@@ -0,0 +1,9 @@
+[Unit]
+Description=etcd2-backup service timer
+
+[Timer]
+OnBootSec=1min
+OnUnitActiveSec=30sec
+
+[Install]
+WantedBy=timers.target
diff --git a/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-join b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-join
new file mode 100755
index 00000000..7773f2cd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-join
@@ -0,0 +1,39 @@
+#!/bin/bash -e
+
+# Copyright 2015 CoreOS, Inc.
+#
+# Licensed 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.
+
+if [ $# -lt 3 ];then
+ echo "USAGE: $0 <master_advertise_peer_urls> <target_name> <target_peer_url>"
+ exit 1
+fi
+
+function convertDropin {
+ sed -e 's/^Added.*$/[Service]/g' -e 's/="/=/g' -e 's/^ETCD_/Environment="ETCD_/g'
+}
+masterAdvUrl=$1
+targetName=$2
+targetUrl=$3
+
+cmd="etcdctl --peers ${masterAdvUrl} member add ${targetName} ${targetUrl}"
+
+ENV_VARS=`$cmd`
+echo "${ENV_VARS}" | convertDropin > 40-boostrap-cluster.conf
+
+sudo mv 40-boostrap-cluster.conf /var/run/systemd/system/etcd2.service.d/
+sudo systemctl daemon-reload
+sudo systemctl cat etcd2.service
+echo "You can now start etcd2"
+
+
diff --git a/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-join.service b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-join.service
new file mode 100644
index 00000000..ba445065
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-join.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Add etcd2 node to existing cluster
+Conflicts=etcd2.service etcd2-backup.service
+Before=etcd2.service etcd2-backup.service
+
+[Service]
+Type=oneshot
+ExecStartPre=/usr/bin/rm -rf ${ETCD_DATA_DIR}/member
+ExecStartPre=/usr/bin/chown -R etcd:etcd ${ETCD_DATA_DIR}
+ExecStart=/opt/bin/etcd2-join ${ETCD_RESTORE_MASTER_ADV_PEER_URLS} ${ETCD_NAME} ${ETCD_INITIAL_ADVERTISE_PEER_URLS}
+
+[Install]
+WantedBy=multi-user.target
diff --git a/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-restore.go b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-restore.go
new file mode 100644
index 00000000..d4916a50
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-restore.go
@@ -0,0 +1,126 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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"
+ "os"
+ "os/exec"
+ "path"
+ "regexp"
+ "time"
+)
+
+var (
+ etcdctlPath string
+ etcdPath string
+ etcdRestoreDir string
+ etcdName string
+ etcdPeerUrls string
+)
+
+func main() {
+ flag.StringVar(&etcdctlPath, "etcdctl-path", "/usr/bin/etcdctl", "absolute path to etcdctl executable")
+ flag.StringVar(&etcdPath, "etcd-path", "/usr/bin/etcd2", "absolute path to etcd2 executable")
+ flag.StringVar(&etcdRestoreDir, "etcd-restore-dir", "/var/lib/etcd2-restore", "absolute path to etcd2 restore dir")
+ flag.StringVar(&etcdName, "etcd-name", "default", "name of etcd2 node")
+ flag.StringVar(&etcdPeerUrls, "etcd-peer-urls", "", "advertise peer urls")
+
+ flag.Parse()
+
+ if etcdPeerUrls == "" {
+ panic("must set -etcd-peer-urls")
+ }
+
+ if finfo, err := os.Stat(etcdRestoreDir); err != nil {
+ panic(err)
+ } else {
+ if !finfo.IsDir() {
+ panic(fmt.Errorf("%s is not a directory", etcdRestoreDir))
+ }
+ }
+
+ if !path.IsAbs(etcdctlPath) {
+ panic(fmt.Sprintf("etcdctl-path %s is not absolute", etcdctlPath))
+ }
+
+ if !path.IsAbs(etcdPath) {
+ panic(fmt.Sprintf("etcd-path %s is not absolute", etcdPath))
+ }
+
+ if err := restoreEtcd(); err != nil {
+ panic(err)
+ }
+}
+
+func restoreEtcd() error {
+ etcdCmd := exec.Command(etcdPath, "--force-new-cluster", "--data-dir", etcdRestoreDir)
+
+ etcdCmd.Stdout = os.Stdout
+ etcdCmd.Stderr = os.Stderr
+
+ if err := etcdCmd.Start(); err != nil {
+ return fmt.Errorf("Could not start etcd2: %s", err)
+ }
+ defer etcdCmd.Wait()
+ defer etcdCmd.Process.Kill()
+
+ return runCommands(10, 2*time.Second)
+}
+
+var (
+ clusterHealthRegex = regexp.MustCompile(".*cluster is healthy.*")
+ lineSplit = regexp.MustCompile("\n+")
+ colonSplit = regexp.MustCompile(`\:`)
+)
+
+func runCommands(maxRetry int, interval time.Duration) error {
+ var retryCnt int
+ for retryCnt = 1; retryCnt <= maxRetry; retryCnt++ {
+ out, err := exec.Command(etcdctlPath, "cluster-health").CombinedOutput()
+ if err == nil && clusterHealthRegex.Match(out) {
+ break
+ }
+ fmt.Printf("Error: %s: %s\n", err, string(out))
+ time.Sleep(interval)
+ }
+
+ if retryCnt > maxRetry {
+ return fmt.Errorf("Timed out waiting for healthy cluster\n")
+ }
+
+ var (
+ memberID string
+ out []byte
+ err error
+ )
+ if out, err = exec.Command(etcdctlPath, "member", "list").CombinedOutput(); err != nil {
+ return fmt.Errorf("Error calling member list: %s", err)
+ }
+ members := lineSplit.Split(string(out), 2)
+ if len(members) < 1 {
+ return fmt.Errorf("Could not find a cluster member from: \"%s\"", members)
+ }
+ parts := colonSplit.Split(members[0], 2)
+ if len(parts) < 2 {
+ return fmt.Errorf("Could not parse member id from: \"%s\"", members[0])
+ }
+ memberID = parts[0]
+
+ out, err = exec.Command(etcdctlPath, "member", "update", memberID, etcdPeerUrls).CombinedOutput()
+ fmt.Printf("member update result: %s\n", string(out))
+ return err
+}
diff --git a/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-restore.service b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-restore.service
new file mode 100644
index 00000000..a591f783
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/systemd/etcd2-backup-coreos/etcd2-restore.service
@@ -0,0 +1,26 @@
+[Unit]
+Description=Restore single-node etcd2 node from rclone endpoint
+Conflicts=etcd2.service etcd2-backup.service
+Before=etcd2.service etcd2-backup.service
+
+[Service]
+Type=oneshot
+ExecStartPre=/usr/bin/rm -rf ${ETCD_DATA_DIR}/member
+ExecStartPre=/usr/bin/mkdir -p ${ETCD_RESTORE_DIR}
+ExecStartPre=/usr/bin/rm -rf ${ETCD_RESTORE_DIR}/member
+
+# Copy the last backup from rclone endpoint
+ExecStartPre=/usr/bin/docker run --rm \
+ -v ${RCLONE_CONFIG_PATH}:/etc/rclone.conf \
+ -v ${ETCD_RESTORE_DIR}:/etcd2backup \
+ quay.io/coreos/rclone:latest \
+ --config /etc/rclone.conf --checksum=${RCLONE_CHECKSUM} \
+ copy ${RCLONE_ENDPOINT}/%m /etcd2backup
+
+ExecStartPre=/usr/bin/ls -R ${ETCD_RESTORE_DIR}
+ExecStartPre=/opt/bin/etcd2-restore -etcd-name ${ETCD_NAME} -etcd-peer-urls ${ETCD_INITIAL_ADVERTISE_PEER_URLS}
+ExecStartPre=/usr/bin/cp -r ${ETCD_RESTORE_DIR}/member ${ETCD_DATA_DIR}/member
+ExecStart=/usr/bin/chown -R etcd:etcd ${ETCD_DATA_DIR}/member
+
+[Install]
+WantedBy=multi-user.target
diff --git a/vendor/github.com/coreos/etcd/contrib/systemd/etcd3-multinode/README.md b/vendor/github.com/coreos/etcd/contrib/systemd/etcd3-multinode/README.md
new file mode 100644
index 00000000..cab9ab4d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/contrib/systemd/etcd3-multinode/README.md
@@ -0,0 +1,173 @@
+# etcd3 multi-node cluster
+
+Here's how to deploy etcd cluster with systemd.
+
+## Set up data directory
+
+etcd needs data directory on host machine. Configure the data directory accessible to systemd as:
+
+```
+sudo mkdir -p /var/lib/etcd
+sudo chown -R root:$(whoami) /var/lib/etcd
+sudo chmod -R a+rw /var/lib/etcd
+```
+
+## Write systemd service file
+
+In each machine, write etcd systemd service files:
+
+```
+cat > /tmp/my-etcd-1.service <<EOF
+[Unit]
+Description=etcd
+Documentation=https://github.com/coreos/etcd
+Conflicts=etcd.service
+Conflicts=etcd2.service
+
+[Service]
+Type=notify
+Restart=always
+RestartSec=5s
+LimitNOFILE=40000
+TimeoutStartSec=0
+
+ExecStart=etcd --name my-etcd-1 \
+ --data-dir /var/lib/etcd \
+ --listen-client-urls http://${IP_1}:2379 \
+ --advertise-client-urls http://${IP_1}:2379 \
+ --listen-peer-urls http://${IP_1}:2380 \
+ --initial-advertise-peer-urls http://${IP_1}:2380 \
+ --initial-cluster my-etcd-1=http://${IP_1}:2380,my-etcd-2=http://${IP_2}:2380,my-etcd-3=http://${IP_3}:2380 \
+ --initial-cluster-token my-etcd-token \
+ --initial-cluster-state new
+
+[Install]
+WantedBy=multi-user.target
+EOF
+sudo mv /tmp/my-etcd-1.service /etc/systemd/system/my-etcd-1.service
+```
+
+```
+cat > /tmp/my-etcd-2.service <<EOF
+[Unit]
+Description=etcd
+Documentation=https://github.com/coreos/etcd
+Conflicts=etcd.service
+Conflicts=etcd2.service
+
+[Service]
+Type=notify
+Restart=always
+RestartSec=5s
+LimitNOFILE=40000
+TimeoutStartSec=0
+
+ExecStart=etcd --name my-etcd-2 \
+ --data-dir /var/lib/etcd \
+ --listen-client-urls http://${IP_2}:2379 \
+ --advertise-client-urls http://${IP_2}:2379 \
+ --listen-peer-urls http://${IP_2}:2380 \
+ --initial-advertise-peer-urls http://${IP_2}:2380 \
+ --initial-cluster my-etcd-1=http://${IP_1}:2380,my-etcd-2=http://${IP_2}:2380,my-etcd-3=http://${IP_3}:2380 \
+ --initial-cluster-token my-etcd-token \
+ --initial-cluster-state new
+
+[Install]
+WantedBy=multi-user.target
+EOF
+sudo mv /tmp/my-etcd-2.service /etc/systemd/system/my-etcd-2.service
+```
+
+```
+cat > /tmp/my-etcd-3.service <<EOF
+[Unit]
+Description=etcd
+Documentation=https://github.com/coreos/etcd
+Conflicts=etcd.service
+Conflicts=etcd2.service
+
+[Service]
+Type=notify
+Restart=always
+RestartSec=5s
+LimitNOFILE=40000
+TimeoutStartSec=0
+
+ExecStart=etcd --name my-etcd-3 \
+ --data-dir /var/lib/etcd \
+ --listen-client-urls http://${IP_3}:2379 \
+ --advertise-client-urls http://${IP_3}:2379 \
+ --listen-peer-urls http://${IP_3}:2380 \
+ --initial-advertise-peer-urls http://${IP_3}:2380 \
+ --initial-cluster my-etcd-1=http://${IP_1}:2380,my-etcd-2=http://${IP_2}:2380,my-etcd-3=http://${IP_3}:2380 \
+ --initial-cluster-token my-etcd-token \
+ --initial-cluster-state new
+
+[Install]
+WantedBy=multi-user.target
+EOF
+sudo mv /tmp/my-etcd-3.service /etc/systemd/system/my-etcd-3.service
+```
+
+## Start the service
+
+The service needs to be enabled first, in case of system reboot:
+
+```
+sudo systemctl daemon-reload
+sudo systemctl enable my-etcd-1.service
+sudo systemctl start my-etcd-1.service
+```
+
+```
+sudo systemctl daemon-reload
+sudo systemctl enable my-etcd-2.service
+sudo systemctl start my-etcd-2.service
+```
+
+```
+sudo systemctl daemon-reload
+sudo systemctl enable my-etcd-3.service
+sudo systemctl start my-etcd-3.service
+```
+
+## Check logs
+
+systemd stores etcd server logs with journald:
+
+```
+sudo systemctl status my-etcd-1.service -l --no-pager
+sudo journalctl -u my-etcd-1.service -l --no-pager|less
+sudo journalctl -f -u my-etcd-1.service
+```
+
+```
+sudo systemctl status my-etcd-2.service -l --no-pager
+sudo journalctl -u my-etcd-2.service -l --no-pager|less
+sudo journalctl -f -u my-etcd-2.service
+```
+
+```
+sudo systemctl status my-etcd-3.service -l --no-pager
+sudo journalctl -u my-etcd-3.service -l --no-pager|less
+sudo journalctl -f -u my-etcd-3.service
+```
+
+## Stop etcd
+
+To disable etcd process:
+
+```
+sudo systemctl stop my-etcd-1.service
+sudo systemctl disable my-etcd-1.service
+```
+
+```
+sudo systemctl stop my-etcd-2.service
+sudo systemctl disable my-etcd-2.service
+```
+
+```
+sudo systemctl stop my-etcd-3.service
+sudo systemctl disable my-etcd-3.service
+```
diff --git a/vendor/github.com/coreos/etcd/cover b/vendor/github.com/coreos/etcd/cover
new file mode 100755
index 00000000..b7ad3911
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/cover
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+#
+# Generate coverage HTML for a package
+# e.g. PKG=./unit ./cover
+#
+set -e
+
+if [ -z "$PKG" ]; then
+ echo "cover only works with a single package, sorry"
+ exit 255
+fi
+
+COVEROUT="coverage"
+
+if ! [ -d "$COVEROUT" ]; then
+ mkdir "$COVEROUT"
+fi
+
+# strip leading dot/slash and trailing slash and sanitize other slashes
+# e.g. ./etcdserver/etcdhttp/ ==> etcdserver_etcdhttp
+COVERPKG=${PKG/#./}
+COVERPKG=${COVERPKG/#\//}
+COVERPKG=${COVERPKG/%\//}
+COVERPKG=${COVERPKG//\//_}
+
+# generate arg for "go test"
+export COVER="-coverprofile ${COVEROUT}/${COVERPKG}.out"
+
+source ./test
+
+go tool cover -html=${COVEROUT}/${COVERPKG}.out
diff --git a/vendor/github.com/coreos/etcd/discovery/discovery.go b/vendor/github.com/coreos/etcd/discovery/discovery.go
new file mode 100644
index 00000000..edc842ff
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/discovery/discovery.go
@@ -0,0 +1,362 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 discovery provides an implementation of the cluster discovery that
+// is used by etcd.
+package discovery
+
+import (
+ "errors"
+ "fmt"
+ "math"
+ "net/http"
+ "net/url"
+ "path"
+ "sort"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/coreos/etcd/client"
+ "github.com/coreos/etcd/pkg/transport"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/pkg/capnslog"
+ "github.com/jonboulle/clockwork"
+ "golang.org/x/net/context"
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "discovery")
+
+ ErrInvalidURL = errors.New("discovery: invalid URL")
+ ErrBadSizeKey = errors.New("discovery: size key is bad")
+ ErrSizeNotFound = errors.New("discovery: size key not found")
+ ErrTokenNotFound = errors.New("discovery: token not found")
+ ErrDuplicateID = errors.New("discovery: found duplicate id")
+ ErrDuplicateName = errors.New("discovery: found duplicate name")
+ ErrFullCluster = errors.New("discovery: cluster is full")
+ ErrTooManyRetries = errors.New("discovery: too many retries")
+ ErrBadDiscoveryEndpoint = errors.New("discovery: bad discovery endpoint")
+)
+
+var (
+ // Number of retries discovery will attempt before giving up and erroring out.
+ nRetries = uint(math.MaxUint32)
+ maxExpoentialRetries = uint(8)
+)
+
+// JoinCluster will connect to the discovery service at the given url, and
+// register the server represented by the given id and config to the cluster
+func JoinCluster(durl, dproxyurl string, id types.ID, config string) (string, error) {
+ d, err := newDiscovery(durl, dproxyurl, id)
+ if err != nil {
+ return "", err
+ }
+ return d.joinCluster(config)
+}
+
+// GetCluster will connect to the discovery service at the given url and
+// retrieve a string describing the cluster
+func GetCluster(durl, dproxyurl string) (string, error) {
+ d, err := newDiscovery(durl, dproxyurl, 0)
+ if err != nil {
+ return "", err
+ }
+ return d.getCluster()
+}
+
+type discovery struct {
+ cluster string
+ id types.ID
+ c client.KeysAPI
+ retries uint
+ url *url.URL
+
+ clock clockwork.Clock
+}
+
+// newProxyFunc builds a proxy function from the given string, which should
+// represent a URL that can be used as a proxy. It performs basic
+// sanitization of the URL and returns any error encountered.
+func newProxyFunc(proxy string) (func(*http.Request) (*url.URL, error), error) {
+ if proxy == "" {
+ return nil, nil
+ }
+ // Do a small amount of URL sanitization to help the user
+ // Derived from net/http.ProxyFromEnvironment
+ proxyURL, err := url.Parse(proxy)
+ if err != nil || !strings.HasPrefix(proxyURL.Scheme, "http") {
+ // proxy was bogus. Try prepending "http://" to it and
+ // see if that parses correctly. If not, we ignore the
+ // error and complain about the original one
+ var err2 error
+ proxyURL, err2 = url.Parse("http://" + proxy)
+ if err2 == nil {
+ err = nil
+ }
+ }
+ if err != nil {
+ return nil, fmt.Errorf("invalid proxy address %q: %v", proxy, err)
+ }
+
+ plog.Infof("using proxy %q", proxyURL.String())
+ return http.ProxyURL(proxyURL), nil
+}
+
+func newDiscovery(durl, dproxyurl string, id types.ID) (*discovery, error) {
+ u, err := url.Parse(durl)
+ if err != nil {
+ return nil, err
+ }
+ token := u.Path
+ u.Path = ""
+ pf, err := newProxyFunc(dproxyurl)
+ if err != nil {
+ return nil, err
+ }
+
+ // TODO: add ResponseHeaderTimeout back when watch on discovery service writes header early
+ tr, err := transport.NewTransport(transport.TLSInfo{}, 30*time.Second)
+ if err != nil {
+ return nil, err
+ }
+ tr.Proxy = pf
+ cfg := client.Config{
+ Transport: tr,
+ Endpoints: []string{u.String()},
+ }
+ c, err := client.New(cfg)
+ if err != nil {
+ return nil, err
+ }
+ dc := client.NewKeysAPIWithPrefix(c, "")
+ return &discovery{
+ cluster: token,
+ c: dc,
+ id: id,
+ url: u,
+ clock: clockwork.NewRealClock(),
+ }, nil
+}
+
+func (d *discovery) joinCluster(config string) (string, error) {
+ // fast path: if the cluster is full, return the error
+ // do not need to register to the cluster in this case.
+ if _, _, _, err := d.checkCluster(); err != nil {
+ return "", err
+ }
+
+ if err := d.createSelf(config); err != nil {
+ // Fails, even on a timeout, if createSelf times out.
+ // TODO(barakmich): Retrying the same node might want to succeed here
+ // (ie, createSelf should be idempotent for discovery).
+ return "", err
+ }
+
+ nodes, size, index, err := d.checkCluster()
+ if err != nil {
+ return "", err
+ }
+
+ all, err := d.waitNodes(nodes, size, index)
+ if err != nil {
+ return "", err
+ }
+
+ return nodesToCluster(all, size)
+}
+
+func (d *discovery) getCluster() (string, error) {
+ nodes, size, index, err := d.checkCluster()
+ if err != nil {
+ if err == ErrFullCluster {
+ return nodesToCluster(nodes, size)
+ }
+ return "", err
+ }
+
+ all, err := d.waitNodes(nodes, size, index)
+ if err != nil {
+ return "", err
+ }
+ return nodesToCluster(all, size)
+}
+
+func (d *discovery) createSelf(contents string) error {
+ ctx, cancel := context.WithTimeout(context.Background(), client.DefaultRequestTimeout)
+ resp, err := d.c.Create(ctx, d.selfKey(), contents)
+ cancel()
+ if err != nil {
+ if eerr, ok := err.(client.Error); ok && eerr.Code == client.ErrorCodeNodeExist {
+ return ErrDuplicateID
+ }
+ return err
+ }
+
+ // ensure self appears on the server we connected to
+ w := d.c.Watcher(d.selfKey(), &client.WatcherOptions{AfterIndex: resp.Node.CreatedIndex - 1})
+ _, err = w.Next(context.Background())
+ return err
+}
+
+func (d *discovery) checkCluster() ([]*client.Node, int, uint64, error) {
+ configKey := path.Join("/", d.cluster, "_config")
+ ctx, cancel := context.WithTimeout(context.Background(), client.DefaultRequestTimeout)
+ // find cluster size
+ resp, err := d.c.Get(ctx, path.Join(configKey, "size"), nil)
+ cancel()
+ if err != nil {
+ if eerr, ok := err.(*client.Error); ok && eerr.Code == client.ErrorCodeKeyNotFound {
+ return nil, 0, 0, ErrSizeNotFound
+ }
+ if err == client.ErrInvalidJSON {
+ return nil, 0, 0, ErrBadDiscoveryEndpoint
+ }
+ if ce, ok := err.(*client.ClusterError); ok {
+ plog.Error(ce.Detail())
+ return d.checkClusterRetry()
+ }
+ return nil, 0, 0, err
+ }
+ size, err := strconv.Atoi(resp.Node.Value)
+ if err != nil {
+ return nil, 0, 0, ErrBadSizeKey
+ }
+
+ ctx, cancel = context.WithTimeout(context.Background(), client.DefaultRequestTimeout)
+ resp, err = d.c.Get(ctx, d.cluster, nil)
+ cancel()
+ if err != nil {
+ if ce, ok := err.(*client.ClusterError); ok {
+ plog.Error(ce.Detail())
+ return d.checkClusterRetry()
+ }
+ return nil, 0, 0, err
+ }
+ var nodes []*client.Node
+ // append non-config keys to nodes
+ for _, n := range resp.Node.Nodes {
+ if !(path.Base(n.Key) == path.Base(configKey)) {
+ nodes = append(nodes, n)
+ }
+ }
+
+ snodes := sortableNodes{nodes}
+ sort.Sort(snodes)
+
+ // find self position
+ for i := range nodes {
+ if path.Base(nodes[i].Key) == path.Base(d.selfKey()) {
+ break
+ }
+ if i >= size-1 {
+ return nodes[:size], size, resp.Index, ErrFullCluster
+ }
+ }
+ return nodes, size, resp.Index, nil
+}
+
+func (d *discovery) logAndBackoffForRetry(step string) {
+ d.retries++
+ // logAndBackoffForRetry stops exponential backoff when the retries are more than maxExpoentialRetries and is set to a constant backoff afterward.
+ retries := d.retries
+ if retries > maxExpoentialRetries {
+ retries = maxExpoentialRetries
+ }
+ retryTimeInSecond := time.Duration(0x1<<retries) * time.Second
+ plog.Infof("%s: error connecting to %s, retrying in %s", step, d.url, retryTimeInSecond)
+ d.clock.Sleep(retryTimeInSecond)
+}
+
+func (d *discovery) checkClusterRetry() ([]*client.Node, int, uint64, error) {
+ if d.retries < nRetries {
+ d.logAndBackoffForRetry("cluster status check")
+ return d.checkCluster()
+ }
+ return nil, 0, 0, ErrTooManyRetries
+}
+
+func (d *discovery) waitNodesRetry() ([]*client.Node, error) {
+ if d.retries < nRetries {
+ d.logAndBackoffForRetry("waiting for other nodes")
+ nodes, n, index, err := d.checkCluster()
+ if err != nil {
+ return nil, err
+ }
+ return d.waitNodes(nodes, n, index)
+ }
+ return nil, ErrTooManyRetries
+}
+
+func (d *discovery) waitNodes(nodes []*client.Node, size int, index uint64) ([]*client.Node, error) {
+ if len(nodes) > size {
+ nodes = nodes[:size]
+ }
+ // watch from the next index
+ w := d.c.Watcher(d.cluster, &client.WatcherOptions{AfterIndex: index, Recursive: true})
+ all := make([]*client.Node, len(nodes))
+ copy(all, nodes)
+ for _, n := range all {
+ if path.Base(n.Key) == path.Base(d.selfKey()) {
+ plog.Noticef("found self %s in the cluster", path.Base(d.selfKey()))
+ } else {
+ plog.Noticef("found peer %s in the cluster", path.Base(n.Key))
+ }
+ }
+
+ // wait for others
+ for len(all) < size {
+ plog.Noticef("found %d peer(s), waiting for %d more", len(all), size-len(all))
+ resp, err := w.Next(context.Background())
+ if err != nil {
+ if ce, ok := err.(*client.ClusterError); ok {
+ plog.Error(ce.Detail())
+ return d.waitNodesRetry()
+ }
+ return nil, err
+ }
+ plog.Noticef("found peer %s in the cluster", path.Base(resp.Node.Key))
+ all = append(all, resp.Node)
+ }
+ plog.Noticef("found %d needed peer(s)", len(all))
+ return all, nil
+}
+
+func (d *discovery) selfKey() string {
+ return path.Join("/", d.cluster, d.id.String())
+}
+
+func nodesToCluster(ns []*client.Node, size int) (string, error) {
+ s := make([]string, len(ns))
+ for i, n := range ns {
+ s[i] = n.Value
+ }
+ us := strings.Join(s, ",")
+ m, err := types.NewURLsMap(us)
+ if err != nil {
+ return us, ErrInvalidURL
+ }
+ if m.Len() != size {
+ return us, ErrDuplicateName
+ }
+ return us, nil
+}
+
+type sortableNodes struct{ Nodes []*client.Node }
+
+func (ns sortableNodes) Len() int { return len(ns.Nodes) }
+func (ns sortableNodes) Less(i, j int) bool {
+ return ns.Nodes[i].CreatedIndex < ns.Nodes[j].CreatedIndex
+}
+func (ns sortableNodes) Swap(i, j int) { ns.Nodes[i], ns.Nodes[j] = ns.Nodes[j], ns.Nodes[i] }
diff --git a/vendor/github.com/coreos/etcd/discovery/discovery_test.go b/vendor/github.com/coreos/etcd/discovery/discovery_test.go
new file mode 100644
index 00000000..bf0636af
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/discovery/discovery_test.go
@@ -0,0 +1,558 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 discovery
+
+import (
+ "errors"
+ "math"
+ "math/rand"
+ "net/http"
+ "reflect"
+ "sort"
+ "strconv"
+ "testing"
+ "time"
+
+ "github.com/jonboulle/clockwork"
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/client"
+)
+
+const (
+ maxRetryInTest = 3
+)
+
+func TestNewProxyFuncUnset(t *testing.T) {
+ pf, err := newProxyFunc("")
+ if pf != nil {
+ t.Fatal("unexpected non-nil proxyFunc")
+ }
+ if err != nil {
+ t.Fatalf("unexpected non-nil err: %v", err)
+ }
+}
+
+func TestNewProxyFuncBad(t *testing.T) {
+ tests := []string{
+ "%%",
+ "http://foo.com/%1",
+ }
+ for i, in := range tests {
+ pf, err := newProxyFunc(in)
+ if pf != nil {
+ t.Errorf("#%d: unexpected non-nil proxyFunc", i)
+ }
+ if err == nil {
+ t.Errorf("#%d: unexpected nil err", i)
+ }
+ }
+}
+
+func TestNewProxyFunc(t *testing.T) {
+ tests := map[string]string{
+ "bar.com": "http://bar.com",
+ "http://disco.foo.bar": "http://disco.foo.bar",
+ }
+ for in, w := range tests {
+ pf, err := newProxyFunc(in)
+ if pf == nil {
+ t.Errorf("%s: unexpected nil proxyFunc", in)
+ continue
+ }
+ if err != nil {
+ t.Errorf("%s: unexpected non-nil err: %v", in, err)
+ continue
+ }
+ g, err := pf(&http.Request{})
+ if err != nil {
+ t.Errorf("%s: unexpected non-nil err: %v", in, err)
+ }
+ if g.String() != w {
+ t.Errorf("%s: proxyURL=%q, want %q", in, g, w)
+ }
+
+ }
+}
+
+func TestCheckCluster(t *testing.T) {
+ cluster := "/prefix/1000"
+ self := "/1000/1"
+
+ tests := []struct {
+ nodes []*client.Node
+ index uint64
+ werr error
+ wsize int
+ }{
+ {
+ // self is in the size range
+ []*client.Node{
+ {Key: "/1000/_config/size", Value: "3", CreatedIndex: 1},
+ {Key: "/1000/_config/"},
+ {Key: self, CreatedIndex: 2},
+ {Key: "/1000/2", CreatedIndex: 3},
+ {Key: "/1000/3", CreatedIndex: 4},
+ {Key: "/1000/4", CreatedIndex: 5},
+ },
+ 5,
+ nil,
+ 3,
+ },
+ {
+ // self is in the size range
+ []*client.Node{
+ {Key: "/1000/_config/size", Value: "3", CreatedIndex: 1},
+ {Key: "/1000/_config/"},
+ {Key: "/1000/2", CreatedIndex: 2},
+ {Key: "/1000/3", CreatedIndex: 3},
+ {Key: self, CreatedIndex: 4},
+ {Key: "/1000/4", CreatedIndex: 5},
+ },
+ 5,
+ nil,
+ 3,
+ },
+ {
+ // self is out of the size range
+ []*client.Node{
+ {Key: "/1000/_config/size", Value: "3", CreatedIndex: 1},
+ {Key: "/1000/_config/"},
+ {Key: "/1000/2", CreatedIndex: 2},
+ {Key: "/1000/3", CreatedIndex: 3},
+ {Key: "/1000/4", CreatedIndex: 4},
+ {Key: self, CreatedIndex: 5},
+ },
+ 5,
+ ErrFullCluster,
+ 3,
+ },
+ {
+ // self is not in the cluster
+ []*client.Node{
+ {Key: "/1000/_config/size", Value: "3", CreatedIndex: 1},
+ {Key: "/1000/_config/"},
+ {Key: "/1000/2", CreatedIndex: 2},
+ {Key: "/1000/3", CreatedIndex: 3},
+ },
+ 3,
+ nil,
+ 3,
+ },
+ {
+ []*client.Node{
+ {Key: "/1000/_config/size", Value: "3", CreatedIndex: 1},
+ {Key: "/1000/_config/"},
+ {Key: "/1000/2", CreatedIndex: 2},
+ {Key: "/1000/3", CreatedIndex: 3},
+ {Key: "/1000/4", CreatedIndex: 4},
+ },
+ 3,
+ ErrFullCluster,
+ 3,
+ },
+ {
+ // bad size key
+ []*client.Node{
+ {Key: "/1000/_config/size", Value: "bad", CreatedIndex: 1},
+ },
+ 0,
+ ErrBadSizeKey,
+ 0,
+ },
+ {
+ // no size key
+ []*client.Node{},
+ 0,
+ ErrSizeNotFound,
+ 0,
+ },
+ }
+
+ for i, tt := range tests {
+ var rs []*client.Response
+ if len(tt.nodes) > 0 {
+ rs = append(rs, &client.Response{Node: tt.nodes[0], Index: tt.index})
+ rs = append(rs, &client.Response{
+ Node: &client.Node{
+ Key: cluster,
+ Nodes: tt.nodes[1:],
+ },
+ Index: tt.index,
+ })
+ }
+ c := &clientWithResp{rs: rs}
+ dBase := discovery{cluster: cluster, id: 1, c: c}
+
+ cRetry := &clientWithRetry{failTimes: 3}
+ cRetry.rs = rs
+ fc := clockwork.NewFakeClock()
+ dRetry := discovery{cluster: cluster, id: 1, c: cRetry, clock: fc}
+
+ for _, d := range []discovery{dBase, dRetry} {
+ go func() {
+ for i := uint(1); i <= maxRetryInTest; i++ {
+ fc.BlockUntil(1)
+ fc.Advance(time.Second * (0x1 << i))
+ }
+ }()
+ ns, size, index, err := d.checkCluster()
+ if err != tt.werr {
+ t.Errorf("#%d: err = %v, want %v", i, err, tt.werr)
+ }
+ if reflect.DeepEqual(ns, tt.nodes) {
+ t.Errorf("#%d: nodes = %v, want %v", i, ns, tt.nodes)
+ }
+ if size != tt.wsize {
+ t.Errorf("#%d: size = %v, want %d", i, size, tt.wsize)
+ }
+ if index != tt.index {
+ t.Errorf("#%d: index = %v, want %d", i, index, tt.index)
+ }
+ }
+ }
+}
+
+func TestWaitNodes(t *testing.T) {
+ all := []*client.Node{
+ 0: {Key: "/1000/1", CreatedIndex: 2},
+ 1: {Key: "/1000/2", CreatedIndex: 3},
+ 2: {Key: "/1000/3", CreatedIndex: 4},
+ }
+
+ tests := []struct {
+ nodes []*client.Node
+ rs []*client.Response
+ }{
+ {
+ all,
+ []*client.Response{},
+ },
+ {
+ all[:1],
+ []*client.Response{
+ {Node: &client.Node{Key: "/1000/2", CreatedIndex: 3}},
+ {Node: &client.Node{Key: "/1000/3", CreatedIndex: 4}},
+ },
+ },
+ {
+ all[:2],
+ []*client.Response{
+ {Node: &client.Node{Key: "/1000/3", CreatedIndex: 4}},
+ },
+ },
+ {
+ append(all, &client.Node{Key: "/1000/4", CreatedIndex: 5}),
+ []*client.Response{
+ {Node: &client.Node{Key: "/1000/3", CreatedIndex: 4}},
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ // Basic case
+ c := &clientWithResp{rs: nil, w: &watcherWithResp{rs: tt.rs}}
+ dBase := &discovery{cluster: "1000", c: c}
+
+ // Retry case
+ var retryScanResp []*client.Response
+ if len(tt.nodes) > 0 {
+ retryScanResp = append(retryScanResp, &client.Response{
+ Node: &client.Node{
+ Key: "1000",
+ Value: strconv.Itoa(3),
+ },
+ })
+ retryScanResp = append(retryScanResp, &client.Response{
+ Node: &client.Node{
+ Nodes: tt.nodes,
+ },
+ })
+ }
+ cRetry := &clientWithResp{
+ rs: retryScanResp,
+ w: &watcherWithRetry{rs: tt.rs, failTimes: 2},
+ }
+ fc := clockwork.NewFakeClock()
+ dRetry := &discovery{
+ cluster: "1000",
+ c: cRetry,
+ clock: fc,
+ }
+
+ for _, d := range []*discovery{dBase, dRetry} {
+ go func() {
+ for i := uint(1); i <= maxRetryInTest; i++ {
+ fc.BlockUntil(1)
+ fc.Advance(time.Second * (0x1 << i))
+ }
+ }()
+ g, err := d.waitNodes(tt.nodes, 3, 0) // we do not care about index in this test
+ if err != nil {
+ t.Errorf("#%d: err = %v, want %v", i, err, nil)
+ }
+ if !reflect.DeepEqual(g, all) {
+ t.Errorf("#%d: all = %v, want %v", i, g, all)
+ }
+ }
+ }
+}
+
+func TestCreateSelf(t *testing.T) {
+ rs := []*client.Response{{Node: &client.Node{Key: "1000/1", CreatedIndex: 2}}}
+
+ w := &watcherWithResp{rs: rs}
+ errw := &watcherWithErr{err: errors.New("watch err")}
+
+ c := &clientWithResp{rs: rs, w: w}
+ errc := &clientWithErr{err: errors.New("create err"), w: w}
+ errdupc := &clientWithErr{err: client.Error{Code: client.ErrorCodeNodeExist}}
+ errwc := &clientWithResp{rs: rs, w: errw}
+
+ tests := []struct {
+ c client.KeysAPI
+ werr error
+ }{
+ // no error
+ {c, nil},
+ // client.create returns an error
+ {errc, errc.err},
+ // watcher.next returns an error
+ {errwc, errw.err},
+ // parse key exist error to duplicate ID error
+ {errdupc, ErrDuplicateID},
+ }
+
+ for i, tt := range tests {
+ d := discovery{cluster: "1000", c: tt.c}
+ if err := d.createSelf(""); err != tt.werr {
+ t.Errorf("#%d: err = %v, want %v", i, err, nil)
+ }
+ }
+}
+
+func TestNodesToCluster(t *testing.T) {
+ tests := []struct {
+ nodes []*client.Node
+ size int
+ wcluster string
+ werr error
+ }{
+ {
+ []*client.Node{
+ 0: {Key: "/1000/1", Value: "1=http://1.1.1.1:2380", CreatedIndex: 1},
+ 1: {Key: "/1000/2", Value: "2=http://2.2.2.2:2380", CreatedIndex: 2},
+ 2: {Key: "/1000/3", Value: "3=http://3.3.3.3:2380", CreatedIndex: 3},
+ },
+ 3,
+ "1=http://1.1.1.1:2380,2=http://2.2.2.2:2380,3=http://3.3.3.3:2380",
+ nil,
+ },
+ {
+ []*client.Node{
+ 0: {Key: "/1000/1", Value: "1=http://1.1.1.1:2380", CreatedIndex: 1},
+ 1: {Key: "/1000/2", Value: "2=http://2.2.2.2:2380", CreatedIndex: 2},
+ 2: {Key: "/1000/3", Value: "2=http://3.3.3.3:2380", CreatedIndex: 3},
+ },
+ 3,
+ "1=http://1.1.1.1:2380,2=http://2.2.2.2:2380,2=http://3.3.3.3:2380",
+ ErrDuplicateName,
+ },
+ {
+ []*client.Node{
+ 0: {Key: "/1000/1", Value: "1=1.1.1.1:2380", CreatedIndex: 1},
+ 1: {Key: "/1000/2", Value: "2=http://2.2.2.2:2380", CreatedIndex: 2},
+ 2: {Key: "/1000/3", Value: "2=http://3.3.3.3:2380", CreatedIndex: 3},
+ },
+ 3,
+ "1=1.1.1.1:2380,2=http://2.2.2.2:2380,2=http://3.3.3.3:2380",
+ ErrInvalidURL,
+ },
+ }
+
+ for i, tt := range tests {
+ cluster, err := nodesToCluster(tt.nodes, tt.size)
+ if err != tt.werr {
+ t.Errorf("#%d: err = %v, want %v", i, err, tt.werr)
+ }
+ if !reflect.DeepEqual(cluster, tt.wcluster) {
+ t.Errorf("#%d: cluster = %v, want %v", i, cluster, tt.wcluster)
+ }
+ }
+}
+
+func TestSortableNodes(t *testing.T) {
+ ns := []*client.Node{
+ 0: {CreatedIndex: 5},
+ 1: {CreatedIndex: 1},
+ 2: {CreatedIndex: 3},
+ 3: {CreatedIndex: 4},
+ }
+ // add some randomness
+ for i := 0; i < 10000; i++ {
+ ns = append(ns, &client.Node{CreatedIndex: uint64(rand.Int31())})
+ }
+ sns := sortableNodes{ns}
+ sort.Sort(sns)
+ var cis []int
+ for _, n := range sns.Nodes {
+ cis = append(cis, int(n.CreatedIndex))
+ }
+ if !sort.IntsAreSorted(cis) {
+ t.Errorf("isSorted = %v, want %v", sort.IntsAreSorted(cis), true)
+ }
+ cis = make([]int, 0)
+ for _, n := range ns {
+ cis = append(cis, int(n.CreatedIndex))
+ }
+ if !sort.IntsAreSorted(cis) {
+ t.Errorf("isSorted = %v, want %v", sort.IntsAreSorted(cis), true)
+ }
+}
+
+func TestRetryFailure(t *testing.T) {
+ nRetries = maxRetryInTest
+ defer func() { nRetries = math.MaxUint32 }()
+
+ cluster := "1000"
+ c := &clientWithRetry{failTimes: 4}
+ fc := clockwork.NewFakeClock()
+ d := discovery{
+ cluster: cluster,
+ id: 1,
+ c: c,
+ clock: fc,
+ }
+ go func() {
+ for i := uint(1); i <= maxRetryInTest; i++ {
+ fc.BlockUntil(1)
+ fc.Advance(time.Second * (0x1 << i))
+ }
+ }()
+ if _, _, _, err := d.checkCluster(); err != ErrTooManyRetries {
+ t.Errorf("err = %v, want %v", err, ErrTooManyRetries)
+ }
+}
+
+type clientWithResp struct {
+ rs []*client.Response
+ w client.Watcher
+ client.KeysAPI
+}
+
+func (c *clientWithResp) Create(ctx context.Context, key string, value string) (*client.Response, error) {
+ if len(c.rs) == 0 {
+ return &client.Response{}, nil
+ }
+ r := c.rs[0]
+ c.rs = c.rs[1:]
+ return r, nil
+}
+
+func (c *clientWithResp) Get(ctx context.Context, key string, opts *client.GetOptions) (*client.Response, error) {
+ if len(c.rs) == 0 {
+ return &client.Response{}, &client.Error{Code: client.ErrorCodeKeyNotFound}
+ }
+ r := c.rs[0]
+ c.rs = append(c.rs[1:], r)
+ return r, nil
+}
+
+func (c *clientWithResp) Watcher(key string, opts *client.WatcherOptions) client.Watcher {
+ return c.w
+}
+
+type clientWithErr struct {
+ err error
+ w client.Watcher
+ client.KeysAPI
+}
+
+func (c *clientWithErr) Create(ctx context.Context, key string, value string) (*client.Response, error) {
+ return &client.Response{}, c.err
+}
+
+func (c *clientWithErr) Get(ctx context.Context, key string, opts *client.GetOptions) (*client.Response, error) {
+ return &client.Response{}, c.err
+}
+
+func (c *clientWithErr) Watcher(key string, opts *client.WatcherOptions) client.Watcher {
+ return c.w
+}
+
+type watcherWithResp struct {
+ client.KeysAPI
+ rs []*client.Response
+}
+
+func (w *watcherWithResp) Next(context.Context) (*client.Response, error) {
+ if len(w.rs) == 0 {
+ return &client.Response{}, nil
+ }
+ r := w.rs[0]
+ w.rs = w.rs[1:]
+ return r, nil
+}
+
+type watcherWithErr struct {
+ err error
+}
+
+func (w *watcherWithErr) Next(context.Context) (*client.Response, error) {
+ return &client.Response{}, w.err
+}
+
+// clientWithRetry will timeout all requests up to failTimes
+type clientWithRetry struct {
+ clientWithResp
+ failCount int
+ failTimes int
+}
+
+func (c *clientWithRetry) Create(ctx context.Context, key string, value string) (*client.Response, error) {
+ if c.failCount < c.failTimes {
+ c.failCount++
+ return nil, &client.ClusterError{Errors: []error{context.DeadlineExceeded}}
+ }
+ return c.clientWithResp.Create(ctx, key, value)
+}
+
+func (c *clientWithRetry) Get(ctx context.Context, key string, opts *client.GetOptions) (*client.Response, error) {
+ if c.failCount < c.failTimes {
+ c.failCount++
+ return nil, &client.ClusterError{Errors: []error{context.DeadlineExceeded}}
+ }
+ return c.clientWithResp.Get(ctx, key, opts)
+}
+
+// watcherWithRetry will timeout all requests up to failTimes
+type watcherWithRetry struct {
+ rs []*client.Response
+ failCount int
+ failTimes int
+}
+
+func (w *watcherWithRetry) Next(context.Context) (*client.Response, error) {
+ if w.failCount < w.failTimes {
+ w.failCount++
+ return nil, &client.ClusterError{Errors: []error{context.DeadlineExceeded}}
+ }
+ if len(w.rs) == 0 {
+ return &client.Response{}, nil
+ }
+ r := w.rs[0]
+ w.rs = w.rs[1:]
+ return r, nil
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v2_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v2_test.go
new file mode 100644
index 00000000..294a478f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v2_test.go
@@ -0,0 +1,473 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "io/ioutil"
+ "os"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/fileutil"
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestCtlV2Set(t *testing.T) { testCtlV2Set(t, &configNoTLS, false) }
+func TestCtlV2SetQuorum(t *testing.T) { testCtlV2Set(t, &configNoTLS, true) }
+func TestCtlV2SetClientTLS(t *testing.T) { testCtlV2Set(t, &configClientTLS, false) }
+func TestCtlV2SetPeerTLS(t *testing.T) { testCtlV2Set(t, &configPeerTLS, false) }
+func TestCtlV2SetTLS(t *testing.T) { testCtlV2Set(t, &configTLS, false) }
+func testCtlV2Set(t *testing.T, cfg *etcdProcessClusterConfig, quorum bool) {
+ defer testutil.AfterTest(t)
+
+ epc := setupEtcdctlTest(t, cfg, quorum)
+ defer func() {
+ if errC := epc.Close(); errC != nil {
+ t.Fatalf("error closing etcd processes (%v)", errC)
+ }
+ }()
+
+ key, value := "foo", "bar"
+
+ if err := etcdctlSet(epc, key, value); err != nil {
+ t.Fatalf("failed set (%v)", err)
+ }
+
+ if err := etcdctlGet(epc, key, value, quorum); err != nil {
+ t.Fatalf("failed get (%v)", err)
+ }
+}
+
+func TestCtlV2Mk(t *testing.T) { testCtlV2Mk(t, &configNoTLS, false) }
+func TestCtlV2MkQuorum(t *testing.T) { testCtlV2Mk(t, &configNoTLS, true) }
+func TestCtlV2MkTLS(t *testing.T) { testCtlV2Mk(t, &configTLS, false) }
+func testCtlV2Mk(t *testing.T, cfg *etcdProcessClusterConfig, quorum bool) {
+ defer testutil.AfterTest(t)
+
+ epc := setupEtcdctlTest(t, cfg, quorum)
+ defer func() {
+ if errC := epc.Close(); errC != nil {
+ t.Fatalf("error closing etcd processes (%v)", errC)
+ }
+ }()
+
+ key, value := "foo", "bar"
+
+ if err := etcdctlMk(epc, key, value, true); err != nil {
+ t.Fatalf("failed mk (%v)", err)
+ }
+ if err := etcdctlMk(epc, key, value, false); err != nil {
+ t.Fatalf("failed mk (%v)", err)
+ }
+
+ if err := etcdctlGet(epc, key, value, quorum); err != nil {
+ t.Fatalf("failed get (%v)", err)
+ }
+}
+
+func TestCtlV2Rm(t *testing.T) { testCtlV2Rm(t, &configNoTLS) }
+func TestCtlV2RmTLS(t *testing.T) { testCtlV2Rm(t, &configTLS) }
+func testCtlV2Rm(t *testing.T, cfg *etcdProcessClusterConfig) {
+ defer testutil.AfterTest(t)
+
+ epc := setupEtcdctlTest(t, cfg, true)
+ defer func() {
+ if errC := epc.Close(); errC != nil {
+ t.Fatalf("error closing etcd processes (%v)", errC)
+ }
+ }()
+
+ key, value := "foo", "bar"
+
+ if err := etcdctlSet(epc, key, value); err != nil {
+ t.Fatalf("failed set (%v)", err)
+ }
+
+ if err := etcdctlRm(epc, key, value, true); err != nil {
+ t.Fatalf("failed rm (%v)", err)
+ }
+ if err := etcdctlRm(epc, key, value, false); err != nil {
+ t.Fatalf("failed rm (%v)", err)
+ }
+}
+
+func TestCtlV2Ls(t *testing.T) { testCtlV2Ls(t, &configNoTLS, false) }
+func TestCtlV2LsQuorum(t *testing.T) { testCtlV2Ls(t, &configNoTLS, true) }
+func TestCtlV2LsTLS(t *testing.T) { testCtlV2Ls(t, &configTLS, false) }
+func testCtlV2Ls(t *testing.T, cfg *etcdProcessClusterConfig, quorum bool) {
+ defer testutil.AfterTest(t)
+
+ epc := setupEtcdctlTest(t, cfg, quorum)
+ defer func() {
+ if errC := epc.Close(); errC != nil {
+ t.Fatalf("error closing etcd processes (%v)", errC)
+ }
+ }()
+
+ key, value := "foo", "bar"
+
+ if err := etcdctlSet(epc, key, value); err != nil {
+ t.Fatalf("failed set (%v)", err)
+ }
+
+ if err := etcdctlLs(epc, key, quorum); err != nil {
+ t.Fatalf("failed ls (%v)", err)
+ }
+}
+
+func TestCtlV2Watch(t *testing.T) { testCtlV2Watch(t, &configNoTLS, false) }
+func TestCtlV2WatchTLS(t *testing.T) { testCtlV2Watch(t, &configTLS, false) }
+func TestCtlV2WatchWithProxy(t *testing.T) { testCtlV2Watch(t, &configWithProxy, false) }
+func TestCtlV2WatchWithProxyNoSync(t *testing.T) { testCtlV2Watch(t, &configWithProxy, true) }
+func testCtlV2Watch(t *testing.T, cfg *etcdProcessClusterConfig, noSync bool) {
+ defer testutil.AfterTest(t)
+
+ epc := setupEtcdctlTest(t, cfg, true)
+ defer func() {
+ if errC := epc.Close(); errC != nil {
+ t.Fatalf("error closing etcd processes (%v)", errC)
+ }
+ }()
+
+ key, value := "foo", "bar"
+ errc := etcdctlWatch(epc, key, value, noSync)
+ if err := etcdctlSet(epc, key, value); err != nil {
+ t.Fatalf("failed set (%v)", err)
+ }
+
+ select {
+ case err := <-errc:
+ if err != nil {
+ t.Fatalf("failed watch (%v)", err)
+ }
+ case <-time.After(5 * time.Second):
+ t.Fatalf("watch timed out")
+ }
+}
+
+func TestCtlV2GetRoleUser(t *testing.T) { testCtlV2GetRoleUser(t, &configNoTLS) }
+func TestCtlV2GetRoleUserWithProxy(t *testing.T) { testCtlV2GetRoleUser(t, &configWithProxy) }
+func testCtlV2GetRoleUser(t *testing.T, cfg *etcdProcessClusterConfig) {
+ defer testutil.AfterTest(t)
+
+ epc := setupEtcdctlTest(t, cfg, true)
+ defer func() {
+ if err := epc.Close(); err != nil {
+ t.Fatalf("error closing etcd processes (%v)", err)
+ }
+ }()
+
+ if err := etcdctlRoleAdd(epc, "foo"); err != nil {
+ t.Fatalf("failed to add role (%v)", err)
+ }
+ if err := etcdctlUserAdd(epc, "username", "password"); err != nil {
+ t.Fatalf("failed to add user (%v)", err)
+ }
+ if err := etcdctlUserGrant(epc, "username", "foo"); err != nil {
+ t.Fatalf("failed to grant role (%v)", err)
+ }
+ if err := etcdctlUserGet(epc, "username"); err != nil {
+ t.Fatalf("failed to get user (%v)", err)
+ }
+
+ // ensure double grant gives an error; was crashing in 2.3.1
+ regrantArgs := etcdctlPrefixArgs(epc)
+ regrantArgs = append(regrantArgs, "user", "grant", "--roles", "foo", "username")
+ if err := spawnWithExpect(regrantArgs, "duplicate"); err != nil {
+ t.Fatalf("missing duplicate error on double grant role (%v)", err)
+ }
+}
+
+func TestCtlV2UserListUsername(t *testing.T) { testCtlV2UserList(t, "username") }
+func TestCtlV2UserListRoot(t *testing.T) { testCtlV2UserList(t, "root") }
+func testCtlV2UserList(t *testing.T, username string) {
+ defer testutil.AfterTest(t)
+
+ epc := setupEtcdctlTest(t, &configWithProxy, false)
+ defer func() {
+ if err := epc.Close(); err != nil {
+ t.Fatalf("error closing etcd processes (%v)", err)
+ }
+ }()
+
+ if err := etcdctlUserAdd(epc, username, "password"); err != nil {
+ t.Fatalf("failed to add user (%v)", err)
+ }
+ if err := etcdctlUserList(epc, username); err != nil {
+ t.Fatalf("failed to list users (%v)", err)
+ }
+}
+
+func TestCtlV2RoleList(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ epc := setupEtcdctlTest(t, &configWithProxy, false)
+ defer func() {
+ if err := epc.Close(); err != nil {
+ t.Fatalf("error closing etcd processes (%v)", err)
+ }
+ }()
+
+ if err := etcdctlRoleAdd(epc, "foo"); err != nil {
+ t.Fatalf("failed to add role (%v)", err)
+ }
+ if err := etcdctlRoleList(epc, "foo"); err != nil {
+ t.Fatalf("failed to list roles (%v)", err)
+ }
+}
+
+func TestCtlV2Backup(t *testing.T) { // For https://github.com/coreos/etcd/issues/5360
+ defer testutil.AfterTest(t)
+
+ backupDir, err := ioutil.TempDir("", "testbackup0.etcd")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(backupDir)
+
+ epc1 := setupEtcdctlTest(t, &configNoTLS, false)
+ if err := etcdctlSet(epc1, "foo1", "bar"); err != nil {
+ t.Fatal(err)
+ }
+
+ if err := etcdctlBackup(epc1, epc1.procs[0].cfg.dataDirPath, backupDir); err != nil {
+ t.Fatal(err)
+ }
+
+ if err := epc1.Close(); err != nil {
+ t.Fatalf("error closing etcd processes (%v)", err)
+ }
+
+ // restart from the backup directory
+ cfg2 := configNoTLS
+ cfg2.dataDirPath = backupDir
+ cfg2.keepDataDir = true
+ cfg2.forceNewCluster = true
+ epc2 := setupEtcdctlTest(t, &cfg2, false)
+
+ // check if backup went through correctly
+ if err := etcdctlGet(epc2, "foo1", "bar", false); err != nil {
+ t.Fatal(err)
+ }
+
+ // check if it can serve client requests
+ if err := etcdctlSet(epc2, "foo2", "bar"); err != nil {
+ t.Fatal(err)
+ }
+ if err := etcdctlGet(epc2, "foo2", "bar", false); err != nil {
+ t.Fatal(err)
+ }
+
+ if err := epc2.Close(); err != nil {
+ t.Fatalf("error closing etcd processes (%v)", err)
+ }
+}
+
+func TestCtlV2AuthWithCommonName(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ copiedCfg := configClientTLS
+ copiedCfg.clientCertAuthEnabled = true
+
+ epc := setupEtcdctlTest(t, &copiedCfg, false)
+ defer func() {
+ if err := epc.Close(); err != nil {
+ t.Fatalf("error closing etcd processes (%v)", err)
+ }
+ }()
+
+ if err := etcdctlRoleAdd(epc, "testrole"); err != nil {
+ t.Fatalf("failed to add role (%v)", err)
+ }
+ if err := etcdctlRoleGrant(epc, "testrole", "--rw", "--path=/foo"); err != nil {
+ t.Fatalf("failed to grant role (%v)", err)
+ }
+ if err := etcdctlUserAdd(epc, "root", "123"); err != nil {
+ t.Fatalf("failed to add user (%v)", err)
+ }
+ if err := etcdctlUserAdd(epc, "Autogenerated CA", "123"); err != nil {
+ t.Fatalf("failed to add user (%v)", err)
+ }
+ if err := etcdctlUserGrant(epc, "Autogenerated CA", "testrole"); err != nil {
+ t.Fatalf("failed to grant role (%v)", err)
+ }
+ if err := etcdctlAuthEnable(epc); err != nil {
+ t.Fatalf("failed to enable auth (%v)", err)
+ }
+ if err := etcdctlSet(epc, "foo", "bar"); err != nil {
+ t.Fatalf("failed to write (%v)", err)
+ }
+}
+
+func TestCtlV2ClusterHealth(t *testing.T) {
+ defer testutil.AfterTest(t)
+ epc := setupEtcdctlTest(t, &configNoTLS, true)
+ defer func() {
+ if err := epc.Close(); err != nil {
+ t.Fatalf("error closing etcd processes (%v)", err)
+ }
+ }()
+
+ // has quorum
+ if err := etcdctlClusterHealth(epc, "cluster is healthy"); err != nil {
+ t.Fatalf("cluster-health expected to be healthy (%v)", err)
+ }
+
+ // cut quorum
+ epc.procs[0].Stop()
+ epc.procs[1].Stop()
+ if err := etcdctlClusterHealth(epc, "cluster is unhealthy"); err != nil {
+ t.Fatalf("cluster-health expected to be unhealthy (%v)", err)
+ }
+ epc.procs[0], epc.procs[1] = nil, nil
+}
+
+func etcdctlPrefixArgs(clus *etcdProcessCluster) []string {
+ endpoints := ""
+ if proxies := clus.proxies(); len(proxies) != 0 {
+ endpoints = proxies[0].cfg.acurl
+ } else if processes := clus.processes(); len(processes) != 0 {
+ es := []string{}
+ for _, b := range processes {
+ es = append(es, b.cfg.acurl)
+ }
+ endpoints = strings.Join(es, ",")
+ }
+ cmdArgs := []string{ctlBinPath, "--endpoints", endpoints}
+ if clus.cfg.clientTLS == clientTLS {
+ cmdArgs = append(cmdArgs, "--ca-file", caPath, "--cert-file", certPath, "--key-file", privateKeyPath)
+ }
+ return cmdArgs
+}
+
+func etcdctlClusterHealth(clus *etcdProcessCluster, val string) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "cluster-health")
+ return spawnWithExpect(cmdArgs, val)
+}
+
+func etcdctlSet(clus *etcdProcessCluster, key, value string) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "set", key, value)
+ return spawnWithExpect(cmdArgs, value)
+}
+
+func etcdctlMk(clus *etcdProcessCluster, key, value string, first bool) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "mk", key, value)
+ if first {
+ return spawnWithExpect(cmdArgs, value)
+ }
+ return spawnWithExpect(cmdArgs, "Error: 105: Key already exists")
+}
+
+func etcdctlGet(clus *etcdProcessCluster, key, value string, quorum bool) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "get", key)
+ if quorum {
+ cmdArgs = append(cmdArgs, "--quorum")
+ }
+ return spawnWithExpect(cmdArgs, value)
+}
+
+func etcdctlRm(clus *etcdProcessCluster, key, value string, first bool) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "rm", key)
+ if first {
+ return spawnWithExpect(cmdArgs, "PrevNode.Value: "+value)
+ }
+ return spawnWithExpect(cmdArgs, "Error: 100: Key not found")
+}
+
+func etcdctlLs(clus *etcdProcessCluster, key string, quorum bool) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "ls")
+ if quorum {
+ cmdArgs = append(cmdArgs, "--quorum")
+ }
+ return spawnWithExpect(cmdArgs, key)
+}
+
+func etcdctlWatch(clus *etcdProcessCluster, key, value string, noSync bool) <-chan error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "watch", "--after-index=1", key)
+ if noSync {
+ cmdArgs = append(cmdArgs, "--no-sync")
+ }
+ errc := make(chan error, 1)
+ go func() {
+ errc <- spawnWithExpect(cmdArgs, value)
+ }()
+ return errc
+}
+
+func etcdctlRoleAdd(clus *etcdProcessCluster, role string) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "role", "add", role)
+ return spawnWithExpect(cmdArgs, role)
+}
+
+func etcdctlRoleGrant(clus *etcdProcessCluster, role string, perms ...string) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "role", "grant")
+ cmdArgs = append(cmdArgs, perms...)
+ cmdArgs = append(cmdArgs, role)
+ return spawnWithExpect(cmdArgs, role)
+}
+
+func etcdctlRoleList(clus *etcdProcessCluster, expectedRole string) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "role", "list")
+ return spawnWithExpect(cmdArgs, expectedRole)
+}
+
+func etcdctlUserAdd(clus *etcdProcessCluster, user, pass string) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "user", "add", user+":"+pass)
+ return spawnWithExpect(cmdArgs, "User "+user+" created")
+}
+
+func etcdctlUserGrant(clus *etcdProcessCluster, user, role string) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "user", "grant", "--roles", role, user)
+ return spawnWithExpect(cmdArgs, "User "+user+" updated")
+}
+
+func etcdctlUserGet(clus *etcdProcessCluster, user string) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "user", "get", user)
+ return spawnWithExpect(cmdArgs, "User: "+user)
+}
+
+func etcdctlUserList(clus *etcdProcessCluster, expectedUser string) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "user", "list")
+ return spawnWithExpect(cmdArgs, expectedUser)
+}
+
+func etcdctlAuthEnable(clus *etcdProcessCluster) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "auth", "enable")
+ return spawnWithExpect(cmdArgs, "Authentication Enabled")
+}
+
+func etcdctlBackup(clus *etcdProcessCluster, dataDir, backupDir string) error {
+ cmdArgs := append(etcdctlPrefixArgs(clus), "backup", "--data-dir", dataDir, "--backup-dir", backupDir)
+ return spawnWithExpects(cmdArgs)
+}
+
+func mustEtcdctl(t *testing.T) {
+ if !fileutil.Exist(binDir + "/etcdctl") {
+ t.Fatalf("could not find etcdctl binary")
+ }
+}
+
+func setupEtcdctlTest(t *testing.T, cfg *etcdProcessClusterConfig, quorum bool) *etcdProcessCluster {
+ mustEtcdctl(t)
+ if !quorum {
+ cfg = configStandalone(*cfg)
+ }
+ epc, err := newEtcdProcessCluster(cfg)
+ if err != nil {
+ t.Fatalf("could not start etcd process cluster (%v)", err)
+ }
+ return epc
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_alarm_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_alarm_test.go
new file mode 100644
index 00000000..a8555400
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_alarm_test.go
@@ -0,0 +1,100 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "os"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "golang.org/x/net/context"
+)
+
+func TestCtlV3Alarm(t *testing.T) {
+ // The boltdb minimum working set is six pages.
+ testCtl(t, alarmTest, withQuota(int64(13*os.Getpagesize())))
+}
+
+func alarmTest(cx ctlCtx) {
+ // test small put still works
+ smallbuf := strings.Repeat("a", 64)
+ if err := ctlV3Put(cx, "1st_test", smallbuf, ""); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // write some chunks to fill up the database
+ buf := strings.Repeat("b", int(os.Getpagesize()))
+ for {
+ if err := ctlV3Put(cx, "2nd_test", buf, ""); err != nil {
+ if !strings.Contains(err.Error(), "etcdserver: mvcc: database space exceeded") {
+ cx.t.Fatal(err)
+ }
+ break
+ }
+ }
+
+ // quota alarm should now be on
+ if err := ctlV3Alarm(cx, "list", "alarm:NOSPACE"); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // check that Put is rejected when alarm is on
+ if err := ctlV3Put(cx, "3rd_test", smallbuf, ""); err != nil {
+ if !strings.Contains(err.Error(), "etcdserver: mvcc: database space exceeded") {
+ cx.t.Fatal(err)
+ }
+ }
+
+ eps := cx.epc.grpcEndpoints()
+
+ // get latest revision to compact
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: eps,
+ DialTimeout: 3 * time.Second,
+ })
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+ defer cli.Close()
+ sresp, err := cli.Status(context.TODO(), eps[0])
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // make some space
+ if err := ctlV3Compact(cx, sresp.Header.Revision, true); err != nil {
+ cx.t.Fatal(err)
+ }
+ if err := ctlV3Defrag(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // turn off alarm
+ if err := ctlV3Alarm(cx, "disarm", "alarm:NOSPACE"); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // put one more key below quota
+ if err := ctlV3Put(cx, "4th_test", smallbuf, ""); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func ctlV3Alarm(cx ctlCtx, cmd string, as ...string) error {
+ cmdArgs := append(cx.PrefixArgs(), "alarm", cmd)
+ return spawnWithExpects(cmdArgs, as...)
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_auth_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_auth_test.go
new file mode 100644
index 00000000..1028cfd6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_auth_test.go
@@ -0,0 +1,741 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/coreos/etcd/clientv3"
+)
+
+func TestCtlV3AuthEnable(t *testing.T) { testCtl(t, authEnableTest) }
+func TestCtlV3AuthDisable(t *testing.T) { testCtl(t, authDisableTest) }
+func TestCtlV3AuthWriteKey(t *testing.T) { testCtl(t, authCredWriteKeyTest) }
+func TestCtlV3AuthRoleUpdate(t *testing.T) { testCtl(t, authRoleUpdateTest) }
+func TestCtlV3AuthUserDeleteDuringOps(t *testing.T) { testCtl(t, authUserDeleteDuringOpsTest) }
+func TestCtlV3AuthRoleRevokeDuringOps(t *testing.T) { testCtl(t, authRoleRevokeDuringOpsTest) }
+func TestCtlV3AuthTxn(t *testing.T) { testCtl(t, authTestTxn) }
+func TestCtlV3AuthPerfixPerm(t *testing.T) { testCtl(t, authTestPrefixPerm) }
+func TestCtlV3AuthMemberAdd(t *testing.T) { testCtl(t, authTestMemberAdd) }
+func TestCtlV3AuthMemberRemove(t *testing.T) {
+ testCtl(t, authTestMemberRemove, withQuorum(), withNoStrictReconfig())
+}
+func TestCtlV3AuthMemberUpdate(t *testing.T) { testCtl(t, authTestMemberUpdate) }
+func TestCtlV3AuthCertCN(t *testing.T) { testCtl(t, authTestCertCN, withCfg(configClientTLSCertAuth)) }
+func TestCtlV3AuthRevokeWithDelete(t *testing.T) { testCtl(t, authTestRevokeWithDelete) }
+func TestCtlV3AuthInvalidMgmt(t *testing.T) { testCtl(t, authTestInvalidMgmt) }
+func TestCtlV3AuthFromKeyPerm(t *testing.T) { testCtl(t, authTestFromKeyPerm) }
+func TestCtlV3AuthAndWatch(t *testing.T) { testCtl(t, authTestWatch) }
+
+func authEnableTest(cx ctlCtx) {
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func authEnable(cx ctlCtx) error {
+ // create root user with root role
+ if err := ctlV3User(cx, []string{"add", "root", "--interactive=false"}, "User root created", []string{"root"}); err != nil {
+ return fmt.Errorf("failed to create root user %v", err)
+ }
+ if err := ctlV3User(cx, []string{"grant-role", "root", "root"}, "Role root is granted to user root", nil); err != nil {
+ return fmt.Errorf("failed to grant root user root role %v", err)
+ }
+ if err := ctlV3AuthEnable(cx); err != nil {
+ return fmt.Errorf("authEnableTest ctlV3AuthEnable error (%v)", err)
+ }
+ return nil
+}
+
+func ctlV3AuthEnable(cx ctlCtx) error {
+ cmdArgs := append(cx.PrefixArgs(), "auth", "enable")
+ return spawnWithExpect(cmdArgs, "Authentication Enabled")
+}
+
+func authDisableTest(cx ctlCtx) {
+ // a key that isn't granted to test-user
+ if err := ctlV3Put(cx, "hoo", "a", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ // test-user doesn't have the permission, it must fail
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3PutFailPerm(cx, "hoo", "bar"); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ if err := ctlV3AuthDisable(cx); err != nil {
+ cx.t.Fatalf("authDisableTest ctlV3AuthDisable error (%v)", err)
+ }
+
+ // now ErrAuthNotEnabled of Authenticate() is simply ignored
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3Put(cx, "hoo", "bar", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // now the key can be accessed
+ cx.user, cx.pass = "", ""
+ if err := ctlV3Put(cx, "hoo", "bar", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ // confirm put succeeded
+ if err := ctlV3Get(cx, []string{"hoo"}, []kv{{"hoo", "bar"}}...); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func ctlV3AuthDisable(cx ctlCtx) error {
+ cmdArgs := append(cx.PrefixArgs(), "auth", "disable")
+ return spawnWithExpect(cmdArgs, "Authentication Disabled")
+}
+
+func authCredWriteKeyTest(cx ctlCtx) {
+ // baseline key to check for failed puts
+ if err := ctlV3Put(cx, "foo", "a", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ // confirm root role can access to all keys
+ if err := ctlV3Put(cx, "foo", "bar", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ if err := ctlV3Get(cx, []string{"foo"}, []kv{{"foo", "bar"}}...); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // try invalid user
+ cx.user, cx.pass = "a", "b"
+ if err := ctlV3PutFailAuth(cx, "foo", "bar"); err != nil {
+ cx.t.Fatal(err)
+ }
+ // confirm put failed
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3Get(cx, []string{"foo"}, []kv{{"foo", "bar"}}...); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // try good user
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3Put(cx, "foo", "bar2", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ // confirm put succeeded
+ if err := ctlV3Get(cx, []string{"foo"}, []kv{{"foo", "bar2"}}...); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // try bad password
+ cx.user, cx.pass = "test-user", "badpass"
+ if err := ctlV3PutFailAuth(cx, "foo", "baz"); err != nil {
+ cx.t.Fatal(err)
+ }
+ // confirm put failed
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3Get(cx, []string{"foo"}, []kv{{"foo", "bar2"}}...); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func authRoleUpdateTest(cx ctlCtx) {
+ if err := ctlV3Put(cx, "foo", "bar", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ // try put to not granted key
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3PutFailPerm(cx, "hoo", "bar"); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // grant a new key
+ cx.user, cx.pass = "root", "root"
+ if err := ctlV3RoleGrantPermission(cx, "test-role", grantingPerm{true, true, "hoo", "", false}); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // try a newly granted key
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3Put(cx, "hoo", "bar", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ // confirm put succeeded
+ if err := ctlV3Get(cx, []string{"hoo"}, []kv{{"hoo", "bar"}}...); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // revoke the newly granted key
+ cx.user, cx.pass = "root", "root"
+ if err := ctlV3RoleRevokePermission(cx, "test-role", "hoo", "", false); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // try put to the revoked key
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3PutFailPerm(cx, "hoo", "bar"); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // confirm a key still granted can be accessed
+ if err := ctlV3Get(cx, []string{"foo"}, []kv{{"foo", "bar"}}...); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func authUserDeleteDuringOpsTest(cx ctlCtx) {
+ if err := ctlV3Put(cx, "foo", "bar", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ // create a key
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3Put(cx, "foo", "bar", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ // confirm put succeeded
+ if err := ctlV3Get(cx, []string{"foo"}, []kv{{"foo", "bar"}}...); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // delete the user
+ cx.user, cx.pass = "root", "root"
+ err := ctlV3User(cx, []string{"delete", "test-user"}, "User test-user deleted", []string{})
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // check the user is deleted
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3PutFailAuth(cx, "foo", "baz"); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func authRoleRevokeDuringOpsTest(cx ctlCtx) {
+ if err := ctlV3Put(cx, "foo", "bar", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ // create a key
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3Put(cx, "foo", "bar", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ // confirm put succeeded
+ if err := ctlV3Get(cx, []string{"foo"}, []kv{{"foo", "bar"}}...); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // create a new role
+ cx.user, cx.pass = "root", "root"
+ if err := ctlV3Role(cx, []string{"add", "test-role2"}, "Role test-role2 created"); err != nil {
+ cx.t.Fatal(err)
+ }
+ // grant a new key to the new role
+ if err := ctlV3RoleGrantPermission(cx, "test-role2", grantingPerm{true, true, "hoo", "", false}); err != nil {
+ cx.t.Fatal(err)
+ }
+ // grant the new role to the user
+ if err := ctlV3User(cx, []string{"grant-role", "test-user", "test-role2"}, "Role test-role2 is granted to user test-user", nil); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // try a newly granted key
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3Put(cx, "hoo", "bar", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ // confirm put succeeded
+ if err := ctlV3Get(cx, []string{"hoo"}, []kv{{"hoo", "bar"}}...); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // revoke a role from the user
+ cx.user, cx.pass = "root", "root"
+ err := ctlV3User(cx, []string{"revoke-role", "test-user", "test-role"}, "Role test-role is revoked from user test-user", []string{})
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // check the role is revoked and permission is lost from the user
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3PutFailPerm(cx, "foo", "baz"); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // try a key that can be accessed from the remaining role
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3Put(cx, "hoo", "bar2", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ // confirm put succeeded
+ if err := ctlV3Get(cx, []string{"hoo"}, []kv{{"hoo", "bar2"}}...); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func ctlV3PutFailAuth(cx ctlCtx, key, val string) error {
+ return spawnWithExpect(append(cx.PrefixArgs(), "put", key, val), "authentication failed")
+}
+
+func ctlV3PutFailPerm(cx ctlCtx, key, val string) error {
+ return spawnWithExpect(append(cx.PrefixArgs(), "put", key, val), "permission denied")
+}
+
+func authSetupTestUser(cx ctlCtx) {
+ if err := ctlV3User(cx, []string{"add", "test-user", "--interactive=false"}, "User test-user created", []string{"pass"}); err != nil {
+ cx.t.Fatal(err)
+ }
+ if err := spawnWithExpect(append(cx.PrefixArgs(), "role", "add", "test-role"), "Role test-role created"); err != nil {
+ cx.t.Fatal(err)
+ }
+ if err := ctlV3User(cx, []string{"grant-role", "test-user", "test-role"}, "Role test-role is granted to user test-user", nil); err != nil {
+ cx.t.Fatal(err)
+ }
+ cmd := append(cx.PrefixArgs(), "role", "grant-permission", "test-role", "readwrite", "foo")
+ if err := spawnWithExpect(cmd, "Role test-role updated"); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func authTestTxn(cx ctlCtx) {
+ // keys with 1 suffix aren't granted to test-user
+ // keys with 2 suffix are granted to test-user
+
+ keys := []string{"c1", "s1", "f1"}
+ grantedKeys := []string{"c2", "s2", "f2"}
+ for _, key := range keys {
+ if err := ctlV3Put(cx, key, "v", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ }
+
+ for _, key := range grantedKeys {
+ if err := ctlV3Put(cx, key, "v", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ }
+
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ // grant keys to test-user
+ cx.user, cx.pass = "root", "root"
+ for _, key := range grantedKeys {
+ if err := ctlV3RoleGrantPermission(cx, "test-role", grantingPerm{true, true, key, "", false}); err != nil {
+ cx.t.Fatal(err)
+ }
+ }
+
+ // now test txn
+ cx.interactive = true
+ cx.user, cx.pass = "test-user", "pass"
+
+ rqs := txnRequests{
+ compare: []string{`version("c2") = "1"`},
+ ifSucess: []string{"get s2"},
+ ifFail: []string{"get f2"},
+ results: []string{"SUCCESS", "s2", "v"},
+ }
+ if err := ctlV3Txn(cx, rqs); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // a key of compare case isn't granted
+ rqs = txnRequests{
+ compare: []string{`version("c1") = "1"`},
+ ifSucess: []string{"get s2"},
+ ifFail: []string{"get f2"},
+ results: []string{"Error: etcdserver: permission denied"},
+ }
+ if err := ctlV3Txn(cx, rqs); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // a key of success case isn't granted
+ rqs = txnRequests{
+ compare: []string{`version("c2") = "1"`},
+ ifSucess: []string{"get s1"},
+ ifFail: []string{"get f2"},
+ results: []string{"Error: etcdserver: permission denied"},
+ }
+ if err := ctlV3Txn(cx, rqs); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // a key of failure case isn't granted
+ rqs = txnRequests{
+ compare: []string{`version("c2") = "1"`},
+ ifSucess: []string{"get s2"},
+ ifFail: []string{"get f1"},
+ results: []string{"Error: etcdserver: permission denied"},
+ }
+ if err := ctlV3Txn(cx, rqs); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func authTestPrefixPerm(cx ctlCtx) {
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ prefix := "/prefix/" // directory like prefix
+ // grant keys to test-user
+ cx.user, cx.pass = "root", "root"
+ if err := ctlV3RoleGrantPermission(cx, "test-role", grantingPerm{true, true, prefix, "", true}); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // try a prefix granted permission
+ cx.user, cx.pass = "test-user", "pass"
+ for i := 0; i < 10; i++ {
+ key := fmt.Sprintf("%s%d", prefix, i)
+ if err := ctlV3Put(cx, key, "val", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ }
+
+ if err := ctlV3PutFailPerm(cx, clientv3.GetPrefixRangeEnd(prefix), "baz"); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func authTestMemberAdd(cx ctlCtx) {
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ peerURL := fmt.Sprintf("http://localhost:%d", etcdProcessBasePort+11)
+ // ordinary user cannot add a new member
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3MemberAdd(cx, peerURL); err == nil {
+ cx.t.Fatalf("ordinary user must not be allowed to add a member")
+ }
+
+ // root can add a new member
+ cx.user, cx.pass = "root", "root"
+ if err := ctlV3MemberAdd(cx, peerURL); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func authTestMemberRemove(cx ctlCtx) {
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ ep, memIDToRemove, clusterID := cx.memberToRemove()
+
+ // ordinary user cannot remove a member
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3MemberRemove(cx, ep, memIDToRemove, clusterID); err == nil {
+ cx.t.Fatalf("ordinary user must not be allowed to remove a member")
+ }
+
+ // root can remove a member
+ cx.user, cx.pass = "root", "root"
+ if err := ctlV3MemberRemove(cx, ep, memIDToRemove, clusterID); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func authTestMemberUpdate(cx ctlCtx) {
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ mr, err := getMemberList(cx)
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // ordinary user cannot update a member
+ cx.user, cx.pass = "test-user", "pass"
+ peerURL := fmt.Sprintf("http://localhost:%d", etcdProcessBasePort+11)
+ memberID := fmt.Sprintf("%x", mr.Members[0].ID)
+ if err = ctlV3MemberUpdate(cx, memberID, peerURL); err == nil {
+ cx.t.Fatalf("ordinary user must not be allowed to update a member")
+ }
+
+ // root can update a member
+ cx.user, cx.pass = "root", "root"
+ if err = ctlV3MemberUpdate(cx, memberID, peerURL); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func authTestCertCN(cx ctlCtx) {
+ if err := ctlV3User(cx, []string{"add", "etcd", "--interactive=false"}, "User etcd created", []string{""}); err != nil {
+ cx.t.Fatal(err)
+ }
+ if err := spawnWithExpect(append(cx.PrefixArgs(), "role", "add", "test-role"), "Role test-role created"); err != nil {
+ cx.t.Fatal(err)
+ }
+ if err := ctlV3User(cx, []string{"grant-role", "etcd", "test-role"}, "Role test-role is granted to user etcd", nil); err != nil {
+ cx.t.Fatal(err)
+ }
+ cmd := append(cx.PrefixArgs(), "role", "grant-permission", "test-role", "readwrite", "foo")
+ if err := spawnWithExpect(cmd, "Role test-role updated"); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // grant a new key
+ if err := ctlV3RoleGrantPermission(cx, "test-role", grantingPerm{true, true, "hoo", "", false}); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // try a granted key
+ cx.user, cx.pass = "", ""
+ if err := ctlV3Put(cx, "hoo", "bar", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // try a non granted key
+ cx.user, cx.pass = "", ""
+ if err := ctlV3PutFailPerm(cx, "baz", "bar"); err == nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func authTestRevokeWithDelete(cx ctlCtx) {
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ // create a new role
+ cx.user, cx.pass = "root", "root"
+ if err := ctlV3Role(cx, []string{"add", "test-role2"}, "Role test-role2 created"); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // grant the new role to the user
+ if err := ctlV3User(cx, []string{"grant-role", "test-user", "test-role2"}, "Role test-role2 is granted to user test-user", nil); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // check the result
+ if err := ctlV3User(cx, []string{"get", "test-user"}, "Roles: test-role test-role2", nil); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // delete the role, test-role2 must be revoked from test-user
+ if err := ctlV3Role(cx, []string{"delete", "test-role2"}, "Role test-role2 deleted"); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // check the result
+ if err := ctlV3User(cx, []string{"get", "test-user"}, "Roles: test-role", nil); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func authTestInvalidMgmt(cx ctlCtx) {
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ if err := ctlV3Role(cx, []string{"delete", "root"}, "Error: etcdserver: invalid auth management"); err == nil {
+ cx.t.Fatal("deleting the role root must not be allowed")
+ }
+
+ if err := ctlV3User(cx, []string{"revoke-role", "root", "root"}, "Error: etcdserver: invalid auth management", []string{}); err == nil {
+ cx.t.Fatal("revoking the role root from the user root must not be allowed")
+ }
+}
+
+func authTestFromKeyPerm(cx ctlCtx) {
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ // grant keys after z to test-user
+ cx.user, cx.pass = "root", "root"
+ if err := ctlV3RoleGrantPermission(cx, "test-role", grantingPerm{true, true, "z", "\x00", false}); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // try the granted open ended permission
+ cx.user, cx.pass = "test-user", "pass"
+ for i := 0; i < 10; i++ {
+ key := fmt.Sprintf("z%d", i)
+ if err := ctlV3Put(cx, key, "val", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ }
+ largeKey := ""
+ for i := 0; i < 10; i++ {
+ largeKey += "\xff"
+ if err := ctlV3Put(cx, largeKey, "val", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ }
+
+ // try a non granted key
+ if err := ctlV3PutFailPerm(cx, "x", "baz"); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // revoke the open ended permission
+ cx.user, cx.pass = "root", "root"
+ if err := ctlV3RoleRevokePermission(cx, "test-role", "z", "", true); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // try the revoked open ended permission
+ cx.user, cx.pass = "test-user", "pass"
+ for i := 0; i < 10; i++ {
+ key := fmt.Sprintf("z%d", i)
+ if err := ctlV3PutFailPerm(cx, key, "val"); err != nil {
+ cx.t.Fatal(err)
+ }
+ }
+}
+
+func authTestWatch(cx ctlCtx) {
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ // grant a key range
+ if err := ctlV3RoleGrantPermission(cx, "test-role", grantingPerm{true, true, "key", "key4", false}); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ tests := []struct {
+ puts []kv
+ args []string
+
+ wkv []kv
+ want bool
+ }{
+ { // watch 1 key, should be successful
+ []kv{{"key", "value"}},
+ []string{"key", "--rev", "1"},
+ []kv{{"key", "value"}},
+ true,
+ },
+ { // watch 3 keys by range, should be successful
+ []kv{{"key1", "val1"}, {"key3", "val3"}, {"key2", "val2"}},
+ []string{"key", "key3", "--rev", "1"},
+ []kv{{"key1", "val1"}, {"key2", "val2"}},
+ true,
+ },
+
+ { // watch 1 key, should not be successful
+ []kv{},
+ []string{"key5", "--rev", "1"},
+ []kv{},
+ false,
+ },
+ { // watch 3 keys by range, should not be successful
+ []kv{},
+ []string{"key", "key6", "--rev", "1"},
+ []kv{},
+ false,
+ },
+ }
+
+ cx.user, cx.pass = "test-user", "pass"
+ for i, tt := range tests {
+ donec := make(chan struct{})
+ go func(i int, puts []kv) {
+ defer close(donec)
+ for j := range puts {
+ if err := ctlV3Put(cx, puts[j].key, puts[j].val, ""); err != nil {
+ cx.t.Fatalf("watchTest #%d-%d: ctlV3Put error (%v)", i, j, err)
+ }
+ }
+ }(i, tt.puts)
+
+ var err error
+ if tt.want {
+ err = ctlV3Watch(cx, tt.args, tt.wkv...)
+ } else {
+ err = ctlV3WatchFailPerm(cx, tt.args)
+ }
+
+ if err != nil {
+ if cx.dialTimeout > 0 && !isGRPCTimedout(err) {
+ cx.t.Errorf("watchTest #%d: ctlV3Watch error (%v)", i, err)
+ }
+ }
+
+ <-donec
+ }
+
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_compact_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_compact_test.go
new file mode 100644
index 00000000..5b0c51eb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_compact_test.go
@@ -0,0 +1,75 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "strconv"
+ "strings"
+ "testing"
+)
+
+func TestCtlV3Compact(t *testing.T) { testCtl(t, compactTest) }
+func TestCtlV3CompactPhysical(t *testing.T) { testCtl(t, compactTest, withCompactPhysical()) }
+
+func compactTest(cx ctlCtx) {
+ compactPhysical := cx.compactPhysical
+ if err := ctlV3Compact(cx, 2, compactPhysical); err != nil {
+ if !strings.Contains(err.Error(), "required revision is a future revision") {
+ cx.t.Fatal(err)
+ }
+ } else {
+ cx.t.Fatalf("expected '...future revision' error, got <nil>")
+ }
+
+ var kvs = []kv{{"key", "val1"}, {"key", "val2"}, {"key", "val3"}}
+ for i := range kvs {
+ if err := ctlV3Put(cx, kvs[i].key, kvs[i].val, ""); err != nil {
+ cx.t.Fatalf("compactTest #%d: ctlV3Put error (%v)", i, err)
+ }
+ }
+
+ if err := ctlV3Get(cx, []string{"key", "--rev", "3"}, kvs[1:2]...); err != nil {
+ cx.t.Errorf("compactTest: ctlV3Get error (%v)", err)
+ }
+
+ if err := ctlV3Compact(cx, 4, compactPhysical); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ if err := ctlV3Get(cx, []string{"key", "--rev", "3"}, kvs[1:2]...); err != nil {
+ if !strings.Contains(err.Error(), "required revision has been compacted") {
+ cx.t.Errorf("compactTest: ctlV3Get error (%v)", err)
+ }
+ } else {
+ cx.t.Fatalf("expected '...has been compacted' error, got <nil>")
+ }
+
+ if err := ctlV3Compact(cx, 2, compactPhysical); err != nil {
+ if !strings.Contains(err.Error(), "required revision has been compacted") {
+ cx.t.Fatal(err)
+ }
+ } else {
+ cx.t.Fatalf("expected '...has been compacted' error, got <nil>")
+ }
+}
+
+func ctlV3Compact(cx ctlCtx, rev int64, physical bool) error {
+ rs := strconv.FormatInt(rev, 10)
+ cmdArgs := append(cx.PrefixArgs(), "compact", rs)
+ if physical {
+ cmdArgs = append(cmdArgs, "--physical")
+ }
+ return spawnWithExpect(cmdArgs, "compacted revision "+rs)
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_defrag_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_defrag_test.go
new file mode 100644
index 00000000..cc197d36
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_defrag_test.go
@@ -0,0 +1,73 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import "testing"
+
+func TestCtlV3Defrag(t *testing.T) { testCtl(t, defragTest) }
+func TestCtlV3DefragWithAuth(t *testing.T) { testCtl(t, defragTestWithAuth) }
+
+func maintenanceInitKeys(cx ctlCtx) {
+ var kvs = []kv{{"key", "val1"}, {"key", "val2"}, {"key", "val3"}}
+ for i := range kvs {
+ if err := ctlV3Put(cx, kvs[i].key, kvs[i].val, ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ }
+}
+
+func defragTest(cx ctlCtx) {
+ maintenanceInitKeys(cx)
+
+ if err := ctlV3Compact(cx, 4, cx.compactPhysical); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ if err := ctlV3Defrag(cx); err != nil {
+ cx.t.Fatalf("defragTest ctlV3Defrag error (%v)", err)
+ }
+}
+
+func defragTestWithAuth(cx ctlCtx) {
+ maintenanceInitKeys(cx)
+
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ // ordinary user cannot defrag
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3Defrag(cx); err == nil {
+ cx.t.Fatal("ordinary user should not be able to issue a defrag request")
+ }
+
+ // root can defrag
+ cx.user, cx.pass = "root", "root"
+ if err := ctlV3Defrag(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func ctlV3Defrag(cx ctlCtx) error {
+ cmdArgs := append(cx.PrefixArgs(), "defrag")
+ lines := make([]string, cx.epc.cfg.clusterSize)
+ for i := range lines {
+ lines[i] = "Finished defragmenting etcd member"
+ }
+ return spawnWithExpects(cmdArgs, lines...)
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_elect_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_elect_test.go
new file mode 100644
index 00000000..2c9c986d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_elect_test.go
@@ -0,0 +1,124 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "os"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/expect"
+)
+
+func TestCtlV3Elect(t *testing.T) {
+ oldenv := os.Getenv("EXPECT_DEBUG")
+ defer os.Setenv("EXPECT_DEBUG", oldenv)
+ os.Setenv("EXPECT_DEBUG", "1")
+
+ testCtl(t, testElect)
+}
+
+func testElect(cx ctlCtx) {
+ // debugging for #6934
+ sig := cx.epc.withStopSignal(debugLockSignal)
+ defer cx.epc.withStopSignal(sig)
+
+ name := "a"
+
+ holder, ch, err := ctlV3Elect(cx, name, "p1")
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+
+ l1 := ""
+ select {
+ case <-time.After(2 * time.Second):
+ cx.t.Fatalf("timed out electing")
+ case l1 = <-ch:
+ if !strings.HasPrefix(l1, name) {
+ cx.t.Errorf("got %q, expected %q prefix", l1, name)
+ }
+ }
+
+ // blocked process that won't win the election
+ blocked, ch, err := ctlV3Elect(cx, name, "p2")
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+ select {
+ case <-time.After(100 * time.Millisecond):
+ case <-ch:
+ cx.t.Fatalf("should block")
+ }
+
+ // overlap with a blocker that will win the election
+ blockAcquire, ch, err := ctlV3Elect(cx, name, "p2")
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+ defer blockAcquire.Stop()
+ select {
+ case <-time.After(100 * time.Millisecond):
+ case <-ch:
+ cx.t.Fatalf("should block")
+ }
+
+ // kill blocked process with clean shutdown
+ if err = blocked.Signal(os.Interrupt); err != nil {
+ cx.t.Fatal(err)
+ }
+ if err = closeWithTimeout(blocked, time.Second); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // kill the holder with clean shutdown
+ if err = holder.Signal(os.Interrupt); err != nil {
+ cx.t.Fatal(err)
+ }
+ if err = closeWithTimeout(holder, time.Second); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // blockAcquire should win the election
+ select {
+ case <-time.After(time.Second):
+ cx.t.Fatalf("timed out from waiting to holding")
+ case l2 := <-ch:
+ if l1 == l2 || !strings.HasPrefix(l2, name) {
+ cx.t.Fatalf("expected different elect name, got l1=%q, l2=%q", l1, l2)
+ }
+ }
+}
+
+// ctlV3Elect creates a elect process with a channel listening for when it wins the election.
+func ctlV3Elect(cx ctlCtx, name, proposal string) (*expect.ExpectProcess, <-chan string, error) {
+ cmdArgs := append(cx.PrefixArgs(), "elect", name, proposal)
+ proc, err := spawnCmd(cmdArgs)
+ outc := make(chan string, 1)
+ if err != nil {
+ close(outc)
+ return proc, outc, err
+ }
+ proc.StopSignal = debugLockSignal
+ go func() {
+ s, xerr := proc.ExpectFunc(func(string) bool { return true })
+ if xerr != nil {
+ cx.t.Errorf("expect failed (%v)", xerr)
+ }
+ outc <- s
+ }()
+ return proc, outc, err
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_endpoint_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_endpoint_test.go
new file mode 100644
index 00000000..3a42c1c9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_endpoint_test.go
@@ -0,0 +1,86 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "net/url"
+ "testing"
+)
+
+func TestCtlV3EndpointHealth(t *testing.T) { testCtl(t, endpointHealthTest, withQuorum()) }
+func TestCtlV3EndpointStatus(t *testing.T) { testCtl(t, endpointStatusTest, withQuorum()) }
+func TestCtlV3EndpointHealthWithAuth(t *testing.T) {
+ testCtl(t, endpointHealthTestWithAuth, withQuorum())
+}
+
+func endpointHealthTest(cx ctlCtx) {
+ if err := ctlV3EndpointHealth(cx); err != nil {
+ cx.t.Fatalf("endpointStatusTest ctlV3EndpointHealth error (%v)", err)
+ }
+}
+
+func ctlV3EndpointHealth(cx ctlCtx) error {
+ cmdArgs := append(cx.PrefixArgs(), "endpoint", "health")
+ lines := make([]string, cx.epc.cfg.clusterSize)
+ for i := range lines {
+ lines[i] = "is healthy"
+ }
+ return spawnWithExpects(cmdArgs, lines...)
+}
+
+func endpointStatusTest(cx ctlCtx) {
+ if err := ctlV3EndpointStatus(cx); err != nil {
+ cx.t.Fatalf("endpointStatusTest ctlV3EndpointStatus error (%v)", err)
+ }
+}
+
+func ctlV3EndpointStatus(cx ctlCtx) error {
+ cmdArgs := append(cx.PrefixArgs(), "endpoint", "status")
+ var eps []string
+ for _, ep := range cx.epc.endpoints() {
+ u, _ := url.Parse(ep)
+ eps = append(eps, u.Host)
+ }
+ return spawnWithExpects(cmdArgs, eps...)
+}
+
+func endpointHealthTestWithAuth(cx ctlCtx) {
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ if err := ctlV3EndpointHealth(cx); err != nil {
+ cx.t.Fatalf("endpointStatusTest ctlV3EndpointHealth error (%v)", err)
+ }
+
+ // health checking with an ordinary user "succeeds" since permission denial goes through consensus
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3EndpointHealth(cx); err != nil {
+ cx.t.Fatalf("endpointStatusTest ctlV3EndpointHealth error (%v)", err)
+ }
+
+ // succeed if permissions granted for ordinary user
+ cx.user, cx.pass = "root", "root"
+ if err := ctlV3RoleGrantPermission(cx, "test-role", grantingPerm{true, true, "health", "", false}); err != nil {
+ cx.t.Fatal(err)
+ }
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3EndpointHealth(cx); err != nil {
+ cx.t.Fatalf("endpointStatusTest ctlV3EndpointHealth error (%v)", err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_kv_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_kv_test.go
new file mode 100644
index 00000000..1fcc38ec
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_kv_test.go
@@ -0,0 +1,317 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "fmt"
+ "testing"
+)
+
+func TestCtlV3Put(t *testing.T) { testCtl(t, putTest) }
+func TestCtlV3PutNoTLS(t *testing.T) { testCtl(t, putTest, withCfg(configNoTLS)) }
+func TestCtlV3PutClientTLS(t *testing.T) { testCtl(t, putTest, withCfg(configClientTLS)) }
+func TestCtlV3PutClientAutoTLS(t *testing.T) { testCtl(t, putTest, withCfg(configClientAutoTLS)) }
+func TestCtlV3PutPeerTLS(t *testing.T) { testCtl(t, putTest, withCfg(configPeerTLS)) }
+func TestCtlV3PutTimeout(t *testing.T) { testCtl(t, putTest, withDialTimeout(0)) }
+func TestCtlV3PutClientTLSFlagByEnv(t *testing.T) {
+ testCtl(t, putTest, withCfg(configClientTLS), withFlagByEnv())
+}
+func TestCtlV3PutIgnoreValue(t *testing.T) { testCtl(t, putTestIgnoreValue) }
+func TestCtlV3PutIgnoreLease(t *testing.T) { testCtl(t, putTestIgnoreLease) }
+
+func TestCtlV3Get(t *testing.T) { testCtl(t, getTest) }
+func TestCtlV3GetNoTLS(t *testing.T) { testCtl(t, getTest, withCfg(configNoTLS)) }
+func TestCtlV3GetClientTLS(t *testing.T) { testCtl(t, getTest, withCfg(configClientTLS)) }
+func TestCtlV3GetClientAutoTLS(t *testing.T) { testCtl(t, getTest, withCfg(configClientAutoTLS)) }
+func TestCtlV3GetPeerTLS(t *testing.T) { testCtl(t, getTest, withCfg(configPeerTLS)) }
+func TestCtlV3GetTimeout(t *testing.T) { testCtl(t, getTest, withDialTimeout(0)) }
+func TestCtlV3GetQuorum(t *testing.T) { testCtl(t, getTest, withQuorum()) }
+
+func TestCtlV3GetFormat(t *testing.T) { testCtl(t, getFormatTest) }
+func TestCtlV3GetRev(t *testing.T) { testCtl(t, getRevTest) }
+func TestCtlV3GetKeysOnly(t *testing.T) { testCtl(t, getKeysOnlyTest) }
+
+func TestCtlV3Del(t *testing.T) { testCtl(t, delTest) }
+func TestCtlV3DelNoTLS(t *testing.T) { testCtl(t, delTest, withCfg(configNoTLS)) }
+func TestCtlV3DelClientTLS(t *testing.T) { testCtl(t, delTest, withCfg(configClientTLS)) }
+func TestCtlV3DelPeerTLS(t *testing.T) { testCtl(t, delTest, withCfg(configPeerTLS)) }
+func TestCtlV3DelTimeout(t *testing.T) { testCtl(t, delTest, withDialTimeout(0)) }
+
+func putTest(cx ctlCtx) {
+ key, value := "foo", "bar"
+
+ if err := ctlV3Put(cx, key, value, ""); err != nil {
+ if cx.dialTimeout > 0 && !isGRPCTimedout(err) {
+ cx.t.Fatalf("putTest ctlV3Put error (%v)", err)
+ }
+ }
+ if err := ctlV3Get(cx, []string{key}, kv{key, value}); err != nil {
+ if cx.dialTimeout > 0 && !isGRPCTimedout(err) {
+ cx.t.Fatalf("putTest ctlV3Get error (%v)", err)
+ }
+ }
+}
+
+func putTestIgnoreValue(cx ctlCtx) {
+ if err := ctlV3Put(cx, "foo", "bar", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ if err := ctlV3Get(cx, []string{"foo"}, kv{"foo", "bar"}); err != nil {
+ cx.t.Fatal(err)
+ }
+ if err := ctlV3Put(cx, "foo", "", "", "--ignore-value"); err != nil {
+ cx.t.Fatal(err)
+ }
+ if err := ctlV3Get(cx, []string{"foo"}, kv{"foo", "bar"}); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func putTestIgnoreLease(cx ctlCtx) {
+ leaseID, err := ctlV3LeaseGrant(cx, 10)
+ if err != nil {
+ cx.t.Fatalf("putTestIgnoreLease: ctlV3LeaseGrant error (%v)", err)
+ }
+ if err := ctlV3Put(cx, "foo", "bar", leaseID); err != nil {
+ cx.t.Fatalf("putTestIgnoreLease: ctlV3Put error (%v)", err)
+ }
+ if err := ctlV3Get(cx, []string{"foo"}, kv{"foo", "bar"}); err != nil {
+ cx.t.Fatalf("putTestIgnoreLease: ctlV3Get error (%v)", err)
+ }
+ if err := ctlV3Put(cx, "foo", "bar1", "", "--ignore-lease"); err != nil {
+ cx.t.Fatalf("putTestIgnoreLease: ctlV3Put error (%v)", err)
+ }
+ if err := ctlV3Get(cx, []string{"foo"}, kv{"foo", "bar1"}); err != nil {
+ cx.t.Fatalf("putTestIgnoreLease: ctlV3Get error (%v)", err)
+ }
+ if err := ctlV3LeaseRevoke(cx, leaseID); err != nil {
+ cx.t.Fatalf("putTestIgnoreLease: ctlV3LeaseRevok error (%v)", err)
+ }
+ if err := ctlV3Get(cx, []string{"key"}); err != nil { // expect no output
+ cx.t.Fatalf("putTestIgnoreLease: ctlV3Get error (%v)", err)
+ }
+}
+
+func getTest(cx ctlCtx) {
+ var (
+ kvs = []kv{{"key1", "val1"}, {"key2", "val2"}, {"key3", "val3"}}
+ revkvs = []kv{{"key3", "val3"}, {"key2", "val2"}, {"key1", "val1"}}
+ )
+ for i := range kvs {
+ if err := ctlV3Put(cx, kvs[i].key, kvs[i].val, ""); err != nil {
+ cx.t.Fatalf("getTest #%d: ctlV3Put error (%v)", i, err)
+ }
+ }
+
+ tests := []struct {
+ args []string
+
+ wkv []kv
+ }{
+ {[]string{"key1"}, []kv{{"key1", "val1"}}},
+ {[]string{"", "--prefix"}, kvs},
+ {[]string{"", "--from-key"}, kvs},
+ {[]string{"key", "--prefix"}, kvs},
+ {[]string{"key", "--prefix", "--limit=2"}, kvs[:2]},
+ {[]string{"key", "--prefix", "--order=ASCEND", "--sort-by=MODIFY"}, kvs},
+ {[]string{"key", "--prefix", "--order=ASCEND", "--sort-by=VERSION"}, kvs},
+ {[]string{"key", "--prefix", "--sort-by=CREATE"}, kvs}, // ASCEND by default
+ {[]string{"key", "--prefix", "--order=DESCEND", "--sort-by=CREATE"}, revkvs},
+ {[]string{"key", "--prefix", "--order=DESCEND", "--sort-by=KEY"}, revkvs},
+ }
+ for i, tt := range tests {
+ if err := ctlV3Get(cx, tt.args, tt.wkv...); err != nil {
+ if cx.dialTimeout > 0 && !isGRPCTimedout(err) {
+ cx.t.Errorf("getTest #%d: ctlV3Get error (%v)", i, err)
+ }
+ }
+ }
+}
+
+func getFormatTest(cx ctlCtx) {
+ if err := ctlV3Put(cx, "abc", "123", ""); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ tests := []struct {
+ format string
+ valueOnly bool
+
+ wstr string
+ }{
+ {"simple", false, "abc"},
+ {"simple", true, "123"},
+ {"json", false, `"kvs":[{"key":"YWJj"`},
+ {"protobuf", false, "\x17\b\x93\xe7\xf6\x93\xd4?\xe14\x10\xed"},
+ }
+
+ for i, tt := range tests {
+ cmdArgs := append(cx.PrefixArgs(), "get")
+ cmdArgs = append(cmdArgs, "--write-out="+tt.format)
+ if tt.valueOnly {
+ cmdArgs = append(cmdArgs, "--print-value-only")
+ }
+ cmdArgs = append(cmdArgs, "abc")
+ if err := spawnWithExpect(cmdArgs, tt.wstr); err != nil {
+ cx.t.Errorf("#%d: error (%v), wanted %v", i, err, tt.wstr)
+ }
+ }
+}
+
+func getRevTest(cx ctlCtx) {
+ var (
+ kvs = []kv{{"key", "val1"}, {"key", "val2"}, {"key", "val3"}}
+ )
+ for i := range kvs {
+ if err := ctlV3Put(cx, kvs[i].key, kvs[i].val, ""); err != nil {
+ cx.t.Fatalf("getRevTest #%d: ctlV3Put error (%v)", i, err)
+ }
+ }
+
+ tests := []struct {
+ args []string
+
+ wkv []kv
+ }{
+ {[]string{"key", "--rev", "2"}, kvs[:1]},
+ {[]string{"key", "--rev", "3"}, kvs[1:2]},
+ {[]string{"key", "--rev", "4"}, kvs[2:]},
+ }
+
+ for i, tt := range tests {
+ if err := ctlV3Get(cx, tt.args, tt.wkv...); err != nil {
+ cx.t.Errorf("getTest #%d: ctlV3Get error (%v)", i, err)
+ }
+ }
+}
+
+func getKeysOnlyTest(cx ctlCtx) {
+ var (
+ kvs = []kv{{"key1", "val1"}}
+ )
+ for i := range kvs {
+ if err := ctlV3Put(cx, kvs[i].key, kvs[i].val, ""); err != nil {
+ cx.t.Fatalf("getKeysOnlyTest #%d: ctlV3Put error (%v)", i, err)
+ }
+ }
+
+ cmdArgs := append(cx.PrefixArgs(), "get")
+ cmdArgs = append(cmdArgs, []string{"--prefix", "--keys-only", "key"}...)
+
+ err := spawnWithExpects(cmdArgs, []string{"key1", ""}...)
+ if err != nil {
+ cx.t.Fatalf("getKeysOnlyTest : error (%v)", err)
+ }
+}
+
+func delTest(cx ctlCtx) {
+ tests := []struct {
+ puts []kv
+ args []string
+
+ deletedNum int
+ }{
+ { // delete all keys
+ []kv{{"foo1", "bar"}, {"foo2", "bar"}, {"foo3", "bar"}},
+ []string{"", "--prefix"},
+ 3,
+ },
+ { // delete all keys
+ []kv{{"foo1", "bar"}, {"foo2", "bar"}, {"foo3", "bar"}},
+ []string{"", "--from-key"},
+ 3,
+ },
+ {
+ []kv{{"this", "value"}},
+ []string{"that"},
+ 0,
+ },
+ {
+ []kv{{"sample", "value"}},
+ []string{"sample"},
+ 1,
+ },
+ {
+ []kv{{"key1", "val1"}, {"key2", "val2"}, {"key3", "val3"}},
+ []string{"key", "--prefix"},
+ 3,
+ },
+ {
+ []kv{{"zoo1", "bar"}, {"zoo2", "bar2"}, {"zoo3", "bar3"}},
+ []string{"zoo1", "--from-key"},
+ 3,
+ },
+ }
+
+ for i, tt := range tests {
+ for j := range tt.puts {
+ if err := ctlV3Put(cx, tt.puts[j].key, tt.puts[j].val, ""); err != nil {
+ cx.t.Fatalf("delTest #%d-%d: ctlV3Put error (%v)", i, j, err)
+ }
+ }
+ if err := ctlV3Del(cx, tt.args, tt.deletedNum); err != nil {
+ if cx.dialTimeout > 0 && !isGRPCTimedout(err) {
+ cx.t.Fatalf("delTest #%d: ctlV3Del error (%v)", i, err)
+ }
+ }
+ }
+}
+
+func ctlV3Put(cx ctlCtx, key, value, leaseID string, flags ...string) error {
+ skipValue := false
+ skipLease := false
+ for _, f := range flags {
+ if f == "--ignore-value" {
+ skipValue = true
+ }
+ if f == "--ignore-lease" {
+ skipLease = true
+ }
+ }
+ cmdArgs := append(cx.PrefixArgs(), "put", key)
+ if !skipValue {
+ cmdArgs = append(cmdArgs, value)
+ }
+ if leaseID != "" && !skipLease {
+ cmdArgs = append(cmdArgs, "--lease", leaseID)
+ }
+ if len(flags) != 0 {
+ cmdArgs = append(cmdArgs, flags...)
+ }
+ return spawnWithExpect(cmdArgs, "OK")
+}
+
+type kv struct {
+ key, val string
+}
+
+func ctlV3Get(cx ctlCtx, args []string, kvs ...kv) error {
+ cmdArgs := append(cx.PrefixArgs(), "get")
+ cmdArgs = append(cmdArgs, args...)
+ if !cx.quorum {
+ cmdArgs = append(cmdArgs, "--consistency", "s")
+ }
+ var lines []string
+ for _, elem := range kvs {
+ lines = append(lines, elem.key, elem.val)
+ }
+ return spawnWithExpects(cmdArgs, lines...)
+}
+
+func ctlV3Del(cx ctlCtx, args []string, num int) error {
+ cmdArgs := append(cx.PrefixArgs(), "del")
+ cmdArgs = append(cmdArgs, args...)
+ return spawnWithExpects(cmdArgs, fmt.Sprintf("%d", num))
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_lease_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_lease_test.go
new file mode 100644
index 00000000..d27060a6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_lease_test.go
@@ -0,0 +1,128 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "fmt"
+ "strconv"
+ "strings"
+ "testing"
+)
+
+func TestCtlV3LeaseGrantTimeToLive(t *testing.T) { testCtl(t, leaseTestGrantTimeToLive) }
+func TestCtlV3LeaseKeepAlive(t *testing.T) { testCtl(t, leaseTestKeepAlive) }
+func TestCtlV3LeaseRevoke(t *testing.T) { testCtl(t, leaseTestRevoke) }
+
+func leaseTestGrantTimeToLive(cx ctlCtx) {
+ id, err := ctlV3LeaseGrant(cx, 10)
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cmdArgs := append(cx.PrefixArgs(), "lease", "timetolive", id, "--keys")
+ proc, err := spawnCmd(cmdArgs)
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+ line, err := proc.Expect(" granted with TTL(")
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+ if err = proc.Close(); err != nil {
+ cx.t.Fatal(err)
+ }
+ if !strings.Contains(line, ", attached keys") {
+ cx.t.Fatalf("expected 'attached keys', got %q", line)
+ }
+ if !strings.Contains(line, id) {
+ cx.t.Fatalf("expected leaseID %q, got %q", id, line)
+ }
+}
+
+func leaseTestKeepAlive(cx ctlCtx) {
+ // put with TTL 10 seconds and keep-alive
+ leaseID, err := ctlV3LeaseGrant(cx, 10)
+ if err != nil {
+ cx.t.Fatalf("leaseTestKeepAlive: ctlV3LeaseGrant error (%v)", err)
+ }
+ if err := ctlV3Put(cx, "key", "val", leaseID); err != nil {
+ cx.t.Fatalf("leaseTestKeepAlive: ctlV3Put error (%v)", err)
+ }
+ if err := ctlV3LeaseKeepAlive(cx, leaseID); err != nil {
+ cx.t.Fatalf("leaseTestKeepAlive: ctlV3LeaseKeepAlive error (%v)", err)
+ }
+ if err := ctlV3Get(cx, []string{"key"}, kv{"key", "val"}); err != nil {
+ cx.t.Fatalf("leaseTestKeepAlive: ctlV3Get error (%v)", err)
+ }
+}
+
+func leaseTestRevoke(cx ctlCtx) {
+ // put with TTL 10 seconds and revoke
+ leaseID, err := ctlV3LeaseGrant(cx, 10)
+ if err != nil {
+ cx.t.Fatalf("leaseTestRevoke: ctlV3LeaseGrant error (%v)", err)
+ }
+ if err := ctlV3Put(cx, "key", "val", leaseID); err != nil {
+ cx.t.Fatalf("leaseTestRevoke: ctlV3Put error (%v)", err)
+ }
+ if err := ctlV3LeaseRevoke(cx, leaseID); err != nil {
+ cx.t.Fatalf("leaseTestRevoke: ctlV3LeaseRevok error (%v)", err)
+ }
+ if err := ctlV3Get(cx, []string{"key"}); err != nil { // expect no output
+ cx.t.Fatalf("leaseTestRevoke: ctlV3Get error (%v)", err)
+ }
+}
+
+func ctlV3LeaseGrant(cx ctlCtx, ttl int) (string, error) {
+ cmdArgs := append(cx.PrefixArgs(), "lease", "grant", strconv.Itoa(ttl))
+ proc, err := spawnCmd(cmdArgs)
+ if err != nil {
+ return "", err
+ }
+
+ line, err := proc.Expect(" granted with TTL(")
+ if err != nil {
+ return "", err
+ }
+ if err = proc.Close(); err != nil {
+ return "", err
+ }
+
+ // parse 'line LEASE_ID granted with TTL(5s)' to get lease ID
+ hs := strings.Split(line, " ")
+ if len(hs) < 2 {
+ return "", fmt.Errorf("lease grant failed with %q", line)
+ }
+ return hs[1], nil
+}
+
+func ctlV3LeaseKeepAlive(cx ctlCtx, leaseID string) error {
+ cmdArgs := append(cx.PrefixArgs(), "lease", "keep-alive", leaseID)
+
+ proc, err := spawnCmd(cmdArgs)
+ if err != nil {
+ return err
+ }
+
+ if _, err = proc.Expect(fmt.Sprintf("lease %s keepalived with TTL(", leaseID)); err != nil {
+ return err
+ }
+ return proc.Stop()
+}
+
+func ctlV3LeaseRevoke(cx ctlCtx, leaseID string) error {
+ cmdArgs := append(cx.PrefixArgs(), "lease", "revoke", leaseID)
+ return spawnWithExpect(cmdArgs, fmt.Sprintf("lease %s revoked", leaseID))
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_lock_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_lock_test.go
new file mode 100644
index 00000000..416f26d8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_lock_test.go
@@ -0,0 +1,147 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "os"
+ "runtime"
+ "strings"
+ "syscall"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/expect"
+)
+
+// debugLockSignal forces SIGQUIT to debug etcdctl elect and lock failures
+var debugLockSignal os.Signal
+
+func init() {
+ // hacks to ignore SIGQUIT debugging for some builds
+ switch {
+ case os.Getenv("COVERDIR") != "":
+ // SIGQUIT interferes with coverage collection
+ debugLockSignal = syscall.SIGTERM
+ case runtime.GOARCH == "ppc64le":
+ // ppc64le's signal handling won't kill processes with SIGQUIT
+ // in the same way as amd64/i386, so processes won't terminate
+ // as expected. Since this debugging code for CI, just ignore
+ // ppc64le.
+ debugLockSignal = syscall.SIGKILL
+ default:
+ // stack dumping OK
+ debugLockSignal = syscall.SIGQUIT
+ }
+}
+
+func TestCtlV3Lock(t *testing.T) {
+ oldenv := os.Getenv("EXPECT_DEBUG")
+ defer os.Setenv("EXPECT_DEBUG", oldenv)
+ os.Setenv("EXPECT_DEBUG", "1")
+
+ testCtl(t, testLock)
+}
+
+func testLock(cx ctlCtx) {
+ // debugging for #6464
+ sig := cx.epc.withStopSignal(debugLockSignal)
+ defer cx.epc.withStopSignal(sig)
+
+ name := "a"
+
+ holder, ch, err := ctlV3Lock(cx, name)
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+
+ l1 := ""
+ select {
+ case <-time.After(2 * time.Second):
+ cx.t.Fatalf("timed out locking")
+ case l1 = <-ch:
+ if !strings.HasPrefix(l1, name) {
+ cx.t.Errorf("got %q, expected %q prefix", l1, name)
+ }
+ }
+
+ // blocked process that won't acquire the lock
+ blocked, ch, err := ctlV3Lock(cx, name)
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+ select {
+ case <-time.After(100 * time.Millisecond):
+ case <-ch:
+ cx.t.Fatalf("should block")
+ }
+
+ // overlap with a blocker that will acquire the lock
+ blockAcquire, ch, err := ctlV3Lock(cx, name)
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+ defer blockAcquire.Stop()
+ select {
+ case <-time.After(100 * time.Millisecond):
+ case <-ch:
+ cx.t.Fatalf("should block")
+ }
+
+ // kill blocked process with clean shutdown
+ if err = blocked.Signal(os.Interrupt); err != nil {
+ cx.t.Fatal(err)
+ }
+ if err = closeWithTimeout(blocked, time.Second); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // kill the holder with clean shutdown
+ if err = holder.Signal(os.Interrupt); err != nil {
+ cx.t.Fatal(err)
+ }
+ if err = closeWithTimeout(holder, time.Second); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ // blockAcquire should acquire the lock
+ select {
+ case <-time.After(time.Second):
+ cx.t.Fatalf("timed out from waiting to holding")
+ case l2 := <-ch:
+ if l1 == l2 || !strings.HasPrefix(l2, name) {
+ cx.t.Fatalf("expected different lock name, got l1=%q, l2=%q", l1, l2)
+ }
+ }
+}
+
+// ctlV3Lock creates a lock process with a channel listening for when it acquires the lock.
+func ctlV3Lock(cx ctlCtx, name string) (*expect.ExpectProcess, <-chan string, error) {
+ cmdArgs := append(cx.PrefixArgs(), "lock", name)
+ proc, err := spawnCmd(cmdArgs)
+ outc := make(chan string, 1)
+ if err != nil {
+ close(outc)
+ return proc, outc, err
+ }
+ proc.StopSignal = debugLockSignal
+ go func() {
+ s, xerr := proc.ExpectFunc(func(string) bool { return true })
+ if xerr != nil {
+ cx.t.Errorf("expect failed (%v)", xerr)
+ }
+ outc <- s
+ }()
+ return proc, outc, err
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_make_mirror_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_make_mirror_test.go
new file mode 100644
index 00000000..8bb92e1d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_make_mirror_test.go
@@ -0,0 +1,108 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "fmt"
+ "testing"
+ "time"
+)
+
+func TestCtlV3MakeMirror(t *testing.T) { testCtl(t, makeMirrorTest) }
+func TestCtlV3MakeMirrorModifyDestPrefix(t *testing.T) { testCtl(t, makeMirrorModifyDestPrefixTest) }
+func TestCtlV3MakeMirrorNoDestPrefix(t *testing.T) { testCtl(t, makeMirrorNoDestPrefixTest) }
+
+func makeMirrorTest(cx ctlCtx) {
+ var (
+ flags = []string{}
+ kvs = []kv{{"key1", "val1"}, {"key2", "val2"}, {"key3", "val3"}}
+ prefix = "key"
+ )
+ testMirrorCommand(cx, flags, kvs, kvs, prefix, prefix)
+}
+
+func makeMirrorModifyDestPrefixTest(cx ctlCtx) {
+ var (
+ flags = []string{"--prefix", "o_", "--dest-prefix", "d_"}
+ kvs = []kv{{"o_key1", "val1"}, {"o_key2", "val2"}, {"o_key3", "val3"}}
+ kvs2 = []kv{{"d_key1", "val1"}, {"d_key2", "val2"}, {"d_key3", "val3"}}
+ srcprefix = "o_"
+ destprefix = "d_"
+ )
+ testMirrorCommand(cx, flags, kvs, kvs2, srcprefix, destprefix)
+}
+
+func makeMirrorNoDestPrefixTest(cx ctlCtx) {
+ var (
+ flags = []string{"--prefix", "o_", "--no-dest-prefix"}
+ kvs = []kv{{"o_key1", "val1"}, {"o_key2", "val2"}, {"o_key3", "val3"}}
+ kvs2 = []kv{{"key1", "val1"}, {"key2", "val2"}, {"key3", "val3"}}
+ srcprefix = "o_"
+ destprefix = "key"
+ )
+
+ testMirrorCommand(cx, flags, kvs, kvs2, srcprefix, destprefix)
+}
+
+func testMirrorCommand(cx ctlCtx, flags []string, sourcekvs, destkvs []kv, srcprefix, destprefix string) {
+ // set up another cluster to mirror with
+ mirrorcfg := configAutoTLS
+ mirrorcfg.clusterSize = 1
+ mirrorcfg.basePort = 10000
+ mirrorctx := ctlCtx{
+ t: cx.t,
+ cfg: mirrorcfg,
+ dialTimeout: 7 * time.Second,
+ }
+
+ mirrorepc, err := newEtcdProcessCluster(&mirrorctx.cfg)
+ if err != nil {
+ cx.t.Fatalf("could not start etcd process cluster (%v)", err)
+ }
+ mirrorctx.epc = mirrorepc
+
+ defer func() {
+ if err = mirrorctx.epc.Close(); err != nil {
+ cx.t.Fatalf("error closing etcd processes (%v)", err)
+ }
+ }()
+
+ cmdArgs := append(cx.PrefixArgs(), "make-mirror")
+ cmdArgs = append(cmdArgs, flags...)
+ cmdArgs = append(cmdArgs, fmt.Sprintf("localhost:%d", mirrorcfg.basePort))
+ proc, err := spawnCmd(cmdArgs)
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+ defer func() {
+ err = proc.Stop()
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+ }()
+
+ for i := range sourcekvs {
+ if err = ctlV3Put(cx, sourcekvs[i].key, sourcekvs[i].val, ""); err != nil {
+ cx.t.Fatal(err)
+ }
+ }
+ if err = ctlV3Get(cx, []string{srcprefix, "--prefix"}, sourcekvs...); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ if err = ctlV3Watch(mirrorctx, []string{destprefix, "--rev", "1", "--prefix"}, destkvs...); err != nil {
+ cx.t.Fatal(err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_member_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_member_test.go
new file mode 100644
index 00000000..dfd3f799
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_member_test.go
@@ -0,0 +1,112 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "encoding/json"
+ "fmt"
+ "io"
+ "strings"
+ "testing"
+
+ "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+func TestCtlV3MemberList(t *testing.T) { testCtl(t, memberListTest) }
+func TestCtlV3MemberRemove(t *testing.T) {
+ testCtl(t, memberRemoveTest, withQuorum(), withNoStrictReconfig())
+}
+func TestCtlV3MemberAdd(t *testing.T) { testCtl(t, memberAddTest) }
+func TestCtlV3MemberUpdate(t *testing.T) { testCtl(t, memberUpdateTest) }
+
+func memberListTest(cx ctlCtx) {
+ if err := ctlV3MemberList(cx); err != nil {
+ cx.t.Fatalf("memberListTest ctlV3MemberList error (%v)", err)
+ }
+}
+
+func ctlV3MemberList(cx ctlCtx) error {
+ cmdArgs := append(cx.PrefixArgs(), "member", "list")
+ lines := make([]string, cx.cfg.clusterSize)
+ for i := range lines {
+ lines[i] = "started"
+ }
+ return spawnWithExpects(cmdArgs, lines...)
+}
+
+func getMemberList(cx ctlCtx) (etcdserverpb.MemberListResponse, error) {
+ cmdArgs := append(cx.PrefixArgs(), "--write-out", "json", "member", "list")
+
+ proc, err := spawnCmd(cmdArgs)
+ if err != nil {
+ return etcdserverpb.MemberListResponse{}, err
+ }
+ var txt string
+ txt, err = proc.Expect("members")
+ if err != nil {
+ return etcdserverpb.MemberListResponse{}, err
+ }
+ if err = proc.Close(); err != nil {
+ return etcdserverpb.MemberListResponse{}, err
+ }
+
+ resp := etcdserverpb.MemberListResponse{}
+ dec := json.NewDecoder(strings.NewReader(txt))
+ if err := dec.Decode(&resp); err == io.EOF {
+ return etcdserverpb.MemberListResponse{}, err
+ }
+ return resp, nil
+}
+
+func memberRemoveTest(cx ctlCtx) {
+ ep, memIDToRemove, clusterID := cx.memberToRemove()
+ if err := ctlV3MemberRemove(cx, ep, memIDToRemove, clusterID); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func ctlV3MemberRemove(cx ctlCtx, ep, memberID, clusterID string) error {
+ cmdArgs := append(cx.prefixArgs([]string{ep}), "member", "remove", memberID)
+ return spawnWithExpect(cmdArgs, fmt.Sprintf("%s removed from cluster %s", memberID, clusterID))
+}
+
+func memberAddTest(cx ctlCtx) {
+ if err := ctlV3MemberAdd(cx, fmt.Sprintf("http://localhost:%d", etcdProcessBasePort+11)); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func ctlV3MemberAdd(cx ctlCtx, peerURL string) error {
+ cmdArgs := append(cx.PrefixArgs(), "member", "add", "newmember", fmt.Sprintf("--peer-urls=%s", peerURL))
+ return spawnWithExpect(cmdArgs, " added to cluster ")
+}
+
+func memberUpdateTest(cx ctlCtx) {
+ mr, err := getMemberList(cx)
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+
+ peerURL := fmt.Sprintf("http://localhost:%d", etcdProcessBasePort+11)
+ memberID := fmt.Sprintf("%x", mr.Members[0].ID)
+ if err = ctlV3MemberUpdate(cx, memberID, peerURL); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+func ctlV3MemberUpdate(cx ctlCtx, memberID, peerURL string) error {
+ cmdArgs := append(cx.PrefixArgs(), "member", "update", memberID, fmt.Sprintf("--peer-urls=%s", peerURL))
+ return spawnWithExpect(cmdArgs, " updated in cluster ")
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_migrate_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_migrate_test.go
new file mode 100644
index 00000000..3136c492
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_migrate_test.go
@@ -0,0 +1,100 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "fmt"
+ "os"
+ "testing"
+ "time"
+
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestCtlV3Migrate(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ epc := setupEtcdctlTest(t, &configNoTLS, false)
+ defer func() {
+ if errC := epc.Close(); errC != nil {
+ t.Fatalf("error closing etcd processes (%v)", errC)
+ }
+ }()
+
+ keys := make([]string, 3)
+ vals := make([]string, 3)
+ for i := range keys {
+ keys[i] = fmt.Sprintf("foo_%d", i)
+ vals[i] = fmt.Sprintf("bar_%d", i)
+ }
+ for i := range keys {
+ if err := etcdctlSet(epc, keys[i], vals[i]); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ dataDir := epc.procs[0].cfg.dataDirPath
+ if err := epc.StopAll(); err != nil {
+ t.Fatalf("error closing etcd processes (%v)", err)
+ }
+
+ os.Setenv("ETCDCTL_API", "3")
+ defer os.Unsetenv("ETCDCTL_API")
+ cx := ctlCtx{
+ t: t,
+ cfg: configNoTLS,
+ dialTimeout: 7 * time.Second,
+ epc: epc,
+ }
+ if err := ctlV3Migrate(cx, dataDir, ""); err != nil {
+ t.Fatal(err)
+ }
+
+ epc.procs[0].cfg.keepDataDir = true
+ if err := epc.RestartAll(); err != nil {
+ t.Fatal(err)
+ }
+
+ // to ensure revision increment is continuous from migrated v2 data
+ if err := ctlV3Put(cx, "test", "value", ""); err != nil {
+ t.Fatal(err)
+ }
+ cli, err := clientv3.New(clientv3.Config{
+ Endpoints: epc.grpcEndpoints(),
+ DialTimeout: 3 * time.Second,
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer cli.Close()
+ resp, err := cli.Get(context.TODO(), "test")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(resp.Kvs) != 1 {
+ t.Fatalf("len(resp.Kvs) expected 1, got %+v", resp.Kvs)
+ }
+ if resp.Kvs[0].CreateRevision != 7 {
+ t.Fatalf("resp.Kvs[0].CreateRevision expected 7, got %d", resp.Kvs[0].CreateRevision)
+ }
+}
+
+func ctlV3Migrate(cx ctlCtx, dataDir, walDir string) error {
+ cmdArgs := append(cx.PrefixArgs(), "migrate", "--data-dir", dataDir, "--wal-dir", walDir)
+ return spawnWithExpects(cmdArgs, "finished transforming keys")
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_role_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_role_test.go
new file mode 100644
index 00000000..340446a1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_role_test.go
@@ -0,0 +1,179 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "fmt"
+ "testing"
+)
+
+func TestCtlV3RoleAdd(t *testing.T) { testCtl(t, roleAddTest) }
+func TestCtlV3RoleAddNoTLS(t *testing.T) { testCtl(t, roleAddTest, withCfg(configNoTLS)) }
+func TestCtlV3RoleAddClientTLS(t *testing.T) { testCtl(t, roleAddTest, withCfg(configClientTLS)) }
+func TestCtlV3RoleAddPeerTLS(t *testing.T) { testCtl(t, roleAddTest, withCfg(configPeerTLS)) }
+func TestCtlV3RoleAddTimeout(t *testing.T) { testCtl(t, roleAddTest, withDialTimeout(0)) }
+
+func TestCtlV3RoleGrant(t *testing.T) { testCtl(t, roleGrantTest) }
+
+func roleAddTest(cx ctlCtx) {
+ cmdSet := []struct {
+ args []string
+ expectedStr string
+ }{
+ // Add a role.
+ {
+ args: []string{"add", "root"},
+ expectedStr: "Role root created",
+ },
+ // Try adding the same role.
+ {
+ args: []string{"add", "root"},
+ expectedStr: "role name already exists",
+ },
+ }
+
+ for i, cmd := range cmdSet {
+ if err := ctlV3Role(cx, cmd.args, cmd.expectedStr); err != nil {
+ if cx.dialTimeout > 0 && !isGRPCTimedout(err) {
+ cx.t.Fatalf("roleAddTest #%d: ctlV3Role error (%v)", i, err)
+ }
+ }
+ }
+}
+
+func roleGrantTest(cx ctlCtx) {
+ cmdSet := []struct {
+ args []string
+ expectedStr string
+ }{
+ // Add a role.
+ {
+ args: []string{"add", "root"},
+ expectedStr: "Role root created",
+ },
+ // Grant read permission to the role.
+ {
+ args: []string{"grant", "root", "read", "foo"},
+ expectedStr: "Role root updated",
+ },
+ // Grant write permission to the role.
+ {
+ args: []string{"grant", "root", "write", "foo"},
+ expectedStr: "Role root updated",
+ },
+ // Grant rw permission to the role.
+ {
+ args: []string{"grant", "root", "readwrite", "foo"},
+ expectedStr: "Role root updated",
+ },
+ // Try granting invalid permission to the role.
+ {
+ args: []string{"grant", "root", "123", "foo"},
+ expectedStr: "invalid permission type",
+ },
+ }
+
+ for i, cmd := range cmdSet {
+ if err := ctlV3Role(cx, cmd.args, cmd.expectedStr); err != nil {
+ cx.t.Fatalf("roleGrantTest #%d: ctlV3Role error (%v)", i, err)
+ }
+ }
+}
+
+func ctlV3Role(cx ctlCtx, args []string, expStr string) error {
+ cmdArgs := append(cx.PrefixArgs(), "role")
+ cmdArgs = append(cmdArgs, args...)
+
+ return spawnWithExpect(cmdArgs, expStr)
+}
+
+func ctlV3RoleGrantPermission(cx ctlCtx, rolename string, perm grantingPerm) error {
+ cmdArgs := append(cx.PrefixArgs(), "role", "grant-permission")
+ if perm.prefix {
+ cmdArgs = append(cmdArgs, "--prefix")
+ } else if len(perm.rangeEnd) == 1 && perm.rangeEnd[0] == '\x00' {
+ cmdArgs = append(cmdArgs, "--from-key")
+ }
+
+ cmdArgs = append(cmdArgs, rolename)
+ cmdArgs = append(cmdArgs, grantingPermToArgs(perm)...)
+
+ proc, err := spawnCmd(cmdArgs)
+ if err != nil {
+ return err
+ }
+
+ expStr := fmt.Sprintf("Role %s updated", rolename)
+ _, err = proc.Expect(expStr)
+ return err
+}
+
+func ctlV3RoleRevokePermission(cx ctlCtx, rolename string, key, rangeEnd string, fromKey bool) error {
+ cmdArgs := append(cx.PrefixArgs(), "role", "revoke-permission")
+ cmdArgs = append(cmdArgs, rolename)
+ cmdArgs = append(cmdArgs, key)
+ expStr := ""
+ if len(rangeEnd) != 0 {
+ cmdArgs = append(cmdArgs, rangeEnd)
+ expStr = fmt.Sprintf("Permission of range [%s, %s) is revoked from role %s", key, rangeEnd, rolename)
+ } else if fromKey {
+ cmdArgs = append(cmdArgs, "--from-key")
+ expStr = fmt.Sprintf("Permission of range [%s, <open ended> is revoked from role %s", key, rolename)
+ } else {
+ expStr = fmt.Sprintf("Permission of key %s is revoked from role %s", key, rolename)
+ }
+
+ proc, err := spawnCmd(cmdArgs)
+ if err != nil {
+ return err
+ }
+
+ _, err = proc.Expect(expStr)
+ return err
+}
+
+type grantingPerm struct {
+ read bool
+ write bool
+ key string
+ rangeEnd string
+ prefix bool
+}
+
+func grantingPermToArgs(perm grantingPerm) []string {
+ permstr := ""
+
+ if perm.read {
+ permstr += "read"
+ }
+
+ if perm.write {
+ permstr += "write"
+ }
+
+ if len(permstr) == 0 {
+ panic("invalid granting permission")
+ }
+
+ if len(perm.rangeEnd) == 0 {
+ return []string{permstr, perm.key}
+ }
+
+ if len(perm.rangeEnd) == 1 && perm.rangeEnd[0] == '\x00' {
+ return []string{permstr, perm.key}
+ }
+
+ return []string{permstr, perm.key, perm.rangeEnd}
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_snapshot_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_snapshot_test.go
new file mode 100644
index 00000000..d2394885
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_snapshot_test.go
@@ -0,0 +1,286 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "encoding/json"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/expect"
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestCtlV3Snapshot(t *testing.T) { testCtl(t, snapshotTest) }
+
+func snapshotTest(cx ctlCtx) {
+ maintenanceInitKeys(cx)
+
+ leaseID, err := ctlV3LeaseGrant(cx, 100)
+ if err != nil {
+ cx.t.Fatalf("snapshot: ctlV3LeaseGrant error (%v)", err)
+ }
+ if err = ctlV3Put(cx, "withlease", "withlease", leaseID); err != nil {
+ cx.t.Fatalf("snapshot: ctlV3Put error (%v)", err)
+ }
+
+ fpath := "test.snapshot"
+ defer os.RemoveAll(fpath)
+
+ if err = ctlV3SnapshotSave(cx, fpath); err != nil {
+ cx.t.Fatalf("snapshotTest ctlV3SnapshotSave error (%v)", err)
+ }
+
+ st, err := getSnapshotStatus(cx, fpath)
+ if err != nil {
+ cx.t.Fatalf("snapshotTest getSnapshotStatus error (%v)", err)
+ }
+ if st.Revision != 5 {
+ cx.t.Fatalf("expected 4, got %d", st.Revision)
+ }
+ if st.TotalKey < 4 {
+ cx.t.Fatalf("expected at least 4, got %d", st.TotalKey)
+ }
+}
+
+func TestCtlV3SnapshotCorrupt(t *testing.T) { testCtl(t, snapshotCorruptTest) }
+
+func snapshotCorruptTest(cx ctlCtx) {
+ fpath := "test.snapshot"
+ defer os.RemoveAll(fpath)
+
+ if err := ctlV3SnapshotSave(cx, fpath); err != nil {
+ cx.t.Fatalf("snapshotTest ctlV3SnapshotSave error (%v)", err)
+ }
+
+ // corrupt file
+ f, oerr := os.OpenFile(fpath, os.O_WRONLY, 0)
+ if oerr != nil {
+ cx.t.Fatal(oerr)
+ }
+ if _, err := f.Write(make([]byte, 512)); err != nil {
+ cx.t.Fatal(err)
+ }
+ f.Close()
+
+ defer os.RemoveAll("snap.etcd")
+ serr := spawnWithExpect(
+ append(cx.PrefixArgs(), "snapshot", "restore",
+ "--data-dir", "snap.etcd",
+ fpath),
+ "expected sha256")
+
+ if serr != nil {
+ cx.t.Fatal(serr)
+ }
+}
+
+func ctlV3SnapshotSave(cx ctlCtx, fpath string) error {
+ cmdArgs := append(cx.PrefixArgs(), "snapshot", "save", fpath)
+ return spawnWithExpect(cmdArgs, fmt.Sprintf("Snapshot saved at %s", fpath))
+}
+
+type snapshotStatus struct {
+ Hash uint32 `json:"hash"`
+ Revision int64 `json:"revision"`
+ TotalKey int `json:"totalKey"`
+ TotalSize int64 `json:"totalSize"`
+}
+
+func getSnapshotStatus(cx ctlCtx, fpath string) (snapshotStatus, error) {
+ cmdArgs := append(cx.PrefixArgs(), "--write-out", "json", "snapshot", "status", fpath)
+
+ proc, err := spawnCmd(cmdArgs)
+ if err != nil {
+ return snapshotStatus{}, err
+ }
+ var txt string
+ txt, err = proc.Expect("totalKey")
+ if err != nil {
+ return snapshotStatus{}, err
+ }
+ if err = proc.Close(); err != nil {
+ return snapshotStatus{}, err
+ }
+
+ resp := snapshotStatus{}
+ dec := json.NewDecoder(strings.NewReader(txt))
+ if err := dec.Decode(&resp); err == io.EOF {
+ return snapshotStatus{}, err
+ }
+ return resp, nil
+}
+
+// TestIssue6361 ensures new member that starts with snapshot correctly
+// syncs up with other members and serve correct data.
+func TestIssue6361(t *testing.T) {
+ defer testutil.AfterTest(t)
+ mustEtcdctl(t)
+ os.Setenv("ETCDCTL_API", "3")
+ defer os.Unsetenv("ETCDCTL_API")
+
+ epc, err := newEtcdProcessCluster(&etcdProcessClusterConfig{
+ clusterSize: 1,
+ initialToken: "new",
+ keepDataDir: true,
+ })
+ if err != nil {
+ t.Fatalf("could not start etcd process cluster (%v)", err)
+ }
+ defer func() {
+ if errC := epc.Close(); errC != nil {
+ t.Fatalf("error closing etcd processes (%v)", errC)
+ }
+ }()
+
+ dialTimeout := 7 * time.Second
+ prefixArgs := []string{ctlBinPath, "--endpoints", strings.Join(epc.grpcEndpoints(), ","), "--dial-timeout", dialTimeout.String()}
+
+ // write some keys
+ kvs := []kv{{"foo1", "val1"}, {"foo2", "val2"}, {"foo3", "val3"}}
+ for i := range kvs {
+ if err = spawnWithExpect(append(prefixArgs, "put", kvs[i].key, kvs[i].val), "OK"); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ fpath := filepath.Join(os.TempDir(), "test.snapshot")
+ defer os.RemoveAll(fpath)
+
+ // etcdctl save snapshot
+ if err = spawnWithExpect(append(prefixArgs, "snapshot", "save", fpath), fmt.Sprintf("Snapshot saved at %s", fpath)); err != nil {
+ t.Fatal(err)
+ }
+
+ if err = epc.processes()[0].Stop(); err != nil {
+ t.Fatal(err)
+ }
+
+ newDataDir := filepath.Join(os.TempDir(), "test.data")
+ defer os.RemoveAll(newDataDir)
+
+ // etcdctl restore the snapshot
+ err = spawnWithExpect([]string{ctlBinPath, "snapshot", "restore", fpath, "--name", epc.procs[0].cfg.name, "--initial-cluster", epc.procs[0].cfg.initialCluster, "--initial-cluster-token", epc.procs[0].cfg.initialToken, "--initial-advertise-peer-urls", epc.procs[0].cfg.purl.String(), "--data-dir", newDataDir}, "membership: added member")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // start the etcd member using the restored snapshot
+ epc.procs[0].cfg.dataDirPath = newDataDir
+ for i := range epc.procs[0].cfg.args {
+ if epc.procs[0].cfg.args[i] == "--data-dir" {
+ epc.procs[0].cfg.args[i+1] = newDataDir
+ }
+ }
+ if err = epc.processes()[0].Restart(); err != nil {
+ t.Fatal(err)
+ }
+
+ // ensure the restored member has the correct data
+ for i := range kvs {
+ if err = spawnWithExpect(append(prefixArgs, "get", kvs[i].key), kvs[i].val); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ // add a new member into the cluster
+ clientURL := fmt.Sprintf("http://localhost:%d", etcdProcessBasePort+30)
+ peerURL := fmt.Sprintf("http://localhost:%d", etcdProcessBasePort+31)
+ err = spawnWithExpect(append(prefixArgs, "member", "add", "newmember", fmt.Sprintf("--peer-urls=%s", peerURL)), " added to cluster ")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ var newDataDir2 string
+ newDataDir2, err = ioutil.TempDir("", "newdata2")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(newDataDir2)
+
+ name2 := "infra2"
+ initialCluster2 := epc.procs[0].cfg.initialCluster + fmt.Sprintf(",%s=%s", name2, peerURL)
+
+ // start the new member
+ var nepc *expect.ExpectProcess
+ nepc, err = spawnCmd([]string{epc.procs[0].cfg.execPath, "--name", name2,
+ "--listen-client-urls", clientURL, "--advertise-client-urls", clientURL,
+ "--listen-peer-urls", peerURL, "--initial-advertise-peer-urls", peerURL,
+ "--initial-cluster", initialCluster2, "--initial-cluster-state", "existing", "--data-dir", newDataDir2})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err = nepc.Expect("enabled capabilities for version"); err != nil {
+ t.Fatal(err)
+ }
+
+ prefixArgs = []string{ctlBinPath, "--endpoints", clientURL, "--dial-timeout", dialTimeout.String()}
+
+ // ensure added member has data from incoming snapshot
+ for i := range kvs {
+ if err = spawnWithExpect(append(prefixArgs, "get", kvs[i].key), kvs[i].val); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ if err = nepc.Stop(); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestCtlV3SnapshotWithAuth(t *testing.T) { testCtl(t, snapshotTestWithAuth) }
+
+func snapshotTestWithAuth(cx ctlCtx) {
+ maintenanceInitKeys(cx)
+
+ if err := authEnable(cx); err != nil {
+ cx.t.Fatal(err)
+ }
+
+ cx.user, cx.pass = "root", "root"
+ authSetupTestUser(cx)
+
+ fpath := "test.snapshot"
+ defer os.RemoveAll(fpath)
+
+ // ordinary user cannot save a snapshot
+ cx.user, cx.pass = "test-user", "pass"
+ if err := ctlV3SnapshotSave(cx, fpath); err == nil {
+ cx.t.Fatal("ordinary user should not be able to save a snapshot")
+ }
+
+ // root can save a snapshot
+ cx.user, cx.pass = "root", "root"
+ if err := ctlV3SnapshotSave(cx, fpath); err != nil {
+ cx.t.Fatalf("snapshotTest ctlV3SnapshotSave error (%v)", err)
+ }
+
+ st, err := getSnapshotStatus(cx, fpath)
+ if err != nil {
+ cx.t.Fatalf("snapshotTest getSnapshotStatus error (%v)", err)
+ }
+ if st.Revision != 4 {
+ cx.t.Fatalf("expected 4, got %d", st.Revision)
+ }
+ if st.TotalKey < 3 {
+ cx.t.Fatalf("expected at least 3, got %d", st.TotalKey)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_test.go
new file mode 100644
index 00000000..a4eab968
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_test.go
@@ -0,0 +1,237 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "fmt"
+ "os"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/flags"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/version"
+)
+
+func TestCtlV3Version(t *testing.T) { testCtl(t, versionTest) }
+
+func versionTest(cx ctlCtx) {
+ if err := ctlV3Version(cx); err != nil {
+ cx.t.Fatalf("versionTest ctlV3Version error (%v)", err)
+ }
+}
+
+func ctlV3Version(cx ctlCtx) error {
+ cmdArgs := append(cx.PrefixArgs(), "version")
+ return spawnWithExpect(cmdArgs, version.Version)
+}
+
+// TestCtlV3DialWithHTTPScheme ensures that client handles endpoints with HTTPS scheme.
+func TestCtlV3DialWithHTTPScheme(t *testing.T) {
+ testCtl(t, dialWithSchemeTest, withCfg(configClientTLS))
+}
+
+func dialWithSchemeTest(cx ctlCtx) {
+ cmdArgs := append(cx.prefixArgs(cx.epc.endpoints()), "put", "foo", "bar")
+ if err := spawnWithExpect(cmdArgs, "OK"); err != nil {
+ cx.t.Fatal(err)
+ }
+}
+
+type ctlCtx struct {
+ t *testing.T
+ cfg etcdProcessClusterConfig
+ quotaBackendBytes int64
+ noStrictReconfig bool
+
+ epc *etcdProcessCluster
+
+ envMap map[string]struct{}
+
+ dialTimeout time.Duration
+
+ quorum bool // if true, set up 3-node cluster and linearizable read
+ interactive bool
+
+ user string
+ pass string
+
+ // for compaction
+ compactPhysical bool
+}
+
+type ctlOption func(*ctlCtx)
+
+func (cx *ctlCtx) applyOpts(opts []ctlOption) {
+ for _, opt := range opts {
+ opt(cx)
+ }
+}
+
+func withCfg(cfg etcdProcessClusterConfig) ctlOption {
+ return func(cx *ctlCtx) { cx.cfg = cfg }
+}
+
+func withDialTimeout(timeout time.Duration) ctlOption {
+ return func(cx *ctlCtx) { cx.dialTimeout = timeout }
+}
+
+func withQuorum() ctlOption {
+ return func(cx *ctlCtx) { cx.quorum = true }
+}
+
+func withInteractive() ctlOption {
+ return func(cx *ctlCtx) { cx.interactive = true }
+}
+
+func withQuota(b int64) ctlOption {
+ return func(cx *ctlCtx) { cx.quotaBackendBytes = b }
+}
+
+func withCompactPhysical() ctlOption {
+ return func(cx *ctlCtx) { cx.compactPhysical = true }
+}
+
+func withNoStrictReconfig() ctlOption {
+ return func(cx *ctlCtx) { cx.noStrictReconfig = true }
+}
+
+func withFlagByEnv() ctlOption {
+ return func(cx *ctlCtx) { cx.envMap = make(map[string]struct{}) }
+}
+
+func testCtl(t *testing.T, testFunc func(ctlCtx), opts ...ctlOption) {
+ defer testutil.AfterTest(t)
+
+ ret := ctlCtx{
+ t: t,
+ cfg: configAutoTLS,
+ dialTimeout: 7 * time.Second,
+ }
+ ret.applyOpts(opts)
+
+ os.Setenv("ETCDCTL_API", "3")
+ mustEtcdctl(t)
+ if !ret.quorum {
+ ret.cfg = *configStandalone(ret.cfg)
+ }
+ if ret.quotaBackendBytes > 0 {
+ ret.cfg.quotaBackendBytes = ret.quotaBackendBytes
+ }
+ ret.cfg.noStrictReconfig = ret.noStrictReconfig
+
+ epc, err := newEtcdProcessCluster(&ret.cfg)
+ if err != nil {
+ t.Fatalf("could not start etcd process cluster (%v)", err)
+ }
+ ret.epc = epc
+
+ defer func() {
+ os.Unsetenv("ETCDCTL_API")
+ if ret.envMap != nil {
+ for k := range ret.envMap {
+ os.Unsetenv(k)
+ }
+ }
+ if errC := ret.epc.Close(); errC != nil {
+ t.Fatalf("error closing etcd processes (%v)", errC)
+ }
+ }()
+
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ testFunc(ret)
+ }()
+
+ timeout := 2*ret.dialTimeout + time.Second
+ if ret.dialTimeout == 0 {
+ timeout = 30 * time.Second
+ }
+ select {
+ case <-time.After(timeout):
+ testutil.FatalStack(t, fmt.Sprintf("test timed out after %v", timeout))
+ case <-donec:
+ }
+}
+
+func (cx *ctlCtx) prefixArgs(eps []string) []string {
+ if len(cx.epc.proxies()) > 0 { // TODO: add proxy check as in v2
+ panic("v3 proxy not implemented")
+ }
+
+ fmap := make(map[string]string)
+ fmap["endpoints"] = strings.Join(eps, ",")
+ fmap["dial-timeout"] = cx.dialTimeout.String()
+ if cx.epc.cfg.clientTLS == clientTLS {
+ if cx.epc.cfg.isClientAutoTLS {
+ fmap["insecure-transport"] = "false"
+ fmap["insecure-skip-tls-verify"] = "true"
+ } else {
+ fmap["cacert"] = caPath
+ fmap["cert"] = certPath
+ fmap["key"] = privateKeyPath
+ }
+ }
+ if cx.user != "" {
+ fmap["user"] = cx.user + ":" + cx.pass
+ }
+
+ useEnv := cx.envMap != nil
+
+ cmdArgs := []string{ctlBinPath}
+ for k, v := range fmap {
+ if useEnv {
+ ek := flags.FlagToEnv("ETCDCTL", k)
+ os.Setenv(ek, v)
+ cx.envMap[ek] = struct{}{}
+ } else {
+ cmdArgs = append(cmdArgs, fmt.Sprintf("--%s=%s", k, v))
+ }
+ }
+ return cmdArgs
+}
+
+// PrefixArgs prefixes etcdctl command.
+// Make sure to unset environment variables after tests.
+func (cx *ctlCtx) PrefixArgs() []string {
+ return cx.prefixArgs(cx.epc.grpcEndpoints())
+}
+
+func isGRPCTimedout(err error) bool {
+ return strings.Contains(err.Error(), "grpc: timed out trying to connect")
+}
+
+func (cx *ctlCtx) memberToRemove() (ep string, memberID string, clusterID string) {
+ n1 := cx.cfg.clusterSize
+ if n1 < 2 {
+ cx.t.Fatalf("%d-node is too small to test 'member remove'", n1)
+ }
+
+ resp, err := getMemberList(*cx)
+ if err != nil {
+ cx.t.Fatal(err)
+ }
+ if n1 != len(resp.Members) {
+ cx.t.Fatalf("expected %d, got %d", n1, len(resp.Members))
+ }
+
+ ep = resp.Members[0].ClientURLs[0]
+ clusterID = fmt.Sprintf("%x", resp.Header.ClusterId)
+ memberID = fmt.Sprintf("%x", resp.Members[1].ID)
+
+ return ep, memberID, clusterID
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_txn_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_txn_test.go
new file mode 100644
index 00000000..c6e0b12d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_txn_test.go
@@ -0,0 +1,155 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import "testing"
+
+func TestCtlV3TxnInteractiveSuccess(t *testing.T) {
+ testCtl(t, txnTestSuccess, withInteractive())
+}
+func TestCtlV3TxnInteractiveSuccessNoTLS(t *testing.T) {
+ testCtl(t, txnTestSuccess, withInteractive(), withCfg(configNoTLS))
+}
+func TestCtlV3TxnInteractiveSuccessClientTLS(t *testing.T) {
+ testCtl(t, txnTestSuccess, withInteractive(), withCfg(configClientTLS))
+}
+func TestCtlV3TxnInteractiveSuccessPeerTLS(t *testing.T) {
+ testCtl(t, txnTestSuccess, withInteractive(), withCfg(configPeerTLS))
+}
+func TestCtlV3TxnInteractiveFail(t *testing.T) {
+ testCtl(t, txnTestFail, withInteractive())
+}
+
+func txnTestSuccess(cx ctlCtx) {
+ if err := ctlV3Put(cx, "key1", "value1", ""); err != nil {
+ cx.t.Fatalf("txnTestSuccess ctlV3Put error (%v)", err)
+ }
+ if err := ctlV3Put(cx, "key2", "value2", ""); err != nil {
+ cx.t.Fatalf("txnTestSuccess ctlV3Put error (%v)", err)
+ }
+ rqs := []txnRequests{
+ {
+ compare: []string{`value("key1") != "value2"`, `value("key2") != "value1"`},
+ ifSucess: []string{"get key1", "get key2"},
+ results: []string{"SUCCESS", "key1", "value1", "key2", "value2"},
+ },
+ {
+ compare: []string{`version("key1") = "1"`, `version("key2") = "1"`},
+ ifSucess: []string{"get key1", "get key2", `put "key \"with\" space" "value \x23"`},
+ ifFail: []string{`put key1 "fail"`, `put key2 "fail"`},
+ results: []string{"SUCCESS", "key1", "value1", "key2", "value2"},
+ },
+ {
+ compare: []string{`version("key \"with\" space") = "1"`},
+ ifSucess: []string{`get "key \"with\" space"`},
+ results: []string{"SUCCESS", `key "with" space`, "value \x23"},
+ },
+ }
+ for _, rq := range rqs {
+ if err := ctlV3Txn(cx, rq); err != nil {
+ cx.t.Fatal(err)
+ }
+ }
+}
+
+func txnTestFail(cx ctlCtx) {
+ if err := ctlV3Put(cx, "key1", "value1", ""); err != nil {
+ cx.t.Fatalf("txnTestSuccess ctlV3Put error (%v)", err)
+ }
+ rqs := []txnRequests{
+ {
+ compare: []string{`version("key") < "0"`},
+ ifSucess: []string{`put key "success"`},
+ ifFail: []string{`put key "fail"`},
+ results: []string{"FAILURE", "OK"},
+ },
+ {
+ compare: []string{`value("key1") != "value1"`},
+ ifSucess: []string{`put key1 "success"`},
+ ifFail: []string{`put key1 "fail"`},
+ results: []string{"FAILURE", "OK"},
+ },
+ }
+ for _, rq := range rqs {
+ if err := ctlV3Txn(cx, rq); err != nil {
+ cx.t.Fatal(err)
+ }
+ }
+}
+
+type txnRequests struct {
+ compare []string
+ ifSucess []string
+ ifFail []string
+ results []string
+}
+
+func ctlV3Txn(cx ctlCtx, rqs txnRequests) error {
+ // TODO: support non-interactive mode
+ cmdArgs := append(cx.PrefixArgs(), "txn")
+ if cx.interactive {
+ cmdArgs = append(cmdArgs, "--interactive")
+ }
+ proc, err := spawnCmd(cmdArgs)
+ if err != nil {
+ return err
+ }
+ _, err = proc.Expect("compares:")
+ if err != nil {
+ return err
+ }
+ for _, req := range rqs.compare {
+ if err = proc.Send(req + "\r"); err != nil {
+ return err
+ }
+ }
+ if err = proc.Send("\r"); err != nil {
+ return err
+ }
+
+ _, err = proc.Expect("success requests (get, put, delete):")
+ if err != nil {
+ return err
+ }
+ for _, req := range rqs.ifSucess {
+ if err = proc.Send(req + "\r"); err != nil {
+ return err
+ }
+ }
+ if err = proc.Send("\r"); err != nil {
+ return err
+ }
+
+ _, err = proc.Expect("failure requests (get, put, delete):")
+ if err != nil {
+ return err
+ }
+ for _, req := range rqs.ifFail {
+ if err = proc.Send(req + "\r"); err != nil {
+ return err
+ }
+ }
+ if err = proc.Send("\r"); err != nil {
+ return err
+ }
+
+ for _, line := range rqs.results {
+ _, err = proc.Expect(line)
+ if err != nil {
+ return err
+ }
+ }
+ return proc.Close()
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_user_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_user_test.go
new file mode 100644
index 00000000..392ab4e4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_user_test.go
@@ -0,0 +1,139 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import "testing"
+
+func TestCtlV3UserAdd(t *testing.T) { testCtl(t, userAddTest) }
+func TestCtlV3UserAddNoTLS(t *testing.T) { testCtl(t, userAddTest, withCfg(configNoTLS)) }
+func TestCtlV3UserAddClientTLS(t *testing.T) { testCtl(t, userAddTest, withCfg(configClientTLS)) }
+func TestCtlV3UserAddPeerTLS(t *testing.T) { testCtl(t, userAddTest, withCfg(configPeerTLS)) }
+func TestCtlV3UserAddTimeout(t *testing.T) { testCtl(t, userAddTest, withDialTimeout(0)) }
+
+func TestCtlV3UserDelete(t *testing.T) { testCtl(t, userDelTest) }
+func TestCtlV3UserPasswd(t *testing.T) { testCtl(t, userPasswdTest) }
+
+type userCmdDesc struct {
+ args []string
+ expectedStr string
+ stdIn []string
+}
+
+func userAddTest(cx ctlCtx) {
+ cmdSet := []userCmdDesc{
+ // Adds a user name.
+ {
+ args: []string{"add", "username", "--interactive=false"},
+ expectedStr: "User username created",
+ stdIn: []string{"password"},
+ },
+ // Adds a user name using the usertest:password syntax.
+ {
+ args: []string{"add", "usertest:password"},
+ expectedStr: "User usertest created",
+ stdIn: []string{},
+ },
+ // Tries to add a user with empty username.
+ {
+ args: []string{"add", ":password"},
+ expectedStr: "empty user name is not allowed.",
+ stdIn: []string{},
+ },
+ // Tries to add a user name that already exists.
+ {
+ args: []string{"add", "username", "--interactive=false"},
+ expectedStr: "user name already exists",
+ stdIn: []string{"password"},
+ },
+ }
+
+ for i, cmd := range cmdSet {
+ if err := ctlV3User(cx, cmd.args, cmd.expectedStr, cmd.stdIn); err != nil {
+ if cx.dialTimeout > 0 && !isGRPCTimedout(err) {
+ cx.t.Fatalf("userAddTest #%d: ctlV3User error (%v)", i, err)
+ }
+ }
+ }
+}
+
+func userDelTest(cx ctlCtx) {
+ cmdSet := []userCmdDesc{
+ // Adds a user name.
+ {
+ args: []string{"add", "username", "--interactive=false"},
+ expectedStr: "User username created",
+ stdIn: []string{"password"},
+ },
+ // Deletes the user name just added.
+ {
+ args: []string{"delete", "username"},
+ expectedStr: "User username deleted",
+ },
+ // Deletes a user name that is not present.
+ {
+ args: []string{"delete", "username"},
+ expectedStr: "user name not found",
+ },
+ }
+
+ for i, cmd := range cmdSet {
+ if err := ctlV3User(cx, cmd.args, cmd.expectedStr, cmd.stdIn); err != nil {
+ cx.t.Fatalf("userDelTest #%d: ctlV3User error (%v)", i, err)
+ }
+ }
+}
+
+func userPasswdTest(cx ctlCtx) {
+ cmdSet := []userCmdDesc{
+ // Adds a user name.
+ {
+ args: []string{"add", "username", "--interactive=false"},
+ expectedStr: "User username created",
+ stdIn: []string{"password"},
+ },
+ // Changes the password.
+ {
+ args: []string{"passwd", "username", "--interactive=false"},
+ expectedStr: "Password updated",
+ stdIn: []string{"password1"},
+ },
+ }
+
+ for i, cmd := range cmdSet {
+ if err := ctlV3User(cx, cmd.args, cmd.expectedStr, cmd.stdIn); err != nil {
+ cx.t.Fatalf("userPasswdTest #%d: ctlV3User error (%v)", i, err)
+ }
+ }
+}
+
+func ctlV3User(cx ctlCtx, args []string, expStr string, stdIn []string) error {
+ cmdArgs := append(cx.PrefixArgs(), "user")
+ cmdArgs = append(cmdArgs, args...)
+
+ proc, err := spawnCmd(cmdArgs)
+ if err != nil {
+ return err
+ }
+
+ // Send 'stdIn' strings as input.
+ for _, s := range stdIn {
+ if err = proc.Send(s + "\r"); err != nil {
+ return err
+ }
+ }
+
+ _, err = proc.Expect(expStr)
+ return err
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/ctl_v3_watch_test.go b/vendor/github.com/coreos/etcd/e2e/ctl_v3_watch_test.go
new file mode 100644
index 00000000..bc9d64ac
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/ctl_v3_watch_test.go
@@ -0,0 +1,149 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestCtlV3Watch(t *testing.T) { testCtl(t, watchTest) }
+func TestCtlV3WatchNoTLS(t *testing.T) { testCtl(t, watchTest, withCfg(configNoTLS)) }
+func TestCtlV3WatchClientTLS(t *testing.T) { testCtl(t, watchTest, withCfg(configClientTLS)) }
+func TestCtlV3WatchPeerTLS(t *testing.T) { testCtl(t, watchTest, withCfg(configPeerTLS)) }
+func TestCtlV3WatchTimeout(t *testing.T) { testCtl(t, watchTest, withDialTimeout(0)) }
+
+func TestCtlV3WatchInteractive(t *testing.T) {
+ testCtl(t, watchTest, withInteractive())
+}
+func TestCtlV3WatchInteractiveNoTLS(t *testing.T) {
+ testCtl(t, watchTest, withInteractive(), withCfg(configNoTLS))
+}
+func TestCtlV3WatchInteractiveClientTLS(t *testing.T) {
+ testCtl(t, watchTest, withInteractive(), withCfg(configClientTLS))
+}
+func TestCtlV3WatchInteractivePeerTLS(t *testing.T) {
+ testCtl(t, watchTest, withInteractive(), withCfg(configPeerTLS))
+}
+
+func watchTest(cx ctlCtx) {
+ tests := []struct {
+ puts []kv
+ args []string
+
+ wkv []kv
+ }{
+ { // watch 1 key
+ []kv{{"sample", "value"}},
+ []string{"sample", "--rev", "1"},
+ []kv{{"sample", "value"}},
+ },
+ { // watch 3 keys by prefix
+ []kv{{"key1", "val1"}, {"key2", "val2"}, {"key3", "val3"}},
+ []string{"key", "--rev", "1", "--prefix"},
+ []kv{{"key1", "val1"}, {"key2", "val2"}, {"key3", "val3"}},
+ },
+ { // watch by revision
+ []kv{{"etcd", "revision_1"}, {"etcd", "revision_2"}, {"etcd", "revision_3"}},
+ []string{"etcd", "--rev", "2"},
+ []kv{{"etcd", "revision_2"}, {"etcd", "revision_3"}},
+ },
+ { // watch 3 keys by range
+ []kv{{"key1", "val1"}, {"key3", "val3"}, {"key2", "val2"}},
+ []string{"key", "key3", "--rev", "1"},
+ []kv{{"key1", "val1"}, {"key2", "val2"}},
+ },
+ }
+
+ for i, tt := range tests {
+ donec := make(chan struct{})
+ go func(i int, puts []kv) {
+ for j := range puts {
+ if err := ctlV3Put(cx, puts[j].key, puts[j].val, ""); err != nil {
+ cx.t.Fatalf("watchTest #%d-%d: ctlV3Put error (%v)", i, j, err)
+ }
+ }
+ close(donec)
+ }(i, tt.puts)
+ if err := ctlV3Watch(cx, tt.args, tt.wkv...); err != nil {
+ if cx.dialTimeout > 0 && !isGRPCTimedout(err) {
+ cx.t.Errorf("watchTest #%d: ctlV3Watch error (%v)", i, err)
+ }
+ }
+ <-donec
+ }
+}
+
+func setupWatchArgs(cx ctlCtx, args []string) []string {
+ cmdArgs := append(cx.PrefixArgs(), "watch")
+ if cx.interactive {
+ cmdArgs = append(cmdArgs, "--interactive")
+ } else {
+ cmdArgs = append(cmdArgs, args...)
+ }
+
+ return cmdArgs
+}
+
+func ctlV3Watch(cx ctlCtx, args []string, kvs ...kv) error {
+ cmdArgs := setupWatchArgs(cx, args)
+
+ proc, err := spawnCmd(cmdArgs)
+ if err != nil {
+ return err
+ }
+
+ if cx.interactive {
+ wl := strings.Join(append([]string{"watch"}, args...), " ") + "\r"
+ if err = proc.Send(wl); err != nil {
+ return err
+ }
+ }
+
+ for _, elem := range kvs {
+ if _, err = proc.Expect(elem.key); err != nil {
+ return err
+ }
+ if _, err = proc.Expect(elem.val); err != nil {
+ return err
+ }
+ }
+ return proc.Stop()
+}
+
+func ctlV3WatchFailPerm(cx ctlCtx, args []string) error {
+ cmdArgs := setupWatchArgs(cx, args)
+
+ proc, err := spawnCmd(cmdArgs)
+ if err != nil {
+ return err
+ }
+
+ if cx.interactive {
+ wl := strings.Join(append([]string{"watch"}, args...), " ") + "\r"
+ if err = proc.Send(wl); err != nil {
+ return err
+ }
+ }
+
+ // TODO(mitake): after printing accurate error message that includes
+ // "permission denied", the above string argument of proc.Expect()
+ // should be updated.
+ _, err = proc.Expect("watch is canceled by the server")
+ if err != nil {
+ return err
+ }
+ return proc.Close()
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/doc.go b/vendor/github.com/coreos/etcd/e2e/doc.go
new file mode 100644
index 00000000..a6887cfc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/doc.go
@@ -0,0 +1,24 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e implements tests built upon etcd binaries, and focus on
+end-to-end testing.
+
+Features/goals of the end-to-end tests:
+1. test command-line parsing and arguments.
+2. test user-facing command-line API.
+3. launch full processes and check for expected outputs.
+*/
+package e2e
diff --git a/vendor/github.com/coreos/etcd/e2e/docker/Dockerfile b/vendor/github.com/coreos/etcd/e2e/docker/Dockerfile
new file mode 100644
index 00000000..c94e1612
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/docker/Dockerfile
@@ -0,0 +1,12 @@
+FROM golang:1.8.3-stretch
+LABEL Description="Image for etcd DNS testing"
+RUN apt update -y
+RUN go get github.com/mattn/goreman
+RUN apt install -y bind9
+RUN mkdir /var/bind
+RUN chown bind /var/bind
+ADD Procfile.tls /Procfile.tls
+ADD run.sh /run.sh
+ADD named.conf etcd.zone rdns.zone /etc/bind/
+ADD resolv.conf /etc/resolv.conf
+CMD ["/run.sh"]
\ No newline at end of file
diff --git a/vendor/github.com/coreos/etcd/e2e/docker/Makefile b/vendor/github.com/coreos/etcd/e2e/docker/Makefile
new file mode 100644
index 00000000..7ec14d42
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/docker/Makefile
@@ -0,0 +1,7 @@
+# run makefile from repo root
+
+docker-dns-build:
+ docker build -t etcd-dns e2e/docker/
+
+docker-dns-test: docker-dns-build
+ docker run --dns 127.0.0.1 --rm -v `pwd`/bin/:/etcd -v `pwd`/integration/fixtures:/certs -w /etcd -t etcd-dns
diff --git a/vendor/github.com/coreos/etcd/e2e/docker/Procfile.tls b/vendor/github.com/coreos/etcd/e2e/docker/Procfile.tls
new file mode 100644
index 00000000..d8b79020
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/docker/Procfile.tls
@@ -0,0 +1,6 @@
+# Use goreman to run `go get github.com/mattn/goreman`
+etcd1: ./etcd --name infra1 --listen-client-urls https://127.0.0.1:2379 --advertise-client-urls https://m1.etcd.local:2379 --listen-peer-urls https://127.0.0.1:12380 --initial-advertise-peer-urls=https://m1.etcd.local:12380 --initial-cluster-token etcd-cluster-1 --initial-cluster=infra1=https://m1.etcd.local:12380,infra2=https://m2.etcd.local:22380,infra3=https://m3.etcd.local:32380 --initial-cluster-state new --enable-pprof --peer-cert-file=/certs/server-wildcard.crt --peer-key-file=/certs/server-wildcard.key.insecure --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --trusted-ca-file=/certs/ca.crt
+
+etcd2: ./etcd --name infra2 --listen-client-urls https://127.0.0.1:22379 --advertise-client-urls https://m2.etcd.local:22379 --listen-peer-urls https://127.0.0.1:22380 --initial-advertise-peer-urls=https://m2.etcd.local:22380 --initial-cluster-token etcd-cluster-1 --initial-cluster=infra1=https://m1.etcd.local:12380,infra2=https://m2.etcd.local:22380,infra3=https://m3.etcd.local:32380 --initial-cluster-state new --enable-pprof --peer-cert-file=/certs/server-wildcard.crt -peer-key-file=/certs/server-wildcard.key.insecure --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --trusted-ca-file=/certs/ca.crt
+
+etcd3: ./etcd --name infra3 --listen-client-urls https://127.0.0.1:32379 --advertise-client-urls https://m3.etcd.local:32379 --listen-peer-urls https://127.0.0.1:32380 --initial-advertise-peer-urls=https://m3.etcd.local:32380 --initial-cluster-token etcd-cluster-1 --initial-cluster=infra1=https://m1.etcd.local:12380,infra2=https://m2.etcd.local:22380,infra3=https://m3.etcd.local:32380 --initial-cluster-state new --enable-pprof --peer-cert-file=/certs/server-wildcard.crt --peer-key-file=/certs/server-wildcard.key.insecure --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --trusted-ca-file=/certs/ca.crt
diff --git a/vendor/github.com/coreos/etcd/e2e/docker/etcd.zone b/vendor/github.com/coreos/etcd/e2e/docker/etcd.zone
new file mode 100644
index 00000000..03c15fe8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/docker/etcd.zone
@@ -0,0 +1,14 @@
+$TTL 86400
+@ IN SOA etcdns.local. root.etcdns.local. (
+ 100500 ; Serial
+ 604800 ; Refresh
+ 86400 ; Retry
+ 2419200 ; Expire
+ 86400 ) ; Negative Cache TTL
+ IN NS ns.etcdns.local.
+ IN A 127.0.0.1
+
+ns IN A 127.0.0.1
+m1 IN A 127.0.0.1
+m2 IN A 127.0.0.1
+m3 IN A 127.0.0.1
diff --git a/vendor/github.com/coreos/etcd/e2e/docker/named.conf b/vendor/github.com/coreos/etcd/e2e/docker/named.conf
new file mode 100644
index 00000000..83549305
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/docker/named.conf
@@ -0,0 +1,23 @@
+options {
+ directory "/var/bind";
+ listen-on { 127.0.0.1; };
+ listen-on-v6 { none; };
+ allow-transfer {
+ none;
+ };
+ // If you have problems and are behind a firewall:
+ query-source address * port 53;
+ pid-file "/var/run/named/named.pid";
+ allow-recursion { none; };
+ recursion no;
+};
+
+zone "etcd.local" IN {
+ type master;
+ file "/etc/bind/etcd.zone";
+};
+
+zone "0.0.127.in-addr.arpa" {
+ type master;
+ file "/etc/bind/rdns.zone";
+};
diff --git a/vendor/github.com/coreos/etcd/e2e/docker/rdns.zone b/vendor/github.com/coreos/etcd/e2e/docker/rdns.zone
new file mode 100644
index 00000000..fb71b30b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/docker/rdns.zone
@@ -0,0 +1,13 @@
+$TTL 86400
+@ IN SOA etcdns.local. root.etcdns.local. (
+ 100500 ; Serial
+ 604800 ; Refresh
+ 86400 ; Retry
+ 2419200 ; Expire
+ 86400 ) ; Negative Cache TTL
+ IN NS ns.etcdns.local.
+ IN A 127.0.0.1
+
+1 IN PTR m1.etcd.local.
+1 IN PTR m2.etcd.local.
+1 IN PTR m3.etcd.local.
diff --git a/vendor/github.com/coreos/etcd/e2e/docker/resolv.conf b/vendor/github.com/coreos/etcd/e2e/docker/resolv.conf
new file mode 100644
index 00000000..bbc8559c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/docker/resolv.conf
@@ -0,0 +1 @@
+nameserver 127.0.0.1
diff --git a/vendor/github.com/coreos/etcd/e2e/docker/run.sh b/vendor/github.com/coreos/etcd/e2e/docker/run.sh
new file mode 100755
index 00000000..e020bcbe
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/docker/run.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+/etc/init.d/bind9 start
+# get rid of hosts so go lookup won't resolve 127.0.0.1 to localhost
+cat /dev/null >/etc/hosts
+goreman -f /Procfile.tls start &
+sleep 5s
+ETCDCTL_API=3 ./etcdctl --cacert=/certs/ca.crt --endpoints=https://m1.etcd.local:2379 put abc def
diff --git a/vendor/github.com/coreos/etcd/e2e/etcd_config_test.go b/vendor/github.com/coreos/etcd/e2e/etcd_config_test.go
new file mode 100644
index 00000000..9e308c3b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/etcd_config_test.go
@@ -0,0 +1,34 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "testing"
+)
+
+const exampleConfigFile = "../etcd.conf.yml.sample"
+
+func TestEtcdExampleConfig(t *testing.T) {
+ proc, err := spawnCmd([]string{binDir + "/etcd", "--config-file", exampleConfigFile})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = waitReadyExpectProc(proc, false); err != nil {
+ t.Fatal(err)
+ }
+ if err = proc.Stop(); err != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/etcd_release_upgrade_test.go b/vendor/github.com/coreos/etcd/e2e/etcd_release_upgrade_test.go
new file mode 100644
index 00000000..af958e89
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/etcd_release_upgrade_test.go
@@ -0,0 +1,171 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "fmt"
+ "os"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/fileutil"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/version"
+)
+
+// TestReleaseUpgrade ensures that changes to master branch does not affect
+// upgrade from latest etcd releases.
+func TestReleaseUpgrade(t *testing.T) {
+ lastReleaseBinary := binDir + "/etcd-last-release"
+ if !fileutil.Exist(lastReleaseBinary) {
+ t.Skipf("%q does not exist", lastReleaseBinary)
+ }
+
+ defer testutil.AfterTest(t)
+
+ copiedCfg := configNoTLS
+ copiedCfg.execPath = lastReleaseBinary
+ copiedCfg.snapCount = 3
+ copiedCfg.baseScheme = "unix" // to avoid port conflict
+
+ epc, err := newEtcdProcessCluster(&copiedCfg)
+ if err != nil {
+ t.Fatalf("could not start etcd process cluster (%v)", err)
+ }
+ defer func() {
+ if errC := epc.Close(); errC != nil {
+ t.Fatalf("error closing etcd processes (%v)", errC)
+ }
+ }()
+ // 3.0 boots as 2.3 then negotiates up to 3.0
+ // so there's a window at boot time where it doesn't have V3rpcCapability enabled
+ // poll /version until etcdcluster is >2.3.x before making v3 requests
+ for i := 0; i < 7; i++ {
+ if err = cURLGet(epc, cURLReq{endpoint: "/version", expected: `"etcdcluster":"` + version.Cluster(version.Version)}); err != nil {
+ t.Logf("#%d: v3 is not ready yet (%v)", i, err)
+ time.Sleep(time.Second)
+ continue
+ }
+ break
+ }
+ if err != nil {
+ t.Fatalf("cannot pull version (%v)", err)
+ }
+
+ os.Setenv("ETCDCTL_API", "3")
+ defer os.Unsetenv("ETCDCTL_API")
+ cx := ctlCtx{
+ t: t,
+ cfg: configNoTLS,
+ dialTimeout: 7 * time.Second,
+ quorum: true,
+ epc: epc,
+ }
+ var kvs []kv
+ for i := 0; i < 5; i++ {
+ kvs = append(kvs, kv{key: fmt.Sprintf("foo%d", i), val: "bar"})
+ }
+ for i := range kvs {
+ if err := ctlV3Put(cx, kvs[i].key, kvs[i].val, ""); err != nil {
+ cx.t.Fatalf("#%d: ctlV3Put error (%v)", i, err)
+ }
+ }
+
+ for i := range epc.procs {
+ if err := epc.procs[i].Stop(); err != nil {
+ t.Fatalf("#%d: error closing etcd process (%v)", i, err)
+ }
+ epc.procs[i].cfg.execPath = binDir + "/etcd"
+ epc.procs[i].cfg.keepDataDir = true
+
+ if err := epc.procs[i].Restart(); err != nil {
+ t.Fatalf("error restarting etcd process (%v)", err)
+ }
+
+ for j := range kvs {
+ if err := ctlV3Get(cx, []string{kvs[j].key}, []kv{kvs[j]}...); err != nil {
+ cx.t.Fatalf("#%d-%d: ctlV3Get error (%v)", i, j, err)
+ }
+ }
+ }
+}
+
+func TestReleaseUpgradeWithRestart(t *testing.T) {
+ lastReleaseBinary := binDir + "/etcd-last-release"
+ if !fileutil.Exist(lastReleaseBinary) {
+ t.Skipf("%q does not exist", lastReleaseBinary)
+ }
+
+ defer testutil.AfterTest(t)
+
+ copiedCfg := configNoTLS
+ copiedCfg.execPath = lastReleaseBinary
+ copiedCfg.snapCount = 10
+ copiedCfg.baseScheme = "unix"
+
+ epc, err := newEtcdProcessCluster(&copiedCfg)
+ if err != nil {
+ t.Fatalf("could not start etcd process cluster (%v)", err)
+ }
+ defer func() {
+ if errC := epc.Close(); errC != nil {
+ t.Fatalf("error closing etcd processes (%v)", errC)
+ }
+ }()
+
+ os.Setenv("ETCDCTL_API", "3")
+ defer os.Unsetenv("ETCDCTL_API")
+ cx := ctlCtx{
+ t: t,
+ cfg: configNoTLS,
+ dialTimeout: 7 * time.Second,
+ quorum: true,
+ epc: epc,
+ }
+ var kvs []kv
+ for i := 0; i < 50; i++ {
+ kvs = append(kvs, kv{key: fmt.Sprintf("foo%d", i), val: "bar"})
+ }
+ for i := range kvs {
+ if err := ctlV3Put(cx, kvs[i].key, kvs[i].val, ""); err != nil {
+ cx.t.Fatalf("#%d: ctlV3Put error (%v)", i, err)
+ }
+ }
+
+ for i := range epc.procs {
+ if err := epc.procs[i].Stop(); err != nil {
+ t.Fatalf("#%d: error closing etcd process (%v)", i, err)
+ }
+ }
+
+ var wg sync.WaitGroup
+ wg.Add(len(epc.procs))
+ for i := range epc.procs {
+ go func(i int) {
+ epc.procs[i].cfg.execPath = binDir + "/etcd"
+ epc.procs[i].cfg.keepDataDir = true
+ if err := epc.procs[i].Restart(); err != nil {
+ t.Fatalf("error restarting etcd process (%v)", err)
+ }
+ wg.Done()
+ }(i)
+ }
+ wg.Wait()
+
+ if err := ctlV3Get(cx, []string{kvs[0].key}, []kv{kvs[0]}...); err != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/etcd_spawn_cov.go b/vendor/github.com/coreos/etcd/e2e/etcd_spawn_cov.go
new file mode 100644
index 00000000..840cde49
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/etcd_spawn_cov.go
@@ -0,0 +1,116 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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.
+
+// +build cov
+
+package e2e
+
+import (
+ "fmt"
+ "os"
+ "path/filepath"
+ "strings"
+ "syscall"
+ "time"
+
+ "github.com/coreos/etcd/pkg/expect"
+ "github.com/coreos/etcd/pkg/fileutil"
+ "github.com/coreos/etcd/pkg/flags"
+)
+
+const noOutputLineCount = 2 // cov-enabled binaries emit PASS and coverage count lines
+
+func spawnCmd(args []string) (*expect.ExpectProcess, error) {
+ if args[0] == binPath {
+ covArgs, err := getCovArgs()
+ if err != nil {
+ return nil, err
+ }
+ ep, err := expect.NewExpectWithEnv(binDir+"/etcd_test", covArgs, args2env(args[1:]))
+ if err != nil {
+ return nil, err
+ }
+ // ep sends SIGTERM to etcd_test process on ep.close()
+ // allowing the process to exit gracefully in order to generate a coverage report.
+ // note: go runtime ignores SIGINT but not SIGTERM
+ // if e2e test is run as a background process.
+ ep.StopSignal = syscall.SIGTERM
+ return ep, nil
+ }
+
+ if args[0] == ctlBinPath {
+ covArgs, err := getCovArgs()
+ if err != nil {
+ return nil, err
+ }
+ // avoid test flag conflicts in coverage enabled etcdctl by putting flags in ETCDCTL_ARGS
+ ctl_cov_env := []string{
+ "ETCDCTL_ARGS" + "=" + strings.Join(args, "\xff"),
+ }
+ // when withFlagByEnv() is used in testCtl(), env variables for ctl is set to os.env.
+ // they must be included in ctl_cov_env.
+ ctl_cov_env = append(ctl_cov_env, os.Environ()...)
+ ep, err := expect.NewExpectWithEnv(binDir+"/etcdctl_test", covArgs, ctl_cov_env)
+ if err != nil {
+ return nil, err
+ }
+ ep.StopSignal = syscall.SIGTERM
+ return ep, nil
+ }
+
+ return expect.NewExpect(args[0], args[1:]...)
+}
+
+func getCovArgs() ([]string, error) {
+ coverPath := os.Getenv("COVERDIR")
+ if !filepath.IsAbs(coverPath) {
+ // COVERDIR is relative to etcd root but e2e test has its path set to be relative to the e2e folder.
+ // adding ".." in front of COVERDIR ensures that e2e saves coverage reports to the correct location.
+ coverPath = filepath.Join("..", coverPath)
+ }
+ if !fileutil.Exist(coverPath) {
+ return nil, fmt.Errorf("could not find coverage folder")
+ }
+ covArgs := []string{
+ fmt.Sprintf("-test.coverprofile=e2e.%v.coverprofile", time.Now().UnixNano()),
+ "-test.outputdir=" + coverPath,
+ }
+ return covArgs, nil
+}
+
+func args2env(args []string) []string {
+ var covEnvs []string
+ for i := range args[1:] {
+ if !strings.HasPrefix(args[i], "--") {
+ continue
+ }
+ flag := strings.Split(args[i], "--")[1]
+ val := "true"
+ // split the flag that has "="
+ // e.g --auto-tls=true" => flag=auto-tls and val=true
+ if strings.Contains(args[i], "=") {
+ split := strings.Split(flag, "=")
+ flag = split[0]
+ val = split[1]
+ }
+
+ if i+1 < len(args) {
+ if !strings.HasPrefix(args[i+1], "--") {
+ val = args[i+1]
+ }
+ }
+ covEnvs = append(covEnvs, flags.FlagToEnv("ETCD", flag)+"="+val)
+ }
+ return covEnvs
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/etcd_spawn_nocov.go b/vendor/github.com/coreos/etcd/e2e/etcd_spawn_nocov.go
new file mode 100644
index 00000000..82243e7e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/etcd_spawn_nocov.go
@@ -0,0 +1,25 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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.
+
+// +build !cov
+
+package e2e
+
+import "github.com/coreos/etcd/pkg/expect"
+
+const noOutputLineCount = 0 // regular binaries emit no extra lines
+
+func spawnCmd(args []string) (*expect.ExpectProcess, error) {
+ return expect.NewExpect(args[0], args[1:]...)
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/etcd_test.go b/vendor/github.com/coreos/etcd/e2e/etcd_test.go
new file mode 100644
index 00000000..c15f95d6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/etcd_test.go
@@ -0,0 +1,578 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "fmt"
+ "io/ioutil"
+ "net/url"
+ "os"
+ "strings"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/pkg/expect"
+ "github.com/coreos/etcd/pkg/fileutil"
+)
+
+const etcdProcessBasePort = 20000
+
+var (
+ binPath string
+ ctlBinPath string
+ certPath string
+ privateKeyPath string
+ caPath string
+)
+
+type clientConnType int
+
+const (
+ clientNonTLS clientConnType = iota
+ clientTLS
+ clientTLSAndNonTLS
+)
+
+var (
+ configNoTLS = etcdProcessClusterConfig{
+ clusterSize: 3,
+ proxySize: 0,
+ initialToken: "new",
+ }
+ configAutoTLS = etcdProcessClusterConfig{
+ clusterSize: 3,
+ isPeerTLS: true,
+ isPeerAutoTLS: true,
+ initialToken: "new",
+ }
+ configTLS = etcdProcessClusterConfig{
+ clusterSize: 3,
+ proxySize: 0,
+ clientTLS: clientTLS,
+ isPeerTLS: true,
+ initialToken: "new",
+ }
+ configClientTLS = etcdProcessClusterConfig{
+ clusterSize: 3,
+ proxySize: 0,
+ clientTLS: clientTLS,
+ initialToken: "new",
+ }
+ configClientBoth = etcdProcessClusterConfig{
+ clusterSize: 1,
+ proxySize: 0,
+ clientTLS: clientTLSAndNonTLS,
+ initialToken: "new",
+ }
+ configClientAutoTLS = etcdProcessClusterConfig{
+ clusterSize: 1,
+ proxySize: 0,
+ isClientAutoTLS: true,
+ clientTLS: clientTLS,
+ initialToken: "new",
+ }
+ configPeerTLS = etcdProcessClusterConfig{
+ clusterSize: 3,
+ proxySize: 0,
+ isPeerTLS: true,
+ initialToken: "new",
+ }
+ configWithProxy = etcdProcessClusterConfig{
+ clusterSize: 3,
+ proxySize: 1,
+ initialToken: "new",
+ }
+ configWithProxyTLS = etcdProcessClusterConfig{
+ clusterSize: 3,
+ proxySize: 1,
+ clientTLS: clientTLS,
+ isPeerTLS: true,
+ initialToken: "new",
+ }
+ configWithProxyPeerTLS = etcdProcessClusterConfig{
+ clusterSize: 3,
+ proxySize: 1,
+ isPeerTLS: true,
+ initialToken: "new",
+ }
+ configClientTLSCertAuth = etcdProcessClusterConfig{
+ clusterSize: 1,
+ proxySize: 0,
+ clientTLS: clientTLS,
+ initialToken: "new",
+ clientCertAuthEnabled: true,
+ }
+)
+
+func configStandalone(cfg etcdProcessClusterConfig) *etcdProcessClusterConfig {
+ ret := cfg
+ ret.clusterSize = 1
+ return &ret
+}
+
+type etcdProcessCluster struct {
+ cfg *etcdProcessClusterConfig
+ procs []*etcdProcess
+}
+
+type etcdProcess struct {
+ cfg *etcdProcessConfig
+ proc *expect.ExpectProcess
+ donec chan struct{} // closed when Interact() terminates
+}
+
+type etcdProcessConfig struct {
+ execPath string
+ args []string
+
+ dataDirPath string
+ keepDataDir bool
+
+ name string
+
+ purl url.URL
+
+ acurl string
+ // additional url for tls connection when the etcd process
+ // serves both http and https
+ acurltls string
+ acurlHost string
+
+ initialToken string
+ initialCluster string
+
+ isProxy bool
+}
+
+type etcdProcessClusterConfig struct {
+ execPath string
+ dataDirPath string
+ keepDataDir bool
+
+ clusterSize int
+
+ baseScheme string
+ basePort int
+
+ proxySize int
+
+ snapCount int // default is 10000
+
+ clientTLS clientConnType
+ clientCertAuthEnabled bool
+ isPeerTLS bool
+ isPeerAutoTLS bool
+ isClientAutoTLS bool
+ forceNewCluster bool
+ initialToken string
+ quotaBackendBytes int64
+ noStrictReconfig bool
+}
+
+// newEtcdProcessCluster launches a new cluster from etcd processes, returning
+// a new etcdProcessCluster once all nodes are ready to accept client requests.
+func newEtcdProcessCluster(cfg *etcdProcessClusterConfig) (*etcdProcessCluster, error) {
+ etcdCfgs := cfg.etcdProcessConfigs()
+ epc := &etcdProcessCluster{
+ cfg: cfg,
+ procs: make([]*etcdProcess, cfg.clusterSize+cfg.proxySize),
+ }
+
+ // launch etcd processes
+ for i := range etcdCfgs {
+ proc, err := newEtcdProcess(etcdCfgs[i])
+ if err != nil {
+ epc.Close()
+ return nil, err
+ }
+ epc.procs[i] = proc
+ }
+
+ return epc, epc.Start()
+}
+
+func newEtcdProcess(cfg *etcdProcessConfig) (*etcdProcess, error) {
+ if !fileutil.Exist(cfg.execPath) {
+ return nil, fmt.Errorf("could not find etcd binary")
+ }
+
+ if !cfg.keepDataDir {
+ if err := os.RemoveAll(cfg.dataDirPath); err != nil {
+ return nil, err
+ }
+ }
+
+ child, err := spawnCmd(append([]string{cfg.execPath}, cfg.args...))
+ if err != nil {
+ return nil, err
+ }
+ return &etcdProcess{cfg: cfg, proc: child, donec: make(chan struct{})}, nil
+}
+
+func (cfg *etcdProcessClusterConfig) etcdProcessConfigs() []*etcdProcessConfig {
+ binPath = binDir + "/etcd"
+ ctlBinPath = binDir + "/etcdctl"
+ certPath = certDir + "/server.crt"
+ privateKeyPath = certDir + "/server.key.insecure"
+ caPath = certDir + "/ca.crt"
+
+ if cfg.basePort == 0 {
+ cfg.basePort = etcdProcessBasePort
+ }
+
+ if cfg.execPath == "" {
+ cfg.execPath = binPath
+ }
+ if cfg.snapCount == 0 {
+ cfg.snapCount = etcdserver.DefaultSnapCount
+ }
+
+ clientScheme := "http"
+ if cfg.clientTLS == clientTLS {
+ clientScheme = "https"
+ }
+ peerScheme := cfg.baseScheme
+ if peerScheme == "" {
+ peerScheme = "http"
+ }
+ if cfg.isPeerTLS {
+ peerScheme += "s"
+ }
+
+ etcdCfgs := make([]*etcdProcessConfig, cfg.clusterSize+cfg.proxySize)
+ initialCluster := make([]string, cfg.clusterSize)
+ for i := 0; i < cfg.clusterSize; i++ {
+ var curls []string
+ var curl, curltls string
+ port := cfg.basePort + 2*i
+ curlHost := fmt.Sprintf("localhost:%d", port)
+
+ switch cfg.clientTLS {
+ case clientNonTLS, clientTLS:
+ curl = (&url.URL{Scheme: clientScheme, Host: curlHost}).String()
+ curls = []string{curl}
+ case clientTLSAndNonTLS:
+ curl = (&url.URL{Scheme: "http", Host: curlHost}).String()
+ curltls = (&url.URL{Scheme: "https", Host: curlHost}).String()
+ curls = []string{curl, curltls}
+ }
+
+ purl := url.URL{Scheme: peerScheme, Host: fmt.Sprintf("localhost:%d", port+1)}
+ name := fmt.Sprintf("testname%d", i)
+ dataDirPath := cfg.dataDirPath
+ if cfg.dataDirPath == "" {
+ var derr error
+ dataDirPath, derr = ioutil.TempDir("", name+".etcd")
+ if derr != nil {
+ panic("could not get tempdir for datadir")
+ }
+ }
+ initialCluster[i] = fmt.Sprintf("%s=%s", name, purl.String())
+
+ args := []string{
+ "--name", name,
+ "--listen-client-urls", strings.Join(curls, ","),
+ "--advertise-client-urls", strings.Join(curls, ","),
+ "--listen-peer-urls", purl.String(),
+ "--initial-advertise-peer-urls", purl.String(),
+ "--initial-cluster-token", cfg.initialToken,
+ "--data-dir", dataDirPath,
+ "--snapshot-count", fmt.Sprintf("%d", cfg.snapCount),
+ }
+ if cfg.forceNewCluster {
+ args = append(args, "--force-new-cluster")
+ }
+ if cfg.quotaBackendBytes > 0 {
+ args = append(args,
+ "--quota-backend-bytes", fmt.Sprintf("%d", cfg.quotaBackendBytes),
+ )
+ }
+ if cfg.noStrictReconfig {
+ args = append(args, "--strict-reconfig-check=false")
+ }
+
+ args = append(args, cfg.tlsArgs()...)
+ etcdCfgs[i] = &etcdProcessConfig{
+ execPath: cfg.execPath,
+ args: args,
+ dataDirPath: dataDirPath,
+ keepDataDir: cfg.keepDataDir,
+ name: name,
+ purl: purl,
+ acurl: curl,
+ acurltls: curltls,
+ acurlHost: curlHost,
+ initialToken: cfg.initialToken,
+ }
+ }
+ for i := 0; i < cfg.proxySize; i++ {
+ port := cfg.basePort + 2*cfg.clusterSize + i + 1
+ curlHost := fmt.Sprintf("localhost:%d", port)
+ curl := url.URL{Scheme: clientScheme, Host: curlHost}
+ name := fmt.Sprintf("testname-proxy%d", i)
+ dataDirPath, derr := ioutil.TempDir("", name+".etcd")
+ if derr != nil {
+ panic("could not get tempdir for datadir")
+ }
+ args := []string{
+ "--name", name,
+ "--proxy", "on",
+ "--listen-client-urls", curl.String(),
+ "--data-dir", dataDirPath,
+ }
+ args = append(args, cfg.tlsArgs()...)
+ etcdCfgs[cfg.clusterSize+i] = &etcdProcessConfig{
+ execPath: cfg.execPath,
+ args: args,
+ dataDirPath: dataDirPath,
+ keepDataDir: cfg.keepDataDir,
+ name: name,
+ acurl: curl.String(),
+ acurlHost: curlHost,
+ isProxy: true,
+ }
+ }
+
+ initialClusterArgs := []string{"--initial-cluster", strings.Join(initialCluster, ",")}
+ for i := range etcdCfgs {
+ etcdCfgs[i].initialCluster = strings.Join(initialCluster, ",")
+ etcdCfgs[i].args = append(etcdCfgs[i].args, initialClusterArgs...)
+ }
+
+ return etcdCfgs
+}
+
+func (cfg *etcdProcessClusterConfig) tlsArgs() (args []string) {
+ if cfg.clientTLS != clientNonTLS {
+ if cfg.isClientAutoTLS {
+ args = append(args, "--auto-tls=true")
+ } else {
+ tlsClientArgs := []string{
+ "--cert-file", certPath,
+ "--key-file", privateKeyPath,
+ "--ca-file", caPath,
+ }
+ args = append(args, tlsClientArgs...)
+
+ if cfg.clientCertAuthEnabled {
+ args = append(args, "--client-cert-auth")
+ }
+ }
+ }
+
+ if cfg.isPeerTLS {
+ if cfg.isPeerAutoTLS {
+ args = append(args, "--peer-auto-tls=true")
+ } else {
+ tlsPeerArgs := []string{
+ "--peer-cert-file", certPath,
+ "--peer-key-file", privateKeyPath,
+ "--peer-ca-file", caPath,
+ }
+ args = append(args, tlsPeerArgs...)
+ }
+ }
+ return args
+}
+
+func (epc *etcdProcessCluster) Start() (err error) {
+ readyC := make(chan error, epc.cfg.clusterSize+epc.cfg.proxySize)
+ for i := range epc.procs {
+ go func(n int) { readyC <- epc.procs[n].waitReady() }(i)
+ }
+ for range epc.procs {
+ if err := <-readyC; err != nil {
+ epc.Close()
+ return err
+ }
+ }
+ return nil
+}
+
+func (epc *etcdProcessCluster) RestartAll() error {
+ for i := range epc.procs {
+ proc, err := newEtcdProcess(epc.procs[i].cfg)
+ if err != nil {
+ epc.Close()
+ return err
+ }
+ epc.procs[i] = proc
+ }
+ return epc.Start()
+}
+
+func (epc *etcdProcessCluster) StopAll() (err error) {
+ for _, p := range epc.procs {
+ if p == nil {
+ continue
+ }
+ if curErr := p.Stop(); curErr != nil {
+ if err != nil {
+ err = fmt.Errorf("%v; %v", err, curErr)
+ } else {
+ err = curErr
+ }
+ }
+ }
+ return err
+}
+
+func (epc *etcdProcessCluster) Close() error {
+ err := epc.StopAll()
+ for _, p := range epc.procs {
+ // p is nil when newEtcdProcess fails in the middle
+ // Close still gets called to clean up test data
+ if p == nil {
+ continue
+ }
+ os.RemoveAll(p.cfg.dataDirPath)
+ }
+ return err
+}
+
+func (ep *etcdProcess) Restart() error {
+ newEp, err := newEtcdProcess(ep.cfg)
+ if err != nil {
+ ep.Stop()
+ return err
+ }
+ *ep = *newEp
+ if err = ep.waitReady(); err != nil {
+ ep.Stop()
+ return err
+ }
+ return nil
+}
+
+func (ep *etcdProcess) Stop() error {
+ if ep == nil {
+ return nil
+ }
+ if err := ep.proc.Stop(); err != nil {
+ return err
+ }
+ <-ep.donec
+
+ if ep.cfg.purl.Scheme == "unix" || ep.cfg.purl.Scheme == "unixs" {
+ os.Remove(ep.cfg.purl.Host + ep.cfg.purl.Path)
+ }
+ return nil
+}
+
+func (ep *etcdProcess) waitReady() error {
+ defer close(ep.donec)
+ return waitReadyExpectProc(ep.proc, ep.cfg.isProxy)
+}
+
+func waitReadyExpectProc(exproc *expect.ExpectProcess, isProxy bool) error {
+ readyStrs := []string{"enabled capabilities for version", "published"}
+ if isProxy {
+ readyStrs = []string{"httpproxy: endpoints found"}
+ }
+ c := 0
+ matchSet := func(l string) bool {
+ for _, s := range readyStrs {
+ if strings.Contains(l, s) {
+ c++
+ break
+ }
+ }
+ return c == len(readyStrs)
+ }
+ _, err := exproc.ExpectFunc(matchSet)
+ return err
+}
+
+func spawnWithExpect(args []string, expected string) error {
+ return spawnWithExpects(args, []string{expected}...)
+}
+
+func spawnWithExpects(args []string, xs ...string) error {
+ proc, err := spawnCmd(args)
+ if err != nil {
+ return err
+ }
+ // process until either stdout or stderr contains
+ // the expected string
+ var (
+ lines []string
+ lineFunc = func(txt string) bool { return true }
+ )
+ for _, txt := range xs {
+ for {
+ l, lerr := proc.ExpectFunc(lineFunc)
+ if lerr != nil {
+ proc.Close()
+ return fmt.Errorf("%v (expected %q, got %q)", lerr, txt, lines)
+ }
+ lines = append(lines, l)
+ if strings.Contains(l, txt) {
+ break
+ }
+ }
+ }
+ perr := proc.Close()
+ if len(xs) == 0 && proc.LineCount() != noOutputLineCount { // expect no output
+ return fmt.Errorf("unexpected output (got lines %q, line count %d)", lines, proc.LineCount())
+ }
+ return perr
+}
+
+// proxies returns only the proxy etcdProcess.
+func (epc *etcdProcessCluster) proxies() []*etcdProcess {
+ return epc.procs[epc.cfg.clusterSize:]
+}
+
+func (epc *etcdProcessCluster) processes() []*etcdProcess {
+ return epc.procs[:epc.cfg.clusterSize]
+}
+
+func (epc *etcdProcessCluster) endpoints() []string {
+ eps := make([]string, epc.cfg.clusterSize)
+ for i, ep := range epc.processes() {
+ eps[i] = ep.cfg.acurl
+ }
+ return eps
+}
+
+func (epc *etcdProcessCluster) grpcEndpoints() []string {
+ eps := make([]string, epc.cfg.clusterSize)
+ for i, ep := range epc.processes() {
+ eps[i] = ep.cfg.acurlHost
+ }
+ return eps
+}
+
+func (epc *etcdProcessCluster) withStopSignal(sig os.Signal) os.Signal {
+ ret := epc.procs[0].proc.StopSignal
+ for _, p := range epc.procs {
+ p.proc.StopSignal = sig
+ }
+ return ret
+}
+
+func closeWithTimeout(p *expect.ExpectProcess, d time.Duration) error {
+ errc := make(chan error, 1)
+ go func() { errc <- p.Close() }()
+ select {
+ case err := <-errc:
+ return err
+ case <-time.After(d):
+ p.Stop()
+ // retry close after stopping to collect SIGQUIT data, if any
+ closeWithTimeout(p, time.Second)
+ }
+ return fmt.Errorf("took longer than %v to Close process %+v", d, p)
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/gateway_test.go b/vendor/github.com/coreos/etcd/e2e/gateway_test.go
new file mode 100644
index 00000000..9eee0170
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/gateway_test.go
@@ -0,0 +1,60 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "os"
+ "strings"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/expect"
+)
+
+var (
+ defaultGatewayEndpoint = "127.0.0.1:23790"
+)
+
+func TestGateway(t *testing.T) {
+ ec, err := newEtcdProcessCluster(&configNoTLS)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer ec.StopAll()
+
+ eps := strings.Join(ec.grpcEndpoints(), ",")
+
+ p := startGateway(t, eps)
+ defer p.Stop()
+
+ os.Setenv("ETCDCTL_API", "3")
+ defer os.Unsetenv("ETCDCTL_API")
+
+ err = spawnWithExpect([]string{ctlBinPath, "--endpoints=" + defaultGatewayEndpoint, "put", "foo", "bar"}, "OK\r\n")
+ if err != nil {
+ t.Errorf("failed to finish put request through gateway: %v", err)
+ }
+}
+
+func startGateway(t *testing.T, endpoints string) *expect.ExpectProcess {
+ p, err := expect.NewExpect(binPath, "gateway", "--endpoints="+endpoints, "start")
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, err = p.Expect("tcpproxy: ready to proxy client requests to")
+ if err != nil {
+ t.Fatal(err)
+ }
+ return p
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/main_test.go b/vendor/github.com/coreos/etcd/e2e/main_test.go
new file mode 100644
index 00000000..59589507
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/main_test.go
@@ -0,0 +1,32 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package e2e
+
+import (
+ "flag"
+ "os"
+ "runtime"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+var binDir string
+var certDir string
+
+func TestMain(m *testing.M) {
+ os.Setenv("ETCD_UNSUPPORTED_ARCH", runtime.GOARCH)
+ os.Unsetenv("ETCDCTL_API")
+
+ flag.StringVar(&binDir, "bin-dir", "../bin", "The directory for store etcd and etcdctl binaries.")
+ flag.StringVar(&certDir, "cert-dir", "../integration/fixtures", "The directory for store certificate files.")
+ flag.Parse()
+
+ v := m.Run()
+ if v == 0 && testutil.CheckLeakedGoroutine() {
+ os.Exit(1)
+ }
+ os.Exit(v)
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/v2_curl_test.go b/vendor/github.com/coreos/etcd/e2e/v2_curl_test.go
new file mode 100644
index 00000000..289d64c0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/v2_curl_test.go
@@ -0,0 +1,180 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "fmt"
+ "math/rand"
+ "strings"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestV2CurlNoTLS(t *testing.T) { testCurlPutGet(t, &configNoTLS) }
+func TestV2CurlAutoTLS(t *testing.T) { testCurlPutGet(t, &configAutoTLS) }
+func TestV2CurlAllTLS(t *testing.T) { testCurlPutGet(t, &configTLS) }
+func TestV2CurlPeerTLS(t *testing.T) { testCurlPutGet(t, &configPeerTLS) }
+func TestV2CurlClientTLS(t *testing.T) { testCurlPutGet(t, &configClientTLS) }
+func TestV2CurlProxyNoTLS(t *testing.T) { testCurlPutGet(t, &configWithProxy) }
+func TestV2CurlProxyTLS(t *testing.T) { testCurlPutGet(t, &configWithProxyTLS) }
+func TestV2CurlProxyPeerTLS(t *testing.T) { testCurlPutGet(t, &configWithProxyPeerTLS) }
+func TestV2CurlClientBoth(t *testing.T) { testCurlPutGet(t, &configClientBoth) }
+func testCurlPutGet(t *testing.T, cfg *etcdProcessClusterConfig) {
+ defer testutil.AfterTest(t)
+
+ // test doesn't use quorum gets, so ensure there are no followers to avoid
+ // stale reads that will break the test
+ cfg = configStandalone(*cfg)
+
+ epc, err := newEtcdProcessCluster(cfg)
+ if err != nil {
+ t.Fatalf("could not start etcd process cluster (%v)", err)
+ }
+ defer func() {
+ if err := epc.Close(); err != nil {
+ t.Fatalf("error closing etcd processes (%v)", err)
+ }
+ }()
+
+ var (
+ expectPut = `{"action":"set","node":{"key":"/foo","value":"bar","`
+ expectGet = `{"action":"get","node":{"key":"/foo","value":"bar","`
+ )
+ if err := cURLPut(epc, cURLReq{endpoint: "/v2/keys/foo", value: "bar", expected: expectPut}); err != nil {
+ t.Fatalf("failed put with curl (%v)", err)
+ }
+ if err := cURLGet(epc, cURLReq{endpoint: "/v2/keys/foo", expected: expectGet}); err != nil {
+ t.Fatalf("failed get with curl (%v)", err)
+ }
+ if cfg.clientTLS == clientTLSAndNonTLS {
+ if err := cURLGet(epc, cURLReq{endpoint: "/v2/keys/foo", expected: expectGet, isTLS: true}); err != nil {
+ t.Fatalf("failed get with curl (%v)", err)
+ }
+ }
+}
+
+func TestV2CurlIssue5182(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ epc := setupEtcdctlTest(t, &configNoTLS, false)
+ defer func() {
+ if err := epc.Close(); err != nil {
+ t.Fatalf("error closing etcd processes (%v)", err)
+ }
+ }()
+
+ expectPut := `{"action":"set","node":{"key":"/foo","value":"bar","`
+ if err := cURLPut(epc, cURLReq{endpoint: "/v2/keys/foo", value: "bar", expected: expectPut}); err != nil {
+ t.Fatal(err)
+ }
+
+ expectUserAdd := `{"user":"foo","roles":null}`
+ if err := cURLPut(epc, cURLReq{endpoint: "/v2/auth/users/foo", value: `{"user":"foo", "password":"pass"}`, expected: expectUserAdd}); err != nil {
+ t.Fatal(err)
+ }
+ expectRoleAdd := `{"role":"foo","permissions":{"kv":{"read":["/foo/*"],"write":null}}`
+ if err := cURLPut(epc, cURLReq{endpoint: "/v2/auth/roles/foo", value: `{"role":"foo", "permissions": {"kv": {"read": ["/foo/*"]}}}`, expected: expectRoleAdd}); err != nil {
+ t.Fatal(err)
+ }
+ expectUserUpdate := `{"user":"foo","roles":["foo"]}`
+ if err := cURLPut(epc, cURLReq{endpoint: "/v2/auth/users/foo", value: `{"user": "foo", "grant": ["foo"]}`, expected: expectUserUpdate}); err != nil {
+ t.Fatal(err)
+ }
+
+ if err := etcdctlUserAdd(epc, "root", "a"); err != nil {
+ t.Fatal(err)
+ }
+ if err := etcdctlAuthEnable(epc); err != nil {
+ t.Fatal(err)
+ }
+
+ if err := cURLGet(epc, cURLReq{endpoint: "/v2/keys/foo/", username: "root", password: "a", expected: "bar"}); err != nil {
+ t.Fatal(err)
+ }
+ if err := cURLGet(epc, cURLReq{endpoint: "/v2/keys/foo/", username: "foo", password: "pass", expected: "bar"}); err != nil {
+ t.Fatal(err)
+ }
+ if err := cURLGet(epc, cURLReq{endpoint: "/v2/keys/foo/", username: "foo", password: "", expected: "bar"}); err != nil {
+ if !strings.Contains(err.Error(), `The request requires user authentication`) {
+ t.Fatalf("expected 'The request requires user authentication' error, got %v", err)
+ }
+ } else {
+ t.Fatalf("expected 'The request requires user authentication' error")
+ }
+}
+
+type cURLReq struct {
+ username string
+ password string
+
+ isTLS bool
+ timeout int
+
+ endpoint string
+
+ value string
+ expected string
+}
+
+// cURLPrefixArgs builds the beginning of a curl command for a given key
+// addressed to a random URL in the given cluster.
+func cURLPrefixArgs(clus *etcdProcessCluster, method string, req cURLReq) []string {
+ var (
+ cmdArgs = []string{"curl"}
+ acurl = clus.procs[rand.Intn(clus.cfg.clusterSize)].cfg.acurl
+ )
+ if req.isTLS {
+ if clus.cfg.clientTLS != clientTLSAndNonTLS {
+ panic("should not use cURLPrefixArgsUseTLS when serving only TLS or non-TLS")
+ }
+ cmdArgs = append(cmdArgs, "--cacert", caPath, "--cert", certPath, "--key", privateKeyPath)
+ acurl = clus.procs[rand.Intn(clus.cfg.clusterSize)].cfg.acurltls
+ } else if clus.cfg.clientTLS == clientTLS {
+ cmdArgs = append(cmdArgs, "--cacert", caPath, "--cert", certPath, "--key", privateKeyPath)
+ }
+ ep := acurl + req.endpoint
+
+ if req.username != "" || req.password != "" {
+ cmdArgs = append(cmdArgs, "-L", "-u", fmt.Sprintf("%s:%s", req.username, req.password), ep)
+ } else {
+ cmdArgs = append(cmdArgs, "-L", ep)
+ }
+ if req.timeout != 0 {
+ cmdArgs = append(cmdArgs, "-m", fmt.Sprintf("%d", req.timeout))
+ }
+
+ switch method {
+ case "POST", "PUT":
+ dt := req.value
+ if !strings.HasPrefix(dt, "{") { // for non-JSON value
+ dt = "value=" + dt
+ }
+ cmdArgs = append(cmdArgs, "-X", method, "-d", dt)
+ }
+ return cmdArgs
+}
+
+func cURLPost(clus *etcdProcessCluster, req cURLReq) error {
+ return spawnWithExpect(cURLPrefixArgs(clus, "POST", req), req.expected)
+}
+
+func cURLPut(clus *etcdProcessCluster, req cURLReq) error {
+ return spawnWithExpect(cURLPrefixArgs(clus, "PUT", req), req.expected)
+}
+
+func cURLGet(clus *etcdProcessCluster, req cURLReq) error {
+ return spawnWithExpect(cURLPrefixArgs(clus, "GET", req), req.expected)
+}
diff --git a/vendor/github.com/coreos/etcd/e2e/v3_curl_test.go b/vendor/github.com/coreos/etcd/e2e/v3_curl_test.go
new file mode 100644
index 00000000..af137c4a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/e2e/v3_curl_test.go
@@ -0,0 +1,164 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 e2e
+
+import (
+ "encoding/json"
+ "testing"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/testutil"
+
+ "github.com/grpc-ecosystem/grpc-gateway/runtime"
+)
+
+func TestV3CurlPutGetNoTLS(t *testing.T) { testCurlPutGetGRPCGateway(t, &configNoTLS) }
+func TestV3CurlPutGetAutoTLS(t *testing.T) { testCurlPutGetGRPCGateway(t, &configAutoTLS) }
+func TestV3CurlPutGetAllTLS(t *testing.T) { testCurlPutGetGRPCGateway(t, &configTLS) }
+func TestV3CurlPutGetPeerTLS(t *testing.T) { testCurlPutGetGRPCGateway(t, &configPeerTLS) }
+func TestV3CurlPutGetClientTLS(t *testing.T) { testCurlPutGetGRPCGateway(t, &configClientTLS) }
+func testCurlPutGetGRPCGateway(t *testing.T, cfg *etcdProcessClusterConfig) {
+ defer testutil.AfterTest(t)
+
+ epc, err := newEtcdProcessCluster(cfg)
+ if err != nil {
+ t.Fatalf("could not start etcd process cluster (%v)", err)
+ }
+ defer func() {
+ if cerr := epc.Close(); err != nil {
+ t.Fatalf("error closing etcd processes (%v)", cerr)
+ }
+ }()
+
+ var (
+ key = []byte("foo")
+ value = []byte("bar") // this will be automatically base64-encoded by Go
+
+ expectPut = `"revision":"`
+ expectGet = `"value":"`
+ )
+ putData, err := json.Marshal(&pb.PutRequest{
+ Key: key,
+ Value: value,
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ rangeData, err := json.Marshal(&pb.RangeRequest{
+ Key: key,
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if err := cURLPost(epc, cURLReq{endpoint: "/v3alpha/kv/put", value: string(putData), expected: expectPut}); err != nil {
+ t.Fatalf("failed put with curl (%v)", err)
+ }
+ if err := cURLPost(epc, cURLReq{endpoint: "/v3alpha/kv/range", value: string(rangeData), expected: expectGet}); err != nil {
+ t.Fatalf("failed get with curl (%v)", err)
+ }
+
+ if cfg.clientTLS == clientTLSAndNonTLS {
+ if err := cURLPost(epc, cURLReq{endpoint: "/v3alpha/kv/range", value: string(rangeData), expected: expectGet, isTLS: true}); err != nil {
+ t.Fatalf("failed get with curl (%v)", err)
+ }
+ }
+}
+
+func TestV3CurlWatch(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ epc, err := newEtcdProcessCluster(&configNoTLS)
+ if err != nil {
+ t.Fatalf("could not start etcd process cluster (%v)", err)
+ }
+ defer func() {
+ if cerr := epc.Close(); err != nil {
+ t.Fatalf("error closing etcd processes (%v)", cerr)
+ }
+ }()
+
+ // store "bar" into "foo"
+ putreq, err := json.Marshal(&pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = cURLPost(epc, cURLReq{endpoint: "/v3alpha/kv/put", value: string(putreq), expected: "revision"}); err != nil {
+ t.Fatalf("failed put with curl (%v)", err)
+ }
+ // watch for first update to "foo"
+ wcr := &pb.WatchCreateRequest{Key: []byte("foo"), StartRevision: 1}
+ wreq, err := json.Marshal(wcr)
+ if err != nil {
+ t.Fatal(err)
+ }
+ // marshaling the grpc to json gives:
+ // "{"RequestUnion":{"CreateRequest":{"key":"Zm9v","start_revision":1}}}"
+ // but the gprc-gateway expects a different format..
+ wstr := `{"create_request" : ` + string(wreq) + "}"
+ // expects "bar", timeout after 2 seconds since stream waits forever
+ if err = cURLPost(epc, cURLReq{endpoint: "/v3alpha/watch", value: wstr, expected: `"YmFy"`, timeout: 2}); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestV3CurlTxn(t *testing.T) {
+ defer testutil.AfterTest(t)
+ epc, err := newEtcdProcessCluster(&configNoTLS)
+ if err != nil {
+ t.Fatalf("could not start etcd process cluster (%v)", err)
+ }
+ defer func() {
+ if cerr := epc.Close(); err != nil {
+ t.Fatalf("error closing etcd processes (%v)", cerr)
+ }
+ }()
+
+ txn := &pb.TxnRequest{
+ Compare: []*pb.Compare{
+ {
+ Key: []byte("foo"),
+ Result: pb.Compare_EQUAL,
+ Target: pb.Compare_CREATE,
+ TargetUnion: &pb.Compare_CreateRevision{0},
+ },
+ },
+ Success: []*pb.RequestOp{
+ {
+ Request: &pb.RequestOp_RequestPut{
+ RequestPut: &pb.PutRequest{
+ Key: []byte("foo"),
+ Value: []byte("bar"),
+ },
+ },
+ },
+ },
+ }
+ m := &runtime.JSONPb{}
+ jsonDat, jerr := m.Marshal(txn)
+ if jerr != nil {
+ t.Fatal(jerr)
+ }
+ expected := `"succeeded":true,"responses":[{"response_put":{"header":{"revision":"2"}}}]`
+ if err = cURLPost(epc, cURLReq{endpoint: "/v3alpha/kv/txn", value: string(jsonDat), expected: expected}); err != nil {
+ t.Fatalf("failed txn with curl (%v)", err)
+ }
+
+ // was crashing etcd server
+ malformed := `{"compare":[{"result":0,"target":1,"key":"Zm9v","TargetUnion":null}],"success":[{"Request":{"RequestPut":{"key":"Zm9v","value":"YmFy"}}}]}`
+ if err = cURLPost(epc, cURLReq{endpoint: "/v3alpha/kv/txn", value: malformed, expected: "error"}); err != nil {
+ t.Fatalf("failed put with curl (%v)", err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/embed/config.go b/vendor/github.com/coreos/etcd/embed/config.go
new file mode 100644
index 00000000..e3926f66
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/embed/config.go
@@ -0,0 +1,437 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 embed
+
+import (
+ "fmt"
+ "io/ioutil"
+ "net"
+ "net/http"
+ "net/url"
+ "strings"
+
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/pkg/cors"
+ "github.com/coreos/etcd/pkg/netutil"
+ "github.com/coreos/etcd/pkg/srv"
+ "github.com/coreos/etcd/pkg/transport"
+ "github.com/coreos/etcd/pkg/types"
+
+ "github.com/ghodss/yaml"
+ "google.golang.org/grpc"
+)
+
+const (
+ ClusterStateFlagNew = "new"
+ ClusterStateFlagExisting = "existing"
+
+ DefaultName = "default"
+ DefaultMaxSnapshots = 5
+ DefaultMaxWALs = 5
+
+ DefaultListenPeerURLs = "http://localhost:2380"
+ DefaultListenClientURLs = "http://localhost:2379"
+
+ // maxElectionMs specifies the maximum value of election timeout.
+ // More details are listed in ../Documentation/tuning.md#time-parameters.
+ maxElectionMs = 50000
+)
+
+var (
+ ErrConflictBootstrapFlags = fmt.Errorf("multiple discovery or bootstrap flags are set. " +
+ "Choose one of \"initial-cluster\", \"discovery\" or \"discovery-srv\"")
+ ErrUnsetAdvertiseClientURLsFlag = fmt.Errorf("--advertise-client-urls is required when --listen-client-urls is set explicitly")
+
+ DefaultInitialAdvertisePeerURLs = "http://localhost:2380"
+ DefaultAdvertiseClientURLs = "http://localhost:2379"
+
+ defaultHostname string
+ defaultHostStatus error
+)
+
+func init() {
+ defaultHostname, defaultHostStatus = netutil.GetDefaultHost()
+}
+
+// Config holds the arguments for configuring an etcd server.
+type Config struct {
+ // member
+
+ CorsInfo *cors.CORSInfo
+ LPUrls, LCUrls []url.URL
+ Dir string `json:"data-dir"`
+ WalDir string `json:"wal-dir"`
+ MaxSnapFiles uint `json:"max-snapshots"`
+ MaxWalFiles uint `json:"max-wals"`
+ Name string `json:"name"`
+ SnapCount uint64 `json:"snapshot-count"`
+ AutoCompactionRetention int `json:"auto-compaction-retention"`
+
+ // TickMs is the number of milliseconds between heartbeat ticks.
+ // TODO: decouple tickMs and heartbeat tick (current heartbeat tick = 1).
+ // make ticks a cluster wide configuration.
+ TickMs uint `json:"heartbeat-interval"`
+ ElectionMs uint `json:"election-timeout"`
+ QuotaBackendBytes int64 `json:"quota-backend-bytes"`
+
+ // clustering
+
+ APUrls, ACUrls []url.URL
+ ClusterState string `json:"initial-cluster-state"`
+ DNSCluster string `json:"discovery-srv"`
+ Dproxy string `json:"discovery-proxy"`
+ Durl string `json:"discovery"`
+ InitialCluster string `json:"initial-cluster"`
+ InitialClusterToken string `json:"initial-cluster-token"`
+ StrictReconfigCheck bool `json:"strict-reconfig-check"`
+ EnableV2 bool `json:"enable-v2"`
+
+ // security
+
+ ClientTLSInfo transport.TLSInfo
+ ClientAutoTLS bool
+ PeerTLSInfo transport.TLSInfo
+ PeerAutoTLS bool
+
+ // debug
+
+ Debug bool `json:"debug"`
+ LogPkgLevels string `json:"log-package-levels"`
+ EnablePprof bool
+ Metrics string `json:"metrics"`
+
+ // ForceNewCluster starts a new cluster even if previously started; unsafe.
+ ForceNewCluster bool `json:"force-new-cluster"`
+
+ // UserHandlers is for registering users handlers and only used for
+ // embedding etcd into other applications.
+ // The map key is the route path for the handler, and
+ // you must ensure it can't be conflicted with etcd's.
+ UserHandlers map[string]http.Handler `json:"-"`
+ // ServiceRegister is for registering users' gRPC services. A simple usage example:
+ // cfg := embed.NewConfig()
+ // cfg.ServerRegister = func(s *grpc.Server) {
+ // pb.RegisterFooServer(s, &fooServer{})
+ // pb.RegisterBarServer(s, &barServer{})
+ // }
+ // embed.StartEtcd(cfg)
+ ServiceRegister func(*grpc.Server) `json:"-"`
+
+ // auth
+
+ AuthToken string `json:"auth-token"`
+}
+
+// configYAML holds the config suitable for yaml parsing
+type configYAML struct {
+ Config
+ configJSON
+}
+
+// configJSON has file options that are translated into Config options
+type configJSON struct {
+ LPUrlsJSON string `json:"listen-peer-urls"`
+ LCUrlsJSON string `json:"listen-client-urls"`
+ CorsJSON string `json:"cors"`
+ APUrlsJSON string `json:"initial-advertise-peer-urls"`
+ ACUrlsJSON string `json:"advertise-client-urls"`
+ ClientSecurityJSON securityConfig `json:"client-transport-security"`
+ PeerSecurityJSON securityConfig `json:"peer-transport-security"`
+}
+
+type securityConfig struct {
+ CAFile string `json:"ca-file"`
+ CertFile string `json:"cert-file"`
+ KeyFile string `json:"key-file"`
+ CertAuth bool `json:"client-cert-auth"`
+ TrustedCAFile string `json:"trusted-ca-file"`
+ AutoTLS bool `json:"auto-tls"`
+}
+
+// NewConfig creates a new Config populated with default values.
+func NewConfig() *Config {
+ lpurl, _ := url.Parse(DefaultListenPeerURLs)
+ apurl, _ := url.Parse(DefaultInitialAdvertisePeerURLs)
+ lcurl, _ := url.Parse(DefaultListenClientURLs)
+ acurl, _ := url.Parse(DefaultAdvertiseClientURLs)
+ cfg := &Config{
+ CorsInfo: &cors.CORSInfo{},
+ MaxSnapFiles: DefaultMaxSnapshots,
+ MaxWalFiles: DefaultMaxWALs,
+ Name: DefaultName,
+ SnapCount: etcdserver.DefaultSnapCount,
+ TickMs: 100,
+ ElectionMs: 1000,
+ LPUrls: []url.URL{*lpurl},
+ LCUrls: []url.URL{*lcurl},
+ APUrls: []url.URL{*apurl},
+ ACUrls: []url.URL{*acurl},
+ ClusterState: ClusterStateFlagNew,
+ InitialClusterToken: "etcd-cluster",
+ StrictReconfigCheck: true,
+ Metrics: "basic",
+ EnableV2: true,
+ AuthToken: "simple",
+ }
+ cfg.InitialCluster = cfg.InitialClusterFromName(cfg.Name)
+ return cfg
+}
+
+func ConfigFromFile(path string) (*Config, error) {
+ cfg := &configYAML{Config: *NewConfig()}
+ if err := cfg.configFromFile(path); err != nil {
+ return nil, err
+ }
+ return &cfg.Config, nil
+}
+
+func (cfg *configYAML) configFromFile(path string) error {
+ b, err := ioutil.ReadFile(path)
+ if err != nil {
+ return err
+ }
+
+ defaultInitialCluster := cfg.InitialCluster
+
+ err = yaml.Unmarshal(b, cfg)
+ if err != nil {
+ return err
+ }
+
+ if cfg.LPUrlsJSON != "" {
+ u, err := types.NewURLs(strings.Split(cfg.LPUrlsJSON, ","))
+ if err != nil {
+ plog.Fatalf("unexpected error setting up listen-peer-urls: %v", err)
+ }
+ cfg.LPUrls = []url.URL(u)
+ }
+
+ if cfg.LCUrlsJSON != "" {
+ u, err := types.NewURLs(strings.Split(cfg.LCUrlsJSON, ","))
+ if err != nil {
+ plog.Fatalf("unexpected error setting up listen-client-urls: %v", err)
+ }
+ cfg.LCUrls = []url.URL(u)
+ }
+
+ if cfg.CorsJSON != "" {
+ if err := cfg.CorsInfo.Set(cfg.CorsJSON); err != nil {
+ plog.Panicf("unexpected error setting up cors: %v", err)
+ }
+ }
+
+ if cfg.APUrlsJSON != "" {
+ u, err := types.NewURLs(strings.Split(cfg.APUrlsJSON, ","))
+ if err != nil {
+ plog.Fatalf("unexpected error setting up initial-advertise-peer-urls: %v", err)
+ }
+ cfg.APUrls = []url.URL(u)
+ }
+
+ if cfg.ACUrlsJSON != "" {
+ u, err := types.NewURLs(strings.Split(cfg.ACUrlsJSON, ","))
+ if err != nil {
+ plog.Fatalf("unexpected error setting up advertise-peer-urls: %v", err)
+ }
+ cfg.ACUrls = []url.URL(u)
+ }
+
+ // If a discovery flag is set, clear default initial cluster set by InitialClusterFromName
+ if (cfg.Durl != "" || cfg.DNSCluster != "") && cfg.InitialCluster == defaultInitialCluster {
+ cfg.InitialCluster = ""
+ }
+ if cfg.ClusterState == "" {
+ cfg.ClusterState = ClusterStateFlagNew
+ }
+
+ copySecurityDetails := func(tls *transport.TLSInfo, ysc *securityConfig) {
+ tls.CAFile = ysc.CAFile
+ tls.CertFile = ysc.CertFile
+ tls.KeyFile = ysc.KeyFile
+ tls.ClientCertAuth = ysc.CertAuth
+ tls.TrustedCAFile = ysc.TrustedCAFile
+ }
+ copySecurityDetails(&cfg.ClientTLSInfo, &cfg.ClientSecurityJSON)
+ copySecurityDetails(&cfg.PeerTLSInfo, &cfg.PeerSecurityJSON)
+ cfg.ClientAutoTLS = cfg.ClientSecurityJSON.AutoTLS
+ cfg.PeerAutoTLS = cfg.PeerSecurityJSON.AutoTLS
+
+ return cfg.Validate()
+}
+
+func (cfg *Config) Validate() error {
+ if err := checkBindURLs(cfg.LPUrls); err != nil {
+ return err
+ }
+ if err := checkBindURLs(cfg.LCUrls); err != nil {
+ return err
+ }
+
+ // Check if conflicting flags are passed.
+ nSet := 0
+ for _, v := range []bool{cfg.Durl != "", cfg.InitialCluster != "", cfg.DNSCluster != ""} {
+ if v {
+ nSet++
+ }
+ }
+
+ if cfg.ClusterState != ClusterStateFlagNew && cfg.ClusterState != ClusterStateFlagExisting {
+ return fmt.Errorf("unexpected clusterState %q", cfg.ClusterState)
+ }
+
+ if nSet > 1 {
+ return ErrConflictBootstrapFlags
+ }
+
+ if 5*cfg.TickMs > cfg.ElectionMs {
+ return fmt.Errorf("--election-timeout[%vms] should be at least as 5 times as --heartbeat-interval[%vms]", cfg.ElectionMs, cfg.TickMs)
+ }
+ if cfg.ElectionMs > maxElectionMs {
+ return fmt.Errorf("--election-timeout[%vms] is too long, and should be set less than %vms", cfg.ElectionMs, maxElectionMs)
+ }
+
+ // check this last since proxying in etcdmain may make this OK
+ if cfg.LCUrls != nil && cfg.ACUrls == nil {
+ return ErrUnsetAdvertiseClientURLsFlag
+ }
+
+ return nil
+}
+
+// PeerURLsMapAndToken sets up an initial peer URLsMap and cluster token for bootstrap or discovery.
+func (cfg *Config) PeerURLsMapAndToken(which string) (urlsmap types.URLsMap, token string, err error) {
+ token = cfg.InitialClusterToken
+ switch {
+ case cfg.Durl != "":
+ urlsmap = types.URLsMap{}
+ // If using discovery, generate a temporary cluster based on
+ // self's advertised peer URLs
+ urlsmap[cfg.Name] = cfg.APUrls
+ token = cfg.Durl
+ case cfg.DNSCluster != "":
+ clusterStrs, cerr := srv.GetCluster("etcd-server", cfg.Name, cfg.DNSCluster, cfg.APUrls)
+ if cerr != nil {
+ plog.Errorf("couldn't resolve during SRV discovery (%v)", cerr)
+ return nil, "", cerr
+ }
+ for _, s := range clusterStrs {
+ plog.Noticef("got bootstrap from DNS for etcd-server at %s", s)
+ }
+ clusterStr := strings.Join(clusterStrs, ",")
+ if strings.Contains(clusterStr, "https://") && cfg.PeerTLSInfo.CAFile == "" {
+ cfg.PeerTLSInfo.ServerName = cfg.DNSCluster
+ }
+ urlsmap, err = types.NewURLsMap(clusterStr)
+ // only etcd member must belong to the discovered cluster.
+ // proxy does not need to belong to the discovered cluster.
+ if which == "etcd" {
+ if _, ok := urlsmap[cfg.Name]; !ok {
+ return nil, "", fmt.Errorf("cannot find local etcd member %q in SRV records", cfg.Name)
+ }
+ }
+ default:
+ // We're statically configured, and cluster has appropriately been set.
+ urlsmap, err = types.NewURLsMap(cfg.InitialCluster)
+ }
+ return urlsmap, token, err
+}
+
+func (cfg Config) InitialClusterFromName(name string) (ret string) {
+ if len(cfg.APUrls) == 0 {
+ return ""
+ }
+ n := name
+ if name == "" {
+ n = DefaultName
+ }
+ for i := range cfg.APUrls {
+ ret = ret + "," + n + "=" + cfg.APUrls[i].String()
+ }
+ return ret[1:]
+}
+
+func (cfg Config) IsNewCluster() bool { return cfg.ClusterState == ClusterStateFlagNew }
+func (cfg Config) ElectionTicks() int { return int(cfg.ElectionMs / cfg.TickMs) }
+
+func (cfg Config) defaultPeerHost() bool {
+ return len(cfg.APUrls) == 1 && cfg.APUrls[0].String() == DefaultInitialAdvertisePeerURLs
+}
+
+func (cfg Config) defaultClientHost() bool {
+ return len(cfg.ACUrls) == 1 && cfg.ACUrls[0].String() == DefaultAdvertiseClientURLs
+}
+
+// UpdateDefaultClusterFromName updates cluster advertise URLs with, if available, default host,
+// if advertise URLs are default values(localhost:2379,2380) AND if listen URL is 0.0.0.0.
+// e.g. advertise peer URL localhost:2380 or listen peer URL 0.0.0.0:2380
+// then the advertise peer host would be updated with machine's default host,
+// while keeping the listen URL's port.
+// User can work around this by explicitly setting URL with 127.0.0.1.
+// It returns the default hostname, if used, and the error, if any, from getting the machine's default host.
+// TODO: check whether fields are set instead of whether fields have default value
+func (cfg *Config) UpdateDefaultClusterFromName(defaultInitialCluster string) (string, error) {
+ if defaultHostname == "" || defaultHostStatus != nil {
+ // update 'initial-cluster' when only the name is specified (e.g. 'etcd --name=abc')
+ if cfg.Name != DefaultName && cfg.InitialCluster == defaultInitialCluster {
+ cfg.InitialCluster = cfg.InitialClusterFromName(cfg.Name)
+ }
+ return "", defaultHostStatus
+ }
+
+ used := false
+ pip, pport := cfg.LPUrls[0].Hostname(), cfg.LPUrls[0].Port()
+ if cfg.defaultPeerHost() && pip == "0.0.0.0" {
+ cfg.APUrls[0] = url.URL{Scheme: cfg.APUrls[0].Scheme, Host: fmt.Sprintf("%s:%s", defaultHostname, pport)}
+ used = true
+ }
+ // update 'initial-cluster' when only the name is specified (e.g. 'etcd --name=abc')
+ if cfg.Name != DefaultName && cfg.InitialCluster == defaultInitialCluster {
+ cfg.InitialCluster = cfg.InitialClusterFromName(cfg.Name)
+ }
+
+ cip, cport := cfg.LCUrls[0].Hostname(), cfg.LCUrls[0].Port()
+ if cfg.defaultClientHost() && cip == "0.0.0.0" {
+ cfg.ACUrls[0] = url.URL{Scheme: cfg.ACUrls[0].Scheme, Host: fmt.Sprintf("%s:%s", defaultHostname, cport)}
+ used = true
+ }
+ dhost := defaultHostname
+ if !used {
+ dhost = ""
+ }
+ return dhost, defaultHostStatus
+}
+
+// checkBindURLs returns an error if any URL uses a domain name.
+// TODO: return error in 3.2.0
+func checkBindURLs(urls []url.URL) error {
+ for _, url := range urls {
+ if url.Scheme == "unix" || url.Scheme == "unixs" {
+ continue
+ }
+ host, _, err := net.SplitHostPort(url.Host)
+ if err != nil {
+ return err
+ }
+ if host == "localhost" {
+ // special case for local address
+ // TODO: support /etc/hosts ?
+ continue
+ }
+ if net.ParseIP(host) == nil {
+ return fmt.Errorf("expected IP in URL for binding (%s)", url.String())
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/embed/config_test.go b/vendor/github.com/coreos/etcd/embed/config_test.go
new file mode 100644
index 00000000..27b73238
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/embed/config_test.go
@@ -0,0 +1,150 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 embed
+
+import (
+ "fmt"
+ "io/ioutil"
+ "net/url"
+ "os"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/transport"
+
+ "github.com/ghodss/yaml"
+)
+
+func TestConfigFileOtherFields(t *testing.T) {
+ ctls := securityConfig{CAFile: "cca", CertFile: "ccert", KeyFile: "ckey"}
+ ptls := securityConfig{CAFile: "pca", CertFile: "pcert", KeyFile: "pkey"}
+ yc := struct {
+ ClientSecurityCfgFile securityConfig `json:"client-transport-security"`
+ PeerSecurityCfgFile securityConfig `json:"peer-transport-security"`
+ ForceNewCluster bool `json:"force-new-cluster"`
+ }{
+ ctls,
+ ptls,
+ true,
+ }
+
+ b, err := yaml.Marshal(&yc)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ tmpfile := mustCreateCfgFile(t, b)
+ defer os.Remove(tmpfile.Name())
+
+ cfg, err := ConfigFromFile(tmpfile.Name())
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if !cfg.ForceNewCluster {
+ t.Errorf("ForceNewCluster = %v, want %v", cfg.ForceNewCluster, true)
+ }
+
+ if !ctls.equals(&cfg.ClientTLSInfo) {
+ t.Errorf("ClientTLS = %v, want %v", cfg.ClientTLSInfo, ctls)
+ }
+ if !ptls.equals(&cfg.PeerTLSInfo) {
+ t.Errorf("PeerTLS = %v, want %v", cfg.PeerTLSInfo, ptls)
+ }
+}
+
+// TestUpdateDefaultClusterFromName ensures that etcd can start with 'etcd --name=abc'.
+func TestUpdateDefaultClusterFromName(t *testing.T) {
+ cfg := NewConfig()
+ defaultInitialCluster := cfg.InitialCluster
+ oldscheme := cfg.APUrls[0].Scheme
+ origpeer := cfg.APUrls[0].String()
+ origadvc := cfg.ACUrls[0].String()
+
+ cfg.Name = "abc"
+ lpport := cfg.LPUrls[0].Port()
+
+ // in case of 'etcd --name=abc'
+ exp := fmt.Sprintf("%s=%s://localhost:%s", cfg.Name, oldscheme, lpport)
+ cfg.UpdateDefaultClusterFromName(defaultInitialCluster)
+ if exp != cfg.InitialCluster {
+ t.Fatalf("initial-cluster expected %q, got %q", exp, cfg.InitialCluster)
+ }
+ // advertise peer URL should not be affected
+ if origpeer != cfg.APUrls[0].String() {
+ t.Fatalf("advertise peer url expected %q, got %q", origadvc, cfg.APUrls[0].String())
+ }
+ // advertise client URL should not be affected
+ if origadvc != cfg.ACUrls[0].String() {
+ t.Fatalf("advertise client url expected %q, got %q", origadvc, cfg.ACUrls[0].String())
+ }
+}
+
+// TestUpdateDefaultClusterFromNameOverwrite ensures that machine's default host is only used
+// if advertise URLs are default values(localhost:2379,2380) AND if listen URL is 0.0.0.0.
+func TestUpdateDefaultClusterFromNameOverwrite(t *testing.T) {
+ if defaultHostname == "" {
+ t.Skip("machine's default host not found")
+ }
+
+ cfg := NewConfig()
+ defaultInitialCluster := cfg.InitialCluster
+ oldscheme := cfg.APUrls[0].Scheme
+ origadvc := cfg.ACUrls[0].String()
+
+ cfg.Name = "abc"
+ lpport := cfg.LPUrls[0].Port()
+ cfg.LPUrls[0] = url.URL{Scheme: cfg.LPUrls[0].Scheme, Host: fmt.Sprintf("0.0.0.0:%s", lpport)}
+ dhost, _ := cfg.UpdateDefaultClusterFromName(defaultInitialCluster)
+ if dhost != defaultHostname {
+ t.Fatalf("expected default host %q, got %q", defaultHostname, dhost)
+ }
+ aphost, apport := cfg.APUrls[0].Hostname(), cfg.APUrls[0].Port()
+ if apport != lpport {
+ t.Fatalf("advertise peer url got different port %s, expected %s", apport, lpport)
+ }
+ if aphost != defaultHostname {
+ t.Fatalf("advertise peer url expected machine default host %q, got %q", defaultHostname, aphost)
+ }
+ expected := fmt.Sprintf("%s=%s://%s:%s", cfg.Name, oldscheme, defaultHostname, lpport)
+ if expected != cfg.InitialCluster {
+ t.Fatalf("initial-cluster expected %q, got %q", expected, cfg.InitialCluster)
+ }
+
+ // advertise client URL should not be affected
+ if origadvc != cfg.ACUrls[0].String() {
+ t.Fatalf("advertise-client-url expected %q, got %q", origadvc, cfg.ACUrls[0].String())
+ }
+}
+
+func (s *securityConfig) equals(t *transport.TLSInfo) bool {
+ return s.CAFile == t.CAFile &&
+ s.CertFile == t.CertFile &&
+ s.CertAuth == t.ClientCertAuth &&
+ s.TrustedCAFile == t.TrustedCAFile
+}
+
+func mustCreateCfgFile(t *testing.T, b []byte) *os.File {
+ tmpfile, err := ioutil.TempFile("", "servercfg")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err = tmpfile.Write(b); err != nil {
+ t.Fatal(err)
+ }
+ if err = tmpfile.Close(); err != nil {
+ t.Fatal(err)
+ }
+ return tmpfile
+}
diff --git a/vendor/github.com/coreos/etcd/embed/doc.go b/vendor/github.com/coreos/etcd/embed/doc.go
new file mode 100644
index 00000000..c555aa58
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/embed/doc.go
@@ -0,0 +1,45 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 embed provides bindings for embedding an etcd server in a program.
+
+Launch an embedded etcd server using the configuration defaults:
+
+ import (
+ "log"
+ "time"
+
+ "github.com/coreos/etcd/embed"
+ )
+
+ func main() {
+ cfg := embed.NewConfig()
+ cfg.Dir = "default.etcd"
+ e, err := embed.StartEtcd(cfg)
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer e.Close()
+ select {
+ case <-e.Server.ReadyNotify():
+ log.Printf("Server is ready!")
+ case <-time.After(60 * time.Second):
+ e.Server.Stop() // trigger a shutdown
+ log.Printf("Server took too long to start!")
+ }
+ log.Fatal(<-e.Err())
+ }
+*/
+package embed
diff --git a/vendor/github.com/coreos/etcd/embed/etcd.go b/vendor/github.com/coreos/etcd/embed/etcd.go
new file mode 100644
index 00000000..6f24762b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/embed/etcd.go
@@ -0,0 +1,436 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 embed
+
+import (
+ "context"
+ "crypto/tls"
+ "fmt"
+ "io/ioutil"
+ defaultLog "log"
+ "net"
+ "net/http"
+ "path/filepath"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api/etcdhttp"
+ "github.com/coreos/etcd/etcdserver/api/v2http"
+ "github.com/coreos/etcd/pkg/cors"
+ "github.com/coreos/etcd/pkg/debugutil"
+ runtimeutil "github.com/coreos/etcd/pkg/runtime"
+ "github.com/coreos/etcd/pkg/transport"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/rafthttp"
+ "github.com/coreos/pkg/capnslog"
+)
+
+var plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "embed")
+
+const (
+ // internal fd usage includes disk usage and transport usage.
+ // To read/write snapshot, snap pkg needs 1. In normal case, wal pkg needs
+ // at most 2 to read/lock/write WALs. One case that it needs to 2 is to
+ // read all logs after some snapshot index, which locates at the end of
+ // the second last and the head of the last. For purging, it needs to read
+ // directory, so it needs 1. For fd monitor, it needs 1.
+ // For transport, rafthttp builds two long-polling connections and at most
+ // four temporary connections with each member. There are at most 9 members
+ // in a cluster, so it should reserve 96.
+ // For the safety, we set the total reserved number to 150.
+ reservedInternalFDNum = 150
+)
+
+// Etcd contains a running etcd server and its listeners.
+type Etcd struct {
+ Peers []*peerListener
+ Clients []net.Listener
+ Server *etcdserver.EtcdServer
+
+ cfg Config
+ stopc chan struct{}
+ errc chan error
+ sctxs map[string]*serveCtx
+
+ closeOnce sync.Once
+}
+
+type peerListener struct {
+ net.Listener
+ serve func() error
+ close func(context.Context) error
+}
+
+// StartEtcd launches the etcd server and HTTP handlers for client/server communication.
+// The returned Etcd.Server is not guaranteed to have joined the cluster. Wait
+// on the Etcd.Server.ReadyNotify() channel to know when it completes and is ready for use.
+func StartEtcd(inCfg *Config) (e *Etcd, err error) {
+ if err = inCfg.Validate(); err != nil {
+ return nil, err
+ }
+ serving := false
+ e = &Etcd{cfg: *inCfg, stopc: make(chan struct{})}
+ cfg := &e.cfg
+ defer func() {
+ if e == nil || err == nil {
+ return
+ }
+ if !serving {
+ // errored before starting gRPC server for serveCtx.grpcServerC
+ for _, sctx := range e.sctxs {
+ close(sctx.grpcServerC)
+ }
+ }
+ e.Close()
+ e = nil
+ }()
+
+ if e.Peers, err = startPeerListeners(cfg); err != nil {
+ return
+ }
+ if e.sctxs, err = startClientListeners(cfg); err != nil {
+ return
+ }
+ for _, sctx := range e.sctxs {
+ e.Clients = append(e.Clients, sctx.l)
+ }
+
+ var (
+ urlsmap types.URLsMap
+ token string
+ )
+
+ if !isMemberInitialized(cfg) {
+ urlsmap, token, err = cfg.PeerURLsMapAndToken("etcd")
+ if err != nil {
+ return e, fmt.Errorf("error setting up initial cluster: %v", err)
+ }
+ }
+
+ srvcfg := &etcdserver.ServerConfig{
+ Name: cfg.Name,
+ ClientURLs: cfg.ACUrls,
+ PeerURLs: cfg.APUrls,
+ DataDir: cfg.Dir,
+ DedicatedWALDir: cfg.WalDir,
+ SnapCount: cfg.SnapCount,
+ MaxSnapFiles: cfg.MaxSnapFiles,
+ MaxWALFiles: cfg.MaxWalFiles,
+ InitialPeerURLsMap: urlsmap,
+ InitialClusterToken: token,
+ DiscoveryURL: cfg.Durl,
+ DiscoveryProxy: cfg.Dproxy,
+ NewCluster: cfg.IsNewCluster(),
+ ForceNewCluster: cfg.ForceNewCluster,
+ PeerTLSInfo: cfg.PeerTLSInfo,
+ TickMs: cfg.TickMs,
+ ElectionTicks: cfg.ElectionTicks(),
+ AutoCompactionRetention: cfg.AutoCompactionRetention,
+ QuotaBackendBytes: cfg.QuotaBackendBytes,
+ StrictReconfigCheck: cfg.StrictReconfigCheck,
+ ClientCertAuthEnabled: cfg.ClientTLSInfo.ClientCertAuth,
+ AuthToken: cfg.AuthToken,
+ }
+
+ if e.Server, err = etcdserver.NewServer(srvcfg); err != nil {
+ return
+ }
+
+ // configure peer handlers after rafthttp.Transport started
+ ph := etcdhttp.NewPeerHandler(e.Server)
+ for i := range e.Peers {
+ srv := &http.Server{
+ Handler: ph,
+ ReadTimeout: 5 * time.Minute,
+ ErrorLog: defaultLog.New(ioutil.Discard, "", 0), // do not log user error
+ }
+ e.Peers[i].serve = func() error {
+ return srv.Serve(e.Peers[i].Listener)
+ }
+ e.Peers[i].close = func(ctx context.Context) error {
+ // gracefully shutdown http.Server
+ // close open listeners, idle connections
+ // until context cancel or time-out
+ return srv.Shutdown(ctx)
+ }
+ }
+
+ // buffer channel so goroutines on closed connections won't wait forever
+ e.errc = make(chan error, len(e.Peers)+len(e.Clients)+2*len(e.sctxs))
+
+ e.Server.Start()
+ if err = e.serve(); err != nil {
+ return
+ }
+ serving = true
+ return
+}
+
+// Config returns the current configuration.
+func (e *Etcd) Config() Config {
+ return e.cfg
+}
+
+func (e *Etcd) Close() {
+ e.closeOnce.Do(func() { close(e.stopc) })
+
+ timeout := 2 * time.Second
+ if e.Server != nil {
+ timeout = e.Server.Cfg.ReqTimeout()
+ }
+ for _, sctx := range e.sctxs {
+ for gs := range sctx.grpcServerC {
+ ch := make(chan struct{})
+ go func() {
+ defer close(ch)
+ // close listeners to stop accepting new connections,
+ // will block on any existing transports
+ gs.GracefulStop()
+ }()
+ // wait until all pending RPCs are finished
+ select {
+ case <-ch:
+ case <-time.After(timeout):
+ // took too long, manually close open transports
+ // e.g. watch streams
+ gs.Stop()
+ // concurrent GracefulStop should be interrupted
+ <-ch
+ }
+ }
+ }
+
+ for _, sctx := range e.sctxs {
+ sctx.cancel()
+ }
+ for i := range e.Clients {
+ if e.Clients[i] != nil {
+ e.Clients[i].Close()
+ }
+ }
+
+ // close rafthttp transports
+ if e.Server != nil {
+ e.Server.Stop()
+ }
+
+ // close all idle connections in peer handler (wait up to 1-second)
+ for i := range e.Peers {
+ if e.Peers[i] != nil && e.Peers[i].close != nil {
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+ e.Peers[i].close(ctx)
+ cancel()
+ }
+ }
+}
+
+func (e *Etcd) Err() <-chan error { return e.errc }
+
+func startPeerListeners(cfg *Config) (peers []*peerListener, err error) {
+ if cfg.PeerAutoTLS && cfg.PeerTLSInfo.Empty() {
+ phosts := make([]string, len(cfg.LPUrls))
+ for i, u := range cfg.LPUrls {
+ phosts[i] = u.Host
+ }
+ cfg.PeerTLSInfo, err = transport.SelfCert(filepath.Join(cfg.Dir, "fixtures", "peer"), phosts)
+ if err != nil {
+ plog.Fatalf("could not get certs (%v)", err)
+ }
+ } else if cfg.PeerAutoTLS {
+ plog.Warningf("ignoring peer auto TLS since certs given")
+ }
+
+ if !cfg.PeerTLSInfo.Empty() {
+ plog.Infof("peerTLS: %s", cfg.PeerTLSInfo)
+ }
+
+ peers = make([]*peerListener, len(cfg.LPUrls))
+ defer func() {
+ if err == nil {
+ return
+ }
+ for i := range peers {
+ if peers[i] != nil && peers[i].close != nil {
+ plog.Info("stopping listening for peers on ", cfg.LPUrls[i].String())
+ peers[i].close(context.Background())
+ }
+ }
+ }()
+
+ for i, u := range cfg.LPUrls {
+ if u.Scheme == "http" {
+ if !cfg.PeerTLSInfo.Empty() {
+ plog.Warningf("The scheme of peer url %s is HTTP while peer key/cert files are presented. Ignored peer key/cert files.", u.String())
+ }
+ if cfg.PeerTLSInfo.ClientCertAuth {
+ plog.Warningf("The scheme of peer url %s is HTTP while client cert auth (--peer-client-cert-auth) is enabled. Ignored client cert auth for this url.", u.String())
+ }
+ }
+ peers[i] = &peerListener{close: func(context.Context) error { return nil }}
+ peers[i].Listener, err = rafthttp.NewListener(u, &cfg.PeerTLSInfo)
+ if err != nil {
+ return nil, err
+ }
+ // once serve, overwrite with 'http.Server.Shutdown'
+ peers[i].close = func(context.Context) error {
+ return peers[i].Listener.Close()
+ }
+ plog.Info("listening for peers on ", u.String())
+ }
+ return peers, nil
+}
+
+func startClientListeners(cfg *Config) (sctxs map[string]*serveCtx, err error) {
+ if cfg.ClientAutoTLS && cfg.ClientTLSInfo.Empty() {
+ chosts := make([]string, len(cfg.LCUrls))
+ for i, u := range cfg.LCUrls {
+ chosts[i] = u.Host
+ }
+ cfg.ClientTLSInfo, err = transport.SelfCert(filepath.Join(cfg.Dir, "fixtures", "client"), chosts)
+ if err != nil {
+ plog.Fatalf("could not get certs (%v)", err)
+ }
+ } else if cfg.ClientAutoTLS {
+ plog.Warningf("ignoring client auto TLS since certs given")
+ }
+
+ if cfg.EnablePprof {
+ plog.Infof("pprof is enabled under %s", debugutil.HTTPPrefixPProf)
+ }
+
+ sctxs = make(map[string]*serveCtx)
+ for _, u := range cfg.LCUrls {
+ sctx := newServeCtx()
+
+ if u.Scheme == "http" || u.Scheme == "unix" {
+ if !cfg.ClientTLSInfo.Empty() {
+ plog.Warningf("The scheme of client url %s is HTTP while peer key/cert files are presented. Ignored key/cert files.", u.String())
+ }
+ if cfg.ClientTLSInfo.ClientCertAuth {
+ plog.Warningf("The scheme of client url %s is HTTP while client cert auth (--client-cert-auth) is enabled. Ignored client cert auth for this url.", u.String())
+ }
+ }
+ if (u.Scheme == "https" || u.Scheme == "unixs") && cfg.ClientTLSInfo.Empty() {
+ return nil, fmt.Errorf("TLS key/cert (--cert-file, --key-file) must be provided for client url %s with HTTPs scheme", u.String())
+ }
+
+ proto := "tcp"
+ addr := u.Host
+ if u.Scheme == "unix" || u.Scheme == "unixs" {
+ proto = "unix"
+ addr = u.Host + u.Path
+ }
+
+ sctx.secure = u.Scheme == "https" || u.Scheme == "unixs"
+ sctx.insecure = !sctx.secure
+ if oldctx := sctxs[addr]; oldctx != nil {
+ oldctx.secure = oldctx.secure || sctx.secure
+ oldctx.insecure = oldctx.insecure || sctx.insecure
+ continue
+ }
+
+ if sctx.l, err = net.Listen(proto, addr); err != nil {
+ return nil, err
+ }
+ // net.Listener will rewrite ipv4 0.0.0.0 to ipv6 [::], breaking
+ // hosts that disable ipv6. So, use the address given by the user.
+ sctx.addr = addr
+
+ if fdLimit, fderr := runtimeutil.FDLimit(); fderr == nil {
+ if fdLimit <= reservedInternalFDNum {
+ plog.Fatalf("file descriptor limit[%d] of etcd process is too low, and should be set higher than %d to ensure internal usage", fdLimit, reservedInternalFDNum)
+ }
+ sctx.l = transport.LimitListener(sctx.l, int(fdLimit-reservedInternalFDNum))
+ }
+
+ if proto == "tcp" {
+ if sctx.l, err = transport.NewKeepAliveListener(sctx.l, "tcp", nil); err != nil {
+ return nil, err
+ }
+ }
+
+ plog.Info("listening for client requests on ", u.Host)
+ defer func() {
+ if err != nil {
+ sctx.l.Close()
+ plog.Info("stopping listening for client requests on ", u.Host)
+ }
+ }()
+ for k := range cfg.UserHandlers {
+ sctx.userHandlers[k] = cfg.UserHandlers[k]
+ }
+ sctx.serviceRegister = cfg.ServiceRegister
+ if cfg.EnablePprof || cfg.Debug {
+ sctx.registerPprof()
+ }
+ if cfg.Debug {
+ sctx.registerTrace()
+ }
+ sctxs[addr] = sctx
+ }
+ return sctxs, nil
+}
+
+func (e *Etcd) serve() (err error) {
+ var ctlscfg *tls.Config
+ if !e.cfg.ClientTLSInfo.Empty() {
+ plog.Infof("ClientTLS: %s", e.cfg.ClientTLSInfo)
+ if ctlscfg, err = e.cfg.ClientTLSInfo.ServerConfig(); err != nil {
+ return err
+ }
+ }
+
+ if e.cfg.CorsInfo.String() != "" {
+ plog.Infof("cors = %s", e.cfg.CorsInfo)
+ }
+
+ // Start the peer server in a goroutine
+ for _, pl := range e.Peers {
+ go func(l *peerListener) {
+ e.errHandler(l.serve())
+ }(pl)
+ }
+
+ // Start a client server goroutine for each listen address
+ var h http.Handler
+ if e.Config().EnableV2 {
+ h = v2http.NewClientHandler(e.Server, e.Server.Cfg.ReqTimeout())
+ } else {
+ mux := http.NewServeMux()
+ etcdhttp.HandleBasic(mux, e.Server)
+ h = mux
+ }
+ h = http.Handler(&cors.CORSHandler{Handler: h, Info: e.cfg.CorsInfo})
+
+ for _, sctx := range e.sctxs {
+ go func(s *serveCtx) {
+ e.errHandler(s.serve(e.Server, ctlscfg, h, e.errHandler))
+ }(sctx)
+ }
+ return nil
+}
+
+func (e *Etcd) errHandler(err error) {
+ select {
+ case <-e.stopc:
+ return
+ default:
+ }
+ select {
+ case <-e.stopc:
+ case e.errc <- err:
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/embed/serve.go b/vendor/github.com/coreos/etcd/embed/serve.go
new file mode 100644
index 00000000..602074c7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/embed/serve.go
@@ -0,0 +1,231 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 embed
+
+import (
+ "crypto/tls"
+ "io/ioutil"
+ defaultLog "log"
+ "net"
+ "net/http"
+ "strings"
+
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api/v3client"
+ "github.com/coreos/etcd/etcdserver/api/v3election"
+ "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb"
+ v3electiongw "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb/gw"
+ "github.com/coreos/etcd/etcdserver/api/v3lock"
+ "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb"
+ v3lockgw "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb/gw"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc"
+ etcdservergw "github.com/coreos/etcd/etcdserver/etcdserverpb/gw"
+ "github.com/coreos/etcd/pkg/debugutil"
+
+ "github.com/cockroachdb/cmux"
+ gw "github.com/grpc-ecosystem/grpc-gateway/runtime"
+ "golang.org/x/net/context"
+ "golang.org/x/net/trace"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/credentials"
+)
+
+type serveCtx struct {
+ l net.Listener
+ addr string
+ secure bool
+ insecure bool
+
+ ctx context.Context
+ cancel context.CancelFunc
+
+ userHandlers map[string]http.Handler
+ serviceRegister func(*grpc.Server)
+ grpcServerC chan *grpc.Server
+}
+
+func newServeCtx() *serveCtx {
+ ctx, cancel := context.WithCancel(context.Background())
+ return &serveCtx{ctx: ctx, cancel: cancel, userHandlers: make(map[string]http.Handler),
+ grpcServerC: make(chan *grpc.Server, 2), // in case sctx.insecure,sctx.secure true
+ }
+}
+
+// serve accepts incoming connections on the listener l,
+// creating a new service goroutine for each. The service goroutines
+// read requests and then call handler to reply to them.
+func (sctx *serveCtx) serve(s *etcdserver.EtcdServer, tlscfg *tls.Config, handler http.Handler, errHandler func(error)) error {
+ logger := defaultLog.New(ioutil.Discard, "etcdhttp", 0)
+ <-s.ReadyNotify()
+ plog.Info("ready to serve client requests")
+
+ m := cmux.New(sctx.l)
+ v3c := v3client.New(s)
+ servElection := v3election.NewElectionServer(v3c)
+ servLock := v3lock.NewLockServer(v3c)
+
+ if sctx.insecure {
+ gs := v3rpc.Server(s, nil)
+ sctx.grpcServerC <- gs
+ v3electionpb.RegisterElectionServer(gs, servElection)
+ v3lockpb.RegisterLockServer(gs, servLock)
+ if sctx.serviceRegister != nil {
+ sctx.serviceRegister(gs)
+ }
+ grpcl := m.Match(cmux.HTTP2())
+ go func() { errHandler(gs.Serve(grpcl)) }()
+
+ opts := []grpc.DialOption{
+ grpc.WithInsecure(),
+ }
+ gwmux, err := sctx.registerGateway(opts)
+ if err != nil {
+ return err
+ }
+
+ httpmux := sctx.createMux(gwmux, handler)
+
+ srvhttp := &http.Server{
+ Handler: httpmux,
+ ErrorLog: logger, // do not log user error
+ }
+ httpl := m.Match(cmux.HTTP1())
+ go func() { errHandler(srvhttp.Serve(httpl)) }()
+ plog.Noticef("serving insecure client requests on %s, this is strongly discouraged!", sctx.l.Addr().String())
+ }
+
+ if sctx.secure {
+ gs := v3rpc.Server(s, tlscfg)
+ sctx.grpcServerC <- gs
+ v3electionpb.RegisterElectionServer(gs, servElection)
+ v3lockpb.RegisterLockServer(gs, servLock)
+ if sctx.serviceRegister != nil {
+ sctx.serviceRegister(gs)
+ }
+ handler = grpcHandlerFunc(gs, handler)
+
+ dtls := tlscfg.Clone()
+ // trust local server
+ dtls.InsecureSkipVerify = true
+ creds := credentials.NewTLS(dtls)
+ opts := []grpc.DialOption{grpc.WithTransportCredentials(creds)}
+ gwmux, err := sctx.registerGateway(opts)
+ if err != nil {
+ return err
+ }
+
+ tlsl := tls.NewListener(m.Match(cmux.Any()), tlscfg)
+ // TODO: add debug flag; enable logging when debug flag is set
+ httpmux := sctx.createMux(gwmux, handler)
+
+ srv := &http.Server{
+ Handler: httpmux,
+ TLSConfig: tlscfg,
+ ErrorLog: logger, // do not log user error
+ }
+ go func() { errHandler(srv.Serve(tlsl)) }()
+
+ plog.Infof("serving client requests on %s", sctx.l.Addr().String())
+ }
+
+ close(sctx.grpcServerC)
+ return m.Serve()
+}
+
+// grpcHandlerFunc returns an http.Handler that delegates to grpcServer on incoming gRPC
+// connections or otherHandler otherwise. Copied from cockroachdb.
+func grpcHandlerFunc(grpcServer *grpc.Server, otherHandler http.Handler) http.Handler {
+ if otherHandler == nil {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ grpcServer.ServeHTTP(w, r)
+ })
+ }
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.ProtoMajor == 2 && strings.Contains(r.Header.Get("Content-Type"), "application/grpc") {
+ grpcServer.ServeHTTP(w, r)
+ } else {
+ otherHandler.ServeHTTP(w, r)
+ }
+ })
+}
+
+type registerHandlerFunc func(context.Context, *gw.ServeMux, *grpc.ClientConn) error
+
+func (sctx *serveCtx) registerGateway(opts []grpc.DialOption) (*gw.ServeMux, error) {
+ ctx := sctx.ctx
+ conn, err := grpc.DialContext(ctx, sctx.addr, opts...)
+ if err != nil {
+ return nil, err
+ }
+ gwmux := gw.NewServeMux()
+
+ handlers := []registerHandlerFunc{
+ etcdservergw.RegisterKVHandler,
+ etcdservergw.RegisterWatchHandler,
+ etcdservergw.RegisterLeaseHandler,
+ etcdservergw.RegisterClusterHandler,
+ etcdservergw.RegisterMaintenanceHandler,
+ etcdservergw.RegisterAuthHandler,
+ v3lockgw.RegisterLockHandler,
+ v3electiongw.RegisterElectionHandler,
+ }
+ for _, h := range handlers {
+ if err := h(ctx, gwmux, conn); err != nil {
+ return nil, err
+ }
+ }
+ go func() {
+ <-ctx.Done()
+ if cerr := conn.Close(); cerr != nil {
+ plog.Warningf("failed to close conn to %s: %v", sctx.l.Addr().String(), cerr)
+ }
+ }()
+
+ return gwmux, nil
+}
+
+func (sctx *serveCtx) createMux(gwmux *gw.ServeMux, handler http.Handler) *http.ServeMux {
+ httpmux := http.NewServeMux()
+ for path, h := range sctx.userHandlers {
+ httpmux.Handle(path, h)
+ }
+
+ httpmux.Handle("/v3alpha/", gwmux)
+ if handler != nil {
+ httpmux.Handle("/", handler)
+ }
+ return httpmux
+}
+
+func (sctx *serveCtx) registerUserHandler(s string, h http.Handler) {
+ if sctx.userHandlers[s] != nil {
+ plog.Warningf("path %s already registered by user handler", s)
+ return
+ }
+ sctx.userHandlers[s] = h
+}
+
+func (sctx *serveCtx) registerPprof() {
+ for p, h := range debugutil.PProfHandlers() {
+ sctx.registerUserHandler(p, h)
+ }
+}
+
+func (sctx *serveCtx) registerTrace() {
+ reqf := func(w http.ResponseWriter, r *http.Request) { trace.Render(w, r, true) }
+ sctx.registerUserHandler("/debug/requests", http.HandlerFunc(reqf))
+ evf := func(w http.ResponseWriter, r *http.Request) { trace.RenderEvents(w, r, true) }
+ sctx.registerUserHandler("/debug/events", http.HandlerFunc(evf))
+}
diff --git a/vendor/github.com/coreos/etcd/embed/serve_test.go b/vendor/github.com/coreos/etcd/embed/serve_test.go
new file mode 100644
index 00000000..d46631fc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/embed/serve_test.go
@@ -0,0 +1,38 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 embed
+
+import (
+ "io/ioutil"
+ "os"
+ "testing"
+
+ "github.com/coreos/etcd/auth"
+)
+
+// TestStartEtcdWrongToken ensures that StartEtcd with wrong configs returns with error.
+func TestStartEtcdWrongToken(t *testing.T) {
+ tdir, err := ioutil.TempDir(os.TempDir(), "token-test")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(tdir)
+ cfg := NewConfig()
+ cfg.Dir = tdir
+ cfg.AuthToken = "wrong-token"
+ if _, err = StartEtcd(cfg); err != auth.ErrInvalidAuthOpts {
+ t.Fatalf("expected %v, got %v", auth.ErrInvalidAuthOpts, err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/embed/util.go b/vendor/github.com/coreos/etcd/embed/util.go
new file mode 100644
index 00000000..168e0313
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/embed/util.go
@@ -0,0 +1,30 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 embed
+
+import (
+ "path/filepath"
+
+ "github.com/coreos/etcd/wal"
+)
+
+func isMemberInitialized(cfg *Config) bool {
+ waldir := cfg.WalDir
+ if waldir == "" {
+ waldir = filepath.Join(cfg.Dir, "member", "wal")
+ }
+
+ return wal.Exist(waldir)
+}
diff --git a/vendor/github.com/coreos/etcd/error/error.go b/vendor/github.com/coreos/etcd/error/error.go
new file mode 100644
index 00000000..b541a628
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/error/error.go
@@ -0,0 +1,163 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 error describes errors in etcd project. When any change happens,
+// Documentation/v2/errorcode.md needs to be updated correspondingly.
+package error
+
+import (
+ "encoding/json"
+ "fmt"
+ "net/http"
+)
+
+var errors = map[int]string{
+ // command related errors
+ EcodeKeyNotFound: "Key not found",
+ EcodeTestFailed: "Compare failed", //test and set
+ EcodeNotFile: "Not a file",
+ ecodeNoMorePeer: "Reached the max number of peers in the cluster",
+ EcodeNotDir: "Not a directory",
+ EcodeNodeExist: "Key already exists", // create
+ ecodeKeyIsPreserved: "The prefix of given key is a keyword in etcd",
+ EcodeRootROnly: "Root is read only",
+ EcodeDirNotEmpty: "Directory not empty",
+ ecodeExistingPeerAddr: "Peer address has existed",
+ EcodeUnauthorized: "The request requires user authentication",
+
+ // Post form related errors
+ ecodeValueRequired: "Value is Required in POST form",
+ EcodePrevValueRequired: "PrevValue is Required in POST form",
+ EcodeTTLNaN: "The given TTL in POST form is not a number",
+ EcodeIndexNaN: "The given index in POST form is not a number",
+ ecodeValueOrTTLRequired: "Value or TTL is required in POST form",
+ ecodeTimeoutNaN: "The given timeout in POST form is not a number",
+ ecodeNameRequired: "Name is required in POST form",
+ ecodeIndexOrValueRequired: "Index or value is required",
+ ecodeIndexValueMutex: "Index and value cannot both be specified",
+ EcodeInvalidField: "Invalid field",
+ EcodeInvalidForm: "Invalid POST form",
+ EcodeRefreshValue: "Value provided on refresh",
+ EcodeRefreshTTLRequired: "A TTL must be provided on refresh",
+
+ // raft related errors
+ EcodeRaftInternal: "Raft Internal Error",
+ EcodeLeaderElect: "During Leader Election",
+
+ // etcd related errors
+ EcodeWatcherCleared: "watcher is cleared due to etcd recovery",
+ EcodeEventIndexCleared: "The event in requested index is outdated and cleared",
+ ecodeStandbyInternal: "Standby Internal Error",
+ ecodeInvalidActiveSize: "Invalid active size",
+ ecodeInvalidRemoveDelay: "Standby remove delay",
+
+ // client related errors
+ ecodeClientInternal: "Client Internal Error",
+}
+
+var errorStatus = map[int]int{
+ EcodeKeyNotFound: http.StatusNotFound,
+ EcodeNotFile: http.StatusForbidden,
+ EcodeDirNotEmpty: http.StatusForbidden,
+ EcodeUnauthorized: http.StatusUnauthorized,
+ EcodeTestFailed: http.StatusPreconditionFailed,
+ EcodeNodeExist: http.StatusPreconditionFailed,
+ EcodeRaftInternal: http.StatusInternalServerError,
+ EcodeLeaderElect: http.StatusInternalServerError,
+}
+
+const (
+ EcodeKeyNotFound = 100
+ EcodeTestFailed = 101
+ EcodeNotFile = 102
+ ecodeNoMorePeer = 103
+ EcodeNotDir = 104
+ EcodeNodeExist = 105
+ ecodeKeyIsPreserved = 106
+ EcodeRootROnly = 107
+ EcodeDirNotEmpty = 108
+ ecodeExistingPeerAddr = 109
+ EcodeUnauthorized = 110
+
+ ecodeValueRequired = 200
+ EcodePrevValueRequired = 201
+ EcodeTTLNaN = 202
+ EcodeIndexNaN = 203
+ ecodeValueOrTTLRequired = 204
+ ecodeTimeoutNaN = 205
+ ecodeNameRequired = 206
+ ecodeIndexOrValueRequired = 207
+ ecodeIndexValueMutex = 208
+ EcodeInvalidField = 209
+ EcodeInvalidForm = 210
+ EcodeRefreshValue = 211
+ EcodeRefreshTTLRequired = 212
+
+ EcodeRaftInternal = 300
+ EcodeLeaderElect = 301
+
+ EcodeWatcherCleared = 400
+ EcodeEventIndexCleared = 401
+ ecodeStandbyInternal = 402
+ ecodeInvalidActiveSize = 403
+ ecodeInvalidRemoveDelay = 404
+
+ ecodeClientInternal = 500
+)
+
+type Error struct {
+ ErrorCode int `json:"errorCode"`
+ Message string `json:"message"`
+ Cause string `json:"cause,omitempty"`
+ Index uint64 `json:"index"`
+}
+
+func NewRequestError(errorCode int, cause string) *Error {
+ return NewError(errorCode, cause, 0)
+}
+
+func NewError(errorCode int, cause string, index uint64) *Error {
+ return &Error{
+ ErrorCode: errorCode,
+ Message: errors[errorCode],
+ Cause: cause,
+ Index: index,
+ }
+}
+
+// Error is for the error interface
+func (e Error) Error() string {
+ return e.Message + " (" + e.Cause + ")"
+}
+
+func (e Error) toJsonString() string {
+ b, _ := json.Marshal(e)
+ return string(b)
+}
+
+func (e Error) StatusCode() int {
+ status, ok := errorStatus[e.ErrorCode]
+ if !ok {
+ status = http.StatusBadRequest
+ }
+ return status
+}
+
+func (e Error) WriteTo(w http.ResponseWriter) error {
+ w.Header().Add("X-Etcd-Index", fmt.Sprint(e.Index))
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(e.StatusCode())
+ _, err := w.Write([]byte(e.toJsonString() + "\n"))
+ return err
+}
diff --git a/vendor/github.com/coreos/etcd/error/error_test.go b/vendor/github.com/coreos/etcd/error/error_test.go
new file mode 100644
index 00000000..2d8164b3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/error/error_test.go
@@ -0,0 +1,50 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 error
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "reflect"
+ "strings"
+ "testing"
+)
+
+func TestErrorWriteTo(t *testing.T) {
+ for k := range errors {
+ err := NewError(k, "", 1)
+ rr := httptest.NewRecorder()
+ err.WriteTo(rr)
+
+ if err.StatusCode() != rr.Code {
+ t.Errorf("HTTP status code %d, want %d", rr.Code, err.StatusCode())
+ }
+
+ gbody := strings.TrimSuffix(rr.Body.String(), "\n")
+ if err.toJsonString() != gbody {
+ t.Errorf("HTTP body %q, want %q", gbody, err.toJsonString())
+ }
+
+ wheader := http.Header(map[string][]string{
+ "Content-Type": {"application/json"},
+ "X-Etcd-Index": {"1"},
+ })
+
+ if !reflect.DeepEqual(wheader, rr.HeaderMap) {
+ t.Errorf("HTTP headers %v, want %v", rr.HeaderMap, wheader)
+ }
+ }
+
+}
diff --git a/vendor/github.com/coreos/etcd/etcd.conf.yml.sample b/vendor/github.com/coreos/etcd/etcd.conf.yml.sample
new file mode 100644
index 00000000..7a3e802e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcd.conf.yml.sample
@@ -0,0 +1,138 @@
+# This is the configuration file for the etcd server.
+
+# Human-readable name for this member.
+name: 'default'
+
+# Path to the data directory.
+data-dir:
+
+# Path to the dedicated wal directory.
+wal-dir:
+
+# Number of committed transactions to trigger a snapshot to disk.
+snapshot-count: 10000
+
+# Time (in milliseconds) of a heartbeat interval.
+heartbeat-interval: 100
+
+# Time (in milliseconds) for an election to timeout.
+election-timeout: 1000
+
+# Raise alarms when backend size exceeds the given quota. 0 means use the
+# default quota.
+quota-backend-bytes: 0
+
+# List of comma separated URLs to listen on for peer traffic.
+listen-peer-urls: http://localhost:2380
+
+# List of comma separated URLs to listen on for client traffic.
+listen-client-urls: http://localhost:2379
+
+# Maximum number of snapshot files to retain (0 is unlimited).
+max-snapshots: 5
+
+# Maximum number of wal files to retain (0 is unlimited).
+max-wals: 5
+
+# Comma-separated white list of origins for CORS (cross-origin resource sharing).
+cors:
+
+# List of this member's peer URLs to advertise to the rest of the cluster.
+# The URLs needed to be a comma-separated list.
+initial-advertise-peer-urls: http://localhost:2380
+
+# List of this member's client URLs to advertise to the public.
+# The URLs needed to be a comma-separated list.
+advertise-client-urls: http://localhost:2379
+
+# Discovery URL used to bootstrap the cluster.
+discovery:
+
+# Valid values include 'exit', 'proxy'
+discovery-fallback: 'proxy'
+
+# HTTP proxy to use for traffic to discovery service.
+discovery-proxy:
+
+# DNS domain used to bootstrap initial cluster.
+discovery-srv:
+
+# Initial cluster configuration for bootstrapping.
+initial-cluster:
+
+# Initial cluster token for the etcd cluster during bootstrap.
+initial-cluster-token: 'etcd-cluster'
+
+# Initial cluster state ('new' or 'existing').
+initial-cluster-state: 'new'
+
+# Reject reconfiguration requests that would cause quorum loss.
+strict-reconfig-check: false
+
+# Accept etcd V2 client requests
+enable-v2: true
+
+# Valid values include 'on', 'readonly', 'off'
+proxy: 'off'
+
+# Time (in milliseconds) an endpoint will be held in a failed state.
+proxy-failure-wait: 5000
+
+# Time (in milliseconds) of the endpoints refresh interval.
+proxy-refresh-interval: 30000
+
+# Time (in milliseconds) for a dial to timeout.
+proxy-dial-timeout: 1000
+
+# Time (in milliseconds) for a write to timeout.
+proxy-write-timeout: 5000
+
+# Time (in milliseconds) for a read to timeout.
+proxy-read-timeout: 0
+
+client-transport-security:
+ # DEPRECATED: Path to the client server TLS CA file.
+ ca-file:
+
+ # Path to the client server TLS cert file.
+ cert-file:
+
+ # Path to the client server TLS key file.
+ key-file:
+
+ # Enable client cert authentication.
+ client-cert-auth: false
+
+ # Path to the client server TLS trusted CA key file.
+ trusted-ca-file:
+
+ # Client TLS using generated certificates
+ auto-tls: false
+
+peer-transport-security:
+ # DEPRECATED: Path to the peer server TLS CA file.
+ ca-file:
+
+ # Path to the peer server TLS cert file.
+ cert-file:
+
+ # Path to the peer server TLS key file.
+ key-file:
+
+ # Enable peer client cert authentication.
+ client-cert-auth: false
+
+ # Path to the peer server TLS trusted CA key file.
+ trusted-ca-file:
+
+ # Peer TLS using generated certificates.
+ auto-tls: false
+
+# Enable debug-level logging for etcd.
+debug: false
+
+# Specify a particular log level for each etcd package (eg: 'etcdmain=CRITICAL,etcdserver=DEBUG'.
+log-package-levels:
+
+# Force to create a new one member cluster.
+force-new-cluster: false
diff --git a/vendor/github.com/coreos/etcd/etcdctl/README.md b/vendor/github.com/coreos/etcd/etcdctl/README.md
new file mode 100644
index 00000000..22682370
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/README.md
@@ -0,0 +1,1315 @@
+etcdctl
+========
+
+`etcdctl` is a command line client for [etcd][etcd].
+Make sure to set environment variable `ETCDCTL_API=3`. For etcdctl v2, please check [READMEv2][READMEv2].
+
+Global flags (e.g., `dial-timeout`, `--cacert`, `--cert`, `--key`) can be set with environment variables:
+
+```
+ETCDCTL_DIAL_TIMEOUT=3s
+ETCDCTL_CACERT=/tmp/ca.pem
+ETCDCTL_CERT=/tmp/cert.pem
+ETCDCTL_KEY=/tmp/key.pem
+```
+
+Prefix flag strings with `ETCDCTL_`, convert all letters to upper-case, and replace dash(`-`) with underscore(`_`).
+
+## Key-value commands
+
+### PUT [options] \<key\> \<value\>
+
+PUT assigns the specified value with the specified key. If key already holds a value, it is overwritten.
+
+RPC: Put
+
+#### Options
+
+- lease -- lease ID (in hexadecimal) to attach to the key.
+
+- prev-kv -- return the previous key-value pair before modification.
+
+- ignore-value -- updates the key using its current value.
+
+- ignore-lease -- updates the key using its current lease.
+
+#### Output
+
+`OK`
+
+#### Examples
+
+```bash
+./etcdctl put foo bar --lease=1234abcd
+# OK
+./etcdctl get foo
+# foo
+# bar
+./etcdctl put foo --ignore-value # to detache lease
+# OK
+```
+
+```bash
+./etcdctl put foo bar --lease=1234abcd
+# OK
+./etcdctl put foo bar1 --ignore-lease # to use existing lease 1234abcd
+# OK
+./etcdctl get foo
+# foo
+# bar1
+```
+
+```bash
+./etcdctl put foo bar1 --prev-kv
+# OK
+# foo
+# bar
+./etcdctl get foo
+# foo
+# bar1
+```
+
+#### Remarks
+
+If \<value\> isn't given as command line argument, this command tries to read the value from standard input.
+
+When \<value\> begins with '-', \<value\> is interpreted as a flag.
+Insert '--' for workaround:
+
+```bash
+./etcdctl put <key> -- <value>
+./etcdctl put -- <key> <value>
+```
+
+### GET [options] \<key\> [range_end]
+
+GET gets the key or a range of keys [key, range_end) if `range-end` is given.
+
+RPC: Range
+
+#### Options
+
+- hex -- print out key and value as hex encode string
+
+- limit -- maximum number of results
+
+- prefix -- get keys by matching prefix
+
+- order -- order of results; ASCEND or DESCEND
+
+- sort-by -- sort target; CREATE, KEY, MODIFY, VALUE, or VERSION
+
+- rev -- specify the kv revision
+
+- print-value-only -- print only value when used with write-out=simple
+
+- consistency -- Linearizable(l) or Serializable(s)
+
+- from-key -- Get keys that are greater than or equal to the given key using byte compare
+
+- keys-only -- Get only the keys
+
+#### Output
+
+\<key\>\n\<value\>\n\<next_key\>\n\<next_value\>...
+
+#### Examples
+
+```bash
+./etcdctl put foo bar
+# OK
+./etcdctl put foo1 bar1
+# OK
+./etcdctl put foo2 bar2
+# OK
+./etcdctl put foo3 bar3
+# OK
+./etcdctl get foo
+# foo
+# bar
+./etcdctl get --from-key foo1
+# foo1
+# bar1
+# foo2
+# bar2
+# foo3
+# bar3
+./etcdctl get foo1 foo3
+# foo1
+# bar1
+# foo2
+# bar2
+```
+
+#### Remarks
+
+If any key or value contains non-printable characters or control characters, simple formatted output can be ambiguous due to new lines. To resolve this issue, set `--hex` to hex encode all strings.
+
+### DEL [options] \<key\> [range_end]
+
+Removes the specified key or range of keys [key, range_end) if `range-end` is given.
+
+RPC: DeleteRange
+
+#### Options
+
+- prefix -- delete keys by matching prefix
+
+- prev-kv -- return deleted key-value pairs
+
+- from-key -- delete keys that are greater than or equal to the given key using byte compare
+
+#### Output
+
+Prints the number of keys that were removed in decimal if DEL succeeded.
+
+#### Examples
+
+```bash
+./etcdctl put foo bar
+# OK
+./etcdctl del foo
+# 1
+./etcdctl get foo
+```
+
+```bash
+./etcdctl put key val
+# OK
+./etcdctl del --prev-kv key
+# 1
+# key
+# val
+./etcdctl get key
+```
+
+```bash
+./etcdctl put a 123
+# OK
+./etcdctl put b 456
+# OK
+./etcdctl put z 789
+# OK
+./etcdctl del --from-key a
+# 3
+./etcdctl get --from-key a
+```
+
+```bash
+./etcdctl put zoo val
+# OK
+./etcdctl put zoo1 val1
+# OK
+./etcdctl put zoo2 val2
+# OK
+./etcdctl del --prefix zoo
+# 3
+./etcdctl get zoo2
+```
+
+### TXN [options]
+
+TXN reads multiple etcd requests from standard input and applies them as a single atomic transaction.
+A transaction consists of list of conditions, a list of requests to apply if all the conditions are true, and a list of requests to apply if any condition is false.
+
+RPC: Txn
+
+#### Options
+
+- hex -- print out keys and values as hex encoded strings.
+
+- interactive -- input transaction with interactive prompting.
+
+#### Input Format
+```ebnf
+<Txn> ::= <CMP>* "\n" <THEN> "\n" <ELSE> "\n"
+<CMP> ::= (<CMPCREATE>|<CMPMOD>|<CMPVAL>|<CMPVER>) "\n"
+<CMPOP> ::= "<" | "=" | ">"
+<CMPCREATE> := ("c"|"create")"("<KEY>")" <REVISION>
+<CMPMOD> ::= ("m"|"mod")"("<KEY>")" <CMPOP> <REVISION>
+<CMPVAL> ::= ("val"|"value")"("<KEY>")" <CMPOP> <VALUE>
+<CMPVER> ::= ("ver"|"version")"("<KEY>")" <CMPOP> <VERSION>
+<THEN> ::= <OP>*
+<ELSE> ::= <OP>*
+<OP> ::= ((see put, get, del etcdctl command syntax)) "\n"
+<KEY> ::= (%q formatted string)
+<VALUE> ::= (%q formatted string)
+<REVISION> ::= "\""[0-9]+"\""
+<VERSION> ::= "\""[0-9]+"\""
+```
+
+#### Output
+
+`SUCCESS` if etcd processed the transaction success list, `FAILURE` if etcd processed the transaction failure list. Prints the output for each command in the executed request list, each separated by a blank line.
+
+#### Examples
+
+txn in interactive mode:
+```bash
+./etcdctl txn -i
+# compares:
+mod("key1") > "0"
+
+# success requests (get, put, delete):
+put key1 "overwrote-key1"
+
+# failure requests (get, put, delete):
+put key1 "created-key1"
+put key2 "some extra key"
+
+# FAILURE
+
+# OK
+
+# OK
+```
+
+txn in non-interactive mode:
+```bash
+./etcdctl txn <<<'mod("key1") > "0"
+
+put key1 "overwrote-key1"
+
+put key1 "created-key1"
+put key2 "some extra key"
+
+'
+
+# FAILURE
+
+# OK
+
+# OK
+```
+
+### COMPACTION [options] \<revision\>
+
+COMPACTION discards all etcd event history prior to a given revision. Since etcd uses a multiversion concurrency control
+model, it preserves all key updates as event history. When the event history up to some revision is no longer needed,
+all superseded keys may be compacted away to reclaim storage space in the etcd backend database.
+
+RPC: Compact
+
+#### Options
+
+- physical -- 'true' to wait for compaction to physically remove all old revisions
+
+#### Output
+
+Prints the compacted revision.
+
+#### Example
+```bash
+./etcdctl compaction 1234
+# compacted revision 1234
+```
+
+### WATCH [options] [key or prefix] [range_end]
+
+Watch watches events stream on keys or prefixes, [key or prefix, range_end) if `range-end` is given. The watch command runs until it encounters an error or is terminated by the user. If range_end is given, it must be lexicographically greater than key or "\x00".
+
+RPC: Watch
+
+#### Options
+
+- hex -- print out key and value as hex encode string
+
+- interactive -- begins an interactive watch session
+
+- prefix -- watch on a prefix if prefix is set.
+
+- prev-kv -- get the previous key-value pair before the event happens.
+
+- rev -- the revision to start watching. Specifying a revision is useful for observing past events.
+
+#### Input format
+
+Input is only accepted for interactive mode.
+
+```
+watch [options] <key or prefix>\n
+```
+
+#### Output
+
+\<event\>[\n\<old_key\>\n\<old_value\>]\n\<key\>\n\<value\>\n\<event\>\n\<next_key\>\n\<next_value\>\n...
+
+#### Examples
+
+##### Non-interactive
+
+```bash
+./etcdctl watch foo
+# PUT
+# foo
+# bar
+```
+
+##### Interactive
+
+```bash
+./etcdctl watch -i
+watch foo
+watch foo
+# PUT
+# foo
+# bar
+# PUT
+# foo
+# bar
+```
+
+### LEASE \<subcommand\>
+
+LEASE provides commands for key lease management.
+
+### LEASE GRANT \<ttl\>
+
+LEASE GRANT creates a fresh lease with a server-selected time-to-live in seconds
+greater than or equal to the requested TTL value.
+
+RPC: LeaseGrant
+
+#### Output
+
+Prints a message with the granted lease ID.
+
+#### Example
+
+```bash
+./etcdctl lease grant 10
+# lease 32695410dcc0ca06 granted with TTL(10s)
+```
+
+### LEASE REVOKE \<leaseID\>
+
+LEASE REVOKE destroys a given lease, deleting all attached keys.
+
+RPC: LeaseRevoke
+
+#### Output
+
+Prints a message indicating the lease is revoked.
+
+#### Example
+
+```bash
+./etcdctl lease revoke 32695410dcc0ca06
+# lease 32695410dcc0ca06 revoked
+```
+
+### LEASE TIMETOLIVE \<leaseID\> [options]
+
+LEASE TIMETOLIVE retrieves the lease information with the given lease ID.
+
+RPC: LeaseTimeToLive
+
+#### Options
+
+- keys -- Get keys attached to this lease
+
+#### Output
+
+Prints lease information.
+
+#### Example
+
+```bash
+./etcdctl lease grant 500
+# lease 2d8257079fa1bc0c granted with TTL(500s)
+
+./etcdctl put foo1 bar --lease=2d8257079fa1bc0c
+# OK
+
+./etcdctl put foo2 bar --lease=2d8257079fa1bc0c
+# OK
+
+./etcdctl lease timetolive 2d8257079fa1bc0c
+# lease 2d8257079fa1bc0c granted with TTL(500s), remaining(481s)
+
+./etcdctl lease timetolive 2d8257079fa1bc0c --keys
+# lease 2d8257079fa1bc0c granted with TTL(500s), remaining(472s), attached keys([foo2 foo1])
+
+./etcdctl lease timetolive 2d8257079fa1bc0c --write-out=json
+# {"cluster_id":17186838941855831277,"member_id":4845372305070271874,"revision":3,"raft_term":2,"id":3279279168933706764,"ttl":465,"granted-ttl":500,"keys":null}
+
+./etcdctl lease timetolive 2d8257079fa1bc0c --write-out=json --keys
+# {"cluster_id":17186838941855831277,"member_id":4845372305070271874,"revision":3,"raft_term":2,"id":3279279168933706764,"ttl":459,"granted-ttl":500,"keys":["Zm9vMQ==","Zm9vMg=="]}
+```
+
+### LEASE KEEP-ALIVE \<leaseID\>
+
+LEASE KEEP-ALIVE periodically refreshes a lease so it does not expire.
+
+RPC: LeaseKeepAlive
+
+#### Output
+
+Prints a message for every keep alive sent or prints a message indicating the lease is gone.
+
+#### Example
+```bash
+./etcdctl lease keep-alive 32695410dcc0ca0
+# lease 32695410dcc0ca0 keepalived with TTL(100)
+# lease 32695410dcc0ca0 keepalived with TTL(100)
+# lease 32695410dcc0ca0 keepalived with TTL(100)
+...
+```
+
+## Cluster maintenance commands
+
+### MEMBER \<subcommand\>
+
+MEMBER provides commands for managing etcd cluster membership.
+
+### MEMBER ADD \<memberName\> [options]
+
+MEMBER ADD introduces a new member into the etcd cluster as a new peer.
+
+RPC: MemberAdd
+
+#### Options
+
+- peer-urls -- comma separated list of URLs to associate with the new member.
+
+#### Output
+
+Prints the member ID of the new member and the cluster ID.
+
+#### Example
+
+```bash
+./etcdctl member add newMember --peer-urls=https://127.0.0.1:12345
+
+Member ced000fda4d05edf added to cluster 8c4281cc65c7b112
+
+ETCD_NAME="newMember"
+ETCD_INITIAL_CLUSTER="newMember=https://127.0.0.1:12345,default=http://10.0.0.30:2380"
+ETCD_INITIAL_CLUSTER_STATE="existing"
+```
+
+### MEMBER UPDATE \<memberID\> [options]
+
+MEMBER UPDATE sets the peer URLs for an existing member in the etcd cluster.
+
+RPC: MemberUpdate
+
+#### Options
+
+- peer-urls -- comma separated list of URLs to associate with the updated member.
+
+#### Output
+
+Prints the member ID of the updated member and the cluster ID.
+
+#### Example
+
+```bash
+./etcdctl member update 2be1eb8f84b7f63e --peer-urls=https://127.0.0.1:11112
+# Member 2be1eb8f84b7f63e updated in cluster ef37ad9dc622a7c4
+```
+
+### MEMBER REMOVE \<memberID\>
+
+MEMBER REMOVE removes a member of an etcd cluster from participating in cluster consensus.
+
+RPC: MemberRemove
+
+#### Output
+
+Prints the member ID of the removed member and the cluster ID.
+
+#### Example
+
+```bash
+./etcdctl member remove 2be1eb8f84b7f63e
+# Member 2be1eb8f84b7f63e removed from cluster ef37ad9dc622a7c4
+```
+
+### MEMBER LIST
+
+MEMBER LIST prints the member details for all members associated with an etcd cluster.
+
+RPC: [MemberList][member_list_rpc].
+
+#### Output
+
+Prints a humanized table of the member IDs, statuses, names, peer addresses, and client addresses.
+
+#### Examples
+
+```bash
+./etcdctl member list
+# 8211f1d0f64f3269, started, infra1, http://127.0.0.1:12380, http://127.0.0.1:2379
+# 91bc3c398fb3c146, started, infra2, http://127.0.0.1:22380, http://127.0.0.1:22379
+# fd422379fda50e48, started, infra3, http://127.0.0.1:32380, http://127.0.0.1:32379
+```
+
+```bash
+./etcdctl -w json member list
+# {"header":{"cluster_id":17237436991929493444,"member_id":9372538179322589801,"raft_term":2},"members":[{"ID":9372538179322589801,"name":"infra1","peerURLs":["http://127.0.0.1:12380"],"clientURLs":["http://127.0.0.1:2379"]},{"ID":10501334649042878790,"name":"infra2","peerURLs":["http://127.0.0.1:22380"],"clientURLs":["http://127.0.0.1:22379"]},{"ID":18249187646912138824,"name":"infra3","peerURLs":["http://127.0.0.1:32380"],"clientURLs":["http://127.0.0.1:32379"]}]}
+```
+
+```bash
+./etcdctl -w table member list
++------------------+---------+--------+------------------------+------------------------+
+| ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS |
++------------------+---------+--------+------------------------+------------------------+
+| 8211f1d0f64f3269 | started | infra1 | http://127.0.0.1:12380 | http://127.0.0.1:2379 |
+| 91bc3c398fb3c146 | started | infra2 | http://127.0.0.1:22380 | http://127.0.0.1:22379 |
+| fd422379fda50e48 | started | infra3 | http://127.0.0.1:32380 | http://127.0.0.1:32379 |
++------------------+---------+--------+------------------------+------------------------+
+```
+
+### ENDPOINT \<subcommand\>
+
+ENDPOINT provides commands for querying individual endpoints.
+
+### ENDPOINT HEALTH
+
+ENDPOINT HEALTH checks the health of the list of endpoints with respect to cluster. An endpoint is unhealthy
+when it cannot participate in consensus with the rest of the cluster.
+
+#### Output
+
+If an endpoint can participate in consensus, prints a message indicating the endpoint is healthy. If an endpoint fails to participate in consensus, prints a message indicating the endpoint is unhealthy.
+
+#### Example
+
+```bash
+./etcdctl endpoint health
+# 127.0.0.1:32379 is healthy: successfully committed proposal: took = 2.130877ms
+# 127.0.0.1:2379 is healthy: successfully committed proposal: took = 2.095242ms
+# 127.0.0.1:22379 is healthy: successfully committed proposal: took = 2.083263ms
+```
+
+### ENDPOINT STATUS
+
+ENDPOINT STATUS queries the status of each endpoint in the given endpoint list.
+
+#### Output
+
+##### Simple format
+
+Prints a humanized table of each endpoint URL, ID, version, database size, leadership status, raft term, and raft status.
+
+##### JSON format
+
+Prints a line of JSON encoding each endpoint URL, ID, version, database size, leadership status, raft term, and raft status.
+
+#### Examples
+
+```bash
+./etcdctl endpoint status
+# 127.0.0.1:2379, 8211f1d0f64f3269, 3.0.0, 25 kB, false, 2, 63
+# 127.0.0.1:22379, 91bc3c398fb3c146, 3.0.0, 25 kB, false, 2, 63
+# 127.0.0.1:32379, fd422379fda50e48, 3.0.0, 25 kB, true, 2, 63
+```
+
+```bash
+./etcdctl -w json endpoint status
+# [{"Endpoint":"127.0.0.1:2379","Status":{"header":{"cluster_id":17237436991929493444,"member_id":9372538179322589801,"revision":2,"raft_term":2},"version":"3.0.0","dbSize":24576,"leader":18249187646912138824,"raftIndex":32623,"raftTerm":2}},{"Endpoint":"127.0.0.1:22379","Status":{"header":{"cluster_id":17237436991929493444,"member_id":10501334649042878790,"revision":2,"raft_term":2},"version":"3.0.0","dbSize":24576,"leader":18249187646912138824,"raftIndex":32623,"raftTerm":2}},{"Endpoint":"127.0.0.1:32379","Status":{"header":{"cluster_id":17237436991929493444,"member_id":18249187646912138824,"revision":2,"raft_term":2},"version":"3.0.0","dbSize":24576,"leader":18249187646912138824,"raftIndex":32623,"raftTerm":2}}]
+```
+
+```bash
+./etcdctl -w table endpoint status
++-----------------+------------------+---------+---------+-----------+-----------+------------+
+| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | RAFT TERM | RAFT INDEX |
++-----------------+------------------+---------+---------+-----------+-----------+------------+
+| 127.0.0.1:2379 | 8211f1d0f64f3269 | 3.0.0 | 25 kB | false | 2 | 52 |
+| 127.0.0.1:22379 | 91bc3c398fb3c146 | 3.0.0 | 25 kB | false | 2 | 52 |
+| 127.0.0.1:32379 | fd422379fda50e48 | 3.0.0 | 25 kB | true | 2 | 52 |
++-----------------+------------------+---------+---------+-----------+-----------+------------+
+```
+
+### ALARM \<subcommand\>
+
+Provides alarm related commands
+
+### ALARM DISARM
+
+`alarm disarm` Disarms all alarms
+
+RPC: Alarm
+
+#### Output
+
+`alarm:<alarm type>` if alarm is present and disarmed.
+
+#### Examples
+
+```bash
+./etcdctl alarm disarm
+```
+
+If NOSPACE alarm is present:
+
+```bash
+./etcdctl alarm disarm
+# alarm:NOSPACE
+```
+
+### ALARM LIST
+
+`alarm list` lists all alarms.
+
+RPC: Alarm
+
+#### Output
+
+`alarm:<alarm type>` if alarm is present, empty string if no alarms present.
+
+#### Examples
+
+```bash
+./etcdctl alarm list
+```
+
+If NOSPACE alarm is present:
+
+```bash
+./etcdctl alarm list
+# alarm:NOSPACE
+```
+
+### DEFRAG
+
+DEFRAG defragments the backend database file for a set of given endpoints. When an etcd member reclaims storage space
+from deleted and compacted keys, the space is kept in a free list and the database file remains the same size. By defragmenting
+the database, the etcd member releases this free space back to the file system.
+
+#### Output
+
+For each endpoints, prints a message indicating whether the endpoint was successfully defragmented.
+
+#### Example
+
+```bash
+./etcdctl --endpoints=localhost:2379,badendpoint:2379 defrag
+# Finished defragmenting etcd member[localhost:2379]
+# Failed to defragment etcd member[badendpoint:2379] (grpc: timed out trying to connect)
+```
+
+#### Remarks
+
+DEFRAG returns a zero exit code only if it succeeded defragmenting all given endpoints.
+
+### SNAPSHOT \<subcommand\>
+
+SNAPSHOT provides commands to restore a snapshot of a running etcd server into a fresh cluster.
+
+### SNAPSHOT SAVE \<filename\>
+
+SNAPSHOT SAVE writes a point-in-time snapshot of the etcd backend database to a file.
+
+#### Output
+
+The backend snapshot is written to the given file path.
+
+#### Example
+
+Save a snapshot to "snapshot.db":
+```
+./etcdctl snapshot save snapshot.db
+```
+
+### SNAPSHOT RESTORE [options] \<filename\>
+
+SNAPSHOT RESTORE creates an etcd data directory for an etcd cluster member from a backend database snapshot and a new cluster configuration. Restoring the snapshot into each member for a new cluster configuration will initialize a new etcd cluster preloaded by the snapshot data.
+
+#### Options
+
+The snapshot restore options closely resemble to those used in the `etcd` command for defining a cluster.
+
+- data-dir -- Path to the data directory. Uses \<name\>.etcd if none given.
+
+- initial-cluster -- The initial cluster configuration for the restored etcd cluster.
+
+- initial-cluster-token -- Initial cluster token for the restored etcd cluster.
+
+- initial-advertise-peer-urls -- List of peer URLs for the member being restored.
+
+- name -- Human-readable name for the etcd cluster member being restored.
+
+- skip-hash-check -- Ignore snapshot integrity hash value (required if copied from data directory)
+
+#### Output
+
+A new etcd data directory initialized with the snapshot.
+
+#### Example
+
+Save a snapshot, restore into a new 3 node cluster, and start the cluster:
+```
+./etcdctl snapshot save snapshot.db
+
+# restore members
+bin/etcdctl snapshot restore snapshot.db --initial-cluster-token etcd-cluster-1 --initial-advertise-peer-urls http://127.0.0.1:12380 --name sshot1 --initial-cluster 'sshot1=http://127.0.0.1:12380,sshot2=http://127.0.0.1:22380,sshot3=http://127.0.0.1:32380'
+bin/etcdctl snapshot restore snapshot.db --initial-cluster-token etcd-cluster-1 --initial-advertise-peer-urls http://127.0.0.1:22380 --name sshot2 --initial-cluster 'sshot1=http://127.0.0.1:12380,sshot2=http://127.0.0.1:22380,sshot3=http://127.0.0.1:32380'
+bin/etcdctl snapshot restore snapshot.db --initial-cluster-token etcd-cluster-1 --initial-advertise-peer-urls http://127.0.0.1:32380 --name sshot3 --initial-cluster 'sshot1=http://127.0.0.1:12380,sshot2=http://127.0.0.1:22380,sshot3=http://127.0.0.1:32380'
+
+# launch members
+bin/etcd --name sshot1 --listen-client-urls http://127.0.0.1:2379 --advertise-client-urls http://127.0.0.1:2379 --listen-peer-urls http://127.0.0.1:12380 &
+bin/etcd --name sshot2 --listen-client-urls http://127.0.0.1:22379 --advertise-client-urls http://127.0.0.1:22379 --listen-peer-urls http://127.0.0.1:22380 &
+bin/etcd --name sshot3 --listen-client-urls http://127.0.0.1:32379 --advertise-client-urls http://127.0.0.1:32379 --listen-peer-urls http://127.0.0.1:32380 &
+```
+
+### SNAPSHOT STATUS \<filename\>
+
+SNAPSHOT STATUS lists information about a given backend database snapshot file.
+
+#### Output
+
+##### Simple format
+
+Prints a humanized table of the database hash, revision, total keys, and size.
+
+##### JSON format
+
+Prints a line of JSON encoding the database hash, revision, total keys, and size.
+
+#### Examples
+```bash
+./etcdctl snapshot status file.db
+# cf1550fb, 3, 3, 25 kB
+```
+
+```bash
+./etcdctl -write-out=json snapshot status file.db
+# {"hash":3474280699,"revision":3,"totalKey":3,"totalSize":24576}
+```
+
+```bash
+./etcdctl -write-out=table snapshot status file.db
++----------+----------+------------+------------+
+| HASH | REVISION | TOTAL KEYS | TOTAL SIZE |
++----------+----------+------------+------------+
+| cf1550fb | 3 | 3 | 25 kB |
++----------+----------+------------+------------+
+```
+
+## Concurrency commands
+
+### LOCK \<lockname\> [command arg1 arg2 ...]
+
+LOCK acquires a distributed named mutex with a given name. Once the lock is acquired, it will be held until etcdctl is terminated.
+
+#### Output
+
+Once the lock is acquired, the result for the GET on the unique lock holder key is displayed.
+
+If a command is given, it will be launched with environment variables `ETCD_LOCK_KEY` and `ETCD_LOCK_REV` set to the lock's holder key and revision.
+
+#### Example
+
+Acquire lock with standard output display:
+
+```bash
+./etcdctl lock mylock
+# mylock/1234534535445
+```
+
+Acquire lock and execute `echo lock acquired`:
+
+```bash
+./etcdctl lock mylock echo lock acquired
+# lock acquired
+```
+
+#### Remarks
+
+LOCK returns a zero exit code only if it is terminated by a signal and releases the lock.
+
+If LOCK is abnormally terminated or fails to contact the cluster to release the lock, the lock will remain held until the lease expires. Progress may be delayed by up to the default lease length of 60 seconds.
+
+### ELECT [options] \<election-name\> [proposal]
+
+ELECT participates on a named election. A node announces its candidacy in the election by providing
+a proposal value. If a node wishes to observe the election, ELECT listens for new leaders values.
+Whenever a leader is elected, its proposal is given as output.
+
+#### Options
+
+- listen -- observe the election.
+
+#### Output
+
+- If a candidate, ELECT displays the GET on the leader key once the node is elected election.
+
+- If observing, ELECT streams the result for a GET on the leader key for the current election and all future elections.
+
+#### Example
+
+```bash
+./etcdctl elect myelection foo
+# myelection/1456952310051373265
+# foo
+```
+
+#### Remarks
+
+ELECT returns a zero exit code only if it is terminated by a signal and can revoke its candidacy or leadership, if any.
+
+If a candidate is abnormally terminated, election rogress may be delayed by up to the default lease length of 60 seconds.
+
+## Authentication commands
+
+### AUTH \<enable or disable\>
+
+`auth enable` activates authentication on an etcd cluster and `auth disable` deactivates. When authentication is enabled, etcd checks all requests for appropriate authorization.
+
+RPC: AuthEnable/AuthDisable
+
+#### Output
+
+`Authentication Enabled`.
+
+#### Examples
+
+```bash
+./etcdctl user add root
+# Password of root:#type password for root
+# Type password of root again for confirmation:#re-type password for root
+# User root created
+./etcdctl user grant-role root root
+# Role root is granted to user root
+./etcdctl user get root
+# User: root
+# Roles: root
+./etcdctl role add root
+# Role root created
+./etcdctl role get root
+# Role root
+# KV Read:
+# KV Write:
+./etcdctl auth enable
+# Authentication Enabled
+```
+
+### ROLE \<subcommand\>
+
+ROLE is used to specify differnt roles which can be assigned to etcd user(s).
+
+### ROLE ADD \<role name\>
+
+`role add` creates a role.
+
+RPC: RoleAdd
+
+#### Output
+
+`Role <role name> created`.
+
+#### Examples
+
+```bash
+./etcdctl --user=root:123 role add myrole
+# Role myrole created
+```
+
+### ROLE GET \<role name\>
+
+`role get` lists detailed role information.
+
+RPC: RoleGet
+
+#### Output
+
+Detailed role information.
+
+#### Examples
+
+```bash
+./etcdctl --user=root:123 role get myrole
+# Role myrole
+# KV Read:
+# foo
+# KV Write:
+# foo
+```
+
+### ROLE DELETE \<role name\>
+
+`role delete` deletes a role.
+
+RPC: RoleDelete
+
+#### Output
+
+`Role <role name> deleted`.
+
+#### Examples
+
+```bash
+./etcdctl --user=root:123 role delete myrole
+# Role myrole deleted
+```
+
+### ROLE LIST \<role name\>
+
+`role list` lists all roles in etcd.
+
+RPC: RoleList
+
+#### Output
+
+A role per line.
+
+#### Examples
+
+```bash
+./etcdctl --user=root:123 role list
+# roleA
+# roleB
+# myrole
+```
+
+### ROLE GRANT-PERMISSION [options] \<role name\> \<permission type\> \<key\> [endkey]
+
+`role grant-permission` grants a key to a role.
+
+RPC: RoleGrantPermission
+
+#### Options
+
+- from-key -- grant a permission of keys that are greater than or equal to the given key using byte compare
+
+- prefix -- grant a prefix permission
+
+#### Output
+
+`Role <role name> updated`.
+
+#### Examples
+
+Grant read and write permission on the key `foo` to role `myrole`:
+
+```bash
+./etcdctl --user=root:123 role grant-permission myrole readwrite foo
+# Role myrole updated
+```
+
+Grant read permission on the wildcard key pattern `foo/*` to role `myrole`:
+
+```bash
+./etcdctl --user=root:123 role grant-permission --prefix myrole readwrite foo/
+# Role myrole updated
+```
+
+### ROLE REVOKE-PERMISSION \<role name\> \<permission type\> \<key\> [endkey]
+
+`role revoke-permission` revokes a key from a role.
+
+RPC: RoleRevokePermission
+
+#### Options
+
+- from-key -- revoke a permission of keys that are greater than or equal to the given key using byte compare
+
+- prefix -- revoke a prefix permission
+
+#### Output
+
+`Permission of key <key> is revoked from role <role name>` for single key. `Permission of range [<key>, <endkey>) is revoked from role <role name>` for a key range. Exit code is zero.
+
+#### Examples
+
+```bash
+./etcdctl --user=root:123 role revoke-permission myrole foo
+# Permission of key foo is revoked from role myrole
+```
+
+### USER \<subcommand\>
+
+USER provides commands for managing users of etcd.
+
+### USER ADD \<user name or user:password\> [options]
+
+`user add` creates a user.
+
+RPC: UserAdd
+
+#### Options
+
+- interactive -- Read password from stdin instead of interactive terminal
+
+#### Output
+
+`User <user name> created`.
+
+#### Examples
+
+```bash
+./etcdctl --user=root:123 user add myuser
+# Password of myuser: #type password for my user
+# Type password of myuser again for confirmation:#re-type password for my user
+# User myuser created
+```
+
+### USER GET \<user name\> [options]
+
+`user get` lists detailed user information.
+
+RPC: UserGet
+
+#### Options
+
+- detail -- Show permissions of roles granted to the user
+
+#### Output
+
+Detailed user information.
+
+#### Examples
+
+```bash
+./etcdctl --user=root:123 user get myuser
+# User: myuser
+# Roles:
+```
+
+### USER DELETE \<user name\>
+
+`user delete` deletes a user.
+
+RPC: UserDelete
+
+#### Output
+
+`User <user name> deleted`.
+
+#### Examples
+
+```bash
+./etcdctl --user=root:123 user delete myuser
+# User myuser deleted
+```
+
+### USER LIST
+
+`user list` lists detailed user information.
+
+RPC: UserList
+
+#### Output
+
+- List of users, one per line.
+
+#### Examples
+
+```bash
+./etcdctl --user=root:123 user list
+# user1
+# user2
+# myuser
+```
+
+### USER PASSWD \<user name\> [options]
+
+`user passwd` changes a user's password.
+
+RPC: UserChangePassword
+
+#### Options
+
+- interactive -- if true, read password in interactive terminal
+
+#### Output
+
+`Password updated`.
+
+#### Examples
+
+```bash
+./etcdctl --user=root:123 user passwd myuser
+# Password of myuser: #type new password for my user
+# Type password of myuser again for confirmation: #re-type the new password for my user
+# Password updated
+```
+
+### USER GRANT-ROLE \<user name\> \<role name\>
+
+`user grant-role` grants a role to a user
+
+RPC: UserGrantRole
+
+#### Output
+
+`Role <role name> is granted to user <user name>`.
+
+#### Examples
+
+```bash
+./etcdctl --user=root:123 user grant-role userA roleA
+# Role roleA is granted to user userA
+```
+
+### USER REVOKE-ROLE \<user name\> \<role name\>
+
+`user revoke-role` revokes a role from a user
+
+RPC: UserRevokeRole
+
+#### Output
+
+`Role <role name> is revoked from user <user name>`.
+
+#### Examples
+
+```bash
+./etcdctl --user=root:123 user revoke-role userA roleA
+# Role roleA is revoked from user userA
+```
+
+## Utility commands
+
+### MAKE-MIRROR [options] \<destination\>
+
+[make-mirror][mirror] mirrors a key prefix in an etcd cluster to a destination etcd cluster.
+
+#### Options
+
+- dest-cacert -- TLS certificate authority file for destination cluster
+
+- dest-cert -- TLS certificate file for destination cluster
+
+- dest-key -- TLS key file for destination cluster
+
+- prefix -- The key-value prefix to mirror
+
+- dest-prefix -- The destination prefix to mirror a prefix to a different prefix in the destination cluster
+
+- no-dest-prefix -- Mirror key-values to the root of the destination cluster
+
+- dest-insecure-transport -- Disable transport security for client connections
+
+#### Output
+
+The approximate total number of keys transferred to the destination cluster, updated every 30 seconds.
+
+#### Examples
+
+```
+./etcdctl make-mirror mirror.example.com:2379
+# 10
+# 18
+```
+
+[mirror]: ./doc/mirror_maker.md
+
+### MIGRATE [options]
+
+Migrates keys in a v2 store to a v3 mvcc store. Users should run migration command for all members in the cluster.
+
+#### Options
+
+- data-dir -- Path to the data directory
+
+- wal-dir -- Path to the WAL directory
+
+- transformer -- Path to the user-provided transformer program (default if not provided)
+
+#### Output
+
+No output on success.
+
+#### Default transformer
+
+If user does not provide a transformer program, migrate command will use the default transformer. The default transformer transforms `storev2` formatted keys into `mvcc` formatted keys according to the following Go program:
+
+```go
+func transform(n *storev2.Node) *mvccpb.KeyValue {
+ if n.Dir {
+ return nil
+ }
+ kv := &mvccpb.KeyValue{
+ Key: []byte(n.Key),
+ Value: []byte(n.Value),
+ CreateRevision: int64(n.CreatedIndex),
+ ModRevision: int64(n.ModifiedIndex),
+ Version: 1,
+ }
+ return kv
+}
+```
+
+#### User-provided transformer
+
+Users can provide a customized 1:n transformer function that transforms a key from the v2 store to any number of keys in the mvcc store. The migration program writes JSON formatted [v2 store keys][v2key] to the transformer program's stdin, reads protobuf formatted [mvcc keys][v3key] back from the transformer program's stdout, and finishes migration by saving the transformed keys into the mvcc store.
+
+The provided transformer should read until EOF and flush the stdout before exiting to ensure data integrity.
+
+#### Example
+
+```
+./etcdctl migrate --data-dir=/var/etcd --transformer=k8s-transformer
+# finished transforming keys
+```
+
+### VERSION
+
+Prints the version of etcdctl.
+
+#### Output
+
+Prints etcd version and API version.
+
+#### Examples
+
+```bash
+./etcdctl version
+# etcdctl version: 3.1.0-alpha.0+git
+# API version: 3.1
+```
+
+## Exit codes
+
+For all commands, a successful execution return a zero exit code. All failures will return non-zero exit codes.
+
+## Output formats
+
+All commands accept an output format by setting `-w` or `--write-out`. All commands default to the "simple" output format, which is meant to be human-readable. The simple format is listed in each command's `Output` description since it is customized for each command. If a command has a corresponding RPC, it will respect all output formats.
+
+If a command fails, returning a non-zero exit code, an error string will be written to standard error regardless of output format.
+
+### Simple
+
+A format meant to be easy to parse and human-readable. Specific to each command.
+
+### JSON
+
+The JSON encoding of the command's [RPC response][etcdrpc]. Since etcd's RPCs use byte strings, the JSON output will encode keys and values in base64.
+
+Some commands without an RPC also support JSON; see the command's `Output` description.
+
+### Protobuf
+
+The protobuf encoding of the command's [RPC response][etcdrpc]. If an RPC is streaming, the stream messages will be concetenated. If an RPC is not given for a command, the protobuf output is not defined.
+
+### Fields
+
+An output format similar to JSON but meant to parse with coreutils. For an integer field named `Field`, it writes a line in the format `"Field" : %d` where `%d` is go's integer formatting. For byte array fields, it writes `"Field" : %q` where `%q` is go's quoted string formatting (e.g., `[]byte{'a', '\n'}` is written as `"a\n"`).
+
+## Compatibility Support
+
+etcdctl is still in its early stage. We try out best to ensure fully compatible releases, however we might break compatibility to fix bugs or improve commands. If we intend to release a version of etcdctl with backward incompatibilities, we will provide notice prior to release and have instructions on how to upgrade.
+
+### Input Compatibility
+
+Input includes the command name, its flags, and its arguments. We ensure backward compatibility of the input of normal commands in non-interactive mode.
+
+### Output Compatibility
+
+Output includes output from etcdctl and its exit code. etcdctl provides `simple` output format by default.
+We ensure compatibility for the `simple` output format of normal commands in non-interactive mode. Currently, we do not ensure
+backward compatibility for `JSON` format and the format in non-interactive mode. Currently, we do not ensure backward compatibility of utility commands.
+
+### TODO: compatibility with etcd server
+
+[etcd]: https://github.com/coreos/etcd
+[READMEv2]: READMEv2.md
+[v2key]: ../store/node_extern.go#L28-L37
+[v3key]: ../mvcc/mvccpb/kv.proto#L12-L29
+[etcdrpc]: ../etcdserver/etcdserverpb/rpc.proto
+[storagerpc]: ../mvcc/mvccpb/kv.proto
+[member_list_rpc]: ../etcdserver/etcdserverpb/rpc.proto#L493-L497
diff --git a/vendor/github.com/coreos/etcd/etcdctl/READMEv2.md b/vendor/github.com/coreos/etcd/etcdctl/READMEv2.md
new file mode 100644
index 00000000..5ee2329e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/READMEv2.md
@@ -0,0 +1,336 @@
+etcdctl
+========
+
+`etcdctl` is a command line client for [etcd][etcd].
+It can be used in scripts or for administrators to explore an etcd cluster.
+
+## Getting etcdctl
+
+The latest release is available as a binary at [Github][github-release] along with etcd.
+
+etcdctl can also be built from source using the build script found in the parent directory.
+
+## Configuration
+### --debug
++ output cURL commands which can be used to reproduce the request
+
+### --no-sync
++ don't synchronize cluster information before sending request
++ Use this to access non-published client endpoints
++ Without this flag, values from `--endpoint` flag will be overwritten by etcd cluster when it does internal sync.
+
+### --output, -o
++ output response in the given format (`simple`, `extended` or `json`)
++ default: `"simple"`
+
+### --discovery-srv, -D
++ domain name to query for SRV records describing cluster endpoints
++ default: none
++ env variable: ETCDCTL_DISCOVERY_SRV
+
+### --peers
++ a comma-delimited list of machine addresses in the cluster
++ default: `"http://127.0.0.1:2379"`
++ env variable: ETCDCTL_PEERS
+
+### --endpoint
++ a comma-delimited list of machine addresses in the cluster
++ default: `"http://127.0.0.1:2379"`
++ env variable: ETCDCTL_ENDPOINT
++ Without `--no-sync` flag, this will be overwritten by etcd cluster when it does internal sync.
+
+### --cert-file
++ identify HTTPS client using this SSL certificate file
++ default: none
++ env variable: ETCDCTL_CERT_FILE
+
+### --key-file
++ identify HTTPS client using this SSL key file
++ default: none
++ env variable: ETCDCTL_KEY_FILE
+
+### --ca-file
++ verify certificates of HTTPS-enabled servers using this CA bundle
++ default: none
++ env variable: ETCDCTL_CA_FILE
+
+### --username, -u
++ provide username[:password] and prompt if password is not supplied
++ default: none
++ env variable: ETCDCTL_USERNAME
+
+### --timeout
++ connection timeout per request
++ default: `"1s"`
+
+### --total-timeout
++ timeout for the command execution (except watch)
++ default: `"5s"`
+
+## Usage
+
+### Setting Key Values
+
+Set a value on the `/foo/bar` key:
+
+```sh
+$ etcdctl set /foo/bar "Hello world"
+Hello world
+```
+
+Set a value on the `/foo/bar` key with a value that expires in 60 seconds:
+
+```sh
+$ etcdctl set /foo/bar "Hello world" --ttl 60
+Hello world
+```
+
+Conditionally set a value on `/foo/bar` if the previous value was "Hello world":
+
+```sh
+$ etcdctl set /foo/bar "Goodbye world" --swap-with-value "Hello world"
+Goodbye world
+```
+
+Conditionally set a value on `/foo/bar` if the previous etcd index was 12:
+
+```sh
+$ etcdctl set /foo/bar "Goodbye world" --swap-with-index 12
+Goodbye world
+```
+
+Create a new key `/foo/bar`, only if the key did not previously exist:
+
+```sh
+$ etcdctl mk /foo/new_bar "Hello world"
+Hello world
+```
+
+Create a new in-order key under dir `/fooDir`:
+
+```sh
+$ etcdctl mk --in-order /fooDir "Hello world"
+```
+
+Create a new dir `/fooDir`, only if the key did not previously exist:
+
+```sh
+$ etcdctl mkdir /fooDir
+```
+
+Update an existing key `/foo/bar`, only if the key already existed:
+
+```sh
+$ etcdctl update /foo/bar "Hola mundo"
+Hola mundo
+```
+
+Create or update a directory called `/mydir`:
+
+```sh
+$ etcdctl setdir /mydir
+```
+
+
+### Retrieving a key value
+
+Get the current value for a single key in the local etcd node:
+
+```sh
+$ etcdctl get /foo/bar
+Hello world
+```
+
+Get the value of a key with additional metadata in a parseable format:
+
+```sh
+$ etcdctl -o extended get /foo/bar
+Key: /foo/bar
+Modified-Index: 72
+TTL: 0
+Etcd-Index: 72
+Raft-Index: 5611
+Raft-Term: 1
+
+Hello World
+```
+
+### Listing a directory
+
+Explore the keyspace using the `ls` command
+
+```sh
+$ etcdctl ls
+/akey
+/adir
+$ etcdctl ls /adir
+/adir/key1
+/adir/key2
+```
+
+Add `--recursive` to recursively list subdirectories encountered.
+
+```sh
+$ etcdctl ls --recursive
+/akey
+/adir
+/adir/key1
+/adir/key2
+```
+
+Directories can also have a trailing `/` added to output using `-p`.
+
+```sh
+$ etcdctl ls -p
+/akey
+/adir/
+```
+
+### Deleting a key
+
+Delete a key:
+
+```sh
+$ etcdctl rm /foo/bar
+```
+
+Delete an empty directory or a key-value pair
+
+```sh
+$ etcdctl rmdir /path/to/dir
+```
+
+or
+
+```sh
+$ etcdctl rm /path/to/dir --dir
+```
+
+Recursively delete a key and all child keys:
+
+```sh
+$ etcdctl rm /path/to/dir --recursive
+```
+
+Conditionally delete `/foo/bar` if the previous value was "Hello world":
+
+```sh
+$ etcdctl rm /foo/bar --with-value "Hello world"
+```
+
+Conditionally delete `/foo/bar` if the previous etcd index was 12:
+
+```sh
+$ etcdctl rm /foo/bar --with-index 12
+```
+
+### Watching for changes
+
+Watch for only the next change on a key:
+
+```sh
+$ etcdctl watch /foo/bar
+Hello world
+```
+
+Continuously watch a key:
+
+```sh
+$ etcdctl watch /foo/bar --forever
+Hello world
+.... client hangs forever until ctrl+C printing values as key change
+```
+
+Continuously watch a key, starting with a given etcd index:
+
+```sh
+$ etcdctl watch /foo/bar --forever --index 12
+Hello world
+.... client hangs forever until ctrl+C printing values as key change
+```
+
+Continuously watch a key and exec a program:
+
+```sh
+$ etcdctl exec-watch /foo/bar -- sh -c "env | grep ETCD"
+ETCD_WATCH_ACTION=set
+ETCD_WATCH_VALUE=My configuration stuff
+ETCD_WATCH_MODIFIED_INDEX=1999
+ETCD_WATCH_KEY=/foo/bar
+ETCD_WATCH_ACTION=set
+ETCD_WATCH_VALUE=My new configuration stuff
+ETCD_WATCH_MODIFIED_INDEX=2000
+ETCD_WATCH_KEY=/foo/bar
+```
+
+Continuously and recursively watch a key and exec a program:
+```sh
+$ etcdctl exec-watch --recursive /foo -- sh -c "env | grep ETCD"
+ETCD_WATCH_ACTION=set
+ETCD_WATCH_VALUE=My configuration stuff
+ETCD_WATCH_MODIFIED_INDEX=1999
+ETCD_WATCH_KEY=/foo/bar
+ETCD_WATCH_ACTION=set
+ETCD_WATCH_VALUE=My new configuration stuff
+ETCD_WATCH_MODIFIED_INDEX=2000
+ETCD_WATCH_KEY=/foo/barbar
+```
+
+## Return Codes
+
+The following exit codes can be returned from etcdctl:
+
+```
+0 Success
+1 Malformed etcdctl arguments
+2 Failed to connect to host
+3 Failed to auth (client cert rejected, ca validation failure, etc)
+4 400 error from etcd
+5 500 error from etcd
+```
+
+## Endpoint
+
+If the etcd cluster isn't available on `http://127.0.0.1:2379`, specify a `--endpoint` flag or `ETCDCTL_ENDPOINT` environment variable. One endpoint or a comma-separated list of endpoints can be listed. This option is ignored if the `--discovery-srv` option is provided.
+
+```sh
+ETCDCTL_ENDPOINT="http://10.0.28.1:4002" etcdctl set my-key to-a-value
+ETCDCTL_ENDPOINT="http://10.0.28.1:4002,http://10.0.28.2:4002,http://10.0.28.3:4002" etcdctl set my-key to-a-value
+etcdctl --endpoint http://10.0.28.1:4002 my-key to-a-value
+etcdctl --endpoint http://10.0.28.1:4002,http://10.0.28.2:4002,http://10.0.28.3:4002 etcdctl set my-key to-a-value
+```
+
+## Username and Password
+
+If the etcd cluster is protected by [authentication][authentication], specify username and password using the [`--username`][username-flag] or `ETCDCTL_USERNAME` environment variable. When `--username` flag or `ETCDCTL_USERNAME` environment variable doesn't contain password, etcdctl will prompt password in interactive mode.
+
+```sh
+ETCDCTL_USERNAME="root:password" etcdctl set my-key to-a-value
+```
+
+## DNS Discovery
+
+To discover the etcd cluster through domain SRV records, specify a `--discovery-srv` flag or `ETCDCTL_DISCOVERY_SRV` environment variable. This option takes precedence over the `--endpoint` flag.
+
+```sh
+ETCDCTL_DISCOVERY_SRV="some-domain" etcdctl set my-key to-a-value
+etcdctl --discovery-srv some-domain set my-key to-a-value
+```
+
+## Project Details
+
+### Versioning
+
+etcdctl uses [semantic versioning][semver].
+Releases will follow lockstep with the etcd release cycle.
+
+### License
+
+etcdctl is under the Apache 2.0 license. See the [LICENSE][license] file for details.
+
+[authentication]: ../Documentation/v2/authentication.md
+[etcd]: https://github.com/coreos/etcd
+[github-release]: https://github.com/coreos/etcd/releases/
+[license]: ../LICENSE
+[semver]: http://semver.org/
+[username-flag]: #--username--u
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/auth_commands.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/auth_commands.go
new file mode 100644
index 00000000..96a17738
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/auth_commands.go
@@ -0,0 +1,90 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "os"
+ "strings"
+
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+)
+
+func NewAuthCommands() cli.Command {
+ return cli.Command{
+ Name: "auth",
+ Usage: "overall auth controls",
+ Subcommands: []cli.Command{
+ {
+ Name: "enable",
+ Usage: "enable auth access controls",
+ ArgsUsage: " ",
+ Action: actionAuthEnable,
+ },
+ {
+ Name: "disable",
+ Usage: "disable auth access controls",
+ ArgsUsage: " ",
+ Action: actionAuthDisable,
+ },
+ },
+ }
+}
+
+func actionAuthEnable(c *cli.Context) error {
+ authEnableDisable(c, true)
+ return nil
+}
+
+func actionAuthDisable(c *cli.Context) error {
+ authEnableDisable(c, false)
+ return nil
+}
+
+func mustNewAuthAPI(c *cli.Context) client.AuthAPI {
+ hc := mustNewClient(c)
+
+ if c.GlobalBool("debug") {
+ fmt.Fprintf(os.Stderr, "Cluster-Endpoints: %s\n", strings.Join(hc.Endpoints(), ", "))
+ }
+
+ return client.NewAuthAPI(hc)
+}
+
+func authEnableDisable(c *cli.Context, enable bool) {
+ if len(c.Args()) != 0 {
+ fmt.Fprintln(os.Stderr, "No arguments accepted")
+ os.Exit(1)
+ }
+ s := mustNewAuthAPI(c)
+ ctx, cancel := contextWithTotalTimeout(c)
+ var err error
+ if enable {
+ err = s.Enable(ctx)
+ } else {
+ err = s.Disable(ctx)
+ }
+ cancel()
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+ if enable {
+ fmt.Println("Authentication Enabled")
+ } else {
+ fmt.Println("Authentication Disabled")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/backup_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/backup_command.go
new file mode 100644
index 00000000..feda4b19
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/backup_command.go
@@ -0,0 +1,118 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "log"
+ "path/filepath"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/fileutil"
+ "github.com/coreos/etcd/pkg/idutil"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/snap"
+ "github.com/coreos/etcd/wal"
+ "github.com/coreos/etcd/wal/walpb"
+ "github.com/urfave/cli"
+)
+
+func NewBackupCommand() cli.Command {
+ return cli.Command{
+ Name: "backup",
+ Usage: "backup an etcd directory",
+ ArgsUsage: " ",
+ Flags: []cli.Flag{
+ cli.StringFlag{Name: "data-dir", Value: "", Usage: "Path to the etcd data dir"},
+ cli.StringFlag{Name: "wal-dir", Value: "", Usage: "Path to the etcd wal dir"},
+ cli.StringFlag{Name: "backup-dir", Value: "", Usage: "Path to the backup dir"},
+ cli.StringFlag{Name: "backup-wal-dir", Value: "", Usage: "Path to the backup wal dir"},
+ },
+ Action: handleBackup,
+ }
+}
+
+// handleBackup handles a request that intends to do a backup.
+func handleBackup(c *cli.Context) error {
+ var srcWAL string
+ var destWAL string
+
+ srcSnap := filepath.Join(c.String("data-dir"), "member", "snap")
+ destSnap := filepath.Join(c.String("backup-dir"), "member", "snap")
+
+ if c.String("wal-dir") != "" {
+ srcWAL = c.String("wal-dir")
+ } else {
+ srcWAL = filepath.Join(c.String("data-dir"), "member", "wal")
+ }
+
+ if c.String("backup-wal-dir") != "" {
+ destWAL = c.String("backup-wal-dir")
+ } else {
+ destWAL = filepath.Join(c.String("backup-dir"), "member", "wal")
+ }
+
+ if err := fileutil.CreateDirAll(destSnap); err != nil {
+ log.Fatalf("failed creating backup snapshot dir %v: %v", destSnap, err)
+ }
+ ss := snap.New(srcSnap)
+ snapshot, err := ss.Load()
+ if err != nil && err != snap.ErrNoSnapshot {
+ log.Fatal(err)
+ }
+ var walsnap walpb.Snapshot
+ if snapshot != nil {
+ walsnap.Index, walsnap.Term = snapshot.Metadata.Index, snapshot.Metadata.Term
+ newss := snap.New(destSnap)
+ if err = newss.SaveSnap(*snapshot); err != nil {
+ log.Fatal(err)
+ }
+ }
+
+ w, err := wal.OpenForRead(srcWAL, walsnap)
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer w.Close()
+ wmetadata, state, ents, err := w.ReadAll()
+ switch err {
+ case nil:
+ case wal.ErrSnapshotNotFound:
+ fmt.Printf("Failed to find the match snapshot record %+v in wal %v.", walsnap, srcWAL)
+ fmt.Printf("etcdctl will add it back. Start auto fixing...")
+ default:
+ log.Fatal(err)
+ }
+ var metadata etcdserverpb.Metadata
+ pbutil.MustUnmarshal(&metadata, wmetadata)
+ idgen := idutil.NewGenerator(0, time.Now())
+ metadata.NodeID = idgen.Next()
+ metadata.ClusterID = idgen.Next()
+
+ neww, err := wal.Create(destWAL, pbutil.MustMarshal(&metadata))
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer neww.Close()
+ if err := neww.Save(state, ents); err != nil {
+ log.Fatal(err)
+ }
+ if err := neww.SaveSnapshot(walsnap); err != nil {
+ log.Fatal(err)
+ }
+
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/cluster_health.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/cluster_health.go
new file mode 100644
index 00000000..95101785
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/cluster_health.go
@@ -0,0 +1,137 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "encoding/json"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "os"
+ "os/signal"
+ "time"
+
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+ "golang.org/x/net/context"
+)
+
+func NewClusterHealthCommand() cli.Command {
+ return cli.Command{
+ Name: "cluster-health",
+ Usage: "check the health of the etcd cluster",
+ ArgsUsage: " ",
+ Flags: []cli.Flag{
+ cli.BoolFlag{Name: "forever, f", Usage: "forever check the health every 10 second until CTRL+C"},
+ },
+ Action: handleClusterHealth,
+ }
+}
+
+func handleClusterHealth(c *cli.Context) error {
+ forever := c.Bool("forever")
+ if forever {
+ sigch := make(chan os.Signal, 1)
+ signal.Notify(sigch, os.Interrupt)
+
+ go func() {
+ <-sigch
+ os.Exit(0)
+ }()
+ }
+
+ tr, err := getTransport(c)
+ if err != nil {
+ handleError(c, ExitServerError, err)
+ }
+
+ hc := http.Client{
+ Transport: tr,
+ }
+
+ cln := mustNewClientNoSync(c)
+ mi := client.NewMembersAPI(cln)
+ ms, err := mi.List(context.TODO())
+ if err != nil {
+ fmt.Println("cluster may be unhealthy: failed to list members")
+ handleError(c, ExitServerError, err)
+ }
+
+ for {
+ health := false
+ for _, m := range ms {
+ if len(m.ClientURLs) == 0 {
+ fmt.Printf("member %s is unreachable: no available published client urls\n", m.ID)
+ continue
+ }
+
+ checked := false
+ for _, url := range m.ClientURLs {
+ resp, err := hc.Get(url + "/health")
+ if err != nil {
+ fmt.Printf("failed to check the health of member %s on %s: %v\n", m.ID, url, err)
+ continue
+ }
+
+ result := struct{ Health string }{}
+ nresult := struct{ Health bool }{}
+ bytes, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ fmt.Printf("failed to check the health of member %s on %s: %v\n", m.ID, url, err)
+ continue
+ }
+ resp.Body.Close()
+
+ err = json.Unmarshal(bytes, &result)
+ if err != nil {
+ err = json.Unmarshal(bytes, &nresult)
+ }
+ if err != nil {
+ fmt.Printf("failed to check the health of member %s on %s: %v\n", m.ID, url, err)
+ continue
+ }
+
+ checked = true
+ if result.Health == "true" || nresult.Health {
+ health = true
+ fmt.Printf("member %s is healthy: got healthy result from %s\n", m.ID, url)
+ } else {
+ fmt.Printf("member %s is unhealthy: got unhealthy result from %s\n", m.ID, url)
+ }
+ break
+ }
+ if !checked {
+ fmt.Printf("member %s is unreachable: %v are all unreachable\n", m.ID, m.ClientURLs)
+ }
+ }
+ if health {
+ fmt.Println("cluster is healthy")
+ } else {
+ fmt.Println("cluster is unhealthy")
+ }
+
+ if !forever {
+ if health {
+ os.Exit(ExitSuccess)
+ return nil
+ }
+ os.Exit(ExitClusterNotHealthy)
+ return nil
+ }
+
+ fmt.Printf("\nnext check after 10 second...\n\n")
+ time.Sleep(10 * time.Second)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/doc.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/doc.go
new file mode 100644
index 00000000..cedf3f76
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command is a set of libraries for etcdctl commands.
+package command
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/error.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/error.go
new file mode 100644
index 00000000..e673fa39
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/error.go
@@ -0,0 +1,52 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "encoding/json"
+ "fmt"
+ "os"
+
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+)
+
+const (
+ ExitSuccess = iota
+ ExitBadArgs
+ ExitBadConnection
+ ExitBadAuth
+ ExitServerError
+ ExitClusterNotHealthy
+)
+
+func handleError(c *cli.Context, code int, err error) {
+ if c.GlobalString("output") == "json" {
+ if err, ok := err.(*client.Error); ok {
+ b, err := json.Marshal(err)
+ if err != nil {
+ panic(err)
+ }
+ fmt.Fprintln(os.Stderr, string(b))
+ os.Exit(code)
+ }
+ }
+
+ fmt.Fprintln(os.Stderr, "Error: ", err)
+ if cerr, ok := err.(*client.ClusterError); ok {
+ fmt.Fprintln(os.Stderr, cerr.Detail())
+ }
+ os.Exit(code)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/exec_watch_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/exec_watch_command.go
new file mode 100644
index 00000000..5ae24524
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/exec_watch_command.go
@@ -0,0 +1,128 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+ "fmt"
+ "os"
+ "os/exec"
+ "os/signal"
+
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+ "golang.org/x/net/context"
+)
+
+// NewExecWatchCommand returns the CLI command for "exec-watch".
+func NewExecWatchCommand() cli.Command {
+ return cli.Command{
+ Name: "exec-watch",
+ Usage: "watch a key for changes and exec an executable",
+ ArgsUsage: "<key> <command> [args...]",
+ Flags: []cli.Flag{
+ cli.IntFlag{Name: "after-index", Value: 0, Usage: "watch after the given index"},
+ cli.BoolFlag{Name: "recursive, r", Usage: "watch all values for key and child keys"},
+ },
+ Action: func(c *cli.Context) error {
+ execWatchCommandFunc(c, mustNewKeyAPI(c))
+ return nil
+ },
+ }
+}
+
+// execWatchCommandFunc executes the "exec-watch" command.
+func execWatchCommandFunc(c *cli.Context, ki client.KeysAPI) {
+ args := c.Args()
+ argslen := len(args)
+
+ if argslen < 2 {
+ handleError(c, ExitBadArgs, errors.New("key and command to exec required"))
+ }
+
+ var (
+ key string
+ cmdArgs []string
+ )
+
+ foundSep := false
+ for i := range args {
+ if args[i] == "--" && i != 0 {
+ foundSep = true
+ break
+ }
+ }
+
+ if foundSep {
+ key = args[0]
+ cmdArgs = args[2:]
+ } else {
+ // If no flag is parsed, the order of key and cmdArgs will be switched and
+ // args will not contain `--`.
+ key = args[argslen-1]
+ cmdArgs = args[:argslen-1]
+ }
+
+ index := 0
+ if c.Int("after-index") != 0 {
+ index = c.Int("after-index")
+ }
+
+ recursive := c.Bool("recursive")
+
+ sigch := make(chan os.Signal, 1)
+ signal.Notify(sigch, os.Interrupt)
+
+ go func() {
+ <-sigch
+ os.Exit(0)
+ }()
+
+ w := ki.Watcher(key, &client.WatcherOptions{AfterIndex: uint64(index), Recursive: recursive})
+
+ for {
+ resp, err := w.Next(context.TODO())
+ if err != nil {
+ handleError(c, ExitServerError, err)
+ }
+ if resp.Node.Dir {
+ fmt.Fprintf(os.Stderr, "Ignored dir %s change\n", resp.Node.Key)
+ continue
+ }
+
+ cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...)
+ cmd.Env = environResponse(resp, os.Environ())
+
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+
+ go func() {
+ err := cmd.Start()
+ if err != nil {
+ fmt.Fprintf(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+ cmd.Wait()
+ }()
+ }
+}
+
+func environResponse(resp *client.Response, env []string) []string {
+ env = append(env, "ETCD_WATCH_ACTION="+resp.Action)
+ env = append(env, "ETCD_WATCH_MODIFIED_INDEX="+fmt.Sprintf("%d", resp.Node.ModifiedIndex))
+ env = append(env, "ETCD_WATCH_KEY="+resp.Node.Key)
+ env = append(env, "ETCD_WATCH_VALUE="+resp.Node.Value)
+ return env
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/format.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/format.go
new file mode 100644
index 00000000..4a5d4a6a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/format.go
@@ -0,0 +1,60 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "encoding/json"
+ "fmt"
+ "os"
+
+ "github.com/coreos/etcd/client"
+)
+
+// printResponseKey only supports to print key correctly.
+func printResponseKey(resp *client.Response, format string) {
+ // Format the result.
+ switch format {
+ case "simple":
+ if resp.Action != "delete" {
+ fmt.Println(resp.Node.Value)
+ } else {
+ fmt.Println("PrevNode.Value:", resp.PrevNode.Value)
+ }
+ case "extended":
+ // Extended prints in a rfc2822 style format
+ fmt.Println("Key:", resp.Node.Key)
+ fmt.Println("Created-Index:", resp.Node.CreatedIndex)
+ fmt.Println("Modified-Index:", resp.Node.ModifiedIndex)
+
+ if resp.PrevNode != nil {
+ fmt.Println("PrevNode.Value:", resp.PrevNode.Value)
+ }
+
+ fmt.Println("TTL:", resp.Node.TTL)
+ fmt.Println("Index:", resp.Index)
+ if resp.Action != "delete" {
+ fmt.Println("")
+ fmt.Println(resp.Node.Value)
+ }
+ case "json":
+ b, err := json.Marshal(resp)
+ if err != nil {
+ panic(err)
+ }
+ fmt.Println(string(b))
+ default:
+ fmt.Fprintln(os.Stderr, "Unsupported output format:", format)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/get_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/get_command.go
new file mode 100644
index 00000000..7f1fc4db
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/get_command.go
@@ -0,0 +1,66 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+ "fmt"
+ "os"
+
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+)
+
+// NewGetCommand returns the CLI command for "get".
+func NewGetCommand() cli.Command {
+ return cli.Command{
+ Name: "get",
+ Usage: "retrieve the value of a key",
+ ArgsUsage: "<key>",
+ Flags: []cli.Flag{
+ cli.BoolFlag{Name: "sort", Usage: "returns result in sorted order"},
+ cli.BoolFlag{Name: "quorum, q", Usage: "require quorum for get request"},
+ },
+ Action: func(c *cli.Context) error {
+ getCommandFunc(c, mustNewKeyAPI(c))
+ return nil
+ },
+ }
+}
+
+// getCommandFunc executes the "get" command.
+func getCommandFunc(c *cli.Context, ki client.KeysAPI) {
+ if len(c.Args()) == 0 {
+ handleError(c, ExitBadArgs, errors.New("key required"))
+ }
+
+ key := c.Args()[0]
+ sorted := c.Bool("sort")
+ quorum := c.Bool("quorum")
+
+ ctx, cancel := contextWithTotalTimeout(c)
+ resp, err := ki.Get(ctx, key, &client.GetOptions{Sort: sorted, Quorum: quorum})
+ cancel()
+ if err != nil {
+ handleError(c, ExitServerError, err)
+ }
+
+ if resp.Node.Dir {
+ fmt.Fprintln(os.Stderr, fmt.Sprintf("%s: is a directory", resp.Node.Key))
+ os.Exit(1)
+ }
+
+ printResponseKey(resp, c.GlobalString("output"))
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/ls_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/ls_command.go
new file mode 100644
index 00000000..b2e94fb9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/ls_command.go
@@ -0,0 +1,90 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+)
+
+func NewLsCommand() cli.Command {
+ return cli.Command{
+ Name: "ls",
+ Usage: "retrieve a directory",
+ ArgsUsage: "[key]",
+ Flags: []cli.Flag{
+ cli.BoolFlag{Name: "sort", Usage: "returns result in sorted order"},
+ cli.BoolFlag{Name: "recursive, r", Usage: "returns all key names recursively for the given path"},
+ cli.BoolFlag{Name: "p", Usage: "append slash (/) to directories"},
+ cli.BoolFlag{Name: "quorum, q", Usage: "require quorum for get request"},
+ },
+ Action: func(c *cli.Context) error {
+ lsCommandFunc(c, mustNewKeyAPI(c))
+ return nil
+ },
+ }
+}
+
+// lsCommandFunc executes the "ls" command.
+func lsCommandFunc(c *cli.Context, ki client.KeysAPI) {
+ key := "/"
+ if len(c.Args()) != 0 {
+ key = c.Args()[0]
+ }
+
+ sort := c.Bool("sort")
+ recursive := c.Bool("recursive")
+ quorum := c.Bool("quorum")
+
+ ctx, cancel := contextWithTotalTimeout(c)
+ resp, err := ki.Get(ctx, key, &client.GetOptions{Sort: sort, Recursive: recursive, Quorum: quorum})
+ cancel()
+ if err != nil {
+ handleError(c, ExitServerError, err)
+ }
+
+ printLs(c, resp)
+}
+
+// printLs writes a response out in a manner similar to the `ls` command in unix.
+// Non-empty directories list their contents and files list their name.
+func printLs(c *cli.Context, resp *client.Response) {
+ if c.GlobalString("output") == "simple" {
+ if !resp.Node.Dir {
+ fmt.Println(resp.Node.Key)
+ }
+ for _, node := range resp.Node.Nodes {
+ rPrint(c, node)
+ }
+ } else {
+ // user wants JSON or extended output
+ printResponseKey(resp, c.GlobalString("output"))
+ }
+}
+
+// rPrint recursively prints out the nodes in the node structure.
+func rPrint(c *cli.Context, n *client.Node) {
+ if n.Dir && c.Bool("p") {
+ fmt.Println(fmt.Sprintf("%v/", n.Key))
+ } else {
+ fmt.Println(n.Key)
+ }
+
+ for _, node := range n.Nodes {
+ rPrint(c, node)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/member_commands.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/member_commands.go
new file mode 100644
index 00000000..84747873
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/member_commands.go
@@ -0,0 +1,207 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "os"
+ "strings"
+
+ "github.com/urfave/cli"
+)
+
+func NewMemberCommand() cli.Command {
+ return cli.Command{
+ Name: "member",
+ Usage: "member add, remove and list subcommands",
+ Subcommands: []cli.Command{
+ {
+ Name: "list",
+ Usage: "enumerate existing cluster members",
+ ArgsUsage: " ",
+ Action: actionMemberList,
+ },
+ {
+ Name: "add",
+ Usage: "add a new member to the etcd cluster",
+ ArgsUsage: "<name> <peerURL>",
+ Action: actionMemberAdd,
+ },
+ {
+ Name: "remove",
+ Usage: "remove an existing member from the etcd cluster",
+ ArgsUsage: "<memberID>",
+ Action: actionMemberRemove,
+ },
+ {
+ Name: "update",
+ Usage: "update an existing member in the etcd cluster",
+ ArgsUsage: "<memberID> <peerURLs>",
+ Action: actionMemberUpdate,
+ },
+ },
+ }
+}
+
+func actionMemberList(c *cli.Context) error {
+ if len(c.Args()) != 0 {
+ fmt.Fprintln(os.Stderr, "No arguments accepted")
+ os.Exit(1)
+ }
+ mAPI := mustNewMembersAPI(c)
+ ctx, cancel := contextWithTotalTimeout(c)
+ defer cancel()
+
+ members, err := mAPI.List(ctx)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+ leader, err := mAPI.Leader(ctx)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, "Failed to get leader: ", err)
+ os.Exit(1)
+ }
+
+ for _, m := range members {
+ isLeader := false
+ if m.ID == leader.ID {
+ isLeader = true
+ }
+ if len(m.Name) == 0 {
+ fmt.Printf("%s[unstarted]: peerURLs=%s\n", m.ID, strings.Join(m.PeerURLs, ","))
+ } else {
+ fmt.Printf("%s: name=%s peerURLs=%s clientURLs=%s isLeader=%v\n", m.ID, m.Name, strings.Join(m.PeerURLs, ","), strings.Join(m.ClientURLs, ","), isLeader)
+ }
+ }
+
+ return nil
+}
+
+func actionMemberAdd(c *cli.Context) error {
+ args := c.Args()
+ if len(args) != 2 {
+ fmt.Fprintln(os.Stderr, "Provide a name and a single member peerURL")
+ os.Exit(1)
+ }
+
+ mAPI := mustNewMembersAPI(c)
+
+ url := args[1]
+ ctx, cancel := contextWithTotalTimeout(c)
+ defer cancel()
+
+ m, err := mAPI.Add(ctx, url)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+
+ newID := m.ID
+ newName := args[0]
+ fmt.Printf("Added member named %s with ID %s to cluster\n", newName, newID)
+
+ members, err := mAPI.List(ctx)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+
+ conf := []string{}
+ for _, memb := range members {
+ for _, u := range memb.PeerURLs {
+ n := memb.Name
+ if memb.ID == newID {
+ n = newName
+ }
+ conf = append(conf, fmt.Sprintf("%s=%s", n, u))
+ }
+ }
+
+ fmt.Print("\n")
+ fmt.Printf("ETCD_NAME=%q\n", newName)
+ fmt.Printf("ETCD_INITIAL_CLUSTER=%q\n", strings.Join(conf, ","))
+ fmt.Printf("ETCD_INITIAL_CLUSTER_STATE=\"existing\"\n")
+ return nil
+}
+
+func actionMemberRemove(c *cli.Context) error {
+ args := c.Args()
+ if len(args) != 1 {
+ fmt.Fprintln(os.Stderr, "Provide a single member ID")
+ os.Exit(1)
+ }
+ removalID := args[0]
+
+ mAPI := mustNewMembersAPI(c)
+
+ ctx, cancel := contextWithTotalTimeout(c)
+ defer cancel()
+ // Get the list of members.
+ members, err := mAPI.List(ctx)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, "Error while verifying ID against known members:", err.Error())
+ os.Exit(1)
+ }
+ // Sanity check the input.
+ foundID := false
+ for _, m := range members {
+ if m.ID == removalID {
+ foundID = true
+ }
+ if m.Name == removalID {
+ // Note that, so long as it's not ambiguous, we *could* do the right thing by name here.
+ fmt.Fprintf(os.Stderr, "Found a member named %s; if this is correct, please use its ID, eg:\n\tetcdctl member remove %s\n", m.Name, m.ID)
+ fmt.Fprintf(os.Stderr, "For more details, read the documentation at https://github.com/coreos/etcd/blob/master/Documentation/runtime-configuration.md#remove-a-member\n\n")
+ }
+ }
+ if !foundID {
+ fmt.Fprintf(os.Stderr, "Couldn't find a member in the cluster with an ID of %s.\n", removalID)
+ os.Exit(1)
+ }
+
+ // Actually attempt to remove the member.
+ err = mAPI.Remove(ctx, removalID)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Received an error trying to remove member %s: %s", removalID, err.Error())
+ os.Exit(1)
+ }
+
+ fmt.Printf("Removed member %s from cluster\n", removalID)
+ return nil
+}
+
+func actionMemberUpdate(c *cli.Context) error {
+ args := c.Args()
+ if len(args) != 2 {
+ fmt.Fprintln(os.Stderr, "Provide an ID and a list of comma separated peerURL (0xabcd http://example.com,http://example1.com)")
+ os.Exit(1)
+ }
+
+ mAPI := mustNewMembersAPI(c)
+
+ mid := args[0]
+ urls := args[1]
+ ctx, cancel := contextWithTotalTimeout(c)
+ err := mAPI.Update(ctx, mid, strings.Split(urls, ","))
+ cancel()
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+
+ fmt.Printf("Updated member with ID %s in cluster\n", mid)
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/mk_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/mk_command.go
new file mode 100644
index 00000000..f6241535
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/mk_command.go
@@ -0,0 +1,76 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+ "os"
+ "time"
+
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+)
+
+// NewMakeCommand returns the CLI command for "mk".
+func NewMakeCommand() cli.Command {
+ return cli.Command{
+ Name: "mk",
+ Usage: "make a new key with a given value",
+ ArgsUsage: "<key> <value>",
+ Flags: []cli.Flag{
+ cli.BoolFlag{Name: "in-order", Usage: "create in-order key under directory <key>"},
+ cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live in seconds"},
+ },
+ Action: func(c *cli.Context) error {
+ mkCommandFunc(c, mustNewKeyAPI(c))
+ return nil
+ },
+ }
+}
+
+// mkCommandFunc executes the "mk" command.
+func mkCommandFunc(c *cli.Context, ki client.KeysAPI) {
+ if len(c.Args()) == 0 {
+ handleError(c, ExitBadArgs, errors.New("key required"))
+ }
+ key := c.Args()[0]
+ value, err := argOrStdin(c.Args(), os.Stdin, 1)
+ if err != nil {
+ handleError(c, ExitBadArgs, errors.New("value required"))
+ }
+
+ ttl := c.Int("ttl")
+ inorder := c.Bool("in-order")
+
+ var resp *client.Response
+ ctx, cancel := contextWithTotalTimeout(c)
+ if !inorder {
+ // Since PrevNoExist means that the Node must not exist previously,
+ // this Set method always creates a new key. Therefore, mk command
+ // succeeds only if the key did not previously exist, and the command
+ // prevents one from overwriting values accidentally.
+ resp, err = ki.Set(ctx, key, value, &client.SetOptions{TTL: time.Duration(ttl) * time.Second, PrevExist: client.PrevNoExist})
+ } else {
+ // If in-order flag is specified then create an inorder key under
+ // the directory identified by the key argument.
+ resp, err = ki.CreateInOrder(ctx, key, value, &client.CreateInOrderOptions{TTL: time.Duration(ttl) * time.Second})
+ }
+ cancel()
+ if err != nil {
+ handleError(c, ExitServerError, err)
+ }
+
+ printResponseKey(resp, c.GlobalString("output"))
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/mkdir_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/mkdir_command.go
new file mode 100644
index 00000000..1d17b7b9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/mkdir_command.go
@@ -0,0 +1,59 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+ "time"
+
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+)
+
+// NewMakeDirCommand returns the CLI command for "mkdir".
+func NewMakeDirCommand() cli.Command {
+ return cli.Command{
+ Name: "mkdir",
+ Usage: "make a new directory",
+ ArgsUsage: "<key>",
+ Flags: []cli.Flag{
+ cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live in seconds"},
+ },
+ Action: func(c *cli.Context) error {
+ mkdirCommandFunc(c, mustNewKeyAPI(c), client.PrevNoExist)
+ return nil
+ },
+ }
+}
+
+// mkdirCommandFunc executes the "mkdir" command.
+func mkdirCommandFunc(c *cli.Context, ki client.KeysAPI, prevExist client.PrevExistType) {
+ if len(c.Args()) == 0 {
+ handleError(c, ExitBadArgs, errors.New("key required"))
+ }
+
+ key := c.Args()[0]
+ ttl := c.Int("ttl")
+
+ ctx, cancel := contextWithTotalTimeout(c)
+ resp, err := ki.Set(ctx, key, "", &client.SetOptions{TTL: time.Duration(ttl) * time.Second, Dir: true, PrevExist: prevExist})
+ cancel()
+ if err != nil {
+ handleError(c, ExitServerError, err)
+ }
+ if c.GlobalString("output") != "simple" {
+ printResponseKey(resp, c.GlobalString("output"))
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/rm_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/rm_command.go
new file mode 100644
index 00000000..c6f173be
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/rm_command.go
@@ -0,0 +1,63 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+)
+
+// NewRemoveCommand returns the CLI command for "rm".
+func NewRemoveCommand() cli.Command {
+ return cli.Command{
+ Name: "rm",
+ Usage: "remove a key or a directory",
+ ArgsUsage: "<key>",
+ Flags: []cli.Flag{
+ cli.BoolFlag{Name: "dir", Usage: "removes the key if it is an empty directory or a key-value pair"},
+ cli.BoolFlag{Name: "recursive, r", Usage: "removes the key and all child keys(if it is a directory)"},
+ cli.StringFlag{Name: "with-value", Value: "", Usage: "previous value"},
+ cli.IntFlag{Name: "with-index", Value: 0, Usage: "previous index"},
+ },
+ Action: func(c *cli.Context) error {
+ rmCommandFunc(c, mustNewKeyAPI(c))
+ return nil
+ },
+ }
+}
+
+// rmCommandFunc executes the "rm" command.
+func rmCommandFunc(c *cli.Context, ki client.KeysAPI) {
+ if len(c.Args()) == 0 {
+ handleError(c, ExitBadArgs, errors.New("key required"))
+ }
+ key := c.Args()[0]
+ recursive := c.Bool("recursive")
+ dir := c.Bool("dir")
+ prevValue := c.String("with-value")
+ prevIndex := c.Int("with-index")
+
+ ctx, cancel := contextWithTotalTimeout(c)
+ resp, err := ki.Delete(ctx, key, &client.DeleteOptions{PrevIndex: uint64(prevIndex), PrevValue: prevValue, Dir: dir, Recursive: recursive})
+ cancel()
+ if err != nil {
+ handleError(c, ExitServerError, err)
+ }
+ if !resp.Node.Dir || c.GlobalString("output") != "simple" {
+ printResponseKey(resp, c.GlobalString("output"))
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/rmdir_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/rmdir_command.go
new file mode 100644
index 00000000..cb308954
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/rmdir_command.go
@@ -0,0 +1,54 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+)
+
+// NewRemoveDirCommand returns the CLI command for "rmdir".
+func NewRemoveDirCommand() cli.Command {
+ return cli.Command{
+ Name: "rmdir",
+ Usage: "removes the key if it is an empty directory or a key-value pair",
+ ArgsUsage: "<key>",
+ Action: func(c *cli.Context) error {
+ rmdirCommandFunc(c, mustNewKeyAPI(c))
+ return nil
+ },
+ }
+}
+
+// rmdirCommandFunc executes the "rmdir" command.
+func rmdirCommandFunc(c *cli.Context, ki client.KeysAPI) {
+ if len(c.Args()) == 0 {
+ handleError(c, ExitBadArgs, errors.New("key required"))
+ }
+ key := c.Args()[0]
+
+ ctx, cancel := contextWithTotalTimeout(c)
+ resp, err := ki.Delete(ctx, key, &client.DeleteOptions{Dir: true})
+ cancel()
+ if err != nil {
+ handleError(c, ExitServerError, err)
+ }
+
+ if !resp.Node.Dir || c.GlobalString("output") != "simple" {
+ printResponseKey(resp, c.GlobalString("output"))
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/role_commands.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/role_commands.go
new file mode 100644
index 00000000..838b0406
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/role_commands.go
@@ -0,0 +1,255 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "os"
+ "reflect"
+ "strings"
+
+ "github.com/coreos/etcd/client"
+ "github.com/coreos/etcd/pkg/pathutil"
+ "github.com/urfave/cli"
+)
+
+func NewRoleCommands() cli.Command {
+ return cli.Command{
+ Name: "role",
+ Usage: "role add, grant and revoke subcommands",
+ Subcommands: []cli.Command{
+ {
+ Name: "add",
+ Usage: "add a new role for the etcd cluster",
+ ArgsUsage: "<role> ",
+ Action: actionRoleAdd,
+ },
+ {
+ Name: "get",
+ Usage: "get details for a role",
+ ArgsUsage: "<role>",
+ Action: actionRoleGet,
+ },
+ {
+ Name: "list",
+ Usage: "list all roles",
+ ArgsUsage: " ",
+ Action: actionRoleList,
+ },
+ {
+ Name: "remove",
+ Usage: "remove a role from the etcd cluster",
+ ArgsUsage: "<role>",
+ Action: actionRoleRemove,
+ },
+ {
+ Name: "grant",
+ Usage: "grant path matches to an etcd role",
+ ArgsUsage: "<role>",
+ Flags: []cli.Flag{
+ cli.StringFlag{Name: "path", Value: "", Usage: "Path granted for the role to access"},
+ cli.BoolFlag{Name: "read", Usage: "Grant read-only access"},
+ cli.BoolFlag{Name: "write", Usage: "Grant write-only access"},
+ cli.BoolFlag{Name: "readwrite, rw", Usage: "Grant read-write access"},
+ },
+ Action: actionRoleGrant,
+ },
+ {
+ Name: "revoke",
+ Usage: "revoke path matches for an etcd role",
+ ArgsUsage: "<role>",
+ Flags: []cli.Flag{
+ cli.StringFlag{Name: "path", Value: "", Usage: "Path revoked for the role to access"},
+ cli.BoolFlag{Name: "read", Usage: "Revoke read access"},
+ cli.BoolFlag{Name: "write", Usage: "Revoke write access"},
+ cli.BoolFlag{Name: "readwrite, rw", Usage: "Revoke read-write access"},
+ },
+ Action: actionRoleRevoke,
+ },
+ },
+ }
+}
+
+func mustNewAuthRoleAPI(c *cli.Context) client.AuthRoleAPI {
+ hc := mustNewClient(c)
+
+ if c.GlobalBool("debug") {
+ fmt.Fprintf(os.Stderr, "Cluster-Endpoints: %s\n", strings.Join(hc.Endpoints(), ", "))
+ }
+
+ return client.NewAuthRoleAPI(hc)
+}
+
+func actionRoleList(c *cli.Context) error {
+ if len(c.Args()) != 0 {
+ fmt.Fprintln(os.Stderr, "No arguments accepted")
+ os.Exit(1)
+ }
+ r := mustNewAuthRoleAPI(c)
+ ctx, cancel := contextWithTotalTimeout(c)
+ roles, err := r.ListRoles(ctx)
+ cancel()
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+
+ for _, role := range roles {
+ fmt.Printf("%s\n", role)
+ }
+
+ return nil
+}
+
+func actionRoleAdd(c *cli.Context) error {
+ api, role := mustRoleAPIAndName(c)
+ ctx, cancel := contextWithTotalTimeout(c)
+ defer cancel()
+ currentRole, _ := api.GetRole(ctx, role)
+ if currentRole != nil {
+ fmt.Fprintf(os.Stderr, "Role %s already exists\n", role)
+ os.Exit(1)
+ }
+
+ err := api.AddRole(ctx, role)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+
+ fmt.Printf("Role %s created\n", role)
+ return nil
+}
+
+func actionRoleRemove(c *cli.Context) error {
+ api, role := mustRoleAPIAndName(c)
+ ctx, cancel := contextWithTotalTimeout(c)
+ err := api.RemoveRole(ctx, role)
+ cancel()
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+
+ fmt.Printf("Role %s removed\n", role)
+ return nil
+}
+
+func actionRoleGrant(c *cli.Context) error {
+ roleGrantRevoke(c, true)
+ return nil
+}
+
+func actionRoleRevoke(c *cli.Context) error {
+ roleGrantRevoke(c, false)
+ return nil
+}
+
+func roleGrantRevoke(c *cli.Context, grant bool) {
+ path := c.String("path")
+ if path == "" {
+ fmt.Fprintln(os.Stderr, "No path specified; please use `--path`")
+ os.Exit(1)
+ }
+ if pathutil.CanonicalURLPath(path) != path {
+ fmt.Fprintf(os.Stderr, "Not canonical path; please use `--path=%s`\n", pathutil.CanonicalURLPath(path))
+ os.Exit(1)
+ }
+
+ read := c.Bool("read")
+ write := c.Bool("write")
+ rw := c.Bool("readwrite")
+ permcount := 0
+ for _, v := range []bool{read, write, rw} {
+ if v {
+ permcount++
+ }
+ }
+ if permcount != 1 {
+ fmt.Fprintln(os.Stderr, "Please specify exactly one of --read, --write or --readwrite")
+ os.Exit(1)
+ }
+ var permType client.PermissionType
+ switch {
+ case read:
+ permType = client.ReadPermission
+ case write:
+ permType = client.WritePermission
+ case rw:
+ permType = client.ReadWritePermission
+ }
+
+ api, role := mustRoleAPIAndName(c)
+ ctx, cancel := contextWithTotalTimeout(c)
+ defer cancel()
+ currentRole, err := api.GetRole(ctx, role)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+ var newRole *client.Role
+ if grant {
+ newRole, err = api.GrantRoleKV(ctx, role, []string{path}, permType)
+ } else {
+ newRole, err = api.RevokeRoleKV(ctx, role, []string{path}, permType)
+ }
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+ if reflect.DeepEqual(newRole, currentRole) {
+ if grant {
+ fmt.Printf("Role unchanged; already granted")
+ } else {
+ fmt.Printf("Role unchanged; already revoked")
+ }
+ }
+
+ fmt.Printf("Role %s updated\n", role)
+}
+
+func actionRoleGet(c *cli.Context) error {
+ api, rolename := mustRoleAPIAndName(c)
+
+ ctx, cancel := contextWithTotalTimeout(c)
+ role, err := api.GetRole(ctx, rolename)
+ cancel()
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+ fmt.Printf("Role: %s\n", role.Role)
+ fmt.Printf("KV Read:\n")
+ for _, v := range role.Permissions.KV.Read {
+ fmt.Printf("\t%s\n", v)
+ }
+ fmt.Printf("KV Write:\n")
+ for _, v := range role.Permissions.KV.Write {
+ fmt.Printf("\t%s\n", v)
+ }
+ return nil
+}
+
+func mustRoleAPIAndName(c *cli.Context) (client.AuthRoleAPI, string) {
+ args := c.Args()
+ if len(args) != 1 {
+ fmt.Fprintln(os.Stderr, "Please provide a role name")
+ os.Exit(1)
+ }
+
+ name := args[0]
+ api := mustNewAuthRoleAPI(c)
+ return api, name
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/set_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/set_command.go
new file mode 100644
index 00000000..f7bb6bd5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/set_command.go
@@ -0,0 +1,73 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+ "os"
+ "time"
+
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+)
+
+// NewSetCommand returns the CLI command for "set".
+func NewSetCommand() cli.Command {
+ return cli.Command{
+ Name: "set",
+ Usage: "set the value of a key",
+ ArgsUsage: "<key> <value>",
+ Description: `Set sets the value of a key.
+
+ When <value> begins with '-', <value> is interpreted as a flag.
+ Insert '--' for workaround:
+
+ $ set -- <key> <value>`,
+ Flags: []cli.Flag{
+ cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live in seconds"},
+ cli.StringFlag{Name: "swap-with-value", Value: "", Usage: "previous value"},
+ cli.IntFlag{Name: "swap-with-index", Value: 0, Usage: "previous index"},
+ },
+ Action: func(c *cli.Context) error {
+ setCommandFunc(c, mustNewKeyAPI(c))
+ return nil
+ },
+ }
+}
+
+// setCommandFunc executes the "set" command.
+func setCommandFunc(c *cli.Context, ki client.KeysAPI) {
+ if len(c.Args()) == 0 {
+ handleError(c, ExitBadArgs, errors.New("key required"))
+ }
+ key := c.Args()[0]
+ value, err := argOrStdin(c.Args(), os.Stdin, 1)
+ if err != nil {
+ handleError(c, ExitBadArgs, errors.New("value required"))
+ }
+
+ ttl := c.Int("ttl")
+ prevValue := c.String("swap-with-value")
+ prevIndex := c.Int("swap-with-index")
+
+ ctx, cancel := contextWithTotalTimeout(c)
+ resp, err := ki.Set(ctx, key, value, &client.SetOptions{TTL: time.Duration(ttl) * time.Second, PrevIndex: uint64(prevIndex), PrevValue: prevValue})
+ cancel()
+ if err != nil {
+ handleError(c, ExitServerError, err)
+ }
+
+ printResponseKey(resp, c.GlobalString("output"))
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/set_dir_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/set_dir_command.go
new file mode 100644
index 00000000..aba66b08
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/set_dir_command.go
@@ -0,0 +1,36 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+)
+
+// NewSetDirCommand returns the CLI command for "setDir".
+func NewSetDirCommand() cli.Command {
+ return cli.Command{
+ Name: "setdir",
+ Usage: "create a new directory or update an existing directory TTL",
+ ArgsUsage: "<key>",
+ Flags: []cli.Flag{
+ cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live in seconds"},
+ },
+ Action: func(c *cli.Context) error {
+ mkdirCommandFunc(c, mustNewKeyAPI(c), client.PrevIgnore)
+ return nil
+ },
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/update_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/update_command.go
new file mode 100644
index 00000000..ed422489
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/update_command.go
@@ -0,0 +1,63 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+ "os"
+ "time"
+
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+)
+
+// NewUpdateCommand returns the CLI command for "update".
+func NewUpdateCommand() cli.Command {
+ return cli.Command{
+ Name: "update",
+ Usage: "update an existing key with a given value",
+ ArgsUsage: "<key> <value>",
+ Flags: []cli.Flag{
+ cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live in seconds"},
+ },
+ Action: func(c *cli.Context) error {
+ updateCommandFunc(c, mustNewKeyAPI(c))
+ return nil
+ },
+ }
+}
+
+// updateCommandFunc executes the "update" command.
+func updateCommandFunc(c *cli.Context, ki client.KeysAPI) {
+ if len(c.Args()) == 0 {
+ handleError(c, ExitBadArgs, errors.New("key required"))
+ }
+ key := c.Args()[0]
+ value, err := argOrStdin(c.Args(), os.Stdin, 1)
+ if err != nil {
+ handleError(c, ExitBadArgs, errors.New("value required"))
+ }
+
+ ttl := c.Int("ttl")
+
+ ctx, cancel := contextWithTotalTimeout(c)
+ resp, err := ki.Set(ctx, key, value, &client.SetOptions{TTL: time.Duration(ttl) * time.Second, PrevExist: client.PrevExist})
+ cancel()
+ if err != nil {
+ handleError(c, ExitServerError, err)
+ }
+
+ printResponseKey(resp, c.GlobalString("output"))
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/update_dir_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/update_dir_command.go
new file mode 100644
index 00000000..72411dfb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/update_dir_command.go
@@ -0,0 +1,57 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+ "time"
+
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+)
+
+// NewUpdateDirCommand returns the CLI command for "updatedir".
+func NewUpdateDirCommand() cli.Command {
+ return cli.Command{
+ Name: "updatedir",
+ Usage: "update an existing directory",
+ ArgsUsage: "<key> <value>",
+ Flags: []cli.Flag{
+ cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live in seconds"},
+ },
+ Action: func(c *cli.Context) error {
+ updatedirCommandFunc(c, mustNewKeyAPI(c))
+ return nil
+ },
+ }
+}
+
+// updatedirCommandFunc executes the "updatedir" command.
+func updatedirCommandFunc(c *cli.Context, ki client.KeysAPI) {
+ if len(c.Args()) == 0 {
+ handleError(c, ExitBadArgs, errors.New("key required"))
+ }
+ key := c.Args()[0]
+ ttl := c.Int("ttl")
+ ctx, cancel := contextWithTotalTimeout(c)
+ resp, err := ki.Set(ctx, key, "", &client.SetOptions{TTL: time.Duration(ttl) * time.Second, Dir: true, PrevExist: client.PrevExist})
+ cancel()
+ if err != nil {
+ handleError(c, ExitServerError, err)
+ }
+ if c.GlobalString("output") != "simple" {
+ printResponseKey(resp, c.GlobalString("output"))
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/user_commands.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/user_commands.go
new file mode 100644
index 00000000..c0fb900b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/user_commands.go
@@ -0,0 +1,225 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "os"
+ "strings"
+
+ "github.com/bgentry/speakeasy"
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+)
+
+func NewUserCommands() cli.Command {
+ return cli.Command{
+ Name: "user",
+ Usage: "user add, grant and revoke subcommands",
+ Subcommands: []cli.Command{
+ {
+ Name: "add",
+ Usage: "add a new user for the etcd cluster",
+ ArgsUsage: "<user>",
+ Action: actionUserAdd,
+ },
+ {
+ Name: "get",
+ Usage: "get details for a user",
+ ArgsUsage: "<user>",
+ Action: actionUserGet,
+ },
+ {
+ Name: "list",
+ Usage: "list all current users",
+ ArgsUsage: "<user>",
+ Action: actionUserList,
+ },
+ {
+ Name: "remove",
+ Usage: "remove a user for the etcd cluster",
+ ArgsUsage: "<user>",
+ Action: actionUserRemove,
+ },
+ {
+ Name: "grant",
+ Usage: "grant roles to an etcd user",
+ ArgsUsage: "<user>",
+ Flags: []cli.Flag{cli.StringSliceFlag{Name: "roles", Value: new(cli.StringSlice), Usage: "List of roles to grant or revoke"}},
+ Action: actionUserGrant,
+ },
+ {
+ Name: "revoke",
+ Usage: "revoke roles for an etcd user",
+ ArgsUsage: "<user>",
+ Flags: []cli.Flag{cli.StringSliceFlag{Name: "roles", Value: new(cli.StringSlice), Usage: "List of roles to grant or revoke"}},
+ Action: actionUserRevoke,
+ },
+ {
+ Name: "passwd",
+ Usage: "change password for a user",
+ ArgsUsage: "<user>",
+ Action: actionUserPasswd,
+ },
+ },
+ }
+}
+
+func mustNewAuthUserAPI(c *cli.Context) client.AuthUserAPI {
+ hc := mustNewClient(c)
+
+ if c.GlobalBool("debug") {
+ fmt.Fprintf(os.Stderr, "Cluster-Endpoints: %s\n", strings.Join(hc.Endpoints(), ", "))
+ }
+
+ return client.NewAuthUserAPI(hc)
+}
+
+func actionUserList(c *cli.Context) error {
+ if len(c.Args()) != 0 {
+ fmt.Fprintln(os.Stderr, "No arguments accepted")
+ os.Exit(1)
+ }
+ u := mustNewAuthUserAPI(c)
+ ctx, cancel := contextWithTotalTimeout(c)
+ users, err := u.ListUsers(ctx)
+ cancel()
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+
+ for _, user := range users {
+ fmt.Printf("%s\n", user)
+ }
+ return nil
+}
+
+func actionUserAdd(c *cli.Context) error {
+ api, userarg := mustUserAPIAndName(c)
+ ctx, cancel := contextWithTotalTimeout(c)
+ defer cancel()
+ user, _, _ := getUsernamePassword("", userarg+":")
+
+ _, pass, err := getUsernamePassword("New password: ", userarg)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, "Error reading password:", err)
+ os.Exit(1)
+ }
+ err = api.AddUser(ctx, user, pass)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+
+ fmt.Printf("User %s created\n", user)
+ return nil
+}
+
+func actionUserRemove(c *cli.Context) error {
+ api, user := mustUserAPIAndName(c)
+ ctx, cancel := contextWithTotalTimeout(c)
+ err := api.RemoveUser(ctx, user)
+ cancel()
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+
+ fmt.Printf("User %s removed\n", user)
+ return nil
+}
+
+func actionUserPasswd(c *cli.Context) error {
+ api, user := mustUserAPIAndName(c)
+ ctx, cancel := contextWithTotalTimeout(c)
+ defer cancel()
+ pass, err := speakeasy.Ask("New password: ")
+ if err != nil {
+ fmt.Fprintln(os.Stderr, "Error reading password:", err)
+ os.Exit(1)
+ }
+
+ _, err = api.ChangePassword(ctx, user, pass)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+
+ fmt.Printf("Password updated\n")
+ return nil
+}
+
+func actionUserGrant(c *cli.Context) error {
+ userGrantRevoke(c, true)
+ return nil
+}
+
+func actionUserRevoke(c *cli.Context) error {
+ userGrantRevoke(c, false)
+ return nil
+}
+
+func userGrantRevoke(c *cli.Context, grant bool) {
+ roles := c.StringSlice("roles")
+ if len(roles) == 0 {
+ fmt.Fprintln(os.Stderr, "No roles specified; please use `--roles`")
+ os.Exit(1)
+ }
+
+ ctx, cancel := contextWithTotalTimeout(c)
+ defer cancel()
+
+ api, user := mustUserAPIAndName(c)
+ var err error
+ if grant {
+ _, err = api.GrantUser(ctx, user, roles)
+ } else {
+ _, err = api.RevokeUser(ctx, user, roles)
+ }
+
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+
+ fmt.Printf("User %s updated\n", user)
+}
+
+func actionUserGet(c *cli.Context) error {
+ api, username := mustUserAPIAndName(c)
+ ctx, cancel := contextWithTotalTimeout(c)
+ user, err := api.GetUser(ctx, username)
+ cancel()
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+ fmt.Printf("User: %s\n", user.User)
+ fmt.Printf("Roles: %s\n", strings.Join(user.Roles, " "))
+ return nil
+}
+
+func mustUserAPIAndName(c *cli.Context) (client.AuthUserAPI, string) {
+ args := c.Args()
+ if len(args) != 1 {
+ fmt.Fprintln(os.Stderr, "Please provide a username")
+ os.Exit(1)
+ }
+
+ api := mustNewAuthUserAPI(c)
+ username := args[0]
+ return api, username
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/util.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/util.go
new file mode 100644
index 00000000..d6a58145
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/util.go
@@ -0,0 +1,336 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "net"
+ "net/http"
+ "net/url"
+ "os"
+ "strings"
+ "syscall"
+ "time"
+
+ "github.com/bgentry/speakeasy"
+ "github.com/coreos/etcd/client"
+ "github.com/coreos/etcd/pkg/transport"
+ "github.com/urfave/cli"
+ "golang.org/x/net/context"
+)
+
+var (
+ ErrNoAvailSrc = errors.New("no available argument and stdin")
+
+ // the maximum amount of time a dial will wait for a connection to setup.
+ // 30s is long enough for most of the network conditions.
+ defaultDialTimeout = 30 * time.Second
+)
+
+func argOrStdin(args []string, stdin io.Reader, i int) (string, error) {
+ if i < len(args) {
+ return args[i], nil
+ }
+ bytes, err := ioutil.ReadAll(stdin)
+ if string(bytes) == "" || err != nil {
+ return "", ErrNoAvailSrc
+ }
+ return string(bytes), nil
+}
+
+func getPeersFlagValue(c *cli.Context) []string {
+ peerstr := c.GlobalString("endpoints")
+
+ if peerstr == "" {
+ peerstr = os.Getenv("ETCDCTL_ENDPOINTS")
+ }
+
+ if peerstr == "" {
+ peerstr = c.GlobalString("endpoint")
+ }
+
+ if peerstr == "" {
+ peerstr = os.Getenv("ETCDCTL_ENDPOINT")
+ }
+
+ if peerstr == "" {
+ peerstr = c.GlobalString("peers")
+ }
+
+ if peerstr == "" {
+ peerstr = os.Getenv("ETCDCTL_PEERS")
+ }
+
+ // If we still don't have peers, use a default
+ if peerstr == "" {
+ peerstr = "http://127.0.0.1:2379,http://127.0.0.1:4001"
+ }
+
+ return strings.Split(peerstr, ",")
+}
+
+func getDomainDiscoveryFlagValue(c *cli.Context) ([]string, error) {
+ domainstr, insecure := getDiscoveryDomain(c)
+
+ // If we still don't have domain discovery, return nothing
+ if domainstr == "" {
+ return []string{}, nil
+ }
+
+ discoverer := client.NewSRVDiscover()
+ eps, err := discoverer.Discover(domainstr)
+ if err != nil {
+ return nil, err
+ }
+ if insecure {
+ return eps, err
+ }
+ // strip insecure connections
+ ret := []string{}
+ for _, ep := range eps {
+ if strings.HasPrefix("http://", ep) {
+ fmt.Fprintf(os.Stderr, "ignoring discovered insecure endpoint %q\n", ep)
+ continue
+ }
+ ret = append(ret, ep)
+ }
+ return ret, err
+}
+
+func getDiscoveryDomain(c *cli.Context) (domainstr string, insecure bool) {
+ domainstr = c.GlobalString("discovery-srv")
+ // Use an environment variable if nothing was supplied on the
+ // command line
+ if domainstr == "" {
+ domainstr = os.Getenv("ETCDCTL_DISCOVERY_SRV")
+ }
+ insecure = c.GlobalBool("insecure-discovery") || (os.Getenv("ETCDCTL_INSECURE_DISCOVERY") != "")
+ return domainstr, insecure
+}
+
+func getEndpoints(c *cli.Context) ([]string, error) {
+ eps, err := getDomainDiscoveryFlagValue(c)
+ if err != nil {
+ return nil, err
+ }
+
+ // If domain discovery returns no endpoints, check peer flag
+ if len(eps) == 0 {
+ eps = getPeersFlagValue(c)
+ }
+
+ for i, ep := range eps {
+ u, err := url.Parse(ep)
+ if err != nil {
+ return nil, err
+ }
+
+ if u.Scheme == "" {
+ u.Scheme = "http"
+ }
+
+ eps[i] = u.String()
+ }
+
+ return eps, nil
+}
+
+func getTransport(c *cli.Context) (*http.Transport, error) {
+ cafile := c.GlobalString("ca-file")
+ certfile := c.GlobalString("cert-file")
+ keyfile := c.GlobalString("key-file")
+
+ // Use an environment variable if nothing was supplied on the
+ // command line
+ if cafile == "" {
+ cafile = os.Getenv("ETCDCTL_CA_FILE")
+ }
+ if certfile == "" {
+ certfile = os.Getenv("ETCDCTL_CERT_FILE")
+ }
+ if keyfile == "" {
+ keyfile = os.Getenv("ETCDCTL_KEY_FILE")
+ }
+
+ discoveryDomain, insecure := getDiscoveryDomain(c)
+ if insecure {
+ discoveryDomain = ""
+ }
+ tls := transport.TLSInfo{
+ CAFile: cafile,
+ CertFile: certfile,
+ KeyFile: keyfile,
+ ServerName: discoveryDomain,
+ }
+
+ dialTimeout := defaultDialTimeout
+ totalTimeout := c.GlobalDuration("total-timeout")
+ if totalTimeout != 0 && totalTimeout < dialTimeout {
+ dialTimeout = totalTimeout
+ }
+ return transport.NewTransport(tls, dialTimeout)
+}
+
+func getUsernamePasswordFromFlag(usernameFlag string) (username string, password string, err error) {
+ return getUsernamePassword("Password: ", usernameFlag)
+}
+
+func getUsernamePassword(prompt, usernameFlag string) (username string, password string, err error) {
+ colon := strings.Index(usernameFlag, ":")
+ if colon == -1 {
+ username = usernameFlag
+ // Prompt for the password.
+ password, err = speakeasy.Ask(prompt)
+ if err != nil {
+ return "", "", err
+ }
+ } else {
+ username = usernameFlag[:colon]
+ password = usernameFlag[colon+1:]
+ }
+ return username, password, nil
+}
+
+func mustNewKeyAPI(c *cli.Context) client.KeysAPI {
+ return client.NewKeysAPI(mustNewClient(c))
+}
+
+func mustNewMembersAPI(c *cli.Context) client.MembersAPI {
+ return client.NewMembersAPI(mustNewClient(c))
+}
+
+func mustNewClient(c *cli.Context) client.Client {
+ hc, err := newClient(c)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+
+ debug := c.GlobalBool("debug")
+ if debug {
+ client.EnablecURLDebug()
+ }
+
+ if !c.GlobalBool("no-sync") {
+ if debug {
+ fmt.Fprintf(os.Stderr, "start to sync cluster using endpoints(%s)\n", strings.Join(hc.Endpoints(), ","))
+ }
+ ctx, cancel := contextWithTotalTimeout(c)
+ err := hc.Sync(ctx)
+ cancel()
+ if err != nil {
+ if err == client.ErrNoEndpoints {
+ fmt.Fprintf(os.Stderr, "etcd cluster has no published client endpoints.\n")
+ fmt.Fprintf(os.Stderr, "Try '--no-sync' if you want to access non-published client endpoints(%s).\n", strings.Join(hc.Endpoints(), ","))
+ handleError(c, ExitServerError, err)
+ }
+ if isConnectionError(err) {
+ handleError(c, ExitBadConnection, err)
+ }
+ }
+ if debug {
+ fmt.Fprintf(os.Stderr, "got endpoints(%s) after sync\n", strings.Join(hc.Endpoints(), ","))
+ }
+ }
+
+ if debug {
+ fmt.Fprintf(os.Stderr, "Cluster-Endpoints: %s\n", strings.Join(hc.Endpoints(), ", "))
+ }
+
+ return hc
+}
+
+func isConnectionError(err error) bool {
+ switch t := err.(type) {
+ case *client.ClusterError:
+ for _, cerr := range t.Errors {
+ if !isConnectionError(cerr) {
+ return false
+ }
+ }
+ return true
+ case *net.OpError:
+ if t.Op == "dial" || t.Op == "read" {
+ return true
+ }
+ return isConnectionError(t.Err)
+ case net.Error:
+ if t.Timeout() {
+ return true
+ }
+ case syscall.Errno:
+ if t == syscall.ECONNREFUSED {
+ return true
+ }
+ }
+ return false
+}
+
+func mustNewClientNoSync(c *cli.Context) client.Client {
+ hc, err := newClient(c)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+
+ if c.GlobalBool("debug") {
+ fmt.Fprintf(os.Stderr, "Cluster-Endpoints: %s\n", strings.Join(hc.Endpoints(), ", "))
+ client.EnablecURLDebug()
+ }
+
+ return hc
+}
+
+func newClient(c *cli.Context) (client.Client, error) {
+ eps, err := getEndpoints(c)
+ if err != nil {
+ return nil, err
+ }
+
+ tr, err := getTransport(c)
+ if err != nil {
+ return nil, err
+ }
+
+ cfg := client.Config{
+ Transport: tr,
+ Endpoints: eps,
+ HeaderTimeoutPerRequest: c.GlobalDuration("timeout"),
+ }
+
+ uFlag := c.GlobalString("username")
+
+ if uFlag == "" {
+ uFlag = os.Getenv("ETCDCTL_USERNAME")
+ }
+
+ if uFlag != "" {
+ username, password, err := getUsernamePasswordFromFlag(uFlag)
+ if err != nil {
+ return nil, err
+ }
+ cfg.Username = username
+ cfg.Password = password
+ }
+
+ return client.New(cfg)
+}
+
+func contextWithTotalTimeout(c *cli.Context) (context.Context, context.CancelFunc) {
+ return context.WithTimeout(context.Background(), c.GlobalDuration("total-timeout"))
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/util_test.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/util_test.go
new file mode 100644
index 00000000..7f9bed8d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/util_test.go
@@ -0,0 +1,70 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "bytes"
+ "testing"
+)
+
+func TestArgOrStdin(t *testing.T) {
+ tests := []struct {
+ args []string
+ stdin string
+ i int
+ w string
+ we error
+ }{
+ {
+ args: []string{
+ "a",
+ },
+ stdin: "b",
+ i: 0,
+ w: "a",
+ we: nil,
+ },
+ {
+ args: []string{
+ "a",
+ },
+ stdin: "b",
+ i: 1,
+ w: "b",
+ we: nil,
+ },
+ {
+ args: []string{
+ "a",
+ },
+ stdin: "",
+ i: 1,
+ w: "",
+ we: ErrNoAvailSrc,
+ },
+ }
+
+ for i, tt := range tests {
+ var b bytes.Buffer
+ b.Write([]byte(tt.stdin))
+ g, ge := argOrStdin(tt.args, &b, tt.i)
+ if g != tt.w {
+ t.Errorf("#%d: expect %v, not %v", i, tt.w, g)
+ }
+ if ge != tt.we {
+ t.Errorf("#%d: expect %v, not %v", i, tt.we, ge)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/watch_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/watch_command.go
new file mode 100644
index 00000000..71f4c014
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/command/watch_command.go
@@ -0,0 +1,85 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+ "fmt"
+ "os"
+ "os/signal"
+
+ "github.com/coreos/etcd/client"
+ "github.com/urfave/cli"
+ "golang.org/x/net/context"
+)
+
+// NewWatchCommand returns the CLI command for "watch".
+func NewWatchCommand() cli.Command {
+ return cli.Command{
+ Name: "watch",
+ Usage: "watch a key for changes",
+ ArgsUsage: "<key>",
+ Flags: []cli.Flag{
+ cli.BoolFlag{Name: "forever, f", Usage: "forever watch a key until CTRL+C"},
+ cli.IntFlag{Name: "after-index", Value: 0, Usage: "watch after the given index"},
+ cli.BoolFlag{Name: "recursive, r", Usage: "returns all values for key and child keys"},
+ },
+ Action: func(c *cli.Context) error {
+ watchCommandFunc(c, mustNewKeyAPI(c))
+ return nil
+ },
+ }
+}
+
+// watchCommandFunc executes the "watch" command.
+func watchCommandFunc(c *cli.Context, ki client.KeysAPI) {
+ if len(c.Args()) == 0 {
+ handleError(c, ExitBadArgs, errors.New("key required"))
+ }
+ key := c.Args()[0]
+ recursive := c.Bool("recursive")
+ forever := c.Bool("forever")
+ index := c.Int("after-index")
+
+ stop := false
+ w := ki.Watcher(key, &client.WatcherOptions{AfterIndex: uint64(index), Recursive: recursive})
+
+ sigch := make(chan os.Signal, 1)
+ signal.Notify(sigch, os.Interrupt)
+
+ go func() {
+ <-sigch
+ os.Exit(0)
+ }()
+
+ for !stop {
+ resp, err := w.Next(context.TODO())
+ if err != nil {
+ handleError(c, ExitServerError, err)
+ }
+ if resp.Node.Dir {
+ continue
+ }
+ if recursive {
+ fmt.Printf("[%s] %s\n", resp.Action, resp.Node.Key)
+ }
+
+ printResponseKey(resp, c.GlobalString("output"))
+
+ if !forever {
+ stop = true
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/ctl.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/ctl.go
new file mode 100644
index 00000000..e949b06f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/ctl.go
@@ -0,0 +1,87 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 ctlv2 contains the main entry point for the etcdctl for v2 API.
+package ctlv2
+
+import (
+ "fmt"
+ "os"
+ "time"
+
+ "github.com/coreos/etcd/etcdctl/ctlv2/command"
+ "github.com/coreos/etcd/version"
+ "github.com/urfave/cli"
+)
+
+func Start(apiv string) {
+ app := cli.NewApp()
+ app.Name = "etcdctl"
+ app.Version = version.Version
+ cli.VersionPrinter = func(c *cli.Context) {
+ fmt.Fprintf(c.App.Writer, "etcdctl version: %v\n", c.App.Version)
+ fmt.Fprintln(c.App.Writer, "API version: 2")
+ }
+ app.Usage = "A simple command line client for etcd."
+
+ if apiv == "" {
+ app.Usage += "\n\n" +
+ "WARNING:\n" +
+ " Environment variable ETCDCTL_API is not set; defaults to etcdctl v2.\n" +
+ " Set environment variable ETCDCTL_API=3 to use v3 API or ETCDCTL_API=2 to use v2 API."
+ }
+
+ app.Flags = []cli.Flag{
+ cli.BoolFlag{Name: "debug", Usage: "output cURL commands which can be used to reproduce the request"},
+ cli.BoolFlag{Name: "no-sync", Usage: "don't synchronize cluster information before sending request"},
+ cli.StringFlag{Name: "output, o", Value: "simple", Usage: "output response in the given format (`simple`, `extended` or `json`)"},
+ cli.StringFlag{Name: "discovery-srv, D", Usage: "domain name to query for SRV records describing cluster endpoints"},
+ cli.BoolFlag{Name: "insecure-discovery", Usage: "accept insecure SRV records describing cluster endpoints"},
+ cli.StringFlag{Name: "peers, C", Value: "", Usage: "DEPRECATED - \"--endpoints\" should be used instead"},
+ cli.StringFlag{Name: "endpoint", Value: "", Usage: "DEPRECATED - \"--endpoints\" should be used instead"},
+ cli.StringFlag{Name: "endpoints", Value: "", Usage: "a comma-delimited list of machine addresses in the cluster (default: \"http://127.0.0.1:2379,http://127.0.0.1:4001\")"},
+ cli.StringFlag{Name: "cert-file", Value: "", Usage: "identify HTTPS client using this SSL certificate file"},
+ cli.StringFlag{Name: "key-file", Value: "", Usage: "identify HTTPS client using this SSL key file"},
+ cli.StringFlag{Name: "ca-file", Value: "", Usage: "verify certificates of HTTPS-enabled servers using this CA bundle"},
+ cli.StringFlag{Name: "username, u", Value: "", Usage: "provide username[:password] and prompt if password is not supplied."},
+ cli.DurationFlag{Name: "timeout", Value: 2 * time.Second, Usage: "connection timeout per request"},
+ cli.DurationFlag{Name: "total-timeout", Value: 5 * time.Second, Usage: "timeout for the command execution (except watch)"},
+ }
+ app.Commands = []cli.Command{
+ command.NewBackupCommand(),
+ command.NewClusterHealthCommand(),
+ command.NewMakeCommand(),
+ command.NewMakeDirCommand(),
+ command.NewRemoveCommand(),
+ command.NewRemoveDirCommand(),
+ command.NewGetCommand(),
+ command.NewLsCommand(),
+ command.NewSetCommand(),
+ command.NewSetDirCommand(),
+ command.NewUpdateCommand(),
+ command.NewUpdateDirCommand(),
+ command.NewWatchCommand(),
+ command.NewExecWatchCommand(),
+ command.NewMemberCommand(),
+ command.NewUserCommands(),
+ command.NewRoleCommands(),
+ command.NewAuthCommands(),
+ }
+
+ err := runCtlV2(app)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/ctl_cov.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/ctl_cov.go
new file mode 100644
index 00000000..f76125dc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/ctl_cov.go
@@ -0,0 +1,28 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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.
+
+// +build cov
+
+package ctlv2
+
+import (
+ "os"
+ "strings"
+
+ "github.com/urfave/cli"
+)
+
+func runCtlV2(app *cli.App) error {
+ return app.Run(strings.Split(os.Getenv("ETCDCTL_ARGS"), "\xff"))
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv2/ctl_nocov.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/ctl_nocov.go
new file mode 100644
index 00000000..1591360e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv2/ctl_nocov.go
@@ -0,0 +1,27 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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.
+
+// +build !cov
+
+package ctlv2
+
+import (
+ "os"
+
+ "github.com/urfave/cli"
+)
+
+func runCtlV2(app *cli.App) error {
+ return app.Run(os.Args)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/alarm_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/alarm_command.go
new file mode 100644
index 00000000..2befbc2a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/alarm_command.go
@@ -0,0 +1,81 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/spf13/cobra"
+)
+
+// NewAlarmCommand returns the cobra command for "alarm".
+func NewAlarmCommand() *cobra.Command {
+ ac := &cobra.Command{
+ Use: "alarm <subcommand>",
+ Short: "Alarm related commands",
+ }
+
+ ac.AddCommand(NewAlarmDisarmCommand())
+ ac.AddCommand(NewAlarmListCommand())
+
+ return ac
+}
+
+func NewAlarmDisarmCommand() *cobra.Command {
+ cmd := cobra.Command{
+ Use: "disarm",
+ Short: "Disarms all alarms",
+ Run: alarmDisarmCommandFunc,
+ }
+ return &cmd
+}
+
+// alarmDisarmCommandFunc executes the "alarm disarm" command.
+func alarmDisarmCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("alarm disarm command accepts no arguments"))
+ }
+ ctx, cancel := commandCtx(cmd)
+ resp, err := mustClientFromCmd(cmd).AlarmDisarm(ctx, &v3.AlarmMember{})
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ display.Alarm(*resp)
+}
+
+func NewAlarmListCommand() *cobra.Command {
+ cmd := cobra.Command{
+ Use: "list",
+ Short: "Lists all alarms",
+ Run: alarmListCommandFunc,
+ }
+ return &cmd
+}
+
+// alarmListCommandFunc executes the "alarm list" command.
+func alarmListCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("alarm list command accepts no arguments"))
+ }
+ ctx, cancel := commandCtx(cmd)
+ resp, err := mustClientFromCmd(cmd).AlarmList(ctx)
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ display.Alarm(*resp)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/auth_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/auth_command.go
new file mode 100644
index 00000000..f9a90904
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/auth_command.go
@@ -0,0 +1,97 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ "github.com/spf13/cobra"
+)
+
+// NewAuthCommand returns the cobra command for "auth".
+func NewAuthCommand() *cobra.Command {
+ ac := &cobra.Command{
+ Use: "auth <enable or disable>",
+ Short: "Enable or disable authentication",
+ }
+
+ ac.AddCommand(newAuthEnableCommand())
+ ac.AddCommand(newAuthDisableCommand())
+
+ return ac
+}
+
+func newAuthEnableCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "enable",
+ Short: "Enables authentication",
+ Run: authEnableCommandFunc,
+ }
+}
+
+// authEnableCommandFunc executes the "auth enable" command.
+func authEnableCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("auth enable command does not accept any arguments."))
+ }
+
+ ctx, cancel := commandCtx(cmd)
+ cli := mustClientFromCmd(cmd)
+ var err error
+ for err == nil {
+ if _, err = cli.AuthEnable(ctx); err == nil {
+ break
+ }
+ if err == rpctypes.ErrRootRoleNotExist {
+ if _, err = cli.RoleAdd(ctx, "root"); err != nil {
+ break
+ }
+ if _, err = cli.UserGrantRole(ctx, "root", "root"); err != nil {
+ break
+ }
+ }
+ }
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ fmt.Println("Authentication Enabled")
+}
+
+func newAuthDisableCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "disable",
+ Short: "Disables authentication",
+ Run: authDisableCommandFunc,
+ }
+}
+
+// authDisableCommandFunc executes the "auth disable" command.
+func authDisableCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("auth disable command does not accept any arguments."))
+ }
+
+ ctx, cancel := commandCtx(cmd)
+ _, err := mustClientFromCmd(cmd).Auth.AuthDisable(ctx)
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ fmt.Println("Authentication Disabled")
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/check.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/check.go
new file mode 100644
index 00000000..590234ee
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/check.go
@@ -0,0 +1,217 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "context"
+ "encoding/binary"
+ "fmt"
+ "math"
+ "math/rand"
+ "os"
+ "sync"
+ "time"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/pkg/report"
+
+ "github.com/spf13/cobra"
+ "golang.org/x/time/rate"
+ "gopkg.in/cheggaaa/pb.v1"
+)
+
+var (
+ checkPerfLoad string
+ checkPerfPrefix string
+)
+
+type checkPerfCfg struct {
+ limit int
+ clients int
+ duration int
+}
+
+var checkPerfCfgMap = map[string]checkPerfCfg{
+ // TODO: support read limit
+ "s": {
+ limit: 150,
+ clients: 50,
+ duration: 60,
+ },
+ "m": {
+ limit: 1000,
+ clients: 200,
+ duration: 60,
+ },
+ "l": {
+ limit: 8000,
+ clients: 500,
+ duration: 60,
+ },
+ "xl": {
+ limit: 15000,
+ clients: 1000,
+ duration: 60,
+ },
+}
+
+// NewCheckCommand returns the cobra command for "check".
+func NewCheckCommand() *cobra.Command {
+ cc := &cobra.Command{
+ Use: "check <subcommand>",
+ Short: "commands for checking properties of the etcd cluster",
+ }
+
+ cc.AddCommand(NewCheckPerfCommand())
+
+ return cc
+}
+
+// NewCheckPerfCommand returns the cobra command for "check perf".
+func NewCheckPerfCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "perf [options]",
+ Short: "Check the performance of the etcd cluster",
+ Run: newCheckPerfCommand,
+ }
+
+ // TODO: support customized configuration
+ cmd.Flags().StringVar(&checkPerfLoad, "load", "s", "The performance check's workload model. Accepted workloads: s(small), m(medium), l(large), xl(xLarge)")
+ cmd.Flags().StringVar(&checkPerfPrefix, "prefix", "/etcdctl-check-perf/", "The prefix for writing the performance check's keys.")
+
+ return cmd
+}
+
+// newCheckPerfCommand executes the "check perf" command.
+func newCheckPerfCommand(cmd *cobra.Command, args []string) {
+ var checkPerfAlias = map[string]string{
+ "s": "s", "small": "s",
+ "m": "m", "medium": "m",
+ "l": "l", "large": "l",
+ "xl": "xl", "xLarge": "xl",
+ }
+
+ model, ok := checkPerfAlias[checkPerfLoad]
+ if !ok {
+ ExitWithError(ExitBadFeature, fmt.Errorf("unknown load option %v", checkPerfLoad))
+ }
+ cfg := checkPerfCfgMap[model]
+
+ requests := make(chan v3.Op, cfg.clients)
+ limit := rate.NewLimiter(rate.Limit(cfg.limit), 1)
+
+ var clients []*v3.Client
+ for i := 0; i < cfg.clients; i++ {
+ clients = append(clients, mustClientFromCmd(cmd))
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), time.Duration(cfg.duration)*time.Second)
+ resp, err := clients[0].Get(ctx, checkPerfPrefix, v3.WithPrefix(), v3.WithLimit(1))
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ if len(resp.Kvs) > 0 {
+ ExitWithError(ExitInvalidInput, fmt.Errorf("prefix %q has keys. Delete with etcdctl del --prefix %s first.", checkPerfPrefix, checkPerfPrefix))
+ }
+
+ ksize, vsize := 256, 1024
+ k, v := make([]byte, ksize), string(make([]byte, vsize))
+
+ bar := pb.New(cfg.duration)
+ bar.Format("Bom !")
+ bar.Start()
+
+ r := report.NewReport("%4.4f")
+ var wg sync.WaitGroup
+
+ wg.Add(len(clients))
+ for i := range clients {
+ go func(c *v3.Client) {
+ defer wg.Done()
+ for op := range requests {
+ st := time.Now()
+ _, derr := c.Do(context.Background(), op)
+ r.Results() <- report.Result{Err: derr, Start: st, End: time.Now()}
+ }
+ }(clients[i])
+ }
+
+ go func() {
+ cctx, ccancel := context.WithTimeout(context.Background(), time.Duration(cfg.duration)*time.Second)
+ defer ccancel()
+ for limit.Wait(cctx) == nil {
+ binary.PutVarint(k, int64(rand.Int63n(math.MaxInt64)))
+ requests <- v3.OpPut(checkPerfPrefix+string(k), v)
+ }
+ close(requests)
+ }()
+
+ go func() {
+ for i := 0; i < cfg.duration; i++ {
+ time.Sleep(time.Second)
+ bar.Add(1)
+ }
+ bar.Finish()
+ }()
+
+ sc := r.Stats()
+ wg.Wait()
+ close(r.Results())
+
+ s := <-sc
+
+ ctx, cancel = context.WithTimeout(context.Background(), 30*time.Second)
+ _, err = clients[0].Delete(ctx, checkPerfPrefix, v3.WithPrefix())
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ ok = true
+ if len(s.ErrorDist) != 0 {
+ fmt.Println("FAIL: too many errors")
+ for k, v := range s.ErrorDist {
+ fmt.Printf("FAIL: ERROR(%v) -> %d\n", k, v)
+ }
+ ok = false
+ }
+
+ if s.RPS/float64(cfg.limit) <= 0.9 {
+ fmt.Printf("FAIL: Throughput too low: %d writes/s\n", int(s.RPS)+1)
+ ok = false
+ } else {
+ fmt.Printf("PASS: Throughput is %d writes/s\n", int(s.RPS)+1)
+ }
+ if s.Slowest > 0.5 { // slowest request > 500ms
+ fmt.Printf("Slowest request took too long: %fs\n", s.Slowest)
+ ok = false
+ } else {
+ fmt.Printf("PASS: Slowest request took %fs\n", s.Slowest)
+ }
+ if s.Stddev > 0.1 { // stddev > 100ms
+ fmt.Printf("Stddev too high: %fs\n", s.Stddev)
+ ok = false
+ } else {
+ fmt.Printf("PASS: Stddev is %fs\n", s.Stddev)
+ }
+
+ if ok {
+ fmt.Println("PASS")
+ } else {
+ fmt.Println("FAIL")
+ os.Exit(ExitError)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/compaction_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/compaction_command.go
new file mode 100644
index 00000000..1b791b9d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/compaction_command.go
@@ -0,0 +1,63 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "strconv"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/spf13/cobra"
+)
+
+var compactPhysical bool
+
+// NewCompactionCommand returns the cobra command for "compaction".
+func NewCompactionCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "compaction [options] <revision>",
+ Short: "Compacts the event history in etcd",
+ Run: compactionCommandFunc,
+ }
+ cmd.Flags().BoolVar(&compactPhysical, "physical", false, "'true' to wait for compaction to physically remove all old revisions")
+ return cmd
+}
+
+// compactionCommandFunc executes the "compaction" command.
+func compactionCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("compaction command needs 1 argument."))
+ }
+
+ rev, err := strconv.ParseInt(args[0], 10, 64)
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ var opts []clientv3.CompactOption
+ if compactPhysical {
+ opts = append(opts, clientv3.WithCompactPhysical())
+ }
+
+ c := mustClientFromCmd(cmd)
+ ctx, cancel := commandCtx(cmd)
+ _, cerr := c.Compact(ctx, rev, opts...)
+ cancel()
+ if cerr != nil {
+ ExitWithError(ExitError, cerr)
+ return
+ }
+ fmt.Println("compacted revision", rev)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/defrag_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/defrag_command.go
new file mode 100644
index 00000000..b00ca205
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/defrag_command.go
@@ -0,0 +1,51 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/spf13/cobra"
+)
+
+// NewDefragCommand returns the cobra command for "Defrag".
+func NewDefragCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "defrag",
+ Short: "Defragments the storage of the etcd members with given endpoints",
+ Run: defragCommandFunc,
+ }
+}
+
+func defragCommandFunc(cmd *cobra.Command, args []string) {
+ failures := 0
+ c := mustClientFromCmd(cmd)
+ for _, ep := range c.Endpoints() {
+ ctx, cancel := commandCtx(cmd)
+ _, err := c.Defragment(ctx, ep)
+ cancel()
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Failed to defragment etcd member[%s] (%v)\n", ep, err)
+ failures++
+ } else {
+ fmt.Printf("Finished defragmenting etcd member[%s]\n", ep)
+ }
+ }
+
+ if failures != 0 {
+ os.Exit(ExitError)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/del_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/del_command.go
new file mode 100644
index 00000000..bb066302
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/del_command.go
@@ -0,0 +1,94 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/spf13/cobra"
+)
+
+var (
+ delPrefix bool
+ delPrevKV bool
+ delFromKey bool
+)
+
+// NewDelCommand returns the cobra command for "del".
+func NewDelCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "del [options] <key> [range_end]",
+ Short: "Removes the specified key or range of keys [key, range_end)",
+ Run: delCommandFunc,
+ }
+
+ cmd.Flags().BoolVar(&delPrefix, "prefix", false, "delete keys with matching prefix")
+ cmd.Flags().BoolVar(&delPrevKV, "prev-kv", false, "return deleted key-value pairs")
+ cmd.Flags().BoolVar(&delFromKey, "from-key", false, "delete keys that are greater than or equal to the given key using byte compare")
+ return cmd
+}
+
+// delCommandFunc executes the "del" command.
+func delCommandFunc(cmd *cobra.Command, args []string) {
+ key, opts := getDelOp(cmd, args)
+ ctx, cancel := commandCtx(cmd)
+ resp, err := mustClientFromCmd(cmd).Delete(ctx, key, opts...)
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ display.Del(*resp)
+}
+
+func getDelOp(cmd *cobra.Command, args []string) (string, []clientv3.OpOption) {
+ if len(args) == 0 || len(args) > 2 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("del command needs one argument as key and an optional argument as range_end."))
+ }
+
+ if delPrefix && delFromKey {
+ ExitWithError(ExitBadArgs, fmt.Errorf("`--prefix` and `--from-key` cannot be set at the same time, choose one."))
+ }
+
+ opts := []clientv3.OpOption{}
+ key := args[0]
+ if len(args) > 1 {
+ if delPrefix || delFromKey {
+ ExitWithError(ExitBadArgs, fmt.Errorf("too many arguments, only accept one argument when `--prefix` or `--from-key` is set."))
+ }
+ opts = append(opts, clientv3.WithRange(args[1]))
+ }
+
+ if delPrefix {
+ if len(key) == 0 {
+ key = "\x00"
+ opts = append(opts, clientv3.WithFromKey())
+ } else {
+ opts = append(opts, clientv3.WithPrefix())
+ }
+ }
+ if delPrevKV {
+ opts = append(opts, clientv3.WithPrevKV())
+ }
+
+ if delFromKey {
+ if len(key) == 0 {
+ key = "\x00"
+ }
+ opts = append(opts, clientv3.WithFromKey())
+ }
+
+ return key, opts
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/doc.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/doc.go
new file mode 100644
index 00000000..2e5636c2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command is a set of libraries for etcd v3 commands.
+package command
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/elect_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/elect_command.go
new file mode 100644
index 00000000..74216f3e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/elect_command.go
@@ -0,0 +1,136 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+ "os"
+ "os/signal"
+ "syscall"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/concurrency"
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+)
+
+var (
+ electListen bool
+)
+
+// NewElectCommand returns the cobra command for "elect".
+func NewElectCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "elect <election-name> [proposal]",
+ Short: "Observes and participates in leader election",
+ Run: electCommandFunc,
+ }
+ cmd.Flags().BoolVarP(&electListen, "listen", "l", false, "observation mode")
+ return cmd
+}
+
+func electCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 && len(args) != 2 {
+ ExitWithError(ExitBadArgs, errors.New("elect takes one election name argument and an optional proposal argument."))
+ }
+ c := mustClientFromCmd(cmd)
+
+ var err error
+ if len(args) == 1 {
+ if !electListen {
+ ExitWithError(ExitBadArgs, errors.New("no proposal argument but -l not set"))
+ }
+ err = observe(c, args[0])
+ } else {
+ if electListen {
+ ExitWithError(ExitBadArgs, errors.New("proposal given but -l is set"))
+ }
+ err = campaign(c, args[0], args[1])
+ }
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+}
+
+func observe(c *clientv3.Client, election string) error {
+ s, err := concurrency.NewSession(c)
+ if err != nil {
+ return err
+ }
+ e := concurrency.NewElection(s, election)
+ ctx, cancel := context.WithCancel(context.TODO())
+
+ donec := make(chan struct{})
+ sigc := make(chan os.Signal, 1)
+ signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM)
+ go func() {
+ <-sigc
+ cancel()
+ }()
+
+ go func() {
+ for resp := range e.Observe(ctx) {
+ display.Get(resp)
+ }
+ close(donec)
+ }()
+
+ <-donec
+
+ select {
+ case <-ctx.Done():
+ default:
+ return errors.New("elect: observer lost")
+ }
+
+ return nil
+}
+
+func campaign(c *clientv3.Client, election string, prop string) error {
+ s, err := concurrency.NewSession(c)
+ if err != nil {
+ return err
+ }
+ e := concurrency.NewElection(s, election)
+ ctx, cancel := context.WithCancel(context.TODO())
+
+ donec := make(chan struct{})
+ sigc := make(chan os.Signal, 1)
+ signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM)
+ go func() {
+ <-sigc
+ cancel()
+ close(donec)
+ }()
+
+ if err = e.Campaign(ctx, prop); err != nil {
+ return err
+ }
+
+ // print key since elected
+ resp, err := c.Get(ctx, e.Key())
+ if err != nil {
+ return err
+ }
+ display.Get(*resp)
+
+ select {
+ case <-donec:
+ case <-s.Done():
+ return errors.New("elect: session expired")
+ }
+
+ return e.Resign(context.TODO())
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/ep_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/ep_command.go
new file mode 100644
index 00000000..2d2a72c0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/ep_command.go
@@ -0,0 +1,153 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "os"
+ "sync"
+ "time"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ "github.com/coreos/etcd/pkg/flags"
+
+ "github.com/spf13/cobra"
+)
+
+// NewEndpointCommand returns the cobra command for "endpoint".
+func NewEndpointCommand() *cobra.Command {
+ ec := &cobra.Command{
+ Use: "endpoint <subcommand>",
+ Short: "Endpoint related commands",
+ }
+
+ ec.AddCommand(newEpHealthCommand())
+ ec.AddCommand(newEpStatusCommand())
+
+ return ec
+}
+
+func newEpHealthCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "health",
+ Short: "Checks the healthiness of endpoints specified in `--endpoints` flag",
+ Run: epHealthCommandFunc,
+ }
+
+ return cmd
+}
+
+func newEpStatusCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "status",
+ Short: "Prints out the status of endpoints specified in `--endpoints` flag",
+ Long: `When --write-out is set to simple, this command prints out comma-separated status lists for each endpoint.
+The items in the lists are endpoint, ID, version, db size, is leader, raft term, raft index.
+`,
+ Run: epStatusCommandFunc,
+ }
+}
+
+// epHealthCommandFunc executes the "endpoint-health" command.
+func epHealthCommandFunc(cmd *cobra.Command, args []string) {
+ flags.SetPflagsFromEnv("ETCDCTL", cmd.InheritedFlags())
+ endpoints, err := cmd.Flags().GetStringSlice("endpoints")
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ sec := secureCfgFromCmd(cmd)
+ dt := dialTimeoutFromCmd(cmd)
+ auth := authCfgFromCmd(cmd)
+ cfgs := []*v3.Config{}
+ for _, ep := range endpoints {
+ cfg, err := newClientCfg([]string{ep}, dt, sec, auth)
+ if err != nil {
+ ExitWithError(ExitBadArgs, err)
+ }
+ cfgs = append(cfgs, cfg)
+ }
+
+ var wg sync.WaitGroup
+ errc := make(chan error, len(cfgs))
+ for _, cfg := range cfgs {
+ wg.Add(1)
+ go func(cfg *v3.Config) {
+ defer wg.Done()
+ ep := cfg.Endpoints[0]
+ cli, err := v3.New(*cfg)
+ if err != nil {
+ errc <- fmt.Errorf("%s is unhealthy: failed to connect: %v", ep, err)
+ return
+ }
+ st := time.Now()
+ // get a random key. As long as we can get the response without an error, the
+ // endpoint is health.
+ ctx, cancel := commandCtx(cmd)
+ _, err = cli.Get(ctx, "health")
+ cancel()
+ // permission denied is OK since proposal goes through consensus to get it
+ if err == nil || err == rpctypes.ErrPermissionDenied {
+ fmt.Printf("%s is healthy: successfully committed proposal: took = %v\n", ep, time.Since(st))
+ } else {
+ errc <- fmt.Errorf("%s is unhealthy: failed to commit proposal: %v", ep, err)
+ }
+ }(cfg)
+ }
+
+ wg.Wait()
+ close(errc)
+
+ errs := false
+ for err := range errc {
+ if err != nil {
+ errs = true
+ fmt.Fprintln(os.Stderr, err)
+ }
+ }
+ if errs {
+ ExitWithError(ExitError, fmt.Errorf("unhealthy cluster"))
+ }
+}
+
+type epStatus struct {
+ Ep string `json:"Endpoint"`
+ Resp *v3.StatusResponse `json:"Status"`
+}
+
+func epStatusCommandFunc(cmd *cobra.Command, args []string) {
+ c := mustClientFromCmd(cmd)
+
+ statusList := []epStatus{}
+ var err error
+ for _, ep := range c.Endpoints() {
+ ctx, cancel := commandCtx(cmd)
+ resp, serr := c.Status(ctx, ep)
+ cancel()
+ if serr != nil {
+ err = serr
+ fmt.Fprintf(os.Stderr, "Failed to get the status of endpoint %s (%v)\n", ep, serr)
+ continue
+ }
+ statusList = append(statusList, epStatus{Ep: ep, Resp: resp})
+ }
+
+ display.EndpointStatus(statusList)
+
+ if err != nil {
+ os.Exit(ExitError)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/error.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/error.go
new file mode 100644
index 00000000..3188cd5e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/error.go
@@ -0,0 +1,42 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/coreos/etcd/client"
+)
+
+const (
+ // http://tldp.org/LDP/abs/html/exitcodes.html
+ ExitSuccess = iota
+ ExitError
+ ExitBadConnection
+ ExitInvalidInput // for txn, watch command
+ ExitBadFeature // provided a valid flag with an unsupported value
+ ExitInterrupted
+ ExitIO
+ ExitBadArgs = 128
+)
+
+func ExitWithError(code int, err error) {
+ fmt.Fprintln(os.Stderr, "Error: ", err)
+ if cerr, ok := err.(*client.ClusterError); ok {
+ fmt.Fprintln(os.Stderr, cerr.Detail())
+ }
+ os.Exit(code)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/get_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/get_command.go
new file mode 100644
index 00000000..5f9c74f3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/get_command.go
@@ -0,0 +1,163 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/spf13/cobra"
+)
+
+var (
+ getConsistency string
+ getLimit int64
+ getSortOrder string
+ getSortTarget string
+ getPrefix bool
+ getFromKey bool
+ getRev int64
+ getKeysOnly bool
+ printValueOnly bool
+)
+
+// NewGetCommand returns the cobra command for "get".
+func NewGetCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "get [options] <key> [range_end]",
+ Short: "Gets the key or a range of keys",
+ Run: getCommandFunc,
+ }
+
+ cmd.Flags().StringVar(&getConsistency, "consistency", "l", "Linearizable(l) or Serializable(s)")
+ cmd.Flags().StringVar(&getSortOrder, "order", "", "Order of results; ASCEND or DESCEND (ASCEND by default)")
+ cmd.Flags().StringVar(&getSortTarget, "sort-by", "", "Sort target; CREATE, KEY, MODIFY, VALUE, or VERSION")
+ cmd.Flags().Int64Var(&getLimit, "limit", 0, "Maximum number of results")
+ cmd.Flags().BoolVar(&getPrefix, "prefix", false, "Get keys with matching prefix")
+ cmd.Flags().BoolVar(&getFromKey, "from-key", false, "Get keys that are greater than or equal to the given key using byte compare")
+ cmd.Flags().Int64Var(&getRev, "rev", 0, "Specify the kv revision")
+ cmd.Flags().BoolVar(&getKeysOnly, "keys-only", false, "Get only the keys")
+ cmd.Flags().BoolVar(&printValueOnly, "print-value-only", false, `Only write values when using the "simple" output format`)
+ return cmd
+}
+
+// getCommandFunc executes the "get" command.
+func getCommandFunc(cmd *cobra.Command, args []string) {
+ key, opts := getGetOp(cmd, args)
+ ctx, cancel := commandCtx(cmd)
+ resp, err := mustClientFromCmd(cmd).Get(ctx, key, opts...)
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ if printValueOnly {
+ dp, simple := (display).(*simplePrinter)
+ if !simple {
+ ExitWithError(ExitBadArgs, fmt.Errorf("print-value-only is only for `--write-out=simple`."))
+ }
+ dp.valueOnly = true
+ }
+ display.Get(*resp)
+}
+
+func getGetOp(cmd *cobra.Command, args []string) (string, []clientv3.OpOption) {
+ if len(args) == 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("range command needs arguments."))
+ }
+
+ if getPrefix && getFromKey {
+ ExitWithError(ExitBadArgs, fmt.Errorf("`--prefix` and `--from-key` cannot be set at the same time, choose one."))
+ }
+
+ opts := []clientv3.OpOption{}
+ switch getConsistency {
+ case "s":
+ opts = append(opts, clientv3.WithSerializable())
+ case "l":
+ default:
+ ExitWithError(ExitBadFeature, fmt.Errorf("unknown consistency flag %q", getConsistency))
+ }
+
+ key := args[0]
+ if len(args) > 1 {
+ if getPrefix || getFromKey {
+ ExitWithError(ExitBadArgs, fmt.Errorf("too many arguments, only accept one argument when `--prefix` or `--from-key` is set."))
+ }
+ opts = append(opts, clientv3.WithRange(args[1]))
+ }
+
+ opts = append(opts, clientv3.WithLimit(getLimit))
+ if getRev > 0 {
+ opts = append(opts, clientv3.WithRev(getRev))
+ }
+
+ sortByOrder := clientv3.SortNone
+ sortOrder := strings.ToUpper(getSortOrder)
+ switch {
+ case sortOrder == "ASCEND":
+ sortByOrder = clientv3.SortAscend
+ case sortOrder == "DESCEND":
+ sortByOrder = clientv3.SortDescend
+ case sortOrder == "":
+ // nothing
+ default:
+ ExitWithError(ExitBadFeature, fmt.Errorf("bad sort order %v", getSortOrder))
+ }
+
+ sortByTarget := clientv3.SortByKey
+ sortTarget := strings.ToUpper(getSortTarget)
+ switch {
+ case sortTarget == "CREATE":
+ sortByTarget = clientv3.SortByCreateRevision
+ case sortTarget == "KEY":
+ sortByTarget = clientv3.SortByKey
+ case sortTarget == "MODIFY":
+ sortByTarget = clientv3.SortByModRevision
+ case sortTarget == "VALUE":
+ sortByTarget = clientv3.SortByValue
+ case sortTarget == "VERSION":
+ sortByTarget = clientv3.SortByVersion
+ case sortTarget == "":
+ // nothing
+ default:
+ ExitWithError(ExitBadFeature, fmt.Errorf("bad sort target %v", getSortTarget))
+ }
+
+ opts = append(opts, clientv3.WithSort(sortByTarget, sortByOrder))
+
+ if getPrefix {
+ if len(key) == 0 {
+ key = "\x00"
+ opts = append(opts, clientv3.WithFromKey())
+ } else {
+ opts = append(opts, clientv3.WithPrefix())
+ }
+ }
+
+ if getFromKey {
+ if len(key) == 0 {
+ key = "\x00"
+ }
+ opts = append(opts, clientv3.WithFromKey())
+ }
+
+ if getKeysOnly {
+ opts = append(opts, clientv3.WithKeysOnly())
+ }
+
+ return key, opts
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/global.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/global.go
new file mode 100644
index 00000000..616d32e2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/global.go
@@ -0,0 +1,270 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "crypto/tls"
+ "errors"
+ "io"
+ "io/ioutil"
+ "log"
+ "os"
+ "strings"
+ "time"
+
+ "github.com/bgentry/speakeasy"
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/pkg/flags"
+ "github.com/coreos/etcd/pkg/transport"
+ "github.com/spf13/cobra"
+)
+
+// GlobalFlags are flags that defined globally
+// and are inherited to all sub-commands.
+type GlobalFlags struct {
+ Insecure bool
+ InsecureSkipVerify bool
+ Endpoints []string
+ DialTimeout time.Duration
+ CommandTimeOut time.Duration
+
+ TLS transport.TLSInfo
+
+ OutputFormat string
+ IsHex bool
+
+ User string
+
+ Debug bool
+}
+
+type secureCfg struct {
+ cert string
+ key string
+ cacert string
+
+ insecureTransport bool
+ insecureSkipVerify bool
+}
+
+type authCfg struct {
+ username string
+ password string
+}
+
+var display printer = &simplePrinter{}
+
+func initDisplayFromCmd(cmd *cobra.Command) {
+ isHex, err := cmd.Flags().GetBool("hex")
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ outputType, err := cmd.Flags().GetString("write-out")
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ if display = NewPrinter(outputType, isHex); display == nil {
+ ExitWithError(ExitBadFeature, errors.New("unsupported output format"))
+ }
+}
+
+func mustClientFromCmd(cmd *cobra.Command) *clientv3.Client {
+ flags.SetPflagsFromEnv("ETCDCTL", cmd.InheritedFlags())
+
+ debug, derr := cmd.Flags().GetBool("debug")
+ if derr != nil {
+ ExitWithError(ExitError, derr)
+ }
+ if debug {
+ clientv3.SetLogger(log.New(os.Stderr, "grpc: ", 0))
+ }
+
+ endpoints, err := cmd.Flags().GetStringSlice("endpoints")
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ dialTimeout := dialTimeoutFromCmd(cmd)
+ sec := secureCfgFromCmd(cmd)
+ auth := authCfgFromCmd(cmd)
+
+ initDisplayFromCmd(cmd)
+
+ return mustClient(endpoints, dialTimeout, sec, auth)
+}
+
+func mustClient(endpoints []string, dialTimeout time.Duration, scfg *secureCfg, acfg *authCfg) *clientv3.Client {
+ cfg, err := newClientCfg(endpoints, dialTimeout, scfg, acfg)
+ if err != nil {
+ ExitWithError(ExitBadArgs, err)
+ }
+
+ client, err := clientv3.New(*cfg)
+ if err != nil {
+ ExitWithError(ExitBadConnection, err)
+ }
+
+ return client
+}
+
+func newClientCfg(endpoints []string, dialTimeout time.Duration, scfg *secureCfg, acfg *authCfg) (*clientv3.Config, error) {
+ // set tls if any one tls option set
+ var cfgtls *transport.TLSInfo
+ tlsinfo := transport.TLSInfo{}
+ if scfg.cert != "" {
+ tlsinfo.CertFile = scfg.cert
+ cfgtls = &tlsinfo
+ }
+
+ if scfg.key != "" {
+ tlsinfo.KeyFile = scfg.key
+ cfgtls = &tlsinfo
+ }
+
+ if scfg.cacert != "" {
+ tlsinfo.CAFile = scfg.cacert
+ cfgtls = &tlsinfo
+ }
+
+ cfg := &clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: dialTimeout,
+ }
+ if cfgtls != nil {
+ clientTLS, err := cfgtls.ClientConfig()
+ if err != nil {
+ return nil, err
+ }
+ cfg.TLS = clientTLS
+ }
+ // if key/cert is not given but user wants secure connection, we
+ // should still setup an empty tls configuration for gRPC to setup
+ // secure connection.
+ if cfg.TLS == nil && !scfg.insecureTransport {
+ cfg.TLS = &tls.Config{}
+ }
+
+ // If the user wants to skip TLS verification then we should set
+ // the InsecureSkipVerify flag in tls configuration.
+ if scfg.insecureSkipVerify && cfg.TLS != nil {
+ cfg.TLS.InsecureSkipVerify = true
+ }
+
+ if acfg != nil {
+ cfg.Username = acfg.username
+ cfg.Password = acfg.password
+ }
+
+ return cfg, nil
+}
+
+func argOrStdin(args []string, stdin io.Reader, i int) (string, error) {
+ if i < len(args) {
+ return args[i], nil
+ }
+ bytes, err := ioutil.ReadAll(stdin)
+ if string(bytes) == "" || err != nil {
+ return "", errors.New("no available argument and stdin")
+ }
+ return string(bytes), nil
+}
+
+func dialTimeoutFromCmd(cmd *cobra.Command) time.Duration {
+ dialTimeout, err := cmd.Flags().GetDuration("dial-timeout")
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ return dialTimeout
+}
+
+func secureCfgFromCmd(cmd *cobra.Command) *secureCfg {
+ cert, key, cacert := keyAndCertFromCmd(cmd)
+ insecureTr := insecureTransportFromCmd(cmd)
+ skipVerify := insecureSkipVerifyFromCmd(cmd)
+
+ return &secureCfg{
+ cert: cert,
+ key: key,
+ cacert: cacert,
+
+ insecureTransport: insecureTr,
+ insecureSkipVerify: skipVerify,
+ }
+}
+
+func insecureTransportFromCmd(cmd *cobra.Command) bool {
+ insecureTr, err := cmd.Flags().GetBool("insecure-transport")
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ return insecureTr
+}
+
+func insecureSkipVerifyFromCmd(cmd *cobra.Command) bool {
+ skipVerify, err := cmd.Flags().GetBool("insecure-skip-tls-verify")
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ return skipVerify
+}
+
+func keyAndCertFromCmd(cmd *cobra.Command) (cert, key, cacert string) {
+ var err error
+ if cert, err = cmd.Flags().GetString("cert"); err != nil {
+ ExitWithError(ExitBadArgs, err)
+ } else if cert == "" && cmd.Flags().Changed("cert") {
+ ExitWithError(ExitBadArgs, errors.New("empty string is passed to --cert option"))
+ }
+
+ if key, err = cmd.Flags().GetString("key"); err != nil {
+ ExitWithError(ExitBadArgs, err)
+ } else if key == "" && cmd.Flags().Changed("key") {
+ ExitWithError(ExitBadArgs, errors.New("empty string is passed to --key option"))
+ }
+
+ if cacert, err = cmd.Flags().GetString("cacert"); err != nil {
+ ExitWithError(ExitBadArgs, err)
+ } else if cacert == "" && cmd.Flags().Changed("cacert") {
+ ExitWithError(ExitBadArgs, errors.New("empty string is passed to --cacert option"))
+ }
+
+ return cert, key, cacert
+}
+
+func authCfgFromCmd(cmd *cobra.Command) *authCfg {
+ userFlag, err := cmd.Flags().GetString("user")
+ if err != nil {
+ ExitWithError(ExitBadArgs, err)
+ }
+
+ if userFlag == "" {
+ return nil
+ }
+
+ var cfg authCfg
+
+ splitted := strings.SplitN(userFlag, ":", 2)
+ if len(splitted) < 2 {
+ cfg.username = userFlag
+ cfg.password, err = speakeasy.Ask("Password: ")
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ } else {
+ cfg.username = splitted[0]
+ cfg.password = splitted[1]
+ }
+
+ return &cfg
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/lease_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/lease_command.go
new file mode 100644
index 00000000..0afb3d69
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/lease_command.go
@@ -0,0 +1,171 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "strconv"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+)
+
+// NewLeaseCommand returns the cobra command for "lease".
+func NewLeaseCommand() *cobra.Command {
+ lc := &cobra.Command{
+ Use: "lease <subcommand>",
+ Short: "Lease related commands",
+ }
+
+ lc.AddCommand(NewLeaseGrantCommand())
+ lc.AddCommand(NewLeaseRevokeCommand())
+ lc.AddCommand(NewLeaseTimeToLiveCommand())
+ lc.AddCommand(NewLeaseKeepAliveCommand())
+
+ return lc
+}
+
+// NewLeaseGrantCommand returns the cobra command for "lease grant".
+func NewLeaseGrantCommand() *cobra.Command {
+ lc := &cobra.Command{
+ Use: "grant <ttl>",
+ Short: "Creates leases",
+
+ Run: leaseGrantCommandFunc,
+ }
+
+ return lc
+}
+
+// leaseGrantCommandFunc executes the "lease grant" command.
+func leaseGrantCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("lease grant command needs TTL argument."))
+ }
+
+ ttl, err := strconv.ParseInt(args[0], 10, 64)
+ if err != nil {
+ ExitWithError(ExitBadArgs, fmt.Errorf("bad TTL (%v)", err))
+ }
+
+ ctx, cancel := commandCtx(cmd)
+ resp, err := mustClientFromCmd(cmd).Grant(ctx, ttl)
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, fmt.Errorf("failed to grant lease (%v)\n", err))
+ }
+ display.Grant(*resp)
+}
+
+// NewLeaseRevokeCommand returns the cobra command for "lease revoke".
+func NewLeaseRevokeCommand() *cobra.Command {
+ lc := &cobra.Command{
+ Use: "revoke <leaseID>",
+ Short: "Revokes leases",
+
+ Run: leaseRevokeCommandFunc,
+ }
+
+ return lc
+}
+
+// leaseRevokeCommandFunc executes the "lease grant" command.
+func leaseRevokeCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("lease revoke command needs 1 argument"))
+ }
+
+ id := leaseFromArgs(args[0])
+ ctx, cancel := commandCtx(cmd)
+ resp, err := mustClientFromCmd(cmd).Revoke(ctx, id)
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, fmt.Errorf("failed to revoke lease (%v)\n", err))
+ }
+ display.Revoke(id, *resp)
+}
+
+var timeToLiveKeys bool
+
+// NewLeaseTimeToLiveCommand returns the cobra command for "lease timetolive".
+func NewLeaseTimeToLiveCommand() *cobra.Command {
+ lc := &cobra.Command{
+ Use: "timetolive <leaseID> [options]",
+ Short: "Get lease information",
+
+ Run: leaseTimeToLiveCommandFunc,
+ }
+ lc.Flags().BoolVar(&timeToLiveKeys, "keys", false, "Get keys attached to this lease")
+
+ return lc
+}
+
+// leaseTimeToLiveCommandFunc executes the "lease timetolive" command.
+func leaseTimeToLiveCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("lease timetolive command needs lease ID as argument"))
+ }
+ var opts []v3.LeaseOption
+ if timeToLiveKeys {
+ opts = append(opts, v3.WithAttachedKeys())
+ }
+ resp, rerr := mustClientFromCmd(cmd).TimeToLive(context.TODO(), leaseFromArgs(args[0]), opts...)
+ if rerr != nil {
+ ExitWithError(ExitBadConnection, rerr)
+ }
+ display.TimeToLive(*resp, timeToLiveKeys)
+}
+
+// NewLeaseKeepAliveCommand returns the cobra command for "lease keep-alive".
+func NewLeaseKeepAliveCommand() *cobra.Command {
+ lc := &cobra.Command{
+ Use: "keep-alive <leaseID>",
+ Short: "Keeps leases alive (renew)",
+
+ Run: leaseKeepAliveCommandFunc,
+ }
+
+ return lc
+}
+
+// leaseKeepAliveCommandFunc executes the "lease keep-alive" command.
+func leaseKeepAliveCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("lease keep-alive command needs lease ID as argument"))
+ }
+
+ id := leaseFromArgs(args[0])
+ respc, kerr := mustClientFromCmd(cmd).KeepAlive(context.TODO(), id)
+ if kerr != nil {
+ ExitWithError(ExitBadConnection, kerr)
+ }
+
+ for resp := range respc {
+ display.KeepAlive(*resp)
+ }
+
+ if _, ok := (display).(*simplePrinter); ok {
+ fmt.Printf("lease %016x expired or revoked.\n", id)
+ }
+}
+
+func leaseFromArgs(arg string) v3.LeaseID {
+ id, err := strconv.ParseInt(arg, 16, 64)
+ if err != nil {
+ ExitWithError(ExitBadArgs, fmt.Errorf("bad lease ID arg (%v), expecting ID in Hex", err))
+ }
+ return v3.LeaseID(id)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/lock_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/lock_command.go
new file mode 100644
index 00000000..e130493f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/lock_command.go
@@ -0,0 +1,109 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+ "fmt"
+ "os"
+ "os/exec"
+ "os/signal"
+ "syscall"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/concurrency"
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+)
+
+// NewLockCommand returns the cobra command for "lock".
+func NewLockCommand() *cobra.Command {
+ c := &cobra.Command{
+ Use: "lock <lockname> [exec-command arg1 arg2 ...]",
+ Short: "Acquires a named lock",
+ Run: lockCommandFunc,
+ }
+ return c
+}
+
+func lockCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) == 0 {
+ ExitWithError(ExitBadArgs, errors.New("lock takes a lock name argument and an optional command to execute."))
+ }
+ c := mustClientFromCmd(cmd)
+ if err := lockUntilSignal(c, args[0], args[1:]); err != nil {
+ ExitWithError(ExitError, err)
+ }
+}
+
+func lockUntilSignal(c *clientv3.Client, lockname string, cmdArgs []string) error {
+ s, err := concurrency.NewSession(c)
+ if err != nil {
+ return err
+ }
+
+ m := concurrency.NewMutex(s, lockname)
+ ctx, cancel := context.WithCancel(context.TODO())
+
+ // unlock in case of ordinary shutdown
+ donec := make(chan struct{})
+ sigc := make(chan os.Signal, 1)
+ signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM)
+ go func() {
+ <-sigc
+ cancel()
+ close(donec)
+ }()
+
+ if err := m.Lock(ctx); err != nil {
+ return err
+ }
+
+ if len(cmdArgs) > 0 {
+ cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...)
+ cmd.Env = append(environLockResponse(m), os.Environ()...)
+ cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
+ err := cmd.Run()
+ unlockErr := m.Unlock(context.TODO())
+ if err != nil {
+ return err
+ }
+ return unlockErr
+ }
+
+ k, kerr := c.Get(ctx, m.Key())
+ if kerr != nil {
+ return kerr
+ }
+ if len(k.Kvs) == 0 {
+ return errors.New("lock lost on init")
+ }
+ display.Get(*k)
+
+ select {
+ case <-donec:
+ return m.Unlock(context.TODO())
+ case <-s.Done():
+ }
+
+ return errors.New("session expired")
+}
+
+func environLockResponse(m *concurrency.Mutex) []string {
+ return []string{
+ "ETCD_LOCK_KEY=" + m.Key(),
+ fmt.Sprintf("ETCD_LOCK_REV=%d", m.Header().Revision),
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/make_mirror_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/make_mirror_command.go
new file mode 100644
index 00000000..e333c999
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/make_mirror_command.go
@@ -0,0 +1,166 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+ "fmt"
+ "strings"
+ "sync/atomic"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/mirror"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+)
+
+var (
+ mminsecureTr bool
+ mmcert string
+ mmkey string
+ mmcacert string
+ mmprefix string
+ mmdestprefix string
+ mmnodestprefix bool
+)
+
+// NewMakeMirrorCommand returns the cobra command for "makeMirror".
+func NewMakeMirrorCommand() *cobra.Command {
+ c := &cobra.Command{
+ Use: "make-mirror [options] <destination>",
+ Short: "Makes a mirror at the destination etcd cluster",
+ Run: makeMirrorCommandFunc,
+ }
+
+ c.Flags().StringVar(&mmprefix, "prefix", "", "Key-value prefix to mirror")
+ c.Flags().StringVar(&mmdestprefix, "dest-prefix", "", "destination prefix to mirror a prefix to a different prefix in the destination cluster")
+ c.Flags().BoolVar(&mmnodestprefix, "no-dest-prefix", false, "mirror key-values to the root of the destination cluster")
+ c.Flags().StringVar(&mmcert, "dest-cert", "", "Identify secure client using this TLS certificate file for the destination cluster")
+ c.Flags().StringVar(&mmkey, "dest-key", "", "Identify secure client using this TLS key file")
+ c.Flags().StringVar(&mmcacert, "dest-cacert", "", "Verify certificates of TLS enabled secure servers using this CA bundle")
+ // TODO: secure by default when etcd enables secure gRPC by default.
+ c.Flags().BoolVar(&mminsecureTr, "dest-insecure-transport", true, "Disable transport security for client connections")
+
+ return c
+}
+
+func makeMirrorCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, errors.New("make-mirror takes one destination argument."))
+ }
+
+ dialTimeout := dialTimeoutFromCmd(cmd)
+ sec := &secureCfg{
+ cert: mmcert,
+ key: mmkey,
+ cacert: mmcacert,
+ insecureTransport: mminsecureTr,
+ }
+
+ dc := mustClient([]string{args[0]}, dialTimeout, sec, nil)
+ c := mustClientFromCmd(cmd)
+
+ err := makeMirror(context.TODO(), c, dc)
+ ExitWithError(ExitError, err)
+}
+
+func makeMirror(ctx context.Context, c *clientv3.Client, dc *clientv3.Client) error {
+ total := int64(0)
+
+ go func() {
+ for {
+ time.Sleep(30 * time.Second)
+ fmt.Println(atomic.LoadInt64(&total))
+ }
+ }()
+
+ s := mirror.NewSyncer(c, mmprefix, 0)
+
+ rc, errc := s.SyncBase(ctx)
+
+ // if destination prefix is specified and remove destination prefix is true return error
+ if mmnodestprefix && len(mmdestprefix) > 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("`--dest-prefix` and `--no-dest-prefix` cannot be set at the same time, choose one."))
+ }
+
+ // if remove destination prefix is false and destination prefix is empty set the value of destination prefix same as prefix
+ if !mmnodestprefix && len(mmdestprefix) == 0 {
+ mmdestprefix = mmprefix
+ }
+
+ for r := range rc {
+ for _, kv := range r.Kvs {
+ _, err := dc.Put(ctx, modifyPrefix(string(kv.Key)), string(kv.Value))
+ if err != nil {
+ return err
+ }
+ atomic.AddInt64(&total, 1)
+ }
+ }
+
+ err := <-errc
+ if err != nil {
+ return err
+ }
+
+ wc := s.SyncUpdates(ctx)
+
+ for wr := range wc {
+ if wr.CompactRevision != 0 {
+ return rpctypes.ErrCompacted
+ }
+
+ var lastRev int64
+ ops := []clientv3.Op{}
+
+ for _, ev := range wr.Events {
+ nextRev := ev.Kv.ModRevision
+ if lastRev != 0 && nextRev > lastRev {
+ _, err := dc.Txn(ctx).Then(ops...).Commit()
+ if err != nil {
+ return err
+ }
+ ops = []clientv3.Op{}
+ }
+ lastRev = nextRev
+ switch ev.Type {
+ case mvccpb.PUT:
+ ops = append(ops, clientv3.OpPut(modifyPrefix(string(ev.Kv.Key)), string(ev.Kv.Value)))
+ atomic.AddInt64(&total, 1)
+ case mvccpb.DELETE:
+ ops = append(ops, clientv3.OpDelete(modifyPrefix(string(ev.Kv.Key))))
+ atomic.AddInt64(&total, 1)
+ default:
+ panic("unexpected event type")
+ }
+ }
+
+ if len(ops) != 0 {
+ _, err := dc.Txn(ctx).Then(ops...).Commit()
+ if err != nil {
+ return err
+ }
+ }
+ }
+
+ return nil
+}
+
+func modifyPrefix(key string) string {
+ return strings.Replace(key, mmprefix, mmdestprefix, 1)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/member_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/member_command.go
new file mode 100644
index 00000000..c45584ec
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/member_command.go
@@ -0,0 +1,216 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "strconv"
+ "strings"
+
+ "github.com/spf13/cobra"
+)
+
+var memberPeerURLs string
+
+// NewMemberCommand returns the cobra command for "member".
+func NewMemberCommand() *cobra.Command {
+ mc := &cobra.Command{
+ Use: "member <subcommand>",
+ Short: "Membership related commands",
+ }
+
+ mc.AddCommand(NewMemberAddCommand())
+ mc.AddCommand(NewMemberRemoveCommand())
+ mc.AddCommand(NewMemberUpdateCommand())
+ mc.AddCommand(NewMemberListCommand())
+
+ return mc
+}
+
+// NewMemberAddCommand returns the cobra command for "member add".
+func NewMemberAddCommand() *cobra.Command {
+ cc := &cobra.Command{
+ Use: "add <memberName> [options]",
+ Short: "Adds a member into the cluster",
+
+ Run: memberAddCommandFunc,
+ }
+
+ cc.Flags().StringVar(&memberPeerURLs, "peer-urls", "", "comma separated peer URLs for the new member.")
+
+ return cc
+}
+
+// NewMemberRemoveCommand returns the cobra command for "member remove".
+func NewMemberRemoveCommand() *cobra.Command {
+ cc := &cobra.Command{
+ Use: "remove <memberID>",
+ Short: "Removes a member from the cluster",
+
+ Run: memberRemoveCommandFunc,
+ }
+
+ return cc
+}
+
+// NewMemberUpdateCommand returns the cobra command for "member update".
+func NewMemberUpdateCommand() *cobra.Command {
+ cc := &cobra.Command{
+ Use: "update <memberID> [options]",
+ Short: "Updates a member in the cluster",
+
+ Run: memberUpdateCommandFunc,
+ }
+
+ cc.Flags().StringVar(&memberPeerURLs, "peer-urls", "", "comma separated peer URLs for the updated member.")
+
+ return cc
+}
+
+// NewMemberListCommand returns the cobra command for "member list".
+func NewMemberListCommand() *cobra.Command {
+ cc := &cobra.Command{
+ Use: "list",
+ Short: "Lists all members in the cluster",
+ Long: `When --write-out is set to simple, this command prints out comma-separated member lists for each endpoint.
+The items in the lists are ID, Status, Name, Peer Addrs, Client Addrs.
+`,
+
+ Run: memberListCommandFunc,
+ }
+
+ return cc
+}
+
+// memberAddCommandFunc executes the "member add" command.
+func memberAddCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("member name not provided."))
+ }
+ newMemberName := args[0]
+
+ if len(memberPeerURLs) == 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("member peer urls not provided."))
+ }
+
+ urls := strings.Split(memberPeerURLs, ",")
+ ctx, cancel := commandCtx(cmd)
+ cli := mustClientFromCmd(cmd)
+ resp, err := cli.MemberAdd(ctx, urls)
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ newID := resp.Member.ID
+
+ display.MemberAdd(*resp)
+
+ if _, ok := (display).(*simplePrinter); ok {
+ ctx, cancel = commandCtx(cmd)
+ listResp, err := cli.MemberList(ctx)
+ // get latest member list; if there's failover new member might have outdated list
+ for {
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ if listResp.Header.MemberId == resp.Header.MemberId {
+ break
+ }
+ // quorum get to sync cluster list
+ gresp, gerr := cli.Get(ctx, "_")
+ if gerr != nil {
+ ExitWithError(ExitError, err)
+ }
+ resp.Header.MemberId = gresp.Header.MemberId
+ listResp, err = cli.MemberList(ctx)
+ }
+ cancel()
+
+ conf := []string{}
+ for _, memb := range listResp.Members {
+ for _, u := range memb.PeerURLs {
+ n := memb.Name
+ if memb.ID == newID {
+ n = newMemberName
+ }
+ conf = append(conf, fmt.Sprintf("%s=%s", n, u))
+ }
+ }
+
+ fmt.Print("\n")
+ fmt.Printf("ETCD_NAME=%q\n", newMemberName)
+ fmt.Printf("ETCD_INITIAL_CLUSTER=%q\n", strings.Join(conf, ","))
+ fmt.Printf("ETCD_INITIAL_CLUSTER_STATE=\"existing\"\n")
+ }
+}
+
+// memberRemoveCommandFunc executes the "member remove" command.
+func memberRemoveCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("member ID is not provided"))
+ }
+
+ id, err := strconv.ParseUint(args[0], 16, 64)
+ if err != nil {
+ ExitWithError(ExitBadArgs, fmt.Errorf("bad member ID arg (%v), expecting ID in Hex", err))
+ }
+
+ ctx, cancel := commandCtx(cmd)
+ resp, err := mustClientFromCmd(cmd).MemberRemove(ctx, id)
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ display.MemberRemove(id, *resp)
+}
+
+// memberUpdateCommandFunc executes the "member update" command.
+func memberUpdateCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("member ID is not provided"))
+ }
+
+ id, err := strconv.ParseUint(args[0], 16, 64)
+ if err != nil {
+ ExitWithError(ExitBadArgs, fmt.Errorf("bad member ID arg (%v), expecting ID in Hex", err))
+ }
+
+ if len(memberPeerURLs) == 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("member peer urls not provided."))
+ }
+
+ urls := strings.Split(memberPeerURLs, ",")
+
+ ctx, cancel := commandCtx(cmd)
+ resp, err := mustClientFromCmd(cmd).MemberUpdate(ctx, id, urls)
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ display.MemberUpdate(id, *resp)
+}
+
+// memberListCommandFunc executes the "member list" command.
+func memberListCommandFunc(cmd *cobra.Command, args []string) {
+ ctx, cancel := commandCtx(cmd)
+ resp, err := mustClientFromCmd(cmd).MemberList(ctx)
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ display.MemberList(*resp)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/migrate_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/migrate_command.go
new file mode 100644
index 00000000..634ebb94
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/migrate_command.go
@@ -0,0 +1,410 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "encoding/binary"
+ "encoding/json"
+ "fmt"
+ "io"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "time"
+
+ "github.com/coreos/etcd/client"
+ etcdErr "github.com/coreos/etcd/error"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/mvcc"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/snap"
+ "github.com/coreos/etcd/store"
+ "github.com/coreos/etcd/wal"
+ "github.com/coreos/etcd/wal/walpb"
+ "github.com/gogo/protobuf/proto"
+ "github.com/spf13/cobra"
+)
+
+var (
+ migrateExcludeTTLKey bool
+ migrateDatadir string
+ migrateWALdir string
+ migrateTransformer string
+)
+
+// NewMigrateCommand returns the cobra command for "migrate".
+func NewMigrateCommand() *cobra.Command {
+ mc := &cobra.Command{
+ Use: "migrate",
+ Short: "Migrates keys in a v2 store to a mvcc store",
+ Run: migrateCommandFunc,
+ }
+
+ mc.Flags().BoolVar(&migrateExcludeTTLKey, "no-ttl", false, "Do not convert TTL keys")
+ mc.Flags().StringVar(&migrateDatadir, "data-dir", "", "Path to the data directory")
+ mc.Flags().StringVar(&migrateWALdir, "wal-dir", "", "Path to the WAL directory")
+ mc.Flags().StringVar(&migrateTransformer, "transformer", "", "Path to the user-provided transformer program")
+ return mc
+}
+
+func migrateCommandFunc(cmd *cobra.Command, args []string) {
+ var (
+ writer io.WriteCloser
+ reader io.ReadCloser
+ errc chan error
+ )
+ if migrateTransformer != "" {
+ writer, reader, errc = startTransformer()
+ } else {
+ fmt.Println("using default transformer")
+ writer, reader, errc = defaultTransformer()
+ }
+
+ st, index := rebuildStoreV2()
+ be := prepareBackend()
+ defer be.Close()
+
+ go func() {
+ writeStore(writer, st)
+ writer.Close()
+ }()
+
+ readKeys(reader, be)
+ mvcc.UpdateConsistentIndex(be, index)
+ err := <-errc
+ if err != nil {
+ fmt.Println("failed to transform keys")
+ ExitWithError(ExitError, err)
+ }
+
+ fmt.Println("finished transforming keys")
+}
+
+func prepareBackend() backend.Backend {
+ var be backend.Backend
+
+ bch := make(chan struct{})
+ dbpath := filepath.Join(migrateDatadir, "member", "snap", "db")
+ go func() {
+ defer close(bch)
+ be = backend.NewDefaultBackend(dbpath)
+
+ }()
+ select {
+ case <-bch:
+ case <-time.After(time.Second):
+ fmt.Fprintf(os.Stderr, "waiting for etcd to close and release its lock on %q\n", dbpath)
+ <-bch
+ }
+
+ tx := be.BatchTx()
+ tx.Lock()
+ tx.UnsafeCreateBucket([]byte("key"))
+ tx.UnsafeCreateBucket([]byte("meta"))
+ tx.Unlock()
+ return be
+}
+
+func rebuildStoreV2() (store.Store, uint64) {
+ var index uint64
+ cl := membership.NewCluster("")
+
+ waldir := migrateWALdir
+ if len(waldir) == 0 {
+ waldir = filepath.Join(migrateDatadir, "member", "wal")
+ }
+ snapdir := filepath.Join(migrateDatadir, "member", "snap")
+
+ ss := snap.New(snapdir)
+ snapshot, err := ss.Load()
+ if err != nil && err != snap.ErrNoSnapshot {
+ ExitWithError(ExitError, err)
+ }
+
+ var walsnap walpb.Snapshot
+ if snapshot != nil {
+ walsnap.Index, walsnap.Term = snapshot.Metadata.Index, snapshot.Metadata.Term
+ index = snapshot.Metadata.Index
+ }
+
+ w, err := wal.OpenForRead(waldir, walsnap)
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ defer w.Close()
+
+ _, _, ents, err := w.ReadAll()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ st := store.New()
+ if snapshot != nil {
+ err := st.Recovery(snapshot.Data)
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ }
+
+ cl.SetStore(st)
+ cl.Recover(api.UpdateCapability)
+
+ applier := etcdserver.NewApplierV2(st, cl)
+ for _, ent := range ents {
+ if ent.Type == raftpb.EntryConfChange {
+ var cc raftpb.ConfChange
+ pbutil.MustUnmarshal(&cc, ent.Data)
+ applyConf(cc, cl)
+ continue
+ }
+
+ var raftReq pb.InternalRaftRequest
+ if !pbutil.MaybeUnmarshal(&raftReq, ent.Data) { // backward compatible
+ var r pb.Request
+ pbutil.MustUnmarshal(&r, ent.Data)
+ applyRequest(&r, applier)
+ } else {
+ if raftReq.V2 != nil {
+ req := raftReq.V2
+ applyRequest(req, applier)
+ }
+ }
+ if ent.Index > index {
+ index = ent.Index
+ }
+ }
+
+ return st, index
+}
+
+func applyConf(cc raftpb.ConfChange, cl *membership.RaftCluster) {
+ if err := cl.ValidateConfigurationChange(cc); err != nil {
+ return
+ }
+ switch cc.Type {
+ case raftpb.ConfChangeAddNode:
+ m := new(membership.Member)
+ if err := json.Unmarshal(cc.Context, m); err != nil {
+ panic(err)
+ }
+ cl.AddMember(m)
+ case raftpb.ConfChangeRemoveNode:
+ cl.RemoveMember(types.ID(cc.NodeID))
+ case raftpb.ConfChangeUpdateNode:
+ m := new(membership.Member)
+ if err := json.Unmarshal(cc.Context, m); err != nil {
+ panic(err)
+ }
+ cl.UpdateRaftAttributes(m.ID, m.RaftAttributes)
+ }
+}
+
+func applyRequest(r *pb.Request, applyV2 etcdserver.ApplierV2) {
+ toTTLOptions(r)
+ switch r.Method {
+ case "POST":
+ applyV2.Post(r)
+ case "PUT":
+ applyV2.Put(r)
+ case "DELETE":
+ applyV2.Delete(r)
+ case "QGET":
+ applyV2.QGet(r)
+ case "SYNC":
+ applyV2.Sync(r)
+ default:
+ panic("unknown command")
+ }
+}
+
+func toTTLOptions(r *pb.Request) store.TTLOptionSet {
+ refresh, _ := pbutil.GetBool(r.Refresh)
+ ttlOptions := store.TTLOptionSet{Refresh: refresh}
+ if r.Expiration != 0 {
+ ttlOptions.ExpireTime = time.Unix(0, r.Expiration)
+ }
+ return ttlOptions
+}
+
+func writeStore(w io.Writer, st store.Store) uint64 {
+ all, err := st.Get("/1", true, true)
+ if err != nil {
+ if eerr, ok := err.(*etcdErr.Error); ok && eerr.ErrorCode == etcdErr.EcodeKeyNotFound {
+ fmt.Println("no v2 keys to migrate")
+ os.Exit(0)
+ }
+ ExitWithError(ExitError, err)
+ }
+ return writeKeys(w, all.Node)
+}
+
+func writeKeys(w io.Writer, n *store.NodeExtern) uint64 {
+ maxIndex := n.ModifiedIndex
+
+ nodes := n.Nodes
+ // remove store v2 bucket prefix
+ n.Key = n.Key[2:]
+ if n.Key == "" {
+ n.Key = "/"
+ }
+ if n.Dir {
+ n.Nodes = nil
+ }
+ if !migrateExcludeTTLKey || n.TTL == 0 {
+ b, err := json.Marshal(n)
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ fmt.Fprint(w, string(b))
+ }
+ for _, nn := range nodes {
+ max := writeKeys(w, nn)
+ if max > maxIndex {
+ maxIndex = max
+ }
+ }
+ return maxIndex
+}
+
+func readKeys(r io.Reader, be backend.Backend) error {
+ for {
+ length64, err := readInt64(r)
+ if err != nil {
+ if err == io.EOF {
+ return nil
+ }
+ return err
+ }
+
+ buf := make([]byte, int(length64))
+ if _, err = io.ReadFull(r, buf); err != nil {
+ return err
+ }
+
+ var kv mvccpb.KeyValue
+ err = proto.Unmarshal(buf, &kv)
+ if err != nil {
+ return err
+ }
+
+ mvcc.WriteKV(be, kv)
+ }
+}
+
+func readInt64(r io.Reader) (int64, error) {
+ var n int64
+ err := binary.Read(r, binary.LittleEndian, &n)
+ return n, err
+}
+
+func startTransformer() (io.WriteCloser, io.ReadCloser, chan error) {
+ cmd := exec.Command(migrateTransformer)
+ cmd.Stderr = os.Stderr
+
+ writer, err := cmd.StdinPipe()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ reader, rerr := cmd.StdoutPipe()
+ if rerr != nil {
+ ExitWithError(ExitError, rerr)
+ }
+
+ if err := cmd.Start(); err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ errc := make(chan error, 1)
+
+ go func() {
+ errc <- cmd.Wait()
+ }()
+
+ return writer, reader, errc
+}
+
+func defaultTransformer() (io.WriteCloser, io.ReadCloser, chan error) {
+ // transformer decodes v2 keys from sr
+ sr, sw := io.Pipe()
+ // transformer encodes v3 keys into dw
+ dr, dw := io.Pipe()
+
+ decoder := json.NewDecoder(sr)
+
+ errc := make(chan error, 1)
+
+ go func() {
+ defer func() {
+ sr.Close()
+ dw.Close()
+ }()
+
+ for decoder.More() {
+ node := &client.Node{}
+ if err := decoder.Decode(node); err != nil {
+ errc <- err
+ return
+ }
+
+ kv := transform(node)
+ if kv == nil {
+ continue
+ }
+
+ data, err := proto.Marshal(kv)
+ if err != nil {
+ errc <- err
+ return
+ }
+ buf := make([]byte, 8)
+ binary.LittleEndian.PutUint64(buf, uint64(len(data)))
+ if _, err := dw.Write(buf); err != nil {
+ errc <- err
+ return
+ }
+ if _, err := dw.Write(data); err != nil {
+ errc <- err
+ return
+ }
+ }
+
+ errc <- nil
+ }()
+
+ return sw, dr, errc
+}
+
+func transform(n *client.Node) *mvccpb.KeyValue {
+ const unKnownVersion = 1
+ if n.Dir {
+ return nil
+ }
+ kv := &mvccpb.KeyValue{
+ Key: []byte(n.Key),
+ Value: []byte(n.Value),
+ CreateRevision: int64(n.CreatedIndex),
+ ModRevision: int64(n.ModifiedIndex),
+ Version: unKnownVersion,
+ }
+ return kv
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer.go
new file mode 100644
index 00000000..ad29e75c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer.go
@@ -0,0 +1,191 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "errors"
+ "fmt"
+ "strings"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/dustin/go-humanize"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+type printer interface {
+ Del(v3.DeleteResponse)
+ Get(v3.GetResponse)
+ Put(v3.PutResponse)
+ Txn(v3.TxnResponse)
+ Watch(v3.WatchResponse)
+
+ Grant(r v3.LeaseGrantResponse)
+ Revoke(id v3.LeaseID, r v3.LeaseRevokeResponse)
+ KeepAlive(r v3.LeaseKeepAliveResponse)
+ TimeToLive(r v3.LeaseTimeToLiveResponse, keys bool)
+
+ MemberAdd(v3.MemberAddResponse)
+ MemberRemove(id uint64, r v3.MemberRemoveResponse)
+ MemberUpdate(id uint64, r v3.MemberUpdateResponse)
+ MemberList(v3.MemberListResponse)
+
+ EndpointStatus([]epStatus)
+
+ Alarm(v3.AlarmResponse)
+ DBStatus(dbstatus)
+
+ RoleAdd(role string, r v3.AuthRoleAddResponse)
+ RoleGet(role string, r v3.AuthRoleGetResponse)
+ RoleDelete(role string, r v3.AuthRoleDeleteResponse)
+ RoleList(v3.AuthRoleListResponse)
+ RoleGrantPermission(role string, r v3.AuthRoleGrantPermissionResponse)
+ RoleRevokePermission(role string, key string, end string, r v3.AuthRoleRevokePermissionResponse)
+
+ UserAdd(user string, r v3.AuthUserAddResponse)
+ UserGet(user string, r v3.AuthUserGetResponse)
+ UserList(r v3.AuthUserListResponse)
+ UserChangePassword(v3.AuthUserChangePasswordResponse)
+ UserGrantRole(user string, role string, r v3.AuthUserGrantRoleResponse)
+ UserRevokeRole(user string, role string, r v3.AuthUserRevokeRoleResponse)
+ UserDelete(user string, r v3.AuthUserDeleteResponse)
+}
+
+func NewPrinter(printerType string, isHex bool) printer {
+ switch printerType {
+ case "simple":
+ return &simplePrinter{isHex: isHex}
+ case "fields":
+ return &fieldsPrinter{newPrinterUnsupported("fields")}
+ case "json":
+ return newJSONPrinter()
+ case "protobuf":
+ return newPBPrinter()
+ case "table":
+ return &tablePrinter{newPrinterUnsupported("table")}
+ }
+ return nil
+}
+
+type printerRPC struct {
+ printer
+ p func(interface{})
+}
+
+func (p *printerRPC) Del(r v3.DeleteResponse) { p.p((*pb.DeleteRangeResponse)(&r)) }
+func (p *printerRPC) Get(r v3.GetResponse) { p.p((*pb.RangeResponse)(&r)) }
+func (p *printerRPC) Put(r v3.PutResponse) { p.p((*pb.PutResponse)(&r)) }
+func (p *printerRPC) Txn(r v3.TxnResponse) { p.p((*pb.TxnResponse)(&r)) }
+func (p *printerRPC) Watch(r v3.WatchResponse) { p.p(&r) }
+
+func (p *printerRPC) Grant(r v3.LeaseGrantResponse) { p.p(r) }
+func (p *printerRPC) Revoke(id v3.LeaseID, r v3.LeaseRevokeResponse) { p.p(r) }
+func (p *printerRPC) KeepAlive(r v3.LeaseKeepAliveResponse) { p.p(r) }
+func (p *printerRPC) TimeToLive(r v3.LeaseTimeToLiveResponse, keys bool) { p.p(&r) }
+
+func (p *printerRPC) MemberAdd(r v3.MemberAddResponse) { p.p((*pb.MemberAddResponse)(&r)) }
+func (p *printerRPC) MemberRemove(id uint64, r v3.MemberRemoveResponse) {
+ p.p((*pb.MemberRemoveResponse)(&r))
+}
+func (p *printerRPC) MemberUpdate(id uint64, r v3.MemberUpdateResponse) {
+ p.p((*pb.MemberUpdateResponse)(&r))
+}
+func (p *printerRPC) MemberList(r v3.MemberListResponse) { p.p((*pb.MemberListResponse)(&r)) }
+func (p *printerRPC) Alarm(r v3.AlarmResponse) { p.p((*pb.AlarmResponse)(&r)) }
+
+func (p *printerRPC) RoleAdd(_ string, r v3.AuthRoleAddResponse) { p.p((*pb.AuthRoleAddResponse)(&r)) }
+func (p *printerRPC) RoleGet(_ string, r v3.AuthRoleGetResponse) { p.p((*pb.AuthRoleGetResponse)(&r)) }
+func (p *printerRPC) RoleDelete(_ string, r v3.AuthRoleDeleteResponse) {
+ p.p((*pb.AuthRoleDeleteResponse)(&r))
+}
+func (p *printerRPC) RoleList(r v3.AuthRoleListResponse) { p.p((*pb.AuthRoleListResponse)(&r)) }
+func (p *printerRPC) RoleGrantPermission(_ string, r v3.AuthRoleGrantPermissionResponse) {
+ p.p((*pb.AuthRoleGrantPermissionResponse)(&r))
+}
+func (p *printerRPC) RoleRevokePermission(_ string, _ string, _ string, r v3.AuthRoleRevokePermissionResponse) {
+ p.p((*pb.AuthRoleRevokePermissionResponse)(&r))
+}
+func (p *printerRPC) UserAdd(_ string, r v3.AuthUserAddResponse) { p.p((*pb.AuthUserAddResponse)(&r)) }
+func (p *printerRPC) UserGet(_ string, r v3.AuthUserGetResponse) { p.p((*pb.AuthUserGetResponse)(&r)) }
+func (p *printerRPC) UserList(r v3.AuthUserListResponse) { p.p((*pb.AuthUserListResponse)(&r)) }
+func (p *printerRPC) UserChangePassword(r v3.AuthUserChangePasswordResponse) {
+ p.p((*pb.AuthUserChangePasswordResponse)(&r))
+}
+func (p *printerRPC) UserGrantRole(_ string, _ string, r v3.AuthUserGrantRoleResponse) {
+ p.p((*pb.AuthUserGrantRoleResponse)(&r))
+}
+func (p *printerRPC) UserRevokeRole(_ string, _ string, r v3.AuthUserRevokeRoleResponse) {
+ p.p((*pb.AuthUserRevokeRoleResponse)(&r))
+}
+func (p *printerRPC) UserDelete(_ string, r v3.AuthUserDeleteResponse) {
+ p.p((*pb.AuthUserDeleteResponse)(&r))
+}
+
+type printerUnsupported struct{ printerRPC }
+
+func newPrinterUnsupported(n string) printer {
+ f := func(interface{}) {
+ ExitWithError(ExitBadFeature, errors.New(n+" not supported as output format"))
+ }
+ return &printerUnsupported{printerRPC{nil, f}}
+}
+
+func (p *printerUnsupported) EndpointStatus([]epStatus) { p.p(nil) }
+func (p *printerUnsupported) DBStatus(dbstatus) { p.p(nil) }
+
+func makeMemberListTable(r v3.MemberListResponse) (hdr []string, rows [][]string) {
+ hdr = []string{"ID", "Status", "Name", "Peer Addrs", "Client Addrs"}
+ for _, m := range r.Members {
+ status := "started"
+ if len(m.Name) == 0 {
+ status = "unstarted"
+ }
+ rows = append(rows, []string{
+ fmt.Sprintf("%x", m.ID),
+ status,
+ m.Name,
+ strings.Join(m.PeerURLs, ","),
+ strings.Join(m.ClientURLs, ","),
+ })
+ }
+ return
+}
+
+func makeEndpointStatusTable(statusList []epStatus) (hdr []string, rows [][]string) {
+ hdr = []string{"endpoint", "ID", "version", "db size", "is leader", "raft term", "raft index"}
+ for _, status := range statusList {
+ rows = append(rows, []string{
+ status.Ep,
+ fmt.Sprintf("%x", status.Resp.Header.MemberId),
+ status.Resp.Version,
+ humanize.Bytes(uint64(status.Resp.DbSize)),
+ fmt.Sprint(status.Resp.Leader == status.Resp.Header.MemberId),
+ fmt.Sprint(status.Resp.RaftTerm),
+ fmt.Sprint(status.Resp.RaftIndex),
+ })
+ }
+ return
+}
+
+func makeDBStatusTable(ds dbstatus) (hdr []string, rows [][]string) {
+ hdr = []string{"hash", "revision", "total keys", "total size"}
+ rows = append(rows, []string{
+ fmt.Sprintf("%x", ds.Hash),
+ fmt.Sprint(ds.Revision),
+ fmt.Sprint(ds.TotalKey),
+ humanize.Bytes(uint64(ds.TotalSize)),
+ })
+ return
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_fields.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_fields.go
new file mode 100644
index 00000000..3e25a950
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_fields.go
@@ -0,0 +1,197 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ spb "github.com/coreos/etcd/mvcc/mvccpb"
+)
+
+type fieldsPrinter struct{ printer }
+
+func (p *fieldsPrinter) kv(pfx string, kv *spb.KeyValue) {
+ fmt.Printf("\"%sKey\" : %q\n", pfx, string(kv.Key))
+ fmt.Printf("\"%sCreateRevision\" : %d\n", pfx, kv.CreateRevision)
+ fmt.Printf("\"%sModRevision\" : %d\n", pfx, kv.ModRevision)
+ fmt.Printf("\"%sVersion\" : %d\n", pfx, kv.Version)
+ fmt.Printf("\"%sValue\" : %q\n", pfx, string(kv.Value))
+ fmt.Printf("\"%sLease\" : %d\n", pfx, kv.Lease)
+}
+
+func (p *fieldsPrinter) hdr(h *pb.ResponseHeader) {
+ fmt.Println(`"ClusterID" :`, h.ClusterId)
+ fmt.Println(`"MemberID" :`, h.MemberId)
+ fmt.Println(`"Revision" :`, h.Revision)
+ fmt.Println(`"RaftTerm" :`, h.RaftTerm)
+}
+
+func (p *fieldsPrinter) Del(r v3.DeleteResponse) {
+ p.hdr(r.Header)
+ fmt.Println(`"Deleted" :`, r.Deleted)
+ for _, kv := range r.PrevKvs {
+ p.kv("Prev", kv)
+ }
+}
+
+func (p *fieldsPrinter) Get(r v3.GetResponse) {
+ p.hdr(r.Header)
+ for _, kv := range r.Kvs {
+ p.kv("", kv)
+ }
+ fmt.Println(`"More" :`, r.More)
+ fmt.Println(`"Count" :`, r.Count)
+}
+
+func (p *fieldsPrinter) Put(r v3.PutResponse) {
+ p.hdr(r.Header)
+ if r.PrevKv != nil {
+ p.kv("Prev", r.PrevKv)
+ }
+}
+
+func (p *fieldsPrinter) Txn(r v3.TxnResponse) {
+ p.hdr(r.Header)
+ fmt.Println(`"Succeeded" :`, r.Succeeded)
+ for _, resp := range r.Responses {
+ switch v := resp.Response.(type) {
+ case *pb.ResponseOp_ResponseDeleteRange:
+ p.Del((v3.DeleteResponse)(*v.ResponseDeleteRange))
+ case *pb.ResponseOp_ResponsePut:
+ p.Put((v3.PutResponse)(*v.ResponsePut))
+ case *pb.ResponseOp_ResponseRange:
+ p.Get((v3.GetResponse)(*v.ResponseRange))
+ default:
+ fmt.Printf("\"Unknown\" : %q\n", fmt.Sprintf("%+v", v))
+ }
+ }
+}
+
+func (p *fieldsPrinter) Watch(resp v3.WatchResponse) {
+ p.hdr(&resp.Header)
+ for _, e := range resp.Events {
+ fmt.Println(`"Type" :`, e.Type)
+ if e.PrevKv != nil {
+ p.kv("Prev", e.PrevKv)
+ }
+ p.kv("", e.Kv)
+ }
+}
+
+func (p *fieldsPrinter) Grant(r v3.LeaseGrantResponse) {
+ p.hdr(r.ResponseHeader)
+ fmt.Println(`"ID" :`, r.ID)
+ fmt.Println(`"TTL" :`, r.TTL)
+}
+
+func (p *fieldsPrinter) Revoke(id v3.LeaseID, r v3.LeaseRevokeResponse) {
+ p.hdr(r.Header)
+}
+
+func (p *fieldsPrinter) KeepAlive(r v3.LeaseKeepAliveResponse) {
+ p.hdr(r.ResponseHeader)
+ fmt.Println(`"ID" :`, r.ID)
+ fmt.Println(`"TTL" :`, r.TTL)
+}
+
+func (p *fieldsPrinter) TimeToLive(r v3.LeaseTimeToLiveResponse, keys bool) {
+ p.hdr(r.ResponseHeader)
+ fmt.Println(`"ID" :`, r.ID)
+ fmt.Println(`"TTL" :`, r.TTL)
+ fmt.Println(`"GrantedTTL" :`, r.GrantedTTL)
+ for _, k := range r.Keys {
+ fmt.Printf("\"Key\" : %q\n", string(k))
+ }
+}
+
+func (p *fieldsPrinter) MemberList(r v3.MemberListResponse) {
+ p.hdr(r.Header)
+ for _, m := range r.Members {
+ fmt.Println(`"ID" :`, m.ID)
+ fmt.Printf("\"Name\" : %q\n", m.Name)
+ for _, u := range m.PeerURLs {
+ fmt.Printf("\"PeerURL\" : %q\n", u)
+ }
+ for _, u := range m.ClientURLs {
+ fmt.Printf("\"ClientURL\" : %q\n", u)
+ }
+ fmt.Println()
+ }
+}
+
+func (p *fieldsPrinter) EndpointStatus(eps []epStatus) {
+ for _, ep := range eps {
+ p.hdr(ep.Resp.Header)
+ fmt.Printf("\"Version\" : %q\n", ep.Resp.Version)
+ fmt.Println(`"DBSize" :`, ep.Resp.DbSize)
+ fmt.Println(`"Leader" :`, ep.Resp.Leader)
+ fmt.Println(`"RaftIndex" :`, ep.Resp.RaftIndex)
+ fmt.Println(`"RaftTerm" :`, ep.Resp.RaftTerm)
+ fmt.Printf("\"Endpoint\" : %q\n", ep.Ep)
+ fmt.Println()
+ }
+}
+
+func (p *fieldsPrinter) Alarm(r v3.AlarmResponse) {
+ p.hdr(r.Header)
+ for _, a := range r.Alarms {
+ fmt.Println(`"MemberID" :`, a.MemberID)
+ fmt.Println(`"AlarmType" :`, a.Alarm)
+ fmt.Println()
+ }
+}
+
+func (p *fieldsPrinter) DBStatus(r dbstatus) {
+ fmt.Println(`"Hash" :`, r.Hash)
+ fmt.Println(`"Revision" :`, r.Revision)
+ fmt.Println(`"Keys" :`, r.TotalKey)
+ fmt.Println(`"Size" :`, r.TotalSize)
+}
+
+func (p *fieldsPrinter) RoleAdd(role string, r v3.AuthRoleAddResponse) { p.hdr(r.Header) }
+func (p *fieldsPrinter) RoleGet(role string, r v3.AuthRoleGetResponse) {
+ p.hdr(r.Header)
+ for _, p := range r.Perm {
+ fmt.Println(`"PermType" : `, p.PermType.String())
+ fmt.Printf("\"Key\" : %q\n", string(p.Key))
+ fmt.Printf("\"RangeEnd\" : %q\n", string(p.RangeEnd))
+ }
+}
+func (p *fieldsPrinter) RoleDelete(role string, r v3.AuthRoleDeleteResponse) { p.hdr(r.Header) }
+func (p *fieldsPrinter) RoleList(r v3.AuthRoleListResponse) {
+ p.hdr(r.Header)
+ fmt.Printf(`"Roles" :`)
+ for _, r := range r.Roles {
+ fmt.Printf(" %q", r)
+ }
+ fmt.Println()
+}
+func (p *fieldsPrinter) RoleGrantPermission(role string, r v3.AuthRoleGrantPermissionResponse) {
+ p.hdr(r.Header)
+}
+func (p *fieldsPrinter) RoleRevokePermission(role string, key string, end string, r v3.AuthRoleRevokePermissionResponse) {
+ p.hdr(r.Header)
+}
+func (p *fieldsPrinter) UserAdd(user string, r v3.AuthUserAddResponse) { p.hdr(r.Header) }
+func (p *fieldsPrinter) UserChangePassword(r v3.AuthUserChangePasswordResponse) { p.hdr(r.Header) }
+func (p *fieldsPrinter) UserGrantRole(user string, role string, r v3.AuthUserGrantRoleResponse) {
+ p.hdr(r.Header)
+}
+func (p *fieldsPrinter) UserRevokeRole(user string, role string, r v3.AuthUserRevokeRoleResponse) {
+ p.hdr(r.Header)
+}
+func (p *fieldsPrinter) UserDelete(user string, r v3.AuthUserDeleteResponse) { p.hdr(r.Header) }
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_json.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_json.go
new file mode 100644
index 00000000..d5d884e5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_json.go
@@ -0,0 +1,41 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "encoding/json"
+ "fmt"
+ "os"
+)
+
+type jsonPrinter struct{ printer }
+
+func newJSONPrinter() printer {
+ return &jsonPrinter{
+ &printerRPC{newPrinterUnsupported("json"), printJSON},
+ }
+}
+
+func (p *jsonPrinter) EndpointStatus(r []epStatus) { printJSON(r) }
+func (p *jsonPrinter) DBStatus(r dbstatus) { printJSON(r) }
+
+func printJSON(v interface{}) {
+ b, err := json.Marshal(v)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "%v\n", err)
+ return
+ }
+ fmt.Println(string(b))
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_protobuf.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_protobuf.go
new file mode 100644
index 00000000..c5109c5c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_protobuf.go
@@ -0,0 +1,64 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "os"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ mvccpb "github.com/coreos/etcd/mvcc/mvccpb"
+)
+
+type pbPrinter struct{ printer }
+
+type pbMarshal interface {
+ Marshal() ([]byte, error)
+}
+
+func newPBPrinter() printer {
+ return &pbPrinter{
+ &printerRPC{newPrinterUnsupported("protobuf"), printPB},
+ }
+}
+
+func (p *pbPrinter) Watch(r v3.WatchResponse) {
+ evs := make([]*mvccpb.Event, len(r.Events))
+ for i, ev := range r.Events {
+ evs[i] = (*mvccpb.Event)(ev)
+ }
+ wr := pb.WatchResponse{
+ Header: &r.Header,
+ Events: evs,
+ CompactRevision: r.CompactRevision,
+ Canceled: r.Canceled,
+ Created: r.Created,
+ }
+ printPB(&wr)
+}
+
+func printPB(v interface{}) {
+ m, ok := v.(pbMarshal)
+ if !ok {
+ ExitWithError(ExitBadFeature, fmt.Errorf("marshal unsupported for type %T (%v)", v, v))
+ }
+ b, err := m.Marshal()
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "%v\n", err)
+ return
+ }
+ fmt.Print(string(b))
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_simple.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_simple.go
new file mode 100644
index 00000000..baa79e23
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_simple.go
@@ -0,0 +1,247 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "strings"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+type simplePrinter struct {
+ isHex bool
+ valueOnly bool
+}
+
+func (s *simplePrinter) Del(resp v3.DeleteResponse) {
+ fmt.Println(resp.Deleted)
+ for _, kv := range resp.PrevKvs {
+ printKV(s.isHex, s.valueOnly, kv)
+ }
+}
+
+func (s *simplePrinter) Get(resp v3.GetResponse) {
+ for _, kv := range resp.Kvs {
+ printKV(s.isHex, s.valueOnly, kv)
+ }
+}
+
+func (s *simplePrinter) Put(r v3.PutResponse) {
+ fmt.Println("OK")
+ if r.PrevKv != nil {
+ printKV(s.isHex, s.valueOnly, r.PrevKv)
+ }
+}
+
+func (s *simplePrinter) Txn(resp v3.TxnResponse) {
+ if resp.Succeeded {
+ fmt.Println("SUCCESS")
+ } else {
+ fmt.Println("FAILURE")
+ }
+
+ for _, r := range resp.Responses {
+ fmt.Println("")
+ switch v := r.Response.(type) {
+ case *pb.ResponseOp_ResponseDeleteRange:
+ s.Del((v3.DeleteResponse)(*v.ResponseDeleteRange))
+ case *pb.ResponseOp_ResponsePut:
+ s.Put((v3.PutResponse)(*v.ResponsePut))
+ case *pb.ResponseOp_ResponseRange:
+ s.Get(((v3.GetResponse)(*v.ResponseRange)))
+ default:
+ fmt.Printf("unexpected response %+v\n", r)
+ }
+ }
+}
+
+func (s *simplePrinter) Watch(resp v3.WatchResponse) {
+ for _, e := range resp.Events {
+ fmt.Println(e.Type)
+ if e.PrevKv != nil {
+ printKV(s.isHex, s.valueOnly, e.PrevKv)
+ }
+ printKV(s.isHex, s.valueOnly, e.Kv)
+ }
+}
+
+func (s *simplePrinter) Grant(resp v3.LeaseGrantResponse) {
+ fmt.Printf("lease %016x granted with TTL(%ds)\n", resp.ID, resp.TTL)
+}
+
+func (p *simplePrinter) Revoke(id v3.LeaseID, r v3.LeaseRevokeResponse) {
+ fmt.Printf("lease %016x revoked\n", id)
+}
+
+func (p *simplePrinter) KeepAlive(resp v3.LeaseKeepAliveResponse) {
+ fmt.Printf("lease %016x keepalived with TTL(%d)\n", resp.ID, resp.TTL)
+}
+
+func (s *simplePrinter) TimeToLive(resp v3.LeaseTimeToLiveResponse, keys bool) {
+ txt := fmt.Sprintf("lease %016x granted with TTL(%ds), remaining(%ds)", resp.ID, resp.GrantedTTL, resp.TTL)
+ if keys {
+ ks := make([]string, len(resp.Keys))
+ for i := range resp.Keys {
+ ks[i] = string(resp.Keys[i])
+ }
+ txt += fmt.Sprintf(", attached keys(%v)", ks)
+ }
+ fmt.Println(txt)
+}
+
+func (s *simplePrinter) Alarm(resp v3.AlarmResponse) {
+ for _, e := range resp.Alarms {
+ fmt.Printf("%+v\n", e)
+ }
+}
+
+func (s *simplePrinter) MemberAdd(r v3.MemberAddResponse) {
+ fmt.Printf("Member %16x added to cluster %16x\n", r.Member.ID, r.Header.ClusterId)
+}
+
+func (s *simplePrinter) MemberRemove(id uint64, r v3.MemberRemoveResponse) {
+ fmt.Printf("Member %16x removed from cluster %16x\n", id, r.Header.ClusterId)
+}
+
+func (s *simplePrinter) MemberUpdate(id uint64, r v3.MemberUpdateResponse) {
+ fmt.Printf("Member %16x updated in cluster %16x\n", id, r.Header.ClusterId)
+}
+
+func (s *simplePrinter) MemberList(resp v3.MemberListResponse) {
+ _, rows := makeMemberListTable(resp)
+ for _, row := range rows {
+ fmt.Println(strings.Join(row, ", "))
+ }
+}
+
+func (s *simplePrinter) EndpointStatus(statusList []epStatus) {
+ _, rows := makeEndpointStatusTable(statusList)
+ for _, row := range rows {
+ fmt.Println(strings.Join(row, ", "))
+ }
+}
+
+func (s *simplePrinter) DBStatus(ds dbstatus) {
+ _, rows := makeDBStatusTable(ds)
+ for _, row := range rows {
+ fmt.Println(strings.Join(row, ", "))
+ }
+}
+
+func (s *simplePrinter) RoleAdd(role string, r v3.AuthRoleAddResponse) {
+ fmt.Printf("Role %s created\n", role)
+}
+
+func (s *simplePrinter) RoleGet(role string, r v3.AuthRoleGetResponse) {
+ fmt.Printf("Role %s\n", role)
+ fmt.Println("KV Read:")
+
+ printRange := func(perm *v3.Permission) {
+ sKey := string(perm.Key)
+ sRangeEnd := string(perm.RangeEnd)
+ if strings.Compare(sRangeEnd, "\x00") != 0 {
+ fmt.Printf("\t[%s, %s)", sKey, sRangeEnd)
+ } else {
+ fmt.Printf("\t[%s, <open ended>", sKey)
+ }
+ if strings.Compare(v3.GetPrefixRangeEnd(sKey), sRangeEnd) == 0 {
+ fmt.Printf(" (prefix %s)", sKey)
+ }
+ fmt.Printf("\n")
+ }
+
+ for _, perm := range r.Perm {
+ if perm.PermType == v3.PermRead || perm.PermType == v3.PermReadWrite {
+ if len(perm.RangeEnd) == 0 {
+ fmt.Printf("\t%s\n", string(perm.Key))
+ } else {
+ printRange((*v3.Permission)(perm))
+ }
+ }
+ }
+ fmt.Println("KV Write:")
+ for _, perm := range r.Perm {
+ if perm.PermType == v3.PermWrite || perm.PermType == v3.PermReadWrite {
+ if len(perm.RangeEnd) == 0 {
+ fmt.Printf("\t%s\n", string(perm.Key))
+ } else {
+ printRange((*v3.Permission)(perm))
+ }
+ }
+ }
+}
+
+func (s *simplePrinter) RoleList(r v3.AuthRoleListResponse) {
+ for _, role := range r.Roles {
+ fmt.Printf("%s\n", role)
+ }
+}
+
+func (s *simplePrinter) RoleDelete(role string, r v3.AuthRoleDeleteResponse) {
+ fmt.Printf("Role %s deleted\n", role)
+}
+
+func (s *simplePrinter) RoleGrantPermission(role string, r v3.AuthRoleGrantPermissionResponse) {
+ fmt.Printf("Role %s updated\n", role)
+}
+
+func (s *simplePrinter) RoleRevokePermission(role string, key string, end string, r v3.AuthRoleRevokePermissionResponse) {
+ if len(end) == 0 {
+ fmt.Printf("Permission of key %s is revoked from role %s\n", key, role)
+ return
+ }
+ if strings.Compare(end, "\x00") != 0 {
+ fmt.Printf("Permission of range [%s, %s) is revoked from role %s\n", key, end, role)
+ } else {
+ fmt.Printf("Permission of range [%s, <open ended> is revoked from role %s\n", key, role)
+ }
+}
+
+func (s *simplePrinter) UserAdd(name string, r v3.AuthUserAddResponse) {
+ fmt.Printf("User %s created\n", name)
+}
+
+func (s *simplePrinter) UserGet(name string, r v3.AuthUserGetResponse) {
+ fmt.Printf("User: %s\n", name)
+ fmt.Printf("Roles:")
+ for _, role := range r.Roles {
+ fmt.Printf(" %s", role)
+ }
+ fmt.Printf("\n")
+}
+
+func (s *simplePrinter) UserChangePassword(v3.AuthUserChangePasswordResponse) {
+ fmt.Println("Password updated")
+}
+
+func (s *simplePrinter) UserGrantRole(user string, role string, r v3.AuthUserGrantRoleResponse) {
+ fmt.Printf("Role %s is granted to user %s\n", role, user)
+}
+
+func (s *simplePrinter) UserRevokeRole(user string, role string, r v3.AuthUserRevokeRoleResponse) {
+ fmt.Printf("Role %s is revoked from user %s\n", role, user)
+}
+
+func (s *simplePrinter) UserDelete(user string, r v3.AuthUserDeleteResponse) {
+ fmt.Printf("User %s deleted\n", user)
+}
+
+func (s *simplePrinter) UserList(r v3.AuthUserListResponse) {
+ for _, user := range r.Users {
+ fmt.Printf("%s\n", user)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_table.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_table.go
new file mode 100644
index 00000000..fb85c584
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/printer_table.go
@@ -0,0 +1,56 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "os"
+
+ "github.com/olekukonko/tablewriter"
+
+ v3 "github.com/coreos/etcd/clientv3"
+)
+
+type tablePrinter struct{ printer }
+
+func (tp *tablePrinter) MemberList(r v3.MemberListResponse) {
+ hdr, rows := makeMemberListTable(r)
+ table := tablewriter.NewWriter(os.Stdout)
+ table.SetHeader(hdr)
+ for _, row := range rows {
+ table.Append(row)
+ }
+ table.SetAlignment(tablewriter.ALIGN_RIGHT)
+ table.Render()
+}
+func (tp *tablePrinter) EndpointStatus(r []epStatus) {
+ hdr, rows := makeEndpointStatusTable(r)
+ table := tablewriter.NewWriter(os.Stdout)
+ table.SetHeader(hdr)
+ for _, row := range rows {
+ table.Append(row)
+ }
+ table.SetAlignment(tablewriter.ALIGN_RIGHT)
+ table.Render()
+}
+func (tp *tablePrinter) DBStatus(r dbstatus) {
+ hdr, rows := makeDBStatusTable(r)
+ table := tablewriter.NewWriter(os.Stdout)
+ table.SetHeader(hdr)
+ for _, row := range rows {
+ table.Append(row)
+ }
+ table.SetAlignment(tablewriter.ALIGN_RIGHT)
+ table.Render()
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/put_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/put_command.go
new file mode 100644
index 00000000..a72f0c4d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/put_command.go
@@ -0,0 +1,118 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "os"
+ "strconv"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/spf13/cobra"
+)
+
+var (
+ leaseStr string
+ putPrevKV bool
+ putIgnoreVal bool
+ putIgnoreLease bool
+)
+
+// NewPutCommand returns the cobra command for "put".
+func NewPutCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "put [options] <key> <value> (<value> can also be given from stdin)",
+ Short: "Puts the given key into the store",
+ Long: `
+Puts the given key into the store.
+
+When <value> begins with '-', <value> is interpreted as a flag.
+Insert '--' for workaround:
+
+$ put <key> -- <value>
+$ put -- <key> <value>
+
+If <value> isn't given as a command line argument and '--ignore-value' is not specified,
+this command tries to read the value from standard input.
+
+If <lease> isn't given as a command line argument and '--ignore-lease' is not specified,
+this command tries to read the value from standard input.
+
+For example,
+$ cat file | put <key>
+will store the content of the file to <key>.
+`,
+ Run: putCommandFunc,
+ }
+ cmd.Flags().StringVar(&leaseStr, "lease", "0", "lease ID (in hexadecimal) to attach to the key")
+ cmd.Flags().BoolVar(&putPrevKV, "prev-kv", false, "return the previous key-value pair before modification")
+ cmd.Flags().BoolVar(&putIgnoreVal, "ignore-value", false, "updates the key using its current value")
+ cmd.Flags().BoolVar(&putIgnoreLease, "ignore-lease", false, "updates the key using its current lease")
+ return cmd
+}
+
+// putCommandFunc executes the "put" command.
+func putCommandFunc(cmd *cobra.Command, args []string) {
+ key, value, opts := getPutOp(cmd, args)
+
+ ctx, cancel := commandCtx(cmd)
+ resp, err := mustClientFromCmd(cmd).Put(ctx, key, value, opts...)
+ cancel()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ display.Put(*resp)
+}
+
+func getPutOp(cmd *cobra.Command, args []string) (string, string, []clientv3.OpOption) {
+ if len(args) == 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("put command needs 1 argument and input from stdin or 2 arguments."))
+ }
+
+ key := args[0]
+ if putIgnoreVal && len(args) > 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("put command needs only 1 argument when 'ignore-value' is set."))
+ }
+
+ var value string
+ var err error
+ if !putIgnoreVal {
+ value, err = argOrStdin(args, os.Stdin, 1)
+ if err != nil {
+ ExitWithError(ExitBadArgs, fmt.Errorf("put command needs 1 argument and input from stdin or 2 arguments."))
+ }
+ }
+
+ id, err := strconv.ParseInt(leaseStr, 16, 64)
+ if err != nil {
+ ExitWithError(ExitBadArgs, fmt.Errorf("bad lease ID (%v), expecting ID in Hex", err))
+ }
+
+ opts := []clientv3.OpOption{}
+ if id != 0 {
+ opts = append(opts, clientv3.WithLease(clientv3.LeaseID(id)))
+ }
+ if putPrevKV {
+ opts = append(opts, clientv3.WithPrevKV())
+ }
+ if putIgnoreVal {
+ opts = append(opts, clientv3.WithIgnoreValue())
+ }
+ if putIgnoreLease {
+ opts = append(opts, clientv3.WithIgnoreLease())
+ }
+
+ return key, value, opts
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/role_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/role_command.go
new file mode 100644
index 00000000..b467a563
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/role_command.go
@@ -0,0 +1,223 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+)
+
+var (
+ rolePermPrefix bool
+ rolePermFromKey bool
+)
+
+// NewRoleCommand returns the cobra command for "role".
+func NewRoleCommand() *cobra.Command {
+ ac := &cobra.Command{
+ Use: "role <subcommand>",
+ Short: "Role related commands",
+ }
+
+ ac.AddCommand(newRoleAddCommand())
+ ac.AddCommand(newRoleDeleteCommand())
+ ac.AddCommand(newRoleGetCommand())
+ ac.AddCommand(newRoleListCommand())
+ ac.AddCommand(newRoleGrantPermissionCommand())
+ ac.AddCommand(newRoleRevokePermissionCommand())
+
+ return ac
+}
+
+func newRoleAddCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "add <role name>",
+ Short: "Adds a new role",
+ Run: roleAddCommandFunc,
+ }
+}
+
+func newRoleDeleteCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "delete <role name>",
+ Short: "Deletes a role",
+ Run: roleDeleteCommandFunc,
+ }
+}
+
+func newRoleGetCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "get <role name>",
+ Short: "Gets detailed information of a role",
+ Run: roleGetCommandFunc,
+ }
+}
+
+func newRoleListCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "list",
+ Short: "Lists all roles",
+ Run: roleListCommandFunc,
+ }
+}
+
+func newRoleGrantPermissionCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "grant-permission [options] <role name> <permission type> <key> [endkey]",
+ Short: "Grants a key to a role",
+ Run: roleGrantPermissionCommandFunc,
+ }
+
+ cmd.Flags().BoolVar(&rolePermPrefix, "prefix", false, "grant a prefix permission")
+ cmd.Flags().BoolVar(&rolePermFromKey, "from-key", false, "grant a permission of keys that are greater than or equal to the given key using byte compare")
+
+ return cmd
+}
+
+func newRoleRevokePermissionCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "revoke-permission <role name> <key> [endkey]",
+ Short: "Revokes a key from a role",
+ Run: roleRevokePermissionCommandFunc,
+ }
+
+ cmd.Flags().BoolVar(&rolePermPrefix, "prefix", false, "revoke a prefix permission")
+ cmd.Flags().BoolVar(&rolePermFromKey, "from-key", false, "revoke a permission of keys that are greater than or equal to the given key using byte compare")
+
+ return cmd
+}
+
+// roleAddCommandFunc executes the "role add" command.
+func roleAddCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("role add command requires role name as its argument."))
+ }
+
+ resp, err := mustClientFromCmd(cmd).Auth.RoleAdd(context.TODO(), args[0])
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ display.RoleAdd(args[0], *resp)
+}
+
+// roleDeleteCommandFunc executes the "role delete" command.
+func roleDeleteCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("role delete command requires role name as its argument."))
+ }
+
+ resp, err := mustClientFromCmd(cmd).Auth.RoleDelete(context.TODO(), args[0])
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ display.RoleDelete(args[0], *resp)
+}
+
+// roleGetCommandFunc executes the "role get" command.
+func roleGetCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("role get command requires role name as its argument."))
+ }
+
+ name := args[0]
+ resp, err := mustClientFromCmd(cmd).Auth.RoleGet(context.TODO(), name)
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ display.RoleGet(name, *resp)
+}
+
+// roleListCommandFunc executes the "role list" command.
+func roleListCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("role list command requires no arguments."))
+ }
+
+ resp, err := mustClientFromCmd(cmd).Auth.RoleList(context.TODO())
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ display.RoleList(*resp)
+}
+
+// roleGrantPermissionCommandFunc executes the "role grant-permission" command.
+func roleGrantPermissionCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) < 3 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("role grant command requires role name, permission type, and key [endkey] as its argument."))
+ }
+
+ perm, err := clientv3.StrToPermissionType(args[1])
+ if err != nil {
+ ExitWithError(ExitBadArgs, err)
+ }
+
+ rangeEnd, rerr := rangeEndFromPermFlags(args[2:])
+ if rerr != nil {
+ ExitWithError(ExitBadArgs, rerr)
+ }
+ resp, err := mustClientFromCmd(cmd).Auth.RoleGrantPermission(context.TODO(), args[0], args[2], rangeEnd, perm)
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ display.RoleGrantPermission(args[0], *resp)
+}
+
+// roleRevokePermissionCommandFunc executes the "role revoke-permission" command.
+func roleRevokePermissionCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) < 2 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("role revoke-permission command requires role name and key [endkey] as its argument."))
+ }
+
+ rangeEnd, rerr := rangeEndFromPermFlags(args[1:])
+ if rerr != nil {
+ ExitWithError(ExitBadArgs, rerr)
+ }
+ resp, err := mustClientFromCmd(cmd).Auth.RoleRevokePermission(context.TODO(), args[0], args[1], rangeEnd)
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ display.RoleRevokePermission(args[0], args[1], rangeEnd, *resp)
+}
+
+func rangeEndFromPermFlags(args []string) (string, error) {
+ if len(args) == 1 {
+ if rolePermPrefix {
+ if rolePermFromKey {
+ return "", fmt.Errorf("--from-key and --prefix flags are mutually exclusive")
+ }
+ return clientv3.GetPrefixRangeEnd(args[0]), nil
+ }
+ if rolePermFromKey {
+ return "\x00", nil
+ }
+ // single key case
+ return "", nil
+ }
+ if rolePermPrefix {
+ return "", fmt.Errorf("unexpected endkey argument with --prefix flag")
+ }
+ if rolePermFromKey {
+ return "", fmt.Errorf("unexpected endkey argument with --from-key flag")
+ }
+ return args[1], nil
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/snapshot_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/snapshot_command.go
new file mode 100644
index 00000000..eb8630fd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/snapshot_command.go
@@ -0,0 +1,460 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "crypto/sha256"
+ "encoding/binary"
+ "encoding/json"
+ "fmt"
+ "hash/crc32"
+ "io"
+ "math"
+ "os"
+ "path/filepath"
+ "reflect"
+ "strings"
+
+ "github.com/boltdb/bolt"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/pkg/fileutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/snap"
+ "github.com/coreos/etcd/store"
+ "github.com/coreos/etcd/wal"
+ "github.com/coreos/etcd/wal/walpb"
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+)
+
+const (
+ defaultName = "default"
+ defaultInitialAdvertisePeerURLs = "http://localhost:2380"
+)
+
+var (
+ restoreCluster string
+ restoreClusterToken string
+ restoreDataDir string
+ restorePeerURLs string
+ restoreName string
+ skipHashCheck bool
+)
+
+// NewSnapshotCommand returns the cobra command for "snapshot".
+func NewSnapshotCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "snapshot <subcommand>",
+ Short: "Manages etcd node snapshots",
+ }
+ cmd.AddCommand(NewSnapshotSaveCommand())
+ cmd.AddCommand(NewSnapshotRestoreCommand())
+ cmd.AddCommand(newSnapshotStatusCommand())
+ return cmd
+}
+
+func NewSnapshotSaveCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "save <filename>",
+ Short: "Stores an etcd node backend snapshot to a given file",
+ Run: snapshotSaveCommandFunc,
+ }
+}
+
+func newSnapshotStatusCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "status <filename>",
+ Short: "Gets backend snapshot status of a given file",
+ Long: `When --write-out is set to simple, this command prints out comma-separated status lists for each endpoint.
+The items in the lists are hash, revision, total keys, total size.
+`,
+ Run: snapshotStatusCommandFunc,
+ }
+}
+
+func NewSnapshotRestoreCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "restore <filename> [options]",
+ Short: "Restores an etcd member snapshot to an etcd directory",
+ Run: snapshotRestoreCommandFunc,
+ }
+ cmd.Flags().StringVar(&restoreDataDir, "data-dir", "", "Path to the data directory")
+ cmd.Flags().StringVar(&restoreCluster, "initial-cluster", initialClusterFromName(defaultName), "Initial cluster configuration for restore bootstrap")
+ cmd.Flags().StringVar(&restoreClusterToken, "initial-cluster-token", "etcd-cluster", "Initial cluster token for the etcd cluster during restore bootstrap")
+ cmd.Flags().StringVar(&restorePeerURLs, "initial-advertise-peer-urls", defaultInitialAdvertisePeerURLs, "List of this member's peer URLs to advertise to the rest of the cluster")
+ cmd.Flags().StringVar(&restoreName, "name", defaultName, "Human-readable name for this member")
+ cmd.Flags().BoolVar(&skipHashCheck, "skip-hash-check", false, "Ignore snapshot integrity hash value (required if copied from data directory)")
+
+ return cmd
+}
+
+func snapshotSaveCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ err := fmt.Errorf("snapshot save expects one argument")
+ ExitWithError(ExitBadArgs, err)
+ }
+
+ path := args[0]
+
+ partpath := path + ".part"
+ f, err := os.Create(partpath)
+
+ if err != nil {
+ exiterr := fmt.Errorf("could not open %s (%v)", partpath, err)
+ ExitWithError(ExitBadArgs, exiterr)
+ }
+
+ c := mustClientFromCmd(cmd)
+ r, serr := c.Snapshot(context.TODO())
+ if serr != nil {
+ os.RemoveAll(partpath)
+ ExitWithError(ExitInterrupted, serr)
+ }
+ if _, rerr := io.Copy(f, r); rerr != nil {
+ os.RemoveAll(partpath)
+ ExitWithError(ExitInterrupted, rerr)
+ }
+
+ fileutil.Fsync(f)
+
+ f.Close()
+
+ if rerr := os.Rename(partpath, path); rerr != nil {
+ exiterr := fmt.Errorf("could not rename %s to %s (%v)", partpath, path, rerr)
+ ExitWithError(ExitIO, exiterr)
+ }
+ fmt.Printf("Snapshot saved at %s\n", path)
+}
+
+func snapshotStatusCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ err := fmt.Errorf("snapshot status requires exactly one argument")
+ ExitWithError(ExitBadArgs, err)
+ }
+ initDisplayFromCmd(cmd)
+ ds := dbStatus(args[0])
+ display.DBStatus(ds)
+}
+
+func snapshotRestoreCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ err := fmt.Errorf("snapshot restore requires exactly one argument")
+ ExitWithError(ExitBadArgs, err)
+ }
+
+ urlmap, uerr := types.NewURLsMap(restoreCluster)
+ if uerr != nil {
+ ExitWithError(ExitBadArgs, uerr)
+ }
+
+ cfg := etcdserver.ServerConfig{
+ InitialClusterToken: restoreClusterToken,
+ InitialPeerURLsMap: urlmap,
+ PeerURLs: types.MustNewURLs(strings.Split(restorePeerURLs, ",")),
+ Name: restoreName,
+ }
+ if err := cfg.VerifyBootstrap(); err != nil {
+ ExitWithError(ExitBadArgs, err)
+ }
+
+ cl, cerr := membership.NewClusterFromURLsMap(restoreClusterToken, urlmap)
+ if cerr != nil {
+ ExitWithError(ExitBadArgs, cerr)
+ }
+
+ basedir := restoreDataDir
+ if basedir == "" {
+ basedir = restoreName + ".etcd"
+ }
+
+ waldir := filepath.Join(basedir, "member", "wal")
+ snapdir := filepath.Join(basedir, "member", "snap")
+
+ if _, err := os.Stat(basedir); err == nil {
+ ExitWithError(ExitInvalidInput, fmt.Errorf("data-dir %q exists", basedir))
+ }
+
+ makeDB(snapdir, args[0], len(cl.Members()))
+ makeWALAndSnap(waldir, snapdir, cl)
+}
+
+func initialClusterFromName(name string) string {
+ n := name
+ if name == "" {
+ n = defaultName
+ }
+ return fmt.Sprintf("%s=http://localhost:2380", n)
+}
+
+// makeWAL creates a WAL for the initial cluster
+func makeWALAndSnap(waldir, snapdir string, cl *membership.RaftCluster) {
+ if err := fileutil.CreateDirAll(waldir); err != nil {
+ ExitWithError(ExitIO, err)
+ }
+
+ // add members again to persist them to the store we create.
+ st := store.New(etcdserver.StoreClusterPrefix, etcdserver.StoreKeysPrefix)
+ cl.SetStore(st)
+ for _, m := range cl.Members() {
+ cl.AddMember(m)
+ }
+
+ m := cl.MemberByName(restoreName)
+ md := &etcdserverpb.Metadata{NodeID: uint64(m.ID), ClusterID: uint64(cl.ID())}
+ metadata, merr := md.Marshal()
+ if merr != nil {
+ ExitWithError(ExitInvalidInput, merr)
+ }
+
+ w, walerr := wal.Create(waldir, metadata)
+ if walerr != nil {
+ ExitWithError(ExitIO, walerr)
+ }
+ defer w.Close()
+
+ peers := make([]raft.Peer, len(cl.MemberIDs()))
+ for i, id := range cl.MemberIDs() {
+ ctx, err := json.Marshal((*cl).Member(id))
+ if err != nil {
+ ExitWithError(ExitInvalidInput, err)
+ }
+ peers[i] = raft.Peer{ID: uint64(id), Context: ctx}
+ }
+
+ ents := make([]raftpb.Entry, len(peers))
+ nodeIDs := make([]uint64, len(peers))
+ for i, p := range peers {
+ nodeIDs[i] = p.ID
+ cc := raftpb.ConfChange{
+ Type: raftpb.ConfChangeAddNode,
+ NodeID: p.ID,
+ Context: p.Context}
+ d, err := cc.Marshal()
+ if err != nil {
+ ExitWithError(ExitInvalidInput, err)
+ }
+ e := raftpb.Entry{
+ Type: raftpb.EntryConfChange,
+ Term: 1,
+ Index: uint64(i + 1),
+ Data: d,
+ }
+ ents[i] = e
+ }
+
+ commit, term := uint64(len(ents)), uint64(1)
+
+ if err := w.Save(raftpb.HardState{
+ Term: term,
+ Vote: peers[0].ID,
+ Commit: commit}, ents); err != nil {
+ ExitWithError(ExitIO, err)
+ }
+
+ b, berr := st.Save()
+ if berr != nil {
+ ExitWithError(ExitError, berr)
+ }
+
+ raftSnap := raftpb.Snapshot{
+ Data: b,
+ Metadata: raftpb.SnapshotMetadata{
+ Index: commit,
+ Term: term,
+ ConfState: raftpb.ConfState{
+ Nodes: nodeIDs,
+ },
+ },
+ }
+ snapshotter := snap.New(snapdir)
+ if err := snapshotter.SaveSnap(raftSnap); err != nil {
+ panic(err)
+ }
+
+ if err := w.SaveSnapshot(walpb.Snapshot{Index: commit, Term: term}); err != nil {
+ ExitWithError(ExitIO, err)
+ }
+}
+
+// initIndex implements ConsistentIndexGetter so the snapshot won't block
+// the new raft instance by waiting for a future raft index.
+type initIndex int
+
+func (i *initIndex) ConsistentIndex() uint64 { return uint64(*i) }
+
+// makeDB copies the database snapshot to the snapshot directory
+func makeDB(snapdir, dbfile string, commit int) {
+ f, ferr := os.OpenFile(dbfile, os.O_RDONLY, 0600)
+ if ferr != nil {
+ ExitWithError(ExitInvalidInput, ferr)
+ }
+ defer f.Close()
+
+ // get snapshot integrity hash
+ if _, err := f.Seek(-sha256.Size, io.SeekEnd); err != nil {
+ ExitWithError(ExitIO, err)
+ }
+ sha := make([]byte, sha256.Size)
+ if _, err := f.Read(sha); err != nil {
+ ExitWithError(ExitIO, err)
+ }
+ if _, err := f.Seek(0, io.SeekStart); err != nil {
+ ExitWithError(ExitIO, err)
+ }
+
+ if err := fileutil.CreateDirAll(snapdir); err != nil {
+ ExitWithError(ExitIO, err)
+ }
+
+ dbpath := filepath.Join(snapdir, "db")
+ db, dberr := os.OpenFile(dbpath, os.O_RDWR|os.O_CREATE, 0600)
+ if dberr != nil {
+ ExitWithError(ExitIO, dberr)
+ }
+ if _, err := io.Copy(db, f); err != nil {
+ ExitWithError(ExitIO, err)
+ }
+
+ // truncate away integrity hash, if any.
+ off, serr := db.Seek(0, io.SeekEnd)
+ if serr != nil {
+ ExitWithError(ExitIO, serr)
+ }
+ hasHash := (off % 512) == sha256.Size
+ if hasHash {
+ if err := db.Truncate(off - sha256.Size); err != nil {
+ ExitWithError(ExitIO, err)
+ }
+ }
+
+ if !hasHash && !skipHashCheck {
+ err := fmt.Errorf("snapshot missing hash but --skip-hash-check=false")
+ ExitWithError(ExitBadArgs, err)
+ }
+
+ if hasHash && !skipHashCheck {
+ // check for match
+ if _, err := db.Seek(0, io.SeekStart); err != nil {
+ ExitWithError(ExitIO, err)
+ }
+ h := sha256.New()
+ if _, err := io.Copy(h, db); err != nil {
+ ExitWithError(ExitIO, err)
+ }
+ dbsha := h.Sum(nil)
+ if !reflect.DeepEqual(sha, dbsha) {
+ err := fmt.Errorf("expected sha256 %v, got %v", sha, dbsha)
+ ExitWithError(ExitInvalidInput, err)
+ }
+ }
+
+ // db hash is OK, can now modify DB so it can be part of a new cluster
+ db.Close()
+
+ // update consistentIndex so applies go through on etcdserver despite
+ // having a new raft instance
+ be := backend.NewDefaultBackend(dbpath)
+ // a lessor never timeouts leases
+ lessor := lease.NewLessor(be, math.MaxInt64)
+ s := mvcc.NewStore(be, lessor, (*initIndex)(&commit))
+ txn := s.Write()
+ btx := be.BatchTx()
+ del := func(k, v []byte) error {
+ txn.DeleteRange(k, nil)
+ return nil
+ }
+
+ // delete stored members from old cluster since using new members
+ btx.UnsafeForEach([]byte("members"), del)
+ // todo: add back new members when we start to deprecate old snap file.
+ btx.UnsafeForEach([]byte("members_removed"), del)
+ // trigger write-out of new consistent index
+ txn.End()
+ s.Commit()
+ s.Close()
+}
+
+type dbstatus struct {
+ Hash uint32 `json:"hash"`
+ Revision int64 `json:"revision"`
+ TotalKey int `json:"totalKey"`
+ TotalSize int64 `json:"totalSize"`
+}
+
+func dbStatus(p string) dbstatus {
+ if _, err := os.Stat(p); err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ ds := dbstatus{}
+
+ db, err := bolt.Open(p, 0400, nil)
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ defer db.Close()
+
+ h := crc32.New(crc32.MakeTable(crc32.Castagnoli))
+
+ err = db.View(func(tx *bolt.Tx) error {
+ ds.TotalSize = tx.Size()
+ c := tx.Cursor()
+ for next, _ := c.First(); next != nil; next, _ = c.Next() {
+ b := tx.Bucket(next)
+ if b == nil {
+ return fmt.Errorf("cannot get hash of bucket %s", string(next))
+ }
+ h.Write(next)
+ iskeyb := (string(next) == "key")
+ b.ForEach(func(k, v []byte) error {
+ h.Write(k)
+ h.Write(v)
+ if iskeyb {
+ rev := bytesToRev(k)
+ ds.Revision = rev.main
+ }
+ ds.TotalKey++
+ return nil
+ })
+ }
+ return nil
+ })
+
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ ds.Hash = h.Sum32()
+ return ds
+}
+
+type revision struct {
+ main int64
+ sub int64
+}
+
+func bytesToRev(bytes []byte) revision {
+ return revision{
+ main: int64(binary.BigEndian.Uint64(bytes[0:8])),
+ sub: int64(binary.BigEndian.Uint64(bytes[9:])),
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/txn_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/txn_command.go
new file mode 100644
index 00000000..d5e75b05
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/txn_command.go
@@ -0,0 +1,205 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "bufio"
+ "fmt"
+ "os"
+ "strconv"
+ "strings"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+)
+
+var (
+ txnInteractive bool
+)
+
+// NewTxnCommand returns the cobra command for "txn".
+func NewTxnCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "txn [options]",
+ Short: "Txn processes all the requests in one transaction",
+ Run: txnCommandFunc,
+ }
+ cmd.Flags().BoolVarP(&txnInteractive, "interactive", "i", false, "Input transaction in interactive mode")
+ return cmd
+}
+
+// txnCommandFunc executes the "txn" command.
+func txnCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("txn command does not accept argument."))
+ }
+
+ reader := bufio.NewReader(os.Stdin)
+
+ txn := mustClientFromCmd(cmd).Txn(context.Background())
+ promptInteractive("compares:")
+ txn.If(readCompares(reader)...)
+ promptInteractive("success requests (get, put, delete):")
+ txn.Then(readOps(reader)...)
+ promptInteractive("failure requests (get, put, delete):")
+ txn.Else(readOps(reader)...)
+
+ resp, err := txn.Commit()
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ display.Txn(*resp)
+}
+
+func promptInteractive(s string) {
+ if txnInteractive {
+ fmt.Println(s)
+ }
+}
+
+func readCompares(r *bufio.Reader) (cmps []clientv3.Cmp) {
+ for {
+ line, err := r.ReadString('\n')
+ if err != nil {
+ ExitWithError(ExitInvalidInput, err)
+ }
+
+ // remove space from the line
+ line = strings.TrimSpace(line)
+ if len(line) == 0 {
+ break
+ }
+
+ cmp, err := parseCompare(line)
+ if err != nil {
+ ExitWithError(ExitInvalidInput, err)
+ }
+ cmps = append(cmps, *cmp)
+ }
+
+ return cmps
+}
+
+func readOps(r *bufio.Reader) (ops []clientv3.Op) {
+ for {
+ line, err := r.ReadString('\n')
+ if err != nil {
+ ExitWithError(ExitInvalidInput, err)
+ }
+
+ // remove space from the line
+ line = strings.TrimSpace(line)
+ if len(line) == 0 {
+ break
+ }
+
+ op, err := parseRequestUnion(line)
+ if err != nil {
+ ExitWithError(ExitInvalidInput, err)
+ }
+ ops = append(ops, *op)
+ }
+
+ return ops
+}
+
+func parseRequestUnion(line string) (*clientv3.Op, error) {
+ args := argify(line)
+ if len(args) < 2 {
+ return nil, fmt.Errorf("invalid txn compare request: %s", line)
+ }
+
+ opc := make(chan clientv3.Op, 1)
+
+ put := NewPutCommand()
+ put.Run = func(cmd *cobra.Command, args []string) {
+ key, value, opts := getPutOp(cmd, args)
+ opc <- clientv3.OpPut(key, value, opts...)
+ }
+ get := NewGetCommand()
+ get.Run = func(cmd *cobra.Command, args []string) {
+ key, opts := getGetOp(cmd, args)
+ opc <- clientv3.OpGet(key, opts...)
+ }
+ del := NewDelCommand()
+ del.Run = func(cmd *cobra.Command, args []string) {
+ key, opts := getDelOp(cmd, args)
+ opc <- clientv3.OpDelete(key, opts...)
+ }
+ cmds := &cobra.Command{SilenceErrors: true}
+ cmds.AddCommand(put, get, del)
+
+ cmds.SetArgs(args)
+ if err := cmds.Execute(); err != nil {
+ return nil, fmt.Errorf("invalid txn request: %s", line)
+ }
+
+ op := <-opc
+ return &op, nil
+}
+
+func parseCompare(line string) (*clientv3.Cmp, error) {
+ var (
+ key string
+ op string
+ val string
+ )
+
+ lparenSplit := strings.SplitN(line, "(", 2)
+ if len(lparenSplit) != 2 {
+ return nil, fmt.Errorf("malformed comparison: %s", line)
+ }
+
+ target := lparenSplit[0]
+ n, serr := fmt.Sscanf(lparenSplit[1], "%q) %s %q", &key, &op, &val)
+ if n != 3 {
+ return nil, fmt.Errorf("malformed comparison: %s; got %s(%q) %s %q", line, target, key, op, val)
+ }
+ if serr != nil {
+ return nil, fmt.Errorf("malformed comparison: %s (%v)", line, serr)
+ }
+
+ var (
+ v int64
+ err error
+ cmp clientv3.Cmp
+ )
+ switch target {
+ case "ver", "version":
+ if v, err = strconv.ParseInt(val, 10, 64); err == nil {
+ cmp = clientv3.Compare(clientv3.Version(key), op, v)
+ }
+ case "c", "create":
+ if v, err = strconv.ParseInt(val, 10, 64); err == nil {
+ cmp = clientv3.Compare(clientv3.CreateRevision(key), op, v)
+ }
+ case "m", "mod":
+ if v, err = strconv.ParseInt(val, 10, 64); err == nil {
+ cmp = clientv3.Compare(clientv3.ModRevision(key), op, v)
+ }
+ case "val", "value":
+ cmp = clientv3.Compare(clientv3.Value(key), op, val)
+ default:
+ return nil, fmt.Errorf("malformed comparison: %s (unknown target %s)", line, target)
+ }
+
+ if err != nil {
+ return nil, fmt.Errorf("invalid txn compare request: %s", line)
+ }
+
+ return &cmp, nil
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/user_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/user_command.go
new file mode 100644
index 00000000..8a157e2a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/user_command.go
@@ -0,0 +1,280 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/bgentry/speakeasy"
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+)
+
+var (
+ userShowDetail bool
+)
+
+// NewUserCommand returns the cobra command for "user".
+func NewUserCommand() *cobra.Command {
+ ac := &cobra.Command{
+ Use: "user <subcommand>",
+ Short: "User related commands",
+ }
+
+ ac.AddCommand(newUserAddCommand())
+ ac.AddCommand(newUserDeleteCommand())
+ ac.AddCommand(newUserGetCommand())
+ ac.AddCommand(newUserListCommand())
+ ac.AddCommand(newUserChangePasswordCommand())
+ ac.AddCommand(newUserGrantRoleCommand())
+ ac.AddCommand(newUserRevokeRoleCommand())
+
+ return ac
+}
+
+var (
+ passwordInteractive bool
+)
+
+func newUserAddCommand() *cobra.Command {
+ cmd := cobra.Command{
+ Use: "add <user name or user:password> [options]",
+ Short: "Adds a new user",
+ Run: userAddCommandFunc,
+ }
+
+ cmd.Flags().BoolVar(&passwordInteractive, "interactive", true, "Read password from stdin instead of interactive terminal")
+
+ return &cmd
+}
+
+func newUserDeleteCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "delete <user name>",
+ Short: "Deletes a user",
+ Run: userDeleteCommandFunc,
+ }
+}
+
+func newUserGetCommand() *cobra.Command {
+ cmd := cobra.Command{
+ Use: "get <user name> [options]",
+ Short: "Gets detailed information of a user",
+ Run: userGetCommandFunc,
+ }
+
+ cmd.Flags().BoolVar(&userShowDetail, "detail", false, "Show permissions of roles granted to the user")
+
+ return &cmd
+}
+
+func newUserListCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "list",
+ Short: "Lists all users",
+ Run: userListCommandFunc,
+ }
+}
+
+func newUserChangePasswordCommand() *cobra.Command {
+ cmd := cobra.Command{
+ Use: "passwd <user name> [options]",
+ Short: "Changes password of user",
+ Run: userChangePasswordCommandFunc,
+ }
+
+ cmd.Flags().BoolVar(&passwordInteractive, "interactive", true, "If true, read password from stdin instead of interactive terminal")
+
+ return &cmd
+}
+
+func newUserGrantRoleCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "grant-role <user name> <role name>",
+ Short: "Grants a role to a user",
+ Run: userGrantRoleCommandFunc,
+ }
+}
+
+func newUserRevokeRoleCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "revoke-role <user name> <role name>",
+ Short: "Revokes a role from a user",
+ Run: userRevokeRoleCommandFunc,
+ }
+}
+
+// userAddCommandFunc executes the "user add" command.
+func userAddCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("user add command requires user name as its argument."))
+ }
+
+ var password string
+ var user string
+
+ splitted := strings.SplitN(args[0], ":", 2)
+ if len(splitted) < 2 {
+ user = args[0]
+ if !passwordInteractive {
+ fmt.Scanf("%s", &password)
+ } else {
+ password = readPasswordInteractive(args[0])
+ }
+ } else {
+ user = splitted[0]
+ password = splitted[1]
+ if len(user) == 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("empty user name is not allowed."))
+ }
+ }
+
+ resp, err := mustClientFromCmd(cmd).Auth.UserAdd(context.TODO(), user, password)
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ display.UserAdd(user, *resp)
+}
+
+// userDeleteCommandFunc executes the "user delete" command.
+func userDeleteCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("user delete command requires user name as its argument."))
+ }
+
+ resp, err := mustClientFromCmd(cmd).Auth.UserDelete(context.TODO(), args[0])
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ display.UserDelete(args[0], *resp)
+}
+
+// userGetCommandFunc executes the "user get" command.
+func userGetCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("user get command requires user name as its argument."))
+ }
+
+ name := args[0]
+ client := mustClientFromCmd(cmd)
+ resp, err := client.Auth.UserGet(context.TODO(), name)
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ if userShowDetail {
+ fmt.Printf("User: %s\n", name)
+ for _, role := range resp.Roles {
+ fmt.Printf("\n")
+ roleResp, err := client.Auth.RoleGet(context.TODO(), role)
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ display.RoleGet(role, *roleResp)
+ }
+ } else {
+ display.UserGet(name, *resp)
+ }
+}
+
+// userListCommandFunc executes the "user list" command.
+func userListCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("user list command requires no arguments."))
+ }
+
+ resp, err := mustClientFromCmd(cmd).Auth.UserList(context.TODO())
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ display.UserList(*resp)
+}
+
+// userChangePasswordCommandFunc executes the "user passwd" command.
+func userChangePasswordCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 1 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("user passwd command requires user name as its argument."))
+ }
+
+ var password string
+
+ if !passwordInteractive {
+ fmt.Scanf("%s", &password)
+ } else {
+ password = readPasswordInteractive(args[0])
+ }
+
+ resp, err := mustClientFromCmd(cmd).Auth.UserChangePassword(context.TODO(), args[0], password)
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ display.UserChangePassword(*resp)
+}
+
+// userGrantRoleCommandFunc executes the "user grant-role" command.
+func userGrantRoleCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 2 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("user grant command requires user name and role name as its argument."))
+ }
+
+ resp, err := mustClientFromCmd(cmd).Auth.UserGrantRole(context.TODO(), args[0], args[1])
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ display.UserGrantRole(args[0], args[1], *resp)
+}
+
+// userRevokeRoleCommandFunc executes the "user revoke-role" command.
+func userRevokeRoleCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) != 2 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("user revoke-role requires user name and role name as its argument."))
+ }
+
+ resp, err := mustClientFromCmd(cmd).Auth.UserRevokeRole(context.TODO(), args[0], args[1])
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+
+ display.UserRevokeRole(args[0], args[1], *resp)
+}
+
+func readPasswordInteractive(name string) string {
+ prompt1 := fmt.Sprintf("Password of %s: ", name)
+ password1, err1 := speakeasy.Ask(prompt1)
+ if err1 != nil {
+ ExitWithError(ExitBadArgs, fmt.Errorf("failed to ask password: %s.", err1))
+ }
+
+ if len(password1) == 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("empty password"))
+ }
+
+ prompt2 := fmt.Sprintf("Type password of %s again for confirmation: ", name)
+ password2, err2 := speakeasy.Ask(prompt2)
+ if err2 != nil {
+ ExitWithError(ExitBadArgs, fmt.Errorf("failed to ask password: %s.", err2))
+ }
+
+ if strings.Compare(password1, password2) != 0 {
+ ExitWithError(ExitBadArgs, fmt.Errorf("given passwords are different."))
+ }
+
+ return password1
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/util.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/util.go
new file mode 100644
index 00000000..c9201c7b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/util.go
@@ -0,0 +1,76 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "encoding/hex"
+ "fmt"
+ "regexp"
+
+ pb "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+)
+
+func printKV(isHex bool, valueOnly bool, kv *pb.KeyValue) {
+ k, v := string(kv.Key), string(kv.Value)
+ if isHex {
+ k = addHexPrefix(hex.EncodeToString(kv.Key))
+ v = addHexPrefix(hex.EncodeToString(kv.Value))
+ }
+ if !valueOnly {
+ fmt.Println(k)
+ }
+ fmt.Println(v)
+}
+
+func addHexPrefix(s string) string {
+ ns := make([]byte, len(s)*2)
+ for i := 0; i < len(s); i += 2 {
+ ns[i*2] = '\\'
+ ns[i*2+1] = 'x'
+ ns[i*2+2] = s[i]
+ ns[i*2+3] = s[i+1]
+ }
+ return string(ns)
+}
+
+func argify(s string) []string {
+ r := regexp.MustCompile(`"(?:[^"\\]|\\.)*"|'[^']*'|[^'"\s]\S*[^'"\s]?`)
+ args := r.FindAllString(s, -1)
+ for i := range args {
+ if len(args[i]) == 0 {
+ continue
+ }
+ if args[i][0] == '\'' {
+ // 'single-quoted string'
+ args[i] = args[i][1 : len(args)-1]
+ } else if args[i][0] == '"' {
+ // "double quoted string"
+ if _, err := fmt.Sscanf(args[i], "%q", &args[i]); err != nil {
+ ExitWithError(ExitInvalidInput, err)
+ }
+ }
+ }
+ return args
+}
+
+func commandCtx(cmd *cobra.Command) (context.Context, context.CancelFunc) {
+ timeOut, err := cmd.Flags().GetDuration("command-timeout")
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ return context.WithTimeout(context.Background(), timeOut)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/version_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/version_command.go
new file mode 100644
index 00000000..9fa990f1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/version_command.go
@@ -0,0 +1,36 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+
+ "github.com/coreos/etcd/version"
+ "github.com/spf13/cobra"
+)
+
+// NewVersionCommand prints out the version of etcd.
+func NewVersionCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "version",
+ Short: "Prints the version of etcdctl",
+ Run: versionCommandFunc,
+ }
+}
+
+func versionCommandFunc(cmd *cobra.Command, args []string) {
+ fmt.Println("etcdctl version:", version.Version)
+ fmt.Println("API version:", version.APIVersion)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/watch_command.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/watch_command.go
new file mode 100644
index 00000000..17b670e9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/command/watch_command.go
@@ -0,0 +1,137 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "bufio"
+ "fmt"
+ "os"
+ "strings"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+)
+
+var (
+ watchRev int64
+ watchPrefix bool
+ watchInteractive bool
+ watchPrevKey bool
+)
+
+// NewWatchCommand returns the cobra command for "watch".
+func NewWatchCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "watch [options] [key or prefix] [range_end]",
+ Short: "Watches events stream on keys or prefixes",
+ Run: watchCommandFunc,
+ }
+
+ cmd.Flags().BoolVarP(&watchInteractive, "interactive", "i", false, "Interactive mode")
+ cmd.Flags().BoolVar(&watchPrefix, "prefix", false, "Watch on a prefix if prefix is set")
+ cmd.Flags().Int64Var(&watchRev, "rev", 0, "Revision to start watching")
+ cmd.Flags().BoolVar(&watchPrevKey, "prev-kv", false, "get the previous key-value pair before the event happens")
+
+ return cmd
+}
+
+// watchCommandFunc executes the "watch" command.
+func watchCommandFunc(cmd *cobra.Command, args []string) {
+ if watchInteractive {
+ watchInteractiveFunc(cmd, args)
+ return
+ }
+
+ c := mustClientFromCmd(cmd)
+ wc, err := getWatchChan(c, args)
+ if err != nil {
+ ExitWithError(ExitBadArgs, err)
+ }
+
+ printWatchCh(wc)
+ if err = c.Close(); err != nil {
+ ExitWithError(ExitBadConnection, err)
+ }
+ ExitWithError(ExitInterrupted, fmt.Errorf("watch is canceled by the server"))
+}
+
+func watchInteractiveFunc(cmd *cobra.Command, args []string) {
+ c := mustClientFromCmd(cmd)
+
+ reader := bufio.NewReader(os.Stdin)
+
+ for {
+ l, err := reader.ReadString('\n')
+ if err != nil {
+ ExitWithError(ExitInvalidInput, fmt.Errorf("Error reading watch request line: %v", err))
+ }
+ l = strings.TrimSuffix(l, "\n")
+
+ args := argify(l)
+ if len(args) < 2 {
+ fmt.Fprintf(os.Stderr, "Invalid command %s (command type or key is not provided)\n", l)
+ continue
+ }
+
+ if args[0] != "watch" {
+ fmt.Fprintf(os.Stderr, "Invalid command %s (only support watch)\n", l)
+ continue
+ }
+
+ flagset := NewWatchCommand().Flags()
+ err = flagset.Parse(args[1:])
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Invalid command %s (%v)\n", l, err)
+ continue
+ }
+ ch, err := getWatchChan(c, flagset.Args())
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Invalid command %s (%v)\n", l, err)
+ continue
+ }
+ go printWatchCh(ch)
+ }
+}
+
+func getWatchChan(c *clientv3.Client, args []string) (clientv3.WatchChan, error) {
+ if len(args) < 1 || len(args) > 2 {
+ return nil, fmt.Errorf("bad number of arguments")
+ }
+ key := args[0]
+ opts := []clientv3.OpOption{clientv3.WithRev(watchRev)}
+ if len(args) == 2 {
+ if watchPrefix {
+ return nil, fmt.Errorf("`range_end` and `--prefix` are mutually exclusive")
+ }
+ opts = append(opts, clientv3.WithRange(args[1]))
+ }
+ if watchPrefix {
+ opts = append(opts, clientv3.WithPrefix())
+ }
+ if watchPrevKey {
+ opts = append(opts, clientv3.WithPrevKV())
+ }
+ return c.Watch(context.TODO(), key, opts...), nil
+}
+
+func printWatchCh(ch clientv3.WatchChan) {
+ for resp := range ch {
+ if resp.Canceled {
+ fmt.Fprintf(os.Stderr, "watch was canceled (%v)\n", resp.Err())
+ }
+ display.Watch(resp)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/ctl.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/ctl.go
new file mode 100644
index 00000000..92e715d9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/ctl.go
@@ -0,0 +1,90 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 ctlv3 contains the main entry point for the etcdctl for v3 API.
+package ctlv3
+
+import (
+ "time"
+
+ "github.com/coreos/etcd/etcdctl/ctlv3/command"
+ "github.com/spf13/cobra"
+)
+
+const (
+ cliName = "etcdctl"
+ cliDescription = "A simple command line client for etcd3."
+
+ defaultDialTimeout = 2 * time.Second
+ defaultCommandTimeOut = 5 * time.Second
+)
+
+var (
+ globalFlags = command.GlobalFlags{}
+)
+
+var (
+ rootCmd = &cobra.Command{
+ Use: cliName,
+ Short: cliDescription,
+ SuggestFor: []string{"etcdctl"},
+ }
+)
+
+func init() {
+ rootCmd.PersistentFlags().StringSliceVar(&globalFlags.Endpoints, "endpoints", []string{"127.0.0.1:2379"}, "gRPC endpoints")
+ rootCmd.PersistentFlags().BoolVar(&globalFlags.Debug, "debug", false, "enable client-side debug logging")
+
+ rootCmd.PersistentFlags().StringVarP(&globalFlags.OutputFormat, "write-out", "w", "simple", "set the output format (fields, json, protobuf, simple, table)")
+ rootCmd.PersistentFlags().BoolVar(&globalFlags.IsHex, "hex", false, "print byte strings as hex encoded strings")
+
+ rootCmd.PersistentFlags().DurationVar(&globalFlags.DialTimeout, "dial-timeout", defaultDialTimeout, "dial timeout for client connections")
+ rootCmd.PersistentFlags().DurationVar(&globalFlags.CommandTimeOut, "command-timeout", defaultCommandTimeOut, "timeout for short running command (excluding dial timeout)")
+
+ // TODO: secure by default when etcd enables secure gRPC by default.
+ rootCmd.PersistentFlags().BoolVar(&globalFlags.Insecure, "insecure-transport", true, "disable transport security for client connections")
+ rootCmd.PersistentFlags().BoolVar(&globalFlags.InsecureSkipVerify, "insecure-skip-tls-verify", false, "skip server certificate verification")
+ rootCmd.PersistentFlags().StringVar(&globalFlags.TLS.CertFile, "cert", "", "identify secure client using this TLS certificate file")
+ rootCmd.PersistentFlags().StringVar(&globalFlags.TLS.KeyFile, "key", "", "identify secure client using this TLS key file")
+ rootCmd.PersistentFlags().StringVar(&globalFlags.TLS.CAFile, "cacert", "", "verify certificates of TLS-enabled secure servers using this CA bundle")
+ rootCmd.PersistentFlags().StringVar(&globalFlags.User, "user", "", "username[:password] for authentication (prompt if password is not supplied)")
+
+ rootCmd.AddCommand(
+ command.NewGetCommand(),
+ command.NewPutCommand(),
+ command.NewDelCommand(),
+ command.NewTxnCommand(),
+ command.NewCompactionCommand(),
+ command.NewAlarmCommand(),
+ command.NewDefragCommand(),
+ command.NewEndpointCommand(),
+ command.NewWatchCommand(),
+ command.NewVersionCommand(),
+ command.NewLeaseCommand(),
+ command.NewMemberCommand(),
+ command.NewSnapshotCommand(),
+ command.NewMakeMirrorCommand(),
+ command.NewMigrateCommand(),
+ command.NewLockCommand(),
+ command.NewElectCommand(),
+ command.NewAuthCommand(),
+ command.NewUserCommand(),
+ command.NewRoleCommand(),
+ command.NewCheckCommand(),
+ )
+}
+
+func init() {
+ cobra.EnablePrefixMatching = true
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/ctl_cov.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/ctl_cov.go
new file mode 100644
index 00000000..79cf93cd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/ctl_cov.go
@@ -0,0 +1,33 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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.
+
+// +build cov
+
+package ctlv3
+
+import (
+ "os"
+ "strings"
+
+ "github.com/coreos/etcd/etcdctl/ctlv3/command"
+)
+
+func Start() {
+ // ETCDCTL_ARGS=etcdctl_test arg1 arg2...
+ // SetArgs() takes arg1 arg2...
+ rootCmd.SetArgs(strings.Split(os.Getenv("ETCDCTL_ARGS"), "\xff")[1:])
+ if err := rootCmd.Execute(); err != nil {
+ command.ExitWithError(command.ExitError, err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/ctl_nocov.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/ctl_nocov.go
new file mode 100644
index 00000000..52751fee
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/ctl_nocov.go
@@ -0,0 +1,28 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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.
+
+// +build !cov
+
+package ctlv3
+
+import "github.com/coreos/etcd/etcdctl/ctlv3/command"
+
+func Start() {
+ rootCmd.SetUsageFunc(usageFunc)
+ // Make help just show the usage
+ rootCmd.SetHelpTemplate(`{{.UsageString}}`)
+ if err := rootCmd.Execute(); err != nil {
+ command.ExitWithError(command.ExitError, err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/ctlv3/help.go b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/help.go
new file mode 100644
index 00000000..fc2c62dd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/ctlv3/help.go
@@ -0,0 +1,174 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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.
+
+// copied from https://github.com/rkt/rkt/blob/master/rkt/help.go
+
+package ctlv3
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "os"
+ "strings"
+ "text/tabwriter"
+ "text/template"
+
+ "github.com/coreos/etcd/version"
+ "github.com/spf13/cobra"
+ "github.com/spf13/pflag"
+)
+
+var (
+ commandUsageTemplate *template.Template
+ templFuncs = template.FuncMap{
+ "descToLines": func(s string) []string {
+ // trim leading/trailing whitespace and split into slice of lines
+ return strings.Split(strings.Trim(s, "\n\t "), "\n")
+ },
+ "cmdName": func(cmd *cobra.Command, startCmd *cobra.Command) string {
+ parts := []string{cmd.Name()}
+ for cmd.HasParent() && cmd.Parent().Name() != startCmd.Name() {
+ cmd = cmd.Parent()
+ parts = append([]string{cmd.Name()}, parts...)
+ }
+ return strings.Join(parts, " ")
+ },
+ }
+)
+
+func init() {
+ commandUsage := `
+{{ $cmd := .Cmd }}\
+{{ $cmdname := cmdName .Cmd .Cmd.Root }}\
+NAME:
+{{ if not .Cmd.HasParent }}\
+{{printf "\t%s - %s" .Cmd.Name .Cmd.Short}}
+{{else}}\
+{{printf "\t%s - %s" $cmdname .Cmd.Short}}
+{{end}}\
+
+USAGE:
+{{printf "\t%s" .Cmd.UseLine}}
+{{ if not .Cmd.HasParent }}\
+
+VERSION:
+{{printf "\t%s" .Version}}
+{{end}}\
+{{if .Cmd.HasSubCommands}}\
+
+API VERSION:
+{{printf "\t%s" .APIVersion}}
+{{end}}\
+{{if .Cmd.HasSubCommands}}\
+
+
+COMMANDS:
+{{range .SubCommands}}\
+{{ $cmdname := cmdName . $cmd }}\
+{{ if .Runnable }}\
+{{printf "\t%s\t%s" $cmdname .Short}}
+{{end}}\
+{{end}}\
+{{end}}\
+{{ if .Cmd.Long }}\
+
+DESCRIPTION:
+{{range $line := descToLines .Cmd.Long}}{{printf "\t%s" $line}}
+{{end}}\
+{{end}}\
+{{if .Cmd.HasLocalFlags}}\
+
+OPTIONS:
+{{.LocalFlags}}\
+{{end}}\
+{{if .Cmd.HasInheritedFlags}}\
+
+GLOBAL OPTIONS:
+{{.GlobalFlags}}\
+{{end}}
+`[1:]
+
+ commandUsageTemplate = template.Must(template.New("command_usage").Funcs(templFuncs).Parse(strings.Replace(commandUsage, "\\\n", "", -1)))
+}
+
+func etcdFlagUsages(flagSet *pflag.FlagSet) string {
+ x := new(bytes.Buffer)
+
+ flagSet.VisitAll(func(flag *pflag.Flag) {
+ if len(flag.Deprecated) > 0 {
+ return
+ }
+ format := ""
+ if len(flag.Shorthand) > 0 {
+ format = " -%s, --%s"
+ } else {
+ format = " %s --%s"
+ }
+ if len(flag.NoOptDefVal) > 0 {
+ format = format + "["
+ }
+ if flag.Value.Type() == "string" {
+ // put quotes on the value
+ format = format + "=%q"
+ } else {
+ format = format + "=%s"
+ }
+ if len(flag.NoOptDefVal) > 0 {
+ format = format + "]"
+ }
+ format = format + "\t%s\n"
+ shorthand := flag.Shorthand
+ fmt.Fprintf(x, format, shorthand, flag.Name, flag.DefValue, flag.Usage)
+ })
+
+ return x.String()
+}
+
+func getSubCommands(cmd *cobra.Command) []*cobra.Command {
+ var subCommands []*cobra.Command
+ for _, subCmd := range cmd.Commands() {
+ subCommands = append(subCommands, subCmd)
+ subCommands = append(subCommands, getSubCommands(subCmd)...)
+ }
+ return subCommands
+}
+
+func usageFunc(cmd *cobra.Command) error {
+ subCommands := getSubCommands(cmd)
+ tabOut := getTabOutWithWriter(os.Stdout)
+ commandUsageTemplate.Execute(tabOut, struct {
+ Cmd *cobra.Command
+ LocalFlags string
+ GlobalFlags string
+ SubCommands []*cobra.Command
+ Version string
+ APIVersion string
+ }{
+ cmd,
+ etcdFlagUsages(cmd.LocalFlags()),
+ etcdFlagUsages(cmd.InheritedFlags()),
+ subCommands,
+ version.Version,
+ version.APIVersion,
+ })
+ tabOut.Flush()
+ return nil
+}
+
+func getTabOutWithWriter(writer io.Writer) *tabwriter.Writer {
+ aTabOut := new(tabwriter.Writer)
+ aTabOut.Init(writer, 0, 8, 1, '\t', 0)
+ return aTabOut
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/doc/mirror_maker.md b/vendor/github.com/coreos/etcd/etcdctl/doc/mirror_maker.md
new file mode 100644
index 00000000..6b14a256
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/doc/mirror_maker.md
@@ -0,0 +1,29 @@
+## Mirror Maker
+
+Mirror maker mirrors a prefix in the key-value space of an etcd cluster into another prefix in another cluster. Mirroring is designed for copying configuration to various clusters distributed around the world. Mirroring usually has very low latency once it completes synchronizing with the initial state. Mirror maker utilizes the etcd watcher facility to immediately inform the mirror of any key modifications. Based on our experiments, the network latency between the mirror maker and the two clusters accounts for most of the latency. If the network is healthy, copying configuration held in etcd to the mirror should take under one second even for a world-wide deployment.
+
+If the mirror maker fails to connect to one of the clusters, the mirroring will pause. Mirroring can be resumed automatically once connectivity is reestablished.
+
+The mirroring mechanism is unidirectional. Data under the destination cluster?s mirroring prefix should be treated as read only. The mirror maker only mirrors key-value pairs; metadata, such as version number or modification revision, is discarded. However, mirror maker still attempts to preserve update ordering during normal operation, but there is no ordering guarantee during initial sync nor during failure recovery following network interruption. As a rule of thumb, the ordering of the updates on the mirror should not be considered reliable.
+
+```
++-------------+
+| |
+| source | +-----------+
+| cluster +----> | mirror |
+| | | maker |
++-------------+ +---+-------+
+ |
+ v
+ +-------------+
+ | |
+ | mirror |
+ | cluster |
+ | |
+ +-------------+
+
+```
+
+Mirror-maker is a built-in feature of [etcdctl][etcdctl].
+
+[etcdctl]: ../README.md
diff --git a/vendor/github.com/coreos/etcd/etcdctl/main.go b/vendor/github.com/coreos/etcd/etcdctl/main.go
new file mode 100644
index 00000000..b5c7bddb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/main.go
@@ -0,0 +1,46 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// etcdctl is a command line application that controls etcd.
+package main
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/coreos/etcd/etcdctl/ctlv2"
+ "github.com/coreos/etcd/etcdctl/ctlv3"
+)
+
+const (
+ apiEnv = "ETCDCTL_API"
+)
+
+func main() {
+ apiv := os.Getenv(apiEnv)
+ // unset apiEnv to avoid side-effect for future env and flag parsing.
+ os.Unsetenv(apiEnv)
+ if len(apiv) == 0 || apiv == "2" {
+ ctlv2.Start(apiv)
+ return
+ }
+
+ if apiv == "3" {
+ ctlv3.Start()
+ return
+ }
+
+ fmt.Fprintln(os.Stderr, "unsupported API version", apiv)
+ os.Exit(1)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdctl/main_test.go b/vendor/github.com/coreos/etcd/etcdctl/main_test.go
new file mode 100644
index 00000000..ccd3ba0a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdctl/main_test.go
@@ -0,0 +1,29 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 (
+ "os"
+ "strings"
+ "testing"
+)
+
+func TestMain(t *testing.T) {
+ // don't launch etcdctl when invoked via go test
+ if strings.HasSuffix(os.Args[0], "etcdctl.test") {
+ return
+ }
+ main()
+}
diff --git a/vendor/github.com/coreos/etcd/etcdmain/config.go b/vendor/github.com/coreos/etcd/etcdmain/config.go
new file mode 100644
index 00000000..b8732200
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdmain/config.go
@@ -0,0 +1,324 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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.
+
+// Every change should be reflected on help.go as well.
+
+package etcdmain
+
+import (
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "runtime"
+ "strings"
+
+ "github.com/coreos/etcd/embed"
+ "github.com/coreos/etcd/pkg/flags"
+ "github.com/coreos/etcd/version"
+ "github.com/ghodss/yaml"
+)
+
+var (
+ proxyFlagOff = "off"
+ proxyFlagReadonly = "readonly"
+ proxyFlagOn = "on"
+
+ fallbackFlagExit = "exit"
+ fallbackFlagProxy = "proxy"
+
+ ignored = []string{
+ "cluster-active-size",
+ "cluster-remove-delay",
+ "cluster-sync-interval",
+ "config",
+ "force",
+ "max-result-buffer",
+ "max-retry-attempts",
+ "peer-heartbeat-interval",
+ "peer-election-timeout",
+ "retry-interval",
+ "snapshot",
+ "v",
+ "vv",
+ // for coverage testing
+ "test.coverprofile",
+ "test.outputdir",
+ }
+)
+
+type configProxy struct {
+ ProxyFailureWaitMs uint `json:"proxy-failure-wait"`
+ ProxyRefreshIntervalMs uint `json:"proxy-refresh-interval"`
+ ProxyDialTimeoutMs uint `json:"proxy-dial-timeout"`
+ ProxyWriteTimeoutMs uint `json:"proxy-write-timeout"`
+ ProxyReadTimeoutMs uint `json:"proxy-read-timeout"`
+ Fallback string
+ Proxy string
+ ProxyJSON string `json:"proxy"`
+ FallbackJSON string `json:"discovery-fallback"`
+}
+
+// config holds the config for a command line invocation of etcd
+type config struct {
+ embed.Config
+ configProxy
+ configFlags
+ configFile string
+ printVersion bool
+ ignored []string
+ logOutput string
+}
+
+// configFlags has the set of flags used for command line parsing a Config
+type configFlags struct {
+ *flag.FlagSet
+ clusterState *flags.StringsFlag
+ fallback *flags.StringsFlag
+ proxy *flags.StringsFlag
+}
+
+func newConfig() *config {
+ cfg := &config{
+ Config: *embed.NewConfig(),
+ configProxy: configProxy{
+ Proxy: proxyFlagOff,
+ ProxyFailureWaitMs: 5000,
+ ProxyRefreshIntervalMs: 30000,
+ ProxyDialTimeoutMs: 1000,
+ ProxyWriteTimeoutMs: 5000,
+ },
+ ignored: ignored,
+ }
+ cfg.configFlags = configFlags{
+ FlagSet: flag.NewFlagSet("etcd", flag.ContinueOnError),
+ clusterState: flags.NewStringsFlag(
+ embed.ClusterStateFlagNew,
+ embed.ClusterStateFlagExisting,
+ ),
+ fallback: flags.NewStringsFlag(
+ fallbackFlagExit,
+ fallbackFlagProxy,
+ ),
+ proxy: flags.NewStringsFlag(
+ proxyFlagOff,
+ proxyFlagReadonly,
+ proxyFlagOn,
+ ),
+ }
+
+ fs := cfg.FlagSet
+ fs.Usage = func() {
+ fmt.Fprintln(os.Stderr, usageline)
+ }
+
+ fs.StringVar(&cfg.configFile, "config-file", "", "Path to the server configuration file")
+
+ // member
+ fs.Var(cfg.CorsInfo, "cors", "Comma-separated white list of origins for CORS (cross-origin resource sharing).")
+ fs.StringVar(&cfg.Dir, "data-dir", cfg.Dir, "Path to the data directory.")
+ fs.StringVar(&cfg.WalDir, "wal-dir", cfg.WalDir, "Path to the dedicated wal directory.")
+ fs.Var(flags.NewURLsValue(embed.DefaultListenPeerURLs), "listen-peer-urls", "List of URLs to listen on for peer traffic.")
+ fs.Var(flags.NewURLsValue(embed.DefaultListenClientURLs), "listen-client-urls", "List of URLs to listen on for client traffic.")
+ fs.UintVar(&cfg.MaxSnapFiles, "max-snapshots", cfg.MaxSnapFiles, "Maximum number of snapshot files to retain (0 is unlimited).")
+ fs.UintVar(&cfg.MaxWalFiles, "max-wals", cfg.MaxWalFiles, "Maximum number of wal files to retain (0 is unlimited).")
+ fs.StringVar(&cfg.Name, "name", cfg.Name, "Human-readable name for this member.")
+ fs.Uint64Var(&cfg.SnapCount, "snapshot-count", cfg.SnapCount, "Number of committed transactions to trigger a snapshot to disk.")
+ fs.UintVar(&cfg.TickMs, "heartbeat-interval", cfg.TickMs, "Time (in milliseconds) of a heartbeat interval.")
+ fs.UintVar(&cfg.ElectionMs, "election-timeout", cfg.ElectionMs, "Time (in milliseconds) for an election to timeout.")
+ fs.Int64Var(&cfg.QuotaBackendBytes, "quota-backend-bytes", cfg.QuotaBackendBytes, "Raise alarms when backend size exceeds the given quota. 0 means use the default quota.")
+
+ // clustering
+ fs.Var(flags.NewURLsValue(embed.DefaultInitialAdvertisePeerURLs), "initial-advertise-peer-urls", "List of this member's peer URLs to advertise to the rest of the cluster.")
+ fs.Var(flags.NewURLsValue(embed.DefaultAdvertiseClientURLs), "advertise-client-urls", "List of this member's client URLs to advertise to the public.")
+ fs.StringVar(&cfg.Durl, "discovery", cfg.Durl, "Discovery URL used to bootstrap the cluster.")
+ fs.Var(cfg.fallback, "discovery-fallback", fmt.Sprintf("Valid values include %s", strings.Join(cfg.fallback.Values, ", ")))
+ if err := cfg.fallback.Set(fallbackFlagProxy); err != nil {
+ // Should never happen.
+ plog.Panicf("unexpected error setting up discovery-fallback flag: %v", err)
+ }
+ fs.StringVar(&cfg.Dproxy, "discovery-proxy", cfg.Dproxy, "HTTP proxy to use for traffic to discovery service.")
+ fs.StringVar(&cfg.DNSCluster, "discovery-srv", cfg.DNSCluster, "DNS domain used to bootstrap initial cluster.")
+ fs.StringVar(&cfg.InitialCluster, "initial-cluster", cfg.InitialCluster, "Initial cluster configuration for bootstrapping.")
+ fs.StringVar(&cfg.InitialClusterToken, "initial-cluster-token", cfg.InitialClusterToken, "Initial cluster token for the etcd cluster during bootstrap.")
+ fs.Var(cfg.clusterState, "initial-cluster-state", "Initial cluster state ('new' or 'existing').")
+ if err := cfg.clusterState.Set(embed.ClusterStateFlagNew); err != nil {
+ // Should never happen.
+ plog.Panicf("unexpected error setting up clusterStateFlag: %v", err)
+ }
+ fs.BoolVar(&cfg.StrictReconfigCheck, "strict-reconfig-check", cfg.StrictReconfigCheck, "Reject reconfiguration requests that would cause quorum loss.")
+ fs.BoolVar(&cfg.EnableV2, "enable-v2", true, "Accept etcd V2 client requests.")
+
+ // proxy
+ fs.Var(cfg.proxy, "proxy", fmt.Sprintf("Valid values include %s", strings.Join(cfg.proxy.Values, ", ")))
+ if err := cfg.proxy.Set(proxyFlagOff); err != nil {
+ // Should never happen.
+ plog.Panicf("unexpected error setting up proxyFlag: %v", err)
+ }
+ fs.UintVar(&cfg.ProxyFailureWaitMs, "proxy-failure-wait", cfg.ProxyFailureWaitMs, "Time (in milliseconds) an endpoint will be held in a failed state.")
+ fs.UintVar(&cfg.ProxyRefreshIntervalMs, "proxy-refresh-interval", cfg.ProxyRefreshIntervalMs, "Time (in milliseconds) of the endpoints refresh interval.")
+ fs.UintVar(&cfg.ProxyDialTimeoutMs, "proxy-dial-timeout", cfg.ProxyDialTimeoutMs, "Time (in milliseconds) for a dial to timeout.")
+ fs.UintVar(&cfg.ProxyWriteTimeoutMs, "proxy-write-timeout", cfg.ProxyWriteTimeoutMs, "Time (in milliseconds) for a write to timeout.")
+ fs.UintVar(&cfg.ProxyReadTimeoutMs, "proxy-read-timeout", cfg.ProxyReadTimeoutMs, "Time (in milliseconds) for a read to timeout.")
+
+ // security
+ fs.StringVar(&cfg.ClientTLSInfo.CAFile, "ca-file", "", "DEPRECATED: Path to the client server TLS CA file.")
+ fs.StringVar(&cfg.ClientTLSInfo.CertFile, "cert-file", "", "Path to the client server TLS cert file.")
+ fs.StringVar(&cfg.ClientTLSInfo.KeyFile, "key-file", "", "Path to the client server TLS key file.")
+ fs.BoolVar(&cfg.ClientTLSInfo.ClientCertAuth, "client-cert-auth", false, "Enable client cert authentication.")
+ fs.StringVar(&cfg.ClientTLSInfo.TrustedCAFile, "trusted-ca-file", "", "Path to the client server TLS trusted CA key file.")
+ fs.BoolVar(&cfg.ClientAutoTLS, "auto-tls", false, "Client TLS using generated certificates")
+ fs.StringVar(&cfg.PeerTLSInfo.CAFile, "peer-ca-file", "", "DEPRECATED: Path to the peer server TLS CA file.")
+ fs.StringVar(&cfg.PeerTLSInfo.CertFile, "peer-cert-file", "", "Path to the peer server TLS cert file.")
+ fs.StringVar(&cfg.PeerTLSInfo.KeyFile, "peer-key-file", "", "Path to the peer server TLS key file.")
+ fs.BoolVar(&cfg.PeerTLSInfo.ClientCertAuth, "peer-client-cert-auth", false, "Enable peer client cert authentication.")
+ fs.StringVar(&cfg.PeerTLSInfo.TrustedCAFile, "peer-trusted-ca-file", "", "Path to the peer server TLS trusted CA file.")
+ fs.BoolVar(&cfg.PeerAutoTLS, "peer-auto-tls", false, "Peer TLS using generated certificates")
+
+ // logging
+ fs.BoolVar(&cfg.Debug, "debug", false, "Enable debug-level logging for etcd.")
+ fs.StringVar(&cfg.LogPkgLevels, "log-package-levels", "", "Specify a particular log level for each etcd package (eg: 'etcdmain=CRITICAL,etcdserver=DEBUG').")
+ fs.StringVar(&cfg.logOutput, "log-output", "default", "Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd.")
+
+ // unsafe
+ fs.BoolVar(&cfg.ForceNewCluster, "force-new-cluster", false, "Force to create a new one member cluster.")
+
+ // version
+ fs.BoolVar(&cfg.printVersion, "version", false, "Print the version and exit.")
+
+ fs.IntVar(&cfg.AutoCompactionRetention, "auto-compaction-retention", 0, "Auto compaction retention for mvcc key value store in hour. 0 means disable auto compaction.")
+
+ // pprof profiler via HTTP
+ fs.BoolVar(&cfg.EnablePprof, "enable-pprof", false, "Enable runtime profiling data via HTTP server. Address is at client URL + \"/debug/pprof/\"")
+
+ // additional metrics
+ fs.StringVar(&cfg.Metrics, "metrics", cfg.Metrics, "Set level of detail for exported metrics, specify 'extensive' to include histogram metrics")
+
+ // auth
+ fs.StringVar(&cfg.AuthToken, "auth-token", cfg.AuthToken, "Specify auth token specific options.")
+
+ // ignored
+ for _, f := range cfg.ignored {
+ fs.Var(&flags.IgnoredFlag{Name: f}, f, "")
+ }
+ return cfg
+}
+
+func (cfg *config) parse(arguments []string) error {
+ perr := cfg.FlagSet.Parse(arguments)
+ switch perr {
+ case nil:
+ case flag.ErrHelp:
+ fmt.Println(flagsline)
+ os.Exit(0)
+ default:
+ os.Exit(2)
+ }
+ if len(cfg.FlagSet.Args()) != 0 {
+ return fmt.Errorf("'%s' is not a valid flag", cfg.FlagSet.Arg(0))
+ }
+
+ if cfg.printVersion {
+ fmt.Printf("etcd Version: %s\n", version.Version)
+ fmt.Printf("Git SHA: %s\n", version.GitSHA)
+ fmt.Printf("Go Version: %s\n", runtime.Version())
+ fmt.Printf("Go OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
+ os.Exit(0)
+ }
+
+ var err error
+ if cfg.configFile != "" {
+ plog.Infof("Loading server configuration from %q", cfg.configFile)
+ err = cfg.configFromFile(cfg.configFile)
+ } else {
+ err = cfg.configFromCmdLine()
+ }
+ return err
+}
+
+func (cfg *config) configFromCmdLine() error {
+ err := flags.SetFlagsFromEnv("ETCD", cfg.FlagSet)
+ if err != nil {
+ plog.Fatalf("%v", err)
+ }
+
+ cfg.LPUrls = flags.URLsFromFlag(cfg.FlagSet, "listen-peer-urls")
+ cfg.APUrls = flags.URLsFromFlag(cfg.FlagSet, "initial-advertise-peer-urls")
+ cfg.LCUrls = flags.URLsFromFlag(cfg.FlagSet, "listen-client-urls")
+ cfg.ACUrls = flags.URLsFromFlag(cfg.FlagSet, "advertise-client-urls")
+ cfg.ClusterState = cfg.clusterState.String()
+ cfg.Fallback = cfg.fallback.String()
+ cfg.Proxy = cfg.proxy.String()
+
+ // disable default advertise-client-urls if lcurls is set
+ missingAC := flags.IsSet(cfg.FlagSet, "listen-client-urls") && !flags.IsSet(cfg.FlagSet, "advertise-client-urls")
+ if !cfg.mayBeProxy() && missingAC {
+ cfg.ACUrls = nil
+ }
+
+ // disable default initial-cluster if discovery is set
+ if (cfg.Durl != "" || cfg.DNSCluster != "") && !flags.IsSet(cfg.FlagSet, "initial-cluster") {
+ cfg.InitialCluster = ""
+ }
+
+ return cfg.validate()
+}
+
+func (cfg *config) configFromFile(path string) error {
+ eCfg, err := embed.ConfigFromFile(path)
+ if err != nil {
+ return err
+ }
+ cfg.Config = *eCfg
+
+ // load extra config information
+ b, rerr := ioutil.ReadFile(path)
+ if rerr != nil {
+ return rerr
+ }
+ if yerr := yaml.Unmarshal(b, &cfg.configProxy); yerr != nil {
+ return yerr
+ }
+ if cfg.FallbackJSON != "" {
+ if err := cfg.fallback.Set(cfg.FallbackJSON); err != nil {
+ plog.Panicf("unexpected error setting up discovery-fallback flag: %v", err)
+ }
+ cfg.Fallback = cfg.fallback.String()
+ }
+ if cfg.ProxyJSON != "" {
+ if err := cfg.proxy.Set(cfg.ProxyJSON); err != nil {
+ plog.Panicf("unexpected error setting up proxyFlag: %v", err)
+ }
+ cfg.Proxy = cfg.proxy.String()
+ }
+ return nil
+}
+
+func (cfg *config) mayBeProxy() bool {
+ mayFallbackToProxy := cfg.Durl != "" && cfg.Fallback == fallbackFlagProxy
+ return cfg.Proxy != proxyFlagOff || mayFallbackToProxy
+}
+
+func (cfg *config) validate() error {
+ err := cfg.Config.Validate()
+ // TODO(yichengq): check this for joining through discovery service case
+ if err == embed.ErrUnsetAdvertiseClientURLsFlag && cfg.mayBeProxy() {
+ return nil
+ }
+ return err
+}
+
+func (cfg config) isProxy() bool { return cfg.proxy.String() != proxyFlagOff }
+func (cfg config) isReadonlyProxy() bool { return cfg.proxy.String() == proxyFlagReadonly }
+func (cfg config) shouldFallbackToProxy() bool { return cfg.fallback.String() == fallbackFlagProxy }
diff --git a/vendor/github.com/coreos/etcd/etcdmain/config_test.go b/vendor/github.com/coreos/etcd/etcdmain/config_test.go
new file mode 100644
index 00000000..c82afba4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdmain/config_test.go
@@ -0,0 +1,573 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdmain
+
+import (
+ "fmt"
+ "io/ioutil"
+ "net/url"
+ "os"
+ "reflect"
+ "strings"
+ "testing"
+
+ "github.com/coreos/etcd/embed"
+ "github.com/ghodss/yaml"
+)
+
+func TestConfigParsingMemberFlags(t *testing.T) {
+ args := []string{
+ "-data-dir=testdir",
+ "-name=testname",
+ "-max-wals=10",
+ "-max-snapshots=10",
+ "-snapshot-count=10",
+ "-listen-peer-urls=http://localhost:8000,https://localhost:8001",
+ "-listen-client-urls=http://localhost:7000,https://localhost:7001",
+ // it should be set if -listen-client-urls is set
+ "-advertise-client-urls=http://localhost:7000,https://localhost:7001",
+ }
+
+ cfg := newConfig()
+ err := cfg.parse(args)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ validateMemberFlags(t, cfg)
+}
+
+func TestConfigFileMemberFields(t *testing.T) {
+ yc := struct {
+ Dir string `json:"data-dir"`
+ MaxSnapFiles uint `json:"max-snapshots"`
+ MaxWalFiles uint `json:"max-wals"`
+ Name string `json:"name"`
+ SnapCount uint64 `json:"snapshot-count"`
+ LPUrls string `json:"listen-peer-urls"`
+ LCUrls string `json:"listen-client-urls"`
+ AcurlsCfgFile string `json:"advertise-client-urls"`
+ }{
+ "testdir",
+ 10,
+ 10,
+ "testname",
+ 10,
+ "http://localhost:8000,https://localhost:8001",
+ "http://localhost:7000,https://localhost:7001",
+ "http://localhost:7000,https://localhost:7001",
+ }
+
+ b, err := yaml.Marshal(&yc)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ tmpfile := mustCreateCfgFile(t, b)
+ defer os.Remove(tmpfile.Name())
+
+ args := []string{fmt.Sprintf("--config-file=%s", tmpfile.Name())}
+
+ cfg := newConfig()
+ if err = cfg.parse(args); err != nil {
+ t.Fatal(err)
+ }
+
+ validateMemberFlags(t, cfg)
+}
+
+func TestConfigParsingClusteringFlags(t *testing.T) {
+ args := []string{
+ "-initial-cluster=0=http://localhost:8000",
+ "-initial-cluster-state=existing",
+ "-initial-cluster-token=etcdtest",
+ "-initial-advertise-peer-urls=http://localhost:8000,https://localhost:8001",
+ "-advertise-client-urls=http://localhost:7000,https://localhost:7001",
+ "-discovery-fallback=exit",
+ }
+
+ cfg := newConfig()
+ if err := cfg.parse(args); err != nil {
+ t.Fatal(err)
+ }
+
+ validateClusteringFlags(t, cfg)
+}
+
+func TestConfigFileClusteringFields(t *testing.T) {
+ yc := struct {
+ InitialCluster string `json:"initial-cluster"`
+ ClusterState string `json:"initial-cluster-state"`
+ InitialClusterToken string `json:"initial-cluster-token"`
+ Apurls string `json:"initial-advertise-peer-urls"`
+ Acurls string `json:"advertise-client-urls"`
+ Fallback string `json:"discovery-fallback"`
+ }{
+ "0=http://localhost:8000",
+ "existing",
+ "etcdtest",
+ "http://localhost:8000,https://localhost:8001",
+ "http://localhost:7000,https://localhost:7001",
+ "exit",
+ }
+
+ b, err := yaml.Marshal(&yc)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ tmpfile := mustCreateCfgFile(t, b)
+ defer os.Remove(tmpfile.Name())
+
+ args := []string{fmt.Sprintf("--config-file=%s", tmpfile.Name())}
+ cfg := newConfig()
+ err = cfg.parse(args)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ validateClusteringFlags(t, cfg)
+}
+
+func TestConfigFileClusteringFlags(t *testing.T) {
+ tests := []struct {
+ Name string `json:"name"`
+ InitialCluster string `json:"initial-cluster"`
+ DNSCluster string `json:"discovery-srv"`
+ Durl string `json:"discovery"`
+ }{
+ {
+ // Use default name and generate a default initial-cluster
+ },
+ {
+ Name: "non-default",
+ },
+ {
+ InitialCluster: "0=localhost:8000",
+ },
+ {
+ Name: "non-default",
+ InitialCluster: "0=localhost:8000",
+ },
+ {
+ DNSCluster: "example.com",
+ },
+ {
+ Name: "non-default",
+ DNSCluster: "example.com",
+ },
+ {
+ Durl: "http://example.com/abc",
+ },
+ {
+ Name: "non-default",
+ Durl: "http://example.com/abc",
+ },
+ }
+
+ for i, tt := range tests {
+ b, err := yaml.Marshal(&tt)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ tmpfile := mustCreateCfgFile(t, b)
+ defer os.Remove(tmpfile.Name())
+
+ args := []string{fmt.Sprintf("--config-file=%s", tmpfile.Name())}
+
+ cfg := newConfig()
+ if err := cfg.parse(args); err != nil {
+ t.Errorf("%d: err = %v", i, err)
+ }
+ }
+}
+
+func TestConfigParsingOtherFlags(t *testing.T) {
+ args := []string{"-proxy=readonly"}
+
+ cfg := newConfig()
+ err := cfg.parse(args)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ validateOtherFlags(t, cfg)
+}
+
+func TestConfigFileOtherFields(t *testing.T) {
+ yc := struct {
+ ProxyCfgFile string `json:"proxy"`
+ }{
+ "readonly",
+ }
+
+ b, err := yaml.Marshal(&yc)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ tmpfile := mustCreateCfgFile(t, b)
+ defer os.Remove(tmpfile.Name())
+
+ args := []string{fmt.Sprintf("--config-file=%s", tmpfile.Name())}
+
+ cfg := newConfig()
+ err = cfg.parse(args)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ validateOtherFlags(t, cfg)
+}
+
+func TestConfigParsingConflictClusteringFlags(t *testing.T) {
+ conflictArgs := [][]string{
+ {
+ "-initial-cluster=0=localhost:8000",
+ "-discovery=http://example.com/abc",
+ },
+ {
+ "-discovery-srv=example.com",
+ "-discovery=http://example.com/abc",
+ },
+ {
+ "-initial-cluster=0=localhost:8000",
+ "-discovery-srv=example.com",
+ },
+ {
+ "-initial-cluster=0=localhost:8000",
+ "-discovery=http://example.com/abc",
+ "-discovery-srv=example.com",
+ },
+ }
+
+ for i, tt := range conflictArgs {
+ cfg := newConfig()
+ if err := cfg.parse(tt); err != embed.ErrConflictBootstrapFlags {
+ t.Errorf("%d: err = %v, want %v", i, err, embed.ErrConflictBootstrapFlags)
+ }
+ }
+}
+
+func TestConfigFileConflictClusteringFlags(t *testing.T) {
+ tests := []struct {
+ InitialCluster string `json:"initial-cluster"`
+ DNSCluster string `json:"discovery-srv"`
+ Durl string `json:"discovery"`
+ }{
+ {
+ InitialCluster: "0=localhost:8000",
+ Durl: "http://example.com/abc",
+ },
+ {
+ DNSCluster: "example.com",
+ Durl: "http://example.com/abc",
+ },
+ {
+ InitialCluster: "0=localhost:8000",
+ DNSCluster: "example.com",
+ },
+ {
+ InitialCluster: "0=localhost:8000",
+ Durl: "http://example.com/abc",
+ DNSCluster: "example.com",
+ },
+ }
+
+ for i, tt := range tests {
+ b, err := yaml.Marshal(&tt)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ tmpfile := mustCreateCfgFile(t, b)
+ defer os.Remove(tmpfile.Name())
+
+ args := []string{fmt.Sprintf("--config-file=%s", tmpfile.Name())}
+
+ cfg := newConfig()
+ if err := cfg.parse(args); err != embed.ErrConflictBootstrapFlags {
+ t.Errorf("%d: err = %v, want %v", i, err, embed.ErrConflictBootstrapFlags)
+ }
+ }
+}
+
+func TestConfigParsingMissedAdvertiseClientURLsFlag(t *testing.T) {
+ tests := []struct {
+ args []string
+ werr error
+ }{
+ {
+ []string{
+ "-initial-cluster=infra1=http://127.0.0.1:2380",
+ "-listen-client-urls=http://127.0.0.1:2379",
+ },
+ embed.ErrUnsetAdvertiseClientURLsFlag,
+ },
+ {
+ []string{
+ "-discovery-srv=example.com",
+ "-listen-client-urls=http://127.0.0.1:2379",
+ },
+ embed.ErrUnsetAdvertiseClientURLsFlag,
+ },
+ {
+ []string{
+ "-discovery=http://example.com/abc",
+ "-discovery-fallback=exit",
+ "-listen-client-urls=http://127.0.0.1:2379",
+ },
+ embed.ErrUnsetAdvertiseClientURLsFlag,
+ },
+ {
+ []string{
+ "-listen-client-urls=http://127.0.0.1:2379",
+ },
+ embed.ErrUnsetAdvertiseClientURLsFlag,
+ },
+ {
+ []string{
+ "-discovery=http://example.com/abc",
+ "-listen-client-urls=http://127.0.0.1:2379",
+ },
+ nil,
+ },
+ {
+ []string{
+ "-proxy=on",
+ "-listen-client-urls=http://127.0.0.1:2379",
+ },
+ nil,
+ },
+ {
+ []string{
+ "-proxy=readonly",
+ "-listen-client-urls=http://127.0.0.1:2379",
+ },
+ nil,
+ },
+ }
+
+ for i, tt := range tests {
+ cfg := newConfig()
+ if err := cfg.parse(tt.args); err != tt.werr {
+ t.Errorf("%d: err = %v, want %v", i, err, tt.werr)
+ }
+ }
+}
+
+func TestConfigIsNewCluster(t *testing.T) {
+ tests := []struct {
+ state string
+ wIsNew bool
+ }{
+ {embed.ClusterStateFlagExisting, false},
+ {embed.ClusterStateFlagNew, true},
+ }
+ for i, tt := range tests {
+ cfg := newConfig()
+ args := []string{"--initial-cluster-state", tests[i].state}
+ if err := cfg.parse(args); err != nil {
+ t.Fatalf("#%d: unexpected clusterState.Set error: %v", i, err)
+ }
+ if g := cfg.IsNewCluster(); g != tt.wIsNew {
+ t.Errorf("#%d: isNewCluster = %v, want %v", i, g, tt.wIsNew)
+ }
+ }
+}
+
+func TestConfigIsProxy(t *testing.T) {
+ tests := []struct {
+ proxy string
+ wIsProxy bool
+ }{
+ {proxyFlagOff, false},
+ {proxyFlagReadonly, true},
+ {proxyFlagOn, true},
+ }
+ for i, tt := range tests {
+ cfg := newConfig()
+ if err := cfg.proxy.Set(tt.proxy); err != nil {
+ t.Fatalf("#%d: unexpected proxy.Set error: %v", i, err)
+ }
+ if g := cfg.isProxy(); g != tt.wIsProxy {
+ t.Errorf("#%d: isProxy = %v, want %v", i, g, tt.wIsProxy)
+ }
+ }
+}
+
+func TestConfigIsReadonlyProxy(t *testing.T) {
+ tests := []struct {
+ proxy string
+ wIsReadonly bool
+ }{
+ {proxyFlagOff, false},
+ {proxyFlagReadonly, true},
+ {proxyFlagOn, false},
+ }
+ for i, tt := range tests {
+ cfg := newConfig()
+ if err := cfg.proxy.Set(tt.proxy); err != nil {
+ t.Fatalf("#%d: unexpected proxy.Set error: %v", i, err)
+ }
+ if g := cfg.isReadonlyProxy(); g != tt.wIsReadonly {
+ t.Errorf("#%d: isReadonlyProxy = %v, want %v", i, g, tt.wIsReadonly)
+ }
+ }
+}
+
+func TestConfigShouldFallbackToProxy(t *testing.T) {
+ tests := []struct {
+ fallback string
+ wFallback bool
+ }{
+ {fallbackFlagProxy, true},
+ {fallbackFlagExit, false},
+ }
+ for i, tt := range tests {
+ cfg := newConfig()
+ if err := cfg.fallback.Set(tt.fallback); err != nil {
+ t.Fatalf("#%d: unexpected fallback.Set error: %v", i, err)
+ }
+ if g := cfg.shouldFallbackToProxy(); g != tt.wFallback {
+ t.Errorf("#%d: shouldFallbackToProxy = %v, want %v", i, g, tt.wFallback)
+ }
+ }
+}
+
+func TestConfigFileElectionTimeout(t *testing.T) {
+ tests := []struct {
+ TickMs uint `json:"heartbeat-interval"`
+ ElectionMs uint `json:"election-timeout"`
+ errStr string
+ }{
+ {
+ ElectionMs: 1000,
+ TickMs: 800,
+ errStr: "should be at least as 5 times as",
+ },
+ {
+ ElectionMs: 60000,
+ errStr: "is too long, and should be set less than",
+ },
+ }
+
+ for i, tt := range tests {
+ b, err := yaml.Marshal(&tt)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ tmpfile := mustCreateCfgFile(t, b)
+ defer os.Remove(tmpfile.Name())
+
+ args := []string{fmt.Sprintf("--config-file=%s", tmpfile.Name())}
+
+ cfg := newConfig()
+ if err := cfg.parse(args); err == nil || !strings.Contains(err.Error(), tt.errStr) {
+ t.Errorf("%d: Wrong err = %v", i, err)
+ }
+ }
+}
+
+func mustCreateCfgFile(t *testing.T, b []byte) *os.File {
+ tmpfile, err := ioutil.TempFile("", "servercfg")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ _, err = tmpfile.Write(b)
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = tmpfile.Close()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ return tmpfile
+}
+
+func validateMemberFlags(t *testing.T, cfg *config) {
+ wcfg := &embed.Config{
+ Dir: "testdir",
+ LPUrls: []url.URL{{Scheme: "http", Host: "localhost:8000"}, {Scheme: "https", Host: "localhost:8001"}},
+ LCUrls: []url.URL{{Scheme: "http", Host: "localhost:7000"}, {Scheme: "https", Host: "localhost:7001"}},
+ MaxSnapFiles: 10,
+ MaxWalFiles: 10,
+ Name: "testname",
+ SnapCount: 10,
+ }
+
+ if cfg.Dir != wcfg.Dir {
+ t.Errorf("dir = %v, want %v", cfg.Dir, wcfg.Dir)
+ }
+ if cfg.MaxSnapFiles != wcfg.MaxSnapFiles {
+ t.Errorf("maxsnap = %v, want %v", cfg.MaxSnapFiles, wcfg.MaxSnapFiles)
+ }
+ if cfg.MaxWalFiles != wcfg.MaxWalFiles {
+ t.Errorf("maxwal = %v, want %v", cfg.MaxWalFiles, wcfg.MaxWalFiles)
+ }
+ if cfg.Name != wcfg.Name {
+ t.Errorf("name = %v, want %v", cfg.Name, wcfg.Name)
+ }
+ if cfg.SnapCount != wcfg.SnapCount {
+ t.Errorf("snapcount = %v, want %v", cfg.SnapCount, wcfg.SnapCount)
+ }
+ if !reflect.DeepEqual(cfg.LPUrls, wcfg.LPUrls) {
+ t.Errorf("listen-peer-urls = %v, want %v", cfg.LPUrls, wcfg.LPUrls)
+ }
+ if !reflect.DeepEqual(cfg.LCUrls, wcfg.LCUrls) {
+ t.Errorf("listen-client-urls = %v, want %v", cfg.LCUrls, wcfg.LCUrls)
+ }
+}
+
+func validateClusteringFlags(t *testing.T, cfg *config) {
+ wcfg := newConfig()
+ wcfg.APUrls = []url.URL{{Scheme: "http", Host: "localhost:8000"}, {Scheme: "https", Host: "localhost:8001"}}
+ wcfg.ACUrls = []url.URL{{Scheme: "http", Host: "localhost:7000"}, {Scheme: "https", Host: "localhost:7001"}}
+ wcfg.ClusterState = embed.ClusterStateFlagExisting
+ wcfg.fallback.Set(fallbackFlagExit)
+ wcfg.InitialCluster = "0=http://localhost:8000"
+ wcfg.InitialClusterToken = "etcdtest"
+
+ if cfg.ClusterState != wcfg.ClusterState {
+ t.Errorf("clusterState = %v, want %v", cfg.ClusterState, wcfg.ClusterState)
+ }
+ if cfg.fallback.String() != wcfg.fallback.String() {
+ t.Errorf("fallback = %v, want %v", cfg.fallback, wcfg.fallback)
+ }
+ if cfg.InitialCluster != wcfg.InitialCluster {
+ t.Errorf("initialCluster = %v, want %v", cfg.InitialCluster, wcfg.InitialCluster)
+ }
+ if cfg.InitialClusterToken != wcfg.InitialClusterToken {
+ t.Errorf("initialClusterToken = %v, want %v", cfg.InitialClusterToken, wcfg.InitialClusterToken)
+ }
+ if !reflect.DeepEqual(cfg.APUrls, wcfg.APUrls) {
+ t.Errorf("initial-advertise-peer-urls = %v, want %v", cfg.LPUrls, wcfg.LPUrls)
+ }
+ if !reflect.DeepEqual(cfg.ACUrls, wcfg.ACUrls) {
+ t.Errorf("advertise-client-urls = %v, want %v", cfg.LCUrls, wcfg.LCUrls)
+ }
+}
+
+func validateOtherFlags(t *testing.T, cfg *config) {
+ wcfg := newConfig()
+ wcfg.proxy.Set(proxyFlagReadonly)
+ if cfg.proxy.String() != wcfg.proxy.String() {
+ t.Errorf("proxy = %v, want %v", cfg.proxy, wcfg.proxy)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdmain/doc.go b/vendor/github.com/coreos/etcd/etcdmain/doc.go
new file mode 100644
index 00000000..ff281aab
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdmain/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdmain contains the main entry point for the etcd binary.
+package etcdmain
diff --git a/vendor/github.com/coreos/etcd/etcdmain/etcd.go b/vendor/github.com/coreos/etcd/etcdmain/etcd.go
new file mode 100644
index 00000000..2f7f00d6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdmain/etcd.go
@@ -0,0 +1,405 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdmain
+
+import (
+ "crypto/tls"
+ "encoding/json"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "os"
+ "path/filepath"
+ "reflect"
+ "runtime"
+ "strings"
+ "time"
+
+ "github.com/coreos/etcd/discovery"
+ "github.com/coreos/etcd/embed"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/pkg/cors"
+ "github.com/coreos/etcd/pkg/fileutil"
+ pkgioutil "github.com/coreos/etcd/pkg/ioutil"
+ "github.com/coreos/etcd/pkg/osutil"
+ "github.com/coreos/etcd/pkg/transport"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/proxy/httpproxy"
+ "github.com/coreos/etcd/version"
+ "github.com/coreos/pkg/capnslog"
+ "github.com/grpc-ecosystem/go-grpc-prometheus"
+ "github.com/prometheus/client_golang/prometheus"
+ "google.golang.org/grpc"
+)
+
+type dirType string
+
+var plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "etcdmain")
+
+var (
+ dirMember = dirType("member")
+ dirProxy = dirType("proxy")
+ dirEmpty = dirType("empty")
+)
+
+func startEtcdOrProxyV2() {
+ grpc.EnableTracing = false
+
+ cfg := newConfig()
+ defaultInitialCluster := cfg.InitialCluster
+
+ err := cfg.parse(os.Args[1:])
+ if err != nil {
+ plog.Errorf("error verifying flags, %v. See 'etcd --help'.", err)
+ switch err {
+ case embed.ErrUnsetAdvertiseClientURLsFlag:
+ plog.Errorf("When listening on specific address(es), this etcd process must advertise accessible url(s) to each connected client.")
+ }
+ os.Exit(1)
+ }
+ setupLogging(cfg)
+
+ var stopped <-chan struct{}
+ var errc <-chan error
+
+ plog.Infof("etcd Version: %s\n", version.Version)
+ plog.Infof("Git SHA: %s\n", version.GitSHA)
+ plog.Infof("Go Version: %s\n", runtime.Version())
+ plog.Infof("Go OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
+
+ GoMaxProcs := runtime.GOMAXPROCS(0)
+ plog.Infof("setting maximum number of CPUs to %d, total number of available CPUs is %d", GoMaxProcs, runtime.NumCPU())
+
+ defaultHost, dhErr := (&cfg.Config).UpdateDefaultClusterFromName(defaultInitialCluster)
+ if defaultHost != "" {
+ plog.Infof("advertising using detected default host %q", defaultHost)
+ }
+ if dhErr != nil {
+ plog.Noticef("failed to detect default host (%v)", dhErr)
+ }
+
+ if cfg.Dir == "" {
+ cfg.Dir = fmt.Sprintf("%v.etcd", cfg.Name)
+ plog.Warningf("no data-dir provided, using default data-dir ./%s", cfg.Dir)
+ }
+
+ which := identifyDataDirOrDie(cfg.Dir)
+ if which != dirEmpty {
+ plog.Noticef("the server is already initialized as %v before, starting as etcd %v...", which, which)
+ switch which {
+ case dirMember:
+ stopped, errc, err = startEtcd(&cfg.Config)
+ case dirProxy:
+ err = startProxy(cfg)
+ default:
+ plog.Panicf("unhandled dir type %v", which)
+ }
+ } else {
+ shouldProxy := cfg.isProxy()
+ if !shouldProxy {
+ stopped, errc, err = startEtcd(&cfg.Config)
+ if derr, ok := err.(*etcdserver.DiscoveryError); ok && derr.Err == discovery.ErrFullCluster {
+ if cfg.shouldFallbackToProxy() {
+ plog.Noticef("discovery cluster full, falling back to %s", fallbackFlagProxy)
+ shouldProxy = true
+ }
+ }
+ }
+ if shouldProxy {
+ err = startProxy(cfg)
+ }
+ }
+
+ if err != nil {
+ if derr, ok := err.(*etcdserver.DiscoveryError); ok {
+ switch derr.Err {
+ case discovery.ErrDuplicateID:
+ plog.Errorf("member %q has previously registered with discovery service token (%s).", cfg.Name, cfg.Durl)
+ plog.Errorf("But etcd could not find valid cluster configuration in the given data dir (%s).", cfg.Dir)
+ plog.Infof("Please check the given data dir path if the previous bootstrap succeeded")
+ plog.Infof("or use a new discovery token if the previous bootstrap failed.")
+ case discovery.ErrDuplicateName:
+ plog.Errorf("member with duplicated name has registered with discovery service token(%s).", cfg.Durl)
+ plog.Errorf("please check (cURL) the discovery token for more information.")
+ plog.Errorf("please do not reuse the discovery token and generate a new one to bootstrap the cluster.")
+ default:
+ plog.Errorf("%v", err)
+ plog.Infof("discovery token %s was used, but failed to bootstrap the cluster.", cfg.Durl)
+ plog.Infof("please generate a new discovery token and try to bootstrap again.")
+ }
+ os.Exit(1)
+ }
+
+ if strings.Contains(err.Error(), "include") && strings.Contains(err.Error(), "--initial-cluster") {
+ plog.Infof("%v", err)
+ if cfg.InitialCluster == cfg.InitialClusterFromName(cfg.Name) {
+ plog.Infof("forgot to set --initial-cluster flag?")
+ }
+ if types.URLs(cfg.APUrls).String() == embed.DefaultInitialAdvertisePeerURLs {
+ plog.Infof("forgot to set --initial-advertise-peer-urls flag?")
+ }
+ if cfg.InitialCluster == cfg.InitialClusterFromName(cfg.Name) && len(cfg.Durl) == 0 {
+ plog.Infof("if you want to use discovery service, please set --discovery flag.")
+ }
+ os.Exit(1)
+ }
+ plog.Fatalf("%v", err)
+ }
+
+ osutil.HandleInterrupts()
+
+ // At this point, the initialization of etcd is done.
+ // The listeners are listening on the TCP ports and ready
+ // for accepting connections. The etcd instance should be
+ // joined with the cluster and ready to serve incoming
+ // connections.
+ notifySystemd()
+
+ select {
+ case lerr := <-errc:
+ // fatal out on listener errors
+ plog.Fatal(lerr)
+ case <-stopped:
+ }
+
+ osutil.Exit(0)
+}
+
+// startEtcd runs StartEtcd in addition to hooks needed for standalone etcd.
+func startEtcd(cfg *embed.Config) (<-chan struct{}, <-chan error, error) {
+ if cfg.Metrics == "extensive" {
+ grpc_prometheus.EnableHandlingTimeHistogram()
+ }
+
+ e, err := embed.StartEtcd(cfg)
+ if err != nil {
+ return nil, nil, err
+ }
+ osutil.RegisterInterruptHandler(e.Close)
+ select {
+ case <-e.Server.ReadyNotify(): // wait for e.Server to join the cluster
+ case <-e.Server.StopNotify(): // publish aborted from 'ErrStopped'
+ }
+ return e.Server.StopNotify(), e.Err(), nil
+}
+
+// startProxy launches an HTTP proxy for client communication which proxies to other etcd nodes.
+func startProxy(cfg *config) error {
+ plog.Notice("proxy: this proxy supports v2 API only!")
+
+ pt, err := transport.NewTimeoutTransport(cfg.PeerTLSInfo, time.Duration(cfg.ProxyDialTimeoutMs)*time.Millisecond, time.Duration(cfg.ProxyReadTimeoutMs)*time.Millisecond, time.Duration(cfg.ProxyWriteTimeoutMs)*time.Millisecond)
+ if err != nil {
+ return err
+ }
+ pt.MaxIdleConnsPerHost = httpproxy.DefaultMaxIdleConnsPerHost
+
+ tr, err := transport.NewTimeoutTransport(cfg.PeerTLSInfo, time.Duration(cfg.ProxyDialTimeoutMs)*time.Millisecond, time.Duration(cfg.ProxyReadTimeoutMs)*time.Millisecond, time.Duration(cfg.ProxyWriteTimeoutMs)*time.Millisecond)
+ if err != nil {
+ return err
+ }
+
+ cfg.Dir = filepath.Join(cfg.Dir, "proxy")
+ err = os.MkdirAll(cfg.Dir, fileutil.PrivateDirMode)
+ if err != nil {
+ return err
+ }
+
+ var peerURLs []string
+ clusterfile := filepath.Join(cfg.Dir, "cluster")
+
+ b, err := ioutil.ReadFile(clusterfile)
+ switch {
+ case err == nil:
+ if cfg.Durl != "" {
+ plog.Warningf("discovery token ignored since the proxy has already been initialized. Valid cluster file found at %q", clusterfile)
+ }
+ if cfg.DNSCluster != "" {
+ plog.Warningf("DNS SRV discovery ignored since the proxy has already been initialized. Valid cluster file found at %q", clusterfile)
+ }
+ urls := struct{ PeerURLs []string }{}
+ err = json.Unmarshal(b, &urls)
+ if err != nil {
+ return err
+ }
+ peerURLs = urls.PeerURLs
+ plog.Infof("proxy: using peer urls %v from cluster file %q", peerURLs, clusterfile)
+ case os.IsNotExist(err):
+ var urlsmap types.URLsMap
+ urlsmap, _, err = cfg.PeerURLsMapAndToken("proxy")
+ if err != nil {
+ return fmt.Errorf("error setting up initial cluster: %v", err)
+ }
+
+ if cfg.Durl != "" {
+ var s string
+ s, err = discovery.GetCluster(cfg.Durl, cfg.Dproxy)
+ if err != nil {
+ return err
+ }
+ if urlsmap, err = types.NewURLsMap(s); err != nil {
+ return err
+ }
+ }
+ peerURLs = urlsmap.URLs()
+ plog.Infof("proxy: using peer urls %v ", peerURLs)
+ default:
+ return err
+ }
+
+ clientURLs := []string{}
+ uf := func() []string {
+ gcls, gerr := etcdserver.GetClusterFromRemotePeers(peerURLs, tr)
+
+ if gerr != nil {
+ plog.Warningf("proxy: %v", gerr)
+ return []string{}
+ }
+
+ clientURLs = gcls.ClientURLs()
+
+ urls := struct{ PeerURLs []string }{gcls.PeerURLs()}
+ b, jerr := json.Marshal(urls)
+ if jerr != nil {
+ plog.Warningf("proxy: error on marshal peer urls %s", jerr)
+ return clientURLs
+ }
+
+ err = pkgioutil.WriteAndSyncFile(clusterfile+".bak", b, 0600)
+ if err != nil {
+ plog.Warningf("proxy: error on writing urls %s", err)
+ return clientURLs
+ }
+ err = os.Rename(clusterfile+".bak", clusterfile)
+ if err != nil {
+ plog.Warningf("proxy: error on updating clusterfile %s", err)
+ return clientURLs
+ }
+ if !reflect.DeepEqual(gcls.PeerURLs(), peerURLs) {
+ plog.Noticef("proxy: updated peer urls in cluster file from %v to %v", peerURLs, gcls.PeerURLs())
+ }
+ peerURLs = gcls.PeerURLs()
+
+ return clientURLs
+ }
+ ph := httpproxy.NewHandler(pt, uf, time.Duration(cfg.ProxyFailureWaitMs)*time.Millisecond, time.Duration(cfg.ProxyRefreshIntervalMs)*time.Millisecond)
+ ph = &cors.CORSHandler{
+ Handler: ph,
+ Info: cfg.CorsInfo,
+ }
+
+ if cfg.isReadonlyProxy() {
+ ph = httpproxy.NewReadonlyHandler(ph)
+ }
+ // Start a proxy server goroutine for each listen address
+ for _, u := range cfg.LCUrls {
+ l, err := transport.NewListener(u.Host, u.Scheme, &cfg.ClientTLSInfo)
+ if err != nil {
+ return err
+ }
+
+ host := u.String()
+ go func() {
+ plog.Info("proxy: listening for client requests on ", host)
+ mux := http.NewServeMux()
+ mux.Handle("/metrics", prometheus.Handler())
+ mux.Handle("/", ph)
+ plog.Fatal(http.Serve(l, mux))
+ }()
+ }
+ return nil
+}
+
+// identifyDataDirOrDie returns the type of the data dir.
+// Dies if the datadir is invalid.
+func identifyDataDirOrDie(dir string) dirType {
+ names, err := fileutil.ReadDir(dir)
+ if err != nil {
+ if os.IsNotExist(err) {
+ return dirEmpty
+ }
+ plog.Fatalf("error listing data dir: %s", dir)
+ }
+
+ var m, p bool
+ for _, name := range names {
+ switch dirType(name) {
+ case dirMember:
+ m = true
+ case dirProxy:
+ p = true
+ default:
+ plog.Warningf("found invalid file/dir %s under data dir %s (Ignore this if you are upgrading etcd)", name, dir)
+ }
+ }
+
+ if m && p {
+ plog.Fatal("invalid datadir. Both member and proxy directories exist.")
+ }
+ if m {
+ return dirMember
+ }
+ if p {
+ return dirProxy
+ }
+ return dirEmpty
+}
+
+func setupLogging(cfg *config) {
+ cfg.ClientTLSInfo.HandshakeFailure = func(conn *tls.Conn, err error) {
+ plog.Infof("rejected connection from %q (%v)", conn.RemoteAddr().String(), err)
+ }
+ cfg.PeerTLSInfo.HandshakeFailure = cfg.ClientTLSInfo.HandshakeFailure
+
+ capnslog.SetGlobalLogLevel(capnslog.INFO)
+ if cfg.Debug {
+ capnslog.SetGlobalLogLevel(capnslog.DEBUG)
+ grpc.EnableTracing = true
+ }
+ if cfg.LogPkgLevels != "" {
+ repoLog := capnslog.MustRepoLogger("github.com/coreos/etcd")
+ settings, err := repoLog.ParseLogLevelConfig(cfg.LogPkgLevels)
+ if err != nil {
+ plog.Warningf("couldn't parse log level string: %s, continuing with default levels", err.Error())
+ return
+ }
+ repoLog.SetLogLevel(settings)
+ }
+
+ // capnslog initially SetFormatter(NewDefaultFormatter(os.Stderr))
+ // where NewDefaultFormatter returns NewJournaldFormatter when syscall.Getppid() == 1
+ // specify 'stdout' or 'stderr' to skip journald logging even when running under systemd
+ switch cfg.logOutput {
+ case "stdout":
+ capnslog.SetFormatter(capnslog.NewPrettyFormatter(os.Stdout, cfg.Debug))
+ case "stderr":
+ capnslog.SetFormatter(capnslog.NewPrettyFormatter(os.Stderr, cfg.Debug))
+ case "default":
+ default:
+ plog.Panicf(`unknown log-output %q (only supports "default", "stdout", "stderr")`, cfg.logOutput)
+ }
+}
+
+func checkSupportArch() {
+ // TODO qualify arm64
+ if runtime.GOARCH == "amd64" || runtime.GOARCH == "ppc64le" {
+ return
+ }
+ if env, ok := os.LookupEnv("ETCD_UNSUPPORTED_ARCH"); ok && env == runtime.GOARCH {
+ plog.Warningf("running etcd on unsupported architecture %q since ETCD_UNSUPPORTED_ARCH is set", env)
+ return
+ }
+ plog.Errorf("etcd on unsupported platform without ETCD_UNSUPPORTED_ARCH=%s set.", runtime.GOARCH)
+ os.Exit(1)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdmain/gateway.go b/vendor/github.com/coreos/etcd/etcdmain/gateway.go
new file mode 100644
index 00000000..5487414e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdmain/gateway.go
@@ -0,0 +1,135 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 etcdmain
+
+import (
+ "fmt"
+ "net"
+ "net/url"
+ "os"
+ "time"
+
+ "github.com/coreos/etcd/proxy/tcpproxy"
+
+ "github.com/spf13/cobra"
+)
+
+var (
+ gatewayListenAddr string
+ gatewayEndpoints []string
+ gatewayDNSCluster string
+ gatewayInsecureDiscovery bool
+ getewayRetryDelay time.Duration
+ gatewayCA string
+)
+
+var (
+ rootCmd = &cobra.Command{
+ Use: "etcd",
+ Short: "etcd server",
+ SuggestFor: []string{"etcd"},
+ }
+)
+
+func init() {
+ rootCmd.AddCommand(newGatewayCommand())
+}
+
+// newGatewayCommand returns the cobra command for "gateway".
+func newGatewayCommand() *cobra.Command {
+ lpc := &cobra.Command{
+ Use: "gateway <subcommand>",
+ Short: "gateway related command",
+ }
+ lpc.AddCommand(newGatewayStartCommand())
+
+ return lpc
+}
+
+func newGatewayStartCommand() *cobra.Command {
+ cmd := cobra.Command{
+ Use: "start",
+ Short: "start the gateway",
+ Run: startGateway,
+ }
+
+ cmd.Flags().StringVar(&gatewayListenAddr, "listen-addr", "127.0.0.1:23790", "listen address")
+ cmd.Flags().StringVar(&gatewayDNSCluster, "discovery-srv", "", "DNS domain used to bootstrap initial cluster")
+ cmd.Flags().BoolVar(&gatewayInsecureDiscovery, "insecure-discovery", false, "accept insecure SRV records")
+ cmd.Flags().StringVar(&gatewayCA, "trusted-ca-file", "", "path to the client server TLS CA file.")
+
+ cmd.Flags().StringSliceVar(&gatewayEndpoints, "endpoints", []string{"127.0.0.1:2379"}, "comma separated etcd cluster endpoints")
+
+ cmd.Flags().DurationVar(&getewayRetryDelay, "retry-delay", time.Minute, "duration of delay before retrying failed endpoints")
+
+ return &cmd
+}
+
+func stripSchema(eps []string) []string {
+ var endpoints []string
+
+ for _, ep := range eps {
+
+ if u, err := url.Parse(ep); err == nil && u.Host != "" {
+ ep = u.Host
+ }
+
+ endpoints = append(endpoints, ep)
+ }
+
+ return endpoints
+}
+
+func startGateway(cmd *cobra.Command, args []string) {
+ srvs := discoverEndpoints(gatewayDNSCluster, gatewayCA, gatewayInsecureDiscovery)
+ if len(srvs.Endpoints) == 0 {
+ // no endpoints discovered, fall back to provided endpoints
+ srvs.Endpoints = gatewayEndpoints
+ }
+ // Strip the schema from the endpoints because we start just a TCP proxy
+ srvs.Endpoints = stripSchema(srvs.Endpoints)
+ if len(srvs.SRVs) == 0 {
+ for _, ep := range srvs.Endpoints {
+ h, p, err := net.SplitHostPort(ep)
+ if err != nil {
+ plog.Fatalf("error parsing endpoint %q", ep)
+ }
+ var port uint16
+ fmt.Sscanf(p, "%d", &port)
+ srvs.SRVs = append(srvs.SRVs, &net.SRV{Target: h, Port: port})
+ }
+ }
+
+ if len(srvs.Endpoints) == 0 {
+ plog.Fatalf("no endpoints found")
+ }
+
+ l, err := net.Listen("tcp", gatewayListenAddr)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
+ }
+
+ tp := tcpproxy.TCPProxy{
+ Listener: l,
+ Endpoints: srvs.SRVs,
+ MonitorInterval: getewayRetryDelay,
+ }
+
+ // At this point, etcd gateway listener is initialized
+ notifySystemd()
+
+ tp.Run()
+}
diff --git a/vendor/github.com/coreos/etcd/etcdmain/grpc_proxy.go b/vendor/github.com/coreos/etcd/etcdmain/grpc_proxy.go
new file mode 100644
index 00000000..b2cc25c3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdmain/grpc_proxy.go
@@ -0,0 +1,246 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 etcdmain
+
+import (
+ "crypto/tls"
+ "fmt"
+ "net"
+ "net/http"
+ "os"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/namespace"
+ "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb"
+ "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/debugutil"
+ "github.com/coreos/etcd/pkg/transport"
+ "github.com/coreos/etcd/proxy/grpcproxy"
+
+ "github.com/cockroachdb/cmux"
+ grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
+ "github.com/prometheus/client_golang/prometheus"
+ "github.com/spf13/cobra"
+ "google.golang.org/grpc"
+)
+
+var (
+ grpcProxyListenAddr string
+ grpcProxyEndpoints []string
+ grpcProxyDNSCluster string
+ grpcProxyInsecureDiscovery bool
+ grpcProxyCert string
+ grpcProxyKey string
+ grpcProxyCA string
+
+ grpcProxyAdvertiseClientURL string
+ grpcProxyResolverPrefix string
+ grpcProxyResolverTTL int
+
+ grpcProxyNamespace string
+
+ grpcProxyEnablePprof bool
+)
+
+func init() {
+ rootCmd.AddCommand(newGRPCProxyCommand())
+}
+
+// newGRPCProxyCommand returns the cobra command for "grpc-proxy".
+func newGRPCProxyCommand() *cobra.Command {
+ lpc := &cobra.Command{
+ Use: "grpc-proxy <subcommand>",
+ Short: "grpc-proxy related command",
+ }
+ lpc.AddCommand(newGRPCProxyStartCommand())
+
+ return lpc
+}
+
+func newGRPCProxyStartCommand() *cobra.Command {
+ cmd := cobra.Command{
+ Use: "start",
+ Short: "start the grpc proxy",
+ Run: startGRPCProxy,
+ }
+
+ cmd.Flags().StringVar(&grpcProxyListenAddr, "listen-addr", "127.0.0.1:23790", "listen address")
+ cmd.Flags().StringVar(&grpcProxyDNSCluster, "discovery-srv", "", "DNS domain used to bootstrap initial cluster")
+ cmd.Flags().BoolVar(&grpcProxyInsecureDiscovery, "insecure-discovery", false, "accept insecure SRV records")
+ cmd.Flags().StringSliceVar(&grpcProxyEndpoints, "endpoints", []string{"127.0.0.1:2379"}, "comma separated etcd cluster endpoints")
+ cmd.Flags().StringVar(&grpcProxyCert, "cert", "", "identify secure connections with etcd servers using this TLS certificate file")
+ cmd.Flags().StringVar(&grpcProxyKey, "key", "", "identify secure connections with etcd servers using this TLS key file")
+ cmd.Flags().StringVar(&grpcProxyCA, "cacert", "", "verify certificates of TLS-enabled secure etcd servers using this CA bundle")
+ cmd.Flags().StringVar(&grpcProxyAdvertiseClientURL, "advertise-client-url", "127.0.0.1:23790", "advertise address to register (must be reachable by client)")
+ cmd.Flags().StringVar(&grpcProxyResolverPrefix, "resolver-prefix", "", "prefix to use for registering proxy (must be shared with other grpc-proxy members)")
+ cmd.Flags().IntVar(&grpcProxyResolverTTL, "resolver-ttl", 0, "specify TTL, in seconds, when registering proxy endpoints")
+ cmd.Flags().StringVar(&grpcProxyNamespace, "namespace", "", "string to prefix to all keys for namespacing requests")
+ cmd.Flags().BoolVar(&grpcProxyEnablePprof, "enable-pprof", false, `Enable runtime profiling data via HTTP server. Address is at client URL + "/debug/pprof/"`)
+
+ return &cmd
+}
+
+func startGRPCProxy(cmd *cobra.Command, args []string) {
+ if grpcProxyResolverPrefix != "" && grpcProxyResolverTTL < 1 {
+ fmt.Fprintln(os.Stderr, fmt.Errorf("invalid resolver-ttl %d", grpcProxyResolverTTL))
+ os.Exit(1)
+ }
+ if grpcProxyResolverPrefix == "" && grpcProxyResolverTTL > 0 {
+ fmt.Fprintln(os.Stderr, fmt.Errorf("invalid resolver-prefix %q", grpcProxyResolverPrefix))
+ os.Exit(1)
+ }
+ if grpcProxyResolverPrefix != "" && grpcProxyResolverTTL > 0 && grpcProxyAdvertiseClientURL == "" {
+ fmt.Fprintln(os.Stderr, fmt.Errorf("invalid advertise-client-url %q", grpcProxyAdvertiseClientURL))
+ os.Exit(1)
+ }
+
+ srvs := discoverEndpoints(grpcProxyDNSCluster, grpcProxyCA, grpcProxyInsecureDiscovery)
+ if len(srvs.Endpoints) != 0 {
+ grpcProxyEndpoints = srvs.Endpoints
+ }
+
+ l, err := net.Listen("tcp", grpcProxyListenAddr)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
+ }
+ if l, err = transport.NewKeepAliveListener(l, "tcp", nil); err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
+ }
+ plog.Infof("listening for grpc-proxy client requests on %s", grpcProxyListenAddr)
+ defer func() {
+ l.Close()
+ plog.Infof("stopping listening for grpc-proxy client requests on %s", grpcProxyListenAddr)
+ }()
+ m := cmux.New(l)
+
+ cfg, err := newClientCfg()
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
+ }
+
+ client, err := clientv3.New(*cfg)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
+ }
+
+ if len(grpcProxyNamespace) > 0 {
+ client.KV = namespace.NewKV(client.KV, grpcProxyNamespace)
+ client.Watcher = namespace.NewWatcher(client.Watcher, grpcProxyNamespace)
+ client.Lease = namespace.NewLease(client.Lease, grpcProxyNamespace)
+ }
+
+ kvp, _ := grpcproxy.NewKvProxy(client)
+ watchp, _ := grpcproxy.NewWatchProxy(client)
+ if grpcProxyResolverPrefix != "" {
+ grpcproxy.Register(client, grpcProxyResolverPrefix, grpcProxyAdvertiseClientURL, grpcProxyResolverTTL)
+ }
+ clusterp, _ := grpcproxy.NewClusterProxy(client, grpcProxyAdvertiseClientURL, grpcProxyResolverPrefix)
+ leasep, _ := grpcproxy.NewLeaseProxy(client)
+ mainp := grpcproxy.NewMaintenanceProxy(client)
+ authp := grpcproxy.NewAuthProxy(client)
+ electionp := grpcproxy.NewElectionProxy(client)
+ lockp := grpcproxy.NewLockProxy(client)
+
+ server := grpc.NewServer(
+ grpc.StreamInterceptor(grpc_prometheus.StreamServerInterceptor),
+ grpc.UnaryInterceptor(grpc_prometheus.UnaryServerInterceptor),
+ )
+ pb.RegisterKVServer(server, kvp)
+ pb.RegisterWatchServer(server, watchp)
+ pb.RegisterClusterServer(server, clusterp)
+ pb.RegisterLeaseServer(server, leasep)
+ pb.RegisterMaintenanceServer(server, mainp)
+ pb.RegisterAuthServer(server, authp)
+ v3electionpb.RegisterElectionServer(server, electionp)
+ v3lockpb.RegisterLockServer(server, lockp)
+
+ errc := make(chan error)
+
+ grpcl := m.Match(cmux.HTTP2())
+ go func() { errc <- server.Serve(grpcl) }()
+
+ httpmux := http.NewServeMux()
+ httpmux.HandleFunc("/", http.NotFound)
+ httpmux.Handle("/metrics", prometheus.Handler())
+ if grpcProxyEnablePprof {
+ for p, h := range debugutil.PProfHandlers() {
+ httpmux.Handle(p, h)
+ }
+ plog.Infof("pprof is enabled under %s", debugutil.HTTPPrefixPProf)
+ }
+
+ srvhttp := &http.Server{
+ Handler: httpmux,
+ }
+
+ var httpl net.Listener
+ if cfg.TLS != nil {
+ srvhttp.TLSConfig = cfg.TLS
+ httpl = tls.NewListener(m.Match(cmux.Any()), cfg.TLS)
+ } else {
+ httpl = m.Match(cmux.HTTP1())
+ }
+ go func() { errc <- srvhttp.Serve(httpl) }()
+
+ go func() { errc <- m.Serve() }()
+
+ // grpc-proxy is initialized, ready to serve
+ notifySystemd()
+
+ fmt.Fprintln(os.Stderr, <-errc)
+ os.Exit(1)
+}
+
+func newClientCfg() (*clientv3.Config, error) {
+ // set tls if any one tls option set
+ var cfgtls *transport.TLSInfo
+ tlsinfo := transport.TLSInfo{}
+ if grpcProxyCert != "" {
+ tlsinfo.CertFile = grpcProxyCert
+ cfgtls = &tlsinfo
+ }
+
+ if grpcProxyKey != "" {
+ tlsinfo.KeyFile = grpcProxyKey
+ cfgtls = &tlsinfo
+ }
+
+ if grpcProxyCA != "" {
+ tlsinfo.CAFile = grpcProxyCA
+ cfgtls = &tlsinfo
+ }
+
+ cfg := clientv3.Config{
+ Endpoints: grpcProxyEndpoints,
+ DialTimeout: 5 * time.Second,
+ }
+ if cfgtls != nil {
+ clientTLS, err := cfgtls.ClientConfig()
+ if err != nil {
+ return nil, err
+ }
+ cfg.TLS = clientTLS
+ }
+
+ // TODO: support insecure tls
+
+ return &cfg, nil
+}
diff --git a/vendor/github.com/coreos/etcd/etcdmain/help.go b/vendor/github.com/coreos/etcd/etcdmain/help.go
new file mode 100644
index 00000000..cd9282a3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdmain/help.go
@@ -0,0 +1,171 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdmain
+
+import (
+ "strconv"
+
+ "github.com/coreos/etcd/embed"
+)
+
+var (
+ usageline = `usage: etcd [flags]
+ start an etcd server
+
+ etcd --version
+ show the version of etcd
+
+ etcd -h | --help
+ show the help information about etcd
+
+ etcd --config-file
+ path to the server configuration file
+
+ etcd gateway
+ run the stateless pass-through etcd TCP connection forwarding proxy
+
+ etcd grpc-proxy
+ run the stateless etcd v3 gRPC L7 reverse proxy
+ `
+ flagsline = `
+member flags:
+
+ --name 'default'
+ human-readable name for this member.
+ --data-dir '${name}.etcd'
+ path to the data directory.
+ --wal-dir ''
+ path to the dedicated wal directory.
+ --snapshot-count '100000'
+ number of committed transactions to trigger a snapshot to disk.
+ --heartbeat-interval '100'
+ time (in milliseconds) of a heartbeat interval.
+ --election-timeout '1000'
+ time (in milliseconds) for an election to timeout. See tuning documentation for details.
+ --listen-peer-urls 'http://localhost:2380'
+ list of URLs to listen on for peer traffic.
+ --listen-client-urls 'http://localhost:2379'
+ list of URLs to listen on for client traffic.
+ --max-snapshots '` + strconv.Itoa(embed.DefaultMaxSnapshots) + `'
+ maximum number of snapshot files to retain (0 is unlimited).
+ --max-wals '` + strconv.Itoa(embed.DefaultMaxWALs) + `'
+ maximum number of wal files to retain (0 is unlimited).
+ --cors ''
+ comma-separated whitelist of origins for CORS (cross-origin resource sharing).
+ --quota-backend-bytes '0'
+ raise alarms when backend size exceeds the given quota (0 defaults to low space quota).
+
+clustering flags:
+
+ --initial-advertise-peer-urls 'http://localhost:2380'
+ list of this member's peer URLs to advertise to the rest of the cluster.
+ --initial-cluster 'default=http://localhost:2380'
+ initial cluster configuration for bootstrapping.
+ --initial-cluster-state 'new'
+ initial cluster state ('new' or 'existing').
+ --initial-cluster-token 'etcd-cluster'
+ initial cluster token for the etcd cluster during bootstrap.
+ Specifying this can protect you from unintended cross-cluster interaction when running multiple clusters.
+ --advertise-client-urls 'http://localhost:2379'
+ list of this member's client URLs to advertise to the public.
+ The client URLs advertised should be accessible to machines that talk to etcd cluster. etcd client libraries parse these URLs to connect to the cluster.
+ --discovery ''
+ discovery URL used to bootstrap the cluster.
+ --discovery-fallback 'proxy'
+ expected behavior ('exit' or 'proxy') when discovery services fails.
+ "proxy" supports v2 API only.
+ --discovery-proxy ''
+ HTTP proxy to use for traffic to discovery service.
+ --discovery-srv ''
+ dns srv domain used to bootstrap the cluster.
+ --strict-reconfig-check
+ reject reconfiguration requests that would cause quorum loss.
+ --auto-compaction-retention '0'
+ auto compaction retention in hour. 0 means disable auto compaction.
+ --enable-v2
+ Accept etcd V2 client requests.
+
+proxy flags:
+ "proxy" supports v2 API only.
+
+ --proxy 'off'
+ proxy mode setting ('off', 'readonly' or 'on').
+ --proxy-failure-wait 5000
+ time (in milliseconds) an endpoint will be held in a failed state.
+ --proxy-refresh-interval 30000
+ time (in milliseconds) of the endpoints refresh interval.
+ --proxy-dial-timeout 1000
+ time (in milliseconds) for a dial to timeout.
+ --proxy-write-timeout 5000
+ time (in milliseconds) for a write to timeout.
+ --proxy-read-timeout 0
+ time (in milliseconds) for a read to timeout.
+
+
+security flags:
+
+ --ca-file '' [DEPRECATED]
+ path to the client server TLS CA file. '-ca-file ca.crt' could be replaced by '-trusted-ca-file ca.crt -client-cert-auth' and etcd will perform the same.
+ --cert-file ''
+ path to the client server TLS cert file.
+ --key-file ''
+ path to the client server TLS key file.
+ --client-cert-auth 'false'
+ enable client cert authentication.
+ --trusted-ca-file ''
+ path to the client server TLS trusted CA key file.
+ --auto-tls 'false'
+ client TLS using generated certificates.
+ --peer-ca-file '' [DEPRECATED]
+ path to the peer server TLS CA file. '-peer-ca-file ca.crt' could be replaced by '-peer-trusted-ca-file ca.crt -peer-client-cert-auth' and etcd will perform the same.
+ --peer-cert-file ''
+ path to the peer server TLS cert file.
+ --peer-key-file ''
+ path to the peer server TLS key file.
+ --peer-client-cert-auth 'false'
+ enable peer client cert authentication.
+ --peer-trusted-ca-file ''
+ path to the peer server TLS trusted CA file.
+ --peer-auto-tls 'false'
+ peer TLS using self-generated certificates if --peer-key-file and --peer-cert-file are not provided.
+
+logging flags
+
+ --debug 'false'
+ enable debug-level logging for etcd.
+ --log-package-levels ''
+ specify a particular log level for each etcd package (eg: 'etcdmain=CRITICAL,etcdserver=DEBUG').
+ --log-output 'default'
+ specify 'stdout' or 'stderr' to skip journald logging even when running under systemd.
+
+unsafe flags:
+
+Please be CAUTIOUS when using unsafe flags because it will break the guarantees
+given by the consensus protocol.
+
+ --force-new-cluster 'false'
+ force to create a new one-member cluster.
+
+profiling flags:
+ --enable-pprof 'false'
+ Enable runtime profiling data via HTTP server. Address is at client URL + "/debug/pprof/"
+ --metrics 'basic'
+ Set level of detail for exported metrics, specify 'extensive' to include histogram metrics.
+
+auth flags:
+ --auth-token 'simple'
+ Specify a v3 authentication token type and its options ('simple' or 'jwt').
+`
+)
diff --git a/vendor/github.com/coreos/etcd/etcdmain/main.go b/vendor/github.com/coreos/etcd/etcdmain/main.go
new file mode 100644
index 00000000..fd4e7f69
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdmain/main.go
@@ -0,0 +1,53 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdmain
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/coreos/go-systemd/daemon"
+ systemdutil "github.com/coreos/go-systemd/util"
+)
+
+func Main() {
+ checkSupportArch()
+
+ if len(os.Args) > 1 {
+ switch os.Args[1] {
+ case "gateway", "grpc-proxy":
+ if err := rootCmd.Execute(); err != nil {
+ fmt.Fprint(os.Stderr, err)
+ os.Exit(1)
+ }
+ return
+ }
+ }
+
+ startEtcdOrProxyV2()
+}
+
+func notifySystemd() {
+ if !systemdutil.IsRunningSystemd() {
+ return
+ }
+ sent, err := daemon.SdNotify(false, "READY=1")
+ if err != nil {
+ plog.Errorf("failed to notify systemd for readiness: %v", err)
+ }
+ if !sent {
+ plog.Errorf("forgot to set Type=notify in systemd service file?")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdmain/util.go b/vendor/github.com/coreos/etcd/etcdmain/util.go
new file mode 100644
index 00000000..9657271d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdmain/util.go
@@ -0,0 +1,65 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 etcdmain
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/coreos/etcd/pkg/srv"
+ "github.com/coreos/etcd/pkg/transport"
+)
+
+func discoverEndpoints(dns string, ca string, insecure bool) (s srv.SRVClients) {
+ if dns == "" {
+ return s
+ }
+ srvs, err := srv.GetClient("etcd-client", dns)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
+ }
+ endpoints := srvs.Endpoints
+ plog.Infof("discovered the cluster %s from %s", endpoints, dns)
+ if insecure {
+ return *srvs
+ }
+ // confirm TLS connections are good
+ tlsInfo := transport.TLSInfo{
+ TrustedCAFile: ca,
+ ServerName: dns,
+ }
+ plog.Infof("validating discovered endpoints %v", endpoints)
+ endpoints, err = transport.ValidateSecureEndpoints(tlsInfo, endpoints)
+ if err != nil {
+ plog.Warningf("%v", err)
+ }
+ plog.Infof("using discovered endpoints %v", endpoints)
+
+ // map endpoints back to SRVClients struct with SRV data
+ eps := make(map[string]struct{})
+ for _, ep := range endpoints {
+ eps[ep] = struct{}{}
+ }
+ for i := range srvs.Endpoints {
+ if _, ok := eps[srvs.Endpoints[i]]; !ok {
+ continue
+ }
+ s.Endpoints = append(s.Endpoints, srvs.Endpoints[i])
+ s.SRVs = append(s.SRVs, srvs.SRVs[i])
+ }
+
+ return s
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/capability.go b/vendor/github.com/coreos/etcd/etcdserver/api/capability.go
new file mode 100644
index 00000000..5e2de58e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/capability.go
@@ -0,0 +1,86 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 api
+
+import (
+ "sync"
+
+ "github.com/coreos/etcd/version"
+ "github.com/coreos/go-semver/semver"
+ "github.com/coreos/pkg/capnslog"
+)
+
+type Capability string
+
+const (
+ AuthCapability Capability = "auth"
+ V3rpcCapability Capability = "v3rpc"
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "etcdserver/api")
+
+ // capabilityMaps is a static map of version to capability map.
+ capabilityMaps = map[string]map[Capability]bool{
+ "3.0.0": {AuthCapability: true, V3rpcCapability: true},
+ "3.1.0": {AuthCapability: true, V3rpcCapability: true},
+ "3.2.0": {AuthCapability: true, V3rpcCapability: true},
+ }
+
+ enableMapMu sync.RWMutex
+ // enabledMap points to a map in capabilityMaps
+ enabledMap map[Capability]bool
+
+ curVersion *semver.Version
+)
+
+func init() {
+ enabledMap = map[Capability]bool{
+ AuthCapability: true,
+ V3rpcCapability: true,
+ }
+}
+
+// UpdateCapability updates the enabledMap when the cluster version increases.
+func UpdateCapability(v *semver.Version) {
+ if v == nil {
+ // if recovered but version was never set by cluster
+ return
+ }
+ enableMapMu.Lock()
+ if curVersion != nil && !curVersion.LessThan(*v) {
+ enableMapMu.Unlock()
+ return
+ }
+ curVersion = v
+ enabledMap = capabilityMaps[curVersion.String()]
+ enableMapMu.Unlock()
+ plog.Infof("enabled capabilities for version %s", version.Cluster(v.String()))
+}
+
+func IsCapabilityEnabled(c Capability) bool {
+ enableMapMu.RLock()
+ defer enableMapMu.RUnlock()
+ if enabledMap == nil {
+ return false
+ }
+ return enabledMap[c]
+}
+
+func EnableCapability(c Capability) {
+ enableMapMu.Lock()
+ defer enableMapMu.Unlock()
+ enabledMap[c] = true
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/cluster.go b/vendor/github.com/coreos/etcd/etcdserver/api/cluster.go
new file mode 100644
index 00000000..87face4a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/cluster.go
@@ -0,0 +1,41 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 api
+
+import (
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/pkg/types"
+
+ "github.com/coreos/go-semver/semver"
+)
+
+// Cluster is an interface representing a collection of members in one etcd cluster.
+type Cluster interface {
+ // ID returns the cluster ID
+ ID() types.ID
+ // ClientURLs returns an aggregate set of all URLs on which this
+ // cluster is listening for client requests
+ ClientURLs() []string
+ // Members returns a slice of members sorted by their ID
+ Members() []*membership.Member
+ // Member retrieves a particular member based on ID, or nil if the
+ // member does not exist in the cluster
+ Member(id types.ID) *membership.Member
+ // IsIDRemoved checks whether the given ID has been removed from this
+ // cluster at some point in the past
+ IsIDRemoved(id types.ID) bool
+ // Version is the cluster-wide minimum major.minor version.
+ Version() *semver.Version
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/doc.go b/vendor/github.com/coreos/etcd/etcdserver/api/doc.go
new file mode 100644
index 00000000..f44881be
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 api manages the capabilities and features that are exposed to clients by the etcd cluster.
+package api
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/etcdhttp/base.go b/vendor/github.com/coreos/etcd/etcdserver/api/etcdhttp/base.go
new file mode 100644
index 00000000..283b32db
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/etcdhttp/base.go
@@ -0,0 +1,186 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdhttp
+
+import (
+ "encoding/json"
+ "expvar"
+ "fmt"
+ "net/http"
+ "strings"
+ "time"
+
+ etcdErr "github.com/coreos/etcd/error"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api"
+ "github.com/coreos/etcd/etcdserver/api/v2http/httptypes"
+ "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/logutil"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/version"
+ "github.com/coreos/pkg/capnslog"
+ "github.com/prometheus/client_golang/prometheus"
+ "golang.org/x/net/context"
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "etcdserver/api/etcdhttp")
+ mlog = logutil.NewMergeLogger(plog)
+)
+
+const (
+ configPath = "/config"
+ metricsPath = "/metrics"
+ healthPath = "/health"
+ varsPath = "/debug/vars"
+ versionPath = "/version"
+)
+
+// HandleBasic adds handlers to a mux for serving JSON etcd client requests
+// that do not access the v2 store.
+func HandleBasic(mux *http.ServeMux, server *etcdserver.EtcdServer) {
+ mux.HandleFunc(varsPath, serveVars)
+ mux.HandleFunc(configPath+"/local/log", logHandleFunc)
+ mux.Handle(metricsPath, prometheus.Handler())
+ mux.Handle(healthPath, healthHandler(server))
+ mux.HandleFunc(versionPath, versionHandler(server.Cluster(), serveVersion))
+}
+
+func healthHandler(server *etcdserver.EtcdServer) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ if !allowMethod(w, r, "GET") {
+ return
+ }
+ if uint64(server.Leader()) == raft.None {
+ http.Error(w, `{"health": "false"}`, http.StatusServiceUnavailable)
+ return
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+ defer cancel()
+ if _, err := server.Do(ctx, etcdserverpb.Request{Method: "QGET"}); err != nil {
+ http.Error(w, `{"health": "false"}`, http.StatusServiceUnavailable)
+ return
+ }
+ w.WriteHeader(http.StatusOK)
+ w.Write([]byte(`{"health": "true"}`))
+ }
+}
+
+func versionHandler(c api.Cluster, fn func(http.ResponseWriter, *http.Request, string)) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ v := c.Version()
+ if v != nil {
+ fn(w, r, v.String())
+ } else {
+ fn(w, r, "not_decided")
+ }
+ }
+}
+
+func serveVersion(w http.ResponseWriter, r *http.Request, clusterV string) {
+ if !allowMethod(w, r, "GET") {
+ return
+ }
+ vs := version.Versions{
+ Server: version.Version,
+ Cluster: clusterV,
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ b, err := json.Marshal(&vs)
+ if err != nil {
+ plog.Panicf("cannot marshal versions to json (%v)", err)
+ }
+ w.Write(b)
+}
+
+func logHandleFunc(w http.ResponseWriter, r *http.Request) {
+ if !allowMethod(w, r, "PUT") {
+ return
+ }
+
+ in := struct{ Level string }{}
+
+ d := json.NewDecoder(r.Body)
+ if err := d.Decode(&in); err != nil {
+ WriteError(w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Invalid json body"))
+ return
+ }
+
+ logl, err := capnslog.ParseLevel(strings.ToUpper(in.Level))
+ if err != nil {
+ WriteError(w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Invalid log level "+in.Level))
+ return
+ }
+
+ plog.Noticef("globalLogLevel set to %q", logl.String())
+ capnslog.SetGlobalLogLevel(logl)
+ w.WriteHeader(http.StatusNoContent)
+}
+
+func serveVars(w http.ResponseWriter, r *http.Request) {
+ if !allowMethod(w, r, "GET") {
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json; charset=utf-8")
+ fmt.Fprintf(w, "{\n")
+ first := true
+ expvar.Do(func(kv expvar.KeyValue) {
+ if !first {
+ fmt.Fprintf(w, ",\n")
+ }
+ first = false
+ fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value)
+ })
+ fmt.Fprintf(w, "\n}\n")
+}
+
+func allowMethod(w http.ResponseWriter, r *http.Request, m string) bool {
+ if m == r.Method {
+ return true
+ }
+ w.Header().Set("Allow", m)
+ http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
+ return false
+}
+
+// WriteError logs and writes the given Error to the ResponseWriter
+// If Error is an etcdErr, it is rendered to the ResponseWriter
+// Otherwise, it is assumed to be a StatusInternalServerError
+func WriteError(w http.ResponseWriter, r *http.Request, err error) {
+ if err == nil {
+ return
+ }
+ switch e := err.(type) {
+ case *etcdErr.Error:
+ e.WriteTo(w)
+ case *httptypes.HTTPError:
+ if et := e.WriteTo(w); et != nil {
+ plog.Debugf("error writing HTTPError (%v) to %s", et, r.RemoteAddr)
+ }
+ default:
+ switch err {
+ case etcdserver.ErrTimeoutDueToLeaderFail, etcdserver.ErrTimeoutDueToConnectionLost, etcdserver.ErrNotEnoughStartedMembers, etcdserver.ErrUnhealthy:
+ mlog.MergeError(err)
+ default:
+ mlog.MergeErrorf("got unexpected response error (%v)", err)
+ }
+ herr := httptypes.NewHTTPError(http.StatusInternalServerError, "Internal Server Error")
+ if et := herr.WriteTo(w); et != nil {
+ plog.Debugf("error writing HTTPError (%v) to %s", et, r.RemoteAddr)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/etcdhttp/peer.go b/vendor/github.com/coreos/etcd/etcdserver/api/etcdhttp/peer.go
new file mode 100644
index 00000000..721bae3c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/etcdhttp/peer.go
@@ -0,0 +1,78 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdhttp
+
+import (
+ "encoding/json"
+ "net/http"
+
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api"
+ "github.com/coreos/etcd/lease/leasehttp"
+ "github.com/coreos/etcd/rafthttp"
+)
+
+const (
+ peerMembersPrefix = "/members"
+)
+
+// NewPeerHandler generates an http.Handler to handle etcd peer requests.
+func NewPeerHandler(s *etcdserver.EtcdServer) http.Handler {
+ var lh http.Handler
+ l := s.Lessor()
+ if l != nil {
+ lh = leasehttp.NewHandler(l, func() <-chan struct{} { return s.ApplyWait() })
+ }
+ return newPeerHandler(s.Cluster(), s.RaftHandler(), lh)
+}
+
+func newPeerHandler(cluster api.Cluster, raftHandler http.Handler, leaseHandler http.Handler) http.Handler {
+ mh := &peerMembersHandler{
+ cluster: cluster,
+ }
+
+ mux := http.NewServeMux()
+ mux.HandleFunc("/", http.NotFound)
+ mux.Handle(rafthttp.RaftPrefix, raftHandler)
+ mux.Handle(rafthttp.RaftPrefix+"/", raftHandler)
+ mux.Handle(peerMembersPrefix, mh)
+ if leaseHandler != nil {
+ mux.Handle(leasehttp.LeasePrefix, leaseHandler)
+ mux.Handle(leasehttp.LeaseInternalPrefix, leaseHandler)
+ }
+ mux.HandleFunc(versionPath, versionHandler(cluster, serveVersion))
+ return mux
+}
+
+type peerMembersHandler struct {
+ cluster api.Cluster
+}
+
+func (h *peerMembersHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ if !allowMethod(w, r, "GET") {
+ return
+ }
+ w.Header().Set("X-Etcd-Cluster-ID", h.cluster.ID().String())
+
+ if r.URL.Path != peerMembersPrefix {
+ http.Error(w, "bad path", http.StatusBadRequest)
+ return
+ }
+ ms := h.cluster.Members()
+ w.Header().Set("Content-Type", "application/json")
+ if err := json.NewEncoder(w).Encode(ms); err != nil {
+ plog.Warningf("failed to encode members response (%v)", err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/etcdhttp/peer_test.go b/vendor/github.com/coreos/etcd/etcdserver/api/etcdhttp/peer_test.go
new file mode 100644
index 00000000..c2b14f19
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/etcdhttp/peer_test.go
@@ -0,0 +1,157 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdhttp
+
+import (
+ "encoding/json"
+ "io/ioutil"
+ "net/http"
+ "net/http/httptest"
+ "path"
+ "sort"
+ "testing"
+
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/rafthttp"
+ "github.com/coreos/go-semver/semver"
+)
+
+type fakeCluster struct {
+ id uint64
+ clientURLs []string
+ members map[uint64]*membership.Member
+}
+
+func (c *fakeCluster) ID() types.ID { return types.ID(c.id) }
+func (c *fakeCluster) ClientURLs() []string { return c.clientURLs }
+func (c *fakeCluster) Members() []*membership.Member {
+ var ms membership.MembersByID
+ for _, m := range c.members {
+ ms = append(ms, m)
+ }
+ sort.Sort(ms)
+ return []*membership.Member(ms)
+}
+func (c *fakeCluster) Member(id types.ID) *membership.Member { return c.members[uint64(id)] }
+func (c *fakeCluster) IsIDRemoved(id types.ID) bool { return false }
+func (c *fakeCluster) Version() *semver.Version { return nil }
+
+// TestNewPeerHandlerOnRaftPrefix tests that NewPeerHandler returns a handler that
+// handles raft-prefix requests well.
+func TestNewPeerHandlerOnRaftPrefix(t *testing.T) {
+ h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.Write([]byte("test data"))
+ })
+ ph := newPeerHandler(&fakeCluster{}, h, nil)
+ srv := httptest.NewServer(ph)
+ defer srv.Close()
+
+ tests := []string{
+ rafthttp.RaftPrefix,
+ rafthttp.RaftPrefix + "/hello",
+ }
+ for i, tt := range tests {
+ resp, err := http.Get(srv.URL + tt)
+ if err != nil {
+ t.Fatalf("unexpected http.Get error: %v", err)
+ }
+ body, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ t.Fatalf("unexpected ioutil.ReadAll error: %v", err)
+ }
+ if w := "test data"; string(body) != w {
+ t.Errorf("#%d: body = %s, want %s", i, body, w)
+ }
+ }
+}
+
+func TestServeMembersFails(t *testing.T) {
+ tests := []struct {
+ method string
+ wcode int
+ }{
+ {
+ "POST",
+ http.StatusMethodNotAllowed,
+ },
+ {
+ "DELETE",
+ http.StatusMethodNotAllowed,
+ },
+ {
+ "BAD",
+ http.StatusMethodNotAllowed,
+ },
+ }
+ for i, tt := range tests {
+ rw := httptest.NewRecorder()
+ h := &peerMembersHandler{cluster: nil}
+ h.ServeHTTP(rw, &http.Request{Method: tt.method})
+ if rw.Code != tt.wcode {
+ t.Errorf("#%d: code=%d, want %d", i, rw.Code, tt.wcode)
+ }
+ }
+}
+
+func TestServeMembersGet(t *testing.T) {
+ memb1 := membership.Member{ID: 1, Attributes: membership.Attributes{ClientURLs: []string{"http://localhost:8080"}}}
+ memb2 := membership.Member{ID: 2, Attributes: membership.Attributes{ClientURLs: []string{"http://localhost:8081"}}}
+ cluster := &fakeCluster{
+ id: 1,
+ members: map[uint64]*membership.Member{1: &memb1, 2: &memb2},
+ }
+ h := &peerMembersHandler{cluster: cluster}
+ msb, err := json.Marshal([]membership.Member{memb1, memb2})
+ if err != nil {
+ t.Fatal(err)
+ }
+ wms := string(msb) + "\n"
+
+ tests := []struct {
+ path string
+ wcode int
+ wct string
+ wbody string
+ }{
+ {peerMembersPrefix, http.StatusOK, "application/json", wms},
+ {path.Join(peerMembersPrefix, "bad"), http.StatusBadRequest, "text/plain; charset=utf-8", "bad path\n"},
+ }
+
+ for i, tt := range tests {
+ req, err := http.NewRequest("GET", testutil.MustNewURL(t, tt.path).String(), nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ rw := httptest.NewRecorder()
+ h.ServeHTTP(rw, req)
+
+ if rw.Code != tt.wcode {
+ t.Errorf("#%d: code=%d, want %d", i, rw.Code, tt.wcode)
+ }
+ if gct := rw.Header().Get("Content-Type"); gct != tt.wct {
+ t.Errorf("#%d: content-type = %s, want %s", i, gct, tt.wct)
+ }
+ if rw.Body.String() != tt.wbody {
+ t.Errorf("#%d: body = %s, want %s", i, rw.Body.String(), tt.wbody)
+ }
+ gcid := rw.Header().Get("X-Etcd-Cluster-ID")
+ wcid := cluster.ID().String()
+ if gcid != wcid {
+ t.Errorf("#%d: cid = %s, want %s", i, gcid, wcid)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/etcdhttp/version_test.go b/vendor/github.com/coreos/etcd/etcdserver/api/etcdhttp/version_test.go
new file mode 100644
index 00000000..fea16595
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/etcdhttp/version_test.go
@@ -0,0 +1,66 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 etcdhttp
+
+import (
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "testing"
+
+ "github.com/coreos/etcd/version"
+)
+
+func TestServeVersion(t *testing.T) {
+ req, err := http.NewRequest("GET", "", nil)
+ if err != nil {
+ t.Fatalf("error creating request: %v", err)
+ }
+ rw := httptest.NewRecorder()
+ serveVersion(rw, req, "2.1.0")
+ if rw.Code != http.StatusOK {
+ t.Errorf("code=%d, want %d", rw.Code, http.StatusOK)
+ }
+ vs := version.Versions{
+ Server: version.Version,
+ Cluster: "2.1.0",
+ }
+ w, err := json.Marshal(&vs)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if g := rw.Body.String(); g != string(w) {
+ t.Fatalf("body = %q, want %q", g, string(w))
+ }
+ if ct := rw.HeaderMap.Get("Content-Type"); ct != "application/json" {
+ t.Errorf("contet-type header = %s, want %s", ct, "application/json")
+ }
+}
+
+func TestServeVersionFails(t *testing.T) {
+ for _, m := range []string{
+ "CONNECT", "TRACE", "PUT", "POST", "HEAD",
+ } {
+ req, err := http.NewRequest(m, "", nil)
+ if err != nil {
+ t.Fatalf("error creating request: %v", err)
+ }
+ rw := httptest.NewRecorder()
+ serveVersion(rw, req, "2.1.0")
+ if rw.Code != http.StatusMethodNotAllowed {
+ t.Errorf("method %s: code=%d, want %d", m, rw.Code, http.StatusMethodNotAllowed)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/capability.go b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/capability.go
new file mode 100644
index 00000000..fa0bcca5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/capability.go
@@ -0,0 +1,40 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 v2http
+
+import (
+ "fmt"
+ "net/http"
+
+ "github.com/coreos/etcd/etcdserver/api"
+ "github.com/coreos/etcd/etcdserver/api/v2http/httptypes"
+)
+
+func capabilityHandler(c api.Capability, fn func(http.ResponseWriter, *http.Request)) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ if !api.IsCapabilityEnabled(c) {
+ notCapable(w, r, c)
+ return
+ }
+ fn(w, r)
+ }
+}
+
+func notCapable(w http.ResponseWriter, r *http.Request, c api.Capability) {
+ herr := httptypes.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Not capable of accessing %s feature during rolling upgrades.", c))
+ if err := herr.WriteTo(w); err != nil {
+ plog.Debugf("error writing HTTPError (%v) to %s", err, r.RemoteAddr)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/client.go b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/client.go
new file mode 100644
index 00000000..aa1e71ec
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/client.go
@@ -0,0 +1,718 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 v2http
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "net/url"
+ "path"
+ "strconv"
+ "strings"
+ "time"
+
+ etcdErr "github.com/coreos/etcd/error"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api"
+ "github.com/coreos/etcd/etcdserver/api/etcdhttp"
+ "github.com/coreos/etcd/etcdserver/api/v2http/httptypes"
+ "github.com/coreos/etcd/etcdserver/auth"
+ "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/etcdserver/stats"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/store"
+ "github.com/jonboulle/clockwork"
+ "golang.org/x/net/context"
+)
+
+const (
+ authPrefix = "/v2/auth"
+ keysPrefix = "/v2/keys"
+ machinesPrefix = "/v2/machines"
+ membersPrefix = "/v2/members"
+ statsPrefix = "/v2/stats"
+)
+
+// NewClientHandler generates a muxed http.Handler with the given parameters to serve etcd client requests.
+func NewClientHandler(server *etcdserver.EtcdServer, timeout time.Duration) http.Handler {
+ mux := http.NewServeMux()
+ etcdhttp.HandleBasic(mux, server)
+ handleV2(mux, server, timeout)
+ return requestLogger(mux)
+}
+
+func handleV2(mux *http.ServeMux, server *etcdserver.EtcdServer, timeout time.Duration) {
+ sec := auth.NewStore(server, timeout)
+ kh := &keysHandler{
+ sec: sec,
+ server: server,
+ cluster: server.Cluster(),
+ timer: server,
+ timeout: timeout,
+ clientCertAuthEnabled: server.Cfg.ClientCertAuthEnabled,
+ }
+
+ sh := &statsHandler{
+ stats: server,
+ }
+
+ mh := &membersHandler{
+ sec: sec,
+ server: server,
+ cluster: server.Cluster(),
+ timeout: timeout,
+ clock: clockwork.NewRealClock(),
+ clientCertAuthEnabled: server.Cfg.ClientCertAuthEnabled,
+ }
+
+ mah := &machinesHandler{cluster: server.Cluster()}
+
+ sech := &authHandler{
+ sec: sec,
+ cluster: server.Cluster(),
+ clientCertAuthEnabled: server.Cfg.ClientCertAuthEnabled,
+ }
+ mux.HandleFunc("/", http.NotFound)
+ mux.Handle(keysPrefix, kh)
+ mux.Handle(keysPrefix+"/", kh)
+ mux.HandleFunc(statsPrefix+"/store", sh.serveStore)
+ mux.HandleFunc(statsPrefix+"/self", sh.serveSelf)
+ mux.HandleFunc(statsPrefix+"/leader", sh.serveLeader)
+ mux.Handle(membersPrefix, mh)
+ mux.Handle(membersPrefix+"/", mh)
+ mux.Handle(machinesPrefix, mah)
+ handleAuth(mux, sech)
+}
+
+type keysHandler struct {
+ sec auth.Store
+ server etcdserver.Server
+ cluster api.Cluster
+ timer etcdserver.RaftTimer
+ timeout time.Duration
+ clientCertAuthEnabled bool
+}
+
+func (h *keysHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ if !allowMethod(w, r.Method, "HEAD", "GET", "PUT", "POST", "DELETE") {
+ return
+ }
+
+ w.Header().Set("X-Etcd-Cluster-ID", h.cluster.ID().String())
+
+ ctx, cancel := context.WithTimeout(context.Background(), h.timeout)
+ defer cancel()
+ clock := clockwork.NewRealClock()
+ startTime := clock.Now()
+ rr, noValueOnSuccess, err := parseKeyRequest(r, clock)
+ if err != nil {
+ writeKeyError(w, err)
+ return
+ }
+ // The path must be valid at this point (we've parsed the request successfully).
+ if !hasKeyPrefixAccess(h.sec, r, r.URL.Path[len(keysPrefix):], rr.Recursive, h.clientCertAuthEnabled) {
+ writeKeyNoAuth(w)
+ return
+ }
+ if !rr.Wait {
+ reportRequestReceived(rr)
+ }
+ resp, err := h.server.Do(ctx, rr)
+ if err != nil {
+ err = trimErrorPrefix(err, etcdserver.StoreKeysPrefix)
+ writeKeyError(w, err)
+ reportRequestFailed(rr, err)
+ return
+ }
+ switch {
+ case resp.Event != nil:
+ if err := writeKeyEvent(w, resp.Event, noValueOnSuccess, h.timer); err != nil {
+ // Should never be reached
+ plog.Errorf("error writing event (%v)", err)
+ }
+ reportRequestCompleted(rr, resp, startTime)
+ case resp.Watcher != nil:
+ ctx, cancel := context.WithTimeout(context.Background(), defaultWatchTimeout)
+ defer cancel()
+ handleKeyWatch(ctx, w, resp.Watcher, rr.Stream, h.timer)
+ default:
+ writeKeyError(w, errors.New("received response with no Event/Watcher!"))
+ }
+}
+
+type machinesHandler struct {
+ cluster api.Cluster
+}
+
+func (h *machinesHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ if !allowMethod(w, r.Method, "GET", "HEAD") {
+ return
+ }
+ endpoints := h.cluster.ClientURLs()
+ w.Write([]byte(strings.Join(endpoints, ", ")))
+}
+
+type membersHandler struct {
+ sec auth.Store
+ server etcdserver.Server
+ cluster api.Cluster
+ timeout time.Duration
+ clock clockwork.Clock
+ clientCertAuthEnabled bool
+}
+
+func (h *membersHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ if !allowMethod(w, r.Method, "GET", "POST", "DELETE", "PUT") {
+ return
+ }
+ if !hasWriteRootAccess(h.sec, r, h.clientCertAuthEnabled) {
+ writeNoAuth(w, r)
+ return
+ }
+ w.Header().Set("X-Etcd-Cluster-ID", h.cluster.ID().String())
+
+ ctx, cancel := context.WithTimeout(context.Background(), h.timeout)
+ defer cancel()
+
+ switch r.Method {
+ case "GET":
+ switch trimPrefix(r.URL.Path, membersPrefix) {
+ case "":
+ mc := newMemberCollection(h.cluster.Members())
+ w.Header().Set("Content-Type", "application/json")
+ if err := json.NewEncoder(w).Encode(mc); err != nil {
+ plog.Warningf("failed to encode members response (%v)", err)
+ }
+ case "leader":
+ id := h.server.Leader()
+ if id == 0 {
+ writeError(w, r, httptypes.NewHTTPError(http.StatusServiceUnavailable, "During election"))
+ return
+ }
+ m := newMember(h.cluster.Member(id))
+ w.Header().Set("Content-Type", "application/json")
+ if err := json.NewEncoder(w).Encode(m); err != nil {
+ plog.Warningf("failed to encode members response (%v)", err)
+ }
+ default:
+ writeError(w, r, httptypes.NewHTTPError(http.StatusNotFound, "Not found"))
+ }
+ case "POST":
+ req := httptypes.MemberCreateRequest{}
+ if ok := unmarshalRequest(r, &req, w); !ok {
+ return
+ }
+ now := h.clock.Now()
+ m := membership.NewMember("", req.PeerURLs, "", &now)
+ _, err := h.server.AddMember(ctx, *m)
+ switch {
+ case err == membership.ErrIDExists || err == membership.ErrPeerURLexists:
+ writeError(w, r, httptypes.NewHTTPError(http.StatusConflict, err.Error()))
+ return
+ case err != nil:
+ plog.Errorf("error adding member %s (%v)", m.ID, err)
+ writeError(w, r, err)
+ return
+ }
+ res := newMember(m)
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ if err := json.NewEncoder(w).Encode(res); err != nil {
+ plog.Warningf("failed to encode members response (%v)", err)
+ }
+ case "DELETE":
+ id, ok := getID(r.URL.Path, w)
+ if !ok {
+ return
+ }
+ _, err := h.server.RemoveMember(ctx, uint64(id))
+ switch {
+ case err == membership.ErrIDRemoved:
+ writeError(w, r, httptypes.NewHTTPError(http.StatusGone, fmt.Sprintf("Member permanently removed: %s", id)))
+ case err == membership.ErrIDNotFound:
+ writeError(w, r, httptypes.NewHTTPError(http.StatusNotFound, fmt.Sprintf("No such member: %s", id)))
+ case err != nil:
+ plog.Errorf("error removing member %s (%v)", id, err)
+ writeError(w, r, err)
+ default:
+ w.WriteHeader(http.StatusNoContent)
+ }
+ case "PUT":
+ id, ok := getID(r.URL.Path, w)
+ if !ok {
+ return
+ }
+ req := httptypes.MemberUpdateRequest{}
+ if ok := unmarshalRequest(r, &req, w); !ok {
+ return
+ }
+ m := membership.Member{
+ ID: id,
+ RaftAttributes: membership.RaftAttributes{PeerURLs: req.PeerURLs.StringSlice()},
+ }
+ _, err := h.server.UpdateMember(ctx, m)
+ switch {
+ case err == membership.ErrPeerURLexists:
+ writeError(w, r, httptypes.NewHTTPError(http.StatusConflict, err.Error()))
+ case err == membership.ErrIDNotFound:
+ writeError(w, r, httptypes.NewHTTPError(http.StatusNotFound, fmt.Sprintf("No such member: %s", id)))
+ case err != nil:
+ plog.Errorf("error updating member %s (%v)", m.ID, err)
+ writeError(w, r, err)
+ default:
+ w.WriteHeader(http.StatusNoContent)
+ }
+ }
+}
+
+type statsHandler struct {
+ stats stats.Stats
+}
+
+func (h *statsHandler) serveStore(w http.ResponseWriter, r *http.Request) {
+ if !allowMethod(w, r.Method, "GET") {
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.Write(h.stats.StoreStats())
+}
+
+func (h *statsHandler) serveSelf(w http.ResponseWriter, r *http.Request) {
+ if !allowMethod(w, r.Method, "GET") {
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.Write(h.stats.SelfStats())
+}
+
+func (h *statsHandler) serveLeader(w http.ResponseWriter, r *http.Request) {
+ if !allowMethod(w, r.Method, "GET") {
+ return
+ }
+ stats := h.stats.LeaderStats()
+ if stats == nil {
+ etcdhttp.WriteError(w, r, httptypes.NewHTTPError(http.StatusForbidden, "not current leader"))
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.Write(stats)
+}
+
+// parseKeyRequest converts a received http.Request on keysPrefix to
+// a server Request, performing validation of supplied fields as appropriate.
+// If any validation fails, an empty Request and non-nil error is returned.
+func parseKeyRequest(r *http.Request, clock clockwork.Clock) (etcdserverpb.Request, bool, error) {
+ noValueOnSuccess := false
+ emptyReq := etcdserverpb.Request{}
+
+ err := r.ParseForm()
+ if err != nil {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeInvalidForm,
+ err.Error(),
+ )
+ }
+
+ if !strings.HasPrefix(r.URL.Path, keysPrefix) {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeInvalidForm,
+ "incorrect key prefix",
+ )
+ }
+ p := path.Join(etcdserver.StoreKeysPrefix, r.URL.Path[len(keysPrefix):])
+
+ var pIdx, wIdx uint64
+ if pIdx, err = getUint64(r.Form, "prevIndex"); err != nil {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeIndexNaN,
+ `invalid value for "prevIndex"`,
+ )
+ }
+ if wIdx, err = getUint64(r.Form, "waitIndex"); err != nil {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeIndexNaN,
+ `invalid value for "waitIndex"`,
+ )
+ }
+
+ var rec, sort, wait, dir, quorum, stream bool
+ if rec, err = getBool(r.Form, "recursive"); err != nil {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeInvalidField,
+ `invalid value for "recursive"`,
+ )
+ }
+ if sort, err = getBool(r.Form, "sorted"); err != nil {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeInvalidField,
+ `invalid value for "sorted"`,
+ )
+ }
+ if wait, err = getBool(r.Form, "wait"); err != nil {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeInvalidField,
+ `invalid value for "wait"`,
+ )
+ }
+ // TODO(jonboulle): define what parameters dir is/isn't compatible with?
+ if dir, err = getBool(r.Form, "dir"); err != nil {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeInvalidField,
+ `invalid value for "dir"`,
+ )
+ }
+ if quorum, err = getBool(r.Form, "quorum"); err != nil {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeInvalidField,
+ `invalid value for "quorum"`,
+ )
+ }
+ if stream, err = getBool(r.Form, "stream"); err != nil {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeInvalidField,
+ `invalid value for "stream"`,
+ )
+ }
+
+ if wait && r.Method != "GET" {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeInvalidField,
+ `"wait" can only be used with GET requests`,
+ )
+ }
+
+ pV := r.FormValue("prevValue")
+ if _, ok := r.Form["prevValue"]; ok && pV == "" {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodePrevValueRequired,
+ `"prevValue" cannot be empty`,
+ )
+ }
+
+ if noValueOnSuccess, err = getBool(r.Form, "noValueOnSuccess"); err != nil {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeInvalidField,
+ `invalid value for "noValueOnSuccess"`,
+ )
+ }
+
+ // TTL is nullable, so leave it null if not specified
+ // or an empty string
+ var ttl *uint64
+ if len(r.FormValue("ttl")) > 0 {
+ i, err := getUint64(r.Form, "ttl")
+ if err != nil {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeTTLNaN,
+ `invalid value for "ttl"`,
+ )
+ }
+ ttl = &i
+ }
+
+ // prevExist is nullable, so leave it null if not specified
+ var pe *bool
+ if _, ok := r.Form["prevExist"]; ok {
+ bv, err := getBool(r.Form, "prevExist")
+ if err != nil {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeInvalidField,
+ "invalid value for prevExist",
+ )
+ }
+ pe = &bv
+ }
+
+ // refresh is nullable, so leave it null if not specified
+ var refresh *bool
+ if _, ok := r.Form["refresh"]; ok {
+ bv, err := getBool(r.Form, "refresh")
+ if err != nil {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeInvalidField,
+ "invalid value for refresh",
+ )
+ }
+ refresh = &bv
+ if refresh != nil && *refresh {
+ val := r.FormValue("value")
+ if _, ok := r.Form["value"]; ok && val != "" {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeRefreshValue,
+ `A value was provided on a refresh`,
+ )
+ }
+ if ttl == nil {
+ return emptyReq, false, etcdErr.NewRequestError(
+ etcdErr.EcodeRefreshTTLRequired,
+ `No TTL value set`,
+ )
+ }
+ }
+ }
+
+ rr := etcdserverpb.Request{
+ Method: r.Method,
+ Path: p,
+ Val: r.FormValue("value"),
+ Dir: dir,
+ PrevValue: pV,
+ PrevIndex: pIdx,
+ PrevExist: pe,
+ Wait: wait,
+ Since: wIdx,
+ Recursive: rec,
+ Sorted: sort,
+ Quorum: quorum,
+ Stream: stream,
+ }
+
+ if pe != nil {
+ rr.PrevExist = pe
+ }
+
+ if refresh != nil {
+ rr.Refresh = refresh
+ }
+
+ // Null TTL is equivalent to unset Expiration
+ if ttl != nil {
+ expr := time.Duration(*ttl) * time.Second
+ rr.Expiration = clock.Now().Add(expr).UnixNano()
+ }
+
+ return rr, noValueOnSuccess, nil
+}
+
+// writeKeyEvent trims the prefix of key path in a single Event under
+// StoreKeysPrefix, serializes it and writes the resulting JSON to the given
+// ResponseWriter, along with the appropriate headers.
+func writeKeyEvent(w http.ResponseWriter, ev *store.Event, noValueOnSuccess bool, rt etcdserver.RaftTimer) error {
+ if ev == nil {
+ return errors.New("cannot write empty Event!")
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.Header().Set("X-Etcd-Index", fmt.Sprint(ev.EtcdIndex))
+ w.Header().Set("X-Raft-Index", fmt.Sprint(rt.Index()))
+ w.Header().Set("X-Raft-Term", fmt.Sprint(rt.Term()))
+
+ if ev.IsCreated() {
+ w.WriteHeader(http.StatusCreated)
+ }
+
+ ev = trimEventPrefix(ev, etcdserver.StoreKeysPrefix)
+ if noValueOnSuccess &&
+ (ev.Action == store.Set || ev.Action == store.CompareAndSwap ||
+ ev.Action == store.Create || ev.Action == store.Update) {
+ ev.Node = nil
+ ev.PrevNode = nil
+ }
+ return json.NewEncoder(w).Encode(ev)
+}
+
+func writeKeyNoAuth(w http.ResponseWriter) {
+ e := etcdErr.NewError(etcdErr.EcodeUnauthorized, "Insufficient credentials", 0)
+ e.WriteTo(w)
+}
+
+// writeKeyError logs and writes the given Error to the ResponseWriter.
+// If Error is not an etcdErr, the error will be converted to an etcd error.
+func writeKeyError(w http.ResponseWriter, err error) {
+ if err == nil {
+ return
+ }
+ switch e := err.(type) {
+ case *etcdErr.Error:
+ e.WriteTo(w)
+ default:
+ switch err {
+ case etcdserver.ErrTimeoutDueToLeaderFail, etcdserver.ErrTimeoutDueToConnectionLost:
+ mlog.MergeError(err)
+ default:
+ mlog.MergeErrorf("got unexpected response error (%v)", err)
+ }
+ ee := etcdErr.NewError(etcdErr.EcodeRaftInternal, err.Error(), 0)
+ ee.WriteTo(w)
+ }
+}
+
+func handleKeyWatch(ctx context.Context, w http.ResponseWriter, wa store.Watcher, stream bool, rt etcdserver.RaftTimer) {
+ defer wa.Remove()
+ ech := wa.EventChan()
+ var nch <-chan bool
+ if x, ok := w.(http.CloseNotifier); ok {
+ nch = x.CloseNotify()
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.Header().Set("X-Etcd-Index", fmt.Sprint(wa.StartIndex()))
+ w.Header().Set("X-Raft-Index", fmt.Sprint(rt.Index()))
+ w.Header().Set("X-Raft-Term", fmt.Sprint(rt.Term()))
+ w.WriteHeader(http.StatusOK)
+
+ // Ensure headers are flushed early, in case of long polling
+ w.(http.Flusher).Flush()
+
+ for {
+ select {
+ case <-nch:
+ // Client closed connection. Nothing to do.
+ return
+ case <-ctx.Done():
+ // Timed out. net/http will close the connection for us, so nothing to do.
+ return
+ case ev, ok := <-ech:
+ if !ok {
+ // If the channel is closed this may be an indication of
+ // that notifications are much more than we are able to
+ // send to the client in time. Then we simply end streaming.
+ return
+ }
+ ev = trimEventPrefix(ev, etcdserver.StoreKeysPrefix)
+ if err := json.NewEncoder(w).Encode(ev); err != nil {
+ // Should never be reached
+ plog.Warningf("error writing event (%v)", err)
+ return
+ }
+ if !stream {
+ return
+ }
+ w.(http.Flusher).Flush()
+ }
+ }
+}
+
+func trimEventPrefix(ev *store.Event, prefix string) *store.Event {
+ if ev == nil {
+ return nil
+ }
+ // Since the *Event may reference one in the store history
+ // history, we must copy it before modifying
+ e := ev.Clone()
+ trimNodeExternPrefix(e.Node, prefix)
+ trimNodeExternPrefix(e.PrevNode, prefix)
+ return e
+}
+
+func trimNodeExternPrefix(n *store.NodeExtern, prefix string) {
+ if n == nil {
+ return
+ }
+ n.Key = strings.TrimPrefix(n.Key, prefix)
+ for _, nn := range n.Nodes {
+ trimNodeExternPrefix(nn, prefix)
+ }
+}
+
+func trimErrorPrefix(err error, prefix string) error {
+ if e, ok := err.(*etcdErr.Error); ok {
+ e.Cause = strings.TrimPrefix(e.Cause, prefix)
+ }
+ return err
+}
+
+func unmarshalRequest(r *http.Request, req json.Unmarshaler, w http.ResponseWriter) bool {
+ ctype := r.Header.Get("Content-Type")
+ semicolonPosition := strings.Index(ctype, ";")
+ if semicolonPosition != -1 {
+ ctype = strings.TrimSpace(strings.ToLower(ctype[0:semicolonPosition]))
+ }
+ if ctype != "application/json" {
+ writeError(w, r, httptypes.NewHTTPError(http.StatusUnsupportedMediaType, fmt.Sprintf("Bad Content-Type %s, accept application/json", ctype)))
+ return false
+ }
+ b, err := ioutil.ReadAll(r.Body)
+ if err != nil {
+ writeError(w, r, httptypes.NewHTTPError(http.StatusBadRequest, err.Error()))
+ return false
+ }
+ if err := req.UnmarshalJSON(b); err != nil {
+ writeError(w, r, httptypes.NewHTTPError(http.StatusBadRequest, err.Error()))
+ return false
+ }
+ return true
+}
+
+func getID(p string, w http.ResponseWriter) (types.ID, bool) {
+ idStr := trimPrefix(p, membersPrefix)
+ if idStr == "" {
+ http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
+ return 0, false
+ }
+ id, err := types.IDFromString(idStr)
+ if err != nil {
+ writeError(w, nil, httptypes.NewHTTPError(http.StatusNotFound, fmt.Sprintf("No such member: %s", idStr)))
+ return 0, false
+ }
+ return id, true
+}
+
+// getUint64 extracts a uint64 by the given key from a Form. If the key does
+// not exist in the form, 0 is returned. If the key exists but the value is
+// badly formed, an error is returned. If multiple values are present only the
+// first is considered.
+func getUint64(form url.Values, key string) (i uint64, err error) {
+ if vals, ok := form[key]; ok {
+ i, err = strconv.ParseUint(vals[0], 10, 64)
+ }
+ return
+}
+
+// getBool extracts a bool by the given key from a Form. If the key does not
+// exist in the form, false is returned. If the key exists but the value is
+// badly formed, an error is returned. If multiple values are present only the
+// first is considered.
+func getBool(form url.Values, key string) (b bool, err error) {
+ if vals, ok := form[key]; ok {
+ b, err = strconv.ParseBool(vals[0])
+ }
+ return
+}
+
+// trimPrefix removes a given prefix and any slash following the prefix
+// e.g.: trimPrefix("foo", "foo") == trimPrefix("foo/", "foo") == ""
+func trimPrefix(p, prefix string) (s string) {
+ s = strings.TrimPrefix(p, prefix)
+ s = strings.TrimPrefix(s, "/")
+ return
+}
+
+func newMemberCollection(ms []*membership.Member) *httptypes.MemberCollection {
+ c := httptypes.MemberCollection(make([]httptypes.Member, len(ms)))
+
+ for i, m := range ms {
+ c[i] = newMember(m)
+ }
+
+ return &c
+}
+
+func newMember(m *membership.Member) httptypes.Member {
+ tm := httptypes.Member{
+ ID: m.ID.String(),
+ Name: m.Name,
+ PeerURLs: make([]string, len(m.PeerURLs)),
+ ClientURLs: make([]string, len(m.ClientURLs)),
+ }
+
+ copy(tm.PeerURLs, m.PeerURLs)
+ copy(tm.ClientURLs, m.ClientURLs)
+
+ return tm
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/client_auth.go b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/client_auth.go
new file mode 100644
index 00000000..606e2e00
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/client_auth.go
@@ -0,0 +1,543 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 v2http
+
+import (
+ "encoding/json"
+ "net/http"
+ "path"
+ "strings"
+
+ "github.com/coreos/etcd/etcdserver/api"
+ "github.com/coreos/etcd/etcdserver/api/v2http/httptypes"
+ "github.com/coreos/etcd/etcdserver/auth"
+)
+
+type authHandler struct {
+ sec auth.Store
+ cluster api.Cluster
+ clientCertAuthEnabled bool
+}
+
+func hasWriteRootAccess(sec auth.Store, r *http.Request, clientCertAuthEnabled bool) bool {
+ if r.Method == "GET" || r.Method == "HEAD" {
+ return true
+ }
+ return hasRootAccess(sec, r, clientCertAuthEnabled)
+}
+
+func userFromBasicAuth(sec auth.Store, r *http.Request) *auth.User {
+ username, password, ok := r.BasicAuth()
+ if !ok {
+ plog.Warningf("auth: malformed basic auth encoding")
+ return nil
+ }
+ user, err := sec.GetUser(username)
+ if err != nil {
+ return nil
+ }
+
+ ok = sec.CheckPassword(user, password)
+ if !ok {
+ plog.Warningf("auth: incorrect password for user: %s", username)
+ return nil
+ }
+ return &user
+}
+
+func userFromClientCertificate(sec auth.Store, r *http.Request) *auth.User {
+ if r.TLS == nil {
+ return nil
+ }
+
+ for _, chains := range r.TLS.VerifiedChains {
+ for _, chain := range chains {
+ plog.Debugf("auth: found common name %s.\n", chain.Subject.CommonName)
+ user, err := sec.GetUser(chain.Subject.CommonName)
+ if err == nil {
+ plog.Debugf("auth: authenticated user %s by cert common name.", user.User)
+ return &user
+ }
+ }
+ }
+ return nil
+}
+
+func hasRootAccess(sec auth.Store, r *http.Request, clientCertAuthEnabled bool) bool {
+ if sec == nil {
+ // No store means no auth available, eg, tests.
+ return true
+ }
+ if !sec.AuthEnabled() {
+ return true
+ }
+
+ var rootUser *auth.User
+ if r.Header.Get("Authorization") == "" && clientCertAuthEnabled {
+ rootUser = userFromClientCertificate(sec, r)
+ if rootUser == nil {
+ return false
+ }
+ } else {
+ rootUser = userFromBasicAuth(sec, r)
+ if rootUser == nil {
+ return false
+ }
+ }
+
+ for _, role := range rootUser.Roles {
+ if role == auth.RootRoleName {
+ return true
+ }
+ }
+ plog.Warningf("auth: user %s does not have the %s role for resource %s.", rootUser.User, auth.RootRoleName, r.URL.Path)
+ return false
+}
+
+func hasKeyPrefixAccess(sec auth.Store, r *http.Request, key string, recursive, clientCertAuthEnabled bool) bool {
+ if sec == nil {
+ // No store means no auth available, eg, tests.
+ return true
+ }
+ if !sec.AuthEnabled() {
+ return true
+ }
+
+ var user *auth.User
+ if r.Header.Get("Authorization") == "" {
+ if clientCertAuthEnabled {
+ user = userFromClientCertificate(sec, r)
+ }
+ if user == nil {
+ return hasGuestAccess(sec, r, key)
+ }
+ } else {
+ user = userFromBasicAuth(sec, r)
+ if user == nil {
+ return false
+ }
+ }
+
+ writeAccess := r.Method != "GET" && r.Method != "HEAD"
+ for _, roleName := range user.Roles {
+ role, err := sec.GetRole(roleName)
+ if err != nil {
+ continue
+ }
+ if recursive {
+ if role.HasRecursiveAccess(key, writeAccess) {
+ return true
+ }
+ } else if role.HasKeyAccess(key, writeAccess) {
+ return true
+ }
+ }
+ plog.Warningf("auth: invalid access for user %s on key %s.", user.User, key)
+ return false
+}
+
+func hasGuestAccess(sec auth.Store, r *http.Request, key string) bool {
+ writeAccess := r.Method != "GET" && r.Method != "HEAD"
+ role, err := sec.GetRole(auth.GuestRoleName)
+ if err != nil {
+ return false
+ }
+ if role.HasKeyAccess(key, writeAccess) {
+ return true
+ }
+ plog.Warningf("auth: invalid access for unauthenticated user on resource %s.", key)
+ return false
+}
+
+func writeNoAuth(w http.ResponseWriter, r *http.Request) {
+ herr := httptypes.NewHTTPError(http.StatusUnauthorized, "Insufficient credentials")
+ if err := herr.WriteTo(w); err != nil {
+ plog.Debugf("error writing HTTPError (%v) to %s", err, r.RemoteAddr)
+ }
+}
+
+func handleAuth(mux *http.ServeMux, sh *authHandler) {
+ mux.HandleFunc(authPrefix+"/roles", capabilityHandler(api.AuthCapability, sh.baseRoles))
+ mux.HandleFunc(authPrefix+"/roles/", capabilityHandler(api.AuthCapability, sh.handleRoles))
+ mux.HandleFunc(authPrefix+"/users", capabilityHandler(api.AuthCapability, sh.baseUsers))
+ mux.HandleFunc(authPrefix+"/users/", capabilityHandler(api.AuthCapability, sh.handleUsers))
+ mux.HandleFunc(authPrefix+"/enable", capabilityHandler(api.AuthCapability, sh.enableDisable))
+}
+
+func (sh *authHandler) baseRoles(w http.ResponseWriter, r *http.Request) {
+ if !allowMethod(w, r.Method, "GET") {
+ return
+ }
+ if !hasRootAccess(sh.sec, r, sh.clientCertAuthEnabled) {
+ writeNoAuth(w, r)
+ return
+ }
+
+ w.Header().Set("X-Etcd-Cluster-ID", sh.cluster.ID().String())
+ w.Header().Set("Content-Type", "application/json")
+
+ roles, err := sh.sec.AllRoles()
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+ if roles == nil {
+ roles = make([]string, 0)
+ }
+
+ err = r.ParseForm()
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+
+ var rolesCollections struct {
+ Roles []auth.Role `json:"roles"`
+ }
+ for _, roleName := range roles {
+ var role auth.Role
+ role, err = sh.sec.GetRole(roleName)
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+ rolesCollections.Roles = append(rolesCollections.Roles, role)
+ }
+ err = json.NewEncoder(w).Encode(rolesCollections)
+
+ if err != nil {
+ plog.Warningf("baseRoles error encoding on %s", r.URL)
+ writeError(w, r, err)
+ return
+ }
+}
+
+func (sh *authHandler) handleRoles(w http.ResponseWriter, r *http.Request) {
+ subpath := path.Clean(r.URL.Path[len(authPrefix):])
+ // Split "/roles/rolename/command".
+ // First item is an empty string, second is "roles"
+ pieces := strings.Split(subpath, "/")
+ if len(pieces) == 2 {
+ sh.baseRoles(w, r)
+ return
+ }
+ if len(pieces) != 3 {
+ writeError(w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Invalid path"))
+ return
+ }
+ sh.forRole(w, r, pieces[2])
+}
+
+func (sh *authHandler) forRole(w http.ResponseWriter, r *http.Request, role string) {
+ if !allowMethod(w, r.Method, "GET", "PUT", "DELETE") {
+ return
+ }
+ if !hasRootAccess(sh.sec, r, sh.clientCertAuthEnabled) {
+ writeNoAuth(w, r)
+ return
+ }
+ w.Header().Set("X-Etcd-Cluster-ID", sh.cluster.ID().String())
+ w.Header().Set("Content-Type", "application/json")
+
+ switch r.Method {
+ case "GET":
+ data, err := sh.sec.GetRole(role)
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+ err = json.NewEncoder(w).Encode(data)
+ if err != nil {
+ plog.Warningf("forRole error encoding on %s", r.URL)
+ return
+ }
+ return
+ case "PUT":
+ var in auth.Role
+ err := json.NewDecoder(r.Body).Decode(&in)
+ if err != nil {
+ writeError(w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Invalid JSON in request body."))
+ return
+ }
+ if in.Role != role {
+ writeError(w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Role JSON name does not match the name in the URL"))
+ return
+ }
+
+ var out auth.Role
+
+ // create
+ if in.Grant.IsEmpty() && in.Revoke.IsEmpty() {
+ err = sh.sec.CreateRole(in)
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+ w.WriteHeader(http.StatusCreated)
+ out = in
+ } else {
+ if !in.Permissions.IsEmpty() {
+ writeError(w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Role JSON contains both permissions and grant/revoke"))
+ return
+ }
+ out, err = sh.sec.UpdateRole(in)
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+ w.WriteHeader(http.StatusOK)
+ }
+
+ err = json.NewEncoder(w).Encode(out)
+ if err != nil {
+ plog.Warningf("forRole error encoding on %s", r.URL)
+ return
+ }
+ return
+ case "DELETE":
+ err := sh.sec.DeleteRole(role)
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+ }
+}
+
+type userWithRoles struct {
+ User string `json:"user"`
+ Roles []auth.Role `json:"roles,omitempty"`
+}
+
+type usersCollections struct {
+ Users []userWithRoles `json:"users"`
+}
+
+func (sh *authHandler) baseUsers(w http.ResponseWriter, r *http.Request) {
+ if !allowMethod(w, r.Method, "GET") {
+ return
+ }
+ if !hasRootAccess(sh.sec, r, sh.clientCertAuthEnabled) {
+ writeNoAuth(w, r)
+ return
+ }
+ w.Header().Set("X-Etcd-Cluster-ID", sh.cluster.ID().String())
+ w.Header().Set("Content-Type", "application/json")
+
+ users, err := sh.sec.AllUsers()
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+ if users == nil {
+ users = make([]string, 0)
+ }
+
+ err = r.ParseForm()
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+
+ ucs := usersCollections{}
+ for _, userName := range users {
+ var user auth.User
+ user, err = sh.sec.GetUser(userName)
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+
+ uwr := userWithRoles{User: user.User}
+ for _, roleName := range user.Roles {
+ var role auth.Role
+ role, err = sh.sec.GetRole(roleName)
+ if err != nil {
+ continue
+ }
+ uwr.Roles = append(uwr.Roles, role)
+ }
+
+ ucs.Users = append(ucs.Users, uwr)
+ }
+ err = json.NewEncoder(w).Encode(ucs)
+
+ if err != nil {
+ plog.Warningf("baseUsers error encoding on %s", r.URL)
+ writeError(w, r, err)
+ return
+ }
+}
+
+func (sh *authHandler) handleUsers(w http.ResponseWriter, r *http.Request) {
+ subpath := path.Clean(r.URL.Path[len(authPrefix):])
+ // Split "/users/username".
+ // First item is an empty string, second is "users"
+ pieces := strings.Split(subpath, "/")
+ if len(pieces) == 2 {
+ sh.baseUsers(w, r)
+ return
+ }
+ if len(pieces) != 3 {
+ writeError(w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Invalid path"))
+ return
+ }
+ sh.forUser(w, r, pieces[2])
+}
+
+func (sh *authHandler) forUser(w http.ResponseWriter, r *http.Request, user string) {
+ if !allowMethod(w, r.Method, "GET", "PUT", "DELETE") {
+ return
+ }
+ if !hasRootAccess(sh.sec, r, sh.clientCertAuthEnabled) {
+ writeNoAuth(w, r)
+ return
+ }
+ w.Header().Set("X-Etcd-Cluster-ID", sh.cluster.ID().String())
+ w.Header().Set("Content-Type", "application/json")
+
+ switch r.Method {
+ case "GET":
+ u, err := sh.sec.GetUser(user)
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+
+ err = r.ParseForm()
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+
+ uwr := userWithRoles{User: u.User}
+ for _, roleName := range u.Roles {
+ var role auth.Role
+ role, err = sh.sec.GetRole(roleName)
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+ uwr.Roles = append(uwr.Roles, role)
+ }
+ err = json.NewEncoder(w).Encode(uwr)
+
+ if err != nil {
+ plog.Warningf("forUser error encoding on %s", r.URL)
+ return
+ }
+ return
+ case "PUT":
+ var u auth.User
+ err := json.NewDecoder(r.Body).Decode(&u)
+ if err != nil {
+ writeError(w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Invalid JSON in request body."))
+ return
+ }
+ if u.User != user {
+ writeError(w, r, httptypes.NewHTTPError(http.StatusBadRequest, "User JSON name does not match the name in the URL"))
+ return
+ }
+
+ var (
+ out auth.User
+ created bool
+ )
+
+ if len(u.Grant) == 0 && len(u.Revoke) == 0 {
+ // create or update
+ if len(u.Roles) != 0 {
+ out, err = sh.sec.CreateUser(u)
+ } else {
+ // if user passes in both password and roles, we are unsure about his/her
+ // intention.
+ out, created, err = sh.sec.CreateOrUpdateUser(u)
+ }
+
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+ } else {
+ // update case
+ if len(u.Roles) != 0 {
+ writeError(w, r, httptypes.NewHTTPError(http.StatusBadRequest, "User JSON contains both roles and grant/revoke"))
+ return
+ }
+ out, err = sh.sec.UpdateUser(u)
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+ }
+
+ if created {
+ w.WriteHeader(http.StatusCreated)
+ } else {
+ w.WriteHeader(http.StatusOK)
+ }
+
+ out.Password = ""
+
+ err = json.NewEncoder(w).Encode(out)
+ if err != nil {
+ plog.Warningf("forUser error encoding on %s", r.URL)
+ return
+ }
+ return
+ case "DELETE":
+ err := sh.sec.DeleteUser(user)
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+ }
+}
+
+type enabled struct {
+ Enabled bool `json:"enabled"`
+}
+
+func (sh *authHandler) enableDisable(w http.ResponseWriter, r *http.Request) {
+ if !allowMethod(w, r.Method, "GET", "PUT", "DELETE") {
+ return
+ }
+ if !hasWriteRootAccess(sh.sec, r, sh.clientCertAuthEnabled) {
+ writeNoAuth(w, r)
+ return
+ }
+ w.Header().Set("X-Etcd-Cluster-ID", sh.cluster.ID().String())
+ w.Header().Set("Content-Type", "application/json")
+ isEnabled := sh.sec.AuthEnabled()
+ switch r.Method {
+ case "GET":
+ jsonDict := enabled{isEnabled}
+ err := json.NewEncoder(w).Encode(jsonDict)
+ if err != nil {
+ plog.Warningf("error encoding auth state on %s", r.URL)
+ }
+ case "PUT":
+ err := sh.sec.EnableAuth()
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+ case "DELETE":
+ err := sh.sec.DisableAuth()
+ if err != nil {
+ writeError(w, r, err)
+ return
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/client_auth_test.go b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/client_auth_test.go
new file mode 100644
index 00000000..261ce168
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/client_auth_test.go
@@ -0,0 +1,910 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 v2http
+
+import (
+ "crypto/tls"
+ "crypto/x509"
+ "encoding/json"
+ "encoding/pem"
+ "errors"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "net/http/httptest"
+ "net/url"
+ "path"
+ "sort"
+ "strings"
+ "testing"
+
+ "github.com/coreos/etcd/etcdserver/api"
+ "github.com/coreos/etcd/etcdserver/auth"
+)
+
+const goodPassword = "good"
+
+func mustJSONRequest(t *testing.T, method string, p string, body string) *http.Request {
+ req, err := http.NewRequest(method, path.Join(authPrefix, p), strings.NewReader(body))
+ if err != nil {
+ t.Fatalf("Error making JSON request: %s %s %s\n", method, p, body)
+ }
+ req.Header.Set("Content-Type", "application/json")
+ return req
+}
+
+type mockAuthStore struct {
+ users map[string]*auth.User
+ roles map[string]*auth.Role
+ err error
+ enabled bool
+}
+
+func (s *mockAuthStore) AllUsers() ([]string, error) {
+ var us []string
+ for u := range s.users {
+ us = append(us, u)
+ }
+ sort.Strings(us)
+ return us, s.err
+}
+func (s *mockAuthStore) GetUser(name string) (auth.User, error) {
+ u, ok := s.users[name]
+ if !ok {
+ return auth.User{}, s.err
+ }
+ return *u, s.err
+}
+func (s *mockAuthStore) CreateOrUpdateUser(user auth.User) (out auth.User, created bool, err error) {
+ if s.users == nil {
+ out, err = s.CreateUser(user)
+ return out, true, err
+ }
+ out, err = s.UpdateUser(user)
+ return out, false, err
+}
+func (s *mockAuthStore) CreateUser(user auth.User) (auth.User, error) { return user, s.err }
+func (s *mockAuthStore) DeleteUser(name string) error { return s.err }
+func (s *mockAuthStore) UpdateUser(user auth.User) (auth.User, error) {
+ return *s.users[user.User], s.err
+}
+func (s *mockAuthStore) AllRoles() ([]string, error) {
+ return []string{"awesome", "guest", "root"}, s.err
+}
+func (s *mockAuthStore) GetRole(name string) (auth.Role, error) {
+ r, ok := s.roles[name]
+ if ok {
+ return *r, s.err
+ }
+ return auth.Role{}, fmt.Errorf("%q does not exist (%v)", name, s.err)
+}
+func (s *mockAuthStore) CreateRole(role auth.Role) error { return s.err }
+func (s *mockAuthStore) DeleteRole(name string) error { return s.err }
+func (s *mockAuthStore) UpdateRole(role auth.Role) (auth.Role, error) {
+ return *s.roles[role.Role], s.err
+}
+func (s *mockAuthStore) AuthEnabled() bool { return s.enabled }
+func (s *mockAuthStore) EnableAuth() error { return s.err }
+func (s *mockAuthStore) DisableAuth() error { return s.err }
+
+func (s *mockAuthStore) CheckPassword(user auth.User, password string) bool {
+ return user.Password == password
+}
+
+func (s *mockAuthStore) HashPassword(password string) (string, error) {
+ return password, nil
+}
+
+func TestAuthFlow(t *testing.T) {
+ api.EnableCapability(api.AuthCapability)
+ var testCases = []struct {
+ req *http.Request
+ store mockAuthStore
+
+ wcode int
+ wbody string
+ }{
+ {
+ req: mustJSONRequest(t, "PUT", "users/alice", `{{{{{{{`),
+ store: mockAuthStore{},
+ wcode: http.StatusBadRequest,
+ wbody: `{"message":"Invalid JSON in request body."}`,
+ },
+ {
+ req: mustJSONRequest(t, "PUT", "users/alice", `{"user": "alice", "password": "goodpassword"}`),
+ store: mockAuthStore{enabled: true},
+ wcode: http.StatusUnauthorized,
+ wbody: `{"message":"Insufficient credentials"}`,
+ },
+ // Users
+ {
+ req: mustJSONRequest(t, "GET", "users", ""),
+ store: mockAuthStore{
+ users: map[string]*auth.User{
+ "alice": {
+ User: "alice",
+ Roles: []string{"alicerole", "guest"},
+ Password: "wheeee",
+ },
+ "bob": {
+ User: "bob",
+ Roles: []string{"guest"},
+ Password: "wheeee",
+ },
+ "root": {
+ User: "root",
+ Roles: []string{"root"},
+ Password: "wheeee",
+ },
+ },
+ roles: map[string]*auth.Role{
+ "alicerole": {
+ Role: "alicerole",
+ },
+ "guest": {
+ Role: "guest",
+ },
+ "root": {
+ Role: "root",
+ },
+ },
+ },
+ wcode: http.StatusOK,
+ wbody: `{"users":[` +
+ `{"user":"alice","roles":[` +
+ `{"role":"alicerole","permissions":{"kv":{"read":null,"write":null}}},` +
+ `{"role":"guest","permissions":{"kv":{"read":null,"write":null}}}` +
+ `]},` +
+ `{"user":"bob","roles":[{"role":"guest","permissions":{"kv":{"read":null,"write":null}}}]},` +
+ `{"user":"root","roles":[{"role":"root","permissions":{"kv":{"read":null,"write":null}}}]}]}`,
+ },
+ {
+ req: mustJSONRequest(t, "GET", "users/alice", ""),
+ store: mockAuthStore{
+ users: map[string]*auth.User{
+ "alice": {
+ User: "alice",
+ Roles: []string{"alicerole"},
+ Password: "wheeee",
+ },
+ },
+ roles: map[string]*auth.Role{
+ "alicerole": {
+ Role: "alicerole",
+ },
+ },
+ },
+ wcode: http.StatusOK,
+ wbody: `{"user":"alice","roles":[{"role":"alicerole","permissions":{"kv":{"read":null,"write":null}}}]}`,
+ },
+ {
+ req: mustJSONRequest(t, "PUT", "users/alice", `{"user": "alice", "password": "goodpassword"}`),
+ store: mockAuthStore{},
+ wcode: http.StatusCreated,
+ wbody: `{"user":"alice","roles":null}`,
+ },
+ {
+ req: mustJSONRequest(t, "DELETE", "users/alice", ``),
+ store: mockAuthStore{},
+ wcode: http.StatusOK,
+ wbody: ``,
+ },
+ {
+ req: mustJSONRequest(t, "PUT", "users/alice", `{"user": "alice", "password": "goodpassword"}`),
+ store: mockAuthStore{
+ users: map[string]*auth.User{
+ "alice": {
+ User: "alice",
+ Roles: []string{"alicerole", "guest"},
+ Password: "wheeee",
+ },
+ },
+ },
+ wcode: http.StatusOK,
+ wbody: `{"user":"alice","roles":["alicerole","guest"]}`,
+ },
+ {
+ req: mustJSONRequest(t, "PUT", "users/alice", `{"user": "alice", "grant": ["alicerole"]}`),
+ store: mockAuthStore{
+ users: map[string]*auth.User{
+ "alice": {
+ User: "alice",
+ Roles: []string{"alicerole", "guest"},
+ Password: "wheeee",
+ },
+ },
+ },
+ wcode: http.StatusOK,
+ wbody: `{"user":"alice","roles":["alicerole","guest"]}`,
+ },
+ {
+ req: mustJSONRequest(t, "GET", "users/alice", ``),
+ store: mockAuthStore{
+ users: map[string]*auth.User{},
+ err: auth.Error{Status: http.StatusNotFound, Errmsg: "auth: User alice doesn't exist."},
+ },
+ wcode: http.StatusNotFound,
+ wbody: `{"message":"auth: User alice doesn't exist."}`,
+ },
+ {
+ req: mustJSONRequest(t, "GET", "roles/manager", ""),
+ store: mockAuthStore{
+ roles: map[string]*auth.Role{
+ "manager": {
+ Role: "manager",
+ },
+ },
+ },
+ wcode: http.StatusOK,
+ wbody: `{"role":"manager","permissions":{"kv":{"read":null,"write":null}}}`,
+ },
+ {
+ req: mustJSONRequest(t, "DELETE", "roles/manager", ``),
+ store: mockAuthStore{},
+ wcode: http.StatusOK,
+ wbody: ``,
+ },
+ {
+ req: mustJSONRequest(t, "PUT", "roles/manager", `{"role":"manager","permissions":{"kv":{"read":[],"write":[]}}}`),
+ store: mockAuthStore{},
+ wcode: http.StatusCreated,
+ wbody: `{"role":"manager","permissions":{"kv":{"read":[],"write":[]}}}`,
+ },
+ {
+ req: mustJSONRequest(t, "PUT", "roles/manager", `{"role":"manager","revoke":{"kv":{"read":["foo"],"write":[]}}}`),
+ store: mockAuthStore{
+ roles: map[string]*auth.Role{
+ "manager": {
+ Role: "manager",
+ },
+ },
+ },
+ wcode: http.StatusOK,
+ wbody: `{"role":"manager","permissions":{"kv":{"read":null,"write":null}}}`,
+ },
+ {
+ req: mustJSONRequest(t, "GET", "roles", ""),
+ store: mockAuthStore{
+ roles: map[string]*auth.Role{
+ "awesome": {
+ Role: "awesome",
+ },
+ "guest": {
+ Role: "guest",
+ },
+ "root": {
+ Role: "root",
+ },
+ },
+ },
+ wcode: http.StatusOK,
+ wbody: `{"roles":[{"role":"awesome","permissions":{"kv":{"read":null,"write":null}}},` +
+ `{"role":"guest","permissions":{"kv":{"read":null,"write":null}}},` +
+ `{"role":"root","permissions":{"kv":{"read":null,"write":null}}}]}`,
+ },
+ {
+ req: mustJSONRequest(t, "GET", "enable", ""),
+ store: mockAuthStore{
+ enabled: true,
+ },
+ wcode: http.StatusOK,
+ wbody: `{"enabled":true}`,
+ },
+ {
+ req: mustJSONRequest(t, "PUT", "enable", ""),
+ store: mockAuthStore{
+ enabled: false,
+ },
+ wcode: http.StatusOK,
+ wbody: ``,
+ },
+ {
+ req: (func() *http.Request {
+ req := mustJSONRequest(t, "DELETE", "enable", "")
+ req.SetBasicAuth("root", "good")
+ return req
+ })(),
+ store: mockAuthStore{
+ enabled: true,
+ users: map[string]*auth.User{
+ "root": {
+ User: "root",
+ Password: goodPassword,
+ Roles: []string{"root"},
+ },
+ },
+ roles: map[string]*auth.Role{
+ "root": {
+ Role: "root",
+ },
+ },
+ },
+ wcode: http.StatusOK,
+ wbody: ``,
+ },
+ {
+ req: (func() *http.Request {
+ req := mustJSONRequest(t, "DELETE", "enable", "")
+ req.SetBasicAuth("root", "bad")
+ return req
+ })(),
+ store: mockAuthStore{
+ enabled: true,
+ users: map[string]*auth.User{
+ "root": {
+ User: "root",
+ Password: goodPassword,
+ Roles: []string{"root"},
+ },
+ },
+ roles: map[string]*auth.Role{
+ "root": {
+ Role: "guest",
+ },
+ },
+ },
+ wcode: http.StatusUnauthorized,
+ wbody: `{"message":"Insufficient credentials"}`,
+ },
+ }
+
+ for i, tt := range testCases {
+ mux := http.NewServeMux()
+ h := &authHandler{
+ sec: &tt.store,
+ cluster: &fakeCluster{id: 1},
+ }
+ handleAuth(mux, h)
+ rw := httptest.NewRecorder()
+ mux.ServeHTTP(rw, tt.req)
+ if rw.Code != tt.wcode {
+ t.Errorf("#%d: got code=%d, want %d", i, rw.Code, tt.wcode)
+ }
+ g := rw.Body.String()
+ g = strings.TrimSpace(g)
+ if g != tt.wbody {
+ t.Errorf("#%d: got body=%s, want %s", i, g, tt.wbody)
+ }
+ }
+}
+
+func TestGetUserGrantedWithNonexistingRole(t *testing.T) {
+ sh := &authHandler{
+ sec: &mockAuthStore{
+ users: map[string]*auth.User{
+ "root": {
+ User: "root",
+ Roles: []string{"root", "foo"},
+ },
+ },
+ roles: map[string]*auth.Role{
+ "root": {
+ Role: "root",
+ },
+ },
+ },
+ cluster: &fakeCluster{id: 1},
+ }
+ srv := httptest.NewServer(http.HandlerFunc(sh.baseUsers))
+ defer srv.Close()
+
+ req, err := http.NewRequest("GET", "", nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ req.URL, err = url.Parse(srv.URL)
+ if err != nil {
+ t.Fatal(err)
+ }
+ req.Header.Set("Content-Type", "application/json")
+
+ cli := http.DefaultClient
+ resp, err := cli.Do(req)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer resp.Body.Close()
+
+ var uc usersCollections
+ if err := json.NewDecoder(resp.Body).Decode(&uc); err != nil {
+ t.Fatal(err)
+ }
+ if len(uc.Users) != 1 {
+ t.Fatalf("expected 1 user, got %+v", uc.Users)
+ }
+ if uc.Users[0].User != "root" {
+ t.Fatalf("expected 'root', got %q", uc.Users[0].User)
+ }
+ if len(uc.Users[0].Roles) != 1 {
+ t.Fatalf("expected 1 role, got %+v", uc.Users[0].Roles)
+ }
+ if uc.Users[0].Roles[0].Role != "root" {
+ t.Fatalf("expected 'root', got %q", uc.Users[0].Roles[0].Role)
+ }
+}
+
+func mustAuthRequest(method, username, password string) *http.Request {
+ req, err := http.NewRequest(method, "path", strings.NewReader(""))
+ if err != nil {
+ panic("Cannot make auth request: " + err.Error())
+ }
+ req.SetBasicAuth(username, password)
+ return req
+}
+
+func unauthedRequest(method string) *http.Request {
+ req, err := http.NewRequest(method, "path", strings.NewReader(""))
+ if err != nil {
+ panic("Cannot make request: " + err.Error())
+ }
+ return req
+}
+
+func tlsAuthedRequest(req *http.Request, certname string) *http.Request {
+ bytes, err := ioutil.ReadFile(fmt.Sprintf("testdata/%s.pem", certname))
+ if err != nil {
+ panic(err)
+ }
+
+ block, _ := pem.Decode(bytes)
+ cert, err := x509.ParseCertificate(block.Bytes)
+ if err != nil {
+ panic(err)
+ }
+
+ req.TLS = &tls.ConnectionState{
+ VerifiedChains: [][]*x509.Certificate{{cert}},
+ }
+ return req
+}
+
+func TestPrefixAccess(t *testing.T) {
+ var table = []struct {
+ key string
+ req *http.Request
+ store *mockAuthStore
+ hasRoot bool
+ hasKeyPrefixAccess bool
+ hasRecursiveAccess bool
+ }{
+ {
+ key: "/foo",
+ req: mustAuthRequest("GET", "root", "good"),
+ store: &mockAuthStore{
+ users: map[string]*auth.User{
+ "root": {
+ User: "root",
+ Password: goodPassword,
+ Roles: []string{"root"},
+ },
+ },
+ roles: map[string]*auth.Role{
+ "root": {
+ Role: "root",
+ },
+ },
+ enabled: true,
+ },
+ hasRoot: true,
+ hasKeyPrefixAccess: true,
+ hasRecursiveAccess: true,
+ },
+ {
+ key: "/foo",
+ req: mustAuthRequest("GET", "user", "good"),
+ store: &mockAuthStore{
+ users: map[string]*auth.User{
+ "user": {
+ User: "user",
+ Password: goodPassword,
+ Roles: []string{"foorole"},
+ },
+ },
+ roles: map[string]*auth.Role{
+ "foorole": {
+ Role: "foorole",
+ Permissions: auth.Permissions{
+ KV: auth.RWPermission{
+ Read: []string{"/foo"},
+ Write: []string{"/foo"},
+ },
+ },
+ },
+ },
+ enabled: true,
+ },
+ hasRoot: false,
+ hasKeyPrefixAccess: true,
+ hasRecursiveAccess: false,
+ },
+ {
+ key: "/foo",
+ req: mustAuthRequest("GET", "user", "good"),
+ store: &mockAuthStore{
+ users: map[string]*auth.User{
+ "user": {
+ User: "user",
+ Password: goodPassword,
+ Roles: []string{"foorole"},
+ },
+ },
+ roles: map[string]*auth.Role{
+ "foorole": {
+ Role: "foorole",
+ Permissions: auth.Permissions{
+ KV: auth.RWPermission{
+ Read: []string{"/foo*"},
+ Write: []string{"/foo*"},
+ },
+ },
+ },
+ },
+ enabled: true,
+ },
+ hasRoot: false,
+ hasKeyPrefixAccess: true,
+ hasRecursiveAccess: true,
+ },
+ {
+ key: "/foo",
+ req: mustAuthRequest("GET", "user", "bad"),
+ store: &mockAuthStore{
+ users: map[string]*auth.User{
+ "user": {
+ User: "user",
+ Password: goodPassword,
+ Roles: []string{"foorole"},
+ },
+ },
+ roles: map[string]*auth.Role{
+ "foorole": {
+ Role: "foorole",
+ Permissions: auth.Permissions{
+ KV: auth.RWPermission{
+ Read: []string{"/foo*"},
+ Write: []string{"/foo*"},
+ },
+ },
+ },
+ },
+ enabled: true,
+ },
+ hasRoot: false,
+ hasKeyPrefixAccess: false,
+ hasRecursiveAccess: false,
+ },
+ {
+ key: "/foo",
+ req: mustAuthRequest("GET", "user", "good"),
+ store: &mockAuthStore{
+ users: map[string]*auth.User{},
+ err: errors.New("Not the user"),
+ enabled: true,
+ },
+ hasRoot: false,
+ hasKeyPrefixAccess: false,
+ hasRecursiveAccess: false,
+ },
+ {
+ key: "/foo",
+ req: mustJSONRequest(t, "GET", "somepath", ""),
+ store: &mockAuthStore{
+ users: map[string]*auth.User{
+ "user": {
+ User: "user",
+ Password: goodPassword,
+ Roles: []string{"foorole"},
+ },
+ },
+ roles: map[string]*auth.Role{
+ "guest": {
+ Role: "guest",
+ Permissions: auth.Permissions{
+ KV: auth.RWPermission{
+ Read: []string{"/foo*"},
+ Write: []string{"/foo*"},
+ },
+ },
+ },
+ },
+ enabled: true,
+ },
+ hasRoot: false,
+ hasKeyPrefixAccess: true,
+ hasRecursiveAccess: true,
+ },
+ {
+ key: "/bar",
+ req: mustJSONRequest(t, "GET", "somepath", ""),
+ store: &mockAuthStore{
+ users: map[string]*auth.User{
+ "user": {
+ User: "user",
+ Password: goodPassword,
+ Roles: []string{"foorole"},
+ },
+ },
+ roles: map[string]*auth.Role{
+ "guest": {
+ Role: "guest",
+ Permissions: auth.Permissions{
+ KV: auth.RWPermission{
+ Read: []string{"/foo*"},
+ Write: []string{"/foo*"},
+ },
+ },
+ },
+ },
+ enabled: true,
+ },
+ hasRoot: false,
+ hasKeyPrefixAccess: false,
+ hasRecursiveAccess: false,
+ },
+ // check access for multiple roles
+ {
+ key: "/foo",
+ req: mustAuthRequest("GET", "user", "good"),
+ store: &mockAuthStore{
+ users: map[string]*auth.User{
+ "user": {
+ User: "user",
+ Password: goodPassword,
+ Roles: []string{"role1", "role2"},
+ },
+ },
+ roles: map[string]*auth.Role{
+ "role1": {
+ Role: "role1",
+ },
+ "role2": {
+ Role: "role2",
+ Permissions: auth.Permissions{
+ KV: auth.RWPermission{
+ Read: []string{"/foo"},
+ Write: []string{"/foo"},
+ },
+ },
+ },
+ },
+ enabled: true,
+ },
+ hasRoot: false,
+ hasKeyPrefixAccess: true,
+ hasRecursiveAccess: false,
+ },
+ {
+ key: "/foo",
+ req: (func() *http.Request {
+ req := mustJSONRequest(t, "GET", "somepath", "")
+ req.Header.Set("Authorization", "malformedencoding")
+ return req
+ })(),
+ store: &mockAuthStore{
+ enabled: true,
+ users: map[string]*auth.User{
+ "root": {
+ User: "root",
+ Password: goodPassword,
+ Roles: []string{"root"},
+ },
+ },
+ roles: map[string]*auth.Role{
+ "guest": {
+ Role: "guest",
+ Permissions: auth.Permissions{
+ KV: auth.RWPermission{
+ Read: []string{"/foo*"},
+ Write: []string{"/foo*"},
+ },
+ },
+ },
+ },
+ },
+ hasRoot: false,
+ hasKeyPrefixAccess: false,
+ hasRecursiveAccess: false,
+ },
+ { // guest access in non-TLS mode
+ key: "/foo",
+ req: (func() *http.Request {
+ return mustJSONRequest(t, "GET", "somepath", "")
+ })(),
+ store: &mockAuthStore{
+ enabled: true,
+ users: map[string]*auth.User{
+ "root": {
+ User: "root",
+ Password: goodPassword,
+ Roles: []string{"root"},
+ },
+ },
+ roles: map[string]*auth.Role{
+ "guest": {
+ Role: "guest",
+ Permissions: auth.Permissions{
+ KV: auth.RWPermission{
+ Read: []string{"/foo*"},
+ Write: []string{"/foo*"},
+ },
+ },
+ },
+ },
+ },
+ hasRoot: false,
+ hasKeyPrefixAccess: true,
+ hasRecursiveAccess: true,
+ },
+ }
+
+ for i, tt := range table {
+ if tt.hasRoot != hasRootAccess(tt.store, tt.req, true) {
+ t.Errorf("#%d: hasRoot doesn't match (expected %v)", i, tt.hasRoot)
+ }
+ if tt.hasKeyPrefixAccess != hasKeyPrefixAccess(tt.store, tt.req, tt.key, false, true) {
+ t.Errorf("#%d: hasKeyPrefixAccess doesn't match (expected %v)", i, tt.hasRoot)
+ }
+ if tt.hasRecursiveAccess != hasKeyPrefixAccess(tt.store, tt.req, tt.key, true, true) {
+ t.Errorf("#%d: hasRecursiveAccess doesn't match (expected %v)", i, tt.hasRoot)
+ }
+ }
+}
+
+func TestUserFromClientCertificate(t *testing.T) {
+ witherror := &mockAuthStore{
+ users: map[string]*auth.User{
+ "user": {
+ User: "user",
+ Roles: []string{"root"},
+ Password: "password",
+ },
+ "basicauth": {
+ User: "basicauth",
+ Roles: []string{"root"},
+ Password: "password",
+ },
+ },
+ roles: map[string]*auth.Role{
+ "root": {
+ Role: "root",
+ },
+ },
+ err: errors.New(""),
+ }
+
+ noerror := &mockAuthStore{
+ users: map[string]*auth.User{
+ "user": {
+ User: "user",
+ Roles: []string{"root"},
+ Password: "password",
+ },
+ "basicauth": {
+ User: "basicauth",
+ Roles: []string{"root"},
+ Password: "password",
+ },
+ },
+ roles: map[string]*auth.Role{
+ "root": {
+ Role: "root",
+ },
+ },
+ }
+
+ var table = []struct {
+ req *http.Request
+ userExists bool
+ store auth.Store
+ username string
+ }{
+ {
+ // non tls request
+ req: unauthedRequest("GET"),
+ userExists: false,
+ store: witherror,
+ },
+ {
+ // cert with cn of existing user
+ req: tlsAuthedRequest(unauthedRequest("GET"), "user"),
+ userExists: true,
+ username: "user",
+ store: noerror,
+ },
+ {
+ // cert with cn of non-existing user
+ req: tlsAuthedRequest(unauthedRequest("GET"), "otheruser"),
+ userExists: false,
+ store: witherror,
+ },
+ }
+
+ for i, tt := range table {
+ user := userFromClientCertificate(tt.store, tt.req)
+ userExists := user != nil
+
+ if tt.userExists != userExists {
+ t.Errorf("#%d: userFromClientCertificate doesn't match (expected %v)", i, tt.userExists)
+ }
+ if user != nil && (tt.username != user.User) {
+ t.Errorf("#%d: userFromClientCertificate username doesn't match (expected %s, got %s)", i, tt.username, user.User)
+ }
+ }
+}
+
+func TestUserFromBasicAuth(t *testing.T) {
+ sec := &mockAuthStore{
+ users: map[string]*auth.User{
+ "user": {
+ User: "user",
+ Roles: []string{"root"},
+ Password: "password",
+ },
+ },
+ roles: map[string]*auth.Role{
+ "root": {
+ Role: "root",
+ },
+ },
+ }
+
+ var table = []struct {
+ username string
+ req *http.Request
+ userExists bool
+ }{
+ {
+ // valid user, valid pass
+ username: "user",
+ req: mustAuthRequest("GET", "user", "password"),
+ userExists: true,
+ },
+ {
+ // valid user, bad pass
+ username: "user",
+ req: mustAuthRequest("GET", "user", "badpass"),
+ userExists: false,
+ },
+ {
+ // valid user, no pass
+ username: "user",
+ req: mustAuthRequest("GET", "user", ""),
+ userExists: false,
+ },
+ {
+ // missing user
+ username: "missing",
+ req: mustAuthRequest("GET", "missing", "badpass"),
+ userExists: false,
+ },
+ {
+ // no basic auth
+ req: unauthedRequest("GET"),
+ userExists: false,
+ },
+ }
+
+ for i, tt := range table {
+ user := userFromBasicAuth(sec, tt.req)
+ userExists := user != nil
+
+ if tt.userExists != userExists {
+ t.Errorf("#%d: userFromBasicAuth doesn't match (expected %v)", i, tt.userExists)
+ }
+ if user != nil && (tt.username != user.User) {
+ t.Errorf("#%d: userFromBasicAuth username doesn't match (expected %s, got %s)", i, tt.username, user.User)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/client_test.go b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/client_test.go
new file mode 100644
index 00000000..896021b2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/client_test.go
@@ -0,0 +1,2049 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 v2http
+
+import (
+ "bytes"
+ "encoding/json"
+ "errors"
+ "io/ioutil"
+ "net/http"
+ "net/http/httptest"
+ "net/url"
+ "path"
+ "reflect"
+ "strings"
+ "testing"
+ "time"
+
+ etcdErr "github.com/coreos/etcd/error"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api/v2http/httptypes"
+ "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/store"
+ "github.com/coreos/go-semver/semver"
+ "github.com/jonboulle/clockwork"
+ "golang.org/x/net/context"
+)
+
+func mustMarshalEvent(t *testing.T, ev *store.Event) string {
+ b := new(bytes.Buffer)
+ if err := json.NewEncoder(b).Encode(ev); err != nil {
+ t.Fatalf("error marshalling event %#v: %v", ev, err)
+ }
+ return b.String()
+}
+
+// mustNewForm takes a set of Values and constructs a PUT *http.Request,
+// with a URL constructed from appending the given path to the standard keysPrefix
+func mustNewForm(t *testing.T, p string, vals url.Values) *http.Request {
+ u := testutil.MustNewURL(t, path.Join(keysPrefix, p))
+ req, err := http.NewRequest("PUT", u.String(), strings.NewReader(vals.Encode()))
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ if err != nil {
+ t.Fatalf("error creating new request: %v", err)
+ }
+ return req
+}
+
+// mustNewPostForm takes a set of Values and constructs a POST *http.Request,
+// with a URL constructed from appending the given path to the standard keysPrefix
+func mustNewPostForm(t *testing.T, p string, vals url.Values) *http.Request {
+ u := testutil.MustNewURL(t, path.Join(keysPrefix, p))
+ req, err := http.NewRequest("POST", u.String(), strings.NewReader(vals.Encode()))
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ if err != nil {
+ t.Fatalf("error creating new request: %v", err)
+ }
+ return req
+}
+
+// mustNewRequest takes a path, appends it to the standard keysPrefix, and constructs
+// a GET *http.Request referencing the resulting URL
+func mustNewRequest(t *testing.T, p string) *http.Request {
+ return mustNewMethodRequest(t, "GET", p)
+}
+
+func mustNewMethodRequest(t *testing.T, m, p string) *http.Request {
+ return &http.Request{
+ Method: m,
+ URL: testutil.MustNewURL(t, path.Join(keysPrefix, p)),
+ }
+}
+
+type serverRecorder struct {
+ actions []action
+}
+
+func (s *serverRecorder) Start() {}
+func (s *serverRecorder) Stop() {}
+func (s *serverRecorder) Leader() types.ID { return types.ID(1) }
+func (s *serverRecorder) ID() types.ID { return types.ID(1) }
+func (s *serverRecorder) Do(_ context.Context, r etcdserverpb.Request) (etcdserver.Response, error) {
+ s.actions = append(s.actions, action{name: "Do", params: []interface{}{r}})
+ return etcdserver.Response{}, nil
+}
+func (s *serverRecorder) Process(_ context.Context, m raftpb.Message) error {
+ s.actions = append(s.actions, action{name: "Process", params: []interface{}{m}})
+ return nil
+}
+func (s *serverRecorder) AddMember(_ context.Context, m membership.Member) ([]*membership.Member, error) {
+ s.actions = append(s.actions, action{name: "AddMember", params: []interface{}{m}})
+ return nil, nil
+}
+func (s *serverRecorder) RemoveMember(_ context.Context, id uint64) ([]*membership.Member, error) {
+ s.actions = append(s.actions, action{name: "RemoveMember", params: []interface{}{id}})
+ return nil, nil
+}
+
+func (s *serverRecorder) UpdateMember(_ context.Context, m membership.Member) ([]*membership.Member, error) {
+ s.actions = append(s.actions, action{name: "UpdateMember", params: []interface{}{m}})
+ return nil, nil
+}
+
+func (s *serverRecorder) ClusterVersion() *semver.Version { return nil }
+
+type action struct {
+ name string
+ params []interface{}
+}
+
+// flushingRecorder provides a channel to allow users to block until the Recorder is Flushed()
+type flushingRecorder struct {
+ *httptest.ResponseRecorder
+ ch chan struct{}
+}
+
+func (fr *flushingRecorder) Flush() {
+ fr.ResponseRecorder.Flush()
+ fr.ch <- struct{}{}
+}
+
+// resServer implements the etcd.Server interface for testing.
+// It returns the given response from any Do calls, and nil error
+type resServer struct {
+ res etcdserver.Response
+}
+
+func (rs *resServer) Start() {}
+func (rs *resServer) Stop() {}
+func (rs *resServer) ID() types.ID { return types.ID(1) }
+func (rs *resServer) Leader() types.ID { return types.ID(1) }
+func (rs *resServer) Do(_ context.Context, _ etcdserverpb.Request) (etcdserver.Response, error) {
+ return rs.res, nil
+}
+func (rs *resServer) Process(_ context.Context, _ raftpb.Message) error { return nil }
+func (rs *resServer) AddMember(_ context.Context, _ membership.Member) ([]*membership.Member, error) {
+ return nil, nil
+}
+func (rs *resServer) RemoveMember(_ context.Context, _ uint64) ([]*membership.Member, error) {
+ return nil, nil
+}
+func (rs *resServer) UpdateMember(_ context.Context, _ membership.Member) ([]*membership.Member, error) {
+ return nil, nil
+}
+func (rs *resServer) ClusterVersion() *semver.Version { return nil }
+
+func boolp(b bool) *bool { return &b }
+
+type dummyRaftTimer struct{}
+
+func (drt dummyRaftTimer) Index() uint64 { return uint64(100) }
+func (drt dummyRaftTimer) Term() uint64 { return uint64(5) }
+
+type dummyWatcher struct {
+ echan chan *store.Event
+ sidx uint64
+}
+
+func (w *dummyWatcher) EventChan() chan *store.Event {
+ return w.echan
+}
+func (w *dummyWatcher) StartIndex() uint64 { return w.sidx }
+func (w *dummyWatcher) Remove() {}
+
+func TestBadRefreshRequest(t *testing.T) {
+ tests := []struct {
+ in *http.Request
+ wcode int
+ }{
+ {
+ mustNewRequest(t, "foo?refresh=true&value=test"),
+ etcdErr.EcodeRefreshValue,
+ },
+ {
+ mustNewRequest(t, "foo?refresh=true&value=10"),
+ etcdErr.EcodeRefreshValue,
+ },
+ {
+ mustNewRequest(t, "foo?refresh=true"),
+ etcdErr.EcodeRefreshTTLRequired,
+ },
+ {
+ mustNewRequest(t, "foo?refresh=true&ttl="),
+ etcdErr.EcodeRefreshTTLRequired,
+ },
+ }
+ for i, tt := range tests {
+ got, _, err := parseKeyRequest(tt.in, clockwork.NewFakeClock())
+ if err == nil {
+ t.Errorf("#%d: unexpected nil error!", i)
+ continue
+ }
+ ee, ok := err.(*etcdErr.Error)
+ if !ok {
+ t.Errorf("#%d: err is not etcd.Error!", i)
+ continue
+ }
+ if ee.ErrorCode != tt.wcode {
+ t.Errorf("#%d: code=%d, want %v", i, ee.ErrorCode, tt.wcode)
+ t.Logf("cause: %#v", ee.Cause)
+ }
+ if !reflect.DeepEqual(got, etcdserverpb.Request{}) {
+ t.Errorf("#%d: unexpected non-empty Request: %#v", i, got)
+ }
+ }
+}
+
+func TestBadParseRequest(t *testing.T) {
+ tests := []struct {
+ in *http.Request
+ wcode int
+ }{
+ {
+ // parseForm failure
+ &http.Request{
+ Body: nil,
+ Method: "PUT",
+ },
+ etcdErr.EcodeInvalidForm,
+ },
+ {
+ // bad key prefix
+ &http.Request{
+ URL: testutil.MustNewURL(t, "/badprefix/"),
+ },
+ etcdErr.EcodeInvalidForm,
+ },
+ // bad values for prevIndex, waitIndex, ttl
+ {
+ mustNewForm(t, "foo", url.Values{"prevIndex": []string{"garbage"}}),
+ etcdErr.EcodeIndexNaN,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"prevIndex": []string{"1.5"}}),
+ etcdErr.EcodeIndexNaN,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"prevIndex": []string{"-1"}}),
+ etcdErr.EcodeIndexNaN,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"waitIndex": []string{"garbage"}}),
+ etcdErr.EcodeIndexNaN,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"waitIndex": []string{"??"}}),
+ etcdErr.EcodeIndexNaN,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"ttl": []string{"-1"}}),
+ etcdErr.EcodeTTLNaN,
+ },
+ // bad values for recursive, sorted, wait, prevExist, dir, stream
+ {
+ mustNewForm(t, "foo", url.Values{"recursive": []string{"hahaha"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"recursive": []string{"1234"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"recursive": []string{"?"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"sorted": []string{"?"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"sorted": []string{"x"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"wait": []string{"?!"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"wait": []string{"yes"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"prevExist": []string{"yes"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"prevExist": []string{"#2"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"dir": []string{"no"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"dir": []string{"file"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"quorum": []string{"no"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"quorum": []string{"file"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"stream": []string{"zzz"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"stream": []string{"something"}}),
+ etcdErr.EcodeInvalidField,
+ },
+ // prevValue cannot be empty
+ {
+ mustNewForm(t, "foo", url.Values{"prevValue": []string{""}}),
+ etcdErr.EcodePrevValueRequired,
+ },
+ // wait is only valid with GET requests
+ {
+ mustNewMethodRequest(t, "HEAD", "foo?wait=true"),
+ etcdErr.EcodeInvalidField,
+ },
+ // query values are considered
+ {
+ mustNewRequest(t, "foo?prevExist=wrong"),
+ etcdErr.EcodeInvalidField,
+ },
+ {
+ mustNewRequest(t, "foo?ttl=wrong"),
+ etcdErr.EcodeTTLNaN,
+ },
+ // but body takes precedence if both are specified
+ {
+ mustNewForm(
+ t,
+ "foo?ttl=12",
+ url.Values{"ttl": []string{"garbage"}},
+ ),
+ etcdErr.EcodeTTLNaN,
+ },
+ {
+ mustNewForm(
+ t,
+ "foo?prevExist=false",
+ url.Values{"prevExist": []string{"yes"}},
+ ),
+ etcdErr.EcodeInvalidField,
+ },
+ }
+ for i, tt := range tests {
+ got, _, err := parseKeyRequest(tt.in, clockwork.NewFakeClock())
+ if err == nil {
+ t.Errorf("#%d: unexpected nil error!", i)
+ continue
+ }
+ ee, ok := err.(*etcdErr.Error)
+ if !ok {
+ t.Errorf("#%d: err is not etcd.Error!", i)
+ continue
+ }
+ if ee.ErrorCode != tt.wcode {
+ t.Errorf("#%d: code=%d, want %v", i, ee.ErrorCode, tt.wcode)
+ t.Logf("cause: %#v", ee.Cause)
+ }
+ if !reflect.DeepEqual(got, etcdserverpb.Request{}) {
+ t.Errorf("#%d: unexpected non-empty Request: %#v", i, got)
+ }
+ }
+}
+
+func TestGoodParseRequest(t *testing.T) {
+ fc := clockwork.NewFakeClock()
+ fc.Advance(1111)
+ tests := []struct {
+ in *http.Request
+ w etcdserverpb.Request
+ noValue bool
+ }{
+ {
+ // good prefix, all other values default
+ mustNewRequest(t, "foo"),
+ etcdserverpb.Request{
+ Method: "GET",
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ false,
+ },
+ {
+ // value specified
+ mustNewForm(
+ t,
+ "foo",
+ url.Values{"value": []string{"some_value"}},
+ ),
+ etcdserverpb.Request{
+ Method: "PUT",
+ Val: "some_value",
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ false,
+ },
+ {
+ // prevIndex specified
+ mustNewForm(
+ t,
+ "foo",
+ url.Values{"prevIndex": []string{"98765"}},
+ ),
+ etcdserverpb.Request{
+ Method: "PUT",
+ PrevIndex: 98765,
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ false,
+ },
+ {
+ // recursive specified
+ mustNewForm(
+ t,
+ "foo",
+ url.Values{"recursive": []string{"true"}},
+ ),
+ etcdserverpb.Request{
+ Method: "PUT",
+ Recursive: true,
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ false,
+ },
+ {
+ // sorted specified
+ mustNewForm(
+ t,
+ "foo",
+ url.Values{"sorted": []string{"true"}},
+ ),
+ etcdserverpb.Request{
+ Method: "PUT",
+ Sorted: true,
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ false,
+ },
+ {
+ // quorum specified
+ mustNewForm(
+ t,
+ "foo",
+ url.Values{"quorum": []string{"true"}},
+ ),
+ etcdserverpb.Request{
+ Method: "PUT",
+ Quorum: true,
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ false,
+ },
+ {
+ // wait specified
+ mustNewRequest(t, "foo?wait=true"),
+ etcdserverpb.Request{
+ Method: "GET",
+ Wait: true,
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ false,
+ },
+ {
+ // empty TTL specified
+ mustNewRequest(t, "foo?ttl="),
+ etcdserverpb.Request{
+ Method: "GET",
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ Expiration: 0,
+ },
+ false,
+ },
+ {
+ // non-empty TTL specified
+ mustNewRequest(t, "foo?ttl=5678"),
+ etcdserverpb.Request{
+ Method: "GET",
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ Expiration: fc.Now().Add(5678 * time.Second).UnixNano(),
+ },
+ false,
+ },
+ {
+ // zero TTL specified
+ mustNewRequest(t, "foo?ttl=0"),
+ etcdserverpb.Request{
+ Method: "GET",
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ Expiration: fc.Now().UnixNano(),
+ },
+ false,
+ },
+ {
+ // dir specified
+ mustNewRequest(t, "foo?dir=true"),
+ etcdserverpb.Request{
+ Method: "GET",
+ Dir: true,
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ false,
+ },
+ {
+ // dir specified negatively
+ mustNewRequest(t, "foo?dir=false"),
+ etcdserverpb.Request{
+ Method: "GET",
+ Dir: false,
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ false,
+ },
+ {
+ // prevExist should be non-null if specified
+ mustNewForm(
+ t,
+ "foo",
+ url.Values{"prevExist": []string{"true"}},
+ ),
+ etcdserverpb.Request{
+ Method: "PUT",
+ PrevExist: boolp(true),
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ false,
+ },
+ {
+ // prevExist should be non-null if specified
+ mustNewForm(
+ t,
+ "foo",
+ url.Values{"prevExist": []string{"false"}},
+ ),
+ etcdserverpb.Request{
+ Method: "PUT",
+ PrevExist: boolp(false),
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ false,
+ },
+ // mix various fields
+ {
+ mustNewForm(
+ t,
+ "foo",
+ url.Values{
+ "value": []string{"some value"},
+ "prevExist": []string{"true"},
+ "prevValue": []string{"previous value"},
+ },
+ ),
+ etcdserverpb.Request{
+ Method: "PUT",
+ PrevExist: boolp(true),
+ PrevValue: "previous value",
+ Val: "some value",
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ false,
+ },
+ // query parameters should be used if given
+ {
+ mustNewForm(
+ t,
+ "foo?prevValue=woof",
+ url.Values{},
+ ),
+ etcdserverpb.Request{
+ Method: "PUT",
+ PrevValue: "woof",
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ false,
+ },
+ // but form values should take precedence over query parameters
+ {
+ mustNewForm(
+ t,
+ "foo?prevValue=woof",
+ url.Values{
+ "prevValue": []string{"miaow"},
+ },
+ ),
+ etcdserverpb.Request{
+ Method: "PUT",
+ PrevValue: "miaow",
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ false,
+ },
+ {
+ // noValueOnSuccess specified
+ mustNewForm(
+ t,
+ "foo",
+ url.Values{"noValueOnSuccess": []string{"true"}},
+ ),
+ etcdserverpb.Request{
+ Method: "PUT",
+ Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
+ },
+ true,
+ },
+ }
+
+ for i, tt := range tests {
+ got, noValueOnSuccess, err := parseKeyRequest(tt.in, fc)
+ if err != nil {
+ t.Errorf("#%d: err = %v, want %v", i, err, nil)
+ }
+
+ if noValueOnSuccess != tt.noValue {
+ t.Errorf("#%d: noValue=%t, want %t", i, noValueOnSuccess, tt.noValue)
+ }
+
+ if !reflect.DeepEqual(got, tt.w) {
+ t.Errorf("#%d: request=%#v, want %#v", i, got, tt.w)
+ }
+ }
+}
+
+func TestServeMembers(t *testing.T) {
+ memb1 := membership.Member{ID: 12, Attributes: membership.Attributes{ClientURLs: []string{"http://localhost:8080"}}}
+ memb2 := membership.Member{ID: 13, Attributes: membership.Attributes{ClientURLs: []string{"http://localhost:8081"}}}
+ cluster := &fakeCluster{
+ id: 1,
+ members: map[uint64]*membership.Member{1: &memb1, 2: &memb2},
+ }
+ h := &membersHandler{
+ server: &serverRecorder{},
+ clock: clockwork.NewFakeClock(),
+ cluster: cluster,
+ }
+
+ wmc := string(`{"members":[{"id":"c","name":"","peerURLs":[],"clientURLs":["http://localhost:8080"]},{"id":"d","name":"","peerURLs":[],"clientURLs":["http://localhost:8081"]}]}`)
+
+ tests := []struct {
+ path string
+ wcode int
+ wct string
+ wbody string
+ }{
+ {membersPrefix, http.StatusOK, "application/json", wmc + "\n"},
+ {membersPrefix + "/", http.StatusOK, "application/json", wmc + "\n"},
+ {path.Join(membersPrefix, "100"), http.StatusNotFound, "application/json", `{"message":"Not found"}`},
+ {path.Join(membersPrefix, "foobar"), http.StatusNotFound, "application/json", `{"message":"Not found"}`},
+ }
+
+ for i, tt := range tests {
+ req, err := http.NewRequest("GET", testutil.MustNewURL(t, tt.path).String(), nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ rw := httptest.NewRecorder()
+ h.ServeHTTP(rw, req)
+
+ if rw.Code != tt.wcode {
+ t.Errorf("#%d: code=%d, want %d", i, rw.Code, tt.wcode)
+ }
+ if gct := rw.Header().Get("Content-Type"); gct != tt.wct {
+ t.Errorf("#%d: content-type = %s, want %s", i, gct, tt.wct)
+ }
+ gcid := rw.Header().Get("X-Etcd-Cluster-ID")
+ wcid := cluster.ID().String()
+ if gcid != wcid {
+ t.Errorf("#%d: cid = %s, want %s", i, gcid, wcid)
+ }
+ if rw.Body.String() != tt.wbody {
+ t.Errorf("#%d: body = %q, want %q", i, rw.Body.String(), tt.wbody)
+ }
+ }
+}
+
+// TODO: consolidate **ALL** fake server implementations and add no leader test case.
+func TestServeLeader(t *testing.T) {
+ memb1 := membership.Member{ID: 1, Attributes: membership.Attributes{ClientURLs: []string{"http://localhost:8080"}}}
+ memb2 := membership.Member{ID: 2, Attributes: membership.Attributes{ClientURLs: []string{"http://localhost:8081"}}}
+ cluster := &fakeCluster{
+ id: 1,
+ members: map[uint64]*membership.Member{1: &memb1, 2: &memb2},
+ }
+ h := &membersHandler{
+ server: &serverRecorder{},
+ clock: clockwork.NewFakeClock(),
+ cluster: cluster,
+ }
+
+ wmc := string(`{"id":"1","name":"","peerURLs":[],"clientURLs":["http://localhost:8080"]}`)
+
+ tests := []struct {
+ path string
+ wcode int
+ wct string
+ wbody string
+ }{
+ {membersPrefix + "leader", http.StatusOK, "application/json", wmc + "\n"},
+ // TODO: add no leader case
+ }
+
+ for i, tt := range tests {
+ req, err := http.NewRequest("GET", testutil.MustNewURL(t, tt.path).String(), nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ rw := httptest.NewRecorder()
+ h.ServeHTTP(rw, req)
+
+ if rw.Code != tt.wcode {
+ t.Errorf("#%d: code=%d, want %d", i, rw.Code, tt.wcode)
+ }
+ if gct := rw.Header().Get("Content-Type"); gct != tt.wct {
+ t.Errorf("#%d: content-type = %s, want %s", i, gct, tt.wct)
+ }
+ gcid := rw.Header().Get("X-Etcd-Cluster-ID")
+ wcid := cluster.ID().String()
+ if gcid != wcid {
+ t.Errorf("#%d: cid = %s, want %s", i, gcid, wcid)
+ }
+ if rw.Body.String() != tt.wbody {
+ t.Errorf("#%d: body = %q, want %q", i, rw.Body.String(), tt.wbody)
+ }
+ }
+}
+
+func TestServeMembersCreate(t *testing.T) {
+ u := testutil.MustNewURL(t, membersPrefix)
+ b := []byte(`{"peerURLs":["http://127.0.0.1:1"]}`)
+ req, err := http.NewRequest("POST", u.String(), bytes.NewReader(b))
+ if err != nil {
+ t.Fatal(err)
+ }
+ req.Header.Set("Content-Type", "application/json")
+ s := &serverRecorder{}
+ h := &membersHandler{
+ server: s,
+ clock: clockwork.NewFakeClock(),
+ cluster: &fakeCluster{id: 1},
+ }
+ rw := httptest.NewRecorder()
+
+ h.ServeHTTP(rw, req)
+
+ wcode := http.StatusCreated
+ if rw.Code != wcode {
+ t.Errorf("code=%d, want %d", rw.Code, wcode)
+ }
+
+ wct := "application/json"
+ if gct := rw.Header().Get("Content-Type"); gct != wct {
+ t.Errorf("content-type = %s, want %s", gct, wct)
+ }
+ gcid := rw.Header().Get("X-Etcd-Cluster-ID")
+ wcid := h.cluster.ID().String()
+ if gcid != wcid {
+ t.Errorf("cid = %s, want %s", gcid, wcid)
+ }
+
+ wb := `{"id":"c29b431f04be0bc7","name":"","peerURLs":["http://127.0.0.1:1"],"clientURLs":[]}` + "\n"
+ g := rw.Body.String()
+ if g != wb {
+ t.Errorf("got body=%q, want %q", g, wb)
+ }
+
+ wm := membership.Member{
+ ID: 14022875665250782151,
+ RaftAttributes: membership.RaftAttributes{
+ PeerURLs: []string{"http://127.0.0.1:1"},
+ },
+ }
+
+ wactions := []action{{name: "AddMember", params: []interface{}{wm}}}
+ if !reflect.DeepEqual(s.actions, wactions) {
+ t.Errorf("actions = %+v, want %+v", s.actions, wactions)
+ }
+}
+
+func TestServeMembersDelete(t *testing.T) {
+ req := &http.Request{
+ Method: "DELETE",
+ URL: testutil.MustNewURL(t, path.Join(membersPrefix, "BEEF")),
+ }
+ s := &serverRecorder{}
+ h := &membersHandler{
+ server: s,
+ cluster: &fakeCluster{id: 1},
+ }
+ rw := httptest.NewRecorder()
+
+ h.ServeHTTP(rw, req)
+
+ wcode := http.StatusNoContent
+ if rw.Code != wcode {
+ t.Errorf("code=%d, want %d", rw.Code, wcode)
+ }
+ gcid := rw.Header().Get("X-Etcd-Cluster-ID")
+ wcid := h.cluster.ID().String()
+ if gcid != wcid {
+ t.Errorf("cid = %s, want %s", gcid, wcid)
+ }
+ g := rw.Body.String()
+ if g != "" {
+ t.Errorf("got body=%q, want %q", g, "")
+ }
+ wactions := []action{{name: "RemoveMember", params: []interface{}{uint64(0xBEEF)}}}
+ if !reflect.DeepEqual(s.actions, wactions) {
+ t.Errorf("actions = %+v, want %+v", s.actions, wactions)
+ }
+}
+
+func TestServeMembersUpdate(t *testing.T) {
+ u := testutil.MustNewURL(t, path.Join(membersPrefix, "1"))
+ b := []byte(`{"peerURLs":["http://127.0.0.1:1"]}`)
+ req, err := http.NewRequest("PUT", u.String(), bytes.NewReader(b))
+ if err != nil {
+ t.Fatal(err)
+ }
+ req.Header.Set("Content-Type", "application/json")
+ s := &serverRecorder{}
+ h := &membersHandler{
+ server: s,
+ clock: clockwork.NewFakeClock(),
+ cluster: &fakeCluster{id: 1},
+ }
+ rw := httptest.NewRecorder()
+
+ h.ServeHTTP(rw, req)
+
+ wcode := http.StatusNoContent
+ if rw.Code != wcode {
+ t.Errorf("code=%d, want %d", rw.Code, wcode)
+ }
+
+ gcid := rw.Header().Get("X-Etcd-Cluster-ID")
+ wcid := h.cluster.ID().String()
+ if gcid != wcid {
+ t.Errorf("cid = %s, want %s", gcid, wcid)
+ }
+
+ wm := membership.Member{
+ ID: 1,
+ RaftAttributes: membership.RaftAttributes{
+ PeerURLs: []string{"http://127.0.0.1:1"},
+ },
+ }
+
+ wactions := []action{{name: "UpdateMember", params: []interface{}{wm}}}
+ if !reflect.DeepEqual(s.actions, wactions) {
+ t.Errorf("actions = %+v, want %+v", s.actions, wactions)
+ }
+}
+
+func TestServeMembersFail(t *testing.T) {
+ tests := []struct {
+ req *http.Request
+ server etcdserver.Server
+
+ wcode int
+ }{
+ {
+ // bad method
+ &http.Request{
+ Method: "CONNECT",
+ },
+ &resServer{},
+
+ http.StatusMethodNotAllowed,
+ },
+ {
+ // bad method
+ &http.Request{
+ Method: "TRACE",
+ },
+ &resServer{},
+
+ http.StatusMethodNotAllowed,
+ },
+ {
+ // parse body error
+ &http.Request{
+ URL: testutil.MustNewURL(t, membersPrefix),
+ Method: "POST",
+ Body: ioutil.NopCloser(strings.NewReader("bad json")),
+ Header: map[string][]string{"Content-Type": {"application/json"}},
+ },
+ &resServer{},
+
+ http.StatusBadRequest,
+ },
+ {
+ // bad content type
+ &http.Request{
+ URL: testutil.MustNewURL(t, membersPrefix),
+ Method: "POST",
+ Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
+ Header: map[string][]string{"Content-Type": {"application/bad"}},
+ },
+ &errServer{},
+
+ http.StatusUnsupportedMediaType,
+ },
+ {
+ // bad url
+ &http.Request{
+ URL: testutil.MustNewURL(t, membersPrefix),
+ Method: "POST",
+ Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://a"]}`)),
+ Header: map[string][]string{"Content-Type": {"application/json"}},
+ },
+ &errServer{},
+
+ http.StatusBadRequest,
+ },
+ {
+ // etcdserver.AddMember error
+ &http.Request{
+ URL: testutil.MustNewURL(t, membersPrefix),
+ Method: "POST",
+ Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
+ Header: map[string][]string{"Content-Type": {"application/json"}},
+ },
+ &errServer{
+ errors.New("Error while adding a member"),
+ },
+
+ http.StatusInternalServerError,
+ },
+ {
+ // etcdserver.AddMember error
+ &http.Request{
+ URL: testutil.MustNewURL(t, membersPrefix),
+ Method: "POST",
+ Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
+ Header: map[string][]string{"Content-Type": {"application/json"}},
+ },
+ &errServer{
+ membership.ErrIDExists,
+ },
+
+ http.StatusConflict,
+ },
+ {
+ // etcdserver.AddMember error
+ &http.Request{
+ URL: testutil.MustNewURL(t, membersPrefix),
+ Method: "POST",
+ Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
+ Header: map[string][]string{"Content-Type": {"application/json"}},
+ },
+ &errServer{
+ membership.ErrPeerURLexists,
+ },
+
+ http.StatusConflict,
+ },
+ {
+ // etcdserver.RemoveMember error with arbitrary server error
+ &http.Request{
+ URL: testutil.MustNewURL(t, path.Join(membersPrefix, "1")),
+ Method: "DELETE",
+ },
+ &errServer{
+ errors.New("Error while removing member"),
+ },
+
+ http.StatusInternalServerError,
+ },
+ {
+ // etcdserver.RemoveMember error with previously removed ID
+ &http.Request{
+ URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")),
+ Method: "DELETE",
+ },
+ &errServer{
+ membership.ErrIDRemoved,
+ },
+
+ http.StatusGone,
+ },
+ {
+ // etcdserver.RemoveMember error with nonexistent ID
+ &http.Request{
+ URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")),
+ Method: "DELETE",
+ },
+ &errServer{
+ membership.ErrIDNotFound,
+ },
+
+ http.StatusNotFound,
+ },
+ {
+ // etcdserver.RemoveMember error with badly formed ID
+ &http.Request{
+ URL: testutil.MustNewURL(t, path.Join(membersPrefix, "bad_id")),
+ Method: "DELETE",
+ },
+ nil,
+
+ http.StatusNotFound,
+ },
+ {
+ // etcdserver.RemoveMember with no ID
+ &http.Request{
+ URL: testutil.MustNewURL(t, membersPrefix),
+ Method: "DELETE",
+ },
+ nil,
+
+ http.StatusMethodNotAllowed,
+ },
+ {
+ // parse body error
+ &http.Request{
+ URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")),
+ Method: "PUT",
+ Body: ioutil.NopCloser(strings.NewReader("bad json")),
+ Header: map[string][]string{"Content-Type": {"application/json"}},
+ },
+ &resServer{},
+
+ http.StatusBadRequest,
+ },
+ {
+ // bad content type
+ &http.Request{
+ URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")),
+ Method: "PUT",
+ Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
+ Header: map[string][]string{"Content-Type": {"application/bad"}},
+ },
+ &errServer{},
+
+ http.StatusUnsupportedMediaType,
+ },
+ {
+ // bad url
+ &http.Request{
+ URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")),
+ Method: "PUT",
+ Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://a"]}`)),
+ Header: map[string][]string{"Content-Type": {"application/json"}},
+ },
+ &errServer{},
+
+ http.StatusBadRequest,
+ },
+ {
+ // etcdserver.UpdateMember error
+ &http.Request{
+ URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")),
+ Method: "PUT",
+ Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
+ Header: map[string][]string{"Content-Type": {"application/json"}},
+ },
+ &errServer{
+ errors.New("blah"),
+ },
+
+ http.StatusInternalServerError,
+ },
+ {
+ // etcdserver.UpdateMember error
+ &http.Request{
+ URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")),
+ Method: "PUT",
+ Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
+ Header: map[string][]string{"Content-Type": {"application/json"}},
+ },
+ &errServer{
+ membership.ErrPeerURLexists,
+ },
+
+ http.StatusConflict,
+ },
+ {
+ // etcdserver.UpdateMember error
+ &http.Request{
+ URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")),
+ Method: "PUT",
+ Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
+ Header: map[string][]string{"Content-Type": {"application/json"}},
+ },
+ &errServer{
+ membership.ErrIDNotFound,
+ },
+
+ http.StatusNotFound,
+ },
+ {
+ // etcdserver.UpdateMember error with badly formed ID
+ &http.Request{
+ URL: testutil.MustNewURL(t, path.Join(membersPrefix, "bad_id")),
+ Method: "PUT",
+ },
+ nil,
+
+ http.StatusNotFound,
+ },
+ {
+ // etcdserver.UpdateMember with no ID
+ &http.Request{
+ URL: testutil.MustNewURL(t, membersPrefix),
+ Method: "PUT",
+ },
+ nil,
+
+ http.StatusMethodNotAllowed,
+ },
+ }
+ for i, tt := range tests {
+ h := &membersHandler{
+ server: tt.server,
+ cluster: &fakeCluster{id: 1},
+ clock: clockwork.NewFakeClock(),
+ }
+ rw := httptest.NewRecorder()
+ h.ServeHTTP(rw, tt.req)
+ if rw.Code != tt.wcode {
+ t.Errorf("#%d: code=%d, want %d", i, rw.Code, tt.wcode)
+ }
+ if rw.Code != http.StatusMethodNotAllowed {
+ gcid := rw.Header().Get("X-Etcd-Cluster-ID")
+ wcid := h.cluster.ID().String()
+ if gcid != wcid {
+ t.Errorf("#%d: cid = %s, want %s", i, gcid, wcid)
+ }
+ }
+ }
+}
+
+func TestWriteEvent(t *testing.T) {
+ // nil event should not panic
+ rec := httptest.NewRecorder()
+ writeKeyEvent(rec, nil, false, dummyRaftTimer{})
+ h := rec.Header()
+ if len(h) > 0 {
+ t.Fatalf("unexpected non-empty headers: %#v", h)
+ }
+ b := rec.Body.String()
+ if len(b) > 0 {
+ t.Fatalf("unexpected non-empty body: %q", b)
+ }
+
+ tests := []struct {
+ ev *store.Event
+ noValue bool
+ idx string
+ // TODO(jonboulle): check body as well as just status code
+ code int
+ err error
+ }{
+ // standard case, standard 200 response
+ {
+ &store.Event{
+ Action: store.Get,
+ Node: &store.NodeExtern{},
+ PrevNode: &store.NodeExtern{},
+ },
+ false,
+ "0",
+ http.StatusOK,
+ nil,
+ },
+ // check new nodes return StatusCreated
+ {
+ &store.Event{
+ Action: store.Create,
+ Node: &store.NodeExtern{},
+ PrevNode: &store.NodeExtern{},
+ },
+ false,
+ "0",
+ http.StatusCreated,
+ nil,
+ },
+ }
+
+ for i, tt := range tests {
+ rw := httptest.NewRecorder()
+ writeKeyEvent(rw, tt.ev, tt.noValue, dummyRaftTimer{})
+ if gct := rw.Header().Get("Content-Type"); gct != "application/json" {
+ t.Errorf("case %d: bad Content-Type: got %q, want application/json", i, gct)
+ }
+ if gri := rw.Header().Get("X-Raft-Index"); gri != "100" {
+ t.Errorf("case %d: bad X-Raft-Index header: got %s, want %s", i, gri, "100")
+ }
+ if grt := rw.Header().Get("X-Raft-Term"); grt != "5" {
+ t.Errorf("case %d: bad X-Raft-Term header: got %s, want %s", i, grt, "5")
+ }
+ if gei := rw.Header().Get("X-Etcd-Index"); gei != tt.idx {
+ t.Errorf("case %d: bad X-Etcd-Index header: got %s, want %s", i, gei, tt.idx)
+ }
+ if rw.Code != tt.code {
+ t.Errorf("case %d: bad response code: got %d, want %v", i, rw.Code, tt.code)
+ }
+
+ }
+}
+
+func TestV2DMachinesEndpoint(t *testing.T) {
+ tests := []struct {
+ method string
+ wcode int
+ }{
+ {"GET", http.StatusOK},
+ {"HEAD", http.StatusOK},
+ {"POST", http.StatusMethodNotAllowed},
+ }
+
+ m := &machinesHandler{cluster: &fakeCluster{}}
+ s := httptest.NewServer(m)
+ defer s.Close()
+
+ for _, tt := range tests {
+ req, err := http.NewRequest(tt.method, s.URL+machinesPrefix, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ resp, err := http.DefaultClient.Do(req)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if resp.StatusCode != tt.wcode {
+ t.Errorf("StatusCode = %d, expected %d", resp.StatusCode, tt.wcode)
+ }
+ }
+}
+
+func TestServeMachines(t *testing.T) {
+ cluster := &fakeCluster{
+ clientURLs: []string{"http://localhost:8080", "http://localhost:8081", "http://localhost:8082"},
+ }
+ writer := httptest.NewRecorder()
+ req, err := http.NewRequest("GET", "", nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ h := &machinesHandler{cluster: cluster}
+ h.ServeHTTP(writer, req)
+ w := "http://localhost:8080, http://localhost:8081, http://localhost:8082"
+ if g := writer.Body.String(); g != w {
+ t.Errorf("body = %s, want %s", g, w)
+ }
+ if writer.Code != http.StatusOK {
+ t.Errorf("code = %d, want %d", writer.Code, http.StatusOK)
+ }
+}
+
+func TestGetID(t *testing.T) {
+ tests := []struct {
+ path string
+
+ wok bool
+ wid types.ID
+ wcode int
+ }{
+ {
+ "123",
+ true, 0x123, http.StatusOK,
+ },
+ {
+ "bad_id",
+ false, 0, http.StatusNotFound,
+ },
+ {
+ "",
+ false, 0, http.StatusMethodNotAllowed,
+ },
+ }
+
+ for i, tt := range tests {
+ w := httptest.NewRecorder()
+ id, ok := getID(tt.path, w)
+ if id != tt.wid {
+ t.Errorf("#%d: id = %d, want %d", i, id, tt.wid)
+ }
+ if ok != tt.wok {
+ t.Errorf("#%d: ok = %t, want %t", i, ok, tt.wok)
+ }
+ if w.Code != tt.wcode {
+ t.Errorf("#%d code = %d, want %d", i, w.Code, tt.wcode)
+ }
+ }
+}
+
+type dummyStats struct {
+ data []byte
+}
+
+func (ds *dummyStats) SelfStats() []byte { return ds.data }
+func (ds *dummyStats) LeaderStats() []byte { return ds.data }
+func (ds *dummyStats) StoreStats() []byte { return ds.data }
+func (ds *dummyStats) UpdateRecvApp(_ types.ID, _ int64) {}
+
+func TestServeSelfStats(t *testing.T) {
+ wb := []byte("some statistics")
+ w := string(wb)
+ sh := &statsHandler{
+ stats: &dummyStats{data: wb},
+ }
+ rw := httptest.NewRecorder()
+ sh.serveSelf(rw, &http.Request{Method: "GET"})
+ if rw.Code != http.StatusOK {
+ t.Errorf("code = %d, want %d", rw.Code, http.StatusOK)
+ }
+ wct := "application/json"
+ if gct := rw.Header().Get("Content-Type"); gct != wct {
+ t.Errorf("Content-Type = %q, want %q", gct, wct)
+ }
+ if g := rw.Body.String(); g != w {
+ t.Errorf("body = %s, want %s", g, w)
+ }
+}
+
+func TestSelfServeStatsBad(t *testing.T) {
+ for _, m := range []string{"PUT", "POST", "DELETE"} {
+ sh := &statsHandler{}
+ rw := httptest.NewRecorder()
+ sh.serveSelf(
+ rw,
+ &http.Request{
+ Method: m,
+ },
+ )
+ if rw.Code != http.StatusMethodNotAllowed {
+ t.Errorf("method %s: code=%d, want %d", m, rw.Code, http.StatusMethodNotAllowed)
+ }
+ }
+}
+
+func TestLeaderServeStatsBad(t *testing.T) {
+ for _, m := range []string{"PUT", "POST", "DELETE"} {
+ sh := &statsHandler{}
+ rw := httptest.NewRecorder()
+ sh.serveLeader(
+ rw,
+ &http.Request{
+ Method: m,
+ },
+ )
+ if rw.Code != http.StatusMethodNotAllowed {
+ t.Errorf("method %s: code=%d, want %d", m, rw.Code, http.StatusMethodNotAllowed)
+ }
+ }
+}
+
+func TestServeLeaderStats(t *testing.T) {
+ wb := []byte("some statistics")
+ w := string(wb)
+ sh := &statsHandler{
+ stats: &dummyStats{data: wb},
+ }
+ rw := httptest.NewRecorder()
+ sh.serveLeader(rw, &http.Request{Method: "GET"})
+ if rw.Code != http.StatusOK {
+ t.Errorf("code = %d, want %d", rw.Code, http.StatusOK)
+ }
+ wct := "application/json"
+ if gct := rw.Header().Get("Content-Type"); gct != wct {
+ t.Errorf("Content-Type = %q, want %q", gct, wct)
+ }
+ if g := rw.Body.String(); g != w {
+ t.Errorf("body = %s, want %s", g, w)
+ }
+}
+
+func TestServeStoreStats(t *testing.T) {
+ wb := []byte("some statistics")
+ w := string(wb)
+ sh := &statsHandler{
+ stats: &dummyStats{data: wb},
+ }
+ rw := httptest.NewRecorder()
+ sh.serveStore(rw, &http.Request{Method: "GET"})
+ if rw.Code != http.StatusOK {
+ t.Errorf("code = %d, want %d", rw.Code, http.StatusOK)
+ }
+ wct := "application/json"
+ if gct := rw.Header().Get("Content-Type"); gct != wct {
+ t.Errorf("Content-Type = %q, want %q", gct, wct)
+ }
+ if g := rw.Body.String(); g != w {
+ t.Errorf("body = %s, want %s", g, w)
+ }
+
+}
+
+func TestBadServeKeys(t *testing.T) {
+ testBadCases := []struct {
+ req *http.Request
+ server etcdserver.Server
+
+ wcode int
+ wbody string
+ }{
+ {
+ // bad method
+ &http.Request{
+ Method: "CONNECT",
+ },
+ &resServer{},
+
+ http.StatusMethodNotAllowed,
+ "Method Not Allowed",
+ },
+ {
+ // bad method
+ &http.Request{
+ Method: "TRACE",
+ },
+ &resServer{},
+
+ http.StatusMethodNotAllowed,
+ "Method Not Allowed",
+ },
+ {
+ // parseRequest error
+ &http.Request{
+ Body: nil,
+ Method: "PUT",
+ },
+ &resServer{},
+
+ http.StatusBadRequest,
+ `{"errorCode":210,"message":"Invalid POST form","cause":"missing form body","index":0}`,
+ },
+ {
+ // etcdserver.Server error
+ mustNewRequest(t, "foo"),
+ &errServer{
+ errors.New("Internal Server Error"),
+ },
+
+ http.StatusInternalServerError,
+ `{"errorCode":300,"message":"Raft Internal Error","cause":"Internal Server Error","index":0}`,
+ },
+ {
+ // etcdserver.Server etcd error
+ mustNewRequest(t, "foo"),
+ &errServer{
+ etcdErr.NewError(etcdErr.EcodeKeyNotFound, "/1/pant", 0),
+ },
+
+ http.StatusNotFound,
+ `{"errorCode":100,"message":"Key not found","cause":"/pant","index":0}`,
+ },
+ {
+ // non-event/watcher response from etcdserver.Server
+ mustNewRequest(t, "foo"),
+ &resServer{
+ etcdserver.Response{},
+ },
+
+ http.StatusInternalServerError,
+ `{"errorCode":300,"message":"Raft Internal Error","cause":"received response with no Event/Watcher!","index":0}`,
+ },
+ }
+ for i, tt := range testBadCases {
+ h := &keysHandler{
+ timeout: 0, // context times out immediately
+ server: tt.server,
+ cluster: &fakeCluster{id: 1},
+ }
+ rw := httptest.NewRecorder()
+ h.ServeHTTP(rw, tt.req)
+ if rw.Code != tt.wcode {
+ t.Errorf("#%d: got code=%d, want %d", i, rw.Code, tt.wcode)
+ }
+ if rw.Code != http.StatusMethodNotAllowed {
+ gcid := rw.Header().Get("X-Etcd-Cluster-ID")
+ wcid := h.cluster.ID().String()
+ if gcid != wcid {
+ t.Errorf("#%d: cid = %s, want %s", i, gcid, wcid)
+ }
+ }
+ if g := strings.TrimSuffix(rw.Body.String(), "\n"); g != tt.wbody {
+ t.Errorf("#%d: body = %s, want %s", i, g, tt.wbody)
+ }
+ }
+}
+
+func TestServeKeysGood(t *testing.T) {
+ tests := []struct {
+ req *http.Request
+ wcode int
+ }{
+ {
+ mustNewMethodRequest(t, "HEAD", "foo"),
+ http.StatusOK,
+ },
+ {
+ mustNewMethodRequest(t, "GET", "foo"),
+ http.StatusOK,
+ },
+ {
+ mustNewForm(t, "foo", url.Values{"value": []string{"bar"}}),
+ http.StatusOK,
+ },
+ {
+ mustNewMethodRequest(t, "DELETE", "foo"),
+ http.StatusOK,
+ },
+ {
+ mustNewPostForm(t, "foo", url.Values{"value": []string{"bar"}}),
+ http.StatusOK,
+ },
+ }
+ server := &resServer{
+ etcdserver.Response{
+ Event: &store.Event{
+ Action: store.Get,
+ Node: &store.NodeExtern{},
+ },
+ },
+ }
+ for i, tt := range tests {
+ h := &keysHandler{
+ timeout: time.Hour,
+ server: server,
+ timer: &dummyRaftTimer{},
+ cluster: &fakeCluster{id: 1},
+ }
+ rw := httptest.NewRecorder()
+ h.ServeHTTP(rw, tt.req)
+ if rw.Code != tt.wcode {
+ t.Errorf("#%d: got code=%d, want %d", i, rw.Code, tt.wcode)
+ }
+ }
+}
+
+func TestServeKeysEvent(t *testing.T) {
+ tests := []struct {
+ req *http.Request
+ rsp etcdserver.Response
+ wcode int
+ event *store.Event
+ }{
+ {
+ mustNewRequest(t, "foo"),
+ etcdserver.Response{
+ Event: &store.Event{
+ Action: store.Get,
+ Node: &store.NodeExtern{},
+ },
+ },
+ http.StatusOK,
+ &store.Event{
+ Action: store.Get,
+ Node: &store.NodeExtern{},
+ },
+ },
+ {
+ mustNewForm(
+ t,
+ "foo",
+ url.Values{"noValueOnSuccess": []string{"true"}},
+ ),
+ etcdserver.Response{
+ Event: &store.Event{
+ Action: store.CompareAndSwap,
+ Node: &store.NodeExtern{},
+ },
+ },
+ http.StatusOK,
+ &store.Event{
+ Action: store.CompareAndSwap,
+ Node: nil,
+ },
+ },
+ }
+
+ server := &resServer{}
+ h := &keysHandler{
+ timeout: time.Hour,
+ server: server,
+ cluster: &fakeCluster{id: 1},
+ timer: &dummyRaftTimer{},
+ }
+
+ for _, tt := range tests {
+ server.res = tt.rsp
+ rw := httptest.NewRecorder()
+ h.ServeHTTP(rw, tt.req)
+
+ wbody := mustMarshalEvent(
+ t,
+ tt.event,
+ )
+
+ if rw.Code != tt.wcode {
+ t.Errorf("got code=%d, want %d", rw.Code, tt.wcode)
+ }
+ gcid := rw.Header().Get("X-Etcd-Cluster-ID")
+ wcid := h.cluster.ID().String()
+ if gcid != wcid {
+ t.Errorf("cid = %s, want %s", gcid, wcid)
+ }
+ g := rw.Body.String()
+ if g != wbody {
+ t.Errorf("got body=%#v, want %#v", g, wbody)
+ }
+ }
+}
+
+func TestServeKeysWatch(t *testing.T) {
+ req := mustNewRequest(t, "/foo/bar")
+ ec := make(chan *store.Event)
+ dw := &dummyWatcher{
+ echan: ec,
+ }
+ server := &resServer{
+ etcdserver.Response{
+ Watcher: dw,
+ },
+ }
+ h := &keysHandler{
+ timeout: time.Hour,
+ server: server,
+ cluster: &fakeCluster{id: 1},
+ timer: &dummyRaftTimer{},
+ }
+ go func() {
+ ec <- &store.Event{
+ Action: store.Get,
+ Node: &store.NodeExtern{},
+ }
+ }()
+ rw := httptest.NewRecorder()
+
+ h.ServeHTTP(rw, req)
+
+ wcode := http.StatusOK
+ wbody := mustMarshalEvent(
+ t,
+ &store.Event{
+ Action: store.Get,
+ Node: &store.NodeExtern{},
+ },
+ )
+
+ if rw.Code != wcode {
+ t.Errorf("got code=%d, want %d", rw.Code, wcode)
+ }
+ gcid := rw.Header().Get("X-Etcd-Cluster-ID")
+ wcid := h.cluster.ID().String()
+ if gcid != wcid {
+ t.Errorf("cid = %s, want %s", gcid, wcid)
+ }
+ g := rw.Body.String()
+ if g != wbody {
+ t.Errorf("got body=%#v, want %#v", g, wbody)
+ }
+}
+
+type recordingCloseNotifier struct {
+ *httptest.ResponseRecorder
+ cn chan bool
+}
+
+func (rcn *recordingCloseNotifier) CloseNotify() <-chan bool {
+ return rcn.cn
+}
+
+func TestHandleWatch(t *testing.T) {
+ defaultRwRr := func() (http.ResponseWriter, *httptest.ResponseRecorder) {
+ r := httptest.NewRecorder()
+ return r, r
+ }
+ noopEv := func(chan *store.Event) {}
+
+ tests := []struct {
+ getCtx func() context.Context
+ getRwRr func() (http.ResponseWriter, *httptest.ResponseRecorder)
+ doToChan func(chan *store.Event)
+
+ wbody string
+ }{
+ {
+ // Normal case: one event
+ context.Background,
+ defaultRwRr,
+ func(ch chan *store.Event) {
+ ch <- &store.Event{
+ Action: store.Get,
+ Node: &store.NodeExtern{},
+ }
+ },
+
+ mustMarshalEvent(
+ t,
+ &store.Event{
+ Action: store.Get,
+ Node: &store.NodeExtern{},
+ },
+ ),
+ },
+ {
+ // Channel is closed, no event
+ context.Background,
+ defaultRwRr,
+ func(ch chan *store.Event) {
+ close(ch)
+ },
+
+ "",
+ },
+ {
+ // Simulate a timed-out context
+ func() context.Context {
+ ctx, cancel := context.WithCancel(context.Background())
+ cancel()
+ return ctx
+ },
+ defaultRwRr,
+ noopEv,
+
+ "",
+ },
+ {
+ // Close-notifying request
+ context.Background,
+ func() (http.ResponseWriter, *httptest.ResponseRecorder) {
+ rw := &recordingCloseNotifier{
+ ResponseRecorder: httptest.NewRecorder(),
+ cn: make(chan bool, 1),
+ }
+ rw.cn <- true
+ return rw, rw.ResponseRecorder
+ },
+ noopEv,
+
+ "",
+ },
+ }
+
+ for i, tt := range tests {
+ rw, rr := tt.getRwRr()
+ wa := &dummyWatcher{
+ echan: make(chan *store.Event, 1),
+ sidx: 10,
+ }
+ tt.doToChan(wa.echan)
+
+ handleKeyWatch(tt.getCtx(), rw, wa, false, dummyRaftTimer{})
+
+ wcode := http.StatusOK
+ wct := "application/json"
+ wei := "10"
+ wri := "100"
+ wrt := "5"
+
+ if rr.Code != wcode {
+ t.Errorf("#%d: got code=%d, want %d", i, rr.Code, wcode)
+ }
+ h := rr.Header()
+ if ct := h.Get("Content-Type"); ct != wct {
+ t.Errorf("#%d: Content-Type=%q, want %q", i, ct, wct)
+ }
+ if ei := h.Get("X-Etcd-Index"); ei != wei {
+ t.Errorf("#%d: X-Etcd-Index=%q, want %q", i, ei, wei)
+ }
+ if ri := h.Get("X-Raft-Index"); ri != wri {
+ t.Errorf("#%d: X-Raft-Index=%q, want %q", i, ri, wri)
+ }
+ if rt := h.Get("X-Raft-Term"); rt != wrt {
+ t.Errorf("#%d: X-Raft-Term=%q, want %q", i, rt, wrt)
+ }
+ g := rr.Body.String()
+ if g != tt.wbody {
+ t.Errorf("#%d: got body=%#v, want %#v", i, g, tt.wbody)
+ }
+ }
+}
+
+func TestHandleWatchStreaming(t *testing.T) {
+ rw := &flushingRecorder{
+ httptest.NewRecorder(),
+ make(chan struct{}, 1),
+ }
+ wa := &dummyWatcher{
+ echan: make(chan *store.Event),
+ }
+
+ // Launch the streaming handler in the background with a cancellable context
+ ctx, cancel := context.WithCancel(context.Background())
+ done := make(chan struct{})
+ go func() {
+ handleKeyWatch(ctx, rw, wa, true, dummyRaftTimer{})
+ close(done)
+ }()
+
+ // Expect one Flush for the headers etc.
+ select {
+ case <-rw.ch:
+ case <-time.After(time.Second):
+ t.Fatalf("timed out waiting for flush")
+ }
+
+ // Expect headers but no body
+ wcode := http.StatusOK
+ wct := "application/json"
+ wbody := ""
+
+ if rw.Code != wcode {
+ t.Errorf("got code=%d, want %d", rw.Code, wcode)
+ }
+ h := rw.Header()
+ if ct := h.Get("Content-Type"); ct != wct {
+ t.Errorf("Content-Type=%q, want %q", ct, wct)
+ }
+ g := rw.Body.String()
+ if g != wbody {
+ t.Errorf("got body=%#v, want %#v", g, wbody)
+ }
+
+ // Now send the first event
+ select {
+ case wa.echan <- &store.Event{
+ Action: store.Get,
+ Node: &store.NodeExtern{},
+ }:
+ case <-time.After(time.Second):
+ t.Fatal("timed out waiting for send")
+ }
+
+ // Wait for it to be flushed...
+ select {
+ case <-rw.ch:
+ case <-time.After(time.Second):
+ t.Fatalf("timed out waiting for flush")
+ }
+
+ // And check the body is as expected
+ wbody = mustMarshalEvent(
+ t,
+ &store.Event{
+ Action: store.Get,
+ Node: &store.NodeExtern{},
+ },
+ )
+ g = rw.Body.String()
+ if g != wbody {
+ t.Errorf("got body=%#v, want %#v", g, wbody)
+ }
+
+ // Rinse and repeat
+ select {
+ case wa.echan <- &store.Event{
+ Action: store.Get,
+ Node: &store.NodeExtern{},
+ }:
+ case <-time.After(time.Second):
+ t.Fatal("timed out waiting for send")
+ }
+
+ select {
+ case <-rw.ch:
+ case <-time.After(time.Second):
+ t.Fatalf("timed out waiting for flush")
+ }
+
+ // This time, we expect to see both events
+ wbody = wbody + wbody
+ g = rw.Body.String()
+ if g != wbody {
+ t.Errorf("got body=%#v, want %#v", g, wbody)
+ }
+
+ // Finally, time out the connection and ensure the serving goroutine returns
+ cancel()
+
+ select {
+ case <-done:
+ case <-time.After(time.Second):
+ t.Fatalf("timed out waiting for done")
+ }
+}
+
+func TestTrimEventPrefix(t *testing.T) {
+ pre := "/abc"
+ tests := []struct {
+ ev *store.Event
+ wev *store.Event
+ }{
+ {
+ nil,
+ nil,
+ },
+ {
+ &store.Event{},
+ &store.Event{},
+ },
+ {
+ &store.Event{Node: &store.NodeExtern{Key: "/abc/def"}},
+ &store.Event{Node: &store.NodeExtern{Key: "/def"}},
+ },
+ {
+ &store.Event{PrevNode: &store.NodeExtern{Key: "/abc/ghi"}},
+ &store.Event{PrevNode: &store.NodeExtern{Key: "/ghi"}},
+ },
+ {
+ &store.Event{
+ Node: &store.NodeExtern{Key: "/abc/def"},
+ PrevNode: &store.NodeExtern{Key: "/abc/ghi"},
+ },
+ &store.Event{
+ Node: &store.NodeExtern{Key: "/def"},
+ PrevNode: &store.NodeExtern{Key: "/ghi"},
+ },
+ },
+ }
+ for i, tt := range tests {
+ ev := trimEventPrefix(tt.ev, pre)
+ if !reflect.DeepEqual(ev, tt.wev) {
+ t.Errorf("#%d: event = %+v, want %+v", i, ev, tt.wev)
+ }
+ }
+}
+
+func TestTrimNodeExternPrefix(t *testing.T) {
+ pre := "/abc"
+ tests := []struct {
+ n *store.NodeExtern
+ wn *store.NodeExtern
+ }{
+ {
+ nil,
+ nil,
+ },
+ {
+ &store.NodeExtern{Key: "/abc/def"},
+ &store.NodeExtern{Key: "/def"},
+ },
+ {
+ &store.NodeExtern{
+ Key: "/abc/def",
+ Nodes: []*store.NodeExtern{
+ {Key: "/abc/def/1"},
+ {Key: "/abc/def/2"},
+ },
+ },
+ &store.NodeExtern{
+ Key: "/def",
+ Nodes: []*store.NodeExtern{
+ {Key: "/def/1"},
+ {Key: "/def/2"},
+ },
+ },
+ },
+ }
+ for i, tt := range tests {
+ trimNodeExternPrefix(tt.n, pre)
+ if !reflect.DeepEqual(tt.n, tt.wn) {
+ t.Errorf("#%d: node = %+v, want %+v", i, tt.n, tt.wn)
+ }
+ }
+}
+
+func TestTrimPrefix(t *testing.T) {
+ tests := []struct {
+ in string
+ prefix string
+ w string
+ }{
+ {"/v2/members", "/v2/members", ""},
+ {"/v2/members/", "/v2/members", ""},
+ {"/v2/members/foo", "/v2/members", "foo"},
+ }
+ for i, tt := range tests {
+ if g := trimPrefix(tt.in, tt.prefix); g != tt.w {
+ t.Errorf("#%d: trimPrefix = %q, want %q", i, g, tt.w)
+ }
+ }
+}
+
+func TestNewMemberCollection(t *testing.T) {
+ fixture := []*membership.Member{
+ {
+ ID: 12,
+ Attributes: membership.Attributes{ClientURLs: []string{"http://localhost:8080", "http://localhost:8081"}},
+ RaftAttributes: membership.RaftAttributes{PeerURLs: []string{"http://localhost:8082", "http://localhost:8083"}},
+ },
+ {
+ ID: 13,
+ Attributes: membership.Attributes{ClientURLs: []string{"http://localhost:9090", "http://localhost:9091"}},
+ RaftAttributes: membership.RaftAttributes{PeerURLs: []string{"http://localhost:9092", "http://localhost:9093"}},
+ },
+ }
+ got := newMemberCollection(fixture)
+
+ want := httptypes.MemberCollection([]httptypes.Member{
+ {
+ ID: "c",
+ ClientURLs: []string{"http://localhost:8080", "http://localhost:8081"},
+ PeerURLs: []string{"http://localhost:8082", "http://localhost:8083"},
+ },
+ {
+ ID: "d",
+ ClientURLs: []string{"http://localhost:9090", "http://localhost:9091"},
+ PeerURLs: []string{"http://localhost:9092", "http://localhost:9093"},
+ },
+ })
+
+ if !reflect.DeepEqual(&want, got) {
+ t.Fatalf("newMemberCollection failure: want=%#v, got=%#v", &want, got)
+ }
+}
+
+func TestNewMember(t *testing.T) {
+ fixture := &membership.Member{
+ ID: 12,
+ Attributes: membership.Attributes{ClientURLs: []string{"http://localhost:8080", "http://localhost:8081"}},
+ RaftAttributes: membership.RaftAttributes{PeerURLs: []string{"http://localhost:8082", "http://localhost:8083"}},
+ }
+ got := newMember(fixture)
+
+ want := httptypes.Member{
+ ID: "c",
+ ClientURLs: []string{"http://localhost:8080", "http://localhost:8081"},
+ PeerURLs: []string{"http://localhost:8082", "http://localhost:8083"},
+ }
+
+ if !reflect.DeepEqual(want, got) {
+ t.Fatalf("newMember failure: want=%#v, got=%#v", want, got)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/doc.go b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/doc.go
new file mode 100644
index 00000000..475c4b1f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 v2http provides etcd client and server implementations.
+package v2http
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/http.go b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/http.go
new file mode 100644
index 00000000..589c172d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/http.go
@@ -0,0 +1,74 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 v2http
+
+import (
+ "math"
+ "net/http"
+ "strings"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/api/etcdhttp"
+ "github.com/coreos/etcd/etcdserver/api/v2http/httptypes"
+ "github.com/coreos/etcd/etcdserver/auth"
+ "github.com/coreos/etcd/pkg/logutil"
+
+ "github.com/coreos/pkg/capnslog"
+)
+
+const (
+ // time to wait for a Watch request
+ defaultWatchTimeout = time.Duration(math.MaxInt64)
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "etcdserver/api/v2http")
+ mlog = logutil.NewMergeLogger(plog)
+)
+
+func writeError(w http.ResponseWriter, r *http.Request, err error) {
+ if err == nil {
+ return
+ }
+ if e, ok := err.(auth.Error); ok {
+ herr := httptypes.NewHTTPError(e.HTTPStatus(), e.Error())
+ if et := herr.WriteTo(w); et != nil {
+ plog.Debugf("error writing HTTPError (%v) to %s", et, r.RemoteAddr)
+ }
+ return
+ }
+ etcdhttp.WriteError(w, r, err)
+}
+
+// allowMethod verifies that the given method is one of the allowed methods,
+// and if not, it writes an error to w. A boolean is returned indicating
+// whether or not the method is allowed.
+func allowMethod(w http.ResponseWriter, m string, ms ...string) bool {
+ for _, meth := range ms {
+ if m == meth {
+ return true
+ }
+ }
+ w.Header().Set("Allow", strings.Join(ms, ","))
+ http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
+ return false
+}
+
+func requestLogger(handler http.Handler) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ plog.Debugf("[%s] %s remote:%s", r.Method, r.RequestURI, r.RemoteAddr)
+ handler.ServeHTTP(w, r)
+ })
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/http_test.go b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/http_test.go
new file mode 100644
index 00000000..61225409
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/http_test.go
@@ -0,0 +1,193 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 v2http
+
+import (
+ "errors"
+ "net/http"
+ "net/http/httptest"
+ "sort"
+ "testing"
+
+ etcdErr "github.com/coreos/etcd/error"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/go-semver/semver"
+ "golang.org/x/net/context"
+)
+
+type fakeCluster struct {
+ id uint64
+ clientURLs []string
+ members map[uint64]*membership.Member
+}
+
+func (c *fakeCluster) ID() types.ID { return types.ID(c.id) }
+func (c *fakeCluster) ClientURLs() []string { return c.clientURLs }
+func (c *fakeCluster) Members() []*membership.Member {
+ var ms membership.MembersByID
+ for _, m := range c.members {
+ ms = append(ms, m)
+ }
+ sort.Sort(ms)
+ return []*membership.Member(ms)
+}
+func (c *fakeCluster) Member(id types.ID) *membership.Member { return c.members[uint64(id)] }
+func (c *fakeCluster) IsIDRemoved(id types.ID) bool { return false }
+func (c *fakeCluster) Version() *semver.Version { return nil }
+
+// errServer implements the etcd.Server interface for testing.
+// It returns the given error from any Do/Process/AddMember/RemoveMember calls.
+type errServer struct {
+ err error
+}
+
+func (fs *errServer) Start() {}
+func (fs *errServer) Stop() {}
+func (fs *errServer) ID() types.ID { return types.ID(1) }
+func (fs *errServer) Leader() types.ID { return types.ID(1) }
+func (fs *errServer) Do(ctx context.Context, r etcdserverpb.Request) (etcdserver.Response, error) {
+ return etcdserver.Response{}, fs.err
+}
+func (fs *errServer) Process(ctx context.Context, m raftpb.Message) error {
+ return fs.err
+}
+func (fs *errServer) AddMember(ctx context.Context, m membership.Member) ([]*membership.Member, error) {
+ return nil, fs.err
+}
+func (fs *errServer) RemoveMember(ctx context.Context, id uint64) ([]*membership.Member, error) {
+ return nil, fs.err
+}
+func (fs *errServer) UpdateMember(ctx context.Context, m membership.Member) ([]*membership.Member, error) {
+ return nil, fs.err
+}
+
+func (fs *errServer) ClusterVersion() *semver.Version { return nil }
+
+func TestWriteError(t *testing.T) {
+ // nil error should not panic
+ rec := httptest.NewRecorder()
+ r := new(http.Request)
+ writeError(rec, r, nil)
+ h := rec.Header()
+ if len(h) > 0 {
+ t.Fatalf("unexpected non-empty headers: %#v", h)
+ }
+ b := rec.Body.String()
+ if len(b) > 0 {
+ t.Fatalf("unexpected non-empty body: %q", b)
+ }
+
+ tests := []struct {
+ err error
+ wcode int
+ wi string
+ }{
+ {
+ etcdErr.NewError(etcdErr.EcodeKeyNotFound, "/foo/bar", 123),
+ http.StatusNotFound,
+ "123",
+ },
+ {
+ etcdErr.NewError(etcdErr.EcodeTestFailed, "/foo/bar", 456),
+ http.StatusPreconditionFailed,
+ "456",
+ },
+ {
+ err: errors.New("something went wrong"),
+ wcode: http.StatusInternalServerError,
+ },
+ }
+
+ for i, tt := range tests {
+ rw := httptest.NewRecorder()
+ writeError(rw, r, tt.err)
+ if code := rw.Code; code != tt.wcode {
+ t.Errorf("#%d: code=%d, want %d", i, code, tt.wcode)
+ }
+ if idx := rw.Header().Get("X-Etcd-Index"); idx != tt.wi {
+ t.Errorf("#%d: X-Etcd-Index=%q, want %q", i, idx, tt.wi)
+ }
+ }
+}
+
+func TestAllowMethod(t *testing.T) {
+ tests := []struct {
+ m string
+ ms []string
+ w bool
+ wh string
+ }{
+ // Accepted methods
+ {
+ m: "GET",
+ ms: []string{"GET", "POST", "PUT"},
+ w: true,
+ },
+ {
+ m: "POST",
+ ms: []string{"POST"},
+ w: true,
+ },
+ // Made-up methods no good
+ {
+ m: "FAKE",
+ ms: []string{"GET", "POST", "PUT"},
+ w: false,
+ wh: "GET,POST,PUT",
+ },
+ // Empty methods no good
+ {
+ m: "",
+ ms: []string{"GET", "POST"},
+ w: false,
+ wh: "GET,POST",
+ },
+ // Empty accepted methods no good
+ {
+ m: "GET",
+ ms: []string{""},
+ w: false,
+ wh: "",
+ },
+ // No methods accepted
+ {
+ m: "GET",
+ ms: []string{},
+ w: false,
+ wh: "",
+ },
+ }
+
+ for i, tt := range tests {
+ rw := httptest.NewRecorder()
+ g := allowMethod(rw, tt.m, tt.ms...)
+ if g != tt.w {
+ t.Errorf("#%d: got allowMethod()=%t, want %t", i, g, tt.w)
+ }
+ if !tt.w {
+ if rw.Code != http.StatusMethodNotAllowed {
+ t.Errorf("#%d: code=%d, want %d", i, rw.Code, http.StatusMethodNotAllowed)
+ }
+ gh := rw.Header().Get("Allow")
+ if gh != tt.wh {
+ t.Errorf("#%d: Allow header=%q, want %q", i, gh, tt.wh)
+ }
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/httptypes/errors.go b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/httptypes/errors.go
new file mode 100644
index 00000000..0657604c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/httptypes/errors.go
@@ -0,0 +1,56 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 httptypes
+
+import (
+ "encoding/json"
+ "net/http"
+
+ "github.com/coreos/pkg/capnslog"
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "etcdserver/api/v2http/httptypes")
+)
+
+type HTTPError struct {
+ Message string `json:"message"`
+ // Code is the HTTP status code
+ Code int `json:"-"`
+}
+
+func (e HTTPError) Error() string {
+ return e.Message
+}
+
+func (e HTTPError) WriteTo(w http.ResponseWriter) error {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(e.Code)
+ b, err := json.Marshal(e)
+ if err != nil {
+ plog.Panicf("marshal HTTPError should never fail (%v)", err)
+ }
+ if _, err := w.Write(b); err != nil {
+ return err
+ }
+ return nil
+}
+
+func NewHTTPError(code int, m string) *HTTPError {
+ return &HTTPError{
+ Message: m,
+ Code: code,
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/httptypes/errors_test.go b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/httptypes/errors_test.go
new file mode 100644
index 00000000..287950dc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/httptypes/errors_test.go
@@ -0,0 +1,49 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 httptypes
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "reflect"
+ "testing"
+)
+
+func TestHTTPErrorWriteTo(t *testing.T) {
+ err := NewHTTPError(http.StatusBadRequest, "what a bad request you made!")
+ rr := httptest.NewRecorder()
+ if e := err.WriteTo(rr); e != nil {
+ t.Fatalf("HTTPError.WriteTo error (%v)", e)
+ }
+
+ wcode := http.StatusBadRequest
+ wheader := http.Header(map[string][]string{
+ "Content-Type": {"application/json"},
+ })
+ wbody := `{"message":"what a bad request you made!"}`
+
+ if wcode != rr.Code {
+ t.Errorf("HTTP status code %d, want %d", rr.Code, wcode)
+ }
+
+ if !reflect.DeepEqual(wheader, rr.HeaderMap) {
+ t.Errorf("HTTP headers %v, want %v", rr.HeaderMap, wheader)
+ }
+
+ gbody := rr.Body.String()
+ if wbody != gbody {
+ t.Errorf("HTTP body %q, want %q", gbody, wbody)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/httptypes/member.go b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/httptypes/member.go
new file mode 100644
index 00000000..738d7443
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/httptypes/member.go
@@ -0,0 +1,69 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 httptypes defines how etcd's HTTP API entities are serialized to and
+// deserialized from JSON.
+package httptypes
+
+import (
+ "encoding/json"
+
+ "github.com/coreos/etcd/pkg/types"
+)
+
+type Member struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ PeerURLs []string `json:"peerURLs"`
+ ClientURLs []string `json:"clientURLs"`
+}
+
+type MemberCreateRequest struct {
+ PeerURLs types.URLs
+}
+
+type MemberUpdateRequest struct {
+ MemberCreateRequest
+}
+
+func (m *MemberCreateRequest) UnmarshalJSON(data []byte) error {
+ s := struct {
+ PeerURLs []string `json:"peerURLs"`
+ }{}
+
+ err := json.Unmarshal(data, &s)
+ if err != nil {
+ return err
+ }
+
+ urls, err := types.NewURLs(s.PeerURLs)
+ if err != nil {
+ return err
+ }
+
+ m.PeerURLs = urls
+ return nil
+}
+
+type MemberCollection []Member
+
+func (c *MemberCollection) MarshalJSON() ([]byte, error) {
+ d := struct {
+ Members []Member `json:"members"`
+ }{
+ Members: []Member(*c),
+ }
+
+ return json.Marshal(d)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/httptypes/member_test.go b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/httptypes/member_test.go
new file mode 100644
index 00000000..ab6045e0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/httptypes/member_test.go
@@ -0,0 +1,135 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 httptypes
+
+import (
+ "encoding/json"
+ "net/url"
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/types"
+)
+
+func TestMemberUnmarshal(t *testing.T) {
+ tests := []struct {
+ body []byte
+ wantMember Member
+ wantError bool
+ }{
+ // no URLs, just check ID & Name
+ {
+ body: []byte(`{"id": "c", "name": "dungarees"}`),
+ wantMember: Member{ID: "c", Name: "dungarees", PeerURLs: nil, ClientURLs: nil},
+ },
+
+ // both client and peer URLs
+ {
+ body: []byte(`{"peerURLs": ["http://127.0.0.1:2379"], "clientURLs": ["http://127.0.0.1:2379"]}`),
+ wantMember: Member{
+ PeerURLs: []string{
+ "http://127.0.0.1:2379",
+ },
+ ClientURLs: []string{
+ "http://127.0.0.1:2379",
+ },
+ },
+ },
+
+ // multiple peer URLs
+ {
+ body: []byte(`{"peerURLs": ["http://127.0.0.1:2379", "https://example.com"]}`),
+ wantMember: Member{
+ PeerURLs: []string{
+ "http://127.0.0.1:2379",
+ "https://example.com",
+ },
+ ClientURLs: nil,
+ },
+ },
+
+ // multiple client URLs
+ {
+ body: []byte(`{"clientURLs": ["http://127.0.0.1:2379", "https://example.com"]}`),
+ wantMember: Member{
+ PeerURLs: nil,
+ ClientURLs: []string{
+ "http://127.0.0.1:2379",
+ "https://example.com",
+ },
+ },
+ },
+
+ // invalid JSON
+ {
+ body: []byte(`{"peerU`),
+ wantError: true,
+ },
+ }
+
+ for i, tt := range tests {
+ got := Member{}
+ err := json.Unmarshal(tt.body, &got)
+ if tt.wantError != (err != nil) {
+ t.Errorf("#%d: want error %t, got %v", i, tt.wantError, err)
+ continue
+ }
+
+ if !reflect.DeepEqual(tt.wantMember, got) {
+ t.Errorf("#%d: incorrect output: want=%#v, got=%#v", i, tt.wantMember, got)
+ }
+ }
+}
+
+func TestMemberCreateRequestUnmarshal(t *testing.T) {
+ body := []byte(`{"peerURLs": ["http://127.0.0.1:8081", "https://127.0.0.1:8080"]}`)
+ want := MemberCreateRequest{
+ PeerURLs: types.URLs([]url.URL{
+ {Scheme: "http", Host: "127.0.0.1:8081"},
+ {Scheme: "https", Host: "127.0.0.1:8080"},
+ }),
+ }
+
+ var req MemberCreateRequest
+ if err := json.Unmarshal(body, &req); err != nil {
+ t.Fatalf("Unmarshal returned unexpected err=%v", err)
+ }
+
+ if !reflect.DeepEqual(want, req) {
+ t.Fatalf("Failed to unmarshal MemberCreateRequest: want=%#v, got=%#v", want, req)
+ }
+}
+
+func TestMemberCreateRequestUnmarshalFail(t *testing.T) {
+ tests := [][]byte{
+ // invalid JSON
+ []byte(``),
+ []byte(`{`),
+
+ // spot-check validation done in types.NewURLs
+ []byte(`{"peerURLs": "foo"}`),
+ []byte(`{"peerURLs": ["."]}`),
+ []byte(`{"peerURLs": []}`),
+ []byte(`{"peerURLs": ["http://127.0.0.1:2379/foo"]}`),
+ []byte(`{"peerURLs": ["http://127.0.0.1"]}`),
+ }
+
+ for i, tt := range tests {
+ var req MemberCreateRequest
+ if err := json.Unmarshal(tt, &req); err == nil {
+ t.Errorf("#%d: expected err, got nil", i)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/metrics.go b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/metrics.go
new file mode 100644
index 00000000..fdfb0c60
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/metrics.go
@@ -0,0 +1,96 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 v2http
+
+import (
+ "strconv"
+ "time"
+
+ "net/http"
+
+ etcdErr "github.com/coreos/etcd/error"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api/v2http/httptypes"
+ "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/prometheus/client_golang/prometheus"
+)
+
+var (
+ incomingEvents = prometheus.NewCounterVec(
+ prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "http",
+ Name: "received_total",
+ Help: "Counter of requests received into the system (successfully parsed and authd).",
+ }, []string{"method"})
+
+ failedEvents = prometheus.NewCounterVec(
+ prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "http",
+ Name: "failed_total",
+ Help: "Counter of handle failures of requests (non-watches), by method (GET/PUT etc.) and code (400, 500 etc.).",
+ }, []string{"method", "code"})
+
+ successfulEventsHandlingTime = prometheus.NewHistogramVec(
+ prometheus.HistogramOpts{
+ Namespace: "etcd",
+ Subsystem: "http",
+ Name: "successful_duration_seconds",
+ Help: "Bucketed histogram of processing time (s) of successfully handled requests (non-watches), by method (GET/PUT etc.).",
+ Buckets: prometheus.ExponentialBuckets(0.0005, 2, 13),
+ }, []string{"method"})
+)
+
+func init() {
+ prometheus.MustRegister(incomingEvents)
+ prometheus.MustRegister(failedEvents)
+ prometheus.MustRegister(successfulEventsHandlingTime)
+}
+
+func reportRequestReceived(request etcdserverpb.Request) {
+ incomingEvents.WithLabelValues(methodFromRequest(request)).Inc()
+}
+
+func reportRequestCompleted(request etcdserverpb.Request, response etcdserver.Response, startTime time.Time) {
+ method := methodFromRequest(request)
+ successfulEventsHandlingTime.WithLabelValues(method).Observe(time.Since(startTime).Seconds())
+}
+
+func reportRequestFailed(request etcdserverpb.Request, err error) {
+ method := methodFromRequest(request)
+ failedEvents.WithLabelValues(method, strconv.Itoa(codeFromError(err))).Inc()
+}
+
+func methodFromRequest(request etcdserverpb.Request) string {
+ if request.Method == "GET" && request.Quorum {
+ return "QGET"
+ }
+ return request.Method
+}
+
+func codeFromError(err error) int {
+ if err == nil {
+ return http.StatusInternalServerError
+ }
+ switch e := err.(type) {
+ case *etcdErr.Error:
+ return (*etcdErr.Error)(e).StatusCode()
+ case *httptypes.HTTPError:
+ return (*httptypes.HTTPError)(e).Code
+ default:
+ return http.StatusInternalServerError
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/testdata/ca.pem b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/testdata/ca.pem
new file mode 100644
index 00000000..60cbee3b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/testdata/ca.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDEjCCAfqgAwIBAgIIYpX+8HgWGfkwDQYJKoZIhvcNAQELBQAwFTETMBEGA1UE
+AxMKZXRjZCB0ZXN0czAeFw0xNTExMjQwMzA1MDBaFw0yMDExMjIwMzA1MDBaMBUx
+EzARBgNVBAMTCmV0Y2QgdGVzdHMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
+AoIBAQDa9PkwEwiBD8mB+VIKz5r5gRHnNF4Icj6T6R/RsdatecQe6vU0EU4FXtKZ
+drWnCGlATyrQooqHpb+rDc7CUt3mXrIxrNkcGTMaesF7P0GWxVkyOGSjJMxGBv3e
+bAZknBe4eLMi68L1aT/uYmxcp/B3L2mfdFtc1Gd6mYJpNm1PgilRyIrO0mY5ysIX
+4WHCa3yudAv8HrFbQcw7l7OyKA6uSWg6h07lE3d5jw5YOly+hz0iaRtzhb4tJrYD
+Lm1tehb0nnoLuW6yYblRSoyBVDT50MFVlyvW40Po5WkOXw/wnsnyxWRR4yqU23wq
+quQU0HXJEBLFnT+KbLOQ0EAE35vXAgMBAAGjZjBkMA4GA1UdDwEB/wQEAwIBBjAS
+BgNVHRMBAf8ECDAGAQH/AgECMB0GA1UdDgQWBBSbUCGB95ochDrbEZlzGGYuA7xu
+xjAfBgNVHSMEGDAWgBSbUCGB95ochDrbEZlzGGYuA7xuxjANBgkqhkiG9w0BAQsF
+AAOCAQEAardO/SGCu7Snz3YRBUinzpZEUFTFend+FJtBkxBXCao1RvTXg8PBMkza
+LUsaR4mLsGoXLIbNCoIinvVG0QULYCZe11N3l1L0G2g5uhEM4MfJ2rwrMD0o17i+
+nwNRRE3tfKAlWhYQg+4ye36kQVxASPniHjdQgjKYUFTNXdyG6DzuAclaVte9iVw6
+cWl61fB2CZya3+uMtih8t/Kgl2KbMO2PvNByfnDjKmW+v58qHbXyoJZqnpvDn14+
+p2Ox+AvvxYiEiUIvFdWy101QB7NJMCtdwq6oG6OvIOgXzLgitTFSq4kfWDfupQjW
+iFoQ+vWmYhK5ld0nBaiz+JmHuemK7A==
+-----END CERTIFICATE-----
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/testdata/otheruser.pem b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/testdata/otheruser.pem
new file mode 100644
index 00000000..d0c74eb9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/testdata/otheruser.pem
@@ -0,0 +1,20 @@
+-----BEGIN CERTIFICATE-----
+MIIDOTCCAiGgAwIBAgIINYpsso1f3SswDQYJKoZIhvcNAQELBQAwFTETMBEGA1UE
+AxMKZXRjZCB0ZXN0czAeFw0xNTExMjQwMzA4MDBaFw0xNjExMjMwMzA4MDBaMBQx
+EjAQBgNVBAMTCW90aGVydXNlcjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
+ggEBAPOAUa5GblwIjHTEnox2c/Am9jV1TMvzBuVXxnp2UnNHMNwstAooFrEs/Z+d
+ft5AOsooP6zVuM3eBQa4i9huJbVNDfPU2H94yA89jYfJYUgo7C838V6NjGsCCptQ
+WzkKPNlDbT9xA/7XpIUJ2WltuYDRrjWq8pXQONqTjcg5n4l0JO8xdHJHRUkFQ76F
+1npXeLndgGaP11lqzpYlglEGi5URhzAT1xxQ0hLSe8WNmiCxxkq++C8Gx4sPg9mX
+M94aoJDzZSnoaqDxckbP/7Q0ZKe/fVdCFkd5+jqT4Mt7hwmz9jTCHcVnAz4EKI+t
+rbWgbCfMK6013GotXz7InStVe+MCAwEAAaOBjTCBijAOBgNVHQ8BAf8EBAMCBaAw
+HQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwHQYD
+VR0OBBYEFFwMmf+pnaejmri6y1T+lfU+MBq/MB8GA1UdIwQYMBaAFJtQIYH3mhyE
+OtsRmXMYZi4DvG7GMAsGA1UdEQQEMAKCADANBgkqhkiG9w0BAQsFAAOCAQEACOn6
+mec29MTMGPt/EPOmSyhvTKSwH+5YWjCbyUFeoB8puxrJlIphK4mvT+sXp2wzno89
+FVCliO/rJurdErKvyOjlK1QrVGPYIt7Wz9ssAfvlwCyBM8PqgEG8dJN9aAkf2h4r
+Ye+hBh1y6Nnataf7lxe9mqAOvD/7wVIgzjCnMD1q5QSY2Mln3HwVQXtbZFbY363Z
+X9Fk3PUpjJSX9jbEz9kIlT8AJAdxl6GB8Z9B8PrA8qf4Bhk15ICRHxb67EhDrGWV
+8q7ArU2XBqs/+GWpUIMoGKNZv+K+/SksZK1KnzaUvApUCJzt+ac+p8HOgMdvDRgr
+GfVVJqcZgyEmeczy0A==
+-----END CERTIFICATE-----
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v2http/testdata/user.pem b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/testdata/user.pem
new file mode 100644
index 00000000..0fc21086
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v2http/testdata/user.pem
@@ -0,0 +1,20 @@
+-----BEGIN CERTIFICATE-----
+MIIDNDCCAhygAwIBAgIIcQ0DAfgevocwDQYJKoZIhvcNAQELBQAwFTETMBEGA1UE
+AxMKZXRjZCB0ZXN0czAeFw0xNTExMjQwMzA4MDBaFw0xNjExMjMwMzA4MDBaMA8x
+DTALBgNVBAMTBHVzZXIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQD0
++3Lm1SmUJJLufaFTYz+e5qyQEshNRyeAhXIeZ1aw+yBjslXGZQ3/uGOwnOnGqUeA
+Nidc9ty4NsK6RVppHlezUrBnpl4hws8vHWFKZpU2R6kKL8EYLmg+iVqEBj7XqfAp
+8bJqqZI3KOqLXpRH55mA69KP7VEK9ngTVR/tERSrUPT8jcjwbvhSOqD8Qk07BUDR
+6RpDr94Mnaf+fMGG36Sh7iUl+i4Oh6FFar+7+b0+5Bhs2/6uVsK4A1Z3jqqfSQH8
+q8Wf5h9Ka4aqGSw4ia5G3Uw7Jsl2aDgpJ7uwJo1k8SclbMYnYdhZuo+U+esY/Fai
+YdbjG+AroZ+y9TB8bMlHAgMBAAGjgY0wgYowDgYDVR0PAQH/BAQDAgWgMB0GA1Ud
+JQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMB0GA1UdDgQW
+BBRuTt0lJIVKYaz76aSxl/MQOLRwfDAfBgNVHSMEGDAWgBSbUCGB95ochDrbEZlz
+GGYuA7xuxjALBgNVHREEBDACggAwDQYJKoZIhvcNAQELBQADggEBABLRWZm+Lgjs
+c5qDXbgOJW2pR630syY8ixR9c6HvzPVJim8mFioMX+xrlbOC6BmOUlOb9j83bTKn
+aOg/0xlpxNbd8QYzgRxZmHZLULPdiNeeRvIzsrzrH88+inrmZhRXRVcHjdO6CG6t
+hCdDdRiNU6GkF7dPna0xNcEOKe2wUfzd1ZtKOqzi1w+fKjSeMplZomeWgP4WRvkh
+JJ/0ujlMMckgyTxRh8EEaJ35OnpXX7EdipoWhOMmiUnlPqye2icC8Y+CMdZsrod6
+nkoEQnXDCLf/Iv0qj7B9iKbxn7t3QDVxY4UILUReDuD8yrGULlGOl//aY/T3pkZ6
+R5trduZhI3o=
+-----END CERTIFICATE-----
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3client/doc.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3client/doc.go
new file mode 100644
index 00000000..310715f5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3client/doc.go
@@ -0,0 +1,45 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 v3client provides clientv3 interfaces from an etcdserver.
+//
+// Use v3client by creating an EtcdServer instance, then wrapping it with v3client.New:
+//
+// import (
+// "context"
+//
+// "github.com/coreos/etcd/embed"
+// "github.com/coreos/etcd/etcdserver/api/v3client"
+// )
+//
+// ...
+//
+// // create an embedded EtcdServer from the default configuration
+// cfg := embed.NewConfig()
+// cfg.Dir = "default.etcd"
+// e, err := embed.StartEtcd(cfg)
+// if err != nil {
+// // handle error!
+// }
+//
+// // wrap the EtcdServer with v3client
+// cli := v3client.New(e.Server)
+//
+// // use like an ordinary clientv3
+// resp, err := cli.Put(context.TODO(), "some-key", "it works!")
+// if err != nil {
+// // handle error!
+// }
+//
+package v3client
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3client/v3client.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3client/v3client.go
new file mode 100644
index 00000000..cc4147d2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3client/v3client.go
@@ -0,0 +1,67 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 v3client
+
+import (
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc"
+ "github.com/coreos/etcd/proxy/grpcproxy/adapter"
+
+ "golang.org/x/net/context"
+)
+
+// New creates a clientv3 client that wraps an in-process EtcdServer. Instead
+// of making gRPC calls through sockets, the client makes direct function calls
+// to the etcd server through its api/v3rpc function interfaces.
+func New(s *etcdserver.EtcdServer) *clientv3.Client {
+ c := clientv3.NewCtxClient(context.Background())
+
+ kvc := adapter.KvServerToKvClient(v3rpc.NewQuotaKVServer(s))
+ c.KV = clientv3.NewKVFromKVClient(kvc)
+
+ lc := adapter.LeaseServerToLeaseClient(v3rpc.NewQuotaLeaseServer(s))
+ c.Lease = clientv3.NewLeaseFromLeaseClient(lc, time.Second)
+
+ wc := adapter.WatchServerToWatchClient(v3rpc.NewWatchServer(s))
+ c.Watcher = &watchWrapper{clientv3.NewWatchFromWatchClient(wc)}
+
+ mc := adapter.MaintenanceServerToMaintenanceClient(v3rpc.NewMaintenanceServer(s))
+ c.Maintenance = clientv3.NewMaintenanceFromMaintenanceClient(mc)
+
+ clc := adapter.ClusterServerToClusterClient(v3rpc.NewClusterServer(s))
+ c.Cluster = clientv3.NewClusterFromClusterClient(clc)
+
+ // TODO: implement clientv3.Auth interface?
+
+ return c
+}
+
+// BlankContext implements Stringer on a context so the ctx string doesn't
+// depend on the context's WithValue data, which tends to be unsynchronized
+// (e.g., x/net/trace), causing ctx.String() to throw data races.
+type blankContext struct{ context.Context }
+
+func (*blankContext) String() string { return "(blankCtx)" }
+
+// watchWrapper wraps clientv3 watch calls to blank out the context
+// to avoid races on trace data.
+type watchWrapper struct{ clientv3.Watcher }
+
+func (ww *watchWrapper) Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan {
+ return ww.Watcher.Watch(&blankContext{ctx}, key, opts...)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3election/doc.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3election/doc.go
new file mode 100644
index 00000000..d6fefd74
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3election/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 v3election provides a v3 election service from an etcdserver.
+package v3election
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3election/election.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3election/election.go
new file mode 100644
index 00000000..f9061c07
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3election/election.go
@@ -0,0 +1,123 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 v3election
+
+import (
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/concurrency"
+ epb "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb"
+)
+
+type electionServer struct {
+ c *clientv3.Client
+}
+
+func NewElectionServer(c *clientv3.Client) epb.ElectionServer {
+ return &electionServer{c}
+}
+
+func (es *electionServer) Campaign(ctx context.Context, req *epb.CampaignRequest) (*epb.CampaignResponse, error) {
+ s, err := es.session(ctx, req.Lease)
+ if err != nil {
+ return nil, err
+ }
+ e := concurrency.NewElection(s, string(req.Name))
+ if err = e.Campaign(ctx, string(req.Value)); err != nil {
+ return nil, err
+ }
+ return &epb.CampaignResponse{
+ Header: e.Header(),
+ Leader: &epb.LeaderKey{
+ Name: req.Name,
+ Key: []byte(e.Key()),
+ Rev: e.Rev(),
+ Lease: int64(s.Lease()),
+ },
+ }, nil
+}
+
+func (es *electionServer) Proclaim(ctx context.Context, req *epb.ProclaimRequest) (*epb.ProclaimResponse, error) {
+ s, err := es.session(ctx, req.Leader.Lease)
+ if err != nil {
+ return nil, err
+ }
+ e := concurrency.ResumeElection(s, string(req.Leader.Name), string(req.Leader.Key), req.Leader.Rev)
+ if err := e.Proclaim(ctx, string(req.Value)); err != nil {
+ return nil, err
+ }
+ return &epb.ProclaimResponse{Header: e.Header()}, nil
+}
+
+func (es *electionServer) Observe(req *epb.LeaderRequest, stream epb.Election_ObserveServer) error {
+ s, err := es.session(stream.Context(), -1)
+ if err != nil {
+ return err
+ }
+ e := concurrency.NewElection(s, string(req.Name))
+ ch := e.Observe(stream.Context())
+ for stream.Context().Err() == nil {
+ select {
+ case <-stream.Context().Done():
+ case resp, ok := <-ch:
+ if !ok {
+ return nil
+ }
+ lresp := &epb.LeaderResponse{Header: resp.Header, Kv: resp.Kvs[0]}
+ if err := stream.Send(lresp); err != nil {
+ return err
+ }
+ }
+ }
+ return stream.Context().Err()
+}
+
+func (es *electionServer) Leader(ctx context.Context, req *epb.LeaderRequest) (*epb.LeaderResponse, error) {
+ s, err := es.session(ctx, -1)
+ if err != nil {
+ return nil, err
+ }
+ l, lerr := concurrency.NewElection(s, string(req.Name)).Leader(ctx)
+ if lerr != nil {
+ return nil, lerr
+ }
+ return &epb.LeaderResponse{Header: l.Header, Kv: l.Kvs[0]}, nil
+}
+
+func (es *electionServer) Resign(ctx context.Context, req *epb.ResignRequest) (*epb.ResignResponse, error) {
+ s, err := es.session(ctx, req.Leader.Lease)
+ if err != nil {
+ return nil, err
+ }
+ e := concurrency.ResumeElection(s, string(req.Leader.Name), string(req.Leader.Key), req.Leader.Rev)
+ if err := e.Resign(ctx); err != nil {
+ return nil, err
+ }
+ return &epb.ResignResponse{Header: e.Header()}, nil
+}
+
+func (es *electionServer) session(ctx context.Context, lease int64) (*concurrency.Session, error) {
+ s, err := concurrency.NewSession(
+ es.c,
+ concurrency.WithLease(clientv3.LeaseID(lease)),
+ concurrency.WithContext(ctx),
+ )
+ if err != nil {
+ return nil, err
+ }
+ s.Orphan()
+ return s, nil
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb/gw/v3election.pb.gw.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb/gw/v3election.pb.gw.go
new file mode 100644
index 00000000..eb4b68c0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb/gw/v3election.pb.gw.go
@@ -0,0 +1,299 @@
+// Code generated by protoc-gen-grpc-gateway
+// source: etcdserver/api/v3election/v3electionpb/v3election.proto
+// DO NOT EDIT!
+
+/*
+Package v3electionpb is a reverse proxy.
+
+It translates gRPC into RESTful JSON APIs.
+*/
+package gw
+
+import (
+ "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb"
+ "io"
+ "net/http"
+
+ "github.com/golang/protobuf/proto"
+ "github.com/grpc-ecosystem/grpc-gateway/runtime"
+ "github.com/grpc-ecosystem/grpc-gateway/utilities"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/grpclog"
+)
+
+var _ codes.Code
+var _ io.Reader
+var _ = runtime.String
+var _ = utilities.NewDoubleArray
+
+func request_Election_Campaign_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq v3electionpb.CampaignRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Campaign(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Election_Proclaim_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq v3electionpb.ProclaimRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Proclaim(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Election_Leader_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq v3electionpb.LeaderRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Leader(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Election_Observe_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (v3electionpb.Election_ObserveClient, runtime.ServerMetadata, error) {
+ var protoReq v3electionpb.LeaderRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ stream, err := client.Observe(ctx, &protoReq)
+ if err != nil {
+ return nil, metadata, err
+ }
+ header, err := stream.Header()
+ if err != nil {
+ return nil, metadata, err
+ }
+ metadata.HeaderMD = header
+ return stream, metadata, nil
+
+}
+
+func request_Election_Resign_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq v3electionpb.ResignRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Resign(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+// RegisterElectionHandlerFromEndpoint is same as RegisterElectionHandler but
+// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
+func RegisterElectionHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
+ conn, err := grpc.Dial(endpoint, opts...)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ if err != nil {
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ return
+ }
+ go func() {
+ <-ctx.Done()
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ }()
+ }()
+
+ return RegisterElectionHandler(ctx, mux, conn)
+}
+
+// RegisterElectionHandler registers the http handlers for service Election to "mux".
+// The handlers forward requests to the grpc endpoint over "conn".
+func RegisterElectionHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
+ client := v3electionpb.NewElectionClient(conn)
+
+ mux.Handle("POST", pattern_Election_Campaign_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Election_Campaign_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Election_Campaign_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Election_Proclaim_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Election_Proclaim_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Election_Proclaim_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Election_Leader_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Election_Leader_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Election_Leader_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Election_Observe_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Election_Observe_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Election_Observe_0(ctx, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Election_Resign_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Election_Resign_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Election_Resign_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ return nil
+}
+
+var (
+ pattern_Election_Campaign_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "election", "campaign"}, ""))
+
+ pattern_Election_Proclaim_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "election", "proclaim"}, ""))
+
+ pattern_Election_Leader_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "election", "leader"}, ""))
+
+ pattern_Election_Observe_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "election", "observe"}, ""))
+
+ pattern_Election_Resign_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "election", "resign"}, ""))
+)
+
+var (
+ forward_Election_Campaign_0 = runtime.ForwardResponseMessage
+
+ forward_Election_Proclaim_0 = runtime.ForwardResponseMessage
+
+ forward_Election_Leader_0 = runtime.ForwardResponseMessage
+
+ forward_Election_Observe_0 = runtime.ForwardResponseStream
+
+ forward_Election_Resign_0 = runtime.ForwardResponseMessage
+)
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb/v3election.pb.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb/v3election.pb.go
new file mode 100644
index 00000000..2600756e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb/v3election.pb.go
@@ -0,0 +1,2033 @@
+// Code generated by protoc-gen-gogo.
+// source: v3election.proto
+// DO NOT EDIT!
+
+/*
+ Package v3electionpb is a generated protocol buffer package.
+
+ It is generated from these files:
+ v3election.proto
+
+ It has these top-level messages:
+ CampaignRequest
+ CampaignResponse
+ LeaderKey
+ LeaderRequest
+ LeaderResponse
+ ResignRequest
+ ResignResponse
+ ProclaimRequest
+ ProclaimResponse
+*/
+package v3electionpb
+
+import (
+ "fmt"
+
+ proto "github.com/golang/protobuf/proto"
+
+ math "math"
+
+ etcdserverpb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+
+ mvccpb "github.com/coreos/etcd/mvcc/mvccpb"
+
+ context "golang.org/x/net/context"
+
+ grpc "google.golang.org/grpc"
+
+ io "io"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+type CampaignRequest struct {
+ // name is the election's identifier for the campaign.
+ Name []byte `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ // lease is the ID of the lease attached to leadership of the election. If the
+ // lease expires or is revoked before resigning leadership, then the
+ // leadership is transferred to the next campaigner, if any.
+ Lease int64 `protobuf:"varint,2,opt,name=lease,proto3" json:"lease,omitempty"`
+ // value is the initial proclaimed value set when the campaigner wins the
+ // election.
+ Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
+}
+
+func (m *CampaignRequest) Reset() { *m = CampaignRequest{} }
+func (m *CampaignRequest) String() string { return proto.CompactTextString(m) }
+func (*CampaignRequest) ProtoMessage() {}
+func (*CampaignRequest) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{0} }
+
+type CampaignResponse struct {
+ Header *etcdserverpb.ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // leader describes the resources used for holding leadereship of the election.
+ Leader *LeaderKey `protobuf:"bytes,2,opt,name=leader" json:"leader,omitempty"`
+}
+
+func (m *CampaignResponse) Reset() { *m = CampaignResponse{} }
+func (m *CampaignResponse) String() string { return proto.CompactTextString(m) }
+func (*CampaignResponse) ProtoMessage() {}
+func (*CampaignResponse) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{1} }
+
+func (m *CampaignResponse) GetHeader() *etcdserverpb.ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func (m *CampaignResponse) GetLeader() *LeaderKey {
+ if m != nil {
+ return m.Leader
+ }
+ return nil
+}
+
+type LeaderKey struct {
+ // name is the election identifier that correponds to the leadership key.
+ Name []byte `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ // key is an opaque key representing the ownership of the election. If the key
+ // is deleted, then leadership is lost.
+ Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
+ // rev is the creation revision of the key. It can be used to test for ownership
+ // of an election during transactions by testing the key's creation revision
+ // matches rev.
+ Rev int64 `protobuf:"varint,3,opt,name=rev,proto3" json:"rev,omitempty"`
+ // lease is the lease ID of the election leader.
+ Lease int64 `protobuf:"varint,4,opt,name=lease,proto3" json:"lease,omitempty"`
+}
+
+func (m *LeaderKey) Reset() { *m = LeaderKey{} }
+func (m *LeaderKey) String() string { return proto.CompactTextString(m) }
+func (*LeaderKey) ProtoMessage() {}
+func (*LeaderKey) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{2} }
+
+type LeaderRequest struct {
+ // name is the election identifier for the leadership information.
+ Name []byte `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+}
+
+func (m *LeaderRequest) Reset() { *m = LeaderRequest{} }
+func (m *LeaderRequest) String() string { return proto.CompactTextString(m) }
+func (*LeaderRequest) ProtoMessage() {}
+func (*LeaderRequest) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{3} }
+
+type LeaderResponse struct {
+ Header *etcdserverpb.ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // kv is the key-value pair representing the latest leader update.
+ Kv *mvccpb.KeyValue `protobuf:"bytes,2,opt,name=kv" json:"kv,omitempty"`
+}
+
+func (m *LeaderResponse) Reset() { *m = LeaderResponse{} }
+func (m *LeaderResponse) String() string { return proto.CompactTextString(m) }
+func (*LeaderResponse) ProtoMessage() {}
+func (*LeaderResponse) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{4} }
+
+func (m *LeaderResponse) GetHeader() *etcdserverpb.ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func (m *LeaderResponse) GetKv() *mvccpb.KeyValue {
+ if m != nil {
+ return m.Kv
+ }
+ return nil
+}
+
+type ResignRequest struct {
+ // leader is the leadership to relinquish by resignation.
+ Leader *LeaderKey `protobuf:"bytes,1,opt,name=leader" json:"leader,omitempty"`
+}
+
+func (m *ResignRequest) Reset() { *m = ResignRequest{} }
+func (m *ResignRequest) String() string { return proto.CompactTextString(m) }
+func (*ResignRequest) ProtoMessage() {}
+func (*ResignRequest) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{5} }
+
+func (m *ResignRequest) GetLeader() *LeaderKey {
+ if m != nil {
+ return m.Leader
+ }
+ return nil
+}
+
+type ResignResponse struct {
+ Header *etcdserverpb.ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *ResignResponse) Reset() { *m = ResignResponse{} }
+func (m *ResignResponse) String() string { return proto.CompactTextString(m) }
+func (*ResignResponse) ProtoMessage() {}
+func (*ResignResponse) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{6} }
+
+func (m *ResignResponse) GetHeader() *etcdserverpb.ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type ProclaimRequest struct {
+ // leader is the leadership hold on the election.
+ Leader *LeaderKey `protobuf:"bytes,1,opt,name=leader" json:"leader,omitempty"`
+ // value is an update meant to overwrite the leader's current value.
+ Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
+}
+
+func (m *ProclaimRequest) Reset() { *m = ProclaimRequest{} }
+func (m *ProclaimRequest) String() string { return proto.CompactTextString(m) }
+func (*ProclaimRequest) ProtoMessage() {}
+func (*ProclaimRequest) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{7} }
+
+func (m *ProclaimRequest) GetLeader() *LeaderKey {
+ if m != nil {
+ return m.Leader
+ }
+ return nil
+}
+
+type ProclaimResponse struct {
+ Header *etcdserverpb.ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *ProclaimResponse) Reset() { *m = ProclaimResponse{} }
+func (m *ProclaimResponse) String() string { return proto.CompactTextString(m) }
+func (*ProclaimResponse) ProtoMessage() {}
+func (*ProclaimResponse) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{8} }
+
+func (m *ProclaimResponse) GetHeader() *etcdserverpb.ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func init() {
+ proto.RegisterType((*CampaignRequest)(nil), "v3electionpb.CampaignRequest")
+ proto.RegisterType((*CampaignResponse)(nil), "v3electionpb.CampaignResponse")
+ proto.RegisterType((*LeaderKey)(nil), "v3electionpb.LeaderKey")
+ proto.RegisterType((*LeaderRequest)(nil), "v3electionpb.LeaderRequest")
+ proto.RegisterType((*LeaderResponse)(nil), "v3electionpb.LeaderResponse")
+ proto.RegisterType((*ResignRequest)(nil), "v3electionpb.ResignRequest")
+ proto.RegisterType((*ResignResponse)(nil), "v3electionpb.ResignResponse")
+ proto.RegisterType((*ProclaimRequest)(nil), "v3electionpb.ProclaimRequest")
+ proto.RegisterType((*ProclaimResponse)(nil), "v3electionpb.ProclaimResponse")
+}
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ context.Context
+var _ grpc.ClientConn
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+const _ = grpc.SupportPackageIsVersion4
+
+// Client API for Election service
+
+type ElectionClient interface {
+ // Campaign waits to acquire leadership in an election, returning a LeaderKey
+ // representing the leadership if successful. The LeaderKey can then be used
+ // to issue new values on the election, transactionally guard API requests on
+ // leadership still being held, and resign from the election.
+ Campaign(ctx context.Context, in *CampaignRequest, opts ...grpc.CallOption) (*CampaignResponse, error)
+ // Proclaim updates the leader's posted value with a new value.
+ Proclaim(ctx context.Context, in *ProclaimRequest, opts ...grpc.CallOption) (*ProclaimResponse, error)
+ // Leader returns the current election proclamation, if any.
+ Leader(ctx context.Context, in *LeaderRequest, opts ...grpc.CallOption) (*LeaderResponse, error)
+ // Observe streams election proclamations in-order as made by the election's
+ // elected leaders.
+ Observe(ctx context.Context, in *LeaderRequest, opts ...grpc.CallOption) (Election_ObserveClient, error)
+ // Resign releases election leadership so other campaigners may acquire
+ // leadership on the election.
+ Resign(ctx context.Context, in *ResignRequest, opts ...grpc.CallOption) (*ResignResponse, error)
+}
+
+type electionClient struct {
+ cc *grpc.ClientConn
+}
+
+func NewElectionClient(cc *grpc.ClientConn) ElectionClient {
+ return &electionClient{cc}
+}
+
+func (c *electionClient) Campaign(ctx context.Context, in *CampaignRequest, opts ...grpc.CallOption) (*CampaignResponse, error) {
+ out := new(CampaignResponse)
+ err := grpc.Invoke(ctx, "/v3electionpb.Election/Campaign", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *electionClient) Proclaim(ctx context.Context, in *ProclaimRequest, opts ...grpc.CallOption) (*ProclaimResponse, error) {
+ out := new(ProclaimResponse)
+ err := grpc.Invoke(ctx, "/v3electionpb.Election/Proclaim", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *electionClient) Leader(ctx context.Context, in *LeaderRequest, opts ...grpc.CallOption) (*LeaderResponse, error) {
+ out := new(LeaderResponse)
+ err := grpc.Invoke(ctx, "/v3electionpb.Election/Leader", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *electionClient) Observe(ctx context.Context, in *LeaderRequest, opts ...grpc.CallOption) (Election_ObserveClient, error) {
+ stream, err := grpc.NewClientStream(ctx, &_Election_serviceDesc.Streams[0], c.cc, "/v3electionpb.Election/Observe", opts...)
+ if err != nil {
+ return nil, err
+ }
+ x := &electionObserveClient{stream}
+ if err := x.ClientStream.SendMsg(in); err != nil {
+ return nil, err
+ }
+ if err := x.ClientStream.CloseSend(); err != nil {
+ return nil, err
+ }
+ return x, nil
+}
+
+type Election_ObserveClient interface {
+ Recv() (*LeaderResponse, error)
+ grpc.ClientStream
+}
+
+type electionObserveClient struct {
+ grpc.ClientStream
+}
+
+func (x *electionObserveClient) Recv() (*LeaderResponse, error) {
+ m := new(LeaderResponse)
+ if err := x.ClientStream.RecvMsg(m); err != nil {
+ return nil, err
+ }
+ return m, nil
+}
+
+func (c *electionClient) Resign(ctx context.Context, in *ResignRequest, opts ...grpc.CallOption) (*ResignResponse, error) {
+ out := new(ResignResponse)
+ err := grpc.Invoke(ctx, "/v3electionpb.Election/Resign", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// Server API for Election service
+
+type ElectionServer interface {
+ // Campaign waits to acquire leadership in an election, returning a LeaderKey
+ // representing the leadership if successful. The LeaderKey can then be used
+ // to issue new values on the election, transactionally guard API requests on
+ // leadership still being held, and resign from the election.
+ Campaign(context.Context, *CampaignRequest) (*CampaignResponse, error)
+ // Proclaim updates the leader's posted value with a new value.
+ Proclaim(context.Context, *ProclaimRequest) (*ProclaimResponse, error)
+ // Leader returns the current election proclamation, if any.
+ Leader(context.Context, *LeaderRequest) (*LeaderResponse, error)
+ // Observe streams election proclamations in-order as made by the election's
+ // elected leaders.
+ Observe(*LeaderRequest, Election_ObserveServer) error
+ // Resign releases election leadership so other campaigners may acquire
+ // leadership on the election.
+ Resign(context.Context, *ResignRequest) (*ResignResponse, error)
+}
+
+func RegisterElectionServer(s *grpc.Server, srv ElectionServer) {
+ s.RegisterService(&_Election_serviceDesc, srv)
+}
+
+func _Election_Campaign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(CampaignRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(ElectionServer).Campaign(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/v3electionpb.Election/Campaign",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(ElectionServer).Campaign(ctx, req.(*CampaignRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Election_Proclaim_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(ProclaimRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(ElectionServer).Proclaim(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/v3electionpb.Election/Proclaim",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(ElectionServer).Proclaim(ctx, req.(*ProclaimRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Election_Leader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(LeaderRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(ElectionServer).Leader(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/v3electionpb.Election/Leader",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(ElectionServer).Leader(ctx, req.(*LeaderRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Election_Observe_Handler(srv interface{}, stream grpc.ServerStream) error {
+ m := new(LeaderRequest)
+ if err := stream.RecvMsg(m); err != nil {
+ return err
+ }
+ return srv.(ElectionServer).Observe(m, &electionObserveServer{stream})
+}
+
+type Election_ObserveServer interface {
+ Send(*LeaderResponse) error
+ grpc.ServerStream
+}
+
+type electionObserveServer struct {
+ grpc.ServerStream
+}
+
+func (x *electionObserveServer) Send(m *LeaderResponse) error {
+ return x.ServerStream.SendMsg(m)
+}
+
+func _Election_Resign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(ResignRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(ElectionServer).Resign(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/v3electionpb.Election/Resign",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(ElectionServer).Resign(ctx, req.(*ResignRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+var _Election_serviceDesc = grpc.ServiceDesc{
+ ServiceName: "v3electionpb.Election",
+ HandlerType: (*ElectionServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "Campaign",
+ Handler: _Election_Campaign_Handler,
+ },
+ {
+ MethodName: "Proclaim",
+ Handler: _Election_Proclaim_Handler,
+ },
+ {
+ MethodName: "Leader",
+ Handler: _Election_Leader_Handler,
+ },
+ {
+ MethodName: "Resign",
+ Handler: _Election_Resign_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{
+ {
+ StreamName: "Observe",
+ Handler: _Election_Observe_Handler,
+ ServerStreams: true,
+ },
+ },
+ Metadata: "v3election.proto",
+}
+
+func (m *CampaignRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *CampaignRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ if m.Lease != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(m.Lease))
+ }
+ if len(m.Value) > 0 {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(len(m.Value)))
+ i += copy(dAtA[i:], m.Value)
+ }
+ return i, nil
+}
+
+func (m *CampaignResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *CampaignResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(m.Header.Size()))
+ n1, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n1
+ }
+ if m.Leader != nil {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(m.Leader.Size()))
+ n2, err := m.Leader.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n2
+ }
+ return i, nil
+}
+
+func (m *LeaderKey) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LeaderKey) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ if len(m.Key) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(len(m.Key)))
+ i += copy(dAtA[i:], m.Key)
+ }
+ if m.Rev != 0 {
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(m.Rev))
+ }
+ if m.Lease != 0 {
+ dAtA[i] = 0x20
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(m.Lease))
+ }
+ return i, nil
+}
+
+func (m *LeaderRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LeaderRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ return i, nil
+}
+
+func (m *LeaderResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LeaderResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(m.Header.Size()))
+ n3, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n3
+ }
+ if m.Kv != nil {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(m.Kv.Size()))
+ n4, err := m.Kv.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n4
+ }
+ return i, nil
+}
+
+func (m *ResignRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *ResignRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Leader != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(m.Leader.Size()))
+ n5, err := m.Leader.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n5
+ }
+ return i, nil
+}
+
+func (m *ResignResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *ResignResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(m.Header.Size()))
+ n6, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n6
+ }
+ return i, nil
+}
+
+func (m *ProclaimRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *ProclaimRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Leader != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(m.Leader.Size()))
+ n7, err := m.Leader.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n7
+ }
+ if len(m.Value) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(len(m.Value)))
+ i += copy(dAtA[i:], m.Value)
+ }
+ return i, nil
+}
+
+func (m *ProclaimResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *ProclaimResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintV3Election(dAtA, i, uint64(m.Header.Size()))
+ n8, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n8
+ }
+ return i, nil
+}
+
+func encodeFixed64V3Election(dAtA []byte, offset int, v uint64) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ dAtA[offset+4] = uint8(v >> 32)
+ dAtA[offset+5] = uint8(v >> 40)
+ dAtA[offset+6] = uint8(v >> 48)
+ dAtA[offset+7] = uint8(v >> 56)
+ return offset + 8
+}
+func encodeFixed32V3Election(dAtA []byte, offset int, v uint32) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ return offset + 4
+}
+func encodeVarintV3Election(dAtA []byte, offset int, v uint64) int {
+ for v >= 1<<7 {
+ dAtA[offset] = uint8(v&0x7f | 0x80)
+ v >>= 7
+ offset++
+ }
+ dAtA[offset] = uint8(v)
+ return offset + 1
+}
+func (m *CampaignRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovV3Election(uint64(l))
+ }
+ if m.Lease != 0 {
+ n += 1 + sovV3Election(uint64(m.Lease))
+ }
+ l = len(m.Value)
+ if l > 0 {
+ n += 1 + l + sovV3Election(uint64(l))
+ }
+ return n
+}
+
+func (m *CampaignResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovV3Election(uint64(l))
+ }
+ if m.Leader != nil {
+ l = m.Leader.Size()
+ n += 1 + l + sovV3Election(uint64(l))
+ }
+ return n
+}
+
+func (m *LeaderKey) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovV3Election(uint64(l))
+ }
+ l = len(m.Key)
+ if l > 0 {
+ n += 1 + l + sovV3Election(uint64(l))
+ }
+ if m.Rev != 0 {
+ n += 1 + sovV3Election(uint64(m.Rev))
+ }
+ if m.Lease != 0 {
+ n += 1 + sovV3Election(uint64(m.Lease))
+ }
+ return n
+}
+
+func (m *LeaderRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovV3Election(uint64(l))
+ }
+ return n
+}
+
+func (m *LeaderResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovV3Election(uint64(l))
+ }
+ if m.Kv != nil {
+ l = m.Kv.Size()
+ n += 1 + l + sovV3Election(uint64(l))
+ }
+ return n
+}
+
+func (m *ResignRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.Leader != nil {
+ l = m.Leader.Size()
+ n += 1 + l + sovV3Election(uint64(l))
+ }
+ return n
+}
+
+func (m *ResignResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovV3Election(uint64(l))
+ }
+ return n
+}
+
+func (m *ProclaimRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.Leader != nil {
+ l = m.Leader.Size()
+ n += 1 + l + sovV3Election(uint64(l))
+ }
+ l = len(m.Value)
+ if l > 0 {
+ n += 1 + l + sovV3Election(uint64(l))
+ }
+ return n
+}
+
+func (m *ProclaimResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovV3Election(uint64(l))
+ }
+ return n
+}
+
+func sovV3Election(x uint64) (n int) {
+ for {
+ n++
+ x >>= 7
+ if x == 0 {
+ break
+ }
+ }
+ return n
+}
+func sozV3Election(x uint64) (n int) {
+ return sovV3Election(uint64((x << 1) ^ uint64((int64(x) >> 63))))
+}
+func (m *CampaignRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: CampaignRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: CampaignRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...)
+ if m.Name == nil {
+ m.Name = []byte{}
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Lease", wireType)
+ }
+ m.Lease = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Lease |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...)
+ if m.Value == nil {
+ m.Value = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipV3Election(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *CampaignResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: CampaignResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: CampaignResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &etcdserverpb.ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Leader", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Leader == nil {
+ m.Leader = &LeaderKey{}
+ }
+ if err := m.Leader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipV3Election(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *LeaderKey) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LeaderKey: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LeaderKey: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...)
+ if m.Name == nil {
+ m.Name = []byte{}
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
+ if m.Key == nil {
+ m.Key = []byte{}
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Rev", wireType)
+ }
+ m.Rev = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Rev |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 4:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Lease", wireType)
+ }
+ m.Lease = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Lease |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipV3Election(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *LeaderRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LeaderRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...)
+ if m.Name == nil {
+ m.Name = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipV3Election(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *LeaderResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LeaderResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &etcdserverpb.ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Kv", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Kv == nil {
+ m.Kv = &mvccpb.KeyValue{}
+ }
+ if err := m.Kv.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipV3Election(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *ResignRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: ResignRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: ResignRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Leader", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Leader == nil {
+ m.Leader = &LeaderKey{}
+ }
+ if err := m.Leader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipV3Election(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *ResignResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: ResignResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: ResignResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &etcdserverpb.ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipV3Election(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *ProclaimRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: ProclaimRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: ProclaimRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Leader", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Leader == nil {
+ m.Leader = &LeaderKey{}
+ }
+ if err := m.Leader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...)
+ if m.Value == nil {
+ m.Value = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipV3Election(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *ProclaimResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: ProclaimResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: ProclaimResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &etcdserverpb.ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipV3Election(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthV3Election
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func skipV3Election(dAtA []byte) (n int, err error) {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ wireType := int(wire & 0x7)
+ switch wireType {
+ case 0:
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ iNdEx++
+ if dAtA[iNdEx-1] < 0x80 {
+ break
+ }
+ }
+ return iNdEx, nil
+ case 1:
+ iNdEx += 8
+ return iNdEx, nil
+ case 2:
+ var length int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ length |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ iNdEx += length
+ if length < 0 {
+ return 0, ErrInvalidLengthV3Election
+ }
+ return iNdEx, nil
+ case 3:
+ for {
+ var innerWire uint64
+ var start int = iNdEx
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowV3Election
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ innerWire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ innerWireType := int(innerWire & 0x7)
+ if innerWireType == 4 {
+ break
+ }
+ next, err := skipV3Election(dAtA[start:])
+ if err != nil {
+ return 0, err
+ }
+ iNdEx = start + next
+ }
+ return iNdEx, nil
+ case 4:
+ return iNdEx, nil
+ case 5:
+ iNdEx += 4
+ return iNdEx, nil
+ default:
+ return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
+ }
+ }
+ panic("unreachable")
+}
+
+var (
+ ErrInvalidLengthV3Election = fmt.Errorf("proto: negative length found during unmarshaling")
+ ErrIntOverflowV3Election = fmt.Errorf("proto: integer overflow")
+)
+
+func init() { proto.RegisterFile("v3election.proto", fileDescriptorV3Election) }
+
+var fileDescriptorV3Election = []byte{
+ // 540 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xc1, 0x6e, 0xd3, 0x40,
+ 0x10, 0x65, 0x9d, 0x10, 0xca, 0x90, 0xb6, 0x96, 0x55, 0x89, 0x34, 0xa4, 0x26, 0xda, 0x02, 0xaa,
+ 0x72, 0xf0, 0xa2, 0x86, 0x53, 0x4e, 0x08, 0x04, 0xaa, 0x54, 0x24, 0xc0, 0x07, 0x04, 0xc7, 0x8d,
+ 0x3b, 0x4a, 0xa2, 0x38, 0xde, 0xc5, 0x4e, 0x2d, 0xe5, 0xca, 0x2f, 0x70, 0xe1, 0x33, 0xf8, 0x0c,
+ 0x8e, 0x48, 0xfc, 0x00, 0x0a, 0x7c, 0x08, 0xda, 0x5d, 0x1b, 0x3b, 0x6e, 0x88, 0x50, 0x73, 0xb1,
+ 0xc6, 0x33, 0xcf, 0xf3, 0xe6, 0xbd, 0x9d, 0x35, 0xd8, 0x69, 0x1f, 0x43, 0x0c, 0xe6, 0x13, 0x11,
+ 0x79, 0x32, 0x16, 0x73, 0xe1, 0x34, 0x8b, 0x8c, 0x1c, 0xb6, 0x0f, 0x46, 0x62, 0x24, 0x74, 0x81,
+ 0xa9, 0xc8, 0x60, 0xda, 0x8f, 0x70, 0x1e, 0x5c, 0x30, 0xf5, 0x48, 0x30, 0x4e, 0x31, 0x2e, 0x85,
+ 0x72, 0xc8, 0x62, 0x19, 0x64, 0xb8, 0x43, 0x8d, 0x9b, 0xa5, 0x41, 0xa0, 0x1f, 0x72, 0xc8, 0xa6,
+ 0x69, 0x56, 0xea, 0x8c, 0x84, 0x18, 0x85, 0xc8, 0xb8, 0x9c, 0x30, 0x1e, 0x45, 0x62, 0xce, 0x15,
+ 0x63, 0x62, 0xaa, 0xf4, 0x2d, 0xec, 0x3f, 0xe7, 0x33, 0xc9, 0x27, 0xa3, 0xc8, 0xc7, 0x8f, 0x97,
+ 0x98, 0xcc, 0x1d, 0x07, 0xea, 0x11, 0x9f, 0x61, 0x8b, 0x74, 0xc9, 0x49, 0xd3, 0xd7, 0xb1, 0x73,
+ 0x00, 0x37, 0x43, 0xe4, 0x09, 0xb6, 0xac, 0x2e, 0x39, 0xa9, 0xf9, 0xe6, 0x45, 0x65, 0x53, 0x1e,
+ 0x5e, 0x62, 0xab, 0xa6, 0xa1, 0xe6, 0x85, 0x2e, 0xc0, 0x2e, 0x5a, 0x26, 0x52, 0x44, 0x09, 0x3a,
+ 0x4f, 0xa0, 0x31, 0x46, 0x7e, 0x81, 0xb1, 0xee, 0x7a, 0xe7, 0xb4, 0xe3, 0x95, 0x85, 0x78, 0x39,
+ 0xee, 0x4c, 0x63, 0xfc, 0x0c, 0xeb, 0x30, 0x68, 0x84, 0xe6, 0x2b, 0x4b, 0x7f, 0x75, 0xd7, 0x2b,
+ 0x5b, 0xe6, 0xbd, 0xd2, 0xb5, 0x73, 0x5c, 0xf8, 0x19, 0x8c, 0x7e, 0x80, 0xdb, 0x7f, 0x93, 0x6b,
+ 0x75, 0xd8, 0x50, 0x9b, 0xe2, 0x42, 0xb7, 0x6b, 0xfa, 0x2a, 0x54, 0x99, 0x18, 0x53, 0xad, 0xa0,
+ 0xe6, 0xab, 0xb0, 0xd0, 0x5a, 0x2f, 0x69, 0xa5, 0xc7, 0xb0, 0x6b, 0x5a, 0x6f, 0xb0, 0x89, 0x8e,
+ 0x61, 0x2f, 0x07, 0x6d, 0x25, 0xbc, 0x0b, 0xd6, 0x34, 0xcd, 0x44, 0xdb, 0x9e, 0x39, 0x51, 0xef,
+ 0x1c, 0x17, 0xef, 0x94, 0xc1, 0xbe, 0x35, 0x4d, 0xe9, 0x53, 0xd8, 0xf5, 0x31, 0x29, 0x9d, 0x5a,
+ 0xe1, 0x15, 0xf9, 0x3f, 0xaf, 0x5e, 0xc2, 0x5e, 0xde, 0x61, 0x9b, 0x59, 0xe9, 0x7b, 0xd8, 0x7f,
+ 0x13, 0x8b, 0x20, 0xe4, 0x93, 0xd9, 0x75, 0x67, 0x29, 0x16, 0xc9, 0x2a, 0x2f, 0xd2, 0x19, 0xd8,
+ 0x45, 0xe7, 0x6d, 0x66, 0x3c, 0xfd, 0x5a, 0x87, 0x9d, 0x17, 0xd9, 0x00, 0x8e, 0x84, 0x9d, 0x7c,
+ 0x3f, 0x9d, 0xa3, 0xd5, 0xc9, 0x2a, 0x57, 0xa1, 0xed, 0xfe, 0xab, 0x6c, 0x58, 0xe8, 0xc3, 0x4f,
+ 0x3f, 0x7e, 0x7f, 0xb6, 0xee, 0xd3, 0x36, 0x4b, 0xfb, 0x3c, 0x94, 0x63, 0xce, 0x72, 0x34, 0x0b,
+ 0x32, 0xec, 0x80, 0xf4, 0x14, 0x63, 0x2e, 0xa4, 0xca, 0x58, 0xb1, 0xae, 0xca, 0x58, 0xd5, 0xbf,
+ 0x89, 0x51, 0x66, 0x58, 0xc5, 0x38, 0x86, 0x86, 0x71, 0xd9, 0xb9, 0xb7, 0xce, 0xfb, 0x9c, 0xad,
+ 0xb3, 0xbe, 0x98, 0x71, 0x1d, 0x6b, 0xae, 0x23, 0xda, 0xba, 0xca, 0x65, 0xce, 0x4d, 0x31, 0x85,
+ 0x70, 0xeb, 0xf5, 0x50, 0xfb, 0xbf, 0x0d, 0xd5, 0x03, 0x4d, 0xe5, 0xd2, 0xc3, 0xab, 0x54, 0xc2,
+ 0x74, 0x1f, 0x90, 0xde, 0x63, 0xa2, 0x74, 0x99, 0xa5, 0xad, 0x92, 0xad, 0x5c, 0x86, 0x2a, 0xd9,
+ 0xea, 0x9e, 0x6f, 0xd2, 0x15, 0x6b, 0xe4, 0x80, 0xf4, 0x9e, 0xd9, 0xdf, 0x96, 0x2e, 0xf9, 0xbe,
+ 0x74, 0xc9, 0xcf, 0xa5, 0x4b, 0xbe, 0xfc, 0x72, 0x6f, 0x0c, 0x1b, 0xfa, 0x8f, 0xd9, 0xff, 0x13,
+ 0x00, 0x00, 0xff, 0xff, 0xfc, 0x4d, 0x5a, 0x40, 0xca, 0x05, 0x00, 0x00,
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb/v3election.proto b/vendor/github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb/v3election.proto
new file mode 100644
index 00000000..ebf6c88f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb/v3election.proto
@@ -0,0 +1,119 @@
+syntax = "proto3";
+package v3electionpb;
+
+import "gogoproto/gogo.proto";
+import "etcd/etcdserver/etcdserverpb/rpc.proto";
+import "etcd/mvcc/mvccpb/kv.proto";
+
+// for grpc-gateway
+import "google/api/annotations.proto";
+
+option (gogoproto.marshaler_all) = true;
+option (gogoproto.unmarshaler_all) = true;
+
+// The election service exposes client-side election facilities as a gRPC interface.
+service Election {
+ // Campaign waits to acquire leadership in an election, returning a LeaderKey
+ // representing the leadership if successful. The LeaderKey can then be used
+ // to issue new values on the election, transactionally guard API requests on
+ // leadership still being held, and resign from the election.
+ rpc Campaign(CampaignRequest) returns (CampaignResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/election/campaign"
+ body: "*"
+ };
+ }
+ // Proclaim updates the leader's posted value with a new value.
+ rpc Proclaim(ProclaimRequest) returns (ProclaimResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/election/proclaim"
+ body: "*"
+ };
+ }
+ // Leader returns the current election proclamation, if any.
+ rpc Leader(LeaderRequest) returns (LeaderResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/election/leader"
+ body: "*"
+ };
+ }
+ // Observe streams election proclamations in-order as made by the election's
+ // elected leaders.
+ rpc Observe(LeaderRequest) returns (stream LeaderResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/election/observe"
+ body: "*"
+ };
+ }
+ // Resign releases election leadership so other campaigners may acquire
+ // leadership on the election.
+ rpc Resign(ResignRequest) returns (ResignResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/election/resign"
+ body: "*"
+ };
+ }
+}
+
+message CampaignRequest {
+ // name is the election's identifier for the campaign.
+ bytes name = 1;
+ // lease is the ID of the lease attached to leadership of the election. If the
+ // lease expires or is revoked before resigning leadership, then the
+ // leadership is transferred to the next campaigner, if any.
+ int64 lease = 2;
+ // value is the initial proclaimed value set when the campaigner wins the
+ // election.
+ bytes value = 3;
+}
+
+message CampaignResponse {
+ etcdserverpb.ResponseHeader header = 1;
+ // leader describes the resources used for holding leadereship of the election.
+ LeaderKey leader = 2;
+}
+
+message LeaderKey {
+ // name is the election identifier that correponds to the leadership key.
+ bytes name = 1;
+ // key is an opaque key representing the ownership of the election. If the key
+ // is deleted, then leadership is lost.
+ bytes key = 2;
+ // rev is the creation revision of the key. It can be used to test for ownership
+ // of an election during transactions by testing the key's creation revision
+ // matches rev.
+ int64 rev = 3;
+ // lease is the lease ID of the election leader.
+ int64 lease = 4;
+}
+
+message LeaderRequest {
+ // name is the election identifier for the leadership information.
+ bytes name = 1;
+}
+
+message LeaderResponse {
+ etcdserverpb.ResponseHeader header = 1;
+ // kv is the key-value pair representing the latest leader update.
+ mvccpb.KeyValue kv = 2;
+}
+
+message ResignRequest {
+ // leader is the leadership to relinquish by resignation.
+ LeaderKey leader = 1;
+}
+
+message ResignResponse {
+ etcdserverpb.ResponseHeader header = 1;
+}
+
+message ProclaimRequest {
+ // leader is the leadership hold on the election.
+ LeaderKey leader = 1;
+ // value is an update meant to overwrite the leader's current value.
+ bytes value = 2;
+}
+
+message ProclaimResponse {
+ etcdserverpb.ResponseHeader header = 1;
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/doc.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/doc.go
new file mode 100644
index 00000000..e0a1008a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 v3lock provides a v3 locking service from an etcdserver.
+package v3lock
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/lock.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/lock.go
new file mode 100644
index 00000000..66465bf1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/lock.go
@@ -0,0 +1,56 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 v3lock
+
+import (
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/concurrency"
+ "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb"
+)
+
+type lockServer struct {
+ c *clientv3.Client
+}
+
+func NewLockServer(c *clientv3.Client) v3lockpb.LockServer {
+ return &lockServer{c}
+}
+
+func (ls *lockServer) Lock(ctx context.Context, req *v3lockpb.LockRequest) (*v3lockpb.LockResponse, error) {
+ s, err := concurrency.NewSession(
+ ls.c,
+ concurrency.WithLease(clientv3.LeaseID(req.Lease)),
+ concurrency.WithContext(ctx),
+ )
+ if err != nil {
+ return nil, err
+ }
+ s.Orphan()
+ m := concurrency.NewMutex(s, string(req.Name))
+ if err = m.Lock(ctx); err != nil {
+ return nil, err
+ }
+ return &v3lockpb.LockResponse{Header: m.Header(), Key: []byte(m.Key())}, nil
+}
+
+func (ls *lockServer) Unlock(ctx context.Context, req *v3lockpb.UnlockRequest) (*v3lockpb.UnlockResponse, error) {
+ resp, err := ls.c.Delete(ctx, string(req.Key))
+ if err != nil {
+ return nil, err
+ }
+ return &v3lockpb.UnlockResponse{Header: resp.Header}, nil
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb/gw/v3lock.pb.gw.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb/gw/v3lock.pb.gw.go
new file mode 100644
index 00000000..f31cc401
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb/gw/v3lock.pb.gw.go
@@ -0,0 +1,156 @@
+// Code generated by protoc-gen-grpc-gateway
+// source: etcdserver/api/v3lock/v3lockpb/v3lock.proto
+// DO NOT EDIT!
+
+/*
+Package v3lockpb is a reverse proxy.
+
+It translates gRPC into RESTful JSON APIs.
+*/
+package gw
+
+import (
+ "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb"
+ "io"
+ "net/http"
+
+ "github.com/golang/protobuf/proto"
+ "github.com/grpc-ecosystem/grpc-gateway/runtime"
+ "github.com/grpc-ecosystem/grpc-gateway/utilities"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/grpclog"
+)
+
+var _ codes.Code
+var _ io.Reader
+var _ = runtime.String
+var _ = utilities.NewDoubleArray
+
+func request_Lock_Lock_0(ctx context.Context, marshaler runtime.Marshaler, client v3lockpb.LockClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq v3lockpb.LockRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Lock(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Lock_Unlock_0(ctx context.Context, marshaler runtime.Marshaler, client v3lockpb.LockClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq v3lockpb.UnlockRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Unlock(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+// RegisterLockHandlerFromEndpoint is same as RegisterLockHandler but
+// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
+func RegisterLockHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
+ conn, err := grpc.Dial(endpoint, opts...)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ if err != nil {
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ return
+ }
+ go func() {
+ <-ctx.Done()
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ }()
+ }()
+
+ return RegisterLockHandler(ctx, mux, conn)
+}
+
+// RegisterLockHandler registers the http handlers for service Lock to "mux".
+// The handlers forward requests to the grpc endpoint over "conn".
+func RegisterLockHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
+ client := v3lockpb.NewLockClient(conn)
+
+ mux.Handle("POST", pattern_Lock_Lock_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Lock_Lock_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Lock_Lock_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Lock_Unlock_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Lock_Unlock_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Lock_Unlock_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ return nil
+}
+
+var (
+ pattern_Lock_Lock_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 1}, []string{"v3alpha", "lock"}, ""))
+
+ pattern_Lock_Unlock_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "lock", "unlock"}, ""))
+)
+
+var (
+ forward_Lock_Lock_0 = runtime.ForwardResponseMessage
+
+ forward_Lock_Unlock_0 = runtime.ForwardResponseMessage
+)
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb/v3lock.pb.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb/v3lock.pb.go
new file mode 100644
index 00000000..44bde286
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb/v3lock.pb.go
@@ -0,0 +1,948 @@
+// Code generated by protoc-gen-gogo.
+// source: v3lock.proto
+// DO NOT EDIT!
+
+/*
+ Package v3lockpb is a generated protocol buffer package.
+
+ It is generated from these files:
+ v3lock.proto
+
+ It has these top-level messages:
+ LockRequest
+ LockResponse
+ UnlockRequest
+ UnlockResponse
+*/
+package v3lockpb
+
+import (
+ "fmt"
+
+ proto "github.com/golang/protobuf/proto"
+
+ math "math"
+
+ etcdserverpb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+
+ context "golang.org/x/net/context"
+
+ grpc "google.golang.org/grpc"
+
+ io "io"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+type LockRequest struct {
+ // name is the identifier for the distributed shared lock to be acquired.
+ Name []byte `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ // lease is the ID of the lease that will be attached to ownership of the
+ // lock. If the lease expires or is revoked and currently holds the lock,
+ // the lock is automatically released. Calls to Lock with the same lease will
+ // be treated as a single acquistion; locking twice with the same lease is a
+ // no-op.
+ Lease int64 `protobuf:"varint,2,opt,name=lease,proto3" json:"lease,omitempty"`
+}
+
+func (m *LockRequest) Reset() { *m = LockRequest{} }
+func (m *LockRequest) String() string { return proto.CompactTextString(m) }
+func (*LockRequest) ProtoMessage() {}
+func (*LockRequest) Descriptor() ([]byte, []int) { return fileDescriptorV3Lock, []int{0} }
+
+type LockResponse struct {
+ Header *etcdserverpb.ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // key is a key that will exist on etcd for the duration that the Lock caller
+ // owns the lock. Users should not modify this key or the lock may exhibit
+ // undefined behavior.
+ Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
+}
+
+func (m *LockResponse) Reset() { *m = LockResponse{} }
+func (m *LockResponse) String() string { return proto.CompactTextString(m) }
+func (*LockResponse) ProtoMessage() {}
+func (*LockResponse) Descriptor() ([]byte, []int) { return fileDescriptorV3Lock, []int{1} }
+
+func (m *LockResponse) GetHeader() *etcdserverpb.ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type UnlockRequest struct {
+ // key is the lock ownership key granted by Lock.
+ Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
+}
+
+func (m *UnlockRequest) Reset() { *m = UnlockRequest{} }
+func (m *UnlockRequest) String() string { return proto.CompactTextString(m) }
+func (*UnlockRequest) ProtoMessage() {}
+func (*UnlockRequest) Descriptor() ([]byte, []int) { return fileDescriptorV3Lock, []int{2} }
+
+type UnlockResponse struct {
+ Header *etcdserverpb.ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *UnlockResponse) Reset() { *m = UnlockResponse{} }
+func (m *UnlockResponse) String() string { return proto.CompactTextString(m) }
+func (*UnlockResponse) ProtoMessage() {}
+func (*UnlockResponse) Descriptor() ([]byte, []int) { return fileDescriptorV3Lock, []int{3} }
+
+func (m *UnlockResponse) GetHeader() *etcdserverpb.ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func init() {
+ proto.RegisterType((*LockRequest)(nil), "v3lockpb.LockRequest")
+ proto.RegisterType((*LockResponse)(nil), "v3lockpb.LockResponse")
+ proto.RegisterType((*UnlockRequest)(nil), "v3lockpb.UnlockRequest")
+ proto.RegisterType((*UnlockResponse)(nil), "v3lockpb.UnlockResponse")
+}
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ context.Context
+var _ grpc.ClientConn
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+const _ = grpc.SupportPackageIsVersion4
+
+// Client API for Lock service
+
+type LockClient interface {
+ // Lock acquires a distributed shared lock on a given named lock.
+ // On success, it will return a unique key that exists so long as the
+ // lock is held by the caller. This key can be used in conjunction with
+ // transactions to safely ensure updates to etcd only occur while holding
+ // lock ownership. The lock is held until Unlock is called on the key or the
+ // lease associate with the owner expires.
+ Lock(ctx context.Context, in *LockRequest, opts ...grpc.CallOption) (*LockResponse, error)
+ // Unlock takes a key returned by Lock and releases the hold on lock. The
+ // next Lock caller waiting for the lock will then be woken up and given
+ // ownership of the lock.
+ Unlock(ctx context.Context, in *UnlockRequest, opts ...grpc.CallOption) (*UnlockResponse, error)
+}
+
+type lockClient struct {
+ cc *grpc.ClientConn
+}
+
+func NewLockClient(cc *grpc.ClientConn) LockClient {
+ return &lockClient{cc}
+}
+
+func (c *lockClient) Lock(ctx context.Context, in *LockRequest, opts ...grpc.CallOption) (*LockResponse, error) {
+ out := new(LockResponse)
+ err := grpc.Invoke(ctx, "/v3lockpb.Lock/Lock", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *lockClient) Unlock(ctx context.Context, in *UnlockRequest, opts ...grpc.CallOption) (*UnlockResponse, error) {
+ out := new(UnlockResponse)
+ err := grpc.Invoke(ctx, "/v3lockpb.Lock/Unlock", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// Server API for Lock service
+
+type LockServer interface {
+ // Lock acquires a distributed shared lock on a given named lock.
+ // On success, it will return a unique key that exists so long as the
+ // lock is held by the caller. This key can be used in conjunction with
+ // transactions to safely ensure updates to etcd only occur while holding
+ // lock ownership. The lock is held until Unlock is called on the key or the
+ // lease associate with the owner expires.
+ Lock(context.Context, *LockRequest) (*LockResponse, error)
+ // Unlock takes a key returned by Lock and releases the hold on lock. The
+ // next Lock caller waiting for the lock will then be woken up and given
+ // ownership of the lock.
+ Unlock(context.Context, *UnlockRequest) (*UnlockResponse, error)
+}
+
+func RegisterLockServer(s *grpc.Server, srv LockServer) {
+ s.RegisterService(&_Lock_serviceDesc, srv)
+}
+
+func _Lock_Lock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(LockRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(LockServer).Lock(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/v3lockpb.Lock/Lock",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(LockServer).Lock(ctx, req.(*LockRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Lock_Unlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(UnlockRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(LockServer).Unlock(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/v3lockpb.Lock/Unlock",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(LockServer).Unlock(ctx, req.(*UnlockRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+var _Lock_serviceDesc = grpc.ServiceDesc{
+ ServiceName: "v3lockpb.Lock",
+ HandlerType: (*LockServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "Lock",
+ Handler: _Lock_Lock_Handler,
+ },
+ {
+ MethodName: "Unlock",
+ Handler: _Lock_Unlock_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{},
+ Metadata: "v3lock.proto",
+}
+
+func (m *LockRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LockRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintV3Lock(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ if m.Lease != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintV3Lock(dAtA, i, uint64(m.Lease))
+ }
+ return i, nil
+}
+
+func (m *LockResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LockResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintV3Lock(dAtA, i, uint64(m.Header.Size()))
+ n1, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n1
+ }
+ if len(m.Key) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintV3Lock(dAtA, i, uint64(len(m.Key)))
+ i += copy(dAtA[i:], m.Key)
+ }
+ return i, nil
+}
+
+func (m *UnlockRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *UnlockRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Key) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintV3Lock(dAtA, i, uint64(len(m.Key)))
+ i += copy(dAtA[i:], m.Key)
+ }
+ return i, nil
+}
+
+func (m *UnlockResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *UnlockResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintV3Lock(dAtA, i, uint64(m.Header.Size()))
+ n2, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n2
+ }
+ return i, nil
+}
+
+func encodeFixed64V3Lock(dAtA []byte, offset int, v uint64) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ dAtA[offset+4] = uint8(v >> 32)
+ dAtA[offset+5] = uint8(v >> 40)
+ dAtA[offset+6] = uint8(v >> 48)
+ dAtA[offset+7] = uint8(v >> 56)
+ return offset + 8
+}
+func encodeFixed32V3Lock(dAtA []byte, offset int, v uint32) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ return offset + 4
+}
+func encodeVarintV3Lock(dAtA []byte, offset int, v uint64) int {
+ for v >= 1<<7 {
+ dAtA[offset] = uint8(v&0x7f | 0x80)
+ v >>= 7
+ offset++
+ }
+ dAtA[offset] = uint8(v)
+ return offset + 1
+}
+func (m *LockRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovV3Lock(uint64(l))
+ }
+ if m.Lease != 0 {
+ n += 1 + sovV3Lock(uint64(m.Lease))
+ }
+ return n
+}
+
+func (m *LockResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovV3Lock(uint64(l))
+ }
+ l = len(m.Key)
+ if l > 0 {
+ n += 1 + l + sovV3Lock(uint64(l))
+ }
+ return n
+}
+
+func (m *UnlockRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Key)
+ if l > 0 {
+ n += 1 + l + sovV3Lock(uint64(l))
+ }
+ return n
+}
+
+func (m *UnlockResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovV3Lock(uint64(l))
+ }
+ return n
+}
+
+func sovV3Lock(x uint64) (n int) {
+ for {
+ n++
+ x >>= 7
+ if x == 0 {
+ break
+ }
+ }
+ return n
+}
+func sozV3Lock(x uint64) (n int) {
+ return sovV3Lock(uint64((x << 1) ^ uint64((int64(x) >> 63))))
+}
+func (m *LockRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Lock
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LockRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LockRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Lock
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthV3Lock
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...)
+ if m.Name == nil {
+ m.Name = []byte{}
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Lease", wireType)
+ }
+ m.Lease = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Lock
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Lease |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipV3Lock(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthV3Lock
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *LockResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Lock
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LockResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LockResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Lock
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthV3Lock
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &etcdserverpb.ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Lock
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthV3Lock
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
+ if m.Key == nil {
+ m.Key = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipV3Lock(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthV3Lock
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *UnlockRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Lock
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: UnlockRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: UnlockRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Lock
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthV3Lock
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
+ if m.Key == nil {
+ m.Key = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipV3Lock(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthV3Lock
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *UnlockResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Lock
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: UnlockResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: UnlockResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowV3Lock
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthV3Lock
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &etcdserverpb.ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipV3Lock(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthV3Lock
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func skipV3Lock(dAtA []byte) (n int, err error) {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowV3Lock
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ wireType := int(wire & 0x7)
+ switch wireType {
+ case 0:
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowV3Lock
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ iNdEx++
+ if dAtA[iNdEx-1] < 0x80 {
+ break
+ }
+ }
+ return iNdEx, nil
+ case 1:
+ iNdEx += 8
+ return iNdEx, nil
+ case 2:
+ var length int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowV3Lock
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ length |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ iNdEx += length
+ if length < 0 {
+ return 0, ErrInvalidLengthV3Lock
+ }
+ return iNdEx, nil
+ case 3:
+ for {
+ var innerWire uint64
+ var start int = iNdEx
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowV3Lock
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ innerWire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ innerWireType := int(innerWire & 0x7)
+ if innerWireType == 4 {
+ break
+ }
+ next, err := skipV3Lock(dAtA[start:])
+ if err != nil {
+ return 0, err
+ }
+ iNdEx = start + next
+ }
+ return iNdEx, nil
+ case 4:
+ return iNdEx, nil
+ case 5:
+ iNdEx += 4
+ return iNdEx, nil
+ default:
+ return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
+ }
+ }
+ panic("unreachable")
+}
+
+var (
+ ErrInvalidLengthV3Lock = fmt.Errorf("proto: negative length found during unmarshaling")
+ ErrIntOverflowV3Lock = fmt.Errorf("proto: integer overflow")
+)
+
+func init() { proto.RegisterFile("v3lock.proto", fileDescriptorV3Lock) }
+
+var fileDescriptorV3Lock = []byte{
+ // 336 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x29, 0x33, 0xce, 0xc9,
+ 0x4f, 0xce, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x80, 0xf0, 0x0a, 0x92, 0xa4, 0x44,
+ 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x82, 0xfa, 0x20, 0x16, 0x44, 0x5e, 0x4a, 0x2d, 0xb5, 0x24, 0x39,
+ 0x45, 0x1f, 0x44, 0x14, 0xa7, 0x16, 0x95, 0xa5, 0x16, 0x21, 0x31, 0x0b, 0x92, 0xf4, 0x8b, 0x0a,
+ 0x92, 0xa1, 0xea, 0x64, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, 0x32, 0xf5, 0x13,
+ 0xf3, 0xf2, 0xf2, 0x4b, 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x8a, 0x21, 0xb2, 0x4a, 0xe6, 0x5c, 0xdc,
+ 0x3e, 0xf9, 0xc9, 0xd9, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x42, 0x42, 0x5c, 0x2c, 0x79,
+ 0x89, 0xb9, 0xa9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x3c, 0x41, 0x60, 0xb6, 0x90, 0x08, 0x17, 0x6b,
+ 0x4e, 0x6a, 0x62, 0x71, 0xaa, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x73, 0x10, 0x84, 0xa3, 0x14, 0xc6,
+ 0xc5, 0x03, 0xd1, 0x58, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x2a, 0x64, 0xc2, 0xc5, 0x96, 0x91, 0x9a,
+ 0x98, 0x92, 0x5a, 0x04, 0xd6, 0xcb, 0x6d, 0x24, 0xa3, 0x87, 0xec, 0x1e, 0x3d, 0x98, 0x3a, 0x0f,
+ 0xb0, 0x9a, 0x20, 0xa8, 0x5a, 0x21, 0x01, 0x2e, 0xe6, 0xec, 0xd4, 0x4a, 0xb0, 0xc9, 0x3c, 0x41,
+ 0x20, 0xa6, 0x92, 0x22, 0x17, 0x6f, 0x68, 0x5e, 0x0e, 0x92, 0x93, 0xa0, 0x4a, 0x18, 0x11, 0x4a,
+ 0xdc, 0xb8, 0xf8, 0x60, 0x4a, 0x28, 0xb1, 0xdc, 0x68, 0x17, 0x23, 0x17, 0x0b, 0xc8, 0x0f, 0x42,
+ 0x21, 0x50, 0x5a, 0x54, 0x0f, 0x16, 0xe6, 0x7a, 0x48, 0x81, 0x22, 0x25, 0x86, 0x2e, 0x0c, 0x31,
+ 0x4d, 0x49, 0xb6, 0xe9, 0xf2, 0x93, 0xc9, 0x4c, 0xe2, 0x4a, 0x42, 0xfa, 0x65, 0xc6, 0x89, 0x39,
+ 0x05, 0x19, 0x89, 0xfa, 0x20, 0x55, 0x60, 0xc2, 0x8a, 0x51, 0x4b, 0x28, 0x86, 0x8b, 0x0d, 0xe2,
+ 0x4c, 0x21, 0x71, 0x84, 0x01, 0x28, 0x7e, 0x93, 0x92, 0xc0, 0x94, 0x80, 0x9a, 0x2d, 0x0f, 0x36,
+ 0x5b, 0x52, 0x49, 0x04, 0xd5, 0xec, 0xd2, 0x3c, 0xa8, 0xe9, 0x4e, 0x02, 0x27, 0x1e, 0xc9, 0x31,
+ 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x8c, 0xc7, 0x72, 0x0c, 0x49, 0x6c, 0xe0,
+ 0x18, 0x35, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xb6, 0xa0, 0x26, 0x28, 0x47, 0x02, 0x00, 0x00,
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb/v3lock.proto b/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb/v3lock.proto
new file mode 100644
index 00000000..3e92a6ec
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb/v3lock.proto
@@ -0,0 +1,65 @@
+syntax = "proto3";
+package v3lockpb;
+
+import "gogoproto/gogo.proto";
+import "etcd/etcdserver/etcdserverpb/rpc.proto";
+
+// for grpc-gateway
+import "google/api/annotations.proto";
+
+option (gogoproto.marshaler_all) = true;
+option (gogoproto.unmarshaler_all) = true;
+
+// The lock service exposes client-side locking facilities as a gRPC interface.
+service Lock {
+ // Lock acquires a distributed shared lock on a given named lock.
+ // On success, it will return a unique key that exists so long as the
+ // lock is held by the caller. This key can be used in conjunction with
+ // transactions to safely ensure updates to etcd only occur while holding
+ // lock ownership. The lock is held until Unlock is called on the key or the
+ // lease associate with the owner expires.
+ rpc Lock(LockRequest) returns (LockResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/lock/lock"
+ body: "*"
+ };
+ }
+
+ // Unlock takes a key returned by Lock and releases the hold on lock. The
+ // next Lock caller waiting for the lock will then be woken up and given
+ // ownership of the lock.
+ rpc Unlock(UnlockRequest) returns (UnlockResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/lock/unlock"
+ body: "*"
+ };
+ }
+}
+
+message LockRequest {
+ // name is the identifier for the distributed shared lock to be acquired.
+ bytes name = 1;
+ // lease is the ID of the lease that will be attached to ownership of the
+ // lock. If the lease expires or is revoked and currently holds the lock,
+ // the lock is automatically released. Calls to Lock with the same lease will
+ // be treated as a single acquistion; locking twice with the same lease is a
+ // no-op.
+ int64 lease = 2;
+}
+
+message LockResponse {
+ etcdserverpb.ResponseHeader header = 1;
+ // key is a key that will exist on etcd for the duration that the Lock caller
+ // owns the lock. Users should not modify this key or the lock may exhibit
+ // undefined behavior.
+ bytes key = 2;
+}
+
+message UnlockRequest {
+ // key is the lock ownership key granted by Lock.
+ bytes key = 1;
+}
+
+message UnlockResponse {
+ etcdserverpb.ResponseHeader header = 1;
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/auth.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/auth.go
new file mode 100644
index 00000000..e66c5261
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/auth.go
@@ -0,0 +1,157 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 v3rpc
+
+import (
+ "github.com/coreos/etcd/etcdserver"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "golang.org/x/net/context"
+)
+
+type AuthServer struct {
+ authenticator etcdserver.Authenticator
+}
+
+func NewAuthServer(s *etcdserver.EtcdServer) *AuthServer {
+ return &AuthServer{authenticator: s}
+}
+
+func (as *AuthServer) AuthEnable(ctx context.Context, r *pb.AuthEnableRequest) (*pb.AuthEnableResponse, error) {
+ resp, err := as.authenticator.AuthEnable(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) AuthDisable(ctx context.Context, r *pb.AuthDisableRequest) (*pb.AuthDisableResponse, error) {
+ resp, err := as.authenticator.AuthDisable(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) Authenticate(ctx context.Context, r *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) {
+ resp, err := as.authenticator.Authenticate(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) RoleAdd(ctx context.Context, r *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error) {
+ resp, err := as.authenticator.RoleAdd(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) RoleDelete(ctx context.Context, r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error) {
+ resp, err := as.authenticator.RoleDelete(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) RoleGet(ctx context.Context, r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error) {
+ resp, err := as.authenticator.RoleGet(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) RoleList(ctx context.Context, r *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error) {
+ resp, err := as.authenticator.RoleList(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) RoleRevokePermission(ctx context.Context, r *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error) {
+ resp, err := as.authenticator.RoleRevokePermission(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) RoleGrantPermission(ctx context.Context, r *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error) {
+ resp, err := as.authenticator.RoleGrantPermission(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) UserAdd(ctx context.Context, r *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error) {
+ resp, err := as.authenticator.UserAdd(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) UserDelete(ctx context.Context, r *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error) {
+ resp, err := as.authenticator.UserDelete(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) UserGet(ctx context.Context, r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error) {
+ resp, err := as.authenticator.UserGet(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) UserList(ctx context.Context, r *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error) {
+ resp, err := as.authenticator.UserList(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) UserGrantRole(ctx context.Context, r *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error) {
+ resp, err := as.authenticator.UserGrantRole(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) UserRevokeRole(ctx context.Context, r *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error) {
+ resp, err := as.authenticator.UserRevokeRole(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
+
+func (as *AuthServer) UserChangePassword(ctx context.Context, r *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error) {
+ resp, err := as.authenticator.UserChangePassword(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return resp, nil
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/codec.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/codec.go
new file mode 100644
index 00000000..17a2c87a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/codec.go
@@ -0,0 +1,34 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 v3rpc
+
+import "github.com/gogo/protobuf/proto"
+
+type codec struct{}
+
+func (c *codec) Marshal(v interface{}) ([]byte, error) {
+ b, err := proto.Marshal(v.(proto.Message))
+ sentBytes.Add(float64(len(b)))
+ return b, err
+}
+
+func (c *codec) Unmarshal(data []byte, v interface{}) error {
+ receivedBytes.Add(float64(len(data)))
+ return proto.Unmarshal(data, v.(proto.Message))
+}
+
+func (c *codec) String() string {
+ return "proto"
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/grpc.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/grpc.go
new file mode 100644
index 00000000..68a7c120
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/grpc.go
@@ -0,0 +1,53 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 v3rpc
+
+import (
+ "crypto/tls"
+ "math"
+
+ "github.com/coreos/etcd/etcdserver"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/credentials"
+ "google.golang.org/grpc/grpclog"
+)
+
+const maxStreams = math.MaxUint32
+
+func init() {
+ grpclog.SetLogger(plog)
+}
+
+func Server(s *etcdserver.EtcdServer, tls *tls.Config) *grpc.Server {
+ var opts []grpc.ServerOption
+ opts = append(opts, grpc.CustomCodec(&codec{}))
+ if tls != nil {
+ opts = append(opts, grpc.Creds(credentials.NewTLS(tls)))
+ }
+ opts = append(opts, grpc.UnaryInterceptor(newUnaryInterceptor(s)))
+ opts = append(opts, grpc.StreamInterceptor(newStreamInterceptor(s)))
+ opts = append(opts, grpc.MaxConcurrentStreams(maxStreams))
+ grpcServer := grpc.NewServer(opts...)
+
+ pb.RegisterKVServer(grpcServer, NewQuotaKVServer(s))
+ pb.RegisterWatchServer(grpcServer, NewWatchServer(s))
+ pb.RegisterLeaseServer(grpcServer, NewQuotaLeaseServer(s))
+ pb.RegisterClusterServer(grpcServer, NewClusterServer(s))
+ pb.RegisterAuthServer(grpcServer, NewAuthServer(s))
+ pb.RegisterMaintenanceServer(grpcServer, NewMaintenanceServer(s))
+
+ return grpcServer
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/header.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/header.go
new file mode 100644
index 00000000..d6d7f35d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/header.go
@@ -0,0 +1,46 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 v3rpc
+
+import (
+ "github.com/coreos/etcd/etcdserver"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+type header struct {
+ clusterID int64
+ memberID int64
+ raftTimer etcdserver.RaftTimer
+ rev func() int64
+}
+
+func newHeader(s *etcdserver.EtcdServer) header {
+ return header{
+ clusterID: int64(s.Cluster().ID()),
+ memberID: int64(s.ID()),
+ raftTimer: s,
+ rev: func() int64 { return s.KV().Rev() },
+ }
+}
+
+// fill populates pb.ResponseHeader using etcdserver information
+func (h *header) fill(rh *pb.ResponseHeader) {
+ rh.ClusterId = uint64(h.clusterID)
+ rh.MemberId = uint64(h.memberID)
+ rh.RaftTerm = h.raftTimer.Term()
+ if rh.Revision == 0 {
+ rh.Revision = h.rev()
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/interceptor.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/interceptor.go
new file mode 100644
index 00000000..29aef291
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/interceptor.go
@@ -0,0 +1,144 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 v3rpc
+
+import (
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft"
+
+ prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/metadata"
+)
+
+const (
+ maxNoLeaderCnt = 3
+)
+
+type streamsMap struct {
+ mu sync.Mutex
+ streams map[grpc.ServerStream]struct{}
+}
+
+func newUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerInterceptor {
+ return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
+ if !api.IsCapabilityEnabled(api.V3rpcCapability) {
+ return nil, rpctypes.ErrGRPCNotCapable
+ }
+
+ md, ok := metadata.FromContext(ctx)
+ if ok {
+ if ks := md[rpctypes.MetadataRequireLeaderKey]; len(ks) > 0 && ks[0] == rpctypes.MetadataHasLeader {
+ if s.Leader() == types.ID(raft.None) {
+ return nil, rpctypes.ErrGRPCNoLeader
+ }
+ }
+ }
+
+ return prometheus.UnaryServerInterceptor(ctx, req, info, handler)
+ }
+}
+
+func newStreamInterceptor(s *etcdserver.EtcdServer) grpc.StreamServerInterceptor {
+ smap := monitorLeader(s)
+
+ return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
+ if !api.IsCapabilityEnabled(api.V3rpcCapability) {
+ return rpctypes.ErrGRPCNotCapable
+ }
+
+ md, ok := metadata.FromContext(ss.Context())
+ if ok {
+ if ks := md[rpctypes.MetadataRequireLeaderKey]; len(ks) > 0 && ks[0] == rpctypes.MetadataHasLeader {
+ if s.Leader() == types.ID(raft.None) {
+ return rpctypes.ErrGRPCNoLeader
+ }
+
+ cctx, cancel := context.WithCancel(ss.Context())
+ ss = serverStreamWithCtx{ctx: cctx, cancel: &cancel, ServerStream: ss}
+
+ smap.mu.Lock()
+ smap.streams[ss] = struct{}{}
+ smap.mu.Unlock()
+
+ defer func() {
+ smap.mu.Lock()
+ delete(smap.streams, ss)
+ smap.mu.Unlock()
+ cancel()
+ }()
+
+ }
+ }
+
+ return prometheus.StreamServerInterceptor(srv, ss, info, handler)
+ }
+}
+
+type serverStreamWithCtx struct {
+ grpc.ServerStream
+ ctx context.Context
+ cancel *context.CancelFunc
+}
+
+func (ssc serverStreamWithCtx) Context() context.Context { return ssc.ctx }
+
+func monitorLeader(s *etcdserver.EtcdServer) *streamsMap {
+ smap := &streamsMap{
+ streams: make(map[grpc.ServerStream]struct{}),
+ }
+
+ go func() {
+ election := time.Duration(s.Cfg.TickMs) * time.Duration(s.Cfg.ElectionTicks) * time.Millisecond
+ noLeaderCnt := 0
+
+ for {
+ select {
+ case <-s.StopNotify():
+ return
+ case <-time.After(election):
+ if s.Leader() == types.ID(raft.None) {
+ noLeaderCnt++
+ } else {
+ noLeaderCnt = 0
+ }
+
+ // We are more conservative on canceling existing streams. Reconnecting streams
+ // cost much more than just rejecting new requests. So we wait until the member
+ // cannot find a leader for maxNoLeaderCnt election timeouts to cancel existing streams.
+ if noLeaderCnt >= maxNoLeaderCnt {
+ smap.mu.Lock()
+ for ss := range smap.streams {
+ if ssWithCtx, ok := ss.(serverStreamWithCtx); ok {
+ (*ssWithCtx.cancel)()
+ <-ss.Context().Done()
+ }
+ }
+ smap.streams = make(map[grpc.ServerStream]struct{})
+ smap.mu.Unlock()
+ }
+ }
+ }
+ }()
+
+ return smap
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/key.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/key.go
new file mode 100644
index 00000000..d0220e03
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/key.go
@@ -0,0 +1,259 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 v3rpc implements etcd v3 RPC system based on gRPC.
+package v3rpc
+
+import (
+ "sort"
+
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/pkg/capnslog"
+ "golang.org/x/net/context"
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "etcdserver/api/v3rpc")
+
+ // Max operations per txn list. For example, Txn.Success can have at most 128 operations,
+ // and Txn.Failure can have at most 128 operations.
+ MaxOpsPerTxn = 128
+)
+
+type kvServer struct {
+ hdr header
+ kv etcdserver.RaftKV
+}
+
+func NewKVServer(s *etcdserver.EtcdServer) pb.KVServer {
+ return &kvServer{hdr: newHeader(s), kv: s}
+}
+
+func (s *kvServer) Range(ctx context.Context, r *pb.RangeRequest) (*pb.RangeResponse, error) {
+ if err := checkRangeRequest(r); err != nil {
+ return nil, err
+ }
+
+ resp, err := s.kv.Range(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+
+ if resp.Header == nil {
+ plog.Panic("unexpected nil resp.Header")
+ }
+ s.hdr.fill(resp.Header)
+ return resp, nil
+}
+
+func (s *kvServer) Put(ctx context.Context, r *pb.PutRequest) (*pb.PutResponse, error) {
+ if err := checkPutRequest(r); err != nil {
+ return nil, err
+ }
+
+ resp, err := s.kv.Put(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+
+ if resp.Header == nil {
+ plog.Panic("unexpected nil resp.Header")
+ }
+ s.hdr.fill(resp.Header)
+ return resp, nil
+}
+
+func (s *kvServer) DeleteRange(ctx context.Context, r *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error) {
+ if err := checkDeleteRequest(r); err != nil {
+ return nil, err
+ }
+
+ resp, err := s.kv.DeleteRange(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+
+ if resp.Header == nil {
+ plog.Panic("unexpected nil resp.Header")
+ }
+ s.hdr.fill(resp.Header)
+ return resp, nil
+}
+
+func (s *kvServer) Txn(ctx context.Context, r *pb.TxnRequest) (*pb.TxnResponse, error) {
+ if err := checkTxnRequest(r); err != nil {
+ return nil, err
+ }
+
+ resp, err := s.kv.Txn(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+
+ if resp.Header == nil {
+ plog.Panic("unexpected nil resp.Header")
+ }
+ s.hdr.fill(resp.Header)
+ return resp, nil
+}
+
+func (s *kvServer) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) {
+ resp, err := s.kv.Compact(ctx, r)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+
+ if resp.Header == nil {
+ plog.Panic("unexpected nil resp.Header")
+ }
+ s.hdr.fill(resp.Header)
+ return resp, nil
+}
+
+func checkRangeRequest(r *pb.RangeRequest) error {
+ if len(r.Key) == 0 {
+ return rpctypes.ErrGRPCEmptyKey
+ }
+ return nil
+}
+
+func checkPutRequest(r *pb.PutRequest) error {
+ if len(r.Key) == 0 {
+ return rpctypes.ErrGRPCEmptyKey
+ }
+ if r.IgnoreValue && len(r.Value) != 0 {
+ return rpctypes.ErrGRPCValueProvided
+ }
+ if r.IgnoreLease && r.Lease != 0 {
+ return rpctypes.ErrGRPCLeaseProvided
+ }
+ return nil
+}
+
+func checkDeleteRequest(r *pb.DeleteRangeRequest) error {
+ if len(r.Key) == 0 {
+ return rpctypes.ErrGRPCEmptyKey
+ }
+ return nil
+}
+
+func checkTxnRequest(r *pb.TxnRequest) error {
+ if len(r.Compare) > MaxOpsPerTxn || len(r.Success) > MaxOpsPerTxn || len(r.Failure) > MaxOpsPerTxn {
+ return rpctypes.ErrGRPCTooManyOps
+ }
+
+ for _, c := range r.Compare {
+ if len(c.Key) == 0 {
+ return rpctypes.ErrGRPCEmptyKey
+ }
+ }
+
+ for _, u := range r.Success {
+ if err := checkRequestOp(u); err != nil {
+ return err
+ }
+ }
+ if err := checkRequestDupKeys(r.Success); err != nil {
+ return err
+ }
+
+ for _, u := range r.Failure {
+ if err := checkRequestOp(u); err != nil {
+ return err
+ }
+ }
+ return checkRequestDupKeys(r.Failure)
+}
+
+// checkRequestDupKeys gives rpctypes.ErrGRPCDuplicateKey if the same key is modified twice
+func checkRequestDupKeys(reqs []*pb.RequestOp) error {
+ // check put overlap
+ keys := make(map[string]struct{})
+ for _, requ := range reqs {
+ tv, ok := requ.Request.(*pb.RequestOp_RequestPut)
+ if !ok {
+ continue
+ }
+ preq := tv.RequestPut
+ if preq == nil {
+ continue
+ }
+ if _, ok := keys[string(preq.Key)]; ok {
+ return rpctypes.ErrGRPCDuplicateKey
+ }
+ keys[string(preq.Key)] = struct{}{}
+ }
+
+ // no need to check deletes if no puts; delete overlaps are permitted
+ if len(keys) == 0 {
+ return nil
+ }
+
+ // sort keys for range checking
+ sortedKeys := []string{}
+ for k := range keys {
+ sortedKeys = append(sortedKeys, k)
+ }
+ sort.Strings(sortedKeys)
+
+ // check put overlap with deletes
+ for _, requ := range reqs {
+ tv, ok := requ.Request.(*pb.RequestOp_RequestDeleteRange)
+ if !ok {
+ continue
+ }
+ dreq := tv.RequestDeleteRange
+ if dreq == nil {
+ continue
+ }
+ if dreq.RangeEnd == nil {
+ if _, found := keys[string(dreq.Key)]; found {
+ return rpctypes.ErrGRPCDuplicateKey
+ }
+ } else {
+ lo := sort.SearchStrings(sortedKeys, string(dreq.Key))
+ hi := sort.SearchStrings(sortedKeys, string(dreq.RangeEnd))
+ if lo != hi {
+ // element between lo and hi => overlap
+ return rpctypes.ErrGRPCDuplicateKey
+ }
+ }
+ }
+
+ return nil
+}
+
+func checkRequestOp(u *pb.RequestOp) error {
+ // TODO: ensure only one of the field is set.
+ switch uv := u.Request.(type) {
+ case *pb.RequestOp_RequestRange:
+ if uv.RequestRange != nil {
+ return checkRangeRequest(uv.RequestRange)
+ }
+ case *pb.RequestOp_RequestPut:
+ if uv.RequestPut != nil {
+ return checkPutRequest(uv.RequestPut)
+ }
+ case *pb.RequestOp_RequestDeleteRange:
+ if uv.RequestDeleteRange != nil {
+ return checkDeleteRequest(uv.RequestDeleteRange)
+ }
+ default:
+ // empty op / nil entry
+ return rpctypes.ErrGRPCKeyNotFound
+ }
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/lease.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/lease.go
new file mode 100644
index 00000000..a25d0ce6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/lease.go
@@ -0,0 +1,123 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 v3rpc
+
+import (
+ "io"
+
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/lease"
+ "golang.org/x/net/context"
+)
+
+type LeaseServer struct {
+ hdr header
+ le etcdserver.Lessor
+}
+
+func NewLeaseServer(s *etcdserver.EtcdServer) pb.LeaseServer {
+ return &LeaseServer{le: s, hdr: newHeader(s)}
+}
+
+func (ls *LeaseServer) LeaseGrant(ctx context.Context, cr *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) {
+ resp, err := ls.le.LeaseGrant(ctx, cr)
+
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ ls.hdr.fill(resp.Header)
+ return resp, nil
+}
+
+func (ls *LeaseServer) LeaseRevoke(ctx context.Context, rr *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error) {
+ resp, err := ls.le.LeaseRevoke(ctx, rr)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ ls.hdr.fill(resp.Header)
+ return resp, nil
+}
+
+func (ls *LeaseServer) LeaseTimeToLive(ctx context.Context, rr *pb.LeaseTimeToLiveRequest) (*pb.LeaseTimeToLiveResponse, error) {
+ resp, err := ls.le.LeaseTimeToLive(ctx, rr)
+ if err != nil && err != lease.ErrLeaseNotFound {
+ return nil, togRPCError(err)
+ }
+ if err == lease.ErrLeaseNotFound {
+ resp = &pb.LeaseTimeToLiveResponse{
+ Header: &pb.ResponseHeader{},
+ ID: rr.ID,
+ TTL: -1,
+ }
+ }
+ ls.hdr.fill(resp.Header)
+ return resp, nil
+}
+
+func (ls *LeaseServer) LeaseKeepAlive(stream pb.Lease_LeaseKeepAliveServer) (err error) {
+ errc := make(chan error, 1)
+ go func() {
+ errc <- ls.leaseKeepAlive(stream)
+ }()
+ select {
+ case err = <-errc:
+ case <-stream.Context().Done():
+ // the only server-side cancellation is noleader for now.
+ err = stream.Context().Err()
+ if err == context.Canceled {
+ err = rpctypes.ErrGRPCNoLeader
+ }
+ }
+ return err
+}
+
+func (ls *LeaseServer) leaseKeepAlive(stream pb.Lease_LeaseKeepAliveServer) error {
+ for {
+ req, err := stream.Recv()
+ if err == io.EOF {
+ return nil
+ }
+ if err != nil {
+ return err
+ }
+
+ // Create header before we sent out the renew request.
+ // This can make sure that the revision is strictly smaller or equal to
+ // when the keepalive happened at the local server (when the local server is the leader)
+ // or remote leader.
+ // Without this, a lease might be revoked at rev 3 but client can see the keepalive succeeded
+ // at rev 4.
+ resp := &pb.LeaseKeepAliveResponse{ID: req.ID, Header: &pb.ResponseHeader{}}
+ ls.hdr.fill(resp.Header)
+
+ ttl, err := ls.le.LeaseRenew(stream.Context(), lease.LeaseID(req.ID))
+ if err == lease.ErrLeaseNotFound {
+ err = nil
+ ttl = 0
+ }
+
+ if err != nil {
+ return togRPCError(err)
+ }
+
+ resp.TTL = ttl
+ err = stream.Send(resp)
+ if err != nil {
+ return err
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/maintenance.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/maintenance.go
new file mode 100644
index 00000000..3657d036
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/maintenance.go
@@ -0,0 +1,190 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 v3rpc
+
+import (
+ "crypto/sha256"
+ "io"
+
+ "github.com/coreos/etcd/auth"
+ "github.com/coreos/etcd/etcdserver"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/mvcc"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/version"
+ "golang.org/x/net/context"
+)
+
+type KVGetter interface {
+ KV() mvcc.ConsistentWatchableKV
+}
+
+type BackendGetter interface {
+ Backend() backend.Backend
+}
+
+type Alarmer interface {
+ Alarm(ctx context.Context, ar *pb.AlarmRequest) (*pb.AlarmResponse, error)
+}
+
+type RaftStatusGetter interface {
+ Index() uint64
+ Term() uint64
+ Leader() types.ID
+}
+
+type AuthGetter interface {
+ AuthInfoFromCtx(ctx context.Context) (*auth.AuthInfo, error)
+ AuthStore() auth.AuthStore
+}
+
+type maintenanceServer struct {
+ rg RaftStatusGetter
+ kg KVGetter
+ bg BackendGetter
+ a Alarmer
+ hdr header
+}
+
+func NewMaintenanceServer(s *etcdserver.EtcdServer) pb.MaintenanceServer {
+ srv := &maintenanceServer{rg: s, kg: s, bg: s, a: s, hdr: newHeader(s)}
+ return &authMaintenanceServer{srv, s}
+}
+
+func (ms *maintenanceServer) Defragment(ctx context.Context, sr *pb.DefragmentRequest) (*pb.DefragmentResponse, error) {
+ plog.Noticef("starting to defragment the storage backend...")
+ err := ms.bg.Backend().Defrag()
+ if err != nil {
+ plog.Errorf("failed to defragment the storage backend (%v)", err)
+ return nil, err
+ }
+ plog.Noticef("finished defragmenting the storage backend")
+ return &pb.DefragmentResponse{}, nil
+}
+
+func (ms *maintenanceServer) Snapshot(sr *pb.SnapshotRequest, srv pb.Maintenance_SnapshotServer) error {
+ snap := ms.bg.Backend().Snapshot()
+ pr, pw := io.Pipe()
+
+ defer pr.Close()
+
+ go func() {
+ snap.WriteTo(pw)
+ if err := snap.Close(); err != nil {
+ plog.Errorf("error closing snapshot (%v)", err)
+ }
+ pw.Close()
+ }()
+
+ // send file data
+ h := sha256.New()
+ br := int64(0)
+ buf := make([]byte, 32*1024)
+ sz := snap.Size()
+ for br < sz {
+ n, err := io.ReadFull(pr, buf)
+ if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF {
+ return togRPCError(err)
+ }
+ br += int64(n)
+ resp := &pb.SnapshotResponse{
+ RemainingBytes: uint64(sz - br),
+ Blob: buf[:n],
+ }
+ if err = srv.Send(resp); err != nil {
+ return togRPCError(err)
+ }
+ h.Write(buf[:n])
+ }
+
+ // send sha
+ sha := h.Sum(nil)
+ hresp := &pb.SnapshotResponse{RemainingBytes: 0, Blob: sha}
+ if err := srv.Send(hresp); err != nil {
+ return togRPCError(err)
+ }
+
+ return nil
+}
+
+func (ms *maintenanceServer) Hash(ctx context.Context, r *pb.HashRequest) (*pb.HashResponse, error) {
+ h, rev, err := ms.kg.KV().Hash()
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ resp := &pb.HashResponse{Header: &pb.ResponseHeader{Revision: rev}, Hash: h}
+ ms.hdr.fill(resp.Header)
+ return resp, nil
+}
+
+func (ms *maintenanceServer) Alarm(ctx context.Context, ar *pb.AlarmRequest) (*pb.AlarmResponse, error) {
+ return ms.a.Alarm(ctx, ar)
+}
+
+func (ms *maintenanceServer) Status(ctx context.Context, ar *pb.StatusRequest) (*pb.StatusResponse, error) {
+ resp := &pb.StatusResponse{
+ Header: &pb.ResponseHeader{Revision: ms.hdr.rev()},
+ Version: version.Version,
+ DbSize: ms.bg.Backend().Size(),
+ Leader: uint64(ms.rg.Leader()),
+ RaftIndex: ms.rg.Index(),
+ RaftTerm: ms.rg.Term(),
+ }
+ ms.hdr.fill(resp.Header)
+ return resp, nil
+}
+
+type authMaintenanceServer struct {
+ *maintenanceServer
+ ag AuthGetter
+}
+
+func (ams *authMaintenanceServer) isAuthenticated(ctx context.Context) error {
+ authInfo, err := ams.ag.AuthInfoFromCtx(ctx)
+ if err != nil {
+ return err
+ }
+
+ return ams.ag.AuthStore().IsAdminPermitted(authInfo)
+}
+
+func (ams *authMaintenanceServer) Defragment(ctx context.Context, sr *pb.DefragmentRequest) (*pb.DefragmentResponse, error) {
+ if err := ams.isAuthenticated(ctx); err != nil {
+ return nil, err
+ }
+
+ return ams.maintenanceServer.Defragment(ctx, sr)
+}
+
+func (ams *authMaintenanceServer) Snapshot(sr *pb.SnapshotRequest, srv pb.Maintenance_SnapshotServer) error {
+ if err := ams.isAuthenticated(srv.Context()); err != nil {
+ return err
+ }
+
+ return ams.maintenanceServer.Snapshot(sr, srv)
+}
+
+func (ams *authMaintenanceServer) Hash(ctx context.Context, r *pb.HashRequest) (*pb.HashResponse, error) {
+ if err := ams.isAuthenticated(ctx); err != nil {
+ return nil, err
+ }
+
+ return ams.maintenanceServer.Hash(ctx, r)
+}
+
+func (ams *authMaintenanceServer) Status(ctx context.Context, ar *pb.StatusRequest) (*pb.StatusResponse, error) {
+ return ams.maintenanceServer.Status(ctx, ar)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/member.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/member.go
new file mode 100644
index 00000000..91a59389
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/member.go
@@ -0,0 +1,103 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 v3rpc
+
+import (
+ "time"
+
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/pkg/types"
+ "golang.org/x/net/context"
+)
+
+type ClusterServer struct {
+ cluster api.Cluster
+ server etcdserver.Server
+ raftTimer etcdserver.RaftTimer
+}
+
+func NewClusterServer(s *etcdserver.EtcdServer) *ClusterServer {
+ return &ClusterServer{
+ cluster: s.Cluster(),
+ server: s,
+ raftTimer: s,
+ }
+}
+
+func (cs *ClusterServer) MemberAdd(ctx context.Context, r *pb.MemberAddRequest) (*pb.MemberAddResponse, error) {
+ urls, err := types.NewURLs(r.PeerURLs)
+ if err != nil {
+ return nil, rpctypes.ErrGRPCMemberBadURLs
+ }
+
+ now := time.Now()
+ m := membership.NewMember("", urls, "", &now)
+ membs, merr := cs.server.AddMember(ctx, *m)
+ if merr != nil {
+ return nil, togRPCError(merr)
+ }
+
+ return &pb.MemberAddResponse{
+ Header: cs.header(),
+ Member: &pb.Member{ID: uint64(m.ID), PeerURLs: m.PeerURLs},
+ Members: membersToProtoMembers(membs),
+ }, nil
+}
+
+func (cs *ClusterServer) MemberRemove(ctx context.Context, r *pb.MemberRemoveRequest) (*pb.MemberRemoveResponse, error) {
+ membs, err := cs.server.RemoveMember(ctx, r.ID)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return &pb.MemberRemoveResponse{Header: cs.header(), Members: membersToProtoMembers(membs)}, nil
+}
+
+func (cs *ClusterServer) MemberUpdate(ctx context.Context, r *pb.MemberUpdateRequest) (*pb.MemberUpdateResponse, error) {
+ m := membership.Member{
+ ID: types.ID(r.ID),
+ RaftAttributes: membership.RaftAttributes{PeerURLs: r.PeerURLs},
+ }
+ membs, err := cs.server.UpdateMember(ctx, m)
+ if err != nil {
+ return nil, togRPCError(err)
+ }
+ return &pb.MemberUpdateResponse{Header: cs.header(), Members: membersToProtoMembers(membs)}, nil
+}
+
+func (cs *ClusterServer) MemberList(ctx context.Context, r *pb.MemberListRequest) (*pb.MemberListResponse, error) {
+ membs := membersToProtoMembers(cs.cluster.Members())
+ return &pb.MemberListResponse{Header: cs.header(), Members: membs}, nil
+}
+
+func (cs *ClusterServer) header() *pb.ResponseHeader {
+ return &pb.ResponseHeader{ClusterId: uint64(cs.cluster.ID()), MemberId: uint64(cs.server.ID()), RaftTerm: cs.raftTimer.Term()}
+}
+
+func membersToProtoMembers(membs []*membership.Member) []*pb.Member {
+ protoMembs := make([]*pb.Member, len(membs))
+ for i := range membs {
+ protoMembs[i] = &pb.Member{
+ Name: membs[i].Name,
+ ID: uint64(membs[i].ID),
+ PeerURLs: membs[i].PeerURLs,
+ ClientURLs: membs[i].ClientURLs,
+ }
+ }
+ return protoMembs
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/metrics.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/metrics.go
new file mode 100644
index 00000000..6cb41a61
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/metrics.go
@@ -0,0 +1,38 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 v3rpc
+
+import "github.com/prometheus/client_golang/prometheus"
+
+var (
+ sentBytes = prometheus.NewCounter(prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "network",
+ Name: "client_grpc_sent_bytes_total",
+ Help: "The total number of bytes sent to grpc clients.",
+ })
+
+ receivedBytes = prometheus.NewCounter(prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "network",
+ Name: "client_grpc_received_bytes_total",
+ Help: "The total number of bytes received from grpc clients.",
+ })
+)
+
+func init() {
+ prometheus.MustRegister(sentBytes)
+ prometheus.MustRegister(receivedBytes)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/quota.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/quota.go
new file mode 100644
index 00000000..836f2fd3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/quota.go
@@ -0,0 +1,89 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 v3rpc
+
+import (
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/types"
+ "golang.org/x/net/context"
+)
+
+type quotaKVServer struct {
+ pb.KVServer
+ qa quotaAlarmer
+}
+
+type quotaAlarmer struct {
+ q etcdserver.Quota
+ a Alarmer
+ id types.ID
+}
+
+// check whether request satisfies the quota. If there is not enough space,
+// ignore request and raise the free space alarm.
+func (qa *quotaAlarmer) check(ctx context.Context, r interface{}) error {
+ if qa.q.Available(r) {
+ return nil
+ }
+ req := &pb.AlarmRequest{
+ MemberID: uint64(qa.id),
+ Action: pb.AlarmRequest_ACTIVATE,
+ Alarm: pb.AlarmType_NOSPACE,
+ }
+ qa.a.Alarm(ctx, req)
+ return rpctypes.ErrGRPCNoSpace
+}
+
+func NewQuotaKVServer(s *etcdserver.EtcdServer) pb.KVServer {
+ return "aKVServer{
+ NewKVServer(s),
+ quotaAlarmer{etcdserver.NewBackendQuota(s), s, s.ID()},
+ }
+}
+
+func (s *quotaKVServer) Put(ctx context.Context, r *pb.PutRequest) (*pb.PutResponse, error) {
+ if err := s.qa.check(ctx, r); err != nil {
+ return nil, err
+ }
+ return s.KVServer.Put(ctx, r)
+}
+
+func (s *quotaKVServer) Txn(ctx context.Context, r *pb.TxnRequest) (*pb.TxnResponse, error) {
+ if err := s.qa.check(ctx, r); err != nil {
+ return nil, err
+ }
+ return s.KVServer.Txn(ctx, r)
+}
+
+type quotaLeaseServer struct {
+ pb.LeaseServer
+ qa quotaAlarmer
+}
+
+func (s *quotaLeaseServer) LeaseGrant(ctx context.Context, cr *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) {
+ if err := s.qa.check(ctx, cr); err != nil {
+ return nil, err
+ }
+ return s.LeaseServer.LeaseGrant(ctx, cr)
+}
+
+func NewQuotaLeaseServer(s *etcdserver.EtcdServer) pb.LeaseServer {
+ return "aLeaseServer{
+ NewLeaseServer(s),
+ quotaAlarmer{etcdserver.NewBackendQuota(s), s, s.ID()},
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/doc.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/doc.go
new file mode 100644
index 00000000..f72c6a64
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 rpctypes has types and values shared by the etcd server and client for v3 RPC interaction.
+package rpctypes
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/error.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/error.go
new file mode 100644
index 00000000..0907e902
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/error.go
@@ -0,0 +1,190 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rpctypes
+
+import (
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+)
+
+var (
+ // server-side error
+ ErrGRPCEmptyKey = grpc.Errorf(codes.InvalidArgument, "etcdserver: key is not provided")
+ ErrGRPCKeyNotFound = grpc.Errorf(codes.InvalidArgument, "etcdserver: key not found")
+ ErrGRPCValueProvided = grpc.Errorf(codes.InvalidArgument, "etcdserver: value is provided")
+ ErrGRPCLeaseProvided = grpc.Errorf(codes.InvalidArgument, "etcdserver: lease is provided")
+ ErrGRPCTooManyOps = grpc.Errorf(codes.InvalidArgument, "etcdserver: too many operations in txn request")
+ ErrGRPCDuplicateKey = grpc.Errorf(codes.InvalidArgument, "etcdserver: duplicate key given in txn request")
+ ErrGRPCCompacted = grpc.Errorf(codes.OutOfRange, "etcdserver: mvcc: required revision has been compacted")
+ ErrGRPCFutureRev = grpc.Errorf(codes.OutOfRange, "etcdserver: mvcc: required revision is a future revision")
+ ErrGRPCNoSpace = grpc.Errorf(codes.ResourceExhausted, "etcdserver: mvcc: database space exceeded")
+
+ ErrGRPCLeaseNotFound = grpc.Errorf(codes.NotFound, "etcdserver: requested lease not found")
+ ErrGRPCLeaseExist = grpc.Errorf(codes.FailedPrecondition, "etcdserver: lease already exists")
+
+ ErrGRPCMemberExist = grpc.Errorf(codes.FailedPrecondition, "etcdserver: member ID already exist")
+ ErrGRPCPeerURLExist = grpc.Errorf(codes.FailedPrecondition, "etcdserver: Peer URLs already exists")
+ ErrGRPCMemberNotEnoughStarted = grpc.Errorf(codes.FailedPrecondition, "etcdserver: re-configuration failed due to not enough started members")
+ ErrGRPCMemberBadURLs = grpc.Errorf(codes.InvalidArgument, "etcdserver: given member URLs are invalid")
+ ErrGRPCMemberNotFound = grpc.Errorf(codes.NotFound, "etcdserver: member not found")
+
+ ErrGRPCRequestTooLarge = grpc.Errorf(codes.InvalidArgument, "etcdserver: request is too large")
+ ErrGRPCRequestTooManyRequests = grpc.Errorf(codes.ResourceExhausted, "etcdserver: too many requests")
+
+ ErrGRPCRootUserNotExist = grpc.Errorf(codes.FailedPrecondition, "etcdserver: root user does not exist")
+ ErrGRPCRootRoleNotExist = grpc.Errorf(codes.FailedPrecondition, "etcdserver: root user does not have root role")
+ ErrGRPCUserAlreadyExist = grpc.Errorf(codes.FailedPrecondition, "etcdserver: user name already exists")
+ ErrGRPCUserEmpty = grpc.Errorf(codes.InvalidArgument, "etcdserver: user name is empty")
+ ErrGRPCUserNotFound = grpc.Errorf(codes.FailedPrecondition, "etcdserver: user name not found")
+ ErrGRPCRoleAlreadyExist = grpc.Errorf(codes.FailedPrecondition, "etcdserver: role name already exists")
+ ErrGRPCRoleNotFound = grpc.Errorf(codes.FailedPrecondition, "etcdserver: role name not found")
+ ErrGRPCAuthFailed = grpc.Errorf(codes.InvalidArgument, "etcdserver: authentication failed, invalid user ID or password")
+ ErrGRPCPermissionDenied = grpc.Errorf(codes.PermissionDenied, "etcdserver: permission denied")
+ ErrGRPCRoleNotGranted = grpc.Errorf(codes.FailedPrecondition, "etcdserver: role is not granted to the user")
+ ErrGRPCPermissionNotGranted = grpc.Errorf(codes.FailedPrecondition, "etcdserver: permission is not granted to the role")
+ ErrGRPCAuthNotEnabled = grpc.Errorf(codes.FailedPrecondition, "etcdserver: authentication is not enabled")
+ ErrGRPCInvalidAuthToken = grpc.Errorf(codes.Unauthenticated, "etcdserver: invalid auth token")
+ ErrGRPCInvalidAuthMgmt = grpc.Errorf(codes.InvalidArgument, "etcdserver: invalid auth management")
+
+ ErrGRPCNoLeader = grpc.Errorf(codes.Unavailable, "etcdserver: no leader")
+ ErrGRPCNotCapable = grpc.Errorf(codes.Unavailable, "etcdserver: not capable")
+ ErrGRPCStopped = grpc.Errorf(codes.Unavailable, "etcdserver: server stopped")
+ ErrGRPCTimeout = grpc.Errorf(codes.Unavailable, "etcdserver: request timed out")
+ ErrGRPCTimeoutDueToLeaderFail = grpc.Errorf(codes.Unavailable, "etcdserver: request timed out, possibly due to previous leader failure")
+ ErrGRPCTimeoutDueToConnectionLost = grpc.Errorf(codes.Unavailable, "etcdserver: request timed out, possibly due to connection lost")
+ ErrGRPCUnhealthy = grpc.Errorf(codes.Unavailable, "etcdserver: unhealthy cluster")
+
+ errStringToError = map[string]error{
+ grpc.ErrorDesc(ErrGRPCEmptyKey): ErrGRPCEmptyKey,
+ grpc.ErrorDesc(ErrGRPCKeyNotFound): ErrGRPCKeyNotFound,
+ grpc.ErrorDesc(ErrGRPCValueProvided): ErrGRPCValueProvided,
+ grpc.ErrorDesc(ErrGRPCLeaseProvided): ErrGRPCLeaseProvided,
+
+ grpc.ErrorDesc(ErrGRPCTooManyOps): ErrGRPCTooManyOps,
+ grpc.ErrorDesc(ErrGRPCDuplicateKey): ErrGRPCDuplicateKey,
+ grpc.ErrorDesc(ErrGRPCCompacted): ErrGRPCCompacted,
+ grpc.ErrorDesc(ErrGRPCFutureRev): ErrGRPCFutureRev,
+ grpc.ErrorDesc(ErrGRPCNoSpace): ErrGRPCNoSpace,
+
+ grpc.ErrorDesc(ErrGRPCLeaseNotFound): ErrGRPCLeaseNotFound,
+ grpc.ErrorDesc(ErrGRPCLeaseExist): ErrGRPCLeaseExist,
+
+ grpc.ErrorDesc(ErrGRPCMemberExist): ErrGRPCMemberExist,
+ grpc.ErrorDesc(ErrGRPCPeerURLExist): ErrGRPCPeerURLExist,
+ grpc.ErrorDesc(ErrGRPCMemberNotEnoughStarted): ErrGRPCMemberNotEnoughStarted,
+ grpc.ErrorDesc(ErrGRPCMemberBadURLs): ErrGRPCMemberBadURLs,
+ grpc.ErrorDesc(ErrGRPCMemberNotFound): ErrGRPCMemberNotFound,
+
+ grpc.ErrorDesc(ErrGRPCRequestTooLarge): ErrGRPCRequestTooLarge,
+ grpc.ErrorDesc(ErrGRPCRequestTooManyRequests): ErrGRPCRequestTooManyRequests,
+
+ grpc.ErrorDesc(ErrGRPCRootUserNotExist): ErrGRPCRootUserNotExist,
+ grpc.ErrorDesc(ErrGRPCRootRoleNotExist): ErrGRPCRootRoleNotExist,
+ grpc.ErrorDesc(ErrGRPCUserAlreadyExist): ErrGRPCUserAlreadyExist,
+ grpc.ErrorDesc(ErrGRPCUserEmpty): ErrGRPCUserEmpty,
+ grpc.ErrorDesc(ErrGRPCUserNotFound): ErrGRPCUserNotFound,
+ grpc.ErrorDesc(ErrGRPCRoleAlreadyExist): ErrGRPCRoleAlreadyExist,
+ grpc.ErrorDesc(ErrGRPCRoleNotFound): ErrGRPCRoleNotFound,
+ grpc.ErrorDesc(ErrGRPCAuthFailed): ErrGRPCAuthFailed,
+ grpc.ErrorDesc(ErrGRPCPermissionDenied): ErrGRPCPermissionDenied,
+ grpc.ErrorDesc(ErrGRPCRoleNotGranted): ErrGRPCRoleNotGranted,
+ grpc.ErrorDesc(ErrGRPCPermissionNotGranted): ErrGRPCPermissionNotGranted,
+ grpc.ErrorDesc(ErrGRPCAuthNotEnabled): ErrGRPCAuthNotEnabled,
+ grpc.ErrorDesc(ErrGRPCInvalidAuthToken): ErrGRPCInvalidAuthToken,
+ grpc.ErrorDesc(ErrGRPCInvalidAuthMgmt): ErrGRPCInvalidAuthMgmt,
+
+ grpc.ErrorDesc(ErrGRPCNoLeader): ErrGRPCNoLeader,
+ grpc.ErrorDesc(ErrGRPCNotCapable): ErrGRPCNotCapable,
+ grpc.ErrorDesc(ErrGRPCStopped): ErrGRPCStopped,
+ grpc.ErrorDesc(ErrGRPCTimeout): ErrGRPCTimeout,
+ grpc.ErrorDesc(ErrGRPCTimeoutDueToLeaderFail): ErrGRPCTimeoutDueToLeaderFail,
+ grpc.ErrorDesc(ErrGRPCTimeoutDueToConnectionLost): ErrGRPCTimeoutDueToConnectionLost,
+ grpc.ErrorDesc(ErrGRPCUnhealthy): ErrGRPCUnhealthy,
+ }
+
+ // client-side error
+ ErrEmptyKey = Error(ErrGRPCEmptyKey)
+ ErrKeyNotFound = Error(ErrGRPCKeyNotFound)
+ ErrValueProvided = Error(ErrGRPCValueProvided)
+ ErrLeaseProvided = Error(ErrGRPCLeaseProvided)
+ ErrTooManyOps = Error(ErrGRPCTooManyOps)
+ ErrDuplicateKey = Error(ErrGRPCDuplicateKey)
+ ErrCompacted = Error(ErrGRPCCompacted)
+ ErrFutureRev = Error(ErrGRPCFutureRev)
+ ErrNoSpace = Error(ErrGRPCNoSpace)
+
+ ErrLeaseNotFound = Error(ErrGRPCLeaseNotFound)
+ ErrLeaseExist = Error(ErrGRPCLeaseExist)
+
+ ErrMemberExist = Error(ErrGRPCMemberExist)
+ ErrPeerURLExist = Error(ErrGRPCPeerURLExist)
+ ErrMemberNotEnoughStarted = Error(ErrGRPCMemberNotEnoughStarted)
+ ErrMemberBadURLs = Error(ErrGRPCMemberBadURLs)
+ ErrMemberNotFound = Error(ErrGRPCMemberNotFound)
+
+ ErrRequestTooLarge = Error(ErrGRPCRequestTooLarge)
+ ErrTooManyRequests = Error(ErrGRPCRequestTooManyRequests)
+
+ ErrRootUserNotExist = Error(ErrGRPCRootUserNotExist)
+ ErrRootRoleNotExist = Error(ErrGRPCRootRoleNotExist)
+ ErrUserAlreadyExist = Error(ErrGRPCUserAlreadyExist)
+ ErrUserEmpty = Error(ErrGRPCUserEmpty)
+ ErrUserNotFound = Error(ErrGRPCUserNotFound)
+ ErrRoleAlreadyExist = Error(ErrGRPCRoleAlreadyExist)
+ ErrRoleNotFound = Error(ErrGRPCRoleNotFound)
+ ErrAuthFailed = Error(ErrGRPCAuthFailed)
+ ErrPermissionDenied = Error(ErrGRPCPermissionDenied)
+ ErrRoleNotGranted = Error(ErrGRPCRoleNotGranted)
+ ErrPermissionNotGranted = Error(ErrGRPCPermissionNotGranted)
+ ErrAuthNotEnabled = Error(ErrGRPCAuthNotEnabled)
+ ErrInvalidAuthToken = Error(ErrGRPCInvalidAuthToken)
+ ErrInvalidAuthMgmt = Error(ErrGRPCInvalidAuthMgmt)
+
+ ErrNoLeader = Error(ErrGRPCNoLeader)
+ ErrNotCapable = Error(ErrGRPCNotCapable)
+ ErrStopped = Error(ErrGRPCStopped)
+ ErrTimeout = Error(ErrGRPCTimeout)
+ ErrTimeoutDueToLeaderFail = Error(ErrGRPCTimeoutDueToLeaderFail)
+ ErrTimeoutDueToConnectionLost = Error(ErrGRPCTimeoutDueToConnectionLost)
+ ErrUnhealthy = Error(ErrGRPCUnhealthy)
+)
+
+// EtcdError defines gRPC server errors.
+// (https://github.com/grpc/grpc-go/blob/master/rpc_util.go#L319-L323)
+type EtcdError struct {
+ code codes.Code
+ desc string
+}
+
+// Code returns grpc/codes.Code.
+// TODO: define clientv3/codes.Code.
+func (e EtcdError) Code() codes.Code {
+ return e.code
+}
+
+func (e EtcdError) Error() string {
+ return e.desc
+}
+
+func Error(err error) error {
+ if err == nil {
+ return nil
+ }
+ verr, ok := errStringToError[grpc.ErrorDesc(err)]
+ if !ok { // not gRPC error
+ return err
+ }
+ return EtcdError{code: grpc.Code(verr), desc: grpc.ErrorDesc(verr)}
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/error_test.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/error_test.go
new file mode 100644
index 00000000..b1097c33
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/error_test.go
@@ -0,0 +1,42 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 rpctypes
+
+import (
+ "testing"
+
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+)
+
+func TestConvert(t *testing.T) {
+ e1 := grpc.Errorf(codes.InvalidArgument, "etcdserver: key is not provided")
+ e2 := ErrGRPCEmptyKey
+ e3 := ErrEmptyKey
+
+ if e1.Error() != e2.Error() {
+ t.Fatalf("expected %q == %q", e1.Error(), e2.Error())
+ }
+ if grpc.Code(e1) != e3.(EtcdError).Code() {
+ t.Fatalf("expected them to be equal, got %v / %v", grpc.Code(e1), e3.(EtcdError).Code())
+ }
+
+ if e1.Error() == e3.Error() {
+ t.Fatalf("expected %q != %q", e1.Error(), e3.Error())
+ }
+ if grpc.Code(e2) != e3.(EtcdError).Code() {
+ t.Fatalf("expected them to be equal, got %v / %v", grpc.Code(e2), e3.(EtcdError).Code())
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/md.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/md.go
new file mode 100644
index 00000000..5c590e1a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes/md.go
@@ -0,0 +1,20 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 rpctypes
+
+var (
+ MetadataRequireLeaderKey = "hasleader"
+ MetadataHasLeader = "true"
+)
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/util.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/util.go
new file mode 100644
index 00000000..8d38d9bd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/util.go
@@ -0,0 +1,103 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 v3rpc
+
+import (
+ "github.com/coreos/etcd/auth"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+)
+
+func togRPCError(err error) error {
+ switch err {
+ case membership.ErrIDRemoved:
+ return rpctypes.ErrGRPCMemberNotFound
+ case membership.ErrIDNotFound:
+ return rpctypes.ErrGRPCMemberNotFound
+ case membership.ErrIDExists:
+ return rpctypes.ErrGRPCMemberExist
+ case membership.ErrPeerURLexists:
+ return rpctypes.ErrGRPCPeerURLExist
+ case etcdserver.ErrNotEnoughStartedMembers:
+ return rpctypes.ErrMemberNotEnoughStarted
+
+ case mvcc.ErrCompacted:
+ return rpctypes.ErrGRPCCompacted
+ case mvcc.ErrFutureRev:
+ return rpctypes.ErrGRPCFutureRev
+ case etcdserver.ErrRequestTooLarge:
+ return rpctypes.ErrGRPCRequestTooLarge
+ case etcdserver.ErrNoSpace:
+ return rpctypes.ErrGRPCNoSpace
+ case etcdserver.ErrTooManyRequests:
+ return rpctypes.ErrTooManyRequests
+
+ case etcdserver.ErrNoLeader:
+ return rpctypes.ErrGRPCNoLeader
+ case etcdserver.ErrStopped:
+ return rpctypes.ErrGRPCStopped
+ case etcdserver.ErrTimeout:
+ return rpctypes.ErrGRPCTimeout
+ case etcdserver.ErrTimeoutDueToLeaderFail:
+ return rpctypes.ErrGRPCTimeoutDueToLeaderFail
+ case etcdserver.ErrTimeoutDueToConnectionLost:
+ return rpctypes.ErrGRPCTimeoutDueToConnectionLost
+ case etcdserver.ErrUnhealthy:
+ return rpctypes.ErrGRPCUnhealthy
+ case etcdserver.ErrKeyNotFound:
+ return rpctypes.ErrGRPCKeyNotFound
+
+ case lease.ErrLeaseNotFound:
+ return rpctypes.ErrGRPCLeaseNotFound
+ case lease.ErrLeaseExists:
+ return rpctypes.ErrGRPCLeaseExist
+
+ case auth.ErrRootUserNotExist:
+ return rpctypes.ErrGRPCRootUserNotExist
+ case auth.ErrRootRoleNotExist:
+ return rpctypes.ErrGRPCRootRoleNotExist
+ case auth.ErrUserAlreadyExist:
+ return rpctypes.ErrGRPCUserAlreadyExist
+ case auth.ErrUserEmpty:
+ return rpctypes.ErrGRPCUserEmpty
+ case auth.ErrUserNotFound:
+ return rpctypes.ErrGRPCUserNotFound
+ case auth.ErrRoleAlreadyExist:
+ return rpctypes.ErrGRPCRoleAlreadyExist
+ case auth.ErrRoleNotFound:
+ return rpctypes.ErrGRPCRoleNotFound
+ case auth.ErrAuthFailed:
+ return rpctypes.ErrGRPCAuthFailed
+ case auth.ErrPermissionDenied:
+ return rpctypes.ErrGRPCPermissionDenied
+ case auth.ErrRoleNotGranted:
+ return rpctypes.ErrGRPCRoleNotGranted
+ case auth.ErrPermissionNotGranted:
+ return rpctypes.ErrGRPCPermissionNotGranted
+ case auth.ErrAuthNotEnabled:
+ return rpctypes.ErrGRPCAuthNotEnabled
+ case auth.ErrInvalidAuthToken:
+ return rpctypes.ErrGRPCInvalidAuthToken
+ case auth.ErrInvalidAuthMgmt:
+ return rpctypes.ErrGRPCInvalidAuthMgmt
+ default:
+ return grpc.Errorf(codes.Unknown, err.Error())
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/watch.go b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/watch.go
new file mode 100644
index 00000000..84c0a5ea
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/api/v3rpc/watch.go
@@ -0,0 +1,426 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 v3rpc
+
+import (
+ "io"
+ "sync"
+ "time"
+
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/auth"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/mvcc"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+)
+
+type watchServer struct {
+ clusterID int64
+ memberID int64
+ raftTimer etcdserver.RaftTimer
+ watchable mvcc.WatchableKV
+
+ ag AuthGetter
+}
+
+func NewWatchServer(s *etcdserver.EtcdServer) pb.WatchServer {
+ return &watchServer{
+ clusterID: int64(s.Cluster().ID()),
+ memberID: int64(s.ID()),
+ raftTimer: s,
+ watchable: s.Watchable(),
+ ag: s,
+ }
+}
+
+var (
+ // External test can read this with GetProgressReportInterval()
+ // and change this to a small value to finish fast with
+ // SetProgressReportInterval().
+ progressReportInterval = 10 * time.Minute
+ progressReportIntervalMu sync.RWMutex
+)
+
+func GetProgressReportInterval() time.Duration {
+ progressReportIntervalMu.RLock()
+ defer progressReportIntervalMu.RUnlock()
+ return progressReportInterval
+}
+
+func SetProgressReportInterval(newTimeout time.Duration) {
+ progressReportIntervalMu.Lock()
+ defer progressReportIntervalMu.Unlock()
+ progressReportInterval = newTimeout
+}
+
+const (
+ // We send ctrl response inside the read loop. We do not want
+ // send to block read, but we still want ctrl response we sent to
+ // be serialized. Thus we use a buffered chan to solve the problem.
+ // A small buffer should be OK for most cases, since we expect the
+ // ctrl requests are infrequent.
+ ctrlStreamBufLen = 16
+)
+
+// serverWatchStream is an etcd server side stream. It receives requests
+// from client side gRPC stream. It receives watch events from mvcc.WatchStream,
+// and creates responses that forwarded to gRPC stream.
+// It also forwards control message like watch created and canceled.
+type serverWatchStream struct {
+ clusterID int64
+ memberID int64
+ raftTimer etcdserver.RaftTimer
+
+ watchable mvcc.WatchableKV
+
+ gRPCStream pb.Watch_WatchServer
+ watchStream mvcc.WatchStream
+ ctrlStream chan *pb.WatchResponse
+
+ // mu protects progress, prevKV
+ mu sync.Mutex
+ // progress tracks the watchID that stream might need to send
+ // progress to.
+ // TODO: combine progress and prevKV into a single struct?
+ progress map[mvcc.WatchID]bool
+ prevKV map[mvcc.WatchID]bool
+
+ // closec indicates the stream is closed.
+ closec chan struct{}
+
+ // wg waits for the send loop to complete
+ wg sync.WaitGroup
+
+ ag AuthGetter
+}
+
+func (ws *watchServer) Watch(stream pb.Watch_WatchServer) (err error) {
+ sws := serverWatchStream{
+ clusterID: ws.clusterID,
+ memberID: ws.memberID,
+ raftTimer: ws.raftTimer,
+
+ watchable: ws.watchable,
+
+ gRPCStream: stream,
+ watchStream: ws.watchable.NewWatchStream(),
+ // chan for sending control response like watcher created and canceled.
+ ctrlStream: make(chan *pb.WatchResponse, ctrlStreamBufLen),
+ progress: make(map[mvcc.WatchID]bool),
+ prevKV: make(map[mvcc.WatchID]bool),
+ closec: make(chan struct{}),
+
+ ag: ws.ag,
+ }
+
+ sws.wg.Add(1)
+ go func() {
+ sws.sendLoop()
+ sws.wg.Done()
+ }()
+
+ errc := make(chan error, 1)
+ // Ideally recvLoop would also use sws.wg to signal its completion
+ // but when stream.Context().Done() is closed, the stream's recv
+ // may continue to block since it uses a different context, leading to
+ // deadlock when calling sws.close().
+ go func() {
+ if rerr := sws.recvLoop(); rerr != nil {
+ errc <- rerr
+ }
+ }()
+ select {
+ case err = <-errc:
+ close(sws.ctrlStream)
+ case <-stream.Context().Done():
+ err = stream.Context().Err()
+ // the only server-side cancellation is noleader for now.
+ if err == context.Canceled {
+ err = rpctypes.ErrGRPCNoLeader
+ }
+ }
+ sws.close()
+ return err
+}
+
+func (sws *serverWatchStream) isWatchPermitted(wcr *pb.WatchCreateRequest) bool {
+ authInfo, err := sws.ag.AuthInfoFromCtx(sws.gRPCStream.Context())
+ if err != nil {
+ return false
+ }
+ if authInfo == nil {
+ // if auth is enabled, IsRangePermitted() can cause an error
+ authInfo = &auth.AuthInfo{}
+ }
+
+ return sws.ag.AuthStore().IsRangePermitted(authInfo, wcr.Key, wcr.RangeEnd) == nil
+}
+
+func (sws *serverWatchStream) recvLoop() error {
+ for {
+ req, err := sws.gRPCStream.Recv()
+ if err == io.EOF {
+ return nil
+ }
+ if err != nil {
+ return err
+ }
+
+ switch uv := req.RequestUnion.(type) {
+ case *pb.WatchRequest_CreateRequest:
+ if uv.CreateRequest == nil {
+ break
+ }
+
+ creq := uv.CreateRequest
+ if len(creq.Key) == 0 {
+ // \x00 is the smallest key
+ creq.Key = []byte{0}
+ }
+ if len(creq.RangeEnd) == 0 {
+ // force nil since watchstream.Watch distinguishes
+ // between nil and []byte{} for single key / >=
+ creq.RangeEnd = nil
+ }
+ if len(creq.RangeEnd) == 1 && creq.RangeEnd[0] == 0 {
+ // support >= key queries
+ creq.RangeEnd = []byte{}
+ }
+
+ if !sws.isWatchPermitted(creq) {
+ wr := &pb.WatchResponse{
+ Header: sws.newResponseHeader(sws.watchStream.Rev()),
+ WatchId: -1,
+ Canceled: true,
+ Created: true,
+ CancelReason: rpctypes.ErrGRPCPermissionDenied.Error(),
+ }
+
+ select {
+ case sws.ctrlStream <- wr:
+ case <-sws.closec:
+ }
+ return nil
+ }
+
+ filters := FiltersFromRequest(creq)
+
+ wsrev := sws.watchStream.Rev()
+ rev := creq.StartRevision
+ if rev == 0 {
+ rev = wsrev + 1
+ }
+ id := sws.watchStream.Watch(creq.Key, creq.RangeEnd, rev, filters...)
+ if id != -1 {
+ sws.mu.Lock()
+ if creq.ProgressNotify {
+ sws.progress[id] = true
+ }
+ if creq.PrevKv {
+ sws.prevKV[id] = true
+ }
+ sws.mu.Unlock()
+ }
+ wr := &pb.WatchResponse{
+ Header: sws.newResponseHeader(wsrev),
+ WatchId: int64(id),
+ Created: true,
+ Canceled: id == -1,
+ }
+ select {
+ case sws.ctrlStream <- wr:
+ case <-sws.closec:
+ return nil
+ }
+ case *pb.WatchRequest_CancelRequest:
+ if uv.CancelRequest != nil {
+ id := uv.CancelRequest.WatchId
+ err := sws.watchStream.Cancel(mvcc.WatchID(id))
+ if err == nil {
+ sws.ctrlStream <- &pb.WatchResponse{
+ Header: sws.newResponseHeader(sws.watchStream.Rev()),
+ WatchId: id,
+ Canceled: true,
+ }
+ sws.mu.Lock()
+ delete(sws.progress, mvcc.WatchID(id))
+ delete(sws.prevKV, mvcc.WatchID(id))
+ sws.mu.Unlock()
+ }
+ }
+ default:
+ // we probably should not shutdown the entire stream when
+ // receive an valid command.
+ // so just do nothing instead.
+ continue
+ }
+ }
+}
+
+func (sws *serverWatchStream) sendLoop() {
+ // watch ids that are currently active
+ ids := make(map[mvcc.WatchID]struct{})
+ // watch responses pending on a watch id creation message
+ pending := make(map[mvcc.WatchID][]*pb.WatchResponse)
+
+ interval := GetProgressReportInterval()
+ progressTicker := time.NewTicker(interval)
+
+ defer func() {
+ progressTicker.Stop()
+ // drain the chan to clean up pending events
+ for ws := range sws.watchStream.Chan() {
+ mvcc.ReportEventReceived(len(ws.Events))
+ }
+ for _, wrs := range pending {
+ for _, ws := range wrs {
+ mvcc.ReportEventReceived(len(ws.Events))
+ }
+ }
+ }()
+
+ for {
+ select {
+ case wresp, ok := <-sws.watchStream.Chan():
+ if !ok {
+ return
+ }
+
+ // TODO: evs is []mvccpb.Event type
+ // either return []*mvccpb.Event from the mvcc package
+ // or define protocol buffer with []mvccpb.Event.
+ evs := wresp.Events
+ events := make([]*mvccpb.Event, len(evs))
+ sws.mu.Lock()
+ needPrevKV := sws.prevKV[wresp.WatchID]
+ sws.mu.Unlock()
+ for i := range evs {
+ events[i] = &evs[i]
+
+ if needPrevKV {
+ opt := mvcc.RangeOptions{Rev: evs[i].Kv.ModRevision - 1}
+ r, err := sws.watchable.Range(evs[i].Kv.Key, nil, opt)
+ if err == nil && len(r.KVs) != 0 {
+ events[i].PrevKv = &(r.KVs[0])
+ }
+ }
+ }
+
+ wr := &pb.WatchResponse{
+ Header: sws.newResponseHeader(wresp.Revision),
+ WatchId: int64(wresp.WatchID),
+ Events: events,
+ CompactRevision: wresp.CompactRevision,
+ }
+
+ if _, hasId := ids[wresp.WatchID]; !hasId {
+ // buffer if id not yet announced
+ wrs := append(pending[wresp.WatchID], wr)
+ pending[wresp.WatchID] = wrs
+ continue
+ }
+
+ mvcc.ReportEventReceived(len(evs))
+ if err := sws.gRPCStream.Send(wr); err != nil {
+ return
+ }
+
+ sws.mu.Lock()
+ if len(evs) > 0 && sws.progress[wresp.WatchID] {
+ // elide next progress update if sent a key update
+ sws.progress[wresp.WatchID] = false
+ }
+ sws.mu.Unlock()
+
+ case c, ok := <-sws.ctrlStream:
+ if !ok {
+ return
+ }
+
+ if err := sws.gRPCStream.Send(c); err != nil {
+ return
+ }
+
+ // track id creation
+ wid := mvcc.WatchID(c.WatchId)
+ if c.Canceled {
+ delete(ids, wid)
+ continue
+ }
+ if c.Created {
+ // flush buffered events
+ ids[wid] = struct{}{}
+ for _, v := range pending[wid] {
+ mvcc.ReportEventReceived(len(v.Events))
+ if err := sws.gRPCStream.Send(v); err != nil {
+ return
+ }
+ }
+ delete(pending, wid)
+ }
+ case <-progressTicker.C:
+ sws.mu.Lock()
+ for id, ok := range sws.progress {
+ if ok {
+ sws.watchStream.RequestProgress(id)
+ }
+ sws.progress[id] = true
+ }
+ sws.mu.Unlock()
+ case <-sws.closec:
+ return
+ }
+ }
+}
+
+func (sws *serverWatchStream) close() {
+ sws.watchStream.Close()
+ close(sws.closec)
+ sws.wg.Wait()
+}
+
+func (sws *serverWatchStream) newResponseHeader(rev int64) *pb.ResponseHeader {
+ return &pb.ResponseHeader{
+ ClusterId: uint64(sws.clusterID),
+ MemberId: uint64(sws.memberID),
+ Revision: rev,
+ RaftTerm: sws.raftTimer.Term(),
+ }
+}
+
+func filterNoDelete(e mvccpb.Event) bool {
+ return e.Type == mvccpb.DELETE
+}
+
+func filterNoPut(e mvccpb.Event) bool {
+ return e.Type == mvccpb.PUT
+}
+
+func FiltersFromRequest(creq *pb.WatchCreateRequest) []mvcc.FilterFunc {
+ filters := make([]mvcc.FilterFunc, 0, len(creq.Filters))
+ for _, ft := range creq.Filters {
+ switch ft {
+ case pb.WatchCreateRequest_NOPUT:
+ filters = append(filters, filterNoPut)
+ case pb.WatchCreateRequest_NODELETE:
+ filters = append(filters, filterNoDelete)
+ default:
+ }
+ }
+ return filters
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/apply.go b/vendor/github.com/coreos/etcd/etcdserver/apply.go
new file mode 100644
index 00000000..0be93c52
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/apply.go
@@ -0,0 +1,878 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "bytes"
+ "sort"
+ "time"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/gogo/protobuf/proto"
+ "golang.org/x/net/context"
+)
+
+const (
+ warnApplyDuration = 100 * time.Millisecond
+)
+
+type applyResult struct {
+ resp proto.Message
+ err error
+ // physc signals the physical effect of the request has completed in addition
+ // to being logically reflected by the node. Currently only used for
+ // Compaction requests.
+ physc <-chan struct{}
+}
+
+// applierV3 is the interface for processing V3 raft messages
+type applierV3 interface {
+ Apply(r *pb.InternalRaftRequest) *applyResult
+
+ Put(txn mvcc.TxnWrite, p *pb.PutRequest) (*pb.PutResponse, error)
+ Range(txn mvcc.TxnRead, r *pb.RangeRequest) (*pb.RangeResponse, error)
+ DeleteRange(txn mvcc.TxnWrite, dr *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error)
+ Txn(rt *pb.TxnRequest) (*pb.TxnResponse, error)
+ Compaction(compaction *pb.CompactionRequest) (*pb.CompactionResponse, <-chan struct{}, error)
+
+ LeaseGrant(lc *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error)
+ LeaseRevoke(lc *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error)
+
+ Alarm(*pb.AlarmRequest) (*pb.AlarmResponse, error)
+
+ Authenticate(r *pb.InternalAuthenticateRequest) (*pb.AuthenticateResponse, error)
+
+ AuthEnable() (*pb.AuthEnableResponse, error)
+ AuthDisable() (*pb.AuthDisableResponse, error)
+
+ UserAdd(ua *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error)
+ UserDelete(ua *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error)
+ UserChangePassword(ua *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error)
+ UserGrantRole(ua *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error)
+ UserGet(ua *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error)
+ UserRevokeRole(ua *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error)
+ RoleAdd(ua *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error)
+ RoleGrantPermission(ua *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error)
+ RoleGet(ua *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error)
+ RoleRevokePermission(ua *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error)
+ RoleDelete(ua *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error)
+ UserList(ua *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error)
+ RoleList(ua *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error)
+}
+
+type applierV3backend struct {
+ s *EtcdServer
+}
+
+func (s *EtcdServer) newApplierV3() applierV3 {
+ return newAuthApplierV3(
+ s.AuthStore(),
+ newQuotaApplierV3(s, &applierV3backend{s}),
+ )
+}
+
+func (a *applierV3backend) Apply(r *pb.InternalRaftRequest) *applyResult {
+ ar := &applyResult{}
+
+ // call into a.s.applyV3.F instead of a.F so upper appliers can check individual calls
+ switch {
+ case r.Range != nil:
+ ar.resp, ar.err = a.s.applyV3.Range(nil, r.Range)
+ case r.Put != nil:
+ ar.resp, ar.err = a.s.applyV3.Put(nil, r.Put)
+ case r.DeleteRange != nil:
+ ar.resp, ar.err = a.s.applyV3.DeleteRange(nil, r.DeleteRange)
+ case r.Txn != nil:
+ ar.resp, ar.err = a.s.applyV3.Txn(r.Txn)
+ case r.Compaction != nil:
+ ar.resp, ar.physc, ar.err = a.s.applyV3.Compaction(r.Compaction)
+ case r.LeaseGrant != nil:
+ ar.resp, ar.err = a.s.applyV3.LeaseGrant(r.LeaseGrant)
+ case r.LeaseRevoke != nil:
+ ar.resp, ar.err = a.s.applyV3.LeaseRevoke(r.LeaseRevoke)
+ case r.Alarm != nil:
+ ar.resp, ar.err = a.s.applyV3.Alarm(r.Alarm)
+ case r.Authenticate != nil:
+ ar.resp, ar.err = a.s.applyV3.Authenticate(r.Authenticate)
+ case r.AuthEnable != nil:
+ ar.resp, ar.err = a.s.applyV3.AuthEnable()
+ case r.AuthDisable != nil:
+ ar.resp, ar.err = a.s.applyV3.AuthDisable()
+ case r.AuthUserAdd != nil:
+ ar.resp, ar.err = a.s.applyV3.UserAdd(r.AuthUserAdd)
+ case r.AuthUserDelete != nil:
+ ar.resp, ar.err = a.s.applyV3.UserDelete(r.AuthUserDelete)
+ case r.AuthUserChangePassword != nil:
+ ar.resp, ar.err = a.s.applyV3.UserChangePassword(r.AuthUserChangePassword)
+ case r.AuthUserGrantRole != nil:
+ ar.resp, ar.err = a.s.applyV3.UserGrantRole(r.AuthUserGrantRole)
+ case r.AuthUserGet != nil:
+ ar.resp, ar.err = a.s.applyV3.UserGet(r.AuthUserGet)
+ case r.AuthUserRevokeRole != nil:
+ ar.resp, ar.err = a.s.applyV3.UserRevokeRole(r.AuthUserRevokeRole)
+ case r.AuthRoleAdd != nil:
+ ar.resp, ar.err = a.s.applyV3.RoleAdd(r.AuthRoleAdd)
+ case r.AuthRoleGrantPermission != nil:
+ ar.resp, ar.err = a.s.applyV3.RoleGrantPermission(r.AuthRoleGrantPermission)
+ case r.AuthRoleGet != nil:
+ ar.resp, ar.err = a.s.applyV3.RoleGet(r.AuthRoleGet)
+ case r.AuthRoleRevokePermission != nil:
+ ar.resp, ar.err = a.s.applyV3.RoleRevokePermission(r.AuthRoleRevokePermission)
+ case r.AuthRoleDelete != nil:
+ ar.resp, ar.err = a.s.applyV3.RoleDelete(r.AuthRoleDelete)
+ case r.AuthUserList != nil:
+ ar.resp, ar.err = a.s.applyV3.UserList(r.AuthUserList)
+ case r.AuthRoleList != nil:
+ ar.resp, ar.err = a.s.applyV3.RoleList(r.AuthRoleList)
+ default:
+ panic("not implemented")
+ }
+ return ar
+}
+
+func (a *applierV3backend) Put(txn mvcc.TxnWrite, p *pb.PutRequest) (resp *pb.PutResponse, err error) {
+ resp = &pb.PutResponse{}
+ resp.Header = &pb.ResponseHeader{}
+
+ val, leaseID := p.Value, lease.LeaseID(p.Lease)
+ if txn == nil {
+ if leaseID != lease.NoLease {
+ if l := a.s.lessor.Lookup(leaseID); l == nil {
+ return nil, lease.ErrLeaseNotFound
+ }
+ }
+ txn = a.s.KV().Write()
+ defer txn.End()
+ }
+
+ var rr *mvcc.RangeResult
+ if p.IgnoreValue || p.IgnoreLease || p.PrevKv {
+ rr, err = txn.Range(p.Key, nil, mvcc.RangeOptions{})
+ if err != nil {
+ return nil, err
+ }
+ }
+ if p.IgnoreValue || p.IgnoreLease {
+ if rr == nil || len(rr.KVs) == 0 {
+ // ignore_{lease,value} flag expects previous key-value pair
+ return nil, ErrKeyNotFound
+ }
+ }
+ if p.IgnoreValue {
+ val = rr.KVs[0].Value
+ }
+ if p.IgnoreLease {
+ leaseID = lease.LeaseID(rr.KVs[0].Lease)
+ }
+ if p.PrevKv {
+ if rr != nil && len(rr.KVs) != 0 {
+ resp.PrevKv = &rr.KVs[0]
+ }
+ }
+
+ resp.Header.Revision = txn.Put(p.Key, val, leaseID)
+ return resp, nil
+}
+
+func (a *applierV3backend) DeleteRange(txn mvcc.TxnWrite, dr *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error) {
+ resp := &pb.DeleteRangeResponse{}
+ resp.Header = &pb.ResponseHeader{}
+
+ if txn == nil {
+ txn = a.s.kv.Write()
+ defer txn.End()
+ }
+
+ if isGteRange(dr.RangeEnd) {
+ dr.RangeEnd = []byte{}
+ }
+
+ if dr.PrevKv {
+ rr, err := txn.Range(dr.Key, dr.RangeEnd, mvcc.RangeOptions{})
+ if err != nil {
+ return nil, err
+ }
+ if rr != nil {
+ for i := range rr.KVs {
+ resp.PrevKvs = append(resp.PrevKvs, &rr.KVs[i])
+ }
+ }
+ }
+
+ resp.Deleted, resp.Header.Revision = txn.DeleteRange(dr.Key, dr.RangeEnd)
+ return resp, nil
+}
+
+func (a *applierV3backend) Range(txn mvcc.TxnRead, r *pb.RangeRequest) (*pb.RangeResponse, error) {
+ resp := &pb.RangeResponse{}
+ resp.Header = &pb.ResponseHeader{}
+
+ if txn == nil {
+ txn = a.s.kv.Read()
+ defer txn.End()
+ }
+
+ if isGteRange(r.RangeEnd) {
+ r.RangeEnd = []byte{}
+ }
+
+ limit := r.Limit
+ if r.SortOrder != pb.RangeRequest_NONE ||
+ r.MinModRevision != 0 || r.MaxModRevision != 0 ||
+ r.MinCreateRevision != 0 || r.MaxCreateRevision != 0 {
+ // fetch everything; sort and truncate afterwards
+ limit = 0
+ }
+ if limit > 0 {
+ // fetch one extra for 'more' flag
+ limit = limit + 1
+ }
+
+ ro := mvcc.RangeOptions{
+ Limit: limit,
+ Rev: r.Revision,
+ Count: r.CountOnly,
+ }
+
+ rr, err := txn.Range(r.Key, r.RangeEnd, ro)
+ if err != nil {
+ return nil, err
+ }
+
+ if r.MaxModRevision != 0 {
+ f := func(kv *mvccpb.KeyValue) bool { return kv.ModRevision > r.MaxModRevision }
+ pruneKVs(rr, f)
+ }
+ if r.MinModRevision != 0 {
+ f := func(kv *mvccpb.KeyValue) bool { return kv.ModRevision < r.MinModRevision }
+ pruneKVs(rr, f)
+ }
+ if r.MaxCreateRevision != 0 {
+ f := func(kv *mvccpb.KeyValue) bool { return kv.CreateRevision > r.MaxCreateRevision }
+ pruneKVs(rr, f)
+ }
+ if r.MinCreateRevision != 0 {
+ f := func(kv *mvccpb.KeyValue) bool { return kv.CreateRevision < r.MinCreateRevision }
+ pruneKVs(rr, f)
+ }
+
+ sortOrder := r.SortOrder
+ if r.SortTarget != pb.RangeRequest_KEY && sortOrder == pb.RangeRequest_NONE {
+ // Since current mvcc.Range implementation returns results
+ // sorted by keys in lexiographically ascending order,
+ // sort ASCEND by default only when target is not 'KEY'
+ sortOrder = pb.RangeRequest_ASCEND
+ }
+ if sortOrder != pb.RangeRequest_NONE {
+ var sorter sort.Interface
+ switch {
+ case r.SortTarget == pb.RangeRequest_KEY:
+ sorter = &kvSortByKey{&kvSort{rr.KVs}}
+ case r.SortTarget == pb.RangeRequest_VERSION:
+ sorter = &kvSortByVersion{&kvSort{rr.KVs}}
+ case r.SortTarget == pb.RangeRequest_CREATE:
+ sorter = &kvSortByCreate{&kvSort{rr.KVs}}
+ case r.SortTarget == pb.RangeRequest_MOD:
+ sorter = &kvSortByMod{&kvSort{rr.KVs}}
+ case r.SortTarget == pb.RangeRequest_VALUE:
+ sorter = &kvSortByValue{&kvSort{rr.KVs}}
+ }
+ switch {
+ case sortOrder == pb.RangeRequest_ASCEND:
+ sort.Sort(sorter)
+ case sortOrder == pb.RangeRequest_DESCEND:
+ sort.Sort(sort.Reverse(sorter))
+ }
+ }
+
+ if r.Limit > 0 && len(rr.KVs) > int(r.Limit) {
+ rr.KVs = rr.KVs[:r.Limit]
+ resp.More = true
+ }
+
+ resp.Header.Revision = rr.Rev
+ resp.Count = int64(rr.Count)
+ for i := range rr.KVs {
+ if r.KeysOnly {
+ rr.KVs[i].Value = nil
+ }
+ resp.Kvs = append(resp.Kvs, &rr.KVs[i])
+ }
+ return resp, nil
+}
+
+func (a *applierV3backend) Txn(rt *pb.TxnRequest) (*pb.TxnResponse, error) {
+ isWrite := !isTxnReadonly(rt)
+ txn := mvcc.NewReadOnlyTxnWrite(a.s.KV().Read())
+
+ reqs, ok := a.compareToOps(txn, rt)
+ if isWrite {
+ if err := a.checkRequestPut(txn, reqs); err != nil {
+ txn.End()
+ return nil, err
+ }
+ }
+ if err := checkRequestRange(txn, reqs); err != nil {
+ txn.End()
+ return nil, err
+ }
+
+ resps := make([]*pb.ResponseOp, len(reqs))
+ txnResp := &pb.TxnResponse{
+ Responses: resps,
+ Succeeded: ok,
+ Header: &pb.ResponseHeader{},
+ }
+
+ // When executing mutable txn ops, etcd must hold the txn lock so
+ // readers do not see any intermediate results. Since writes are
+ // serialized on the raft loop, the revision in the read view will
+ // be the revision of the write txn.
+ if isWrite {
+ txn.End()
+ txn = a.s.KV().Write()
+ }
+ for i := range reqs {
+ resps[i] = a.applyUnion(txn, reqs[i])
+ }
+ rev := txn.Rev()
+ if len(txn.Changes()) != 0 {
+ rev++
+ }
+ txn.End()
+
+ txnResp.Header.Revision = rev
+ return txnResp, nil
+}
+
+func (a *applierV3backend) compareToOps(rv mvcc.ReadView, rt *pb.TxnRequest) ([]*pb.RequestOp, bool) {
+ for _, c := range rt.Compare {
+ if !applyCompare(rv, c) {
+ return rt.Failure, false
+ }
+ }
+ return rt.Success, true
+}
+
+// applyCompare applies the compare request.
+// If the comparison succeeds, it returns true. Otherwise, returns false.
+func applyCompare(rv mvcc.ReadView, c *pb.Compare) bool {
+ rr, err := rv.Range(c.Key, nil, mvcc.RangeOptions{})
+ if err != nil {
+ return false
+ }
+ var ckv mvccpb.KeyValue
+ if len(rr.KVs) != 0 {
+ ckv = rr.KVs[0]
+ } else {
+ // Use the zero value of ckv normally. However...
+ if c.Target == pb.Compare_VALUE {
+ // Always fail if we're comparing a value on a key that doesn't exist.
+ // We can treat non-existence as the empty set explicitly, such that
+ // even a key with a value of length 0 bytes is still a real key
+ // that was written that way
+ return false
+ }
+ }
+
+ // -1 is less, 0 is equal, 1 is greater
+ var result int
+ switch c.Target {
+ case pb.Compare_VALUE:
+ tv, _ := c.TargetUnion.(*pb.Compare_Value)
+ if tv != nil {
+ result = bytes.Compare(ckv.Value, tv.Value)
+ }
+ case pb.Compare_CREATE:
+ tv, _ := c.TargetUnion.(*pb.Compare_CreateRevision)
+ if tv != nil {
+ result = compareInt64(ckv.CreateRevision, tv.CreateRevision)
+ }
+
+ case pb.Compare_MOD:
+ tv, _ := c.TargetUnion.(*pb.Compare_ModRevision)
+ if tv != nil {
+ result = compareInt64(ckv.ModRevision, tv.ModRevision)
+ }
+ case pb.Compare_VERSION:
+ tv, _ := c.TargetUnion.(*pb.Compare_Version)
+ if tv != nil {
+ result = compareInt64(ckv.Version, tv.Version)
+ }
+ }
+
+ switch c.Result {
+ case pb.Compare_EQUAL:
+ return result == 0
+ case pb.Compare_NOT_EQUAL:
+ return result != 0
+ case pb.Compare_GREATER:
+ return result > 0
+ case pb.Compare_LESS:
+ return result < 0
+ }
+ return true
+}
+
+func (a *applierV3backend) applyUnion(txn mvcc.TxnWrite, union *pb.RequestOp) *pb.ResponseOp {
+ switch tv := union.Request.(type) {
+ case *pb.RequestOp_RequestRange:
+ if tv.RequestRange != nil {
+ resp, err := a.Range(txn, tv.RequestRange)
+ if err != nil {
+ plog.Panicf("unexpected error during txn: %v", err)
+ }
+ return &pb.ResponseOp{Response: &pb.ResponseOp_ResponseRange{ResponseRange: resp}}
+ }
+ case *pb.RequestOp_RequestPut:
+ if tv.RequestPut != nil {
+ resp, err := a.Put(txn, tv.RequestPut)
+ if err != nil {
+ plog.Panicf("unexpected error during txn: %v", err)
+ }
+ return &pb.ResponseOp{Response: &pb.ResponseOp_ResponsePut{ResponsePut: resp}}
+ }
+ case *pb.RequestOp_RequestDeleteRange:
+ if tv.RequestDeleteRange != nil {
+ resp, err := a.DeleteRange(txn, tv.RequestDeleteRange)
+ if err != nil {
+ plog.Panicf("unexpected error during txn: %v", err)
+ }
+ return &pb.ResponseOp{Response: &pb.ResponseOp_ResponseDeleteRange{ResponseDeleteRange: resp}}
+ }
+ default:
+ // empty union
+ return nil
+ }
+ return nil
+
+}
+
+func (a *applierV3backend) Compaction(compaction *pb.CompactionRequest) (*pb.CompactionResponse, <-chan struct{}, error) {
+ resp := &pb.CompactionResponse{}
+ resp.Header = &pb.ResponseHeader{}
+ ch, err := a.s.KV().Compact(compaction.Revision)
+ if err != nil {
+ return nil, ch, err
+ }
+ // get the current revision. which key to get is not important.
+ rr, _ := a.s.KV().Range([]byte("compaction"), nil, mvcc.RangeOptions{})
+ resp.Header.Revision = rr.Rev
+ return resp, ch, err
+}
+
+func (a *applierV3backend) LeaseGrant(lc *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) {
+ l, err := a.s.lessor.Grant(lease.LeaseID(lc.ID), lc.TTL)
+ resp := &pb.LeaseGrantResponse{}
+ if err == nil {
+ resp.ID = int64(l.ID)
+ resp.TTL = l.TTL()
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+func (a *applierV3backend) LeaseRevoke(lc *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error) {
+ err := a.s.lessor.Revoke(lease.LeaseID(lc.ID))
+ return &pb.LeaseRevokeResponse{Header: newHeader(a.s)}, err
+}
+
+func (a *applierV3backend) Alarm(ar *pb.AlarmRequest) (*pb.AlarmResponse, error) {
+ resp := &pb.AlarmResponse{}
+ oldCount := len(a.s.alarmStore.Get(ar.Alarm))
+
+ switch ar.Action {
+ case pb.AlarmRequest_GET:
+ resp.Alarms = a.s.alarmStore.Get(ar.Alarm)
+ case pb.AlarmRequest_ACTIVATE:
+ m := a.s.alarmStore.Activate(types.ID(ar.MemberID), ar.Alarm)
+ if m == nil {
+ break
+ }
+ resp.Alarms = append(resp.Alarms, m)
+ activated := oldCount == 0 && len(a.s.alarmStore.Get(m.Alarm)) == 1
+ if !activated {
+ break
+ }
+
+ switch m.Alarm {
+ case pb.AlarmType_NOSPACE:
+ plog.Warningf("alarm raised %+v", m)
+ a.s.applyV3 = newApplierV3Capped(a)
+ default:
+ plog.Errorf("unimplemented alarm activation (%+v)", m)
+ }
+ case pb.AlarmRequest_DEACTIVATE:
+ m := a.s.alarmStore.Deactivate(types.ID(ar.MemberID), ar.Alarm)
+ if m == nil {
+ break
+ }
+ resp.Alarms = append(resp.Alarms, m)
+ deactivated := oldCount > 0 && len(a.s.alarmStore.Get(ar.Alarm)) == 0
+ if !deactivated {
+ break
+ }
+
+ switch m.Alarm {
+ case pb.AlarmType_NOSPACE:
+ plog.Infof("alarm disarmed %+v", ar)
+ a.s.applyV3 = a.s.newApplierV3()
+ default:
+ plog.Errorf("unimplemented alarm deactivation (%+v)", m)
+ }
+ default:
+ return nil, nil
+ }
+ return resp, nil
+}
+
+type applierV3Capped struct {
+ applierV3
+ q backendQuota
+}
+
+// newApplierV3Capped creates an applyV3 that will reject Puts and transactions
+// with Puts so that the number of keys in the store is capped.
+func newApplierV3Capped(base applierV3) applierV3 { return &applierV3Capped{applierV3: base} }
+
+func (a *applierV3Capped) Put(txn mvcc.TxnWrite, p *pb.PutRequest) (*pb.PutResponse, error) {
+ return nil, ErrNoSpace
+}
+
+func (a *applierV3Capped) Txn(r *pb.TxnRequest) (*pb.TxnResponse, error) {
+ if a.q.Cost(r) > 0 {
+ return nil, ErrNoSpace
+ }
+ return a.applierV3.Txn(r)
+}
+
+func (a *applierV3Capped) LeaseGrant(lc *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) {
+ return nil, ErrNoSpace
+}
+
+func (a *applierV3backend) AuthEnable() (*pb.AuthEnableResponse, error) {
+ err := a.s.AuthStore().AuthEnable()
+ if err != nil {
+ return nil, err
+ }
+ return &pb.AuthEnableResponse{Header: newHeader(a.s)}, nil
+}
+
+func (a *applierV3backend) AuthDisable() (*pb.AuthDisableResponse, error) {
+ a.s.AuthStore().AuthDisable()
+ return &pb.AuthDisableResponse{Header: newHeader(a.s)}, nil
+}
+
+func (a *applierV3backend) Authenticate(r *pb.InternalAuthenticateRequest) (*pb.AuthenticateResponse, error) {
+ ctx := context.WithValue(context.WithValue(a.s.ctx, "index", a.s.consistIndex.ConsistentIndex()), "simpleToken", r.SimpleToken)
+ resp, err := a.s.AuthStore().Authenticate(ctx, r.Name, r.Password)
+ if resp != nil {
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+func (a *applierV3backend) UserAdd(r *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error) {
+ resp, err := a.s.AuthStore().UserAdd(r)
+ if resp != nil {
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+func (a *applierV3backend) UserDelete(r *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error) {
+ resp, err := a.s.AuthStore().UserDelete(r)
+ if resp != nil {
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+func (a *applierV3backend) UserChangePassword(r *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error) {
+ resp, err := a.s.AuthStore().UserChangePassword(r)
+ if resp != nil {
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+func (a *applierV3backend) UserGrantRole(r *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error) {
+ resp, err := a.s.AuthStore().UserGrantRole(r)
+ if resp != nil {
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+func (a *applierV3backend) UserGet(r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error) {
+ resp, err := a.s.AuthStore().UserGet(r)
+ if resp != nil {
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+func (a *applierV3backend) UserRevokeRole(r *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error) {
+ resp, err := a.s.AuthStore().UserRevokeRole(r)
+ if resp != nil {
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+func (a *applierV3backend) RoleAdd(r *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error) {
+ resp, err := a.s.AuthStore().RoleAdd(r)
+ if resp != nil {
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+func (a *applierV3backend) RoleGrantPermission(r *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error) {
+ resp, err := a.s.AuthStore().RoleGrantPermission(r)
+ if resp != nil {
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+func (a *applierV3backend) RoleGet(r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error) {
+ resp, err := a.s.AuthStore().RoleGet(r)
+ if resp != nil {
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+func (a *applierV3backend) RoleRevokePermission(r *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error) {
+ resp, err := a.s.AuthStore().RoleRevokePermission(r)
+ if resp != nil {
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+func (a *applierV3backend) RoleDelete(r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error) {
+ resp, err := a.s.AuthStore().RoleDelete(r)
+ if resp != nil {
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+func (a *applierV3backend) UserList(r *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error) {
+ resp, err := a.s.AuthStore().UserList(r)
+ if resp != nil {
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+func (a *applierV3backend) RoleList(r *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error) {
+ resp, err := a.s.AuthStore().RoleList(r)
+ if resp != nil {
+ resp.Header = newHeader(a.s)
+ }
+ return resp, err
+}
+
+type quotaApplierV3 struct {
+ applierV3
+ q Quota
+}
+
+func newQuotaApplierV3(s *EtcdServer, app applierV3) applierV3 {
+ return "aApplierV3{app, NewBackendQuota(s)}
+}
+
+func (a *quotaApplierV3) Put(txn mvcc.TxnWrite, p *pb.PutRequest) (*pb.PutResponse, error) {
+ ok := a.q.Available(p)
+ resp, err := a.applierV3.Put(txn, p)
+ if err == nil && !ok {
+ err = ErrNoSpace
+ }
+ return resp, err
+}
+
+func (a *quotaApplierV3) Txn(rt *pb.TxnRequest) (*pb.TxnResponse, error) {
+ ok := a.q.Available(rt)
+ resp, err := a.applierV3.Txn(rt)
+ if err == nil && !ok {
+ err = ErrNoSpace
+ }
+ return resp, err
+}
+
+func (a *quotaApplierV3) LeaseGrant(lc *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) {
+ ok := a.q.Available(lc)
+ resp, err := a.applierV3.LeaseGrant(lc)
+ if err == nil && !ok {
+ err = ErrNoSpace
+ }
+ return resp, err
+}
+
+type kvSort struct{ kvs []mvccpb.KeyValue }
+
+func (s *kvSort) Swap(i, j int) {
+ t := s.kvs[i]
+ s.kvs[i] = s.kvs[j]
+ s.kvs[j] = t
+}
+func (s *kvSort) Len() int { return len(s.kvs) }
+
+type kvSortByKey struct{ *kvSort }
+
+func (s *kvSortByKey) Less(i, j int) bool {
+ return bytes.Compare(s.kvs[i].Key, s.kvs[j].Key) < 0
+}
+
+type kvSortByVersion struct{ *kvSort }
+
+func (s *kvSortByVersion) Less(i, j int) bool {
+ return (s.kvs[i].Version - s.kvs[j].Version) < 0
+}
+
+type kvSortByCreate struct{ *kvSort }
+
+func (s *kvSortByCreate) Less(i, j int) bool {
+ return (s.kvs[i].CreateRevision - s.kvs[j].CreateRevision) < 0
+}
+
+type kvSortByMod struct{ *kvSort }
+
+func (s *kvSortByMod) Less(i, j int) bool {
+ return (s.kvs[i].ModRevision - s.kvs[j].ModRevision) < 0
+}
+
+type kvSortByValue struct{ *kvSort }
+
+func (s *kvSortByValue) Less(i, j int) bool {
+ return bytes.Compare(s.kvs[i].Value, s.kvs[j].Value) < 0
+}
+
+func (a *applierV3backend) checkRequestPut(rv mvcc.ReadView, reqs []*pb.RequestOp) error {
+ for _, requ := range reqs {
+ tv, ok := requ.Request.(*pb.RequestOp_RequestPut)
+ if !ok {
+ continue
+ }
+ preq := tv.RequestPut
+ if preq == nil {
+ continue
+ }
+ if preq.IgnoreValue || preq.IgnoreLease {
+ // expects previous key-value, error if not exist
+ rr, err := rv.Range(preq.Key, nil, mvcc.RangeOptions{})
+ if err != nil {
+ return err
+ }
+ if rr == nil || len(rr.KVs) == 0 {
+ return ErrKeyNotFound
+ }
+ }
+ if lease.LeaseID(preq.Lease) == lease.NoLease {
+ continue
+ }
+ if l := a.s.lessor.Lookup(lease.LeaseID(preq.Lease)); l == nil {
+ return lease.ErrLeaseNotFound
+ }
+ }
+ return nil
+}
+
+func checkRequestRange(rv mvcc.ReadView, reqs []*pb.RequestOp) error {
+ for _, requ := range reqs {
+ tv, ok := requ.Request.(*pb.RequestOp_RequestRange)
+ if !ok {
+ continue
+ }
+ greq := tv.RequestRange
+ if greq == nil || greq.Revision == 0 {
+ continue
+ }
+
+ if greq.Revision > rv.Rev() {
+ return mvcc.ErrFutureRev
+ }
+ if greq.Revision < rv.FirstRev() {
+ return mvcc.ErrCompacted
+ }
+ }
+ return nil
+}
+
+func compareInt64(a, b int64) int {
+ switch {
+ case a < b:
+ return -1
+ case a > b:
+ return 1
+ default:
+ return 0
+ }
+}
+
+// isGteRange determines if the range end is a >= range. This works around grpc
+// sending empty byte strings as nil; >= is encoded in the range end as '\0'.
+func isGteRange(rangeEnd []byte) bool {
+ return len(rangeEnd) == 1 && rangeEnd[0] == 0
+}
+
+func noSideEffect(r *pb.InternalRaftRequest) bool {
+ return r.Range != nil || r.AuthUserGet != nil || r.AuthRoleGet != nil
+}
+
+func removeNeedlessRangeReqs(txn *pb.TxnRequest) {
+ f := func(ops []*pb.RequestOp) []*pb.RequestOp {
+ j := 0
+ for i := 0; i < len(ops); i++ {
+ if _, ok := ops[i].Request.(*pb.RequestOp_RequestRange); ok {
+ continue
+ }
+ ops[j] = ops[i]
+ j++
+ }
+
+ return ops[:j]
+ }
+
+ txn.Success = f(txn.Success)
+ txn.Failure = f(txn.Failure)
+}
+
+func pruneKVs(rr *mvcc.RangeResult, isPrunable func(*mvccpb.KeyValue) bool) {
+ j := 0
+ for i := range rr.KVs {
+ rr.KVs[j] = rr.KVs[i]
+ if !isPrunable(&rr.KVs[i]) {
+ j++
+ }
+ }
+ rr.KVs = rr.KVs[:j]
+}
+
+func newHeader(s *EtcdServer) *pb.ResponseHeader {
+ return &pb.ResponseHeader{
+ ClusterId: uint64(s.Cluster().ID()),
+ MemberId: uint64(s.ID()),
+ Revision: s.KV().Rev(),
+ RaftTerm: s.Term(),
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/apply_auth.go b/vendor/github.com/coreos/etcd/etcdserver/apply_auth.go
new file mode 100644
index 00000000..7da4ae45
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/apply_auth.go
@@ -0,0 +1,196 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "sync"
+
+ "github.com/coreos/etcd/auth"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/mvcc"
+)
+
+type authApplierV3 struct {
+ applierV3
+ as auth.AuthStore
+
+ // mu serializes Apply so that user isn't corrupted and so that
+ // serialized requests don't leak data from TOCTOU errors
+ mu sync.Mutex
+
+ authInfo auth.AuthInfo
+}
+
+func newAuthApplierV3(as auth.AuthStore, base applierV3) *authApplierV3 {
+ return &authApplierV3{applierV3: base, as: as}
+}
+
+func (aa *authApplierV3) Apply(r *pb.InternalRaftRequest) *applyResult {
+ aa.mu.Lock()
+ defer aa.mu.Unlock()
+ if r.Header != nil {
+ // backward-compatible with pre-3.0 releases when internalRaftRequest
+ // does not have header field
+ aa.authInfo.Username = r.Header.Username
+ aa.authInfo.Revision = r.Header.AuthRevision
+ }
+ if needAdminPermission(r) {
+ if err := aa.as.IsAdminPermitted(&aa.authInfo); err != nil {
+ aa.authInfo.Username = ""
+ aa.authInfo.Revision = 0
+ return &applyResult{err: err}
+ }
+ }
+ ret := aa.applierV3.Apply(r)
+ aa.authInfo.Username = ""
+ aa.authInfo.Revision = 0
+ return ret
+}
+
+func (aa *authApplierV3) Put(txn mvcc.TxnWrite, r *pb.PutRequest) (*pb.PutResponse, error) {
+ if err := aa.as.IsPutPermitted(&aa.authInfo, r.Key); err != nil {
+ return nil, err
+ }
+ if r.PrevKv {
+ err := aa.as.IsRangePermitted(&aa.authInfo, r.Key, nil)
+ if err != nil {
+ return nil, err
+ }
+ }
+ return aa.applierV3.Put(txn, r)
+}
+
+func (aa *authApplierV3) Range(txn mvcc.TxnRead, r *pb.RangeRequest) (*pb.RangeResponse, error) {
+ if err := aa.as.IsRangePermitted(&aa.authInfo, r.Key, r.RangeEnd); err != nil {
+ return nil, err
+ }
+ return aa.applierV3.Range(txn, r)
+}
+
+func (aa *authApplierV3) DeleteRange(txn mvcc.TxnWrite, r *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error) {
+ if err := aa.as.IsDeleteRangePermitted(&aa.authInfo, r.Key, r.RangeEnd); err != nil {
+ return nil, err
+ }
+ if r.PrevKv {
+ err := aa.as.IsRangePermitted(&aa.authInfo, r.Key, r.RangeEnd)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ return aa.applierV3.DeleteRange(txn, r)
+}
+
+func checkTxnReqsPermission(as auth.AuthStore, ai *auth.AuthInfo, reqs []*pb.RequestOp) error {
+ for _, requ := range reqs {
+ switch tv := requ.Request.(type) {
+ case *pb.RequestOp_RequestRange:
+ if tv.RequestRange == nil {
+ continue
+ }
+
+ if err := as.IsRangePermitted(ai, tv.RequestRange.Key, tv.RequestRange.RangeEnd); err != nil {
+ return err
+ }
+
+ case *pb.RequestOp_RequestPut:
+ if tv.RequestPut == nil {
+ continue
+ }
+
+ if err := as.IsPutPermitted(ai, tv.RequestPut.Key); err != nil {
+ return err
+ }
+
+ case *pb.RequestOp_RequestDeleteRange:
+ if tv.RequestDeleteRange == nil {
+ continue
+ }
+
+ if tv.RequestDeleteRange.PrevKv {
+ err := as.IsRangePermitted(ai, tv.RequestDeleteRange.Key, tv.RequestDeleteRange.RangeEnd)
+ if err != nil {
+ return err
+ }
+ }
+
+ err := as.IsDeleteRangePermitted(ai, tv.RequestDeleteRange.Key, tv.RequestDeleteRange.RangeEnd)
+ if err != nil {
+ return err
+ }
+ }
+ }
+
+ return nil
+}
+
+func checkTxnAuth(as auth.AuthStore, ai *auth.AuthInfo, rt *pb.TxnRequest) error {
+ for _, c := range rt.Compare {
+ if err := as.IsRangePermitted(ai, c.Key, nil); err != nil {
+ return err
+ }
+ }
+ if err := checkTxnReqsPermission(as, ai, rt.Success); err != nil {
+ return err
+ }
+ if err := checkTxnReqsPermission(as, ai, rt.Failure); err != nil {
+ return err
+ }
+ return nil
+}
+
+func (aa *authApplierV3) Txn(rt *pb.TxnRequest) (*pb.TxnResponse, error) {
+ if err := checkTxnAuth(aa.as, &aa.authInfo, rt); err != nil {
+ return nil, err
+ }
+ return aa.applierV3.Txn(rt)
+}
+
+func needAdminPermission(r *pb.InternalRaftRequest) bool {
+ switch {
+ case r.AuthEnable != nil:
+ return true
+ case r.AuthDisable != nil:
+ return true
+ case r.AuthUserAdd != nil:
+ return true
+ case r.AuthUserDelete != nil:
+ return true
+ case r.AuthUserChangePassword != nil:
+ return true
+ case r.AuthUserGrantRole != nil:
+ return true
+ case r.AuthUserGet != nil:
+ return true
+ case r.AuthUserRevokeRole != nil:
+ return true
+ case r.AuthRoleAdd != nil:
+ return true
+ case r.AuthRoleGrantPermission != nil:
+ return true
+ case r.AuthRoleGet != nil:
+ return true
+ case r.AuthRoleRevokePermission != nil:
+ return true
+ case r.AuthRoleDelete != nil:
+ return true
+ case r.AuthUserList != nil:
+ return true
+ case r.AuthRoleList != nil:
+ return true
+ default:
+ return false
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/apply_v2.go b/vendor/github.com/coreos/etcd/etcdserver/apply_v2.go
new file mode 100644
index 00000000..f278efca
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/apply_v2.go
@@ -0,0 +1,140 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "encoding/json"
+ "path"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/api"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/store"
+ "github.com/coreos/go-semver/semver"
+)
+
+// ApplierV2 is the interface for processing V2 raft messages
+type ApplierV2 interface {
+ Delete(r *pb.Request) Response
+ Post(r *pb.Request) Response
+ Put(r *pb.Request) Response
+ QGet(r *pb.Request) Response
+ Sync(r *pb.Request) Response
+}
+
+func NewApplierV2(s store.Store, c *membership.RaftCluster) ApplierV2 {
+ return &applierV2store{store: s, cluster: c}
+}
+
+type applierV2store struct {
+ store store.Store
+ cluster *membership.RaftCluster
+}
+
+func (a *applierV2store) Delete(r *pb.Request) Response {
+ switch {
+ case r.PrevIndex > 0 || r.PrevValue != "":
+ return toResponse(a.store.CompareAndDelete(r.Path, r.PrevValue, r.PrevIndex))
+ default:
+ return toResponse(a.store.Delete(r.Path, r.Dir, r.Recursive))
+ }
+}
+
+func (a *applierV2store) Post(r *pb.Request) Response {
+ return toResponse(a.store.Create(r.Path, r.Dir, r.Val, true, toTTLOptions(r)))
+}
+
+func (a *applierV2store) Put(r *pb.Request) Response {
+ ttlOptions := toTTLOptions(r)
+ exists, existsSet := pbutil.GetBool(r.PrevExist)
+ switch {
+ case existsSet:
+ if exists {
+ if r.PrevIndex == 0 && r.PrevValue == "" {
+ return toResponse(a.store.Update(r.Path, r.Val, ttlOptions))
+ }
+ return toResponse(a.store.CompareAndSwap(r.Path, r.PrevValue, r.PrevIndex, r.Val, ttlOptions))
+ }
+ return toResponse(a.store.Create(r.Path, r.Dir, r.Val, false, ttlOptions))
+ case r.PrevIndex > 0 || r.PrevValue != "":
+ return toResponse(a.store.CompareAndSwap(r.Path, r.PrevValue, r.PrevIndex, r.Val, ttlOptions))
+ default:
+ if storeMemberAttributeRegexp.MatchString(r.Path) {
+ id := membership.MustParseMemberIDFromKey(path.Dir(r.Path))
+ var attr membership.Attributes
+ if err := json.Unmarshal([]byte(r.Val), &attr); err != nil {
+ plog.Panicf("unmarshal %s should never fail: %v", r.Val, err)
+ }
+ if a.cluster != nil {
+ a.cluster.UpdateAttributes(id, attr)
+ }
+ // return an empty response since there is no consumer.
+ return Response{}
+ }
+ if r.Path == membership.StoreClusterVersionKey() {
+ if a.cluster != nil {
+ a.cluster.SetVersion(semver.Must(semver.NewVersion(r.Val)), api.UpdateCapability)
+ }
+ // return an empty response since there is no consumer.
+ return Response{}
+ }
+ return toResponse(a.store.Set(r.Path, r.Dir, r.Val, ttlOptions))
+ }
+}
+
+func (a *applierV2store) QGet(r *pb.Request) Response {
+ return toResponse(a.store.Get(r.Path, r.Recursive, r.Sorted))
+}
+
+func (a *applierV2store) Sync(r *pb.Request) Response {
+ a.store.DeleteExpiredKeys(time.Unix(0, r.Time))
+ return Response{}
+}
+
+// applyV2Request interprets r as a call to store.X and returns a Response interpreted
+// from store.Event
+func (s *EtcdServer) applyV2Request(r *pb.Request) Response {
+ toTTLOptions(r)
+ switch r.Method {
+ case "POST":
+ return s.applyV2.Post(r)
+ case "PUT":
+ return s.applyV2.Put(r)
+ case "DELETE":
+ return s.applyV2.Delete(r)
+ case "QGET":
+ return s.applyV2.QGet(r)
+ case "SYNC":
+ return s.applyV2.Sync(r)
+ default:
+ // This should never be reached, but just in case:
+ return Response{err: ErrUnknownMethod}
+ }
+}
+
+func toTTLOptions(r *pb.Request) store.TTLOptionSet {
+ refresh, _ := pbutil.GetBool(r.Refresh)
+ ttlOptions := store.TTLOptionSet{Refresh: refresh}
+ if r.Expiration != 0 {
+ ttlOptions.ExpireTime = time.Unix(0, r.Expiration)
+ }
+ return ttlOptions
+}
+
+func toResponse(ev *store.Event, err error) Response {
+ return Response{Event: ev, err: err}
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/auth/auth.go b/vendor/github.com/coreos/etcd/etcdserver/auth/auth.go
new file mode 100644
index 00000000..19e96d57
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/auth/auth.go
@@ -0,0 +1,647 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 auth implements etcd authentication.
+package auth
+
+import (
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "path"
+ "reflect"
+ "sort"
+ "strings"
+ "time"
+
+ etcderr "github.com/coreos/etcd/error"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/pkg/capnslog"
+ "golang.org/x/crypto/bcrypt"
+ "golang.org/x/net/context"
+)
+
+const (
+ // StorePermsPrefix is the internal prefix of the storage layer dedicated to storing user data.
+ StorePermsPrefix = "/2"
+
+ // RootRoleName is the name of the ROOT role, with privileges to manage the cluster.
+ RootRoleName = "root"
+
+ // GuestRoleName is the name of the role that defines the privileges of an unauthenticated user.
+ GuestRoleName = "guest"
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "etcdserver/auth")
+)
+
+var rootRole = Role{
+ Role: RootRoleName,
+ Permissions: Permissions{
+ KV: RWPermission{
+ Read: []string{"/*"},
+ Write: []string{"/*"},
+ },
+ },
+}
+
+var guestRole = Role{
+ Role: GuestRoleName,
+ Permissions: Permissions{
+ KV: RWPermission{
+ Read: []string{"/*"},
+ Write: []string{"/*"},
+ },
+ },
+}
+
+type doer interface {
+ Do(context.Context, etcdserverpb.Request) (etcdserver.Response, error)
+}
+
+type Store interface {
+ AllUsers() ([]string, error)
+ GetUser(name string) (User, error)
+ CreateOrUpdateUser(user User) (out User, created bool, err error)
+ CreateUser(user User) (User, error)
+ DeleteUser(name string) error
+ UpdateUser(user User) (User, error)
+ AllRoles() ([]string, error)
+ GetRole(name string) (Role, error)
+ CreateRole(role Role) error
+ DeleteRole(name string) error
+ UpdateRole(role Role) (Role, error)
+ AuthEnabled() bool
+ EnableAuth() error
+ DisableAuth() error
+ PasswordStore
+}
+
+type PasswordStore interface {
+ CheckPassword(user User, password string) bool
+ HashPassword(password string) (string, error)
+}
+
+type store struct {
+ server doer
+ timeout time.Duration
+ ensuredOnce bool
+
+ PasswordStore
+}
+
+type User struct {
+ User string `json:"user"`
+ Password string `json:"password,omitempty"`
+ Roles []string `json:"roles"`
+ Grant []string `json:"grant,omitempty"`
+ Revoke []string `json:"revoke,omitempty"`
+}
+
+type Role struct {
+ Role string `json:"role"`
+ Permissions Permissions `json:"permissions"`
+ Grant *Permissions `json:"grant,omitempty"`
+ Revoke *Permissions `json:"revoke,omitempty"`
+}
+
+type Permissions struct {
+ KV RWPermission `json:"kv"`
+}
+
+func (p *Permissions) IsEmpty() bool {
+ return p == nil || (len(p.KV.Read) == 0 && len(p.KV.Write) == 0)
+}
+
+type RWPermission struct {
+ Read []string `json:"read"`
+ Write []string `json:"write"`
+}
+
+type Error struct {
+ Status int
+ Errmsg string
+}
+
+func (ae Error) Error() string { return ae.Errmsg }
+func (ae Error) HTTPStatus() int { return ae.Status }
+
+func authErr(hs int, s string, v ...interface{}) Error {
+ return Error{Status: hs, Errmsg: fmt.Sprintf("auth: "+s, v...)}
+}
+
+func NewStore(server doer, timeout time.Duration) Store {
+ s := &store{
+ server: server,
+ timeout: timeout,
+ PasswordStore: passwordStore{},
+ }
+ return s
+}
+
+// passwordStore implements PasswordStore using bcrypt to hash user passwords
+type passwordStore struct{}
+
+func (_ passwordStore) CheckPassword(user User, password string) bool {
+ err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))
+ return err == nil
+}
+
+func (_ passwordStore) HashPassword(password string) (string, error) {
+ hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
+ return string(hash), err
+}
+
+func (s *store) AllUsers() ([]string, error) {
+ resp, err := s.requestResource("/users/", false, false)
+ if err != nil {
+ if e, ok := err.(*etcderr.Error); ok {
+ if e.ErrorCode == etcderr.EcodeKeyNotFound {
+ return []string{}, nil
+ }
+ }
+ return nil, err
+ }
+ var nodes []string
+ for _, n := range resp.Event.Node.Nodes {
+ _, user := path.Split(n.Key)
+ nodes = append(nodes, user)
+ }
+ sort.Strings(nodes)
+ return nodes, nil
+}
+
+func (s *store) GetUser(name string) (User, error) { return s.getUser(name, false) }
+
+// CreateOrUpdateUser should be only used for creating the new user or when you are not
+// sure if it is a create or update. (When only password is passed in, we are not sure
+// if it is a update or create)
+func (s *store) CreateOrUpdateUser(user User) (out User, created bool, err error) {
+ _, err = s.getUser(user.User, true)
+ if err == nil {
+ out, err = s.UpdateUser(user)
+ return out, false, err
+ }
+ u, err := s.CreateUser(user)
+ return u, true, err
+}
+
+func (s *store) CreateUser(user User) (User, error) {
+ // Attach root role to root user.
+ if user.User == "root" {
+ user = attachRootRole(user)
+ }
+ u, err := s.createUserInternal(user)
+ if err == nil {
+ plog.Noticef("created user %s", user.User)
+ }
+ return u, err
+}
+
+func (s *store) createUserInternal(user User) (User, error) {
+ if user.Password == "" {
+ return user, authErr(http.StatusBadRequest, "Cannot create user %s with an empty password", user.User)
+ }
+ hash, err := s.HashPassword(user.Password)
+ if err != nil {
+ return user, err
+ }
+ user.Password = hash
+
+ _, err = s.createResource("/users/"+user.User, user)
+ if err != nil {
+ if e, ok := err.(*etcderr.Error); ok {
+ if e.ErrorCode == etcderr.EcodeNodeExist {
+ return user, authErr(http.StatusConflict, "User %s already exists.", user.User)
+ }
+ }
+ }
+ return user, err
+}
+
+func (s *store) DeleteUser(name string) error {
+ if s.AuthEnabled() && name == "root" {
+ return authErr(http.StatusForbidden, "Cannot delete root user while auth is enabled.")
+ }
+ _, err := s.deleteResource("/users/" + name)
+ if err != nil {
+ if e, ok := err.(*etcderr.Error); ok {
+ if e.ErrorCode == etcderr.EcodeKeyNotFound {
+ return authErr(http.StatusNotFound, "User %s does not exist", name)
+ }
+ }
+ return err
+ }
+ plog.Noticef("deleted user %s", name)
+ return nil
+}
+
+func (s *store) UpdateUser(user User) (User, error) {
+ old, err := s.getUser(user.User, true)
+ if err != nil {
+ if e, ok := err.(*etcderr.Error); ok {
+ if e.ErrorCode == etcderr.EcodeKeyNotFound {
+ return user, authErr(http.StatusNotFound, "User %s doesn't exist.", user.User)
+ }
+ }
+ return old, err
+ }
+
+ newUser, err := old.merge(user, s.PasswordStore)
+ if err != nil {
+ return old, err
+ }
+ if reflect.DeepEqual(old, newUser) {
+ return old, authErr(http.StatusBadRequest, "User not updated. Use grant/revoke/password to update the user.")
+ }
+ _, err = s.updateResource("/users/"+user.User, newUser)
+ if err == nil {
+ plog.Noticef("updated user %s", user.User)
+ }
+ return newUser, err
+}
+
+func (s *store) AllRoles() ([]string, error) {
+ nodes := []string{RootRoleName}
+ resp, err := s.requestResource("/roles/", false, false)
+ if err != nil {
+ if e, ok := err.(*etcderr.Error); ok {
+ if e.ErrorCode == etcderr.EcodeKeyNotFound {
+ return nodes, nil
+ }
+ }
+ return nil, err
+ }
+ for _, n := range resp.Event.Node.Nodes {
+ _, role := path.Split(n.Key)
+ nodes = append(nodes, role)
+ }
+ sort.Strings(nodes)
+ return nodes, nil
+}
+
+func (s *store) GetRole(name string) (Role, error) { return s.getRole(name, false) }
+
+func (s *store) CreateRole(role Role) error {
+ if role.Role == RootRoleName {
+ return authErr(http.StatusForbidden, "Cannot modify role %s: is root role.", role.Role)
+ }
+ _, err := s.createResource("/roles/"+role.Role, role)
+ if err != nil {
+ if e, ok := err.(*etcderr.Error); ok {
+ if e.ErrorCode == etcderr.EcodeNodeExist {
+ return authErr(http.StatusConflict, "Role %s already exists.", role.Role)
+ }
+ }
+ }
+ if err == nil {
+ plog.Noticef("created new role %s", role.Role)
+ }
+ return err
+}
+
+func (s *store) DeleteRole(name string) error {
+ if name == RootRoleName {
+ return authErr(http.StatusForbidden, "Cannot modify role %s: is root role.", name)
+ }
+ _, err := s.deleteResource("/roles/" + name)
+ if err != nil {
+ if e, ok := err.(*etcderr.Error); ok {
+ if e.ErrorCode == etcderr.EcodeKeyNotFound {
+ return authErr(http.StatusNotFound, "Role %s doesn't exist.", name)
+ }
+ }
+ }
+ if err == nil {
+ plog.Noticef("deleted role %s", name)
+ }
+ return err
+}
+
+func (s *store) UpdateRole(role Role) (Role, error) {
+ if role.Role == RootRoleName {
+ return Role{}, authErr(http.StatusForbidden, "Cannot modify role %s: is root role.", role.Role)
+ }
+ old, err := s.getRole(role.Role, true)
+ if err != nil {
+ if e, ok := err.(*etcderr.Error); ok {
+ if e.ErrorCode == etcderr.EcodeKeyNotFound {
+ return role, authErr(http.StatusNotFound, "Role %s doesn't exist.", role.Role)
+ }
+ }
+ return old, err
+ }
+ newRole, err := old.merge(role)
+ if err != nil {
+ return old, err
+ }
+ if reflect.DeepEqual(old, newRole) {
+ return old, authErr(http.StatusBadRequest, "Role not updated. Use grant/revoke to update the role.")
+ }
+ _, err = s.updateResource("/roles/"+role.Role, newRole)
+ if err == nil {
+ plog.Noticef("updated role %s", role.Role)
+ }
+ return newRole, err
+}
+
+func (s *store) AuthEnabled() bool {
+ return s.detectAuth()
+}
+
+func (s *store) EnableAuth() error {
+ if s.AuthEnabled() {
+ return authErr(http.StatusConflict, "already enabled")
+ }
+
+ if _, err := s.getUser("root", true); err != nil {
+ return authErr(http.StatusConflict, "No root user available, please create one")
+ }
+ if _, err := s.getRole(GuestRoleName, true); err != nil {
+ plog.Printf("no guest role access found, creating default")
+ if err := s.CreateRole(guestRole); err != nil {
+ plog.Errorf("error creating guest role. aborting auth enable.")
+ return err
+ }
+ }
+
+ if err := s.enableAuth(); err != nil {
+ plog.Errorf("error enabling auth (%v)", err)
+ return err
+ }
+
+ plog.Noticef("auth: enabled auth")
+ return nil
+}
+
+func (s *store) DisableAuth() error {
+ if !s.AuthEnabled() {
+ return authErr(http.StatusConflict, "already disabled")
+ }
+
+ err := s.disableAuth()
+ if err == nil {
+ plog.Noticef("auth: disabled auth")
+ } else {
+ plog.Errorf("error disabling auth (%v)", err)
+ }
+ return err
+}
+
+// merge applies the properties of the passed-in User to the User on which it
+// is called and returns a new User with these modifications applied. Think of
+// all Users as immutable sets of data. Merge allows you to perform the set
+// operations (desired grants and revokes) atomically
+func (ou User) merge(nu User, s PasswordStore) (User, error) {
+ var out User
+ if ou.User != nu.User {
+ return out, authErr(http.StatusConflict, "Merging user data with conflicting usernames: %s %s", ou.User, nu.User)
+ }
+ out.User = ou.User
+ if nu.Password != "" {
+ hash, err := s.HashPassword(nu.Password)
+ if err != nil {
+ return ou, err
+ }
+ out.Password = hash
+ } else {
+ out.Password = ou.Password
+ }
+ currentRoles := types.NewUnsafeSet(ou.Roles...)
+ for _, g := range nu.Grant {
+ if currentRoles.Contains(g) {
+ plog.Noticef("granting duplicate role %s for user %s", g, nu.User)
+ return User{}, authErr(http.StatusConflict, fmt.Sprintf("Granting duplicate role %s for user %s", g, nu.User))
+ }
+ currentRoles.Add(g)
+ }
+ for _, r := range nu.Revoke {
+ if !currentRoles.Contains(r) {
+ plog.Noticef("revoking ungranted role %s for user %s", r, nu.User)
+ return User{}, authErr(http.StatusConflict, fmt.Sprintf("Revoking ungranted role %s for user %s", r, nu.User))
+ }
+ currentRoles.Remove(r)
+ }
+ out.Roles = currentRoles.Values()
+ sort.Strings(out.Roles)
+ return out, nil
+}
+
+// merge for a role works the same as User above -- atomic Role application to
+// each of the substructures.
+func (r Role) merge(n Role) (Role, error) {
+ var out Role
+ var err error
+ if r.Role != n.Role {
+ return out, authErr(http.StatusConflict, "Merging role with conflicting names: %s %s", r.Role, n.Role)
+ }
+ out.Role = r.Role
+ out.Permissions, err = r.Permissions.Grant(n.Grant)
+ if err != nil {
+ return out, err
+ }
+ out.Permissions, err = out.Permissions.Revoke(n.Revoke)
+ return out, err
+}
+
+func (r Role) HasKeyAccess(key string, write bool) bool {
+ if r.Role == RootRoleName {
+ return true
+ }
+ return r.Permissions.KV.HasAccess(key, write)
+}
+
+func (r Role) HasRecursiveAccess(key string, write bool) bool {
+ if r.Role == RootRoleName {
+ return true
+ }
+ return r.Permissions.KV.HasRecursiveAccess(key, write)
+}
+
+// Grant adds a set of permissions to the permission object on which it is called,
+// returning a new permission object.
+func (p Permissions) Grant(n *Permissions) (Permissions, error) {
+ var out Permissions
+ var err error
+ if n == nil {
+ return p, nil
+ }
+ out.KV, err = p.KV.Grant(n.KV)
+ return out, err
+}
+
+// Revoke removes a set of permissions to the permission object on which it is called,
+// returning a new permission object.
+func (p Permissions) Revoke(n *Permissions) (Permissions, error) {
+ var out Permissions
+ var err error
+ if n == nil {
+ return p, nil
+ }
+ out.KV, err = p.KV.Revoke(n.KV)
+ return out, err
+}
+
+// Grant adds a set of permissions to the permission object on which it is called,
+// returning a new permission object.
+func (rw RWPermission) Grant(n RWPermission) (RWPermission, error) {
+ var out RWPermission
+ currentRead := types.NewUnsafeSet(rw.Read...)
+ for _, r := range n.Read {
+ if currentRead.Contains(r) {
+ return out, authErr(http.StatusConflict, "Granting duplicate read permission %s", r)
+ }
+ currentRead.Add(r)
+ }
+ currentWrite := types.NewUnsafeSet(rw.Write...)
+ for _, w := range n.Write {
+ if currentWrite.Contains(w) {
+ return out, authErr(http.StatusConflict, "Granting duplicate write permission %s", w)
+ }
+ currentWrite.Add(w)
+ }
+ out.Read = currentRead.Values()
+ out.Write = currentWrite.Values()
+ sort.Strings(out.Read)
+ sort.Strings(out.Write)
+ return out, nil
+}
+
+// Revoke removes a set of permissions to the permission object on which it is called,
+// returning a new permission object.
+func (rw RWPermission) Revoke(n RWPermission) (RWPermission, error) {
+ var out RWPermission
+ currentRead := types.NewUnsafeSet(rw.Read...)
+ for _, r := range n.Read {
+ if !currentRead.Contains(r) {
+ plog.Noticef("revoking ungranted read permission %s", r)
+ continue
+ }
+ currentRead.Remove(r)
+ }
+ currentWrite := types.NewUnsafeSet(rw.Write...)
+ for _, w := range n.Write {
+ if !currentWrite.Contains(w) {
+ plog.Noticef("revoking ungranted write permission %s", w)
+ continue
+ }
+ currentWrite.Remove(w)
+ }
+ out.Read = currentRead.Values()
+ out.Write = currentWrite.Values()
+ sort.Strings(out.Read)
+ sort.Strings(out.Write)
+ return out, nil
+}
+
+func (rw RWPermission) HasAccess(key string, write bool) bool {
+ var list []string
+ if write {
+ list = rw.Write
+ } else {
+ list = rw.Read
+ }
+ for _, pat := range list {
+ match, err := simpleMatch(pat, key)
+ if err == nil && match {
+ return true
+ }
+ }
+ return false
+}
+
+func (rw RWPermission) HasRecursiveAccess(key string, write bool) bool {
+ list := rw.Read
+ if write {
+ list = rw.Write
+ }
+ for _, pat := range list {
+ match, err := prefixMatch(pat, key)
+ if err == nil && match {
+ return true
+ }
+ }
+ return false
+}
+
+func simpleMatch(pattern string, key string) (match bool, err error) {
+ if pattern[len(pattern)-1] == '*' {
+ return strings.HasPrefix(key, pattern[:len(pattern)-1]), nil
+ }
+ return key == pattern, nil
+}
+
+func prefixMatch(pattern string, key string) (match bool, err error) {
+ if pattern[len(pattern)-1] != '*' {
+ return false, nil
+ }
+ return strings.HasPrefix(key, pattern[:len(pattern)-1]), nil
+}
+
+func attachRootRole(u User) User {
+ inRoles := false
+ for _, r := range u.Roles {
+ if r == RootRoleName {
+ inRoles = true
+ break
+ }
+ }
+ if !inRoles {
+ u.Roles = append(u.Roles, RootRoleName)
+ }
+ return u
+}
+
+func (s *store) getUser(name string, quorum bool) (User, error) {
+ resp, err := s.requestResource("/users/"+name, false, quorum)
+ if err != nil {
+ if e, ok := err.(*etcderr.Error); ok {
+ if e.ErrorCode == etcderr.EcodeKeyNotFound {
+ return User{}, authErr(http.StatusNotFound, "User %s does not exist.", name)
+ }
+ }
+ return User{}, err
+ }
+ var u User
+ err = json.Unmarshal([]byte(*resp.Event.Node.Value), &u)
+ if err != nil {
+ return u, err
+ }
+ // Attach root role to root user.
+ if u.User == "root" {
+ u = attachRootRole(u)
+ }
+ return u, nil
+}
+
+func (s *store) getRole(name string, quorum bool) (Role, error) {
+ if name == RootRoleName {
+ return rootRole, nil
+ }
+ resp, err := s.requestResource("/roles/"+name, false, quorum)
+ if err != nil {
+ if e, ok := err.(*etcderr.Error); ok {
+ if e.ErrorCode == etcderr.EcodeKeyNotFound {
+ return Role{}, authErr(http.StatusNotFound, "Role %s does not exist.", name)
+ }
+ }
+ return Role{}, err
+ }
+ var r Role
+ err = json.Unmarshal([]byte(*resp.Event.Node.Value), &r)
+ return r, err
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/auth/auth_requests.go b/vendor/github.com/coreos/etcd/etcdserver/auth/auth_requests.go
new file mode 100644
index 00000000..eec700ac
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/auth/auth_requests.go
@@ -0,0 +1,166 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 auth
+
+import (
+ "encoding/json"
+ "path"
+
+ etcderr "github.com/coreos/etcd/error"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "golang.org/x/net/context"
+)
+
+func (s *store) ensureAuthDirectories() error {
+ if s.ensuredOnce {
+ return nil
+ }
+ for _, res := range []string{StorePermsPrefix, StorePermsPrefix + "/users/", StorePermsPrefix + "/roles/"} {
+ ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
+ defer cancel()
+ pe := false
+ rr := etcdserverpb.Request{
+ Method: "PUT",
+ Path: res,
+ Dir: true,
+ PrevExist: &pe,
+ }
+ _, err := s.server.Do(ctx, rr)
+ if err != nil {
+ if e, ok := err.(*etcderr.Error); ok {
+ if e.ErrorCode == etcderr.EcodeNodeExist {
+ continue
+ }
+ }
+ plog.Errorf("failed to create auth directories in the store (%v)", err)
+ return err
+ }
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
+ defer cancel()
+ pe := false
+ rr := etcdserverpb.Request{
+ Method: "PUT",
+ Path: StorePermsPrefix + "/enabled",
+ Val: "false",
+ PrevExist: &pe,
+ }
+ _, err := s.server.Do(ctx, rr)
+ if err != nil {
+ if e, ok := err.(*etcderr.Error); ok {
+ if e.ErrorCode == etcderr.EcodeNodeExist {
+ s.ensuredOnce = true
+ return nil
+ }
+ }
+ return err
+ }
+ s.ensuredOnce = true
+ return nil
+}
+
+func (s *store) enableAuth() error {
+ _, err := s.updateResource("/enabled", true)
+ return err
+}
+func (s *store) disableAuth() error {
+ _, err := s.updateResource("/enabled", false)
+ return err
+}
+
+func (s *store) detectAuth() bool {
+ if s.server == nil {
+ return false
+ }
+ value, err := s.requestResource("/enabled", false, false)
+ if err != nil {
+ if e, ok := err.(*etcderr.Error); ok {
+ if e.ErrorCode == etcderr.EcodeKeyNotFound {
+ return false
+ }
+ }
+ plog.Errorf("failed to detect auth settings (%s)", err)
+ return false
+ }
+
+ var u bool
+ err = json.Unmarshal([]byte(*value.Event.Node.Value), &u)
+ if err != nil {
+ plog.Errorf("internal bookkeeping value for enabled isn't valid JSON (%v)", err)
+ return false
+ }
+ return u
+}
+
+func (s *store) requestResource(res string, dir, quorum bool) (etcdserver.Response, error) {
+ ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
+ defer cancel()
+ p := path.Join(StorePermsPrefix, res)
+ method := "GET"
+ if quorum {
+ method = "QGET"
+ }
+ rr := etcdserverpb.Request{
+ Method: method,
+ Path: p,
+ Dir: dir,
+ }
+ return s.server.Do(ctx, rr)
+}
+
+func (s *store) updateResource(res string, value interface{}) (etcdserver.Response, error) {
+ return s.setResource(res, value, true)
+}
+func (s *store) createResource(res string, value interface{}) (etcdserver.Response, error) {
+ return s.setResource(res, value, false)
+}
+func (s *store) setResource(res string, value interface{}, prevexist bool) (etcdserver.Response, error) {
+ err := s.ensureAuthDirectories()
+ if err != nil {
+ return etcdserver.Response{}, err
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
+ defer cancel()
+ data, err := json.Marshal(value)
+ if err != nil {
+ return etcdserver.Response{}, err
+ }
+ p := path.Join(StorePermsPrefix, res)
+ rr := etcdserverpb.Request{
+ Method: "PUT",
+ Path: p,
+ Val: string(data),
+ PrevExist: &prevexist,
+ }
+ return s.server.Do(ctx, rr)
+}
+
+func (s *store) deleteResource(res string) (etcdserver.Response, error) {
+ err := s.ensureAuthDirectories()
+ if err != nil {
+ return etcdserver.Response{}, err
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
+ defer cancel()
+ pex := true
+ p := path.Join(StorePermsPrefix, res)
+ rr := etcdserverpb.Request{
+ Method: "DELETE",
+ Path: p,
+ PrevExist: &pex,
+ }
+ return s.server.Do(ctx, rr)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/auth/auth_test.go b/vendor/github.com/coreos/etcd/etcdserver/auth/auth_test.go
new file mode 100644
index 00000000..2d81d924
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/auth/auth_test.go
@@ -0,0 +1,676 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 auth
+
+import (
+ "reflect"
+ "testing"
+ "time"
+
+ etcderr "github.com/coreos/etcd/error"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ etcdstore "github.com/coreos/etcd/store"
+ "golang.org/x/net/context"
+)
+
+type fakeDoer struct{}
+
+func (_ fakeDoer) Do(context.Context, etcdserverpb.Request) (etcdserver.Response, error) {
+ return etcdserver.Response{}, nil
+}
+
+func TestCheckPassword(t *testing.T) {
+ st := NewStore(fakeDoer{}, 5*time.Second)
+ u := User{Password: "$2a$10$I3iddh1D..EIOXXQtsra4u8AjOtgEa2ERxVvYGfXFBJDo1omXwP.q"}
+ matched := st.CheckPassword(u, "foo")
+ if matched {
+ t.Fatalf("expected false, got %v", matched)
+ }
+}
+
+const testTimeout = time.Millisecond
+
+func TestMergeUser(t *testing.T) {
+ tbl := []struct {
+ input User
+ merge User
+ expect User
+ iserr bool
+ }{
+ {
+ User{User: "foo"},
+ User{User: "bar"},
+ User{},
+ true,
+ },
+ {
+ User{User: "foo"},
+ User{User: "foo"},
+ User{User: "foo", Roles: []string{}},
+ false,
+ },
+ {
+ User{User: "foo"},
+ User{User: "foo", Grant: []string{"role1"}},
+ User{User: "foo", Roles: []string{"role1"}},
+ false,
+ },
+ {
+ User{User: "foo", Roles: []string{"role1"}},
+ User{User: "foo", Grant: []string{"role1"}},
+ User{},
+ true,
+ },
+ {
+ User{User: "foo", Roles: []string{"role1"}},
+ User{User: "foo", Revoke: []string{"role2"}},
+ User{},
+ true,
+ },
+ {
+ User{User: "foo", Roles: []string{"role1"}},
+ User{User: "foo", Grant: []string{"role2"}},
+ User{User: "foo", Roles: []string{"role1", "role2"}},
+ false,
+ },
+ { // empty password will not overwrite the previous password
+ User{User: "foo", Password: "foo", Roles: []string{}},
+ User{User: "foo", Password: ""},
+ User{User: "foo", Password: "foo", Roles: []string{}},
+ false,
+ },
+ }
+
+ for i, tt := range tbl {
+ out, err := tt.input.merge(tt.merge, passwordStore{})
+ if err != nil && !tt.iserr {
+ t.Fatalf("Got unexpected error on item %d", i)
+ }
+ if !tt.iserr {
+ if !reflect.DeepEqual(out, tt.expect) {
+ t.Errorf("Unequal merge expectation on item %d: got: %#v, expect: %#v", i, out, tt.expect)
+ }
+ }
+ }
+}
+
+func TestMergeRole(t *testing.T) {
+ tbl := []struct {
+ input Role
+ merge Role
+ expect Role
+ iserr bool
+ }{
+ {
+ Role{Role: "foo"},
+ Role{Role: "bar"},
+ Role{},
+ true,
+ },
+ {
+ Role{Role: "foo"},
+ Role{Role: "foo", Grant: &Permissions{KV: RWPermission{Read: []string{"/foodir"}, Write: []string{"/foodir"}}}},
+ Role{Role: "foo", Permissions: Permissions{KV: RWPermission{Read: []string{"/foodir"}, Write: []string{"/foodir"}}}},
+ false,
+ },
+ {
+ Role{Role: "foo", Permissions: Permissions{KV: RWPermission{Read: []string{"/foodir"}, Write: []string{"/foodir"}}}},
+ Role{Role: "foo", Revoke: &Permissions{KV: RWPermission{Read: []string{"/foodir"}, Write: []string{"/foodir"}}}},
+ Role{Role: "foo", Permissions: Permissions{KV: RWPermission{Read: []string{}, Write: []string{}}}},
+ false,
+ },
+ {
+ Role{Role: "foo", Permissions: Permissions{KV: RWPermission{Read: []string{"/bardir"}}}},
+ Role{Role: "foo", Revoke: &Permissions{KV: RWPermission{Read: []string{"/foodir"}}}},
+ Role{},
+ true,
+ },
+ }
+ for i, tt := range tbl {
+ out, err := tt.input.merge(tt.merge)
+ if err != nil && !tt.iserr {
+ t.Fatalf("Got unexpected error on item %d", i)
+ }
+ if !tt.iserr {
+ if !reflect.DeepEqual(out, tt.expect) {
+ t.Errorf("Unequal merge expectation on item %d: got: %#v, expect: %#v", i, out, tt.expect)
+ }
+ }
+ }
+}
+
+type testDoer struct {
+ get []etcdserver.Response
+ put []etcdserver.Response
+ getindex int
+ putindex int
+ explicitlyEnabled bool
+}
+
+func (td *testDoer) Do(_ context.Context, req etcdserverpb.Request) (etcdserver.Response, error) {
+ if td.explicitlyEnabled && (req.Path == StorePermsPrefix+"/enabled") {
+ t := "true"
+ return etcdserver.Response{
+ Event: &etcdstore.Event{
+ Action: etcdstore.Get,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/users/cat",
+ Value: &t,
+ },
+ },
+ }, nil
+ }
+ if (req.Method == "GET" || req.Method == "QGET") && td.get != nil {
+ res := td.get[td.getindex]
+ if res.Event == nil {
+ td.getindex++
+ return etcdserver.Response{}, &etcderr.Error{
+ ErrorCode: etcderr.EcodeKeyNotFound,
+ }
+ }
+ td.getindex++
+ return res, nil
+ }
+ if req.Method == "PUT" && td.put != nil {
+ res := td.put[td.putindex]
+ if res.Event == nil {
+ td.putindex++
+ return etcdserver.Response{}, &etcderr.Error{
+ ErrorCode: etcderr.EcodeNodeExist,
+ }
+ }
+ td.putindex++
+ return res, nil
+ }
+ return etcdserver.Response{}, nil
+}
+
+func TestAllUsers(t *testing.T) {
+ d := &testDoer{
+ get: []etcdserver.Response{
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Get,
+ Node: &etcdstore.NodeExtern{
+ Nodes: etcdstore.NodeExterns([]*etcdstore.NodeExtern{
+ {
+ Key: StorePermsPrefix + "/users/cat",
+ },
+ {
+ Key: StorePermsPrefix + "/users/dog",
+ },
+ }),
+ },
+ },
+ },
+ },
+ }
+ expected := []string{"cat", "dog"}
+
+ s := store{server: d, timeout: testTimeout, ensuredOnce: false}
+ users, err := s.AllUsers()
+ if err != nil {
+ t.Error("Unexpected error", err)
+ }
+ if !reflect.DeepEqual(users, expected) {
+ t.Error("AllUsers doesn't match given store. Got", users, "expected", expected)
+ }
+}
+
+func TestGetAndDeleteUser(t *testing.T) {
+ data := `{"user": "cat", "roles" : ["animal"]}`
+ d := &testDoer{
+ get: []etcdserver.Response{
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Get,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/users/cat",
+ Value: &data,
+ },
+ },
+ },
+ },
+ explicitlyEnabled: true,
+ }
+ expected := User{User: "cat", Roles: []string{"animal"}}
+
+ s := store{server: d, timeout: testTimeout, ensuredOnce: false}
+ out, err := s.GetUser("cat")
+ if err != nil {
+ t.Error("Unexpected error", err)
+ }
+ if !reflect.DeepEqual(out, expected) {
+ t.Error("GetUser doesn't match given store. Got", out, "expected", expected)
+ }
+ err = s.DeleteUser("cat")
+ if err != nil {
+ t.Error("Unexpected error", err)
+ }
+}
+
+func TestAllRoles(t *testing.T) {
+ d := &testDoer{
+ get: []etcdserver.Response{
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Get,
+ Node: &etcdstore.NodeExtern{
+ Nodes: etcdstore.NodeExterns([]*etcdstore.NodeExtern{
+ {
+ Key: StorePermsPrefix + "/roles/animal",
+ },
+ {
+ Key: StorePermsPrefix + "/roles/human",
+ },
+ }),
+ },
+ },
+ },
+ },
+ explicitlyEnabled: true,
+ }
+ expected := []string{"animal", "human", "root"}
+
+ s := store{server: d, timeout: testTimeout, ensuredOnce: false}
+ out, err := s.AllRoles()
+ if err != nil {
+ t.Error("Unexpected error", err)
+ }
+ if !reflect.DeepEqual(out, expected) {
+ t.Error("AllRoles doesn't match given store. Got", out, "expected", expected)
+ }
+}
+
+func TestGetAndDeleteRole(t *testing.T) {
+ data := `{"role": "animal"}`
+ d := &testDoer{
+ get: []etcdserver.Response{
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Get,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/roles/animal",
+ Value: &data,
+ },
+ },
+ },
+ },
+ explicitlyEnabled: true,
+ }
+ expected := Role{Role: "animal"}
+
+ s := store{server: d, timeout: testTimeout, ensuredOnce: false}
+ out, err := s.GetRole("animal")
+ if err != nil {
+ t.Error("Unexpected error", err)
+ }
+ if !reflect.DeepEqual(out, expected) {
+ t.Error("GetRole doesn't match given store. Got", out, "expected", expected)
+ }
+ err = s.DeleteRole("animal")
+ if err != nil {
+ t.Error("Unexpected error", err)
+ }
+}
+
+func TestEnsure(t *testing.T) {
+ d := &testDoer{
+ get: []etcdserver.Response{
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Set,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix,
+ Dir: true,
+ },
+ },
+ },
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Set,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/users/",
+ Dir: true,
+ },
+ },
+ },
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Set,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/roles/",
+ Dir: true,
+ },
+ },
+ },
+ },
+ }
+
+ s := store{server: d, timeout: testTimeout, ensuredOnce: false}
+ err := s.ensureAuthDirectories()
+ if err != nil {
+ t.Error("Unexpected error", err)
+ }
+}
+
+type fastPasswordStore struct {
+}
+
+func (_ fastPasswordStore) CheckPassword(user User, password string) bool {
+ return user.Password == password
+}
+
+func (_ fastPasswordStore) HashPassword(password string) (string, error) { return password, nil }
+
+func TestCreateAndUpdateUser(t *testing.T) {
+ olduser := `{"user": "cat", "roles" : ["animal"]}`
+ newuser := `{"user": "cat", "roles" : ["animal", "pet"]}`
+ d := &testDoer{
+ get: []etcdserver.Response{
+ {
+ Event: nil,
+ },
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Get,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/users/cat",
+ Value: &olduser,
+ },
+ },
+ },
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Get,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/users/cat",
+ Value: &olduser,
+ },
+ },
+ },
+ },
+ put: []etcdserver.Response{
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Update,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/users/cat",
+ Value: &olduser,
+ },
+ },
+ },
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Update,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/users/cat",
+ Value: &newuser,
+ },
+ },
+ },
+ },
+ explicitlyEnabled: true,
+ }
+ user := User{User: "cat", Password: "meow", Roles: []string{"animal"}}
+ update := User{User: "cat", Grant: []string{"pet"}}
+ expected := User{User: "cat", Roles: []string{"animal", "pet"}}
+
+ s := store{server: d, timeout: testTimeout, ensuredOnce: true, PasswordStore: fastPasswordStore{}}
+ out, created, err := s.CreateOrUpdateUser(user)
+ if !created {
+ t.Error("Should have created user, instead updated?")
+ }
+ if err != nil {
+ t.Error("Unexpected error", err)
+ }
+ out.Password = "meow"
+ if !reflect.DeepEqual(out, user) {
+ t.Error("UpdateUser doesn't match given update. Got", out, "expected", expected)
+ }
+ out, created, err = s.CreateOrUpdateUser(update)
+ if created {
+ t.Error("Should have updated user, instead created?")
+ }
+ if err != nil {
+ t.Error("Unexpected error", err)
+ }
+ if !reflect.DeepEqual(out, expected) {
+ t.Error("UpdateUser doesn't match given update. Got", out, "expected", expected)
+ }
+}
+
+func TestUpdateRole(t *testing.T) {
+ oldrole := `{"role": "animal", "permissions" : {"kv": {"read": ["/animal"], "write": []}}}`
+ newrole := `{"role": "animal", "permissions" : {"kv": {"read": ["/animal"], "write": ["/animal"]}}}`
+ d := &testDoer{
+ get: []etcdserver.Response{
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Get,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/roles/animal",
+ Value: &oldrole,
+ },
+ },
+ },
+ },
+ put: []etcdserver.Response{
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Update,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/roles/animal",
+ Value: &newrole,
+ },
+ },
+ },
+ },
+ explicitlyEnabled: true,
+ }
+ update := Role{Role: "animal", Grant: &Permissions{KV: RWPermission{Read: []string{}, Write: []string{"/animal"}}}}
+ expected := Role{Role: "animal", Permissions: Permissions{KV: RWPermission{Read: []string{"/animal"}, Write: []string{"/animal"}}}}
+
+ s := store{server: d, timeout: testTimeout, ensuredOnce: true}
+ out, err := s.UpdateRole(update)
+ if err != nil {
+ t.Error("Unexpected error", err)
+ }
+ if !reflect.DeepEqual(out, expected) {
+ t.Error("UpdateRole doesn't match given update. Got", out, "expected", expected)
+ }
+}
+
+func TestCreateRole(t *testing.T) {
+ role := `{"role": "animal", "permissions" : {"kv": {"read": ["/animal"], "write": []}}}`
+ d := &testDoer{
+ put: []etcdserver.Response{
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Create,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/roles/animal",
+ Value: &role,
+ },
+ },
+ },
+ {
+ Event: nil,
+ },
+ },
+ explicitlyEnabled: true,
+ }
+ r := Role{Role: "animal", Permissions: Permissions{KV: RWPermission{Read: []string{"/animal"}, Write: []string{}}}}
+
+ s := store{server: d, timeout: testTimeout, ensuredOnce: true}
+ err := s.CreateRole(Role{Role: "root"})
+ if err == nil {
+ t.Error("Should error creating root role")
+ }
+ err = s.CreateRole(r)
+ if err != nil {
+ t.Error("Unexpected error", err)
+ }
+ err = s.CreateRole(r)
+ if err == nil {
+ t.Error("Creating duplicate role, should error")
+ }
+}
+
+func TestEnableAuth(t *testing.T) {
+ rootUser := `{"user": "root", "password": ""}`
+ guestRole := `{"role": "guest", "permissions" : {"kv": {"read": ["*"], "write": ["*"]}}}`
+ trueval := "true"
+ falseval := "false"
+ d := &testDoer{
+ get: []etcdserver.Response{
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Get,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/enabled",
+ Value: &falseval,
+ },
+ },
+ },
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Get,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/user/root",
+ Value: &rootUser,
+ },
+ },
+ },
+ {
+ Event: nil,
+ },
+ },
+ put: []etcdserver.Response{
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Create,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/roles/guest",
+ Value: &guestRole,
+ },
+ },
+ },
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Update,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/enabled",
+ Value: &trueval,
+ },
+ },
+ },
+ },
+ explicitlyEnabled: false,
+ }
+ s := store{server: d, timeout: testTimeout, ensuredOnce: true}
+ err := s.EnableAuth()
+ if err != nil {
+ t.Error("Unexpected error", err)
+ }
+}
+
+func TestDisableAuth(t *testing.T) {
+ trueval := "true"
+ falseval := "false"
+ d := &testDoer{
+ get: []etcdserver.Response{
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Get,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/enabled",
+ Value: &falseval,
+ },
+ },
+ },
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Get,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/enabled",
+ Value: &trueval,
+ },
+ },
+ },
+ },
+ put: []etcdserver.Response{
+ {
+ Event: &etcdstore.Event{
+ Action: etcdstore.Update,
+ Node: &etcdstore.NodeExtern{
+ Key: StorePermsPrefix + "/enabled",
+ Value: &falseval,
+ },
+ },
+ },
+ },
+ explicitlyEnabled: false,
+ }
+ s := store{server: d, timeout: testTimeout, ensuredOnce: true}
+ err := s.DisableAuth()
+ if err == nil {
+ t.Error("Expected error; already disabled")
+ }
+
+ err = s.DisableAuth()
+ if err != nil {
+ t.Error("Unexpected error", err)
+ }
+}
+
+func TestSimpleMatch(t *testing.T) {
+ role := Role{Role: "foo", Permissions: Permissions{KV: RWPermission{Read: []string{"/foodir/*", "/fookey"}, Write: []string{"/bardir/*", "/barkey"}}}}
+ if !role.HasKeyAccess("/foodir/foo/bar", false) {
+ t.Fatal("role lacks expected access")
+ }
+ if !role.HasKeyAccess("/fookey", false) {
+ t.Fatal("role lacks expected access")
+ }
+ if !role.HasRecursiveAccess("/foodir/*", false) {
+ t.Fatal("role lacks expected access")
+ }
+ if !role.HasRecursiveAccess("/foodir/foo*", false) {
+ t.Fatal("role lacks expected access")
+ }
+ if !role.HasRecursiveAccess("/bardir/*", true) {
+ t.Fatal("role lacks expected access")
+ }
+ if !role.HasKeyAccess("/bardir/bar/foo", true) {
+ t.Fatal("role lacks expected access")
+ }
+ if !role.HasKeyAccess("/barkey", true) {
+ t.Fatal("role lacks expected access")
+ }
+
+ if role.HasKeyAccess("/bardir/bar/foo", false) {
+ t.Fatal("role has unexpected access")
+ }
+ if role.HasKeyAccess("/barkey", false) {
+ t.Fatal("role has unexpected access")
+ }
+ if role.HasKeyAccess("/foodir/foo/bar", true) {
+ t.Fatal("role has unexpected access")
+ }
+ if role.HasKeyAccess("/fookey", true) {
+ t.Fatal("role has unexpected access")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/backend.go b/vendor/github.com/coreos/etcd/etcdserver/backend.go
new file mode 100644
index 00000000..c5e2dabf
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/backend.go
@@ -0,0 +1,81 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "fmt"
+ "os"
+ "time"
+
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/snap"
+)
+
+func newBackend(cfg *ServerConfig) backend.Backend {
+ bcfg := backend.DefaultBackendConfig()
+ bcfg.Path = cfg.backendPath()
+ if cfg.QuotaBackendBytes > 0 && cfg.QuotaBackendBytes != DefaultQuotaBytes {
+ // permit 10% excess over quota for disarm
+ bcfg.MmapSize = uint64(cfg.QuotaBackendBytes + cfg.QuotaBackendBytes/10)
+ }
+ return backend.New(bcfg)
+}
+
+// openSnapshotBackend renames a snapshot db to the current etcd db and opens it.
+func openSnapshotBackend(cfg *ServerConfig, ss *snap.Snapshotter, snapshot raftpb.Snapshot) (backend.Backend, error) {
+ snapPath, err := ss.DBFilePath(snapshot.Metadata.Index)
+ if err != nil {
+ return nil, fmt.Errorf("database snapshot file path error: %v", err)
+ }
+ if err := os.Rename(snapPath, cfg.backendPath()); err != nil {
+ return nil, fmt.Errorf("rename snapshot file error: %v", err)
+ }
+ return openBackend(cfg), nil
+}
+
+// openBackend returns a backend using the current etcd db.
+func openBackend(cfg *ServerConfig) backend.Backend {
+ fn := cfg.backendPath()
+ beOpened := make(chan backend.Backend)
+ go func() {
+ beOpened <- newBackend(cfg)
+ }()
+ select {
+ case be := <-beOpened:
+ return be
+ case <-time.After(time.Second):
+ plog.Warningf("another etcd process is using %q and holds the file lock.", fn)
+ plog.Warningf("waiting for it to exit before starting...")
+ }
+ return <-beOpened
+}
+
+// recoverBackendSnapshot recovers the DB from a snapshot in case etcd crashes
+// before updating the backend db after persisting raft snapshot to disk,
+// violating the invariant snapshot.Metadata.Index < db.consistentIndex. In this
+// case, replace the db with the snapshot db sent by the leader.
+func recoverSnapshotBackend(cfg *ServerConfig, oldbe backend.Backend, snapshot raftpb.Snapshot) (backend.Backend, error) {
+ var cIndex consistentIndex
+ kv := mvcc.New(oldbe, &lease.FakeLessor{}, &cIndex)
+ defer kv.Close()
+ if snapshot.Metadata.Index <= kv.ConsistentIndex() {
+ return oldbe, nil
+ }
+ oldbe.Close()
+ return openSnapshotBackend(cfg, snap.New(cfg.SnapDir()), snapshot)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/cluster_util.go b/vendor/github.com/coreos/etcd/etcdserver/cluster_util.go
new file mode 100644
index 00000000..f44862a4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/cluster_util.go
@@ -0,0 +1,258 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "encoding/json"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "sort"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/version"
+ "github.com/coreos/go-semver/semver"
+)
+
+// isMemberBootstrapped tries to check if the given member has been bootstrapped
+// in the given cluster.
+func isMemberBootstrapped(cl *membership.RaftCluster, member string, rt http.RoundTripper, timeout time.Duration) bool {
+ rcl, err := getClusterFromRemotePeers(getRemotePeerURLs(cl, member), timeout, false, rt)
+ if err != nil {
+ return false
+ }
+ id := cl.MemberByName(member).ID
+ m := rcl.Member(id)
+ if m == nil {
+ return false
+ }
+ if len(m.ClientURLs) > 0 {
+ return true
+ }
+ return false
+}
+
+// GetClusterFromRemotePeers takes a set of URLs representing etcd peers, and
+// attempts to construct a Cluster by accessing the members endpoint on one of
+// these URLs. The first URL to provide a response is used. If no URLs provide
+// a response, or a Cluster cannot be successfully created from a received
+// response, an error is returned.
+// Each request has a 10-second timeout. Because the upper limit of TTL is 5s,
+// 10 second is enough for building connection and finishing request.
+func GetClusterFromRemotePeers(urls []string, rt http.RoundTripper) (*membership.RaftCluster, error) {
+ return getClusterFromRemotePeers(urls, 10*time.Second, true, rt)
+}
+
+// If logerr is true, it prints out more error messages.
+func getClusterFromRemotePeers(urls []string, timeout time.Duration, logerr bool, rt http.RoundTripper) (*membership.RaftCluster, error) {
+ cc := &http.Client{
+ Transport: rt,
+ Timeout: timeout,
+ }
+ for _, u := range urls {
+ resp, err := cc.Get(u + "/members")
+ if err != nil {
+ if logerr {
+ plog.Warningf("could not get cluster response from %s: %v", u, err)
+ }
+ continue
+ }
+ b, err := ioutil.ReadAll(resp.Body)
+ resp.Body.Close()
+ if err != nil {
+ if logerr {
+ plog.Warningf("could not read the body of cluster response: %v", err)
+ }
+ continue
+ }
+ var membs []*membership.Member
+ if err = json.Unmarshal(b, &membs); err != nil {
+ if logerr {
+ plog.Warningf("could not unmarshal cluster response: %v", err)
+ }
+ continue
+ }
+ id, err := types.IDFromString(resp.Header.Get("X-Etcd-Cluster-ID"))
+ if err != nil {
+ if logerr {
+ plog.Warningf("could not parse the cluster ID from cluster res: %v", err)
+ }
+ continue
+ }
+
+ // check the length of membership members
+ // if the membership members are present then prepare and return raft cluster
+ // if membership members are not present then the raft cluster formed will be
+ // an invalid empty cluster hence return failed to get raft cluster member(s) from the given urls error
+ if len(membs) > 0 {
+ return membership.NewClusterFromMembers("", id, membs), nil
+ }
+
+ return nil, fmt.Errorf("failed to get raft cluster member(s) from the given urls.")
+ }
+ return nil, fmt.Errorf("could not retrieve cluster information from the given urls")
+}
+
+// getRemotePeerURLs returns peer urls of remote members in the cluster. The
+// returned list is sorted in ascending lexicographical order.
+func getRemotePeerURLs(cl *membership.RaftCluster, local string) []string {
+ us := make([]string, 0)
+ for _, m := range cl.Members() {
+ if m.Name == local {
+ continue
+ }
+ us = append(us, m.PeerURLs...)
+ }
+ sort.Strings(us)
+ return us
+}
+
+// getVersions returns the versions of the members in the given cluster.
+// The key of the returned map is the member's ID. The value of the returned map
+// is the semver versions string, including server and cluster.
+// If it fails to get the version of a member, the key will be nil.
+func getVersions(cl *membership.RaftCluster, local types.ID, rt http.RoundTripper) map[string]*version.Versions {
+ members := cl.Members()
+ vers := make(map[string]*version.Versions)
+ for _, m := range members {
+ if m.ID == local {
+ cv := "not_decided"
+ if cl.Version() != nil {
+ cv = cl.Version().String()
+ }
+ vers[m.ID.String()] = &version.Versions{Server: version.Version, Cluster: cv}
+ continue
+ }
+ ver, err := getVersion(m, rt)
+ if err != nil {
+ plog.Warningf("cannot get the version of member %s (%v)", m.ID, err)
+ vers[m.ID.String()] = nil
+ } else {
+ vers[m.ID.String()] = ver
+ }
+ }
+ return vers
+}
+
+// decideClusterVersion decides the cluster version based on the versions map.
+// The returned version is the min server version in the map, or nil if the min
+// version in unknown.
+func decideClusterVersion(vers map[string]*version.Versions) *semver.Version {
+ var cv *semver.Version
+ lv := semver.Must(semver.NewVersion(version.Version))
+
+ for mid, ver := range vers {
+ if ver == nil {
+ return nil
+ }
+ v, err := semver.NewVersion(ver.Server)
+ if err != nil {
+ plog.Errorf("cannot understand the version of member %s (%v)", mid, err)
+ return nil
+ }
+ if lv.LessThan(*v) {
+ plog.Warningf("the local etcd version %s is not up-to-date", lv.String())
+ plog.Warningf("member %s has a higher version %s", mid, ver.Server)
+ }
+ if cv == nil {
+ cv = v
+ } else if v.LessThan(*cv) {
+ cv = v
+ }
+ }
+ return cv
+}
+
+// isCompatibleWithCluster return true if the local member has a compatible version with
+// the current running cluster.
+// The version is considered as compatible when at least one of the other members in the cluster has a
+// cluster version in the range of [MinClusterVersion, Version] and no known members has a cluster version
+// out of the range.
+// We set this rule since when the local member joins, another member might be offline.
+func isCompatibleWithCluster(cl *membership.RaftCluster, local types.ID, rt http.RoundTripper) bool {
+ vers := getVersions(cl, local, rt)
+ minV := semver.Must(semver.NewVersion(version.MinClusterVersion))
+ maxV := semver.Must(semver.NewVersion(version.Version))
+ maxV = &semver.Version{
+ Major: maxV.Major,
+ Minor: maxV.Minor,
+ }
+
+ return isCompatibleWithVers(vers, local, minV, maxV)
+}
+
+func isCompatibleWithVers(vers map[string]*version.Versions, local types.ID, minV, maxV *semver.Version) bool {
+ var ok bool
+ for id, v := range vers {
+ // ignore comparison with local version
+ if id == local.String() {
+ continue
+ }
+ if v == nil {
+ continue
+ }
+ clusterv, err := semver.NewVersion(v.Cluster)
+ if err != nil {
+ plog.Errorf("cannot understand the cluster version of member %s (%v)", id, err)
+ continue
+ }
+ if clusterv.LessThan(*minV) {
+ plog.Warningf("the running cluster version(%v) is lower than the minimal cluster version(%v) supported", clusterv.String(), minV.String())
+ return false
+ }
+ if maxV.LessThan(*clusterv) {
+ plog.Warningf("the running cluster version(%v) is higher than the maximum cluster version(%v) supported", clusterv.String(), maxV.String())
+ return false
+ }
+ ok = true
+ }
+ return ok
+}
+
+// getVersion returns the Versions of the given member via its
+// peerURLs. Returns the last error if it fails to get the version.
+func getVersion(m *membership.Member, rt http.RoundTripper) (*version.Versions, error) {
+ cc := &http.Client{
+ Transport: rt,
+ }
+ var (
+ err error
+ resp *http.Response
+ )
+
+ for _, u := range m.PeerURLs {
+ resp, err = cc.Get(u + "/version")
+ if err != nil {
+ plog.Warningf("failed to reach the peerURL(%s) of member %s (%v)", u, m.ID, err)
+ continue
+ }
+ var b []byte
+ b, err = ioutil.ReadAll(resp.Body)
+ resp.Body.Close()
+ if err != nil {
+ plog.Warningf("failed to read out the response body from the peerURL(%s) of member %s (%v)", u, m.ID, err)
+ continue
+ }
+ var vers version.Versions
+ if err = json.Unmarshal(b, &vers); err != nil {
+ plog.Warningf("failed to unmarshal the response body got from the peerURL(%s) of member %s (%v)", u, m.ID, err)
+ continue
+ }
+ return &vers, nil
+ }
+ return nil, err
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/cluster_util_test.go b/vendor/github.com/coreos/etcd/etcdserver/cluster_util_test.go
new file mode 100644
index 00000000..159d3f3a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/cluster_util_test.go
@@ -0,0 +1,131 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/version"
+ "github.com/coreos/go-semver/semver"
+)
+
+func TestDecideClusterVersion(t *testing.T) {
+ tests := []struct {
+ vers map[string]*version.Versions
+ wdver *semver.Version
+ }{
+ {
+ map[string]*version.Versions{"a": {Server: "2.0.0"}},
+ semver.Must(semver.NewVersion("2.0.0")),
+ },
+ // unknown
+ {
+ map[string]*version.Versions{"a": nil},
+ nil,
+ },
+ {
+ map[string]*version.Versions{"a": {Server: "2.0.0"}, "b": {Server: "2.1.0"}, "c": {Server: "2.1.0"}},
+ semver.Must(semver.NewVersion("2.0.0")),
+ },
+ {
+ map[string]*version.Versions{"a": {Server: "2.1.0"}, "b": {Server: "2.1.0"}, "c": {Server: "2.1.0"}},
+ semver.Must(semver.NewVersion("2.1.0")),
+ },
+ {
+ map[string]*version.Versions{"a": nil, "b": {Server: "2.1.0"}, "c": {Server: "2.1.0"}},
+ nil,
+ },
+ }
+
+ for i, tt := range tests {
+ dver := decideClusterVersion(tt.vers)
+ if !reflect.DeepEqual(dver, tt.wdver) {
+ t.Errorf("#%d: ver = %+v, want %+v", i, dver, tt.wdver)
+ }
+ }
+}
+
+func TestIsCompatibleWithVers(t *testing.T) {
+ tests := []struct {
+ vers map[string]*version.Versions
+ local types.ID
+ minV, maxV *semver.Version
+ wok bool
+ }{
+ // too low
+ {
+ map[string]*version.Versions{
+ "a": {Server: "2.0.0", Cluster: "not_decided"},
+ "b": {Server: "2.1.0", Cluster: "2.1.0"},
+ "c": {Server: "2.1.0", Cluster: "2.1.0"},
+ },
+ 0xa,
+ semver.Must(semver.NewVersion("2.0.0")), semver.Must(semver.NewVersion("2.0.0")),
+ false,
+ },
+ {
+ map[string]*version.Versions{
+ "a": {Server: "2.1.0", Cluster: "not_decided"},
+ "b": {Server: "2.1.0", Cluster: "2.1.0"},
+ "c": {Server: "2.1.0", Cluster: "2.1.0"},
+ },
+ 0xa,
+ semver.Must(semver.NewVersion("2.0.0")), semver.Must(semver.NewVersion("2.1.0")),
+ true,
+ },
+ // too high
+ {
+ map[string]*version.Versions{
+ "a": {Server: "2.2.0", Cluster: "not_decided"},
+ "b": {Server: "2.0.0", Cluster: "2.0.0"},
+ "c": {Server: "2.0.0", Cluster: "2.0.0"},
+ },
+ 0xa,
+ semver.Must(semver.NewVersion("2.1.0")), semver.Must(semver.NewVersion("2.2.0")),
+ false,
+ },
+ // cannot get b's version, expect ok
+ {
+ map[string]*version.Versions{
+ "a": {Server: "2.1.0", Cluster: "not_decided"},
+ "b": nil,
+ "c": {Server: "2.1.0", Cluster: "2.1.0"},
+ },
+ 0xa,
+ semver.Must(semver.NewVersion("2.0.0")), semver.Must(semver.NewVersion("2.1.0")),
+ true,
+ },
+ // cannot get b and c's version, expect not ok
+ {
+ map[string]*version.Versions{
+ "a": {Server: "2.1.0", Cluster: "not_decided"},
+ "b": nil,
+ "c": nil,
+ },
+ 0xa,
+ semver.Must(semver.NewVersion("2.0.0")), semver.Must(semver.NewVersion("2.1.0")),
+ false,
+ },
+ }
+
+ for i, tt := range tests {
+ ok := isCompatibleWithVers(tt.vers, tt.local, tt.minV, tt.maxV)
+ if ok != tt.wok {
+ t.Errorf("#%d: ok = %+v, want %+v", i, ok, tt.wok)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/config.go b/vendor/github.com/coreos/etcd/etcdserver/config.go
new file mode 100644
index 00000000..9c258934
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/config.go
@@ -0,0 +1,204 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "fmt"
+ "path/filepath"
+ "sort"
+ "strings"
+ "time"
+
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/pkg/netutil"
+ "github.com/coreos/etcd/pkg/transport"
+ "github.com/coreos/etcd/pkg/types"
+)
+
+// ServerConfig holds the configuration of etcd as taken from the command line or discovery.
+type ServerConfig struct {
+ Name string
+ DiscoveryURL string
+ DiscoveryProxy string
+ ClientURLs types.URLs
+ PeerURLs types.URLs
+ DataDir string
+ // DedicatedWALDir config will make the etcd to write the WAL to the WALDir
+ // rather than the dataDir/member/wal.
+ DedicatedWALDir string
+ SnapCount uint64
+ MaxSnapFiles uint
+ MaxWALFiles uint
+ InitialPeerURLsMap types.URLsMap
+ InitialClusterToken string
+ NewCluster bool
+ ForceNewCluster bool
+ PeerTLSInfo transport.TLSInfo
+
+ TickMs uint
+ ElectionTicks int
+ BootstrapTimeout time.Duration
+
+ AutoCompactionRetention int
+ QuotaBackendBytes int64
+
+ StrictReconfigCheck bool
+
+ // ClientCertAuthEnabled is true when cert has been signed by the client CA.
+ ClientCertAuthEnabled bool
+
+ AuthToken string
+}
+
+// VerifyBootstrap sanity-checks the initial config for bootstrap case
+// and returns an error for things that should never happen.
+func (c *ServerConfig) VerifyBootstrap() error {
+ if err := c.hasLocalMember(); err != nil {
+ return err
+ }
+ if err := c.advertiseMatchesCluster(); err != nil {
+ return err
+ }
+ if checkDuplicateURL(c.InitialPeerURLsMap) {
+ return fmt.Errorf("initial cluster %s has duplicate url", c.InitialPeerURLsMap)
+ }
+ if c.InitialPeerURLsMap.String() == "" && c.DiscoveryURL == "" {
+ return fmt.Errorf("initial cluster unset and no discovery URL found")
+ }
+ return nil
+}
+
+// VerifyJoinExisting sanity-checks the initial config for join existing cluster
+// case and returns an error for things that should never happen.
+func (c *ServerConfig) VerifyJoinExisting() error {
+ // The member has announced its peer urls to the cluster before starting; no need to
+ // set the configuration again.
+ if err := c.hasLocalMember(); err != nil {
+ return err
+ }
+ if checkDuplicateURL(c.InitialPeerURLsMap) {
+ return fmt.Errorf("initial cluster %s has duplicate url", c.InitialPeerURLsMap)
+ }
+ if c.DiscoveryURL != "" {
+ return fmt.Errorf("discovery URL should not be set when joining existing initial cluster")
+ }
+ return nil
+}
+
+// hasLocalMember checks that the cluster at least contains the local server.
+func (c *ServerConfig) hasLocalMember() error {
+ if urls := c.InitialPeerURLsMap[c.Name]; urls == nil {
+ return fmt.Errorf("couldn't find local name %q in the initial cluster configuration", c.Name)
+ }
+ return nil
+}
+
+// advertiseMatchesCluster confirms peer URLs match those in the cluster peer list.
+func (c *ServerConfig) advertiseMatchesCluster() error {
+ urls, apurls := c.InitialPeerURLsMap[c.Name], c.PeerURLs.StringSlice()
+ urls.Sort()
+ sort.Strings(apurls)
+ ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
+ defer cancel()
+ if !netutil.URLStringsEqual(ctx, apurls, urls.StringSlice()) {
+ umap := map[string]types.URLs{c.Name: c.PeerURLs}
+ return fmt.Errorf("--initial-cluster must include %s given --initial-advertise-peer-urls=%s", types.URLsMap(umap).String(), strings.Join(apurls, ","))
+ }
+ return nil
+}
+
+func (c *ServerConfig) MemberDir() string { return filepath.Join(c.DataDir, "member") }
+
+func (c *ServerConfig) WALDir() string {
+ if c.DedicatedWALDir != "" {
+ return c.DedicatedWALDir
+ }
+ return filepath.Join(c.MemberDir(), "wal")
+}
+
+func (c *ServerConfig) SnapDir() string { return filepath.Join(c.MemberDir(), "snap") }
+
+func (c *ServerConfig) ShouldDiscover() bool { return c.DiscoveryURL != "" }
+
+// ReqTimeout returns timeout for request to finish.
+func (c *ServerConfig) ReqTimeout() time.Duration {
+ // 5s for queue waiting, computation and disk IO delay
+ // + 2 * election timeout for possible leader election
+ return 5*time.Second + 2*time.Duration(c.ElectionTicks)*time.Duration(c.TickMs)*time.Millisecond
+}
+
+func (c *ServerConfig) electionTimeout() time.Duration {
+ return time.Duration(c.ElectionTicks) * time.Duration(c.TickMs) * time.Millisecond
+}
+
+func (c *ServerConfig) peerDialTimeout() time.Duration {
+ // 1s for queue wait and system delay
+ // + one RTT, which is smaller than 1/5 election timeout
+ return time.Second + time.Duration(c.ElectionTicks)*time.Duration(c.TickMs)*time.Millisecond/5
+}
+
+func (c *ServerConfig) PrintWithInitial() { c.print(true) }
+
+func (c *ServerConfig) Print() { c.print(false) }
+
+func (c *ServerConfig) print(initial bool) {
+ plog.Infof("name = %s", c.Name)
+ if c.ForceNewCluster {
+ plog.Infof("force new cluster")
+ }
+ plog.Infof("data dir = %s", c.DataDir)
+ plog.Infof("member dir = %s", c.MemberDir())
+ if c.DedicatedWALDir != "" {
+ plog.Infof("dedicated WAL dir = %s", c.DedicatedWALDir)
+ }
+ plog.Infof("heartbeat = %dms", c.TickMs)
+ plog.Infof("election = %dms", c.ElectionTicks*int(c.TickMs))
+ plog.Infof("snapshot count = %d", c.SnapCount)
+ if len(c.DiscoveryURL) != 0 {
+ plog.Infof("discovery URL= %s", c.DiscoveryURL)
+ if len(c.DiscoveryProxy) != 0 {
+ plog.Infof("discovery proxy = %s", c.DiscoveryProxy)
+ }
+ }
+ plog.Infof("advertise client URLs = %s", c.ClientURLs)
+ if initial {
+ plog.Infof("initial advertise peer URLs = %s", c.PeerURLs)
+ plog.Infof("initial cluster = %s", c.InitialPeerURLsMap)
+ }
+}
+
+func checkDuplicateURL(urlsmap types.URLsMap) bool {
+ um := make(map[string]bool)
+ for _, urls := range urlsmap {
+ for _, url := range urls {
+ u := url.String()
+ if um[u] {
+ return true
+ }
+ um[u] = true
+ }
+ }
+ return false
+}
+
+func (c *ServerConfig) bootstrapTimeout() time.Duration {
+ if c.BootstrapTimeout != 0 {
+ return c.BootstrapTimeout
+ }
+ return time.Second
+}
+
+func (c *ServerConfig) backendPath() string { return filepath.Join(c.SnapDir(), "db") }
diff --git a/vendor/github.com/coreos/etcd/etcdserver/config_test.go b/vendor/github.com/coreos/etcd/etcdserver/config_test.go
new file mode 100644
index 00000000..bf0cd7f7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/config_test.go
@@ -0,0 +1,196 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "net/url"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/types"
+)
+
+func mustNewURLs(t *testing.T, urls []string) []url.URL {
+ if len(urls) == 0 {
+ return nil
+ }
+ u, err := types.NewURLs(urls)
+ if err != nil {
+ t.Fatalf("error creating new URLs from %q: %v", urls, err)
+ }
+ return u
+}
+
+func TestConfigVerifyBootstrapWithoutClusterAndDiscoveryURLFail(t *testing.T) {
+ c := &ServerConfig{
+ Name: "node1",
+ DiscoveryURL: "",
+ InitialPeerURLsMap: types.URLsMap{},
+ }
+ if err := c.VerifyBootstrap(); err == nil {
+ t.Errorf("err = nil, want not nil")
+ }
+}
+
+func TestConfigVerifyExistingWithDiscoveryURLFail(t *testing.T) {
+ cluster, err := types.NewURLsMap("node1=http://127.0.0.1:2380")
+ if err != nil {
+ t.Fatalf("NewCluster error: %v", err)
+ }
+ c := &ServerConfig{
+ Name: "node1",
+ DiscoveryURL: "http://127.0.0.1:2379/abcdefg",
+ PeerURLs: mustNewURLs(t, []string{"http://127.0.0.1:2380"}),
+ InitialPeerURLsMap: cluster,
+ NewCluster: false,
+ }
+ if err := c.VerifyJoinExisting(); err == nil {
+ t.Errorf("err = nil, want not nil")
+ }
+}
+
+func TestConfigVerifyLocalMember(t *testing.T) {
+ tests := []struct {
+ clusterSetting string
+ apurls []string
+ strict bool
+ shouldError bool
+ }{
+ {
+ // Node must exist in cluster
+ "",
+ nil,
+ true,
+
+ true,
+ },
+ {
+ // Initial cluster set
+ "node1=http://localhost:7001,node2=http://localhost:7002",
+ []string{"http://localhost:7001"},
+ true,
+
+ false,
+ },
+ {
+ // Default initial cluster
+ "node1=http://localhost:2380,node1=http://localhost:7001",
+ []string{"http://localhost:2380", "http://localhost:7001"},
+ true,
+
+ false,
+ },
+ {
+ // Advertised peer URLs must match those in cluster-state
+ "node1=http://localhost:7001",
+ []string{"http://localhost:12345"},
+ true,
+
+ true,
+ },
+ {
+ // Advertised peer URLs must match those in cluster-state
+ "node1=http://localhost:2380,node1=http://localhost:12345",
+ []string{"http://localhost:12345"},
+ true,
+
+ true,
+ },
+ {
+ // Advertised peer URLs must match those in cluster-state
+ "node1=http://localhost:2380",
+ []string{},
+ true,
+
+ true,
+ },
+ {
+ // do not care about the urls if strict is not set
+ "node1=http://localhost:2380",
+ []string{},
+ false,
+
+ false,
+ },
+ }
+
+ for i, tt := range tests {
+ cluster, err := types.NewURLsMap(tt.clusterSetting)
+ if err != nil {
+ t.Fatalf("#%d: Got unexpected error: %v", i, err)
+ }
+ cfg := ServerConfig{
+ Name: "node1",
+ InitialPeerURLsMap: cluster,
+ }
+ if tt.apurls != nil {
+ cfg.PeerURLs = mustNewURLs(t, tt.apurls)
+ }
+ if err = cfg.hasLocalMember(); err == nil && tt.strict {
+ err = cfg.advertiseMatchesCluster()
+ }
+ if (err == nil) && tt.shouldError {
+ t.Errorf("#%d: Got no error where one was expected", i)
+ }
+ if (err != nil) && !tt.shouldError {
+ t.Errorf("#%d: Got unexpected error: %v", i, err)
+ }
+ }
+}
+
+func TestSnapDir(t *testing.T) {
+ tests := map[string]string{
+ "/": "/member/snap",
+ "/var/lib/etc": "/var/lib/etc/member/snap",
+ }
+ for dd, w := range tests {
+ cfg := ServerConfig{
+ DataDir: dd,
+ }
+ if g := cfg.SnapDir(); g != w {
+ t.Errorf("DataDir=%q: SnapDir()=%q, want=%q", dd, g, w)
+ }
+ }
+}
+
+func TestWALDir(t *testing.T) {
+ tests := map[string]string{
+ "/": "/member/wal",
+ "/var/lib/etc": "/var/lib/etc/member/wal",
+ }
+ for dd, w := range tests {
+ cfg := ServerConfig{
+ DataDir: dd,
+ }
+ if g := cfg.WALDir(); g != w {
+ t.Errorf("DataDir=%q: WALDir()=%q, want=%q", dd, g, w)
+ }
+ }
+}
+
+func TestShouldDiscover(t *testing.T) {
+ tests := map[string]bool{
+ "": false,
+ "foo": true,
+ "http://discovery.etcd.io/asdf": true,
+ }
+ for durl, w := range tests {
+ cfg := ServerConfig{
+ DiscoveryURL: durl,
+ }
+ if g := cfg.ShouldDiscover(); g != w {
+ t.Errorf("durl=%q: ShouldDiscover()=%t, want=%t", durl, g, w)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/consistent_index.go b/vendor/github.com/coreos/etcd/etcdserver/consistent_index.go
new file mode 100644
index 00000000..d513f670
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/consistent_index.go
@@ -0,0 +1,33 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "sync/atomic"
+)
+
+// consistentIndex represents the offset of an entry in a consistent replica log.
+// It implements the mvcc.ConsistentIndexGetter interface.
+// It is always set to the offset of current entry before executing the entry,
+// so ConsistentWatchableKV could get the consistent index from it.
+type consistentIndex uint64
+
+func (i *consistentIndex) setConsistentIndex(v uint64) {
+ atomic.StoreUint64((*uint64)(i), v)
+}
+
+func (i *consistentIndex) ConsistentIndex() uint64 {
+ return atomic.LoadUint64((*uint64)(i))
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/consistent_index_test.go b/vendor/github.com/coreos/etcd/etcdserver/consistent_index_test.go
new file mode 100644
index 00000000..0d74fca8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/consistent_index_test.go
@@ -0,0 +1,25 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import "testing"
+
+func TestConsistentIndex(t *testing.T) {
+ var i consistentIndex
+ i.setConsistentIndex(10)
+ if g := i.ConsistentIndex(); g != 10 {
+ t.Errorf("value = %d, want 10", g)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/doc.go b/vendor/github.com/coreos/etcd/etcdserver/doc.go
new file mode 100644
index 00000000..b195d2d1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver defines how etcd servers interact and store their states.
+package etcdserver
diff --git a/vendor/github.com/coreos/etcd/etcdserver/errors.go b/vendor/github.com/coreos/etcd/etcdserver/errors.go
new file mode 100644
index 00000000..ed749dbe
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/errors.go
@@ -0,0 +1,46 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "errors"
+ "fmt"
+)
+
+var (
+ ErrUnknownMethod = errors.New("etcdserver: unknown method")
+ ErrStopped = errors.New("etcdserver: server stopped")
+ ErrCanceled = errors.New("etcdserver: request cancelled")
+ ErrTimeout = errors.New("etcdserver: request timed out")
+ ErrTimeoutDueToLeaderFail = errors.New("etcdserver: request timed out, possibly due to previous leader failure")
+ ErrTimeoutDueToConnectionLost = errors.New("etcdserver: request timed out, possibly due to connection lost")
+ ErrTimeoutLeaderTransfer = errors.New("etcdserver: request timed out, leader transfer took too long")
+ ErrNotEnoughStartedMembers = errors.New("etcdserver: re-configuration failed due to not enough started members")
+ ErrNoLeader = errors.New("etcdserver: no leader")
+ ErrRequestTooLarge = errors.New("etcdserver: request is too large")
+ ErrNoSpace = errors.New("etcdserver: no space")
+ ErrTooManyRequests = errors.New("etcdserver: too many requests")
+ ErrUnhealthy = errors.New("etcdserver: unhealthy cluster")
+ ErrKeyNotFound = errors.New("etcdserver: key not found")
+)
+
+type DiscoveryError struct {
+ Op string
+ Err error
+}
+
+func (e DiscoveryError) Error() string {
+ return fmt.Sprintf("failed to %s discovery cluster (%v)", e.Op, e.Err)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/etcdserver.pb.go b/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/etcdserver.pb.go
new file mode 100644
index 00000000..aabf9006
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/etcdserver.pb.go
@@ -0,0 +1,1045 @@
+// Code generated by protoc-gen-gogo.
+// source: etcdserver.proto
+// DO NOT EDIT!
+
+/*
+ Package etcdserverpb is a generated protocol buffer package.
+
+ It is generated from these files:
+ etcdserver.proto
+ raft_internal.proto
+ rpc.proto
+
+ It has these top-level messages:
+ Request
+ Metadata
+ RequestHeader
+ InternalRaftRequest
+ EmptyResponse
+ InternalAuthenticateRequest
+ ResponseHeader
+ RangeRequest
+ RangeResponse
+ PutRequest
+ PutResponse
+ DeleteRangeRequest
+ DeleteRangeResponse
+ RequestOp
+ ResponseOp
+ Compare
+ TxnRequest
+ TxnResponse
+ CompactionRequest
+ CompactionResponse
+ HashRequest
+ HashResponse
+ SnapshotRequest
+ SnapshotResponse
+ WatchRequest
+ WatchCreateRequest
+ WatchCancelRequest
+ WatchResponse
+ LeaseGrantRequest
+ LeaseGrantResponse
+ LeaseRevokeRequest
+ LeaseRevokeResponse
+ LeaseKeepAliveRequest
+ LeaseKeepAliveResponse
+ LeaseTimeToLiveRequest
+ LeaseTimeToLiveResponse
+ Member
+ MemberAddRequest
+ MemberAddResponse
+ MemberRemoveRequest
+ MemberRemoveResponse
+ MemberUpdateRequest
+ MemberUpdateResponse
+ MemberListRequest
+ MemberListResponse
+ DefragmentRequest
+ DefragmentResponse
+ AlarmRequest
+ AlarmMember
+ AlarmResponse
+ StatusRequest
+ StatusResponse
+ AuthEnableRequest
+ AuthDisableRequest
+ AuthenticateRequest
+ AuthUserAddRequest
+ AuthUserGetRequest
+ AuthUserDeleteRequest
+ AuthUserChangePasswordRequest
+ AuthUserGrantRoleRequest
+ AuthUserRevokeRoleRequest
+ AuthRoleAddRequest
+ AuthRoleGetRequest
+ AuthUserListRequest
+ AuthRoleListRequest
+ AuthRoleDeleteRequest
+ AuthRoleGrantPermissionRequest
+ AuthRoleRevokePermissionRequest
+ AuthEnableResponse
+ AuthDisableResponse
+ AuthenticateResponse
+ AuthUserAddResponse
+ AuthUserGetResponse
+ AuthUserDeleteResponse
+ AuthUserChangePasswordResponse
+ AuthUserGrantRoleResponse
+ AuthUserRevokeRoleResponse
+ AuthRoleAddResponse
+ AuthRoleGetResponse
+ AuthRoleListResponse
+ AuthUserListResponse
+ AuthRoleDeleteResponse
+ AuthRoleGrantPermissionResponse
+ AuthRoleRevokePermissionResponse
+*/
+package etcdserverpb
+
+import (
+ "fmt"
+
+ proto "github.com/golang/protobuf/proto"
+
+ math "math"
+
+ io "io"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+type Request struct {
+ ID uint64 `protobuf:"varint,1,opt,name=ID" json:"ID"`
+ Method string `protobuf:"bytes,2,opt,name=Method" json:"Method"`
+ Path string `protobuf:"bytes,3,opt,name=Path" json:"Path"`
+ Val string `protobuf:"bytes,4,opt,name=Val" json:"Val"`
+ Dir bool `protobuf:"varint,5,opt,name=Dir" json:"Dir"`
+ PrevValue string `protobuf:"bytes,6,opt,name=PrevValue" json:"PrevValue"`
+ PrevIndex uint64 `protobuf:"varint,7,opt,name=PrevIndex" json:"PrevIndex"`
+ PrevExist *bool `protobuf:"varint,8,opt,name=PrevExist" json:"PrevExist,omitempty"`
+ Expiration int64 `protobuf:"varint,9,opt,name=Expiration" json:"Expiration"`
+ Wait bool `protobuf:"varint,10,opt,name=Wait" json:"Wait"`
+ Since uint64 `protobuf:"varint,11,opt,name=Since" json:"Since"`
+ Recursive bool `protobuf:"varint,12,opt,name=Recursive" json:"Recursive"`
+ Sorted bool `protobuf:"varint,13,opt,name=Sorted" json:"Sorted"`
+ Quorum bool `protobuf:"varint,14,opt,name=Quorum" json:"Quorum"`
+ Time int64 `protobuf:"varint,15,opt,name=Time" json:"Time"`
+ Stream bool `protobuf:"varint,16,opt,name=Stream" json:"Stream"`
+ Refresh *bool `protobuf:"varint,17,opt,name=Refresh" json:"Refresh,omitempty"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *Request) Reset() { *m = Request{} }
+func (m *Request) String() string { return proto.CompactTextString(m) }
+func (*Request) ProtoMessage() {}
+func (*Request) Descriptor() ([]byte, []int) { return fileDescriptorEtcdserver, []int{0} }
+
+type Metadata struct {
+ NodeID uint64 `protobuf:"varint,1,opt,name=NodeID" json:"NodeID"`
+ ClusterID uint64 `protobuf:"varint,2,opt,name=ClusterID" json:"ClusterID"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *Metadata) Reset() { *m = Metadata{} }
+func (m *Metadata) String() string { return proto.CompactTextString(m) }
+func (*Metadata) ProtoMessage() {}
+func (*Metadata) Descriptor() ([]byte, []int) { return fileDescriptorEtcdserver, []int{1} }
+
+func init() {
+ proto.RegisterType((*Request)(nil), "etcdserverpb.Request")
+ proto.RegisterType((*Metadata)(nil), "etcdserverpb.Metadata")
+}
+func (m *Request) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *Request) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintEtcdserver(dAtA, i, uint64(m.ID))
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintEtcdserver(dAtA, i, uint64(len(m.Method)))
+ i += copy(dAtA[i:], m.Method)
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintEtcdserver(dAtA, i, uint64(len(m.Path)))
+ i += copy(dAtA[i:], m.Path)
+ dAtA[i] = 0x22
+ i++
+ i = encodeVarintEtcdserver(dAtA, i, uint64(len(m.Val)))
+ i += copy(dAtA[i:], m.Val)
+ dAtA[i] = 0x28
+ i++
+ if m.Dir {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ dAtA[i] = 0x32
+ i++
+ i = encodeVarintEtcdserver(dAtA, i, uint64(len(m.PrevValue)))
+ i += copy(dAtA[i:], m.PrevValue)
+ dAtA[i] = 0x38
+ i++
+ i = encodeVarintEtcdserver(dAtA, i, uint64(m.PrevIndex))
+ if m.PrevExist != nil {
+ dAtA[i] = 0x40
+ i++
+ if *m.PrevExist {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ dAtA[i] = 0x48
+ i++
+ i = encodeVarintEtcdserver(dAtA, i, uint64(m.Expiration))
+ dAtA[i] = 0x50
+ i++
+ if m.Wait {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ dAtA[i] = 0x58
+ i++
+ i = encodeVarintEtcdserver(dAtA, i, uint64(m.Since))
+ dAtA[i] = 0x60
+ i++
+ if m.Recursive {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ dAtA[i] = 0x68
+ i++
+ if m.Sorted {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ dAtA[i] = 0x70
+ i++
+ if m.Quorum {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ dAtA[i] = 0x78
+ i++
+ i = encodeVarintEtcdserver(dAtA, i, uint64(m.Time))
+ dAtA[i] = 0x80
+ i++
+ dAtA[i] = 0x1
+ i++
+ if m.Stream {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ if m.Refresh != nil {
+ dAtA[i] = 0x88
+ i++
+ dAtA[i] = 0x1
+ i++
+ if *m.Refresh {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ if m.XXX_unrecognized != nil {
+ i += copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return i, nil
+}
+
+func (m *Metadata) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *Metadata) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintEtcdserver(dAtA, i, uint64(m.NodeID))
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintEtcdserver(dAtA, i, uint64(m.ClusterID))
+ if m.XXX_unrecognized != nil {
+ i += copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return i, nil
+}
+
+func encodeFixed64Etcdserver(dAtA []byte, offset int, v uint64) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ dAtA[offset+4] = uint8(v >> 32)
+ dAtA[offset+5] = uint8(v >> 40)
+ dAtA[offset+6] = uint8(v >> 48)
+ dAtA[offset+7] = uint8(v >> 56)
+ return offset + 8
+}
+func encodeFixed32Etcdserver(dAtA []byte, offset int, v uint32) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ return offset + 4
+}
+func encodeVarintEtcdserver(dAtA []byte, offset int, v uint64) int {
+ for v >= 1<<7 {
+ dAtA[offset] = uint8(v&0x7f | 0x80)
+ v >>= 7
+ offset++
+ }
+ dAtA[offset] = uint8(v)
+ return offset + 1
+}
+func (m *Request) Size() (n int) {
+ var l int
+ _ = l
+ n += 1 + sovEtcdserver(uint64(m.ID))
+ l = len(m.Method)
+ n += 1 + l + sovEtcdserver(uint64(l))
+ l = len(m.Path)
+ n += 1 + l + sovEtcdserver(uint64(l))
+ l = len(m.Val)
+ n += 1 + l + sovEtcdserver(uint64(l))
+ n += 2
+ l = len(m.PrevValue)
+ n += 1 + l + sovEtcdserver(uint64(l))
+ n += 1 + sovEtcdserver(uint64(m.PrevIndex))
+ if m.PrevExist != nil {
+ n += 2
+ }
+ n += 1 + sovEtcdserver(uint64(m.Expiration))
+ n += 2
+ n += 1 + sovEtcdserver(uint64(m.Since))
+ n += 2
+ n += 2
+ n += 2
+ n += 1 + sovEtcdserver(uint64(m.Time))
+ n += 3
+ if m.Refresh != nil {
+ n += 3
+ }
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *Metadata) Size() (n int) {
+ var l int
+ _ = l
+ n += 1 + sovEtcdserver(uint64(m.NodeID))
+ n += 1 + sovEtcdserver(uint64(m.ClusterID))
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func sovEtcdserver(x uint64) (n int) {
+ for {
+ n++
+ x >>= 7
+ if x == 0 {
+ break
+ }
+ }
+ return n
+}
+func sozEtcdserver(x uint64) (n int) {
+ return sovEtcdserver(uint64((x << 1) ^ uint64((int64(x) >> 63))))
+}
+func (m *Request) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: Request: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: Request: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Method", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthEtcdserver
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Method = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthEtcdserver
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Path = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 4:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Val", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthEtcdserver
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Val = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 5:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Dir", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Dir = bool(v != 0)
+ case 6:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PrevValue", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthEtcdserver
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.PrevValue = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 7:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PrevIndex", wireType)
+ }
+ m.PrevIndex = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.PrevIndex |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 8:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PrevExist", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ b := bool(v != 0)
+ m.PrevExist = &b
+ case 9:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType)
+ }
+ m.Expiration = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Expiration |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 10:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Wait", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Wait = bool(v != 0)
+ case 11:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Since", wireType)
+ }
+ m.Since = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Since |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 12:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Recursive", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Recursive = bool(v != 0)
+ case 13:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Sorted", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Sorted = bool(v != 0)
+ case 14:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Quorum", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Quorum = bool(v != 0)
+ case 15:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType)
+ }
+ m.Time = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Time |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 16:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Stream", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Stream = bool(v != 0)
+ case 17:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Refresh", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ b := bool(v != 0)
+ m.Refresh = &b
+ default:
+ iNdEx = preIndex
+ skippy, err := skipEtcdserver(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthEtcdserver
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *Metadata) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: Metadata: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: Metadata: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field NodeID", wireType)
+ }
+ m.NodeID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.NodeID |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ClusterID", wireType)
+ }
+ m.ClusterID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ClusterID |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipEtcdserver(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthEtcdserver
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func skipEtcdserver(dAtA []byte) (n int, err error) {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ wireType := int(wire & 0x7)
+ switch wireType {
+ case 0:
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ iNdEx++
+ if dAtA[iNdEx-1] < 0x80 {
+ break
+ }
+ }
+ return iNdEx, nil
+ case 1:
+ iNdEx += 8
+ return iNdEx, nil
+ case 2:
+ var length int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ length |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ iNdEx += length
+ if length < 0 {
+ return 0, ErrInvalidLengthEtcdserver
+ }
+ return iNdEx, nil
+ case 3:
+ for {
+ var innerWire uint64
+ var start int = iNdEx
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowEtcdserver
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ innerWire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ innerWireType := int(innerWire & 0x7)
+ if innerWireType == 4 {
+ break
+ }
+ next, err := skipEtcdserver(dAtA[start:])
+ if err != nil {
+ return 0, err
+ }
+ iNdEx = start + next
+ }
+ return iNdEx, nil
+ case 4:
+ return iNdEx, nil
+ case 5:
+ iNdEx += 4
+ return iNdEx, nil
+ default:
+ return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
+ }
+ }
+ panic("unreachable")
+}
+
+var (
+ ErrInvalidLengthEtcdserver = fmt.Errorf("proto: negative length found during unmarshaling")
+ ErrIntOverflowEtcdserver = fmt.Errorf("proto: integer overflow")
+)
+
+func init() { proto.RegisterFile("etcdserver.proto", fileDescriptorEtcdserver) }
+
+var fileDescriptorEtcdserver = []byte{
+ // 380 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0xd2, 0xdd, 0x6e, 0xda, 0x30,
+ 0x14, 0x07, 0x70, 0x0c, 0xe1, 0xcb, 0x63, 0x1b, 0xb3, 0xd0, 0x74, 0x84, 0xa6, 0x2c, 0x42, 0xbb,
+ 0xc8, 0xd5, 0xf6, 0x0e, 0x2c, 0x5c, 0x44, 0x2a, 0x15, 0x0d, 0x15, 0xbd, 0x76, 0xc9, 0x29, 0x58,
+ 0x02, 0x4c, 0x1d, 0x07, 0xf1, 0x06, 0x7d, 0x85, 0x3e, 0x12, 0x97, 0x7d, 0x82, 0xaa, 0xa5, 0x2f,
+ 0x52, 0x39, 0x24, 0xc4, 0xed, 0x5d, 0xf4, 0xfb, 0x9f, 0x1c, 0x1f, 0x7f, 0xd0, 0x2e, 0xea, 0x79,
+ 0x9c, 0xa0, 0xda, 0xa1, 0xfa, 0xbb, 0x55, 0x52, 0x4b, 0xd6, 0x29, 0x65, 0x7b, 0xdb, 0xef, 0x2d,
+ 0xe4, 0x42, 0x66, 0xc1, 0x3f, 0xf3, 0x75, 0xaa, 0x19, 0x3c, 0x38, 0xb4, 0x19, 0xe1, 0x7d, 0x8a,
+ 0x89, 0x66, 0x3d, 0x5a, 0x0d, 0x03, 0x20, 0x1e, 0xf1, 0x9d, 0xa1, 0x73, 0x78, 0xfe, 0x5d, 0x89,
+ 0xaa, 0x61, 0xc0, 0x7e, 0xd1, 0xc6, 0x18, 0xf5, 0x52, 0xc6, 0x50, 0xf5, 0x88, 0xdf, 0xce, 0x93,
+ 0xdc, 0x18, 0x50, 0x67, 0xc2, 0xf5, 0x12, 0x6a, 0x56, 0x96, 0x09, 0xfb, 0x49, 0x6b, 0x33, 0xbe,
+ 0x02, 0xc7, 0x0a, 0x0c, 0x18, 0x0f, 0x84, 0x82, 0xba, 0x47, 0xfc, 0x56, 0xe1, 0x81, 0x50, 0x6c,
+ 0x40, 0xdb, 0x13, 0x85, 0xbb, 0x19, 0x5f, 0xa5, 0x08, 0x0d, 0xeb, 0xaf, 0x92, 0x8b, 0x9a, 0x70,
+ 0x13, 0xe3, 0x1e, 0x9a, 0xd6, 0xa0, 0x25, 0x17, 0x35, 0xa3, 0xbd, 0x48, 0x34, 0xb4, 0xce, 0xab,
+ 0x90, 0xa8, 0x64, 0xf6, 0x87, 0xd2, 0xd1, 0x7e, 0x2b, 0x14, 0xd7, 0x42, 0x6e, 0xa0, 0xed, 0x11,
+ 0xbf, 0x96, 0x37, 0xb2, 0xdc, 0xec, 0xed, 0x86, 0x0b, 0x0d, 0xd4, 0x1a, 0x35, 0x13, 0xd6, 0xa7,
+ 0xf5, 0xa9, 0xd8, 0xcc, 0x11, 0xbe, 0x58, 0x33, 0x9c, 0xc8, 0xac, 0x1f, 0xe1, 0x3c, 0x55, 0x89,
+ 0xd8, 0x21, 0x74, 0xac, 0x5f, 0x4b, 0x36, 0x67, 0x3a, 0x95, 0x4a, 0x63, 0x0c, 0x5f, 0xad, 0x82,
+ 0xdc, 0x4c, 0x7a, 0x95, 0x4a, 0x95, 0xae, 0xe1, 0x9b, 0x9d, 0x9e, 0xcc, 0x4c, 0x75, 0x2d, 0xd6,
+ 0x08, 0xdf, 0xad, 0xa9, 0x33, 0xc9, 0xba, 0x6a, 0x85, 0x7c, 0x0d, 0xdd, 0x0f, 0x5d, 0x33, 0x63,
+ 0xae, 0xb9, 0xe8, 0x3b, 0x85, 0xc9, 0x12, 0x7e, 0x58, 0xa7, 0x52, 0xe0, 0xe0, 0x82, 0xb6, 0xc6,
+ 0xa8, 0x79, 0xcc, 0x35, 0x37, 0x9d, 0x2e, 0x65, 0x8c, 0x9f, 0x5e, 0x43, 0x6e, 0x66, 0x87, 0xff,
+ 0x57, 0x69, 0xa2, 0x51, 0x85, 0x41, 0xf6, 0x28, 0xce, 0xb7, 0x70, 0xe6, 0x61, 0xef, 0xf0, 0xea,
+ 0x56, 0x0e, 0x47, 0x97, 0x3c, 0x1d, 0x5d, 0xf2, 0x72, 0x74, 0xc9, 0xe3, 0x9b, 0x5b, 0x79, 0x0f,
+ 0x00, 0x00, 0xff, 0xff, 0xee, 0x40, 0xba, 0xd6, 0xa4, 0x02, 0x00, 0x00,
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/etcdserver.proto b/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/etcdserver.proto
new file mode 100644
index 00000000..25e0aca5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/etcdserver.proto
@@ -0,0 +1,34 @@
+syntax = "proto2";
+package etcdserverpb;
+
+import "gogoproto/gogo.proto";
+
+option (gogoproto.marshaler_all) = true;
+option (gogoproto.sizer_all) = true;
+option (gogoproto.unmarshaler_all) = true;
+option (gogoproto.goproto_getters_all) = false;
+
+message Request {
+ optional uint64 ID = 1 [(gogoproto.nullable) = false];
+ optional string Method = 2 [(gogoproto.nullable) = false];
+ optional string Path = 3 [(gogoproto.nullable) = false];
+ optional string Val = 4 [(gogoproto.nullable) = false];
+ optional bool Dir = 5 [(gogoproto.nullable) = false];
+ optional string PrevValue = 6 [(gogoproto.nullable) = false];
+ optional uint64 PrevIndex = 7 [(gogoproto.nullable) = false];
+ optional bool PrevExist = 8 [(gogoproto.nullable) = true];
+ optional int64 Expiration = 9 [(gogoproto.nullable) = false];
+ optional bool Wait = 10 [(gogoproto.nullable) = false];
+ optional uint64 Since = 11 [(gogoproto.nullable) = false];
+ optional bool Recursive = 12 [(gogoproto.nullable) = false];
+ optional bool Sorted = 13 [(gogoproto.nullable) = false];
+ optional bool Quorum = 14 [(gogoproto.nullable) = false];
+ optional int64 Time = 15 [(gogoproto.nullable) = false];
+ optional bool Stream = 16 [(gogoproto.nullable) = false];
+ optional bool Refresh = 17 [(gogoproto.nullable) = true];
+}
+
+message Metadata {
+ optional uint64 NodeID = 1 [(gogoproto.nullable) = false];
+ optional uint64 ClusterID = 2 [(gogoproto.nullable) = false];
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/gw/rpc.pb.gw.go b/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/gw/rpc.pb.gw.go
new file mode 100644
index 00000000..601df671
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/gw/rpc.pb.gw.go
@@ -0,0 +1,1912 @@
+// Code generated by protoc-gen-grpc-gateway
+// source: etcdserver/etcdserverpb/rpc.proto
+// DO NOT EDIT!
+
+/*
+Package etcdserverpb is a reverse proxy.
+
+It translates gRPC into RESTful JSON APIs.
+*/
+package gw
+
+import (
+ "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "io"
+ "net/http"
+
+ "github.com/golang/protobuf/proto"
+ "github.com/grpc-ecosystem/grpc-gateway/runtime"
+ "github.com/grpc-ecosystem/grpc-gateway/utilities"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/grpclog"
+)
+
+var _ codes.Code
+var _ io.Reader
+var _ = runtime.String
+var _ = utilities.NewDoubleArray
+
+func request_KV_Range_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.KVClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.RangeRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Range(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_KV_Put_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.KVClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.PutRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Put(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_KV_DeleteRange_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.KVClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.DeleteRangeRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.DeleteRange(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_KV_Txn_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.KVClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.TxnRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Txn(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_KV_Compact_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.KVClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.CompactionRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Compact(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Watch_Watch_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.WatchClient, req *http.Request, pathParams map[string]string) (etcdserverpb.Watch_WatchClient, runtime.ServerMetadata, error) {
+ var metadata runtime.ServerMetadata
+ stream, err := client.Watch(ctx)
+ if err != nil {
+ grpclog.Printf("Failed to start streaming: %v", err)
+ return nil, metadata, err
+ }
+ dec := marshaler.NewDecoder(req.Body)
+ handleSend := func() error {
+ var protoReq etcdserverpb.WatchRequest
+ err = dec.Decode(&protoReq)
+ if err == io.EOF {
+ return err
+ }
+ if err != nil {
+ grpclog.Printf("Failed to decode request: %v", err)
+ return err
+ }
+ if err = stream.Send(&protoReq); err != nil {
+ grpclog.Printf("Failed to send request: %v", err)
+ return err
+ }
+ return nil
+ }
+ if err := handleSend(); err != nil {
+ if cerr := stream.CloseSend(); cerr != nil {
+ grpclog.Printf("Failed to terminate client stream: %v", cerr)
+ }
+ if err == io.EOF {
+ return stream, metadata, nil
+ }
+ return nil, metadata, err
+ }
+ go func() {
+ for {
+ if err := handleSend(); err != nil {
+ break
+ }
+ }
+ if err := stream.CloseSend(); err != nil {
+ grpclog.Printf("Failed to terminate client stream: %v", err)
+ }
+ }()
+ header, err := stream.Header()
+ if err != nil {
+ grpclog.Printf("Failed to get header from client: %v", err)
+ return nil, metadata, err
+ }
+ metadata.HeaderMD = header
+ return stream, metadata, nil
+}
+
+func request_Lease_LeaseGrant_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.LeaseClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.LeaseGrantRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.LeaseGrant(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Lease_LeaseRevoke_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.LeaseClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.LeaseRevokeRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.LeaseRevoke(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Lease_LeaseKeepAlive_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.LeaseClient, req *http.Request, pathParams map[string]string) (etcdserverpb.Lease_LeaseKeepAliveClient, runtime.ServerMetadata, error) {
+ var metadata runtime.ServerMetadata
+ stream, err := client.LeaseKeepAlive(ctx)
+ if err != nil {
+ grpclog.Printf("Failed to start streaming: %v", err)
+ return nil, metadata, err
+ }
+ dec := marshaler.NewDecoder(req.Body)
+ handleSend := func() error {
+ var protoReq etcdserverpb.LeaseKeepAliveRequest
+ err = dec.Decode(&protoReq)
+ if err == io.EOF {
+ return err
+ }
+ if err != nil {
+ grpclog.Printf("Failed to decode request: %v", err)
+ return err
+ }
+ if err = stream.Send(&protoReq); err != nil {
+ grpclog.Printf("Failed to send request: %v", err)
+ return err
+ }
+ return nil
+ }
+ if err := handleSend(); err != nil {
+ if cerr := stream.CloseSend(); cerr != nil {
+ grpclog.Printf("Failed to terminate client stream: %v", cerr)
+ }
+ if err == io.EOF {
+ return stream, metadata, nil
+ }
+ return nil, metadata, err
+ }
+ go func() {
+ for {
+ if err := handleSend(); err != nil {
+ break
+ }
+ }
+ if err := stream.CloseSend(); err != nil {
+ grpclog.Printf("Failed to terminate client stream: %v", err)
+ }
+ }()
+ header, err := stream.Header()
+ if err != nil {
+ grpclog.Printf("Failed to get header from client: %v", err)
+ return nil, metadata, err
+ }
+ metadata.HeaderMD = header
+ return stream, metadata, nil
+}
+
+func request_Lease_LeaseTimeToLive_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.LeaseClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.LeaseTimeToLiveRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.LeaseTimeToLive(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Cluster_MemberAdd_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.ClusterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.MemberAddRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.MemberAdd(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Cluster_MemberRemove_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.ClusterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.MemberRemoveRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.MemberRemove(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Cluster_MemberUpdate_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.ClusterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.MemberUpdateRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.MemberUpdate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Cluster_MemberList_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.ClusterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.MemberListRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.MemberList(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Maintenance_Alarm_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.MaintenanceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AlarmRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Alarm(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Maintenance_Status_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.MaintenanceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.StatusRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Status(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Maintenance_Defragment_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.MaintenanceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.DefragmentRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Defragment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Maintenance_Hash_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.MaintenanceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.HashRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Hash(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Maintenance_Snapshot_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.MaintenanceClient, req *http.Request, pathParams map[string]string) (etcdserverpb.Maintenance_SnapshotClient, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.SnapshotRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ stream, err := client.Snapshot(ctx, &protoReq)
+ if err != nil {
+ return nil, metadata, err
+ }
+ header, err := stream.Header()
+ if err != nil {
+ return nil, metadata, err
+ }
+ metadata.HeaderMD = header
+ return stream, metadata, nil
+
+}
+
+func request_Auth_AuthEnable_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthEnableRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.AuthEnable(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_AuthDisable_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthDisableRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.AuthDisable(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthenticateRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.Authenticate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_UserAdd_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthUserAddRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.UserAdd(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_UserGet_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthUserGetRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.UserGet(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_UserList_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthUserListRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.UserList(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_UserDelete_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthUserDeleteRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.UserDelete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_UserChangePassword_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthUserChangePasswordRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.UserChangePassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_UserGrantRole_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthUserGrantRoleRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.UserGrantRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_UserRevokeRole_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthUserRevokeRoleRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.UserRevokeRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_RoleAdd_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthRoleAddRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.RoleAdd(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_RoleGet_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthRoleGetRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.RoleGet(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_RoleList_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthRoleListRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.RoleList(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_RoleDelete_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthRoleDeleteRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.RoleDelete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_RoleGrantPermission_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthRoleGrantPermissionRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.RoleGrantPermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func request_Auth_RoleRevokePermission_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq etcdserverpb.AuthRoleRevokePermissionRequest
+ var metadata runtime.ServerMetadata
+
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
+ return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.RoleRevokePermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+// RegisterKVHandlerFromEndpoint is same as RegisterKVHandler but
+// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
+func RegisterKVHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
+ conn, err := grpc.Dial(endpoint, opts...)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ if err != nil {
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ return
+ }
+ go func() {
+ <-ctx.Done()
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ }()
+ }()
+
+ return RegisterKVHandler(ctx, mux, conn)
+}
+
+// RegisterKVHandler registers the http handlers for service KV to "mux".
+// The handlers forward requests to the grpc endpoint over "conn".
+func RegisterKVHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
+ client := etcdserverpb.NewKVClient(conn)
+
+ mux.Handle("POST", pattern_KV_Range_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_KV_Range_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_KV_Range_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_KV_Put_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_KV_Put_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_KV_Put_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_KV_DeleteRange_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_KV_DeleteRange_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_KV_DeleteRange_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_KV_Txn_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_KV_Txn_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_KV_Txn_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_KV_Compact_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_KV_Compact_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_KV_Compact_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ return nil
+}
+
+var (
+ pattern_KV_Range_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "kv", "range"}, ""))
+
+ pattern_KV_Put_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "kv", "put"}, ""))
+
+ pattern_KV_DeleteRange_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "kv", "deleterange"}, ""))
+
+ pattern_KV_Txn_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "kv", "txn"}, ""))
+
+ pattern_KV_Compact_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "kv", "compaction"}, ""))
+)
+
+var (
+ forward_KV_Range_0 = runtime.ForwardResponseMessage
+
+ forward_KV_Put_0 = runtime.ForwardResponseMessage
+
+ forward_KV_DeleteRange_0 = runtime.ForwardResponseMessage
+
+ forward_KV_Txn_0 = runtime.ForwardResponseMessage
+
+ forward_KV_Compact_0 = runtime.ForwardResponseMessage
+)
+
+// RegisterWatchHandlerFromEndpoint is same as RegisterWatchHandler but
+// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
+func RegisterWatchHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
+ conn, err := grpc.Dial(endpoint, opts...)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ if err != nil {
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ return
+ }
+ go func() {
+ <-ctx.Done()
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ }()
+ }()
+
+ return RegisterWatchHandler(ctx, mux, conn)
+}
+
+// RegisterWatchHandler registers the http handlers for service Watch to "mux".
+// The handlers forward requests to the grpc endpoint over "conn".
+func RegisterWatchHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
+ client := etcdserverpb.NewWatchClient(conn)
+
+ mux.Handle("POST", pattern_Watch_Watch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Watch_Watch_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Watch_Watch_0(ctx, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
+
+ })
+
+ return nil
+}
+
+var (
+ pattern_Watch_Watch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v3alpha", "watch"}, ""))
+)
+
+var (
+ forward_Watch_Watch_0 = runtime.ForwardResponseStream
+)
+
+// RegisterLeaseHandlerFromEndpoint is same as RegisterLeaseHandler but
+// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
+func RegisterLeaseHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
+ conn, err := grpc.Dial(endpoint, opts...)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ if err != nil {
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ return
+ }
+ go func() {
+ <-ctx.Done()
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ }()
+ }()
+
+ return RegisterLeaseHandler(ctx, mux, conn)
+}
+
+// RegisterLeaseHandler registers the http handlers for service Lease to "mux".
+// The handlers forward requests to the grpc endpoint over "conn".
+func RegisterLeaseHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
+ client := etcdserverpb.NewLeaseClient(conn)
+
+ mux.Handle("POST", pattern_Lease_LeaseGrant_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Lease_LeaseGrant_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Lease_LeaseGrant_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Lease_LeaseRevoke_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Lease_LeaseRevoke_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Lease_LeaseRevoke_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Lease_LeaseKeepAlive_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Lease_LeaseKeepAlive_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Lease_LeaseKeepAlive_0(ctx, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Lease_LeaseTimeToLive_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Lease_LeaseTimeToLive_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Lease_LeaseTimeToLive_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ return nil
+}
+
+var (
+ pattern_Lease_LeaseGrant_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "lease", "grant"}, ""))
+
+ pattern_Lease_LeaseRevoke_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "kv", "lease", "revoke"}, ""))
+
+ pattern_Lease_LeaseKeepAlive_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "lease", "keepalive"}, ""))
+
+ pattern_Lease_LeaseTimeToLive_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "kv", "lease", "timetolive"}, ""))
+)
+
+var (
+ forward_Lease_LeaseGrant_0 = runtime.ForwardResponseMessage
+
+ forward_Lease_LeaseRevoke_0 = runtime.ForwardResponseMessage
+
+ forward_Lease_LeaseKeepAlive_0 = runtime.ForwardResponseStream
+
+ forward_Lease_LeaseTimeToLive_0 = runtime.ForwardResponseMessage
+)
+
+// RegisterClusterHandlerFromEndpoint is same as RegisterClusterHandler but
+// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
+func RegisterClusterHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
+ conn, err := grpc.Dial(endpoint, opts...)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ if err != nil {
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ return
+ }
+ go func() {
+ <-ctx.Done()
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ }()
+ }()
+
+ return RegisterClusterHandler(ctx, mux, conn)
+}
+
+// RegisterClusterHandler registers the http handlers for service Cluster to "mux".
+// The handlers forward requests to the grpc endpoint over "conn".
+func RegisterClusterHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
+ client := etcdserverpb.NewClusterClient(conn)
+
+ mux.Handle("POST", pattern_Cluster_MemberAdd_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Cluster_MemberAdd_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Cluster_MemberAdd_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Cluster_MemberRemove_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Cluster_MemberRemove_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Cluster_MemberRemove_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Cluster_MemberUpdate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Cluster_MemberUpdate_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Cluster_MemberUpdate_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Cluster_MemberList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Cluster_MemberList_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Cluster_MemberList_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ return nil
+}
+
+var (
+ pattern_Cluster_MemberAdd_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "cluster", "member", "add"}, ""))
+
+ pattern_Cluster_MemberRemove_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "cluster", "member", "remove"}, ""))
+
+ pattern_Cluster_MemberUpdate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "cluster", "member", "update"}, ""))
+
+ pattern_Cluster_MemberList_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "cluster", "member", "list"}, ""))
+)
+
+var (
+ forward_Cluster_MemberAdd_0 = runtime.ForwardResponseMessage
+
+ forward_Cluster_MemberRemove_0 = runtime.ForwardResponseMessage
+
+ forward_Cluster_MemberUpdate_0 = runtime.ForwardResponseMessage
+
+ forward_Cluster_MemberList_0 = runtime.ForwardResponseMessage
+)
+
+// RegisterMaintenanceHandlerFromEndpoint is same as RegisterMaintenanceHandler but
+// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
+func RegisterMaintenanceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
+ conn, err := grpc.Dial(endpoint, opts...)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ if err != nil {
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ return
+ }
+ go func() {
+ <-ctx.Done()
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ }()
+ }()
+
+ return RegisterMaintenanceHandler(ctx, mux, conn)
+}
+
+// RegisterMaintenanceHandler registers the http handlers for service Maintenance to "mux".
+// The handlers forward requests to the grpc endpoint over "conn".
+func RegisterMaintenanceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
+ client := etcdserverpb.NewMaintenanceClient(conn)
+
+ mux.Handle("POST", pattern_Maintenance_Alarm_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Maintenance_Alarm_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Maintenance_Alarm_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Maintenance_Status_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Maintenance_Status_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Maintenance_Status_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Maintenance_Defragment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Maintenance_Defragment_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Maintenance_Defragment_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Maintenance_Hash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Maintenance_Hash_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Maintenance_Hash_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Maintenance_Snapshot_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Maintenance_Snapshot_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Maintenance_Snapshot_0(ctx, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
+
+ })
+
+ return nil
+}
+
+var (
+ pattern_Maintenance_Alarm_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "maintenance", "alarm"}, ""))
+
+ pattern_Maintenance_Status_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "maintenance", "status"}, ""))
+
+ pattern_Maintenance_Defragment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "maintenance", "defragment"}, ""))
+
+ pattern_Maintenance_Hash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "maintenance", "hash"}, ""))
+
+ pattern_Maintenance_Snapshot_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "maintenance", "snapshot"}, ""))
+)
+
+var (
+ forward_Maintenance_Alarm_0 = runtime.ForwardResponseMessage
+
+ forward_Maintenance_Status_0 = runtime.ForwardResponseMessage
+
+ forward_Maintenance_Defragment_0 = runtime.ForwardResponseMessage
+
+ forward_Maintenance_Hash_0 = runtime.ForwardResponseMessage
+
+ forward_Maintenance_Snapshot_0 = runtime.ForwardResponseStream
+)
+
+// RegisterAuthHandlerFromEndpoint is same as RegisterAuthHandler but
+// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
+func RegisterAuthHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
+ conn, err := grpc.Dial(endpoint, opts...)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ if err != nil {
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ return
+ }
+ go func() {
+ <-ctx.Done()
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ }()
+ }()
+
+ return RegisterAuthHandler(ctx, mux, conn)
+}
+
+// RegisterAuthHandler registers the http handlers for service Auth to "mux".
+// The handlers forward requests to the grpc endpoint over "conn".
+func RegisterAuthHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
+ client := etcdserverpb.NewAuthClient(conn)
+
+ mux.Handle("POST", pattern_Auth_AuthEnable_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_AuthEnable_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_AuthEnable_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_AuthDisable_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_AuthDisable_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_AuthDisable_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_Authenticate_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_Authenticate_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_UserAdd_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_UserAdd_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_UserAdd_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_UserGet_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_UserGet_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_UserGet_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_UserList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_UserList_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_UserList_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_UserDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_UserDelete_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_UserDelete_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_UserChangePassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_UserChangePassword_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_UserChangePassword_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_UserGrantRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_UserGrantRole_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_UserGrantRole_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_UserRevokeRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_UserRevokeRole_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_UserRevokeRole_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_RoleAdd_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_RoleAdd_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_RoleAdd_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_RoleGet_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_RoleGet_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_RoleGet_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_RoleList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_RoleList_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_RoleList_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_RoleDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_RoleDelete_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_RoleDelete_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_RoleGrantPermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_RoleGrantPermission_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_RoleGrantPermission_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_Auth_RoleRevokePermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ if cn, ok := w.(http.CloseNotifier); ok {
+ go func(done <-chan struct{}, closed <-chan bool) {
+ select {
+ case <-done:
+ case <-closed:
+ cancel()
+ }
+ }(ctx.Done(), cn.CloseNotify())
+ }
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ rctx, err := runtime.AnnotateContext(ctx, req)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ }
+ resp, md, err := request_Auth_RoleRevokePermission_0(rctx, inboundMarshaler, client, req, pathParams)
+ ctx = runtime.NewServerMetadataContext(ctx, md)
+ if err != nil {
+ runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_Auth_RoleRevokePermission_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ return nil
+}
+
+var (
+ pattern_Auth_AuthEnable_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "auth", "enable"}, ""))
+
+ pattern_Auth_AuthDisable_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "auth", "disable"}, ""))
+
+ pattern_Auth_Authenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3alpha", "auth", "authenticate"}, ""))
+
+ pattern_Auth_UserAdd_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "auth", "user", "add"}, ""))
+
+ pattern_Auth_UserGet_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "auth", "user", "get"}, ""))
+
+ pattern_Auth_UserList_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "auth", "user", "list"}, ""))
+
+ pattern_Auth_UserDelete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "auth", "user", "delete"}, ""))
+
+ pattern_Auth_UserChangePassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "auth", "user", "changepw"}, ""))
+
+ pattern_Auth_UserGrantRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "auth", "user", "grant"}, ""))
+
+ pattern_Auth_UserRevokeRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "auth", "user", "revoke"}, ""))
+
+ pattern_Auth_RoleAdd_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "auth", "role", "add"}, ""))
+
+ pattern_Auth_RoleGet_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "auth", "role", "get"}, ""))
+
+ pattern_Auth_RoleList_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "auth", "role", "list"}, ""))
+
+ pattern_Auth_RoleDelete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "auth", "role", "delete"}, ""))
+
+ pattern_Auth_RoleGrantPermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "auth", "role", "grant"}, ""))
+
+ pattern_Auth_RoleRevokePermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3alpha", "auth", "role", "revoke"}, ""))
+)
+
+var (
+ forward_Auth_AuthEnable_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_AuthDisable_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_Authenticate_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_UserAdd_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_UserGet_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_UserList_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_UserDelete_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_UserChangePassword_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_UserGrantRole_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_UserRevokeRole_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_RoleAdd_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_RoleGet_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_RoleList_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_RoleDelete_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_RoleGrantPermission_0 = runtime.ForwardResponseMessage
+
+ forward_Auth_RoleRevokePermission_0 = runtime.ForwardResponseMessage
+)
diff --git a/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/raft_internal.pb.go b/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/raft_internal.pb.go
new file mode 100644
index 00000000..44a3b6f6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/raft_internal.pb.go
@@ -0,0 +1,2094 @@
+// Code generated by protoc-gen-gogo.
+// source: raft_internal.proto
+// DO NOT EDIT!
+
+package etcdserverpb
+
+import (
+ "fmt"
+
+ proto "github.com/golang/protobuf/proto"
+
+ math "math"
+
+ io "io"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+type RequestHeader struct {
+ ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
+ // username is a username that is associated with an auth token of gRPC connection
+ Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
+ // auth_revision is a revision number of auth.authStore. It is not related to mvcc
+ AuthRevision uint64 `protobuf:"varint,3,opt,name=auth_revision,json=authRevision,proto3" json:"auth_revision,omitempty"`
+}
+
+func (m *RequestHeader) Reset() { *m = RequestHeader{} }
+func (m *RequestHeader) String() string { return proto.CompactTextString(m) }
+func (*RequestHeader) ProtoMessage() {}
+func (*RequestHeader) Descriptor() ([]byte, []int) { return fileDescriptorRaftInternal, []int{0} }
+
+// An InternalRaftRequest is the union of all requests which can be
+// sent via raft.
+type InternalRaftRequest struct {
+ Header *RequestHeader `protobuf:"bytes,100,opt,name=header" json:"header,omitempty"`
+ ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
+ V2 *Request `protobuf:"bytes,2,opt,name=v2" json:"v2,omitempty"`
+ Range *RangeRequest `protobuf:"bytes,3,opt,name=range" json:"range,omitempty"`
+ Put *PutRequest `protobuf:"bytes,4,opt,name=put" json:"put,omitempty"`
+ DeleteRange *DeleteRangeRequest `protobuf:"bytes,5,opt,name=delete_range,json=deleteRange" json:"delete_range,omitempty"`
+ Txn *TxnRequest `protobuf:"bytes,6,opt,name=txn" json:"txn,omitempty"`
+ Compaction *CompactionRequest `protobuf:"bytes,7,opt,name=compaction" json:"compaction,omitempty"`
+ LeaseGrant *LeaseGrantRequest `protobuf:"bytes,8,opt,name=lease_grant,json=leaseGrant" json:"lease_grant,omitempty"`
+ LeaseRevoke *LeaseRevokeRequest `protobuf:"bytes,9,opt,name=lease_revoke,json=leaseRevoke" json:"lease_revoke,omitempty"`
+ Alarm *AlarmRequest `protobuf:"bytes,10,opt,name=alarm" json:"alarm,omitempty"`
+ AuthEnable *AuthEnableRequest `protobuf:"bytes,1000,opt,name=auth_enable,json=authEnable" json:"auth_enable,omitempty"`
+ AuthDisable *AuthDisableRequest `protobuf:"bytes,1011,opt,name=auth_disable,json=authDisable" json:"auth_disable,omitempty"`
+ Authenticate *InternalAuthenticateRequest `protobuf:"bytes,1012,opt,name=authenticate" json:"authenticate,omitempty"`
+ AuthUserAdd *AuthUserAddRequest `protobuf:"bytes,1100,opt,name=auth_user_add,json=authUserAdd" json:"auth_user_add,omitempty"`
+ AuthUserDelete *AuthUserDeleteRequest `protobuf:"bytes,1101,opt,name=auth_user_delete,json=authUserDelete" json:"auth_user_delete,omitempty"`
+ AuthUserGet *AuthUserGetRequest `protobuf:"bytes,1102,opt,name=auth_user_get,json=authUserGet" json:"auth_user_get,omitempty"`
+ AuthUserChangePassword *AuthUserChangePasswordRequest `protobuf:"bytes,1103,opt,name=auth_user_change_password,json=authUserChangePassword" json:"auth_user_change_password,omitempty"`
+ AuthUserGrantRole *AuthUserGrantRoleRequest `protobuf:"bytes,1104,opt,name=auth_user_grant_role,json=authUserGrantRole" json:"auth_user_grant_role,omitempty"`
+ AuthUserRevokeRole *AuthUserRevokeRoleRequest `protobuf:"bytes,1105,opt,name=auth_user_revoke_role,json=authUserRevokeRole" json:"auth_user_revoke_role,omitempty"`
+ AuthUserList *AuthUserListRequest `protobuf:"bytes,1106,opt,name=auth_user_list,json=authUserList" json:"auth_user_list,omitempty"`
+ AuthRoleList *AuthRoleListRequest `protobuf:"bytes,1107,opt,name=auth_role_list,json=authRoleList" json:"auth_role_list,omitempty"`
+ AuthRoleAdd *AuthRoleAddRequest `protobuf:"bytes,1200,opt,name=auth_role_add,json=authRoleAdd" json:"auth_role_add,omitempty"`
+ AuthRoleDelete *AuthRoleDeleteRequest `protobuf:"bytes,1201,opt,name=auth_role_delete,json=authRoleDelete" json:"auth_role_delete,omitempty"`
+ AuthRoleGet *AuthRoleGetRequest `protobuf:"bytes,1202,opt,name=auth_role_get,json=authRoleGet" json:"auth_role_get,omitempty"`
+ AuthRoleGrantPermission *AuthRoleGrantPermissionRequest `protobuf:"bytes,1203,opt,name=auth_role_grant_permission,json=authRoleGrantPermission" json:"auth_role_grant_permission,omitempty"`
+ AuthRoleRevokePermission *AuthRoleRevokePermissionRequest `protobuf:"bytes,1204,opt,name=auth_role_revoke_permission,json=authRoleRevokePermission" json:"auth_role_revoke_permission,omitempty"`
+}
+
+func (m *InternalRaftRequest) Reset() { *m = InternalRaftRequest{} }
+func (m *InternalRaftRequest) String() string { return proto.CompactTextString(m) }
+func (*InternalRaftRequest) ProtoMessage() {}
+func (*InternalRaftRequest) Descriptor() ([]byte, []int) { return fileDescriptorRaftInternal, []int{1} }
+
+type EmptyResponse struct {
+}
+
+func (m *EmptyResponse) Reset() { *m = EmptyResponse{} }
+func (m *EmptyResponse) String() string { return proto.CompactTextString(m) }
+func (*EmptyResponse) ProtoMessage() {}
+func (*EmptyResponse) Descriptor() ([]byte, []int) { return fileDescriptorRaftInternal, []int{2} }
+
+// What is the difference between AuthenticateRequest (defined in rpc.proto) and InternalAuthenticateRequest?
+// InternalAuthenticateRequest has a member that is filled by etcdserver and shouldn't be user-facing.
+// For avoiding misusage the field, we have an internal version of AuthenticateRequest.
+type InternalAuthenticateRequest struct {
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
+ // simple_token is generated in API layer (etcdserver/v3_server.go)
+ SimpleToken string `protobuf:"bytes,3,opt,name=simple_token,json=simpleToken,proto3" json:"simple_token,omitempty"`
+}
+
+func (m *InternalAuthenticateRequest) Reset() { *m = InternalAuthenticateRequest{} }
+func (m *InternalAuthenticateRequest) String() string { return proto.CompactTextString(m) }
+func (*InternalAuthenticateRequest) ProtoMessage() {}
+func (*InternalAuthenticateRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptorRaftInternal, []int{3}
+}
+
+func init() {
+ proto.RegisterType((*RequestHeader)(nil), "etcdserverpb.RequestHeader")
+ proto.RegisterType((*InternalRaftRequest)(nil), "etcdserverpb.InternalRaftRequest")
+ proto.RegisterType((*EmptyResponse)(nil), "etcdserverpb.EmptyResponse")
+ proto.RegisterType((*InternalAuthenticateRequest)(nil), "etcdserverpb.InternalAuthenticateRequest")
+}
+func (m *RequestHeader) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *RequestHeader) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.ID != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.ID))
+ }
+ if len(m.Username) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(len(m.Username)))
+ i += copy(dAtA[i:], m.Username)
+ }
+ if m.AuthRevision != 0 {
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthRevision))
+ }
+ return i, nil
+}
+
+func (m *InternalRaftRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *InternalRaftRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.ID != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.ID))
+ }
+ if m.V2 != nil {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.V2.Size()))
+ n1, err := m.V2.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n1
+ }
+ if m.Range != nil {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.Range.Size()))
+ n2, err := m.Range.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n2
+ }
+ if m.Put != nil {
+ dAtA[i] = 0x22
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.Put.Size()))
+ n3, err := m.Put.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n3
+ }
+ if m.DeleteRange != nil {
+ dAtA[i] = 0x2a
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.DeleteRange.Size()))
+ n4, err := m.DeleteRange.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n4
+ }
+ if m.Txn != nil {
+ dAtA[i] = 0x32
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.Txn.Size()))
+ n5, err := m.Txn.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n5
+ }
+ if m.Compaction != nil {
+ dAtA[i] = 0x3a
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.Compaction.Size()))
+ n6, err := m.Compaction.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n6
+ }
+ if m.LeaseGrant != nil {
+ dAtA[i] = 0x42
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.LeaseGrant.Size()))
+ n7, err := m.LeaseGrant.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n7
+ }
+ if m.LeaseRevoke != nil {
+ dAtA[i] = 0x4a
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.LeaseRevoke.Size()))
+ n8, err := m.LeaseRevoke.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n8
+ }
+ if m.Alarm != nil {
+ dAtA[i] = 0x52
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.Alarm.Size()))
+ n9, err := m.Alarm.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n9
+ }
+ if m.Header != nil {
+ dAtA[i] = 0xa2
+ i++
+ dAtA[i] = 0x6
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.Header.Size()))
+ n10, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n10
+ }
+ if m.AuthEnable != nil {
+ dAtA[i] = 0xc2
+ i++
+ dAtA[i] = 0x3e
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthEnable.Size()))
+ n11, err := m.AuthEnable.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n11
+ }
+ if m.AuthDisable != nil {
+ dAtA[i] = 0x9a
+ i++
+ dAtA[i] = 0x3f
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthDisable.Size()))
+ n12, err := m.AuthDisable.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n12
+ }
+ if m.Authenticate != nil {
+ dAtA[i] = 0xa2
+ i++
+ dAtA[i] = 0x3f
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.Authenticate.Size()))
+ n13, err := m.Authenticate.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n13
+ }
+ if m.AuthUserAdd != nil {
+ dAtA[i] = 0xe2
+ i++
+ dAtA[i] = 0x44
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthUserAdd.Size()))
+ n14, err := m.AuthUserAdd.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n14
+ }
+ if m.AuthUserDelete != nil {
+ dAtA[i] = 0xea
+ i++
+ dAtA[i] = 0x44
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthUserDelete.Size()))
+ n15, err := m.AuthUserDelete.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n15
+ }
+ if m.AuthUserGet != nil {
+ dAtA[i] = 0xf2
+ i++
+ dAtA[i] = 0x44
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthUserGet.Size()))
+ n16, err := m.AuthUserGet.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n16
+ }
+ if m.AuthUserChangePassword != nil {
+ dAtA[i] = 0xfa
+ i++
+ dAtA[i] = 0x44
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthUserChangePassword.Size()))
+ n17, err := m.AuthUserChangePassword.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n17
+ }
+ if m.AuthUserGrantRole != nil {
+ dAtA[i] = 0x82
+ i++
+ dAtA[i] = 0x45
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthUserGrantRole.Size()))
+ n18, err := m.AuthUserGrantRole.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n18
+ }
+ if m.AuthUserRevokeRole != nil {
+ dAtA[i] = 0x8a
+ i++
+ dAtA[i] = 0x45
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthUserRevokeRole.Size()))
+ n19, err := m.AuthUserRevokeRole.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n19
+ }
+ if m.AuthUserList != nil {
+ dAtA[i] = 0x92
+ i++
+ dAtA[i] = 0x45
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthUserList.Size()))
+ n20, err := m.AuthUserList.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n20
+ }
+ if m.AuthRoleList != nil {
+ dAtA[i] = 0x9a
+ i++
+ dAtA[i] = 0x45
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthRoleList.Size()))
+ n21, err := m.AuthRoleList.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n21
+ }
+ if m.AuthRoleAdd != nil {
+ dAtA[i] = 0x82
+ i++
+ dAtA[i] = 0x4b
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthRoleAdd.Size()))
+ n22, err := m.AuthRoleAdd.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n22
+ }
+ if m.AuthRoleDelete != nil {
+ dAtA[i] = 0x8a
+ i++
+ dAtA[i] = 0x4b
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthRoleDelete.Size()))
+ n23, err := m.AuthRoleDelete.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n23
+ }
+ if m.AuthRoleGet != nil {
+ dAtA[i] = 0x92
+ i++
+ dAtA[i] = 0x4b
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthRoleGet.Size()))
+ n24, err := m.AuthRoleGet.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n24
+ }
+ if m.AuthRoleGrantPermission != nil {
+ dAtA[i] = 0x9a
+ i++
+ dAtA[i] = 0x4b
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthRoleGrantPermission.Size()))
+ n25, err := m.AuthRoleGrantPermission.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n25
+ }
+ if m.AuthRoleRevokePermission != nil {
+ dAtA[i] = 0xa2
+ i++
+ dAtA[i] = 0x4b
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthRoleRevokePermission.Size()))
+ n26, err := m.AuthRoleRevokePermission.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n26
+ }
+ return i, nil
+}
+
+func (m *EmptyResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *EmptyResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ return i, nil
+}
+
+func (m *InternalAuthenticateRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *InternalAuthenticateRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ if len(m.Password) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(len(m.Password)))
+ i += copy(dAtA[i:], m.Password)
+ }
+ if len(m.SimpleToken) > 0 {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintRaftInternal(dAtA, i, uint64(len(m.SimpleToken)))
+ i += copy(dAtA[i:], m.SimpleToken)
+ }
+ return i, nil
+}
+
+func encodeFixed64RaftInternal(dAtA []byte, offset int, v uint64) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ dAtA[offset+4] = uint8(v >> 32)
+ dAtA[offset+5] = uint8(v >> 40)
+ dAtA[offset+6] = uint8(v >> 48)
+ dAtA[offset+7] = uint8(v >> 56)
+ return offset + 8
+}
+func encodeFixed32RaftInternal(dAtA []byte, offset int, v uint32) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ return offset + 4
+}
+func encodeVarintRaftInternal(dAtA []byte, offset int, v uint64) int {
+ for v >= 1<<7 {
+ dAtA[offset] = uint8(v&0x7f | 0x80)
+ v >>= 7
+ offset++
+ }
+ dAtA[offset] = uint8(v)
+ return offset + 1
+}
+func (m *RequestHeader) Size() (n int) {
+ var l int
+ _ = l
+ if m.ID != 0 {
+ n += 1 + sovRaftInternal(uint64(m.ID))
+ }
+ l = len(m.Username)
+ if l > 0 {
+ n += 1 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthRevision != 0 {
+ n += 1 + sovRaftInternal(uint64(m.AuthRevision))
+ }
+ return n
+}
+
+func (m *InternalRaftRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.ID != 0 {
+ n += 1 + sovRaftInternal(uint64(m.ID))
+ }
+ if m.V2 != nil {
+ l = m.V2.Size()
+ n += 1 + l + sovRaftInternal(uint64(l))
+ }
+ if m.Range != nil {
+ l = m.Range.Size()
+ n += 1 + l + sovRaftInternal(uint64(l))
+ }
+ if m.Put != nil {
+ l = m.Put.Size()
+ n += 1 + l + sovRaftInternal(uint64(l))
+ }
+ if m.DeleteRange != nil {
+ l = m.DeleteRange.Size()
+ n += 1 + l + sovRaftInternal(uint64(l))
+ }
+ if m.Txn != nil {
+ l = m.Txn.Size()
+ n += 1 + l + sovRaftInternal(uint64(l))
+ }
+ if m.Compaction != nil {
+ l = m.Compaction.Size()
+ n += 1 + l + sovRaftInternal(uint64(l))
+ }
+ if m.LeaseGrant != nil {
+ l = m.LeaseGrant.Size()
+ n += 1 + l + sovRaftInternal(uint64(l))
+ }
+ if m.LeaseRevoke != nil {
+ l = m.LeaseRevoke.Size()
+ n += 1 + l + sovRaftInternal(uint64(l))
+ }
+ if m.Alarm != nil {
+ l = m.Alarm.Size()
+ n += 1 + l + sovRaftInternal(uint64(l))
+ }
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthEnable != nil {
+ l = m.AuthEnable.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthDisable != nil {
+ l = m.AuthDisable.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.Authenticate != nil {
+ l = m.Authenticate.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthUserAdd != nil {
+ l = m.AuthUserAdd.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthUserDelete != nil {
+ l = m.AuthUserDelete.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthUserGet != nil {
+ l = m.AuthUserGet.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthUserChangePassword != nil {
+ l = m.AuthUserChangePassword.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthUserGrantRole != nil {
+ l = m.AuthUserGrantRole.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthUserRevokeRole != nil {
+ l = m.AuthUserRevokeRole.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthUserList != nil {
+ l = m.AuthUserList.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthRoleList != nil {
+ l = m.AuthRoleList.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthRoleAdd != nil {
+ l = m.AuthRoleAdd.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthRoleDelete != nil {
+ l = m.AuthRoleDelete.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthRoleGet != nil {
+ l = m.AuthRoleGet.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthRoleGrantPermission != nil {
+ l = m.AuthRoleGrantPermission.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ if m.AuthRoleRevokePermission != nil {
+ l = m.AuthRoleRevokePermission.Size()
+ n += 2 + l + sovRaftInternal(uint64(l))
+ }
+ return n
+}
+
+func (m *EmptyResponse) Size() (n int) {
+ var l int
+ _ = l
+ return n
+}
+
+func (m *InternalAuthenticateRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovRaftInternal(uint64(l))
+ }
+ l = len(m.Password)
+ if l > 0 {
+ n += 1 + l + sovRaftInternal(uint64(l))
+ }
+ l = len(m.SimpleToken)
+ if l > 0 {
+ n += 1 + l + sovRaftInternal(uint64(l))
+ }
+ return n
+}
+
+func sovRaftInternal(x uint64) (n int) {
+ for {
+ n++
+ x >>= 7
+ if x == 0 {
+ break
+ }
+ }
+ return n
+}
+func sozRaftInternal(x uint64) (n int) {
+ return sovRaftInternal(uint64((x << 1) ^ uint64((int64(x) >> 63))))
+}
+func (m *RequestHeader) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: RequestHeader: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: RequestHeader: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Username", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Username = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthRevision", wireType)
+ }
+ m.AuthRevision = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.AuthRevision |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRaftInternal(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *InternalRaftRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: InternalRaftRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: InternalRaftRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field V2", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.V2 == nil {
+ m.V2 = &Request{}
+ }
+ if err := m.V2.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Range", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Range == nil {
+ m.Range = &RangeRequest{}
+ }
+ if err := m.Range.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 4:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Put", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Put == nil {
+ m.Put = &PutRequest{}
+ }
+ if err := m.Put.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 5:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field DeleteRange", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.DeleteRange == nil {
+ m.DeleteRange = &DeleteRangeRequest{}
+ }
+ if err := m.DeleteRange.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 6:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Txn", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Txn == nil {
+ m.Txn = &TxnRequest{}
+ }
+ if err := m.Txn.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 7:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Compaction", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Compaction == nil {
+ m.Compaction = &CompactionRequest{}
+ }
+ if err := m.Compaction.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 8:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field LeaseGrant", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.LeaseGrant == nil {
+ m.LeaseGrant = &LeaseGrantRequest{}
+ }
+ if err := m.LeaseGrant.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 9:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field LeaseRevoke", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.LeaseRevoke == nil {
+ m.LeaseRevoke = &LeaseRevokeRequest{}
+ }
+ if err := m.LeaseRevoke.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 10:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Alarm", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Alarm == nil {
+ m.Alarm = &AlarmRequest{}
+ }
+ if err := m.Alarm.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 100:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &RequestHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1000:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthEnable", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthEnable == nil {
+ m.AuthEnable = &AuthEnableRequest{}
+ }
+ if err := m.AuthEnable.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1011:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthDisable", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthDisable == nil {
+ m.AuthDisable = &AuthDisableRequest{}
+ }
+ if err := m.AuthDisable.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1012:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Authenticate", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Authenticate == nil {
+ m.Authenticate = &InternalAuthenticateRequest{}
+ }
+ if err := m.Authenticate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1100:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthUserAdd", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthUserAdd == nil {
+ m.AuthUserAdd = &AuthUserAddRequest{}
+ }
+ if err := m.AuthUserAdd.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1101:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthUserDelete", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthUserDelete == nil {
+ m.AuthUserDelete = &AuthUserDeleteRequest{}
+ }
+ if err := m.AuthUserDelete.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1102:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthUserGet", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthUserGet == nil {
+ m.AuthUserGet = &AuthUserGetRequest{}
+ }
+ if err := m.AuthUserGet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1103:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthUserChangePassword", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthUserChangePassword == nil {
+ m.AuthUserChangePassword = &AuthUserChangePasswordRequest{}
+ }
+ if err := m.AuthUserChangePassword.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1104:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthUserGrantRole", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthUserGrantRole == nil {
+ m.AuthUserGrantRole = &AuthUserGrantRoleRequest{}
+ }
+ if err := m.AuthUserGrantRole.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1105:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthUserRevokeRole", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthUserRevokeRole == nil {
+ m.AuthUserRevokeRole = &AuthUserRevokeRoleRequest{}
+ }
+ if err := m.AuthUserRevokeRole.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1106:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthUserList", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthUserList == nil {
+ m.AuthUserList = &AuthUserListRequest{}
+ }
+ if err := m.AuthUserList.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1107:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthRoleList", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthRoleList == nil {
+ m.AuthRoleList = &AuthRoleListRequest{}
+ }
+ if err := m.AuthRoleList.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1200:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthRoleAdd", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthRoleAdd == nil {
+ m.AuthRoleAdd = &AuthRoleAddRequest{}
+ }
+ if err := m.AuthRoleAdd.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1201:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthRoleDelete", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthRoleDelete == nil {
+ m.AuthRoleDelete = &AuthRoleDeleteRequest{}
+ }
+ if err := m.AuthRoleDelete.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1202:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthRoleGet", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthRoleGet == nil {
+ m.AuthRoleGet = &AuthRoleGetRequest{}
+ }
+ if err := m.AuthRoleGet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1203:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthRoleGrantPermission", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthRoleGrantPermission == nil {
+ m.AuthRoleGrantPermission = &AuthRoleGrantPermissionRequest{}
+ }
+ if err := m.AuthRoleGrantPermission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 1204:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field AuthRoleRevokePermission", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.AuthRoleRevokePermission == nil {
+ m.AuthRoleRevokePermission = &AuthRoleRevokePermissionRequest{}
+ }
+ if err := m.AuthRoleRevokePermission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRaftInternal(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *EmptyResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: EmptyResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: EmptyResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRaftInternal(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *InternalAuthenticateRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: InternalAuthenticateRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: InternalAuthenticateRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Password", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Password = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field SimpleToken", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.SimpleToken = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRaftInternal(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRaftInternal
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func skipRaftInternal(dAtA []byte) (n int, err error) {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ wireType := int(wire & 0x7)
+ switch wireType {
+ case 0:
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ iNdEx++
+ if dAtA[iNdEx-1] < 0x80 {
+ break
+ }
+ }
+ return iNdEx, nil
+ case 1:
+ iNdEx += 8
+ return iNdEx, nil
+ case 2:
+ var length int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ length |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ iNdEx += length
+ if length < 0 {
+ return 0, ErrInvalidLengthRaftInternal
+ }
+ return iNdEx, nil
+ case 3:
+ for {
+ var innerWire uint64
+ var start int = iNdEx
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRaftInternal
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ innerWire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ innerWireType := int(innerWire & 0x7)
+ if innerWireType == 4 {
+ break
+ }
+ next, err := skipRaftInternal(dAtA[start:])
+ if err != nil {
+ return 0, err
+ }
+ iNdEx = start + next
+ }
+ return iNdEx, nil
+ case 4:
+ return iNdEx, nil
+ case 5:
+ iNdEx += 4
+ return iNdEx, nil
+ default:
+ return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
+ }
+ }
+ panic("unreachable")
+}
+
+var (
+ ErrInvalidLengthRaftInternal = fmt.Errorf("proto: negative length found during unmarshaling")
+ ErrIntOverflowRaftInternal = fmt.Errorf("proto: integer overflow")
+)
+
+func init() { proto.RegisterFile("raft_internal.proto", fileDescriptorRaftInternal) }
+
+var fileDescriptorRaftInternal = []byte{
+ // 837 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x96, 0xdd, 0x52, 0xd3, 0x40,
+ 0x14, 0xc7, 0x69, 0xf9, 0xec, 0xb6, 0x54, 0x5c, 0x40, 0xd7, 0x32, 0x53, 0xa1, 0x8c, 0x8a, 0x5f,
+ 0xe8, 0x94, 0x07, 0xd0, 0x4a, 0x19, 0x60, 0x86, 0x61, 0x98, 0x0c, 0xce, 0x38, 0xe3, 0x45, 0x5c,
+ 0x9a, 0x43, 0x1b, 0x49, 0x93, 0xb8, 0xd9, 0x56, 0x7c, 0x13, 0x1f, 0xc3, 0xaf, 0x87, 0xe0, 0xc2,
+ 0x0f, 0xd4, 0x17, 0x50, 0xbc, 0xf1, 0xca, 0x1b, 0x7d, 0x00, 0x67, 0x3f, 0x92, 0x34, 0x6d, 0xca,
+ 0x5d, 0x72, 0xce, 0xff, 0xfc, 0xce, 0xd9, 0xec, 0x7f, 0xbb, 0x45, 0xb3, 0x8c, 0x1e, 0x72, 0xd3,
+ 0x76, 0x39, 0x30, 0x97, 0x3a, 0xab, 0x3e, 0xf3, 0xb8, 0x87, 0x0b, 0xc0, 0x1b, 0x56, 0x00, 0xac,
+ 0x0b, 0xcc, 0x3f, 0x28, 0xcd, 0x35, 0xbd, 0xa6, 0x27, 0x13, 0xf7, 0xc4, 0x93, 0xd2, 0x94, 0x66,
+ 0x62, 0x8d, 0x8e, 0xe4, 0x98, 0xdf, 0x50, 0x8f, 0x95, 0x67, 0x68, 0xda, 0x80, 0x17, 0x1d, 0x08,
+ 0xf8, 0x16, 0x50, 0x0b, 0x18, 0x2e, 0xa2, 0xec, 0x76, 0x9d, 0x64, 0x16, 0x33, 0x2b, 0x63, 0x46,
+ 0x76, 0xbb, 0x8e, 0x4b, 0x68, 0xaa, 0x13, 0x88, 0x96, 0x6d, 0x20, 0xd9, 0xc5, 0xcc, 0x4a, 0xce,
+ 0x88, 0xde, 0xf1, 0x32, 0x9a, 0xa6, 0x1d, 0xde, 0x32, 0x19, 0x74, 0xed, 0xc0, 0xf6, 0x5c, 0x32,
+ 0x2a, 0xcb, 0x0a, 0x22, 0x68, 0xe8, 0x58, 0xe5, 0x4f, 0x11, 0xcd, 0x6e, 0xeb, 0xa9, 0x0d, 0x7a,
+ 0xc8, 0x75, 0xbb, 0x81, 0x46, 0xd7, 0x50, 0xb6, 0x5b, 0x95, 0x2d, 0xf2, 0xd5, 0xf9, 0xd5, 0xde,
+ 0x75, 0xad, 0xea, 0x12, 0x23, 0xdb, 0xad, 0xe2, 0xfb, 0x68, 0x9c, 0x51, 0xb7, 0x09, 0xb2, 0x57,
+ 0xbe, 0x5a, 0xea, 0x53, 0x8a, 0x54, 0x28, 0x57, 0x42, 0x7c, 0x0b, 0x8d, 0xfa, 0x1d, 0x4e, 0xc6,
+ 0xa4, 0x9e, 0x24, 0xf5, 0x7b, 0x9d, 0x70, 0x1e, 0x43, 0x88, 0xf0, 0x3a, 0x2a, 0x58, 0xe0, 0x00,
+ 0x07, 0x53, 0x35, 0x19, 0x97, 0x45, 0x8b, 0xc9, 0xa2, 0xba, 0x54, 0x24, 0x5a, 0xe5, 0xad, 0x38,
+ 0x26, 0x1a, 0xf2, 0x63, 0x97, 0x4c, 0xa4, 0x35, 0xdc, 0x3f, 0x76, 0xa3, 0x86, 0xfc, 0xd8, 0xc5,
+ 0x0f, 0x10, 0x6a, 0x78, 0x6d, 0x9f, 0x36, 0xb8, 0xf8, 0x7e, 0x93, 0xb2, 0xe4, 0x6a, 0xb2, 0x64,
+ 0x3d, 0xca, 0x87, 0x95, 0x3d, 0x25, 0xf8, 0x21, 0xca, 0x3b, 0x40, 0x03, 0x30, 0x9b, 0x8c, 0xba,
+ 0x9c, 0x4c, 0xa5, 0x11, 0x76, 0x84, 0x60, 0x53, 0xe4, 0x23, 0x82, 0x13, 0x85, 0xc4, 0x9a, 0x15,
+ 0x81, 0x41, 0xd7, 0x3b, 0x02, 0x92, 0x4b, 0x5b, 0xb3, 0x44, 0x18, 0x52, 0x10, 0xad, 0xd9, 0x89,
+ 0x63, 0x62, 0x5b, 0xa8, 0x43, 0x59, 0x9b, 0xa0, 0xb4, 0x6d, 0xa9, 0x89, 0x54, 0xb4, 0x2d, 0x52,
+ 0x88, 0xd7, 0xd0, 0x44, 0x4b, 0x5a, 0x8e, 0x58, 0xb2, 0x64, 0x21, 0x75, 0xcf, 0x95, 0x2b, 0x0d,
+ 0x2d, 0xc5, 0x35, 0x94, 0x97, 0x8e, 0x03, 0x97, 0x1e, 0x38, 0x40, 0x7e, 0xa7, 0x7e, 0xb0, 0x5a,
+ 0x87, 0xb7, 0x36, 0xa4, 0x20, 0x5a, 0x2e, 0x8d, 0x42, 0xb8, 0x8e, 0xa4, 0x3f, 0x4d, 0xcb, 0x0e,
+ 0x24, 0xe3, 0xef, 0x64, 0xda, 0x7a, 0x05, 0xa3, 0xae, 0x14, 0xd1, 0x7a, 0x69, 0x1c, 0xc3, 0xbb,
+ 0x8a, 0x02, 0x2e, 0xb7, 0x1b, 0x94, 0x03, 0xf9, 0xa7, 0x28, 0x37, 0x93, 0x94, 0xd0, 0xf7, 0xb5,
+ 0x1e, 0x69, 0x88, 0x4b, 0xd4, 0xe3, 0x0d, 0x7d, 0x94, 0xc4, 0xd9, 0x32, 0xa9, 0x65, 0x91, 0x8f,
+ 0x53, 0xc3, 0xc6, 0x7a, 0x1c, 0x00, 0xab, 0x59, 0x56, 0x62, 0x2c, 0x1d, 0xc3, 0xbb, 0x68, 0x26,
+ 0xc6, 0x28, 0x4f, 0x92, 0x4f, 0x8a, 0xb4, 0x9c, 0x4e, 0xd2, 0x66, 0xd6, 0xb0, 0x22, 0x4d, 0x84,
+ 0x93, 0x63, 0x35, 0x81, 0x93, 0xcf, 0xe7, 0x8e, 0xb5, 0x09, 0x7c, 0x60, 0xac, 0x4d, 0xe0, 0xb8,
+ 0x89, 0xae, 0xc4, 0x98, 0x46, 0x4b, 0x9c, 0x12, 0xd3, 0xa7, 0x41, 0xf0, 0xd2, 0x63, 0x16, 0xf9,
+ 0xa2, 0x90, 0xb7, 0xd3, 0x91, 0xeb, 0x52, 0xbd, 0xa7, 0xc5, 0x21, 0xfd, 0x12, 0x4d, 0x4d, 0xe3,
+ 0x27, 0x68, 0xae, 0x67, 0x5e, 0x61, 0x6f, 0x93, 0x79, 0x0e, 0x90, 0x53, 0xd5, 0xe3, 0xfa, 0x90,
+ 0xb1, 0xe5, 0xd1, 0xf0, 0xe2, 0xad, 0xbe, 0x48, 0xfb, 0x33, 0xf8, 0x29, 0x9a, 0x8f, 0xc9, 0xea,
+ 0xa4, 0x28, 0xf4, 0x57, 0x85, 0xbe, 0x91, 0x8e, 0xd6, 0x47, 0xa6, 0x87, 0x8d, 0xe9, 0x40, 0x0a,
+ 0x6f, 0xa1, 0x62, 0x0c, 0x77, 0xec, 0x80, 0x93, 0x6f, 0x8a, 0xba, 0x94, 0x4e, 0xdd, 0xb1, 0x03,
+ 0x9e, 0xf0, 0x51, 0x18, 0x8c, 0x48, 0x62, 0x34, 0x45, 0xfa, 0x3e, 0x94, 0x24, 0x5a, 0x0f, 0x90,
+ 0xc2, 0x60, 0xb4, 0xf5, 0x92, 0x24, 0x1c, 0xf9, 0x26, 0x37, 0x6c, 0xeb, 0x45, 0x4d, 0xbf, 0x23,
+ 0x75, 0x2c, 0x72, 0xa4, 0xc4, 0x68, 0x47, 0xbe, 0xcd, 0x0d, 0x73, 0xa4, 0xa8, 0x4a, 0x71, 0x64,
+ 0x1c, 0x4e, 0x8e, 0x25, 0x1c, 0xf9, 0xee, 0xdc, 0xb1, 0xfa, 0x1d, 0xa9, 0x63, 0xf8, 0x39, 0x2a,
+ 0xf5, 0x60, 0xa4, 0x51, 0x7c, 0x60, 0x6d, 0x3b, 0x90, 0xf7, 0xd8, 0x7b, 0xc5, 0xbc, 0x33, 0x84,
+ 0x29, 0xe4, 0x7b, 0x91, 0x3a, 0xe4, 0x5f, 0xa6, 0xe9, 0x79, 0xdc, 0x46, 0x0b, 0x71, 0x2f, 0x6d,
+ 0x9d, 0x9e, 0x66, 0x1f, 0x54, 0xb3, 0xbb, 0xe9, 0xcd, 0x94, 0x4b, 0x06, 0xbb, 0x11, 0x3a, 0x44,
+ 0x50, 0xb9, 0x80, 0xa6, 0x37, 0xda, 0x3e, 0x7f, 0x65, 0x40, 0xe0, 0x7b, 0x6e, 0x00, 0x15, 0x1f,
+ 0x2d, 0x9c, 0xf3, 0x43, 0x84, 0x31, 0x1a, 0x93, 0xb7, 0x7b, 0x46, 0xde, 0xee, 0xf2, 0x59, 0xdc,
+ 0xfa, 0xd1, 0xf9, 0xd4, 0xb7, 0x7e, 0xf8, 0x8e, 0x97, 0x50, 0x21, 0xb0, 0xdb, 0xbe, 0x03, 0x26,
+ 0xf7, 0x8e, 0x40, 0x5d, 0xfa, 0x39, 0x23, 0xaf, 0x62, 0xfb, 0x22, 0xf4, 0x68, 0xee, 0xe4, 0x67,
+ 0x79, 0xe4, 0xe4, 0xac, 0x9c, 0x39, 0x3d, 0x2b, 0x67, 0x7e, 0x9c, 0x95, 0x33, 0xaf, 0x7f, 0x95,
+ 0x47, 0x0e, 0x26, 0xe4, 0x5f, 0x8e, 0xb5, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xff, 0xc9, 0xfc,
+ 0x0e, 0xca, 0x08, 0x00, 0x00,
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/raft_internal.proto b/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/raft_internal.proto
new file mode 100644
index 00000000..25d45d3c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/raft_internal.proto
@@ -0,0 +1,74 @@
+syntax = "proto3";
+package etcdserverpb;
+
+import "gogoproto/gogo.proto";
+import "etcdserver.proto";
+import "rpc.proto";
+
+option (gogoproto.marshaler_all) = true;
+option (gogoproto.sizer_all) = true;
+option (gogoproto.unmarshaler_all) = true;
+option (gogoproto.goproto_getters_all) = false;
+
+message RequestHeader {
+ uint64 ID = 1;
+ // username is a username that is associated with an auth token of gRPC connection
+ string username = 2;
+ // auth_revision is a revision number of auth.authStore. It is not related to mvcc
+ uint64 auth_revision = 3;
+}
+
+// An InternalRaftRequest is the union of all requests which can be
+// sent via raft.
+message InternalRaftRequest {
+ RequestHeader header = 100;
+ uint64 ID = 1;
+
+ Request v2 = 2;
+
+ RangeRequest range = 3;
+ PutRequest put = 4;
+ DeleteRangeRequest delete_range = 5;
+ TxnRequest txn = 6;
+ CompactionRequest compaction = 7;
+
+ LeaseGrantRequest lease_grant = 8;
+ LeaseRevokeRequest lease_revoke = 9;
+
+ AlarmRequest alarm = 10;
+
+ AuthEnableRequest auth_enable = 1000;
+ AuthDisableRequest auth_disable = 1011;
+
+ InternalAuthenticateRequest authenticate = 1012;
+
+ AuthUserAddRequest auth_user_add = 1100;
+ AuthUserDeleteRequest auth_user_delete = 1101;
+ AuthUserGetRequest auth_user_get = 1102;
+ AuthUserChangePasswordRequest auth_user_change_password = 1103;
+ AuthUserGrantRoleRequest auth_user_grant_role = 1104;
+ AuthUserRevokeRoleRequest auth_user_revoke_role = 1105;
+ AuthUserListRequest auth_user_list = 1106;
+ AuthRoleListRequest auth_role_list = 1107;
+
+ AuthRoleAddRequest auth_role_add = 1200;
+ AuthRoleDeleteRequest auth_role_delete = 1201;
+ AuthRoleGetRequest auth_role_get = 1202;
+ AuthRoleGrantPermissionRequest auth_role_grant_permission = 1203;
+ AuthRoleRevokePermissionRequest auth_role_revoke_permission = 1204;
+}
+
+message EmptyResponse {
+}
+
+// What is the difference between AuthenticateRequest (defined in rpc.proto) and InternalAuthenticateRequest?
+// InternalAuthenticateRequest has a member that is filled by etcdserver and shouldn't be user-facing.
+// For avoiding misusage the field, we have an internal version of AuthenticateRequest.
+message InternalAuthenticateRequest {
+ string name = 1;
+ string password = 2;
+
+ // simple_token is generated in API layer (etcdserver/v3_server.go)
+ string simple_token = 3;
+}
+
diff --git a/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/rpc.pb.go b/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/rpc.pb.go
new file mode 100644
index 00000000..018a3652
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/rpc.pb.go
@@ -0,0 +1,16549 @@
+// Code generated by protoc-gen-gogo.
+// source: rpc.proto
+// DO NOT EDIT!
+
+package etcdserverpb
+
+import (
+ "fmt"
+
+ proto "github.com/golang/protobuf/proto"
+
+ math "math"
+
+ mvccpb "github.com/coreos/etcd/mvcc/mvccpb"
+
+ authpb "github.com/coreos/etcd/auth/authpb"
+
+ context "golang.org/x/net/context"
+
+ grpc "google.golang.org/grpc"
+
+ io "io"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+type AlarmType int32
+
+const (
+ AlarmType_NONE AlarmType = 0
+ AlarmType_NOSPACE AlarmType = 1
+)
+
+var AlarmType_name = map[int32]string{
+ 0: "NONE",
+ 1: "NOSPACE",
+}
+var AlarmType_value = map[string]int32{
+ "NONE": 0,
+ "NOSPACE": 1,
+}
+
+func (x AlarmType) String() string {
+ return proto.EnumName(AlarmType_name, int32(x))
+}
+func (AlarmType) EnumDescriptor() ([]byte, []int) { return fileDescriptorRpc, []int{0} }
+
+type RangeRequest_SortOrder int32
+
+const (
+ RangeRequest_NONE RangeRequest_SortOrder = 0
+ RangeRequest_ASCEND RangeRequest_SortOrder = 1
+ RangeRequest_DESCEND RangeRequest_SortOrder = 2
+)
+
+var RangeRequest_SortOrder_name = map[int32]string{
+ 0: "NONE",
+ 1: "ASCEND",
+ 2: "DESCEND",
+}
+var RangeRequest_SortOrder_value = map[string]int32{
+ "NONE": 0,
+ "ASCEND": 1,
+ "DESCEND": 2,
+}
+
+func (x RangeRequest_SortOrder) String() string {
+ return proto.EnumName(RangeRequest_SortOrder_name, int32(x))
+}
+func (RangeRequest_SortOrder) EnumDescriptor() ([]byte, []int) { return fileDescriptorRpc, []int{1, 0} }
+
+type RangeRequest_SortTarget int32
+
+const (
+ RangeRequest_KEY RangeRequest_SortTarget = 0
+ RangeRequest_VERSION RangeRequest_SortTarget = 1
+ RangeRequest_CREATE RangeRequest_SortTarget = 2
+ RangeRequest_MOD RangeRequest_SortTarget = 3
+ RangeRequest_VALUE RangeRequest_SortTarget = 4
+)
+
+var RangeRequest_SortTarget_name = map[int32]string{
+ 0: "KEY",
+ 1: "VERSION",
+ 2: "CREATE",
+ 3: "MOD",
+ 4: "VALUE",
+}
+var RangeRequest_SortTarget_value = map[string]int32{
+ "KEY": 0,
+ "VERSION": 1,
+ "CREATE": 2,
+ "MOD": 3,
+ "VALUE": 4,
+}
+
+func (x RangeRequest_SortTarget) String() string {
+ return proto.EnumName(RangeRequest_SortTarget_name, int32(x))
+}
+func (RangeRequest_SortTarget) EnumDescriptor() ([]byte, []int) { return fileDescriptorRpc, []int{1, 1} }
+
+type Compare_CompareResult int32
+
+const (
+ Compare_EQUAL Compare_CompareResult = 0
+ Compare_GREATER Compare_CompareResult = 1
+ Compare_LESS Compare_CompareResult = 2
+ Compare_NOT_EQUAL Compare_CompareResult = 3
+)
+
+var Compare_CompareResult_name = map[int32]string{
+ 0: "EQUAL",
+ 1: "GREATER",
+ 2: "LESS",
+ 3: "NOT_EQUAL",
+}
+var Compare_CompareResult_value = map[string]int32{
+ "EQUAL": 0,
+ "GREATER": 1,
+ "LESS": 2,
+ "NOT_EQUAL": 3,
+}
+
+func (x Compare_CompareResult) String() string {
+ return proto.EnumName(Compare_CompareResult_name, int32(x))
+}
+func (Compare_CompareResult) EnumDescriptor() ([]byte, []int) { return fileDescriptorRpc, []int{9, 0} }
+
+type Compare_CompareTarget int32
+
+const (
+ Compare_VERSION Compare_CompareTarget = 0
+ Compare_CREATE Compare_CompareTarget = 1
+ Compare_MOD Compare_CompareTarget = 2
+ Compare_VALUE Compare_CompareTarget = 3
+)
+
+var Compare_CompareTarget_name = map[int32]string{
+ 0: "VERSION",
+ 1: "CREATE",
+ 2: "MOD",
+ 3: "VALUE",
+}
+var Compare_CompareTarget_value = map[string]int32{
+ "VERSION": 0,
+ "CREATE": 1,
+ "MOD": 2,
+ "VALUE": 3,
+}
+
+func (x Compare_CompareTarget) String() string {
+ return proto.EnumName(Compare_CompareTarget_name, int32(x))
+}
+func (Compare_CompareTarget) EnumDescriptor() ([]byte, []int) { return fileDescriptorRpc, []int{9, 1} }
+
+type WatchCreateRequest_FilterType int32
+
+const (
+ // filter out put event.
+ WatchCreateRequest_NOPUT WatchCreateRequest_FilterType = 0
+ // filter out delete event.
+ WatchCreateRequest_NODELETE WatchCreateRequest_FilterType = 1
+)
+
+var WatchCreateRequest_FilterType_name = map[int32]string{
+ 0: "NOPUT",
+ 1: "NODELETE",
+}
+var WatchCreateRequest_FilterType_value = map[string]int32{
+ "NOPUT": 0,
+ "NODELETE": 1,
+}
+
+func (x WatchCreateRequest_FilterType) String() string {
+ return proto.EnumName(WatchCreateRequest_FilterType_name, int32(x))
+}
+func (WatchCreateRequest_FilterType) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptorRpc, []int{19, 0}
+}
+
+type AlarmRequest_AlarmAction int32
+
+const (
+ AlarmRequest_GET AlarmRequest_AlarmAction = 0
+ AlarmRequest_ACTIVATE AlarmRequest_AlarmAction = 1
+ AlarmRequest_DEACTIVATE AlarmRequest_AlarmAction = 2
+)
+
+var AlarmRequest_AlarmAction_name = map[int32]string{
+ 0: "GET",
+ 1: "ACTIVATE",
+ 2: "DEACTIVATE",
+}
+var AlarmRequest_AlarmAction_value = map[string]int32{
+ "GET": 0,
+ "ACTIVATE": 1,
+ "DEACTIVATE": 2,
+}
+
+func (x AlarmRequest_AlarmAction) String() string {
+ return proto.EnumName(AlarmRequest_AlarmAction_name, int32(x))
+}
+func (AlarmRequest_AlarmAction) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptorRpc, []int{41, 0}
+}
+
+type ResponseHeader struct {
+ // cluster_id is the ID of the cluster which sent the response.
+ ClusterId uint64 `protobuf:"varint,1,opt,name=cluster_id,json=clusterId,proto3" json:"cluster_id,omitempty"`
+ // member_id is the ID of the member which sent the response.
+ MemberId uint64 `protobuf:"varint,2,opt,name=member_id,json=memberId,proto3" json:"member_id,omitempty"`
+ // revision is the key-value store revision when the request was applied.
+ Revision int64 `protobuf:"varint,3,opt,name=revision,proto3" json:"revision,omitempty"`
+ // raft_term is the raft term when the request was applied.
+ RaftTerm uint64 `protobuf:"varint,4,opt,name=raft_term,json=raftTerm,proto3" json:"raft_term,omitempty"`
+}
+
+func (m *ResponseHeader) Reset() { *m = ResponseHeader{} }
+func (m *ResponseHeader) String() string { return proto.CompactTextString(m) }
+func (*ResponseHeader) ProtoMessage() {}
+func (*ResponseHeader) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{0} }
+
+type RangeRequest struct {
+ // key is the first key for the range. If range_end is not given, the request only looks up key.
+ Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
+ // range_end is the upper bound on the requested range [key, range_end).
+ // If range_end is '\0', the range is all keys >= key.
+ // If range_end is key plus one (e.g., "aa"+1 == "ab", "a\xff"+1 == "b"),
+ // then the range request gets all keys prefixed with key.
+ // If both key and range_end are '\0', then the range request returns all keys.
+ RangeEnd []byte `protobuf:"bytes,2,opt,name=range_end,json=rangeEnd,proto3" json:"range_end,omitempty"`
+ // limit is a limit on the number of keys returned for the request. When limit is set to 0,
+ // it is treated as no limit.
+ Limit int64 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"`
+ // revision is the point-in-time of the key-value store to use for the range.
+ // If revision is less or equal to zero, the range is over the newest key-value store.
+ // If the revision has been compacted, ErrCompacted is returned as a response.
+ Revision int64 `protobuf:"varint,4,opt,name=revision,proto3" json:"revision,omitempty"`
+ // sort_order is the order for returned sorted results.
+ SortOrder RangeRequest_SortOrder `protobuf:"varint,5,opt,name=sort_order,json=sortOrder,proto3,enum=etcdserverpb.RangeRequest_SortOrder" json:"sort_order,omitempty"`
+ // sort_target is the key-value field to use for sorting.
+ SortTarget RangeRequest_SortTarget `protobuf:"varint,6,opt,name=sort_target,json=sortTarget,proto3,enum=etcdserverpb.RangeRequest_SortTarget" json:"sort_target,omitempty"`
+ // serializable sets the range request to use serializable member-local reads.
+ // Range requests are linearizable by default; linearizable requests have higher
+ // latency and lower throughput than serializable requests but reflect the current
+ // consensus of the cluster. For better performance, in exchange for possible stale reads,
+ // a serializable range request is served locally without needing to reach consensus
+ // with other nodes in the cluster.
+ Serializable bool `protobuf:"varint,7,opt,name=serializable,proto3" json:"serializable,omitempty"`
+ // keys_only when set returns only the keys and not the values.
+ KeysOnly bool `protobuf:"varint,8,opt,name=keys_only,json=keysOnly,proto3" json:"keys_only,omitempty"`
+ // count_only when set returns only the count of the keys in the range.
+ CountOnly bool `protobuf:"varint,9,opt,name=count_only,json=countOnly,proto3" json:"count_only,omitempty"`
+ // min_mod_revision is the lower bound for returned key mod revisions; all keys with
+ // lesser mod revisions will be filtered away.
+ MinModRevision int64 `protobuf:"varint,10,opt,name=min_mod_revision,json=minModRevision,proto3" json:"min_mod_revision,omitempty"`
+ // max_mod_revision is the upper bound for returned key mod revisions; all keys with
+ // greater mod revisions will be filtered away.
+ MaxModRevision int64 `protobuf:"varint,11,opt,name=max_mod_revision,json=maxModRevision,proto3" json:"max_mod_revision,omitempty"`
+ // min_create_revision is the lower bound for returned key create revisions; all keys with
+ // lesser create trevisions will be filtered away.
+ MinCreateRevision int64 `protobuf:"varint,12,opt,name=min_create_revision,json=minCreateRevision,proto3" json:"min_create_revision,omitempty"`
+ // max_create_revision is the upper bound for returned key create revisions; all keys with
+ // greater create revisions will be filtered away.
+ MaxCreateRevision int64 `protobuf:"varint,13,opt,name=max_create_revision,json=maxCreateRevision,proto3" json:"max_create_revision,omitempty"`
+}
+
+func (m *RangeRequest) Reset() { *m = RangeRequest{} }
+func (m *RangeRequest) String() string { return proto.CompactTextString(m) }
+func (*RangeRequest) ProtoMessage() {}
+func (*RangeRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{1} }
+
+type RangeResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // kvs is the list of key-value pairs matched by the range request.
+ // kvs is empty when count is requested.
+ Kvs []*mvccpb.KeyValue `protobuf:"bytes,2,rep,name=kvs" json:"kvs,omitempty"`
+ // more indicates if there are more keys to return in the requested range.
+ More bool `protobuf:"varint,3,opt,name=more,proto3" json:"more,omitempty"`
+ // count is set to the number of keys within the range when requested.
+ Count int64 `protobuf:"varint,4,opt,name=count,proto3" json:"count,omitempty"`
+}
+
+func (m *RangeResponse) Reset() { *m = RangeResponse{} }
+func (m *RangeResponse) String() string { return proto.CompactTextString(m) }
+func (*RangeResponse) ProtoMessage() {}
+func (*RangeResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{2} }
+
+func (m *RangeResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func (m *RangeResponse) GetKvs() []*mvccpb.KeyValue {
+ if m != nil {
+ return m.Kvs
+ }
+ return nil
+}
+
+type PutRequest struct {
+ // key is the key, in bytes, to put into the key-value store.
+ Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
+ // value is the value, in bytes, to associate with the key in the key-value store.
+ Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
+ // lease is the lease ID to associate with the key in the key-value store. A lease
+ // value of 0 indicates no lease.
+ Lease int64 `protobuf:"varint,3,opt,name=lease,proto3" json:"lease,omitempty"`
+ // If prev_kv is set, etcd gets the previous key-value pair before changing it.
+ // The previous key-value pair will be returned in the put response.
+ PrevKv bool `protobuf:"varint,4,opt,name=prev_kv,json=prevKv,proto3" json:"prev_kv,omitempty"`
+ // If ignore_value is set, etcd updates the key using its current value.
+ // Returns an error if the key does not exist.
+ IgnoreValue bool `protobuf:"varint,5,opt,name=ignore_value,json=ignoreValue,proto3" json:"ignore_value,omitempty"`
+ // If ignore_lease is set, etcd updates the key using its current lease.
+ // Returns an error if the key does not exist.
+ IgnoreLease bool `protobuf:"varint,6,opt,name=ignore_lease,json=ignoreLease,proto3" json:"ignore_lease,omitempty"`
+}
+
+func (m *PutRequest) Reset() { *m = PutRequest{} }
+func (m *PutRequest) String() string { return proto.CompactTextString(m) }
+func (*PutRequest) ProtoMessage() {}
+func (*PutRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{3} }
+
+type PutResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // if prev_kv is set in the request, the previous key-value pair will be returned.
+ PrevKv *mvccpb.KeyValue `protobuf:"bytes,2,opt,name=prev_kv,json=prevKv" json:"prev_kv,omitempty"`
+}
+
+func (m *PutResponse) Reset() { *m = PutResponse{} }
+func (m *PutResponse) String() string { return proto.CompactTextString(m) }
+func (*PutResponse) ProtoMessage() {}
+func (*PutResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{4} }
+
+func (m *PutResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func (m *PutResponse) GetPrevKv() *mvccpb.KeyValue {
+ if m != nil {
+ return m.PrevKv
+ }
+ return nil
+}
+
+type DeleteRangeRequest struct {
+ // key is the first key to delete in the range.
+ Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
+ // range_end is the key following the last key to delete for the range [key, range_end).
+ // If range_end is not given, the range is defined to contain only the key argument.
+ // If range_end is one bit larger than the given key, then the range is all the keys
+ // with the prefix (the given key).
+ // If range_end is '\0', the range is all keys greater than or equal to the key argument.
+ RangeEnd []byte `protobuf:"bytes,2,opt,name=range_end,json=rangeEnd,proto3" json:"range_end,omitempty"`
+ // If prev_kv is set, etcd gets the previous key-value pairs before deleting it.
+ // The previous key-value pairs will be returned in the delete response.
+ PrevKv bool `protobuf:"varint,3,opt,name=prev_kv,json=prevKv,proto3" json:"prev_kv,omitempty"`
+}
+
+func (m *DeleteRangeRequest) Reset() { *m = DeleteRangeRequest{} }
+func (m *DeleteRangeRequest) String() string { return proto.CompactTextString(m) }
+func (*DeleteRangeRequest) ProtoMessage() {}
+func (*DeleteRangeRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{5} }
+
+type DeleteRangeResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // deleted is the number of keys deleted by the delete range request.
+ Deleted int64 `protobuf:"varint,2,opt,name=deleted,proto3" json:"deleted,omitempty"`
+ // if prev_kv is set in the request, the previous key-value pairs will be returned.
+ PrevKvs []*mvccpb.KeyValue `protobuf:"bytes,3,rep,name=prev_kvs,json=prevKvs" json:"prev_kvs,omitempty"`
+}
+
+func (m *DeleteRangeResponse) Reset() { *m = DeleteRangeResponse{} }
+func (m *DeleteRangeResponse) String() string { return proto.CompactTextString(m) }
+func (*DeleteRangeResponse) ProtoMessage() {}
+func (*DeleteRangeResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{6} }
+
+func (m *DeleteRangeResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func (m *DeleteRangeResponse) GetPrevKvs() []*mvccpb.KeyValue {
+ if m != nil {
+ return m.PrevKvs
+ }
+ return nil
+}
+
+type RequestOp struct {
+ // request is a union of request types accepted by a transaction.
+ //
+ // Types that are valid to be assigned to Request:
+ // *RequestOp_RequestRange
+ // *RequestOp_RequestPut
+ // *RequestOp_RequestDeleteRange
+ Request isRequestOp_Request `protobuf_oneof:"request"`
+}
+
+func (m *RequestOp) Reset() { *m = RequestOp{} }
+func (m *RequestOp) String() string { return proto.CompactTextString(m) }
+func (*RequestOp) ProtoMessage() {}
+func (*RequestOp) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{7} }
+
+type isRequestOp_Request interface {
+ isRequestOp_Request()
+ MarshalTo([]byte) (int, error)
+ Size() int
+}
+
+type RequestOp_RequestRange struct {
+ RequestRange *RangeRequest `protobuf:"bytes,1,opt,name=request_range,json=requestRange,oneof"`
+}
+type RequestOp_RequestPut struct {
+ RequestPut *PutRequest `protobuf:"bytes,2,opt,name=request_put,json=requestPut,oneof"`
+}
+type RequestOp_RequestDeleteRange struct {
+ RequestDeleteRange *DeleteRangeRequest `protobuf:"bytes,3,opt,name=request_delete_range,json=requestDeleteRange,oneof"`
+}
+
+func (*RequestOp_RequestRange) isRequestOp_Request() {}
+func (*RequestOp_RequestPut) isRequestOp_Request() {}
+func (*RequestOp_RequestDeleteRange) isRequestOp_Request() {}
+
+func (m *RequestOp) GetRequest() isRequestOp_Request {
+ if m != nil {
+ return m.Request
+ }
+ return nil
+}
+
+func (m *RequestOp) GetRequestRange() *RangeRequest {
+ if x, ok := m.GetRequest().(*RequestOp_RequestRange); ok {
+ return x.RequestRange
+ }
+ return nil
+}
+
+func (m *RequestOp) GetRequestPut() *PutRequest {
+ if x, ok := m.GetRequest().(*RequestOp_RequestPut); ok {
+ return x.RequestPut
+ }
+ return nil
+}
+
+func (m *RequestOp) GetRequestDeleteRange() *DeleteRangeRequest {
+ if x, ok := m.GetRequest().(*RequestOp_RequestDeleteRange); ok {
+ return x.RequestDeleteRange
+ }
+ return nil
+}
+
+// XXX_OneofFuncs is for the internal use of the proto package.
+func (*RequestOp) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
+ return _RequestOp_OneofMarshaler, _RequestOp_OneofUnmarshaler, _RequestOp_OneofSizer, []interface{}{
+ (*RequestOp_RequestRange)(nil),
+ (*RequestOp_RequestPut)(nil),
+ (*RequestOp_RequestDeleteRange)(nil),
+ }
+}
+
+func _RequestOp_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
+ m := msg.(*RequestOp)
+ // request
+ switch x := m.Request.(type) {
+ case *RequestOp_RequestRange:
+ _ = b.EncodeVarint(1<<3 | proto.WireBytes)
+ if err := b.EncodeMessage(x.RequestRange); err != nil {
+ return err
+ }
+ case *RequestOp_RequestPut:
+ _ = b.EncodeVarint(2<<3 | proto.WireBytes)
+ if err := b.EncodeMessage(x.RequestPut); err != nil {
+ return err
+ }
+ case *RequestOp_RequestDeleteRange:
+ _ = b.EncodeVarint(3<<3 | proto.WireBytes)
+ if err := b.EncodeMessage(x.RequestDeleteRange); err != nil {
+ return err
+ }
+ case nil:
+ default:
+ return fmt.Errorf("RequestOp.Request has unexpected type %T", x)
+ }
+ return nil
+}
+
+func _RequestOp_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
+ m := msg.(*RequestOp)
+ switch tag {
+ case 1: // request.request_range
+ if wire != proto.WireBytes {
+ return true, proto.ErrInternalBadWireType
+ }
+ msg := new(RangeRequest)
+ err := b.DecodeMessage(msg)
+ m.Request = &RequestOp_RequestRange{msg}
+ return true, err
+ case 2: // request.request_put
+ if wire != proto.WireBytes {
+ return true, proto.ErrInternalBadWireType
+ }
+ msg := new(PutRequest)
+ err := b.DecodeMessage(msg)
+ m.Request = &RequestOp_RequestPut{msg}
+ return true, err
+ case 3: // request.request_delete_range
+ if wire != proto.WireBytes {
+ return true, proto.ErrInternalBadWireType
+ }
+ msg := new(DeleteRangeRequest)
+ err := b.DecodeMessage(msg)
+ m.Request = &RequestOp_RequestDeleteRange{msg}
+ return true, err
+ default:
+ return false, nil
+ }
+}
+
+func _RequestOp_OneofSizer(msg proto.Message) (n int) {
+ m := msg.(*RequestOp)
+ // request
+ switch x := m.Request.(type) {
+ case *RequestOp_RequestRange:
+ s := proto.Size(x.RequestRange)
+ n += proto.SizeVarint(1<<3 | proto.WireBytes)
+ n += proto.SizeVarint(uint64(s))
+ n += s
+ case *RequestOp_RequestPut:
+ s := proto.Size(x.RequestPut)
+ n += proto.SizeVarint(2<<3 | proto.WireBytes)
+ n += proto.SizeVarint(uint64(s))
+ n += s
+ case *RequestOp_RequestDeleteRange:
+ s := proto.Size(x.RequestDeleteRange)
+ n += proto.SizeVarint(3<<3 | proto.WireBytes)
+ n += proto.SizeVarint(uint64(s))
+ n += s
+ case nil:
+ default:
+ panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
+ }
+ return n
+}
+
+type ResponseOp struct {
+ // response is a union of response types returned by a transaction.
+ //
+ // Types that are valid to be assigned to Response:
+ // *ResponseOp_ResponseRange
+ // *ResponseOp_ResponsePut
+ // *ResponseOp_ResponseDeleteRange
+ Response isResponseOp_Response `protobuf_oneof:"response"`
+}
+
+func (m *ResponseOp) Reset() { *m = ResponseOp{} }
+func (m *ResponseOp) String() string { return proto.CompactTextString(m) }
+func (*ResponseOp) ProtoMessage() {}
+func (*ResponseOp) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{8} }
+
+type isResponseOp_Response interface {
+ isResponseOp_Response()
+ MarshalTo([]byte) (int, error)
+ Size() int
+}
+
+type ResponseOp_ResponseRange struct {
+ ResponseRange *RangeResponse `protobuf:"bytes,1,opt,name=response_range,json=responseRange,oneof"`
+}
+type ResponseOp_ResponsePut struct {
+ ResponsePut *PutResponse `protobuf:"bytes,2,opt,name=response_put,json=responsePut,oneof"`
+}
+type ResponseOp_ResponseDeleteRange struct {
+ ResponseDeleteRange *DeleteRangeResponse `protobuf:"bytes,3,opt,name=response_delete_range,json=responseDeleteRange,oneof"`
+}
+
+func (*ResponseOp_ResponseRange) isResponseOp_Response() {}
+func (*ResponseOp_ResponsePut) isResponseOp_Response() {}
+func (*ResponseOp_ResponseDeleteRange) isResponseOp_Response() {}
+
+func (m *ResponseOp) GetResponse() isResponseOp_Response {
+ if m != nil {
+ return m.Response
+ }
+ return nil
+}
+
+func (m *ResponseOp) GetResponseRange() *RangeResponse {
+ if x, ok := m.GetResponse().(*ResponseOp_ResponseRange); ok {
+ return x.ResponseRange
+ }
+ return nil
+}
+
+func (m *ResponseOp) GetResponsePut() *PutResponse {
+ if x, ok := m.GetResponse().(*ResponseOp_ResponsePut); ok {
+ return x.ResponsePut
+ }
+ return nil
+}
+
+func (m *ResponseOp) GetResponseDeleteRange() *DeleteRangeResponse {
+ if x, ok := m.GetResponse().(*ResponseOp_ResponseDeleteRange); ok {
+ return x.ResponseDeleteRange
+ }
+ return nil
+}
+
+// XXX_OneofFuncs is for the internal use of the proto package.
+func (*ResponseOp) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
+ return _ResponseOp_OneofMarshaler, _ResponseOp_OneofUnmarshaler, _ResponseOp_OneofSizer, []interface{}{
+ (*ResponseOp_ResponseRange)(nil),
+ (*ResponseOp_ResponsePut)(nil),
+ (*ResponseOp_ResponseDeleteRange)(nil),
+ }
+}
+
+func _ResponseOp_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
+ m := msg.(*ResponseOp)
+ // response
+ switch x := m.Response.(type) {
+ case *ResponseOp_ResponseRange:
+ _ = b.EncodeVarint(1<<3 | proto.WireBytes)
+ if err := b.EncodeMessage(x.ResponseRange); err != nil {
+ return err
+ }
+ case *ResponseOp_ResponsePut:
+ _ = b.EncodeVarint(2<<3 | proto.WireBytes)
+ if err := b.EncodeMessage(x.ResponsePut); err != nil {
+ return err
+ }
+ case *ResponseOp_ResponseDeleteRange:
+ _ = b.EncodeVarint(3<<3 | proto.WireBytes)
+ if err := b.EncodeMessage(x.ResponseDeleteRange); err != nil {
+ return err
+ }
+ case nil:
+ default:
+ return fmt.Errorf("ResponseOp.Response has unexpected type %T", x)
+ }
+ return nil
+}
+
+func _ResponseOp_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
+ m := msg.(*ResponseOp)
+ switch tag {
+ case 1: // response.response_range
+ if wire != proto.WireBytes {
+ return true, proto.ErrInternalBadWireType
+ }
+ msg := new(RangeResponse)
+ err := b.DecodeMessage(msg)
+ m.Response = &ResponseOp_ResponseRange{msg}
+ return true, err
+ case 2: // response.response_put
+ if wire != proto.WireBytes {
+ return true, proto.ErrInternalBadWireType
+ }
+ msg := new(PutResponse)
+ err := b.DecodeMessage(msg)
+ m.Response = &ResponseOp_ResponsePut{msg}
+ return true, err
+ case 3: // response.response_delete_range
+ if wire != proto.WireBytes {
+ return true, proto.ErrInternalBadWireType
+ }
+ msg := new(DeleteRangeResponse)
+ err := b.DecodeMessage(msg)
+ m.Response = &ResponseOp_ResponseDeleteRange{msg}
+ return true, err
+ default:
+ return false, nil
+ }
+}
+
+func _ResponseOp_OneofSizer(msg proto.Message) (n int) {
+ m := msg.(*ResponseOp)
+ // response
+ switch x := m.Response.(type) {
+ case *ResponseOp_ResponseRange:
+ s := proto.Size(x.ResponseRange)
+ n += proto.SizeVarint(1<<3 | proto.WireBytes)
+ n += proto.SizeVarint(uint64(s))
+ n += s
+ case *ResponseOp_ResponsePut:
+ s := proto.Size(x.ResponsePut)
+ n += proto.SizeVarint(2<<3 | proto.WireBytes)
+ n += proto.SizeVarint(uint64(s))
+ n += s
+ case *ResponseOp_ResponseDeleteRange:
+ s := proto.Size(x.ResponseDeleteRange)
+ n += proto.SizeVarint(3<<3 | proto.WireBytes)
+ n += proto.SizeVarint(uint64(s))
+ n += s
+ case nil:
+ default:
+ panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
+ }
+ return n
+}
+
+type Compare struct {
+ // result is logical comparison operation for this comparison.
+ Result Compare_CompareResult `protobuf:"varint,1,opt,name=result,proto3,enum=etcdserverpb.Compare_CompareResult" json:"result,omitempty"`
+ // target is the key-value field to inspect for the comparison.
+ Target Compare_CompareTarget `protobuf:"varint,2,opt,name=target,proto3,enum=etcdserverpb.Compare_CompareTarget" json:"target,omitempty"`
+ // key is the subject key for the comparison operation.
+ Key []byte `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
+ // Types that are valid to be assigned to TargetUnion:
+ // *Compare_Version
+ // *Compare_CreateRevision
+ // *Compare_ModRevision
+ // *Compare_Value
+ TargetUnion isCompare_TargetUnion `protobuf_oneof:"target_union"`
+}
+
+func (m *Compare) Reset() { *m = Compare{} }
+func (m *Compare) String() string { return proto.CompactTextString(m) }
+func (*Compare) ProtoMessage() {}
+func (*Compare) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{9} }
+
+type isCompare_TargetUnion interface {
+ isCompare_TargetUnion()
+ MarshalTo([]byte) (int, error)
+ Size() int
+}
+
+type Compare_Version struct {
+ Version int64 `protobuf:"varint,4,opt,name=version,proto3,oneof"`
+}
+type Compare_CreateRevision struct {
+ CreateRevision int64 `protobuf:"varint,5,opt,name=create_revision,json=createRevision,proto3,oneof"`
+}
+type Compare_ModRevision struct {
+ ModRevision int64 `protobuf:"varint,6,opt,name=mod_revision,json=modRevision,proto3,oneof"`
+}
+type Compare_Value struct {
+ Value []byte `protobuf:"bytes,7,opt,name=value,proto3,oneof"`
+}
+
+func (*Compare_Version) isCompare_TargetUnion() {}
+func (*Compare_CreateRevision) isCompare_TargetUnion() {}
+func (*Compare_ModRevision) isCompare_TargetUnion() {}
+func (*Compare_Value) isCompare_TargetUnion() {}
+
+func (m *Compare) GetTargetUnion() isCompare_TargetUnion {
+ if m != nil {
+ return m.TargetUnion
+ }
+ return nil
+}
+
+func (m *Compare) GetVersion() int64 {
+ if x, ok := m.GetTargetUnion().(*Compare_Version); ok {
+ return x.Version
+ }
+ return 0
+}
+
+func (m *Compare) GetCreateRevision() int64 {
+ if x, ok := m.GetTargetUnion().(*Compare_CreateRevision); ok {
+ return x.CreateRevision
+ }
+ return 0
+}
+
+func (m *Compare) GetModRevision() int64 {
+ if x, ok := m.GetTargetUnion().(*Compare_ModRevision); ok {
+ return x.ModRevision
+ }
+ return 0
+}
+
+func (m *Compare) GetValue() []byte {
+ if x, ok := m.GetTargetUnion().(*Compare_Value); ok {
+ return x.Value
+ }
+ return nil
+}
+
+// XXX_OneofFuncs is for the internal use of the proto package.
+func (*Compare) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
+ return _Compare_OneofMarshaler, _Compare_OneofUnmarshaler, _Compare_OneofSizer, []interface{}{
+ (*Compare_Version)(nil),
+ (*Compare_CreateRevision)(nil),
+ (*Compare_ModRevision)(nil),
+ (*Compare_Value)(nil),
+ }
+}
+
+func _Compare_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
+ m := msg.(*Compare)
+ // target_union
+ switch x := m.TargetUnion.(type) {
+ case *Compare_Version:
+ _ = b.EncodeVarint(4<<3 | proto.WireVarint)
+ _ = b.EncodeVarint(uint64(x.Version))
+ case *Compare_CreateRevision:
+ _ = b.EncodeVarint(5<<3 | proto.WireVarint)
+ _ = b.EncodeVarint(uint64(x.CreateRevision))
+ case *Compare_ModRevision:
+ _ = b.EncodeVarint(6<<3 | proto.WireVarint)
+ _ = b.EncodeVarint(uint64(x.ModRevision))
+ case *Compare_Value:
+ _ = b.EncodeVarint(7<<3 | proto.WireBytes)
+ _ = b.EncodeRawBytes(x.Value)
+ case nil:
+ default:
+ return fmt.Errorf("Compare.TargetUnion has unexpected type %T", x)
+ }
+ return nil
+}
+
+func _Compare_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
+ m := msg.(*Compare)
+ switch tag {
+ case 4: // target_union.version
+ if wire != proto.WireVarint {
+ return true, proto.ErrInternalBadWireType
+ }
+ x, err := b.DecodeVarint()
+ m.TargetUnion = &Compare_Version{int64(x)}
+ return true, err
+ case 5: // target_union.create_revision
+ if wire != proto.WireVarint {
+ return true, proto.ErrInternalBadWireType
+ }
+ x, err := b.DecodeVarint()
+ m.TargetUnion = &Compare_CreateRevision{int64(x)}
+ return true, err
+ case 6: // target_union.mod_revision
+ if wire != proto.WireVarint {
+ return true, proto.ErrInternalBadWireType
+ }
+ x, err := b.DecodeVarint()
+ m.TargetUnion = &Compare_ModRevision{int64(x)}
+ return true, err
+ case 7: // target_union.value
+ if wire != proto.WireBytes {
+ return true, proto.ErrInternalBadWireType
+ }
+ x, err := b.DecodeRawBytes(true)
+ m.TargetUnion = &Compare_Value{x}
+ return true, err
+ default:
+ return false, nil
+ }
+}
+
+func _Compare_OneofSizer(msg proto.Message) (n int) {
+ m := msg.(*Compare)
+ // target_union
+ switch x := m.TargetUnion.(type) {
+ case *Compare_Version:
+ n += proto.SizeVarint(4<<3 | proto.WireVarint)
+ n += proto.SizeVarint(uint64(x.Version))
+ case *Compare_CreateRevision:
+ n += proto.SizeVarint(5<<3 | proto.WireVarint)
+ n += proto.SizeVarint(uint64(x.CreateRevision))
+ case *Compare_ModRevision:
+ n += proto.SizeVarint(6<<3 | proto.WireVarint)
+ n += proto.SizeVarint(uint64(x.ModRevision))
+ case *Compare_Value:
+ n += proto.SizeVarint(7<<3 | proto.WireBytes)
+ n += proto.SizeVarint(uint64(len(x.Value)))
+ n += len(x.Value)
+ case nil:
+ default:
+ panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
+ }
+ return n
+}
+
+// From google paxosdb paper:
+// Our implementation hinges around a powerful primitive which we call MultiOp. All other database
+// operations except for iteration are implemented as a single call to MultiOp. A MultiOp is applied atomically
+// and consists of three components:
+// 1. A list of tests called guard. Each test in guard checks a single entry in the database. It may check
+// for the absence or presence of a value, or compare with a given value. Two different tests in the guard
+// may apply to the same or different entries in the database. All tests in the guard are applied and
+// MultiOp returns the results. If all tests are true, MultiOp executes t op (see item 2 below), otherwise
+// it executes f op (see item 3 below).
+// 2. A list of database operations called t op. Each operation in the list is either an insert, delete, or
+// lookup operation, and applies to a single database entry. Two different operations in the list may apply
+// to the same or different entries in the database. These operations are executed
+// if guard evaluates to
+// true.
+// 3. A list of database operations called f op. Like t op, but executed if guard evaluates to false.
+type TxnRequest struct {
+ // compare is a list of predicates representing a conjunction of terms.
+ // If the comparisons succeed, then the success requests will be processed in order,
+ // and the response will contain their respective responses in order.
+ // If the comparisons fail, then the failure requests will be processed in order,
+ // and the response will contain their respective responses in order.
+ Compare []*Compare `protobuf:"bytes,1,rep,name=compare" json:"compare,omitempty"`
+ // success is a list of requests which will be applied when compare evaluates to true.
+ Success []*RequestOp `protobuf:"bytes,2,rep,name=success" json:"success,omitempty"`
+ // failure is a list of requests which will be applied when compare evaluates to false.
+ Failure []*RequestOp `protobuf:"bytes,3,rep,name=failure" json:"failure,omitempty"`
+}
+
+func (m *TxnRequest) Reset() { *m = TxnRequest{} }
+func (m *TxnRequest) String() string { return proto.CompactTextString(m) }
+func (*TxnRequest) ProtoMessage() {}
+func (*TxnRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{10} }
+
+func (m *TxnRequest) GetCompare() []*Compare {
+ if m != nil {
+ return m.Compare
+ }
+ return nil
+}
+
+func (m *TxnRequest) GetSuccess() []*RequestOp {
+ if m != nil {
+ return m.Success
+ }
+ return nil
+}
+
+func (m *TxnRequest) GetFailure() []*RequestOp {
+ if m != nil {
+ return m.Failure
+ }
+ return nil
+}
+
+type TxnResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // succeeded is set to true if the compare evaluated to true or false otherwise.
+ Succeeded bool `protobuf:"varint,2,opt,name=succeeded,proto3" json:"succeeded,omitempty"`
+ // responses is a list of responses corresponding to the results from applying
+ // success if succeeded is true or failure if succeeded is false.
+ Responses []*ResponseOp `protobuf:"bytes,3,rep,name=responses" json:"responses,omitempty"`
+}
+
+func (m *TxnResponse) Reset() { *m = TxnResponse{} }
+func (m *TxnResponse) String() string { return proto.CompactTextString(m) }
+func (*TxnResponse) ProtoMessage() {}
+func (*TxnResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{11} }
+
+func (m *TxnResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func (m *TxnResponse) GetResponses() []*ResponseOp {
+ if m != nil {
+ return m.Responses
+ }
+ return nil
+}
+
+// CompactionRequest compacts the key-value store up to a given revision. All superseded keys
+// with a revision less than the compaction revision will be removed.
+type CompactionRequest struct {
+ // revision is the key-value store revision for the compaction operation.
+ Revision int64 `protobuf:"varint,1,opt,name=revision,proto3" json:"revision,omitempty"`
+ // physical is set so the RPC will wait until the compaction is physically
+ // applied to the local database such that compacted entries are totally
+ // removed from the backend database.
+ Physical bool `protobuf:"varint,2,opt,name=physical,proto3" json:"physical,omitempty"`
+}
+
+func (m *CompactionRequest) Reset() { *m = CompactionRequest{} }
+func (m *CompactionRequest) String() string { return proto.CompactTextString(m) }
+func (*CompactionRequest) ProtoMessage() {}
+func (*CompactionRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{12} }
+
+type CompactionResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *CompactionResponse) Reset() { *m = CompactionResponse{} }
+func (m *CompactionResponse) String() string { return proto.CompactTextString(m) }
+func (*CompactionResponse) ProtoMessage() {}
+func (*CompactionResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{13} }
+
+func (m *CompactionResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type HashRequest struct {
+}
+
+func (m *HashRequest) Reset() { *m = HashRequest{} }
+func (m *HashRequest) String() string { return proto.CompactTextString(m) }
+func (*HashRequest) ProtoMessage() {}
+func (*HashRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{14} }
+
+type HashResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // hash is the hash value computed from the responding member's key-value store.
+ Hash uint32 `protobuf:"varint,2,opt,name=hash,proto3" json:"hash,omitempty"`
+}
+
+func (m *HashResponse) Reset() { *m = HashResponse{} }
+func (m *HashResponse) String() string { return proto.CompactTextString(m) }
+func (*HashResponse) ProtoMessage() {}
+func (*HashResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{15} }
+
+func (m *HashResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type SnapshotRequest struct {
+}
+
+func (m *SnapshotRequest) Reset() { *m = SnapshotRequest{} }
+func (m *SnapshotRequest) String() string { return proto.CompactTextString(m) }
+func (*SnapshotRequest) ProtoMessage() {}
+func (*SnapshotRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{16} }
+
+type SnapshotResponse struct {
+ // header has the current key-value store information. The first header in the snapshot
+ // stream indicates the point in time of the snapshot.
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // remaining_bytes is the number of blob bytes to be sent after this message
+ RemainingBytes uint64 `protobuf:"varint,2,opt,name=remaining_bytes,json=remainingBytes,proto3" json:"remaining_bytes,omitempty"`
+ // blob contains the next chunk of the snapshot in the snapshot stream.
+ Blob []byte `protobuf:"bytes,3,opt,name=blob,proto3" json:"blob,omitempty"`
+}
+
+func (m *SnapshotResponse) Reset() { *m = SnapshotResponse{} }
+func (m *SnapshotResponse) String() string { return proto.CompactTextString(m) }
+func (*SnapshotResponse) ProtoMessage() {}
+func (*SnapshotResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{17} }
+
+func (m *SnapshotResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type WatchRequest struct {
+ // request_union is a request to either create a new watcher or cancel an existing watcher.
+ //
+ // Types that are valid to be assigned to RequestUnion:
+ // *WatchRequest_CreateRequest
+ // *WatchRequest_CancelRequest
+ RequestUnion isWatchRequest_RequestUnion `protobuf_oneof:"request_union"`
+}
+
+func (m *WatchRequest) Reset() { *m = WatchRequest{} }
+func (m *WatchRequest) String() string { return proto.CompactTextString(m) }
+func (*WatchRequest) ProtoMessage() {}
+func (*WatchRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{18} }
+
+type isWatchRequest_RequestUnion interface {
+ isWatchRequest_RequestUnion()
+ MarshalTo([]byte) (int, error)
+ Size() int
+}
+
+type WatchRequest_CreateRequest struct {
+ CreateRequest *WatchCreateRequest `protobuf:"bytes,1,opt,name=create_request,json=createRequest,oneof"`
+}
+type WatchRequest_CancelRequest struct {
+ CancelRequest *WatchCancelRequest `protobuf:"bytes,2,opt,name=cancel_request,json=cancelRequest,oneof"`
+}
+
+func (*WatchRequest_CreateRequest) isWatchRequest_RequestUnion() {}
+func (*WatchRequest_CancelRequest) isWatchRequest_RequestUnion() {}
+
+func (m *WatchRequest) GetRequestUnion() isWatchRequest_RequestUnion {
+ if m != nil {
+ return m.RequestUnion
+ }
+ return nil
+}
+
+func (m *WatchRequest) GetCreateRequest() *WatchCreateRequest {
+ if x, ok := m.GetRequestUnion().(*WatchRequest_CreateRequest); ok {
+ return x.CreateRequest
+ }
+ return nil
+}
+
+func (m *WatchRequest) GetCancelRequest() *WatchCancelRequest {
+ if x, ok := m.GetRequestUnion().(*WatchRequest_CancelRequest); ok {
+ return x.CancelRequest
+ }
+ return nil
+}
+
+// XXX_OneofFuncs is for the internal use of the proto package.
+func (*WatchRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
+ return _WatchRequest_OneofMarshaler, _WatchRequest_OneofUnmarshaler, _WatchRequest_OneofSizer, []interface{}{
+ (*WatchRequest_CreateRequest)(nil),
+ (*WatchRequest_CancelRequest)(nil),
+ }
+}
+
+func _WatchRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
+ m := msg.(*WatchRequest)
+ // request_union
+ switch x := m.RequestUnion.(type) {
+ case *WatchRequest_CreateRequest:
+ _ = b.EncodeVarint(1<<3 | proto.WireBytes)
+ if err := b.EncodeMessage(x.CreateRequest); err != nil {
+ return err
+ }
+ case *WatchRequest_CancelRequest:
+ _ = b.EncodeVarint(2<<3 | proto.WireBytes)
+ if err := b.EncodeMessage(x.CancelRequest); err != nil {
+ return err
+ }
+ case nil:
+ default:
+ return fmt.Errorf("WatchRequest.RequestUnion has unexpected type %T", x)
+ }
+ return nil
+}
+
+func _WatchRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
+ m := msg.(*WatchRequest)
+ switch tag {
+ case 1: // request_union.create_request
+ if wire != proto.WireBytes {
+ return true, proto.ErrInternalBadWireType
+ }
+ msg := new(WatchCreateRequest)
+ err := b.DecodeMessage(msg)
+ m.RequestUnion = &WatchRequest_CreateRequest{msg}
+ return true, err
+ case 2: // request_union.cancel_request
+ if wire != proto.WireBytes {
+ return true, proto.ErrInternalBadWireType
+ }
+ msg := new(WatchCancelRequest)
+ err := b.DecodeMessage(msg)
+ m.RequestUnion = &WatchRequest_CancelRequest{msg}
+ return true, err
+ default:
+ return false, nil
+ }
+}
+
+func _WatchRequest_OneofSizer(msg proto.Message) (n int) {
+ m := msg.(*WatchRequest)
+ // request_union
+ switch x := m.RequestUnion.(type) {
+ case *WatchRequest_CreateRequest:
+ s := proto.Size(x.CreateRequest)
+ n += proto.SizeVarint(1<<3 | proto.WireBytes)
+ n += proto.SizeVarint(uint64(s))
+ n += s
+ case *WatchRequest_CancelRequest:
+ s := proto.Size(x.CancelRequest)
+ n += proto.SizeVarint(2<<3 | proto.WireBytes)
+ n += proto.SizeVarint(uint64(s))
+ n += s
+ case nil:
+ default:
+ panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
+ }
+ return n
+}
+
+type WatchCreateRequest struct {
+ // key is the key to register for watching.
+ Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
+ // range_end is the end of the range [key, range_end) to watch. If range_end is not given,
+ // only the key argument is watched. If range_end is equal to '\0', all keys greater than
+ // or equal to the key argument are watched.
+ // If the range_end is one bit larger than the given key,
+ // then all keys with the prefix (the given key) will be watched.
+ RangeEnd []byte `protobuf:"bytes,2,opt,name=range_end,json=rangeEnd,proto3" json:"range_end,omitempty"`
+ // start_revision is an optional revision to watch from (inclusive). No start_revision is "now".
+ StartRevision int64 `protobuf:"varint,3,opt,name=start_revision,json=startRevision,proto3" json:"start_revision,omitempty"`
+ // progress_notify is set so that the etcd server will periodically send a WatchResponse with
+ // no events to the new watcher if there are no recent events. It is useful when clients
+ // wish to recover a disconnected watcher starting from a recent known revision.
+ // The etcd server may decide how often it will send notifications based on current load.
+ ProgressNotify bool `protobuf:"varint,4,opt,name=progress_notify,json=progressNotify,proto3" json:"progress_notify,omitempty"`
+ // filters filter the events at server side before it sends back to the watcher.
+ Filters []WatchCreateRequest_FilterType `protobuf:"varint,5,rep,packed,name=filters,enum=etcdserverpb.WatchCreateRequest_FilterType" json:"filters,omitempty"`
+ // If prev_kv is set, created watcher gets the previous KV before the event happens.
+ // If the previous KV is already compacted, nothing will be returned.
+ PrevKv bool `protobuf:"varint,6,opt,name=prev_kv,json=prevKv,proto3" json:"prev_kv,omitempty"`
+}
+
+func (m *WatchCreateRequest) Reset() { *m = WatchCreateRequest{} }
+func (m *WatchCreateRequest) String() string { return proto.CompactTextString(m) }
+func (*WatchCreateRequest) ProtoMessage() {}
+func (*WatchCreateRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{19} }
+
+type WatchCancelRequest struct {
+ // watch_id is the watcher id to cancel so that no more events are transmitted.
+ WatchId int64 `protobuf:"varint,1,opt,name=watch_id,json=watchId,proto3" json:"watch_id,omitempty"`
+}
+
+func (m *WatchCancelRequest) Reset() { *m = WatchCancelRequest{} }
+func (m *WatchCancelRequest) String() string { return proto.CompactTextString(m) }
+func (*WatchCancelRequest) ProtoMessage() {}
+func (*WatchCancelRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{20} }
+
+type WatchResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // watch_id is the ID of the watcher that corresponds to the response.
+ WatchId int64 `protobuf:"varint,2,opt,name=watch_id,json=watchId,proto3" json:"watch_id,omitempty"`
+ // created is set to true if the response is for a create watch request.
+ // The client should record the watch_id and expect to receive events for
+ // the created watcher from the same stream.
+ // All events sent to the created watcher will attach with the same watch_id.
+ Created bool `protobuf:"varint,3,opt,name=created,proto3" json:"created,omitempty"`
+ // canceled is set to true if the response is for a cancel watch request.
+ // No further events will be sent to the canceled watcher.
+ Canceled bool `protobuf:"varint,4,opt,name=canceled,proto3" json:"canceled,omitempty"`
+ // compact_revision is set to the minimum index if a watcher tries to watch
+ // at a compacted index.
+ //
+ // This happens when creating a watcher at a compacted revision or the watcher cannot
+ // catch up with the progress of the key-value store.
+ //
+ // The client should treat the watcher as canceled and should not try to create any
+ // watcher with the same start_revision again.
+ CompactRevision int64 `protobuf:"varint,5,opt,name=compact_revision,json=compactRevision,proto3" json:"compact_revision,omitempty"`
+ // cancel_reason indicates the reason for canceling the watcher.
+ CancelReason string `protobuf:"bytes,6,opt,name=cancel_reason,json=cancelReason,proto3" json:"cancel_reason,omitempty"`
+ Events []*mvccpb.Event `protobuf:"bytes,11,rep,name=events" json:"events,omitempty"`
+}
+
+func (m *WatchResponse) Reset() { *m = WatchResponse{} }
+func (m *WatchResponse) String() string { return proto.CompactTextString(m) }
+func (*WatchResponse) ProtoMessage() {}
+func (*WatchResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{21} }
+
+func (m *WatchResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func (m *WatchResponse) GetEvents() []*mvccpb.Event {
+ if m != nil {
+ return m.Events
+ }
+ return nil
+}
+
+type LeaseGrantRequest struct {
+ // TTL is the advisory time-to-live in seconds.
+ TTL int64 `protobuf:"varint,1,opt,name=TTL,proto3" json:"TTL,omitempty"`
+ // ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID.
+ ID int64 `protobuf:"varint,2,opt,name=ID,proto3" json:"ID,omitempty"`
+}
+
+func (m *LeaseGrantRequest) Reset() { *m = LeaseGrantRequest{} }
+func (m *LeaseGrantRequest) String() string { return proto.CompactTextString(m) }
+func (*LeaseGrantRequest) ProtoMessage() {}
+func (*LeaseGrantRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{22} }
+
+type LeaseGrantResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // ID is the lease ID for the granted lease.
+ ID int64 `protobuf:"varint,2,opt,name=ID,proto3" json:"ID,omitempty"`
+ // TTL is the server chosen lease time-to-live in seconds.
+ TTL int64 `protobuf:"varint,3,opt,name=TTL,proto3" json:"TTL,omitempty"`
+ Error string `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"`
+}
+
+func (m *LeaseGrantResponse) Reset() { *m = LeaseGrantResponse{} }
+func (m *LeaseGrantResponse) String() string { return proto.CompactTextString(m) }
+func (*LeaseGrantResponse) ProtoMessage() {}
+func (*LeaseGrantResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{23} }
+
+func (m *LeaseGrantResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type LeaseRevokeRequest struct {
+ // ID is the lease ID to revoke. When the ID is revoked, all associated keys will be deleted.
+ ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
+}
+
+func (m *LeaseRevokeRequest) Reset() { *m = LeaseRevokeRequest{} }
+func (m *LeaseRevokeRequest) String() string { return proto.CompactTextString(m) }
+func (*LeaseRevokeRequest) ProtoMessage() {}
+func (*LeaseRevokeRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{24} }
+
+type LeaseRevokeResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *LeaseRevokeResponse) Reset() { *m = LeaseRevokeResponse{} }
+func (m *LeaseRevokeResponse) String() string { return proto.CompactTextString(m) }
+func (*LeaseRevokeResponse) ProtoMessage() {}
+func (*LeaseRevokeResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{25} }
+
+func (m *LeaseRevokeResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type LeaseKeepAliveRequest struct {
+ // ID is the lease ID for the lease to keep alive.
+ ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
+}
+
+func (m *LeaseKeepAliveRequest) Reset() { *m = LeaseKeepAliveRequest{} }
+func (m *LeaseKeepAliveRequest) String() string { return proto.CompactTextString(m) }
+func (*LeaseKeepAliveRequest) ProtoMessage() {}
+func (*LeaseKeepAliveRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{26} }
+
+type LeaseKeepAliveResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // ID is the lease ID from the keep alive request.
+ ID int64 `protobuf:"varint,2,opt,name=ID,proto3" json:"ID,omitempty"`
+ // TTL is the new time-to-live for the lease.
+ TTL int64 `protobuf:"varint,3,opt,name=TTL,proto3" json:"TTL,omitempty"`
+}
+
+func (m *LeaseKeepAliveResponse) Reset() { *m = LeaseKeepAliveResponse{} }
+func (m *LeaseKeepAliveResponse) String() string { return proto.CompactTextString(m) }
+func (*LeaseKeepAliveResponse) ProtoMessage() {}
+func (*LeaseKeepAliveResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{27} }
+
+func (m *LeaseKeepAliveResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type LeaseTimeToLiveRequest struct {
+ // ID is the lease ID for the lease.
+ ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
+ // keys is true to query all the keys attached to this lease.
+ Keys bool `protobuf:"varint,2,opt,name=keys,proto3" json:"keys,omitempty"`
+}
+
+func (m *LeaseTimeToLiveRequest) Reset() { *m = LeaseTimeToLiveRequest{} }
+func (m *LeaseTimeToLiveRequest) String() string { return proto.CompactTextString(m) }
+func (*LeaseTimeToLiveRequest) ProtoMessage() {}
+func (*LeaseTimeToLiveRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{28} }
+
+type LeaseTimeToLiveResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // ID is the lease ID from the keep alive request.
+ ID int64 `protobuf:"varint,2,opt,name=ID,proto3" json:"ID,omitempty"`
+ // TTL is the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds.
+ TTL int64 `protobuf:"varint,3,opt,name=TTL,proto3" json:"TTL,omitempty"`
+ // GrantedTTL is the initial granted time in seconds upon lease creation/renewal.
+ GrantedTTL int64 `protobuf:"varint,4,opt,name=grantedTTL,proto3" json:"grantedTTL,omitempty"`
+ // Keys is the list of keys attached to this lease.
+ Keys [][]byte `protobuf:"bytes,5,rep,name=keys" json:"keys,omitempty"`
+}
+
+func (m *LeaseTimeToLiveResponse) Reset() { *m = LeaseTimeToLiveResponse{} }
+func (m *LeaseTimeToLiveResponse) String() string { return proto.CompactTextString(m) }
+func (*LeaseTimeToLiveResponse) ProtoMessage() {}
+func (*LeaseTimeToLiveResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{29} }
+
+func (m *LeaseTimeToLiveResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type Member struct {
+ // ID is the member ID for this member.
+ ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
+ // name is the human-readable name of the member. If the member is not started, the name will be an empty string.
+ Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
+ // peerURLs is the list of URLs the member exposes to the cluster for communication.
+ PeerURLs []string `protobuf:"bytes,3,rep,name=peerURLs" json:"peerURLs,omitempty"`
+ // clientURLs is the list of URLs the member exposes to clients for communication. If the member is not started, clientURLs will be empty.
+ ClientURLs []string `protobuf:"bytes,4,rep,name=clientURLs" json:"clientURLs,omitempty"`
+}
+
+func (m *Member) Reset() { *m = Member{} }
+func (m *Member) String() string { return proto.CompactTextString(m) }
+func (*Member) ProtoMessage() {}
+func (*Member) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{30} }
+
+type MemberAddRequest struct {
+ // peerURLs is the list of URLs the added member will use to communicate with the cluster.
+ PeerURLs []string `protobuf:"bytes,1,rep,name=peerURLs" json:"peerURLs,omitempty"`
+}
+
+func (m *MemberAddRequest) Reset() { *m = MemberAddRequest{} }
+func (m *MemberAddRequest) String() string { return proto.CompactTextString(m) }
+func (*MemberAddRequest) ProtoMessage() {}
+func (*MemberAddRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{31} }
+
+type MemberAddResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // member is the member information for the added member.
+ Member *Member `protobuf:"bytes,2,opt,name=member" json:"member,omitempty"`
+ // members is a list of all members after adding the new member.
+ Members []*Member `protobuf:"bytes,3,rep,name=members" json:"members,omitempty"`
+}
+
+func (m *MemberAddResponse) Reset() { *m = MemberAddResponse{} }
+func (m *MemberAddResponse) String() string { return proto.CompactTextString(m) }
+func (*MemberAddResponse) ProtoMessage() {}
+func (*MemberAddResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{32} }
+
+func (m *MemberAddResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func (m *MemberAddResponse) GetMember() *Member {
+ if m != nil {
+ return m.Member
+ }
+ return nil
+}
+
+func (m *MemberAddResponse) GetMembers() []*Member {
+ if m != nil {
+ return m.Members
+ }
+ return nil
+}
+
+type MemberRemoveRequest struct {
+ // ID is the member ID of the member to remove.
+ ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
+}
+
+func (m *MemberRemoveRequest) Reset() { *m = MemberRemoveRequest{} }
+func (m *MemberRemoveRequest) String() string { return proto.CompactTextString(m) }
+func (*MemberRemoveRequest) ProtoMessage() {}
+func (*MemberRemoveRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{33} }
+
+type MemberRemoveResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // members is a list of all members after removing the member.
+ Members []*Member `protobuf:"bytes,2,rep,name=members" json:"members,omitempty"`
+}
+
+func (m *MemberRemoveResponse) Reset() { *m = MemberRemoveResponse{} }
+func (m *MemberRemoveResponse) String() string { return proto.CompactTextString(m) }
+func (*MemberRemoveResponse) ProtoMessage() {}
+func (*MemberRemoveResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{34} }
+
+func (m *MemberRemoveResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func (m *MemberRemoveResponse) GetMembers() []*Member {
+ if m != nil {
+ return m.Members
+ }
+ return nil
+}
+
+type MemberUpdateRequest struct {
+ // ID is the member ID of the member to update.
+ ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
+ // peerURLs is the new list of URLs the member will use to communicate with the cluster.
+ PeerURLs []string `protobuf:"bytes,2,rep,name=peerURLs" json:"peerURLs,omitempty"`
+}
+
+func (m *MemberUpdateRequest) Reset() { *m = MemberUpdateRequest{} }
+func (m *MemberUpdateRequest) String() string { return proto.CompactTextString(m) }
+func (*MemberUpdateRequest) ProtoMessage() {}
+func (*MemberUpdateRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{35} }
+
+type MemberUpdateResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // members is a list of all members after updating the member.
+ Members []*Member `protobuf:"bytes,2,rep,name=members" json:"members,omitempty"`
+}
+
+func (m *MemberUpdateResponse) Reset() { *m = MemberUpdateResponse{} }
+func (m *MemberUpdateResponse) String() string { return proto.CompactTextString(m) }
+func (*MemberUpdateResponse) ProtoMessage() {}
+func (*MemberUpdateResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{36} }
+
+func (m *MemberUpdateResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func (m *MemberUpdateResponse) GetMembers() []*Member {
+ if m != nil {
+ return m.Members
+ }
+ return nil
+}
+
+type MemberListRequest struct {
+}
+
+func (m *MemberListRequest) Reset() { *m = MemberListRequest{} }
+func (m *MemberListRequest) String() string { return proto.CompactTextString(m) }
+func (*MemberListRequest) ProtoMessage() {}
+func (*MemberListRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{37} }
+
+type MemberListResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // members is a list of all members associated with the cluster.
+ Members []*Member `protobuf:"bytes,2,rep,name=members" json:"members,omitempty"`
+}
+
+func (m *MemberListResponse) Reset() { *m = MemberListResponse{} }
+func (m *MemberListResponse) String() string { return proto.CompactTextString(m) }
+func (*MemberListResponse) ProtoMessage() {}
+func (*MemberListResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{38} }
+
+func (m *MemberListResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func (m *MemberListResponse) GetMembers() []*Member {
+ if m != nil {
+ return m.Members
+ }
+ return nil
+}
+
+type DefragmentRequest struct {
+}
+
+func (m *DefragmentRequest) Reset() { *m = DefragmentRequest{} }
+func (m *DefragmentRequest) String() string { return proto.CompactTextString(m) }
+func (*DefragmentRequest) ProtoMessage() {}
+func (*DefragmentRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{39} }
+
+type DefragmentResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *DefragmentResponse) Reset() { *m = DefragmentResponse{} }
+func (m *DefragmentResponse) String() string { return proto.CompactTextString(m) }
+func (*DefragmentResponse) ProtoMessage() {}
+func (*DefragmentResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{40} }
+
+func (m *DefragmentResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AlarmRequest struct {
+ // action is the kind of alarm request to issue. The action
+ // may GET alarm statuses, ACTIVATE an alarm, or DEACTIVATE a
+ // raised alarm.
+ Action AlarmRequest_AlarmAction `protobuf:"varint,1,opt,name=action,proto3,enum=etcdserverpb.AlarmRequest_AlarmAction" json:"action,omitempty"`
+ // memberID is the ID of the member associated with the alarm. If memberID is 0, the
+ // alarm request covers all members.
+ MemberID uint64 `protobuf:"varint,2,opt,name=memberID,proto3" json:"memberID,omitempty"`
+ // alarm is the type of alarm to consider for this request.
+ Alarm AlarmType `protobuf:"varint,3,opt,name=alarm,proto3,enum=etcdserverpb.AlarmType" json:"alarm,omitempty"`
+}
+
+func (m *AlarmRequest) Reset() { *m = AlarmRequest{} }
+func (m *AlarmRequest) String() string { return proto.CompactTextString(m) }
+func (*AlarmRequest) ProtoMessage() {}
+func (*AlarmRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{41} }
+
+type AlarmMember struct {
+ // memberID is the ID of the member associated with the raised alarm.
+ MemberID uint64 `protobuf:"varint,1,opt,name=memberID,proto3" json:"memberID,omitempty"`
+ // alarm is the type of alarm which has been raised.
+ Alarm AlarmType `protobuf:"varint,2,opt,name=alarm,proto3,enum=etcdserverpb.AlarmType" json:"alarm,omitempty"`
+}
+
+func (m *AlarmMember) Reset() { *m = AlarmMember{} }
+func (m *AlarmMember) String() string { return proto.CompactTextString(m) }
+func (*AlarmMember) ProtoMessage() {}
+func (*AlarmMember) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{42} }
+
+type AlarmResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // alarms is a list of alarms associated with the alarm request.
+ Alarms []*AlarmMember `protobuf:"bytes,2,rep,name=alarms" json:"alarms,omitempty"`
+}
+
+func (m *AlarmResponse) Reset() { *m = AlarmResponse{} }
+func (m *AlarmResponse) String() string { return proto.CompactTextString(m) }
+func (*AlarmResponse) ProtoMessage() {}
+func (*AlarmResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{43} }
+
+func (m *AlarmResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func (m *AlarmResponse) GetAlarms() []*AlarmMember {
+ if m != nil {
+ return m.Alarms
+ }
+ return nil
+}
+
+type StatusRequest struct {
+}
+
+func (m *StatusRequest) Reset() { *m = StatusRequest{} }
+func (m *StatusRequest) String() string { return proto.CompactTextString(m) }
+func (*StatusRequest) ProtoMessage() {}
+func (*StatusRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{44} }
+
+type StatusResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // version is the cluster protocol version used by the responding member.
+ Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
+ // dbSize is the size of the backend database, in bytes, of the responding member.
+ DbSize int64 `protobuf:"varint,3,opt,name=dbSize,proto3" json:"dbSize,omitempty"`
+ // leader is the member ID which the responding member believes is the current leader.
+ Leader uint64 `protobuf:"varint,4,opt,name=leader,proto3" json:"leader,omitempty"`
+ // raftIndex is the current raft index of the responding member.
+ RaftIndex uint64 `protobuf:"varint,5,opt,name=raftIndex,proto3" json:"raftIndex,omitempty"`
+ // raftTerm is the current raft term of the responding member.
+ RaftTerm uint64 `protobuf:"varint,6,opt,name=raftTerm,proto3" json:"raftTerm,omitempty"`
+}
+
+func (m *StatusResponse) Reset() { *m = StatusResponse{} }
+func (m *StatusResponse) String() string { return proto.CompactTextString(m) }
+func (*StatusResponse) ProtoMessage() {}
+func (*StatusResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{45} }
+
+func (m *StatusResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthEnableRequest struct {
+}
+
+func (m *AuthEnableRequest) Reset() { *m = AuthEnableRequest{} }
+func (m *AuthEnableRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthEnableRequest) ProtoMessage() {}
+func (*AuthEnableRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{46} }
+
+type AuthDisableRequest struct {
+}
+
+func (m *AuthDisableRequest) Reset() { *m = AuthDisableRequest{} }
+func (m *AuthDisableRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthDisableRequest) ProtoMessage() {}
+func (*AuthDisableRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{47} }
+
+type AuthenticateRequest struct {
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
+}
+
+func (m *AuthenticateRequest) Reset() { *m = AuthenticateRequest{} }
+func (m *AuthenticateRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthenticateRequest) ProtoMessage() {}
+func (*AuthenticateRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{48} }
+
+type AuthUserAddRequest struct {
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
+}
+
+func (m *AuthUserAddRequest) Reset() { *m = AuthUserAddRequest{} }
+func (m *AuthUserAddRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthUserAddRequest) ProtoMessage() {}
+func (*AuthUserAddRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{49} }
+
+type AuthUserGetRequest struct {
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+}
+
+func (m *AuthUserGetRequest) Reset() { *m = AuthUserGetRequest{} }
+func (m *AuthUserGetRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthUserGetRequest) ProtoMessage() {}
+func (*AuthUserGetRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{50} }
+
+type AuthUserDeleteRequest struct {
+ // name is the name of the user to delete.
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+}
+
+func (m *AuthUserDeleteRequest) Reset() { *m = AuthUserDeleteRequest{} }
+func (m *AuthUserDeleteRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthUserDeleteRequest) ProtoMessage() {}
+func (*AuthUserDeleteRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{51} }
+
+type AuthUserChangePasswordRequest struct {
+ // name is the name of the user whose password is being changed.
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ // password is the new password for the user.
+ Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
+}
+
+func (m *AuthUserChangePasswordRequest) Reset() { *m = AuthUserChangePasswordRequest{} }
+func (m *AuthUserChangePasswordRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthUserChangePasswordRequest) ProtoMessage() {}
+func (*AuthUserChangePasswordRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptorRpc, []int{52}
+}
+
+type AuthUserGrantRoleRequest struct {
+ // user is the name of the user which should be granted a given role.
+ User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
+ // role is the name of the role to grant to the user.
+ Role string `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"`
+}
+
+func (m *AuthUserGrantRoleRequest) Reset() { *m = AuthUserGrantRoleRequest{} }
+func (m *AuthUserGrantRoleRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthUserGrantRoleRequest) ProtoMessage() {}
+func (*AuthUserGrantRoleRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{53} }
+
+type AuthUserRevokeRoleRequest struct {
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ Role string `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"`
+}
+
+func (m *AuthUserRevokeRoleRequest) Reset() { *m = AuthUserRevokeRoleRequest{} }
+func (m *AuthUserRevokeRoleRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthUserRevokeRoleRequest) ProtoMessage() {}
+func (*AuthUserRevokeRoleRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{54} }
+
+type AuthRoleAddRequest struct {
+ // name is the name of the role to add to the authentication system.
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+}
+
+func (m *AuthRoleAddRequest) Reset() { *m = AuthRoleAddRequest{} }
+func (m *AuthRoleAddRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthRoleAddRequest) ProtoMessage() {}
+func (*AuthRoleAddRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{55} }
+
+type AuthRoleGetRequest struct {
+ Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
+}
+
+func (m *AuthRoleGetRequest) Reset() { *m = AuthRoleGetRequest{} }
+func (m *AuthRoleGetRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthRoleGetRequest) ProtoMessage() {}
+func (*AuthRoleGetRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{56} }
+
+type AuthUserListRequest struct {
+}
+
+func (m *AuthUserListRequest) Reset() { *m = AuthUserListRequest{} }
+func (m *AuthUserListRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthUserListRequest) ProtoMessage() {}
+func (*AuthUserListRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{57} }
+
+type AuthRoleListRequest struct {
+}
+
+func (m *AuthRoleListRequest) Reset() { *m = AuthRoleListRequest{} }
+func (m *AuthRoleListRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthRoleListRequest) ProtoMessage() {}
+func (*AuthRoleListRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{58} }
+
+type AuthRoleDeleteRequest struct {
+ Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
+}
+
+func (m *AuthRoleDeleteRequest) Reset() { *m = AuthRoleDeleteRequest{} }
+func (m *AuthRoleDeleteRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthRoleDeleteRequest) ProtoMessage() {}
+func (*AuthRoleDeleteRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{59} }
+
+type AuthRoleGrantPermissionRequest struct {
+ // name is the name of the role which will be granted the permission.
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ // perm is the permission to grant to the role.
+ Perm *authpb.Permission `protobuf:"bytes,2,opt,name=perm" json:"perm,omitempty"`
+}
+
+func (m *AuthRoleGrantPermissionRequest) Reset() { *m = AuthRoleGrantPermissionRequest{} }
+func (m *AuthRoleGrantPermissionRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthRoleGrantPermissionRequest) ProtoMessage() {}
+func (*AuthRoleGrantPermissionRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptorRpc, []int{60}
+}
+
+func (m *AuthRoleGrantPermissionRequest) GetPerm() *authpb.Permission {
+ if m != nil {
+ return m.Perm
+ }
+ return nil
+}
+
+type AuthRoleRevokePermissionRequest struct {
+ Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
+ Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
+ RangeEnd string `protobuf:"bytes,3,opt,name=range_end,json=rangeEnd,proto3" json:"range_end,omitempty"`
+}
+
+func (m *AuthRoleRevokePermissionRequest) Reset() { *m = AuthRoleRevokePermissionRequest{} }
+func (m *AuthRoleRevokePermissionRequest) String() string { return proto.CompactTextString(m) }
+func (*AuthRoleRevokePermissionRequest) ProtoMessage() {}
+func (*AuthRoleRevokePermissionRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptorRpc, []int{61}
+}
+
+type AuthEnableResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *AuthEnableResponse) Reset() { *m = AuthEnableResponse{} }
+func (m *AuthEnableResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthEnableResponse) ProtoMessage() {}
+func (*AuthEnableResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{62} }
+
+func (m *AuthEnableResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthDisableResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *AuthDisableResponse) Reset() { *m = AuthDisableResponse{} }
+func (m *AuthDisableResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthDisableResponse) ProtoMessage() {}
+func (*AuthDisableResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{63} }
+
+func (m *AuthDisableResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthenticateResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ // token is an authorized token that can be used in succeeding RPCs
+ Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
+}
+
+func (m *AuthenticateResponse) Reset() { *m = AuthenticateResponse{} }
+func (m *AuthenticateResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthenticateResponse) ProtoMessage() {}
+func (*AuthenticateResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{64} }
+
+func (m *AuthenticateResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthUserAddResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *AuthUserAddResponse) Reset() { *m = AuthUserAddResponse{} }
+func (m *AuthUserAddResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthUserAddResponse) ProtoMessage() {}
+func (*AuthUserAddResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{65} }
+
+func (m *AuthUserAddResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthUserGetResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ Roles []string `protobuf:"bytes,2,rep,name=roles" json:"roles,omitempty"`
+}
+
+func (m *AuthUserGetResponse) Reset() { *m = AuthUserGetResponse{} }
+func (m *AuthUserGetResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthUserGetResponse) ProtoMessage() {}
+func (*AuthUserGetResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{66} }
+
+func (m *AuthUserGetResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthUserDeleteResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *AuthUserDeleteResponse) Reset() { *m = AuthUserDeleteResponse{} }
+func (m *AuthUserDeleteResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthUserDeleteResponse) ProtoMessage() {}
+func (*AuthUserDeleteResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{67} }
+
+func (m *AuthUserDeleteResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthUserChangePasswordResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *AuthUserChangePasswordResponse) Reset() { *m = AuthUserChangePasswordResponse{} }
+func (m *AuthUserChangePasswordResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthUserChangePasswordResponse) ProtoMessage() {}
+func (*AuthUserChangePasswordResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptorRpc, []int{68}
+}
+
+func (m *AuthUserChangePasswordResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthUserGrantRoleResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *AuthUserGrantRoleResponse) Reset() { *m = AuthUserGrantRoleResponse{} }
+func (m *AuthUserGrantRoleResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthUserGrantRoleResponse) ProtoMessage() {}
+func (*AuthUserGrantRoleResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{69} }
+
+func (m *AuthUserGrantRoleResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthUserRevokeRoleResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *AuthUserRevokeRoleResponse) Reset() { *m = AuthUserRevokeRoleResponse{} }
+func (m *AuthUserRevokeRoleResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthUserRevokeRoleResponse) ProtoMessage() {}
+func (*AuthUserRevokeRoleResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{70} }
+
+func (m *AuthUserRevokeRoleResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthRoleAddResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *AuthRoleAddResponse) Reset() { *m = AuthRoleAddResponse{} }
+func (m *AuthRoleAddResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthRoleAddResponse) ProtoMessage() {}
+func (*AuthRoleAddResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{71} }
+
+func (m *AuthRoleAddResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthRoleGetResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ Perm []*authpb.Permission `protobuf:"bytes,2,rep,name=perm" json:"perm,omitempty"`
+}
+
+func (m *AuthRoleGetResponse) Reset() { *m = AuthRoleGetResponse{} }
+func (m *AuthRoleGetResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthRoleGetResponse) ProtoMessage() {}
+func (*AuthRoleGetResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{72} }
+
+func (m *AuthRoleGetResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func (m *AuthRoleGetResponse) GetPerm() []*authpb.Permission {
+ if m != nil {
+ return m.Perm
+ }
+ return nil
+}
+
+type AuthRoleListResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ Roles []string `protobuf:"bytes,2,rep,name=roles" json:"roles,omitempty"`
+}
+
+func (m *AuthRoleListResponse) Reset() { *m = AuthRoleListResponse{} }
+func (m *AuthRoleListResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthRoleListResponse) ProtoMessage() {}
+func (*AuthRoleListResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{73} }
+
+func (m *AuthRoleListResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthUserListResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+ Users []string `protobuf:"bytes,2,rep,name=users" json:"users,omitempty"`
+}
+
+func (m *AuthUserListResponse) Reset() { *m = AuthUserListResponse{} }
+func (m *AuthUserListResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthUserListResponse) ProtoMessage() {}
+func (*AuthUserListResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{74} }
+
+func (m *AuthUserListResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthRoleDeleteResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *AuthRoleDeleteResponse) Reset() { *m = AuthRoleDeleteResponse{} }
+func (m *AuthRoleDeleteResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthRoleDeleteResponse) ProtoMessage() {}
+func (*AuthRoleDeleteResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{75} }
+
+func (m *AuthRoleDeleteResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthRoleGrantPermissionResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *AuthRoleGrantPermissionResponse) Reset() { *m = AuthRoleGrantPermissionResponse{} }
+func (m *AuthRoleGrantPermissionResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthRoleGrantPermissionResponse) ProtoMessage() {}
+func (*AuthRoleGrantPermissionResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptorRpc, []int{76}
+}
+
+func (m *AuthRoleGrantPermissionResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+type AuthRoleRevokePermissionResponse struct {
+ Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
+}
+
+func (m *AuthRoleRevokePermissionResponse) Reset() { *m = AuthRoleRevokePermissionResponse{} }
+func (m *AuthRoleRevokePermissionResponse) String() string { return proto.CompactTextString(m) }
+func (*AuthRoleRevokePermissionResponse) ProtoMessage() {}
+func (*AuthRoleRevokePermissionResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptorRpc, []int{77}
+}
+
+func (m *AuthRoleRevokePermissionResponse) GetHeader() *ResponseHeader {
+ if m != nil {
+ return m.Header
+ }
+ return nil
+}
+
+func init() {
+ proto.RegisterType((*ResponseHeader)(nil), "etcdserverpb.ResponseHeader")
+ proto.RegisterType((*RangeRequest)(nil), "etcdserverpb.RangeRequest")
+ proto.RegisterType((*RangeResponse)(nil), "etcdserverpb.RangeResponse")
+ proto.RegisterType((*PutRequest)(nil), "etcdserverpb.PutRequest")
+ proto.RegisterType((*PutResponse)(nil), "etcdserverpb.PutResponse")
+ proto.RegisterType((*DeleteRangeRequest)(nil), "etcdserverpb.DeleteRangeRequest")
+ proto.RegisterType((*DeleteRangeResponse)(nil), "etcdserverpb.DeleteRangeResponse")
+ proto.RegisterType((*RequestOp)(nil), "etcdserverpb.RequestOp")
+ proto.RegisterType((*ResponseOp)(nil), "etcdserverpb.ResponseOp")
+ proto.RegisterType((*Compare)(nil), "etcdserverpb.Compare")
+ proto.RegisterType((*TxnRequest)(nil), "etcdserverpb.TxnRequest")
+ proto.RegisterType((*TxnResponse)(nil), "etcdserverpb.TxnResponse")
+ proto.RegisterType((*CompactionRequest)(nil), "etcdserverpb.CompactionRequest")
+ proto.RegisterType((*CompactionResponse)(nil), "etcdserverpb.CompactionResponse")
+ proto.RegisterType((*HashRequest)(nil), "etcdserverpb.HashRequest")
+ proto.RegisterType((*HashResponse)(nil), "etcdserverpb.HashResponse")
+ proto.RegisterType((*SnapshotRequest)(nil), "etcdserverpb.SnapshotRequest")
+ proto.RegisterType((*SnapshotResponse)(nil), "etcdserverpb.SnapshotResponse")
+ proto.RegisterType((*WatchRequest)(nil), "etcdserverpb.WatchRequest")
+ proto.RegisterType((*WatchCreateRequest)(nil), "etcdserverpb.WatchCreateRequest")
+ proto.RegisterType((*WatchCancelRequest)(nil), "etcdserverpb.WatchCancelRequest")
+ proto.RegisterType((*WatchResponse)(nil), "etcdserverpb.WatchResponse")
+ proto.RegisterType((*LeaseGrantRequest)(nil), "etcdserverpb.LeaseGrantRequest")
+ proto.RegisterType((*LeaseGrantResponse)(nil), "etcdserverpb.LeaseGrantResponse")
+ proto.RegisterType((*LeaseRevokeRequest)(nil), "etcdserverpb.LeaseRevokeRequest")
+ proto.RegisterType((*LeaseRevokeResponse)(nil), "etcdserverpb.LeaseRevokeResponse")
+ proto.RegisterType((*LeaseKeepAliveRequest)(nil), "etcdserverpb.LeaseKeepAliveRequest")
+ proto.RegisterType((*LeaseKeepAliveResponse)(nil), "etcdserverpb.LeaseKeepAliveResponse")
+ proto.RegisterType((*LeaseTimeToLiveRequest)(nil), "etcdserverpb.LeaseTimeToLiveRequest")
+ proto.RegisterType((*LeaseTimeToLiveResponse)(nil), "etcdserverpb.LeaseTimeToLiveResponse")
+ proto.RegisterType((*Member)(nil), "etcdserverpb.Member")
+ proto.RegisterType((*MemberAddRequest)(nil), "etcdserverpb.MemberAddRequest")
+ proto.RegisterType((*MemberAddResponse)(nil), "etcdserverpb.MemberAddResponse")
+ proto.RegisterType((*MemberRemoveRequest)(nil), "etcdserverpb.MemberRemoveRequest")
+ proto.RegisterType((*MemberRemoveResponse)(nil), "etcdserverpb.MemberRemoveResponse")
+ proto.RegisterType((*MemberUpdateRequest)(nil), "etcdserverpb.MemberUpdateRequest")
+ proto.RegisterType((*MemberUpdateResponse)(nil), "etcdserverpb.MemberUpdateResponse")
+ proto.RegisterType((*MemberListRequest)(nil), "etcdserverpb.MemberListRequest")
+ proto.RegisterType((*MemberListResponse)(nil), "etcdserverpb.MemberListResponse")
+ proto.RegisterType((*DefragmentRequest)(nil), "etcdserverpb.DefragmentRequest")
+ proto.RegisterType((*DefragmentResponse)(nil), "etcdserverpb.DefragmentResponse")
+ proto.RegisterType((*AlarmRequest)(nil), "etcdserverpb.AlarmRequest")
+ proto.RegisterType((*AlarmMember)(nil), "etcdserverpb.AlarmMember")
+ proto.RegisterType((*AlarmResponse)(nil), "etcdserverpb.AlarmResponse")
+ proto.RegisterType((*StatusRequest)(nil), "etcdserverpb.StatusRequest")
+ proto.RegisterType((*StatusResponse)(nil), "etcdserverpb.StatusResponse")
+ proto.RegisterType((*AuthEnableRequest)(nil), "etcdserverpb.AuthEnableRequest")
+ proto.RegisterType((*AuthDisableRequest)(nil), "etcdserverpb.AuthDisableRequest")
+ proto.RegisterType((*AuthenticateRequest)(nil), "etcdserverpb.AuthenticateRequest")
+ proto.RegisterType((*AuthUserAddRequest)(nil), "etcdserverpb.AuthUserAddRequest")
+ proto.RegisterType((*AuthUserGetRequest)(nil), "etcdserverpb.AuthUserGetRequest")
+ proto.RegisterType((*AuthUserDeleteRequest)(nil), "etcdserverpb.AuthUserDeleteRequest")
+ proto.RegisterType((*AuthUserChangePasswordRequest)(nil), "etcdserverpb.AuthUserChangePasswordRequest")
+ proto.RegisterType((*AuthUserGrantRoleRequest)(nil), "etcdserverpb.AuthUserGrantRoleRequest")
+ proto.RegisterType((*AuthUserRevokeRoleRequest)(nil), "etcdserverpb.AuthUserRevokeRoleRequest")
+ proto.RegisterType((*AuthRoleAddRequest)(nil), "etcdserverpb.AuthRoleAddRequest")
+ proto.RegisterType((*AuthRoleGetRequest)(nil), "etcdserverpb.AuthRoleGetRequest")
+ proto.RegisterType((*AuthUserListRequest)(nil), "etcdserverpb.AuthUserListRequest")
+ proto.RegisterType((*AuthRoleListRequest)(nil), "etcdserverpb.AuthRoleListRequest")
+ proto.RegisterType((*AuthRoleDeleteRequest)(nil), "etcdserverpb.AuthRoleDeleteRequest")
+ proto.RegisterType((*AuthRoleGrantPermissionRequest)(nil), "etcdserverpb.AuthRoleGrantPermissionRequest")
+ proto.RegisterType((*AuthRoleRevokePermissionRequest)(nil), "etcdserverpb.AuthRoleRevokePermissionRequest")
+ proto.RegisterType((*AuthEnableResponse)(nil), "etcdserverpb.AuthEnableResponse")
+ proto.RegisterType((*AuthDisableResponse)(nil), "etcdserverpb.AuthDisableResponse")
+ proto.RegisterType((*AuthenticateResponse)(nil), "etcdserverpb.AuthenticateResponse")
+ proto.RegisterType((*AuthUserAddResponse)(nil), "etcdserverpb.AuthUserAddResponse")
+ proto.RegisterType((*AuthUserGetResponse)(nil), "etcdserverpb.AuthUserGetResponse")
+ proto.RegisterType((*AuthUserDeleteResponse)(nil), "etcdserverpb.AuthUserDeleteResponse")
+ proto.RegisterType((*AuthUserChangePasswordResponse)(nil), "etcdserverpb.AuthUserChangePasswordResponse")
+ proto.RegisterType((*AuthUserGrantRoleResponse)(nil), "etcdserverpb.AuthUserGrantRoleResponse")
+ proto.RegisterType((*AuthUserRevokeRoleResponse)(nil), "etcdserverpb.AuthUserRevokeRoleResponse")
+ proto.RegisterType((*AuthRoleAddResponse)(nil), "etcdserverpb.AuthRoleAddResponse")
+ proto.RegisterType((*AuthRoleGetResponse)(nil), "etcdserverpb.AuthRoleGetResponse")
+ proto.RegisterType((*AuthRoleListResponse)(nil), "etcdserverpb.AuthRoleListResponse")
+ proto.RegisterType((*AuthUserListResponse)(nil), "etcdserverpb.AuthUserListResponse")
+ proto.RegisterType((*AuthRoleDeleteResponse)(nil), "etcdserverpb.AuthRoleDeleteResponse")
+ proto.RegisterType((*AuthRoleGrantPermissionResponse)(nil), "etcdserverpb.AuthRoleGrantPermissionResponse")
+ proto.RegisterType((*AuthRoleRevokePermissionResponse)(nil), "etcdserverpb.AuthRoleRevokePermissionResponse")
+ proto.RegisterEnum("etcdserverpb.AlarmType", AlarmType_name, AlarmType_value)
+ proto.RegisterEnum("etcdserverpb.RangeRequest_SortOrder", RangeRequest_SortOrder_name, RangeRequest_SortOrder_value)
+ proto.RegisterEnum("etcdserverpb.RangeRequest_SortTarget", RangeRequest_SortTarget_name, RangeRequest_SortTarget_value)
+ proto.RegisterEnum("etcdserverpb.Compare_CompareResult", Compare_CompareResult_name, Compare_CompareResult_value)
+ proto.RegisterEnum("etcdserverpb.Compare_CompareTarget", Compare_CompareTarget_name, Compare_CompareTarget_value)
+ proto.RegisterEnum("etcdserverpb.WatchCreateRequest_FilterType", WatchCreateRequest_FilterType_name, WatchCreateRequest_FilterType_value)
+ proto.RegisterEnum("etcdserverpb.AlarmRequest_AlarmAction", AlarmRequest_AlarmAction_name, AlarmRequest_AlarmAction_value)
+}
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ context.Context
+var _ grpc.ClientConn
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+const _ = grpc.SupportPackageIsVersion4
+
+// Client API for KV service
+
+type KVClient interface {
+ // Range gets the keys in the range from the key-value store.
+ Range(ctx context.Context, in *RangeRequest, opts ...grpc.CallOption) (*RangeResponse, error)
+ // Put puts the given key into the key-value store.
+ // A put request increments the revision of the key-value store
+ // and generates one event in the event history.
+ Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error)
+ // DeleteRange deletes the given range from the key-value store.
+ // A delete request increments the revision of the key-value store
+ // and generates a delete event in the event history for every deleted key.
+ DeleteRange(ctx context.Context, in *DeleteRangeRequest, opts ...grpc.CallOption) (*DeleteRangeResponse, error)
+ // Txn processes multiple requests in a single transaction.
+ // A txn request increments the revision of the key-value store
+ // and generates events with the same revision for every completed request.
+ // It is not allowed to modify the same key several times within one txn.
+ Txn(ctx context.Context, in *TxnRequest, opts ...grpc.CallOption) (*TxnResponse, error)
+ // Compact compacts the event history in the etcd key-value store. The key-value
+ // store should be periodically compacted or the event history will continue to grow
+ // indefinitely.
+ Compact(ctx context.Context, in *CompactionRequest, opts ...grpc.CallOption) (*CompactionResponse, error)
+}
+
+type kVClient struct {
+ cc *grpc.ClientConn
+}
+
+func NewKVClient(cc *grpc.ClientConn) KVClient {
+ return &kVClient{cc}
+}
+
+func (c *kVClient) Range(ctx context.Context, in *RangeRequest, opts ...grpc.CallOption) (*RangeResponse, error) {
+ out := new(RangeResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.KV/Range", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *kVClient) Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error) {
+ out := new(PutResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.KV/Put", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *kVClient) DeleteRange(ctx context.Context, in *DeleteRangeRequest, opts ...grpc.CallOption) (*DeleteRangeResponse, error) {
+ out := new(DeleteRangeResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.KV/DeleteRange", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *kVClient) Txn(ctx context.Context, in *TxnRequest, opts ...grpc.CallOption) (*TxnResponse, error) {
+ out := new(TxnResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.KV/Txn", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *kVClient) Compact(ctx context.Context, in *CompactionRequest, opts ...grpc.CallOption) (*CompactionResponse, error) {
+ out := new(CompactionResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.KV/Compact", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// Server API for KV service
+
+type KVServer interface {
+ // Range gets the keys in the range from the key-value store.
+ Range(context.Context, *RangeRequest) (*RangeResponse, error)
+ // Put puts the given key into the key-value store.
+ // A put request increments the revision of the key-value store
+ // and generates one event in the event history.
+ Put(context.Context, *PutRequest) (*PutResponse, error)
+ // DeleteRange deletes the given range from the key-value store.
+ // A delete request increments the revision of the key-value store
+ // and generates a delete event in the event history for every deleted key.
+ DeleteRange(context.Context, *DeleteRangeRequest) (*DeleteRangeResponse, error)
+ // Txn processes multiple requests in a single transaction.
+ // A txn request increments the revision of the key-value store
+ // and generates events with the same revision for every completed request.
+ // It is not allowed to modify the same key several times within one txn.
+ Txn(context.Context, *TxnRequest) (*TxnResponse, error)
+ // Compact compacts the event history in the etcd key-value store. The key-value
+ // store should be periodically compacted or the event history will continue to grow
+ // indefinitely.
+ Compact(context.Context, *CompactionRequest) (*CompactionResponse, error)
+}
+
+func RegisterKVServer(s *grpc.Server, srv KVServer) {
+ s.RegisterService(&_KV_serviceDesc, srv)
+}
+
+func _KV_Range_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(RangeRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(KVServer).Range(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.KV/Range",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(KVServer).Range(ctx, req.(*RangeRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _KV_Put_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(PutRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(KVServer).Put(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.KV/Put",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(KVServer).Put(ctx, req.(*PutRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _KV_DeleteRange_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(DeleteRangeRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(KVServer).DeleteRange(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.KV/DeleteRange",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(KVServer).DeleteRange(ctx, req.(*DeleteRangeRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _KV_Txn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(TxnRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(KVServer).Txn(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.KV/Txn",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(KVServer).Txn(ctx, req.(*TxnRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _KV_Compact_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(CompactionRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(KVServer).Compact(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.KV/Compact",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(KVServer).Compact(ctx, req.(*CompactionRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+var _KV_serviceDesc = grpc.ServiceDesc{
+ ServiceName: "etcdserverpb.KV",
+ HandlerType: (*KVServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "Range",
+ Handler: _KV_Range_Handler,
+ },
+ {
+ MethodName: "Put",
+ Handler: _KV_Put_Handler,
+ },
+ {
+ MethodName: "DeleteRange",
+ Handler: _KV_DeleteRange_Handler,
+ },
+ {
+ MethodName: "Txn",
+ Handler: _KV_Txn_Handler,
+ },
+ {
+ MethodName: "Compact",
+ Handler: _KV_Compact_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{},
+ Metadata: "rpc.proto",
+}
+
+// Client API for Watch service
+
+type WatchClient interface {
+ // Watch watches for events happening or that have happened. Both input and output
+ // are streams; the input stream is for creating and canceling watchers and the output
+ // stream sends events. One watch RPC can watch on multiple key ranges, streaming events
+ // for several watches at once. The entire event history can be watched starting from the
+ // last compaction revision.
+ Watch(ctx context.Context, opts ...grpc.CallOption) (Watch_WatchClient, error)
+}
+
+type watchClient struct {
+ cc *grpc.ClientConn
+}
+
+func NewWatchClient(cc *grpc.ClientConn) WatchClient {
+ return &watchClient{cc}
+}
+
+func (c *watchClient) Watch(ctx context.Context, opts ...grpc.CallOption) (Watch_WatchClient, error) {
+ stream, err := grpc.NewClientStream(ctx, &_Watch_serviceDesc.Streams[0], c.cc, "/etcdserverpb.Watch/Watch", opts...)
+ if err != nil {
+ return nil, err
+ }
+ x := &watchWatchClient{stream}
+ return x, nil
+}
+
+type Watch_WatchClient interface {
+ Send(*WatchRequest) error
+ Recv() (*WatchResponse, error)
+ grpc.ClientStream
+}
+
+type watchWatchClient struct {
+ grpc.ClientStream
+}
+
+func (x *watchWatchClient) Send(m *WatchRequest) error {
+ return x.ClientStream.SendMsg(m)
+}
+
+func (x *watchWatchClient) Recv() (*WatchResponse, error) {
+ m := new(WatchResponse)
+ if err := x.ClientStream.RecvMsg(m); err != nil {
+ return nil, err
+ }
+ return m, nil
+}
+
+// Server API for Watch service
+
+type WatchServer interface {
+ // Watch watches for events happening or that have happened. Both input and output
+ // are streams; the input stream is for creating and canceling watchers and the output
+ // stream sends events. One watch RPC can watch on multiple key ranges, streaming events
+ // for several watches at once. The entire event history can be watched starting from the
+ // last compaction revision.
+ Watch(Watch_WatchServer) error
+}
+
+func RegisterWatchServer(s *grpc.Server, srv WatchServer) {
+ s.RegisterService(&_Watch_serviceDesc, srv)
+}
+
+func _Watch_Watch_Handler(srv interface{}, stream grpc.ServerStream) error {
+ return srv.(WatchServer).Watch(&watchWatchServer{stream})
+}
+
+type Watch_WatchServer interface {
+ Send(*WatchResponse) error
+ Recv() (*WatchRequest, error)
+ grpc.ServerStream
+}
+
+type watchWatchServer struct {
+ grpc.ServerStream
+}
+
+func (x *watchWatchServer) Send(m *WatchResponse) error {
+ return x.ServerStream.SendMsg(m)
+}
+
+func (x *watchWatchServer) Recv() (*WatchRequest, error) {
+ m := new(WatchRequest)
+ if err := x.ServerStream.RecvMsg(m); err != nil {
+ return nil, err
+ }
+ return m, nil
+}
+
+var _Watch_serviceDesc = grpc.ServiceDesc{
+ ServiceName: "etcdserverpb.Watch",
+ HandlerType: (*WatchServer)(nil),
+ Methods: []grpc.MethodDesc{},
+ Streams: []grpc.StreamDesc{
+ {
+ StreamName: "Watch",
+ Handler: _Watch_Watch_Handler,
+ ServerStreams: true,
+ ClientStreams: true,
+ },
+ },
+ Metadata: "rpc.proto",
+}
+
+// Client API for Lease service
+
+type LeaseClient interface {
+ // LeaseGrant creates a lease which expires if the server does not receive a keepAlive
+ // within a given time to live period. All keys attached to the lease will be expired and
+ // deleted if the lease expires. Each expired key generates a delete event in the event history.
+ LeaseGrant(ctx context.Context, in *LeaseGrantRequest, opts ...grpc.CallOption) (*LeaseGrantResponse, error)
+ // LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.
+ LeaseRevoke(ctx context.Context, in *LeaseRevokeRequest, opts ...grpc.CallOption) (*LeaseRevokeResponse, error)
+ // LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
+ // to the server and streaming keep alive responses from the server to the client.
+ LeaseKeepAlive(ctx context.Context, opts ...grpc.CallOption) (Lease_LeaseKeepAliveClient, error)
+ // LeaseTimeToLive retrieves lease information.
+ LeaseTimeToLive(ctx context.Context, in *LeaseTimeToLiveRequest, opts ...grpc.CallOption) (*LeaseTimeToLiveResponse, error)
+}
+
+type leaseClient struct {
+ cc *grpc.ClientConn
+}
+
+func NewLeaseClient(cc *grpc.ClientConn) LeaseClient {
+ return &leaseClient{cc}
+}
+
+func (c *leaseClient) LeaseGrant(ctx context.Context, in *LeaseGrantRequest, opts ...grpc.CallOption) (*LeaseGrantResponse, error) {
+ out := new(LeaseGrantResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Lease/LeaseGrant", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *leaseClient) LeaseRevoke(ctx context.Context, in *LeaseRevokeRequest, opts ...grpc.CallOption) (*LeaseRevokeResponse, error) {
+ out := new(LeaseRevokeResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Lease/LeaseRevoke", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *leaseClient) LeaseKeepAlive(ctx context.Context, opts ...grpc.CallOption) (Lease_LeaseKeepAliveClient, error) {
+ stream, err := grpc.NewClientStream(ctx, &_Lease_serviceDesc.Streams[0], c.cc, "/etcdserverpb.Lease/LeaseKeepAlive", opts...)
+ if err != nil {
+ return nil, err
+ }
+ x := &leaseLeaseKeepAliveClient{stream}
+ return x, nil
+}
+
+type Lease_LeaseKeepAliveClient interface {
+ Send(*LeaseKeepAliveRequest) error
+ Recv() (*LeaseKeepAliveResponse, error)
+ grpc.ClientStream
+}
+
+type leaseLeaseKeepAliveClient struct {
+ grpc.ClientStream
+}
+
+func (x *leaseLeaseKeepAliveClient) Send(m *LeaseKeepAliveRequest) error {
+ return x.ClientStream.SendMsg(m)
+}
+
+func (x *leaseLeaseKeepAliveClient) Recv() (*LeaseKeepAliveResponse, error) {
+ m := new(LeaseKeepAliveResponse)
+ if err := x.ClientStream.RecvMsg(m); err != nil {
+ return nil, err
+ }
+ return m, nil
+}
+
+func (c *leaseClient) LeaseTimeToLive(ctx context.Context, in *LeaseTimeToLiveRequest, opts ...grpc.CallOption) (*LeaseTimeToLiveResponse, error) {
+ out := new(LeaseTimeToLiveResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Lease/LeaseTimeToLive", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// Server API for Lease service
+
+type LeaseServer interface {
+ // LeaseGrant creates a lease which expires if the server does not receive a keepAlive
+ // within a given time to live period. All keys attached to the lease will be expired and
+ // deleted if the lease expires. Each expired key generates a delete event in the event history.
+ LeaseGrant(context.Context, *LeaseGrantRequest) (*LeaseGrantResponse, error)
+ // LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.
+ LeaseRevoke(context.Context, *LeaseRevokeRequest) (*LeaseRevokeResponse, error)
+ // LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
+ // to the server and streaming keep alive responses from the server to the client.
+ LeaseKeepAlive(Lease_LeaseKeepAliveServer) error
+ // LeaseTimeToLive retrieves lease information.
+ LeaseTimeToLive(context.Context, *LeaseTimeToLiveRequest) (*LeaseTimeToLiveResponse, error)
+}
+
+func RegisterLeaseServer(s *grpc.Server, srv LeaseServer) {
+ s.RegisterService(&_Lease_serviceDesc, srv)
+}
+
+func _Lease_LeaseGrant_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(LeaseGrantRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(LeaseServer).LeaseGrant(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Lease/LeaseGrant",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(LeaseServer).LeaseGrant(ctx, req.(*LeaseGrantRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Lease_LeaseRevoke_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(LeaseRevokeRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(LeaseServer).LeaseRevoke(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Lease/LeaseRevoke",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(LeaseServer).LeaseRevoke(ctx, req.(*LeaseRevokeRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Lease_LeaseKeepAlive_Handler(srv interface{}, stream grpc.ServerStream) error {
+ return srv.(LeaseServer).LeaseKeepAlive(&leaseLeaseKeepAliveServer{stream})
+}
+
+type Lease_LeaseKeepAliveServer interface {
+ Send(*LeaseKeepAliveResponse) error
+ Recv() (*LeaseKeepAliveRequest, error)
+ grpc.ServerStream
+}
+
+type leaseLeaseKeepAliveServer struct {
+ grpc.ServerStream
+}
+
+func (x *leaseLeaseKeepAliveServer) Send(m *LeaseKeepAliveResponse) error {
+ return x.ServerStream.SendMsg(m)
+}
+
+func (x *leaseLeaseKeepAliveServer) Recv() (*LeaseKeepAliveRequest, error) {
+ m := new(LeaseKeepAliveRequest)
+ if err := x.ServerStream.RecvMsg(m); err != nil {
+ return nil, err
+ }
+ return m, nil
+}
+
+func _Lease_LeaseTimeToLive_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(LeaseTimeToLiveRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(LeaseServer).LeaseTimeToLive(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Lease/LeaseTimeToLive",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(LeaseServer).LeaseTimeToLive(ctx, req.(*LeaseTimeToLiveRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+var _Lease_serviceDesc = grpc.ServiceDesc{
+ ServiceName: "etcdserverpb.Lease",
+ HandlerType: (*LeaseServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "LeaseGrant",
+ Handler: _Lease_LeaseGrant_Handler,
+ },
+ {
+ MethodName: "LeaseRevoke",
+ Handler: _Lease_LeaseRevoke_Handler,
+ },
+ {
+ MethodName: "LeaseTimeToLive",
+ Handler: _Lease_LeaseTimeToLive_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{
+ {
+ StreamName: "LeaseKeepAlive",
+ Handler: _Lease_LeaseKeepAlive_Handler,
+ ServerStreams: true,
+ ClientStreams: true,
+ },
+ },
+ Metadata: "rpc.proto",
+}
+
+// Client API for Cluster service
+
+type ClusterClient interface {
+ // MemberAdd adds a member into the cluster.
+ MemberAdd(ctx context.Context, in *MemberAddRequest, opts ...grpc.CallOption) (*MemberAddResponse, error)
+ // MemberRemove removes an existing member from the cluster.
+ MemberRemove(ctx context.Context, in *MemberRemoveRequest, opts ...grpc.CallOption) (*MemberRemoveResponse, error)
+ // MemberUpdate updates the member configuration.
+ MemberUpdate(ctx context.Context, in *MemberUpdateRequest, opts ...grpc.CallOption) (*MemberUpdateResponse, error)
+ // MemberList lists all the members in the cluster.
+ MemberList(ctx context.Context, in *MemberListRequest, opts ...grpc.CallOption) (*MemberListResponse, error)
+}
+
+type clusterClient struct {
+ cc *grpc.ClientConn
+}
+
+func NewClusterClient(cc *grpc.ClientConn) ClusterClient {
+ return &clusterClient{cc}
+}
+
+func (c *clusterClient) MemberAdd(ctx context.Context, in *MemberAddRequest, opts ...grpc.CallOption) (*MemberAddResponse, error) {
+ out := new(MemberAddResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Cluster/MemberAdd", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *clusterClient) MemberRemove(ctx context.Context, in *MemberRemoveRequest, opts ...grpc.CallOption) (*MemberRemoveResponse, error) {
+ out := new(MemberRemoveResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Cluster/MemberRemove", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *clusterClient) MemberUpdate(ctx context.Context, in *MemberUpdateRequest, opts ...grpc.CallOption) (*MemberUpdateResponse, error) {
+ out := new(MemberUpdateResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Cluster/MemberUpdate", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *clusterClient) MemberList(ctx context.Context, in *MemberListRequest, opts ...grpc.CallOption) (*MemberListResponse, error) {
+ out := new(MemberListResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Cluster/MemberList", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// Server API for Cluster service
+
+type ClusterServer interface {
+ // MemberAdd adds a member into the cluster.
+ MemberAdd(context.Context, *MemberAddRequest) (*MemberAddResponse, error)
+ // MemberRemove removes an existing member from the cluster.
+ MemberRemove(context.Context, *MemberRemoveRequest) (*MemberRemoveResponse, error)
+ // MemberUpdate updates the member configuration.
+ MemberUpdate(context.Context, *MemberUpdateRequest) (*MemberUpdateResponse, error)
+ // MemberList lists all the members in the cluster.
+ MemberList(context.Context, *MemberListRequest) (*MemberListResponse, error)
+}
+
+func RegisterClusterServer(s *grpc.Server, srv ClusterServer) {
+ s.RegisterService(&_Cluster_serviceDesc, srv)
+}
+
+func _Cluster_MemberAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(MemberAddRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(ClusterServer).MemberAdd(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Cluster/MemberAdd",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(ClusterServer).MemberAdd(ctx, req.(*MemberAddRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Cluster_MemberRemove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(MemberRemoveRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(ClusterServer).MemberRemove(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Cluster/MemberRemove",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(ClusterServer).MemberRemove(ctx, req.(*MemberRemoveRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Cluster_MemberUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(MemberUpdateRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(ClusterServer).MemberUpdate(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Cluster/MemberUpdate",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(ClusterServer).MemberUpdate(ctx, req.(*MemberUpdateRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Cluster_MemberList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(MemberListRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(ClusterServer).MemberList(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Cluster/MemberList",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(ClusterServer).MemberList(ctx, req.(*MemberListRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+var _Cluster_serviceDesc = grpc.ServiceDesc{
+ ServiceName: "etcdserverpb.Cluster",
+ HandlerType: (*ClusterServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "MemberAdd",
+ Handler: _Cluster_MemberAdd_Handler,
+ },
+ {
+ MethodName: "MemberRemove",
+ Handler: _Cluster_MemberRemove_Handler,
+ },
+ {
+ MethodName: "MemberUpdate",
+ Handler: _Cluster_MemberUpdate_Handler,
+ },
+ {
+ MethodName: "MemberList",
+ Handler: _Cluster_MemberList_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{},
+ Metadata: "rpc.proto",
+}
+
+// Client API for Maintenance service
+
+type MaintenanceClient interface {
+ // Alarm activates, deactivates, and queries alarms regarding cluster health.
+ Alarm(ctx context.Context, in *AlarmRequest, opts ...grpc.CallOption) (*AlarmResponse, error)
+ // Status gets the status of the member.
+ Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error)
+ // Defragment defragments a member's backend database to recover storage space.
+ Defragment(ctx context.Context, in *DefragmentRequest, opts ...grpc.CallOption) (*DefragmentResponse, error)
+ // Hash returns the hash of the local KV state for consistency checking purpose.
+ // This is designed for testing; do not use this in production when there
+ // are ongoing transactions.
+ Hash(ctx context.Context, in *HashRequest, opts ...grpc.CallOption) (*HashResponse, error)
+ // Snapshot sends a snapshot of the entire backend from a member over a stream to a client.
+ Snapshot(ctx context.Context, in *SnapshotRequest, opts ...grpc.CallOption) (Maintenance_SnapshotClient, error)
+}
+
+type maintenanceClient struct {
+ cc *grpc.ClientConn
+}
+
+func NewMaintenanceClient(cc *grpc.ClientConn) MaintenanceClient {
+ return &maintenanceClient{cc}
+}
+
+func (c *maintenanceClient) Alarm(ctx context.Context, in *AlarmRequest, opts ...grpc.CallOption) (*AlarmResponse, error) {
+ out := new(AlarmResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Maintenance/Alarm", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *maintenanceClient) Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) {
+ out := new(StatusResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Maintenance/Status", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *maintenanceClient) Defragment(ctx context.Context, in *DefragmentRequest, opts ...grpc.CallOption) (*DefragmentResponse, error) {
+ out := new(DefragmentResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Maintenance/Defragment", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *maintenanceClient) Hash(ctx context.Context, in *HashRequest, opts ...grpc.CallOption) (*HashResponse, error) {
+ out := new(HashResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Maintenance/Hash", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *maintenanceClient) Snapshot(ctx context.Context, in *SnapshotRequest, opts ...grpc.CallOption) (Maintenance_SnapshotClient, error) {
+ stream, err := grpc.NewClientStream(ctx, &_Maintenance_serviceDesc.Streams[0], c.cc, "/etcdserverpb.Maintenance/Snapshot", opts...)
+ if err != nil {
+ return nil, err
+ }
+ x := &maintenanceSnapshotClient{stream}
+ if err := x.ClientStream.SendMsg(in); err != nil {
+ return nil, err
+ }
+ if err := x.ClientStream.CloseSend(); err != nil {
+ return nil, err
+ }
+ return x, nil
+}
+
+type Maintenance_SnapshotClient interface {
+ Recv() (*SnapshotResponse, error)
+ grpc.ClientStream
+}
+
+type maintenanceSnapshotClient struct {
+ grpc.ClientStream
+}
+
+func (x *maintenanceSnapshotClient) Recv() (*SnapshotResponse, error) {
+ m := new(SnapshotResponse)
+ if err := x.ClientStream.RecvMsg(m); err != nil {
+ return nil, err
+ }
+ return m, nil
+}
+
+// Server API for Maintenance service
+
+type MaintenanceServer interface {
+ // Alarm activates, deactivates, and queries alarms regarding cluster health.
+ Alarm(context.Context, *AlarmRequest) (*AlarmResponse, error)
+ // Status gets the status of the member.
+ Status(context.Context, *StatusRequest) (*StatusResponse, error)
+ // Defragment defragments a member's backend database to recover storage space.
+ Defragment(context.Context, *DefragmentRequest) (*DefragmentResponse, error)
+ // Hash returns the hash of the local KV state for consistency checking purpose.
+ // This is designed for testing; do not use this in production when there
+ // are ongoing transactions.
+ Hash(context.Context, *HashRequest) (*HashResponse, error)
+ // Snapshot sends a snapshot of the entire backend from a member over a stream to a client.
+ Snapshot(*SnapshotRequest, Maintenance_SnapshotServer) error
+}
+
+func RegisterMaintenanceServer(s *grpc.Server, srv MaintenanceServer) {
+ s.RegisterService(&_Maintenance_serviceDesc, srv)
+}
+
+func _Maintenance_Alarm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AlarmRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(MaintenanceServer).Alarm(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Maintenance/Alarm",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(MaintenanceServer).Alarm(ctx, req.(*AlarmRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Maintenance_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(StatusRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(MaintenanceServer).Status(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Maintenance/Status",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(MaintenanceServer).Status(ctx, req.(*StatusRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Maintenance_Defragment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(DefragmentRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(MaintenanceServer).Defragment(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Maintenance/Defragment",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(MaintenanceServer).Defragment(ctx, req.(*DefragmentRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Maintenance_Hash_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(HashRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(MaintenanceServer).Hash(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Maintenance/Hash",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(MaintenanceServer).Hash(ctx, req.(*HashRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Maintenance_Snapshot_Handler(srv interface{}, stream grpc.ServerStream) error {
+ m := new(SnapshotRequest)
+ if err := stream.RecvMsg(m); err != nil {
+ return err
+ }
+ return srv.(MaintenanceServer).Snapshot(m, &maintenanceSnapshotServer{stream})
+}
+
+type Maintenance_SnapshotServer interface {
+ Send(*SnapshotResponse) error
+ grpc.ServerStream
+}
+
+type maintenanceSnapshotServer struct {
+ grpc.ServerStream
+}
+
+func (x *maintenanceSnapshotServer) Send(m *SnapshotResponse) error {
+ return x.ServerStream.SendMsg(m)
+}
+
+var _Maintenance_serviceDesc = grpc.ServiceDesc{
+ ServiceName: "etcdserverpb.Maintenance",
+ HandlerType: (*MaintenanceServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "Alarm",
+ Handler: _Maintenance_Alarm_Handler,
+ },
+ {
+ MethodName: "Status",
+ Handler: _Maintenance_Status_Handler,
+ },
+ {
+ MethodName: "Defragment",
+ Handler: _Maintenance_Defragment_Handler,
+ },
+ {
+ MethodName: "Hash",
+ Handler: _Maintenance_Hash_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{
+ {
+ StreamName: "Snapshot",
+ Handler: _Maintenance_Snapshot_Handler,
+ ServerStreams: true,
+ },
+ },
+ Metadata: "rpc.proto",
+}
+
+// Client API for Auth service
+
+type AuthClient interface {
+ // AuthEnable enables authentication.
+ AuthEnable(ctx context.Context, in *AuthEnableRequest, opts ...grpc.CallOption) (*AuthEnableResponse, error)
+ // AuthDisable disables authentication.
+ AuthDisable(ctx context.Context, in *AuthDisableRequest, opts ...grpc.CallOption) (*AuthDisableResponse, error)
+ // Authenticate processes an authenticate request.
+ Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error)
+ // UserAdd adds a new user.
+ UserAdd(ctx context.Context, in *AuthUserAddRequest, opts ...grpc.CallOption) (*AuthUserAddResponse, error)
+ // UserGet gets detailed user information.
+ UserGet(ctx context.Context, in *AuthUserGetRequest, opts ...grpc.CallOption) (*AuthUserGetResponse, error)
+ // UserList gets a list of all users.
+ UserList(ctx context.Context, in *AuthUserListRequest, opts ...grpc.CallOption) (*AuthUserListResponse, error)
+ // UserDelete deletes a specified user.
+ UserDelete(ctx context.Context, in *AuthUserDeleteRequest, opts ...grpc.CallOption) (*AuthUserDeleteResponse, error)
+ // UserChangePassword changes the password of a specified user.
+ UserChangePassword(ctx context.Context, in *AuthUserChangePasswordRequest, opts ...grpc.CallOption) (*AuthUserChangePasswordResponse, error)
+ // UserGrant grants a role to a specified user.
+ UserGrantRole(ctx context.Context, in *AuthUserGrantRoleRequest, opts ...grpc.CallOption) (*AuthUserGrantRoleResponse, error)
+ // UserRevokeRole revokes a role of specified user.
+ UserRevokeRole(ctx context.Context, in *AuthUserRevokeRoleRequest, opts ...grpc.CallOption) (*AuthUserRevokeRoleResponse, error)
+ // RoleAdd adds a new role.
+ RoleAdd(ctx context.Context, in *AuthRoleAddRequest, opts ...grpc.CallOption) (*AuthRoleAddResponse, error)
+ // RoleGet gets detailed role information.
+ RoleGet(ctx context.Context, in *AuthRoleGetRequest, opts ...grpc.CallOption) (*AuthRoleGetResponse, error)
+ // RoleList gets lists of all roles.
+ RoleList(ctx context.Context, in *AuthRoleListRequest, opts ...grpc.CallOption) (*AuthRoleListResponse, error)
+ // RoleDelete deletes a specified role.
+ RoleDelete(ctx context.Context, in *AuthRoleDeleteRequest, opts ...grpc.CallOption) (*AuthRoleDeleteResponse, error)
+ // RoleGrantPermission grants a permission of a specified key or range to a specified role.
+ RoleGrantPermission(ctx context.Context, in *AuthRoleGrantPermissionRequest, opts ...grpc.CallOption) (*AuthRoleGrantPermissionResponse, error)
+ // RoleRevokePermission revokes a key or range permission of a specified role.
+ RoleRevokePermission(ctx context.Context, in *AuthRoleRevokePermissionRequest, opts ...grpc.CallOption) (*AuthRoleRevokePermissionResponse, error)
+}
+
+type authClient struct {
+ cc *grpc.ClientConn
+}
+
+func NewAuthClient(cc *grpc.ClientConn) AuthClient {
+ return &authClient{cc}
+}
+
+func (c *authClient) AuthEnable(ctx context.Context, in *AuthEnableRequest, opts ...grpc.CallOption) (*AuthEnableResponse, error) {
+ out := new(AuthEnableResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/AuthEnable", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) AuthDisable(ctx context.Context, in *AuthDisableRequest, opts ...grpc.CallOption) (*AuthDisableResponse, error) {
+ out := new(AuthDisableResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/AuthDisable", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) {
+ out := new(AuthenticateResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/Authenticate", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) UserAdd(ctx context.Context, in *AuthUserAddRequest, opts ...grpc.CallOption) (*AuthUserAddResponse, error) {
+ out := new(AuthUserAddResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/UserAdd", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) UserGet(ctx context.Context, in *AuthUserGetRequest, opts ...grpc.CallOption) (*AuthUserGetResponse, error) {
+ out := new(AuthUserGetResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/UserGet", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) UserList(ctx context.Context, in *AuthUserListRequest, opts ...grpc.CallOption) (*AuthUserListResponse, error) {
+ out := new(AuthUserListResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/UserList", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) UserDelete(ctx context.Context, in *AuthUserDeleteRequest, opts ...grpc.CallOption) (*AuthUserDeleteResponse, error) {
+ out := new(AuthUserDeleteResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/UserDelete", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) UserChangePassword(ctx context.Context, in *AuthUserChangePasswordRequest, opts ...grpc.CallOption) (*AuthUserChangePasswordResponse, error) {
+ out := new(AuthUserChangePasswordResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/UserChangePassword", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) UserGrantRole(ctx context.Context, in *AuthUserGrantRoleRequest, opts ...grpc.CallOption) (*AuthUserGrantRoleResponse, error) {
+ out := new(AuthUserGrantRoleResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/UserGrantRole", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) UserRevokeRole(ctx context.Context, in *AuthUserRevokeRoleRequest, opts ...grpc.CallOption) (*AuthUserRevokeRoleResponse, error) {
+ out := new(AuthUserRevokeRoleResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/UserRevokeRole", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) RoleAdd(ctx context.Context, in *AuthRoleAddRequest, opts ...grpc.CallOption) (*AuthRoleAddResponse, error) {
+ out := new(AuthRoleAddResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/RoleAdd", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) RoleGet(ctx context.Context, in *AuthRoleGetRequest, opts ...grpc.CallOption) (*AuthRoleGetResponse, error) {
+ out := new(AuthRoleGetResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/RoleGet", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) RoleList(ctx context.Context, in *AuthRoleListRequest, opts ...grpc.CallOption) (*AuthRoleListResponse, error) {
+ out := new(AuthRoleListResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/RoleList", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) RoleDelete(ctx context.Context, in *AuthRoleDeleteRequest, opts ...grpc.CallOption) (*AuthRoleDeleteResponse, error) {
+ out := new(AuthRoleDeleteResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/RoleDelete", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) RoleGrantPermission(ctx context.Context, in *AuthRoleGrantPermissionRequest, opts ...grpc.CallOption) (*AuthRoleGrantPermissionResponse, error) {
+ out := new(AuthRoleGrantPermissionResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/RoleGrantPermission", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) RoleRevokePermission(ctx context.Context, in *AuthRoleRevokePermissionRequest, opts ...grpc.CallOption) (*AuthRoleRevokePermissionResponse, error) {
+ out := new(AuthRoleRevokePermissionResponse)
+ err := grpc.Invoke(ctx, "/etcdserverpb.Auth/RoleRevokePermission", in, out, c.cc, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// Server API for Auth service
+
+type AuthServer interface {
+ // AuthEnable enables authentication.
+ AuthEnable(context.Context, *AuthEnableRequest) (*AuthEnableResponse, error)
+ // AuthDisable disables authentication.
+ AuthDisable(context.Context, *AuthDisableRequest) (*AuthDisableResponse, error)
+ // Authenticate processes an authenticate request.
+ Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error)
+ // UserAdd adds a new user.
+ UserAdd(context.Context, *AuthUserAddRequest) (*AuthUserAddResponse, error)
+ // UserGet gets detailed user information.
+ UserGet(context.Context, *AuthUserGetRequest) (*AuthUserGetResponse, error)
+ // UserList gets a list of all users.
+ UserList(context.Context, *AuthUserListRequest) (*AuthUserListResponse, error)
+ // UserDelete deletes a specified user.
+ UserDelete(context.Context, *AuthUserDeleteRequest) (*AuthUserDeleteResponse, error)
+ // UserChangePassword changes the password of a specified user.
+ UserChangePassword(context.Context, *AuthUserChangePasswordRequest) (*AuthUserChangePasswordResponse, error)
+ // UserGrant grants a role to a specified user.
+ UserGrantRole(context.Context, *AuthUserGrantRoleRequest) (*AuthUserGrantRoleResponse, error)
+ // UserRevokeRole revokes a role of specified user.
+ UserRevokeRole(context.Context, *AuthUserRevokeRoleRequest) (*AuthUserRevokeRoleResponse, error)
+ // RoleAdd adds a new role.
+ RoleAdd(context.Context, *AuthRoleAddRequest) (*AuthRoleAddResponse, error)
+ // RoleGet gets detailed role information.
+ RoleGet(context.Context, *AuthRoleGetRequest) (*AuthRoleGetResponse, error)
+ // RoleList gets lists of all roles.
+ RoleList(context.Context, *AuthRoleListRequest) (*AuthRoleListResponse, error)
+ // RoleDelete deletes a specified role.
+ RoleDelete(context.Context, *AuthRoleDeleteRequest) (*AuthRoleDeleteResponse, error)
+ // RoleGrantPermission grants a permission of a specified key or range to a specified role.
+ RoleGrantPermission(context.Context, *AuthRoleGrantPermissionRequest) (*AuthRoleGrantPermissionResponse, error)
+ // RoleRevokePermission revokes a key or range permission of a specified role.
+ RoleRevokePermission(context.Context, *AuthRoleRevokePermissionRequest) (*AuthRoleRevokePermissionResponse, error)
+}
+
+func RegisterAuthServer(s *grpc.Server, srv AuthServer) {
+ s.RegisterService(&_Auth_serviceDesc, srv)
+}
+
+func _Auth_AuthEnable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthEnableRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).AuthEnable(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/AuthEnable",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).AuthEnable(ctx, req.(*AuthEnableRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_AuthDisable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthDisableRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).AuthDisable(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/AuthDisable",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).AuthDisable(ctx, req.(*AuthDisableRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_Authenticate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthenticateRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).Authenticate(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/Authenticate",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).Authenticate(ctx, req.(*AuthenticateRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_UserAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthUserAddRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).UserAdd(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/UserAdd",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).UserAdd(ctx, req.(*AuthUserAddRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_UserGet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthUserGetRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).UserGet(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/UserGet",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).UserGet(ctx, req.(*AuthUserGetRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_UserList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthUserListRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).UserList(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/UserList",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).UserList(ctx, req.(*AuthUserListRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_UserDelete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthUserDeleteRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).UserDelete(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/UserDelete",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).UserDelete(ctx, req.(*AuthUserDeleteRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_UserChangePassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthUserChangePasswordRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).UserChangePassword(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/UserChangePassword",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).UserChangePassword(ctx, req.(*AuthUserChangePasswordRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_UserGrantRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthUserGrantRoleRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).UserGrantRole(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/UserGrantRole",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).UserGrantRole(ctx, req.(*AuthUserGrantRoleRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_UserRevokeRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthUserRevokeRoleRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).UserRevokeRole(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/UserRevokeRole",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).UserRevokeRole(ctx, req.(*AuthUserRevokeRoleRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_RoleAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthRoleAddRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).RoleAdd(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/RoleAdd",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).RoleAdd(ctx, req.(*AuthRoleAddRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_RoleGet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthRoleGetRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).RoleGet(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/RoleGet",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).RoleGet(ctx, req.(*AuthRoleGetRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_RoleList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthRoleListRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).RoleList(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/RoleList",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).RoleList(ctx, req.(*AuthRoleListRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_RoleDelete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthRoleDeleteRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).RoleDelete(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/RoleDelete",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).RoleDelete(ctx, req.(*AuthRoleDeleteRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_RoleGrantPermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthRoleGrantPermissionRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).RoleGrantPermission(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/RoleGrantPermission",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).RoleGrantPermission(ctx, req.(*AuthRoleGrantPermissionRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_RoleRevokePermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AuthRoleRevokePermissionRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).RoleRevokePermission(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/etcdserverpb.Auth/RoleRevokePermission",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).RoleRevokePermission(ctx, req.(*AuthRoleRevokePermissionRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+var _Auth_serviceDesc = grpc.ServiceDesc{
+ ServiceName: "etcdserverpb.Auth",
+ HandlerType: (*AuthServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "AuthEnable",
+ Handler: _Auth_AuthEnable_Handler,
+ },
+ {
+ MethodName: "AuthDisable",
+ Handler: _Auth_AuthDisable_Handler,
+ },
+ {
+ MethodName: "Authenticate",
+ Handler: _Auth_Authenticate_Handler,
+ },
+ {
+ MethodName: "UserAdd",
+ Handler: _Auth_UserAdd_Handler,
+ },
+ {
+ MethodName: "UserGet",
+ Handler: _Auth_UserGet_Handler,
+ },
+ {
+ MethodName: "UserList",
+ Handler: _Auth_UserList_Handler,
+ },
+ {
+ MethodName: "UserDelete",
+ Handler: _Auth_UserDelete_Handler,
+ },
+ {
+ MethodName: "UserChangePassword",
+ Handler: _Auth_UserChangePassword_Handler,
+ },
+ {
+ MethodName: "UserGrantRole",
+ Handler: _Auth_UserGrantRole_Handler,
+ },
+ {
+ MethodName: "UserRevokeRole",
+ Handler: _Auth_UserRevokeRole_Handler,
+ },
+ {
+ MethodName: "RoleAdd",
+ Handler: _Auth_RoleAdd_Handler,
+ },
+ {
+ MethodName: "RoleGet",
+ Handler: _Auth_RoleGet_Handler,
+ },
+ {
+ MethodName: "RoleList",
+ Handler: _Auth_RoleList_Handler,
+ },
+ {
+ MethodName: "RoleDelete",
+ Handler: _Auth_RoleDelete_Handler,
+ },
+ {
+ MethodName: "RoleGrantPermission",
+ Handler: _Auth_RoleGrantPermission_Handler,
+ },
+ {
+ MethodName: "RoleRevokePermission",
+ Handler: _Auth_RoleRevokePermission_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{},
+ Metadata: "rpc.proto",
+}
+
+func (m *ResponseHeader) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *ResponseHeader) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.ClusterId != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ClusterId))
+ }
+ if m.MemberId != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.MemberId))
+ }
+ if m.Revision != 0 {
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Revision))
+ }
+ if m.RaftTerm != 0 {
+ dAtA[i] = 0x20
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.RaftTerm))
+ }
+ return i, nil
+}
+
+func (m *RangeRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *RangeRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Key) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Key)))
+ i += copy(dAtA[i:], m.Key)
+ }
+ if len(m.RangeEnd) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.RangeEnd)))
+ i += copy(dAtA[i:], m.RangeEnd)
+ }
+ if m.Limit != 0 {
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Limit))
+ }
+ if m.Revision != 0 {
+ dAtA[i] = 0x20
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Revision))
+ }
+ if m.SortOrder != 0 {
+ dAtA[i] = 0x28
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.SortOrder))
+ }
+ if m.SortTarget != 0 {
+ dAtA[i] = 0x30
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.SortTarget))
+ }
+ if m.Serializable {
+ dAtA[i] = 0x38
+ i++
+ if m.Serializable {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ if m.KeysOnly {
+ dAtA[i] = 0x40
+ i++
+ if m.KeysOnly {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ if m.CountOnly {
+ dAtA[i] = 0x48
+ i++
+ if m.CountOnly {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ if m.MinModRevision != 0 {
+ dAtA[i] = 0x50
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.MinModRevision))
+ }
+ if m.MaxModRevision != 0 {
+ dAtA[i] = 0x58
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.MaxModRevision))
+ }
+ if m.MinCreateRevision != 0 {
+ dAtA[i] = 0x60
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.MinCreateRevision))
+ }
+ if m.MaxCreateRevision != 0 {
+ dAtA[i] = 0x68
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.MaxCreateRevision))
+ }
+ return i, nil
+}
+
+func (m *RangeResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *RangeResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n1, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n1
+ }
+ if len(m.Kvs) > 0 {
+ for _, msg := range m.Kvs {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ if m.More {
+ dAtA[i] = 0x18
+ i++
+ if m.More {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ if m.Count != 0 {
+ dAtA[i] = 0x20
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Count))
+ }
+ return i, nil
+}
+
+func (m *PutRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *PutRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Key) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Key)))
+ i += copy(dAtA[i:], m.Key)
+ }
+ if len(m.Value) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Value)))
+ i += copy(dAtA[i:], m.Value)
+ }
+ if m.Lease != 0 {
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Lease))
+ }
+ if m.PrevKv {
+ dAtA[i] = 0x20
+ i++
+ if m.PrevKv {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ if m.IgnoreValue {
+ dAtA[i] = 0x28
+ i++
+ if m.IgnoreValue {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ if m.IgnoreLease {
+ dAtA[i] = 0x30
+ i++
+ if m.IgnoreLease {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ return i, nil
+}
+
+func (m *PutResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *PutResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n2, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n2
+ }
+ if m.PrevKv != nil {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.PrevKv.Size()))
+ n3, err := m.PrevKv.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n3
+ }
+ return i, nil
+}
+
+func (m *DeleteRangeRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *DeleteRangeRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Key) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Key)))
+ i += copy(dAtA[i:], m.Key)
+ }
+ if len(m.RangeEnd) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.RangeEnd)))
+ i += copy(dAtA[i:], m.RangeEnd)
+ }
+ if m.PrevKv {
+ dAtA[i] = 0x18
+ i++
+ if m.PrevKv {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ return i, nil
+}
+
+func (m *DeleteRangeResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *DeleteRangeResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n4, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n4
+ }
+ if m.Deleted != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Deleted))
+ }
+ if len(m.PrevKvs) > 0 {
+ for _, msg := range m.PrevKvs {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ return i, nil
+}
+
+func (m *RequestOp) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *RequestOp) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Request != nil {
+ nn5, err := m.Request.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += nn5
+ }
+ return i, nil
+}
+
+func (m *RequestOp_RequestRange) MarshalTo(dAtA []byte) (int, error) {
+ i := 0
+ if m.RequestRange != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.RequestRange.Size()))
+ n6, err := m.RequestRange.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n6
+ }
+ return i, nil
+}
+func (m *RequestOp_RequestPut) MarshalTo(dAtA []byte) (int, error) {
+ i := 0
+ if m.RequestPut != nil {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.RequestPut.Size()))
+ n7, err := m.RequestPut.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n7
+ }
+ return i, nil
+}
+func (m *RequestOp_RequestDeleteRange) MarshalTo(dAtA []byte) (int, error) {
+ i := 0
+ if m.RequestDeleteRange != nil {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.RequestDeleteRange.Size()))
+ n8, err := m.RequestDeleteRange.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n8
+ }
+ return i, nil
+}
+func (m *ResponseOp) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *ResponseOp) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Response != nil {
+ nn9, err := m.Response.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += nn9
+ }
+ return i, nil
+}
+
+func (m *ResponseOp_ResponseRange) MarshalTo(dAtA []byte) (int, error) {
+ i := 0
+ if m.ResponseRange != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ResponseRange.Size()))
+ n10, err := m.ResponseRange.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n10
+ }
+ return i, nil
+}
+func (m *ResponseOp_ResponsePut) MarshalTo(dAtA []byte) (int, error) {
+ i := 0
+ if m.ResponsePut != nil {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ResponsePut.Size()))
+ n11, err := m.ResponsePut.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n11
+ }
+ return i, nil
+}
+func (m *ResponseOp_ResponseDeleteRange) MarshalTo(dAtA []byte) (int, error) {
+ i := 0
+ if m.ResponseDeleteRange != nil {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ResponseDeleteRange.Size()))
+ n12, err := m.ResponseDeleteRange.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n12
+ }
+ return i, nil
+}
+func (m *Compare) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *Compare) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Result != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Result))
+ }
+ if m.Target != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Target))
+ }
+ if len(m.Key) > 0 {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Key)))
+ i += copy(dAtA[i:], m.Key)
+ }
+ if m.TargetUnion != nil {
+ nn13, err := m.TargetUnion.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += nn13
+ }
+ return i, nil
+}
+
+func (m *Compare_Version) MarshalTo(dAtA []byte) (int, error) {
+ i := 0
+ dAtA[i] = 0x20
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Version))
+ return i, nil
+}
+func (m *Compare_CreateRevision) MarshalTo(dAtA []byte) (int, error) {
+ i := 0
+ dAtA[i] = 0x28
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.CreateRevision))
+ return i, nil
+}
+func (m *Compare_ModRevision) MarshalTo(dAtA []byte) (int, error) {
+ i := 0
+ dAtA[i] = 0x30
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ModRevision))
+ return i, nil
+}
+func (m *Compare_Value) MarshalTo(dAtA []byte) (int, error) {
+ i := 0
+ if m.Value != nil {
+ dAtA[i] = 0x3a
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Value)))
+ i += copy(dAtA[i:], m.Value)
+ }
+ return i, nil
+}
+func (m *TxnRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *TxnRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Compare) > 0 {
+ for _, msg := range m.Compare {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ if len(m.Success) > 0 {
+ for _, msg := range m.Success {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ if len(m.Failure) > 0 {
+ for _, msg := range m.Failure {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ return i, nil
+}
+
+func (m *TxnResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *TxnResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n14, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n14
+ }
+ if m.Succeeded {
+ dAtA[i] = 0x10
+ i++
+ if m.Succeeded {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ if len(m.Responses) > 0 {
+ for _, msg := range m.Responses {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ return i, nil
+}
+
+func (m *CompactionRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *CompactionRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Revision != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Revision))
+ }
+ if m.Physical {
+ dAtA[i] = 0x10
+ i++
+ if m.Physical {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ return i, nil
+}
+
+func (m *CompactionResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *CompactionResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n15, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n15
+ }
+ return i, nil
+}
+
+func (m *HashRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *HashRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ return i, nil
+}
+
+func (m *HashResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *HashResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n16, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n16
+ }
+ if m.Hash != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Hash))
+ }
+ return i, nil
+}
+
+func (m *SnapshotRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *SnapshotRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ return i, nil
+}
+
+func (m *SnapshotResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *SnapshotResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n17, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n17
+ }
+ if m.RemainingBytes != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.RemainingBytes))
+ }
+ if len(m.Blob) > 0 {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Blob)))
+ i += copy(dAtA[i:], m.Blob)
+ }
+ return i, nil
+}
+
+func (m *WatchRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *WatchRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.RequestUnion != nil {
+ nn18, err := m.RequestUnion.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += nn18
+ }
+ return i, nil
+}
+
+func (m *WatchRequest_CreateRequest) MarshalTo(dAtA []byte) (int, error) {
+ i := 0
+ if m.CreateRequest != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.CreateRequest.Size()))
+ n19, err := m.CreateRequest.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n19
+ }
+ return i, nil
+}
+func (m *WatchRequest_CancelRequest) MarshalTo(dAtA []byte) (int, error) {
+ i := 0
+ if m.CancelRequest != nil {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.CancelRequest.Size()))
+ n20, err := m.CancelRequest.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n20
+ }
+ return i, nil
+}
+func (m *WatchCreateRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *WatchCreateRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Key) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Key)))
+ i += copy(dAtA[i:], m.Key)
+ }
+ if len(m.RangeEnd) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.RangeEnd)))
+ i += copy(dAtA[i:], m.RangeEnd)
+ }
+ if m.StartRevision != 0 {
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.StartRevision))
+ }
+ if m.ProgressNotify {
+ dAtA[i] = 0x20
+ i++
+ if m.ProgressNotify {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ if len(m.Filters) > 0 {
+ dAtA22 := make([]byte, len(m.Filters)*10)
+ var j21 int
+ for _, num := range m.Filters {
+ for num >= 1<<7 {
+ dAtA22[j21] = uint8(uint64(num)&0x7f | 0x80)
+ num >>= 7
+ j21++
+ }
+ dAtA22[j21] = uint8(num)
+ j21++
+ }
+ dAtA[i] = 0x2a
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(j21))
+ i += copy(dAtA[i:], dAtA22[:j21])
+ }
+ if m.PrevKv {
+ dAtA[i] = 0x30
+ i++
+ if m.PrevKv {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ return i, nil
+}
+
+func (m *WatchCancelRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *WatchCancelRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.WatchId != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.WatchId))
+ }
+ return i, nil
+}
+
+func (m *WatchResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *WatchResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n23, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n23
+ }
+ if m.WatchId != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.WatchId))
+ }
+ if m.Created {
+ dAtA[i] = 0x18
+ i++
+ if m.Created {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ if m.Canceled {
+ dAtA[i] = 0x20
+ i++
+ if m.Canceled {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ if m.CompactRevision != 0 {
+ dAtA[i] = 0x28
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.CompactRevision))
+ }
+ if len(m.CancelReason) > 0 {
+ dAtA[i] = 0x32
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.CancelReason)))
+ i += copy(dAtA[i:], m.CancelReason)
+ }
+ if len(m.Events) > 0 {
+ for _, msg := range m.Events {
+ dAtA[i] = 0x5a
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ return i, nil
+}
+
+func (m *LeaseGrantRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LeaseGrantRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.TTL != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.TTL))
+ }
+ if m.ID != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ID))
+ }
+ return i, nil
+}
+
+func (m *LeaseGrantResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LeaseGrantResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n24, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n24
+ }
+ if m.ID != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ID))
+ }
+ if m.TTL != 0 {
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.TTL))
+ }
+ if len(m.Error) > 0 {
+ dAtA[i] = 0x22
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Error)))
+ i += copy(dAtA[i:], m.Error)
+ }
+ return i, nil
+}
+
+func (m *LeaseRevokeRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LeaseRevokeRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.ID != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ID))
+ }
+ return i, nil
+}
+
+func (m *LeaseRevokeResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LeaseRevokeResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n25, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n25
+ }
+ return i, nil
+}
+
+func (m *LeaseKeepAliveRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LeaseKeepAliveRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.ID != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ID))
+ }
+ return i, nil
+}
+
+func (m *LeaseKeepAliveResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LeaseKeepAliveResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n26, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n26
+ }
+ if m.ID != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ID))
+ }
+ if m.TTL != 0 {
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.TTL))
+ }
+ return i, nil
+}
+
+func (m *LeaseTimeToLiveRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LeaseTimeToLiveRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.ID != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ID))
+ }
+ if m.Keys {
+ dAtA[i] = 0x10
+ i++
+ if m.Keys {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ }
+ return i, nil
+}
+
+func (m *LeaseTimeToLiveResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LeaseTimeToLiveResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n27, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n27
+ }
+ if m.ID != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ID))
+ }
+ if m.TTL != 0 {
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.TTL))
+ }
+ if m.GrantedTTL != 0 {
+ dAtA[i] = 0x20
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.GrantedTTL))
+ }
+ if len(m.Keys) > 0 {
+ for _, b := range m.Keys {
+ dAtA[i] = 0x2a
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(b)))
+ i += copy(dAtA[i:], b)
+ }
+ }
+ return i, nil
+}
+
+func (m *Member) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *Member) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.ID != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ID))
+ }
+ if len(m.Name) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ if len(m.PeerURLs) > 0 {
+ for _, s := range m.PeerURLs {
+ dAtA[i] = 0x1a
+ i++
+ l = len(s)
+ for l >= 1<<7 {
+ dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
+ l >>= 7
+ i++
+ }
+ dAtA[i] = uint8(l)
+ i++
+ i += copy(dAtA[i:], s)
+ }
+ }
+ if len(m.ClientURLs) > 0 {
+ for _, s := range m.ClientURLs {
+ dAtA[i] = 0x22
+ i++
+ l = len(s)
+ for l >= 1<<7 {
+ dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
+ l >>= 7
+ i++
+ }
+ dAtA[i] = uint8(l)
+ i++
+ i += copy(dAtA[i:], s)
+ }
+ }
+ return i, nil
+}
+
+func (m *MemberAddRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *MemberAddRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.PeerURLs) > 0 {
+ for _, s := range m.PeerURLs {
+ dAtA[i] = 0xa
+ i++
+ l = len(s)
+ for l >= 1<<7 {
+ dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
+ l >>= 7
+ i++
+ }
+ dAtA[i] = uint8(l)
+ i++
+ i += copy(dAtA[i:], s)
+ }
+ }
+ return i, nil
+}
+
+func (m *MemberAddResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *MemberAddResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n28, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n28
+ }
+ if m.Member != nil {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Member.Size()))
+ n29, err := m.Member.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n29
+ }
+ if len(m.Members) > 0 {
+ for _, msg := range m.Members {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ return i, nil
+}
+
+func (m *MemberRemoveRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *MemberRemoveRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.ID != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ID))
+ }
+ return i, nil
+}
+
+func (m *MemberRemoveResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *MemberRemoveResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n30, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n30
+ }
+ if len(m.Members) > 0 {
+ for _, msg := range m.Members {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ return i, nil
+}
+
+func (m *MemberUpdateRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *MemberUpdateRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.ID != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.ID))
+ }
+ if len(m.PeerURLs) > 0 {
+ for _, s := range m.PeerURLs {
+ dAtA[i] = 0x12
+ i++
+ l = len(s)
+ for l >= 1<<7 {
+ dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
+ l >>= 7
+ i++
+ }
+ dAtA[i] = uint8(l)
+ i++
+ i += copy(dAtA[i:], s)
+ }
+ }
+ return i, nil
+}
+
+func (m *MemberUpdateResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *MemberUpdateResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n31, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n31
+ }
+ if len(m.Members) > 0 {
+ for _, msg := range m.Members {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ return i, nil
+}
+
+func (m *MemberListRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *MemberListRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ return i, nil
+}
+
+func (m *MemberListResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *MemberListResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n32, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n32
+ }
+ if len(m.Members) > 0 {
+ for _, msg := range m.Members {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ return i, nil
+}
+
+func (m *DefragmentRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *DefragmentRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ return i, nil
+}
+
+func (m *DefragmentResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *DefragmentResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n33, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n33
+ }
+ return i, nil
+}
+
+func (m *AlarmRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AlarmRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Action != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Action))
+ }
+ if m.MemberID != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.MemberID))
+ }
+ if m.Alarm != 0 {
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Alarm))
+ }
+ return i, nil
+}
+
+func (m *AlarmMember) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AlarmMember) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.MemberID != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.MemberID))
+ }
+ if m.Alarm != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Alarm))
+ }
+ return i, nil
+}
+
+func (m *AlarmResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AlarmResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n34, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n34
+ }
+ if len(m.Alarms) > 0 {
+ for _, msg := range m.Alarms {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ return i, nil
+}
+
+func (m *StatusRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *StatusRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ return i, nil
+}
+
+func (m *StatusResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *StatusResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n35, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n35
+ }
+ if len(m.Version) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Version)))
+ i += copy(dAtA[i:], m.Version)
+ }
+ if m.DbSize != 0 {
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.DbSize))
+ }
+ if m.Leader != 0 {
+ dAtA[i] = 0x20
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Leader))
+ }
+ if m.RaftIndex != 0 {
+ dAtA[i] = 0x28
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.RaftIndex))
+ }
+ if m.RaftTerm != 0 {
+ dAtA[i] = 0x30
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.RaftTerm))
+ }
+ return i, nil
+}
+
+func (m *AuthEnableRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthEnableRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ return i, nil
+}
+
+func (m *AuthDisableRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthDisableRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ return i, nil
+}
+
+func (m *AuthenticateRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthenticateRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ if len(m.Password) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Password)))
+ i += copy(dAtA[i:], m.Password)
+ }
+ return i, nil
+}
+
+func (m *AuthUserAddRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthUserAddRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ if len(m.Password) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Password)))
+ i += copy(dAtA[i:], m.Password)
+ }
+ return i, nil
+}
+
+func (m *AuthUserGetRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthUserGetRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ return i, nil
+}
+
+func (m *AuthUserDeleteRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthUserDeleteRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ return i, nil
+}
+
+func (m *AuthUserChangePasswordRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthUserChangePasswordRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ if len(m.Password) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Password)))
+ i += copy(dAtA[i:], m.Password)
+ }
+ return i, nil
+}
+
+func (m *AuthUserGrantRoleRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthUserGrantRoleRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.User) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.User)))
+ i += copy(dAtA[i:], m.User)
+ }
+ if len(m.Role) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Role)))
+ i += copy(dAtA[i:], m.Role)
+ }
+ return i, nil
+}
+
+func (m *AuthUserRevokeRoleRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthUserRevokeRoleRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ if len(m.Role) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Role)))
+ i += copy(dAtA[i:], m.Role)
+ }
+ return i, nil
+}
+
+func (m *AuthRoleAddRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthRoleAddRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ return i, nil
+}
+
+func (m *AuthRoleGetRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthRoleGetRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Role) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Role)))
+ i += copy(dAtA[i:], m.Role)
+ }
+ return i, nil
+}
+
+func (m *AuthUserListRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthUserListRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ return i, nil
+}
+
+func (m *AuthRoleListRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthRoleListRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ return i, nil
+}
+
+func (m *AuthRoleDeleteRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthRoleDeleteRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Role) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Role)))
+ i += copy(dAtA[i:], m.Role)
+ }
+ return i, nil
+}
+
+func (m *AuthRoleGrantPermissionRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthRoleGrantPermissionRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Name) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
+ i += copy(dAtA[i:], m.Name)
+ }
+ if m.Perm != nil {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Perm.Size()))
+ n36, err := m.Perm.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n36
+ }
+ return i, nil
+}
+
+func (m *AuthRoleRevokePermissionRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthRoleRevokePermissionRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Role) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Role)))
+ i += copy(dAtA[i:], m.Role)
+ }
+ if len(m.Key) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Key)))
+ i += copy(dAtA[i:], m.Key)
+ }
+ if len(m.RangeEnd) > 0 {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.RangeEnd)))
+ i += copy(dAtA[i:], m.RangeEnd)
+ }
+ return i, nil
+}
+
+func (m *AuthEnableResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthEnableResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n37, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n37
+ }
+ return i, nil
+}
+
+func (m *AuthDisableResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthDisableResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n38, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n38
+ }
+ return i, nil
+}
+
+func (m *AuthenticateResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthenticateResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n39, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n39
+ }
+ if len(m.Token) > 0 {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(len(m.Token)))
+ i += copy(dAtA[i:], m.Token)
+ }
+ return i, nil
+}
+
+func (m *AuthUserAddResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthUserAddResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n40, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n40
+ }
+ return i, nil
+}
+
+func (m *AuthUserGetResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthUserGetResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n41, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n41
+ }
+ if len(m.Roles) > 0 {
+ for _, s := range m.Roles {
+ dAtA[i] = 0x12
+ i++
+ l = len(s)
+ for l >= 1<<7 {
+ dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
+ l >>= 7
+ i++
+ }
+ dAtA[i] = uint8(l)
+ i++
+ i += copy(dAtA[i:], s)
+ }
+ }
+ return i, nil
+}
+
+func (m *AuthUserDeleteResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthUserDeleteResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n42, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n42
+ }
+ return i, nil
+}
+
+func (m *AuthUserChangePasswordResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthUserChangePasswordResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n43, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n43
+ }
+ return i, nil
+}
+
+func (m *AuthUserGrantRoleResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthUserGrantRoleResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n44, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n44
+ }
+ return i, nil
+}
+
+func (m *AuthUserRevokeRoleResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthUserRevokeRoleResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n45, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n45
+ }
+ return i, nil
+}
+
+func (m *AuthRoleAddResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthRoleAddResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n46, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n46
+ }
+ return i, nil
+}
+
+func (m *AuthRoleGetResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthRoleGetResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n47, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n47
+ }
+ if len(m.Perm) > 0 {
+ for _, msg := range m.Perm {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ return i, nil
+}
+
+func (m *AuthRoleListResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthRoleListResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n48, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n48
+ }
+ if len(m.Roles) > 0 {
+ for _, s := range m.Roles {
+ dAtA[i] = 0x12
+ i++
+ l = len(s)
+ for l >= 1<<7 {
+ dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
+ l >>= 7
+ i++
+ }
+ dAtA[i] = uint8(l)
+ i++
+ i += copy(dAtA[i:], s)
+ }
+ }
+ return i, nil
+}
+
+func (m *AuthUserListResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthUserListResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n49, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n49
+ }
+ if len(m.Users) > 0 {
+ for _, s := range m.Users {
+ dAtA[i] = 0x12
+ i++
+ l = len(s)
+ for l >= 1<<7 {
+ dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
+ l >>= 7
+ i++
+ }
+ dAtA[i] = uint8(l)
+ i++
+ i += copy(dAtA[i:], s)
+ }
+ }
+ return i, nil
+}
+
+func (m *AuthRoleDeleteResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthRoleDeleteResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n50, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n50
+ }
+ return i, nil
+}
+
+func (m *AuthRoleGrantPermissionResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthRoleGrantPermissionResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n51, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n51
+ }
+ return i, nil
+}
+
+func (m *AuthRoleRevokePermissionResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *AuthRoleRevokePermissionResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Header != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
+ n52, err := m.Header.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n52
+ }
+ return i, nil
+}
+
+func encodeFixed64Rpc(dAtA []byte, offset int, v uint64) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ dAtA[offset+4] = uint8(v >> 32)
+ dAtA[offset+5] = uint8(v >> 40)
+ dAtA[offset+6] = uint8(v >> 48)
+ dAtA[offset+7] = uint8(v >> 56)
+ return offset + 8
+}
+func encodeFixed32Rpc(dAtA []byte, offset int, v uint32) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ return offset + 4
+}
+func encodeVarintRpc(dAtA []byte, offset int, v uint64) int {
+ for v >= 1<<7 {
+ dAtA[offset] = uint8(v&0x7f | 0x80)
+ v >>= 7
+ offset++
+ }
+ dAtA[offset] = uint8(v)
+ return offset + 1
+}
+func (m *ResponseHeader) Size() (n int) {
+ var l int
+ _ = l
+ if m.ClusterId != 0 {
+ n += 1 + sovRpc(uint64(m.ClusterId))
+ }
+ if m.MemberId != 0 {
+ n += 1 + sovRpc(uint64(m.MemberId))
+ }
+ if m.Revision != 0 {
+ n += 1 + sovRpc(uint64(m.Revision))
+ }
+ if m.RaftTerm != 0 {
+ n += 1 + sovRpc(uint64(m.RaftTerm))
+ }
+ return n
+}
+
+func (m *RangeRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Key)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ l = len(m.RangeEnd)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.Limit != 0 {
+ n += 1 + sovRpc(uint64(m.Limit))
+ }
+ if m.Revision != 0 {
+ n += 1 + sovRpc(uint64(m.Revision))
+ }
+ if m.SortOrder != 0 {
+ n += 1 + sovRpc(uint64(m.SortOrder))
+ }
+ if m.SortTarget != 0 {
+ n += 1 + sovRpc(uint64(m.SortTarget))
+ }
+ if m.Serializable {
+ n += 2
+ }
+ if m.KeysOnly {
+ n += 2
+ }
+ if m.CountOnly {
+ n += 2
+ }
+ if m.MinModRevision != 0 {
+ n += 1 + sovRpc(uint64(m.MinModRevision))
+ }
+ if m.MaxModRevision != 0 {
+ n += 1 + sovRpc(uint64(m.MaxModRevision))
+ }
+ if m.MinCreateRevision != 0 {
+ n += 1 + sovRpc(uint64(m.MinCreateRevision))
+ }
+ if m.MaxCreateRevision != 0 {
+ n += 1 + sovRpc(uint64(m.MaxCreateRevision))
+ }
+ return n
+}
+
+func (m *RangeResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if len(m.Kvs) > 0 {
+ for _, e := range m.Kvs {
+ l = e.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ if m.More {
+ n += 2
+ }
+ if m.Count != 0 {
+ n += 1 + sovRpc(uint64(m.Count))
+ }
+ return n
+}
+
+func (m *PutRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Key)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ l = len(m.Value)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.Lease != 0 {
+ n += 1 + sovRpc(uint64(m.Lease))
+ }
+ if m.PrevKv {
+ n += 2
+ }
+ if m.IgnoreValue {
+ n += 2
+ }
+ if m.IgnoreLease {
+ n += 2
+ }
+ return n
+}
+
+func (m *PutResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.PrevKv != nil {
+ l = m.PrevKv.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *DeleteRangeRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Key)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ l = len(m.RangeEnd)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.PrevKv {
+ n += 2
+ }
+ return n
+}
+
+func (m *DeleteRangeResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.Deleted != 0 {
+ n += 1 + sovRpc(uint64(m.Deleted))
+ }
+ if len(m.PrevKvs) > 0 {
+ for _, e := range m.PrevKvs {
+ l = e.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *RequestOp) Size() (n int) {
+ var l int
+ _ = l
+ if m.Request != nil {
+ n += m.Request.Size()
+ }
+ return n
+}
+
+func (m *RequestOp_RequestRange) Size() (n int) {
+ var l int
+ _ = l
+ if m.RequestRange != nil {
+ l = m.RequestRange.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+func (m *RequestOp_RequestPut) Size() (n int) {
+ var l int
+ _ = l
+ if m.RequestPut != nil {
+ l = m.RequestPut.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+func (m *RequestOp_RequestDeleteRange) Size() (n int) {
+ var l int
+ _ = l
+ if m.RequestDeleteRange != nil {
+ l = m.RequestDeleteRange.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+func (m *ResponseOp) Size() (n int) {
+ var l int
+ _ = l
+ if m.Response != nil {
+ n += m.Response.Size()
+ }
+ return n
+}
+
+func (m *ResponseOp_ResponseRange) Size() (n int) {
+ var l int
+ _ = l
+ if m.ResponseRange != nil {
+ l = m.ResponseRange.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+func (m *ResponseOp_ResponsePut) Size() (n int) {
+ var l int
+ _ = l
+ if m.ResponsePut != nil {
+ l = m.ResponsePut.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+func (m *ResponseOp_ResponseDeleteRange) Size() (n int) {
+ var l int
+ _ = l
+ if m.ResponseDeleteRange != nil {
+ l = m.ResponseDeleteRange.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+func (m *Compare) Size() (n int) {
+ var l int
+ _ = l
+ if m.Result != 0 {
+ n += 1 + sovRpc(uint64(m.Result))
+ }
+ if m.Target != 0 {
+ n += 1 + sovRpc(uint64(m.Target))
+ }
+ l = len(m.Key)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.TargetUnion != nil {
+ n += m.TargetUnion.Size()
+ }
+ return n
+}
+
+func (m *Compare_Version) Size() (n int) {
+ var l int
+ _ = l
+ n += 1 + sovRpc(uint64(m.Version))
+ return n
+}
+func (m *Compare_CreateRevision) Size() (n int) {
+ var l int
+ _ = l
+ n += 1 + sovRpc(uint64(m.CreateRevision))
+ return n
+}
+func (m *Compare_ModRevision) Size() (n int) {
+ var l int
+ _ = l
+ n += 1 + sovRpc(uint64(m.ModRevision))
+ return n
+}
+func (m *Compare_Value) Size() (n int) {
+ var l int
+ _ = l
+ if m.Value != nil {
+ l = len(m.Value)
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+func (m *TxnRequest) Size() (n int) {
+ var l int
+ _ = l
+ if len(m.Compare) > 0 {
+ for _, e := range m.Compare {
+ l = e.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ if len(m.Success) > 0 {
+ for _, e := range m.Success {
+ l = e.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ if len(m.Failure) > 0 {
+ for _, e := range m.Failure {
+ l = e.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *TxnResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.Succeeded {
+ n += 2
+ }
+ if len(m.Responses) > 0 {
+ for _, e := range m.Responses {
+ l = e.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *CompactionRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.Revision != 0 {
+ n += 1 + sovRpc(uint64(m.Revision))
+ }
+ if m.Physical {
+ n += 2
+ }
+ return n
+}
+
+func (m *CompactionResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *HashRequest) Size() (n int) {
+ var l int
+ _ = l
+ return n
+}
+
+func (m *HashResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.Hash != 0 {
+ n += 1 + sovRpc(uint64(m.Hash))
+ }
+ return n
+}
+
+func (m *SnapshotRequest) Size() (n int) {
+ var l int
+ _ = l
+ return n
+}
+
+func (m *SnapshotResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.RemainingBytes != 0 {
+ n += 1 + sovRpc(uint64(m.RemainingBytes))
+ }
+ l = len(m.Blob)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *WatchRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.RequestUnion != nil {
+ n += m.RequestUnion.Size()
+ }
+ return n
+}
+
+func (m *WatchRequest_CreateRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.CreateRequest != nil {
+ l = m.CreateRequest.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+func (m *WatchRequest_CancelRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.CancelRequest != nil {
+ l = m.CancelRequest.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+func (m *WatchCreateRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Key)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ l = len(m.RangeEnd)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.StartRevision != 0 {
+ n += 1 + sovRpc(uint64(m.StartRevision))
+ }
+ if m.ProgressNotify {
+ n += 2
+ }
+ if len(m.Filters) > 0 {
+ l = 0
+ for _, e := range m.Filters {
+ l += sovRpc(uint64(e))
+ }
+ n += 1 + sovRpc(uint64(l)) + l
+ }
+ if m.PrevKv {
+ n += 2
+ }
+ return n
+}
+
+func (m *WatchCancelRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.WatchId != 0 {
+ n += 1 + sovRpc(uint64(m.WatchId))
+ }
+ return n
+}
+
+func (m *WatchResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.WatchId != 0 {
+ n += 1 + sovRpc(uint64(m.WatchId))
+ }
+ if m.Created {
+ n += 2
+ }
+ if m.Canceled {
+ n += 2
+ }
+ if m.CompactRevision != 0 {
+ n += 1 + sovRpc(uint64(m.CompactRevision))
+ }
+ l = len(m.CancelReason)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if len(m.Events) > 0 {
+ for _, e := range m.Events {
+ l = e.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *LeaseGrantRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.TTL != 0 {
+ n += 1 + sovRpc(uint64(m.TTL))
+ }
+ if m.ID != 0 {
+ n += 1 + sovRpc(uint64(m.ID))
+ }
+ return n
+}
+
+func (m *LeaseGrantResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.ID != 0 {
+ n += 1 + sovRpc(uint64(m.ID))
+ }
+ if m.TTL != 0 {
+ n += 1 + sovRpc(uint64(m.TTL))
+ }
+ l = len(m.Error)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *LeaseRevokeRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.ID != 0 {
+ n += 1 + sovRpc(uint64(m.ID))
+ }
+ return n
+}
+
+func (m *LeaseRevokeResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *LeaseKeepAliveRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.ID != 0 {
+ n += 1 + sovRpc(uint64(m.ID))
+ }
+ return n
+}
+
+func (m *LeaseKeepAliveResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.ID != 0 {
+ n += 1 + sovRpc(uint64(m.ID))
+ }
+ if m.TTL != 0 {
+ n += 1 + sovRpc(uint64(m.TTL))
+ }
+ return n
+}
+
+func (m *LeaseTimeToLiveRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.ID != 0 {
+ n += 1 + sovRpc(uint64(m.ID))
+ }
+ if m.Keys {
+ n += 2
+ }
+ return n
+}
+
+func (m *LeaseTimeToLiveResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.ID != 0 {
+ n += 1 + sovRpc(uint64(m.ID))
+ }
+ if m.TTL != 0 {
+ n += 1 + sovRpc(uint64(m.TTL))
+ }
+ if m.GrantedTTL != 0 {
+ n += 1 + sovRpc(uint64(m.GrantedTTL))
+ }
+ if len(m.Keys) > 0 {
+ for _, b := range m.Keys {
+ l = len(b)
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *Member) Size() (n int) {
+ var l int
+ _ = l
+ if m.ID != 0 {
+ n += 1 + sovRpc(uint64(m.ID))
+ }
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if len(m.PeerURLs) > 0 {
+ for _, s := range m.PeerURLs {
+ l = len(s)
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ if len(m.ClientURLs) > 0 {
+ for _, s := range m.ClientURLs {
+ l = len(s)
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *MemberAddRequest) Size() (n int) {
+ var l int
+ _ = l
+ if len(m.PeerURLs) > 0 {
+ for _, s := range m.PeerURLs {
+ l = len(s)
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *MemberAddResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.Member != nil {
+ l = m.Member.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if len(m.Members) > 0 {
+ for _, e := range m.Members {
+ l = e.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *MemberRemoveRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.ID != 0 {
+ n += 1 + sovRpc(uint64(m.ID))
+ }
+ return n
+}
+
+func (m *MemberRemoveResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if len(m.Members) > 0 {
+ for _, e := range m.Members {
+ l = e.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *MemberUpdateRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.ID != 0 {
+ n += 1 + sovRpc(uint64(m.ID))
+ }
+ if len(m.PeerURLs) > 0 {
+ for _, s := range m.PeerURLs {
+ l = len(s)
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *MemberUpdateResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if len(m.Members) > 0 {
+ for _, e := range m.Members {
+ l = e.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *MemberListRequest) Size() (n int) {
+ var l int
+ _ = l
+ return n
+}
+
+func (m *MemberListResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if len(m.Members) > 0 {
+ for _, e := range m.Members {
+ l = e.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *DefragmentRequest) Size() (n int) {
+ var l int
+ _ = l
+ return n
+}
+
+func (m *DefragmentResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AlarmRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.Action != 0 {
+ n += 1 + sovRpc(uint64(m.Action))
+ }
+ if m.MemberID != 0 {
+ n += 1 + sovRpc(uint64(m.MemberID))
+ }
+ if m.Alarm != 0 {
+ n += 1 + sovRpc(uint64(m.Alarm))
+ }
+ return n
+}
+
+func (m *AlarmMember) Size() (n int) {
+ var l int
+ _ = l
+ if m.MemberID != 0 {
+ n += 1 + sovRpc(uint64(m.MemberID))
+ }
+ if m.Alarm != 0 {
+ n += 1 + sovRpc(uint64(m.Alarm))
+ }
+ return n
+}
+
+func (m *AlarmResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if len(m.Alarms) > 0 {
+ for _, e := range m.Alarms {
+ l = e.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *StatusRequest) Size() (n int) {
+ var l int
+ _ = l
+ return n
+}
+
+func (m *StatusResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ l = len(m.Version)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.DbSize != 0 {
+ n += 1 + sovRpc(uint64(m.DbSize))
+ }
+ if m.Leader != 0 {
+ n += 1 + sovRpc(uint64(m.Leader))
+ }
+ if m.RaftIndex != 0 {
+ n += 1 + sovRpc(uint64(m.RaftIndex))
+ }
+ if m.RaftTerm != 0 {
+ n += 1 + sovRpc(uint64(m.RaftTerm))
+ }
+ return n
+}
+
+func (m *AuthEnableRequest) Size() (n int) {
+ var l int
+ _ = l
+ return n
+}
+
+func (m *AuthDisableRequest) Size() (n int) {
+ var l int
+ _ = l
+ return n
+}
+
+func (m *AuthenticateRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ l = len(m.Password)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthUserAddRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ l = len(m.Password)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthUserGetRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthUserDeleteRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthUserChangePasswordRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ l = len(m.Password)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthUserGrantRoleRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.User)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ l = len(m.Role)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthUserRevokeRoleRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ l = len(m.Role)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthRoleAddRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthRoleGetRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Role)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthUserListRequest) Size() (n int) {
+ var l int
+ _ = l
+ return n
+}
+
+func (m *AuthRoleListRequest) Size() (n int) {
+ var l int
+ _ = l
+ return n
+}
+
+func (m *AuthRoleDeleteRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Role)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthRoleGrantPermissionRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Name)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if m.Perm != nil {
+ l = m.Perm.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthRoleRevokePermissionRequest) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Role)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ l = len(m.Key)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ l = len(m.RangeEnd)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthEnableResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthDisableResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthenticateResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ l = len(m.Token)
+ if l > 0 {
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthUserAddResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthUserGetResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if len(m.Roles) > 0 {
+ for _, s := range m.Roles {
+ l = len(s)
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *AuthUserDeleteResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthUserChangePasswordResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthUserGrantRoleResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthUserRevokeRoleResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthRoleAddResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthRoleGetResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if len(m.Perm) > 0 {
+ for _, e := range m.Perm {
+ l = e.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *AuthRoleListResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if len(m.Roles) > 0 {
+ for _, s := range m.Roles {
+ l = len(s)
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *AuthUserListResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ if len(m.Users) > 0 {
+ for _, s := range m.Users {
+ l = len(s)
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *AuthRoleDeleteResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthRoleGrantPermissionResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func (m *AuthRoleRevokePermissionResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.Header != nil {
+ l = m.Header.Size()
+ n += 1 + l + sovRpc(uint64(l))
+ }
+ return n
+}
+
+func sovRpc(x uint64) (n int) {
+ for {
+ n++
+ x >>= 7
+ if x == 0 {
+ break
+ }
+ }
+ return n
+}
+func sozRpc(x uint64) (n int) {
+ return sovRpc(uint64((x << 1) ^ uint64((int64(x) >> 63))))
+}
+func (m *ResponseHeader) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: ResponseHeader: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: ResponseHeader: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ClusterId", wireType)
+ }
+ m.ClusterId = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ClusterId |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field MemberId", wireType)
+ }
+ m.MemberId = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.MemberId |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType)
+ }
+ m.Revision = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Revision |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 4:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field RaftTerm", wireType)
+ }
+ m.RaftTerm = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.RaftTerm |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *RangeRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: RangeRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: RangeRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
+ if m.Key == nil {
+ m.Key = []byte{}
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field RangeEnd", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.RangeEnd = append(m.RangeEnd[:0], dAtA[iNdEx:postIndex]...)
+ if m.RangeEnd == nil {
+ m.RangeEnd = []byte{}
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType)
+ }
+ m.Limit = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Limit |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 4:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType)
+ }
+ m.Revision = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Revision |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 5:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field SortOrder", wireType)
+ }
+ m.SortOrder = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.SortOrder |= (RangeRequest_SortOrder(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 6:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field SortTarget", wireType)
+ }
+ m.SortTarget = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.SortTarget |= (RangeRequest_SortTarget(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 7:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Serializable", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Serializable = bool(v != 0)
+ case 8:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field KeysOnly", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.KeysOnly = bool(v != 0)
+ case 9:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field CountOnly", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.CountOnly = bool(v != 0)
+ case 10:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field MinModRevision", wireType)
+ }
+ m.MinModRevision = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.MinModRevision |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 11:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field MaxModRevision", wireType)
+ }
+ m.MaxModRevision = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.MaxModRevision |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 12:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field MinCreateRevision", wireType)
+ }
+ m.MinCreateRevision = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.MinCreateRevision |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 13:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field MaxCreateRevision", wireType)
+ }
+ m.MaxCreateRevision = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.MaxCreateRevision |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *RangeResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: RangeResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: RangeResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Kvs", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Kvs = append(m.Kvs, &mvccpb.KeyValue{})
+ if err := m.Kvs[len(m.Kvs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field More", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.More = bool(v != 0)
+ case 4:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType)
+ }
+ m.Count = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Count |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *PutRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: PutRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: PutRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
+ if m.Key == nil {
+ m.Key = []byte{}
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...)
+ if m.Value == nil {
+ m.Value = []byte{}
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Lease", wireType)
+ }
+ m.Lease = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Lease |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 4:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.PrevKv = bool(v != 0)
+ case 5:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field IgnoreValue", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.IgnoreValue = bool(v != 0)
+ case 6:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field IgnoreLease", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.IgnoreLease = bool(v != 0)
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *PutResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: PutResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: PutResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.PrevKv == nil {
+ m.PrevKv = &mvccpb.KeyValue{}
+ }
+ if err := m.PrevKv.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *DeleteRangeRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: DeleteRangeRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: DeleteRangeRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
+ if m.Key == nil {
+ m.Key = []byte{}
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field RangeEnd", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.RangeEnd = append(m.RangeEnd[:0], dAtA[iNdEx:postIndex]...)
+ if m.RangeEnd == nil {
+ m.RangeEnd = []byte{}
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.PrevKv = bool(v != 0)
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *DeleteRangeResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: DeleteRangeResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: DeleteRangeResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Deleted", wireType)
+ }
+ m.Deleted = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Deleted |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PrevKvs", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.PrevKvs = append(m.PrevKvs, &mvccpb.KeyValue{})
+ if err := m.PrevKvs[len(m.PrevKvs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *RequestOp) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: RequestOp: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: RequestOp: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field RequestRange", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := &RangeRequest{}
+ if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ m.Request = &RequestOp_RequestRange{v}
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field RequestPut", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := &PutRequest{}
+ if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ m.Request = &RequestOp_RequestPut{v}
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field RequestDeleteRange", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := &DeleteRangeRequest{}
+ if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ m.Request = &RequestOp_RequestDeleteRange{v}
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *ResponseOp) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: ResponseOp: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: ResponseOp: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ResponseRange", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := &RangeResponse{}
+ if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ m.Response = &ResponseOp_ResponseRange{v}
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ResponsePut", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := &PutResponse{}
+ if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ m.Response = &ResponseOp_ResponsePut{v}
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ResponseDeleteRange", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := &DeleteRangeResponse{}
+ if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ m.Response = &ResponseOp_ResponseDeleteRange{v}
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *Compare) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: Compare: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: Compare: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType)
+ }
+ m.Result = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Result |= (Compare_CompareResult(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType)
+ }
+ m.Target = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Target |= (Compare_CompareTarget(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
+ if m.Key == nil {
+ m.Key = []byte{}
+ }
+ iNdEx = postIndex
+ case 4:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType)
+ }
+ var v int64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.TargetUnion = &Compare_Version{v}
+ case 5:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field CreateRevision", wireType)
+ }
+ var v int64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.TargetUnion = &Compare_CreateRevision{v}
+ case 6:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ModRevision", wireType)
+ }
+ var v int64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.TargetUnion = &Compare_ModRevision{v}
+ case 7:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := make([]byte, postIndex-iNdEx)
+ copy(v, dAtA[iNdEx:postIndex])
+ m.TargetUnion = &Compare_Value{v}
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *TxnRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: TxnRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: TxnRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Compare", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Compare = append(m.Compare, &Compare{})
+ if err := m.Compare[len(m.Compare)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Success", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Success = append(m.Success, &RequestOp{})
+ if err := m.Success[len(m.Success)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Failure", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Failure = append(m.Failure, &RequestOp{})
+ if err := m.Failure[len(m.Failure)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *TxnResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: TxnResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: TxnResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Succeeded", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Succeeded = bool(v != 0)
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Responses", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Responses = append(m.Responses, &ResponseOp{})
+ if err := m.Responses[len(m.Responses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *CompactionRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: CompactionRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: CompactionRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType)
+ }
+ m.Revision = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Revision |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Physical", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Physical = bool(v != 0)
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *CompactionResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: CompactionResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: CompactionResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *HashRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: HashRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: HashRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *HashResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: HashResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: HashResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
+ }
+ m.Hash = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Hash |= (uint32(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *SnapshotRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: SnapshotRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: SnapshotRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *SnapshotResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: SnapshotResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: SnapshotResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field RemainingBytes", wireType)
+ }
+ m.RemainingBytes = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.RemainingBytes |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Blob", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Blob = append(m.Blob[:0], dAtA[iNdEx:postIndex]...)
+ if m.Blob == nil {
+ m.Blob = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *WatchRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: WatchRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: WatchRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field CreateRequest", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := &WatchCreateRequest{}
+ if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ m.RequestUnion = &WatchRequest_CreateRequest{v}
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field CancelRequest", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := &WatchCancelRequest{}
+ if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ m.RequestUnion = &WatchRequest_CancelRequest{v}
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *WatchCreateRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: WatchCreateRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: WatchCreateRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
+ if m.Key == nil {
+ m.Key = []byte{}
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field RangeEnd", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.RangeEnd = append(m.RangeEnd[:0], dAtA[iNdEx:postIndex]...)
+ if m.RangeEnd == nil {
+ m.RangeEnd = []byte{}
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field StartRevision", wireType)
+ }
+ m.StartRevision = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.StartRevision |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 4:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ProgressNotify", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.ProgressNotify = bool(v != 0)
+ case 5:
+ if wireType == 2 {
+ var packedLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ packedLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if packedLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + packedLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ for iNdEx < postIndex {
+ var v WatchCreateRequest_FilterType
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (WatchCreateRequest_FilterType(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Filters = append(m.Filters, v)
+ }
+ } else if wireType == 0 {
+ var v WatchCreateRequest_FilterType
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (WatchCreateRequest_FilterType(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Filters = append(m.Filters, v)
+ } else {
+ return fmt.Errorf("proto: wrong wireType = %d for field Filters", wireType)
+ }
+ case 6:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.PrevKv = bool(v != 0)
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *WatchCancelRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: WatchCancelRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: WatchCancelRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field WatchId", wireType)
+ }
+ m.WatchId = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.WatchId |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *WatchResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: WatchResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: WatchResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field WatchId", wireType)
+ }
+ m.WatchId = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.WatchId |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Created", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Created = bool(v != 0)
+ case 4:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Canceled", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Canceled = bool(v != 0)
+ case 5:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field CompactRevision", wireType)
+ }
+ m.CompactRevision = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.CompactRevision |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 6:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field CancelReason", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.CancelReason = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 11:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Events", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Events = append(m.Events, &mvccpb.Event{})
+ if err := m.Events[len(m.Events)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *LeaseGrantRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LeaseGrantRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LeaseGrantRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field TTL", wireType)
+ }
+ m.TTL = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.TTL |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *LeaseGrantResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LeaseGrantResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LeaseGrantResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field TTL", wireType)
+ }
+ m.TTL = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.TTL |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 4:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Error = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *LeaseRevokeRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LeaseRevokeRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LeaseRevokeRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *LeaseRevokeResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LeaseRevokeResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LeaseRevokeResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *LeaseKeepAliveRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LeaseKeepAliveRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LeaseKeepAliveRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *LeaseKeepAliveResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LeaseKeepAliveResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LeaseKeepAliveResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field TTL", wireType)
+ }
+ m.TTL = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.TTL |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *LeaseTimeToLiveRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LeaseTimeToLiveRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LeaseTimeToLiveRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Keys = bool(v != 0)
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *LeaseTimeToLiveResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LeaseTimeToLiveResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LeaseTimeToLiveResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field TTL", wireType)
+ }
+ m.TTL = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.TTL |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 4:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field GrantedTTL", wireType)
+ }
+ m.GrantedTTL = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.GrantedTTL |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 5:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Keys = append(m.Keys, make([]byte, postIndex-iNdEx))
+ copy(m.Keys[len(m.Keys)-1], dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *Member) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: Member: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: Member: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PeerURLs", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.PeerURLs = append(m.PeerURLs, string(dAtA[iNdEx:postIndex]))
+ iNdEx = postIndex
+ case 4:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ClientURLs", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.ClientURLs = append(m.ClientURLs, string(dAtA[iNdEx:postIndex]))
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *MemberAddRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: MemberAddRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: MemberAddRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PeerURLs", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.PeerURLs = append(m.PeerURLs, string(dAtA[iNdEx:postIndex]))
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *MemberAddResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: MemberAddResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: MemberAddResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Member", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Member == nil {
+ m.Member = &Member{}
+ }
+ if err := m.Member.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Members = append(m.Members, &Member{})
+ if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *MemberRemoveRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: MemberRemoveRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: MemberRemoveRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *MemberRemoveResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: MemberRemoveResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: MemberRemoveResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Members = append(m.Members, &Member{})
+ if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *MemberUpdateRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: MemberUpdateRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: MemberUpdateRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PeerURLs", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.PeerURLs = append(m.PeerURLs, string(dAtA[iNdEx:postIndex]))
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *MemberUpdateResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: MemberUpdateResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: MemberUpdateResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Members = append(m.Members, &Member{})
+ if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *MemberListRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: MemberListRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: MemberListRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *MemberListResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: MemberListResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: MemberListResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Members = append(m.Members, &Member{})
+ if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *DefragmentRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: DefragmentRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: DefragmentRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *DefragmentResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: DefragmentResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: DefragmentResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AlarmRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AlarmRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AlarmRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Action", wireType)
+ }
+ m.Action = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Action |= (AlarmRequest_AlarmAction(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field MemberID", wireType)
+ }
+ m.MemberID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.MemberID |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Alarm", wireType)
+ }
+ m.Alarm = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Alarm |= (AlarmType(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AlarmMember) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AlarmMember: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AlarmMember: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field MemberID", wireType)
+ }
+ m.MemberID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.MemberID |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Alarm", wireType)
+ }
+ m.Alarm = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Alarm |= (AlarmType(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AlarmResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AlarmResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AlarmResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Alarms", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Alarms = append(m.Alarms, &AlarmMember{})
+ if err := m.Alarms[len(m.Alarms)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *StatusRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: StatusRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: StatusRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *StatusResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: StatusResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: StatusResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Version = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field DbSize", wireType)
+ }
+ m.DbSize = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.DbSize |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 4:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Leader", wireType)
+ }
+ m.Leader = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Leader |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 5:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field RaftIndex", wireType)
+ }
+ m.RaftIndex = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.RaftIndex |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 6:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field RaftTerm", wireType)
+ }
+ m.RaftTerm = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.RaftTerm |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthEnableRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthEnableRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthEnableRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthDisableRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthDisableRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthDisableRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthenticateRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthenticateRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthenticateRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Password", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Password = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthUserAddRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthUserAddRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthUserAddRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Password", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Password = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthUserGetRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthUserGetRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthUserGetRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthUserDeleteRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthUserDeleteRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthUserDeleteRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthUserChangePasswordRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthUserChangePasswordRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthUserChangePasswordRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Password", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Password = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthUserGrantRoleRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthUserGrantRoleRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthUserGrantRoleRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field User", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.User = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Role = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthUserRevokeRoleRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthUserRevokeRoleRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthUserRevokeRoleRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Role = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthRoleAddRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthRoleAddRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthRoleAddRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthRoleGetRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthRoleGetRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthRoleGetRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Role = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthUserListRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthUserListRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthUserListRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthRoleListRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthRoleListRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthRoleListRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthRoleDeleteRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthRoleDeleteRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthRoleDeleteRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Role = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthRoleGrantPermissionRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthRoleGrantPermissionRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthRoleGrantPermissionRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Name = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Perm", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Perm == nil {
+ m.Perm = &authpb.Permission{}
+ }
+ if err := m.Perm.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthRoleRevokePermissionRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthRoleRevokePermissionRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthRoleRevokePermissionRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Role = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Key = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field RangeEnd", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.RangeEnd = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthEnableResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthEnableResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthEnableResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthDisableResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthDisableResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthDisableResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthenticateResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthenticateResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthenticateResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Token = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthUserAddResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthUserAddResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthUserAddResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthUserGetResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthUserGetResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthUserGetResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Roles", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Roles = append(m.Roles, string(dAtA[iNdEx:postIndex]))
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthUserDeleteResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthUserDeleteResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthUserDeleteResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthUserChangePasswordResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthUserChangePasswordResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthUserChangePasswordResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthUserGrantRoleResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthUserGrantRoleResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthUserGrantRoleResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthUserRevokeRoleResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthUserRevokeRoleResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthUserRevokeRoleResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthRoleAddResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthRoleAddResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthRoleAddResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthRoleGetResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthRoleGetResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthRoleGetResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Perm", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Perm = append(m.Perm, &authpb.Permission{})
+ if err := m.Perm[len(m.Perm)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthRoleListResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthRoleListResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthRoleListResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Roles", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Roles = append(m.Roles, string(dAtA[iNdEx:postIndex]))
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthUserListResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthUserListResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthUserListResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Users", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Users = append(m.Users, string(dAtA[iNdEx:postIndex]))
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthRoleDeleteResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthRoleDeleteResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthRoleDeleteResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthRoleGrantPermissionResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthRoleGrantPermissionResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthRoleGrantPermissionResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *AuthRoleRevokePermissionResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: AuthRoleRevokePermissionResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: AuthRoleRevokePermissionResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRpc
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Header == nil {
+ m.Header = &ResponseHeader{}
+ }
+ if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRpc(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRpc
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func skipRpc(dAtA []byte) (n int, err error) {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ wireType := int(wire & 0x7)
+ switch wireType {
+ case 0:
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ iNdEx++
+ if dAtA[iNdEx-1] < 0x80 {
+ break
+ }
+ }
+ return iNdEx, nil
+ case 1:
+ iNdEx += 8
+ return iNdEx, nil
+ case 2:
+ var length int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ length |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ iNdEx += length
+ if length < 0 {
+ return 0, ErrInvalidLengthRpc
+ }
+ return iNdEx, nil
+ case 3:
+ for {
+ var innerWire uint64
+ var start int = iNdEx
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRpc
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ innerWire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ innerWireType := int(innerWire & 0x7)
+ if innerWireType == 4 {
+ break
+ }
+ next, err := skipRpc(dAtA[start:])
+ if err != nil {
+ return 0, err
+ }
+ iNdEx = start + next
+ }
+ return iNdEx, nil
+ case 4:
+ return iNdEx, nil
+ case 5:
+ iNdEx += 4
+ return iNdEx, nil
+ default:
+ return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
+ }
+ }
+ panic("unreachable")
+}
+
+var (
+ ErrInvalidLengthRpc = fmt.Errorf("proto: negative length found during unmarshaling")
+ ErrIntOverflowRpc = fmt.Errorf("proto: integer overflow")
+)
+
+func init() { proto.RegisterFile("rpc.proto", fileDescriptorRpc) }
+
+var fileDescriptorRpc = []byte{
+ // 3450 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x3b, 0x5b, 0x6f, 0x1b, 0xc7,
+ 0xb9, 0x5a, 0x5e, 0xc5, 0x8f, 0x17, 0xd1, 0x23, 0xd9, 0xa6, 0x68, 0x5b, 0x96, 0xc7, 0x37, 0xd9,
+ 0x4e, 0xa4, 0x44, 0xc9, 0x39, 0x0f, 0x3e, 0x41, 0x70, 0x64, 0x89, 0xb1, 0x74, 0x24, 0x4b, 0xce,
+ 0x4a, 0x76, 0x72, 0x80, 0xa0, 0xc4, 0x8a, 0x1c, 0x53, 0x0b, 0x91, 0xbb, 0xcc, 0xee, 0x92, 0x96,
+ 0xd2, 0x14, 0x28, 0xd2, 0x04, 0x45, 0x0b, 0xf4, 0xa5, 0x79, 0xe8, 0xed, 0xb1, 0x28, 0x8a, 0xfc,
+ 0x80, 0xbe, 0xf5, 0x07, 0x14, 0x7d, 0x69, 0x81, 0xfe, 0x81, 0x22, 0xed, 0x63, 0xdf, 0xfb, 0x54,
+ 0xb4, 0x98, 0xdb, 0xee, 0xec, 0x72, 0x97, 0x52, 0xca, 0x26, 0x2f, 0xd6, 0xce, 0x37, 0xdf, 0x7c,
+ 0xb7, 0x99, 0xef, 0x32, 0xdf, 0xd0, 0x50, 0x70, 0xfa, 0xad, 0xe5, 0xbe, 0x63, 0x7b, 0x36, 0x2a,
+ 0x11, 0xaf, 0xd5, 0x76, 0x89, 0x33, 0x24, 0x4e, 0xff, 0xb0, 0x3e, 0xd7, 0xb1, 0x3b, 0x36, 0x9b,
+ 0x58, 0xa1, 0x5f, 0x1c, 0xa7, 0x3e, 0x4f, 0x71, 0x56, 0x7a, 0xc3, 0x56, 0x8b, 0xfd, 0xd3, 0x3f,
+ 0x5c, 0x39, 0x1e, 0x8a, 0xa9, 0x2b, 0x6c, 0xca, 0x18, 0x78, 0x47, 0xec, 0x9f, 0xfe, 0x21, 0xfb,
+ 0x23, 0x26, 0xaf, 0x76, 0x6c, 0xbb, 0xd3, 0x25, 0x2b, 0x46, 0xdf, 0x5c, 0x31, 0x2c, 0xcb, 0xf6,
+ 0x0c, 0xcf, 0xb4, 0x2d, 0x97, 0xcf, 0xe2, 0xcf, 0x34, 0xa8, 0xe8, 0xc4, 0xed, 0xdb, 0x96, 0x4b,
+ 0x36, 0x89, 0xd1, 0x26, 0x0e, 0xba, 0x06, 0xd0, 0xea, 0x0e, 0x5c, 0x8f, 0x38, 0x4d, 0xb3, 0x5d,
+ 0xd3, 0x16, 0xb5, 0xa5, 0x8c, 0x5e, 0x10, 0x90, 0xad, 0x36, 0xba, 0x02, 0x85, 0x1e, 0xe9, 0x1d,
+ 0xf2, 0xd9, 0x14, 0x9b, 0x9d, 0xe6, 0x80, 0xad, 0x36, 0xaa, 0xc3, 0xb4, 0x43, 0x86, 0xa6, 0x6b,
+ 0xda, 0x56, 0x2d, 0xbd, 0xa8, 0x2d, 0xa5, 0x75, 0x7f, 0x4c, 0x17, 0x3a, 0xc6, 0x0b, 0xaf, 0xe9,
+ 0x11, 0xa7, 0x57, 0xcb, 0xf0, 0x85, 0x14, 0x70, 0x40, 0x9c, 0x1e, 0xfe, 0x34, 0x0b, 0x25, 0xdd,
+ 0xb0, 0x3a, 0x44, 0x27, 0x1f, 0x0e, 0x88, 0xeb, 0xa1, 0x2a, 0xa4, 0x8f, 0xc9, 0x29, 0x63, 0x5f,
+ 0xd2, 0xe9, 0x27, 0x5f, 0x6f, 0x75, 0x48, 0x93, 0x58, 0x9c, 0x71, 0x89, 0xae, 0xb7, 0x3a, 0xa4,
+ 0x61, 0xb5, 0xd1, 0x1c, 0x64, 0xbb, 0x66, 0xcf, 0xf4, 0x04, 0x57, 0x3e, 0x08, 0x89, 0x93, 0x89,
+ 0x88, 0xb3, 0x0e, 0xe0, 0xda, 0x8e, 0xd7, 0xb4, 0x9d, 0x36, 0x71, 0x6a, 0xd9, 0x45, 0x6d, 0xa9,
+ 0xb2, 0x7a, 0x6b, 0x59, 0xdd, 0x88, 0x65, 0x55, 0xa0, 0xe5, 0x7d, 0xdb, 0xf1, 0xf6, 0x28, 0xae,
+ 0x5e, 0x70, 0xe5, 0x27, 0x7a, 0x07, 0x8a, 0x8c, 0x88, 0x67, 0x38, 0x1d, 0xe2, 0xd5, 0x72, 0x8c,
+ 0xca, 0xed, 0x33, 0xa8, 0x1c, 0x30, 0x64, 0x9d, 0xb1, 0xe7, 0xdf, 0x08, 0x43, 0xc9, 0x25, 0x8e,
+ 0x69, 0x74, 0xcd, 0x8f, 0x8c, 0xc3, 0x2e, 0xa9, 0xe5, 0x17, 0xb5, 0xa5, 0x69, 0x3d, 0x04, 0xa3,
+ 0xfa, 0x1f, 0x93, 0x53, 0xb7, 0x69, 0x5b, 0xdd, 0xd3, 0xda, 0x34, 0x43, 0x98, 0xa6, 0x80, 0x3d,
+ 0xab, 0x7b, 0xca, 0x36, 0xcd, 0x1e, 0x58, 0x1e, 0x9f, 0x2d, 0xb0, 0xd9, 0x02, 0x83, 0xb0, 0xe9,
+ 0x25, 0xa8, 0xf6, 0x4c, 0xab, 0xd9, 0xb3, 0xdb, 0x4d, 0xdf, 0x20, 0xc0, 0x0c, 0x52, 0xe9, 0x99,
+ 0xd6, 0x13, 0xbb, 0xad, 0x4b, 0xb3, 0x50, 0x4c, 0xe3, 0x24, 0x8c, 0x59, 0x14, 0x98, 0xc6, 0x89,
+ 0x8a, 0xb9, 0x0c, 0xb3, 0x94, 0x66, 0xcb, 0x21, 0x86, 0x47, 0x02, 0xe4, 0x12, 0x43, 0xbe, 0xd0,
+ 0x33, 0xad, 0x75, 0x36, 0x13, 0xc2, 0x37, 0x4e, 0x46, 0xf0, 0xcb, 0x02, 0xdf, 0x38, 0x09, 0xe3,
+ 0xe3, 0x65, 0x28, 0xf8, 0x36, 0x47, 0xd3, 0x90, 0xd9, 0xdd, 0xdb, 0x6d, 0x54, 0xa7, 0x10, 0x40,
+ 0x6e, 0x6d, 0x7f, 0xbd, 0xb1, 0xbb, 0x51, 0xd5, 0x50, 0x11, 0xf2, 0x1b, 0x0d, 0x3e, 0x48, 0xe1,
+ 0x47, 0x00, 0x81, 0x75, 0x51, 0x1e, 0xd2, 0xdb, 0x8d, 0xff, 0xaf, 0x4e, 0x51, 0x9c, 0xe7, 0x0d,
+ 0x7d, 0x7f, 0x6b, 0x6f, 0xb7, 0xaa, 0xd1, 0xc5, 0xeb, 0x7a, 0x63, 0xed, 0xa0, 0x51, 0x4d, 0x51,
+ 0x8c, 0x27, 0x7b, 0x1b, 0xd5, 0x34, 0x2a, 0x40, 0xf6, 0xf9, 0xda, 0xce, 0xb3, 0x46, 0x35, 0x83,
+ 0x3f, 0xd7, 0xa0, 0x2c, 0xf6, 0x8b, 0xfb, 0x04, 0x7a, 0x13, 0x72, 0x47, 0xcc, 0x2f, 0xd8, 0x51,
+ 0x2c, 0xae, 0x5e, 0x8d, 0x6c, 0x6e, 0xc8, 0x77, 0x74, 0x81, 0x8b, 0x30, 0xa4, 0x8f, 0x87, 0x6e,
+ 0x2d, 0xb5, 0x98, 0x5e, 0x2a, 0xae, 0x56, 0x97, 0xb9, 0xc3, 0x2e, 0x6f, 0x93, 0xd3, 0xe7, 0x46,
+ 0x77, 0x40, 0x74, 0x3a, 0x89, 0x10, 0x64, 0x7a, 0xb6, 0x43, 0xd8, 0x89, 0x9d, 0xd6, 0xd9, 0x37,
+ 0x3d, 0xc6, 0x6c, 0xd3, 0xc4, 0x69, 0xe5, 0x03, 0xfc, 0x85, 0x06, 0xf0, 0x74, 0xe0, 0x25, 0xbb,
+ 0xc6, 0x1c, 0x64, 0x87, 0x94, 0xb0, 0x70, 0x0b, 0x3e, 0x60, 0x3e, 0x41, 0x0c, 0x97, 0xf8, 0x3e,
+ 0x41, 0x07, 0xe8, 0x32, 0xe4, 0xfb, 0x0e, 0x19, 0x36, 0x8f, 0x87, 0x8c, 0xc9, 0xb4, 0x9e, 0xa3,
+ 0xc3, 0xed, 0x21, 0xba, 0x01, 0x25, 0xb3, 0x63, 0xd9, 0x0e, 0x69, 0x72, 0x5a, 0x59, 0x36, 0x5b,
+ 0xe4, 0x30, 0x26, 0xb7, 0x82, 0xc2, 0x09, 0xe7, 0x54, 0x94, 0x1d, 0x0a, 0xc2, 0x16, 0x14, 0x99,
+ 0xa8, 0x13, 0x99, 0xef, 0x5e, 0x20, 0x63, 0x8a, 0x2d, 0x1b, 0x35, 0xa1, 0x90, 0x1a, 0x7f, 0x00,
+ 0x68, 0x83, 0x74, 0x89, 0x47, 0x26, 0x89, 0x1e, 0x8a, 0x4d, 0xd2, 0xaa, 0x4d, 0xf0, 0x8f, 0x35,
+ 0x98, 0x0d, 0x91, 0x9f, 0x48, 0xad, 0x1a, 0xe4, 0xdb, 0x8c, 0x18, 0x97, 0x20, 0xad, 0xcb, 0x21,
+ 0x7a, 0x00, 0xd3, 0x42, 0x00, 0xb7, 0x96, 0x4e, 0x38, 0x34, 0x79, 0x2e, 0x93, 0x8b, 0xff, 0xa6,
+ 0x41, 0x41, 0x28, 0xba, 0xd7, 0x47, 0x6b, 0x50, 0x76, 0xf8, 0xa0, 0xc9, 0xf4, 0x11, 0x12, 0xd5,
+ 0x93, 0x83, 0xd0, 0xe6, 0x94, 0x5e, 0x12, 0x4b, 0x18, 0x18, 0xfd, 0x0f, 0x14, 0x25, 0x89, 0xfe,
+ 0xc0, 0x13, 0x26, 0xaf, 0x85, 0x09, 0x04, 0xe7, 0x6f, 0x73, 0x4a, 0x07, 0x81, 0xfe, 0x74, 0xe0,
+ 0xa1, 0x03, 0x98, 0x93, 0x8b, 0xb9, 0x36, 0x42, 0x8c, 0x34, 0xa3, 0xb2, 0x18, 0xa6, 0x32, 0xba,
+ 0x55, 0x9b, 0x53, 0x3a, 0x12, 0xeb, 0x95, 0xc9, 0x47, 0x05, 0xc8, 0x0b, 0x28, 0xfe, 0xbb, 0x06,
+ 0x20, 0x0d, 0xba, 0xd7, 0x47, 0x1b, 0x50, 0x71, 0xc4, 0x28, 0xa4, 0xf0, 0x95, 0x58, 0x85, 0xc5,
+ 0x3e, 0x4c, 0xe9, 0x65, 0xb9, 0x88, 0xab, 0xfc, 0x36, 0x94, 0x7c, 0x2a, 0x81, 0xce, 0xf3, 0x31,
+ 0x3a, 0xfb, 0x14, 0x8a, 0x72, 0x01, 0xd5, 0xfa, 0x3d, 0xb8, 0xe8, 0xaf, 0x8f, 0x51, 0xfb, 0xc6,
+ 0x18, 0xb5, 0x7d, 0x82, 0xb3, 0x92, 0x82, 0xaa, 0x38, 0xd0, 0x94, 0xc5, 0xc1, 0xf8, 0x8b, 0x34,
+ 0xe4, 0xd7, 0xed, 0x5e, 0xdf, 0x70, 0xe8, 0x1e, 0xe5, 0x1c, 0xe2, 0x0e, 0xba, 0x1e, 0x53, 0xb7,
+ 0xb2, 0x7a, 0x33, 0xcc, 0x41, 0xa0, 0xc9, 0xbf, 0x3a, 0x43, 0xd5, 0xc5, 0x12, 0xba, 0x58, 0x64,
+ 0xa8, 0xd4, 0x39, 0x16, 0x8b, 0xfc, 0x24, 0x96, 0x48, 0x5f, 0x4a, 0x07, 0xbe, 0x54, 0x87, 0xfc,
+ 0x90, 0x38, 0x41, 0x56, 0xdd, 0x9c, 0xd2, 0x25, 0x00, 0xdd, 0x83, 0x99, 0x68, 0x84, 0xcf, 0x0a,
+ 0x9c, 0x4a, 0x2b, 0x9c, 0x10, 0x6e, 0x42, 0x29, 0x94, 0x66, 0x72, 0x02, 0xaf, 0xd8, 0x53, 0xb2,
+ 0xcc, 0x25, 0x19, 0xda, 0x68, 0x4a, 0x2c, 0x6d, 0x4e, 0x89, 0xe0, 0x86, 0xff, 0x17, 0xca, 0x21,
+ 0x5d, 0x69, 0x14, 0x6f, 0xbc, 0xfb, 0x6c, 0x6d, 0x87, 0x87, 0xfc, 0xc7, 0x2c, 0xca, 0xeb, 0x55,
+ 0x8d, 0x66, 0x8e, 0x9d, 0xc6, 0xfe, 0x7e, 0x35, 0x85, 0xca, 0x50, 0xd8, 0xdd, 0x3b, 0x68, 0x72,
+ 0xac, 0x34, 0x7e, 0xcb, 0xa7, 0x20, 0x52, 0x86, 0x92, 0x29, 0xa6, 0x94, 0x4c, 0xa1, 0xc9, 0x4c,
+ 0x91, 0x0a, 0x32, 0x45, 0xfa, 0x51, 0x05, 0x4a, 0xdc, 0x3e, 0xcd, 0x81, 0x45, 0xb3, 0xd5, 0x2f,
+ 0x35, 0x80, 0x83, 0x13, 0x4b, 0x06, 0xa0, 0x15, 0xc8, 0xb7, 0x38, 0xf1, 0x9a, 0xc6, 0xfc, 0xf9,
+ 0x62, 0xac, 0xc9, 0x75, 0x89, 0x85, 0x5e, 0x87, 0xbc, 0x3b, 0x68, 0xb5, 0x88, 0x2b, 0xb3, 0xc6,
+ 0xe5, 0x68, 0x48, 0x11, 0x0e, 0xaf, 0x4b, 0x3c, 0xba, 0xe4, 0x85, 0x61, 0x76, 0x07, 0x2c, 0x87,
+ 0x8c, 0x5f, 0x22, 0xf0, 0xf0, 0xcf, 0x34, 0x28, 0x32, 0x29, 0x27, 0x8a, 0x63, 0x57, 0xa1, 0xc0,
+ 0x64, 0x20, 0x6d, 0x11, 0xc9, 0xa6, 0xf5, 0x00, 0x80, 0xfe, 0x1b, 0x0a, 0xf2, 0x04, 0xcb, 0x60,
+ 0x56, 0x8b, 0x27, 0xbb, 0xd7, 0xd7, 0x03, 0x54, 0xbc, 0x0d, 0x17, 0x98, 0x55, 0x5a, 0xb4, 0x3e,
+ 0x95, 0x76, 0x54, 0x2b, 0x38, 0x2d, 0x52, 0xc1, 0xd5, 0x61, 0xba, 0x7f, 0x74, 0xea, 0x9a, 0x2d,
+ 0xa3, 0x2b, 0xa4, 0xf0, 0xc7, 0xf8, 0xff, 0x00, 0xa9, 0xc4, 0x26, 0x51, 0x17, 0x97, 0xa1, 0xb8,
+ 0x69, 0xb8, 0x47, 0x42, 0x24, 0xfc, 0x3e, 0x94, 0xf8, 0x70, 0x22, 0x1b, 0x22, 0xc8, 0x1c, 0x19,
+ 0xee, 0x11, 0x13, 0xbc, 0xac, 0xb3, 0x6f, 0x7c, 0x01, 0x66, 0xf6, 0x2d, 0xa3, 0xef, 0x1e, 0xd9,
+ 0x32, 0xd6, 0xd2, 0xfa, 0xbc, 0x1a, 0xc0, 0x26, 0xe2, 0x78, 0x17, 0x66, 0x1c, 0xd2, 0x33, 0x4c,
+ 0xcb, 0xb4, 0x3a, 0xcd, 0xc3, 0x53, 0x8f, 0xb8, 0xa2, 0x7c, 0xaf, 0xf8, 0xe0, 0x47, 0x14, 0x4a,
+ 0x45, 0x3b, 0xec, 0xda, 0x87, 0xc2, 0xe3, 0xd9, 0x37, 0xfe, 0x8d, 0x06, 0xa5, 0xf7, 0x0c, 0xaf,
+ 0x25, 0xad, 0x80, 0xb6, 0xa0, 0xe2, 0xfb, 0x39, 0x83, 0x08, 0x59, 0x22, 0x01, 0x9f, 0xad, 0x91,
+ 0x85, 0x9d, 0x0c, 0xf8, 0xe5, 0x96, 0x0a, 0x60, 0xa4, 0x0c, 0xab, 0x45, 0xba, 0x3e, 0xa9, 0x54,
+ 0x32, 0x29, 0x86, 0xa8, 0x92, 0x52, 0x01, 0x8f, 0x66, 0x82, 0x64, 0xc8, 0xdd, 0xf2, 0xe7, 0x29,
+ 0x40, 0xa3, 0x32, 0x7c, 0xd5, 0xfa, 0xe0, 0x36, 0x54, 0x5c, 0xcf, 0x70, 0xbc, 0x66, 0xe4, 0x72,
+ 0x53, 0x66, 0x50, 0x3f, 0x56, 0xdd, 0x85, 0x99, 0xbe, 0x63, 0x77, 0x1c, 0xe2, 0xba, 0x4d, 0xcb,
+ 0xf6, 0xcc, 0x17, 0xa7, 0xa2, 0xc4, 0xaa, 0x48, 0xf0, 0x2e, 0x83, 0xa2, 0x06, 0xe4, 0x5f, 0x98,
+ 0x5d, 0x8f, 0x38, 0x6e, 0x2d, 0xbb, 0x98, 0x5e, 0xaa, 0xac, 0x3e, 0x38, 0xcb, 0x6a, 0xcb, 0xef,
+ 0x30, 0xfc, 0x83, 0xd3, 0x3e, 0xd1, 0xe5, 0x5a, 0xb5, 0x6c, 0xc9, 0x85, 0xca, 0x96, 0xdb, 0x00,
+ 0x01, 0x3e, 0x8d, 0x5a, 0xbb, 0x7b, 0x4f, 0x9f, 0x1d, 0x54, 0xa7, 0x50, 0x09, 0xa6, 0x77, 0xf7,
+ 0x36, 0x1a, 0x3b, 0x0d, 0x1a, 0xd7, 0xf0, 0x8a, 0xb4, 0x8d, 0x6a, 0x43, 0x34, 0x0f, 0xd3, 0x2f,
+ 0x29, 0x54, 0xde, 0xfe, 0xd2, 0x7a, 0x9e, 0x8d, 0xb7, 0xda, 0xf8, 0x47, 0x29, 0x28, 0x8b, 0x53,
+ 0x30, 0xd1, 0x51, 0x54, 0x59, 0xa4, 0x42, 0x2c, 0x68, 0x8d, 0xc4, 0x4f, 0x47, 0x5b, 0x94, 0x62,
+ 0x72, 0x48, 0xdd, 0x9d, 0x6f, 0x36, 0x69, 0x0b, 0xb3, 0xfa, 0x63, 0x74, 0x0f, 0xaa, 0x2d, 0xee,
+ 0xee, 0x91, 0xb4, 0xa3, 0xcf, 0x08, 0xb8, 0x92, 0x75, 0xca, 0xfe, 0x69, 0x33, 0x5c, 0x91, 0x76,
+ 0x0a, 0x7a, 0x49, 0x1e, 0x24, 0x0a, 0x43, 0xb7, 0x21, 0x47, 0x86, 0xc4, 0xf2, 0xdc, 0x5a, 0x91,
+ 0x05, 0xb0, 0xb2, 0xac, 0xc6, 0x1a, 0x14, 0xaa, 0x8b, 0x49, 0xfc, 0x5f, 0x70, 0x81, 0x55, 0xbd,
+ 0x8f, 0x1d, 0xc3, 0x52, 0xcb, 0xf3, 0x83, 0x83, 0x1d, 0x61, 0x3a, 0xfa, 0x89, 0x2a, 0x90, 0xda,
+ 0xda, 0x10, 0x8a, 0xa6, 0xb6, 0x36, 0xf0, 0x27, 0x1a, 0x20, 0x75, 0xdd, 0x44, 0xb6, 0x8c, 0x10,
+ 0x97, 0xec, 0xd3, 0x01, 0xfb, 0x39, 0xc8, 0x12, 0xc7, 0xb1, 0x1d, 0x66, 0xb5, 0x82, 0xce, 0x07,
+ 0xf8, 0x96, 0x90, 0x41, 0x27, 0x43, 0xfb, 0xd8, 0x77, 0x0c, 0x4e, 0x4d, 0xf3, 0x45, 0xdd, 0x86,
+ 0xd9, 0x10, 0xd6, 0x44, 0x81, 0xf4, 0x2e, 0x5c, 0x64, 0xc4, 0xb6, 0x09, 0xe9, 0xaf, 0x75, 0xcd,
+ 0x61, 0x22, 0xd7, 0x3e, 0x5c, 0x8a, 0x22, 0x7e, 0xbd, 0x36, 0xc2, 0x6f, 0x09, 0x8e, 0x07, 0x66,
+ 0x8f, 0x1c, 0xd8, 0x3b, 0xc9, 0xb2, 0xd1, 0xe8, 0x48, 0x6f, 0xdd, 0x22, 0xe3, 0xb0, 0x6f, 0xfc,
+ 0x2b, 0x0d, 0x2e, 0x8f, 0x2c, 0xff, 0x9a, 0x77, 0x75, 0x01, 0xa0, 0x43, 0x8f, 0x0f, 0x69, 0xd3,
+ 0x09, 0x7e, 0x5f, 0x54, 0x20, 0xbe, 0x9c, 0x34, 0xc0, 0x94, 0x84, 0x9c, 0x47, 0x90, 0x7b, 0xc2,
+ 0x5a, 0x35, 0x8a, 0x56, 0x19, 0xa9, 0x95, 0x65, 0xf4, 0xf8, 0x05, 0xb2, 0xa0, 0xb3, 0x6f, 0x96,
+ 0x5f, 0x09, 0x71, 0x9e, 0xe9, 0x3b, 0x3c, 0x8f, 0x17, 0x74, 0x7f, 0x4c, 0xb9, 0xb7, 0xba, 0x26,
+ 0xb1, 0x3c, 0x36, 0x9b, 0x61, 0xb3, 0x0a, 0x04, 0x2f, 0x43, 0x95, 0x73, 0x5a, 0x6b, 0xb7, 0x95,
+ 0x5c, 0xee, 0xd3, 0xd3, 0xc2, 0xf4, 0xf0, 0xaf, 0x35, 0xb8, 0xa0, 0x2c, 0x98, 0xc8, 0x76, 0xaf,
+ 0x40, 0x8e, 0x37, 0xa4, 0x44, 0x1e, 0x99, 0x0b, 0xaf, 0xe2, 0x6c, 0x74, 0x81, 0x83, 0x96, 0x21,
+ 0xcf, 0xbf, 0x64, 0xb1, 0x12, 0x8f, 0x2e, 0x91, 0xf0, 0x6d, 0x98, 0x15, 0x20, 0xd2, 0xb3, 0xe3,
+ 0x8e, 0x09, 0x33, 0x28, 0xfe, 0x18, 0xe6, 0xc2, 0x68, 0x13, 0xa9, 0xa4, 0x08, 0x99, 0x3a, 0x8f,
+ 0x90, 0x6b, 0x52, 0xc8, 0x67, 0xfd, 0xb6, 0x92, 0xf6, 0xa2, 0xbb, 0xae, 0xee, 0x48, 0x2a, 0xb2,
+ 0x23, 0xbe, 0x02, 0x92, 0xc4, 0x37, 0xaa, 0xc0, 0xac, 0x3c, 0x0e, 0x3b, 0xa6, 0xeb, 0x17, 0x43,
+ 0x1f, 0x01, 0x52, 0x81, 0xdf, 0xb4, 0x40, 0x1b, 0xe4, 0x85, 0x63, 0x74, 0x7a, 0xc4, 0x0f, 0xf5,
+ 0xb4, 0xca, 0x54, 0x81, 0x13, 0x05, 0xc7, 0x3f, 0x68, 0x50, 0x5a, 0xeb, 0x1a, 0x4e, 0x4f, 0x6e,
+ 0xd6, 0xdb, 0x90, 0xe3, 0xe5, 0xab, 0xb8, 0xf1, 0xdd, 0x09, 0x93, 0x51, 0x71, 0xf9, 0x60, 0x8d,
+ 0x17, 0xbb, 0x62, 0x15, 0xdd, 0x5c, 0xd1, 0x97, 0xdd, 0x88, 0xf4, 0x69, 0x37, 0xd0, 0xab, 0x90,
+ 0x35, 0xe8, 0x12, 0x16, 0x50, 0x2a, 0xd1, 0x8b, 0x03, 0xa3, 0xc6, 0x4a, 0x0d, 0x8e, 0x85, 0xdf,
+ 0x84, 0xa2, 0xc2, 0x81, 0xde, 0x87, 0x1e, 0x37, 0x44, 0x39, 0xb1, 0xb6, 0x7e, 0xb0, 0xf5, 0x9c,
+ 0x5f, 0x93, 0x2a, 0x00, 0x1b, 0x0d, 0x7f, 0x9c, 0xc2, 0xef, 0x8b, 0x55, 0x22, 0xe4, 0xa8, 0xf2,
+ 0x68, 0x49, 0xf2, 0xa4, 0xce, 0x25, 0xcf, 0x09, 0x94, 0x85, 0xfa, 0x13, 0x9d, 0x81, 0xd7, 0x21,
+ 0xc7, 0xe8, 0xc9, 0x23, 0x30, 0x1f, 0xc3, 0x56, 0x46, 0x0b, 0x8e, 0x88, 0x67, 0xa0, 0xbc, 0xef,
+ 0x19, 0xde, 0xc0, 0x95, 0x47, 0xe0, 0xf7, 0x1a, 0x54, 0x24, 0x64, 0xd2, 0xe6, 0x90, 0xbc, 0x54,
+ 0xf3, 0x20, 0xec, 0x5f, 0xa9, 0x2f, 0x41, 0xae, 0x7d, 0xb8, 0x6f, 0x7e, 0x24, 0x1b, 0x79, 0x62,
+ 0x44, 0xe1, 0x5d, 0xce, 0x87, 0x77, 0xd3, 0xc5, 0x88, 0x5e, 0xcf, 0x1c, 0xe3, 0x85, 0xb7, 0x65,
+ 0xb5, 0xc9, 0x09, 0xab, 0x82, 0x32, 0x7a, 0x00, 0x60, 0x37, 0x2a, 0xd1, 0x75, 0x67, 0xa5, 0x8f,
+ 0xda, 0x85, 0x9f, 0x85, 0x0b, 0x6b, 0x03, 0xef, 0xa8, 0x61, 0x19, 0x87, 0x5d, 0x19, 0x34, 0xf0,
+ 0x1c, 0x20, 0x0a, 0xdc, 0x30, 0x5d, 0x15, 0xda, 0x80, 0x59, 0x0a, 0x25, 0x96, 0x67, 0xb6, 0x94,
+ 0x08, 0x23, 0xf3, 0x88, 0x16, 0xc9, 0x23, 0x86, 0xeb, 0xbe, 0xb4, 0x9d, 0xb6, 0x50, 0xcd, 0x1f,
+ 0xe3, 0x0d, 0x4e, 0xfc, 0x99, 0x1b, 0xca, 0x14, 0x5f, 0x95, 0xca, 0x52, 0x40, 0xe5, 0x31, 0xf1,
+ 0xc6, 0x50, 0xc1, 0x0f, 0xe0, 0xa2, 0xc4, 0x14, 0x5d, 0x97, 0x31, 0xc8, 0x7b, 0x70, 0x4d, 0x22,
+ 0xaf, 0x1f, 0xd1, 0xbb, 0xc0, 0x53, 0xc1, 0xf0, 0xdf, 0x95, 0xf3, 0x11, 0xd4, 0x7c, 0x39, 0x59,
+ 0xe9, 0x67, 0x77, 0x55, 0x01, 0x06, 0xae, 0x38, 0x33, 0x05, 0x9d, 0x7d, 0x53, 0x98, 0x63, 0x77,
+ 0xfd, 0xac, 0x4c, 0xbf, 0xf1, 0x3a, 0xcc, 0x4b, 0x1a, 0xa2, 0x28, 0x0b, 0x13, 0x19, 0x11, 0x28,
+ 0x8e, 0x88, 0x30, 0x18, 0x5d, 0x3a, 0xde, 0xec, 0x2a, 0x66, 0xd8, 0xb4, 0x8c, 0xa6, 0xa6, 0xd0,
+ 0xbc, 0xc8, 0x4f, 0x04, 0x15, 0x4c, 0x0d, 0xda, 0x02, 0x4c, 0x09, 0xa8, 0x60, 0xb1, 0x11, 0x14,
+ 0x3c, 0xb2, 0x11, 0x23, 0xa4, 0x3f, 0x80, 0x05, 0x5f, 0x08, 0x6a, 0xb7, 0xa7, 0xc4, 0xe9, 0x99,
+ 0xae, 0xab, 0xf4, 0x09, 0xe2, 0x14, 0xbf, 0x03, 0x99, 0x3e, 0x11, 0x31, 0xa5, 0xb8, 0x8a, 0x96,
+ 0xf9, 0xdb, 0xd8, 0xb2, 0xb2, 0x98, 0xcd, 0xe3, 0x36, 0x5c, 0x97, 0xd4, 0xb9, 0x45, 0x63, 0xc9,
+ 0x47, 0x85, 0x92, 0x77, 0x48, 0x6e, 0xd6, 0xd1, 0x3b, 0x64, 0x9a, 0xef, 0xbd, 0xbc, 0x43, 0xd2,
+ 0x5c, 0xa1, 0xfa, 0xd6, 0x44, 0xb9, 0x62, 0x9b, 0xdb, 0xd4, 0x77, 0xc9, 0x89, 0x88, 0x1d, 0xc2,
+ 0x5c, 0xd8, 0x93, 0x27, 0x0a, 0x63, 0x73, 0x90, 0xf5, 0xec, 0x63, 0x22, 0x83, 0x18, 0x1f, 0x48,
+ 0x81, 0x7d, 0x37, 0x9f, 0x48, 0x60, 0x23, 0x20, 0xc6, 0x8e, 0xe4, 0xa4, 0xf2, 0xd2, 0xdd, 0x94,
+ 0xf5, 0x0f, 0x1f, 0xe0, 0x5d, 0xb8, 0x14, 0x0d, 0x13, 0x13, 0x89, 0xfc, 0x9c, 0x1f, 0xe0, 0xb8,
+ 0x48, 0x32, 0x11, 0xdd, 0x77, 0x83, 0x60, 0xa0, 0x04, 0x94, 0x89, 0x48, 0xea, 0x50, 0x8f, 0x8b,
+ 0x2f, 0xff, 0x89, 0xf3, 0xea, 0x87, 0x9b, 0x89, 0x88, 0xb9, 0x01, 0xb1, 0xc9, 0xb7, 0x3f, 0x88,
+ 0x11, 0xe9, 0xb1, 0x31, 0x42, 0x38, 0x49, 0x10, 0xc5, 0xbe, 0x86, 0x43, 0x27, 0x78, 0x04, 0x01,
+ 0x74, 0x52, 0x1e, 0x34, 0x87, 0xf8, 0x3c, 0xd8, 0x40, 0x1e, 0x6c, 0x35, 0xec, 0x4e, 0xb4, 0x19,
+ 0xef, 0x05, 0xb1, 0x73, 0x24, 0x32, 0x4f, 0x44, 0xf8, 0x7d, 0x58, 0x4c, 0x0e, 0xca, 0x93, 0x50,
+ 0xbe, 0x8f, 0xa1, 0xe0, 0x17, 0x94, 0xca, 0xbb, 0x72, 0x11, 0xf2, 0xbb, 0x7b, 0xfb, 0x4f, 0xd7,
+ 0xd6, 0x1b, 0x55, 0x6d, 0xf5, 0x1f, 0x69, 0x48, 0x6d, 0x3f, 0x47, 0xdf, 0x82, 0x2c, 0x7f, 0x2e,
+ 0x1a, 0xf3, 0x9a, 0x56, 0x1f, 0xf7, 0xf0, 0x84, 0xaf, 0x7e, 0xf2, 0xa7, 0xbf, 0x7e, 0x9e, 0xba,
+ 0x84, 0x2f, 0xac, 0x0c, 0xdf, 0x30, 0xba, 0xfd, 0x23, 0x63, 0xe5, 0x78, 0xb8, 0xc2, 0x72, 0xc2,
+ 0x43, 0xed, 0x3e, 0x7a, 0x0e, 0xe9, 0xa7, 0x03, 0x0f, 0x25, 0x3e, 0xb5, 0xd5, 0x93, 0x1f, 0xa4,
+ 0x70, 0x9d, 0x51, 0x9e, 0xc3, 0x33, 0x2a, 0xe5, 0xfe, 0xc0, 0xa3, 0x74, 0x87, 0x50, 0x54, 0xde,
+ 0x94, 0xd0, 0x99, 0x8f, 0x70, 0xf5, 0xb3, 0xdf, 0xab, 0x30, 0x66, 0xfc, 0xae, 0xe2, 0xcb, 0x2a,
+ 0x3f, 0xfe, 0xf4, 0xa5, 0xea, 0x73, 0x70, 0x62, 0x45, 0xf5, 0x09, 0x9e, 0x45, 0xa2, 0xfa, 0x28,
+ 0x4f, 0x11, 0xf1, 0xfa, 0x78, 0x27, 0x16, 0xa5, 0x6b, 0x8b, 0x77, 0xb0, 0x96, 0x87, 0xae, 0xc7,
+ 0xbc, 0xa3, 0xa8, 0x2f, 0x06, 0xf5, 0xc5, 0x64, 0x04, 0xc1, 0xe9, 0x06, 0xe3, 0x74, 0x05, 0x5f,
+ 0x52, 0x39, 0xb5, 0x7c, 0xbc, 0x87, 0xda, 0xfd, 0xd5, 0x23, 0xc8, 0xb2, 0x3e, 0x27, 0x6a, 0xca,
+ 0x8f, 0x7a, 0x4c, 0x87, 0x36, 0xe1, 0x04, 0x84, 0x3a, 0xa4, 0x78, 0x9e, 0x71, 0x9b, 0xc5, 0x15,
+ 0x9f, 0x1b, 0x6b, 0x75, 0x3e, 0xd4, 0xee, 0x2f, 0x69, 0xaf, 0x69, 0xab, 0xdf, 0xcb, 0x40, 0x96,
+ 0xb5, 0x8e, 0x50, 0x1f, 0x20, 0x68, 0x0a, 0x46, 0xf5, 0x1c, 0x69, 0x33, 0x46, 0xf5, 0x1c, 0xed,
+ 0x27, 0xe2, 0xeb, 0x8c, 0xf3, 0x3c, 0x9e, 0xf3, 0x39, 0xb3, 0x57, 0xfb, 0x15, 0xd6, 0x24, 0xa2,
+ 0x66, 0x7d, 0x09, 0x45, 0xa5, 0xb9, 0x87, 0xe2, 0x28, 0x86, 0xba, 0x83, 0xd1, 0x63, 0x12, 0xd3,
+ 0x19, 0xc4, 0x37, 0x19, 0xd3, 0x6b, 0xb8, 0xa6, 0x1a, 0x97, 0xf3, 0x75, 0x18, 0x26, 0x65, 0xfc,
+ 0xa9, 0x06, 0x95, 0x70, 0x83, 0x0f, 0xdd, 0x8c, 0x21, 0x1d, 0xed, 0x13, 0xd6, 0x6f, 0x8d, 0x47,
+ 0x4a, 0x14, 0x81, 0xf3, 0x3f, 0x26, 0xa4, 0x6f, 0x50, 0x4c, 0x61, 0x7b, 0xf4, 0x7d, 0x0d, 0x66,
+ 0x22, 0x6d, 0x3b, 0x14, 0xc7, 0x62, 0xa4, 0x29, 0x58, 0xbf, 0x7d, 0x06, 0x96, 0x90, 0xe4, 0x2e,
+ 0x93, 0xe4, 0x06, 0xbe, 0x3a, 0x6a, 0x0c, 0xcf, 0xec, 0x11, 0xcf, 0x16, 0xd2, 0xac, 0xfe, 0x33,
+ 0x0d, 0xf9, 0x75, 0xfe, 0x13, 0x2b, 0xe4, 0x41, 0xc1, 0xef, 0x84, 0xa1, 0x85, 0xb8, 0xae, 0x44,
+ 0x50, 0xb2, 0xd7, 0xaf, 0x27, 0xce, 0x0b, 0x11, 0xee, 0x30, 0x11, 0x16, 0xf1, 0x15, 0x5f, 0x04,
+ 0xf1, 0x53, 0xae, 0x15, 0x7e, 0xf9, 0x5e, 0x31, 0xda, 0x6d, 0xba, 0x25, 0xdf, 0xd5, 0xa0, 0xa4,
+ 0x36, 0xac, 0xd0, 0x8d, 0xd8, 0x7e, 0x88, 0xda, 0xf3, 0xaa, 0xe3, 0x71, 0x28, 0x82, 0xff, 0x3d,
+ 0xc6, 0xff, 0x26, 0x5e, 0x48, 0xe2, 0xef, 0x30, 0xfc, 0xb0, 0x08, 0xbc, 0xe5, 0x14, 0x2f, 0x42,
+ 0xa8, 0xa3, 0x15, 0x2f, 0x42, 0xb8, 0x63, 0x75, 0xb6, 0x08, 0x03, 0x86, 0x4f, 0x45, 0x38, 0x01,
+ 0x08, 0x3a, 0x4c, 0x28, 0xd6, 0xb8, 0xca, 0x25, 0x26, 0xea, 0x83, 0xa3, 0xcd, 0xa9, 0x98, 0x13,
+ 0x10, 0xe1, 0xdd, 0x35, 0x5d, 0xea, 0x8b, 0xab, 0xbf, 0xcd, 0x40, 0xf1, 0x89, 0x61, 0x5a, 0x1e,
+ 0xb1, 0x0c, 0xab, 0x45, 0x50, 0x07, 0xb2, 0x2c, 0x4b, 0x45, 0x03, 0x8f, 0xda, 0xf6, 0x89, 0x06,
+ 0x9e, 0x50, 0x4f, 0x04, 0xdf, 0x66, 0xac, 0xaf, 0xe3, 0xba, 0xcf, 0xba, 0x17, 0xd0, 0x5f, 0x61,
+ 0xfd, 0x0c, 0xaa, 0xf2, 0x31, 0xe4, 0x78, 0xff, 0x02, 0x45, 0xa8, 0x85, 0xfa, 0x1c, 0xf5, 0xab,
+ 0xf1, 0x93, 0x89, 0xa7, 0x4c, 0xe5, 0xe5, 0x32, 0x64, 0xca, 0xec, 0xdb, 0x00, 0x41, 0xc3, 0x2c,
+ 0x6a, 0xdf, 0x91, 0xfe, 0x5a, 0x7d, 0x31, 0x19, 0x41, 0x30, 0xbe, 0xcf, 0x18, 0xdf, 0xc2, 0xd7,
+ 0x63, 0x19, 0xb7, 0xfd, 0x05, 0x94, 0x79, 0x0b, 0x32, 0x9b, 0x86, 0x7b, 0x84, 0x22, 0x49, 0x48,
+ 0x79, 0xdb, 0xad, 0xd7, 0xe3, 0xa6, 0x04, 0xab, 0x5b, 0x8c, 0xd5, 0x02, 0x9e, 0x8f, 0x65, 0x75,
+ 0x64, 0xb8, 0x34, 0xa6, 0xa3, 0x01, 0x4c, 0xcb, 0xf7, 0x5a, 0x74, 0x2d, 0x62, 0xb3, 0xf0, 0xdb,
+ 0x6e, 0x7d, 0x21, 0x69, 0x5a, 0x30, 0x5c, 0x62, 0x0c, 0x31, 0xbe, 0x16, 0x6f, 0x54, 0x81, 0xfe,
+ 0x50, 0xbb, 0xff, 0x9a, 0xb6, 0xfa, 0xc3, 0x2a, 0x64, 0x68, 0xbd, 0x44, 0xb3, 0x48, 0x70, 0xcd,
+ 0x8c, 0x5a, 0x78, 0xa4, 0xb9, 0x13, 0xb5, 0xf0, 0xe8, 0x0d, 0x35, 0x26, 0x8b, 0xb0, 0x1f, 0x9a,
+ 0x12, 0x86, 0x45, 0x35, 0xf6, 0xa0, 0xa8, 0x5c, 0x46, 0x51, 0x0c, 0xc5, 0x70, 0xeb, 0x28, 0x9a,
+ 0x45, 0x62, 0x6e, 0xb2, 0x78, 0x91, 0x31, 0xad, 0xe3, 0x8b, 0x61, 0xa6, 0x6d, 0x8e, 0x46, 0xb9,
+ 0x7e, 0x0c, 0x25, 0xf5, 0xd6, 0x8a, 0x62, 0x88, 0x46, 0x7a, 0x53, 0xd1, 0x58, 0x11, 0x77, 0xe9,
+ 0x8d, 0x71, 0x1a, 0xff, 0x67, 0xb5, 0x12, 0x97, 0x72, 0xff, 0x10, 0xf2, 0xe2, 0x2e, 0x1b, 0xa7,
+ 0x6f, 0xb8, 0x9b, 0x15, 0xa7, 0x6f, 0xe4, 0x22, 0x1c, 0x53, 0x92, 0x30, 0xb6, 0xb4, 0x66, 0x97,
+ 0x01, 0x5a, 0xb0, 0x7c, 0x4c, 0xbc, 0x24, 0x96, 0x41, 0x7f, 0x26, 0x89, 0xa5, 0x72, 0x5f, 0x1a,
+ 0xcb, 0xb2, 0x43, 0x3c, 0x71, 0x96, 0xe5, 0x65, 0x04, 0x25, 0x50, 0x54, 0xa3, 0x21, 0x1e, 0x87,
+ 0x92, 0x58, 0x45, 0x06, 0x5c, 0x45, 0x28, 0x44, 0xdf, 0x01, 0x08, 0x2e, 0xde, 0xd1, 0xc2, 0x20,
+ 0xb6, 0x7b, 0x17, 0x2d, 0x0c, 0xe2, 0xef, 0xee, 0x31, 0x1e, 0x1c, 0x30, 0xe7, 0x95, 0x2c, 0x65,
+ 0xff, 0x13, 0x0d, 0xd0, 0xe8, 0x45, 0x1d, 0x3d, 0x88, 0x67, 0x11, 0xdb, 0x18, 0xac, 0xbf, 0x72,
+ 0x3e, 0xe4, 0xc4, 0xe8, 0x19, 0xc8, 0xd5, 0x62, 0x4b, 0xfa, 0x2f, 0xa9, 0x64, 0x9f, 0x69, 0x50,
+ 0x0e, 0x5d, 0xf5, 0xd1, 0x9d, 0x84, 0x7d, 0x8e, 0x34, 0x17, 0xeb, 0x77, 0xcf, 0xc4, 0x4b, 0xac,
+ 0x9d, 0x94, 0x53, 0x21, 0xeb, 0xc6, 0x1f, 0x68, 0x50, 0x09, 0xf7, 0x07, 0x50, 0x02, 0x83, 0x91,
+ 0x0e, 0x65, 0x7d, 0xe9, 0x6c, 0xc4, 0x73, 0xec, 0x56, 0x50, 0x4a, 0x7e, 0x08, 0x79, 0xd1, 0x56,
+ 0x88, 0x73, 0x8b, 0x70, 0x83, 0x33, 0xce, 0x2d, 0x22, 0x3d, 0x89, 0x24, 0xb7, 0xa0, 0x37, 0x74,
+ 0xc5, 0x13, 0x45, 0xf3, 0x21, 0x89, 0xe5, 0x78, 0x4f, 0x8c, 0x74, 0x2e, 0xc6, 0xb2, 0x0c, 0x3c,
+ 0x51, 0xb6, 0x1e, 0x50, 0x02, 0xc5, 0x33, 0x3c, 0x31, 0xda, 0xb9, 0x48, 0xf2, 0x44, 0xc6, 0x55,
+ 0xf1, 0xc4, 0xa0, 0x53, 0x10, 0xe7, 0x89, 0x23, 0xed, 0xdb, 0x38, 0x4f, 0x1c, 0x6d, 0x36, 0x24,
+ 0xed, 0x2d, 0x63, 0x1e, 0xf2, 0xc4, 0xd9, 0x98, 0xce, 0x02, 0x7a, 0x25, 0xc1, 0xa6, 0xb1, 0xad,
+ 0xe1, 0xfa, 0xab, 0xe7, 0xc4, 0x1e, 0xef, 0x01, 0x7c, 0x37, 0xa4, 0x07, 0xfc, 0x42, 0x83, 0xb9,
+ 0xb8, 0xd6, 0x04, 0x4a, 0x60, 0x96, 0xd0, 0x57, 0xae, 0x2f, 0x9f, 0x17, 0xfd, 0x1c, 0x76, 0xf3,
+ 0x7d, 0xe2, 0x51, 0xf5, 0x77, 0x5f, 0x2e, 0x68, 0x7f, 0xfc, 0x72, 0x41, 0xfb, 0xf3, 0x97, 0x0b,
+ 0xda, 0x4f, 0xff, 0xb2, 0x30, 0x75, 0x98, 0x63, 0xff, 0xdb, 0xe3, 0x8d, 0x7f, 0x05, 0x00, 0x00,
+ 0xff, 0xff, 0x63, 0x1c, 0x78, 0x24, 0x74, 0x32, 0x00, 0x00,
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/rpc.proto b/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/rpc.proto
new file mode 100644
index 00000000..a6cd00ab
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/etcdserverpb/rpc.proto
@@ -0,0 +1,984 @@
+syntax = "proto3";
+package etcdserverpb;
+
+import "gogoproto/gogo.proto";
+import "etcd/mvcc/mvccpb/kv.proto";
+import "etcd/auth/authpb/auth.proto";
+
+// for grpc-gateway
+import "google/api/annotations.proto";
+
+option (gogoproto.marshaler_all) = true;
+option (gogoproto.unmarshaler_all) = true;
+
+service KV {
+ // Range gets the keys in the range from the key-value store.
+ rpc Range(RangeRequest) returns (RangeResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/kv/range"
+ body: "*"
+ };
+ }
+
+ // Put puts the given key into the key-value store.
+ // A put request increments the revision of the key-value store
+ // and generates one event in the event history.
+ rpc Put(PutRequest) returns (PutResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/kv/put"
+ body: "*"
+ };
+ }
+
+ // DeleteRange deletes the given range from the key-value store.
+ // A delete request increments the revision of the key-value store
+ // and generates a delete event in the event history for every deleted key.
+ rpc DeleteRange(DeleteRangeRequest) returns (DeleteRangeResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/kv/deleterange"
+ body: "*"
+ };
+ }
+
+ // Txn processes multiple requests in a single transaction.
+ // A txn request increments the revision of the key-value store
+ // and generates events with the same revision for every completed request.
+ // It is not allowed to modify the same key several times within one txn.
+ rpc Txn(TxnRequest) returns (TxnResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/kv/txn"
+ body: "*"
+ };
+ }
+
+ // Compact compacts the event history in the etcd key-value store. The key-value
+ // store should be periodically compacted or the event history will continue to grow
+ // indefinitely.
+ rpc Compact(CompactionRequest) returns (CompactionResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/kv/compaction"
+ body: "*"
+ };
+ }
+}
+
+service Watch {
+ // Watch watches for events happening or that have happened. Both input and output
+ // are streams; the input stream is for creating and canceling watchers and the output
+ // stream sends events. One watch RPC can watch on multiple key ranges, streaming events
+ // for several watches at once. The entire event history can be watched starting from the
+ // last compaction revision.
+ rpc Watch(stream WatchRequest) returns (stream WatchResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/watch"
+ body: "*"
+ };
+ }
+}
+
+service Lease {
+ // LeaseGrant creates a lease which expires if the server does not receive a keepAlive
+ // within a given time to live period. All keys attached to the lease will be expired and
+ // deleted if the lease expires. Each expired key generates a delete event in the event history.
+ rpc LeaseGrant(LeaseGrantRequest) returns (LeaseGrantResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/lease/grant"
+ body: "*"
+ };
+ }
+
+ // LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.
+ rpc LeaseRevoke(LeaseRevokeRequest) returns (LeaseRevokeResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/kv/lease/revoke"
+ body: "*"
+ };
+ }
+
+ // LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
+ // to the server and streaming keep alive responses from the server to the client.
+ rpc LeaseKeepAlive(stream LeaseKeepAliveRequest) returns (stream LeaseKeepAliveResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/lease/keepalive"
+ body: "*"
+ };
+ }
+
+ // LeaseTimeToLive retrieves lease information.
+ rpc LeaseTimeToLive(LeaseTimeToLiveRequest) returns (LeaseTimeToLiveResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/kv/lease/timetolive"
+ body: "*"
+ };
+ }
+
+ // TODO(xiangli) List all existing Leases?
+}
+
+service Cluster {
+ // MemberAdd adds a member into the cluster.
+ rpc MemberAdd(MemberAddRequest) returns (MemberAddResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/cluster/member/add"
+ body: "*"
+ };
+ }
+
+ // MemberRemove removes an existing member from the cluster.
+ rpc MemberRemove(MemberRemoveRequest) returns (MemberRemoveResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/cluster/member/remove"
+ body: "*"
+ };
+ }
+
+ // MemberUpdate updates the member configuration.
+ rpc MemberUpdate(MemberUpdateRequest) returns (MemberUpdateResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/cluster/member/update"
+ body: "*"
+ };
+ }
+
+ // MemberList lists all the members in the cluster.
+ rpc MemberList(MemberListRequest) returns (MemberListResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/cluster/member/list"
+ body: "*"
+ };
+ }
+}
+
+service Maintenance {
+ // Alarm activates, deactivates, and queries alarms regarding cluster health.
+ rpc Alarm(AlarmRequest) returns (AlarmResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/maintenance/alarm"
+ body: "*"
+ };
+ }
+
+ // Status gets the status of the member.
+ rpc Status(StatusRequest) returns (StatusResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/maintenance/status"
+ body: "*"
+ };
+ }
+
+ // Defragment defragments a member's backend database to recover storage space.
+ rpc Defragment(DefragmentRequest) returns (DefragmentResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/maintenance/defragment"
+ body: "*"
+ };
+ }
+
+ // Hash returns the hash of the local KV state for consistency checking purpose.
+ // This is designed for testing; do not use this in production when there
+ // are ongoing transactions.
+ rpc Hash(HashRequest) returns (HashResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/maintenance/hash"
+ body: "*"
+ };
+ }
+
+ // Snapshot sends a snapshot of the entire backend from a member over a stream to a client.
+ rpc Snapshot(SnapshotRequest) returns (stream SnapshotResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/maintenance/snapshot"
+ body: "*"
+ };
+ }
+}
+
+service Auth {
+ // AuthEnable enables authentication.
+ rpc AuthEnable(AuthEnableRequest) returns (AuthEnableResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/enable"
+ body: "*"
+ };
+ }
+
+ // AuthDisable disables authentication.
+ rpc AuthDisable(AuthDisableRequest) returns (AuthDisableResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/disable"
+ body: "*"
+ };
+ }
+
+ // Authenticate processes an authenticate request.
+ rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/authenticate"
+ body: "*"
+ };
+ }
+
+ // UserAdd adds a new user.
+ rpc UserAdd(AuthUserAddRequest) returns (AuthUserAddResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/user/add"
+ body: "*"
+ };
+ }
+
+ // UserGet gets detailed user information.
+ rpc UserGet(AuthUserGetRequest) returns (AuthUserGetResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/user/get"
+ body: "*"
+ };
+ }
+
+ // UserList gets a list of all users.
+ rpc UserList(AuthUserListRequest) returns (AuthUserListResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/user/list"
+ body: "*"
+ };
+ }
+
+ // UserDelete deletes a specified user.
+ rpc UserDelete(AuthUserDeleteRequest) returns (AuthUserDeleteResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/user/delete"
+ body: "*"
+ };
+ }
+
+ // UserChangePassword changes the password of a specified user.
+ rpc UserChangePassword(AuthUserChangePasswordRequest) returns (AuthUserChangePasswordResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/user/changepw"
+ body: "*"
+ };
+ }
+
+ // UserGrant grants a role to a specified user.
+ rpc UserGrantRole(AuthUserGrantRoleRequest) returns (AuthUserGrantRoleResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/user/grant"
+ body: "*"
+ };
+ }
+
+ // UserRevokeRole revokes a role of specified user.
+ rpc UserRevokeRole(AuthUserRevokeRoleRequest) returns (AuthUserRevokeRoleResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/user/revoke"
+ body: "*"
+ };
+ }
+
+ // RoleAdd adds a new role.
+ rpc RoleAdd(AuthRoleAddRequest) returns (AuthRoleAddResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/role/add"
+ body: "*"
+ };
+ }
+
+ // RoleGet gets detailed role information.
+ rpc RoleGet(AuthRoleGetRequest) returns (AuthRoleGetResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/role/get"
+ body: "*"
+ };
+ }
+
+ // RoleList gets lists of all roles.
+ rpc RoleList(AuthRoleListRequest) returns (AuthRoleListResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/role/list"
+ body: "*"
+ };
+ }
+
+ // RoleDelete deletes a specified role.
+ rpc RoleDelete(AuthRoleDeleteRequest) returns (AuthRoleDeleteResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/role/delete"
+ body: "*"
+ };
+ }
+
+ // RoleGrantPermission grants a permission of a specified key or range to a specified role.
+ rpc RoleGrantPermission(AuthRoleGrantPermissionRequest) returns (AuthRoleGrantPermissionResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/role/grant"
+ body: "*"
+ };
+ }
+
+ // RoleRevokePermission revokes a key or range permission of a specified role.
+ rpc RoleRevokePermission(AuthRoleRevokePermissionRequest) returns (AuthRoleRevokePermissionResponse) {
+ option (google.api.http) = {
+ post: "/v3alpha/auth/role/revoke"
+ body: "*"
+ };
+ }
+}
+
+message ResponseHeader {
+ // cluster_id is the ID of the cluster which sent the response.
+ uint64 cluster_id = 1;
+ // member_id is the ID of the member which sent the response.
+ uint64 member_id = 2;
+ // revision is the key-value store revision when the request was applied.
+ int64 revision = 3;
+ // raft_term is the raft term when the request was applied.
+ uint64 raft_term = 4;
+}
+
+message RangeRequest {
+ enum SortOrder {
+ NONE = 0; // default, no sorting
+ ASCEND = 1; // lowest target value first
+ DESCEND = 2; // highest target value first
+ }
+ enum SortTarget {
+ KEY = 0;
+ VERSION = 1;
+ CREATE = 2;
+ MOD = 3;
+ VALUE = 4;
+ }
+
+ // key is the first key for the range. If range_end is not given, the request only looks up key.
+ bytes key = 1;
+ // range_end is the upper bound on the requested range [key, range_end).
+ // If range_end is '\0', the range is all keys >= key.
+ // If range_end is key plus one (e.g., "aa"+1 == "ab", "a\xff"+1 == "b"),
+ // then the range request gets all keys prefixed with key.
+ // If both key and range_end are '\0', then the range request returns all keys.
+ bytes range_end = 2;
+ // limit is a limit on the number of keys returned for the request. When limit is set to 0,
+ // it is treated as no limit.
+ int64 limit = 3;
+ // revision is the point-in-time of the key-value store to use for the range.
+ // If revision is less or equal to zero, the range is over the newest key-value store.
+ // If the revision has been compacted, ErrCompacted is returned as a response.
+ int64 revision = 4;
+
+ // sort_order is the order for returned sorted results.
+ SortOrder sort_order = 5;
+
+ // sort_target is the key-value field to use for sorting.
+ SortTarget sort_target = 6;
+
+ // serializable sets the range request to use serializable member-local reads.
+ // Range requests are linearizable by default; linearizable requests have higher
+ // latency and lower throughput than serializable requests but reflect the current
+ // consensus of the cluster. For better performance, in exchange for possible stale reads,
+ // a serializable range request is served locally without needing to reach consensus
+ // with other nodes in the cluster.
+ bool serializable = 7;
+
+ // keys_only when set returns only the keys and not the values.
+ bool keys_only = 8;
+
+ // count_only when set returns only the count of the keys in the range.
+ bool count_only = 9;
+
+ // min_mod_revision is the lower bound for returned key mod revisions; all keys with
+ // lesser mod revisions will be filtered away.
+ int64 min_mod_revision = 10;
+
+ // max_mod_revision is the upper bound for returned key mod revisions; all keys with
+ // greater mod revisions will be filtered away.
+ int64 max_mod_revision = 11;
+
+ // min_create_revision is the lower bound for returned key create revisions; all keys with
+ // lesser create trevisions will be filtered away.
+ int64 min_create_revision = 12;
+
+ // max_create_revision is the upper bound for returned key create revisions; all keys with
+ // greater create revisions will be filtered away.
+ int64 max_create_revision = 13;
+}
+
+message RangeResponse {
+ ResponseHeader header = 1;
+ // kvs is the list of key-value pairs matched by the range request.
+ // kvs is empty when count is requested.
+ repeated mvccpb.KeyValue kvs = 2;
+ // more indicates if there are more keys to return in the requested range.
+ bool more = 3;
+ // count is set to the number of keys within the range when requested.
+ int64 count = 4;
+}
+
+message PutRequest {
+ // key is the key, in bytes, to put into the key-value store.
+ bytes key = 1;
+ // value is the value, in bytes, to associate with the key in the key-value store.
+ bytes value = 2;
+ // lease is the lease ID to associate with the key in the key-value store. A lease
+ // value of 0 indicates no lease.
+ int64 lease = 3;
+
+ // If prev_kv is set, etcd gets the previous key-value pair before changing it.
+ // The previous key-value pair will be returned in the put response.
+ bool prev_kv = 4;
+
+ // If ignore_value is set, etcd updates the key using its current value.
+ // Returns an error if the key does not exist.
+ bool ignore_value = 5;
+
+ // If ignore_lease is set, etcd updates the key using its current lease.
+ // Returns an error if the key does not exist.
+ bool ignore_lease = 6;
+}
+
+message PutResponse {
+ ResponseHeader header = 1;
+ // if prev_kv is set in the request, the previous key-value pair will be returned.
+ mvccpb.KeyValue prev_kv = 2;
+}
+
+message DeleteRangeRequest {
+ // key is the first key to delete in the range.
+ bytes key = 1;
+ // range_end is the key following the last key to delete for the range [key, range_end).
+ // If range_end is not given, the range is defined to contain only the key argument.
+ // If range_end is one bit larger than the given key, then the range is all the keys
+ // with the prefix (the given key).
+ // If range_end is '\0', the range is all keys greater than or equal to the key argument.
+ bytes range_end = 2;
+
+ // If prev_kv is set, etcd gets the previous key-value pairs before deleting it.
+ // The previous key-value pairs will be returned in the delete response.
+ bool prev_kv = 3;
+}
+
+message DeleteRangeResponse {
+ ResponseHeader header = 1;
+ // deleted is the number of keys deleted by the delete range request.
+ int64 deleted = 2;
+ // if prev_kv is set in the request, the previous key-value pairs will be returned.
+ repeated mvccpb.KeyValue prev_kvs = 3;
+}
+
+message RequestOp {
+ // request is a union of request types accepted by a transaction.
+ oneof request {
+ RangeRequest request_range = 1;
+ PutRequest request_put = 2;
+ DeleteRangeRequest request_delete_range = 3;
+ }
+}
+
+message ResponseOp {
+ // response is a union of response types returned by a transaction.
+ oneof response {
+ RangeResponse response_range = 1;
+ PutResponse response_put = 2;
+ DeleteRangeResponse response_delete_range = 3;
+ }
+}
+
+message Compare {
+ enum CompareResult {
+ EQUAL = 0;
+ GREATER = 1;
+ LESS = 2;
+ NOT_EQUAL = 3;
+ }
+ enum CompareTarget {
+ VERSION = 0;
+ CREATE = 1;
+ MOD = 2;
+ VALUE= 3;
+ }
+ // result is logical comparison operation for this comparison.
+ CompareResult result = 1;
+ // target is the key-value field to inspect for the comparison.
+ CompareTarget target = 2;
+ // key is the subject key for the comparison operation.
+ bytes key = 3;
+ oneof target_union {
+ // version is the version of the given key
+ int64 version = 4;
+ // create_revision is the creation revision of the given key
+ int64 create_revision = 5;
+ // mod_revision is the last modified revision of the given key.
+ int64 mod_revision = 6;
+ // value is the value of the given key, in bytes.
+ bytes value = 7;
+ }
+}
+
+// From google paxosdb paper:
+// Our implementation hinges around a powerful primitive which we call MultiOp. All other database
+// operations except for iteration are implemented as a single call to MultiOp. A MultiOp is applied atomically
+// and consists of three components:
+// 1. A list of tests called guard. Each test in guard checks a single entry in the database. It may check
+// for the absence or presence of a value, or compare with a given value. Two different tests in the guard
+// may apply to the same or different entries in the database. All tests in the guard are applied and
+// MultiOp returns the results. If all tests are true, MultiOp executes t op (see item 2 below), otherwise
+// it executes f op (see item 3 below).
+// 2. A list of database operations called t op. Each operation in the list is either an insert, delete, or
+// lookup operation, and applies to a single database entry. Two different operations in the list may apply
+// to the same or different entries in the database. These operations are executed
+// if guard evaluates to
+// true.
+// 3. A list of database operations called f op. Like t op, but executed if guard evaluates to false.
+message TxnRequest {
+ // compare is a list of predicates representing a conjunction of terms.
+ // If the comparisons succeed, then the success requests will be processed in order,
+ // and the response will contain their respective responses in order.
+ // If the comparisons fail, then the failure requests will be processed in order,
+ // and the response will contain their respective responses in order.
+ repeated Compare compare = 1;
+ // success is a list of requests which will be applied when compare evaluates to true.
+ repeated RequestOp success = 2;
+ // failure is a list of requests which will be applied when compare evaluates to false.
+ repeated RequestOp failure = 3;
+}
+
+message TxnResponse {
+ ResponseHeader header = 1;
+ // succeeded is set to true if the compare evaluated to true or false otherwise.
+ bool succeeded = 2;
+ // responses is a list of responses corresponding to the results from applying
+ // success if succeeded is true or failure if succeeded is false.
+ repeated ResponseOp responses = 3;
+}
+
+// CompactionRequest compacts the key-value store up to a given revision. All superseded keys
+// with a revision less than the compaction revision will be removed.
+message CompactionRequest {
+ // revision is the key-value store revision for the compaction operation.
+ int64 revision = 1;
+ // physical is set so the RPC will wait until the compaction is physically
+ // applied to the local database such that compacted entries are totally
+ // removed from the backend database.
+ bool physical = 2;
+}
+
+message CompactionResponse {
+ ResponseHeader header = 1;
+}
+
+message HashRequest {
+}
+
+message HashResponse {
+ ResponseHeader header = 1;
+ // hash is the hash value computed from the responding member's key-value store.
+ uint32 hash = 2;
+}
+
+message SnapshotRequest {
+}
+
+message SnapshotResponse {
+ // header has the current key-value store information. The first header in the snapshot
+ // stream indicates the point in time of the snapshot.
+ ResponseHeader header = 1;
+
+ // remaining_bytes is the number of blob bytes to be sent after this message
+ uint64 remaining_bytes = 2;
+
+ // blob contains the next chunk of the snapshot in the snapshot stream.
+ bytes blob = 3;
+}
+
+message WatchRequest {
+ // request_union is a request to either create a new watcher or cancel an existing watcher.
+ oneof request_union {
+ WatchCreateRequest create_request = 1;
+ WatchCancelRequest cancel_request = 2;
+ }
+}
+
+message WatchCreateRequest {
+ // key is the key to register for watching.
+ bytes key = 1;
+ // range_end is the end of the range [key, range_end) to watch. If range_end is not given,
+ // only the key argument is watched. If range_end is equal to '\0', all keys greater than
+ // or equal to the key argument are watched.
+ // If the range_end is one bit larger than the given key,
+ // then all keys with the prefix (the given key) will be watched.
+ bytes range_end = 2;
+ // start_revision is an optional revision to watch from (inclusive). No start_revision is "now".
+ int64 start_revision = 3;
+ // progress_notify is set so that the etcd server will periodically send a WatchResponse with
+ // no events to the new watcher if there are no recent events. It is useful when clients
+ // wish to recover a disconnected watcher starting from a recent known revision.
+ // The etcd server may decide how often it will send notifications based on current load.
+ bool progress_notify = 4;
+
+ enum FilterType {
+ // filter out put event.
+ NOPUT = 0;
+ // filter out delete event.
+ NODELETE = 1;
+ }
+ // filters filter the events at server side before it sends back to the watcher.
+ repeated FilterType filters = 5;
+
+ // If prev_kv is set, created watcher gets the previous KV before the event happens.
+ // If the previous KV is already compacted, nothing will be returned.
+ bool prev_kv = 6;
+}
+
+message WatchCancelRequest {
+ // watch_id is the watcher id to cancel so that no more events are transmitted.
+ int64 watch_id = 1;
+}
+
+message WatchResponse {
+ ResponseHeader header = 1;
+ // watch_id is the ID of the watcher that corresponds to the response.
+ int64 watch_id = 2;
+ // created is set to true if the response is for a create watch request.
+ // The client should record the watch_id and expect to receive events for
+ // the created watcher from the same stream.
+ // All events sent to the created watcher will attach with the same watch_id.
+ bool created = 3;
+ // canceled is set to true if the response is for a cancel watch request.
+ // No further events will be sent to the canceled watcher.
+ bool canceled = 4;
+ // compact_revision is set to the minimum index if a watcher tries to watch
+ // at a compacted index.
+ //
+ // This happens when creating a watcher at a compacted revision or the watcher cannot
+ // catch up with the progress of the key-value store.
+ //
+ // The client should treat the watcher as canceled and should not try to create any
+ // watcher with the same start_revision again.
+ int64 compact_revision = 5;
+
+ // cancel_reason indicates the reason for canceling the watcher.
+ string cancel_reason = 6;
+
+ repeated mvccpb.Event events = 11;
+}
+
+message LeaseGrantRequest {
+ // TTL is the advisory time-to-live in seconds.
+ int64 TTL = 1;
+ // ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID.
+ int64 ID = 2;
+}
+
+message LeaseGrantResponse {
+ ResponseHeader header = 1;
+ // ID is the lease ID for the granted lease.
+ int64 ID = 2;
+ // TTL is the server chosen lease time-to-live in seconds.
+ int64 TTL = 3;
+ string error = 4;
+}
+
+message LeaseRevokeRequest {
+ // ID is the lease ID to revoke. When the ID is revoked, all associated keys will be deleted.
+ int64 ID = 1;
+}
+
+message LeaseRevokeResponse {
+ ResponseHeader header = 1;
+}
+
+message LeaseKeepAliveRequest {
+ // ID is the lease ID for the lease to keep alive.
+ int64 ID = 1;
+}
+
+message LeaseKeepAliveResponse {
+ ResponseHeader header = 1;
+ // ID is the lease ID from the keep alive request.
+ int64 ID = 2;
+ // TTL is the new time-to-live for the lease.
+ int64 TTL = 3;
+}
+
+message LeaseTimeToLiveRequest {
+ // ID is the lease ID for the lease.
+ int64 ID = 1;
+ // keys is true to query all the keys attached to this lease.
+ bool keys = 2;
+}
+
+message LeaseTimeToLiveResponse {
+ ResponseHeader header = 1;
+ // ID is the lease ID from the keep alive request.
+ int64 ID = 2;
+ // TTL is the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds.
+ int64 TTL = 3;
+ // GrantedTTL is the initial granted time in seconds upon lease creation/renewal.
+ int64 grantedTTL = 4;
+ // Keys is the list of keys attached to this lease.
+ repeated bytes keys = 5;
+}
+
+message Member {
+ // ID is the member ID for this member.
+ uint64 ID = 1;
+ // name is the human-readable name of the member. If the member is not started, the name will be an empty string.
+ string name = 2;
+ // peerURLs is the list of URLs the member exposes to the cluster for communication.
+ repeated string peerURLs = 3;
+ // clientURLs is the list of URLs the member exposes to clients for communication. If the member is not started, clientURLs will be empty.
+ repeated string clientURLs = 4;
+}
+
+message MemberAddRequest {
+ // peerURLs is the list of URLs the added member will use to communicate with the cluster.
+ repeated string peerURLs = 1;
+}
+
+message MemberAddResponse {
+ ResponseHeader header = 1;
+ // member is the member information for the added member.
+ Member member = 2;
+ // members is a list of all members after adding the new member.
+ repeated Member members = 3;
+}
+
+message MemberRemoveRequest {
+ // ID is the member ID of the member to remove.
+ uint64 ID = 1;
+}
+
+message MemberRemoveResponse {
+ ResponseHeader header = 1;
+ // members is a list of all members after removing the member.
+ repeated Member members = 2;
+}
+
+message MemberUpdateRequest {
+ // ID is the member ID of the member to update.
+ uint64 ID = 1;
+ // peerURLs is the new list of URLs the member will use to communicate with the cluster.
+ repeated string peerURLs = 2;
+}
+
+message MemberUpdateResponse{
+ ResponseHeader header = 1;
+ // members is a list of all members after updating the member.
+ repeated Member members = 2;
+}
+
+message MemberListRequest {
+}
+
+message MemberListResponse {
+ ResponseHeader header = 1;
+ // members is a list of all members associated with the cluster.
+ repeated Member members = 2;
+}
+
+message DefragmentRequest {
+}
+
+message DefragmentResponse {
+ ResponseHeader header = 1;
+}
+
+enum AlarmType {
+ NONE = 0; // default, used to query if any alarm is active
+ NOSPACE = 1; // space quota is exhausted
+}
+
+message AlarmRequest {
+ enum AlarmAction {
+ GET = 0;
+ ACTIVATE = 1;
+ DEACTIVATE = 2;
+ }
+ // action is the kind of alarm request to issue. The action
+ // may GET alarm statuses, ACTIVATE an alarm, or DEACTIVATE a
+ // raised alarm.
+ AlarmAction action = 1;
+ // memberID is the ID of the member associated with the alarm. If memberID is 0, the
+ // alarm request covers all members.
+ uint64 memberID = 2;
+ // alarm is the type of alarm to consider for this request.
+ AlarmType alarm = 3;
+}
+
+message AlarmMember {
+ // memberID is the ID of the member associated with the raised alarm.
+ uint64 memberID = 1;
+ // alarm is the type of alarm which has been raised.
+ AlarmType alarm = 2;
+}
+
+message AlarmResponse {
+ ResponseHeader header = 1;
+ // alarms is a list of alarms associated with the alarm request.
+ repeated AlarmMember alarms = 2;
+}
+
+message StatusRequest {
+}
+
+message StatusResponse {
+ ResponseHeader header = 1;
+ // version is the cluster protocol version used by the responding member.
+ string version = 2;
+ // dbSize is the size of the backend database, in bytes, of the responding member.
+ int64 dbSize = 3;
+ // leader is the member ID which the responding member believes is the current leader.
+ uint64 leader = 4;
+ // raftIndex is the current raft index of the responding member.
+ uint64 raftIndex = 5;
+ // raftTerm is the current raft term of the responding member.
+ uint64 raftTerm = 6;
+}
+
+message AuthEnableRequest {
+}
+
+message AuthDisableRequest {
+}
+
+message AuthenticateRequest {
+ string name = 1;
+ string password = 2;
+}
+
+message AuthUserAddRequest {
+ string name = 1;
+ string password = 2;
+}
+
+message AuthUserGetRequest {
+ string name = 1;
+}
+
+message AuthUserDeleteRequest {
+ // name is the name of the user to delete.
+ string name = 1;
+}
+
+message AuthUserChangePasswordRequest {
+ // name is the name of the user whose password is being changed.
+ string name = 1;
+ // password is the new password for the user.
+ string password = 2;
+}
+
+message AuthUserGrantRoleRequest {
+ // user is the name of the user which should be granted a given role.
+ string user = 1;
+ // role is the name of the role to grant to the user.
+ string role = 2;
+}
+
+message AuthUserRevokeRoleRequest {
+ string name = 1;
+ string role = 2;
+}
+
+message AuthRoleAddRequest {
+ // name is the name of the role to add to the authentication system.
+ string name = 1;
+}
+
+message AuthRoleGetRequest {
+ string role = 1;
+}
+
+message AuthUserListRequest {
+}
+
+message AuthRoleListRequest {
+}
+
+message AuthRoleDeleteRequest {
+ string role = 1;
+}
+
+message AuthRoleGrantPermissionRequest {
+ // name is the name of the role which will be granted the permission.
+ string name = 1;
+ // perm is the permission to grant to the role.
+ authpb.Permission perm = 2;
+}
+
+message AuthRoleRevokePermissionRequest {
+ string role = 1;
+ string key = 2;
+ string range_end = 3;
+}
+
+message AuthEnableResponse {
+ ResponseHeader header = 1;
+}
+
+message AuthDisableResponse {
+ ResponseHeader header = 1;
+}
+
+message AuthenticateResponse {
+ ResponseHeader header = 1;
+ // token is an authorized token that can be used in succeeding RPCs
+ string token = 2;
+}
+
+message AuthUserAddResponse {
+ ResponseHeader header = 1;
+}
+
+message AuthUserGetResponse {
+ ResponseHeader header = 1;
+
+ repeated string roles = 2;
+}
+
+message AuthUserDeleteResponse {
+ ResponseHeader header = 1;
+}
+
+message AuthUserChangePasswordResponse {
+ ResponseHeader header = 1;
+}
+
+message AuthUserGrantRoleResponse {
+ ResponseHeader header = 1;
+}
+
+message AuthUserRevokeRoleResponse {
+ ResponseHeader header = 1;
+}
+
+message AuthRoleAddResponse {
+ ResponseHeader header = 1;
+}
+
+message AuthRoleGetResponse {
+ ResponseHeader header = 1;
+
+ repeated authpb.Permission perm = 2;
+}
+
+message AuthRoleListResponse {
+ ResponseHeader header = 1;
+
+ repeated string roles = 2;
+}
+
+message AuthUserListResponse {
+ ResponseHeader header = 1;
+
+ repeated string users = 2;
+}
+
+message AuthRoleDeleteResponse {
+ ResponseHeader header = 1;
+}
+
+message AuthRoleGrantPermissionResponse {
+ ResponseHeader header = 1;
+}
+
+message AuthRoleRevokePermissionResponse {
+ ResponseHeader header = 1;
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/membership/cluster.go b/vendor/github.com/coreos/etcd/etcdserver/membership/cluster.go
new file mode 100644
index 00000000..2330219f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/membership/cluster.go
@@ -0,0 +1,512 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 membership
+
+import (
+ "bytes"
+ "crypto/sha1"
+ "encoding/binary"
+ "encoding/json"
+ "fmt"
+ "path"
+ "sort"
+ "strings"
+ "sync"
+ "time"
+
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/pkg/netutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/store"
+ "github.com/coreos/etcd/version"
+ "github.com/coreos/go-semver/semver"
+)
+
+// RaftCluster is a list of Members that belong to the same raft cluster
+type RaftCluster struct {
+ id types.ID
+ token string
+
+ store store.Store
+ be backend.Backend
+
+ sync.Mutex // guards the fields below
+ version *semver.Version
+ members map[types.ID]*Member
+ // removed contains the ids of removed members in the cluster.
+ // removed id cannot be reused.
+ removed map[types.ID]bool
+}
+
+func NewClusterFromURLsMap(token string, urlsmap types.URLsMap) (*RaftCluster, error) {
+ c := NewCluster(token)
+ for name, urls := range urlsmap {
+ m := NewMember(name, urls, token, nil)
+ if _, ok := c.members[m.ID]; ok {
+ return nil, fmt.Errorf("member exists with identical ID %v", m)
+ }
+ if uint64(m.ID) == raft.None {
+ return nil, fmt.Errorf("cannot use %x as member id", raft.None)
+ }
+ c.members[m.ID] = m
+ }
+ c.genID()
+ return c, nil
+}
+
+func NewClusterFromMembers(token string, id types.ID, membs []*Member) *RaftCluster {
+ c := NewCluster(token)
+ c.id = id
+ for _, m := range membs {
+ c.members[m.ID] = m
+ }
+ return c
+}
+
+func NewCluster(token string) *RaftCluster {
+ return &RaftCluster{
+ token: token,
+ members: make(map[types.ID]*Member),
+ removed: make(map[types.ID]bool),
+ }
+}
+
+func (c *RaftCluster) ID() types.ID { return c.id }
+
+func (c *RaftCluster) Members() []*Member {
+ c.Lock()
+ defer c.Unlock()
+ var ms MembersByID
+ for _, m := range c.members {
+ ms = append(ms, m.Clone())
+ }
+ sort.Sort(ms)
+ return []*Member(ms)
+}
+
+func (c *RaftCluster) Member(id types.ID) *Member {
+ c.Lock()
+ defer c.Unlock()
+ return c.members[id].Clone()
+}
+
+// MemberByName returns a Member with the given name if exists.
+// If more than one member has the given name, it will panic.
+func (c *RaftCluster) MemberByName(name string) *Member {
+ c.Lock()
+ defer c.Unlock()
+ var memb *Member
+ for _, m := range c.members {
+ if m.Name == name {
+ if memb != nil {
+ plog.Panicf("two members with the given name %q exist", name)
+ }
+ memb = m
+ }
+ }
+ return memb.Clone()
+}
+
+func (c *RaftCluster) MemberIDs() []types.ID {
+ c.Lock()
+ defer c.Unlock()
+ var ids []types.ID
+ for _, m := range c.members {
+ ids = append(ids, m.ID)
+ }
+ sort.Sort(types.IDSlice(ids))
+ return ids
+}
+
+func (c *RaftCluster) IsIDRemoved(id types.ID) bool {
+ c.Lock()
+ defer c.Unlock()
+ return c.removed[id]
+}
+
+// PeerURLs returns a list of all peer addresses.
+// The returned list is sorted in ascending lexicographical order.
+func (c *RaftCluster) PeerURLs() []string {
+ c.Lock()
+ defer c.Unlock()
+ urls := make([]string, 0)
+ for _, p := range c.members {
+ urls = append(urls, p.PeerURLs...)
+ }
+ sort.Strings(urls)
+ return urls
+}
+
+// ClientURLs returns a list of all client addresses.
+// The returned list is sorted in ascending lexicographical order.
+func (c *RaftCluster) ClientURLs() []string {
+ c.Lock()
+ defer c.Unlock()
+ urls := make([]string, 0)
+ for _, p := range c.members {
+ urls = append(urls, p.ClientURLs...)
+ }
+ sort.Strings(urls)
+ return urls
+}
+
+func (c *RaftCluster) String() string {
+ c.Lock()
+ defer c.Unlock()
+ b := &bytes.Buffer{}
+ fmt.Fprintf(b, "{ClusterID:%s ", c.id)
+ var ms []string
+ for _, m := range c.members {
+ ms = append(ms, fmt.Sprintf("%+v", m))
+ }
+ fmt.Fprintf(b, "Members:[%s] ", strings.Join(ms, " "))
+ var ids []string
+ for id := range c.removed {
+ ids = append(ids, id.String())
+ }
+ fmt.Fprintf(b, "RemovedMemberIDs:[%s]}", strings.Join(ids, " "))
+ return b.String()
+}
+
+func (c *RaftCluster) genID() {
+ mIDs := c.MemberIDs()
+ b := make([]byte, 8*len(mIDs))
+ for i, id := range mIDs {
+ binary.BigEndian.PutUint64(b[8*i:], uint64(id))
+ }
+ hash := sha1.Sum(b)
+ c.id = types.ID(binary.BigEndian.Uint64(hash[:8]))
+}
+
+func (c *RaftCluster) SetID(id types.ID) { c.id = id }
+
+func (c *RaftCluster) SetStore(st store.Store) { c.store = st }
+
+func (c *RaftCluster) SetBackend(be backend.Backend) {
+ c.be = be
+ mustCreateBackendBuckets(c.be)
+}
+
+func (c *RaftCluster) Recover(onSet func(*semver.Version)) {
+ c.Lock()
+ defer c.Unlock()
+
+ c.members, c.removed = membersFromStore(c.store)
+ c.version = clusterVersionFromStore(c.store)
+ mustDetectDowngrade(c.version)
+ onSet(c.version)
+
+ for _, m := range c.members {
+ plog.Infof("added member %s %v to cluster %s from store", m.ID, m.PeerURLs, c.id)
+ }
+ if c.version != nil {
+ plog.Infof("set the cluster version to %v from store", version.Cluster(c.version.String()))
+ }
+}
+
+// ValidateConfigurationChange takes a proposed ConfChange and
+// ensures that it is still valid.
+func (c *RaftCluster) ValidateConfigurationChange(cc raftpb.ConfChange) error {
+ members, removed := membersFromStore(c.store)
+ id := types.ID(cc.NodeID)
+ if removed[id] {
+ return ErrIDRemoved
+ }
+ switch cc.Type {
+ case raftpb.ConfChangeAddNode:
+ if members[id] != nil {
+ return ErrIDExists
+ }
+ urls := make(map[string]bool)
+ for _, m := range members {
+ for _, u := range m.PeerURLs {
+ urls[u] = true
+ }
+ }
+ m := new(Member)
+ if err := json.Unmarshal(cc.Context, m); err != nil {
+ plog.Panicf("unmarshal member should never fail: %v", err)
+ }
+ for _, u := range m.PeerURLs {
+ if urls[u] {
+ return ErrPeerURLexists
+ }
+ }
+ case raftpb.ConfChangeRemoveNode:
+ if members[id] == nil {
+ return ErrIDNotFound
+ }
+ case raftpb.ConfChangeUpdateNode:
+ if members[id] == nil {
+ return ErrIDNotFound
+ }
+ urls := make(map[string]bool)
+ for _, m := range members {
+ if m.ID == id {
+ continue
+ }
+ for _, u := range m.PeerURLs {
+ urls[u] = true
+ }
+ }
+ m := new(Member)
+ if err := json.Unmarshal(cc.Context, m); err != nil {
+ plog.Panicf("unmarshal member should never fail: %v", err)
+ }
+ for _, u := range m.PeerURLs {
+ if urls[u] {
+ return ErrPeerURLexists
+ }
+ }
+ default:
+ plog.Panicf("ConfChange type should be either AddNode, RemoveNode or UpdateNode")
+ }
+ return nil
+}
+
+// AddMember adds a new Member into the cluster, and saves the given member's
+// raftAttributes into the store. The given member should have empty attributes.
+// A Member with a matching id must not exist.
+func (c *RaftCluster) AddMember(m *Member) {
+ c.Lock()
+ defer c.Unlock()
+ if c.store != nil {
+ mustSaveMemberToStore(c.store, m)
+ }
+ if c.be != nil {
+ mustSaveMemberToBackend(c.be, m)
+ }
+
+ c.members[m.ID] = m
+
+ plog.Infof("added member %s %v to cluster %s", m.ID, m.PeerURLs, c.id)
+}
+
+// RemoveMember removes a member from the store.
+// The given id MUST exist, or the function panics.
+func (c *RaftCluster) RemoveMember(id types.ID) {
+ c.Lock()
+ defer c.Unlock()
+ if c.store != nil {
+ mustDeleteMemberFromStore(c.store, id)
+ }
+ if c.be != nil {
+ mustDeleteMemberFromBackend(c.be, id)
+ }
+
+ delete(c.members, id)
+ c.removed[id] = true
+
+ plog.Infof("removed member %s from cluster %s", id, c.id)
+}
+
+func (c *RaftCluster) UpdateAttributes(id types.ID, attr Attributes) {
+ c.Lock()
+ defer c.Unlock()
+ if m, ok := c.members[id]; ok {
+ m.Attributes = attr
+ if c.store != nil {
+ mustUpdateMemberAttrInStore(c.store, m)
+ }
+ if c.be != nil {
+ mustSaveMemberToBackend(c.be, m)
+ }
+ return
+ }
+ _, ok := c.removed[id]
+ if !ok {
+ plog.Panicf("error updating attributes of unknown member %s", id)
+ }
+ plog.Warningf("skipped updating attributes of removed member %s", id)
+}
+
+func (c *RaftCluster) UpdateRaftAttributes(id types.ID, raftAttr RaftAttributes) {
+ c.Lock()
+ defer c.Unlock()
+
+ c.members[id].RaftAttributes = raftAttr
+ if c.store != nil {
+ mustUpdateMemberInStore(c.store, c.members[id])
+ }
+ if c.be != nil {
+ mustSaveMemberToBackend(c.be, c.members[id])
+ }
+
+ plog.Noticef("updated member %s %v in cluster %s", id, raftAttr.PeerURLs, c.id)
+}
+
+func (c *RaftCluster) Version() *semver.Version {
+ c.Lock()
+ defer c.Unlock()
+ if c.version == nil {
+ return nil
+ }
+ return semver.Must(semver.NewVersion(c.version.String()))
+}
+
+func (c *RaftCluster) SetVersion(ver *semver.Version, onSet func(*semver.Version)) {
+ c.Lock()
+ defer c.Unlock()
+ if c.version != nil {
+ plog.Noticef("updated the cluster version from %v to %v", version.Cluster(c.version.String()), version.Cluster(ver.String()))
+ } else {
+ plog.Noticef("set the initial cluster version to %v", version.Cluster(ver.String()))
+ }
+ c.version = ver
+ mustDetectDowngrade(c.version)
+ if c.store != nil {
+ mustSaveClusterVersionToStore(c.store, ver)
+ }
+ if c.be != nil {
+ mustSaveClusterVersionToBackend(c.be, ver)
+ }
+ onSet(ver)
+}
+
+func (c *RaftCluster) IsReadyToAddNewMember() bool {
+ nmembers := 1
+ nstarted := 0
+
+ for _, member := range c.members {
+ if member.IsStarted() {
+ nstarted++
+ }
+ nmembers++
+ }
+
+ if nstarted == 1 && nmembers == 2 {
+ // a case of adding a new node to 1-member cluster for restoring cluster data
+ // https://github.com/coreos/etcd/blob/master/Documentation/v2/admin_guide.md#restoring-the-cluster
+
+ plog.Debugf("The number of started member is 1. This cluster can accept add member request.")
+ return true
+ }
+
+ nquorum := nmembers/2 + 1
+ if nstarted < nquorum {
+ plog.Warningf("Reject add member request: the number of started member (%d) will be less than the quorum number of the cluster (%d)", nstarted, nquorum)
+ return false
+ }
+
+ return true
+}
+
+func (c *RaftCluster) IsReadyToRemoveMember(id uint64) bool {
+ nmembers := 0
+ nstarted := 0
+
+ for _, member := range c.members {
+ if uint64(member.ID) == id {
+ continue
+ }
+
+ if member.IsStarted() {
+ nstarted++
+ }
+ nmembers++
+ }
+
+ nquorum := nmembers/2 + 1
+ if nstarted < nquorum {
+ plog.Warningf("Reject remove member request: the number of started member (%d) will be less than the quorum number of the cluster (%d)", nstarted, nquorum)
+ return false
+ }
+
+ return true
+}
+
+func membersFromStore(st store.Store) (map[types.ID]*Member, map[types.ID]bool) {
+ members := make(map[types.ID]*Member)
+ removed := make(map[types.ID]bool)
+ e, err := st.Get(StoreMembersPrefix, true, true)
+ if err != nil {
+ if isKeyNotFound(err) {
+ return members, removed
+ }
+ plog.Panicf("get storeMembers should never fail: %v", err)
+ }
+ for _, n := range e.Node.Nodes {
+ var m *Member
+ m, err = nodeToMember(n)
+ if err != nil {
+ plog.Panicf("nodeToMember should never fail: %v", err)
+ }
+ members[m.ID] = m
+ }
+
+ e, err = st.Get(storeRemovedMembersPrefix, true, true)
+ if err != nil {
+ if isKeyNotFound(err) {
+ return members, removed
+ }
+ plog.Panicf("get storeRemovedMembers should never fail: %v", err)
+ }
+ for _, n := range e.Node.Nodes {
+ removed[MustParseMemberIDFromKey(n.Key)] = true
+ }
+ return members, removed
+}
+
+func clusterVersionFromStore(st store.Store) *semver.Version {
+ e, err := st.Get(path.Join(storePrefix, "version"), false, false)
+ if err != nil {
+ if isKeyNotFound(err) {
+ return nil
+ }
+ plog.Panicf("unexpected error (%v) when getting cluster version from store", err)
+ }
+ return semver.Must(semver.NewVersion(*e.Node.Value))
+}
+
+// ValidateClusterAndAssignIDs validates the local cluster by matching the PeerURLs
+// with the existing cluster. If the validation succeeds, it assigns the IDs
+// from the existing cluster to the local cluster.
+// If the validation fails, an error will be returned.
+func ValidateClusterAndAssignIDs(local *RaftCluster, existing *RaftCluster) error {
+ ems := existing.Members()
+ lms := local.Members()
+ if len(ems) != len(lms) {
+ return fmt.Errorf("member count is unequal")
+ }
+ sort.Sort(MembersByPeerURLs(ems))
+ sort.Sort(MembersByPeerURLs(lms))
+
+ ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
+ defer cancel()
+ for i := range ems {
+ if !netutil.URLStringsEqual(ctx, ems[i].PeerURLs, lms[i].PeerURLs) {
+ return fmt.Errorf("unmatched member while checking PeerURLs")
+ }
+ lms[i].ID = ems[i].ID
+ }
+ local.members = make(map[types.ID]*Member)
+ for _, m := range lms {
+ local.members[m.ID] = m
+ }
+ return nil
+}
+
+func mustDetectDowngrade(cv *semver.Version) {
+ lv := semver.Must(semver.NewVersion(version.Version))
+ // only keep major.minor version for comparison against cluster version
+ lv = &semver.Version{Major: lv.Major, Minor: lv.Minor}
+ if cv != nil && lv.LessThan(*cv) {
+ plog.Fatalf("cluster cannot be downgraded (current version: %s is lower than determined cluster version: %s).", version.Version, version.Cluster(cv.String()))
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/membership/cluster_test.go b/vendor/github.com/coreos/etcd/etcdserver/membership/cluster_test.go
new file mode 100644
index 00000000..c2ffd25b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/membership/cluster_test.go
@@ -0,0 +1,734 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 membership
+
+import (
+ "encoding/json"
+ "fmt"
+ "path"
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/mock/mockstore"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/store"
+)
+
+func TestClusterMember(t *testing.T) {
+ membs := []*Member{
+ newTestMember(1, nil, "node1", nil),
+ newTestMember(2, nil, "node2", nil),
+ }
+ tests := []struct {
+ id types.ID
+ match bool
+ }{
+ {1, true},
+ {2, true},
+ {3, false},
+ }
+ for i, tt := range tests {
+ c := newTestCluster(membs)
+ m := c.Member(tt.id)
+ if g := m != nil; g != tt.match {
+ t.Errorf("#%d: find member = %v, want %v", i, g, tt.match)
+ }
+ if m != nil && m.ID != tt.id {
+ t.Errorf("#%d: id = %x, want %x", i, m.ID, tt.id)
+ }
+ }
+}
+
+func TestClusterMemberByName(t *testing.T) {
+ membs := []*Member{
+ newTestMember(1, nil, "node1", nil),
+ newTestMember(2, nil, "node2", nil),
+ }
+ tests := []struct {
+ name string
+ match bool
+ }{
+ {"node1", true},
+ {"node2", true},
+ {"node3", false},
+ }
+ for i, tt := range tests {
+ c := newTestCluster(membs)
+ m := c.MemberByName(tt.name)
+ if g := m != nil; g != tt.match {
+ t.Errorf("#%d: find member = %v, want %v", i, g, tt.match)
+ }
+ if m != nil && m.Name != tt.name {
+ t.Errorf("#%d: name = %v, want %v", i, m.Name, tt.name)
+ }
+ }
+}
+
+func TestClusterMemberIDs(t *testing.T) {
+ c := newTestCluster([]*Member{
+ newTestMember(1, nil, "", nil),
+ newTestMember(4, nil, "", nil),
+ newTestMember(100, nil, "", nil),
+ })
+ w := []types.ID{1, 4, 100}
+ g := c.MemberIDs()
+ if !reflect.DeepEqual(w, g) {
+ t.Errorf("IDs = %+v, want %+v", g, w)
+ }
+}
+
+func TestClusterPeerURLs(t *testing.T) {
+ tests := []struct {
+ mems []*Member
+ wurls []string
+ }{
+ // single peer with a single address
+ {
+ mems: []*Member{
+ newTestMember(1, []string{"http://192.0.2.1"}, "", nil),
+ },
+ wurls: []string{"http://192.0.2.1"},
+ },
+
+ // single peer with a single address with a port
+ {
+ mems: []*Member{
+ newTestMember(1, []string{"http://192.0.2.1:8001"}, "", nil),
+ },
+ wurls: []string{"http://192.0.2.1:8001"},
+ },
+
+ // several members explicitly unsorted
+ {
+ mems: []*Member{
+ newTestMember(2, []string{"http://192.0.2.3", "http://192.0.2.4"}, "", nil),
+ newTestMember(3, []string{"http://192.0.2.5", "http://192.0.2.6"}, "", nil),
+ newTestMember(1, []string{"http://192.0.2.1", "http://192.0.2.2"}, "", nil),
+ },
+ wurls: []string{"http://192.0.2.1", "http://192.0.2.2", "http://192.0.2.3", "http://192.0.2.4", "http://192.0.2.5", "http://192.0.2.6"},
+ },
+
+ // no members
+ {
+ mems: []*Member{},
+ wurls: []string{},
+ },
+
+ // peer with no peer urls
+ {
+ mems: []*Member{
+ newTestMember(3, []string{}, "", nil),
+ },
+ wurls: []string{},
+ },
+ }
+
+ for i, tt := range tests {
+ c := newTestCluster(tt.mems)
+ urls := c.PeerURLs()
+ if !reflect.DeepEqual(urls, tt.wurls) {
+ t.Errorf("#%d: PeerURLs = %v, want %v", i, urls, tt.wurls)
+ }
+ }
+}
+
+func TestClusterClientURLs(t *testing.T) {
+ tests := []struct {
+ mems []*Member
+ wurls []string
+ }{
+ // single peer with a single address
+ {
+ mems: []*Member{
+ newTestMember(1, nil, "", []string{"http://192.0.2.1"}),
+ },
+ wurls: []string{"http://192.0.2.1"},
+ },
+
+ // single peer with a single address with a port
+ {
+ mems: []*Member{
+ newTestMember(1, nil, "", []string{"http://192.0.2.1:8001"}),
+ },
+ wurls: []string{"http://192.0.2.1:8001"},
+ },
+
+ // several members explicitly unsorted
+ {
+ mems: []*Member{
+ newTestMember(2, nil, "", []string{"http://192.0.2.3", "http://192.0.2.4"}),
+ newTestMember(3, nil, "", []string{"http://192.0.2.5", "http://192.0.2.6"}),
+ newTestMember(1, nil, "", []string{"http://192.0.2.1", "http://192.0.2.2"}),
+ },
+ wurls: []string{"http://192.0.2.1", "http://192.0.2.2", "http://192.0.2.3", "http://192.0.2.4", "http://192.0.2.5", "http://192.0.2.6"},
+ },
+
+ // no members
+ {
+ mems: []*Member{},
+ wurls: []string{},
+ },
+
+ // peer with no client urls
+ {
+ mems: []*Member{
+ newTestMember(3, nil, "", []string{}),
+ },
+ wurls: []string{},
+ },
+ }
+
+ for i, tt := range tests {
+ c := newTestCluster(tt.mems)
+ urls := c.ClientURLs()
+ if !reflect.DeepEqual(urls, tt.wurls) {
+ t.Errorf("#%d: ClientURLs = %v, want %v", i, urls, tt.wurls)
+ }
+ }
+}
+
+func TestClusterValidateAndAssignIDsBad(t *testing.T) {
+ tests := []struct {
+ clmembs []*Member
+ membs []*Member
+ }{
+ {
+ // unmatched length
+ []*Member{
+ newTestMember(1, []string{"http://127.0.0.1:2379"}, "", nil),
+ },
+ []*Member{},
+ },
+ {
+ // unmatched peer urls
+ []*Member{
+ newTestMember(1, []string{"http://127.0.0.1:2379"}, "", nil),
+ },
+ []*Member{
+ newTestMember(1, []string{"http://127.0.0.1:4001"}, "", nil),
+ },
+ },
+ {
+ // unmatched peer urls
+ []*Member{
+ newTestMember(1, []string{"http://127.0.0.1:2379"}, "", nil),
+ newTestMember(2, []string{"http://127.0.0.2:2379"}, "", nil),
+ },
+ []*Member{
+ newTestMember(1, []string{"http://127.0.0.1:2379"}, "", nil),
+ newTestMember(2, []string{"http://127.0.0.2:4001"}, "", nil),
+ },
+ },
+ }
+ for i, tt := range tests {
+ ecl := newTestCluster(tt.clmembs)
+ lcl := newTestCluster(tt.membs)
+ if err := ValidateClusterAndAssignIDs(lcl, ecl); err == nil {
+ t.Errorf("#%d: unexpected update success", i)
+ }
+ }
+}
+
+func TestClusterValidateAndAssignIDs(t *testing.T) {
+ tests := []struct {
+ clmembs []*Member
+ membs []*Member
+ wids []types.ID
+ }{
+ {
+ []*Member{
+ newTestMember(1, []string{"http://127.0.0.1:2379"}, "", nil),
+ newTestMember(2, []string{"http://127.0.0.2:2379"}, "", nil),
+ },
+ []*Member{
+ newTestMember(3, []string{"http://127.0.0.1:2379"}, "", nil),
+ newTestMember(4, []string{"http://127.0.0.2:2379"}, "", nil),
+ },
+ []types.ID{3, 4},
+ },
+ }
+ for i, tt := range tests {
+ lcl := newTestCluster(tt.clmembs)
+ ecl := newTestCluster(tt.membs)
+ if err := ValidateClusterAndAssignIDs(lcl, ecl); err != nil {
+ t.Errorf("#%d: unexpect update error: %v", i, err)
+ }
+ if !reflect.DeepEqual(lcl.MemberIDs(), tt.wids) {
+ t.Errorf("#%d: ids = %v, want %v", i, lcl.MemberIDs(), tt.wids)
+ }
+ }
+}
+
+func TestClusterValidateConfigurationChange(t *testing.T) {
+ cl := NewCluster("")
+ cl.SetStore(store.New())
+ for i := 1; i <= 4; i++ {
+ attr := RaftAttributes{PeerURLs: []string{fmt.Sprintf("http://127.0.0.1:%d", i)}}
+ cl.AddMember(&Member{ID: types.ID(i), RaftAttributes: attr})
+ }
+ cl.RemoveMember(4)
+
+ attr := RaftAttributes{PeerURLs: []string{fmt.Sprintf("http://127.0.0.1:%d", 1)}}
+ ctx, err := json.Marshal(&Member{ID: types.ID(5), RaftAttributes: attr})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ attr = RaftAttributes{PeerURLs: []string{fmt.Sprintf("http://127.0.0.1:%d", 5)}}
+ ctx5, err := json.Marshal(&Member{ID: types.ID(5), RaftAttributes: attr})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ attr = RaftAttributes{PeerURLs: []string{fmt.Sprintf("http://127.0.0.1:%d", 3)}}
+ ctx2to3, err := json.Marshal(&Member{ID: types.ID(2), RaftAttributes: attr})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ attr = RaftAttributes{PeerURLs: []string{fmt.Sprintf("http://127.0.0.1:%d", 5)}}
+ ctx2to5, err := json.Marshal(&Member{ID: types.ID(2), RaftAttributes: attr})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ tests := []struct {
+ cc raftpb.ConfChange
+ werr error
+ }{
+ {
+ raftpb.ConfChange{
+ Type: raftpb.ConfChangeRemoveNode,
+ NodeID: 3,
+ },
+ nil,
+ },
+ {
+ raftpb.ConfChange{
+ Type: raftpb.ConfChangeAddNode,
+ NodeID: 4,
+ },
+ ErrIDRemoved,
+ },
+ {
+ raftpb.ConfChange{
+ Type: raftpb.ConfChangeRemoveNode,
+ NodeID: 4,
+ },
+ ErrIDRemoved,
+ },
+ {
+ raftpb.ConfChange{
+ Type: raftpb.ConfChangeAddNode,
+ NodeID: 1,
+ },
+ ErrIDExists,
+ },
+ {
+ raftpb.ConfChange{
+ Type: raftpb.ConfChangeAddNode,
+ NodeID: 5,
+ Context: ctx,
+ },
+ ErrPeerURLexists,
+ },
+ {
+ raftpb.ConfChange{
+ Type: raftpb.ConfChangeRemoveNode,
+ NodeID: 5,
+ },
+ ErrIDNotFound,
+ },
+ {
+ raftpb.ConfChange{
+ Type: raftpb.ConfChangeAddNode,
+ NodeID: 5,
+ Context: ctx5,
+ },
+ nil,
+ },
+ {
+ raftpb.ConfChange{
+ Type: raftpb.ConfChangeUpdateNode,
+ NodeID: 5,
+ Context: ctx,
+ },
+ ErrIDNotFound,
+ },
+ // try to change the peer url of 2 to the peer url of 3
+ {
+ raftpb.ConfChange{
+ Type: raftpb.ConfChangeUpdateNode,
+ NodeID: 2,
+ Context: ctx2to3,
+ },
+ ErrPeerURLexists,
+ },
+ {
+ raftpb.ConfChange{
+ Type: raftpb.ConfChangeUpdateNode,
+ NodeID: 2,
+ Context: ctx2to5,
+ },
+ nil,
+ },
+ }
+ for i, tt := range tests {
+ err := cl.ValidateConfigurationChange(tt.cc)
+ if err != tt.werr {
+ t.Errorf("#%d: validateConfigurationChange error = %v, want %v", i, err, tt.werr)
+ }
+ }
+}
+
+func TestClusterGenID(t *testing.T) {
+ cs := newTestCluster([]*Member{
+ newTestMember(1, nil, "", nil),
+ newTestMember(2, nil, "", nil),
+ })
+
+ cs.genID()
+ if cs.ID() == 0 {
+ t.Fatalf("cluster.ID = %v, want not 0", cs.ID())
+ }
+ previd := cs.ID()
+
+ cs.SetStore(mockstore.NewNop())
+ cs.AddMember(newTestMember(3, nil, "", nil))
+ cs.genID()
+ if cs.ID() == previd {
+ t.Fatalf("cluster.ID = %v, want not %v", cs.ID(), previd)
+ }
+}
+
+func TestNodeToMemberBad(t *testing.T) {
+ tests := []*store.NodeExtern{
+ {Key: "/1234", Nodes: []*store.NodeExtern{
+ {Key: "/1234/strange"},
+ }},
+ {Key: "/1234", Nodes: []*store.NodeExtern{
+ {Key: "/1234/raftAttributes", Value: stringp("garbage")},
+ }},
+ {Key: "/1234", Nodes: []*store.NodeExtern{
+ {Key: "/1234/attributes", Value: stringp(`{"name":"node1","clientURLs":null}`)},
+ }},
+ {Key: "/1234", Nodes: []*store.NodeExtern{
+ {Key: "/1234/raftAttributes", Value: stringp(`{"peerURLs":null}`)},
+ {Key: "/1234/strange"},
+ }},
+ {Key: "/1234", Nodes: []*store.NodeExtern{
+ {Key: "/1234/raftAttributes", Value: stringp(`{"peerURLs":null}`)},
+ {Key: "/1234/attributes", Value: stringp("garbage")},
+ }},
+ {Key: "/1234", Nodes: []*store.NodeExtern{
+ {Key: "/1234/raftAttributes", Value: stringp(`{"peerURLs":null}`)},
+ {Key: "/1234/attributes", Value: stringp(`{"name":"node1","clientURLs":null}`)},
+ {Key: "/1234/strange"},
+ }},
+ }
+ for i, tt := range tests {
+ if _, err := nodeToMember(tt); err == nil {
+ t.Errorf("#%d: unexpected nil error", i)
+ }
+ }
+}
+
+func TestClusterAddMember(t *testing.T) {
+ st := mockstore.NewRecorder()
+ c := newTestCluster(nil)
+ c.SetStore(st)
+ c.AddMember(newTestMember(1, nil, "node1", nil))
+
+ wactions := []testutil.Action{
+ {
+ Name: "Create",
+ Params: []interface{}{
+ path.Join(StoreMembersPrefix, "1", "raftAttributes"),
+ false,
+ `{"peerURLs":null}`,
+ false,
+ store.TTLOptionSet{ExpireTime: store.Permanent},
+ },
+ },
+ }
+ if g := st.Action(); !reflect.DeepEqual(g, wactions) {
+ t.Errorf("actions = %v, want %v", g, wactions)
+ }
+}
+
+func TestClusterMembers(t *testing.T) {
+ cls := &RaftCluster{
+ members: map[types.ID]*Member{
+ 1: {ID: 1},
+ 20: {ID: 20},
+ 100: {ID: 100},
+ 5: {ID: 5},
+ 50: {ID: 50},
+ },
+ }
+ w := []*Member{
+ {ID: 1},
+ {ID: 5},
+ {ID: 20},
+ {ID: 50},
+ {ID: 100},
+ }
+ if g := cls.Members(); !reflect.DeepEqual(g, w) {
+ t.Fatalf("Members()=%#v, want %#v", g, w)
+ }
+}
+
+func TestClusterRemoveMember(t *testing.T) {
+ st := mockstore.NewRecorder()
+ c := newTestCluster(nil)
+ c.SetStore(st)
+ c.RemoveMember(1)
+
+ wactions := []testutil.Action{
+ {Name: "Delete", Params: []interface{}{MemberStoreKey(1), true, true}},
+ {Name: "Create", Params: []interface{}{RemovedMemberStoreKey(1), false, "", false, store.TTLOptionSet{ExpireTime: store.Permanent}}},
+ }
+ if !reflect.DeepEqual(st.Action(), wactions) {
+ t.Errorf("actions = %v, want %v", st.Action(), wactions)
+ }
+}
+
+func TestClusterUpdateAttributes(t *testing.T) {
+ name := "etcd"
+ clientURLs := []string{"http://127.0.0.1:4001"}
+ tests := []struct {
+ mems []*Member
+ removed map[types.ID]bool
+ wmems []*Member
+ }{
+ // update attributes of existing member
+ {
+ []*Member{
+ newTestMember(1, nil, "", nil),
+ },
+ nil,
+ []*Member{
+ newTestMember(1, nil, name, clientURLs),
+ },
+ },
+ // update attributes of removed member
+ {
+ nil,
+ map[types.ID]bool{types.ID(1): true},
+ nil,
+ },
+ }
+ for i, tt := range tests {
+ c := newTestCluster(tt.mems)
+ c.removed = tt.removed
+
+ c.UpdateAttributes(types.ID(1), Attributes{Name: name, ClientURLs: clientURLs})
+ if g := c.Members(); !reflect.DeepEqual(g, tt.wmems) {
+ t.Errorf("#%d: members = %+v, want %+v", i, g, tt.wmems)
+ }
+ }
+}
+
+func TestNodeToMember(t *testing.T) {
+ n := &store.NodeExtern{Key: "/1234", Nodes: []*store.NodeExtern{
+ {Key: "/1234/attributes", Value: stringp(`{"name":"node1","clientURLs":null}`)},
+ {Key: "/1234/raftAttributes", Value: stringp(`{"peerURLs":null}`)},
+ }}
+ wm := &Member{ID: 0x1234, RaftAttributes: RaftAttributes{}, Attributes: Attributes{Name: "node1"}}
+ m, err := nodeToMember(n)
+ if err != nil {
+ t.Fatalf("unexpected nodeToMember error: %v", err)
+ }
+ if !reflect.DeepEqual(m, wm) {
+ t.Errorf("member = %+v, want %+v", m, wm)
+ }
+}
+
+func newTestCluster(membs []*Member) *RaftCluster {
+ c := &RaftCluster{members: make(map[types.ID]*Member), removed: make(map[types.ID]bool)}
+ for _, m := range membs {
+ c.members[m.ID] = m
+ }
+ return c
+}
+
+func stringp(s string) *string { return &s }
+
+func TestIsReadyToAddNewMember(t *testing.T) {
+ tests := []struct {
+ members []*Member
+ want bool
+ }{
+ {
+ // 0/3 members ready, should fail
+ []*Member{
+ newTestMember(1, nil, "", nil),
+ newTestMember(2, nil, "", nil),
+ newTestMember(3, nil, "", nil),
+ },
+ false,
+ },
+ {
+ // 1/2 members ready, should fail
+ []*Member{
+ newTestMember(1, nil, "1", nil),
+ newTestMember(2, nil, "", nil),
+ },
+ false,
+ },
+ {
+ // 1/3 members ready, should fail
+ []*Member{
+ newTestMember(1, nil, "1", nil),
+ newTestMember(2, nil, "", nil),
+ newTestMember(3, nil, "", nil),
+ },
+ false,
+ },
+ {
+ // 1/1 members ready, should succeed (special case of 1-member cluster for recovery)
+ []*Member{
+ newTestMember(1, nil, "1", nil),
+ },
+ true,
+ },
+ {
+ // 2/3 members ready, should fail
+ []*Member{
+ newTestMember(1, nil, "1", nil),
+ newTestMember(2, nil, "2", nil),
+ newTestMember(3, nil, "", nil),
+ },
+ false,
+ },
+ {
+ // 3/3 members ready, should be fine to add one member and retain quorum
+ []*Member{
+ newTestMember(1, nil, "1", nil),
+ newTestMember(2, nil, "2", nil),
+ newTestMember(3, nil, "3", nil),
+ },
+ true,
+ },
+ {
+ // 3/4 members ready, should be fine to add one member and retain quorum
+ []*Member{
+ newTestMember(1, nil, "1", nil),
+ newTestMember(2, nil, "2", nil),
+ newTestMember(3, nil, "3", nil),
+ newTestMember(4, nil, "", nil),
+ },
+ true,
+ },
+ {
+ // empty cluster, it is impossible but should fail
+ []*Member{},
+ false,
+ },
+ }
+ for i, tt := range tests {
+ c := newTestCluster(tt.members)
+ if got := c.IsReadyToAddNewMember(); got != tt.want {
+ t.Errorf("%d: isReadyToAddNewMember returned %t, want %t", i, got, tt.want)
+ }
+ }
+}
+
+func TestIsReadyToRemoveMember(t *testing.T) {
+ tests := []struct {
+ members []*Member
+ removeID uint64
+ want bool
+ }{
+ {
+ // 1/1 members ready, should fail
+ []*Member{
+ newTestMember(1, nil, "1", nil),
+ },
+ 1,
+ false,
+ },
+ {
+ // 0/3 members ready, should fail
+ []*Member{
+ newTestMember(1, nil, "", nil),
+ newTestMember(2, nil, "", nil),
+ newTestMember(3, nil, "", nil),
+ },
+ 1,
+ false,
+ },
+ {
+ // 1/2 members ready, should be fine to remove unstarted member
+ // (isReadyToRemoveMember() logic should return success, but operation itself would fail)
+ []*Member{
+ newTestMember(1, nil, "1", nil),
+ newTestMember(2, nil, "", nil),
+ },
+ 2,
+ true,
+ },
+ {
+ // 2/3 members ready, should fail
+ []*Member{
+ newTestMember(1, nil, "1", nil),
+ newTestMember(2, nil, "2", nil),
+ newTestMember(3, nil, "", nil),
+ },
+ 2,
+ false,
+ },
+ {
+ // 3/3 members ready, should be fine to remove one member and retain quorum
+ []*Member{
+ newTestMember(1, nil, "1", nil),
+ newTestMember(2, nil, "2", nil),
+ newTestMember(3, nil, "3", nil),
+ },
+ 3,
+ true,
+ },
+ {
+ // 3/4 members ready, should be fine to remove one member
+ []*Member{
+ newTestMember(1, nil, "1", nil),
+ newTestMember(2, nil, "2", nil),
+ newTestMember(3, nil, "3", nil),
+ newTestMember(4, nil, "", nil),
+ },
+ 3,
+ true,
+ },
+ {
+ // 3/4 members ready, should be fine to remove unstarted member
+ []*Member{
+ newTestMember(1, nil, "1", nil),
+ newTestMember(2, nil, "2", nil),
+ newTestMember(3, nil, "3", nil),
+ newTestMember(4, nil, "", nil),
+ },
+ 4,
+ true,
+ },
+ }
+ for i, tt := range tests {
+ c := newTestCluster(tt.members)
+ if got := c.IsReadyToRemoveMember(tt.removeID); got != tt.want {
+ t.Errorf("%d: isReadyToAddNewMember returned %t, want %t", i, got, tt.want)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/membership/doc.go b/vendor/github.com/coreos/etcd/etcdserver/membership/doc.go
new file mode 100644
index 00000000..b07fb2d9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/membership/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 membership describes individual etcd members and clusters of members.
+package membership
diff --git a/vendor/github.com/coreos/etcd/etcdserver/membership/errors.go b/vendor/github.com/coreos/etcd/etcdserver/membership/errors.go
new file mode 100644
index 00000000..e4d36af2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/membership/errors.go
@@ -0,0 +1,33 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 membership
+
+import (
+ "errors"
+
+ etcdErr "github.com/coreos/etcd/error"
+)
+
+var (
+ ErrIDRemoved = errors.New("membership: ID removed")
+ ErrIDExists = errors.New("membership: ID exists")
+ ErrIDNotFound = errors.New("membership: ID not found")
+ ErrPeerURLexists = errors.New("membership: peerURL exists")
+)
+
+func isKeyNotFound(err error) bool {
+ e, ok := err.(*etcdErr.Error)
+ return ok && e.ErrorCode == etcdErr.EcodeKeyNotFound
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/membership/member.go b/vendor/github.com/coreos/etcd/etcdserver/membership/member.go
new file mode 100644
index 00000000..6de74d26
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/membership/member.go
@@ -0,0 +1,124 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 membership
+
+import (
+ "crypto/sha1"
+ "encoding/binary"
+ "fmt"
+ "math/rand"
+ "sort"
+ "time"
+
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/pkg/capnslog"
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "etcdserver/membership")
+)
+
+// RaftAttributes represents the raft related attributes of an etcd member.
+type RaftAttributes struct {
+ // PeerURLs is the list of peers in the raft cluster.
+ // TODO(philips): ensure these are URLs
+ PeerURLs []string `json:"peerURLs"`
+}
+
+// Attributes represents all the non-raft related attributes of an etcd member.
+type Attributes struct {
+ Name string `json:"name,omitempty"`
+ ClientURLs []string `json:"clientURLs,omitempty"`
+}
+
+type Member struct {
+ ID types.ID `json:"id"`
+ RaftAttributes
+ Attributes
+}
+
+// NewMember creates a Member without an ID and generates one based on the
+// cluster name, peer URLs, and time. This is used for bootstrapping/adding new member.
+func NewMember(name string, peerURLs types.URLs, clusterName string, now *time.Time) *Member {
+ m := &Member{
+ RaftAttributes: RaftAttributes{PeerURLs: peerURLs.StringSlice()},
+ Attributes: Attributes{Name: name},
+ }
+
+ var b []byte
+ sort.Strings(m.PeerURLs)
+ for _, p := range m.PeerURLs {
+ b = append(b, []byte(p)...)
+ }
+
+ b = append(b, []byte(clusterName)...)
+ if now != nil {
+ b = append(b, []byte(fmt.Sprintf("%d", now.Unix()))...)
+ }
+
+ hash := sha1.Sum(b)
+ m.ID = types.ID(binary.BigEndian.Uint64(hash[:8]))
+ return m
+}
+
+// PickPeerURL chooses a random address from a given Member's PeerURLs.
+// It will panic if there is no PeerURLs available in Member.
+func (m *Member) PickPeerURL() string {
+ if len(m.PeerURLs) == 0 {
+ plog.Panicf("member should always have some peer url")
+ }
+ return m.PeerURLs[rand.Intn(len(m.PeerURLs))]
+}
+
+func (m *Member) Clone() *Member {
+ if m == nil {
+ return nil
+ }
+ mm := &Member{
+ ID: m.ID,
+ Attributes: Attributes{
+ Name: m.Name,
+ },
+ }
+ if m.PeerURLs != nil {
+ mm.PeerURLs = make([]string, len(m.PeerURLs))
+ copy(mm.PeerURLs, m.PeerURLs)
+ }
+ if m.ClientURLs != nil {
+ mm.ClientURLs = make([]string, len(m.ClientURLs))
+ copy(mm.ClientURLs, m.ClientURLs)
+ }
+ return mm
+}
+
+func (m *Member) IsStarted() bool {
+ return len(m.Name) != 0
+}
+
+// MembersByID implements sort by ID interface
+type MembersByID []*Member
+
+func (ms MembersByID) Len() int { return len(ms) }
+func (ms MembersByID) Less(i, j int) bool { return ms[i].ID < ms[j].ID }
+func (ms MembersByID) Swap(i, j int) { ms[i], ms[j] = ms[j], ms[i] }
+
+// MembersByPeerURLs implements sort by peer urls interface
+type MembersByPeerURLs []*Member
+
+func (ms MembersByPeerURLs) Len() int { return len(ms) }
+func (ms MembersByPeerURLs) Less(i, j int) bool {
+ return ms[i].PeerURLs[0] < ms[j].PeerURLs[0]
+}
+func (ms MembersByPeerURLs) Swap(i, j int) { ms[i], ms[j] = ms[j], ms[i] }
diff --git a/vendor/github.com/coreos/etcd/etcdserver/membership/member_test.go b/vendor/github.com/coreos/etcd/etcdserver/membership/member_test.go
new file mode 100644
index 00000000..36015fd1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/membership/member_test.go
@@ -0,0 +1,115 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 membership
+
+import (
+ "net/url"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/types"
+)
+
+func timeParse(value string) *time.Time {
+ t, err := time.Parse(time.RFC3339, value)
+ if err != nil {
+ panic(err)
+ }
+ return &t
+}
+
+func TestMemberTime(t *testing.T) {
+ tests := []struct {
+ mem *Member
+ id types.ID
+ }{
+ {NewMember("mem1", []url.URL{{Scheme: "http", Host: "10.0.0.8:2379"}}, "", nil), 14544069596553697298},
+ // Same ID, different name (names shouldn't matter)
+ {NewMember("memfoo", []url.URL{{Scheme: "http", Host: "10.0.0.8:2379"}}, "", nil), 14544069596553697298},
+ // Same ID, different Time
+ {NewMember("mem1", []url.URL{{Scheme: "http", Host: "10.0.0.8:2379"}}, "", timeParse("1984-12-23T15:04:05Z")), 2448790162483548276},
+ // Different cluster name
+ {NewMember("mcm1", []url.URL{{Scheme: "http", Host: "10.0.0.8:2379"}}, "etcd", timeParse("1984-12-23T15:04:05Z")), 6973882743191604649},
+ {NewMember("mem1", []url.URL{{Scheme: "http", Host: "10.0.0.1:2379"}}, "", timeParse("1984-12-23T15:04:05Z")), 1466075294948436910},
+ // Order shouldn't matter
+ {NewMember("mem1", []url.URL{{Scheme: "http", Host: "10.0.0.1:2379"}, {Scheme: "http", Host: "10.0.0.2:2379"}}, "", nil), 16552244735972308939},
+ {NewMember("mem1", []url.URL{{Scheme: "http", Host: "10.0.0.2:2379"}, {Scheme: "http", Host: "10.0.0.1:2379"}}, "", nil), 16552244735972308939},
+ }
+ for i, tt := range tests {
+ if tt.mem.ID != tt.id {
+ t.Errorf("#%d: mem.ID = %v, want %v", i, tt.mem.ID, tt.id)
+ }
+ }
+}
+
+func TestMemberPick(t *testing.T) {
+ tests := []struct {
+ memb *Member
+ urls map[string]bool
+ }{
+ {
+ newTestMember(1, []string{"abc", "def", "ghi", "jkl", "mno", "pqr", "stu"}, "", nil),
+ map[string]bool{
+ "abc": true,
+ "def": true,
+ "ghi": true,
+ "jkl": true,
+ "mno": true,
+ "pqr": true,
+ "stu": true,
+ },
+ },
+ {
+ newTestMember(2, []string{"xyz"}, "", nil),
+ map[string]bool{"xyz": true},
+ },
+ }
+ for i, tt := range tests {
+ for j := 0; j < 1000; j++ {
+ a := tt.memb.PickPeerURL()
+ if !tt.urls[a] {
+ t.Errorf("#%d: returned ID %q not in expected range!", i, a)
+ break
+ }
+ }
+ }
+}
+
+func TestMemberClone(t *testing.T) {
+ tests := []*Member{
+ newTestMember(1, nil, "abc", nil),
+ newTestMember(1, []string{"http://a"}, "abc", nil),
+ newTestMember(1, nil, "abc", []string{"http://b"}),
+ newTestMember(1, []string{"http://a"}, "abc", []string{"http://b"}),
+ }
+ for i, tt := range tests {
+ nm := tt.Clone()
+ if nm == tt {
+ t.Errorf("#%d: the pointers are the same, and clone doesn't happen", i)
+ }
+ if !reflect.DeepEqual(nm, tt) {
+ t.Errorf("#%d: member = %+v, want %+v", i, nm, tt)
+ }
+ }
+}
+
+func newTestMember(id uint64, peerURLs []string, name string, clientURLs []string) *Member {
+ return &Member{
+ ID: types.ID(id),
+ RaftAttributes: RaftAttributes{PeerURLs: peerURLs},
+ Attributes: Attributes{Name: name, ClientURLs: clientURLs},
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/membership/store.go b/vendor/github.com/coreos/etcd/etcdserver/membership/store.go
new file mode 100644
index 00000000..d3f8f247
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/membership/store.go
@@ -0,0 +1,193 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 membership
+
+import (
+ "encoding/json"
+ "fmt"
+ "path"
+
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/store"
+
+ "github.com/coreos/go-semver/semver"
+)
+
+const (
+ attributesSuffix = "attributes"
+ raftAttributesSuffix = "raftAttributes"
+
+ // the prefix for stroing membership related information in store provided by store pkg.
+ storePrefix = "/0"
+)
+
+var (
+ membersBucketName = []byte("members")
+ membersRemovedBucketName = []byte("members_removed")
+ clusterBucketName = []byte("cluster")
+
+ StoreMembersPrefix = path.Join(storePrefix, "members")
+ storeRemovedMembersPrefix = path.Join(storePrefix, "removed_members")
+)
+
+func mustSaveMemberToBackend(be backend.Backend, m *Member) {
+ mkey := backendMemberKey(m.ID)
+ mvalue, err := json.Marshal(m)
+ if err != nil {
+ plog.Panicf("marshal raftAttributes should never fail: %v", err)
+ }
+
+ tx := be.BatchTx()
+ tx.Lock()
+ tx.UnsafePut(membersBucketName, mkey, mvalue)
+ tx.Unlock()
+}
+
+func mustDeleteMemberFromBackend(be backend.Backend, id types.ID) {
+ mkey := backendMemberKey(id)
+
+ tx := be.BatchTx()
+ tx.Lock()
+ tx.UnsafeDelete(membersBucketName, mkey)
+ tx.UnsafePut(membersRemovedBucketName, mkey, []byte("removed"))
+ tx.Unlock()
+}
+
+func mustSaveClusterVersionToBackend(be backend.Backend, ver *semver.Version) {
+ ckey := backendClusterVersionKey()
+
+ tx := be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+ tx.UnsafePut(clusterBucketName, ckey, []byte(ver.String()))
+}
+
+func mustSaveMemberToStore(s store.Store, m *Member) {
+ b, err := json.Marshal(m.RaftAttributes)
+ if err != nil {
+ plog.Panicf("marshal raftAttributes should never fail: %v", err)
+ }
+ p := path.Join(MemberStoreKey(m.ID), raftAttributesSuffix)
+ if _, err := s.Create(p, false, string(b), false, store.TTLOptionSet{ExpireTime: store.Permanent}); err != nil {
+ plog.Panicf("create raftAttributes should never fail: %v", err)
+ }
+}
+
+func mustDeleteMemberFromStore(s store.Store, id types.ID) {
+ if _, err := s.Delete(MemberStoreKey(id), true, true); err != nil {
+ plog.Panicf("delete member should never fail: %v", err)
+ }
+ if _, err := s.Create(RemovedMemberStoreKey(id), false, "", false, store.TTLOptionSet{ExpireTime: store.Permanent}); err != nil {
+ plog.Panicf("create removedMember should never fail: %v", err)
+ }
+}
+
+func mustUpdateMemberInStore(s store.Store, m *Member) {
+ b, err := json.Marshal(m.RaftAttributes)
+ if err != nil {
+ plog.Panicf("marshal raftAttributes should never fail: %v", err)
+ }
+ p := path.Join(MemberStoreKey(m.ID), raftAttributesSuffix)
+ if _, err := s.Update(p, string(b), store.TTLOptionSet{ExpireTime: store.Permanent}); err != nil {
+ plog.Panicf("update raftAttributes should never fail: %v", err)
+ }
+}
+
+func mustUpdateMemberAttrInStore(s store.Store, m *Member) {
+ b, err := json.Marshal(m.Attributes)
+ if err != nil {
+ plog.Panicf("marshal raftAttributes should never fail: %v", err)
+ }
+ p := path.Join(MemberStoreKey(m.ID), attributesSuffix)
+ if _, err := s.Set(p, false, string(b), store.TTLOptionSet{ExpireTime: store.Permanent}); err != nil {
+ plog.Panicf("update raftAttributes should never fail: %v", err)
+ }
+}
+
+func mustSaveClusterVersionToStore(s store.Store, ver *semver.Version) {
+ if _, err := s.Set(StoreClusterVersionKey(), false, ver.String(), store.TTLOptionSet{ExpireTime: store.Permanent}); err != nil {
+ plog.Panicf("save cluster version should never fail: %v", err)
+ }
+}
+
+// nodeToMember builds member from a key value node.
+// the child nodes of the given node MUST be sorted by key.
+func nodeToMember(n *store.NodeExtern) (*Member, error) {
+ m := &Member{ID: MustParseMemberIDFromKey(n.Key)}
+ attrs := make(map[string][]byte)
+ raftAttrKey := path.Join(n.Key, raftAttributesSuffix)
+ attrKey := path.Join(n.Key, attributesSuffix)
+ for _, nn := range n.Nodes {
+ if nn.Key != raftAttrKey && nn.Key != attrKey {
+ return nil, fmt.Errorf("unknown key %q", nn.Key)
+ }
+ attrs[nn.Key] = []byte(*nn.Value)
+ }
+ if data := attrs[raftAttrKey]; data != nil {
+ if err := json.Unmarshal(data, &m.RaftAttributes); err != nil {
+ return nil, fmt.Errorf("unmarshal raftAttributes error: %v", err)
+ }
+ } else {
+ return nil, fmt.Errorf("raftAttributes key doesn't exist")
+ }
+ if data := attrs[attrKey]; data != nil {
+ if err := json.Unmarshal(data, &m.Attributes); err != nil {
+ return m, fmt.Errorf("unmarshal attributes error: %v", err)
+ }
+ }
+ return m, nil
+}
+
+func backendMemberKey(id types.ID) []byte {
+ return []byte(id.String())
+}
+
+func backendClusterVersionKey() []byte {
+ return []byte("clusterVersion")
+}
+
+func mustCreateBackendBuckets(be backend.Backend) {
+ tx := be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+ tx.UnsafeCreateBucket(membersBucketName)
+ tx.UnsafeCreateBucket(membersRemovedBucketName)
+ tx.UnsafeCreateBucket(clusterBucketName)
+}
+
+func MemberStoreKey(id types.ID) string {
+ return path.Join(StoreMembersPrefix, id.String())
+}
+
+func StoreClusterVersionKey() string {
+ return path.Join(storePrefix, "version")
+}
+
+func MemberAttributesStorePath(id types.ID) string {
+ return path.Join(MemberStoreKey(id), attributesSuffix)
+}
+
+func MustParseMemberIDFromKey(key string) types.ID {
+ id, err := types.IDFromString(path.Base(key))
+ if err != nil {
+ plog.Panicf("unexpected parse member id error: %v", err)
+ }
+ return id
+}
+
+func RemovedMemberStoreKey(id types.ID) string {
+ return path.Join(storeRemovedMembersPrefix, id.String())
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/metrics.go b/vendor/github.com/coreos/etcd/etcdserver/metrics.go
new file mode 100644
index 00000000..90bbd363
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/metrics.go
@@ -0,0 +1,102 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "time"
+
+ "github.com/coreos/etcd/pkg/runtime"
+ "github.com/prometheus/client_golang/prometheus"
+)
+
+var (
+ hasLeader = prometheus.NewGauge(prometheus.GaugeOpts{
+ Namespace: "etcd",
+ Subsystem: "server",
+ Name: "has_leader",
+ Help: "Whether or not a leader exists. 1 is existence, 0 is not.",
+ })
+ leaderChanges = prometheus.NewCounter(prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "server",
+ Name: "leader_changes_seen_total",
+ Help: "The number of leader changes seen.",
+ })
+ proposalsCommitted = prometheus.NewGauge(prometheus.GaugeOpts{
+ Namespace: "etcd",
+ Subsystem: "server",
+ Name: "proposals_committed_total",
+ Help: "The total number of consensus proposals committed.",
+ })
+ proposalsApplied = prometheus.NewGauge(prometheus.GaugeOpts{
+ Namespace: "etcd",
+ Subsystem: "server",
+ Name: "proposals_applied_total",
+ Help: "The total number of consensus proposals applied.",
+ })
+ proposalsPending = prometheus.NewGauge(prometheus.GaugeOpts{
+ Namespace: "etcd",
+ Subsystem: "server",
+ Name: "proposals_pending",
+ Help: "The current number of pending proposals to commit.",
+ })
+ proposalsFailed = prometheus.NewCounter(prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "server",
+ Name: "proposals_failed_total",
+ Help: "The total number of failed proposals seen.",
+ })
+ leaseExpired = prometheus.NewCounter(prometheus.CounterOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "server",
+ Name: "lease_expired_total",
+ Help: "The total number of expired leases.",
+ })
+)
+
+func init() {
+ prometheus.MustRegister(hasLeader)
+ prometheus.MustRegister(leaderChanges)
+ prometheus.MustRegister(proposalsCommitted)
+ prometheus.MustRegister(proposalsApplied)
+ prometheus.MustRegister(proposalsPending)
+ prometheus.MustRegister(proposalsFailed)
+ prometheus.MustRegister(leaseExpired)
+}
+
+func monitorFileDescriptor(done <-chan struct{}) {
+ ticker := time.NewTicker(5 * time.Second)
+ defer ticker.Stop()
+ for {
+ used, err := runtime.FDUsage()
+ if err != nil {
+ plog.Errorf("cannot monitor file descriptor usage (%v)", err)
+ return
+ }
+ limit, err := runtime.FDLimit()
+ if err != nil {
+ plog.Errorf("cannot monitor file descriptor usage (%v)", err)
+ return
+ }
+ if used >= limit/5*4 {
+ plog.Warningf("80%% of the file descriptor limit is used [used = %d, limit = %d]", used, limit)
+ }
+ select {
+ case <-ticker.C:
+ case <-done:
+ return
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/quota.go b/vendor/github.com/coreos/etcd/etcdserver/quota.go
new file mode 100644
index 00000000..87126f15
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/quota.go
@@ -0,0 +1,121 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+const (
+ // DefaultQuotaBytes is the number of bytes the backend Size may
+ // consume before exceeding the space quota.
+ DefaultQuotaBytes = int64(2 * 1024 * 1024 * 1024) // 2GB
+ // MaxQuotaBytes is the maximum number of bytes suggested for a backend
+ // quota. A larger quota may lead to degraded performance.
+ MaxQuotaBytes = int64(8 * 1024 * 1024 * 1024) // 8GB
+)
+
+// Quota represents an arbitrary quota against arbitrary requests. Each request
+// costs some charge; if there is not enough remaining charge, then there are
+// too few resources available within the quota to apply the request.
+type Quota interface {
+ // Available judges whether the given request fits within the quota.
+ Available(req interface{}) bool
+ // Cost computes the charge against the quota for a given request.
+ Cost(req interface{}) int
+ // Remaining is the amount of charge left for the quota.
+ Remaining() int64
+}
+
+type passthroughQuota struct{}
+
+func (*passthroughQuota) Available(interface{}) bool { return true }
+func (*passthroughQuota) Cost(interface{}) int { return 0 }
+func (*passthroughQuota) Remaining() int64 { return 1 }
+
+type backendQuota struct {
+ s *EtcdServer
+ maxBackendBytes int64
+}
+
+const (
+ // leaseOverhead is an estimate for the cost of storing a lease
+ leaseOverhead = 64
+ // kvOverhead is an estimate for the cost of storing a key's metadata
+ kvOverhead = 256
+)
+
+func NewBackendQuota(s *EtcdServer) Quota {
+ if s.Cfg.QuotaBackendBytes < 0 {
+ // disable quotas if negative
+ plog.Warningf("disabling backend quota")
+ return &passthroughQuota{}
+ }
+ if s.Cfg.QuotaBackendBytes == 0 {
+ // use default size if no quota size given
+ return &backendQuota{s, DefaultQuotaBytes}
+ }
+ if s.Cfg.QuotaBackendBytes > MaxQuotaBytes {
+ plog.Warningf("backend quota %v exceeds maximum recommended quota %v", s.Cfg.QuotaBackendBytes, MaxQuotaBytes)
+ }
+ return &backendQuota{s, s.Cfg.QuotaBackendBytes}
+}
+
+func (b *backendQuota) Available(v interface{}) bool {
+ // TODO: maybe optimize backend.Size()
+ return b.s.Backend().Size()+int64(b.Cost(v)) < b.maxBackendBytes
+}
+
+func (b *backendQuota) Cost(v interface{}) int {
+ switch r := v.(type) {
+ case *pb.PutRequest:
+ return costPut(r)
+ case *pb.TxnRequest:
+ return costTxn(r)
+ case *pb.LeaseGrantRequest:
+ return leaseOverhead
+ default:
+ panic("unexpected cost")
+ }
+}
+
+func costPut(r *pb.PutRequest) int { return kvOverhead + len(r.Key) + len(r.Value) }
+
+func costTxnReq(u *pb.RequestOp) int {
+ r := u.GetRequestPut()
+ if r == nil {
+ return 0
+ }
+ return costPut(r)
+}
+
+func costTxn(r *pb.TxnRequest) int {
+ sizeSuccess := 0
+ for _, u := range r.Success {
+ sizeSuccess += costTxnReq(u)
+ }
+ sizeFailure := 0
+ for _, u := range r.Failure {
+ sizeFailure += costTxnReq(u)
+ }
+ if sizeFailure > sizeSuccess {
+ return sizeFailure
+ }
+ return sizeSuccess
+}
+
+func (b *backendQuota) Remaining() int64 {
+ return b.maxBackendBytes - b.s.Backend().Size()
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/raft.go b/vendor/github.com/coreos/etcd/etcdserver/raft.go
new file mode 100644
index 00000000..dcb894f8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/raft.go
@@ -0,0 +1,594 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "encoding/json"
+ "expvar"
+ "sort"
+ "sync"
+ "sync/atomic"
+ "time"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/pkg/contention"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/rafthttp"
+ "github.com/coreos/etcd/wal"
+ "github.com/coreos/etcd/wal/walpb"
+ "github.com/coreos/pkg/capnslog"
+)
+
+const (
+ // Number of entries for slow follower to catch-up after compacting
+ // the raft storage entries.
+ // We expect the follower has a millisecond level latency with the leader.
+ // The max throughput is around 10K. Keep a 5K entries is enough for helping
+ // follower to catch up.
+ numberOfCatchUpEntries = 5000
+
+ // The max throughput of etcd will not exceed 100MB/s (100K * 1KB value).
+ // Assuming the RTT is around 10ms, 1MB max size is large enough.
+ maxSizePerMsg = 1 * 1024 * 1024
+ // Never overflow the rafthttp buffer, which is 4096.
+ // TODO: a better const?
+ maxInflightMsgs = 4096 / 8
+)
+
+var (
+ // protects raftStatus
+ raftStatusMu sync.Mutex
+ // indirection for expvar func interface
+ // expvar panics when publishing duplicate name
+ // expvar does not support remove a registered name
+ // so only register a func that calls raftStatus
+ // and change raftStatus as we need.
+ raftStatus func() raft.Status
+)
+
+func init() {
+ raft.SetLogger(capnslog.NewPackageLogger("github.com/coreos/etcd", "raft"))
+ expvar.Publish("raft.status", expvar.Func(func() interface{} {
+ raftStatusMu.Lock()
+ defer raftStatusMu.Unlock()
+ return raftStatus()
+ }))
+}
+
+type RaftTimer interface {
+ Index() uint64
+ Term() uint64
+}
+
+// apply contains entries, snapshot to be applied. Once
+// an apply is consumed, the entries will be persisted to
+// to raft storage concurrently; the application must read
+// raftDone before assuming the raft messages are stable.
+type apply struct {
+ entries []raftpb.Entry
+ snapshot raftpb.Snapshot
+ // notifyc synchronizes etcd server applies with the raft node
+ notifyc chan struct{}
+}
+
+type raftNode struct {
+ // Cache of the latest raft index and raft term the server has seen.
+ // These three unit64 fields must be the first elements to keep 64-bit
+ // alignment for atomic access to the fields.
+ index uint64
+ term uint64
+ lead uint64
+
+ raftNodeConfig
+
+ // a chan to send/receive snapshot
+ msgSnapC chan raftpb.Message
+
+ // a chan to send out apply
+ applyc chan apply
+
+ // a chan to send out readState
+ readStateC chan raft.ReadState
+
+ // utility
+ ticker *time.Ticker
+ // contention detectors for raft heartbeat message
+ td *contention.TimeoutDetector
+
+ stopped chan struct{}
+ done chan struct{}
+}
+
+type raftNodeConfig struct {
+ // to check if msg receiver is removed from cluster
+ isIDRemoved func(id uint64) bool
+ raft.Node
+ raftStorage *raft.MemoryStorage
+ storage Storage
+ heartbeat time.Duration // for logging
+ // transport specifies the transport to send and receive msgs to members.
+ // Sending messages MUST NOT block. It is okay to drop messages, since
+ // clients should timeout and reissue their messages.
+ // If transport is nil, server will panic.
+ transport rafthttp.Transporter
+}
+
+func newRaftNode(cfg raftNodeConfig) *raftNode {
+ r := &raftNode{
+ raftNodeConfig: cfg,
+ // set up contention detectors for raft heartbeat message.
+ // expect to send a heartbeat within 2 heartbeat intervals.
+ td: contention.NewTimeoutDetector(2 * cfg.heartbeat),
+ readStateC: make(chan raft.ReadState, 1),
+ msgSnapC: make(chan raftpb.Message, maxInFlightMsgSnap),
+ applyc: make(chan apply),
+ stopped: make(chan struct{}),
+ done: make(chan struct{}),
+ }
+ if r.heartbeat == 0 {
+ r.ticker = &time.Ticker{}
+ } else {
+ r.ticker = time.NewTicker(r.heartbeat)
+ }
+ return r
+}
+
+// start prepares and starts raftNode in a new goroutine. It is no longer safe
+// to modify the fields after it has been started.
+func (r *raftNode) start(rh *raftReadyHandler) {
+ internalTimeout := time.Second
+
+ go func() {
+ defer r.onStop()
+ islead := false
+
+ for {
+ select {
+ case <-r.ticker.C:
+ r.Tick()
+ case rd := <-r.Ready():
+ if rd.SoftState != nil {
+ newLeader := rd.SoftState.Lead != raft.None && atomic.LoadUint64(&r.lead) != rd.SoftState.Lead
+ if newLeader {
+ leaderChanges.Inc()
+ }
+
+ if rd.SoftState.Lead == raft.None {
+ hasLeader.Set(0)
+ } else {
+ hasLeader.Set(1)
+ }
+
+ atomic.StoreUint64(&r.lead, rd.SoftState.Lead)
+ islead = rd.RaftState == raft.StateLeader
+ rh.updateLeadership(newLeader)
+ r.td.Reset()
+ }
+
+ if len(rd.ReadStates) != 0 {
+ select {
+ case r.readStateC <- rd.ReadStates[len(rd.ReadStates)-1]:
+ case <-time.After(internalTimeout):
+ plog.Warningf("timed out sending read state")
+ case <-r.stopped:
+ return
+ }
+ }
+
+ notifyc := make(chan struct{}, 1)
+ ap := apply{
+ entries: rd.CommittedEntries,
+ snapshot: rd.Snapshot,
+ notifyc: notifyc,
+ }
+
+ updateCommittedIndex(&ap, rh)
+
+ select {
+ case r.applyc <- ap:
+ case <-r.stopped:
+ return
+ }
+
+ // the leader can write to its disk in parallel with replicating to the followers and them
+ // writing to their disks.
+ // For more details, check raft thesis 10.2.1
+ if islead {
+ // gofail: var raftBeforeLeaderSend struct{}
+ r.transport.Send(r.processMessages(rd.Messages))
+ }
+
+ // gofail: var raftBeforeSave struct{}
+ if err := r.storage.Save(rd.HardState, rd.Entries); err != nil {
+ plog.Fatalf("raft save state and entries error: %v", err)
+ }
+ if !raft.IsEmptyHardState(rd.HardState) {
+ proposalsCommitted.Set(float64(rd.HardState.Commit))
+ }
+ // gofail: var raftAfterSave struct{}
+
+ if !raft.IsEmptySnap(rd.Snapshot) {
+ // gofail: var raftBeforeSaveSnap struct{}
+ if err := r.storage.SaveSnap(rd.Snapshot); err != nil {
+ plog.Fatalf("raft save snapshot error: %v", err)
+ }
+ // etcdserver now claim the snapshot has been persisted onto the disk
+ notifyc <- struct{}{}
+
+ // gofail: var raftAfterSaveSnap struct{}
+ r.raftStorage.ApplySnapshot(rd.Snapshot)
+ plog.Infof("raft applied incoming snapshot at index %d", rd.Snapshot.Metadata.Index)
+ // gofail: var raftAfterApplySnap struct{}
+ }
+
+ r.raftStorage.Append(rd.Entries)
+
+ if !islead {
+ // finish processing incoming messages before we signal raftdone chan
+ msgs := r.processMessages(rd.Messages)
+
+ // now unblocks 'applyAll' that waits on Raft log disk writes before triggering snapshots
+ notifyc <- struct{}{}
+
+ // Candidate or follower needs to wait for all pending configuration
+ // changes to be applied before sending messages.
+ // Otherwise we might incorrectly count votes (e.g. votes from removed members).
+ // Also slow machine's follower raft-layer could proceed to become the leader
+ // on its own single-node cluster, before apply-layer applies the config change.
+ // We simply wait for ALL pending entries to be applied for now.
+ // We might improve this later on if it causes unnecessary long blocking issues.
+ waitApply := false
+ for _, ent := range rd.CommittedEntries {
+ if ent.Type == raftpb.EntryConfChange {
+ waitApply = true
+ break
+ }
+ }
+ if waitApply {
+ // blocks until 'applyAll' calls 'applyWait.Trigger'
+ // to be in sync with scheduled config-change job
+ // (assume notifyc has cap of 1)
+ select {
+ case notifyc <- struct{}{}:
+ case <-r.stopped:
+ return
+ }
+ }
+
+ // gofail: var raftBeforeFollowerSend struct{}
+ r.transport.Send(msgs)
+ } else {
+ // leader already processed 'MsgSnap' and signaled
+ notifyc <- struct{}{}
+ }
+
+ r.Advance()
+ case <-r.stopped:
+ return
+ }
+ }
+ }()
+}
+
+func updateCommittedIndex(ap *apply, rh *raftReadyHandler) {
+ var ci uint64
+ if len(ap.entries) != 0 {
+ ci = ap.entries[len(ap.entries)-1].Index
+ }
+ if ap.snapshot.Metadata.Index > ci {
+ ci = ap.snapshot.Metadata.Index
+ }
+ if ci != 0 {
+ rh.updateCommittedIndex(ci)
+ }
+}
+
+func (r *raftNode) processMessages(ms []raftpb.Message) []raftpb.Message {
+ sentAppResp := false
+ for i := len(ms) - 1; i >= 0; i-- {
+ if r.isIDRemoved(ms[i].To) {
+ ms[i].To = 0
+ }
+
+ if ms[i].Type == raftpb.MsgAppResp {
+ if sentAppResp {
+ ms[i].To = 0
+ } else {
+ sentAppResp = true
+ }
+ }
+
+ if ms[i].Type == raftpb.MsgSnap {
+ // There are two separate data store: the store for v2, and the KV for v3.
+ // The msgSnap only contains the most recent snapshot of store without KV.
+ // So we need to redirect the msgSnap to etcd server main loop for merging in the
+ // current store snapshot and KV snapshot.
+ select {
+ case r.msgSnapC <- ms[i]:
+ default:
+ // drop msgSnap if the inflight chan if full.
+ }
+ ms[i].To = 0
+ }
+ if ms[i].Type == raftpb.MsgHeartbeat {
+ ok, exceed := r.td.Observe(ms[i].To)
+ if !ok {
+ // TODO: limit request rate.
+ plog.Warningf("failed to send out heartbeat on time (exceeded the %v timeout for %v)", r.heartbeat, exceed)
+ plog.Warningf("server is likely overloaded")
+ }
+ }
+ }
+ return ms
+}
+
+func (r *raftNode) apply() chan apply {
+ return r.applyc
+}
+
+func (r *raftNode) stop() {
+ r.stopped <- struct{}{}
+ <-r.done
+}
+
+func (r *raftNode) onStop() {
+ r.Stop()
+ r.ticker.Stop()
+ r.transport.Stop()
+ if err := r.storage.Close(); err != nil {
+ plog.Panicf("raft close storage error: %v", err)
+ }
+ close(r.done)
+}
+
+// for testing
+func (r *raftNode) pauseSending() {
+ p := r.transport.(rafthttp.Pausable)
+ p.Pause()
+}
+
+func (r *raftNode) resumeSending() {
+ p := r.transport.(rafthttp.Pausable)
+ p.Resume()
+}
+
+// advanceTicksForElection advances ticks to the node for fast election.
+// This reduces the time to wait for first leader election if bootstrapping the whole
+// cluster, while leaving at least 1 heartbeat for possible existing leader
+// to contact it.
+func advanceTicksForElection(n raft.Node, electionTicks int) {
+ for i := 0; i < electionTicks-1; i++ {
+ n.Tick()
+ }
+}
+
+func startNode(cfg *ServerConfig, cl *membership.RaftCluster, ids []types.ID) (id types.ID, n raft.Node, s *raft.MemoryStorage, w *wal.WAL) {
+ var err error
+ member := cl.MemberByName(cfg.Name)
+ metadata := pbutil.MustMarshal(
+ &pb.Metadata{
+ NodeID: uint64(member.ID),
+ ClusterID: uint64(cl.ID()),
+ },
+ )
+ if w, err = wal.Create(cfg.WALDir(), metadata); err != nil {
+ plog.Fatalf("create wal error: %v", err)
+ }
+ peers := make([]raft.Peer, len(ids))
+ for i, id := range ids {
+ ctx, err := json.Marshal((*cl).Member(id))
+ if err != nil {
+ plog.Panicf("marshal member should never fail: %v", err)
+ }
+ peers[i] = raft.Peer{ID: uint64(id), Context: ctx}
+ }
+ id = member.ID
+ plog.Infof("starting member %s in cluster %s", id, cl.ID())
+ s = raft.NewMemoryStorage()
+ c := &raft.Config{
+ ID: uint64(id),
+ ElectionTick: cfg.ElectionTicks,
+ HeartbeatTick: 1,
+ Storage: s,
+ MaxSizePerMsg: maxSizePerMsg,
+ MaxInflightMsgs: maxInflightMsgs,
+ CheckQuorum: true,
+ }
+
+ n = raft.StartNode(c, peers)
+ raftStatusMu.Lock()
+ raftStatus = n.Status
+ raftStatusMu.Unlock()
+ advanceTicksForElection(n, c.ElectionTick)
+ return
+}
+
+func restartNode(cfg *ServerConfig, snapshot *raftpb.Snapshot) (types.ID, *membership.RaftCluster, raft.Node, *raft.MemoryStorage, *wal.WAL) {
+ var walsnap walpb.Snapshot
+ if snapshot != nil {
+ walsnap.Index, walsnap.Term = snapshot.Metadata.Index, snapshot.Metadata.Term
+ }
+ w, id, cid, st, ents := readWAL(cfg.WALDir(), walsnap)
+
+ plog.Infof("restarting member %s in cluster %s at commit index %d", id, cid, st.Commit)
+ cl := membership.NewCluster("")
+ cl.SetID(cid)
+ s := raft.NewMemoryStorage()
+ if snapshot != nil {
+ s.ApplySnapshot(*snapshot)
+ }
+ s.SetHardState(st)
+ s.Append(ents)
+ c := &raft.Config{
+ ID: uint64(id),
+ ElectionTick: cfg.ElectionTicks,
+ HeartbeatTick: 1,
+ Storage: s,
+ MaxSizePerMsg: maxSizePerMsg,
+ MaxInflightMsgs: maxInflightMsgs,
+ CheckQuorum: true,
+ }
+
+ n := raft.RestartNode(c)
+ raftStatusMu.Lock()
+ raftStatus = n.Status
+ raftStatusMu.Unlock()
+ advanceTicksForElection(n, c.ElectionTick)
+ return id, cl, n, s, w
+}
+
+func restartAsStandaloneNode(cfg *ServerConfig, snapshot *raftpb.Snapshot) (types.ID, *membership.RaftCluster, raft.Node, *raft.MemoryStorage, *wal.WAL) {
+ var walsnap walpb.Snapshot
+ if snapshot != nil {
+ walsnap.Index, walsnap.Term = snapshot.Metadata.Index, snapshot.Metadata.Term
+ }
+ w, id, cid, st, ents := readWAL(cfg.WALDir(), walsnap)
+
+ // discard the previously uncommitted entries
+ for i, ent := range ents {
+ if ent.Index > st.Commit {
+ plog.Infof("discarding %d uncommitted WAL entries ", len(ents)-i)
+ ents = ents[:i]
+ break
+ }
+ }
+
+ // force append the configuration change entries
+ toAppEnts := createConfigChangeEnts(getIDs(snapshot, ents), uint64(id), st.Term, st.Commit)
+ ents = append(ents, toAppEnts...)
+
+ // force commit newly appended entries
+ err := w.Save(raftpb.HardState{}, toAppEnts)
+ if err != nil {
+ plog.Fatalf("%v", err)
+ }
+ if len(ents) != 0 {
+ st.Commit = ents[len(ents)-1].Index
+ }
+
+ plog.Printf("forcing restart of member %s in cluster %s at commit index %d", id, cid, st.Commit)
+ cl := membership.NewCluster("")
+ cl.SetID(cid)
+ s := raft.NewMemoryStorage()
+ if snapshot != nil {
+ s.ApplySnapshot(*snapshot)
+ }
+ s.SetHardState(st)
+ s.Append(ents)
+ c := &raft.Config{
+ ID: uint64(id),
+ ElectionTick: cfg.ElectionTicks,
+ HeartbeatTick: 1,
+ Storage: s,
+ MaxSizePerMsg: maxSizePerMsg,
+ MaxInflightMsgs: maxInflightMsgs,
+ }
+ n := raft.RestartNode(c)
+ raftStatus = n.Status
+ return id, cl, n, s, w
+}
+
+// getIDs returns an ordered set of IDs included in the given snapshot and
+// the entries. The given snapshot/entries can contain two kinds of
+// ID-related entry:
+// - ConfChangeAddNode, in which case the contained ID will be added into the set.
+// - ConfChangeRemoveNode, in which case the contained ID will be removed from the set.
+func getIDs(snap *raftpb.Snapshot, ents []raftpb.Entry) []uint64 {
+ ids := make(map[uint64]bool)
+ if snap != nil {
+ for _, id := range snap.Metadata.ConfState.Nodes {
+ ids[id] = true
+ }
+ }
+ for _, e := range ents {
+ if e.Type != raftpb.EntryConfChange {
+ continue
+ }
+ var cc raftpb.ConfChange
+ pbutil.MustUnmarshal(&cc, e.Data)
+ switch cc.Type {
+ case raftpb.ConfChangeAddNode:
+ ids[cc.NodeID] = true
+ case raftpb.ConfChangeRemoveNode:
+ delete(ids, cc.NodeID)
+ case raftpb.ConfChangeUpdateNode:
+ // do nothing
+ default:
+ plog.Panicf("ConfChange Type should be either ConfChangeAddNode or ConfChangeRemoveNode!")
+ }
+ }
+ sids := make(types.Uint64Slice, 0, len(ids))
+ for id := range ids {
+ sids = append(sids, id)
+ }
+ sort.Sort(sids)
+ return []uint64(sids)
+}
+
+// createConfigChangeEnts creates a series of Raft entries (i.e.
+// EntryConfChange) to remove the set of given IDs from the cluster. The ID
+// `self` is _not_ removed, even if present in the set.
+// If `self` is not inside the given ids, it creates a Raft entry to add a
+// default member with the given `self`.
+func createConfigChangeEnts(ids []uint64, self uint64, term, index uint64) []raftpb.Entry {
+ ents := make([]raftpb.Entry, 0)
+ next := index + 1
+ found := false
+ for _, id := range ids {
+ if id == self {
+ found = true
+ continue
+ }
+ cc := &raftpb.ConfChange{
+ Type: raftpb.ConfChangeRemoveNode,
+ NodeID: id,
+ }
+ e := raftpb.Entry{
+ Type: raftpb.EntryConfChange,
+ Data: pbutil.MustMarshal(cc),
+ Term: term,
+ Index: next,
+ }
+ ents = append(ents, e)
+ next++
+ }
+ if !found {
+ m := membership.Member{
+ ID: types.ID(self),
+ RaftAttributes: membership.RaftAttributes{PeerURLs: []string{"http://localhost:2380"}},
+ }
+ ctx, err := json.Marshal(m)
+ if err != nil {
+ plog.Panicf("marshal member should never fail: %v", err)
+ }
+ cc := &raftpb.ConfChange{
+ Type: raftpb.ConfChangeAddNode,
+ NodeID: self,
+ Context: ctx,
+ }
+ e := raftpb.Entry{
+ Type: raftpb.EntryConfChange,
+ Data: pbutil.MustMarshal(cc),
+ Term: term,
+ Index: next,
+ }
+ ents = append(ents, e)
+ }
+ return ents
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/raft_test.go b/vendor/github.com/coreos/etcd/etcdserver/raft_test.go
new file mode 100644
index 00000000..757826cc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/raft_test.go
@@ -0,0 +1,221 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "encoding/json"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/pkg/mock/mockstorage"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/rafthttp"
+)
+
+func TestGetIDs(t *testing.T) {
+ addcc := &raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 2}
+ addEntry := raftpb.Entry{Type: raftpb.EntryConfChange, Data: pbutil.MustMarshal(addcc)}
+ removecc := &raftpb.ConfChange{Type: raftpb.ConfChangeRemoveNode, NodeID: 2}
+ removeEntry := raftpb.Entry{Type: raftpb.EntryConfChange, Data: pbutil.MustMarshal(removecc)}
+ normalEntry := raftpb.Entry{Type: raftpb.EntryNormal}
+ updatecc := &raftpb.ConfChange{Type: raftpb.ConfChangeUpdateNode, NodeID: 2}
+ updateEntry := raftpb.Entry{Type: raftpb.EntryConfChange, Data: pbutil.MustMarshal(updatecc)}
+
+ tests := []struct {
+ confState *raftpb.ConfState
+ ents []raftpb.Entry
+
+ widSet []uint64
+ }{
+ {nil, []raftpb.Entry{}, []uint64{}},
+ {&raftpb.ConfState{Nodes: []uint64{1}},
+ []raftpb.Entry{}, []uint64{1}},
+ {&raftpb.ConfState{Nodes: []uint64{1}},
+ []raftpb.Entry{addEntry}, []uint64{1, 2}},
+ {&raftpb.ConfState{Nodes: []uint64{1}},
+ []raftpb.Entry{addEntry, removeEntry}, []uint64{1}},
+ {&raftpb.ConfState{Nodes: []uint64{1}},
+ []raftpb.Entry{addEntry, normalEntry}, []uint64{1, 2}},
+ {&raftpb.ConfState{Nodes: []uint64{1}},
+ []raftpb.Entry{addEntry, normalEntry, updateEntry}, []uint64{1, 2}},
+ {&raftpb.ConfState{Nodes: []uint64{1}},
+ []raftpb.Entry{addEntry, removeEntry, normalEntry}, []uint64{1}},
+ }
+
+ for i, tt := range tests {
+ var snap raftpb.Snapshot
+ if tt.confState != nil {
+ snap.Metadata.ConfState = *tt.confState
+ }
+ idSet := getIDs(&snap, tt.ents)
+ if !reflect.DeepEqual(idSet, tt.widSet) {
+ t.Errorf("#%d: idset = %#v, want %#v", i, idSet, tt.widSet)
+ }
+ }
+}
+
+func TestCreateConfigChangeEnts(t *testing.T) {
+ m := membership.Member{
+ ID: types.ID(1),
+ RaftAttributes: membership.RaftAttributes{PeerURLs: []string{"http://localhost:2380"}},
+ }
+ ctx, err := json.Marshal(m)
+ if err != nil {
+ t.Fatal(err)
+ }
+ addcc1 := &raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 1, Context: ctx}
+ removecc2 := &raftpb.ConfChange{Type: raftpb.ConfChangeRemoveNode, NodeID: 2}
+ removecc3 := &raftpb.ConfChange{Type: raftpb.ConfChangeRemoveNode, NodeID: 3}
+ tests := []struct {
+ ids []uint64
+ self uint64
+ term, index uint64
+
+ wents []raftpb.Entry
+ }{
+ {
+ []uint64{1},
+ 1,
+ 1, 1,
+
+ []raftpb.Entry{},
+ },
+ {
+ []uint64{1, 2},
+ 1,
+ 1, 1,
+
+ []raftpb.Entry{{Term: 1, Index: 2, Type: raftpb.EntryConfChange, Data: pbutil.MustMarshal(removecc2)}},
+ },
+ {
+ []uint64{1, 2},
+ 1,
+ 2, 2,
+
+ []raftpb.Entry{{Term: 2, Index: 3, Type: raftpb.EntryConfChange, Data: pbutil.MustMarshal(removecc2)}},
+ },
+ {
+ []uint64{1, 2, 3},
+ 1,
+ 2, 2,
+
+ []raftpb.Entry{
+ {Term: 2, Index: 3, Type: raftpb.EntryConfChange, Data: pbutil.MustMarshal(removecc2)},
+ {Term: 2, Index: 4, Type: raftpb.EntryConfChange, Data: pbutil.MustMarshal(removecc3)},
+ },
+ },
+ {
+ []uint64{2, 3},
+ 2,
+ 2, 2,
+
+ []raftpb.Entry{
+ {Term: 2, Index: 3, Type: raftpb.EntryConfChange, Data: pbutil.MustMarshal(removecc3)},
+ },
+ },
+ {
+ []uint64{2, 3},
+ 1,
+ 2, 2,
+
+ []raftpb.Entry{
+ {Term: 2, Index: 3, Type: raftpb.EntryConfChange, Data: pbutil.MustMarshal(removecc2)},
+ {Term: 2, Index: 4, Type: raftpb.EntryConfChange, Data: pbutil.MustMarshal(removecc3)},
+ {Term: 2, Index: 5, Type: raftpb.EntryConfChange, Data: pbutil.MustMarshal(addcc1)},
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ gents := createConfigChangeEnts(tt.ids, tt.self, tt.term, tt.index)
+ if !reflect.DeepEqual(gents, tt.wents) {
+ t.Errorf("#%d: ents = %v, want %v", i, gents, tt.wents)
+ }
+ }
+}
+
+func TestStopRaftWhenWaitingForApplyDone(t *testing.T) {
+ n := newNopReadyNode()
+ r := newRaftNode(raftNodeConfig{
+ Node: n,
+ storage: mockstorage.NewStorageRecorder(""),
+ raftStorage: raft.NewMemoryStorage(),
+ transport: rafthttp.NewNopTransporter(),
+ })
+ srv := &EtcdServer{r: *r}
+ srv.r.start(nil)
+ n.readyc <- raft.Ready{}
+ select {
+ case <-srv.r.applyc:
+ case <-time.After(time.Second):
+ t.Fatalf("failed to receive apply struct")
+ }
+
+ srv.r.stopped <- struct{}{}
+ select {
+ case <-srv.r.done:
+ case <-time.After(time.Second):
+ t.Fatalf("failed to stop raft loop")
+ }
+}
+
+// TestConfgChangeBlocksApply ensures apply blocks if committed entries contain config-change.
+func TestConfgChangeBlocksApply(t *testing.T) {
+ n := newNopReadyNode()
+
+ r := newRaftNode(raftNodeConfig{
+ Node: n,
+ storage: mockstorage.NewStorageRecorder(""),
+ raftStorage: raft.NewMemoryStorage(),
+ transport: rafthttp.NewNopTransporter(),
+ })
+ srv := &EtcdServer{r: *r}
+
+ srv.r.start(&raftReadyHandler{updateLeadership: func(bool) {}})
+ defer srv.r.Stop()
+
+ n.readyc <- raft.Ready{
+ SoftState: &raft.SoftState{RaftState: raft.StateFollower},
+ CommittedEntries: []raftpb.Entry{{Type: raftpb.EntryConfChange}},
+ }
+ ap := <-srv.r.applyc
+
+ continueC := make(chan struct{})
+ go func() {
+ n.readyc <- raft.Ready{}
+ <-srv.r.applyc
+ close(continueC)
+ }()
+
+ select {
+ case <-continueC:
+ t.Fatalf("unexpected execution: raft routine should block waiting for apply")
+ case <-time.After(time.Second):
+ }
+
+ // finish apply, unblock raft routine
+ <-ap.notifyc
+
+ select {
+ case <-continueC:
+ case <-time.After(time.Second):
+ t.Fatalf("unexpected blocking on execution")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/server.go b/vendor/github.com/coreos/etcd/etcdserver/server.go
new file mode 100644
index 00000000..f0de2e25
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/server.go
@@ -0,0 +1,1660 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "encoding/json"
+ "expvar"
+ "fmt"
+ "math"
+ "math/rand"
+ "net/http"
+ "os"
+ "path"
+ "regexp"
+ "sync"
+ "sync/atomic"
+ "time"
+
+ "github.com/coreos/etcd/alarm"
+ "github.com/coreos/etcd/auth"
+ "github.com/coreos/etcd/compactor"
+ "github.com/coreos/etcd/discovery"
+ "github.com/coreos/etcd/etcdserver/api"
+ "github.com/coreos/etcd/etcdserver/api/v2http/httptypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/etcdserver/stats"
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/pkg/fileutil"
+ "github.com/coreos/etcd/pkg/idutil"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/pkg/runtime"
+ "github.com/coreos/etcd/pkg/schedule"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/pkg/wait"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/rafthttp"
+ "github.com/coreos/etcd/snap"
+ "github.com/coreos/etcd/store"
+ "github.com/coreos/etcd/version"
+ "github.com/coreos/etcd/wal"
+ "github.com/coreos/go-semver/semver"
+ "github.com/coreos/pkg/capnslog"
+ "golang.org/x/net/context"
+)
+
+const (
+ DefaultSnapCount = 100000
+
+ StoreClusterPrefix = "/0"
+ StoreKeysPrefix = "/1"
+
+ // HealthInterval is the minimum time the cluster should be healthy
+ // before accepting add member requests.
+ HealthInterval = 5 * time.Second
+
+ purgeFileInterval = 30 * time.Second
+ // monitorVersionInterval should be smaller than the timeout
+ // on the connection. Or we will not be able to reuse the connection
+ // (since it will timeout).
+ monitorVersionInterval = rafthttp.ConnWriteTimeout - time.Second
+
+ // max number of in-flight snapshot messages etcdserver allows to have
+ // This number is more than enough for most clusters with 5 machines.
+ maxInFlightMsgSnap = 16
+
+ releaseDelayAfterSnapshot = 30 * time.Second
+
+ // maxPendingRevokes is the maximum number of outstanding expired lease revocations.
+ maxPendingRevokes = 16
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "etcdserver")
+
+ storeMemberAttributeRegexp = regexp.MustCompile(path.Join(membership.StoreMembersPrefix, "[[:xdigit:]]{1,16}", "attributes"))
+)
+
+func init() {
+ rand.Seed(time.Now().UnixNano())
+
+ expvar.Publish(
+ "file_descriptor_limit",
+ expvar.Func(
+ func() interface{} {
+ n, _ := runtime.FDLimit()
+ return n
+ },
+ ),
+ )
+}
+
+type Response struct {
+ Event *store.Event
+ Watcher store.Watcher
+ err error
+}
+
+type Server interface {
+ // Start performs any initialization of the Server necessary for it to
+ // begin serving requests. It must be called before Do or Process.
+ // Start must be non-blocking; any long-running server functionality
+ // should be implemented in goroutines.
+ Start()
+ // Stop terminates the Server and performs any necessary finalization.
+ // Do and Process cannot be called after Stop has been invoked.
+ Stop()
+ // ID returns the ID of the Server.
+ ID() types.ID
+ // Leader returns the ID of the leader Server.
+ Leader() types.ID
+ // Do takes a request and attempts to fulfill it, returning a Response.
+ Do(ctx context.Context, r pb.Request) (Response, error)
+ // Process takes a raft message and applies it to the server's raft state
+ // machine, respecting any timeout of the given context.
+ Process(ctx context.Context, m raftpb.Message) error
+ // AddMember attempts to add a member into the cluster. It will return
+ // ErrIDRemoved if member ID is removed from the cluster, or return
+ // ErrIDExists if member ID exists in the cluster.
+ AddMember(ctx context.Context, memb membership.Member) ([]*membership.Member, error)
+ // RemoveMember attempts to remove a member from the cluster. It will
+ // return ErrIDRemoved if member ID is removed from the cluster, or return
+ // ErrIDNotFound if member ID is not in the cluster.
+ RemoveMember(ctx context.Context, id uint64) ([]*membership.Member, error)
+
+ // UpdateMember attempts to update an existing member in the cluster. It will
+ // return ErrIDNotFound if the member ID does not exist.
+ UpdateMember(ctx context.Context, updateMemb membership.Member) ([]*membership.Member, error)
+
+ // ClusterVersion is the cluster-wide minimum major.minor version.
+ // Cluster version is set to the min version that an etcd member is
+ // compatible with when first bootstrap.
+ //
+ // ClusterVersion is nil until the cluster is bootstrapped (has a quorum).
+ //
+ // During a rolling upgrades, the ClusterVersion will be updated
+ // automatically after a sync. (5 second by default)
+ //
+ // The API/raft component can utilize ClusterVersion to determine if
+ // it can accept a client request or a raft RPC.
+ // NOTE: ClusterVersion might be nil when etcd 2.1 works with etcd 2.0 and
+ // the leader is etcd 2.0. etcd 2.0 leader will not update clusterVersion since
+ // this feature is introduced post 2.0.
+ ClusterVersion() *semver.Version
+}
+
+// EtcdServer is the production implementation of the Server interface
+type EtcdServer struct {
+ // inflightSnapshots holds count the number of snapshots currently inflight.
+ inflightSnapshots int64 // must use atomic operations to access; keep 64-bit aligned.
+ appliedIndex uint64 // must use atomic operations to access; keep 64-bit aligned.
+ committedIndex uint64 // must use atomic operations to access; keep 64-bit aligned.
+ // consistIndex used to hold the offset of current executing entry
+ // It is initialized to 0 before executing any entry.
+ consistIndex consistentIndex // must use atomic operations to access; keep 64-bit aligned.
+ Cfg *ServerConfig
+
+ readych chan struct{}
+ r raftNode
+
+ snapCount uint64
+
+ w wait.Wait
+
+ readMu sync.RWMutex
+ // read routine notifies etcd server that it waits for reading by sending an empty struct to
+ // readwaitC
+ readwaitc chan struct{}
+ // readNotifier is used to notify the read routine that it can process the request
+ // when there is no error
+ readNotifier *notifier
+
+ // stop signals the run goroutine should shutdown.
+ stop chan struct{}
+ // stopping is closed by run goroutine on shutdown.
+ stopping chan struct{}
+ // done is closed when all goroutines from start() complete.
+ done chan struct{}
+
+ errorc chan error
+ id types.ID
+ attributes membership.Attributes
+
+ cluster *membership.RaftCluster
+
+ store store.Store
+ snapshotter *snap.Snapshotter
+
+ applyV2 ApplierV2
+
+ // applyV3 is the applier with auth and quotas
+ applyV3 applierV3
+ // applyV3Base is the core applier without auth or quotas
+ applyV3Base applierV3
+ applyWait wait.WaitTime
+
+ kv mvcc.ConsistentWatchableKV
+ lessor lease.Lessor
+ bemu sync.Mutex
+ be backend.Backend
+ authStore auth.AuthStore
+ alarmStore *alarm.AlarmStore
+
+ stats *stats.ServerStats
+ lstats *stats.LeaderStats
+
+ SyncTicker *time.Ticker
+ // compactor is used to auto-compact the KV.
+ compactor *compactor.Periodic
+
+ // peerRt used to send requests (version, lease) to peers.
+ peerRt http.RoundTripper
+ reqIDGen *idutil.Generator
+
+ // forceVersionC is used to force the version monitor loop
+ // to detect the cluster version immediately.
+ forceVersionC chan struct{}
+
+ // wgMu blocks concurrent waitgroup mutation while server stopping
+ wgMu sync.RWMutex
+ // wg is used to wait for the go routines that depends on the server state
+ // to exit when stopping the server.
+ wg sync.WaitGroup
+
+ // ctx is used for etcd-initiated requests that may need to be canceled
+ // on etcd server shutdown.
+ ctx context.Context
+ cancel context.CancelFunc
+
+ leadTimeMu sync.RWMutex
+ leadElectedTime time.Time
+}
+
+// NewServer creates a new EtcdServer from the supplied configuration. The
+// configuration is considered static for the lifetime of the EtcdServer.
+func NewServer(cfg *ServerConfig) (srv *EtcdServer, err error) {
+ st := store.New(StoreClusterPrefix, StoreKeysPrefix)
+
+ var (
+ w *wal.WAL
+ n raft.Node
+ s *raft.MemoryStorage
+ id types.ID
+ cl *membership.RaftCluster
+ )
+
+ if terr := fileutil.TouchDirAll(cfg.DataDir); terr != nil {
+ return nil, fmt.Errorf("cannot access data directory: %v", terr)
+ }
+
+ haveWAL := wal.Exist(cfg.WALDir())
+
+ if err = fileutil.TouchDirAll(cfg.SnapDir()); err != nil {
+ plog.Fatalf("create snapshot directory error: %v", err)
+ }
+ ss := snap.New(cfg.SnapDir())
+
+ bepath := cfg.backendPath()
+ beExist := fileutil.Exist(bepath)
+ be := openBackend(cfg)
+
+ defer func() {
+ if err != nil {
+ be.Close()
+ }
+ }()
+
+ prt, err := rafthttp.NewRoundTripper(cfg.PeerTLSInfo, cfg.peerDialTimeout())
+ if err != nil {
+ return nil, err
+ }
+ var (
+ remotes []*membership.Member
+ snapshot *raftpb.Snapshot
+ )
+
+ switch {
+ case !haveWAL && !cfg.NewCluster:
+ if err = cfg.VerifyJoinExisting(); err != nil {
+ return nil, err
+ }
+ cl, err = membership.NewClusterFromURLsMap(cfg.InitialClusterToken, cfg.InitialPeerURLsMap)
+ if err != nil {
+ return nil, err
+ }
+ existingCluster, gerr := GetClusterFromRemotePeers(getRemotePeerURLs(cl, cfg.Name), prt)
+ if gerr != nil {
+ return nil, fmt.Errorf("cannot fetch cluster info from peer urls: %v", gerr)
+ }
+ if err = membership.ValidateClusterAndAssignIDs(cl, existingCluster); err != nil {
+ return nil, fmt.Errorf("error validating peerURLs %s: %v", existingCluster, err)
+ }
+ if !isCompatibleWithCluster(cl, cl.MemberByName(cfg.Name).ID, prt) {
+ return nil, fmt.Errorf("incompatible with current running cluster")
+ }
+
+ remotes = existingCluster.Members()
+ cl.SetID(existingCluster.ID())
+ cl.SetStore(st)
+ cl.SetBackend(be)
+ cfg.Print()
+ id, n, s, w = startNode(cfg, cl, nil)
+ case !haveWAL && cfg.NewCluster:
+ if err = cfg.VerifyBootstrap(); err != nil {
+ return nil, err
+ }
+ cl, err = membership.NewClusterFromURLsMap(cfg.InitialClusterToken, cfg.InitialPeerURLsMap)
+ if err != nil {
+ return nil, err
+ }
+ m := cl.MemberByName(cfg.Name)
+ if isMemberBootstrapped(cl, cfg.Name, prt, cfg.bootstrapTimeout()) {
+ return nil, fmt.Errorf("member %s has already been bootstrapped", m.ID)
+ }
+ if cfg.ShouldDiscover() {
+ var str string
+ str, err = discovery.JoinCluster(cfg.DiscoveryURL, cfg.DiscoveryProxy, m.ID, cfg.InitialPeerURLsMap.String())
+ if err != nil {
+ return nil, &DiscoveryError{Op: "join", Err: err}
+ }
+ var urlsmap types.URLsMap
+ urlsmap, err = types.NewURLsMap(str)
+ if err != nil {
+ return nil, err
+ }
+ if checkDuplicateURL(urlsmap) {
+ return nil, fmt.Errorf("discovery cluster %s has duplicate url", urlsmap)
+ }
+ if cl, err = membership.NewClusterFromURLsMap(cfg.InitialClusterToken, urlsmap); err != nil {
+ return nil, err
+ }
+ }
+ cl.SetStore(st)
+ cl.SetBackend(be)
+ cfg.PrintWithInitial()
+ id, n, s, w = startNode(cfg, cl, cl.MemberIDs())
+ case haveWAL:
+ if err = fileutil.IsDirWriteable(cfg.MemberDir()); err != nil {
+ return nil, fmt.Errorf("cannot write to member directory: %v", err)
+ }
+
+ if err = fileutil.IsDirWriteable(cfg.WALDir()); err != nil {
+ return nil, fmt.Errorf("cannot write to WAL directory: %v", err)
+ }
+
+ if cfg.ShouldDiscover() {
+ plog.Warningf("discovery token ignored since a cluster has already been initialized. Valid log found at %q", cfg.WALDir())
+ }
+ snapshot, err = ss.Load()
+ if err != nil && err != snap.ErrNoSnapshot {
+ return nil, err
+ }
+ if snapshot != nil {
+ if err = st.Recovery(snapshot.Data); err != nil {
+ plog.Panicf("recovered store from snapshot error: %v", err)
+ }
+ plog.Infof("recovered store from snapshot at index %d", snapshot.Metadata.Index)
+ if be, err = recoverSnapshotBackend(cfg, be, *snapshot); err != nil {
+ plog.Panicf("recovering backend from snapshot error: %v", err)
+ }
+ }
+ cfg.Print()
+ if !cfg.ForceNewCluster {
+ id, cl, n, s, w = restartNode(cfg, snapshot)
+ } else {
+ id, cl, n, s, w = restartAsStandaloneNode(cfg, snapshot)
+ }
+ cl.SetStore(st)
+ cl.SetBackend(be)
+ cl.Recover(api.UpdateCapability)
+ if cl.Version() != nil && !cl.Version().LessThan(semver.Version{Major: 3}) && !beExist {
+ os.RemoveAll(bepath)
+ return nil, fmt.Errorf("database file (%v) of the backend is missing", bepath)
+ }
+ default:
+ return nil, fmt.Errorf("unsupported bootstrap config")
+ }
+
+ if terr := fileutil.TouchDirAll(cfg.MemberDir()); terr != nil {
+ return nil, fmt.Errorf("cannot access member directory: %v", terr)
+ }
+
+ sstats := stats.NewServerStats(cfg.Name, id.String())
+ lstats := stats.NewLeaderStats(id.String())
+
+ heartbeat := time.Duration(cfg.TickMs) * time.Millisecond
+ srv = &EtcdServer{
+ readych: make(chan struct{}),
+ Cfg: cfg,
+ snapCount: cfg.SnapCount,
+ errorc: make(chan error, 1),
+ store: st,
+ snapshotter: ss,
+ r: *newRaftNode(
+ raftNodeConfig{
+ isIDRemoved: func(id uint64) bool { return cl.IsIDRemoved(types.ID(id)) },
+ Node: n,
+ heartbeat: heartbeat,
+ raftStorage: s,
+ storage: NewStorage(w, ss),
+ },
+ ),
+ id: id,
+ attributes: membership.Attributes{Name: cfg.Name, ClientURLs: cfg.ClientURLs.StringSlice()},
+ cluster: cl,
+ stats: sstats,
+ lstats: lstats,
+ SyncTicker: time.NewTicker(500 * time.Millisecond),
+ peerRt: prt,
+ reqIDGen: idutil.NewGenerator(uint16(id), time.Now()),
+ forceVersionC: make(chan struct{}),
+ }
+
+ srv.applyV2 = &applierV2store{store: srv.store, cluster: srv.cluster}
+
+ srv.be = be
+ minTTL := time.Duration((3*cfg.ElectionTicks)/2) * heartbeat
+
+ // always recover lessor before kv. When we recover the mvcc.KV it will reattach keys to its leases.
+ // If we recover mvcc.KV first, it will attach the keys to the wrong lessor before it recovers.
+ srv.lessor = lease.NewLessor(srv.be, int64(math.Ceil(minTTL.Seconds())))
+ srv.kv = mvcc.New(srv.be, srv.lessor, &srv.consistIndex)
+ if beExist {
+ kvindex := srv.kv.ConsistentIndex()
+ // TODO: remove kvindex != 0 checking when we do not expect users to upgrade
+ // etcd from pre-3.0 release.
+ if snapshot != nil && kvindex < snapshot.Metadata.Index {
+ if kvindex != 0 {
+ return nil, fmt.Errorf("database file (%v index %d) does not match with snapshot (index %d).", bepath, kvindex, snapshot.Metadata.Index)
+ }
+ plog.Warningf("consistent index never saved (snapshot index=%d)", snapshot.Metadata.Index)
+ }
+ }
+ newSrv := srv // since srv == nil in defer if srv is returned as nil
+ defer func() {
+ // closing backend without first closing kv can cause
+ // resumed compactions to fail with closed tx errors
+ if err != nil {
+ newSrv.kv.Close()
+ }
+ }()
+
+ srv.consistIndex.setConsistentIndex(srv.kv.ConsistentIndex())
+ tp, err := auth.NewTokenProvider(cfg.AuthToken,
+ func(index uint64) <-chan struct{} {
+ return srv.applyWait.Wait(index)
+ },
+ )
+ if err != nil {
+ plog.Errorf("failed to create token provider: %s", err)
+ return nil, err
+ }
+ srv.authStore = auth.NewAuthStore(srv.be, tp)
+ if h := cfg.AutoCompactionRetention; h != 0 {
+ srv.compactor = compactor.NewPeriodic(h, srv.kv, srv)
+ srv.compactor.Run()
+ }
+
+ srv.applyV3Base = &applierV3backend{srv}
+ if err = srv.restoreAlarms(); err != nil {
+ return nil, err
+ }
+
+ // TODO: move transport initialization near the definition of remote
+ tr := &rafthttp.Transport{
+ TLSInfo: cfg.PeerTLSInfo,
+ DialTimeout: cfg.peerDialTimeout(),
+ ID: id,
+ URLs: cfg.PeerURLs,
+ ClusterID: cl.ID(),
+ Raft: srv,
+ Snapshotter: ss,
+ ServerStats: sstats,
+ LeaderStats: lstats,
+ ErrorC: srv.errorc,
+ }
+ if err = tr.Start(); err != nil {
+ return nil, err
+ }
+ // add all remotes into transport
+ for _, m := range remotes {
+ if m.ID != id {
+ tr.AddRemote(m.ID, m.PeerURLs)
+ }
+ }
+ for _, m := range cl.Members() {
+ if m.ID != id {
+ tr.AddPeer(m.ID, m.PeerURLs)
+ }
+ }
+ srv.r.transport = tr
+
+ return srv, nil
+}
+
+// Start prepares and starts server in a new goroutine. It is no longer safe to
+// modify a server's fields after it has been sent to Start.
+// It also starts a goroutine to publish its server information.
+func (s *EtcdServer) Start() {
+ s.start()
+ s.goAttach(func() { s.publish(s.Cfg.ReqTimeout()) })
+ s.goAttach(s.purgeFile)
+ s.goAttach(func() { monitorFileDescriptor(s.stopping) })
+ s.goAttach(s.monitorVersions)
+ s.goAttach(s.linearizableReadLoop)
+}
+
+// start prepares and starts server in a new goroutine. It is no longer safe to
+// modify a server's fields after it has been sent to Start.
+// This function is just used for testing.
+func (s *EtcdServer) start() {
+ if s.snapCount == 0 {
+ plog.Infof("set snapshot count to default %d", DefaultSnapCount)
+ s.snapCount = DefaultSnapCount
+ }
+ s.w = wait.New()
+ s.applyWait = wait.NewTimeList()
+ s.done = make(chan struct{})
+ s.stop = make(chan struct{})
+ s.stopping = make(chan struct{})
+ s.ctx, s.cancel = context.WithCancel(context.Background())
+ s.readwaitc = make(chan struct{}, 1)
+ s.readNotifier = newNotifier()
+ if s.ClusterVersion() != nil {
+ plog.Infof("starting server... [version: %v, cluster version: %v]", version.Version, version.Cluster(s.ClusterVersion().String()))
+ } else {
+ plog.Infof("starting server... [version: %v, cluster version: to_be_decided]", version.Version)
+ }
+ // TODO: if this is an empty log, writes all peer infos
+ // into the first entry
+ go s.run()
+}
+
+func (s *EtcdServer) purgeFile() {
+ var serrc, werrc <-chan error
+ if s.Cfg.MaxSnapFiles > 0 {
+ serrc = fileutil.PurgeFile(s.Cfg.SnapDir(), "snap", s.Cfg.MaxSnapFiles, purgeFileInterval, s.done)
+ }
+ if s.Cfg.MaxWALFiles > 0 {
+ werrc = fileutil.PurgeFile(s.Cfg.WALDir(), "wal", s.Cfg.MaxWALFiles, purgeFileInterval, s.done)
+ }
+ select {
+ case e := <-werrc:
+ plog.Fatalf("failed to purge wal file %v", e)
+ case e := <-serrc:
+ plog.Fatalf("failed to purge snap file %v", e)
+ case <-s.stopping:
+ return
+ }
+}
+
+func (s *EtcdServer) ID() types.ID { return s.id }
+
+func (s *EtcdServer) Cluster() *membership.RaftCluster { return s.cluster }
+
+func (s *EtcdServer) RaftHandler() http.Handler { return s.r.transport.Handler() }
+
+func (s *EtcdServer) Lessor() lease.Lessor { return s.lessor }
+
+func (s *EtcdServer) ApplyWait() <-chan struct{} { return s.applyWait.Wait(s.getCommittedIndex()) }
+
+func (s *EtcdServer) Process(ctx context.Context, m raftpb.Message) error {
+ if s.cluster.IsIDRemoved(types.ID(m.From)) {
+ plog.Warningf("reject message from removed member %s", types.ID(m.From).String())
+ return httptypes.NewHTTPError(http.StatusForbidden, "cannot process message from removed member")
+ }
+ if m.Type == raftpb.MsgApp {
+ s.stats.RecvAppendReq(types.ID(m.From).String(), m.Size())
+ }
+ return s.r.Step(ctx, m)
+}
+
+func (s *EtcdServer) IsIDRemoved(id uint64) bool { return s.cluster.IsIDRemoved(types.ID(id)) }
+
+func (s *EtcdServer) ReportUnreachable(id uint64) { s.r.ReportUnreachable(id) }
+
+// ReportSnapshot reports snapshot sent status to the raft state machine,
+// and clears the used snapshot from the snapshot store.
+func (s *EtcdServer) ReportSnapshot(id uint64, status raft.SnapshotStatus) {
+ s.r.ReportSnapshot(id, status)
+}
+
+type etcdProgress struct {
+ confState raftpb.ConfState
+ snapi uint64
+ appliedt uint64
+ appliedi uint64
+}
+
+// raftReadyHandler contains a set of EtcdServer operations to be called by raftNode,
+// and helps decouple state machine logic from Raft algorithms.
+// TODO: add a state machine interface to apply the commit entries and do snapshot/recover
+type raftReadyHandler struct {
+ updateLeadership func(newLeader bool)
+ updateCommittedIndex func(uint64)
+}
+
+func (s *EtcdServer) run() {
+ sn, err := s.r.raftStorage.Snapshot()
+ if err != nil {
+ plog.Panicf("get snapshot from raft storage error: %v", err)
+ }
+
+ // asynchronously accept apply packets, dispatch progress in-order
+ sched := schedule.NewFIFOScheduler()
+
+ var (
+ smu sync.RWMutex
+ syncC <-chan time.Time
+ )
+ setSyncC := func(ch <-chan time.Time) {
+ smu.Lock()
+ syncC = ch
+ smu.Unlock()
+ }
+ getSyncC := func() (ch <-chan time.Time) {
+ smu.RLock()
+ ch = syncC
+ smu.RUnlock()
+ return
+ }
+ rh := &raftReadyHandler{
+ updateLeadership: func(newLeader bool) {
+ if !s.isLeader() {
+ if s.lessor != nil {
+ s.lessor.Demote()
+ }
+ if s.compactor != nil {
+ s.compactor.Pause()
+ }
+ setSyncC(nil)
+ } else {
+ if newLeader {
+ t := time.Now()
+ s.leadTimeMu.Lock()
+ s.leadElectedTime = t
+ s.leadTimeMu.Unlock()
+ }
+ setSyncC(s.SyncTicker.C)
+ if s.compactor != nil {
+ s.compactor.Resume()
+ }
+ }
+
+ // TODO: remove the nil checking
+ // current test utility does not provide the stats
+ if s.stats != nil {
+ s.stats.BecomeLeader()
+ }
+ },
+ updateCommittedIndex: func(ci uint64) {
+ cci := s.getCommittedIndex()
+ if ci > cci {
+ s.setCommittedIndex(ci)
+ }
+ },
+ }
+ s.r.start(rh)
+
+ ep := etcdProgress{
+ confState: sn.Metadata.ConfState,
+ snapi: sn.Metadata.Index,
+ appliedt: sn.Metadata.Term,
+ appliedi: sn.Metadata.Index,
+ }
+
+ defer func() {
+ s.wgMu.Lock() // block concurrent waitgroup adds in goAttach while stopping
+ close(s.stopping)
+ s.wgMu.Unlock()
+ s.cancel()
+
+ sched.Stop()
+
+ // wait for gouroutines before closing raft so wal stays open
+ s.wg.Wait()
+
+ s.SyncTicker.Stop()
+
+ // must stop raft after scheduler-- etcdserver can leak rafthttp pipelines
+ // by adding a peer after raft stops the transport
+ s.r.stop()
+
+ // kv, lessor and backend can be nil if running without v3 enabled
+ // or running unit tests.
+ if s.lessor != nil {
+ s.lessor.Stop()
+ }
+ if s.kv != nil {
+ s.kv.Close()
+ }
+ if s.authStore != nil {
+ s.authStore.Close()
+ }
+ if s.be != nil {
+ s.be.Close()
+ }
+ if s.compactor != nil {
+ s.compactor.Stop()
+ }
+ close(s.done)
+ }()
+
+ var expiredLeaseC <-chan []*lease.Lease
+ if s.lessor != nil {
+ expiredLeaseC = s.lessor.ExpiredLeasesC()
+ }
+
+ for {
+ select {
+ case ap := <-s.r.apply():
+ f := func(context.Context) { s.applyAll(&ep, &ap) }
+ sched.Schedule(f)
+ case leases := <-expiredLeaseC:
+ s.goAttach(func() {
+ // Increases throughput of expired leases deletion process through parallelization
+ c := make(chan struct{}, maxPendingRevokes)
+ for _, lease := range leases {
+ select {
+ case c <- struct{}{}:
+ case <-s.stopping:
+ return
+ }
+ lid := lease.ID
+ s.goAttach(func() {
+ s.LeaseRevoke(s.ctx, &pb.LeaseRevokeRequest{ID: int64(lid)})
+ leaseExpired.Inc()
+ <-c
+ })
+ }
+ })
+ case err := <-s.errorc:
+ plog.Errorf("%s", err)
+ plog.Infof("the data-dir used by this member must be removed.")
+ return
+ case <-getSyncC():
+ if s.store.HasTTLKeys() {
+ s.sync(s.Cfg.ReqTimeout())
+ }
+ case <-s.stop:
+ return
+ }
+ }
+}
+
+func (s *EtcdServer) applyAll(ep *etcdProgress, apply *apply) {
+ s.applySnapshot(ep, apply)
+ st := time.Now()
+ s.applyEntries(ep, apply)
+ d := time.Since(st)
+ entriesNum := len(apply.entries)
+ if entriesNum != 0 && d > time.Duration(entriesNum)*warnApplyDuration {
+ plog.Warningf("apply entries took too long [%v for %d entries]", d, len(apply.entries))
+ plog.Warningf("avoid queries with large range/delete range!")
+ }
+ proposalsApplied.Set(float64(ep.appliedi))
+ s.applyWait.Trigger(ep.appliedi)
+ // wait for the raft routine to finish the disk writes before triggering a
+ // snapshot. or applied index might be greater than the last index in raft
+ // storage, since the raft routine might be slower than apply routine.
+ <-apply.notifyc
+
+ s.triggerSnapshot(ep)
+ select {
+ // snapshot requested via send()
+ case m := <-s.r.msgSnapC:
+ merged := s.createMergedSnapshotMessage(m, ep.appliedt, ep.appliedi, ep.confState)
+ s.sendMergedSnap(merged)
+ default:
+ }
+}
+
+func (s *EtcdServer) applySnapshot(ep *etcdProgress, apply *apply) {
+ if raft.IsEmptySnap(apply.snapshot) {
+ return
+ }
+
+ plog.Infof("applying snapshot at index %d...", ep.snapi)
+ defer plog.Infof("finished applying incoming snapshot at index %d", ep.snapi)
+
+ if apply.snapshot.Metadata.Index <= ep.appliedi {
+ plog.Panicf("snapshot index [%d] should > appliedi[%d] + 1",
+ apply.snapshot.Metadata.Index, ep.appliedi)
+ }
+
+ // wait for raftNode to persist snapshot onto the disk
+ <-apply.notifyc
+
+ newbe, err := openSnapshotBackend(s.Cfg, s.snapshotter, apply.snapshot)
+ if err != nil {
+ plog.Panic(err)
+ }
+
+ // always recover lessor before kv. When we recover the mvcc.KV it will reattach keys to its leases.
+ // If we recover mvcc.KV first, it will attach the keys to the wrong lessor before it recovers.
+ if s.lessor != nil {
+ plog.Info("recovering lessor...")
+ s.lessor.Recover(newbe, func() lease.TxnDelete { return s.kv.Write() })
+ plog.Info("finished recovering lessor")
+ }
+
+ plog.Info("restoring mvcc store...")
+
+ if err := s.kv.Restore(newbe); err != nil {
+ plog.Panicf("restore KV error: %v", err)
+ }
+ s.consistIndex.setConsistentIndex(s.kv.ConsistentIndex())
+
+ plog.Info("finished restoring mvcc store")
+
+ // Closing old backend might block until all the txns
+ // on the backend are finished.
+ // We do not want to wait on closing the old backend.
+ s.bemu.Lock()
+ oldbe := s.be
+ go func() {
+ plog.Info("closing old backend...")
+ defer plog.Info("finished closing old backend")
+
+ if err := oldbe.Close(); err != nil {
+ plog.Panicf("close backend error: %v", err)
+ }
+ }()
+
+ s.be = newbe
+ s.bemu.Unlock()
+
+ plog.Info("recovering alarms...")
+ if err := s.restoreAlarms(); err != nil {
+ plog.Panicf("restore alarms error: %v", err)
+ }
+ plog.Info("finished recovering alarms")
+
+ if s.authStore != nil {
+ plog.Info("recovering auth store...")
+ s.authStore.Recover(newbe)
+ plog.Info("finished recovering auth store")
+ }
+
+ plog.Info("recovering store v2...")
+ if err := s.store.Recovery(apply.snapshot.Data); err != nil {
+ plog.Panicf("recovery store error: %v", err)
+ }
+ plog.Info("finished recovering store v2")
+
+ s.cluster.SetBackend(s.be)
+ plog.Info("recovering cluster configuration...")
+ s.cluster.Recover(api.UpdateCapability)
+ plog.Info("finished recovering cluster configuration")
+
+ plog.Info("removing old peers from network...")
+ // recover raft transport
+ s.r.transport.RemoveAllPeers()
+ plog.Info("finished removing old peers from network")
+
+ plog.Info("adding peers from new cluster configuration into network...")
+ for _, m := range s.cluster.Members() {
+ if m.ID == s.ID() {
+ continue
+ }
+ s.r.transport.AddPeer(m.ID, m.PeerURLs)
+ }
+ plog.Info("finished adding peers from new cluster configuration into network...")
+
+ ep.appliedt = apply.snapshot.Metadata.Term
+ ep.appliedi = apply.snapshot.Metadata.Index
+ ep.snapi = ep.appliedi
+ ep.confState = apply.snapshot.Metadata.ConfState
+}
+
+func (s *EtcdServer) applyEntries(ep *etcdProgress, apply *apply) {
+ if len(apply.entries) == 0 {
+ return
+ }
+ firsti := apply.entries[0].Index
+ if firsti > ep.appliedi+1 {
+ plog.Panicf("first index of committed entry[%d] should <= appliedi[%d] + 1", firsti, ep.appliedi)
+ }
+ var ents []raftpb.Entry
+ if ep.appliedi+1-firsti < uint64(len(apply.entries)) {
+ ents = apply.entries[ep.appliedi+1-firsti:]
+ }
+ if len(ents) == 0 {
+ return
+ }
+ var shouldstop bool
+ if ep.appliedt, ep.appliedi, shouldstop = s.apply(ents, &ep.confState); shouldstop {
+ go s.stopWithDelay(10*100*time.Millisecond, fmt.Errorf("the member has been permanently removed from the cluster"))
+ }
+}
+
+func (s *EtcdServer) triggerSnapshot(ep *etcdProgress) {
+ if ep.appliedi-ep.snapi <= s.snapCount {
+ return
+ }
+
+ plog.Infof("start to snapshot (applied: %d, lastsnap: %d)", ep.appliedi, ep.snapi)
+ s.snapshot(ep.appliedi, ep.confState)
+ ep.snapi = ep.appliedi
+}
+
+func (s *EtcdServer) isMultiNode() bool {
+ return s.cluster != nil && len(s.cluster.MemberIDs()) > 1
+}
+
+func (s *EtcdServer) isLeader() bool {
+ return uint64(s.ID()) == s.Lead()
+}
+
+// transferLeadership transfers the leader to the given transferee.
+// TODO: maybe expose to client?
+func (s *EtcdServer) transferLeadership(ctx context.Context, lead, transferee uint64) error {
+ now := time.Now()
+ interval := time.Duration(s.Cfg.TickMs) * time.Millisecond
+
+ plog.Infof("%s starts leadership transfer from %s to %s", s.ID(), types.ID(lead), types.ID(transferee))
+ s.r.TransferLeadership(ctx, lead, transferee)
+ for s.Lead() != transferee {
+ select {
+ case <-ctx.Done(): // time out
+ return ErrTimeoutLeaderTransfer
+ case <-time.After(interval):
+ }
+ }
+
+ // TODO: drain all requests, or drop all messages to the old leader
+
+ plog.Infof("%s finished leadership transfer from %s to %s (took %v)", s.ID(), types.ID(lead), types.ID(transferee), time.Since(now))
+ return nil
+}
+
+// TransferLeadership transfers the leader to the chosen transferee.
+func (s *EtcdServer) TransferLeadership() error {
+ if !s.isLeader() {
+ plog.Printf("skipped leadership transfer for stopping non-leader member")
+ return nil
+ }
+
+ if !s.isMultiNode() {
+ plog.Printf("skipped leadership transfer for single member cluster")
+ return nil
+ }
+
+ transferee, ok := longestConnected(s.r.transport, s.cluster.MemberIDs())
+ if !ok {
+ return ErrUnhealthy
+ }
+
+ tm := s.Cfg.ReqTimeout()
+ ctx, cancel := context.WithTimeout(s.ctx, tm)
+ err := s.transferLeadership(ctx, s.Lead(), uint64(transferee))
+ cancel()
+ return err
+}
+
+// HardStop stops the server without coordination with other members in the cluster.
+func (s *EtcdServer) HardStop() {
+ select {
+ case s.stop <- struct{}{}:
+ case <-s.done:
+ return
+ }
+ <-s.done
+}
+
+// Stop stops the server gracefully, and shuts down the running goroutine.
+// Stop should be called after a Start(s), otherwise it will block forever.
+// When stopping leader, Stop transfers its leadership to one of its peers
+// before stopping the server.
+func (s *EtcdServer) Stop() {
+ if err := s.TransferLeadership(); err != nil {
+ plog.Warningf("%s failed to transfer leadership (%v)", s.ID(), err)
+ }
+ s.HardStop()
+}
+
+// ReadyNotify returns a channel that will be closed when the server
+// is ready to serve client requests
+func (s *EtcdServer) ReadyNotify() <-chan struct{} { return s.readych }
+
+func (s *EtcdServer) stopWithDelay(d time.Duration, err error) {
+ select {
+ case <-time.After(d):
+ case <-s.done:
+ }
+ select {
+ case s.errorc <- err:
+ default:
+ }
+}
+
+// StopNotify returns a channel that receives a empty struct
+// when the server is stopped.
+func (s *EtcdServer) StopNotify() <-chan struct{} { return s.done }
+
+func (s *EtcdServer) SelfStats() []byte { return s.stats.JSON() }
+
+func (s *EtcdServer) LeaderStats() []byte {
+ lead := atomic.LoadUint64(&s.r.lead)
+ if lead != uint64(s.id) {
+ return nil
+ }
+ return s.lstats.JSON()
+}
+
+func (s *EtcdServer) StoreStats() []byte { return s.store.JsonStats() }
+
+func (s *EtcdServer) checkMembershipOperationPermission(ctx context.Context) error {
+ if s.authStore == nil {
+ // In the context of ordinary etcd process, s.authStore will never be nil.
+ // This branch is for handling cases in server_test.go
+ return nil
+ }
+
+ // Note that this permission check is done in the API layer,
+ // so TOCTOU problem can be caused potentially in a schedule like this:
+ // update membership with user A -> revoke root role of A -> apply membership change
+ // in the state machine layer
+ // However, both of membership change and role management requires the root privilege.
+ // So careful operation by admins can prevent the problem.
+ authInfo, err := s.AuthInfoFromCtx(ctx)
+ if err != nil {
+ return err
+ }
+
+ return s.AuthStore().IsAdminPermitted(authInfo)
+}
+
+func (s *EtcdServer) AddMember(ctx context.Context, memb membership.Member) ([]*membership.Member, error) {
+ if err := s.checkMembershipOperationPermission(ctx); err != nil {
+ return nil, err
+ }
+
+ if s.Cfg.StrictReconfigCheck {
+ // by default StrictReconfigCheck is enabled; reject new members if unhealthy
+ if !s.cluster.IsReadyToAddNewMember() {
+ plog.Warningf("not enough started members, rejecting member add %+v", memb)
+ return nil, ErrNotEnoughStartedMembers
+ }
+ if !isConnectedFullySince(s.r.transport, time.Now().Add(-HealthInterval), s.ID(), s.cluster.Members()) {
+ plog.Warningf("not healthy for reconfigure, rejecting member add %+v", memb)
+ return nil, ErrUnhealthy
+ }
+ }
+
+ // TODO: move Member to protobuf type
+ b, err := json.Marshal(memb)
+ if err != nil {
+ return nil, err
+ }
+ cc := raftpb.ConfChange{
+ Type: raftpb.ConfChangeAddNode,
+ NodeID: uint64(memb.ID),
+ Context: b,
+ }
+ return s.configure(ctx, cc)
+}
+
+func (s *EtcdServer) RemoveMember(ctx context.Context, id uint64) ([]*membership.Member, error) {
+ if err := s.checkMembershipOperationPermission(ctx); err != nil {
+ return nil, err
+ }
+
+ // by default StrictReconfigCheck is enabled; reject removal if leads to quorum loss
+ if err := s.mayRemoveMember(types.ID(id)); err != nil {
+ return nil, err
+ }
+
+ cc := raftpb.ConfChange{
+ Type: raftpb.ConfChangeRemoveNode,
+ NodeID: id,
+ }
+ return s.configure(ctx, cc)
+}
+
+func (s *EtcdServer) mayRemoveMember(id types.ID) error {
+ if !s.Cfg.StrictReconfigCheck {
+ return nil
+ }
+
+ if !s.cluster.IsReadyToRemoveMember(uint64(id)) {
+ plog.Warningf("not enough started members, rejecting remove member %s", id)
+ return ErrNotEnoughStartedMembers
+ }
+
+ // downed member is safe to remove since it's not part of the active quorum
+ if t := s.r.transport.ActiveSince(id); id != s.ID() && t.IsZero() {
+ return nil
+ }
+
+ // protect quorum if some members are down
+ m := s.cluster.Members()
+ active := numConnectedSince(s.r.transport, time.Now().Add(-HealthInterval), s.ID(), m)
+ if (active - 1) < 1+((len(m)-1)/2) {
+ plog.Warningf("reconfigure breaks active quorum, rejecting remove member %s", id)
+ return ErrUnhealthy
+ }
+
+ return nil
+}
+
+func (s *EtcdServer) UpdateMember(ctx context.Context, memb membership.Member) ([]*membership.Member, error) {
+ b, merr := json.Marshal(memb)
+ if merr != nil {
+ return nil, merr
+ }
+
+ if err := s.checkMembershipOperationPermission(ctx); err != nil {
+ return nil, err
+ }
+ cc := raftpb.ConfChange{
+ Type: raftpb.ConfChangeUpdateNode,
+ NodeID: uint64(memb.ID),
+ Context: b,
+ }
+ return s.configure(ctx, cc)
+}
+
+// Implement the RaftTimer interface
+
+func (s *EtcdServer) Index() uint64 { return atomic.LoadUint64(&s.r.index) }
+
+func (s *EtcdServer) Term() uint64 { return atomic.LoadUint64(&s.r.term) }
+
+// Lead is only for testing purposes.
+// TODO: add Raft server interface to expose raft related info:
+// Index, Term, Lead, Committed, Applied, LastIndex, etc.
+func (s *EtcdServer) Lead() uint64 { return atomic.LoadUint64(&s.r.lead) }
+
+func (s *EtcdServer) Leader() types.ID { return types.ID(s.Lead()) }
+
+type confChangeResponse struct {
+ membs []*membership.Member
+ err error
+}
+
+// configure sends a configuration change through consensus and
+// then waits for it to be applied to the server. It
+// will block until the change is performed or there is an error.
+func (s *EtcdServer) configure(ctx context.Context, cc raftpb.ConfChange) ([]*membership.Member, error) {
+ cc.ID = s.reqIDGen.Next()
+ ch := s.w.Register(cc.ID)
+ start := time.Now()
+ if err := s.r.ProposeConfChange(ctx, cc); err != nil {
+ s.w.Trigger(cc.ID, nil)
+ return nil, err
+ }
+ select {
+ case x := <-ch:
+ if x == nil {
+ plog.Panicf("configure trigger value should never be nil")
+ }
+ resp := x.(*confChangeResponse)
+ return resp.membs, resp.err
+ case <-ctx.Done():
+ s.w.Trigger(cc.ID, nil) // GC wait
+ return nil, s.parseProposeCtxErr(ctx.Err(), start)
+ case <-s.stopping:
+ return nil, ErrStopped
+ }
+}
+
+// sync proposes a SYNC request and is non-blocking.
+// This makes no guarantee that the request will be proposed or performed.
+// The request will be canceled after the given timeout.
+func (s *EtcdServer) sync(timeout time.Duration) {
+ req := pb.Request{
+ Method: "SYNC",
+ ID: s.reqIDGen.Next(),
+ Time: time.Now().UnixNano(),
+ }
+ data := pbutil.MustMarshal(&req)
+ // There is no promise that node has leader when do SYNC request,
+ // so it uses goroutine to propose.
+ ctx, cancel := context.WithTimeout(s.ctx, timeout)
+ s.goAttach(func() {
+ s.r.Propose(ctx, data)
+ cancel()
+ })
+}
+
+// publish registers server information into the cluster. The information
+// is the JSON representation of this server's member struct, updated with the
+// static clientURLs of the server.
+// The function keeps attempting to register until it succeeds,
+// or its server is stopped.
+func (s *EtcdServer) publish(timeout time.Duration) {
+ b, err := json.Marshal(s.attributes)
+ if err != nil {
+ plog.Panicf("json marshal error: %v", err)
+ return
+ }
+ req := pb.Request{
+ Method: "PUT",
+ Path: membership.MemberAttributesStorePath(s.id),
+ Val: string(b),
+ }
+
+ for {
+ ctx, cancel := context.WithTimeout(s.ctx, timeout)
+ _, err := s.Do(ctx, req)
+ cancel()
+ switch err {
+ case nil:
+ close(s.readych)
+ plog.Infof("published %+v to cluster %s", s.attributes, s.cluster.ID())
+ return
+ case ErrStopped:
+ plog.Infof("aborting publish because server is stopped")
+ return
+ default:
+ plog.Errorf("publish error: %v", err)
+ }
+ }
+}
+
+func (s *EtcdServer) sendMergedSnap(merged snap.Message) {
+ atomic.AddInt64(&s.inflightSnapshots, 1)
+
+ s.r.transport.SendSnapshot(merged)
+ s.goAttach(func() {
+ select {
+ case ok := <-merged.CloseNotify():
+ // delay releasing inflight snapshot for another 30 seconds to
+ // block log compaction.
+ // If the follower still fails to catch up, it is probably just too slow
+ // to catch up. We cannot avoid the snapshot cycle anyway.
+ if ok {
+ select {
+ case <-time.After(releaseDelayAfterSnapshot):
+ case <-s.stopping:
+ }
+ }
+ atomic.AddInt64(&s.inflightSnapshots, -1)
+ case <-s.stopping:
+ return
+ }
+ })
+}
+
+// apply takes entries received from Raft (after it has been committed) and
+// applies them to the current state of the EtcdServer.
+// The given entries should not be empty.
+func (s *EtcdServer) apply(es []raftpb.Entry, confState *raftpb.ConfState) (appliedt uint64, appliedi uint64, shouldStop bool) {
+ for i := range es {
+ e := es[i]
+ switch e.Type {
+ case raftpb.EntryNormal:
+ s.applyEntryNormal(&e)
+ case raftpb.EntryConfChange:
+ // set the consistent index of current executing entry
+ if e.Index > s.consistIndex.ConsistentIndex() {
+ s.consistIndex.setConsistentIndex(e.Index)
+ }
+ var cc raftpb.ConfChange
+ pbutil.MustUnmarshal(&cc, e.Data)
+ removedSelf, err := s.applyConfChange(cc, confState)
+ s.setAppliedIndex(e.Index)
+ shouldStop = shouldStop || removedSelf
+ s.w.Trigger(cc.ID, &confChangeResponse{s.cluster.Members(), err})
+ default:
+ plog.Panicf("entry type should be either EntryNormal or EntryConfChange")
+ }
+ atomic.StoreUint64(&s.r.index, e.Index)
+ atomic.StoreUint64(&s.r.term, e.Term)
+ appliedt = e.Term
+ appliedi = e.Index
+ }
+ return appliedt, appliedi, shouldStop
+}
+
+// applyEntryNormal apples an EntryNormal type raftpb request to the EtcdServer
+func (s *EtcdServer) applyEntryNormal(e *raftpb.Entry) {
+ shouldApplyV3 := false
+ if e.Index > s.consistIndex.ConsistentIndex() {
+ // set the consistent index of current executing entry
+ s.consistIndex.setConsistentIndex(e.Index)
+ shouldApplyV3 = true
+ }
+ defer s.setAppliedIndex(e.Index)
+
+ // raft state machine may generate noop entry when leader confirmation.
+ // skip it in advance to avoid some potential bug in the future
+ if len(e.Data) == 0 {
+ select {
+ case s.forceVersionC <- struct{}{}:
+ default:
+ }
+ // promote lessor when the local member is leader and finished
+ // applying all entries from the last term.
+ if s.isLeader() {
+ s.lessor.Promote(s.Cfg.electionTimeout())
+ }
+ return
+ }
+
+ var raftReq pb.InternalRaftRequest
+ if !pbutil.MaybeUnmarshal(&raftReq, e.Data) { // backward compatible
+ var r pb.Request
+ pbutil.MustUnmarshal(&r, e.Data)
+ s.w.Trigger(r.ID, s.applyV2Request(&r))
+ return
+ }
+ if raftReq.V2 != nil {
+ req := raftReq.V2
+ s.w.Trigger(req.ID, s.applyV2Request(req))
+ return
+ }
+
+ // do not re-apply applied entries.
+ if !shouldApplyV3 {
+ return
+ }
+
+ id := raftReq.ID
+ if id == 0 {
+ id = raftReq.Header.ID
+ }
+
+ var ar *applyResult
+ needResult := s.w.IsRegistered(id)
+ if needResult || !noSideEffect(&raftReq) {
+ if !needResult && raftReq.Txn != nil {
+ removeNeedlessRangeReqs(raftReq.Txn)
+ }
+ ar = s.applyV3.Apply(&raftReq)
+ }
+
+ if ar == nil {
+ return
+ }
+
+ if ar.err != ErrNoSpace || len(s.alarmStore.Get(pb.AlarmType_NOSPACE)) > 0 {
+ s.w.Trigger(id, ar)
+ return
+ }
+
+ plog.Errorf("applying raft message exceeded backend quota")
+ s.goAttach(func() {
+ a := &pb.AlarmRequest{
+ MemberID: uint64(s.ID()),
+ Action: pb.AlarmRequest_ACTIVATE,
+ Alarm: pb.AlarmType_NOSPACE,
+ }
+ r := pb.InternalRaftRequest{Alarm: a}
+ s.processInternalRaftRequest(s.ctx, r)
+ s.w.Trigger(id, ar)
+ })
+}
+
+// applyConfChange applies a ConfChange to the server. It is only
+// invoked with a ConfChange that has already passed through Raft
+func (s *EtcdServer) applyConfChange(cc raftpb.ConfChange, confState *raftpb.ConfState) (bool, error) {
+ if err := s.cluster.ValidateConfigurationChange(cc); err != nil {
+ cc.NodeID = raft.None
+ s.r.ApplyConfChange(cc)
+ return false, err
+ }
+ *confState = *s.r.ApplyConfChange(cc)
+ switch cc.Type {
+ case raftpb.ConfChangeAddNode:
+ m := new(membership.Member)
+ if err := json.Unmarshal(cc.Context, m); err != nil {
+ plog.Panicf("unmarshal member should never fail: %v", err)
+ }
+ if cc.NodeID != uint64(m.ID) {
+ plog.Panicf("nodeID should always be equal to member ID")
+ }
+ s.cluster.AddMember(m)
+ if m.ID != s.id {
+ s.r.transport.AddPeer(m.ID, m.PeerURLs)
+ }
+ case raftpb.ConfChangeRemoveNode:
+ id := types.ID(cc.NodeID)
+ s.cluster.RemoveMember(id)
+ if id == s.id {
+ return true, nil
+ }
+ s.r.transport.RemovePeer(id)
+ case raftpb.ConfChangeUpdateNode:
+ m := new(membership.Member)
+ if err := json.Unmarshal(cc.Context, m); err != nil {
+ plog.Panicf("unmarshal member should never fail: %v", err)
+ }
+ if cc.NodeID != uint64(m.ID) {
+ plog.Panicf("nodeID should always be equal to member ID")
+ }
+ s.cluster.UpdateRaftAttributes(m.ID, m.RaftAttributes)
+ if m.ID != s.id {
+ s.r.transport.UpdatePeer(m.ID, m.PeerURLs)
+ }
+ }
+ return false, nil
+}
+
+// TODO: non-blocking snapshot
+func (s *EtcdServer) snapshot(snapi uint64, confState raftpb.ConfState) {
+ clone := s.store.Clone()
+ // commit kv to write metadata (for example: consistent index) to disk.
+ // KV().commit() updates the consistent index in backend.
+ // All operations that update consistent index must be called sequentially
+ // from applyAll function.
+ // So KV().Commit() cannot run in parallel with apply. It has to be called outside
+ // the go routine created below.
+ s.KV().Commit()
+
+ s.goAttach(func() {
+ d, err := clone.SaveNoCopy()
+ // TODO: current store will never fail to do a snapshot
+ // what should we do if the store might fail?
+ if err != nil {
+ plog.Panicf("store save should never fail: %v", err)
+ }
+ snap, err := s.r.raftStorage.CreateSnapshot(snapi, &confState, d)
+ if err != nil {
+ // the snapshot was done asynchronously with the progress of raft.
+ // raft might have already got a newer snapshot.
+ if err == raft.ErrSnapOutOfDate {
+ return
+ }
+ plog.Panicf("unexpected create snapshot error %v", err)
+ }
+ // SaveSnap saves the snapshot and releases the locked wal files
+ // to the snapshot index.
+ if err = s.r.storage.SaveSnap(snap); err != nil {
+ plog.Fatalf("save snapshot error: %v", err)
+ }
+ plog.Infof("saved snapshot at index %d", snap.Metadata.Index)
+
+ // When sending a snapshot, etcd will pause compaction.
+ // After receives a snapshot, the slow follower needs to get all the entries right after
+ // the snapshot sent to catch up. If we do not pause compaction, the log entries right after
+ // the snapshot sent might already be compacted. It happens when the snapshot takes long time
+ // to send and save. Pausing compaction avoids triggering a snapshot sending cycle.
+ if atomic.LoadInt64(&s.inflightSnapshots) != 0 {
+ plog.Infof("skip compaction since there is an inflight snapshot")
+ return
+ }
+
+ // keep some in memory log entries for slow followers.
+ compacti := uint64(1)
+ if snapi > numberOfCatchUpEntries {
+ compacti = snapi - numberOfCatchUpEntries
+ }
+ err = s.r.raftStorage.Compact(compacti)
+ if err != nil {
+ // the compaction was done asynchronously with the progress of raft.
+ // raft log might already been compact.
+ if err == raft.ErrCompacted {
+ return
+ }
+ plog.Panicf("unexpected compaction error %v", err)
+ }
+ plog.Infof("compacted raft log at %d", compacti)
+ })
+}
+
+// CutPeer drops messages to the specified peer.
+func (s *EtcdServer) CutPeer(id types.ID) {
+ tr, ok := s.r.transport.(*rafthttp.Transport)
+ if ok {
+ tr.CutPeer(id)
+ }
+}
+
+// MendPeer recovers the message dropping behavior of the given peer.
+func (s *EtcdServer) MendPeer(id types.ID) {
+ tr, ok := s.r.transport.(*rafthttp.Transport)
+ if ok {
+ tr.MendPeer(id)
+ }
+}
+
+func (s *EtcdServer) PauseSending() { s.r.pauseSending() }
+
+func (s *EtcdServer) ResumeSending() { s.r.resumeSending() }
+
+func (s *EtcdServer) ClusterVersion() *semver.Version {
+ if s.cluster == nil {
+ return nil
+ }
+ return s.cluster.Version()
+}
+
+// monitorVersions checks the member's version every monitorVersionInterval.
+// It updates the cluster version if all members agrees on a higher one.
+// It prints out log if there is a member with a higher version than the
+// local version.
+func (s *EtcdServer) monitorVersions() {
+ for {
+ select {
+ case <-s.forceVersionC:
+ case <-time.After(monitorVersionInterval):
+ case <-s.stopping:
+ return
+ }
+
+ if s.Leader() != s.ID() {
+ continue
+ }
+
+ v := decideClusterVersion(getVersions(s.cluster, s.id, s.peerRt))
+ if v != nil {
+ // only keep major.minor version for comparison
+ v = &semver.Version{
+ Major: v.Major,
+ Minor: v.Minor,
+ }
+ }
+
+ // if the current version is nil:
+ // 1. use the decided version if possible
+ // 2. or use the min cluster version
+ if s.cluster.Version() == nil {
+ verStr := version.MinClusterVersion
+ if v != nil {
+ verStr = v.String()
+ }
+ s.goAttach(func() { s.updateClusterVersion(verStr) })
+ continue
+ }
+
+ // update cluster version only if the decided version is greater than
+ // the current cluster version
+ if v != nil && s.cluster.Version().LessThan(*v) {
+ s.goAttach(func() { s.updateClusterVersion(v.String()) })
+ }
+ }
+}
+
+func (s *EtcdServer) updateClusterVersion(ver string) {
+ if s.cluster.Version() == nil {
+ plog.Infof("setting up the initial cluster version to %s", version.Cluster(ver))
+ } else {
+ plog.Infof("updating the cluster version from %s to %s", version.Cluster(s.cluster.Version().String()), version.Cluster(ver))
+ }
+ req := pb.Request{
+ Method: "PUT",
+ Path: membership.StoreClusterVersionKey(),
+ Val: ver,
+ }
+ ctx, cancel := context.WithTimeout(s.ctx, s.Cfg.ReqTimeout())
+ _, err := s.Do(ctx, req)
+ cancel()
+ switch err {
+ case nil:
+ return
+ case ErrStopped:
+ plog.Infof("aborting update cluster version because server is stopped")
+ return
+ default:
+ plog.Errorf("error updating cluster version (%v)", err)
+ }
+}
+
+func (s *EtcdServer) parseProposeCtxErr(err error, start time.Time) error {
+ switch err {
+ case context.Canceled:
+ return ErrCanceled
+ case context.DeadlineExceeded:
+ s.leadTimeMu.RLock()
+ curLeadElected := s.leadElectedTime
+ s.leadTimeMu.RUnlock()
+ prevLeadLost := curLeadElected.Add(-2 * time.Duration(s.Cfg.ElectionTicks) * time.Duration(s.Cfg.TickMs) * time.Millisecond)
+ if start.After(prevLeadLost) && start.Before(curLeadElected) {
+ return ErrTimeoutDueToLeaderFail
+ }
+
+ lead := types.ID(atomic.LoadUint64(&s.r.lead))
+ switch lead {
+ case types.ID(raft.None):
+ // TODO: return error to specify it happens because the cluster does not have leader now
+ case s.ID():
+ if !isConnectedToQuorumSince(s.r.transport, start, s.ID(), s.cluster.Members()) {
+ return ErrTimeoutDueToConnectionLost
+ }
+ default:
+ if !isConnectedSince(s.r.transport, start, lead) {
+ return ErrTimeoutDueToConnectionLost
+ }
+ }
+
+ return ErrTimeout
+ default:
+ return err
+ }
+}
+
+func (s *EtcdServer) KV() mvcc.ConsistentWatchableKV { return s.kv }
+func (s *EtcdServer) Backend() backend.Backend {
+ s.bemu.Lock()
+ defer s.bemu.Unlock()
+ return s.be
+}
+
+func (s *EtcdServer) AuthStore() auth.AuthStore { return s.authStore }
+
+func (s *EtcdServer) restoreAlarms() error {
+ s.applyV3 = s.newApplierV3()
+ as, err := alarm.NewAlarmStore(s)
+ if err != nil {
+ return err
+ }
+ s.alarmStore = as
+ if len(as.Get(pb.AlarmType_NOSPACE)) > 0 {
+ s.applyV3 = newApplierV3Capped(s.applyV3)
+ }
+ return nil
+}
+
+func (s *EtcdServer) getAppliedIndex() uint64 {
+ return atomic.LoadUint64(&s.appliedIndex)
+}
+
+func (s *EtcdServer) setAppliedIndex(v uint64) {
+ atomic.StoreUint64(&s.appliedIndex, v)
+}
+
+func (s *EtcdServer) getCommittedIndex() uint64 {
+ return atomic.LoadUint64(&s.committedIndex)
+}
+
+func (s *EtcdServer) setCommittedIndex(v uint64) {
+ atomic.StoreUint64(&s.committedIndex, v)
+}
+
+// goAttach creates a goroutine on a given function and tracks it using
+// the etcdserver waitgroup.
+func (s *EtcdServer) goAttach(f func()) {
+ s.wgMu.RLock() // this blocks with ongoing close(s.stopping)
+ defer s.wgMu.RUnlock()
+ select {
+ case <-s.stopping:
+ plog.Warning("server has stopped (skipping goAttach)")
+ return
+ default:
+ }
+
+ // now safe to add since waitgroup wait has not started yet
+ s.wg.Add(1)
+ go func() {
+ defer s.wg.Done()
+ f()
+ }()
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/server_test.go b/vendor/github.com/coreos/etcd/etcdserver/server_test.go
new file mode 100644
index 00000000..c7ba0951
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/server_test.go
@@ -0,0 +1,1662 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "encoding/json"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path"
+ "path/filepath"
+ "reflect"
+ "testing"
+ "time"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/pkg/fileutil"
+ "github.com/coreos/etcd/pkg/idutil"
+ "github.com/coreos/etcd/pkg/mock/mockstorage"
+ "github.com/coreos/etcd/pkg/mock/mockstore"
+ "github.com/coreos/etcd/pkg/mock/mockwait"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/pkg/wait"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/rafthttp"
+ "github.com/coreos/etcd/snap"
+ "github.com/coreos/etcd/store"
+ "golang.org/x/net/context"
+)
+
+// TestDoLocalAction tests requests which do not need to go through raft to be applied,
+// and are served through local data.
+func TestDoLocalAction(t *testing.T) {
+ tests := []struct {
+ req pb.Request
+
+ wresp Response
+ werr error
+ wactions []testutil.Action
+ }{
+ {
+ pb.Request{Method: "GET", ID: 1, Wait: true},
+ Response{Watcher: store.NewNopWatcher()}, nil, []testutil.Action{{Name: "Watch"}},
+ },
+ {
+ pb.Request{Method: "GET", ID: 1},
+ Response{Event: &store.Event{}}, nil,
+ []testutil.Action{
+ {
+ Name: "Get",
+ Params: []interface{}{"", false, false},
+ },
+ },
+ },
+ {
+ pb.Request{Method: "HEAD", ID: 1},
+ Response{Event: &store.Event{}}, nil,
+ []testutil.Action{
+ {
+ Name: "Get",
+ Params: []interface{}{"", false, false},
+ },
+ },
+ },
+ {
+ pb.Request{Method: "BADMETHOD", ID: 1},
+ Response{}, ErrUnknownMethod, []testutil.Action{},
+ },
+ }
+ for i, tt := range tests {
+ st := mockstore.NewRecorder()
+ srv := &EtcdServer{
+ store: st,
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ }
+ resp, err := srv.Do(context.TODO(), tt.req)
+
+ if err != tt.werr {
+ t.Fatalf("#%d: err = %+v, want %+v", i, err, tt.werr)
+ }
+ if !reflect.DeepEqual(resp, tt.wresp) {
+ t.Errorf("#%d: resp = %+v, want %+v", i, resp, tt.wresp)
+ }
+ gaction := st.Action()
+ if !reflect.DeepEqual(gaction, tt.wactions) {
+ t.Errorf("#%d: action = %+v, want %+v", i, gaction, tt.wactions)
+ }
+ }
+}
+
+// TestDoBadLocalAction tests server requests which do not need to go through consensus,
+// and return errors when they fetch from local data.
+func TestDoBadLocalAction(t *testing.T) {
+ storeErr := fmt.Errorf("bah")
+ tests := []struct {
+ req pb.Request
+
+ wactions []testutil.Action
+ }{
+ {
+ pb.Request{Method: "GET", ID: 1, Wait: true},
+ []testutil.Action{{Name: "Watch"}},
+ },
+ {
+ pb.Request{Method: "GET", ID: 1},
+ []testutil.Action{
+ {
+ Name: "Get",
+ Params: []interface{}{"", false, false},
+ },
+ },
+ },
+ {
+ pb.Request{Method: "HEAD", ID: 1},
+ []testutil.Action{
+ {
+ Name: "Get",
+ Params: []interface{}{"", false, false},
+ },
+ },
+ },
+ }
+ for i, tt := range tests {
+ st := mockstore.NewErrRecorder(storeErr)
+ srv := &EtcdServer{
+ store: st,
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ }
+ resp, err := srv.Do(context.Background(), tt.req)
+
+ if err != storeErr {
+ t.Fatalf("#%d: err = %+v, want %+v", i, err, storeErr)
+ }
+ if !reflect.DeepEqual(resp, Response{}) {
+ t.Errorf("#%d: resp = %+v, want %+v", i, resp, Response{})
+ }
+ gaction := st.Action()
+ if !reflect.DeepEqual(gaction, tt.wactions) {
+ t.Errorf("#%d: action = %+v, want %+v", i, gaction, tt.wactions)
+ }
+ }
+}
+
+// TestApplyRepeat tests that server handles repeat raft messages gracefully
+func TestApplyRepeat(t *testing.T) {
+ n := newNodeConfChangeCommitterStream()
+ n.readyc <- raft.Ready{
+ SoftState: &raft.SoftState{RaftState: raft.StateLeader},
+ }
+ cl := newTestCluster(nil)
+ st := store.New()
+ cl.SetStore(store.New())
+ cl.AddMember(&membership.Member{ID: 1234})
+ r := newRaftNode(raftNodeConfig{
+ Node: n,
+ raftStorage: raft.NewMemoryStorage(),
+ storage: mockstorage.NewStorageRecorder(""),
+ transport: rafthttp.NewNopTransporter(),
+ })
+ s := &EtcdServer{
+ r: *r,
+ Cfg: &ServerConfig{},
+ store: st,
+ cluster: cl,
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ SyncTicker: &time.Ticker{},
+ }
+ s.applyV2 = &applierV2store{store: s.store, cluster: s.cluster}
+ s.start()
+ req := &pb.Request{Method: "QGET", ID: uint64(1)}
+ ents := []raftpb.Entry{{Index: 1, Data: pbutil.MustMarshal(req)}}
+ n.readyc <- raft.Ready{CommittedEntries: ents}
+ // dup msg
+ n.readyc <- raft.Ready{CommittedEntries: ents}
+
+ // use a conf change to block until dup msgs are all processed
+ cc := &raftpb.ConfChange{Type: raftpb.ConfChangeRemoveNode, NodeID: 2}
+ ents = []raftpb.Entry{{
+ Index: 2,
+ Type: raftpb.EntryConfChange,
+ Data: pbutil.MustMarshal(cc),
+ }}
+ n.readyc <- raft.Ready{CommittedEntries: ents}
+ // wait for conf change message
+ act, err := n.Wait(1)
+ // wait for stop message (async to avoid deadlock)
+ stopc := make(chan error)
+ go func() {
+ _, werr := n.Wait(1)
+ stopc <- werr
+ }()
+ s.Stop()
+
+ // only want to confirm etcdserver won't panic; no data to check
+
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(act) == 0 {
+ t.Fatalf("expected len(act)=0, got %d", len(act))
+ }
+
+ if err = <-stopc; err != nil {
+ t.Fatalf("error on stop (%v)", err)
+ }
+}
+
+func TestApplyRequest(t *testing.T) {
+ tests := []struct {
+ req pb.Request
+
+ wresp Response
+ wactions []testutil.Action
+ }{
+ // POST ==> Create
+ {
+ pb.Request{Method: "POST", ID: 1},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "Create",
+ Params: []interface{}{"", false, "", true, store.TTLOptionSet{ExpireTime: time.Time{}}},
+ },
+ },
+ },
+ // POST ==> Create, with expiration
+ {
+ pb.Request{Method: "POST", ID: 1, Expiration: 1337},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "Create",
+ Params: []interface{}{"", false, "", true, store.TTLOptionSet{ExpireTime: time.Unix(0, 1337)}},
+ },
+ },
+ },
+ // POST ==> Create, with dir
+ {
+ pb.Request{Method: "POST", ID: 1, Dir: true},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "Create",
+ Params: []interface{}{"", true, "", true, store.TTLOptionSet{ExpireTime: time.Time{}}},
+ },
+ },
+ },
+ // PUT ==> Set
+ {
+ pb.Request{Method: "PUT", ID: 1},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "Set",
+ Params: []interface{}{"", false, "", store.TTLOptionSet{ExpireTime: time.Time{}}},
+ },
+ },
+ },
+ // PUT ==> Set, with dir
+ {
+ pb.Request{Method: "PUT", ID: 1, Dir: true},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "Set",
+ Params: []interface{}{"", true, "", store.TTLOptionSet{ExpireTime: time.Time{}}},
+ },
+ },
+ },
+ // PUT with PrevExist=true ==> Update
+ {
+ pb.Request{Method: "PUT", ID: 1, PrevExist: pbutil.Boolp(true)},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "Update",
+ Params: []interface{}{"", "", store.TTLOptionSet{ExpireTime: time.Time{}}},
+ },
+ },
+ },
+ // PUT with PrevExist=false ==> Create
+ {
+ pb.Request{Method: "PUT", ID: 1, PrevExist: pbutil.Boolp(false)},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "Create",
+ Params: []interface{}{"", false, "", false, store.TTLOptionSet{ExpireTime: time.Time{}}},
+ },
+ },
+ },
+ // PUT with PrevExist=true *and* PrevIndex set ==> CompareAndSwap
+ {
+ pb.Request{Method: "PUT", ID: 1, PrevExist: pbutil.Boolp(true), PrevIndex: 1},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "CompareAndSwap",
+ Params: []interface{}{"", "", uint64(1), "", store.TTLOptionSet{ExpireTime: time.Time{}}},
+ },
+ },
+ },
+ // PUT with PrevExist=false *and* PrevIndex set ==> Create
+ {
+ pb.Request{Method: "PUT", ID: 1, PrevExist: pbutil.Boolp(false), PrevIndex: 1},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "Create",
+ Params: []interface{}{"", false, "", false, store.TTLOptionSet{ExpireTime: time.Time{}}},
+ },
+ },
+ },
+ // PUT with PrevIndex set ==> CompareAndSwap
+ {
+ pb.Request{Method: "PUT", ID: 1, PrevIndex: 1},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "CompareAndSwap",
+ Params: []interface{}{"", "", uint64(1), "", store.TTLOptionSet{ExpireTime: time.Time{}}},
+ },
+ },
+ },
+ // PUT with PrevValue set ==> CompareAndSwap
+ {
+ pb.Request{Method: "PUT", ID: 1, PrevValue: "bar"},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "CompareAndSwap",
+ Params: []interface{}{"", "bar", uint64(0), "", store.TTLOptionSet{ExpireTime: time.Time{}}},
+ },
+ },
+ },
+ // PUT with PrevIndex and PrevValue set ==> CompareAndSwap
+ {
+ pb.Request{Method: "PUT", ID: 1, PrevIndex: 1, PrevValue: "bar"},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "CompareAndSwap",
+ Params: []interface{}{"", "bar", uint64(1), "", store.TTLOptionSet{ExpireTime: time.Time{}}},
+ },
+ },
+ },
+ // DELETE ==> Delete
+ {
+ pb.Request{Method: "DELETE", ID: 1},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "Delete",
+ Params: []interface{}{"", false, false},
+ },
+ },
+ },
+ // DELETE with PrevIndex set ==> CompareAndDelete
+ {
+ pb.Request{Method: "DELETE", ID: 1, PrevIndex: 1},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "CompareAndDelete",
+ Params: []interface{}{"", "", uint64(1)},
+ },
+ },
+ },
+ // DELETE with PrevValue set ==> CompareAndDelete
+ {
+ pb.Request{Method: "DELETE", ID: 1, PrevValue: "bar"},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "CompareAndDelete",
+ Params: []interface{}{"", "bar", uint64(0)},
+ },
+ },
+ },
+ // DELETE with PrevIndex *and* PrevValue set ==> CompareAndDelete
+ {
+ pb.Request{Method: "DELETE", ID: 1, PrevIndex: 5, PrevValue: "bar"},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "CompareAndDelete",
+ Params: []interface{}{"", "bar", uint64(5)},
+ },
+ },
+ },
+ // QGET ==> Get
+ {
+ pb.Request{Method: "QGET", ID: 1},
+ Response{Event: &store.Event{}},
+ []testutil.Action{
+ {
+ Name: "Get",
+ Params: []interface{}{"", false, false},
+ },
+ },
+ },
+ // SYNC ==> DeleteExpiredKeys
+ {
+ pb.Request{Method: "SYNC", ID: 1},
+ Response{},
+ []testutil.Action{
+ {
+ Name: "DeleteExpiredKeys",
+ Params: []interface{}{time.Unix(0, 0)},
+ },
+ },
+ },
+ {
+ pb.Request{Method: "SYNC", ID: 1, Time: 12345},
+ Response{},
+ []testutil.Action{
+ {
+ Name: "DeleteExpiredKeys",
+ Params: []interface{}{time.Unix(0, 12345)},
+ },
+ },
+ },
+ // Unknown method - error
+ {
+ pb.Request{Method: "BADMETHOD", ID: 1},
+ Response{err: ErrUnknownMethod},
+ []testutil.Action{},
+ },
+ }
+
+ for i, tt := range tests {
+ st := mockstore.NewRecorder()
+ srv := &EtcdServer{store: st}
+ srv.applyV2 = &applierV2store{store: srv.store, cluster: srv.cluster}
+ resp := srv.applyV2Request(&tt.req)
+
+ if !reflect.DeepEqual(resp, tt.wresp) {
+ t.Errorf("#%d: resp = %+v, want %+v", i, resp, tt.wresp)
+ }
+ gaction := st.Action()
+ if !reflect.DeepEqual(gaction, tt.wactions) {
+ t.Errorf("#%d: action = %#v, want %#v", i, gaction, tt.wactions)
+ }
+ }
+}
+
+func TestApplyRequestOnAdminMemberAttributes(t *testing.T) {
+ cl := newTestCluster([]*membership.Member{{ID: 1}})
+ srv := &EtcdServer{
+ store: mockstore.NewRecorder(),
+ cluster: cl,
+ }
+ srv.applyV2 = &applierV2store{store: srv.store, cluster: srv.cluster}
+
+ req := pb.Request{
+ Method: "PUT",
+ ID: 1,
+ Path: membership.MemberAttributesStorePath(1),
+ Val: `{"Name":"abc","ClientURLs":["http://127.0.0.1:2379"]}`,
+ }
+ srv.applyV2Request(&req)
+ w := membership.Attributes{Name: "abc", ClientURLs: []string{"http://127.0.0.1:2379"}}
+ if g := cl.Member(1).Attributes; !reflect.DeepEqual(g, w) {
+ t.Errorf("attributes = %v, want %v", g, w)
+ }
+}
+
+func TestApplyConfChangeError(t *testing.T) {
+ cl := membership.NewCluster("")
+ cl.SetStore(store.New())
+ for i := 1; i <= 4; i++ {
+ cl.AddMember(&membership.Member{ID: types.ID(i)})
+ }
+ cl.RemoveMember(4)
+
+ tests := []struct {
+ cc raftpb.ConfChange
+ werr error
+ }{
+ {
+ raftpb.ConfChange{
+ Type: raftpb.ConfChangeAddNode,
+ NodeID: 4,
+ },
+ membership.ErrIDRemoved,
+ },
+ {
+ raftpb.ConfChange{
+ Type: raftpb.ConfChangeUpdateNode,
+ NodeID: 4,
+ },
+ membership.ErrIDRemoved,
+ },
+ {
+ raftpb.ConfChange{
+ Type: raftpb.ConfChangeAddNode,
+ NodeID: 1,
+ },
+ membership.ErrIDExists,
+ },
+ {
+ raftpb.ConfChange{
+ Type: raftpb.ConfChangeRemoveNode,
+ NodeID: 5,
+ },
+ membership.ErrIDNotFound,
+ },
+ }
+ for i, tt := range tests {
+ n := newNodeRecorder()
+ srv := &EtcdServer{
+ r: *newRaftNode(raftNodeConfig{Node: n}),
+ cluster: cl,
+ Cfg: &ServerConfig{},
+ }
+ _, err := srv.applyConfChange(tt.cc, nil)
+ if err != tt.werr {
+ t.Errorf("#%d: applyConfChange error = %v, want %v", i, err, tt.werr)
+ }
+ cc := raftpb.ConfChange{Type: tt.cc.Type, NodeID: raft.None}
+ w := []testutil.Action{
+ {
+ Name: "ApplyConfChange",
+ Params: []interface{}{cc},
+ },
+ }
+ if g, _ := n.Wait(1); !reflect.DeepEqual(g, w) {
+ t.Errorf("#%d: action = %+v, want %+v", i, g, w)
+ }
+ }
+}
+
+func TestApplyConfChangeShouldStop(t *testing.T) {
+ cl := membership.NewCluster("")
+ cl.SetStore(store.New())
+ for i := 1; i <= 3; i++ {
+ cl.AddMember(&membership.Member{ID: types.ID(i)})
+ }
+ r := newRaftNode(raftNodeConfig{
+ Node: newNodeNop(),
+ transport: rafthttp.NewNopTransporter(),
+ })
+ srv := &EtcdServer{
+ id: 1,
+ r: *r,
+ cluster: cl,
+ }
+ cc := raftpb.ConfChange{
+ Type: raftpb.ConfChangeRemoveNode,
+ NodeID: 2,
+ }
+ // remove non-local member
+ shouldStop, err := srv.applyConfChange(cc, &raftpb.ConfState{})
+ if err != nil {
+ t.Fatalf("unexpected error %v", err)
+ }
+ if shouldStop {
+ t.Errorf("shouldStop = %t, want %t", shouldStop, false)
+ }
+
+ // remove local member
+ cc.NodeID = 1
+ shouldStop, err = srv.applyConfChange(cc, &raftpb.ConfState{})
+ if err != nil {
+ t.Fatalf("unexpected error %v", err)
+ }
+ if !shouldStop {
+ t.Errorf("shouldStop = %t, want %t", shouldStop, true)
+ }
+}
+
+// TestApplyConfigChangeUpdatesConsistIndex ensures a config change also updates the consistIndex
+// where consistIndex equals to applied index.
+func TestApplyConfigChangeUpdatesConsistIndex(t *testing.T) {
+ cl := membership.NewCluster("")
+ cl.SetStore(store.New())
+ cl.AddMember(&membership.Member{ID: types.ID(1)})
+ r := newRaftNode(raftNodeConfig{
+ Node: newNodeNop(),
+ transport: rafthttp.NewNopTransporter(),
+ })
+ srv := &EtcdServer{
+ id: 1,
+ r: *r,
+ cluster: cl,
+ w: wait.New(),
+ }
+
+ // create EntryConfChange entry
+ now := time.Now()
+ urls, err := types.NewURLs([]string{"http://whatever:123"})
+ if err != nil {
+ t.Fatal(err)
+ }
+ m := membership.NewMember("", urls, "", &now)
+ m.ID = types.ID(2)
+ b, err := json.Marshal(m)
+ if err != nil {
+ t.Fatal(err)
+ }
+ cc := &raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 2, Context: b}
+ ents := []raftpb.Entry{{
+ Index: 2,
+ Type: raftpb.EntryConfChange,
+ Data: pbutil.MustMarshal(cc),
+ }}
+
+ _, appliedi, _ := srv.apply(ents, &raftpb.ConfState{})
+ consistIndex := srv.consistIndex.ConsistentIndex()
+ if consistIndex != appliedi {
+ t.Fatalf("consistIndex = %v, want %v", consistIndex, appliedi)
+ }
+}
+
+// TestApplyMultiConfChangeShouldStop ensures that apply will return shouldStop
+// if the local member is removed along with other conf updates.
+func TestApplyMultiConfChangeShouldStop(t *testing.T) {
+ cl := membership.NewCluster("")
+ cl.SetStore(store.New())
+ for i := 1; i <= 5; i++ {
+ cl.AddMember(&membership.Member{ID: types.ID(i)})
+ }
+ r := newRaftNode(raftNodeConfig{
+ Node: newNodeNop(),
+ transport: rafthttp.NewNopTransporter(),
+ })
+ srv := &EtcdServer{
+ id: 2,
+ r: *r,
+ cluster: cl,
+ w: wait.New(),
+ }
+ ents := []raftpb.Entry{}
+ for i := 1; i <= 4; i++ {
+ ent := raftpb.Entry{
+ Term: 1,
+ Index: uint64(i),
+ Type: raftpb.EntryConfChange,
+ Data: pbutil.MustMarshal(
+ &raftpb.ConfChange{
+ Type: raftpb.ConfChangeRemoveNode,
+ NodeID: uint64(i)}),
+ }
+ ents = append(ents, ent)
+ }
+
+ _, _, shouldStop := srv.apply(ents, &raftpb.ConfState{})
+ if !shouldStop {
+ t.Errorf("shouldStop = %t, want %t", shouldStop, true)
+ }
+}
+
+func TestDoProposal(t *testing.T) {
+ tests := []pb.Request{
+ {Method: "POST", ID: 1},
+ {Method: "PUT", ID: 1},
+ {Method: "DELETE", ID: 1},
+ {Method: "GET", ID: 1, Quorum: true},
+ }
+ for i, tt := range tests {
+ st := mockstore.NewRecorder()
+ r := newRaftNode(raftNodeConfig{
+ Node: newNodeCommitter(),
+ storage: mockstorage.NewStorageRecorder(""),
+ raftStorage: raft.NewMemoryStorage(),
+ transport: rafthttp.NewNopTransporter(),
+ })
+ srv := &EtcdServer{
+ Cfg: &ServerConfig{TickMs: 1},
+ r: *r,
+ store: st,
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ SyncTicker: &time.Ticker{},
+ }
+ srv.applyV2 = &applierV2store{store: srv.store, cluster: srv.cluster}
+ srv.start()
+ resp, err := srv.Do(context.Background(), tt)
+ srv.Stop()
+
+ action := st.Action()
+ if len(action) != 1 {
+ t.Errorf("#%d: len(action) = %d, want 1", i, len(action))
+ }
+ if err != nil {
+ t.Fatalf("#%d: err = %v, want nil", i, err)
+ }
+ wresp := Response{Event: &store.Event{}}
+ if !reflect.DeepEqual(resp, wresp) {
+ t.Errorf("#%d: resp = %v, want %v", i, resp, wresp)
+ }
+ }
+}
+
+func TestDoProposalCancelled(t *testing.T) {
+ wt := mockwait.NewRecorder()
+ srv := &EtcdServer{
+ Cfg: &ServerConfig{TickMs: 1},
+ r: *newRaftNode(raftNodeConfig{Node: newNodeNop()}),
+ w: wt,
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ }
+ srv.applyV2 = &applierV2store{store: srv.store, cluster: srv.cluster}
+
+ ctx, cancel := context.WithCancel(context.Background())
+ cancel()
+ _, err := srv.Do(ctx, pb.Request{Method: "PUT"})
+
+ if err != ErrCanceled {
+ t.Fatalf("err = %v, want %v", err, ErrCanceled)
+ }
+ w := []testutil.Action{{Name: "Register"}, {Name: "Trigger"}}
+ if !reflect.DeepEqual(wt.Action(), w) {
+ t.Errorf("wt.action = %+v, want %+v", wt.Action(), w)
+ }
+}
+
+func TestDoProposalTimeout(t *testing.T) {
+ srv := &EtcdServer{
+ Cfg: &ServerConfig{TickMs: 1},
+ r: *newRaftNode(raftNodeConfig{Node: newNodeNop()}),
+ w: mockwait.NewNop(),
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ }
+ srv.applyV2 = &applierV2store{store: srv.store, cluster: srv.cluster}
+
+ ctx, _ := context.WithTimeout(context.Background(), 0)
+ _, err := srv.Do(ctx, pb.Request{Method: "PUT"})
+ if err != ErrTimeout {
+ t.Fatalf("err = %v, want %v", err, ErrTimeout)
+ }
+}
+
+func TestDoProposalStopped(t *testing.T) {
+ srv := &EtcdServer{
+ Cfg: &ServerConfig{TickMs: 1},
+ r: *newRaftNode(raftNodeConfig{Node: newNodeNop()}),
+ w: mockwait.NewNop(),
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ }
+ srv.applyV2 = &applierV2store{store: srv.store, cluster: srv.cluster}
+
+ srv.stopping = make(chan struct{})
+ close(srv.stopping)
+ _, err := srv.Do(context.Background(), pb.Request{Method: "PUT", ID: 1})
+ if err != ErrStopped {
+ t.Errorf("err = %v, want %v", err, ErrStopped)
+ }
+}
+
+// TestSync tests sync 1. is nonblocking 2. proposes SYNC request.
+func TestSync(t *testing.T) {
+ n := newNodeRecorder()
+ ctx, cancel := context.WithCancel(context.TODO())
+ srv := &EtcdServer{
+ r: *newRaftNode(raftNodeConfig{Node: n}),
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ ctx: ctx,
+ cancel: cancel,
+ }
+ srv.applyV2 = &applierV2store{store: srv.store, cluster: srv.cluster}
+
+ // check that sync is non-blocking
+ done := make(chan struct{})
+ go func() {
+ srv.sync(10 * time.Second)
+ done <- struct{}{}
+ }()
+
+ select {
+ case <-done:
+ case <-time.After(time.Second):
+ t.Fatal("sync should be non-blocking but did not return after 1s!")
+ }
+
+ action, _ := n.Wait(1)
+ if len(action) != 1 {
+ t.Fatalf("len(action) = %d, want 1", len(action))
+ }
+ if action[0].Name != "Propose" {
+ t.Fatalf("action = %s, want Propose", action[0].Name)
+ }
+ data := action[0].Params[0].([]byte)
+ var r pb.Request
+ if err := r.Unmarshal(data); err != nil {
+ t.Fatalf("unmarshal request error: %v", err)
+ }
+ if r.Method != "SYNC" {
+ t.Errorf("method = %s, want SYNC", r.Method)
+ }
+}
+
+// TestSyncTimeout tests the case that sync 1. is non-blocking 2. cancel request
+// after timeout
+func TestSyncTimeout(t *testing.T) {
+ n := newProposalBlockerRecorder()
+ ctx, cancel := context.WithCancel(context.TODO())
+ srv := &EtcdServer{
+ r: *newRaftNode(raftNodeConfig{Node: n}),
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ ctx: ctx,
+ cancel: cancel,
+ }
+ srv.applyV2 = &applierV2store{store: srv.store, cluster: srv.cluster}
+
+ // check that sync is non-blocking
+ done := make(chan struct{})
+ go func() {
+ srv.sync(0)
+ done <- struct{}{}
+ }()
+
+ select {
+ case <-done:
+ case <-time.After(time.Second):
+ t.Fatal("sync should be non-blocking but did not return after 1s!")
+ }
+
+ w := []testutil.Action{{Name: "Propose blocked"}}
+ if g, _ := n.Wait(1); !reflect.DeepEqual(g, w) {
+ t.Errorf("action = %v, want %v", g, w)
+ }
+}
+
+// TODO: TestNoSyncWhenNoLeader
+
+// TestSyncTrigger tests that the server proposes a SYNC request when its sync timer ticks
+func TestSyncTrigger(t *testing.T) {
+ n := newReadyNode()
+ st := make(chan time.Time, 1)
+ tk := &time.Ticker{C: st}
+ r := newRaftNode(raftNodeConfig{
+ Node: n,
+ raftStorage: raft.NewMemoryStorage(),
+ transport: rafthttp.NewNopTransporter(),
+ storage: mockstorage.NewStorageRecorder(""),
+ })
+
+ srv := &EtcdServer{
+ Cfg: &ServerConfig{TickMs: 1},
+ r: *r,
+ store: mockstore.NewNop(),
+ SyncTicker: tk,
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ }
+
+ // trigger the server to become a leader and accept sync requests
+ go func() {
+ srv.start()
+ n.readyc <- raft.Ready{
+ SoftState: &raft.SoftState{
+ RaftState: raft.StateLeader,
+ },
+ }
+ // trigger a sync request
+ st <- time.Time{}
+ }()
+
+ action, _ := n.Wait(1)
+ go srv.Stop()
+
+ if len(action) != 1 {
+ t.Fatalf("len(action) = %d, want 1", len(action))
+ }
+ if action[0].Name != "Propose" {
+ t.Fatalf("action = %s, want Propose", action[0].Name)
+ }
+ data := action[0].Params[0].([]byte)
+ var req pb.Request
+ if err := req.Unmarshal(data); err != nil {
+ t.Fatalf("error unmarshalling data: %v", err)
+ }
+ if req.Method != "SYNC" {
+ t.Fatalf("unexpected proposed request: %#v", req.Method)
+ }
+
+ // wait on stop message
+ <-n.Chan()
+}
+
+// snapshot should snapshot the store and cut the persistent
+func TestSnapshot(t *testing.T) {
+ be, tmpPath := backend.NewDefaultTmpBackend()
+ defer func() {
+ os.RemoveAll(tmpPath)
+ }()
+
+ s := raft.NewMemoryStorage()
+ s.Append([]raftpb.Entry{{Index: 1}})
+ st := mockstore.NewRecorderStream()
+ p := mockstorage.NewStorageRecorderStream("")
+ r := newRaftNode(raftNodeConfig{
+ Node: newNodeNop(),
+ raftStorage: s,
+ storage: p,
+ })
+ srv := &EtcdServer{
+ Cfg: &ServerConfig{},
+ r: *r,
+ store: st,
+ }
+ srv.kv = mvcc.New(be, &lease.FakeLessor{}, &srv.consistIndex)
+ srv.be = be
+
+ ch := make(chan struct{}, 2)
+
+ go func() {
+ gaction, _ := p.Wait(1)
+ defer func() { ch <- struct{}{} }()
+
+ if len(gaction) != 1 {
+ t.Fatalf("len(action) = %d, want 1", len(gaction))
+ }
+ if !reflect.DeepEqual(gaction[0], testutil.Action{Name: "SaveSnap"}) {
+ t.Errorf("action = %s, want SaveSnap", gaction[0])
+ }
+ }()
+
+ go func() {
+ gaction, _ := st.Wait(2)
+ defer func() { ch <- struct{}{} }()
+
+ if len(gaction) != 2 {
+ t.Fatalf("len(action) = %d, want 2", len(gaction))
+ }
+ if !reflect.DeepEqual(gaction[0], testutil.Action{Name: "Clone"}) {
+ t.Errorf("action = %s, want Clone", gaction[0])
+ }
+ if !reflect.DeepEqual(gaction[1], testutil.Action{Name: "SaveNoCopy"}) {
+ t.Errorf("action = %s, want SaveNoCopy", gaction[1])
+ }
+ }()
+
+ srv.snapshot(1, raftpb.ConfState{Nodes: []uint64{1}})
+ <-ch
+ <-ch
+}
+
+// TestSnapshotOrdering ensures raft persists snapshot onto disk before
+// snapshot db is applied.
+func TestSnapshotOrdering(t *testing.T) {
+ n := newNopReadyNode()
+ st := store.New()
+ cl := membership.NewCluster("abc")
+ cl.SetStore(st)
+
+ testdir, err := ioutil.TempDir(os.TempDir(), "testsnapdir")
+ if err != nil {
+ t.Fatalf("couldn't open tempdir (%v)", err)
+ }
+ defer os.RemoveAll(testdir)
+
+ snapdir := filepath.Join(testdir, "member", "snap")
+ if err := os.MkdirAll(snapdir, 0755); err != nil {
+ t.Fatalf("couldn't make snap dir (%v)", err)
+ }
+
+ rs := raft.NewMemoryStorage()
+ p := mockstorage.NewStorageRecorderStream(testdir)
+ tr, snapDoneC := rafthttp.NewSnapTransporter(snapdir)
+ r := newRaftNode(raftNodeConfig{
+ isIDRemoved: func(id uint64) bool { return cl.IsIDRemoved(types.ID(id)) },
+ Node: n,
+ transport: tr,
+ storage: p,
+ raftStorage: rs,
+ })
+ s := &EtcdServer{
+ Cfg: &ServerConfig{
+ DataDir: testdir,
+ },
+ r: *r,
+ store: st,
+ snapshotter: snap.New(snapdir),
+ cluster: cl,
+ SyncTicker: &time.Ticker{},
+ }
+ s.applyV2 = &applierV2store{store: s.store, cluster: s.cluster}
+
+ be, tmpPath := backend.NewDefaultTmpBackend()
+ defer os.RemoveAll(tmpPath)
+ s.kv = mvcc.New(be, &lease.FakeLessor{}, &s.consistIndex)
+ s.be = be
+
+ s.start()
+ defer s.Stop()
+
+ n.readyc <- raft.Ready{Messages: []raftpb.Message{{Type: raftpb.MsgSnap}}}
+ go func() {
+ // get the snapshot sent by the transport
+ snapMsg := <-snapDoneC
+ // Snapshot first triggers raftnode to persists the snapshot onto disk
+ // before renaming db snapshot file to db
+ snapMsg.Snapshot.Metadata.Index = 1
+ n.readyc <- raft.Ready{Snapshot: snapMsg.Snapshot}
+ }()
+
+ if ac := <-p.Chan(); ac.Name != "Save" {
+ t.Fatalf("expected Save, got %+v", ac)
+ }
+ if ac := <-p.Chan(); ac.Name != "Save" {
+ t.Fatalf("expected Save, got %+v", ac)
+ }
+ // confirm snapshot file still present before calling SaveSnap
+ snapPath := filepath.Join(snapdir, fmt.Sprintf("%016x.snap.db", 1))
+ if !fileutil.Exist(snapPath) {
+ t.Fatalf("expected file %q, got missing", snapPath)
+ }
+ // unblock SaveSnapshot, etcdserver now permitted to move snapshot file
+ if ac := <-p.Chan(); ac.Name != "SaveSnap" {
+ t.Fatalf("expected SaveSnap, got %+v", ac)
+ }
+}
+
+// Applied > SnapCount should trigger a SaveSnap event
+func TestTriggerSnap(t *testing.T) {
+ be, tmpPath := backend.NewDefaultTmpBackend()
+ defer func() {
+ os.RemoveAll(tmpPath)
+ }()
+
+ snapc := 10
+ st := mockstore.NewRecorder()
+ p := mockstorage.NewStorageRecorderStream("")
+ r := newRaftNode(raftNodeConfig{
+ Node: newNodeCommitter(),
+ raftStorage: raft.NewMemoryStorage(),
+ storage: p,
+ transport: rafthttp.NewNopTransporter(),
+ })
+ srv := &EtcdServer{
+ Cfg: &ServerConfig{TickMs: 1},
+ snapCount: uint64(snapc),
+ r: *r,
+ store: st,
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ SyncTicker: &time.Ticker{},
+ }
+ srv.applyV2 = &applierV2store{store: srv.store, cluster: srv.cluster}
+
+ srv.kv = mvcc.New(be, &lease.FakeLessor{}, &srv.consistIndex)
+ srv.be = be
+
+ srv.start()
+
+ donec := make(chan struct{})
+ go func() {
+ wcnt := 2 + snapc
+ gaction, _ := p.Wait(wcnt)
+
+ // each operation is recorded as a Save
+ // (SnapCount+1) * Puts + SaveSnap = (SnapCount+1) * Save + SaveSnap
+ if len(gaction) != wcnt {
+ t.Fatalf("len(action) = %d, want %d", len(gaction), wcnt)
+ }
+ if !reflect.DeepEqual(gaction[wcnt-1], testutil.Action{Name: "SaveSnap"}) {
+ t.Errorf("action = %s, want SaveSnap", gaction[wcnt-1])
+ }
+ close(donec)
+ }()
+
+ for i := 0; i < snapc+1; i++ {
+ srv.Do(context.Background(), pb.Request{Method: "PUT"})
+ }
+
+ <-donec
+ srv.Stop()
+}
+
+// TestConcurrentApplyAndSnapshotV3 will send out snapshots concurrently with
+// proposals.
+func TestConcurrentApplyAndSnapshotV3(t *testing.T) {
+ n := newNopReadyNode()
+ st := store.New()
+ cl := membership.NewCluster("abc")
+ cl.SetStore(st)
+
+ testdir, err := ioutil.TempDir(os.TempDir(), "testsnapdir")
+ if err != nil {
+ t.Fatalf("Couldn't open tempdir (%v)", err)
+ }
+ defer os.RemoveAll(testdir)
+ if err := os.MkdirAll(testdir+"/member/snap", 0755); err != nil {
+ t.Fatalf("Couldn't make snap dir (%v)", err)
+ }
+
+ rs := raft.NewMemoryStorage()
+ tr, snapDoneC := rafthttp.NewSnapTransporter(testdir)
+ r := newRaftNode(raftNodeConfig{
+ isIDRemoved: func(id uint64) bool { return cl.IsIDRemoved(types.ID(id)) },
+ Node: n,
+ transport: tr,
+ storage: mockstorage.NewStorageRecorder(testdir),
+ raftStorage: rs,
+ })
+ s := &EtcdServer{
+ Cfg: &ServerConfig{
+ DataDir: testdir,
+ },
+ r: *r,
+ store: st,
+ snapshotter: snap.New(testdir),
+ cluster: cl,
+ SyncTicker: &time.Ticker{},
+ }
+ s.applyV2 = &applierV2store{store: s.store, cluster: s.cluster}
+
+ be, tmpPath := backend.NewDefaultTmpBackend()
+ defer func() {
+ os.RemoveAll(tmpPath)
+ }()
+ s.kv = mvcc.New(be, &lease.FakeLessor{}, &s.consistIndex)
+ s.be = be
+
+ s.start()
+ defer s.Stop()
+
+ // submit applied entries and snap entries
+ idx := uint64(0)
+ outdated := 0
+ accepted := 0
+ for k := 1; k <= 101; k++ {
+ idx++
+ ch := s.w.Register(uint64(idx))
+ req := &pb.Request{Method: "QGET", ID: uint64(idx)}
+ ent := raftpb.Entry{Index: uint64(idx), Data: pbutil.MustMarshal(req)}
+ ready := raft.Ready{Entries: []raftpb.Entry{ent}}
+ n.readyc <- ready
+
+ ready = raft.Ready{CommittedEntries: []raftpb.Entry{ent}}
+ n.readyc <- ready
+
+ // "idx" applied
+ <-ch
+
+ // one snapshot for every two messages
+ if k%2 != 0 {
+ continue
+ }
+
+ n.readyc <- raft.Ready{Messages: []raftpb.Message{{Type: raftpb.MsgSnap}}}
+ // get the snapshot sent by the transport
+ snapMsg := <-snapDoneC
+ // If the snapshot trails applied records, recovery will panic
+ // since there's no allocated snapshot at the place of the
+ // snapshot record. This only happens when the applier and the
+ // snapshot sender get out of sync.
+ if snapMsg.Snapshot.Metadata.Index == idx {
+ idx++
+ snapMsg.Snapshot.Metadata.Index = idx
+ ready = raft.Ready{Snapshot: snapMsg.Snapshot}
+ n.readyc <- ready
+ accepted++
+ } else {
+ outdated++
+ }
+ // don't wait for the snapshot to complete, move to next message
+ }
+ if accepted != 50 {
+ t.Errorf("accepted=%v, want 50", accepted)
+ }
+ if outdated != 0 {
+ t.Errorf("outdated=%v, want 0", outdated)
+ }
+}
+
+// TestAddMember tests AddMember can propose and perform node addition.
+func TestAddMember(t *testing.T) {
+ n := newNodeConfChangeCommitterRecorder()
+ n.readyc <- raft.Ready{
+ SoftState: &raft.SoftState{RaftState: raft.StateLeader},
+ }
+ cl := newTestCluster(nil)
+ st := store.New()
+ cl.SetStore(st)
+ r := newRaftNode(raftNodeConfig{
+ Node: n,
+ raftStorage: raft.NewMemoryStorage(),
+ storage: mockstorage.NewStorageRecorder(""),
+ transport: rafthttp.NewNopTransporter(),
+ })
+ s := &EtcdServer{
+ r: *r,
+ Cfg: &ServerConfig{},
+ store: st,
+ cluster: cl,
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ SyncTicker: &time.Ticker{},
+ }
+ s.start()
+ m := membership.Member{ID: 1234, RaftAttributes: membership.RaftAttributes{PeerURLs: []string{"foo"}}}
+ _, err := s.AddMember(context.TODO(), m)
+ gaction := n.Action()
+ s.Stop()
+
+ if err != nil {
+ t.Fatalf("AddMember error: %v", err)
+ }
+ wactions := []testutil.Action{{Name: "ProposeConfChange:ConfChangeAddNode"}, {Name: "ApplyConfChange:ConfChangeAddNode"}}
+ if !reflect.DeepEqual(gaction, wactions) {
+ t.Errorf("action = %v, want %v", gaction, wactions)
+ }
+ if cl.Member(1234) == nil {
+ t.Errorf("member with id 1234 is not added")
+ }
+}
+
+// TestRemoveMember tests RemoveMember can propose and perform node removal.
+func TestRemoveMember(t *testing.T) {
+ n := newNodeConfChangeCommitterRecorder()
+ n.readyc <- raft.Ready{
+ SoftState: &raft.SoftState{RaftState: raft.StateLeader},
+ }
+ cl := newTestCluster(nil)
+ st := store.New()
+ cl.SetStore(store.New())
+ cl.AddMember(&membership.Member{ID: 1234})
+ r := newRaftNode(raftNodeConfig{
+ Node: n,
+ raftStorage: raft.NewMemoryStorage(),
+ storage: mockstorage.NewStorageRecorder(""),
+ transport: rafthttp.NewNopTransporter(),
+ })
+ s := &EtcdServer{
+ r: *r,
+ Cfg: &ServerConfig{},
+ store: st,
+ cluster: cl,
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ SyncTicker: &time.Ticker{},
+ }
+ s.start()
+ _, err := s.RemoveMember(context.TODO(), 1234)
+ gaction := n.Action()
+ s.Stop()
+
+ if err != nil {
+ t.Fatalf("RemoveMember error: %v", err)
+ }
+ wactions := []testutil.Action{{Name: "ProposeConfChange:ConfChangeRemoveNode"}, {Name: "ApplyConfChange:ConfChangeRemoveNode"}}
+ if !reflect.DeepEqual(gaction, wactions) {
+ t.Errorf("action = %v, want %v", gaction, wactions)
+ }
+ if cl.Member(1234) != nil {
+ t.Errorf("member with id 1234 is not removed")
+ }
+}
+
+// TestUpdateMember tests RemoveMember can propose and perform node update.
+func TestUpdateMember(t *testing.T) {
+ n := newNodeConfChangeCommitterRecorder()
+ n.readyc <- raft.Ready{
+ SoftState: &raft.SoftState{RaftState: raft.StateLeader},
+ }
+ cl := newTestCluster(nil)
+ st := store.New()
+ cl.SetStore(st)
+ cl.AddMember(&membership.Member{ID: 1234})
+ r := newRaftNode(raftNodeConfig{
+ Node: n,
+ raftStorage: raft.NewMemoryStorage(),
+ storage: mockstorage.NewStorageRecorder(""),
+ transport: rafthttp.NewNopTransporter(),
+ })
+ s := &EtcdServer{
+ r: *r,
+ store: st,
+ cluster: cl,
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ SyncTicker: &time.Ticker{},
+ }
+ s.start()
+ wm := membership.Member{ID: 1234, RaftAttributes: membership.RaftAttributes{PeerURLs: []string{"http://127.0.0.1:1"}}}
+ _, err := s.UpdateMember(context.TODO(), wm)
+ gaction := n.Action()
+ s.Stop()
+
+ if err != nil {
+ t.Fatalf("UpdateMember error: %v", err)
+ }
+ wactions := []testutil.Action{{Name: "ProposeConfChange:ConfChangeUpdateNode"}, {Name: "ApplyConfChange:ConfChangeUpdateNode"}}
+ if !reflect.DeepEqual(gaction, wactions) {
+ t.Errorf("action = %v, want %v", gaction, wactions)
+ }
+ if !reflect.DeepEqual(cl.Member(1234), &wm) {
+ t.Errorf("member = %v, want %v", cl.Member(1234), &wm)
+ }
+}
+
+// TODO: test server could stop itself when being removed
+
+func TestPublish(t *testing.T) {
+ n := newNodeRecorder()
+ ch := make(chan interface{}, 1)
+ // simulate that request has gone through consensus
+ ch <- Response{}
+ w := wait.NewWithResponse(ch)
+ ctx, cancel := context.WithCancel(context.TODO())
+ srv := &EtcdServer{
+ readych: make(chan struct{}),
+ Cfg: &ServerConfig{TickMs: 1},
+ id: 1,
+ r: *newRaftNode(raftNodeConfig{Node: n}),
+ attributes: membership.Attributes{Name: "node1", ClientURLs: []string{"http://a", "http://b"}},
+ cluster: &membership.RaftCluster{},
+ w: w,
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ SyncTicker: &time.Ticker{},
+
+ ctx: ctx,
+ cancel: cancel,
+ }
+ srv.publish(time.Hour)
+
+ action := n.Action()
+ if len(action) != 1 {
+ t.Fatalf("len(action) = %d, want 1", len(action))
+ }
+ if action[0].Name != "Propose" {
+ t.Fatalf("action = %s, want Propose", action[0].Name)
+ }
+ data := action[0].Params[0].([]byte)
+ var r pb.Request
+ if err := r.Unmarshal(data); err != nil {
+ t.Fatalf("unmarshal request error: %v", err)
+ }
+ if r.Method != "PUT" {
+ t.Errorf("method = %s, want PUT", r.Method)
+ }
+ wm := membership.Member{ID: 1, Attributes: membership.Attributes{Name: "node1", ClientURLs: []string{"http://a", "http://b"}}}
+ if wpath := membership.MemberAttributesStorePath(wm.ID); r.Path != wpath {
+ t.Errorf("path = %s, want %s", r.Path, wpath)
+ }
+ var gattr membership.Attributes
+ if err := json.Unmarshal([]byte(r.Val), &gattr); err != nil {
+ t.Fatalf("unmarshal val error: %v", err)
+ }
+ if !reflect.DeepEqual(gattr, wm.Attributes) {
+ t.Errorf("member = %v, want %v", gattr, wm.Attributes)
+ }
+}
+
+// TestPublishStopped tests that publish will be stopped if server is stopped.
+func TestPublishStopped(t *testing.T) {
+ ctx, cancel := context.WithCancel(context.TODO())
+ r := newRaftNode(raftNodeConfig{
+ Node: newNodeNop(),
+ transport: rafthttp.NewNopTransporter(),
+ })
+ srv := &EtcdServer{
+ Cfg: &ServerConfig{TickMs: 1},
+ r: *r,
+ cluster: &membership.RaftCluster{},
+ w: mockwait.NewNop(),
+ done: make(chan struct{}),
+ stopping: make(chan struct{}),
+ stop: make(chan struct{}),
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ SyncTicker: &time.Ticker{},
+
+ ctx: ctx,
+ cancel: cancel,
+ }
+ close(srv.stopping)
+ srv.publish(time.Hour)
+}
+
+// TestPublishRetry tests that publish will keep retry until success.
+func TestPublishRetry(t *testing.T) {
+ ctx, cancel := context.WithCancel(context.TODO())
+ n := newNodeRecorderStream()
+ srv := &EtcdServer{
+ Cfg: &ServerConfig{TickMs: 1},
+ r: *newRaftNode(raftNodeConfig{Node: n}),
+ w: mockwait.NewNop(),
+ stopping: make(chan struct{}),
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ SyncTicker: &time.Ticker{},
+ ctx: ctx,
+ cancel: cancel,
+ }
+ // expect multiple proposals from retrying
+ ch := make(chan struct{})
+ go func() {
+ defer close(ch)
+ if action, err := n.Wait(2); err != nil {
+ t.Errorf("len(action) = %d, want >= 2 (%v)", len(action), err)
+ }
+ close(srv.stopping)
+ // drain remaining actions, if any, so publish can terminate
+ for {
+ select {
+ case <-ch:
+ return
+ default:
+ n.Action()
+ }
+ }
+ }()
+ srv.publish(10 * time.Nanosecond)
+ ch <- struct{}{}
+ <-ch
+}
+
+func TestUpdateVersion(t *testing.T) {
+ n := newNodeRecorder()
+ ch := make(chan interface{}, 1)
+ // simulate that request has gone through consensus
+ ch <- Response{}
+ w := wait.NewWithResponse(ch)
+ ctx, cancel := context.WithCancel(context.TODO())
+ srv := &EtcdServer{
+ id: 1,
+ Cfg: &ServerConfig{TickMs: 1},
+ r: *newRaftNode(raftNodeConfig{Node: n}),
+ attributes: membership.Attributes{Name: "node1", ClientURLs: []string{"http://node1.com"}},
+ cluster: &membership.RaftCluster{},
+ w: w,
+ reqIDGen: idutil.NewGenerator(0, time.Time{}),
+ SyncTicker: &time.Ticker{},
+
+ ctx: ctx,
+ cancel: cancel,
+ }
+ srv.updateClusterVersion("2.0.0")
+
+ action := n.Action()
+ if len(action) != 1 {
+ t.Fatalf("len(action) = %d, want 1", len(action))
+ }
+ if action[0].Name != "Propose" {
+ t.Fatalf("action = %s, want Propose", action[0].Name)
+ }
+ data := action[0].Params[0].([]byte)
+ var r pb.Request
+ if err := r.Unmarshal(data); err != nil {
+ t.Fatalf("unmarshal request error: %v", err)
+ }
+ if r.Method != "PUT" {
+ t.Errorf("method = %s, want PUT", r.Method)
+ }
+ if wpath := path.Join(StoreClusterPrefix, "version"); r.Path != wpath {
+ t.Errorf("path = %s, want %s", r.Path, wpath)
+ }
+ if r.Val != "2.0.0" {
+ t.Errorf("val = %s, want %s", r.Val, "2.0.0")
+ }
+}
+
+func TestStopNotify(t *testing.T) {
+ s := &EtcdServer{
+ stop: make(chan struct{}),
+ done: make(chan struct{}),
+ }
+ go func() {
+ <-s.stop
+ close(s.done)
+ }()
+
+ notifier := s.StopNotify()
+ select {
+ case <-notifier:
+ t.Fatalf("received unexpected stop notification")
+ default:
+ }
+ s.Stop()
+ select {
+ case <-notifier:
+ default:
+ t.Fatalf("cannot receive stop notification")
+ }
+}
+
+func TestGetOtherPeerURLs(t *testing.T) {
+ tests := []struct {
+ membs []*membership.Member
+ wurls []string
+ }{
+ {
+ []*membership.Member{
+ membership.NewMember("1", types.MustNewURLs([]string{"http://10.0.0.1:1"}), "a", nil),
+ },
+ []string{},
+ },
+ {
+ []*membership.Member{
+ membership.NewMember("1", types.MustNewURLs([]string{"http://10.0.0.1:1"}), "a", nil),
+ membership.NewMember("2", types.MustNewURLs([]string{"http://10.0.0.2:2"}), "a", nil),
+ membership.NewMember("3", types.MustNewURLs([]string{"http://10.0.0.3:3"}), "a", nil),
+ },
+ []string{"http://10.0.0.2:2", "http://10.0.0.3:3"},
+ },
+ {
+ []*membership.Member{
+ membership.NewMember("1", types.MustNewURLs([]string{"http://10.0.0.1:1"}), "a", nil),
+ membership.NewMember("3", types.MustNewURLs([]string{"http://10.0.0.3:3"}), "a", nil),
+ membership.NewMember("2", types.MustNewURLs([]string{"http://10.0.0.2:2"}), "a", nil),
+ },
+ []string{"http://10.0.0.2:2", "http://10.0.0.3:3"},
+ },
+ }
+ for i, tt := range tests {
+ cl := membership.NewClusterFromMembers("", types.ID(0), tt.membs)
+ self := "1"
+ urls := getRemotePeerURLs(cl, self)
+ if !reflect.DeepEqual(urls, tt.wurls) {
+ t.Errorf("#%d: urls = %+v, want %+v", i, urls, tt.wurls)
+ }
+ }
+}
+
+type nodeRecorder struct{ testutil.Recorder }
+
+func newNodeRecorder() *nodeRecorder { return &nodeRecorder{&testutil.RecorderBuffered{}} }
+func newNodeRecorderStream() *nodeRecorder { return &nodeRecorder{testutil.NewRecorderStream()} }
+func newNodeNop() raft.Node { return newNodeRecorder() }
+
+func (n *nodeRecorder) Tick() { n.Record(testutil.Action{Name: "Tick"}) }
+func (n *nodeRecorder) Campaign(ctx context.Context) error {
+ n.Record(testutil.Action{Name: "Campaign"})
+ return nil
+}
+func (n *nodeRecorder) Propose(ctx context.Context, data []byte) error {
+ n.Record(testutil.Action{Name: "Propose", Params: []interface{}{data}})
+ return nil
+}
+func (n *nodeRecorder) ProposeConfChange(ctx context.Context, conf raftpb.ConfChange) error {
+ n.Record(testutil.Action{Name: "ProposeConfChange"})
+ return nil
+}
+func (n *nodeRecorder) Step(ctx context.Context, msg raftpb.Message) error {
+ n.Record(testutil.Action{Name: "Step"})
+ return nil
+}
+func (n *nodeRecorder) Status() raft.Status { return raft.Status{} }
+func (n *nodeRecorder) Ready() <-chan raft.Ready { return nil }
+func (n *nodeRecorder) TransferLeadership(ctx context.Context, lead, transferee uint64) {}
+func (n *nodeRecorder) ReadIndex(ctx context.Context, rctx []byte) error { return nil }
+func (n *nodeRecorder) Advance() {}
+func (n *nodeRecorder) ApplyConfChange(conf raftpb.ConfChange) *raftpb.ConfState {
+ n.Record(testutil.Action{Name: "ApplyConfChange", Params: []interface{}{conf}})
+ return &raftpb.ConfState{}
+}
+
+func (n *nodeRecorder) Stop() {
+ n.Record(testutil.Action{Name: "Stop"})
+}
+
+func (n *nodeRecorder) ReportUnreachable(id uint64) {}
+
+func (n *nodeRecorder) ReportSnapshot(id uint64, status raft.SnapshotStatus) {}
+
+func (n *nodeRecorder) Compact(index uint64, nodes []uint64, d []byte) {
+ n.Record(testutil.Action{Name: "Compact"})
+}
+
+type nodeProposalBlockerRecorder struct {
+ nodeRecorder
+}
+
+func newProposalBlockerRecorder() *nodeProposalBlockerRecorder {
+ return &nodeProposalBlockerRecorder{*newNodeRecorder()}
+}
+
+func (n *nodeProposalBlockerRecorder) Propose(ctx context.Context, data []byte) error {
+ <-ctx.Done()
+ n.Record(testutil.Action{Name: "Propose blocked"})
+ return nil
+}
+
+// readyNode is a nodeRecorder with a user-writeable ready channel
+type readyNode struct {
+ nodeRecorder
+ readyc chan raft.Ready
+}
+
+func newReadyNode() *readyNode {
+ return &readyNode{
+ nodeRecorder{testutil.NewRecorderStream()},
+ make(chan raft.Ready, 1)}
+}
+func newNopReadyNode() *readyNode {
+ return &readyNode{*newNodeRecorder(), make(chan raft.Ready, 1)}
+}
+
+func (n *readyNode) Ready() <-chan raft.Ready { return n.readyc }
+
+type nodeConfChangeCommitterRecorder struct {
+ readyNode
+ index uint64
+}
+
+func newNodeConfChangeCommitterRecorder() *nodeConfChangeCommitterRecorder {
+ return &nodeConfChangeCommitterRecorder{*newNopReadyNode(), 0}
+}
+
+func newNodeConfChangeCommitterStream() *nodeConfChangeCommitterRecorder {
+ return &nodeConfChangeCommitterRecorder{*newReadyNode(), 0}
+}
+
+func (n *nodeConfChangeCommitterRecorder) ProposeConfChange(ctx context.Context, conf raftpb.ConfChange) error {
+ data, err := conf.Marshal()
+ if err != nil {
+ return err
+ }
+ n.index++
+ n.Record(testutil.Action{Name: "ProposeConfChange:" + conf.Type.String()})
+ n.readyc <- raft.Ready{CommittedEntries: []raftpb.Entry{{Index: n.index, Type: raftpb.EntryConfChange, Data: data}}}
+ return nil
+}
+func (n *nodeConfChangeCommitterRecorder) Ready() <-chan raft.Ready {
+ return n.readyc
+}
+func (n *nodeConfChangeCommitterRecorder) ApplyConfChange(conf raftpb.ConfChange) *raftpb.ConfState {
+ n.Record(testutil.Action{Name: "ApplyConfChange:" + conf.Type.String()})
+ return &raftpb.ConfState{}
+}
+
+// nodeCommitter commits proposed data immediately.
+type nodeCommitter struct {
+ readyNode
+ index uint64
+}
+
+func newNodeCommitter() raft.Node {
+ return &nodeCommitter{*newNopReadyNode(), 0}
+}
+func (n *nodeCommitter) Propose(ctx context.Context, data []byte) error {
+ n.index++
+ ents := []raftpb.Entry{{Index: n.index, Data: data}}
+ n.readyc <- raft.Ready{
+ Entries: ents,
+ CommittedEntries: ents,
+ }
+ return nil
+}
+
+func newTestCluster(membs []*membership.Member) *membership.RaftCluster {
+ c := membership.NewCluster("")
+ for _, m := range membs {
+ c.AddMember(m)
+ }
+ return c
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/snapshot_merge.go b/vendor/github.com/coreos/etcd/etcdserver/snapshot_merge.go
new file mode 100644
index 00000000..928aa95b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/snapshot_merge.go
@@ -0,0 +1,73 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "io"
+
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/snap"
+)
+
+// createMergedSnapshotMessage creates a snapshot message that contains: raft status (term, conf),
+// a snapshot of v2 store inside raft.Snapshot as []byte, a snapshot of v3 KV in the top level message
+// as ReadCloser.
+func (s *EtcdServer) createMergedSnapshotMessage(m raftpb.Message, snapt, snapi uint64, confState raftpb.ConfState) snap.Message {
+ // get a snapshot of v2 store as []byte
+ clone := s.store.Clone()
+ d, err := clone.SaveNoCopy()
+ if err != nil {
+ plog.Panicf("store save should never fail: %v", err)
+ }
+
+ // commit kv to write metadata(for example: consistent index).
+ s.KV().Commit()
+ dbsnap := s.be.Snapshot()
+ // get a snapshot of v3 KV as readCloser
+ rc := newSnapshotReaderCloser(dbsnap)
+
+ // put the []byte snapshot of store into raft snapshot and return the merged snapshot with
+ // KV readCloser snapshot.
+ snapshot := raftpb.Snapshot{
+ Metadata: raftpb.SnapshotMetadata{
+ Index: snapi,
+ Term: snapt,
+ ConfState: confState,
+ },
+ Data: d,
+ }
+ m.Snapshot = snapshot
+
+ return *snap.NewMessage(m, rc, dbsnap.Size())
+}
+
+func newSnapshotReaderCloser(snapshot backend.Snapshot) io.ReadCloser {
+ pr, pw := io.Pipe()
+ go func() {
+ n, err := snapshot.WriteTo(pw)
+ if err == nil {
+ plog.Infof("wrote database snapshot out [total bytes: %d]", n)
+ } else {
+ plog.Warningf("failed to write database snapshot out [written bytes: %d]: %v", n, err)
+ }
+ pw.CloseWithError(err)
+ err = snapshot.Close()
+ if err != nil {
+ plog.Panicf("failed to close database snapshot: %v", err)
+ }
+ }()
+ return pr
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/stats/leader.go b/vendor/github.com/coreos/etcd/etcdserver/stats/leader.go
new file mode 100644
index 00000000..8f6a54ff
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/stats/leader.go
@@ -0,0 +1,128 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 stats
+
+import (
+ "encoding/json"
+ "math"
+ "sync"
+ "time"
+)
+
+// LeaderStats is used by the leader in an etcd cluster, and encapsulates
+// statistics about communication with its followers
+type LeaderStats struct {
+ leaderStats
+ sync.Mutex
+}
+
+type leaderStats struct {
+ // Leader is the ID of the leader in the etcd cluster.
+ // TODO(jonboulle): clarify that these are IDs, not names
+ Leader string `json:"leader"`
+ Followers map[string]*FollowerStats `json:"followers"`
+}
+
+// NewLeaderStats generates a new LeaderStats with the given id as leader
+func NewLeaderStats(id string) *LeaderStats {
+ return &LeaderStats{
+ leaderStats: leaderStats{
+ Leader: id,
+ Followers: make(map[string]*FollowerStats),
+ },
+ }
+}
+
+func (ls *LeaderStats) JSON() []byte {
+ ls.Lock()
+ stats := ls.leaderStats
+ ls.Unlock()
+ b, err := json.Marshal(stats)
+ // TODO(jonboulle): appropriate error handling?
+ if err != nil {
+ plog.Errorf("error marshalling leader stats (%v)", err)
+ }
+ return b
+}
+
+func (ls *LeaderStats) Follower(name string) *FollowerStats {
+ ls.Lock()
+ defer ls.Unlock()
+ fs, ok := ls.Followers[name]
+ if !ok {
+ fs = &FollowerStats{}
+ fs.Latency.Minimum = 1 << 63
+ ls.Followers[name] = fs
+ }
+ return fs
+}
+
+// FollowerStats encapsulates various statistics about a follower in an etcd cluster
+type FollowerStats struct {
+ Latency LatencyStats `json:"latency"`
+ Counts CountsStats `json:"counts"`
+
+ sync.Mutex
+}
+
+// LatencyStats encapsulates latency statistics.
+type LatencyStats struct {
+ Current float64 `json:"current"`
+ Average float64 `json:"average"`
+ averageSquare float64
+ StandardDeviation float64 `json:"standardDeviation"`
+ Minimum float64 `json:"minimum"`
+ Maximum float64 `json:"maximum"`
+}
+
+// CountsStats encapsulates raft statistics.
+type CountsStats struct {
+ Fail uint64 `json:"fail"`
+ Success uint64 `json:"success"`
+}
+
+// Succ updates the FollowerStats with a successful send
+func (fs *FollowerStats) Succ(d time.Duration) {
+ fs.Lock()
+ defer fs.Unlock()
+
+ total := float64(fs.Counts.Success) * fs.Latency.Average
+ totalSquare := float64(fs.Counts.Success) * fs.Latency.averageSquare
+
+ fs.Counts.Success++
+
+ fs.Latency.Current = float64(d) / (1000000.0)
+
+ if fs.Latency.Current > fs.Latency.Maximum {
+ fs.Latency.Maximum = fs.Latency.Current
+ }
+
+ if fs.Latency.Current < fs.Latency.Minimum {
+ fs.Latency.Minimum = fs.Latency.Current
+ }
+
+ fs.Latency.Average = (total + fs.Latency.Current) / float64(fs.Counts.Success)
+ fs.Latency.averageSquare = (totalSquare + fs.Latency.Current*fs.Latency.Current) / float64(fs.Counts.Success)
+
+ // sdv = sqrt(avg(x^2) - avg(x)^2)
+ fs.Latency.StandardDeviation = math.Sqrt(fs.Latency.averageSquare - fs.Latency.Average*fs.Latency.Average)
+}
+
+// Fail updates the FollowerStats with an unsuccessful send
+func (fs *FollowerStats) Fail() {
+ fs.Lock()
+ defer fs.Unlock()
+ fs.Counts.Fail++
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/stats/queue.go b/vendor/github.com/coreos/etcd/etcdserver/stats/queue.go
new file mode 100644
index 00000000..635074c4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/stats/queue.go
@@ -0,0 +1,110 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 stats
+
+import (
+ "sync"
+ "time"
+)
+
+const (
+ queueCapacity = 200
+)
+
+// RequestStats represent the stats for a request.
+// It encapsulates the sending time and the size of the request.
+type RequestStats struct {
+ SendingTime time.Time
+ Size int
+}
+
+type statsQueue struct {
+ items [queueCapacity]*RequestStats
+ size int
+ front int
+ back int
+ totalReqSize int
+ rwl sync.RWMutex
+}
+
+func (q *statsQueue) Len() int {
+ return q.size
+}
+
+func (q *statsQueue) ReqSize() int {
+ return q.totalReqSize
+}
+
+// FrontAndBack gets the front and back elements in the queue
+// We must grab front and back together with the protection of the lock
+func (q *statsQueue) frontAndBack() (*RequestStats, *RequestStats) {
+ q.rwl.RLock()
+ defer q.rwl.RUnlock()
+ if q.size != 0 {
+ return q.items[q.front], q.items[q.back]
+ }
+ return nil, nil
+}
+
+// Insert function insert a RequestStats into the queue and update the records
+func (q *statsQueue) Insert(p *RequestStats) {
+ q.rwl.Lock()
+ defer q.rwl.Unlock()
+
+ q.back = (q.back + 1) % queueCapacity
+
+ if q.size == queueCapacity { //dequeue
+ q.totalReqSize -= q.items[q.front].Size
+ q.front = (q.back + 1) % queueCapacity
+ } else {
+ q.size++
+ }
+
+ q.items[q.back] = p
+ q.totalReqSize += q.items[q.back].Size
+
+}
+
+// Rate function returns the package rate and byte rate
+func (q *statsQueue) Rate() (float64, float64) {
+ front, back := q.frontAndBack()
+
+ if front == nil || back == nil {
+ return 0, 0
+ }
+
+ if time.Since(back.SendingTime) > time.Second {
+ q.Clear()
+ return 0, 0
+ }
+
+ sampleDuration := back.SendingTime.Sub(front.SendingTime)
+
+ pr := float64(q.Len()) / float64(sampleDuration) * float64(time.Second)
+
+ br := float64(q.ReqSize()) / float64(sampleDuration) * float64(time.Second)
+
+ return pr, br
+}
+
+// Clear function clear up the statsQueue
+func (q *statsQueue) Clear() {
+ q.rwl.Lock()
+ defer q.rwl.Unlock()
+ q.back = -1
+ q.front = 0
+ q.size = 0
+ q.totalReqSize = 0
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/stats/server.go b/vendor/github.com/coreos/etcd/etcdserver/stats/server.go
new file mode 100644
index 00000000..0278e885
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/stats/server.go
@@ -0,0 +1,142 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 stats
+
+import (
+ "encoding/json"
+ "log"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/raft"
+)
+
+// ServerStats encapsulates various statistics about an EtcdServer and its
+// communication with other members of the cluster
+type ServerStats struct {
+ serverStats
+ sync.Mutex
+}
+
+func NewServerStats(name, id string) *ServerStats {
+ ss := &ServerStats{
+ serverStats: serverStats{
+ Name: name,
+ ID: id,
+ },
+ }
+ now := time.Now()
+ ss.StartTime = now
+ ss.LeaderInfo.StartTime = now
+ ss.sendRateQueue = &statsQueue{back: -1}
+ ss.recvRateQueue = &statsQueue{back: -1}
+ return ss
+}
+
+type serverStats struct {
+ Name string `json:"name"`
+ // ID is the raft ID of the node.
+ // TODO(jonboulle): use ID instead of name?
+ ID string `json:"id"`
+ State raft.StateType `json:"state"`
+ StartTime time.Time `json:"startTime"`
+
+ LeaderInfo struct {
+ Name string `json:"leader"`
+ Uptime string `json:"uptime"`
+ StartTime time.Time `json:"startTime"`
+ } `json:"leaderInfo"`
+
+ RecvAppendRequestCnt uint64 `json:"recvAppendRequestCnt,"`
+ RecvingPkgRate float64 `json:"recvPkgRate,omitempty"`
+ RecvingBandwidthRate float64 `json:"recvBandwidthRate,omitempty"`
+
+ SendAppendRequestCnt uint64 `json:"sendAppendRequestCnt"`
+ SendingPkgRate float64 `json:"sendPkgRate,omitempty"`
+ SendingBandwidthRate float64 `json:"sendBandwidthRate,omitempty"`
+
+ sendRateQueue *statsQueue
+ recvRateQueue *statsQueue
+}
+
+func (ss *ServerStats) JSON() []byte {
+ ss.Lock()
+ stats := ss.serverStats
+ ss.Unlock()
+ stats.LeaderInfo.Uptime = time.Since(stats.LeaderInfo.StartTime).String()
+ stats.SendingPkgRate, stats.SendingBandwidthRate = stats.sendRateQueue.Rate()
+ stats.RecvingPkgRate, stats.RecvingBandwidthRate = stats.recvRateQueue.Rate()
+ b, err := json.Marshal(stats)
+ // TODO(jonboulle): appropriate error handling?
+ if err != nil {
+ log.Printf("stats: error marshalling server stats: %v", err)
+ }
+ return b
+}
+
+// RecvAppendReq updates the ServerStats in response to an AppendRequest
+// from the given leader being received
+func (ss *ServerStats) RecvAppendReq(leader string, reqSize int) {
+ ss.Lock()
+ defer ss.Unlock()
+
+ now := time.Now()
+
+ ss.State = raft.StateFollower
+ if leader != ss.LeaderInfo.Name {
+ ss.LeaderInfo.Name = leader
+ ss.LeaderInfo.StartTime = now
+ }
+
+ ss.recvRateQueue.Insert(
+ &RequestStats{
+ SendingTime: now,
+ Size: reqSize,
+ },
+ )
+ ss.RecvAppendRequestCnt++
+}
+
+// SendAppendReq updates the ServerStats in response to an AppendRequest
+// being sent by this server
+func (ss *ServerStats) SendAppendReq(reqSize int) {
+ ss.Lock()
+ defer ss.Unlock()
+
+ ss.becomeLeader()
+
+ ss.sendRateQueue.Insert(
+ &RequestStats{
+ SendingTime: time.Now(),
+ Size: reqSize,
+ },
+ )
+
+ ss.SendAppendRequestCnt++
+}
+
+func (ss *ServerStats) BecomeLeader() {
+ ss.Lock()
+ defer ss.Unlock()
+ ss.becomeLeader()
+}
+
+func (ss *ServerStats) becomeLeader() {
+ if ss.State != raft.StateLeader {
+ ss.State = raft.StateLeader
+ ss.LeaderInfo.Name = ss.ID
+ ss.LeaderInfo.StartTime = time.Now()
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/stats/stats.go b/vendor/github.com/coreos/etcd/etcdserver/stats/stats.go
new file mode 100644
index 00000000..2b5f7071
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/stats/stats.go
@@ -0,0 +1,32 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 stats defines a standard interface for etcd cluster statistics.
+package stats
+
+import "github.com/coreos/pkg/capnslog"
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "etcdserver/stats")
+)
+
+type Stats interface {
+ // SelfStats returns the struct representing statistics of this server
+ SelfStats() []byte
+ // LeaderStats returns the statistics of all followers in the cluster
+ // if this server is leader. Otherwise, nil is returned.
+ LeaderStats() []byte
+ // StoreStats returns statistics of the store backing this EtcdServer
+ StoreStats() []byte
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/storage.go b/vendor/github.com/coreos/etcd/etcdserver/storage.go
new file mode 100644
index 00000000..aa8f8756
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/storage.go
@@ -0,0 +1,98 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "io"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/snap"
+ "github.com/coreos/etcd/wal"
+ "github.com/coreos/etcd/wal/walpb"
+)
+
+type Storage interface {
+ // Save function saves ents and state to the underlying stable storage.
+ // Save MUST block until st and ents are on stable storage.
+ Save(st raftpb.HardState, ents []raftpb.Entry) error
+ // SaveSnap function saves snapshot to the underlying stable storage.
+ SaveSnap(snap raftpb.Snapshot) error
+ // Close closes the Storage and performs finalization.
+ Close() error
+}
+
+type storage struct {
+ *wal.WAL
+ *snap.Snapshotter
+}
+
+func NewStorage(w *wal.WAL, s *snap.Snapshotter) Storage {
+ return &storage{w, s}
+}
+
+// SaveSnap saves the snapshot to disk and release the locked
+// wal files since they will not be used.
+func (st *storage) SaveSnap(snap raftpb.Snapshot) error {
+ walsnap := walpb.Snapshot{
+ Index: snap.Metadata.Index,
+ Term: snap.Metadata.Term,
+ }
+ err := st.WAL.SaveSnapshot(walsnap)
+ if err != nil {
+ return err
+ }
+ err = st.Snapshotter.SaveSnap(snap)
+ if err != nil {
+ return err
+ }
+ return st.WAL.ReleaseLockTo(snap.Metadata.Index)
+}
+
+func readWAL(waldir string, snap walpb.Snapshot) (w *wal.WAL, id, cid types.ID, st raftpb.HardState, ents []raftpb.Entry) {
+ var (
+ err error
+ wmetadata []byte
+ )
+
+ repaired := false
+ for {
+ if w, err = wal.Open(waldir, snap); err != nil {
+ plog.Fatalf("open wal error: %v", err)
+ }
+ if wmetadata, st, ents, err = w.ReadAll(); err != nil {
+ w.Close()
+ // we can only repair ErrUnexpectedEOF and we never repair twice.
+ if repaired || err != io.ErrUnexpectedEOF {
+ plog.Fatalf("read wal error (%v) and cannot be repaired", err)
+ }
+ if !wal.Repair(waldir) {
+ plog.Fatalf("WAL error (%v) cannot be repaired", err)
+ } else {
+ plog.Infof("repaired WAL error (%v)", err)
+ repaired = true
+ }
+ continue
+ }
+ break
+ }
+ var metadata pb.Metadata
+ pbutil.MustUnmarshal(&metadata, wmetadata)
+ id = types.ID(metadata.NodeID)
+ cid = types.ID(metadata.ClusterID)
+ return
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/util.go b/vendor/github.com/coreos/etcd/etcdserver/util.go
new file mode 100644
index 00000000..e3896ffc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/util.go
@@ -0,0 +1,97 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/rafthttp"
+)
+
+// isConnectedToQuorumSince checks whether the local member is connected to the
+// quorum of the cluster since the given time.
+func isConnectedToQuorumSince(transport rafthttp.Transporter, since time.Time, self types.ID, members []*membership.Member) bool {
+ return numConnectedSince(transport, since, self, members) >= (len(members)/2)+1
+}
+
+// isConnectedSince checks whether the local member is connected to the
+// remote member since the given time.
+func isConnectedSince(transport rafthttp.Transporter, since time.Time, remote types.ID) bool {
+ t := transport.ActiveSince(remote)
+ return !t.IsZero() && t.Before(since)
+}
+
+// isConnectedFullySince checks whether the local member is connected to all
+// members in the cluster since the given time.
+func isConnectedFullySince(transport rafthttp.Transporter, since time.Time, self types.ID, members []*membership.Member) bool {
+ return numConnectedSince(transport, since, self, members) == len(members)
+}
+
+// numConnectedSince counts how many members are connected to the local member
+// since the given time.
+func numConnectedSince(transport rafthttp.Transporter, since time.Time, self types.ID, members []*membership.Member) int {
+ connectedNum := 0
+ for _, m := range members {
+ if m.ID == self || isConnectedSince(transport, since, m.ID) {
+ connectedNum++
+ }
+ }
+ return connectedNum
+}
+
+// longestConnected chooses the member with longest active-since-time.
+// It returns false, if nothing is active.
+func longestConnected(tp rafthttp.Transporter, membs []types.ID) (types.ID, bool) {
+ var longest types.ID
+ var oldest time.Time
+ for _, id := range membs {
+ tm := tp.ActiveSince(id)
+ if tm.IsZero() { // inactive
+ continue
+ }
+
+ if oldest.IsZero() { // first longest candidate
+ oldest = tm
+ longest = id
+ }
+
+ if tm.Before(oldest) {
+ oldest = tm
+ longest = id
+ }
+ }
+ if uint64(longest) == 0 {
+ return longest, false
+ }
+ return longest, true
+}
+
+type notifier struct {
+ c chan struct{}
+ err error
+}
+
+func newNotifier() *notifier {
+ return ¬ifier{
+ c: make(chan struct{}),
+ }
+}
+
+func (nc *notifier) notify(err error) {
+ nc.err = err
+ close(nc.c)
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/util_test.go b/vendor/github.com/coreos/etcd/etcdserver/util_test.go
new file mode 100644
index 00000000..79edabd1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/util_test.go
@@ -0,0 +1,89 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "net/http"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/rafthttp"
+ "github.com/coreos/etcd/snap"
+)
+
+func TestLongestConnected(t *testing.T) {
+ umap, err := types.NewURLsMap("mem1=http://10.1:2379,mem2=http://10.2:2379,mem3=http://10.3:2379")
+ if err != nil {
+ t.Fatal(err)
+ }
+ clus, err := membership.NewClusterFromURLsMap("test", umap)
+ if err != nil {
+ t.Fatal(err)
+ }
+ memberIDs := clus.MemberIDs()
+
+ tr := newNopTransporterWithActiveTime(memberIDs)
+ transferee, ok := longestConnected(tr, memberIDs)
+ if !ok {
+ t.Fatalf("unexpected ok %v", ok)
+ }
+ if memberIDs[0] != transferee {
+ t.Fatalf("expected first member %s to be transferee, got %s", memberIDs[0], transferee)
+ }
+
+ // make all members non-active
+ amap := make(map[types.ID]time.Time)
+ for _, id := range memberIDs {
+ amap[id] = time.Time{}
+ }
+ tr.(*nopTransporterWithActiveTime).reset(amap)
+
+ _, ok2 := longestConnected(tr, memberIDs)
+ if ok2 {
+ t.Fatalf("unexpected ok %v", ok)
+ }
+}
+
+type nopTransporterWithActiveTime struct {
+ activeMap map[types.ID]time.Time
+}
+
+// newNopTransporterWithActiveTime creates nopTransporterWithActiveTime with the first member
+// being the most stable (longest active-since time).
+func newNopTransporterWithActiveTime(memberIDs []types.ID) rafthttp.Transporter {
+ am := make(map[types.ID]time.Time)
+ for i, id := range memberIDs {
+ am[id] = time.Now().Add(time.Duration(i) * time.Second)
+ }
+ return &nopTransporterWithActiveTime{activeMap: am}
+}
+
+func (s *nopTransporterWithActiveTime) Start() error { return nil }
+func (s *nopTransporterWithActiveTime) Handler() http.Handler { return nil }
+func (s *nopTransporterWithActiveTime) Send(m []raftpb.Message) {}
+func (s *nopTransporterWithActiveTime) SendSnapshot(m snap.Message) {}
+func (s *nopTransporterWithActiveTime) AddRemote(id types.ID, us []string) {}
+func (s *nopTransporterWithActiveTime) AddPeer(id types.ID, us []string) {}
+func (s *nopTransporterWithActiveTime) RemovePeer(id types.ID) {}
+func (s *nopTransporterWithActiveTime) RemoveAllPeers() {}
+func (s *nopTransporterWithActiveTime) UpdatePeer(id types.ID, us []string) {}
+func (s *nopTransporterWithActiveTime) ActiveSince(id types.ID) time.Time { return s.activeMap[id] }
+func (s *nopTransporterWithActiveTime) Stop() {}
+func (s *nopTransporterWithActiveTime) Pause() {}
+func (s *nopTransporterWithActiveTime) Resume() {}
+func (s *nopTransporterWithActiveTime) reset(am map[types.ID]time.Time) { s.activeMap = am }
diff --git a/vendor/github.com/coreos/etcd/etcdserver/v2_server.go b/vendor/github.com/coreos/etcd/etcdserver/v2_server.go
new file mode 100644
index 00000000..72c4eb7c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/v2_server.go
@@ -0,0 +1,125 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "time"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "golang.org/x/net/context"
+)
+
+type v2API interface {
+ Post(ctx context.Context, r *pb.Request) (Response, error)
+ Put(ctx context.Context, r *pb.Request) (Response, error)
+ Delete(ctx context.Context, r *pb.Request) (Response, error)
+ QGet(ctx context.Context, r *pb.Request) (Response, error)
+ Get(ctx context.Context, r *pb.Request) (Response, error)
+ Head(ctx context.Context, r *pb.Request) (Response, error)
+}
+
+type v2apiStore struct{ s *EtcdServer }
+
+func (a *v2apiStore) Post(ctx context.Context, r *pb.Request) (Response, error) {
+ return a.processRaftRequest(ctx, r)
+}
+
+func (a *v2apiStore) Put(ctx context.Context, r *pb.Request) (Response, error) {
+ return a.processRaftRequest(ctx, r)
+}
+
+func (a *v2apiStore) Delete(ctx context.Context, r *pb.Request) (Response, error) {
+ return a.processRaftRequest(ctx, r)
+}
+
+func (a *v2apiStore) QGet(ctx context.Context, r *pb.Request) (Response, error) {
+ return a.processRaftRequest(ctx, r)
+}
+
+func (a *v2apiStore) processRaftRequest(ctx context.Context, r *pb.Request) (Response, error) {
+ data, err := r.Marshal()
+ if err != nil {
+ return Response{}, err
+ }
+ ch := a.s.w.Register(r.ID)
+
+ start := time.Now()
+ a.s.r.Propose(ctx, data)
+ proposalsPending.Inc()
+ defer proposalsPending.Dec()
+
+ select {
+ case x := <-ch:
+ resp := x.(Response)
+ return resp, resp.err
+ case <-ctx.Done():
+ proposalsFailed.Inc()
+ a.s.w.Trigger(r.ID, nil) // GC wait
+ return Response{}, a.s.parseProposeCtxErr(ctx.Err(), start)
+ case <-a.s.stopping:
+ }
+ return Response{}, ErrStopped
+}
+
+func (a *v2apiStore) Get(ctx context.Context, r *pb.Request) (Response, error) {
+ if r.Wait {
+ wc, err := a.s.store.Watch(r.Path, r.Recursive, r.Stream, r.Since)
+ if err != nil {
+ return Response{}, err
+ }
+ return Response{Watcher: wc}, nil
+ }
+ ev, err := a.s.store.Get(r.Path, r.Recursive, r.Sorted)
+ if err != nil {
+ return Response{}, err
+ }
+ return Response{Event: ev}, nil
+}
+
+func (a *v2apiStore) Head(ctx context.Context, r *pb.Request) (Response, error) {
+ ev, err := a.s.store.Get(r.Path, r.Recursive, r.Sorted)
+ if err != nil {
+ return Response{}, err
+ }
+ return Response{Event: ev}, nil
+}
+
+// Do interprets r and performs an operation on s.store according to r.Method
+// and other fields. If r.Method is "POST", "PUT", "DELETE", or a "GET" with
+// Quorum == true, r will be sent through consensus before performing its
+// respective operation. Do will block until an action is performed or there is
+// an error.
+func (s *EtcdServer) Do(ctx context.Context, r pb.Request) (Response, error) {
+ r.ID = s.reqIDGen.Next()
+ if r.Method == "GET" && r.Quorum {
+ r.Method = "QGET"
+ }
+ v2api := (v2API)(&v2apiStore{s})
+ switch r.Method {
+ case "POST":
+ return v2api.Post(ctx, &r)
+ case "PUT":
+ return v2api.Put(ctx, &r)
+ case "DELETE":
+ return v2api.Delete(ctx, &r)
+ case "QGET":
+ return v2api.QGet(ctx, &r)
+ case "GET":
+ return v2api.Get(ctx, &r)
+ case "HEAD":
+ return v2api.Head(ctx, &r)
+ }
+ return Response{}, ErrUnknownMethod
+}
diff --git a/vendor/github.com/coreos/etcd/etcdserver/v3_server.go b/vendor/github.com/coreos/etcd/etcdserver/v3_server.go
new file mode 100644
index 00000000..a86e0751
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/etcdserver/v3_server.go
@@ -0,0 +1,754 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 etcdserver
+
+import (
+ "bytes"
+ "encoding/binary"
+ "time"
+
+ "github.com/coreos/etcd/auth"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/etcdserver/membership"
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/lease/leasehttp"
+ "github.com/coreos/etcd/mvcc"
+ "github.com/coreos/etcd/raft"
+
+ "golang.org/x/net/context"
+)
+
+const (
+ // the max request size that raft accepts.
+ // TODO: make this a flag? But we probably do not want to
+ // accept large request which might block raft stream. User
+ // specify a large value might end up with shooting in the foot.
+ maxRequestBytes = 1.5 * 1024 * 1024
+
+ // In the health case, there might be a small gap (10s of entries) between
+ // the applied index and committed index.
+ // However, if the committed entries are very heavy to apply, the gap might grow.
+ // We should stop accepting new proposals if the gap growing to a certain point.
+ maxGapBetweenApplyAndCommitIndex = 5000
+)
+
+type RaftKV interface {
+ Range(ctx context.Context, r *pb.RangeRequest) (*pb.RangeResponse, error)
+ Put(ctx context.Context, r *pb.PutRequest) (*pb.PutResponse, error)
+ DeleteRange(ctx context.Context, r *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error)
+ Txn(ctx context.Context, r *pb.TxnRequest) (*pb.TxnResponse, error)
+ Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error)
+}
+
+type Lessor interface {
+ // LeaseGrant sends LeaseGrant request to raft and apply it after committed.
+ LeaseGrant(ctx context.Context, r *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error)
+ // LeaseRevoke sends LeaseRevoke request to raft and apply it after committed.
+ LeaseRevoke(ctx context.Context, r *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error)
+
+ // LeaseRenew renews the lease with given ID. The renewed TTL is returned. Or an error
+ // is returned.
+ LeaseRenew(ctx context.Context, id lease.LeaseID) (int64, error)
+
+ // LeaseTimeToLive retrieves lease information.
+ LeaseTimeToLive(ctx context.Context, r *pb.LeaseTimeToLiveRequest) (*pb.LeaseTimeToLiveResponse, error)
+}
+
+type Authenticator interface {
+ AuthEnable(ctx context.Context, r *pb.AuthEnableRequest) (*pb.AuthEnableResponse, error)
+ AuthDisable(ctx context.Context, r *pb.AuthDisableRequest) (*pb.AuthDisableResponse, error)
+ Authenticate(ctx context.Context, r *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error)
+ UserAdd(ctx context.Context, r *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error)
+ UserDelete(ctx context.Context, r *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error)
+ UserChangePassword(ctx context.Context, r *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error)
+ UserGrantRole(ctx context.Context, r *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error)
+ UserGet(ctx context.Context, r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error)
+ UserRevokeRole(ctx context.Context, r *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error)
+ RoleAdd(ctx context.Context, r *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error)
+ RoleGrantPermission(ctx context.Context, r *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error)
+ RoleGet(ctx context.Context, r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error)
+ RoleRevokePermission(ctx context.Context, r *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error)
+ RoleDelete(ctx context.Context, r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error)
+ UserList(ctx context.Context, r *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error)
+ RoleList(ctx context.Context, r *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error)
+}
+
+func (s *EtcdServer) Range(ctx context.Context, r *pb.RangeRequest) (*pb.RangeResponse, error) {
+ if !r.Serializable {
+ err := s.linearizableReadNotify(ctx)
+ if err != nil {
+ return nil, err
+ }
+ }
+ var resp *pb.RangeResponse
+ var err error
+ chk := func(ai *auth.AuthInfo) error {
+ return s.authStore.IsRangePermitted(ai, r.Key, r.RangeEnd)
+ }
+ get := func() { resp, err = s.applyV3Base.Range(nil, r) }
+ if serr := s.doSerialize(ctx, chk, get); serr != nil {
+ return nil, serr
+ }
+ return resp, err
+}
+
+func (s *EtcdServer) Put(ctx context.Context, r *pb.PutRequest) (*pb.PutResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{Put: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.PutResponse), nil
+}
+
+func (s *EtcdServer) DeleteRange(ctx context.Context, r *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{DeleteRange: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.DeleteRangeResponse), nil
+}
+
+func (s *EtcdServer) Txn(ctx context.Context, r *pb.TxnRequest) (*pb.TxnResponse, error) {
+ if isTxnReadonly(r) {
+ if !isTxnSerializable(r) {
+ err := s.linearizableReadNotify(ctx)
+ if err != nil {
+ return nil, err
+ }
+ }
+ var resp *pb.TxnResponse
+ var err error
+ chk := func(ai *auth.AuthInfo) error {
+ return checkTxnAuth(s.authStore, ai, r)
+ }
+ get := func() { resp, err = s.applyV3Base.Txn(r) }
+ if serr := s.doSerialize(ctx, chk, get); serr != nil {
+ return nil, serr
+ }
+ return resp, err
+ }
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{Txn: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.TxnResponse), nil
+}
+
+func isTxnSerializable(r *pb.TxnRequest) bool {
+ for _, u := range r.Success {
+ if r := u.GetRequestRange(); r == nil || !r.Serializable {
+ return false
+ }
+ }
+ for _, u := range r.Failure {
+ if r := u.GetRequestRange(); r == nil || !r.Serializable {
+ return false
+ }
+ }
+ return true
+}
+
+func isTxnReadonly(r *pb.TxnRequest) bool {
+ for _, u := range r.Success {
+ if r := u.GetRequestRange(); r == nil {
+ return false
+ }
+ }
+ for _, u := range r.Failure {
+ if r := u.GetRequestRange(); r == nil {
+ return false
+ }
+ }
+ return true
+}
+
+func (s *EtcdServer) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) {
+ result, err := s.processInternalRaftRequestOnce(ctx, pb.InternalRaftRequest{Compaction: r})
+ if r.Physical && result != nil && result.physc != nil {
+ <-result.physc
+ // The compaction is done deleting keys; the hash is now settled
+ // but the data is not necessarily committed. If there's a crash,
+ // the hash may revert to a hash prior to compaction completing
+ // if the compaction resumes. Force the finished compaction to
+ // commit so it won't resume following a crash.
+ s.be.ForceCommit()
+ }
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ resp := result.resp.(*pb.CompactionResponse)
+ if resp == nil {
+ resp = &pb.CompactionResponse{}
+ }
+ if resp.Header == nil {
+ resp.Header = &pb.ResponseHeader{}
+ }
+ resp.Header.Revision = s.kv.Rev()
+ return resp, nil
+}
+
+func (s *EtcdServer) LeaseGrant(ctx context.Context, r *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) {
+ // no id given? choose one
+ for r.ID == int64(lease.NoLease) {
+ // only use positive int64 id's
+ r.ID = int64(s.reqIDGen.Next() & ((1 << 63) - 1))
+ }
+ result, err := s.processInternalRaftRequestOnce(ctx, pb.InternalRaftRequest{LeaseGrant: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.LeaseGrantResponse), nil
+}
+
+func (s *EtcdServer) LeaseRevoke(ctx context.Context, r *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error) {
+ result, err := s.processInternalRaftRequestOnce(ctx, pb.InternalRaftRequest{LeaseRevoke: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.LeaseRevokeResponse), nil
+}
+
+func (s *EtcdServer) LeaseRenew(ctx context.Context, id lease.LeaseID) (int64, error) {
+ ttl, err := s.lessor.Renew(id)
+ if err == nil { // already requested to primary lessor(leader)
+ return ttl, nil
+ }
+ if err != lease.ErrNotPrimary {
+ return -1, err
+ }
+
+ cctx, cancel := context.WithTimeout(ctx, s.Cfg.ReqTimeout())
+ defer cancel()
+
+ // renewals don't go through raft; forward to leader manually
+ for cctx.Err() == nil && err != nil {
+ leader, lerr := s.waitLeader(cctx)
+ if lerr != nil {
+ return -1, lerr
+ }
+ for _, url := range leader.PeerURLs {
+ lurl := url + leasehttp.LeasePrefix
+ ttl, err = leasehttp.RenewHTTP(cctx, id, lurl, s.peerRt)
+ if err == nil || err == lease.ErrLeaseNotFound {
+ return ttl, err
+ }
+ }
+ }
+ return -1, ErrTimeout
+}
+
+func (s *EtcdServer) LeaseTimeToLive(ctx context.Context, r *pb.LeaseTimeToLiveRequest) (*pb.LeaseTimeToLiveResponse, error) {
+ if s.Leader() == s.ID() {
+ // primary; timetolive directly from leader
+ le := s.lessor.Lookup(lease.LeaseID(r.ID))
+ if le == nil {
+ return nil, lease.ErrLeaseNotFound
+ }
+ // TODO: fill out ResponseHeader
+ resp := &pb.LeaseTimeToLiveResponse{Header: &pb.ResponseHeader{}, ID: r.ID, TTL: int64(le.Remaining().Seconds()), GrantedTTL: le.TTL()}
+ if r.Keys {
+ ks := le.Keys()
+ kbs := make([][]byte, len(ks))
+ for i := range ks {
+ kbs[i] = []byte(ks[i])
+ }
+ resp.Keys = kbs
+ }
+ return resp, nil
+ }
+
+ cctx, cancel := context.WithTimeout(ctx, s.Cfg.ReqTimeout())
+ defer cancel()
+
+ // forward to leader
+ for cctx.Err() == nil {
+ leader, err := s.waitLeader(cctx)
+ if err != nil {
+ return nil, err
+ }
+ for _, url := range leader.PeerURLs {
+ lurl := url + leasehttp.LeaseInternalPrefix
+ resp, err := leasehttp.TimeToLiveHTTP(cctx, lease.LeaseID(r.ID), r.Keys, lurl, s.peerRt)
+ if err == nil {
+ return resp.LeaseTimeToLiveResponse, nil
+ }
+ if err == lease.ErrLeaseNotFound {
+ return nil, err
+ }
+ }
+ }
+ return nil, ErrTimeout
+}
+
+func (s *EtcdServer) waitLeader(ctx context.Context) (*membership.Member, error) {
+ leader := s.cluster.Member(s.Leader())
+ for leader == nil {
+ // wait an election
+ dur := time.Duration(s.Cfg.ElectionTicks) * time.Duration(s.Cfg.TickMs) * time.Millisecond
+ select {
+ case <-time.After(dur):
+ leader = s.cluster.Member(s.Leader())
+ case <-s.stopping:
+ return nil, ErrStopped
+ case <-ctx.Done():
+ return nil, ErrNoLeader
+ }
+ }
+ if leader == nil || len(leader.PeerURLs) == 0 {
+ return nil, ErrNoLeader
+ }
+ return leader, nil
+}
+
+func (s *EtcdServer) Alarm(ctx context.Context, r *pb.AlarmRequest) (*pb.AlarmResponse, error) {
+ result, err := s.processInternalRaftRequestOnce(ctx, pb.InternalRaftRequest{Alarm: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AlarmResponse), nil
+}
+
+func (s *EtcdServer) AuthEnable(ctx context.Context, r *pb.AuthEnableRequest) (*pb.AuthEnableResponse, error) {
+ result, err := s.processInternalRaftRequestOnce(ctx, pb.InternalRaftRequest{AuthEnable: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthEnableResponse), nil
+}
+
+func (s *EtcdServer) AuthDisable(ctx context.Context, r *pb.AuthDisableRequest) (*pb.AuthDisableResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{AuthDisable: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthDisableResponse), nil
+}
+
+func (s *EtcdServer) Authenticate(ctx context.Context, r *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) {
+ var result *applyResult
+
+ err := s.linearizableReadNotify(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ for {
+ checkedRevision, err := s.AuthStore().CheckPassword(r.Name, r.Password)
+ if err != nil {
+ if err != auth.ErrAuthNotEnabled {
+ plog.Errorf("invalid authentication request to user %s was issued", r.Name)
+ }
+ return nil, err
+ }
+
+ st, err := s.AuthStore().GenTokenPrefix()
+ if err != nil {
+ return nil, err
+ }
+
+ internalReq := &pb.InternalAuthenticateRequest{
+ Name: r.Name,
+ Password: r.Password,
+ SimpleToken: st,
+ }
+
+ result, err = s.processInternalRaftRequestOnce(ctx, pb.InternalRaftRequest{Authenticate: internalReq})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+
+ if checkedRevision != s.AuthStore().Revision() {
+ plog.Infof("revision when password checked is obsolete, retrying")
+ continue
+ }
+
+ break
+ }
+
+ return result.resp.(*pb.AuthenticateResponse), nil
+}
+
+func (s *EtcdServer) UserAdd(ctx context.Context, r *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{AuthUserAdd: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthUserAddResponse), nil
+}
+
+func (s *EtcdServer) UserDelete(ctx context.Context, r *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{AuthUserDelete: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthUserDeleteResponse), nil
+}
+
+func (s *EtcdServer) UserChangePassword(ctx context.Context, r *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{AuthUserChangePassword: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthUserChangePasswordResponse), nil
+}
+
+func (s *EtcdServer) UserGrantRole(ctx context.Context, r *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{AuthUserGrantRole: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthUserGrantRoleResponse), nil
+}
+
+func (s *EtcdServer) UserGet(ctx context.Context, r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{AuthUserGet: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthUserGetResponse), nil
+}
+
+func (s *EtcdServer) UserList(ctx context.Context, r *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{AuthUserList: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthUserListResponse), nil
+}
+
+func (s *EtcdServer) UserRevokeRole(ctx context.Context, r *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{AuthUserRevokeRole: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthUserRevokeRoleResponse), nil
+}
+
+func (s *EtcdServer) RoleAdd(ctx context.Context, r *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{AuthRoleAdd: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthRoleAddResponse), nil
+}
+
+func (s *EtcdServer) RoleGrantPermission(ctx context.Context, r *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{AuthRoleGrantPermission: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthRoleGrantPermissionResponse), nil
+}
+
+func (s *EtcdServer) RoleGet(ctx context.Context, r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{AuthRoleGet: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthRoleGetResponse), nil
+}
+
+func (s *EtcdServer) RoleList(ctx context.Context, r *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{AuthRoleList: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthRoleListResponse), nil
+}
+
+func (s *EtcdServer) RoleRevokePermission(ctx context.Context, r *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{AuthRoleRevokePermission: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthRoleRevokePermissionResponse), nil
+}
+
+func (s *EtcdServer) RoleDelete(ctx context.Context, r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error) {
+ result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{AuthRoleDelete: r})
+ if err != nil {
+ return nil, err
+ }
+ if result.err != nil {
+ return nil, result.err
+ }
+ return result.resp.(*pb.AuthRoleDeleteResponse), nil
+}
+
+// doSerialize handles the auth logic, with permissions checked by "chk", for a serialized request "get". Returns a non-nil error on authentication failure.
+func (s *EtcdServer) doSerialize(ctx context.Context, chk func(*auth.AuthInfo) error, get func()) error {
+ for {
+ ai, err := s.AuthInfoFromCtx(ctx)
+ if err != nil {
+ return err
+ }
+ if ai == nil {
+ // chk expects non-nil AuthInfo; use empty credentials
+ ai = &auth.AuthInfo{}
+ }
+ if err = chk(ai); err != nil {
+ if err == auth.ErrAuthOldRevision {
+ continue
+ }
+ return err
+ }
+ // fetch response for serialized request
+ get()
+ // empty credentials or current auth info means no need to retry
+ if ai.Revision == 0 || ai.Revision == s.authStore.Revision() {
+ return nil
+ }
+ // avoid TOCTOU error, retry of the request is required.
+ }
+}
+
+func (s *EtcdServer) processInternalRaftRequestOnce(ctx context.Context, r pb.InternalRaftRequest) (*applyResult, error) {
+ ai := s.getAppliedIndex()
+ ci := s.getCommittedIndex()
+ if ci > ai+maxGapBetweenApplyAndCommitIndex {
+ return nil, ErrTooManyRequests
+ }
+
+ r.Header = &pb.RequestHeader{
+ ID: s.reqIDGen.Next(),
+ }
+
+ authInfo, err := s.AuthInfoFromCtx(ctx)
+ if err != nil {
+ return nil, err
+ }
+ if authInfo != nil {
+ r.Header.Username = authInfo.Username
+ r.Header.AuthRevision = authInfo.Revision
+ }
+
+ data, err := r.Marshal()
+ if err != nil {
+ return nil, err
+ }
+
+ if len(data) > maxRequestBytes {
+ return nil, ErrRequestTooLarge
+ }
+
+ id := r.ID
+ if id == 0 {
+ id = r.Header.ID
+ }
+ ch := s.w.Register(id)
+
+ cctx, cancel := context.WithTimeout(ctx, s.Cfg.ReqTimeout())
+ defer cancel()
+
+ start := time.Now()
+ s.r.Propose(cctx, data)
+ proposalsPending.Inc()
+ defer proposalsPending.Dec()
+
+ select {
+ case x := <-ch:
+ return x.(*applyResult), nil
+ case <-cctx.Done():
+ proposalsFailed.Inc()
+ s.w.Trigger(id, nil) // GC wait
+ return nil, s.parseProposeCtxErr(cctx.Err(), start)
+ case <-s.done:
+ return nil, ErrStopped
+ }
+}
+
+func (s *EtcdServer) processInternalRaftRequest(ctx context.Context, r pb.InternalRaftRequest) (*applyResult, error) {
+ var result *applyResult
+ var err error
+ for {
+ result, err = s.processInternalRaftRequestOnce(ctx, r)
+ if err != auth.ErrAuthOldRevision {
+ break
+ }
+ }
+
+ return result, err
+}
+
+// Watchable returns a watchable interface attached to the etcdserver.
+func (s *EtcdServer) Watchable() mvcc.WatchableKV { return s.KV() }
+
+func (s *EtcdServer) linearizableReadLoop() {
+ var rs raft.ReadState
+
+ for {
+ ctx := make([]byte, 8)
+ binary.BigEndian.PutUint64(ctx, s.reqIDGen.Next())
+
+ select {
+ case <-s.readwaitc:
+ case <-s.stopping:
+ return
+ }
+
+ nextnr := newNotifier()
+
+ s.readMu.Lock()
+ nr := s.readNotifier
+ s.readNotifier = nextnr
+ s.readMu.Unlock()
+
+ cctx, cancel := context.WithTimeout(context.Background(), s.Cfg.ReqTimeout())
+ if err := s.r.ReadIndex(cctx, ctx); err != nil {
+ cancel()
+ if err == raft.ErrStopped {
+ return
+ }
+ plog.Errorf("failed to get read index from raft: %v", err)
+ nr.notify(err)
+ continue
+ }
+ cancel()
+
+ var (
+ timeout bool
+ done bool
+ )
+ for !timeout && !done {
+ select {
+ case rs = <-s.r.readStateC:
+ done = bytes.Equal(rs.RequestCtx, ctx)
+ if !done {
+ // a previous request might time out. now we should ignore the response of it and
+ // continue waiting for the response of the current requests.
+ plog.Warningf("ignored out-of-date read index response (want %v, got %v)", rs.RequestCtx, ctx)
+ }
+ case <-time.After(s.Cfg.ReqTimeout()):
+ plog.Warningf("timed out waiting for read index response")
+ nr.notify(ErrTimeout)
+ timeout = true
+ case <-s.stopping:
+ return
+ }
+ }
+ if !done {
+ continue
+ }
+
+ if ai := s.getAppliedIndex(); ai < rs.Index {
+ select {
+ case <-s.applyWait.Wait(rs.Index):
+ case <-s.stopping:
+ return
+ }
+ }
+ // unblock all l-reads requested at indices before rs.Index
+ nr.notify(nil)
+ }
+}
+
+func (s *EtcdServer) linearizableReadNotify(ctx context.Context) error {
+ s.readMu.RLock()
+ nc := s.readNotifier
+ s.readMu.RUnlock()
+
+ // signal linearizable loop for current notify if it hasn't been already
+ select {
+ case s.readwaitc <- struct{}{}:
+ default:
+ }
+
+ // wait for read state notification
+ select {
+ case <-nc.c:
+ return nc.err
+ case <-ctx.Done():
+ return ctx.Err()
+ case <-s.done:
+ return ErrStopped
+ }
+}
+
+func (s *EtcdServer) AuthInfoFromCtx(ctx context.Context) (*auth.AuthInfo, error) {
+ if s.Cfg.ClientCertAuthEnabled {
+ authInfo := s.AuthStore().AuthInfoFromTLS(ctx)
+ if authInfo != nil {
+ return authInfo, nil
+ }
+ }
+
+ return s.AuthStore().AuthInfoFromCtx(ctx)
+}
diff --git a/vendor/github.com/coreos/etcd/glide.lock b/vendor/github.com/coreos/etcd/glide.lock
new file mode 100644
index 00000000..1d866cf7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/glide.lock
@@ -0,0 +1,158 @@
+hash: cee1f2629857e9c2384ad89ff6014db09498c9af53771e5144ad3a4b510ff00e
+updated: 2017-05-30T10:29:08.22609283-07:00
+imports:
+- name: github.com/beorn7/perks
+ version: 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9
+ subpackages:
+ - quantile
+- name: github.com/bgentry/speakeasy
+ version: 4aabc24848ce5fd31929f7d1e4ea74d3709c14cd
+- name: github.com/boltdb/bolt
+ version: 583e8937c61f1af6513608ccc75c97b6abdf4ff9
+- name: github.com/cockroachdb/cmux
+ version: 112f0506e7743d64a6eb8fedbcff13d9979bbf92
+- name: github.com/coreos/go-semver
+ version: 8ab6407b697782a06568d4b7f1db25550ec2e4c6
+ subpackages:
+ - semver
+- name: github.com/coreos/go-systemd
+ version: 48702e0da86bd25e76cfef347e2adeb434a0d0a6
+ subpackages:
+ - daemon
+ - journal
+ - util
+- name: github.com/coreos/pkg
+ version: 3ac0863d7acf3bc44daf49afef8919af12f704ef
+ subpackages:
+ - capnslog
+ - dlopen
+- name: github.com/cpuguy83/go-md2man
+ version: bcc0a711c5e6bbe72c7cb13d81c7109b45267fd2
+ subpackages:
+ - md2man
+- name: github.com/dgrijalva/jwt-go
+ version: d2709f9f1f31ebcda9651b03077758c1f3a0018c
+- name: github.com/dustin/go-humanize
+ version: 8929fe90cee4b2cb9deb468b51fb34eba64d1bf0
+- name: github.com/ghodss/yaml
+ version: 0ca9ea5df5451ffdf184b4428c902747c2c11cd7
+- name: github.com/gogo/protobuf
+ version: 909568be09de550ed094403c2bf8a261b5bb730a
+ subpackages:
+ - proto
+- name: github.com/golang/groupcache
+ version: 02826c3e79038b59d737d3b1c0a1d937f71a4433
+ subpackages:
+ - lru
+- name: github.com/golang/protobuf
+ version: 4bd1920723d7b7c925de087aa32e2187708897f7
+ subpackages:
+ - jsonpb
+ - proto
+- name: github.com/google/btree
+ version: 925471ac9e2131377a91e1595defec898166fe49
+- name: github.com/grpc-ecosystem/go-grpc-prometheus
+ version: 6b7015e65d366bf3f19b2b2a000a831940f0f7e0
+- name: github.com/grpc-ecosystem/grpc-gateway
+ version: 18d159699f2e83fc5bb9ef2f79465ca3f3122676
+ subpackages:
+ - runtime
+ - runtime/internal
+ - utilities
+- name: github.com/inconshreveable/mousetrap
+ version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75
+- name: github.com/jonboulle/clockwork
+ version: 2eee05ed794112d45db504eb05aa693efd2b8b09
+- name: github.com/kr/pty
+ version: 2c10821df3c3cf905230d078702dfbe9404c9b23
+- name: github.com/mattn/go-runewidth
+ version: 9e777a8366cce605130a531d2cd6363d07ad7317
+ subpackages:
+ - runewidth.go
+- name: github.com/matttproud/golang_protobuf_extensions
+ version: c12348ce28de40eed0136aa2b644d0ee0650e56c
+ subpackages:
+ - pbutil
+- name: github.com/olekukonko/tablewriter
+ version: a0225b3f23b5ce0cbec6d7a66a968f8a59eca9c4
+- name: github.com/prometheus/client_golang
+ version: c5b7fccd204277076155f10851dad72b76a49317
+ subpackages:
+ - prometheus
+- name: github.com/prometheus/client_model
+ version: 6f3806018612930941127f2a7c6c453ba2c527d2
+ subpackages:
+ - go
+- name: github.com/prometheus/common
+ version: 49fee292b27bfff7f354ee0f64e1bc4850462edf
+ subpackages:
+ - expfmt
+ - internal/bitbucket.org/ww/goautoneg
+ - model
+- name: github.com/prometheus/procfs
+ version: a1dba9ce8baed984a2495b658c82687f8157b98f
+ subpackages:
+ - xfs
+- name: github.com/russross/blackfriday
+ version: 0ba0f2b6ed7c475a92e4df8641825cb7a11d1fa3
+- name: github.com/spf13/cobra
+ version: 1c44ec8d3f1552cac48999f9306da23c4d8a288b
+- name: github.com/spf13/pflag
+ version: 08b1a584251b5b62f458943640fc8ebd4d50aaa5
+- name: github.com/ugorji/go
+ version: ded73eae5db7e7a0ef6f55aace87a2873c5d2b74
+ subpackages:
+ - codec
+- name: github.com/urfave/cli
+ version: 1efa31f08b9333f1bd4882d61f9d668a70cd902e
+- name: github.com/xiang90/probing
+ version: 07dd2e8dfe18522e9c447ba95f2fe95262f63bb2
+- name: golang.org/x/crypto
+ version: 1351f936d976c60a0a48d728281922cf63eafb8d
+ subpackages:
+ - bcrypt
+ - blowfish
+- name: golang.org/x/net
+ version: c8c74377599bd978aee1cf3b9b63a8634051cec2
+ subpackages:
+ - context
+ - http2
+ - http2/hpack
+ - idna
+ - internal/timeseries
+ - lex/httplex
+ - trace
+- name: golang.org/x/sys
+ version: e48874b42435b4347fc52bdee0424a52abc974d7
+ subpackages:
+ - unix
+- name: golang.org/x/text
+ version: 4ee4af566555f5fbe026368b75596286a312663a
+ subpackages:
+ - secure/bidirule
+ - transform
+ - unicode/bidi
+ - unicode/norm
+- name: golang.org/x/time
+ version: c06e80d9300e4443158a03817b8a8cb37d230320
+ subpackages:
+ - rate
+- name: google.golang.org/grpc
+ version: 8050b9cbc271307e5a716a9d782803d09b0d6f2d
+ subpackages:
+ - codes
+ - credentials
+ - grpclog
+ - internal
+ - keepalive
+ - metadata
+ - naming
+ - peer
+ - stats
+ - tap
+ - transport
+- name: gopkg.in/cheggaaa/pb.v1
+ version: 226d21d43a305fac52b3a104ef83e721b15275e0
+- name: gopkg.in/yaml.v2
+ version: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b
+testImports: []
diff --git a/vendor/github.com/coreos/etcd/glide.yaml b/vendor/github.com/coreos/etcd/glide.yaml
new file mode 100644
index 00000000..90bcfedd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/glide.yaml
@@ -0,0 +1,115 @@
+package: github.com/coreos/etcd
+import:
+- package: github.com/bgentry/speakeasy
+ version: 4aabc24848ce5fd31929f7d1e4ea74d3709c14cd
+- package: github.com/boltdb/bolt
+ version: v1.3.0
+- package: github.com/cockroachdb/cmux
+ version: 112f0506e7743d64a6eb8fedbcff13d9979bbf92
+- package: github.com/coreos/go-semver
+ version: v0.2.0
+ subpackages:
+ - semver
+- package: github.com/coreos/go-systemd
+ version: v14
+ subpackages:
+ - daemon
+ - journal
+ - util
+- package: github.com/coreos/pkg
+ version: v3
+ subpackages:
+ - capnslog
+- package: github.com/dustin/go-humanize
+ version: 8929fe90cee4b2cb9deb468b51fb34eba64d1bf0
+- package: github.com/ghodss/yaml
+ version: v1.0.0
+- package: github.com/gogo/protobuf
+ version: v0.3
+ subpackages:
+ - proto
+- package: github.com/golang/groupcache
+ version: 02826c3e79038b59d737d3b1c0a1d937f71a4433
+ subpackages:
+ - lru
+- package: github.com/golang/protobuf
+ version: 4bd1920723d7b7c925de087aa32e2187708897f7
+ subpackages:
+ - jsonpb
+ - proto
+- package: github.com/google/btree
+ version: 925471ac9e2131377a91e1595defec898166fe49
+- package: github.com/grpc-ecosystem/grpc-gateway
+ version: v1.2.0
+ subpackages:
+ - runtime
+ - runtime/internal
+ - utilities
+- package: github.com/jonboulle/clockwork
+ version: v0.1.0
+- package: github.com/kr/pty
+ version: v1.0.0
+- package: github.com/olekukonko/tablewriter
+ version: a0225b3f23b5ce0cbec6d7a66a968f8a59eca9c4
+- package: github.com/mattn/go-runewidth
+ version: v0.0.2
+ subpackages:
+ - runewidth.go
+- package: github.com/prometheus/client_golang
+ version: v0.8.0
+ subpackages:
+ - prometheus
+- package: github.com/prometheus/common
+ version: 49fee292b27bfff7f354ee0f64e1bc4850462edf
+- package: github.com/prometheus/procfs
+ version: a1dba9ce8baed984a2495b658c82687f8157b98f
+- package: github.com/spf13/cobra
+ version: 1c44ec8d3f1552cac48999f9306da23c4d8a288b
+- package: github.com/spf13/pflag
+ version: 08b1a584251b5b62f458943640fc8ebd4d50aaa5
+- package: github.com/ugorji/go
+ version: ded73eae5db7e7a0ef6f55aace87a2873c5d2b74
+ subpackages:
+ - codec
+- package: github.com/urfave/cli
+ version: v1.18.0
+- package: github.com/xiang90/probing
+ version: 07dd2e8dfe18522e9c447ba95f2fe95262f63bb2
+- package: github.com/grpc-ecosystem/go-grpc-prometheus
+ version: v1.1
+- package: golang.org/x/crypto
+ version: 1351f936d976c60a0a48d728281922cf63eafb8d
+ subpackages:
+ - bcrypt
+ - blowfish
+- package: golang.org/x/net
+ version: c8c74377599bd978aee1cf3b9b63a8634051cec2
+ subpackages:
+ - context
+ - http2
+ - http2/hpack
+ - internal/timeseries
+ - trace
+- package: golang.org/x/sys
+ version: e48874b42435b4347fc52bdee0424a52abc974d7
+- package: golang.org/x/time
+ version: c06e80d9300e4443158a03817b8a8cb37d230320
+ subpackages:
+ - rate
+- package: google.golang.org/grpc
+ version: v1.2.1
+ subpackages:
+ - codes
+ - credentials
+ - grpclog
+ - internal
+ - metadata
+ - naming
+ - peer
+ - transport
+- package: gopkg.in/cheggaaa/pb.v1
+ version: v1.0.2
+- package: gopkg.in/yaml.v2
+ version: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b
+- package: github.com/dgrijalva/jwt-go
+ version: v3.0.0
diff --git a/vendor/github.com/coreos/etcd/hack/README.md b/vendor/github.com/coreos/etcd/hack/README.md
new file mode 100644
index 00000000..9392dc15
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/README.md
@@ -0,0 +1 @@
+Various hacks that are used by developers.
diff --git a/vendor/github.com/coreos/etcd/hack/benchmark/README.md b/vendor/github.com/coreos/etcd/hack/benchmark/README.md
new file mode 100644
index 00000000..6a09c530
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/benchmark/README.md
@@ -0,0 +1,14 @@
+## Usage
+
+Benchmark 3-member etcd cluster to get its read and write performance.
+
+## Instructions
+
+1. Start 3-member etcd cluster on 3 machines
+2. Update `$leader` and `$servers` in the script
+3. Run the script in a separate machine
+
+## Caveat
+
+1. Set environment variable `GOMAXPROCS` as the number of available cores to maximize CPU resources for both etcd member and bench process.
+2. Set the number of open files per process as 10000 for amounts of client connections for both etcd member and benchmark process.
diff --git a/vendor/github.com/coreos/etcd/hack/benchmark/bench.sh b/vendor/github.com/coreos/etcd/hack/benchmark/bench.sh
new file mode 100644
index 00000000..3955d9e6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/benchmark/bench.sh
@@ -0,0 +1,65 @@
+#!/bin/bash -e
+
+leader=http://10.240.201.15:2379
+# assume three servers
+servers=( http://10.240.201.15:2379 http://10.240.212.209:2379 http://10.240.95.3:2379 )
+
+keyarray=( 64 256 )
+
+for keysize in ${keyarray[@]}; do
+
+ echo write, 1 client, $keysize key size, to leader
+ ./hey -m PUT -n 10 -d value=`head -c $keysize < /dev/zero | tr '\0' '\141'` -c 1 -T application/x-www-form-urlencoded $leader/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%" | tr "\n" "\t" | xargs echo
+
+ echo write, 64 client, $keysize key size, to leader
+ ./hey -m PUT -n 640 -d value=`head -c $keysize < /dev/zero | tr '\0' '\141'` -c 64 -T application/x-www-form-urlencoded $leader/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%" | tr "\n" "\t" | xargs echo
+
+ echo write, 256 client, $keysize key size, to leader
+ ./hey -m PUT -n 2560 -d value=`head -c $keysize < /dev/zero | tr '\0' '\141'` -c 256 -T application/x-www-form-urlencoded $leader/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%" | tr "\n" "\t" | xargs echo
+
+ echo write, 64 client, $keysize key size, to all servers
+ for i in ${servers[@]}; do
+ ./hey -m PUT -n 210 -d value=`head -c $keysize < /dev/zero | tr '\0' '\141'` -c 21 -T application/x-www-form-urlencoded $i/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%" | tr "\n" "\t" | xargs echo &
+ done
+ # wait for all heys to start running
+ sleep 3
+ # wait for all heys to finish
+ for pid in $(pgrep 'hey'); do
+ while kill -0 "$pid" 2> /dev/null; do
+ sleep 3
+ done
+ done
+
+ echo write, 256 client, $keysize key size, to all servers
+ for i in ${servers[@]}; do
+ ./hey -m PUT -n 850 -d value=`head -c $keysize < /dev/zero | tr '\0' '\141'` -c 85 -T application/x-www-form-urlencoded $i/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%" | tr "\n" "\t" | xargs echo &
+ done
+ sleep 3
+ for pid in $(pgrep 'hey'); do
+ while kill -0 "$pid" 2> /dev/null; do
+ sleep 3
+ done
+ done
+
+ echo read, 1 client, $keysize key size, to leader
+ ./hey -n 100 -c 1 $leader/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%" | tr "\n" "\t" | xargs echo
+
+ echo read, 64 client, $keysize key size, to leader
+ ./hey -n 6400 -c 64 $leader/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%" | tr "\n" "\t" | xargs echo
+
+ echo read, 256 client, $keysize key size, to leader
+ ./hey -n 25600 -c 256 $leader/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%" | tr "\n" "\t" | xargs echo
+
+ echo read, 64 client, $keysize key size, to all servers
+ # bench servers one by one, so it doesn't overload this benchmark machine
+ # It doesn't impact correctness because read request doesn't involve peer interaction.
+ for i in ${servers[@]}; do
+ ./hey -n 21000 -c 21 $i/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%" | tr "\n" "\t" | xargs echo
+ done
+
+ echo read, 256 client, $keysize key size, to all servers
+ for i in ${servers[@]}; do
+ ./hey -n 85000 -c 85 $i/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%" | tr "\n" "\t" | xargs echo
+ done
+
+done
diff --git a/vendor/github.com/coreos/etcd/hack/insta-discovery/Procfile b/vendor/github.com/coreos/etcd/hack/insta-discovery/Procfile
new file mode 100644
index 00000000..b35eb450
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/insta-discovery/Procfile
@@ -0,0 +1,6 @@
+# Use goreman to run `go get github.com/mattn/goreman`
+# One of the four etcd members falls back to a proxy
+etcd1: ../../bin/etcd --name infra1 --listen-client-urls http://127.0.0.1:2379 --advertise-client-urls http://127.0.0.1:2379 --listen-peer-urls http://127.0.0.1:2380 --initial-advertise-peer-urls http://127.0.0.1:2380
+etcd2: ../../bin/etcd --name infra2 --listen-client-urls http://127.0.0.1:12379 --advertise-client-urls http://127.0.0.1:12379 --listen-peer-urls http://127.0.0.1:12380 --initial-advertise-peer-urls http://127.0.0.1:12380
+etcd3: ../../bin/etcd --name infra3 --listen-client-urls http://127.0.0.1:22379 --advertise-client-urls http://127.0.0.1:22379 --listen-peer-urls http://127.0.0.1:22380 --initial-advertise-peer-urls http://127.0.0.1:22380
+etcd4: ../../bin/etcd --name infra4 --listen-client-urls http://127.0.0.1:32379 --advertise-client-urls http://127.0.0.1:32379 --listen-peer-urls http://127.0.0.1:32380 --initial-advertise-peer-urls http://127.0.0.1:32380
diff --git a/vendor/github.com/coreos/etcd/hack/insta-discovery/README.md b/vendor/github.com/coreos/etcd/hack/insta-discovery/README.md
new file mode 100644
index 00000000..e1252b9d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/insta-discovery/README.md
@@ -0,0 +1 @@
+Starts a cluster via the discovery service locally. Useful for testing.
diff --git a/vendor/github.com/coreos/etcd/hack/insta-discovery/discovery b/vendor/github.com/coreos/etcd/hack/insta-discovery/discovery
new file mode 100755
index 00000000..b33b1512
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/insta-discovery/discovery
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+rm -rf infra*.etcd
+disc=$(curl -s https://discovery.etcd.io/new?size=3)
+echo ETCD_DISCOVERY=${disc} > .env
+echo "setup discovery start your cluster"
+cat .env
+goreman start
diff --git a/vendor/github.com/coreos/etcd/hack/kubernetes-deploy/README.md b/vendor/github.com/coreos/etcd/hack/kubernetes-deploy/README.md
new file mode 100644
index 00000000..bd34115d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/kubernetes-deploy/README.md
@@ -0,0 +1,21 @@
+# etcd on Kubernetes
+
+This is an example setting up etcd as a set of pods and services running on top of kubernetes. Using:
+
+```
+$ kubectl create -f etcd.yml
+services/etcd-client
+pods/etcd0
+services/etcd0
+pods/etcd1
+services/etcd1
+pods/etcd2
+services/etcd2
+$ # now deploy a service that consumes etcd, such as vulcand
+$ kubectl create -f vulcand.yml
+```
+
+TODO:
+
+- create a replication controller like service that knows how to add and remove nodes from the cluster correctly
+- use kubernetes secrets API to configure TLS for etcd clients and peers
diff --git a/vendor/github.com/coreos/etcd/hack/kubernetes-deploy/etcd.yml b/vendor/github.com/coreos/etcd/hack/kubernetes-deploy/etcd.yml
new file mode 100644
index 00000000..55a92174
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/kubernetes-deploy/etcd.yml
@@ -0,0 +1,189 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: etcd-client
+spec:
+ ports:
+ - name: etcd-client-port
+ port: 2379
+ protocol: TCP
+ targetPort: 2379
+ selector:
+ app: etcd
+
+---
+
+apiVersion: v1
+kind: Pod
+metadata:
+ labels:
+ app: etcd
+ etcd_node: etcd0
+ name: etcd0
+spec:
+ containers:
+ - command:
+ - /usr/local/bin/etcd
+ - --name
+ - etcd0
+ - --initial-advertise-peer-urls
+ - http://etcd0:2380
+ - --listen-peer-urls
+ - http://0.0.0.0:2380
+ - --listen-client-urls
+ - http://0.0.0.0:2379
+ - --advertise-client-urls
+ - http://etcd0:2379
+ - --initial-cluster
+ - etcd0=http://etcd0:2380,etcd1=http://etcd1:2380,etcd2=http://etcd2:2380
+ - --initial-cluster-state
+ - new
+ image: quay.io/coreos/etcd:latest
+ name: etcd0
+ ports:
+ - containerPort: 2379
+ name: client
+ protocol: TCP
+ - containerPort: 2380
+ name: server
+ protocol: TCP
+ restartPolicy: Never
+
+---
+
+apiVersion: v1
+kind: Service
+metadata:
+ labels:
+ etcd_node: etcd0
+ name: etcd0
+spec:
+ ports:
+ - name: client
+ port: 2379
+ protocol: TCP
+ targetPort: 2379
+ - name: server
+ port: 2380
+ protocol: TCP
+ targetPort: 2380
+ selector:
+ etcd_node: etcd0
+
+---
+
+apiVersion: v1
+kind: Pod
+metadata:
+ labels:
+ app: etcd
+ etcd_node: etcd1
+ name: etcd1
+spec:
+ containers:
+ - command:
+ - /usr/local/bin/etcd
+ - --name
+ - etcd1
+ - --initial-advertise-peer-urls
+ - http://etcd1:2380
+ - --listen-peer-urls
+ - http://0.0.0.0:2380
+ - --listen-client-urls
+ - http://0.0.0.0:2379
+ - --advertise-client-urls
+ - http://etcd1:2379
+ - --initial-cluster
+ - etcd0=http://etcd0:2380,etcd1=http://etcd1:2380,etcd2=http://etcd2:2380
+ - --initial-cluster-state
+ - new
+ image: quay.io/coreos/etcd:latest
+ name: etcd1
+ ports:
+ - containerPort: 2379
+ name: client
+ protocol: TCP
+ - containerPort: 2380
+ name: server
+ protocol: TCP
+ restartPolicy: Never
+
+---
+
+apiVersion: v1
+kind: Service
+metadata:
+ labels:
+ etcd_node: etcd1
+ name: etcd1
+spec:
+ ports:
+ - name: client
+ port: 2379
+ protocol: TCP
+ targetPort: 2379
+ - name: server
+ port: 2380
+ protocol: TCP
+ targetPort: 2380
+ selector:
+ etcd_node: etcd1
+
+---
+
+apiVersion: v1
+kind: Pod
+metadata:
+ labels:
+ app: etcd
+ etcd_node: etcd2
+ name: etcd2
+spec:
+ containers:
+ - command:
+ - /usr/local/bin/etcd
+ - --name
+ - etcd2
+ - --initial-advertise-peer-urls
+ - http://etcd2:2380
+ - --listen-peer-urls
+ - http://0.0.0.0:2380
+ - --listen-client-urls
+ - http://0.0.0.0:2379
+ - --advertise-client-urls
+ - http://etcd2:2379
+ - --initial-cluster
+ - etcd0=http://etcd0:2380,etcd1=http://etcd1:2380,etcd2=http://etcd2:2380
+ - --initial-cluster-state
+ - new
+ image: quay.io/coreos/etcd:latest
+ name: etcd2
+ ports:
+ - containerPort: 2379
+ name: client
+ protocol: TCP
+ - containerPort: 2380
+ name: server
+ protocol: TCP
+ restartPolicy: Never
+
+---
+
+apiVersion: v1
+kind: Service
+metadata:
+ labels:
+ etcd_node: etcd2
+ name: etcd2
+spec:
+ ports:
+ - name: client
+ port: 2379
+ protocol: TCP
+ targetPort: 2379
+ - name: server
+ port: 2380
+ protocol: TCP
+ targetPort: 2380
+ selector:
+ etcd_node: etcd2
diff --git a/vendor/github.com/coreos/etcd/hack/kubernetes-deploy/vulcand.yml b/vendor/github.com/coreos/etcd/hack/kubernetes-deploy/vulcand.yml
new file mode 100644
index 00000000..bb61eec4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/kubernetes-deploy/vulcand.yml
@@ -0,0 +1,22 @@
+apiVersion: v1
+kind: Pod
+metadata:
+ labels:
+ app: vulcand
+ name: vulcand
+spec:
+ containers:
+ - command:
+ - /go/bin/vulcand
+ - -apiInterface=0.0.0.0
+ - --etcd=http://etcd-client:2379
+ image: mailgun/vulcand:v0.8.0-beta.2
+ name: vulcand
+ ports:
+ - containerPort: 8081
+ name: api
+ protocol: TCP
+ - containerPort: 8082
+ name: server
+ protocol: TCP
+ restartPolicy: Always
diff --git a/vendor/github.com/coreos/etcd/hack/tls-setup/Makefile b/vendor/github.com/coreos/etcd/hack/tls-setup/Makefile
new file mode 100644
index 00000000..96ad3830
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/tls-setup/Makefile
@@ -0,0 +1,41 @@
+.PHONY: cfssl ca req clean
+
+CFSSL = @env PATH=$(GOPATH)/bin:$(PATH) cfssl
+JSON = env PATH=$(GOPATH)/bin:$(PATH) cfssljson
+
+all: cfssl ca req
+
+cfssl:
+ go get -u -tags nopkcs11 github.com/cloudflare/cfssl/cmd/cfssl
+ go get -u github.com/cloudflare/cfssl/cmd/cfssljson
+ go get -u github.com/mattn/goreman
+
+ca:
+ mkdir -p certs
+ $(CFSSL) gencert -initca config/ca-csr.json | $(JSON) -bare certs/ca
+
+req:
+ $(CFSSL) gencert \
+ -ca certs/ca.pem \
+ -ca-key certs/ca-key.pem \
+ -config config/ca-config.json \
+ config/req-csr.json | $(JSON) -bare certs/etcd1
+ $(CFSSL) gencert \
+ -ca certs/ca.pem \
+ -ca-key certs/ca-key.pem \
+ -config config/ca-config.json \
+ config/req-csr.json | $(JSON) -bare certs/etcd2
+ $(CFSSL) gencert \
+ -ca certs/ca.pem \
+ -ca-key certs/ca-key.pem \
+ -config config/ca-config.json \
+ config/req-csr.json | $(JSON) -bare certs/etcd3
+ $(CFSSL) gencert \
+ -ca certs/ca.pem \
+ -ca-key certs/ca-key.pem \
+ -config config/ca-config.json \
+ config/req-csr.json | $(JSON) -bare certs/proxy1
+
+clean:
+ rm -rf certs
+
diff --git a/vendor/github.com/coreos/etcd/hack/tls-setup/Procfile b/vendor/github.com/coreos/etcd/hack/tls-setup/Procfile
new file mode 100644
index 00000000..f3532ca8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/tls-setup/Procfile
@@ -0,0 +1,9 @@
+# Use goreman to run `go get github.com/mattn/goreman`
+etcd1: ../../bin/etcd --name infra1 --listen-client-urls https://localhost:2379 --advertise-client-urls https://localhost:2379 --listen-peer-urls https://localhost:2380 --initial-advertise-peer-urls https://localhost:2380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=https://localhost:2380,infra2=https://localhost:12380,infra3=https://localhost:22380' --initial-cluster-state new --cert-file=certs/etcd1.pem --key-file=certs/etcd1-key.pem --peer-cert-file=certs/etcd1.pem --peer-key-file=certs/etcd1-key.pem --peer-client-cert-auth --peer-trusted-ca-file=certs/ca.pem
+
+etcd2: ../../bin/etcd --name infra2 --listen-client-urls https://localhost:12379 --advertise-client-urls https://localhost:12379 --listen-peer-urls https://localhost:12380 --initial-advertise-peer-urls https://localhost:12380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=https://localhost:2380,infra2=https://localhost:12380,infra3=https://localhost:22380' --initial-cluster-state new --cert-file=certs/etcd2.pem --key-file=certs/etcd2-key.pem --peer-cert-file=certs/etcd2.pem --peer-key-file=certs/etcd2-key.pem --peer-client-cert-auth --peer-trusted-ca-file=certs/ca.pem
+
+etcd3: ../../bin/etcd --name infra3 --listen-client-urls https://localhost:22379 --advertise-client-urls https://localhost:22379 --listen-peer-urls https://localhost:22380 --initial-advertise-peer-urls https://localhost:22380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=https://localhost:2380,infra2=https://localhost:12380,infra3=https://localhost:22380' --initial-cluster-state new --cert-file=certs/etcd3.pem --key-file=certs/etcd3-key.pem --peer-cert-file=certs/etcd3.pem --peer-key-file=certs/etcd3-key.pem --peer-client-cert-auth --peer-trusted-ca-file=certs/ca.pem
+
+proxy: ../../bin/etcd --name proxy1 --proxy=on --listen-client-urls https://localhost:8080 --initial-cluster 'infra1=https://localhost:2380,infra2=https://localhost:12380,infra3=https://localhost:22380' --cert-file=certs/proxy1.pem --key-file=certs/proxy1-key.pem --trusted-ca-file=certs/ca.pem --peer-cert-file=certs/proxy1.pem --peer-key-file=certs/proxy1-key.pem --peer-client-cert-auth --peer-trusted-ca-file=certs/ca.pem
+
diff --git a/vendor/github.com/coreos/etcd/hack/tls-setup/README.md b/vendor/github.com/coreos/etcd/hack/tls-setup/README.md
new file mode 100644
index 00000000..9f687395
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/tls-setup/README.md
@@ -0,0 +1,31 @@
+This demonstrates using Cloudflare's [cfssl](https://github.com/cloudflare/cfssl) to easily generate certificates for an etcd cluster.
+
+Defaults generate an ECDSA-384 root and leaf certificates for `localhost`. etcd nodes will use the same certificates for both sides of mutual authentication, but won't require client certs for non-peer clients.
+
+**Instructions**
+
+1. Install git, go, and make
+2. Amend https://github.com/coreos/etcd/blob/master/hack/tls-setup/config/req-csr.json - IP's currently in the config should be replaced/added with IP addresses of each cluster node, please note 127.0.0.1 is always required for loopback purposes:
+```json
+Example:
+{
+ "CN": "etcd",
+ "hosts": [
+ "3.8.121.201",
+ "46.4.19.20",
+ "127.0.0.1"
+ ],
+ "key": {
+ "algo": "ecdsa",
+ "size": 384
+ },
+ "names": [
+ {
+ "O": "autogenerated",
+ "OU": "etcd cluster",
+ "L": "the internet"
+ }
+ ]
+}
+```
+3. Run `make` to generate the certs
diff --git a/vendor/github.com/coreos/etcd/hack/tls-setup/config/ca-config.json b/vendor/github.com/coreos/etcd/hack/tls-setup/config/ca-config.json
new file mode 100644
index 00000000..e492de1a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/tls-setup/config/ca-config.json
@@ -0,0 +1,13 @@
+{
+ "signing": {
+ "default": {
+ "usages": [
+ "signing",
+ "key encipherment",
+ "server auth",
+ "client auth"
+ ],
+ "expiry": "8760h"
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/hack/tls-setup/config/ca-csr.json b/vendor/github.com/coreos/etcd/hack/tls-setup/config/ca-csr.json
new file mode 100644
index 00000000..4d7dd753
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/tls-setup/config/ca-csr.json
@@ -0,0 +1,16 @@
+{
+ "CN": "Autogenerated CA",
+ "key": {
+ "algo": "ecdsa",
+ "size": 384
+ },
+ "names": [
+ {
+ "O": "Honest Achmed's Used Certificates",
+ "OU": "Hastily-Generated Values Divison",
+ "L": "San Francisco",
+ "ST": "California",
+ "C": "US"
+ }
+ ]
+}
diff --git a/vendor/github.com/coreos/etcd/hack/tls-setup/config/req-csr.json b/vendor/github.com/coreos/etcd/hack/tls-setup/config/req-csr.json
new file mode 100644
index 00000000..a91ffc90
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/hack/tls-setup/config/req-csr.json
@@ -0,0 +1,17 @@
+{
+ "CN": "etcd",
+ "hosts": [
+ "localhost"
+ ],
+ "key": {
+ "algo": "ecdsa",
+ "size": 384
+ },
+ "names": [
+ {
+ "O": "autogenerated",
+ "OU": "etcd cluster",
+ "L": "the internet"
+ }
+ ]
+}
diff --git a/vendor/github.com/coreos/etcd/integration/bridge.go b/vendor/github.com/coreos/etcd/integration/bridge.go
new file mode 100644
index 00000000..b9e67318
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/bridge.go
@@ -0,0 +1,181 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "fmt"
+ "io"
+ "net"
+ "sync"
+
+ "github.com/coreos/etcd/pkg/transport"
+)
+
+// bridge creates a unix socket bridge to another unix socket, making it possible
+// to disconnect grpc network connections without closing the logical grpc connection.
+type bridge struct {
+ inaddr string
+ outaddr string
+ l net.Listener
+ conns map[*bridgeConn]struct{}
+
+ stopc chan struct{}
+ pausec chan struct{}
+ wg sync.WaitGroup
+
+ mu sync.Mutex
+}
+
+func newBridge(addr string) (*bridge, error) {
+ b := &bridge{
+ // bridge "port" is ("%05d%05d0", port, pid) since go1.8 expects the port to be a number
+ inaddr: addr + "0",
+ outaddr: addr,
+ conns: make(map[*bridgeConn]struct{}),
+ stopc: make(chan struct{}),
+ pausec: make(chan struct{}),
+ }
+ close(b.pausec)
+
+ l, err := transport.NewUnixListener(b.inaddr)
+ if err != nil {
+ return nil, fmt.Errorf("listen failed on socket %s (%v)", addr, err)
+ }
+ b.l = l
+ b.wg.Add(1)
+ go b.serveListen()
+ return b, nil
+}
+
+func (b *bridge) URL() string { return "unix://" + b.inaddr }
+
+func (b *bridge) Close() {
+ b.l.Close()
+ b.mu.Lock()
+ select {
+ case <-b.stopc:
+ default:
+ close(b.stopc)
+ }
+ b.mu.Unlock()
+ b.wg.Wait()
+}
+
+func (b *bridge) Reset() {
+ b.mu.Lock()
+ defer b.mu.Unlock()
+ for bc := range b.conns {
+ bc.Close()
+ }
+ b.conns = make(map[*bridgeConn]struct{})
+}
+
+func (b *bridge) Pause() {
+ b.mu.Lock()
+ b.pausec = make(chan struct{})
+ b.mu.Unlock()
+}
+
+func (b *bridge) Unpause() {
+ b.mu.Lock()
+ select {
+ case <-b.pausec:
+ default:
+ close(b.pausec)
+ }
+ b.mu.Unlock()
+}
+
+func (b *bridge) serveListen() {
+ defer func() {
+ b.l.Close()
+ b.mu.Lock()
+ for bc := range b.conns {
+ bc.Close()
+ }
+ b.mu.Unlock()
+ b.wg.Done()
+ }()
+
+ for {
+ inc, ierr := b.l.Accept()
+ if ierr != nil {
+ return
+ }
+ b.mu.Lock()
+ pausec := b.pausec
+ b.mu.Unlock()
+ select {
+ case <-b.stopc:
+ inc.Close()
+ return
+ case <-pausec:
+ }
+
+ outc, oerr := net.Dial("unix", b.outaddr)
+ if oerr != nil {
+ inc.Close()
+ return
+ }
+
+ bc := &bridgeConn{inc, outc, make(chan struct{})}
+ b.wg.Add(1)
+ b.mu.Lock()
+ b.conns[bc] = struct{}{}
+ go b.serveConn(bc)
+ b.mu.Unlock()
+ }
+}
+
+func (b *bridge) serveConn(bc *bridgeConn) {
+ defer func() {
+ close(bc.donec)
+ bc.Close()
+ b.mu.Lock()
+ delete(b.conns, bc)
+ b.mu.Unlock()
+ b.wg.Done()
+ }()
+
+ var wg sync.WaitGroup
+ wg.Add(2)
+ go func() {
+ io.Copy(bc.out, bc.in)
+ bc.close()
+ wg.Done()
+ }()
+ go func() {
+ io.Copy(bc.in, bc.out)
+ bc.close()
+ wg.Done()
+ }()
+ wg.Wait()
+}
+
+type bridgeConn struct {
+ in net.Conn
+ out net.Conn
+ donec chan struct{}
+}
+
+func (bc *bridgeConn) Close() {
+ bc.close()
+ <-bc.donec
+}
+
+func (bc *bridgeConn) close() {
+ bc.in.Close()
+ bc.out.Close()
+}
diff --git a/vendor/github.com/coreos/etcd/integration/cluster.go b/vendor/github.com/coreos/etcd/integration/cluster.go
new file mode 100644
index 00000000..18c526bb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/cluster.go
@@ -0,0 +1,943 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "crypto/tls"
+ "fmt"
+ "io/ioutil"
+ "math/rand"
+ "net"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "reflect"
+ "sort"
+ "strings"
+ "sync"
+ "sync/atomic"
+ "testing"
+ "time"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+
+ "github.com/coreos/etcd/client"
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api/etcdhttp"
+ "github.com/coreos/etcd/etcdserver/api/v2http"
+ "github.com/coreos/etcd/etcdserver/api/v3client"
+ "github.com/coreos/etcd/etcdserver/api/v3election"
+ epb "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb"
+ "github.com/coreos/etcd/etcdserver/api/v3lock"
+ lockpb "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/pkg/transport"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/rafthttp"
+ "github.com/coreos/pkg/capnslog"
+)
+
+const (
+ tickDuration = 10 * time.Millisecond
+ clusterName = "etcd"
+ requestTimeout = 20 * time.Second
+
+ basePort = 21000
+ UrlScheme = "unix"
+ UrlSchemeTLS = "unixs"
+)
+
+var (
+ electionTicks = 10
+
+ // integration test uses unique ports, counting up, to listen for each
+ // member, ensuring restarted members can listen on the same port again.
+ localListenCount int64 = 0
+
+ testTLSInfo = transport.TLSInfo{
+ KeyFile: "./fixtures/server.key.insecure",
+ CertFile: "./fixtures/server.crt",
+ TrustedCAFile: "./fixtures/ca.crt",
+ ClientCertAuth: true,
+ }
+
+ testTLSInfoExpired = transport.TLSInfo{
+ KeyFile: "./fixtures-expired/server-key.pem",
+ CertFile: "./fixtures-expired/server.pem",
+ TrustedCAFile: "./fixtures-expired/etcd-root-ca.pem",
+ ClientCertAuth: true,
+ }
+
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "integration")
+)
+
+type ClusterConfig struct {
+ Size int
+ PeerTLS *transport.TLSInfo
+ ClientTLS *transport.TLSInfo
+ DiscoveryURL string
+ UseGRPC bool
+ QuotaBackendBytes int64
+}
+
+type cluster struct {
+ cfg *ClusterConfig
+ Members []*member
+}
+
+func schemeFromTLSInfo(tls *transport.TLSInfo) string {
+ if tls == nil {
+ return UrlScheme
+ }
+ return UrlSchemeTLS
+}
+
+func (c *cluster) fillClusterForMembers() error {
+ if c.cfg.DiscoveryURL != "" {
+ // cluster will be discovered
+ return nil
+ }
+
+ addrs := make([]string, 0)
+ for _, m := range c.Members {
+ scheme := schemeFromTLSInfo(m.PeerTLSInfo)
+ for _, l := range m.PeerListeners {
+ addrs = append(addrs, fmt.Sprintf("%s=%s://%s", m.Name, scheme, l.Addr().String()))
+ }
+ }
+ clusterStr := strings.Join(addrs, ",")
+ var err error
+ for _, m := range c.Members {
+ m.InitialPeerURLsMap, err = types.NewURLsMap(clusterStr)
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func newCluster(t *testing.T, cfg *ClusterConfig) *cluster {
+ c := &cluster{cfg: cfg}
+ ms := make([]*member, cfg.Size)
+ for i := 0; i < cfg.Size; i++ {
+ ms[i] = c.mustNewMember(t)
+ }
+ c.Members = ms
+ if err := c.fillClusterForMembers(); err != nil {
+ t.Fatal(err)
+ }
+
+ return c
+}
+
+// NewCluster returns an unlaunched cluster of the given size which has been
+// set to use static bootstrap.
+func NewCluster(t *testing.T, size int) *cluster {
+ return newCluster(t, &ClusterConfig{Size: size})
+}
+
+// NewClusterByConfig returns an unlaunched cluster defined by a cluster configuration
+func NewClusterByConfig(t *testing.T, cfg *ClusterConfig) *cluster {
+ return newCluster(t, cfg)
+}
+
+func (c *cluster) Launch(t *testing.T) {
+ errc := make(chan error)
+ for _, m := range c.Members {
+ // Members are launched in separate goroutines because if they boot
+ // using discovery url, they have to wait for others to register to continue.
+ go func(m *member) {
+ errc <- m.Launch()
+ }(m)
+ }
+ for range c.Members {
+ if err := <-errc; err != nil {
+ t.Fatalf("error setting up member: %v", err)
+ }
+ }
+ // wait cluster to be stable to receive future client requests
+ c.waitMembersMatch(t, c.HTTPMembers())
+ c.waitVersion()
+}
+
+func (c *cluster) URL(i int) string {
+ return c.Members[i].ClientURLs[0].String()
+}
+
+// URLs returns a list of all active client URLs in the cluster
+func (c *cluster) URLs() []string {
+ return getMembersURLs(c.Members)
+}
+
+func getMembersURLs(members []*member) []string {
+ urls := make([]string, 0)
+ for _, m := range members {
+ select {
+ case <-m.s.StopNotify():
+ continue
+ default:
+ }
+ for _, u := range m.ClientURLs {
+ urls = append(urls, u.String())
+ }
+ }
+ return urls
+}
+
+// HTTPMembers returns a list of all active members as client.Members
+func (c *cluster) HTTPMembers() []client.Member {
+ ms := []client.Member{}
+ for _, m := range c.Members {
+ pScheme := schemeFromTLSInfo(m.PeerTLSInfo)
+ cScheme := schemeFromTLSInfo(m.ClientTLSInfo)
+ cm := client.Member{Name: m.Name}
+ for _, ln := range m.PeerListeners {
+ cm.PeerURLs = append(cm.PeerURLs, pScheme+"://"+ln.Addr().String())
+ }
+ for _, ln := range m.ClientListeners {
+ cm.ClientURLs = append(cm.ClientURLs, cScheme+"://"+ln.Addr().String())
+ }
+ ms = append(ms, cm)
+ }
+ return ms
+}
+
+func (c *cluster) mustNewMember(t *testing.T) *member {
+ m := mustNewMember(t,
+ memberConfig{
+ name: c.name(rand.Int()),
+ peerTLS: c.cfg.PeerTLS,
+ clientTLS: c.cfg.ClientTLS,
+ quotaBackendBytes: c.cfg.QuotaBackendBytes,
+ })
+ m.DiscoveryURL = c.cfg.DiscoveryURL
+ if c.cfg.UseGRPC {
+ if err := m.listenGRPC(); err != nil {
+ t.Fatal(err)
+ }
+ }
+ return m
+}
+
+func (c *cluster) addMember(t *testing.T) {
+ m := c.mustNewMember(t)
+
+ scheme := schemeFromTLSInfo(c.cfg.PeerTLS)
+
+ // send add request to the cluster
+ var err error
+ for i := 0; i < len(c.Members); i++ {
+ clientURL := c.URL(i)
+ peerURL := scheme + "://" + m.PeerListeners[0].Addr().String()
+ if err = c.addMemberByURL(t, clientURL, peerURL); err == nil {
+ break
+ }
+ }
+ if err != nil {
+ t.Fatalf("add member failed on all members error: %v", err)
+ }
+
+ m.InitialPeerURLsMap = types.URLsMap{}
+ for _, mm := range c.Members {
+ m.InitialPeerURLsMap[mm.Name] = mm.PeerURLs
+ }
+ m.InitialPeerURLsMap[m.Name] = m.PeerURLs
+ m.NewCluster = false
+ if err := m.Launch(); err != nil {
+ t.Fatal(err)
+ }
+ c.Members = append(c.Members, m)
+ // wait cluster to be stable to receive future client requests
+ c.waitMembersMatch(t, c.HTTPMembers())
+}
+
+func (c *cluster) addMemberByURL(t *testing.T, clientURL, peerURL string) error {
+ cc := MustNewHTTPClient(t, []string{clientURL}, c.cfg.ClientTLS)
+ ma := client.NewMembersAPI(cc)
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ if _, err := ma.Add(ctx, peerURL); err != nil {
+ return err
+ }
+ cancel()
+
+ // wait for the add node entry applied in the cluster
+ members := append(c.HTTPMembers(), client.Member{PeerURLs: []string{peerURL}, ClientURLs: []string{}})
+ c.waitMembersMatch(t, members)
+ return nil
+}
+
+func (c *cluster) AddMember(t *testing.T) {
+ c.addMember(t)
+}
+
+func (c *cluster) RemoveMember(t *testing.T, id uint64) {
+ if err := c.removeMember(t, id); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func (c *cluster) removeMember(t *testing.T, id uint64) error {
+ // send remove request to the cluster
+ cc := MustNewHTTPClient(t, c.URLs(), c.cfg.ClientTLS)
+ ma := client.NewMembersAPI(cc)
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ if err := ma.Remove(ctx, types.ID(id).String()); err != nil {
+ return err
+ }
+ cancel()
+ newMembers := make([]*member, 0)
+ for _, m := range c.Members {
+ if uint64(m.s.ID()) != id {
+ newMembers = append(newMembers, m)
+ } else {
+ select {
+ case <-m.s.StopNotify():
+ m.Terminate(t)
+ // 1s stop delay + election timeout + 1s disk and network delay + connection write timeout
+ // TODO: remove connection write timeout by selecting on http response closeNotifier
+ // blocking on https://github.com/golang/go/issues/9524
+ case <-time.After(time.Second + time.Duration(electionTicks)*tickDuration + time.Second + rafthttp.ConnWriteTimeout):
+ t.Fatalf("failed to remove member %s in time", m.s.ID())
+ }
+ }
+ }
+ c.Members = newMembers
+ c.waitMembersMatch(t, c.HTTPMembers())
+ return nil
+}
+
+func (c *cluster) Terminate(t *testing.T) {
+ var wg sync.WaitGroup
+ wg.Add(len(c.Members))
+ for _, m := range c.Members {
+ go func(mm *member) {
+ defer wg.Done()
+ mm.Terminate(t)
+ }(m)
+ }
+ wg.Wait()
+}
+
+func (c *cluster) waitMembersMatch(t *testing.T, membs []client.Member) {
+ for _, u := range c.URLs() {
+ cc := MustNewHTTPClient(t, []string{u}, c.cfg.ClientTLS)
+ ma := client.NewMembersAPI(cc)
+ for {
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ ms, err := ma.List(ctx)
+ cancel()
+ if err == nil && isMembersEqual(ms, membs) {
+ break
+ }
+ time.Sleep(tickDuration)
+ }
+ }
+}
+
+func (c *cluster) WaitLeader(t *testing.T) int { return c.waitLeader(t, c.Members) }
+
+// waitLeader waits until given members agree on the same leader.
+func (c *cluster) waitLeader(t *testing.T, membs []*member) int {
+ possibleLead := make(map[uint64]bool)
+ var lead uint64
+ for _, m := range membs {
+ possibleLead[uint64(m.s.ID())] = true
+ }
+ cc := MustNewHTTPClient(t, getMembersURLs(membs), nil)
+ kapi := client.NewKeysAPI(cc)
+
+ // ensure leader is up via linearizable get
+ for {
+ ctx, cancel := context.WithTimeout(context.Background(), 10*tickDuration)
+ _, err := kapi.Get(ctx, "0", &client.GetOptions{Quorum: true})
+ cancel()
+ if err == nil || strings.Contains(err.Error(), "Key not found") {
+ break
+ }
+ }
+
+ for lead == 0 || !possibleLead[lead] {
+ lead = 0
+ for _, m := range membs {
+ select {
+ case <-m.s.StopNotify():
+ continue
+ default:
+ }
+ if lead != 0 && lead != m.s.Lead() {
+ lead = 0
+ time.Sleep(10 * tickDuration)
+ break
+ }
+ lead = m.s.Lead()
+ }
+ }
+
+ for i, m := range membs {
+ if uint64(m.s.ID()) == lead {
+ return i
+ }
+ }
+
+ return -1
+}
+
+func (c *cluster) WaitNoLeader(t *testing.T) { c.waitNoLeader(t, c.Members) }
+
+// waitNoLeader waits until given members lose leader.
+func (c *cluster) waitNoLeader(t *testing.T, membs []*member) {
+ noLeader := false
+ for !noLeader {
+ noLeader = true
+ for _, m := range membs {
+ select {
+ case <-m.s.StopNotify():
+ continue
+ default:
+ }
+ if m.s.Lead() != 0 {
+ noLeader = false
+ time.Sleep(10 * tickDuration)
+ break
+ }
+ }
+ }
+}
+
+func (c *cluster) waitVersion() {
+ for _, m := range c.Members {
+ for {
+ if m.s.ClusterVersion() != nil {
+ break
+ }
+ time.Sleep(tickDuration)
+ }
+ }
+}
+
+func (c *cluster) name(i int) string {
+ return fmt.Sprint(i)
+}
+
+// isMembersEqual checks whether two members equal except ID field.
+// The given wmembs should always set ID field to empty string.
+func isMembersEqual(membs []client.Member, wmembs []client.Member) bool {
+ sort.Sort(SortableMemberSliceByPeerURLs(membs))
+ sort.Sort(SortableMemberSliceByPeerURLs(wmembs))
+ for i := range membs {
+ membs[i].ID = ""
+ }
+ return reflect.DeepEqual(membs, wmembs)
+}
+
+func newLocalListener(t *testing.T) net.Listener {
+ c := atomic.AddInt64(&localListenCount, 1)
+ // Go 1.8+ allows only numbers in port
+ addr := fmt.Sprintf("127.0.0.1:%05d%05d", c+basePort, os.Getpid())
+ return NewListenerWithAddr(t, addr)
+}
+
+func NewListenerWithAddr(t *testing.T, addr string) net.Listener {
+ l, err := transport.NewUnixListener(addr)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return l
+}
+
+type member struct {
+ etcdserver.ServerConfig
+ PeerListeners, ClientListeners []net.Listener
+ grpcListener net.Listener
+ // PeerTLSInfo enables peer TLS when set
+ PeerTLSInfo *transport.TLSInfo
+ // ClientTLSInfo enables client TLS when set
+ ClientTLSInfo *transport.TLSInfo
+
+ raftHandler *testutil.PauseableHandler
+ s *etcdserver.EtcdServer
+ hss []*httptest.Server
+
+ grpcServer *grpc.Server
+ grpcAddr string
+ grpcBridge *bridge
+
+ // serverClient is a clientv3 that directly calls the etcdserver.
+ serverClient *clientv3.Client
+
+ keepDataDirTerminate bool
+}
+
+func (m *member) GRPCAddr() string { return m.grpcAddr }
+
+type memberConfig struct {
+ name string
+ peerTLS *transport.TLSInfo
+ clientTLS *transport.TLSInfo
+ quotaBackendBytes int64
+}
+
+// mustNewMember return an inited member with the given name. If peerTLS is
+// set, it will use https scheme to communicate between peers.
+func mustNewMember(t *testing.T, mcfg memberConfig) *member {
+ var err error
+ m := &member{}
+
+ peerScheme := schemeFromTLSInfo(mcfg.peerTLS)
+ clientScheme := schemeFromTLSInfo(mcfg.clientTLS)
+
+ pln := newLocalListener(t)
+ m.PeerListeners = []net.Listener{pln}
+ m.PeerURLs, err = types.NewURLs([]string{peerScheme + "://" + pln.Addr().String()})
+ if err != nil {
+ t.Fatal(err)
+ }
+ m.PeerTLSInfo = mcfg.peerTLS
+
+ cln := newLocalListener(t)
+ m.ClientListeners = []net.Listener{cln}
+ m.ClientURLs, err = types.NewURLs([]string{clientScheme + "://" + cln.Addr().String()})
+ if err != nil {
+ t.Fatal(err)
+ }
+ m.ClientTLSInfo = mcfg.clientTLS
+
+ m.Name = mcfg.name
+
+ m.DataDir, err = ioutil.TempDir(os.TempDir(), "etcd")
+ if err != nil {
+ t.Fatal(err)
+ }
+ clusterStr := fmt.Sprintf("%s=%s://%s", mcfg.name, peerScheme, pln.Addr().String())
+ m.InitialPeerURLsMap, err = types.NewURLsMap(clusterStr)
+ if err != nil {
+ t.Fatal(err)
+ }
+ m.InitialClusterToken = clusterName
+ m.NewCluster = true
+ m.BootstrapTimeout = 10 * time.Millisecond
+ if m.PeerTLSInfo != nil {
+ m.ServerConfig.PeerTLSInfo = *m.PeerTLSInfo
+ }
+ m.ElectionTicks = electionTicks
+ m.TickMs = uint(tickDuration / time.Millisecond)
+ m.QuotaBackendBytes = mcfg.quotaBackendBytes
+ m.AuthToken = "simple" // for the purpose of integration testing, simple token is enough
+ return m
+}
+
+// listenGRPC starts a grpc server over a unix domain socket on the member
+func (m *member) listenGRPC() error {
+ // prefix with localhost so cert has right domain
+ m.grpcAddr = "localhost:" + m.Name
+ l, err := transport.NewUnixListener(m.grpcAddr)
+ if err != nil {
+ return fmt.Errorf("listen failed on grpc socket %s (%v)", m.grpcAddr, err)
+ }
+ m.grpcBridge, err = newBridge(m.grpcAddr)
+ if err != nil {
+ l.Close()
+ return err
+ }
+ m.grpcAddr = schemeFromTLSInfo(m.ClientTLSInfo) + "://" + m.grpcBridge.inaddr
+ m.grpcListener = l
+ return nil
+}
+
+func (m *member) electionTimeout() time.Duration {
+ return time.Duration(m.s.Cfg.ElectionTicks) * time.Millisecond
+}
+
+func (m *member) DropConnections() { m.grpcBridge.Reset() }
+func (m *member) PauseConnections() { m.grpcBridge.Pause() }
+func (m *member) UnpauseConnections() { m.grpcBridge.Unpause() }
+
+// NewClientV3 creates a new grpc client connection to the member
+func NewClientV3(m *member) (*clientv3.Client, error) {
+ if m.grpcAddr == "" {
+ return nil, fmt.Errorf("member not configured for grpc")
+ }
+
+ cfg := clientv3.Config{
+ Endpoints: []string{m.grpcAddr},
+ DialTimeout: 5 * time.Second,
+ }
+
+ if m.ClientTLSInfo != nil {
+ tls, err := m.ClientTLSInfo.ClientConfig()
+ if err != nil {
+ return nil, err
+ }
+ cfg.TLS = tls
+ }
+ return newClientV3(cfg)
+}
+
+// Clone returns a member with the same server configuration. The returned
+// member will not set PeerListeners and ClientListeners.
+func (m *member) Clone(t *testing.T) *member {
+ mm := &member{}
+ mm.ServerConfig = m.ServerConfig
+
+ var err error
+ clientURLStrs := m.ClientURLs.StringSlice()
+ mm.ClientURLs, err = types.NewURLs(clientURLStrs)
+ if err != nil {
+ // this should never fail
+ panic(err)
+ }
+ peerURLStrs := m.PeerURLs.StringSlice()
+ mm.PeerURLs, err = types.NewURLs(peerURLStrs)
+ if err != nil {
+ // this should never fail
+ panic(err)
+ }
+ clusterStr := m.InitialPeerURLsMap.String()
+ mm.InitialPeerURLsMap, err = types.NewURLsMap(clusterStr)
+ if err != nil {
+ // this should never fail
+ panic(err)
+ }
+ mm.InitialClusterToken = m.InitialClusterToken
+ mm.ElectionTicks = m.ElectionTicks
+ mm.PeerTLSInfo = m.PeerTLSInfo
+ mm.ClientTLSInfo = m.ClientTLSInfo
+ return mm
+}
+
+// Launch starts a member based on ServerConfig, PeerListeners
+// and ClientListeners.
+func (m *member) Launch() error {
+ plog.Printf("launching %s (%s)", m.Name, m.grpcAddr)
+ var err error
+ if m.s, err = etcdserver.NewServer(&m.ServerConfig); err != nil {
+ return fmt.Errorf("failed to initialize the etcd server: %v", err)
+ }
+ m.s.SyncTicker = time.NewTicker(500 * time.Millisecond)
+ m.s.Start()
+
+ m.raftHandler = &testutil.PauseableHandler{Next: etcdhttp.NewPeerHandler(m.s)}
+
+ for _, ln := range m.PeerListeners {
+ hs := &httptest.Server{
+ Listener: ln,
+ Config: &http.Server{Handler: m.raftHandler},
+ }
+ if m.PeerTLSInfo == nil {
+ hs.Start()
+ } else {
+ hs.TLS, err = m.PeerTLSInfo.ServerConfig()
+ if err != nil {
+ return err
+ }
+ hs.StartTLS()
+ }
+ m.hss = append(m.hss, hs)
+ }
+ for _, ln := range m.ClientListeners {
+ hs := &httptest.Server{
+ Listener: ln,
+ Config: &http.Server{Handler: v2http.NewClientHandler(m.s, m.ServerConfig.ReqTimeout())},
+ }
+ if m.ClientTLSInfo == nil {
+ hs.Start()
+ } else {
+ hs.TLS, err = m.ClientTLSInfo.ServerConfig()
+ if err != nil {
+ return err
+ }
+ hs.StartTLS()
+ }
+ m.hss = append(m.hss, hs)
+ }
+ if m.grpcListener != nil {
+ var (
+ tlscfg *tls.Config
+ )
+ if m.ClientTLSInfo != nil && !m.ClientTLSInfo.Empty() {
+ tlscfg, err = m.ClientTLSInfo.ServerConfig()
+ if err != nil {
+ return err
+ }
+ }
+ m.grpcServer = v3rpc.Server(m.s, tlscfg)
+ m.serverClient = v3client.New(m.s)
+ lockpb.RegisterLockServer(m.grpcServer, v3lock.NewLockServer(m.serverClient))
+ epb.RegisterElectionServer(m.grpcServer, v3election.NewElectionServer(m.serverClient))
+ go m.grpcServer.Serve(m.grpcListener)
+ }
+
+ plog.Printf("launched %s (%s)", m.Name, m.grpcAddr)
+ return nil
+}
+
+func (m *member) WaitOK(t *testing.T) {
+ cc := MustNewHTTPClient(t, []string{m.URL()}, m.ClientTLSInfo)
+ kapi := client.NewKeysAPI(cc)
+ for {
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ _, err := kapi.Get(ctx, "/", nil)
+ if err != nil {
+ time.Sleep(tickDuration)
+ continue
+ }
+ cancel()
+ break
+ }
+ for m.s.Leader() == 0 {
+ time.Sleep(tickDuration)
+ }
+}
+
+func (m *member) URL() string { return m.ClientURLs[0].String() }
+
+func (m *member) Pause() {
+ m.raftHandler.Pause()
+ m.s.PauseSending()
+}
+
+func (m *member) Resume() {
+ m.raftHandler.Resume()
+ m.s.ResumeSending()
+}
+
+// Close stops the member's etcdserver and closes its connections
+func (m *member) Close() {
+ if m.grpcBridge != nil {
+ m.grpcBridge.Close()
+ m.grpcBridge = nil
+ }
+ if m.serverClient != nil {
+ m.serverClient.Close()
+ m.serverClient = nil
+ }
+ if m.grpcServer != nil {
+ m.grpcServer.GracefulStop()
+ m.grpcServer = nil
+ }
+ m.s.HardStop()
+ for _, hs := range m.hss {
+ hs.CloseClientConnections()
+ hs.Close()
+ }
+}
+
+// Stop stops the member, but the data dir of the member is preserved.
+func (m *member) Stop(t *testing.T) {
+ plog.Printf("stopping %s (%s)", m.Name, m.grpcAddr)
+ m.Close()
+ m.hss = nil
+ plog.Printf("stopped %s (%s)", m.Name, m.grpcAddr)
+}
+
+// checkLeaderTransition waits for leader transition, returning the new leader ID.
+func checkLeaderTransition(t *testing.T, m *member, oldLead uint64) uint64 {
+ interval := time.Duration(m.s.Cfg.TickMs) * time.Millisecond
+ for m.s.Lead() == 0 || (m.s.Lead() == oldLead) {
+ time.Sleep(interval)
+ }
+ return m.s.Lead()
+}
+
+// StopNotify unblocks when a member stop completes
+func (m *member) StopNotify() <-chan struct{} {
+ return m.s.StopNotify()
+}
+
+// Restart starts the member using the preserved data dir.
+func (m *member) Restart(t *testing.T) error {
+ plog.Printf("restarting %s (%s)", m.Name, m.grpcAddr)
+ newPeerListeners := make([]net.Listener, 0)
+ for _, ln := range m.PeerListeners {
+ newPeerListeners = append(newPeerListeners, NewListenerWithAddr(t, ln.Addr().String()))
+ }
+ m.PeerListeners = newPeerListeners
+ newClientListeners := make([]net.Listener, 0)
+ for _, ln := range m.ClientListeners {
+ newClientListeners = append(newClientListeners, NewListenerWithAddr(t, ln.Addr().String()))
+ }
+ m.ClientListeners = newClientListeners
+
+ if m.grpcListener != nil {
+ if err := m.listenGRPC(); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ err := m.Launch()
+ plog.Printf("restarted %s (%s)", m.Name, m.grpcAddr)
+ return err
+}
+
+// Terminate stops the member and removes the data dir.
+func (m *member) Terminate(t *testing.T) {
+ plog.Printf("terminating %s (%s)", m.Name, m.grpcAddr)
+ m.Close()
+ if !m.keepDataDirTerminate {
+ if err := os.RemoveAll(m.ServerConfig.DataDir); err != nil {
+ t.Fatal(err)
+ }
+ }
+ plog.Printf("terminated %s (%s)", m.Name, m.grpcAddr)
+}
+
+// Metric gets the metric value for a member
+func (m *member) Metric(metricName string) (string, error) {
+ cfgtls := transport.TLSInfo{}
+ tr, err := transport.NewTimeoutTransport(cfgtls, time.Second, time.Second, time.Second)
+ if err != nil {
+ return "", err
+ }
+ cli := &http.Client{Transport: tr}
+ resp, err := cli.Get(m.ClientURLs[0].String() + "/metrics")
+ if err != nil {
+ return "", err
+ }
+ defer resp.Body.Close()
+ b, rerr := ioutil.ReadAll(resp.Body)
+ if rerr != nil {
+ return "", rerr
+ }
+ lines := strings.Split(string(b), "\n")
+ for _, l := range lines {
+ if strings.HasPrefix(l, metricName) {
+ return strings.Split(l, " ")[1], nil
+ }
+ }
+ return "", nil
+}
+
+// InjectPartition drops connections from m to others, vice versa.
+func (m *member) InjectPartition(t *testing.T, others []*member) {
+ for _, other := range others {
+ m.s.CutPeer(other.s.ID())
+ other.s.CutPeer(m.s.ID())
+ }
+}
+
+// RecoverPartition recovers connections from m to others, vice versa.
+func (m *member) RecoverPartition(t *testing.T, others []*member) {
+ for _, other := range others {
+ m.s.MendPeer(other.s.ID())
+ other.s.MendPeer(m.s.ID())
+ }
+}
+
+func MustNewHTTPClient(t *testing.T, eps []string, tls *transport.TLSInfo) client.Client {
+ cfgtls := transport.TLSInfo{}
+ if tls != nil {
+ cfgtls = *tls
+ }
+ cfg := client.Config{Transport: mustNewTransport(t, cfgtls), Endpoints: eps}
+ c, err := client.New(cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return c
+}
+
+func mustNewTransport(t *testing.T, tlsInfo transport.TLSInfo) *http.Transport {
+ // tick in integration test is short, so 1s dial timeout could play well.
+ tr, err := transport.NewTimeoutTransport(tlsInfo, time.Second, rafthttp.ConnReadTimeout, rafthttp.ConnWriteTimeout)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return tr
+}
+
+type SortableMemberSliceByPeerURLs []client.Member
+
+func (p SortableMemberSliceByPeerURLs) Len() int { return len(p) }
+func (p SortableMemberSliceByPeerURLs) Less(i, j int) bool {
+ return p[i].PeerURLs[0] < p[j].PeerURLs[0]
+}
+func (p SortableMemberSliceByPeerURLs) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+type ClusterV3 struct {
+ *cluster
+
+ mu sync.Mutex
+ clients []*clientv3.Client
+}
+
+// NewClusterV3 returns a launched cluster with a grpc client connection
+// for each cluster member.
+func NewClusterV3(t *testing.T, cfg *ClusterConfig) *ClusterV3 {
+ cfg.UseGRPC = true
+ clus := &ClusterV3{
+ cluster: NewClusterByConfig(t, cfg),
+ }
+ clus.Launch(t)
+ for _, m := range clus.Members {
+ client, err := NewClientV3(m)
+ if err != nil {
+ t.Fatalf("cannot create client: %v", err)
+ }
+ clus.clients = append(clus.clients, client)
+ }
+
+ return clus
+}
+
+func (c *ClusterV3) TakeClient(idx int) {
+ c.mu.Lock()
+ c.clients[idx] = nil
+ c.mu.Unlock()
+}
+
+func (c *ClusterV3) Terminate(t *testing.T) {
+ c.mu.Lock()
+ for _, client := range c.clients {
+ if client == nil {
+ continue
+ }
+ if err := client.Close(); err != nil {
+ t.Error(err)
+ }
+ }
+ c.mu.Unlock()
+ c.cluster.Terminate(t)
+}
+
+func (c *ClusterV3) RandClient() *clientv3.Client {
+ return c.clients[rand.Intn(len(c.clients))]
+}
+
+func (c *ClusterV3) Client(i int) *clientv3.Client {
+ return c.clients[i]
+}
+
+type grpcAPI struct {
+ // Cluster is the cluster API for the client's connection.
+ Cluster pb.ClusterClient
+ // KV is the keyvalue API for the client's connection.
+ KV pb.KVClient
+ // Lease is the lease API for the client's connection.
+ Lease pb.LeaseClient
+ // Watch is the watch API for the client's connection.
+ Watch pb.WatchClient
+ // Maintenance is the maintenance API for the client's connection.
+ Maintenance pb.MaintenanceClient
+ // Auth is the authentication API for the client's connection.
+ Auth pb.AuthClient
+ // Lock is the lock API for the client's connection.
+ Lock lockpb.LockClient
+ // Election is the election API for the client's connection.
+ Election epb.ElectionClient
+}
diff --git a/vendor/github.com/coreos/etcd/integration/cluster_direct.go b/vendor/github.com/coreos/etcd/integration/cluster_direct.go
new file mode 100644
index 00000000..ff97e614
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/cluster_direct.go
@@ -0,0 +1,41 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build !cluster_proxy
+
+package integration
+
+import (
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb"
+ "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+func toGRPC(c *clientv3.Client) grpcAPI {
+ return grpcAPI{
+ pb.NewClusterClient(c.ActiveConnection()),
+ pb.NewKVClient(c.ActiveConnection()),
+ pb.NewLeaseClient(c.ActiveConnection()),
+ pb.NewWatchClient(c.ActiveConnection()),
+ pb.NewMaintenanceClient(c.ActiveConnection()),
+ pb.NewAuthClient(c.ActiveConnection()),
+ v3lockpb.NewLockClient(c.ActiveConnection()),
+ v3electionpb.NewElectionClient(c.ActiveConnection()),
+ }
+}
+
+func newClientV3(cfg clientv3.Config) (*clientv3.Client, error) {
+ return clientv3.New(cfg)
+}
diff --git a/vendor/github.com/coreos/etcd/integration/cluster_proxy.go b/vendor/github.com/coreos/etcd/integration/cluster_proxy.go
new file mode 100644
index 00000000..3916553b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/cluster_proxy.go
@@ -0,0 +1,115 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build cluster_proxy
+
+package integration
+
+import (
+ "sync"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/namespace"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/proxy/grpcproxy"
+ "github.com/coreos/etcd/proxy/grpcproxy/adapter"
+)
+
+var (
+ pmu sync.Mutex
+ proxies map[*clientv3.Client]grpcClientProxy = make(map[*clientv3.Client]grpcClientProxy)
+)
+
+const proxyNamespace = "proxy-namespace"
+
+type grpcClientProxy struct {
+ grpc grpcAPI
+ wdonec <-chan struct{}
+ kvdonec <-chan struct{}
+ lpdonec <-chan struct{}
+}
+
+func toGRPC(c *clientv3.Client) grpcAPI {
+ pmu.Lock()
+ defer pmu.Unlock()
+
+ if v, ok := proxies[c]; ok {
+ return v.grpc
+ }
+
+ // test namespacing proxy
+ c.KV = namespace.NewKV(c.KV, proxyNamespace)
+ c.Watcher = namespace.NewWatcher(c.Watcher, proxyNamespace)
+ c.Lease = namespace.NewLease(c.Lease, proxyNamespace)
+ // test coalescing/caching proxy
+ kvp, kvpch := grpcproxy.NewKvProxy(c)
+ wp, wpch := grpcproxy.NewWatchProxy(c)
+ lp, lpch := grpcproxy.NewLeaseProxy(c)
+ mp := grpcproxy.NewMaintenanceProxy(c)
+ clp, _ := grpcproxy.NewClusterProxy(c, "", "") // without registering proxy URLs
+ lockp := grpcproxy.NewLockProxy(c)
+ electp := grpcproxy.NewElectionProxy(c)
+
+ grpc := grpcAPI{
+ adapter.ClusterServerToClusterClient(clp),
+ adapter.KvServerToKvClient(kvp),
+ adapter.LeaseServerToLeaseClient(lp),
+ adapter.WatchServerToWatchClient(wp),
+ adapter.MaintenanceServerToMaintenanceClient(mp),
+ pb.NewAuthClient(c.ActiveConnection()),
+ adapter.LockServerToLockClient(lockp),
+ adapter.ElectionServerToElectionClient(electp),
+ }
+ proxies[c] = grpcClientProxy{grpc: grpc, wdonec: wpch, kvdonec: kvpch, lpdonec: lpch}
+ return grpc
+}
+
+type proxyCloser struct {
+ clientv3.Watcher
+ wdonec <-chan struct{}
+ kvdonec <-chan struct{}
+ lclose func()
+ lpdonec <-chan struct{}
+}
+
+func (pc *proxyCloser) Close() error {
+ // client ctx is canceled before calling close, so kv and lp will close out
+ <-pc.kvdonec
+ err := pc.Watcher.Close()
+ <-pc.wdonec
+ pc.lclose()
+ <-pc.lpdonec
+ return err
+}
+
+func newClientV3(cfg clientv3.Config) (*clientv3.Client, error) {
+ c, err := clientv3.New(cfg)
+ if err != nil {
+ return nil, err
+ }
+ rpc := toGRPC(c)
+ c.KV = clientv3.NewKVFromKVClient(rpc.KV)
+ pmu.Lock()
+ lc := c.Lease
+ c.Lease = clientv3.NewLeaseFromLeaseClient(rpc.Lease, cfg.DialTimeout)
+ c.Watcher = &proxyCloser{
+ Watcher: clientv3.NewWatchFromWatchClient(rpc.Watch),
+ wdonec: proxies[c].wdonec,
+ kvdonec: proxies[c].kvdonec,
+ lclose: func() { lc.Close() },
+ lpdonec: proxies[c].lpdonec,
+ }
+ pmu.Unlock()
+ return c, nil
+}
diff --git a/vendor/github.com/coreos/etcd/integration/cluster_test.go b/vendor/github.com/coreos/etcd/integration/cluster_test.go
new file mode 100644
index 00000000..5a1040ad
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/cluster_test.go
@@ -0,0 +1,592 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "fmt"
+ "log"
+ "math/rand"
+ "os"
+ "strconv"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/client"
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/pkg/capnslog"
+
+ "golang.org/x/net/context"
+)
+
+func init() {
+ // open microsecond-level time log for integration test debugging
+ log.SetFlags(log.Ltime | log.Lmicroseconds | log.Lshortfile)
+ if t := os.Getenv("ETCD_ELECTION_TIMEOUT_TICKS"); t != "" {
+ if i, err := strconv.ParseInt(t, 10, 64); err == nil {
+ electionTicks = int(i)
+ }
+ }
+}
+
+func TestClusterOf1(t *testing.T) { testCluster(t, 1) }
+func TestClusterOf3(t *testing.T) { testCluster(t, 3) }
+
+func testCluster(t *testing.T, size int) {
+ defer testutil.AfterTest(t)
+ c := NewCluster(t, size)
+ c.Launch(t)
+ defer c.Terminate(t)
+ clusterMustProgress(t, c.Members)
+}
+
+func TestTLSClusterOf3(t *testing.T) {
+ defer testutil.AfterTest(t)
+ c := NewClusterByConfig(t, &ClusterConfig{Size: 3, PeerTLS: &testTLSInfo})
+ c.Launch(t)
+ defer c.Terminate(t)
+ clusterMustProgress(t, c.Members)
+}
+
+func TestClusterOf1UsingDiscovery(t *testing.T) { testClusterUsingDiscovery(t, 1) }
+func TestClusterOf3UsingDiscovery(t *testing.T) { testClusterUsingDiscovery(t, 3) }
+
+func testClusterUsingDiscovery(t *testing.T, size int) {
+ defer testutil.AfterTest(t)
+ dc := NewCluster(t, 1)
+ dc.Launch(t)
+ defer dc.Terminate(t)
+ // init discovery token space
+ dcc := MustNewHTTPClient(t, dc.URLs(), nil)
+ dkapi := client.NewKeysAPI(dcc)
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ if _, err := dkapi.Create(ctx, "/_config/size", fmt.Sprintf("%d", size)); err != nil {
+ t.Fatal(err)
+ }
+ cancel()
+
+ c := NewClusterByConfig(
+ t,
+ &ClusterConfig{Size: size, DiscoveryURL: dc.URL(0) + "/v2/keys"},
+ )
+ c.Launch(t)
+ defer c.Terminate(t)
+ clusterMustProgress(t, c.Members)
+}
+
+func TestTLSClusterOf3UsingDiscovery(t *testing.T) {
+ defer testutil.AfterTest(t)
+ dc := NewCluster(t, 1)
+ dc.Launch(t)
+ defer dc.Terminate(t)
+ // init discovery token space
+ dcc := MustNewHTTPClient(t, dc.URLs(), nil)
+ dkapi := client.NewKeysAPI(dcc)
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ if _, err := dkapi.Create(ctx, "/_config/size", fmt.Sprintf("%d", 3)); err != nil {
+ t.Fatal(err)
+ }
+ cancel()
+
+ c := NewClusterByConfig(t,
+ &ClusterConfig{
+ Size: 3,
+ PeerTLS: &testTLSInfo,
+ DiscoveryURL: dc.URL(0) + "/v2/keys"},
+ )
+ c.Launch(t)
+ defer c.Terminate(t)
+ clusterMustProgress(t, c.Members)
+}
+
+func TestDoubleClusterSizeOf1(t *testing.T) { testDoubleClusterSize(t, 1) }
+func TestDoubleClusterSizeOf3(t *testing.T) { testDoubleClusterSize(t, 3) }
+
+func testDoubleClusterSize(t *testing.T, size int) {
+ defer testutil.AfterTest(t)
+ c := NewCluster(t, size)
+ c.Launch(t)
+ defer c.Terminate(t)
+
+ for i := 0; i < size; i++ {
+ c.AddMember(t)
+ }
+ clusterMustProgress(t, c.Members)
+}
+
+func TestDoubleTLSClusterSizeOf3(t *testing.T) {
+ defer testutil.AfterTest(t)
+ c := NewClusterByConfig(t, &ClusterConfig{Size: 3, PeerTLS: &testTLSInfo})
+ c.Launch(t)
+ defer c.Terminate(t)
+
+ for i := 0; i < 3; i++ {
+ c.AddMember(t)
+ }
+ clusterMustProgress(t, c.Members)
+}
+
+func TestDecreaseClusterSizeOf3(t *testing.T) { testDecreaseClusterSize(t, 3) }
+func TestDecreaseClusterSizeOf5(t *testing.T) { testDecreaseClusterSize(t, 5) }
+
+func testDecreaseClusterSize(t *testing.T, size int) {
+ defer testutil.AfterTest(t)
+ c := NewCluster(t, size)
+ c.Launch(t)
+ defer c.Terminate(t)
+
+ // TODO: remove the last but one member
+ for i := 0; i < size-1; i++ {
+ id := c.Members[len(c.Members)-1].s.ID()
+ c.RemoveMember(t, uint64(id))
+ c.waitLeader(t, c.Members)
+ }
+ clusterMustProgress(t, c.Members)
+}
+
+func TestForceNewCluster(t *testing.T) {
+ c := NewCluster(t, 3)
+ c.Launch(t)
+ cc := MustNewHTTPClient(t, []string{c.Members[0].URL()}, nil)
+ kapi := client.NewKeysAPI(cc)
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ resp, err := kapi.Create(ctx, "/foo", "bar")
+ if err != nil {
+ t.Fatalf("unexpected create error: %v", err)
+ }
+ cancel()
+ // ensure create has been applied in this machine
+ ctx, cancel = context.WithTimeout(context.Background(), requestTimeout)
+ if _, err = kapi.Watcher("/foo", &client.WatcherOptions{AfterIndex: resp.Node.ModifiedIndex - 1}).Next(ctx); err != nil {
+ t.Fatalf("unexpected watch error: %v", err)
+ }
+ cancel()
+
+ c.Members[0].Stop(t)
+ c.Members[1].Terminate(t)
+ c.Members[2].Terminate(t)
+ c.Members[0].ForceNewCluster = true
+ err = c.Members[0].Restart(t)
+ if err != nil {
+ t.Fatalf("unexpected ForceRestart error: %v", err)
+ }
+ defer c.Members[0].Terminate(t)
+ c.waitLeader(t, c.Members[:1])
+
+ // use new http client to init new connection
+ cc = MustNewHTTPClient(t, []string{c.Members[0].URL()}, nil)
+ kapi = client.NewKeysAPI(cc)
+ // ensure force restart keep the old data, and new cluster can make progress
+ ctx, cancel = context.WithTimeout(context.Background(), requestTimeout)
+ if _, err := kapi.Watcher("/foo", &client.WatcherOptions{AfterIndex: resp.Node.ModifiedIndex - 1}).Next(ctx); err != nil {
+ t.Fatalf("unexpected watch error: %v", err)
+ }
+ cancel()
+ clusterMustProgress(t, c.Members[:1])
+}
+
+func TestAddMemberAfterClusterFullRotation(t *testing.T) {
+ defer testutil.AfterTest(t)
+ c := NewCluster(t, 3)
+ c.Launch(t)
+ defer c.Terminate(t)
+
+ // remove all the previous three members and add in three new members.
+ for i := 0; i < 3; i++ {
+ c.RemoveMember(t, uint64(c.Members[0].s.ID()))
+ c.waitLeader(t, c.Members)
+
+ c.AddMember(t)
+ c.waitLeader(t, c.Members)
+ }
+
+ c.AddMember(t)
+ c.waitLeader(t, c.Members)
+
+ clusterMustProgress(t, c.Members)
+}
+
+// Ensure we can remove a member then add a new one back immediately.
+func TestIssue2681(t *testing.T) {
+ defer testutil.AfterTest(t)
+ c := NewCluster(t, 5)
+ c.Launch(t)
+ defer c.Terminate(t)
+
+ c.RemoveMember(t, uint64(c.Members[4].s.ID()))
+ c.waitLeader(t, c.Members)
+
+ c.AddMember(t)
+ c.waitLeader(t, c.Members)
+ clusterMustProgress(t, c.Members)
+}
+
+// Ensure we can remove a member after a snapshot then add a new one back.
+func TestIssue2746(t *testing.T) { testIssue2746(t, 5) }
+
+// With 3 nodes TestIssue2476 sometimes had a shutdown with an inflight snapshot.
+func TestIssue2746WithThree(t *testing.T) { testIssue2746(t, 3) }
+
+func testIssue2746(t *testing.T, members int) {
+ defer testutil.AfterTest(t)
+ c := NewCluster(t, members)
+
+ for _, m := range c.Members {
+ m.SnapCount = 10
+ }
+
+ c.Launch(t)
+ defer c.Terminate(t)
+
+ // force a snapshot
+ for i := 0; i < 20; i++ {
+ clusterMustProgress(t, c.Members)
+ }
+
+ c.RemoveMember(t, uint64(c.Members[members-1].s.ID()))
+ c.waitLeader(t, c.Members)
+
+ c.AddMember(t)
+ c.waitLeader(t, c.Members)
+ clusterMustProgress(t, c.Members)
+}
+
+// Ensure etcd will not panic when removing a just started member.
+func TestIssue2904(t *testing.T) {
+ defer testutil.AfterTest(t)
+ // start 1-member cluster to ensure member 0 is the leader of the cluster.
+ c := NewCluster(t, 1)
+ c.Launch(t)
+ defer c.Terminate(t)
+
+ c.AddMember(t)
+ c.Members[1].Stop(t)
+
+ // send remove member-1 request to the cluster.
+ cc := MustNewHTTPClient(t, c.URLs(), nil)
+ ma := client.NewMembersAPI(cc)
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ // the proposal is not committed because member 1 is stopped, but the
+ // proposal is appended to leader's raft log.
+ ma.Remove(ctx, c.Members[1].s.ID().String())
+ cancel()
+
+ // restart member, and expect it to send UpdateAttributes request.
+ // the log in the leader is like this:
+ // [..., remove 1, ..., update attr 1, ...]
+ c.Members[1].Restart(t)
+ // when the member comes back, it ack the proposal to remove itself,
+ // and apply it.
+ <-c.Members[1].s.StopNotify()
+
+ // terminate removed member
+ c.Members[1].Terminate(t)
+ c.Members = c.Members[:1]
+ // wait member to be removed.
+ c.waitMembersMatch(t, c.HTTPMembers())
+}
+
+// TestIssue3699 tests minority failure during cluster configuration; it was
+// deadlocking.
+func TestIssue3699(t *testing.T) {
+ // start a cluster of 3 nodes a, b, c
+ defer testutil.AfterTest(t)
+ c := NewCluster(t, 3)
+ c.Launch(t)
+ defer c.Terminate(t)
+
+ // make node a unavailable
+ c.Members[0].Stop(t)
+
+ // add node d
+ c.AddMember(t)
+
+ // electing node d as leader makes node a unable to participate
+ leaderID := c.waitLeader(t, c.Members)
+ for leaderID != 3 {
+ c.Members[leaderID].Stop(t)
+ <-c.Members[leaderID].s.StopNotify()
+ // do not restart the killed member immediately.
+ // the member will advance its election timeout after restart,
+ // so it will have a better chance to become the leader again.
+ time.Sleep(time.Duration(electionTicks * int(tickDuration)))
+ c.Members[leaderID].Restart(t)
+ leaderID = c.waitLeader(t, c.Members)
+ }
+
+ // bring back node a
+ // node a will remain useless as long as d is the leader.
+ if err := c.Members[0].Restart(t); err != nil {
+ t.Fatal(err)
+ }
+ select {
+ // waiting for ReadyNotify can take several seconds
+ case <-time.After(10 * time.Second):
+ t.Fatalf("waited too long for ready notification")
+ case <-c.Members[0].s.StopNotify():
+ t.Fatalf("should not be stopped")
+ case <-c.Members[0].s.ReadyNotify():
+ }
+ // must waitLeader so goroutines don't leak on terminate
+ c.waitLeader(t, c.Members)
+
+ // try to participate in cluster
+ cc := MustNewHTTPClient(t, []string{c.URL(0)}, c.cfg.ClientTLS)
+ kapi := client.NewKeysAPI(cc)
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ if _, err := kapi.Set(ctx, "/foo", "bar", nil); err != nil {
+ t.Fatalf("unexpected error on Set (%v)", err)
+ }
+ cancel()
+}
+
+// TestRejectUnhealthyAdd ensures an unhealthy cluster rejects adding members.
+func TestRejectUnhealthyAdd(t *testing.T) {
+ defer testutil.AfterTest(t)
+ c := NewCluster(t, 3)
+ for _, m := range c.Members {
+ m.ServerConfig.StrictReconfigCheck = true
+ }
+ c.Launch(t)
+ defer c.Terminate(t)
+
+ // make cluster unhealthy and wait for downed peer
+ c.Members[0].Stop(t)
+ c.WaitLeader(t)
+
+ // all attempts to add member should fail
+ for i := 1; i < len(c.Members); i++ {
+ err := c.addMemberByURL(t, c.URL(i), "unix://foo:12345")
+ if err == nil {
+ t.Fatalf("should have failed adding peer")
+ }
+ // TODO: client should return descriptive error codes for internal errors
+ if !strings.Contains(err.Error(), "has no leader") {
+ t.Errorf("unexpected error (%v)", err)
+ }
+ }
+
+ // make cluster healthy
+ c.Members[0].Restart(t)
+ c.WaitLeader(t)
+ time.Sleep(2 * etcdserver.HealthInterval)
+
+ // add member should succeed now that it's healthy
+ var err error
+ for i := 1; i < len(c.Members); i++ {
+ if err = c.addMemberByURL(t, c.URL(i), "unix://foo:12345"); err == nil {
+ break
+ }
+ }
+ if err != nil {
+ t.Fatalf("should have added peer to healthy cluster (%v)", err)
+ }
+}
+
+// TestRejectUnhealthyRemove ensures an unhealthy cluster rejects removing members
+// if quorum will be lost.
+func TestRejectUnhealthyRemove(t *testing.T) {
+ defer testutil.AfterTest(t)
+ c := NewCluster(t, 5)
+ for _, m := range c.Members {
+ m.ServerConfig.StrictReconfigCheck = true
+ }
+ c.Launch(t)
+ defer c.Terminate(t)
+
+ // make cluster unhealthy and wait for downed peer; (3 up, 2 down)
+ c.Members[0].Stop(t)
+ c.Members[1].Stop(t)
+ c.WaitLeader(t)
+
+ // reject remove active member since (3,2)-(1,0) => (2,2) lacks quorum
+ err := c.removeMember(t, uint64(c.Members[2].s.ID()))
+ if err == nil {
+ t.Fatalf("should reject quorum breaking remove")
+ }
+ // TODO: client should return more descriptive error codes for internal errors
+ if !strings.Contains(err.Error(), "has no leader") {
+ t.Errorf("unexpected error (%v)", err)
+ }
+
+ // member stopped after launch; wait for missing heartbeats
+ time.Sleep(time.Duration(electionTicks * int(tickDuration)))
+
+ // permit remove dead member since (3,2) - (0,1) => (3,1) has quorum
+ if err = c.removeMember(t, uint64(c.Members[0].s.ID())); err != nil {
+ t.Fatalf("should accept removing down member")
+ }
+
+ // bring cluster to (4,1)
+ c.Members[0].Restart(t)
+
+ // restarted member must be connected for a HealthInterval before remove is accepted
+ time.Sleep((3 * etcdserver.HealthInterval) / 2)
+
+ // accept remove member since (4,1)-(1,0) => (3,1) has quorum
+ if err = c.removeMember(t, uint64(c.Members[0].s.ID())); err != nil {
+ t.Fatalf("expected to remove member, got error %v", err)
+ }
+}
+
+// TestRestartRemoved ensures that restarting removed member must exit
+// if 'initial-cluster-state' is set 'new' and old data directory still exists
+// (see https://github.com/coreos/etcd/issues/7512 for more).
+func TestRestartRemoved(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ capnslog.SetGlobalLogLevel(capnslog.INFO)
+ defer capnslog.SetGlobalLogLevel(defaultLogLevel)
+
+ // 1. start single-member cluster
+ c := NewCluster(t, 1)
+ for _, m := range c.Members {
+ m.ServerConfig.StrictReconfigCheck = true
+ }
+ c.Launch(t)
+ defer c.Terminate(t)
+
+ // 2. add a new member
+ c.AddMember(t)
+ c.WaitLeader(t)
+
+ oldm := c.Members[0]
+ oldm.keepDataDirTerminate = true
+
+ // 3. remove first member, shut down without deleting data
+ if err := c.removeMember(t, uint64(c.Members[0].s.ID())); err != nil {
+ t.Fatalf("expected to remove member, got error %v", err)
+ }
+ c.WaitLeader(t)
+
+ // 4. restart first member with 'initial-cluster-state=new'
+ // wrong config, expects exit within ReqTimeout
+ oldm.ServerConfig.NewCluster = false
+ if err := oldm.Restart(t); err != nil {
+ t.Fatalf("unexpected ForceRestart error: %v", err)
+ }
+ defer func() {
+ oldm.Close()
+ os.RemoveAll(oldm.ServerConfig.DataDir)
+ }()
+ select {
+ case <-oldm.s.StopNotify():
+ case <-time.After(time.Minute):
+ t.Fatalf("removed member didn't exit within %v", time.Minute)
+ }
+}
+
+// clusterMustProgress ensures that cluster can make progress. It creates
+// a random key first, and check the new key could be got from all client urls
+// of the cluster.
+func clusterMustProgress(t *testing.T, membs []*member) {
+ cc := MustNewHTTPClient(t, []string{membs[0].URL()}, nil)
+ kapi := client.NewKeysAPI(cc)
+ key := fmt.Sprintf("foo%d", rand.Int())
+ var (
+ err error
+ resp *client.Response
+ )
+ // retry in case of leader loss induced by slow CI
+ for i := 0; i < 3; i++ {
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ resp, err = kapi.Create(ctx, "/"+key, "bar")
+ cancel()
+ if err == nil {
+ break
+ }
+ t.Logf("failed to create key on %q (%v)", membs[0].URL(), err)
+ }
+ if err != nil {
+ t.Fatalf("create on %s error: %v", membs[0].URL(), err)
+ }
+
+ for i, m := range membs {
+ u := m.URL()
+ mcc := MustNewHTTPClient(t, []string{u}, nil)
+ mkapi := client.NewKeysAPI(mcc)
+ mctx, mcancel := context.WithTimeout(context.Background(), requestTimeout)
+ if _, err := mkapi.Watcher(key, &client.WatcherOptions{AfterIndex: resp.Node.ModifiedIndex - 1}).Next(mctx); err != nil {
+ t.Fatalf("#%d: watch on %s error: %v", i, u, err)
+ }
+ mcancel()
+ }
+}
+
+func TestTransferLeader(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ oldLeadIdx := clus.WaitLeader(t)
+ oldLeadID := uint64(clus.Members[oldLeadIdx].s.ID())
+
+ // ensure followers go through leader transition while learship transfer
+ idc := make(chan uint64)
+ for i := range clus.Members {
+ if oldLeadIdx != i {
+ go func(m *member) {
+ idc <- checkLeaderTransition(t, m, oldLeadID)
+ }(clus.Members[i])
+ }
+ }
+
+ err := clus.Members[oldLeadIdx].s.TransferLeadership()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // wait until leader transitions have happened
+ var newLeadIDs [2]uint64
+ for i := range newLeadIDs {
+ select {
+ case newLeadIDs[i] = <-idc:
+ case <-time.After(time.Second):
+ t.Fatal("timed out waiting for leader transition")
+ }
+ }
+
+ // remaining members must agree on the same leader
+ if newLeadIDs[0] != newLeadIDs[1] {
+ t.Fatalf("expected same new leader %d == %d", newLeadIDs[0], newLeadIDs[1])
+ }
+
+ // new leader must be different than the old leader
+ if oldLeadID == newLeadIDs[0] {
+ t.Fatalf("expected old leader %d != new leader %d", oldLeadID, newLeadIDs[0])
+ }
+}
+
+func TestSpeedyTerminate(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ // Stop/Restart so requests will time out on lost leaders
+ for i := 0; i < 3; i++ {
+ clus.Members[i].Stop(t)
+ clus.Members[i].Restart(t)
+ }
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ clus.Terminate(t)
+ }()
+ select {
+ case <-time.After(10 * time.Second):
+ t.Fatalf("cluster took too long to terminate")
+ case <-donec:
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/integration/doc.go b/vendor/github.com/coreos/etcd/integration/doc.go
new file mode 100644
index 00000000..fbf19d54
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/doc.go
@@ -0,0 +1,25 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 integration implements tests built upon embedded etcd, and focus on
+etcd correctness.
+
+Features/goals of the integration tests:
+1. test the whole code base except command-line parsing.
+2. check internal data, including raft, store and etc.
+3. based on goroutines, which is faster than process.
+4. mainly tests user behavior and user-facing API.
+*/
+package integration
diff --git a/vendor/github.com/coreos/etcd/integration/embed_test.go b/vendor/github.com/coreos/etcd/integration/embed_test.go
new file mode 100644
index 00000000..751494ea
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/embed_test.go
@@ -0,0 +1,166 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "context"
+ "fmt"
+ "net/url"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/embed"
+)
+
+func TestEmbedEtcd(t *testing.T) {
+ tests := []struct {
+ cfg embed.Config
+
+ werr string
+ wpeers int
+ wclients int
+ }{
+ {werr: "multiple discovery"},
+ {werr: "advertise-client-urls is required"},
+ {werr: "should be at least"},
+ {werr: "is too long"},
+ {wpeers: 1, wclients: 1},
+ {wpeers: 2, wclients: 1},
+ {wpeers: 1, wclients: 2},
+ {werr: "expected IP"},
+ {werr: "expected IP"},
+ }
+
+ urls := newEmbedURLs(10)
+
+ // setup defaults
+ for i := range tests {
+ tests[i].cfg = *embed.NewConfig()
+ }
+
+ tests[0].cfg.Durl = "abc"
+ setupEmbedCfg(&tests[1].cfg, []url.URL{urls[0]}, []url.URL{urls[1]})
+ tests[1].cfg.ACUrls = nil
+ tests[2].cfg.TickMs = tests[2].cfg.ElectionMs - 1
+ tests[3].cfg.ElectionMs = 999999
+ setupEmbedCfg(&tests[4].cfg, []url.URL{urls[2]}, []url.URL{urls[3]})
+ setupEmbedCfg(&tests[5].cfg, []url.URL{urls[4]}, []url.URL{urls[5], urls[6]})
+ setupEmbedCfg(&tests[6].cfg, []url.URL{urls[7], urls[8]}, []url.URL{urls[9]})
+
+ dnsURL, _ := url.Parse("http://whatever.test:12345")
+ tests[7].cfg.LCUrls = []url.URL{*dnsURL}
+ tests[8].cfg.LPUrls = []url.URL{*dnsURL}
+
+ dir := filepath.Join(os.TempDir(), fmt.Sprintf("embed-etcd"))
+ os.RemoveAll(dir)
+ defer os.RemoveAll(dir)
+
+ for i, tt := range tests {
+ tests[i].cfg.Dir = dir
+ e, err := embed.StartEtcd(&tests[i].cfg)
+ if e != nil {
+ <-e.Server.ReadyNotify() // wait for e.Server to join the cluster
+ }
+ if tt.werr != "" {
+ if err == nil || !strings.Contains(err.Error(), tt.werr) {
+ t.Errorf("%d: expected error with %q, got %v", i, tt.werr, err)
+ }
+ if e != nil {
+ e.Close()
+ }
+ continue
+ }
+ if err != nil {
+ t.Errorf("%d: expected success, got error %v", i, err)
+ continue
+ }
+ if len(e.Peers) != tt.wpeers {
+ t.Errorf("%d: expected %d peers, got %d", i, tt.wpeers, len(e.Peers))
+ }
+ if len(e.Clients) != tt.wclients {
+ t.Errorf("%d: expected %d clients, got %d", i, tt.wclients, len(e.Clients))
+ }
+ e.Close()
+ select {
+ case err := <-e.Err():
+ t.Errorf("#%d: unexpected error on close (%v)", i, err)
+ default:
+ }
+ }
+}
+
+// TestEmbedEtcdGracefulStop ensures embedded server stops
+// cutting existing transports.
+func TestEmbedEtcdGracefulStop(t *testing.T) {
+ cfg := embed.NewConfig()
+
+ urls := newEmbedURLs(2)
+ setupEmbedCfg(cfg, []url.URL{urls[0]}, []url.URL{urls[1]})
+
+ cfg.Dir = filepath.Join(os.TempDir(), fmt.Sprintf("embed-etcd"))
+ os.RemoveAll(cfg.Dir)
+ defer os.RemoveAll(cfg.Dir)
+
+ e, err := embed.StartEtcd(cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ <-e.Server.ReadyNotify() // wait for e.Server to join the cluster
+
+ cli, err := clientv3.New(clientv3.Config{Endpoints: []string{urls[0].String()}})
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer cli.Close()
+
+ // open watch connection
+ cli.Watch(context.Background(), "foo")
+
+ donec := make(chan struct{})
+ go func() {
+ e.Close()
+ close(donec)
+ }()
+ select {
+ case err := <-e.Err():
+ t.Fatal(err)
+ case <-donec:
+ case <-time.After(2*time.Second + e.Server.Cfg.ReqTimeout()):
+ t.Fatalf("took too long to close server")
+ }
+}
+
+func newEmbedURLs(n int) (urls []url.URL) {
+ for i := 0; i < n; i++ {
+ u, _ := url.Parse(fmt.Sprintf("unix://localhost:%d%06d", os.Getpid(), i))
+ urls = append(urls, *u)
+ }
+ return
+}
+
+func setupEmbedCfg(cfg *embed.Config, curls []url.URL, purls []url.URL) {
+ cfg.ClusterState = "new"
+ cfg.LCUrls, cfg.ACUrls = curls, curls
+ cfg.LPUrls, cfg.APUrls = purls, purls
+ cfg.InitialCluster = ""
+ for i := range purls {
+ cfg.InitialCluster += ",default=" + purls[i].String()
+ }
+ cfg.InitialCluster = cfg.InitialCluster[1:]
+}
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures-expired/README b/vendor/github.com/coreos/etcd/integration/fixtures-expired/README
new file mode 100644
index 00000000..3651eb55
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures-expired/README
@@ -0,0 +1,5 @@
+To generate bad certs
+
+1. Manually set system time back to past
+2. Run ./gencerts.sh
+
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures-expired/etcd-root-ca-key.pem b/vendor/github.com/coreos/etcd/integration/fixtures-expired/etcd-root-ca-key.pem
new file mode 100644
index 00000000..449cab35
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures-expired/etcd-root-ca-key.pem
@@ -0,0 +1,51 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIJKQIBAAKCAgEAn/3pG4N9sLWucz5yPVmAuPCuh5tvHs2wRWsBnrTM9qqIpCjR
+7rNJzZSy3bAMxX+u1JXUK/Nt3lT87zrIkkC4En74avJSxt+cQlSs54sHFsRo/Idl
+b/6b/dEeS4bko7xlymzX5WDSZJ9Aj69wNZx73TGsHiZDBnQziyE1lPPs38qYcJtc
+kZKGgsTwJ0e1gvBE+k8KdhTSBX1jYPiycOpibajEERa6dMNZHIJRElJAQejgFDzE
+VRLCZBddT0kwVx1ttqYCtYDGlqg2Th2J5n1GAddQLffz8/8ZOuJsCYYgA+8LY55f
+x7H392msdTWnaLVW3VYE9j5lf69/pJlVThP46kjuwtX9hfEkoLRjXBF98TibnQXQ
+E+LVUNv3ezR/W+lntJOxg7Pka+5OjG/S9Kgj/QOA4nAkoPeQ/NXosBX8d/Z8qHi3
+f5YRtmT5NLwAgaSBg2lty8B20o9a63prwhEOmk++ENh8UmexUJ+Amy8lGyB/0fRC
+2YFnC5sJJETjDjyrPrWJA8760Eq0TffRYYgcKyJJtioduyPncLxGY7CkT/tsh6oy
+IY+RndKOfHdD67yqLZyuwdz/LsaxABELEbbFekE6mlQ/OclZzce5m8+bDZ4W3nRt
+S/GygXhWNj6XxKyk8RQNB6p2a5gRIxEAadHuUJd0fFZht+xNlOEuB6n7CPkCAwEA
+AQKCAgBILiZ/2jfXhG/64D5r/Tg8t6EV3wMn84ZGGzu03T7nPhK9dQkZVtvCGwcD
+SwzIAY3frOT3GzEDMHaYe33HtdkVxyDOJxs/S9zUdB05rRh6pgvzeiZCe6zmuvSf
+AHGgiTunMqnIe4EQEmTvLihCl6GuLl3HkF2GyOAEMexZkh7Y7C8QBpehuWhkEPOD
+1S9HrpyADS7cDRKflW1Db5AZrzTO4mfqicV/Li7C1Ow8hs0kryqBFtVAyGDZBU18
+mrlrZAR+dbEdL8boa2Vsopj3Wqc952TuCEKQXxOD5Gj3dwJ0o+EQhYASuPD1N0Ct
+9JHdhIp2+vrsGURzcbr1iJPa0NnoKk1HHee5LI8PnjOIsy/KaNBM4PWvmP+sWbUC
+Ej6JTiyZklHztRCq6EkXhUU2D1PplkqBtAM9DnubkuHvqrPa+BDEI1OZABxJHblA
+FvSB5D8bLx7rFZD7H2UvDG+e/Y7STNSo178qY2X6e5GRxoaB+/m9XU/P0+nSA+U1
+QtR00b95WSw6rn3hdgLXf5pxpmCoQqndkQzT8Xx/iY53s8Lr020c84tp6eMp4rsJ
+t145eLi+RnJLGDnXeb0I5/sEJE9SUyR7L/AARB0ewgrTsr2Cy2zpDCDh2s6oWTcS
+46XqU/yPcEf5NnPC7YLVjF8zWa6qO6VsBadntW6PmUbxQqehXQKCAQEAwdJGyX6w
+F8WrUv3nxP1GOAB1z86/6HS/+2znmDAqlIFqMikIcUHsMfRMeBga/M+pvSRajmG3
+MUWIoRZhgyDMMtdMGOqv8bAvaHqR7UlFymeU4m/kIRmJaU81167KKF0eFc4akf6G
+bzIbkGkZVAlnLWGBaloYj6vz8NWw6gJkTT+vH+Cz9g0hJ+bnNHuttxLKkDW2Fc87
+Mt8KFI14xK/tJiPktSCfVxjyVj16tn63lLQFKo5bOqsTUSxkFTPtIhGm2YGTk0Dv
+/hM9x7GhMPnQ2o0lK6FhCHzAnQkoD5ld8KL5hV3iP7Jg0+H9c9c8e+gHum0n+vxo
+WolOFsrd26ocEwKCAQEA01FbcKfz85qCP6336oVhr/Kl4TE2V+kWRbOpg48EVkJ+
+uJrqLoA/OSCYjmmh7ly5fjTpE1Juvhbuo54MoGLxQ954H47Hux+0daoX9hAEcOK5
+AiWINC7Gqi1rzQ3b9Vp2PxbiR6JcDqiy6UoK81uP6N6PgpUuu+EV74asP5SWGx/u
+BhScd5QLjjtf77n0Zn5aoNSuHt3JOzjToMl4WCtaP+/t0edkBsfcU/grNs85B/wN
+6A5uJR8T52wVWw5xQYbblU92JeDSgfQr1LD5VVOr8hQzVxDoOI8SL2dx68OEMw9v
+hzVfHL79sKCLUAJHGqnBC+zLcVCbDctm7EVxgAmQQwKCAQEArO1Xit8lbZBHUzyG
+VRNEWyLN+iKUxmmkAEciOn5+/xCYFzjU93fBrLAyqdOYAIenAcI1qWM1dxh61n6J
+cd0JUzMUCgcaA6EWKzlwiS0ev3+7Lmx2NbH7D6JEf7LLW0f5V6sTub5FY2Bph2a9
+2mSpUav1M1Y/I7BfbTi7J44Kv4FaVi69YYJFWryA/Cp8yyJQ6GmDk+HZB4JIFB5E
+6festqK/o3r/r03qqVcg7UIRuPMEyPtKGgYYrgvVH7W8lPD61ITvjioZ9a5lKI4r
+Ku84kEXuLAdH87Kah4Fr5L8JOXGu/nbNLdeQ3Hp9D6WxqTtT6dkKGryovl5S9bL6
+TspvUQKCAQEAxAwJmlWnJMymo++BPolqHLMwI+DlOt/bMuVAkfYgHurn59qJAoUm
+ophUEGN9wMczrBvoVG24ohBia1dY/X9tt/pwVU7AjCEY6cTZIAayKAyfeZdaapcu
+5njnN0DxXQoFA/j2C2FcqJjoCzkPOcErnO7GE27WAaYMFMFLkl0GebnAuNFsbB/k
+LJt3IM/TJzd4WxeVRruaUqAg7l2bkaj+vKyaZY+XpBbNmPV3Gg1cKsU0HaMtmrDf
+ZWdH1MdsWU+E7lvfD7spcTkXZOafGwNaVWdaTh84YiiRxXriHMmyHzDl1nm0eNXU
+RIZdWOgUEW+F0stn3wPaJg0bun2elBvLQwKCAQBcTaEhnVOJvBxMtM6G6N/rzBLb
+yQNKPPmMfCK9+TXFMpfsfYqiST/63wRbYIQ0tjiyx+dXb7VawhovCT7AR5Ct+0zW
+iCG9yUNhbFEXUWUbthdrt1Xr3IBw9NCfYHosTjyOHi0eAn1ORFlD6GNzv27zeQHR
+nBJwR6/SJOLYNztJLIyQGrK8fBuqaVFf2zaxDwCiPtIRUudbLJPobEyGfszjpvAR
+nIe1aqh/ONLjBgwkj/6uLI15IDexqoW5j6KyW+MlAqBmqLecOFnfM7ZKW6VHvZpZ
+me+2Zgxulhq9iRyPHcYDhUzIktH6IF4hYITdLS4IbCezcp4LmHgbyDpxu3+J
+-----END RSA PRIVATE KEY-----
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures-expired/etcd-root-ca.pem b/vendor/github.com/coreos/etcd/integration/fixtures-expired/etcd-root-ca.pem
new file mode 100644
index 00000000..64cc269b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures-expired/etcd-root-ca.pem
@@ -0,0 +1,34 @@
+-----BEGIN CERTIFICATE-----
+MIIF5jCCA86gAwIBAgIUIzbfeuRpE4/TdkmJEYNNOA2VoLgwDQYJKoZIhvcNAQEN
+BQAweTEMMAoGA1UEBhMDVVNBMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQH
+Ew1TYW4gRnJhbmNpc2NvMQ0wCwYDVQQKEwRldGNkMRYwFAYDVQQLEw1ldGNkIFNl
+Y3VyaXR5MRUwEwYDVQQDEwxldGNkLXJvb3QtY2EwHhcNMTcwMTI2MTkxNTAwWhcN
+MTcwMTI2MjAxNTAwWjB5MQwwCgYDVQQGEwNVU0ExEzARBgNVBAgTCkNhbGlmb3Ju
+aWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xDTALBgNVBAoTBGV0Y2QxFjAUBgNV
+BAsTDWV0Y2QgU2VjdXJpdHkxFTATBgNVBAMTDGV0Y2Qtcm9vdC1jYTCCAiIwDQYJ
+KoZIhvcNAQEBBQADggIPADCCAgoCggIBAJ/96RuDfbC1rnM+cj1ZgLjwroebbx7N
+sEVrAZ60zPaqiKQo0e6zSc2Ust2wDMV/rtSV1Cvzbd5U/O86yJJAuBJ++GryUsbf
+nEJUrOeLBxbEaPyHZW/+m/3RHkuG5KO8Zcps1+Vg0mSfQI+vcDWce90xrB4mQwZ0
+M4shNZTz7N/KmHCbXJGShoLE8CdHtYLwRPpPCnYU0gV9Y2D4snDqYm2oxBEWunTD
+WRyCURJSQEHo4BQ8xFUSwmQXXU9JMFcdbbamArWAxpaoNk4dieZ9RgHXUC338/P/
+GTribAmGIAPvC2OeX8ex9/dprHU1p2i1Vt1WBPY+ZX+vf6SZVU4T+OpI7sLV/YXx
+JKC0Y1wRffE4m50F0BPi1VDb93s0f1vpZ7STsYOz5GvuToxv0vSoI/0DgOJwJKD3
+kPzV6LAV/Hf2fKh4t3+WEbZk+TS8AIGkgYNpbcvAdtKPWut6a8IRDppPvhDYfFJn
+sVCfgJsvJRsgf9H0QtmBZwubCSRE4w48qz61iQPO+tBKtE330WGIHCsiSbYqHbsj
+53C8RmOwpE/7bIeqMiGPkZ3Sjnx3Q+u8qi2crsHc/y7GsQARCxG2xXpBOppUPznJ
+Wc3HuZvPmw2eFt50bUvxsoF4VjY+l8SspPEUDQeqdmuYESMRAGnR7lCXdHxWYbfs
+TZThLgep+wj5AgMBAAGjZjBkMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAG
+AQH/AgECMB0GA1UdDgQWBBRnbPUmgSmUC3API24MQ5x/Xh08xzAfBgNVHSMEGDAW
+gBRnbPUmgSmUC3API24MQ5x/Xh08xzANBgkqhkiG9w0BAQ0FAAOCAgEAFPoCwCcw
+ecCkvFTxjJnMI9v+i0VlqgKH5Q8ZAxwsPI+bck5KdUbi7aWTwvlZxM/2WT0NsWGO
+hKZhsJnOZsRaEmeKV5TD1Ua2urQSXWztjGDn/+6JR47FYIP57d3+w5wYuwwzy2ne
+4oY4OIOmot9Wqgc1D5yOo9D81Udq6DOfb9DeXqa+UuQGoYu1hLQrgUQATxiYsu8T
+FNoG7EQihNuIMlBhU/H1rCKtX4aeRXRRl7Rr/p/+AYqNUblnjwowvBGyYEfzO9ag
+ixO+li3SbpD4SfZwX1T3SQukoOq2iSCnrWDdP9yvx04X8oPxhbAncjxASDfy4l2S
+vhaks6L10qZkLjWNGA65UVDPgzAWTi/7XCZZ37bP2poLbg+/VbKVvN4PII81NB54
+Ew9mkS9NwcjWQvjkhVPVGtk/fiYtkl5yrrWswJMW/fQJvipveMZbEW0jLVx28f7n
+t+hvaKMy1QBr1HG3bVtty/izDVTsHJLbki07NRNkJM8M7zv960/rL8SK4J300Zm1
+DjxeyipcX1IGnIeBzNT2ASu1cD40T+qwG7hYtSCpGAkBVq4ZnFSGb3yICv5TvUE4
+WItEf4eaV/dK0f7yu02u+TS22LiFiWU1d1/wL8HX9n8utS2w3g/YXy8GNWahcjiM
+AlehNnzoyVafYDVvMKNHBfJuaxa5qTQrctY=
+-----END CERTIFICATE-----
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures-expired/gencerts.sh b/vendor/github.com/coreos/etcd/integration/fixtures-expired/gencerts.sh
new file mode 100755
index 00000000..3722b75c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures-expired/gencerts.sh
@@ -0,0 +1,91 @@
+#!/usr/bin/env bash
+set -e
+
+if ! [[ "$0" =~ "./gencerts.sh" ]]; then
+ echo "must be run from 'fixtures-expired'"
+ exit 255
+fi
+
+if which cfssl >/dev/null; then
+ echo "cfssl is installed; generating certs"
+else
+ echo "cfssl is not installed; exiting"
+ exit 255
+fi
+
+cat > ./etcd-root-ca-csr.json <<EOF
+{
+ "key": {
+ "algo": "rsa",
+ "size": 4096
+ },
+ "names": [
+ {
+ "O": "etcd",
+ "OU": "etcd Security",
+ "L": "San Francisco",
+ "ST": "California",
+ "C": "USA"
+ }
+ ],
+ "CN": "etcd-root-ca",
+ "ca": {
+ "expiry": "1h"
+ }
+}
+EOF
+
+cfssl gencert --initca=true ./etcd-root-ca-csr.json | cfssljson --bare ./etcd-root-ca
+
+cat > ./etcd-gencert.json <<EOF
+{
+ "signing": {
+ "default": {
+ "usages": [
+ "signing",
+ "key encipherment",
+ "server auth",
+ "client auth"
+ ],
+ "expiry": "1h"
+ }
+ }
+}
+EOF
+
+cat > ./server-ca-csr.json <<EOF
+{
+ "key": {
+ "algo": "rsa",
+ "size": 4096
+ },
+ "names": [
+ {
+ "O": "etcd",
+ "OU": "etcd Security",
+ "L": "San Francisco",
+ "ST": "California",
+ "C": "USA"
+ }
+ ],
+ "CN": "example.com",
+ "hosts": [
+ "127.0.0.1",
+ "localhost"
+ ]
+}
+EOF
+
+cfssl gencert \
+ --ca ./etcd-root-ca.pem \
+ --ca-key ./etcd-root-ca-key.pem \
+ --config ./etcd-gencert.json \
+ ./server-ca-csr.json | cfssljson --bare ./server
+
+rm ./*.json
+rm ./*.csr
+
+if which openssl >/dev/null; then
+ openssl x509 -in ./etcd-root-ca.pem -text -noout
+ openssl x509 -in ./server.pem -text -noout
+fi
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures-expired/server-key.pem b/vendor/github.com/coreos/etcd/integration/fixtures-expired/server-key.pem
new file mode 100644
index 00000000..a1a9f1eb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures-expired/server-key.pem
@@ -0,0 +1,51 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIJKAIBAAKCAgEArjJG7BkDXGJ7IJeUbt9ilXZl/SqKVYnQQcbAVqKKsZOUTnWl
+jYgslXIVDJAYUCZ2WNzXrHq6XOY4qbfNjDIdq28hlq+EydMOU9T/1WrFASbiJdrC
+mFH1XUX9SImDw9qDit2S4bxW5gs+Q6cSRSGyHf+6/DD24NY2VP3qpjwaEByZGZ7K
+769zRBhoI2sWslilztQKuiVdeTRNqMtCD/Qa4JIiwyzmYOwKEd+kitrsPwUQg/11
+RNbUHZEy51GCzeZ467DcjnXiGHsAF6ZMznDvPY8GU71JYkBN1Tq8IQVe9yemqk6S
+UXYoJJnebX3WMvCZ+XLKYWObANQpXxHsu6t68Hkcg5bDTTbg79JAS8co7wf1S3NA
+3QudhrTf3anvdbtaZFukusQbVnH7qSp5LFTle+Vl7Megy0/juCBL9/xMSpWqUwUl
+7evfrm/JkVmCoGm2+56uCyrVK9uRRraqp7J19RuNmhunOiURN610DjsisI1eqAHS
+naDtMluwBc+HEaJWYzJN1JLvGA3ahOyOcv94FZ1msabq20txvp5oHLd7j9TaVGob
+qSbDGLZGHrm5If/x2+1Dc9O55Om/82Q8r1Qxt+GqVX+TFed7AvBHFTYbBiW5gT8M
+SqMb91t+MYmC9ChFbWepC35I6zoHX1B1CgV20lr5PH1wYO+k0IdO6ufZYBcCAwEA
+AQKCAgAMledX4YrDnv3kYe9Af3VA9TfzLaKnAXkBd5mn6MB6if4aGRfn/OGzvnVU
+3ghTqiO80d/nP0q9sYiAgp4gNfK80x+rIm1Go7ASUH5Xbgpjxepq775FgQ5oOclN
+91mEygHdA5s8If5pSoCqJKUGR6P11Ocul18O6YstYtcUQZ1kcpyBJF7nKFb8oYLM
+pE0Uf6EjK2DHCDITsrq1qlHQk0Np3EUUsubGM+eaWP0rZxvQhc4mqyZQ3fCfXkE+
+Qz5fH/q2lKWqyUuXlzNvgf1koPY4DWBYpoFpztmQwVicTiYJV10MSvb5Wb8WveM7
+J+9U6NtHEYsbtDWbvrhqfQIMoRwVqxryUj1h/GN95oZ80pFkhcLfBeu045Fyc7Aa
+gZT/ugC2Jov/+1uxtLe9ZsZeY+MVBuLrUoG5+Q+Tink+uJ3KYn2TltpdiYmSZ7lY
+s/SnUBGbmSJjpXsbqbcimnsZLX/T8X53UwHRG5eWmGhJBU60kATsFqZmvkYgI3wc
+yenDQaIx93fwsBWEBn/Ms1XHaYvVIpeQ4eRboIzkNq0Aefyat6MIQPj5tf2Hlb93
+bRNxoJaX6oiOtCrqfIdqk688pgjTwV5r4z4R+K4FbVRx0VbU0Dfsa4rVsRFidMdg
+9s+xvS2wYePkjP5m5q574oStRKYuJsaPDJeXLI5XfzKnLa/eUQKCAQEA5bjIhflh
+P/3yL/EEC4Pr9t655mi0qyxNegllfkuhEEdH6u+ygj4MtJikVUatL5XHylo0KGM1
+asdJLlOwFYGsOKLk0Vj2BU1b9PljRYyS+8sZvOQOhDbxkl7zrvaezYPbsVd1IX0v
+Q6fvOh9N5H127LkspHC+G03g6X+nY/+5b5CxaUHke6Cd+fjxiZnAbyzmhgIHohfC
+7HCzmKfyJPIJgVpDAHaEWIpAVYU5qRwgrWWjx2WftFXF7NaI5KIoMgbqWCLp1A/O
+eaO3CB/uRn3l4yjBy+paxpYzkS0LtfHMDk/0tPn8/AFt9L6Pjv+KXYhvpsJAqknQ
+p0RmFEuEh+AQKQKCAQEAwh96H3TdUzRl0TewWL9IbKdeF1IV7PC1dwljevsTYlU5
+kUztebtHA6XWXNwlKr8VQ1PVTsncB4VlX3bIlbg8fVy90Uu7FQ/dhSczyuZANjz/
+ocazZi9wk8OG5k6Sgz/EdevsIPnBfdbPPGgxFkSr1CUEOkRwtI7p/F3gjeJviH7j
+7BYKJje1mln3/r8h3esgeILOmK4/oKpjjRCbhAsU4j8kLFKMgUYdPgpqFzdgzOLO
+EIoDqTl7anQkbJUoSbenoHF0xWmWG5uaOo4/ORuTr+ZoN4nkZ6D8R6ZQlPpIw4oD
+WDeoAcSoFgKoczIlBk4lcz5mbwp2UsiLBYXJFH72PwKCAQEAzBd0R9r8dK74KXG2
+h0iILodIoBTsVpuApeiNPDyS9vRtR6P3c1EPVq+6aGznVrx6iSPE7RDfF2PAd6Ew
+cpsHWDYYlomz4ZgOF8ItWVAAEiYqUrBG2V47FzC2zP4crjf0ykUKMluWz0P2/Sts
+t5BkRQJrUBk+POHe7XRVUjmTFTR2+i3pgZB8aearKPXpipxYnjxVbcQwkIG8febP
+8dT7bumzV0j0YflKGPDI/p6XxZXkgTWfQsdllfowGviaP3/3WaCDH71/UoCKD3TW
+69fUkxHVw4YNahtt6xAbNGWDRj/xB4yGH5phhyx6PLB5zIl3sK8qZmA4OTNCgctq
+DpGZqQKCAQBgc+lnBdcOh4Nrj+MERY7Dxek/Zx7Tysovai/OpD/+ZOAkrPd1u7LO
+QjEflJa3BZiYCmh7LFsyNXqoE0oY8iDEHTeHbbx3+5kSlubqErum92oAxMzQohOq
+p8U4W6P6qM2B1gZOYCpez0PK/O4e5WIHF5lhJi5l2Hi0VyTC+tZ2GK5A2LaURKvs
+FHXfUrKOJEzO9BeYz0N4HhE2vyC2XBc1TzA3AZEkjmTrNZt/C5oCU1MV7q1hANms
+jCao+Pe6oREd7CGcERlvgEIChDkvs98O0EnKBq7BOsD/DMkPLMjIt6Nvyr+kmUT3
+Irz1991jo6KB/2hAFg+ylEhXJyFBGNBbAoIBAFQhMh25emwXX/L0lEqoo1miDl2U
+IYUFLl8sasRyZp7PmGuUSyKLMZwJesPvcXb4OL4h4Q+2Esx4nFhTkHjoo22AJWRK
+ivLiDZHEVN5DKFCfaNoNCMeLi07syLRWl28K5O924lVfsEwISOd5VjuFynNHn5Tu
+pE/VkfwUtY1owak3k737Yum1bBmUHyP6kJyUGQW0E9yhTcau1OnhU8XSvO+6lClK
+wOg3RsP3LF3gslrRVgc+R95KOva7Oc2EuJDqoHJ8877+r68cHdJYe3mmb1pPNqC1
+It+c6mphFAT6frmzkew72FEFzaiSx/Iqiwz4LqoMEnVYN8eVp7hehyGbb8o=
+-----END RSA PRIVATE KEY-----
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures-expired/server.pem b/vendor/github.com/coreos/etcd/integration/fixtures-expired/server.pem
new file mode 100644
index 00000000..0e4a0ab8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures-expired/server.pem
@@ -0,0 +1,35 @@
+-----BEGIN CERTIFICATE-----
+MIIGHDCCBASgAwIBAgIUcGlr9BUSOAwUt3SDhav9yWokZDowDQYJKoZIhvcNAQEN
+BQAweTEMMAoGA1UEBhMDVVNBMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQH
+Ew1TYW4gRnJhbmNpc2NvMQ0wCwYDVQQKEwRldGNkMRYwFAYDVQQLEw1ldGNkIFNl
+Y3VyaXR5MRUwEwYDVQQDEwxldGNkLXJvb3QtY2EwHhcNMTcwMTI2MTkxNTAwWhcN
+MTcwMTI2MjAxNTAwWjB4MQwwCgYDVQQGEwNVU0ExEzARBgNVBAgTCkNhbGlmb3Ju
+aWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xDTALBgNVBAoTBGV0Y2QxFjAUBgNV
+BAsTDWV0Y2QgU2VjdXJpdHkxFDASBgNVBAMTC2V4YW1wbGUuY29tMIICIjANBgkq
+hkiG9w0BAQEFAAOCAg8AMIICCgKCAgEArjJG7BkDXGJ7IJeUbt9ilXZl/SqKVYnQ
+QcbAVqKKsZOUTnWljYgslXIVDJAYUCZ2WNzXrHq6XOY4qbfNjDIdq28hlq+EydMO
+U9T/1WrFASbiJdrCmFH1XUX9SImDw9qDit2S4bxW5gs+Q6cSRSGyHf+6/DD24NY2
+VP3qpjwaEByZGZ7K769zRBhoI2sWslilztQKuiVdeTRNqMtCD/Qa4JIiwyzmYOwK
+Ed+kitrsPwUQg/11RNbUHZEy51GCzeZ467DcjnXiGHsAF6ZMznDvPY8GU71JYkBN
+1Tq8IQVe9yemqk6SUXYoJJnebX3WMvCZ+XLKYWObANQpXxHsu6t68Hkcg5bDTTbg
+79JAS8co7wf1S3NA3QudhrTf3anvdbtaZFukusQbVnH7qSp5LFTle+Vl7Megy0/j
+uCBL9/xMSpWqUwUl7evfrm/JkVmCoGm2+56uCyrVK9uRRraqp7J19RuNmhunOiUR
+N610DjsisI1eqAHSnaDtMluwBc+HEaJWYzJN1JLvGA3ahOyOcv94FZ1msabq20tx
+vp5oHLd7j9TaVGobqSbDGLZGHrm5If/x2+1Dc9O55Om/82Q8r1Qxt+GqVX+TFed7
+AvBHFTYbBiW5gT8MSqMb91t+MYmC9ChFbWepC35I6zoHX1B1CgV20lr5PH1wYO+k
+0IdO6ufZYBcCAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYI
+KwYBBQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFE7MTPuM
+DNH+edtzjnjB+8Tuwx62MB8GA1UdIwQYMBaAFGds9SaBKZQLcA8jbgxDnH9eHTzH
+MBoGA1UdEQQTMBGCCWxvY2FsaG9zdIcEfwAAATANBgkqhkiG9w0BAQ0FAAOCAgEA
+S1Kx/+L5UNAjvXoDWAvFJMIpQcsFhV6vj/sbwxgwXTKjQHOOehEwaaEW735EDmhC
+4CLgyM94i7eFEGwAVwWpnh6XAfqCMGd32T5aRPktiGqnQ+aAVdC/fgmWWKqA7ix5
+Bsjg9WbuBZvI1tAIscq7ajeHFBb/mndgP2kRJf8Rd7NH3VsmLHlK6KKwe/ThKvwZ
+IRTfN7ABWzKq/MmGUOWuBiQaLM7DT05m3ISpN3YCHJL4HRjLz6WZ9vP3GLDcrC8H
+a7TPizjB3/+y++htnDBhVAAVl4GgolRZzjkzERxDZlvyY7T8sfq9a+9GGHgRXB8v
+9wWOYph2r8K1aPaVPw88cri9l993g+vWgKhEse+JoiHgcyCp2VjnM6cpMhCPktBp
+YBZ/jBma5EQoLIdBFmDcH/tVs6l6o/9J3q2x+fPZYZkvyuUbxb+TdRZllCqx1myy
+YxCGTLdjWEHQbdcVc8totLPgJik2LjFoPAvYgrqO0o3vTz1oagLbwie4D2uK9Ats
+pu4KxGCsDtzyf/w9sBZti/ovIgttB7IxeFWZYIWVRCkJkre9rm8qmaCmMY2FvBDY
+nBSTldaLpHAryjleyu/WYdqW8Qc+EqIPCzCvJkrKfhZEN7AT7vFwmvnOjJetFdEL
+UNJ3wyITBZtiMRAInMkRi3zFeHTVqaockL/FoplkY4Q=
+-----END CERTIFICATE-----
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures/ca-csr.json b/vendor/github.com/coreos/etcd/integration/fixtures/ca-csr.json
new file mode 100644
index 00000000..a25404ba
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures/ca-csr.json
@@ -0,0 +1,19 @@
+{
+ "key": {
+ "algo": "rsa",
+ "size": 4096
+ },
+ "names": [
+ {
+ "O": "etcd",
+ "OU": "etcd Security",
+ "L": "San Francisco",
+ "ST": "California",
+ "C": "USA"
+ }
+ ],
+ "CN": "ca",
+ "ca": {
+ "expiry": "87600h"
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures/ca.crt b/vendor/github.com/coreos/etcd/integration/fixtures/ca.crt
new file mode 100644
index 00000000..3ccaadbf
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures/ca.crt
@@ -0,0 +1,33 @@
+-----BEGIN CERTIFICATE-----
+MIIFrjCCA5agAwIBAgIUXWXsuLEZuHtKgeQSIVthb14+9EQwDQYJKoZIhvcNAQEN
+BQAwbzEMMAoGA1UEBhMDVVNBMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQH
+Ew1TYW4gRnJhbmNpc2NvMQ0wCwYDVQQKEwRldGNkMRYwFAYDVQQLEw1ldGNkIFNl
+Y3VyaXR5MQswCQYDVQQDEwJjYTAeFw0xNzA3MjAyMjA1MDBaFw0yNzA3MTgyMjA1
+MDBaMG8xDDAKBgNVBAYTA1VTQTETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UE
+BxMNU2FuIEZyYW5jaXNjbzENMAsGA1UEChMEZXRjZDEWMBQGA1UECxMNZXRjZCBT
+ZWN1cml0eTELMAkGA1UEAxMCY2EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK
+AoICAQCmtwjSg7gQBcVaoMycpePT0qoM0SKJVuvQRXIjL53/Bae5zuWiBdDVTElf
+6OOFkjqPAxU7t28jmn/EqNcKkaVuFcFtVbgyD+vXWQITGSGfE1hmqVUcpbSpzLim
+UIFNy6slMeUdFGiLG7/4P6mCHePgoW9r1+J2oAHSooCzJDqLNAGkgHhFQPhBC62G
+3QrY2gwKlJ6Yl+2Ilb+bdT4PJq8sSlyAynPFTp07hnciEG6Ef6IQxc9pZb+UCa2A
+Cyn9RU83AWj/aIcdlB8iNf86np4wFe8VEkgBdih91vfEzvoMhJZYBb0b0CnrRo1e
+jVXAJkqTbajQM+yxlvlhB2PNCZusJa69eDCtnnO29MbTjOTqElTxlvU9c3huZycc
+VMDgzyzm87F+Me3vh/6l6VC4Pm0zkA3XdwydncxreFoD/G+fQK2m6wXWzIsSGwqG
+gzgAq8neJFfkcgzRu6WU1S8S/idqK9AoQAFIEPXYyIk3+K6JzHxhYZIBFE3OrZ58
+oEo2PCP4snzTysZk7eWCe/WTZvReKtytzKAIS/CcjxsmgaviHee5tlV/rIghAxq8
+QFnldJ1J9AtqPriRv0+EDFwOL8eyA+cVbWgX9UR0gWLe5lUqooowpq2ioWHG5F1m
+cyi0u8cUtf5YZN6SVktQUdddsOCFfxvCU1NigxVxqs1ZWhSSrwIDAQABo0IwQDAO
+BgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUp//gP4sC
+l0dWZOXJWaPOYED2YdQwDQYJKoZIhvcNAQENBQADggIBABXyQox/T4kD+sLuTAp9
+IP6Hr/XaHmKj3Zkrp8DdWt62R13ugCdWA8hu2yYzu92mSHBGbssaSaLzsNeb+LqE
+/gSNQBvbfV0btQN2h+B3+BmEUuiv4ZTMPNArGfG7L1p35kH0NL46Bcssu59XSFLe
+RIc7M5yT/C5+f/muhIxsAT6AdnwwkcxjQvQj9257S1gonOjLmmsVXW+Z+G9Y3YIf
+hp84yvrJh86QVGsDC5Cu5i9kC/0CodCouIlBjWdELZDWV5KvbLAuWoQ5Jp1Y6+Jo
+Dhx+2HB9mKmDWJfS8rWd//EiX/JH8iSMSaltmrzk6PYlWFAuM8jycDyyQI4mCe6J
+wPMRyism7cowcGqHb+Nn2OiPvJtX6bGcVb8DbaGDmfgPdACqjdguzLHnaFyLmDe/
+la0y1FAfW7jOyQrXEzqB4tJ8ZhI+HxRiXAh8ahBcKnMQFpjsEse03d2t65ZPDgev
+NjIcoqhbANpYXdygux4hJNCT8KB194frC+eK0XqyO8BJYvid1Qp7SlnpFdEo1vMK
+whLje6QkrgIyqoTP1+SiB3R79rtg+41bTb8paPJs9AqNaxS/l2bSnWnRvdkiJv89
+YWgQGNO21XW+VbNV7Z0tMglmTvJc0ubbV5zZpVsuSOAQjdRXKieAxWAePrzDx5AM
+ZiQgL5b9icqHm0aV7bcfp8H+
+-----END CERTIFICATE-----
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures/gencert.json b/vendor/github.com/coreos/etcd/integration/fixtures/gencert.json
new file mode 100644
index 00000000..09b67267
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures/gencert.json
@@ -0,0 +1,13 @@
+{
+ "signing": {
+ "default": {
+ "usages": [
+ "signing",
+ "key encipherment",
+ "server auth",
+ "client auth"
+ ],
+ "expiry": "87600h"
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures/gencerts.sh b/vendor/github.com/coreos/etcd/integration/fixtures/gencerts.sh
new file mode 100755
index 00000000..912e0490
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures/gencerts.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+if ! [[ "$0" =~ "./gencerts.sh" ]]; then
+ echo "must be run from 'fixtures'"
+ exit 255
+fi
+
+if ! which cfssl; then
+ echo "cfssl is not installed"
+ exit 255
+fi
+
+cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca
+mv ca.pem ca.crt
+openssl x509 -in ca.crt -noout -text
+
+# generate DNS: localhost, IP: 127.0.0.1, CN: example.com certificates
+cfssl gencert \
+ --ca ./ca.crt \
+ --ca-key ./ca-key.pem \
+ --config ./gencert.json \
+ ./server-ca-csr.json | cfssljson --bare ./server
+mv server.pem server.crt
+mv server-key.pem server.key.insecure
+
+# generate revoked certificates and crl
+cfssl gencert --ca ./ca.crt \
+ --ca-key ./ca-key.pem \
+ --config ./gencert.json \
+ ./server-ca-csr.json 2>revoked.stderr | cfssljson --bare ./server-revoked
+mv server-revoked.pem server-revoked.crt
+mv server-revoked-key.pem server-revoked.key.insecure
+grep serial revoked.stderr | awk ' { print $9 } ' >revoke.txt
+cfssl gencrl revoke.txt ca.crt ca-key.pem | base64 -d >revoke.crl
+
+# generate wildcard certificates DNS: *.etcd.local
+cfssl gencert \
+ --ca ./ca.crt \
+ --ca-key ./ca-key.pem \
+ --config ./gencert.json \
+ ./server-ca-csr-wildcard.json | cfssljson --bare ./server-wildcard
+mv server-wildcard.pem server-wildcard.crt
+mv server-wildcard-key.pem server-wildcard.key.insecure
+
+
+rm -f *.csr *.pem *.stderr *.txt
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures/revoke.crl b/vendor/github.com/coreos/etcd/integration/fixtures/revoke.crl
new file mode 100644
index 00000000..dd378e09
Binary files /dev/null and b/vendor/github.com/coreos/etcd/integration/fixtures/revoke.crl differ
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures/server-ca-csr.json b/vendor/github.com/coreos/etcd/integration/fixtures/server-ca-csr.json
new file mode 100644
index 00000000..b8906656
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures/server-ca-csr.json
@@ -0,0 +1,20 @@
+{
+ "key": {
+ "algo": "rsa",
+ "size": 4096
+ },
+ "names": [
+ {
+ "O": "etcd",
+ "OU": "etcd Security",
+ "L": "San Francisco",
+ "ST": "California",
+ "C": "USA"
+ }
+ ],
+ "CN": "example.com",
+ "hosts": [
+ "127.0.0.1",
+ "localhost"
+ ]
+}
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures/server-revoked.crt b/vendor/github.com/coreos/etcd/integration/fixtures/server-revoked.crt
new file mode 100644
index 00000000..92997edf
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures/server-revoked.crt
@@ -0,0 +1,35 @@
+-----BEGIN CERTIFICATE-----
+MIIGEjCCA/qgAwIBAgIUBmQ4fvS9/9znydzkBFJ6EwYeoC0wDQYJKoZIhvcNAQEN
+BQAwbzEMMAoGA1UEBhMDVVNBMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQH
+Ew1TYW4gRnJhbmNpc2NvMQ0wCwYDVQQKEwRldGNkMRYwFAYDVQQLEw1ldGNkIFNl
+Y3VyaXR5MQswCQYDVQQDEwJjYTAeFw0xNzA3MjAyMjA1MDBaFw0yNzA3MTgyMjA1
+MDBaMHgxDDAKBgNVBAYTA1VTQTETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UE
+BxMNU2FuIEZyYW5jaXNjbzENMAsGA1UEChMEZXRjZDEWMBQGA1UECxMNZXRjZCBT
+ZWN1cml0eTEUMBIGA1UEAxMLZXhhbXBsZS5jb20wggIiMA0GCSqGSIb3DQEBAQUA
+A4ICDwAwggIKAoICAQDKaPgCc+vw1m8qNuPp4ujMhd0ZomWb4Ev5ik3wqp0M0ebK
+fVXFwKhLwsmkA8YRafVsjZsyDeS7rRPm1tyAXonTjIXeQfYNEmS9SlqV3zSlNJk4
+lRGJSAEnAJwqpH4fAAxAGzvyHL8o7Pu+Rg2yMXEaWb0niuafa5s0oRQln25DGMWq
+dwdzVeiRb8MkUhlyWrmEKe5gr/lolxAxwXh7pVXqyqqzisnP+UETY/kmwNO5feGS
+Ox195tyWsYNFq142gWJlfI+atrslBW1qOD+zam+niVkvSwATLQqrqF6HmfBRLIUO
+xzvzWarnXskV5PiF7WVZuYZgw7Ez7JYxqo713xcGzB6IygMjjXpirLuhIon2E8aq
+jtsOJHuEiJvfMywYbAd3ryPDU040iKHxHLsiQXMjycv+AjK/Z6JWBRk9OM06v8ua
+/XeyBdChiXrRPwwSfPvkggyWo07ZYzuWCYZgxke5Bt7LsJ/uIBmX6gjGzW/mxNuA
+X+c9FLKtMsqTRjHdU5Y1GkgGx9ZOWKXnDICPosz5fYqiGKKAy0sS2/4+/TFRssvY
+Ef7KWjYQoMHJpWzhpLPmimp69XCTIdVh6JbkNxQlebiMS/NRD4qyCnZRvVvRhetp
+9wlzDf+T/aUmBMdd6ins05mLjol/TCDb3IOhoMkzjwPKXzl89FAGhHrEXTFexQID
+AQABo4GcMIGZMA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYI
+KwYBBQUHAwIwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUO3LyYm5pTwmuadST/Y3N
+d78VIAswHwYDVR0jBBgwFoAUp//gP4sCl0dWZOXJWaPOYED2YdQwGgYDVR0RBBMw
+EYIJbG9jYWxob3N0hwR/AAABMA0GCSqGSIb3DQEBDQUAA4ICAQA37eO0sz0gXZcn
+rEp/jLoCpD6PF96tMYtWztqhoCBj3IlzkSHBiZG3o8Jm08ldbgyOe4xCKrLgTPM5
+zDCAXcTN1JpV4NPBzk+Oeyzl7Hayg8WftftoAyxzZqYZA2JAdQrjuW8nC18eKZ5P
+05t+lQiXgOI0DaYpfJabJ2AFr8kqsZKW/gw1kvdhhar72Ar2rJwm+h6XWpWghGzQ
+CWgr+q+FbWCqCtJ+MvwVe9qxwc8vwG/YxPeumNI2sC4pGIx6AxnNvvTtEVndQdA1
+AG2HCjDm/6hbTre+4ps4orFfgwkavSxT4SPJYsLloD914oJ8ekuPKoMqgqF4jQRp
+IiuwXZ5dhDJu5qAL/LcgG99j8beyNhpXbsiO7iWgskUHPOjFzZEfnV1K7g2yu0zS
+Ym4zRKKIWWePn2Tvnu14aIC3pVaaYGL13+0UCbI1Dhm5qyJ+I7MNQte/bMVKEdfG
+Xr+fL7VQL0MH58cNJoPdUBPmmiDTR8ZH73iuFA+6YpTzOtoDi1mWAu/PHdFDiR3o
+hqTzUBEisfWsvj9Dd2las+glsCsmhCon00kuxau1zyvqxZrVXA82rdy981E09NOu
+kSagZkOb60q/il1BCKYVXlZ5Mn9IUMQur7y8Tg2NPY66BXs0neTS/RcrMKtOdTdM
+hE/fY15ykrUxtAio49yuhfQm5SxSQA==
+-----END CERTIFICATE-----
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures/server-revoked.key.insecure b/vendor/github.com/coreos/etcd/integration/fixtures/server-revoked.key.insecure
new file mode 100644
index 00000000..8bf96aae
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures/server-revoked.key.insecure
@@ -0,0 +1,51 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIJKQIBAAKCAgEAymj4AnPr8NZvKjbj6eLozIXdGaJlm+BL+YpN8KqdDNHmyn1V
+xcCoS8LJpAPGEWn1bI2bMg3ku60T5tbcgF6J04yF3kH2DRJkvUpald80pTSZOJUR
+iUgBJwCcKqR+HwAMQBs78hy/KOz7vkYNsjFxGlm9J4rmn2ubNKEUJZ9uQxjFqncH
+c1XokW/DJFIZclq5hCnuYK/5aJcQMcF4e6VV6sqqs4rJz/lBE2P5JsDTuX3hkjsd
+febclrGDRateNoFiZXyPmra7JQVtajg/s2pvp4lZL0sAEy0Kq6heh5nwUSyFDsc7
+81mq517JFeT4he1lWbmGYMOxM+yWMaqO9d8XBsweiMoDI416Yqy7oSKJ9hPGqo7b
+DiR7hIib3zMsGGwHd68jw1NONIih8Ry7IkFzI8nL/gIyv2eiVgUZPTjNOr/Lmv13
+sgXQoYl60T8MEnz75IIMlqNO2WM7lgmGYMZHuQbey7Cf7iAZl+oIxs1v5sTbgF/n
+PRSyrTLKk0Yx3VOWNRpIBsfWTlil5wyAj6LM+X2KohiigMtLEtv+Pv0xUbLL2BH+
+ylo2EKDByaVs4aSz5opqevVwkyHVYeiW5DcUJXm4jEvzUQ+Ksgp2Ub1b0YXrafcJ
+cw3/k/2lJgTHXeop7NOZi46Jf0wg29yDoaDJM48Dyl85fPRQBoR6xF0xXsUCAwEA
+AQKCAgA3rEubERtycOi+qb5ilIEH0EISTPK5vyXmiz4I1kTAQ/PA+lxfOjCQNhGU
+RV1zaLuSkhh/2gZyAJcaxTp9LIOoZlxj16y/x7Fhx1PHKU+nqSIDyCy8n8uBWM+b
+gwcVq8Oy1krUu0dxEE3l9grKWoMLhmdauv/YFZbpEO0jtAh1+BhWXMr11ElVx3Hb
+SaGqLH4edhIVEhH9zJ8tsFNdXwqUvA3buG7t/1cA6FydZihWOuOSfyQLfzZpVIYQ
+4aPWRhw0YeB145DyC94eez46MSpo4IRhV7W7kIYA1Ry7G4JYMXCfsfkxZBZ38UBJ
+/2LEI5ne5gKqFulkqMxe+NS9mBES1c5s2EqGdIsRAyOHlh7XvE+aHoiPSNqXGC4S
+h1x5HIakc8AITtCkoJ1WF5Ir01vc2XFQzZW+yJtXoO2GmZjJUO0NowNkpnCJPIaL
+ri3q5Yx0O/1ZqctS4J1+/U6FG3ccdZvgui+XfX6x7Nf/l5JSuKIYNiHoPmQXfFcn
+yfw0e2xR84IXkXnXy8pOHfFelQkAzNIoH+wcH0hQrECD+R8XDIrv5i7ys2IRsJuG
+/PLJ0I2adYjMgn2s4Z8upMJcHDzn2wbIhzxG1LY7yVvyr233ScuaJE8+LpVwQvU9
+fDjfJ+wXmGm2R+xfwXUAOtnvMpKOYOrVBDwT3Cp4V1b8NUaYwQKCAQEAz7hZ9kCk
+wSDOE/LEdzf/OSIKgb9UVAl9af3F1n02U06PUHrlhB9qxhOi5z+Hqox1cFkHlVvl
+1P6S6VGLAEnyMaD7e2zhVx0ByOSZAjMGaEve3ataocCWJfOM16WrC7r65gptjdZZ
+FabzUBAW1YB7kadrdVg767c/xf9fAQ7bEYuDoJB4ER3o3h6aMZ1eeL2tiKrgIn8m
+ql9WHX4X0dfF94V2bIaHnqTpTmmDMYE4tFZarfG4+e21YvnREd1PhlGMrsfGhYFS
+DLYJw1gtJKM9ht4g1A0dggBt6GW7ziOvA23HGeIAEqLO+zT5e4WvxBV95x/OjWrs
+v7YcipW8Kndd3QKCAQEA+XSoz0fsiKvfGJeg6dR64pr9hmGZz9nJRkCOejVd3U5L
+uCbkPq5bFRjDGsBgih+9lWDApQq1lKeQmnin+sXDSmQEtVpDqW4gHuOk++xf6CkG
+D9X6NR9PMrXDkRCJDONfyk7WppMjLzpFOrUcBW2VI2ZJdZd2oeQGV8QhQIHQEw0W
+iYmAEFAjRoU6Y6g/XDngMkwL5PqmOuAXrw+HvwEJ0cyNisl0F9a6C0pkRQeZGWNi
+EEpCvsg1NasTzsk/Rd0YjWGY5cNJKIkKVQoIX1Y8O644aIam3klpZLpA3Z41zmdl
+/saIMcJHtW4s2s/YZ8wJrjxY/vsvCK9SrIFB2nc6CQKCAQEArCyQVO9MINDCQAKw
+GmmN4Zt3vggLLAUZsSsqOxlaWD77x6e2aodoB3rrQmaEWzdFeLQy9vhPTvccasyu
+PLUOTVi0Wp/rQDvI6O2ibhJBM14AAxkvbHenfRmdGno1humbYeYu3KxY9vuFHk3X
+v2xaAGcXSRKzyDQCZmnAI65eovJTTlmxS+7QwJv5DzrzvXzrRCbu1WkzcXDIfnWv
+5L3HV92GRXpVG4hx4g7PMc98Yu5ZB2ke+/quqLWNOBOLATjDNXRd9vc0PVj+Sq7h
+7EZqj0m7SEj+tm0IrOL2gm1Nebgamjeb+9Z7XfmQ+XPcNtnhnBvfJ5UDW/zlN3HZ
+oBGE+QKCAQBAjjAhdDuCIvhZJOQ/nv0uJ230mM11PKcZxxsYBTeFTf3KakYm8ngf
+vYjAI4jYNd6aCa/RBjR3g+WoFBFklEk1tyyAwhtAfX9SfxbzGvi22+b1sipOFQwp
+02AI6n6NF0py0HQ8J1ezoSDJUJUv0mwF/TKFe+z3eEsr61Wvm+h9BaYPccXycsqu
+NUwm/iNnepLKcWOinjrmgZefdiVrCJnB8W2vvPKOOMNsqJPKSW0VZOK71HvxY15h
+xSQbH3mAWvc/n0IyM5d7JfvGhhIkmex8hVmTs0T7wYPEzW5767WA9MEwbbBRMDXe
+feSdu6wFMIhQzs05L0e8t6JtggXIw5IBAoIBAQCtyxIDHmoxKQeomXvdsCSL45F2
+caA8b8THXTD0IDLPq1Z8J568lE86meVmyogLktyWRouatE4ZAg/ehOZdJwcTBGki
+ZcQ1oycveFzH8cbVrS1x1zMXRcWh4ERkm28M9xTfOFBJRhcCADUOB6RHlz5q7iRj
+5wQMd4OEtrXHnUaewelCNmfTUA+Z2JBA+wGUXEPpg9tD5NMzYMtYKYRCljUEyLTQ
+oieAAiPzZI9UmolaHufW5+9s0kyGqGU69ORk8i/Fy27g/Ca83A6i9BsNiPaWUk5m
+HF9YrkAh5TQDOA3dRoPmjJfPg6Pa92m95QHq9GcfdV3ifrNTJb0X3JCxCa9b
+-----END RSA PRIVATE KEY-----
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures/server-wildcard.crt b/vendor/github.com/coreos/etcd/integration/fixtures/server-wildcard.crt
new file mode 100644
index 00000000..283e8ec6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures/server-wildcard.crt
@@ -0,0 +1,30 @@
+-----BEGIN CERTIFICATE-----
+MIIFDzCCAvegAwIBAgIUeJ6mpnfPEW9DQsXb3n1/wfj6y04wDQYJKoZIhvcNAQEN
+BQAwbzEMMAoGA1UEBhMDVVNBMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQH
+Ew1TYW4gRnJhbmNpc2NvMQ0wCwYDVQQKEwRldGNkMRYwFAYDVQQLEw1ldGNkIFNl
+Y3VyaXR5MQswCQYDVQQDEwJjYTAeFw0xNzA3MjAyMjA1MDBaFw0yNzA3MTgyMjA1
+MDBaMHgxDDAKBgNVBAYTA1VTQTETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UE
+BxMNU2FuIEZyYW5jaXNjbzENMAsGA1UEChMEZXRjZDEWMBQGA1UECxMNZXRjZCBT
+ZWN1cml0eTEUMBIGA1UEAxMLZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUA
+A4IBDwAwggEKAoIBAQClaGICudWL2LbCIxBEtsSUC9cFzskwH0+9M17nKN9mA6dx
+PWnOK3kLuLcV5kjzc70kechTzHXHfSSCw7DozUfecQQlxxeRZsf/sGJ88aUqnmn9
+oYA0Yf32rZ5M4MkyeZM1uG279N/LLUvBt1wojgmddw9VhgM3FQ2wC8L6TwCPCER4
+0pDjLx2wqjsGd/M2D2ixBSenRKnDMrIe1zY5RQYMfSX0Y1zmkr3ld2SfMpeIh28T
+fG8tmOx19y++mB3kz8VJKknC2AbdnX/8i3BV+Y4DWZlxR7CT1flBih358w+6TOIi
+BR6yuErkpsiYUP5dt4tyTYxxMIkHl+bIWRxswRQ7AgMBAAGjgZkwgZYwDgYDVR0P
+AQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMB
+Af8EAjAAMB0GA1UdDgQWBBQPhUhOX+soZsPIPqa0cw9SEqM9lzAfBgNVHSMEGDAW
+gBSn/+A/iwKXR1Zk5clZo85gQPZh1DAXBgNVHREEEDAOggwqLmV0Y2QubG9jYWww
+DQYJKoZIhvcNAQENBQADggIBAHKU/dvRCfMXW2XurSpuIuGtnMn6ozSapiYETy3C
+9UZ1hPldZc4D7QE2MsC2nthEzXkrf+uU/TtYl2OR/DWjaCWX4zP1F3qyLSUiXdZh
+e48HQViLtLN8ZG+PRxM7KOW+DYChIRA+OAtYj9Ti6OiBOcnWY5K8MyJfNqq2wxD/
+ja+dGD3u4qeHlnsfloFwr0Nj1+fhj+PYrAKgRJ7VsPKNisDgTWnBGfzO9pFY9e1E
+aAoPDQJEfxpnEzupATfrHeEKBJVBj2SW1MX0zUwDv9NS7+AToxBuRbNtdsC7zfrS
+657LAGQMHcahxuLvQQjYhP662ke98JsYNld49i/SP4o4ViK16BURwAHlm1ljNw43
+7WQxdCuH7Fk5lXouaX+Btn5pkKGvguQfuW3T6lU+Kv2i3ZRKPdvhyN+aSfK7t8Rp
+G2tDodGjZDorV6ZjBbMNUKHK8J/r+MHYiU95JIgjfn3pXztU0Nxhq15eIW+74yug
+IZQfZ5TIMUlmhtR5truKSvdrwJqznFzPfr1iupyy30HhIHLVxy3fmyXHjdD9YeHC
+CjQu+juiJrVo2JCrmlp/pEIe7sY2UnzkC30tJT1Ys4tRSlbN8YHrzdSgcd/0bkSA
+TlkDkee6yb5jKf9/xHtUYFhGu3nLDX9aJwkJcKuZ0pz8yjlBK7sN/HFsQACbAVeW
+aGks
+-----END CERTIFICATE-----
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures/server-wildcard.key.insecure b/vendor/github.com/coreos/etcd/integration/fixtures/server-wildcard.key.insecure
new file mode 100644
index 00000000..0806784d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures/server-wildcard.key.insecure
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpAIBAAKCAQEApWhiArnVi9i2wiMQRLbElAvXBc7JMB9PvTNe5yjfZgOncT1p
+zit5C7i3FeZI83O9JHnIU8x1x30kgsOw6M1H3nEEJccXkWbH/7BifPGlKp5p/aGA
+NGH99q2eTODJMnmTNbhtu/Tfyy1LwbdcKI4JnXcPVYYDNxUNsAvC+k8AjwhEeNKQ
+4y8dsKo7BnfzNg9osQUnp0SpwzKyHtc2OUUGDH0l9GNc5pK95XdknzKXiIdvE3xv
+LZjsdfcvvpgd5M/FSSpJwtgG3Z1//ItwVfmOA1mZcUewk9X5QYod+fMPukziIgUe
+srhK5KbImFD+XbeLck2McTCJB5fmyFkcbMEUOwIDAQABAoIBAFFMoP/d/0whVJLP
+USu0+aIav7EnFlQEz9ia60aLHGKz4RUTrnGbhH9yZuroqWqftJO9F+24TRukMtHj
+BY0neO+odPVsifT5o8vVElN/IkN0YXw8aRtWHtGkPG5k/f9FKkn5QFZl4amntdid
+GzsDtU4kOvE6UVI9kuC4pzkIo6mpCDmDFu9SzsSKVAakKPPrvZ7w25jiyBuJUYKF
+XOMOlTviZjbrsEW2BsNF/HNZywH3YRcE1jfiRHcQMLyF4Bk1VJSrPh4ahXlvTWmO
+/5Pwl7OIaxFUSjrjSioRXP9VJRMgeMH0D2giQCHDXzYrqg6cxGTCwLnvVNagVBLx
+/uiVFuECgYEAxyA11z778PyIxpbPxC6ui+vODKRh+sHERFUkhJTXLfYFZ55fIJ24
+XjQJkZp8qMLhiBoqZjYvVCp+HUmyXoS2ts+DwNP+r/dOm/yyc1DsAyhvb39g9tHO
+a2IjhkOiR5z6OxgYuv90gefq0glyVvFzmIhnRi398lhXJ2OU4XJWxHUCgYEA1KbB
+iKKAT5Tvw3T23Z2T52YEorTS2DfPyp07zmiKxSdJiW2Or0mZAtNwDT72emy+9bSD
+THs9PvS/Csoq6pWer1humF84K6qZ/ICPQnzt6jDG44R8vkdPdBSm2K8lWqlXxYFp
+ya3Y8Fen5XFxEvrp7eD5NYkqZY3tqRVO8c9vn+8CgYEAxQz0+tqTSzk8yPj5BbUE
+eeaR8yTA6PrTFKQFDUaVYiAx3QZ2MLqjdmWcioAMmJyxvpPWHWvFjk62mpkRcEN4
+5JOaWDnxsYTUP7zjgwYzaDSdggLVm6qn0NA/Q2CuuJt5bP09i9+8FcnBMLS0d6Fc
+uTdSq7pbsXUGWi5LaIZTovkCgYBacbpqxMLSFkSL21mMFJNtneRm14W91K8aPBnN
+xoUPKZCLVP+U6jacDxXfbGIk28+0bVxS0S/RcQM4MZhjQdPGPFR9ljIr0FnCHWPR
+IZWHP8u3xQfRXj8a3hXAn23By7i7FjnKP5i/UGjmm4M+UV3hgQg9juNrYhwtCBUV
+n+aYHQKBgQCtidqW1EajQmZL26mzCb9ChtAgRT0fR4ui3wA2b4aZGu9CmJdRBS2K
+K6XjqlQhFDtARWc8Svwuw5FZ+SJNDBFiHmuxu3uwmzMsPPgMk9YJxh5olu/ZgiKg
+GApXR4U+CKlKLzeGk2WgpmfsF3KR12aUuc+BQnaeILRBZqjR0W4kvw==
+-----END RSA PRIVATE KEY-----
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures/server.crt b/vendor/github.com/coreos/etcd/integration/fixtures/server.crt
new file mode 100644
index 00000000..d54d9c28
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures/server.crt
@@ -0,0 +1,35 @@
+-----BEGIN CERTIFICATE-----
+MIIGEjCCA/qgAwIBAgIUPViBCYkAU+aOqe9Db3rdN4EJxj8wDQYJKoZIhvcNAQEN
+BQAwbzEMMAoGA1UEBhMDVVNBMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQH
+Ew1TYW4gRnJhbmNpc2NvMQ0wCwYDVQQKEwRldGNkMRYwFAYDVQQLEw1ldGNkIFNl
+Y3VyaXR5MQswCQYDVQQDEwJjYTAeFw0xNzA3MjAyMjA1MDBaFw0yNzA3MTgyMjA1
+MDBaMHgxDDAKBgNVBAYTA1VTQTETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UE
+BxMNU2FuIEZyYW5jaXNjbzENMAsGA1UEChMEZXRjZDEWMBQGA1UECxMNZXRjZCBT
+ZWN1cml0eTEUMBIGA1UEAxMLZXhhbXBsZS5jb20wggIiMA0GCSqGSIb3DQEBAQUA
+A4ICDwAwggIKAoICAQDi5InXatzyDc9B+ho+S4+6O1ZmIU44OMOnNfROaYBz4wnH
+xGRcwFPBONVT+mAZ7CIdXV02oxHAJ2d5+Asjkt3p93dWJk+Q3DTnBL/3puPDUXt7
+LCuYJ8sQrihqoF7KVHZeDVKUXMDKTwp0CnyDXAEG0wNbI81AqDA/umo1Kh9gacP6
+1z4129EybwRd7K/ZqC97Zo36qsT3iCKrxS2njvQbbBfqr7njpFxF0qTBgDERhFeR
+SFcaMPn1v0AFvaFFczTQDCVvSdLD0XswJVhe29DI0TsB/f85OV8R5rHcBXNvHdzB
+vYpfH6Iy10/lKCj1CDNsGxaZHK3nhwODeTxa6qQCfFSRBvL8e5ieBNekHK0mM2pb
+8P4nu3Xo4C3FMUDmO2qE0xYaJ076nTqkMQRYoLM/hTQzbIaXt2kUw9D6oqbmu3xt
+gaZTFZjHveXVRg3hzjUKVLeqHqB2nMozBtx9wSCOvLCZSKj8DHwvh5kJrJpxYgpM
+9uNQk32XL+QYF/OK2eIFVU9Mk1NC7PtrsQczdvFyAAkCTBzba0xOd3VzK8SQQmCr
+RBFmsIAABPzPUv1WkwsWbYz5LaWOJXKUGMC00dH97eD6apgvA7jK2ILO14ETbNm9
+hxod/DZqr6z8ijlw3WcqHzjYW49oZYg9H6YCRisf3yWuWFTWyL03fM00RgCSYwID
+AQABo4GcMIGZMA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYI
+KwYBBQUHAwIwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQURgEb31GFrs1S/4cgV4ZI
+fonP7OkwHwYDVR0jBBgwFoAUp//gP4sCl0dWZOXJWaPOYED2YdQwGgYDVR0RBBMw
+EYIJbG9jYWxob3N0hwR/AAABMA0GCSqGSIb3DQEBDQUAA4ICAQBS506hAyC9R6qo
+KZY8E1tFeIxlkunnWqKrc/ElDxOvJOVJRJmY88KzyGN8v7gUog3RUmen4h5v6+SJ
+IY00ljeu8zSqYoBOajlX+ej8LnNcr4viq+m+eMljA3jt7TRyHt9TIZ5MOns+M7Vb
+HGTa9juRMfdX7oL8KdCsdzKVI7p8bK9qcE4JEDjDsh1vX5qc61hQfLyG6hkwTgyb
+WjFeCjhP41ZrxoTS85qtBsmCj0Rv7uPjvR4GI9MCP/q41sXve7ejcepLFPTl0diH
+E/5/9IO8TcrcaEBG8k5QvGoknW2vR8Y1IpcakcxoijjtDewJYcfMnB7uchBriGaR
+sHFE8t3kmjOCo7Ve3kdsOGmcQAi3rCQ6PTs8t11L1g435NOYrNP72D22N96YYgYT
+0VFNsJYUpDlGHGShTVtIAQFWlRmR9GxRb2OoJWN/JsxOuO++jc/SJw/X1NXOdpHH
+pp+OhQTZqkU1KRMkdtxqI4LcQUN6TL6BPeXFcCKJ8F7kQ78DntYFOdf/WVsoY/8i
+GmTIaCCGsB4yBDM6oe7WroVMgOd2ES+yeyyfyQr591/7peoFrTGUlVpZjjMHaGxl
+HORsnQO48dN6h7EIoKxG/cfrx3TwwaNgzWSQJdA5pB+Vsia4we92UK/r+5Lu8Uzv
+1DSnPpH/KZ1ASOH2ebWeBJP+PU8+cg==
+-----END CERTIFICATE-----
diff --git a/vendor/github.com/coreos/etcd/integration/fixtures/server.key.insecure b/vendor/github.com/coreos/etcd/integration/fixtures/server.key.insecure
new file mode 100644
index 00000000..563ab208
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/fixtures/server.key.insecure
@@ -0,0 +1,51 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIJKQIBAAKCAgEA4uSJ12rc8g3PQfoaPkuPujtWZiFOODjDpzX0TmmAc+MJx8Rk
+XMBTwTjVU/pgGewiHV1dNqMRwCdnefgLI5Ld6fd3ViZPkNw05wS/96bjw1F7eywr
+mCfLEK4oaqBeylR2Xg1SlFzAyk8KdAp8g1wBBtMDWyPNQKgwP7pqNSofYGnD+tc+
+NdvRMm8EXeyv2agve2aN+qrE94giq8Utp470G2wX6q+546RcRdKkwYAxEYRXkUhX
+GjD59b9ABb2hRXM00Awlb0nSw9F7MCVYXtvQyNE7Af3/OTlfEeax3AVzbx3cwb2K
+Xx+iMtdP5Sgo9QgzbBsWmRyt54cDg3k8WuqkAnxUkQby/HuYngTXpBytJjNqW/D+
+J7t16OAtxTFA5jtqhNMWGidO+p06pDEEWKCzP4U0M2yGl7dpFMPQ+qKm5rt8bYGm
+UxWYx73l1UYN4c41ClS3qh6gdpzKMwbcfcEgjrywmUio/Ax8L4eZCayacWIKTPbj
+UJN9ly/kGBfzitniBVVPTJNTQuz7a7EHM3bxcgAJAkwc22tMTnd1cyvEkEJgq0QR
+ZrCAAAT8z1L9VpMLFm2M+S2ljiVylBjAtNHR/e3g+mqYLwO4ytiCzteBE2zZvYca
+Hfw2aq+s/Io5cN1nKh842FuPaGWIPR+mAkYrH98lrlhU1si9N3zNNEYAkmMCAwEA
+AQKCAgBU1KuwzfSTz5P5EAB14Bx5vau8/aDYJmkIgIS6OHndWjqS5Ru9De+Co7Qm
+9Mqvhnjuz7SFNAzz8gefM50+jK/JxUtp+2LuP1bMNRttBYnMwg9P6yDVf7NNpj/Y
+NeOa9F9ZJNQGQnOWcFzxK+aH2oNLwONVVRptnTSE7za8b+ZRTtoGVCmfS3N4zscs
+Ms1ArMAr/BkDaovAHLcRz+QU7L7Z7d03UsJGmXIibPJKopo1+WwgFpLyaPNb7UiL
+nO3KIJvTWWc5p7lUm2Laimvy826pVokgYo3lIE0qTT2cjLEvD1Q1X593l0U2iwgF
+HrHJg2pudeZKEs32baVjp5VoTKhKzWZMugY/ZZG4fuOdmJRZksj4Op9Swk6F5cgT
+tZ+EWEK48jIWfxVyAyua41301APTZwohwWp1qc9QOkA/tuqULZLfsVGRqrupF8te
+UKbMG0MnTBKlL+ojGmFUSnrj2GBd4NSUbGLOve0TxvktTakKATdFMphE2A5JnvxC
+lET3J1THj4xsDX3XwJ2KDkNCv86VUK0EptsaP7C/h3DbRhqJU30VTRhGjmtpwXj4
+4+EKDmWKHpIXY9Qu/qMXm1utM1q39wUFYdTpVDY1/VcHVu1VDjqHwxJXwLzv3B5U
+u17P2RIqvgD2IT1Xo0phi9WgzcllMRlEREpuLPnAZ8sSRbdNKQKCAQEA70cRtk5E
+yPoQ8X18RFxllZle6MfIuYv1v6ojF9Cd/Klf/OKu1VAbXjcUxhH4gpKsdrvvA6TS
+6Io8UonR3zqMuBsY+/L817ZTr8N/Q+iLK5hkhj4p2J3uX6ipLmfuQovlL478LpR6
+nD1eB+2tF1yk76A5uyny1m+rUHufpdQ+MlsoV0kLdo18uRF02w5HY1D2S5/lTACz
+WAmFCe9mnuQK0YMFyfiM/oVp9GjuOkf15QBnKW5klJByrB7oxw64VPwyxR1kkJhF
+UkTb6AIHEGcZkI5pKyuifaGNhDk5b9x8R9nvqoNMRgNV9XR/euJ33W0BzePB5fAQ
+NIrw4Y6z+oKJhQKCAQEA8r/j9vtFucZYfxPGXauipqubPER7YyXNbbO6skaQm7T7
+CUzaJdAYwRorHsDZ8Cvii0W+iZ9s0JLekcPtEECoiVm7Xg8pcFfzMu/B7Cb7MkEu
+w1kxrhYkb9xLZtBUaPD5vD7irxUxnu13GB9pbMYc/vw78F7SYjh/xyZXUjA7EVza
+q2IgCS8oWqlROJBh4lzNPw787WPpBokeUujIY9HOcE7MFE8+p5AUm8Zz62sgY/4f
+AMrSWD+cQ71bCMcdu12O4PUFCZtUx+ON8p0Awoy5KZniyUwIbt8UAlaoCT581Xh1
+1BGEVHKkwv1nwuH6hOL80/9zl6yZSKu0mBgq+IK8xwKCAQAuh1tiYAXwLvBshUJM
+6Mq4NILIMVFPA3BePO9mCiMupqELw+jLgjBQOdXITmZMvcjbrd/kjYCVx4vDYRl2
+lyQWCO7qz21rZQERBKsSwX2OlKu3jw8EGHHqGBoN9BfYyOtgPCW9yRGuoCBQ2l72
+VAWes0GGq7mVCVH+7Is26/bMQ/2sO4AHJaxDMKnQjw5CudOrEQS9qsU1MWS1ceA6
+tY2FAD138OU5+SeJZ34rxyKBzXpCDD1yxkQGRFxvmOUvYXtd6UFM/M8+GDXK/9nv
+zpyiB49b3bhTRb8HHzmUDwP71N1OAwop8ywb9vNzKea1ICVhrBBgbjY4gWwl8GH/
+LLMhAoIBAQDHci4FARKavoJ7dm3nDFwJALn83G9cWPTeC2t7ikrKA/q1+3TI2J9e
+GPgQvnbRw9zQfS89t8UZ4XII5adjURyoLRerAl4Ttc9VrHPyaVy+P5wCWMhetkad
+uawh/007I7KsniZ1n74zS/wrz7M48dVlEyzUI7RLiwxBPhlEp+gALgBkC60ynpJT
+WwYmqUojSAhCpTfee9Y7znEhwazThtBMqhE3Jpzd451rF7SqWkw0m9gxOHN2mlzz
+syKWpbKh/Q6leer3p64Sxb4c9i5nqmN/8LXKmjPblGHGQhix76t1YRG+ed313HPO
+2ZFlJ3JDuJPuQtZgailO8fThegnkQNaFAoIBAQCCG81C/p7BcUPdKoCT0vKXEEeB
+4Kf0ziKy/1asIY365qAWXJ+wet/Y6erl4JddeUEp2IupB67G35uf/5Eit2+/4sOG
+utd8BwxPKxkDY/iah00+2jRuNp+CYMr9MnIfTJE5daxG/YPabhMpUxRPsdveBWUL
+sogPgEvbxvvlzg6NyQDsmCFRQfmwNZOsfUqOoFwmrE5Woz26y4wvF+ZooxOHnxx8
+RsoJy1DvJgKtisE5eVBAq4ToLiFdQsb4NP39JBPWeaRZTRonS6F2NZw/lTWqKnQk
+QZZMSoUwzJWFUqJ22sE4NHJzv17rJ3txnPtMroB0RPXcQUIywNn7mvF3ltZp
+-----END RSA PRIVATE KEY-----
diff --git a/vendor/github.com/coreos/etcd/integration/logger_test.go b/vendor/github.com/coreos/etcd/integration/logger_test.go
new file mode 100644
index 00000000..aecd7200
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/logger_test.go
@@ -0,0 +1,23 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import "github.com/coreos/pkg/capnslog"
+
+const defaultLogLevel = capnslog.CRITICAL
+
+func init() {
+ capnslog.SetGlobalLogLevel(defaultLogLevel)
+}
diff --git a/vendor/github.com/coreos/etcd/integration/main_test.go b/vendor/github.com/coreos/etcd/integration/main_test.go
new file mode 100644
index 00000000..2913ce51
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/main_test.go
@@ -0,0 +1,20 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package integration
+
+import (
+ "os"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestMain(m *testing.M) {
+ v := m.Run()
+ if v == 0 && testutil.CheckLeakedGoroutine() {
+ os.Exit(1)
+ }
+ os.Exit(v)
+}
diff --git a/vendor/github.com/coreos/etcd/integration/member_test.go b/vendor/github.com/coreos/etcd/integration/member_test.go
new file mode 100644
index 00000000..501d9183
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/member_test.go
@@ -0,0 +1,125 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/client"
+ "github.com/coreos/etcd/pkg/testutil"
+ "golang.org/x/net/context"
+)
+
+func TestPauseMember(t *testing.T) {
+ defer testutil.AfterTest(t)
+ c := NewCluster(t, 5)
+ c.Launch(t)
+ defer c.Terminate(t)
+
+ for i := 0; i < 5; i++ {
+ c.Members[i].Pause()
+ membs := append([]*member{}, c.Members[:i]...)
+ membs = append(membs, c.Members[i+1:]...)
+ c.waitLeader(t, membs)
+ clusterMustProgress(t, membs)
+ c.Members[i].Resume()
+ }
+ c.waitLeader(t, c.Members)
+ clusterMustProgress(t, c.Members)
+}
+
+func TestRestartMember(t *testing.T) {
+ defer testutil.AfterTest(t)
+ c := NewCluster(t, 3)
+ c.Launch(t)
+ defer c.Terminate(t)
+
+ for i := 0; i < 3; i++ {
+ c.Members[i].Stop(t)
+ membs := append([]*member{}, c.Members[:i]...)
+ membs = append(membs, c.Members[i+1:]...)
+ c.waitLeader(t, membs)
+ clusterMustProgress(t, membs)
+ err := c.Members[i].Restart(t)
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
+ c.waitLeader(t, c.Members)
+ clusterMustProgress(t, c.Members)
+}
+
+func TestLaunchDuplicateMemberShouldFail(t *testing.T) {
+ size := 3
+ c := NewCluster(t, size)
+ m := c.Members[0].Clone(t)
+ var err error
+ m.DataDir, err = ioutil.TempDir(os.TempDir(), "etcd")
+ if err != nil {
+ t.Fatal(err)
+ }
+ c.Launch(t)
+ defer c.Terminate(t)
+
+ if err := m.Launch(); err == nil {
+ t.Errorf("unexpect successful launch")
+ }
+}
+
+func TestSnapshotAndRestartMember(t *testing.T) {
+ defer testutil.AfterTest(t)
+ m := mustNewMember(t, memberConfig{name: "snapAndRestartTest"})
+ m.SnapCount = 100
+ m.Launch()
+ defer m.Terminate(t)
+ m.WaitOK(t)
+
+ resps := make([]*client.Response, 120)
+ var err error
+ for i := 0; i < 120; i++ {
+ cc := MustNewHTTPClient(t, []string{m.URL()}, nil)
+ kapi := client.NewKeysAPI(cc)
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ key := fmt.Sprintf("foo%d", i)
+ resps[i], err = kapi.Create(ctx, "/"+key, "bar")
+ if err != nil {
+ t.Fatalf("#%d: create on %s error: %v", i, m.URL(), err)
+ }
+ cancel()
+ }
+ m.Stop(t)
+ m.Restart(t)
+
+ m.WaitOK(t)
+ for i := 0; i < 120; i++ {
+ cc := MustNewHTTPClient(t, []string{m.URL()}, nil)
+ kapi := client.NewKeysAPI(cc)
+ ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
+ key := fmt.Sprintf("foo%d", i)
+ resp, err := kapi.Get(ctx, "/"+key, nil)
+ if err != nil {
+ t.Fatalf("#%d: get on %s error: %v", i, m.URL(), err)
+ }
+ cancel()
+
+ if !reflect.DeepEqual(resp.Node, resps[i].Node) {
+ t.Errorf("#%d: node = %v, want %v", i, resp.Node, resps[i].Node)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/integration/metrics_test.go b/vendor/github.com/coreos/etcd/integration/metrics_test.go
new file mode 100644
index 00000000..8e7d60a5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/metrics_test.go
@@ -0,0 +1,97 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "context"
+ "strconv"
+ "testing"
+ "time"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+// TestMetricDbSizeBoot checks that the db size metric is set on boot.
+func TestMetricDbSizeBoot(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ v, err := clus.Members[0].Metric("etcd_debugging_mvcc_db_total_size_in_bytes")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if v == "0" {
+ t.Fatalf("expected non-zero, got %q", v)
+ }
+}
+
+// TestMetricDbSizeDefrag checks that the db size metric is set after defrag.
+func TestMetricDbSizeDefrag(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.Client(0)).KV
+ mc := toGRPC(clus.Client(0)).Maintenance
+
+ // expand the db size
+ numPuts := 10
+ putreq := &pb.PutRequest{Key: []byte("k"), Value: make([]byte, 4096)}
+ for i := 0; i < numPuts; i++ {
+ if _, err := kvc.Put(context.TODO(), putreq); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ // wait for backend txn sync
+ time.Sleep(500 * time.Millisecond)
+
+ beforeDefrag, err := clus.Members[0].Metric("etcd_debugging_mvcc_db_total_size_in_bytes")
+ if err != nil {
+ t.Fatal(err)
+ }
+ bv, err := strconv.Atoi(beforeDefrag)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if expected := numPuts * len(putreq.Value); bv < expected {
+ t.Fatalf("expected db size greater than %d, got %d", expected, bv)
+ }
+
+ // clear out historical keys
+ creq := &pb.CompactionRequest{Revision: int64(numPuts), Physical: true}
+ if _, err := kvc.Compact(context.TODO(), creq); err != nil {
+ t.Fatal(err)
+ }
+
+ // defrag should give freed space back to fs
+ mc.Defragment(context.TODO(), &pb.DefragmentRequest{})
+ afterDefrag, err := clus.Members[0].Metric("etcd_debugging_mvcc_db_total_size_in_bytes")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ av, err := strconv.Atoi(afterDefrag)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if bv <= av {
+ t.Fatalf("expected less than %d, got %d after defrag", bv, av)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/integration/network_partition_test.go b/vendor/github.com/coreos/etcd/integration/network_partition_test.go
new file mode 100644
index 00000000..21130eb0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/network_partition_test.go
@@ -0,0 +1,160 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "fmt"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestNetworkPartition5MembersLeaderInMinority(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := NewClusterV3(t, &ClusterConfig{Size: 5})
+ defer clus.Terminate(t)
+
+ leadIndex := clus.WaitLeader(t)
+
+ // minority: leader, follower / majority: follower, follower, follower
+ minority := []int{leadIndex, (leadIndex + 1) % 5}
+ majority := []int{(leadIndex + 2) % 5, (leadIndex + 3) % 5, (leadIndex + 4) % 5}
+
+ minorityMembers := getMembersByIndexSlice(clus.cluster, minority)
+ majorityMembers := getMembersByIndexSlice(clus.cluster, majority)
+
+ // network partition (bi-directional)
+ injectPartition(t, minorityMembers, majorityMembers)
+
+ // minority leader must be lost
+ clus.waitNoLeader(t, minorityMembers)
+
+ // wait extra election timeout
+ time.Sleep(2 * majorityMembers[0].electionTimeout())
+
+ // new leader must be from majority
+ clus.waitLeader(t, majorityMembers)
+
+ // recover network partition (bi-directional)
+ recoverPartition(t, minorityMembers, majorityMembers)
+
+ // write to majority first
+ clusterMustProgress(t, append(majorityMembers, minorityMembers...))
+}
+
+func TestNetworkPartition5MembersLeaderInMajority(t *testing.T) {
+ // retry up to 3 times, in case of leader election on majority partition due to slow hardware
+ var err error
+ for i := 0; i < 3; i++ {
+ if err = testNetworkPartition5MembersLeaderInMajority(t); err == nil {
+ break
+ }
+ t.Logf("[%d] got %v", i, err)
+ }
+ if err != nil {
+ t.Fatalf("failed after 3 tries (%v)", err)
+ }
+}
+
+func testNetworkPartition5MembersLeaderInMajority(t *testing.T) error {
+ defer testutil.AfterTest(t)
+
+ clus := NewClusterV3(t, &ClusterConfig{Size: 5})
+ defer clus.Terminate(t)
+
+ leadIndex := clus.WaitLeader(t)
+
+ // majority: leader, follower, follower / minority: follower, follower
+ majority := []int{leadIndex, (leadIndex + 1) % 5, (leadIndex + 2) % 5}
+ minority := []int{(leadIndex + 3) % 5, (leadIndex + 4) % 5}
+
+ majorityMembers := getMembersByIndexSlice(clus.cluster, majority)
+ minorityMembers := getMembersByIndexSlice(clus.cluster, minority)
+
+ // network partition (bi-directional)
+ injectPartition(t, majorityMembers, minorityMembers)
+
+ // minority leader must be lost
+ clus.waitNoLeader(t, minorityMembers)
+
+ // wait extra election timeout
+ time.Sleep(2 * majorityMembers[0].electionTimeout())
+
+ // leader must be hold in majority
+ leadIndex2 := clus.waitLeader(t, majorityMembers)
+ leadID, leadID2 := clus.Members[leadIndex].s.ID(), majorityMembers[leadIndex2].s.ID()
+ if leadID != leadID2 {
+ return fmt.Errorf("unexpected leader change from %s, got %s", leadID, leadID2)
+ }
+
+ // recover network partition (bi-directional)
+ recoverPartition(t, majorityMembers, minorityMembers)
+
+ // write to majority first
+ clusterMustProgress(t, append(majorityMembers, minorityMembers...))
+ return nil
+}
+
+func TestNetworkPartition4Members(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := NewClusterV3(t, &ClusterConfig{Size: 4})
+ defer clus.Terminate(t)
+
+ leadIndex := clus.WaitLeader(t)
+
+ // groupA: leader, follower / groupB: follower, follower
+ groupA := []int{leadIndex, (leadIndex + 1) % 4}
+ groupB := []int{(leadIndex + 2) % 4, (leadIndex + 3) % 4}
+
+ leaderPartition := getMembersByIndexSlice(clus.cluster, groupA)
+ followerPartition := getMembersByIndexSlice(clus.cluster, groupB)
+
+ // network partition (bi-directional)
+ injectPartition(t, leaderPartition, followerPartition)
+
+ // no group has quorum, so leader must be lost in all members
+ clus.WaitNoLeader(t)
+
+ // recover network partition (bi-directional)
+ recoverPartition(t, leaderPartition, followerPartition)
+
+ // need to wait since it recovered with no leader
+ clus.WaitLeader(t)
+
+ clusterMustProgress(t, clus.Members)
+}
+
+func getMembersByIndexSlice(clus *cluster, idxs []int) []*member {
+ ms := make([]*member, len(idxs))
+ for i, idx := range idxs {
+ ms[i] = clus.Members[idx]
+ }
+ return ms
+}
+
+func injectPartition(t *testing.T, src, others []*member) {
+ for _, m := range src {
+ m.InjectPartition(t, others)
+ }
+}
+
+func recoverPartition(t *testing.T, src, others []*member) {
+ for _, m := range src {
+ m.RecoverPartition(t, others)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/integration/util_test.go b/vendor/github.com/coreos/etcd/integration/util_test.go
new file mode 100644
index 00000000..18894198
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/util_test.go
@@ -0,0 +1,62 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "io"
+ "os"
+ "path/filepath"
+
+ "github.com/coreos/etcd/pkg/transport"
+)
+
+// copyTLSFiles clones certs files to dst directory.
+func copyTLSFiles(ti transport.TLSInfo, dst string) (transport.TLSInfo, error) {
+ ci := transport.TLSInfo{
+ KeyFile: filepath.Join(dst, "server-key.pem"),
+ CertFile: filepath.Join(dst, "server.pem"),
+ TrustedCAFile: filepath.Join(dst, "etcd-root-ca.pem"),
+ ClientCertAuth: ti.ClientCertAuth,
+ }
+ if err := copyFile(ti.KeyFile, ci.KeyFile); err != nil {
+ return transport.TLSInfo{}, err
+ }
+ if err := copyFile(ti.CertFile, ci.CertFile); err != nil {
+ return transport.TLSInfo{}, err
+ }
+ if err := copyFile(ti.TrustedCAFile, ci.TrustedCAFile); err != nil {
+ return transport.TLSInfo{}, err
+ }
+ return ci, nil
+}
+
+func copyFile(src, dst string) error {
+ f, err := os.Open(src)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ w, err := os.Create(dst)
+ if err != nil {
+ return err
+ }
+ defer w.Close()
+
+ if _, err = io.Copy(w, f); err != nil {
+ return err
+ }
+ return w.Sync()
+}
diff --git a/vendor/github.com/coreos/etcd/integration/v2_http_kv_test.go b/vendor/github.com/coreos/etcd/integration/v2_http_kv_test.go
new file mode 100644
index 00000000..4b844447
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/v2_http_kv_test.go
@@ -0,0 +1,1153 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "encoding/json"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "net/http"
+ "net/url"
+ "reflect"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/pkg/transport"
+)
+
+func TestV2Set(t *testing.T) {
+ defer testutil.AfterTest(t)
+ cl := NewCluster(t, 1)
+ cl.Launch(t)
+ defer cl.Terminate(t)
+
+ u := cl.URL(0)
+ tc := NewTestClient()
+ v := url.Values{}
+ v.Set("value", "bar")
+ vAndNoValue := url.Values{}
+ vAndNoValue.Set("value", "bar")
+ vAndNoValue.Set("noValueOnSuccess", "true")
+
+ tests := []struct {
+ relativeURL string
+ value url.Values
+ wStatus int
+ w string
+ }{
+ {
+ "/v2/keys/foo/bar",
+ v,
+ http.StatusCreated,
+ `{"action":"set","node":{"key":"/foo/bar","value":"bar","modifiedIndex":4,"createdIndex":4}}`,
+ },
+ {
+ "/v2/keys/foodir?dir=true",
+ url.Values{},
+ http.StatusCreated,
+ `{"action":"set","node":{"key":"/foodir","dir":true,"modifiedIndex":5,"createdIndex":5}}`,
+ },
+ {
+ "/v2/keys/fooempty",
+ url.Values(map[string][]string{"value": {""}}),
+ http.StatusCreated,
+ `{"action":"set","node":{"key":"/fooempty","value":"","modifiedIndex":6,"createdIndex":6}}`,
+ },
+ {
+ "/v2/keys/foo/novalue",
+ vAndNoValue,
+ http.StatusCreated,
+ `{"action":"set"}`,
+ },
+ }
+
+ for i, tt := range tests {
+ resp, err := tc.PutForm(fmt.Sprintf("%s%s", u, tt.relativeURL), tt.value)
+ if err != nil {
+ t.Errorf("#%d: err = %v, want nil", i, err)
+ }
+ g := string(tc.ReadBody(resp))
+ w := tt.w + "\n"
+ if g != w {
+ t.Errorf("#%d: body = %v, want %v", i, g, w)
+ }
+ if resp.StatusCode != tt.wStatus {
+ t.Errorf("#%d: status = %d, want %d", i, resp.StatusCode, tt.wStatus)
+ }
+ }
+}
+
+func TestV2CreateUpdate(t *testing.T) {
+ defer testutil.AfterTest(t)
+ cl := NewCluster(t, 1)
+ cl.Launch(t)
+ defer cl.Terminate(t)
+
+ u := cl.URL(0)
+ tc := NewTestClient()
+
+ tests := []struct {
+ relativeURL string
+ value url.Values
+ wStatus int
+ w map[string]interface{}
+ }{
+ // key with ttl
+ {
+ "/v2/keys/ttl/foo",
+ url.Values(map[string][]string{"value": {"XXX"}, "ttl": {"20"}}),
+ http.StatusCreated,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "value": "XXX",
+ "ttl": float64(20),
+ },
+ },
+ },
+ // key with bad ttl
+ {
+ "/v2/keys/ttl/foo",
+ url.Values(map[string][]string{"value": {"XXX"}, "ttl": {"bad_ttl"}}),
+ http.StatusBadRequest,
+ map[string]interface{}{
+ "errorCode": float64(202),
+ "message": "The given TTL in POST form is not a number",
+ },
+ },
+ // create key
+ {
+ "/v2/keys/create/foo",
+ url.Values(map[string][]string{"value": {"XXX"}, "prevExist": {"false"}}),
+ http.StatusCreated,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "value": "XXX",
+ },
+ },
+ },
+ // created key failed
+ {
+ "/v2/keys/create/foo",
+ url.Values(map[string][]string{"value": {"XXX"}, "prevExist": {"false"}}),
+ http.StatusPreconditionFailed,
+ map[string]interface{}{
+ "errorCode": float64(105),
+ "message": "Key already exists",
+ "cause": "/create/foo",
+ },
+ },
+ // update the newly created key with ttl
+ {
+ "/v2/keys/create/foo",
+ url.Values(map[string][]string{"value": {"YYY"}, "prevExist": {"true"}, "ttl": {"20"}}),
+ http.StatusOK,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "value": "YYY",
+ "ttl": float64(20),
+ },
+ "action": "update",
+ },
+ },
+ // update the ttl to none
+ {
+ "/v2/keys/create/foo",
+ url.Values(map[string][]string{"value": {"ZZZ"}, "prevExist": {"true"}}),
+ http.StatusOK,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "value": "ZZZ",
+ },
+ "action": "update",
+ },
+ },
+ // update on a non-existing key
+ {
+ "/v2/keys/nonexist",
+ url.Values(map[string][]string{"value": {"XXX"}, "prevExist": {"true"}}),
+ http.StatusNotFound,
+ map[string]interface{}{
+ "errorCode": float64(100),
+ "message": "Key not found",
+ "cause": "/nonexist",
+ },
+ },
+ // create with no value on success
+ {
+ "/v2/keys/create/novalue",
+ url.Values(map[string][]string{"value": {"XXX"}, "prevExist": {"false"}, "noValueOnSuccess": {"true"}}),
+ http.StatusCreated,
+ map[string]interface{}{},
+ },
+ // update with no value on success
+ {
+ "/v2/keys/create/novalue",
+ url.Values(map[string][]string{"value": {"XXX"}, "prevExist": {"true"}, "noValueOnSuccess": {"true"}}),
+ http.StatusOK,
+ map[string]interface{}{},
+ },
+ // created key failed with no value on success
+ {
+ "/v2/keys/create/foo",
+ url.Values(map[string][]string{"value": {"XXX"}, "prevExist": {"false"}, "noValueOnSuccess": {"true"}}),
+ http.StatusPreconditionFailed,
+ map[string]interface{}{
+ "errorCode": float64(105),
+ "message": "Key already exists",
+ "cause": "/create/foo",
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ resp, err := tc.PutForm(fmt.Sprintf("%s%s", u, tt.relativeURL), tt.value)
+ if err != nil {
+ t.Fatalf("#%d: put err = %v, want nil", i, err)
+ }
+ if resp.StatusCode != tt.wStatus {
+ t.Errorf("#%d: status = %d, want %d", i, resp.StatusCode, tt.wStatus)
+ }
+ if err := checkBody(tc.ReadBodyJSON(resp), tt.w); err != nil {
+ t.Errorf("#%d: %v", i, err)
+ }
+ }
+}
+
+func TestV2CAS(t *testing.T) {
+ defer testutil.AfterTest(t)
+ cl := NewCluster(t, 1)
+ cl.Launch(t)
+ defer cl.Terminate(t)
+
+ u := cl.URL(0)
+ tc := NewTestClient()
+
+ tests := []struct {
+ relativeURL string
+ value url.Values
+ wStatus int
+ w map[string]interface{}
+ }{
+ {
+ "/v2/keys/cas/foo",
+ url.Values(map[string][]string{"value": {"XXX"}}),
+ http.StatusCreated,
+ nil,
+ },
+ {
+ "/v2/keys/cas/foo",
+ url.Values(map[string][]string{"value": {"YYY"}, "prevIndex": {"4"}}),
+ http.StatusOK,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "value": "YYY",
+ "modifiedIndex": float64(5),
+ },
+ "action": "compareAndSwap",
+ },
+ },
+ {
+ "/v2/keys/cas/foo",
+ url.Values(map[string][]string{"value": {"YYY"}, "prevIndex": {"10"}}),
+ http.StatusPreconditionFailed,
+ map[string]interface{}{
+ "errorCode": float64(101),
+ "message": "Compare failed",
+ "cause": "[10 != 5]",
+ "index": float64(5),
+ },
+ },
+ {
+ "/v2/keys/cas/foo",
+ url.Values(map[string][]string{"value": {"YYY"}, "prevIndex": {"bad_index"}}),
+ http.StatusBadRequest,
+ map[string]interface{}{
+ "errorCode": float64(203),
+ "message": "The given index in POST form is not a number",
+ },
+ },
+ {
+ "/v2/keys/cas/foo",
+ url.Values(map[string][]string{"value": {"ZZZ"}, "prevValue": {"YYY"}}),
+ http.StatusOK,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "value": "ZZZ",
+ },
+ "action": "compareAndSwap",
+ },
+ },
+ {
+ "/v2/keys/cas/foo",
+ url.Values(map[string][]string{"value": {"XXX"}, "prevValue": {"bad_value"}}),
+ http.StatusPreconditionFailed,
+ map[string]interface{}{
+ "errorCode": float64(101),
+ "message": "Compare failed",
+ "cause": "[bad_value != ZZZ]",
+ },
+ },
+ // prevValue is required
+ {
+ "/v2/keys/cas/foo",
+ url.Values(map[string][]string{"value": {"XXX"}, "prevValue": {""}}),
+ http.StatusBadRequest,
+ map[string]interface{}{
+ "errorCode": float64(201),
+ },
+ },
+ {
+ "/v2/keys/cas/foo",
+ url.Values(map[string][]string{"value": {"XXX"}, "prevValue": {"bad_value"}, "prevIndex": {"100"}}),
+ http.StatusPreconditionFailed,
+ map[string]interface{}{
+ "errorCode": float64(101),
+ "message": "Compare failed",
+ "cause": "[bad_value != ZZZ] [100 != 6]",
+ },
+ },
+ {
+ "/v2/keys/cas/foo",
+ url.Values(map[string][]string{"value": {"XXX"}, "prevValue": {"ZZZ"}, "prevIndex": {"100"}}),
+ http.StatusPreconditionFailed,
+ map[string]interface{}{
+ "errorCode": float64(101),
+ "message": "Compare failed",
+ "cause": "[100 != 6]",
+ },
+ },
+ {
+ "/v2/keys/cas/foo",
+ url.Values(map[string][]string{"value": {"XXX"}, "prevValue": {"bad_value"}, "prevIndex": {"6"}}),
+ http.StatusPreconditionFailed,
+ map[string]interface{}{
+ "errorCode": float64(101),
+ "message": "Compare failed",
+ "cause": "[bad_value != ZZZ]",
+ },
+ },
+ {
+ "/v2/keys/cas/foo",
+ url.Values(map[string][]string{"value": {"YYY"}, "prevIndex": {"6"}, "noValueOnSuccess": {"true"}}),
+ http.StatusOK,
+ map[string]interface{}{
+ "action": "compareAndSwap",
+ },
+ },
+ {
+ "/v2/keys/cas/foo",
+ url.Values(map[string][]string{"value": {"YYY"}, "prevIndex": {"10"}, "noValueOnSuccess": {"true"}}),
+ http.StatusPreconditionFailed,
+ map[string]interface{}{
+ "errorCode": float64(101),
+ "message": "Compare failed",
+ "cause": "[10 != 7]",
+ "index": float64(7),
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ resp, err := tc.PutForm(fmt.Sprintf("%s%s", u, tt.relativeURL), tt.value)
+ if err != nil {
+ t.Fatalf("#%d: put err = %v, want nil", i, err)
+ }
+ if resp.StatusCode != tt.wStatus {
+ t.Errorf("#%d: status = %d, want %d", i, resp.StatusCode, tt.wStatus)
+ }
+ if err := checkBody(tc.ReadBodyJSON(resp), tt.w); err != nil {
+ t.Errorf("#%d: %v", i, err)
+ }
+ }
+}
+
+func TestV2Delete(t *testing.T) {
+ defer testutil.AfterTest(t)
+ cl := NewCluster(t, 1)
+ cl.Launch(t)
+ defer cl.Terminate(t)
+
+ u := cl.URL(0)
+ tc := NewTestClient()
+
+ v := url.Values{}
+ v.Set("value", "XXX")
+ r, err := tc.PutForm(fmt.Sprintf("%s%s", u, "/v2/keys/foo"), v)
+ if err != nil {
+ t.Error(err)
+ }
+ r.Body.Close()
+ r, err = tc.PutForm(fmt.Sprintf("%s%s", u, "/v2/keys/emptydir?dir=true"), v)
+ if err != nil {
+ t.Error(err)
+ }
+ r.Body.Close()
+ r, err = tc.PutForm(fmt.Sprintf("%s%s", u, "/v2/keys/foodir/bar?dir=true"), v)
+ if err != nil {
+ t.Error(err)
+ }
+ r.Body.Close()
+
+ tests := []struct {
+ relativeURL string
+ wStatus int
+ w map[string]interface{}
+ }{
+ {
+ "/v2/keys/foo",
+ http.StatusOK,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/foo",
+ },
+ "prevNode": map[string]interface{}{
+ "key": "/foo",
+ "value": "XXX",
+ },
+ "action": "delete",
+ },
+ },
+ {
+ "/v2/keys/emptydir",
+ http.StatusForbidden,
+ map[string]interface{}{
+ "errorCode": float64(102),
+ "message": "Not a file",
+ "cause": "/emptydir",
+ },
+ },
+ {
+ "/v2/keys/emptydir?dir=true",
+ http.StatusOK,
+ nil,
+ },
+ {
+ "/v2/keys/foodir?dir=true",
+ http.StatusForbidden,
+ map[string]interface{}{
+ "errorCode": float64(108),
+ "message": "Directory not empty",
+ "cause": "/foodir",
+ },
+ },
+ {
+ "/v2/keys/foodir?recursive=true",
+ http.StatusOK,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/foodir",
+ "dir": true,
+ },
+ "prevNode": map[string]interface{}{
+ "key": "/foodir",
+ "dir": true,
+ },
+ "action": "delete",
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ resp, err := tc.DeleteForm(fmt.Sprintf("%s%s", u, tt.relativeURL), nil)
+ if err != nil {
+ t.Fatalf("#%d: delete err = %v, want nil", i, err)
+ }
+ if resp.StatusCode != tt.wStatus {
+ t.Errorf("#%d: status = %d, want %d", i, resp.StatusCode, tt.wStatus)
+ }
+ if err := checkBody(tc.ReadBodyJSON(resp), tt.w); err != nil {
+ t.Errorf("#%d: %v", i, err)
+ }
+ }
+}
+
+func TestV2CAD(t *testing.T) {
+ defer testutil.AfterTest(t)
+ cl := NewCluster(t, 1)
+ cl.Launch(t)
+ defer cl.Terminate(t)
+
+ u := cl.URL(0)
+ tc := NewTestClient()
+
+ v := url.Values{}
+ v.Set("value", "XXX")
+ r, err := tc.PutForm(fmt.Sprintf("%s%s", u, "/v2/keys/foo"), v)
+ if err != nil {
+ t.Error(err)
+ }
+ r.Body.Close()
+
+ r, err = tc.PutForm(fmt.Sprintf("%s%s", u, "/v2/keys/foovalue"), v)
+ if err != nil {
+ t.Error(err)
+ }
+ r.Body.Close()
+
+ tests := []struct {
+ relativeURL string
+ wStatus int
+ w map[string]interface{}
+ }{
+ {
+ "/v2/keys/foo?prevIndex=100",
+ http.StatusPreconditionFailed,
+ map[string]interface{}{
+ "errorCode": float64(101),
+ "message": "Compare failed",
+ "cause": "[100 != 4]",
+ },
+ },
+ {
+ "/v2/keys/foo?prevIndex=bad_index",
+ http.StatusBadRequest,
+ map[string]interface{}{
+ "errorCode": float64(203),
+ "message": "The given index in POST form is not a number",
+ },
+ },
+ {
+ "/v2/keys/foo?prevIndex=4",
+ http.StatusOK,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/foo",
+ "modifiedIndex": float64(6),
+ },
+ "action": "compareAndDelete",
+ },
+ },
+ {
+ "/v2/keys/foovalue?prevValue=YYY",
+ http.StatusPreconditionFailed,
+ map[string]interface{}{
+ "errorCode": float64(101),
+ "message": "Compare failed",
+ "cause": "[YYY != XXX]",
+ },
+ },
+ {
+ "/v2/keys/foovalue?prevValue=",
+ http.StatusBadRequest,
+ map[string]interface{}{
+ "errorCode": float64(201),
+ "cause": `"prevValue" cannot be empty`,
+ },
+ },
+ {
+ "/v2/keys/foovalue?prevValue=XXX",
+ http.StatusOK,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/foovalue",
+ "modifiedIndex": float64(7),
+ },
+ "action": "compareAndDelete",
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ resp, err := tc.DeleteForm(fmt.Sprintf("%s%s", u, tt.relativeURL), nil)
+ if err != nil {
+ t.Fatalf("#%d: delete err = %v, want nil", i, err)
+ }
+ if resp.StatusCode != tt.wStatus {
+ t.Errorf("#%d: status = %d, want %d", i, resp.StatusCode, tt.wStatus)
+ }
+ if err := checkBody(tc.ReadBodyJSON(resp), tt.w); err != nil {
+ t.Errorf("#%d: %v", i, err)
+ }
+ }
+}
+
+func TestV2Unique(t *testing.T) {
+ defer testutil.AfterTest(t)
+ cl := NewCluster(t, 1)
+ cl.Launch(t)
+ defer cl.Terminate(t)
+
+ u := cl.URL(0)
+ tc := NewTestClient()
+
+ tests := []struct {
+ relativeURL string
+ value url.Values
+ wStatus int
+ w map[string]interface{}
+ }{
+ {
+ "/v2/keys/foo",
+ url.Values(map[string][]string{"value": {"XXX"}}),
+ http.StatusCreated,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/foo/00000000000000000004",
+ "value": "XXX",
+ },
+ "action": "create",
+ },
+ },
+ {
+ "/v2/keys/foo",
+ url.Values(map[string][]string{"value": {"XXX"}}),
+ http.StatusCreated,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/foo/00000000000000000005",
+ "value": "XXX",
+ },
+ "action": "create",
+ },
+ },
+ {
+ "/v2/keys/bar",
+ url.Values(map[string][]string{"value": {"XXX"}}),
+ http.StatusCreated,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/bar/00000000000000000006",
+ "value": "XXX",
+ },
+ "action": "create",
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ resp, err := tc.PostForm(fmt.Sprintf("%s%s", u, tt.relativeURL), tt.value)
+ if err != nil {
+ t.Fatalf("#%d: post err = %v, want nil", i, err)
+ }
+ if resp.StatusCode != tt.wStatus {
+ t.Errorf("#%d: status = %d, want %d", i, resp.StatusCode, tt.wStatus)
+ }
+ if err := checkBody(tc.ReadBodyJSON(resp), tt.w); err != nil {
+ t.Errorf("#%d: %v", i, err)
+ }
+ }
+}
+
+func TestV2Get(t *testing.T) {
+ defer testutil.AfterTest(t)
+ cl := NewCluster(t, 1)
+ cl.Launch(t)
+ defer cl.Terminate(t)
+
+ u := cl.URL(0)
+ tc := NewTestClient()
+
+ v := url.Values{}
+ v.Set("value", "XXX")
+ r, err := tc.PutForm(fmt.Sprintf("%s%s", u, "/v2/keys/foo/bar/zar"), v)
+ if err != nil {
+ t.Error(err)
+ }
+ r.Body.Close()
+
+ tests := []struct {
+ relativeURL string
+ wStatus int
+ w map[string]interface{}
+ }{
+ {
+ "/v2/keys/foo/bar/zar",
+ http.StatusOK,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/foo/bar/zar",
+ "value": "XXX",
+ },
+ "action": "get",
+ },
+ },
+ {
+ "/v2/keys/foo",
+ http.StatusOK,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/foo",
+ "dir": true,
+ "nodes": []interface{}{
+ map[string]interface{}{
+ "key": "/foo/bar",
+ "dir": true,
+ "createdIndex": float64(4),
+ "modifiedIndex": float64(4),
+ },
+ },
+ },
+ "action": "get",
+ },
+ },
+ {
+ "/v2/keys/foo?recursive=true",
+ http.StatusOK,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/foo",
+ "dir": true,
+ "nodes": []interface{}{
+ map[string]interface{}{
+ "key": "/foo/bar",
+ "dir": true,
+ "createdIndex": float64(4),
+ "modifiedIndex": float64(4),
+ "nodes": []interface{}{
+ map[string]interface{}{
+ "key": "/foo/bar/zar",
+ "value": "XXX",
+ "createdIndex": float64(4),
+ "modifiedIndex": float64(4),
+ },
+ },
+ },
+ },
+ },
+ "action": "get",
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ resp, err := tc.Get(fmt.Sprintf("%s%s", u, tt.relativeURL))
+ if err != nil {
+ t.Fatalf("#%d: get err = %v, want nil", i, err)
+ }
+ if resp.StatusCode != tt.wStatus {
+ t.Errorf("#%d: status = %d, want %d", i, resp.StatusCode, tt.wStatus)
+ }
+ if resp.Header.Get("Content-Type") != "application/json" {
+ t.Errorf("#%d: header = %v, want %v", i, resp.Header.Get("Content-Type"), "application/json")
+ }
+ if err := checkBody(tc.ReadBodyJSON(resp), tt.w); err != nil {
+ t.Errorf("#%d: %v", i, err)
+ }
+ }
+}
+
+func TestV2QuorumGet(t *testing.T) {
+ defer testutil.AfterTest(t)
+ cl := NewCluster(t, 1)
+ cl.Launch(t)
+ defer cl.Terminate(t)
+
+ u := cl.URL(0)
+ tc := NewTestClient()
+
+ v := url.Values{}
+ v.Set("value", "XXX")
+ r, err := tc.PutForm(fmt.Sprintf("%s%s", u, "/v2/keys/foo/bar/zar?quorum=true"), v)
+ if err != nil {
+ t.Error(err)
+ }
+ r.Body.Close()
+
+ tests := []struct {
+ relativeURL string
+ wStatus int
+ w map[string]interface{}
+ }{
+ {
+ "/v2/keys/foo/bar/zar",
+ http.StatusOK,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/foo/bar/zar",
+ "value": "XXX",
+ },
+ "action": "get",
+ },
+ },
+ {
+ "/v2/keys/foo",
+ http.StatusOK,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/foo",
+ "dir": true,
+ "nodes": []interface{}{
+ map[string]interface{}{
+ "key": "/foo/bar",
+ "dir": true,
+ "createdIndex": float64(4),
+ "modifiedIndex": float64(4),
+ },
+ },
+ },
+ "action": "get",
+ },
+ },
+ {
+ "/v2/keys/foo?recursive=true",
+ http.StatusOK,
+ map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/foo",
+ "dir": true,
+ "nodes": []interface{}{
+ map[string]interface{}{
+ "key": "/foo/bar",
+ "dir": true,
+ "createdIndex": float64(4),
+ "modifiedIndex": float64(4),
+ "nodes": []interface{}{
+ map[string]interface{}{
+ "key": "/foo/bar/zar",
+ "value": "XXX",
+ "createdIndex": float64(4),
+ "modifiedIndex": float64(4),
+ },
+ },
+ },
+ },
+ },
+ "action": "get",
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ resp, err := tc.Get(fmt.Sprintf("%s%s", u, tt.relativeURL))
+ if err != nil {
+ t.Fatalf("#%d: get err = %v, want nil", i, err)
+ }
+ if resp.StatusCode != tt.wStatus {
+ t.Errorf("#%d: status = %d, want %d", i, resp.StatusCode, tt.wStatus)
+ }
+ if resp.Header.Get("Content-Type") != "application/json" {
+ t.Errorf("#%d: header = %v, want %v", i, resp.Header.Get("Content-Type"), "application/json")
+ }
+ if err := checkBody(tc.ReadBodyJSON(resp), tt.w); err != nil {
+ t.Errorf("#%d: %v", i, err)
+ }
+ }
+}
+
+func TestV2Watch(t *testing.T) {
+ defer testutil.AfterTest(t)
+ cl := NewCluster(t, 1)
+ cl.Launch(t)
+ defer cl.Terminate(t)
+
+ u := cl.URL(0)
+ tc := NewTestClient()
+
+ watchResp, err := tc.Get(fmt.Sprintf("%s%s", u, "/v2/keys/foo/bar?wait=true"))
+ if err != nil {
+ t.Fatalf("watch err = %v, want nil", err)
+ }
+
+ // Set a value.
+ v := url.Values{}
+ v.Set("value", "XXX")
+ resp, err := tc.PutForm(fmt.Sprintf("%s%s", u, "/v2/keys/foo/bar"), v)
+ if err != nil {
+ t.Fatalf("put err = %v, want nil", err)
+ }
+ resp.Body.Close()
+
+ body := tc.ReadBodyJSON(watchResp)
+ w := map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/foo/bar",
+ "value": "XXX",
+ "modifiedIndex": float64(4),
+ },
+ "action": "set",
+ }
+
+ if err := checkBody(body, w); err != nil {
+ t.Error(err)
+ }
+}
+
+func TestV2WatchWithIndex(t *testing.T) {
+ defer testutil.AfterTest(t)
+ cl := NewCluster(t, 1)
+ cl.Launch(t)
+ defer cl.Terminate(t)
+
+ u := cl.URL(0)
+ tc := NewTestClient()
+
+ var body map[string]interface{}
+ c := make(chan bool, 1)
+ go func() {
+ resp, err := tc.Get(fmt.Sprintf("%s%s", u, "/v2/keys/foo/bar?wait=true&waitIndex=5"))
+ if err != nil {
+ t.Fatalf("watch err = %v, want nil", err)
+ }
+ body = tc.ReadBodyJSON(resp)
+ c <- true
+ }()
+
+ select {
+ case <-c:
+ t.Fatal("should not get the watch result")
+ case <-time.After(time.Millisecond):
+ }
+
+ // Set a value (before given index).
+ v := url.Values{}
+ v.Set("value", "XXX")
+ resp, err := tc.PutForm(fmt.Sprintf("%s%s", u, "/v2/keys/foo/bar"), v)
+ if err != nil {
+ t.Fatalf("put err = %v, want nil", err)
+ }
+ resp.Body.Close()
+
+ select {
+ case <-c:
+ t.Fatal("should not get the watch result")
+ case <-time.After(time.Millisecond):
+ }
+
+ // Set a value (before given index).
+ resp, err = tc.PutForm(fmt.Sprintf("%s%s", u, "/v2/keys/foo/bar"), v)
+ if err != nil {
+ t.Fatalf("put err = %v, want nil", err)
+ }
+ resp.Body.Close()
+
+ select {
+ case <-c:
+ case <-time.After(time.Second):
+ t.Fatal("cannot get watch result")
+ }
+
+ w := map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/foo/bar",
+ "value": "XXX",
+ "modifiedIndex": float64(5),
+ },
+ "action": "set",
+ }
+ if err := checkBody(body, w); err != nil {
+ t.Error(err)
+ }
+}
+
+func TestV2WatchKeyInDir(t *testing.T) {
+ defer testutil.AfterTest(t)
+ cl := NewCluster(t, 1)
+ cl.Launch(t)
+ defer cl.Terminate(t)
+
+ u := cl.URL(0)
+ tc := NewTestClient()
+
+ var body map[string]interface{}
+ c := make(chan bool)
+
+ // Create an expiring directory
+ v := url.Values{}
+ v.Set("dir", "true")
+ v.Set("ttl", "1")
+ resp, err := tc.PutForm(fmt.Sprintf("%s%s", u, "/v2/keys/keyindir"), v)
+ if err != nil {
+ t.Fatalf("put err = %v, want nil", err)
+ }
+ resp.Body.Close()
+
+ // Create a permanent node within the directory
+ v = url.Values{}
+ v.Set("value", "XXX")
+ resp, err = tc.PutForm(fmt.Sprintf("%s%s", u, "/v2/keys/keyindir/bar"), v)
+ if err != nil {
+ t.Fatalf("put err = %v, want nil", err)
+ }
+ resp.Body.Close()
+
+ go func() {
+ // Expect a notification when watching the node
+ resp, err := tc.Get(fmt.Sprintf("%s%s", u, "/v2/keys/keyindir/bar?wait=true"))
+ if err != nil {
+ t.Fatalf("watch err = %v, want nil", err)
+ }
+ body = tc.ReadBodyJSON(resp)
+ c <- true
+ }()
+
+ select {
+ case <-c:
+ // 1s ttl + 0.5s sync delay + 1.5s disk and network delay
+ // We set that long disk and network delay because travis may be slow
+ // when do system calls.
+ case <-time.After(3 * time.Second):
+ t.Fatal("timed out waiting for watch result")
+ }
+
+ w := map[string]interface{}{
+ "node": map[string]interface{}{
+ "key": "/keyindir",
+ },
+ "action": "expire",
+ }
+ if err := checkBody(body, w); err != nil {
+ t.Error(err)
+ }
+}
+
+func TestV2Head(t *testing.T) {
+ defer testutil.AfterTest(t)
+ cl := NewCluster(t, 1)
+ cl.Launch(t)
+ defer cl.Terminate(t)
+
+ u := cl.URL(0)
+ tc := NewTestClient()
+
+ v := url.Values{}
+ v.Set("value", "XXX")
+ fullURL := fmt.Sprintf("%s%s", u, "/v2/keys/foo/bar")
+ resp, err := tc.Head(fullURL)
+ if err != nil {
+ t.Fatalf("head err = %v, want nil", err)
+ }
+ resp.Body.Close()
+ if resp.StatusCode != http.StatusNotFound {
+ t.Errorf("status = %d, want %d", resp.StatusCode, http.StatusNotFound)
+ }
+ if resp.ContentLength <= 0 {
+ t.Errorf("ContentLength = %d, want > 0", resp.ContentLength)
+ }
+
+ resp, err = tc.PutForm(fullURL, v)
+ if err != nil {
+ t.Fatalf("put err = %v, want nil", err)
+ }
+ resp.Body.Close()
+
+ resp, err = tc.Head(fullURL)
+ if err != nil {
+ t.Fatalf("head err = %v, want nil", err)
+ }
+ resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ t.Errorf("status = %d, want %d", resp.StatusCode, http.StatusOK)
+ }
+ if resp.ContentLength <= 0 {
+ t.Errorf("ContentLength = %d, want > 0", resp.ContentLength)
+ }
+}
+
+func checkBody(body map[string]interface{}, w map[string]interface{}) error {
+ if body["node"] != nil {
+ if w["node"] != nil {
+ wn := w["node"].(map[string]interface{})
+ n := body["node"].(map[string]interface{})
+ for k := range n {
+ if wn[k] == nil {
+ delete(n, k)
+ }
+ }
+ body["node"] = n
+ }
+ if w["prevNode"] != nil {
+ wn := w["prevNode"].(map[string]interface{})
+ n := body["prevNode"].(map[string]interface{})
+ for k := range n {
+ if wn[k] == nil {
+ delete(n, k)
+ }
+ }
+ body["prevNode"] = n
+ }
+ }
+ for k, v := range w {
+ g := body[k]
+ if !reflect.DeepEqual(g, v) {
+ return fmt.Errorf("%v = %+v, want %+v", k, g, v)
+ }
+ }
+ return nil
+}
+
+type testHttpClient struct {
+ *http.Client
+}
+
+// Creates a new HTTP client with KeepAlive disabled.
+func NewTestClient() *testHttpClient {
+ tr, _ := transport.NewTransport(transport.TLSInfo{}, time.Second)
+ tr.DisableKeepAlives = true
+ return &testHttpClient{&http.Client{Transport: tr}}
+}
+
+// Reads the body from the response and closes it.
+func (t *testHttpClient) ReadBody(resp *http.Response) []byte {
+ if resp == nil {
+ return []byte{}
+ }
+ body, _ := ioutil.ReadAll(resp.Body)
+ resp.Body.Close()
+ return body
+}
+
+// Reads the body from the response and parses it as JSON.
+func (t *testHttpClient) ReadBodyJSON(resp *http.Response) map[string]interface{} {
+ m := make(map[string]interface{})
+ b := t.ReadBody(resp)
+ if err := json.Unmarshal(b, &m); err != nil {
+ panic(fmt.Sprintf("HTTP body JSON parse error: %v: %s", err, string(b)))
+ }
+ return m
+}
+
+func (t *testHttpClient) Head(url string) (*http.Response, error) {
+ return t.send("HEAD", url, "application/json", nil)
+}
+
+func (t *testHttpClient) Get(url string) (*http.Response, error) {
+ return t.send("GET", url, "application/json", nil)
+}
+
+func (t *testHttpClient) Post(url string, bodyType string, body io.Reader) (*http.Response, error) {
+ return t.send("POST", url, bodyType, body)
+}
+
+func (t *testHttpClient) PostForm(url string, data url.Values) (*http.Response, error) {
+ return t.Post(url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode()))
+}
+
+func (t *testHttpClient) Put(url string, bodyType string, body io.Reader) (*http.Response, error) {
+ return t.send("PUT", url, bodyType, body)
+}
+
+func (t *testHttpClient) PutForm(url string, data url.Values) (*http.Response, error) {
+ return t.Put(url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode()))
+}
+
+func (t *testHttpClient) Delete(url string, bodyType string, body io.Reader) (*http.Response, error) {
+ return t.send("DELETE", url, bodyType, body)
+}
+
+func (t *testHttpClient) DeleteForm(url string, data url.Values) (*http.Response, error) {
+ return t.Delete(url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode()))
+}
+
+func (t *testHttpClient) send(method string, url string, bodyType string, body io.Reader) (*http.Response, error) {
+ req, err := http.NewRequest(method, url, body)
+ if err != nil {
+ return nil, err
+ }
+ req.Header.Set("Content-Type", bodyType)
+ return t.Do(req)
+}
diff --git a/vendor/github.com/coreos/etcd/integration/v3_auth_test.go b/vendor/github.com/coreos/etcd/integration/v3_auth_test.go
new file mode 100644
index 00000000..06ee68ec
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/v3_auth_test.go
@@ -0,0 +1,120 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "testing"
+ "time"
+
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+// TestV3AuthEmptyUserGet ensures that a get with an empty user will return an empty user error.
+func TestV3AuthEmptyUserGet(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
+ defer cancel()
+
+ api := toGRPC(clus.Client(0))
+ authSetupRoot(t, api.Auth)
+
+ _, err := api.KV.Range(ctx, &pb.RangeRequest{Key: []byte("abc")})
+ if !eqErrGRPC(err, rpctypes.ErrUserEmpty) {
+ t.Fatalf("got %v, expected %v", err, rpctypes.ErrUserEmpty)
+ }
+}
+
+// TestV3AuthTokenWithDisable tests that auth won't crash if
+// given a valid token when authentication is disabled
+func TestV3AuthTokenWithDisable(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ authSetupRoot(t, toGRPC(clus.Client(0)).Auth)
+
+ c, cerr := clientv3.New(clientv3.Config{Endpoints: clus.Client(0).Endpoints(), Username: "root", Password: "123"})
+ if cerr != nil {
+ t.Fatal(cerr)
+ }
+ defer c.Close()
+
+ rctx, cancel := context.WithCancel(context.TODO())
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ for rctx.Err() == nil {
+ c.Put(rctx, "abc", "def")
+ }
+ }()
+
+ time.Sleep(10 * time.Millisecond)
+ if _, err := c.AuthDisable(context.TODO()); err != nil {
+ t.Fatal(err)
+ }
+ time.Sleep(10 * time.Millisecond)
+
+ cancel()
+ <-donec
+}
+
+func TestV3AuthRevision(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ api := toGRPC(clus.Client(0))
+
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ presp, perr := api.KV.Put(ctx, &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")})
+ cancel()
+ if perr != nil {
+ t.Fatal(perr)
+ }
+ rev := presp.Header.Revision
+
+ ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
+ aresp, aerr := api.Auth.UserAdd(ctx, &pb.AuthUserAddRequest{Name: "root", Password: "123"})
+ cancel()
+ if aerr != nil {
+ t.Fatal(aerr)
+ }
+ if aresp.Header.Revision != rev {
+ t.Fatalf("revision expected %d, got %d", rev, aresp.Header.Revision)
+ }
+}
+
+func authSetupRoot(t *testing.T, auth pb.AuthClient) {
+ if _, err := auth.UserAdd(context.TODO(), &pb.AuthUserAddRequest{Name: "root", Password: "123"}); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := auth.RoleAdd(context.TODO(), &pb.AuthRoleAddRequest{Name: "root"}); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := auth.UserGrantRole(context.TODO(), &pb.AuthUserGrantRoleRequest{User: "root", Role: "root"}); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := auth.AuthEnable(context.TODO(), &pb.AuthEnableRequest{}); err != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/integration/v3_barrier_test.go b/vendor/github.com/coreos/etcd/integration/v3_barrier_test.go
new file mode 100644
index 00000000..f86999c4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/v3_barrier_test.go
@@ -0,0 +1,78 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/contrib/recipes"
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestBarrierSingleNode(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+ testBarrier(t, 5, func() *clientv3.Client { return clus.clients[0] })
+}
+
+func TestBarrierMultiNode(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+ testBarrier(t, 5, func() *clientv3.Client { return clus.RandClient() })
+}
+
+func testBarrier(t *testing.T, waiters int, chooseClient func() *clientv3.Client) {
+ b := recipe.NewBarrier(chooseClient(), "test-barrier")
+ if err := b.Hold(); err != nil {
+ t.Fatalf("could not hold barrier (%v)", err)
+ }
+ if err := b.Hold(); err == nil {
+ t.Fatalf("able to double-hold barrier")
+ }
+
+ donec := make(chan struct{})
+ for i := 0; i < waiters; i++ {
+ go func() {
+ br := recipe.NewBarrier(chooseClient(), "test-barrier")
+ if err := br.Wait(); err != nil {
+ t.Fatalf("could not wait on barrier (%v)", err)
+ }
+ donec <- struct{}{}
+ }()
+ }
+
+ select {
+ case <-donec:
+ t.Fatalf("barrier did not wait")
+ default:
+ }
+
+ if err := b.Release(); err != nil {
+ t.Fatalf("could not release barrier (%v)", err)
+ }
+
+ timerC := time.After(time.Duration(waiters*100) * time.Millisecond)
+ for i := 0; i < waiters; i++ {
+ select {
+ case <-timerC:
+ t.Fatalf("barrier timed out")
+ case <-donec:
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/integration/v3_double_barrier_test.go b/vendor/github.com/coreos/etcd/integration/v3_double_barrier_test.go
new file mode 100644
index 00000000..da520967
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/v3_double_barrier_test.go
@@ -0,0 +1,155 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3/concurrency"
+ "github.com/coreos/etcd/contrib/recipes"
+)
+
+func TestDoubleBarrier(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ waiters := 10
+ session, err := concurrency.NewSession(clus.RandClient())
+ if err != nil {
+ t.Error(err)
+ }
+ defer session.Orphan()
+
+ b := recipe.NewDoubleBarrier(session, "test-barrier", waiters)
+ donec := make(chan struct{})
+ for i := 0; i < waiters-1; i++ {
+ go func() {
+ session, err := concurrency.NewSession(clus.RandClient())
+ if err != nil {
+ t.Error(err)
+ }
+ defer session.Orphan()
+
+ bb := recipe.NewDoubleBarrier(session, "test-barrier", waiters)
+ if err := bb.Enter(); err != nil {
+ t.Fatalf("could not enter on barrier (%v)", err)
+ }
+ donec <- struct{}{}
+ if err := bb.Leave(); err != nil {
+ t.Fatalf("could not leave on barrier (%v)", err)
+ }
+ donec <- struct{}{}
+ }()
+ }
+
+ time.Sleep(10 * time.Millisecond)
+ select {
+ case <-donec:
+ t.Fatalf("barrier did not enter-wait")
+ default:
+ }
+
+ if err := b.Enter(); err != nil {
+ t.Fatalf("could not enter last barrier (%v)", err)
+ }
+
+ timerC := time.After(time.Duration(waiters*100) * time.Millisecond)
+ for i := 0; i < waiters-1; i++ {
+ select {
+ case <-timerC:
+ t.Fatalf("barrier enter timed out")
+ case <-donec:
+ }
+ }
+
+ time.Sleep(10 * time.Millisecond)
+ select {
+ case <-donec:
+ t.Fatalf("barrier did not leave-wait")
+ default:
+ }
+
+ b.Leave()
+ timerC = time.After(time.Duration(waiters*100) * time.Millisecond)
+ for i := 0; i < waiters-1; i++ {
+ select {
+ case <-timerC:
+ t.Fatalf("barrier leave timed out")
+ case <-donec:
+ }
+ }
+}
+
+func TestDoubleBarrierFailover(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ waiters := 10
+ donec := make(chan struct{})
+
+ s0, err := concurrency.NewSession(clus.clients[0])
+ if err != nil {
+ t.Error(err)
+ }
+ defer s0.Orphan()
+ s1, err := concurrency.NewSession(clus.clients[0])
+ if err != nil {
+ t.Error(err)
+ }
+ defer s1.Orphan()
+
+ // sacrificial barrier holder; lease will be revoked
+ go func() {
+ b := recipe.NewDoubleBarrier(s0, "test-barrier", waiters)
+ if berr := b.Enter(); berr != nil {
+ t.Fatalf("could not enter on barrier (%v)", berr)
+ }
+ donec <- struct{}{}
+ }()
+
+ for i := 0; i < waiters-1; i++ {
+ go func() {
+ b := recipe.NewDoubleBarrier(s1, "test-barrier", waiters)
+ if berr := b.Enter(); berr != nil {
+ t.Fatalf("could not enter on barrier (%v)", berr)
+ }
+ donec <- struct{}{}
+ b.Leave()
+ donec <- struct{}{}
+ }()
+ }
+
+ // wait for barrier enter to unblock
+ for i := 0; i < waiters; i++ {
+ select {
+ case <-donec:
+ case <-time.After(10 * time.Second):
+ t.Fatalf("timed out waiting for enter, %d", i)
+ }
+ }
+
+ if err = s0.Close(); err != nil {
+ t.Fatal(err)
+ }
+ // join on rest of waiters
+ for i := 0; i < waiters-1; i++ {
+ select {
+ case <-donec:
+ case <-time.After(10 * time.Second):
+ t.Fatalf("timed out waiting for leave, %d", i)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/integration/v3_election_test.go b/vendor/github.com/coreos/etcd/integration/v3_election_test.go
new file mode 100644
index 00000000..95f5b494
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/v3_election_test.go
@@ -0,0 +1,310 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "fmt"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/concurrency"
+ "golang.org/x/net/context"
+)
+
+// TestElectionWait tests if followers can correctly wait for elections.
+func TestElectionWait(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ leaders := 3
+ followers := 3
+ var clients []*clientv3.Client
+ newClient := makeMultiNodeClients(t, clus.cluster, &clients)
+
+ electedc := make(chan string)
+ nextc := []chan struct{}{}
+
+ // wait for all elections
+ donec := make(chan struct{})
+ for i := 0; i < followers; i++ {
+ nextc = append(nextc, make(chan struct{}))
+ go func(ch chan struct{}) {
+ for j := 0; j < leaders; j++ {
+ session, err := concurrency.NewSession(newClient())
+ if err != nil {
+ t.Error(err)
+ }
+ b := concurrency.NewElection(session, "test-election")
+
+ cctx, cancel := context.WithCancel(context.TODO())
+ defer cancel()
+ s, ok := <-b.Observe(cctx)
+ if !ok {
+ t.Fatalf("could not observe election; channel closed")
+ }
+ electedc <- string(s.Kvs[0].Value)
+ // wait for next election round
+ <-ch
+ session.Orphan()
+ }
+ donec <- struct{}{}
+ }(nextc[i])
+ }
+
+ // elect some leaders
+ for i := 0; i < leaders; i++ {
+ go func() {
+ session, err := concurrency.NewSession(newClient())
+ if err != nil {
+ t.Error(err)
+ }
+ defer session.Orphan()
+
+ e := concurrency.NewElection(session, "test-election")
+ ev := fmt.Sprintf("electval-%v", time.Now().UnixNano())
+ if err := e.Campaign(context.TODO(), ev); err != nil {
+ t.Fatalf("failed volunteer (%v)", err)
+ }
+ // wait for followers to accept leadership
+ for j := 0; j < followers; j++ {
+ s := <-electedc
+ if s != ev {
+ t.Errorf("wrong election value got %s, wanted %s", s, ev)
+ }
+ }
+ // let next leader take over
+ if err := e.Resign(context.TODO()); err != nil {
+ t.Fatalf("failed resign (%v)", err)
+ }
+ // tell followers to start listening for next leader
+ for j := 0; j < followers; j++ {
+ nextc[j] <- struct{}{}
+ }
+ }()
+ }
+
+ // wait on followers
+ for i := 0; i < followers; i++ {
+ <-donec
+ }
+
+ closeClients(t, clients)
+}
+
+// TestElectionFailover tests that an election will
+func TestElectionFailover(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ cctx, cancel := context.WithCancel(context.TODO())
+ defer cancel()
+
+ ss := make([]*concurrency.Session, 3)
+
+ for i := 0; i < 3; i++ {
+ var err error
+ ss[i], err = concurrency.NewSession(clus.clients[i])
+ if err != nil {
+ t.Error(err)
+ }
+ defer ss[i].Orphan()
+ }
+
+ // first leader (elected)
+ e := concurrency.NewElection(ss[0], "test-election")
+ if err := e.Campaign(context.TODO(), "foo"); err != nil {
+ t.Fatalf("failed volunteer (%v)", err)
+ }
+
+ // check first leader
+ resp, ok := <-e.Observe(cctx)
+ if !ok {
+ t.Fatalf("could not wait for first election; channel closed")
+ }
+ s := string(resp.Kvs[0].Value)
+ if s != "foo" {
+ t.Fatalf("wrong election result. got %s, wanted foo", s)
+ }
+
+ // next leader
+ electedc := make(chan struct{})
+ go func() {
+ ee := concurrency.NewElection(ss[1], "test-election")
+ if eer := ee.Campaign(context.TODO(), "bar"); eer != nil {
+ t.Fatal(eer)
+ }
+ electedc <- struct{}{}
+ }()
+
+ // invoke leader failover
+ if err := ss[0].Close(); err != nil {
+ t.Fatal(err)
+ }
+
+ // check new leader
+ e = concurrency.NewElection(ss[2], "test-election")
+ resp, ok = <-e.Observe(cctx)
+ if !ok {
+ t.Fatalf("could not wait for second election; channel closed")
+ }
+ s = string(resp.Kvs[0].Value)
+ if s != "bar" {
+ t.Fatalf("wrong election result. got %s, wanted bar", s)
+ }
+
+ // leader must ack election (otherwise, Campaign may see closed conn)
+ <-electedc
+}
+
+// TestElectionSessionRelock ensures that campaigning twice on the same election
+// with the same lock will Proclaim instead of deadlocking.
+func TestElectionSessionRecampaign(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+ cli := clus.RandClient()
+
+ session, err := concurrency.NewSession(cli)
+ if err != nil {
+ t.Error(err)
+ }
+ defer session.Orphan()
+
+ e := concurrency.NewElection(session, "test-elect")
+ if err := e.Campaign(context.TODO(), "abc"); err != nil {
+ t.Fatal(err)
+ }
+ e2 := concurrency.NewElection(session, "test-elect")
+ if err := e2.Campaign(context.TODO(), "def"); err != nil {
+ t.Fatal(err)
+ }
+
+ ctx, cancel := context.WithCancel(context.TODO())
+ defer cancel()
+ if resp := <-e.Observe(ctx); len(resp.Kvs) == 0 || string(resp.Kvs[0].Value) != "def" {
+ t.Fatalf("expected value=%q, got response %v", "def", resp)
+ }
+}
+
+// TestElectionOnPrefixOfExistingKey checks that a single
+// candidate can be elected on a new key that is a prefix
+// of an existing key. To wit, check for regression
+// of bug #6278. https://github.com/coreos/etcd/issues/6278
+//
+func TestElectionOnPrefixOfExistingKey(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.RandClient()
+ if _, err := cli.Put(context.TODO(), "testa", "value"); err != nil {
+ t.Fatal(err)
+ }
+ s, serr := concurrency.NewSession(cli)
+ if serr != nil {
+ t.Fatal(serr)
+ }
+ e := concurrency.NewElection(s, "test")
+ ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
+ err := e.Campaign(ctx, "abc")
+ cancel()
+ if err != nil {
+ // after 5 seconds, deadlock results in
+ // 'context deadline exceeded' here.
+ t.Fatal(err)
+ }
+}
+
+// TestElectionOnSessionRestart tests that a quick restart of leader (resulting
+// in a new session with the same lease id) does not result in loss of
+// leadership.
+func TestElectionOnSessionRestart(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+ cli := clus.RandClient()
+
+ session, err := concurrency.NewSession(cli)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ e := concurrency.NewElection(session, "test-elect")
+ if cerr := e.Campaign(context.TODO(), "abc"); cerr != nil {
+ t.Fatal(cerr)
+ }
+
+ // ensure leader is not lost to waiter on fail-over
+ waitSession, werr := concurrency.NewSession(cli)
+ if werr != nil {
+ t.Fatal(werr)
+ }
+ defer waitSession.Orphan()
+ waitCtx, waitCancel := context.WithTimeout(context.TODO(), 5*time.Second)
+ defer waitCancel()
+ go concurrency.NewElection(waitSession, "test-elect").Campaign(waitCtx, "123")
+
+ // simulate restart by reusing the lease from the old session
+ newSession, nerr := concurrency.NewSession(cli, concurrency.WithLease(session.Lease()))
+ if nerr != nil {
+ t.Fatal(nerr)
+ }
+ defer newSession.Orphan()
+
+ newElection := concurrency.NewElection(newSession, "test-elect")
+ if ncerr := newElection.Campaign(context.TODO(), "def"); ncerr != nil {
+ t.Fatal(ncerr)
+ }
+
+ ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
+ defer cancel()
+ if resp := <-newElection.Observe(ctx); len(resp.Kvs) == 0 || string(resp.Kvs[0].Value) != "def" {
+ t.Errorf("expected value=%q, got response %v", "def", resp)
+ }
+}
+
+// TestElectionObserveCompacted checks that observe can tolerate
+// a leader key with a modrev less than the compaction revision.
+func TestElectionObserveCompacted(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.Client(0)
+
+ session, err := concurrency.NewSession(cli)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer session.Orphan()
+
+ e := concurrency.NewElection(session, "test-elect")
+ if cerr := e.Campaign(context.TODO(), "abc"); cerr != nil {
+ t.Fatal(cerr)
+ }
+
+ presp, perr := cli.Put(context.TODO(), "foo", "bar")
+ if perr != nil {
+ t.Fatal(perr)
+ }
+ if _, cerr := cli.Compact(context.TODO(), presp.Header.Revision); cerr != nil {
+ t.Fatal(cerr)
+ }
+
+ v, ok := <-e.Observe(context.TODO())
+ if !ok {
+ t.Fatal("failed to observe on compacted revision")
+ }
+ if string(v.Kvs[0].Value) != "abc" {
+ t.Fatalf(`expected leader value "abc", got %q`, string(v.Kvs[0].Value))
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/integration/v3_grpc_inflight_test.go b/vendor/github.com/coreos/etcd/integration/v3_grpc_inflight_test.go
new file mode 100644
index 00000000..1994af06
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/v3_grpc_inflight_test.go
@@ -0,0 +1,92 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "sync"
+ "testing"
+ "time"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/testutil"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+// TestV3MaintenanceDefragmentInflightRange ensures inflight range requests
+// does not panic the mvcc backend while defragment is running.
+func TestV3MaintenanceDefragmentInflightRange(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.RandClient()
+ kvc := toGRPC(cli).KV
+ if _, err := kvc.Put(context.Background(), &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}); err != nil {
+ t.Fatal(err)
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ kvc.Range(ctx, &pb.RangeRequest{Key: []byte("foo")})
+ }()
+
+ mvc := toGRPC(cli).Maintenance
+ mvc.Defragment(context.Background(), &pb.DefragmentRequest{})
+ cancel()
+
+ <-donec
+}
+
+// TestV3KVInflightRangeRequests ensures that inflight requests
+// (sent before server shutdown) are gracefully handled by server-side.
+// They are either finished or canceled, but never crash the backend.
+// See https://github.com/coreos/etcd/issues/7322 for more detail.
+func TestV3KVInflightRangeRequests(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.RandClient()
+ kvc := toGRPC(cli).KV
+
+ if _, err := kvc.Put(context.Background(), &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}); err != nil {
+ t.Fatal(err)
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
+
+ reqN := 10 // use 500+ for fast machine
+ var wg sync.WaitGroup
+ wg.Add(reqN)
+ for i := 0; i < reqN; i++ {
+ go func() {
+ defer wg.Done()
+ _, err := kvc.Range(ctx, &pb.RangeRequest{Key: []byte("foo"), Serializable: true}, grpc.FailFast(false))
+ if err != nil && grpc.ErrorDesc(err) != context.Canceled.Error() {
+ t.Fatalf("inflight request should be canceld with %v, got %v", context.Canceled, err)
+ }
+ }()
+ }
+
+ clus.Members[0].Stop(t)
+ cancel()
+
+ wg.Wait()
+}
diff --git a/vendor/github.com/coreos/etcd/integration/v3_grpc_test.go b/vendor/github.com/coreos/etcd/integration/v3_grpc_test.go
new file mode 100644
index 00000000..30de93cd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/v3_grpc_test.go
@@ -0,0 +1,1696 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "bytes"
+ "fmt"
+ "io/ioutil"
+ "math/rand"
+ "os"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/pkg/transport"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/metadata"
+)
+
+// TestV3PutOverwrite puts a key with the v3 api to a random cluster member,
+// overwrites it, then checks that the change was applied.
+func TestV3PutOverwrite(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.RandClient()).KV
+ key := []byte("foo")
+ reqput := &pb.PutRequest{Key: key, Value: []byte("bar"), PrevKv: true}
+
+ respput, err := kvc.Put(context.TODO(), reqput)
+ if err != nil {
+ t.Fatalf("couldn't put key (%v)", err)
+ }
+
+ // overwrite
+ reqput.Value = []byte("baz")
+ respput2, err := kvc.Put(context.TODO(), reqput)
+ if err != nil {
+ t.Fatalf("couldn't put key (%v)", err)
+ }
+ if respput2.Header.Revision <= respput.Header.Revision {
+ t.Fatalf("expected newer revision on overwrite, got %v <= %v",
+ respput2.Header.Revision, respput.Header.Revision)
+ }
+ if pkv := respput2.PrevKv; pkv == nil || string(pkv.Value) != "bar" {
+ t.Fatalf("expected PrevKv=bar, got response %+v", respput2)
+ }
+
+ reqrange := &pb.RangeRequest{Key: key}
+ resprange, err := kvc.Range(context.TODO(), reqrange)
+ if err != nil {
+ t.Fatalf("couldn't get key (%v)", err)
+ }
+ if len(resprange.Kvs) != 1 {
+ t.Fatalf("expected 1 key, got %v", len(resprange.Kvs))
+ }
+
+ kv := resprange.Kvs[0]
+ if kv.ModRevision <= kv.CreateRevision {
+ t.Errorf("expected modRev > createRev, got %d <= %d",
+ kv.ModRevision, kv.CreateRevision)
+ }
+ if !reflect.DeepEqual(reqput.Value, kv.Value) {
+ t.Errorf("expected value %v, got %v", reqput.Value, kv.Value)
+ }
+}
+
+// TestPutRestart checks if a put after an unrelated member restart succeeds
+func TestV3PutRestart(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kvIdx := rand.Intn(3)
+ kvc := toGRPC(clus.Client(kvIdx)).KV
+
+ stopIdx := kvIdx
+ for stopIdx == kvIdx {
+ stopIdx = rand.Intn(3)
+ }
+
+ clus.clients[stopIdx].Close()
+ clus.Members[stopIdx].Stop(t)
+ clus.Members[stopIdx].Restart(t)
+ c, cerr := NewClientV3(clus.Members[stopIdx])
+ if cerr != nil {
+ t.Fatalf("cannot create client: %v", cerr)
+ }
+ clus.clients[stopIdx] = c
+
+ ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
+ defer cancel()
+ reqput := &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}
+ _, err := kvc.Put(ctx, reqput)
+ if err != nil && err == ctx.Err() {
+ t.Fatalf("expected grpc error, got local ctx error (%v)", err)
+ }
+}
+
+// TestV3CompactCurrentRev ensures keys are present when compacting on current revision.
+func TestV3CompactCurrentRev(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.RandClient()).KV
+ preq := &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}
+ for i := 0; i < 3; i++ {
+ if _, err := kvc.Put(context.Background(), preq); err != nil {
+ t.Fatalf("couldn't put key (%v)", err)
+ }
+ }
+ // get key to add to proxy cache, if any
+ if _, err := kvc.Range(context.TODO(), &pb.RangeRequest{Key: []byte("foo")}); err != nil {
+ t.Fatal(err)
+ }
+ // compact on current revision
+ _, err := kvc.Compact(context.Background(), &pb.CompactionRequest{Revision: 4})
+ if err != nil {
+ t.Fatalf("couldn't compact kv space (%v)", err)
+ }
+ // key still exists when linearized?
+ _, err = kvc.Range(context.Background(), &pb.RangeRequest{Key: []byte("foo")})
+ if err != nil {
+ t.Fatalf("couldn't get key after compaction (%v)", err)
+ }
+ // key still exists when serialized?
+ _, err = kvc.Range(context.Background(), &pb.RangeRequest{Key: []byte("foo"), Serializable: true})
+ if err != nil {
+ t.Fatalf("couldn't get serialized key after compaction (%v)", err)
+ }
+}
+
+func TestV3TxnTooManyOps(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.RandClient()).KV
+
+ // unique keys
+ i := new(int)
+ keyf := func() []byte {
+ *i++
+ return []byte(fmt.Sprintf("key-%d", i))
+ }
+
+ addCompareOps := func(txn *pb.TxnRequest) {
+ txn.Compare = append(txn.Compare,
+ &pb.Compare{
+ Result: pb.Compare_GREATER,
+ Target: pb.Compare_CREATE,
+ Key: keyf(),
+ })
+ }
+ addSuccessOps := func(txn *pb.TxnRequest) {
+ txn.Success = append(txn.Success,
+ &pb.RequestOp{
+ Request: &pb.RequestOp_RequestPut{
+ RequestPut: &pb.PutRequest{
+ Key: keyf(),
+ Value: []byte("bar"),
+ },
+ },
+ })
+ }
+ addFailureOps := func(txn *pb.TxnRequest) {
+ txn.Failure = append(txn.Failure,
+ &pb.RequestOp{
+ Request: &pb.RequestOp_RequestPut{
+ RequestPut: &pb.PutRequest{
+ Key: keyf(),
+ Value: []byte("bar"),
+ },
+ },
+ })
+ }
+
+ tests := []func(txn *pb.TxnRequest){
+ addCompareOps,
+ addSuccessOps,
+ addFailureOps,
+ }
+
+ for i, tt := range tests {
+ txn := &pb.TxnRequest{}
+ for j := 0; j < v3rpc.MaxOpsPerTxn+1; j++ {
+ tt(txn)
+ }
+
+ _, err := kvc.Txn(context.Background(), txn)
+ if !eqErrGRPC(err, rpctypes.ErrGRPCTooManyOps) {
+ t.Errorf("#%d: err = %v, want %v", i, err, rpctypes.ErrGRPCTooManyOps)
+ }
+ }
+}
+
+func TestV3TxnDuplicateKeys(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ putreq := &pb.RequestOp{Request: &pb.RequestOp_RequestPut{RequestPut: &pb.PutRequest{Key: []byte("abc"), Value: []byte("def")}}}
+ delKeyReq := &pb.RequestOp{Request: &pb.RequestOp_RequestDeleteRange{
+ RequestDeleteRange: &pb.DeleteRangeRequest{
+ Key: []byte("abc"),
+ },
+ },
+ }
+ delInRangeReq := &pb.RequestOp{Request: &pb.RequestOp_RequestDeleteRange{
+ RequestDeleteRange: &pb.DeleteRangeRequest{
+ Key: []byte("a"), RangeEnd: []byte("b"),
+ },
+ },
+ }
+ delOutOfRangeReq := &pb.RequestOp{Request: &pb.RequestOp_RequestDeleteRange{
+ RequestDeleteRange: &pb.DeleteRangeRequest{
+ Key: []byte("abb"), RangeEnd: []byte("abc"),
+ },
+ },
+ }
+
+ kvc := toGRPC(clus.RandClient()).KV
+ tests := []struct {
+ txnSuccess []*pb.RequestOp
+
+ werr error
+ }{
+ {
+ txnSuccess: []*pb.RequestOp{putreq, putreq},
+
+ werr: rpctypes.ErrGRPCDuplicateKey,
+ },
+ {
+ txnSuccess: []*pb.RequestOp{putreq, delKeyReq},
+
+ werr: rpctypes.ErrGRPCDuplicateKey,
+ },
+ {
+ txnSuccess: []*pb.RequestOp{putreq, delInRangeReq},
+
+ werr: rpctypes.ErrGRPCDuplicateKey,
+ },
+ {
+ txnSuccess: []*pb.RequestOp{delKeyReq, delInRangeReq, delKeyReq, delInRangeReq},
+
+ werr: nil,
+ },
+ {
+ txnSuccess: []*pb.RequestOp{putreq, delOutOfRangeReq},
+
+ werr: nil,
+ },
+ }
+ for i, tt := range tests {
+ txn := &pb.TxnRequest{Success: tt.txnSuccess}
+ _, err := kvc.Txn(context.Background(), txn)
+ if !eqErrGRPC(err, tt.werr) {
+ t.Errorf("#%d: err = %v, want %v", i, err, tt.werr)
+ }
+ }
+}
+
+// Testv3TxnRevision tests that the transaction header revision is set as expected.
+func TestV3TxnRevision(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.RandClient()).KV
+ pr := &pb.PutRequest{Key: []byte("abc"), Value: []byte("def")}
+ presp, err := kvc.Put(context.TODO(), pr)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ txnget := &pb.RequestOp{Request: &pb.RequestOp_RequestRange{RequestRange: &pb.RangeRequest{Key: []byte("abc")}}}
+ txn := &pb.TxnRequest{Success: []*pb.RequestOp{txnget}}
+ tresp, err := kvc.Txn(context.TODO(), txn)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // did not update revision
+ if presp.Header.Revision != tresp.Header.Revision {
+ t.Fatalf("got rev %d, wanted rev %d", tresp.Header.Revision, presp.Header.Revision)
+ }
+
+ txndr := &pb.RequestOp{Request: &pb.RequestOp_RequestDeleteRange{RequestDeleteRange: &pb.DeleteRangeRequest{Key: []byte("def")}}}
+ txn = &pb.TxnRequest{Success: []*pb.RequestOp{txndr}}
+ tresp, err = kvc.Txn(context.TODO(), txn)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // did not update revision
+ if presp.Header.Revision != tresp.Header.Revision {
+ t.Fatalf("got rev %d, wanted rev %d", tresp.Header.Revision, presp.Header.Revision)
+ }
+
+ txnput := &pb.RequestOp{Request: &pb.RequestOp_RequestPut{RequestPut: &pb.PutRequest{Key: []byte("abc"), Value: []byte("123")}}}
+ txn = &pb.TxnRequest{Success: []*pb.RequestOp{txnput}}
+ tresp, err = kvc.Txn(context.TODO(), txn)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // updated revision
+ if tresp.Header.Revision != presp.Header.Revision+1 {
+ t.Fatalf("got rev %d, wanted rev %d", tresp.Header.Revision, presp.Header.Revision+1)
+ }
+}
+
+// Testv3TxnCmpHeaderRev tests that the txn header revision is set as expected
+// when compared to the Succeeded field in the txn response.
+func TestV3TxnCmpHeaderRev(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.RandClient()).KV
+
+ for i := 0; i < 10; i++ {
+ // Concurrently put a key with a txn comparing on it.
+ revc := make(chan int64, 1)
+ go func() {
+ defer close(revc)
+ pr := &pb.PutRequest{Key: []byte("k"), Value: []byte("v")}
+ presp, err := kvc.Put(context.TODO(), pr)
+ if err != nil {
+ t.Fatal(err)
+ }
+ revc <- presp.Header.Revision
+ }()
+
+ // The read-only txn uses the optimized readindex server path.
+ txnget := &pb.RequestOp{Request: &pb.RequestOp_RequestRange{
+ RequestRange: &pb.RangeRequest{Key: []byte("k")}}}
+ txn := &pb.TxnRequest{Success: []*pb.RequestOp{txnget}}
+ // i = 0 /\ Succeeded => put followed txn
+ cmp := &pb.Compare{
+ Result: pb.Compare_EQUAL,
+ Target: pb.Compare_VERSION,
+ Key: []byte("k"),
+ TargetUnion: &pb.Compare_Version{Version: int64(i)},
+ }
+ txn.Compare = append(txn.Compare, cmp)
+
+ tresp, err := kvc.Txn(context.TODO(), txn)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ prev := <-revc
+ // put followed txn; should eval to false
+ if prev > tresp.Header.Revision && !tresp.Succeeded {
+ t.Errorf("#%d: got else but put rev %d followed txn rev (%+v)", i, prev, tresp)
+ }
+ // txn follows put; should eval to true
+ if tresp.Header.Revision >= prev && tresp.Succeeded {
+ t.Errorf("#%d: got then but put rev %d preceded txn (%+v)", i, prev, tresp)
+ }
+ }
+}
+
+// TestV3PutIgnoreValue ensures that writes with ignore_value overwrites with previous key-value pair.
+func TestV3PutIgnoreValue(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.RandClient()).KV
+ key, val := []byte("foo"), []byte("bar")
+ putReq := pb.PutRequest{Key: key, Value: val}
+
+ // create lease
+ lc := toGRPC(clus.RandClient()).Lease
+ lresp, err := lc.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: 30})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if lresp.Error != "" {
+ t.Fatal(lresp.Error)
+ }
+
+ tests := []struct {
+ putFunc func() error
+ putErr error
+ wleaseID int64
+ }{
+ { // put failure for non-existent key
+ func() error {
+ preq := putReq
+ preq.IgnoreValue = true
+ _, err := kvc.Put(context.TODO(), &preq)
+ return err
+ },
+ rpctypes.ErrGRPCKeyNotFound,
+ 0,
+ },
+ { // txn failure for non-existent key
+ func() error {
+ preq := putReq
+ preq.Value = nil
+ preq.IgnoreValue = true
+ txn := &pb.TxnRequest{}
+ txn.Success = append(txn.Success, &pb.RequestOp{
+ Request: &pb.RequestOp_RequestPut{RequestPut: &preq}})
+ _, err := kvc.Txn(context.TODO(), txn)
+ return err
+ },
+ rpctypes.ErrGRPCKeyNotFound,
+ 0,
+ },
+ { // put success
+ func() error {
+ _, err := kvc.Put(context.TODO(), &putReq)
+ return err
+ },
+ nil,
+ 0,
+ },
+ { // txn success, attach lease
+ func() error {
+ preq := putReq
+ preq.Value = nil
+ preq.Lease = lresp.ID
+ preq.IgnoreValue = true
+ txn := &pb.TxnRequest{}
+ txn.Success = append(txn.Success, &pb.RequestOp{
+ Request: &pb.RequestOp_RequestPut{RequestPut: &preq}})
+ _, err := kvc.Txn(context.TODO(), txn)
+ return err
+ },
+ nil,
+ lresp.ID,
+ },
+ { // non-empty value with ignore_value should error
+ func() error {
+ preq := putReq
+ preq.IgnoreValue = true
+ _, err := kvc.Put(context.TODO(), &preq)
+ return err
+ },
+ rpctypes.ErrGRPCValueProvided,
+ 0,
+ },
+ { // overwrite with previous value, ensure no prev-kv is returned and lease is detached
+ func() error {
+ preq := putReq
+ preq.Value = nil
+ preq.IgnoreValue = true
+ presp, err := kvc.Put(context.TODO(), &preq)
+ if err != nil {
+ return err
+ }
+ if presp.PrevKv != nil && len(presp.PrevKv.Key) != 0 {
+ return fmt.Errorf("unexexpected previous key-value %v", presp.PrevKv)
+ }
+ return nil
+ },
+ nil,
+ 0,
+ },
+ { // revoke lease, ensure detached key doesn't get deleted
+ func() error {
+ _, err := lc.LeaseRevoke(context.TODO(), &pb.LeaseRevokeRequest{ID: lresp.ID})
+ return err
+ },
+ nil,
+ 0,
+ },
+ }
+
+ for i, tt := range tests {
+ if err := tt.putFunc(); !eqErrGRPC(err, tt.putErr) {
+ t.Fatalf("#%d: err expected %v, got %v", i, tt.putErr, err)
+ }
+ if tt.putErr != nil {
+ continue
+ }
+ rr, err := kvc.Range(context.TODO(), &pb.RangeRequest{Key: key})
+ if err != nil {
+ t.Fatalf("#%d: %v", i, err)
+ }
+ if len(rr.Kvs) != 1 {
+ t.Fatalf("#%d: len(rr.KVs) expected 1, got %d", i, len(rr.Kvs))
+ }
+ if !bytes.Equal(rr.Kvs[0].Value, val) {
+ t.Fatalf("#%d: value expected %q, got %q", i, val, rr.Kvs[0].Value)
+ }
+ if rr.Kvs[0].Lease != tt.wleaseID {
+ t.Fatalf("#%d: lease ID expected %d, got %d", i, tt.wleaseID, rr.Kvs[0].Lease)
+ }
+ }
+}
+
+// TestV3PutIgnoreLease ensures that writes with ignore_lease uses previous lease for the key overwrites.
+func TestV3PutIgnoreLease(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.RandClient()).KV
+
+ // create lease
+ lc := toGRPC(clus.RandClient()).Lease
+ lresp, err := lc.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: 30})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if lresp.Error != "" {
+ t.Fatal(lresp.Error)
+ }
+
+ key, val, val1 := []byte("zoo"), []byte("bar"), []byte("bar1")
+ putReq := pb.PutRequest{Key: key, Value: val}
+
+ tests := []struct {
+ putFunc func() error
+ putErr error
+ wleaseID int64
+ wvalue []byte
+ }{
+ { // put failure for non-existent key
+ func() error {
+ preq := putReq
+ preq.IgnoreLease = true
+ _, err := kvc.Put(context.TODO(), &preq)
+ return err
+ },
+ rpctypes.ErrGRPCKeyNotFound,
+ 0,
+ nil,
+ },
+ { // txn failure for non-existent key
+ func() error {
+ preq := putReq
+ preq.IgnoreLease = true
+ txn := &pb.TxnRequest{}
+ txn.Success = append(txn.Success, &pb.RequestOp{
+ Request: &pb.RequestOp_RequestPut{RequestPut: &preq}})
+ _, err := kvc.Txn(context.TODO(), txn)
+ return err
+ },
+ rpctypes.ErrGRPCKeyNotFound,
+ 0,
+ nil,
+ },
+ { // put success
+ func() error {
+ preq := putReq
+ preq.Lease = lresp.ID
+ _, err := kvc.Put(context.TODO(), &preq)
+ return err
+ },
+ nil,
+ lresp.ID,
+ val,
+ },
+ { // txn success, modify value using 'ignore_lease' and ensure lease is not detached
+ func() error {
+ preq := putReq
+ preq.Value = val1
+ preq.IgnoreLease = true
+ txn := &pb.TxnRequest{}
+ txn.Success = append(txn.Success, &pb.RequestOp{
+ Request: &pb.RequestOp_RequestPut{RequestPut: &preq}})
+ _, err := kvc.Txn(context.TODO(), txn)
+ return err
+ },
+ nil,
+ lresp.ID,
+ val1,
+ },
+ { // non-empty lease with ignore_lease should error
+ func() error {
+ preq := putReq
+ preq.Lease = lresp.ID
+ preq.IgnoreLease = true
+ _, err := kvc.Put(context.TODO(), &preq)
+ return err
+ },
+ rpctypes.ErrGRPCLeaseProvided,
+ 0,
+ nil,
+ },
+ { // overwrite with previous value, ensure no prev-kv is returned and lease is detached
+ func() error {
+ presp, err := kvc.Put(context.TODO(), &putReq)
+ if err != nil {
+ return err
+ }
+ if presp.PrevKv != nil && len(presp.PrevKv.Key) != 0 {
+ return fmt.Errorf("unexexpected previous key-value %v", presp.PrevKv)
+ }
+ return nil
+ },
+ nil,
+ 0,
+ val,
+ },
+ { // revoke lease, ensure detached key doesn't get deleted
+ func() error {
+ _, err := lc.LeaseRevoke(context.TODO(), &pb.LeaseRevokeRequest{ID: lresp.ID})
+ return err
+ },
+ nil,
+ 0,
+ val,
+ },
+ }
+
+ for i, tt := range tests {
+ if err := tt.putFunc(); !eqErrGRPC(err, tt.putErr) {
+ t.Fatalf("#%d: err expected %v, got %v", i, tt.putErr, err)
+ }
+ if tt.putErr != nil {
+ continue
+ }
+ rr, err := kvc.Range(context.TODO(), &pb.RangeRequest{Key: key})
+ if err != nil {
+ t.Fatalf("#%d: %v", i, err)
+ }
+ if len(rr.Kvs) != 1 {
+ t.Fatalf("#%d: len(rr.KVs) expected 1, got %d", i, len(rr.Kvs))
+ }
+ if !bytes.Equal(rr.Kvs[0].Value, tt.wvalue) {
+ t.Fatalf("#%d: value expected %q, got %q", i, val, rr.Kvs[0].Value)
+ }
+ if rr.Kvs[0].Lease != tt.wleaseID {
+ t.Fatalf("#%d: lease ID expected %d, got %d", i, tt.wleaseID, rr.Kvs[0].Lease)
+ }
+ }
+}
+
+// TestV3PutMissingLease ensures that a Put on a key with a bogus lease fails.
+func TestV3PutMissingLease(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.RandClient()).KV
+ key := []byte("foo")
+ preq := &pb.PutRequest{Key: key, Lease: 123456}
+ tests := []func(){
+ // put case
+ func() {
+ if presp, err := kvc.Put(context.TODO(), preq); err == nil {
+ t.Errorf("succeeded put key. req: %v. resp: %v", preq, presp)
+ }
+ },
+ // txn success case
+ func() {
+ txn := &pb.TxnRequest{}
+ txn.Success = append(txn.Success, &pb.RequestOp{
+ Request: &pb.RequestOp_RequestPut{
+ RequestPut: preq}})
+ if tresp, err := kvc.Txn(context.TODO(), txn); err == nil {
+ t.Errorf("succeeded txn success. req: %v. resp: %v", txn, tresp)
+ }
+ },
+ // txn failure case
+ func() {
+ txn := &pb.TxnRequest{}
+ txn.Failure = append(txn.Failure, &pb.RequestOp{
+ Request: &pb.RequestOp_RequestPut{
+ RequestPut: preq}})
+ cmp := &pb.Compare{
+ Result: pb.Compare_GREATER,
+ Target: pb.Compare_CREATE,
+ Key: []byte("bar"),
+ }
+ txn.Compare = append(txn.Compare, cmp)
+ if tresp, err := kvc.Txn(context.TODO(), txn); err == nil {
+ t.Errorf("succeeded txn failure. req: %v. resp: %v", txn, tresp)
+ }
+ },
+ // ignore bad lease in failure on success txn
+ func() {
+ txn := &pb.TxnRequest{}
+ rreq := &pb.RangeRequest{Key: []byte("bar")}
+ txn.Success = append(txn.Success, &pb.RequestOp{
+ Request: &pb.RequestOp_RequestRange{
+ RequestRange: rreq}})
+ txn.Failure = append(txn.Failure, &pb.RequestOp{
+ Request: &pb.RequestOp_RequestPut{
+ RequestPut: preq}})
+ if tresp, err := kvc.Txn(context.TODO(), txn); err != nil {
+ t.Errorf("failed good txn. req: %v. resp: %v", txn, tresp)
+ }
+ },
+ }
+
+ for i, f := range tests {
+ f()
+ // key shouldn't have been stored
+ rreq := &pb.RangeRequest{Key: key}
+ rresp, err := kvc.Range(context.TODO(), rreq)
+ if err != nil {
+ t.Errorf("#%d. could not rangereq (%v)", i, err)
+ } else if len(rresp.Kvs) != 0 {
+ t.Errorf("#%d. expected no keys, got %v", i, rresp)
+ }
+ }
+}
+
+// TestV3DeleteRange tests various edge cases in the DeleteRange API.
+func TestV3DeleteRange(t *testing.T) {
+ defer testutil.AfterTest(t)
+ tests := []struct {
+ keySet []string
+ begin string
+ end string
+ prevKV bool
+
+ wantSet [][]byte
+ deleted int64
+ }{
+ // delete middle
+ {
+ []string{"foo", "foo/abc", "fop"},
+ "foo/", "fop", false,
+ [][]byte{[]byte("foo"), []byte("fop")}, 1,
+ },
+ // no delete
+ {
+ []string{"foo", "foo/abc", "fop"},
+ "foo/", "foo/", false,
+ [][]byte{[]byte("foo"), []byte("foo/abc"), []byte("fop")}, 0,
+ },
+ // delete first
+ {
+ []string{"foo", "foo/abc", "fop"},
+ "fo", "fop", false,
+ [][]byte{[]byte("fop")}, 2,
+ },
+ // delete tail
+ {
+ []string{"foo", "foo/abc", "fop"},
+ "foo/", "fos", false,
+ [][]byte{[]byte("foo")}, 2,
+ },
+ // delete exact
+ {
+ []string{"foo", "foo/abc", "fop"},
+ "foo/abc", "", false,
+ [][]byte{[]byte("foo"), []byte("fop")}, 1,
+ },
+ // delete none, [x,x)
+ {
+ []string{"foo"},
+ "foo", "foo", false,
+ [][]byte{[]byte("foo")}, 0,
+ },
+ // delete middle with preserveKVs set
+ {
+ []string{"foo", "foo/abc", "fop"},
+ "foo/", "fop", true,
+ [][]byte{[]byte("foo"), []byte("fop")}, 1,
+ },
+ }
+
+ for i, tt := range tests {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ kvc := toGRPC(clus.RandClient()).KV
+
+ ks := tt.keySet
+ for j := range ks {
+ reqput := &pb.PutRequest{Key: []byte(ks[j]), Value: []byte{}}
+ _, err := kvc.Put(context.TODO(), reqput)
+ if err != nil {
+ t.Fatalf("couldn't put key (%v)", err)
+ }
+ }
+
+ dreq := &pb.DeleteRangeRequest{
+ Key: []byte(tt.begin),
+ RangeEnd: []byte(tt.end),
+ PrevKv: tt.prevKV,
+ }
+ dresp, err := kvc.DeleteRange(context.TODO(), dreq)
+ if err != nil {
+ t.Fatalf("couldn't delete range on test %d (%v)", i, err)
+ }
+ if tt.deleted != dresp.Deleted {
+ t.Errorf("expected %d on test %v, got %d", tt.deleted, i, dresp.Deleted)
+ }
+ if tt.prevKV {
+ if len(dresp.PrevKvs) != int(dresp.Deleted) {
+ t.Errorf("preserve %d keys, want %d", len(dresp.PrevKvs), dresp.Deleted)
+ }
+ }
+
+ rreq := &pb.RangeRequest{Key: []byte{0x0}, RangeEnd: []byte{0xff}}
+ rresp, err := kvc.Range(context.TODO(), rreq)
+ if err != nil {
+ t.Errorf("couldn't get range on test %v (%v)", i, err)
+ }
+ if dresp.Header.Revision != rresp.Header.Revision {
+ t.Errorf("expected revision %v, got %v",
+ dresp.Header.Revision, rresp.Header.Revision)
+ }
+
+ keys := [][]byte{}
+ for j := range rresp.Kvs {
+ keys = append(keys, rresp.Kvs[j].Key)
+ }
+ if !reflect.DeepEqual(tt.wantSet, keys) {
+ t.Errorf("expected %v on test %v, got %v", tt.wantSet, i, keys)
+ }
+ // can't defer because tcp ports will be in use
+ clus.Terminate(t)
+ }
+}
+
+// TestV3TxnInvalidRange tests that invalid ranges are rejected in txns.
+func TestV3TxnInvalidRange(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.RandClient()).KV
+ preq := &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}
+
+ for i := 0; i < 3; i++ {
+ _, err := kvc.Put(context.Background(), preq)
+ if err != nil {
+ t.Fatalf("couldn't put key (%v)", err)
+ }
+ }
+
+ _, err := kvc.Compact(context.Background(), &pb.CompactionRequest{Revision: 2})
+ if err != nil {
+ t.Fatalf("couldn't compact kv space (%v)", err)
+ }
+
+ // future rev
+ txn := &pb.TxnRequest{}
+ txn.Success = append(txn.Success, &pb.RequestOp{
+ Request: &pb.RequestOp_RequestPut{
+ RequestPut: preq}})
+
+ rreq := &pb.RangeRequest{Key: []byte("foo"), Revision: 100}
+ txn.Success = append(txn.Success, &pb.RequestOp{
+ Request: &pb.RequestOp_RequestRange{
+ RequestRange: rreq}})
+
+ if _, err := kvc.Txn(context.TODO(), txn); !eqErrGRPC(err, rpctypes.ErrGRPCFutureRev) {
+ t.Errorf("err = %v, want %v", err, rpctypes.ErrGRPCFutureRev)
+ }
+
+ // compacted rev
+ tv, _ := txn.Success[1].Request.(*pb.RequestOp_RequestRange)
+ tv.RequestRange.Revision = 1
+ if _, err := kvc.Txn(context.TODO(), txn); !eqErrGRPC(err, rpctypes.ErrGRPCCompacted) {
+ t.Errorf("err = %v, want %v", err, rpctypes.ErrGRPCCompacted)
+ }
+}
+
+func TestV3TooLargeRequest(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.RandClient()).KV
+
+ // 2MB request value
+ largeV := make([]byte, 2*1024*1024)
+ preq := &pb.PutRequest{Key: []byte("foo"), Value: largeV}
+
+ _, err := kvc.Put(context.Background(), preq)
+ if !eqErrGRPC(err, rpctypes.ErrGRPCRequestTooLarge) {
+ t.Errorf("err = %v, want %v", err, rpctypes.ErrGRPCRequestTooLarge)
+ }
+}
+
+// TestV3Hash tests hash.
+func TestV3Hash(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ cli := clus.RandClient()
+ kvc := toGRPC(cli).KV
+ m := toGRPC(cli).Maintenance
+
+ preq := &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}
+
+ for i := 0; i < 3; i++ {
+ _, err := kvc.Put(context.Background(), preq)
+ if err != nil {
+ t.Fatalf("couldn't put key (%v)", err)
+ }
+ }
+
+ resp, err := m.Hash(context.Background(), &pb.HashRequest{})
+ if err != nil || resp.Hash == 0 {
+ t.Fatalf("couldn't hash (%v, hash %d)", err, resp.Hash)
+ }
+}
+
+// TestV3HashRestart ensures that hash stays the same after restart.
+func TestV3HashRestart(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.RandClient()
+ resp, err := toGRPC(cli).Maintenance.Hash(context.Background(), &pb.HashRequest{})
+ if err != nil || resp.Hash == 0 {
+ t.Fatalf("couldn't hash (%v, hash %d)", err, resp.Hash)
+ }
+ hash1 := resp.Hash
+
+ clus.Members[0].Stop(t)
+ clus.Members[0].Restart(t)
+ clus.waitLeader(t, clus.Members)
+ kvc := toGRPC(clus.Client(0)).KV
+ waitForRestart(t, kvc)
+
+ cli = clus.RandClient()
+ resp, err = toGRPC(cli).Maintenance.Hash(context.Background(), &pb.HashRequest{})
+ if err != nil || resp.Hash == 0 {
+ t.Fatalf("couldn't hash (%v, hash %d)", err, resp.Hash)
+ }
+ hash2 := resp.Hash
+
+ if hash1 != hash2 {
+ t.Fatalf("hash expected %d, got %d", hash1, hash2)
+ }
+}
+
+// TestV3StorageQuotaAPI tests the V3 server respects quotas at the API layer
+func TestV3StorageQuotaAPI(t *testing.T) {
+ defer testutil.AfterTest(t)
+ quotasize := int64(16 * os.Getpagesize())
+
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+
+ // Set a quota on one node
+ clus.Members[0].QuotaBackendBytes = quotasize
+ clus.Members[0].Stop(t)
+ clus.Members[0].Restart(t)
+
+ defer clus.Terminate(t)
+ kvc := toGRPC(clus.Client(0)).KV
+ waitForRestart(t, kvc)
+
+ key := []byte("abc")
+
+ // test small put that fits in quota
+ smallbuf := make([]byte, 512)
+ if _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: key, Value: smallbuf}); err != nil {
+ t.Fatal(err)
+ }
+
+ // test big put
+ bigbuf := make([]byte, quotasize)
+ _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: key, Value: bigbuf})
+ if !eqErrGRPC(err, rpctypes.ErrGRPCNoSpace) {
+ t.Fatalf("big put got %v, expected %v", err, rpctypes.ErrGRPCNoSpace)
+ }
+
+ // test big txn
+ puttxn := &pb.RequestOp{
+ Request: &pb.RequestOp_RequestPut{
+ RequestPut: &pb.PutRequest{
+ Key: key,
+ Value: bigbuf,
+ },
+ },
+ }
+ txnreq := &pb.TxnRequest{}
+ txnreq.Success = append(txnreq.Success, puttxn)
+ _, txnerr := kvc.Txn(context.TODO(), txnreq)
+ if !eqErrGRPC(txnerr, rpctypes.ErrGRPCNoSpace) {
+ t.Fatalf("big txn got %v, expected %v", err, rpctypes.ErrGRPCNoSpace)
+ }
+}
+
+// TestV3StorageQuotaApply tests the V3 server respects quotas during apply
+func TestV3StorageQuotaApply(t *testing.T) {
+ testutil.AfterTest(t)
+ quotasize := int64(16 * os.Getpagesize())
+
+ clus := NewClusterV3(t, &ClusterConfig{Size: 2})
+ defer clus.Terminate(t)
+ kvc0 := toGRPC(clus.Client(0)).KV
+ kvc1 := toGRPC(clus.Client(1)).KV
+
+ // Set a quota on one node
+ clus.Members[0].QuotaBackendBytes = quotasize
+ clus.Members[0].Stop(t)
+ clus.Members[0].Restart(t)
+ clus.waitLeader(t, clus.Members)
+ waitForRestart(t, kvc0)
+
+ key := []byte("abc")
+
+ // test small put still works
+ smallbuf := make([]byte, 1024)
+ _, serr := kvc0.Put(context.TODO(), &pb.PutRequest{Key: key, Value: smallbuf})
+ if serr != nil {
+ t.Fatal(serr)
+ }
+
+ // test big put
+ bigbuf := make([]byte, quotasize)
+ _, err := kvc1.Put(context.TODO(), &pb.PutRequest{Key: key, Value: bigbuf})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // quorum get should work regardless of whether alarm is raised
+ _, err = kvc0.Range(context.TODO(), &pb.RangeRequest{Key: []byte("foo")})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // wait until alarm is raised for sure-- poll the alarms
+ stopc := time.After(5 * time.Second)
+ for {
+ req := &pb.AlarmRequest{Action: pb.AlarmRequest_GET}
+ resp, aerr := clus.Members[0].s.Alarm(context.TODO(), req)
+ if aerr != nil {
+ t.Fatal(aerr)
+ }
+ if len(resp.Alarms) != 0 {
+ break
+ }
+ select {
+ case <-stopc:
+ t.Fatalf("timed out waiting for alarm")
+ case <-time.After(10 * time.Millisecond):
+ }
+ }
+
+ // small quota machine should reject put
+ if _, err := kvc0.Put(context.TODO(), &pb.PutRequest{Key: key, Value: smallbuf}); err == nil {
+ t.Fatalf("past-quota instance should reject put")
+ }
+
+ // large quota machine should reject put
+ if _, err := kvc1.Put(context.TODO(), &pb.PutRequest{Key: key, Value: smallbuf}); err == nil {
+ t.Fatalf("past-quota instance should reject put")
+ }
+
+ // reset large quota node to ensure alarm persisted
+ clus.Members[1].Stop(t)
+ clus.Members[1].Restart(t)
+ clus.waitLeader(t, clus.Members)
+
+ if _, err := kvc1.Put(context.TODO(), &pb.PutRequest{Key: key, Value: smallbuf}); err == nil {
+ t.Fatalf("alarmed instance should reject put after reset")
+ }
+}
+
+// TestV3AlarmDeactivate ensures that space alarms can be deactivated so puts go through.
+func TestV3AlarmDeactivate(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+ kvc := toGRPC(clus.RandClient()).KV
+ mt := toGRPC(clus.RandClient()).Maintenance
+
+ alarmReq := &pb.AlarmRequest{
+ MemberID: 123,
+ Action: pb.AlarmRequest_ACTIVATE,
+ Alarm: pb.AlarmType_NOSPACE,
+ }
+ if _, err := mt.Alarm(context.TODO(), alarmReq); err != nil {
+ t.Fatal(err)
+ }
+
+ key := []byte("abc")
+ smallbuf := make([]byte, 512)
+ _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: key, Value: smallbuf})
+ if err == nil && !eqErrGRPC(err, rpctypes.ErrGRPCNoSpace) {
+ t.Fatalf("put got %v, expected %v", err, rpctypes.ErrGRPCNoSpace)
+ }
+
+ alarmReq.Action = pb.AlarmRequest_DEACTIVATE
+ if _, err = mt.Alarm(context.TODO(), alarmReq); err != nil {
+ t.Fatal(err)
+ }
+
+ if _, err = kvc.Put(context.TODO(), &pb.PutRequest{Key: key, Value: smallbuf}); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestV3RangeRequest(t *testing.T) {
+ defer testutil.AfterTest(t)
+ tests := []struct {
+ putKeys []string
+ reqs []pb.RangeRequest
+
+ wresps [][]string
+ wmores []bool
+ }{
+ // single key
+ {
+ []string{"foo", "bar"},
+ []pb.RangeRequest{
+ // exists
+ {Key: []byte("foo")},
+ // doesn't exist
+ {Key: []byte("baz")},
+ },
+
+ [][]string{
+ {"foo"},
+ {},
+ },
+ []bool{false, false},
+ },
+ // multi-key
+ {
+ []string{"a", "b", "c", "d", "e"},
+ []pb.RangeRequest{
+ // all in range
+ {Key: []byte("a"), RangeEnd: []byte("z")},
+ // [b, d)
+ {Key: []byte("b"), RangeEnd: []byte("d")},
+ // out of range
+ {Key: []byte("f"), RangeEnd: []byte("z")},
+ // [c,c) = empty
+ {Key: []byte("c"), RangeEnd: []byte("c")},
+ // [d, b) = empty
+ {Key: []byte("d"), RangeEnd: []byte("b")},
+ // ["\0", "\0") => all in range
+ {Key: []byte{0}, RangeEnd: []byte{0}},
+ },
+
+ [][]string{
+ {"a", "b", "c", "d", "e"},
+ {"b", "c"},
+ {},
+ {},
+ {},
+ {"a", "b", "c", "d", "e"},
+ },
+ []bool{false, false, false, false, false, false},
+ },
+ // revision
+ {
+ []string{"a", "b", "c", "d", "e"},
+ []pb.RangeRequest{
+ {Key: []byte("a"), RangeEnd: []byte("z"), Revision: 0},
+ {Key: []byte("a"), RangeEnd: []byte("z"), Revision: 1},
+ {Key: []byte("a"), RangeEnd: []byte("z"), Revision: 2},
+ {Key: []byte("a"), RangeEnd: []byte("z"), Revision: 3},
+ },
+
+ [][]string{
+ {"a", "b", "c", "d", "e"},
+ {},
+ {"a"},
+ {"a", "b"},
+ },
+ []bool{false, false, false, false},
+ },
+ // limit
+ {
+ []string{"foo", "bar"},
+ []pb.RangeRequest{
+ // more
+ {Key: []byte("a"), RangeEnd: []byte("z"), Limit: 1},
+ // no more
+ {Key: []byte("a"), RangeEnd: []byte("z"), Limit: 2},
+ },
+
+ [][]string{
+ {"bar"},
+ {"bar", "foo"},
+ },
+ []bool{true, false},
+ },
+ // sort
+ {
+ []string{"b", "a", "c", "d", "c"},
+ []pb.RangeRequest{
+ {
+ Key: []byte("a"), RangeEnd: []byte("z"),
+ Limit: 1,
+ SortOrder: pb.RangeRequest_ASCEND,
+ SortTarget: pb.RangeRequest_KEY,
+ },
+ {
+ Key: []byte("a"), RangeEnd: []byte("z"),
+ Limit: 1,
+ SortOrder: pb.RangeRequest_DESCEND,
+ SortTarget: pb.RangeRequest_KEY,
+ },
+ {
+ Key: []byte("a"), RangeEnd: []byte("z"),
+ Limit: 1,
+ SortOrder: pb.RangeRequest_ASCEND,
+ SortTarget: pb.RangeRequest_CREATE,
+ },
+ {
+ Key: []byte("a"), RangeEnd: []byte("z"),
+ Limit: 1,
+ SortOrder: pb.RangeRequest_DESCEND,
+ SortTarget: pb.RangeRequest_MOD,
+ },
+ {
+ Key: []byte("z"), RangeEnd: []byte("z"),
+ Limit: 1,
+ SortOrder: pb.RangeRequest_DESCEND,
+ SortTarget: pb.RangeRequest_CREATE,
+ },
+ { // sort ASCEND by default
+ Key: []byte("a"), RangeEnd: []byte("z"),
+ Limit: 10,
+ SortOrder: pb.RangeRequest_NONE,
+ SortTarget: pb.RangeRequest_CREATE,
+ },
+ },
+
+ [][]string{
+ {"a"},
+ {"d"},
+ {"b"},
+ {"c"},
+ {},
+ {"b", "a", "c", "d"},
+ },
+ []bool{true, true, true, true, false, false},
+ },
+ // min/max mod rev
+ {
+ []string{"rev2", "rev3", "rev4", "rev5", "rev6"},
+ []pb.RangeRequest{
+ {
+ Key: []byte{0}, RangeEnd: []byte{0},
+ MinModRevision: 3,
+ },
+ {
+ Key: []byte{0}, RangeEnd: []byte{0},
+ MaxModRevision: 3,
+ },
+ {
+ Key: []byte{0}, RangeEnd: []byte{0},
+ MinModRevision: 3,
+ MaxModRevision: 5,
+ },
+ {
+ Key: []byte{0}, RangeEnd: []byte{0},
+ MaxModRevision: 10,
+ },
+ },
+
+ [][]string{
+ {"rev3", "rev4", "rev5", "rev6"},
+ {"rev2", "rev3"},
+ {"rev3", "rev4", "rev5"},
+ {"rev2", "rev3", "rev4", "rev5", "rev6"},
+ },
+ []bool{false, false, false, false},
+ },
+ // min/max create rev
+ {
+ []string{"rev2", "rev3", "rev2", "rev2", "rev6", "rev3"},
+ []pb.RangeRequest{
+ {
+ Key: []byte{0}, RangeEnd: []byte{0},
+ MinCreateRevision: 3,
+ },
+ {
+ Key: []byte{0}, RangeEnd: []byte{0},
+ MaxCreateRevision: 3,
+ },
+ {
+ Key: []byte{0}, RangeEnd: []byte{0},
+ MinCreateRevision: 3,
+ MaxCreateRevision: 5,
+ },
+ {
+ Key: []byte{0}, RangeEnd: []byte{0},
+ MaxCreateRevision: 10,
+ },
+ },
+
+ [][]string{
+ {"rev3", "rev6"},
+ {"rev2", "rev3"},
+ {"rev3"},
+ {"rev2", "rev3", "rev6"},
+ },
+ []bool{false, false, false, false},
+ },
+ }
+
+ for i, tt := range tests {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ for _, k := range tt.putKeys {
+ kvc := toGRPC(clus.RandClient()).KV
+ req := &pb.PutRequest{Key: []byte(k), Value: []byte("bar")}
+ if _, err := kvc.Put(context.TODO(), req); err != nil {
+ t.Fatalf("#%d: couldn't put key (%v)", i, err)
+ }
+ }
+
+ for j, req := range tt.reqs {
+ kvc := toGRPC(clus.RandClient()).KV
+ resp, err := kvc.Range(context.TODO(), &req)
+ if err != nil {
+ t.Errorf("#%d.%d: Range error: %v", i, j, err)
+ continue
+ }
+ if len(resp.Kvs) != len(tt.wresps[j]) {
+ t.Errorf("#%d.%d: bad len(resp.Kvs). got = %d, want = %d, ", i, j, len(resp.Kvs), len(tt.wresps[j]))
+ continue
+ }
+ for k, wKey := range tt.wresps[j] {
+ respKey := string(resp.Kvs[k].Key)
+ if respKey != wKey {
+ t.Errorf("#%d.%d: key[%d]. got = %v, want = %v, ", i, j, k, respKey, wKey)
+ }
+ }
+ if resp.More != tt.wmores[j] {
+ t.Errorf("#%d.%d: bad more. got = %v, want = %v, ", i, j, resp.More, tt.wmores[j])
+ }
+ wrev := int64(len(tt.putKeys) + 1)
+ if resp.Header.Revision != wrev {
+ t.Errorf("#%d.%d: bad header revision. got = %d. want = %d", i, j, resp.Header.Revision, wrev)
+ }
+ }
+ clus.Terminate(t)
+ }
+}
+
+func newClusterV3NoClients(t *testing.T, cfg *ClusterConfig) *ClusterV3 {
+ cfg.UseGRPC = true
+ clus := &ClusterV3{cluster: NewClusterByConfig(t, cfg)}
+ clus.Launch(t)
+ return clus
+}
+
+// TestTLSGRPCRejectInsecureClient checks that connection is rejected if server is TLS but not client.
+func TestTLSGRPCRejectInsecureClient(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ cfg := ClusterConfig{Size: 3, ClientTLS: &testTLSInfo}
+ clus := newClusterV3NoClients(t, &cfg)
+ defer clus.Terminate(t)
+
+ // nil out TLS field so client will use an insecure connection
+ clus.Members[0].ClientTLSInfo = nil
+ client, err := NewClientV3(clus.Members[0])
+ if err != nil && err != grpc.ErrClientConnTimeout {
+ t.Fatalf("unexpected error (%v)", err)
+ } else if client == nil {
+ // Ideally, no client would be returned. However, grpc will
+ // return a connection without trying to handshake first so
+ // the connection appears OK.
+ return
+ }
+ defer client.Close()
+
+ donec := make(chan error, 1)
+ go func() {
+ ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
+ reqput := &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}
+ _, perr := toGRPC(client).KV.Put(ctx, reqput)
+ cancel()
+ donec <- perr
+ }()
+
+ if perr := <-donec; perr == nil {
+ t.Fatalf("expected client error on put")
+ }
+}
+
+// TestTLSGRPCRejectSecureClient checks that connection is rejected if client is TLS but not server.
+func TestTLSGRPCRejectSecureClient(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ cfg := ClusterConfig{Size: 3}
+ clus := newClusterV3NoClients(t, &cfg)
+ defer clus.Terminate(t)
+
+ clus.Members[0].ClientTLSInfo = &testTLSInfo
+ client, err := NewClientV3(clus.Members[0])
+ if client != nil || err == nil {
+ t.Fatalf("expected no client")
+ } else if err != grpc.ErrClientConnTimeout {
+ t.Fatalf("unexpected error (%v)", err)
+ }
+}
+
+// TestTLSGRPCAcceptSecureAll checks that connection is accepted if both client and server are TLS
+func TestTLSGRPCAcceptSecureAll(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ cfg := ClusterConfig{Size: 3, ClientTLS: &testTLSInfo}
+ clus := newClusterV3NoClients(t, &cfg)
+ defer clus.Terminate(t)
+
+ client, err := NewClientV3(clus.Members[0])
+ if err != nil {
+ t.Fatalf("expected tls client (%v)", err)
+ }
+ defer client.Close()
+
+ reqput := &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}
+ if _, err := toGRPC(client).KV.Put(context.TODO(), reqput); err != nil {
+ t.Fatalf("unexpected error on put over tls (%v)", err)
+ }
+}
+
+// TestTLSReloadAtomicReplace ensures server reloads expired/valid certs
+// when all certs are atomically replaced by directory renaming.
+// And expects server to reject client requests, and vice versa.
+func TestTLSReloadAtomicReplace(t *testing.T) {
+ tmpDir, err := ioutil.TempDir(os.TempDir(), "fixtures-tmp")
+ if err != nil {
+ t.Fatal(err)
+ }
+ os.RemoveAll(tmpDir)
+ defer os.RemoveAll(tmpDir)
+
+ certsDir, err := ioutil.TempDir(os.TempDir(), "fixtures-to-load")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(certsDir)
+
+ certsDirExp, err := ioutil.TempDir(os.TempDir(), "fixtures-expired")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(certsDirExp)
+
+ cloneFunc := func() transport.TLSInfo {
+ tlsInfo, terr := copyTLSFiles(testTLSInfo, certsDir)
+ if terr != nil {
+ t.Fatal(terr)
+ }
+ if _, err = copyTLSFiles(testTLSInfoExpired, certsDirExp); err != nil {
+ t.Fatal(err)
+ }
+ return tlsInfo
+ }
+ replaceFunc := func() {
+ if err = os.Rename(certsDir, tmpDir); err != nil {
+ t.Fatal(err)
+ }
+ if err = os.Rename(certsDirExp, certsDir); err != nil {
+ t.Fatal(err)
+ }
+ // after rename,
+ // 'certsDir' contains expired certs
+ // 'tmpDir' contains valid certs
+ // 'certsDirExp' does not exist
+ }
+ revertFunc := func() {
+ if err = os.Rename(tmpDir, certsDirExp); err != nil {
+ t.Fatal(err)
+ }
+ if err = os.Rename(certsDir, tmpDir); err != nil {
+ t.Fatal(err)
+ }
+ if err = os.Rename(certsDirExp, certsDir); err != nil {
+ t.Fatal(err)
+ }
+ }
+ testTLSReload(t, cloneFunc, replaceFunc, revertFunc)
+}
+
+// TestTLSReloadCopy ensures server reloads expired/valid certs
+// when new certs are copied over, one by one. And expects server
+// to reject client requests, and vice versa.
+func TestTLSReloadCopy(t *testing.T) {
+ certsDir, err := ioutil.TempDir(os.TempDir(), "fixtures-to-load")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(certsDir)
+
+ cloneFunc := func() transport.TLSInfo {
+ tlsInfo, terr := copyTLSFiles(testTLSInfo, certsDir)
+ if terr != nil {
+ t.Fatal(terr)
+ }
+ return tlsInfo
+ }
+ replaceFunc := func() {
+ if _, err = copyTLSFiles(testTLSInfoExpired, certsDir); err != nil {
+ t.Fatal(err)
+ }
+ }
+ revertFunc := func() {
+ if _, err = copyTLSFiles(testTLSInfo, certsDir); err != nil {
+ t.Fatal(err)
+ }
+ }
+ testTLSReload(t, cloneFunc, replaceFunc, revertFunc)
+}
+
+func testTLSReload(t *testing.T, cloneFunc func() transport.TLSInfo, replaceFunc func(), revertFunc func()) {
+ defer testutil.AfterTest(t)
+
+ // 1. separate copies for TLS assets modification
+ tlsInfo := cloneFunc()
+
+ // 2. start cluster with valid certs
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1, PeerTLS: &tlsInfo, ClientTLS: &tlsInfo})
+ defer clus.Terminate(t)
+
+ // 3. concurrent client dialing while certs become expired
+ errc := make(chan error, 1)
+ go func() {
+ for {
+ cc, err := tlsInfo.ClientConfig()
+ if err != nil {
+ // errors in 'go/src/crypto/tls/tls.go'
+ // tls: private key does not match public key
+ // tls: failed to find any PEM data in key input
+ // tls: failed to find any PEM data in certificate input
+ // Or 'does not exist', 'not found', etc
+ t.Log(err)
+ continue
+ }
+ cli, cerr := clientv3.New(clientv3.Config{
+ Endpoints: []string{clus.Members[0].GRPCAddr()},
+ DialTimeout: time.Second,
+ TLS: cc,
+ })
+ if cerr != nil {
+ errc <- cerr
+ return
+ }
+ cli.Close()
+ }
+ }()
+
+ // 4. replace certs with expired ones
+ replaceFunc()
+
+ // 5. expect dial time-out when loading expired certs
+ select {
+ case gerr := <-errc:
+ if gerr != grpc.ErrClientConnTimeout {
+ t.Fatalf("expected %v, got %v", grpc.ErrClientConnTimeout, gerr)
+ }
+ case <-time.After(5 * time.Second):
+ t.Fatal("failed to receive dial timeout error")
+ }
+
+ // 6. replace expired certs back with valid ones
+ revertFunc()
+
+ // 7. new requests should trigger listener to reload valid certs
+ tls, terr := tlsInfo.ClientConfig()
+ if terr != nil {
+ t.Fatal(terr)
+ }
+ cl, cerr := clientv3.New(clientv3.Config{
+ Endpoints: []string{clus.Members[0].GRPCAddr()},
+ DialTimeout: time.Second,
+ TLS: tls,
+ })
+ if cerr != nil {
+ t.Fatalf("expected no error, got %v", cerr)
+ }
+ cl.Close()
+}
+
+func TestGRPCRequireLeader(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ cfg := ClusterConfig{Size: 3}
+ clus := newClusterV3NoClients(t, &cfg)
+ defer clus.Terminate(t)
+
+ clus.Members[1].Stop(t)
+ clus.Members[2].Stop(t)
+
+ client, err := NewClientV3(clus.Members[0])
+ if err != nil {
+ t.Fatalf("cannot create client: %v", err)
+ }
+ defer client.Close()
+
+ // wait for election timeout, then member[0] will not have a leader.
+ time.Sleep(time.Duration(3*electionTicks) * tickDuration)
+
+ md := metadata.Pairs(rpctypes.MetadataRequireLeaderKey, rpctypes.MetadataHasLeader)
+ ctx := metadata.NewContext(context.Background(), md)
+ reqput := &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}
+ if _, err := toGRPC(client).KV.Put(ctx, reqput); grpc.ErrorDesc(err) != rpctypes.ErrNoLeader.Error() {
+ t.Errorf("err = %v, want %v", err, rpctypes.ErrNoLeader)
+ }
+}
+
+func TestGRPCStreamRequireLeader(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ cfg := ClusterConfig{Size: 3}
+ clus := newClusterV3NoClients(t, &cfg)
+ defer clus.Terminate(t)
+
+ client, err := NewClientV3(clus.Members[0])
+ if err != nil {
+ t.Fatalf("failed to create client (%v)", err)
+ }
+ defer client.Close()
+
+ wAPI := toGRPC(client).Watch
+ md := metadata.Pairs(rpctypes.MetadataRequireLeaderKey, rpctypes.MetadataHasLeader)
+ ctx := metadata.NewContext(context.Background(), md)
+ wStream, err := wAPI.Watch(ctx)
+ if err != nil {
+ t.Fatalf("wAPI.Watch error: %v", err)
+ }
+
+ clus.Members[1].Stop(t)
+ clus.Members[2].Stop(t)
+
+ // existing stream should be rejected
+ _, err = wStream.Recv()
+ if grpc.ErrorDesc(err) != rpctypes.ErrNoLeader.Error() {
+ t.Errorf("err = %v, want %v", err, rpctypes.ErrNoLeader)
+ }
+
+ // new stream should also be rejected
+ wStream, err = wAPI.Watch(ctx)
+ if err != nil {
+ t.Fatalf("wAPI.Watch error: %v", err)
+ }
+ _, err = wStream.Recv()
+ if grpc.ErrorDesc(err) != rpctypes.ErrNoLeader.Error() {
+ t.Errorf("err = %v, want %v", err, rpctypes.ErrNoLeader)
+ }
+
+ clus.Members[1].Restart(t)
+ clus.Members[2].Restart(t)
+
+ clus.waitLeader(t, clus.Members)
+ time.Sleep(time.Duration(2*electionTicks) * tickDuration)
+
+ // new stream should also be OK now after we restarted the other members
+ wStream, err = wAPI.Watch(ctx)
+ if err != nil {
+ t.Fatalf("wAPI.Watch error: %v", err)
+ }
+ wreq := &pb.WatchRequest{
+ RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{Key: []byte("foo")},
+ },
+ }
+ err = wStream.Send(wreq)
+ if err != nil {
+ t.Errorf("err = %v, want nil", err)
+ }
+}
+
+func eqErrGRPC(err1 error, err2 error) bool {
+ return !(err1 == nil && err2 != nil) || err1.Error() == err2.Error()
+}
+
+// waitForRestart tries a range request until the client's server responds.
+// This is mainly a stop-gap function until grpcproxy's KVClient adapter
+// (and by extension, clientv3) supports grpc.CallOption pass-through so
+// FailFast=false works with Put.
+func waitForRestart(t *testing.T, kvc pb.KVClient) {
+ req := &pb.RangeRequest{Key: []byte("_"), Serializable: true}
+ if _, err := kvc.Range(context.TODO(), req, grpc.FailFast(false)); err != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/integration/v3_lease_test.go b/vendor/github.com/coreos/etcd/integration/v3_lease_test.go
new file mode 100644
index 00000000..dbb8e6b7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/v3_lease_test.go
@@ -0,0 +1,829 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "fmt"
+ "testing"
+ "time"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/metadata"
+
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+// TestV3LeasePrmote ensures the newly elected leader can promote itself
+// to the primary lessor, refresh the leases and start to manage leases.
+// TODO: use customized clock to make this test go faster?
+func TestV3LeasePrmote(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ // create lease
+ lresp, err := toGRPC(clus.RandClient()).Lease.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: 5})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if lresp.Error != "" {
+ t.Fatal(lresp.Error)
+ }
+
+ // wait until the lease is going to expire.
+ time.Sleep(time.Duration(lresp.TTL-1) * time.Second)
+
+ // kill the current leader, all leases should be refreshed.
+ toStop := clus.waitLeader(t, clus.Members)
+ clus.Members[toStop].Stop(t)
+
+ var toWait []*member
+ for i, m := range clus.Members {
+ if i != toStop {
+ toWait = append(toWait, m)
+ }
+ }
+ clus.waitLeader(t, toWait)
+ clus.Members[toStop].Restart(t)
+ clus.waitLeader(t, clus.Members)
+
+ // ensure lease is refreshed by waiting for a "long" time.
+ // it was going to expire anyway.
+ time.Sleep(3 * time.Second)
+
+ if !leaseExist(t, clus, lresp.ID) {
+ t.Error("unexpected lease not exists")
+ }
+
+ // let lease expires. total lease = 5 seconds and we already
+ // waits for 3 seconds, so 3 seconds more is enough.
+ time.Sleep(3 * time.Second)
+ if leaseExist(t, clus, lresp.ID) {
+ t.Error("unexpected lease exists")
+ }
+}
+
+// TestV3LeaseRevoke ensures a key is deleted once its lease is revoked.
+func TestV3LeaseRevoke(t *testing.T) {
+ defer testutil.AfterTest(t)
+ testLeaseRemoveLeasedKey(t, func(clus *ClusterV3, leaseID int64) error {
+ lc := toGRPC(clus.RandClient()).Lease
+ _, err := lc.LeaseRevoke(context.TODO(), &pb.LeaseRevokeRequest{ID: leaseID})
+ return err
+ })
+}
+
+// TestV3LeaseGrantById ensures leases may be created by a given id.
+func TestV3LeaseGrantByID(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ // create fixed lease
+ lresp, err := toGRPC(clus.RandClient()).Lease.LeaseGrant(
+ context.TODO(),
+ &pb.LeaseGrantRequest{ID: 1, TTL: 1})
+ if err != nil {
+ t.Errorf("could not create lease 1 (%v)", err)
+ }
+ if lresp.ID != 1 {
+ t.Errorf("got id %v, wanted id %v", lresp.ID, 1)
+ }
+
+ // create duplicate fixed lease
+ _, err = toGRPC(clus.RandClient()).Lease.LeaseGrant(
+ context.TODO(),
+ &pb.LeaseGrantRequest{ID: 1, TTL: 1})
+ if !eqErrGRPC(err, rpctypes.ErrGRPCLeaseExist) {
+ t.Error(err)
+ }
+
+ // create fresh fixed lease
+ lresp, err = toGRPC(clus.RandClient()).Lease.LeaseGrant(
+ context.TODO(),
+ &pb.LeaseGrantRequest{ID: 2, TTL: 1})
+ if err != nil {
+ t.Errorf("could not create lease 2 (%v)", err)
+ }
+ if lresp.ID != 2 {
+ t.Errorf("got id %v, wanted id %v", lresp.ID, 2)
+ }
+}
+
+// TestV3LeaseExpire ensures a key is deleted once a key expires.
+func TestV3LeaseExpire(t *testing.T) {
+ defer testutil.AfterTest(t)
+ testLeaseRemoveLeasedKey(t, func(clus *ClusterV3, leaseID int64) error {
+ // let lease lapse; wait for deleted key
+
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ wStream, err := toGRPC(clus.RandClient()).Watch.Watch(ctx)
+ if err != nil {
+ return err
+ }
+
+ wreq := &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("foo"), StartRevision: 1}}}
+ if err := wStream.Send(wreq); err != nil {
+ return err
+ }
+ if _, err := wStream.Recv(); err != nil {
+ // the 'created' message
+ return err
+ }
+ if _, err := wStream.Recv(); err != nil {
+ // the 'put' message
+ return err
+ }
+
+ errc := make(chan error, 1)
+ go func() {
+ resp, err := wStream.Recv()
+ switch {
+ case err != nil:
+ errc <- err
+ case len(resp.Events) != 1:
+ fallthrough
+ case resp.Events[0].Type != mvccpb.DELETE:
+ errc <- fmt.Errorf("expected key delete, got %v", resp)
+ default:
+ errc <- nil
+ }
+ }()
+
+ select {
+ case <-time.After(15 * time.Second):
+ return fmt.Errorf("lease expiration too slow")
+ case err := <-errc:
+ return err
+ }
+ })
+}
+
+// TestV3LeaseKeepAlive ensures keepalive keeps the lease alive.
+func TestV3LeaseKeepAlive(t *testing.T) {
+ defer testutil.AfterTest(t)
+ testLeaseRemoveLeasedKey(t, func(clus *ClusterV3, leaseID int64) error {
+ lc := toGRPC(clus.RandClient()).Lease
+ lreq := &pb.LeaseKeepAliveRequest{ID: leaseID}
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ lac, err := lc.LeaseKeepAlive(ctx)
+ if err != nil {
+ return err
+ }
+ defer lac.CloseSend()
+
+ // renew long enough so lease would've expired otherwise
+ for i := 0; i < 3; i++ {
+ if err = lac.Send(lreq); err != nil {
+ return err
+ }
+ lresp, rxerr := lac.Recv()
+ if rxerr != nil {
+ return rxerr
+ }
+ if lresp.ID != leaseID {
+ return fmt.Errorf("expected lease ID %v, got %v", leaseID, lresp.ID)
+ }
+ time.Sleep(time.Duration(lresp.TTL/2) * time.Second)
+ }
+ _, err = lc.LeaseRevoke(context.TODO(), &pb.LeaseRevokeRequest{ID: leaseID})
+ return err
+ })
+}
+
+// TestV3LeaseExists creates a lease on a random client and confirms it exists in the cluster.
+func TestV3LeaseExists(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ // create lease
+ ctx0, cancel0 := context.WithCancel(context.Background())
+ defer cancel0()
+ lresp, err := toGRPC(clus.RandClient()).Lease.LeaseGrant(
+ ctx0,
+ &pb.LeaseGrantRequest{TTL: 30})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if lresp.Error != "" {
+ t.Fatal(lresp.Error)
+ }
+
+ if !leaseExist(t, clus, lresp.ID) {
+ t.Error("unexpected lease not exists")
+ }
+}
+
+// TestV3LeaseRenewStress keeps creating lease and renewing it immediately to ensure the renewal goes through.
+// it was oberserved that the immediate lease renewal after granting a lease from follower resulted lease not found.
+// related issue https://github.com/coreos/etcd/issues/6978
+func TestV3LeaseRenewStress(t *testing.T) {
+ testLeaseStress(t, stressLeaseRenew)
+}
+
+// TestV3LeaseTimeToLiveStress keeps creating lease and retrieving it immediately to ensure the lease can be retrieved.
+// it was oberserved that the immediate lease retrieval after granting a lease from follower resulted lease not found.
+// related issue https://github.com/coreos/etcd/issues/6978
+func TestV3LeaseTimeToLiveStress(t *testing.T) {
+ testLeaseStress(t, stressLeaseTimeToLive)
+}
+
+func testLeaseStress(t *testing.T, stresser func(context.Context, pb.LeaseClient) error) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ errc := make(chan error)
+
+ for i := 0; i < 30; i++ {
+ for j := 0; j < 3; j++ {
+ go func(i int) { errc <- stresser(ctx, toGRPC(clus.Client(i)).Lease) }(j)
+ }
+ }
+
+ for i := 0; i < 90; i++ {
+ if err := <-errc; err != nil {
+ t.Fatal(err)
+ }
+ }
+}
+
+func stressLeaseRenew(tctx context.Context, lc pb.LeaseClient) (reterr error) {
+ defer func() {
+ if tctx.Err() != nil {
+ reterr = nil
+ }
+ }()
+ lac, err := lc.LeaseKeepAlive(tctx)
+ if err != nil {
+ return err
+ }
+ for tctx.Err() == nil {
+ resp, gerr := lc.LeaseGrant(tctx, &pb.LeaseGrantRequest{TTL: 60})
+ if gerr != nil {
+ continue
+ }
+ err = lac.Send(&pb.LeaseKeepAliveRequest{ID: resp.ID})
+ if err != nil {
+ continue
+ }
+ rresp, rxerr := lac.Recv()
+ if rxerr != nil {
+ continue
+ }
+ if rresp.TTL == 0 {
+ return fmt.Errorf("TTL shouldn't be 0 so soon")
+ }
+ }
+ return nil
+}
+
+func stressLeaseTimeToLive(tctx context.Context, lc pb.LeaseClient) (reterr error) {
+ defer func() {
+ if tctx.Err() != nil {
+ reterr = nil
+ }
+ }()
+ for tctx.Err() == nil {
+ resp, gerr := lc.LeaseGrant(tctx, &pb.LeaseGrantRequest{TTL: 60})
+ if gerr != nil {
+ continue
+ }
+ _, kerr := lc.LeaseTimeToLive(tctx, &pb.LeaseTimeToLiveRequest{ID: resp.ID})
+ if rpctypes.Error(kerr) == rpctypes.ErrLeaseNotFound {
+ return kerr
+ }
+ }
+ return nil
+}
+
+func TestV3PutOnNonExistLease(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+
+ badLeaseID := int64(0x12345678)
+ putr := &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar"), Lease: badLeaseID}
+ _, err := toGRPC(clus.RandClient()).KV.Put(ctx, putr)
+ if !eqErrGRPC(err, rpctypes.ErrGRPCLeaseNotFound) {
+ t.Errorf("err = %v, want %v", err, rpctypes.ErrGRPCLeaseNotFound)
+ }
+}
+
+// TestV3GetNonExistLease ensures client retrieving nonexistent lease on a follower doesn't result node panic
+// related issue https://github.com/coreos/etcd/issues/6537
+func TestV3GetNonExistLease(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ lc := toGRPC(clus.RandClient()).Lease
+ lresp, err := lc.LeaseGrant(ctx, &pb.LeaseGrantRequest{TTL: 10})
+ if err != nil {
+ t.Errorf("failed to create lease %v", err)
+ }
+ _, err = lc.LeaseRevoke(context.TODO(), &pb.LeaseRevokeRequest{ID: lresp.ID})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ leaseTTLr := &pb.LeaseTimeToLiveRequest{
+ ID: lresp.ID,
+ Keys: true,
+ }
+
+ for _, client := range clus.clients {
+ // quorum-read to ensure revoke completes before TimeToLive
+ if _, err := toGRPC(client).KV.Range(ctx, &pb.RangeRequest{Key: []byte("_")}); err != nil {
+ t.Fatal(err)
+ }
+ resp, err := toGRPC(client).Lease.LeaseTimeToLive(ctx, leaseTTLr)
+ if err != nil {
+ t.Fatalf("expected non nil error, but go %v", err)
+ }
+ if resp.TTL != -1 {
+ t.Fatalf("expected TTL to be -1, but got %v", resp.TTL)
+ }
+ }
+}
+
+// TestV3LeaseSwitch tests a key can be switched from one lease to another.
+func TestV3LeaseSwitch(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ key := "foo"
+
+ // create lease
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ lresp1, err1 := toGRPC(clus.RandClient()).Lease.LeaseGrant(ctx, &pb.LeaseGrantRequest{TTL: 30})
+ if err1 != nil {
+ t.Fatal(err1)
+ }
+ lresp2, err2 := toGRPC(clus.RandClient()).Lease.LeaseGrant(ctx, &pb.LeaseGrantRequest{TTL: 30})
+ if err2 != nil {
+ t.Fatal(err2)
+ }
+
+ // attach key on lease1 then switch it to lease2
+ put1 := &pb.PutRequest{Key: []byte(key), Lease: lresp1.ID}
+ _, err := toGRPC(clus.RandClient()).KV.Put(ctx, put1)
+ if err != nil {
+ t.Fatal(err)
+ }
+ put2 := &pb.PutRequest{Key: []byte(key), Lease: lresp2.ID}
+ _, err = toGRPC(clus.RandClient()).KV.Put(ctx, put2)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // revoke lease1 should not remove key
+ _, err = toGRPC(clus.RandClient()).Lease.LeaseRevoke(ctx, &pb.LeaseRevokeRequest{ID: lresp1.ID})
+ if err != nil {
+ t.Fatal(err)
+ }
+ rreq := &pb.RangeRequest{Key: []byte("foo")}
+ rresp, err := toGRPC(clus.RandClient()).KV.Range(context.TODO(), rreq)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(rresp.Kvs) != 1 {
+ t.Fatalf("unexpect removal of key")
+ }
+
+ // revoke lease2 should remove key
+ _, err = toGRPC(clus.RandClient()).Lease.LeaseRevoke(ctx, &pb.LeaseRevokeRequest{ID: lresp2.ID})
+ if err != nil {
+ t.Fatal(err)
+ }
+ rresp, err = toGRPC(clus.RandClient()).KV.Range(context.TODO(), rreq)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(rresp.Kvs) != 0 {
+ t.Fatalf("lease removed but key remains")
+ }
+}
+
+// TestV3LeaseFailover ensures the old leader drops lease keepalive requests within
+// election timeout after it loses its quorum. And the new leader extends the TTL of
+// the lease to at least TTL + election timeout.
+func TestV3LeaseFailover(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ toIsolate := clus.waitLeader(t, clus.Members)
+
+ lc := toGRPC(clus.Client(toIsolate)).Lease
+
+ // create lease
+ lresp, err := lc.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: 5})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if lresp.Error != "" {
+ t.Fatal(lresp.Error)
+ }
+
+ // isolate the current leader with its followers.
+ clus.Members[toIsolate].Pause()
+
+ lreq := &pb.LeaseKeepAliveRequest{ID: lresp.ID}
+
+ md := metadata.Pairs(rpctypes.MetadataRequireLeaderKey, rpctypes.MetadataHasLeader)
+ mctx := metadata.NewContext(context.Background(), md)
+ ctx, cancel := context.WithCancel(mctx)
+ defer cancel()
+ lac, err := lc.LeaseKeepAlive(ctx)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer lac.CloseSend()
+
+ // send keep alive to old leader until the old leader starts
+ // to drop lease request.
+ var expectedExp time.Time
+ for {
+ if err = lac.Send(lreq); err != nil {
+ break
+ }
+ lkresp, rxerr := lac.Recv()
+ if rxerr != nil {
+ break
+ }
+ expectedExp = time.Now().Add(time.Duration(lkresp.TTL) * time.Second)
+ time.Sleep(time.Duration(lkresp.TTL/2) * time.Second)
+ }
+
+ clus.Members[toIsolate].Resume()
+ clus.waitLeader(t, clus.Members)
+
+ // lease should not expire at the last received expire deadline.
+ time.Sleep(time.Until(expectedExp) - 500*time.Millisecond)
+
+ if !leaseExist(t, clus, lresp.ID) {
+ t.Error("unexpected lease not exists")
+ }
+}
+
+// TestV3LeaseRequireLeader ensures that a Recv will get a leader
+// loss error if there is no leader.
+func TestV3LeaseRequireLeader(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ lc := toGRPC(clus.Client(0)).Lease
+ clus.Members[1].Stop(t)
+ clus.Members[2].Stop(t)
+
+ md := metadata.Pairs(rpctypes.MetadataRequireLeaderKey, rpctypes.MetadataHasLeader)
+ mctx := metadata.NewContext(context.Background(), md)
+ ctx, cancel := context.WithCancel(mctx)
+ defer cancel()
+ lac, err := lc.LeaseKeepAlive(ctx)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ resp, err := lac.Recv()
+ if err == nil {
+ t.Fatalf("got response %+v, expected error", resp)
+ }
+ if grpc.ErrorDesc(err) != rpctypes.ErrNoLeader.Error() {
+ t.Errorf("err = %v, want %v", err, rpctypes.ErrNoLeader)
+ }
+ }()
+ select {
+ case <-time.After(5 * time.Second):
+ t.Fatal("did not receive leader loss error (in 5-sec)")
+ case <-donec:
+ }
+}
+
+const fiveMinTTL int64 = 300
+
+// TestV3LeaseRecoverAndRevoke ensures that revoking a lease after restart deletes the attached key.
+func TestV3LeaseRecoverAndRevoke(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.Client(0)).KV
+ lsc := toGRPC(clus.Client(0)).Lease
+
+ lresp, err := lsc.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: fiveMinTTL})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if lresp.Error != "" {
+ t.Fatal(lresp.Error)
+ }
+ _, err = kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar"), Lease: lresp.ID})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // restart server and ensure lease still exists
+ clus.Members[0].Stop(t)
+ clus.Members[0].Restart(t)
+ clus.waitLeader(t, clus.Members)
+
+ // overwrite old client with newly dialed connection
+ // otherwise, error with "grpc: RPC failed fast due to transport failure"
+ nc, err := NewClientV3(clus.Members[0])
+ if err != nil {
+ t.Fatal(err)
+ }
+ kvc = toGRPC(nc).KV
+ lsc = toGRPC(nc).Lease
+ defer nc.Close()
+
+ // revoke should delete the key
+ _, err = lsc.LeaseRevoke(context.TODO(), &pb.LeaseRevokeRequest{ID: lresp.ID})
+ if err != nil {
+ t.Fatal(err)
+ }
+ rresp, err := kvc.Range(context.TODO(), &pb.RangeRequest{Key: []byte("foo")})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(rresp.Kvs) != 0 {
+ t.Fatalf("lease removed but key remains")
+ }
+}
+
+// TestV3LeaseRevokeAndRecover ensures that revoked key stays deleted after restart.
+func TestV3LeaseRevokeAndRecover(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.Client(0)).KV
+ lsc := toGRPC(clus.Client(0)).Lease
+
+ lresp, err := lsc.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: fiveMinTTL})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if lresp.Error != "" {
+ t.Fatal(lresp.Error)
+ }
+ _, err = kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar"), Lease: lresp.ID})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // revoke should delete the key
+ _, err = lsc.LeaseRevoke(context.TODO(), &pb.LeaseRevokeRequest{ID: lresp.ID})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // restart server and ensure revoked key doesn't exist
+ clus.Members[0].Stop(t)
+ clus.Members[0].Restart(t)
+ clus.waitLeader(t, clus.Members)
+
+ // overwrite old client with newly dialed connection
+ // otherwise, error with "grpc: RPC failed fast due to transport failure"
+ nc, err := NewClientV3(clus.Members[0])
+ if err != nil {
+ t.Fatal(err)
+ }
+ kvc = toGRPC(nc).KV
+ defer nc.Close()
+
+ rresp, err := kvc.Range(context.TODO(), &pb.RangeRequest{Key: []byte("foo")})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(rresp.Kvs) != 0 {
+ t.Fatalf("lease removed but key remains")
+ }
+}
+
+// TestV3LeaseRecoverKeyWithDetachedLease ensures that revoking a detached lease after restart
+// does not delete the key.
+func TestV3LeaseRecoverKeyWithDetachedLease(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.Client(0)).KV
+ lsc := toGRPC(clus.Client(0)).Lease
+
+ lresp, err := lsc.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: fiveMinTTL})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if lresp.Error != "" {
+ t.Fatal(lresp.Error)
+ }
+ _, err = kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar"), Lease: lresp.ID})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // overwrite lease with none
+ _, err = kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // restart server and ensure lease still exists
+ clus.Members[0].Stop(t)
+ clus.Members[0].Restart(t)
+ clus.waitLeader(t, clus.Members)
+
+ // overwrite old client with newly dialed connection
+ // otherwise, error with "grpc: RPC failed fast due to transport failure"
+ nc, err := NewClientV3(clus.Members[0])
+ if err != nil {
+ t.Fatal(err)
+ }
+ kvc = toGRPC(nc).KV
+ lsc = toGRPC(nc).Lease
+ defer nc.Close()
+
+ // revoke the detached lease
+ _, err = lsc.LeaseRevoke(context.TODO(), &pb.LeaseRevokeRequest{ID: lresp.ID})
+ if err != nil {
+ t.Fatal(err)
+ }
+ rresp, err := kvc.Range(context.TODO(), &pb.RangeRequest{Key: []byte("foo")})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(rresp.Kvs) != 1 {
+ t.Fatalf("only detached lease removed, key should remain")
+ }
+}
+
+func TestV3LeaseRecoverKeyWithMutipleLease(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.Client(0)).KV
+ lsc := toGRPC(clus.Client(0)).Lease
+
+ var leaseIDs []int64
+ for i := 0; i < 2; i++ {
+ lresp, err := lsc.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: fiveMinTTL})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if lresp.Error != "" {
+ t.Fatal(lresp.Error)
+ }
+ leaseIDs = append(leaseIDs, lresp.ID)
+
+ _, err = kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar"), Lease: lresp.ID})
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ // restart server and ensure lease still exists
+ clus.Members[0].Stop(t)
+ clus.Members[0].Restart(t)
+ clus.waitLeader(t, clus.Members)
+ for i, leaseID := range leaseIDs {
+ if !leaseExist(t, clus, leaseID) {
+ t.Errorf("#%d: unexpected lease not exists", i)
+ }
+ }
+
+ // overwrite old client with newly dialed connection
+ // otherwise, error with "grpc: RPC failed fast due to transport failure"
+ nc, err := NewClientV3(clus.Members[0])
+ if err != nil {
+ t.Fatal(err)
+ }
+ kvc = toGRPC(nc).KV
+ lsc = toGRPC(nc).Lease
+ defer nc.Close()
+
+ // revoke the old lease
+ _, err = lsc.LeaseRevoke(context.TODO(), &pb.LeaseRevokeRequest{ID: leaseIDs[0]})
+ if err != nil {
+ t.Fatal(err)
+ }
+ // key should still exist
+ rresp, err := kvc.Range(context.TODO(), &pb.RangeRequest{Key: []byte("foo")})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(rresp.Kvs) != 1 {
+ t.Fatalf("only detached lease removed, key should remain")
+ }
+
+ // revoke the latest lease
+ _, err = lsc.LeaseRevoke(context.TODO(), &pb.LeaseRevokeRequest{ID: leaseIDs[1]})
+ if err != nil {
+ t.Fatal(err)
+ }
+ rresp, err = kvc.Range(context.TODO(), &pb.RangeRequest{Key: []byte("foo")})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(rresp.Kvs) != 0 {
+ t.Fatalf("lease removed but key remains")
+ }
+}
+
+// acquireLeaseAndKey creates a new lease and creates an attached key.
+func acquireLeaseAndKey(clus *ClusterV3, key string) (int64, error) {
+ // create lease
+ lresp, err := toGRPC(clus.RandClient()).Lease.LeaseGrant(
+ context.TODO(),
+ &pb.LeaseGrantRequest{TTL: 1})
+ if err != nil {
+ return 0, err
+ }
+ if lresp.Error != "" {
+ return 0, fmt.Errorf(lresp.Error)
+ }
+ // attach to key
+ put := &pb.PutRequest{Key: []byte(key), Lease: lresp.ID}
+ if _, err := toGRPC(clus.RandClient()).KV.Put(context.TODO(), put); err != nil {
+ return 0, err
+ }
+ return lresp.ID, nil
+}
+
+// testLeaseRemoveLeasedKey performs some action while holding a lease with an
+// attached key "foo", then confirms the key is gone.
+func testLeaseRemoveLeasedKey(t *testing.T, act func(*ClusterV3, int64) error) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ leaseID, err := acquireLeaseAndKey(clus, "foo")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if err = act(clus, leaseID); err != nil {
+ t.Fatal(err)
+ }
+
+ // confirm no key
+ rreq := &pb.RangeRequest{Key: []byte("foo")}
+ rresp, err := toGRPC(clus.RandClient()).KV.Range(context.TODO(), rreq)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(rresp.Kvs) != 0 {
+ t.Fatalf("lease removed but key remains")
+ }
+}
+
+func leaseExist(t *testing.T, clus *ClusterV3, leaseID int64) bool {
+ l := toGRPC(clus.RandClient()).Lease
+
+ _, err := l.LeaseGrant(context.Background(), &pb.LeaseGrantRequest{ID: leaseID, TTL: 5})
+ if err == nil {
+ _, err = l.LeaseRevoke(context.Background(), &pb.LeaseRevokeRequest{ID: leaseID})
+ if err != nil {
+ t.Fatalf("failed to check lease %v", err)
+ }
+ return false
+ }
+
+ if eqErrGRPC(err, rpctypes.ErrGRPCLeaseExist) {
+ return true
+ }
+ t.Fatalf("unexpecter error %v", err)
+
+ return true
+}
diff --git a/vendor/github.com/coreos/etcd/integration/v3_lock_test.go b/vendor/github.com/coreos/etcd/integration/v3_lock_test.go
new file mode 100644
index 00000000..e2f37afe
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/v3_lock_test.go
@@ -0,0 +1,323 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "math/rand"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/concurrency"
+ "github.com/coreos/etcd/contrib/recipes"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/coreos/etcd/pkg/testutil"
+ "golang.org/x/net/context"
+)
+
+func TestMutexSingleNode(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ var clients []*clientv3.Client
+ testMutex(t, 5, makeSingleNodeClients(t, clus.cluster, &clients))
+ closeClients(t, clients)
+}
+
+func TestMutexMultiNode(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ var clients []*clientv3.Client
+ testMutex(t, 5, makeMultiNodeClients(t, clus.cluster, &clients))
+ closeClients(t, clients)
+}
+
+func testMutex(t *testing.T, waiters int, chooseClient func() *clientv3.Client) {
+ // stream lock acquisitions
+ lockedC := make(chan *concurrency.Mutex)
+ for i := 0; i < waiters; i++ {
+ go func() {
+ session, err := concurrency.NewSession(chooseClient())
+ if err != nil {
+ t.Error(err)
+ }
+ m := concurrency.NewMutex(session, "test-mutex")
+ if err := m.Lock(context.TODO()); err != nil {
+ t.Fatalf("could not wait on lock (%v)", err)
+ }
+ lockedC <- m
+ }()
+ }
+ // unlock locked mutexes
+ timerC := time.After(time.Duration(waiters) * time.Second)
+ for i := 0; i < waiters; i++ {
+ select {
+ case <-timerC:
+ t.Fatalf("timed out waiting for lock %d", i)
+ case m := <-lockedC:
+ // lock acquired with m
+ select {
+ case <-lockedC:
+ t.Fatalf("lock %d followers did not wait", i)
+ default:
+ }
+ if err := m.Unlock(context.TODO()); err != nil {
+ t.Fatalf("could not release lock (%v)", err)
+ }
+ }
+ }
+}
+
+// TestMutexSessionRelock ensures that acquiring the same lock with the same
+// session will not result in deadlock.
+func TestMutexSessionRelock(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+ session, err := concurrency.NewSession(clus.RandClient())
+ if err != nil {
+ t.Error(err)
+ }
+
+ m := concurrency.NewMutex(session, "test-mutex")
+ if err := m.Lock(context.TODO()); err != nil {
+ t.Fatal(err)
+ }
+
+ m2 := concurrency.NewMutex(session, "test-mutex")
+ if err := m2.Lock(context.TODO()); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// TestMutexWaitsOnCurrentHolder ensures a mutex is only acquired once all
+// waiters older than the new owner are gone by testing the case where
+// the waiter prior to the acquirer expires before the current holder.
+func TestMutexWaitsOnCurrentHolder(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cctx := context.Background()
+
+ cli := clus.Client(0)
+
+ firstOwnerSession, err := concurrency.NewSession(cli)
+ if err != nil {
+ t.Error(err)
+ }
+ defer firstOwnerSession.Close()
+ firstOwnerMutex := concurrency.NewMutex(firstOwnerSession, "test-mutex")
+ if err = firstOwnerMutex.Lock(cctx); err != nil {
+ t.Fatal(err)
+ }
+
+ victimSession, err := concurrency.NewSession(cli)
+ if err != nil {
+ t.Error(err)
+ }
+ defer victimSession.Close()
+ victimDonec := make(chan struct{})
+ go func() {
+ defer close(victimDonec)
+ concurrency.NewMutex(victimSession, "test-mutex").Lock(cctx)
+ }()
+
+ // ensure mutexes associated with firstOwnerSession and victimSession waits before new owner
+ wch := cli.Watch(cctx, "test-mutex", clientv3.WithPrefix(), clientv3.WithRev(1))
+ putCounts := 0
+ for putCounts < 2 {
+ select {
+ case wrp := <-wch:
+ putCounts += len(wrp.Events)
+ case <-time.After(time.Second):
+ t.Fatal("failed to receive watch response")
+ }
+ }
+ if putCounts != 2 {
+ t.Fatalf("expect 2 put events, but got %v", putCounts)
+ }
+
+ newOwnerSession, err := concurrency.NewSession(cli)
+ if err != nil {
+ t.Error(err)
+ }
+ defer newOwnerSession.Close()
+ newOwnerDonec := make(chan struct{})
+ go func() {
+ defer close(newOwnerDonec)
+ concurrency.NewMutex(newOwnerSession, "test-mutex").Lock(cctx)
+ }()
+
+ select {
+ case wrp := <-wch:
+ if len(wrp.Events) != 1 {
+ t.Fatalf("expect a event, but got %v events", len(wrp.Events))
+ }
+ if e := wrp.Events[0]; e.Type != mvccpb.PUT {
+ t.Fatalf("expect a put event on prefix test-mutex, but got event type %v", e.Type)
+ }
+ case <-time.After(time.Second):
+ t.Fatalf("failed to receive a watch response")
+ }
+
+ // simulate losing the client that's next in line to acquire the lock
+ victimSession.Close()
+
+ // ensures the deletion of victim waiter from server side.
+ select {
+ case wrp := <-wch:
+ if len(wrp.Events) != 1 {
+ t.Fatalf("expect a event, but got %v events", len(wrp.Events))
+ }
+ if e := wrp.Events[0]; e.Type != mvccpb.DELETE {
+ t.Fatalf("expect a delete event on prefix test-mutex, but got event type %v", e.Type)
+ }
+ case <-time.After(time.Second):
+ t.Fatal("failed to receive a watch response")
+ }
+
+ select {
+ case <-newOwnerDonec:
+ t.Fatal("new owner obtained lock before first owner unlocked")
+ default:
+ }
+
+ if err := firstOwnerMutex.Unlock(cctx); err != nil {
+ t.Fatal(err)
+ }
+
+ select {
+ case <-newOwnerDonec:
+ case <-time.After(time.Second):
+ t.Fatal("new owner failed to obtain lock")
+ }
+
+ select {
+ case <-victimDonec:
+ case <-time.After(time.Second):
+ t.Fatal("victim mutex failed to exit after first owner releases lock")
+ }
+}
+
+func BenchmarkMutex4Waiters(b *testing.B) {
+ // XXX switch tests to use TB interface
+ clus := NewClusterV3(nil, &ClusterConfig{Size: 3})
+ defer clus.Terminate(nil)
+ for i := 0; i < b.N; i++ {
+ testMutex(nil, 4, func() *clientv3.Client { return clus.RandClient() })
+ }
+}
+
+func TestRWMutexSingleNode(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+ testRWMutex(t, 5, func() *clientv3.Client { return clus.clients[0] })
+}
+
+func TestRWMutexMultiNode(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+ testRWMutex(t, 5, func() *clientv3.Client { return clus.RandClient() })
+}
+
+func testRWMutex(t *testing.T, waiters int, chooseClient func() *clientv3.Client) {
+ // stream rwlock acquistions
+ rlockedC := make(chan *recipe.RWMutex, 1)
+ wlockedC := make(chan *recipe.RWMutex, 1)
+ for i := 0; i < waiters; i++ {
+ go func() {
+ session, err := concurrency.NewSession(chooseClient())
+ if err != nil {
+ t.Error(err)
+ }
+ rwm := recipe.NewRWMutex(session, "test-rwmutex")
+ if rand.Intn(2) == 0 {
+ if err := rwm.RLock(); err != nil {
+ t.Fatalf("could not rlock (%v)", err)
+ }
+ rlockedC <- rwm
+ } else {
+ if err := rwm.Lock(); err != nil {
+ t.Fatalf("could not lock (%v)", err)
+ }
+ wlockedC <- rwm
+ }
+ }()
+ }
+ // unlock locked rwmutexes
+ timerC := time.After(time.Duration(waiters) * time.Second)
+ for i := 0; i < waiters; i++ {
+ select {
+ case <-timerC:
+ t.Fatalf("timed out waiting for lock %d", i)
+ case wl := <-wlockedC:
+ select {
+ case <-rlockedC:
+ t.Fatalf("rlock %d readers did not wait", i)
+ default:
+ }
+ if err := wl.Unlock(); err != nil {
+ t.Fatalf("could not release lock (%v)", err)
+ }
+ case rl := <-rlockedC:
+ select {
+ case <-wlockedC:
+ t.Fatalf("rlock %d writers did not wait", i)
+ default:
+ }
+ if err := rl.RUnlock(); err != nil {
+ t.Fatalf("could not release rlock (%v)", err)
+ }
+ }
+ }
+}
+
+func makeClients(t *testing.T, clients *[]*clientv3.Client, choose func() *member) func() *clientv3.Client {
+ var mu sync.Mutex
+ *clients = nil
+ return func() *clientv3.Client {
+ cli, err := NewClientV3(choose())
+ if err != nil {
+ t.Fatalf("cannot create client: %v", err)
+ }
+ mu.Lock()
+ *clients = append(*clients, cli)
+ mu.Unlock()
+ return cli
+ }
+}
+
+func makeSingleNodeClients(t *testing.T, clus *cluster, clients *[]*clientv3.Client) func() *clientv3.Client {
+ return makeClients(t, clients, func() *member {
+ return clus.Members[0]
+ })
+}
+
+func makeMultiNodeClients(t *testing.T, clus *cluster, clients *[]*clientv3.Client) func() *clientv3.Client {
+ return makeClients(t, clients, func() *member {
+ return clus.Members[rand.Intn(len(clus.Members))]
+ })
+}
+
+func closeClients(t *testing.T, clients []*clientv3.Client) {
+ for _, cli := range clients {
+ if err := cli.Close(); err != nil {
+ t.Fatal(err)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/integration/v3_queue_test.go b/vendor/github.com/coreos/etcd/integration/v3_queue_test.go
new file mode 100644
index 00000000..f7673f9b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/v3_queue_test.go
@@ -0,0 +1,225 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "fmt"
+ "math/rand"
+ "sync/atomic"
+ "testing"
+
+ "github.com/coreos/etcd/contrib/recipes"
+)
+
+const (
+ manyQueueClients = 3
+ queueItemsPerClient = 2
+)
+
+// TestQueueOneReaderOneWriter confirms the queue is FIFO
+func TestQueueOneReaderOneWriter(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ done := make(chan struct{})
+ go func() {
+ defer func() {
+ done <- struct{}{}
+ }()
+ etcdc := clus.RandClient()
+ q := recipe.NewQueue(etcdc, "testq")
+ for i := 0; i < 5; i++ {
+ if err := q.Enqueue(fmt.Sprintf("%d", i)); err != nil {
+ t.Fatalf("error enqueuing (%v)", err)
+ }
+ }
+ }()
+
+ etcdc := clus.RandClient()
+ q := recipe.NewQueue(etcdc, "testq")
+ for i := 0; i < 5; i++ {
+ s, err := q.Dequeue()
+ if err != nil {
+ t.Fatalf("error dequeueing (%v)", err)
+ }
+ if s != fmt.Sprintf("%d", i) {
+ t.Fatalf("expected dequeue value %v, got %v", s, i)
+ }
+ }
+ <-done
+}
+
+func TestQueueManyReaderOneWriter(t *testing.T) {
+ testQueueNReaderMWriter(t, manyQueueClients, 1)
+}
+
+func TestQueueOneReaderManyWriter(t *testing.T) {
+ testQueueNReaderMWriter(t, 1, manyQueueClients)
+}
+
+func TestQueueManyReaderManyWriter(t *testing.T) {
+ testQueueNReaderMWriter(t, manyQueueClients, manyQueueClients)
+}
+
+// BenchmarkQueue benchmarks Queues using many/many readers/writers
+func BenchmarkQueue(b *testing.B) {
+ // XXX switch tests to use TB interface
+ clus := NewClusterV3(nil, &ClusterConfig{Size: 3})
+ defer clus.Terminate(nil)
+ for i := 0; i < b.N; i++ {
+ testQueueNReaderMWriter(nil, manyQueueClients, manyQueueClients)
+ }
+}
+
+// TestPrQueueOneReaderOneWriter tests whether priority queues respect priorities.
+func TestPrQueueOneReaderOneWriter(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ // write out five items with random priority
+ etcdc := clus.RandClient()
+ q := recipe.NewPriorityQueue(etcdc, "testprq")
+ for i := 0; i < 5; i++ {
+ // [0, 2] priority for priority collision to test seq keys
+ pr := uint16(rand.Intn(3))
+ if err := q.Enqueue(fmt.Sprintf("%d", pr), pr); err != nil {
+ t.Fatalf("error enqueuing (%v)", err)
+ }
+ }
+
+ // read back items; confirm priority order is respected
+ lastPr := -1
+ for i := 0; i < 5; i++ {
+ s, err := q.Dequeue()
+ if err != nil {
+ t.Fatalf("error dequeueing (%v)", err)
+ }
+ curPr := 0
+ if _, err := fmt.Sscanf(s, "%d", &curPr); err != nil {
+ t.Fatalf(`error parsing item "%s" (%v)`, s, err)
+ }
+ if lastPr > curPr {
+ t.Fatalf("expected priority %v > %v", curPr, lastPr)
+ }
+ }
+}
+
+func TestPrQueueManyReaderManyWriter(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+ rqs := newPriorityQueues(clus, manyQueueClients)
+ wqs := newPriorityQueues(clus, manyQueueClients)
+ testReadersWriters(t, rqs, wqs)
+}
+
+// BenchmarkQueue benchmarks Queues using n/n readers/writers
+func BenchmarkPrQueueOneReaderOneWriter(b *testing.B) {
+ // XXX switch tests to use TB interface
+ clus := NewClusterV3(nil, &ClusterConfig{Size: 3})
+ defer clus.Terminate(nil)
+ rqs := newPriorityQueues(clus, 1)
+ wqs := newPriorityQueues(clus, 1)
+ for i := 0; i < b.N; i++ {
+ testReadersWriters(nil, rqs, wqs)
+ }
+}
+
+func testQueueNReaderMWriter(t *testing.T, n int, m int) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+ testReadersWriters(t, newQueues(clus, n), newQueues(clus, m))
+}
+
+func newQueues(clus *ClusterV3, n int) (qs []testQueue) {
+ for i := 0; i < n; i++ {
+ etcdc := clus.RandClient()
+ qs = append(qs, recipe.NewQueue(etcdc, "q"))
+ }
+ return qs
+}
+
+func newPriorityQueues(clus *ClusterV3, n int) (qs []testQueue) {
+ for i := 0; i < n; i++ {
+ etcdc := clus.RandClient()
+ q := &flatPriorityQueue{recipe.NewPriorityQueue(etcdc, "prq")}
+ qs = append(qs, q)
+ }
+ return qs
+}
+
+func testReadersWriters(t *testing.T, rqs []testQueue, wqs []testQueue) {
+ rerrc := make(chan error)
+ werrc := make(chan error)
+ manyWriters(wqs, queueItemsPerClient, werrc)
+ manyReaders(rqs, len(wqs)*queueItemsPerClient, rerrc)
+ for range wqs {
+ if err := <-werrc; err != nil {
+ t.Errorf("error writing (%v)", err)
+ }
+ }
+ for range rqs {
+ if err := <-rerrc; err != nil {
+ t.Errorf("error reading (%v)", err)
+ }
+ }
+}
+
+func manyReaders(qs []testQueue, totalReads int, errc chan<- error) {
+ var rxReads int32
+ for _, q := range qs {
+ go func(q testQueue) {
+ for {
+ total := atomic.AddInt32(&rxReads, 1)
+ if int(total) > totalReads {
+ break
+ }
+ if _, err := q.Dequeue(); err != nil {
+ errc <- err
+ return
+ }
+ }
+ errc <- nil
+ }(q)
+ }
+}
+
+func manyWriters(qs []testQueue, writesEach int, errc chan<- error) {
+ for _, q := range qs {
+ go func(q testQueue) {
+ for j := 0; j < writesEach; j++ {
+ if err := q.Enqueue("foo"); err != nil {
+ errc <- err
+ return
+ }
+ }
+ errc <- nil
+ }(q)
+ }
+}
+
+type testQueue interface {
+ Enqueue(val string) error
+ Dequeue() (string, error)
+}
+
+type flatPriorityQueue struct{ *recipe.PriorityQueue }
+
+func (q *flatPriorityQueue) Enqueue(val string) error {
+ // randomized to stress dequeuing logic; order isn't important
+ return q.PriorityQueue.Enqueue(val, uint16(rand.Intn(2)))
+}
+func (q *flatPriorityQueue) Dequeue() (string, error) {
+ return q.PriorityQueue.Dequeue()
+}
diff --git a/vendor/github.com/coreos/etcd/integration/v3_stm_test.go b/vendor/github.com/coreos/etcd/integration/v3_stm_test.go
new file mode 100644
index 00000000..057bfb88
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/v3_stm_test.go
@@ -0,0 +1,255 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "fmt"
+ "math/rand"
+ "strconv"
+ "testing"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/concurrency"
+ "golang.org/x/net/context"
+)
+
+// TestSTMConflict tests that conflicts are retried.
+func TestSTMConflict(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ etcdc := clus.RandClient()
+ keys := make([]string, 5)
+ for i := 0; i < len(keys); i++ {
+ keys[i] = fmt.Sprintf("foo-%d", i)
+ if _, err := etcdc.Put(context.TODO(), keys[i], "100"); err != nil {
+ t.Fatalf("could not make key (%v)", err)
+ }
+ }
+
+ errc := make(chan error)
+ for i := range keys {
+ curEtcdc := clus.RandClient()
+ srcKey := keys[i]
+ applyf := func(stm concurrency.STM) error {
+ src := stm.Get(srcKey)
+ // must be different key to avoid double-adding
+ dstKey := srcKey
+ for dstKey == srcKey {
+ dstKey = keys[rand.Intn(len(keys))]
+ }
+ dst := stm.Get(dstKey)
+ srcV, _ := strconv.ParseInt(src, 10, 64)
+ dstV, _ := strconv.ParseInt(dst, 10, 64)
+ if srcV == 0 {
+ // can't rand.Intn on 0, so skip this transaction
+ return nil
+ }
+ xfer := int64(rand.Intn(int(srcV)) / 2)
+ stm.Put(srcKey, fmt.Sprintf("%d", srcV-xfer))
+ stm.Put(dstKey, fmt.Sprintf("%d", dstV+xfer))
+ return nil
+ }
+ go func() {
+ iso := concurrency.WithIsolation(concurrency.RepeatableReads)
+ _, err := concurrency.NewSTM(curEtcdc, applyf, iso)
+ errc <- err
+ }()
+ }
+
+ // wait for txns
+ for range keys {
+ if err := <-errc; err != nil {
+ t.Fatalf("apply failed (%v)", err)
+ }
+ }
+
+ // ensure sum matches initial sum
+ sum := 0
+ for _, oldkey := range keys {
+ rk, err := etcdc.Get(context.TODO(), oldkey)
+ if err != nil {
+ t.Fatalf("couldn't fetch key %s (%v)", oldkey, err)
+ }
+ v, _ := strconv.ParseInt(string(rk.Kvs[0].Value), 10, 64)
+ sum += int(v)
+ }
+ if sum != len(keys)*100 {
+ t.Fatalf("bad sum. got %d, expected %d", sum, len(keys)*100)
+ }
+}
+
+// TestSTMPutNewKey confirms a STM put on a new key is visible after commit.
+func TestSTMPutNewKey(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ etcdc := clus.RandClient()
+ applyf := func(stm concurrency.STM) error {
+ stm.Put("foo", "bar")
+ return nil
+ }
+
+ iso := concurrency.WithIsolation(concurrency.RepeatableReads)
+ if _, err := concurrency.NewSTM(etcdc, applyf, iso); err != nil {
+ t.Fatalf("error on stm txn (%v)", err)
+ }
+
+ resp, err := etcdc.Get(context.TODO(), "foo")
+ if err != nil {
+ t.Fatalf("error fetching key (%v)", err)
+ }
+ if string(resp.Kvs[0].Value) != "bar" {
+ t.Fatalf("bad value. got %+v, expected 'bar' value", resp)
+ }
+}
+
+// TestSTMAbort tests that an aborted txn does not modify any keys.
+func TestSTMAbort(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ etcdc := clus.RandClient()
+ ctx, cancel := context.WithCancel(context.TODO())
+ applyf := func(stm concurrency.STM) error {
+ stm.Put("foo", "baz")
+ cancel()
+ stm.Put("foo", "bap")
+ return nil
+ }
+
+ iso := concurrency.WithIsolation(concurrency.RepeatableReads)
+ sctx := concurrency.WithAbortContext(ctx)
+ if _, err := concurrency.NewSTM(etcdc, applyf, iso, sctx); err == nil {
+ t.Fatalf("no error on stm txn")
+ }
+
+ resp, err := etcdc.Get(context.TODO(), "foo")
+ if err != nil {
+ t.Fatalf("error fetching key (%v)", err)
+ }
+ if len(resp.Kvs) != 0 {
+ t.Fatalf("bad value. got %+v, expected nothing", resp)
+ }
+}
+
+// TestSTMSerialize tests that serialization is honored when serializable.
+func TestSTMSerialize(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ etcdc := clus.RandClient()
+
+ // set up initial keys
+ keys := make([]string, 5)
+ for i := 0; i < len(keys); i++ {
+ keys[i] = fmt.Sprintf("foo-%d", i)
+ }
+
+ // update keys in full batches
+ updatec := make(chan struct{})
+ go func() {
+ defer close(updatec)
+ for i := 0; i < 5; i++ {
+ s := fmt.Sprintf("%d", i)
+ ops := []v3.Op{}
+ for _, k := range keys {
+ ops = append(ops, v3.OpPut(k, s))
+ }
+ if _, err := etcdc.Txn(context.TODO()).Then(ops...).Commit(); err != nil {
+ t.Fatalf("couldn't put keys (%v)", err)
+ }
+ updatec <- struct{}{}
+ }
+ }()
+
+ // read all keys in txn, make sure all values match
+ errc := make(chan error)
+ for range updatec {
+ curEtcdc := clus.RandClient()
+ applyf := func(stm concurrency.STM) error {
+ vs := []string{}
+ for i := range keys {
+ vs = append(vs, stm.Get(keys[i]))
+ }
+ for i := range vs {
+ if vs[0] != vs[i] {
+ return fmt.Errorf("got vs[%d] = %v, want %v", i, vs[i], vs[0])
+ }
+ }
+ return nil
+ }
+ go func() {
+ iso := concurrency.WithIsolation(concurrency.Serializable)
+ _, err := concurrency.NewSTM(curEtcdc, applyf, iso)
+ errc <- err
+ }()
+ }
+
+ for i := 0; i < 5; i++ {
+ if err := <-errc; err != nil {
+ t.Error(err)
+ }
+ }
+}
+
+// TestSTMApplyOnConcurrentDeletion ensures that concurrent key deletion
+// fails the first GET revision comparison within STM; trigger retry.
+func TestSTMApplyOnConcurrentDeletion(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ etcdc := clus.RandClient()
+ if _, err := etcdc.Put(context.TODO(), "foo", "bar"); err != nil {
+ t.Fatal(err)
+ }
+ donec, readyc := make(chan struct{}), make(chan struct{})
+ go func() {
+ <-readyc
+ if _, err := etcdc.Delete(context.TODO(), "foo"); err != nil {
+ t.Fatal(err)
+ }
+ close(donec)
+ }()
+
+ try := 0
+ applyf := func(stm concurrency.STM) error {
+ try++
+ stm.Get("foo")
+ if try == 1 {
+ // trigger delete to make GET rev comparison outdated
+ close(readyc)
+ <-donec
+ }
+ stm.Put("foo2", "bar2")
+ return nil
+ }
+
+ iso := concurrency.WithIsolation(concurrency.RepeatableReads)
+ if _, err := concurrency.NewSTM(etcdc, applyf, iso); err != nil {
+ t.Fatalf("error on stm txn (%v)", err)
+ }
+ if try != 2 {
+ t.Fatalf("STM apply expected to run twice, got %d", try)
+ }
+
+ resp, err := etcdc.Get(context.TODO(), "foo2")
+ if err != nil {
+ t.Fatalf("error fetching key (%v)", err)
+ }
+ if string(resp.Kvs[0].Value) != "bar2" {
+ t.Fatalf("bad value. got %+v, expected 'bar2' value", resp)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/integration/v3_watch_test.go b/vendor/github.com/coreos/etcd/integration/v3_watch_test.go
new file mode 100644
index 00000000..c6570d0c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/v3_watch_test.go
@@ -0,0 +1,1199 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "bytes"
+ "fmt"
+ "reflect"
+ "sort"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/api/v3rpc"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/coreos/etcd/pkg/testutil"
+ "golang.org/x/net/context"
+)
+
+// TestV3WatchFromCurrentRevision tests Watch APIs from current revision.
+func TestV3WatchFromCurrentRevision(t *testing.T) {
+ defer testutil.AfterTest(t)
+ tests := []struct {
+ putKeys []string
+ watchRequest *pb.WatchRequest
+
+ wresps []*pb.WatchResponse
+ }{
+ // watch the key, matching
+ {
+ []string{"foo"},
+ &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("foo")}}},
+
+ []*pb.WatchResponse{
+ {
+ Header: &pb.ResponseHeader{Revision: 2},
+ Created: false,
+ Events: []*mvccpb.Event{
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1},
+ },
+ },
+ },
+ },
+ },
+ // watch the key, non-matching
+ {
+ []string{"foo"},
+ &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("helloworld")}}},
+
+ []*pb.WatchResponse{},
+ },
+ // watch the prefix, matching
+ {
+ []string{"fooLong"},
+ &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("foo"),
+ RangeEnd: []byte("fop")}}},
+
+ []*pb.WatchResponse{
+ {
+ Header: &pb.ResponseHeader{Revision: 2},
+ Created: false,
+ Events: []*mvccpb.Event{
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("fooLong"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1},
+ },
+ },
+ },
+ },
+ },
+ // watch the prefix, non-matching
+ {
+ []string{"foo"},
+ &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("helloworld"),
+ RangeEnd: []byte("helloworle")}}},
+
+ []*pb.WatchResponse{},
+ },
+ // watch full range, matching
+ {
+ []string{"fooLong"},
+ &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte(""),
+ RangeEnd: []byte("\x00")}}},
+
+ []*pb.WatchResponse{
+ {
+ Header: &pb.ResponseHeader{Revision: 2},
+ Created: false,
+ Events: []*mvccpb.Event{
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("fooLong"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1},
+ },
+ },
+ },
+ },
+ },
+ // multiple puts, one watcher with matching key
+ {
+ []string{"foo", "foo", "foo"},
+ &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("foo")}}},
+
+ []*pb.WatchResponse{
+ {
+ Header: &pb.ResponseHeader{Revision: 2},
+ Created: false,
+ Events: []*mvccpb.Event{
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1},
+ },
+ },
+ },
+ {
+ Header: &pb.ResponseHeader{Revision: 3},
+ Created: false,
+ Events: []*mvccpb.Event{
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 3, Version: 2},
+ },
+ },
+ },
+ {
+ Header: &pb.ResponseHeader{Revision: 4},
+ Created: false,
+ Events: []*mvccpb.Event{
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 4, Version: 3},
+ },
+ },
+ },
+ },
+ },
+ // multiple puts, one watcher with matching prefix
+ {
+ []string{"foo", "foo", "foo"},
+ &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("foo"),
+ RangeEnd: []byte("fop")}}},
+
+ []*pb.WatchResponse{
+ {
+ Header: &pb.ResponseHeader{Revision: 2},
+ Created: false,
+ Events: []*mvccpb.Event{
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1},
+ },
+ },
+ },
+ {
+ Header: &pb.ResponseHeader{Revision: 3},
+ Created: false,
+ Events: []*mvccpb.Event{
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 3, Version: 2},
+ },
+ },
+ },
+ {
+ Header: &pb.ResponseHeader{Revision: 4},
+ Created: false,
+ Events: []*mvccpb.Event{
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 4, Version: 3},
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+
+ wAPI := toGRPC(clus.RandClient()).Watch
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ wStream, err := wAPI.Watch(ctx)
+ if err != nil {
+ t.Fatalf("#%d: wAPI.Watch error: %v", i, err)
+ }
+
+ err = wStream.Send(tt.watchRequest)
+ if err != nil {
+ t.Fatalf("#%d: wStream.Send error: %v", i, err)
+ }
+
+ // ensure watcher request created a new watcher
+ cresp, err := wStream.Recv()
+ if err != nil {
+ t.Errorf("#%d: wStream.Recv error: %v", i, err)
+ continue
+ }
+ if !cresp.Created {
+ t.Errorf("#%d: did not create watchid, got %+v", i, cresp)
+ continue
+ }
+ if cresp.Canceled {
+ t.Errorf("#%d: canceled watcher on create %+v", i, cresp)
+ continue
+ }
+
+ createdWatchId := cresp.WatchId
+ if cresp.Header == nil || cresp.Header.Revision != 1 {
+ t.Errorf("#%d: header revision got +%v, wanted revison 1", i, cresp)
+ continue
+ }
+
+ // asynchronously create keys
+ go func() {
+ for _, k := range tt.putKeys {
+ kvc := toGRPC(clus.RandClient()).KV
+ req := &pb.PutRequest{Key: []byte(k), Value: []byte("bar")}
+ if _, err := kvc.Put(context.TODO(), req); err != nil {
+ t.Fatalf("#%d: couldn't put key (%v)", i, err)
+ }
+ }
+ }()
+
+ // check stream results
+ for j, wresp := range tt.wresps {
+ resp, err := wStream.Recv()
+ if err != nil {
+ t.Errorf("#%d.%d: wStream.Recv error: %v", i, j, err)
+ }
+
+ if resp.Header == nil {
+ t.Fatalf("#%d.%d: unexpected nil resp.Header", i, j)
+ }
+ if resp.Header.Revision != wresp.Header.Revision {
+ t.Errorf("#%d.%d: resp.Header.Revision got = %d, want = %d", i, j, resp.Header.Revision, wresp.Header.Revision)
+ }
+
+ if wresp.Created != resp.Created {
+ t.Errorf("#%d.%d: resp.Created got = %v, want = %v", i, j, resp.Created, wresp.Created)
+ }
+ if resp.WatchId != createdWatchId {
+ t.Errorf("#%d.%d: resp.WatchId got = %d, want = %d", i, j, resp.WatchId, createdWatchId)
+ }
+
+ if !reflect.DeepEqual(resp.Events, wresp.Events) {
+ t.Errorf("#%d.%d: resp.Events got = %+v, want = %+v", i, j, resp.Events, wresp.Events)
+ }
+ }
+
+ rok, nr := waitResponse(wStream, 1*time.Second)
+ if !rok {
+ t.Errorf("unexpected pb.WatchResponse is received %+v", nr)
+ }
+
+ // can't defer because tcp ports will be in use
+ clus.Terminate(t)
+ }
+}
+
+// TestV3WatchFutureRevision tests Watch APIs from a future revision.
+func TestV3WatchFutureRevision(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ wAPI := toGRPC(clus.RandClient()).Watch
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ wStream, err := wAPI.Watch(ctx)
+ if err != nil {
+ t.Fatalf("wAPI.Watch error: %v", err)
+ }
+
+ wkey := []byte("foo")
+ wrev := int64(10)
+ req := &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{Key: wkey, StartRevision: wrev}}}
+ err = wStream.Send(req)
+ if err != nil {
+ t.Fatalf("wStream.Send error: %v", err)
+ }
+
+ // ensure watcher request created a new watcher
+ cresp, err := wStream.Recv()
+ if err != nil {
+ t.Fatalf("wStream.Recv error: %v", err)
+ }
+ if !cresp.Created {
+ t.Fatalf("create %v, want %v", cresp.Created, true)
+ }
+
+ kvc := toGRPC(clus.RandClient()).KV
+ for {
+ req := &pb.PutRequest{Key: wkey, Value: []byte("bar")}
+ resp, rerr := kvc.Put(context.TODO(), req)
+ if rerr != nil {
+ t.Fatalf("couldn't put key (%v)", rerr)
+ }
+ if resp.Header.Revision == wrev {
+ break
+ }
+ }
+
+ // ensure watcher request created a new watcher
+ cresp, err = wStream.Recv()
+ if err != nil {
+ t.Fatalf("wStream.Recv error: %v", err)
+ }
+ if cresp.Header.Revision != wrev {
+ t.Fatalf("revision = %d, want %d", cresp.Header.Revision, wrev)
+ }
+ if len(cresp.Events) != 1 {
+ t.Fatalf("failed to receive events")
+ }
+ if cresp.Events[0].Kv.ModRevision != wrev {
+ t.Errorf("mod revision = %d, want %d", cresp.Events[0].Kv.ModRevision, wrev)
+ }
+}
+
+// TestV3WatchWrongRange tests wrong range does not create watchers.
+func TestV3WatchWrongRange(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ wAPI := toGRPC(clus.RandClient()).Watch
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ wStream, err := wAPI.Watch(ctx)
+ if err != nil {
+ t.Fatalf("wAPI.Watch error: %v", err)
+ }
+
+ tests := []struct {
+ key []byte
+ end []byte
+ canceled bool
+ }{
+ {[]byte("a"), []byte("a"), true}, // wrong range end
+ {[]byte("b"), []byte("a"), true}, // wrong range end
+ {[]byte("foo"), []byte{0}, false}, // watch request with 'WithFromKey'
+ }
+ for i, tt := range tests {
+ if err := wStream.Send(&pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{Key: tt.key, RangeEnd: tt.end, StartRevision: 1}}}); err != nil {
+ t.Fatalf("#%d: wStream.Send error: %v", i, err)
+ }
+ cresp, err := wStream.Recv()
+ if err != nil {
+ t.Fatalf("#%d: wStream.Recv error: %v", i, err)
+ }
+ if !cresp.Created {
+ t.Fatalf("#%d: create %v, want %v", i, cresp.Created, true)
+ }
+ if cresp.Canceled != tt.canceled {
+ t.Fatalf("#%d: canceled %v, want %v", i, tt.canceled, cresp.Canceled)
+ }
+ if tt.canceled && cresp.WatchId != -1 {
+ t.Fatalf("#%d: canceled watch ID %d, want -1", i, cresp.WatchId)
+ }
+ }
+}
+
+// TestV3WatchCancelSynced tests Watch APIs cancellation from synced map.
+func TestV3WatchCancelSynced(t *testing.T) {
+ defer testutil.AfterTest(t)
+ testV3WatchCancel(t, 0)
+}
+
+// TestV3WatchCancelUnsynced tests Watch APIs cancellation from unsynced map.
+func TestV3WatchCancelUnsynced(t *testing.T) {
+ defer testutil.AfterTest(t)
+ testV3WatchCancel(t, 1)
+}
+
+func testV3WatchCancel(t *testing.T, startRev int64) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ wStream, errW := toGRPC(clus.RandClient()).Watch.Watch(ctx)
+ if errW != nil {
+ t.Fatalf("wAPI.Watch error: %v", errW)
+ }
+
+ wreq := &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("foo"), StartRevision: startRev}}}
+ if err := wStream.Send(wreq); err != nil {
+ t.Fatalf("wStream.Send error: %v", err)
+ }
+
+ wresp, errR := wStream.Recv()
+ if errR != nil {
+ t.Errorf("wStream.Recv error: %v", errR)
+ }
+ if !wresp.Created {
+ t.Errorf("wresp.Created got = %v, want = true", wresp.Created)
+ }
+
+ creq := &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CancelRequest{
+ CancelRequest: &pb.WatchCancelRequest{
+ WatchId: wresp.WatchId}}}
+ if err := wStream.Send(creq); err != nil {
+ t.Fatalf("wStream.Send error: %v", err)
+ }
+
+ cresp, err := wStream.Recv()
+ if err != nil {
+ t.Errorf("wStream.Recv error: %v", err)
+ }
+ if !cresp.Canceled {
+ t.Errorf("cresp.Canceled got = %v, want = true", cresp.Canceled)
+ }
+
+ kvc := toGRPC(clus.RandClient()).KV
+ if _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}); err != nil {
+ t.Errorf("couldn't put key (%v)", err)
+ }
+
+ // watch got canceled, so this should block
+ rok, nr := waitResponse(wStream, 1*time.Second)
+ if !rok {
+ t.Errorf("unexpected pb.WatchResponse is received %+v", nr)
+ }
+}
+
+// TestV3WatchCurrentPutOverlap ensures current watchers receive all events with
+// overlapping puts.
+func TestV3WatchCurrentPutOverlap(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ wStream, wErr := toGRPC(clus.RandClient()).Watch.Watch(ctx)
+ if wErr != nil {
+ t.Fatalf("wAPI.Watch error: %v", wErr)
+ }
+
+ // last mod_revision that will be observed
+ nrRevisions := 32
+ // first revision already allocated as empty revision
+ for i := 1; i < nrRevisions; i++ {
+ go func() {
+ kvc := toGRPC(clus.RandClient()).KV
+ req := &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}
+ if _, err := kvc.Put(context.TODO(), req); err != nil {
+ t.Fatalf("couldn't put key (%v)", err)
+ }
+ }()
+ }
+
+ // maps watcher to current expected revision
+ progress := make(map[int64]int64)
+
+ wreq := &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{Key: []byte("foo"), RangeEnd: []byte("fop")}}}
+ if err := wStream.Send(wreq); err != nil {
+ t.Fatalf("first watch request failed (%v)", err)
+ }
+
+ more := true
+ progress[-1] = 0 // watcher creation pending
+ for more {
+ resp, err := wStream.Recv()
+ if err != nil {
+ t.Fatalf("wStream.Recv error: %v", err)
+ }
+
+ if resp.Created {
+ // accept events > header revision
+ progress[resp.WatchId] = resp.Header.Revision + 1
+ if resp.Header.Revision == int64(nrRevisions) {
+ // covered all revisions; create no more watchers
+ progress[-1] = int64(nrRevisions) + 1
+ } else if err := wStream.Send(wreq); err != nil {
+ t.Fatalf("watch request failed (%v)", err)
+ }
+ } else if len(resp.Events) == 0 {
+ t.Fatalf("got events %v, want non-empty", resp.Events)
+ } else {
+ wRev, ok := progress[resp.WatchId]
+ if !ok {
+ t.Fatalf("got %+v, but watch id shouldn't exist ", resp)
+ }
+ if resp.Events[0].Kv.ModRevision != wRev {
+ t.Fatalf("got %+v, wanted first revision %d", resp, wRev)
+ }
+ lastRev := resp.Events[len(resp.Events)-1].Kv.ModRevision
+ progress[resp.WatchId] = lastRev + 1
+ }
+ more = false
+ for _, v := range progress {
+ if v <= int64(nrRevisions) {
+ more = true
+ break
+ }
+ }
+ }
+
+ if rok, nr := waitResponse(wStream, time.Second); !rok {
+ t.Errorf("unexpected pb.WatchResponse is received %+v", nr)
+ }
+}
+
+// TestV3WatchEmptyKey ensures synced watchers see empty key PUTs as PUT events
+func TestV3WatchEmptyKey(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+
+ ws, werr := toGRPC(clus.RandClient()).Watch.Watch(ctx)
+ if werr != nil {
+ t.Fatal(werr)
+ }
+ req := &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("foo")}}}
+ if err := ws.Send(req); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := ws.Recv(); err != nil {
+ t.Fatal(err)
+ }
+
+ // put a key with empty value
+ kvc := toGRPC(clus.RandClient()).KV
+ preq := &pb.PutRequest{Key: []byte("foo")}
+ if _, err := kvc.Put(context.TODO(), preq); err != nil {
+ t.Fatal(err)
+ }
+
+ // check received PUT
+ resp, rerr := ws.Recv()
+ if rerr != nil {
+ t.Fatal(rerr)
+ }
+ wevs := []*mvccpb.Event{
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo"), CreateRevision: 2, ModRevision: 2, Version: 1},
+ },
+ }
+ if !reflect.DeepEqual(resp.Events, wevs) {
+ t.Fatalf("got %v, expected %v", resp.Events, wevs)
+ }
+}
+
+func TestV3WatchMultipleWatchersSynced(t *testing.T) {
+ defer testutil.AfterTest(t)
+ testV3WatchMultipleWatchers(t, 0)
+}
+
+func TestV3WatchMultipleWatchersUnsynced(t *testing.T) {
+ defer testutil.AfterTest(t)
+ testV3WatchMultipleWatchers(t, 1)
+}
+
+// testV3WatchMultipleWatchers tests multiple watchers on the same key
+// and one watcher with matching prefix. It first puts the key
+// that matches all watchers, and another key that matches only
+// one watcher to test if it receives expected events.
+func testV3WatchMultipleWatchers(t *testing.T, startRev int64) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.RandClient()).KV
+
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ wStream, errW := toGRPC(clus.RandClient()).Watch.Watch(ctx)
+ if errW != nil {
+ t.Fatalf("wAPI.Watch error: %v", errW)
+ }
+
+ watchKeyN := 4
+ for i := 0; i < watchKeyN+1; i++ {
+ var wreq *pb.WatchRequest
+ if i < watchKeyN {
+ wreq = &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("foo"), StartRevision: startRev}}}
+ } else {
+ wreq = &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("fo"), RangeEnd: []byte("fp"), StartRevision: startRev}}}
+ }
+ if err := wStream.Send(wreq); err != nil {
+ t.Fatalf("wStream.Send error: %v", err)
+ }
+ }
+
+ ids := make(map[int64]struct{})
+ for i := 0; i < watchKeyN+1; i++ {
+ wresp, err := wStream.Recv()
+ if err != nil {
+ t.Fatalf("wStream.Recv error: %v", err)
+ }
+ if !wresp.Created {
+ t.Fatalf("wresp.Created got = %v, want = true", wresp.Created)
+ }
+ ids[wresp.WatchId] = struct{}{}
+ }
+
+ if _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}); err != nil {
+ t.Fatalf("couldn't put key (%v)", err)
+ }
+
+ for i := 0; i < watchKeyN+1; i++ {
+ wresp, err := wStream.Recv()
+ if err != nil {
+ t.Fatalf("wStream.Recv error: %v", err)
+ }
+ if _, ok := ids[wresp.WatchId]; !ok {
+ t.Errorf("watchId %d is not created!", wresp.WatchId)
+ } else {
+ delete(ids, wresp.WatchId)
+ }
+ if len(wresp.Events) == 0 {
+ t.Errorf("#%d: no events received", i)
+ }
+ for _, ev := range wresp.Events {
+ if string(ev.Kv.Key) != "foo" {
+ t.Errorf("ev.Kv.Key got = %s, want = foo", ev.Kv.Key)
+ }
+ if string(ev.Kv.Value) != "bar" {
+ t.Errorf("ev.Kv.Value got = %s, want = bar", ev.Kv.Value)
+ }
+ }
+ }
+
+ // now put one key that has only one matching watcher
+ if _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte("fo"), Value: []byte("bar")}); err != nil {
+ t.Fatalf("couldn't put key (%v)", err)
+ }
+ wresp, err := wStream.Recv()
+ if err != nil {
+ t.Errorf("wStream.Recv error: %v", err)
+ }
+ if len(wresp.Events) != 1 {
+ t.Fatalf("len(wresp.Events) got = %d, want = 1", len(wresp.Events))
+ }
+ if string(wresp.Events[0].Kv.Key) != "fo" {
+ t.Errorf("wresp.Events[0].Kv.Key got = %s, want = fo", wresp.Events[0].Kv.Key)
+ }
+
+ // now Recv should block because there is no more events coming
+ rok, nr := waitResponse(wStream, 1*time.Second)
+ if !rok {
+ t.Errorf("unexpected pb.WatchResponse is received %+v", nr)
+ }
+}
+
+func TestV3WatchMultipleEventsTxnSynced(t *testing.T) {
+ defer testutil.AfterTest(t)
+ testV3WatchMultipleEventsTxn(t, 0)
+}
+
+func TestV3WatchMultipleEventsTxnUnsynced(t *testing.T) {
+ defer testutil.AfterTest(t)
+ testV3WatchMultipleEventsTxn(t, 1)
+}
+
+// testV3WatchMultipleEventsTxn tests Watch APIs when it receives multiple events.
+func testV3WatchMultipleEventsTxn(t *testing.T, startRev int64) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ wStream, wErr := toGRPC(clus.RandClient()).Watch.Watch(ctx)
+ if wErr != nil {
+ t.Fatalf("wAPI.Watch error: %v", wErr)
+ }
+
+ wreq := &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("foo"), RangeEnd: []byte("fop"), StartRevision: startRev}}}
+ if err := wStream.Send(wreq); err != nil {
+ t.Fatalf("wStream.Send error: %v", err)
+ }
+ if resp, err := wStream.Recv(); err != nil || !resp.Created {
+ t.Fatalf("create response failed: resp=%v, err=%v", resp, err)
+ }
+
+ kvc := toGRPC(clus.RandClient()).KV
+ txn := pb.TxnRequest{}
+ for i := 0; i < 3; i++ {
+ ru := &pb.RequestOp{}
+ ru.Request = &pb.RequestOp_RequestPut{
+ RequestPut: &pb.PutRequest{
+ Key: []byte(fmt.Sprintf("foo%d", i)), Value: []byte("bar")}}
+ txn.Success = append(txn.Success, ru)
+ }
+
+ tresp, err := kvc.Txn(context.Background(), &txn)
+ if err != nil {
+ t.Fatalf("kvc.Txn error: %v", err)
+ }
+ if !tresp.Succeeded {
+ t.Fatalf("kvc.Txn failed: %+v", tresp)
+ }
+
+ events := []*mvccpb.Event{}
+ for len(events) < 3 {
+ resp, err := wStream.Recv()
+ if err != nil {
+ t.Errorf("wStream.Recv error: %v", err)
+ }
+ events = append(events, resp.Events...)
+ }
+ sort.Sort(eventsSortByKey(events))
+
+ wevents := []*mvccpb.Event{
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo0"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1},
+ },
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo1"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1},
+ },
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo2"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1},
+ },
+ }
+
+ if !reflect.DeepEqual(events, wevents) {
+ t.Errorf("events got = %+v, want = %+v", events, wevents)
+ }
+
+ rok, nr := waitResponse(wStream, 1*time.Second)
+ if !rok {
+ t.Errorf("unexpected pb.WatchResponse is received %+v", nr)
+ }
+}
+
+type eventsSortByKey []*mvccpb.Event
+
+func (evs eventsSortByKey) Len() int { return len(evs) }
+func (evs eventsSortByKey) Swap(i, j int) { evs[i], evs[j] = evs[j], evs[i] }
+func (evs eventsSortByKey) Less(i, j int) bool { return bytes.Compare(evs[i].Kv.Key, evs[j].Kv.Key) < 0 }
+
+func TestV3WatchMultipleEventsPutUnsynced(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ kvc := toGRPC(clus.RandClient()).KV
+
+ if _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte("foo0"), Value: []byte("bar")}); err != nil {
+ t.Fatalf("couldn't put key (%v)", err)
+ }
+ if _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte("foo1"), Value: []byte("bar")}); err != nil {
+ t.Fatalf("couldn't put key (%v)", err)
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ wStream, wErr := toGRPC(clus.RandClient()).Watch.Watch(ctx)
+ if wErr != nil {
+ t.Fatalf("wAPI.Watch error: %v", wErr)
+ }
+
+ wreq := &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("foo"), RangeEnd: []byte("fop"), StartRevision: 1}}}
+ if err := wStream.Send(wreq); err != nil {
+ t.Fatalf("wStream.Send error: %v", err)
+ }
+
+ if _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte("foo0"), Value: []byte("bar")}); err != nil {
+ t.Fatalf("couldn't put key (%v)", err)
+ }
+ if _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte("foo1"), Value: []byte("bar")}); err != nil {
+ t.Fatalf("couldn't put key (%v)", err)
+ }
+
+ allWevents := []*mvccpb.Event{
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo0"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1},
+ },
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo1"), Value: []byte("bar"), CreateRevision: 3, ModRevision: 3, Version: 1},
+ },
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo0"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 4, Version: 2},
+ },
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo1"), Value: []byte("bar"), CreateRevision: 3, ModRevision: 5, Version: 2},
+ },
+ }
+
+ events := []*mvccpb.Event{}
+ for len(events) < 4 {
+ resp, err := wStream.Recv()
+ if err != nil {
+ t.Errorf("wStream.Recv error: %v", err)
+ }
+ if resp.Created {
+ continue
+ }
+ events = append(events, resp.Events...)
+ // if PUT requests are committed by now, first receive would return
+ // multiple events, but if not, it returns a single event. In SSD,
+ // it should return 4 events at once.
+ }
+
+ if !reflect.DeepEqual(events, allWevents) {
+ t.Errorf("events got = %+v, want = %+v", events, allWevents)
+ }
+
+ rok, nr := waitResponse(wStream, 1*time.Second)
+ if !rok {
+ t.Errorf("unexpected pb.WatchResponse is received %+v", nr)
+ }
+}
+
+func TestV3WatchMultipleStreamsSynced(t *testing.T) {
+ defer testutil.AfterTest(t)
+ testV3WatchMultipleStreams(t, 0)
+}
+
+func TestV3WatchMultipleStreamsUnsynced(t *testing.T) {
+ defer testutil.AfterTest(t)
+ testV3WatchMultipleStreams(t, 1)
+}
+
+// testV3WatchMultipleStreams tests multiple watchers on the same key on multiple streams.
+func testV3WatchMultipleStreams(t *testing.T, startRev int64) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ wAPI := toGRPC(clus.RandClient()).Watch
+ kvc := toGRPC(clus.RandClient()).KV
+
+ streams := make([]pb.Watch_WatchClient, 5)
+ for i := range streams {
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ wStream, errW := wAPI.Watch(ctx)
+ if errW != nil {
+ t.Fatalf("wAPI.Watch error: %v", errW)
+ }
+ wreq := &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("foo"), StartRevision: startRev}}}
+ if err := wStream.Send(wreq); err != nil {
+ t.Fatalf("wStream.Send error: %v", err)
+ }
+ streams[i] = wStream
+ }
+
+ for _, wStream := range streams {
+ wresp, err := wStream.Recv()
+ if err != nil {
+ t.Fatalf("wStream.Recv error: %v", err)
+ }
+ if !wresp.Created {
+ t.Fatalf("wresp.Created got = %v, want = true", wresp.Created)
+ }
+ }
+
+ if _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}); err != nil {
+ t.Fatalf("couldn't put key (%v)", err)
+ }
+
+ var wg sync.WaitGroup
+ wg.Add(len(streams))
+ wevents := []*mvccpb.Event{
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1},
+ },
+ }
+ for i := range streams {
+ go func(i int) {
+ defer wg.Done()
+ wStream := streams[i]
+ wresp, err := wStream.Recv()
+ if err != nil {
+ t.Fatalf("wStream.Recv error: %v", err)
+ }
+ if wresp.WatchId != 0 {
+ t.Errorf("watchId got = %d, want = 0", wresp.WatchId)
+ }
+ if !reflect.DeepEqual(wresp.Events, wevents) {
+ t.Errorf("wresp.Events got = %+v, want = %+v", wresp.Events, wevents)
+ }
+ // now Recv should block because there is no more events coming
+ rok, nr := waitResponse(wStream, 1*time.Second)
+ if !rok {
+ t.Errorf("unexpected pb.WatchResponse is received %+v", nr)
+ }
+ }(i)
+ }
+ wg.Wait()
+}
+
+// waitResponse waits on the given stream for given duration.
+// If there is no more events, true and a nil response will be
+// returned closing the WatchClient stream. Or the response will
+// be returned.
+func waitResponse(wc pb.Watch_WatchClient, timeout time.Duration) (bool, *pb.WatchResponse) {
+ rCh := make(chan *pb.WatchResponse, 1)
+ donec := make(chan struct{})
+ defer close(donec)
+ go func() {
+ resp, _ := wc.Recv()
+ select {
+ case rCh <- resp:
+ case <-donec:
+ }
+ }()
+ select {
+ case nr := <-rCh:
+ return false, nr
+ case <-time.After(timeout):
+ }
+ // didn't get response
+ wc.CloseSend()
+ return true, nil
+}
+
+func TestWatchWithProgressNotify(t *testing.T) {
+ // accelerate report interval so test terminates quickly
+ oldpi := v3rpc.GetProgressReportInterval()
+ // using atomics to avoid race warnings
+ v3rpc.SetProgressReportInterval(3 * time.Second)
+ testInterval := 3 * time.Second
+ defer func() { v3rpc.SetProgressReportInterval(oldpi) }()
+
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 3})
+ defer clus.Terminate(t)
+
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ wStream, wErr := toGRPC(clus.RandClient()).Watch.Watch(ctx)
+ if wErr != nil {
+ t.Fatalf("wAPI.Watch error: %v", wErr)
+ }
+
+ // create two watchers, one with progressNotify set.
+ wreq := &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{Key: []byte("foo"), StartRevision: 1, ProgressNotify: true}}}
+ if err := wStream.Send(wreq); err != nil {
+ t.Fatalf("watch request failed (%v)", err)
+ }
+ wreq = &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{Key: []byte("foo"), StartRevision: 1}}}
+ if err := wStream.Send(wreq); err != nil {
+ t.Fatalf("watch request failed (%v)", err)
+ }
+
+ // two creation + one notification
+ for i := 0; i < 3; i++ {
+ rok, resp := waitResponse(wStream, testInterval+time.Second)
+ if resp.Created {
+ continue
+ }
+
+ if rok {
+ t.Errorf("failed to receive response from watch stream")
+ }
+ if resp.Header.Revision != 1 {
+ t.Errorf("revision = %d, want 1", resp.Header.Revision)
+ }
+ if len(resp.Events) != 0 {
+ t.Errorf("len(resp.Events) = %d, want 0", len(resp.Events))
+ }
+ }
+
+ // no more notification
+ rok, resp := waitResponse(wStream, time.Second)
+ if !rok {
+ t.Errorf("unexpected pb.WatchResponse is received %+v", resp)
+ }
+}
+
+// TestV3WatcMultiOpenhClose opens many watchers concurrently on multiple streams.
+func TestV3WatchClose(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ c := clus.Client(0)
+ wapi := toGRPC(c).Watch
+
+ var wg sync.WaitGroup
+ wg.Add(100)
+ for i := 0; i < 100; i++ {
+ go func() {
+ ctx, cancel := context.WithCancel(context.TODO())
+ defer func() {
+ wg.Done()
+ cancel()
+ }()
+ ws, err := wapi.Watch(ctx)
+ if err != nil {
+ return
+ }
+ cr := &pb.WatchCreateRequest{Key: []byte("a")}
+ req := &pb.WatchRequest{
+ RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: cr}}
+ ws.Send(req)
+ ws.Recv()
+ }()
+ }
+
+ clus.Members[0].DropConnections()
+ wg.Wait()
+}
+
+// TestV3WatchWithFilter ensures watcher filters out the events correctly.
+func TestV3WatchWithFilter(t *testing.T) {
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+
+ ws, werr := toGRPC(clus.RandClient()).Watch.Watch(ctx)
+ if werr != nil {
+ t.Fatal(werr)
+ }
+ req := &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte("foo"),
+ Filters: []pb.WatchCreateRequest_FilterType{pb.WatchCreateRequest_NOPUT},
+ }}}
+ if err := ws.Send(req); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := ws.Recv(); err != nil {
+ t.Fatal(err)
+ }
+
+ recv := make(chan *pb.WatchResponse)
+ go func() {
+ // check received PUT
+ resp, rerr := ws.Recv()
+ if rerr != nil {
+ t.Fatal(rerr)
+ }
+ recv <- resp
+ }()
+
+ // put a key with empty value
+ kvc := toGRPC(clus.RandClient()).KV
+ preq := &pb.PutRequest{Key: []byte("foo")}
+ if _, err := kvc.Put(context.TODO(), preq); err != nil {
+ t.Fatal(err)
+ }
+
+ select {
+ case <-recv:
+ t.Fatal("failed to filter out put event")
+ case <-time.After(100 * time.Millisecond):
+ }
+
+ dreq := &pb.DeleteRangeRequest{Key: []byte("foo")}
+ if _, err := kvc.DeleteRange(context.TODO(), dreq); err != nil {
+ t.Fatal(err)
+ }
+
+ select {
+ case resp := <-recv:
+ wevs := []*mvccpb.Event{
+ {
+ Type: mvccpb.DELETE,
+ Kv: &mvccpb.KeyValue{Key: []byte("foo"), ModRevision: 3},
+ },
+ }
+ if !reflect.DeepEqual(resp.Events, wevs) {
+ t.Fatalf("got %v, expected %v", resp.Events, wevs)
+ }
+ case <-time.After(100 * time.Millisecond):
+ t.Fatal("failed to receive delete event")
+ }
+}
+
+func TestV3WatchWithPrevKV(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ wctx, wcancel := context.WithCancel(context.Background())
+ defer wcancel()
+
+ tests := []struct {
+ key string
+ end string
+ vals []string
+ }{{
+ key: "foo",
+ end: "fop",
+ vals: []string{"bar1", "bar2"},
+ }, {
+ key: "/abc",
+ end: "/abd",
+ vals: []string{"first", "second"},
+ }}
+ for i, tt := range tests {
+ kvc := toGRPC(clus.RandClient()).KV
+ if _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte(tt.key), Value: []byte(tt.vals[0])}); err != nil {
+ t.Fatal(err)
+ }
+
+ ws, werr := toGRPC(clus.RandClient()).Watch.Watch(wctx)
+ if werr != nil {
+ t.Fatal(werr)
+ }
+
+ req := &pb.WatchRequest{RequestUnion: &pb.WatchRequest_CreateRequest{
+ CreateRequest: &pb.WatchCreateRequest{
+ Key: []byte(tt.key),
+ RangeEnd: []byte(tt.end),
+ PrevKv: true,
+ }}}
+ if err := ws.Send(req); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := ws.Recv(); err != nil {
+ t.Fatal(err)
+ }
+
+ if _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte(tt.key), Value: []byte(tt.vals[1])}); err != nil {
+ t.Fatal(err)
+ }
+
+ recv := make(chan *pb.WatchResponse)
+ go func() {
+ // check received PUT
+ resp, rerr := ws.Recv()
+ if rerr != nil {
+ t.Fatal(rerr)
+ }
+ recv <- resp
+ }()
+
+ select {
+ case resp := <-recv:
+ if tt.vals[1] != string(resp.Events[0].Kv.Value) {
+ t.Errorf("#%d: unequal value: want=%s, get=%s", i, tt.vals[1], resp.Events[0].Kv.Value)
+ }
+ if tt.vals[0] != string(resp.Events[0].PrevKv.Value) {
+ t.Errorf("#%d: unequal value: want=%s, get=%s", i, tt.vals[0], resp.Events[0].PrevKv.Value)
+ }
+ case <-time.After(30 * time.Second):
+ t.Error("timeout waiting for watch response")
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/integration/v3election_grpc_test.go b/vendor/github.com/coreos/etcd/integration/v3election_grpc_test.go
new file mode 100644
index 00000000..be320286
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/v3election_grpc_test.go
@@ -0,0 +1,177 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "fmt"
+ "testing"
+ "time"
+
+ epb "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/testutil"
+ "golang.org/x/net/context"
+)
+
+// TestV3ElectionCampaign checks that Campaign will not give
+// simultaneous leadership to multiple campaigners.
+func TestV3ElectionCampaign(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ lease1, err1 := toGRPC(clus.RandClient()).Lease.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: 30})
+ if err1 != nil {
+ t.Fatal(err1)
+ }
+ lease2, err2 := toGRPC(clus.RandClient()).Lease.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: 30})
+ if err2 != nil {
+ t.Fatal(err2)
+ }
+
+ lc := toGRPC(clus.Client(0)).Election
+ req1 := &epb.CampaignRequest{Name: []byte("foo"), Lease: lease1.ID, Value: []byte("abc")}
+ l1, lerr1 := lc.Campaign(context.TODO(), req1)
+ if lerr1 != nil {
+ t.Fatal(lerr1)
+ }
+
+ campaignc := make(chan struct{})
+ go func() {
+ defer close(campaignc)
+ req2 := &epb.CampaignRequest{Name: []byte("foo"), Lease: lease2.ID, Value: []byte("def")}
+ l2, lerr2 := lc.Campaign(context.TODO(), req2)
+ if lerr2 != nil {
+ t.Fatal(lerr2)
+ }
+ if l1.Header.Revision >= l2.Header.Revision {
+ t.Fatalf("expected l1 revision < l2 revision, got %d >= %d", l1.Header.Revision, l2.Header.Revision)
+ }
+ }()
+
+ select {
+ case <-time.After(200 * time.Millisecond):
+ case <-campaignc:
+ t.Fatalf("got leadership before resign")
+ }
+
+ if _, uerr := lc.Resign(context.TODO(), &epb.ResignRequest{Leader: l1.Leader}); uerr != nil {
+ t.Fatal(uerr)
+ }
+
+ select {
+ case <-time.After(200 * time.Millisecond):
+ t.Fatalf("campaigner unelected after resign")
+ case <-campaignc:
+ }
+
+ lval, lverr := lc.Leader(context.TODO(), &epb.LeaderRequest{Name: []byte("foo")})
+ if lverr != nil {
+ t.Fatal(lverr)
+ }
+
+ if string(lval.Kv.Value) != "def" {
+ t.Fatalf("got election value %q, expected %q", string(lval.Kv.Value), "def")
+ }
+}
+
+// TestV3ElectionObserve checks that an Observe stream receives
+// proclamations from different leaders uninterrupted.
+func TestV3ElectionObserve(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ lc := toGRPC(clus.Client(0)).Election
+
+ // observe leadership events
+ observec := make(chan struct{})
+ go func() {
+ defer close(observec)
+ s, err := lc.Observe(context.Background(), &epb.LeaderRequest{Name: []byte("foo")})
+ observec <- struct{}{}
+ if err != nil {
+ t.Fatal(err)
+ }
+ for i := 0; i < 10; i++ {
+ resp, rerr := s.Recv()
+ if rerr != nil {
+ t.Fatal(rerr)
+ }
+ respV := 0
+ fmt.Sscanf(string(resp.Kv.Value), "%d", &respV)
+ // leader transitions should not go backwards
+ if respV < i {
+ t.Fatalf(`got observe value %q, expected >= "%d"`, string(resp.Kv.Value), i)
+ }
+ i = respV
+ }
+ }()
+
+ select {
+ case <-observec:
+ case <-time.After(time.Second):
+ t.Fatalf("observe stream took too long to start")
+ }
+
+ lease1, err1 := toGRPC(clus.RandClient()).Lease.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: 30})
+ if err1 != nil {
+ t.Fatal(err1)
+ }
+ c1, cerr1 := lc.Campaign(context.TODO(), &epb.CampaignRequest{Name: []byte("foo"), Lease: lease1.ID, Value: []byte("0")})
+ if cerr1 != nil {
+ t.Fatal(cerr1)
+ }
+
+ // overlap other leader so it waits on resign
+ leader2c := make(chan struct{})
+ go func() {
+ defer close(leader2c)
+
+ lease2, err2 := toGRPC(clus.RandClient()).Lease.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: 30})
+ if err2 != nil {
+ t.Fatal(err2)
+ }
+ c2, cerr2 := lc.Campaign(context.TODO(), &epb.CampaignRequest{Name: []byte("foo"), Lease: lease2.ID, Value: []byte("5")})
+ if cerr2 != nil {
+ t.Fatal(cerr2)
+ }
+ for i := 6; i < 10; i++ {
+ v := []byte(fmt.Sprintf("%d", i))
+ req := &epb.ProclaimRequest{Leader: c2.Leader, Value: v}
+ if _, err := lc.Proclaim(context.TODO(), req); err != nil {
+ t.Fatal(err)
+ }
+ }
+ }()
+
+ for i := 1; i < 5; i++ {
+ v := []byte(fmt.Sprintf("%d", i))
+ req := &epb.ProclaimRequest{Leader: c1.Leader, Value: v}
+ if _, err := lc.Proclaim(context.TODO(), req); err != nil {
+ t.Fatal(err)
+ }
+ }
+ // start second leader
+ lc.Resign(context.TODO(), &epb.ResignRequest{Leader: c1.Leader})
+
+ select {
+ case <-observec:
+ case <-time.After(time.Second):
+ t.Fatalf("observe did not observe all events in time")
+ }
+
+ <-leader2c
+}
diff --git a/vendor/github.com/coreos/etcd/integration/v3lock_grpc_test.go b/vendor/github.com/coreos/etcd/integration/v3lock_grpc_test.go
new file mode 100644
index 00000000..a66a8cf4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/integration/v3lock_grpc_test.go
@@ -0,0 +1,76 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 integration
+
+import (
+ "testing"
+ "time"
+
+ lockpb "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/testutil"
+ "golang.org/x/net/context"
+)
+
+// TestV3LockLockWaiter tests that a client will wait for a lock, then acquire it
+// once it is unlocked.
+func TestV3LockLockWaiter(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ lease1, err1 := toGRPC(clus.RandClient()).Lease.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: 30})
+ if err1 != nil {
+ t.Fatal(err1)
+ }
+ lease2, err2 := toGRPC(clus.RandClient()).Lease.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: 30})
+ if err2 != nil {
+ t.Fatal(err2)
+ }
+
+ lc := toGRPC(clus.Client(0)).Lock
+ l1, lerr1 := lc.Lock(context.TODO(), &lockpb.LockRequest{Name: []byte("foo"), Lease: lease1.ID})
+ if lerr1 != nil {
+ t.Fatal(lerr1)
+ }
+
+ lockc := make(chan struct{})
+ go func() {
+ l2, lerr2 := lc.Lock(context.TODO(), &lockpb.LockRequest{Name: []byte("foo"), Lease: lease2.ID})
+ if lerr2 != nil {
+ t.Fatal(lerr2)
+ }
+ if l1.Header.Revision >= l2.Header.Revision {
+ t.Fatalf("expected l1 revision < l2 revision, got %d >= %d", l1.Header.Revision, l2.Header.Revision)
+ }
+ close(lockc)
+ }()
+
+ select {
+ case <-time.After(200 * time.Millisecond):
+ case <-lockc:
+ t.Fatalf("locked before unlock")
+ }
+
+ if _, uerr := lc.Unlock(context.TODO(), &lockpb.UnlockRequest{Key: l1.Key}); uerr != nil {
+ t.Fatal(uerr)
+ }
+
+ select {
+ case <-time.After(200 * time.Millisecond):
+ t.Fatalf("waiter did not lock after unlock")
+ case <-lockc:
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/lease/doc.go b/vendor/github.com/coreos/etcd/lease/doc.go
new file mode 100644
index 00000000..73e7d0ec
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/lease/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 lease provides an interface and implemetation for time-limited leases over arbitrary resources.
+package lease
diff --git a/vendor/github.com/coreos/etcd/lease/leasehttp/doc.go b/vendor/github.com/coreos/etcd/lease/leasehttp/doc.go
new file mode 100644
index 00000000..8177a37b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/lease/leasehttp/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 leasehttp serves lease renewals made through HTTP requests.
+package leasehttp
diff --git a/vendor/github.com/coreos/etcd/lease/leasehttp/http.go b/vendor/github.com/coreos/etcd/lease/leasehttp/http.go
new file mode 100644
index 00000000..c3175cbb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/lease/leasehttp/http.go
@@ -0,0 +1,242 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 leasehttp
+
+import (
+ "bytes"
+ "context"
+ "errors"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "time"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/lease/leasepb"
+ "github.com/coreos/etcd/pkg/httputil"
+)
+
+var (
+ LeasePrefix = "/leases"
+ LeaseInternalPrefix = "/leases/internal"
+ applyTimeout = time.Second
+ ErrLeaseHTTPTimeout = errors.New("waiting for node to catch up its applied index has timed out")
+)
+
+// NewHandler returns an http Handler for lease renewals
+func NewHandler(l lease.Lessor, waitch func() <-chan struct{}) http.Handler {
+ return &leaseHandler{l, waitch}
+}
+
+type leaseHandler struct {
+ l lease.Lessor
+ waitch func() <-chan struct{}
+}
+
+func (h *leaseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ if r.Method != "POST" {
+ http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
+ return
+ }
+
+ b, err := ioutil.ReadAll(r.Body)
+ if err != nil {
+ http.Error(w, "error reading body", http.StatusBadRequest)
+ return
+ }
+
+ var v []byte
+ switch r.URL.Path {
+ case LeasePrefix:
+ lreq := pb.LeaseKeepAliveRequest{}
+ if err := lreq.Unmarshal(b); err != nil {
+ http.Error(w, "error unmarshalling request", http.StatusBadRequest)
+ return
+ }
+ select {
+ case <-h.waitch():
+ case <-time.After(applyTimeout):
+ http.Error(w, ErrLeaseHTTPTimeout.Error(), http.StatusRequestTimeout)
+ return
+ }
+ ttl, err := h.l.Renew(lease.LeaseID(lreq.ID))
+ if err != nil {
+ if err == lease.ErrLeaseNotFound {
+ http.Error(w, err.Error(), http.StatusNotFound)
+ return
+ }
+
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ return
+ }
+ // TODO: fill out ResponseHeader
+ resp := &pb.LeaseKeepAliveResponse{ID: lreq.ID, TTL: ttl}
+ v, err = resp.Marshal()
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ case LeaseInternalPrefix:
+ lreq := leasepb.LeaseInternalRequest{}
+ if err := lreq.Unmarshal(b); err != nil {
+ http.Error(w, "error unmarshalling request", http.StatusBadRequest)
+ return
+ }
+ select {
+ case <-h.waitch():
+ case <-time.After(applyTimeout):
+ http.Error(w, ErrLeaseHTTPTimeout.Error(), http.StatusRequestTimeout)
+ return
+ }
+ l := h.l.Lookup(lease.LeaseID(lreq.LeaseTimeToLiveRequest.ID))
+ if l == nil {
+ http.Error(w, lease.ErrLeaseNotFound.Error(), http.StatusNotFound)
+ return
+ }
+ // TODO: fill out ResponseHeader
+ resp := &leasepb.LeaseInternalResponse{
+ LeaseTimeToLiveResponse: &pb.LeaseTimeToLiveResponse{
+ Header: &pb.ResponseHeader{},
+ ID: lreq.LeaseTimeToLiveRequest.ID,
+ TTL: int64(l.Remaining().Seconds()),
+ GrantedTTL: l.TTL(),
+ },
+ }
+ if lreq.LeaseTimeToLiveRequest.Keys {
+ ks := l.Keys()
+ kbs := make([][]byte, len(ks))
+ for i := range ks {
+ kbs[i] = []byte(ks[i])
+ }
+ resp.LeaseTimeToLiveResponse.Keys = kbs
+ }
+
+ v, err = resp.Marshal()
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ default:
+ http.Error(w, fmt.Sprintf("unknown request path %q", r.URL.Path), http.StatusBadRequest)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/protobuf")
+ w.Write(v)
+}
+
+// RenewHTTP renews a lease at a given primary server.
+// TODO: Batch request in future?
+func RenewHTTP(ctx context.Context, id lease.LeaseID, url string, rt http.RoundTripper) (int64, error) {
+ // will post lreq protobuf to leader
+ lreq, err := (&pb.LeaseKeepAliveRequest{ID: int64(id)}).Marshal()
+ if err != nil {
+ return -1, err
+ }
+
+ cc := &http.Client{Transport: rt}
+ req, err := http.NewRequest("POST", url, bytes.NewReader(lreq))
+ if err != nil {
+ return -1, err
+ }
+ req.Header.Set("Content-Type", "application/protobuf")
+ req.Cancel = ctx.Done()
+
+ resp, err := cc.Do(req)
+ if err != nil {
+ return -1, err
+ }
+ b, err := readResponse(resp)
+ if err != nil {
+ return -1, err
+ }
+
+ if resp.StatusCode == http.StatusRequestTimeout {
+ return -1, ErrLeaseHTTPTimeout
+ }
+
+ if resp.StatusCode == http.StatusNotFound {
+ return -1, lease.ErrLeaseNotFound
+ }
+
+ if resp.StatusCode != http.StatusOK {
+ return -1, fmt.Errorf("lease: unknown error(%s)", string(b))
+ }
+
+ lresp := &pb.LeaseKeepAliveResponse{}
+ if err := lresp.Unmarshal(b); err != nil {
+ return -1, fmt.Errorf(`lease: %v. data = "%s"`, err, string(b))
+ }
+ if lresp.ID != int64(id) {
+ return -1, fmt.Errorf("lease: renew id mismatch")
+ }
+ return lresp.TTL, nil
+}
+
+// TimeToLiveHTTP retrieves lease information of the given lease ID.
+func TimeToLiveHTTP(ctx context.Context, id lease.LeaseID, keys bool, url string, rt http.RoundTripper) (*leasepb.LeaseInternalResponse, error) {
+ // will post lreq protobuf to leader
+ lreq, err := (&leasepb.LeaseInternalRequest{&pb.LeaseTimeToLiveRequest{ID: int64(id), Keys: keys}}).Marshal()
+ if err != nil {
+ return nil, err
+ }
+
+ req, err := http.NewRequest("POST", url, bytes.NewReader(lreq))
+ if err != nil {
+ return nil, err
+ }
+ req.Header.Set("Content-Type", "application/protobuf")
+
+ req = req.WithContext(ctx)
+
+ cc := &http.Client{Transport: rt}
+ var b []byte
+ // buffer errc channel so that errc don't block inside the go routinue
+ resp, err := cc.Do(req)
+ if err != nil {
+ return nil, err
+ }
+ b, err = readResponse(resp)
+ if err != nil {
+ return nil, err
+ }
+ if resp.StatusCode == http.StatusRequestTimeout {
+ return nil, ErrLeaseHTTPTimeout
+ }
+ if resp.StatusCode == http.StatusNotFound {
+ return nil, lease.ErrLeaseNotFound
+ }
+ if resp.StatusCode != http.StatusOK {
+ return nil, fmt.Errorf("lease: unknown error(%s)", string(b))
+ }
+
+ lresp := &leasepb.LeaseInternalResponse{}
+ if err := lresp.Unmarshal(b); err != nil {
+ return nil, fmt.Errorf(`lease: %v. data = "%s"`, err, string(b))
+ }
+ if lresp.LeaseTimeToLiveResponse.ID != int64(id) {
+ return nil, fmt.Errorf("lease: renew id mismatch")
+ }
+ return lresp, nil
+}
+
+func readResponse(resp *http.Response) (b []byte, err error) {
+ b, err = ioutil.ReadAll(resp.Body)
+ httputil.GracefulClose(resp)
+ return
+}
diff --git a/vendor/github.com/coreos/etcd/lease/leasehttp/http_test.go b/vendor/github.com/coreos/etcd/lease/leasehttp/http_test.go
new file mode 100644
index 00000000..41320810
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/lease/leasehttp/http_test.go
@@ -0,0 +1,127 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 leasehttp
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc/backend"
+
+ "golang.org/x/net/context"
+)
+
+func TestRenewHTTP(t *testing.T) {
+ be, tmpPath := backend.NewTmpBackend(time.Hour, 10000)
+ defer os.Remove(tmpPath)
+ defer be.Close()
+
+ le := lease.NewLessor(be, int64(5))
+ le.Promote(time.Second)
+ l, err := le.Grant(1, int64(5))
+ if err != nil {
+ t.Fatalf("failed to create lease: %v", err)
+ }
+
+ ts := httptest.NewServer(NewHandler(le, waitReady))
+ defer ts.Close()
+
+ ttl, err := RenewHTTP(context.TODO(), l.ID, ts.URL+LeasePrefix, http.DefaultTransport)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if ttl != 5 {
+ t.Fatalf("ttl expected 5, got %d", ttl)
+ }
+}
+
+func TestTimeToLiveHTTP(t *testing.T) {
+ be, tmpPath := backend.NewTmpBackend(time.Hour, 10000)
+ defer os.Remove(tmpPath)
+ defer be.Close()
+
+ le := lease.NewLessor(be, int64(5))
+ le.Promote(time.Second)
+ l, err := le.Grant(1, int64(5))
+ if err != nil {
+ t.Fatalf("failed to create lease: %v", err)
+ }
+
+ ts := httptest.NewServer(NewHandler(le, waitReady))
+ defer ts.Close()
+
+ resp, err := TimeToLiveHTTP(context.TODO(), l.ID, true, ts.URL+LeaseInternalPrefix, http.DefaultTransport)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if resp.LeaseTimeToLiveResponse.ID != 1 {
+ t.Fatalf("lease id expected 1, got %d", resp.LeaseTimeToLiveResponse.ID)
+ }
+ if resp.LeaseTimeToLiveResponse.GrantedTTL != 5 {
+ t.Fatalf("granted TTL expected 5, got %d", resp.LeaseTimeToLiveResponse.GrantedTTL)
+ }
+}
+
+func TestRenewHTTPTimeout(t *testing.T) {
+ testApplyTimeout(t, func(l *lease.Lease, serverURL string) error {
+ _, err := RenewHTTP(context.TODO(), l.ID, serverURL+LeasePrefix, http.DefaultTransport)
+ return err
+ })
+}
+
+func TestTimeToLiveHTTPTimeout(t *testing.T) {
+ testApplyTimeout(t, func(l *lease.Lease, serverURL string) error {
+ _, err := TimeToLiveHTTP(context.TODO(), l.ID, true, serverURL+LeaseInternalPrefix, http.DefaultTransport)
+ return err
+ })
+}
+
+func testApplyTimeout(t *testing.T, f func(*lease.Lease, string) error) {
+ be, tmpPath := backend.NewTmpBackend(time.Hour, 10000)
+ defer os.Remove(tmpPath)
+ defer be.Close()
+
+ le := lease.NewLessor(be, int64(5))
+ le.Promote(time.Second)
+ l, err := le.Grant(1, int64(5))
+ if err != nil {
+ t.Fatalf("failed to create lease: %v", err)
+ }
+
+ ts := httptest.NewServer(NewHandler(le, waitNotReady))
+ defer ts.Close()
+ err = f(l, ts.URL)
+ if err == nil {
+ t.Fatalf("expected timeout error, got nil")
+ }
+ if strings.Compare(err.Error(), ErrLeaseHTTPTimeout.Error()) != 0 {
+ t.Fatalf("expected (%v), got (%v)", ErrLeaseHTTPTimeout.Error(), err.Error())
+ }
+}
+
+func waitReady() <-chan struct{} {
+ ch := make(chan struct{})
+ close(ch)
+ return ch
+}
+
+func waitNotReady() <-chan struct{} {
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/lease/leasepb/lease.pb.go b/vendor/github.com/coreos/etcd/lease/leasepb/lease.pb.go
new file mode 100644
index 00000000..ec8db732
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/lease/leasepb/lease.pb.go
@@ -0,0 +1,608 @@
+// Code generated by protoc-gen-gogo.
+// source: lease.proto
+// DO NOT EDIT!
+
+/*
+ Package leasepb is a generated protocol buffer package.
+
+ It is generated from these files:
+ lease.proto
+
+ It has these top-level messages:
+ Lease
+ LeaseInternalRequest
+ LeaseInternalResponse
+*/
+package leasepb
+
+import (
+ "fmt"
+
+ proto "github.com/golang/protobuf/proto"
+
+ math "math"
+
+ etcdserverpb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+
+ io "io"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+type Lease struct {
+ ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
+ TTL int64 `protobuf:"varint,2,opt,name=TTL,proto3" json:"TTL,omitempty"`
+}
+
+func (m *Lease) Reset() { *m = Lease{} }
+func (m *Lease) String() string { return proto.CompactTextString(m) }
+func (*Lease) ProtoMessage() {}
+func (*Lease) Descriptor() ([]byte, []int) { return fileDescriptorLease, []int{0} }
+
+type LeaseInternalRequest struct {
+ LeaseTimeToLiveRequest *etcdserverpb.LeaseTimeToLiveRequest `protobuf:"bytes,1,opt,name=LeaseTimeToLiveRequest" json:"LeaseTimeToLiveRequest,omitempty"`
+}
+
+func (m *LeaseInternalRequest) Reset() { *m = LeaseInternalRequest{} }
+func (m *LeaseInternalRequest) String() string { return proto.CompactTextString(m) }
+func (*LeaseInternalRequest) ProtoMessage() {}
+func (*LeaseInternalRequest) Descriptor() ([]byte, []int) { return fileDescriptorLease, []int{1} }
+
+type LeaseInternalResponse struct {
+ LeaseTimeToLiveResponse *etcdserverpb.LeaseTimeToLiveResponse `protobuf:"bytes,1,opt,name=LeaseTimeToLiveResponse" json:"LeaseTimeToLiveResponse,omitempty"`
+}
+
+func (m *LeaseInternalResponse) Reset() { *m = LeaseInternalResponse{} }
+func (m *LeaseInternalResponse) String() string { return proto.CompactTextString(m) }
+func (*LeaseInternalResponse) ProtoMessage() {}
+func (*LeaseInternalResponse) Descriptor() ([]byte, []int) { return fileDescriptorLease, []int{2} }
+
+func init() {
+ proto.RegisterType((*Lease)(nil), "leasepb.Lease")
+ proto.RegisterType((*LeaseInternalRequest)(nil), "leasepb.LeaseInternalRequest")
+ proto.RegisterType((*LeaseInternalResponse)(nil), "leasepb.LeaseInternalResponse")
+}
+func (m *Lease) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *Lease) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.ID != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintLease(dAtA, i, uint64(m.ID))
+ }
+ if m.TTL != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintLease(dAtA, i, uint64(m.TTL))
+ }
+ return i, nil
+}
+
+func (m *LeaseInternalRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LeaseInternalRequest) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.LeaseTimeToLiveRequest != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintLease(dAtA, i, uint64(m.LeaseTimeToLiveRequest.Size()))
+ n1, err := m.LeaseTimeToLiveRequest.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n1
+ }
+ return i, nil
+}
+
+func (m *LeaseInternalResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *LeaseInternalResponse) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.LeaseTimeToLiveResponse != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintLease(dAtA, i, uint64(m.LeaseTimeToLiveResponse.Size()))
+ n2, err := m.LeaseTimeToLiveResponse.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n2
+ }
+ return i, nil
+}
+
+func encodeFixed64Lease(dAtA []byte, offset int, v uint64) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ dAtA[offset+4] = uint8(v >> 32)
+ dAtA[offset+5] = uint8(v >> 40)
+ dAtA[offset+6] = uint8(v >> 48)
+ dAtA[offset+7] = uint8(v >> 56)
+ return offset + 8
+}
+func encodeFixed32Lease(dAtA []byte, offset int, v uint32) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ return offset + 4
+}
+func encodeVarintLease(dAtA []byte, offset int, v uint64) int {
+ for v >= 1<<7 {
+ dAtA[offset] = uint8(v&0x7f | 0x80)
+ v >>= 7
+ offset++
+ }
+ dAtA[offset] = uint8(v)
+ return offset + 1
+}
+func (m *Lease) Size() (n int) {
+ var l int
+ _ = l
+ if m.ID != 0 {
+ n += 1 + sovLease(uint64(m.ID))
+ }
+ if m.TTL != 0 {
+ n += 1 + sovLease(uint64(m.TTL))
+ }
+ return n
+}
+
+func (m *LeaseInternalRequest) Size() (n int) {
+ var l int
+ _ = l
+ if m.LeaseTimeToLiveRequest != nil {
+ l = m.LeaseTimeToLiveRequest.Size()
+ n += 1 + l + sovLease(uint64(l))
+ }
+ return n
+}
+
+func (m *LeaseInternalResponse) Size() (n int) {
+ var l int
+ _ = l
+ if m.LeaseTimeToLiveResponse != nil {
+ l = m.LeaseTimeToLiveResponse.Size()
+ n += 1 + l + sovLease(uint64(l))
+ }
+ return n
+}
+
+func sovLease(x uint64) (n int) {
+ for {
+ n++
+ x >>= 7
+ if x == 0 {
+ break
+ }
+ }
+ return n
+}
+func sozLease(x uint64) (n int) {
+ return sovLease(uint64((x << 1) ^ uint64((int64(x) >> 63))))
+}
+func (m *Lease) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowLease
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: Lease: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: Lease: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowLease
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field TTL", wireType)
+ }
+ m.TTL = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowLease
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.TTL |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipLease(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthLease
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *LeaseInternalRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowLease
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LeaseInternalRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LeaseInternalRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field LeaseTimeToLiveRequest", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowLease
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthLease
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.LeaseTimeToLiveRequest == nil {
+ m.LeaseTimeToLiveRequest = &etcdserverpb.LeaseTimeToLiveRequest{}
+ }
+ if err := m.LeaseTimeToLiveRequest.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipLease(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthLease
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *LeaseInternalResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowLease
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: LeaseInternalResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: LeaseInternalResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field LeaseTimeToLiveResponse", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowLease
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthLease
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.LeaseTimeToLiveResponse == nil {
+ m.LeaseTimeToLiveResponse = &etcdserverpb.LeaseTimeToLiveResponse{}
+ }
+ if err := m.LeaseTimeToLiveResponse.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipLease(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthLease
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func skipLease(dAtA []byte) (n int, err error) {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowLease
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ wireType := int(wire & 0x7)
+ switch wireType {
+ case 0:
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowLease
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ iNdEx++
+ if dAtA[iNdEx-1] < 0x80 {
+ break
+ }
+ }
+ return iNdEx, nil
+ case 1:
+ iNdEx += 8
+ return iNdEx, nil
+ case 2:
+ var length int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowLease
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ length |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ iNdEx += length
+ if length < 0 {
+ return 0, ErrInvalidLengthLease
+ }
+ return iNdEx, nil
+ case 3:
+ for {
+ var innerWire uint64
+ var start int = iNdEx
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowLease
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ innerWire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ innerWireType := int(innerWire & 0x7)
+ if innerWireType == 4 {
+ break
+ }
+ next, err := skipLease(dAtA[start:])
+ if err != nil {
+ return 0, err
+ }
+ iNdEx = start + next
+ }
+ return iNdEx, nil
+ case 4:
+ return iNdEx, nil
+ case 5:
+ iNdEx += 4
+ return iNdEx, nil
+ default:
+ return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
+ }
+ }
+ panic("unreachable")
+}
+
+var (
+ ErrInvalidLengthLease = fmt.Errorf("proto: negative length found during unmarshaling")
+ ErrIntOverflowLease = fmt.Errorf("proto: integer overflow")
+)
+
+func init() { proto.RegisterFile("lease.proto", fileDescriptorLease) }
+
+var fileDescriptorLease = []byte{
+ // 233 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xce, 0x49, 0x4d, 0x2c,
+ 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x07, 0x73, 0x0a, 0x92, 0xa4, 0x44, 0xd2,
+ 0xf3, 0xd3, 0xf3, 0xc1, 0x62, 0xfa, 0x20, 0x16, 0x44, 0x5a, 0x4a, 0x2d, 0xb5, 0x24, 0x39, 0x45,
+ 0x1f, 0x44, 0x14, 0xa7, 0x16, 0x95, 0xa5, 0x16, 0x21, 0x31, 0x0b, 0x92, 0xf4, 0x8b, 0x0a, 0x92,
+ 0x21, 0xea, 0x94, 0x34, 0xb9, 0x58, 0x7d, 0x40, 0x06, 0x09, 0xf1, 0x71, 0x31, 0x79, 0xba, 0x48,
+ 0x30, 0x2a, 0x30, 0x6a, 0x30, 0x07, 0x31, 0x79, 0xba, 0x08, 0x09, 0x70, 0x31, 0x87, 0x84, 0xf8,
+ 0x48, 0x30, 0x81, 0x05, 0x40, 0x4c, 0xa5, 0x12, 0x2e, 0x11, 0xb0, 0x52, 0xcf, 0xbc, 0x92, 0xd4,
+ 0xa2, 0xbc, 0xc4, 0x9c, 0xa0, 0xd4, 0xc2, 0xd2, 0xd4, 0xe2, 0x12, 0xa1, 0x18, 0x2e, 0x31, 0xb0,
+ 0x78, 0x48, 0x66, 0x6e, 0x6a, 0x48, 0xbe, 0x4f, 0x66, 0x59, 0x2a, 0x54, 0x06, 0x6c, 0x1a, 0xb7,
+ 0x91, 0x8a, 0x1e, 0xb2, 0xdd, 0x7a, 0xd8, 0xd5, 0x06, 0xe1, 0x30, 0x43, 0xa9, 0x82, 0x4b, 0x14,
+ 0xcd, 0xd6, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0xa1, 0x78, 0x2e, 0x71, 0x0c, 0x2d, 0x10, 0x29,
+ 0xa8, 0xbd, 0xaa, 0x04, 0xec, 0x85, 0x28, 0x0e, 0xc2, 0x65, 0x8a, 0x93, 0xc4, 0x89, 0x87, 0x72,
+ 0x0c, 0x17, 0x1e, 0xca, 0x31, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47,
+ 0x72, 0x8c, 0x33, 0x1e, 0xcb, 0x31, 0x24, 0xb1, 0x81, 0xc3, 0xce, 0x18, 0x10, 0x00, 0x00, 0xff,
+ 0xff, 0x9f, 0xf2, 0x42, 0xe0, 0x91, 0x01, 0x00, 0x00,
+}
diff --git a/vendor/github.com/coreos/etcd/lease/leasepb/lease.proto b/vendor/github.com/coreos/etcd/lease/leasepb/lease.proto
new file mode 100644
index 00000000..be414b99
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/lease/leasepb/lease.proto
@@ -0,0 +1,24 @@
+syntax = "proto3";
+package leasepb;
+
+import "gogoproto/gogo.proto";
+import "etcd/etcdserver/etcdserverpb/rpc.proto";
+
+option (gogoproto.marshaler_all) = true;
+option (gogoproto.sizer_all) = true;
+option (gogoproto.unmarshaler_all) = true;
+option (gogoproto.goproto_getters_all) = false;
+option (gogoproto.goproto_enum_prefix_all) = false;
+
+message Lease {
+ int64 ID = 1;
+ int64 TTL = 2;
+}
+
+message LeaseInternalRequest {
+ etcdserverpb.LeaseTimeToLiveRequest LeaseTimeToLiveRequest = 1;
+}
+
+message LeaseInternalResponse {
+ etcdserverpb.LeaseTimeToLiveResponse LeaseTimeToLiveResponse = 1;
+}
diff --git a/vendor/github.com/coreos/etcd/lease/lessor.go b/vendor/github.com/coreos/etcd/lease/lessor.go
new file mode 100644
index 00000000..3418cf56
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/lease/lessor.go
@@ -0,0 +1,643 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 lease
+
+import (
+ "encoding/binary"
+ "errors"
+ "math"
+ "sort"
+ "sync"
+ "sync/atomic"
+ "time"
+
+ "github.com/coreos/etcd/lease/leasepb"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/pkg/monotime"
+)
+
+const (
+ // NoLease is a special LeaseID representing the absence of a lease.
+ NoLease = LeaseID(0)
+
+ forever = monotime.Time(math.MaxInt64)
+)
+
+var (
+ leaseBucketName = []byte("lease")
+
+ // maximum number of leases to revoke per second; configurable for tests
+ leaseRevokeRate = 1000
+
+ ErrNotPrimary = errors.New("not a primary lessor")
+ ErrLeaseNotFound = errors.New("lease not found")
+ ErrLeaseExists = errors.New("lease already exists")
+)
+
+// TxnDelete is a TxnWrite that only permits deletes. Defined here
+// to avoid circular dependency with mvcc.
+type TxnDelete interface {
+ DeleteRange(key, end []byte) (n, rev int64)
+ End()
+}
+
+// RangeDeleter is a TxnDelete constructor.
+type RangeDeleter func() TxnDelete
+
+type LeaseID int64
+
+// Lessor owns leases. It can grant, revoke, renew and modify leases for lessee.
+type Lessor interface {
+ // SetRangeDeleter lets the lessor create TxnDeletes to the store.
+ // Lessor deletes the items in the revoked or expired lease by creating
+ // new TxnDeletes.
+ SetRangeDeleter(rd RangeDeleter)
+
+ // Grant grants a lease that expires at least after TTL seconds.
+ Grant(id LeaseID, ttl int64) (*Lease, error)
+ // Revoke revokes a lease with given ID. The item attached to the
+ // given lease will be removed. If the ID does not exist, an error
+ // will be returned.
+ Revoke(id LeaseID) error
+
+ // Attach attaches given leaseItem to the lease with given LeaseID.
+ // If the lease does not exist, an error will be returned.
+ Attach(id LeaseID, items []LeaseItem) error
+
+ // GetLease returns LeaseID for given item.
+ // If no lease found, NoLease value will be returned.
+ GetLease(item LeaseItem) LeaseID
+
+ // Detach detaches given leaseItem from the lease with given LeaseID.
+ // If the lease does not exist, an error will be returned.
+ Detach(id LeaseID, items []LeaseItem) error
+
+ // Promote promotes the lessor to be the primary lessor. Primary lessor manages
+ // the expiration and renew of leases.
+ // Newly promoted lessor renew the TTL of all lease to extend + previous TTL.
+ Promote(extend time.Duration)
+
+ // Demote demotes the lessor from being the primary lessor.
+ Demote()
+
+ // Renew renews a lease with given ID. It returns the renewed TTL. If the ID does not exist,
+ // an error will be returned.
+ Renew(id LeaseID) (int64, error)
+
+ // Lookup gives the lease at a given lease id, if any
+ Lookup(id LeaseID) *Lease
+
+ // ExpiredLeasesC returns a chan that is used to receive expired leases.
+ ExpiredLeasesC() <-chan []*Lease
+
+ // Recover recovers the lessor state from the given backend and RangeDeleter.
+ Recover(b backend.Backend, rd RangeDeleter)
+
+ // Stop stops the lessor for managing leases. The behavior of calling Stop multiple
+ // times is undefined.
+ Stop()
+}
+
+// lessor implements Lessor interface.
+// TODO: use clockwork for testability.
+type lessor struct {
+ mu sync.Mutex
+
+ // demotec is set when the lessor is the primary.
+ // demotec will be closed if the lessor is demoted.
+ demotec chan struct{}
+
+ // TODO: probably this should be a heap with a secondary
+ // id index.
+ // Now it is O(N) to loop over the leases to find expired ones.
+ // We want to make Grant, Revoke, and findExpiredLeases all O(logN) and
+ // Renew O(1).
+ // findExpiredLeases and Renew should be the most frequent operations.
+ leaseMap map[LeaseID]*Lease
+
+ itemMap map[LeaseItem]LeaseID
+
+ // When a lease expires, the lessor will delete the
+ // leased range (or key) by the RangeDeleter.
+ rd RangeDeleter
+
+ // backend to persist leases. We only persist lease ID and expiry for now.
+ // The leased items can be recovered by iterating all the keys in kv.
+ b backend.Backend
+
+ // minLeaseTTL is the minimum lease TTL that can be granted for a lease. Any
+ // requests for shorter TTLs are extended to the minimum TTL.
+ minLeaseTTL int64
+
+ expiredC chan []*Lease
+ // stopC is a channel whose closure indicates that the lessor should be stopped.
+ stopC chan struct{}
+ // doneC is a channel whose closure indicates that the lessor is stopped.
+ doneC chan struct{}
+}
+
+func NewLessor(b backend.Backend, minLeaseTTL int64) Lessor {
+ return newLessor(b, minLeaseTTL)
+}
+
+func newLessor(b backend.Backend, minLeaseTTL int64) *lessor {
+ l := &lessor{
+ leaseMap: make(map[LeaseID]*Lease),
+ itemMap: make(map[LeaseItem]LeaseID),
+ b: b,
+ minLeaseTTL: minLeaseTTL,
+ // expiredC is a small buffered chan to avoid unnecessary blocking.
+ expiredC: make(chan []*Lease, 16),
+ stopC: make(chan struct{}),
+ doneC: make(chan struct{}),
+ }
+ l.initAndRecover()
+
+ go l.runLoop()
+
+ return l
+}
+
+// isPrimary indicates if this lessor is the primary lessor. The primary
+// lessor manages lease expiration and renew.
+//
+// in etcd, raft leader is the primary. Thus there might be two primary
+// leaders at the same time (raft allows concurrent leader but with different term)
+// for at most a leader election timeout.
+// The old primary leader cannot affect the correctness since its proposal has a
+// smaller term and will not be committed.
+//
+// TODO: raft follower do not forward lease management proposals. There might be a
+// very small window (within second normally which depends on go scheduling) that
+// a raft follow is the primary between the raft leader demotion and lessor demotion.
+// Usually this should not be a problem. Lease should not be that sensitive to timing.
+func (le *lessor) isPrimary() bool {
+ return le.demotec != nil
+}
+
+func (le *lessor) SetRangeDeleter(rd RangeDeleter) {
+ le.mu.Lock()
+ defer le.mu.Unlock()
+
+ le.rd = rd
+}
+
+func (le *lessor) Grant(id LeaseID, ttl int64) (*Lease, error) {
+ if id == NoLease {
+ return nil, ErrLeaseNotFound
+ }
+
+ // TODO: when lessor is under high load, it should give out lease
+ // with longer TTL to reduce renew load.
+ l := &Lease{
+ ID: id,
+ ttl: ttl,
+ itemSet: make(map[LeaseItem]struct{}),
+ revokec: make(chan struct{}),
+ }
+
+ le.mu.Lock()
+ defer le.mu.Unlock()
+
+ if _, ok := le.leaseMap[id]; ok {
+ return nil, ErrLeaseExists
+ }
+
+ if l.ttl < le.minLeaseTTL {
+ l.ttl = le.minLeaseTTL
+ }
+
+ if le.isPrimary() {
+ l.refresh(0)
+ } else {
+ l.forever()
+ }
+
+ le.leaseMap[id] = l
+ l.persistTo(le.b)
+
+ return l, nil
+}
+
+func (le *lessor) Revoke(id LeaseID) error {
+ le.mu.Lock()
+
+ l := le.leaseMap[id]
+ if l == nil {
+ le.mu.Unlock()
+ return ErrLeaseNotFound
+ }
+ defer close(l.revokec)
+ // unlock before doing external work
+ le.mu.Unlock()
+
+ if le.rd == nil {
+ return nil
+ }
+
+ txn := le.rd()
+
+ // sort keys so deletes are in same order among all members,
+ // otherwise the backened hashes will be different
+ keys := l.Keys()
+ sort.StringSlice(keys).Sort()
+ for _, key := range keys {
+ txn.DeleteRange([]byte(key), nil)
+ }
+
+ le.mu.Lock()
+ defer le.mu.Unlock()
+ delete(le.leaseMap, l.ID)
+ // lease deletion needs to be in the same backend transaction with the
+ // kv deletion. Or we might end up with not executing the revoke or not
+ // deleting the keys if etcdserver fails in between.
+ le.b.BatchTx().UnsafeDelete(leaseBucketName, int64ToBytes(int64(l.ID)))
+
+ txn.End()
+ return nil
+}
+
+// Renew renews an existing lease. If the given lease does not exist or
+// has expired, an error will be returned.
+func (le *lessor) Renew(id LeaseID) (int64, error) {
+ le.mu.Lock()
+
+ unlock := func() { le.mu.Unlock() }
+ defer func() { unlock() }()
+
+ if !le.isPrimary() {
+ // forward renew request to primary instead of returning error.
+ return -1, ErrNotPrimary
+ }
+
+ demotec := le.demotec
+
+ l := le.leaseMap[id]
+ if l == nil {
+ return -1, ErrLeaseNotFound
+ }
+
+ if l.expired() {
+ le.mu.Unlock()
+ unlock = func() {}
+ select {
+ // A expired lease might be pending for revoking or going through
+ // quorum to be revoked. To be accurate, renew request must wait for the
+ // deletion to complete.
+ case <-l.revokec:
+ return -1, ErrLeaseNotFound
+ // The expired lease might fail to be revoked if the primary changes.
+ // The caller will retry on ErrNotPrimary.
+ case <-demotec:
+ return -1, ErrNotPrimary
+ case <-le.stopC:
+ return -1, ErrNotPrimary
+ }
+ }
+
+ l.refresh(0)
+ return l.ttl, nil
+}
+
+func (le *lessor) Lookup(id LeaseID) *Lease {
+ le.mu.Lock()
+ defer le.mu.Unlock()
+ return le.leaseMap[id]
+}
+
+func (le *lessor) Promote(extend time.Duration) {
+ le.mu.Lock()
+ defer le.mu.Unlock()
+
+ le.demotec = make(chan struct{})
+
+ // refresh the expiries of all leases.
+ for _, l := range le.leaseMap {
+ l.refresh(extend)
+ }
+
+ if len(le.leaseMap) < leaseRevokeRate {
+ // no possibility of lease pile-up
+ return
+ }
+
+ // adjust expiries in case of overlap
+ leases := make([]*Lease, 0, len(le.leaseMap))
+ for _, l := range le.leaseMap {
+ leases = append(leases, l)
+ }
+ sort.Sort(leasesByExpiry(leases))
+
+ baseWindow := leases[0].Remaining()
+ nextWindow := baseWindow + time.Second
+ expires := 0
+ // have fewer expires than the total revoke rate so piled up leases
+ // don't consume the entire revoke limit
+ targetExpiresPerSecond := (3 * leaseRevokeRate) / 4
+ for _, l := range leases {
+ remaining := l.Remaining()
+ if remaining > nextWindow {
+ baseWindow = remaining
+ nextWindow = baseWindow + time.Second
+ expires = 1
+ continue
+ }
+ expires++
+ if expires <= targetExpiresPerSecond {
+ continue
+ }
+ rateDelay := float64(time.Second) * (float64(expires) / float64(targetExpiresPerSecond))
+ // If leases are extended by n seconds, leases n seconds ahead of the
+ // base window should be extended by only one second.
+ rateDelay -= float64(remaining - baseWindow)
+ delay := time.Duration(rateDelay)
+ nextWindow = baseWindow + delay
+ l.refresh(delay + extend)
+ }
+}
+
+type leasesByExpiry []*Lease
+
+func (le leasesByExpiry) Len() int { return len(le) }
+func (le leasesByExpiry) Less(i, j int) bool { return le[i].Remaining() < le[j].Remaining() }
+func (le leasesByExpiry) Swap(i, j int) { le[i], le[j] = le[j], le[i] }
+
+func (le *lessor) Demote() {
+ le.mu.Lock()
+ defer le.mu.Unlock()
+
+ // set the expiries of all leases to forever
+ for _, l := range le.leaseMap {
+ l.forever()
+ }
+
+ if le.demotec != nil {
+ close(le.demotec)
+ le.demotec = nil
+ }
+}
+
+// Attach attaches items to the lease with given ID. When the lease
+// expires, the attached items will be automatically removed.
+// If the given lease does not exist, an error will be returned.
+func (le *lessor) Attach(id LeaseID, items []LeaseItem) error {
+ le.mu.Lock()
+ defer le.mu.Unlock()
+
+ l := le.leaseMap[id]
+ if l == nil {
+ return ErrLeaseNotFound
+ }
+
+ l.mu.Lock()
+ for _, it := range items {
+ l.itemSet[it] = struct{}{}
+ le.itemMap[it] = id
+ }
+ l.mu.Unlock()
+ return nil
+}
+
+func (le *lessor) GetLease(item LeaseItem) LeaseID {
+ le.mu.Lock()
+ id := le.itemMap[item]
+ le.mu.Unlock()
+ return id
+}
+
+// Detach detaches items from the lease with given ID.
+// If the given lease does not exist, an error will be returned.
+func (le *lessor) Detach(id LeaseID, items []LeaseItem) error {
+ le.mu.Lock()
+ defer le.mu.Unlock()
+
+ l := le.leaseMap[id]
+ if l == nil {
+ return ErrLeaseNotFound
+ }
+
+ l.mu.Lock()
+ for _, it := range items {
+ delete(l.itemSet, it)
+ delete(le.itemMap, it)
+ }
+ l.mu.Unlock()
+ return nil
+}
+
+func (le *lessor) Recover(b backend.Backend, rd RangeDeleter) {
+ le.mu.Lock()
+ defer le.mu.Unlock()
+
+ le.b = b
+ le.rd = rd
+ le.leaseMap = make(map[LeaseID]*Lease)
+ le.itemMap = make(map[LeaseItem]LeaseID)
+ le.initAndRecover()
+}
+
+func (le *lessor) ExpiredLeasesC() <-chan []*Lease {
+ return le.expiredC
+}
+
+func (le *lessor) Stop() {
+ close(le.stopC)
+ <-le.doneC
+}
+
+func (le *lessor) runLoop() {
+ defer close(le.doneC)
+
+ for {
+ var ls []*Lease
+
+ le.mu.Lock()
+ if le.isPrimary() {
+ ls = le.findExpiredLeases()
+ }
+ le.mu.Unlock()
+
+ if len(ls) != 0 {
+ // rate limit
+ if len(ls) > leaseRevokeRate/2 {
+ ls = ls[:leaseRevokeRate/2]
+ }
+ select {
+ case <-le.stopC:
+ return
+ case le.expiredC <- ls:
+ default:
+ // the receiver of expiredC is probably busy handling
+ // other stuff
+ // let's try this next time after 500ms
+ }
+ }
+
+ select {
+ case <-time.After(500 * time.Millisecond):
+ case <-le.stopC:
+ return
+ }
+ }
+}
+
+// findExpiredLeases loops all the leases in the leaseMap and returns the expired
+// leases that needed to be revoked.
+func (le *lessor) findExpiredLeases() []*Lease {
+ leases := make([]*Lease, 0, 16)
+
+ for _, l := range le.leaseMap {
+ // TODO: probably should change to <= 100-500 millisecond to
+ // make up committing latency.
+ if l.expired() {
+ leases = append(leases, l)
+ }
+ }
+
+ return leases
+}
+
+func (le *lessor) initAndRecover() {
+ tx := le.b.BatchTx()
+ tx.Lock()
+
+ tx.UnsafeCreateBucket(leaseBucketName)
+ _, vs := tx.UnsafeRange(leaseBucketName, int64ToBytes(0), int64ToBytes(math.MaxInt64), 0)
+ // TODO: copy vs and do decoding outside tx lock if lock contention becomes an issue.
+ for i := range vs {
+ var lpb leasepb.Lease
+ err := lpb.Unmarshal(vs[i])
+ if err != nil {
+ tx.Unlock()
+ panic("failed to unmarshal lease proto item")
+ }
+ ID := LeaseID(lpb.ID)
+ if lpb.TTL < le.minLeaseTTL {
+ lpb.TTL = le.minLeaseTTL
+ }
+ le.leaseMap[ID] = &Lease{
+ ID: ID,
+ ttl: lpb.TTL,
+ // itemSet will be filled in when recover key-value pairs
+ // set expiry to forever, refresh when promoted
+ itemSet: make(map[LeaseItem]struct{}),
+ expiry: forever,
+ revokec: make(chan struct{}),
+ }
+ }
+ tx.Unlock()
+
+ le.b.ForceCommit()
+}
+
+type Lease struct {
+ ID LeaseID
+ ttl int64 // time to live in seconds
+ // expiry is time when lease should expire; must be 64-bit aligned.
+ expiry monotime.Time
+
+ // mu protects concurrent accesses to itemSet
+ mu sync.RWMutex
+ itemSet map[LeaseItem]struct{}
+ revokec chan struct{}
+}
+
+func (l *Lease) expired() bool {
+ return l.Remaining() <= 0
+}
+
+func (l *Lease) persistTo(b backend.Backend) {
+ key := int64ToBytes(int64(l.ID))
+
+ lpb := leasepb.Lease{ID: int64(l.ID), TTL: int64(l.ttl)}
+ val, err := lpb.Marshal()
+ if err != nil {
+ panic("failed to marshal lease proto item")
+ }
+
+ b.BatchTx().Lock()
+ b.BatchTx().UnsafePut(leaseBucketName, key, val)
+ b.BatchTx().Unlock()
+}
+
+// TTL returns the TTL of the Lease.
+func (l *Lease) TTL() int64 {
+ return l.ttl
+}
+
+// refresh refreshes the expiry of the lease.
+func (l *Lease) refresh(extend time.Duration) {
+ t := monotime.Now().Add(extend + time.Duration(l.ttl)*time.Second)
+ atomic.StoreUint64((*uint64)(&l.expiry), uint64(t))
+}
+
+// forever sets the expiry of lease to be forever.
+func (l *Lease) forever() { atomic.StoreUint64((*uint64)(&l.expiry), uint64(forever)) }
+
+// Keys returns all the keys attached to the lease.
+func (l *Lease) Keys() []string {
+ l.mu.RLock()
+ keys := make([]string, 0, len(l.itemSet))
+ for k := range l.itemSet {
+ keys = append(keys, k.Key)
+ }
+ l.mu.RUnlock()
+ return keys
+}
+
+// Remaining returns the remaining time of the lease.
+func (l *Lease) Remaining() time.Duration {
+ t := monotime.Time(atomic.LoadUint64((*uint64)(&l.expiry)))
+ return time.Duration(t - monotime.Now())
+}
+
+type LeaseItem struct {
+ Key string
+}
+
+func int64ToBytes(n int64) []byte {
+ bytes := make([]byte, 8)
+ binary.BigEndian.PutUint64(bytes, uint64(n))
+ return bytes
+}
+
+// FakeLessor is a fake implementation of Lessor interface.
+// Used for testing only.
+type FakeLessor struct{}
+
+func (fl *FakeLessor) SetRangeDeleter(dr RangeDeleter) {}
+
+func (fl *FakeLessor) Grant(id LeaseID, ttl int64) (*Lease, error) { return nil, nil }
+
+func (fl *FakeLessor) Revoke(id LeaseID) error { return nil }
+
+func (fl *FakeLessor) Attach(id LeaseID, items []LeaseItem) error { return nil }
+
+func (fl *FakeLessor) GetLease(item LeaseItem) LeaseID { return 0 }
+func (fl *FakeLessor) Detach(id LeaseID, items []LeaseItem) error { return nil }
+
+func (fl *FakeLessor) Promote(extend time.Duration) {}
+
+func (fl *FakeLessor) Demote() {}
+
+func (fl *FakeLessor) Renew(id LeaseID) (int64, error) { return 10, nil }
+
+func (le *FakeLessor) Lookup(id LeaseID) *Lease { return nil }
+
+func (fl *FakeLessor) ExpiredLeasesC() <-chan []*Lease { return nil }
+
+func (fl *FakeLessor) Recover(b backend.Backend, rd RangeDeleter) {}
+
+func (fl *FakeLessor) Stop() {}
diff --git a/vendor/github.com/coreos/etcd/lease/lessor_test.go b/vendor/github.com/coreos/etcd/lease/lessor_test.go
new file mode 100644
index 00000000..7ea2972a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/lease/lessor_test.go
@@ -0,0 +1,465 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 lease
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "reflect"
+ "sort"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/mvcc/backend"
+)
+
+const (
+ minLeaseTTL = int64(5)
+ minLeaseTTLDuration = time.Duration(minLeaseTTL) * time.Second
+)
+
+// TestLessorGrant ensures Lessor can grant wanted lease.
+// The granted lease should have a unique ID with a term
+// that is greater than minLeaseTTL.
+func TestLessorGrant(t *testing.T) {
+ dir, be := NewTestBackend(t)
+ defer os.RemoveAll(dir)
+ defer be.Close()
+
+ le := newLessor(be, minLeaseTTL)
+ defer le.Stop()
+ le.Promote(0)
+
+ l, err := le.Grant(1, 1)
+ if err != nil {
+ t.Fatalf("could not grant lease 1 (%v)", err)
+ }
+ gl := le.Lookup(l.ID)
+
+ if !reflect.DeepEqual(gl, l) {
+ t.Errorf("lease = %v, want %v", gl, l)
+ }
+ if l.Remaining() < minLeaseTTLDuration-time.Second {
+ t.Errorf("term = %v, want at least %v", l.Remaining(), minLeaseTTLDuration-time.Second)
+ }
+
+ _, err = le.Grant(1, 1)
+ if err == nil {
+ t.Errorf("allocated the same lease")
+ }
+
+ var nl *Lease
+ nl, err = le.Grant(2, 1)
+ if err != nil {
+ t.Errorf("could not grant lease 2 (%v)", err)
+ }
+ if nl.ID == l.ID {
+ t.Errorf("new lease.id = %x, want != %x", nl.ID, l.ID)
+ }
+
+ be.BatchTx().Lock()
+ _, vs := be.BatchTx().UnsafeRange(leaseBucketName, int64ToBytes(int64(l.ID)), nil, 0)
+ if len(vs) != 1 {
+ t.Errorf("len(vs) = %d, want 1", len(vs))
+ }
+ be.BatchTx().Unlock()
+}
+
+// TestLeaseConcurrentKeys ensures Lease.Keys method calls are guarded
+// from concurrent map writes on 'itemSet'.
+func TestLeaseConcurrentKeys(t *testing.T) {
+ dir, be := NewTestBackend(t)
+ defer os.RemoveAll(dir)
+ defer be.Close()
+
+ le := newLessor(be, minLeaseTTL)
+ defer le.Stop()
+ le.SetRangeDeleter(func() TxnDelete { return newFakeDeleter(be) })
+
+ // grant a lease with long term (100 seconds) to
+ // avoid early termination during the test.
+ l, err := le.Grant(1, 100)
+ if err != nil {
+ t.Fatalf("could not grant lease for 100s ttl (%v)", err)
+ }
+
+ itemn := 10
+ items := make([]LeaseItem, itemn)
+ for i := 0; i < itemn; i++ {
+ items[i] = LeaseItem{Key: fmt.Sprintf("foo%d", i)}
+ }
+ if err = le.Attach(l.ID, items); err != nil {
+ t.Fatalf("failed to attach items to the lease: %v", err)
+ }
+
+ donec := make(chan struct{})
+ go func() {
+ le.Detach(l.ID, items)
+ close(donec)
+ }()
+
+ var wg sync.WaitGroup
+ wg.Add(itemn)
+ for i := 0; i < itemn; i++ {
+ go func() {
+ defer wg.Done()
+ l.Keys()
+ }()
+ }
+
+ <-donec
+ wg.Wait()
+}
+
+// TestLessorRevoke ensures Lessor can revoke a lease.
+// The items in the revoked lease should be removed from
+// the backend.
+// The revoked lease cannot be got from Lessor again.
+func TestLessorRevoke(t *testing.T) {
+ dir, be := NewTestBackend(t)
+ defer os.RemoveAll(dir)
+ defer be.Close()
+
+ le := newLessor(be, minLeaseTTL)
+ defer le.Stop()
+ var fd *fakeDeleter
+ le.SetRangeDeleter(func() TxnDelete {
+ fd = newFakeDeleter(be)
+ return fd
+ })
+
+ // grant a lease with long term (100 seconds) to
+ // avoid early termination during the test.
+ l, err := le.Grant(1, 100)
+ if err != nil {
+ t.Fatalf("could not grant lease for 100s ttl (%v)", err)
+ }
+
+ items := []LeaseItem{
+ {"foo"},
+ {"bar"},
+ }
+
+ if err = le.Attach(l.ID, items); err != nil {
+ t.Fatalf("failed to attach items to the lease: %v", err)
+ }
+
+ if err = le.Revoke(l.ID); err != nil {
+ t.Fatal("failed to revoke lease:", err)
+ }
+
+ if le.Lookup(l.ID) != nil {
+ t.Errorf("got revoked lease %x", l.ID)
+ }
+
+ wdeleted := []string{"bar_", "foo_"}
+ sort.Sort(sort.StringSlice(fd.deleted))
+ if !reflect.DeepEqual(fd.deleted, wdeleted) {
+ t.Errorf("deleted= %v, want %v", fd.deleted, wdeleted)
+ }
+
+ be.BatchTx().Lock()
+ _, vs := be.BatchTx().UnsafeRange(leaseBucketName, int64ToBytes(int64(l.ID)), nil, 0)
+ if len(vs) != 0 {
+ t.Errorf("len(vs) = %d, want 0", len(vs))
+ }
+ be.BatchTx().Unlock()
+}
+
+// TestLessorRenew ensures Lessor can renew an existing lease.
+func TestLessorRenew(t *testing.T) {
+ dir, be := NewTestBackend(t)
+ defer be.Close()
+ defer os.RemoveAll(dir)
+
+ le := newLessor(be, minLeaseTTL)
+ defer le.Stop()
+ le.Promote(0)
+
+ l, err := le.Grant(1, minLeaseTTL)
+ if err != nil {
+ t.Fatalf("failed to grant lease (%v)", err)
+ }
+
+ // manually change the ttl field
+ le.mu.Lock()
+ l.ttl = 10
+ le.mu.Unlock()
+ ttl, err := le.Renew(l.ID)
+ if err != nil {
+ t.Fatalf("failed to renew lease (%v)", err)
+ }
+ if ttl != l.ttl {
+ t.Errorf("ttl = %d, want %d", ttl, l.ttl)
+ }
+
+ l = le.Lookup(l.ID)
+ if l.Remaining() < 9*time.Second {
+ t.Errorf("failed to renew the lease")
+ }
+}
+
+// TestLessorRenewExtendPileup ensures Lessor extends leases on promotion if too many
+// expire at the same time.
+func TestLessorRenewExtendPileup(t *testing.T) {
+ oldRevokeRate := leaseRevokeRate
+ defer func() { leaseRevokeRate = oldRevokeRate }()
+ leaseRevokeRate = 10
+
+ dir, be := NewTestBackend(t)
+ defer os.RemoveAll(dir)
+
+ le := newLessor(be, minLeaseTTL)
+ ttl := int64(10)
+ for i := 1; i <= leaseRevokeRate*10; i++ {
+ if _, err := le.Grant(LeaseID(2*i), ttl); err != nil {
+ t.Fatal(err)
+ }
+ // ttls that overlap spillover for ttl=10
+ if _, err := le.Grant(LeaseID(2*i+1), ttl+1); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ // simulate stop and recovery
+ le.Stop()
+ be.Close()
+ bcfg := backend.DefaultBackendConfig()
+ bcfg.Path = filepath.Join(dir, "be")
+ be = backend.New(bcfg)
+ defer be.Close()
+ le = newLessor(be, minLeaseTTL)
+ defer le.Stop()
+
+ // extend after recovery should extend expiration on lease pile-up
+ le.Promote(0)
+
+ windowCounts := make(map[int64]int)
+ for _, l := range le.leaseMap {
+ // round up slightly for baseline ttl
+ s := int64(l.Remaining().Seconds() + 0.1)
+ windowCounts[s]++
+ }
+
+ for i := ttl; i < ttl+20; i++ {
+ c := windowCounts[i]
+ if c > leaseRevokeRate {
+ t.Errorf("expected at most %d expiring at %ds, got %d", leaseRevokeRate, i, c)
+ }
+ if c < leaseRevokeRate/2 {
+ t.Errorf("expected at least %d expiring at %ds, got %d", leaseRevokeRate/2, i, c)
+ }
+ }
+}
+
+func TestLessorDetach(t *testing.T) {
+ dir, be := NewTestBackend(t)
+ defer os.RemoveAll(dir)
+ defer be.Close()
+
+ le := newLessor(be, minLeaseTTL)
+ defer le.Stop()
+ le.SetRangeDeleter(func() TxnDelete { return newFakeDeleter(be) })
+
+ // grant a lease with long term (100 seconds) to
+ // avoid early termination during the test.
+ l, err := le.Grant(1, 100)
+ if err != nil {
+ t.Fatalf("could not grant lease for 100s ttl (%v)", err)
+ }
+
+ items := []LeaseItem{
+ {"foo"},
+ {"bar"},
+ }
+
+ if err := le.Attach(l.ID, items); err != nil {
+ t.Fatalf("failed to attach items to the lease: %v", err)
+ }
+
+ if err := le.Detach(l.ID, items[0:1]); err != nil {
+ t.Fatalf("failed to de-attach items to the lease: %v", err)
+ }
+
+ l = le.Lookup(l.ID)
+ if len(l.itemSet) != 1 {
+ t.Fatalf("len(l.itemSet) = %d, failed to de-attach items", len(l.itemSet))
+ }
+ if _, ok := l.itemSet[LeaseItem{"bar"}]; !ok {
+ t.Fatalf("de-attached wrong item, want %q exists", "bar")
+ }
+}
+
+// TestLessorRecover ensures Lessor recovers leases from
+// persist backend.
+func TestLessorRecover(t *testing.T) {
+ dir, be := NewTestBackend(t)
+ defer os.RemoveAll(dir)
+ defer be.Close()
+
+ le := newLessor(be, minLeaseTTL)
+ defer le.Stop()
+ l1, err1 := le.Grant(1, 10)
+ l2, err2 := le.Grant(2, 20)
+ if err1 != nil || err2 != nil {
+ t.Fatalf("could not grant initial leases (%v, %v)", err1, err2)
+ }
+
+ // Create a new lessor with the same backend
+ nle := newLessor(be, minLeaseTTL)
+ defer nle.Stop()
+ nl1 := nle.Lookup(l1.ID)
+ if nl1 == nil || nl1.ttl != l1.ttl {
+ t.Errorf("nl1 = %v, want nl1.ttl= %d", nl1.ttl, l1.ttl)
+ }
+
+ nl2 := nle.Lookup(l2.ID)
+ if nl2 == nil || nl2.ttl != l2.ttl {
+ t.Errorf("nl2 = %v, want nl2.ttl= %d", nl2.ttl, l2.ttl)
+ }
+}
+
+func TestLessorExpire(t *testing.T) {
+ dir, be := NewTestBackend(t)
+ defer os.RemoveAll(dir)
+ defer be.Close()
+
+ testMinTTL := int64(1)
+
+ le := newLessor(be, testMinTTL)
+ defer le.Stop()
+
+ le.Promote(1 * time.Second)
+ l, err := le.Grant(1, testMinTTL)
+ if err != nil {
+ t.Fatalf("failed to create lease: %v", err)
+ }
+
+ select {
+ case el := <-le.ExpiredLeasesC():
+ if el[0].ID != l.ID {
+ t.Fatalf("expired id = %x, want %x", el[0].ID, l.ID)
+ }
+ case <-time.After(10 * time.Second):
+ t.Fatalf("failed to receive expired lease")
+ }
+
+ donec := make(chan struct{})
+ go func() {
+ // expired lease cannot be renewed
+ if _, err := le.Renew(l.ID); err != ErrLeaseNotFound {
+ t.Fatalf("unexpected renew")
+ }
+ donec <- struct{}{}
+ }()
+
+ select {
+ case <-donec:
+ t.Fatalf("renew finished before lease revocation")
+ case <-time.After(50 * time.Millisecond):
+ }
+
+ // expired lease can be revoked
+ if err := le.Revoke(l.ID); err != nil {
+ t.Fatalf("failed to revoke expired lease: %v", err)
+ }
+
+ select {
+ case <-donec:
+ case <-time.After(10 * time.Second):
+ t.Fatalf("renew has not returned after lease revocation")
+ }
+}
+
+func TestLessorExpireAndDemote(t *testing.T) {
+ dir, be := NewTestBackend(t)
+ defer os.RemoveAll(dir)
+ defer be.Close()
+
+ testMinTTL := int64(1)
+
+ le := newLessor(be, testMinTTL)
+ defer le.Stop()
+
+ le.Promote(1 * time.Second)
+ l, err := le.Grant(1, testMinTTL)
+ if err != nil {
+ t.Fatalf("failed to create lease: %v", err)
+ }
+
+ select {
+ case el := <-le.ExpiredLeasesC():
+ if el[0].ID != l.ID {
+ t.Fatalf("expired id = %x, want %x", el[0].ID, l.ID)
+ }
+ case <-time.After(10 * time.Second):
+ t.Fatalf("failed to receive expired lease")
+ }
+
+ donec := make(chan struct{})
+ go func() {
+ // expired lease cannot be renewed
+ if _, err := le.Renew(l.ID); err != ErrNotPrimary {
+ t.Fatalf("unexpected renew: %v", err)
+ }
+ donec <- struct{}{}
+ }()
+
+ select {
+ case <-donec:
+ t.Fatalf("renew finished before demotion")
+ case <-time.After(50 * time.Millisecond):
+ }
+
+ // demote will cause the renew request to fail with ErrNotPrimary
+ le.Demote()
+
+ select {
+ case <-donec:
+ case <-time.After(10 * time.Second):
+ t.Fatalf("renew has not returned after lessor demotion")
+ }
+}
+
+type fakeDeleter struct {
+ deleted []string
+ tx backend.BatchTx
+}
+
+func newFakeDeleter(be backend.Backend) *fakeDeleter {
+ fd := &fakeDeleter{nil, be.BatchTx()}
+ fd.tx.Lock()
+ return fd
+}
+
+func (fd *fakeDeleter) End() { fd.tx.Unlock() }
+
+func (fd *fakeDeleter) DeleteRange(key, end []byte) (int64, int64) {
+ fd.deleted = append(fd.deleted, string(key)+"_"+string(end))
+ return 0, 0
+}
+
+func NewTestBackend(t *testing.T) (string, backend.Backend) {
+ tmpPath, err := ioutil.TempDir("", "lease")
+ if err != nil {
+ t.Fatalf("failed to create tmpdir (%v)", err)
+ }
+ bcfg := backend.DefaultBackendConfig()
+ bcfg.Path = filepath.Join(tmpPath, "be")
+ return tmpPath, backend.New(bcfg)
+}
diff --git a/vendor/github.com/coreos/etcd/logos/etcd-glyph-color.png b/vendor/github.com/coreos/etcd/logos/etcd-glyph-color.png
new file mode 100644
index 00000000..8bf92948
Binary files /dev/null and b/vendor/github.com/coreos/etcd/logos/etcd-glyph-color.png differ
diff --git a/vendor/github.com/coreos/etcd/logos/etcd-glyph-color.svg b/vendor/github.com/coreos/etcd/logos/etcd-glyph-color.svg
new file mode 100644
index 00000000..5884e927
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/logos/etcd-glyph-color.svg
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="235px" height="225px" viewBox="189.5 283.5 235 225" enable-background="new 189.5 283.5 235 225" xml:space="preserve">
+<g>
+ <g>
+ <path fill="#419EDA" d="M296.544,384.038c0,8.063-6.533,14.585-14.585,14.585c-8.058,0-14.573-6.521-14.573-14.585
+ c0-8.029,6.516-14.576,14.573-14.576C290.011,369.462,296.544,376.009,296.544,384.038z"/>
+ <path fill="#419EDA" d="M315.39,384.038c0,8.063,6.534,14.585,14.586,14.585c8.05,0,14.577-6.521,14.577-14.585
+ c0-8.032-6.527-14.579-14.577-14.579C321.924,369.459,315.39,376.006,315.39,384.038z"/>
+ <path fill="#419EDA" d="M414.636,399.847c-1.05,0.088-2.105,0.129-3.226,0.129c-6.503,0-12.812-1.525-18.504-4.318
+ c1.895-10.871,2.701-21.823,2.49-32.735c-6.171-8.926-13.224-17.348-21.185-25.107c3.454-6.476,8.56-12.048,14.934-15.999
+ l2.737-1.692l-2.133-2.405c-10.988-12.373-24.102-21.939-38.97-28.43l-2.965-1.29l-0.753,3.134
+ c-1.773,7.304-5.479,13.893-10.567,19.181c-9.779-5.198-19.995-9.399-30.53-12.581c-10.51,3.175-20.708,7.364-30.483,12.554
+ c-5.067-5.281-8.764-11.854-10.53-19.137l-0.758-3.133l-2.954,1.284c-14.681,6.397-28.156,16.222-38.964,28.411l-2.139,2.41
+ l2.734,1.692c6.354,3.936,11.446,9.475,14.894,15.916c-7.937,7.729-14.982,16.124-21.148,25.009
+ c-0.24,10.907,0.525,21.939,2.429,32.96c-5.664,2.767-11.938,4.275-18.398,4.275c-1.134,0-2.195-0.041-3.226-0.127l-3.212-0.245
+ l0.301,3.207c1.574,16.225,6.612,31.657,14.982,45.872l1.634,2.774l2.453-2.082c5.685-4.822,12.554-8.015,19.858-9.302
+ c4.815,9.845,10.522,19.095,16.996,27.683c10.33,3.613,21.093,6.31,32.208,7.915c1.066,7.351,0.217,14.954-2.683,21.984
+ l-1.223,2.979l3.145,0.692c8.053,1.771,16.177,2.673,24.132,2.673l24.125-2.673l3.148-0.692l-1.226-2.985
+ c-2.892-7.03-3.741-14.642-2.675-21.994c11.071-1.606,21.794-4.297,32.086-7.899c6.48-8.595,12.192-17.851,17.015-27.709
+ c7.327,1.279,14.235,4.474,19.955,9.31l2.453,2.079l1.626-2.767c8.385-14.233,13.422-29.664,14.972-45.863l0.301-3.201
+ L414.636,399.847z M340.49,439.058c-11.413,3.104-23.004,4.671-34.526,4.671c-11.553,0-23.13-1.566-34.553-4.671
+ c-6.267-9.738-11.222-20.17-14.788-31.153c-3.551-10.932-5.629-22.385-6.232-34.178c7.377-9.121,15.766-17.111,25.035-23.837
+ c9.419-6.851,19.666-12.417,30.538-16.604c10.854,4.188,21.082,9.746,30.479,16.568c9.305,6.762,17.731,14.814,25.144,23.992
+ c-0.632,11.726-2.735,23.113-6.292,34.027C351.738,418.854,346.767,429.319,340.49,439.058z"/>
+ </g>
+</g>
+</svg>
diff --git a/vendor/github.com/coreos/etcd/logos/etcd-horizontal-bw.png b/vendor/github.com/coreos/etcd/logos/etcd-horizontal-bw.png
new file mode 100644
index 00000000..044d8cf7
Binary files /dev/null and b/vendor/github.com/coreos/etcd/logos/etcd-horizontal-bw.png differ
diff --git a/vendor/github.com/coreos/etcd/logos/etcd-horizontal-bw.svg b/vendor/github.com/coreos/etcd/logos/etcd-horizontal-bw.svg
new file mode 100644
index 00000000..1403d90c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/logos/etcd-horizontal-bw.svg
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="298px" height="111px" viewBox="156.5 340.5 298 111" enable-background="new 156.5 340.5 298 111" xml:space="preserve">
+<g>
+ <g>
+ <path d="M203.144,398.853c0,3.24-2.628,5.863-5.863,5.863c-3.237,0-5.858-2.623-5.858-5.863c0-3.226,2.622-5.859,5.858-5.859
+ C200.516,392.993,203.144,395.627,203.144,398.853z"/>
+ <path d="M210.722,398.853c0,3.244,2.624,5.864,5.863,5.864c3.235,0,5.863-2.62,5.863-5.864c0-3.228-2.628-5.859-5.863-5.859
+ C213.346,392.993,210.722,395.625,210.722,398.853z"/>
+ <path d="M250.623,405.212c-0.425,0.034-0.845,0.049-1.295,0.049c-2.616,0-5.152-0.612-7.441-1.732
+ c0.76-4.374,1.086-8.775,1.002-13.163c-2.482-3.592-5.317-6.977-8.519-10.095c1.389-2.604,3.444-4.845,6.003-6.43l1.102-0.683
+ l-0.86-0.971c-4.417-4.97-9.686-8.815-15.666-11.426l-1.192-0.518l-0.303,1.257c-0.714,2.936-2.202,5.585-4.248,7.711
+ c-3.931-2.088-8.038-3.777-12.274-5.056c-4.226,1.276-8.329,2.96-12.256,5.048c-2.04-2.123-3.522-4.768-4.231-7.694l-0.308-1.261
+ l-1.188,0.516c-5.901,2.571-11.319,6.521-15.665,11.422l-0.859,0.971l1.1,0.682c2.556,1.58,4.6,3.808,5.989,6.396
+ c-3.19,3.108-6.026,6.484-8.504,10.058c-0.096,4.383,0.212,8.818,0.976,13.25c-2.278,1.11-4.798,1.717-7.396,1.717
+ c-0.455,0-0.883-0.015-1.298-0.049L162,405.11l0.12,1.29c0.636,6.522,2.658,12.729,6.026,18.442l0.656,1.117l0.984-0.838
+ c2.287-1.938,5.047-3.222,7.985-3.738c1.937,3.956,4.229,7.676,6.834,11.13c4.152,1.452,8.479,2.538,12.949,3.184
+ c0.429,2.952,0.087,6.009-1.078,8.835l-0.492,1.198l1.264,0.28c3.236,0.714,6.501,1.073,9.702,1.073l9.7-1.073l1.265-0.28
+ l-0.49-1.198c-1.165-2.826-1.509-5.888-1.075-8.845c4.448-0.645,8.758-1.728,12.897-3.174c2.607-3.454,4.903-7.179,6.839-11.14
+ c2.948,0.512,5.727,1.796,8.025,3.742l0.985,0.834l0.657-1.108c3.37-5.726,5.395-11.93,6.019-18.441l0.12-1.289L250.623,405.212z
+ M220.815,420.975c-4.592,1.245-9.25,1.875-13.882,1.875c-4.648,0-9.301-0.63-13.893-1.875c-2.52-3.914-4.512-8.108-5.944-12.524
+ c-1.429-4.397-2.265-9-2.508-13.741c2.968-3.668,6.34-6.881,10.067-9.583c3.787-2.754,7.905-4.993,12.278-6.679
+ c4.365,1.686,8.477,3.919,12.253,6.661c3.74,2.72,7.129,5.956,10.111,9.649c-0.256,4.712-1.104,9.291-2.531,13.68
+ C225.334,412.854,223.335,417.061,220.815,420.975z"/>
+ </g>
+ <g>
+ <path d="M287.554,370.327c14.725,0,23.038,10.569,23.038,27.074c0,2.019-0.12,3.919-0.357,5.343h-38.95
+ c0.713,12.47,8.196,20.308,19.237,20.308c5.462,0,10.092-1.782,14.368-4.513l3.443,6.411c-4.987,3.207-11.162,5.938-18.998,5.938
+ c-15.437,0-27.668-11.28-27.668-30.163C261.667,381.847,274.371,370.327,287.554,370.327z M302.042,396.332
+ c0-11.756-5.225-18.285-14.25-18.285c-8.075,0-15.438,6.648-16.625,18.285H302.042z"/>
+ <path d="M321.633,379.708h-8.55v-7.362l9.024-0.594l1.189-16.149h8.191v16.149h15.557v7.957h-15.557v32.062
+ c0,7.126,2.259,11.162,8.907,11.162c2.02,0,4.632-0.831,6.532-1.545l1.897,7.364c-3.205,1.068-7.123,2.138-10.687,2.138
+ c-12.348,0-16.506-7.837-16.506-19.237v-31.945H321.633z"/>
+ <path d="M378.871,370.327c7.6,0,12.942,3.207,16.86,6.888l-4.867,6.292c-3.444-2.966-7.006-5.104-11.638-5.104
+ c-10.448,0-18.05,9.023-18.05,22.323c0,13.182,7.244,22.088,17.813,22.088c5.462,0,10.095-2.731,13.537-5.818l4.394,6.412
+ c-5.225,4.631-11.876,7.481-18.764,7.481c-15.315,0-27.072-11.044-27.072-30.163C351.085,381.371,364.028,370.327,378.871,370.327
+ z"/>
+ <path d="M424.471,370.327c6.649,0,11.042,2.494,16.149,6.651l-0.476-9.856v-22.206H450v84.546h-8.072l-0.834-6.768h-0.355
+ c-4.513,4.394-10.686,8.194-17.456,8.194c-14.487,0-23.867-10.925-23.867-30.163C399.415,381.965,411.29,370.327,424.471,370.327z
+ M425.42,422.694c5.343,0,9.976-2.612,14.725-7.954v-30.164c-4.87-4.393-9.262-6.056-14.012-6.056
+ c-9.263,0-16.624,8.905-16.624,22.088C409.509,414.383,415.326,422.694,425.42,422.694z"/>
+ </g>
+</g>
+</svg>
diff --git a/vendor/github.com/coreos/etcd/logos/etcd-horizontal-color.png b/vendor/github.com/coreos/etcd/logos/etcd-horizontal-color.png
new file mode 100644
index 00000000..2638ff37
Binary files /dev/null and b/vendor/github.com/coreos/etcd/logos/etcd-horizontal-color.png differ
diff --git a/vendor/github.com/coreos/etcd/logos/etcd-horizontal-color.svg b/vendor/github.com/coreos/etcd/logos/etcd-horizontal-color.svg
new file mode 100644
index 00000000..c6b05657
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/logos/etcd-horizontal-color.svg
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="298px" height="111px" viewBox="156.5 340.5 298 111" enable-background="new 156.5 340.5 298 111" xml:space="preserve">
+<g>
+ <g>
+ <path fill="#419EDA" d="M203.144,398.853c0,3.24-2.628,5.863-5.863,5.863c-3.237,0-5.858-2.623-5.858-5.863
+ c0-3.226,2.622-5.859,5.858-5.859C200.516,392.993,203.144,395.627,203.144,398.853z"/>
+ <path fill="#419EDA" d="M210.722,398.853c0,3.244,2.624,5.864,5.863,5.864c3.235,0,5.863-2.62,5.863-5.864
+ c0-3.228-2.628-5.859-5.863-5.859C213.346,392.993,210.722,395.625,210.722,398.853z"/>
+ <path fill="#419EDA" d="M250.623,405.212c-0.425,0.034-0.845,0.049-1.295,0.049c-2.616,0-5.152-0.612-7.441-1.732
+ c0.76-4.374,1.086-8.775,1.002-13.163c-2.482-3.592-5.317-6.977-8.519-10.095c1.389-2.604,3.444-4.845,6.003-6.43l1.102-0.683
+ l-0.86-0.971c-4.417-4.97-9.686-8.815-15.666-11.426l-1.192-0.518l-0.303,1.257c-0.714,2.936-2.202,5.585-4.248,7.711
+ c-3.931-2.088-8.038-3.777-12.274-5.056c-4.226,1.276-8.329,2.96-12.256,5.048c-2.04-2.123-3.522-4.768-4.231-7.694l-0.308-1.261
+ l-1.188,0.516c-5.901,2.571-11.319,6.521-15.665,11.422l-0.859,0.971l1.1,0.682c2.556,1.58,4.6,3.808,5.989,6.396
+ c-3.19,3.108-6.026,6.484-8.504,10.058c-0.096,4.383,0.212,8.818,0.976,13.25c-2.278,1.11-4.798,1.717-7.396,1.717
+ c-0.455,0-0.883-0.015-1.298-0.049L162,405.11l0.12,1.29c0.636,6.522,2.658,12.729,6.026,18.442l0.656,1.117l0.984-0.838
+ c2.287-1.938,5.047-3.222,7.985-3.738c1.937,3.956,4.229,7.676,6.834,11.13c4.152,1.452,8.479,2.538,12.949,3.184
+ c0.429,2.952,0.087,6.009-1.078,8.835l-0.492,1.198l1.264,0.28c3.236,0.714,6.501,1.073,9.702,1.073l9.7-1.073l1.265-0.28
+ l-0.49-1.198c-1.165-2.826-1.509-5.888-1.075-8.845c4.448-0.645,8.758-1.728,12.897-3.174c2.607-3.454,4.903-7.179,6.839-11.14
+ c2.948,0.512,5.727,1.796,8.025,3.742l0.985,0.834l0.657-1.108c3.37-5.726,5.395-11.93,6.019-18.441l0.12-1.289L250.623,405.212z
+ M220.815,420.975c-4.592,1.245-9.25,1.875-13.882,1.875c-4.648,0-9.301-0.63-13.893-1.875c-2.52-3.914-4.512-8.108-5.944-12.524
+ c-1.429-4.397-2.265-9-2.508-13.741c2.968-3.668,6.34-6.881,10.067-9.583c3.787-2.754,7.905-4.993,12.278-6.679
+ c4.365,1.686,8.477,3.919,12.253,6.661c3.74,2.72,7.129,5.956,10.111,9.649c-0.256,4.712-1.104,9.291-2.531,13.68
+ C225.334,412.854,223.335,417.061,220.815,420.975z"/>
+ </g>
+ <g>
+ <path d="M287.554,370.327c14.725,0,23.038,10.569,23.038,27.074c0,2.019-0.12,3.919-0.357,5.343h-38.95
+ c0.713,12.47,8.196,20.308,19.237,20.308c5.462,0,10.092-1.782,14.368-4.513l3.443,6.411c-4.987,3.207-11.162,5.938-18.998,5.938
+ c-15.437,0-27.668-11.28-27.668-30.163C261.667,381.847,274.371,370.327,287.554,370.327z M302.042,396.332
+ c0-11.756-5.225-18.285-14.25-18.285c-8.075,0-15.438,6.648-16.625,18.285H302.042z"/>
+ <path d="M321.633,379.708h-8.55v-7.362l9.024-0.594l1.189-16.149h8.191v16.149h15.557v7.957h-15.557v32.062
+ c0,7.126,2.259,11.162,8.907,11.162c2.02,0,4.632-0.831,6.532-1.545l1.897,7.364c-3.205,1.068-7.123,2.138-10.687,2.138
+ c-12.348,0-16.506-7.837-16.506-19.237v-31.945H321.633z"/>
+ <path d="M378.871,370.327c7.6,0,12.942,3.207,16.86,6.888l-4.867,6.292c-3.444-2.966-7.006-5.104-11.638-5.104
+ c-10.448,0-18.05,9.023-18.05,22.323c0,13.182,7.244,22.088,17.813,22.088c5.462,0,10.095-2.731,13.537-5.818l4.394,6.412
+ c-5.225,4.631-11.876,7.481-18.764,7.481c-15.315,0-27.072-11.044-27.072-30.163C351.085,381.371,364.028,370.327,378.871,370.327
+ z"/>
+ <path d="M424.471,370.327c6.649,0,11.042,2.494,16.149,6.651l-0.476-9.856v-22.206H450v84.546h-8.072l-0.834-6.768h-0.355
+ c-4.513,4.394-10.686,8.194-17.456,8.194c-14.487,0-23.867-10.925-23.867-30.163C399.415,381.965,411.29,370.327,424.471,370.327z
+ M425.42,422.694c5.343,0,9.976-2.612,14.725-7.954v-30.164c-4.87-4.393-9.262-6.056-14.012-6.056
+ c-9.263,0-16.624,8.905-16.624,22.088C409.509,414.383,415.326,422.694,425.42,422.694z"/>
+ </g>
+</g>
+</svg>
diff --git a/vendor/github.com/coreos/etcd/logos/etcd-offset-bw.png b/vendor/github.com/coreos/etcd/logos/etcd-offset-bw.png
new file mode 100644
index 00000000..f5cc3944
Binary files /dev/null and b/vendor/github.com/coreos/etcd/logos/etcd-offset-bw.png differ
diff --git a/vendor/github.com/coreos/etcd/logos/etcd-offset-bw.svg b/vendor/github.com/coreos/etcd/logos/etcd-offset-bw.svg
new file mode 100644
index 00000000..2dbdb416
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/logos/etcd-offset-bw.svg
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="299px" height="161px" viewBox="157.5 315.5 299 161" enable-background="new 157.5 315.5 299 161" xml:space="preserve">
+<g>
+ <g>
+ <path d="M203.909,359.442c0,3.302-2.676,5.972-5.973,5.972c-3.3,0-5.97-2.67-5.97-5.972c0-3.287,2.67-5.97,5.97-5.97
+ C201.233,353.472,203.909,356.155,203.909,359.442z"/>
+ <path d="M211.626,359.442c0,3.303,2.677,5.974,5.972,5.974c3.3,0,5.972-2.67,5.972-5.974c0-3.288-2.672-5.97-5.972-5.97
+ C214.303,353.472,211.626,356.154,211.626,359.442z"/>
+ <path d="M252.269,365.917c-0.428,0.036-0.861,0.052-1.319,0.052c-2.662,0-5.245-0.626-7.577-1.768
+ c0.775-4.453,1.105-8.938,1.02-13.408c-2.529-3.655-5.416-7.105-8.675-10.282c1.413-2.652,3.504-4.935,6.116-6.552l1.122-0.692
+ l-0.876-0.986c-4.5-5.066-9.869-8.984-15.958-11.642l-1.215-0.528l-0.311,1.284c-0.724,2.992-2.242,5.689-4.325,7.853
+ c-4.003-2.127-8.188-3.848-12.502-5.151c-4.306,1.302-8.48,3.016-12.485,5.144c-2.075-2.162-3.587-4.857-4.31-7.838l-0.312-1.284
+ l-1.21,0.527c-6.011,2.618-11.53,6.643-15.957,11.635l-0.876,0.988l1.122,0.692c2.6,1.611,4.687,3.88,6.1,6.518
+ c-3.253,3.164-6.137,6.604-8.662,10.243c-0.1,4.466,0.214,8.983,0.994,13.496c-2.32,1.133-4.889,1.753-7.535,1.753
+ c-0.464,0-0.897-0.016-1.319-0.051l-1.318-0.103l0.124,1.315c0.645,6.643,2.709,12.963,6.135,18.785l0.67,1.135l1.004-0.85
+ c2.327-1.974,5.141-3.284,8.131-3.811c1.974,4.033,4.312,7.82,6.963,11.336c4.232,1.481,8.639,2.587,13.191,3.244
+ c0.435,3.009,0.087,6.122-1.1,9.002l-0.5,1.218l1.289,0.286c3.298,0.727,6.624,1.095,9.881,1.095l9.88-1.095l1.292-0.286
+ l-0.503-1.218c-1.184-2.882-1.532-5.998-1.096-9.012c4.535-0.657,8.925-1.758,13.141-3.234c2.654-3.518,4.994-7.31,6.97-11.347
+ c3,0.524,5.828,1.831,8.171,3.813l1.003,0.851l0.667-1.132c3.434-5.83,5.496-12.148,6.129-18.783l0.126-1.308L252.269,365.917z
+ M221.908,381.973c-4.677,1.271-9.422,1.914-14.143,1.914c-4.729,0-9.472-0.643-14.149-1.914
+ c-2.565-3.988-4.595-8.259-6.057-12.755c-1.454-4.479-2.304-9.167-2.551-13.996c3.021-3.739,6.456-7.012,10.253-9.766
+ c3.857-2.804,8.053-5.082,12.506-6.801c4.444,1.719,8.634,3.993,12.483,6.786c3.81,2.769,7.259,6.068,10.295,9.828
+ c-0.258,4.801-1.12,9.463-2.577,13.935C226.513,373.7,224.477,377.984,221.908,381.973z"/>
+ </g>
+ <g>
+ <path d="M257.854,400.253c17.417,0,27.249,12.501,27.249,32.025c0,2.391-0.141,4.636-0.419,6.319h-46.07
+ c0.841,14.75,9.688,24.019,22.751,24.019c6.463,0,11.939-2.106,16.997-5.334l4.072,7.582c-5.896,3.792-13.201,7.023-22.475,7.023
+ c-18.256,0-32.723-13.345-32.723-35.674C227.236,413.879,242.264,400.253,257.854,400.253z M274.992,431.016
+ c0-13.906-6.181-21.632-16.856-21.632c-9.553,0-18.259,7.866-19.664,21.632H274.992z"/>
+ <path d="M298.166,411.35h-10.114v-8.709l10.677-0.701l1.404-19.102h9.69v19.102h18.401v9.41h-18.401v37.923
+ c0,8.428,2.669,13.203,10.534,13.203c2.389,0,5.479-0.983,7.727-1.827l2.246,8.711c-3.793,1.265-8.428,2.528-12.642,2.528
+ c-14.607,0-19.522-9.271-19.522-22.752L298.166,411.35L298.166,411.35z"/>
+ <path d="M365.866,400.253c8.992,0,15.311,3.794,19.947,8.146l-5.759,7.447c-4.073-3.513-8.287-6.044-13.767-6.044
+ c-12.36,0-21.348,10.678-21.348,26.411c0,15.587,8.568,26.121,21.066,26.121c6.464,0,11.941-3.229,16.014-6.881l5.198,7.582
+ c-6.182,5.481-14.048,8.852-22.194,8.852c-18.117,0-32.022-13.062-32.022-35.674C333.002,413.316,348.311,400.253,365.866,400.253
+ z"/>
+ <path d="M419.805,400.253c7.865,0,13.063,2.95,19.103,7.865l-0.562-11.657v-26.266h11.657V470.2h-9.55l-0.984-8.006h-0.422
+ c-5.336,5.198-12.641,9.693-20.646,9.693c-17.134,0-28.232-12.922-28.232-35.674C390.167,414.019,404.214,400.253,419.805,400.253
+ z M420.93,462.194c6.319,0,11.798-3.089,17.415-9.406v-35.679c-5.758-5.197-10.956-7.164-16.573-7.164
+ c-10.956,0-19.663,10.535-19.663,26.125C402.108,452.365,408.989,462.194,420.93,462.194z"/>
+ </g>
+</g>
+</svg>
diff --git a/vendor/github.com/coreos/etcd/logos/etcd-offset-color.png b/vendor/github.com/coreos/etcd/logos/etcd-offset-color.png
new file mode 100644
index 00000000..a7f90428
Binary files /dev/null and b/vendor/github.com/coreos/etcd/logos/etcd-offset-color.png differ
diff --git a/vendor/github.com/coreos/etcd/logos/etcd-offset-color.svg b/vendor/github.com/coreos/etcd/logos/etcd-offset-color.svg
new file mode 100644
index 00000000..722cd3e0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/logos/etcd-offset-color.svg
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="299px" height="161px" viewBox="157.5 315.5 299 161" enable-background="new 157.5 315.5 299 161" xml:space="preserve">
+<g>
+ <g>
+ <path fill="#419EDA" d="M203.909,359.442c0,3.302-2.676,5.972-5.973,5.972c-3.3,0-5.97-2.67-5.97-5.972
+ c0-3.287,2.67-5.97,5.97-5.97C201.233,353.472,203.909,356.155,203.909,359.442z"/>
+ <path fill="#419EDA" d="M211.626,359.442c0,3.303,2.677,5.974,5.972,5.974c3.3,0,5.972-2.67,5.972-5.974
+ c0-3.288-2.672-5.97-5.972-5.97C214.303,353.472,211.626,356.154,211.626,359.442z"/>
+ <path fill="#419EDA" d="M252.269,365.917c-0.428,0.036-0.861,0.052-1.319,0.052c-2.662,0-5.245-0.626-7.577-1.768
+ c0.775-4.453,1.105-8.938,1.02-13.408c-2.529-3.655-5.416-7.105-8.675-10.282c1.413-2.652,3.504-4.935,6.116-6.552l1.122-0.692
+ l-0.876-0.986c-4.5-5.066-9.869-8.984-15.958-11.642l-1.215-0.528l-0.311,1.284c-0.724,2.992-2.242,5.689-4.325,7.853
+ c-4.003-2.127-8.188-3.848-12.502-5.151c-4.306,1.302-8.48,3.016-12.485,5.144c-2.075-2.162-3.587-4.857-4.31-7.838l-0.312-1.284
+ l-1.21,0.527c-6.011,2.618-11.53,6.643-15.957,11.635l-0.876,0.988l1.122,0.692c2.6,1.611,4.687,3.88,6.1,6.518
+ c-3.253,3.164-6.137,6.604-8.662,10.243c-0.1,4.466,0.214,8.983,0.994,13.496c-2.32,1.133-4.889,1.753-7.535,1.753
+ c-0.464,0-0.897-0.016-1.319-0.051l-1.318-0.103l0.124,1.315c0.645,6.643,2.709,12.963,6.135,18.785l0.67,1.135l1.004-0.85
+ c2.327-1.974,5.141-3.284,8.131-3.811c1.974,4.033,4.312,7.82,6.963,11.336c4.232,1.481,8.639,2.587,13.191,3.244
+ c0.435,3.009,0.087,6.122-1.1,9.002l-0.5,1.218l1.289,0.286c3.298,0.727,6.624,1.095,9.881,1.095l9.88-1.095l1.292-0.286
+ l-0.503-1.218c-1.184-2.882-1.532-5.998-1.096-9.012c4.535-0.657,8.925-1.758,13.141-3.234c2.654-3.518,4.994-7.31,6.97-11.347
+ c3,0.524,5.828,1.831,8.171,3.813l1.003,0.851l0.667-1.132c3.434-5.83,5.496-12.148,6.129-18.783l0.126-1.308L252.269,365.917z
+ M221.908,381.973c-4.677,1.271-9.422,1.914-14.143,1.914c-4.729,0-9.472-0.643-14.149-1.914
+ c-2.565-3.988-4.595-8.259-6.057-12.755c-1.454-4.479-2.304-9.167-2.551-13.996c3.021-3.739,6.456-7.012,10.253-9.766
+ c3.857-2.804,8.053-5.082,12.506-6.801c4.444,1.719,8.634,3.993,12.483,6.786c3.81,2.769,7.259,6.068,10.295,9.828
+ c-0.258,4.801-1.12,9.463-2.577,13.935C226.513,373.7,224.477,377.984,221.908,381.973z"/>
+ </g>
+ <g>
+ <path d="M257.854,400.253c17.417,0,27.249,12.501,27.249,32.025c0,2.391-0.141,4.636-0.419,6.319h-46.07
+ c0.841,14.75,9.688,24.019,22.751,24.019c6.463,0,11.939-2.106,16.997-5.334l4.072,7.582c-5.896,3.792-13.201,7.023-22.475,7.023
+ c-18.256,0-32.723-13.345-32.723-35.674C227.236,413.879,242.264,400.253,257.854,400.253z M274.992,431.016
+ c0-13.906-6.181-21.632-16.856-21.632c-9.553,0-18.259,7.866-19.664,21.632H274.992z"/>
+ <path d="M298.166,411.35h-10.114v-8.709l10.677-0.701l1.404-19.102h9.69v19.102h18.401v9.41h-18.401v37.923
+ c0,8.428,2.669,13.203,10.534,13.203c2.389,0,5.479-0.983,7.727-1.827l2.246,8.711c-3.793,1.265-8.428,2.528-12.642,2.528
+ c-14.607,0-19.522-9.271-19.522-22.752L298.166,411.35L298.166,411.35z"/>
+ <path d="M365.866,400.253c8.992,0,15.311,3.794,19.947,8.146l-5.759,7.447c-4.073-3.513-8.287-6.044-13.767-6.044
+ c-12.36,0-21.348,10.678-21.348,26.411c0,15.587,8.568,26.121,21.066,26.121c6.464,0,11.941-3.229,16.014-6.881l5.198,7.582
+ c-6.182,5.481-14.048,8.852-22.194,8.852c-18.117,0-32.022-13.062-32.022-35.674C333.002,413.316,348.311,400.253,365.866,400.253
+ z"/>
+ <path d="M419.805,400.253c7.865,0,13.063,2.95,19.103,7.865l-0.562-11.657v-26.266h11.657V470.2h-9.55l-0.984-8.006h-0.422
+ c-5.336,5.198-12.641,9.693-20.646,9.693c-17.134,0-28.232-12.922-28.232-35.674C390.167,414.019,404.214,400.253,419.805,400.253
+ z M420.93,462.194c6.319,0,11.798-3.089,17.415-9.406v-35.679c-5.758-5.197-10.956-7.164-16.573-7.164
+ c-10.956,0-19.663,10.535-19.663,26.125C402.108,452.365,408.989,462.194,420.93,462.194z"/>
+ </g>
+</g>
+</svg>
diff --git a/vendor/github.com/coreos/etcd/logos/etcd-stacked-bw.png b/vendor/github.com/coreos/etcd/logos/etcd-stacked-bw.png
new file mode 100644
index 00000000..ffcb379c
Binary files /dev/null and b/vendor/github.com/coreos/etcd/logos/etcd-stacked-bw.png differ
diff --git a/vendor/github.com/coreos/etcd/logos/etcd-stacked-bw.svg b/vendor/github.com/coreos/etcd/logos/etcd-stacked-bw.svg
new file mode 100644
index 00000000..7338327e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/logos/etcd-stacked-bw.svg
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="172px" height="226px" viewBox="220.5 284.5 172 226" enable-background="new 220.5 284.5 172 226" xml:space="preserve">
+<g>
+ <g>
+ <path d="M299.134,358.947c0,5.855-4.744,10.589-10.589,10.589c-5.85,0-10.581-4.734-10.581-10.589
+ c0-5.829,4.731-10.583,10.581-10.583C294.391,348.365,299.134,353.118,299.134,358.947z"/>
+ <path d="M312.817,358.947c0,5.855,4.744,10.589,10.59,10.589c5.845,0,10.584-4.734,10.584-10.589
+ c0-5.832-4.739-10.585-10.584-10.585S312.817,353.116,312.817,358.947z"/>
+ <path d="M384.875,370.425c-0.762,0.064-1.528,0.094-2.342,0.094c-4.722,0-9.303-1.108-13.435-3.136
+ c1.375-7.893,1.961-15.844,1.808-23.767c-4.48-6.48-9.601-12.596-15.381-18.229c2.508-4.702,6.215-8.747,10.843-11.616
+ l1.987-1.229l-1.549-1.747c-7.978-8.983-17.499-15.929-28.294-20.641l-2.153-0.936l-0.547,2.275
+ c-1.287,5.303-3.978,10.087-7.672,13.926c-7.101-3.774-14.518-6.825-22.167-9.134c-7.631,2.305-15.035,5.347-22.133,9.115
+ c-3.679-3.834-6.363-8.607-7.645-13.895l-0.551-2.274l-2.145,0.932c-10.659,4.645-20.443,11.778-28.29,20.628l-1.553,1.75
+ l1.986,1.229c4.613,2.857,8.31,6.879,10.813,11.556c-5.763,5.611-10.878,11.707-15.355,18.157
+ c-0.174,7.919,0.381,15.93,1.763,23.931c-4.112,2.009-8.667,3.104-13.358,3.104c-0.823,0-1.594-0.03-2.342-0.092l-2.332-0.178
+ l0.219,2.329c1.143,11.78,4.8,22.985,10.878,33.306l1.186,2.015l1.781-1.512c4.127-3.501,9.115-5.819,14.418-6.754
+ c3.497,7.148,7.64,13.864,12.34,20.1c7.5,2.623,15.315,4.581,23.385,5.746c0.774,5.337,0.157,10.857-1.948,15.962l-0.887,2.163
+ l2.283,0.503c5.847,1.286,11.745,1.94,17.521,1.94l17.516-1.94l2.286-0.503l-0.89-2.167c-2.1-5.104-2.717-10.631-1.942-15.969
+ c8.038-1.167,15.823-3.12,23.296-5.735c4.705-6.24,8.853-12.961,12.354-20.118c5.32,0.929,10.336,3.248,14.488,6.759l1.781,1.51
+ l1.181-2.009c6.088-10.334,9.745-21.538,10.87-33.299l0.219-2.324L384.875,370.425z M331.042,398.895
+ c-8.287,2.254-16.702,3.392-25.068,3.392c-8.388,0-16.793-1.138-25.087-3.392c-4.55-7.07-8.147-14.644-10.737-22.619
+ c-2.578-7.938-4.087-16.252-4.525-24.815c5.356-6.623,11.447-12.424,18.177-17.307c6.839-4.974,14.278-9.015,22.172-12.056
+ c7.881,3.041,15.307,7.076,22.129,12.029c6.756,4.91,12.874,10.756,18.256,17.42c-0.459,8.514-1.986,16.782-4.568,24.706
+ C339.208,384.226,335.599,391.824,331.042,398.895z"/>
+ </g>
+ <g>
+ <path d="M258.944,463.478c10.148,0,15.877,7.284,15.877,18.66c0,1.393-0.082,2.701-0.246,3.683H247.73
+ c0.491,8.596,5.647,13.996,13.258,13.996c3.765,0,6.958-1.228,9.905-3.109l2.373,4.419c-3.438,2.211-7.693,4.093-13.095,4.093
+ c-10.64,0-19.07-7.774-19.07-20.789C241.102,471.416,249.859,463.478,258.944,463.478z M268.927,481.401
+ c0-8.103-3.601-12.604-9.819-12.604c-5.567,0-10.64,4.584-11.458,12.604H268.927z"/>
+ <path d="M282.433,469.943h-5.892v-5.074l6.221-0.41l0.816-11.131h5.648v11.131h10.723v5.484h-10.723v22.098
+ c0,4.911,1.556,7.694,6.139,7.694c1.392,0,3.192-0.573,4.502-1.064l1.309,5.075c-2.208,0.735-4.911,1.473-7.367,1.473
+ c-8.51,0-11.376-5.402-11.376-13.26L282.433,469.943L282.433,469.943z"/>
+ <path d="M321.882,463.478c5.239,0,8.921,2.21,11.622,4.747l-3.356,4.338c-2.372-2.047-4.828-3.519-8.021-3.519
+ c-7.202,0-12.439,6.22-12.439,15.386c0,9.084,4.992,15.223,12.276,15.223c3.765,0,6.957-1.881,9.331-4.01l3.027,4.419
+ c-3.602,3.192-8.186,5.157-12.932,5.157c-10.558,0-18.661-7.611-18.661-20.789C302.729,471.089,311.65,463.478,321.882,463.478z"
+ />
+ <path d="M353.31,463.478c4.584,0,7.612,1.72,11.131,4.582l-0.327-6.793v-15.305h6.793v58.273h-5.565l-0.572-4.663h-0.245
+ c-3.109,3.027-7.366,5.646-12.032,5.646c-9.984,0-16.45-7.529-16.45-20.789C336.041,471.499,344.227,463.478,353.31,463.478z
+ M353.964,499.572c3.685,0,6.875-1.801,10.149-5.483v-20.79c-3.354-3.028-6.384-4.173-9.657-4.173
+ c-6.385,0-11.459,6.138-11.459,15.223C342.997,493.843,347.008,499.572,353.964,499.572z"/>
+ </g>
+</g>
+</svg>
diff --git a/vendor/github.com/coreos/etcd/logos/etcd-stacked-color.png b/vendor/github.com/coreos/etcd/logos/etcd-stacked-color.png
new file mode 100644
index 00000000..fa342b58
Binary files /dev/null and b/vendor/github.com/coreos/etcd/logos/etcd-stacked-color.png differ
diff --git a/vendor/github.com/coreos/etcd/logos/etcd-stacked-color.svg b/vendor/github.com/coreos/etcd/logos/etcd-stacked-color.svg
new file mode 100644
index 00000000..c73fd37f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/logos/etcd-stacked-color.svg
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="172px" height="226px" viewBox="220.5 284.5 172 226" enable-background="new 220.5 284.5 172 226" xml:space="preserve">
+<g>
+ <g>
+ <path fill="#419EDA" d="M299.134,358.947c0,5.855-4.744,10.589-10.589,10.589c-5.85,0-10.581-4.734-10.581-10.589
+ c0-5.829,4.731-10.583,10.581-10.583C294.391,348.365,299.134,353.118,299.134,358.947z"/>
+ <path fill="#419EDA" d="M312.817,358.947c0,5.855,4.744,10.589,10.59,10.589c5.845,0,10.584-4.734,10.584-10.589
+ c0-5.832-4.739-10.585-10.584-10.585S312.817,353.116,312.817,358.947z"/>
+ <path fill="#419EDA" d="M384.875,370.425c-0.762,0.064-1.528,0.094-2.342,0.094c-4.722,0-9.303-1.108-13.435-3.136
+ c1.375-7.893,1.961-15.844,1.808-23.767c-4.48-6.48-9.601-12.596-15.381-18.229c2.508-4.702,6.215-8.747,10.843-11.616
+ l1.987-1.229l-1.549-1.747c-7.978-8.983-17.499-15.929-28.294-20.641l-2.153-0.936l-0.547,2.275
+ c-1.287,5.303-3.978,10.087-7.672,13.926c-7.101-3.774-14.518-6.825-22.167-9.134c-7.631,2.305-15.035,5.347-22.133,9.115
+ c-3.679-3.834-6.363-8.607-7.645-13.895l-0.551-2.274l-2.145,0.932c-10.659,4.645-20.443,11.778-28.29,20.628l-1.553,1.75
+ l1.986,1.229c4.613,2.857,8.31,6.879,10.813,11.556c-5.763,5.611-10.878,11.707-15.355,18.157
+ c-0.174,7.919,0.381,15.93,1.763,23.931c-4.112,2.009-8.667,3.104-13.358,3.104c-0.823,0-1.594-0.03-2.342-0.092l-2.332-0.178
+ l0.219,2.329c1.143,11.78,4.8,22.985,10.878,33.306l1.186,2.015l1.781-1.512c4.127-3.501,9.115-5.819,14.418-6.754
+ c3.497,7.148,7.64,13.864,12.34,20.1c7.5,2.623,15.315,4.581,23.385,5.746c0.774,5.337,0.157,10.857-1.948,15.962l-0.887,2.163
+ l2.283,0.503c5.847,1.286,11.745,1.94,17.521,1.94l17.516-1.94l2.286-0.503l-0.89-2.167c-2.1-5.104-2.717-10.631-1.942-15.969
+ c8.038-1.167,15.823-3.12,23.296-5.735c4.705-6.24,8.853-12.961,12.354-20.118c5.32,0.929,10.336,3.248,14.488,6.759l1.781,1.51
+ l1.181-2.009c6.088-10.334,9.745-21.538,10.87-33.299l0.219-2.324L384.875,370.425z M331.042,398.895
+ c-8.287,2.254-16.702,3.392-25.068,3.392c-8.388,0-16.793-1.138-25.087-3.392c-4.55-7.07-8.147-14.644-10.737-22.619
+ c-2.578-7.938-4.087-16.252-4.525-24.815c5.356-6.623,11.447-12.424,18.177-17.307c6.839-4.974,14.278-9.015,22.172-12.056
+ c7.881,3.041,15.307,7.076,22.129,12.029c6.756,4.91,12.874,10.756,18.256,17.42c-0.459,8.514-1.986,16.782-4.568,24.706
+ C339.208,384.226,335.599,391.824,331.042,398.895z"/>
+ </g>
+ <g>
+ <path d="M258.944,463.478c10.148,0,15.877,7.284,15.877,18.66c0,1.393-0.082,2.701-0.246,3.683H247.73
+ c0.491,8.596,5.647,13.996,13.258,13.996c3.765,0,6.958-1.228,9.905-3.109l2.373,4.419c-3.438,2.211-7.693,4.093-13.095,4.093
+ c-10.64,0-19.07-7.774-19.07-20.789C241.102,471.416,249.859,463.478,258.944,463.478z M268.927,481.401
+ c0-8.103-3.601-12.604-9.819-12.604c-5.567,0-10.64,4.584-11.458,12.604H268.927z"/>
+ <path d="M282.433,469.943h-5.892v-5.074l6.221-0.41l0.816-11.131h5.648v11.131h10.723v5.484h-10.723v22.098
+ c0,4.911,1.556,7.694,6.139,7.694c1.392,0,3.192-0.573,4.502-1.064l1.309,5.075c-2.208,0.735-4.911,1.473-7.367,1.473
+ c-8.51,0-11.376-5.402-11.376-13.26L282.433,469.943L282.433,469.943z"/>
+ <path d="M321.882,463.478c5.239,0,8.921,2.21,11.622,4.747l-3.356,4.338c-2.372-2.047-4.828-3.519-8.021-3.519
+ c-7.202,0-12.439,6.22-12.439,15.386c0,9.084,4.992,15.223,12.276,15.223c3.765,0,6.957-1.881,9.331-4.01l3.027,4.419
+ c-3.602,3.192-8.186,5.157-12.932,5.157c-10.558,0-18.661-7.611-18.661-20.789C302.729,471.089,311.65,463.478,321.882,463.478z"
+ />
+ <path d="M353.31,463.478c4.584,0,7.612,1.72,11.131,4.582l-0.327-6.793v-15.305h6.793v58.273h-5.565l-0.572-4.663h-0.245
+ c-3.109,3.027-7.366,5.646-12.032,5.646c-9.984,0-16.45-7.529-16.45-20.789C336.041,471.499,344.227,463.478,353.31,463.478z
+ M353.964,499.572c3.685,0,6.875-1.801,10.149-5.483v-20.79c-3.354-3.028-6.384-4.173-9.657-4.173
+ c-6.385,0-11.459,6.138-11.459,15.223C342.997,493.843,347.008,499.572,353.964,499.572z"/>
+ </g>
+</g>
+</svg>
diff --git a/vendor/github.com/coreos/etcd/main.go b/vendor/github.com/coreos/etcd/main.go
new file mode 100644
index 00000000..0b735737
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/main.go
@@ -0,0 +1,29 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 is a simple wrapper of the real etcd entrypoint package
+// (located at github.com/coreos/etcd/etcdmain) to ensure that etcd is still
+// "go getable"; e.g. `go get github.com/coreos/etcd` works as expected and
+// builds a binary in $GOBIN/etcd
+//
+// This package should NOT be extended or modified in any way; to modify the
+// etcd binary, work in the `github.com/coreos/etcd/etcdmain` package.
+//
+package main
+
+import "github.com/coreos/etcd/etcdmain"
+
+func main() {
+ etcdmain.Main()
+}
diff --git a/vendor/github.com/coreos/etcd/main_test.go b/vendor/github.com/coreos/etcd/main_test.go
new file mode 100644
index 00000000..371ff1d0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/main_test.go
@@ -0,0 +1,35 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 (
+ "os"
+ "os/signal"
+ "strings"
+ "syscall"
+ "testing"
+)
+
+func TestMain(t *testing.T) {
+ // don't launch etcd server when invoked via go test
+ if strings.HasSuffix(os.Args[0], "etcd.test") {
+ return
+ }
+
+ notifier := make(chan os.Signal, 1)
+ signal.Notify(notifier, syscall.SIGINT, syscall.SIGTERM)
+ go main()
+ <-notifier
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/backend/backend.go b/vendor/github.com/coreos/etcd/mvcc/backend/backend.go
new file mode 100644
index 00000000..62a831ad
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/backend/backend.go
@@ -0,0 +1,443 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 backend
+
+import (
+ "fmt"
+ "hash/crc32"
+ "io"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "sync"
+ "sync/atomic"
+ "time"
+
+ "github.com/boltdb/bolt"
+ "github.com/coreos/pkg/capnslog"
+)
+
+var (
+ defaultBatchLimit = 10000
+ defaultBatchInterval = 100 * time.Millisecond
+
+ defragLimit = 10000
+
+ // initialMmapSize is the initial size of the mmapped region. Setting this larger than
+ // the potential max db size can prevent writer from blocking reader.
+ // This only works for linux.
+ initialMmapSize = uint64(10 * 1024 * 1024 * 1024)
+
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "mvcc/backend")
+
+ // minSnapshotWarningTimeout is the minimum threshold to trigger a long running snapshot warning.
+ minSnapshotWarningTimeout = time.Duration(30 * time.Second)
+)
+
+type Backend interface {
+ ReadTx() ReadTx
+ BatchTx() BatchTx
+
+ Snapshot() Snapshot
+ Hash(ignores map[IgnoreKey]struct{}) (uint32, error)
+ // Size returns the current size of the backend.
+ Size() int64
+ Defrag() error
+ ForceCommit()
+ Close() error
+}
+
+type Snapshot interface {
+ // Size gets the size of the snapshot.
+ Size() int64
+ // WriteTo writes the snapshot into the given writer.
+ WriteTo(w io.Writer) (n int64, err error)
+ // Close closes the snapshot.
+ Close() error
+}
+
+type backend struct {
+ // size and commits are used with atomic operations so they must be
+ // 64-bit aligned, otherwise 32-bit tests will crash
+
+ // size is the number of bytes in the backend
+ size int64
+ // commits counts number of commits since start
+ commits int64
+
+ mu sync.RWMutex
+ db *bolt.DB
+
+ batchInterval time.Duration
+ batchLimit int
+ batchTx *batchTxBuffered
+
+ readTx *readTx
+
+ stopc chan struct{}
+ donec chan struct{}
+}
+
+type BackendConfig struct {
+ // Path is the file path to the backend file.
+ Path string
+ // BatchInterval is the maximum time before flushing the BatchTx.
+ BatchInterval time.Duration
+ // BatchLimit is the maximum puts before flushing the BatchTx.
+ BatchLimit int
+ // MmapSize is the number of bytes to mmap for the backend.
+ MmapSize uint64
+}
+
+func DefaultBackendConfig() BackendConfig {
+ return BackendConfig{
+ BatchInterval: defaultBatchInterval,
+ BatchLimit: defaultBatchLimit,
+ MmapSize: initialMmapSize,
+ }
+}
+
+func New(bcfg BackendConfig) Backend {
+ return newBackend(bcfg)
+}
+
+func NewDefaultBackend(path string) Backend {
+ bcfg := DefaultBackendConfig()
+ bcfg.Path = path
+ return newBackend(bcfg)
+}
+
+func newBackend(bcfg BackendConfig) *backend {
+ bopts := &bolt.Options{}
+ if boltOpenOptions != nil {
+ *bopts = *boltOpenOptions
+ }
+ bopts.InitialMmapSize = bcfg.mmapSize()
+
+ db, err := bolt.Open(bcfg.Path, 0600, bopts)
+ if err != nil {
+ plog.Panicf("cannot open database at %s (%v)", bcfg.Path, err)
+ }
+
+ // In future, may want to make buffering optional for low-concurrency systems
+ // or dynamically swap between buffered/non-buffered depending on workload.
+ b := &backend{
+ db: db,
+
+ batchInterval: bcfg.BatchInterval,
+ batchLimit: bcfg.BatchLimit,
+
+ readTx: &readTx{buf: txReadBuffer{
+ txBuffer: txBuffer{make(map[string]*bucketBuffer)}},
+ },
+
+ stopc: make(chan struct{}),
+ donec: make(chan struct{}),
+ }
+ b.batchTx = newBatchTxBuffered(b)
+ go b.run()
+ return b
+}
+
+// BatchTx returns the current batch tx in coalescer. The tx can be used for read and
+// write operations. The write result can be retrieved within the same tx immediately.
+// The write result is isolated with other txs until the current one get committed.
+func (b *backend) BatchTx() BatchTx {
+ return b.batchTx
+}
+
+func (b *backend) ReadTx() ReadTx { return b.readTx }
+
+// ForceCommit forces the current batching tx to commit.
+func (b *backend) ForceCommit() {
+ b.batchTx.Commit()
+}
+
+func (b *backend) Snapshot() Snapshot {
+ b.batchTx.Commit()
+
+ b.mu.RLock()
+ defer b.mu.RUnlock()
+ tx, err := b.db.Begin(false)
+ if err != nil {
+ plog.Fatalf("cannot begin tx (%s)", err)
+ }
+
+ stopc, donec := make(chan struct{}), make(chan struct{})
+ dbBytes := tx.Size()
+ go func() {
+ defer close(donec)
+ // sendRateBytes is based on transferring snapshot data over a 1 gigabit/s connection
+ // assuming a min tcp throughput of 100MB/s.
+ var sendRateBytes int64 = 100 * 1024 * 1014
+ warningTimeout := time.Duration(int64((float64(dbBytes) / float64(sendRateBytes)) * float64(time.Second)))
+ if warningTimeout < minSnapshotWarningTimeout {
+ warningTimeout = minSnapshotWarningTimeout
+ }
+ start := time.Now()
+ ticker := time.NewTicker(warningTimeout)
+ defer ticker.Stop()
+ for {
+ select {
+ case <-ticker.C:
+ plog.Warningf("snapshotting is taking more than %v seconds to finish transferring %v MB [started at %v]", time.Since(start).Seconds(), float64(dbBytes)/float64(1024*1014), start)
+ case <-stopc:
+ snapshotDurations.Observe(time.Since(start).Seconds())
+ return
+ }
+ }
+ }()
+
+ return &snapshot{tx, stopc, donec}
+}
+
+type IgnoreKey struct {
+ Bucket string
+ Key string
+}
+
+func (b *backend) Hash(ignores map[IgnoreKey]struct{}) (uint32, error) {
+ h := crc32.New(crc32.MakeTable(crc32.Castagnoli))
+
+ b.mu.RLock()
+ defer b.mu.RUnlock()
+ err := b.db.View(func(tx *bolt.Tx) error {
+ c := tx.Cursor()
+ for next, _ := c.First(); next != nil; next, _ = c.Next() {
+ b := tx.Bucket(next)
+ if b == nil {
+ return fmt.Errorf("cannot get hash of bucket %s", string(next))
+ }
+ h.Write(next)
+ b.ForEach(func(k, v []byte) error {
+ bk := IgnoreKey{Bucket: string(next), Key: string(k)}
+ if _, ok := ignores[bk]; !ok {
+ h.Write(k)
+ h.Write(v)
+ }
+ return nil
+ })
+ }
+ return nil
+ })
+
+ if err != nil {
+ return 0, err
+ }
+
+ return h.Sum32(), nil
+}
+
+func (b *backend) Size() int64 {
+ return atomic.LoadInt64(&b.size)
+}
+
+func (b *backend) run() {
+ defer close(b.donec)
+ t := time.NewTimer(b.batchInterval)
+ defer t.Stop()
+ for {
+ select {
+ case <-t.C:
+ case <-b.stopc:
+ b.batchTx.CommitAndStop()
+ return
+ }
+ b.batchTx.Commit()
+ t.Reset(b.batchInterval)
+ }
+}
+
+func (b *backend) Close() error {
+ close(b.stopc)
+ <-b.donec
+ return b.db.Close()
+}
+
+// Commits returns total number of commits since start
+func (b *backend) Commits() int64 {
+ return atomic.LoadInt64(&b.commits)
+}
+
+func (b *backend) Defrag() error {
+ err := b.defrag()
+ if err != nil {
+ return err
+ }
+
+ // commit to update metadata like db.size
+ b.batchTx.Commit()
+
+ return nil
+}
+
+func (b *backend) defrag() error {
+ // TODO: make this non-blocking?
+ // lock batchTx to ensure nobody is using previous tx, and then
+ // close previous ongoing tx.
+ b.batchTx.Lock()
+ defer b.batchTx.Unlock()
+
+ // lock database after lock tx to avoid deadlock.
+ b.mu.Lock()
+ defer b.mu.Unlock()
+
+ // block concurrent read requests while resetting tx
+ b.readTx.mu.Lock()
+ defer b.readTx.mu.Unlock()
+
+ b.batchTx.unsafeCommit(true)
+ b.batchTx.tx = nil
+
+ tmpdb, err := bolt.Open(b.db.Path()+".tmp", 0600, boltOpenOptions)
+ if err != nil {
+ return err
+ }
+
+ err = defragdb(b.db, tmpdb, defragLimit)
+
+ if err != nil {
+ tmpdb.Close()
+ os.RemoveAll(tmpdb.Path())
+ return err
+ }
+
+ dbp := b.db.Path()
+ tdbp := tmpdb.Path()
+
+ err = b.db.Close()
+ if err != nil {
+ plog.Fatalf("cannot close database (%s)", err)
+ }
+ err = tmpdb.Close()
+ if err != nil {
+ plog.Fatalf("cannot close database (%s)", err)
+ }
+ err = os.Rename(tdbp, dbp)
+ if err != nil {
+ plog.Fatalf("cannot rename database (%s)", err)
+ }
+
+ b.db, err = bolt.Open(dbp, 0600, boltOpenOptions)
+ if err != nil {
+ plog.Panicf("cannot open database at %s (%v)", dbp, err)
+ }
+ b.batchTx.tx, err = b.db.Begin(true)
+ if err != nil {
+ plog.Fatalf("cannot begin tx (%s)", err)
+ }
+
+ b.readTx.buf.reset()
+ b.readTx.tx = b.unsafeBegin(false)
+ atomic.StoreInt64(&b.size, b.readTx.tx.Size())
+
+ return nil
+}
+
+func defragdb(odb, tmpdb *bolt.DB, limit int) error {
+ // open a tx on tmpdb for writes
+ tmptx, err := tmpdb.Begin(true)
+ if err != nil {
+ return err
+ }
+
+ // open a tx on old db for read
+ tx, err := odb.Begin(false)
+ if err != nil {
+ return err
+ }
+ defer tx.Rollback()
+
+ c := tx.Cursor()
+
+ count := 0
+ for next, _ := c.First(); next != nil; next, _ = c.Next() {
+ b := tx.Bucket(next)
+ if b == nil {
+ return fmt.Errorf("backend: cannot defrag bucket %s", string(next))
+ }
+
+ tmpb, berr := tmptx.CreateBucketIfNotExists(next)
+ tmpb.FillPercent = 0.9 // for seq write in for each
+ if berr != nil {
+ return berr
+ }
+
+ b.ForEach(func(k, v []byte) error {
+ count++
+ if count > limit {
+ err = tmptx.Commit()
+ if err != nil {
+ return err
+ }
+ tmptx, err = tmpdb.Begin(true)
+ if err != nil {
+ return err
+ }
+ tmpb = tmptx.Bucket(next)
+ tmpb.FillPercent = 0.9 // for seq write in for each
+
+ count = 0
+ }
+ return tmpb.Put(k, v)
+ })
+ }
+
+ return tmptx.Commit()
+}
+
+func (b *backend) begin(write bool) *bolt.Tx {
+ b.mu.RLock()
+ tx := b.unsafeBegin(write)
+ b.mu.RUnlock()
+ atomic.StoreInt64(&b.size, tx.Size())
+ return tx
+}
+
+func (b *backend) unsafeBegin(write bool) *bolt.Tx {
+ tx, err := b.db.Begin(write)
+ if err != nil {
+ plog.Fatalf("cannot begin tx (%s)", err)
+ }
+ return tx
+}
+
+// NewTmpBackend creates a backend implementation for testing.
+func NewTmpBackend(batchInterval time.Duration, batchLimit int) (*backend, string) {
+ dir, err := ioutil.TempDir(os.TempDir(), "etcd_backend_test")
+ if err != nil {
+ plog.Fatal(err)
+ }
+ tmpPath := filepath.Join(dir, "database")
+ bcfg := DefaultBackendConfig()
+ bcfg.Path, bcfg.BatchInterval, bcfg.BatchLimit = tmpPath, batchInterval, batchLimit
+ return newBackend(bcfg), tmpPath
+}
+
+func NewDefaultTmpBackend() (*backend, string) {
+ return NewTmpBackend(defaultBatchInterval, defaultBatchLimit)
+}
+
+type snapshot struct {
+ *bolt.Tx
+ stopc chan struct{}
+ donec chan struct{}
+}
+
+func (s *snapshot) Close() error {
+ close(s.stopc)
+ <-s.donec
+ return s.Tx.Rollback()
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/backend/backend_bench_test.go b/vendor/github.com/coreos/etcd/mvcc/backend/backend_bench_test.go
new file mode 100644
index 00000000..30b47516
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/backend/backend_bench_test.go
@@ -0,0 +1,50 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 backend
+
+import (
+ "crypto/rand"
+ "os"
+ "testing"
+ "time"
+)
+
+func BenchmarkBackendPut(b *testing.B) {
+ backend, tmppath := NewTmpBackend(100*time.Millisecond, 10000)
+ defer backend.Close()
+ defer os.Remove(tmppath)
+
+ // prepare keys
+ keys := make([][]byte, b.N)
+ for i := 0; i < b.N; i++ {
+ keys[i] = make([]byte, 64)
+ rand.Read(keys[i])
+ }
+ value := make([]byte, 128)
+ rand.Read(value)
+
+ batchTx := backend.BatchTx()
+
+ batchTx.Lock()
+ batchTx.UnsafeCreateBucket([]byte("test"))
+ batchTx.Unlock()
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ batchTx.Lock()
+ batchTx.UnsafePut([]byte("test"), keys[i], value)
+ batchTx.Unlock()
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/backend/backend_test.go b/vendor/github.com/coreos/etcd/mvcc/backend/backend_test.go
new file mode 100644
index 00000000..af898b5a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/backend/backend_test.go
@@ -0,0 +1,256 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 backend
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/boltdb/bolt"
+)
+
+func TestBackendClose(t *testing.T) {
+ b, tmpPath := NewTmpBackend(time.Hour, 10000)
+ defer os.Remove(tmpPath)
+
+ // check close could work
+ done := make(chan struct{})
+ go func() {
+ err := b.Close()
+ if err != nil {
+ t.Errorf("close error = %v, want nil", err)
+ }
+ done <- struct{}{}
+ }()
+ select {
+ case <-done:
+ case <-time.After(10 * time.Second):
+ t.Errorf("failed to close database in 10s")
+ }
+}
+
+func TestBackendSnapshot(t *testing.T) {
+ b, tmpPath := NewTmpBackend(time.Hour, 10000)
+ defer cleanup(b, tmpPath)
+
+ tx := b.BatchTx()
+ tx.Lock()
+ tx.UnsafeCreateBucket([]byte("test"))
+ tx.UnsafePut([]byte("test"), []byte("foo"), []byte("bar"))
+ tx.Unlock()
+ b.ForceCommit()
+
+ // write snapshot to a new file
+ f, err := ioutil.TempFile(os.TempDir(), "etcd_backend_test")
+ if err != nil {
+ t.Fatal(err)
+ }
+ snap := b.Snapshot()
+ defer snap.Close()
+ if _, err := snap.WriteTo(f); err != nil {
+ t.Fatal(err)
+ }
+ f.Close()
+
+ // bootstrap new backend from the snapshot
+ bcfg := DefaultBackendConfig()
+ bcfg.Path, bcfg.BatchInterval, bcfg.BatchLimit = f.Name(), time.Hour, 10000
+ nb := New(bcfg)
+ defer cleanup(nb, f.Name())
+
+ newTx := b.BatchTx()
+ newTx.Lock()
+ ks, _ := newTx.UnsafeRange([]byte("test"), []byte("foo"), []byte("goo"), 0)
+ if len(ks) != 1 {
+ t.Errorf("len(kvs) = %d, want 1", len(ks))
+ }
+ newTx.Unlock()
+}
+
+func TestBackendBatchIntervalCommit(t *testing.T) {
+ // start backend with super short batch interval so
+ // we do not need to wait long before commit to happen.
+ b, tmpPath := NewTmpBackend(time.Nanosecond, 10000)
+ defer cleanup(b, tmpPath)
+
+ pc := b.Commits()
+
+ tx := b.BatchTx()
+ tx.Lock()
+ tx.UnsafeCreateBucket([]byte("test"))
+ tx.UnsafePut([]byte("test"), []byte("foo"), []byte("bar"))
+ tx.Unlock()
+
+ for i := 0; i < 10; i++ {
+ if b.Commits() >= pc+1 {
+ break
+ }
+ time.Sleep(time.Duration(i*100) * time.Millisecond)
+ }
+
+ // check whether put happens via db view
+ b.db.View(func(tx *bolt.Tx) error {
+ bucket := tx.Bucket([]byte("test"))
+ if bucket == nil {
+ t.Errorf("bucket test does not exit")
+ return nil
+ }
+ v := bucket.Get([]byte("foo"))
+ if v == nil {
+ t.Errorf("foo key failed to written in backend")
+ }
+ return nil
+ })
+}
+
+func TestBackendDefrag(t *testing.T) {
+ b, tmpPath := NewDefaultTmpBackend()
+ defer cleanup(b, tmpPath)
+
+ tx := b.BatchTx()
+ tx.Lock()
+ tx.UnsafeCreateBucket([]byte("test"))
+ for i := 0; i < defragLimit+100; i++ {
+ tx.UnsafePut([]byte("test"), []byte(fmt.Sprintf("foo_%d", i)), []byte("bar"))
+ }
+ tx.Unlock()
+ b.ForceCommit()
+
+ // remove some keys to ensure the disk space will be reclaimed after defrag
+ tx = b.BatchTx()
+ tx.Lock()
+ for i := 0; i < 50; i++ {
+ tx.UnsafeDelete([]byte("test"), []byte(fmt.Sprintf("foo_%d", i)))
+ }
+ tx.Unlock()
+ b.ForceCommit()
+
+ size := b.Size()
+
+ // shrink and check hash
+ oh, err := b.Hash(nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ err = b.Defrag()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ nh, err := b.Hash(nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if oh != nh {
+ t.Errorf("hash = %v, want %v", nh, oh)
+ }
+
+ nsize := b.Size()
+ if nsize >= size {
+ t.Errorf("new size = %v, want < %d", nsize, size)
+ }
+
+ // try put more keys after shrink.
+ tx = b.BatchTx()
+ tx.Lock()
+ tx.UnsafeCreateBucket([]byte("test"))
+ tx.UnsafePut([]byte("test"), []byte("more"), []byte("bar"))
+ tx.Unlock()
+ b.ForceCommit()
+}
+
+// TestBackendWriteback ensures writes are stored to the read txn on write txn unlock.
+func TestBackendWriteback(t *testing.T) {
+ b, tmpPath := NewDefaultTmpBackend()
+ defer cleanup(b, tmpPath)
+
+ tx := b.BatchTx()
+ tx.Lock()
+ tx.UnsafeCreateBucket([]byte("key"))
+ tx.UnsafePut([]byte("key"), []byte("abc"), []byte("bar"))
+ tx.UnsafePut([]byte("key"), []byte("def"), []byte("baz"))
+ tx.UnsafePut([]byte("key"), []byte("overwrite"), []byte("1"))
+ tx.Unlock()
+
+ // overwrites should be propagated too
+ tx.Lock()
+ tx.UnsafePut([]byte("key"), []byte("overwrite"), []byte("2"))
+ tx.Unlock()
+
+ keys := []struct {
+ key []byte
+ end []byte
+ limit int64
+
+ wkey [][]byte
+ wval [][]byte
+ }{
+ {
+ key: []byte("abc"),
+ end: nil,
+
+ wkey: [][]byte{[]byte("abc")},
+ wval: [][]byte{[]byte("bar")},
+ },
+ {
+ key: []byte("abc"),
+ end: []byte("def"),
+
+ wkey: [][]byte{[]byte("abc")},
+ wval: [][]byte{[]byte("bar")},
+ },
+ {
+ key: []byte("abc"),
+ end: []byte("deg"),
+
+ wkey: [][]byte{[]byte("abc"), []byte("def")},
+ wval: [][]byte{[]byte("bar"), []byte("baz")},
+ },
+ {
+ key: []byte("abc"),
+ end: []byte("\xff"),
+ limit: 1,
+
+ wkey: [][]byte{[]byte("abc")},
+ wval: [][]byte{[]byte("bar")},
+ },
+ {
+ key: []byte("abc"),
+ end: []byte("\xff"),
+
+ wkey: [][]byte{[]byte("abc"), []byte("def"), []byte("overwrite")},
+ wval: [][]byte{[]byte("bar"), []byte("baz"), []byte("2")},
+ },
+ }
+ rtx := b.ReadTx()
+ for i, tt := range keys {
+ rtx.Lock()
+ k, v := rtx.UnsafeRange([]byte("key"), tt.key, tt.end, tt.limit)
+ rtx.Unlock()
+ if !reflect.DeepEqual(tt.wkey, k) || !reflect.DeepEqual(tt.wval, v) {
+ t.Errorf("#%d: want k=%+v, v=%+v; got k=%+v, v=%+v", i, tt.wkey, tt.wval, k, v)
+ }
+ }
+}
+
+func cleanup(b Backend, path string) {
+ b.Close()
+ os.Remove(path)
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/backend/batch_tx.go b/vendor/github.com/coreos/etcd/mvcc/backend/batch_tx.go
new file mode 100644
index 00000000..a47f67d4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/backend/batch_tx.go
@@ -0,0 +1,266 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 backend
+
+import (
+ "bytes"
+ "fmt"
+ "math"
+ "sync"
+ "sync/atomic"
+ "time"
+
+ "github.com/boltdb/bolt"
+)
+
+type BatchTx interface {
+ ReadTx
+ UnsafeCreateBucket(name []byte)
+ UnsafePut(bucketName []byte, key []byte, value []byte)
+ UnsafeSeqPut(bucketName []byte, key []byte, value []byte)
+ UnsafeDelete(bucketName []byte, key []byte)
+ // Commit commits a previous tx and begins a new writable one.
+ Commit()
+ // CommitAndStop commits the previous tx and does not create a new one.
+ CommitAndStop()
+}
+
+type batchTx struct {
+ sync.Mutex
+ tx *bolt.Tx
+ backend *backend
+
+ pending int
+}
+
+func (t *batchTx) UnsafeCreateBucket(name []byte) {
+ _, err := t.tx.CreateBucket(name)
+ if err != nil && err != bolt.ErrBucketExists {
+ plog.Fatalf("cannot create bucket %s (%v)", name, err)
+ }
+ t.pending++
+}
+
+// UnsafePut must be called holding the lock on the tx.
+func (t *batchTx) UnsafePut(bucketName []byte, key []byte, value []byte) {
+ t.unsafePut(bucketName, key, value, false)
+}
+
+// UnsafeSeqPut must be called holding the lock on the tx.
+func (t *batchTx) UnsafeSeqPut(bucketName []byte, key []byte, value []byte) {
+ t.unsafePut(bucketName, key, value, true)
+}
+
+func (t *batchTx) unsafePut(bucketName []byte, key []byte, value []byte, seq bool) {
+ bucket := t.tx.Bucket(bucketName)
+ if bucket == nil {
+ plog.Fatalf("bucket %s does not exist", bucketName)
+ }
+ if seq {
+ // it is useful to increase fill percent when the workloads are mostly append-only.
+ // this can delay the page split and reduce space usage.
+ bucket.FillPercent = 0.9
+ }
+ if err := bucket.Put(key, value); err != nil {
+ plog.Fatalf("cannot put key into bucket (%v)", err)
+ }
+ t.pending++
+}
+
+// UnsafeRange must be called holding the lock on the tx.
+func (t *batchTx) UnsafeRange(bucketName, key, endKey []byte, limit int64) ([][]byte, [][]byte) {
+ k, v, err := unsafeRange(t.tx, bucketName, key, endKey, limit)
+ if err != nil {
+ plog.Fatal(err)
+ }
+ return k, v
+}
+
+func unsafeRange(tx *bolt.Tx, bucketName, key, endKey []byte, limit int64) (keys [][]byte, vs [][]byte, err error) {
+ bucket := tx.Bucket(bucketName)
+ if bucket == nil {
+ return nil, nil, fmt.Errorf("bucket %s does not exist", bucketName)
+ }
+ if len(endKey) == 0 {
+ if v := bucket.Get(key); v != nil {
+ return append(keys, key), append(vs, v), nil
+ }
+ return nil, nil, nil
+ }
+ if limit <= 0 {
+ limit = math.MaxInt64
+ }
+ c := bucket.Cursor()
+ for ck, cv := c.Seek(key); ck != nil && bytes.Compare(ck, endKey) < 0; ck, cv = c.Next() {
+ vs = append(vs, cv)
+ keys = append(keys, ck)
+ if limit == int64(len(keys)) {
+ break
+ }
+ }
+ return keys, vs, nil
+}
+
+// UnsafeDelete must be called holding the lock on the tx.
+func (t *batchTx) UnsafeDelete(bucketName []byte, key []byte) {
+ bucket := t.tx.Bucket(bucketName)
+ if bucket == nil {
+ plog.Fatalf("bucket %s does not exist", bucketName)
+ }
+ err := bucket.Delete(key)
+ if err != nil {
+ plog.Fatalf("cannot delete key from bucket (%v)", err)
+ }
+ t.pending++
+}
+
+// UnsafeForEach must be called holding the lock on the tx.
+func (t *batchTx) UnsafeForEach(bucketName []byte, visitor func(k, v []byte) error) error {
+ return unsafeForEach(t.tx, bucketName, visitor)
+}
+
+func unsafeForEach(tx *bolt.Tx, bucket []byte, visitor func(k, v []byte) error) error {
+ if b := tx.Bucket(bucket); b != nil {
+ return b.ForEach(visitor)
+ }
+ return nil
+}
+
+// Commit commits a previous tx and begins a new writable one.
+func (t *batchTx) Commit() {
+ t.Lock()
+ defer t.Unlock()
+ t.commit(false)
+}
+
+// CommitAndStop commits the previous tx and does not create a new one.
+func (t *batchTx) CommitAndStop() {
+ t.Lock()
+ defer t.Unlock()
+ t.commit(true)
+}
+
+func (t *batchTx) Unlock() {
+ if t.pending >= t.backend.batchLimit {
+ t.commit(false)
+ }
+ t.Mutex.Unlock()
+}
+
+func (t *batchTx) commit(stop bool) {
+ // commit the last tx
+ if t.tx != nil {
+ if t.pending == 0 && !stop {
+ t.backend.mu.RLock()
+ defer t.backend.mu.RUnlock()
+
+ // t.tx.DB()==nil if 'CommitAndStop' calls 'batchTx.commit(true)',
+ // which initializes *bolt.Tx.db and *bolt.Tx.meta as nil; panics t.tx.Size().
+ // Server must make sure 'batchTx.commit(false)' does not follow
+ // 'batchTx.commit(true)' (e.g. stopping backend, and inflight Hash call).
+ atomic.StoreInt64(&t.backend.size, t.tx.Size())
+ return
+ }
+
+ start := time.Now()
+ // gofail: var beforeCommit struct{}
+ err := t.tx.Commit()
+ // gofail: var afterCommit struct{}
+ commitDurations.Observe(time.Since(start).Seconds())
+ atomic.AddInt64(&t.backend.commits, 1)
+
+ t.pending = 0
+ if err != nil {
+ plog.Fatalf("cannot commit tx (%s)", err)
+ }
+ }
+ if !stop {
+ t.tx = t.backend.begin(true)
+ }
+}
+
+type batchTxBuffered struct {
+ batchTx
+ buf txWriteBuffer
+}
+
+func newBatchTxBuffered(backend *backend) *batchTxBuffered {
+ tx := &batchTxBuffered{
+ batchTx: batchTx{backend: backend},
+ buf: txWriteBuffer{
+ txBuffer: txBuffer{make(map[string]*bucketBuffer)},
+ seq: true,
+ },
+ }
+ tx.Commit()
+ return tx
+}
+
+func (t *batchTxBuffered) Unlock() {
+ if t.pending != 0 {
+ t.backend.readTx.mu.Lock()
+ t.buf.writeback(&t.backend.readTx.buf)
+ t.backend.readTx.mu.Unlock()
+ if t.pending >= t.backend.batchLimit {
+ t.commit(false)
+ }
+ }
+ t.batchTx.Unlock()
+}
+
+func (t *batchTxBuffered) Commit() {
+ t.Lock()
+ defer t.Unlock()
+ t.commit(false)
+}
+
+func (t *batchTxBuffered) CommitAndStop() {
+ t.Lock()
+ defer t.Unlock()
+ t.commit(true)
+}
+
+func (t *batchTxBuffered) commit(stop bool) {
+ // all read txs must be closed to acquire boltdb commit rwlock
+ t.backend.readTx.mu.Lock()
+ defer t.backend.readTx.mu.Unlock()
+ t.unsafeCommit(stop)
+}
+
+func (t *batchTxBuffered) unsafeCommit(stop bool) {
+ if t.backend.readTx.tx != nil {
+ if err := t.backend.readTx.tx.Rollback(); err != nil {
+ plog.Fatalf("cannot rollback tx (%s)", err)
+ }
+ t.backend.readTx.buf.reset()
+ t.backend.readTx.tx = nil
+ }
+
+ t.batchTx.commit(stop)
+
+ if !stop {
+ t.backend.readTx.tx = t.backend.begin(false)
+ }
+}
+
+func (t *batchTxBuffered) UnsafePut(bucketName []byte, key []byte, value []byte) {
+ t.batchTx.UnsafePut(bucketName, key, value)
+ t.buf.put(bucketName, key, value)
+}
+
+func (t *batchTxBuffered) UnsafeSeqPut(bucketName []byte, key []byte, value []byte) {
+ t.batchTx.UnsafeSeqPut(bucketName, key, value)
+ t.buf.putSeq(bucketName, key, value)
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/backend/batch_tx_test.go b/vendor/github.com/coreos/etcd/mvcc/backend/batch_tx_test.go
new file mode 100644
index 00000000..582cbf84
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/backend/batch_tx_test.go
@@ -0,0 +1,197 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 backend
+
+import (
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/boltdb/bolt"
+)
+
+func TestBatchTxPut(t *testing.T) {
+ b, tmpPath := NewTmpBackend(time.Hour, 10000)
+ defer cleanup(b, tmpPath)
+
+ tx := b.batchTx
+ tx.Lock()
+ defer tx.Unlock()
+
+ // create bucket
+ tx.UnsafeCreateBucket([]byte("test"))
+
+ // put
+ v := []byte("bar")
+ tx.UnsafePut([]byte("test"), []byte("foo"), v)
+
+ // check put result before and after tx is committed
+ for k := 0; k < 2; k++ {
+ _, gv := tx.UnsafeRange([]byte("test"), []byte("foo"), nil, 0)
+ if !reflect.DeepEqual(gv[0], v) {
+ t.Errorf("v = %s, want %s", string(gv[0]), string(v))
+ }
+ tx.commit(false)
+ }
+}
+
+func TestBatchTxRange(t *testing.T) {
+ b, tmpPath := NewTmpBackend(time.Hour, 10000)
+ defer cleanup(b, tmpPath)
+
+ tx := b.batchTx
+ tx.Lock()
+ defer tx.Unlock()
+
+ tx.UnsafeCreateBucket([]byte("test"))
+ // put keys
+ allKeys := [][]byte{[]byte("foo"), []byte("foo1"), []byte("foo2")}
+ allVals := [][]byte{[]byte("bar"), []byte("bar1"), []byte("bar2")}
+ for i := range allKeys {
+ tx.UnsafePut([]byte("test"), allKeys[i], allVals[i])
+ }
+
+ tests := []struct {
+ key []byte
+ endKey []byte
+ limit int64
+
+ wkeys [][]byte
+ wvals [][]byte
+ }{
+ // single key
+ {
+ []byte("foo"), nil, 0,
+ allKeys[:1], allVals[:1],
+ },
+ // single key, bad
+ {
+ []byte("doo"), nil, 0,
+ nil, nil,
+ },
+ // key range
+ {
+ []byte("foo"), []byte("foo1"), 0,
+ allKeys[:1], allVals[:1],
+ },
+ // key range, get all keys
+ {
+ []byte("foo"), []byte("foo3"), 0,
+ allKeys, allVals,
+ },
+ // key range, bad
+ {
+ []byte("goo"), []byte("goo3"), 0,
+ nil, nil,
+ },
+ // key range with effective limit
+ {
+ []byte("foo"), []byte("foo3"), 1,
+ allKeys[:1], allVals[:1],
+ },
+ // key range with limit
+ {
+ []byte("foo"), []byte("foo3"), 4,
+ allKeys, allVals,
+ },
+ }
+ for i, tt := range tests {
+ keys, vals := tx.UnsafeRange([]byte("test"), tt.key, tt.endKey, tt.limit)
+ if !reflect.DeepEqual(keys, tt.wkeys) {
+ t.Errorf("#%d: keys = %+v, want %+v", i, keys, tt.wkeys)
+ }
+ if !reflect.DeepEqual(vals, tt.wvals) {
+ t.Errorf("#%d: vals = %+v, want %+v", i, vals, tt.wvals)
+ }
+ }
+}
+
+func TestBatchTxDelete(t *testing.T) {
+ b, tmpPath := NewTmpBackend(time.Hour, 10000)
+ defer cleanup(b, tmpPath)
+
+ tx := b.batchTx
+ tx.Lock()
+ defer tx.Unlock()
+
+ tx.UnsafeCreateBucket([]byte("test"))
+ tx.UnsafePut([]byte("test"), []byte("foo"), []byte("bar"))
+
+ tx.UnsafeDelete([]byte("test"), []byte("foo"))
+
+ // check put result before and after tx is committed
+ for k := 0; k < 2; k++ {
+ ks, _ := tx.UnsafeRange([]byte("test"), []byte("foo"), nil, 0)
+ if len(ks) != 0 {
+ t.Errorf("keys on foo = %v, want nil", ks)
+ }
+ tx.commit(false)
+ }
+}
+
+func TestBatchTxCommit(t *testing.T) {
+ b, tmpPath := NewTmpBackend(time.Hour, 10000)
+ defer cleanup(b, tmpPath)
+
+ tx := b.batchTx
+ tx.Lock()
+ tx.UnsafeCreateBucket([]byte("test"))
+ tx.UnsafePut([]byte("test"), []byte("foo"), []byte("bar"))
+ tx.Unlock()
+
+ tx.Commit()
+
+ // check whether put happens via db view
+ b.db.View(func(tx *bolt.Tx) error {
+ bucket := tx.Bucket([]byte("test"))
+ if bucket == nil {
+ t.Errorf("bucket test does not exit")
+ return nil
+ }
+ v := bucket.Get([]byte("foo"))
+ if v == nil {
+ t.Errorf("foo key failed to written in backend")
+ }
+ return nil
+ })
+}
+
+func TestBatchTxBatchLimitCommit(t *testing.T) {
+ // start backend with batch limit 1 so one write can
+ // trigger a commit
+ b, tmpPath := NewTmpBackend(time.Hour, 1)
+ defer cleanup(b, tmpPath)
+
+ tx := b.batchTx
+ tx.Lock()
+ tx.UnsafeCreateBucket([]byte("test"))
+ tx.UnsafePut([]byte("test"), []byte("foo"), []byte("bar"))
+ tx.Unlock()
+
+ // batch limit commit should have been triggered
+ // check whether put happens via db view
+ b.db.View(func(tx *bolt.Tx) error {
+ bucket := tx.Bucket([]byte("test"))
+ if bucket == nil {
+ t.Errorf("bucket test does not exit")
+ return nil
+ }
+ v := bucket.Get([]byte("foo"))
+ if v == nil {
+ t.Errorf("foo key failed to written in backend")
+ }
+ return nil
+ })
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/backend/config_default.go b/vendor/github.com/coreos/etcd/mvcc/backend/config_default.go
new file mode 100644
index 00000000..9b9a7ee3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/backend/config_default.go
@@ -0,0 +1,23 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build !linux,!windows
+
+package backend
+
+import "github.com/boltdb/bolt"
+
+var boltOpenOptions *bolt.Options = nil
+
+func (bcfg *BackendConfig) mmapSize() int { return int(bcfg.MmapSize) }
diff --git a/vendor/github.com/coreos/etcd/mvcc/backend/config_linux.go b/vendor/github.com/coreos/etcd/mvcc/backend/config_linux.go
new file mode 100644
index 00000000..416158c6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/backend/config_linux.go
@@ -0,0 +1,33 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 backend
+
+import (
+ "syscall"
+
+ "github.com/boltdb/bolt"
+)
+
+// syscall.MAP_POPULATE on linux 2.6.23+ does sequential read-ahead
+// which can speed up entire-database read with boltdb. We want to
+// enable MAP_POPULATE for faster key-value store recovery in storage
+// package. If your kernel version is lower than 2.6.23
+// (https://github.com/torvalds/linux/releases/tag/v2.6.23), mmap might
+// silently ignore this flag. Please update your kernel to prevent this.
+var boltOpenOptions = &bolt.Options{
+ MmapFlags: syscall.MAP_POPULATE,
+}
+
+func (bcfg *BackendConfig) mmapSize() int { return int(bcfg.MmapSize) }
diff --git a/vendor/github.com/coreos/etcd/mvcc/backend/config_windows.go b/vendor/github.com/coreos/etcd/mvcc/backend/config_windows.go
new file mode 100644
index 00000000..fe30a220
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/backend/config_windows.go
@@ -0,0 +1,26 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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.
+
+// +build windows
+
+package backend
+
+import "github.com/boltdb/bolt"
+
+var boltOpenOptions *bolt.Options = nil
+
+// setting mmap size != 0 on windows will allocate the entire
+// mmap size for the file, instead of growing it. So, force 0.
+
+func (bcfg *BackendConfig) mmapSize() int { return 0 }
diff --git a/vendor/github.com/coreos/etcd/mvcc/backend/doc.go b/vendor/github.com/coreos/etcd/mvcc/backend/doc.go
new file mode 100644
index 00000000..9cc42fa7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/backend/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 backend defines a standard interface for etcd's backend MVCC storage.
+package backend
diff --git a/vendor/github.com/coreos/etcd/mvcc/backend/metrics.go b/vendor/github.com/coreos/etcd/mvcc/backend/metrics.go
new file mode 100644
index 00000000..30a38801
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/backend/metrics.go
@@ -0,0 +1,41 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 backend
+
+import "github.com/prometheus/client_golang/prometheus"
+
+var (
+ commitDurations = prometheus.NewHistogram(prometheus.HistogramOpts{
+ Namespace: "etcd",
+ Subsystem: "disk",
+ Name: "backend_commit_duration_seconds",
+ Help: "The latency distributions of commit called by backend.",
+ Buckets: prometheus.ExponentialBuckets(0.001, 2, 14),
+ })
+
+ snapshotDurations = prometheus.NewHistogram(prometheus.HistogramOpts{
+ Namespace: "etcd",
+ Subsystem: "disk",
+ Name: "backend_snapshot_duration_seconds",
+ Help: "The latency distribution of backend snapshots.",
+ // 10 ms -> 655 seconds
+ Buckets: prometheus.ExponentialBuckets(.01, 2, 17),
+ })
+)
+
+func init() {
+ prometheus.MustRegister(commitDurations)
+ prometheus.MustRegister(snapshotDurations)
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/backend/read_tx.go b/vendor/github.com/coreos/etcd/mvcc/backend/read_tx.go
new file mode 100644
index 00000000..51596ffd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/backend/read_tx.go
@@ -0,0 +1,92 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 backend
+
+import (
+ "bytes"
+ "math"
+ "sync"
+
+ "github.com/boltdb/bolt"
+)
+
+// safeRangeBucket is a hack to avoid inadvertently reading duplicate keys;
+// overwrites on a bucket should only fetch with limit=1, but safeRangeBucket
+// is known to never overwrite any key so range is safe.
+var safeRangeBucket = []byte("key")
+
+type ReadTx interface {
+ Lock()
+ Unlock()
+
+ UnsafeRange(bucketName []byte, key, endKey []byte, limit int64) (keys [][]byte, vals [][]byte)
+ UnsafeForEach(bucketName []byte, visitor func(k, v []byte) error) error
+}
+
+type readTx struct {
+ // mu protects accesses to the txReadBuffer
+ mu sync.RWMutex
+ buf txReadBuffer
+
+ // txmu protects accesses to the Tx on Range requests
+ txmu sync.Mutex
+ tx *bolt.Tx
+}
+
+func (rt *readTx) Lock() { rt.mu.RLock() }
+func (rt *readTx) Unlock() { rt.mu.RUnlock() }
+
+func (rt *readTx) UnsafeRange(bucketName, key, endKey []byte, limit int64) ([][]byte, [][]byte) {
+ if endKey == nil {
+ // forbid duplicates for single keys
+ limit = 1
+ }
+ if limit <= 0 {
+ limit = math.MaxInt64
+ }
+ if limit > 1 && !bytes.Equal(bucketName, safeRangeBucket) {
+ panic("do not use unsafeRange on non-keys bucket")
+ }
+ keys, vals := rt.buf.Range(bucketName, key, endKey, limit)
+ if int64(len(keys)) == limit {
+ return keys, vals
+ }
+ rt.txmu.Lock()
+ // ignore error since bucket may have been created in this batch
+ k2, v2, _ := unsafeRange(rt.tx, bucketName, key, endKey, limit-int64(len(keys)))
+ rt.txmu.Unlock()
+ return append(k2, keys...), append(v2, vals...)
+}
+
+func (rt *readTx) UnsafeForEach(bucketName []byte, visitor func(k, v []byte) error) error {
+ dups := make(map[string]struct{})
+ f1 := func(k, v []byte) error {
+ dups[string(k)] = struct{}{}
+ return visitor(k, v)
+ }
+ f2 := func(k, v []byte) error {
+ if _, ok := dups[string(k)]; ok {
+ return nil
+ }
+ return visitor(k, v)
+ }
+ if err := rt.buf.ForEach(bucketName, f1); err != nil {
+ return err
+ }
+ rt.txmu.Lock()
+ err := unsafeForEach(rt.tx, bucketName, f2)
+ rt.txmu.Unlock()
+ return err
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/backend/tx_buffer.go b/vendor/github.com/coreos/etcd/mvcc/backend/tx_buffer.go
new file mode 100644
index 00000000..56e885db
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/backend/tx_buffer.go
@@ -0,0 +1,181 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 backend
+
+import (
+ "bytes"
+ "sort"
+)
+
+// txBuffer handles functionality shared between txWriteBuffer and txReadBuffer.
+type txBuffer struct {
+ buckets map[string]*bucketBuffer
+}
+
+func (txb *txBuffer) reset() {
+ for k, v := range txb.buckets {
+ if v.used == 0 {
+ // demote
+ delete(txb.buckets, k)
+ }
+ v.used = 0
+ }
+}
+
+// txWriteBuffer buffers writes of pending updates that have not yet committed.
+type txWriteBuffer struct {
+ txBuffer
+ seq bool
+}
+
+func (txw *txWriteBuffer) put(bucket, k, v []byte) {
+ txw.seq = false
+ txw.putSeq(bucket, k, v)
+}
+
+func (txw *txWriteBuffer) putSeq(bucket, k, v []byte) {
+ b, ok := txw.buckets[string(bucket)]
+ if !ok {
+ b = newBucketBuffer()
+ txw.buckets[string(bucket)] = b
+ }
+ b.add(k, v)
+}
+
+func (txw *txWriteBuffer) writeback(txr *txReadBuffer) {
+ for k, wb := range txw.buckets {
+ rb, ok := txr.buckets[k]
+ if !ok {
+ delete(txw.buckets, k)
+ txr.buckets[k] = wb
+ continue
+ }
+ if !txw.seq && wb.used > 1 {
+ // assume no duplicate keys
+ sort.Sort(wb)
+ }
+ rb.merge(wb)
+ }
+ txw.reset()
+}
+
+// txReadBuffer accesses buffered updates.
+type txReadBuffer struct{ txBuffer }
+
+func (txr *txReadBuffer) Range(bucketName, key, endKey []byte, limit int64) ([][]byte, [][]byte) {
+ if b := txr.buckets[string(bucketName)]; b != nil {
+ return b.Range(key, endKey, limit)
+ }
+ return nil, nil
+}
+
+func (txr *txReadBuffer) ForEach(bucketName []byte, visitor func(k, v []byte) error) error {
+ if b := txr.buckets[string(bucketName)]; b != nil {
+ return b.ForEach(visitor)
+ }
+ return nil
+}
+
+type kv struct {
+ key []byte
+ val []byte
+}
+
+// bucketBuffer buffers key-value pairs that are pending commit.
+type bucketBuffer struct {
+ buf []kv
+ // used tracks number of elements in use so buf can be reused without reallocation.
+ used int
+}
+
+func newBucketBuffer() *bucketBuffer {
+ return &bucketBuffer{buf: make([]kv, 512), used: 0}
+}
+
+func (bb *bucketBuffer) Range(key, endKey []byte, limit int64) (keys [][]byte, vals [][]byte) {
+ f := func(i int) bool { return bytes.Compare(bb.buf[i].key, key) >= 0 }
+ idx := sort.Search(bb.used, f)
+ if idx < 0 {
+ return nil, nil
+ }
+ if len(endKey) == 0 {
+ if bytes.Equal(key, bb.buf[idx].key) {
+ keys = append(keys, bb.buf[idx].key)
+ vals = append(vals, bb.buf[idx].val)
+ }
+ return keys, vals
+ }
+ if bytes.Compare(endKey, bb.buf[idx].key) <= 0 {
+ return nil, nil
+ }
+ for i := idx; i < bb.used && int64(len(keys)) < limit; i++ {
+ if bytes.Compare(endKey, bb.buf[i].key) <= 0 {
+ break
+ }
+ keys = append(keys, bb.buf[i].key)
+ vals = append(vals, bb.buf[i].val)
+ }
+ return keys, vals
+}
+
+func (bb *bucketBuffer) ForEach(visitor func(k, v []byte) error) error {
+ for i := 0; i < bb.used; i++ {
+ if err := visitor(bb.buf[i].key, bb.buf[i].val); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func (bb *bucketBuffer) add(k, v []byte) {
+ bb.buf[bb.used].key, bb.buf[bb.used].val = k, v
+ bb.used++
+ if bb.used == len(bb.buf) {
+ buf := make([]kv, (3*len(bb.buf))/2)
+ copy(buf, bb.buf)
+ bb.buf = buf
+ }
+}
+
+// merge merges data from bb into bbsrc.
+func (bb *bucketBuffer) merge(bbsrc *bucketBuffer) {
+ for i := 0; i < bbsrc.used; i++ {
+ bb.add(bbsrc.buf[i].key, bbsrc.buf[i].val)
+ }
+ if bb.used == bbsrc.used {
+ return
+ }
+ if bytes.Compare(bb.buf[(bb.used-bbsrc.used)-1].key, bbsrc.buf[0].key) < 0 {
+ return
+ }
+
+ sort.Stable(bb)
+
+ // remove duplicates, using only newest update
+ widx := 0
+ for ridx := 1; ridx < bb.used; ridx++ {
+ if !bytes.Equal(bb.buf[ridx].key, bb.buf[widx].key) {
+ widx++
+ }
+ bb.buf[widx] = bb.buf[ridx]
+ }
+ bb.used = widx + 1
+}
+
+func (bb *bucketBuffer) Len() int { return bb.used }
+func (bb *bucketBuffer) Less(i, j int) bool {
+ return bytes.Compare(bb.buf[i].key, bb.buf[j].key) < 0
+}
+func (bb *bucketBuffer) Swap(i, j int) { bb.buf[i], bb.buf[j] = bb.buf[j], bb.buf[i] }
diff --git a/vendor/github.com/coreos/etcd/mvcc/doc.go b/vendor/github.com/coreos/etcd/mvcc/doc.go
new file mode 100644
index 00000000..ad5be030
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc defines etcd's stable MVCC storage.
+package mvcc
diff --git a/vendor/github.com/coreos/etcd/mvcc/index.go b/vendor/github.com/coreos/etcd/mvcc/index.go
new file mode 100644
index 00000000..991289cd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/index.go
@@ -0,0 +1,219 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "sort"
+ "sync"
+
+ "github.com/google/btree"
+)
+
+type index interface {
+ Get(key []byte, atRev int64) (rev, created revision, ver int64, err error)
+ Range(key, end []byte, atRev int64) ([][]byte, []revision)
+ Put(key []byte, rev revision)
+ Tombstone(key []byte, rev revision) error
+ RangeSince(key, end []byte, rev int64) []revision
+ Compact(rev int64) map[revision]struct{}
+ Equal(b index) bool
+
+ Insert(ki *keyIndex)
+ KeyIndex(ki *keyIndex) *keyIndex
+}
+
+type treeIndex struct {
+ sync.RWMutex
+ tree *btree.BTree
+}
+
+func newTreeIndex() index {
+ return &treeIndex{
+ tree: btree.New(32),
+ }
+}
+
+func (ti *treeIndex) Put(key []byte, rev revision) {
+ keyi := &keyIndex{key: key}
+
+ ti.Lock()
+ defer ti.Unlock()
+ item := ti.tree.Get(keyi)
+ if item == nil {
+ keyi.put(rev.main, rev.sub)
+ ti.tree.ReplaceOrInsert(keyi)
+ return
+ }
+ okeyi := item.(*keyIndex)
+ okeyi.put(rev.main, rev.sub)
+}
+
+func (ti *treeIndex) Get(key []byte, atRev int64) (modified, created revision, ver int64, err error) {
+ keyi := &keyIndex{key: key}
+ ti.RLock()
+ defer ti.RUnlock()
+ if keyi = ti.keyIndex(keyi); keyi == nil {
+ return revision{}, revision{}, 0, ErrRevisionNotFound
+ }
+ return keyi.get(atRev)
+}
+
+func (ti *treeIndex) KeyIndex(keyi *keyIndex) *keyIndex {
+ ti.RLock()
+ defer ti.RUnlock()
+ return ti.keyIndex(keyi)
+}
+
+func (ti *treeIndex) keyIndex(keyi *keyIndex) *keyIndex {
+ if item := ti.tree.Get(keyi); item != nil {
+ return item.(*keyIndex)
+ }
+ return nil
+}
+
+func (ti *treeIndex) Range(key, end []byte, atRev int64) (keys [][]byte, revs []revision) {
+ if end == nil {
+ rev, _, _, err := ti.Get(key, atRev)
+ if err != nil {
+ return nil, nil
+ }
+ return [][]byte{key}, []revision{rev}
+ }
+
+ keyi := &keyIndex{key: key}
+ endi := &keyIndex{key: end}
+
+ ti.RLock()
+ defer ti.RUnlock()
+
+ ti.tree.AscendGreaterOrEqual(keyi, func(item btree.Item) bool {
+ if len(endi.key) > 0 && !item.Less(endi) {
+ return false
+ }
+ curKeyi := item.(*keyIndex)
+ rev, _, _, err := curKeyi.get(atRev)
+ if err != nil {
+ return true
+ }
+ revs = append(revs, rev)
+ keys = append(keys, curKeyi.key)
+ return true
+ })
+
+ return keys, revs
+}
+
+func (ti *treeIndex) Tombstone(key []byte, rev revision) error {
+ keyi := &keyIndex{key: key}
+
+ ti.Lock()
+ defer ti.Unlock()
+ item := ti.tree.Get(keyi)
+ if item == nil {
+ return ErrRevisionNotFound
+ }
+
+ ki := item.(*keyIndex)
+ return ki.tombstone(rev.main, rev.sub)
+}
+
+// RangeSince returns all revisions from key(including) to end(excluding)
+// at or after the given rev. The returned slice is sorted in the order
+// of revision.
+func (ti *treeIndex) RangeSince(key, end []byte, rev int64) []revision {
+ ti.RLock()
+ defer ti.RUnlock()
+
+ keyi := &keyIndex{key: key}
+ if end == nil {
+ item := ti.tree.Get(keyi)
+ if item == nil {
+ return nil
+ }
+ keyi = item.(*keyIndex)
+ return keyi.since(rev)
+ }
+
+ endi := &keyIndex{key: end}
+ var revs []revision
+ ti.tree.AscendGreaterOrEqual(keyi, func(item btree.Item) bool {
+ if len(endi.key) > 0 && !item.Less(endi) {
+ return false
+ }
+ curKeyi := item.(*keyIndex)
+ revs = append(revs, curKeyi.since(rev)...)
+ return true
+ })
+ sort.Sort(revisions(revs))
+
+ return revs
+}
+
+func (ti *treeIndex) Compact(rev int64) map[revision]struct{} {
+ available := make(map[revision]struct{})
+ var emptyki []*keyIndex
+ plog.Printf("store.index: compact %d", rev)
+ // TODO: do not hold the lock for long time?
+ // This is probably OK. Compacting 10M keys takes O(10ms).
+ ti.Lock()
+ defer ti.Unlock()
+ ti.tree.Ascend(compactIndex(rev, available, &emptyki))
+ for _, ki := range emptyki {
+ item := ti.tree.Delete(ki)
+ if item == nil {
+ plog.Panic("store.index: unexpected delete failure during compaction")
+ }
+ }
+ return available
+}
+
+func compactIndex(rev int64, available map[revision]struct{}, emptyki *[]*keyIndex) func(i btree.Item) bool {
+ return func(i btree.Item) bool {
+ keyi := i.(*keyIndex)
+ keyi.compact(rev, available)
+ if keyi.isEmpty() {
+ *emptyki = append(*emptyki, keyi)
+ }
+ return true
+ }
+}
+
+func (a *treeIndex) Equal(bi index) bool {
+ b := bi.(*treeIndex)
+
+ if a.tree.Len() != b.tree.Len() {
+ return false
+ }
+
+ equal := true
+
+ a.tree.Ascend(func(item btree.Item) bool {
+ aki := item.(*keyIndex)
+ bki := b.tree.Get(item).(*keyIndex)
+ if !aki.equal(bki) {
+ equal = false
+ return false
+ }
+ return true
+ })
+
+ return equal
+}
+
+func (ti *treeIndex) Insert(ki *keyIndex) {
+ ti.Lock()
+ defer ti.Unlock()
+ ti.tree.ReplaceOrInsert(ki)
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/index_test.go b/vendor/github.com/coreos/etcd/mvcc/index_test.go
new file mode 100644
index 00000000..ef8df88f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/index_test.go
@@ -0,0 +1,286 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "reflect"
+ "testing"
+
+ "github.com/google/btree"
+)
+
+func TestIndexGet(t *testing.T) {
+ ti := newTreeIndex()
+ ti.Put([]byte("foo"), revision{main: 2})
+ ti.Put([]byte("foo"), revision{main: 4})
+ ti.Tombstone([]byte("foo"), revision{main: 6})
+
+ tests := []struct {
+ rev int64
+
+ wrev revision
+ wcreated revision
+ wver int64
+ werr error
+ }{
+ {0, revision{}, revision{}, 0, ErrRevisionNotFound},
+ {1, revision{}, revision{}, 0, ErrRevisionNotFound},
+ {2, revision{main: 2}, revision{main: 2}, 1, nil},
+ {3, revision{main: 2}, revision{main: 2}, 1, nil},
+ {4, revision{main: 4}, revision{main: 2}, 2, nil},
+ {5, revision{main: 4}, revision{main: 2}, 2, nil},
+ {6, revision{}, revision{}, 0, ErrRevisionNotFound},
+ }
+ for i, tt := range tests {
+ rev, created, ver, err := ti.Get([]byte("foo"), tt.rev)
+ if err != tt.werr {
+ t.Errorf("#%d: err = %v, want %v", i, err, tt.werr)
+ }
+ if rev != tt.wrev {
+ t.Errorf("#%d: rev = %+v, want %+v", i, rev, tt.wrev)
+ }
+ if created != tt.wcreated {
+ t.Errorf("#%d: created = %+v, want %+v", i, created, tt.wcreated)
+ }
+ if ver != tt.wver {
+ t.Errorf("#%d: ver = %d, want %d", i, ver, tt.wver)
+ }
+ }
+}
+
+func TestIndexRange(t *testing.T) {
+ allKeys := [][]byte{[]byte("foo"), []byte("foo1"), []byte("foo2")}
+ allRevs := []revision{{main: 1}, {main: 2}, {main: 3}}
+
+ ti := newTreeIndex()
+ for i := range allKeys {
+ ti.Put(allKeys[i], allRevs[i])
+ }
+
+ atRev := int64(3)
+ tests := []struct {
+ key, end []byte
+ wkeys [][]byte
+ wrevs []revision
+ }{
+ // single key that not found
+ {
+ []byte("bar"), nil, nil, nil,
+ },
+ // single key that found
+ {
+ []byte("foo"), nil, allKeys[:1], allRevs[:1],
+ },
+ // range keys, return first member
+ {
+ []byte("foo"), []byte("foo1"), allKeys[:1], allRevs[:1],
+ },
+ // range keys, return first two members
+ {
+ []byte("foo"), []byte("foo2"), allKeys[:2], allRevs[:2],
+ },
+ // range keys, return all members
+ {
+ []byte("foo"), []byte("fop"), allKeys, allRevs,
+ },
+ // range keys, return last two members
+ {
+ []byte("foo1"), []byte("fop"), allKeys[1:], allRevs[1:],
+ },
+ // range keys, return last member
+ {
+ []byte("foo2"), []byte("fop"), allKeys[2:], allRevs[2:],
+ },
+ // range keys, return nothing
+ {
+ []byte("foo3"), []byte("fop"), nil, nil,
+ },
+ }
+ for i, tt := range tests {
+ keys, revs := ti.Range(tt.key, tt.end, atRev)
+ if !reflect.DeepEqual(keys, tt.wkeys) {
+ t.Errorf("#%d: keys = %+v, want %+v", i, keys, tt.wkeys)
+ }
+ if !reflect.DeepEqual(revs, tt.wrevs) {
+ t.Errorf("#%d: revs = %+v, want %+v", i, revs, tt.wrevs)
+ }
+ }
+}
+
+func TestIndexTombstone(t *testing.T) {
+ ti := newTreeIndex()
+ ti.Put([]byte("foo"), revision{main: 1})
+
+ err := ti.Tombstone([]byte("foo"), revision{main: 2})
+ if err != nil {
+ t.Errorf("tombstone error = %v, want nil", err)
+ }
+
+ _, _, _, err = ti.Get([]byte("foo"), 2)
+ if err != ErrRevisionNotFound {
+ t.Errorf("get error = %v, want nil", err)
+ }
+ err = ti.Tombstone([]byte("foo"), revision{main: 3})
+ if err != ErrRevisionNotFound {
+ t.Errorf("tombstone error = %v, want %v", err, ErrRevisionNotFound)
+ }
+}
+
+func TestIndexRangeSince(t *testing.T) {
+ allKeys := [][]byte{[]byte("foo"), []byte("foo1"), []byte("foo2"), []byte("foo2"), []byte("foo1"), []byte("foo")}
+ allRevs := []revision{{main: 1}, {main: 2}, {main: 3}, {main: 4}, {main: 5}, {main: 6}}
+
+ ti := newTreeIndex()
+ for i := range allKeys {
+ ti.Put(allKeys[i], allRevs[i])
+ }
+
+ atRev := int64(1)
+ tests := []struct {
+ key, end []byte
+ wrevs []revision
+ }{
+ // single key that not found
+ {
+ []byte("bar"), nil, nil,
+ },
+ // single key that found
+ {
+ []byte("foo"), nil, []revision{{main: 1}, {main: 6}},
+ },
+ // range keys, return first member
+ {
+ []byte("foo"), []byte("foo1"), []revision{{main: 1}, {main: 6}},
+ },
+ // range keys, return first two members
+ {
+ []byte("foo"), []byte("foo2"), []revision{{main: 1}, {main: 2}, {main: 5}, {main: 6}},
+ },
+ // range keys, return all members
+ {
+ []byte("foo"), []byte("fop"), allRevs,
+ },
+ // range keys, return last two members
+ {
+ []byte("foo1"), []byte("fop"), []revision{{main: 2}, {main: 3}, {main: 4}, {main: 5}},
+ },
+ // range keys, return last member
+ {
+ []byte("foo2"), []byte("fop"), []revision{{main: 3}, {main: 4}},
+ },
+ // range keys, return nothing
+ {
+ []byte("foo3"), []byte("fop"), nil,
+ },
+ }
+ for i, tt := range tests {
+ revs := ti.RangeSince(tt.key, tt.end, atRev)
+ if !reflect.DeepEqual(revs, tt.wrevs) {
+ t.Errorf("#%d: revs = %+v, want %+v", i, revs, tt.wrevs)
+ }
+ }
+}
+
+func TestIndexCompact(t *testing.T) {
+ maxRev := int64(20)
+ tests := []struct {
+ key []byte
+ remove bool
+ rev revision
+ created revision
+ ver int64
+ }{
+ {[]byte("foo"), false, revision{main: 1}, revision{main: 1}, 1},
+ {[]byte("foo1"), false, revision{main: 2}, revision{main: 2}, 1},
+ {[]byte("foo2"), false, revision{main: 3}, revision{main: 3}, 1},
+ {[]byte("foo2"), false, revision{main: 4}, revision{main: 3}, 2},
+ {[]byte("foo"), false, revision{main: 5}, revision{main: 1}, 2},
+ {[]byte("foo1"), false, revision{main: 6}, revision{main: 2}, 2},
+ {[]byte("foo1"), true, revision{main: 7}, revision{}, 0},
+ {[]byte("foo2"), true, revision{main: 8}, revision{}, 0},
+ {[]byte("foo"), true, revision{main: 9}, revision{}, 0},
+ {[]byte("foo"), false, revision{10, 0}, revision{10, 0}, 1},
+ {[]byte("foo1"), false, revision{10, 1}, revision{10, 1}, 1},
+ }
+
+ // Continuous Compact
+ ti := newTreeIndex()
+ for _, tt := range tests {
+ if tt.remove {
+ ti.Tombstone(tt.key, tt.rev)
+ } else {
+ ti.Put(tt.key, tt.rev)
+ }
+ }
+ for i := int64(1); i < maxRev; i++ {
+ am := ti.Compact(i)
+
+ wti := &treeIndex{tree: btree.New(32)}
+ for _, tt := range tests {
+ if _, ok := am[tt.rev]; ok || tt.rev.GreaterThan(revision{main: i}) {
+ if tt.remove {
+ wti.Tombstone(tt.key, tt.rev)
+ } else {
+ restore(wti, tt.key, tt.created, tt.rev, tt.ver)
+ }
+ }
+ }
+ if !ti.Equal(wti) {
+ t.Errorf("#%d: not equal ti", i)
+ }
+ }
+
+ // Once Compact
+ for i := int64(1); i < maxRev; i++ {
+ ti := newTreeIndex()
+ for _, tt := range tests {
+ if tt.remove {
+ ti.Tombstone(tt.key, tt.rev)
+ } else {
+ ti.Put(tt.key, tt.rev)
+ }
+ }
+ am := ti.Compact(i)
+
+ wti := &treeIndex{tree: btree.New(32)}
+ for _, tt := range tests {
+ if _, ok := am[tt.rev]; ok || tt.rev.GreaterThan(revision{main: i}) {
+ if tt.remove {
+ wti.Tombstone(tt.key, tt.rev)
+ } else {
+ restore(wti, tt.key, tt.created, tt.rev, tt.ver)
+ }
+ }
+ }
+ if !ti.Equal(wti) {
+ t.Errorf("#%d: not equal ti", i)
+ }
+ }
+}
+
+func restore(ti *treeIndex, key []byte, created, modified revision, ver int64) {
+ keyi := &keyIndex{key: key}
+
+ ti.Lock()
+ defer ti.Unlock()
+ item := ti.tree.Get(keyi)
+ if item == nil {
+ keyi.restore(created, modified, ver)
+ ti.tree.ReplaceOrInsert(keyi)
+ return
+ }
+ okeyi := item.(*keyIndex)
+ okeyi.put(modified.main, modified.sub)
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/key_index.go b/vendor/github.com/coreos/etcd/mvcc/key_index.go
new file mode 100644
index 00000000..9104f9b2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/key_index.go
@@ -0,0 +1,332 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "bytes"
+ "errors"
+ "fmt"
+
+ "github.com/google/btree"
+)
+
+var (
+ ErrRevisionNotFound = errors.New("mvcc: revision not found")
+)
+
+// keyIndex stores the revisions of a key in the backend.
+// Each keyIndex has at least one key generation.
+// Each generation might have several key versions.
+// Tombstone on a key appends an tombstone version at the end
+// of the current generation and creates a new empty generation.
+// Each version of a key has an index pointing to the backend.
+//
+// For example: put(1.0);put(2.0);tombstone(3.0);put(4.0);tombstone(5.0) on key "foo"
+// generate a keyIndex:
+// key: "foo"
+// rev: 5
+// generations:
+// {empty}
+// {4.0, 5.0(t)}
+// {1.0, 2.0, 3.0(t)}
+//
+// Compact a keyIndex removes the versions with smaller or equal to
+// rev except the largest one. If the generation becomes empty
+// during compaction, it will be removed. if all the generations get
+// removed, the keyIndex should be removed.
+
+// For example:
+// compact(2) on the previous example
+// generations:
+// {empty}
+// {4.0, 5.0(t)}
+// {2.0, 3.0(t)}
+//
+// compact(4)
+// generations:
+// {empty}
+// {4.0, 5.0(t)}
+//
+// compact(5):
+// generations:
+// {empty} -> key SHOULD be removed.
+//
+// compact(6):
+// generations:
+// {empty} -> key SHOULD be removed.
+type keyIndex struct {
+ key []byte
+ modified revision // the main rev of the last modification
+ generations []generation
+}
+
+// put puts a revision to the keyIndex.
+func (ki *keyIndex) put(main int64, sub int64) {
+ rev := revision{main: main, sub: sub}
+
+ if !rev.GreaterThan(ki.modified) {
+ plog.Panicf("store.keyindex: put with unexpected smaller revision [%v / %v]", rev, ki.modified)
+ }
+ if len(ki.generations) == 0 {
+ ki.generations = append(ki.generations, generation{})
+ }
+ g := &ki.generations[len(ki.generations)-1]
+ if len(g.revs) == 0 { // create a new key
+ keysGauge.Inc()
+ g.created = rev
+ }
+ g.revs = append(g.revs, rev)
+ g.ver++
+ ki.modified = rev
+}
+
+func (ki *keyIndex) restore(created, modified revision, ver int64) {
+ if len(ki.generations) != 0 {
+ plog.Panicf("store.keyindex: cannot restore non-empty keyIndex")
+ }
+
+ ki.modified = modified
+ g := generation{created: created, ver: ver, revs: []revision{modified}}
+ ki.generations = append(ki.generations, g)
+ keysGauge.Inc()
+}
+
+// tombstone puts a revision, pointing to a tombstone, to the keyIndex.
+// It also creates a new empty generation in the keyIndex.
+// It returns ErrRevisionNotFound when tombstone on an empty generation.
+func (ki *keyIndex) tombstone(main int64, sub int64) error {
+ if ki.isEmpty() {
+ plog.Panicf("store.keyindex: unexpected tombstone on empty keyIndex %s", string(ki.key))
+ }
+ if ki.generations[len(ki.generations)-1].isEmpty() {
+ return ErrRevisionNotFound
+ }
+ ki.put(main, sub)
+ ki.generations = append(ki.generations, generation{})
+ keysGauge.Dec()
+ return nil
+}
+
+// get gets the modified, created revision and version of the key that satisfies the given atRev.
+// Rev must be higher than or equal to the given atRev.
+func (ki *keyIndex) get(atRev int64) (modified, created revision, ver int64, err error) {
+ if ki.isEmpty() {
+ plog.Panicf("store.keyindex: unexpected get on empty keyIndex %s", string(ki.key))
+ }
+ g := ki.findGeneration(atRev)
+ if g.isEmpty() {
+ return revision{}, revision{}, 0, ErrRevisionNotFound
+ }
+
+ n := g.walk(func(rev revision) bool { return rev.main > atRev })
+ if n != -1 {
+ return g.revs[n], g.created, g.ver - int64(len(g.revs)-n-1), nil
+ }
+
+ return revision{}, revision{}, 0, ErrRevisionNotFound
+}
+
+// since returns revisions since the given rev. Only the revision with the
+// largest sub revision will be returned if multiple revisions have the same
+// main revision.
+func (ki *keyIndex) since(rev int64) []revision {
+ if ki.isEmpty() {
+ plog.Panicf("store.keyindex: unexpected get on empty keyIndex %s", string(ki.key))
+ }
+ since := revision{rev, 0}
+ var gi int
+ // find the generations to start checking
+ for gi = len(ki.generations) - 1; gi > 0; gi-- {
+ g := ki.generations[gi]
+ if g.isEmpty() {
+ continue
+ }
+ if since.GreaterThan(g.created) {
+ break
+ }
+ }
+
+ var revs []revision
+ var last int64
+ for ; gi < len(ki.generations); gi++ {
+ for _, r := range ki.generations[gi].revs {
+ if since.GreaterThan(r) {
+ continue
+ }
+ if r.main == last {
+ // replace the revision with a new one that has higher sub value,
+ // because the original one should not be seen by external
+ revs[len(revs)-1] = r
+ continue
+ }
+ revs = append(revs, r)
+ last = r.main
+ }
+ }
+ return revs
+}
+
+// compact compacts a keyIndex by removing the versions with smaller or equal
+// revision than the given atRev except the largest one (If the largest one is
+// a tombstone, it will not be kept).
+// If a generation becomes empty during compaction, it will be removed.
+func (ki *keyIndex) compact(atRev int64, available map[revision]struct{}) {
+ if ki.isEmpty() {
+ plog.Panicf("store.keyindex: unexpected compact on empty keyIndex %s", string(ki.key))
+ }
+
+ // walk until reaching the first revision that has an revision smaller or equal to
+ // the atRev.
+ // add it to the available map
+ f := func(rev revision) bool {
+ if rev.main <= atRev {
+ available[rev] = struct{}{}
+ return false
+ }
+ return true
+ }
+
+ i, g := 0, &ki.generations[0]
+ // find first generation includes atRev or created after atRev
+ for i < len(ki.generations)-1 {
+ if tomb := g.revs[len(g.revs)-1].main; tomb > atRev {
+ break
+ }
+ i++
+ g = &ki.generations[i]
+ }
+
+ if !g.isEmpty() {
+ n := g.walk(f)
+ // remove the previous contents.
+ if n != -1 {
+ g.revs = g.revs[n:]
+ }
+ // remove any tombstone
+ if len(g.revs) == 1 && i != len(ki.generations)-1 {
+ delete(available, g.revs[0])
+ i++
+ }
+ }
+ // remove the previous generations.
+ ki.generations = ki.generations[i:]
+}
+
+func (ki *keyIndex) isEmpty() bool {
+ return len(ki.generations) == 1 && ki.generations[0].isEmpty()
+}
+
+// findGeneration finds out the generation of the keyIndex that the
+// given rev belongs to. If the given rev is at the gap of two generations,
+// which means that the key does not exist at the given rev, it returns nil.
+func (ki *keyIndex) findGeneration(rev int64) *generation {
+ lastg := len(ki.generations) - 1
+ cg := lastg
+
+ for cg >= 0 {
+ if len(ki.generations[cg].revs) == 0 {
+ cg--
+ continue
+ }
+ g := ki.generations[cg]
+ if cg != lastg {
+ if tomb := g.revs[len(g.revs)-1].main; tomb <= rev {
+ return nil
+ }
+ }
+ if g.revs[0].main <= rev {
+ return &ki.generations[cg]
+ }
+ cg--
+ }
+ return nil
+}
+
+func (a *keyIndex) Less(b btree.Item) bool {
+ return bytes.Compare(a.key, b.(*keyIndex).key) == -1
+}
+
+func (a *keyIndex) equal(b *keyIndex) bool {
+ if !bytes.Equal(a.key, b.key) {
+ return false
+ }
+ if a.modified != b.modified {
+ return false
+ }
+ if len(a.generations) != len(b.generations) {
+ return false
+ }
+ for i := range a.generations {
+ ag, bg := a.generations[i], b.generations[i]
+ if !ag.equal(bg) {
+ return false
+ }
+ }
+ return true
+}
+
+func (ki *keyIndex) String() string {
+ var s string
+ for _, g := range ki.generations {
+ s += g.String()
+ }
+ return s
+}
+
+// generation contains multiple revisions of a key.
+type generation struct {
+ ver int64
+ created revision // when the generation is created (put in first revision).
+ revs []revision
+}
+
+func (g *generation) isEmpty() bool { return g == nil || len(g.revs) == 0 }
+
+// walk walks through the revisions in the generation in descending order.
+// It passes the revision to the given function.
+// walk returns until: 1. it finishes walking all pairs 2. the function returns false.
+// walk returns the position at where it stopped. If it stopped after
+// finishing walking, -1 will be returned.
+func (g *generation) walk(f func(rev revision) bool) int {
+ l := len(g.revs)
+ for i := range g.revs {
+ ok := f(g.revs[l-i-1])
+ if !ok {
+ return l - i - 1
+ }
+ }
+ return -1
+}
+
+func (g *generation) String() string {
+ return fmt.Sprintf("g: created[%d] ver[%d], revs %#v\n", g.created, g.ver, g.revs)
+}
+
+func (a generation) equal(b generation) bool {
+ if a.ver != b.ver {
+ return false
+ }
+ if len(a.revs) != len(b.revs) {
+ return false
+ }
+
+ for i := range a.revs {
+ ar, br := a.revs[i], b.revs[i]
+ if ar != br {
+ return false
+ }
+ }
+ return true
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/key_index_test.go b/vendor/github.com/coreos/etcd/mvcc/key_index_test.go
new file mode 100644
index 00000000..bfaed985
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/key_index_test.go
@@ -0,0 +1,654 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "reflect"
+ "testing"
+)
+
+func TestKeyIndexGet(t *testing.T) {
+ // key: "foo"
+ // rev: 16
+ // generations:
+ // {empty}
+ // {{14, 0}[1], {14, 1}[2], {16, 0}(t)[3]}
+ // {{8, 0}[1], {10, 0}[2], {12, 0}(t)[3]}
+ // {{2, 0}[1], {4, 0}[2], {6, 0}(t)[3]}
+ ki := newTestKeyIndex()
+ ki.compact(4, make(map[revision]struct{}))
+
+ tests := []struct {
+ rev int64
+
+ wmod revision
+ wcreat revision
+ wver int64
+ werr error
+ }{
+ {17, revision{}, revision{}, 0, ErrRevisionNotFound},
+ {16, revision{}, revision{}, 0, ErrRevisionNotFound},
+
+ // get on generation 3
+ {15, revision{14, 1}, revision{14, 0}, 2, nil},
+ {14, revision{14, 1}, revision{14, 0}, 2, nil},
+
+ {13, revision{}, revision{}, 0, ErrRevisionNotFound},
+ {12, revision{}, revision{}, 0, ErrRevisionNotFound},
+
+ // get on generation 2
+ {11, revision{10, 0}, revision{8, 0}, 2, nil},
+ {10, revision{10, 0}, revision{8, 0}, 2, nil},
+ {9, revision{8, 0}, revision{8, 0}, 1, nil},
+ {8, revision{8, 0}, revision{8, 0}, 1, nil},
+
+ {7, revision{}, revision{}, 0, ErrRevisionNotFound},
+ {6, revision{}, revision{}, 0, ErrRevisionNotFound},
+
+ // get on generation 1
+ {5, revision{4, 0}, revision{2, 0}, 2, nil},
+ {4, revision{4, 0}, revision{2, 0}, 2, nil},
+
+ {3, revision{}, revision{}, 0, ErrRevisionNotFound},
+ {2, revision{}, revision{}, 0, ErrRevisionNotFound},
+ {1, revision{}, revision{}, 0, ErrRevisionNotFound},
+ {0, revision{}, revision{}, 0, ErrRevisionNotFound},
+ }
+
+ for i, tt := range tests {
+ mod, creat, ver, err := ki.get(tt.rev)
+ if err != tt.werr {
+ t.Errorf("#%d: err = %v, want %v", i, err, tt.werr)
+ }
+ if mod != tt.wmod {
+ t.Errorf("#%d: modified = %+v, want %+v", i, mod, tt.wmod)
+ }
+ if creat != tt.wcreat {
+ t.Errorf("#%d: created = %+v, want %+v", i, creat, tt.wcreat)
+ }
+ if ver != tt.wver {
+ t.Errorf("#%d: version = %d, want %d", i, ver, tt.wver)
+ }
+ }
+}
+
+func TestKeyIndexSince(t *testing.T) {
+ ki := newTestKeyIndex()
+ ki.compact(4, make(map[revision]struct{}))
+
+ allRevs := []revision{{4, 0}, {6, 0}, {8, 0}, {10, 0}, {12, 0}, {14, 1}, {16, 0}}
+ tests := []struct {
+ rev int64
+
+ wrevs []revision
+ }{
+ {17, nil},
+ {16, allRevs[6:]},
+ {15, allRevs[6:]},
+ {14, allRevs[5:]},
+ {13, allRevs[5:]},
+ {12, allRevs[4:]},
+ {11, allRevs[4:]},
+ {10, allRevs[3:]},
+ {9, allRevs[3:]},
+ {8, allRevs[2:]},
+ {7, allRevs[2:]},
+ {6, allRevs[1:]},
+ {5, allRevs[1:]},
+ {4, allRevs},
+ {3, allRevs},
+ {2, allRevs},
+ {1, allRevs},
+ {0, allRevs},
+ }
+
+ for i, tt := range tests {
+ revs := ki.since(tt.rev)
+ if !reflect.DeepEqual(revs, tt.wrevs) {
+ t.Errorf("#%d: revs = %+v, want %+v", i, revs, tt.wrevs)
+ }
+ }
+}
+
+func TestKeyIndexPut(t *testing.T) {
+ ki := &keyIndex{key: []byte("foo")}
+ ki.put(5, 0)
+
+ wki := &keyIndex{
+ key: []byte("foo"),
+ modified: revision{5, 0},
+ generations: []generation{{created: revision{5, 0}, ver: 1, revs: []revision{{main: 5}}}},
+ }
+ if !reflect.DeepEqual(ki, wki) {
+ t.Errorf("ki = %+v, want %+v", ki, wki)
+ }
+
+ ki.put(7, 0)
+
+ wki = &keyIndex{
+ key: []byte("foo"),
+ modified: revision{7, 0},
+ generations: []generation{{created: revision{5, 0}, ver: 2, revs: []revision{{main: 5}, {main: 7}}}},
+ }
+ if !reflect.DeepEqual(ki, wki) {
+ t.Errorf("ki = %+v, want %+v", ki, wki)
+ }
+}
+
+func TestKeyIndexRestore(t *testing.T) {
+ ki := &keyIndex{key: []byte("foo")}
+ ki.restore(revision{5, 0}, revision{7, 0}, 2)
+
+ wki := &keyIndex{
+ key: []byte("foo"),
+ modified: revision{7, 0},
+ generations: []generation{{created: revision{5, 0}, ver: 2, revs: []revision{{main: 7}}}},
+ }
+ if !reflect.DeepEqual(ki, wki) {
+ t.Errorf("ki = %+v, want %+v", ki, wki)
+ }
+}
+
+func TestKeyIndexTombstone(t *testing.T) {
+ ki := &keyIndex{key: []byte("foo")}
+ ki.put(5, 0)
+
+ err := ki.tombstone(7, 0)
+ if err != nil {
+ t.Errorf("unexpected tombstone error: %v", err)
+ }
+
+ wki := &keyIndex{
+ key: []byte("foo"),
+ modified: revision{7, 0},
+ generations: []generation{{created: revision{5, 0}, ver: 2, revs: []revision{{main: 5}, {main: 7}}}, {}},
+ }
+ if !reflect.DeepEqual(ki, wki) {
+ t.Errorf("ki = %+v, want %+v", ki, wki)
+ }
+
+ ki.put(8, 0)
+ ki.put(9, 0)
+ err = ki.tombstone(15, 0)
+ if err != nil {
+ t.Errorf("unexpected tombstone error: %v", err)
+ }
+
+ wki = &keyIndex{
+ key: []byte("foo"),
+ modified: revision{15, 0},
+ generations: []generation{
+ {created: revision{5, 0}, ver: 2, revs: []revision{{main: 5}, {main: 7}}},
+ {created: revision{8, 0}, ver: 3, revs: []revision{{main: 8}, {main: 9}, {main: 15}}},
+ {},
+ },
+ }
+ if !reflect.DeepEqual(ki, wki) {
+ t.Errorf("ki = %+v, want %+v", ki, wki)
+ }
+
+ err = ki.tombstone(16, 0)
+ if err != ErrRevisionNotFound {
+ t.Errorf("tombstone error = %v, want %v", err, ErrRevisionNotFound)
+ }
+}
+
+func TestKeyIndexCompact(t *testing.T) {
+ tests := []struct {
+ compact int64
+
+ wki *keyIndex
+ wam map[revision]struct{}
+ }{
+ {
+ 1,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{2, 0}, ver: 3, revs: []revision{{main: 2}, {main: 4}, {main: 6}}},
+ {created: revision{8, 0}, ver: 3, revs: []revision{{main: 8}, {main: 10}, {main: 12}}},
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14}, {main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{},
+ },
+ {
+ 2,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{2, 0}, ver: 3, revs: []revision{{main: 2}, {main: 4}, {main: 6}}},
+ {created: revision{8, 0}, ver: 3, revs: []revision{{main: 8}, {main: 10}, {main: 12}}},
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14}, {main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{
+ {main: 2}: {},
+ },
+ },
+ {
+ 3,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{2, 0}, ver: 3, revs: []revision{{main: 2}, {main: 4}, {main: 6}}},
+ {created: revision{8, 0}, ver: 3, revs: []revision{{main: 8}, {main: 10}, {main: 12}}},
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14}, {main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{
+ {main: 2}: {},
+ },
+ },
+ {
+ 4,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{2, 0}, ver: 3, revs: []revision{{main: 4}, {main: 6}}},
+ {created: revision{8, 0}, ver: 3, revs: []revision{{main: 8}, {main: 10}, {main: 12}}},
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14}, {main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{
+ {main: 4}: {},
+ },
+ },
+ {
+ 5,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{2, 0}, ver: 3, revs: []revision{{main: 4}, {main: 6}}},
+ {created: revision{8, 0}, ver: 3, revs: []revision{{main: 8}, {main: 10}, {main: 12}}},
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14}, {main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{
+ {main: 4}: {},
+ },
+ },
+ {
+ 6,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{8, 0}, ver: 3, revs: []revision{{main: 8}, {main: 10}, {main: 12}}},
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14}, {main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{},
+ },
+ {
+ 7,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{8, 0}, ver: 3, revs: []revision{{main: 8}, {main: 10}, {main: 12}}},
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14}, {main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{},
+ },
+ {
+ 8,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{8, 0}, ver: 3, revs: []revision{{main: 8}, {main: 10}, {main: 12}}},
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14}, {main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{
+ {main: 8}: {},
+ },
+ },
+ {
+ 9,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{8, 0}, ver: 3, revs: []revision{{main: 8}, {main: 10}, {main: 12}}},
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14}, {main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{
+ {main: 8}: {},
+ },
+ },
+ {
+ 10,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{8, 0}, ver: 3, revs: []revision{{main: 10}, {main: 12}}},
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14}, {main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{
+ {main: 10}: {},
+ },
+ },
+ {
+ 11,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{8, 0}, ver: 3, revs: []revision{{main: 10}, {main: 12}}},
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14}, {main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{
+ {main: 10}: {},
+ },
+ },
+ {
+ 12,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14}, {main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{},
+ },
+ {
+ 13,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14}, {main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{},
+ },
+ {
+ 14,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{
+ {main: 14, sub: 1}: {},
+ },
+ },
+ {
+ 15,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {created: revision{14, 0}, ver: 3, revs: []revision{{main: 14, sub: 1}, {main: 16}}},
+ {},
+ },
+ },
+ map[revision]struct{}{
+ {main: 14, sub: 1}: {},
+ },
+ },
+ {
+ 16,
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{16, 0},
+ generations: []generation{
+ {},
+ },
+ },
+ map[revision]struct{}{},
+ },
+ }
+
+ // Continuous Compaction
+ ki := newTestKeyIndex()
+ for i, tt := range tests {
+ am := make(map[revision]struct{})
+ ki.compact(tt.compact, am)
+ if !reflect.DeepEqual(ki, tt.wki) {
+ t.Errorf("#%d: ki = %+v, want %+v", i, ki, tt.wki)
+ }
+ if !reflect.DeepEqual(am, tt.wam) {
+ t.Errorf("#%d: am = %+v, want %+v", i, am, tt.wam)
+ }
+ }
+
+ // Jump Compaction
+ ki = newTestKeyIndex()
+ for i, tt := range tests {
+ if (i%2 == 0 && i < 6) || (i%2 == 1 && i > 6) {
+ am := make(map[revision]struct{})
+ ki.compact(tt.compact, am)
+ if !reflect.DeepEqual(ki, tt.wki) {
+ t.Errorf("#%d: ki = %+v, want %+v", i, ki, tt.wki)
+ }
+ if !reflect.DeepEqual(am, tt.wam) {
+ t.Errorf("#%d: am = %+v, want %+v", i, am, tt.wam)
+ }
+ }
+ }
+
+ // Once Compaction
+ for i, tt := range tests {
+ ki := newTestKeyIndex()
+ am := make(map[revision]struct{})
+ ki.compact(tt.compact, am)
+ if !reflect.DeepEqual(ki, tt.wki) {
+ t.Errorf("#%d: ki = %+v, want %+v", i, ki, tt.wki)
+ }
+ if !reflect.DeepEqual(am, tt.wam) {
+ t.Errorf("#%d: am = %+v, want %+v", i, am, tt.wam)
+ }
+ }
+}
+
+// test that compact on version that higher than last modified version works well
+func TestKeyIndexCompactOnFurtherRev(t *testing.T) {
+ ki := &keyIndex{key: []byte("foo")}
+ ki.put(1, 0)
+ ki.put(2, 0)
+ am := make(map[revision]struct{})
+ ki.compact(3, am)
+
+ wki := &keyIndex{
+ key: []byte("foo"),
+ modified: revision{2, 0},
+ generations: []generation{
+ {created: revision{1, 0}, ver: 2, revs: []revision{{main: 2}}},
+ },
+ }
+ wam := map[revision]struct{}{
+ {main: 2}: {},
+ }
+ if !reflect.DeepEqual(ki, wki) {
+ t.Errorf("ki = %+v, want %+v", ki, wki)
+ }
+ if !reflect.DeepEqual(am, wam) {
+ t.Errorf("am = %+v, want %+v", am, wam)
+ }
+}
+
+func TestKeyIndexIsEmpty(t *testing.T) {
+ tests := []struct {
+ ki *keyIndex
+ w bool
+ }{
+ {
+ &keyIndex{
+ key: []byte("foo"),
+ generations: []generation{{}},
+ },
+ true,
+ },
+ {
+ &keyIndex{
+ key: []byte("foo"),
+ modified: revision{2, 0},
+ generations: []generation{
+ {created: revision{1, 0}, ver: 2, revs: []revision{{main: 2}}},
+ },
+ },
+ false,
+ },
+ }
+ for i, tt := range tests {
+ g := tt.ki.isEmpty()
+ if g != tt.w {
+ t.Errorf("#%d: isEmpty = %v, want %v", i, g, tt.w)
+ }
+ }
+}
+
+func TestKeyIndexFindGeneration(t *testing.T) {
+ ki := newTestKeyIndex()
+
+ tests := []struct {
+ rev int64
+ wg *generation
+ }{
+ {0, nil},
+ {1, nil},
+ {2, &ki.generations[0]},
+ {3, &ki.generations[0]},
+ {4, &ki.generations[0]},
+ {5, &ki.generations[0]},
+ {6, nil},
+ {7, nil},
+ {8, &ki.generations[1]},
+ {9, &ki.generations[1]},
+ {10, &ki.generations[1]},
+ {11, &ki.generations[1]},
+ {12, nil},
+ {13, nil},
+ }
+ for i, tt := range tests {
+ g := ki.findGeneration(tt.rev)
+ if g != tt.wg {
+ t.Errorf("#%d: generation = %+v, want %+v", i, g, tt.wg)
+ }
+ }
+}
+
+func TestKeyIndexLess(t *testing.T) {
+ ki := &keyIndex{key: []byte("foo")}
+
+ tests := []struct {
+ ki *keyIndex
+ w bool
+ }{
+ {&keyIndex{key: []byte("doo")}, false},
+ {&keyIndex{key: []byte("foo")}, false},
+ {&keyIndex{key: []byte("goo")}, true},
+ }
+ for i, tt := range tests {
+ g := ki.Less(tt.ki)
+ if g != tt.w {
+ t.Errorf("#%d: Less = %v, want %v", i, g, tt.w)
+ }
+ }
+}
+
+func TestGenerationIsEmpty(t *testing.T) {
+ tests := []struct {
+ g *generation
+ w bool
+ }{
+ {nil, true},
+ {&generation{}, true},
+ {&generation{revs: []revision{{main: 1}}}, false},
+ }
+ for i, tt := range tests {
+ g := tt.g.isEmpty()
+ if g != tt.w {
+ t.Errorf("#%d: isEmpty = %v, want %v", i, g, tt.w)
+ }
+ }
+}
+
+func TestGenerationWalk(t *testing.T) {
+ g := &generation{
+ ver: 3,
+ created: revision{2, 0},
+ revs: []revision{{main: 2}, {main: 4}, {main: 6}},
+ }
+ tests := []struct {
+ f func(rev revision) bool
+ wi int
+ }{
+ {func(rev revision) bool { return rev.main >= 7 }, 2},
+ {func(rev revision) bool { return rev.main >= 6 }, 1},
+ {func(rev revision) bool { return rev.main >= 5 }, 1},
+ {func(rev revision) bool { return rev.main >= 4 }, 0},
+ {func(rev revision) bool { return rev.main >= 3 }, 0},
+ {func(rev revision) bool { return rev.main >= 2 }, -1},
+ }
+ for i, tt := range tests {
+ idx := g.walk(tt.f)
+ if idx != tt.wi {
+ t.Errorf("#%d: index = %d, want %d", i, idx, tt.wi)
+ }
+ }
+}
+
+func newTestKeyIndex() *keyIndex {
+ // key: "foo"
+ // rev: 16
+ // generations:
+ // {empty}
+ // {{14, 0}[1], {14, 1}[2], {16, 0}(t)[3]}
+ // {{8, 0}[1], {10, 0}[2], {12, 0}(t)[3]}
+ // {{2, 0}[1], {4, 0}[2], {6, 0}(t)[3]}
+
+ ki := &keyIndex{key: []byte("foo")}
+ ki.put(2, 0)
+ ki.put(4, 0)
+ ki.tombstone(6, 0)
+ ki.put(8, 0)
+ ki.put(10, 0)
+ ki.tombstone(12, 0)
+ ki.put(14, 0)
+ ki.put(14, 1)
+ ki.tombstone(16, 0)
+ return ki
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/kv.go b/vendor/github.com/coreos/etcd/mvcc/kv.go
new file mode 100644
index 00000000..6636347a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/kv.go
@@ -0,0 +1,147 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+)
+
+type RangeOptions struct {
+ Limit int64
+ Rev int64
+ Count bool
+}
+
+type RangeResult struct {
+ KVs []mvccpb.KeyValue
+ Rev int64
+ Count int
+}
+
+type ReadView interface {
+ // FirstRev returns the first KV revision at the time of opening the txn.
+ // After a compaction, the first revision increases to the compaction
+ // revision.
+ FirstRev() int64
+
+ // Rev returns the revision of the KV at the time of opening the txn.
+ Rev() int64
+
+ // Range gets the keys in the range at rangeRev.
+ // The returned rev is the current revision of the KV when the operation is executed.
+ // If rangeRev <=0, range gets the keys at currentRev.
+ // If `end` is nil, the request returns the key.
+ // If `end` is not nil and not empty, it gets the keys in range [key, range_end).
+ // If `end` is not nil and empty, it gets the keys greater than or equal to key.
+ // Limit limits the number of keys returned.
+ // If the required rev is compacted, ErrCompacted will be returned.
+ Range(key, end []byte, ro RangeOptions) (r *RangeResult, err error)
+}
+
+// TxnRead represents a read-only transaction with operations that will not
+// block other read transactions.
+type TxnRead interface {
+ ReadView
+ // End marks the transaction is complete and ready to commit.
+ End()
+}
+
+type WriteView interface {
+ // DeleteRange deletes the given range from the store.
+ // A deleteRange increases the rev of the store if any key in the range exists.
+ // The number of key deleted will be returned.
+ // The returned rev is the current revision of the KV when the operation is executed.
+ // It also generates one event for each key delete in the event history.
+ // if the `end` is nil, deleteRange deletes the key.
+ // if the `end` is not nil, deleteRange deletes the keys in range [key, range_end).
+ DeleteRange(key, end []byte) (n, rev int64)
+
+ // Put puts the given key, value into the store. Put also takes additional argument lease to
+ // attach a lease to a key-value pair as meta-data. KV implementation does not validate the lease
+ // id.
+ // A put also increases the rev of the store, and generates one event in the event history.
+ // The returned rev is the current revision of the KV when the operation is executed.
+ Put(key, value []byte, lease lease.LeaseID) (rev int64)
+}
+
+// TxnWrite represents a transaction that can modify the store.
+type TxnWrite interface {
+ TxnRead
+ WriteView
+ // Changes gets the changes made since opening the write txn.
+ Changes() []mvccpb.KeyValue
+}
+
+// txnReadWrite coerces a read txn to a write, panicking on any write operation.
+type txnReadWrite struct{ TxnRead }
+
+func (trw *txnReadWrite) DeleteRange(key, end []byte) (n, rev int64) { panic("unexpected DeleteRange") }
+func (trw *txnReadWrite) Put(key, value []byte, lease lease.LeaseID) (rev int64) {
+ panic("unexpected Put")
+}
+func (trw *txnReadWrite) Changes() []mvccpb.KeyValue { return nil }
+
+func NewReadOnlyTxnWrite(txn TxnRead) TxnWrite { return &txnReadWrite{txn} }
+
+type KV interface {
+ ReadView
+ WriteView
+
+ // Read creates a read transaction.
+ Read() TxnRead
+
+ // Write creates a write transaction.
+ Write() TxnWrite
+
+ // Hash retrieves the hash of KV state and revision.
+ // This method is designed for consistency checking purposes.
+ Hash() (hash uint32, revision int64, err error)
+
+ // Compact frees all superseded keys with revisions less than rev.
+ Compact(rev int64) (<-chan struct{}, error)
+
+ // Commit commits outstanding txns into the underlying backend.
+ Commit()
+
+ // Restore restores the KV store from a backend.
+ Restore(b backend.Backend) error
+ Close() error
+}
+
+// WatchableKV is a KV that can be watched.
+type WatchableKV interface {
+ KV
+ Watchable
+}
+
+// Watchable is the interface that wraps the NewWatchStream function.
+type Watchable interface {
+ // NewWatchStream returns a WatchStream that can be used to
+ // watch events happened or happening on the KV.
+ NewWatchStream() WatchStream
+}
+
+// ConsistentWatchableKV is a WatchableKV that understands the consistency
+// algorithm and consistent index.
+// If the consistent index of executing entry is not larger than the
+// consistent index of ConsistentWatchableKV, all operations in
+// this entry are skipped and return empty response.
+type ConsistentWatchableKV interface {
+ WatchableKV
+ // ConsistentIndex returns the current consistent index of the KV.
+ ConsistentIndex() uint64
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/kv_test.go b/vendor/github.com/coreos/etcd/mvcc/kv_test.go
new file mode 100644
index 00000000..162dac40
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/kv_test.go
@@ -0,0 +1,811 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "fmt"
+ "os"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+// Functional tests for features implemented in v3 store. It treats v3 store
+// as a black box, and tests it by feeding the input and validating the output.
+
+// TODO: add similar tests on operations in one txn/rev
+
+type (
+ rangeFunc func(kv KV, key, end []byte, ro RangeOptions) (*RangeResult, error)
+ putFunc func(kv KV, key, value []byte, lease lease.LeaseID) int64
+ deleteRangeFunc func(kv KV, key, end []byte) (n, rev int64)
+)
+
+var (
+ normalRangeFunc = func(kv KV, key, end []byte, ro RangeOptions) (*RangeResult, error) {
+ return kv.Range(key, end, ro)
+ }
+ txnRangeFunc = func(kv KV, key, end []byte, ro RangeOptions) (*RangeResult, error) {
+ txn := kv.Read()
+ defer txn.End()
+ return txn.Range(key, end, ro)
+ }
+
+ normalPutFunc = func(kv KV, key, value []byte, lease lease.LeaseID) int64 {
+ return kv.Put(key, value, lease)
+ }
+ txnPutFunc = func(kv KV, key, value []byte, lease lease.LeaseID) int64 {
+ txn := kv.Write()
+ defer txn.End()
+ return txn.Put(key, value, lease)
+ }
+
+ normalDeleteRangeFunc = func(kv KV, key, end []byte) (n, rev int64) {
+ return kv.DeleteRange(key, end)
+ }
+ txnDeleteRangeFunc = func(kv KV, key, end []byte) (n, rev int64) {
+ txn := kv.Write()
+ defer txn.End()
+ return txn.DeleteRange(key, end)
+ }
+)
+
+func TestKVRange(t *testing.T) { testKVRange(t, normalRangeFunc) }
+func TestKVTxnRange(t *testing.T) { testKVRange(t, txnRangeFunc) }
+
+func testKVRange(t *testing.T, f rangeFunc) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer cleanup(s, b, tmpPath)
+
+ kvs := put3TestKVs(s)
+
+ wrev := int64(4)
+ tests := []struct {
+ key, end []byte
+ wkvs []mvccpb.KeyValue
+ }{
+ // get no keys
+ {
+ []byte("doo"), []byte("foo"),
+ nil,
+ },
+ // get no keys when key == end
+ {
+ []byte("foo"), []byte("foo"),
+ nil,
+ },
+ // get no keys when ranging single key
+ {
+ []byte("doo"), nil,
+ nil,
+ },
+ // get all keys
+ {
+ []byte("foo"), []byte("foo3"),
+ kvs,
+ },
+ // get partial keys
+ {
+ []byte("foo"), []byte("foo1"),
+ kvs[:1],
+ },
+ // get single key
+ {
+ []byte("foo"), nil,
+ kvs[:1],
+ },
+ // get entire keyspace
+ {
+ []byte(""), []byte(""),
+ kvs,
+ },
+ }
+
+ for i, tt := range tests {
+ r, err := f(s, tt.key, tt.end, RangeOptions{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if r.Rev != wrev {
+ t.Errorf("#%d: rev = %d, want %d", i, r.Rev, wrev)
+ }
+ if !reflect.DeepEqual(r.KVs, tt.wkvs) {
+ t.Errorf("#%d: kvs = %+v, want %+v", i, r.KVs, tt.wkvs)
+ }
+ }
+}
+
+func TestKVRangeRev(t *testing.T) { testKVRangeRev(t, normalRangeFunc) }
+func TestKVTxnRangeRev(t *testing.T) { testKVRangeRev(t, txnRangeFunc) }
+
+func testKVRangeRev(t *testing.T, f rangeFunc) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer cleanup(s, b, tmpPath)
+
+ kvs := put3TestKVs(s)
+
+ tests := []struct {
+ rev int64
+ wrev int64
+ wkvs []mvccpb.KeyValue
+ }{
+ {-1, 4, kvs},
+ {0, 4, kvs},
+ {2, 4, kvs[:1]},
+ {3, 4, kvs[:2]},
+ {4, 4, kvs},
+ }
+
+ for i, tt := range tests {
+ r, err := f(s, []byte("foo"), []byte("foo3"), RangeOptions{Rev: tt.rev})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if r.Rev != tt.wrev {
+ t.Errorf("#%d: rev = %d, want %d", i, r.Rev, tt.wrev)
+ }
+ if !reflect.DeepEqual(r.KVs, tt.wkvs) {
+ t.Errorf("#%d: kvs = %+v, want %+v", i, r.KVs, tt.wkvs)
+ }
+ }
+}
+
+func TestKVRangeBadRev(t *testing.T) { testKVRangeBadRev(t, normalRangeFunc) }
+func TestKVTxnRangeBadRev(t *testing.T) { testKVRangeBadRev(t, txnRangeFunc) }
+
+func testKVRangeBadRev(t *testing.T, f rangeFunc) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer cleanup(s, b, tmpPath)
+
+ put3TestKVs(s)
+ if _, err := s.Compact(4); err != nil {
+ t.Fatalf("compact error (%v)", err)
+ }
+
+ tests := []struct {
+ rev int64
+ werr error
+ }{
+ {-1, nil}, // <= 0 is most recent store
+ {0, nil},
+ {1, ErrCompacted},
+ {2, ErrCompacted},
+ {4, nil},
+ {5, ErrFutureRev},
+ {100, ErrFutureRev},
+ }
+ for i, tt := range tests {
+ _, err := f(s, []byte("foo"), []byte("foo3"), RangeOptions{Rev: tt.rev})
+ if err != tt.werr {
+ t.Errorf("#%d: error = %v, want %v", i, err, tt.werr)
+ }
+ }
+}
+
+func TestKVRangeLimit(t *testing.T) { testKVRangeLimit(t, normalRangeFunc) }
+func TestKVTxnRangeLimit(t *testing.T) { testKVRangeLimit(t, txnRangeFunc) }
+
+func testKVRangeLimit(t *testing.T, f rangeFunc) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer cleanup(s, b, tmpPath)
+
+ kvs := put3TestKVs(s)
+
+ wrev := int64(4)
+ tests := []struct {
+ limit int64
+ wkvs []mvccpb.KeyValue
+ }{
+ // no limit
+ {-1, kvs},
+ // no limit
+ {0, kvs},
+ {1, kvs[:1]},
+ {2, kvs[:2]},
+ {3, kvs},
+ {100, kvs},
+ }
+ for i, tt := range tests {
+ r, err := f(s, []byte("foo"), []byte("foo3"), RangeOptions{Limit: tt.limit})
+ if err != nil {
+ t.Fatalf("#%d: range error (%v)", i, err)
+ }
+ if !reflect.DeepEqual(r.KVs, tt.wkvs) {
+ t.Errorf("#%d: kvs = %+v, want %+v", i, r.KVs, tt.wkvs)
+ }
+ if r.Rev != wrev {
+ t.Errorf("#%d: rev = %d, want %d", i, r.Rev, wrev)
+ }
+ if r.Count != len(kvs) {
+ t.Errorf("#%d: count = %d, want %d", i, r.Count, len(kvs))
+ }
+ }
+}
+
+func TestKVPutMultipleTimes(t *testing.T) { testKVPutMultipleTimes(t, normalPutFunc) }
+func TestKVTxnPutMultipleTimes(t *testing.T) { testKVPutMultipleTimes(t, txnPutFunc) }
+
+func testKVPutMultipleTimes(t *testing.T, f putFunc) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer cleanup(s, b, tmpPath)
+
+ for i := 0; i < 10; i++ {
+ base := int64(i + 1)
+
+ rev := f(s, []byte("foo"), []byte("bar"), lease.LeaseID(base))
+ if rev != base+1 {
+ t.Errorf("#%d: rev = %d, want %d", i, rev, base+1)
+ }
+
+ r, err := s.Range([]byte("foo"), nil, RangeOptions{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ wkvs := []mvccpb.KeyValue{
+ {Key: []byte("foo"), Value: []byte("bar"), CreateRevision: 2, ModRevision: base + 1, Version: base, Lease: base},
+ }
+ if !reflect.DeepEqual(r.KVs, wkvs) {
+ t.Errorf("#%d: kvs = %+v, want %+v", i, r.KVs, wkvs)
+ }
+ }
+}
+
+func TestKVDeleteRange(t *testing.T) { testKVDeleteRange(t, normalDeleteRangeFunc) }
+func TestKVTxnDeleteRange(t *testing.T) { testKVDeleteRange(t, txnDeleteRangeFunc) }
+
+func testKVDeleteRange(t *testing.T, f deleteRangeFunc) {
+ tests := []struct {
+ key, end []byte
+
+ wrev int64
+ wN int64
+ }{
+ {
+ []byte("foo"), nil,
+ 5, 1,
+ },
+ {
+ []byte("foo"), []byte("foo1"),
+ 5, 1,
+ },
+ {
+ []byte("foo"), []byte("foo2"),
+ 5, 2,
+ },
+ {
+ []byte("foo"), []byte("foo3"),
+ 5, 3,
+ },
+ {
+ []byte("foo3"), []byte("foo8"),
+ 4, 0,
+ },
+ {
+ []byte("foo3"), nil,
+ 4, 0,
+ },
+ }
+
+ for i, tt := range tests {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+
+ s.Put([]byte("foo"), []byte("bar"), lease.NoLease)
+ s.Put([]byte("foo1"), []byte("bar1"), lease.NoLease)
+ s.Put([]byte("foo2"), []byte("bar2"), lease.NoLease)
+
+ n, rev := f(s, tt.key, tt.end)
+ if n != tt.wN || rev != tt.wrev {
+ t.Errorf("#%d: n = %d, rev = %d, want (%d, %d)", i, n, rev, tt.wN, tt.wrev)
+ }
+
+ cleanup(s, b, tmpPath)
+ }
+}
+
+func TestKVDeleteMultipleTimes(t *testing.T) { testKVDeleteMultipleTimes(t, normalDeleteRangeFunc) }
+func TestKVTxnDeleteMultipleTimes(t *testing.T) { testKVDeleteMultipleTimes(t, txnDeleteRangeFunc) }
+
+func testKVDeleteMultipleTimes(t *testing.T, f deleteRangeFunc) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer cleanup(s, b, tmpPath)
+
+ s.Put([]byte("foo"), []byte("bar"), lease.NoLease)
+
+ n, rev := f(s, []byte("foo"), nil)
+ if n != 1 || rev != 3 {
+ t.Fatalf("n = %d, rev = %d, want (%d, %d)", n, rev, 1, 3)
+ }
+
+ for i := 0; i < 10; i++ {
+ n, rev := f(s, []byte("foo"), nil)
+ if n != 0 || rev != 3 {
+ t.Fatalf("#%d: n = %d, rev = %d, want (%d, %d)", i, n, rev, 0, 3)
+ }
+ }
+}
+
+// test that range, put, delete on single key in sequence repeatedly works correctly.
+func TestKVOperationInSequence(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer cleanup(s, b, tmpPath)
+
+ for i := 0; i < 10; i++ {
+ base := int64(i*2 + 1)
+
+ // put foo
+ rev := s.Put([]byte("foo"), []byte("bar"), lease.NoLease)
+ if rev != base+1 {
+ t.Errorf("#%d: put rev = %d, want %d", i, rev, base+1)
+ }
+
+ r, err := s.Range([]byte("foo"), nil, RangeOptions{Rev: base + 1})
+ if err != nil {
+ t.Fatal(err)
+ }
+ wkvs := []mvccpb.KeyValue{
+ {Key: []byte("foo"), Value: []byte("bar"), CreateRevision: base + 1, ModRevision: base + 1, Version: 1, Lease: int64(lease.NoLease)},
+ }
+ if !reflect.DeepEqual(r.KVs, wkvs) {
+ t.Errorf("#%d: kvs = %+v, want %+v", i, r.KVs, wkvs)
+ }
+ if r.Rev != base+1 {
+ t.Errorf("#%d: range rev = %d, want %d", i, rev, base+1)
+ }
+
+ // delete foo
+ n, rev := s.DeleteRange([]byte("foo"), nil)
+ if n != 1 || rev != base+2 {
+ t.Errorf("#%d: n = %d, rev = %d, want (%d, %d)", i, n, rev, 1, base+2)
+ }
+
+ r, err = s.Range([]byte("foo"), nil, RangeOptions{Rev: base + 2})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if r.KVs != nil {
+ t.Errorf("#%d: kvs = %+v, want %+v", i, r.KVs, nil)
+ }
+ if r.Rev != base+2 {
+ t.Errorf("#%d: range rev = %d, want %d", i, r.Rev, base+2)
+ }
+ }
+}
+
+func TestKVTxnBlockWriteOperations(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+
+ tests := []func(){
+ func() { s.Put([]byte("foo"), nil, lease.NoLease) },
+ func() { s.DeleteRange([]byte("foo"), nil) },
+ }
+ for i, tt := range tests {
+ txn := s.Write()
+ done := make(chan struct{}, 1)
+ go func() {
+ tt()
+ done <- struct{}{}
+ }()
+ select {
+ case <-done:
+ t.Fatalf("#%d: operation failed to be blocked", i)
+ case <-time.After(10 * time.Millisecond):
+ }
+
+ txn.End()
+ select {
+ case <-done:
+ case <-time.After(10 * time.Second):
+ testutil.FatalStack(t, fmt.Sprintf("#%d: operation failed to be unblocked", i))
+ }
+ }
+
+ // only close backend when we know all the tx are finished
+ cleanup(s, b, tmpPath)
+}
+
+func TestKVTxnNonBlockRange(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer cleanup(s, b, tmpPath)
+
+ txn := s.Write()
+ defer txn.End()
+
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ s.Range([]byte("foo"), nil, RangeOptions{})
+ }()
+ select {
+ case <-donec:
+ case <-time.After(100 * time.Millisecond):
+ t.Fatalf("range operation blocked on write txn")
+ }
+}
+
+// test that txn range, put, delete on single key in sequence repeatedly works correctly.
+func TestKVTxnOperationInSequence(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer cleanup(s, b, tmpPath)
+
+ for i := 0; i < 10; i++ {
+ txn := s.Write()
+ base := int64(i + 1)
+
+ // put foo
+ rev := txn.Put([]byte("foo"), []byte("bar"), lease.NoLease)
+ if rev != base+1 {
+ t.Errorf("#%d: put rev = %d, want %d", i, rev, base+1)
+ }
+
+ r, err := txn.Range([]byte("foo"), nil, RangeOptions{Rev: base + 1})
+ if err != nil {
+ t.Fatal(err)
+ }
+ wkvs := []mvccpb.KeyValue{
+ {Key: []byte("foo"), Value: []byte("bar"), CreateRevision: base + 1, ModRevision: base + 1, Version: 1, Lease: int64(lease.NoLease)},
+ }
+ if !reflect.DeepEqual(r.KVs, wkvs) {
+ t.Errorf("#%d: kvs = %+v, want %+v", i, r.KVs, wkvs)
+ }
+ if r.Rev != base+1 {
+ t.Errorf("#%d: range rev = %d, want %d", i, r.Rev, base+1)
+ }
+
+ // delete foo
+ n, rev := txn.DeleteRange([]byte("foo"), nil)
+ if n != 1 || rev != base+1 {
+ t.Errorf("#%d: n = %d, rev = %d, want (%d, %d)", i, n, rev, 1, base+1)
+ }
+
+ r, err = txn.Range([]byte("foo"), nil, RangeOptions{Rev: base + 1})
+ if err != nil {
+ t.Errorf("#%d: range error (%v)", i, err)
+ }
+ if r.KVs != nil {
+ t.Errorf("#%d: kvs = %+v, want %+v", i, r.KVs, nil)
+ }
+ if r.Rev != base+1 {
+ t.Errorf("#%d: range rev = %d, want %d", i, r.Rev, base+1)
+ }
+
+ txn.End()
+ }
+}
+
+func TestKVCompactReserveLastValue(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer cleanup(s, b, tmpPath)
+
+ s.Put([]byte("foo"), []byte("bar0"), 1)
+ s.Put([]byte("foo"), []byte("bar1"), 2)
+ s.DeleteRange([]byte("foo"), nil)
+ s.Put([]byte("foo"), []byte("bar2"), 3)
+
+ // rev in tests will be called in Compact() one by one on the same store
+ tests := []struct {
+ rev int64
+ // wanted kvs right after the compacted rev
+ wkvs []mvccpb.KeyValue
+ }{
+ {
+ 1,
+ []mvccpb.KeyValue{
+ {Key: []byte("foo"), Value: []byte("bar0"), CreateRevision: 2, ModRevision: 2, Version: 1, Lease: 1},
+ },
+ },
+ {
+ 2,
+ []mvccpb.KeyValue{
+ {Key: []byte("foo"), Value: []byte("bar1"), CreateRevision: 2, ModRevision: 3, Version: 2, Lease: 2},
+ },
+ },
+ {
+ 3,
+ nil,
+ },
+ {
+ 4,
+ []mvccpb.KeyValue{
+ {Key: []byte("foo"), Value: []byte("bar2"), CreateRevision: 5, ModRevision: 5, Version: 1, Lease: 3},
+ },
+ },
+ }
+ for i, tt := range tests {
+ _, err := s.Compact(tt.rev)
+ if err != nil {
+ t.Errorf("#%d: unexpect compact error %v", i, err)
+ }
+ r, err := s.Range([]byte("foo"), nil, RangeOptions{Rev: tt.rev + 1})
+ if err != nil {
+ t.Errorf("#%d: unexpect range error %v", i, err)
+ }
+ if !reflect.DeepEqual(r.KVs, tt.wkvs) {
+ t.Errorf("#%d: kvs = %+v, want %+v", i, r.KVs, tt.wkvs)
+ }
+ }
+}
+
+func TestKVCompactBad(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer cleanup(s, b, tmpPath)
+
+ s.Put([]byte("foo"), []byte("bar0"), lease.NoLease)
+ s.Put([]byte("foo"), []byte("bar1"), lease.NoLease)
+ s.Put([]byte("foo"), []byte("bar2"), lease.NoLease)
+
+ // rev in tests will be called in Compact() one by one on the same store
+ tests := []struct {
+ rev int64
+ werr error
+ }{
+ {0, nil},
+ {1, nil},
+ {1, ErrCompacted},
+ {4, nil},
+ {5, ErrFutureRev},
+ {100, ErrFutureRev},
+ }
+ for i, tt := range tests {
+ _, err := s.Compact(tt.rev)
+ if err != tt.werr {
+ t.Errorf("#%d: compact error = %v, want %v", i, err, tt.werr)
+ }
+ }
+}
+
+func TestKVHash(t *testing.T) {
+ hashes := make([]uint32, 3)
+
+ for i := 0; i < len(hashes); i++ {
+ var err error
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ kv := NewStore(b, &lease.FakeLessor{}, nil)
+ kv.Put([]byte("foo0"), []byte("bar0"), lease.NoLease)
+ kv.Put([]byte("foo1"), []byte("bar0"), lease.NoLease)
+ hashes[i], _, err = kv.Hash()
+ if err != nil {
+ t.Fatalf("failed to get hash: %v", err)
+ }
+ cleanup(kv, b, tmpPath)
+ }
+
+ for i := 1; i < len(hashes); i++ {
+ if hashes[i-1] != hashes[i] {
+ t.Errorf("hash[%d](%d) != hash[%d](%d)", i-1, hashes[i-1], i, hashes[i])
+ }
+ }
+}
+
+func TestKVRestore(t *testing.T) {
+ tests := []func(kv KV){
+ func(kv KV) {
+ kv.Put([]byte("foo"), []byte("bar0"), 1)
+ kv.Put([]byte("foo"), []byte("bar1"), 2)
+ kv.Put([]byte("foo"), []byte("bar2"), 3)
+ },
+ func(kv KV) {
+ kv.Put([]byte("foo"), []byte("bar0"), 1)
+ kv.DeleteRange([]byte("foo"), nil)
+ kv.Put([]byte("foo"), []byte("bar1"), 2)
+ },
+ func(kv KV) {
+ kv.Put([]byte("foo"), []byte("bar0"), 1)
+ kv.Put([]byte("foo"), []byte("bar1"), 2)
+ kv.Compact(1)
+ },
+ }
+ for i, tt := range tests {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ tt(s)
+ var kvss [][]mvccpb.KeyValue
+ for k := int64(0); k < 10; k++ {
+ r, _ := s.Range([]byte("a"), []byte("z"), RangeOptions{Rev: k})
+ kvss = append(kvss, r.KVs)
+ }
+ s.Close()
+
+ // ns should recover the the previous state from backend.
+ ns := NewStore(b, &lease.FakeLessor{}, nil)
+ // wait for possible compaction to finish
+ testutil.WaitSchedule()
+ var nkvss [][]mvccpb.KeyValue
+ for k := int64(0); k < 10; k++ {
+ r, _ := ns.Range([]byte("a"), []byte("z"), RangeOptions{Rev: k})
+ nkvss = append(nkvss, r.KVs)
+ }
+ cleanup(ns, b, tmpPath)
+
+ if !reflect.DeepEqual(nkvss, kvss) {
+ t.Errorf("#%d: kvs history = %+v, want %+v", i, nkvss, kvss)
+ }
+ }
+}
+
+func TestKVSnapshot(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer cleanup(s, b, tmpPath)
+
+ wkvs := put3TestKVs(s)
+
+ newPath := "new_test"
+ f, err := os.Create(newPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.Remove(newPath)
+
+ snap := s.b.Snapshot()
+ defer snap.Close()
+ _, err = snap.WriteTo(f)
+ if err != nil {
+ t.Fatal(err)
+ }
+ f.Close()
+
+ ns := NewStore(b, &lease.FakeLessor{}, nil)
+ defer ns.Close()
+ r, err := ns.Range([]byte("a"), []byte("z"), RangeOptions{})
+ if err != nil {
+ t.Errorf("unexpect range error (%v)", err)
+ }
+ if !reflect.DeepEqual(r.KVs, wkvs) {
+ t.Errorf("kvs = %+v, want %+v", r.KVs, wkvs)
+ }
+ if r.Rev != 4 {
+ t.Errorf("rev = %d, want %d", r.Rev, 4)
+ }
+}
+
+func TestWatchableKVWatch(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := WatchableKV(newWatchableStore(b, &lease.FakeLessor{}, nil))
+ defer cleanup(s, b, tmpPath)
+
+ w := s.NewWatchStream()
+ defer w.Close()
+
+ wid := w.Watch([]byte("foo"), []byte("fop"), 0)
+
+ wev := []mvccpb.Event{
+ {Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{
+ Key: []byte("foo"),
+ Value: []byte("bar"),
+ CreateRevision: 2,
+ ModRevision: 2,
+ Version: 1,
+ Lease: 1,
+ },
+ },
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{
+ Key: []byte("foo1"),
+ Value: []byte("bar1"),
+ CreateRevision: 3,
+ ModRevision: 3,
+ Version: 1,
+ Lease: 2,
+ },
+ },
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{
+ Key: []byte("foo1"),
+ Value: []byte("bar11"),
+ CreateRevision: 3,
+ ModRevision: 4,
+ Version: 2,
+ Lease: 3,
+ },
+ },
+ }
+
+ s.Put([]byte("foo"), []byte("bar"), 1)
+ select {
+ case resp := <-w.Chan():
+ if resp.WatchID != wid {
+ t.Errorf("resp.WatchID got = %d, want = %d", resp.WatchID, wid)
+ }
+ ev := resp.Events[0]
+ if !reflect.DeepEqual(ev, wev[0]) {
+ t.Errorf("watched event = %+v, want %+v", ev, wev[0])
+ }
+ case <-time.After(5 * time.Second):
+ // CPU might be too slow, and the routine is not able to switch around
+ testutil.FatalStack(t, "failed to watch the event")
+ }
+
+ s.Put([]byte("foo1"), []byte("bar1"), 2)
+ select {
+ case resp := <-w.Chan():
+ if resp.WatchID != wid {
+ t.Errorf("resp.WatchID got = %d, want = %d", resp.WatchID, wid)
+ }
+ ev := resp.Events[0]
+ if !reflect.DeepEqual(ev, wev[1]) {
+ t.Errorf("watched event = %+v, want %+v", ev, wev[1])
+ }
+ case <-time.After(5 * time.Second):
+ testutil.FatalStack(t, "failed to watch the event")
+ }
+
+ w = s.NewWatchStream()
+ wid = w.Watch([]byte("foo1"), []byte("foo2"), 3)
+
+ select {
+ case resp := <-w.Chan():
+ if resp.WatchID != wid {
+ t.Errorf("resp.WatchID got = %d, want = %d", resp.WatchID, wid)
+ }
+ ev := resp.Events[0]
+ if !reflect.DeepEqual(ev, wev[1]) {
+ t.Errorf("watched event = %+v, want %+v", ev, wev[1])
+ }
+ case <-time.After(5 * time.Second):
+ testutil.FatalStack(t, "failed to watch the event")
+ }
+
+ s.Put([]byte("foo1"), []byte("bar11"), 3)
+ select {
+ case resp := <-w.Chan():
+ if resp.WatchID != wid {
+ t.Errorf("resp.WatchID got = %d, want = %d", resp.WatchID, wid)
+ }
+ ev := resp.Events[0]
+ if !reflect.DeepEqual(ev, wev[2]) {
+ t.Errorf("watched event = %+v, want %+v", ev, wev[2])
+ }
+ case <-time.After(5 * time.Second):
+ testutil.FatalStack(t, "failed to watch the event")
+ }
+}
+
+func cleanup(s KV, b backend.Backend, path string) {
+ s.Close()
+ b.Close()
+ os.Remove(path)
+}
+
+func put3TestKVs(s KV) []mvccpb.KeyValue {
+ s.Put([]byte("foo"), []byte("bar"), 1)
+ s.Put([]byte("foo1"), []byte("bar1"), 2)
+ s.Put([]byte("foo2"), []byte("bar2"), 3)
+ return []mvccpb.KeyValue{
+ {Key: []byte("foo"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1, Lease: 1},
+ {Key: []byte("foo1"), Value: []byte("bar1"), CreateRevision: 3, ModRevision: 3, Version: 1, Lease: 2},
+ {Key: []byte("foo2"), Value: []byte("bar2"), CreateRevision: 4, ModRevision: 4, Version: 1, Lease: 3},
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/kv_view.go b/vendor/github.com/coreos/etcd/mvcc/kv_view.go
new file mode 100644
index 00000000..f40ba8ed
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/kv_view.go
@@ -0,0 +1,53 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "github.com/coreos/etcd/lease"
+)
+
+type readView struct{ kv KV }
+
+func (rv *readView) FirstRev() int64 {
+ tr := rv.kv.Read()
+ defer tr.End()
+ return tr.FirstRev()
+}
+
+func (rv *readView) Rev() int64 {
+ tr := rv.kv.Read()
+ defer tr.End()
+ return tr.Rev()
+}
+
+func (rv *readView) Range(key, end []byte, ro RangeOptions) (r *RangeResult, err error) {
+ tr := rv.kv.Read()
+ defer tr.End()
+ return tr.Range(key, end, ro)
+}
+
+type writeView struct{ kv KV }
+
+func (wv *writeView) DeleteRange(key, end []byte) (n, rev int64) {
+ tw := wv.kv.Write()
+ defer tw.End()
+ return tw.DeleteRange(key, end)
+}
+
+func (wv *writeView) Put(key, value []byte, lease lease.LeaseID) (rev int64) {
+ tw := wv.kv.Write()
+ defer tw.End()
+ return tw.Put(key, value, lease)
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/kvstore.go b/vendor/github.com/coreos/etcd/mvcc/kvstore.go
new file mode 100644
index 00000000..283bdf50
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/kvstore.go
@@ -0,0 +1,458 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "encoding/binary"
+ "errors"
+ "math"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/coreos/etcd/pkg/schedule"
+ "github.com/coreos/pkg/capnslog"
+ "golang.org/x/net/context"
+)
+
+var (
+ keyBucketName = []byte("key")
+ metaBucketName = []byte("meta")
+
+ consistentIndexKeyName = []byte("consistent_index")
+ scheduledCompactKeyName = []byte("scheduledCompactRev")
+ finishedCompactKeyName = []byte("finishedCompactRev")
+
+ ErrCompacted = errors.New("mvcc: required revision has been compacted")
+ ErrFutureRev = errors.New("mvcc: required revision is a future revision")
+ ErrCanceled = errors.New("mvcc: watcher is canceled")
+ ErrClosed = errors.New("mvcc: closed")
+
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "mvcc")
+)
+
+const (
+ // markedRevBytesLen is the byte length of marked revision.
+ // The first `revBytesLen` bytes represents a normal revision. The last
+ // one byte is the mark.
+ markedRevBytesLen = revBytesLen + 1
+ markBytePosition = markedRevBytesLen - 1
+ markTombstone byte = 't'
+)
+
+var restoreChunkKeys = 10000 // non-const for testing
+
+// ConsistentIndexGetter is an interface that wraps the Get method.
+// Consistent index is the offset of an entry in a consistent replicated log.
+type ConsistentIndexGetter interface {
+ // ConsistentIndex returns the consistent index of current executing entry.
+ ConsistentIndex() uint64
+}
+
+type store struct {
+ ReadView
+ WriteView
+
+ // mu read locks for txns and write locks for non-txn store changes.
+ mu sync.RWMutex
+
+ ig ConsistentIndexGetter
+
+ b backend.Backend
+ kvindex index
+
+ le lease.Lessor
+
+ // revMuLock protects currentRev and compactMainRev.
+ // Locked at end of write txn and released after write txn unlock lock.
+ // Locked before locking read txn and released after locking.
+ revMu sync.RWMutex
+ // currentRev is the revision of the last completed transaction.
+ currentRev int64
+ // compactMainRev is the main revision of the last compaction.
+ compactMainRev int64
+
+ // bytesBuf8 is a byte slice of length 8
+ // to avoid a repetitive allocation in saveIndex.
+ bytesBuf8 []byte
+
+ fifoSched schedule.Scheduler
+
+ stopc chan struct{}
+}
+
+// NewStore returns a new store. It is useful to create a store inside
+// mvcc pkg. It should only be used for testing externally.
+func NewStore(b backend.Backend, le lease.Lessor, ig ConsistentIndexGetter) *store {
+ s := &store{
+ b: b,
+ ig: ig,
+ kvindex: newTreeIndex(),
+
+ le: le,
+
+ currentRev: 1,
+ compactMainRev: -1,
+
+ bytesBuf8: make([]byte, 8),
+ fifoSched: schedule.NewFIFOScheduler(),
+
+ stopc: make(chan struct{}),
+ }
+ s.ReadView = &readView{s}
+ s.WriteView = &writeView{s}
+ if s.le != nil {
+ s.le.SetRangeDeleter(func() lease.TxnDelete { return s.Write() })
+ }
+
+ tx := s.b.BatchTx()
+ tx.Lock()
+ tx.UnsafeCreateBucket(keyBucketName)
+ tx.UnsafeCreateBucket(metaBucketName)
+ tx.Unlock()
+ s.b.ForceCommit()
+
+ if err := s.restore(); err != nil {
+ // TODO: return the error instead of panic here?
+ panic("failed to recover store from backend")
+ }
+
+ return s
+}
+
+func (s *store) compactBarrier(ctx context.Context, ch chan struct{}) {
+ if ctx == nil || ctx.Err() != nil {
+ s.mu.Lock()
+ select {
+ case <-s.stopc:
+ default:
+ f := func(ctx context.Context) { s.compactBarrier(ctx, ch) }
+ s.fifoSched.Schedule(f)
+ }
+ s.mu.Unlock()
+ return
+ }
+ close(ch)
+}
+
+func (s *store) Hash() (hash uint32, revision int64, err error) {
+ s.b.ForceCommit()
+ h, err := s.b.Hash(DefaultIgnores)
+ return h, s.currentRev, err
+}
+
+func (s *store) Compact(rev int64) (<-chan struct{}, error) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ s.revMu.Lock()
+ defer s.revMu.Unlock()
+
+ if rev <= s.compactMainRev {
+ ch := make(chan struct{})
+ f := func(ctx context.Context) { s.compactBarrier(ctx, ch) }
+ s.fifoSched.Schedule(f)
+ return ch, ErrCompacted
+ }
+ if rev > s.currentRev {
+ return nil, ErrFutureRev
+ }
+
+ start := time.Now()
+
+ s.compactMainRev = rev
+
+ rbytes := newRevBytes()
+ revToBytes(revision{main: rev}, rbytes)
+
+ tx := s.b.BatchTx()
+ tx.Lock()
+ tx.UnsafePut(metaBucketName, scheduledCompactKeyName, rbytes)
+ tx.Unlock()
+ // ensure that desired compaction is persisted
+ s.b.ForceCommit()
+
+ keep := s.kvindex.Compact(rev)
+ ch := make(chan struct{})
+ var j = func(ctx context.Context) {
+ if ctx.Err() != nil {
+ s.compactBarrier(ctx, ch)
+ return
+ }
+ if !s.scheduleCompaction(rev, keep) {
+ s.compactBarrier(nil, ch)
+ return
+ }
+ close(ch)
+ }
+
+ s.fifoSched.Schedule(j)
+
+ indexCompactionPauseDurations.Observe(float64(time.Since(start) / time.Millisecond))
+ return ch, nil
+}
+
+// DefaultIgnores is a map of keys to ignore in hash checking.
+var DefaultIgnores map[backend.IgnoreKey]struct{}
+
+func init() {
+ DefaultIgnores = map[backend.IgnoreKey]struct{}{
+ // consistent index might be changed due to v2 internal sync, which
+ // is not controllable by the user.
+ {Bucket: string(metaBucketName), Key: string(consistentIndexKeyName)}: {},
+ }
+}
+
+func (s *store) Commit() {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+
+ tx := s.b.BatchTx()
+ tx.Lock()
+ s.saveIndex(tx)
+ tx.Unlock()
+ s.b.ForceCommit()
+}
+
+func (s *store) Restore(b backend.Backend) error {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+
+ close(s.stopc)
+ s.fifoSched.Stop()
+
+ s.b = b
+ s.kvindex = newTreeIndex()
+ s.currentRev = 1
+ s.compactMainRev = -1
+ s.fifoSched = schedule.NewFIFOScheduler()
+ s.stopc = make(chan struct{})
+
+ return s.restore()
+}
+
+func (s *store) restore() error {
+ reportDbTotalSizeInBytesMu.Lock()
+ b := s.b
+ reportDbTotalSizeInBytes = func() float64 { return float64(b.Size()) }
+ reportDbTotalSizeInBytesMu.Unlock()
+
+ min, max := newRevBytes(), newRevBytes()
+ revToBytes(revision{main: 1}, min)
+ revToBytes(revision{main: math.MaxInt64, sub: math.MaxInt64}, max)
+
+ keyToLease := make(map[string]lease.LeaseID)
+
+ // restore index
+ tx := s.b.BatchTx()
+ tx.Lock()
+
+ _, finishedCompactBytes := tx.UnsafeRange(metaBucketName, finishedCompactKeyName, nil, 0)
+ if len(finishedCompactBytes) != 0 {
+ s.compactMainRev = bytesToRev(finishedCompactBytes[0]).main
+ plog.Printf("restore compact to %d", s.compactMainRev)
+ }
+ _, scheduledCompactBytes := tx.UnsafeRange(metaBucketName, scheduledCompactKeyName, nil, 0)
+ scheduledCompact := int64(0)
+ if len(scheduledCompactBytes) != 0 {
+ scheduledCompact = bytesToRev(scheduledCompactBytes[0]).main
+ }
+
+ // index keys concurrently as they're loaded in from tx
+ rkvc, revc := restoreIntoIndex(s.kvindex)
+ for {
+ keys, vals := tx.UnsafeRange(keyBucketName, min, max, int64(restoreChunkKeys))
+ if len(keys) == 0 {
+ break
+ }
+ // rkvc blocks if the total pending keys exceeds the restore
+ // chunk size to keep keys from consuming too much memory.
+ restoreChunk(rkvc, keys, vals, keyToLease)
+ if len(keys) < restoreChunkKeys {
+ // partial set implies final set
+ break
+ }
+ // next set begins after where this one ended
+ newMin := bytesToRev(keys[len(keys)-1][:revBytesLen])
+ newMin.sub++
+ revToBytes(newMin, min)
+ }
+ close(rkvc)
+ s.currentRev = <-revc
+
+ // keys in the range [compacted revision -N, compaction] might all be deleted due to compaction.
+ // the correct revision should be set to compaction revision in the case, not the largest revision
+ // we have seen.
+ if s.currentRev < s.compactMainRev {
+ s.currentRev = s.compactMainRev
+ }
+ if scheduledCompact <= s.compactMainRev {
+ scheduledCompact = 0
+ }
+
+ for key, lid := range keyToLease {
+ if s.le == nil {
+ panic("no lessor to attach lease")
+ }
+ err := s.le.Attach(lid, []lease.LeaseItem{{Key: key}})
+ if err != nil {
+ plog.Errorf("unexpected Attach error: %v", err)
+ }
+ }
+
+ tx.Unlock()
+
+ if scheduledCompact != 0 {
+ s.Compact(scheduledCompact)
+ plog.Printf("resume scheduled compaction at %d", scheduledCompact)
+ }
+
+ return nil
+}
+
+type revKeyValue struct {
+ key []byte
+ kv mvccpb.KeyValue
+ kstr string
+}
+
+func restoreIntoIndex(idx index) (chan<- revKeyValue, <-chan int64) {
+ rkvc, revc := make(chan revKeyValue, restoreChunkKeys), make(chan int64, 1)
+ go func() {
+ currentRev := int64(1)
+ defer func() { revc <- currentRev }()
+ // restore the tree index from streaming the unordered index.
+ kiCache := make(map[string]*keyIndex, restoreChunkKeys)
+ for rkv := range rkvc {
+ ki, ok := kiCache[rkv.kstr]
+ // purge kiCache if many keys but still missing in the cache
+ if !ok && len(kiCache) >= restoreChunkKeys {
+ i := 10
+ for k := range kiCache {
+ delete(kiCache, k)
+ if i--; i == 0 {
+ break
+ }
+ }
+ }
+ // cache miss, fetch from tree index if there
+ if !ok {
+ ki = &keyIndex{key: rkv.kv.Key}
+ if idxKey := idx.KeyIndex(ki); idxKey != nil {
+ kiCache[rkv.kstr], ki = idxKey, idxKey
+ ok = true
+ }
+ }
+ rev := bytesToRev(rkv.key)
+ currentRev = rev.main
+ if ok {
+ if isTombstone(rkv.key) {
+ ki.tombstone(rev.main, rev.sub)
+ continue
+ }
+ ki.put(rev.main, rev.sub)
+ } else if !isTombstone(rkv.key) {
+ ki.restore(revision{rkv.kv.CreateRevision, 0}, rev, rkv.kv.Version)
+ idx.Insert(ki)
+ kiCache[rkv.kstr] = ki
+ }
+ }
+ }()
+ return rkvc, revc
+}
+
+func restoreChunk(kvc chan<- revKeyValue, keys, vals [][]byte, keyToLease map[string]lease.LeaseID) {
+ for i, key := range keys {
+ rkv := revKeyValue{key: key}
+ if err := rkv.kv.Unmarshal(vals[i]); err != nil {
+ plog.Fatalf("cannot unmarshal event: %v", err)
+ }
+ rkv.kstr = string(rkv.kv.Key)
+ if isTombstone(key) {
+ delete(keyToLease, rkv.kstr)
+ } else if lid := lease.LeaseID(rkv.kv.Lease); lid != lease.NoLease {
+ keyToLease[rkv.kstr] = lid
+ } else {
+ delete(keyToLease, rkv.kstr)
+ }
+ kvc <- rkv
+ }
+}
+
+func (s *store) Close() error {
+ close(s.stopc)
+ s.fifoSched.Stop()
+ return nil
+}
+
+func (a *store) Equal(b *store) bool {
+ if a.currentRev != b.currentRev {
+ return false
+ }
+ if a.compactMainRev != b.compactMainRev {
+ return false
+ }
+ return a.kvindex.Equal(b.kvindex)
+}
+
+func (s *store) saveIndex(tx backend.BatchTx) {
+ if s.ig == nil {
+ return
+ }
+ bs := s.bytesBuf8
+ binary.BigEndian.PutUint64(bs, s.ig.ConsistentIndex())
+ // put the index into the underlying backend
+ // tx has been locked in TxnBegin, so there is no need to lock it again
+ tx.UnsafePut(metaBucketName, consistentIndexKeyName, bs)
+}
+
+func (s *store) ConsistentIndex() uint64 {
+ // TODO: cache index in a uint64 field?
+ tx := s.b.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+ _, vs := tx.UnsafeRange(metaBucketName, consistentIndexKeyName, nil, 0)
+ if len(vs) == 0 {
+ return 0
+ }
+ return binary.BigEndian.Uint64(vs[0])
+}
+
+// appendMarkTombstone appends tombstone mark to normal revision bytes.
+func appendMarkTombstone(b []byte) []byte {
+ if len(b) != revBytesLen {
+ plog.Panicf("cannot append mark to non normal revision bytes")
+ }
+ return append(b, markTombstone)
+}
+
+// isTombstone checks whether the revision bytes is a tombstone.
+func isTombstone(b []byte) bool {
+ return len(b) == markedRevBytesLen && b[markBytePosition] == markTombstone
+}
+
+// revBytesRange returns the range of revision bytes at
+// the given revision.
+func revBytesRange(rev revision) (start, end []byte) {
+ start = newRevBytes()
+ revToBytes(rev, start)
+
+ end = newRevBytes()
+ endRev := revision{main: rev.main, sub: rev.sub + 1}
+ revToBytes(endRev, end)
+
+ return start, end
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/kvstore_bench_test.go b/vendor/github.com/coreos/etcd/mvcc/kvstore_bench_test.go
new file mode 100644
index 00000000..33fdc17f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/kvstore_bench_test.go
@@ -0,0 +1,124 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "sync/atomic"
+ "testing"
+
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc/backend"
+)
+
+type fakeConsistentIndex uint64
+
+func (i *fakeConsistentIndex) ConsistentIndex() uint64 {
+ return atomic.LoadUint64((*uint64)(i))
+}
+
+func BenchmarkStorePut(b *testing.B) {
+ var i fakeConsistentIndex
+ be, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(be, &lease.FakeLessor{}, &i)
+ defer cleanup(s, be, tmpPath)
+
+ // arbitrary number of bytes
+ bytesN := 64
+ keys := createBytesSlice(bytesN, b.N)
+ vals := createBytesSlice(bytesN, b.N)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ s.Put(keys[i], vals[i], lease.NoLease)
+ }
+}
+
+// BenchmarkStoreTxnPutUpdate is same as above, but instead updates single key
+func BenchmarkStorePutUpdate(b *testing.B) {
+ var i fakeConsistentIndex
+ be, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(be, &lease.FakeLessor{}, &i)
+ defer cleanup(s, be, tmpPath)
+
+ // arbitrary number of bytes
+ keys := createBytesSlice(64, 1)
+ vals := createBytesSlice(1024, 1)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ s.Put(keys[0], vals[0], lease.NoLease)
+ }
+}
+
+// BenchmarkStoreTxnPut benchmarks the Put operation
+// with transaction begin and end, where transaction involves
+// some synchronization operations, such as mutex locking.
+func BenchmarkStoreTxnPut(b *testing.B) {
+ var i fakeConsistentIndex
+ be, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(be, &lease.FakeLessor{}, &i)
+ defer cleanup(s, be, tmpPath)
+
+ // arbitrary number of bytes
+ bytesN := 64
+ keys := createBytesSlice(bytesN, b.N)
+ vals := createBytesSlice(bytesN, b.N)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ txn := s.Write()
+ txn.Put(keys[i], vals[i], lease.NoLease)
+ txn.End()
+ }
+}
+
+// benchmarkStoreRestore benchmarks the restore operation
+func benchmarkStoreRestore(revsPerKey int, b *testing.B) {
+ var i fakeConsistentIndex
+ be, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(be, &lease.FakeLessor{}, &i)
+ // use closure to capture 's' to pick up the reassignment
+ defer func() { cleanup(s, be, tmpPath) }()
+
+ // arbitrary number of bytes
+ bytesN := 64
+ keys := createBytesSlice(bytesN, b.N)
+ vals := createBytesSlice(bytesN, b.N)
+
+ for i := 0; i < b.N; i++ {
+ for j := 0; j < revsPerKey; j++ {
+ txn := s.Write()
+ txn.Put(keys[i], vals[i], lease.NoLease)
+ txn.End()
+ }
+ }
+ s.Close()
+
+ b.ReportAllocs()
+ b.ResetTimer()
+ s = NewStore(be, &lease.FakeLessor{}, &i)
+}
+
+func BenchmarkStoreRestoreRevs1(b *testing.B) {
+ benchmarkStoreRestore(1, b)
+}
+
+func BenchmarkStoreRestoreRevs10(b *testing.B) {
+ benchmarkStoreRestore(10, b)
+}
+
+func BenchmarkStoreRestoreRevs20(b *testing.B) {
+ benchmarkStoreRestore(20, b)
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/kvstore_compaction.go b/vendor/github.com/coreos/etcd/mvcc/kvstore_compaction.go
new file mode 100644
index 00000000..bbd38f54
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/kvstore_compaction.go
@@ -0,0 +1,66 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "encoding/binary"
+ "time"
+)
+
+func (s *store) scheduleCompaction(compactMainRev int64, keep map[revision]struct{}) bool {
+ totalStart := time.Now()
+ defer dbCompactionTotalDurations.Observe(float64(time.Since(totalStart) / time.Millisecond))
+
+ end := make([]byte, 8)
+ binary.BigEndian.PutUint64(end, uint64(compactMainRev+1))
+
+ batchsize := int64(10000)
+ last := make([]byte, 8+1+8)
+ for {
+ var rev revision
+
+ start := time.Now()
+ tx := s.b.BatchTx()
+ tx.Lock()
+
+ keys, _ := tx.UnsafeRange(keyBucketName, last, end, batchsize)
+ for _, key := range keys {
+ rev = bytesToRev(key)
+ if _, ok := keep[rev]; !ok {
+ tx.UnsafeDelete(keyBucketName, key)
+ }
+ }
+
+ if len(keys) < int(batchsize) {
+ rbytes := make([]byte, 8+1+8)
+ revToBytes(revision{main: compactMainRev}, rbytes)
+ tx.UnsafePut(metaBucketName, finishedCompactKeyName, rbytes)
+ tx.Unlock()
+ plog.Printf("finished scheduled compaction at %d (took %v)", compactMainRev, time.Since(totalStart))
+ return true
+ }
+
+ // update last
+ revToBytes(revision{main: rev.main, sub: rev.sub + 1}, last)
+ tx.Unlock()
+ dbCompactionPauseDurations.Observe(float64(time.Since(start) / time.Millisecond))
+
+ select {
+ case <-time.After(100 * time.Millisecond):
+ case <-s.stopc:
+ return false
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/kvstore_compaction_test.go b/vendor/github.com/coreos/etcd/mvcc/kvstore_compaction_test.go
new file mode 100644
index 00000000..b2ee570f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/kvstore_compaction_test.go
@@ -0,0 +1,135 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "os"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc/backend"
+)
+
+func TestScheduleCompaction(t *testing.T) {
+ revs := []revision{{1, 0}, {2, 0}, {3, 0}}
+
+ tests := []struct {
+ rev int64
+ keep map[revision]struct{}
+ wrevs []revision
+ }{
+ // compact at 1 and discard all history
+ {
+ 1,
+ nil,
+ revs[1:],
+ },
+ // compact at 3 and discard all history
+ {
+ 3,
+ nil,
+ nil,
+ },
+ // compact at 1 and keeps history one step earlier
+ {
+ 1,
+ map[revision]struct{}{
+ {main: 1}: {},
+ },
+ revs,
+ },
+ // compact at 1 and keeps history two steps earlier
+ {
+ 3,
+ map[revision]struct{}{
+ {main: 2}: {},
+ {main: 3}: {},
+ },
+ revs[1:],
+ },
+ }
+ for i, tt := range tests {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ tx := s.b.BatchTx()
+
+ tx.Lock()
+ ibytes := newRevBytes()
+ for _, rev := range revs {
+ revToBytes(rev, ibytes)
+ tx.UnsafePut(keyBucketName, ibytes, []byte("bar"))
+ }
+ tx.Unlock()
+
+ s.scheduleCompaction(tt.rev, tt.keep)
+
+ tx.Lock()
+ for _, rev := range tt.wrevs {
+ revToBytes(rev, ibytes)
+ keys, _ := tx.UnsafeRange(keyBucketName, ibytes, nil, 0)
+ if len(keys) != 1 {
+ t.Errorf("#%d: range on %v = %d, want 1", i, rev, len(keys))
+ }
+ }
+ _, vals := tx.UnsafeRange(metaBucketName, finishedCompactKeyName, nil, 0)
+ revToBytes(revision{main: tt.rev}, ibytes)
+ if w := [][]byte{ibytes}; !reflect.DeepEqual(vals, w) {
+ t.Errorf("#%d: vals on %v = %+v, want %+v", i, finishedCompactKeyName, vals, w)
+ }
+ tx.Unlock()
+
+ cleanup(s, b, tmpPath)
+ }
+}
+
+func TestCompactAllAndRestore(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s0 := NewStore(b, &lease.FakeLessor{}, nil)
+ defer os.Remove(tmpPath)
+
+ s0.Put([]byte("foo"), []byte("bar"), lease.NoLease)
+ s0.Put([]byte("foo"), []byte("bar1"), lease.NoLease)
+ s0.Put([]byte("foo"), []byte("bar2"), lease.NoLease)
+ s0.DeleteRange([]byte("foo"), nil)
+
+ rev := s0.Rev()
+ // compact all keys
+ done, err := s0.Compact(rev)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ select {
+ case <-done:
+ case <-time.After(10 * time.Second):
+ t.Fatal("timeout waiting for compaction to finish")
+ }
+
+ err = s0.Close()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ s1 := NewStore(b, &lease.FakeLessor{}, nil)
+ if s1.Rev() != rev {
+ t.Errorf("rev = %v, want %v", s1.Rev(), rev)
+ }
+ _, err = s1.Range([]byte("foo"), nil, RangeOptions{})
+ if err != nil {
+ t.Errorf("unexpect range error %v", err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/kvstore_test.go b/vendor/github.com/coreos/etcd/mvcc/kvstore_test.go
new file mode 100644
index 00000000..6b73a942
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/kvstore_test.go
@@ -0,0 +1,717 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "crypto/rand"
+ "encoding/binary"
+ "fmt"
+ "math"
+ mrand "math/rand"
+ "os"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/coreos/etcd/pkg/schedule"
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestStoreRev(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer s.Close()
+ defer os.Remove(tmpPath)
+
+ for i := 1; i <= 3; i++ {
+ s.Put([]byte("foo"), []byte("bar"), lease.NoLease)
+ if r := s.Rev(); r != int64(i+1) {
+ t.Errorf("#%d: rev = %d, want %d", i, r, i+1)
+ }
+ }
+}
+
+func TestStorePut(t *testing.T) {
+ kv := mvccpb.KeyValue{
+ Key: []byte("foo"),
+ Value: []byte("bar"),
+ CreateRevision: 1,
+ ModRevision: 2,
+ Version: 1,
+ }
+ kvb, err := kv.Marshal()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ tests := []struct {
+ rev revision
+ r indexGetResp
+ rr *rangeResp
+
+ wrev revision
+ wkey []byte
+ wkv mvccpb.KeyValue
+ wputrev revision
+ }{
+ {
+ revision{1, 0},
+ indexGetResp{revision{}, revision{}, 0, ErrRevisionNotFound},
+ nil,
+
+ revision{2, 0},
+ newTestKeyBytes(revision{2, 0}, false),
+ mvccpb.KeyValue{
+ Key: []byte("foo"),
+ Value: []byte("bar"),
+ CreateRevision: 2,
+ ModRevision: 2,
+ Version: 1,
+ Lease: 1,
+ },
+ revision{2, 0},
+ },
+ {
+ revision{1, 1},
+ indexGetResp{revision{2, 0}, revision{2, 0}, 1, nil},
+ &rangeResp{[][]byte{newTestKeyBytes(revision{2, 1}, false)}, [][]byte{kvb}},
+
+ revision{2, 0},
+ newTestKeyBytes(revision{2, 0}, false),
+ mvccpb.KeyValue{
+ Key: []byte("foo"),
+ Value: []byte("bar"),
+ CreateRevision: 2,
+ ModRevision: 2,
+ Version: 2,
+ Lease: 2,
+ },
+ revision{2, 0},
+ },
+ {
+ revision{2, 0},
+ indexGetResp{revision{2, 1}, revision{2, 0}, 2, nil},
+ &rangeResp{[][]byte{newTestKeyBytes(revision{2, 1}, false)}, [][]byte{kvb}},
+
+ revision{3, 0},
+ newTestKeyBytes(revision{3, 0}, false),
+ mvccpb.KeyValue{
+ Key: []byte("foo"),
+ Value: []byte("bar"),
+ CreateRevision: 2,
+ ModRevision: 3,
+ Version: 3,
+ Lease: 3,
+ },
+ revision{3, 0},
+ },
+ }
+ for i, tt := range tests {
+ s := newFakeStore()
+ b := s.b.(*fakeBackend)
+ fi := s.kvindex.(*fakeIndex)
+
+ s.currentRev = tt.rev.main
+ fi.indexGetRespc <- tt.r
+ if tt.rr != nil {
+ b.tx.rangeRespc <- *tt.rr
+ }
+
+ s.Put([]byte("foo"), []byte("bar"), lease.LeaseID(i+1))
+
+ data, err := tt.wkv.Marshal()
+ if err != nil {
+ t.Errorf("#%d: marshal err = %v, want nil", i, err)
+ }
+
+ wact := []testutil.Action{
+ {"seqput", []interface{}{keyBucketName, tt.wkey, data}},
+ }
+
+ if tt.rr != nil {
+ wact = []testutil.Action{
+ {"seqput", []interface{}{keyBucketName, tt.wkey, data}},
+ }
+ }
+
+ if g := b.tx.Action(); !reflect.DeepEqual(g, wact) {
+ t.Errorf("#%d: tx action = %+v, want %+v", i, g, wact)
+ }
+ wact = []testutil.Action{
+ {"get", []interface{}{[]byte("foo"), tt.wputrev.main}},
+ {"put", []interface{}{[]byte("foo"), tt.wputrev}},
+ }
+ if g := fi.Action(); !reflect.DeepEqual(g, wact) {
+ t.Errorf("#%d: index action = %+v, want %+v", i, g, wact)
+ }
+ if s.currentRev != tt.wrev.main {
+ t.Errorf("#%d: rev = %+v, want %+v", i, s.currentRev, tt.wrev)
+ }
+
+ s.Close()
+ }
+}
+
+func TestStoreRange(t *testing.T) {
+ key := newTestKeyBytes(revision{2, 0}, false)
+ kv := mvccpb.KeyValue{
+ Key: []byte("foo"),
+ Value: []byte("bar"),
+ CreateRevision: 1,
+ ModRevision: 2,
+ Version: 1,
+ }
+ kvb, err := kv.Marshal()
+ if err != nil {
+ t.Fatal(err)
+ }
+ wrev := int64(2)
+
+ tests := []struct {
+ idxr indexRangeResp
+ r rangeResp
+ }{
+ {
+ indexRangeResp{[][]byte{[]byte("foo")}, []revision{{2, 0}}},
+ rangeResp{[][]byte{key}, [][]byte{kvb}},
+ },
+ {
+ indexRangeResp{[][]byte{[]byte("foo"), []byte("foo1")}, []revision{{2, 0}, {3, 0}}},
+ rangeResp{[][]byte{key}, [][]byte{kvb}},
+ },
+ }
+
+ ro := RangeOptions{Limit: 1, Rev: 0, Count: false}
+ for i, tt := range tests {
+ s := newFakeStore()
+ b := s.b.(*fakeBackend)
+ fi := s.kvindex.(*fakeIndex)
+
+ s.currentRev = 2
+ b.tx.rangeRespc <- tt.r
+ fi.indexRangeRespc <- tt.idxr
+
+ ret, err := s.Range([]byte("foo"), []byte("goo"), ro)
+ if err != nil {
+ t.Errorf("#%d: err = %v, want nil", i, err)
+ }
+ if w := []mvccpb.KeyValue{kv}; !reflect.DeepEqual(ret.KVs, w) {
+ t.Errorf("#%d: kvs = %+v, want %+v", i, ret.KVs, w)
+ }
+ if ret.Rev != wrev {
+ t.Errorf("#%d: rev = %d, want %d", i, ret.Rev, wrev)
+ }
+
+ wstart, wend := revBytesRange(tt.idxr.revs[0])
+ wact := []testutil.Action{
+ {"range", []interface{}{keyBucketName, wstart, wend, int64(0)}},
+ }
+ if g := b.tx.Action(); !reflect.DeepEqual(g, wact) {
+ t.Errorf("#%d: tx action = %+v, want %+v", i, g, wact)
+ }
+ wact = []testutil.Action{
+ {"range", []interface{}{[]byte("foo"), []byte("goo"), wrev}},
+ }
+ if g := fi.Action(); !reflect.DeepEqual(g, wact) {
+ t.Errorf("#%d: index action = %+v, want %+v", i, g, wact)
+ }
+ if s.currentRev != 2 {
+ t.Errorf("#%d: current rev = %+v, want %+v", i, s.currentRev, 2)
+ }
+
+ s.Close()
+ }
+}
+
+func TestStoreDeleteRange(t *testing.T) {
+ key := newTestKeyBytes(revision{2, 0}, false)
+ kv := mvccpb.KeyValue{
+ Key: []byte("foo"),
+ Value: []byte("bar"),
+ CreateRevision: 1,
+ ModRevision: 2,
+ Version: 1,
+ }
+ kvb, err := kv.Marshal()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ tests := []struct {
+ rev revision
+ r indexRangeResp
+ rr rangeResp
+
+ wkey []byte
+ wrev revision
+ wrrev int64
+ wdelrev revision
+ }{
+ {
+ revision{2, 0},
+ indexRangeResp{[][]byte{[]byte("foo")}, []revision{{2, 0}}},
+ rangeResp{[][]byte{key}, [][]byte{kvb}},
+
+ newTestKeyBytes(revision{3, 0}, true),
+ revision{3, 0},
+ 2,
+ revision{3, 0},
+ },
+ }
+ for i, tt := range tests {
+ s := newFakeStore()
+ b := s.b.(*fakeBackend)
+ fi := s.kvindex.(*fakeIndex)
+
+ s.currentRev = tt.rev.main
+ fi.indexRangeRespc <- tt.r
+ b.tx.rangeRespc <- tt.rr
+
+ n, _ := s.DeleteRange([]byte("foo"), []byte("goo"))
+ if n != 1 {
+ t.Errorf("#%d: n = %d, want 1", i, n)
+ }
+
+ data, err := (&mvccpb.KeyValue{
+ Key: []byte("foo"),
+ }).Marshal()
+ if err != nil {
+ t.Errorf("#%d: marshal err = %v, want nil", i, err)
+ }
+ wact := []testutil.Action{
+ {"seqput", []interface{}{keyBucketName, tt.wkey, data}},
+ }
+ if g := b.tx.Action(); !reflect.DeepEqual(g, wact) {
+ t.Errorf("#%d: tx action = %+v, want %+v", i, g, wact)
+ }
+ wact = []testutil.Action{
+ {"range", []interface{}{[]byte("foo"), []byte("goo"), tt.wrrev}},
+ {"tombstone", []interface{}{[]byte("foo"), tt.wdelrev}},
+ }
+ if g := fi.Action(); !reflect.DeepEqual(g, wact) {
+ t.Errorf("#%d: index action = %+v, want %+v", i, g, wact)
+ }
+ if s.currentRev != tt.wrev.main {
+ t.Errorf("#%d: rev = %+v, want %+v", i, s.currentRev, tt.wrev)
+ }
+ }
+}
+
+func TestStoreCompact(t *testing.T) {
+ s := newFakeStore()
+ defer s.Close()
+ b := s.b.(*fakeBackend)
+ fi := s.kvindex.(*fakeIndex)
+
+ s.currentRev = 3
+ fi.indexCompactRespc <- map[revision]struct{}{{1, 0}: {}}
+ key1 := newTestKeyBytes(revision{1, 0}, false)
+ key2 := newTestKeyBytes(revision{2, 0}, false)
+ b.tx.rangeRespc <- rangeResp{[][]byte{key1, key2}, nil}
+
+ s.Compact(3)
+ s.fifoSched.WaitFinish(1)
+
+ if s.compactMainRev != 3 {
+ t.Errorf("compact main rev = %d, want 3", s.compactMainRev)
+ }
+ end := make([]byte, 8)
+ binary.BigEndian.PutUint64(end, uint64(4))
+ wact := []testutil.Action{
+ {"put", []interface{}{metaBucketName, scheduledCompactKeyName, newTestRevBytes(revision{3, 0})}},
+ {"range", []interface{}{keyBucketName, make([]byte, 17), end, int64(10000)}},
+ {"delete", []interface{}{keyBucketName, key2}},
+ {"put", []interface{}{metaBucketName, finishedCompactKeyName, newTestRevBytes(revision{3, 0})}},
+ }
+ if g := b.tx.Action(); !reflect.DeepEqual(g, wact) {
+ t.Errorf("tx actions = %+v, want %+v", g, wact)
+ }
+ wact = []testutil.Action{
+ {"compact", []interface{}{int64(3)}},
+ }
+ if g := fi.Action(); !reflect.DeepEqual(g, wact) {
+ t.Errorf("index action = %+v, want %+v", g, wact)
+ }
+}
+
+func TestStoreRestore(t *testing.T) {
+ s := newFakeStore()
+ b := s.b.(*fakeBackend)
+ fi := s.kvindex.(*fakeIndex)
+
+ putkey := newTestKeyBytes(revision{3, 0}, false)
+ putkv := mvccpb.KeyValue{
+ Key: []byte("foo"),
+ Value: []byte("bar"),
+ CreateRevision: 4,
+ ModRevision: 4,
+ Version: 1,
+ }
+ putkvb, err := putkv.Marshal()
+ if err != nil {
+ t.Fatal(err)
+ }
+ delkey := newTestKeyBytes(revision{5, 0}, true)
+ delkv := mvccpb.KeyValue{
+ Key: []byte("foo"),
+ }
+ delkvb, err := delkv.Marshal()
+ if err != nil {
+ t.Fatal(err)
+ }
+ b.tx.rangeRespc <- rangeResp{[][]byte{finishedCompactKeyName}, [][]byte{newTestRevBytes(revision{3, 0})}}
+ b.tx.rangeRespc <- rangeResp{[][]byte{scheduledCompactKeyName}, [][]byte{newTestRevBytes(revision{3, 0})}}
+
+ b.tx.rangeRespc <- rangeResp{[][]byte{putkey, delkey}, [][]byte{putkvb, delkvb}}
+ b.tx.rangeRespc <- rangeResp{nil, nil}
+
+ s.restore()
+
+ if s.compactMainRev != 3 {
+ t.Errorf("compact rev = %d, want 5", s.compactMainRev)
+ }
+ if s.currentRev != 5 {
+ t.Errorf("current rev = %v, want 5", s.currentRev)
+ }
+ wact := []testutil.Action{
+ {"range", []interface{}{metaBucketName, finishedCompactKeyName, []byte(nil), int64(0)}},
+ {"range", []interface{}{metaBucketName, scheduledCompactKeyName, []byte(nil), int64(0)}},
+ {"range", []interface{}{keyBucketName, newTestRevBytes(revision{1, 0}), newTestRevBytes(revision{math.MaxInt64, math.MaxInt64}), int64(restoreChunkKeys)}},
+ }
+ if g := b.tx.Action(); !reflect.DeepEqual(g, wact) {
+ t.Errorf("tx actions = %+v, want %+v", g, wact)
+ }
+
+ gens := []generation{
+ {created: revision{4, 0}, ver: 2, revs: []revision{{3, 0}, {5, 0}}},
+ {created: revision{0, 0}, ver: 0, revs: nil},
+ }
+ ki := &keyIndex{key: []byte("foo"), modified: revision{5, 0}, generations: gens}
+ wact = []testutil.Action{
+ {"keyIndex", []interface{}{ki}},
+ {"insert", []interface{}{ki}},
+ }
+ if g := fi.Action(); !reflect.DeepEqual(g, wact) {
+ t.Errorf("index action = %+v, want %+v", g, wact)
+ }
+}
+
+func TestRestoreDelete(t *testing.T) {
+ oldChunk := restoreChunkKeys
+ restoreChunkKeys = mrand.Intn(3) + 2
+ defer func() { restoreChunkKeys = oldChunk }()
+
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer os.Remove(tmpPath)
+
+ keys := make(map[string]struct{})
+ for i := 0; i < 20; i++ {
+ ks := fmt.Sprintf("foo-%d", i)
+ k := []byte(ks)
+ s.Put(k, []byte("bar"), lease.NoLease)
+ keys[ks] = struct{}{}
+ switch mrand.Intn(3) {
+ case 0:
+ // put random key from past via random range on map
+ ks = fmt.Sprintf("foo-%d", mrand.Intn(i+1))
+ s.Put([]byte(ks), []byte("baz"), lease.NoLease)
+ keys[ks] = struct{}{}
+ case 1:
+ // delete random key via random range on map
+ for k := range keys {
+ s.DeleteRange([]byte(k), nil)
+ delete(keys, k)
+ break
+ }
+ }
+ }
+ s.Close()
+
+ s = NewStore(b, &lease.FakeLessor{}, nil)
+ defer s.Close()
+ for i := 0; i < 20; i++ {
+ ks := fmt.Sprintf("foo-%d", i)
+ r, err := s.Range([]byte(ks), nil, RangeOptions{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, ok := keys[ks]; ok {
+ if len(r.KVs) == 0 {
+ t.Errorf("#%d: expected %q, got deleted", i, ks)
+ }
+ } else if len(r.KVs) != 0 {
+ t.Errorf("#%d: expected deleted, got %q", i, ks)
+ }
+ }
+}
+
+func TestRestoreContinueUnfinishedCompaction(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s0 := NewStore(b, &lease.FakeLessor{}, nil)
+ defer os.Remove(tmpPath)
+
+ s0.Put([]byte("foo"), []byte("bar"), lease.NoLease)
+ s0.Put([]byte("foo"), []byte("bar1"), lease.NoLease)
+ s0.Put([]byte("foo"), []byte("bar2"), lease.NoLease)
+
+ // write scheduled compaction, but not do compaction
+ rbytes := newRevBytes()
+ revToBytes(revision{main: 2}, rbytes)
+ tx := s0.b.BatchTx()
+ tx.Lock()
+ tx.UnsafePut(metaBucketName, scheduledCompactKeyName, rbytes)
+ tx.Unlock()
+
+ s0.Close()
+
+ s1 := NewStore(b, &lease.FakeLessor{}, nil)
+
+ // wait for scheduled compaction to be finished
+ time.Sleep(100 * time.Millisecond)
+
+ if _, err := s1.Range([]byte("foo"), nil, RangeOptions{Rev: 1}); err != ErrCompacted {
+ t.Errorf("range on compacted rev error = %v, want %v", err, ErrCompacted)
+ }
+ // check the key in backend is deleted
+ revbytes := newRevBytes()
+ revToBytes(revision{main: 1}, revbytes)
+
+ // The disk compaction is done asynchronously and requires more time on slow disk.
+ // try 5 times for CI with slow IO.
+ for i := 0; i < 5; i++ {
+ tx = s1.b.BatchTx()
+ tx.Lock()
+ ks, _ := tx.UnsafeRange(keyBucketName, revbytes, nil, 0)
+ tx.Unlock()
+ if len(ks) != 0 {
+ time.Sleep(100 * time.Millisecond)
+ continue
+ }
+ return
+ }
+
+ t.Errorf("key for rev %+v still exists, want deleted", bytesToRev(revbytes))
+}
+
+func TestTxnPut(t *testing.T) {
+ // assign arbitrary size
+ bytesN := 30
+ sliceN := 100
+ keys := createBytesSlice(bytesN, sliceN)
+ vals := createBytesSlice(bytesN, sliceN)
+
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer cleanup(s, b, tmpPath)
+
+ for i := 0; i < sliceN; i++ {
+ txn := s.Write()
+ base := int64(i + 2)
+ if rev := txn.Put(keys[i], vals[i], lease.NoLease); rev != base {
+ t.Errorf("#%d: rev = %d, want %d", i, rev, base)
+ }
+ txn.End()
+ }
+}
+
+func TestTxnBlockBackendForceCommit(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(b, &lease.FakeLessor{}, nil)
+ defer os.Remove(tmpPath)
+
+ txn := s.Read()
+
+ done := make(chan struct{})
+ go func() {
+ s.b.ForceCommit()
+ done <- struct{}{}
+ }()
+ select {
+ case <-done:
+ t.Fatalf("failed to block ForceCommit")
+ case <-time.After(100 * time.Millisecond):
+ }
+
+ txn.End()
+ select {
+ case <-done:
+ case <-time.After(5 * time.Second): // wait 5 seconds for CI with slow IO
+ testutil.FatalStack(t, "failed to execute ForceCommit")
+ }
+}
+
+// TODO: test attach key to lessor
+
+func newTestRevBytes(rev revision) []byte {
+ bytes := newRevBytes()
+ revToBytes(rev, bytes)
+ return bytes
+}
+
+func newTestKeyBytes(rev revision, tombstone bool) []byte {
+ bytes := newRevBytes()
+ revToBytes(rev, bytes)
+ if tombstone {
+ bytes = appendMarkTombstone(bytes)
+ }
+ return bytes
+}
+
+func newFakeStore() *store {
+ b := &fakeBackend{&fakeBatchTx{
+ Recorder: &testutil.RecorderBuffered{},
+ rangeRespc: make(chan rangeResp, 5)}}
+ fi := &fakeIndex{
+ Recorder: &testutil.RecorderBuffered{},
+ indexGetRespc: make(chan indexGetResp, 1),
+ indexRangeRespc: make(chan indexRangeResp, 1),
+ indexRangeEventsRespc: make(chan indexRangeEventsResp, 1),
+ indexCompactRespc: make(chan map[revision]struct{}, 1),
+ }
+ s := &store{
+ b: b,
+ le: &lease.FakeLessor{},
+ kvindex: fi,
+ currentRev: 0,
+ compactMainRev: -1,
+ fifoSched: schedule.NewFIFOScheduler(),
+ stopc: make(chan struct{}),
+ }
+ s.ReadView, s.WriteView = &readView{s}, &writeView{s}
+ return s
+}
+
+type rangeResp struct {
+ keys [][]byte
+ vals [][]byte
+}
+
+type fakeBatchTx struct {
+ testutil.Recorder
+ rangeRespc chan rangeResp
+}
+
+func (b *fakeBatchTx) Lock() {}
+func (b *fakeBatchTx) Unlock() {}
+func (b *fakeBatchTx) UnsafeCreateBucket(name []byte) {}
+func (b *fakeBatchTx) UnsafePut(bucketName []byte, key []byte, value []byte) {
+ b.Recorder.Record(testutil.Action{Name: "put", Params: []interface{}{bucketName, key, value}})
+}
+func (b *fakeBatchTx) UnsafeSeqPut(bucketName []byte, key []byte, value []byte) {
+ b.Recorder.Record(testutil.Action{Name: "seqput", Params: []interface{}{bucketName, key, value}})
+}
+func (b *fakeBatchTx) UnsafeRange(bucketName []byte, key, endKey []byte, limit int64) (keys [][]byte, vals [][]byte) {
+ b.Recorder.Record(testutil.Action{Name: "range", Params: []interface{}{bucketName, key, endKey, limit}})
+ r := <-b.rangeRespc
+ return r.keys, r.vals
+}
+func (b *fakeBatchTx) UnsafeDelete(bucketName []byte, key []byte) {
+ b.Recorder.Record(testutil.Action{Name: "delete", Params: []interface{}{bucketName, key}})
+}
+func (b *fakeBatchTx) UnsafeForEach(bucketName []byte, visitor func(k, v []byte) error) error {
+ return nil
+}
+func (b *fakeBatchTx) Commit() {}
+func (b *fakeBatchTx) CommitAndStop() {}
+
+type fakeBackend struct {
+ tx *fakeBatchTx
+}
+
+func (b *fakeBackend) BatchTx() backend.BatchTx { return b.tx }
+func (b *fakeBackend) ReadTx() backend.ReadTx { return b.tx }
+func (b *fakeBackend) Hash(ignores map[backend.IgnoreKey]struct{}) (uint32, error) { return 0, nil }
+func (b *fakeBackend) Size() int64 { return 0 }
+func (b *fakeBackend) Snapshot() backend.Snapshot { return nil }
+func (b *fakeBackend) ForceCommit() {}
+func (b *fakeBackend) Defrag() error { return nil }
+func (b *fakeBackend) Close() error { return nil }
+
+type indexGetResp struct {
+ rev revision
+ created revision
+ ver int64
+ err error
+}
+
+type indexRangeResp struct {
+ keys [][]byte
+ revs []revision
+}
+
+type indexRangeEventsResp struct {
+ revs []revision
+}
+
+type fakeIndex struct {
+ testutil.Recorder
+ indexGetRespc chan indexGetResp
+ indexRangeRespc chan indexRangeResp
+ indexRangeEventsRespc chan indexRangeEventsResp
+ indexCompactRespc chan map[revision]struct{}
+}
+
+func (i *fakeIndex) Get(key []byte, atRev int64) (rev, created revision, ver int64, err error) {
+ i.Recorder.Record(testutil.Action{Name: "get", Params: []interface{}{key, atRev}})
+ r := <-i.indexGetRespc
+ return r.rev, r.created, r.ver, r.err
+}
+func (i *fakeIndex) Range(key, end []byte, atRev int64) ([][]byte, []revision) {
+ i.Recorder.Record(testutil.Action{Name: "range", Params: []interface{}{key, end, atRev}})
+ r := <-i.indexRangeRespc
+ return r.keys, r.revs
+}
+func (i *fakeIndex) Put(key []byte, rev revision) {
+ i.Recorder.Record(testutil.Action{Name: "put", Params: []interface{}{key, rev}})
+}
+func (i *fakeIndex) Tombstone(key []byte, rev revision) error {
+ i.Recorder.Record(testutil.Action{Name: "tombstone", Params: []interface{}{key, rev}})
+ return nil
+}
+func (i *fakeIndex) RangeSince(key, end []byte, rev int64) []revision {
+ i.Recorder.Record(testutil.Action{Name: "rangeEvents", Params: []interface{}{key, end, rev}})
+ r := <-i.indexRangeEventsRespc
+ return r.revs
+}
+func (i *fakeIndex) Compact(rev int64) map[revision]struct{} {
+ i.Recorder.Record(testutil.Action{Name: "compact", Params: []interface{}{rev}})
+ return <-i.indexCompactRespc
+}
+func (i *fakeIndex) Equal(b index) bool { return false }
+
+func (i *fakeIndex) Insert(ki *keyIndex) {
+ i.Recorder.Record(testutil.Action{Name: "insert", Params: []interface{}{ki}})
+}
+
+func (i *fakeIndex) KeyIndex(ki *keyIndex) *keyIndex {
+ i.Recorder.Record(testutil.Action{Name: "keyIndex", Params: []interface{}{ki}})
+ return nil
+}
+
+func createBytesSlice(bytesN, sliceN int) [][]byte {
+ rs := [][]byte{}
+ for len(rs) != sliceN {
+ v := make([]byte, bytesN)
+ if _, err := rand.Read(v); err != nil {
+ panic(err)
+ }
+ rs = append(rs, v)
+ }
+ return rs
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/kvstore_txn.go b/vendor/github.com/coreos/etcd/mvcc/kvstore_txn.go
new file mode 100644
index 00000000..13d4d530
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/kvstore_txn.go
@@ -0,0 +1,253 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+)
+
+type storeTxnRead struct {
+ s *store
+ tx backend.ReadTx
+
+ firstRev int64
+ rev int64
+}
+
+func (s *store) Read() TxnRead {
+ s.mu.RLock()
+ tx := s.b.ReadTx()
+ s.revMu.RLock()
+ tx.Lock()
+ firstRev, rev := s.compactMainRev, s.currentRev
+ s.revMu.RUnlock()
+ return newMetricsTxnRead(&storeTxnRead{s, tx, firstRev, rev})
+}
+
+func (tr *storeTxnRead) FirstRev() int64 { return tr.firstRev }
+func (tr *storeTxnRead) Rev() int64 { return tr.rev }
+
+func (tr *storeTxnRead) Range(key, end []byte, ro RangeOptions) (r *RangeResult, err error) {
+ return tr.rangeKeys(key, end, tr.Rev(), ro)
+}
+
+func (tr *storeTxnRead) End() {
+ tr.tx.Unlock()
+ tr.s.mu.RUnlock()
+}
+
+type storeTxnWrite struct {
+ *storeTxnRead
+ tx backend.BatchTx
+ // beginRev is the revision where the txn begins; it will write to the next revision.
+ beginRev int64
+ changes []mvccpb.KeyValue
+}
+
+func (s *store) Write() TxnWrite {
+ s.mu.RLock()
+ tx := s.b.BatchTx()
+ tx.Lock()
+ tw := &storeTxnWrite{
+ storeTxnRead: &storeTxnRead{s, tx, 0, 0},
+ tx: tx,
+ beginRev: s.currentRev,
+ changes: make([]mvccpb.KeyValue, 0, 4),
+ }
+ return newMetricsTxnWrite(tw)
+}
+
+func (tw *storeTxnWrite) Rev() int64 { return tw.beginRev }
+
+func (tw *storeTxnWrite) Range(key, end []byte, ro RangeOptions) (r *RangeResult, err error) {
+ rev := tw.beginRev
+ if len(tw.changes) > 0 {
+ rev++
+ }
+ return tw.rangeKeys(key, end, rev, ro)
+}
+
+func (tw *storeTxnWrite) DeleteRange(key, end []byte) (int64, int64) {
+ if n := tw.deleteRange(key, end); n != 0 || len(tw.changes) > 0 {
+ return n, int64(tw.beginRev + 1)
+ }
+ return 0, int64(tw.beginRev)
+}
+
+func (tw *storeTxnWrite) Put(key, value []byte, lease lease.LeaseID) int64 {
+ tw.put(key, value, lease)
+ return int64(tw.beginRev + 1)
+}
+
+func (tw *storeTxnWrite) End() {
+ // only update index if the txn modifies the mvcc state.
+ if len(tw.changes) != 0 {
+ tw.s.saveIndex(tw.tx)
+ // hold revMu lock to prevent new read txns from opening until writeback.
+ tw.s.revMu.Lock()
+ tw.s.currentRev++
+ }
+ tw.tx.Unlock()
+ if len(tw.changes) != 0 {
+ tw.s.revMu.Unlock()
+ }
+ tw.s.mu.RUnlock()
+}
+
+func (tr *storeTxnRead) rangeKeys(key, end []byte, curRev int64, ro RangeOptions) (*RangeResult, error) {
+ rev := ro.Rev
+ if rev > curRev {
+ return &RangeResult{KVs: nil, Count: -1, Rev: curRev}, ErrFutureRev
+ }
+ if rev <= 0 {
+ rev = curRev
+ }
+ if rev < tr.s.compactMainRev {
+ return &RangeResult{KVs: nil, Count: -1, Rev: 0}, ErrCompacted
+ }
+
+ _, revpairs := tr.s.kvindex.Range(key, end, int64(rev))
+ if len(revpairs) == 0 {
+ return &RangeResult{KVs: nil, Count: 0, Rev: curRev}, nil
+ }
+ if ro.Count {
+ return &RangeResult{KVs: nil, Count: len(revpairs), Rev: curRev}, nil
+ }
+
+ var kvs []mvccpb.KeyValue
+ for _, revpair := range revpairs {
+ start, end := revBytesRange(revpair)
+ _, vs := tr.tx.UnsafeRange(keyBucketName, start, end, 0)
+ if len(vs) != 1 {
+ plog.Fatalf("range cannot find rev (%d,%d)", revpair.main, revpair.sub)
+ }
+
+ var kv mvccpb.KeyValue
+ if err := kv.Unmarshal(vs[0]); err != nil {
+ plog.Fatalf("cannot unmarshal event: %v", err)
+ }
+ kvs = append(kvs, kv)
+ if ro.Limit > 0 && len(kvs) >= int(ro.Limit) {
+ break
+ }
+ }
+ return &RangeResult{KVs: kvs, Count: len(revpairs), Rev: curRev}, nil
+}
+
+func (tw *storeTxnWrite) put(key, value []byte, leaseID lease.LeaseID) {
+ rev := tw.beginRev + 1
+ c := rev
+ oldLease := lease.NoLease
+
+ // if the key exists before, use its previous created and
+ // get its previous leaseID
+ _, created, ver, err := tw.s.kvindex.Get(key, rev)
+ if err == nil {
+ c = created.main
+ oldLease = tw.s.le.GetLease(lease.LeaseItem{Key: string(key)})
+ }
+
+ ibytes := newRevBytes()
+ idxRev := revision{main: rev, sub: int64(len(tw.changes))}
+ revToBytes(idxRev, ibytes)
+
+ ver = ver + 1
+ kv := mvccpb.KeyValue{
+ Key: key,
+ Value: value,
+ CreateRevision: c,
+ ModRevision: rev,
+ Version: ver,
+ Lease: int64(leaseID),
+ }
+
+ d, err := kv.Marshal()
+ if err != nil {
+ plog.Fatalf("cannot marshal event: %v", err)
+ }
+
+ tw.tx.UnsafeSeqPut(keyBucketName, ibytes, d)
+ tw.s.kvindex.Put(key, idxRev)
+ tw.changes = append(tw.changes, kv)
+
+ if oldLease != lease.NoLease {
+ if tw.s.le == nil {
+ panic("no lessor to detach lease")
+ }
+ err = tw.s.le.Detach(oldLease, []lease.LeaseItem{{Key: string(key)}})
+ if err != nil {
+ plog.Errorf("unexpected error from lease detach: %v", err)
+ }
+ }
+ if leaseID != lease.NoLease {
+ if tw.s.le == nil {
+ panic("no lessor to attach lease")
+ }
+ err = tw.s.le.Attach(leaseID, []lease.LeaseItem{{Key: string(key)}})
+ if err != nil {
+ panic("unexpected error from lease Attach")
+ }
+ }
+}
+
+func (tw *storeTxnWrite) deleteRange(key, end []byte) int64 {
+ rrev := tw.beginRev
+ if len(tw.changes) > 0 {
+ rrev += 1
+ }
+ keys, revs := tw.s.kvindex.Range(key, end, rrev)
+ if len(keys) == 0 {
+ return 0
+ }
+ for i, key := range keys {
+ tw.delete(key, revs[i])
+ }
+ return int64(len(keys))
+}
+
+func (tw *storeTxnWrite) delete(key []byte, rev revision) {
+ ibytes := newRevBytes()
+ idxRev := revision{main: tw.beginRev + 1, sub: int64(len(tw.changes))}
+ revToBytes(idxRev, ibytes)
+ ibytes = appendMarkTombstone(ibytes)
+
+ kv := mvccpb.KeyValue{Key: key}
+
+ d, err := kv.Marshal()
+ if err != nil {
+ plog.Fatalf("cannot marshal event: %v", err)
+ }
+
+ tw.tx.UnsafeSeqPut(keyBucketName, ibytes, d)
+ err = tw.s.kvindex.Tombstone(key, idxRev)
+ if err != nil {
+ plog.Fatalf("cannot tombstone an existing key (%s): %v", string(key), err)
+ }
+ tw.changes = append(tw.changes, kv)
+
+ item := lease.LeaseItem{Key: string(key)}
+ leaseID := tw.s.le.GetLease(item)
+
+ if leaseID != lease.NoLease {
+ err = tw.s.le.Detach(leaseID, []lease.LeaseItem{item})
+ if err != nil {
+ plog.Errorf("cannot detach %v", err)
+ }
+ }
+}
+
+func (tw *storeTxnWrite) Changes() []mvccpb.KeyValue { return tw.changes }
diff --git a/vendor/github.com/coreos/etcd/mvcc/metrics.go b/vendor/github.com/coreos/etcd/mvcc/metrics.go
new file mode 100644
index 00000000..a65fe59b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/metrics.go
@@ -0,0 +1,174 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "sync"
+
+ "github.com/prometheus/client_golang/prometheus"
+)
+
+var (
+ rangeCounter = prometheus.NewCounter(
+ prometheus.CounterOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "mvcc",
+ Name: "range_total",
+ Help: "Total number of ranges seen by this member.",
+ })
+
+ putCounter = prometheus.NewCounter(
+ prometheus.CounterOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "mvcc",
+ Name: "put_total",
+ Help: "Total number of puts seen by this member.",
+ })
+
+ deleteCounter = prometheus.NewCounter(
+ prometheus.CounterOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "mvcc",
+ Name: "delete_total",
+ Help: "Total number of deletes seen by this member.",
+ })
+
+ txnCounter = prometheus.NewCounter(
+ prometheus.CounterOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "mvcc",
+ Name: "txn_total",
+ Help: "Total number of txns seen by this member.",
+ })
+
+ keysGauge = prometheus.NewGauge(
+ prometheus.GaugeOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "mvcc",
+ Name: "keys_total",
+ Help: "Total number of keys.",
+ })
+
+ watchStreamGauge = prometheus.NewGauge(
+ prometheus.GaugeOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "mvcc",
+ Name: "watch_stream_total",
+ Help: "Total number of watch streams.",
+ })
+
+ watcherGauge = prometheus.NewGauge(
+ prometheus.GaugeOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "mvcc",
+ Name: "watcher_total",
+ Help: "Total number of watchers.",
+ })
+
+ slowWatcherGauge = prometheus.NewGauge(
+ prometheus.GaugeOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "mvcc",
+ Name: "slow_watcher_total",
+ Help: "Total number of unsynced slow watchers.",
+ })
+
+ totalEventsCounter = prometheus.NewCounter(
+ prometheus.CounterOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "mvcc",
+ Name: "events_total",
+ Help: "Total number of events sent by this member.",
+ })
+
+ pendingEventsGauge = prometheus.NewGauge(
+ prometheus.GaugeOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "mvcc",
+ Name: "pending_events_total",
+ Help: "Total number of pending events to be sent.",
+ })
+
+ indexCompactionPauseDurations = prometheus.NewHistogram(
+ prometheus.HistogramOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "mvcc",
+ Name: "index_compaction_pause_duration_milliseconds",
+ Help: "Bucketed histogram of index compaction pause duration.",
+ // 0.5ms -> 1second
+ Buckets: prometheus.ExponentialBuckets(0.5, 2, 12),
+ })
+
+ dbCompactionPauseDurations = prometheus.NewHistogram(
+ prometheus.HistogramOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "mvcc",
+ Name: "db_compaction_pause_duration_milliseconds",
+ Help: "Bucketed histogram of db compaction pause duration.",
+ // 1ms -> 4second
+ Buckets: prometheus.ExponentialBuckets(1, 2, 13),
+ })
+
+ dbCompactionTotalDurations = prometheus.NewHistogram(
+ prometheus.HistogramOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "mvcc",
+ Name: "db_compaction_total_duration_milliseconds",
+ Help: "Bucketed histogram of db compaction total duration.",
+ // 100ms -> 800second
+ Buckets: prometheus.ExponentialBuckets(100, 2, 14),
+ })
+
+ dbTotalSize = prometheus.NewGaugeFunc(prometheus.GaugeOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "mvcc",
+ Name: "db_total_size_in_bytes",
+ Help: "Total size of the underlying database in bytes.",
+ },
+ func() float64 {
+ reportDbTotalSizeInBytesMu.RLock()
+ defer reportDbTotalSizeInBytesMu.RUnlock()
+ return reportDbTotalSizeInBytes()
+ },
+ )
+ // overridden by mvcc initialization
+ reportDbTotalSizeInBytesMu sync.RWMutex
+ reportDbTotalSizeInBytes func() float64 = func() float64 { return 0 }
+)
+
+func init() {
+ prometheus.MustRegister(rangeCounter)
+ prometheus.MustRegister(putCounter)
+ prometheus.MustRegister(deleteCounter)
+ prometheus.MustRegister(txnCounter)
+ prometheus.MustRegister(keysGauge)
+ prometheus.MustRegister(watchStreamGauge)
+ prometheus.MustRegister(watcherGauge)
+ prometheus.MustRegister(slowWatcherGauge)
+ prometheus.MustRegister(totalEventsCounter)
+ prometheus.MustRegister(pendingEventsGauge)
+ prometheus.MustRegister(indexCompactionPauseDurations)
+ prometheus.MustRegister(dbCompactionPauseDurations)
+ prometheus.MustRegister(dbCompactionTotalDurations)
+ prometheus.MustRegister(dbTotalSize)
+}
+
+// ReportEventReceived reports that an event is received.
+// This function should be called when the external systems received an
+// event from mvcc.Watcher.
+func ReportEventReceived(n int) {
+ pendingEventsGauge.Sub(float64(n))
+ totalEventsCounter.Add(float64(n))
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/metrics_txn.go b/vendor/github.com/coreos/etcd/mvcc/metrics_txn.go
new file mode 100644
index 00000000..fd214427
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/metrics_txn.go
@@ -0,0 +1,67 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "github.com/coreos/etcd/lease"
+)
+
+type metricsTxnWrite struct {
+ TxnWrite
+ ranges uint
+ puts uint
+ deletes uint
+}
+
+func newMetricsTxnRead(tr TxnRead) TxnRead {
+ return &metricsTxnWrite{&txnReadWrite{tr}, 0, 0, 0}
+}
+
+func newMetricsTxnWrite(tw TxnWrite) TxnWrite {
+ return &metricsTxnWrite{tw, 0, 0, 0}
+}
+
+func (tw *metricsTxnWrite) Range(key, end []byte, ro RangeOptions) (*RangeResult, error) {
+ tw.ranges++
+ return tw.TxnWrite.Range(key, end, ro)
+}
+
+func (tw *metricsTxnWrite) DeleteRange(key, end []byte) (n, rev int64) {
+ tw.deletes++
+ return tw.TxnWrite.DeleteRange(key, end)
+}
+
+func (tw *metricsTxnWrite) Put(key, value []byte, lease lease.LeaseID) (rev int64) {
+ tw.puts++
+ return tw.TxnWrite.Put(key, value, lease)
+}
+
+func (tw *metricsTxnWrite) End() {
+ defer tw.TxnWrite.End()
+ if sum := tw.ranges + tw.puts + tw.deletes; sum != 1 {
+ if sum > 1 {
+ txnCounter.Inc()
+ }
+ return
+ }
+ switch {
+ case tw.ranges == 1:
+ rangeCounter.Inc()
+ case tw.puts == 1:
+ putCounter.Inc()
+ case tw.deletes == 1:
+ deleteCounter.Inc()
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/mvccpb/kv.pb.go b/vendor/github.com/coreos/etcd/mvcc/mvccpb/kv.pb.go
new file mode 100644
index 00000000..7033f132
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/mvccpb/kv.pb.go
@@ -0,0 +1,735 @@
+// Code generated by protoc-gen-gogo.
+// source: kv.proto
+// DO NOT EDIT!
+
+/*
+ Package mvccpb is a generated protocol buffer package.
+
+ It is generated from these files:
+ kv.proto
+
+ It has these top-level messages:
+ KeyValue
+ Event
+*/
+package mvccpb
+
+import (
+ "fmt"
+
+ proto "github.com/golang/protobuf/proto"
+
+ math "math"
+
+ io "io"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+type Event_EventType int32
+
+const (
+ PUT Event_EventType = 0
+ DELETE Event_EventType = 1
+)
+
+var Event_EventType_name = map[int32]string{
+ 0: "PUT",
+ 1: "DELETE",
+}
+var Event_EventType_value = map[string]int32{
+ "PUT": 0,
+ "DELETE": 1,
+}
+
+func (x Event_EventType) String() string {
+ return proto.EnumName(Event_EventType_name, int32(x))
+}
+func (Event_EventType) EnumDescriptor() ([]byte, []int) { return fileDescriptorKv, []int{1, 0} }
+
+type KeyValue struct {
+ // key is the key in bytes. An empty key is not allowed.
+ Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
+ // create_revision is the revision of last creation on this key.
+ CreateRevision int64 `protobuf:"varint,2,opt,name=create_revision,json=createRevision,proto3" json:"create_revision,omitempty"`
+ // mod_revision is the revision of last modification on this key.
+ ModRevision int64 `protobuf:"varint,3,opt,name=mod_revision,json=modRevision,proto3" json:"mod_revision,omitempty"`
+ // version is the version of the key. A deletion resets
+ // the version to zero and any modification of the key
+ // increases its version.
+ Version int64 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"`
+ // value is the value held by the key, in bytes.
+ Value []byte `protobuf:"bytes,5,opt,name=value,proto3" json:"value,omitempty"`
+ // lease is the ID of the lease that attached to key.
+ // When the attached lease expires, the key will be deleted.
+ // If lease is 0, then no lease is attached to the key.
+ Lease int64 `protobuf:"varint,6,opt,name=lease,proto3" json:"lease,omitempty"`
+}
+
+func (m *KeyValue) Reset() { *m = KeyValue{} }
+func (m *KeyValue) String() string { return proto.CompactTextString(m) }
+func (*KeyValue) ProtoMessage() {}
+func (*KeyValue) Descriptor() ([]byte, []int) { return fileDescriptorKv, []int{0} }
+
+type Event struct {
+ // type is the kind of event. If type is a PUT, it indicates
+ // new data has been stored to the key. If type is a DELETE,
+ // it indicates the key was deleted.
+ Type Event_EventType `protobuf:"varint,1,opt,name=type,proto3,enum=mvccpb.Event_EventType" json:"type,omitempty"`
+ // kv holds the KeyValue for the event.
+ // A PUT event contains current kv pair.
+ // A PUT event with kv.Version=1 indicates the creation of a key.
+ // A DELETE/EXPIRE event contains the deleted key with
+ // its modification revision set to the revision of deletion.
+ Kv *KeyValue `protobuf:"bytes,2,opt,name=kv" json:"kv,omitempty"`
+ // prev_kv holds the key-value pair before the event happens.
+ PrevKv *KeyValue `protobuf:"bytes,3,opt,name=prev_kv,json=prevKv" json:"prev_kv,omitempty"`
+}
+
+func (m *Event) Reset() { *m = Event{} }
+func (m *Event) String() string { return proto.CompactTextString(m) }
+func (*Event) ProtoMessage() {}
+func (*Event) Descriptor() ([]byte, []int) { return fileDescriptorKv, []int{1} }
+
+func init() {
+ proto.RegisterType((*KeyValue)(nil), "mvccpb.KeyValue")
+ proto.RegisterType((*Event)(nil), "mvccpb.Event")
+ proto.RegisterEnum("mvccpb.Event_EventType", Event_EventType_name, Event_EventType_value)
+}
+func (m *KeyValue) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *KeyValue) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Key) > 0 {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintKv(dAtA, i, uint64(len(m.Key)))
+ i += copy(dAtA[i:], m.Key)
+ }
+ if m.CreateRevision != 0 {
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintKv(dAtA, i, uint64(m.CreateRevision))
+ }
+ if m.ModRevision != 0 {
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintKv(dAtA, i, uint64(m.ModRevision))
+ }
+ if m.Version != 0 {
+ dAtA[i] = 0x20
+ i++
+ i = encodeVarintKv(dAtA, i, uint64(m.Version))
+ }
+ if len(m.Value) > 0 {
+ dAtA[i] = 0x2a
+ i++
+ i = encodeVarintKv(dAtA, i, uint64(len(m.Value)))
+ i += copy(dAtA[i:], m.Value)
+ }
+ if m.Lease != 0 {
+ dAtA[i] = 0x30
+ i++
+ i = encodeVarintKv(dAtA, i, uint64(m.Lease))
+ }
+ return i, nil
+}
+
+func (m *Event) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *Event) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Type != 0 {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintKv(dAtA, i, uint64(m.Type))
+ }
+ if m.Kv != nil {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintKv(dAtA, i, uint64(m.Kv.Size()))
+ n1, err := m.Kv.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n1
+ }
+ if m.PrevKv != nil {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintKv(dAtA, i, uint64(m.PrevKv.Size()))
+ n2, err := m.PrevKv.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n2
+ }
+ return i, nil
+}
+
+func encodeFixed64Kv(dAtA []byte, offset int, v uint64) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ dAtA[offset+4] = uint8(v >> 32)
+ dAtA[offset+5] = uint8(v >> 40)
+ dAtA[offset+6] = uint8(v >> 48)
+ dAtA[offset+7] = uint8(v >> 56)
+ return offset + 8
+}
+func encodeFixed32Kv(dAtA []byte, offset int, v uint32) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ return offset + 4
+}
+func encodeVarintKv(dAtA []byte, offset int, v uint64) int {
+ for v >= 1<<7 {
+ dAtA[offset] = uint8(v&0x7f | 0x80)
+ v >>= 7
+ offset++
+ }
+ dAtA[offset] = uint8(v)
+ return offset + 1
+}
+func (m *KeyValue) Size() (n int) {
+ var l int
+ _ = l
+ l = len(m.Key)
+ if l > 0 {
+ n += 1 + l + sovKv(uint64(l))
+ }
+ if m.CreateRevision != 0 {
+ n += 1 + sovKv(uint64(m.CreateRevision))
+ }
+ if m.ModRevision != 0 {
+ n += 1 + sovKv(uint64(m.ModRevision))
+ }
+ if m.Version != 0 {
+ n += 1 + sovKv(uint64(m.Version))
+ }
+ l = len(m.Value)
+ if l > 0 {
+ n += 1 + l + sovKv(uint64(l))
+ }
+ if m.Lease != 0 {
+ n += 1 + sovKv(uint64(m.Lease))
+ }
+ return n
+}
+
+func (m *Event) Size() (n int) {
+ var l int
+ _ = l
+ if m.Type != 0 {
+ n += 1 + sovKv(uint64(m.Type))
+ }
+ if m.Kv != nil {
+ l = m.Kv.Size()
+ n += 1 + l + sovKv(uint64(l))
+ }
+ if m.PrevKv != nil {
+ l = m.PrevKv.Size()
+ n += 1 + l + sovKv(uint64(l))
+ }
+ return n
+}
+
+func sovKv(x uint64) (n int) {
+ for {
+ n++
+ x >>= 7
+ if x == 0 {
+ break
+ }
+ }
+ return n
+}
+func sozKv(x uint64) (n int) {
+ return sovKv(uint64((x << 1) ^ uint64((int64(x) >> 63))))
+}
+func (m *KeyValue) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: KeyValue: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: KeyValue: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthKv
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
+ if m.Key == nil {
+ m.Key = []byte{}
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field CreateRevision", wireType)
+ }
+ m.CreateRevision = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.CreateRevision |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ModRevision", wireType)
+ }
+ m.ModRevision = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ModRevision |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 4:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType)
+ }
+ m.Version = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Version |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 5:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthKv
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...)
+ if m.Value == nil {
+ m.Value = []byte{}
+ }
+ iNdEx = postIndex
+ case 6:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Lease", wireType)
+ }
+ m.Lease = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Lease |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipKv(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthKv
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *Event) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: Event: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: Event: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
+ }
+ m.Type = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Type |= (Event_EventType(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Kv", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthKv
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Kv == nil {
+ m.Kv = &KeyValue{}
+ }
+ if err := m.Kv.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthKv
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.PrevKv == nil {
+ m.PrevKv = &KeyValue{}
+ }
+ if err := m.PrevKv.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipKv(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthKv
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func skipKv(dAtA []byte) (n int, err error) {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ wireType := int(wire & 0x7)
+ switch wireType {
+ case 0:
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ iNdEx++
+ if dAtA[iNdEx-1] < 0x80 {
+ break
+ }
+ }
+ return iNdEx, nil
+ case 1:
+ iNdEx += 8
+ return iNdEx, nil
+ case 2:
+ var length int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ length |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ iNdEx += length
+ if length < 0 {
+ return 0, ErrInvalidLengthKv
+ }
+ return iNdEx, nil
+ case 3:
+ for {
+ var innerWire uint64
+ var start int = iNdEx
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowKv
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ innerWire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ innerWireType := int(innerWire & 0x7)
+ if innerWireType == 4 {
+ break
+ }
+ next, err := skipKv(dAtA[start:])
+ if err != nil {
+ return 0, err
+ }
+ iNdEx = start + next
+ }
+ return iNdEx, nil
+ case 4:
+ return iNdEx, nil
+ case 5:
+ iNdEx += 4
+ return iNdEx, nil
+ default:
+ return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
+ }
+ }
+ panic("unreachable")
+}
+
+var (
+ ErrInvalidLengthKv = fmt.Errorf("proto: negative length found during unmarshaling")
+ ErrIntOverflowKv = fmt.Errorf("proto: integer overflow")
+)
+
+func init() { proto.RegisterFile("kv.proto", fileDescriptorKv) }
+
+var fileDescriptorKv = []byte{
+ // 303 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x41, 0x4e, 0xc2, 0x40,
+ 0x14, 0x86, 0x3b, 0x14, 0x0a, 0x3e, 0x08, 0x36, 0x13, 0x12, 0x27, 0x2e, 0x26, 0x95, 0x8d, 0x18,
+ 0x13, 0x4c, 0xf0, 0x06, 0xc6, 0xae, 0x70, 0x61, 0x1a, 0x74, 0x4b, 0x4a, 0x79, 0x21, 0xa4, 0x94,
+ 0x69, 0x4a, 0x9d, 0xa4, 0x37, 0x71, 0xef, 0xde, 0x73, 0xb0, 0xe4, 0x08, 0x52, 0x2f, 0x62, 0xfa,
+ 0xc6, 0xe2, 0xc6, 0xcd, 0xe4, 0xfd, 0xff, 0xff, 0x65, 0xe6, 0x7f, 0x03, 0x9d, 0x58, 0x8f, 0xd3,
+ 0x4c, 0xe5, 0x8a, 0x3b, 0x89, 0x8e, 0xa2, 0x74, 0x71, 0x39, 0x58, 0xa9, 0x95, 0x22, 0xeb, 0xae,
+ 0x9a, 0x4c, 0x3a, 0xfc, 0x64, 0xd0, 0x99, 0x62, 0xf1, 0x1a, 0x6e, 0xde, 0x90, 0xbb, 0x60, 0xc7,
+ 0x58, 0x08, 0xe6, 0xb1, 0x51, 0x2f, 0xa8, 0x46, 0x7e, 0x0d, 0xe7, 0x51, 0x86, 0x61, 0x8e, 0xf3,
+ 0x0c, 0xf5, 0x7a, 0xb7, 0x56, 0x5b, 0xd1, 0xf0, 0xd8, 0xc8, 0x0e, 0xfa, 0xc6, 0x0e, 0x7e, 0x5d,
+ 0x7e, 0x05, 0xbd, 0x44, 0x2d, 0xff, 0x28, 0x9b, 0xa8, 0x6e, 0xa2, 0x96, 0x27, 0x44, 0x40, 0x5b,
+ 0x63, 0x46, 0x69, 0x93, 0xd2, 0x5a, 0xf2, 0x01, 0xb4, 0x74, 0x55, 0x40, 0xb4, 0xe8, 0x65, 0x23,
+ 0x2a, 0x77, 0x83, 0xe1, 0x0e, 0x85, 0x43, 0xb4, 0x11, 0xc3, 0x0f, 0x06, 0x2d, 0x5f, 0xe3, 0x36,
+ 0xe7, 0xb7, 0xd0, 0xcc, 0x8b, 0x14, 0xa9, 0x6e, 0x7f, 0x72, 0x31, 0x36, 0x7b, 0x8e, 0x29, 0x34,
+ 0xe7, 0xac, 0x48, 0x31, 0x20, 0x88, 0x7b, 0xd0, 0x88, 0x35, 0x75, 0xef, 0x4e, 0xdc, 0x1a, 0xad,
+ 0x17, 0x0f, 0x1a, 0xb1, 0xe6, 0x37, 0xd0, 0x4e, 0x33, 0xd4, 0xf3, 0x58, 0x53, 0xf9, 0xff, 0x30,
+ 0xa7, 0x02, 0xa6, 0x7a, 0xe8, 0xc1, 0xd9, 0xe9, 0x7e, 0xde, 0x06, 0xfb, 0xf9, 0x65, 0xe6, 0x5a,
+ 0x1c, 0xc0, 0x79, 0xf4, 0x9f, 0xfc, 0x99, 0xef, 0xb2, 0x07, 0xb1, 0x3f, 0x4a, 0xeb, 0x70, 0x94,
+ 0xd6, 0xbe, 0x94, 0xec, 0x50, 0x4a, 0xf6, 0x55, 0x4a, 0xf6, 0xfe, 0x2d, 0xad, 0x85, 0x43, 0xff,
+ 0x7e, 0xff, 0x13, 0x00, 0x00, 0xff, 0xff, 0xb5, 0x45, 0x92, 0x5d, 0xa1, 0x01, 0x00, 0x00,
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/mvccpb/kv.proto b/vendor/github.com/coreos/etcd/mvcc/mvccpb/kv.proto
new file mode 100644
index 00000000..23c911b7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/mvccpb/kv.proto
@@ -0,0 +1,49 @@
+syntax = "proto3";
+package mvccpb;
+
+import "gogoproto/gogo.proto";
+
+option (gogoproto.marshaler_all) = true;
+option (gogoproto.sizer_all) = true;
+option (gogoproto.unmarshaler_all) = true;
+option (gogoproto.goproto_getters_all) = false;
+option (gogoproto.goproto_enum_prefix_all) = false;
+
+message KeyValue {
+ // key is the key in bytes. An empty key is not allowed.
+ bytes key = 1;
+ // create_revision is the revision of last creation on this key.
+ int64 create_revision = 2;
+ // mod_revision is the revision of last modification on this key.
+ int64 mod_revision = 3;
+ // version is the version of the key. A deletion resets
+ // the version to zero and any modification of the key
+ // increases its version.
+ int64 version = 4;
+ // value is the value held by the key, in bytes.
+ bytes value = 5;
+ // lease is the ID of the lease that attached to key.
+ // When the attached lease expires, the key will be deleted.
+ // If lease is 0, then no lease is attached to the key.
+ int64 lease = 6;
+}
+
+message Event {
+ enum EventType {
+ PUT = 0;
+ DELETE = 1;
+ }
+ // type is the kind of event. If type is a PUT, it indicates
+ // new data has been stored to the key. If type is a DELETE,
+ // it indicates the key was deleted.
+ EventType type = 1;
+ // kv holds the KeyValue for the event.
+ // A PUT event contains current kv pair.
+ // A PUT event with kv.Version=1 indicates the creation of a key.
+ // A DELETE/EXPIRE event contains the deleted key with
+ // its modification revision set to the revision of deletion.
+ KeyValue kv = 2;
+
+ // prev_kv holds the key-value pair before the event happens.
+ KeyValue prev_kv = 3;
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/revision.go b/vendor/github.com/coreos/etcd/mvcc/revision.go
new file mode 100644
index 00000000..5fa35a1c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/revision.go
@@ -0,0 +1,67 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import "encoding/binary"
+
+// revBytesLen is the byte length of a normal revision.
+// First 8 bytes is the revision.main in big-endian format. The 9th byte
+// is a '_'. The last 8 bytes is the revision.sub in big-endian format.
+const revBytesLen = 8 + 1 + 8
+
+// A revision indicates modification of the key-value space.
+// The set of changes that share same main revision changes the key-value space atomically.
+type revision struct {
+ // main is the main revision of a set of changes that happen atomically.
+ main int64
+
+ // sub is the the sub revision of a change in a set of changes that happen
+ // atomically. Each change has different increasing sub revision in that
+ // set.
+ sub int64
+}
+
+func (a revision) GreaterThan(b revision) bool {
+ if a.main > b.main {
+ return true
+ }
+ if a.main < b.main {
+ return false
+ }
+ return a.sub > b.sub
+}
+
+func newRevBytes() []byte {
+ return make([]byte, revBytesLen, markedRevBytesLen)
+}
+
+func revToBytes(rev revision, bytes []byte) {
+ binary.BigEndian.PutUint64(bytes, uint64(rev.main))
+ bytes[8] = '_'
+ binary.BigEndian.PutUint64(bytes[9:], uint64(rev.sub))
+}
+
+func bytesToRev(bytes []byte) revision {
+ return revision{
+ main: int64(binary.BigEndian.Uint64(bytes[0:8])),
+ sub: int64(binary.BigEndian.Uint64(bytes[9:])),
+ }
+}
+
+type revisions []revision
+
+func (a revisions) Len() int { return len(a) }
+func (a revisions) Less(i, j int) bool { return a[j].GreaterThan(a[i]) }
+func (a revisions) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
diff --git a/vendor/github.com/coreos/etcd/mvcc/revision_test.go b/vendor/github.com/coreos/etcd/mvcc/revision_test.go
new file mode 100644
index 00000000..46fcb483
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/revision_test.go
@@ -0,0 +1,53 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "bytes"
+ "math"
+ "reflect"
+ "testing"
+)
+
+// TestRevision tests that revision could be encoded to and decoded from
+// bytes slice. Moreover, the lexicographical order of its byte slice representation
+// follows the order of (main, sub).
+func TestRevision(t *testing.T) {
+ tests := []revision{
+ // order in (main, sub)
+ {},
+ {main: 1, sub: 0},
+ {main: 1, sub: 1},
+ {main: 2, sub: 0},
+ {main: math.MaxInt64, sub: math.MaxInt64},
+ }
+
+ bs := make([][]byte, len(tests))
+ for i, tt := range tests {
+ b := newRevBytes()
+ revToBytes(tt, b)
+ bs[i] = b
+
+ if grev := bytesToRev(b); !reflect.DeepEqual(grev, tt) {
+ t.Errorf("#%d: revision = %+v, want %+v", i, grev, tt)
+ }
+ }
+
+ for i := 0; i < len(tests)-1; i++ {
+ if bytes.Compare(bs[i], bs[i+1]) >= 0 {
+ t.Errorf("#%d: %v (%+v) should be smaller than %v (%+v)", i, bs[i], tests[i], bs[i+1], tests[i+1])
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/util.go b/vendor/github.com/coreos/etcd/mvcc/util.go
new file mode 100644
index 00000000..8a0df0bf
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/util.go
@@ -0,0 +1,56 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "encoding/binary"
+
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+)
+
+func UpdateConsistentIndex(be backend.Backend, index uint64) {
+ tx := be.BatchTx()
+ tx.Lock()
+ defer tx.Unlock()
+
+ var oldi uint64
+ _, vs := tx.UnsafeRange(metaBucketName, consistentIndexKeyName, nil, 0)
+ if len(vs) != 0 {
+ oldi = binary.BigEndian.Uint64(vs[0])
+ }
+
+ if index <= oldi {
+ return
+ }
+
+ bs := make([]byte, 8)
+ binary.BigEndian.PutUint64(bs, index)
+ tx.UnsafePut(metaBucketName, consistentIndexKeyName, bs)
+}
+
+func WriteKV(be backend.Backend, kv mvccpb.KeyValue) {
+ ibytes := newRevBytes()
+ revToBytes(revision{main: kv.ModRevision}, ibytes)
+
+ d, err := kv.Marshal()
+ if err != nil {
+ plog.Fatalf("cannot marshal event: %v", err)
+ }
+
+ be.BatchTx().Lock()
+ be.BatchTx().UnsafePut(keyBucketName, ibytes, d)
+ be.BatchTx().Unlock()
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/watchable_store.go b/vendor/github.com/coreos/etcd/mvcc/watchable_store.go
new file mode 100644
index 00000000..ce852fdd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/watchable_store.go
@@ -0,0 +1,507 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+)
+
+const (
+ // chanBufLen is the length of the buffered chan
+ // for sending out watched events.
+ // TODO: find a good buf value. 1024 is just a random one that
+ // seems to be reasonable.
+ chanBufLen = 1024
+
+ // maxWatchersPerSync is the number of watchers to sync in a single batch
+ maxWatchersPerSync = 512
+)
+
+type watchable interface {
+ watch(key, end []byte, startRev int64, id WatchID, ch chan<- WatchResponse, fcs ...FilterFunc) (*watcher, cancelFunc)
+ progress(w *watcher)
+ rev() int64
+}
+
+type watchableStore struct {
+ *store
+
+ // mu protects watcher groups and batches. It should never be locked
+ // before locking store.mu to avoid deadlock.
+ mu sync.RWMutex
+
+ // victims are watcher batches that were blocked on the watch channel
+ victims []watcherBatch
+ victimc chan struct{}
+
+ // contains all unsynced watchers that needs to sync with events that have happened
+ unsynced watcherGroup
+
+ // contains all synced watchers that are in sync with the progress of the store.
+ // The key of the map is the key that the watcher watches on.
+ synced watcherGroup
+
+ stopc chan struct{}
+ wg sync.WaitGroup
+}
+
+// cancelFunc updates unsynced and synced maps when running
+// cancel operations.
+type cancelFunc func()
+
+func New(b backend.Backend, le lease.Lessor, ig ConsistentIndexGetter) ConsistentWatchableKV {
+ return newWatchableStore(b, le, ig)
+}
+
+func newWatchableStore(b backend.Backend, le lease.Lessor, ig ConsistentIndexGetter) *watchableStore {
+ s := &watchableStore{
+ store: NewStore(b, le, ig),
+ victimc: make(chan struct{}, 1),
+ unsynced: newWatcherGroup(),
+ synced: newWatcherGroup(),
+ stopc: make(chan struct{}),
+ }
+ s.store.ReadView = &readView{s}
+ s.store.WriteView = &writeView{s}
+ if s.le != nil {
+ // use this store as the deleter so revokes trigger watch events
+ s.le.SetRangeDeleter(func() lease.TxnDelete { return s.Write() })
+ }
+ s.wg.Add(2)
+ go s.syncWatchersLoop()
+ go s.syncVictimsLoop()
+ return s
+}
+
+func (s *watchableStore) Close() error {
+ close(s.stopc)
+ s.wg.Wait()
+ return s.store.Close()
+}
+
+func (s *watchableStore) NewWatchStream() WatchStream {
+ watchStreamGauge.Inc()
+ return &watchStream{
+ watchable: s,
+ ch: make(chan WatchResponse, chanBufLen),
+ cancels: make(map[WatchID]cancelFunc),
+ watchers: make(map[WatchID]*watcher),
+ }
+}
+
+func (s *watchableStore) watch(key, end []byte, startRev int64, id WatchID, ch chan<- WatchResponse, fcs ...FilterFunc) (*watcher, cancelFunc) {
+ wa := &watcher{
+ key: key,
+ end: end,
+ minRev: startRev,
+ id: id,
+ ch: ch,
+ fcs: fcs,
+ }
+
+ s.mu.Lock()
+ s.revMu.RLock()
+ synced := startRev > s.store.currentRev || startRev == 0
+ if synced {
+ wa.minRev = s.store.currentRev + 1
+ if startRev > wa.minRev {
+ wa.minRev = startRev
+ }
+ }
+ if synced {
+ s.synced.add(wa)
+ } else {
+ slowWatcherGauge.Inc()
+ s.unsynced.add(wa)
+ }
+ s.revMu.RUnlock()
+ s.mu.Unlock()
+
+ watcherGauge.Inc()
+
+ return wa, func() { s.cancelWatcher(wa) }
+}
+
+// cancelWatcher removes references of the watcher from the watchableStore
+func (s *watchableStore) cancelWatcher(wa *watcher) {
+ for {
+ s.mu.Lock()
+
+ if s.unsynced.delete(wa) {
+ slowWatcherGauge.Dec()
+ break
+ } else if s.synced.delete(wa) {
+ break
+ } else if wa.compacted {
+ break
+ }
+
+ if !wa.victim {
+ panic("watcher not victim but not in watch groups")
+ }
+
+ var victimBatch watcherBatch
+ for _, wb := range s.victims {
+ if wb[wa] != nil {
+ victimBatch = wb
+ break
+ }
+ }
+ if victimBatch != nil {
+ slowWatcherGauge.Dec()
+ delete(victimBatch, wa)
+ break
+ }
+
+ // victim being processed so not accessible; retry
+ s.mu.Unlock()
+ time.Sleep(time.Millisecond)
+ }
+
+ watcherGauge.Dec()
+ s.mu.Unlock()
+}
+
+// syncWatchersLoop syncs the watcher in the unsynced map every 100ms.
+func (s *watchableStore) syncWatchersLoop() {
+ defer s.wg.Done()
+
+ for {
+ s.mu.RLock()
+ st := time.Now()
+ lastUnsyncedWatchers := s.unsynced.size()
+ s.mu.RUnlock()
+
+ unsyncedWatchers := 0
+ if lastUnsyncedWatchers > 0 {
+ unsyncedWatchers = s.syncWatchers()
+ }
+ syncDuration := time.Since(st)
+
+ waitDuration := 100 * time.Millisecond
+ // more work pending?
+ if unsyncedWatchers != 0 && lastUnsyncedWatchers > unsyncedWatchers {
+ // be fair to other store operations by yielding time taken
+ waitDuration = syncDuration
+ }
+
+ select {
+ case <-time.After(waitDuration):
+ case <-s.stopc:
+ return
+ }
+ }
+}
+
+// syncVictimsLoop tries to write precomputed watcher responses to
+// watchers that had a blocked watcher channel
+func (s *watchableStore) syncVictimsLoop() {
+ defer s.wg.Done()
+
+ for {
+ for s.moveVictims() != 0 {
+ // try to update all victim watchers
+ }
+ s.mu.RLock()
+ isEmpty := len(s.victims) == 0
+ s.mu.RUnlock()
+
+ var tickc <-chan time.Time
+ if !isEmpty {
+ tickc = time.After(10 * time.Millisecond)
+ }
+
+ select {
+ case <-tickc:
+ case <-s.victimc:
+ case <-s.stopc:
+ return
+ }
+ }
+}
+
+// moveVictims tries to update watches with already pending event data
+func (s *watchableStore) moveVictims() (moved int) {
+ s.mu.Lock()
+ victims := s.victims
+ s.victims = nil
+ s.mu.Unlock()
+
+ var newVictim watcherBatch
+ for _, wb := range victims {
+ // try to send responses again
+ for w, eb := range wb {
+ // watcher has observed the store up to, but not including, w.minRev
+ rev := w.minRev - 1
+ if w.send(WatchResponse{WatchID: w.id, Events: eb.evs, Revision: rev}) {
+ pendingEventsGauge.Add(float64(len(eb.evs)))
+ } else {
+ if newVictim == nil {
+ newVictim = make(watcherBatch)
+ }
+ newVictim[w] = eb
+ continue
+ }
+ moved++
+ }
+
+ // assign completed victim watchers to unsync/sync
+ s.mu.Lock()
+ s.store.revMu.RLock()
+ curRev := s.store.currentRev
+ for w, eb := range wb {
+ if newVictim != nil && newVictim[w] != nil {
+ // couldn't send watch response; stays victim
+ continue
+ }
+ w.victim = false
+ if eb.moreRev != 0 {
+ w.minRev = eb.moreRev
+ }
+ if w.minRev <= curRev {
+ s.unsynced.add(w)
+ } else {
+ slowWatcherGauge.Dec()
+ s.synced.add(w)
+ }
+ }
+ s.store.revMu.RUnlock()
+ s.mu.Unlock()
+ }
+
+ if len(newVictim) > 0 {
+ s.mu.Lock()
+ s.victims = append(s.victims, newVictim)
+ s.mu.Unlock()
+ }
+
+ return moved
+}
+
+// syncWatchers syncs unsynced watchers by:
+// 1. choose a set of watchers from the unsynced watcher group
+// 2. iterate over the set to get the minimum revision and remove compacted watchers
+// 3. use minimum revision to get all key-value pairs and send those events to watchers
+// 4. remove synced watchers in set from unsynced group and move to synced group
+func (s *watchableStore) syncWatchers() int {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+
+ if s.unsynced.size() == 0 {
+ return 0
+ }
+
+ s.store.revMu.RLock()
+ defer s.store.revMu.RUnlock()
+
+ // in order to find key-value pairs from unsynced watchers, we need to
+ // find min revision index, and these revisions can be used to
+ // query the backend store of key-value pairs
+ curRev := s.store.currentRev
+ compactionRev := s.store.compactMainRev
+
+ wg, minRev := s.unsynced.choose(maxWatchersPerSync, curRev, compactionRev)
+ minBytes, maxBytes := newRevBytes(), newRevBytes()
+ revToBytes(revision{main: minRev}, minBytes)
+ revToBytes(revision{main: curRev + 1}, maxBytes)
+
+ // UnsafeRange returns keys and values. And in boltdb, keys are revisions.
+ // values are actual key-value pairs in backend.
+ tx := s.store.b.ReadTx()
+ tx.Lock()
+ revs, vs := tx.UnsafeRange(keyBucketName, minBytes, maxBytes, 0)
+ evs := kvsToEvents(wg, revs, vs)
+ tx.Unlock()
+
+ var victims watcherBatch
+ wb := newWatcherBatch(wg, evs)
+ for w := range wg.watchers {
+ w.minRev = curRev + 1
+
+ eb, ok := wb[w]
+ if !ok {
+ // bring un-notified watcher to synced
+ s.synced.add(w)
+ s.unsynced.delete(w)
+ continue
+ }
+
+ if eb.moreRev != 0 {
+ w.minRev = eb.moreRev
+ }
+
+ if w.send(WatchResponse{WatchID: w.id, Events: eb.evs, Revision: curRev}) {
+ pendingEventsGauge.Add(float64(len(eb.evs)))
+ } else {
+ if victims == nil {
+ victims = make(watcherBatch)
+ }
+ w.victim = true
+ }
+
+ if w.victim {
+ victims[w] = eb
+ } else {
+ if eb.moreRev != 0 {
+ // stay unsynced; more to read
+ continue
+ }
+ s.synced.add(w)
+ }
+ s.unsynced.delete(w)
+ }
+ s.addVictim(victims)
+
+ vsz := 0
+ for _, v := range s.victims {
+ vsz += len(v)
+ }
+ slowWatcherGauge.Set(float64(s.unsynced.size() + vsz))
+
+ return s.unsynced.size()
+}
+
+// kvsToEvents gets all events for the watchers from all key-value pairs
+func kvsToEvents(wg *watcherGroup, revs, vals [][]byte) (evs []mvccpb.Event) {
+ for i, v := range vals {
+ var kv mvccpb.KeyValue
+ if err := kv.Unmarshal(v); err != nil {
+ plog.Panicf("cannot unmarshal event: %v", err)
+ }
+
+ if !wg.contains(string(kv.Key)) {
+ continue
+ }
+
+ ty := mvccpb.PUT
+ if isTombstone(revs[i]) {
+ ty = mvccpb.DELETE
+ // patch in mod revision so watchers won't skip
+ kv.ModRevision = bytesToRev(revs[i]).main
+ }
+ evs = append(evs, mvccpb.Event{Kv: &kv, Type: ty})
+ }
+ return evs
+}
+
+// notify notifies the fact that given event at the given rev just happened to
+// watchers that watch on the key of the event.
+func (s *watchableStore) notify(rev int64, evs []mvccpb.Event) {
+ var victim watcherBatch
+ for w, eb := range newWatcherBatch(&s.synced, evs) {
+ if eb.revs != 1 {
+ plog.Panicf("unexpected multiple revisions in notification")
+ }
+
+ if w.send(WatchResponse{WatchID: w.id, Events: eb.evs, Revision: rev}) {
+ pendingEventsGauge.Add(float64(len(eb.evs)))
+ } else {
+ // move slow watcher to victims
+ w.minRev = rev + 1
+ if victim == nil {
+ victim = make(watcherBatch)
+ }
+ w.victim = true
+ victim[w] = eb
+ s.synced.delete(w)
+ slowWatcherGauge.Inc()
+ }
+ }
+ s.addVictim(victim)
+}
+
+func (s *watchableStore) addVictim(victim watcherBatch) {
+ if victim == nil {
+ return
+ }
+ s.victims = append(s.victims, victim)
+ select {
+ case s.victimc <- struct{}{}:
+ default:
+ }
+}
+
+func (s *watchableStore) rev() int64 { return s.store.Rev() }
+
+func (s *watchableStore) progress(w *watcher) {
+ s.mu.RLock()
+ defer s.mu.RUnlock()
+
+ if _, ok := s.synced.watchers[w]; ok {
+ w.send(WatchResponse{WatchID: w.id, Revision: s.rev()})
+ // If the ch is full, this watcher is receiving events.
+ // We do not need to send progress at all.
+ }
+}
+
+type watcher struct {
+ // the watcher key
+ key []byte
+ // end indicates the end of the range to watch.
+ // If end is set, the watcher is on a range.
+ end []byte
+
+ // victim is set when ch is blocked and undergoing victim processing
+ victim bool
+
+ // compacted is set when the watcher is removed because of compaction
+ compacted bool
+
+ // minRev is the minimum revision update the watcher will accept
+ minRev int64
+ id WatchID
+
+ fcs []FilterFunc
+ // a chan to send out the watch response.
+ // The chan might be shared with other watchers.
+ ch chan<- WatchResponse
+}
+
+func (w *watcher) send(wr WatchResponse) bool {
+ progressEvent := len(wr.Events) == 0
+
+ if len(w.fcs) != 0 {
+ ne := make([]mvccpb.Event, 0, len(wr.Events))
+ for i := range wr.Events {
+ filtered := false
+ for _, filter := range w.fcs {
+ if filter(wr.Events[i]) {
+ filtered = true
+ break
+ }
+ }
+ if !filtered {
+ ne = append(ne, wr.Events[i])
+ }
+ }
+ wr.Events = ne
+ }
+
+ // if all events are filtered out, we should send nothing.
+ if !progressEvent && len(wr.Events) == 0 {
+ return true
+ }
+ select {
+ case w.ch <- wr:
+ return true
+ default:
+ return false
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/watchable_store_bench_test.go b/vendor/github.com/coreos/etcd/mvcc/watchable_store_bench_test.go
new file mode 100644
index 00000000..769d1bc3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/watchable_store_bench_test.go
@@ -0,0 +1,200 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "math/rand"
+ "os"
+ "testing"
+
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc/backend"
+)
+
+func BenchmarkWatchableStorePut(b *testing.B) {
+ be, tmpPath := backend.NewDefaultTmpBackend()
+ s := New(be, &lease.FakeLessor{}, nil)
+ defer cleanup(s, be, tmpPath)
+
+ // arbitrary number of bytes
+ bytesN := 64
+ keys := createBytesSlice(bytesN, b.N)
+ vals := createBytesSlice(bytesN, b.N)
+
+ b.ResetTimer()
+ b.ReportAllocs()
+ for i := 0; i < b.N; i++ {
+ s.Put(keys[i], vals[i], lease.NoLease)
+ }
+}
+
+// BenchmarkWatchableStoreTxnPut benchmarks the Put operation
+// with transaction begin and end, where transaction involves
+// some synchronization operations, such as mutex locking.
+func BenchmarkWatchableStoreTxnPut(b *testing.B) {
+ var i fakeConsistentIndex
+ be, tmpPath := backend.NewDefaultTmpBackend()
+ s := New(be, &lease.FakeLessor{}, &i)
+ defer cleanup(s, be, tmpPath)
+
+ // arbitrary number of bytes
+ bytesN := 64
+ keys := createBytesSlice(bytesN, b.N)
+ vals := createBytesSlice(bytesN, b.N)
+
+ b.ResetTimer()
+ b.ReportAllocs()
+ for i := 0; i < b.N; i++ {
+ txn := s.Write()
+ txn.Put(keys[i], vals[i], lease.NoLease)
+ txn.End()
+ }
+}
+
+// BenchmarkWatchableStoreWatchSyncPut benchmarks the case of
+// many synced watchers receiving a Put notification.
+func BenchmarkWatchableStoreWatchSyncPut(b *testing.B) {
+ be, tmpPath := backend.NewDefaultTmpBackend()
+ s := newWatchableStore(be, &lease.FakeLessor{}, nil)
+ defer cleanup(s, be, tmpPath)
+
+ k := []byte("testkey")
+ v := []byte("testval")
+
+ w := s.NewWatchStream()
+ defer w.Close()
+ watchIDs := make([]WatchID, b.N)
+ for i := range watchIDs {
+ // non-0 value to keep watchers in unsynced
+ watchIDs[i] = w.Watch(k, nil, 1)
+ }
+
+ b.ResetTimer()
+ b.ReportAllocs()
+
+ // trigger watchers
+ s.Put(k, v, lease.NoLease)
+ for range watchIDs {
+ <-w.Chan()
+ }
+ select {
+ case wc := <-w.Chan():
+ b.Fatalf("unexpected data %v", wc)
+ default:
+ }
+}
+
+// Benchmarks on cancel function performance for unsynced watchers
+// in a WatchableStore. It creates k*N watchers to populate unsynced
+// with a reasonably large number of watchers. And measures the time it
+// takes to cancel N watchers out of k*N watchers. The performance is
+// expected to differ depending on the unsynced member implementation.
+// TODO: k is an arbitrary constant. We need to figure out what factor
+// we should put to simulate the real-world use cases.
+func BenchmarkWatchableStoreUnsyncedCancel(b *testing.B) {
+ be, tmpPath := backend.NewDefaultTmpBackend()
+ s := NewStore(be, &lease.FakeLessor{}, nil)
+
+ // manually create watchableStore instead of newWatchableStore
+ // because newWatchableStore periodically calls syncWatchersLoop
+ // method to sync watchers in unsynced map. We want to keep watchers
+ // in unsynced for this benchmark.
+ ws := &watchableStore{
+ store: s,
+ unsynced: newWatcherGroup(),
+
+ // to make the test not crash from assigning to nil map.
+ // 'synced' doesn't get populated in this test.
+ synced: newWatcherGroup(),
+ }
+
+ defer func() {
+ ws.store.Close()
+ os.Remove(tmpPath)
+ }()
+
+ // Put a key so that we can spawn watchers on that key
+ // (testKey in this test). This increases the rev to 1,
+ // and later we can we set the watcher's startRev to 1,
+ // and force watchers to be in unsynced.
+ testKey := []byte("foo")
+ testValue := []byte("bar")
+ s.Put(testKey, testValue, lease.NoLease)
+
+ w := ws.NewWatchStream()
+
+ const k int = 2
+ benchSampleN := b.N
+ watcherN := k * benchSampleN
+
+ watchIDs := make([]WatchID, watcherN)
+ for i := 0; i < watcherN; i++ {
+ // non-0 value to keep watchers in unsynced
+ watchIDs[i] = w.Watch(testKey, nil, 1)
+ }
+
+ // random-cancel N watchers to make it not biased towards
+ // data structures with an order, such as slice.
+ ix := rand.Perm(watcherN)
+
+ b.ResetTimer()
+ b.ReportAllocs()
+
+ // cancel N watchers
+ for _, idx := range ix[:benchSampleN] {
+ if err := w.Cancel(watchIDs[idx]); err != nil {
+ b.Error(err)
+ }
+ }
+}
+
+func BenchmarkWatchableStoreSyncedCancel(b *testing.B) {
+ be, tmpPath := backend.NewDefaultTmpBackend()
+ s := newWatchableStore(be, &lease.FakeLessor{}, nil)
+
+ defer func() {
+ s.store.Close()
+ os.Remove(tmpPath)
+ }()
+
+ // Put a key so that we can spawn watchers on that key
+ testKey := []byte("foo")
+ testValue := []byte("bar")
+ s.Put(testKey, testValue, lease.NoLease)
+
+ w := s.NewWatchStream()
+
+ // put 1 million watchers on the same key
+ const watcherN = 1000000
+
+ watchIDs := make([]WatchID, watcherN)
+ for i := 0; i < watcherN; i++ {
+ // 0 for startRev to keep watchers in synced
+ watchIDs[i] = w.Watch(testKey, nil, 0)
+ }
+
+ // randomly cancel watchers to make it not biased towards
+ // data structures with an order, such as slice.
+ ix := rand.Perm(watcherN)
+
+ b.ResetTimer()
+ b.ReportAllocs()
+
+ for _, idx := range ix {
+ if err := w.Cancel(watchIDs[idx]); err != nil {
+ b.Error(err)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/watchable_store_test.go b/vendor/github.com/coreos/etcd/mvcc/watchable_store_test.go
new file mode 100644
index 00000000..37bd01d8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/watchable_store_test.go
@@ -0,0 +1,426 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "bytes"
+ "os"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+)
+
+func TestWatch(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := newWatchableStore(b, &lease.FakeLessor{}, nil)
+
+ defer func() {
+ s.store.Close()
+ os.Remove(tmpPath)
+ }()
+
+ testKey := []byte("foo")
+ testValue := []byte("bar")
+ s.Put(testKey, testValue, lease.NoLease)
+
+ w := s.NewWatchStream()
+ w.Watch(testKey, nil, 0)
+
+ if !s.synced.contains(string(testKey)) {
+ // the key must have had an entry in synced
+ t.Errorf("existence = false, want true")
+ }
+}
+
+func TestNewWatcherCancel(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := newWatchableStore(b, &lease.FakeLessor{}, nil)
+
+ defer func() {
+ s.store.Close()
+ os.Remove(tmpPath)
+ }()
+ testKey := []byte("foo")
+ testValue := []byte("bar")
+ s.Put(testKey, testValue, lease.NoLease)
+
+ w := s.NewWatchStream()
+ wt := w.Watch(testKey, nil, 0)
+
+ if err := w.Cancel(wt); err != nil {
+ t.Error(err)
+ }
+
+ if s.synced.contains(string(testKey)) {
+ // the key shoud have been deleted
+ t.Errorf("existence = true, want false")
+ }
+}
+
+// TestCancelUnsynced tests if running CancelFunc removes watchers from unsynced.
+func TestCancelUnsynced(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+
+ // manually create watchableStore instead of newWatchableStore
+ // because newWatchableStore automatically calls syncWatchers
+ // method to sync watchers in unsynced map. We want to keep watchers
+ // in unsynced to test if syncWatchers works as expected.
+ s := &watchableStore{
+ store: NewStore(b, &lease.FakeLessor{}, nil),
+ unsynced: newWatcherGroup(),
+
+ // to make the test not crash from assigning to nil map.
+ // 'synced' doesn't get populated in this test.
+ synced: newWatcherGroup(),
+ }
+
+ defer func() {
+ s.store.Close()
+ os.Remove(tmpPath)
+ }()
+
+ // Put a key so that we can spawn watchers on that key.
+ // (testKey in this test). This increases the rev to 1,
+ // and later we can we set the watcher's startRev to 1,
+ // and force watchers to be in unsynced.
+ testKey := []byte("foo")
+ testValue := []byte("bar")
+ s.Put(testKey, testValue, lease.NoLease)
+
+ w := s.NewWatchStream()
+
+ // arbitrary number for watchers
+ watcherN := 100
+
+ // create watcherN of watch ids to cancel
+ watchIDs := make([]WatchID, watcherN)
+ for i := 0; i < watcherN; i++ {
+ // use 1 to keep watchers in unsynced
+ watchIDs[i] = w.Watch(testKey, nil, 1)
+ }
+
+ for _, idx := range watchIDs {
+ if err := w.Cancel(idx); err != nil {
+ t.Error(err)
+ }
+ }
+
+ // After running CancelFunc
+ //
+ // unsynced should be empty
+ // because cancel removes watcher from unsynced
+ if size := s.unsynced.size(); size != 0 {
+ t.Errorf("unsynced size = %d, want 0", size)
+ }
+}
+
+// TestSyncWatchers populates unsynced watcher map and tests syncWatchers
+// method to see if it correctly sends events to channel of unsynced watchers
+// and moves these watchers to synced.
+func TestSyncWatchers(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+
+ s := &watchableStore{
+ store: NewStore(b, &lease.FakeLessor{}, nil),
+ unsynced: newWatcherGroup(),
+ synced: newWatcherGroup(),
+ }
+
+ defer func() {
+ s.store.Close()
+ os.Remove(tmpPath)
+ }()
+
+ testKey := []byte("foo")
+ testValue := []byte("bar")
+ s.Put(testKey, testValue, lease.NoLease)
+
+ w := s.NewWatchStream()
+
+ // arbitrary number for watchers
+ watcherN := 100
+
+ for i := 0; i < watcherN; i++ {
+ // specify rev as 1 to keep watchers in unsynced
+ w.Watch(testKey, nil, 1)
+ }
+
+ // Before running s.syncWatchers() synced should be empty because we manually
+ // populate unsynced only
+ sws := s.synced.watcherSetByKey(string(testKey))
+ uws := s.unsynced.watcherSetByKey(string(testKey))
+
+ if len(sws) != 0 {
+ t.Fatalf("synced[string(testKey)] size = %d, want 0", len(sws))
+ }
+ // unsynced should not be empty because we manually populated unsynced only
+ if len(uws) != watcherN {
+ t.Errorf("unsynced size = %d, want %d", len(uws), watcherN)
+ }
+
+ // this should move all unsynced watchers to synced ones
+ s.syncWatchers()
+
+ sws = s.synced.watcherSetByKey(string(testKey))
+ uws = s.unsynced.watcherSetByKey(string(testKey))
+
+ // After running s.syncWatchers(), synced should not be empty because syncwatchers
+ // populates synced in this test case
+ if len(sws) != watcherN {
+ t.Errorf("synced[string(testKey)] size = %d, want %d", len(sws), watcherN)
+ }
+
+ // unsynced should be empty because syncwatchers is expected to move all watchers
+ // from unsynced to synced in this test case
+ if len(uws) != 0 {
+ t.Errorf("unsynced size = %d, want 0", len(uws))
+ }
+
+ for w := range sws {
+ if w.minRev != s.Rev()+1 {
+ t.Errorf("w.minRev = %d, want %d", w.minRev, s.Rev()+1)
+ }
+ }
+
+ if len(w.(*watchStream).ch) != watcherN {
+ t.Errorf("watched event size = %d, want %d", len(w.(*watchStream).ch), watcherN)
+ }
+
+ evs := (<-w.(*watchStream).ch).Events
+ if len(evs) != 1 {
+ t.Errorf("len(evs) got = %d, want = 1", len(evs))
+ }
+ if evs[0].Type != mvccpb.PUT {
+ t.Errorf("got = %v, want = %v", evs[0].Type, mvccpb.PUT)
+ }
+ if !bytes.Equal(evs[0].Kv.Key, testKey) {
+ t.Errorf("got = %s, want = %s", evs[0].Kv.Key, testKey)
+ }
+ if !bytes.Equal(evs[0].Kv.Value, testValue) {
+ t.Errorf("got = %s, want = %s", evs[0].Kv.Value, testValue)
+ }
+}
+
+// TestWatchCompacted tests a watcher that watches on a compacted revision.
+func TestWatchCompacted(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := newWatchableStore(b, &lease.FakeLessor{}, nil)
+
+ defer func() {
+ s.store.Close()
+ os.Remove(tmpPath)
+ }()
+ testKey := []byte("foo")
+ testValue := []byte("bar")
+
+ maxRev := 10
+ compactRev := int64(5)
+ for i := 0; i < maxRev; i++ {
+ s.Put(testKey, testValue, lease.NoLease)
+ }
+ _, err := s.Compact(compactRev)
+ if err != nil {
+ t.Fatalf("failed to compact kv (%v)", err)
+ }
+
+ w := s.NewWatchStream()
+ wt := w.Watch(testKey, nil, compactRev-1)
+
+ select {
+ case resp := <-w.Chan():
+ if resp.WatchID != wt {
+ t.Errorf("resp.WatchID = %x, want %x", resp.WatchID, wt)
+ }
+ if resp.CompactRevision == 0 {
+ t.Errorf("resp.Compacted = %v, want %v", resp.CompactRevision, compactRev)
+ }
+ case <-time.After(1 * time.Second):
+ t.Fatalf("failed to receive response (timeout)")
+ }
+}
+
+func TestWatchFutureRev(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := newWatchableStore(b, &lease.FakeLessor{}, nil)
+
+ defer func() {
+ s.store.Close()
+ os.Remove(tmpPath)
+ }()
+
+ testKey := []byte("foo")
+ testValue := []byte("bar")
+
+ w := s.NewWatchStream()
+ wrev := int64(10)
+ w.Watch(testKey, nil, wrev)
+
+ for i := 0; i < 10; i++ {
+ rev := s.Put(testKey, testValue, lease.NoLease)
+ if rev >= wrev {
+ break
+ }
+ }
+
+ select {
+ case resp := <-w.Chan():
+ if resp.Revision != wrev {
+ t.Fatalf("rev = %d, want %d", resp.Revision, wrev)
+ }
+ if len(resp.Events) != 1 {
+ t.Fatalf("failed to get events from the response")
+ }
+ if resp.Events[0].Kv.ModRevision != wrev {
+ t.Fatalf("kv.rev = %d, want %d", resp.Events[0].Kv.ModRevision, wrev)
+ }
+ case <-time.After(time.Second):
+ t.Fatal("failed to receive event in 1 second.")
+ }
+}
+
+// TestWatchBatchUnsynced tests batching on unsynced watchers
+func TestWatchBatchUnsynced(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := newWatchableStore(b, &lease.FakeLessor{}, nil)
+
+ oldMaxRevs := watchBatchMaxRevs
+ defer func() {
+ watchBatchMaxRevs = oldMaxRevs
+ s.store.Close()
+ os.Remove(tmpPath)
+ }()
+ batches := 3
+ watchBatchMaxRevs = 4
+
+ v := []byte("foo")
+ for i := 0; i < watchBatchMaxRevs*batches; i++ {
+ s.Put(v, v, lease.NoLease)
+ }
+
+ w := s.NewWatchStream()
+ w.Watch(v, nil, 1)
+ for i := 0; i < batches; i++ {
+ if resp := <-w.Chan(); len(resp.Events) != watchBatchMaxRevs {
+ t.Fatalf("len(events) = %d, want %d", len(resp.Events), watchBatchMaxRevs)
+ }
+ }
+
+ s.store.revMu.Lock()
+ defer s.store.revMu.Unlock()
+ if size := s.synced.size(); size != 1 {
+ t.Errorf("synced size = %d, want 1", size)
+ }
+}
+
+func TestNewMapwatcherToEventMap(t *testing.T) {
+ k0, k1, k2 := []byte("foo0"), []byte("foo1"), []byte("foo2")
+ v0, v1, v2 := []byte("bar0"), []byte("bar1"), []byte("bar2")
+
+ ws := []*watcher{{key: k0}, {key: k1}, {key: k2}}
+
+ evs := []mvccpb.Event{
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: k0, Value: v0},
+ },
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: k1, Value: v1},
+ },
+ {
+ Type: mvccpb.PUT,
+ Kv: &mvccpb.KeyValue{Key: k2, Value: v2},
+ },
+ }
+
+ tests := []struct {
+ sync []*watcher
+ evs []mvccpb.Event
+
+ wwe map[*watcher][]mvccpb.Event
+ }{
+ // no watcher in sync, some events should return empty wwe
+ {
+ nil,
+ evs,
+ map[*watcher][]mvccpb.Event{},
+ },
+
+ // one watcher in sync, one event that does not match the key of that
+ // watcher should return empty wwe
+ {
+ []*watcher{ws[2]},
+ evs[:1],
+ map[*watcher][]mvccpb.Event{},
+ },
+
+ // one watcher in sync, one event that matches the key of that
+ // watcher should return wwe with that matching watcher
+ {
+ []*watcher{ws[1]},
+ evs[1:2],
+ map[*watcher][]mvccpb.Event{
+ ws[1]: evs[1:2],
+ },
+ },
+
+ // two watchers in sync that watches two different keys, one event
+ // that matches the key of only one of the watcher should return wwe
+ // with the matching watcher
+ {
+ []*watcher{ws[0], ws[2]},
+ evs[2:],
+ map[*watcher][]mvccpb.Event{
+ ws[2]: evs[2:],
+ },
+ },
+
+ // two watchers in sync that watches the same key, two events that
+ // match the keys should return wwe with those two watchers
+ {
+ []*watcher{ws[0], ws[1]},
+ evs[:2],
+ map[*watcher][]mvccpb.Event{
+ ws[0]: evs[:1],
+ ws[1]: evs[1:2],
+ },
+ },
+ }
+
+ for i, tt := range tests {
+ wg := newWatcherGroup()
+ for _, w := range tt.sync {
+ wg.add(w)
+ }
+
+ gwe := newWatcherBatch(&wg, tt.evs)
+ if len(gwe) != len(tt.wwe) {
+ t.Errorf("#%d: len(gwe) got = %d, want = %d", i, len(gwe), len(tt.wwe))
+ }
+ // compare gwe and tt.wwe
+ for w, eb := range gwe {
+ if len(eb.evs) != len(tt.wwe[w]) {
+ t.Errorf("#%d: len(eb.evs) got = %d, want = %d", i, len(eb.evs), len(tt.wwe[w]))
+ }
+ if !reflect.DeepEqual(eb.evs, tt.wwe[w]) {
+ t.Errorf("#%d: reflect.DeepEqual events got = %v, want = true", i, false)
+ }
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/watchable_store_txn.go b/vendor/github.com/coreos/etcd/mvcc/watchable_store_txn.go
new file mode 100644
index 00000000..5c5bfda1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/watchable_store_txn.go
@@ -0,0 +1,53 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "github.com/coreos/etcd/mvcc/mvccpb"
+)
+
+func (tw *watchableStoreTxnWrite) End() {
+ changes := tw.Changes()
+ if len(changes) == 0 {
+ tw.TxnWrite.End()
+ return
+ }
+
+ rev := tw.Rev() + 1
+ evs := make([]mvccpb.Event, len(changes))
+ for i, change := range changes {
+ evs[i].Kv = &changes[i]
+ if change.CreateRevision == 0 {
+ evs[i].Type = mvccpb.DELETE
+ evs[i].Kv.ModRevision = rev
+ } else {
+ evs[i].Type = mvccpb.PUT
+ }
+ }
+
+ // end write txn under watchable store lock so the updates are visible
+ // when asynchronous event posting checks the current store revision
+ tw.s.mu.Lock()
+ tw.s.notify(rev, evs)
+ tw.TxnWrite.End()
+ tw.s.mu.Unlock()
+}
+
+type watchableStoreTxnWrite struct {
+ TxnWrite
+ s *watchableStore
+}
+
+func (s *watchableStore) Write() TxnWrite { return &watchableStoreTxnWrite{s.store.Write(), s} }
diff --git a/vendor/github.com/coreos/etcd/mvcc/watcher.go b/vendor/github.com/coreos/etcd/mvcc/watcher.go
new file mode 100644
index 00000000..9468d426
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/watcher.go
@@ -0,0 +1,171 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "bytes"
+ "errors"
+ "sync"
+
+ "github.com/coreos/etcd/mvcc/mvccpb"
+)
+
+var (
+ ErrWatcherNotExist = errors.New("mvcc: watcher does not exist")
+)
+
+type WatchID int64
+
+// FilterFunc returns true if the given event should be filtered out.
+type FilterFunc func(e mvccpb.Event) bool
+
+type WatchStream interface {
+ // Watch creates a watcher. The watcher watches the events happening or
+ // happened on the given key or range [key, end) from the given startRev.
+ //
+ // The whole event history can be watched unless compacted.
+ // If `startRev` <=0, watch observes events after currentRev.
+ //
+ // The returned `id` is the ID of this watcher. It appears as WatchID
+ // in events that are sent to the created watcher through stream channel.
+ //
+ Watch(key, end []byte, startRev int64, fcs ...FilterFunc) WatchID
+
+ // Chan returns a chan. All watch response will be sent to the returned chan.
+ Chan() <-chan WatchResponse
+
+ // RequestProgress requests the progress of the watcher with given ID. The response
+ // will only be sent if the watcher is currently synced.
+ // The responses will be sent through the WatchRespone Chan attached
+ // with this stream to ensure correct ordering.
+ // The responses contains no events. The revision in the response is the progress
+ // of the watchers since the watcher is currently synced.
+ RequestProgress(id WatchID)
+
+ // Cancel cancels a watcher by giving its ID. If watcher does not exist, an error will be
+ // returned.
+ Cancel(id WatchID) error
+
+ // Close closes Chan and release all related resources.
+ Close()
+
+ // Rev returns the current revision of the KV the stream watches on.
+ Rev() int64
+}
+
+type WatchResponse struct {
+ // WatchID is the WatchID of the watcher this response sent to.
+ WatchID WatchID
+
+ // Events contains all the events that needs to send.
+ Events []mvccpb.Event
+
+ // Revision is the revision of the KV when the watchResponse is created.
+ // For a normal response, the revision should be the same as the last
+ // modified revision inside Events. For a delayed response to a unsynced
+ // watcher, the revision is greater than the last modified revision
+ // inside Events.
+ Revision int64
+
+ // CompactRevision is set when the watcher is cancelled due to compaction.
+ CompactRevision int64
+}
+
+// watchStream contains a collection of watchers that share
+// one streaming chan to send out watched events and other control events.
+type watchStream struct {
+ watchable watchable
+ ch chan WatchResponse
+
+ mu sync.Mutex // guards fields below it
+ // nextID is the ID pre-allocated for next new watcher in this stream
+ nextID WatchID
+ closed bool
+ cancels map[WatchID]cancelFunc
+ watchers map[WatchID]*watcher
+}
+
+// Watch creates a new watcher in the stream and returns its WatchID.
+// TODO: return error if ws is closed?
+func (ws *watchStream) Watch(key, end []byte, startRev int64, fcs ...FilterFunc) WatchID {
+ // prevent wrong range where key >= end lexicographically
+ // watch request with 'WithFromKey' has empty-byte range end
+ if len(end) != 0 && bytes.Compare(key, end) != -1 {
+ return -1
+ }
+
+ ws.mu.Lock()
+ defer ws.mu.Unlock()
+ if ws.closed {
+ return -1
+ }
+
+ id := ws.nextID
+ ws.nextID++
+
+ w, c := ws.watchable.watch(key, end, startRev, id, ws.ch, fcs...)
+
+ ws.cancels[id] = c
+ ws.watchers[id] = w
+ return id
+}
+
+func (ws *watchStream) Chan() <-chan WatchResponse {
+ return ws.ch
+}
+
+func (ws *watchStream) Cancel(id WatchID) error {
+ ws.mu.Lock()
+ cancel, ok := ws.cancels[id]
+ ok = ok && !ws.closed
+ if ok {
+ delete(ws.cancels, id)
+ delete(ws.watchers, id)
+ }
+ ws.mu.Unlock()
+ if !ok {
+ return ErrWatcherNotExist
+ }
+ cancel()
+ return nil
+}
+
+func (ws *watchStream) Close() {
+ ws.mu.Lock()
+ defer ws.mu.Unlock()
+
+ for _, cancel := range ws.cancels {
+ cancel()
+ }
+ ws.closed = true
+ close(ws.ch)
+ watchStreamGauge.Dec()
+}
+
+func (ws *watchStream) Rev() int64 {
+ ws.mu.Lock()
+ defer ws.mu.Unlock()
+ return ws.watchable.rev()
+}
+
+func (ws *watchStream) RequestProgress(id WatchID) {
+ ws.mu.Lock()
+ w, ok := ws.watchers[id]
+ ws.mu.Unlock()
+ if !ok {
+ return
+ }
+ ws.watchable.progress(w)
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/watcher_bench_test.go b/vendor/github.com/coreos/etcd/mvcc/watcher_bench_test.go
new file mode 100644
index 00000000..8a4242f3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/watcher_bench_test.go
@@ -0,0 +1,38 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc/backend"
+)
+
+func BenchmarkKVWatcherMemoryUsage(b *testing.B) {
+ be, tmpPath := backend.NewDefaultTmpBackend()
+ watchable := newWatchableStore(be, &lease.FakeLessor{}, nil)
+
+ defer cleanup(watchable, be, tmpPath)
+
+ w := watchable.NewWatchStream()
+
+ b.ReportAllocs()
+ b.StartTimer()
+ for i := 0; i < b.N; i++ {
+ w.Watch([]byte(fmt.Sprint("foo", i)), nil, 0)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/watcher_group.go b/vendor/github.com/coreos/etcd/mvcc/watcher_group.go
new file mode 100644
index 00000000..6ef1d0ce
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/watcher_group.go
@@ -0,0 +1,283 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "math"
+
+ "github.com/coreos/etcd/mvcc/mvccpb"
+ "github.com/coreos/etcd/pkg/adt"
+)
+
+var (
+ // watchBatchMaxRevs is the maximum distinct revisions that
+ // may be sent to an unsynced watcher at a time. Declared as
+ // var instead of const for testing purposes.
+ watchBatchMaxRevs = 1000
+)
+
+type eventBatch struct {
+ // evs is a batch of revision-ordered events
+ evs []mvccpb.Event
+ // revs is the minimum unique revisions observed for this batch
+ revs int
+ // moreRev is first revision with more events following this batch
+ moreRev int64
+}
+
+func (eb *eventBatch) add(ev mvccpb.Event) {
+ if eb.revs > watchBatchMaxRevs {
+ // maxed out batch size
+ return
+ }
+
+ if len(eb.evs) == 0 {
+ // base case
+ eb.revs = 1
+ eb.evs = append(eb.evs, ev)
+ return
+ }
+
+ // revision accounting
+ ebRev := eb.evs[len(eb.evs)-1].Kv.ModRevision
+ evRev := ev.Kv.ModRevision
+ if evRev > ebRev {
+ eb.revs++
+ if eb.revs > watchBatchMaxRevs {
+ eb.moreRev = evRev
+ return
+ }
+ }
+
+ eb.evs = append(eb.evs, ev)
+}
+
+type watcherBatch map[*watcher]*eventBatch
+
+func (wb watcherBatch) add(w *watcher, ev mvccpb.Event) {
+ eb := wb[w]
+ if eb == nil {
+ eb = &eventBatch{}
+ wb[w] = eb
+ }
+ eb.add(ev)
+}
+
+// newWatcherBatch maps watchers to their matched events. It enables quick
+// events look up by watcher.
+func newWatcherBatch(wg *watcherGroup, evs []mvccpb.Event) watcherBatch {
+ if len(wg.watchers) == 0 {
+ return nil
+ }
+
+ wb := make(watcherBatch)
+ for _, ev := range evs {
+ for w := range wg.watcherSetByKey(string(ev.Kv.Key)) {
+ if ev.Kv.ModRevision >= w.minRev {
+ // don't double notify
+ wb.add(w, ev)
+ }
+ }
+ }
+ return wb
+}
+
+type watcherSet map[*watcher]struct{}
+
+func (w watcherSet) add(wa *watcher) {
+ if _, ok := w[wa]; ok {
+ panic("add watcher twice!")
+ }
+ w[wa] = struct{}{}
+}
+
+func (w watcherSet) union(ws watcherSet) {
+ for wa := range ws {
+ w.add(wa)
+ }
+}
+
+func (w watcherSet) delete(wa *watcher) {
+ if _, ok := w[wa]; !ok {
+ panic("removing missing watcher!")
+ }
+ delete(w, wa)
+}
+
+type watcherSetByKey map[string]watcherSet
+
+func (w watcherSetByKey) add(wa *watcher) {
+ set := w[string(wa.key)]
+ if set == nil {
+ set = make(watcherSet)
+ w[string(wa.key)] = set
+ }
+ set.add(wa)
+}
+
+func (w watcherSetByKey) delete(wa *watcher) bool {
+ k := string(wa.key)
+ if v, ok := w[k]; ok {
+ if _, ok := v[wa]; ok {
+ delete(v, wa)
+ if len(v) == 0 {
+ // remove the set; nothing left
+ delete(w, k)
+ }
+ return true
+ }
+ }
+ return false
+}
+
+// watcherGroup is a collection of watchers organized by their ranges
+type watcherGroup struct {
+ // keyWatchers has the watchers that watch on a single key
+ keyWatchers watcherSetByKey
+ // ranges has the watchers that watch a range; it is sorted by interval
+ ranges adt.IntervalTree
+ // watchers is the set of all watchers
+ watchers watcherSet
+}
+
+func newWatcherGroup() watcherGroup {
+ return watcherGroup{
+ keyWatchers: make(watcherSetByKey),
+ watchers: make(watcherSet),
+ }
+}
+
+// add puts a watcher in the group.
+func (wg *watcherGroup) add(wa *watcher) {
+ wg.watchers.add(wa)
+ if wa.end == nil {
+ wg.keyWatchers.add(wa)
+ return
+ }
+
+ // interval already registered?
+ ivl := adt.NewStringAffineInterval(string(wa.key), string(wa.end))
+ if iv := wg.ranges.Find(ivl); iv != nil {
+ iv.Val.(watcherSet).add(wa)
+ return
+ }
+
+ // not registered, put in interval tree
+ ws := make(watcherSet)
+ ws.add(wa)
+ wg.ranges.Insert(ivl, ws)
+}
+
+// contains is whether the given key has a watcher in the group.
+func (wg *watcherGroup) contains(key string) bool {
+ _, ok := wg.keyWatchers[key]
+ return ok || wg.ranges.Intersects(adt.NewStringAffinePoint(key))
+}
+
+// size gives the number of unique watchers in the group.
+func (wg *watcherGroup) size() int { return len(wg.watchers) }
+
+// delete removes a watcher from the group.
+func (wg *watcherGroup) delete(wa *watcher) bool {
+ if _, ok := wg.watchers[wa]; !ok {
+ return false
+ }
+ wg.watchers.delete(wa)
+ if wa.end == nil {
+ wg.keyWatchers.delete(wa)
+ return true
+ }
+
+ ivl := adt.NewStringAffineInterval(string(wa.key), string(wa.end))
+ iv := wg.ranges.Find(ivl)
+ if iv == nil {
+ return false
+ }
+
+ ws := iv.Val.(watcherSet)
+ delete(ws, wa)
+ if len(ws) == 0 {
+ // remove interval missing watchers
+ if ok := wg.ranges.Delete(ivl); !ok {
+ panic("could not remove watcher from interval tree")
+ }
+ }
+
+ return true
+}
+
+// choose selects watchers from the watcher group to update
+func (wg *watcherGroup) choose(maxWatchers int, curRev, compactRev int64) (*watcherGroup, int64) {
+ if len(wg.watchers) < maxWatchers {
+ return wg, wg.chooseAll(curRev, compactRev)
+ }
+ ret := newWatcherGroup()
+ for w := range wg.watchers {
+ if maxWatchers <= 0 {
+ break
+ }
+ maxWatchers--
+ ret.add(w)
+ }
+ return &ret, ret.chooseAll(curRev, compactRev)
+}
+
+func (wg *watcherGroup) chooseAll(curRev, compactRev int64) int64 {
+ minRev := int64(math.MaxInt64)
+ for w := range wg.watchers {
+ if w.minRev > curRev {
+ panic("watcher current revision should not exceed current revision")
+ }
+ if w.minRev < compactRev {
+ select {
+ case w.ch <- WatchResponse{WatchID: w.id, CompactRevision: compactRev}:
+ w.compacted = true
+ wg.delete(w)
+ default:
+ // retry next time
+ }
+ continue
+ }
+ if minRev > w.minRev {
+ minRev = w.minRev
+ }
+ }
+ return minRev
+}
+
+// watcherSetByKey gets the set of watchers that receive events on the given key.
+func (wg *watcherGroup) watcherSetByKey(key string) watcherSet {
+ wkeys := wg.keyWatchers[key]
+ wranges := wg.ranges.Stab(adt.NewStringAffinePoint(key))
+
+ // zero-copy cases
+ switch {
+ case len(wranges) == 0:
+ // no need to merge ranges or copy; reuse single-key set
+ return wkeys
+ case len(wranges) == 0 && len(wkeys) == 0:
+ return nil
+ case len(wranges) == 1 && len(wkeys) == 0:
+ return wranges[0].Val.(watcherSet)
+ }
+
+ // copy case
+ ret := make(watcherSet)
+ ret.union(wg.keyWatchers[key])
+ for _, item := range wranges {
+ ret.union(item.Val.(watcherSet))
+ }
+ return ret
+}
diff --git a/vendor/github.com/coreos/etcd/mvcc/watcher_test.go b/vendor/github.com/coreos/etcd/mvcc/watcher_test.go
new file mode 100644
index 00000000..3d259d1f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/mvcc/watcher_test.go
@@ -0,0 +1,344 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mvcc
+
+import (
+ "bytes"
+ "fmt"
+ "os"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+)
+
+// TestWatcherWatchID tests that each watcher provides unique watchID,
+// and the watched event attaches the correct watchID.
+func TestWatcherWatchID(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := WatchableKV(newWatchableStore(b, &lease.FakeLessor{}, nil))
+ defer cleanup(s, b, tmpPath)
+
+ w := s.NewWatchStream()
+ defer w.Close()
+
+ idm := make(map[WatchID]struct{})
+
+ for i := 0; i < 10; i++ {
+ id := w.Watch([]byte("foo"), nil, 0)
+ if _, ok := idm[id]; ok {
+ t.Errorf("#%d: id %d exists", i, id)
+ }
+ idm[id] = struct{}{}
+
+ s.Put([]byte("foo"), []byte("bar"), lease.NoLease)
+
+ resp := <-w.Chan()
+ if resp.WatchID != id {
+ t.Errorf("#%d: watch id in event = %d, want %d", i, resp.WatchID, id)
+ }
+
+ if err := w.Cancel(id); err != nil {
+ t.Error(err)
+ }
+ }
+
+ s.Put([]byte("foo2"), []byte("bar"), lease.NoLease)
+
+ // unsynced watchers
+ for i := 10; i < 20; i++ {
+ id := w.Watch([]byte("foo2"), nil, 1)
+ if _, ok := idm[id]; ok {
+ t.Errorf("#%d: id %d exists", i, id)
+ }
+ idm[id] = struct{}{}
+
+ resp := <-w.Chan()
+ if resp.WatchID != id {
+ t.Errorf("#%d: watch id in event = %d, want %d", i, resp.WatchID, id)
+ }
+
+ if err := w.Cancel(id); err != nil {
+ t.Error(err)
+ }
+ }
+}
+
+// TestWatcherWatchPrefix tests if Watch operation correctly watches
+// and returns events with matching prefixes.
+func TestWatcherWatchPrefix(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := WatchableKV(newWatchableStore(b, &lease.FakeLessor{}, nil))
+ defer cleanup(s, b, tmpPath)
+
+ w := s.NewWatchStream()
+ defer w.Close()
+
+ idm := make(map[WatchID]struct{})
+
+ val := []byte("bar")
+ keyWatch, keyEnd, keyPut := []byte("foo"), []byte("fop"), []byte("foobar")
+
+ for i := 0; i < 10; i++ {
+ id := w.Watch(keyWatch, keyEnd, 0)
+ if _, ok := idm[id]; ok {
+ t.Errorf("#%d: unexpected duplicated id %x", i, id)
+ }
+ idm[id] = struct{}{}
+
+ s.Put(keyPut, val, lease.NoLease)
+
+ resp := <-w.Chan()
+ if resp.WatchID != id {
+ t.Errorf("#%d: watch id in event = %d, want %d", i, resp.WatchID, id)
+ }
+
+ if err := w.Cancel(id); err != nil {
+ t.Errorf("#%d: unexpected cancel error %v", i, err)
+ }
+
+ if len(resp.Events) != 1 {
+ t.Errorf("#%d: len(resp.Events) got = %d, want = 1", i, len(resp.Events))
+ }
+ if len(resp.Events) == 1 {
+ if !bytes.Equal(resp.Events[0].Kv.Key, keyPut) {
+ t.Errorf("#%d: resp.Events got = %s, want = %s", i, resp.Events[0].Kv.Key, keyPut)
+ }
+ }
+ }
+
+ keyWatch1, keyEnd1, keyPut1 := []byte("foo1"), []byte("foo2"), []byte("foo1bar")
+ s.Put(keyPut1, val, lease.NoLease)
+
+ // unsynced watchers
+ for i := 10; i < 15; i++ {
+ id := w.Watch(keyWatch1, keyEnd1, 1)
+ if _, ok := idm[id]; ok {
+ t.Errorf("#%d: id %d exists", i, id)
+ }
+ idm[id] = struct{}{}
+
+ resp := <-w.Chan()
+ if resp.WatchID != id {
+ t.Errorf("#%d: watch id in event = %d, want %d", i, resp.WatchID, id)
+ }
+
+ if err := w.Cancel(id); err != nil {
+ t.Error(err)
+ }
+
+ if len(resp.Events) != 1 {
+ t.Errorf("#%d: len(resp.Events) got = %d, want = 1", i, len(resp.Events))
+ }
+ if len(resp.Events) == 1 {
+ if !bytes.Equal(resp.Events[0].Kv.Key, keyPut1) {
+ t.Errorf("#%d: resp.Events got = %s, want = %s", i, resp.Events[0].Kv.Key, keyPut1)
+ }
+ }
+ }
+}
+
+// TestWatcherWatchWrongRange ensures that watcher with wrong 'end' range
+// does not create watcher, which panics when canceling in range tree.
+func TestWatcherWatchWrongRange(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := WatchableKV(newWatchableStore(b, &lease.FakeLessor{}, nil))
+ defer cleanup(s, b, tmpPath)
+
+ w := s.NewWatchStream()
+ defer w.Close()
+
+ if id := w.Watch([]byte("foa"), []byte("foa"), 1); id != -1 {
+ t.Fatalf("key == end range given; id expected -1, got %d", id)
+ }
+ if id := w.Watch([]byte("fob"), []byte("foa"), 1); id != -1 {
+ t.Fatalf("key > end range given; id expected -1, got %d", id)
+ }
+ // watch request with 'WithFromKey' has empty-byte range end
+ if id := w.Watch([]byte("foo"), []byte{}, 1); id != 0 {
+ t.Fatalf("\x00 is range given; id expected 0, got %d", id)
+ }
+}
+
+func TestWatchDeleteRange(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := newWatchableStore(b, &lease.FakeLessor{}, nil)
+
+ defer func() {
+ s.store.Close()
+ os.Remove(tmpPath)
+ }()
+
+ testKeyPrefix := []byte("foo")
+
+ for i := 0; i < 3; i++ {
+ s.Put([]byte(fmt.Sprintf("%s_%d", testKeyPrefix, i)), []byte("bar"), lease.NoLease)
+ }
+
+ w := s.NewWatchStream()
+ from, to := []byte(testKeyPrefix), []byte(fmt.Sprintf("%s_%d", testKeyPrefix, 99))
+ w.Watch(from, to, 0)
+
+ s.DeleteRange(from, to)
+
+ we := []mvccpb.Event{
+ {Type: mvccpb.DELETE, Kv: &mvccpb.KeyValue{Key: []byte("foo_0"), ModRevision: 5}},
+ {Type: mvccpb.DELETE, Kv: &mvccpb.KeyValue{Key: []byte("foo_1"), ModRevision: 5}},
+ {Type: mvccpb.DELETE, Kv: &mvccpb.KeyValue{Key: []byte("foo_2"), ModRevision: 5}},
+ }
+
+ select {
+ case r := <-w.Chan():
+ if !reflect.DeepEqual(r.Events, we) {
+ t.Errorf("event = %v, want %v", r.Events, we)
+ }
+ case <-time.After(10 * time.Second):
+ t.Fatal("failed to receive event after 10 seconds!")
+ }
+}
+
+// TestWatchStreamCancelWatcherByID ensures cancel calls the cancel func of the watcher
+// with given id inside watchStream.
+func TestWatchStreamCancelWatcherByID(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := WatchableKV(newWatchableStore(b, &lease.FakeLessor{}, nil))
+ defer cleanup(s, b, tmpPath)
+
+ w := s.NewWatchStream()
+ defer w.Close()
+
+ id := w.Watch([]byte("foo"), nil, 0)
+
+ tests := []struct {
+ cancelID WatchID
+ werr error
+ }{
+ // no error should be returned when cancel the created watcher.
+ {id, nil},
+ // not exist error should be returned when cancel again.
+ {id, ErrWatcherNotExist},
+ // not exist error should be returned when cancel a bad id.
+ {id + 1, ErrWatcherNotExist},
+ }
+
+ for i, tt := range tests {
+ gerr := w.Cancel(tt.cancelID)
+
+ if gerr != tt.werr {
+ t.Errorf("#%d: err = %v, want %v", i, gerr, tt.werr)
+ }
+ }
+
+ if l := len(w.(*watchStream).cancels); l != 0 {
+ t.Errorf("cancels = %d, want 0", l)
+ }
+}
+
+// TestWatcherRequestProgress ensures synced watcher can correctly
+// report its correct progress.
+func TestWatcherRequestProgress(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+
+ // manually create watchableStore instead of newWatchableStore
+ // because newWatchableStore automatically calls syncWatchers
+ // method to sync watchers in unsynced map. We want to keep watchers
+ // in unsynced to test if syncWatchers works as expected.
+ s := &watchableStore{
+ store: NewStore(b, &lease.FakeLessor{}, nil),
+ unsynced: newWatcherGroup(),
+ synced: newWatcherGroup(),
+ }
+
+ defer func() {
+ s.store.Close()
+ os.Remove(tmpPath)
+ }()
+
+ testKey := []byte("foo")
+ notTestKey := []byte("bad")
+ testValue := []byte("bar")
+ s.Put(testKey, testValue, lease.NoLease)
+
+ w := s.NewWatchStream()
+
+ badID := WatchID(1000)
+ w.RequestProgress(badID)
+ select {
+ case resp := <-w.Chan():
+ t.Fatalf("unexpected %+v", resp)
+ default:
+ }
+
+ id := w.Watch(notTestKey, nil, 1)
+ w.RequestProgress(id)
+ select {
+ case resp := <-w.Chan():
+ t.Fatalf("unexpected %+v", resp)
+ default:
+ }
+
+ s.syncWatchers()
+
+ w.RequestProgress(id)
+ wrs := WatchResponse{WatchID: 0, Revision: 2}
+ select {
+ case resp := <-w.Chan():
+ if !reflect.DeepEqual(resp, wrs) {
+ t.Fatalf("got %+v, expect %+v", resp, wrs)
+ }
+ case <-time.After(time.Second):
+ t.Fatal("failed to receive progress")
+ }
+}
+
+func TestWatcherWatchWithFilter(t *testing.T) {
+ b, tmpPath := backend.NewDefaultTmpBackend()
+ s := WatchableKV(newWatchableStore(b, &lease.FakeLessor{}, nil))
+ defer cleanup(s, b, tmpPath)
+
+ w := s.NewWatchStream()
+ defer w.Close()
+
+ filterPut := func(e mvccpb.Event) bool {
+ return e.Type == mvccpb.PUT
+ }
+
+ w.Watch([]byte("foo"), nil, 0, filterPut)
+ done := make(chan struct{})
+
+ go func() {
+ <-w.Chan()
+ done <- struct{}{}
+ }()
+
+ s.Put([]byte("foo"), []byte("bar"), 0)
+
+ select {
+ case <-done:
+ t.Fatal("failed to filter put request")
+ case <-time.After(100 * time.Millisecond):
+ }
+
+ s.DeleteRange([]byte("foo"), nil)
+
+ select {
+ case <-done:
+ case <-time.After(100 * time.Millisecond):
+ t.Fatal("failed to receive delete request")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/README.md b/vendor/github.com/coreos/etcd/pkg/README.md
new file mode 100644
index 00000000..d7de4d33
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/README.md
@@ -0,0 +1,2 @@
+pkg/ is a collection of utility packages used by etcd without being specific to etcd itself. A package belongs here
+only if it could possibly be moved out into its own repository in the future.
diff --git a/vendor/github.com/coreos/etcd/pkg/adt/doc.go b/vendor/github.com/coreos/etcd/pkg/adt/doc.go
new file mode 100644
index 00000000..1a955914
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/adt/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 adt implements useful abstract data types.
+package adt
diff --git a/vendor/github.com/coreos/etcd/pkg/adt/example_test.go b/vendor/github.com/coreos/etcd/pkg/adt/example_test.go
new file mode 100644
index 00000000..caa5317c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/adt/example_test.go
@@ -0,0 +1,37 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 adt_test
+
+import (
+ "fmt"
+
+ "github.com/coreos/etcd/pkg/adt"
+)
+
+func Example() {
+ ivt := &adt.IntervalTree{}
+
+ ivt.Insert(adt.NewInt64Interval(1, 3), 123)
+ ivt.Insert(adt.NewInt64Interval(9, 13), 456)
+ ivt.Insert(adt.NewInt64Interval(7, 20), 789)
+
+ rs := ivt.Stab(adt.NewInt64Point(10))
+ for _, v := range rs {
+ fmt.Printf("Overlapping range: %+v\n", v)
+ }
+ // output:
+ // Overlapping range: &{Ivl:{Begin:7 End:20} Val:789}
+ // Overlapping range: &{Ivl:{Begin:9 End:13} Val:456}
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/adt/interval_tree.go b/vendor/github.com/coreos/etcd/pkg/adt/interval_tree.go
new file mode 100644
index 00000000..9769771e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/adt/interval_tree.go
@@ -0,0 +1,590 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 adt
+
+import (
+ "bytes"
+ "math"
+)
+
+// Comparable is an interface for trichotomic comparisons.
+type Comparable interface {
+ // Compare gives the result of a 3-way comparison
+ // a.Compare(b) = 1 => a > b
+ // a.Compare(b) = 0 => a == b
+ // a.Compare(b) = -1 => a < b
+ Compare(c Comparable) int
+}
+
+type rbcolor int
+
+const (
+ black rbcolor = iota
+ red
+)
+
+// Interval implements a Comparable interval [begin, end)
+// TODO: support different sorts of intervals: (a,b), [a,b], (a, b]
+type Interval struct {
+ Begin Comparable
+ End Comparable
+}
+
+// Compare on an interval gives == if the interval overlaps.
+func (ivl *Interval) Compare(c Comparable) int {
+ ivl2 := c.(*Interval)
+ ivbCmpBegin := ivl.Begin.Compare(ivl2.Begin)
+ ivbCmpEnd := ivl.Begin.Compare(ivl2.End)
+ iveCmpBegin := ivl.End.Compare(ivl2.Begin)
+
+ // ivl is left of ivl2
+ if ivbCmpBegin < 0 && iveCmpBegin <= 0 {
+ return -1
+ }
+
+ // iv is right of iv2
+ if ivbCmpEnd >= 0 {
+ return 1
+ }
+
+ return 0
+}
+
+type intervalNode struct {
+ // iv is the interval-value pair entry.
+ iv IntervalValue
+ // max endpoint of all descendent nodes.
+ max Comparable
+ // left and right are sorted by low endpoint of key interval
+ left, right *intervalNode
+ // parent is the direct ancestor of the node
+ parent *intervalNode
+ c rbcolor
+}
+
+func (x *intervalNode) color() rbcolor {
+ if x == nil {
+ return black
+ }
+ return x.c
+}
+
+func (n *intervalNode) height() int {
+ if n == nil {
+ return 0
+ }
+ ld := n.left.height()
+ rd := n.right.height()
+ if ld < rd {
+ return rd + 1
+ }
+ return ld + 1
+}
+
+func (x *intervalNode) min() *intervalNode {
+ for x.left != nil {
+ x = x.left
+ }
+ return x
+}
+
+// successor is the next in-order node in the tree
+func (x *intervalNode) successor() *intervalNode {
+ if x.right != nil {
+ return x.right.min()
+ }
+ y := x.parent
+ for y != nil && x == y.right {
+ x = y
+ y = y.parent
+ }
+ return y
+}
+
+// updateMax updates the maximum values for a node and its ancestors
+func (x *intervalNode) updateMax() {
+ for x != nil {
+ oldmax := x.max
+ max := x.iv.Ivl.End
+ if x.left != nil && x.left.max.Compare(max) > 0 {
+ max = x.left.max
+ }
+ if x.right != nil && x.right.max.Compare(max) > 0 {
+ max = x.right.max
+ }
+ if oldmax.Compare(max) == 0 {
+ break
+ }
+ x.max = max
+ x = x.parent
+ }
+}
+
+type nodeVisitor func(n *intervalNode) bool
+
+// visit will call a node visitor on each node that overlaps the given interval
+func (x *intervalNode) visit(iv *Interval, nv nodeVisitor) bool {
+ if x == nil {
+ return true
+ }
+ v := iv.Compare(&x.iv.Ivl)
+ switch {
+ case v < 0:
+ if !x.left.visit(iv, nv) {
+ return false
+ }
+ case v > 0:
+ maxiv := Interval{x.iv.Ivl.Begin, x.max}
+ if maxiv.Compare(iv) == 0 {
+ if !x.left.visit(iv, nv) || !x.right.visit(iv, nv) {
+ return false
+ }
+ }
+ default:
+ if !x.left.visit(iv, nv) || !nv(x) || !x.right.visit(iv, nv) {
+ return false
+ }
+ }
+ return true
+}
+
+type IntervalValue struct {
+ Ivl Interval
+ Val interface{}
+}
+
+// IntervalTree represents a (mostly) textbook implementation of the
+// "Introduction to Algorithms" (Cormen et al, 2nd ed.) chapter 13 red-black tree
+// and chapter 14.3 interval tree with search supporting "stabbing queries".
+type IntervalTree struct {
+ root *intervalNode
+ count int
+}
+
+// Delete removes the node with the given interval from the tree, returning
+// true if a node is in fact removed.
+func (ivt *IntervalTree) Delete(ivl Interval) bool {
+ z := ivt.find(ivl)
+ if z == nil {
+ return false
+ }
+
+ y := z
+ if z.left != nil && z.right != nil {
+ y = z.successor()
+ }
+
+ x := y.left
+ if x == nil {
+ x = y.right
+ }
+ if x != nil {
+ x.parent = y.parent
+ }
+
+ if y.parent == nil {
+ ivt.root = x
+ } else {
+ if y == y.parent.left {
+ y.parent.left = x
+ } else {
+ y.parent.right = x
+ }
+ y.parent.updateMax()
+ }
+ if y != z {
+ z.iv = y.iv
+ z.updateMax()
+ }
+
+ if y.color() == black && x != nil {
+ ivt.deleteFixup(x)
+ }
+
+ ivt.count--
+ return true
+}
+
+func (ivt *IntervalTree) deleteFixup(x *intervalNode) {
+ for x != ivt.root && x.color() == black && x.parent != nil {
+ if x == x.parent.left {
+ w := x.parent.right
+ if w.color() == red {
+ w.c = black
+ x.parent.c = red
+ ivt.rotateLeft(x.parent)
+ w = x.parent.right
+ }
+ if w == nil {
+ break
+ }
+ if w.left.color() == black && w.right.color() == black {
+ w.c = red
+ x = x.parent
+ } else {
+ if w.right.color() == black {
+ w.left.c = black
+ w.c = red
+ ivt.rotateRight(w)
+ w = x.parent.right
+ }
+ w.c = x.parent.color()
+ x.parent.c = black
+ w.right.c = black
+ ivt.rotateLeft(x.parent)
+ x = ivt.root
+ }
+ } else {
+ // same as above but with left and right exchanged
+ w := x.parent.left
+ if w.color() == red {
+ w.c = black
+ x.parent.c = red
+ ivt.rotateRight(x.parent)
+ w = x.parent.left
+ }
+ if w == nil {
+ break
+ }
+ if w.left.color() == black && w.right.color() == black {
+ w.c = red
+ x = x.parent
+ } else {
+ if w.left.color() == black {
+ w.right.c = black
+ w.c = red
+ ivt.rotateLeft(w)
+ w = x.parent.left
+ }
+ w.c = x.parent.color()
+ x.parent.c = black
+ w.left.c = black
+ ivt.rotateRight(x.parent)
+ x = ivt.root
+ }
+ }
+ }
+ if x != nil {
+ x.c = black
+ }
+}
+
+// Insert adds a node with the given interval into the tree.
+func (ivt *IntervalTree) Insert(ivl Interval, val interface{}) {
+ var y *intervalNode
+ z := &intervalNode{iv: IntervalValue{ivl, val}, max: ivl.End, c: red}
+ x := ivt.root
+ for x != nil {
+ y = x
+ if z.iv.Ivl.Begin.Compare(x.iv.Ivl.Begin) < 0 {
+ x = x.left
+ } else {
+ x = x.right
+ }
+ }
+
+ z.parent = y
+ if y == nil {
+ ivt.root = z
+ } else {
+ if z.iv.Ivl.Begin.Compare(y.iv.Ivl.Begin) < 0 {
+ y.left = z
+ } else {
+ y.right = z
+ }
+ y.updateMax()
+ }
+ z.c = red
+ ivt.insertFixup(z)
+ ivt.count++
+}
+
+func (ivt *IntervalTree) insertFixup(z *intervalNode) {
+ for z.parent != nil && z.parent.parent != nil && z.parent.color() == red {
+ if z.parent == z.parent.parent.left {
+ y := z.parent.parent.right
+ if y.color() == red {
+ y.c = black
+ z.parent.c = black
+ z.parent.parent.c = red
+ z = z.parent.parent
+ } else {
+ if z == z.parent.right {
+ z = z.parent
+ ivt.rotateLeft(z)
+ }
+ z.parent.c = black
+ z.parent.parent.c = red
+ ivt.rotateRight(z.parent.parent)
+ }
+ } else {
+ // same as then with left/right exchanged
+ y := z.parent.parent.left
+ if y.color() == red {
+ y.c = black
+ z.parent.c = black
+ z.parent.parent.c = red
+ z = z.parent.parent
+ } else {
+ if z == z.parent.left {
+ z = z.parent
+ ivt.rotateRight(z)
+ }
+ z.parent.c = black
+ z.parent.parent.c = red
+ ivt.rotateLeft(z.parent.parent)
+ }
+ }
+ }
+ ivt.root.c = black
+}
+
+// rotateLeft moves x so it is left of its right child
+func (ivt *IntervalTree) rotateLeft(x *intervalNode) {
+ y := x.right
+ x.right = y.left
+ if y.left != nil {
+ y.left.parent = x
+ }
+ x.updateMax()
+ ivt.replaceParent(x, y)
+ y.left = x
+ y.updateMax()
+}
+
+// rotateLeft moves x so it is right of its left child
+func (ivt *IntervalTree) rotateRight(x *intervalNode) {
+ if x == nil {
+ return
+ }
+ y := x.left
+ x.left = y.right
+ if y.right != nil {
+ y.right.parent = x
+ }
+ x.updateMax()
+ ivt.replaceParent(x, y)
+ y.right = x
+ y.updateMax()
+}
+
+// replaceParent replaces x's parent with y
+func (ivt *IntervalTree) replaceParent(x *intervalNode, y *intervalNode) {
+ y.parent = x.parent
+ if x.parent == nil {
+ ivt.root = y
+ } else {
+ if x == x.parent.left {
+ x.parent.left = y
+ } else {
+ x.parent.right = y
+ }
+ x.parent.updateMax()
+ }
+ x.parent = y
+}
+
+// Len gives the number of elements in the tree
+func (ivt *IntervalTree) Len() int { return ivt.count }
+
+// Height is the number of levels in the tree; one node has height 1.
+func (ivt *IntervalTree) Height() int { return ivt.root.height() }
+
+// MaxHeight is the expected maximum tree height given the number of nodes
+func (ivt *IntervalTree) MaxHeight() int {
+ return int((2 * math.Log2(float64(ivt.Len()+1))) + 0.5)
+}
+
+// IntervalVisitor is used on tree searches; return false to stop searching.
+type IntervalVisitor func(n *IntervalValue) bool
+
+// Visit calls a visitor function on every tree node intersecting the given interval.
+// It will visit each interval [x, y) in ascending order sorted on x.
+func (ivt *IntervalTree) Visit(ivl Interval, ivv IntervalVisitor) {
+ ivt.root.visit(&ivl, func(n *intervalNode) bool { return ivv(&n.iv) })
+}
+
+// find the exact node for a given interval
+func (ivt *IntervalTree) find(ivl Interval) (ret *intervalNode) {
+ f := func(n *intervalNode) bool {
+ if n.iv.Ivl != ivl {
+ return true
+ }
+ ret = n
+ return false
+ }
+ ivt.root.visit(&ivl, f)
+ return ret
+}
+
+// Find gets the IntervalValue for the node matching the given interval
+func (ivt *IntervalTree) Find(ivl Interval) (ret *IntervalValue) {
+ n := ivt.find(ivl)
+ if n == nil {
+ return nil
+ }
+ return &n.iv
+}
+
+// Intersects returns true if there is some tree node intersecting the given interval.
+func (ivt *IntervalTree) Intersects(iv Interval) bool {
+ x := ivt.root
+ for x != nil && iv.Compare(&x.iv.Ivl) != 0 {
+ if x.left != nil && x.left.max.Compare(iv.Begin) > 0 {
+ x = x.left
+ } else {
+ x = x.right
+ }
+ }
+ return x != nil
+}
+
+// Contains returns true if the interval tree's keys cover the entire given interval.
+func (ivt *IntervalTree) Contains(ivl Interval) bool {
+ var maxEnd, minBegin Comparable
+
+ isContiguous := true
+ ivt.Visit(ivl, func(n *IntervalValue) bool {
+ if minBegin == nil {
+ minBegin = n.Ivl.Begin
+ maxEnd = n.Ivl.End
+ return true
+ }
+ if maxEnd.Compare(n.Ivl.Begin) < 0 {
+ isContiguous = false
+ return false
+ }
+ if n.Ivl.End.Compare(maxEnd) > 0 {
+ maxEnd = n.Ivl.End
+ }
+ return true
+ })
+
+ return isContiguous && minBegin != nil && maxEnd.Compare(ivl.End) >= 0 && minBegin.Compare(ivl.Begin) <= 0
+}
+
+// Stab returns a slice with all elements in the tree intersecting the interval.
+func (ivt *IntervalTree) Stab(iv Interval) (ivs []*IntervalValue) {
+ if ivt.count == 0 {
+ return nil
+ }
+ f := func(n *IntervalValue) bool { ivs = append(ivs, n); return true }
+ ivt.Visit(iv, f)
+ return ivs
+}
+
+type StringComparable string
+
+func (s StringComparable) Compare(c Comparable) int {
+ sc := c.(StringComparable)
+ if s < sc {
+ return -1
+ }
+ if s > sc {
+ return 1
+ }
+ return 0
+}
+
+func NewStringInterval(begin, end string) Interval {
+ return Interval{StringComparable(begin), StringComparable(end)}
+}
+
+func NewStringPoint(s string) Interval {
+ return Interval{StringComparable(s), StringComparable(s + "\x00")}
+}
+
+// StringAffineComparable treats "" as > all other strings
+type StringAffineComparable string
+
+func (s StringAffineComparable) Compare(c Comparable) int {
+ sc := c.(StringAffineComparable)
+
+ if len(s) == 0 {
+ if len(sc) == 0 {
+ return 0
+ }
+ return 1
+ }
+ if len(sc) == 0 {
+ return -1
+ }
+
+ if s < sc {
+ return -1
+ }
+ if s > sc {
+ return 1
+ }
+ return 0
+}
+
+func NewStringAffineInterval(begin, end string) Interval {
+ return Interval{StringAffineComparable(begin), StringAffineComparable(end)}
+}
+func NewStringAffinePoint(s string) Interval {
+ return NewStringAffineInterval(s, s+"\x00")
+}
+
+func NewInt64Interval(a int64, b int64) Interval {
+ return Interval{Int64Comparable(a), Int64Comparable(b)}
+}
+
+func NewInt64Point(a int64) Interval {
+ return Interval{Int64Comparable(a), Int64Comparable(a + 1)}
+}
+
+type Int64Comparable int64
+
+func (v Int64Comparable) Compare(c Comparable) int {
+ vc := c.(Int64Comparable)
+ cmp := v - vc
+ if cmp < 0 {
+ return -1
+ }
+ if cmp > 0 {
+ return 1
+ }
+ return 0
+}
+
+// BytesAffineComparable treats empty byte arrays as > all other byte arrays
+type BytesAffineComparable []byte
+
+func (b BytesAffineComparable) Compare(c Comparable) int {
+ bc := c.(BytesAffineComparable)
+
+ if len(b) == 0 {
+ if len(bc) == 0 {
+ return 0
+ }
+ return 1
+ }
+ if len(bc) == 0 {
+ return -1
+ }
+
+ return bytes.Compare(b, bc)
+}
+
+func NewBytesAffineInterval(begin, end []byte) Interval {
+ return Interval{BytesAffineComparable(begin), BytesAffineComparable(end)}
+}
+func NewBytesAffinePoint(b []byte) Interval {
+ be := make([]byte, len(b)+1)
+ copy(be, b)
+ be[len(b)] = 0
+ return NewBytesAffineInterval(b, be)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/adt/interval_tree_test.go b/vendor/github.com/coreos/etcd/pkg/adt/interval_tree_test.go
new file mode 100644
index 00000000..493c11fa
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/adt/interval_tree_test.go
@@ -0,0 +1,295 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 adt
+
+import (
+ "math/rand"
+ "testing"
+ "time"
+)
+
+func TestIntervalTreeIntersects(t *testing.T) {
+ ivt := &IntervalTree{}
+ ivt.Insert(NewStringInterval("1", "3"), 123)
+
+ if ivt.Intersects(NewStringPoint("0")) {
+ t.Errorf("contains 0")
+ }
+ if !ivt.Intersects(NewStringPoint("1")) {
+ t.Errorf("missing 1")
+ }
+ if !ivt.Intersects(NewStringPoint("11")) {
+ t.Errorf("missing 11")
+ }
+ if !ivt.Intersects(NewStringPoint("2")) {
+ t.Errorf("missing 2")
+ }
+ if ivt.Intersects(NewStringPoint("3")) {
+ t.Errorf("contains 3")
+ }
+}
+
+func TestIntervalTreeStringAffine(t *testing.T) {
+ ivt := &IntervalTree{}
+ ivt.Insert(NewStringAffineInterval("8", ""), 123)
+ if !ivt.Intersects(NewStringAffinePoint("9")) {
+ t.Errorf("missing 9")
+ }
+ if ivt.Intersects(NewStringAffinePoint("7")) {
+ t.Errorf("contains 7")
+ }
+}
+
+func TestIntervalTreeStab(t *testing.T) {
+ ivt := &IntervalTree{}
+ ivt.Insert(NewStringInterval("0", "1"), 123)
+ ivt.Insert(NewStringInterval("0", "2"), 456)
+ ivt.Insert(NewStringInterval("5", "6"), 789)
+ ivt.Insert(NewStringInterval("6", "8"), 999)
+ ivt.Insert(NewStringInterval("0", "3"), 0)
+
+ if ivt.root.max.Compare(StringComparable("8")) != 0 {
+ t.Fatalf("wrong root max got %v, expected 8", ivt.root.max)
+ }
+ if x := len(ivt.Stab(NewStringPoint("0"))); x != 3 {
+ t.Errorf("got %d, expected 3", x)
+ }
+ if x := len(ivt.Stab(NewStringPoint("1"))); x != 2 {
+ t.Errorf("got %d, expected 2", x)
+ }
+ if x := len(ivt.Stab(NewStringPoint("2"))); x != 1 {
+ t.Errorf("got %d, expected 1", x)
+ }
+ if x := len(ivt.Stab(NewStringPoint("3"))); x != 0 {
+ t.Errorf("got %d, expected 0", x)
+ }
+ if x := len(ivt.Stab(NewStringPoint("5"))); x != 1 {
+ t.Errorf("got %d, expected 1", x)
+ }
+ if x := len(ivt.Stab(NewStringPoint("55"))); x != 1 {
+ t.Errorf("got %d, expected 1", x)
+ }
+ if x := len(ivt.Stab(NewStringPoint("6"))); x != 1 {
+ t.Errorf("got %d, expected 1", x)
+ }
+}
+
+type xy struct {
+ x int64
+ y int64
+}
+
+func TestIntervalTreeRandom(t *testing.T) {
+ // generate unique intervals
+ ivs := make(map[xy]struct{})
+ ivt := &IntervalTree{}
+ maxv := 128
+ rand.Seed(time.Now().UnixNano())
+
+ for i := rand.Intn(maxv) + 1; i != 0; i-- {
+ x, y := int64(rand.Intn(maxv)), int64(rand.Intn(maxv))
+ if x > y {
+ t := x
+ x = y
+ y = t
+ } else if x == y {
+ y++
+ }
+ iv := xy{x, y}
+ if _, ok := ivs[iv]; ok {
+ // don't double insert
+ continue
+ }
+ ivt.Insert(NewInt64Interval(x, y), 123)
+ ivs[iv] = struct{}{}
+ }
+
+ for ab := range ivs {
+ for xy := range ivs {
+ v := xy.x + int64(rand.Intn(int(xy.y-xy.x)))
+ if slen := len(ivt.Stab(NewInt64Point(v))); slen == 0 {
+ t.Fatalf("expected %v stab non-zero for [%+v)", v, xy)
+ }
+ if !ivt.Intersects(NewInt64Point(v)) {
+ t.Fatalf("did not get %d as expected for [%+v)", v, xy)
+ }
+ }
+ if !ivt.Delete(NewInt64Interval(ab.x, ab.y)) {
+ t.Errorf("did not delete %v as expected", ab)
+ }
+ delete(ivs, ab)
+ }
+
+ if ivt.Len() != 0 {
+ t.Errorf("got ivt.Len() = %v, expected 0", ivt.Len())
+ }
+}
+
+// TestIntervalTreeSortedVisit tests that intervals are visited in sorted order.
+func TestIntervalTreeSortedVisit(t *testing.T) {
+ tests := []struct {
+ ivls []Interval
+ visitRange Interval
+ }{
+ {
+ ivls: []Interval{NewInt64Interval(1, 10), NewInt64Interval(2, 5), NewInt64Interval(3, 6)},
+ visitRange: NewInt64Interval(0, 100),
+ },
+ {
+ ivls: []Interval{NewInt64Interval(1, 10), NewInt64Interval(10, 12), NewInt64Interval(3, 6)},
+ visitRange: NewInt64Interval(0, 100),
+ },
+ {
+ ivls: []Interval{NewInt64Interval(2, 3), NewInt64Interval(3, 4), NewInt64Interval(6, 7), NewInt64Interval(5, 6)},
+ visitRange: NewInt64Interval(0, 100),
+ },
+ {
+ ivls: []Interval{
+ NewInt64Interval(2, 3),
+ NewInt64Interval(2, 4),
+ NewInt64Interval(3, 7),
+ NewInt64Interval(2, 5),
+ NewInt64Interval(3, 8),
+ NewInt64Interval(3, 5),
+ },
+ visitRange: NewInt64Interval(0, 100),
+ },
+ }
+ for i, tt := range tests {
+ ivt := &IntervalTree{}
+ for _, ivl := range tt.ivls {
+ ivt.Insert(ivl, struct{}{})
+ }
+ last := tt.ivls[0].Begin
+ count := 0
+ chk := func(iv *IntervalValue) bool {
+ if last.Compare(iv.Ivl.Begin) > 0 {
+ t.Errorf("#%d: expected less than %d, got interval %+v", i, last, iv.Ivl)
+ }
+ last = iv.Ivl.Begin
+ count++
+ return true
+ }
+ ivt.Visit(tt.visitRange, chk)
+ if count != len(tt.ivls) {
+ t.Errorf("#%d: did not cover all intervals. expected %d, got %d", i, len(tt.ivls), count)
+ }
+ }
+}
+
+// TestIntervalTreeVisitExit tests that visiting can be stopped.
+func TestIntervalTreeVisitExit(t *testing.T) {
+ ivls := []Interval{NewInt64Interval(1, 10), NewInt64Interval(2, 5), NewInt64Interval(3, 6), NewInt64Interval(4, 8)}
+ ivlRange := NewInt64Interval(0, 100)
+ tests := []struct {
+ f IntervalVisitor
+
+ wcount int
+ }{
+ {
+ f: func(n *IntervalValue) bool { return false },
+ wcount: 1,
+ },
+ {
+ f: func(n *IntervalValue) bool { return n.Ivl.Begin.Compare(ivls[0].Begin) <= 0 },
+ wcount: 2,
+ },
+ {
+ f: func(n *IntervalValue) bool { return n.Ivl.Begin.Compare(ivls[2].Begin) < 0 },
+ wcount: 3,
+ },
+ {
+ f: func(n *IntervalValue) bool { return true },
+ wcount: 4,
+ },
+ }
+
+ for i, tt := range tests {
+ ivt := &IntervalTree{}
+ for _, ivl := range ivls {
+ ivt.Insert(ivl, struct{}{})
+ }
+ count := 0
+ ivt.Visit(ivlRange, func(n *IntervalValue) bool {
+ count++
+ return tt.f(n)
+ })
+ if count != tt.wcount {
+ t.Errorf("#%d: expected count %d, got %d", i, tt.wcount, count)
+ }
+ }
+}
+
+// TestIntervalTreeContains tests that contains returns true iff the ivt maps the entire interval.
+func TestIntervalTreeContains(t *testing.T) {
+ tests := []struct {
+ ivls []Interval
+ chkIvl Interval
+
+ wContains bool
+ }{
+ {
+ ivls: []Interval{NewInt64Interval(1, 10)},
+ chkIvl: NewInt64Interval(0, 100),
+
+ wContains: false,
+ },
+ {
+ ivls: []Interval{NewInt64Interval(1, 10)},
+ chkIvl: NewInt64Interval(1, 10),
+
+ wContains: true,
+ },
+ {
+ ivls: []Interval{NewInt64Interval(1, 10)},
+ chkIvl: NewInt64Interval(2, 8),
+
+ wContains: true,
+ },
+ {
+ ivls: []Interval{NewInt64Interval(1, 5), NewInt64Interval(6, 10)},
+ chkIvl: NewInt64Interval(1, 10),
+
+ wContains: false,
+ },
+ {
+ ivls: []Interval{NewInt64Interval(1, 5), NewInt64Interval(3, 10)},
+ chkIvl: NewInt64Interval(1, 10),
+
+ wContains: true,
+ },
+ {
+ ivls: []Interval{NewInt64Interval(1, 4), NewInt64Interval(4, 7), NewInt64Interval(3, 10)},
+ chkIvl: NewInt64Interval(1, 10),
+
+ wContains: true,
+ },
+ {
+ ivls: []Interval{},
+ chkIvl: NewInt64Interval(1, 10),
+
+ wContains: false,
+ },
+ }
+ for i, tt := range tests {
+ ivt := &IntervalTree{}
+ for _, ivl := range tt.ivls {
+ ivt.Insert(ivl, struct{}{})
+ }
+ if v := ivt.Contains(tt.chkIvl); v != tt.wContains {
+ t.Errorf("#%d: ivt.Contains got %v, expected %v", i, v, tt.wContains)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/contention/contention.go b/vendor/github.com/coreos/etcd/pkg/contention/contention.go
new file mode 100644
index 00000000..26ce9a2f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/contention/contention.go
@@ -0,0 +1,69 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 contention
+
+import (
+ "sync"
+ "time"
+)
+
+// TimeoutDetector detects routine starvations by
+// observing the actual time duration to finish an action
+// or between two events that should happen in a fixed
+// interval. If the observed duration is longer than
+// the expectation, the detector will report the result.
+type TimeoutDetector struct {
+ mu sync.Mutex // protects all
+ maxDuration time.Duration
+ // map from event to time
+ // time is the last seen time of the event.
+ records map[uint64]time.Time
+}
+
+// NewTimeoutDetector creates the TimeoutDetector.
+func NewTimeoutDetector(maxDuration time.Duration) *TimeoutDetector {
+ return &TimeoutDetector{
+ maxDuration: maxDuration,
+ records: make(map[uint64]time.Time),
+ }
+}
+
+// Reset resets the NewTimeoutDetector.
+func (td *TimeoutDetector) Reset() {
+ td.mu.Lock()
+ defer td.mu.Unlock()
+
+ td.records = make(map[uint64]time.Time)
+}
+
+// Observe observes an event for given id. It returns false and exceeded duration
+// if the interval is longer than the expectation.
+func (td *TimeoutDetector) Observe(which uint64) (bool, time.Duration) {
+ td.mu.Lock()
+ defer td.mu.Unlock()
+
+ ok := true
+ now := time.Now()
+ exceed := time.Duration(0)
+
+ if pt, found := td.records[which]; found {
+ exceed = now.Sub(pt) - td.maxDuration
+ if exceed > 0 {
+ ok = false
+ }
+ }
+ td.records[which] = now
+ return ok, exceed
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/contention/doc.go b/vendor/github.com/coreos/etcd/pkg/contention/doc.go
new file mode 100644
index 00000000..daf45221
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/contention/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 contention provides facilities for detecting system contention.
+package contention
diff --git a/vendor/github.com/coreos/etcd/pkg/cors/cors.go b/vendor/github.com/coreos/etcd/pkg/cors/cors.go
new file mode 100644
index 00000000..0c64f16a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/cors/cors.go
@@ -0,0 +1,90 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 cors handles cross-origin HTTP requests (CORS).
+package cors
+
+import (
+ "fmt"
+ "net/http"
+ "net/url"
+ "sort"
+ "strings"
+)
+
+type CORSInfo map[string]bool
+
+// Set implements the flag.Value interface to allow users to define a list of CORS origins
+func (ci *CORSInfo) Set(s string) error {
+ m := make(map[string]bool)
+ for _, v := range strings.Split(s, ",") {
+ v = strings.TrimSpace(v)
+ if v == "" {
+ continue
+ }
+ if v != "*" {
+ if _, err := url.Parse(v); err != nil {
+ return fmt.Errorf("Invalid CORS origin: %s", err)
+ }
+ }
+ m[v] = true
+
+ }
+ *ci = CORSInfo(m)
+ return nil
+}
+
+func (ci *CORSInfo) String() string {
+ o := make([]string, 0)
+ for k := range *ci {
+ o = append(o, k)
+ }
+ sort.StringSlice(o).Sort()
+ return strings.Join(o, ",")
+}
+
+// OriginAllowed determines whether the server will allow a given CORS origin.
+func (c CORSInfo) OriginAllowed(origin string) bool {
+ return c["*"] || c[origin]
+}
+
+type CORSHandler struct {
+ Handler http.Handler
+ Info *CORSInfo
+}
+
+// addHeader adds the correct cors headers given an origin
+func (h *CORSHandler) addHeader(w http.ResponseWriter, origin string) {
+ w.Header().Add("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
+ w.Header().Add("Access-Control-Allow-Origin", origin)
+ w.Header().Add("Access-Control-Allow-Headers", "accept, content-type, authorization")
+}
+
+// ServeHTTP adds the correct CORS headers based on the origin and returns immediately
+// with a 200 OK if the method is OPTIONS.
+func (h *CORSHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
+ // Write CORS header.
+ if h.Info.OriginAllowed("*") {
+ h.addHeader(w, "*")
+ } else if origin := req.Header.Get("Origin"); h.Info.OriginAllowed(origin) {
+ h.addHeader(w, origin)
+ }
+
+ if req.Method == "OPTIONS" {
+ w.WriteHeader(http.StatusOK)
+ return
+ }
+
+ h.Handler.ServeHTTP(w, req)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/cors/cors_test.go b/vendor/github.com/coreos/etcd/pkg/cors/cors_test.go
new file mode 100644
index 00000000..d36e9c0c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/cors/cors_test.go
@@ -0,0 +1,125 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 cors
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "reflect"
+ "testing"
+)
+
+func TestCORSInfo(t *testing.T) {
+ tests := []struct {
+ s string
+ winfo CORSInfo
+ ws string
+ }{
+ {"", CORSInfo{}, ""},
+ {"http://127.0.0.1", CORSInfo{"http://127.0.0.1": true}, "http://127.0.0.1"},
+ {"*", CORSInfo{"*": true}, "*"},
+ // with space around
+ {" http://127.0.0.1 ", CORSInfo{"http://127.0.0.1": true}, "http://127.0.0.1"},
+ // multiple addrs
+ {
+ "http://127.0.0.1,http://127.0.0.2",
+ CORSInfo{"http://127.0.0.1": true, "http://127.0.0.2": true},
+ "http://127.0.0.1,http://127.0.0.2",
+ },
+ }
+ for i, tt := range tests {
+ info := CORSInfo{}
+ if err := info.Set(tt.s); err != nil {
+ t.Errorf("#%d: set error = %v, want nil", i, err)
+ }
+ if !reflect.DeepEqual(info, tt.winfo) {
+ t.Errorf("#%d: info = %v, want %v", i, info, tt.winfo)
+ }
+ if g := info.String(); g != tt.ws {
+ t.Errorf("#%d: info string = %s, want %s", i, g, tt.ws)
+ }
+ }
+}
+
+func TestCORSInfoOriginAllowed(t *testing.T) {
+ tests := []struct {
+ set string
+ origin string
+ wallowed bool
+ }{
+ {"http://127.0.0.1,http://127.0.0.2", "http://127.0.0.1", true},
+ {"http://127.0.0.1,http://127.0.0.2", "http://127.0.0.2", true},
+ {"http://127.0.0.1,http://127.0.0.2", "*", false},
+ {"http://127.0.0.1,http://127.0.0.2", "http://127.0.0.3", false},
+ {"*", "*", true},
+ {"*", "http://127.0.0.1", true},
+ }
+ for i, tt := range tests {
+ info := CORSInfo{}
+ if err := info.Set(tt.set); err != nil {
+ t.Errorf("#%d: set error = %v, want nil", i, err)
+ }
+ if g := info.OriginAllowed(tt.origin); g != tt.wallowed {
+ t.Errorf("#%d: allowed = %v, want %v", i, g, tt.wallowed)
+ }
+ }
+}
+
+func TestCORSHandler(t *testing.T) {
+ info := &CORSInfo{}
+ if err := info.Set("http://127.0.0.1,http://127.0.0.2"); err != nil {
+ t.Fatalf("unexpected set error: %v", err)
+ }
+ h := &CORSHandler{
+ Handler: http.NotFoundHandler(),
+ Info: info,
+ }
+
+ header := func(origin string) http.Header {
+ return http.Header{
+ "Access-Control-Allow-Methods": []string{"POST, GET, OPTIONS, PUT, DELETE"},
+ "Access-Control-Allow-Origin": []string{origin},
+ "Access-Control-Allow-Headers": []string{"accept, content-type, authorization"},
+ }
+ }
+ tests := []struct {
+ method string
+ origin string
+ wcode int
+ wheader http.Header
+ }{
+ {"GET", "http://127.0.0.1", http.StatusNotFound, header("http://127.0.0.1")},
+ {"GET", "http://127.0.0.2", http.StatusNotFound, header("http://127.0.0.2")},
+ {"GET", "http://127.0.0.3", http.StatusNotFound, http.Header{}},
+ {"OPTIONS", "http://127.0.0.1", http.StatusOK, header("http://127.0.0.1")},
+ }
+ for i, tt := range tests {
+ rr := httptest.NewRecorder()
+ req := &http.Request{
+ Method: tt.method,
+ Header: http.Header{"Origin": []string{tt.origin}},
+ }
+ h.ServeHTTP(rr, req)
+ if rr.Code != tt.wcode {
+ t.Errorf("#%d: code = %v, want %v", i, rr.Code, tt.wcode)
+ }
+ // it is set by http package, and there is no need to test it
+ rr.HeaderMap.Del("Content-Type")
+ rr.HeaderMap.Del("X-Content-Type-Options")
+ if !reflect.DeepEqual(rr.HeaderMap, tt.wheader) {
+ t.Errorf("#%d: header = %+v, want %+v", i, rr.HeaderMap, tt.wheader)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/cpuutil/doc.go b/vendor/github.com/coreos/etcd/pkg/cpuutil/doc.go
new file mode 100644
index 00000000..0323b2d3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/cpuutil/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 cpuutil provides facilities for detecting cpu-specific features.
+package cpuutil
diff --git a/vendor/github.com/coreos/etcd/pkg/cpuutil/endian.go b/vendor/github.com/coreos/etcd/pkg/cpuutil/endian.go
new file mode 100644
index 00000000..6ab898d4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/cpuutil/endian.go
@@ -0,0 +1,36 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 cpuutil
+
+import (
+ "encoding/binary"
+ "unsafe"
+)
+
+const intWidth int = int(unsafe.Sizeof(0))
+
+var byteOrder binary.ByteOrder
+
+// ByteOrder returns the byte order for the CPU's native endianness.
+func ByteOrder() binary.ByteOrder { return byteOrder }
+
+func init() {
+ var i int = 0x1
+ if v := (*[intWidth]byte)(unsafe.Pointer(&i)); v[0] == 0 {
+ byteOrder = binary.BigEndian
+ } else {
+ byteOrder = binary.LittleEndian
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/crc/crc.go b/vendor/github.com/coreos/etcd/pkg/crc/crc.go
new file mode 100644
index 00000000..4b998a48
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/crc/crc.go
@@ -0,0 +1,43 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package crc provides utility function for cyclic redundancy check
+// algorithms.
+package crc
+
+import (
+ "hash"
+ "hash/crc32"
+)
+
+// The size of a CRC-32 checksum in bytes.
+const Size = 4
+
+type digest struct {
+ crc uint32
+ tab *crc32.Table
+}
+
+// New creates a new hash.Hash32 computing the CRC-32 checksum
+// using the polynomial represented by the Table.
+// Modified by xiangli to take a prevcrc.
+func New(prev uint32, tab *crc32.Table) hash.Hash32 { return &digest{prev, tab} }
+
+func (d *digest) Size() int { return Size }
+
+func (d *digest) BlockSize() int { return 1 }
+
+func (d *digest) Reset() { d.crc = 0 }
+
+func (d *digest) Write(p []byte) (n int, err error) {
+ d.crc = crc32.Update(d.crc, d.tab, p)
+ return len(p), nil
+}
+
+func (d *digest) Sum32() uint32 { return d.crc }
+
+func (d *digest) Sum(in []byte) []byte {
+ s := d.Sum32()
+ return append(in, byte(s>>24), byte(s>>16), byte(s>>8), byte(s))
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/crc/crc_test.go b/vendor/github.com/coreos/etcd/pkg/crc/crc_test.go
new file mode 100644
index 00000000..45759640
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/crc/crc_test.go
@@ -0,0 +1,59 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package crc
+
+import (
+ "hash/crc32"
+ "reflect"
+ "testing"
+)
+
+// TestHash32 tests that Hash32 provided by this package can take an initial
+// crc and behaves exactly the same as the standard one in the following calls.
+func TestHash32(t *testing.T) {
+ stdhash := crc32.New(crc32.IEEETable)
+ if _, err := stdhash.Write([]byte("test data")); err != nil {
+ t.Fatalf("unexpected write error: %v", err)
+ }
+ // create a new hash with stdhash.Sum32() as initial crc
+ hash := New(stdhash.Sum32(), crc32.IEEETable)
+
+ wsize := stdhash.Size()
+ if g := hash.Size(); g != wsize {
+ t.Errorf("size = %d, want %d", g, wsize)
+ }
+ wbsize := stdhash.BlockSize()
+ if g := hash.BlockSize(); g != wbsize {
+ t.Errorf("block size = %d, want %d", g, wbsize)
+ }
+ wsum32 := stdhash.Sum32()
+ if g := hash.Sum32(); g != wsum32 {
+ t.Errorf("Sum32 = %d, want %d", g, wsum32)
+ }
+ wsum := stdhash.Sum(make([]byte, 32))
+ if g := hash.Sum(make([]byte, 32)); !reflect.DeepEqual(g, wsum) {
+ t.Errorf("sum = %v, want %v", g, wsum)
+ }
+
+ // write something
+ if _, err := stdhash.Write([]byte("test data")); err != nil {
+ t.Fatalf("unexpected write error: %v", err)
+ }
+ if _, err := hash.Write([]byte("test data")); err != nil {
+ t.Fatalf("unexpected write error: %v", err)
+ }
+ wsum32 = stdhash.Sum32()
+ if g := hash.Sum32(); g != wsum32 {
+ t.Errorf("Sum32 after write = %d, want %d", g, wsum32)
+ }
+
+ // reset
+ stdhash.Reset()
+ hash.Reset()
+ wsum32 = stdhash.Sum32()
+ if g := hash.Sum32(); g != wsum32 {
+ t.Errorf("Sum32 after reset = %d, want %d", g, wsum32)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/debugutil/doc.go b/vendor/github.com/coreos/etcd/pkg/debugutil/doc.go
new file mode 100644
index 00000000..74499eb2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/debugutil/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 debugutil includes utility functions for debugging.
+package debugutil
diff --git a/vendor/github.com/coreos/etcd/pkg/debugutil/pprof.go b/vendor/github.com/coreos/etcd/pkg/debugutil/pprof.go
new file mode 100644
index 00000000..8d5544a3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/debugutil/pprof.go
@@ -0,0 +1,47 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 debugutil
+
+import (
+ "net/http"
+ "net/http/pprof"
+ "runtime"
+)
+
+const HTTPPrefixPProf = "/debug/pprof"
+
+// PProfHandlers returns a map of pprof handlers keyed by the HTTP path.
+func PProfHandlers() map[string]http.Handler {
+ // set only when there's no existing setting
+ if runtime.SetMutexProfileFraction(-1) == 0 {
+ // 1 out of 5 mutex events are reported, on average
+ runtime.SetMutexProfileFraction(5)
+ }
+
+ m := make(map[string]http.Handler)
+
+ m[HTTPPrefixPProf+"/"] = http.HandlerFunc(pprof.Index)
+ m[HTTPPrefixPProf+"/profile"] = http.HandlerFunc(pprof.Profile)
+ m[HTTPPrefixPProf+"/symbol"] = http.HandlerFunc(pprof.Symbol)
+ m[HTTPPrefixPProf+"/cmdline"] = http.HandlerFunc(pprof.Cmdline)
+ m[HTTPPrefixPProf+"/trace "] = http.HandlerFunc(pprof.Trace)
+ m[HTTPPrefixPProf+"/heap"] = pprof.Handler("heap")
+ m[HTTPPrefixPProf+"/goroutine"] = pprof.Handler("goroutine")
+ m[HTTPPrefixPProf+"/threadcreate"] = pprof.Handler("threadcreate")
+ m[HTTPPrefixPProf+"/block"] = pprof.Handler("block")
+ m[HTTPPrefixPProf+"/mutex"] = pprof.Handler("mutex")
+
+ return m
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/expect/expect.go b/vendor/github.com/coreos/etcd/pkg/expect/expect.go
new file mode 100644
index 00000000..fe27ef7f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/expect/expect.go
@@ -0,0 +1,174 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 expect implements a small expect-style interface
+package expect
+
+import (
+ "bufio"
+ "fmt"
+ "io"
+ "os"
+ "os/exec"
+ "strings"
+ "sync"
+ "syscall"
+
+ "github.com/kr/pty"
+)
+
+type ExpectProcess struct {
+ cmd *exec.Cmd
+ fpty *os.File
+ wg sync.WaitGroup
+
+ ptyMu sync.Mutex // protects accessing fpty
+ cond *sync.Cond // for broadcasting updates are available
+ mu sync.Mutex // protects lines and err
+ lines []string
+ count int // increment whenever new line gets added
+ err error
+
+ // StopSignal is the signal Stop sends to the process; defaults to SIGKILL.
+ StopSignal os.Signal
+}
+
+// NewExpect creates a new process for expect testing.
+func NewExpect(name string, arg ...string) (ep *ExpectProcess, err error) {
+ // if env[] is nil, use current system env
+ return NewExpectWithEnv(name, arg, nil)
+}
+
+// NewExpectWithEnv creates a new process with user defined env variables for expect testing.
+func NewExpectWithEnv(name string, args []string, env []string) (ep *ExpectProcess, err error) {
+ cmd := exec.Command(name, args...)
+ cmd.Env = env
+ ep = &ExpectProcess{
+ cmd: cmd,
+ StopSignal: syscall.SIGKILL,
+ }
+ ep.cond = sync.NewCond(&ep.mu)
+ ep.cmd.Stderr = ep.cmd.Stdout
+ ep.cmd.Stdin = nil
+
+ if ep.fpty, err = pty.Start(ep.cmd); err != nil {
+ return nil, err
+ }
+
+ ep.wg.Add(1)
+ go ep.read()
+ return ep, nil
+}
+
+func (ep *ExpectProcess) read() {
+ defer ep.wg.Done()
+ printDebugLines := os.Getenv("EXPECT_DEBUG") != ""
+ r := bufio.NewReader(ep.fpty)
+ for ep.err == nil {
+ ep.ptyMu.Lock()
+ l, rerr := r.ReadString('\n')
+ ep.ptyMu.Unlock()
+ ep.mu.Lock()
+ ep.err = rerr
+ if l != "" {
+ if printDebugLines {
+ fmt.Printf("%s-%d: %s", ep.cmd.Path, ep.cmd.Process.Pid, l)
+ }
+ ep.lines = append(ep.lines, l)
+ ep.count++
+ if len(ep.lines) == 1 {
+ ep.cond.Signal()
+ }
+ }
+ ep.mu.Unlock()
+ }
+ ep.cond.Signal()
+}
+
+// ExpectFunc returns the first line satisfying the function f.
+func (ep *ExpectProcess) ExpectFunc(f func(string) bool) (string, error) {
+ ep.mu.Lock()
+ for {
+ for len(ep.lines) == 0 && ep.err == nil {
+ ep.cond.Wait()
+ }
+ if len(ep.lines) == 0 {
+ break
+ }
+ l := ep.lines[0]
+ ep.lines = ep.lines[1:]
+ if f(l) {
+ ep.mu.Unlock()
+ return l, nil
+ }
+ }
+ ep.mu.Unlock()
+ return "", ep.err
+}
+
+// Expect returns the first line containing the given string.
+func (ep *ExpectProcess) Expect(s string) (string, error) {
+ return ep.ExpectFunc(func(txt string) bool { return strings.Contains(txt, s) })
+}
+
+// LineCount returns the number of recorded lines since
+// the beginning of the process.
+func (ep *ExpectProcess) LineCount() int {
+ ep.mu.Lock()
+ defer ep.mu.Unlock()
+ return ep.count
+}
+
+// Stop kills the expect process and waits for it to exit.
+func (ep *ExpectProcess) Stop() error { return ep.close(true) }
+
+// Signal sends a signal to the expect process
+func (ep *ExpectProcess) Signal(sig os.Signal) error {
+ return ep.cmd.Process.Signal(sig)
+}
+
+// Close waits for the expect process to exit.
+func (ep *ExpectProcess) Close() error { return ep.close(false) }
+
+func (ep *ExpectProcess) close(kill bool) error {
+ if ep.cmd == nil {
+ return ep.err
+ }
+ if kill {
+ ep.Signal(ep.StopSignal)
+ }
+
+ err := ep.cmd.Wait()
+ ep.ptyMu.Lock()
+ ep.fpty.Close()
+ ep.ptyMu.Unlock()
+ ep.wg.Wait()
+
+ if err != nil {
+ ep.err = err
+ if !kill && strings.Contains(err.Error(), "exit status") {
+ // non-zero exit code
+ err = nil
+ } else if kill && strings.Contains(err.Error(), "signal:") {
+ err = nil
+ }
+ }
+ ep.cmd = nil
+ return err
+}
+
+func (ep *ExpectProcess) Send(command string) error {
+ _, err := io.WriteString(ep.fpty, command)
+ return err
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/expect/expect_test.go b/vendor/github.com/coreos/etcd/pkg/expect/expect_test.go
new file mode 100644
index 00000000..d5cdaef5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/expect/expect_test.go
@@ -0,0 +1,120 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// build !windows
+
+package expect
+
+import (
+ "os"
+ "testing"
+ "time"
+)
+
+func TestExpectFunc(t *testing.T) {
+ ep, err := NewExpect("/bin/echo", "hello world")
+ if err != nil {
+ t.Fatal(err)
+ }
+ wstr := "hello world\r\n"
+ l, eerr := ep.ExpectFunc(func(a string) bool { return len(a) > 10 })
+ if eerr != nil {
+ t.Fatal(eerr)
+ }
+ if l != wstr {
+ t.Fatalf(`got "%v", expected "%v"`, l, wstr)
+ }
+ if cerr := ep.Close(); cerr != nil {
+ t.Fatal(cerr)
+ }
+}
+
+func TestEcho(t *testing.T) {
+ ep, err := NewExpect("/bin/echo", "hello world")
+ if err != nil {
+ t.Fatal(err)
+ }
+ l, eerr := ep.Expect("world")
+ if eerr != nil {
+ t.Fatal(eerr)
+ }
+ wstr := "hello world"
+ if l[:len(wstr)] != wstr {
+ t.Fatalf(`got "%v", expected "%v"`, l, wstr)
+ }
+ if cerr := ep.Close(); cerr != nil {
+ t.Fatal(cerr)
+ }
+ if _, eerr = ep.Expect("..."); eerr == nil {
+ t.Fatalf("expected error on closed expect process")
+ }
+}
+
+func TestLineCount(t *testing.T) {
+ ep, err := NewExpect("/usr/bin/printf", "1\n2\n3")
+ if err != nil {
+ t.Fatal(err)
+ }
+ wstr := "3"
+ l, eerr := ep.Expect(wstr)
+ if eerr != nil {
+ t.Fatal(eerr)
+ }
+ if l != wstr {
+ t.Fatalf(`got "%v", expected "%v"`, l, wstr)
+ }
+ if ep.LineCount() != 3 {
+ t.Fatalf("got %d, expected 3", ep.LineCount())
+ }
+ if cerr := ep.Close(); cerr != nil {
+ t.Fatal(cerr)
+ }
+}
+
+func TestSend(t *testing.T) {
+ ep, err := NewExpect("/usr/bin/tr", "a", "b")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := ep.Send("a\r"); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := ep.Expect("b"); err != nil {
+ t.Fatal(err)
+ }
+ if err := ep.Stop(); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestSignal(t *testing.T) {
+ ep, err := NewExpect("/bin/sleep", "100")
+ if err != nil {
+ t.Fatal(err)
+ }
+ ep.Signal(os.Interrupt)
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ werr := "signal: interrupt"
+ if cerr := ep.Close(); cerr == nil || cerr.Error() != werr {
+ t.Fatalf("got error %v, wanted error %s", cerr, werr)
+ }
+ }()
+ select {
+ case <-time.After(5 * time.Second):
+ t.Fatalf("signal test timed out")
+ case <-donec:
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/dir_unix.go b/vendor/github.com/coreos/etcd/pkg/fileutil/dir_unix.go
new file mode 100644
index 00000000..58a77dfc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/dir_unix.go
@@ -0,0 +1,22 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build !windows
+
+package fileutil
+
+import "os"
+
+// OpenDir opens a directory for syncing.
+func OpenDir(path string) (*os.File, error) { return os.Open(path) }
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/dir_windows.go b/vendor/github.com/coreos/etcd/pkg/fileutil/dir_windows.go
new file mode 100644
index 00000000..c123395c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/dir_windows.go
@@ -0,0 +1,46 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build windows
+
+package fileutil
+
+import (
+ "os"
+ "syscall"
+)
+
+// OpenDir opens a directory in windows with write access for syncing.
+func OpenDir(path string) (*os.File, error) {
+ fd, err := openDir(path)
+ if err != nil {
+ return nil, err
+ }
+ return os.NewFile(uintptr(fd), path), nil
+}
+
+func openDir(path string) (fd syscall.Handle, err error) {
+ if len(path) == 0 {
+ return syscall.InvalidHandle, syscall.ERROR_FILE_NOT_FOUND
+ }
+ pathp, err := syscall.UTF16PtrFromString(path)
+ if err != nil {
+ return syscall.InvalidHandle, err
+ }
+ access := uint32(syscall.GENERIC_READ | syscall.GENERIC_WRITE)
+ sharemode := uint32(syscall.FILE_SHARE_READ | syscall.FILE_SHARE_WRITE)
+ createmode := uint32(syscall.OPEN_EXISTING)
+ fl := uint32(syscall.FILE_FLAG_BACKUP_SEMANTICS)
+ return syscall.CreateFile(pathp, access, sharemode, nil, createmode, fl, 0)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/fileutil.go b/vendor/github.com/coreos/etcd/pkg/fileutil/fileutil.go
new file mode 100644
index 00000000..fce5126c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/fileutil.go
@@ -0,0 +1,122 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 fileutil implements utility functions related to files and paths.
+package fileutil
+
+import (
+ "fmt"
+ "io"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "sort"
+
+ "github.com/coreos/pkg/capnslog"
+)
+
+const (
+ // PrivateFileMode grants owner to read/write a file.
+ PrivateFileMode = 0600
+ // PrivateDirMode grants owner to make/remove files inside the directory.
+ PrivateDirMode = 0700
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "pkg/fileutil")
+)
+
+// IsDirWriteable checks if dir is writable by writing and removing a file
+// to dir. It returns nil if dir is writable.
+func IsDirWriteable(dir string) error {
+ f := filepath.Join(dir, ".touch")
+ if err := ioutil.WriteFile(f, []byte(""), PrivateFileMode); err != nil {
+ return err
+ }
+ return os.Remove(f)
+}
+
+// ReadDir returns the filenames in the given directory in sorted order.
+func ReadDir(dirpath string) ([]string, error) {
+ dir, err := os.Open(dirpath)
+ if err != nil {
+ return nil, err
+ }
+ defer dir.Close()
+ names, err := dir.Readdirnames(-1)
+ if err != nil {
+ return nil, err
+ }
+ sort.Strings(names)
+ return names, nil
+}
+
+// TouchDirAll is similar to os.MkdirAll. It creates directories with 0700 permission if any directory
+// does not exists. TouchDirAll also ensures the given directory is writable.
+func TouchDirAll(dir string) error {
+ // If path is already a directory, MkdirAll does nothing
+ // and returns nil.
+ err := os.MkdirAll(dir, PrivateDirMode)
+ if err != nil {
+ // if mkdirAll("a/text") and "text" is not
+ // a directory, this will return syscall.ENOTDIR
+ return err
+ }
+ return IsDirWriteable(dir)
+}
+
+// CreateDirAll is similar to TouchDirAll but returns error
+// if the deepest directory was not empty.
+func CreateDirAll(dir string) error {
+ err := TouchDirAll(dir)
+ if err == nil {
+ var ns []string
+ ns, err = ReadDir(dir)
+ if err != nil {
+ return err
+ }
+ if len(ns) != 0 {
+ err = fmt.Errorf("expected %q to be empty, got %q", dir, ns)
+ }
+ }
+ return err
+}
+
+func Exist(name string) bool {
+ _, err := os.Stat(name)
+ return err == nil
+}
+
+// ZeroToEnd zeros a file starting from SEEK_CUR to its SEEK_END. May temporarily
+// shorten the length of the file.
+func ZeroToEnd(f *os.File) error {
+ // TODO: support FALLOC_FL_ZERO_RANGE
+ off, err := f.Seek(0, io.SeekCurrent)
+ if err != nil {
+ return err
+ }
+ lenf, lerr := f.Seek(0, io.SeekEnd)
+ if lerr != nil {
+ return lerr
+ }
+ if err = f.Truncate(off); err != nil {
+ return err
+ }
+ // make sure blocks remain allocated
+ if err = Preallocate(f, lenf, true); err != nil {
+ return err
+ }
+ _, err = f.Seek(off, io.SeekStart)
+ return err
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/fileutil_test.go b/vendor/github.com/coreos/etcd/pkg/fileutil/fileutil_test.go
new file mode 100644
index 00000000..cde2f516
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/fileutil_test.go
@@ -0,0 +1,165 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 fileutil
+
+import (
+ "io"
+ "io/ioutil"
+ "os"
+ "os/user"
+ "path/filepath"
+ "reflect"
+ "runtime"
+ "strings"
+ "testing"
+)
+
+func TestIsDirWriteable(t *testing.T) {
+ tmpdir, err := ioutil.TempDir("", "")
+ if err != nil {
+ t.Fatalf("unexpected ioutil.TempDir error: %v", err)
+ }
+ defer os.RemoveAll(tmpdir)
+ if err = IsDirWriteable(tmpdir); err != nil {
+ t.Fatalf("unexpected IsDirWriteable error: %v", err)
+ }
+ if err = os.Chmod(tmpdir, 0444); err != nil {
+ t.Fatalf("unexpected os.Chmod error: %v", err)
+ }
+ me, err := user.Current()
+ if err != nil {
+ // err can be non-nil when cross compiled
+ // http://stackoverflow.com/questions/20609415/cross-compiling-user-current-not-implemented-on-linux-amd64
+ t.Skipf("failed to get current user: %v", err)
+ }
+ if me.Name == "root" || runtime.GOOS == "windows" {
+ // ideally we should check CAP_DAC_OVERRIDE.
+ // but it does not matter for tests.
+ // Chmod is not supported under windows.
+ t.Skipf("running as a superuser or in windows")
+ }
+ if err := IsDirWriteable(tmpdir); err == nil {
+ t.Fatalf("expected IsDirWriteable to error")
+ }
+}
+
+func TestReadDir(t *testing.T) {
+ tmpdir, err := ioutil.TempDir("", "")
+ defer os.RemoveAll(tmpdir)
+ if err != nil {
+ t.Fatalf("unexpected ioutil.TempDir error: %v", err)
+ }
+ files := []string{"def", "abc", "xyz", "ghi"}
+ for _, f := range files {
+ var fh *os.File
+ fh, err = os.Create(filepath.Join(tmpdir, f))
+ if err != nil {
+ t.Fatalf("error creating file: %v", err)
+ }
+ if err = fh.Close(); err != nil {
+ t.Fatalf("error closing file: %v", err)
+ }
+ }
+ fs, err := ReadDir(tmpdir)
+ if err != nil {
+ t.Fatalf("error calling ReadDir: %v", err)
+ }
+ wfs := []string{"abc", "def", "ghi", "xyz"}
+ if !reflect.DeepEqual(fs, wfs) {
+ t.Fatalf("ReadDir: got %v, want %v", fs, wfs)
+ }
+}
+
+func TestCreateDirAll(t *testing.T) {
+ tmpdir, err := ioutil.TempDir(os.TempDir(), "foo")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(tmpdir)
+
+ tmpdir2 := filepath.Join(tmpdir, "testdir")
+ if err = CreateDirAll(tmpdir2); err != nil {
+ t.Fatal(err)
+ }
+
+ if err = ioutil.WriteFile(filepath.Join(tmpdir2, "text.txt"), []byte("test text"), PrivateFileMode); err != nil {
+ t.Fatal(err)
+ }
+
+ if err = CreateDirAll(tmpdir2); err == nil || !strings.Contains(err.Error(), "to be empty, got") {
+ t.Fatalf("unexpected error %v", err)
+ }
+}
+
+func TestExist(t *testing.T) {
+ f, err := ioutil.TempFile(os.TempDir(), "fileutil")
+ if err != nil {
+ t.Fatal(err)
+ }
+ f.Close()
+
+ if g := Exist(f.Name()); !g {
+ t.Errorf("exist = %v, want true", g)
+ }
+
+ os.Remove(f.Name())
+ if g := Exist(f.Name()); g {
+ t.Errorf("exist = %v, want false", g)
+ }
+}
+
+func TestZeroToEnd(t *testing.T) {
+ f, err := ioutil.TempFile(os.TempDir(), "fileutil")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer f.Close()
+
+ // Ensure 0 size is a nop so zero-to-end on an empty file won't give EINVAL.
+ if err = ZeroToEnd(f); err != nil {
+ t.Fatal(err)
+ }
+
+ b := make([]byte, 1024)
+ for i := range b {
+ b[i] = 12
+ }
+ if _, err = f.Write(b); err != nil {
+ t.Fatal(err)
+ }
+ if _, err = f.Seek(512, io.SeekStart); err != nil {
+ t.Fatal(err)
+ }
+ if err = ZeroToEnd(f); err != nil {
+ t.Fatal(err)
+ }
+ off, serr := f.Seek(0, io.SeekCurrent)
+ if serr != nil {
+ t.Fatal(serr)
+ }
+ if off != 512 {
+ t.Fatalf("expected offset 512, got %d", off)
+ }
+
+ b = make([]byte, 512)
+ if _, err = f.Read(b); err != nil {
+ t.Fatal(err)
+ }
+ for i := range b {
+ if b[i] != 0 {
+ t.Errorf("expected b[%d] = 0, got %d", i, b[i])
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/lock.go b/vendor/github.com/coreos/etcd/pkg/fileutil/lock.go
new file mode 100644
index 00000000..338627f4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/lock.go
@@ -0,0 +1,26 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 fileutil
+
+import (
+ "errors"
+ "os"
+)
+
+var (
+ ErrLocked = errors.New("fileutil: file already locked")
+)
+
+type LockedFile struct{ *os.File }
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/lock_flock.go b/vendor/github.com/coreos/etcd/pkg/fileutil/lock_flock.go
new file mode 100644
index 00000000..542550bc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/lock_flock.go
@@ -0,0 +1,49 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build !windows,!plan9,!solaris
+
+package fileutil
+
+import (
+ "os"
+ "syscall"
+)
+
+func flockTryLockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
+ f, err := os.OpenFile(path, flag, perm)
+ if err != nil {
+ return nil, err
+ }
+ if err = syscall.Flock(int(f.Fd()), syscall.LOCK_EX|syscall.LOCK_NB); err != nil {
+ f.Close()
+ if err == syscall.EWOULDBLOCK {
+ err = ErrLocked
+ }
+ return nil, err
+ }
+ return &LockedFile{f}, nil
+}
+
+func flockLockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
+ f, err := os.OpenFile(path, flag, perm)
+ if err != nil {
+ return nil, err
+ }
+ if err = syscall.Flock(int(f.Fd()), syscall.LOCK_EX); err != nil {
+ f.Close()
+ return nil, err
+ }
+ return &LockedFile{f}, err
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/lock_linux.go b/vendor/github.com/coreos/etcd/pkg/fileutil/lock_linux.go
new file mode 100644
index 00000000..939fea62
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/lock_linux.go
@@ -0,0 +1,97 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build linux
+
+package fileutil
+
+import (
+ "io"
+ "os"
+ "syscall"
+)
+
+// This used to call syscall.Flock() but that call fails with EBADF on NFS.
+// An alternative is lockf() which works on NFS but that call lets a process lock
+// the same file twice. Instead, use Linux's non-standard open file descriptor
+// locks which will block if the process already holds the file lock.
+//
+// constants from /usr/include/bits/fcntl-linux.h
+const (
+ F_OFD_GETLK = 37
+ F_OFD_SETLK = 37
+ F_OFD_SETLKW = 38
+)
+
+var (
+ wrlck = syscall.Flock_t{
+ Type: syscall.F_WRLCK,
+ Whence: int16(io.SeekStart),
+ Start: 0,
+ Len: 0,
+ }
+
+ linuxTryLockFile = flockTryLockFile
+ linuxLockFile = flockLockFile
+)
+
+func init() {
+ // use open file descriptor locks if the system supports it
+ getlk := syscall.Flock_t{Type: syscall.F_RDLCK}
+ if err := syscall.FcntlFlock(0, F_OFD_GETLK, &getlk); err == nil {
+ linuxTryLockFile = ofdTryLockFile
+ linuxLockFile = ofdLockFile
+ }
+}
+
+func TryLockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
+ return linuxTryLockFile(path, flag, perm)
+}
+
+func ofdTryLockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
+ f, err := os.OpenFile(path, flag, perm)
+ if err != nil {
+ return nil, err
+ }
+
+ flock := wrlck
+ if err = syscall.FcntlFlock(f.Fd(), F_OFD_SETLK, &flock); err != nil {
+ f.Close()
+ if err == syscall.EWOULDBLOCK {
+ err = ErrLocked
+ }
+ return nil, err
+ }
+ return &LockedFile{f}, nil
+}
+
+func LockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
+ return linuxLockFile(path, flag, perm)
+}
+
+func ofdLockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
+ f, err := os.OpenFile(path, flag, perm)
+ if err != nil {
+ return nil, err
+ }
+
+ flock := wrlck
+ err = syscall.FcntlFlock(f.Fd(), F_OFD_SETLKW, &flock)
+
+ if err != nil {
+ f.Close()
+ return nil, err
+ }
+ return &LockedFile{f}, err
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/lock_plan9.go b/vendor/github.com/coreos/etcd/pkg/fileutil/lock_plan9.go
new file mode 100644
index 00000000..fee6a7c8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/lock_plan9.go
@@ -0,0 +1,45 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 fileutil
+
+import (
+ "os"
+ "syscall"
+ "time"
+)
+
+func TryLockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
+ if err := os.Chmod(path, syscall.DMEXCL|PrivateFileMode); err != nil {
+ return nil, err
+ }
+ f, err := os.Open(path, flag, perm)
+ if err != nil {
+ return nil, ErrLocked
+ }
+ return &LockedFile{f}, nil
+}
+
+func LockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
+ if err := os.Chmod(path, syscall.DMEXCL|PrivateFileMode); err != nil {
+ return nil, err
+ }
+ for {
+ f, err := os.OpenFile(path, flag, perm)
+ if err == nil {
+ return &LockedFile{f}, nil
+ }
+ time.Sleep(10 * time.Millisecond)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/lock_solaris.go b/vendor/github.com/coreos/etcd/pkg/fileutil/lock_solaris.go
new file mode 100644
index 00000000..352ca559
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/lock_solaris.go
@@ -0,0 +1,62 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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.
+
+// +build solaris
+
+package fileutil
+
+import (
+ "os"
+ "syscall"
+)
+
+func TryLockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
+ var lock syscall.Flock_t
+ lock.Start = 0
+ lock.Len = 0
+ lock.Pid = 0
+ lock.Type = syscall.F_WRLCK
+ lock.Whence = 0
+ lock.Pid = 0
+ f, err := os.OpenFile(path, flag, perm)
+ if err != nil {
+ return nil, err
+ }
+ if err := syscall.FcntlFlock(f.Fd(), syscall.F_SETLK, &lock); err != nil {
+ f.Close()
+ if err == syscall.EAGAIN {
+ err = ErrLocked
+ }
+ return nil, err
+ }
+ return &LockedFile{f}, nil
+}
+
+func LockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
+ var lock syscall.Flock_t
+ lock.Start = 0
+ lock.Len = 0
+ lock.Pid = 0
+ lock.Type = syscall.F_WRLCK
+ lock.Whence = 0
+ f, err := os.OpenFile(path, flag, perm)
+ if err != nil {
+ return nil, err
+ }
+ if err = syscall.FcntlFlock(f.Fd(), syscall.F_SETLKW, &lock); err != nil {
+ f.Close()
+ return nil, err
+ }
+ return &LockedFile{f}, nil
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/lock_test.go b/vendor/github.com/coreos/etcd/pkg/fileutil/lock_test.go
new file mode 100644
index 00000000..7c1dd864
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/lock_test.go
@@ -0,0 +1,89 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 fileutil
+
+import (
+ "io/ioutil"
+ "os"
+ "testing"
+ "time"
+)
+
+func TestLockAndUnlock(t *testing.T) {
+ f, err := ioutil.TempFile("", "lock")
+ if err != nil {
+ t.Fatal(err)
+ }
+ f.Close()
+ defer func() {
+ err = os.Remove(f.Name())
+ if err != nil {
+ t.Fatal(err)
+ }
+ }()
+
+ // lock the file
+ l, err := LockFile(f.Name(), os.O_WRONLY, PrivateFileMode)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // try lock a locked file
+ if _, err = TryLockFile(f.Name(), os.O_WRONLY, PrivateFileMode); err != ErrLocked {
+ t.Fatal(err)
+ }
+
+ // unlock the file
+ if err = l.Close(); err != nil {
+ t.Fatal(err)
+ }
+
+ // try lock the unlocked file
+ dupl, err := TryLockFile(f.Name(), os.O_WRONLY, PrivateFileMode)
+ if err != nil {
+ t.Errorf("err = %v, want %v", err, nil)
+ }
+
+ // blocking on locked file
+ locked := make(chan struct{}, 1)
+ go func() {
+ bl, blerr := LockFile(f.Name(), os.O_WRONLY, PrivateFileMode)
+ if blerr != nil {
+ t.Fatal(blerr)
+ }
+ locked <- struct{}{}
+ if blerr = bl.Close(); blerr != nil {
+ t.Fatal(blerr)
+ }
+ }()
+
+ select {
+ case <-locked:
+ t.Error("unexpected unblocking")
+ case <-time.After(100 * time.Millisecond):
+ }
+
+ // unlock
+ if err = dupl.Close(); err != nil {
+ t.Fatal(err)
+ }
+
+ // the previously blocked routine should be unblocked
+ select {
+ case <-locked:
+ case <-time.After(1 * time.Second):
+ t.Error("unexpected blocking")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/lock_unix.go b/vendor/github.com/coreos/etcd/pkg/fileutil/lock_unix.go
new file mode 100644
index 00000000..ed01164d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/lock_unix.go
@@ -0,0 +1,29 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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.
+
+// +build !windows,!plan9,!solaris,!linux
+
+package fileutil
+
+import (
+ "os"
+)
+
+func TryLockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
+ return flockTryLockFile(path, flag, perm)
+}
+
+func LockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
+ return flockLockFile(path, flag, perm)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/lock_windows.go b/vendor/github.com/coreos/etcd/pkg/fileutil/lock_windows.go
new file mode 100644
index 00000000..8698f4a8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/lock_windows.go
@@ -0,0 +1,125 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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.
+
+// +build windows
+
+package fileutil
+
+import (
+ "errors"
+ "fmt"
+ "os"
+ "syscall"
+ "unsafe"
+)
+
+var (
+ modkernel32 = syscall.NewLazyDLL("kernel32.dll")
+ procLockFileEx = modkernel32.NewProc("LockFileEx")
+
+ errLocked = errors.New("The process cannot access the file because another process has locked a portion of the file.")
+)
+
+const (
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365203(v=vs.85).aspx
+ LOCKFILE_EXCLUSIVE_LOCK = 2
+ LOCKFILE_FAIL_IMMEDIATELY = 1
+
+ // see https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx
+ errLockViolation syscall.Errno = 0x21
+)
+
+func TryLockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
+ f, err := open(path, flag, perm)
+ if err != nil {
+ return nil, err
+ }
+ if err := lockFile(syscall.Handle(f.Fd()), LOCKFILE_FAIL_IMMEDIATELY); err != nil {
+ f.Close()
+ return nil, err
+ }
+ return &LockedFile{f}, nil
+}
+
+func LockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
+ f, err := open(path, flag, perm)
+ if err != nil {
+ return nil, err
+ }
+ if err := lockFile(syscall.Handle(f.Fd()), 0); err != nil {
+ f.Close()
+ return nil, err
+ }
+ return &LockedFile{f}, nil
+}
+
+func open(path string, flag int, perm os.FileMode) (*os.File, error) {
+ if path == "" {
+ return nil, fmt.Errorf("cannot open empty filename")
+ }
+ var access uint32
+ switch flag {
+ case syscall.O_RDONLY:
+ access = syscall.GENERIC_READ
+ case syscall.O_WRONLY:
+ access = syscall.GENERIC_WRITE
+ case syscall.O_RDWR:
+ access = syscall.GENERIC_READ | syscall.GENERIC_WRITE
+ case syscall.O_WRONLY | syscall.O_CREAT:
+ access = syscall.GENERIC_ALL
+ default:
+ panic(fmt.Errorf("flag %v is not supported", flag))
+ }
+ fd, err := syscall.CreateFile(&(syscall.StringToUTF16(path)[0]),
+ access,
+ syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE,
+ nil,
+ syscall.OPEN_ALWAYS,
+ syscall.FILE_ATTRIBUTE_NORMAL,
+ 0)
+ if err != nil {
+ return nil, err
+ }
+ return os.NewFile(uintptr(fd), path), nil
+}
+
+func lockFile(fd syscall.Handle, flags uint32) error {
+ var flag uint32 = LOCKFILE_EXCLUSIVE_LOCK
+ flag |= flags
+ if fd == syscall.InvalidHandle {
+ return nil
+ }
+ err := lockFileEx(fd, flag, 1, 0, &syscall.Overlapped{})
+ if err == nil {
+ return nil
+ } else if err.Error() == errLocked.Error() {
+ return ErrLocked
+ } else if err != errLockViolation {
+ return err
+ }
+ return nil
+}
+
+func lockFileEx(h syscall.Handle, flags, locklow, lockhigh uint32, ol *syscall.Overlapped) (err error) {
+ var reserved uint32 = 0
+ r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(h), uintptr(flags), uintptr(reserved), uintptr(locklow), uintptr(lockhigh), uintptr(unsafe.Pointer(ol)))
+ if r1 == 0 {
+ if e1 != 0 {
+ err = error(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate.go b/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate.go
new file mode 100644
index 00000000..c747b7cf
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate.go
@@ -0,0 +1,54 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 fileutil
+
+import (
+ "io"
+ "os"
+)
+
+// Preallocate tries to allocate the space for given
+// file. This operation is only supported on linux by a
+// few filesystems (btrfs, ext4, etc.).
+// If the operation is unsupported, no error will be returned.
+// Otherwise, the error encountered will be returned.
+func Preallocate(f *os.File, sizeInBytes int64, extendFile bool) error {
+ if sizeInBytes == 0 {
+ // fallocate will return EINVAL if length is 0; skip
+ return nil
+ }
+ if extendFile {
+ return preallocExtend(f, sizeInBytes)
+ }
+ return preallocFixed(f, sizeInBytes)
+}
+
+func preallocExtendTrunc(f *os.File, sizeInBytes int64) error {
+ curOff, err := f.Seek(0, io.SeekCurrent)
+ if err != nil {
+ return err
+ }
+ size, err := f.Seek(sizeInBytes, io.SeekEnd)
+ if err != nil {
+ return err
+ }
+ if _, err = f.Seek(curOff, io.SeekStart); err != nil {
+ return err
+ }
+ if sizeInBytes > size {
+ return nil
+ }
+ return f.Truncate(sizeInBytes)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate_darwin.go b/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate_darwin.go
new file mode 100644
index 00000000..1ed09c56
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate_darwin.go
@@ -0,0 +1,43 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build darwin
+
+package fileutil
+
+import (
+ "os"
+ "syscall"
+ "unsafe"
+)
+
+func preallocExtend(f *os.File, sizeInBytes int64) error {
+ if err := preallocFixed(f, sizeInBytes); err != nil {
+ return err
+ }
+ return preallocExtendTrunc(f, sizeInBytes)
+}
+
+func preallocFixed(f *os.File, sizeInBytes int64) error {
+ fstore := &syscall.Fstore_t{
+ Flags: syscall.F_ALLOCATEALL,
+ Posmode: syscall.F_PEOFPOSMODE,
+ Length: sizeInBytes}
+ p := unsafe.Pointer(fstore)
+ _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.Fd(), uintptr(syscall.F_PREALLOCATE), uintptr(p))
+ if errno == 0 || errno == syscall.ENOTSUP {
+ return nil
+ }
+ return errno
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate_test.go b/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate_test.go
new file mode 100644
index 00000000..c6a357c5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate_test.go
@@ -0,0 +1,67 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 fileutil
+
+import (
+ "io/ioutil"
+ "os"
+ "testing"
+)
+
+func TestPreallocateExtend(t *testing.T) { runPreallocTest(t, testPreallocateExtend) }
+func testPreallocateExtend(t *testing.T, f *os.File) {
+ size := int64(64 * 1000)
+ if err := Preallocate(f, size, true); err != nil {
+ t.Fatal(err)
+ }
+
+ stat, err := f.Stat()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if stat.Size() != size {
+ t.Errorf("size = %d, want %d", stat.Size(), size)
+ }
+}
+
+func TestPreallocateFixed(t *testing.T) { runPreallocTest(t, testPreallocateFixed) }
+func testPreallocateFixed(t *testing.T, f *os.File) {
+ size := int64(64 * 1000)
+ if err := Preallocate(f, size, false); err != nil {
+ t.Fatal(err)
+ }
+
+ stat, err := f.Stat()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if stat.Size() != 0 {
+ t.Errorf("size = %d, want %d", stat.Size(), 0)
+ }
+}
+
+func runPreallocTest(t *testing.T, test func(*testing.T, *os.File)) {
+ p, err := ioutil.TempDir(os.TempDir(), "preallocateTest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+
+ f, err := ioutil.TempFile(p, "")
+ if err != nil {
+ t.Fatal(err)
+ }
+ test(t, f)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate_unix.go b/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate_unix.go
new file mode 100644
index 00000000..50bd84f0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate_unix.go
@@ -0,0 +1,49 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build linux
+
+package fileutil
+
+import (
+ "os"
+ "syscall"
+)
+
+func preallocExtend(f *os.File, sizeInBytes int64) error {
+ // use mode = 0 to change size
+ err := syscall.Fallocate(int(f.Fd()), 0, 0, sizeInBytes)
+ if err != nil {
+ errno, ok := err.(syscall.Errno)
+ // not supported; fallback
+ // fallocate EINTRs frequently in some environments; fallback
+ if ok && (errno == syscall.ENOTSUP || errno == syscall.EINTR) {
+ return preallocExtendTrunc(f, sizeInBytes)
+ }
+ }
+ return err
+}
+
+func preallocFixed(f *os.File, sizeInBytes int64) error {
+ // use mode = 1 to keep size; see FALLOC_FL_KEEP_SIZE
+ err := syscall.Fallocate(int(f.Fd()), 1, 0, sizeInBytes)
+ if err != nil {
+ errno, ok := err.(syscall.Errno)
+ // treat not supported as nil error
+ if ok && errno == syscall.ENOTSUP {
+ return nil
+ }
+ }
+ return err
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate_unsupported.go b/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate_unsupported.go
new file mode 100644
index 00000000..162fbc5f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/preallocate_unsupported.go
@@ -0,0 +1,25 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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.
+
+// +build !linux,!darwin
+
+package fileutil
+
+import "os"
+
+func preallocExtend(f *os.File, sizeInBytes int64) error {
+ return preallocExtendTrunc(f, sizeInBytes)
+}
+
+func preallocFixed(f *os.File, sizeInBytes int64) error { return nil }
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/purge.go b/vendor/github.com/coreos/etcd/pkg/fileutil/purge.go
new file mode 100644
index 00000000..92fceab0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/purge.go
@@ -0,0 +1,78 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 fileutil
+
+import (
+ "os"
+ "path/filepath"
+ "sort"
+ "strings"
+ "time"
+)
+
+func PurgeFile(dirname string, suffix string, max uint, interval time.Duration, stop <-chan struct{}) <-chan error {
+ return purgeFile(dirname, suffix, max, interval, stop, nil)
+}
+
+// purgeFile is the internal implementation for PurgeFile which can post purged files to purgec if non-nil.
+func purgeFile(dirname string, suffix string, max uint, interval time.Duration, stop <-chan struct{}, purgec chan<- string) <-chan error {
+ errC := make(chan error, 1)
+ go func() {
+ for {
+ fnames, err := ReadDir(dirname)
+ if err != nil {
+ errC <- err
+ return
+ }
+ newfnames := make([]string, 0)
+ for _, fname := range fnames {
+ if strings.HasSuffix(fname, suffix) {
+ newfnames = append(newfnames, fname)
+ }
+ }
+ sort.Strings(newfnames)
+ fnames = newfnames
+ for len(newfnames) > int(max) {
+ f := filepath.Join(dirname, newfnames[0])
+ l, err := TryLockFile(f, os.O_WRONLY, PrivateFileMode)
+ if err != nil {
+ break
+ }
+ if err = os.Remove(f); err != nil {
+ errC <- err
+ return
+ }
+ if err = l.Close(); err != nil {
+ plog.Errorf("error unlocking %s when purging file (%v)", l.Name(), err)
+ errC <- err
+ return
+ }
+ plog.Infof("purged file %s successfully", f)
+ newfnames = newfnames[1:]
+ }
+ if purgec != nil {
+ for i := 0; i < len(fnames)-len(newfnames); i++ {
+ purgec <- fnames[i]
+ }
+ }
+ select {
+ case <-time.After(interval):
+ case <-stop:
+ return
+ }
+ }
+ }()
+ return errC
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/purge_test.go b/vendor/github.com/coreos/etcd/pkg/fileutil/purge_test.go
new file mode 100644
index 00000000..addd8e82
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/purge_test.go
@@ -0,0 +1,177 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 fileutil
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "reflect"
+ "testing"
+ "time"
+)
+
+func TestPurgeFile(t *testing.T) {
+ dir, err := ioutil.TempDir("", "purgefile")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(dir)
+
+ // minimal file set
+ for i := 0; i < 3; i++ {
+ f, ferr := os.Create(filepath.Join(dir, fmt.Sprintf("%d.test", i)))
+ if ferr != nil {
+ t.Fatal(err)
+ }
+ f.Close()
+ }
+
+ stop, purgec := make(chan struct{}), make(chan string, 10)
+
+ // keep 3 most recent files
+ errch := purgeFile(dir, "test", 3, time.Millisecond, stop, purgec)
+ select {
+ case f := <-purgec:
+ t.Errorf("unexpected purge on %q", f)
+ case <-time.After(10 * time.Millisecond):
+ }
+
+ // rest of the files
+ for i := 4; i < 10; i++ {
+ go func(n int) {
+ f, ferr := os.Create(filepath.Join(dir, fmt.Sprintf("%d.test", n)))
+ if ferr != nil {
+ t.Fatal(err)
+ }
+ f.Close()
+ }(i)
+ }
+
+ // watch files purge away
+ for i := 4; i < 10; i++ {
+ select {
+ case <-purgec:
+ case <-time.After(time.Second):
+ t.Errorf("purge took too long")
+ }
+ }
+
+ fnames, rerr := ReadDir(dir)
+ if rerr != nil {
+ t.Fatal(rerr)
+ }
+ wnames := []string{"7.test", "8.test", "9.test"}
+ if !reflect.DeepEqual(fnames, wnames) {
+ t.Errorf("filenames = %v, want %v", fnames, wnames)
+ }
+
+ // no error should be reported from purge routine
+ select {
+ case f := <-purgec:
+ t.Errorf("unexpected purge on %q", f)
+ case err := <-errch:
+ t.Errorf("unexpected purge error %v", err)
+ case <-time.After(10 * time.Millisecond):
+ }
+ close(stop)
+}
+
+func TestPurgeFileHoldingLockFile(t *testing.T) {
+ dir, err := ioutil.TempDir("", "purgefile")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(dir)
+
+ for i := 0; i < 10; i++ {
+ var f *os.File
+ f, err = os.Create(filepath.Join(dir, fmt.Sprintf("%d.test", i)))
+ if err != nil {
+ t.Fatal(err)
+ }
+ f.Close()
+ }
+
+ // create a purge barrier at 5
+ p := filepath.Join(dir, fmt.Sprintf("%d.test", 5))
+ l, err := LockFile(p, os.O_WRONLY, PrivateFileMode)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ stop, purgec := make(chan struct{}), make(chan string, 10)
+ errch := purgeFile(dir, "test", 3, time.Millisecond, stop, purgec)
+
+ for i := 0; i < 5; i++ {
+ select {
+ case <-purgec:
+ case <-time.After(time.Second):
+ t.Fatalf("purge took too long")
+ }
+ }
+
+ fnames, rerr := ReadDir(dir)
+ if rerr != nil {
+ t.Fatal(rerr)
+ }
+
+ wnames := []string{"5.test", "6.test", "7.test", "8.test", "9.test"}
+ if !reflect.DeepEqual(fnames, wnames) {
+ t.Errorf("filenames = %v, want %v", fnames, wnames)
+ }
+
+ select {
+ case s := <-purgec:
+ t.Errorf("unexpected purge %q", s)
+ case err = <-errch:
+ t.Errorf("unexpected purge error %v", err)
+ case <-time.After(10 * time.Millisecond):
+ }
+
+ // remove the purge barrier
+ if err = l.Close(); err != nil {
+ t.Fatal(err)
+ }
+
+ // wait for rest of purges (5, 6)
+ for i := 0; i < 2; i++ {
+ select {
+ case <-purgec:
+ case <-time.After(time.Second):
+ t.Fatalf("purge took too long")
+ }
+ }
+
+ fnames, rerr = ReadDir(dir)
+ if rerr != nil {
+ t.Fatal(rerr)
+ }
+ wnames = []string{"7.test", "8.test", "9.test"}
+ if !reflect.DeepEqual(fnames, wnames) {
+ t.Errorf("filenames = %v, want %v", fnames, wnames)
+ }
+
+ select {
+ case f := <-purgec:
+ t.Errorf("unexpected purge on %q", f)
+ case err := <-errch:
+ t.Errorf("unexpected purge error %v", err)
+ case <-time.After(10 * time.Millisecond):
+ }
+
+ close(stop)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/sync.go b/vendor/github.com/coreos/etcd/pkg/fileutil/sync.go
new file mode 100644
index 00000000..54dd41f4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/sync.go
@@ -0,0 +1,29 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build !linux,!darwin
+
+package fileutil
+
+import "os"
+
+// Fsync is a wrapper around file.Sync(). Special handling is needed on darwin platform.
+func Fsync(f *os.File) error {
+ return f.Sync()
+}
+
+// Fdatasync is a wrapper around file.Sync(). Special handling is needed on linux platform.
+func Fdatasync(f *os.File) error {
+ return f.Sync()
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/sync_darwin.go b/vendor/github.com/coreos/etcd/pkg/fileutil/sync_darwin.go
new file mode 100644
index 00000000..c2f39bf2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/sync_darwin.go
@@ -0,0 +1,40 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build darwin
+
+package fileutil
+
+import (
+ "os"
+ "syscall"
+)
+
+// Fsync on HFS/OSX flushes the data on to the physical drive but the drive
+// may not write it to the persistent media for quite sometime and it may be
+// written in out-of-order sequence. Using F_FULLFSYNC ensures that the
+// physical drive's buffer will also get flushed to the media.
+func Fsync(f *os.File) error {
+ _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.Fd(), uintptr(syscall.F_FULLFSYNC), uintptr(0))
+ if errno == 0 {
+ return nil
+ }
+ return errno
+}
+
+// Fdatasync on darwin platform invokes fcntl(F_FULLFSYNC) for actual persistence
+// on physical drive media.
+func Fdatasync(f *os.File) error {
+ return Fsync(f)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/fileutil/sync_linux.go b/vendor/github.com/coreos/etcd/pkg/fileutil/sync_linux.go
new file mode 100644
index 00000000..1bbced91
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/fileutil/sync_linux.go
@@ -0,0 +1,34 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build linux
+
+package fileutil
+
+import (
+ "os"
+ "syscall"
+)
+
+// Fsync is a wrapper around file.Sync(). Special handling is needed on darwin platform.
+func Fsync(f *os.File) error {
+ return f.Sync()
+}
+
+// Fdatasync is similar to fsync(), but does not flush modified metadata
+// unless that metadata is needed in order to allow a subsequent data retrieval
+// to be correctly handled.
+func Fdatasync(f *os.File) error {
+ return syscall.Fdatasync(int(f.Fd()))
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/flags/flag.go b/vendor/github.com/coreos/etcd/pkg/flags/flag.go
new file mode 100644
index 00000000..d30bf3f9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/flags/flag.go
@@ -0,0 +1,164 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 flags implements command-line flag parsing.
+package flags
+
+import (
+ "flag"
+ "fmt"
+ "net/url"
+ "os"
+ "strings"
+
+ "github.com/coreos/pkg/capnslog"
+ "github.com/spf13/pflag"
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "pkg/flags")
+)
+
+// DeprecatedFlag encapsulates a flag that may have been previously valid but
+// is now deprecated. If a DeprecatedFlag is set, an error occurs.
+type DeprecatedFlag struct {
+ Name string
+}
+
+func (f *DeprecatedFlag) Set(_ string) error {
+ return fmt.Errorf(`flag "-%s" is no longer supported.`, f.Name)
+}
+
+func (f *DeprecatedFlag) String() string {
+ return ""
+}
+
+// IgnoredFlag encapsulates a flag that may have been previously valid but is
+// now ignored. If an IgnoredFlag is set, a warning is printed and
+// operation continues.
+type IgnoredFlag struct {
+ Name string
+}
+
+// IsBoolFlag is defined to allow the flag to be defined without an argument
+func (f *IgnoredFlag) IsBoolFlag() bool {
+ return true
+}
+
+func (f *IgnoredFlag) Set(s string) error {
+ plog.Warningf(`flag "-%s" is no longer supported - ignoring.`, f.Name)
+ return nil
+}
+
+func (f *IgnoredFlag) String() string {
+ return ""
+}
+
+// SetFlagsFromEnv parses all registered flags in the given flagset,
+// and if they are not already set it attempts to set their values from
+// environment variables. Environment variables take the name of the flag but
+// are UPPERCASE, have the given prefix and any dashes are replaced by
+// underscores - for example: some-flag => ETCD_SOME_FLAG
+func SetFlagsFromEnv(prefix string, fs *flag.FlagSet) error {
+ var err error
+ alreadySet := make(map[string]bool)
+ fs.Visit(func(f *flag.Flag) {
+ alreadySet[FlagToEnv(prefix, f.Name)] = true
+ })
+ usedEnvKey := make(map[string]bool)
+ fs.VisitAll(func(f *flag.Flag) {
+ err = setFlagFromEnv(fs, prefix, f.Name, usedEnvKey, alreadySet, true)
+ })
+
+ verifyEnv(prefix, usedEnvKey, alreadySet)
+
+ return err
+}
+
+// SetPflagsFromEnv is similar to SetFlagsFromEnv. However, the accepted flagset type is pflag.FlagSet
+// and it does not do any logging.
+func SetPflagsFromEnv(prefix string, fs *pflag.FlagSet) error {
+ var err error
+ alreadySet := make(map[string]bool)
+ usedEnvKey := make(map[string]bool)
+ fs.VisitAll(func(f *pflag.Flag) {
+ if f.Changed {
+ alreadySet[FlagToEnv(prefix, f.Name)] = true
+ }
+ if serr := setFlagFromEnv(fs, prefix, f.Name, usedEnvKey, alreadySet, false); serr != nil {
+ err = serr
+ }
+ })
+ return err
+}
+
+// FlagToEnv converts flag string to upper-case environment variable key string.
+func FlagToEnv(prefix, name string) string {
+ return prefix + "_" + strings.ToUpper(strings.Replace(name, "-", "_", -1))
+}
+
+func verifyEnv(prefix string, usedEnvKey, alreadySet map[string]bool) {
+ for _, env := range os.Environ() {
+ kv := strings.SplitN(env, "=", 2)
+ if len(kv) != 2 {
+ plog.Warningf("found invalid env %s", env)
+ }
+ if usedEnvKey[kv[0]] {
+ continue
+ }
+ if alreadySet[kv[0]] {
+ plog.Infof("recognized environment variable %s, but unused: shadowed by corresponding flag ", kv[0])
+ continue
+ }
+ if strings.HasPrefix(env, prefix+"_") {
+ plog.Warningf("unrecognized environment variable %s", env)
+ }
+ }
+}
+
+type flagSetter interface {
+ Set(fk string, fv string) error
+}
+
+func setFlagFromEnv(fs flagSetter, prefix, fname string, usedEnvKey, alreadySet map[string]bool, log bool) error {
+ key := FlagToEnv(prefix, fname)
+ if !alreadySet[key] {
+ val := os.Getenv(key)
+ if val != "" {
+ usedEnvKey[key] = true
+ if serr := fs.Set(fname, val); serr != nil {
+ return fmt.Errorf("invalid value %q for %s: %v", val, key, serr)
+ }
+ if log {
+ plog.Infof("recognized and used environment variable %s=%s", key, val)
+ }
+ }
+ }
+ return nil
+}
+
+// URLsFromFlag returns a slices from url got from the flag.
+func URLsFromFlag(fs *flag.FlagSet, urlsFlagName string) []url.URL {
+ return []url.URL(*fs.Lookup(urlsFlagName).Value.(*URLsValue))
+}
+
+func IsSet(fs *flag.FlagSet, name string) bool {
+ set := false
+ fs.Visit(func(f *flag.Flag) {
+ if f.Name == name {
+ set = true
+ }
+ })
+ return set
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/flags/flag_test.go b/vendor/github.com/coreos/etcd/pkg/flags/flag_test.go
new file mode 100644
index 00000000..726bc418
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/flags/flag_test.go
@@ -0,0 +1,78 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 flags
+
+import (
+ "flag"
+ "os"
+ "testing"
+)
+
+func TestSetFlagsFromEnv(t *testing.T) {
+ fs := flag.NewFlagSet("testing", flag.ExitOnError)
+ fs.String("a", "", "")
+ fs.String("b", "", "")
+ fs.String("c", "", "")
+ fs.Parse([]string{})
+
+ os.Clearenv()
+ // flags should be settable using env vars
+ os.Setenv("ETCD_A", "foo")
+ // and command-line flags
+ if err := fs.Set("b", "bar"); err != nil {
+ t.Fatal(err)
+ }
+ // command-line flags take precedence over env vars
+ os.Setenv("ETCD_C", "woof")
+ if err := fs.Set("c", "quack"); err != nil {
+ t.Fatal(err)
+ }
+
+ // first verify that flags are as expected before reading the env
+ for f, want := range map[string]string{
+ "a": "",
+ "b": "bar",
+ "c": "quack",
+ } {
+ if got := fs.Lookup(f).Value.String(); got != want {
+ t.Fatalf("flag %q=%q, want %q", f, got, want)
+ }
+ }
+
+ // now read the env and verify flags were updated as expected
+ err := SetFlagsFromEnv("ETCD", fs)
+ if err != nil {
+ t.Errorf("err=%v, want nil", err)
+ }
+ for f, want := range map[string]string{
+ "a": "foo",
+ "b": "bar",
+ "c": "quack",
+ } {
+ if got := fs.Lookup(f).Value.String(); got != want {
+ t.Errorf("flag %q=%q, want %q", f, got, want)
+ }
+ }
+}
+
+func TestSetFlagsFromEnvBad(t *testing.T) {
+ // now verify that an error is propagated
+ fs := flag.NewFlagSet("testing", flag.ExitOnError)
+ fs.Int("x", 0, "")
+ os.Setenv("ETCD_X", "not_a_number")
+ if err := SetFlagsFromEnv("ETCD", fs); err == nil {
+ t.Errorf("err=nil, want != nil")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/flags/strings.go b/vendor/github.com/coreos/etcd/pkg/flags/strings.go
new file mode 100644
index 00000000..21ff916a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/flags/strings.go
@@ -0,0 +1,46 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 flags
+
+import "errors"
+
+// NewStringsFlag creates a new string flag for which any one of the given
+// strings is a valid value, and any other value is an error.
+func NewStringsFlag(valids ...string) *StringsFlag {
+ return &StringsFlag{Values: valids}
+}
+
+// StringsFlag implements the flag.Value interface.
+type StringsFlag struct {
+ Values []string
+ val string
+}
+
+// Set verifies the argument to be a valid member of the allowed values
+// before setting the underlying flag value.
+func (ss *StringsFlag) Set(s string) error {
+ for _, v := range ss.Values {
+ if s == v {
+ ss.val = s
+ return nil
+ }
+ }
+ return errors.New("invalid value")
+}
+
+// String returns the set value (if any) of the StringsFlag
+func (ss *StringsFlag) String() string {
+ return ss.val
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/flags/strings_test.go b/vendor/github.com/coreos/etcd/pkg/flags/strings_test.go
new file mode 100644
index 00000000..351085a3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/flags/strings_test.go
@@ -0,0 +1,45 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 flags
+
+import (
+ "testing"
+)
+
+func TestStringsSet(t *testing.T) {
+ tests := []struct {
+ vals []string
+
+ val string
+ pass bool
+ }{
+ // known values
+ {[]string{"abc", "def"}, "abc", true},
+ {[]string{"on", "off", "false"}, "on", true},
+
+ // unrecognized values
+ {[]string{"abc", "def"}, "ghi", false},
+ {[]string{"on", "off"}, "", false},
+ {[]string{}, "asdf", false},
+ }
+
+ for i, tt := range tests {
+ sf := NewStringsFlag(tt.vals...)
+ err := sf.Set(tt.val)
+ if tt.pass != (err == nil) {
+ t.Errorf("#%d: want pass=%t, but got err=%v", i, tt.pass, err)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/flags/urls.go b/vendor/github.com/coreos/etcd/pkg/flags/urls.go
new file mode 100644
index 00000000..6383d7e9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/flags/urls.go
@@ -0,0 +1,52 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 flags
+
+import (
+ "strings"
+
+ "github.com/coreos/etcd/pkg/types"
+)
+
+type URLsValue types.URLs
+
+// Set parses a command line set of URLs formatted like:
+// http://127.0.0.1:2380,http://10.1.1.2:80
+func (us *URLsValue) Set(s string) error {
+ strs := strings.Split(s, ",")
+ nus, err := types.NewURLs(strs)
+ if err != nil {
+ return err
+ }
+
+ *us = URLsValue(nus)
+ return nil
+}
+
+func (us *URLsValue) String() string {
+ all := make([]string, len(*us))
+ for i, u := range *us {
+ all[i] = u.String()
+ }
+ return strings.Join(all, ",")
+}
+
+func NewURLsValue(init string) *URLsValue {
+ v := &URLsValue{}
+ if err := v.Set(init); err != nil {
+ plog.Panicf("new URLsValue should never fail: %v", err)
+ }
+ return v
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/flags/urls_test.go b/vendor/github.com/coreos/etcd/pkg/flags/urls_test.go
new file mode 100644
index 00000000..bcccdfaa
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/flags/urls_test.go
@@ -0,0 +1,61 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 flags
+
+import (
+ "testing"
+)
+
+func TestValidateURLsValueBad(t *testing.T) {
+ tests := []string{
+ // bad IP specification
+ ":2379",
+ "127.0:8080",
+ "123:456",
+ // bad port specification
+ "127.0.0.1:foo",
+ "127.0.0.1:",
+ // unix sockets not supported
+ "unix://",
+ "unix://tmp/etcd.sock",
+ // bad strings
+ "somewhere",
+ "234#$",
+ "file://foo/bar",
+ "http://hello/asdf",
+ "http://10.1.1.1",
+ }
+ for i, in := range tests {
+ u := URLsValue{}
+ if err := u.Set(in); err == nil {
+ t.Errorf(`#%d: unexpected nil error for in=%q`, i, in)
+ }
+ }
+}
+
+func TestValidateURLsValueGood(t *testing.T) {
+ tests := []string{
+ "https://1.2.3.4:8080",
+ "http://10.1.1.1:80",
+ "http://localhost:80",
+ "http://:80",
+ }
+ for i, in := range tests {
+ u := URLsValue{}
+ if err := u.Set(in); err != nil {
+ t.Errorf("#%d: err=%v, want nil for in=%q", i, err, in)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/httputil/httputil.go b/vendor/github.com/coreos/etcd/pkg/httputil/httputil.go
new file mode 100644
index 00000000..09f44e7c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/httputil/httputil.go
@@ -0,0 +1,22 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// borrowed from golang/net/context/ctxhttp/cancelreq.go
+
+// Package httputil provides HTTP utility functions.
+package httputil
+
+import (
+ "io"
+ "io/ioutil"
+ "net/http"
+)
+
+// GracefulClose drains http.Response.Body until it hits EOF
+// and closes it. This prevents TCP/TLS connections from closing,
+// therefore available for reuse.
+func GracefulClose(resp *http.Response) {
+ io.Copy(ioutil.Discard, resp.Body)
+ resp.Body.Close()
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/idutil/id.go b/vendor/github.com/coreos/etcd/pkg/idutil/id.go
new file mode 100644
index 00000000..2da21062
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/idutil/id.go
@@ -0,0 +1,78 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 idutil implements utility functions for generating unique,
+// randomized ids.
+package idutil
+
+import (
+ "math"
+ "sync"
+ "time"
+)
+
+const (
+ tsLen = 5 * 8
+ cntLen = 8
+ suffixLen = tsLen + cntLen
+)
+
+// Generator generates unique identifiers based on counters, timestamps, and
+// a node member ID.
+//
+// The initial id is in this format:
+// High order 2 bytes are from memberID, next 5 bytes are from timestamp,
+// and low order one byte is a counter.
+// | prefix | suffix |
+// | 2 bytes | 5 bytes | 1 byte |
+// | memberID | timestamp | cnt |
+//
+// The timestamp 5 bytes is different when the machine is restart
+// after 1 ms and before 35 years.
+//
+// It increases suffix to generate the next id.
+// The count field may overflow to timestamp field, which is intentional.
+// It helps to extend the event window to 2^56. This doesn't break that
+// id generated after restart is unique because etcd throughput is <<
+// 256req/ms(250k reqs/second).
+type Generator struct {
+ mu sync.Mutex
+ // high order 2 bytes
+ prefix uint64
+ // low order 6 bytes
+ suffix uint64
+}
+
+func NewGenerator(memberID uint16, now time.Time) *Generator {
+ prefix := uint64(memberID) << suffixLen
+ unixMilli := uint64(now.UnixNano()) / uint64(time.Millisecond/time.Nanosecond)
+ suffix := lowbit(unixMilli, tsLen) << cntLen
+ return &Generator{
+ prefix: prefix,
+ suffix: suffix,
+ }
+}
+
+// Next generates a id that is unique.
+func (g *Generator) Next() uint64 {
+ g.mu.Lock()
+ defer g.mu.Unlock()
+ g.suffix++
+ id := g.prefix | lowbit(g.suffix, suffixLen)
+ return id
+}
+
+func lowbit(x uint64, n uint) uint64 {
+ return x & (math.MaxUint64 >> (64 - n))
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/idutil/id_test.go b/vendor/github.com/coreos/etcd/pkg/idutil/id_test.go
new file mode 100644
index 00000000..ddcbc6d3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/idutil/id_test.go
@@ -0,0 +1,55 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 idutil
+
+import (
+ "testing"
+ "time"
+)
+
+func TestNewGenerator(t *testing.T) {
+ g := NewGenerator(0x12, time.Unix(0, 0).Add(0x3456*time.Millisecond))
+ id := g.Next()
+ wid := uint64(0x12000000345601)
+ if id != wid {
+ t.Errorf("id = %x, want %x", id, wid)
+ }
+}
+
+func TestNewGeneratorUnique(t *testing.T) {
+ g := NewGenerator(0, time.Time{})
+ id := g.Next()
+ // different server generates different ID
+ g1 := NewGenerator(1, time.Time{})
+ if gid := g1.Next(); id == gid {
+ t.Errorf("generate the same id %x using different server ID", id)
+ }
+ // restarted server generates different ID
+ g2 := NewGenerator(0, time.Now())
+ if gid := g2.Next(); id == gid {
+ t.Errorf("generate the same id %x after restart", id)
+ }
+}
+
+func TestNext(t *testing.T) {
+ g := NewGenerator(0x12, time.Unix(0, 0).Add(0x3456*time.Millisecond))
+ wid := uint64(0x12000000345601)
+ for i := 0; i < 1000; i++ {
+ id := g.Next()
+ if id != wid+uint64(i) {
+ t.Errorf("id = %x, want %x", id, wid+uint64(i))
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/ioutil/pagewriter.go b/vendor/github.com/coreos/etcd/pkg/ioutil/pagewriter.go
new file mode 100644
index 00000000..72de1593
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/ioutil/pagewriter.go
@@ -0,0 +1,106 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 ioutil
+
+import (
+ "io"
+)
+
+var defaultBufferBytes = 128 * 1024
+
+// PageWriter implements the io.Writer interface so that writes will
+// either be in page chunks or from flushing.
+type PageWriter struct {
+ w io.Writer
+ // pageOffset tracks the page offset of the base of the buffer
+ pageOffset int
+ // pageBytes is the number of bytes per page
+ pageBytes int
+ // bufferedBytes counts the number of bytes pending for write in the buffer
+ bufferedBytes int
+ // buf holds the write buffer
+ buf []byte
+ // bufWatermarkBytes is the number of bytes the buffer can hold before it needs
+ // to be flushed. It is less than len(buf) so there is space for slack writes
+ // to bring the writer to page alignment.
+ bufWatermarkBytes int
+}
+
+// NewPageWriter creates a new PageWriter. pageBytes is the number of bytes
+// to write per page. pageOffset is the starting offset of io.Writer.
+func NewPageWriter(w io.Writer, pageBytes, pageOffset int) *PageWriter {
+ return &PageWriter{
+ w: w,
+ pageOffset: pageOffset,
+ pageBytes: pageBytes,
+ buf: make([]byte, defaultBufferBytes+pageBytes),
+ bufWatermarkBytes: defaultBufferBytes,
+ }
+}
+
+func (pw *PageWriter) Write(p []byte) (n int, err error) {
+ if len(p)+pw.bufferedBytes <= pw.bufWatermarkBytes {
+ // no overflow
+ copy(pw.buf[pw.bufferedBytes:], p)
+ pw.bufferedBytes += len(p)
+ return len(p), nil
+ }
+ // complete the slack page in the buffer if unaligned
+ slack := pw.pageBytes - ((pw.pageOffset + pw.bufferedBytes) % pw.pageBytes)
+ if slack != pw.pageBytes {
+ partial := slack > len(p)
+ if partial {
+ // not enough data to complete the slack page
+ slack = len(p)
+ }
+ // special case: writing to slack page in buffer
+ copy(pw.buf[pw.bufferedBytes:], p[:slack])
+ pw.bufferedBytes += slack
+ n = slack
+ p = p[slack:]
+ if partial {
+ // avoid forcing an unaligned flush
+ return n, nil
+ }
+ }
+ // buffer contents are now page-aligned; clear out
+ if err = pw.Flush(); err != nil {
+ return n, err
+ }
+ // directly write all complete pages without copying
+ if len(p) > pw.pageBytes {
+ pages := len(p) / pw.pageBytes
+ c, werr := pw.w.Write(p[:pages*pw.pageBytes])
+ n += c
+ if werr != nil {
+ return n, werr
+ }
+ p = p[pages*pw.pageBytes:]
+ }
+ // write remaining tail to buffer
+ c, werr := pw.Write(p)
+ n += c
+ return n, werr
+}
+
+func (pw *PageWriter) Flush() error {
+ if pw.bufferedBytes == 0 {
+ return nil
+ }
+ _, err := pw.w.Write(pw.buf[:pw.bufferedBytes])
+ pw.pageOffset = (pw.pageOffset + pw.bufferedBytes) % pw.pageBytes
+ pw.bufferedBytes = 0
+ return err
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/ioutil/pagewriter_test.go b/vendor/github.com/coreos/etcd/pkg/ioutil/pagewriter_test.go
new file mode 100644
index 00000000..cdeaba92
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/ioutil/pagewriter_test.go
@@ -0,0 +1,129 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 ioutil
+
+import (
+ "math/rand"
+ "testing"
+)
+
+func TestPageWriterRandom(t *testing.T) {
+ // smaller buffer for stress testing
+ defaultBufferBytes = 8 * 1024
+ pageBytes := 128
+ buf := make([]byte, 4*defaultBufferBytes)
+ cw := &checkPageWriter{pageBytes: pageBytes, t: t}
+ w := NewPageWriter(cw, pageBytes, 0)
+ n := 0
+ for i := 0; i < 4096; i++ {
+ c, err := w.Write(buf[:rand.Intn(len(buf))])
+ if err != nil {
+ t.Fatal(err)
+ }
+ n += c
+ }
+ if cw.writeBytes > n {
+ t.Fatalf("wrote %d bytes to io.Writer, but only wrote %d bytes", cw.writeBytes, n)
+ }
+ if cw.writeBytes-n > pageBytes {
+ t.Fatalf("got %d bytes pending, expected less than %d bytes", cw.writeBytes-n, pageBytes)
+ }
+ t.Logf("total writes: %d", cw.writes)
+ t.Logf("total write bytes: %d (of %d)", cw.writeBytes, n)
+}
+
+// TestPageWriterPariallack tests the case where a write overflows the buffer
+// but there is not enough data to complete the slack write.
+func TestPageWriterPartialSlack(t *testing.T) {
+ defaultBufferBytes = 1024
+ pageBytes := 128
+ buf := make([]byte, defaultBufferBytes)
+ cw := &checkPageWriter{pageBytes: 64, t: t}
+ w := NewPageWriter(cw, pageBytes, 0)
+ // put writer in non-zero page offset
+ if _, err := w.Write(buf[:64]); err != nil {
+ t.Fatal(err)
+ }
+ if err := w.Flush(); err != nil {
+ t.Fatal(err)
+ }
+ if cw.writes != 1 {
+ t.Fatalf("got %d writes, expected 1", cw.writes)
+ }
+ // nearly fill buffer
+ if _, err := w.Write(buf[:1022]); err != nil {
+ t.Fatal(err)
+ }
+ // overflow buffer, but without enough to write as aligned
+ if _, err := w.Write(buf[:8]); err != nil {
+ t.Fatal(err)
+ }
+ if cw.writes != 1 {
+ t.Fatalf("got %d writes, expected 1", cw.writes)
+ }
+ // finish writing slack space
+ if _, err := w.Write(buf[:128]); err != nil {
+ t.Fatal(err)
+ }
+ if cw.writes != 2 {
+ t.Fatalf("got %d writes, expected 2", cw.writes)
+ }
+}
+
+// TestPageWriterOffset tests if page writer correctly repositions when offset is given.
+func TestPageWriterOffset(t *testing.T) {
+ defaultBufferBytes = 1024
+ pageBytes := 128
+ buf := make([]byte, defaultBufferBytes)
+ cw := &checkPageWriter{pageBytes: 64, t: t}
+ w := NewPageWriter(cw, pageBytes, 0)
+ if _, err := w.Write(buf[:64]); err != nil {
+ t.Fatal(err)
+ }
+ if err := w.Flush(); err != nil {
+ t.Fatal(err)
+ }
+ if w.pageOffset != 64 {
+ t.Fatalf("w.pageOffset expected 64, got %d", w.pageOffset)
+ }
+
+ w = NewPageWriter(cw, w.pageOffset, pageBytes)
+ if _, err := w.Write(buf[:64]); err != nil {
+ t.Fatal(err)
+ }
+ if err := w.Flush(); err != nil {
+ t.Fatal(err)
+ }
+ if w.pageOffset != 0 {
+ t.Fatalf("w.pageOffset expected 0, got %d", w.pageOffset)
+ }
+}
+
+// checkPageWriter implements an io.Writer that fails a test on unaligned writes.
+type checkPageWriter struct {
+ pageBytes int
+ writes int
+ writeBytes int
+ t *testing.T
+}
+
+func (cw *checkPageWriter) Write(p []byte) (int, error) {
+ if len(p)%cw.pageBytes != 0 {
+ cw.t.Fatalf("got write len(p) = %d, expected len(p) == k*cw.pageBytes", len(p))
+ }
+ cw.writes++
+ cw.writeBytes += len(p)
+ return len(p), nil
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/ioutil/readcloser.go b/vendor/github.com/coreos/etcd/pkg/ioutil/readcloser.go
new file mode 100644
index 00000000..d3efcfe3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/ioutil/readcloser.go
@@ -0,0 +1,66 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 ioutil
+
+import (
+ "fmt"
+ "io"
+)
+
+// ReaderAndCloser implements io.ReadCloser interface by combining
+// reader and closer together.
+type ReaderAndCloser struct {
+ io.Reader
+ io.Closer
+}
+
+var (
+ ErrShortRead = fmt.Errorf("ioutil: short read")
+ ErrExpectEOF = fmt.Errorf("ioutil: expect EOF")
+)
+
+// NewExactReadCloser returns a ReadCloser that returns errors if the underlying
+// reader does not read back exactly the requested number of bytes.
+func NewExactReadCloser(rc io.ReadCloser, totalBytes int64) io.ReadCloser {
+ return &exactReadCloser{rc: rc, totalBytes: totalBytes}
+}
+
+type exactReadCloser struct {
+ rc io.ReadCloser
+ br int64
+ totalBytes int64
+}
+
+func (e *exactReadCloser) Read(p []byte) (int, error) {
+ n, err := e.rc.Read(p)
+ e.br += int64(n)
+ if e.br > e.totalBytes {
+ return 0, ErrExpectEOF
+ }
+ if e.br < e.totalBytes && n == 0 {
+ return 0, ErrShortRead
+ }
+ return n, err
+}
+
+func (e *exactReadCloser) Close() error {
+ if err := e.rc.Close(); err != nil {
+ return err
+ }
+ if e.br < e.totalBytes {
+ return ErrShortRead
+ }
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/ioutil/readcloser_test.go b/vendor/github.com/coreos/etcd/pkg/ioutil/readcloser_test.go
new file mode 100644
index 00000000..6d13bdce
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/ioutil/readcloser_test.go
@@ -0,0 +1,46 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 ioutil
+
+import (
+ "bytes"
+ "io"
+ "testing"
+)
+
+type readerNilCloser struct{ io.Reader }
+
+func (rc *readerNilCloser) Close() error { return nil }
+
+// TestExactReadCloserExpectEOF expects an eof when reading too much.
+func TestExactReadCloserExpectEOF(t *testing.T) {
+ buf := bytes.NewBuffer(make([]byte, 10))
+ rc := NewExactReadCloser(&readerNilCloser{buf}, 1)
+ if _, err := rc.Read(make([]byte, 10)); err != ErrExpectEOF {
+ t.Fatalf("expected %v, got %v", ErrExpectEOF, err)
+ }
+}
+
+// TestExactReadCloserShort expects an eof when reading too little
+func TestExactReadCloserShort(t *testing.T) {
+ buf := bytes.NewBuffer(make([]byte, 5))
+ rc := NewExactReadCloser(&readerNilCloser{buf}, 10)
+ if _, err := rc.Read(make([]byte, 10)); err != nil {
+ t.Fatalf("Read expected nil err, got %v", err)
+ }
+ if err := rc.Close(); err != ErrShortRead {
+ t.Fatalf("Close expected %v, got %v", ErrShortRead, err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/ioutil/reader.go b/vendor/github.com/coreos/etcd/pkg/ioutil/reader.go
new file mode 100644
index 00000000..0703ed47
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/ioutil/reader.go
@@ -0,0 +1,40 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 ioutil implements I/O utility functions.
+package ioutil
+
+import "io"
+
+// NewLimitedBufferReader returns a reader that reads from the given reader
+// but limits the amount of data returned to at most n bytes.
+func NewLimitedBufferReader(r io.Reader, n int) io.Reader {
+ return &limitedBufferReader{
+ r: r,
+ n: n,
+ }
+}
+
+type limitedBufferReader struct {
+ r io.Reader
+ n int
+}
+
+func (r *limitedBufferReader) Read(p []byte) (n int, err error) {
+ np := p
+ if len(np) > r.n {
+ np = np[:r.n]
+ }
+ return r.r.Read(np)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/ioutil/reader_test.go b/vendor/github.com/coreos/etcd/pkg/ioutil/reader_test.go
new file mode 100644
index 00000000..06ff2906
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/ioutil/reader_test.go
@@ -0,0 +1,33 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 ioutil
+
+import (
+ "bytes"
+ "testing"
+)
+
+func TestLimitedBufferReaderRead(t *testing.T) {
+ buf := bytes.NewBuffer(make([]byte, 10))
+ ln := 1
+ lr := NewLimitedBufferReader(buf, ln)
+ n, err := lr.Read(make([]byte, 10))
+ if err != nil {
+ t.Fatalf("unexpected read error: %v", err)
+ }
+ if n != ln {
+ t.Errorf("len(data read) = %d, want %d", n, ln)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/ioutil/util.go b/vendor/github.com/coreos/etcd/pkg/ioutil/util.go
new file mode 100644
index 00000000..192ad888
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/ioutil/util.go
@@ -0,0 +1,43 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 ioutil
+
+import (
+ "io"
+ "os"
+
+ "github.com/coreos/etcd/pkg/fileutil"
+)
+
+// WriteAndSyncFile behaves just like ioutil.WriteFile in the standard library,
+// but calls Sync before closing the file. WriteAndSyncFile guarantees the data
+// is synced if there is no error returned.
+func WriteAndSyncFile(filename string, data []byte, perm os.FileMode) error {
+ f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
+ if err != nil {
+ return err
+ }
+ n, err := f.Write(data)
+ if err == nil && n < len(data) {
+ err = io.ErrShortWrite
+ }
+ if err == nil {
+ err = fileutil.Fsync(f)
+ }
+ if err1 := f.Close(); err == nil {
+ err = err1
+ }
+ return err
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/logutil/merge_logger.go b/vendor/github.com/coreos/etcd/pkg/logutil/merge_logger.go
new file mode 100644
index 00000000..cc750f4d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/logutil/merge_logger.go
@@ -0,0 +1,195 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 logutil includes utilities to facilitate logging.
+package logutil
+
+import (
+ "fmt"
+ "sync"
+ "time"
+
+ "github.com/coreos/pkg/capnslog"
+)
+
+var (
+ defaultMergePeriod = time.Second
+ defaultTimeOutputScale = 10 * time.Millisecond
+
+ outputInterval = time.Second
+)
+
+// line represents a log line that can be printed out
+// through capnslog.PackageLogger.
+type line struct {
+ level capnslog.LogLevel
+ str string
+}
+
+func (l line) append(s string) line {
+ return line{
+ level: l.level,
+ str: l.str + " " + s,
+ }
+}
+
+// status represents the merge status of a line.
+type status struct {
+ period time.Duration
+
+ start time.Time // start time of latest merge period
+ count int // number of merged lines from starting
+}
+
+func (s *status) isInMergePeriod(now time.Time) bool {
+ return s.period == 0 || s.start.Add(s.period).After(now)
+}
+
+func (s *status) isEmpty() bool { return s.count == 0 }
+
+func (s *status) summary(now time.Time) string {
+ ts := s.start.Round(defaultTimeOutputScale)
+ took := now.Round(defaultTimeOutputScale).Sub(ts)
+ return fmt.Sprintf("[merged %d repeated lines in %s]", s.count, took)
+}
+
+func (s *status) reset(now time.Time) {
+ s.start = now
+ s.count = 0
+}
+
+// MergeLogger supports merge logging, which merges repeated log lines
+// and prints summary log lines instead.
+//
+// For merge logging, MergeLogger prints out the line when the line appears
+// at the first time. MergeLogger holds the same log line printed within
+// defaultMergePeriod, and prints out summary log line at the end of defaultMergePeriod.
+// It stops merging when the line doesn't appear within the
+// defaultMergePeriod.
+type MergeLogger struct {
+ *capnslog.PackageLogger
+
+ mu sync.Mutex // protect statusm
+ statusm map[line]*status
+}
+
+func NewMergeLogger(logger *capnslog.PackageLogger) *MergeLogger {
+ l := &MergeLogger{
+ PackageLogger: logger,
+ statusm: make(map[line]*status),
+ }
+ go l.outputLoop()
+ return l
+}
+
+func (l *MergeLogger) MergeInfo(entries ...interface{}) {
+ l.merge(line{
+ level: capnslog.INFO,
+ str: fmt.Sprint(entries...),
+ })
+}
+
+func (l *MergeLogger) MergeInfof(format string, args ...interface{}) {
+ l.merge(line{
+ level: capnslog.INFO,
+ str: fmt.Sprintf(format, args...),
+ })
+}
+
+func (l *MergeLogger) MergeNotice(entries ...interface{}) {
+ l.merge(line{
+ level: capnslog.NOTICE,
+ str: fmt.Sprint(entries...),
+ })
+}
+
+func (l *MergeLogger) MergeNoticef(format string, args ...interface{}) {
+ l.merge(line{
+ level: capnslog.NOTICE,
+ str: fmt.Sprintf(format, args...),
+ })
+}
+
+func (l *MergeLogger) MergeWarning(entries ...interface{}) {
+ l.merge(line{
+ level: capnslog.WARNING,
+ str: fmt.Sprint(entries...),
+ })
+}
+
+func (l *MergeLogger) MergeWarningf(format string, args ...interface{}) {
+ l.merge(line{
+ level: capnslog.WARNING,
+ str: fmt.Sprintf(format, args...),
+ })
+}
+
+func (l *MergeLogger) MergeError(entries ...interface{}) {
+ l.merge(line{
+ level: capnslog.ERROR,
+ str: fmt.Sprint(entries...),
+ })
+}
+
+func (l *MergeLogger) MergeErrorf(format string, args ...interface{}) {
+ l.merge(line{
+ level: capnslog.ERROR,
+ str: fmt.Sprintf(format, args...),
+ })
+}
+
+func (l *MergeLogger) merge(ln line) {
+ l.mu.Lock()
+
+ // increase count if the logger is merging the line
+ if status, ok := l.statusm[ln]; ok {
+ status.count++
+ l.mu.Unlock()
+ return
+ }
+
+ // initialize status of the line
+ l.statusm[ln] = &status{
+ period: defaultMergePeriod,
+ start: time.Now(),
+ }
+ // release the lock before IO operation
+ l.mu.Unlock()
+ // print out the line at its first time
+ l.PackageLogger.Logf(ln.level, ln.str)
+}
+
+func (l *MergeLogger) outputLoop() {
+ for now := range time.Tick(outputInterval) {
+ var outputs []line
+
+ l.mu.Lock()
+ for ln, status := range l.statusm {
+ if status.isInMergePeriod(now) {
+ continue
+ }
+ if status.isEmpty() {
+ delete(l.statusm, ln)
+ continue
+ }
+ outputs = append(outputs, ln.append(status.summary(now)))
+ status.reset(now)
+ }
+ l.mu.Unlock()
+
+ for _, o := range outputs {
+ l.PackageLogger.Logf(o.level, o.str)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/logutil/merge_logger_test.go b/vendor/github.com/coreos/etcd/pkg/logutil/merge_logger_test.go
new file mode 100644
index 00000000..99e422d9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/logutil/merge_logger_test.go
@@ -0,0 +1,71 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 logutil
+
+import (
+ "fmt"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/pkg/capnslog"
+)
+
+var (
+ testLogger = capnslog.NewPackageLogger("github.com/coreos/etcd", "pkg/logutil")
+)
+
+func TestMergeLogger(t *testing.T) {
+ var (
+ txt = "hello"
+ repeatN = 6
+ duration = 2049843762 * time.Nanosecond
+ mg = NewMergeLogger(testLogger)
+ )
+ // overwrite this for testing
+ defaultMergePeriod = time.Minute
+
+ for i := 0; i < repeatN; i++ {
+ mg.MergeError(txt)
+ if i == 0 {
+ time.Sleep(duration)
+ }
+ }
+
+ if len(mg.statusm) != 1 {
+ t.Errorf("got = %d, want = %d", len(mg.statusm), 1)
+ }
+
+ var l line
+ for k := range mg.statusm {
+ l = k
+ break
+ }
+
+ if l.level != capnslog.ERROR {
+ t.Errorf("got = %v, want = %v", l.level, capnslog.DEBUG)
+ }
+ if l.str != txt {
+ t.Errorf("got = %s, want = %s", l.str, txt)
+ }
+ if mg.statusm[l].count != repeatN-1 {
+ t.Errorf("got = %d, want = %d", mg.statusm[l].count, repeatN-1)
+ }
+ sum := mg.statusm[l].summary(time.Now())
+ pre := fmt.Sprintf("[merged %d repeated lines in ", repeatN-1)
+ if !strings.HasPrefix(sum, pre) {
+ t.Errorf("got = %s, want = %s...", sum, pre)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/mock/mockstorage/doc.go b/vendor/github.com/coreos/etcd/pkg/mock/mockstorage/doc.go
new file mode 100644
index 00000000..b298ab48
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/mock/mockstorage/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 mockstorage provides mock implementations for etcdserver's storage interface.
+package mockstorage
diff --git a/vendor/github.com/coreos/etcd/pkg/mock/mockstorage/storage_recorder.go b/vendor/github.com/coreos/etcd/pkg/mock/mockstorage/storage_recorder.go
new file mode 100644
index 00000000..4ecab983
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/mock/mockstorage/storage_recorder.go
@@ -0,0 +1,48 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mockstorage
+
+import (
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+type storageRecorder struct {
+ testutil.Recorder
+ dbPath string // must have '/' suffix if set
+}
+
+func NewStorageRecorder(db string) *storageRecorder {
+ return &storageRecorder{&testutil.RecorderBuffered{}, db}
+}
+
+func NewStorageRecorderStream(db string) *storageRecorder {
+ return &storageRecorder{testutil.NewRecorderStream(), db}
+}
+
+func (p *storageRecorder) Save(st raftpb.HardState, ents []raftpb.Entry) error {
+ p.Record(testutil.Action{Name: "Save"})
+ return nil
+}
+
+func (p *storageRecorder) SaveSnap(st raftpb.Snapshot) error {
+ if !raft.IsEmptySnap(st) {
+ p.Record(testutil.Action{Name: "SaveSnap"})
+ }
+ return nil
+}
+
+func (p *storageRecorder) Close() error { return nil }
diff --git a/vendor/github.com/coreos/etcd/pkg/mock/mockstore/doc.go b/vendor/github.com/coreos/etcd/pkg/mock/mockstore/doc.go
new file mode 100644
index 00000000..e74cebea
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/mock/mockstore/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 mockstore provides mock structures for the etcd store package.
+package mockstore
diff --git a/vendor/github.com/coreos/etcd/pkg/mock/mockstore/store_recorder.go b/vendor/github.com/coreos/etcd/pkg/mock/mockstore/store_recorder.go
new file mode 100644
index 00000000..4dad19ee
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/mock/mockstore/store_recorder.go
@@ -0,0 +1,157 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mockstore
+
+import (
+ "time"
+
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/store"
+)
+
+// StoreRecorder provides a Store interface with a testutil.Recorder
+type StoreRecorder struct {
+ store.Store
+ testutil.Recorder
+}
+
+// storeRecorder records all the methods it receives.
+// storeRecorder DOES NOT work as a actual store.
+// It always returns invalid empty response and no error.
+type storeRecorder struct {
+ store.Store
+ testutil.Recorder
+}
+
+func NewNop() store.Store { return &storeRecorder{Recorder: &testutil.RecorderBuffered{}} }
+func NewRecorder() *StoreRecorder {
+ sr := &storeRecorder{Recorder: &testutil.RecorderBuffered{}}
+ return &StoreRecorder{Store: sr, Recorder: sr.Recorder}
+}
+func NewRecorderStream() *StoreRecorder {
+ sr := &storeRecorder{Recorder: testutil.NewRecorderStream()}
+ return &StoreRecorder{Store: sr, Recorder: sr.Recorder}
+}
+
+func (s *storeRecorder) Version() int { return 0 }
+func (s *storeRecorder) Index() uint64 { return 0 }
+func (s *storeRecorder) Get(path string, recursive, sorted bool) (*store.Event, error) {
+ s.Record(testutil.Action{
+ Name: "Get",
+ Params: []interface{}{path, recursive, sorted},
+ })
+ return &store.Event{}, nil
+}
+func (s *storeRecorder) Set(path string, dir bool, val string, expireOpts store.TTLOptionSet) (*store.Event, error) {
+ s.Record(testutil.Action{
+ Name: "Set",
+ Params: []interface{}{path, dir, val, expireOpts},
+ })
+ return &store.Event{}, nil
+}
+func (s *storeRecorder) Update(path, val string, expireOpts store.TTLOptionSet) (*store.Event, error) {
+ s.Record(testutil.Action{
+ Name: "Update",
+ Params: []interface{}{path, val, expireOpts},
+ })
+ return &store.Event{}, nil
+}
+func (s *storeRecorder) Create(path string, dir bool, val string, uniq bool, expireOpts store.TTLOptionSet) (*store.Event, error) {
+ s.Record(testutil.Action{
+ Name: "Create",
+ Params: []interface{}{path, dir, val, uniq, expireOpts},
+ })
+ return &store.Event{}, nil
+}
+func (s *storeRecorder) CompareAndSwap(path, prevVal string, prevIdx uint64, val string, expireOpts store.TTLOptionSet) (*store.Event, error) {
+ s.Record(testutil.Action{
+ Name: "CompareAndSwap",
+ Params: []interface{}{path, prevVal, prevIdx, val, expireOpts},
+ })
+ return &store.Event{}, nil
+}
+func (s *storeRecorder) Delete(path string, dir, recursive bool) (*store.Event, error) {
+ s.Record(testutil.Action{
+ Name: "Delete",
+ Params: []interface{}{path, dir, recursive},
+ })
+ return &store.Event{}, nil
+}
+func (s *storeRecorder) CompareAndDelete(path, prevVal string, prevIdx uint64) (*store.Event, error) {
+ s.Record(testutil.Action{
+ Name: "CompareAndDelete",
+ Params: []interface{}{path, prevVal, prevIdx},
+ })
+ return &store.Event{}, nil
+}
+func (s *storeRecorder) Watch(_ string, _, _ bool, _ uint64) (store.Watcher, error) {
+ s.Record(testutil.Action{Name: "Watch"})
+ return store.NewNopWatcher(), nil
+}
+func (s *storeRecorder) Save() ([]byte, error) {
+ s.Record(testutil.Action{Name: "Save"})
+ return nil, nil
+}
+func (s *storeRecorder) Recovery(b []byte) error {
+ s.Record(testutil.Action{Name: "Recovery"})
+ return nil
+}
+
+func (s *storeRecorder) SaveNoCopy() ([]byte, error) {
+ s.Record(testutil.Action{Name: "SaveNoCopy"})
+ return nil, nil
+}
+
+func (s *storeRecorder) Clone() store.Store {
+ s.Record(testutil.Action{Name: "Clone"})
+ return s
+}
+
+func (s *storeRecorder) JsonStats() []byte { return nil }
+func (s *storeRecorder) DeleteExpiredKeys(cutoff time.Time) {
+ s.Record(testutil.Action{
+ Name: "DeleteExpiredKeys",
+ Params: []interface{}{cutoff},
+ })
+}
+
+func (s *storeRecorder) HasTTLKeys() bool {
+ s.Record(testutil.Action{
+ Name: "HasTTLKeys",
+ })
+ return true
+}
+
+// errStoreRecorder is a storeRecorder, but returns the given error on
+// Get, Watch methods.
+type errStoreRecorder struct {
+ storeRecorder
+ err error
+}
+
+func NewErrRecorder(err error) *StoreRecorder {
+ sr := &errStoreRecorder{err: err}
+ sr.Recorder = &testutil.RecorderBuffered{}
+ return &StoreRecorder{Store: sr, Recorder: sr.Recorder}
+}
+
+func (s *errStoreRecorder) Get(path string, recursive, sorted bool) (*store.Event, error) {
+ s.storeRecorder.Get(path, recursive, sorted)
+ return nil, s.err
+}
+func (s *errStoreRecorder) Watch(path string, recursive, sorted bool, index uint64) (store.Watcher, error) {
+ s.storeRecorder.Watch(path, recursive, sorted, index)
+ return nil, s.err
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/mock/mockwait/doc.go b/vendor/github.com/coreos/etcd/pkg/mock/mockwait/doc.go
new file mode 100644
index 00000000..ac3c5d27
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/mock/mockwait/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 mockwait provides mock implementations for pkg/wait.
+package mockwait
diff --git a/vendor/github.com/coreos/etcd/pkg/mock/mockwait/wait_recorder.go b/vendor/github.com/coreos/etcd/pkg/mock/mockwait/wait_recorder.go
new file mode 100644
index 00000000..f9c82009
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/mock/mockwait/wait_recorder.go
@@ -0,0 +1,47 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 mockwait
+
+import (
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/pkg/wait"
+)
+
+type WaitRecorder struct {
+ wait.Wait
+ testutil.Recorder
+}
+
+type waitRecorder struct {
+ testutil.RecorderBuffered
+}
+
+func NewRecorder() *WaitRecorder {
+ wr := &waitRecorder{}
+ return &WaitRecorder{Wait: wr, Recorder: wr}
+}
+func NewNop() wait.Wait { return NewRecorder() }
+
+func (w *waitRecorder) Register(id uint64) <-chan interface{} {
+ w.Record(testutil.Action{Name: "Register"})
+ return nil
+}
+func (w *waitRecorder) Trigger(id uint64, x interface{}) {
+ w.Record(testutil.Action{Name: "Trigger"})
+}
+
+func (w *waitRecorder) IsRegistered(id uint64) bool {
+ panic("waitRecorder.IsRegistered() shouldn't be called")
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/monotime/issue15006.s b/vendor/github.com/coreos/etcd/pkg/monotime/issue15006.s
new file mode 100644
index 00000000..c3132a1f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/monotime/issue15006.s
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 Arista Networks, Inc.
+// Use of this source code is governed by the Apache License 2.0
+// that can be found in the COPYING file.
+
+// This file is intentionally empty.
+// It's a workaround for https://github.com/golang/go/issues/15006
\ No newline at end of file
diff --git a/vendor/github.com/coreos/etcd/pkg/monotime/monotime.go b/vendor/github.com/coreos/etcd/pkg/monotime/monotime.go
new file mode 100644
index 00000000..a5e16ce1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/monotime/monotime.go
@@ -0,0 +1,26 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 monotime
+
+import (
+ "time"
+)
+
+// Time represents a point in monotonic time
+type Time uint64
+
+func (t Time) Add(d time.Duration) Time {
+ return Time(uint64(t) + uint64(d.Nanoseconds()))
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/monotime/nanotime.go b/vendor/github.com/coreos/etcd/pkg/monotime/nanotime.go
new file mode 100644
index 00000000..e3fc846e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/monotime/nanotime.go
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 Arista Networks, Inc.
+// Use of this source code is governed by the Apache License 2.0
+// that can be found in the COPYING file.
+
+// Package monotime provides a fast monotonic clock source.
+package monotime
+
+import (
+ _ "unsafe" // required to use //go:linkname
+)
+
+//go:noescape
+//go:linkname nanotime runtime.nanotime
+func nanotime() int64
+
+// Now returns the current time in nanoseconds from a monotonic clock.
+// The time returned is based on some arbitrary platform-specific point in the
+// past. The time returned is guaranteed to increase monotonically at a
+// constant rate, unlike time.Now() from the Go standard library, which may
+// slow down, speed up, jump forward or backward, due to NTP activity or leap
+// seconds.
+func Now() Time {
+ return Time(nanotime())
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/monotime/nanotime_test.go b/vendor/github.com/coreos/etcd/pkg/monotime/nanotime_test.go
new file mode 100644
index 00000000..c22b328b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/monotime/nanotime_test.go
@@ -0,0 +1,22 @@
+// Copyright (C) 2016 Arista Networks, Inc.
+// Use of this source code is governed by the Apache License 2.0
+
+// Package monotime provides a fast monotonic clock source.
+
+package monotime
+
+import (
+ "testing"
+)
+
+func TestNow(t *testing.T) {
+ for i := 0; i < 100; i++ {
+ t1 := Now()
+ t2 := Now()
+ // I honestly thought that we needed >= here, but in some environments
+ // two consecutive calls can return the same value!
+ if t1 > t2 {
+ t.Fatalf("t1=%d should have been less than or equal to t2=%d", t1, t2)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/netutil/isolate_linux.go b/vendor/github.com/coreos/etcd/pkg/netutil/isolate_linux.go
new file mode 100644
index 00000000..418580ac
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/netutil/isolate_linux.go
@@ -0,0 +1,82 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 netutil
+
+import (
+ "fmt"
+ "os/exec"
+)
+
+// DropPort drops all tcp packets that are received from the given port and sent to the given port.
+func DropPort(port int) error {
+ cmdStr := fmt.Sprintf("sudo iptables -A OUTPUT -p tcp --destination-port %d -j DROP", port)
+ if _, err := exec.Command("/bin/sh", "-c", cmdStr).Output(); err != nil {
+ return err
+ }
+ cmdStr = fmt.Sprintf("sudo iptables -A INPUT -p tcp --destination-port %d -j DROP", port)
+ _, err := exec.Command("/bin/sh", "-c", cmdStr).Output()
+ return err
+}
+
+// RecoverPort stops dropping tcp packets at given port.
+func RecoverPort(port int) error {
+ cmdStr := fmt.Sprintf("sudo iptables -D OUTPUT -p tcp --destination-port %d -j DROP", port)
+ if _, err := exec.Command("/bin/sh", "-c", cmdStr).Output(); err != nil {
+ return err
+ }
+ cmdStr = fmt.Sprintf("sudo iptables -D INPUT -p tcp --destination-port %d -j DROP", port)
+ _, err := exec.Command("/bin/sh", "-c", cmdStr).Output()
+ return err
+}
+
+// SetLatency adds latency in millisecond scale with random variations.
+func SetLatency(ms, rv int) error {
+ ifces, err := GetDefaultInterfaces()
+ if err != nil {
+ return err
+ }
+
+ if rv > ms {
+ rv = 1
+ }
+ for ifce := range ifces {
+ cmdStr := fmt.Sprintf("sudo tc qdisc add dev %s root netem delay %dms %dms distribution normal", ifce, ms, rv)
+ _, err = exec.Command("/bin/sh", "-c", cmdStr).Output()
+ if err != nil {
+ // the rule has already been added. Overwrite it.
+ cmdStr = fmt.Sprintf("sudo tc qdisc change dev %s root netem delay %dms %dms distribution normal", ifce, ms, rv)
+ _, err = exec.Command("/bin/sh", "-c", cmdStr).Output()
+ if err != nil {
+ return err
+ }
+ }
+ }
+ return nil
+}
+
+// RemoveLatency resets latency configurations.
+func RemoveLatency() error {
+ ifces, err := GetDefaultInterfaces()
+ if err != nil {
+ return err
+ }
+ for ifce := range ifces {
+ _, err = exec.Command("/bin/sh", "-c", fmt.Sprintf("sudo tc qdisc del dev %s root netem", ifce)).Output()
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/netutil/isolate_stub.go b/vendor/github.com/coreos/etcd/pkg/netutil/isolate_stub.go
new file mode 100644
index 00000000..7f4c3e67
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/netutil/isolate_stub.go
@@ -0,0 +1,25 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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.
+
+// +build !linux
+
+package netutil
+
+func DropPort(port int) error { return nil }
+
+func RecoverPort(port int) error { return nil }
+
+func SetLatency(ms, rv int) error { return nil }
+
+func RemoveLatency() error { return nil }
diff --git a/vendor/github.com/coreos/etcd/pkg/netutil/netutil.go b/vendor/github.com/coreos/etcd/pkg/netutil/netutil.go
new file mode 100644
index 00000000..5e38dc98
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/netutil/netutil.go
@@ -0,0 +1,169 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 netutil implements network-related utility functions.
+package netutil
+
+import (
+ "context"
+ "net"
+ "net/url"
+ "reflect"
+ "sort"
+ "time"
+
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/pkg/capnslog"
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "pkg/netutil")
+
+ // indirection for testing
+ resolveTCPAddr = resolveTCPAddrDefault
+)
+
+const retryInterval = time.Second
+
+// taken from go's ResolveTCP code but uses configurable ctx
+func resolveTCPAddrDefault(ctx context.Context, addr string) (*net.TCPAddr, error) {
+ host, port, serr := net.SplitHostPort(addr)
+ if serr != nil {
+ return nil, serr
+ }
+ portnum, perr := net.DefaultResolver.LookupPort(ctx, "tcp", port)
+ if perr != nil {
+ return nil, perr
+ }
+
+ var ips []net.IPAddr
+ if ip := net.ParseIP(host); ip != nil {
+ ips = []net.IPAddr{{IP: ip}}
+ } else {
+ // Try as a DNS name.
+ ipss, err := net.DefaultResolver.LookupIPAddr(ctx, host)
+ if err != nil {
+ return nil, err
+ }
+ ips = ipss
+ }
+ // randomize?
+ ip := ips[0]
+ return &net.TCPAddr{IP: ip.IP, Port: portnum, Zone: ip.Zone}, nil
+}
+
+// resolveTCPAddrs is a convenience wrapper for net.ResolveTCPAddr.
+// resolveTCPAddrs return a new set of url.URLs, in which all DNS hostnames
+// are resolved.
+func resolveTCPAddrs(ctx context.Context, urls [][]url.URL) ([][]url.URL, error) {
+ newurls := make([][]url.URL, 0)
+ for _, us := range urls {
+ nus := make([]url.URL, len(us))
+ for i, u := range us {
+ nu, err := url.Parse(u.String())
+ if err != nil {
+ return nil, err
+ }
+ nus[i] = *nu
+ }
+ for i, u := range nus {
+ h, err := resolveURL(ctx, u)
+ if err != nil {
+ return nil, err
+ }
+ if h != "" {
+ nus[i].Host = h
+ }
+ }
+ newurls = append(newurls, nus)
+ }
+ return newurls, nil
+}
+
+func resolveURL(ctx context.Context, u url.URL) (string, error) {
+ for ctx.Err() == nil {
+ host, _, err := net.SplitHostPort(u.Host)
+ if err != nil {
+ plog.Errorf("could not parse url %s during tcp resolving", u.Host)
+ return "", err
+ }
+ if host == "localhost" || net.ParseIP(host) != nil {
+ return "", nil
+ }
+ tcpAddr, err := resolveTCPAddr(ctx, u.Host)
+ if err == nil {
+ plog.Infof("resolving %s to %s", u.Host, tcpAddr.String())
+ return tcpAddr.String(), nil
+ }
+ plog.Warningf("failed resolving host %s (%v); retrying in %v", u.Host, err, retryInterval)
+ select {
+ case <-ctx.Done():
+ plog.Errorf("could not resolve host %s", u.Host)
+ return "", err
+ case <-time.After(retryInterval):
+ }
+ }
+ return "", ctx.Err()
+}
+
+// urlsEqual checks equality of url.URLS between two arrays.
+// This check pass even if an URL is in hostname and opposite is in IP address.
+func urlsEqual(ctx context.Context, a []url.URL, b []url.URL) bool {
+ if len(a) != len(b) {
+ return false
+ }
+ urls, err := resolveTCPAddrs(ctx, [][]url.URL{a, b})
+ if err != nil {
+ return false
+ }
+ a, b = urls[0], urls[1]
+ sort.Sort(types.URLs(a))
+ sort.Sort(types.URLs(b))
+ for i := range a {
+ if !reflect.DeepEqual(a[i], b[i]) {
+ return false
+ }
+ }
+
+ return true
+}
+
+func URLStringsEqual(ctx context.Context, a []string, b []string) bool {
+ if len(a) != len(b) {
+ return false
+ }
+ urlsA := make([]url.URL, 0)
+ for _, str := range a {
+ u, err := url.Parse(str)
+ if err != nil {
+ return false
+ }
+ urlsA = append(urlsA, *u)
+ }
+ urlsB := make([]url.URL, 0)
+ for _, str := range b {
+ u, err := url.Parse(str)
+ if err != nil {
+ return false
+ }
+ urlsB = append(urlsB, *u)
+ }
+
+ return urlsEqual(ctx, urlsA, urlsB)
+}
+
+func IsNetworkTimeoutError(err error) bool {
+ nerr, ok := err.(net.Error)
+ return ok && nerr.Timeout()
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/netutil/netutil_test.go b/vendor/github.com/coreos/etcd/pkg/netutil/netutil_test.go
new file mode 100644
index 00000000..82abe6d1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/netutil/netutil_test.go
@@ -0,0 +1,265 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 netutil
+
+import (
+ "context"
+ "errors"
+ "net"
+ "net/url"
+ "reflect"
+ "strconv"
+ "testing"
+ "time"
+)
+
+func TestResolveTCPAddrs(t *testing.T) {
+ defer func() { resolveTCPAddr = resolveTCPAddrDefault }()
+ tests := []struct {
+ urls [][]url.URL
+ expected [][]url.URL
+ hostMap map[string]string
+ hasError bool
+ }{
+ {
+ urls: [][]url.URL{
+ {
+ {Scheme: "http", Host: "127.0.0.1:4001"},
+ {Scheme: "http", Host: "127.0.0.1:2379"},
+ },
+ {
+ {Scheme: "http", Host: "127.0.0.1:7001"},
+ {Scheme: "http", Host: "127.0.0.1:2380"},
+ },
+ },
+ expected: [][]url.URL{
+ {
+ {Scheme: "http", Host: "127.0.0.1:4001"},
+ {Scheme: "http", Host: "127.0.0.1:2379"},
+ },
+ {
+ {Scheme: "http", Host: "127.0.0.1:7001"},
+ {Scheme: "http", Host: "127.0.0.1:2380"},
+ },
+ },
+ },
+ {
+ urls: [][]url.URL{
+ {
+ {Scheme: "http", Host: "infra0.example.com:4001"},
+ {Scheme: "http", Host: "infra0.example.com:2379"},
+ },
+ {
+ {Scheme: "http", Host: "infra0.example.com:7001"},
+ {Scheme: "http", Host: "infra0.example.com:2380"},
+ },
+ },
+ expected: [][]url.URL{
+ {
+ {Scheme: "http", Host: "10.0.1.10:4001"},
+ {Scheme: "http", Host: "10.0.1.10:2379"},
+ },
+ {
+ {Scheme: "http", Host: "10.0.1.10:7001"},
+ {Scheme: "http", Host: "10.0.1.10:2380"},
+ },
+ },
+ hostMap: map[string]string{
+ "infra0.example.com": "10.0.1.10",
+ },
+ hasError: false,
+ },
+ {
+ urls: [][]url.URL{
+ {
+ {Scheme: "http", Host: "infra0.example.com:4001"},
+ {Scheme: "http", Host: "infra0.example.com:2379"},
+ },
+ {
+ {Scheme: "http", Host: "infra0.example.com:7001"},
+ {Scheme: "http", Host: "infra0.example.com:2380"},
+ },
+ },
+ hostMap: map[string]string{
+ "infra0.example.com": "",
+ },
+ hasError: true,
+ },
+ {
+ urls: [][]url.URL{
+ {
+ {Scheme: "http", Host: "ssh://infra0.example.com:4001"},
+ {Scheme: "http", Host: "ssh://infra0.example.com:2379"},
+ },
+ {
+ {Scheme: "http", Host: "ssh://infra0.example.com:7001"},
+ {Scheme: "http", Host: "ssh://infra0.example.com:2380"},
+ },
+ },
+ hasError: true,
+ },
+ }
+ for _, tt := range tests {
+ resolveTCPAddr = func(ctx context.Context, addr string) (*net.TCPAddr, error) {
+ host, port, err := net.SplitHostPort(addr)
+ if err != nil {
+ return nil, err
+ }
+ if tt.hostMap[host] == "" {
+ return nil, errors.New("cannot resolve host.")
+ }
+ i, err := strconv.Atoi(port)
+ if err != nil {
+ return nil, err
+ }
+ return &net.TCPAddr{IP: net.ParseIP(tt.hostMap[host]), Port: i, Zone: ""}, nil
+ }
+ ctx, cancel := context.WithTimeout(context.TODO(), time.Second)
+ urls, err := resolveTCPAddrs(ctx, tt.urls)
+ cancel()
+ if tt.hasError {
+ if err == nil {
+ t.Errorf("expected error")
+ }
+ continue
+ }
+ if !reflect.DeepEqual(urls, tt.expected) {
+ t.Errorf("expected: %v, got %v", tt.expected, urls)
+ }
+ }
+}
+
+func TestURLsEqual(t *testing.T) {
+ defer func() { resolveTCPAddr = resolveTCPAddrDefault }()
+ hostm := map[string]string{
+ "example.com": "10.0.10.1",
+ "first.com": "10.0.11.1",
+ "second.com": "10.0.11.2",
+ }
+ resolveTCPAddr = func(ctx context.Context, addr string) (*net.TCPAddr, error) {
+ host, port, herr := net.SplitHostPort(addr)
+ if herr != nil {
+ return nil, herr
+ }
+ if _, ok := hostm[host]; !ok {
+ return nil, errors.New("cannot resolve host.")
+ }
+ i, err := strconv.Atoi(port)
+ if err != nil {
+ return nil, err
+ }
+ return &net.TCPAddr{IP: net.ParseIP(hostm[host]), Port: i, Zone: ""}, nil
+ }
+
+ tests := []struct {
+ a []url.URL
+ b []url.URL
+ expect bool
+ }{
+ {
+ a: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}},
+ b: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}},
+ expect: true,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "example.com:2379"}},
+ b: []url.URL{{Scheme: "http", Host: "10.0.10.1:2379"}},
+ expect: true,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ b: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ expect: true,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "example.com:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ b: []url.URL{{Scheme: "http", Host: "example.com:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ expect: true,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "10.0.10.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ b: []url.URL{{Scheme: "http", Host: "example.com:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ expect: true,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}},
+ b: []url.URL{{Scheme: "http", Host: "127.0.0.1:2380"}},
+ expect: false,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "example.com:2380"}},
+ b: []url.URL{{Scheme: "http", Host: "10.0.10.1:2379"}},
+ expect: false,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}},
+ b: []url.URL{{Scheme: "http", Host: "10.0.0.1:2379"}},
+ expect: false,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "example.com:2379"}},
+ b: []url.URL{{Scheme: "http", Host: "10.0.0.1:2379"}},
+ expect: false,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ b: []url.URL{{Scheme: "http", Host: "127.0.0.1:2380"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ expect: false,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "example.com:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ b: []url.URL{{Scheme: "http", Host: "127.0.0.1:2380"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ expect: false,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ b: []url.URL{{Scheme: "http", Host: "10.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ expect: false,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "example.com:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ b: []url.URL{{Scheme: "http", Host: "10.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ expect: false,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "10.0.0.1:2379"}},
+ b: []url.URL{{Scheme: "http", Host: "10.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}},
+ expect: false,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "first.com:2379"}, {Scheme: "http", Host: "second.com:2380"}},
+ b: []url.URL{{Scheme: "http", Host: "10.0.11.1:2379"}, {Scheme: "http", Host: "10.0.11.2:2380"}},
+ expect: true,
+ },
+ {
+ a: []url.URL{{Scheme: "http", Host: "second.com:2380"}, {Scheme: "http", Host: "first.com:2379"}},
+ b: []url.URL{{Scheme: "http", Host: "10.0.11.1:2379"}, {Scheme: "http", Host: "10.0.11.2:2380"}},
+ expect: true,
+ },
+ }
+
+ for _, test := range tests {
+ result := urlsEqual(context.TODO(), test.a, test.b)
+ if result != test.expect {
+ t.Errorf("a:%v b:%v, expected %v but %v", test.a, test.b, test.expect, result)
+ }
+ }
+}
+func TestURLStringsEqual(t *testing.T) {
+ result := URLStringsEqual(context.TODO(), []string{"http://127.0.0.1:8080"}, []string{"http://127.0.0.1:8080"})
+ if !result {
+ t.Errorf("unexpected result %v", result)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/netutil/routes.go b/vendor/github.com/coreos/etcd/pkg/netutil/routes.go
new file mode 100644
index 00000000..3eb6a19e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/netutil/routes.go
@@ -0,0 +1,33 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build !linux
+
+package netutil
+
+import (
+ "fmt"
+ "runtime"
+)
+
+// GetDefaultHost fetches the a resolvable name that corresponds
+// to the machine's default routable interface
+func GetDefaultHost() (string, error) {
+ return "", fmt.Errorf("default host not supported on %s_%s", runtime.GOOS, runtime.GOARCH)
+}
+
+// GetDefaultInterfaces fetches the device name of default routable interface.
+func GetDefaultInterfaces() (map[string]uint8, error) {
+ return nil, fmt.Errorf("default host not supported on %s_%s", runtime.GOOS, runtime.GOARCH)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/netutil/routes_linux.go b/vendor/github.com/coreos/etcd/pkg/netutil/routes_linux.go
new file mode 100644
index 00000000..5d234d46
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/netutil/routes_linux.go
@@ -0,0 +1,250 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build linux
+
+package netutil
+
+import (
+ "bytes"
+ "encoding/binary"
+ "fmt"
+ "net"
+ "sort"
+ "syscall"
+
+ "github.com/coreos/etcd/pkg/cpuutil"
+)
+
+var errNoDefaultRoute = fmt.Errorf("could not find default route")
+var errNoDefaultHost = fmt.Errorf("could not find default host")
+var errNoDefaultInterface = fmt.Errorf("could not find default interface")
+
+// GetDefaultHost obtains the first IP address of machine from the routing table and returns the IP address as string.
+// An IPv4 address is preferred to an IPv6 address for backward compatibility.
+func GetDefaultHost() (string, error) {
+ rmsgs, rerr := getDefaultRoutes()
+ if rerr != nil {
+ return "", rerr
+ }
+
+ // prioritize IPv4
+ if rmsg, ok := rmsgs[syscall.AF_INET]; ok {
+ if host, err := chooseHost(syscall.AF_INET, rmsg); host != "" || err != nil {
+ return host, err
+ }
+ delete(rmsgs, syscall.AF_INET)
+ }
+
+ // sort so choice is deterministic
+ var families []int
+ for family := range rmsgs {
+ families = append(families, int(family))
+ }
+ sort.Ints(families)
+
+ for _, f := range families {
+ family := uint8(f)
+ if host, err := chooseHost(family, rmsgs[family]); host != "" || err != nil {
+ return host, err
+ }
+ }
+
+ return "", errNoDefaultHost
+}
+
+func chooseHost(family uint8, rmsg *syscall.NetlinkMessage) (string, error) {
+ host, oif, err := parsePREFSRC(rmsg)
+ if host != "" || err != nil {
+ return host, err
+ }
+
+ // prefsrc not detected, fall back to getting address from iface
+ ifmsg, ierr := getIfaceAddr(oif, family)
+ if ierr != nil {
+ return "", ierr
+ }
+
+ attrs, aerr := syscall.ParseNetlinkRouteAttr(ifmsg)
+ if aerr != nil {
+ return "", aerr
+ }
+
+ for _, attr := range attrs {
+ // search for RTA_DST because ipv6 doesn't have RTA_SRC
+ if attr.Attr.Type == syscall.RTA_DST {
+ return net.IP(attr.Value).String(), nil
+ }
+ }
+
+ return "", nil
+}
+
+func getDefaultRoutes() (map[uint8]*syscall.NetlinkMessage, error) {
+ dat, err := syscall.NetlinkRIB(syscall.RTM_GETROUTE, syscall.AF_UNSPEC)
+ if err != nil {
+ return nil, err
+ }
+
+ msgs, msgErr := syscall.ParseNetlinkMessage(dat)
+ if msgErr != nil {
+ return nil, msgErr
+ }
+
+ routes := make(map[uint8]*syscall.NetlinkMessage)
+ rtmsg := syscall.RtMsg{}
+ for _, m := range msgs {
+ if m.Header.Type != syscall.RTM_NEWROUTE {
+ continue
+ }
+ buf := bytes.NewBuffer(m.Data[:syscall.SizeofRtMsg])
+ if rerr := binary.Read(buf, cpuutil.ByteOrder(), &rtmsg); rerr != nil {
+ continue
+ }
+ if rtmsg.Dst_len == 0 && rtmsg.Table == syscall.RT_TABLE_MAIN {
+ // zero-length Dst_len implies default route
+ msg := m
+ routes[rtmsg.Family] = &msg
+ }
+ }
+
+ if len(routes) > 0 {
+ return routes, nil
+ }
+
+ return nil, errNoDefaultRoute
+}
+
+// Used to get an address of interface.
+func getIfaceAddr(idx uint32, family uint8) (*syscall.NetlinkMessage, error) {
+ dat, err := syscall.NetlinkRIB(syscall.RTM_GETADDR, int(family))
+ if err != nil {
+ return nil, err
+ }
+
+ msgs, msgErr := syscall.ParseNetlinkMessage(dat)
+ if msgErr != nil {
+ return nil, msgErr
+ }
+
+ ifaddrmsg := syscall.IfAddrmsg{}
+ for _, m := range msgs {
+ if m.Header.Type != syscall.RTM_NEWADDR {
+ continue
+ }
+ buf := bytes.NewBuffer(m.Data[:syscall.SizeofIfAddrmsg])
+ if rerr := binary.Read(buf, cpuutil.ByteOrder(), &ifaddrmsg); rerr != nil {
+ continue
+ }
+ if ifaddrmsg.Index == idx {
+ return &m, nil
+ }
+ }
+
+ return nil, fmt.Errorf("could not find address for interface index %v", idx)
+
+}
+
+// Used to get a name of interface.
+func getIfaceLink(idx uint32) (*syscall.NetlinkMessage, error) {
+ dat, err := syscall.NetlinkRIB(syscall.RTM_GETLINK, syscall.AF_UNSPEC)
+ if err != nil {
+ return nil, err
+ }
+
+ msgs, msgErr := syscall.ParseNetlinkMessage(dat)
+ if msgErr != nil {
+ return nil, msgErr
+ }
+
+ ifinfomsg := syscall.IfInfomsg{}
+ for _, m := range msgs {
+ if m.Header.Type != syscall.RTM_NEWLINK {
+ continue
+ }
+ buf := bytes.NewBuffer(m.Data[:syscall.SizeofIfInfomsg])
+ if rerr := binary.Read(buf, cpuutil.ByteOrder(), &ifinfomsg); rerr != nil {
+ continue
+ }
+ if ifinfomsg.Index == int32(idx) {
+ return &m, nil
+ }
+ }
+
+ return nil, fmt.Errorf("could not find link for interface index %v", idx)
+}
+
+// GetDefaultInterfaces gets names of interfaces and returns a map[interface]families.
+func GetDefaultInterfaces() (map[string]uint8, error) {
+ interfaces := make(map[string]uint8)
+ rmsgs, rerr := getDefaultRoutes()
+ if rerr != nil {
+ return interfaces, rerr
+ }
+
+ for family, rmsg := range rmsgs {
+ _, oif, err := parsePREFSRC(rmsg)
+ if err != nil {
+ return interfaces, err
+ }
+
+ ifmsg, ierr := getIfaceLink(oif)
+ if ierr != nil {
+ return interfaces, ierr
+ }
+
+ attrs, aerr := syscall.ParseNetlinkRouteAttr(ifmsg)
+ if aerr != nil {
+ return interfaces, aerr
+ }
+
+ for _, attr := range attrs {
+ if attr.Attr.Type == syscall.IFLA_IFNAME {
+ // key is an interface name
+ // possible values: 2 - AF_INET, 10 - AF_INET6, 12 - dualstack
+ interfaces[string(attr.Value[:len(attr.Value)-1])] += family
+ }
+ }
+ }
+ if len(interfaces) > 0 {
+ return interfaces, nil
+ }
+ return interfaces, errNoDefaultInterface
+}
+
+// parsePREFSRC returns preferred source address and output interface index (RTA_OIF).
+func parsePREFSRC(m *syscall.NetlinkMessage) (host string, oif uint32, err error) {
+ var attrs []syscall.NetlinkRouteAttr
+ attrs, err = syscall.ParseNetlinkRouteAttr(m)
+ if err != nil {
+ return "", 0, err
+ }
+
+ for _, attr := range attrs {
+ if attr.Attr.Type == syscall.RTA_PREFSRC {
+ host = net.IP(attr.Value).String()
+ }
+ if attr.Attr.Type == syscall.RTA_OIF {
+ oif = cpuutil.ByteOrder().Uint32(attr.Value)
+ }
+ if host != "" && oif != uint32(0) {
+ break
+ }
+ }
+
+ if oif == 0 {
+ err = errNoDefaultRoute
+ }
+ return
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/netutil/routes_linux_test.go b/vendor/github.com/coreos/etcd/pkg/netutil/routes_linux_test.go
new file mode 100644
index 00000000..707fd2d8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/netutil/routes_linux_test.go
@@ -0,0 +1,35 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build linux
+
+package netutil
+
+import "testing"
+
+func TestGetDefaultInterface(t *testing.T) {
+ ifc, err := GetDefaultInterfaces()
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Logf("default network interfaces: %+v\n", ifc)
+}
+
+func TestGetDefaultHost(t *testing.T) {
+ ip, err := GetDefaultHost()
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Logf("default ip: %v", ip)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/osutil/interrupt_unix.go b/vendor/github.com/coreos/etcd/pkg/osutil/interrupt_unix.go
new file mode 100644
index 00000000..b9feaffc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/osutil/interrupt_unix.go
@@ -0,0 +1,80 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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.
+
+// +build !windows,!plan9
+
+package osutil
+
+import (
+ "os"
+ "os/signal"
+ "sync"
+ "syscall"
+)
+
+// InterruptHandler is a function that is called on receiving a
+// SIGTERM or SIGINT signal.
+type InterruptHandler func()
+
+var (
+ interruptRegisterMu, interruptExitMu sync.Mutex
+ // interruptHandlers holds all registered InterruptHandlers in order
+ // they will be executed.
+ interruptHandlers = []InterruptHandler{}
+)
+
+// RegisterInterruptHandler registers a new InterruptHandler. Handlers registered
+// after interrupt handing was initiated will not be executed.
+func RegisterInterruptHandler(h InterruptHandler) {
+ interruptRegisterMu.Lock()
+ defer interruptRegisterMu.Unlock()
+ interruptHandlers = append(interruptHandlers, h)
+}
+
+// HandleInterrupts calls the handler functions on receiving a SIGINT or SIGTERM.
+func HandleInterrupts() {
+ notifier := make(chan os.Signal, 1)
+ signal.Notify(notifier, syscall.SIGINT, syscall.SIGTERM)
+
+ go func() {
+ sig := <-notifier
+
+ interruptRegisterMu.Lock()
+ ihs := make([]InterruptHandler, len(interruptHandlers))
+ copy(ihs, interruptHandlers)
+ interruptRegisterMu.Unlock()
+
+ interruptExitMu.Lock()
+
+ plog.Noticef("received %v signal, shutting down...", sig)
+
+ for _, h := range ihs {
+ h()
+ }
+ signal.Stop(notifier)
+ pid := syscall.Getpid()
+ // exit directly if it is the "init" process, since the kernel will not help to kill pid 1.
+ if pid == 1 {
+ os.Exit(0)
+ }
+ setDflSignal(sig.(syscall.Signal))
+ syscall.Kill(pid, sig.(syscall.Signal))
+ }()
+}
+
+// Exit relays to os.Exit if no interrupt handlers are running, blocks otherwise.
+func Exit(code int) {
+ interruptExitMu.Lock()
+ os.Exit(code)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/osutil/interrupt_windows.go b/vendor/github.com/coreos/etcd/pkg/osutil/interrupt_windows.go
new file mode 100644
index 00000000..013ae88e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/osutil/interrupt_windows.go
@@ -0,0 +1,32 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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.
+
+// +build windows
+
+package osutil
+
+import "os"
+
+type InterruptHandler func()
+
+// RegisterInterruptHandler is a no-op on windows
+func RegisterInterruptHandler(h InterruptHandler) {}
+
+// HandleInterrupts is a no-op on windows
+func HandleInterrupts() {}
+
+// Exit calls os.Exit
+func Exit(code int) {
+ os.Exit(code)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/osutil/osutil.go b/vendor/github.com/coreos/etcd/pkg/osutil/osutil.go
new file mode 100644
index 00000000..ef38280e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/osutil/osutil.go
@@ -0,0 +1,45 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 osutil implements operating system-related utility functions.
+package osutil
+
+import (
+ "os"
+ "strings"
+
+ "github.com/coreos/pkg/capnslog"
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "pkg/osutil")
+
+ // support to override setting SIG_DFL so tests don't terminate early
+ setDflSignal = dflSignal
+)
+
+func Unsetenv(key string) error {
+ envs := os.Environ()
+ os.Clearenv()
+ for _, e := range envs {
+ strs := strings.SplitN(e, "=", 2)
+ if strs[0] == key {
+ continue
+ }
+ if err := os.Setenv(strs[0], strs[1]); err != nil {
+ return err
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/osutil/osutil_test.go b/vendor/github.com/coreos/etcd/pkg/osutil/osutil_test.go
new file mode 100644
index 00000000..9fbc7a44
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/osutil/osutil_test.go
@@ -0,0 +1,90 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 osutil
+
+import (
+ "os"
+ "os/signal"
+ "reflect"
+ "syscall"
+ "testing"
+ "time"
+)
+
+func init() { setDflSignal = func(syscall.Signal) {} }
+
+func TestUnsetenv(t *testing.T) {
+ tests := []string{
+ "data",
+ "space data",
+ "equal=data",
+ }
+ for i, tt := range tests {
+ key := "ETCD_UNSETENV_TEST"
+ if os.Getenv(key) != "" {
+ t.Fatalf("#%d: cannot get empty %s", i, key)
+ }
+ env := os.Environ()
+ if err := os.Setenv(key, tt); err != nil {
+ t.Fatalf("#%d: cannot set %s: %v", i, key, err)
+ }
+ if err := Unsetenv(key); err != nil {
+ t.Errorf("#%d: unsetenv %s error: %v", i, key, err)
+ }
+ if g := os.Environ(); !reflect.DeepEqual(g, env) {
+ t.Errorf("#%d: env = %+v, want %+v", i, g, env)
+ }
+ }
+}
+
+func waitSig(t *testing.T, c <-chan os.Signal, sig os.Signal) {
+ select {
+ case s := <-c:
+ if s != sig {
+ t.Fatalf("signal was %v, want %v", s, sig)
+ }
+ case <-time.After(1 * time.Second):
+ t.Fatalf("timeout waiting for %v", sig)
+ }
+}
+
+func TestHandleInterrupts(t *testing.T) {
+ for _, sig := range []syscall.Signal{syscall.SIGINT, syscall.SIGTERM} {
+ n := 1
+ RegisterInterruptHandler(func() { n++ })
+ RegisterInterruptHandler(func() { n *= 2 })
+
+ c := make(chan os.Signal, 2)
+ signal.Notify(c, sig)
+
+ HandleInterrupts()
+ syscall.Kill(syscall.Getpid(), sig)
+
+ // we should receive the signal once from our own kill and
+ // a second time from HandleInterrupts
+ waitSig(t, c, sig)
+ waitSig(t, c, sig)
+
+ if n == 3 {
+ t.Fatalf("interrupt handlers were called in wrong order")
+ }
+ if n != 4 {
+ t.Fatalf("interrupt handlers were not called properly")
+ }
+ // reset interrupt handlers
+ interruptHandlers = interruptHandlers[:0]
+ interruptExitMu.Unlock()
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/osutil/signal.go b/vendor/github.com/coreos/etcd/pkg/osutil/signal.go
new file mode 100644
index 00000000..687397fd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/osutil/signal.go
@@ -0,0 +1,21 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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.
+
+// +build !linux cov
+
+package osutil
+
+import "syscall"
+
+func dflSignal(sig syscall.Signal) { /* nop */ }
diff --git a/vendor/github.com/coreos/etcd/pkg/osutil/signal_linux.go b/vendor/github.com/coreos/etcd/pkg/osutil/signal_linux.go
new file mode 100644
index 00000000..b94d80c5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/osutil/signal_linux.go
@@ -0,0 +1,30 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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.
+
+// +build linux,!cov
+
+package osutil
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+// dflSignal sets the given signal to SIG_DFL
+func dflSignal(sig syscall.Signal) {
+ // clearing out the sigact sets the signal to SIG_DFL
+ var sigactBuf [32]uint64
+ ptr := unsafe.Pointer(&sigactBuf)
+ syscall.Syscall6(uintptr(syscall.SYS_RT_SIGACTION), uintptr(sig), uintptr(ptr), 0, 8, 0, 0)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/pathutil/path.go b/vendor/github.com/coreos/etcd/pkg/pathutil/path.go
new file mode 100644
index 00000000..f26254ba
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/pathutil/path.go
@@ -0,0 +1,31 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package pathutil implements utility functions for handling slash-separated
+// paths.
+package pathutil
+
+import "path"
+
+// CanonicalURLPath returns the canonical url path for p, which follows the rules:
+// 1. the path always starts with "/"
+// 2. replace multiple slashes with a single slash
+// 3. replace each '.' '..' path name element with equivalent one
+// 4. keep the trailing slash
+// The function is borrowed from stdlib http.cleanPath in server.go.
+func CanonicalURLPath(p string) string {
+ if p == "" {
+ return "/"
+ }
+ if p[0] != '/' {
+ p = "/" + p
+ }
+ np := path.Clean(p)
+ // path.Clean removes trailing slash except for root,
+ // put the trailing slash back if necessary.
+ if p[len(p)-1] == '/' && np != "/" {
+ np += "/"
+ }
+ return np
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/pathutil/path_test.go b/vendor/github.com/coreos/etcd/pkg/pathutil/path_test.go
new file mode 100644
index 00000000..209fdc93
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/pathutil/path_test.go
@@ -0,0 +1,38 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 pathutil
+
+import "testing"
+
+func TestCanonicalURLPath(t *testing.T) {
+ tests := []struct {
+ p string
+ wp string
+ }{
+ {"/a", "/a"},
+ {"", "/"},
+ {"a", "/a"},
+ {"//a", "/a"},
+ {"/a/.", "/a"},
+ {"/a/..", "/"},
+ {"/a/", "/a/"},
+ {"/a//", "/a/"},
+ }
+ for i, tt := range tests {
+ if g := CanonicalURLPath(tt.p); g != tt.wp {
+ t.Errorf("#%d: canonical path = %s, want %s", i, g, tt.wp)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/pbutil/pbutil.go b/vendor/github.com/coreos/etcd/pkg/pbutil/pbutil.go
new file mode 100644
index 00000000..d70f98dd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/pbutil/pbutil.go
@@ -0,0 +1,60 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 pbutil defines interfaces for handling Protocol Buffer objects.
+package pbutil
+
+import "github.com/coreos/pkg/capnslog"
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "pkg/pbutil")
+)
+
+type Marshaler interface {
+ Marshal() (data []byte, err error)
+}
+
+type Unmarshaler interface {
+ Unmarshal(data []byte) error
+}
+
+func MustMarshal(m Marshaler) []byte {
+ d, err := m.Marshal()
+ if err != nil {
+ plog.Panicf("marshal should never fail (%v)", err)
+ }
+ return d
+}
+
+func MustUnmarshal(um Unmarshaler, data []byte) {
+ if err := um.Unmarshal(data); err != nil {
+ plog.Panicf("unmarshal should never fail (%v)", err)
+ }
+}
+
+func MaybeUnmarshal(um Unmarshaler, data []byte) bool {
+ if err := um.Unmarshal(data); err != nil {
+ return false
+ }
+ return true
+}
+
+func GetBool(v *bool) (vv bool, set bool) {
+ if v == nil {
+ return false, false
+ }
+ return *v, true
+}
+
+func Boolp(b bool) *bool { return &b }
diff --git a/vendor/github.com/coreos/etcd/pkg/pbutil/pbutil_test.go b/vendor/github.com/coreos/etcd/pkg/pbutil/pbutil_test.go
new file mode 100644
index 00000000..fd361ec5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/pbutil/pbutil_test.go
@@ -0,0 +1,98 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 pbutil
+
+import (
+ "errors"
+ "reflect"
+ "testing"
+)
+
+func TestMarshaler(t *testing.T) {
+ data := []byte("test data")
+ m := &fakeMarshaler{data: data}
+ if g := MustMarshal(m); !reflect.DeepEqual(g, data) {
+ t.Errorf("data = %s, want %s", g, m)
+ }
+}
+
+func TestMarshalerPanic(t *testing.T) {
+ defer func() {
+ if r := recover(); r == nil {
+ t.Errorf("recover = nil, want error")
+ }
+ }()
+ m := &fakeMarshaler{err: errors.New("blah")}
+ MustMarshal(m)
+}
+
+func TestUnmarshaler(t *testing.T) {
+ data := []byte("test data")
+ m := &fakeUnmarshaler{}
+ MustUnmarshal(m, data)
+ if !reflect.DeepEqual(m.data, data) {
+ t.Errorf("data = %s, want %s", m.data, m)
+ }
+}
+
+func TestUnmarshalerPanic(t *testing.T) {
+ defer func() {
+ if r := recover(); r == nil {
+ t.Errorf("recover = nil, want error")
+ }
+ }()
+ m := &fakeUnmarshaler{err: errors.New("blah")}
+ MustUnmarshal(m, nil)
+}
+
+func TestGetBool(t *testing.T) {
+ tests := []struct {
+ b *bool
+ wb bool
+ wset bool
+ }{
+ {nil, false, false},
+ {Boolp(true), true, true},
+ {Boolp(false), false, true},
+ }
+ for i, tt := range tests {
+ b, set := GetBool(tt.b)
+ if b != tt.wb {
+ t.Errorf("#%d: value = %v, want %v", i, b, tt.wb)
+ }
+ if set != tt.wset {
+ t.Errorf("#%d: set = %v, want %v", i, set, tt.wset)
+ }
+ }
+}
+
+type fakeMarshaler struct {
+ data []byte
+ err error
+}
+
+func (m *fakeMarshaler) Marshal() ([]byte, error) {
+ return m.data, m.err
+}
+
+type fakeUnmarshaler struct {
+ data []byte
+ err error
+}
+
+func (m *fakeUnmarshaler) Unmarshal(data []byte) error {
+ m.data = data
+ return m.err
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/report/doc.go b/vendor/github.com/coreos/etcd/pkg/report/doc.go
new file mode 100644
index 00000000..1ebd119f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/report/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 report generates human-readable benchmark reports.
+package report
diff --git a/vendor/github.com/coreos/etcd/pkg/report/report.go b/vendor/github.com/coreos/etcd/pkg/report/report.go
new file mode 100644
index 00000000..77e29838
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/report/report.go
@@ -0,0 +1,278 @@
+// Copyright 2014 The etcd Authors
+//
+// Licensed 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.
+
+// the file is borrowed from github.com/rakyll/boom/boomer/print.go
+
+package report
+
+import (
+ "fmt"
+ "math"
+ "sort"
+ "strings"
+ "time"
+)
+
+const (
+ barChar = "?"
+)
+
+// Result describes the timings for an operation.
+type Result struct {
+ Start time.Time
+ End time.Time
+ Err error
+ Weight float64
+}
+
+func (res *Result) Duration() time.Duration { return res.End.Sub(res.Start) }
+
+type report struct {
+ results chan Result
+ precision string
+
+ stats Stats
+ sps *secondPoints
+}
+
+// Stats exposes results raw data.
+type Stats struct {
+ AvgTotal float64
+ Fastest float64
+ Slowest float64
+ Average float64
+ Stddev float64
+ RPS float64
+ Total time.Duration
+ ErrorDist map[string]int
+ Lats []float64
+ TimeSeries TimeSeries
+}
+
+func (s *Stats) copy() Stats {
+ ss := *s
+ ss.ErrorDist = copyMap(ss.ErrorDist)
+ ss.Lats = copyFloats(ss.Lats)
+ return ss
+}
+
+// Report processes a result stream until it is closed, then produces a
+// string with information about the consumed result data.
+type Report interface {
+ Results() chan<- Result
+
+ // Run returns results in print-friendly format.
+ Run() <-chan string
+
+ // Stats returns results in raw data.
+ Stats() <-chan Stats
+}
+
+func NewReport(precision string) Report { return newReport(precision) }
+
+func newReport(precision string) *report {
+ r := &report{
+ results: make(chan Result, 16),
+ precision: precision,
+ }
+ r.stats.ErrorDist = make(map[string]int)
+ return r
+}
+
+func NewReportSample(precision string) Report {
+ r := NewReport(precision).(*report)
+ r.sps = newSecondPoints()
+ return r
+}
+
+func (r *report) Results() chan<- Result { return r.results }
+
+func (r *report) Run() <-chan string {
+ donec := make(chan string, 1)
+ go func() {
+ defer close(donec)
+ r.processResults()
+ donec <- r.String()
+ }()
+ return donec
+}
+
+func (r *report) Stats() <-chan Stats {
+ donec := make(chan Stats, 1)
+ go func() {
+ defer close(donec)
+ r.processResults()
+ s := r.stats.copy()
+ if r.sps != nil {
+ s.TimeSeries = r.sps.getTimeSeries()
+ }
+ donec <- s
+ }()
+ return donec
+}
+
+func copyMap(m map[string]int) (c map[string]int) {
+ c = make(map[string]int, len(m))
+ for k, v := range m {
+ c[k] = v
+ }
+ return
+}
+
+func copyFloats(s []float64) (c []float64) {
+ c = make([]float64, len(s))
+ copy(c, s)
+ return
+}
+
+func (r *report) String() (s string) {
+ if len(r.stats.Lats) > 0 {
+ s += fmt.Sprintf("\nSummary:\n")
+ s += fmt.Sprintf(" Total:\t%s.\n", r.sec2str(r.stats.Total.Seconds()))
+ s += fmt.Sprintf(" Slowest:\t%s.\n", r.sec2str(r.stats.Slowest))
+ s += fmt.Sprintf(" Fastest:\t%s.\n", r.sec2str(r.stats.Fastest))
+ s += fmt.Sprintf(" Average:\t%s.\n", r.sec2str(r.stats.Average))
+ s += fmt.Sprintf(" Stddev:\t%s.\n", r.sec2str(r.stats.Stddev))
+ s += fmt.Sprintf(" Requests/sec:\t"+r.precision+"\n", r.stats.RPS)
+ s += r.histogram()
+ s += r.sprintLatencies()
+ if r.sps != nil {
+ s += fmt.Sprintf("%v\n", r.sps.getTimeSeries())
+ }
+ }
+ if len(r.stats.ErrorDist) > 0 {
+ s += r.errors()
+ }
+ return s
+}
+
+func (r *report) sec2str(sec float64) string { return fmt.Sprintf(r.precision+" secs", sec) }
+
+type reportRate struct{ *report }
+
+func NewReportRate(precision string) Report {
+ return &reportRate{NewReport(precision).(*report)}
+}
+
+func (r *reportRate) String() string {
+ return fmt.Sprintf(" Requests/sec:\t"+r.precision+"\n", r.stats.RPS)
+}
+
+func (r *report) processResult(res *Result) {
+ if res.Err != nil {
+ r.stats.ErrorDist[res.Err.Error()]++
+ return
+ }
+ dur := res.Duration()
+ r.stats.Lats = append(r.stats.Lats, dur.Seconds())
+ r.stats.AvgTotal += dur.Seconds()
+ if r.sps != nil {
+ r.sps.Add(res.Start, dur)
+ }
+}
+
+func (r *report) processResults() {
+ st := time.Now()
+ for res := range r.results {
+ r.processResult(&res)
+ }
+ r.stats.Total = time.Since(st)
+
+ r.stats.RPS = float64(len(r.stats.Lats)) / r.stats.Total.Seconds()
+ r.stats.Average = r.stats.AvgTotal / float64(len(r.stats.Lats))
+ for i := range r.stats.Lats {
+ dev := r.stats.Lats[i] - r.stats.Average
+ r.stats.Stddev += dev * dev
+ }
+ r.stats.Stddev = math.Sqrt(r.stats.Stddev / float64(len(r.stats.Lats)))
+ sort.Float64s(r.stats.Lats)
+ if len(r.stats.Lats) > 0 {
+ r.stats.Fastest = r.stats.Lats[0]
+ r.stats.Slowest = r.stats.Lats[len(r.stats.Lats)-1]
+ }
+}
+
+var pctls = []float64{10, 25, 50, 75, 90, 95, 99, 99.9}
+
+// Percentiles returns percentile distribution of float64 slice.
+func Percentiles(nums []float64) (pcs []float64, data []float64) {
+ return pctls, percentiles(nums)
+}
+
+func percentiles(nums []float64) (data []float64) {
+ data = make([]float64, len(pctls))
+ j := 0
+ n := len(nums)
+ for i := 0; i < n && j < len(pctls); i++ {
+ current := float64(i) * 100.0 / float64(n)
+ if current >= pctls[j] {
+ data[j] = nums[i]
+ j++
+ }
+ }
+ return
+}
+
+func (r *report) sprintLatencies() string {
+ data := percentiles(r.stats.Lats)
+ s := fmt.Sprintf("\nLatency distribution:\n")
+ for i := 0; i < len(pctls); i++ {
+ if data[i] > 0 {
+ s += fmt.Sprintf(" %v%% in %s.\n", pctls[i], r.sec2str(data[i]))
+ }
+ }
+ return s
+}
+
+func (r *report) histogram() string {
+ bc := 10
+ buckets := make([]float64, bc+1)
+ counts := make([]int, bc+1)
+ bs := (r.stats.Slowest - r.stats.Fastest) / float64(bc)
+ for i := 0; i < bc; i++ {
+ buckets[i] = r.stats.Fastest + bs*float64(i)
+ }
+ buckets[bc] = r.stats.Slowest
+ var bi int
+ var max int
+ for i := 0; i < len(r.stats.Lats); {
+ if r.stats.Lats[i] <= buckets[bi] {
+ i++
+ counts[bi]++
+ if max < counts[bi] {
+ max = counts[bi]
+ }
+ } else if bi < len(buckets)-1 {
+ bi++
+ }
+ }
+ s := fmt.Sprintf("\nResponse time histogram:\n")
+ for i := 0; i < len(buckets); i++ {
+ // Normalize bar lengths.
+ var barLen int
+ if max > 0 {
+ barLen = counts[i] * 40 / max
+ }
+ s += fmt.Sprintf(" "+r.precision+" [%v]\t|%v\n", buckets[i], counts[i], strings.Repeat(barChar, barLen))
+ }
+ return s
+}
+
+func (r *report) errors() string {
+ s := fmt.Sprintf("\nError distribution:\n")
+ for err, num := range r.stats.ErrorDist {
+ s += fmt.Sprintf(" [%d]\t%s\n", num, err)
+ }
+ return s
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/report/report_test.go b/vendor/github.com/coreos/etcd/pkg/report/report_test.go
new file mode 100644
index 00000000..6f073f3e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/report/report_test.go
@@ -0,0 +1,114 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 report
+
+import (
+ "fmt"
+ "reflect"
+ "strings"
+ "testing"
+ "time"
+)
+
+func TestPercentiles(t *testing.T) {
+ nums := make([]float64, 100)
+ nums[99] = 1 // 99-percentile (1 out of 100)
+ data := percentiles(nums)
+ if data[len(pctls)-2] != 1 {
+ t.Fatalf("99-percentile expected 1, got %f", data[len(pctls)-2])
+ }
+
+ nums = make([]float64, 1000)
+ nums[999] = 1 // 99.9-percentile (1 out of 1000)
+ data = percentiles(nums)
+ if data[len(pctls)-1] != 1 {
+ t.Fatalf("99.9-percentile expected 1, got %f", data[len(pctls)-1])
+ }
+}
+
+func TestReport(t *testing.T) {
+ r := NewReportSample("%f")
+ go func() {
+ start := time.Now()
+ for i := 0; i < 5; i++ {
+ end := start.Add(time.Second)
+ r.Results() <- Result{Start: start, End: end}
+ start = end
+ }
+ r.Results() <- Result{Start: start, End: start.Add(time.Second), Err: fmt.Errorf("oops")}
+ close(r.Results())
+ }()
+
+ stats := <-r.Stats()
+ stats.TimeSeries = nil // ignore timeseries since it uses wall clock
+ wStats := Stats{
+ AvgTotal: 5.0,
+ Fastest: 1.0,
+ Slowest: 1.0,
+ Average: 1.0,
+ Stddev: 0.0,
+ Total: stats.Total,
+ RPS: 5.0 / stats.Total.Seconds(),
+ ErrorDist: map[string]int{"oops": 1},
+ Lats: []float64{1.0, 1.0, 1.0, 1.0, 1.0},
+ }
+ if !reflect.DeepEqual(stats, wStats) {
+ t.Fatalf("got %+v, want %+v", stats, wStats)
+ }
+
+ wstrs := []string{
+ "Stddev:\t0",
+ "Average:\t1.0",
+ "Slowest:\t1.0",
+ "Fastest:\t1.0",
+ }
+ ss := <-r.Run()
+ for i, ws := range wstrs {
+ if !strings.Contains(ss, ws) {
+ t.Errorf("#%d: stats string missing %s", i, ws)
+ }
+ }
+}
+
+func TestWeightedReport(t *testing.T) {
+ r := NewWeightedReport(NewReport("%f"), "%f")
+ go func() {
+ start := time.Now()
+ for i := 0; i < 5; i++ {
+ end := start.Add(time.Second)
+ r.Results() <- Result{Start: start, End: end, Weight: 2.0}
+ start = end
+ }
+ r.Results() <- Result{Start: start, End: start.Add(time.Second), Err: fmt.Errorf("oops")}
+ close(r.Results())
+ }()
+
+ stats := <-r.Stats()
+ stats.TimeSeries = nil // ignore timeseries since it uses wall clock
+ wStats := Stats{
+ AvgTotal: 10.0,
+ Fastest: 0.5,
+ Slowest: 0.5,
+ Average: 0.5,
+ Stddev: 0.0,
+ Total: stats.Total,
+ RPS: 10.0 / stats.Total.Seconds(),
+ ErrorDist: map[string]int{"oops": 1},
+ Lats: []float64{0.5, 0.5, 0.5, 0.5, 0.5},
+ }
+ if !reflect.DeepEqual(stats, wStats) {
+ t.Fatalf("got %+v, want %+v", stats, wStats)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/report/timeseries.go b/vendor/github.com/coreos/etcd/pkg/report/timeseries.go
new file mode 100644
index 00000000..ee401eb9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/report/timeseries.go
@@ -0,0 +1,160 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 report
+
+import (
+ "bytes"
+ "encoding/csv"
+ "fmt"
+ "log"
+ "math"
+ "sort"
+ "sync"
+ "time"
+)
+
+type DataPoint struct {
+ Timestamp int64
+ MinLatency time.Duration
+ AvgLatency time.Duration
+ MaxLatency time.Duration
+ ThroughPut int64
+}
+
+type TimeSeries []DataPoint
+
+func (t TimeSeries) Swap(i, j int) { t[i], t[j] = t[j], t[i] }
+func (t TimeSeries) Len() int { return len(t) }
+func (t TimeSeries) Less(i, j int) bool { return t[i].Timestamp < t[j].Timestamp }
+
+type secondPoint struct {
+ minLatency time.Duration
+ maxLatency time.Duration
+ totalLatency time.Duration
+ count int64
+}
+
+type secondPoints struct {
+ mu sync.Mutex
+ tm map[int64]secondPoint
+}
+
+func newSecondPoints() *secondPoints {
+ return &secondPoints{tm: make(map[int64]secondPoint)}
+}
+
+func (sp *secondPoints) Add(ts time.Time, lat time.Duration) {
+ sp.mu.Lock()
+ defer sp.mu.Unlock()
+
+ tk := ts.Unix()
+ if v, ok := sp.tm[tk]; !ok {
+ sp.tm[tk] = secondPoint{minLatency: lat, maxLatency: lat, totalLatency: lat, count: 1}
+ } else {
+ if lat != time.Duration(0) {
+ v.minLatency = minDuration(v.minLatency, lat)
+ }
+ v.maxLatency = maxDuration(v.maxLatency, lat)
+ v.totalLatency += lat
+ v.count++
+ sp.tm[tk] = v
+ }
+}
+
+func (sp *secondPoints) getTimeSeries() TimeSeries {
+ sp.mu.Lock()
+ defer sp.mu.Unlock()
+
+ var (
+ minTs int64 = math.MaxInt64
+ maxTs int64 = -1
+ )
+ for k := range sp.tm {
+ if minTs > k {
+ minTs = k
+ }
+ if maxTs < k {
+ maxTs = k
+ }
+ }
+ for ti := minTs; ti < maxTs; ti++ {
+ if _, ok := sp.tm[ti]; !ok { // fill-in empties
+ sp.tm[ti] = secondPoint{totalLatency: 0, count: 0}
+ }
+ }
+
+ var (
+ tslice = make(TimeSeries, len(sp.tm))
+ i int
+ )
+ for k, v := range sp.tm {
+ var lat time.Duration
+ if v.count > 0 {
+ lat = time.Duration(v.totalLatency) / time.Duration(v.count)
+ }
+ tslice[i] = DataPoint{
+ Timestamp: k,
+ MinLatency: v.minLatency,
+ AvgLatency: lat,
+ MaxLatency: v.maxLatency,
+ ThroughPut: v.count,
+ }
+ i++
+ }
+
+ sort.Sort(tslice)
+ return tslice
+}
+
+func (ts TimeSeries) String() string {
+ buf := new(bytes.Buffer)
+ wr := csv.NewWriter(buf)
+ if err := wr.Write([]string{"UNIX-SECOND", "MIN-LATENCY-MS", "AVG-LATENCY-MS", "MAX-LATENCY-MS", "AVG-THROUGHPUT"}); err != nil {
+ log.Fatal(err)
+ }
+ rows := [][]string{}
+ for i := range ts {
+ row := []string{
+ fmt.Sprintf("%d", ts[i].Timestamp),
+ ts[i].MinLatency.String(),
+ ts[i].AvgLatency.String(),
+ ts[i].MaxLatency.String(),
+ fmt.Sprintf("%d", ts[i].ThroughPut),
+ }
+ rows = append(rows, row)
+ }
+ if err := wr.WriteAll(rows); err != nil {
+ log.Fatal(err)
+ }
+ wr.Flush()
+ if err := wr.Error(); err != nil {
+ log.Fatal(err)
+ }
+ return fmt.Sprintf("\nSample in one second (unix latency throughput):\n%s", buf.String())
+}
+
+func minDuration(a, b time.Duration) time.Duration {
+ if a < b {
+ return a
+ }
+ return b
+}
+
+func maxDuration(a, b time.Duration) time.Duration {
+ if a > b {
+ return a
+ }
+ return b
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/report/timeseries_test.go b/vendor/github.com/coreos/etcd/pkg/report/timeseries_test.go
new file mode 100644
index 00000000..13fcbfa3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/report/timeseries_test.go
@@ -0,0 +1,44 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 report
+
+import (
+ "testing"
+ "time"
+)
+
+func TestGetTimeseries(t *testing.T) {
+ sp := newSecondPoints()
+ now := time.Now()
+ sp.Add(now, time.Second)
+ sp.Add(now.Add(5*time.Second), time.Second)
+ n := sp.getTimeSeries().Len()
+ if n < 3 {
+ t.Fatalf("expected at 6 points of time series, got %s", sp.getTimeSeries())
+ }
+
+ // add a point with duplicate timestamp
+ sp.Add(now, 3*time.Second)
+ ts := sp.getTimeSeries()
+ if ts[0].MinLatency != time.Second {
+ t.Fatalf("ts[0] min latency expected %v, got %s", time.Second, ts[0].MinLatency)
+ }
+ if ts[0].AvgLatency != 2*time.Second {
+ t.Fatalf("ts[0] average latency expected %v, got %s", 2*time.Second, ts[0].AvgLatency)
+ }
+ if ts[0].MaxLatency != 3*time.Second {
+ t.Fatalf("ts[0] max latency expected %v, got %s", 3*time.Second, ts[0].MaxLatency)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/report/weighted.go b/vendor/github.com/coreos/etcd/pkg/report/weighted.go
new file mode 100644
index 00000000..411214f6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/report/weighted.go
@@ -0,0 +1,101 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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.
+
+// the file is borrowed from github.com/rakyll/boom/boomer/print.go
+
+package report
+
+import (
+ "time"
+)
+
+type weightedReport struct {
+ baseReport Report
+
+ report *report
+ results chan Result
+ weightTotal float64
+}
+
+// NewWeightedReport returns a report that includes
+// both weighted and unweighted statistics.
+func NewWeightedReport(r Report, precision string) Report {
+ return &weightedReport{
+ baseReport: r,
+ report: newReport(precision),
+ results: make(chan Result, 16),
+ }
+}
+
+func (wr *weightedReport) Results() chan<- Result { return wr.results }
+
+func (wr *weightedReport) Run() <-chan string {
+ donec := make(chan string, 2)
+ go func() {
+ defer close(donec)
+ basec, rc := make(chan string, 1), make(chan Stats, 1)
+ go func() { basec <- (<-wr.baseReport.Run()) }()
+ go func() { rc <- (<-wr.report.Stats()) }()
+ go wr.processResults()
+ wr.report.stats = wr.reweighStat(<-rc)
+ donec <- wr.report.String()
+ donec <- (<-basec)
+ }()
+ return donec
+}
+
+func (wr *weightedReport) Stats() <-chan Stats {
+ donec := make(chan Stats, 2)
+ go func() {
+ defer close(donec)
+ basec, rc := make(chan Stats, 1), make(chan Stats, 1)
+ go func() { basec <- (<-wr.baseReport.Stats()) }()
+ go func() { rc <- (<-wr.report.Stats()) }()
+ go wr.processResults()
+ donec <- wr.reweighStat(<-rc)
+ donec <- (<-basec)
+ }()
+ return donec
+}
+
+func (wr *weightedReport) processResults() {
+ defer close(wr.report.results)
+ defer close(wr.baseReport.Results())
+ for res := range wr.results {
+ wr.processResult(res)
+ wr.baseReport.Results() <- res
+ }
+}
+
+func (wr *weightedReport) processResult(res Result) {
+ if res.Err != nil {
+ wr.report.results <- res
+ return
+ }
+ if res.Weight == 0 {
+ res.Weight = 1.0
+ }
+ wr.weightTotal += res.Weight
+ res.End = res.Start.Add(time.Duration(float64(res.End.Sub(res.Start)) / res.Weight))
+ res.Weight = 1.0
+ wr.report.results <- res
+}
+
+func (wr *weightedReport) reweighStat(s Stats) Stats {
+ weightCoef := wr.weightTotal / float64(len(s.Lats))
+ // weight > 1 => processing more than one request
+ s.RPS *= weightCoef
+ s.AvgTotal *= weightCoef * weightCoef
+ return s
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/runtime/fds_linux.go b/vendor/github.com/coreos/etcd/pkg/runtime/fds_linux.go
new file mode 100644
index 00000000..8e9359db
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/runtime/fds_linux.go
@@ -0,0 +1,37 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 runtime implements utility functions for runtime systems.
+package runtime
+
+import (
+ "io/ioutil"
+ "syscall"
+)
+
+func FDLimit() (uint64, error) {
+ var rlimit syscall.Rlimit
+ if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlimit); err != nil {
+ return 0, err
+ }
+ return rlimit.Cur, nil
+}
+
+func FDUsage() (uint64, error) {
+ fds, err := ioutil.ReadDir("/proc/self/fd")
+ if err != nil {
+ return 0, err
+ }
+ return uint64(len(fds)), nil
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/runtime/fds_other.go b/vendor/github.com/coreos/etcd/pkg/runtime/fds_other.go
new file mode 100644
index 00000000..0cbdb88c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/runtime/fds_other.go
@@ -0,0 +1,30 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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.
+
+// +build !linux
+
+package runtime
+
+import (
+ "fmt"
+ "runtime"
+)
+
+func FDLimit() (uint64, error) {
+ return 0, fmt.Errorf("cannot get FDLimit on %s", runtime.GOOS)
+}
+
+func FDUsage() (uint64, error) {
+ return 0, fmt.Errorf("cannot get FDUsage on %s", runtime.GOOS)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/schedule/doc.go b/vendor/github.com/coreos/etcd/pkg/schedule/doc.go
new file mode 100644
index 00000000..cca2c75f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/schedule/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 schedule provides mechanisms and policies for scheduling units of work.
+package schedule
diff --git a/vendor/github.com/coreos/etcd/pkg/schedule/schedule.go b/vendor/github.com/coreos/etcd/pkg/schedule/schedule.go
new file mode 100644
index 00000000..bf8528b7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/schedule/schedule.go
@@ -0,0 +1,166 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 schedule
+
+import (
+ "sync"
+
+ "golang.org/x/net/context"
+)
+
+type Job func(context.Context)
+
+// Scheduler can schedule jobs.
+type Scheduler interface {
+ // Schedule asks the scheduler to schedule a job defined by the given func.
+ // Schedule to a stopped scheduler might panic.
+ Schedule(j Job)
+
+ // Pending returns number of pending jobs
+ Pending() int
+
+ // Scheduled returns the number of scheduled jobs (excluding pending jobs)
+ Scheduled() int
+
+ // Finished returns the number of finished jobs
+ Finished() int
+
+ // WaitFinish waits until at least n job are finished and all pending jobs are finished.
+ WaitFinish(n int)
+
+ // Stop stops the scheduler.
+ Stop()
+}
+
+type fifo struct {
+ mu sync.Mutex
+
+ resume chan struct{}
+ scheduled int
+ finished int
+ pendings []Job
+
+ ctx context.Context
+ cancel context.CancelFunc
+
+ finishCond *sync.Cond
+ donec chan struct{}
+}
+
+// NewFIFOScheduler returns a Scheduler that schedules jobs in FIFO
+// order sequentially
+func NewFIFOScheduler() Scheduler {
+ f := &fifo{
+ resume: make(chan struct{}, 1),
+ donec: make(chan struct{}, 1),
+ }
+ f.finishCond = sync.NewCond(&f.mu)
+ f.ctx, f.cancel = context.WithCancel(context.Background())
+ go f.run()
+ return f
+}
+
+// Schedule schedules a job that will be ran in FIFO order sequentially.
+func (f *fifo) Schedule(j Job) {
+ f.mu.Lock()
+ defer f.mu.Unlock()
+
+ if f.cancel == nil {
+ panic("schedule: schedule to stopped scheduler")
+ }
+
+ if len(f.pendings) == 0 {
+ select {
+ case f.resume <- struct{}{}:
+ default:
+ }
+ }
+ f.pendings = append(f.pendings, j)
+}
+
+func (f *fifo) Pending() int {
+ f.mu.Lock()
+ defer f.mu.Unlock()
+ return len(f.pendings)
+}
+
+func (f *fifo) Scheduled() int {
+ f.mu.Lock()
+ defer f.mu.Unlock()
+ return f.scheduled
+}
+
+func (f *fifo) Finished() int {
+ f.finishCond.L.Lock()
+ defer f.finishCond.L.Unlock()
+ return f.finished
+}
+
+func (f *fifo) WaitFinish(n int) {
+ f.finishCond.L.Lock()
+ for f.finished < n || len(f.pendings) != 0 {
+ f.finishCond.Wait()
+ }
+ f.finishCond.L.Unlock()
+}
+
+// Stop stops the scheduler and cancels all pending jobs.
+func (f *fifo) Stop() {
+ f.mu.Lock()
+ f.cancel()
+ f.cancel = nil
+ f.mu.Unlock()
+ <-f.donec
+}
+
+func (f *fifo) run() {
+ // TODO: recover from job panic?
+ defer func() {
+ close(f.donec)
+ close(f.resume)
+ }()
+
+ for {
+ var todo Job
+ f.mu.Lock()
+ if len(f.pendings) != 0 {
+ f.scheduled++
+ todo = f.pendings[0]
+ }
+ f.mu.Unlock()
+ if todo == nil {
+ select {
+ case <-f.resume:
+ case <-f.ctx.Done():
+ f.mu.Lock()
+ pendings := f.pendings
+ f.pendings = nil
+ f.mu.Unlock()
+ // clean up pending jobs
+ for _, todo := range pendings {
+ todo(f.ctx)
+ }
+ return
+ }
+ } else {
+ todo(f.ctx)
+ f.finishCond.L.Lock()
+ f.finished++
+ f.pendings = f.pendings[1:]
+ f.finishCond.Broadcast()
+ f.finishCond.L.Unlock()
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/schedule/schedule_test.go b/vendor/github.com/coreos/etcd/pkg/schedule/schedule_test.go
new file mode 100644
index 00000000..88c5bf3c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/schedule/schedule_test.go
@@ -0,0 +1,50 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 schedule
+
+import (
+ "testing"
+
+ "golang.org/x/net/context"
+)
+
+func TestFIFOSchedule(t *testing.T) {
+ s := NewFIFOScheduler()
+ defer s.Stop()
+
+ next := 0
+ jobCreator := func(i int) Job {
+ return func(ctx context.Context) {
+ if next != i {
+ t.Fatalf("job#%d: got %d, want %d", i, next, i)
+ }
+ next = i + 1
+ }
+ }
+
+ var jobs []Job
+ for i := 0; i < 100; i++ {
+ jobs = append(jobs, jobCreator(i))
+ }
+
+ for _, j := range jobs {
+ s.Schedule(j)
+ }
+
+ s.WaitFinish(100)
+ if s.Scheduled() != 100 {
+ t.Errorf("scheduled = %d, want %d", s.Scheduled(), 100)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/srv/srv.go b/vendor/github.com/coreos/etcd/pkg/srv/srv.go
new file mode 100644
index 00000000..fefcbcb4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/srv/srv.go
@@ -0,0 +1,140 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 srv looks up DNS SRV records.
+package srv
+
+import (
+ "fmt"
+ "net"
+ "net/url"
+ "strings"
+
+ "github.com/coreos/etcd/pkg/types"
+)
+
+var (
+ // indirection for testing
+ lookupSRV = net.LookupSRV // net.DefaultResolver.LookupSRV when ctxs don't conflict
+ resolveTCPAddr = net.ResolveTCPAddr
+)
+
+// GetCluster gets the cluster information via DNS discovery.
+// Also sees each entry as a separate instance.
+func GetCluster(service, name, dns string, apurls types.URLs) ([]string, error) {
+ tempName := int(0)
+ tcp2ap := make(map[string]url.URL)
+
+ // First, resolve the apurls
+ for _, url := range apurls {
+ tcpAddr, err := resolveTCPAddr("tcp", url.Host)
+ if err != nil {
+ return nil, err
+ }
+ tcp2ap[tcpAddr.String()] = url
+ }
+
+ stringParts := []string{}
+ updateNodeMap := func(service, scheme string) error {
+ _, addrs, err := lookupSRV(service, "tcp", dns)
+ if err != nil {
+ return err
+ }
+ for _, srv := range addrs {
+ port := fmt.Sprintf("%d", srv.Port)
+ host := net.JoinHostPort(srv.Target, port)
+ tcpAddr, terr := resolveTCPAddr("tcp", host)
+ if terr != nil {
+ err = terr
+ continue
+ }
+ n := ""
+ url, ok := tcp2ap[tcpAddr.String()]
+ if ok {
+ n = name
+ }
+ if n == "" {
+ n = fmt.Sprintf("%d", tempName)
+ tempName++
+ }
+ // SRV records have a trailing dot but URL shouldn't.
+ shortHost := strings.TrimSuffix(srv.Target, ".")
+ urlHost := net.JoinHostPort(shortHost, port)
+ stringParts = append(stringParts, fmt.Sprintf("%s=%s://%s", n, scheme, urlHost))
+ if ok && url.Scheme != scheme {
+ err = fmt.Errorf("bootstrap at %s from DNS for %s has scheme mismatch with expected peer %s", scheme+"://"+urlHost, service, url.String())
+ }
+ }
+ if len(stringParts) == 0 {
+ return err
+ }
+ return nil
+ }
+
+ failCount := 0
+ err := updateNodeMap(service+"-ssl", "https")
+ srvErr := make([]string, 2)
+ if err != nil {
+ srvErr[0] = fmt.Sprintf("error querying DNS SRV records for _%s-ssl %s", service, err)
+ failCount++
+ }
+ err = updateNodeMap(service, "http")
+ if err != nil {
+ srvErr[1] = fmt.Sprintf("error querying DNS SRV records for _%s %s", service, err)
+ failCount++
+ }
+ if failCount == 2 {
+ return nil, fmt.Errorf("srv: too many errors querying DNS SRV records (%q, %q)", srvErr[0], srvErr[1])
+ }
+ return stringParts, nil
+}
+
+type SRVClients struct {
+ Endpoints []string
+ SRVs []*net.SRV
+}
+
+// GetClient looks up the client endpoints for a service and domain.
+func GetClient(service, domain string) (*SRVClients, error) {
+ var urls []*url.URL
+ var srvs []*net.SRV
+
+ updateURLs := func(service, scheme string) error {
+ _, addrs, err := lookupSRV(service, "tcp", domain)
+ if err != nil {
+ return err
+ }
+ for _, srv := range addrs {
+ urls = append(urls, &url.URL{
+ Scheme: scheme,
+ Host: net.JoinHostPort(srv.Target, fmt.Sprintf("%d", srv.Port)),
+ })
+ }
+ srvs = append(srvs, addrs...)
+ return nil
+ }
+
+ errHTTPS := updateURLs(service+"-ssl", "https")
+ errHTTP := updateURLs(service, "http")
+
+ if errHTTPS != nil && errHTTP != nil {
+ return nil, fmt.Errorf("dns lookup errors: %s and %s", errHTTPS, errHTTP)
+ }
+
+ endpoints := make([]string, len(urls))
+ for i := range urls {
+ endpoints[i] = urls[i].String()
+ }
+ return &SRVClients{Endpoints: endpoints, SRVs: srvs}, nil
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/srv/srv_test.go b/vendor/github.com/coreos/etcd/pkg/srv/srv_test.go
new file mode 100644
index 00000000..0386c9d2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/srv/srv_test.go
@@ -0,0 +1,200 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 srv
+
+import (
+ "errors"
+ "net"
+ "reflect"
+ "strings"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestSRVGetCluster(t *testing.T) {
+ defer func() {
+ lookupSRV = net.LookupSRV
+ resolveTCPAddr = net.ResolveTCPAddr
+ }()
+
+ name := "dnsClusterTest"
+ dns := map[string]string{
+ "1.example.com.:2480": "10.0.0.1:2480",
+ "2.example.com.:2480": "10.0.0.2:2480",
+ "3.example.com.:2480": "10.0.0.3:2480",
+ "4.example.com.:2380": "10.0.0.3:2380",
+ }
+ srvAll := []*net.SRV{
+ {Target: "1.example.com.", Port: 2480},
+ {Target: "2.example.com.", Port: 2480},
+ {Target: "3.example.com.", Port: 2480},
+ }
+
+ tests := []struct {
+ withSSL []*net.SRV
+ withoutSSL []*net.SRV
+ urls []string
+
+ expected string
+ }{
+ {
+ []*net.SRV{},
+ []*net.SRV{},
+ nil,
+
+ "",
+ },
+ {
+ srvAll,
+ []*net.SRV{},
+ nil,
+
+ "0=https://1.example.com:2480,1=https://2.example.com:2480,2=https://3.example.com:2480",
+ },
+ {
+ srvAll,
+ []*net.SRV{{Target: "4.example.com.", Port: 2380}},
+ nil,
+
+ "0=https://1.example.com:2480,1=https://2.example.com:2480,2=https://3.example.com:2480,3=http://4.example.com:2380",
+ },
+ {
+ srvAll,
+ []*net.SRV{{Target: "4.example.com.", Port: 2380}},
+ []string{"https://10.0.0.1:2480"},
+
+ "dnsClusterTest=https://1.example.com:2480,0=https://2.example.com:2480,1=https://3.example.com:2480,2=http://4.example.com:2380",
+ },
+ // matching local member with resolved addr and return unresolved hostnames
+ {
+ srvAll,
+ nil,
+ []string{"https://10.0.0.1:2480"},
+
+ "dnsClusterTest=https://1.example.com:2480,0=https://2.example.com:2480,1=https://3.example.com:2480",
+ },
+ // invalid
+ }
+
+ resolveTCPAddr = func(network, addr string) (*net.TCPAddr, error) {
+ if strings.Contains(addr, "10.0.0.") {
+ // accept IP addresses when resolving apurls
+ return net.ResolveTCPAddr(network, addr)
+ }
+ if dns[addr] == "" {
+ return nil, errors.New("missing dns record")
+ }
+ return net.ResolveTCPAddr(network, dns[addr])
+ }
+
+ for i, tt := range tests {
+ lookupSRV = func(service string, proto string, domain string) (string, []*net.SRV, error) {
+ if service == "etcd-server-ssl" {
+ return "", tt.withSSL, nil
+ }
+ if service == "etcd-server" {
+ return "", tt.withoutSSL, nil
+ }
+ return "", nil, errors.New("Unknown service in mock")
+ }
+ urls := testutil.MustNewURLs(t, tt.urls)
+ str, err := GetCluster("etcd-server", name, "example.com", urls)
+ if err != nil {
+ t.Fatalf("%d: err: %#v", i, err)
+ }
+ if strings.Join(str, ",") != tt.expected {
+ t.Errorf("#%d: cluster = %s, want %s", i, str, tt.expected)
+ }
+ }
+}
+
+func TestSRVDiscover(t *testing.T) {
+ defer func() { lookupSRV = net.LookupSRV }()
+
+ tests := []struct {
+ withSSL []*net.SRV
+ withoutSSL []*net.SRV
+ expected []string
+ }{
+ {
+ []*net.SRV{},
+ []*net.SRV{},
+ []string{},
+ },
+ {
+ []*net.SRV{
+ {Target: "10.0.0.1", Port: 2480},
+ {Target: "10.0.0.2", Port: 2480},
+ {Target: "10.0.0.3", Port: 2480},
+ },
+ []*net.SRV{},
+ []string{"https://10.0.0.1:2480", "https://10.0.0.2:2480", "https://10.0.0.3:2480"},
+ },
+ {
+ []*net.SRV{
+ {Target: "10.0.0.1", Port: 2480},
+ {Target: "10.0.0.2", Port: 2480},
+ {Target: "10.0.0.3", Port: 2480},
+ },
+ []*net.SRV{
+ {Target: "10.0.0.1", Port: 7001},
+ },
+ []string{"https://10.0.0.1:2480", "https://10.0.0.2:2480", "https://10.0.0.3:2480", "http://10.0.0.1:7001"},
+ },
+ {
+ []*net.SRV{
+ {Target: "10.0.0.1", Port: 2480},
+ {Target: "10.0.0.2", Port: 2480},
+ {Target: "10.0.0.3", Port: 2480},
+ },
+ []*net.SRV{
+ {Target: "10.0.0.1", Port: 7001},
+ },
+ []string{"https://10.0.0.1:2480", "https://10.0.0.2:2480", "https://10.0.0.3:2480", "http://10.0.0.1:7001"},
+ },
+ {
+ []*net.SRV{
+ {Target: "a.example.com", Port: 2480},
+ {Target: "b.example.com", Port: 2480},
+ {Target: "c.example.com", Port: 2480},
+ },
+ []*net.SRV{},
+ []string{"https://a.example.com:2480", "https://b.example.com:2480", "https://c.example.com:2480"},
+ },
+ }
+
+ for i, tt := range tests {
+ lookupSRV = func(service string, proto string, domain string) (string, []*net.SRV, error) {
+ if service == "etcd-client-ssl" {
+ return "", tt.withSSL, nil
+ }
+ if service == "etcd-client" {
+ return "", tt.withoutSSL, nil
+ }
+ return "", nil, errors.New("Unknown service in mock")
+ }
+
+ srvs, err := GetClient("etcd-client", "example.com")
+ if err != nil {
+ t.Fatalf("%d: err: %#v", i, err)
+ }
+
+ if !reflect.DeepEqual(srvs.Endpoints, tt.expected) {
+ t.Errorf("#%d: endpoints = %v, want %v", i, srvs.Endpoints, tt.expected)
+ }
+
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/stringutil/stringutil.go b/vendor/github.com/coreos/etcd/pkg/stringutil/stringutil.go
new file mode 100644
index 00000000..44d637c2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/stringutil/stringutil.go
@@ -0,0 +1,55 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 stringutil exports string utility functions.
+package stringutil
+
+import "math/rand"
+
+const (
+ chars = "abcdefghijklmnopqrstuvwxyz0123456789"
+)
+
+// UniqueStrings returns a slice of randomly generated unique strings.
+func UniqueStrings(maxlen uint, n int) []string {
+ exist := make(map[string]bool)
+ ss := make([]string, 0)
+
+ for len(ss) < n {
+ s := randomString(maxlen)
+ if !exist[s] {
+ exist[s] = true
+ ss = append(ss, s)
+ }
+ }
+
+ return ss
+}
+
+// RandomStrings returns a slice of randomly generated strings.
+func RandomStrings(maxlen uint, n int) []string {
+ ss := make([]string, 0)
+ for i := 0; i < n; i++ {
+ ss = append(ss, randomString(maxlen))
+ }
+ return ss
+}
+
+func randomString(l uint) string {
+ s := make([]byte, l)
+ for i := 0; i < int(l); i++ {
+ s[i] = chars[rand.Intn(len(chars))]
+ }
+ return string(s)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/testutil/assert.go b/vendor/github.com/coreos/etcd/pkg/testutil/assert.go
new file mode 100644
index 00000000..8bd3922e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/testutil/assert.go
@@ -0,0 +1,58 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 testutil
+
+import (
+ "fmt"
+ "reflect"
+ "testing"
+)
+
+func AssertEqual(t *testing.T, e, a interface{}, msg ...string) {
+ if (e == nil || a == nil) && (isNil(e) && isNil(a)) {
+ return
+ }
+ if reflect.DeepEqual(e, a) {
+ return
+ }
+ s := ""
+ if len(msg) > 1 {
+ s = msg[0] + ": "
+ }
+ s = fmt.Sprintf("%sexpected %+v, got %+v", s, e, a)
+ FatalStack(t, s)
+}
+
+func AssertNil(t *testing.T, v interface{}) {
+ AssertEqual(t, nil, v)
+}
+
+func AssertNotNil(t *testing.T, v interface{}) {
+ if v == nil {
+ t.Fatalf("expected non-nil, got %+v", v)
+ }
+}
+
+func AssertTrue(t *testing.T, v bool, msg ...string) {
+ AssertEqual(t, true, v, msg...)
+}
+
+func AssertFalse(t *testing.T, v bool, msg ...string) {
+ AssertEqual(t, false, v, msg...)
+}
+
+func isNil(v interface{}) bool {
+ return v == nil || reflect.ValueOf(v).IsNil()
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/testutil/leak.go b/vendor/github.com/coreos/etcd/pkg/testutil/leak.go
new file mode 100644
index 00000000..a29d06d9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/testutil/leak.go
@@ -0,0 +1,138 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package testutil
+
+import (
+ "fmt"
+ "net/http"
+ "os"
+ "regexp"
+ "runtime"
+ "sort"
+ "strings"
+ "testing"
+ "time"
+)
+
+/*
+CheckLeakedGoroutine verifies tests do not leave any leaky
+goroutines. It returns true when there are goroutines still
+running(leaking) after all tests.
+
+ import "github.com/coreos/etcd/pkg/testutil"
+
+ func TestMain(m *testing.M) {
+ v := m.Run()
+ if v == 0 && testutil.CheckLeakedGoroutine() {
+ os.Exit(1)
+ }
+ os.Exit(v)
+ }
+
+ func TestSample(t *testing.T) {
+ defer testutil.AfterTest(t)
+ ...
+ }
+
+*/
+func CheckLeakedGoroutine() bool {
+ if testing.Short() {
+ // not counting goroutines for leakage in -short mode
+ return false
+ }
+ gs := interestingGoroutines()
+ if len(gs) == 0 {
+ return false
+ }
+
+ stackCount := make(map[string]int)
+ re := regexp.MustCompile(`\(0[0-9a-fx, ]*\)`)
+ for _, g := range gs {
+ // strip out pointer arguments in first function of stack dump
+ normalized := string(re.ReplaceAll([]byte(g), []byte("(...)")))
+ stackCount[normalized]++
+ }
+
+ fmt.Fprintf(os.Stderr, "Too many goroutines running after all test(s).\n")
+ for stack, count := range stackCount {
+ fmt.Fprintf(os.Stderr, "%d instances of:\n%s\n", count, stack)
+ }
+ return true
+}
+
+// CheckAfterTest returns an error if AfterTest would fail with an error.
+func CheckAfterTest(d time.Duration) error {
+ http.DefaultTransport.(*http.Transport).CloseIdleConnections()
+ if testing.Short() {
+ return nil
+ }
+ var bad string
+ badSubstring := map[string]string{
+ ").writeLoop(": "a Transport",
+ "created by net/http/httptest.(*Server).Start": "an httptest.Server",
+ "timeoutHandler": "a TimeoutHandler",
+ "net.(*netFD).connect(": "a timing out dial",
+ ").noteClientGone(": "a closenotifier sender",
+ ").readLoop(": "a Transport",
+ ".grpc": "a gRPC resource",
+ }
+
+ var stacks string
+ begin := time.Now()
+ for time.Since(begin) < d {
+ bad = ""
+ stacks = strings.Join(interestingGoroutines(), "\n\n")
+ for substr, what := range badSubstring {
+ if strings.Contains(stacks, substr) {
+ bad = what
+ }
+ }
+ if bad == "" {
+ return nil
+ }
+ // Bad stuff found, but goroutines might just still be
+ // shutting down, so give it some time.
+ time.Sleep(50 * time.Millisecond)
+ }
+ return fmt.Errorf("appears to have leaked %s:\n%s", bad, stacks)
+}
+
+// AfterTest is meant to run in a defer that executes after a test completes.
+// It will detect common goroutine leaks, retrying in case there are goroutines
+// not synchronously torn down, and fail the test if any goroutines are stuck.
+func AfterTest(t *testing.T) {
+ if err := CheckAfterTest(300 * time.Millisecond); err != nil {
+ t.Errorf("Test %v", err)
+ }
+}
+
+func interestingGoroutines() (gs []string) {
+ buf := make([]byte, 2<<20)
+ buf = buf[:runtime.Stack(buf, true)]
+ for _, g := range strings.Split(string(buf), "\n\n") {
+ sl := strings.SplitN(g, "\n", 2)
+ if len(sl) != 2 {
+ continue
+ }
+ stack := strings.TrimSpace(sl[1])
+ if stack == "" ||
+ strings.Contains(stack, "sync.(*WaitGroup).Done") ||
+ strings.Contains(stack, "created by os/signal.init") ||
+ strings.Contains(stack, "runtime/panic.go") ||
+ strings.Contains(stack, "created by testing.RunTests") ||
+ strings.Contains(stack, "testing.Main(") ||
+ strings.Contains(stack, "runtime.goexit") ||
+ strings.Contains(stack, "github.com/coreos/etcd/pkg/testutil.interestingGoroutines") ||
+ strings.Contains(stack, "github.com/coreos/etcd/pkg/logutil.(*MergeLogger).outputLoop") ||
+ strings.Contains(stack, "github.com/golang/glog.(*loggingT).flushDaemon") ||
+ strings.Contains(stack, "created by runtime.gc") ||
+ strings.Contains(stack, "runtime.MHeap_Scavenger") {
+ continue
+ }
+ gs = append(gs, stack)
+ }
+ sort.Strings(gs)
+ return
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/testutil/leak_test.go b/vendor/github.com/coreos/etcd/pkg/testutil/leak_test.go
new file mode 100644
index 00000000..c6f34efc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/testutil/leak_test.go
@@ -0,0 +1,44 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 testutil
+
+import (
+ "fmt"
+ "os"
+ "testing"
+)
+
+// so tests pass if given a -run that doesn't include TestSample
+var ranSample = false
+
+func TestMain(m *testing.M) {
+ m.Run()
+ isLeaked := CheckLeakedGoroutine()
+ if ranSample && !isLeaked {
+ fmt.Fprintln(os.Stderr, "expected leaky goroutines but none is detected")
+ os.Exit(1)
+ }
+ os.Exit(0)
+}
+
+func TestSample(t *testing.T) {
+ defer AfterTest(t)
+ ranSample = true
+ for range make([]struct{}, 100) {
+ go func() {
+ select {}
+ }()
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/testutil/pauseable_handler.go b/vendor/github.com/coreos/etcd/pkg/testutil/pauseable_handler.go
new file mode 100644
index 00000000..e0d6aca2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/testutil/pauseable_handler.go
@@ -0,0 +1,57 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 testutil
+
+import (
+ "net/http"
+ "sync"
+)
+
+type PauseableHandler struct {
+ Next http.Handler
+ mu sync.Mutex
+ paused bool
+}
+
+func (ph *PauseableHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ ph.mu.Lock()
+ paused := ph.paused
+ ph.mu.Unlock()
+ if !paused {
+ ph.Next.ServeHTTP(w, r)
+ } else {
+ hj, ok := w.(http.Hijacker)
+ if !ok {
+ panic("webserver doesn't support hijacking")
+ }
+ conn, _, err := hj.Hijack()
+ if err != nil {
+ panic(err.Error())
+ }
+ conn.Close()
+ }
+}
+
+func (ph *PauseableHandler) Pause() {
+ ph.mu.Lock()
+ defer ph.mu.Unlock()
+ ph.paused = true
+}
+
+func (ph *PauseableHandler) Resume() {
+ ph.mu.Lock()
+ defer ph.mu.Unlock()
+ ph.paused = false
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/testutil/recorder.go b/vendor/github.com/coreos/etcd/pkg/testutil/recorder.go
new file mode 100644
index 00000000..bdbbd8cc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/testutil/recorder.go
@@ -0,0 +1,132 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 testutil
+
+import (
+ "errors"
+ "fmt"
+ "sync"
+ "time"
+)
+
+type Action struct {
+ Name string
+ Params []interface{}
+}
+
+type Recorder interface {
+ // Record publishes an Action (e.g., function call) which will
+ // be reflected by Wait() or Chan()
+ Record(a Action)
+ // Wait waits until at least n Actions are available or returns with error
+ Wait(n int) ([]Action, error)
+ // Action returns immediately available Actions
+ Action() []Action
+ // Chan returns the channel for actions published by Record
+ Chan() <-chan Action
+}
+
+// RecorderBuffered appends all Actions to a slice
+type RecorderBuffered struct {
+ sync.Mutex
+ actions []Action
+}
+
+func (r *RecorderBuffered) Record(a Action) {
+ r.Lock()
+ r.actions = append(r.actions, a)
+ r.Unlock()
+}
+func (r *RecorderBuffered) Action() []Action {
+ r.Lock()
+ cpy := make([]Action, len(r.actions))
+ copy(cpy, r.actions)
+ r.Unlock()
+ return cpy
+}
+func (r *RecorderBuffered) Wait(n int) (acts []Action, err error) {
+ // legacy racey behavior
+ WaitSchedule()
+ acts = r.Action()
+ if len(acts) < n {
+ err = newLenErr(n, len(acts))
+ }
+ return acts, err
+}
+
+func (r *RecorderBuffered) Chan() <-chan Action {
+ ch := make(chan Action)
+ go func() {
+ acts := r.Action()
+ for i := range acts {
+ ch <- acts[i]
+ }
+ close(ch)
+ }()
+ return ch
+}
+
+// RecorderStream writes all Actions to an unbuffered channel
+type recorderStream struct {
+ ch chan Action
+}
+
+func NewRecorderStream() Recorder {
+ return &recorderStream{ch: make(chan Action)}
+}
+
+func (r *recorderStream) Record(a Action) {
+ r.ch <- a
+}
+
+func (r *recorderStream) Action() (acts []Action) {
+ for {
+ select {
+ case act := <-r.ch:
+ acts = append(acts, act)
+ default:
+ return acts
+ }
+ }
+}
+
+func (r *recorderStream) Chan() <-chan Action {
+ return r.ch
+}
+
+func (r *recorderStream) Wait(n int) ([]Action, error) {
+ acts := make([]Action, n)
+ timeoutC := time.After(5 * time.Second)
+ for i := 0; i < n; i++ {
+ select {
+ case acts[i] = <-r.ch:
+ case <-timeoutC:
+ acts = acts[:i]
+ return acts, newLenErr(n, i)
+ }
+ }
+ // extra wait to catch any Action spew
+ select {
+ case act := <-r.ch:
+ acts = append(acts, act)
+ case <-time.After(10 * time.Millisecond):
+ }
+ return acts, nil
+}
+
+func newLenErr(expected int, actual int) error {
+ s := fmt.Sprintf("len(actions) = %d, expected >= %d", actual, expected)
+ return errors.New(s)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/testutil/testutil.go b/vendor/github.com/coreos/etcd/pkg/testutil/testutil.go
new file mode 100644
index 00000000..db2dd328
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/testutil/testutil.go
@@ -0,0 +1,57 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 testutil provides test utility functions.
+package testutil
+
+import (
+ "net/url"
+ "runtime"
+ "testing"
+ "time"
+)
+
+// WaitSchedule briefly sleeps in order to invoke the go scheduler.
+// TODO: improve this when we are able to know the schedule or status of target go-routine.
+func WaitSchedule() {
+ time.Sleep(10 * time.Millisecond)
+}
+
+func MustNewURLs(t *testing.T, urls []string) []url.URL {
+ if urls == nil {
+ return nil
+ }
+ var us []url.URL
+ for _, url := range urls {
+ u := MustNewURL(t, url)
+ us = append(us, *u)
+ }
+ return us
+}
+
+func MustNewURL(t *testing.T, s string) *url.URL {
+ u, err := url.Parse(s)
+ if err != nil {
+ t.Fatalf("parse %v error: %v", s, err)
+ }
+ return u
+}
+
+// FatalStack helps to fatal the test and print out the stacks of all running goroutines.
+func FatalStack(t *testing.T, s string) {
+ stackTrace := make([]byte, 1024*1024)
+ n := runtime.Stack(stackTrace, true)
+ t.Error(string(stackTrace[:n]))
+ t.Fatalf(s)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/tlsutil/doc.go b/vendor/github.com/coreos/etcd/pkg/tlsutil/doc.go
new file mode 100644
index 00000000..3b6aa670
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/tlsutil/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 tlsutil provides utility functions for handling TLS.
+package tlsutil
diff --git a/vendor/github.com/coreos/etcd/pkg/tlsutil/tlsutil.go b/vendor/github.com/coreos/etcd/pkg/tlsutil/tlsutil.go
new file mode 100644
index 00000000..79b1f632
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/tlsutil/tlsutil.go
@@ -0,0 +1,72 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 tlsutil
+
+import (
+ "crypto/tls"
+ "crypto/x509"
+ "encoding/pem"
+ "io/ioutil"
+)
+
+// NewCertPool creates x509 certPool with provided CA files.
+func NewCertPool(CAFiles []string) (*x509.CertPool, error) {
+ certPool := x509.NewCertPool()
+
+ for _, CAFile := range CAFiles {
+ pemByte, err := ioutil.ReadFile(CAFile)
+ if err != nil {
+ return nil, err
+ }
+
+ for {
+ var block *pem.Block
+ block, pemByte = pem.Decode(pemByte)
+ if block == nil {
+ break
+ }
+ cert, err := x509.ParseCertificate(block.Bytes)
+ if err != nil {
+ return nil, err
+ }
+ certPool.AddCert(cert)
+ }
+ }
+
+ return certPool, nil
+}
+
+// NewCert generates TLS cert by using the given cert,key and parse function.
+func NewCert(certfile, keyfile string, parseFunc func([]byte, []byte) (tls.Certificate, error)) (*tls.Certificate, error) {
+ cert, err := ioutil.ReadFile(certfile)
+ if err != nil {
+ return nil, err
+ }
+
+ key, err := ioutil.ReadFile(keyfile)
+ if err != nil {
+ return nil, err
+ }
+
+ if parseFunc == nil {
+ parseFunc = tls.X509KeyPair
+ }
+
+ tlsCert, err := parseFunc(cert, key)
+ if err != nil {
+ return nil, err
+ }
+ return &tlsCert, nil
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/doc.go b/vendor/github.com/coreos/etcd/pkg/transport/doc.go
new file mode 100644
index 00000000..37658ce5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/doc.go
@@ -0,0 +1,17 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 transport implements various HTTP transport utilities based on Go
+// net package.
+package transport
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/keepalive_listener.go b/vendor/github.com/coreos/etcd/pkg/transport/keepalive_listener.go
new file mode 100644
index 00000000..6ccae4ee
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/keepalive_listener.go
@@ -0,0 +1,94 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "crypto/tls"
+ "fmt"
+ "net"
+ "time"
+)
+
+type keepAliveConn interface {
+ SetKeepAlive(bool) error
+ SetKeepAlivePeriod(d time.Duration) error
+}
+
+// NewKeepAliveListener returns a listener that listens on the given address.
+// Be careful when wrap around KeepAliveListener with another Listener if TLSInfo is not nil.
+// Some pkgs (like go/http) might expect Listener to return TLSConn type to start TLS handshake.
+// http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html
+func NewKeepAliveListener(l net.Listener, scheme string, tlscfg *tls.Config) (net.Listener, error) {
+ if scheme == "https" {
+ if tlscfg == nil {
+ return nil, fmt.Errorf("cannot listen on TLS for given listener: KeyFile and CertFile are not presented")
+ }
+ return newTLSKeepaliveListener(l, tlscfg), nil
+ }
+
+ return &keepaliveListener{
+ Listener: l,
+ }, nil
+}
+
+type keepaliveListener struct{ net.Listener }
+
+func (kln *keepaliveListener) Accept() (net.Conn, error) {
+ c, err := kln.Listener.Accept()
+ if err != nil {
+ return nil, err
+ }
+ kac := c.(keepAliveConn)
+ // detection time: tcp_keepalive_time + tcp_keepalive_probes + tcp_keepalive_intvl
+ // default on linux: 30 + 8 * 30
+ // default on osx: 30 + 8 * 75
+ kac.SetKeepAlive(true)
+ kac.SetKeepAlivePeriod(30 * time.Second)
+ return c, nil
+}
+
+// A tlsKeepaliveListener implements a network listener (net.Listener) for TLS connections.
+type tlsKeepaliveListener struct {
+ net.Listener
+ config *tls.Config
+}
+
+// Accept waits for and returns the next incoming TLS connection.
+// The returned connection c is a *tls.Conn.
+func (l *tlsKeepaliveListener) Accept() (c net.Conn, err error) {
+ c, err = l.Listener.Accept()
+ if err != nil {
+ return
+ }
+ kac := c.(keepAliveConn)
+ // detection time: tcp_keepalive_time + tcp_keepalive_probes + tcp_keepalive_intvl
+ // default on linux: 30 + 8 * 30
+ // default on osx: 30 + 8 * 75
+ kac.SetKeepAlive(true)
+ kac.SetKeepAlivePeriod(30 * time.Second)
+ c = tls.Server(c, l.config)
+ return
+}
+
+// NewListener creates a Listener which accepts connections from an inner
+// Listener and wraps each connection with Server.
+// The configuration config must be non-nil and must have
+// at least one certificate.
+func newTLSKeepaliveListener(inner net.Listener, config *tls.Config) net.Listener {
+ l := &tlsKeepaliveListener{}
+ l.Listener = inner
+ l.config = config
+ return l
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/keepalive_listener_test.go b/vendor/github.com/coreos/etcd/pkg/transport/keepalive_listener_test.go
new file mode 100644
index 00000000..425f5336
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/keepalive_listener_test.go
@@ -0,0 +1,90 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "crypto/tls"
+ "net"
+ "net/http"
+ "testing"
+)
+
+// TestNewKeepAliveListener tests NewKeepAliveListener returns a listener
+// that accepts connections.
+// TODO: verify the keepalive option is set correctly
+func TestNewKeepAliveListener(t *testing.T) {
+ ln, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatalf("unexpected listen error: %v", err)
+ }
+
+ ln, err = NewKeepAliveListener(ln, "http", nil)
+ if err != nil {
+ t.Fatalf("unexpected NewKeepAliveListener error: %v", err)
+ }
+
+ go http.Get("http://" + ln.Addr().String())
+ conn, err := ln.Accept()
+ if err != nil {
+ t.Fatalf("unexpected Accept error: %v", err)
+ }
+ conn.Close()
+ ln.Close()
+
+ ln, err = net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatalf("unexpected Listen error: %v", err)
+ }
+
+ // tls
+ tlsinfo, del, err := createSelfCert()
+ if err != nil {
+ t.Fatalf("unable to create tmpfile: %v", err)
+ }
+ defer del()
+ tlsInfo := TLSInfo{CertFile: tlsinfo.CertFile, KeyFile: tlsinfo.KeyFile}
+ tlsInfo.parseFunc = fakeCertificateParserFunc(tls.Certificate{}, nil)
+ tlscfg, err := tlsInfo.ServerConfig()
+ if err != nil {
+ t.Fatalf("unexpected serverConfig error: %v", err)
+ }
+ tlsln, err := NewKeepAliveListener(ln, "https", tlscfg)
+ if err != nil {
+ t.Fatalf("unexpected NewKeepAliveListener error: %v", err)
+ }
+
+ go http.Get("https://" + tlsln.Addr().String())
+ conn, err = tlsln.Accept()
+ if err != nil {
+ t.Fatalf("unexpected Accept error: %v", err)
+ }
+ if _, ok := conn.(*tls.Conn); !ok {
+ t.Errorf("failed to accept *tls.Conn")
+ }
+ conn.Close()
+ tlsln.Close()
+}
+
+func TestNewKeepAliveListenerTLSEmptyConfig(t *testing.T) {
+ ln, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatalf("unexpected listen error: %v", err)
+ }
+
+ _, err = NewKeepAliveListener(ln, "https", nil)
+ if err == nil {
+ t.Errorf("err = nil, want not presented error")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/limit_listen.go b/vendor/github.com/coreos/etcd/pkg/transport/limit_listen.go
new file mode 100644
index 00000000..930c5420
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/limit_listen.go
@@ -0,0 +1,80 @@
+// Copyright 2013 The etcd Authors
+//
+// Licensed 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 transport provides network utility functions, complementing the more
+// common ones in the net package.
+package transport
+
+import (
+ "errors"
+ "net"
+ "sync"
+ "time"
+)
+
+var (
+ ErrNotTCP = errors.New("only tcp connections have keepalive")
+)
+
+// LimitListener returns a Listener that accepts at most n simultaneous
+// connections from the provided Listener.
+func LimitListener(l net.Listener, n int) net.Listener {
+ return &limitListener{l, make(chan struct{}, n)}
+}
+
+type limitListener struct {
+ net.Listener
+ sem chan struct{}
+}
+
+func (l *limitListener) acquire() { l.sem <- struct{}{} }
+func (l *limitListener) release() { <-l.sem }
+
+func (l *limitListener) Accept() (net.Conn, error) {
+ l.acquire()
+ c, err := l.Listener.Accept()
+ if err != nil {
+ l.release()
+ return nil, err
+ }
+ return &limitListenerConn{Conn: c, release: l.release}, nil
+}
+
+type limitListenerConn struct {
+ net.Conn
+ releaseOnce sync.Once
+ release func()
+}
+
+func (l *limitListenerConn) Close() error {
+ err := l.Conn.Close()
+ l.releaseOnce.Do(l.release)
+ return err
+}
+
+func (l *limitListenerConn) SetKeepAlive(doKeepAlive bool) error {
+ tcpc, ok := l.Conn.(*net.TCPConn)
+ if !ok {
+ return ErrNotTCP
+ }
+ return tcpc.SetKeepAlive(doKeepAlive)
+}
+
+func (l *limitListenerConn) SetKeepAlivePeriod(d time.Duration) error {
+ tcpc, ok := l.Conn.(*net.TCPConn)
+ if !ok {
+ return ErrNotTCP
+ }
+ return tcpc.SetKeepAlivePeriod(d)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/listener.go b/vendor/github.com/coreos/etcd/pkg/transport/listener.go
new file mode 100644
index 00000000..3b58b415
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/listener.go
@@ -0,0 +1,260 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "crypto/ecdsa"
+ "crypto/elliptic"
+ "crypto/rand"
+ "crypto/tls"
+ "crypto/x509"
+ "crypto/x509/pkix"
+ "encoding/pem"
+ "fmt"
+ "math/big"
+ "net"
+ "os"
+ "path/filepath"
+ "strings"
+ "time"
+
+ "github.com/coreos/etcd/pkg/tlsutil"
+)
+
+func NewListener(addr, scheme string, tlsinfo *TLSInfo) (l net.Listener, err error) {
+ if l, err = newListener(addr, scheme); err != nil {
+ return nil, err
+ }
+ return wrapTLS(addr, scheme, tlsinfo, l)
+}
+
+func newListener(addr string, scheme string) (net.Listener, error) {
+ if scheme == "unix" || scheme == "unixs" {
+ // unix sockets via unix://laddr
+ return NewUnixListener(addr)
+ }
+ return net.Listen("tcp", addr)
+}
+
+func wrapTLS(addr, scheme string, tlsinfo *TLSInfo, l net.Listener) (net.Listener, error) {
+ if scheme != "https" && scheme != "unixs" {
+ return l, nil
+ }
+ return newTLSListener(l, tlsinfo)
+}
+
+type TLSInfo struct {
+ CertFile string
+ KeyFile string
+ CAFile string
+ TrustedCAFile string
+ ClientCertAuth bool
+
+ // ServerName ensures the cert matches the given host in case of discovery / virtual hosting
+ ServerName string
+
+ // HandshakeFailure is optionally called when a connection fails to handshake. The
+ // connection will be closed immediately afterwards.
+ HandshakeFailure func(*tls.Conn, error)
+
+ selfCert bool
+
+ // parseFunc exists to simplify testing. Typically, parseFunc
+ // should be left nil. In that case, tls.X509KeyPair will be used.
+ parseFunc func([]byte, []byte) (tls.Certificate, error)
+}
+
+func (info TLSInfo) String() string {
+ return fmt.Sprintf("cert = %s, key = %s, ca = %s, trusted-ca = %s, client-cert-auth = %v", info.CertFile, info.KeyFile, info.CAFile, info.TrustedCAFile, info.ClientCertAuth)
+}
+
+func (info TLSInfo) Empty() bool {
+ return info.CertFile == "" && info.KeyFile == ""
+}
+
+func SelfCert(dirpath string, hosts []string) (info TLSInfo, err error) {
+ if err = os.MkdirAll(dirpath, 0700); err != nil {
+ return
+ }
+
+ certPath := filepath.Join(dirpath, "cert.pem")
+ keyPath := filepath.Join(dirpath, "key.pem")
+ _, errcert := os.Stat(certPath)
+ _, errkey := os.Stat(keyPath)
+ if errcert == nil && errkey == nil {
+ info.CertFile = certPath
+ info.KeyFile = keyPath
+ info.selfCert = true
+ return
+ }
+
+ serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
+ serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
+ if err != nil {
+ return
+ }
+
+ tmpl := x509.Certificate{
+ SerialNumber: serialNumber,
+ Subject: pkix.Name{Organization: []string{"etcd"}},
+ NotBefore: time.Now(),
+ NotAfter: time.Now().Add(365 * (24 * time.Hour)),
+
+ KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
+ ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
+ BasicConstraintsValid: true,
+ }
+
+ for _, host := range hosts {
+ h, _, _ := net.SplitHostPort(host)
+ if ip := net.ParseIP(h); ip != nil {
+ tmpl.IPAddresses = append(tmpl.IPAddresses, ip)
+ } else {
+ tmpl.DNSNames = append(tmpl.DNSNames, h)
+ }
+ }
+
+ priv, err := ecdsa.GenerateKey(elliptic.P521(), rand.Reader)
+ if err != nil {
+ return
+ }
+
+ derBytes, err := x509.CreateCertificate(rand.Reader, &tmpl, &tmpl, &priv.PublicKey, priv)
+ if err != nil {
+ return
+ }
+
+ certOut, err := os.Create(certPath)
+ if err != nil {
+ return
+ }
+ pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes})
+ certOut.Close()
+
+ b, err := x509.MarshalECPrivateKey(priv)
+ if err != nil {
+ return
+ }
+ keyOut, err := os.OpenFile(keyPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
+ if err != nil {
+ return
+ }
+ pem.Encode(keyOut, &pem.Block{Type: "EC PRIVATE KEY", Bytes: b})
+ keyOut.Close()
+
+ return SelfCert(dirpath, hosts)
+}
+
+func (info TLSInfo) baseConfig() (*tls.Config, error) {
+ if info.KeyFile == "" || info.CertFile == "" {
+ return nil, fmt.Errorf("KeyFile and CertFile must both be present[key: %v, cert: %v]", info.KeyFile, info.CertFile)
+ }
+
+ tlsCert, err := tlsutil.NewCert(info.CertFile, info.KeyFile, info.parseFunc)
+ if err != nil {
+ return nil, err
+ }
+
+ cfg := &tls.Config{
+ Certificates: []tls.Certificate{*tlsCert},
+ MinVersion: tls.VersionTLS12,
+ ServerName: info.ServerName,
+ }
+ // this only reloads certs when there's a client request
+ // TODO: support server-side refresh (e.g. inotify, SIGHUP), caching
+ cfg.GetCertificate = func(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error) {
+ return tlsutil.NewCert(info.CertFile, info.KeyFile, info.parseFunc)
+ }
+ cfg.GetClientCertificate = func(unused *tls.CertificateRequestInfo) (*tls.Certificate, error) {
+ return tlsutil.NewCert(info.CertFile, info.KeyFile, info.parseFunc)
+ }
+ return cfg, nil
+}
+
+// cafiles returns a list of CA file paths.
+func (info TLSInfo) cafiles() []string {
+ cs := make([]string, 0)
+ if info.CAFile != "" {
+ cs = append(cs, info.CAFile)
+ }
+ if info.TrustedCAFile != "" {
+ cs = append(cs, info.TrustedCAFile)
+ }
+ return cs
+}
+
+// ServerConfig generates a tls.Config object for use by an HTTP server.
+func (info TLSInfo) ServerConfig() (*tls.Config, error) {
+ cfg, err := info.baseConfig()
+ if err != nil {
+ return nil, err
+ }
+
+ cfg.ClientAuth = tls.NoClientCert
+ if info.CAFile != "" || info.ClientCertAuth {
+ cfg.ClientAuth = tls.RequireAndVerifyClientCert
+ }
+
+ CAFiles := info.cafiles()
+ if len(CAFiles) > 0 {
+ cp, err := tlsutil.NewCertPool(CAFiles)
+ if err != nil {
+ return nil, err
+ }
+ cfg.ClientCAs = cp
+ }
+
+ // "h2" NextProtos is necessary for enabling HTTP2 for go's HTTP server
+ cfg.NextProtos = []string{"h2"}
+
+ return cfg, nil
+}
+
+// ClientConfig generates a tls.Config object for use by an HTTP client.
+func (info TLSInfo) ClientConfig() (*tls.Config, error) {
+ var cfg *tls.Config
+ var err error
+
+ if !info.Empty() {
+ cfg, err = info.baseConfig()
+ if err != nil {
+ return nil, err
+ }
+ } else {
+ cfg = &tls.Config{ServerName: info.ServerName}
+ }
+
+ CAFiles := info.cafiles()
+ if len(CAFiles) > 0 {
+ cfg.RootCAs, err = tlsutil.NewCertPool(CAFiles)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ if info.selfCert {
+ cfg.InsecureSkipVerify = true
+ }
+ return cfg, nil
+}
+
+// IsClosedConnError returns true if the error is from closing listener, cmux.
+// copied from golang.org/x/net/http2/http2.go
+func IsClosedConnError(err error) bool {
+ // 'use of closed network connection' (Go <=1.8)
+ // 'use of closed file or network connection' (Go >1.8, internal/poll.ErrClosing)
+ // 'mux: listener closed' (cmux.ErrListenerClosed)
+ return err != nil && strings.Contains(err.Error(), "closed")
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/listener_test.go b/vendor/github.com/coreos/etcd/pkg/transport/listener_test.go
new file mode 100644
index 00000000..6cc44a11
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/listener_test.go
@@ -0,0 +1,282 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "crypto/tls"
+ "errors"
+ "io/ioutil"
+ "net/http"
+ "os"
+ "testing"
+ "time"
+)
+
+func createSelfCert() (*TLSInfo, func(), error) {
+ d, terr := ioutil.TempDir("", "etcd-test-tls-")
+ if terr != nil {
+ return nil, nil, terr
+ }
+ info, err := SelfCert(d, []string{"127.0.0.1"})
+ if err != nil {
+ return nil, nil, err
+ }
+ return &info, func() { os.RemoveAll(d) }, nil
+}
+
+func fakeCertificateParserFunc(cert tls.Certificate, err error) func(certPEMBlock, keyPEMBlock []byte) (tls.Certificate, error) {
+ return func(certPEMBlock, keyPEMBlock []byte) (tls.Certificate, error) {
+ return cert, err
+ }
+}
+
+// TestNewListenerTLSInfo tests that NewListener with valid TLSInfo returns
+// a TLS listener that accepts TLS connections.
+func TestNewListenerTLSInfo(t *testing.T) {
+ tlsInfo, del, err := createSelfCert()
+ if err != nil {
+ t.Fatalf("unable to create cert: %v", err)
+ }
+ defer del()
+ testNewListenerTLSInfoAccept(t, *tlsInfo)
+}
+
+func testNewListenerTLSInfoAccept(t *testing.T, tlsInfo TLSInfo) {
+ ln, err := NewListener("127.0.0.1:0", "https", &tlsInfo)
+ if err != nil {
+ t.Fatalf("unexpected NewListener error: %v", err)
+ }
+ defer ln.Close()
+
+ tr := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}
+ cli := &http.Client{Transport: tr}
+ go cli.Get("https://" + ln.Addr().String())
+
+ conn, err := ln.Accept()
+ if err != nil {
+ t.Fatalf("unexpected Accept error: %v", err)
+ }
+ defer conn.Close()
+ if _, ok := conn.(*tls.Conn); !ok {
+ t.Errorf("failed to accept *tls.Conn")
+ }
+}
+
+func TestNewListenerTLSEmptyInfo(t *testing.T) {
+ _, err := NewListener("127.0.0.1:0", "https", nil)
+ if err == nil {
+ t.Errorf("err = nil, want not presented error")
+ }
+}
+
+func TestNewTransportTLSInfo(t *testing.T) {
+ tlsinfo, del, err := createSelfCert()
+ if err != nil {
+ t.Fatalf("unable to create cert: %v", err)
+ }
+ defer del()
+
+ tests := []TLSInfo{
+ {},
+ {
+ CertFile: tlsinfo.CertFile,
+ KeyFile: tlsinfo.KeyFile,
+ },
+ {
+ CertFile: tlsinfo.CertFile,
+ KeyFile: tlsinfo.KeyFile,
+ CAFile: tlsinfo.CAFile,
+ },
+ {
+ CAFile: tlsinfo.CAFile,
+ },
+ }
+
+ for i, tt := range tests {
+ tt.parseFunc = fakeCertificateParserFunc(tls.Certificate{}, nil)
+ trans, err := NewTransport(tt, time.Second)
+ if err != nil {
+ t.Fatalf("Received unexpected error from NewTransport: %v", err)
+ }
+
+ if trans.TLSClientConfig == nil {
+ t.Fatalf("#%d: want non-nil TLSClientConfig", i)
+ }
+ }
+}
+
+func TestTLSInfoNonexist(t *testing.T) {
+ tlsInfo := TLSInfo{CertFile: "@badname", KeyFile: "@badname"}
+ _, err := tlsInfo.ServerConfig()
+ werr := &os.PathError{
+ Op: "open",
+ Path: "@badname",
+ Err: errors.New("no such file or directory"),
+ }
+ if err.Error() != werr.Error() {
+ t.Errorf("err = %v, want %v", err, werr)
+ }
+}
+
+func TestTLSInfoEmpty(t *testing.T) {
+ tests := []struct {
+ info TLSInfo
+ want bool
+ }{
+ {TLSInfo{}, true},
+ {TLSInfo{CAFile: "baz"}, true},
+ {TLSInfo{CertFile: "foo"}, false},
+ {TLSInfo{KeyFile: "bar"}, false},
+ {TLSInfo{CertFile: "foo", KeyFile: "bar"}, false},
+ {TLSInfo{CertFile: "foo", CAFile: "baz"}, false},
+ {TLSInfo{KeyFile: "bar", CAFile: "baz"}, false},
+ {TLSInfo{CertFile: "foo", KeyFile: "bar", CAFile: "baz"}, false},
+ }
+
+ for i, tt := range tests {
+ got := tt.info.Empty()
+ if tt.want != got {
+ t.Errorf("#%d: result of Empty() incorrect: want=%t got=%t", i, tt.want, got)
+ }
+ }
+}
+
+func TestTLSInfoMissingFields(t *testing.T) {
+ tlsinfo, del, err := createSelfCert()
+ if err != nil {
+ t.Fatalf("unable to create cert: %v", err)
+ }
+ defer del()
+
+ tests := []TLSInfo{
+ {CertFile: tlsinfo.CertFile},
+ {KeyFile: tlsinfo.KeyFile},
+ {CertFile: tlsinfo.CertFile, CAFile: tlsinfo.CAFile},
+ {KeyFile: tlsinfo.KeyFile, CAFile: tlsinfo.CAFile},
+ }
+
+ for i, info := range tests {
+ if _, err = info.ServerConfig(); err == nil {
+ t.Errorf("#%d: expected non-nil error from ServerConfig()", i)
+ }
+
+ if _, err = info.ClientConfig(); err == nil {
+ t.Errorf("#%d: expected non-nil error from ClientConfig()", i)
+ }
+ }
+}
+
+func TestTLSInfoParseFuncError(t *testing.T) {
+ tlsinfo, del, err := createSelfCert()
+ if err != nil {
+ t.Fatalf("unable to create cert: %v", err)
+ }
+ defer del()
+
+ tlsinfo.parseFunc = fakeCertificateParserFunc(tls.Certificate{}, errors.New("fake"))
+
+ if _, err = tlsinfo.ServerConfig(); err == nil {
+ t.Errorf("expected non-nil error from ServerConfig()")
+ }
+
+ if _, err = tlsinfo.ClientConfig(); err == nil {
+ t.Errorf("expected non-nil error from ClientConfig()")
+ }
+}
+
+func TestTLSInfoConfigFuncs(t *testing.T) {
+ tlsinfo, del, err := createSelfCert()
+ if err != nil {
+ t.Fatalf("unable to create cert: %v", err)
+ }
+ defer del()
+
+ tests := []struct {
+ info TLSInfo
+ clientAuth tls.ClientAuthType
+ wantCAs bool
+ }{
+ {
+ info: TLSInfo{CertFile: tlsinfo.CertFile, KeyFile: tlsinfo.KeyFile},
+ clientAuth: tls.NoClientCert,
+ wantCAs: false,
+ },
+
+ {
+ info: TLSInfo{CertFile: tlsinfo.CertFile, KeyFile: tlsinfo.KeyFile, CAFile: tlsinfo.CertFile},
+ clientAuth: tls.RequireAndVerifyClientCert,
+ wantCAs: true,
+ },
+ }
+
+ for i, tt := range tests {
+ tt.info.parseFunc = fakeCertificateParserFunc(tls.Certificate{}, nil)
+
+ sCfg, err := tt.info.ServerConfig()
+ if err != nil {
+ t.Errorf("#%d: expected nil error from ServerConfig(), got non-nil: %v", i, err)
+ }
+
+ if tt.wantCAs != (sCfg.ClientCAs != nil) {
+ t.Errorf("#%d: wantCAs=%t but ClientCAs=%v", i, tt.wantCAs, sCfg.ClientCAs)
+ }
+
+ cCfg, err := tt.info.ClientConfig()
+ if err != nil {
+ t.Errorf("#%d: expected nil error from ClientConfig(), got non-nil: %v", i, err)
+ }
+
+ if tt.wantCAs != (cCfg.RootCAs != nil) {
+ t.Errorf("#%d: wantCAs=%t but RootCAs=%v", i, tt.wantCAs, sCfg.RootCAs)
+ }
+ }
+}
+
+func TestNewListenerUnixSocket(t *testing.T) {
+ l, err := NewListener("testsocket", "unix", nil)
+ if err != nil {
+ t.Errorf("error listening on unix socket (%v)", err)
+ }
+ l.Close()
+}
+
+// TestNewListenerTLSInfoSelfCert tests that a new certificate accepts connections.
+func TestNewListenerTLSInfoSelfCert(t *testing.T) {
+ tmpdir, err := ioutil.TempDir(os.TempDir(), "tlsdir")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(tmpdir)
+ tlsinfo, err := SelfCert(tmpdir, []string{"127.0.0.1"})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if tlsinfo.Empty() {
+ t.Fatalf("tlsinfo should have certs (%+v)", tlsinfo)
+ }
+ testNewListenerTLSInfoAccept(t, tlsinfo)
+}
+
+func TestIsClosedConnError(t *testing.T) {
+ l, err := NewListener("testsocket", "unix", nil)
+ if err != nil {
+ t.Errorf("error listening on unix socket (%v)", err)
+ }
+ l.Close()
+ _, err = l.Accept()
+ if !IsClosedConnError(err) {
+ t.Fatalf("expect true, got false (%v)", err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/listener_tls.go b/vendor/github.com/coreos/etcd/pkg/transport/listener_tls.go
new file mode 100644
index 00000000..86511860
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/listener_tls.go
@@ -0,0 +1,217 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "context"
+ "crypto/tls"
+ "crypto/x509"
+ "fmt"
+ "net"
+ "strings"
+ "sync"
+)
+
+// tlsListener overrides a TLS listener so it will reject client
+// certificates with insufficient SAN credentials.
+type tlsListener struct {
+ net.Listener
+ connc chan net.Conn
+ donec chan struct{}
+ err error
+ handshakeFailure func(*tls.Conn, error)
+}
+
+func newTLSListener(l net.Listener, tlsinfo *TLSInfo) (net.Listener, error) {
+ if tlsinfo == nil || tlsinfo.Empty() {
+ l.Close()
+ return nil, fmt.Errorf("cannot listen on TLS for %s: KeyFile and CertFile are not presented", l.Addr().String())
+ }
+ tlscfg, err := tlsinfo.ServerConfig()
+ if err != nil {
+ return nil, err
+ }
+
+ hf := tlsinfo.HandshakeFailure
+ if hf == nil {
+ hf = func(*tls.Conn, error) {}
+ }
+ tlsl := &tlsListener{
+ Listener: tls.NewListener(l, tlscfg),
+ connc: make(chan net.Conn),
+ donec: make(chan struct{}),
+ handshakeFailure: hf,
+ }
+ go tlsl.acceptLoop()
+ return tlsl, nil
+}
+
+func (l *tlsListener) Accept() (net.Conn, error) {
+ select {
+ case conn := <-l.connc:
+ return conn, nil
+ case <-l.donec:
+ return nil, l.err
+ }
+}
+
+// acceptLoop launches each TLS handshake in a separate goroutine
+// to prevent a hanging TLS connection from blocking other connections.
+func (l *tlsListener) acceptLoop() {
+ var wg sync.WaitGroup
+ var pendingMu sync.Mutex
+
+ pending := make(map[net.Conn]struct{})
+ ctx, cancel := context.WithCancel(context.Background())
+ defer func() {
+ cancel()
+ pendingMu.Lock()
+ for c := range pending {
+ c.Close()
+ }
+ pendingMu.Unlock()
+ wg.Wait()
+ close(l.donec)
+ }()
+
+ for {
+ conn, err := l.Listener.Accept()
+ if err != nil {
+ l.err = err
+ return
+ }
+
+ pendingMu.Lock()
+ pending[conn] = struct{}{}
+ pendingMu.Unlock()
+
+ wg.Add(1)
+ go func() {
+ defer func() {
+ if conn != nil {
+ conn.Close()
+ }
+ wg.Done()
+ }()
+
+ tlsConn := conn.(*tls.Conn)
+ herr := tlsConn.Handshake()
+ pendingMu.Lock()
+ delete(pending, conn)
+ pendingMu.Unlock()
+ if herr != nil {
+ l.handshakeFailure(tlsConn, herr)
+ return
+ }
+
+ st := tlsConn.ConnectionState()
+ if len(st.PeerCertificates) > 0 {
+ cert := st.PeerCertificates[0]
+ addr := tlsConn.RemoteAddr().String()
+ if cerr := checkCert(ctx, cert, addr); cerr != nil {
+ l.handshakeFailure(tlsConn, cerr)
+ return
+ }
+ }
+ select {
+ case l.connc <- tlsConn:
+ conn = nil
+ case <-ctx.Done():
+ }
+ }()
+ }
+}
+
+func checkCert(ctx context.Context, cert *x509.Certificate, remoteAddr string) error {
+ h, _, herr := net.SplitHostPort(remoteAddr)
+ if len(cert.IPAddresses) == 0 && len(cert.DNSNames) == 0 {
+ return nil
+ }
+ if herr != nil {
+ return herr
+ }
+ if len(cert.IPAddresses) > 0 {
+ cerr := cert.VerifyHostname(h)
+ if cerr == nil {
+ return nil
+ }
+ if len(cert.DNSNames) == 0 {
+ return cerr
+ }
+ }
+ if len(cert.DNSNames) > 0 {
+ ok, err := isHostInDNS(ctx, h, cert.DNSNames)
+ if ok {
+ return nil
+ }
+ errStr := ""
+ if err != nil {
+ errStr = " (" + err.Error() + ")"
+ }
+ return fmt.Errorf("tls: %q does not match any of DNSNames %q"+errStr, h, cert.DNSNames)
+ }
+ return nil
+}
+
+func isHostInDNS(ctx context.Context, host string, dnsNames []string) (ok bool, err error) {
+ // reverse lookup
+ wildcards, names := []string{}, []string{}
+ for _, dns := range dnsNames {
+ if strings.HasPrefix(dns, "*.") {
+ wildcards = append(wildcards, dns[1:])
+ } else {
+ names = append(names, dns)
+ }
+ }
+ lnames, lerr := net.DefaultResolver.LookupAddr(ctx, host)
+ for _, name := range lnames {
+ // strip trailing '.' from PTR record
+ if name[len(name)-1] == '.' {
+ name = name[:len(name)-1]
+ }
+ for _, wc := range wildcards {
+ if strings.HasSuffix(name, wc) {
+ return true, nil
+ }
+ }
+ for _, n := range names {
+ if n == name {
+ return true, nil
+ }
+ }
+ }
+ err = lerr
+
+ // forward lookup
+ for _, dns := range names {
+ addrs, lerr := net.DefaultResolver.LookupHost(ctx, dns)
+ if lerr != nil {
+ err = lerr
+ continue
+ }
+ for _, addr := range addrs {
+ if addr == host {
+ return true, nil
+ }
+ }
+ }
+ return false, err
+}
+
+func (l *tlsListener) Close() error {
+ err := l.Listener.Close()
+ <-l.donec
+ return err
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/timeout_conn.go b/vendor/github.com/coreos/etcd/pkg/transport/timeout_conn.go
new file mode 100644
index 00000000..7e8c0203
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/timeout_conn.go
@@ -0,0 +1,44 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "net"
+ "time"
+)
+
+type timeoutConn struct {
+ net.Conn
+ wtimeoutd time.Duration
+ rdtimeoutd time.Duration
+}
+
+func (c timeoutConn) Write(b []byte) (n int, err error) {
+ if c.wtimeoutd > 0 {
+ if err := c.SetWriteDeadline(time.Now().Add(c.wtimeoutd)); err != nil {
+ return 0, err
+ }
+ }
+ return c.Conn.Write(b)
+}
+
+func (c timeoutConn) Read(b []byte) (n int, err error) {
+ if c.rdtimeoutd > 0 {
+ if err := c.SetReadDeadline(time.Now().Add(c.rdtimeoutd)); err != nil {
+ return 0, err
+ }
+ }
+ return c.Conn.Read(b)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/timeout_dialer.go b/vendor/github.com/coreos/etcd/pkg/transport/timeout_dialer.go
new file mode 100644
index 00000000..6ae39ecf
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/timeout_dialer.go
@@ -0,0 +1,36 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "net"
+ "time"
+)
+
+type rwTimeoutDialer struct {
+ wtimeoutd time.Duration
+ rdtimeoutd time.Duration
+ net.Dialer
+}
+
+func (d *rwTimeoutDialer) Dial(network, address string) (net.Conn, error) {
+ conn, err := d.Dialer.Dial(network, address)
+ tconn := &timeoutConn{
+ rdtimeoutd: d.rdtimeoutd,
+ wtimeoutd: d.wtimeoutd,
+ Conn: conn,
+ }
+ return tconn, err
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/timeout_dialer_test.go b/vendor/github.com/coreos/etcd/pkg/transport/timeout_dialer_test.go
new file mode 100644
index 00000000..c082ca37
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/timeout_dialer_test.go
@@ -0,0 +1,103 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "net"
+ "testing"
+ "time"
+)
+
+func TestReadWriteTimeoutDialer(t *testing.T) {
+ stop := make(chan struct{})
+
+ ln, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatalf("unexpected listen error: %v", err)
+ }
+ ts := testBlockingServer{ln, 2, stop}
+ go ts.Start(t)
+
+ d := rwTimeoutDialer{
+ wtimeoutd: 10 * time.Millisecond,
+ rdtimeoutd: 10 * time.Millisecond,
+ }
+ conn, err := d.Dial("tcp", ln.Addr().String())
+ if err != nil {
+ t.Fatalf("unexpected dial error: %v", err)
+ }
+ defer conn.Close()
+
+ // fill the socket buffer
+ data := make([]byte, 5*1024*1024)
+ done := make(chan struct{})
+ go func() {
+ _, err = conn.Write(data)
+ done <- struct{}{}
+ }()
+
+ select {
+ case <-done:
+ // Wait 5s more than timeout to avoid delay in low-end systems;
+ // the slack was 1s extra, but that wasn't enough for CI.
+ case <-time.After(d.wtimeoutd*10 + 5*time.Second):
+ t.Fatal("wait timeout")
+ }
+
+ if operr, ok := err.(*net.OpError); !ok || operr.Op != "write" || !operr.Timeout() {
+ t.Errorf("err = %v, want write i/o timeout error", err)
+ }
+
+ conn, err = d.Dial("tcp", ln.Addr().String())
+ if err != nil {
+ t.Fatalf("unexpected dial error: %v", err)
+ }
+ defer conn.Close()
+
+ buf := make([]byte, 10)
+ go func() {
+ _, err = conn.Read(buf)
+ done <- struct{}{}
+ }()
+
+ select {
+ case <-done:
+ case <-time.After(d.rdtimeoutd * 10):
+ t.Fatal("wait timeout")
+ }
+
+ if operr, ok := err.(*net.OpError); !ok || operr.Op != "read" || !operr.Timeout() {
+ t.Errorf("err = %v, want write i/o timeout error", err)
+ }
+
+ stop <- struct{}{}
+}
+
+type testBlockingServer struct {
+ ln net.Listener
+ n int
+ stop chan struct{}
+}
+
+func (ts *testBlockingServer) Start(t *testing.T) {
+ for i := 0; i < ts.n; i++ {
+ conn, err := ts.ln.Accept()
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer conn.Close()
+ }
+ <-ts.stop
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/timeout_listener.go b/vendor/github.com/coreos/etcd/pkg/transport/timeout_listener.go
new file mode 100644
index 00000000..b35e0495
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/timeout_listener.go
@@ -0,0 +1,57 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "net"
+ "time"
+)
+
+// NewTimeoutListener returns a listener that listens on the given address.
+// If read/write on the accepted connection blocks longer than its time limit,
+// it will return timeout error.
+func NewTimeoutListener(addr string, scheme string, tlsinfo *TLSInfo, rdtimeoutd, wtimeoutd time.Duration) (net.Listener, error) {
+ ln, err := newListener(addr, scheme)
+ if err != nil {
+ return nil, err
+ }
+ ln = &rwTimeoutListener{
+ Listener: ln,
+ rdtimeoutd: rdtimeoutd,
+ wtimeoutd: wtimeoutd,
+ }
+ if ln, err = wrapTLS(addr, scheme, tlsinfo, ln); err != nil {
+ return nil, err
+ }
+ return ln, nil
+}
+
+type rwTimeoutListener struct {
+ net.Listener
+ wtimeoutd time.Duration
+ rdtimeoutd time.Duration
+}
+
+func (rwln *rwTimeoutListener) Accept() (net.Conn, error) {
+ c, err := rwln.Listener.Accept()
+ if err != nil {
+ return nil, err
+ }
+ return timeoutConn{
+ Conn: c,
+ wtimeoutd: rwln.wtimeoutd,
+ rdtimeoutd: rwln.rdtimeoutd,
+ }, nil
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/timeout_listener_test.go b/vendor/github.com/coreos/etcd/pkg/transport/timeout_listener_test.go
new file mode 100644
index 00000000..be2495d4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/timeout_listener_test.go
@@ -0,0 +1,112 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "net"
+ "testing"
+ "time"
+)
+
+// TestNewTimeoutListener tests that NewTimeoutListener returns a
+// rwTimeoutListener struct with timeouts set.
+func TestNewTimeoutListener(t *testing.T) {
+ l, err := NewTimeoutListener("127.0.0.1:0", "http", nil, time.Hour, time.Hour)
+ if err != nil {
+ t.Fatalf("unexpected NewTimeoutListener error: %v", err)
+ }
+ defer l.Close()
+ tln := l.(*rwTimeoutListener)
+ if tln.rdtimeoutd != time.Hour {
+ t.Errorf("read timeout = %s, want %s", tln.rdtimeoutd, time.Hour)
+ }
+ if tln.wtimeoutd != time.Hour {
+ t.Errorf("write timeout = %s, want %s", tln.wtimeoutd, time.Hour)
+ }
+}
+
+func TestWriteReadTimeoutListener(t *testing.T) {
+ ln, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatalf("unexpected listen error: %v", err)
+ }
+ wln := rwTimeoutListener{
+ Listener: ln,
+ wtimeoutd: 10 * time.Millisecond,
+ rdtimeoutd: 10 * time.Millisecond,
+ }
+ stop := make(chan struct{})
+
+ blocker := func() {
+ conn, derr := net.Dial("tcp", ln.Addr().String())
+ if derr != nil {
+ t.Fatalf("unexpected dail error: %v", derr)
+ }
+ defer conn.Close()
+ // block the receiver until the writer timeout
+ <-stop
+ }
+ go blocker()
+
+ conn, err := wln.Accept()
+ if err != nil {
+ t.Fatalf("unexpected accept error: %v", err)
+ }
+ defer conn.Close()
+
+ // fill the socket buffer
+ data := make([]byte, 5*1024*1024)
+ done := make(chan struct{})
+ go func() {
+ _, err = conn.Write(data)
+ done <- struct{}{}
+ }()
+
+ select {
+ case <-done:
+ // It waits 1s more to avoid delay in low-end system.
+ case <-time.After(wln.wtimeoutd*10 + time.Second):
+ t.Fatal("wait timeout")
+ }
+
+ if operr, ok := err.(*net.OpError); !ok || operr.Op != "write" || !operr.Timeout() {
+ t.Errorf("err = %v, want write i/o timeout error", err)
+ }
+ stop <- struct{}{}
+
+ go blocker()
+
+ conn, err = wln.Accept()
+ if err != nil {
+ t.Fatalf("unexpected accept error: %v", err)
+ }
+ buf := make([]byte, 10)
+
+ go func() {
+ _, err = conn.Read(buf)
+ done <- struct{}{}
+ }()
+
+ select {
+ case <-done:
+ case <-time.After(wln.rdtimeoutd * 10):
+ t.Fatal("wait timeout")
+ }
+
+ if operr, ok := err.(*net.OpError); !ok || operr.Op != "read" || !operr.Timeout() {
+ t.Errorf("err = %v, want write i/o timeout error", err)
+ }
+ stop <- struct{}{}
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/timeout_transport.go b/vendor/github.com/coreos/etcd/pkg/transport/timeout_transport.go
new file mode 100644
index 00000000..ea16b4c0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/timeout_transport.go
@@ -0,0 +1,51 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "net"
+ "net/http"
+ "time"
+)
+
+// NewTimeoutTransport returns a transport created using the given TLS info.
+// If read/write on the created connection blocks longer than its time limit,
+// it will return timeout error.
+// If read/write timeout is set, transport will not be able to reuse connection.
+func NewTimeoutTransport(info TLSInfo, dialtimeoutd, rdtimeoutd, wtimeoutd time.Duration) (*http.Transport, error) {
+ tr, err := NewTransport(info, dialtimeoutd)
+ if err != nil {
+ return nil, err
+ }
+
+ if rdtimeoutd != 0 || wtimeoutd != 0 {
+ // the timed out connection will timeout soon after it is idle.
+ // it should not be put back to http transport as an idle connection for future usage.
+ tr.MaxIdleConnsPerHost = -1
+ } else {
+ // allow more idle connections between peers to avoid unnecessary port allocation.
+ tr.MaxIdleConnsPerHost = 1024
+ }
+
+ tr.Dial = (&rwTimeoutDialer{
+ Dialer: net.Dialer{
+ Timeout: dialtimeoutd,
+ KeepAlive: 30 * time.Second,
+ },
+ rdtimeoutd: rdtimeoutd,
+ wtimeoutd: wtimeoutd,
+ }).Dial
+ return tr, nil
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/timeout_transport_test.go b/vendor/github.com/coreos/etcd/pkg/transport/timeout_transport_test.go
new file mode 100644
index 00000000..f64fd01f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/timeout_transport_test.go
@@ -0,0 +1,85 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "bytes"
+ "io/ioutil"
+ "net/http"
+ "net/http/httptest"
+ "testing"
+ "time"
+)
+
+// TestNewTimeoutTransport tests that NewTimeoutTransport returns a transport
+// that can dial out timeout connections.
+func TestNewTimeoutTransport(t *testing.T) {
+ tr, err := NewTimeoutTransport(TLSInfo{}, time.Hour, time.Hour, time.Hour)
+ if err != nil {
+ t.Fatalf("unexpected NewTimeoutTransport error: %v", err)
+ }
+
+ remoteAddr := func(w http.ResponseWriter, r *http.Request) {
+ w.Write([]byte(r.RemoteAddr))
+ }
+ srv := httptest.NewServer(http.HandlerFunc(remoteAddr))
+
+ defer srv.Close()
+ conn, err := tr.Dial("tcp", srv.Listener.Addr().String())
+ if err != nil {
+ t.Fatalf("unexpected dial error: %v", err)
+ }
+ defer conn.Close()
+
+ tconn, ok := conn.(*timeoutConn)
+ if !ok {
+ t.Fatalf("failed to dial out *timeoutConn")
+ }
+ if tconn.rdtimeoutd != time.Hour {
+ t.Errorf("read timeout = %s, want %s", tconn.rdtimeoutd, time.Hour)
+ }
+ if tconn.wtimeoutd != time.Hour {
+ t.Errorf("write timeout = %s, want %s", tconn.wtimeoutd, time.Hour)
+ }
+
+ // ensure not reuse timeout connection
+ req, err := http.NewRequest("GET", srv.URL, nil)
+ if err != nil {
+ t.Fatalf("unexpected err %v", err)
+ }
+ resp, err := tr.RoundTrip(req)
+ if err != nil {
+ t.Fatalf("unexpected err %v", err)
+ }
+ addr0, err := ioutil.ReadAll(resp.Body)
+ resp.Body.Close()
+ if err != nil {
+ t.Fatalf("unexpected err %v", err)
+ }
+
+ resp, err = tr.RoundTrip(req)
+ if err != nil {
+ t.Fatalf("unexpected err %v", err)
+ }
+ addr1, err := ioutil.ReadAll(resp.Body)
+ resp.Body.Close()
+ if err != nil {
+ t.Fatalf("unexpected err %v", err)
+ }
+
+ if bytes.Equal(addr0, addr1) {
+ t.Errorf("addr0 = %s addr1= %s, want not equal", string(addr0), string(addr1))
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/tls.go b/vendor/github.com/coreos/etcd/pkg/transport/tls.go
new file mode 100644
index 00000000..62fe0d38
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/tls.go
@@ -0,0 +1,49 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "fmt"
+ "strings"
+ "time"
+)
+
+// ValidateSecureEndpoints scans the given endpoints against tls info, returning only those
+// endpoints that could be validated as secure.
+func ValidateSecureEndpoints(tlsInfo TLSInfo, eps []string) ([]string, error) {
+ t, err := NewTransport(tlsInfo, 5*time.Second)
+ if err != nil {
+ return nil, err
+ }
+ var errs []string
+ var endpoints []string
+ for _, ep := range eps {
+ if !strings.HasPrefix(ep, "https://") {
+ errs = append(errs, fmt.Sprintf("%q is insecure", ep))
+ continue
+ }
+ conn, cerr := t.Dial("tcp", ep[len("https://"):])
+ if cerr != nil {
+ errs = append(errs, fmt.Sprintf("%q failed to dial (%v)", ep, cerr))
+ continue
+ }
+ conn.Close()
+ endpoints = append(endpoints, ep)
+ }
+ if len(errs) != 0 {
+ err = fmt.Errorf("%s", strings.Join(errs, ","))
+ }
+ return endpoints, err
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/transport.go b/vendor/github.com/coreos/etcd/pkg/transport/transport.go
new file mode 100644
index 00000000..4a7fe69d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/transport.go
@@ -0,0 +1,71 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "net"
+ "net/http"
+ "strings"
+ "time"
+)
+
+type unixTransport struct{ *http.Transport }
+
+func NewTransport(info TLSInfo, dialtimeoutd time.Duration) (*http.Transport, error) {
+ cfg, err := info.ClientConfig()
+ if err != nil {
+ return nil, err
+ }
+
+ t := &http.Transport{
+ Proxy: http.ProxyFromEnvironment,
+ Dial: (&net.Dialer{
+ Timeout: dialtimeoutd,
+ // value taken from http.DefaultTransport
+ KeepAlive: 30 * time.Second,
+ }).Dial,
+ // value taken from http.DefaultTransport
+ TLSHandshakeTimeout: 10 * time.Second,
+ TLSClientConfig: cfg,
+ }
+
+ dialer := (&net.Dialer{
+ Timeout: dialtimeoutd,
+ KeepAlive: 30 * time.Second,
+ })
+ dial := func(net, addr string) (net.Conn, error) {
+ return dialer.Dial("unix", addr)
+ }
+
+ tu := &http.Transport{
+ Proxy: http.ProxyFromEnvironment,
+ Dial: dial,
+ TLSHandshakeTimeout: 10 * time.Second,
+ TLSClientConfig: cfg,
+ }
+ ut := &unixTransport{tu}
+
+ t.RegisterProtocol("unix", ut)
+ t.RegisterProtocol("unixs", ut)
+
+ return t, nil
+}
+
+func (urt *unixTransport) RoundTrip(req *http.Request) (*http.Response, error) {
+ url := *req.URL
+ req.URL = &url
+ req.URL.Scheme = strings.Replace(req.URL.Scheme, "unix", "http", 1)
+ return urt.Transport.RoundTrip(req)
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/transport/unix_listener.go b/vendor/github.com/coreos/etcd/pkg/transport/unix_listener.go
new file mode 100644
index 00000000..123e2036
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/transport/unix_listener.go
@@ -0,0 +1,40 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 transport
+
+import (
+ "net"
+ "os"
+)
+
+type unixListener struct{ net.Listener }
+
+func NewUnixListener(addr string) (net.Listener, error) {
+ if err := os.Remove(addr); err != nil && !os.IsNotExist(err) {
+ return nil, err
+ }
+ l, err := net.Listen("unix", addr)
+ if err != nil {
+ return nil, err
+ }
+ return &unixListener{l}, nil
+}
+
+func (ul *unixListener) Close() error {
+ if err := os.Remove(ul.Addr().String()); err != nil && !os.IsNotExist(err) {
+ return err
+ }
+ return ul.Listener.Close()
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/types/doc.go b/vendor/github.com/coreos/etcd/pkg/types/doc.go
new file mode 100644
index 00000000..de8ef0bd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/types/doc.go
@@ -0,0 +1,17 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 types declares various data types and implements type-checking
+// functions.
+package types
diff --git a/vendor/github.com/coreos/etcd/pkg/types/id.go b/vendor/github.com/coreos/etcd/pkg/types/id.go
new file mode 100644
index 00000000..1b042d9c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/types/id.go
@@ -0,0 +1,41 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 types
+
+import (
+ "strconv"
+)
+
+// ID represents a generic identifier which is canonically
+// stored as a uint64 but is typically represented as a
+// base-16 string for input/output
+type ID uint64
+
+func (i ID) String() string {
+ return strconv.FormatUint(uint64(i), 16)
+}
+
+// IDFromString attempts to create an ID from a base-16 string.
+func IDFromString(s string) (ID, error) {
+ i, err := strconv.ParseUint(s, 16, 64)
+ return ID(i), err
+}
+
+// IDSlice implements the sort interface
+type IDSlice []ID
+
+func (p IDSlice) Len() int { return len(p) }
+func (p IDSlice) Less(i, j int) bool { return uint64(p[i]) < uint64(p[j]) }
+func (p IDSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
diff --git a/vendor/github.com/coreos/etcd/pkg/types/id_test.go b/vendor/github.com/coreos/etcd/pkg/types/id_test.go
new file mode 100644
index 00000000..bec28534
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/types/id_test.go
@@ -0,0 +1,95 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 types
+
+import (
+ "reflect"
+ "sort"
+ "testing"
+)
+
+func TestIDString(t *testing.T) {
+ tests := []struct {
+ input ID
+ want string
+ }{
+ {
+ input: 12,
+ want: "c",
+ },
+ {
+ input: 4918257920282737594,
+ want: "444129853c343bba",
+ },
+ }
+
+ for i, tt := range tests {
+ got := tt.input.String()
+ if tt.want != got {
+ t.Errorf("#%d: ID.String failure: want=%v, got=%v", i, tt.want, got)
+ }
+ }
+}
+
+func TestIDFromString(t *testing.T) {
+ tests := []struct {
+ input string
+ want ID
+ }{
+ {
+ input: "17",
+ want: 23,
+ },
+ {
+ input: "612840dae127353",
+ want: 437557308098245459,
+ },
+ }
+
+ for i, tt := range tests {
+ got, err := IDFromString(tt.input)
+ if err != nil {
+ t.Errorf("#%d: IDFromString failure: err=%v", i, err)
+ continue
+ }
+ if tt.want != got {
+ t.Errorf("#%d: IDFromString failure: want=%v, got=%v", i, tt.want, got)
+ }
+ }
+}
+
+func TestIDFromStringFail(t *testing.T) {
+ tests := []string{
+ "",
+ "XXX",
+ "612840dae127353612840dae127353",
+ }
+
+ for i, tt := range tests {
+ _, err := IDFromString(tt)
+ if err == nil {
+ t.Fatalf("#%d: IDFromString expected error, but err=nil", i)
+ }
+ }
+}
+
+func TestIDSlice(t *testing.T) {
+ g := []ID{10, 500, 5, 1, 100, 25}
+ w := []ID{1, 5, 10, 25, 100, 500}
+ sort.Sort(IDSlice(g))
+ if !reflect.DeepEqual(g, w) {
+ t.Errorf("slice after sort = %#v, want %#v", g, w)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/types/set.go b/vendor/github.com/coreos/etcd/pkg/types/set.go
new file mode 100644
index 00000000..73ef431b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/types/set.go
@@ -0,0 +1,178 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 types
+
+import (
+ "reflect"
+ "sort"
+ "sync"
+)
+
+type Set interface {
+ Add(string)
+ Remove(string)
+ Contains(string) bool
+ Equals(Set) bool
+ Length() int
+ Values() []string
+ Copy() Set
+ Sub(Set) Set
+}
+
+func NewUnsafeSet(values ...string) *unsafeSet {
+ set := &unsafeSet{make(map[string]struct{})}
+ for _, v := range values {
+ set.Add(v)
+ }
+ return set
+}
+
+func NewThreadsafeSet(values ...string) *tsafeSet {
+ us := NewUnsafeSet(values...)
+ return &tsafeSet{us, sync.RWMutex{}}
+}
+
+type unsafeSet struct {
+ d map[string]struct{}
+}
+
+// Add adds a new value to the set (no-op if the value is already present)
+func (us *unsafeSet) Add(value string) {
+ us.d[value] = struct{}{}
+}
+
+// Remove removes the given value from the set
+func (us *unsafeSet) Remove(value string) {
+ delete(us.d, value)
+}
+
+// Contains returns whether the set contains the given value
+func (us *unsafeSet) Contains(value string) (exists bool) {
+ _, exists = us.d[value]
+ return
+}
+
+// ContainsAll returns whether the set contains all given values
+func (us *unsafeSet) ContainsAll(values []string) bool {
+ for _, s := range values {
+ if !us.Contains(s) {
+ return false
+ }
+ }
+ return true
+}
+
+// Equals returns whether the contents of two sets are identical
+func (us *unsafeSet) Equals(other Set) bool {
+ v1 := sort.StringSlice(us.Values())
+ v2 := sort.StringSlice(other.Values())
+ v1.Sort()
+ v2.Sort()
+ return reflect.DeepEqual(v1, v2)
+}
+
+// Length returns the number of elements in the set
+func (us *unsafeSet) Length() int {
+ return len(us.d)
+}
+
+// Values returns the values of the Set in an unspecified order.
+func (us *unsafeSet) Values() (values []string) {
+ values = make([]string, 0)
+ for val := range us.d {
+ values = append(values, val)
+ }
+ return
+}
+
+// Copy creates a new Set containing the values of the first
+func (us *unsafeSet) Copy() Set {
+ cp := NewUnsafeSet()
+ for val := range us.d {
+ cp.Add(val)
+ }
+
+ return cp
+}
+
+// Sub removes all elements in other from the set
+func (us *unsafeSet) Sub(other Set) Set {
+ oValues := other.Values()
+ result := us.Copy().(*unsafeSet)
+
+ for _, val := range oValues {
+ if _, ok := result.d[val]; !ok {
+ continue
+ }
+ delete(result.d, val)
+ }
+
+ return result
+}
+
+type tsafeSet struct {
+ us *unsafeSet
+ m sync.RWMutex
+}
+
+func (ts *tsafeSet) Add(value string) {
+ ts.m.Lock()
+ defer ts.m.Unlock()
+ ts.us.Add(value)
+}
+
+func (ts *tsafeSet) Remove(value string) {
+ ts.m.Lock()
+ defer ts.m.Unlock()
+ ts.us.Remove(value)
+}
+
+func (ts *tsafeSet) Contains(value string) (exists bool) {
+ ts.m.RLock()
+ defer ts.m.RUnlock()
+ return ts.us.Contains(value)
+}
+
+func (ts *tsafeSet) Equals(other Set) bool {
+ ts.m.RLock()
+ defer ts.m.RUnlock()
+ return ts.us.Equals(other)
+}
+
+func (ts *tsafeSet) Length() int {
+ ts.m.RLock()
+ defer ts.m.RUnlock()
+ return ts.us.Length()
+}
+
+func (ts *tsafeSet) Values() (values []string) {
+ ts.m.RLock()
+ defer ts.m.RUnlock()
+ return ts.us.Values()
+}
+
+func (ts *tsafeSet) Copy() Set {
+ ts.m.RLock()
+ defer ts.m.RUnlock()
+ usResult := ts.us.Copy().(*unsafeSet)
+ return &tsafeSet{usResult, sync.RWMutex{}}
+}
+
+func (ts *tsafeSet) Sub(other Set) Set {
+ ts.m.RLock()
+ defer ts.m.RUnlock()
+ usResult := ts.us.Sub(other).(*unsafeSet)
+ return &tsafeSet{usResult, sync.RWMutex{}}
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/types/set_test.go b/vendor/github.com/coreos/etcd/pkg/types/set_test.go
new file mode 100644
index 00000000..7596577e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/types/set_test.go
@@ -0,0 +1,186 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 types
+
+import (
+ "reflect"
+ "sort"
+ "testing"
+)
+
+func TestUnsafeSet(t *testing.T) {
+ driveSetTests(t, NewUnsafeSet())
+}
+
+func TestThreadsafeSet(t *testing.T) {
+ driveSetTests(t, NewThreadsafeSet())
+}
+
+// Check that two slices contents are equal; order is irrelevant
+func equal(a, b []string) bool {
+ as := sort.StringSlice(a)
+ bs := sort.StringSlice(b)
+ as.Sort()
+ bs.Sort()
+ return reflect.DeepEqual(as, bs)
+}
+
+func driveSetTests(t *testing.T, s Set) {
+ // Verify operations on an empty set
+ eValues := []string{}
+ values := s.Values()
+ if !reflect.DeepEqual(values, eValues) {
+ t.Fatalf("Expect values=%v got %v", eValues, values)
+ }
+ if l := s.Length(); l != 0 {
+ t.Fatalf("Expected length=0, got %d", l)
+ }
+ for _, v := range []string{"foo", "bar", "baz"} {
+ if s.Contains(v) {
+ t.Fatalf("Expect s.Contains(%q) to be fale, got true", v)
+ }
+ }
+
+ // Add three items, ensure they show up
+ s.Add("foo")
+ s.Add("bar")
+ s.Add("baz")
+
+ eValues = []string{"foo", "bar", "baz"}
+ values = s.Values()
+ if !equal(values, eValues) {
+ t.Fatalf("Expect values=%v got %v", eValues, values)
+ }
+
+ for _, v := range eValues {
+ if !s.Contains(v) {
+ t.Fatalf("Expect s.Contains(%q) to be true, got false", v)
+ }
+ }
+
+ if l := s.Length(); l != 3 {
+ t.Fatalf("Expected length=3, got %d", l)
+ }
+
+ // Add the same item a second time, ensuring it is not duplicated
+ s.Add("foo")
+
+ values = s.Values()
+ if !equal(values, eValues) {
+ t.Fatalf("Expect values=%v got %v", eValues, values)
+ }
+ if l := s.Length(); l != 3 {
+ t.Fatalf("Expected length=3, got %d", l)
+ }
+
+ // Remove all items, ensure they are gone
+ s.Remove("foo")
+ s.Remove("bar")
+ s.Remove("baz")
+
+ eValues = []string{}
+ values = s.Values()
+ if !equal(values, eValues) {
+ t.Fatalf("Expect values=%v got %v", eValues, values)
+ }
+
+ if l := s.Length(); l != 0 {
+ t.Fatalf("Expected length=0, got %d", l)
+ }
+
+ // Create new copies of the set, and ensure they are unlinked to the
+ // original Set by making modifications
+ s.Add("foo")
+ s.Add("bar")
+ cp1 := s.Copy()
+ cp2 := s.Copy()
+ s.Remove("foo")
+ cp3 := s.Copy()
+ cp1.Add("baz")
+
+ for i, tt := range []struct {
+ want []string
+ got []string
+ }{
+ {[]string{"bar"}, s.Values()},
+ {[]string{"foo", "bar", "baz"}, cp1.Values()},
+ {[]string{"foo", "bar"}, cp2.Values()},
+ {[]string{"bar"}, cp3.Values()},
+ } {
+ if !equal(tt.want, tt.got) {
+ t.Fatalf("case %d: expect values=%v got %v", i, tt.want, tt.got)
+ }
+ }
+
+ for i, tt := range []struct {
+ want bool
+ got bool
+ }{
+ {true, s.Equals(cp3)},
+ {true, cp3.Equals(s)},
+ {false, s.Equals(cp2)},
+ {false, s.Equals(cp1)},
+ {false, cp1.Equals(s)},
+ {false, cp2.Equals(s)},
+ {false, cp2.Equals(cp1)},
+ } {
+ if tt.got != tt.want {
+ t.Fatalf("case %d: want %t, got %t", i, tt.want, tt.got)
+
+ }
+ }
+
+ // Subtract values from a Set, ensuring a new Set is created and
+ // the original Sets are unmodified
+ sub1 := cp1.Sub(s)
+ sub2 := cp2.Sub(cp1)
+
+ for i, tt := range []struct {
+ want []string
+ got []string
+ }{
+ {[]string{"foo", "bar", "baz"}, cp1.Values()},
+ {[]string{"foo", "bar"}, cp2.Values()},
+ {[]string{"bar"}, s.Values()},
+ {[]string{"foo", "baz"}, sub1.Values()},
+ {[]string{}, sub2.Values()},
+ } {
+ if !equal(tt.want, tt.got) {
+ t.Fatalf("case %d: expect values=%v got %v", i, tt.want, tt.got)
+ }
+ }
+}
+
+func TestUnsafeSetContainsAll(t *testing.T) {
+ vals := []string{"foo", "bar", "baz"}
+ s := NewUnsafeSet(vals...)
+
+ tests := []struct {
+ strs []string
+ wcontain bool
+ }{
+ {[]string{}, true},
+ {vals[:1], true},
+ {vals[:2], true},
+ {vals, true},
+ {[]string{"cuz"}, false},
+ {[]string{vals[0], "cuz"}, false},
+ }
+ for i, tt := range tests {
+ if g := s.ContainsAll(tt.strs); g != tt.wcontain {
+ t.Errorf("#%d: ok = %v, want %v", i, g, tt.wcontain)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/types/slice.go b/vendor/github.com/coreos/etcd/pkg/types/slice.go
new file mode 100644
index 00000000..0dd9ca79
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/types/slice.go
@@ -0,0 +1,22 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 types
+
+// Uint64Slice implements sort interface
+type Uint64Slice []uint64
+
+func (p Uint64Slice) Len() int { return len(p) }
+func (p Uint64Slice) Less(i, j int) bool { return p[i] < p[j] }
+func (p Uint64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
diff --git a/vendor/github.com/coreos/etcd/pkg/types/slice_test.go b/vendor/github.com/coreos/etcd/pkg/types/slice_test.go
new file mode 100644
index 00000000..8d8a4d0e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/types/slice_test.go
@@ -0,0 +1,30 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 types
+
+import (
+ "reflect"
+ "sort"
+ "testing"
+)
+
+func TestUint64Slice(t *testing.T) {
+ g := Uint64Slice{10, 500, 5, 1, 100, 25}
+ w := Uint64Slice{1, 5, 10, 25, 100, 500}
+ sort.Sort(g)
+ if !reflect.DeepEqual(g, w) {
+ t.Errorf("slice after sort = %#v, want %#v", g, w)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/types/urls.go b/vendor/github.com/coreos/etcd/pkg/types/urls.go
new file mode 100644
index 00000000..9e5d03ff
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/types/urls.go
@@ -0,0 +1,82 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 types
+
+import (
+ "errors"
+ "fmt"
+ "net"
+ "net/url"
+ "sort"
+ "strings"
+)
+
+type URLs []url.URL
+
+func NewURLs(strs []string) (URLs, error) {
+ all := make([]url.URL, len(strs))
+ if len(all) == 0 {
+ return nil, errors.New("no valid URLs given")
+ }
+ for i, in := range strs {
+ in = strings.TrimSpace(in)
+ u, err := url.Parse(in)
+ if err != nil {
+ return nil, err
+ }
+ if u.Scheme != "http" && u.Scheme != "https" && u.Scheme != "unix" && u.Scheme != "unixs" {
+ return nil, fmt.Errorf("URL scheme must be http, https, unix, or unixs: %s", in)
+ }
+ if _, _, err := net.SplitHostPort(u.Host); err != nil {
+ return nil, fmt.Errorf(`URL address does not have the form "host:port": %s`, in)
+ }
+ if u.Path != "" {
+ return nil, fmt.Errorf("URL must not contain a path: %s", in)
+ }
+ all[i] = *u
+ }
+ us := URLs(all)
+ us.Sort()
+
+ return us, nil
+}
+
+func MustNewURLs(strs []string) URLs {
+ urls, err := NewURLs(strs)
+ if err != nil {
+ panic(err)
+ }
+ return urls
+}
+
+func (us URLs) String() string {
+ return strings.Join(us.StringSlice(), ",")
+}
+
+func (us *URLs) Sort() {
+ sort.Sort(us)
+}
+func (us URLs) Len() int { return len(us) }
+func (us URLs) Less(i, j int) bool { return us[i].String() < us[j].String() }
+func (us URLs) Swap(i, j int) { us[i], us[j] = us[j], us[i] }
+
+func (us URLs) StringSlice() []string {
+ out := make([]string, len(us))
+ for i := range us {
+ out[i] = us[i].String()
+ }
+
+ return out
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/types/urls_test.go b/vendor/github.com/coreos/etcd/pkg/types/urls_test.go
new file mode 100644
index 00000000..b91d1a92
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/types/urls_test.go
@@ -0,0 +1,169 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 types
+
+import (
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestNewURLs(t *testing.T) {
+ tests := []struct {
+ strs []string
+ wurls URLs
+ }{
+ {
+ []string{"http://127.0.0.1:2379"},
+ testutil.MustNewURLs(t, []string{"http://127.0.0.1:2379"}),
+ },
+ // it can trim space
+ {
+ []string{" http://127.0.0.1:2379 "},
+ testutil.MustNewURLs(t, []string{"http://127.0.0.1:2379"}),
+ },
+ // it does sort
+ {
+ []string{
+ "http://127.0.0.2:2379",
+ "http://127.0.0.1:2379",
+ },
+ testutil.MustNewURLs(t, []string{
+ "http://127.0.0.1:2379",
+ "http://127.0.0.2:2379",
+ }),
+ },
+ }
+ for i, tt := range tests {
+ urls, _ := NewURLs(tt.strs)
+ if !reflect.DeepEqual(urls, tt.wurls) {
+ t.Errorf("#%d: urls = %+v, want %+v", i, urls, tt.wurls)
+ }
+ }
+}
+
+func TestURLsString(t *testing.T) {
+ tests := []struct {
+ us URLs
+ wstr string
+ }{
+ {
+ URLs{},
+ "",
+ },
+ {
+ testutil.MustNewURLs(t, []string{"http://127.0.0.1:2379"}),
+ "http://127.0.0.1:2379",
+ },
+ {
+ testutil.MustNewURLs(t, []string{
+ "http://127.0.0.1:2379",
+ "http://127.0.0.2:2379",
+ }),
+ "http://127.0.0.1:2379,http://127.0.0.2:2379",
+ },
+ {
+ testutil.MustNewURLs(t, []string{
+ "http://127.0.0.2:2379",
+ "http://127.0.0.1:2379",
+ }),
+ "http://127.0.0.2:2379,http://127.0.0.1:2379",
+ },
+ }
+ for i, tt := range tests {
+ g := tt.us.String()
+ if g != tt.wstr {
+ t.Errorf("#%d: string = %s, want %s", i, g, tt.wstr)
+ }
+ }
+}
+
+func TestURLsSort(t *testing.T) {
+ g := testutil.MustNewURLs(t, []string{
+ "http://127.0.0.4:2379",
+ "http://127.0.0.2:2379",
+ "http://127.0.0.1:2379",
+ "http://127.0.0.3:2379",
+ })
+ w := testutil.MustNewURLs(t, []string{
+ "http://127.0.0.1:2379",
+ "http://127.0.0.2:2379",
+ "http://127.0.0.3:2379",
+ "http://127.0.0.4:2379",
+ })
+ gurls := URLs(g)
+ gurls.Sort()
+ if !reflect.DeepEqual(g, w) {
+ t.Errorf("URLs after sort = %#v, want %#v", g, w)
+ }
+}
+
+func TestURLsStringSlice(t *testing.T) {
+ tests := []struct {
+ us URLs
+ wstr []string
+ }{
+ {
+ URLs{},
+ []string{},
+ },
+ {
+ testutil.MustNewURLs(t, []string{"http://127.0.0.1:2379"}),
+ []string{"http://127.0.0.1:2379"},
+ },
+ {
+ testutil.MustNewURLs(t, []string{
+ "http://127.0.0.1:2379",
+ "http://127.0.0.2:2379",
+ }),
+ []string{"http://127.0.0.1:2379", "http://127.0.0.2:2379"},
+ },
+ {
+ testutil.MustNewURLs(t, []string{
+ "http://127.0.0.2:2379",
+ "http://127.0.0.1:2379",
+ }),
+ []string{"http://127.0.0.2:2379", "http://127.0.0.1:2379"},
+ },
+ }
+ for i, tt := range tests {
+ g := tt.us.StringSlice()
+ if !reflect.DeepEqual(g, tt.wstr) {
+ t.Errorf("#%d: string slice = %+v, want %+v", i, g, tt.wstr)
+ }
+ }
+}
+
+func TestNewURLsFail(t *testing.T) {
+ tests := [][]string{
+ // no urls given
+ {},
+ // missing protocol scheme
+ {"://127.0.0.1:2379"},
+ // unsupported scheme
+ {"mailto://127.0.0.1:2379"},
+ // not conform to host:port
+ {"http://127.0.0.1"},
+ // contain a path
+ {"http://127.0.0.1:2379/path"},
+ }
+ for i, tt := range tests {
+ _, err := NewURLs(tt)
+ if err == nil {
+ t.Errorf("#%d: err = nil, but error", i)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/types/urlsmap.go b/vendor/github.com/coreos/etcd/pkg/types/urlsmap.go
new file mode 100644
index 00000000..47690cc3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/types/urlsmap.go
@@ -0,0 +1,107 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 types
+
+import (
+ "fmt"
+ "sort"
+ "strings"
+)
+
+// URLsMap is a map from a name to its URLs.
+type URLsMap map[string]URLs
+
+// NewURLsMap returns a URLsMap instantiated from the given string,
+// which consists of discovery-formatted names-to-URLs, like:
+// mach0=http://1.1.1.1:2380,mach0=http://2.2.2.2::2380,mach1=http://3.3.3.3:2380,mach2=http://4.4.4.4:2380
+func NewURLsMap(s string) (URLsMap, error) {
+ m := parse(s)
+
+ cl := URLsMap{}
+ for name, urls := range m {
+ us, err := NewURLs(urls)
+ if err != nil {
+ return nil, err
+ }
+ cl[name] = us
+ }
+ return cl, nil
+}
+
+// NewURLsMapFromStringMap takes a map of strings and returns a URLsMap. The
+// string values in the map can be multiple values separated by the sep string.
+func NewURLsMapFromStringMap(m map[string]string, sep string) (URLsMap, error) {
+ var err error
+ um := URLsMap{}
+ for k, v := range m {
+ um[k], err = NewURLs(strings.Split(v, sep))
+ if err != nil {
+ return nil, err
+ }
+ }
+ return um, nil
+}
+
+// String turns URLsMap into discovery-formatted name-to-URLs sorted by name.
+func (c URLsMap) String() string {
+ var pairs []string
+ for name, urls := range c {
+ for _, url := range urls {
+ pairs = append(pairs, fmt.Sprintf("%s=%s", name, url.String()))
+ }
+ }
+ sort.Strings(pairs)
+ return strings.Join(pairs, ",")
+}
+
+// URLs returns a list of all URLs.
+// The returned list is sorted in ascending lexicographical order.
+func (c URLsMap) URLs() []string {
+ var urls []string
+ for _, us := range c {
+ for _, u := range us {
+ urls = append(urls, u.String())
+ }
+ }
+ sort.Strings(urls)
+ return urls
+}
+
+// Len returns the size of URLsMap.
+func (c URLsMap) Len() int {
+ return len(c)
+}
+
+// parse parses the given string and returns a map listing the values specified for each key.
+func parse(s string) map[string][]string {
+ m := make(map[string][]string)
+ for s != "" {
+ key := s
+ if i := strings.IndexAny(key, ","); i >= 0 {
+ key, s = key[:i], key[i+1:]
+ } else {
+ s = ""
+ }
+ if key == "" {
+ continue
+ }
+ value := ""
+ if i := strings.Index(key, "="); i >= 0 {
+ key, value = key[:i], key[i+1:]
+ }
+ m[key] = append(m[key], value)
+ }
+ return m
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/types/urlsmap_test.go b/vendor/github.com/coreos/etcd/pkg/types/urlsmap_test.go
new file mode 100644
index 00000000..6f58765c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/types/urlsmap_test.go
@@ -0,0 +1,155 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 types
+
+import (
+ "github.com/coreos/etcd/pkg/testutil"
+ "reflect"
+ "testing"
+)
+
+func TestParseInitialCluster(t *testing.T) {
+ c, err := NewURLsMap("mem1=http://10.0.0.1:2379,mem1=http://128.193.4.20:2379,mem2=http://10.0.0.2:2379,default=http://127.0.0.1:2379")
+ if err != nil {
+ t.Fatalf("unexpected parse error: %v", err)
+ }
+ wc := URLsMap(map[string]URLs{
+ "mem1": testutil.MustNewURLs(t, []string{"http://10.0.0.1:2379", "http://128.193.4.20:2379"}),
+ "mem2": testutil.MustNewURLs(t, []string{"http://10.0.0.2:2379"}),
+ "default": testutil.MustNewURLs(t, []string{"http://127.0.0.1:2379"}),
+ })
+ if !reflect.DeepEqual(c, wc) {
+ t.Errorf("cluster = %+v, want %+v", c, wc)
+ }
+}
+
+func TestParseInitialClusterBad(t *testing.T) {
+ tests := []string{
+ // invalid URL
+ "%^",
+ // no URL defined for member
+ "mem1=,mem2=http://128.193.4.20:2379,mem3=http://10.0.0.2:2379",
+ "mem1,mem2=http://128.193.4.20:2379,mem3=http://10.0.0.2:2379",
+ // bad URL for member
+ "default=http://localhost/",
+ }
+ for i, tt := range tests {
+ if _, err := NewURLsMap(tt); err == nil {
+ t.Errorf("#%d: unexpected successful parse, want err", i)
+ }
+ }
+}
+
+func TestNameURLPairsString(t *testing.T) {
+ cls := URLsMap(map[string]URLs{
+ "abc": testutil.MustNewURLs(t, []string{"http://1.1.1.1:1111", "http://0.0.0.0:0000"}),
+ "def": testutil.MustNewURLs(t, []string{"http://2.2.2.2:2222"}),
+ "ghi": testutil.MustNewURLs(t, []string{"http://3.3.3.3:1234", "http://127.0.0.1:2380"}),
+ // no PeerURLs = not included
+ "four": testutil.MustNewURLs(t, []string{}),
+ "five": testutil.MustNewURLs(t, nil),
+ })
+ w := "abc=http://0.0.0.0:0000,abc=http://1.1.1.1:1111,def=http://2.2.2.2:2222,ghi=http://127.0.0.1:2380,ghi=http://3.3.3.3:1234"
+ if g := cls.String(); g != w {
+ t.Fatalf("NameURLPairs.String():\ngot %#v\nwant %#v", g, w)
+ }
+}
+
+func TestParse(t *testing.T) {
+ tests := []struct {
+ s string
+ wm map[string][]string
+ }{
+ {
+ "",
+ map[string][]string{},
+ },
+ {
+ "a=b",
+ map[string][]string{"a": {"b"}},
+ },
+ {
+ "a=b,a=c",
+ map[string][]string{"a": {"b", "c"}},
+ },
+ {
+ "a=b,a1=c",
+ map[string][]string{"a": {"b"}, "a1": {"c"}},
+ },
+ }
+ for i, tt := range tests {
+ m := parse(tt.s)
+ if !reflect.DeepEqual(m, tt.wm) {
+ t.Errorf("#%d: m = %+v, want %+v", i, m, tt.wm)
+ }
+ }
+}
+
+// TestNewURLsMapIPV6 is only tested in Go1.5+ because Go1.4 doesn't support literal IPv6 address with zone in
+// URI (https://github.com/golang/go/issues/6530).
+func TestNewURLsMapIPV6(t *testing.T) {
+ c, err := NewURLsMap("mem1=http://[2001:db8::1]:2380,mem1=http://[fe80::6e40:8ff:feb1:58e4%25en0]:2380,mem2=http://[fe80::92e2:baff:fe7c:3224%25ext0]:2380")
+ if err != nil {
+ t.Fatalf("unexpected parse error: %v", err)
+ }
+ wc := URLsMap(map[string]URLs{
+ "mem1": testutil.MustNewURLs(t, []string{"http://[2001:db8::1]:2380", "http://[fe80::6e40:8ff:feb1:58e4%25en0]:2380"}),
+ "mem2": testutil.MustNewURLs(t, []string{"http://[fe80::92e2:baff:fe7c:3224%25ext0]:2380"}),
+ })
+ if !reflect.DeepEqual(c, wc) {
+ t.Errorf("cluster = %#v, want %#v", c, wc)
+ }
+}
+
+func TestNewURLsMapFromStringMapEmpty(t *testing.T) {
+ mss := make(map[string]string)
+ urlsMap, err := NewURLsMapFromStringMap(mss, ",")
+ if err != nil {
+ t.Errorf("Unexpected error: %v", err)
+ }
+ s := ""
+ um, err := NewURLsMap(s)
+ if err != nil {
+ t.Errorf("Unexpected error: %v", err)
+ }
+
+ if um.String() != urlsMap.String() {
+ t.Errorf("Expected:\n%+v\ngot:\n%+v", um, urlsMap)
+ }
+}
+
+func TestNewURLsMapFromStringMapNormal(t *testing.T) {
+ mss := make(map[string]string)
+ mss["host0"] = "http://127.0.0.1:2379,http://127.0.0.1:2380"
+ mss["host1"] = "http://127.0.0.1:2381,http://127.0.0.1:2382"
+ mss["host2"] = "http://127.0.0.1:2383,http://127.0.0.1:2384"
+ mss["host3"] = "http://127.0.0.1:2385,http://127.0.0.1:2386"
+ urlsMap, err := NewURLsMapFromStringMap(mss, ",")
+ if err != nil {
+ t.Errorf("Unexpected error: %v", err)
+ }
+ s := "host0=http://127.0.0.1:2379,host0=http://127.0.0.1:2380," +
+ "host1=http://127.0.0.1:2381,host1=http://127.0.0.1:2382," +
+ "host2=http://127.0.0.1:2383,host2=http://127.0.0.1:2384," +
+ "host3=http://127.0.0.1:2385,host3=http://127.0.0.1:2386"
+ um, err := NewURLsMap(s)
+ if err != nil {
+ t.Errorf("Unexpected error: %v", err)
+ }
+
+ if um.String() != urlsMap.String() {
+ t.Errorf("Expected:\n%+v\ngot:\n%+v", um, urlsMap)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/wait/wait.go b/vendor/github.com/coreos/etcd/pkg/wait/wait.go
new file mode 100644
index 00000000..34fa237e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/wait/wait.go
@@ -0,0 +1,91 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wait provides utility functions for polling, listening using Go
+// channel.
+package wait
+
+import (
+ "log"
+ "sync"
+)
+
+// Wait is an interface that provides the ability to wait and trigger events that
+// are associated with IDs.
+type Wait interface {
+ // Register waits returns a chan that waits on the given ID.
+ // The chan will be triggered when Trigger is called with
+ // the same ID.
+ Register(id uint64) <-chan interface{}
+ // Trigger triggers the waiting chans with the given ID.
+ Trigger(id uint64, x interface{})
+ IsRegistered(id uint64) bool
+}
+
+type list struct {
+ l sync.Mutex
+ m map[uint64]chan interface{}
+}
+
+// New creates a Wait.
+func New() Wait {
+ return &list{m: make(map[uint64]chan interface{})}
+}
+
+func (w *list) Register(id uint64) <-chan interface{} {
+ w.l.Lock()
+ defer w.l.Unlock()
+ ch := w.m[id]
+ if ch == nil {
+ ch = make(chan interface{}, 1)
+ w.m[id] = ch
+ } else {
+ log.Panicf("dup id %x", id)
+ }
+ return ch
+}
+
+func (w *list) Trigger(id uint64, x interface{}) {
+ w.l.Lock()
+ ch := w.m[id]
+ delete(w.m, id)
+ w.l.Unlock()
+ if ch != nil {
+ ch <- x
+ close(ch)
+ }
+}
+
+func (w *list) IsRegistered(id uint64) bool {
+ w.l.Lock()
+ defer w.l.Unlock()
+ _, ok := w.m[id]
+ return ok
+}
+
+type waitWithResponse struct {
+ ch <-chan interface{}
+}
+
+func NewWithResponse(ch <-chan interface{}) Wait {
+ return &waitWithResponse{ch: ch}
+}
+
+func (w *waitWithResponse) Register(id uint64) <-chan interface{} {
+ return w.ch
+}
+func (w *waitWithResponse) Trigger(id uint64, x interface{}) {}
+func (w *waitWithResponse) IsRegistered(id uint64) bool {
+ panic("waitWithResponse.IsRegistered() shouldn't be called")
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/wait/wait_test.go b/vendor/github.com/coreos/etcd/pkg/wait/wait_test.go
new file mode 100644
index 00000000..54395cb3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/wait/wait_test.go
@@ -0,0 +1,102 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wait
+
+import (
+ "fmt"
+ "testing"
+ "time"
+)
+
+func TestWait(t *testing.T) {
+ const eid = 1
+ wt := New()
+ ch := wt.Register(eid)
+ wt.Trigger(eid, "foo")
+ v := <-ch
+ if g, w := fmt.Sprintf("%v (%T)", v, v), "foo (string)"; g != w {
+ t.Errorf("<-ch = %v, want %v", g, w)
+ }
+
+ if g := <-ch; g != nil {
+ t.Errorf("unexpected non-nil value: %v (%T)", g, g)
+ }
+}
+
+func TestRegisterDupPanic(t *testing.T) {
+ const eid = 1
+ wt := New()
+ ch1 := wt.Register(eid)
+
+ panicC := make(chan struct{}, 1)
+
+ func() {
+ defer func() {
+ if r := recover(); r != nil {
+ panicC <- struct{}{}
+ }
+ }()
+ wt.Register(eid)
+ }()
+
+ select {
+ case <-panicC:
+ case <-time.After(1 * time.Second):
+ t.Errorf("failed to receive panic")
+ }
+
+ wt.Trigger(eid, "foo")
+ <-ch1
+}
+
+func TestTriggerDupSuppression(t *testing.T) {
+ const eid = 1
+ wt := New()
+ ch := wt.Register(eid)
+ wt.Trigger(eid, "foo")
+ wt.Trigger(eid, "bar")
+
+ v := <-ch
+ if g, w := fmt.Sprintf("%v (%T)", v, v), "foo (string)"; g != w {
+ t.Errorf("<-ch = %v, want %v", g, w)
+ }
+
+ if g := <-ch; g != nil {
+ t.Errorf("unexpected non-nil value: %v (%T)", g, g)
+ }
+}
+
+func TestIsRegistered(t *testing.T) {
+ wt := New()
+
+ wt.Register(0)
+ wt.Register(1)
+ wt.Register(2)
+
+ for i := uint64(0); i < 3; i++ {
+ if !wt.IsRegistered(i) {
+ t.Errorf("event ID %d isn't registered", i)
+ }
+ }
+
+ if wt.IsRegistered(4) {
+ t.Errorf("event ID 4 shouldn't be registered")
+ }
+
+ wt.Trigger(0, "foo")
+ if wt.IsRegistered(0) {
+ t.Errorf("event ID 0 is already triggered, shouldn't be registered")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/wait/wait_time.go b/vendor/github.com/coreos/etcd/pkg/wait/wait_time.go
new file mode 100644
index 00000000..297e48a4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/wait/wait_time.go
@@ -0,0 +1,66 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wait
+
+import "sync"
+
+type WaitTime interface {
+ // Wait returns a chan that waits on the given logical deadline.
+ // The chan will be triggered when Trigger is called with a
+ // deadline that is later than the one it is waiting for.
+ Wait(deadline uint64) <-chan struct{}
+ // Trigger triggers all the waiting chans with an earlier logical deadline.
+ Trigger(deadline uint64)
+}
+
+var closec chan struct{}
+
+func init() { closec = make(chan struct{}); close(closec) }
+
+type timeList struct {
+ l sync.Mutex
+ lastTriggerDeadline uint64
+ m map[uint64]chan struct{}
+}
+
+func NewTimeList() *timeList {
+ return &timeList{m: make(map[uint64]chan struct{})}
+}
+
+func (tl *timeList) Wait(deadline uint64) <-chan struct{} {
+ tl.l.Lock()
+ defer tl.l.Unlock()
+ if tl.lastTriggerDeadline >= deadline {
+ return closec
+ }
+ ch := tl.m[deadline]
+ if ch == nil {
+ ch = make(chan struct{})
+ tl.m[deadline] = ch
+ }
+ return ch
+}
+
+func (tl *timeList) Trigger(deadline uint64) {
+ tl.l.Lock()
+ defer tl.l.Unlock()
+ tl.lastTriggerDeadline = deadline
+ for t, ch := range tl.m {
+ if t <= deadline {
+ delete(tl.m, t)
+ close(ch)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/pkg/wait/wait_time_test.go b/vendor/github.com/coreos/etcd/pkg/wait/wait_time_test.go
new file mode 100644
index 00000000..26164c4a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/pkg/wait/wait_time_test.go
@@ -0,0 +1,86 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wait
+
+import (
+ "testing"
+ "time"
+)
+
+func TestWaitTime(t *testing.T) {
+ wt := NewTimeList()
+ ch1 := wt.Wait(1)
+ wt.Trigger(2)
+ select {
+ case <-ch1:
+ default:
+ t.Fatalf("cannot receive from ch as expected")
+ }
+
+ ch2 := wt.Wait(4)
+ wt.Trigger(3)
+ select {
+ case <-ch2:
+ t.Fatalf("unexpected to receive from ch2")
+ default:
+ }
+ wt.Trigger(4)
+ select {
+ case <-ch2:
+ default:
+ t.Fatalf("cannot receive from ch2 as expected")
+ }
+
+ select {
+ // wait on a triggered deadline
+ case <-wt.Wait(4):
+ default:
+ t.Fatalf("unexpected blocking when wait on triggered deadline")
+ }
+}
+
+func TestWaitTestStress(t *testing.T) {
+ chs := make([]<-chan struct{}, 0)
+ wt := NewTimeList()
+ for i := 0; i < 10000; i++ {
+ chs = append(chs, wt.Wait(uint64(i)))
+ }
+ wt.Trigger(10000 + 1)
+
+ for _, ch := range chs {
+ select {
+ case <-ch:
+ case <-time.After(time.Second):
+ t.Fatalf("cannot receive from ch as expected")
+ }
+ }
+}
+
+func BenchmarkWaitTime(b *testing.B) {
+ wt := NewTimeList()
+ for i := 0; i < b.N; i++ {
+ wt.Wait(1)
+ }
+}
+
+func BenchmarkTriggerAnd10KWaitTime(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ wt := NewTimeList()
+ for j := 0; j < 10000; j++ {
+ wt.Wait(uint64(j))
+ }
+ wt.Trigger(10000 + 1)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/chan_stream.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/chan_stream.go
new file mode 100644
index 00000000..3aa01f20
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/chan_stream.go
@@ -0,0 +1,165 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 adapter
+
+import (
+ "golang.org/x/net/context"
+
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/metadata"
+)
+
+// chanServerStream implements grpc.ServerStream with a chanStream
+type chanServerStream struct {
+ headerc chan<- metadata.MD
+ trailerc chan<- metadata.MD
+ grpc.Stream
+
+ headers []metadata.MD
+}
+
+func (ss *chanServerStream) SendHeader(md metadata.MD) error {
+ if ss.headerc == nil {
+ return errAlreadySentHeader
+ }
+ outmd := make(map[string][]string)
+ for _, h := range append(ss.headers, md) {
+ for k, v := range h {
+ outmd[k] = v
+ }
+ }
+ select {
+ case ss.headerc <- outmd:
+ ss.headerc = nil
+ ss.headers = nil
+ return nil
+ case <-ss.Context().Done():
+ }
+ return ss.Context().Err()
+}
+
+func (ss *chanServerStream) SetHeader(md metadata.MD) error {
+ if ss.headerc == nil {
+ return errAlreadySentHeader
+ }
+ ss.headers = append(ss.headers, md)
+ return nil
+}
+
+func (ss *chanServerStream) SetTrailer(md metadata.MD) {
+ ss.trailerc <- md
+}
+
+// chanClientStream implements grpc.ClientStream with a chanStream
+type chanClientStream struct {
+ headerc <-chan metadata.MD
+ trailerc <-chan metadata.MD
+ *chanStream
+}
+
+func (cs *chanClientStream) Header() (metadata.MD, error) {
+ select {
+ case md := <-cs.headerc:
+ return md, nil
+ case <-cs.Context().Done():
+ }
+ return nil, cs.Context().Err()
+}
+
+func (cs *chanClientStream) Trailer() metadata.MD {
+ select {
+ case md := <-cs.trailerc:
+ return md
+ case <-cs.Context().Done():
+ return nil
+ }
+}
+
+func (cs *chanClientStream) CloseSend() error {
+ close(cs.chanStream.sendc)
+ return nil
+}
+
+// chanStream implements grpc.Stream using channels
+type chanStream struct {
+ recvc <-chan interface{}
+ sendc chan<- interface{}
+ ctx context.Context
+ cancel context.CancelFunc
+}
+
+func (s *chanStream) Context() context.Context { return s.ctx }
+
+func (s *chanStream) SendMsg(m interface{}) error {
+ select {
+ case s.sendc <- m:
+ if err, ok := m.(error); ok {
+ return err
+ }
+ return nil
+ case <-s.ctx.Done():
+ }
+ return s.ctx.Err()
+}
+
+func (s *chanStream) RecvMsg(m interface{}) error {
+ v := m.(*interface{})
+ for {
+ select {
+ case msg, ok := <-s.recvc:
+ if !ok {
+ return grpc.ErrClientConnClosing
+ }
+ if err, ok := msg.(error); ok {
+ return err
+ }
+ *v = msg
+ return nil
+ case <-s.ctx.Done():
+ }
+ if len(s.recvc) == 0 {
+ // prioritize any pending recv messages over canceled context
+ break
+ }
+ }
+ return s.ctx.Err()
+}
+
+func newPipeStream(ctx context.Context, ssHandler func(chanServerStream) error) chanClientStream {
+ // ch1 is buffered so server can send error on close
+ ch1, ch2 := make(chan interface{}, 1), make(chan interface{})
+ headerc, trailerc := make(chan metadata.MD, 1), make(chan metadata.MD, 1)
+
+ cctx, ccancel := context.WithCancel(ctx)
+ cli := &chanStream{recvc: ch1, sendc: ch2, ctx: cctx, cancel: ccancel}
+ cs := chanClientStream{headerc, trailerc, cli}
+
+ sctx, scancel := context.WithCancel(ctx)
+ srv := &chanStream{recvc: ch2, sendc: ch1, ctx: sctx, cancel: scancel}
+ ss := chanServerStream{headerc, trailerc, srv, nil}
+
+ go func() {
+ if err := ssHandler(ss); err != nil {
+ select {
+ case srv.sendc <- err:
+ case <-sctx.Done():
+ case <-cctx.Done():
+ }
+ }
+ scancel()
+ ccancel()
+ }()
+ return cs
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/cluster_client_adapter.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/cluster_client_adapter.go
new file mode 100644
index 00000000..4ddf78e1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/cluster_client_adapter.go
@@ -0,0 +1,44 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 adapter
+
+import (
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+type cls2clc struct{ cls pb.ClusterServer }
+
+func ClusterServerToClusterClient(cls pb.ClusterServer) pb.ClusterClient {
+ return &cls2clc{cls}
+}
+
+func (s *cls2clc) MemberList(ctx context.Context, r *pb.MemberListRequest, opts ...grpc.CallOption) (*pb.MemberListResponse, error) {
+ return s.cls.MemberList(ctx, r)
+}
+
+func (s *cls2clc) MemberAdd(ctx context.Context, r *pb.MemberAddRequest, opts ...grpc.CallOption) (*pb.MemberAddResponse, error) {
+ return s.cls.MemberAdd(ctx, r)
+}
+
+func (s *cls2clc) MemberUpdate(ctx context.Context, r *pb.MemberUpdateRequest, opts ...grpc.CallOption) (*pb.MemberUpdateResponse, error) {
+ return s.cls.MemberUpdate(ctx, r)
+}
+
+func (s *cls2clc) MemberRemove(ctx context.Context, r *pb.MemberRemoveRequest, opts ...grpc.CallOption) (*pb.MemberRemoveResponse, error) {
+ return s.cls.MemberRemove(ctx, r)
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/doc.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/doc.go
new file mode 100644
index 00000000..7170be23
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/doc.go
@@ -0,0 +1,17 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 adapter provides gRPC adapters between client and server
+// gRPC interfaces without needing to go through a gRPC connection.
+package adapter
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/election_client_adapter.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/election_client_adapter.go
new file mode 100644
index 00000000..383c1b9d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/election_client_adapter.go
@@ -0,0 +1,79 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 adapter
+
+import (
+ "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+type es2ec struct{ es v3electionpb.ElectionServer }
+
+func ElectionServerToElectionClient(es v3electionpb.ElectionServer) v3electionpb.ElectionClient {
+ return &es2ec{es}
+}
+
+func (s *es2ec) Campaign(ctx context.Context, r *v3electionpb.CampaignRequest, opts ...grpc.CallOption) (*v3electionpb.CampaignResponse, error) {
+ return s.es.Campaign(ctx, r)
+}
+
+func (s *es2ec) Proclaim(ctx context.Context, r *v3electionpb.ProclaimRequest, opts ...grpc.CallOption) (*v3electionpb.ProclaimResponse, error) {
+ return s.es.Proclaim(ctx, r)
+}
+
+func (s *es2ec) Leader(ctx context.Context, r *v3electionpb.LeaderRequest, opts ...grpc.CallOption) (*v3electionpb.LeaderResponse, error) {
+ return s.es.Leader(ctx, r)
+}
+
+func (s *es2ec) Resign(ctx context.Context, r *v3electionpb.ResignRequest, opts ...grpc.CallOption) (*v3electionpb.ResignResponse, error) {
+ return s.es.Resign(ctx, r)
+}
+
+func (s *es2ec) Observe(ctx context.Context, in *v3electionpb.LeaderRequest, opts ...grpc.CallOption) (v3electionpb.Election_ObserveClient, error) {
+ cs := newPipeStream(ctx, func(ss chanServerStream) error {
+ return s.es.Observe(in, &es2ecServerStream{ss})
+ })
+ return &es2ecClientStream{cs}, nil
+}
+
+// es2ecClientStream implements Election_ObserveClient
+type es2ecClientStream struct{ chanClientStream }
+
+// es2ecServerStream implements Election_ObserveServer
+type es2ecServerStream struct{ chanServerStream }
+
+func (s *es2ecClientStream) Send(rr *v3electionpb.LeaderRequest) error {
+ return s.SendMsg(rr)
+}
+func (s *es2ecClientStream) Recv() (*v3electionpb.LeaderResponse, error) {
+ var v interface{}
+ if err := s.RecvMsg(&v); err != nil {
+ return nil, err
+ }
+ return v.(*v3electionpb.LeaderResponse), nil
+}
+
+func (s *es2ecServerStream) Send(rr *v3electionpb.LeaderResponse) error {
+ return s.SendMsg(rr)
+}
+func (s *es2ecServerStream) Recv() (*v3electionpb.LeaderRequest, error) {
+ var v interface{}
+ if err := s.RecvMsg(&v); err != nil {
+ return nil, err
+ }
+ return v.(*v3electionpb.LeaderRequest), nil
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/kv_client_adapter.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/kv_client_adapter.go
new file mode 100644
index 00000000..fec401d9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/kv_client_adapter.go
@@ -0,0 +1,47 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 adapter
+
+import (
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "golang.org/x/net/context"
+ grpc "google.golang.org/grpc"
+)
+
+type kvs2kvc struct{ kvs pb.KVServer }
+
+func KvServerToKvClient(kvs pb.KVServer) pb.KVClient {
+ return &kvs2kvc{kvs}
+}
+
+func (s *kvs2kvc) Range(ctx context.Context, in *pb.RangeRequest, opts ...grpc.CallOption) (*pb.RangeResponse, error) {
+ return s.kvs.Range(ctx, in)
+}
+
+func (s *kvs2kvc) Put(ctx context.Context, in *pb.PutRequest, opts ...grpc.CallOption) (*pb.PutResponse, error) {
+ return s.kvs.Put(ctx, in)
+}
+
+func (s *kvs2kvc) DeleteRange(ctx context.Context, in *pb.DeleteRangeRequest, opts ...grpc.CallOption) (*pb.DeleteRangeResponse, error) {
+ return s.kvs.DeleteRange(ctx, in)
+}
+
+func (s *kvs2kvc) Txn(ctx context.Context, in *pb.TxnRequest, opts ...grpc.CallOption) (*pb.TxnResponse, error) {
+ return s.kvs.Txn(ctx, in)
+}
+
+func (s *kvs2kvc) Compact(ctx context.Context, in *pb.CompactionRequest, opts ...grpc.CallOption) (*pb.CompactionResponse, error) {
+ return s.kvs.Compact(ctx, in)
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/lease_client_adapter.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/lease_client_adapter.go
new file mode 100644
index 00000000..d471fd91
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/lease_client_adapter.go
@@ -0,0 +1,77 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 adapter
+
+import (
+ "golang.org/x/net/context"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "google.golang.org/grpc"
+)
+
+type ls2lc struct {
+ leaseServer pb.LeaseServer
+}
+
+func LeaseServerToLeaseClient(ls pb.LeaseServer) pb.LeaseClient {
+ return &ls2lc{ls}
+}
+
+func (c *ls2lc) LeaseGrant(ctx context.Context, in *pb.LeaseGrantRequest, opts ...grpc.CallOption) (*pb.LeaseGrantResponse, error) {
+ return c.leaseServer.LeaseGrant(ctx, in)
+}
+
+func (c *ls2lc) LeaseRevoke(ctx context.Context, in *pb.LeaseRevokeRequest, opts ...grpc.CallOption) (*pb.LeaseRevokeResponse, error) {
+ return c.leaseServer.LeaseRevoke(ctx, in)
+}
+
+func (c *ls2lc) LeaseKeepAlive(ctx context.Context, opts ...grpc.CallOption) (pb.Lease_LeaseKeepAliveClient, error) {
+ cs := newPipeStream(ctx, func(ss chanServerStream) error {
+ return c.leaseServer.LeaseKeepAlive(&ls2lcServerStream{ss})
+ })
+ return &ls2lcClientStream{cs}, nil
+}
+
+func (c *ls2lc) LeaseTimeToLive(ctx context.Context, in *pb.LeaseTimeToLiveRequest, opts ...grpc.CallOption) (*pb.LeaseTimeToLiveResponse, error) {
+ return c.leaseServer.LeaseTimeToLive(ctx, in)
+}
+
+// ls2lcClientStream implements Lease_LeaseKeepAliveClient
+type ls2lcClientStream struct{ chanClientStream }
+
+// ls2lcServerStream implements Lease_LeaseKeepAliveServer
+type ls2lcServerStream struct{ chanServerStream }
+
+func (s *ls2lcClientStream) Send(rr *pb.LeaseKeepAliveRequest) error {
+ return s.SendMsg(rr)
+}
+func (s *ls2lcClientStream) Recv() (*pb.LeaseKeepAliveResponse, error) {
+ var v interface{}
+ if err := s.RecvMsg(&v); err != nil {
+ return nil, err
+ }
+ return v.(*pb.LeaseKeepAliveResponse), nil
+}
+
+func (s *ls2lcServerStream) Send(rr *pb.LeaseKeepAliveResponse) error {
+ return s.SendMsg(rr)
+}
+func (s *ls2lcServerStream) Recv() (*pb.LeaseKeepAliveRequest, error) {
+ var v interface{}
+ if err := s.RecvMsg(&v); err != nil {
+ return nil, err
+ }
+ return v.(*pb.LeaseKeepAliveRequest), nil
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/lock_client_adapter.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/lock_client_adapter.go
new file mode 100644
index 00000000..05e5cb02
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/lock_client_adapter.go
@@ -0,0 +1,36 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 adapter
+
+import (
+ "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+type ls2lsc struct{ ls v3lockpb.LockServer }
+
+func LockServerToLockClient(ls v3lockpb.LockServer) v3lockpb.LockClient {
+ return &ls2lsc{ls}
+}
+
+func (s *ls2lsc) Lock(ctx context.Context, r *v3lockpb.LockRequest, opts ...grpc.CallOption) (*v3lockpb.LockResponse, error) {
+ return s.ls.Lock(ctx, r)
+}
+
+func (s *ls2lsc) Unlock(ctx context.Context, r *v3lockpb.UnlockRequest, opts ...grpc.CallOption) (*v3lockpb.UnlockResponse, error) {
+ return s.ls.Unlock(ctx, r)
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/maintenance_client_adapter.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/maintenance_client_adapter.go
new file mode 100644
index 00000000..9b21bf25
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/maintenance_client_adapter.go
@@ -0,0 +1,79 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 adapter
+
+import (
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+type mts2mtc struct{ mts pb.MaintenanceServer }
+
+func MaintenanceServerToMaintenanceClient(mts pb.MaintenanceServer) pb.MaintenanceClient {
+ return &mts2mtc{mts}
+}
+
+func (s *mts2mtc) Alarm(ctx context.Context, r *pb.AlarmRequest, opts ...grpc.CallOption) (*pb.AlarmResponse, error) {
+ return s.mts.Alarm(ctx, r)
+}
+
+func (s *mts2mtc) Status(ctx context.Context, r *pb.StatusRequest, opts ...grpc.CallOption) (*pb.StatusResponse, error) {
+ return s.mts.Status(ctx, r)
+}
+
+func (s *mts2mtc) Defragment(ctx context.Context, dr *pb.DefragmentRequest, opts ...grpc.CallOption) (*pb.DefragmentResponse, error) {
+ return s.mts.Defragment(ctx, dr)
+}
+
+func (s *mts2mtc) Hash(ctx context.Context, r *pb.HashRequest, opts ...grpc.CallOption) (*pb.HashResponse, error) {
+ return s.mts.Hash(ctx, r)
+}
+
+func (s *mts2mtc) Snapshot(ctx context.Context, in *pb.SnapshotRequest, opts ...grpc.CallOption) (pb.Maintenance_SnapshotClient, error) {
+ cs := newPipeStream(ctx, func(ss chanServerStream) error {
+ return s.mts.Snapshot(in, &ss2scServerStream{ss})
+ })
+ return &ss2scClientStream{cs}, nil
+}
+
+// ss2scClientStream implements Maintenance_SnapshotClient
+type ss2scClientStream struct{ chanClientStream }
+
+// ss2scServerStream implements Maintenance_SnapshotServer
+type ss2scServerStream struct{ chanServerStream }
+
+func (s *ss2scClientStream) Send(rr *pb.SnapshotRequest) error {
+ return s.SendMsg(rr)
+}
+func (s *ss2scClientStream) Recv() (*pb.SnapshotResponse, error) {
+ var v interface{}
+ if err := s.RecvMsg(&v); err != nil {
+ return nil, err
+ }
+ return v.(*pb.SnapshotResponse), nil
+}
+
+func (s *ss2scServerStream) Send(rr *pb.SnapshotResponse) error {
+ return s.SendMsg(rr)
+}
+func (s *ss2scServerStream) Recv() (*pb.SnapshotRequest, error) {
+ var v interface{}
+ if err := s.RecvMsg(&v); err != nil {
+ return nil, err
+ }
+ return v.(*pb.SnapshotRequest), nil
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/watch_client_adapter.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/watch_client_adapter.go
new file mode 100644
index 00000000..af4a13c4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/adapter/watch_client_adapter.go
@@ -0,0 +1,66 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 adapter
+
+import (
+ "errors"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+var errAlreadySentHeader = errors.New("adapter: already sent header")
+
+type ws2wc struct{ wserv pb.WatchServer }
+
+func WatchServerToWatchClient(wserv pb.WatchServer) pb.WatchClient {
+ return &ws2wc{wserv}
+}
+
+func (s *ws2wc) Watch(ctx context.Context, opts ...grpc.CallOption) (pb.Watch_WatchClient, error) {
+ cs := newPipeStream(ctx, func(ss chanServerStream) error {
+ return s.wserv.Watch(&ws2wcServerStream{ss})
+ })
+ return &ws2wcClientStream{cs}, nil
+}
+
+// ws2wcClientStream implements Watch_WatchClient
+type ws2wcClientStream struct{ chanClientStream }
+
+// ws2wcServerStream implements Watch_WatchServer
+type ws2wcServerStream struct{ chanServerStream }
+
+func (s *ws2wcClientStream) Send(wr *pb.WatchRequest) error {
+ return s.SendMsg(wr)
+}
+func (s *ws2wcClientStream) Recv() (*pb.WatchResponse, error) {
+ var v interface{}
+ if err := s.RecvMsg(&v); err != nil {
+ return nil, err
+ }
+ return v.(*pb.WatchResponse), nil
+}
+
+func (s *ws2wcServerStream) Send(wr *pb.WatchResponse) error {
+ return s.SendMsg(wr)
+}
+func (s *ws2wcServerStream) Recv() (*pb.WatchRequest, error) {
+ var v interface{}
+ if err := s.RecvMsg(&v); err != nil {
+ return nil, err
+ }
+ return v.(*pb.WatchRequest), nil
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/auth.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/auth.go
new file mode 100644
index 00000000..c1b75e36
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/auth.go
@@ -0,0 +1,110 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+type AuthProxy struct {
+ client *clientv3.Client
+}
+
+func NewAuthProxy(c *clientv3.Client) pb.AuthServer {
+ return &AuthProxy{client: c}
+}
+
+func (ap *AuthProxy) AuthEnable(ctx context.Context, r *pb.AuthEnableRequest) (*pb.AuthEnableResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).AuthEnable(ctx, r)
+}
+
+func (ap *AuthProxy) AuthDisable(ctx context.Context, r *pb.AuthDisableRequest) (*pb.AuthDisableResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).AuthDisable(ctx, r)
+}
+
+func (ap *AuthProxy) Authenticate(ctx context.Context, r *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).Authenticate(ctx, r)
+}
+
+func (ap *AuthProxy) RoleAdd(ctx context.Context, r *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).RoleAdd(ctx, r)
+}
+
+func (ap *AuthProxy) RoleDelete(ctx context.Context, r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).RoleDelete(ctx, r)
+}
+
+func (ap *AuthProxy) RoleGet(ctx context.Context, r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).RoleGet(ctx, r)
+}
+
+func (ap *AuthProxy) RoleList(ctx context.Context, r *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).RoleList(ctx, r)
+}
+
+func (ap *AuthProxy) RoleRevokePermission(ctx context.Context, r *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).RoleRevokePermission(ctx, r)
+}
+
+func (ap *AuthProxy) RoleGrantPermission(ctx context.Context, r *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).RoleGrantPermission(ctx, r)
+}
+
+func (ap *AuthProxy) UserAdd(ctx context.Context, r *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).UserAdd(ctx, r)
+}
+
+func (ap *AuthProxy) UserDelete(ctx context.Context, r *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).UserDelete(ctx, r)
+}
+
+func (ap *AuthProxy) UserGet(ctx context.Context, r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).UserGet(ctx, r)
+}
+
+func (ap *AuthProxy) UserList(ctx context.Context, r *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).UserList(ctx, r)
+}
+
+func (ap *AuthProxy) UserGrantRole(ctx context.Context, r *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).UserGrantRole(ctx, r)
+}
+
+func (ap *AuthProxy) UserRevokeRole(ctx context.Context, r *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).UserRevokeRole(ctx, r)
+}
+
+func (ap *AuthProxy) UserChangePassword(ctx context.Context, r *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error) {
+ conn := ap.client.ActiveConnection()
+ return pb.NewAuthClient(conn).UserChangePassword(ctx, r)
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/cache/store.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/cache/store.go
new file mode 100644
index 00000000..e84a0522
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/cache/store.go
@@ -0,0 +1,168 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 cache exports functionality for efficiently caching and mapping
+// `RangeRequest`s to corresponding `RangeResponse`s.
+package cache
+
+import (
+ "errors"
+ "sync"
+
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/adt"
+ "github.com/golang/groupcache/lru"
+)
+
+var (
+ DefaultMaxEntries = 2048
+ ErrCompacted = rpctypes.ErrGRPCCompacted
+)
+
+type Cache interface {
+ Add(req *pb.RangeRequest, resp *pb.RangeResponse)
+ Get(req *pb.RangeRequest) (*pb.RangeResponse, error)
+ Compact(revision int64)
+ Invalidate(key []byte, endkey []byte)
+ Size() int
+ Close()
+}
+
+// keyFunc returns the key of an request, which is used to look up in the cache for it's caching response.
+func keyFunc(req *pb.RangeRequest) string {
+ // TODO: use marshalTo to reduce allocation
+ b, err := req.Marshal()
+ if err != nil {
+ panic(err)
+ }
+ return string(b)
+}
+
+func NewCache(maxCacheEntries int) Cache {
+ return &cache{
+ lru: lru.New(maxCacheEntries),
+ compactedRev: -1,
+ }
+}
+
+func (c *cache) Close() {}
+
+// cache implements Cache
+type cache struct {
+ mu sync.RWMutex
+ lru *lru.Cache
+
+ // a reverse index for cache invalidation
+ cachedRanges adt.IntervalTree
+
+ compactedRev int64
+}
+
+// Add adds the response of a request to the cache if its revision is larger than the compacted revision of the cache.
+func (c *cache) Add(req *pb.RangeRequest, resp *pb.RangeResponse) {
+ key := keyFunc(req)
+
+ c.mu.Lock()
+ defer c.mu.Unlock()
+
+ if req.Revision > c.compactedRev {
+ c.lru.Add(key, resp)
+ }
+ // we do not need to invalidate a request with a revision specified.
+ // so we do not need to add it into the reverse index.
+ if req.Revision != 0 {
+ return
+ }
+
+ var (
+ iv *adt.IntervalValue
+ ivl adt.Interval
+ )
+ if len(req.RangeEnd) != 0 {
+ ivl = adt.NewStringAffineInterval(string(req.Key), string(req.RangeEnd))
+ } else {
+ ivl = adt.NewStringAffinePoint(string(req.Key))
+ }
+
+ iv = c.cachedRanges.Find(ivl)
+
+ if iv == nil {
+ c.cachedRanges.Insert(ivl, []string{key})
+ } else {
+ iv.Val = append(iv.Val.([]string), key)
+ }
+}
+
+// Get looks up the caching response for a given request.
+// Get is also responsible for lazy eviction when accessing compacted entries.
+func (c *cache) Get(req *pb.RangeRequest) (*pb.RangeResponse, error) {
+ key := keyFunc(req)
+
+ c.mu.Lock()
+ defer c.mu.Unlock()
+
+ if req.Revision > 0 && req.Revision < c.compactedRev {
+ c.lru.Remove(key)
+ return nil, ErrCompacted
+ }
+
+ if resp, ok := c.lru.Get(key); ok {
+ return resp.(*pb.RangeResponse), nil
+ }
+ return nil, errors.New("not exist")
+}
+
+// Invalidate invalidates the cache entries that intersecting with the given range from key to endkey.
+func (c *cache) Invalidate(key, endkey []byte) {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+
+ var (
+ ivs []*adt.IntervalValue
+ ivl adt.Interval
+ )
+ if len(endkey) == 0 {
+ ivl = adt.NewStringAffinePoint(string(key))
+ } else {
+ ivl = adt.NewStringAffineInterval(string(key), string(endkey))
+ }
+
+ ivs = c.cachedRanges.Stab(ivl)
+ for _, iv := range ivs {
+ keys := iv.Val.([]string)
+ for _, key := range keys {
+ c.lru.Remove(key)
+ }
+ }
+ // delete after removing all keys since it is destructive to 'ivs'
+ c.cachedRanges.Delete(ivl)
+}
+
+// Compact invalidate all caching response before the given rev.
+// Replace with the invalidation is lazy. The actual removal happens when the entries is accessed.
+func (c *cache) Compact(revision int64) {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+
+ if revision > c.compactedRev {
+ c.compactedRev = revision
+ }
+}
+
+func (c *cache) Size() int {
+ c.mu.RLock()
+ defer c.mu.RUnlock()
+ return c.lru.Len()
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/cluster.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/cluster.go
new file mode 100644
index 00000000..899fb9be
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/cluster.go
@@ -0,0 +1,177 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "fmt"
+ "os"
+ "sync"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/naming"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+
+ "golang.org/x/net/context"
+ "golang.org/x/time/rate"
+ "google.golang.org/grpc"
+ gnaming "google.golang.org/grpc/naming"
+)
+
+// allow maximum 1 retry per second
+const resolveRetryRate = 1
+
+type clusterProxy struct {
+ clus clientv3.Cluster
+ ctx context.Context
+ gr *naming.GRPCResolver
+
+ // advertise client URL
+ advaddr string
+ prefix string
+
+ umu sync.RWMutex
+ umap map[string]gnaming.Update
+}
+
+// NewClusterProxy takes optional prefix to fetch grpc-proxy member endpoints.
+// The returned channel is closed when there is grpc-proxy endpoint registered
+// and the client's context is canceled so the 'register' loop returns.
+func NewClusterProxy(c *clientv3.Client, advaddr string, prefix string) (pb.ClusterServer, <-chan struct{}) {
+ cp := &clusterProxy{
+ clus: c.Cluster,
+ ctx: c.Ctx(),
+ gr: &naming.GRPCResolver{Client: c},
+
+ advaddr: advaddr,
+ prefix: prefix,
+ umap: make(map[string]gnaming.Update),
+ }
+
+ donec := make(chan struct{})
+ if advaddr != "" && prefix != "" {
+ go func() {
+ defer close(donec)
+ cp.resolve(prefix)
+ }()
+ return cp, donec
+ }
+
+ close(donec)
+ return cp, donec
+}
+
+func (cp *clusterProxy) resolve(prefix string) {
+ rm := rate.NewLimiter(rate.Limit(resolveRetryRate), resolveRetryRate)
+ for rm.Wait(cp.ctx) == nil {
+ wa, err := cp.gr.Resolve(prefix)
+ if err != nil {
+ plog.Warningf("failed to resolve %q (%v)", prefix, err)
+ continue
+ }
+ cp.monitor(wa)
+ }
+}
+
+func (cp *clusterProxy) monitor(wa gnaming.Watcher) {
+ for cp.ctx.Err() == nil {
+ ups, err := wa.Next()
+ if err != nil {
+ plog.Warningf("clusterProxy watcher error (%v)", err)
+ if grpc.ErrorDesc(err) == naming.ErrWatcherClosed.Error() {
+ return
+ }
+ }
+
+ cp.umu.Lock()
+ for i := range ups {
+ switch ups[i].Op {
+ case gnaming.Add:
+ cp.umap[ups[i].Addr] = *ups[i]
+ case gnaming.Delete:
+ delete(cp.umap, ups[i].Addr)
+ }
+ }
+ cp.umu.Unlock()
+ }
+}
+
+func (cp *clusterProxy) MemberAdd(ctx context.Context, r *pb.MemberAddRequest) (*pb.MemberAddResponse, error) {
+ mresp, err := cp.clus.MemberAdd(ctx, r.PeerURLs)
+ if err != nil {
+ return nil, err
+ }
+ resp := (pb.MemberAddResponse)(*mresp)
+ return &resp, err
+}
+
+func (cp *clusterProxy) MemberRemove(ctx context.Context, r *pb.MemberRemoveRequest) (*pb.MemberRemoveResponse, error) {
+ mresp, err := cp.clus.MemberRemove(ctx, r.ID)
+ if err != nil {
+ return nil, err
+ }
+ resp := (pb.MemberRemoveResponse)(*mresp)
+ return &resp, err
+}
+
+func (cp *clusterProxy) MemberUpdate(ctx context.Context, r *pb.MemberUpdateRequest) (*pb.MemberUpdateResponse, error) {
+ mresp, err := cp.clus.MemberUpdate(ctx, r.ID, r.PeerURLs)
+ if err != nil {
+ return nil, err
+ }
+ resp := (pb.MemberUpdateResponse)(*mresp)
+ return &resp, err
+}
+
+func (cp *clusterProxy) membersFromUpdates() ([]*pb.Member, error) {
+ cp.umu.RLock()
+ defer cp.umu.RUnlock()
+ mbs := make([]*pb.Member, 0, len(cp.umap))
+ for addr, upt := range cp.umap {
+ m, err := decodeMeta(fmt.Sprint(upt.Metadata))
+ if err != nil {
+ return nil, err
+ }
+ mbs = append(mbs, &pb.Member{Name: m.Name, ClientURLs: []string{addr}})
+ }
+ return mbs, nil
+}
+
+// MemberList wraps member list API with following rules:
+// - If 'advaddr' is not empty and 'prefix' is not empty, return registered member lists via resolver
+// - If 'advaddr' is not empty and 'prefix' is not empty and registered grpc-proxy members haven't been fetched, return the 'advaddr'
+// - If 'advaddr' is not empty and 'prefix' is empty, return 'advaddr' without forcing it to 'register'
+// - If 'advaddr' is empty, forward to member list API
+func (cp *clusterProxy) MemberList(ctx context.Context, r *pb.MemberListRequest) (*pb.MemberListResponse, error) {
+ if cp.advaddr != "" {
+ if cp.prefix != "" {
+ mbs, err := cp.membersFromUpdates()
+ if err != nil {
+ return nil, err
+ }
+ if len(mbs) > 0 {
+ return &pb.MemberListResponse{Members: mbs}, nil
+ }
+ }
+ // prefix is empty or no grpc-proxy members haven't been registered
+ hostname, _ := os.Hostname()
+ return &pb.MemberListResponse{Members: []*pb.Member{{Name: hostname, ClientURLs: []string{cp.advaddr}}}}, nil
+ }
+ mresp, err := cp.clus.MemberList(ctx)
+ if err != nil {
+ return nil, err
+ }
+ resp := (pb.MemberListResponse)(*mresp)
+ return &resp, err
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/cluster_test.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/cluster_test.go
new file mode 100644
index 00000000..031a9568
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/cluster_test.go
@@ -0,0 +1,121 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "net"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/pkg/testutil"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+func TestClusterProxyMemberList(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cts := newClusterProxyServer([]string{clus.Members[0].GRPCAddr()}, t)
+ defer cts.close(t)
+
+ cfg := clientv3.Config{
+ Endpoints: []string{cts.caddr},
+ DialTimeout: 5 * time.Second,
+ }
+ client, err := clientv3.New(cfg)
+ if err != nil {
+ t.Fatalf("err %v, want nil", err)
+ }
+ defer client.Close()
+
+ // wait some time for register-loop to write keys
+ time.Sleep(time.Second)
+
+ var mresp *clientv3.MemberListResponse
+ mresp, err = client.Cluster.MemberList(context.Background())
+ if err != nil {
+ t.Fatalf("err %v, want nil", err)
+ }
+
+ if len(mresp.Members) != 1 {
+ t.Fatalf("len(mresp.Members) expected 1, got %d (%+v)", len(mresp.Members), mresp.Members)
+ }
+ if len(mresp.Members[0].ClientURLs) != 1 {
+ t.Fatalf("len(mresp.Members[0].ClientURLs) expected 1, got %d (%+v)", len(mresp.Members[0].ClientURLs), mresp.Members[0].ClientURLs[0])
+ }
+ if mresp.Members[0].ClientURLs[0] != cts.caddr {
+ t.Fatalf("mresp.Members[0].ClientURLs[0] expected %q, got %q", cts.caddr, mresp.Members[0].ClientURLs[0])
+ }
+}
+
+type clusterproxyTestServer struct {
+ cp pb.ClusterServer
+ c *clientv3.Client
+ server *grpc.Server
+ l net.Listener
+ donec <-chan struct{}
+ caddr string
+}
+
+func (cts *clusterproxyTestServer) close(t *testing.T) {
+ cts.server.Stop()
+ cts.l.Close()
+ cts.c.Close()
+ select {
+ case <-cts.donec:
+ return
+ case <-time.After(5 * time.Second):
+ t.Fatalf("register-loop took too long to return")
+ }
+}
+
+func newClusterProxyServer(endpoints []string, t *testing.T) *clusterproxyTestServer {
+ cfg := clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: 5 * time.Second,
+ }
+ client, err := clientv3.New(cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ cts := &clusterproxyTestServer{
+ c: client,
+ }
+ cts.l, err = net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatal(err)
+ }
+ var opts []grpc.ServerOption
+ cts.server = grpc.NewServer(opts...)
+ go cts.server.Serve(cts.l)
+
+ // wait some time for free port 0 to be resolved
+ time.Sleep(500 * time.Millisecond)
+
+ Register(client, "test-prefix", cts.l.Addr().String(), 7)
+ cts.cp, cts.donec = NewClusterProxy(client, cts.l.Addr().String(), "test-prefix")
+ cts.caddr = cts.l.Addr().String()
+ pb.RegisterClusterServer(cts.server, cts.cp)
+
+ return cts
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/doc.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/doc.go
new file mode 100644
index 00000000..fc022e3c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 grpcproxy is an OSI level 7 proxy for etcd v3 API requests.
+package grpcproxy
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/election.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/election.go
new file mode 100644
index 00000000..27115a81
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/election.go
@@ -0,0 +1,65 @@
+// Copyright 2017 The etcd Lockors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb"
+)
+
+type electionProxy struct {
+ client *clientv3.Client
+}
+
+func NewElectionProxy(client *clientv3.Client) v3electionpb.ElectionServer {
+ return &electionProxy{client: client}
+}
+
+func (ep *electionProxy) Campaign(ctx context.Context, req *v3electionpb.CampaignRequest) (*v3electionpb.CampaignResponse, error) {
+ return v3electionpb.NewElectionClient(ep.client.ActiveConnection()).Campaign(ctx, req)
+}
+
+func (ep *electionProxy) Proclaim(ctx context.Context, req *v3electionpb.ProclaimRequest) (*v3electionpb.ProclaimResponse, error) {
+ return v3electionpb.NewElectionClient(ep.client.ActiveConnection()).Proclaim(ctx, req)
+}
+
+func (ep *electionProxy) Leader(ctx context.Context, req *v3electionpb.LeaderRequest) (*v3electionpb.LeaderResponse, error) {
+ return v3electionpb.NewElectionClient(ep.client.ActiveConnection()).Leader(ctx, req)
+}
+
+func (ep *electionProxy) Observe(req *v3electionpb.LeaderRequest, s v3electionpb.Election_ObserveServer) error {
+ conn := ep.client.ActiveConnection()
+ ctx, cancel := context.WithCancel(s.Context())
+ defer cancel()
+ sc, err := v3electionpb.NewElectionClient(conn).Observe(ctx, req)
+ if err != nil {
+ return err
+ }
+ for {
+ rr, err := sc.Recv()
+ if err != nil {
+ return err
+ }
+ if err = s.Send(rr); err != nil {
+ return err
+ }
+ }
+}
+
+func (ep *electionProxy) Resign(ctx context.Context, req *v3electionpb.ResignRequest) (*v3electionpb.ResignResponse, error) {
+ return v3electionpb.NewElectionClient(ep.client.ActiveConnection()).Resign(ctx, req)
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/kv.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/kv.go
new file mode 100644
index 00000000..e8ea67cd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/kv.go
@@ -0,0 +1,224 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/proxy/grpcproxy/cache"
+
+ "golang.org/x/net/context"
+)
+
+type kvProxy struct {
+ kv clientv3.KV
+ cache cache.Cache
+}
+
+func NewKvProxy(c *clientv3.Client) (pb.KVServer, <-chan struct{}) {
+ kv := &kvProxy{
+ kv: c.KV,
+ cache: cache.NewCache(cache.DefaultMaxEntries),
+ }
+ donec := make(chan struct{})
+ close(donec)
+ return kv, donec
+}
+
+func (p *kvProxy) Range(ctx context.Context, r *pb.RangeRequest) (*pb.RangeResponse, error) {
+ if r.Serializable {
+ resp, err := p.cache.Get(r)
+ switch err {
+ case nil:
+ cacheHits.Inc()
+ return resp, nil
+ case cache.ErrCompacted:
+ cacheHits.Inc()
+ return nil, err
+ }
+ }
+ cachedMisses.Inc()
+
+ resp, err := p.kv.Do(ctx, RangeRequestToOp(r))
+ if err != nil {
+ return nil, err
+ }
+
+ // cache linearizable as serializable
+ req := *r
+ req.Serializable = true
+ gresp := (*pb.RangeResponse)(resp.Get())
+ p.cache.Add(&req, gresp)
+ cacheKeys.Set(float64(p.cache.Size()))
+
+ return gresp, nil
+}
+
+func (p *kvProxy) Put(ctx context.Context, r *pb.PutRequest) (*pb.PutResponse, error) {
+ p.cache.Invalidate(r.Key, nil)
+ cacheKeys.Set(float64(p.cache.Size()))
+
+ resp, err := p.kv.Do(ctx, PutRequestToOp(r))
+ return (*pb.PutResponse)(resp.Put()), err
+}
+
+func (p *kvProxy) DeleteRange(ctx context.Context, r *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error) {
+ p.cache.Invalidate(r.Key, r.RangeEnd)
+ cacheKeys.Set(float64(p.cache.Size()))
+
+ resp, err := p.kv.Do(ctx, DelRequestToOp(r))
+ return (*pb.DeleteRangeResponse)(resp.Del()), err
+}
+
+func (p *kvProxy) txnToCache(reqs []*pb.RequestOp, resps []*pb.ResponseOp) {
+ for i := range resps {
+ switch tv := resps[i].Response.(type) {
+ case *pb.ResponseOp_ResponsePut:
+ p.cache.Invalidate(reqs[i].GetRequestPut().Key, nil)
+ case *pb.ResponseOp_ResponseDeleteRange:
+ rdr := reqs[i].GetRequestDeleteRange()
+ p.cache.Invalidate(rdr.Key, rdr.RangeEnd)
+ case *pb.ResponseOp_ResponseRange:
+ req := *(reqs[i].GetRequestRange())
+ req.Serializable = true
+ p.cache.Add(&req, tv.ResponseRange)
+ }
+ }
+}
+
+func (p *kvProxy) Txn(ctx context.Context, r *pb.TxnRequest) (*pb.TxnResponse, error) {
+ txn := p.kv.Txn(ctx)
+ cmps := make([]clientv3.Cmp, len(r.Compare))
+ thenops := make([]clientv3.Op, len(r.Success))
+ elseops := make([]clientv3.Op, len(r.Failure))
+
+ for i := range r.Compare {
+ cmps[i] = (clientv3.Cmp)(*r.Compare[i])
+ }
+
+ for i := range r.Success {
+ thenops[i] = requestOpToOp(r.Success[i])
+ }
+
+ for i := range r.Failure {
+ elseops[i] = requestOpToOp(r.Failure[i])
+ }
+
+ resp, err := txn.If(cmps...).Then(thenops...).Else(elseops...).Commit()
+
+ if err != nil {
+ return nil, err
+ }
+ // txn may claim an outdated key is updated; be safe and invalidate
+ for _, cmp := range r.Compare {
+ p.cache.Invalidate(cmp.Key, nil)
+ }
+ // update any fetched keys
+ if resp.Succeeded {
+ p.txnToCache(r.Success, resp.Responses)
+ } else {
+ p.txnToCache(r.Failure, resp.Responses)
+ }
+
+ cacheKeys.Set(float64(p.cache.Size()))
+
+ return (*pb.TxnResponse)(resp), nil
+}
+
+func (p *kvProxy) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) {
+ var opts []clientv3.CompactOption
+ if r.Physical {
+ opts = append(opts, clientv3.WithCompactPhysical())
+ }
+
+ resp, err := p.kv.Compact(ctx, r.Revision, opts...)
+ if err == nil {
+ p.cache.Compact(r.Revision)
+ }
+
+ cacheKeys.Set(float64(p.cache.Size()))
+
+ return (*pb.CompactionResponse)(resp), err
+}
+
+func requestOpToOp(union *pb.RequestOp) clientv3.Op {
+ switch tv := union.Request.(type) {
+ case *pb.RequestOp_RequestRange:
+ if tv.RequestRange != nil {
+ return RangeRequestToOp(tv.RequestRange)
+ }
+ case *pb.RequestOp_RequestPut:
+ if tv.RequestPut != nil {
+ return PutRequestToOp(tv.RequestPut)
+ }
+ case *pb.RequestOp_RequestDeleteRange:
+ if tv.RequestDeleteRange != nil {
+ return DelRequestToOp(tv.RequestDeleteRange)
+ }
+ }
+ panic("unknown request")
+}
+
+func RangeRequestToOp(r *pb.RangeRequest) clientv3.Op {
+ opts := []clientv3.OpOption{}
+ if len(r.RangeEnd) != 0 {
+ opts = append(opts, clientv3.WithRange(string(r.RangeEnd)))
+ }
+ opts = append(opts, clientv3.WithRev(r.Revision))
+ opts = append(opts, clientv3.WithLimit(r.Limit))
+ opts = append(opts, clientv3.WithSort(
+ clientv3.SortTarget(r.SortTarget),
+ clientv3.SortOrder(r.SortOrder)),
+ )
+ opts = append(opts, clientv3.WithMaxCreateRev(r.MaxCreateRevision))
+ opts = append(opts, clientv3.WithMinCreateRev(r.MinCreateRevision))
+ opts = append(opts, clientv3.WithMaxModRev(r.MaxModRevision))
+ opts = append(opts, clientv3.WithMinModRev(r.MinModRevision))
+ if r.CountOnly {
+ opts = append(opts, clientv3.WithCountOnly())
+ }
+
+ if r.Serializable {
+ opts = append(opts, clientv3.WithSerializable())
+ }
+
+ return clientv3.OpGet(string(r.Key), opts...)
+}
+
+func PutRequestToOp(r *pb.PutRequest) clientv3.Op {
+ opts := []clientv3.OpOption{}
+ opts = append(opts, clientv3.WithLease(clientv3.LeaseID(r.Lease)))
+ if r.IgnoreValue {
+ opts = append(opts, clientv3.WithIgnoreValue())
+ }
+ if r.IgnoreLease {
+ opts = append(opts, clientv3.WithIgnoreLease())
+ }
+ if r.PrevKv {
+ opts = append(opts, clientv3.WithPrevKV())
+ }
+ return clientv3.OpPut(string(r.Key), string(r.Value), opts...)
+}
+
+func DelRequestToOp(r *pb.DeleteRangeRequest) clientv3.Op {
+ opts := []clientv3.OpOption{}
+ if len(r.RangeEnd) != 0 {
+ opts = append(opts, clientv3.WithRange(string(r.RangeEnd)))
+ }
+ if r.PrevKv {
+ opts = append(opts, clientv3.WithPrevKV())
+ }
+ return clientv3.OpDelete(string(r.Key), opts...)
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/kv_test.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/kv_test.go
new file mode 100644
index 00000000..b0fecc37
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/kv_test.go
@@ -0,0 +1,98 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "net"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/pkg/testutil"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+)
+
+func TestKVProxyRange(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ kvts := newKVProxyServer([]string{clus.Members[0].GRPCAddr()}, t)
+ defer kvts.close()
+
+ // create a client and try to get key from proxy.
+ cfg := clientv3.Config{
+ Endpoints: []string{kvts.l.Addr().String()},
+ DialTimeout: 5 * time.Second,
+ }
+ client, err := clientv3.New(cfg)
+ if err != nil {
+ t.Fatalf("err = %v, want nil", err)
+ }
+ _, err = client.Get(context.Background(), "foo")
+ if err != nil {
+ t.Fatalf("err = %v, want nil", err)
+ }
+ client.Close()
+}
+
+type kvproxyTestServer struct {
+ kp pb.KVServer
+ c *clientv3.Client
+ server *grpc.Server
+ l net.Listener
+}
+
+func (kts *kvproxyTestServer) close() {
+ kts.server.Stop()
+ kts.l.Close()
+ kts.c.Close()
+}
+
+func newKVProxyServer(endpoints []string, t *testing.T) *kvproxyTestServer {
+ cfg := clientv3.Config{
+ Endpoints: endpoints,
+ DialTimeout: 5 * time.Second,
+ }
+ client, err := clientv3.New(cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ kvp, _ := NewKvProxy(client)
+
+ kvts := &kvproxyTestServer{
+ kp: kvp,
+ c: client,
+ }
+
+ var opts []grpc.ServerOption
+ kvts.server = grpc.NewServer(opts...)
+ pb.RegisterKVServer(kvts.server, kvts.kp)
+
+ kvts.l, err = net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ go kvts.server.Serve(kvts.l)
+
+ return kvts
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/leader.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/leader.go
new file mode 100644
index 00000000..86afdb70
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/leader.go
@@ -0,0 +1,114 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "math"
+ "sync"
+
+ "golang.org/x/net/context"
+ "golang.org/x/time/rate"
+ "google.golang.org/grpc"
+
+ "github.com/coreos/etcd/clientv3"
+)
+
+const (
+ lostLeaderKey = "__lostleader" // watched to detect leader loss
+ retryPerSecond = 10
+)
+
+type leader struct {
+ ctx context.Context
+ w clientv3.Watcher
+ // mu protects leaderc updates.
+ mu sync.RWMutex
+ leaderc chan struct{}
+ disconnc chan struct{}
+ donec chan struct{}
+}
+
+func newLeader(ctx context.Context, w clientv3.Watcher) *leader {
+ l := &leader{
+ ctx: clientv3.WithRequireLeader(ctx),
+ w: w,
+ leaderc: make(chan struct{}),
+ disconnc: make(chan struct{}),
+ donec: make(chan struct{}),
+ }
+ // begin assuming leader is lost
+ close(l.leaderc)
+ go l.recvLoop()
+ return l
+}
+
+func (l *leader) recvLoop() {
+ defer close(l.donec)
+
+ limiter := rate.NewLimiter(rate.Limit(retryPerSecond), retryPerSecond)
+ rev := int64(math.MaxInt64 - 2)
+ for limiter.Wait(l.ctx) == nil {
+ wch := l.w.Watch(l.ctx, lostLeaderKey, clientv3.WithRev(rev), clientv3.WithCreatedNotify())
+ cresp, ok := <-wch
+ if !ok {
+ l.loseLeader()
+ continue
+ }
+ if cresp.Err() != nil {
+ l.loseLeader()
+ if grpc.ErrorDesc(cresp.Err()) == grpc.ErrClientConnClosing.Error() {
+ close(l.disconnc)
+ return
+ }
+ continue
+ }
+ l.gotLeader()
+ <-wch
+ l.loseLeader()
+ }
+}
+
+func (l *leader) loseLeader() {
+ l.mu.RLock()
+ defer l.mu.RUnlock()
+ select {
+ case <-l.leaderc:
+ default:
+ close(l.leaderc)
+ }
+}
+
+// gotLeader will force update the leadership status to having a leader.
+func (l *leader) gotLeader() {
+ l.mu.Lock()
+ defer l.mu.Unlock()
+ select {
+ case <-l.leaderc:
+ l.leaderc = make(chan struct{})
+ default:
+ }
+}
+
+func (l *leader) disconnectNotify() <-chan struct{} { return l.disconnc }
+
+func (l *leader) stopNotify() <-chan struct{} { return l.donec }
+
+// lostNotify returns a channel that is closed if there has been
+// a leader loss not yet followed by a leader reacquire.
+func (l *leader) lostNotify() <-chan struct{} {
+ l.mu.RLock()
+ defer l.mu.RUnlock()
+ return l.leaderc
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/lease.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/lease.go
new file mode 100644
index 00000000..dd23425a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/lease.go
@@ -0,0 +1,367 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "io"
+ "sync"
+ "sync/atomic"
+ "time"
+
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/metadata"
+
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+type leaseProxy struct {
+ // leaseClient handles req from LeaseGrant() that requires a lease ID.
+ leaseClient pb.LeaseClient
+
+ lessor clientv3.Lease
+
+ ctx context.Context
+
+ leader *leader
+
+ // mu protects adding outstanding leaseProxyStream through wg.
+ mu sync.RWMutex
+
+ // wg waits until all outstanding leaseProxyStream quit.
+ wg sync.WaitGroup
+}
+
+func NewLeaseProxy(c *clientv3.Client) (pb.LeaseServer, <-chan struct{}) {
+ cctx, cancel := context.WithCancel(c.Ctx())
+ lp := &leaseProxy{
+ leaseClient: pb.NewLeaseClient(c.ActiveConnection()),
+ lessor: c.Lease,
+ ctx: cctx,
+ leader: newLeader(c.Ctx(), c.Watcher),
+ }
+ ch := make(chan struct{})
+ go func() {
+ defer close(ch)
+ <-lp.leader.stopNotify()
+ lp.mu.Lock()
+ select {
+ case <-lp.ctx.Done():
+ case <-lp.leader.disconnectNotify():
+ cancel()
+ }
+ <-lp.ctx.Done()
+ lp.mu.Unlock()
+ lp.wg.Wait()
+ }()
+ return lp, ch
+}
+
+func (lp *leaseProxy) LeaseGrant(ctx context.Context, cr *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) {
+ rp, err := lp.leaseClient.LeaseGrant(ctx, cr)
+ if err != nil {
+ return nil, err
+ }
+ lp.leader.gotLeader()
+ return rp, nil
+}
+
+func (lp *leaseProxy) LeaseRevoke(ctx context.Context, rr *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error) {
+ r, err := lp.lessor.Revoke(ctx, clientv3.LeaseID(rr.ID))
+ if err != nil {
+ return nil, err
+ }
+ lp.leader.gotLeader()
+ return (*pb.LeaseRevokeResponse)(r), nil
+}
+
+func (lp *leaseProxy) LeaseTimeToLive(ctx context.Context, rr *pb.LeaseTimeToLiveRequest) (*pb.LeaseTimeToLiveResponse, error) {
+ var (
+ r *clientv3.LeaseTimeToLiveResponse
+ err error
+ )
+ if rr.Keys {
+ r, err = lp.lessor.TimeToLive(ctx, clientv3.LeaseID(rr.ID), clientv3.WithAttachedKeys())
+ } else {
+ r, err = lp.lessor.TimeToLive(ctx, clientv3.LeaseID(rr.ID))
+ }
+ if err != nil {
+ return nil, err
+ }
+ rp := &pb.LeaseTimeToLiveResponse{
+ Header: r.ResponseHeader,
+ ID: int64(r.ID),
+ TTL: r.TTL,
+ GrantedTTL: r.GrantedTTL,
+ Keys: r.Keys,
+ }
+ return rp, err
+}
+
+func (lp *leaseProxy) LeaseKeepAlive(stream pb.Lease_LeaseKeepAliveServer) error {
+ lp.mu.Lock()
+ select {
+ case <-lp.ctx.Done():
+ lp.mu.Unlock()
+ return lp.ctx.Err()
+ default:
+ lp.wg.Add(1)
+ }
+ lp.mu.Unlock()
+
+ ctx, cancel := context.WithCancel(stream.Context())
+ lps := leaseProxyStream{
+ stream: stream,
+ lessor: lp.lessor,
+ keepAliveLeases: make(map[int64]*atomicCounter),
+ respc: make(chan *pb.LeaseKeepAliveResponse),
+ ctx: ctx,
+ cancel: cancel,
+ }
+
+ errc := make(chan error, 2)
+
+ var lostLeaderC <-chan struct{}
+ if md, ok := metadata.FromContext(stream.Context()); ok {
+ v := md[rpctypes.MetadataRequireLeaderKey]
+ if len(v) > 0 && v[0] == rpctypes.MetadataHasLeader {
+ lostLeaderC = lp.leader.lostNotify()
+ // if leader is known to be lost at creation time, avoid
+ // letting events through at all
+ select {
+ case <-lostLeaderC:
+ lp.wg.Done()
+ return rpctypes.ErrNoLeader
+ default:
+ }
+ }
+ }
+ stopc := make(chan struct{}, 3)
+ go func() {
+ defer func() { stopc <- struct{}{} }()
+ if err := lps.recvLoop(); err != nil {
+ errc <- err
+ }
+ }()
+
+ go func() {
+ defer func() { stopc <- struct{}{} }()
+ if err := lps.sendLoop(); err != nil {
+ errc <- err
+ }
+ }()
+
+ // tears down LeaseKeepAlive stream if leader goes down or entire leaseProxy is terminated.
+ go func() {
+ defer func() { stopc <- struct{}{} }()
+ select {
+ case <-lostLeaderC:
+ case <-ctx.Done():
+ case <-lp.ctx.Done():
+ }
+ }()
+
+ var err error
+ select {
+ case <-stopc:
+ stopc <- struct{}{}
+ case err = <-errc:
+ }
+ cancel()
+
+ // recv/send may only shutdown after function exits;
+ // this goroutine notifies lease proxy that the stream is through
+ go func() {
+ <-stopc
+ <-stopc
+ <-stopc
+ lps.close()
+ close(errc)
+ lp.wg.Done()
+ }()
+
+ select {
+ case <-lostLeaderC:
+ return rpctypes.ErrNoLeader
+ case <-lp.leader.disconnectNotify():
+ return grpc.ErrClientConnClosing
+ default:
+ if err != nil {
+ return err
+ }
+ return ctx.Err()
+ }
+}
+
+type leaseProxyStream struct {
+ stream pb.Lease_LeaseKeepAliveServer
+
+ lessor clientv3.Lease
+ // wg tracks keepAliveLoop goroutines
+ wg sync.WaitGroup
+ // mu protects keepAliveLeases
+ mu sync.RWMutex
+ // keepAliveLeases tracks how many outstanding keepalive requests which need responses are on a lease.
+ keepAliveLeases map[int64]*atomicCounter
+ // respc receives lease keepalive responses from etcd backend
+ respc chan *pb.LeaseKeepAliveResponse
+
+ ctx context.Context
+ cancel context.CancelFunc
+}
+
+func (lps *leaseProxyStream) recvLoop() error {
+ for {
+ rr, err := lps.stream.Recv()
+ if err == io.EOF {
+ return nil
+ }
+ if err != nil {
+ return err
+ }
+ lps.mu.Lock()
+ neededResps, ok := lps.keepAliveLeases[rr.ID]
+ if !ok {
+ neededResps = &atomicCounter{}
+ lps.keepAliveLeases[rr.ID] = neededResps
+ lps.wg.Add(1)
+ go func() {
+ defer lps.wg.Done()
+ if err := lps.keepAliveLoop(rr.ID, neededResps); err != nil {
+ lps.cancel()
+ }
+ }()
+ }
+ neededResps.add(1)
+ lps.mu.Unlock()
+ }
+}
+
+func (lps *leaseProxyStream) keepAliveLoop(leaseID int64, neededResps *atomicCounter) error {
+ cctx, ccancel := context.WithCancel(lps.ctx)
+ defer ccancel()
+ respc, err := lps.lessor.KeepAlive(cctx, clientv3.LeaseID(leaseID))
+ if err != nil {
+ return err
+ }
+ // ticker expires when loop hasn't received keepalive within TTL
+ var ticker <-chan time.Time
+ for {
+ select {
+ case <-ticker:
+ lps.mu.Lock()
+ // if there are outstanding keepAlive reqs at the moment of ticker firing,
+ // don't close keepAliveLoop(), let it continuing to process the KeepAlive reqs.
+ if neededResps.get() > 0 {
+ lps.mu.Unlock()
+ ticker = nil
+ continue
+ }
+ delete(lps.keepAliveLeases, leaseID)
+ lps.mu.Unlock()
+ return nil
+ case rp, ok := <-respc:
+ if !ok {
+ lps.mu.Lock()
+ delete(lps.keepAliveLeases, leaseID)
+ lps.mu.Unlock()
+ if neededResps.get() == 0 {
+ return nil
+ }
+ ttlResp, err := lps.lessor.TimeToLive(cctx, clientv3.LeaseID(leaseID))
+ if err != nil {
+ return err
+ }
+ r := &pb.LeaseKeepAliveResponse{
+ Header: ttlResp.ResponseHeader,
+ ID: int64(ttlResp.ID),
+ TTL: ttlResp.TTL,
+ }
+ for neededResps.get() > 0 {
+ select {
+ case lps.respc <- r:
+ neededResps.add(-1)
+ case <-lps.ctx.Done():
+ return nil
+ }
+ }
+ return nil
+ }
+ if neededResps.get() == 0 {
+ continue
+ }
+ ticker = time.After(time.Duration(rp.TTL) * time.Second)
+ r := &pb.LeaseKeepAliveResponse{
+ Header: rp.ResponseHeader,
+ ID: int64(rp.ID),
+ TTL: rp.TTL,
+ }
+ lps.replyToClient(r, neededResps)
+ }
+ }
+}
+
+func (lps *leaseProxyStream) replyToClient(r *pb.LeaseKeepAliveResponse, neededResps *atomicCounter) {
+ timer := time.After(500 * time.Millisecond)
+ for neededResps.get() > 0 {
+ select {
+ case lps.respc <- r:
+ neededResps.add(-1)
+ case <-timer:
+ return
+ case <-lps.ctx.Done():
+ return
+ }
+ }
+}
+
+func (lps *leaseProxyStream) sendLoop() error {
+ for {
+ select {
+ case lrp, ok := <-lps.respc:
+ if !ok {
+ return nil
+ }
+ if err := lps.stream.Send(lrp); err != nil {
+ return err
+ }
+ case <-lps.ctx.Done():
+ return lps.ctx.Err()
+ }
+ }
+}
+
+func (lps *leaseProxyStream) close() {
+ lps.cancel()
+ lps.wg.Wait()
+ // only close respc channel if all the keepAliveLoop() goroutines have finished
+ // this ensures those goroutines don't send resp to a closed resp channel
+ close(lps.respc)
+}
+
+type atomicCounter struct {
+ counter int64
+}
+
+func (ac *atomicCounter) add(delta int64) {
+ atomic.AddInt64(&ac.counter, delta)
+}
+
+func (ac *atomicCounter) get() int64 {
+ return atomic.LoadInt64(&ac.counter)
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/lock.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/lock.go
new file mode 100644
index 00000000..804aff64
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/lock.go
@@ -0,0 +1,38 @@
+// Copyright 2017 The etcd Lockors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb"
+)
+
+type lockProxy struct {
+ client *clientv3.Client
+}
+
+func NewLockProxy(client *clientv3.Client) v3lockpb.LockServer {
+ return &lockProxy{client: client}
+}
+
+func (lp *lockProxy) Lock(ctx context.Context, req *v3lockpb.LockRequest) (*v3lockpb.LockResponse, error) {
+ return v3lockpb.NewLockClient(lp.client.ActiveConnection()).Lock(ctx, req)
+}
+
+func (lp *lockProxy) Unlock(ctx context.Context, req *v3lockpb.UnlockRequest) (*v3lockpb.UnlockResponse, error) {
+ return v3lockpb.NewLockClient(lp.client.ActiveConnection()).Unlock(ctx, req)
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/logger.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/logger.go
new file mode 100644
index 00000000..c2d81804
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/logger.go
@@ -0,0 +1,19 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import "github.com/coreos/pkg/capnslog"
+
+var plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "grpcproxy")
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/maintenance.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/maintenance.go
new file mode 100644
index 00000000..384d1520
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/maintenance.go
@@ -0,0 +1,79 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "io"
+
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+type maintenanceProxy struct {
+ client *clientv3.Client
+}
+
+func NewMaintenanceProxy(c *clientv3.Client) pb.MaintenanceServer {
+ return &maintenanceProxy{
+ client: c,
+ }
+}
+
+func (mp *maintenanceProxy) Defragment(ctx context.Context, dr *pb.DefragmentRequest) (*pb.DefragmentResponse, error) {
+ conn := mp.client.ActiveConnection()
+ return pb.NewMaintenanceClient(conn).Defragment(ctx, dr)
+}
+
+func (mp *maintenanceProxy) Snapshot(sr *pb.SnapshotRequest, stream pb.Maintenance_SnapshotServer) error {
+ conn := mp.client.ActiveConnection()
+ ctx, cancel := context.WithCancel(stream.Context())
+ defer cancel()
+
+ sc, err := pb.NewMaintenanceClient(conn).Snapshot(ctx, sr)
+ if err != nil {
+ return err
+ }
+
+ for {
+ rr, err := sc.Recv()
+ if err != nil {
+ if err == io.EOF {
+ return nil
+ }
+ return err
+ }
+ err = stream.Send(rr)
+ if err != nil {
+ return err
+ }
+ }
+}
+
+func (mp *maintenanceProxy) Hash(ctx context.Context, r *pb.HashRequest) (*pb.HashResponse, error) {
+ conn := mp.client.ActiveConnection()
+ return pb.NewMaintenanceClient(conn).Hash(ctx, r)
+}
+
+func (mp *maintenanceProxy) Alarm(ctx context.Context, r *pb.AlarmRequest) (*pb.AlarmResponse, error) {
+ conn := mp.client.ActiveConnection()
+ return pb.NewMaintenanceClient(conn).Alarm(ctx, r)
+}
+
+func (mp *maintenanceProxy) Status(ctx context.Context, r *pb.StatusRequest) (*pb.StatusResponse, error) {
+ conn := mp.client.ActiveConnection()
+ return pb.NewMaintenanceClient(conn).Status(ctx, r)
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/metrics.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/metrics.go
new file mode 100644
index 00000000..864fa160
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/metrics.go
@@ -0,0 +1,58 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import "github.com/prometheus/client_golang/prometheus"
+
+var (
+ watchersCoalescing = prometheus.NewGauge(prometheus.GaugeOpts{
+ Namespace: "etcd",
+ Subsystem: "grpc_proxy",
+ Name: "watchers_coalescing_total",
+ Help: "Total number of current watchers coalescing",
+ })
+ eventsCoalescing = prometheus.NewCounter(prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "grpc_proxy",
+ Name: "events_coalescing_total",
+ Help: "Total number of events coalescing",
+ })
+ cacheKeys = prometheus.NewGauge(prometheus.GaugeOpts{
+ Namespace: "etcd",
+ Subsystem: "grpc_proxy",
+ Name: "cache_keys_total",
+ Help: "Total number of keys/ranges cached",
+ })
+ cacheHits = prometheus.NewGauge(prometheus.GaugeOpts{
+ Namespace: "etcd",
+ Subsystem: "grpc_proxy",
+ Name: "cache_hits_total",
+ Help: "Total number of cache hits",
+ })
+ cachedMisses = prometheus.NewGauge(prometheus.GaugeOpts{
+ Namespace: "etcd",
+ Subsystem: "grpc_proxy",
+ Name: "cache_misses_total",
+ Help: "Total number of cache misses",
+ })
+)
+
+func init() {
+ prometheus.MustRegister(watchersCoalescing)
+ prometheus.MustRegister(eventsCoalescing)
+ prometheus.MustRegister(cacheKeys)
+ prometheus.MustRegister(cacheHits)
+ prometheus.MustRegister(cachedMisses)
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/register.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/register.go
new file mode 100644
index 00000000..598c71f0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/register.go
@@ -0,0 +1,94 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "encoding/json"
+ "os"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/concurrency"
+ "github.com/coreos/etcd/clientv3/naming"
+
+ "golang.org/x/time/rate"
+ gnaming "google.golang.org/grpc/naming"
+)
+
+// allow maximum 1 retry per second
+const registerRetryRate = 1
+
+// Register registers itself as a grpc-proxy server by writing prefixed-key
+// with session of specified TTL (in seconds). The returned channel is closed
+// when the client's context is canceled.
+func Register(c *clientv3.Client, prefix string, addr string, ttl int) <-chan struct{} {
+ rm := rate.NewLimiter(rate.Limit(registerRetryRate), registerRetryRate)
+
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+
+ for rm.Wait(c.Ctx()) == nil {
+ ss, err := registerSession(c, prefix, addr, ttl)
+ if err != nil {
+ plog.Warningf("failed to create a session %v", err)
+ continue
+ }
+ select {
+ case <-c.Ctx().Done():
+ ss.Close()
+ return
+
+ case <-ss.Done():
+ plog.Warning("session expired; possible network partition or server restart")
+ plog.Warning("creating a new session to rejoin")
+ continue
+ }
+ }
+ }()
+
+ return donec
+}
+
+func registerSession(c *clientv3.Client, prefix string, addr string, ttl int) (*concurrency.Session, error) {
+ ss, err := concurrency.NewSession(c, concurrency.WithTTL(ttl))
+ if err != nil {
+ return nil, err
+ }
+
+ gr := &naming.GRPCResolver{Client: c}
+ if err = gr.Update(c.Ctx(), prefix, gnaming.Update{Op: gnaming.Add, Addr: addr, Metadata: getMeta()}, clientv3.WithLease(ss.Lease())); err != nil {
+ return nil, err
+ }
+
+ plog.Infof("registered %q with %d-second lease", addr, ttl)
+ return ss, nil
+}
+
+// meta represents metadata of proxy register.
+type meta struct {
+ Name string `json:"name"`
+}
+
+func getMeta() string {
+ hostname, _ := os.Hostname()
+ bts, _ := json.Marshal(meta{Name: hostname})
+ return string(bts)
+}
+
+func decodeMeta(s string) (meta, error) {
+ m := meta{}
+ err := json.Unmarshal([]byte(s), &m)
+ return m, err
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/register_test.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/register_test.go
new file mode 100644
index 00000000..7679e0e7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/register_test.go
@@ -0,0 +1,76 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/clientv3/naming"
+ "github.com/coreos/etcd/integration"
+ "github.com/coreos/etcd/pkg/testutil"
+
+ gnaming "google.golang.org/grpc/naming"
+)
+
+func TestRegister(t *testing.T) {
+ defer testutil.AfterTest(t)
+
+ clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+ cli := clus.Client(0)
+ paddr := clus.Members[0].GRPCAddr()
+
+ testPrefix := "test-name"
+ wa := createWatcher(t, cli, testPrefix)
+ ups, err := wa.Next()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(ups) != 0 {
+ t.Fatalf("len(ups) expected 0, got %d (%v)", len(ups), ups)
+ }
+
+ donec := Register(cli, testPrefix, paddr, 5)
+
+ ups, err = wa.Next()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(ups) != 1 {
+ t.Fatalf("len(ups) expected 1, got %d (%v)", len(ups), ups)
+ }
+ if ups[0].Addr != paddr {
+ t.Fatalf("ups[0].Addr expected %q, got %q", paddr, ups[0].Addr)
+ }
+
+ cli.Close()
+ clus.TakeClient(0)
+ select {
+ case <-donec:
+ case <-time.After(5 * time.Second):
+ t.Fatal("donec 'register' did not return in time")
+ }
+}
+
+func createWatcher(t *testing.T, c *clientv3.Client, prefix string) gnaming.Watcher {
+ gr := &naming.GRPCResolver{Client: c}
+ watcher, err := gr.Resolve(prefix)
+ if err != nil {
+ t.Fatalf("failed to resolve %q (%v)", prefix, err)
+ }
+ return watcher
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/watch.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/watch.go
new file mode 100644
index 00000000..42748fd4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/watch.go
@@ -0,0 +1,262 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "sync"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/metadata"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+type watchProxy struct {
+ cw clientv3.Watcher
+ ctx context.Context
+
+ leader *leader
+
+ ranges *watchRanges
+
+ // mu protects adding outstanding watch servers through wg.
+ mu sync.Mutex
+
+ // wg waits until all outstanding watch servers quit.
+ wg sync.WaitGroup
+}
+
+func NewWatchProxy(c *clientv3.Client) (pb.WatchServer, <-chan struct{}) {
+ cctx, cancel := context.WithCancel(c.Ctx())
+ wp := &watchProxy{
+ cw: c.Watcher,
+ ctx: cctx,
+ leader: newLeader(c.Ctx(), c.Watcher),
+ }
+ wp.ranges = newWatchRanges(wp)
+ ch := make(chan struct{})
+ go func() {
+ defer close(ch)
+ <-wp.leader.stopNotify()
+ wp.mu.Lock()
+ select {
+ case <-wp.ctx.Done():
+ case <-wp.leader.disconnectNotify():
+ cancel()
+ }
+ <-wp.ctx.Done()
+ wp.mu.Unlock()
+ wp.wg.Wait()
+ wp.ranges.stop()
+ }()
+ return wp, ch
+}
+
+func (wp *watchProxy) Watch(stream pb.Watch_WatchServer) (err error) {
+ wp.mu.Lock()
+ select {
+ case <-wp.ctx.Done():
+ wp.mu.Unlock()
+ select {
+ case <-wp.leader.disconnectNotify():
+ return grpc.ErrClientConnClosing
+ default:
+ return wp.ctx.Err()
+ }
+ default:
+ wp.wg.Add(1)
+ }
+ wp.mu.Unlock()
+
+ ctx, cancel := context.WithCancel(stream.Context())
+ wps := &watchProxyStream{
+ ranges: wp.ranges,
+ watchers: make(map[int64]*watcher),
+ stream: stream,
+ watchCh: make(chan *pb.WatchResponse, 1024),
+ ctx: ctx,
+ cancel: cancel,
+ }
+
+ var lostLeaderC <-chan struct{}
+ if md, ok := metadata.FromContext(stream.Context()); ok {
+ v := md[rpctypes.MetadataRequireLeaderKey]
+ if len(v) > 0 && v[0] == rpctypes.MetadataHasLeader {
+ lostLeaderC = wp.leader.lostNotify()
+ // if leader is known to be lost at creation time, avoid
+ // letting events through at all
+ select {
+ case <-lostLeaderC:
+ wp.wg.Done()
+ return rpctypes.ErrNoLeader
+ default:
+ }
+ }
+ }
+
+ // post to stopc => terminate server stream; can't use a waitgroup
+ // since all goroutines will only terminate after Watch() exits.
+ stopc := make(chan struct{}, 3)
+ go func() {
+ defer func() { stopc <- struct{}{} }()
+ wps.recvLoop()
+ }()
+ go func() {
+ defer func() { stopc <- struct{}{} }()
+ wps.sendLoop()
+ }()
+ // tear down watch if leader goes down or entire watch proxy is terminated
+ go func() {
+ defer func() { stopc <- struct{}{} }()
+ select {
+ case <-lostLeaderC:
+ case <-ctx.Done():
+ case <-wp.ctx.Done():
+ }
+ }()
+
+ <-stopc
+ cancel()
+
+ // recv/send may only shutdown after function exits;
+ // goroutine notifies proxy that stream is through
+ go func() {
+ <-stopc
+ <-stopc
+ wps.close()
+ wp.wg.Done()
+ }()
+
+ select {
+ case <-lostLeaderC:
+ return rpctypes.ErrNoLeader
+ case <-wp.leader.disconnectNotify():
+ return grpc.ErrClientConnClosing
+ default:
+ return wps.ctx.Err()
+ }
+}
+
+// watchProxyStream forwards etcd watch events to a proxied client stream.
+type watchProxyStream struct {
+ ranges *watchRanges
+
+ // mu protects watchers and nextWatcherID
+ mu sync.Mutex
+ // watchers receive events from watch broadcast.
+ watchers map[int64]*watcher
+ // nextWatcherID is the id to assign the next watcher on this stream.
+ nextWatcherID int64
+
+ stream pb.Watch_WatchServer
+
+ // watchCh receives watch responses from the watchers.
+ watchCh chan *pb.WatchResponse
+
+ ctx context.Context
+ cancel context.CancelFunc
+}
+
+func (wps *watchProxyStream) close() {
+ var wg sync.WaitGroup
+ wps.cancel()
+ wps.mu.Lock()
+ wg.Add(len(wps.watchers))
+ for _, wpsw := range wps.watchers {
+ go func(w *watcher) {
+ wps.ranges.delete(w)
+ wg.Done()
+ }(wpsw)
+ }
+ wps.watchers = nil
+ wps.mu.Unlock()
+
+ wg.Wait()
+
+ close(wps.watchCh)
+}
+
+func (wps *watchProxyStream) recvLoop() error {
+ for {
+ req, err := wps.stream.Recv()
+ if err != nil {
+ return err
+ }
+ switch uv := req.RequestUnion.(type) {
+ case *pb.WatchRequest_CreateRequest:
+ cr := uv.CreateRequest
+ w := &watcher{
+ wr: watchRange{string(cr.Key), string(cr.RangeEnd)},
+ id: wps.nextWatcherID,
+ wps: wps,
+
+ nextrev: cr.StartRevision,
+ progress: cr.ProgressNotify,
+ prevKV: cr.PrevKv,
+ filters: v3rpc.FiltersFromRequest(cr),
+ }
+ if !w.wr.valid() {
+ w.post(&pb.WatchResponse{WatchId: -1, Created: true, Canceled: true})
+ continue
+ }
+ wps.nextWatcherID++
+ w.nextrev = cr.StartRevision
+ wps.watchers[w.id] = w
+ wps.ranges.add(w)
+ case *pb.WatchRequest_CancelRequest:
+ wps.delete(uv.CancelRequest.WatchId)
+ default:
+ panic("not implemented")
+ }
+ }
+}
+
+func (wps *watchProxyStream) sendLoop() {
+ for {
+ select {
+ case wresp, ok := <-wps.watchCh:
+ if !ok {
+ return
+ }
+ if err := wps.stream.Send(wresp); err != nil {
+ return
+ }
+ case <-wps.ctx.Done():
+ return
+ }
+ }
+}
+
+func (wps *watchProxyStream) delete(id int64) {
+ wps.mu.Lock()
+ defer wps.mu.Unlock()
+
+ w, ok := wps.watchers[id]
+ if !ok {
+ return
+ }
+ wps.ranges.delete(w)
+ delete(wps.watchers, id)
+ resp := &pb.WatchResponse{
+ Header: &w.lastHeader,
+ WatchId: id,
+ Canceled: true,
+ }
+ wps.watchCh <- resp
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/watch_broadcast.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/watch_broadcast.go
new file mode 100644
index 00000000..5e750bdb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/watch_broadcast.go
@@ -0,0 +1,151 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "sync"
+
+ "golang.org/x/net/context"
+
+ "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+// watchBroadcast broadcasts a server watcher to many client watchers.
+type watchBroadcast struct {
+ // cancel stops the underlying etcd server watcher and closes ch.
+ cancel context.CancelFunc
+ donec chan struct{}
+
+ // mu protects rev and receivers.
+ mu sync.RWMutex
+ // nextrev is the minimum expected next revision of the watcher on ch.
+ nextrev int64
+ // receivers contains all the client-side watchers to serve.
+ receivers map[*watcher]struct{}
+ // responses counts the number of responses
+ responses int
+}
+
+func newWatchBroadcast(wp *watchProxy, w *watcher, update func(*watchBroadcast)) *watchBroadcast {
+ cctx, cancel := context.WithCancel(wp.ctx)
+ wb := &watchBroadcast{
+ cancel: cancel,
+ nextrev: w.nextrev,
+ receivers: make(map[*watcher]struct{}),
+ donec: make(chan struct{}),
+ }
+ wb.add(w)
+ go func() {
+ defer close(wb.donec)
+
+ opts := []clientv3.OpOption{
+ clientv3.WithRange(w.wr.end),
+ clientv3.WithProgressNotify(),
+ clientv3.WithRev(wb.nextrev),
+ clientv3.WithPrevKV(),
+ clientv3.WithCreatedNotify(),
+ }
+
+ wch := wp.cw.Watch(cctx, w.wr.key, opts...)
+
+ for wr := range wch {
+ wb.bcast(wr)
+ update(wb)
+ }
+ }()
+ return wb
+}
+
+func (wb *watchBroadcast) bcast(wr clientv3.WatchResponse) {
+ wb.mu.Lock()
+ defer wb.mu.Unlock()
+ // watchers start on the given revision, if any; ignore header rev on create
+ if wb.responses > 0 || wb.nextrev == 0 {
+ wb.nextrev = wr.Header.Revision + 1
+ }
+ wb.responses++
+ for r := range wb.receivers {
+ r.send(wr)
+ }
+ if len(wb.receivers) > 0 {
+ eventsCoalescing.Add(float64(len(wb.receivers) - 1))
+ }
+}
+
+// add puts a watcher into receiving a broadcast if its revision at least
+// meets the broadcast revision. Returns true if added.
+func (wb *watchBroadcast) add(w *watcher) bool {
+ wb.mu.Lock()
+ defer wb.mu.Unlock()
+ if wb.nextrev > w.nextrev || (wb.nextrev == 0 && w.nextrev != 0) {
+ // wb is too far ahead, w will miss events
+ // or wb is being established with a current watcher
+ return false
+ }
+ if wb.responses == 0 {
+ // Newly created; create event will be sent by etcd.
+ wb.receivers[w] = struct{}{}
+ return true
+ }
+ // already sent by etcd; emulate create event
+ ok := w.post(&pb.WatchResponse{
+ Header: &pb.ResponseHeader{
+ // todo: fill in ClusterId
+ // todo: fill in MemberId:
+ Revision: w.nextrev,
+ // todo: fill in RaftTerm:
+ },
+ WatchId: w.id,
+ Created: true,
+ })
+ if !ok {
+ return false
+ }
+ wb.receivers[w] = struct{}{}
+ watchersCoalescing.Inc()
+
+ return true
+}
+func (wb *watchBroadcast) delete(w *watcher) {
+ wb.mu.Lock()
+ defer wb.mu.Unlock()
+ if _, ok := wb.receivers[w]; !ok {
+ panic("deleting missing watcher from broadcast")
+ }
+ delete(wb.receivers, w)
+ if len(wb.receivers) > 0 {
+ // do not dec the only left watcher for coalescing.
+ watchersCoalescing.Dec()
+ }
+}
+
+func (wb *watchBroadcast) size() int {
+ wb.mu.RLock()
+ defer wb.mu.RUnlock()
+ return len(wb.receivers)
+}
+
+func (wb *watchBroadcast) empty() bool { return wb.size() == 0 }
+
+func (wb *watchBroadcast) stop() {
+ if !wb.empty() {
+ // do not dec the only left watcher for coalescing.
+ watchersCoalescing.Sub(float64(wb.size() - 1))
+ }
+
+ wb.cancel()
+ <-wb.donec
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/watch_broadcasts.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/watch_broadcasts.go
new file mode 100644
index 00000000..8fe9e5f5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/watch_broadcasts.go
@@ -0,0 +1,135 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "sync"
+)
+
+type watchBroadcasts struct {
+ wp *watchProxy
+
+ // mu protects bcasts and watchers from the coalesce loop.
+ mu sync.Mutex
+ bcasts map[*watchBroadcast]struct{}
+ watchers map[*watcher]*watchBroadcast
+
+ updatec chan *watchBroadcast
+ donec chan struct{}
+}
+
+// maxCoalesceRecievers prevents a popular watchBroadcast from being coalseced.
+const maxCoalesceReceivers = 5
+
+func newWatchBroadcasts(wp *watchProxy) *watchBroadcasts {
+ wbs := &watchBroadcasts{
+ wp: wp,
+ bcasts: make(map[*watchBroadcast]struct{}),
+ watchers: make(map[*watcher]*watchBroadcast),
+ updatec: make(chan *watchBroadcast, 1),
+ donec: make(chan struct{}),
+ }
+ go func() {
+ defer close(wbs.donec)
+ for wb := range wbs.updatec {
+ wbs.coalesce(wb)
+ }
+ }()
+ return wbs
+}
+
+func (wbs *watchBroadcasts) coalesce(wb *watchBroadcast) {
+ if wb.size() >= maxCoalesceReceivers {
+ return
+ }
+ wbs.mu.Lock()
+ for wbswb := range wbs.bcasts {
+ if wbswb == wb {
+ continue
+ }
+ wb.mu.Lock()
+ wbswb.mu.Lock()
+ // 1. check if wbswb is behind wb so it won't skip any events in wb
+ // 2. ensure wbswb started; nextrev == 0 may mean wbswb is waiting
+ // for a current watcher and expects a create event from the server.
+ if wb.nextrev >= wbswb.nextrev && wbswb.responses > 0 {
+ for w := range wb.receivers {
+ wbswb.receivers[w] = struct{}{}
+ wbs.watchers[w] = wbswb
+ }
+ wb.receivers = nil
+ }
+ wbswb.mu.Unlock()
+ wb.mu.Unlock()
+ if wb.empty() {
+ delete(wbs.bcasts, wb)
+ wb.stop()
+ break
+ }
+ }
+ wbs.mu.Unlock()
+}
+
+func (wbs *watchBroadcasts) add(w *watcher) {
+ wbs.mu.Lock()
+ defer wbs.mu.Unlock()
+ // find fitting bcast
+ for wb := range wbs.bcasts {
+ if wb.add(w) {
+ wbs.watchers[w] = wb
+ return
+ }
+ }
+ // no fit; create a bcast
+ wb := newWatchBroadcast(wbs.wp, w, wbs.update)
+ wbs.watchers[w] = wb
+ wbs.bcasts[wb] = struct{}{}
+}
+
+// delete removes a watcher and returns the number of remaining watchers.
+func (wbs *watchBroadcasts) delete(w *watcher) int {
+ wbs.mu.Lock()
+ defer wbs.mu.Unlock()
+
+ wb, ok := wbs.watchers[w]
+ if !ok {
+ panic("deleting missing watcher from broadcasts")
+ }
+ delete(wbs.watchers, w)
+ wb.delete(w)
+ if wb.empty() {
+ delete(wbs.bcasts, wb)
+ wb.stop()
+ }
+ return len(wbs.bcasts)
+}
+
+func (wbs *watchBroadcasts) stop() {
+ wbs.mu.Lock()
+ for wb := range wbs.bcasts {
+ wb.stop()
+ }
+ wbs.bcasts = nil
+ close(wbs.updatec)
+ wbs.mu.Unlock()
+ <-wbs.donec
+}
+
+func (wbs *watchBroadcasts) update(wb *watchBroadcast) {
+ select {
+ case wbs.updatec <- wb:
+ default:
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/watch_ranges.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/watch_ranges.go
new file mode 100644
index 00000000..31c6b592
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/watch_ranges.go
@@ -0,0 +1,69 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "sync"
+)
+
+// watchRanges tracks all open watches for the proxy.
+type watchRanges struct {
+ wp *watchProxy
+
+ mu sync.Mutex
+ bcasts map[watchRange]*watchBroadcasts
+}
+
+func newWatchRanges(wp *watchProxy) *watchRanges {
+ return &watchRanges{
+ wp: wp,
+ bcasts: make(map[watchRange]*watchBroadcasts),
+ }
+}
+
+func (wrs *watchRanges) add(w *watcher) {
+ wrs.mu.Lock()
+ defer wrs.mu.Unlock()
+
+ if wbs := wrs.bcasts[w.wr]; wbs != nil {
+ wbs.add(w)
+ return
+ }
+ wbs := newWatchBroadcasts(wrs.wp)
+ wrs.bcasts[w.wr] = wbs
+ wbs.add(w)
+}
+
+func (wrs *watchRanges) delete(w *watcher) {
+ wrs.mu.Lock()
+ defer wrs.mu.Unlock()
+ wbs, ok := wrs.bcasts[w.wr]
+ if !ok {
+ panic("deleting missing range")
+ }
+ if wbs.delete(w) == 0 {
+ wbs.stop()
+ delete(wrs.bcasts, w.wr)
+ }
+}
+
+func (wrs *watchRanges) stop() {
+ wrs.mu.Lock()
+ defer wrs.mu.Unlock()
+ for _, wb := range wrs.bcasts {
+ wb.stop()
+ }
+ wrs.bcasts = nil
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/grpcproxy/watcher.go b/vendor/github.com/coreos/etcd/proxy/grpcproxy/watcher.go
new file mode 100644
index 00000000..7387caf4
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/grpcproxy/watcher.go
@@ -0,0 +1,128 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 grpcproxy
+
+import (
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/mvcc"
+ "github.com/coreos/etcd/mvcc/mvccpb"
+)
+
+type watchRange struct {
+ key, end string
+}
+
+func (wr *watchRange) valid() bool {
+ return len(wr.end) == 0 || wr.end > wr.key || (wr.end[0] == 0 && len(wr.end) == 1)
+}
+
+type watcher struct {
+ // user configuration
+
+ wr watchRange
+ filters []mvcc.FilterFunc
+ progress bool
+ prevKV bool
+
+ // id is the id returned to the client on its watch stream.
+ id int64
+ // nextrev is the minimum expected next event revision.
+ nextrev int64
+ // lastHeader has the last header sent over the stream.
+ lastHeader pb.ResponseHeader
+
+ // wps is the parent.
+ wps *watchProxyStream
+}
+
+// send filters out repeated events by discarding revisions older
+// than the last one sent over the watch channel.
+func (w *watcher) send(wr clientv3.WatchResponse) {
+ if wr.IsProgressNotify() && !w.progress {
+ return
+ }
+ if w.nextrev > wr.Header.Revision && len(wr.Events) > 0 {
+ return
+ }
+ if w.nextrev == 0 {
+ // current watch; expect updates following this revision
+ w.nextrev = wr.Header.Revision + 1
+ }
+
+ events := make([]*mvccpb.Event, 0, len(wr.Events))
+
+ var lastRev int64
+ for i := range wr.Events {
+ ev := (*mvccpb.Event)(wr.Events[i])
+ if ev.Kv.ModRevision < w.nextrev {
+ continue
+ } else {
+ // We cannot update w.rev here.
+ // txn can have multiple events with the same rev.
+ // If w.nextrev updates here, it would skip events in the same txn.
+ lastRev = ev.Kv.ModRevision
+ }
+
+ filtered := false
+ for _, filter := range w.filters {
+ if filter(*ev) {
+ filtered = true
+ break
+ }
+ }
+ if filtered {
+ continue
+ }
+
+ if !w.prevKV {
+ evCopy := *ev
+ evCopy.PrevKv = nil
+ ev = &evCopy
+ }
+ events = append(events, ev)
+ }
+
+ if lastRev >= w.nextrev {
+ w.nextrev = lastRev + 1
+ }
+
+ // all events are filtered out?
+ if !wr.IsProgressNotify() && !wr.Created && len(events) == 0 && wr.CompactRevision == 0 {
+ return
+ }
+
+ w.lastHeader = wr.Header
+ w.post(&pb.WatchResponse{
+ Header: &wr.Header,
+ Created: wr.Created,
+ CompactRevision: wr.CompactRevision,
+ WatchId: w.id,
+ Events: events,
+ })
+}
+
+// post puts a watch response on the watcher's proxy stream channel
+func (w *watcher) post(wr *pb.WatchResponse) bool {
+ select {
+ case w.wps.watchCh <- wr:
+ case <-time.After(50 * time.Millisecond):
+ w.wps.cancel()
+ return false
+ }
+ return true
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/httpproxy/director.go b/vendor/github.com/coreos/etcd/proxy/httpproxy/director.go
new file mode 100644
index 00000000..d4145013
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/httpproxy/director.go
@@ -0,0 +1,158 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 httpproxy
+
+import (
+ "math/rand"
+ "net/url"
+ "sync"
+ "time"
+)
+
+// defaultRefreshInterval is the default proxyRefreshIntervalMs value
+// as in etcdmain/config.go.
+const defaultRefreshInterval = 30000 * time.Millisecond
+
+var once sync.Once
+
+func init() {
+ rand.Seed(time.Now().UnixNano())
+}
+
+func newDirector(urlsFunc GetProxyURLs, failureWait time.Duration, refreshInterval time.Duration) *director {
+ d := &director{
+ uf: urlsFunc,
+ failureWait: failureWait,
+ }
+ d.refresh()
+ go func() {
+ // In order to prevent missing proxy endpoints in the first try:
+ // when given refresh interval of defaultRefreshInterval or greater
+ // and whenever there is no available proxy endpoints,
+ // give 1-second refreshInterval.
+ for {
+ es := d.endpoints()
+ ri := refreshInterval
+ if ri >= defaultRefreshInterval {
+ if len(es) == 0 {
+ ri = time.Second
+ }
+ }
+ if len(es) > 0 {
+ once.Do(func() {
+ var sl []string
+ for _, e := range es {
+ sl = append(sl, e.URL.String())
+ }
+ plog.Infof("endpoints found %q", sl)
+ })
+ }
+ time.Sleep(ri)
+ d.refresh()
+ }
+ }()
+ return d
+}
+
+type director struct {
+ sync.Mutex
+ ep []*endpoint
+ uf GetProxyURLs
+ failureWait time.Duration
+}
+
+func (d *director) refresh() {
+ urls := d.uf()
+ d.Lock()
+ defer d.Unlock()
+ var endpoints []*endpoint
+ for _, u := range urls {
+ uu, err := url.Parse(u)
+ if err != nil {
+ plog.Printf("upstream URL invalid: %v", err)
+ continue
+ }
+ endpoints = append(endpoints, newEndpoint(*uu, d.failureWait))
+ }
+
+ // shuffle array to avoid connections being "stuck" to a single endpoint
+ for i := range endpoints {
+ j := rand.Intn(i + 1)
+ endpoints[i], endpoints[j] = endpoints[j], endpoints[i]
+ }
+
+ d.ep = endpoints
+}
+
+func (d *director) endpoints() []*endpoint {
+ d.Lock()
+ defer d.Unlock()
+ filtered := make([]*endpoint, 0)
+ for _, ep := range d.ep {
+ if ep.Available {
+ filtered = append(filtered, ep)
+ }
+ }
+
+ return filtered
+}
+
+func newEndpoint(u url.URL, failureWait time.Duration) *endpoint {
+ ep := endpoint{
+ URL: u,
+ Available: true,
+ failFunc: timedUnavailabilityFunc(failureWait),
+ }
+
+ return &ep
+}
+
+type endpoint struct {
+ sync.Mutex
+
+ URL url.URL
+ Available bool
+
+ failFunc func(ep *endpoint)
+}
+
+func (ep *endpoint) Failed() {
+ ep.Lock()
+ if !ep.Available {
+ ep.Unlock()
+ return
+ }
+
+ ep.Available = false
+ ep.Unlock()
+
+ plog.Printf("marked endpoint %s unavailable", ep.URL.String())
+
+ if ep.failFunc == nil {
+ plog.Printf("no failFunc defined, endpoint %s will be unavailable forever.", ep.URL.String())
+ return
+ }
+
+ ep.failFunc(ep)
+}
+
+func timedUnavailabilityFunc(wait time.Duration) func(*endpoint) {
+ return func(ep *endpoint) {
+ time.AfterFunc(wait, func() {
+ ep.Available = true
+ plog.Printf("marked endpoint %s available, to retest connectivity", ep.URL.String())
+ })
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/httpproxy/director_test.go b/vendor/github.com/coreos/etcd/proxy/httpproxy/director_test.go
new file mode 100644
index 00000000..2227d855
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/httpproxy/director_test.go
@@ -0,0 +1,95 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 httpproxy
+
+import (
+ "net/url"
+ "reflect"
+ "sort"
+ "testing"
+ "time"
+)
+
+func TestNewDirectorScheme(t *testing.T) {
+ tests := []struct {
+ urls []string
+ want []string
+ }{
+ {
+ urls: []string{"http://192.0.2.8:4002", "http://example.com:8080"},
+ want: []string{"http://192.0.2.8:4002", "http://example.com:8080"},
+ },
+ {
+ urls: []string{"https://192.0.2.8:4002", "https://example.com:8080"},
+ want: []string{"https://192.0.2.8:4002", "https://example.com:8080"},
+ },
+
+ // accept urls without a port
+ {
+ urls: []string{"http://192.0.2.8"},
+ want: []string{"http://192.0.2.8"},
+ },
+
+ // accept urls even if they are garbage
+ {
+ urls: []string{"http://."},
+ want: []string{"http://."},
+ },
+ }
+
+ for i, tt := range tests {
+ uf := func() []string {
+ return tt.urls
+ }
+ got := newDirector(uf, time.Minute, time.Minute)
+
+ var gep []string
+ for _, ep := range got.ep {
+ gep = append(gep, ep.URL.String())
+ }
+ sort.Strings(tt.want)
+ sort.Strings(gep)
+ if !reflect.DeepEqual(tt.want, gep) {
+ t.Errorf("#%d: want endpoints = %#v, got = %#v", i, tt.want, gep)
+ }
+ }
+}
+
+func TestDirectorEndpointsFiltering(t *testing.T) {
+ d := director{
+ ep: []*endpoint{
+ {
+ URL: url.URL{Scheme: "http", Host: "192.0.2.5:5050"},
+ Available: false,
+ },
+ {
+ URL: url.URL{Scheme: "http", Host: "192.0.2.4:4000"},
+ Available: true,
+ },
+ },
+ }
+
+ got := d.endpoints()
+ want := []*endpoint{
+ {
+ URL: url.URL{Scheme: "http", Host: "192.0.2.4:4000"},
+ Available: true,
+ },
+ }
+
+ if !reflect.DeepEqual(want, got) {
+ t.Fatalf("directed to incorrect endpoint: want = %#v, got = %#v", want, got)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/httpproxy/doc.go b/vendor/github.com/coreos/etcd/proxy/httpproxy/doc.go
new file mode 100644
index 00000000..7a450991
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/httpproxy/doc.go
@@ -0,0 +1,18 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 httpproxy implements etcd httpproxy. The etcd proxy acts as a reverse
+// http proxy forwarding client requests to active etcd cluster members, and does
+// not participate in consensus.
+package httpproxy
diff --git a/vendor/github.com/coreos/etcd/proxy/httpproxy/metrics.go b/vendor/github.com/coreos/etcd/proxy/httpproxy/metrics.go
new file mode 100644
index 00000000..f71258cb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/httpproxy/metrics.go
@@ -0,0 +1,88 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 httpproxy
+
+import (
+ "net/http"
+ "strconv"
+ "time"
+
+ "github.com/prometheus/client_golang/prometheus"
+)
+
+var (
+ requestsIncoming = prometheus.NewCounterVec(
+ prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "proxy",
+ Name: "requests_total",
+ Help: "Counter requests incoming by method.",
+ }, []string{"method"})
+
+ requestsHandled = prometheus.NewCounterVec(
+ prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "proxy",
+ Name: "handled_total",
+ Help: "Counter of requests fully handled (by authoratitave servers)",
+ }, []string{"method", "code"})
+
+ requestsDropped = prometheus.NewCounterVec(
+ prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "proxy",
+ Name: "dropped_total",
+ Help: "Counter of requests dropped on the proxy.",
+ }, []string{"method", "proxying_error"})
+
+ requestsHandlingTime = prometheus.NewHistogramVec(
+ prometheus.HistogramOpts{
+ Namespace: "etcd",
+ Subsystem: "proxy",
+ Name: "handling_duration_seconds",
+ Help: "Bucketed histogram of handling time of successful events (non-watches), by method " +
+ "(GET/PUT etc.).",
+ Buckets: prometheus.ExponentialBuckets(0.0005, 2, 13),
+ }, []string{"method"})
+)
+
+type forwardingError string
+
+const (
+ zeroEndpoints forwardingError = "zero_endpoints"
+ failedSendingRequest forwardingError = "failed_sending_request"
+ failedGettingResponse forwardingError = "failed_getting_response"
+)
+
+func init() {
+ prometheus.MustRegister(requestsIncoming)
+ prometheus.MustRegister(requestsHandled)
+ prometheus.MustRegister(requestsDropped)
+ prometheus.MustRegister(requestsHandlingTime)
+}
+
+func reportIncomingRequest(request *http.Request) {
+ requestsIncoming.WithLabelValues(request.Method).Inc()
+}
+
+func reportRequestHandled(request *http.Request, response *http.Response, startTime time.Time) {
+ method := request.Method
+ requestsHandled.WithLabelValues(method, strconv.Itoa(response.StatusCode)).Inc()
+ requestsHandlingTime.WithLabelValues(method).Observe(time.Since(startTime).Seconds())
+}
+
+func reportRequestDropped(request *http.Request, err forwardingError) {
+ requestsDropped.WithLabelValues(request.Method, string(err)).Inc()
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/httpproxy/proxy.go b/vendor/github.com/coreos/etcd/proxy/httpproxy/proxy.go
new file mode 100644
index 00000000..3cd3161f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/httpproxy/proxy.go
@@ -0,0 +1,116 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 httpproxy
+
+import (
+ "encoding/json"
+ "net/http"
+ "strings"
+ "time"
+
+ "golang.org/x/net/http2"
+)
+
+const (
+ // DefaultMaxIdleConnsPerHost indicates the default maximum idle connection
+ // count maintained between proxy and each member. We set it to 128 to
+ // let proxy handle 128 concurrent requests in long term smoothly.
+ // If the number of concurrent requests is bigger than this value,
+ // proxy needs to create one new connection when handling each request in
+ // the delta, which is bad because the creation consumes resource and
+ // may eat up ephemeral ports.
+ DefaultMaxIdleConnsPerHost = 128
+)
+
+// GetProxyURLs is a function which should return the current set of URLs to
+// which client requests should be proxied. This function will be queried
+// periodically by the proxy Handler to refresh the set of available
+// backends.
+type GetProxyURLs func() []string
+
+// NewHandler creates a new HTTP handler, listening on the given transport,
+// which will proxy requests to an etcd cluster.
+// The handler will periodically update its view of the cluster.
+func NewHandler(t *http.Transport, urlsFunc GetProxyURLs, failureWait time.Duration, refreshInterval time.Duration) http.Handler {
+ if t.TLSClientConfig != nil {
+ // Enable http2, see Issue 5033.
+ err := http2.ConfigureTransport(t)
+ if err != nil {
+ plog.Infof("Error enabling Transport HTTP/2 support: %v", err)
+ }
+ }
+
+ p := &reverseProxy{
+ director: newDirector(urlsFunc, failureWait, refreshInterval),
+ transport: t,
+ }
+
+ mux := http.NewServeMux()
+ mux.Handle("/", p)
+ mux.HandleFunc("/v2/config/local/proxy", p.configHandler)
+
+ return mux
+}
+
+// NewReadonlyHandler wraps the given HTTP handler to allow only GET requests
+func NewReadonlyHandler(hdlr http.Handler) http.Handler {
+ readonly := readonlyHandlerFunc(hdlr)
+ return http.HandlerFunc(readonly)
+}
+
+func readonlyHandlerFunc(next http.Handler) func(http.ResponseWriter, *http.Request) {
+ return func(w http.ResponseWriter, req *http.Request) {
+ if req.Method != "GET" {
+ w.WriteHeader(http.StatusNotImplemented)
+ return
+ }
+
+ next.ServeHTTP(w, req)
+ }
+}
+
+func (p *reverseProxy) configHandler(w http.ResponseWriter, r *http.Request) {
+ if !allowMethod(w, r.Method, "GET") {
+ return
+ }
+
+ eps := p.director.endpoints()
+ epstr := make([]string, len(eps))
+ for i, e := range eps {
+ epstr[i] = e.URL.String()
+ }
+
+ proxyConfig := struct {
+ Endpoints []string `json:"endpoints"`
+ }{
+ Endpoints: epstr,
+ }
+
+ json.NewEncoder(w).Encode(proxyConfig)
+}
+
+// allowMethod verifies that the given method is one of the allowed methods,
+// and if not, it writes an error to w. A boolean is returned indicating
+// whether or not the method is allowed.
+func allowMethod(w http.ResponseWriter, m string, ms ...string) bool {
+ for _, meth := range ms {
+ if m == meth {
+ return true
+ }
+ }
+ w.Header().Set("Allow", strings.Join(ms, ","))
+ http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
+ return false
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/httpproxy/proxy_test.go b/vendor/github.com/coreos/etcd/proxy/httpproxy/proxy_test.go
new file mode 100644
index 00000000..9209e1a6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/httpproxy/proxy_test.go
@@ -0,0 +1,98 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 httpproxy
+
+import (
+ "io/ioutil"
+ "net/http"
+ "net/http/httptest"
+ "net/url"
+ "testing"
+ "time"
+)
+
+func TestReadonlyHandler(t *testing.T) {
+ fixture := func(w http.ResponseWriter, req *http.Request) {
+ w.WriteHeader(http.StatusOK)
+ }
+ hdlrFunc := readonlyHandlerFunc(http.HandlerFunc(fixture))
+
+ tests := []struct {
+ method string
+ want int
+ }{
+ // GET is only passing method
+ {"GET", http.StatusOK},
+
+ // everything but GET is StatusNotImplemented
+ {"POST", http.StatusNotImplemented},
+ {"PUT", http.StatusNotImplemented},
+ {"PATCH", http.StatusNotImplemented},
+ {"DELETE", http.StatusNotImplemented},
+ {"FOO", http.StatusNotImplemented},
+ }
+
+ for i, tt := range tests {
+ req, _ := http.NewRequest(tt.method, "http://example.com", nil)
+ rr := httptest.NewRecorder()
+ hdlrFunc(rr, req)
+
+ if tt.want != rr.Code {
+ t.Errorf("#%d: incorrect HTTP status code: method=%s want=%d got=%d", i, tt.method, tt.want, rr.Code)
+ }
+ }
+}
+
+func TestConfigHandlerGET(t *testing.T) {
+ var err error
+ us := make([]*url.URL, 3)
+ us[0], err = url.Parse("http://example1.com")
+ if err != nil {
+ t.Fatal(err)
+ }
+ us[1], err = url.Parse("http://example2.com")
+ if err != nil {
+ t.Fatal(err)
+ }
+ us[2], err = url.Parse("http://example3.com")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ rp := reverseProxy{
+ director: &director{
+ ep: []*endpoint{
+ newEndpoint(*us[0], 1*time.Second),
+ newEndpoint(*us[1], 1*time.Second),
+ newEndpoint(*us[2], 1*time.Second),
+ },
+ },
+ }
+
+ req, _ := http.NewRequest("GET", "http://example.com//v2/config/local/proxy", nil)
+ rr := httptest.NewRecorder()
+ rp.configHandler(rr, req)
+
+ wbody := "{\"endpoints\":[\"http://example1.com\",\"http://example2.com\",\"http://example3.com\"]}\n"
+
+ body, err := ioutil.ReadAll(rr.Body)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if string(body) != wbody {
+ t.Errorf("body = %s, want %s", string(body), wbody)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/httpproxy/reverse.go b/vendor/github.com/coreos/etcd/proxy/httpproxy/reverse.go
new file mode 100644
index 00000000..fbde812c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/httpproxy/reverse.go
@@ -0,0 +1,207 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 httpproxy
+
+import (
+ "bytes"
+ "context"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "net"
+ "net/http"
+ "net/url"
+ "strings"
+ "sync/atomic"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/api/v2http/httptypes"
+ "github.com/coreos/pkg/capnslog"
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "proxy/httpproxy")
+
+ // Hop-by-hop headers. These are removed when sent to the backend.
+ // http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
+ // This list of headers borrowed from stdlib httputil.ReverseProxy
+ singleHopHeaders = []string{
+ "Connection",
+ "Keep-Alive",
+ "Proxy-Authenticate",
+ "Proxy-Authorization",
+ "Te", // canonicalized version of "TE"
+ "Trailers",
+ "Transfer-Encoding",
+ "Upgrade",
+ }
+)
+
+func removeSingleHopHeaders(hdrs *http.Header) {
+ for _, h := range singleHopHeaders {
+ hdrs.Del(h)
+ }
+}
+
+type reverseProxy struct {
+ director *director
+ transport http.RoundTripper
+}
+
+func (p *reverseProxy) ServeHTTP(rw http.ResponseWriter, clientreq *http.Request) {
+ reportIncomingRequest(clientreq)
+ proxyreq := new(http.Request)
+ *proxyreq = *clientreq
+ startTime := time.Now()
+
+ var (
+ proxybody []byte
+ err error
+ )
+
+ if clientreq.Body != nil {
+ proxybody, err = ioutil.ReadAll(clientreq.Body)
+ if err != nil {
+ msg := fmt.Sprintf("failed to read request body: %v", err)
+ plog.Println(msg)
+ e := httptypes.NewHTTPError(http.StatusInternalServerError, "httpproxy: "+msg)
+ if we := e.WriteTo(rw); we != nil {
+ plog.Debugf("error writing HTTPError (%v) to %s", we, clientreq.RemoteAddr)
+ }
+ return
+ }
+ }
+
+ // deep-copy the headers, as these will be modified below
+ proxyreq.Header = make(http.Header)
+ copyHeader(proxyreq.Header, clientreq.Header)
+
+ normalizeRequest(proxyreq)
+ removeSingleHopHeaders(&proxyreq.Header)
+ maybeSetForwardedFor(proxyreq)
+
+ endpoints := p.director.endpoints()
+ if len(endpoints) == 0 {
+ msg := "zero endpoints currently available"
+ reportRequestDropped(clientreq, zeroEndpoints)
+
+ // TODO: limit the rate of the error logging.
+ plog.Println(msg)
+ e := httptypes.NewHTTPError(http.StatusServiceUnavailable, "httpproxy: "+msg)
+ if we := e.WriteTo(rw); we != nil {
+ plog.Debugf("error writing HTTPError (%v) to %s", we, clientreq.RemoteAddr)
+ }
+ return
+ }
+
+ var requestClosed int32
+ completeCh := make(chan bool, 1)
+ closeNotifier, ok := rw.(http.CloseNotifier)
+ ctx, cancel := context.WithCancel(context.Background())
+ proxyreq = proxyreq.WithContext(ctx)
+ defer cancel()
+ if ok {
+ closeCh := closeNotifier.CloseNotify()
+ go func() {
+ select {
+ case <-closeCh:
+ atomic.StoreInt32(&requestClosed, 1)
+ plog.Printf("client %v closed request prematurely", clientreq.RemoteAddr)
+ case <-completeCh:
+ }
+ }()
+
+ defer func() {
+ completeCh <- true
+ }()
+ }
+
+ var res *http.Response
+
+ for _, ep := range endpoints {
+ if proxybody != nil {
+ proxyreq.Body = ioutil.NopCloser(bytes.NewBuffer(proxybody))
+ }
+ redirectRequest(proxyreq, ep.URL)
+
+ res, err = p.transport.RoundTrip(proxyreq)
+ if atomic.LoadInt32(&requestClosed) == 1 {
+ return
+ }
+ if err != nil {
+ reportRequestDropped(clientreq, failedSendingRequest)
+ plog.Printf("failed to direct request to %s: %v", ep.URL.String(), err)
+ ep.Failed()
+ continue
+ }
+
+ break
+ }
+
+ if res == nil {
+ // TODO: limit the rate of the error logging.
+ msg := fmt.Sprintf("unable to get response from %d endpoint(s)", len(endpoints))
+ reportRequestDropped(clientreq, failedGettingResponse)
+ plog.Println(msg)
+ e := httptypes.NewHTTPError(http.StatusBadGateway, "httpproxy: "+msg)
+ if we := e.WriteTo(rw); we != nil {
+ plog.Debugf("error writing HTTPError (%v) to %s", we, clientreq.RemoteAddr)
+ }
+ return
+ }
+
+ defer res.Body.Close()
+ reportRequestHandled(clientreq, res, startTime)
+ removeSingleHopHeaders(&res.Header)
+ copyHeader(rw.Header(), res.Header)
+
+ rw.WriteHeader(res.StatusCode)
+ io.Copy(rw, res.Body)
+}
+
+func copyHeader(dst, src http.Header) {
+ for k, vv := range src {
+ for _, v := range vv {
+ dst.Add(k, v)
+ }
+ }
+}
+
+func redirectRequest(req *http.Request, loc url.URL) {
+ req.URL.Scheme = loc.Scheme
+ req.URL.Host = loc.Host
+}
+
+func normalizeRequest(req *http.Request) {
+ req.Proto = "HTTP/1.1"
+ req.ProtoMajor = 1
+ req.ProtoMinor = 1
+ req.Close = false
+}
+
+func maybeSetForwardedFor(req *http.Request) {
+ clientIP, _, err := net.SplitHostPort(req.RemoteAddr)
+ if err != nil {
+ return
+ }
+
+ // If we aren't the first proxy retain prior
+ // X-Forwarded-For information as a comma+space
+ // separated list and fold multiple headers into one.
+ if prior, ok := req.Header["X-Forwarded-For"]; ok {
+ clientIP = strings.Join(prior, ", ") + ", " + clientIP
+ }
+ req.Header.Set("X-Forwarded-For", clientIP)
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/httpproxy/reverse_test.go b/vendor/github.com/coreos/etcd/proxy/httpproxy/reverse_test.go
new file mode 100644
index 00000000..284b6811
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/httpproxy/reverse_test.go
@@ -0,0 +1,245 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 httpproxy
+
+import (
+ "bytes"
+ "errors"
+ "io/ioutil"
+ "net/http"
+ "net/http/httptest"
+ "net/url"
+ "reflect"
+ "testing"
+)
+
+type staticRoundTripper struct {
+ res *http.Response
+ err error
+}
+
+func (srt *staticRoundTripper) RoundTrip(*http.Request) (*http.Response, error) {
+ return srt.res, srt.err
+}
+
+func TestReverseProxyServe(t *testing.T) {
+ u := url.URL{Scheme: "http", Host: "192.0.2.3:4040"}
+
+ tests := []struct {
+ eps []*endpoint
+ rt http.RoundTripper
+ want int
+ }{
+ // no endpoints available so no requests are even made
+ {
+ eps: []*endpoint{},
+ rt: &staticRoundTripper{
+ res: &http.Response{
+ StatusCode: http.StatusCreated,
+ Body: ioutil.NopCloser(&bytes.Reader{}),
+ },
+ },
+ want: http.StatusServiceUnavailable,
+ },
+
+ // error is returned from one endpoint that should be available
+ {
+ eps: []*endpoint{{URL: u, Available: true}},
+ rt: &staticRoundTripper{err: errors.New("what a bad trip")},
+ want: http.StatusBadGateway,
+ },
+
+ // endpoint is available and returns success
+ {
+ eps: []*endpoint{{URL: u, Available: true}},
+ rt: &staticRoundTripper{
+ res: &http.Response{
+ StatusCode: http.StatusCreated,
+ Body: ioutil.NopCloser(&bytes.Reader{}),
+ Header: map[string][]string{"Content-Type": {"application/json"}},
+ },
+ },
+ want: http.StatusCreated,
+ },
+ }
+
+ for i, tt := range tests {
+ rp := reverseProxy{
+ director: &director{ep: tt.eps},
+ transport: tt.rt,
+ }
+
+ req, _ := http.NewRequest("GET", "http://192.0.2.2:2379", nil)
+ rr := httptest.NewRecorder()
+ rp.ServeHTTP(rr, req)
+
+ if rr.Code != tt.want {
+ t.Errorf("#%d: unexpected HTTP status code: want = %d, got = %d", i, tt.want, rr.Code)
+ }
+ if gct := rr.Header().Get("Content-Type"); gct != "application/json" {
+ t.Errorf("#%d: Content-Type = %s, want %s", i, gct, "application/json")
+ }
+ }
+}
+
+func TestRedirectRequest(t *testing.T) {
+ loc := url.URL{
+ Scheme: "http",
+ Host: "bar.example.com",
+ }
+
+ req := &http.Request{
+ Method: "GET",
+ Host: "foo.example.com",
+ URL: &url.URL{
+ Host: "foo.example.com",
+ Path: "/v2/keys/baz",
+ },
+ }
+
+ redirectRequest(req, loc)
+
+ want := &http.Request{
+ Method: "GET",
+ // this field must not change
+ Host: "foo.example.com",
+ URL: &url.URL{
+ // the Scheme field is updated to that of the provided URL
+ Scheme: "http",
+ // the Host field is updated to that of the provided URL
+ Host: "bar.example.com",
+ Path: "/v2/keys/baz",
+ },
+ }
+
+ if !reflect.DeepEqual(want, req) {
+ t.Fatalf("HTTP request does not match expected criteria: want=%#v got=%#v", want, req)
+ }
+}
+
+func TestMaybeSetForwardedFor(t *testing.T) {
+ tests := []struct {
+ raddr string
+ fwdFor string
+ want string
+ }{
+ {"192.0.2.3:8002", "", "192.0.2.3"},
+ {"192.0.2.3:8002", "192.0.2.2", "192.0.2.2, 192.0.2.3"},
+ {"192.0.2.3:8002", "192.0.2.1, 192.0.2.2", "192.0.2.1, 192.0.2.2, 192.0.2.3"},
+ {"example.com:8002", "", "example.com"},
+
+ // While these cases look valid, golang net/http will not let it happen
+ // The RemoteAddr field will always be a valid host:port
+ {":8002", "", ""},
+ {"192.0.2.3", "", ""},
+
+ // blatantly invalid host w/o a port
+ {"12", "", ""},
+ {"12", "192.0.2.3", "192.0.2.3"},
+ }
+
+ for i, tt := range tests {
+ req := &http.Request{
+ RemoteAddr: tt.raddr,
+ Header: make(http.Header),
+ }
+
+ if tt.fwdFor != "" {
+ req.Header.Set("X-Forwarded-For", tt.fwdFor)
+ }
+
+ maybeSetForwardedFor(req)
+ got := req.Header.Get("X-Forwarded-For")
+ if tt.want != got {
+ t.Errorf("#%d: incorrect header: want = %q, got = %q", i, tt.want, got)
+ }
+ }
+}
+
+func TestRemoveSingleHopHeaders(t *testing.T) {
+ hdr := http.Header(map[string][]string{
+ // single-hop headers that should be removed
+ "Connection": {"close"},
+ "Keep-Alive": {"foo"},
+ "Proxy-Authenticate": {"Basic realm=example.com"},
+ "Proxy-Authorization": {"foo"},
+ "Te": {"deflate,gzip"},
+ "Trailers": {"ETag"},
+ "Transfer-Encoding": {"chunked"},
+ "Upgrade": {"WebSocket"},
+
+ // headers that should persist
+ "Accept": {"application/json"},
+ "X-Foo": {"Bar"},
+ })
+
+ removeSingleHopHeaders(&hdr)
+
+ want := http.Header(map[string][]string{
+ "Accept": {"application/json"},
+ "X-Foo": {"Bar"},
+ })
+
+ if !reflect.DeepEqual(want, hdr) {
+ t.Fatalf("unexpected result: want = %#v, got = %#v", want, hdr)
+ }
+}
+
+func TestCopyHeader(t *testing.T) {
+ tests := []struct {
+ src http.Header
+ dst http.Header
+ want http.Header
+ }{
+ {
+ src: http.Header(map[string][]string{
+ "Foo": {"bar", "baz"},
+ }),
+ dst: http.Header(map[string][]string{}),
+ want: http.Header(map[string][]string{
+ "Foo": {"bar", "baz"},
+ }),
+ },
+ {
+ src: http.Header(map[string][]string{
+ "Foo": {"bar"},
+ "Ping": {"pong"},
+ }),
+ dst: http.Header(map[string][]string{}),
+ want: http.Header(map[string][]string{
+ "Foo": {"bar"},
+ "Ping": {"pong"},
+ }),
+ },
+ {
+ src: http.Header(map[string][]string{
+ "Foo": {"bar", "baz"},
+ }),
+ dst: http.Header(map[string][]string{
+ "Foo": {"qux"},
+ }),
+ want: http.Header(map[string][]string{
+ "Foo": {"qux", "bar", "baz"},
+ }),
+ },
+ }
+
+ for i, tt := range tests {
+ copyHeader(tt.dst, tt.src)
+ if !reflect.DeepEqual(tt.dst, tt.want) {
+ t.Errorf("#%d: unexpected headers: want = %v, got = %v", i, tt.want, tt.dst)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/tcpproxy/doc.go b/vendor/github.com/coreos/etcd/proxy/tcpproxy/doc.go
new file mode 100644
index 00000000..6889cacb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/tcpproxy/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 tcpproxy is an OSI level 4 proxy for routing etcd clients to etcd servers.
+package tcpproxy
diff --git a/vendor/github.com/coreos/etcd/proxy/tcpproxy/userspace.go b/vendor/github.com/coreos/etcd/proxy/tcpproxy/userspace.go
new file mode 100644
index 00000000..807e76a3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/tcpproxy/userspace.go
@@ -0,0 +1,226 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 tcpproxy
+
+import (
+ "fmt"
+ "io"
+ "math/rand"
+ "net"
+ "sync"
+ "time"
+
+ "github.com/coreos/pkg/capnslog"
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "proxy/tcpproxy")
+)
+
+type remote struct {
+ mu sync.Mutex
+ srv *net.SRV
+ addr string
+ inactive bool
+}
+
+func (r *remote) inactivate() {
+ r.mu.Lock()
+ defer r.mu.Unlock()
+ r.inactive = true
+}
+
+func (r *remote) tryReactivate() error {
+ conn, err := net.Dial("tcp", r.addr)
+ if err != nil {
+ return err
+ }
+ conn.Close()
+ r.mu.Lock()
+ defer r.mu.Unlock()
+ r.inactive = false
+ return nil
+}
+
+func (r *remote) isActive() bool {
+ r.mu.Lock()
+ defer r.mu.Unlock()
+ return !r.inactive
+}
+
+type TCPProxy struct {
+ Listener net.Listener
+ Endpoints []*net.SRV
+ MonitorInterval time.Duration
+
+ donec chan struct{}
+
+ mu sync.Mutex // guards the following fields
+ remotes []*remote
+ pickCount int // for round robin
+}
+
+func (tp *TCPProxy) Run() error {
+ tp.donec = make(chan struct{})
+ if tp.MonitorInterval == 0 {
+ tp.MonitorInterval = 5 * time.Minute
+ }
+ for _, srv := range tp.Endpoints {
+ addr := fmt.Sprintf("%s:%d", srv.Target, srv.Port)
+ tp.remotes = append(tp.remotes, &remote{srv: srv, addr: addr})
+ }
+
+ eps := []string{}
+ for _, ep := range tp.Endpoints {
+ eps = append(eps, fmt.Sprintf("%s:%d", ep.Target, ep.Port))
+ }
+ plog.Printf("ready to proxy client requests to %+v", eps)
+
+ go tp.runMonitor()
+ for {
+ in, err := tp.Listener.Accept()
+ if err != nil {
+ return err
+ }
+
+ go tp.serve(in)
+ }
+}
+
+func (tp *TCPProxy) pick() *remote {
+ var weighted []*remote
+ var unweighted []*remote
+
+ bestPr := uint16(65535)
+ w := 0
+ // find best priority class
+ for _, r := range tp.remotes {
+ switch {
+ case !r.isActive():
+ case r.srv.Priority < bestPr:
+ bestPr = r.srv.Priority
+ w = 0
+ weighted, unweighted = nil, nil
+ unweighted = []*remote{r}
+ fallthrough
+ case r.srv.Priority == bestPr:
+ if r.srv.Weight > 0 {
+ weighted = append(weighted, r)
+ w += int(r.srv.Weight)
+ } else {
+ unweighted = append(unweighted, r)
+ }
+ }
+ }
+ if weighted != nil {
+ if len(unweighted) > 0 && rand.Intn(100) == 1 {
+ // In the presence of records containing weights greater
+ // than 0, records with weight 0 should have a very small
+ // chance of being selected.
+ r := unweighted[tp.pickCount%len(unweighted)]
+ tp.pickCount++
+ return r
+ }
+ // choose a uniform random number between 0 and the sum computed
+ // (inclusive), and select the RR whose running sum value is the
+ // first in the selected order
+ choose := rand.Intn(w)
+ for i := 0; i < len(weighted); i++ {
+ choose -= int(weighted[i].srv.Weight)
+ if choose <= 0 {
+ return weighted[i]
+ }
+ }
+ }
+ if unweighted != nil {
+ for i := 0; i < len(tp.remotes); i++ {
+ picked := tp.remotes[tp.pickCount%len(tp.remotes)]
+ tp.pickCount++
+ if picked.isActive() {
+ return picked
+ }
+ }
+ }
+ return nil
+}
+
+func (tp *TCPProxy) serve(in net.Conn) {
+ var (
+ err error
+ out net.Conn
+ )
+
+ for {
+ tp.mu.Lock()
+ remote := tp.pick()
+ tp.mu.Unlock()
+ if remote == nil {
+ break
+ }
+ // TODO: add timeout
+ out, err = net.Dial("tcp", remote.addr)
+ if err == nil {
+ break
+ }
+ remote.inactivate()
+ plog.Warningf("deactivated endpoint [%s] due to %v for %v", remote.addr, err, tp.MonitorInterval)
+ }
+
+ if out == nil {
+ in.Close()
+ return
+ }
+
+ go func() {
+ io.Copy(in, out)
+ in.Close()
+ out.Close()
+ }()
+
+ io.Copy(out, in)
+ out.Close()
+ in.Close()
+}
+
+func (tp *TCPProxy) runMonitor() {
+ for {
+ select {
+ case <-time.After(tp.MonitorInterval):
+ tp.mu.Lock()
+ for _, rem := range tp.remotes {
+ if rem.isActive() {
+ continue
+ }
+ go func(r *remote) {
+ if err := r.tryReactivate(); err != nil {
+ plog.Warningf("failed to activate endpoint [%s] due to %v (stay inactive for another %v)", r.addr, err, tp.MonitorInterval)
+ } else {
+ plog.Printf("activated %s", r.addr)
+ }
+ }(rem)
+ }
+ tp.mu.Unlock()
+ case <-tp.donec:
+ return
+ }
+ }
+}
+
+func (tp *TCPProxy) Stop() {
+ // graceful shutdown?
+ // shutdown current connections?
+ tp.Listener.Close()
+ close(tp.donec)
+}
diff --git a/vendor/github.com/coreos/etcd/proxy/tcpproxy/userspace_test.go b/vendor/github.com/coreos/etcd/proxy/tcpproxy/userspace_test.go
new file mode 100644
index 00000000..bf65f570
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/proxy/tcpproxy/userspace_test.go
@@ -0,0 +1,69 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 tcpproxy
+
+import (
+ "fmt"
+ "io/ioutil"
+ "net"
+ "net/http"
+ "net/http/httptest"
+ "net/url"
+ "testing"
+)
+
+func TestUserspaceProxy(t *testing.T) {
+ l, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer l.Close()
+
+ want := "hello proxy"
+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ fmt.Fprint(w, want)
+ }))
+ defer ts.Close()
+
+ u, err := url.Parse(ts.URL)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ var port uint16
+ fmt.Sscanf(u.Port(), "%d", &port)
+ p := TCPProxy{
+ Listener: l,
+ Endpoints: []*net.SRV{{Target: u.Hostname(), Port: port}},
+ }
+ go p.Run()
+ defer p.Stop()
+
+ u.Host = l.Addr().String()
+
+ res, err := http.Get(u.String())
+ if err != nil {
+ t.Fatal(err)
+ }
+ got, gerr := ioutil.ReadAll(res.Body)
+ res.Body.Close()
+ if gerr != nil {
+ t.Fatal(gerr)
+ }
+
+ if string(got) != want {
+ t.Errorf("got = %s, want %s", got, want)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/raft/README.md b/vendor/github.com/coreos/etcd/raft/README.md
new file mode 100644
index 00000000..f485b839
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/README.md
@@ -0,0 +1,196 @@
+# Raft library
+
+Raft is a protocol with which a cluster of nodes can maintain a replicated state machine.
+The state machine is kept in sync through the use of a replicated log.
+For more details on Raft, see "In Search of an Understandable Consensus Algorithm"
+(https://ramcloud.stanford.edu/raft.pdf) by Diego Ongaro and John Ousterhout.
+
+This Raft library is stable and feature complete. As of 2016, it is **the most widely used** Raft library in production, serving tens of thousands clusters each day. It powers distributed systems such as etcd, Kubernetes, Docker Swarm, Cloud Foundry Diego, CockroachDB, TiDB, Project Calico, Flannel, and more.
+
+Most Raft implementations have a monolithic design, including storage handling, messaging serialization, and network transport. This library instead follows a minimalistic design philosophy by only implementing the core raft algorithm. This minimalism buys flexibility, determinism, and performance.
+
+To keep the codebase small as well as provide flexibility, the library only implements the Raft algorithm; both network and disk IO are left to the user. Library users must implement their own transportation layer for message passing between Raft peers over the wire. Similarly, users must implement their own storage layer to persist the Raft log and state.
+
+In order to easily test the Raft library, its behavior should be deterministic. To achieve this determinism, the library models Raft as a state machine. The state machine takes a `Message` as input. A message can either be a local timer update or a network message sent from a remote peer. The state machine's output is a 3-tuple `{[]Messages, []LogEntries, NextState}` consisting of an array of `Messages`, `log entries`, and `Raft state changes`. For state machines with the same state, the same state machine input should always generate the same state machine output.
+
+A simple example application, _raftexample_, is also available to help illustrate how to use this package in practice: https://github.com/coreos/etcd/tree/master/contrib/raftexample
+
+# Features
+
+This raft implementation is a full feature implementation of Raft protocol. Features includes:
+
+- Leader election
+- Log replication
+- Log compaction
+- Membership changes
+- Leadership transfer extension
+- Efficient linearizable read-only queries served by both the leader and followers
+ - leader checks with quorum and bypasses Raft log before processing read-only queries
+ - followers asks leader to get a safe read index before processing read-only queries
+- More efficient lease-based linearizable read-only queries served by both the leader and followers
+ - leader bypasses Raft log and processing read-only queries locally
+ - followers asks leader to get a safe read index before processing read-only queries
+ - this approach relies on the clock of the all the machines in raft group
+
+This raft implementation also includes a few optional enhancements:
+
+- Optimistic pipelining to reduce log replication latency
+- Flow control for log replication
+- Batching Raft messages to reduce synchronized network I/O calls
+- Batching log entries to reduce disk synchronized I/O
+- Writing to leader's disk in parallel
+- Internal proposal redirection from followers to leader
+- Automatic stepping down when the leader loses quorum
+
+## Notable Users
+
+- [cockroachdb](https://github.com/cockroachdb/cockroach) A Scalable, Survivable, Strongly-Consistent SQL Database
+- [dgraph](https://github.com/dgraph-io/dgraph) A Scalable, Distributed, Low Latency, High Throughput Graph Database
+- [etcd](https://github.com/coreos/etcd) A distributed reliable key-value store
+- [tikv](https://github.com/pingcap/tikv) A Distributed transactional key value database powered by Rust and Raft
+- [swarmkit](https://github.com/docker/swarmkit) A toolkit for orchestrating distributed systems at any scale.
+- [chain core](https://github.com/chain/chain) Software for operating permissioned, multi-asset blockchain networks
+
+## Usage
+
+The primary object in raft is a Node. Either start a Node from scratch using raft.StartNode or start a Node from some initial state using raft.RestartNode.
+
+To start a three-node cluster
+```go
+ storage := raft.NewMemoryStorage()
+ c := &Config{
+ ID: 0x01,
+ ElectionTick: 10,
+ HeartbeatTick: 1,
+ Storage: storage,
+ MaxSizePerMsg: 4096,
+ MaxInflightMsgs: 256,
+ }
+ // Set peer list to the other nodes in the cluster.
+ // Note that they need to be started separately as well.
+ n := raft.StartNode(c, []raft.Peer{{ID: 0x02}, {ID: 0x03}})
+```
+
+Start a single node cluster, like so:
+```go
+ // Create storage and config as shown above.
+ // Set peer list to itself, so this node can become the leader of this single-node cluster.
+ peers := []raft.Peer{{ID: 0x01}}
+ n := raft.StartNode(c, peers)
+```
+
+To allow a new node to join this cluster, do not pass in any peers. First, add the node to the existing cluster by calling `ProposeConfChange` on any existing node inside the cluster. Then, start the node with an empty peer list, like so:
+```go
+ // Create storage and config as shown above.
+ n := raft.StartNode(c, nil)
+```
+
+To restart a node from previous state:
+```go
+ storage := raft.NewMemoryStorage()
+
+ // Recover the in-memory storage from persistent snapshot, state and entries.
+ storage.ApplySnapshot(snapshot)
+ storage.SetHardState(state)
+ storage.Append(entries)
+
+ c := &Config{
+ ID: 0x01,
+ ElectionTick: 10,
+ HeartbeatTick: 1,
+ Storage: storage,
+ MaxSizePerMsg: 4096,
+ MaxInflightMsgs: 256,
+ }
+
+ // Restart raft without peer information.
+ // Peer information is already included in the storage.
+ n := raft.RestartNode(c)
+```
+
+After creating a Node, the user has a few responsibilities:
+
+First, read from the Node.Ready() channel and process the updates it contains. These steps may be performed in parallel, except as noted in step 2.
+
+1. Write HardState, Entries, and Snapshot to persistent storage if they are not empty. Note that when writing an Entry with Index i, any previously-persisted entries with Index >= i must be discarded.
+
+2. Send all Messages to the nodes named in the To field. It is important that no messages be sent until the latest HardState has been persisted to disk, and all Entries written by any previous Ready batch (Messages may be sent while entries from the same batch are being persisted). To reduce the I/O latency, an optimization can be applied to make leader write to disk in parallel with its followers (as explained at section 10.2.1 in Raft thesis). If any Message has type MsgSnap, call Node.ReportSnapshot() after it has been sent (these messages may be large). Note: Marshalling messages is not thread-safe; it is important to make sure that no new entries are persisted while marshalling. The easiest way to achieve this is to serialise the messages directly inside the main raft loop.
+
+3. Apply Snapshot (if any) and CommittedEntries to the state machine. If any committed Entry has Type EntryConfChange, call Node.ApplyConfChange() to apply it to the node. The configuration change may be cancelled at this point by setting the NodeID field to zero before calling ApplyConfChange (but ApplyConfChange must be called one way or the other, and the decision to cancel must be based solely on the state machine and not external information such as the observed health of the node).
+
+4. Call Node.Advance() to signal readiness for the next batch of updates. This may be done at any time after step 1, although all updates must be processed in the order they were returned by Ready.
+
+Second, all persisted log entries must be made available via an implementation of the Storage interface. The provided MemoryStorage type can be used for this (if repopulating its state upon a restart), or a custom disk-backed implementation can be supplied.
+
+Third, after receiving a message from another node, pass it to Node.Step:
+
+```go
+ func recvRaftRPC(ctx context.Context, m raftpb.Message) {
+ n.Step(ctx, m)
+ }
+```
+
+Finally, call `Node.Tick()` at regular intervals (probably via a `time.Ticker`). Raft has two important timeouts: heartbeat and the election timeout. However, internally to the raft package time is represented by an abstract "tick".
+
+The total state machine handling loop will look something like this:
+
+```go
+ for {
+ select {
+ case <-s.Ticker:
+ n.Tick()
+ case rd := <-s.Node.Ready():
+ saveToStorage(rd.State, rd.Entries, rd.Snapshot)
+ send(rd.Messages)
+ if !raft.IsEmptySnap(rd.Snapshot) {
+ processSnapshot(rd.Snapshot)
+ }
+ for _, entry := range rd.CommittedEntries {
+ process(entry)
+ if entry.Type == raftpb.EntryConfChange {
+ var cc raftpb.ConfChange
+ cc.Unmarshal(entry.Data)
+ s.Node.ApplyConfChange(cc)
+ }
+ }
+ s.Node.Advance()
+ case <-s.done:
+ return
+ }
+ }
+```
+
+To propose changes to the state machine from the node to take application data, serialize it into a byte slice and call:
+
+```go
+ n.Propose(ctx, data)
+```
+
+If the proposal is committed, data will appear in committed entries with type raftpb.EntryNormal. There is no guarantee that a proposed command will be committed; the command may have to be reproposed after a timeout.
+
+To add or remove node in a cluster, build ConfChange struct 'cc' and call:
+
+```go
+ n.ProposeConfChange(ctx, cc)
+```
+
+After config change is committed, some committed entry with type raftpb.EntryConfChange will be returned. This must be applied to node through:
+
+```go
+ var cc raftpb.ConfChange
+ cc.Unmarshal(data)
+ n.ApplyConfChange(cc)
+```
+
+Note: An ID represents a unique node in a cluster for all time. A
+given ID MUST be used only once even if the old node has been removed.
+This means that for example IP addresses make poor node IDs since they
+may be reused. Node IDs must be non-zero.
+
+## Implementation notes
+
+This implementation is up to date with the final Raft thesis (https://ramcloud.stanford.edu/~ongaro/thesis.pdf), although this implementation of the membership change protocol differs somewhat from that described in chapter 4. The key invariant that membership changes happen one node at a time is preserved, but in our implementation the membership change takes effect when its entry is applied, not when it is added to the log (so the entry is committed under the old membership instead of the new). This is equivalent in terms of safety, since the old and new configurations are guaranteed to overlap.
+
+To ensure there is no attempt to commit two membership changes at once by matching log positions (which would be unsafe since they should have different quorum requirements), any proposed membership change is simply disallowed while any uncommitted change appears in the leader's log.
+
+This approach introduces a problem when removing a member from a two-member cluster: If one of the members dies before the other one receives the commit of the confchange entry, then the member cannot be removed any more since the cluster cannot make progress. For this reason it is highly recommended to use three or more nodes in every cluster.
diff --git a/vendor/github.com/coreos/etcd/raft/design.md b/vendor/github.com/coreos/etcd/raft/design.md
new file mode 100644
index 00000000..7bc0531d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/design.md
@@ -0,0 +1,57 @@
+## Progress
+
+Progress represents a follower?s progress in the view of the leader. Leader maintains progresses of all followers, and sends `replication message` to the follower based on its progress.
+
+`replication message` is a `msgApp` with log entries.
+
+A progress has two attribute: `match` and `next`. `match` is the index of the highest known matched entry. If leader knows nothing about follower?s replication status, `match` is set to zero. `next` is the index of the first entry that will be replicated to the follower. Leader puts entries from `next` to its latest one in next `replication message`.
+
+A progress is in one of the three state: `probe`, `replicate`, `snapshot`.
+
+```
+ +--------------------------------------------------------+
+ | send snapshot |
+ | |
+ +---------+----------+ +----------v---------+
+ +---> probe | | snapshot |
+ | | max inflight = 1 <----------------------------------+ max inflight = 0 |
+ | +---------+----------+ +--------------------+
+ | | 1. snapshot success
+ | | (next=snapshot.index + 1)
+ | | 2. snapshot failure
+ | | (no change)
+ | | 3. receives msgAppResp(rej=false&&index>lastsnap.index)
+ | | (match=m.index,next=match+1)
+receives msgAppResp(rej=true)
+(next=match+1)| |
+ | |
+ | |
+ | | receives msgAppResp(rej=false&&index>match)
+ | | (match=m.index,next=match+1)
+ | |
+ | |
+ | |
+ | +---------v----------+
+ | | replicate |
+ +---+ max inflight = n |
+ +--------------------+
+```
+
+When the progress of a follower is in `probe` state, leader sends at most one `replication message` per heartbeat interval. The leader sends `replication message` slowly and probing the actual progress of the follower. A `msgHeartbeatResp` or a `msgAppResp` with reject might trigger the sending of the next `replication message`.
+
+When the progress of a follower is in `replicate` state, leader sends `replication message`, then optimistically increases `next` to the latest entry sent. This is an optimized state for fast replicating log entries to the follower.
+
+When the progress of a follower is in `snapshot` state, leader stops sending any `replication message`.
+
+A newly elected leader sets the progresses of all the followers to `probe` state with `match` = 0 and `next` = last index. The leader slowly (at most once per heartbeat) sends `replication message` to the follower and probes its progress.
+
+A progress changes to `replicate` when the follower replies with a non-rejection `msgAppResp`, which implies that it has matched the index sent. At this point, leader starts to stream log entries to the follower fast. The progress will fall back to `probe` when the follower replies a rejection `msgAppResp` or the link layer reports the follower is unreachable. We aggressively reset `next` to `match`+1 since if we receive any `msgAppResp` soon, both `match` and `next` will increase directly to the `index` in `msgAppResp`. (We might end up with sending some duplicate entries when aggressively reset `next` too low. see open question)
+
+A progress changes from `probe` to `snapshot` when the follower falls very far behind and requires a snapshot. After sending `msgSnap`, the leader waits until the success, failure or abortion of the previous snapshot sent. The progress will go back to `probe` after the sending result is applied.
+
+### Flow Control
+
+1. limit the max size of message sent per message. Max should be configurable.
+Lower the cost at probing state as we limit the size per message; lower the penalty when aggressively decreased to a too low `next`
+
+2. limit the # of in flight messages < N when in `replicate` state. N should be configurable. Most implementation will have a sending buffer on top of its actual network transport layer (not blocking raft node). We want to make sure raft does not overflow that buffer, which can cause message dropping and triggering a bunch of unnecessary resending repeatedly.
diff --git a/vendor/github.com/coreos/etcd/raft/diff_test.go b/vendor/github.com/coreos/etcd/raft/diff_test.go
new file mode 100644
index 00000000..1c4c5272
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/diff_test.go
@@ -0,0 +1,65 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "fmt"
+ "io"
+ "io/ioutil"
+ "os"
+ "os/exec"
+ "strings"
+)
+
+func diffu(a, b string) string {
+ if a == b {
+ return ""
+ }
+ aname, bname := mustTemp("base", a), mustTemp("other", b)
+ defer os.Remove(aname)
+ defer os.Remove(bname)
+ cmd := exec.Command("diff", "-u", aname, bname)
+ buf, err := cmd.CombinedOutput()
+ if err != nil {
+ if _, ok := err.(*exec.ExitError); ok {
+ // do nothing
+ return string(buf)
+ }
+ panic(err)
+ }
+ return string(buf)
+}
+
+func mustTemp(pre, body string) string {
+ f, err := ioutil.TempFile("", pre)
+ if err != nil {
+ panic(err)
+ }
+ _, err = io.Copy(f, strings.NewReader(body))
+ if err != nil {
+ panic(err)
+ }
+ f.Close()
+ return f.Name()
+}
+
+func ltoa(l *raftLog) string {
+ s := fmt.Sprintf("committed: %d\n", l.committed)
+ s += fmt.Sprintf("applied: %d\n", l.applied)
+ for i, e := range l.allEntries() {
+ s += fmt.Sprintf("#%d: %+v\n", i, e)
+ }
+ return s
+}
diff --git a/vendor/github.com/coreos/etcd/raft/doc.go b/vendor/github.com/coreos/etcd/raft/doc.go
new file mode 100644
index 00000000..b55c591f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/doc.go
@@ -0,0 +1,300 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft sends and receives messages in the Protocol Buffer format
+defined in the raftpb package.
+
+Raft is a protocol with which a cluster of nodes can maintain a replicated state machine.
+The state machine is kept in sync through the use of a replicated log.
+For more details on Raft, see "In Search of an Understandable Consensus Algorithm"
+(https://ramcloud.stanford.edu/raft.pdf) by Diego Ongaro and John Ousterhout.
+
+A simple example application, _raftexample_, is also available to help illustrate
+how to use this package in practice:
+https://github.com/coreos/etcd/tree/master/contrib/raftexample
+
+Usage
+
+The primary object in raft is a Node. You either start a Node from scratch
+using raft.StartNode or start a Node from some initial state using raft.RestartNode.
+
+To start a node from scratch:
+
+ storage := raft.NewMemoryStorage()
+ c := &Config{
+ ID: 0x01,
+ ElectionTick: 10,
+ HeartbeatTick: 1,
+ Storage: storage,
+ MaxSizePerMsg: 4096,
+ MaxInflightMsgs: 256,
+ }
+ n := raft.StartNode(c, []raft.Peer{{ID: 0x02}, {ID: 0x03}})
+
+To restart a node from previous state:
+
+ storage := raft.NewMemoryStorage()
+
+ // recover the in-memory storage from persistent
+ // snapshot, state and entries.
+ storage.ApplySnapshot(snapshot)
+ storage.SetHardState(state)
+ storage.Append(entries)
+
+ c := &Config{
+ ID: 0x01,
+ ElectionTick: 10,
+ HeartbeatTick: 1,
+ Storage: storage,
+ MaxSizePerMsg: 4096,
+ MaxInflightMsgs: 256,
+ }
+
+ // restart raft without peer information.
+ // peer information is already included in the storage.
+ n := raft.RestartNode(c)
+
+Now that you are holding onto a Node you have a few responsibilities:
+
+First, you must read from the Node.Ready() channel and process the updates
+it contains. These steps may be performed in parallel, except as noted in step
+2.
+
+1. Write HardState, Entries, and Snapshot to persistent storage if they are
+not empty. Note that when writing an Entry with Index i, any
+previously-persisted entries with Index >= i must be discarded.
+
+2. Send all Messages to the nodes named in the To field. It is important that
+no messages be sent until the latest HardState has been persisted to disk,
+and all Entries written by any previous Ready batch (Messages may be sent while
+entries from the same batch are being persisted). To reduce the I/O latency, an
+optimization can be applied to make leader write to disk in parallel with its
+followers (as explained at section 10.2.1 in Raft thesis). If any Message has type
+MsgSnap, call Node.ReportSnapshot() after it has been sent (these messages may be
+large).
+
+Note: Marshalling messages is not thread-safe; it is important that you
+make sure that no new entries are persisted while marshalling.
+The easiest way to achieve this is to serialise the messages directly inside
+your main raft loop.
+
+3. Apply Snapshot (if any) and CommittedEntries to the state machine.
+If any committed Entry has Type EntryConfChange, call Node.ApplyConfChange()
+to apply it to the node. The configuration change may be cancelled at this point
+by setting the NodeID field to zero before calling ApplyConfChange
+(but ApplyConfChange must be called one way or the other, and the decision to cancel
+must be based solely on the state machine and not external information such as
+the observed health of the node).
+
+4. Call Node.Advance() to signal readiness for the next batch of updates.
+This may be done at any time after step 1, although all updates must be processed
+in the order they were returned by Ready.
+
+Second, all persisted log entries must be made available via an
+implementation of the Storage interface. The provided MemoryStorage
+type can be used for this (if you repopulate its state upon a
+restart), or you can supply your own disk-backed implementation.
+
+Third, when you receive a message from another node, pass it to Node.Step:
+
+ func recvRaftRPC(ctx context.Context, m raftpb.Message) {
+ n.Step(ctx, m)
+ }
+
+Finally, you need to call Node.Tick() at regular intervals (probably
+via a time.Ticker). Raft has two important timeouts: heartbeat and the
+election timeout. However, internally to the raft package time is
+represented by an abstract "tick".
+
+The total state machine handling loop will look something like this:
+
+ for {
+ select {
+ case <-s.Ticker:
+ n.Tick()
+ case rd := <-s.Node.Ready():
+ saveToStorage(rd.State, rd.Entries, rd.Snapshot)
+ send(rd.Messages)
+ if !raft.IsEmptySnap(rd.Snapshot) {
+ processSnapshot(rd.Snapshot)
+ }
+ for _, entry := range rd.CommittedEntries {
+ process(entry)
+ if entry.Type == raftpb.EntryConfChange {
+ var cc raftpb.ConfChange
+ cc.Unmarshal(entry.Data)
+ s.Node.ApplyConfChange(cc)
+ }
+ }
+ s.Node.Advance()
+ case <-s.done:
+ return
+ }
+ }
+
+To propose changes to the state machine from your node take your application
+data, serialize it into a byte slice and call:
+
+ n.Propose(ctx, data)
+
+If the proposal is committed, data will appear in committed entries with type
+raftpb.EntryNormal. There is no guarantee that a proposed command will be
+committed; you may have to re-propose after a timeout.
+
+To add or remove node in a cluster, build ConfChange struct 'cc' and call:
+
+ n.ProposeConfChange(ctx, cc)
+
+After config change is committed, some committed entry with type
+raftpb.EntryConfChange will be returned. You must apply it to node through:
+
+ var cc raftpb.ConfChange
+ cc.Unmarshal(data)
+ n.ApplyConfChange(cc)
+
+Note: An ID represents a unique node in a cluster for all time. A
+given ID MUST be used only once even if the old node has been removed.
+This means that for example IP addresses make poor node IDs since they
+may be reused. Node IDs must be non-zero.
+
+Implementation notes
+
+This implementation is up to date with the final Raft thesis
+(https://ramcloud.stanford.edu/~ongaro/thesis.pdf), although our
+implementation of the membership change protocol differs somewhat from
+that described in chapter 4. The key invariant that membership changes
+happen one node at a time is preserved, but in our implementation the
+membership change takes effect when its entry is applied, not when it
+is added to the log (so the entry is committed under the old
+membership instead of the new). This is equivalent in terms of safety,
+since the old and new configurations are guaranteed to overlap.
+
+To ensure that we do not attempt to commit two membership changes at
+once by matching log positions (which would be unsafe since they
+should have different quorum requirements), we simply disallow any
+proposed membership change while any uncommitted change appears in
+the leader's log.
+
+This approach introduces a problem when you try to remove a member
+from a two-member cluster: If one of the members dies before the
+other one receives the commit of the confchange entry, then the member
+cannot be removed any more since the cluster cannot make progress.
+For this reason it is highly recommended to use three or more nodes in
+every cluster.
+
+MessageType
+
+Package raft sends and receives message in Protocol Buffer format (defined
+in raftpb package). Each state (follower, candidate, leader) implements its
+own 'step' method ('stepFollower', 'stepCandidate', 'stepLeader') when
+advancing with the given raftpb.Message. Each step is determined by its
+raftpb.MessageType. Note that every step is checked by one common method
+'Step' that safety-checks the terms of node and incoming message to prevent
+stale log entries:
+
+ 'MsgHup' is used for election. If a node is a follower or candidate, the
+ 'tick' function in 'raft' struct is set as 'tickElection'. If a follower or
+ candidate has not received any heartbeat before the election timeout, it
+ passes 'MsgHup' to its Step method and becomes (or remains) a candidate to
+ start a new election.
+
+ 'MsgBeat' is an internal type that signals the leader to send a heartbeat of
+ the 'MsgHeartbeat' type. If a node is a leader, the 'tick' function in
+ the 'raft' struct is set as 'tickHeartbeat', and triggers the leader to
+ send periodic 'MsgHeartbeat' messages to its followers.
+
+ 'MsgProp' proposes to append data to its log entries. This is a special
+ type to redirect proposals to leader. Therefore, send method overwrites
+ raftpb.Message's term with its HardState's term to avoid attaching its
+ local term to 'MsgProp'. When 'MsgProp' is passed to the leader's 'Step'
+ method, the leader first calls the 'appendEntry' method to append entries
+ to its log, and then calls 'bcastAppend' method to send those entries to
+ its peers. When passed to candidate, 'MsgProp' is dropped. When passed to
+ follower, 'MsgProp' is stored in follower's mailbox(msgs) by the send
+ method. It is stored with sender's ID and later forwarded to leader by
+ rafthttp package.
+
+ 'MsgApp' contains log entries to replicate. A leader calls bcastAppend,
+ which calls sendAppend, which sends soon-to-be-replicated logs in 'MsgApp'
+ type. When 'MsgApp' is passed to candidate's Step method, candidate reverts
+ back to follower, because it indicates that there is a valid leader sending
+ 'MsgApp' messages. Candidate and follower respond to this message in
+ 'MsgAppResp' type.
+
+ 'MsgAppResp' is response to log replication request('MsgApp'). When
+ 'MsgApp' is passed to candidate or follower's Step method, it responds by
+ calling 'handleAppendEntries' method, which sends 'MsgAppResp' to raft
+ mailbox.
+
+ 'MsgVote' requests votes for election. When a node is a follower or
+ candidate and 'MsgHup' is passed to its Step method, then the node calls
+ 'campaign' method to campaign itself to become a leader. Once 'campaign'
+ method is called, the node becomes candidate and sends 'MsgVote' to peers
+ in cluster to request votes. When passed to leader or candidate's Step
+ method and the message's Term is lower than leader's or candidate's,
+ 'MsgVote' will be rejected ('MsgVoteResp' is returned with Reject true).
+ If leader or candidate receives 'MsgVote' with higher term, it will revert
+ back to follower. When 'MsgVote' is passed to follower, it votes for the
+ sender only when sender's last term is greater than MsgVote's term or
+ sender's last term is equal to MsgVote's term but sender's last committed
+ index is greater than or equal to follower's.
+
+ 'MsgVoteResp' contains responses from voting request. When 'MsgVoteResp' is
+ passed to candidate, the candidate calculates how many votes it has won. If
+ it's more than majority (quorum), it becomes leader and calls 'bcastAppend'.
+ If candidate receives majority of votes of denials, it reverts back to
+ follower.
+
+ 'MsgPreVote' and 'MsgPreVoteResp' are used in an optional two-phase election
+ protocol. When Config.PreVote is true, a pre-election is carried out first
+ (using the same rules as a regular election), and no node increases its term
+ number unless the pre-election indicates that the campaigining node would win.
+ This minimizes disruption when a partitioned node rejoins the cluster.
+
+ 'MsgSnap' requests to install a snapshot message. When a node has just
+ become a leader or the leader receives 'MsgProp' message, it calls
+ 'bcastAppend' method, which then calls 'sendAppend' method to each
+ follower. In 'sendAppend', if a leader fails to get term or entries,
+ the leader requests snapshot by sending 'MsgSnap' type message.
+
+ 'MsgSnapStatus' tells the result of snapshot install message. When a
+ follower rejected 'MsgSnap', it indicates the snapshot request with
+ 'MsgSnap' had failed from network issues which causes the network layer
+ to fail to send out snapshots to its followers. Then leader considers
+ follower's progress as probe. When 'MsgSnap' were not rejected, it
+ indicates that the snapshot succeeded and the leader sets follower's
+ progress to probe and resumes its log replication.
+
+ 'MsgHeartbeat' sends heartbeat from leader. When 'MsgHeartbeat' is passed
+ to candidate and message's term is higher than candidate's, the candidate
+ reverts back to follower and updates its committed index from the one in
+ this heartbeat. And it sends the message to its mailbox. When
+ 'MsgHeartbeat' is passed to follower's Step method and message's term is
+ higher than follower's, the follower updates its leaderID with the ID
+ from the message.
+
+ 'MsgHeartbeatResp' is a response to 'MsgHeartbeat'. When 'MsgHeartbeatResp'
+ is passed to leader's Step method, the leader knows which follower
+ responded. And only when the leader's last committed index is greater than
+ follower's Match index, the leader runs 'sendAppend` method.
+
+ 'MsgUnreachable' tells that request(message) wasn't delivered. When
+ 'MsgUnreachable' is passed to leader's Step method, the leader discovers
+ that the follower that sent this 'MsgUnreachable' is not reachable, often
+ indicating 'MsgApp' is lost. When follower's progress state is replicate,
+ the leader sets it back to probe.
+
+*/
+package raft
diff --git a/vendor/github.com/coreos/etcd/raft/example_test.go b/vendor/github.com/coreos/etcd/raft/example_test.go
new file mode 100644
index 00000000..26a1e024
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/example_test.go
@@ -0,0 +1,47 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+func applyToStore(ents []pb.Entry) {}
+func sendMessages(msgs []pb.Message) {}
+func saveStateToDisk(st pb.HardState) {}
+func saveToDisk(ents []pb.Entry) {}
+
+func ExampleNode() {
+ c := &Config{}
+ n := StartNode(c, nil)
+ defer n.Stop()
+
+ // stuff to n happens in other goroutines
+
+ // the last known state
+ var prev pb.HardState
+ for {
+ // Ready blocks until there is new state ready.
+ rd := <-n.Ready()
+ if !isHardStateEqual(prev, rd.HardState) {
+ saveStateToDisk(rd.HardState)
+ prev = rd.HardState
+ }
+
+ saveToDisk(rd.Entries)
+ go applyToStore(rd.CommittedEntries)
+ sendMessages(rd.Messages)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/raft/log.go b/vendor/github.com/coreos/etcd/raft/log.go
new file mode 100644
index 00000000..c3036d3c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/log.go
@@ -0,0 +1,358 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "fmt"
+ "log"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+type raftLog struct {
+ // storage contains all stable entries since the last snapshot.
+ storage Storage
+
+ // unstable contains all unstable entries and snapshot.
+ // they will be saved into storage.
+ unstable unstable
+
+ // committed is the highest log position that is known to be in
+ // stable storage on a quorum of nodes.
+ committed uint64
+ // applied is the highest log position that the application has
+ // been instructed to apply to its state machine.
+ // Invariant: applied <= committed
+ applied uint64
+
+ logger Logger
+}
+
+// newLog returns log using the given storage. It recovers the log to the state
+// that it just commits and applies the latest snapshot.
+func newLog(storage Storage, logger Logger) *raftLog {
+ if storage == nil {
+ log.Panic("storage must not be nil")
+ }
+ log := &raftLog{
+ storage: storage,
+ logger: logger,
+ }
+ firstIndex, err := storage.FirstIndex()
+ if err != nil {
+ panic(err) // TODO(bdarnell)
+ }
+ lastIndex, err := storage.LastIndex()
+ if err != nil {
+ panic(err) // TODO(bdarnell)
+ }
+ log.unstable.offset = lastIndex + 1
+ log.unstable.logger = logger
+ // Initialize our committed and applied pointers to the time of the last compaction.
+ log.committed = firstIndex - 1
+ log.applied = firstIndex - 1
+
+ return log
+}
+
+func (l *raftLog) String() string {
+ return fmt.Sprintf("committed=%d, applied=%d, unstable.offset=%d, len(unstable.Entries)=%d", l.committed, l.applied, l.unstable.offset, len(l.unstable.entries))
+}
+
+// maybeAppend returns (0, false) if the entries cannot be appended. Otherwise,
+// it returns (last index of new entries, true).
+func (l *raftLog) maybeAppend(index, logTerm, committed uint64, ents ...pb.Entry) (lastnewi uint64, ok bool) {
+ if l.matchTerm(index, logTerm) {
+ lastnewi = index + uint64(len(ents))
+ ci := l.findConflict(ents)
+ switch {
+ case ci == 0:
+ case ci <= l.committed:
+ l.logger.Panicf("entry %d conflict with committed entry [committed(%d)]", ci, l.committed)
+ default:
+ offset := index + 1
+ l.append(ents[ci-offset:]...)
+ }
+ l.commitTo(min(committed, lastnewi))
+ return lastnewi, true
+ }
+ return 0, false
+}
+
+func (l *raftLog) append(ents ...pb.Entry) uint64 {
+ if len(ents) == 0 {
+ return l.lastIndex()
+ }
+ if after := ents[0].Index - 1; after < l.committed {
+ l.logger.Panicf("after(%d) is out of range [committed(%d)]", after, l.committed)
+ }
+ l.unstable.truncateAndAppend(ents)
+ return l.lastIndex()
+}
+
+// findConflict finds the index of the conflict.
+// It returns the first pair of conflicting entries between the existing
+// entries and the given entries, if there are any.
+// If there is no conflicting entries, and the existing entries contains
+// all the given entries, zero will be returned.
+// If there is no conflicting entries, but the given entries contains new
+// entries, the index of the first new entry will be returned.
+// An entry is considered to be conflicting if it has the same index but
+// a different term.
+// The first entry MUST have an index equal to the argument 'from'.
+// The index of the given entries MUST be continuously increasing.
+func (l *raftLog) findConflict(ents []pb.Entry) uint64 {
+ for _, ne := range ents {
+ if !l.matchTerm(ne.Index, ne.Term) {
+ if ne.Index <= l.lastIndex() {
+ l.logger.Infof("found conflict at index %d [existing term: %d, conflicting term: %d]",
+ ne.Index, l.zeroTermOnErrCompacted(l.term(ne.Index)), ne.Term)
+ }
+ return ne.Index
+ }
+ }
+ return 0
+}
+
+func (l *raftLog) unstableEntries() []pb.Entry {
+ if len(l.unstable.entries) == 0 {
+ return nil
+ }
+ return l.unstable.entries
+}
+
+// nextEnts returns all the available entries for execution.
+// If applied is smaller than the index of snapshot, it returns all committed
+// entries after the index of snapshot.
+func (l *raftLog) nextEnts() (ents []pb.Entry) {
+ off := max(l.applied+1, l.firstIndex())
+ if l.committed+1 > off {
+ ents, err := l.slice(off, l.committed+1, noLimit)
+ if err != nil {
+ l.logger.Panicf("unexpected error when getting unapplied entries (%v)", err)
+ }
+ return ents
+ }
+ return nil
+}
+
+// hasNextEnts returns if there is any available entries for execution. This
+// is a fast check without heavy raftLog.slice() in raftLog.nextEnts().
+func (l *raftLog) hasNextEnts() bool {
+ off := max(l.applied+1, l.firstIndex())
+ return l.committed+1 > off
+}
+
+func (l *raftLog) snapshot() (pb.Snapshot, error) {
+ if l.unstable.snapshot != nil {
+ return *l.unstable.snapshot, nil
+ }
+ return l.storage.Snapshot()
+}
+
+func (l *raftLog) firstIndex() uint64 {
+ if i, ok := l.unstable.maybeFirstIndex(); ok {
+ return i
+ }
+ index, err := l.storage.FirstIndex()
+ if err != nil {
+ panic(err) // TODO(bdarnell)
+ }
+ return index
+}
+
+func (l *raftLog) lastIndex() uint64 {
+ if i, ok := l.unstable.maybeLastIndex(); ok {
+ return i
+ }
+ i, err := l.storage.LastIndex()
+ if err != nil {
+ panic(err) // TODO(bdarnell)
+ }
+ return i
+}
+
+func (l *raftLog) commitTo(tocommit uint64) {
+ // never decrease commit
+ if l.committed < tocommit {
+ if l.lastIndex() < tocommit {
+ l.logger.Panicf("tocommit(%d) is out of range [lastIndex(%d)]. Was the raft log corrupted, truncated, or lost?", tocommit, l.lastIndex())
+ }
+ l.committed = tocommit
+ }
+}
+
+func (l *raftLog) appliedTo(i uint64) {
+ if i == 0 {
+ return
+ }
+ if l.committed < i || i < l.applied {
+ l.logger.Panicf("applied(%d) is out of range [prevApplied(%d), committed(%d)]", i, l.applied, l.committed)
+ }
+ l.applied = i
+}
+
+func (l *raftLog) stableTo(i, t uint64) { l.unstable.stableTo(i, t) }
+
+func (l *raftLog) stableSnapTo(i uint64) { l.unstable.stableSnapTo(i) }
+
+func (l *raftLog) lastTerm() uint64 {
+ t, err := l.term(l.lastIndex())
+ if err != nil {
+ l.logger.Panicf("unexpected error when getting the last term (%v)", err)
+ }
+ return t
+}
+
+func (l *raftLog) term(i uint64) (uint64, error) {
+ // the valid term range is [index of dummy entry, last index]
+ dummyIndex := l.firstIndex() - 1
+ if i < dummyIndex || i > l.lastIndex() {
+ // TODO: return an error instead?
+ return 0, nil
+ }
+
+ if t, ok := l.unstable.maybeTerm(i); ok {
+ return t, nil
+ }
+
+ t, err := l.storage.Term(i)
+ if err == nil {
+ return t, nil
+ }
+ if err == ErrCompacted || err == ErrUnavailable {
+ return 0, err
+ }
+ panic(err) // TODO(bdarnell)
+}
+
+func (l *raftLog) entries(i, maxsize uint64) ([]pb.Entry, error) {
+ if i > l.lastIndex() {
+ return nil, nil
+ }
+ return l.slice(i, l.lastIndex()+1, maxsize)
+}
+
+// allEntries returns all entries in the log.
+func (l *raftLog) allEntries() []pb.Entry {
+ ents, err := l.entries(l.firstIndex(), noLimit)
+ if err == nil {
+ return ents
+ }
+ if err == ErrCompacted { // try again if there was a racing compaction
+ return l.allEntries()
+ }
+ // TODO (xiangli): handle error?
+ panic(err)
+}
+
+// isUpToDate determines if the given (lastIndex,term) log is more up-to-date
+// by comparing the index and term of the last entries in the existing logs.
+// If the logs have last entries with different terms, then the log with the
+// later term is more up-to-date. If the logs end with the same term, then
+// whichever log has the larger lastIndex is more up-to-date. If the logs are
+// the same, the given log is up-to-date.
+func (l *raftLog) isUpToDate(lasti, term uint64) bool {
+ return term > l.lastTerm() || (term == l.lastTerm() && lasti >= l.lastIndex())
+}
+
+func (l *raftLog) matchTerm(i, term uint64) bool {
+ t, err := l.term(i)
+ if err != nil {
+ return false
+ }
+ return t == term
+}
+
+func (l *raftLog) maybeCommit(maxIndex, term uint64) bool {
+ if maxIndex > l.committed && l.zeroTermOnErrCompacted(l.term(maxIndex)) == term {
+ l.commitTo(maxIndex)
+ return true
+ }
+ return false
+}
+
+func (l *raftLog) restore(s pb.Snapshot) {
+ l.logger.Infof("log [%s] starts to restore snapshot [index: %d, term: %d]", l, s.Metadata.Index, s.Metadata.Term)
+ l.committed = s.Metadata.Index
+ l.unstable.restore(s)
+}
+
+// slice returns a slice of log entries from lo through hi-1, inclusive.
+func (l *raftLog) slice(lo, hi, maxSize uint64) ([]pb.Entry, error) {
+ err := l.mustCheckOutOfBounds(lo, hi)
+ if err != nil {
+ return nil, err
+ }
+ if lo == hi {
+ return nil, nil
+ }
+ var ents []pb.Entry
+ if lo < l.unstable.offset {
+ storedEnts, err := l.storage.Entries(lo, min(hi, l.unstable.offset), maxSize)
+ if err == ErrCompacted {
+ return nil, err
+ } else if err == ErrUnavailable {
+ l.logger.Panicf("entries[%d:%d) is unavailable from storage", lo, min(hi, l.unstable.offset))
+ } else if err != nil {
+ panic(err) // TODO(bdarnell)
+ }
+
+ // check if ents has reached the size limitation
+ if uint64(len(storedEnts)) < min(hi, l.unstable.offset)-lo {
+ return storedEnts, nil
+ }
+
+ ents = storedEnts
+ }
+ if hi > l.unstable.offset {
+ unstable := l.unstable.slice(max(lo, l.unstable.offset), hi)
+ if len(ents) > 0 {
+ ents = append([]pb.Entry{}, ents...)
+ ents = append(ents, unstable...)
+ } else {
+ ents = unstable
+ }
+ }
+ return limitSize(ents, maxSize), nil
+}
+
+// l.firstIndex <= lo <= hi <= l.firstIndex + len(l.entries)
+func (l *raftLog) mustCheckOutOfBounds(lo, hi uint64) error {
+ if lo > hi {
+ l.logger.Panicf("invalid slice %d > %d", lo, hi)
+ }
+ fi := l.firstIndex()
+ if lo < fi {
+ return ErrCompacted
+ }
+
+ length := l.lastIndex() + 1 - fi
+ if lo < fi || hi > fi+length {
+ l.logger.Panicf("slice[%d,%d) out of bound [%d,%d]", lo, hi, fi, l.lastIndex())
+ }
+ return nil
+}
+
+func (l *raftLog) zeroTermOnErrCompacted(t uint64, err error) uint64 {
+ if err == nil {
+ return t
+ }
+ if err == ErrCompacted {
+ return 0
+ }
+ l.logger.Panicf("unexpected error (%v)", err)
+ return 0
+}
diff --git a/vendor/github.com/coreos/etcd/raft/log_test.go b/vendor/github.com/coreos/etcd/raft/log_test.go
new file mode 100644
index 00000000..f80e41ce
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/log_test.go
@@ -0,0 +1,819 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "reflect"
+ "testing"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+func TestFindConflict(t *testing.T) {
+ previousEnts := []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}, {Index: 3, Term: 3}}
+ tests := []struct {
+ ents []pb.Entry
+ wconflict uint64
+ }{
+ // no conflict, empty ent
+ {[]pb.Entry{}, 0},
+ // no conflict
+ {[]pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}, {Index: 3, Term: 3}}, 0},
+ {[]pb.Entry{{Index: 2, Term: 2}, {Index: 3, Term: 3}}, 0},
+ {[]pb.Entry{{Index: 3, Term: 3}}, 0},
+ // no conflict, but has new entries
+ {[]pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}, {Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 4}}, 4},
+ {[]pb.Entry{{Index: 2, Term: 2}, {Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 4}}, 4},
+ {[]pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 4}}, 4},
+ {[]pb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 4}}, 4},
+ // conflicts with existing entries
+ {[]pb.Entry{{Index: 1, Term: 4}, {Index: 2, Term: 4}}, 1},
+ {[]pb.Entry{{Index: 2, Term: 1}, {Index: 3, Term: 4}, {Index: 4, Term: 4}}, 2},
+ {[]pb.Entry{{Index: 3, Term: 1}, {Index: 4, Term: 2}, {Index: 5, Term: 4}, {Index: 6, Term: 4}}, 3},
+ }
+
+ for i, tt := range tests {
+ raftLog := newLog(NewMemoryStorage(), raftLogger)
+ raftLog.append(previousEnts...)
+
+ gconflict := raftLog.findConflict(tt.ents)
+ if gconflict != tt.wconflict {
+ t.Errorf("#%d: conflict = %d, want %d", i, gconflict, tt.wconflict)
+ }
+ }
+}
+
+func TestIsUpToDate(t *testing.T) {
+ previousEnts := []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}, {Index: 3, Term: 3}}
+ raftLog := newLog(NewMemoryStorage(), raftLogger)
+ raftLog.append(previousEnts...)
+ tests := []struct {
+ lastIndex uint64
+ term uint64
+ wUpToDate bool
+ }{
+ // greater term, ignore lastIndex
+ {raftLog.lastIndex() - 1, 4, true},
+ {raftLog.lastIndex(), 4, true},
+ {raftLog.lastIndex() + 1, 4, true},
+ // smaller term, ignore lastIndex
+ {raftLog.lastIndex() - 1, 2, false},
+ {raftLog.lastIndex(), 2, false},
+ {raftLog.lastIndex() + 1, 2, false},
+ // equal term, equal or lager lastIndex wins
+ {raftLog.lastIndex() - 1, 3, false},
+ {raftLog.lastIndex(), 3, true},
+ {raftLog.lastIndex() + 1, 3, true},
+ }
+
+ for i, tt := range tests {
+ gUpToDate := raftLog.isUpToDate(tt.lastIndex, tt.term)
+ if gUpToDate != tt.wUpToDate {
+ t.Errorf("#%d: uptodate = %v, want %v", i, gUpToDate, tt.wUpToDate)
+ }
+ }
+}
+
+func TestAppend(t *testing.T) {
+ previousEnts := []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}}
+ tests := []struct {
+ ents []pb.Entry
+ windex uint64
+ wents []pb.Entry
+ wunstable uint64
+ }{
+ {
+ []pb.Entry{},
+ 2,
+ []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}},
+ 3,
+ },
+ {
+ []pb.Entry{{Index: 3, Term: 2}},
+ 3,
+ []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}, {Index: 3, Term: 2}},
+ 3,
+ },
+ // conflicts with index 1
+ {
+ []pb.Entry{{Index: 1, Term: 2}},
+ 1,
+ []pb.Entry{{Index: 1, Term: 2}},
+ 1,
+ },
+ // conflicts with index 2
+ {
+ []pb.Entry{{Index: 2, Term: 3}, {Index: 3, Term: 3}},
+ 3,
+ []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 3}, {Index: 3, Term: 3}},
+ 2,
+ },
+ }
+
+ for i, tt := range tests {
+ storage := NewMemoryStorage()
+ storage.Append(previousEnts)
+ raftLog := newLog(storage, raftLogger)
+
+ index := raftLog.append(tt.ents...)
+ if index != tt.windex {
+ t.Errorf("#%d: lastIndex = %d, want %d", i, index, tt.windex)
+ }
+ g, err := raftLog.entries(1, noLimit)
+ if err != nil {
+ t.Fatalf("#%d: unexpected error %v", i, err)
+ }
+ if !reflect.DeepEqual(g, tt.wents) {
+ t.Errorf("#%d: logEnts = %+v, want %+v", i, g, tt.wents)
+ }
+ if goff := raftLog.unstable.offset; goff != tt.wunstable {
+ t.Errorf("#%d: unstable = %d, want %d", i, goff, tt.wunstable)
+ }
+ }
+}
+
+// TestLogMaybeAppend ensures:
+// If the given (index, term) matches with the existing log:
+// 1. If an existing entry conflicts with a new one (same index
+// but different terms), delete the existing entry and all that
+// follow it
+// 2.Append any new entries not already in the log
+// If the given (index, term) does not match with the existing log:
+// return false
+func TestLogMaybeAppend(t *testing.T) {
+ previousEnts := []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}, {Index: 3, Term: 3}}
+ lastindex := uint64(3)
+ lastterm := uint64(3)
+ commit := uint64(1)
+
+ tests := []struct {
+ logTerm uint64
+ index uint64
+ committed uint64
+ ents []pb.Entry
+
+ wlasti uint64
+ wappend bool
+ wcommit uint64
+ wpanic bool
+ }{
+ // not match: term is different
+ {
+ lastterm - 1, lastindex, lastindex, []pb.Entry{{Index: lastindex + 1, Term: 4}},
+ 0, false, commit, false,
+ },
+ // not match: index out of bound
+ {
+ lastterm, lastindex + 1, lastindex, []pb.Entry{{Index: lastindex + 2, Term: 4}},
+ 0, false, commit, false,
+ },
+ // match with the last existing entry
+ {
+ lastterm, lastindex, lastindex, nil,
+ lastindex, true, lastindex, false,
+ },
+ {
+ lastterm, lastindex, lastindex + 1, nil,
+ lastindex, true, lastindex, false, // do not increase commit higher than lastnewi
+ },
+ {
+ lastterm, lastindex, lastindex - 1, nil,
+ lastindex, true, lastindex - 1, false, // commit up to the commit in the message
+ },
+ {
+ lastterm, lastindex, 0, nil,
+ lastindex, true, commit, false, // commit do not decrease
+ },
+ {
+ 0, 0, lastindex, nil,
+ 0, true, commit, false, // commit do not decrease
+ },
+ {
+ lastterm, lastindex, lastindex, []pb.Entry{{Index: lastindex + 1, Term: 4}},
+ lastindex + 1, true, lastindex, false,
+ },
+ {
+ lastterm, lastindex, lastindex + 1, []pb.Entry{{Index: lastindex + 1, Term: 4}},
+ lastindex + 1, true, lastindex + 1, false,
+ },
+ {
+ lastterm, lastindex, lastindex + 2, []pb.Entry{{Index: lastindex + 1, Term: 4}},
+ lastindex + 1, true, lastindex + 1, false, // do not increase commit higher than lastnewi
+ },
+ {
+ lastterm, lastindex, lastindex + 2, []pb.Entry{{Index: lastindex + 1, Term: 4}, {Index: lastindex + 2, Term: 4}},
+ lastindex + 2, true, lastindex + 2, false,
+ },
+ // match with the the entry in the middle
+ {
+ lastterm - 1, lastindex - 1, lastindex, []pb.Entry{{Index: lastindex, Term: 4}},
+ lastindex, true, lastindex, false,
+ },
+ {
+ lastterm - 2, lastindex - 2, lastindex, []pb.Entry{{Index: lastindex - 1, Term: 4}},
+ lastindex - 1, true, lastindex - 1, false,
+ },
+ {
+ lastterm - 3, lastindex - 3, lastindex, []pb.Entry{{Index: lastindex - 2, Term: 4}},
+ lastindex - 2, true, lastindex - 2, true, // conflict with existing committed entry
+ },
+ {
+ lastterm - 2, lastindex - 2, lastindex, []pb.Entry{{Index: lastindex - 1, Term: 4}, {Index: lastindex, Term: 4}},
+ lastindex, true, lastindex, false,
+ },
+ }
+
+ for i, tt := range tests {
+ raftLog := newLog(NewMemoryStorage(), raftLogger)
+ raftLog.append(previousEnts...)
+ raftLog.committed = commit
+ func() {
+ defer func() {
+ if r := recover(); r != nil {
+ if !tt.wpanic {
+ t.Errorf("%d: panic = %v, want %v", i, true, tt.wpanic)
+ }
+ }
+ }()
+ glasti, gappend := raftLog.maybeAppend(tt.index, tt.logTerm, tt.committed, tt.ents...)
+ gcommit := raftLog.committed
+
+ if glasti != tt.wlasti {
+ t.Errorf("#%d: lastindex = %d, want %d", i, glasti, tt.wlasti)
+ }
+ if gappend != tt.wappend {
+ t.Errorf("#%d: append = %v, want %v", i, gappend, tt.wappend)
+ }
+ if gcommit != tt.wcommit {
+ t.Errorf("#%d: committed = %d, want %d", i, gcommit, tt.wcommit)
+ }
+ if gappend && len(tt.ents) != 0 {
+ gents, err := raftLog.slice(raftLog.lastIndex()-uint64(len(tt.ents))+1, raftLog.lastIndex()+1, noLimit)
+ if err != nil {
+ t.Fatalf("unexpected error %v", err)
+ }
+ if !reflect.DeepEqual(tt.ents, gents) {
+ t.Errorf("%d: appended entries = %v, want %v", i, gents, tt.ents)
+ }
+ }
+ }()
+ }
+}
+
+// TestCompactionSideEffects ensures that all the log related functionality works correctly after
+// a compaction.
+func TestCompactionSideEffects(t *testing.T) {
+ var i uint64
+ // Populate the log with 1000 entries; 750 in stable storage and 250 in unstable.
+ lastIndex := uint64(1000)
+ unstableIndex := uint64(750)
+ lastTerm := lastIndex
+ storage := NewMemoryStorage()
+ for i = 1; i <= unstableIndex; i++ {
+ storage.Append([]pb.Entry{{Term: uint64(i), Index: uint64(i)}})
+ }
+ raftLog := newLog(storage, raftLogger)
+ for i = unstableIndex; i < lastIndex; i++ {
+ raftLog.append(pb.Entry{Term: uint64(i + 1), Index: uint64(i + 1)})
+ }
+
+ ok := raftLog.maybeCommit(lastIndex, lastTerm)
+ if !ok {
+ t.Fatalf("maybeCommit returned false")
+ }
+ raftLog.appliedTo(raftLog.committed)
+
+ offset := uint64(500)
+ storage.Compact(offset)
+
+ if raftLog.lastIndex() != lastIndex {
+ t.Errorf("lastIndex = %d, want %d", raftLog.lastIndex(), lastIndex)
+ }
+
+ for j := offset; j <= raftLog.lastIndex(); j++ {
+ if mustTerm(raftLog.term(j)) != j {
+ t.Errorf("term(%d) = %d, want %d", j, mustTerm(raftLog.term(j)), j)
+ }
+ }
+
+ for j := offset; j <= raftLog.lastIndex(); j++ {
+ if !raftLog.matchTerm(j, j) {
+ t.Errorf("matchTerm(%d) = false, want true", j)
+ }
+ }
+
+ unstableEnts := raftLog.unstableEntries()
+ if g := len(unstableEnts); g != 250 {
+ t.Errorf("len(unstableEntries) = %d, want = %d", g, 250)
+ }
+ if unstableEnts[0].Index != 751 {
+ t.Errorf("Index = %d, want = %d", unstableEnts[0].Index, 751)
+ }
+
+ prev := raftLog.lastIndex()
+ raftLog.append(pb.Entry{Index: raftLog.lastIndex() + 1, Term: raftLog.lastIndex() + 1})
+ if raftLog.lastIndex() != prev+1 {
+ t.Errorf("lastIndex = %d, want = %d", raftLog.lastIndex(), prev+1)
+ }
+
+ ents, err := raftLog.entries(raftLog.lastIndex(), noLimit)
+ if err != nil {
+ t.Fatalf("unexpected error %v", err)
+ }
+ if len(ents) != 1 {
+ t.Errorf("len(entries) = %d, want = %d", len(ents), 1)
+ }
+}
+
+func TestHasNextEnts(t *testing.T) {
+ snap := pb.Snapshot{
+ Metadata: pb.SnapshotMetadata{Term: 1, Index: 3},
+ }
+ ents := []pb.Entry{
+ {Term: 1, Index: 4},
+ {Term: 1, Index: 5},
+ {Term: 1, Index: 6},
+ }
+ tests := []struct {
+ applied uint64
+ hasNext bool
+ }{
+ {0, true},
+ {3, true},
+ {4, true},
+ {5, false},
+ }
+ for i, tt := range tests {
+ storage := NewMemoryStorage()
+ storage.ApplySnapshot(snap)
+ raftLog := newLog(storage, raftLogger)
+ raftLog.append(ents...)
+ raftLog.maybeCommit(5, 1)
+ raftLog.appliedTo(tt.applied)
+
+ hasNext := raftLog.hasNextEnts()
+ if hasNext != tt.hasNext {
+ t.Errorf("#%d: hasNext = %v, want %v", i, hasNext, tt.hasNext)
+ }
+ }
+}
+
+func TestNextEnts(t *testing.T) {
+ snap := pb.Snapshot{
+ Metadata: pb.SnapshotMetadata{Term: 1, Index: 3},
+ }
+ ents := []pb.Entry{
+ {Term: 1, Index: 4},
+ {Term: 1, Index: 5},
+ {Term: 1, Index: 6},
+ }
+ tests := []struct {
+ applied uint64
+ wents []pb.Entry
+ }{
+ {0, ents[:2]},
+ {3, ents[:2]},
+ {4, ents[1:2]},
+ {5, nil},
+ }
+ for i, tt := range tests {
+ storage := NewMemoryStorage()
+ storage.ApplySnapshot(snap)
+ raftLog := newLog(storage, raftLogger)
+ raftLog.append(ents...)
+ raftLog.maybeCommit(5, 1)
+ raftLog.appliedTo(tt.applied)
+
+ nents := raftLog.nextEnts()
+ if !reflect.DeepEqual(nents, tt.wents) {
+ t.Errorf("#%d: nents = %+v, want %+v", i, nents, tt.wents)
+ }
+ }
+}
+
+// TestUnstableEnts ensures unstableEntries returns the unstable part of the
+// entries correctly.
+func TestUnstableEnts(t *testing.T) {
+ previousEnts := []pb.Entry{{Term: 1, Index: 1}, {Term: 2, Index: 2}}
+ tests := []struct {
+ unstable uint64
+ wents []pb.Entry
+ }{
+ {3, nil},
+ {1, previousEnts},
+ }
+
+ for i, tt := range tests {
+ // append stable entries to storage
+ storage := NewMemoryStorage()
+ storage.Append(previousEnts[:tt.unstable-1])
+
+ // append unstable entries to raftlog
+ raftLog := newLog(storage, raftLogger)
+ raftLog.append(previousEnts[tt.unstable-1:]...)
+
+ ents := raftLog.unstableEntries()
+ if l := len(ents); l > 0 {
+ raftLog.stableTo(ents[l-1].Index, ents[l-i].Term)
+ }
+ if !reflect.DeepEqual(ents, tt.wents) {
+ t.Errorf("#%d: unstableEnts = %+v, want %+v", i, ents, tt.wents)
+ }
+ w := previousEnts[len(previousEnts)-1].Index + 1
+ if g := raftLog.unstable.offset; g != w {
+ t.Errorf("#%d: unstable = %d, want %d", i, g, w)
+ }
+ }
+}
+
+func TestCommitTo(t *testing.T) {
+ previousEnts := []pb.Entry{{Term: 1, Index: 1}, {Term: 2, Index: 2}, {Term: 3, Index: 3}}
+ commit := uint64(2)
+ tests := []struct {
+ commit uint64
+ wcommit uint64
+ wpanic bool
+ }{
+ {3, 3, false},
+ {1, 2, false}, // never decrease
+ {4, 0, true}, // commit out of range -> panic
+ }
+ for i, tt := range tests {
+ func() {
+ defer func() {
+ if r := recover(); r != nil {
+ if !tt.wpanic {
+ t.Errorf("%d: panic = %v, want %v", i, true, tt.wpanic)
+ }
+ }
+ }()
+ raftLog := newLog(NewMemoryStorage(), raftLogger)
+ raftLog.append(previousEnts...)
+ raftLog.committed = commit
+ raftLog.commitTo(tt.commit)
+ if raftLog.committed != tt.wcommit {
+ t.Errorf("#%d: committed = %d, want %d", i, raftLog.committed, tt.wcommit)
+ }
+ }()
+ }
+}
+
+func TestStableTo(t *testing.T) {
+ tests := []struct {
+ stablei uint64
+ stablet uint64
+ wunstable uint64
+ }{
+ {1, 1, 2},
+ {2, 2, 3},
+ {2, 1, 1}, // bad term
+ {3, 1, 1}, // bad index
+ }
+ for i, tt := range tests {
+ raftLog := newLog(NewMemoryStorage(), raftLogger)
+ raftLog.append([]pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}}...)
+ raftLog.stableTo(tt.stablei, tt.stablet)
+ if raftLog.unstable.offset != tt.wunstable {
+ t.Errorf("#%d: unstable = %d, want %d", i, raftLog.unstable.offset, tt.wunstable)
+ }
+ }
+}
+
+func TestStableToWithSnap(t *testing.T) {
+ snapi, snapt := uint64(5), uint64(2)
+ tests := []struct {
+ stablei uint64
+ stablet uint64
+ newEnts []pb.Entry
+
+ wunstable uint64
+ }{
+ {snapi + 1, snapt, nil, snapi + 1},
+ {snapi, snapt, nil, snapi + 1},
+ {snapi - 1, snapt, nil, snapi + 1},
+
+ {snapi + 1, snapt + 1, nil, snapi + 1},
+ {snapi, snapt + 1, nil, snapi + 1},
+ {snapi - 1, snapt + 1, nil, snapi + 1},
+
+ {snapi + 1, snapt, []pb.Entry{{Index: snapi + 1, Term: snapt}}, snapi + 2},
+ {snapi, snapt, []pb.Entry{{Index: snapi + 1, Term: snapt}}, snapi + 1},
+ {snapi - 1, snapt, []pb.Entry{{Index: snapi + 1, Term: snapt}}, snapi + 1},
+
+ {snapi + 1, snapt + 1, []pb.Entry{{Index: snapi + 1, Term: snapt}}, snapi + 1},
+ {snapi, snapt + 1, []pb.Entry{{Index: snapi + 1, Term: snapt}}, snapi + 1},
+ {snapi - 1, snapt + 1, []pb.Entry{{Index: snapi + 1, Term: snapt}}, snapi + 1},
+ }
+ for i, tt := range tests {
+ s := NewMemoryStorage()
+ s.ApplySnapshot(pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: snapi, Term: snapt}})
+ raftLog := newLog(s, raftLogger)
+ raftLog.append(tt.newEnts...)
+ raftLog.stableTo(tt.stablei, tt.stablet)
+ if raftLog.unstable.offset != tt.wunstable {
+ t.Errorf("#%d: unstable = %d, want %d", i, raftLog.unstable.offset, tt.wunstable)
+ }
+ }
+}
+
+//TestCompaction ensures that the number of log entries is correct after compactions.
+func TestCompaction(t *testing.T) {
+ tests := []struct {
+ lastIndex uint64
+ compact []uint64
+ wleft []int
+ wallow bool
+ }{
+ // out of upper bound
+ {1000, []uint64{1001}, []int{-1}, false},
+ {1000, []uint64{300, 500, 800, 900}, []int{700, 500, 200, 100}, true},
+ // out of lower bound
+ {1000, []uint64{300, 299}, []int{700, -1}, false},
+ }
+
+ for i, tt := range tests {
+ func() {
+ defer func() {
+ if r := recover(); r != nil {
+ if tt.wallow {
+ t.Errorf("%d: allow = %v, want %v: %v", i, false, true, r)
+ }
+ }
+ }()
+
+ storage := NewMemoryStorage()
+ for i := uint64(1); i <= tt.lastIndex; i++ {
+ storage.Append([]pb.Entry{{Index: i}})
+ }
+ raftLog := newLog(storage, raftLogger)
+ raftLog.maybeCommit(tt.lastIndex, 0)
+ raftLog.appliedTo(raftLog.committed)
+
+ for j := 0; j < len(tt.compact); j++ {
+ err := storage.Compact(tt.compact[j])
+ if err != nil {
+ if tt.wallow {
+ t.Errorf("#%d.%d allow = %t, want %t", i, j, false, tt.wallow)
+ }
+ continue
+ }
+ if len(raftLog.allEntries()) != tt.wleft[j] {
+ t.Errorf("#%d.%d len = %d, want %d", i, j, len(raftLog.allEntries()), tt.wleft[j])
+ }
+ }
+ }()
+ }
+}
+
+func TestLogRestore(t *testing.T) {
+ index := uint64(1000)
+ term := uint64(1000)
+ snap := pb.SnapshotMetadata{Index: index, Term: term}
+ storage := NewMemoryStorage()
+ storage.ApplySnapshot(pb.Snapshot{Metadata: snap})
+ raftLog := newLog(storage, raftLogger)
+
+ if len(raftLog.allEntries()) != 0 {
+ t.Errorf("len = %d, want 0", len(raftLog.allEntries()))
+ }
+ if raftLog.firstIndex() != index+1 {
+ t.Errorf("firstIndex = %d, want %d", raftLog.firstIndex(), index+1)
+ }
+ if raftLog.committed != index {
+ t.Errorf("committed = %d, want %d", raftLog.committed, index)
+ }
+ if raftLog.unstable.offset != index+1 {
+ t.Errorf("unstable = %d, want %d", raftLog.unstable.offset, index+1)
+ }
+ if mustTerm(raftLog.term(index)) != term {
+ t.Errorf("term = %d, want %d", mustTerm(raftLog.term(index)), term)
+ }
+}
+
+func TestIsOutOfBounds(t *testing.T) {
+ offset := uint64(100)
+ num := uint64(100)
+ storage := NewMemoryStorage()
+ storage.ApplySnapshot(pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: offset}})
+ l := newLog(storage, raftLogger)
+ for i := uint64(1); i <= num; i++ {
+ l.append(pb.Entry{Index: i + offset})
+ }
+
+ first := offset + 1
+ tests := []struct {
+ lo, hi uint64
+ wpanic bool
+ wErrCompacted bool
+ }{
+ {
+ first - 2, first + 1,
+ false,
+ true,
+ },
+ {
+ first - 1, first + 1,
+ false,
+ true,
+ },
+ {
+ first, first,
+ false,
+ false,
+ },
+ {
+ first + num/2, first + num/2,
+ false,
+ false,
+ },
+ {
+ first + num - 1, first + num - 1,
+ false,
+ false,
+ },
+ {
+ first + num, first + num,
+ false,
+ false,
+ },
+ {
+ first + num, first + num + 1,
+ true,
+ false,
+ },
+ {
+ first + num + 1, first + num + 1,
+ true,
+ false,
+ },
+ }
+
+ for i, tt := range tests {
+ func() {
+ defer func() {
+ if r := recover(); r != nil {
+ if !tt.wpanic {
+ t.Errorf("%d: panic = %v, want %v: %v", i, true, false, r)
+ }
+ }
+ }()
+ err := l.mustCheckOutOfBounds(tt.lo, tt.hi)
+ if tt.wpanic {
+ t.Errorf("%d: panic = %v, want %v", i, false, true)
+ }
+ if tt.wErrCompacted && err != ErrCompacted {
+ t.Errorf("%d: err = %v, want %v", i, err, ErrCompacted)
+ }
+ if !tt.wErrCompacted && err != nil {
+ t.Errorf("%d: unexpected err %v", i, err)
+ }
+ }()
+ }
+}
+
+func TestTerm(t *testing.T) {
+ var i uint64
+ offset := uint64(100)
+ num := uint64(100)
+
+ storage := NewMemoryStorage()
+ storage.ApplySnapshot(pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: offset, Term: 1}})
+ l := newLog(storage, raftLogger)
+ for i = 1; i < num; i++ {
+ l.append(pb.Entry{Index: offset + i, Term: i})
+ }
+
+ tests := []struct {
+ index uint64
+ w uint64
+ }{
+ {offset - 1, 0},
+ {offset, 1},
+ {offset + num/2, num / 2},
+ {offset + num - 1, num - 1},
+ {offset + num, 0},
+ }
+
+ for j, tt := range tests {
+ term := mustTerm(l.term(tt.index))
+ if term != tt.w {
+ t.Errorf("#%d: at = %d, want %d", j, term, tt.w)
+ }
+ }
+}
+
+func TestTermWithUnstableSnapshot(t *testing.T) {
+ storagesnapi := uint64(100)
+ unstablesnapi := storagesnapi + 5
+
+ storage := NewMemoryStorage()
+ storage.ApplySnapshot(pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: storagesnapi, Term: 1}})
+ l := newLog(storage, raftLogger)
+ l.restore(pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: unstablesnapi, Term: 1}})
+
+ tests := []struct {
+ index uint64
+ w uint64
+ }{
+ // cannot get term from storage
+ {storagesnapi, 0},
+ // cannot get term from the gap between storage ents and unstable snapshot
+ {storagesnapi + 1, 0},
+ {unstablesnapi - 1, 0},
+ // get term from unstable snapshot index
+ {unstablesnapi, 1},
+ }
+
+ for i, tt := range tests {
+ term := mustTerm(l.term(tt.index))
+ if term != tt.w {
+ t.Errorf("#%d: at = %d, want %d", i, term, tt.w)
+ }
+ }
+}
+
+func TestSlice(t *testing.T) {
+ var i uint64
+ offset := uint64(100)
+ num := uint64(100)
+ last := offset + num
+ half := offset + num/2
+ halfe := pb.Entry{Index: half, Term: half}
+
+ storage := NewMemoryStorage()
+ storage.ApplySnapshot(pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: offset}})
+ for i = 1; i < num/2; i++ {
+ storage.Append([]pb.Entry{{Index: offset + i, Term: offset + i}})
+ }
+ l := newLog(storage, raftLogger)
+ for i = num / 2; i < num; i++ {
+ l.append(pb.Entry{Index: offset + i, Term: offset + i})
+ }
+
+ tests := []struct {
+ from uint64
+ to uint64
+ limit uint64
+
+ w []pb.Entry
+ wpanic bool
+ }{
+ // test no limit
+ {offset - 1, offset + 1, noLimit, nil, false},
+ {offset, offset + 1, noLimit, nil, false},
+ {half - 1, half + 1, noLimit, []pb.Entry{{Index: half - 1, Term: half - 1}, {Index: half, Term: half}}, false},
+ {half, half + 1, noLimit, []pb.Entry{{Index: half, Term: half}}, false},
+ {last - 1, last, noLimit, []pb.Entry{{Index: last - 1, Term: last - 1}}, false},
+ {last, last + 1, noLimit, nil, true},
+
+ // test limit
+ {half - 1, half + 1, 0, []pb.Entry{{Index: half - 1, Term: half - 1}}, false},
+ {half - 1, half + 1, uint64(halfe.Size() + 1), []pb.Entry{{Index: half - 1, Term: half - 1}}, false},
+ {half - 2, half + 1, uint64(halfe.Size() + 1), []pb.Entry{{Index: half - 2, Term: half - 2}}, false},
+ {half - 1, half + 1, uint64(halfe.Size() * 2), []pb.Entry{{Index: half - 1, Term: half - 1}, {Index: half, Term: half}}, false},
+ {half - 1, half + 2, uint64(halfe.Size() * 3), []pb.Entry{{Index: half - 1, Term: half - 1}, {Index: half, Term: half}, {Index: half + 1, Term: half + 1}}, false},
+ {half, half + 2, uint64(halfe.Size()), []pb.Entry{{Index: half, Term: half}}, false},
+ {half, half + 2, uint64(halfe.Size() * 2), []pb.Entry{{Index: half, Term: half}, {Index: half + 1, Term: half + 1}}, false},
+ }
+
+ for j, tt := range tests {
+ func() {
+ defer func() {
+ if r := recover(); r != nil {
+ if !tt.wpanic {
+ t.Errorf("%d: panic = %v, want %v: %v", j, true, false, r)
+ }
+ }
+ }()
+ g, err := l.slice(tt.from, tt.to, tt.limit)
+ if tt.from <= offset && err != ErrCompacted {
+ t.Fatalf("#%d: err = %v, want %v", j, err, ErrCompacted)
+ }
+ if tt.from > offset && err != nil {
+ t.Fatalf("#%d: unexpected error %v", j, err)
+ }
+ if !reflect.DeepEqual(g, tt.w) {
+ t.Errorf("#%d: from %d to %d = %v, want %v", j, tt.from, tt.to, g, tt.w)
+ }
+ }()
+ }
+}
+
+func mustTerm(term uint64, err error) uint64 {
+ if err != nil {
+ panic(err)
+ }
+ return term
+}
diff --git a/vendor/github.com/coreos/etcd/raft/log_unstable.go b/vendor/github.com/coreos/etcd/raft/log_unstable.go
new file mode 100644
index 00000000..263af9ce
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/log_unstable.go
@@ -0,0 +1,159 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import pb "github.com/coreos/etcd/raft/raftpb"
+
+// unstable.entries[i] has raft log position i+unstable.offset.
+// Note that unstable.offset may be less than the highest log
+// position in storage; this means that the next write to storage
+// might need to truncate the log before persisting unstable.entries.
+type unstable struct {
+ // the incoming unstable snapshot, if any.
+ snapshot *pb.Snapshot
+ // all entries that have not yet been written to storage.
+ entries []pb.Entry
+ offset uint64
+
+ logger Logger
+}
+
+// maybeFirstIndex returns the index of the first possible entry in entries
+// if it has a snapshot.
+func (u *unstable) maybeFirstIndex() (uint64, bool) {
+ if u.snapshot != nil {
+ return u.snapshot.Metadata.Index + 1, true
+ }
+ return 0, false
+}
+
+// maybeLastIndex returns the last index if it has at least one
+// unstable entry or snapshot.
+func (u *unstable) maybeLastIndex() (uint64, bool) {
+ if l := len(u.entries); l != 0 {
+ return u.offset + uint64(l) - 1, true
+ }
+ if u.snapshot != nil {
+ return u.snapshot.Metadata.Index, true
+ }
+ return 0, false
+}
+
+// maybeTerm returns the term of the entry at index i, if there
+// is any.
+func (u *unstable) maybeTerm(i uint64) (uint64, bool) {
+ if i < u.offset {
+ if u.snapshot == nil {
+ return 0, false
+ }
+ if u.snapshot.Metadata.Index == i {
+ return u.snapshot.Metadata.Term, true
+ }
+ return 0, false
+ }
+
+ last, ok := u.maybeLastIndex()
+ if !ok {
+ return 0, false
+ }
+ if i > last {
+ return 0, false
+ }
+ return u.entries[i-u.offset].Term, true
+}
+
+func (u *unstable) stableTo(i, t uint64) {
+ gt, ok := u.maybeTerm(i)
+ if !ok {
+ return
+ }
+ // if i < offset, term is matched with the snapshot
+ // only update the unstable entries if term is matched with
+ // an unstable entry.
+ if gt == t && i >= u.offset {
+ u.entries = u.entries[i+1-u.offset:]
+ u.offset = i + 1
+ u.shrinkEntriesArray()
+ }
+}
+
+// shrinkEntriesArray discards the underlying array used by the entries slice
+// if most of it isn't being used. This avoids holding references to a bunch of
+// potentially large entries that aren't needed anymore. Simply clearing the
+// entries wouldn't be safe because clients might still be using them.
+func (u *unstable) shrinkEntriesArray() {
+ // We replace the array if we're using less than half of the space in
+ // it. This number is fairly arbitrary, chosen as an attempt to balance
+ // memory usage vs number of allocations. It could probably be improved
+ // with some focused tuning.
+ const lenMultiple = 2
+ if len(u.entries) == 0 {
+ u.entries = nil
+ } else if len(u.entries)*lenMultiple < cap(u.entries) {
+ newEntries := make([]pb.Entry, len(u.entries))
+ copy(newEntries, u.entries)
+ u.entries = newEntries
+ }
+}
+
+func (u *unstable) stableSnapTo(i uint64) {
+ if u.snapshot != nil && u.snapshot.Metadata.Index == i {
+ u.snapshot = nil
+ }
+}
+
+func (u *unstable) restore(s pb.Snapshot) {
+ u.offset = s.Metadata.Index + 1
+ u.entries = nil
+ u.snapshot = &s
+}
+
+func (u *unstable) truncateAndAppend(ents []pb.Entry) {
+ after := ents[0].Index
+ switch {
+ case after == u.offset+uint64(len(u.entries)):
+ // after is the next index in the u.entries
+ // directly append
+ u.entries = append(u.entries, ents...)
+ case after <= u.offset:
+ u.logger.Infof("replace the unstable entries from index %d", after)
+ // The log is being truncated to before our current offset
+ // portion, so set the offset and replace the entries
+ u.offset = after
+ u.entries = ents
+ default:
+ // truncate to after and copy to u.entries
+ // then append
+ u.logger.Infof("truncate the unstable entries before index %d", after)
+ u.entries = append([]pb.Entry{}, u.slice(u.offset, after)...)
+ u.entries = append(u.entries, ents...)
+ }
+}
+
+func (u *unstable) slice(lo uint64, hi uint64) []pb.Entry {
+ u.mustCheckOutOfBounds(lo, hi)
+ return u.entries[lo-u.offset : hi-u.offset]
+}
+
+// u.offset <= lo <= hi <= u.offset+len(u.offset)
+func (u *unstable) mustCheckOutOfBounds(lo, hi uint64) {
+ if lo > hi {
+ u.logger.Panicf("invalid unstable.slice %d > %d", lo, hi)
+ }
+ upper := u.offset + uint64(len(u.entries))
+ if lo < u.offset || hi > upper {
+ u.logger.Panicf("unstable.slice[%d,%d) out of bound [%d,%d]", lo, hi, u.offset, upper)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/raft/log_unstable_test.go b/vendor/github.com/coreos/etcd/raft/log_unstable_test.go
new file mode 100644
index 00000000..52cb9a20
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/log_unstable_test.go
@@ -0,0 +1,359 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "reflect"
+ "testing"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+func TestUnstableMaybeFirstIndex(t *testing.T) {
+ tests := []struct {
+ entries []pb.Entry
+ offset uint64
+ snap *pb.Snapshot
+
+ wok bool
+ windex uint64
+ }{
+ // no snapshot
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, nil,
+ false, 0,
+ },
+ {
+ []pb.Entry{}, 0, nil,
+ false, 0,
+ },
+ // has snapshot
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
+ true, 5,
+ },
+ {
+ []pb.Entry{}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
+ true, 5,
+ },
+ }
+
+ for i, tt := range tests {
+ u := unstable{
+ entries: tt.entries,
+ offset: tt.offset,
+ snapshot: tt.snap,
+ logger: raftLogger,
+ }
+ index, ok := u.maybeFirstIndex()
+ if ok != tt.wok {
+ t.Errorf("#%d: ok = %t, want %t", i, ok, tt.wok)
+ }
+ if index != tt.windex {
+ t.Errorf("#%d: index = %d, want %d", i, index, tt.windex)
+ }
+ }
+}
+
+func TestMaybeLastIndex(t *testing.T) {
+ tests := []struct {
+ entries []pb.Entry
+ offset uint64
+ snap *pb.Snapshot
+
+ wok bool
+ windex uint64
+ }{
+ // last in entries
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, nil,
+ true, 5,
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
+ true, 5,
+ },
+ // last in snapshot
+ {
+ []pb.Entry{}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
+ true, 4,
+ },
+ // empty unstable
+ {
+ []pb.Entry{}, 0, nil,
+ false, 0,
+ },
+ }
+
+ for i, tt := range tests {
+ u := unstable{
+ entries: tt.entries,
+ offset: tt.offset,
+ snapshot: tt.snap,
+ logger: raftLogger,
+ }
+ index, ok := u.maybeLastIndex()
+ if ok != tt.wok {
+ t.Errorf("#%d: ok = %t, want %t", i, ok, tt.wok)
+ }
+ if index != tt.windex {
+ t.Errorf("#%d: index = %d, want %d", i, index, tt.windex)
+ }
+ }
+}
+
+func TestUnstableMaybeTerm(t *testing.T) {
+ tests := []struct {
+ entries []pb.Entry
+ offset uint64
+ snap *pb.Snapshot
+ index uint64
+
+ wok bool
+ wterm uint64
+ }{
+ // term from entries
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, nil,
+ 5,
+ true, 1,
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, nil,
+ 6,
+ false, 0,
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, nil,
+ 4,
+ false, 0,
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
+ 5,
+ true, 1,
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
+ 6,
+ false, 0,
+ },
+ // term from snapshot
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
+ 4,
+ true, 1,
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
+ 3,
+ false, 0,
+ },
+ {
+ []pb.Entry{}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
+ 5,
+ false, 0,
+ },
+ {
+ []pb.Entry{}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
+ 4,
+ true, 1,
+ },
+ {
+ []pb.Entry{}, 0, nil,
+ 5,
+ false, 0,
+ },
+ }
+
+ for i, tt := range tests {
+ u := unstable{
+ entries: tt.entries,
+ offset: tt.offset,
+ snapshot: tt.snap,
+ logger: raftLogger,
+ }
+ term, ok := u.maybeTerm(tt.index)
+ if ok != tt.wok {
+ t.Errorf("#%d: ok = %t, want %t", i, ok, tt.wok)
+ }
+ if term != tt.wterm {
+ t.Errorf("#%d: term = %d, want %d", i, term, tt.wterm)
+ }
+ }
+}
+
+func TestUnstableRestore(t *testing.T) {
+ u := unstable{
+ entries: []pb.Entry{{Index: 5, Term: 1}},
+ offset: 5,
+ snapshot: &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
+ logger: raftLogger,
+ }
+ s := pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 6, Term: 2}}
+ u.restore(s)
+
+ if u.offset != s.Metadata.Index+1 {
+ t.Errorf("offset = %d, want %d", u.offset, s.Metadata.Index+1)
+ }
+ if len(u.entries) != 0 {
+ t.Errorf("len = %d, want 0", len(u.entries))
+ }
+ if !reflect.DeepEqual(u.snapshot, &s) {
+ t.Errorf("snap = %v, want %v", u.snapshot, &s)
+ }
+}
+
+func TestUnstableStableTo(t *testing.T) {
+ tests := []struct {
+ entries []pb.Entry
+ offset uint64
+ snap *pb.Snapshot
+ index, term uint64
+
+ woffset uint64
+ wlen int
+ }{
+ {
+ []pb.Entry{}, 0, nil,
+ 5, 1,
+ 0, 0,
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, nil,
+ 5, 1, // stable to the first entry
+ 6, 0,
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 1}, {Index: 6, Term: 1}}, 5, nil,
+ 5, 1, // stable to the first entry
+ 6, 1,
+ },
+ {
+ []pb.Entry{{Index: 6, Term: 2}}, 6, nil,
+ 6, 1, // stable to the first entry and term mismatch
+ 6, 1,
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, nil,
+ 4, 1, // stable to old entry
+ 5, 1,
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, nil,
+ 4, 2, // stable to old entry
+ 5, 1,
+ },
+ // with snapshot
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
+ 5, 1, // stable to the first entry
+ 6, 0,
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 1}, {Index: 6, Term: 1}}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
+ 5, 1, // stable to the first entry
+ 6, 1,
+ },
+ {
+ []pb.Entry{{Index: 6, Term: 2}}, 6, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 5, Term: 1}},
+ 6, 1, // stable to the first entry and term mismatch
+ 6, 1,
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 1}},
+ 4, 1, // stable to snapshot
+ 5, 1,
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 2}}, 5, &pb.Snapshot{Metadata: pb.SnapshotMetadata{Index: 4, Term: 2}},
+ 4, 1, // stable to old entry
+ 5, 1,
+ },
+ }
+
+ for i, tt := range tests {
+ u := unstable{
+ entries: tt.entries,
+ offset: tt.offset,
+ snapshot: tt.snap,
+ logger: raftLogger,
+ }
+ u.stableTo(tt.index, tt.term)
+ if u.offset != tt.woffset {
+ t.Errorf("#%d: offset = %d, want %d", i, u.offset, tt.woffset)
+ }
+ if len(u.entries) != tt.wlen {
+ t.Errorf("#%d: len = %d, want %d", i, len(u.entries), tt.wlen)
+ }
+ }
+}
+
+func TestUnstableTruncateAndAppend(t *testing.T) {
+ tests := []struct {
+ entries []pb.Entry
+ offset uint64
+ snap *pb.Snapshot
+ toappend []pb.Entry
+
+ woffset uint64
+ wentries []pb.Entry
+ }{
+ // append to the end
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, nil,
+ []pb.Entry{{Index: 6, Term: 1}, {Index: 7, Term: 1}},
+ 5, []pb.Entry{{Index: 5, Term: 1}, {Index: 6, Term: 1}, {Index: 7, Term: 1}},
+ },
+ // replace the unstable entries
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, nil,
+ []pb.Entry{{Index: 5, Term: 2}, {Index: 6, Term: 2}},
+ 5, []pb.Entry{{Index: 5, Term: 2}, {Index: 6, Term: 2}},
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 1}}, 5, nil,
+ []pb.Entry{{Index: 4, Term: 2}, {Index: 5, Term: 2}, {Index: 6, Term: 2}},
+ 4, []pb.Entry{{Index: 4, Term: 2}, {Index: 5, Term: 2}, {Index: 6, Term: 2}},
+ },
+ // truncate the existing entries and append
+ {
+ []pb.Entry{{Index: 5, Term: 1}, {Index: 6, Term: 1}, {Index: 7, Term: 1}}, 5, nil,
+ []pb.Entry{{Index: 6, Term: 2}},
+ 5, []pb.Entry{{Index: 5, Term: 1}, {Index: 6, Term: 2}},
+ },
+ {
+ []pb.Entry{{Index: 5, Term: 1}, {Index: 6, Term: 1}, {Index: 7, Term: 1}}, 5, nil,
+ []pb.Entry{{Index: 7, Term: 2}, {Index: 8, Term: 2}},
+ 5, []pb.Entry{{Index: 5, Term: 1}, {Index: 6, Term: 1}, {Index: 7, Term: 2}, {Index: 8, Term: 2}},
+ },
+ }
+
+ for i, tt := range tests {
+ u := unstable{
+ entries: tt.entries,
+ offset: tt.offset,
+ snapshot: tt.snap,
+ logger: raftLogger,
+ }
+ u.truncateAndAppend(tt.toappend)
+ if u.offset != tt.woffset {
+ t.Errorf("#%d: offset = %d, want %d", i, u.offset, tt.woffset)
+ }
+ if !reflect.DeepEqual(u.entries, tt.wentries) {
+ t.Errorf("#%d: entries = %v, want %v", i, u.entries, tt.wentries)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/raft/logger.go b/vendor/github.com/coreos/etcd/raft/logger.go
new file mode 100644
index 00000000..92e55b37
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/logger.go
@@ -0,0 +1,126 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "fmt"
+ "io/ioutil"
+ "log"
+ "os"
+)
+
+type Logger interface {
+ Debug(v ...interface{})
+ Debugf(format string, v ...interface{})
+
+ Error(v ...interface{})
+ Errorf(format string, v ...interface{})
+
+ Info(v ...interface{})
+ Infof(format string, v ...interface{})
+
+ Warning(v ...interface{})
+ Warningf(format string, v ...interface{})
+
+ Fatal(v ...interface{})
+ Fatalf(format string, v ...interface{})
+
+ Panic(v ...interface{})
+ Panicf(format string, v ...interface{})
+}
+
+func SetLogger(l Logger) { raftLogger = l }
+
+var (
+ defaultLogger = &DefaultLogger{Logger: log.New(os.Stderr, "raft", log.LstdFlags)}
+ discardLogger = &DefaultLogger{Logger: log.New(ioutil.Discard, "", 0)}
+ raftLogger = Logger(defaultLogger)
+)
+
+const (
+ calldepth = 2
+)
+
+// DefaultLogger is a default implementation of the Logger interface.
+type DefaultLogger struct {
+ *log.Logger
+ debug bool
+}
+
+func (l *DefaultLogger) EnableTimestamps() {
+ l.SetFlags(l.Flags() | log.Ldate | log.Ltime)
+}
+
+func (l *DefaultLogger) EnableDebug() {
+ l.debug = true
+}
+
+func (l *DefaultLogger) Debug(v ...interface{}) {
+ if l.debug {
+ l.Output(calldepth, header("DEBUG", fmt.Sprint(v...)))
+ }
+}
+
+func (l *DefaultLogger) Debugf(format string, v ...interface{}) {
+ if l.debug {
+ l.Output(calldepth, header("DEBUG", fmt.Sprintf(format, v...)))
+ }
+}
+
+func (l *DefaultLogger) Info(v ...interface{}) {
+ l.Output(calldepth, header("INFO", fmt.Sprint(v...)))
+}
+
+func (l *DefaultLogger) Infof(format string, v ...interface{}) {
+ l.Output(calldepth, header("INFO", fmt.Sprintf(format, v...)))
+}
+
+func (l *DefaultLogger) Error(v ...interface{}) {
+ l.Output(calldepth, header("ERROR", fmt.Sprint(v...)))
+}
+
+func (l *DefaultLogger) Errorf(format string, v ...interface{}) {
+ l.Output(calldepth, header("ERROR", fmt.Sprintf(format, v...)))
+}
+
+func (l *DefaultLogger) Warning(v ...interface{}) {
+ l.Output(calldepth, header("WARN", fmt.Sprint(v...)))
+}
+
+func (l *DefaultLogger) Warningf(format string, v ...interface{}) {
+ l.Output(calldepth, header("WARN", fmt.Sprintf(format, v...)))
+}
+
+func (l *DefaultLogger) Fatal(v ...interface{}) {
+ l.Output(calldepth, header("FATAL", fmt.Sprint(v...)))
+ os.Exit(1)
+}
+
+func (l *DefaultLogger) Fatalf(format string, v ...interface{}) {
+ l.Output(calldepth, header("FATAL", fmt.Sprintf(format, v...)))
+ os.Exit(1)
+}
+
+func (l *DefaultLogger) Panic(v ...interface{}) {
+ l.Logger.Panic(v)
+}
+
+func (l *DefaultLogger) Panicf(format string, v ...interface{}) {
+ l.Logger.Panicf(format, v...)
+}
+
+func header(lvl, msg string) string {
+ return fmt.Sprintf("%s: %s", lvl, msg)
+}
diff --git a/vendor/github.com/coreos/etcd/raft/node.go b/vendor/github.com/coreos/etcd/raft/node.go
new file mode 100644
index 00000000..5da1c119
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/node.go
@@ -0,0 +1,537 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "errors"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+ "golang.org/x/net/context"
+)
+
+type SnapshotStatus int
+
+const (
+ SnapshotFinish SnapshotStatus = 1
+ SnapshotFailure SnapshotStatus = 2
+)
+
+var (
+ emptyState = pb.HardState{}
+
+ // ErrStopped is returned by methods on Nodes that have been stopped.
+ ErrStopped = errors.New("raft: stopped")
+)
+
+// SoftState provides state that is useful for logging and debugging.
+// The state is volatile and does not need to be persisted to the WAL.
+type SoftState struct {
+ Lead uint64 // must use atomic operations to access; keep 64-bit aligned.
+ RaftState StateType
+}
+
+func (a *SoftState) equal(b *SoftState) bool {
+ return a.Lead == b.Lead && a.RaftState == b.RaftState
+}
+
+// Ready encapsulates the entries and messages that are ready to read,
+// be saved to stable storage, committed or sent to other peers.
+// All fields in Ready are read-only.
+type Ready struct {
+ // The current volatile state of a Node.
+ // SoftState will be nil if there is no update.
+ // It is not required to consume or store SoftState.
+ *SoftState
+
+ // The current state of a Node to be saved to stable storage BEFORE
+ // Messages are sent.
+ // HardState will be equal to empty state if there is no update.
+ pb.HardState
+
+ // ReadStates can be used for node to serve linearizable read requests locally
+ // when its applied index is greater than the index in ReadState.
+ // Note that the readState will be returned when raft receives msgReadIndex.
+ // The returned is only valid for the request that requested to read.
+ ReadStates []ReadState
+
+ // Entries specifies entries to be saved to stable storage BEFORE
+ // Messages are sent.
+ Entries []pb.Entry
+
+ // Snapshot specifies the snapshot to be saved to stable storage.
+ Snapshot pb.Snapshot
+
+ // CommittedEntries specifies entries to be committed to a
+ // store/state-machine. These have previously been committed to stable
+ // store.
+ CommittedEntries []pb.Entry
+
+ // Messages specifies outbound messages to be sent AFTER Entries are
+ // committed to stable storage.
+ // If it contains a MsgSnap message, the application MUST report back to raft
+ // when the snapshot has been received or has failed by calling ReportSnapshot.
+ Messages []pb.Message
+
+ // MustSync indicates whether the HardState and Entries must be synchronously
+ // written to disk or if an asynchronous write is permissible.
+ MustSync bool
+}
+
+func isHardStateEqual(a, b pb.HardState) bool {
+ return a.Term == b.Term && a.Vote == b.Vote && a.Commit == b.Commit
+}
+
+// IsEmptyHardState returns true if the given HardState is empty.
+func IsEmptyHardState(st pb.HardState) bool {
+ return isHardStateEqual(st, emptyState)
+}
+
+// IsEmptySnap returns true if the given Snapshot is empty.
+func IsEmptySnap(sp pb.Snapshot) bool {
+ return sp.Metadata.Index == 0
+}
+
+func (rd Ready) containsUpdates() bool {
+ return rd.SoftState != nil || !IsEmptyHardState(rd.HardState) ||
+ !IsEmptySnap(rd.Snapshot) || len(rd.Entries) > 0 ||
+ len(rd.CommittedEntries) > 0 || len(rd.Messages) > 0 || len(rd.ReadStates) != 0
+}
+
+// Node represents a node in a raft cluster.
+type Node interface {
+ // Tick increments the internal logical clock for the Node by a single tick. Election
+ // timeouts and heartbeat timeouts are in units of ticks.
+ Tick()
+ // Campaign causes the Node to transition to candidate state and start campaigning to become leader.
+ Campaign(ctx context.Context) error
+ // Propose proposes that data be appended to the log.
+ Propose(ctx context.Context, data []byte) error
+ // ProposeConfChange proposes config change.
+ // At most one ConfChange can be in the process of going through consensus.
+ // Application needs to call ApplyConfChange when applying EntryConfChange type entry.
+ ProposeConfChange(ctx context.Context, cc pb.ConfChange) error
+ // Step advances the state machine using the given message. ctx.Err() will be returned, if any.
+ Step(ctx context.Context, msg pb.Message) error
+
+ // Ready returns a channel that returns the current point-in-time state.
+ // Users of the Node must call Advance after retrieving the state returned by Ready.
+ //
+ // NOTE: No committed entries from the next Ready may be applied until all committed entries
+ // and snapshots from the previous one have finished.
+ Ready() <-chan Ready
+
+ // Advance notifies the Node that the application has saved progress up to the last Ready.
+ // It prepares the node to return the next available Ready.
+ //
+ // The application should generally call Advance after it applies the entries in last Ready.
+ //
+ // However, as an optimization, the application may call Advance while it is applying the
+ // commands. For example. when the last Ready contains a snapshot, the application might take
+ // a long time to apply the snapshot data. To continue receiving Ready without blocking raft
+ // progress, it can call Advance before finishing applying the last ready.
+ Advance()
+ // ApplyConfChange applies config change to the local node.
+ // Returns an opaque ConfState protobuf which must be recorded
+ // in snapshots. Will never return nil; it returns a pointer only
+ // to match MemoryStorage.Compact.
+ ApplyConfChange(cc pb.ConfChange) *pb.ConfState
+
+ // TransferLeadership attempts to transfer leadership to the given transferee.
+ TransferLeadership(ctx context.Context, lead, transferee uint64)
+
+ // ReadIndex request a read state. The read state will be set in the ready.
+ // Read state has a read index. Once the application advances further than the read
+ // index, any linearizable read requests issued before the read request can be
+ // processed safely. The read state will have the same rctx attached.
+ ReadIndex(ctx context.Context, rctx []byte) error
+
+ // Status returns the current status of the raft state machine.
+ Status() Status
+ // ReportUnreachable reports the given node is not reachable for the last send.
+ ReportUnreachable(id uint64)
+ // ReportSnapshot reports the status of the sent snapshot.
+ ReportSnapshot(id uint64, status SnapshotStatus)
+ // Stop performs any necessary termination of the Node.
+ Stop()
+}
+
+type Peer struct {
+ ID uint64
+ Context []byte
+}
+
+// StartNode returns a new Node given configuration and a list of raft peers.
+// It appends a ConfChangeAddNode entry for each given peer to the initial log.
+func StartNode(c *Config, peers []Peer) Node {
+ r := newRaft(c)
+ // become the follower at term 1 and apply initial configuration
+ // entries of term 1
+ r.becomeFollower(1, None)
+ for _, peer := range peers {
+ cc := pb.ConfChange{Type: pb.ConfChangeAddNode, NodeID: peer.ID, Context: peer.Context}
+ d, err := cc.Marshal()
+ if err != nil {
+ panic("unexpected marshal error")
+ }
+ e := pb.Entry{Type: pb.EntryConfChange, Term: 1, Index: r.raftLog.lastIndex() + 1, Data: d}
+ r.raftLog.append(e)
+ }
+ // Mark these initial entries as committed.
+ // TODO(bdarnell): These entries are still unstable; do we need to preserve
+ // the invariant that committed < unstable?
+ r.raftLog.committed = r.raftLog.lastIndex()
+ // Now apply them, mainly so that the application can call Campaign
+ // immediately after StartNode in tests. Note that these nodes will
+ // be added to raft twice: here and when the application's Ready
+ // loop calls ApplyConfChange. The calls to addNode must come after
+ // all calls to raftLog.append so progress.next is set after these
+ // bootstrapping entries (it is an error if we try to append these
+ // entries since they have already been committed).
+ // We do not set raftLog.applied so the application will be able
+ // to observe all conf changes via Ready.CommittedEntries.
+ for _, peer := range peers {
+ r.addNode(peer.ID)
+ }
+
+ n := newNode()
+ n.logger = c.Logger
+ go n.run(r)
+ return &n
+}
+
+// RestartNode is similar to StartNode but does not take a list of peers.
+// The current membership of the cluster will be restored from the Storage.
+// If the caller has an existing state machine, pass in the last log index that
+// has been applied to it; otherwise use zero.
+func RestartNode(c *Config) Node {
+ r := newRaft(c)
+
+ n := newNode()
+ n.logger = c.Logger
+ go n.run(r)
+ return &n
+}
+
+// node is the canonical implementation of the Node interface
+type node struct {
+ propc chan pb.Message
+ recvc chan pb.Message
+ confc chan pb.ConfChange
+ confstatec chan pb.ConfState
+ readyc chan Ready
+ advancec chan struct{}
+ tickc chan struct{}
+ done chan struct{}
+ stop chan struct{}
+ status chan chan Status
+
+ logger Logger
+}
+
+func newNode() node {
+ return node{
+ propc: make(chan pb.Message),
+ recvc: make(chan pb.Message),
+ confc: make(chan pb.ConfChange),
+ confstatec: make(chan pb.ConfState),
+ readyc: make(chan Ready),
+ advancec: make(chan struct{}),
+ // make tickc a buffered chan, so raft node can buffer some ticks when the node
+ // is busy processing raft messages. Raft node will resume process buffered
+ // ticks when it becomes idle.
+ tickc: make(chan struct{}, 128),
+ done: make(chan struct{}),
+ stop: make(chan struct{}),
+ status: make(chan chan Status),
+ }
+}
+
+func (n *node) Stop() {
+ select {
+ case n.stop <- struct{}{}:
+ // Not already stopped, so trigger it
+ case <-n.done:
+ // Node has already been stopped - no need to do anything
+ return
+ }
+ // Block until the stop has been acknowledged by run()
+ <-n.done
+}
+
+func (n *node) run(r *raft) {
+ var propc chan pb.Message
+ var readyc chan Ready
+ var advancec chan struct{}
+ var prevLastUnstablei, prevLastUnstablet uint64
+ var havePrevLastUnstablei bool
+ var prevSnapi uint64
+ var rd Ready
+
+ lead := None
+ prevSoftSt := r.softState()
+ prevHardSt := emptyState
+
+ for {
+ if advancec != nil {
+ readyc = nil
+ } else {
+ rd = newReady(r, prevSoftSt, prevHardSt)
+ if rd.containsUpdates() {
+ readyc = n.readyc
+ } else {
+ readyc = nil
+ }
+ }
+
+ if lead != r.lead {
+ if r.hasLeader() {
+ if lead == None {
+ r.logger.Infof("raft.node: %x elected leader %x at term %d", r.id, r.lead, r.Term)
+ } else {
+ r.logger.Infof("raft.node: %x changed leader from %x to %x at term %d", r.id, lead, r.lead, r.Term)
+ }
+ propc = n.propc
+ } else {
+ r.logger.Infof("raft.node: %x lost leader %x at term %d", r.id, lead, r.Term)
+ propc = nil
+ }
+ lead = r.lead
+ }
+
+ select {
+ // TODO: maybe buffer the config propose if there exists one (the way
+ // described in raft dissertation)
+ // Currently it is dropped in Step silently.
+ case m := <-propc:
+ m.From = r.id
+ r.Step(m)
+ case m := <-n.recvc:
+ // filter out response message from unknown From.
+ if _, ok := r.prs[m.From]; ok || !IsResponseMsg(m.Type) {
+ r.Step(m) // raft never returns an error
+ }
+ case cc := <-n.confc:
+ if cc.NodeID == None {
+ r.resetPendingConf()
+ select {
+ case n.confstatec <- pb.ConfState{Nodes: r.nodes()}:
+ case <-n.done:
+ }
+ break
+ }
+ switch cc.Type {
+ case pb.ConfChangeAddNode:
+ r.addNode(cc.NodeID)
+ case pb.ConfChangeRemoveNode:
+ // block incoming proposal when local node is
+ // removed
+ if cc.NodeID == r.id {
+ propc = nil
+ }
+ r.removeNode(cc.NodeID)
+ case pb.ConfChangeUpdateNode:
+ r.resetPendingConf()
+ default:
+ panic("unexpected conf type")
+ }
+ select {
+ case n.confstatec <- pb.ConfState{Nodes: r.nodes()}:
+ case <-n.done:
+ }
+ case <-n.tickc:
+ r.tick()
+ case readyc <- rd:
+ if rd.SoftState != nil {
+ prevSoftSt = rd.SoftState
+ }
+ if len(rd.Entries) > 0 {
+ prevLastUnstablei = rd.Entries[len(rd.Entries)-1].Index
+ prevLastUnstablet = rd.Entries[len(rd.Entries)-1].Term
+ havePrevLastUnstablei = true
+ }
+ if !IsEmptyHardState(rd.HardState) {
+ prevHardSt = rd.HardState
+ }
+ if !IsEmptySnap(rd.Snapshot) {
+ prevSnapi = rd.Snapshot.Metadata.Index
+ }
+
+ r.msgs = nil
+ r.readStates = nil
+ advancec = n.advancec
+ case <-advancec:
+ if prevHardSt.Commit != 0 {
+ r.raftLog.appliedTo(prevHardSt.Commit)
+ }
+ if havePrevLastUnstablei {
+ r.raftLog.stableTo(prevLastUnstablei, prevLastUnstablet)
+ havePrevLastUnstablei = false
+ }
+ r.raftLog.stableSnapTo(prevSnapi)
+ advancec = nil
+ case c := <-n.status:
+ c <- getStatus(r)
+ case <-n.stop:
+ close(n.done)
+ return
+ }
+ }
+}
+
+// Tick increments the internal logical clock for this Node. Election timeouts
+// and heartbeat timeouts are in units of ticks.
+func (n *node) Tick() {
+ select {
+ case n.tickc <- struct{}{}:
+ case <-n.done:
+ default:
+ n.logger.Warningf("A tick missed to fire. Node blocks too long!")
+ }
+}
+
+func (n *node) Campaign(ctx context.Context) error { return n.step(ctx, pb.Message{Type: pb.MsgHup}) }
+
+func (n *node) Propose(ctx context.Context, data []byte) error {
+ return n.step(ctx, pb.Message{Type: pb.MsgProp, Entries: []pb.Entry{{Data: data}}})
+}
+
+func (n *node) Step(ctx context.Context, m pb.Message) error {
+ // ignore unexpected local messages receiving over network
+ if IsLocalMsg(m.Type) {
+ // TODO: return an error?
+ return nil
+ }
+ return n.step(ctx, m)
+}
+
+func (n *node) ProposeConfChange(ctx context.Context, cc pb.ConfChange) error {
+ data, err := cc.Marshal()
+ if err != nil {
+ return err
+ }
+ return n.Step(ctx, pb.Message{Type: pb.MsgProp, Entries: []pb.Entry{{Type: pb.EntryConfChange, Data: data}}})
+}
+
+// Step advances the state machine using msgs. The ctx.Err() will be returned,
+// if any.
+func (n *node) step(ctx context.Context, m pb.Message) error {
+ ch := n.recvc
+ if m.Type == pb.MsgProp {
+ ch = n.propc
+ }
+
+ select {
+ case ch <- m:
+ return nil
+ case <-ctx.Done():
+ return ctx.Err()
+ case <-n.done:
+ return ErrStopped
+ }
+}
+
+func (n *node) Ready() <-chan Ready { return n.readyc }
+
+func (n *node) Advance() {
+ select {
+ case n.advancec <- struct{}{}:
+ case <-n.done:
+ }
+}
+
+func (n *node) ApplyConfChange(cc pb.ConfChange) *pb.ConfState {
+ var cs pb.ConfState
+ select {
+ case n.confc <- cc:
+ case <-n.done:
+ }
+ select {
+ case cs = <-n.confstatec:
+ case <-n.done:
+ }
+ return &cs
+}
+
+func (n *node) Status() Status {
+ c := make(chan Status)
+ select {
+ case n.status <- c:
+ return <-c
+ case <-n.done:
+ return Status{}
+ }
+}
+
+func (n *node) ReportUnreachable(id uint64) {
+ select {
+ case n.recvc <- pb.Message{Type: pb.MsgUnreachable, From: id}:
+ case <-n.done:
+ }
+}
+
+func (n *node) ReportSnapshot(id uint64, status SnapshotStatus) {
+ rej := status == SnapshotFailure
+
+ select {
+ case n.recvc <- pb.Message{Type: pb.MsgSnapStatus, From: id, Reject: rej}:
+ case <-n.done:
+ }
+}
+
+func (n *node) TransferLeadership(ctx context.Context, lead, transferee uint64) {
+ select {
+ // manually set 'from' and 'to', so that leader can voluntarily transfers its leadership
+ case n.recvc <- pb.Message{Type: pb.MsgTransferLeader, From: transferee, To: lead}:
+ case <-n.done:
+ case <-ctx.Done():
+ }
+}
+
+func (n *node) ReadIndex(ctx context.Context, rctx []byte) error {
+ return n.step(ctx, pb.Message{Type: pb.MsgReadIndex, Entries: []pb.Entry{{Data: rctx}}})
+}
+
+func newReady(r *raft, prevSoftSt *SoftState, prevHardSt pb.HardState) Ready {
+ rd := Ready{
+ Entries: r.raftLog.unstableEntries(),
+ CommittedEntries: r.raftLog.nextEnts(),
+ Messages: r.msgs,
+ }
+ if softSt := r.softState(); !softSt.equal(prevSoftSt) {
+ rd.SoftState = softSt
+ }
+ if hardSt := r.hardState(); !isHardStateEqual(hardSt, prevHardSt) {
+ rd.HardState = hardSt
+ }
+ if r.raftLog.unstable.snapshot != nil {
+ rd.Snapshot = *r.raftLog.unstable.snapshot
+ }
+ if len(r.readStates) != 0 {
+ rd.ReadStates = r.readStates
+ }
+ rd.MustSync = MustSync(rd.HardState, prevHardSt, len(rd.Entries))
+ return rd
+}
+
+// MustSync returns true if the hard state and count of Raft entries indicate
+// that a synchronous write to persistent storage is required.
+func MustSync(st, prevst pb.HardState, entsnum int) bool {
+ // Persistent state on all servers:
+ // (Updated on stable storage before responding to RPCs)
+ // currentTerm
+ // votedFor
+ // log entries[]
+ return entsnum != 0 || st.Vote != prevst.Vote || st.Term != prevst.Term
+}
diff --git a/vendor/github.com/coreos/etcd/raft/node_bench_test.go b/vendor/github.com/coreos/etcd/raft/node_bench_test.go
new file mode 100644
index 00000000..4e60634a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/node_bench_test.go
@@ -0,0 +1,52 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "testing"
+ "time"
+
+ "golang.org/x/net/context"
+)
+
+func BenchmarkOneNode(b *testing.B) {
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+
+ n := newNode()
+ s := NewMemoryStorage()
+ r := newTestRaft(1, []uint64{1}, 10, 1, s)
+ go n.run(r)
+
+ defer n.Stop()
+
+ n.Campaign(ctx)
+ go func() {
+ for i := 0; i < b.N; i++ {
+ n.Propose(ctx, []byte("foo"))
+ }
+ }()
+
+ for {
+ rd := <-n.Ready()
+ s.Append(rd.Entries)
+ // a reasonable disk sync latency
+ time.Sleep(1 * time.Millisecond)
+ n.Advance()
+ if rd.HardState.Commit == uint64(b.N+1) {
+ return
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/raft/node_test.go b/vendor/github.com/coreos/etcd/raft/node_test.go
new file mode 100644
index 00000000..c57fd05f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/node_test.go
@@ -0,0 +1,698 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "bytes"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/raft/raftpb"
+ "golang.org/x/net/context"
+)
+
+// TestNodeStep ensures that node.Step sends msgProp to propc chan
+// and other kinds of messages to recvc chan.
+func TestNodeStep(t *testing.T) {
+ for i, msgn := range raftpb.MessageType_name {
+ n := &node{
+ propc: make(chan raftpb.Message, 1),
+ recvc: make(chan raftpb.Message, 1),
+ }
+ msgt := raftpb.MessageType(i)
+ n.Step(context.TODO(), raftpb.Message{Type: msgt})
+ // Proposal goes to proc chan. Others go to recvc chan.
+ if msgt == raftpb.MsgProp {
+ select {
+ case <-n.propc:
+ default:
+ t.Errorf("%d: cannot receive %s on propc chan", msgt, msgn)
+ }
+ } else {
+ if IsLocalMsg(msgt) {
+ select {
+ case <-n.recvc:
+ t.Errorf("%d: step should ignore %s", msgt, msgn)
+ default:
+ }
+ } else {
+ select {
+ case <-n.recvc:
+ default:
+ t.Errorf("%d: cannot receive %s on recvc chan", msgt, msgn)
+ }
+ }
+ }
+ }
+}
+
+// Cancel and Stop should unblock Step()
+func TestNodeStepUnblock(t *testing.T) {
+ // a node without buffer to block step
+ n := &node{
+ propc: make(chan raftpb.Message),
+ done: make(chan struct{}),
+ }
+
+ ctx, cancel := context.WithCancel(context.Background())
+ stopFunc := func() { close(n.done) }
+
+ tests := []struct {
+ unblock func()
+ werr error
+ }{
+ {stopFunc, ErrStopped},
+ {cancel, context.Canceled},
+ }
+
+ for i, tt := range tests {
+ errc := make(chan error, 1)
+ go func() {
+ err := n.Step(ctx, raftpb.Message{Type: raftpb.MsgProp})
+ errc <- err
+ }()
+ tt.unblock()
+ select {
+ case err := <-errc:
+ if err != tt.werr {
+ t.Errorf("#%d: err = %v, want %v", i, err, tt.werr)
+ }
+ //clean up side-effect
+ if ctx.Err() != nil {
+ ctx = context.TODO()
+ }
+ select {
+ case <-n.done:
+ n.done = make(chan struct{})
+ default:
+ }
+ case <-time.After(1 * time.Second):
+ t.Fatalf("#%d: failed to unblock step", i)
+ }
+ }
+}
+
+// TestNodePropose ensures that node.Propose sends the given proposal to the underlying raft.
+func TestNodePropose(t *testing.T) {
+ msgs := []raftpb.Message{}
+ appendStep := func(r *raft, m raftpb.Message) {
+ msgs = append(msgs, m)
+ }
+
+ n := newNode()
+ s := NewMemoryStorage()
+ r := newTestRaft(1, []uint64{1}, 10, 1, s)
+ go n.run(r)
+ n.Campaign(context.TODO())
+ for {
+ rd := <-n.Ready()
+ s.Append(rd.Entries)
+ // change the step function to appendStep until this raft becomes leader
+ if rd.SoftState.Lead == r.id {
+ r.step = appendStep
+ n.Advance()
+ break
+ }
+ n.Advance()
+ }
+ n.Propose(context.TODO(), []byte("somedata"))
+ n.Stop()
+
+ if len(msgs) != 1 {
+ t.Fatalf("len(msgs) = %d, want %d", len(msgs), 1)
+ }
+ if msgs[0].Type != raftpb.MsgProp {
+ t.Errorf("msg type = %d, want %d", msgs[0].Type, raftpb.MsgProp)
+ }
+ if !bytes.Equal(msgs[0].Entries[0].Data, []byte("somedata")) {
+ t.Errorf("data = %v, want %v", msgs[0].Entries[0].Data, []byte("somedata"))
+ }
+}
+
+// TestNodeReadIndex ensures that node.ReadIndex sends the MsgReadIndex message to the underlying raft.
+// It also ensures that ReadState can be read out through ready chan.
+func TestNodeReadIndex(t *testing.T) {
+ msgs := []raftpb.Message{}
+ appendStep := func(r *raft, m raftpb.Message) {
+ msgs = append(msgs, m)
+ }
+ wrs := []ReadState{{Index: uint64(1), RequestCtx: []byte("somedata")}}
+
+ n := newNode()
+ s := NewMemoryStorage()
+ r := newTestRaft(1, []uint64{1}, 10, 1, s)
+ r.readStates = wrs
+
+ go n.run(r)
+ n.Campaign(context.TODO())
+ for {
+ rd := <-n.Ready()
+ if !reflect.DeepEqual(rd.ReadStates, wrs) {
+ t.Errorf("ReadStates = %v, want %v", rd.ReadStates, wrs)
+ }
+
+ s.Append(rd.Entries)
+
+ if rd.SoftState.Lead == r.id {
+ n.Advance()
+ break
+ }
+ n.Advance()
+ }
+
+ r.step = appendStep
+ wrequestCtx := []byte("somedata2")
+ n.ReadIndex(context.TODO(), wrequestCtx)
+ n.Stop()
+
+ if len(msgs) != 1 {
+ t.Fatalf("len(msgs) = %d, want %d", len(msgs), 1)
+ }
+ if msgs[0].Type != raftpb.MsgReadIndex {
+ t.Errorf("msg type = %d, want %d", msgs[0].Type, raftpb.MsgReadIndex)
+ }
+ if !bytes.Equal(msgs[0].Entries[0].Data, wrequestCtx) {
+ t.Errorf("data = %v, want %v", msgs[0].Entries[0].Data, wrequestCtx)
+ }
+}
+
+// TestNodeReadIndexToOldLeader ensures that raftpb.MsgReadIndex to old leader
+// gets forwarded to the new leader and 'send' method does not attach its term.
+func TestNodeReadIndexToOldLeader(t *testing.T) {
+ r1 := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ r2 := newTestRaft(2, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ r3 := newTestRaft(3, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+
+ nt := newNetwork(r1, r2, r3)
+
+ // elect r1 as leader
+ nt.send(raftpb.Message{From: 1, To: 1, Type: raftpb.MsgHup})
+
+ var testEntries = []raftpb.Entry{{Data: []byte("testdata")}}
+
+ // send readindex request to r2(follower)
+ r2.Step(raftpb.Message{From: 2, To: 2, Type: raftpb.MsgReadIndex, Entries: testEntries})
+
+ // verify r2(follower) forwards this message to r1(leader) with term not set
+ if len(r2.msgs) != 1 {
+ t.Fatalf("len(r2.msgs) expected 1, got %d", len(r2.msgs))
+ }
+ readIndxMsg1 := raftpb.Message{From: 2, To: 1, Type: raftpb.MsgReadIndex, Entries: testEntries}
+ if !reflect.DeepEqual(r2.msgs[0], readIndxMsg1) {
+ t.Fatalf("r2.msgs[0] expected %+v, got %+v", readIndxMsg1, r2.msgs[0])
+ }
+
+ // send readindex request to r3(follower)
+ r3.Step(raftpb.Message{From: 3, To: 3, Type: raftpb.MsgReadIndex, Entries: testEntries})
+
+ // verify r3(follower) forwards this message to r1(leader) with term not set as well.
+ if len(r3.msgs) != 1 {
+ t.Fatalf("len(r3.msgs) expected 1, got %d", len(r3.msgs))
+ }
+ readIndxMsg2 := raftpb.Message{From: 3, To: 1, Type: raftpb.MsgReadIndex, Entries: testEntries}
+ if !reflect.DeepEqual(r3.msgs[0], readIndxMsg2) {
+ t.Fatalf("r3.msgs[0] expected %+v, got %+v", readIndxMsg2, r3.msgs[0])
+ }
+
+ // now elect r3 as leader
+ nt.send(raftpb.Message{From: 3, To: 3, Type: raftpb.MsgHup})
+
+ // let r1 steps the two messages previously we got from r2, r3
+ r1.Step(readIndxMsg1)
+ r1.Step(readIndxMsg2)
+
+ // verify r1(follower) forwards these messages again to r3(new leader)
+ if len(r1.msgs) != 2 {
+ t.Fatalf("len(r1.msgs) expected 1, got %d", len(r1.msgs))
+ }
+ readIndxMsg3 := raftpb.Message{From: 1, To: 3, Type: raftpb.MsgReadIndex, Entries: testEntries}
+ if !reflect.DeepEqual(r1.msgs[0], readIndxMsg3) {
+ t.Fatalf("r1.msgs[0] expected %+v, got %+v", readIndxMsg3, r1.msgs[0])
+ }
+ if !reflect.DeepEqual(r1.msgs[1], readIndxMsg3) {
+ t.Fatalf("r1.msgs[1] expected %+v, got %+v", readIndxMsg3, r1.msgs[1])
+ }
+}
+
+// TestNodeProposeConfig ensures that node.ProposeConfChange sends the given configuration proposal
+// to the underlying raft.
+func TestNodeProposeConfig(t *testing.T) {
+ msgs := []raftpb.Message{}
+ appendStep := func(r *raft, m raftpb.Message) {
+ msgs = append(msgs, m)
+ }
+
+ n := newNode()
+ s := NewMemoryStorage()
+ r := newTestRaft(1, []uint64{1}, 10, 1, s)
+ go n.run(r)
+ n.Campaign(context.TODO())
+ for {
+ rd := <-n.Ready()
+ s.Append(rd.Entries)
+ // change the step function to appendStep until this raft becomes leader
+ if rd.SoftState.Lead == r.id {
+ r.step = appendStep
+ n.Advance()
+ break
+ }
+ n.Advance()
+ }
+ cc := raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 1}
+ ccdata, err := cc.Marshal()
+ if err != nil {
+ t.Fatal(err)
+ }
+ n.ProposeConfChange(context.TODO(), cc)
+ n.Stop()
+
+ if len(msgs) != 1 {
+ t.Fatalf("len(msgs) = %d, want %d", len(msgs), 1)
+ }
+ if msgs[0].Type != raftpb.MsgProp {
+ t.Errorf("msg type = %d, want %d", msgs[0].Type, raftpb.MsgProp)
+ }
+ if !bytes.Equal(msgs[0].Entries[0].Data, ccdata) {
+ t.Errorf("data = %v, want %v", msgs[0].Entries[0].Data, ccdata)
+ }
+}
+
+// TestNodeProposeAddDuplicateNode ensures that two proposes to add the same node should
+// not affect the later propose to add new node.
+func TestNodeProposeAddDuplicateNode(t *testing.T) {
+ n := newNode()
+ s := NewMemoryStorage()
+ r := newTestRaft(1, []uint64{1}, 10, 1, s)
+ go n.run(r)
+ n.Campaign(context.TODO())
+ rdyEntries := make([]raftpb.Entry, 0)
+ ticker := time.NewTicker(time.Millisecond * 100)
+ defer ticker.Stop()
+ done := make(chan struct{})
+ stop := make(chan struct{})
+ applyConfChan := make(chan struct{})
+
+ go func() {
+ defer close(done)
+ for {
+ select {
+ case <-stop:
+ return
+ case <-ticker.C:
+ n.Tick()
+ case rd := <-n.Ready():
+ s.Append(rd.Entries)
+ for _, e := range rd.Entries {
+ rdyEntries = append(rdyEntries, e)
+ switch e.Type {
+ case raftpb.EntryNormal:
+ case raftpb.EntryConfChange:
+ var cc raftpb.ConfChange
+ cc.Unmarshal(e.Data)
+ n.ApplyConfChange(cc)
+ applyConfChan <- struct{}{}
+ }
+ }
+ n.Advance()
+ }
+ }
+ }()
+
+ cc1 := raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 1}
+ ccdata1, _ := cc1.Marshal()
+ n.ProposeConfChange(context.TODO(), cc1)
+ <-applyConfChan
+
+ // try add the same node again
+ n.ProposeConfChange(context.TODO(), cc1)
+ <-applyConfChan
+
+ // the new node join should be ok
+ cc2 := raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 2}
+ ccdata2, _ := cc2.Marshal()
+ n.ProposeConfChange(context.TODO(), cc2)
+ <-applyConfChan
+
+ close(stop)
+ <-done
+
+ if len(rdyEntries) != 4 {
+ t.Errorf("len(entry) = %d, want %d, %v\n", len(rdyEntries), 4, rdyEntries)
+ }
+ if !bytes.Equal(rdyEntries[1].Data, ccdata1) {
+ t.Errorf("data = %v, want %v", rdyEntries[1].Data, ccdata1)
+ }
+ if !bytes.Equal(rdyEntries[3].Data, ccdata2) {
+ t.Errorf("data = %v, want %v", rdyEntries[3].Data, ccdata2)
+ }
+ n.Stop()
+}
+
+// TestBlockProposal ensures that node will block proposal when it does not
+// know who is the current leader; node will accept proposal when it knows
+// who is the current leader.
+func TestBlockProposal(t *testing.T) {
+ n := newNode()
+ r := newTestRaft(1, []uint64{1}, 10, 1, NewMemoryStorage())
+ go n.run(r)
+ defer n.Stop()
+
+ errc := make(chan error, 1)
+ go func() {
+ errc <- n.Propose(context.TODO(), []byte("somedata"))
+ }()
+
+ testutil.WaitSchedule()
+ select {
+ case err := <-errc:
+ t.Errorf("err = %v, want blocking", err)
+ default:
+ }
+
+ n.Campaign(context.TODO())
+ select {
+ case err := <-errc:
+ if err != nil {
+ t.Errorf("err = %v, want %v", err, nil)
+ }
+ case <-time.After(10 * time.Second):
+ t.Errorf("blocking proposal, want unblocking")
+ }
+}
+
+// TestNodeTick ensures that node.Tick() will increase the
+// elapsed of the underlying raft state machine.
+func TestNodeTick(t *testing.T) {
+ n := newNode()
+ s := NewMemoryStorage()
+ r := newTestRaft(1, []uint64{1}, 10, 1, s)
+ go n.run(r)
+ elapsed := r.electionElapsed
+ n.Tick()
+
+ for len(n.tickc) != 0 {
+ time.Sleep(100 * time.Millisecond)
+ }
+
+ n.Stop()
+ if r.electionElapsed != elapsed+1 {
+ t.Errorf("elapsed = %d, want %d", r.electionElapsed, elapsed+1)
+ }
+}
+
+// TestNodeStop ensures that node.Stop() blocks until the node has stopped
+// processing, and that it is idempotent
+func TestNodeStop(t *testing.T) {
+ n := newNode()
+ s := NewMemoryStorage()
+ r := newTestRaft(1, []uint64{1}, 10, 1, s)
+ donec := make(chan struct{})
+
+ go func() {
+ n.run(r)
+ close(donec)
+ }()
+
+ status := n.Status()
+ n.Stop()
+
+ select {
+ case <-donec:
+ case <-time.After(time.Second):
+ t.Fatalf("timed out waiting for node to stop!")
+ }
+
+ emptyStatus := Status{}
+
+ if reflect.DeepEqual(status, emptyStatus) {
+ t.Errorf("status = %v, want not empty", status)
+ }
+ // Further status should return be empty, the node is stopped.
+ status = n.Status()
+ if !reflect.DeepEqual(status, emptyStatus) {
+ t.Errorf("status = %v, want empty", status)
+ }
+ // Subsequent Stops should have no effect.
+ n.Stop()
+}
+
+func TestReadyContainUpdates(t *testing.T) {
+ tests := []struct {
+ rd Ready
+ wcontain bool
+ }{
+ {Ready{}, false},
+ {Ready{SoftState: &SoftState{Lead: 1}}, true},
+ {Ready{HardState: raftpb.HardState{Vote: 1}}, true},
+ {Ready{Entries: make([]raftpb.Entry, 1)}, true},
+ {Ready{CommittedEntries: make([]raftpb.Entry, 1)}, true},
+ {Ready{Messages: make([]raftpb.Message, 1)}, true},
+ {Ready{Snapshot: raftpb.Snapshot{Metadata: raftpb.SnapshotMetadata{Index: 1}}}, true},
+ }
+
+ for i, tt := range tests {
+ if g := tt.rd.containsUpdates(); g != tt.wcontain {
+ t.Errorf("#%d: containUpdates = %v, want %v", i, g, tt.wcontain)
+ }
+ }
+}
+
+// TestNodeStart ensures that a node can be started correctly. The node should
+// start with correct configuration change entries, and can accept and commit
+// proposals.
+func TestNodeStart(t *testing.T) {
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+
+ cc := raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 1}
+ ccdata, err := cc.Marshal()
+ if err != nil {
+ t.Fatalf("unexpected marshal error: %v", err)
+ }
+ wants := []Ready{
+ {
+ HardState: raftpb.HardState{Term: 1, Commit: 1, Vote: 0},
+ Entries: []raftpb.Entry{
+ {Type: raftpb.EntryConfChange, Term: 1, Index: 1, Data: ccdata},
+ },
+ CommittedEntries: []raftpb.Entry{
+ {Type: raftpb.EntryConfChange, Term: 1, Index: 1, Data: ccdata},
+ },
+ MustSync: true,
+ },
+ {
+ HardState: raftpb.HardState{Term: 2, Commit: 3, Vote: 1},
+ Entries: []raftpb.Entry{{Term: 2, Index: 3, Data: []byte("foo")}},
+ CommittedEntries: []raftpb.Entry{{Term: 2, Index: 3, Data: []byte("foo")}},
+ MustSync: true,
+ },
+ }
+ storage := NewMemoryStorage()
+ c := &Config{
+ ID: 1,
+ ElectionTick: 10,
+ HeartbeatTick: 1,
+ Storage: storage,
+ MaxSizePerMsg: noLimit,
+ MaxInflightMsgs: 256,
+ }
+ n := StartNode(c, []Peer{{ID: 1}})
+ defer n.Stop()
+ g := <-n.Ready()
+ if !reflect.DeepEqual(g, wants[0]) {
+ t.Fatalf("#%d: g = %+v,\n w %+v", 1, g, wants[0])
+ } else {
+ storage.Append(g.Entries)
+ n.Advance()
+ }
+
+ n.Campaign(ctx)
+ rd := <-n.Ready()
+ storage.Append(rd.Entries)
+ n.Advance()
+
+ n.Propose(ctx, []byte("foo"))
+ if g2 := <-n.Ready(); !reflect.DeepEqual(g2, wants[1]) {
+ t.Errorf("#%d: g = %+v,\n w %+v", 2, g2, wants[1])
+ } else {
+ storage.Append(g2.Entries)
+ n.Advance()
+ }
+
+ select {
+ case rd := <-n.Ready():
+ t.Errorf("unexpected Ready: %+v", rd)
+ case <-time.After(time.Millisecond):
+ }
+}
+
+func TestNodeRestart(t *testing.T) {
+ entries := []raftpb.Entry{
+ {Term: 1, Index: 1},
+ {Term: 1, Index: 2, Data: []byte("foo")},
+ }
+ st := raftpb.HardState{Term: 1, Commit: 1}
+
+ want := Ready{
+ HardState: st,
+ // commit up to index commit index in st
+ CommittedEntries: entries[:st.Commit],
+ MustSync: true,
+ }
+
+ storage := NewMemoryStorage()
+ storage.SetHardState(st)
+ storage.Append(entries)
+ c := &Config{
+ ID: 1,
+ ElectionTick: 10,
+ HeartbeatTick: 1,
+ Storage: storage,
+ MaxSizePerMsg: noLimit,
+ MaxInflightMsgs: 256,
+ }
+ n := RestartNode(c)
+ defer n.Stop()
+ if g := <-n.Ready(); !reflect.DeepEqual(g, want) {
+ t.Errorf("g = %+v,\n w %+v", g, want)
+ }
+ n.Advance()
+
+ select {
+ case rd := <-n.Ready():
+ t.Errorf("unexpected Ready: %+v", rd)
+ case <-time.After(time.Millisecond):
+ }
+}
+
+func TestNodeRestartFromSnapshot(t *testing.T) {
+ snap := raftpb.Snapshot{
+ Metadata: raftpb.SnapshotMetadata{
+ ConfState: raftpb.ConfState{Nodes: []uint64{1, 2}},
+ Index: 2,
+ Term: 1,
+ },
+ }
+ entries := []raftpb.Entry{
+ {Term: 1, Index: 3, Data: []byte("foo")},
+ }
+ st := raftpb.HardState{Term: 1, Commit: 3}
+
+ want := Ready{
+ HardState: st,
+ // commit up to index commit index in st
+ CommittedEntries: entries,
+ MustSync: true,
+ }
+
+ s := NewMemoryStorage()
+ s.SetHardState(st)
+ s.ApplySnapshot(snap)
+ s.Append(entries)
+ c := &Config{
+ ID: 1,
+ ElectionTick: 10,
+ HeartbeatTick: 1,
+ Storage: s,
+ MaxSizePerMsg: noLimit,
+ MaxInflightMsgs: 256,
+ }
+ n := RestartNode(c)
+ defer n.Stop()
+ if g := <-n.Ready(); !reflect.DeepEqual(g, want) {
+ t.Errorf("g = %+v,\n w %+v", g, want)
+ } else {
+ n.Advance()
+ }
+
+ select {
+ case rd := <-n.Ready():
+ t.Errorf("unexpected Ready: %+v", rd)
+ case <-time.After(time.Millisecond):
+ }
+}
+
+func TestNodeAdvance(t *testing.T) {
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+
+ storage := NewMemoryStorage()
+ c := &Config{
+ ID: 1,
+ ElectionTick: 10,
+ HeartbeatTick: 1,
+ Storage: storage,
+ MaxSizePerMsg: noLimit,
+ MaxInflightMsgs: 256,
+ }
+ n := StartNode(c, []Peer{{ID: 1}})
+ defer n.Stop()
+ rd := <-n.Ready()
+ storage.Append(rd.Entries)
+ n.Advance()
+
+ n.Campaign(ctx)
+ <-n.Ready()
+
+ n.Propose(ctx, []byte("foo"))
+ select {
+ case rd = <-n.Ready():
+ t.Fatalf("unexpected Ready before Advance: %+v", rd)
+ case <-time.After(time.Millisecond):
+ }
+ storage.Append(rd.Entries)
+ n.Advance()
+ select {
+ case <-n.Ready():
+ case <-time.After(100 * time.Millisecond):
+ t.Errorf("expect Ready after Advance, but there is no Ready available")
+ }
+}
+
+func TestSoftStateEqual(t *testing.T) {
+ tests := []struct {
+ st *SoftState
+ we bool
+ }{
+ {&SoftState{}, true},
+ {&SoftState{Lead: 1}, false},
+ {&SoftState{RaftState: StateLeader}, false},
+ }
+ for i, tt := range tests {
+ if g := tt.st.equal(&SoftState{}); g != tt.we {
+ t.Errorf("#%d, equal = %v, want %v", i, g, tt.we)
+ }
+ }
+}
+
+func TestIsHardStateEqual(t *testing.T) {
+ tests := []struct {
+ st raftpb.HardState
+ we bool
+ }{
+ {emptyState, true},
+ {raftpb.HardState{Vote: 1}, false},
+ {raftpb.HardState{Commit: 1}, false},
+ {raftpb.HardState{Term: 1}, false},
+ }
+
+ for i, tt := range tests {
+ if isHardStateEqual(tt.st, emptyState) != tt.we {
+ t.Errorf("#%d, equal = %v, want %v", i, isHardStateEqual(tt.st, emptyState), tt.we)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/raft/progress.go b/vendor/github.com/coreos/etcd/raft/progress.go
new file mode 100644
index 00000000..77c7b52e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/progress.go
@@ -0,0 +1,279 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import "fmt"
+
+const (
+ ProgressStateProbe ProgressStateType = iota
+ ProgressStateReplicate
+ ProgressStateSnapshot
+)
+
+type ProgressStateType uint64
+
+var prstmap = [...]string{
+ "ProgressStateProbe",
+ "ProgressStateReplicate",
+ "ProgressStateSnapshot",
+}
+
+func (st ProgressStateType) String() string { return prstmap[uint64(st)] }
+
+// Progress represents a follower?s progress in the view of the leader. Leader maintains
+// progresses of all followers, and sends entries to the follower based on its progress.
+type Progress struct {
+ Match, Next uint64
+ // State defines how the leader should interact with the follower.
+ //
+ // When in ProgressStateProbe, leader sends at most one replication message
+ // per heartbeat interval. It also probes actual progress of the follower.
+ //
+ // When in ProgressStateReplicate, leader optimistically increases next
+ // to the latest entry sent after sending replication message. This is
+ // an optimized state for fast replicating log entries to the follower.
+ //
+ // When in ProgressStateSnapshot, leader should have sent out snapshot
+ // before and stops sending any replication message.
+ State ProgressStateType
+ // Paused is used in ProgressStateProbe.
+ // When Paused is true, raft should pause sending replication message to this peer.
+ Paused bool
+ // PendingSnapshot is used in ProgressStateSnapshot.
+ // If there is a pending snapshot, the pendingSnapshot will be set to the
+ // index of the snapshot. If pendingSnapshot is set, the replication process of
+ // this Progress will be paused. raft will not resend snapshot until the pending one
+ // is reported to be failed.
+ PendingSnapshot uint64
+
+ // RecentActive is true if the progress is recently active. Receiving any messages
+ // from the corresponding follower indicates the progress is active.
+ // RecentActive can be reset to false after an election timeout.
+ RecentActive bool
+
+ // inflights is a sliding window for the inflight messages.
+ // Each inflight message contains one or more log entries.
+ // The max number of entries per message is defined in raft config as MaxSizePerMsg.
+ // Thus inflight effectively limits both the number of inflight messages
+ // and the bandwidth each Progress can use.
+ // When inflights is full, no more message should be sent.
+ // When a leader sends out a message, the index of the last
+ // entry should be added to inflights. The index MUST be added
+ // into inflights in order.
+ // When a leader receives a reply, the previous inflights should
+ // be freed by calling inflights.freeTo with the index of the last
+ // received entry.
+ ins *inflights
+}
+
+func (pr *Progress) resetState(state ProgressStateType) {
+ pr.Paused = false
+ pr.PendingSnapshot = 0
+ pr.State = state
+ pr.ins.reset()
+}
+
+func (pr *Progress) becomeProbe() {
+ // If the original state is ProgressStateSnapshot, progress knows that
+ // the pending snapshot has been sent to this peer successfully, then
+ // probes from pendingSnapshot + 1.
+ if pr.State == ProgressStateSnapshot {
+ pendingSnapshot := pr.PendingSnapshot
+ pr.resetState(ProgressStateProbe)
+ pr.Next = max(pr.Match+1, pendingSnapshot+1)
+ } else {
+ pr.resetState(ProgressStateProbe)
+ pr.Next = pr.Match + 1
+ }
+}
+
+func (pr *Progress) becomeReplicate() {
+ pr.resetState(ProgressStateReplicate)
+ pr.Next = pr.Match + 1
+}
+
+func (pr *Progress) becomeSnapshot(snapshoti uint64) {
+ pr.resetState(ProgressStateSnapshot)
+ pr.PendingSnapshot = snapshoti
+}
+
+// maybeUpdate returns false if the given n index comes from an outdated message.
+// Otherwise it updates the progress and returns true.
+func (pr *Progress) maybeUpdate(n uint64) bool {
+ var updated bool
+ if pr.Match < n {
+ pr.Match = n
+ updated = true
+ pr.resume()
+ }
+ if pr.Next < n+1 {
+ pr.Next = n + 1
+ }
+ return updated
+}
+
+func (pr *Progress) optimisticUpdate(n uint64) { pr.Next = n + 1 }
+
+// maybeDecrTo returns false if the given to index comes from an out of order message.
+// Otherwise it decreases the progress next index to min(rejected, last) and returns true.
+func (pr *Progress) maybeDecrTo(rejected, last uint64) bool {
+ if pr.State == ProgressStateReplicate {
+ // the rejection must be stale if the progress has matched and "rejected"
+ // is smaller than "match".
+ if rejected <= pr.Match {
+ return false
+ }
+ // directly decrease next to match + 1
+ pr.Next = pr.Match + 1
+ return true
+ }
+
+ // the rejection must be stale if "rejected" does not match next - 1
+ if pr.Next-1 != rejected {
+ return false
+ }
+
+ if pr.Next = min(rejected, last+1); pr.Next < 1 {
+ pr.Next = 1
+ }
+ pr.resume()
+ return true
+}
+
+func (pr *Progress) pause() { pr.Paused = true }
+func (pr *Progress) resume() { pr.Paused = false }
+
+// IsPaused returns whether sending log entries to this node has been
+// paused. A node may be paused because it has rejected recent
+// MsgApps, is currently waiting for a snapshot, or has reached the
+// MaxInflightMsgs limit.
+func (pr *Progress) IsPaused() bool {
+ switch pr.State {
+ case ProgressStateProbe:
+ return pr.Paused
+ case ProgressStateReplicate:
+ return pr.ins.full()
+ case ProgressStateSnapshot:
+ return true
+ default:
+ panic("unexpected state")
+ }
+}
+
+func (pr *Progress) snapshotFailure() { pr.PendingSnapshot = 0 }
+
+// needSnapshotAbort returns true if snapshot progress's Match
+// is equal or higher than the pendingSnapshot.
+func (pr *Progress) needSnapshotAbort() bool {
+ return pr.State == ProgressStateSnapshot && pr.Match >= pr.PendingSnapshot
+}
+
+func (pr *Progress) String() string {
+ return fmt.Sprintf("next = %d, match = %d, state = %s, waiting = %v, pendingSnapshot = %d", pr.Next, pr.Match, pr.State, pr.IsPaused(), pr.PendingSnapshot)
+}
+
+type inflights struct {
+ // the starting index in the buffer
+ start int
+ // number of inflights in the buffer
+ count int
+
+ // the size of the buffer
+ size int
+
+ // buffer contains the index of the last entry
+ // inside one message.
+ buffer []uint64
+}
+
+func newInflights(size int) *inflights {
+ return &inflights{
+ size: size,
+ }
+}
+
+// add adds an inflight into inflights
+func (in *inflights) add(inflight uint64) {
+ if in.full() {
+ panic("cannot add into a full inflights")
+ }
+ next := in.start + in.count
+ size := in.size
+ if next >= size {
+ next -= size
+ }
+ if next >= len(in.buffer) {
+ in.growBuf()
+ }
+ in.buffer[next] = inflight
+ in.count++
+}
+
+// grow the inflight buffer by doubling up to inflights.size. We grow on demand
+// instead of preallocating to inflights.size to handle systems which have
+// thousands of Raft groups per process.
+func (in *inflights) growBuf() {
+ newSize := len(in.buffer) * 2
+ if newSize == 0 {
+ newSize = 1
+ } else if newSize > in.size {
+ newSize = in.size
+ }
+ newBuffer := make([]uint64, newSize)
+ copy(newBuffer, in.buffer)
+ in.buffer = newBuffer
+}
+
+// freeTo frees the inflights smaller or equal to the given `to` flight.
+func (in *inflights) freeTo(to uint64) {
+ if in.count == 0 || to < in.buffer[in.start] {
+ // out of the left side of the window
+ return
+ }
+
+ i, idx := 0, in.start
+ for i = 0; i < in.count; i++ {
+ if to < in.buffer[idx] { // found the first large inflight
+ break
+ }
+
+ // increase index and maybe rotate
+ size := in.size
+ if idx++; idx >= size {
+ idx -= size
+ }
+ }
+ // free i inflights and set new start index
+ in.count -= i
+ in.start = idx
+ if in.count == 0 {
+ // inflights is empty, reset the start index so that we don't grow the
+ // buffer unnecessarily.
+ in.start = 0
+ }
+}
+
+func (in *inflights) freeFirstOne() { in.freeTo(in.buffer[in.start]) }
+
+// full returns true if the inflights is full.
+func (in *inflights) full() bool {
+ return in.count == in.size
+}
+
+// resets frees all inflights.
+func (in *inflights) reset() {
+ in.count = 0
+ in.start = 0
+}
diff --git a/vendor/github.com/coreos/etcd/raft/progress_test.go b/vendor/github.com/coreos/etcd/raft/progress_test.go
new file mode 100644
index 00000000..cf92eb8e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/progress_test.go
@@ -0,0 +1,189 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "reflect"
+ "testing"
+)
+
+func TestInflightsAdd(t *testing.T) {
+ // no rotating case
+ in := &inflights{
+ size: 10,
+ buffer: make([]uint64, 10),
+ }
+
+ for i := 0; i < 5; i++ {
+ in.add(uint64(i))
+ }
+
+ wantIn := &inflights{
+ start: 0,
+ count: 5,
+ size: 10,
+ // ?------------
+ buffer: []uint64{0, 1, 2, 3, 4, 0, 0, 0, 0, 0},
+ }
+
+ if !reflect.DeepEqual(in, wantIn) {
+ t.Fatalf("in = %+v, want %+v", in, wantIn)
+ }
+
+ for i := 5; i < 10; i++ {
+ in.add(uint64(i))
+ }
+
+ wantIn2 := &inflights{
+ start: 0,
+ count: 10,
+ size: 10,
+ // ?---------------------------
+ buffer: []uint64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
+ }
+
+ if !reflect.DeepEqual(in, wantIn2) {
+ t.Fatalf("in = %+v, want %+v", in, wantIn2)
+ }
+
+ // rotating case
+ in2 := &inflights{
+ start: 5,
+ size: 10,
+ buffer: make([]uint64, 10),
+ }
+
+ for i := 0; i < 5; i++ {
+ in2.add(uint64(i))
+ }
+
+ wantIn21 := &inflights{
+ start: 5,
+ count: 5,
+ size: 10,
+ // ?------------
+ buffer: []uint64{0, 0, 0, 0, 0, 0, 1, 2, 3, 4},
+ }
+
+ if !reflect.DeepEqual(in2, wantIn21) {
+ t.Fatalf("in = %+v, want %+v", in2, wantIn21)
+ }
+
+ for i := 5; i < 10; i++ {
+ in2.add(uint64(i))
+ }
+
+ wantIn22 := &inflights{
+ start: 5,
+ count: 10,
+ size: 10,
+ // -------------- ?------------
+ buffer: []uint64{5, 6, 7, 8, 9, 0, 1, 2, 3, 4},
+ }
+
+ if !reflect.DeepEqual(in2, wantIn22) {
+ t.Fatalf("in = %+v, want %+v", in2, wantIn22)
+ }
+}
+
+func TestInflightFreeTo(t *testing.T) {
+ // no rotating case
+ in := newInflights(10)
+ for i := 0; i < 10; i++ {
+ in.add(uint64(i))
+ }
+
+ in.freeTo(4)
+
+ wantIn := &inflights{
+ start: 5,
+ count: 5,
+ size: 10,
+ // ?------------
+ buffer: []uint64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
+ }
+
+ if !reflect.DeepEqual(in, wantIn) {
+ t.Fatalf("in = %+v, want %+v", in, wantIn)
+ }
+
+ in.freeTo(8)
+
+ wantIn2 := &inflights{
+ start: 9,
+ count: 1,
+ size: 10,
+ // ?
+ buffer: []uint64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
+ }
+
+ if !reflect.DeepEqual(in, wantIn2) {
+ t.Fatalf("in = %+v, want %+v", in, wantIn2)
+ }
+
+ // rotating case
+ for i := 10; i < 15; i++ {
+ in.add(uint64(i))
+ }
+
+ in.freeTo(12)
+
+ wantIn3 := &inflights{
+ start: 3,
+ count: 2,
+ size: 10,
+ // ?-----
+ buffer: []uint64{10, 11, 12, 13, 14, 5, 6, 7, 8, 9},
+ }
+
+ if !reflect.DeepEqual(in, wantIn3) {
+ t.Fatalf("in = %+v, want %+v", in, wantIn3)
+ }
+
+ in.freeTo(14)
+
+ wantIn4 := &inflights{
+ start: 0,
+ count: 0,
+ size: 10,
+ // ?
+ buffer: []uint64{10, 11, 12, 13, 14, 5, 6, 7, 8, 9},
+ }
+
+ if !reflect.DeepEqual(in, wantIn4) {
+ t.Fatalf("in = %+v, want %+v", in, wantIn4)
+ }
+}
+
+func TestInflightFreeFirstOne(t *testing.T) {
+ in := newInflights(10)
+ for i := 0; i < 10; i++ {
+ in.add(uint64(i))
+ }
+
+ in.freeFirstOne()
+
+ wantIn := &inflights{
+ start: 1,
+ count: 9,
+ size: 10,
+ // ?------------------------
+ buffer: []uint64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
+ }
+
+ if !reflect.DeepEqual(in, wantIn) {
+ t.Fatalf("in = %+v, want %+v", in, wantIn)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/raft/raft.go b/vendor/github.com/coreos/etcd/raft/raft.go
new file mode 100644
index 00000000..29f20398
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/raft.go
@@ -0,0 +1,1257 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "bytes"
+ "errors"
+ "fmt"
+ "math"
+ "math/rand"
+ "sort"
+ "strings"
+ "sync"
+ "time"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+// None is a placeholder node ID used when there is no leader.
+const None uint64 = 0
+const noLimit = math.MaxUint64
+
+// Possible values for StateType.
+const (
+ StateFollower StateType = iota
+ StateCandidate
+ StateLeader
+ StatePreCandidate
+ numStates
+)
+
+type ReadOnlyOption int
+
+const (
+ // ReadOnlySafe guarantees the linearizability of the read only request by
+ // communicating with the quorum. It is the default and suggested option.
+ ReadOnlySafe ReadOnlyOption = iota
+ // ReadOnlyLeaseBased ensures linearizability of the read only request by
+ // relying on the leader lease. It can be affected by clock drift.
+ // If the clock drift is unbounded, leader might keep the lease longer than it
+ // should (clock can move backward/pause without any bound). ReadIndex is not safe
+ // in that case.
+ ReadOnlyLeaseBased
+)
+
+// Possible values for CampaignType
+const (
+ // campaignPreElection represents the first phase of a normal election when
+ // Config.PreVote is true.
+ campaignPreElection CampaignType = "CampaignPreElection"
+ // campaignElection represents a normal (time-based) election (the second phase
+ // of the election when Config.PreVote is true).
+ campaignElection CampaignType = "CampaignElection"
+ // campaignTransfer represents the type of leader transfer
+ campaignTransfer CampaignType = "CampaignTransfer"
+)
+
+// lockedRand is a small wrapper around rand.Rand to provide
+// synchronization. Only the methods needed by the code are exposed
+// (e.g. Intn).
+type lockedRand struct {
+ mu sync.Mutex
+ rand *rand.Rand
+}
+
+func (r *lockedRand) Intn(n int) int {
+ r.mu.Lock()
+ v := r.rand.Intn(n)
+ r.mu.Unlock()
+ return v
+}
+
+var globalRand = &lockedRand{
+ rand: rand.New(rand.NewSource(time.Now().UnixNano())),
+}
+
+// CampaignType represents the type of campaigning
+// the reason we use the type of string instead of uint64
+// is because it's simpler to compare and fill in raft entries
+type CampaignType string
+
+// StateType represents the role of a node in a cluster.
+type StateType uint64
+
+var stmap = [...]string{
+ "StateFollower",
+ "StateCandidate",
+ "StateLeader",
+ "StatePreCandidate",
+}
+
+func (st StateType) String() string {
+ return stmap[uint64(st)]
+}
+
+// Config contains the parameters to start a raft.
+type Config struct {
+ // ID is the identity of the local raft. ID cannot be 0.
+ ID uint64
+
+ // peers contains the IDs of all nodes (including self) in the raft cluster. It
+ // should only be set when starting a new raft cluster. Restarting raft from
+ // previous configuration will panic if peers is set. peer is private and only
+ // used for testing right now.
+ peers []uint64
+
+ // ElectionTick is the number of Node.Tick invocations that must pass between
+ // elections. That is, if a follower does not receive any message from the
+ // leader of current term before ElectionTick has elapsed, it will become
+ // candidate and start an election. ElectionTick must be greater than
+ // HeartbeatTick. We suggest ElectionTick = 10 * HeartbeatTick to avoid
+ // unnecessary leader switching.
+ ElectionTick int
+ // HeartbeatTick is the number of Node.Tick invocations that must pass between
+ // heartbeats. That is, a leader sends heartbeat messages to maintain its
+ // leadership every HeartbeatTick ticks.
+ HeartbeatTick int
+
+ // Storage is the storage for raft. raft generates entries and states to be
+ // stored in storage. raft reads the persisted entries and states out of
+ // Storage when it needs. raft reads out the previous state and configuration
+ // out of storage when restarting.
+ Storage Storage
+ // Applied is the last applied index. It should only be set when restarting
+ // raft. raft will not return entries to the application smaller or equal to
+ // Applied. If Applied is unset when restarting, raft might return previous
+ // applied entries. This is a very application dependent configuration.
+ Applied uint64
+
+ // MaxSizePerMsg limits the max size of each append message. Smaller value
+ // lowers the raft recovery cost(initial probing and message lost during normal
+ // operation). On the other side, it might affect the throughput during normal
+ // replication. Note: math.MaxUint64 for unlimited, 0 for at most one entry per
+ // message.
+ MaxSizePerMsg uint64
+ // MaxInflightMsgs limits the max number of in-flight append messages during
+ // optimistic replication phase. The application transportation layer usually
+ // has its own sending buffer over TCP/UDP. Setting MaxInflightMsgs to avoid
+ // overflowing that sending buffer. TODO (xiangli): feedback to application to
+ // limit the proposal rate?
+ MaxInflightMsgs int
+
+ // CheckQuorum specifies if the leader should check quorum activity. Leader
+ // steps down when quorum is not active for an electionTimeout.
+ CheckQuorum bool
+
+ // PreVote enables the Pre-Vote algorithm described in raft thesis section
+ // 9.6. This prevents disruption when a node that has been partitioned away
+ // rejoins the cluster.
+ PreVote bool
+
+ // ReadOnlyOption specifies how the read only request is processed.
+ //
+ // ReadOnlySafe guarantees the linearizability of the read only request by
+ // communicating with the quorum. It is the default and suggested option.
+ //
+ // ReadOnlyLeaseBased ensures linearizability of the read only request by
+ // relying on the leader lease. It can be affected by clock drift.
+ // If the clock drift is unbounded, leader might keep the lease longer than it
+ // should (clock can move backward/pause without any bound). ReadIndex is not safe
+ // in that case.
+ ReadOnlyOption ReadOnlyOption
+
+ // Logger is the logger used for raft log. For multinode which can host
+ // multiple raft group, each raft group can have its own logger
+ Logger Logger
+}
+
+func (c *Config) validate() error {
+ if c.ID == None {
+ return errors.New("cannot use none as id")
+ }
+
+ if c.HeartbeatTick <= 0 {
+ return errors.New("heartbeat tick must be greater than 0")
+ }
+
+ if c.ElectionTick <= c.HeartbeatTick {
+ return errors.New("election tick must be greater than heartbeat tick")
+ }
+
+ if c.Storage == nil {
+ return errors.New("storage cannot be nil")
+ }
+
+ if c.MaxInflightMsgs <= 0 {
+ return errors.New("max inflight messages must be greater than 0")
+ }
+
+ if c.Logger == nil {
+ c.Logger = raftLogger
+ }
+
+ return nil
+}
+
+type raft struct {
+ id uint64
+
+ Term uint64
+ Vote uint64
+
+ readStates []ReadState
+
+ // the log
+ raftLog *raftLog
+
+ maxInflight int
+ maxMsgSize uint64
+ prs map[uint64]*Progress
+
+ state StateType
+
+ votes map[uint64]bool
+
+ msgs []pb.Message
+
+ // the leader id
+ lead uint64
+ // leadTransferee is id of the leader transfer target when its value is not zero.
+ // Follow the procedure defined in raft thesis 3.10.
+ leadTransferee uint64
+ // New configuration is ignored if there exists unapplied configuration.
+ pendingConf bool
+
+ readOnly *readOnly
+
+ // number of ticks since it reached last electionTimeout when it is leader
+ // or candidate.
+ // number of ticks since it reached last electionTimeout or received a
+ // valid message from current leader when it is a follower.
+ electionElapsed int
+
+ // number of ticks since it reached last heartbeatTimeout.
+ // only leader keeps heartbeatElapsed.
+ heartbeatElapsed int
+
+ checkQuorum bool
+ preVote bool
+
+ heartbeatTimeout int
+ electionTimeout int
+ // randomizedElectionTimeout is a random number between
+ // [electiontimeout, 2 * electiontimeout - 1]. It gets reset
+ // when raft changes its state to follower or candidate.
+ randomizedElectionTimeout int
+
+ tick func()
+ step stepFunc
+
+ logger Logger
+}
+
+func newRaft(c *Config) *raft {
+ if err := c.validate(); err != nil {
+ panic(err.Error())
+ }
+ raftlog := newLog(c.Storage, c.Logger)
+ hs, cs, err := c.Storage.InitialState()
+ if err != nil {
+ panic(err) // TODO(bdarnell)
+ }
+ peers := c.peers
+ if len(cs.Nodes) > 0 {
+ if len(peers) > 0 {
+ // TODO(bdarnell): the peers argument is always nil except in
+ // tests; the argument should be removed and these tests should be
+ // updated to specify their nodes through a snapshot.
+ panic("cannot specify both newRaft(peers) and ConfState.Nodes)")
+ }
+ peers = cs.Nodes
+ }
+ r := &raft{
+ id: c.ID,
+ lead: None,
+ raftLog: raftlog,
+ maxMsgSize: c.MaxSizePerMsg,
+ maxInflight: c.MaxInflightMsgs,
+ prs: make(map[uint64]*Progress),
+ electionTimeout: c.ElectionTick,
+ heartbeatTimeout: c.HeartbeatTick,
+ logger: c.Logger,
+ checkQuorum: c.CheckQuorum,
+ preVote: c.PreVote,
+ readOnly: newReadOnly(c.ReadOnlyOption),
+ }
+ for _, p := range peers {
+ r.prs[p] = &Progress{Next: 1, ins: newInflights(r.maxInflight)}
+ }
+ if !isHardStateEqual(hs, emptyState) {
+ r.loadState(hs)
+ }
+ if c.Applied > 0 {
+ raftlog.appliedTo(c.Applied)
+ }
+ r.becomeFollower(r.Term, None)
+
+ var nodesStrs []string
+ for _, n := range r.nodes() {
+ nodesStrs = append(nodesStrs, fmt.Sprintf("%x", n))
+ }
+
+ r.logger.Infof("newRaft %x [peers: [%s], term: %d, commit: %d, applied: %d, lastindex: %d, lastterm: %d]",
+ r.id, strings.Join(nodesStrs, ","), r.Term, r.raftLog.committed, r.raftLog.applied, r.raftLog.lastIndex(), r.raftLog.lastTerm())
+ return r
+}
+
+func (r *raft) hasLeader() bool { return r.lead != None }
+
+func (r *raft) softState() *SoftState { return &SoftState{Lead: r.lead, RaftState: r.state} }
+
+func (r *raft) hardState() pb.HardState {
+ return pb.HardState{
+ Term: r.Term,
+ Vote: r.Vote,
+ Commit: r.raftLog.committed,
+ }
+}
+
+func (r *raft) quorum() int { return len(r.prs)/2 + 1 }
+
+func (r *raft) nodes() []uint64 {
+ nodes := make([]uint64, 0, len(r.prs))
+ for id := range r.prs {
+ nodes = append(nodes, id)
+ }
+ sort.Sort(uint64Slice(nodes))
+ return nodes
+}
+
+// send persists state to stable storage and then sends to its mailbox.
+func (r *raft) send(m pb.Message) {
+ m.From = r.id
+ if m.Type == pb.MsgVote || m.Type == pb.MsgPreVote {
+ if m.Term == 0 {
+ // PreVote RPCs are sent at a term other than our actual term, so the code
+ // that sends these messages is responsible for setting the term.
+ panic(fmt.Sprintf("term should be set when sending %s", m.Type))
+ }
+ } else {
+ if m.Term != 0 {
+ panic(fmt.Sprintf("term should not be set when sending %s (was %d)", m.Type, m.Term))
+ }
+ // do not attach term to MsgProp, MsgReadIndex
+ // proposals are a way to forward to the leader and
+ // should be treated as local message.
+ // MsgReadIndex is also forwarded to leader.
+ if m.Type != pb.MsgProp && m.Type != pb.MsgReadIndex {
+ m.Term = r.Term
+ }
+ }
+ r.msgs = append(r.msgs, m)
+}
+
+// sendAppend sends RPC, with entries to the given peer.
+func (r *raft) sendAppend(to uint64) {
+ pr := r.prs[to]
+ if pr.IsPaused() {
+ return
+ }
+ m := pb.Message{}
+ m.To = to
+
+ term, errt := r.raftLog.term(pr.Next - 1)
+ ents, erre := r.raftLog.entries(pr.Next, r.maxMsgSize)
+
+ if errt != nil || erre != nil { // send snapshot if we failed to get term or entries
+ if !pr.RecentActive {
+ r.logger.Debugf("ignore sending snapshot to %x since it is not recently active", to)
+ return
+ }
+
+ m.Type = pb.MsgSnap
+ snapshot, err := r.raftLog.snapshot()
+ if err != nil {
+ if err == ErrSnapshotTemporarilyUnavailable {
+ r.logger.Debugf("%x failed to send snapshot to %x because snapshot is temporarily unavailable", r.id, to)
+ return
+ }
+ panic(err) // TODO(bdarnell)
+ }
+ if IsEmptySnap(snapshot) {
+ panic("need non-empty snapshot")
+ }
+ m.Snapshot = snapshot
+ sindex, sterm := snapshot.Metadata.Index, snapshot.Metadata.Term
+ r.logger.Debugf("%x [firstindex: %d, commit: %d] sent snapshot[index: %d, term: %d] to %x [%s]",
+ r.id, r.raftLog.firstIndex(), r.raftLog.committed, sindex, sterm, to, pr)
+ pr.becomeSnapshot(sindex)
+ r.logger.Debugf("%x paused sending replication messages to %x [%s]", r.id, to, pr)
+ } else {
+ m.Type = pb.MsgApp
+ m.Index = pr.Next - 1
+ m.LogTerm = term
+ m.Entries = ents
+ m.Commit = r.raftLog.committed
+ if n := len(m.Entries); n != 0 {
+ switch pr.State {
+ // optimistically increase the next when in ProgressStateReplicate
+ case ProgressStateReplicate:
+ last := m.Entries[n-1].Index
+ pr.optimisticUpdate(last)
+ pr.ins.add(last)
+ case ProgressStateProbe:
+ pr.pause()
+ default:
+ r.logger.Panicf("%x is sending append in unhandled state %s", r.id, pr.State)
+ }
+ }
+ }
+ r.send(m)
+}
+
+// sendHeartbeat sends an empty MsgApp
+func (r *raft) sendHeartbeat(to uint64, ctx []byte) {
+ // Attach the commit as min(to.matched, r.committed).
+ // When the leader sends out heartbeat message,
+ // the receiver(follower) might not be matched with the leader
+ // or it might not have all the committed entries.
+ // The leader MUST NOT forward the follower's commit to
+ // an unmatched index.
+ commit := min(r.prs[to].Match, r.raftLog.committed)
+ m := pb.Message{
+ To: to,
+ Type: pb.MsgHeartbeat,
+ Commit: commit,
+ Context: ctx,
+ }
+
+ r.send(m)
+}
+
+// bcastAppend sends RPC, with entries to all peers that are not up-to-date
+// according to the progress recorded in r.prs.
+func (r *raft) bcastAppend() {
+ for id := range r.prs {
+ if id == r.id {
+ continue
+ }
+ r.sendAppend(id)
+ }
+}
+
+// bcastHeartbeat sends RPC, without entries to all the peers.
+func (r *raft) bcastHeartbeat() {
+ lastCtx := r.readOnly.lastPendingRequestCtx()
+ if len(lastCtx) == 0 {
+ r.bcastHeartbeatWithCtx(nil)
+ } else {
+ r.bcastHeartbeatWithCtx([]byte(lastCtx))
+ }
+}
+
+func (r *raft) bcastHeartbeatWithCtx(ctx []byte) {
+ for id := range r.prs {
+ if id == r.id {
+ continue
+ }
+ r.sendHeartbeat(id, ctx)
+ }
+}
+
+// maybeCommit attempts to advance the commit index. Returns true if
+// the commit index changed (in which case the caller should call
+// r.bcastAppend).
+func (r *raft) maybeCommit() bool {
+ // TODO(bmizerany): optimize.. Currently naive
+ mis := make(uint64Slice, 0, len(r.prs))
+ for id := range r.prs {
+ mis = append(mis, r.prs[id].Match)
+ }
+ sort.Sort(sort.Reverse(mis))
+ mci := mis[r.quorum()-1]
+ return r.raftLog.maybeCommit(mci, r.Term)
+}
+
+func (r *raft) reset(term uint64) {
+ if r.Term != term {
+ r.Term = term
+ r.Vote = None
+ }
+ r.lead = None
+
+ r.electionElapsed = 0
+ r.heartbeatElapsed = 0
+ r.resetRandomizedElectionTimeout()
+
+ r.abortLeaderTransfer()
+
+ r.votes = make(map[uint64]bool)
+ for id := range r.prs {
+ r.prs[id] = &Progress{Next: r.raftLog.lastIndex() + 1, ins: newInflights(r.maxInflight)}
+ if id == r.id {
+ r.prs[id].Match = r.raftLog.lastIndex()
+ }
+ }
+ r.pendingConf = false
+ r.readOnly = newReadOnly(r.readOnly.option)
+}
+
+func (r *raft) appendEntry(es ...pb.Entry) {
+ li := r.raftLog.lastIndex()
+ for i := range es {
+ es[i].Term = r.Term
+ es[i].Index = li + 1 + uint64(i)
+ }
+ r.raftLog.append(es...)
+ r.prs[r.id].maybeUpdate(r.raftLog.lastIndex())
+ // Regardless of maybeCommit's return, our caller will call bcastAppend.
+ r.maybeCommit()
+}
+
+// tickElection is run by followers and candidates after r.electionTimeout.
+func (r *raft) tickElection() {
+ r.electionElapsed++
+
+ if r.promotable() && r.pastElectionTimeout() {
+ r.electionElapsed = 0
+ r.Step(pb.Message{From: r.id, Type: pb.MsgHup})
+ }
+}
+
+// tickHeartbeat is run by leaders to send a MsgBeat after r.heartbeatTimeout.
+func (r *raft) tickHeartbeat() {
+ r.heartbeatElapsed++
+ r.electionElapsed++
+
+ if r.electionElapsed >= r.electionTimeout {
+ r.electionElapsed = 0
+ if r.checkQuorum {
+ r.Step(pb.Message{From: r.id, Type: pb.MsgCheckQuorum})
+ }
+ // If current leader cannot transfer leadership in electionTimeout, it becomes leader again.
+ if r.state == StateLeader && r.leadTransferee != None {
+ r.abortLeaderTransfer()
+ }
+ }
+
+ if r.state != StateLeader {
+ return
+ }
+
+ if r.heartbeatElapsed >= r.heartbeatTimeout {
+ r.heartbeatElapsed = 0
+ r.Step(pb.Message{From: r.id, Type: pb.MsgBeat})
+ }
+}
+
+func (r *raft) becomeFollower(term uint64, lead uint64) {
+ r.step = stepFollower
+ r.reset(term)
+ r.tick = r.tickElection
+ r.lead = lead
+ r.state = StateFollower
+ r.logger.Infof("%x became follower at term %d", r.id, r.Term)
+}
+
+func (r *raft) becomeCandidate() {
+ // TODO(xiangli) remove the panic when the raft implementation is stable
+ if r.state == StateLeader {
+ panic("invalid transition [leader -> candidate]")
+ }
+ r.step = stepCandidate
+ r.reset(r.Term + 1)
+ r.tick = r.tickElection
+ r.Vote = r.id
+ r.state = StateCandidate
+ r.logger.Infof("%x became candidate at term %d", r.id, r.Term)
+}
+
+func (r *raft) becomePreCandidate() {
+ // TODO(xiangli) remove the panic when the raft implementation is stable
+ if r.state == StateLeader {
+ panic("invalid transition [leader -> pre-candidate]")
+ }
+ // Becoming a pre-candidate changes our step functions and state,
+ // but doesn't change anything else. In particular it does not increase
+ // r.Term or change r.Vote.
+ r.step = stepCandidate
+ r.tick = r.tickElection
+ r.state = StatePreCandidate
+ r.logger.Infof("%x became pre-candidate at term %d", r.id, r.Term)
+}
+
+func (r *raft) becomeLeader() {
+ // TODO(xiangli) remove the panic when the raft implementation is stable
+ if r.state == StateFollower {
+ panic("invalid transition [follower -> leader]")
+ }
+ r.step = stepLeader
+ r.reset(r.Term)
+ r.tick = r.tickHeartbeat
+ r.lead = r.id
+ r.state = StateLeader
+ ents, err := r.raftLog.entries(r.raftLog.committed+1, noLimit)
+ if err != nil {
+ r.logger.Panicf("unexpected error getting uncommitted entries (%v)", err)
+ }
+
+ nconf := numOfPendingConf(ents)
+ if nconf > 1 {
+ panic("unexpected multiple uncommitted config entry")
+ }
+ if nconf == 1 {
+ r.pendingConf = true
+ }
+
+ r.appendEntry(pb.Entry{Data: nil})
+ r.logger.Infof("%x became leader at term %d", r.id, r.Term)
+}
+
+func (r *raft) campaign(t CampaignType) {
+ var term uint64
+ var voteMsg pb.MessageType
+ if t == campaignPreElection {
+ r.becomePreCandidate()
+ voteMsg = pb.MsgPreVote
+ // PreVote RPCs are sent for the next term before we've incremented r.Term.
+ term = r.Term + 1
+ } else {
+ r.becomeCandidate()
+ voteMsg = pb.MsgVote
+ term = r.Term
+ }
+ if r.quorum() == r.poll(r.id, voteRespMsgType(voteMsg), true) {
+ // We won the election after voting for ourselves (which must mean that
+ // this is a single-node cluster). Advance to the next state.
+ if t == campaignPreElection {
+ r.campaign(campaignElection)
+ } else {
+ r.becomeLeader()
+ }
+ return
+ }
+ for id := range r.prs {
+ if id == r.id {
+ continue
+ }
+ r.logger.Infof("%x [logterm: %d, index: %d] sent %s request to %x at term %d",
+ r.id, r.raftLog.lastTerm(), r.raftLog.lastIndex(), voteMsg, id, r.Term)
+
+ var ctx []byte
+ if t == campaignTransfer {
+ ctx = []byte(t)
+ }
+ r.send(pb.Message{Term: term, To: id, Type: voteMsg, Index: r.raftLog.lastIndex(), LogTerm: r.raftLog.lastTerm(), Context: ctx})
+ }
+}
+
+func (r *raft) poll(id uint64, t pb.MessageType, v bool) (granted int) {
+ if v {
+ r.logger.Infof("%x received %s from %x at term %d", r.id, t, id, r.Term)
+ } else {
+ r.logger.Infof("%x received %s rejection from %x at term %d", r.id, t, id, r.Term)
+ }
+ if _, ok := r.votes[id]; !ok {
+ r.votes[id] = v
+ }
+ for _, vv := range r.votes {
+ if vv {
+ granted++
+ }
+ }
+ return granted
+}
+
+func (r *raft) Step(m pb.Message) error {
+ // Handle the message term, which may result in our stepping down to a follower.
+ switch {
+ case m.Term == 0:
+ // local message
+ case m.Term > r.Term:
+ lead := m.From
+ if m.Type == pb.MsgVote || m.Type == pb.MsgPreVote {
+ force := bytes.Equal(m.Context, []byte(campaignTransfer))
+ inLease := r.checkQuorum && r.lead != None && r.electionElapsed < r.electionTimeout
+ if !force && inLease {
+ // If a server receives a RequestVote request within the minimum election timeout
+ // of hearing from a current leader, it does not update its term or grant its vote
+ r.logger.Infof("%x [logterm: %d, index: %d, vote: %x] ignored %s from %x [logterm: %d, index: %d] at term %d: lease is not expired (remaining ticks: %d)",
+ r.id, r.raftLog.lastTerm(), r.raftLog.lastIndex(), r.Vote, m.Type, m.From, m.LogTerm, m.Index, r.Term, r.electionTimeout-r.electionElapsed)
+ return nil
+ }
+ lead = None
+ }
+ switch {
+ case m.Type == pb.MsgPreVote:
+ // Never change our term in response to a PreVote
+ case m.Type == pb.MsgPreVoteResp && !m.Reject:
+ // We send pre-vote requests with a term in our future. If the
+ // pre-vote is granted, we will increment our term when we get a
+ // quorum. If it is not, the term comes from the node that
+ // rejected our vote so we should become a follower at the new
+ // term.
+ default:
+ r.logger.Infof("%x [term: %d] received a %s message with higher term from %x [term: %d]",
+ r.id, r.Term, m.Type, m.From, m.Term)
+ r.becomeFollower(m.Term, lead)
+ }
+
+ case m.Term < r.Term:
+ if r.checkQuorum && (m.Type == pb.MsgHeartbeat || m.Type == pb.MsgApp) {
+ // We have received messages from a leader at a lower term. It is possible
+ // that these messages were simply delayed in the network, but this could
+ // also mean that this node has advanced its term number during a network
+ // partition, and it is now unable to either win an election or to rejoin
+ // the majority on the old term. If checkQuorum is false, this will be
+ // handled by incrementing term numbers in response to MsgVote with a
+ // higher term, but if checkQuorum is true we may not advance the term on
+ // MsgVote and must generate other messages to advance the term. The net
+ // result of these two features is to minimize the disruption caused by
+ // nodes that have been removed from the cluster's configuration: a
+ // removed node will send MsgVotes (or MsgPreVotes) which will be ignored,
+ // but it will not receive MsgApp or MsgHeartbeat, so it will not create
+ // disruptive term increases
+ r.send(pb.Message{To: m.From, Type: pb.MsgAppResp})
+ } else {
+ // ignore other cases
+ r.logger.Infof("%x [term: %d] ignored a %s message with lower term from %x [term: %d]",
+ r.id, r.Term, m.Type, m.From, m.Term)
+ }
+ return nil
+ }
+
+ switch m.Type {
+ case pb.MsgHup:
+ if r.state != StateLeader {
+ ents, err := r.raftLog.slice(r.raftLog.applied+1, r.raftLog.committed+1, noLimit)
+ if err != nil {
+ r.logger.Panicf("unexpected error getting unapplied entries (%v)", err)
+ }
+ if n := numOfPendingConf(ents); n != 0 && r.raftLog.committed > r.raftLog.applied {
+ r.logger.Warningf("%x cannot campaign at term %d since there are still %d pending configuration changes to apply", r.id, r.Term, n)
+ return nil
+ }
+
+ r.logger.Infof("%x is starting a new election at term %d", r.id, r.Term)
+ if r.preVote {
+ r.campaign(campaignPreElection)
+ } else {
+ r.campaign(campaignElection)
+ }
+ } else {
+ r.logger.Debugf("%x ignoring MsgHup because already leader", r.id)
+ }
+
+ case pb.MsgVote, pb.MsgPreVote:
+ // The m.Term > r.Term clause is for MsgPreVote. For MsgVote m.Term should
+ // always equal r.Term.
+ if (r.Vote == None || m.Term > r.Term || r.Vote == m.From) && r.raftLog.isUpToDate(m.Index, m.LogTerm) {
+ r.logger.Infof("%x [logterm: %d, index: %d, vote: %x] cast %s for %x [logterm: %d, index: %d] at term %d",
+ r.id, r.raftLog.lastTerm(), r.raftLog.lastIndex(), r.Vote, m.Type, m.From, m.LogTerm, m.Index, r.Term)
+ r.send(pb.Message{To: m.From, Type: voteRespMsgType(m.Type)})
+ if m.Type == pb.MsgVote {
+ // Only record real votes.
+ r.electionElapsed = 0
+ r.Vote = m.From
+ }
+ } else {
+ r.logger.Infof("%x [logterm: %d, index: %d, vote: %x] rejected %s from %x [logterm: %d, index: %d] at term %d",
+ r.id, r.raftLog.lastTerm(), r.raftLog.lastIndex(), r.Vote, m.Type, m.From, m.LogTerm, m.Index, r.Term)
+ r.send(pb.Message{To: m.From, Type: voteRespMsgType(m.Type), Reject: true})
+ }
+
+ default:
+ r.step(r, m)
+ }
+ return nil
+}
+
+type stepFunc func(r *raft, m pb.Message)
+
+func stepLeader(r *raft, m pb.Message) {
+ // These message types do not require any progress for m.From.
+ switch m.Type {
+ case pb.MsgBeat:
+ r.bcastHeartbeat()
+ return
+ case pb.MsgCheckQuorum:
+ if !r.checkQuorumActive() {
+ r.logger.Warningf("%x stepped down to follower since quorum is not active", r.id)
+ r.becomeFollower(r.Term, None)
+ }
+ return
+ case pb.MsgProp:
+ if len(m.Entries) == 0 {
+ r.logger.Panicf("%x stepped empty MsgProp", r.id)
+ }
+ if _, ok := r.prs[r.id]; !ok {
+ // If we are not currently a member of the range (i.e. this node
+ // was removed from the configuration while serving as leader),
+ // drop any new proposals.
+ return
+ }
+ if r.leadTransferee != None {
+ r.logger.Debugf("%x [term %d] transfer leadership to %x is in progress; dropping proposal", r.id, r.Term, r.leadTransferee)
+ return
+ }
+
+ for i, e := range m.Entries {
+ if e.Type == pb.EntryConfChange {
+ if r.pendingConf {
+ r.logger.Infof("propose conf %s ignored since pending unapplied configuration", e.String())
+ m.Entries[i] = pb.Entry{Type: pb.EntryNormal}
+ }
+ r.pendingConf = true
+ }
+ }
+ r.appendEntry(m.Entries...)
+ r.bcastAppend()
+ return
+ case pb.MsgReadIndex:
+ if r.quorum() > 1 {
+ if r.raftLog.zeroTermOnErrCompacted(r.raftLog.term(r.raftLog.committed)) != r.Term {
+ // Reject read only request when this leader has not committed any log entry at its term.
+ return
+ }
+
+ // thinking: use an interally defined context instead of the user given context.
+ // We can express this in terms of the term and index instead of a user-supplied value.
+ // This would allow multiple reads to piggyback on the same message.
+ switch r.readOnly.option {
+ case ReadOnlySafe:
+ r.readOnly.addRequest(r.raftLog.committed, m)
+ r.bcastHeartbeatWithCtx(m.Entries[0].Data)
+ case ReadOnlyLeaseBased:
+ var ri uint64
+ if r.checkQuorum {
+ ri = r.raftLog.committed
+ }
+ if m.From == None || m.From == r.id { // from local member
+ r.readStates = append(r.readStates, ReadState{Index: r.raftLog.committed, RequestCtx: m.Entries[0].Data})
+ } else {
+ r.send(pb.Message{To: m.From, Type: pb.MsgReadIndexResp, Index: ri, Entries: m.Entries})
+ }
+ }
+ } else {
+ r.readStates = append(r.readStates, ReadState{Index: r.raftLog.committed, RequestCtx: m.Entries[0].Data})
+ }
+
+ return
+ }
+
+ // All other message types require a progress for m.From (pr).
+ pr, prOk := r.prs[m.From]
+ if !prOk {
+ r.logger.Debugf("%x no progress available for %x", r.id, m.From)
+ return
+ }
+ switch m.Type {
+ case pb.MsgAppResp:
+ pr.RecentActive = true
+
+ if m.Reject {
+ r.logger.Debugf("%x received msgApp rejection(lastindex: %d) from %x for index %d",
+ r.id, m.RejectHint, m.From, m.Index)
+ if pr.maybeDecrTo(m.Index, m.RejectHint) {
+ r.logger.Debugf("%x decreased progress of %x to [%s]", r.id, m.From, pr)
+ if pr.State == ProgressStateReplicate {
+ pr.becomeProbe()
+ }
+ r.sendAppend(m.From)
+ }
+ } else {
+ oldPaused := pr.IsPaused()
+ if pr.maybeUpdate(m.Index) {
+ switch {
+ case pr.State == ProgressStateProbe:
+ pr.becomeReplicate()
+ case pr.State == ProgressStateSnapshot && pr.needSnapshotAbort():
+ r.logger.Debugf("%x snapshot aborted, resumed sending replication messages to %x [%s]", r.id, m.From, pr)
+ pr.becomeProbe()
+ case pr.State == ProgressStateReplicate:
+ pr.ins.freeTo(m.Index)
+ }
+
+ if r.maybeCommit() {
+ r.bcastAppend()
+ } else if oldPaused {
+ // update() reset the wait state on this node. If we had delayed sending
+ // an update before, send it now.
+ r.sendAppend(m.From)
+ }
+ // Transfer leadership is in progress.
+ if m.From == r.leadTransferee && pr.Match == r.raftLog.lastIndex() {
+ r.logger.Infof("%x sent MsgTimeoutNow to %x after received MsgAppResp", r.id, m.From)
+ r.sendTimeoutNow(m.From)
+ }
+ }
+ }
+ case pb.MsgHeartbeatResp:
+ pr.RecentActive = true
+ pr.resume()
+
+ // free one slot for the full inflights window to allow progress.
+ if pr.State == ProgressStateReplicate && pr.ins.full() {
+ pr.ins.freeFirstOne()
+ }
+ if pr.Match < r.raftLog.lastIndex() {
+ r.sendAppend(m.From)
+ }
+
+ if r.readOnly.option != ReadOnlySafe || len(m.Context) == 0 {
+ return
+ }
+
+ ackCount := r.readOnly.recvAck(m)
+ if ackCount < r.quorum() {
+ return
+ }
+
+ rss := r.readOnly.advance(m)
+ for _, rs := range rss {
+ req := rs.req
+ if req.From == None || req.From == r.id { // from local member
+ r.readStates = append(r.readStates, ReadState{Index: rs.index, RequestCtx: req.Entries[0].Data})
+ } else {
+ r.send(pb.Message{To: req.From, Type: pb.MsgReadIndexResp, Index: rs.index, Entries: req.Entries})
+ }
+ }
+ case pb.MsgSnapStatus:
+ if pr.State != ProgressStateSnapshot {
+ return
+ }
+ if !m.Reject {
+ pr.becomeProbe()
+ r.logger.Debugf("%x snapshot succeeded, resumed sending replication messages to %x [%s]", r.id, m.From, pr)
+ } else {
+ pr.snapshotFailure()
+ pr.becomeProbe()
+ r.logger.Debugf("%x snapshot failed, resumed sending replication messages to %x [%s]", r.id, m.From, pr)
+ }
+ // If snapshot finish, wait for the msgAppResp from the remote node before sending
+ // out the next msgApp.
+ // If snapshot failure, wait for a heartbeat interval before next try
+ pr.pause()
+ case pb.MsgUnreachable:
+ // During optimistic replication, if the remote becomes unreachable,
+ // there is huge probability that a MsgApp is lost.
+ if pr.State == ProgressStateReplicate {
+ pr.becomeProbe()
+ }
+ r.logger.Debugf("%x failed to send message to %x because it is unreachable [%s]", r.id, m.From, pr)
+ case pb.MsgTransferLeader:
+ leadTransferee := m.From
+ lastLeadTransferee := r.leadTransferee
+ if lastLeadTransferee != None {
+ if lastLeadTransferee == leadTransferee {
+ r.logger.Infof("%x [term %d] transfer leadership to %x is in progress, ignores request to same node %x",
+ r.id, r.Term, leadTransferee, leadTransferee)
+ return
+ }
+ r.abortLeaderTransfer()
+ r.logger.Infof("%x [term %d] abort previous transferring leadership to %x", r.id, r.Term, lastLeadTransferee)
+ }
+ if leadTransferee == r.id {
+ r.logger.Debugf("%x is already leader. Ignored transferring leadership to self", r.id)
+ return
+ }
+ // Transfer leadership to third party.
+ r.logger.Infof("%x [term %d] starts to transfer leadership to %x", r.id, r.Term, leadTransferee)
+ // Transfer leadership should be finished in one electionTimeout, so reset r.electionElapsed.
+ r.electionElapsed = 0
+ r.leadTransferee = leadTransferee
+ if pr.Match == r.raftLog.lastIndex() {
+ r.sendTimeoutNow(leadTransferee)
+ r.logger.Infof("%x sends MsgTimeoutNow to %x immediately as %x already has up-to-date log", r.id, leadTransferee, leadTransferee)
+ } else {
+ r.sendAppend(leadTransferee)
+ }
+ }
+}
+
+// stepCandidate is shared by StateCandidate and StatePreCandidate; the difference is
+// whether they respond to MsgVoteResp or MsgPreVoteResp.
+func stepCandidate(r *raft, m pb.Message) {
+ // Only handle vote responses corresponding to our candidacy (while in
+ // StateCandidate, we may get stale MsgPreVoteResp messages in this term from
+ // our pre-candidate state).
+ var myVoteRespType pb.MessageType
+ if r.state == StatePreCandidate {
+ myVoteRespType = pb.MsgPreVoteResp
+ } else {
+ myVoteRespType = pb.MsgVoteResp
+ }
+ switch m.Type {
+ case pb.MsgProp:
+ r.logger.Infof("%x no leader at term %d; dropping proposal", r.id, r.Term)
+ return
+ case pb.MsgApp:
+ r.becomeFollower(r.Term, m.From)
+ r.handleAppendEntries(m)
+ case pb.MsgHeartbeat:
+ r.becomeFollower(r.Term, m.From)
+ r.handleHeartbeat(m)
+ case pb.MsgSnap:
+ r.becomeFollower(m.Term, m.From)
+ r.handleSnapshot(m)
+ case myVoteRespType:
+ gr := r.poll(m.From, m.Type, !m.Reject)
+ r.logger.Infof("%x [quorum:%d] has received %d %s votes and %d vote rejections", r.id, r.quorum(), gr, m.Type, len(r.votes)-gr)
+ switch r.quorum() {
+ case gr:
+ if r.state == StatePreCandidate {
+ r.campaign(campaignElection)
+ } else {
+ r.becomeLeader()
+ r.bcastAppend()
+ }
+ case len(r.votes) - gr:
+ r.becomeFollower(r.Term, None)
+ }
+ case pb.MsgTimeoutNow:
+ r.logger.Debugf("%x [term %d state %v] ignored MsgTimeoutNow from %x", r.id, r.Term, r.state, m.From)
+ }
+}
+
+func stepFollower(r *raft, m pb.Message) {
+ switch m.Type {
+ case pb.MsgProp:
+ if r.lead == None {
+ r.logger.Infof("%x no leader at term %d; dropping proposal", r.id, r.Term)
+ return
+ }
+ m.To = r.lead
+ r.send(m)
+ case pb.MsgApp:
+ r.electionElapsed = 0
+ r.lead = m.From
+ r.handleAppendEntries(m)
+ case pb.MsgHeartbeat:
+ r.electionElapsed = 0
+ r.lead = m.From
+ r.handleHeartbeat(m)
+ case pb.MsgSnap:
+ r.electionElapsed = 0
+ r.lead = m.From
+ r.handleSnapshot(m)
+ case pb.MsgTransferLeader:
+ if r.lead == None {
+ r.logger.Infof("%x no leader at term %d; dropping leader transfer msg", r.id, r.Term)
+ return
+ }
+ m.To = r.lead
+ r.send(m)
+ case pb.MsgTimeoutNow:
+ if r.promotable() {
+ r.logger.Infof("%x [term %d] received MsgTimeoutNow from %x and starts an election to get leadership.", r.id, r.Term, m.From)
+ // Leadership transfers never use pre-vote even if r.preVote is true; we
+ // know we are not recovering from a partition so there is no need for the
+ // extra round trip.
+ r.campaign(campaignTransfer)
+ } else {
+ r.logger.Infof("%x received MsgTimeoutNow from %x but is not promotable", r.id, m.From)
+ }
+ case pb.MsgReadIndex:
+ if r.lead == None {
+ r.logger.Infof("%x no leader at term %d; dropping index reading msg", r.id, r.Term)
+ return
+ }
+ m.To = r.lead
+ r.send(m)
+ case pb.MsgReadIndexResp:
+ if len(m.Entries) != 1 {
+ r.logger.Errorf("%x invalid format of MsgReadIndexResp from %x, entries count: %d", r.id, m.From, len(m.Entries))
+ return
+ }
+ r.readStates = append(r.readStates, ReadState{Index: m.Index, RequestCtx: m.Entries[0].Data})
+ }
+}
+
+func (r *raft) handleAppendEntries(m pb.Message) {
+ if m.Index < r.raftLog.committed {
+ r.send(pb.Message{To: m.From, Type: pb.MsgAppResp, Index: r.raftLog.committed})
+ return
+ }
+
+ if mlastIndex, ok := r.raftLog.maybeAppend(m.Index, m.LogTerm, m.Commit, m.Entries...); ok {
+ r.send(pb.Message{To: m.From, Type: pb.MsgAppResp, Index: mlastIndex})
+ } else {
+ r.logger.Debugf("%x [logterm: %d, index: %d] rejected msgApp [logterm: %d, index: %d] from %x",
+ r.id, r.raftLog.zeroTermOnErrCompacted(r.raftLog.term(m.Index)), m.Index, m.LogTerm, m.Index, m.From)
+ r.send(pb.Message{To: m.From, Type: pb.MsgAppResp, Index: m.Index, Reject: true, RejectHint: r.raftLog.lastIndex()})
+ }
+}
+
+func (r *raft) handleHeartbeat(m pb.Message) {
+ r.raftLog.commitTo(m.Commit)
+ r.send(pb.Message{To: m.From, Type: pb.MsgHeartbeatResp, Context: m.Context})
+}
+
+func (r *raft) handleSnapshot(m pb.Message) {
+ sindex, sterm := m.Snapshot.Metadata.Index, m.Snapshot.Metadata.Term
+ if r.restore(m.Snapshot) {
+ r.logger.Infof("%x [commit: %d] restored snapshot [index: %d, term: %d]",
+ r.id, r.raftLog.committed, sindex, sterm)
+ r.send(pb.Message{To: m.From, Type: pb.MsgAppResp, Index: r.raftLog.lastIndex()})
+ } else {
+ r.logger.Infof("%x [commit: %d] ignored snapshot [index: %d, term: %d]",
+ r.id, r.raftLog.committed, sindex, sterm)
+ r.send(pb.Message{To: m.From, Type: pb.MsgAppResp, Index: r.raftLog.committed})
+ }
+}
+
+// restore recovers the state machine from a snapshot. It restores the log and the
+// configuration of state machine.
+func (r *raft) restore(s pb.Snapshot) bool {
+ if s.Metadata.Index <= r.raftLog.committed {
+ return false
+ }
+ if r.raftLog.matchTerm(s.Metadata.Index, s.Metadata.Term) {
+ r.logger.Infof("%x [commit: %d, lastindex: %d, lastterm: %d] fast-forwarded commit to snapshot [index: %d, term: %d]",
+ r.id, r.raftLog.committed, r.raftLog.lastIndex(), r.raftLog.lastTerm(), s.Metadata.Index, s.Metadata.Term)
+ r.raftLog.commitTo(s.Metadata.Index)
+ return false
+ }
+
+ r.logger.Infof("%x [commit: %d, lastindex: %d, lastterm: %d] starts to restore snapshot [index: %d, term: %d]",
+ r.id, r.raftLog.committed, r.raftLog.lastIndex(), r.raftLog.lastTerm(), s.Metadata.Index, s.Metadata.Term)
+
+ r.raftLog.restore(s)
+ r.prs = make(map[uint64]*Progress)
+ for _, n := range s.Metadata.ConfState.Nodes {
+ match, next := uint64(0), r.raftLog.lastIndex()+1
+ if n == r.id {
+ match = next - 1
+ }
+ r.setProgress(n, match, next)
+ r.logger.Infof("%x restored progress of %x [%s]", r.id, n, r.prs[n])
+ }
+ return true
+}
+
+// promotable indicates whether state machine can be promoted to leader,
+// which is true when its own id is in progress list.
+func (r *raft) promotable() bool {
+ _, ok := r.prs[r.id]
+ return ok
+}
+
+func (r *raft) addNode(id uint64) {
+ r.pendingConf = false
+ if _, ok := r.prs[id]; ok {
+ // Ignore any redundant addNode calls (which can happen because the
+ // initial bootstrapping entries are applied twice).
+ return
+ }
+
+ r.setProgress(id, 0, r.raftLog.lastIndex()+1)
+ // When a node is first added, we should mark it as recently active.
+ // Otherwise, CheckQuorum may cause us to step down if it is invoked
+ // before the added node has a chance to communicate with us.
+ r.prs[id].RecentActive = true
+}
+
+func (r *raft) removeNode(id uint64) {
+ r.delProgress(id)
+ r.pendingConf = false
+
+ // do not try to commit or abort transferring if there is no nodes in the cluster.
+ if len(r.prs) == 0 {
+ return
+ }
+
+ // The quorum size is now smaller, so see if any pending entries can
+ // be committed.
+ if r.maybeCommit() {
+ r.bcastAppend()
+ }
+ // If the removed node is the leadTransferee, then abort the leadership transferring.
+ if r.state == StateLeader && r.leadTransferee == id {
+ r.abortLeaderTransfer()
+ }
+}
+
+func (r *raft) resetPendingConf() { r.pendingConf = false }
+
+func (r *raft) setProgress(id, match, next uint64) {
+ r.prs[id] = &Progress{Next: next, Match: match, ins: newInflights(r.maxInflight)}
+}
+
+func (r *raft) delProgress(id uint64) {
+ delete(r.prs, id)
+}
+
+func (r *raft) loadState(state pb.HardState) {
+ if state.Commit < r.raftLog.committed || state.Commit > r.raftLog.lastIndex() {
+ r.logger.Panicf("%x state.commit %d is out of range [%d, %d]", r.id, state.Commit, r.raftLog.committed, r.raftLog.lastIndex())
+ }
+ r.raftLog.committed = state.Commit
+ r.Term = state.Term
+ r.Vote = state.Vote
+}
+
+// pastElectionTimeout returns true iff r.electionElapsed is greater
+// than or equal to the randomized election timeout in
+// [electiontimeout, 2 * electiontimeout - 1].
+func (r *raft) pastElectionTimeout() bool {
+ return r.electionElapsed >= r.randomizedElectionTimeout
+}
+
+func (r *raft) resetRandomizedElectionTimeout() {
+ r.randomizedElectionTimeout = r.electionTimeout + globalRand.Intn(r.electionTimeout)
+}
+
+// checkQuorumActive returns true if the quorum is active from
+// the view of the local raft state machine. Otherwise, it returns
+// false.
+// checkQuorumActive also resets all RecentActive to false.
+func (r *raft) checkQuorumActive() bool {
+ var act int
+
+ for id := range r.prs {
+ if id == r.id { // self is always active
+ act++
+ continue
+ }
+
+ if r.prs[id].RecentActive {
+ act++
+ }
+
+ r.prs[id].RecentActive = false
+ }
+
+ return act >= r.quorum()
+}
+
+func (r *raft) sendTimeoutNow(to uint64) {
+ r.send(pb.Message{To: to, Type: pb.MsgTimeoutNow})
+}
+
+func (r *raft) abortLeaderTransfer() {
+ r.leadTransferee = None
+}
+
+func numOfPendingConf(ents []pb.Entry) int {
+ n := 0
+ for i := range ents {
+ if ents[i].Type == pb.EntryConfChange {
+ n++
+ }
+ }
+ return n
+}
diff --git a/vendor/github.com/coreos/etcd/raft/raft_flow_control_test.go b/vendor/github.com/coreos/etcd/raft/raft_flow_control_test.go
new file mode 100644
index 00000000..c745050f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/raft_flow_control_test.go
@@ -0,0 +1,155 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "testing"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+// TestMsgAppFlowControlFull ensures:
+// 1. msgApp can fill the sending window until full
+// 2. when the window is full, no more msgApp can be sent.
+func TestMsgAppFlowControlFull(t *testing.T) {
+ r := newTestRaft(1, []uint64{1, 2}, 5, 1, NewMemoryStorage())
+ r.becomeCandidate()
+ r.becomeLeader()
+
+ pr2 := r.prs[2]
+ // force the progress to be in replicate state
+ pr2.becomeReplicate()
+ // fill in the inflights window
+ for i := 0; i < r.maxInflight; i++ {
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+ ms := r.readMessages()
+ if len(ms) != 1 {
+ t.Fatalf("#%d: len(ms) = %d, want 1", i, len(ms))
+ }
+ }
+
+ // ensure 1
+ if !pr2.ins.full() {
+ t.Fatalf("inflights.full = %t, want %t", pr2.ins.full(), true)
+ }
+
+ // ensure 2
+ for i := 0; i < 10; i++ {
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+ ms := r.readMessages()
+ if len(ms) != 0 {
+ t.Fatalf("#%d: len(ms) = %d, want 0", i, len(ms))
+ }
+ }
+}
+
+// TestMsgAppFlowControlMoveForward ensures msgAppResp can move
+// forward the sending window correctly:
+// 1. valid msgAppResp.index moves the windows to pass all smaller or equal index.
+// 2. out-of-dated msgAppResp has no effect on the sliding window.
+func TestMsgAppFlowControlMoveForward(t *testing.T) {
+ r := newTestRaft(1, []uint64{1, 2}, 5, 1, NewMemoryStorage())
+ r.becomeCandidate()
+ r.becomeLeader()
+
+ pr2 := r.prs[2]
+ // force the progress to be in replicate state
+ pr2.becomeReplicate()
+ // fill in the inflights window
+ for i := 0; i < r.maxInflight; i++ {
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+ r.readMessages()
+ }
+
+ // 1 is noop, 2 is the first proposal we just sent.
+ // so we start with 2.
+ for tt := 2; tt < r.maxInflight; tt++ {
+ // move forward the window
+ r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgAppResp, Index: uint64(tt)})
+ r.readMessages()
+
+ // fill in the inflights window again
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+ ms := r.readMessages()
+ if len(ms) != 1 {
+ t.Fatalf("#%d: len(ms) = %d, want 1", tt, len(ms))
+ }
+
+ // ensure 1
+ if !pr2.ins.full() {
+ t.Fatalf("inflights.full = %t, want %t", pr2.ins.full(), true)
+ }
+
+ // ensure 2
+ for i := 0; i < tt; i++ {
+ r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgAppResp, Index: uint64(i)})
+ if !pr2.ins.full() {
+ t.Fatalf("#%d: inflights.full = %t, want %t", tt, pr2.ins.full(), true)
+ }
+ }
+ }
+}
+
+// TestMsgAppFlowControlRecvHeartbeat ensures a heartbeat response
+// frees one slot if the window is full.
+func TestMsgAppFlowControlRecvHeartbeat(t *testing.T) {
+ r := newTestRaft(1, []uint64{1, 2}, 5, 1, NewMemoryStorage())
+ r.becomeCandidate()
+ r.becomeLeader()
+
+ pr2 := r.prs[2]
+ // force the progress to be in replicate state
+ pr2.becomeReplicate()
+ // fill in the inflights window
+ for i := 0; i < r.maxInflight; i++ {
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+ r.readMessages()
+ }
+
+ for tt := 1; tt < 5; tt++ {
+ if !pr2.ins.full() {
+ t.Fatalf("#%d: inflights.full = %t, want %t", tt, pr2.ins.full(), true)
+ }
+
+ // recv tt msgHeartbeatResp and expect one free slot
+ for i := 0; i < tt; i++ {
+ r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgHeartbeatResp})
+ r.readMessages()
+ if pr2.ins.full() {
+ t.Fatalf("#%d.%d: inflights.full = %t, want %t", tt, i, pr2.ins.full(), false)
+ }
+ }
+
+ // one slot
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+ ms := r.readMessages()
+ if len(ms) != 1 {
+ t.Fatalf("#%d: free slot = 0, want 1", tt)
+ }
+
+ // and just one slot
+ for i := 0; i < 10; i++ {
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+ ms1 := r.readMessages()
+ if len(ms1) != 0 {
+ t.Fatalf("#%d.%d: len(ms) = %d, want 0", tt, i, len(ms1))
+ }
+ }
+
+ // clear all pending messages.
+ r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgHeartbeatResp})
+ r.readMessages()
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/raft/raft_paper_test.go b/vendor/github.com/coreos/etcd/raft/raft_paper_test.go
new file mode 100644
index 00000000..2911e8aa
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/raft_paper_test.go
@@ -0,0 +1,936 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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.
+
+/*
+This file contains tests which verify that the scenarios described
+in the raft paper (https://ramcloud.stanford.edu/raft.pdf) are
+handled by the raft implementation correctly. Each test focuses on
+several sentences written in the paper. This could help us to prevent
+most implementation bugs.
+
+Each test is composed of three parts: init, test and check.
+Init part uses simple and understandable way to simulate the init state.
+Test part uses Step function to generate the scenario. Check part checks
+outgoing messages and state.
+*/
+package raft
+
+import (
+ "fmt"
+ "testing"
+
+ "reflect"
+ "sort"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+func TestFollowerUpdateTermFromMessage(t *testing.T) {
+ testUpdateTermFromMessage(t, StateFollower)
+}
+func TestCandidateUpdateTermFromMessage(t *testing.T) {
+ testUpdateTermFromMessage(t, StateCandidate)
+}
+func TestLeaderUpdateTermFromMessage(t *testing.T) {
+ testUpdateTermFromMessage(t, StateLeader)
+}
+
+// testUpdateTermFromMessage tests that if one server?s current term is
+// smaller than the other?s, then it updates its current term to the larger
+// value. If a candidate or leader discovers that its term is out of date,
+// it immediately reverts to follower state.
+// Reference: section 5.1
+func testUpdateTermFromMessage(t *testing.T, state StateType) {
+ r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ switch state {
+ case StateFollower:
+ r.becomeFollower(1, 2)
+ case StateCandidate:
+ r.becomeCandidate()
+ case StateLeader:
+ r.becomeCandidate()
+ r.becomeLeader()
+ }
+
+ r.Step(pb.Message{Type: pb.MsgApp, Term: 2})
+
+ if r.Term != 2 {
+ t.Errorf("term = %d, want %d", r.Term, 2)
+ }
+ if r.state != StateFollower {
+ t.Errorf("state = %v, want %v", r.state, StateFollower)
+ }
+}
+
+// TestRejectStaleTermMessage tests that if a server receives a request with
+// a stale term number, it rejects the request.
+// Our implementation ignores the request instead.
+// Reference: section 5.1
+func TestRejectStaleTermMessage(t *testing.T) {
+ called := false
+ fakeStep := func(r *raft, m pb.Message) {
+ called = true
+ }
+ r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ r.step = fakeStep
+ r.loadState(pb.HardState{Term: 2})
+
+ r.Step(pb.Message{Type: pb.MsgApp, Term: r.Term - 1})
+
+ if called {
+ t.Errorf("stepFunc called = %v, want %v", called, false)
+ }
+}
+
+// TestStartAsFollower tests that when servers start up, they begin as followers.
+// Reference: section 5.2
+func TestStartAsFollower(t *testing.T) {
+ r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ if r.state != StateFollower {
+ t.Errorf("state = %s, want %s", r.state, StateFollower)
+ }
+}
+
+// TestLeaderBcastBeat tests that if the leader receives a heartbeat tick,
+// it will send a msgApp with m.Index = 0, m.LogTerm=0 and empty entries as
+// heartbeat to all followers.
+// Reference: section 5.2
+func TestLeaderBcastBeat(t *testing.T) {
+ // heartbeat interval
+ hi := 1
+ r := newTestRaft(1, []uint64{1, 2, 3}, 10, hi, NewMemoryStorage())
+ r.becomeCandidate()
+ r.becomeLeader()
+ for i := 0; i < 10; i++ {
+ r.appendEntry(pb.Entry{Index: uint64(i) + 1})
+ }
+
+ for i := 0; i < hi; i++ {
+ r.tick()
+ }
+
+ msgs := r.readMessages()
+ sort.Sort(messageSlice(msgs))
+ wmsgs := []pb.Message{
+ {From: 1, To: 2, Term: 1, Type: pb.MsgHeartbeat},
+ {From: 1, To: 3, Term: 1, Type: pb.MsgHeartbeat},
+ }
+ if !reflect.DeepEqual(msgs, wmsgs) {
+ t.Errorf("msgs = %v, want %v", msgs, wmsgs)
+ }
+}
+
+func TestFollowerStartElection(t *testing.T) {
+ testNonleaderStartElection(t, StateFollower)
+}
+func TestCandidateStartNewElection(t *testing.T) {
+ testNonleaderStartElection(t, StateCandidate)
+}
+
+// testNonleaderStartElection tests that if a follower receives no communication
+// over election timeout, it begins an election to choose a new leader. It
+// increments its current term and transitions to candidate state. It then
+// votes for itself and issues RequestVote RPCs in parallel to each of the
+// other servers in the cluster.
+// Reference: section 5.2
+// Also if a candidate fails to obtain a majority, it will time out and
+// start a new election by incrementing its term and initiating another
+// round of RequestVote RPCs.
+// Reference: section 5.2
+func testNonleaderStartElection(t *testing.T, state StateType) {
+ // election timeout
+ et := 10
+ r := newTestRaft(1, []uint64{1, 2, 3}, et, 1, NewMemoryStorage())
+ switch state {
+ case StateFollower:
+ r.becomeFollower(1, 2)
+ case StateCandidate:
+ r.becomeCandidate()
+ }
+
+ for i := 1; i < 2*et; i++ {
+ r.tick()
+ }
+
+ if r.Term != 2 {
+ t.Errorf("term = %d, want 2", r.Term)
+ }
+ if r.state != StateCandidate {
+ t.Errorf("state = %s, want %s", r.state, StateCandidate)
+ }
+ if !r.votes[r.id] {
+ t.Errorf("vote for self = false, want true")
+ }
+ msgs := r.readMessages()
+ sort.Sort(messageSlice(msgs))
+ wmsgs := []pb.Message{
+ {From: 1, To: 2, Term: 2, Type: pb.MsgVote},
+ {From: 1, To: 3, Term: 2, Type: pb.MsgVote},
+ }
+ if !reflect.DeepEqual(msgs, wmsgs) {
+ t.Errorf("msgs = %v, want %v", msgs, wmsgs)
+ }
+}
+
+// TestLeaderElectionInOneRoundRPC tests all cases that may happen in
+// leader election during one round of RequestVote RPC:
+// a) it wins the election
+// b) it loses the election
+// c) it is unclear about the result
+// Reference: section 5.2
+func TestLeaderElectionInOneRoundRPC(t *testing.T) {
+ tests := []struct {
+ size int
+ votes map[uint64]bool
+ state StateType
+ }{
+ // win the election when receiving votes from a majority of the servers
+ {1, map[uint64]bool{}, StateLeader},
+ {3, map[uint64]bool{2: true, 3: true}, StateLeader},
+ {3, map[uint64]bool{2: true}, StateLeader},
+ {5, map[uint64]bool{2: true, 3: true, 4: true, 5: true}, StateLeader},
+ {5, map[uint64]bool{2: true, 3: true, 4: true}, StateLeader},
+ {5, map[uint64]bool{2: true, 3: true}, StateLeader},
+
+ // return to follower state if it receives vote denial from a majority
+ {3, map[uint64]bool{2: false, 3: false}, StateFollower},
+ {5, map[uint64]bool{2: false, 3: false, 4: false, 5: false}, StateFollower},
+ {5, map[uint64]bool{2: true, 3: false, 4: false, 5: false}, StateFollower},
+
+ // stay in candidate if it does not obtain the majority
+ {3, map[uint64]bool{}, StateCandidate},
+ {5, map[uint64]bool{2: true}, StateCandidate},
+ {5, map[uint64]bool{2: false, 3: false}, StateCandidate},
+ {5, map[uint64]bool{}, StateCandidate},
+ }
+ for i, tt := range tests {
+ r := newTestRaft(1, idsBySize(tt.size), 10, 1, NewMemoryStorage())
+
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ for id, vote := range tt.votes {
+ r.Step(pb.Message{From: id, To: 1, Type: pb.MsgVoteResp, Reject: !vote})
+ }
+
+ if r.state != tt.state {
+ t.Errorf("#%d: state = %s, want %s", i, r.state, tt.state)
+ }
+ if g := r.Term; g != 1 {
+ t.Errorf("#%d: term = %d, want %d", i, g, 1)
+ }
+ }
+}
+
+// TestFollowerVote tests that each follower will vote for at most one
+// candidate in a given term, on a first-come-first-served basis.
+// Reference: section 5.2
+func TestFollowerVote(t *testing.T) {
+ tests := []struct {
+ vote uint64
+ nvote uint64
+ wreject bool
+ }{
+ {None, 1, false},
+ {None, 2, false},
+ {1, 1, false},
+ {2, 2, false},
+ {1, 2, true},
+ {2, 1, true},
+ }
+ for i, tt := range tests {
+ r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ r.loadState(pb.HardState{Term: 1, Vote: tt.vote})
+
+ r.Step(pb.Message{From: tt.nvote, To: 1, Term: 1, Type: pb.MsgVote})
+
+ msgs := r.readMessages()
+ wmsgs := []pb.Message{
+ {From: 1, To: tt.nvote, Term: 1, Type: pb.MsgVoteResp, Reject: tt.wreject},
+ }
+ if !reflect.DeepEqual(msgs, wmsgs) {
+ t.Errorf("#%d: msgs = %v, want %v", i, msgs, wmsgs)
+ }
+ }
+}
+
+// TestCandidateFallback tests that while waiting for votes,
+// if a candidate receives an AppendEntries RPC from another server claiming
+// to be leader whose term is at least as large as the candidate's current term,
+// it recognizes the leader as legitimate and returns to follower state.
+// Reference: section 5.2
+func TestCandidateFallback(t *testing.T) {
+ tests := []pb.Message{
+ {From: 2, To: 1, Term: 1, Type: pb.MsgApp},
+ {From: 2, To: 1, Term: 2, Type: pb.MsgApp},
+ }
+ for i, tt := range tests {
+ r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ if r.state != StateCandidate {
+ t.Fatalf("unexpected state = %s, want %s", r.state, StateCandidate)
+ }
+
+ r.Step(tt)
+
+ if g := r.state; g != StateFollower {
+ t.Errorf("#%d: state = %s, want %s", i, g, StateFollower)
+ }
+ if g := r.Term; g != tt.Term {
+ t.Errorf("#%d: term = %d, want %d", i, g, tt.Term)
+ }
+ }
+}
+
+func TestFollowerElectionTimeoutRandomized(t *testing.T) {
+ SetLogger(discardLogger)
+ defer SetLogger(defaultLogger)
+ testNonleaderElectionTimeoutRandomized(t, StateFollower)
+}
+func TestCandidateElectionTimeoutRandomized(t *testing.T) {
+ SetLogger(discardLogger)
+ defer SetLogger(defaultLogger)
+ testNonleaderElectionTimeoutRandomized(t, StateCandidate)
+}
+
+// testNonleaderElectionTimeoutRandomized tests that election timeout for
+// follower or candidate is randomized.
+// Reference: section 5.2
+func testNonleaderElectionTimeoutRandomized(t *testing.T, state StateType) {
+ et := 10
+ r := newTestRaft(1, []uint64{1, 2, 3}, et, 1, NewMemoryStorage())
+ timeouts := make(map[int]bool)
+ for round := 0; round < 50*et; round++ {
+ switch state {
+ case StateFollower:
+ r.becomeFollower(r.Term+1, 2)
+ case StateCandidate:
+ r.becomeCandidate()
+ }
+
+ time := 0
+ for len(r.readMessages()) == 0 {
+ r.tick()
+ time++
+ }
+ timeouts[time] = true
+ }
+
+ for d := et + 1; d < 2*et; d++ {
+ if !timeouts[d] {
+ t.Errorf("timeout in %d ticks should happen", d)
+ }
+ }
+}
+
+func TestFollowersElectioinTimeoutNonconflict(t *testing.T) {
+ SetLogger(discardLogger)
+ defer SetLogger(defaultLogger)
+ testNonleadersElectionTimeoutNonconflict(t, StateFollower)
+}
+func TestCandidatesElectionTimeoutNonconflict(t *testing.T) {
+ SetLogger(discardLogger)
+ defer SetLogger(defaultLogger)
+ testNonleadersElectionTimeoutNonconflict(t, StateCandidate)
+}
+
+// testNonleadersElectionTimeoutNonconflict tests that in most cases only a
+// single server(follower or candidate) will time out, which reduces the
+// likelihood of split vote in the new election.
+// Reference: section 5.2
+func testNonleadersElectionTimeoutNonconflict(t *testing.T, state StateType) {
+ et := 10
+ size := 5
+ rs := make([]*raft, size)
+ ids := idsBySize(size)
+ for k := range rs {
+ rs[k] = newTestRaft(ids[k], ids, et, 1, NewMemoryStorage())
+ }
+ conflicts := 0
+ for round := 0; round < 1000; round++ {
+ for _, r := range rs {
+ switch state {
+ case StateFollower:
+ r.becomeFollower(r.Term+1, None)
+ case StateCandidate:
+ r.becomeCandidate()
+ }
+ }
+
+ timeoutNum := 0
+ for timeoutNum == 0 {
+ for _, r := range rs {
+ r.tick()
+ if len(r.readMessages()) > 0 {
+ timeoutNum++
+ }
+ }
+ }
+ // several rafts time out at the same tick
+ if timeoutNum > 1 {
+ conflicts++
+ }
+ }
+
+ if g := float64(conflicts) / 1000; g > 0.3 {
+ t.Errorf("probability of conflicts = %v, want <= 0.3", g)
+ }
+}
+
+// TestLeaderStartReplication tests that when receiving client proposals,
+// the leader appends the proposal to its log as a new entry, then issues
+// AppendEntries RPCs in parallel to each of the other servers to replicate
+// the entry. Also, when sending an AppendEntries RPC, the leader includes
+// the index and term of the entry in its log that immediately precedes
+// the new entries.
+// Also, it writes the new entry into stable storage.
+// Reference: section 5.3
+func TestLeaderStartReplication(t *testing.T) {
+ s := NewMemoryStorage()
+ r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, s)
+ r.becomeCandidate()
+ r.becomeLeader()
+ commitNoopEntry(r, s)
+ li := r.raftLog.lastIndex()
+
+ ents := []pb.Entry{{Data: []byte("some data")}}
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: ents})
+
+ if g := r.raftLog.lastIndex(); g != li+1 {
+ t.Errorf("lastIndex = %d, want %d", g, li+1)
+ }
+ if g := r.raftLog.committed; g != li {
+ t.Errorf("committed = %d, want %d", g, li)
+ }
+ msgs := r.readMessages()
+ sort.Sort(messageSlice(msgs))
+ wents := []pb.Entry{{Index: li + 1, Term: 1, Data: []byte("some data")}}
+ wmsgs := []pb.Message{
+ {From: 1, To: 2, Term: 1, Type: pb.MsgApp, Index: li, LogTerm: 1, Entries: wents, Commit: li},
+ {From: 1, To: 3, Term: 1, Type: pb.MsgApp, Index: li, LogTerm: 1, Entries: wents, Commit: li},
+ }
+ if !reflect.DeepEqual(msgs, wmsgs) {
+ t.Errorf("msgs = %+v, want %+v", msgs, wmsgs)
+ }
+ if g := r.raftLog.unstableEntries(); !reflect.DeepEqual(g, wents) {
+ t.Errorf("ents = %+v, want %+v", g, wents)
+ }
+}
+
+// TestLeaderCommitEntry tests that when the entry has been safely replicated,
+// the leader gives out the applied entries, which can be applied to its state
+// machine.
+// Also, the leader keeps track of the highest index it knows to be committed,
+// and it includes that index in future AppendEntries RPCs so that the other
+// servers eventually find out.
+// Reference: section 5.3
+func TestLeaderCommitEntry(t *testing.T) {
+ s := NewMemoryStorage()
+ r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, s)
+ r.becomeCandidate()
+ r.becomeLeader()
+ commitNoopEntry(r, s)
+ li := r.raftLog.lastIndex()
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("some data")}}})
+
+ for _, m := range r.readMessages() {
+ r.Step(acceptAndReply(m))
+ }
+
+ if g := r.raftLog.committed; g != li+1 {
+ t.Errorf("committed = %d, want %d", g, li+1)
+ }
+ wents := []pb.Entry{{Index: li + 1, Term: 1, Data: []byte("some data")}}
+ if g := r.raftLog.nextEnts(); !reflect.DeepEqual(g, wents) {
+ t.Errorf("nextEnts = %+v, want %+v", g, wents)
+ }
+ msgs := r.readMessages()
+ sort.Sort(messageSlice(msgs))
+ for i, m := range msgs {
+ if w := uint64(i + 2); m.To != w {
+ t.Errorf("to = %x, want %x", m.To, w)
+ }
+ if m.Type != pb.MsgApp {
+ t.Errorf("type = %v, want %v", m.Type, pb.MsgApp)
+ }
+ if m.Commit != li+1 {
+ t.Errorf("commit = %d, want %d", m.Commit, li+1)
+ }
+ }
+}
+
+// TestLeaderAcknowledgeCommit tests that a log entry is committed once the
+// leader that created the entry has replicated it on a majority of the servers.
+// Reference: section 5.3
+func TestLeaderAcknowledgeCommit(t *testing.T) {
+ tests := []struct {
+ size int
+ acceptors map[uint64]bool
+ wack bool
+ }{
+ {1, nil, true},
+ {3, nil, false},
+ {3, map[uint64]bool{2: true}, true},
+ {3, map[uint64]bool{2: true, 3: true}, true},
+ {5, nil, false},
+ {5, map[uint64]bool{2: true}, false},
+ {5, map[uint64]bool{2: true, 3: true}, true},
+ {5, map[uint64]bool{2: true, 3: true, 4: true}, true},
+ {5, map[uint64]bool{2: true, 3: true, 4: true, 5: true}, true},
+ }
+ for i, tt := range tests {
+ s := NewMemoryStorage()
+ r := newTestRaft(1, idsBySize(tt.size), 10, 1, s)
+ r.becomeCandidate()
+ r.becomeLeader()
+ commitNoopEntry(r, s)
+ li := r.raftLog.lastIndex()
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("some data")}}})
+
+ for _, m := range r.readMessages() {
+ if tt.acceptors[m.To] {
+ r.Step(acceptAndReply(m))
+ }
+ }
+
+ if g := r.raftLog.committed > li; g != tt.wack {
+ t.Errorf("#%d: ack commit = %v, want %v", i, g, tt.wack)
+ }
+ }
+}
+
+// TestLeaderCommitPrecedingEntries tests that when leader commits a log entry,
+// it also commits all preceding entries in the leader?s log, including
+// entries created by previous leaders.
+// Also, it applies the entry to its local state machine (in log order).
+// Reference: section 5.3
+func TestLeaderCommitPrecedingEntries(t *testing.T) {
+ tests := [][]pb.Entry{
+ {},
+ {{Term: 2, Index: 1}},
+ {{Term: 1, Index: 1}, {Term: 2, Index: 2}},
+ {{Term: 1, Index: 1}},
+ }
+ for i, tt := range tests {
+ storage := NewMemoryStorage()
+ storage.Append(tt)
+ r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, storage)
+ r.loadState(pb.HardState{Term: 2})
+ r.becomeCandidate()
+ r.becomeLeader()
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("some data")}}})
+
+ for _, m := range r.readMessages() {
+ r.Step(acceptAndReply(m))
+ }
+
+ li := uint64(len(tt))
+ wents := append(tt, pb.Entry{Term: 3, Index: li + 1}, pb.Entry{Term: 3, Index: li + 2, Data: []byte("some data")})
+ if g := r.raftLog.nextEnts(); !reflect.DeepEqual(g, wents) {
+ t.Errorf("#%d: ents = %+v, want %+v", i, g, wents)
+ }
+ }
+}
+
+// TestFollowerCommitEntry tests that once a follower learns that a log entry
+// is committed, it applies the entry to its local state machine (in log order).
+// Reference: section 5.3
+func TestFollowerCommitEntry(t *testing.T) {
+ tests := []struct {
+ ents []pb.Entry
+ commit uint64
+ }{
+ {
+ []pb.Entry{
+ {Term: 1, Index: 1, Data: []byte("some data")},
+ },
+ 1,
+ },
+ {
+ []pb.Entry{
+ {Term: 1, Index: 1, Data: []byte("some data")},
+ {Term: 1, Index: 2, Data: []byte("some data2")},
+ },
+ 2,
+ },
+ {
+ []pb.Entry{
+ {Term: 1, Index: 1, Data: []byte("some data2")},
+ {Term: 1, Index: 2, Data: []byte("some data")},
+ },
+ 2,
+ },
+ {
+ []pb.Entry{
+ {Term: 1, Index: 1, Data: []byte("some data")},
+ {Term: 1, Index: 2, Data: []byte("some data2")},
+ },
+ 1,
+ },
+ }
+ for i, tt := range tests {
+ r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ r.becomeFollower(1, 2)
+
+ r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgApp, Term: 1, Entries: tt.ents, Commit: tt.commit})
+
+ if g := r.raftLog.committed; g != tt.commit {
+ t.Errorf("#%d: committed = %d, want %d", i, g, tt.commit)
+ }
+ wents := tt.ents[:int(tt.commit)]
+ if g := r.raftLog.nextEnts(); !reflect.DeepEqual(g, wents) {
+ t.Errorf("#%d: nextEnts = %v, want %v", i, g, wents)
+ }
+ }
+}
+
+// TestFollowerCheckMsgApp tests that if the follower does not find an
+// entry in its log with the same index and term as the one in AppendEntries RPC,
+// then it refuses the new entries. Otherwise it replies that it accepts the
+// append entries.
+// Reference: section 5.3
+func TestFollowerCheckMsgApp(t *testing.T) {
+ ents := []pb.Entry{{Term: 1, Index: 1}, {Term: 2, Index: 2}}
+ tests := []struct {
+ term uint64
+ index uint64
+ windex uint64
+ wreject bool
+ wrejectHint uint64
+ }{
+ // match with committed entries
+ {0, 0, 1, false, 0},
+ {ents[0].Term, ents[0].Index, 1, false, 0},
+ // match with uncommitted entries
+ {ents[1].Term, ents[1].Index, 2, false, 0},
+
+ // unmatch with existing entry
+ {ents[0].Term, ents[1].Index, ents[1].Index, true, 2},
+ // unexisting entry
+ {ents[1].Term + 1, ents[1].Index + 1, ents[1].Index + 1, true, 2},
+ }
+ for i, tt := range tests {
+ storage := NewMemoryStorage()
+ storage.Append(ents)
+ r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, storage)
+ r.loadState(pb.HardState{Commit: 1})
+ r.becomeFollower(2, 2)
+
+ r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgApp, Term: 2, LogTerm: tt.term, Index: tt.index})
+
+ msgs := r.readMessages()
+ wmsgs := []pb.Message{
+ {From: 1, To: 2, Type: pb.MsgAppResp, Term: 2, Index: tt.windex, Reject: tt.wreject, RejectHint: tt.wrejectHint},
+ }
+ if !reflect.DeepEqual(msgs, wmsgs) {
+ t.Errorf("#%d: msgs = %+v, want %+v", i, msgs, wmsgs)
+ }
+ }
+}
+
+// TestFollowerAppendEntries tests that when AppendEntries RPC is valid,
+// the follower will delete the existing conflict entry and all that follow it,
+// and append any new entries not already in the log.
+// Also, it writes the new entry into stable storage.
+// Reference: section 5.3
+func TestFollowerAppendEntries(t *testing.T) {
+ tests := []struct {
+ index, term uint64
+ ents []pb.Entry
+ wents []pb.Entry
+ wunstable []pb.Entry
+ }{
+ {
+ 2, 2,
+ []pb.Entry{{Term: 3, Index: 3}},
+ []pb.Entry{{Term: 1, Index: 1}, {Term: 2, Index: 2}, {Term: 3, Index: 3}},
+ []pb.Entry{{Term: 3, Index: 3}},
+ },
+ {
+ 1, 1,
+ []pb.Entry{{Term: 3, Index: 2}, {Term: 4, Index: 3}},
+ []pb.Entry{{Term: 1, Index: 1}, {Term: 3, Index: 2}, {Term: 4, Index: 3}},
+ []pb.Entry{{Term: 3, Index: 2}, {Term: 4, Index: 3}},
+ },
+ {
+ 0, 0,
+ []pb.Entry{{Term: 1, Index: 1}},
+ []pb.Entry{{Term: 1, Index: 1}, {Term: 2, Index: 2}},
+ nil,
+ },
+ {
+ 0, 0,
+ []pb.Entry{{Term: 3, Index: 1}},
+ []pb.Entry{{Term: 3, Index: 1}},
+ []pb.Entry{{Term: 3, Index: 1}},
+ },
+ }
+ for i, tt := range tests {
+ storage := NewMemoryStorage()
+ storage.Append([]pb.Entry{{Term: 1, Index: 1}, {Term: 2, Index: 2}})
+ r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, storage)
+ r.becomeFollower(2, 2)
+
+ r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgApp, Term: 2, LogTerm: tt.term, Index: tt.index, Entries: tt.ents})
+
+ if g := r.raftLog.allEntries(); !reflect.DeepEqual(g, tt.wents) {
+ t.Errorf("#%d: ents = %+v, want %+v", i, g, tt.wents)
+ }
+ if g := r.raftLog.unstableEntries(); !reflect.DeepEqual(g, tt.wunstable) {
+ t.Errorf("#%d: unstableEnts = %+v, want %+v", i, g, tt.wunstable)
+ }
+ }
+}
+
+// TestLeaderSyncFollowerLog tests that the leader could bring a follower's log
+// into consistency with its own.
+// Reference: section 5.3, figure 7
+func TestLeaderSyncFollowerLog(t *testing.T) {
+ ents := []pb.Entry{
+ {},
+ {Term: 1, Index: 1}, {Term: 1, Index: 2}, {Term: 1, Index: 3},
+ {Term: 4, Index: 4}, {Term: 4, Index: 5},
+ {Term: 5, Index: 6}, {Term: 5, Index: 7},
+ {Term: 6, Index: 8}, {Term: 6, Index: 9}, {Term: 6, Index: 10},
+ }
+ term := uint64(8)
+ tests := [][]pb.Entry{
+ {
+ {},
+ {Term: 1, Index: 1}, {Term: 1, Index: 2}, {Term: 1, Index: 3},
+ {Term: 4, Index: 4}, {Term: 4, Index: 5},
+ {Term: 5, Index: 6}, {Term: 5, Index: 7},
+ {Term: 6, Index: 8}, {Term: 6, Index: 9},
+ },
+ {
+ {},
+ {Term: 1, Index: 1}, {Term: 1, Index: 2}, {Term: 1, Index: 3},
+ {Term: 4, Index: 4},
+ },
+ {
+ {},
+ {Term: 1, Index: 1}, {Term: 1, Index: 2}, {Term: 1, Index: 3},
+ {Term: 4, Index: 4}, {Term: 4, Index: 5},
+ {Term: 5, Index: 6}, {Term: 5, Index: 7},
+ {Term: 6, Index: 8}, {Term: 6, Index: 9}, {Term: 6, Index: 10}, {Term: 6, Index: 11},
+ },
+ {
+ {},
+ {Term: 1, Index: 1}, {Term: 1, Index: 2}, {Term: 1, Index: 3},
+ {Term: 4, Index: 4}, {Term: 4, Index: 5},
+ {Term: 5, Index: 6}, {Term: 5, Index: 7},
+ {Term: 6, Index: 8}, {Term: 6, Index: 9}, {Term: 6, Index: 10},
+ {Term: 7, Index: 11}, {Term: 7, Index: 12},
+ },
+ {
+ {},
+ {Term: 1, Index: 1}, {Term: 1, Index: 2}, {Term: 1, Index: 3},
+ {Term: 4, Index: 4}, {Term: 4, Index: 5}, {Term: 4, Index: 6}, {Term: 4, Index: 7},
+ },
+ {
+ {},
+ {Term: 1, Index: 1}, {Term: 1, Index: 2}, {Term: 1, Index: 3},
+ {Term: 2, Index: 4}, {Term: 2, Index: 5}, {Term: 2, Index: 6},
+ {Term: 3, Index: 7}, {Term: 3, Index: 8}, {Term: 3, Index: 9}, {Term: 3, Index: 10}, {Term: 3, Index: 11},
+ },
+ }
+ for i, tt := range tests {
+ leadStorage := NewMemoryStorage()
+ leadStorage.Append(ents)
+ lead := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, leadStorage)
+ lead.loadState(pb.HardState{Commit: lead.raftLog.lastIndex(), Term: term})
+ followerStorage := NewMemoryStorage()
+ followerStorage.Append(tt)
+ follower := newTestRaft(2, []uint64{1, 2, 3}, 10, 1, followerStorage)
+ follower.loadState(pb.HardState{Term: term - 1})
+ // It is necessary to have a three-node cluster.
+ // The second may have more up-to-date log than the first one, so the
+ // first node needs the vote from the third node to become the leader.
+ n := newNetwork(lead, follower, nopStepper)
+ n.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ // The election occurs in the term after the one we loaded with
+ // lead.loadState above.
+ n.send(pb.Message{From: 3, To: 1, Type: pb.MsgVoteResp, Term: term + 1})
+
+ n.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{}}})
+
+ if g := diffu(ltoa(lead.raftLog), ltoa(follower.raftLog)); g != "" {
+ t.Errorf("#%d: log diff:\n%s", i, g)
+ }
+ }
+}
+
+// TestVoteRequest tests that the vote request includes information about the candidate?s log
+// and are sent to all of the other nodes.
+// Reference: section 5.4.1
+func TestVoteRequest(t *testing.T) {
+ tests := []struct {
+ ents []pb.Entry
+ wterm uint64
+ }{
+ {[]pb.Entry{{Term: 1, Index: 1}}, 2},
+ {[]pb.Entry{{Term: 1, Index: 1}, {Term: 2, Index: 2}}, 3},
+ }
+ for j, tt := range tests {
+ r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ r.Step(pb.Message{
+ From: 2, To: 1, Type: pb.MsgApp, Term: tt.wterm - 1, LogTerm: 0, Index: 0, Entries: tt.ents,
+ })
+ r.readMessages()
+
+ for i := 1; i < r.electionTimeout*2; i++ {
+ r.tickElection()
+ }
+
+ msgs := r.readMessages()
+ sort.Sort(messageSlice(msgs))
+ if len(msgs) != 2 {
+ t.Fatalf("#%d: len(msg) = %d, want %d", j, len(msgs), 2)
+ }
+ for i, m := range msgs {
+ if m.Type != pb.MsgVote {
+ t.Errorf("#%d: msgType = %d, want %d", i, m.Type, pb.MsgVote)
+ }
+ if m.To != uint64(i+2) {
+ t.Errorf("#%d: to = %d, want %d", i, m.To, i+2)
+ }
+ if m.Term != tt.wterm {
+ t.Errorf("#%d: term = %d, want %d", i, m.Term, tt.wterm)
+ }
+ windex, wlogterm := tt.ents[len(tt.ents)-1].Index, tt.ents[len(tt.ents)-1].Term
+ if m.Index != windex {
+ t.Errorf("#%d: index = %d, want %d", i, m.Index, windex)
+ }
+ if m.LogTerm != wlogterm {
+ t.Errorf("#%d: logterm = %d, want %d", i, m.LogTerm, wlogterm)
+ }
+ }
+ }
+}
+
+// TestVoter tests the voter denies its vote if its own log is more up-to-date
+// than that of the candidate.
+// Reference: section 5.4.1
+func TestVoter(t *testing.T) {
+ tests := []struct {
+ ents []pb.Entry
+ logterm uint64
+ index uint64
+
+ wreject bool
+ }{
+ // same logterm
+ {[]pb.Entry{{Term: 1, Index: 1}}, 1, 1, false},
+ {[]pb.Entry{{Term: 1, Index: 1}}, 1, 2, false},
+ {[]pb.Entry{{Term: 1, Index: 1}, {Term: 1, Index: 2}}, 1, 1, true},
+ // candidate higher logterm
+ {[]pb.Entry{{Term: 1, Index: 1}}, 2, 1, false},
+ {[]pb.Entry{{Term: 1, Index: 1}}, 2, 2, false},
+ {[]pb.Entry{{Term: 1, Index: 1}, {Term: 1, Index: 2}}, 2, 1, false},
+ // voter higher logterm
+ {[]pb.Entry{{Term: 2, Index: 1}}, 1, 1, true},
+ {[]pb.Entry{{Term: 2, Index: 1}}, 1, 2, true},
+ {[]pb.Entry{{Term: 2, Index: 1}, {Term: 1, Index: 2}}, 1, 1, true},
+ }
+ for i, tt := range tests {
+ storage := NewMemoryStorage()
+ storage.Append(tt.ents)
+ r := newTestRaft(1, []uint64{1, 2}, 10, 1, storage)
+
+ r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgVote, Term: 3, LogTerm: tt.logterm, Index: tt.index})
+
+ msgs := r.readMessages()
+ if len(msgs) != 1 {
+ t.Fatalf("#%d: len(msg) = %d, want %d", i, len(msgs), 1)
+ }
+ m := msgs[0]
+ if m.Type != pb.MsgVoteResp {
+ t.Errorf("#%d: msgType = %d, want %d", i, m.Type, pb.MsgVoteResp)
+ }
+ if m.Reject != tt.wreject {
+ t.Errorf("#%d: reject = %t, want %t", i, m.Reject, tt.wreject)
+ }
+ }
+}
+
+// TestLeaderOnlyCommitsLogFromCurrentTerm tests that only log entries from the leader?s
+// current term are committed by counting replicas.
+// Reference: section 5.4.2
+func TestLeaderOnlyCommitsLogFromCurrentTerm(t *testing.T) {
+ ents := []pb.Entry{{Term: 1, Index: 1}, {Term: 2, Index: 2}}
+ tests := []struct {
+ index uint64
+ wcommit uint64
+ }{
+ // do not commit log entries in previous terms
+ {1, 0},
+ {2, 0},
+ // commit log in current term
+ {3, 3},
+ }
+ for i, tt := range tests {
+ storage := NewMemoryStorage()
+ storage.Append(ents)
+ r := newTestRaft(1, []uint64{1, 2}, 10, 1, storage)
+ r.loadState(pb.HardState{Term: 2})
+ // become leader at term 3
+ r.becomeCandidate()
+ r.becomeLeader()
+ r.readMessages()
+ // propose a entry to current term
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{}}})
+
+ r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgAppResp, Term: r.Term, Index: tt.index})
+ if r.raftLog.committed != tt.wcommit {
+ t.Errorf("#%d: commit = %d, want %d", i, r.raftLog.committed, tt.wcommit)
+ }
+ }
+}
+
+type messageSlice []pb.Message
+
+func (s messageSlice) Len() int { return len(s) }
+func (s messageSlice) Less(i, j int) bool { return fmt.Sprint(s[i]) < fmt.Sprint(s[j]) }
+func (s messageSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
+
+func commitNoopEntry(r *raft, s *MemoryStorage) {
+ if r.state != StateLeader {
+ panic("it should only be used when it is the leader")
+ }
+ r.bcastAppend()
+ // simulate the response of MsgApp
+ msgs := r.readMessages()
+ for _, m := range msgs {
+ if m.Type != pb.MsgApp || len(m.Entries) != 1 || m.Entries[0].Data != nil {
+ panic("not a message to append noop entry")
+ }
+ r.Step(acceptAndReply(m))
+ }
+ // ignore further messages to refresh followers' commit index
+ r.readMessages()
+ s.Append(r.raftLog.unstableEntries())
+ r.raftLog.appliedTo(r.raftLog.committed)
+ r.raftLog.stableTo(r.raftLog.lastIndex(), r.raftLog.lastTerm())
+}
+
+func acceptAndReply(m pb.Message) pb.Message {
+ if m.Type != pb.MsgApp {
+ panic("type should be MsgApp")
+ }
+ return pb.Message{
+ From: m.To,
+ To: m.From,
+ Term: m.Term,
+ Type: pb.MsgAppResp,
+ Index: m.Index + uint64(len(m.Entries)),
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/raft/raft_snap_test.go b/vendor/github.com/coreos/etcd/raft/raft_snap_test.go
new file mode 100644
index 00000000..3908d581
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/raft_snap_test.go
@@ -0,0 +1,134 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "testing"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+var (
+ testingSnap = pb.Snapshot{
+ Metadata: pb.SnapshotMetadata{
+ Index: 11, // magic number
+ Term: 11, // magic number
+ ConfState: pb.ConfState{Nodes: []uint64{1, 2}},
+ },
+ }
+)
+
+func TestSendingSnapshotSetPendingSnapshot(t *testing.T) {
+ storage := NewMemoryStorage()
+ sm := newTestRaft(1, []uint64{1}, 10, 1, storage)
+ sm.restore(testingSnap)
+
+ sm.becomeCandidate()
+ sm.becomeLeader()
+
+ // force set the next of node 1, so that
+ // node 1 needs a snapshot
+ sm.prs[2].Next = sm.raftLog.firstIndex()
+
+ sm.Step(pb.Message{From: 2, To: 1, Type: pb.MsgAppResp, Index: sm.prs[2].Next - 1, Reject: true})
+ if sm.prs[2].PendingSnapshot != 11 {
+ t.Fatalf("PendingSnapshot = %d, want 11", sm.prs[2].PendingSnapshot)
+ }
+}
+
+func TestPendingSnapshotPauseReplication(t *testing.T) {
+ storage := NewMemoryStorage()
+ sm := newTestRaft(1, []uint64{1, 2}, 10, 1, storage)
+ sm.restore(testingSnap)
+
+ sm.becomeCandidate()
+ sm.becomeLeader()
+
+ sm.prs[2].becomeSnapshot(11)
+
+ sm.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+ msgs := sm.readMessages()
+ if len(msgs) != 0 {
+ t.Fatalf("len(msgs) = %d, want 0", len(msgs))
+ }
+}
+
+func TestSnapshotFailure(t *testing.T) {
+ storage := NewMemoryStorage()
+ sm := newTestRaft(1, []uint64{1, 2}, 10, 1, storage)
+ sm.restore(testingSnap)
+
+ sm.becomeCandidate()
+ sm.becomeLeader()
+
+ sm.prs[2].Next = 1
+ sm.prs[2].becomeSnapshot(11)
+
+ sm.Step(pb.Message{From: 2, To: 1, Type: pb.MsgSnapStatus, Reject: true})
+ if sm.prs[2].PendingSnapshot != 0 {
+ t.Fatalf("PendingSnapshot = %d, want 0", sm.prs[2].PendingSnapshot)
+ }
+ if sm.prs[2].Next != 1 {
+ t.Fatalf("Next = %d, want 1", sm.prs[2].Next)
+ }
+ if !sm.prs[2].Paused {
+ t.Errorf("Paused = %v, want true", sm.prs[2].Paused)
+ }
+}
+
+func TestSnapshotSucceed(t *testing.T) {
+ storage := NewMemoryStorage()
+ sm := newTestRaft(1, []uint64{1, 2}, 10, 1, storage)
+ sm.restore(testingSnap)
+
+ sm.becomeCandidate()
+ sm.becomeLeader()
+
+ sm.prs[2].Next = 1
+ sm.prs[2].becomeSnapshot(11)
+
+ sm.Step(pb.Message{From: 2, To: 1, Type: pb.MsgSnapStatus, Reject: false})
+ if sm.prs[2].PendingSnapshot != 0 {
+ t.Fatalf("PendingSnapshot = %d, want 0", sm.prs[2].PendingSnapshot)
+ }
+ if sm.prs[2].Next != 12 {
+ t.Fatalf("Next = %d, want 12", sm.prs[2].Next)
+ }
+ if !sm.prs[2].Paused {
+ t.Errorf("Paused = %v, want true", sm.prs[2].Paused)
+ }
+}
+
+func TestSnapshotAbort(t *testing.T) {
+ storage := NewMemoryStorage()
+ sm := newTestRaft(1, []uint64{1, 2}, 10, 1, storage)
+ sm.restore(testingSnap)
+
+ sm.becomeCandidate()
+ sm.becomeLeader()
+
+ sm.prs[2].Next = 1
+ sm.prs[2].becomeSnapshot(11)
+
+ // A successful msgAppResp that has a higher/equal index than the
+ // pending snapshot should abort the pending snapshot.
+ sm.Step(pb.Message{From: 2, To: 1, Type: pb.MsgAppResp, Index: 11})
+ if sm.prs[2].PendingSnapshot != 0 {
+ t.Fatalf("PendingSnapshot = %d, want 0", sm.prs[2].PendingSnapshot)
+ }
+ if sm.prs[2].Next != 12 {
+ t.Fatalf("Next = %d, want 12", sm.prs[2].Next)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/raft/raft_test.go b/vendor/github.com/coreos/etcd/raft/raft_test.go
new file mode 100644
index 00000000..fae05b4d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/raft_test.go
@@ -0,0 +1,3285 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "bytes"
+ "fmt"
+ "math"
+ "math/rand"
+ "reflect"
+ "testing"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+// nextEnts returns the appliable entries and updates the applied index
+func nextEnts(r *raft, s *MemoryStorage) (ents []pb.Entry) {
+ // Transfer all unstable entries to "stable" storage.
+ s.Append(r.raftLog.unstableEntries())
+ r.raftLog.stableTo(r.raftLog.lastIndex(), r.raftLog.lastTerm())
+
+ ents = r.raftLog.nextEnts()
+ r.raftLog.appliedTo(r.raftLog.committed)
+ return ents
+}
+
+type stateMachine interface {
+ Step(m pb.Message) error
+ readMessages() []pb.Message
+}
+
+func (r *raft) readMessages() []pb.Message {
+ msgs := r.msgs
+ r.msgs = make([]pb.Message, 0)
+
+ return msgs
+}
+
+func TestProgressBecomeProbe(t *testing.T) {
+ match := uint64(1)
+ tests := []struct {
+ p *Progress
+ wnext uint64
+ }{
+ {
+ &Progress{State: ProgressStateReplicate, Match: match, Next: 5, ins: newInflights(256)},
+ 2,
+ },
+ {
+ // snapshot finish
+ &Progress{State: ProgressStateSnapshot, Match: match, Next: 5, PendingSnapshot: 10, ins: newInflights(256)},
+ 11,
+ },
+ {
+ // snapshot failure
+ &Progress{State: ProgressStateSnapshot, Match: match, Next: 5, PendingSnapshot: 0, ins: newInflights(256)},
+ 2,
+ },
+ }
+ for i, tt := range tests {
+ tt.p.becomeProbe()
+ if tt.p.State != ProgressStateProbe {
+ t.Errorf("#%d: state = %s, want %s", i, tt.p.State, ProgressStateProbe)
+ }
+ if tt.p.Match != match {
+ t.Errorf("#%d: match = %d, want %d", i, tt.p.Match, match)
+ }
+ if tt.p.Next != tt.wnext {
+ t.Errorf("#%d: next = %d, want %d", i, tt.p.Next, tt.wnext)
+ }
+ }
+}
+
+func TestProgressBecomeReplicate(t *testing.T) {
+ p := &Progress{State: ProgressStateProbe, Match: 1, Next: 5, ins: newInflights(256)}
+ p.becomeReplicate()
+
+ if p.State != ProgressStateReplicate {
+ t.Errorf("state = %s, want %s", p.State, ProgressStateReplicate)
+ }
+ if p.Match != 1 {
+ t.Errorf("match = %d, want 1", p.Match)
+ }
+ if w := p.Match + 1; p.Next != w {
+ t.Errorf("next = %d, want %d", p.Next, w)
+ }
+}
+
+func TestProgressBecomeSnapshot(t *testing.T) {
+ p := &Progress{State: ProgressStateProbe, Match: 1, Next: 5, ins: newInflights(256)}
+ p.becomeSnapshot(10)
+
+ if p.State != ProgressStateSnapshot {
+ t.Errorf("state = %s, want %s", p.State, ProgressStateSnapshot)
+ }
+ if p.Match != 1 {
+ t.Errorf("match = %d, want 1", p.Match)
+ }
+ if p.PendingSnapshot != 10 {
+ t.Errorf("pendingSnapshot = %d, want 10", p.PendingSnapshot)
+ }
+}
+
+func TestProgressUpdate(t *testing.T) {
+ prevM, prevN := uint64(3), uint64(5)
+ tests := []struct {
+ update uint64
+
+ wm uint64
+ wn uint64
+ wok bool
+ }{
+ {prevM - 1, prevM, prevN, false}, // do not decrease match, next
+ {prevM, prevM, prevN, false}, // do not decrease next
+ {prevM + 1, prevM + 1, prevN, true}, // increase match, do not decrease next
+ {prevM + 2, prevM + 2, prevN + 1, true}, // increase match, next
+ }
+ for i, tt := range tests {
+ p := &Progress{
+ Match: prevM,
+ Next: prevN,
+ }
+ ok := p.maybeUpdate(tt.update)
+ if ok != tt.wok {
+ t.Errorf("#%d: ok= %v, want %v", i, ok, tt.wok)
+ }
+ if p.Match != tt.wm {
+ t.Errorf("#%d: match= %d, want %d", i, p.Match, tt.wm)
+ }
+ if p.Next != tt.wn {
+ t.Errorf("#%d: next= %d, want %d", i, p.Next, tt.wn)
+ }
+ }
+}
+
+func TestProgressMaybeDecr(t *testing.T) {
+ tests := []struct {
+ state ProgressStateType
+ m uint64
+ n uint64
+ rejected uint64
+ last uint64
+
+ w bool
+ wn uint64
+ }{
+ {
+ // state replicate and rejected is not greater than match
+ ProgressStateReplicate, 5, 10, 5, 5, false, 10,
+ },
+ {
+ // state replicate and rejected is not greater than match
+ ProgressStateReplicate, 5, 10, 4, 4, false, 10,
+ },
+ {
+ // state replicate and rejected is greater than match
+ // directly decrease to match+1
+ ProgressStateReplicate, 5, 10, 9, 9, true, 6,
+ },
+ {
+ // next-1 != rejected is always false
+ ProgressStateProbe, 0, 0, 0, 0, false, 0,
+ },
+ {
+ // next-1 != rejected is always false
+ ProgressStateProbe, 0, 10, 5, 5, false, 10,
+ },
+ {
+ // next>1 = decremented by 1
+ ProgressStateProbe, 0, 10, 9, 9, true, 9,
+ },
+ {
+ // next>1 = decremented by 1
+ ProgressStateProbe, 0, 2, 1, 1, true, 1,
+ },
+ {
+ // next<=1 = reset to 1
+ ProgressStateProbe, 0, 1, 0, 0, true, 1,
+ },
+ {
+ // decrease to min(rejected, last+1)
+ ProgressStateProbe, 0, 10, 9, 2, true, 3,
+ },
+ {
+ // rejected < 1, reset to 1
+ ProgressStateProbe, 0, 10, 9, 0, true, 1,
+ },
+ }
+ for i, tt := range tests {
+ p := &Progress{
+ State: tt.state,
+ Match: tt.m,
+ Next: tt.n,
+ }
+ if g := p.maybeDecrTo(tt.rejected, tt.last); g != tt.w {
+ t.Errorf("#%d: maybeDecrTo= %t, want %t", i, g, tt.w)
+ }
+ if gm := p.Match; gm != tt.m {
+ t.Errorf("#%d: match= %d, want %d", i, gm, tt.m)
+ }
+ if gn := p.Next; gn != tt.wn {
+ t.Errorf("#%d: next= %d, want %d", i, gn, tt.wn)
+ }
+ }
+}
+
+func TestProgressIsPaused(t *testing.T) {
+ tests := []struct {
+ state ProgressStateType
+ paused bool
+
+ w bool
+ }{
+ {ProgressStateProbe, false, false},
+ {ProgressStateProbe, true, true},
+ {ProgressStateReplicate, false, false},
+ {ProgressStateReplicate, true, false},
+ {ProgressStateSnapshot, false, true},
+ {ProgressStateSnapshot, true, true},
+ }
+ for i, tt := range tests {
+ p := &Progress{
+ State: tt.state,
+ Paused: tt.paused,
+ ins: newInflights(256),
+ }
+ if g := p.IsPaused(); g != tt.w {
+ t.Errorf("#%d: paused= %t, want %t", i, g, tt.w)
+ }
+ }
+}
+
+// TestProgressResume ensures that progress.maybeUpdate and progress.maybeDecrTo
+// will reset progress.paused.
+func TestProgressResume(t *testing.T) {
+ p := &Progress{
+ Next: 2,
+ Paused: true,
+ }
+ p.maybeDecrTo(1, 1)
+ if p.Paused {
+ t.Errorf("paused= %v, want false", p.Paused)
+ }
+ p.Paused = true
+ p.maybeUpdate(2)
+ if p.Paused {
+ t.Errorf("paused= %v, want false", p.Paused)
+ }
+}
+
+// TestProgressResumeByHeartbeatResp ensures raft.heartbeat reset progress.paused by heartbeat response.
+func TestProgressResumeByHeartbeatResp(t *testing.T) {
+ r := newTestRaft(1, []uint64{1, 2}, 5, 1, NewMemoryStorage())
+ r.becomeCandidate()
+ r.becomeLeader()
+ r.prs[2].Paused = true
+
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgBeat})
+ if !r.prs[2].Paused {
+ t.Errorf("paused = %v, want true", r.prs[2].Paused)
+ }
+
+ r.prs[2].becomeReplicate()
+ r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgHeartbeatResp})
+ if r.prs[2].Paused {
+ t.Errorf("paused = %v, want false", r.prs[2].Paused)
+ }
+}
+
+func TestProgressPaused(t *testing.T) {
+ r := newTestRaft(1, []uint64{1, 2}, 5, 1, NewMemoryStorage())
+ r.becomeCandidate()
+ r.becomeLeader()
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+
+ ms := r.readMessages()
+ if len(ms) != 1 {
+ t.Errorf("len(ms) = %d, want 1", len(ms))
+ }
+}
+
+func TestLeaderElection(t *testing.T) {
+ testLeaderElection(t, false)
+}
+
+func TestLeaderElectionPreVote(t *testing.T) {
+ testLeaderElection(t, true)
+}
+
+func testLeaderElection(t *testing.T, preVote bool) {
+ var cfg func(*Config)
+ if preVote {
+ cfg = preVoteConfig
+ }
+ tests := []struct {
+ *network
+ state StateType
+ expTerm uint64
+ }{
+ {newNetworkWithConfig(cfg, nil, nil, nil), StateLeader, 1},
+ {newNetworkWithConfig(cfg, nil, nil, nopStepper), StateLeader, 1},
+ {newNetworkWithConfig(cfg, nil, nopStepper, nopStepper), StateCandidate, 1},
+ {newNetworkWithConfig(cfg, nil, nopStepper, nopStepper, nil), StateCandidate, 1},
+ {newNetworkWithConfig(cfg, nil, nopStepper, nopStepper, nil, nil), StateLeader, 1},
+
+ // three logs further along than 0, but in the same term so rejections
+ // are returned instead of the votes being ignored.
+ {newNetworkWithConfig(cfg,
+ nil, entsWithConfig(cfg, 1), entsWithConfig(cfg, 1), entsWithConfig(cfg, 1, 1), nil),
+ StateFollower, 1},
+ }
+
+ for i, tt := range tests {
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ sm := tt.network.peers[1].(*raft)
+ var expState StateType
+ var expTerm uint64
+ if tt.state == StateCandidate && preVote {
+ // In pre-vote mode, an election that fails to complete
+ // leaves the node in pre-candidate state without advancing
+ // the term.
+ expState = StatePreCandidate
+ expTerm = 0
+ } else {
+ expState = tt.state
+ expTerm = tt.expTerm
+ }
+ if sm.state != expState {
+ t.Errorf("#%d: state = %s, want %s", i, sm.state, expState)
+ }
+ if g := sm.Term; g != expTerm {
+ t.Errorf("#%d: term = %d, want %d", i, g, expTerm)
+ }
+ }
+}
+
+func TestLeaderCycle(t *testing.T) {
+ testLeaderCycle(t, false)
+}
+
+func TestLeaderCyclePreVote(t *testing.T) {
+ testLeaderCycle(t, true)
+}
+
+// testLeaderCycle verifies that each node in a cluster can campaign
+// and be elected in turn. This ensures that elections (including
+// pre-vote) work when not starting from a clean slate (as they do in
+// TestLeaderElection)
+func testLeaderCycle(t *testing.T, preVote bool) {
+ var cfg func(*Config)
+ if preVote {
+ cfg = preVoteConfig
+ }
+ n := newNetworkWithConfig(cfg, nil, nil, nil)
+ for campaignerID := uint64(1); campaignerID <= 3; campaignerID++ {
+ n.send(pb.Message{From: campaignerID, To: campaignerID, Type: pb.MsgHup})
+
+ for _, peer := range n.peers {
+ sm := peer.(*raft)
+ if sm.id == campaignerID && sm.state != StateLeader {
+ t.Errorf("preVote=%v: campaigning node %d state = %v, want StateLeader",
+ preVote, sm.id, sm.state)
+ } else if sm.id != campaignerID && sm.state != StateFollower {
+ t.Errorf("preVote=%v: after campaign of node %d, "+
+ "node %d had state = %v, want StateFollower",
+ preVote, campaignerID, sm.id, sm.state)
+ }
+ }
+ }
+}
+
+// TestLeaderElectionOverwriteNewerLogs tests a scenario in which a
+// newly-elected leader does *not* have the newest (i.e. highest term)
+// log entries, and must overwrite higher-term log entries with
+// lower-term ones.
+func TestLeaderElectionOverwriteNewerLogs(t *testing.T) {
+ testLeaderElectionOverwriteNewerLogs(t, false)
+}
+
+func TestLeaderElectionOverwriteNewerLogsPreVote(t *testing.T) {
+ testLeaderElectionOverwriteNewerLogs(t, true)
+}
+
+func testLeaderElectionOverwriteNewerLogs(t *testing.T, preVote bool) {
+ var cfg func(*Config)
+ if preVote {
+ cfg = preVoteConfig
+ }
+ // This network represents the results of the following sequence of
+ // events:
+ // - Node 1 won the election in term 1.
+ // - Node 1 replicated a log entry to node 2 but died before sending
+ // it to other nodes.
+ // - Node 3 won the second election in term 2.
+ // - Node 3 wrote an entry to its logs but died without sending it
+ // to any other nodes.
+ //
+ // At this point, nodes 1, 2, and 3 all have uncommitted entries in
+ // their logs and could win an election at term 3. The winner's log
+ // entry overwrites the losers'. (TestLeaderSyncFollowerLog tests
+ // the case where older log entries are overwritten, so this test
+ // focuses on the case where the newer entries are lost).
+ n := newNetworkWithConfig(cfg,
+ entsWithConfig(cfg, 1), // Node 1: Won first election
+ entsWithConfig(cfg, 1), // Node 2: Got logs from node 1
+ entsWithConfig(cfg, 2), // Node 3: Won second election
+ votedWithConfig(cfg, 3, 2), // Node 4: Voted but didn't get logs
+ votedWithConfig(cfg, 3, 2)) // Node 5: Voted but didn't get logs
+
+ // Node 1 campaigns. The election fails because a quorum of nodes
+ // know about the election that already happened at term 2. Node 1's
+ // term is pushed ahead to 2.
+ n.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ sm1 := n.peers[1].(*raft)
+ if sm1.state != StateFollower {
+ t.Errorf("state = %s, want StateFollower", sm1.state)
+ }
+ if sm1.Term != 2 {
+ t.Errorf("term = %d, want 2", sm1.Term)
+ }
+
+ // Node 1 campaigns again with a higher term. This time it succeeds.
+ n.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ if sm1.state != StateLeader {
+ t.Errorf("state = %s, want StateLeader", sm1.state)
+ }
+ if sm1.Term != 3 {
+ t.Errorf("term = %d, want 3", sm1.Term)
+ }
+
+ // Now all nodes agree on a log entry with term 1 at index 1 (and
+ // term 3 at index 2).
+ for i := range n.peers {
+ sm := n.peers[i].(*raft)
+ entries := sm.raftLog.allEntries()
+ if len(entries) != 2 {
+ t.Fatalf("node %d: len(entries) == %d, want 2", i, len(entries))
+ }
+ if entries[0].Term != 1 {
+ t.Errorf("node %d: term at index 1 == %d, want 1", i, entries[0].Term)
+ }
+ if entries[1].Term != 3 {
+ t.Errorf("node %d: term at index 2 == %d, want 3", i, entries[1].Term)
+ }
+ }
+}
+
+func TestVoteFromAnyState(t *testing.T) {
+ testVoteFromAnyState(t, pb.MsgVote)
+}
+
+func TestPreVoteFromAnyState(t *testing.T) {
+ testVoteFromAnyState(t, pb.MsgPreVote)
+}
+
+func testVoteFromAnyState(t *testing.T, vt pb.MessageType) {
+ for st := StateType(0); st < numStates; st++ {
+ r := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ r.Term = 1
+
+ switch st {
+ case StateFollower:
+ r.becomeFollower(r.Term, 3)
+ case StatePreCandidate:
+ r.becomePreCandidate()
+ case StateCandidate:
+ r.becomeCandidate()
+ case StateLeader:
+ r.becomeCandidate()
+ r.becomeLeader()
+ }
+
+ // Note that setting our state above may have advanced r.Term
+ // past its initial value.
+ origTerm := r.Term
+ newTerm := r.Term + 1
+
+ msg := pb.Message{
+ From: 2,
+ To: 1,
+ Type: vt,
+ Term: newTerm,
+ LogTerm: newTerm,
+ Index: 42,
+ }
+ if err := r.Step(msg); err != nil {
+ t.Errorf("%s,%s: Step failed: %s", vt, st, err)
+ }
+ if len(r.msgs) != 1 {
+ t.Errorf("%s,%s: %d response messages, want 1: %+v", vt, st, len(r.msgs), r.msgs)
+ } else {
+ resp := r.msgs[0]
+ if resp.Type != voteRespMsgType(vt) {
+ t.Errorf("%s,%s: response message is %s, want %s",
+ vt, st, resp.Type, voteRespMsgType(vt))
+ }
+ if resp.Reject {
+ t.Errorf("%s,%s: unexpected rejection", vt, st)
+ }
+ }
+
+ // If this was a real vote, we reset our state and term.
+ if vt == pb.MsgVote {
+ if r.state != StateFollower {
+ t.Errorf("%s,%s: state %s, want %s", vt, st, r.state, StateFollower)
+ }
+ if r.Term != newTerm {
+ t.Errorf("%s,%s: term %d, want %d", vt, st, r.Term, newTerm)
+ }
+ if r.Vote != 2 {
+ t.Errorf("%s,%s: vote %d, want 2", vt, st, r.Vote)
+ }
+ } else {
+ // In a prevote, nothing changes.
+ if r.state != st {
+ t.Errorf("%s,%s: state %s, want %s", vt, st, r.state, st)
+ }
+ if r.Term != origTerm {
+ t.Errorf("%s,%s: term %d, want %d", vt, st, r.Term, origTerm)
+ }
+ // if st == StateFollower or StatePreCandidate, r hasn't voted yet.
+ // In StateCandidate or StateLeader, it's voted for itself.
+ if r.Vote != None && r.Vote != 1 {
+ t.Errorf("%s,%s: vote %d, want %d or 1", vt, st, r.Vote, None)
+ }
+ }
+ }
+}
+
+func TestLogReplication(t *testing.T) {
+ tests := []struct {
+ *network
+ msgs []pb.Message
+ wcommitted uint64
+ }{
+ {
+ newNetwork(nil, nil, nil),
+ []pb.Message{
+ {From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}},
+ },
+ 2,
+ },
+ {
+ newNetwork(nil, nil, nil),
+ []pb.Message{
+ {From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}},
+ {From: 1, To: 2, Type: pb.MsgHup},
+ {From: 1, To: 2, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}},
+ },
+ 4,
+ },
+ }
+
+ for i, tt := range tests {
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ for _, m := range tt.msgs {
+ tt.send(m)
+ }
+
+ for j, x := range tt.network.peers {
+ sm := x.(*raft)
+
+ if sm.raftLog.committed != tt.wcommitted {
+ t.Errorf("#%d.%d: committed = %d, want %d", i, j, sm.raftLog.committed, tt.wcommitted)
+ }
+
+ ents := []pb.Entry{}
+ for _, e := range nextEnts(sm, tt.network.storage[j]) {
+ if e.Data != nil {
+ ents = append(ents, e)
+ }
+ }
+ props := []pb.Message{}
+ for _, m := range tt.msgs {
+ if m.Type == pb.MsgProp {
+ props = append(props, m)
+ }
+ }
+ for k, m := range props {
+ if !bytes.Equal(ents[k].Data, m.Entries[0].Data) {
+ t.Errorf("#%d.%d: data = %d, want %d", i, j, ents[k].Data, m.Entries[0].Data)
+ }
+ }
+ }
+ }
+}
+
+func TestSingleNodeCommit(t *testing.T) {
+ tt := newNetwork(nil)
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("some data")}}})
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("some data")}}})
+
+ sm := tt.peers[1].(*raft)
+ if sm.raftLog.committed != 3 {
+ t.Errorf("committed = %d, want %d", sm.raftLog.committed, 3)
+ }
+}
+
+// TestCannotCommitWithoutNewTermEntry tests the entries cannot be committed
+// when leader changes, no new proposal comes in and ChangeTerm proposal is
+// filtered.
+func TestCannotCommitWithoutNewTermEntry(t *testing.T) {
+ tt := newNetwork(nil, nil, nil, nil, nil)
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ // 0 cannot reach 2,3,4
+ tt.cut(1, 3)
+ tt.cut(1, 4)
+ tt.cut(1, 5)
+
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("some data")}}})
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("some data")}}})
+
+ sm := tt.peers[1].(*raft)
+ if sm.raftLog.committed != 1 {
+ t.Errorf("committed = %d, want %d", sm.raftLog.committed, 1)
+ }
+
+ // network recovery
+ tt.recover()
+ // avoid committing ChangeTerm proposal
+ tt.ignore(pb.MsgApp)
+
+ // elect 2 as the new leader with term 2
+ tt.send(pb.Message{From: 2, To: 2, Type: pb.MsgHup})
+
+ // no log entries from previous term should be committed
+ sm = tt.peers[2].(*raft)
+ if sm.raftLog.committed != 1 {
+ t.Errorf("committed = %d, want %d", sm.raftLog.committed, 1)
+ }
+
+ tt.recover()
+ // send heartbeat; reset wait
+ tt.send(pb.Message{From: 2, To: 2, Type: pb.MsgBeat})
+ // append an entry at current term
+ tt.send(pb.Message{From: 2, To: 2, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("some data")}}})
+ // expect the committed to be advanced
+ if sm.raftLog.committed != 5 {
+ t.Errorf("committed = %d, want %d", sm.raftLog.committed, 5)
+ }
+}
+
+// TestCommitWithoutNewTermEntry tests the entries could be committed
+// when leader changes, no new proposal comes in.
+func TestCommitWithoutNewTermEntry(t *testing.T) {
+ tt := newNetwork(nil, nil, nil, nil, nil)
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ // 0 cannot reach 2,3,4
+ tt.cut(1, 3)
+ tt.cut(1, 4)
+ tt.cut(1, 5)
+
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("some data")}}})
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("some data")}}})
+
+ sm := tt.peers[1].(*raft)
+ if sm.raftLog.committed != 1 {
+ t.Errorf("committed = %d, want %d", sm.raftLog.committed, 1)
+ }
+
+ // network recovery
+ tt.recover()
+
+ // elect 1 as the new leader with term 2
+ // after append a ChangeTerm entry from the current term, all entries
+ // should be committed
+ tt.send(pb.Message{From: 2, To: 2, Type: pb.MsgHup})
+
+ if sm.raftLog.committed != 4 {
+ t.Errorf("committed = %d, want %d", sm.raftLog.committed, 4)
+ }
+}
+
+func TestDuelingCandidates(t *testing.T) {
+ a := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ b := newTestRaft(2, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ c := newTestRaft(3, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+
+ nt := newNetwork(a, b, c)
+ nt.cut(1, 3)
+
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})
+
+ // 1 becomes leader since it receives votes from 1 and 2
+ sm := nt.peers[1].(*raft)
+ if sm.state != StateLeader {
+ t.Errorf("state = %s, want %s", sm.state, StateLeader)
+ }
+
+ // 3 stays as candidate since it receives a vote from 3 and a rejection from 2
+ sm = nt.peers[3].(*raft)
+ if sm.state != StateCandidate {
+ t.Errorf("state = %s, want %s", sm.state, StateCandidate)
+ }
+
+ nt.recover()
+
+ // candidate 3 now increases its term and tries to vote again
+ // we expect it to disrupt the leader 1 since it has a higher term
+ // 3 will be follower again since both 1 and 2 rejects its vote request since 3 does not have a long enough log
+ nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})
+
+ wlog := &raftLog{
+ storage: &MemoryStorage{ents: []pb.Entry{{}, {Data: nil, Term: 1, Index: 1}}},
+ committed: 1,
+ unstable: unstable{offset: 2},
+ }
+ tests := []struct {
+ sm *raft
+ state StateType
+ term uint64
+ raftLog *raftLog
+ }{
+ {a, StateFollower, 2, wlog},
+ {b, StateFollower, 2, wlog},
+ {c, StateFollower, 2, newLog(NewMemoryStorage(), raftLogger)},
+ }
+
+ for i, tt := range tests {
+ if g := tt.sm.state; g != tt.state {
+ t.Errorf("#%d: state = %s, want %s", i, g, tt.state)
+ }
+ if g := tt.sm.Term; g != tt.term {
+ t.Errorf("#%d: term = %d, want %d", i, g, tt.term)
+ }
+ base := ltoa(tt.raftLog)
+ if sm, ok := nt.peers[1+uint64(i)].(*raft); ok {
+ l := ltoa(sm.raftLog)
+ if g := diffu(base, l); g != "" {
+ t.Errorf("#%d: diff:\n%s", i, g)
+ }
+ } else {
+ t.Logf("#%d: empty log", i)
+ }
+ }
+}
+
+func TestDuelingPreCandidates(t *testing.T) {
+ cfgA := newTestConfig(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ cfgB := newTestConfig(2, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ cfgC := newTestConfig(3, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ cfgA.PreVote = true
+ cfgB.PreVote = true
+ cfgC.PreVote = true
+ a := newRaft(cfgA)
+ b := newRaft(cfgB)
+ c := newRaft(cfgC)
+
+ nt := newNetwork(a, b, c)
+ nt.cut(1, 3)
+
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})
+
+ // 1 becomes leader since it receives votes from 1 and 2
+ sm := nt.peers[1].(*raft)
+ if sm.state != StateLeader {
+ t.Errorf("state = %s, want %s", sm.state, StateLeader)
+ }
+
+ // 3 campaigns then reverts to follower when its PreVote is rejected
+ sm = nt.peers[3].(*raft)
+ if sm.state != StateFollower {
+ t.Errorf("state = %s, want %s", sm.state, StateFollower)
+ }
+
+ nt.recover()
+
+ // Candidate 3 now increases its term and tries to vote again.
+ // With PreVote, it does not disrupt the leader.
+ nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})
+
+ wlog := &raftLog{
+ storage: &MemoryStorage{ents: []pb.Entry{{}, {Data: nil, Term: 1, Index: 1}}},
+ committed: 1,
+ unstable: unstable{offset: 2},
+ }
+ tests := []struct {
+ sm *raft
+ state StateType
+ term uint64
+ raftLog *raftLog
+ }{
+ {a, StateLeader, 1, wlog},
+ {b, StateFollower, 1, wlog},
+ {c, StateFollower, 1, newLog(NewMemoryStorage(), raftLogger)},
+ }
+
+ for i, tt := range tests {
+ if g := tt.sm.state; g != tt.state {
+ t.Errorf("#%d: state = %s, want %s", i, g, tt.state)
+ }
+ if g := tt.sm.Term; g != tt.term {
+ t.Errorf("#%d: term = %d, want %d", i, g, tt.term)
+ }
+ base := ltoa(tt.raftLog)
+ if sm, ok := nt.peers[1+uint64(i)].(*raft); ok {
+ l := ltoa(sm.raftLog)
+ if g := diffu(base, l); g != "" {
+ t.Errorf("#%d: diff:\n%s", i, g)
+ }
+ } else {
+ t.Logf("#%d: empty log", i)
+ }
+ }
+}
+
+func TestCandidateConcede(t *testing.T) {
+ tt := newNetwork(nil, nil, nil)
+ tt.isolate(1)
+
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ tt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})
+
+ // heal the partition
+ tt.recover()
+ // send heartbeat; reset wait
+ tt.send(pb.Message{From: 3, To: 3, Type: pb.MsgBeat})
+
+ data := []byte("force follower")
+ // send a proposal to 3 to flush out a MsgApp to 1
+ tt.send(pb.Message{From: 3, To: 3, Type: pb.MsgProp, Entries: []pb.Entry{{Data: data}}})
+ // send heartbeat; flush out commit
+ tt.send(pb.Message{From: 3, To: 3, Type: pb.MsgBeat})
+
+ a := tt.peers[1].(*raft)
+ if g := a.state; g != StateFollower {
+ t.Errorf("state = %s, want %s", g, StateFollower)
+ }
+ if g := a.Term; g != 1 {
+ t.Errorf("term = %d, want %d", g, 1)
+ }
+ wantLog := ltoa(&raftLog{
+ storage: &MemoryStorage{
+ ents: []pb.Entry{{}, {Data: nil, Term: 1, Index: 1}, {Term: 1, Index: 2, Data: data}},
+ },
+ unstable: unstable{offset: 3},
+ committed: 2,
+ })
+ for i, p := range tt.peers {
+ if sm, ok := p.(*raft); ok {
+ l := ltoa(sm.raftLog)
+ if g := diffu(wantLog, l); g != "" {
+ t.Errorf("#%d: diff:\n%s", i, g)
+ }
+ } else {
+ t.Logf("#%d: empty log", i)
+ }
+ }
+}
+
+func TestSingleNodeCandidate(t *testing.T) {
+ tt := newNetwork(nil)
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ sm := tt.peers[1].(*raft)
+ if sm.state != StateLeader {
+ t.Errorf("state = %d, want %d", sm.state, StateLeader)
+ }
+}
+
+func TestSingleNodePreCandidate(t *testing.T) {
+ tt := newNetworkWithConfig(preVoteConfig, nil)
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ sm := tt.peers[1].(*raft)
+ if sm.state != StateLeader {
+ t.Errorf("state = %d, want %d", sm.state, StateLeader)
+ }
+}
+
+func TestOldMessages(t *testing.T) {
+ tt := newNetwork(nil, nil, nil)
+ // make 0 leader @ term 3
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ tt.send(pb.Message{From: 2, To: 2, Type: pb.MsgHup})
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ // pretend we're an old leader trying to make progress; this entry is expected to be ignored.
+ tt.send(pb.Message{From: 2, To: 1, Type: pb.MsgApp, Term: 2, Entries: []pb.Entry{{Index: 3, Term: 2}}})
+ // commit a new entry
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+
+ ilog := &raftLog{
+ storage: &MemoryStorage{
+ ents: []pb.Entry{
+ {}, {Data: nil, Term: 1, Index: 1},
+ {Data: nil, Term: 2, Index: 2}, {Data: nil, Term: 3, Index: 3},
+ {Data: []byte("somedata"), Term: 3, Index: 4},
+ },
+ },
+ unstable: unstable{offset: 5},
+ committed: 4,
+ }
+ base := ltoa(ilog)
+ for i, p := range tt.peers {
+ if sm, ok := p.(*raft); ok {
+ l := ltoa(sm.raftLog)
+ if g := diffu(base, l); g != "" {
+ t.Errorf("#%d: diff:\n%s", i, g)
+ }
+ } else {
+ t.Logf("#%d: empty log", i)
+ }
+ }
+}
+
+// TestOldMessagesReply - optimization - reply with new term.
+
+func TestProposal(t *testing.T) {
+ tests := []struct {
+ *network
+ success bool
+ }{
+ {newNetwork(nil, nil, nil), true},
+ {newNetwork(nil, nil, nopStepper), true},
+ {newNetwork(nil, nopStepper, nopStepper), false},
+ {newNetwork(nil, nopStepper, nopStepper, nil), false},
+ {newNetwork(nil, nopStepper, nopStepper, nil, nil), true},
+ }
+
+ for j, tt := range tests {
+ send := func(m pb.Message) {
+ defer func() {
+ // only recover is we expect it to panic so
+ // panics we don't expect go up.
+ if !tt.success {
+ e := recover()
+ if e != nil {
+ t.Logf("#%d: err: %s", j, e)
+ }
+ }
+ }()
+ tt.send(m)
+ }
+
+ data := []byte("somedata")
+
+ // promote 0 the leader
+ send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: data}}})
+
+ wantLog := newLog(NewMemoryStorage(), raftLogger)
+ if tt.success {
+ wantLog = &raftLog{
+ storage: &MemoryStorage{
+ ents: []pb.Entry{{}, {Data: nil, Term: 1, Index: 1}, {Term: 1, Index: 2, Data: data}},
+ },
+ unstable: unstable{offset: 3},
+ committed: 2}
+ }
+ base := ltoa(wantLog)
+ for i, p := range tt.peers {
+ if sm, ok := p.(*raft); ok {
+ l := ltoa(sm.raftLog)
+ if g := diffu(base, l); g != "" {
+ t.Errorf("#%d: diff:\n%s", i, g)
+ }
+ } else {
+ t.Logf("#%d: empty log", i)
+ }
+ }
+ sm := tt.network.peers[1].(*raft)
+ if g := sm.Term; g != 1 {
+ t.Errorf("#%d: term = %d, want %d", j, g, 1)
+ }
+ }
+}
+
+func TestProposalByProxy(t *testing.T) {
+ data := []byte("somedata")
+ tests := []*network{
+ newNetwork(nil, nil, nil),
+ newNetwork(nil, nil, nopStepper),
+ }
+
+ for j, tt := range tests {
+ // promote 0 the leader
+ tt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ // propose via follower
+ tt.send(pb.Message{From: 2, To: 2, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+
+ wantLog := &raftLog{
+ storage: &MemoryStorage{
+ ents: []pb.Entry{{}, {Data: nil, Term: 1, Index: 1}, {Term: 1, Data: data, Index: 2}},
+ },
+ unstable: unstable{offset: 3},
+ committed: 2}
+ base := ltoa(wantLog)
+ for i, p := range tt.peers {
+ if sm, ok := p.(*raft); ok {
+ l := ltoa(sm.raftLog)
+ if g := diffu(base, l); g != "" {
+ t.Errorf("#%d: diff:\n%s", i, g)
+ }
+ } else {
+ t.Logf("#%d: empty log", i)
+ }
+ }
+ sm := tt.peers[1].(*raft)
+ if g := sm.Term; g != 1 {
+ t.Errorf("#%d: term = %d, want %d", j, g, 1)
+ }
+ }
+}
+
+func TestCommit(t *testing.T) {
+ tests := []struct {
+ matches []uint64
+ logs []pb.Entry
+ smTerm uint64
+ w uint64
+ }{
+ // single
+ {[]uint64{1}, []pb.Entry{{Index: 1, Term: 1}}, 1, 1},
+ {[]uint64{1}, []pb.Entry{{Index: 1, Term: 1}}, 2, 0},
+ {[]uint64{2}, []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}}, 2, 2},
+ {[]uint64{1}, []pb.Entry{{Index: 1, Term: 2}}, 2, 1},
+
+ // odd
+ {[]uint64{2, 1, 1}, []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}}, 1, 1},
+ {[]uint64{2, 1, 1}, []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 1}}, 2, 0},
+ {[]uint64{2, 1, 2}, []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}}, 2, 2},
+ {[]uint64{2, 1, 2}, []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 1}}, 2, 0},
+
+ // even
+ {[]uint64{2, 1, 1, 1}, []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}}, 1, 1},
+ {[]uint64{2, 1, 1, 1}, []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 1}}, 2, 0},
+ {[]uint64{2, 1, 1, 2}, []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}}, 1, 1},
+ {[]uint64{2, 1, 1, 2}, []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 1}}, 2, 0},
+ {[]uint64{2, 1, 2, 2}, []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}}, 2, 2},
+ {[]uint64{2, 1, 2, 2}, []pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 1}}, 2, 0},
+ }
+
+ for i, tt := range tests {
+ storage := NewMemoryStorage()
+ storage.Append(tt.logs)
+ storage.hardState = pb.HardState{Term: tt.smTerm}
+
+ sm := newTestRaft(1, []uint64{1}, 5, 1, storage)
+ for j := 0; j < len(tt.matches); j++ {
+ sm.setProgress(uint64(j)+1, tt.matches[j], tt.matches[j]+1)
+ }
+ sm.maybeCommit()
+ if g := sm.raftLog.committed; g != tt.w {
+ t.Errorf("#%d: committed = %d, want %d", i, g, tt.w)
+ }
+ }
+}
+
+func TestPastElectionTimeout(t *testing.T) {
+ tests := []struct {
+ elapse int
+ wprobability float64
+ round bool
+ }{
+ {5, 0, false},
+ {10, 0.1, true},
+ {13, 0.4, true},
+ {15, 0.6, true},
+ {18, 0.9, true},
+ {20, 1, false},
+ }
+
+ for i, tt := range tests {
+ sm := newTestRaft(1, []uint64{1}, 10, 1, NewMemoryStorage())
+ sm.electionElapsed = tt.elapse
+ c := 0
+ for j := 0; j < 10000; j++ {
+ sm.resetRandomizedElectionTimeout()
+ if sm.pastElectionTimeout() {
+ c++
+ }
+ }
+ got := float64(c) / 10000.0
+ if tt.round {
+ got = math.Floor(got*10+0.5) / 10.0
+ }
+ if got != tt.wprobability {
+ t.Errorf("#%d: probability = %v, want %v", i, got, tt.wprobability)
+ }
+ }
+}
+
+// ensure that the Step function ignores the message from old term and does not pass it to the
+// actual stepX function.
+func TestStepIgnoreOldTermMsg(t *testing.T) {
+ called := false
+ fakeStep := func(r *raft, m pb.Message) {
+ called = true
+ }
+ sm := newTestRaft(1, []uint64{1}, 10, 1, NewMemoryStorage())
+ sm.step = fakeStep
+ sm.Term = 2
+ sm.Step(pb.Message{Type: pb.MsgApp, Term: sm.Term - 1})
+ if called {
+ t.Errorf("stepFunc called = %v , want %v", called, false)
+ }
+}
+
+// TestHandleMsgApp ensures:
+// 1. Reply false if log doesn?t contain an entry at prevLogIndex whose term matches prevLogTerm.
+// 2. If an existing entry conflicts with a new one (same index but different terms),
+// delete the existing entry and all that follow it; append any new entries not already in the log.
+// 3. If leaderCommit > commitIndex, set commitIndex = min(leaderCommit, index of last new entry).
+func TestHandleMsgApp(t *testing.T) {
+ tests := []struct {
+ m pb.Message
+ wIndex uint64
+ wCommit uint64
+ wReject bool
+ }{
+ // Ensure 1
+ {pb.Message{Type: pb.MsgApp, Term: 2, LogTerm: 3, Index: 2, Commit: 3}, 2, 0, true}, // previous log mismatch
+ {pb.Message{Type: pb.MsgApp, Term: 2, LogTerm: 3, Index: 3, Commit: 3}, 2, 0, true}, // previous log non-exist
+
+ // Ensure 2
+ {pb.Message{Type: pb.MsgApp, Term: 2, LogTerm: 1, Index: 1, Commit: 1}, 2, 1, false},
+ {pb.Message{Type: pb.MsgApp, Term: 2, LogTerm: 0, Index: 0, Commit: 1, Entries: []pb.Entry{{Index: 1, Term: 2}}}, 1, 1, false},
+ {pb.Message{Type: pb.MsgApp, Term: 2, LogTerm: 2, Index: 2, Commit: 3, Entries: []pb.Entry{{Index: 3, Term: 2}, {Index: 4, Term: 2}}}, 4, 3, false},
+ {pb.Message{Type: pb.MsgApp, Term: 2, LogTerm: 2, Index: 2, Commit: 4, Entries: []pb.Entry{{Index: 3, Term: 2}}}, 3, 3, false},
+ {pb.Message{Type: pb.MsgApp, Term: 2, LogTerm: 1, Index: 1, Commit: 4, Entries: []pb.Entry{{Index: 2, Term: 2}}}, 2, 2, false},
+
+ // Ensure 3
+ {pb.Message{Type: pb.MsgApp, Term: 1, LogTerm: 1, Index: 1, Commit: 3}, 2, 1, false}, // match entry 1, commit up to last new entry 1
+ {pb.Message{Type: pb.MsgApp, Term: 1, LogTerm: 1, Index: 1, Commit: 3, Entries: []pb.Entry{{Index: 2, Term: 2}}}, 2, 2, false}, // match entry 1, commit up to last new entry 2
+ {pb.Message{Type: pb.MsgApp, Term: 2, LogTerm: 2, Index: 2, Commit: 3}, 2, 2, false}, // match entry 2, commit up to last new entry 2
+ {pb.Message{Type: pb.MsgApp, Term: 2, LogTerm: 2, Index: 2, Commit: 4}, 2, 2, false}, // commit up to log.last()
+ }
+
+ for i, tt := range tests {
+ storage := NewMemoryStorage()
+ storage.Append([]pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}})
+ sm := newTestRaft(1, []uint64{1}, 10, 1, storage)
+ sm.becomeFollower(2, None)
+
+ sm.handleAppendEntries(tt.m)
+ if sm.raftLog.lastIndex() != tt.wIndex {
+ t.Errorf("#%d: lastIndex = %d, want %d", i, sm.raftLog.lastIndex(), tt.wIndex)
+ }
+ if sm.raftLog.committed != tt.wCommit {
+ t.Errorf("#%d: committed = %d, want %d", i, sm.raftLog.committed, tt.wCommit)
+ }
+ m := sm.readMessages()
+ if len(m) != 1 {
+ t.Fatalf("#%d: msg = nil, want 1", i)
+ }
+ if m[0].Reject != tt.wReject {
+ t.Errorf("#%d: reject = %v, want %v", i, m[0].Reject, tt.wReject)
+ }
+ }
+}
+
+// TestHandleHeartbeat ensures that the follower commits to the commit in the message.
+func TestHandleHeartbeat(t *testing.T) {
+ commit := uint64(2)
+ tests := []struct {
+ m pb.Message
+ wCommit uint64
+ }{
+ {pb.Message{From: 2, To: 1, Type: pb.MsgHeartbeat, Term: 2, Commit: commit + 1}, commit + 1},
+ {pb.Message{From: 2, To: 1, Type: pb.MsgHeartbeat, Term: 2, Commit: commit - 1}, commit}, // do not decrease commit
+ }
+
+ for i, tt := range tests {
+ storage := NewMemoryStorage()
+ storage.Append([]pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}, {Index: 3, Term: 3}})
+ sm := newTestRaft(1, []uint64{1, 2}, 5, 1, storage)
+ sm.becomeFollower(2, 2)
+ sm.raftLog.commitTo(commit)
+ sm.handleHeartbeat(tt.m)
+ if sm.raftLog.committed != tt.wCommit {
+ t.Errorf("#%d: committed = %d, want %d", i, sm.raftLog.committed, tt.wCommit)
+ }
+ m := sm.readMessages()
+ if len(m) != 1 {
+ t.Fatalf("#%d: msg = nil, want 1", i)
+ }
+ if m[0].Type != pb.MsgHeartbeatResp {
+ t.Errorf("#%d: type = %v, want MsgHeartbeatResp", i, m[0].Type)
+ }
+ }
+}
+
+// TestHandleHeartbeatResp ensures that we re-send log entries when we get a heartbeat response.
+func TestHandleHeartbeatResp(t *testing.T) {
+ storage := NewMemoryStorage()
+ storage.Append([]pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 2}, {Index: 3, Term: 3}})
+ sm := newTestRaft(1, []uint64{1, 2}, 5, 1, storage)
+ sm.becomeCandidate()
+ sm.becomeLeader()
+ sm.raftLog.commitTo(sm.raftLog.lastIndex())
+
+ // A heartbeat response from a node that is behind; re-send MsgApp
+ sm.Step(pb.Message{From: 2, Type: pb.MsgHeartbeatResp})
+ msgs := sm.readMessages()
+ if len(msgs) != 1 {
+ t.Fatalf("len(msgs) = %d, want 1", len(msgs))
+ }
+ if msgs[0].Type != pb.MsgApp {
+ t.Errorf("type = %v, want MsgApp", msgs[0].Type)
+ }
+
+ // A second heartbeat response generates another MsgApp re-send
+ sm.Step(pb.Message{From: 2, Type: pb.MsgHeartbeatResp})
+ msgs = sm.readMessages()
+ if len(msgs) != 1 {
+ t.Fatalf("len(msgs) = %d, want 1", len(msgs))
+ }
+ if msgs[0].Type != pb.MsgApp {
+ t.Errorf("type = %v, want MsgApp", msgs[0].Type)
+ }
+
+ // Once we have an MsgAppResp, heartbeats no longer send MsgApp.
+ sm.Step(pb.Message{
+ From: 2,
+ Type: pb.MsgAppResp,
+ Index: msgs[0].Index + uint64(len(msgs[0].Entries)),
+ })
+ // Consume the message sent in response to MsgAppResp
+ sm.readMessages()
+
+ sm.Step(pb.Message{From: 2, Type: pb.MsgHeartbeatResp})
+ msgs = sm.readMessages()
+ if len(msgs) != 0 {
+ t.Fatalf("len(msgs) = %d, want 0: %+v", len(msgs), msgs)
+ }
+}
+
+// TestRaftFreesReadOnlyMem ensures raft will free read request from
+// readOnly readIndexQueue and pendingReadIndex map.
+// related issue: https://github.com/coreos/etcd/issues/7571
+func TestRaftFreesReadOnlyMem(t *testing.T) {
+ sm := newTestRaft(1, []uint64{1, 2}, 5, 1, NewMemoryStorage())
+ sm.becomeCandidate()
+ sm.becomeLeader()
+ sm.raftLog.commitTo(sm.raftLog.lastIndex())
+
+ ctx := []byte("ctx")
+
+ // leader starts linearizable read request.
+ // more info: raft dissertation 6.4, step 2.
+ sm.Step(pb.Message{From: 2, Type: pb.MsgReadIndex, Entries: []pb.Entry{{Data: ctx}}})
+ msgs := sm.readMessages()
+ if len(msgs) != 1 {
+ t.Fatalf("len(msgs) = %d, want 1", len(msgs))
+ }
+ if msgs[0].Type != pb.MsgHeartbeat {
+ t.Fatalf("type = %v, want MsgHeartbeat", msgs[0].Type)
+ }
+ if !bytes.Equal(msgs[0].Context, ctx) {
+ t.Fatalf("Context = %v, want %v", msgs[0].Context, ctx)
+ }
+ if len(sm.readOnly.readIndexQueue) != 1 {
+ t.Fatalf("len(readIndexQueue) = %v, want 1", len(sm.readOnly.readIndexQueue))
+ }
+ if len(sm.readOnly.pendingReadIndex) != 1 {
+ t.Fatalf("len(pendingReadIndex) = %v, want 1", len(sm.readOnly.pendingReadIndex))
+ }
+ if _, ok := sm.readOnly.pendingReadIndex[string(ctx)]; !ok {
+ t.Fatalf("can't find context %v in pendingReadIndex ", ctx)
+ }
+
+ // heartbeat responses from majority of followers (1 in this case)
+ // acknowledge the authority of the leader.
+ // more info: raft dissertation 6.4, step 3.
+ sm.Step(pb.Message{From: 2, Type: pb.MsgHeartbeatResp, Context: ctx})
+ if len(sm.readOnly.readIndexQueue) != 0 {
+ t.Fatalf("len(readIndexQueue) = %v, want 0", len(sm.readOnly.readIndexQueue))
+ }
+ if len(sm.readOnly.pendingReadIndex) != 0 {
+ t.Fatalf("len(pendingReadIndex) = %v, want 0", len(sm.readOnly.pendingReadIndex))
+ }
+ if _, ok := sm.readOnly.pendingReadIndex[string(ctx)]; ok {
+ t.Fatalf("found context %v in pendingReadIndex, want none", ctx)
+ }
+}
+
+// TestMsgAppRespWaitReset verifies the resume behavior of a leader
+// MsgAppResp.
+func TestMsgAppRespWaitReset(t *testing.T) {
+ sm := newTestRaft(1, []uint64{1, 2, 3}, 5, 1, NewMemoryStorage())
+ sm.becomeCandidate()
+ sm.becomeLeader()
+
+ // The new leader has just emitted a new Term 4 entry; consume those messages
+ // from the outgoing queue.
+ sm.bcastAppend()
+ sm.readMessages()
+
+ // Node 2 acks the first entry, making it committed.
+ sm.Step(pb.Message{
+ From: 2,
+ Type: pb.MsgAppResp,
+ Index: 1,
+ })
+ if sm.raftLog.committed != 1 {
+ t.Fatalf("expected committed to be 1, got %d", sm.raftLog.committed)
+ }
+ // Also consume the MsgApp messages that update Commit on the followers.
+ sm.readMessages()
+
+ // A new command is now proposed on node 1.
+ sm.Step(pb.Message{
+ From: 1,
+ Type: pb.MsgProp,
+ Entries: []pb.Entry{{}},
+ })
+
+ // The command is broadcast to all nodes not in the wait state.
+ // Node 2 left the wait state due to its MsgAppResp, but node 3 is still waiting.
+ msgs := sm.readMessages()
+ if len(msgs) != 1 {
+ t.Fatalf("expected 1 message, got %d: %+v", len(msgs), msgs)
+ }
+ if msgs[0].Type != pb.MsgApp || msgs[0].To != 2 {
+ t.Errorf("expected MsgApp to node 2, got %v to %d", msgs[0].Type, msgs[0].To)
+ }
+ if len(msgs[0].Entries) != 1 || msgs[0].Entries[0].Index != 2 {
+ t.Errorf("expected to send entry 2, but got %v", msgs[0].Entries)
+ }
+
+ // Now Node 3 acks the first entry. This releases the wait and entry 2 is sent.
+ sm.Step(pb.Message{
+ From: 3,
+ Type: pb.MsgAppResp,
+ Index: 1,
+ })
+ msgs = sm.readMessages()
+ if len(msgs) != 1 {
+ t.Fatalf("expected 1 message, got %d: %+v", len(msgs), msgs)
+ }
+ if msgs[0].Type != pb.MsgApp || msgs[0].To != 3 {
+ t.Errorf("expected MsgApp to node 3, got %v to %d", msgs[0].Type, msgs[0].To)
+ }
+ if len(msgs[0].Entries) != 1 || msgs[0].Entries[0].Index != 2 {
+ t.Errorf("expected to send entry 2, but got %v", msgs[0].Entries)
+ }
+}
+
+func TestRecvMsgVote(t *testing.T) {
+ testRecvMsgVote(t, pb.MsgVote)
+}
+
+func testRecvMsgVote(t *testing.T, msgType pb.MessageType) {
+ tests := []struct {
+ state StateType
+ i, term uint64
+ voteFor uint64
+ wreject bool
+ }{
+ {StateFollower, 0, 0, None, true},
+ {StateFollower, 0, 1, None, true},
+ {StateFollower, 0, 2, None, true},
+ {StateFollower, 0, 3, None, false},
+
+ {StateFollower, 1, 0, None, true},
+ {StateFollower, 1, 1, None, true},
+ {StateFollower, 1, 2, None, true},
+ {StateFollower, 1, 3, None, false},
+
+ {StateFollower, 2, 0, None, true},
+ {StateFollower, 2, 1, None, true},
+ {StateFollower, 2, 2, None, false},
+ {StateFollower, 2, 3, None, false},
+
+ {StateFollower, 3, 0, None, true},
+ {StateFollower, 3, 1, None, true},
+ {StateFollower, 3, 2, None, false},
+ {StateFollower, 3, 3, None, false},
+
+ {StateFollower, 3, 2, 2, false},
+ {StateFollower, 3, 2, 1, true},
+
+ {StateLeader, 3, 3, 1, true},
+ {StatePreCandidate, 3, 3, 1, true},
+ {StateCandidate, 3, 3, 1, true},
+ }
+
+ for i, tt := range tests {
+ sm := newTestRaft(1, []uint64{1}, 10, 1, NewMemoryStorage())
+ sm.state = tt.state
+ switch tt.state {
+ case StateFollower:
+ sm.step = stepFollower
+ case StateCandidate, StatePreCandidate:
+ sm.step = stepCandidate
+ case StateLeader:
+ sm.step = stepLeader
+ }
+ sm.Vote = tt.voteFor
+ sm.raftLog = &raftLog{
+ storage: &MemoryStorage{ents: []pb.Entry{{}, {Index: 1, Term: 2}, {Index: 2, Term: 2}}},
+ unstable: unstable{offset: 3},
+ }
+
+ sm.Step(pb.Message{Type: msgType, From: 2, Index: tt.i, LogTerm: tt.term})
+
+ msgs := sm.readMessages()
+ if g := len(msgs); g != 1 {
+ t.Fatalf("#%d: len(msgs) = %d, want 1", i, g)
+ continue
+ }
+ if g := msgs[0].Type; g != voteRespMsgType(msgType) {
+ t.Errorf("#%d, m.Type = %v, want %v", i, g, voteRespMsgType(msgType))
+ }
+ if g := msgs[0].Reject; g != tt.wreject {
+ t.Errorf("#%d, m.Reject = %v, want %v", i, g, tt.wreject)
+ }
+ }
+}
+
+func TestStateTransition(t *testing.T) {
+ tests := []struct {
+ from StateType
+ to StateType
+ wallow bool
+ wterm uint64
+ wlead uint64
+ }{
+ {StateFollower, StateFollower, true, 1, None},
+ {StateFollower, StatePreCandidate, true, 0, None},
+ {StateFollower, StateCandidate, true, 1, None},
+ {StateFollower, StateLeader, false, 0, None},
+
+ {StatePreCandidate, StateFollower, true, 0, None},
+ {StatePreCandidate, StatePreCandidate, true, 0, None},
+ {StatePreCandidate, StateCandidate, true, 1, None},
+ {StatePreCandidate, StateLeader, true, 0, 1},
+
+ {StateCandidate, StateFollower, true, 0, None},
+ {StateCandidate, StatePreCandidate, true, 0, None},
+ {StateCandidate, StateCandidate, true, 1, None},
+ {StateCandidate, StateLeader, true, 0, 1},
+
+ {StateLeader, StateFollower, true, 1, None},
+ {StateLeader, StatePreCandidate, false, 0, None},
+ {StateLeader, StateCandidate, false, 1, None},
+ {StateLeader, StateLeader, true, 0, 1},
+ }
+
+ for i, tt := range tests {
+ func() {
+ defer func() {
+ if r := recover(); r != nil {
+ if tt.wallow {
+ t.Errorf("%d: allow = %v, want %v", i, false, true)
+ }
+ }
+ }()
+
+ sm := newTestRaft(1, []uint64{1}, 10, 1, NewMemoryStorage())
+ sm.state = tt.from
+
+ switch tt.to {
+ case StateFollower:
+ sm.becomeFollower(tt.wterm, tt.wlead)
+ case StatePreCandidate:
+ sm.becomePreCandidate()
+ case StateCandidate:
+ sm.becomeCandidate()
+ case StateLeader:
+ sm.becomeLeader()
+ }
+
+ if sm.Term != tt.wterm {
+ t.Errorf("%d: term = %d, want %d", i, sm.Term, tt.wterm)
+ }
+ if sm.lead != tt.wlead {
+ t.Errorf("%d: lead = %d, want %d", i, sm.lead, tt.wlead)
+ }
+ }()
+ }
+}
+
+func TestAllServerStepdown(t *testing.T) {
+ tests := []struct {
+ state StateType
+
+ wstate StateType
+ wterm uint64
+ windex uint64
+ }{
+ {StateFollower, StateFollower, 3, 0},
+ {StatePreCandidate, StateFollower, 3, 0},
+ {StateCandidate, StateFollower, 3, 0},
+ {StateLeader, StateFollower, 3, 1},
+ }
+
+ tmsgTypes := [...]pb.MessageType{pb.MsgVote, pb.MsgApp}
+ tterm := uint64(3)
+
+ for i, tt := range tests {
+ sm := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ switch tt.state {
+ case StateFollower:
+ sm.becomeFollower(1, None)
+ case StatePreCandidate:
+ sm.becomePreCandidate()
+ case StateCandidate:
+ sm.becomeCandidate()
+ case StateLeader:
+ sm.becomeCandidate()
+ sm.becomeLeader()
+ }
+
+ for j, msgType := range tmsgTypes {
+ sm.Step(pb.Message{From: 2, Type: msgType, Term: tterm, LogTerm: tterm})
+
+ if sm.state != tt.wstate {
+ t.Errorf("#%d.%d state = %v , want %v", i, j, sm.state, tt.wstate)
+ }
+ if sm.Term != tt.wterm {
+ t.Errorf("#%d.%d term = %v , want %v", i, j, sm.Term, tt.wterm)
+ }
+ if uint64(sm.raftLog.lastIndex()) != tt.windex {
+ t.Errorf("#%d.%d index = %v , want %v", i, j, sm.raftLog.lastIndex(), tt.windex)
+ }
+ if uint64(len(sm.raftLog.allEntries())) != tt.windex {
+ t.Errorf("#%d.%d len(ents) = %v , want %v", i, j, len(sm.raftLog.allEntries()), tt.windex)
+ }
+ wlead := uint64(2)
+ if msgType == pb.MsgVote {
+ wlead = None
+ }
+ if sm.lead != wlead {
+ t.Errorf("#%d, sm.lead = %d, want %d", i, sm.lead, None)
+ }
+ }
+ }
+}
+
+func TestLeaderStepdownWhenQuorumActive(t *testing.T) {
+ sm := newTestRaft(1, []uint64{1, 2, 3}, 5, 1, NewMemoryStorage())
+
+ sm.checkQuorum = true
+
+ sm.becomeCandidate()
+ sm.becomeLeader()
+
+ for i := 0; i < sm.electionTimeout+1; i++ {
+ sm.Step(pb.Message{From: 2, Type: pb.MsgHeartbeatResp, Term: sm.Term})
+ sm.tick()
+ }
+
+ if sm.state != StateLeader {
+ t.Errorf("state = %v, want %v", sm.state, StateLeader)
+ }
+}
+
+func TestLeaderStepdownWhenQuorumLost(t *testing.T) {
+ sm := newTestRaft(1, []uint64{1, 2, 3}, 5, 1, NewMemoryStorage())
+
+ sm.checkQuorum = true
+
+ sm.becomeCandidate()
+ sm.becomeLeader()
+
+ for i := 0; i < sm.electionTimeout+1; i++ {
+ sm.tick()
+ }
+
+ if sm.state != StateFollower {
+ t.Errorf("state = %v, want %v", sm.state, StateFollower)
+ }
+}
+
+func TestLeaderSupersedingWithCheckQuorum(t *testing.T) {
+ a := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ b := newTestRaft(2, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ c := newTestRaft(3, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+
+ a.checkQuorum = true
+ b.checkQuorum = true
+ c.checkQuorum = true
+
+ nt := newNetwork(a, b, c)
+ setRandomizedElectionTimeout(b, b.electionTimeout+1)
+
+ for i := 0; i < b.electionTimeout; i++ {
+ b.tick()
+ }
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ if a.state != StateLeader {
+ t.Errorf("state = %s, want %s", a.state, StateLeader)
+ }
+
+ if c.state != StateFollower {
+ t.Errorf("state = %s, want %s", c.state, StateFollower)
+ }
+
+ nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})
+
+ // Peer b rejected c's vote since its electionElapsed had not reached to electionTimeout
+ if c.state != StateCandidate {
+ t.Errorf("state = %s, want %s", c.state, StateCandidate)
+ }
+
+ // Letting b's electionElapsed reach to electionTimeout
+ for i := 0; i < b.electionTimeout; i++ {
+ b.tick()
+ }
+ nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})
+
+ if c.state != StateLeader {
+ t.Errorf("state = %s, want %s", c.state, StateLeader)
+ }
+}
+
+func TestLeaderElectionWithCheckQuorum(t *testing.T) {
+ a := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ b := newTestRaft(2, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ c := newTestRaft(3, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+
+ a.checkQuorum = true
+ b.checkQuorum = true
+ c.checkQuorum = true
+
+ nt := newNetwork(a, b, c)
+ setRandomizedElectionTimeout(a, a.electionTimeout+1)
+ setRandomizedElectionTimeout(b, b.electionTimeout+2)
+
+ // Immediately after creation, votes are cast regardless of the
+ // election timeout.
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ if a.state != StateLeader {
+ t.Errorf("state = %s, want %s", a.state, StateLeader)
+ }
+
+ if c.state != StateFollower {
+ t.Errorf("state = %s, want %s", c.state, StateFollower)
+ }
+
+ // need to reset randomizedElectionTimeout larger than electionTimeout again,
+ // because the value might be reset to electionTimeout since the last state changes
+ setRandomizedElectionTimeout(a, a.electionTimeout+1)
+ setRandomizedElectionTimeout(b, b.electionTimeout+2)
+ for i := 0; i < a.electionTimeout; i++ {
+ a.tick()
+ }
+ for i := 0; i < b.electionTimeout; i++ {
+ b.tick()
+ }
+ nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})
+
+ if a.state != StateFollower {
+ t.Errorf("state = %s, want %s", a.state, StateFollower)
+ }
+
+ if c.state != StateLeader {
+ t.Errorf("state = %s, want %s", c.state, StateLeader)
+ }
+}
+
+// TestFreeStuckCandidateWithCheckQuorum ensures that a candidate with a higher term
+// can disrupt the leader even if the leader still "officially" holds the lease, The
+// leader is expected to step down and adopt the candidate's term
+func TestFreeStuckCandidateWithCheckQuorum(t *testing.T) {
+ a := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ b := newTestRaft(2, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ c := newTestRaft(3, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+
+ a.checkQuorum = true
+ b.checkQuorum = true
+ c.checkQuorum = true
+
+ nt := newNetwork(a, b, c)
+ setRandomizedElectionTimeout(b, b.electionTimeout+1)
+
+ for i := 0; i < b.electionTimeout; i++ {
+ b.tick()
+ }
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ nt.isolate(1)
+ nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})
+
+ if b.state != StateFollower {
+ t.Errorf("state = %s, want %s", b.state, StateFollower)
+ }
+
+ if c.state != StateCandidate {
+ t.Errorf("state = %s, want %s", c.state, StateCandidate)
+ }
+
+ if c.Term != b.Term+1 {
+ t.Errorf("term = %d, want %d", c.Term, b.Term+1)
+ }
+
+ // Vote again for safety
+ nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})
+
+ if b.state != StateFollower {
+ t.Errorf("state = %s, want %s", b.state, StateFollower)
+ }
+
+ if c.state != StateCandidate {
+ t.Errorf("state = %s, want %s", c.state, StateCandidate)
+ }
+
+ if c.Term != b.Term+2 {
+ t.Errorf("term = %d, want %d", c.Term, b.Term+2)
+ }
+
+ nt.recover()
+ nt.send(pb.Message{From: 1, To: 3, Type: pb.MsgHeartbeat, Term: a.Term})
+
+ // Disrupt the leader so that the stuck peer is freed
+ if a.state != StateFollower {
+ t.Errorf("state = %s, want %s", a.state, StateFollower)
+ }
+
+ if c.Term != a.Term {
+ t.Errorf("term = %d, want %d", c.Term, a.Term)
+ }
+}
+
+func TestNonPromotableVoterWithCheckQuorum(t *testing.T) {
+ a := newTestRaft(1, []uint64{1, 2}, 10, 1, NewMemoryStorage())
+ b := newTestRaft(2, []uint64{1}, 10, 1, NewMemoryStorage())
+
+ a.checkQuorum = true
+ b.checkQuorum = true
+
+ nt := newNetwork(a, b)
+ setRandomizedElectionTimeout(b, b.electionTimeout+1)
+ // Need to remove 2 again to make it a non-promotable node since newNetwork overwritten some internal states
+ b.delProgress(2)
+
+ if b.promotable() {
+ t.Fatalf("promotable = %v, want false", b.promotable())
+ }
+
+ for i := 0; i < b.electionTimeout; i++ {
+ b.tick()
+ }
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ if a.state != StateLeader {
+ t.Errorf("state = %s, want %s", a.state, StateLeader)
+ }
+
+ if b.state != StateFollower {
+ t.Errorf("state = %s, want %s", b.state, StateFollower)
+ }
+
+ if b.lead != 1 {
+ t.Errorf("lead = %d, want 1", b.lead)
+ }
+}
+
+func TestReadOnlyOptionSafe(t *testing.T) {
+ a := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ b := newTestRaft(2, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ c := newTestRaft(3, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+
+ nt := newNetwork(a, b, c)
+ setRandomizedElectionTimeout(b, b.electionTimeout+1)
+
+ for i := 0; i < b.electionTimeout; i++ {
+ b.tick()
+ }
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ if a.state != StateLeader {
+ t.Fatalf("state = %s, want %s", a.state, StateLeader)
+ }
+
+ tests := []struct {
+ sm *raft
+ proposals int
+ wri uint64
+ wctx []byte
+ }{
+ {a, 10, 11, []byte("ctx1")},
+ {b, 10, 21, []byte("ctx2")},
+ {c, 10, 31, []byte("ctx3")},
+ {a, 10, 41, []byte("ctx4")},
+ {b, 10, 51, []byte("ctx5")},
+ {c, 10, 61, []byte("ctx6")},
+ }
+
+ for i, tt := range tests {
+ for j := 0; j < tt.proposals; j++ {
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{}}})
+ }
+
+ nt.send(pb.Message{From: tt.sm.id, To: tt.sm.id, Type: pb.MsgReadIndex, Entries: []pb.Entry{{Data: tt.wctx}}})
+
+ r := tt.sm
+ if len(r.readStates) == 0 {
+ t.Errorf("#%d: len(readStates) = 0, want non-zero", i)
+ }
+ rs := r.readStates[0]
+ if rs.Index != tt.wri {
+ t.Errorf("#%d: readIndex = %d, want %d", i, rs.Index, tt.wri)
+ }
+
+ if !bytes.Equal(rs.RequestCtx, tt.wctx) {
+ t.Errorf("#%d: requestCtx = %v, want %v", i, rs.RequestCtx, tt.wctx)
+ }
+ r.readStates = nil
+ }
+}
+
+func TestReadOnlyOptionLease(t *testing.T) {
+ a := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ b := newTestRaft(2, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ c := newTestRaft(3, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ a.readOnly.option = ReadOnlyLeaseBased
+ b.readOnly.option = ReadOnlyLeaseBased
+ c.readOnly.option = ReadOnlyLeaseBased
+ a.checkQuorum = true
+ b.checkQuorum = true
+ c.checkQuorum = true
+
+ nt := newNetwork(a, b, c)
+ setRandomizedElectionTimeout(b, b.electionTimeout+1)
+
+ for i := 0; i < b.electionTimeout; i++ {
+ b.tick()
+ }
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ if a.state != StateLeader {
+ t.Fatalf("state = %s, want %s", a.state, StateLeader)
+ }
+
+ tests := []struct {
+ sm *raft
+ proposals int
+ wri uint64
+ wctx []byte
+ }{
+ {a, 10, 11, []byte("ctx1")},
+ {b, 10, 21, []byte("ctx2")},
+ {c, 10, 31, []byte("ctx3")},
+ {a, 10, 41, []byte("ctx4")},
+ {b, 10, 51, []byte("ctx5")},
+ {c, 10, 61, []byte("ctx6")},
+ }
+
+ for i, tt := range tests {
+ for j := 0; j < tt.proposals; j++ {
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{}}})
+ }
+
+ nt.send(pb.Message{From: tt.sm.id, To: tt.sm.id, Type: pb.MsgReadIndex, Entries: []pb.Entry{{Data: tt.wctx}}})
+
+ r := tt.sm
+ rs := r.readStates[0]
+ if rs.Index != tt.wri {
+ t.Errorf("#%d: readIndex = %d, want %d", i, rs.Index, tt.wri)
+ }
+
+ if !bytes.Equal(rs.RequestCtx, tt.wctx) {
+ t.Errorf("#%d: requestCtx = %v, want %v", i, rs.RequestCtx, tt.wctx)
+ }
+ r.readStates = nil
+ }
+}
+
+func TestReadOnlyOptionLeaseWithoutCheckQuorum(t *testing.T) {
+ a := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ b := newTestRaft(2, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ c := newTestRaft(3, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ a.readOnly.option = ReadOnlyLeaseBased
+ b.readOnly.option = ReadOnlyLeaseBased
+ c.readOnly.option = ReadOnlyLeaseBased
+
+ nt := newNetwork(a, b, c)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ ctx := []byte("ctx1")
+ nt.send(pb.Message{From: 2, To: 2, Type: pb.MsgReadIndex, Entries: []pb.Entry{{Data: ctx}}})
+
+ rs := b.readStates[0]
+ if rs.Index != None {
+ t.Errorf("readIndex = %d, want %d", rs.Index, None)
+ }
+
+ if !bytes.Equal(rs.RequestCtx, ctx) {
+ t.Errorf("requestCtx = %v, want %v", rs.RequestCtx, ctx)
+ }
+}
+
+// TestReadOnlyForNewLeader ensures that a leader only accepts MsgReadIndex message
+// when it commits at least one log entry at it term.
+func TestReadOnlyForNewLeader(t *testing.T) {
+ nodeConfigs := []struct {
+ id uint64
+ committed uint64
+ applied uint64
+ compact_index uint64
+ }{
+ {1, 1, 1, 0},
+ {2, 2, 2, 2},
+ {3, 2, 2, 2},
+ }
+ peers := make([]stateMachine, 0)
+ for _, c := range nodeConfigs {
+ storage := NewMemoryStorage()
+ storage.Append([]pb.Entry{{Index: 1, Term: 1}, {Index: 2, Term: 1}})
+ storage.SetHardState(pb.HardState{Term: 1, Commit: c.committed})
+ if c.compact_index != 0 {
+ storage.Compact(c.compact_index)
+ }
+ cfg := newTestConfig(c.id, []uint64{1, 2, 3}, 10, 1, storage)
+ cfg.Applied = c.applied
+ raft := newRaft(cfg)
+ peers = append(peers, raft)
+ }
+ nt := newNetwork(peers...)
+
+ // Drop MsgApp to forbid peer a to commit any log entry at its term after it becomes leader.
+ nt.ignore(pb.MsgApp)
+ // Force peer a to become leader.
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ sm := nt.peers[1].(*raft)
+ if sm.state != StateLeader {
+ t.Fatalf("state = %s, want %s", sm.state, StateLeader)
+ }
+
+ // Ensure peer a drops read only request.
+ var windex uint64 = 4
+ wctx := []byte("ctx")
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgReadIndex, Entries: []pb.Entry{{Data: wctx}}})
+ if len(sm.readStates) != 0 {
+ t.Fatalf("len(readStates) = %d, want zero", len(sm.readStates))
+ }
+
+ nt.recover()
+
+ // Force peer a to commit a log entry at its term
+ for i := 0; i < sm.heartbeatTimeout; i++ {
+ sm.tick()
+ }
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{}}})
+ if sm.raftLog.committed != 4 {
+ t.Fatalf("committed = %d, want 4", sm.raftLog.committed)
+ }
+ lastLogTerm := sm.raftLog.zeroTermOnErrCompacted(sm.raftLog.term(sm.raftLog.committed))
+ if lastLogTerm != sm.Term {
+ t.Fatalf("last log term = %d, want %d", lastLogTerm, sm.Term)
+ }
+
+ // Ensure peer a accepts read only request after it commits a entry at its term.
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgReadIndex, Entries: []pb.Entry{{Data: wctx}}})
+ if len(sm.readStates) != 1 {
+ t.Fatalf("len(readStates) = %d, want 1", len(sm.readStates))
+ }
+ rs := sm.readStates[0]
+ if rs.Index != windex {
+ t.Fatalf("readIndex = %d, want %d", rs.Index, windex)
+ }
+ if !bytes.Equal(rs.RequestCtx, wctx) {
+ t.Fatalf("requestCtx = %v, want %v", rs.RequestCtx, wctx)
+ }
+}
+
+func TestLeaderAppResp(t *testing.T) {
+ // initial progress: match = 0; next = 3
+ tests := []struct {
+ index uint64
+ reject bool
+ // progress
+ wmatch uint64
+ wnext uint64
+ // message
+ wmsgNum int
+ windex uint64
+ wcommitted uint64
+ }{
+ {3, true, 0, 3, 0, 0, 0}, // stale resp; no replies
+ {2, true, 0, 2, 1, 1, 0}, // denied resp; leader does not commit; decrease next and send probing msg
+ {2, false, 2, 4, 2, 2, 2}, // accept resp; leader commits; broadcast with commit index
+ {0, false, 0, 3, 0, 0, 0}, // ignore heartbeat replies
+ }
+
+ for i, tt := range tests {
+ // sm term is 1 after it becomes the leader.
+ // thus the last log term must be 1 to be committed.
+ sm := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ sm.raftLog = &raftLog{
+ storage: &MemoryStorage{ents: []pb.Entry{{}, {Index: 1, Term: 0}, {Index: 2, Term: 1}}},
+ unstable: unstable{offset: 3},
+ }
+ sm.becomeCandidate()
+ sm.becomeLeader()
+ sm.readMessages()
+ sm.Step(pb.Message{From: 2, Type: pb.MsgAppResp, Index: tt.index, Term: sm.Term, Reject: tt.reject, RejectHint: tt.index})
+
+ p := sm.prs[2]
+ if p.Match != tt.wmatch {
+ t.Errorf("#%d match = %d, want %d", i, p.Match, tt.wmatch)
+ }
+ if p.Next != tt.wnext {
+ t.Errorf("#%d next = %d, want %d", i, p.Next, tt.wnext)
+ }
+
+ msgs := sm.readMessages()
+
+ if len(msgs) != tt.wmsgNum {
+ t.Errorf("#%d msgNum = %d, want %d", i, len(msgs), tt.wmsgNum)
+ }
+ for j, msg := range msgs {
+ if msg.Index != tt.windex {
+ t.Errorf("#%d.%d index = %d, want %d", i, j, msg.Index, tt.windex)
+ }
+ if msg.Commit != tt.wcommitted {
+ t.Errorf("#%d.%d commit = %d, want %d", i, j, msg.Commit, tt.wcommitted)
+ }
+ }
+ }
+}
+
+// When the leader receives a heartbeat tick, it should
+// send a MsgApp with m.Index = 0, m.LogTerm=0 and empty entries.
+func TestBcastBeat(t *testing.T) {
+ offset := uint64(1000)
+ // make a state machine with log.offset = 1000
+ s := pb.Snapshot{
+ Metadata: pb.SnapshotMetadata{
+ Index: offset,
+ Term: 1,
+ ConfState: pb.ConfState{Nodes: []uint64{1, 2, 3}},
+ },
+ }
+ storage := NewMemoryStorage()
+ storage.ApplySnapshot(s)
+ sm := newTestRaft(1, nil, 10, 1, storage)
+ sm.Term = 1
+
+ sm.becomeCandidate()
+ sm.becomeLeader()
+ for i := 0; i < 10; i++ {
+ sm.appendEntry(pb.Entry{Index: uint64(i) + 1})
+ }
+ // slow follower
+ sm.prs[2].Match, sm.prs[2].Next = 5, 6
+ // normal follower
+ sm.prs[3].Match, sm.prs[3].Next = sm.raftLog.lastIndex(), sm.raftLog.lastIndex()+1
+
+ sm.Step(pb.Message{Type: pb.MsgBeat})
+ msgs := sm.readMessages()
+ if len(msgs) != 2 {
+ t.Fatalf("len(msgs) = %v, want 2", len(msgs))
+ }
+ wantCommitMap := map[uint64]uint64{
+ 2: min(sm.raftLog.committed, sm.prs[2].Match),
+ 3: min(sm.raftLog.committed, sm.prs[3].Match),
+ }
+ for i, m := range msgs {
+ if m.Type != pb.MsgHeartbeat {
+ t.Fatalf("#%d: type = %v, want = %v", i, m.Type, pb.MsgHeartbeat)
+ }
+ if m.Index != 0 {
+ t.Fatalf("#%d: prevIndex = %d, want %d", i, m.Index, 0)
+ }
+ if m.LogTerm != 0 {
+ t.Fatalf("#%d: prevTerm = %d, want %d", i, m.LogTerm, 0)
+ }
+ if wantCommitMap[m.To] == 0 {
+ t.Fatalf("#%d: unexpected to %d", i, m.To)
+ } else {
+ if m.Commit != wantCommitMap[m.To] {
+ t.Fatalf("#%d: commit = %d, want %d", i, m.Commit, wantCommitMap[m.To])
+ }
+ delete(wantCommitMap, m.To)
+ }
+ if len(m.Entries) != 0 {
+ t.Fatalf("#%d: len(entries) = %d, want 0", i, len(m.Entries))
+ }
+ }
+}
+
+// tests the output of the state machine when receiving MsgBeat
+func TestRecvMsgBeat(t *testing.T) {
+ tests := []struct {
+ state StateType
+ wMsg int
+ }{
+ {StateLeader, 2},
+ // candidate and follower should ignore MsgBeat
+ {StateCandidate, 0},
+ {StateFollower, 0},
+ }
+
+ for i, tt := range tests {
+ sm := newTestRaft(1, []uint64{1, 2, 3}, 10, 1, NewMemoryStorage())
+ sm.raftLog = &raftLog{storage: &MemoryStorage{ents: []pb.Entry{{}, {Index: 1, Term: 0}, {Index: 2, Term: 1}}}}
+ sm.Term = 1
+ sm.state = tt.state
+ switch tt.state {
+ case StateFollower:
+ sm.step = stepFollower
+ case StateCandidate:
+ sm.step = stepCandidate
+ case StateLeader:
+ sm.step = stepLeader
+ }
+ sm.Step(pb.Message{From: 1, To: 1, Type: pb.MsgBeat})
+
+ msgs := sm.readMessages()
+ if len(msgs) != tt.wMsg {
+ t.Errorf("%d: len(msgs) = %d, want %d", i, len(msgs), tt.wMsg)
+ }
+ for _, m := range msgs {
+ if m.Type != pb.MsgHeartbeat {
+ t.Errorf("%d: msg.type = %v, want %v", i, m.Type, pb.MsgHeartbeat)
+ }
+ }
+ }
+}
+
+func TestLeaderIncreaseNext(t *testing.T) {
+ previousEnts := []pb.Entry{{Term: 1, Index: 1}, {Term: 1, Index: 2}, {Term: 1, Index: 3}}
+ tests := []struct {
+ // progress
+ state ProgressStateType
+ next uint64
+
+ wnext uint64
+ }{
+ // state replicate, optimistically increase next
+ // previous entries + noop entry + propose + 1
+ {ProgressStateReplicate, 2, uint64(len(previousEnts) + 1 + 1 + 1)},
+ // state probe, not optimistically increase next
+ {ProgressStateProbe, 2, 2},
+ }
+
+ for i, tt := range tests {
+ sm := newTestRaft(1, []uint64{1, 2}, 10, 1, NewMemoryStorage())
+ sm.raftLog.append(previousEnts...)
+ sm.becomeCandidate()
+ sm.becomeLeader()
+ sm.prs[2].State = tt.state
+ sm.prs[2].Next = tt.next
+ sm.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+
+ p := sm.prs[2]
+ if p.Next != tt.wnext {
+ t.Errorf("#%d next = %d, want %d", i, p.Next, tt.wnext)
+ }
+ }
+}
+
+func TestSendAppendForProgressProbe(t *testing.T) {
+ r := newTestRaft(1, []uint64{1, 2}, 10, 1, NewMemoryStorage())
+ r.becomeCandidate()
+ r.becomeLeader()
+ r.readMessages()
+ r.prs[2].becomeProbe()
+
+ // each round is a heartbeat
+ for i := 0; i < 3; i++ {
+ if i == 0 {
+ // we expect that raft will only send out one msgAPP on the first
+ // loop. After that, the follower is paused until a heartbeat response is
+ // received.
+ r.appendEntry(pb.Entry{Data: []byte("somedata")})
+ r.sendAppend(2)
+ msg := r.readMessages()
+ if len(msg) != 1 {
+ t.Errorf("len(msg) = %d, want %d", len(msg), 1)
+ }
+ if msg[0].Index != 0 {
+ t.Errorf("index = %d, want %d", msg[0].Index, 0)
+ }
+ }
+
+ if !r.prs[2].Paused {
+ t.Errorf("paused = %v, want true", r.prs[2].Paused)
+ }
+ for j := 0; j < 10; j++ {
+ r.appendEntry(pb.Entry{Data: []byte("somedata")})
+ r.sendAppend(2)
+ if l := len(r.readMessages()); l != 0 {
+ t.Errorf("len(msg) = %d, want %d", l, 0)
+ }
+ }
+
+ // do a heartbeat
+ for j := 0; j < r.heartbeatTimeout; j++ {
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgBeat})
+ }
+ if !r.prs[2].Paused {
+ t.Errorf("paused = %v, want true", r.prs[2].Paused)
+ }
+
+ // consume the heartbeat
+ msg := r.readMessages()
+ if len(msg) != 1 {
+ t.Errorf("len(msg) = %d, want %d", len(msg), 1)
+ }
+ if msg[0].Type != pb.MsgHeartbeat {
+ t.Errorf("type = %v, want %v", msg[0].Type, pb.MsgHeartbeat)
+ }
+ }
+
+ // a heartbeat response will allow another message to be sent
+ r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgHeartbeatResp})
+ msg := r.readMessages()
+ if len(msg) != 1 {
+ t.Errorf("len(msg) = %d, want %d", len(msg), 1)
+ }
+ if msg[0].Index != 0 {
+ t.Errorf("index = %d, want %d", msg[0].Index, 0)
+ }
+ if !r.prs[2].Paused {
+ t.Errorf("paused = %v, want true", r.prs[2].Paused)
+ }
+}
+
+func TestSendAppendForProgressReplicate(t *testing.T) {
+ r := newTestRaft(1, []uint64{1, 2}, 10, 1, NewMemoryStorage())
+ r.becomeCandidate()
+ r.becomeLeader()
+ r.readMessages()
+ r.prs[2].becomeReplicate()
+
+ for i := 0; i < 10; i++ {
+ r.appendEntry(pb.Entry{Data: []byte("somedata")})
+ r.sendAppend(2)
+ msgs := r.readMessages()
+ if len(msgs) != 1 {
+ t.Errorf("len(msg) = %d, want %d", len(msgs), 1)
+ }
+ }
+}
+
+func TestSendAppendForProgressSnapshot(t *testing.T) {
+ r := newTestRaft(1, []uint64{1, 2}, 10, 1, NewMemoryStorage())
+ r.becomeCandidate()
+ r.becomeLeader()
+ r.readMessages()
+ r.prs[2].becomeSnapshot(10)
+
+ for i := 0; i < 10; i++ {
+ r.appendEntry(pb.Entry{Data: []byte("somedata")})
+ r.sendAppend(2)
+ msgs := r.readMessages()
+ if len(msgs) != 0 {
+ t.Errorf("len(msg) = %d, want %d", len(msgs), 0)
+ }
+ }
+}
+
+func TestRecvMsgUnreachable(t *testing.T) {
+ previousEnts := []pb.Entry{{Term: 1, Index: 1}, {Term: 1, Index: 2}, {Term: 1, Index: 3}}
+ s := NewMemoryStorage()
+ s.Append(previousEnts)
+ r := newTestRaft(1, []uint64{1, 2}, 10, 1, s)
+ r.becomeCandidate()
+ r.becomeLeader()
+ r.readMessages()
+ // set node 2 to state replicate
+ r.prs[2].Match = 3
+ r.prs[2].becomeReplicate()
+ r.prs[2].optimisticUpdate(5)
+
+ r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgUnreachable})
+
+ if r.prs[2].State != ProgressStateProbe {
+ t.Errorf("state = %s, want %s", r.prs[2].State, ProgressStateProbe)
+ }
+ if wnext := r.prs[2].Match + 1; r.prs[2].Next != wnext {
+ t.Errorf("next = %d, want %d", r.prs[2].Next, wnext)
+ }
+}
+
+func TestRestore(t *testing.T) {
+ s := pb.Snapshot{
+ Metadata: pb.SnapshotMetadata{
+ Index: 11, // magic number
+ Term: 11, // magic number
+ ConfState: pb.ConfState{Nodes: []uint64{1, 2, 3}},
+ },
+ }
+
+ storage := NewMemoryStorage()
+ sm := newTestRaft(1, []uint64{1, 2}, 10, 1, storage)
+ if ok := sm.restore(s); !ok {
+ t.Fatal("restore fail, want succeed")
+ }
+
+ if sm.raftLog.lastIndex() != s.Metadata.Index {
+ t.Errorf("log.lastIndex = %d, want %d", sm.raftLog.lastIndex(), s.Metadata.Index)
+ }
+ if mustTerm(sm.raftLog.term(s.Metadata.Index)) != s.Metadata.Term {
+ t.Errorf("log.lastTerm = %d, want %d", mustTerm(sm.raftLog.term(s.Metadata.Index)), s.Metadata.Term)
+ }
+ sg := sm.nodes()
+ if !reflect.DeepEqual(sg, s.Metadata.ConfState.Nodes) {
+ t.Errorf("sm.Nodes = %+v, want %+v", sg, s.Metadata.ConfState.Nodes)
+ }
+
+ if ok := sm.restore(s); ok {
+ t.Fatal("restore succeed, want fail")
+ }
+}
+
+func TestRestoreIgnoreSnapshot(t *testing.T) {
+ previousEnts := []pb.Entry{{Term: 1, Index: 1}, {Term: 1, Index: 2}, {Term: 1, Index: 3}}
+ commit := uint64(1)
+ storage := NewMemoryStorage()
+ sm := newTestRaft(1, []uint64{1, 2}, 10, 1, storage)
+ sm.raftLog.append(previousEnts...)
+ sm.raftLog.commitTo(commit)
+
+ s := pb.Snapshot{
+ Metadata: pb.SnapshotMetadata{
+ Index: commit,
+ Term: 1,
+ ConfState: pb.ConfState{Nodes: []uint64{1, 2}},
+ },
+ }
+
+ // ignore snapshot
+ if ok := sm.restore(s); ok {
+ t.Errorf("restore = %t, want %t", ok, false)
+ }
+ if sm.raftLog.committed != commit {
+ t.Errorf("commit = %d, want %d", sm.raftLog.committed, commit)
+ }
+
+ // ignore snapshot and fast forward commit
+ s.Metadata.Index = commit + 1
+ if ok := sm.restore(s); ok {
+ t.Errorf("restore = %t, want %t", ok, false)
+ }
+ if sm.raftLog.committed != commit+1 {
+ t.Errorf("commit = %d, want %d", sm.raftLog.committed, commit+1)
+ }
+}
+
+func TestProvideSnap(t *testing.T) {
+ // restore the state machine from a snapshot so it has a compacted log and a snapshot
+ s := pb.Snapshot{
+ Metadata: pb.SnapshotMetadata{
+ Index: 11, // magic number
+ Term: 11, // magic number
+ ConfState: pb.ConfState{Nodes: []uint64{1, 2}},
+ },
+ }
+ storage := NewMemoryStorage()
+ sm := newTestRaft(1, []uint64{1}, 10, 1, storage)
+ sm.restore(s)
+
+ sm.becomeCandidate()
+ sm.becomeLeader()
+
+ // force set the next of node 2, so that node 2 needs a snapshot
+ sm.prs[2].Next = sm.raftLog.firstIndex()
+ sm.Step(pb.Message{From: 2, To: 1, Type: pb.MsgAppResp, Index: sm.prs[2].Next - 1, Reject: true})
+
+ msgs := sm.readMessages()
+ if len(msgs) != 1 {
+ t.Fatalf("len(msgs) = %d, want 1", len(msgs))
+ }
+ m := msgs[0]
+ if m.Type != pb.MsgSnap {
+ t.Errorf("m.Type = %v, want %v", m.Type, pb.MsgSnap)
+ }
+}
+
+func TestIgnoreProvidingSnap(t *testing.T) {
+ // restore the state machine from a snapshot so it has a compacted log and a snapshot
+ s := pb.Snapshot{
+ Metadata: pb.SnapshotMetadata{
+ Index: 11, // magic number
+ Term: 11, // magic number
+ ConfState: pb.ConfState{Nodes: []uint64{1, 2}},
+ },
+ }
+ storage := NewMemoryStorage()
+ sm := newTestRaft(1, []uint64{1}, 10, 1, storage)
+ sm.restore(s)
+
+ sm.becomeCandidate()
+ sm.becomeLeader()
+
+ // force set the next of node 2, so that node 2 needs a snapshot
+ // change node 2 to be inactive, expect node 1 ignore sending snapshot to 2
+ sm.prs[2].Next = sm.raftLog.firstIndex() - 1
+ sm.prs[2].RecentActive = false
+
+ sm.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
+
+ msgs := sm.readMessages()
+ if len(msgs) != 0 {
+ t.Errorf("len(msgs) = %d, want 0", len(msgs))
+ }
+}
+
+func TestRestoreFromSnapMsg(t *testing.T) {
+ s := pb.Snapshot{
+ Metadata: pb.SnapshotMetadata{
+ Index: 11, // magic number
+ Term: 11, // magic number
+ ConfState: pb.ConfState{Nodes: []uint64{1, 2}},
+ },
+ }
+ m := pb.Message{Type: pb.MsgSnap, From: 1, Term: 2, Snapshot: s}
+
+ sm := newTestRaft(2, []uint64{1, 2}, 10, 1, NewMemoryStorage())
+ sm.Step(m)
+
+ if sm.lead != uint64(1) {
+ t.Errorf("sm.lead = %d, want 1", sm.lead)
+ }
+
+ // TODO(bdarnell): what should this test?
+}
+
+func TestSlowNodeRestore(t *testing.T) {
+ nt := newNetwork(nil, nil, nil)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ nt.isolate(3)
+ for j := 0; j <= 100; j++ {
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{}}})
+ }
+ lead := nt.peers[1].(*raft)
+ nextEnts(lead, nt.storage[1])
+ nt.storage[1].CreateSnapshot(lead.raftLog.applied, &pb.ConfState{Nodes: lead.nodes()}, nil)
+ nt.storage[1].Compact(lead.raftLog.applied)
+
+ nt.recover()
+ // send heartbeats so that the leader can learn everyone is active.
+ // node 3 will only be considered as active when node 1 receives a reply from it.
+ for {
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgBeat})
+ if lead.prs[3].RecentActive {
+ break
+ }
+ }
+
+ // trigger a snapshot
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{}}})
+
+ follower := nt.peers[3].(*raft)
+
+ // trigger a commit
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{}}})
+ if follower.raftLog.committed != lead.raftLog.committed {
+ t.Errorf("follower.committed = %d, want %d", follower.raftLog.committed, lead.raftLog.committed)
+ }
+}
+
+// TestStepConfig tests that when raft step msgProp in EntryConfChange type,
+// it appends the entry to log and sets pendingConf to be true.
+func TestStepConfig(t *testing.T) {
+ // a raft that cannot make progress
+ r := newTestRaft(1, []uint64{1, 2}, 10, 1, NewMemoryStorage())
+ r.becomeCandidate()
+ r.becomeLeader()
+ index := r.raftLog.lastIndex()
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Type: pb.EntryConfChange}}})
+ if g := r.raftLog.lastIndex(); g != index+1 {
+ t.Errorf("index = %d, want %d", g, index+1)
+ }
+ if !r.pendingConf {
+ t.Errorf("pendingConf = %v, want true", r.pendingConf)
+ }
+}
+
+// TestStepIgnoreConfig tests that if raft step the second msgProp in
+// EntryConfChange type when the first one is uncommitted, the node will set
+// the proposal to noop and keep its original state.
+func TestStepIgnoreConfig(t *testing.T) {
+ // a raft that cannot make progress
+ r := newTestRaft(1, []uint64{1, 2}, 10, 1, NewMemoryStorage())
+ r.becomeCandidate()
+ r.becomeLeader()
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Type: pb.EntryConfChange}}})
+ index := r.raftLog.lastIndex()
+ pendingConf := r.pendingConf
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Type: pb.EntryConfChange}}})
+ wents := []pb.Entry{{Type: pb.EntryNormal, Term: 1, Index: 3, Data: nil}}
+ ents, err := r.raftLog.entries(index+1, noLimit)
+ if err != nil {
+ t.Fatalf("unexpected error %v", err)
+ }
+ if !reflect.DeepEqual(ents, wents) {
+ t.Errorf("ents = %+v, want %+v", ents, wents)
+ }
+ if r.pendingConf != pendingConf {
+ t.Errorf("pendingConf = %v, want %v", r.pendingConf, pendingConf)
+ }
+}
+
+// TestRecoverPendingConfig tests that new leader recovers its pendingConf flag
+// based on uncommitted entries.
+func TestRecoverPendingConfig(t *testing.T) {
+ tests := []struct {
+ entType pb.EntryType
+ wpending bool
+ }{
+ {pb.EntryNormal, false},
+ {pb.EntryConfChange, true},
+ }
+ for i, tt := range tests {
+ r := newTestRaft(1, []uint64{1, 2}, 10, 1, NewMemoryStorage())
+ r.appendEntry(pb.Entry{Type: tt.entType})
+ r.becomeCandidate()
+ r.becomeLeader()
+ if r.pendingConf != tt.wpending {
+ t.Errorf("#%d: pendingConf = %v, want %v", i, r.pendingConf, tt.wpending)
+ }
+ }
+}
+
+// TestRecoverDoublePendingConfig tests that new leader will panic if
+// there exist two uncommitted config entries.
+func TestRecoverDoublePendingConfig(t *testing.T) {
+ func() {
+ defer func() {
+ if err := recover(); err == nil {
+ t.Errorf("expect panic, but nothing happens")
+ }
+ }()
+ r := newTestRaft(1, []uint64{1, 2}, 10, 1, NewMemoryStorage())
+ r.appendEntry(pb.Entry{Type: pb.EntryConfChange})
+ r.appendEntry(pb.Entry{Type: pb.EntryConfChange})
+ r.becomeCandidate()
+ r.becomeLeader()
+ }()
+}
+
+// TestAddNode tests that addNode could update pendingConf and nodes correctly.
+func TestAddNode(t *testing.T) {
+ r := newTestRaft(1, []uint64{1}, 10, 1, NewMemoryStorage())
+ r.pendingConf = true
+ r.addNode(2)
+ if r.pendingConf {
+ t.Errorf("pendingConf = %v, want false", r.pendingConf)
+ }
+ nodes := r.nodes()
+ wnodes := []uint64{1, 2}
+ if !reflect.DeepEqual(nodes, wnodes) {
+ t.Errorf("nodes = %v, want %v", nodes, wnodes)
+ }
+}
+
+// TestAddNodeCheckQuorum tests that addNode does not trigger a leader election
+// immediately when checkQuorum is set.
+func TestAddNodeCheckQuorum(t *testing.T) {
+ r := newTestRaft(1, []uint64{1}, 10, 1, NewMemoryStorage())
+ r.pendingConf = true
+ r.checkQuorum = true
+
+ r.becomeCandidate()
+ r.becomeLeader()
+
+ for i := 0; i < r.electionTimeout-1; i++ {
+ r.tick()
+ }
+
+ r.addNode(2)
+
+ // This tick will reach electionTimeout, which triggers a quorum check.
+ r.tick()
+
+ // Node 1 should still be the leader after a single tick.
+ if r.state != StateLeader {
+ t.Errorf("state = %v, want %v", r.state, StateLeader)
+ }
+
+ // After another electionTimeout ticks without hearing from node 2,
+ // node 1 should step down.
+ for i := 0; i < r.electionTimeout; i++ {
+ r.tick()
+ }
+
+ if r.state != StateFollower {
+ t.Errorf("state = %v, want %v", r.state, StateFollower)
+ }
+}
+
+// TestRemoveNode tests that removeNode could update pendingConf, nodes and
+// and removed list correctly.
+func TestRemoveNode(t *testing.T) {
+ r := newTestRaft(1, []uint64{1, 2}, 10, 1, NewMemoryStorage())
+ r.pendingConf = true
+ r.removeNode(2)
+ if r.pendingConf {
+ t.Errorf("pendingConf = %v, want false", r.pendingConf)
+ }
+ w := []uint64{1}
+ if g := r.nodes(); !reflect.DeepEqual(g, w) {
+ t.Errorf("nodes = %v, want %v", g, w)
+ }
+
+ // remove all nodes from cluster
+ r.removeNode(1)
+ w = []uint64{}
+ if g := r.nodes(); !reflect.DeepEqual(g, w) {
+ t.Errorf("nodes = %v, want %v", g, w)
+ }
+}
+
+func TestPromotable(t *testing.T) {
+ id := uint64(1)
+ tests := []struct {
+ peers []uint64
+ wp bool
+ }{
+ {[]uint64{1}, true},
+ {[]uint64{1, 2, 3}, true},
+ {[]uint64{}, false},
+ {[]uint64{2, 3}, false},
+ }
+ for i, tt := range tests {
+ r := newTestRaft(id, tt.peers, 5, 1, NewMemoryStorage())
+ if g := r.promotable(); g != tt.wp {
+ t.Errorf("#%d: promotable = %v, want %v", i, g, tt.wp)
+ }
+ }
+}
+
+func TestRaftNodes(t *testing.T) {
+ tests := []struct {
+ ids []uint64
+ wids []uint64
+ }{
+ {
+ []uint64{1, 2, 3},
+ []uint64{1, 2, 3},
+ },
+ {
+ []uint64{3, 2, 1},
+ []uint64{1, 2, 3},
+ },
+ }
+ for i, tt := range tests {
+ r := newTestRaft(1, tt.ids, 10, 1, NewMemoryStorage())
+ if !reflect.DeepEqual(r.nodes(), tt.wids) {
+ t.Errorf("#%d: nodes = %+v, want %+v", i, r.nodes(), tt.wids)
+ }
+ }
+}
+
+func TestCampaignWhileLeader(t *testing.T) {
+ testCampaignWhileLeader(t, false)
+}
+
+func TestPreCampaignWhileLeader(t *testing.T) {
+ testCampaignWhileLeader(t, true)
+}
+
+func testCampaignWhileLeader(t *testing.T, preVote bool) {
+ cfg := newTestConfig(1, []uint64{1}, 5, 1, NewMemoryStorage())
+ cfg.PreVote = preVote
+ r := newRaft(cfg)
+ if r.state != StateFollower {
+ t.Errorf("expected new node to be follower but got %s", r.state)
+ }
+ // We don't call campaign() directly because it comes after the check
+ // for our current state.
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ if r.state != StateLeader {
+ t.Errorf("expected single-node election to become leader but got %s", r.state)
+ }
+ term := r.Term
+ r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+ if r.state != StateLeader {
+ t.Errorf("expected to remain leader but got %s", r.state)
+ }
+ if r.Term != term {
+ t.Errorf("expected to remain in term %v but got %v", term, r.Term)
+ }
+}
+
+// TestCommitAfterRemoveNode verifies that pending commands can become
+// committed when a config change reduces the quorum requirements.
+func TestCommitAfterRemoveNode(t *testing.T) {
+ // Create a cluster with two nodes.
+ s := NewMemoryStorage()
+ r := newTestRaft(1, []uint64{1, 2}, 5, 1, s)
+ r.becomeCandidate()
+ r.becomeLeader()
+
+ // Begin to remove the second node.
+ cc := pb.ConfChange{
+ Type: pb.ConfChangeRemoveNode,
+ NodeID: 2,
+ }
+ ccData, err := cc.Marshal()
+ if err != nil {
+ t.Fatal(err)
+ }
+ r.Step(pb.Message{
+ Type: pb.MsgProp,
+ Entries: []pb.Entry{
+ {Type: pb.EntryConfChange, Data: ccData},
+ },
+ })
+ // Stabilize the log and make sure nothing is committed yet.
+ if ents := nextEnts(r, s); len(ents) > 0 {
+ t.Fatalf("unexpected committed entries: %v", ents)
+ }
+ ccIndex := r.raftLog.lastIndex()
+
+ // While the config change is pending, make another proposal.
+ r.Step(pb.Message{
+ Type: pb.MsgProp,
+ Entries: []pb.Entry{
+ {Type: pb.EntryNormal, Data: []byte("hello")},
+ },
+ })
+
+ // Node 2 acknowledges the config change, committing it.
+ r.Step(pb.Message{
+ Type: pb.MsgAppResp,
+ From: 2,
+ Index: ccIndex,
+ })
+ ents := nextEnts(r, s)
+ if len(ents) != 2 {
+ t.Fatalf("expected two committed entries, got %v", ents)
+ }
+ if ents[0].Type != pb.EntryNormal || ents[0].Data != nil {
+ t.Fatalf("expected ents[0] to be empty, but got %v", ents[0])
+ }
+ if ents[1].Type != pb.EntryConfChange {
+ t.Fatalf("expected ents[1] to be EntryConfChange, got %v", ents[1])
+ }
+
+ // Apply the config change. This reduces quorum requirements so the
+ // pending command can now commit.
+ r.removeNode(2)
+ ents = nextEnts(r, s)
+ if len(ents) != 1 || ents[0].Type != pb.EntryNormal ||
+ string(ents[0].Data) != "hello" {
+ t.Fatalf("expected one committed EntryNormal, got %v", ents)
+ }
+}
+
+// TestLeaderTransferToUpToDateNode verifies transferring should succeed
+// if the transferee has the most up-to-date log entries when transfer starts.
+func TestLeaderTransferToUpToDateNode(t *testing.T) {
+ nt := newNetwork(nil, nil, nil)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ lead := nt.peers[1].(*raft)
+
+ if lead.lead != 1 {
+ t.Fatalf("after election leader is %x, want 1", lead.lead)
+ }
+
+ // Transfer leadership to 2.
+ nt.send(pb.Message{From: 2, To: 1, Type: pb.MsgTransferLeader})
+
+ checkLeaderTransferState(t, lead, StateFollower, 2)
+
+ // After some log replication, transfer leadership back to 1.
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{}}})
+
+ nt.send(pb.Message{From: 1, To: 2, Type: pb.MsgTransferLeader})
+
+ checkLeaderTransferState(t, lead, StateLeader, 1)
+}
+
+// TestLeaderTransferToUpToDateNodeFromFollower verifies transferring should succeed
+// if the transferee has the most up-to-date log entries when transfer starts.
+// Not like TestLeaderTransferToUpToDateNode, where the leader transfer message
+// is sent to the leader, in this test case every leader transfer message is sent
+// to the follower.
+func TestLeaderTransferToUpToDateNodeFromFollower(t *testing.T) {
+ nt := newNetwork(nil, nil, nil)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ lead := nt.peers[1].(*raft)
+
+ if lead.lead != 1 {
+ t.Fatalf("after election leader is %x, want 1", lead.lead)
+ }
+
+ // Transfer leadership to 2.
+ nt.send(pb.Message{From: 2, To: 2, Type: pb.MsgTransferLeader})
+
+ checkLeaderTransferState(t, lead, StateFollower, 2)
+
+ // After some log replication, transfer leadership back to 1.
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{}}})
+
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgTransferLeader})
+
+ checkLeaderTransferState(t, lead, StateLeader, 1)
+}
+
+// TestLeaderTransferWithCheckQuorum ensures transferring leader still works
+// even the current leader is still under its leader lease
+func TestLeaderTransferWithCheckQuorum(t *testing.T) {
+ nt := newNetwork(nil, nil, nil)
+ for i := 1; i < 4; i++ {
+ r := nt.peers[uint64(i)].(*raft)
+ r.checkQuorum = true
+ setRandomizedElectionTimeout(r, r.electionTimeout+i)
+ }
+
+ // Letting peer 2 electionElapsed reach to timeout so that it can vote for peer 1
+ f := nt.peers[2].(*raft)
+ for i := 0; i < f.electionTimeout; i++ {
+ f.tick()
+ }
+
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ lead := nt.peers[1].(*raft)
+
+ if lead.lead != 1 {
+ t.Fatalf("after election leader is %x, want 1", lead.lead)
+ }
+
+ // Transfer leadership to 2.
+ nt.send(pb.Message{From: 2, To: 1, Type: pb.MsgTransferLeader})
+
+ checkLeaderTransferState(t, lead, StateFollower, 2)
+
+ // After some log replication, transfer leadership back to 1.
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{}}})
+
+ nt.send(pb.Message{From: 1, To: 2, Type: pb.MsgTransferLeader})
+
+ checkLeaderTransferState(t, lead, StateLeader, 1)
+}
+
+func TestLeaderTransferToSlowFollower(t *testing.T) {
+ defaultLogger.EnableDebug()
+ nt := newNetwork(nil, nil, nil)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ nt.isolate(3)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{}}})
+
+ nt.recover()
+ lead := nt.peers[1].(*raft)
+ if lead.prs[3].Match != 1 {
+ t.Fatalf("node 1 has match %x for node 3, want %x", lead.prs[3].Match, 1)
+ }
+
+ // Transfer leadership to 3 when node 3 is lack of log.
+ nt.send(pb.Message{From: 3, To: 1, Type: pb.MsgTransferLeader})
+
+ checkLeaderTransferState(t, lead, StateFollower, 3)
+}
+
+func TestLeaderTransferAfterSnapshot(t *testing.T) {
+ nt := newNetwork(nil, nil, nil)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ nt.isolate(3)
+
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{}}})
+ lead := nt.peers[1].(*raft)
+ nextEnts(lead, nt.storage[1])
+ nt.storage[1].CreateSnapshot(lead.raftLog.applied, &pb.ConfState{Nodes: lead.nodes()}, nil)
+ nt.storage[1].Compact(lead.raftLog.applied)
+
+ nt.recover()
+ if lead.prs[3].Match != 1 {
+ t.Fatalf("node 1 has match %x for node 3, want %x", lead.prs[3].Match, 1)
+ }
+
+ // Transfer leadership to 3 when node 3 is lack of snapshot.
+ nt.send(pb.Message{From: 3, To: 1, Type: pb.MsgTransferLeader})
+ // Send pb.MsgHeartbeatResp to leader to trigger a snapshot for node 3.
+ nt.send(pb.Message{From: 3, To: 1, Type: pb.MsgHeartbeatResp})
+
+ checkLeaderTransferState(t, lead, StateFollower, 3)
+}
+
+func TestLeaderTransferToSelf(t *testing.T) {
+ nt := newNetwork(nil, nil, nil)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ lead := nt.peers[1].(*raft)
+
+ // Transfer leadership to self, there will be noop.
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgTransferLeader})
+ checkLeaderTransferState(t, lead, StateLeader, 1)
+}
+
+func TestLeaderTransferToNonExistingNode(t *testing.T) {
+ nt := newNetwork(nil, nil, nil)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ lead := nt.peers[1].(*raft)
+ // Transfer leadership to non-existing node, there will be noop.
+ nt.send(pb.Message{From: 4, To: 1, Type: pb.MsgTransferLeader})
+ checkLeaderTransferState(t, lead, StateLeader, 1)
+}
+
+func TestLeaderTransferTimeout(t *testing.T) {
+ nt := newNetwork(nil, nil, nil)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ nt.isolate(3)
+
+ lead := nt.peers[1].(*raft)
+
+ // Transfer leadership to isolated node, wait for timeout.
+ nt.send(pb.Message{From: 3, To: 1, Type: pb.MsgTransferLeader})
+ if lead.leadTransferee != 3 {
+ t.Fatalf("wait transferring, leadTransferee = %v, want %v", lead.leadTransferee, 3)
+ }
+ for i := 0; i < lead.heartbeatTimeout; i++ {
+ lead.tick()
+ }
+ if lead.leadTransferee != 3 {
+ t.Fatalf("wait transferring, leadTransferee = %v, want %v", lead.leadTransferee, 3)
+ }
+
+ for i := 0; i < lead.electionTimeout-lead.heartbeatTimeout; i++ {
+ lead.tick()
+ }
+
+ checkLeaderTransferState(t, lead, StateLeader, 1)
+}
+
+func TestLeaderTransferIgnoreProposal(t *testing.T) {
+ nt := newNetwork(nil, nil, nil)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ nt.isolate(3)
+
+ lead := nt.peers[1].(*raft)
+
+ // Transfer leadership to isolated node to let transfer pending, then send proposal.
+ nt.send(pb.Message{From: 3, To: 1, Type: pb.MsgTransferLeader})
+ if lead.leadTransferee != 3 {
+ t.Fatalf("wait transferring, leadTransferee = %v, want %v", lead.leadTransferee, 3)
+ }
+
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{}}})
+
+ if lead.prs[1].Match != 1 {
+ t.Fatalf("node 1 has match %x, want %x", lead.prs[1].Match, 1)
+ }
+}
+
+func TestLeaderTransferReceiveHigherTermVote(t *testing.T) {
+ nt := newNetwork(nil, nil, nil)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ nt.isolate(3)
+
+ lead := nt.peers[1].(*raft)
+
+ // Transfer leadership to isolated node to let transfer pending.
+ nt.send(pb.Message{From: 3, To: 1, Type: pb.MsgTransferLeader})
+ if lead.leadTransferee != 3 {
+ t.Fatalf("wait transferring, leadTransferee = %v, want %v", lead.leadTransferee, 3)
+ }
+
+ nt.send(pb.Message{From: 2, To: 2, Type: pb.MsgHup, Index: 1, Term: 2})
+
+ checkLeaderTransferState(t, lead, StateFollower, 2)
+}
+
+func TestLeaderTransferRemoveNode(t *testing.T) {
+ nt := newNetwork(nil, nil, nil)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ nt.ignore(pb.MsgTimeoutNow)
+
+ lead := nt.peers[1].(*raft)
+
+ // The leadTransferee is removed when leadship transferring.
+ nt.send(pb.Message{From: 3, To: 1, Type: pb.MsgTransferLeader})
+ if lead.leadTransferee != 3 {
+ t.Fatalf("wait transferring, leadTransferee = %v, want %v", lead.leadTransferee, 3)
+ }
+
+ lead.removeNode(3)
+
+ checkLeaderTransferState(t, lead, StateLeader, 1)
+}
+
+// TestLeaderTransferBack verifies leadership can transfer back to self when last transfer is pending.
+func TestLeaderTransferBack(t *testing.T) {
+ nt := newNetwork(nil, nil, nil)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ nt.isolate(3)
+
+ lead := nt.peers[1].(*raft)
+
+ nt.send(pb.Message{From: 3, To: 1, Type: pb.MsgTransferLeader})
+ if lead.leadTransferee != 3 {
+ t.Fatalf("wait transferring, leadTransferee = %v, want %v", lead.leadTransferee, 3)
+ }
+
+ // Transfer leadership back to self.
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgTransferLeader})
+
+ checkLeaderTransferState(t, lead, StateLeader, 1)
+}
+
+// TestLeaderTransferSecondTransferToAnotherNode verifies leader can transfer to another node
+// when last transfer is pending.
+func TestLeaderTransferSecondTransferToAnotherNode(t *testing.T) {
+ nt := newNetwork(nil, nil, nil)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ nt.isolate(3)
+
+ lead := nt.peers[1].(*raft)
+
+ nt.send(pb.Message{From: 3, To: 1, Type: pb.MsgTransferLeader})
+ if lead.leadTransferee != 3 {
+ t.Fatalf("wait transferring, leadTransferee = %v, want %v", lead.leadTransferee, 3)
+ }
+
+ // Transfer leadership to another node.
+ nt.send(pb.Message{From: 2, To: 1, Type: pb.MsgTransferLeader})
+
+ checkLeaderTransferState(t, lead, StateFollower, 2)
+}
+
+// TestLeaderTransferSecondTransferToSameNode verifies second transfer leader request
+// to the same node should not extend the timeout while the first one is pending.
+func TestLeaderTransferSecondTransferToSameNode(t *testing.T) {
+ nt := newNetwork(nil, nil, nil)
+ nt.send(pb.Message{From: 1, To: 1, Type: pb.MsgHup})
+
+ nt.isolate(3)
+
+ lead := nt.peers[1].(*raft)
+
+ nt.send(pb.Message{From: 3, To: 1, Type: pb.MsgTransferLeader})
+ if lead.leadTransferee != 3 {
+ t.Fatalf("wait transferring, leadTransferee = %v, want %v", lead.leadTransferee, 3)
+ }
+
+ for i := 0; i < lead.heartbeatTimeout; i++ {
+ lead.tick()
+ }
+ // Second transfer leadership request to the same node.
+ nt.send(pb.Message{From: 3, To: 1, Type: pb.MsgTransferLeader})
+
+ for i := 0; i < lead.electionTimeout-lead.heartbeatTimeout; i++ {
+ lead.tick()
+ }
+
+ checkLeaderTransferState(t, lead, StateLeader, 1)
+}
+
+func checkLeaderTransferState(t *testing.T, r *raft, state StateType, lead uint64) {
+ if r.state != state || r.lead != lead {
+ t.Fatalf("after transferring, node has state %v lead %v, want state %v lead %v", r.state, r.lead, state, lead)
+ }
+ if r.leadTransferee != None {
+ t.Fatalf("after transferring, node has leadTransferee %v, want leadTransferee %v", r.leadTransferee, None)
+ }
+}
+
+// TestTransferNonMember verifies that when a MsgTimeoutNow arrives at
+// a node that has been removed from the group, nothing happens.
+// (previously, if the node also got votes, it would panic as it
+// transitioned to StateLeader)
+func TestTransferNonMember(t *testing.T) {
+ r := newTestRaft(1, []uint64{2, 3, 4}, 5, 1, NewMemoryStorage())
+ r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgTimeoutNow})
+
+ r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgVoteResp})
+ r.Step(pb.Message{From: 3, To: 1, Type: pb.MsgVoteResp})
+ if r.state != StateFollower {
+ t.Fatalf("state is %s, want StateFollower", r.state)
+ }
+}
+
+func entsWithConfig(configFunc func(*Config), terms ...uint64) *raft {
+ storage := NewMemoryStorage()
+ for i, term := range terms {
+ storage.Append([]pb.Entry{{Index: uint64(i + 1), Term: term}})
+ }
+ cfg := newTestConfig(1, []uint64{}, 5, 1, storage)
+ if configFunc != nil {
+ configFunc(cfg)
+ }
+ sm := newRaft(cfg)
+ sm.reset(terms[len(terms)-1])
+ return sm
+}
+
+// votedWithConfig creates a raft state machine with Vote and Term set
+// to the given value but no log entries (indicating that it voted in
+// the given term but has not received any logs).
+func votedWithConfig(configFunc func(*Config), vote, term uint64) *raft {
+ storage := NewMemoryStorage()
+ storage.SetHardState(pb.HardState{Vote: vote, Term: term})
+ cfg := newTestConfig(1, []uint64{}, 5, 1, storage)
+ if configFunc != nil {
+ configFunc(cfg)
+ }
+ sm := newRaft(cfg)
+ sm.reset(term)
+ return sm
+}
+
+type network struct {
+ peers map[uint64]stateMachine
+ storage map[uint64]*MemoryStorage
+ dropm map[connem]float64
+ ignorem map[pb.MessageType]bool
+}
+
+// newNetwork initializes a network from peers.
+// A nil node will be replaced with a new *stateMachine.
+// A *stateMachine will get its k, id.
+// When using stateMachine, the address list is always [1, n].
+func newNetwork(peers ...stateMachine) *network {
+ return newNetworkWithConfig(nil, peers...)
+}
+
+// newNetworkWithConfig is like newNetwork but calls the given func to
+// modify the configuration of any state machines it creates.
+func newNetworkWithConfig(configFunc func(*Config), peers ...stateMachine) *network {
+ size := len(peers)
+ peerAddrs := idsBySize(size)
+
+ npeers := make(map[uint64]stateMachine, size)
+ nstorage := make(map[uint64]*MemoryStorage, size)
+
+ for j, p := range peers {
+ id := peerAddrs[j]
+ switch v := p.(type) {
+ case nil:
+ nstorage[id] = NewMemoryStorage()
+ cfg := newTestConfig(id, peerAddrs, 10, 1, nstorage[id])
+ if configFunc != nil {
+ configFunc(cfg)
+ }
+ sm := newRaft(cfg)
+ npeers[id] = sm
+ case *raft:
+ v.id = id
+ v.prs = make(map[uint64]*Progress)
+ for i := 0; i < size; i++ {
+ v.prs[peerAddrs[i]] = &Progress{}
+ }
+ v.reset(v.Term)
+ npeers[id] = v
+ case *blackHole:
+ npeers[id] = v
+ default:
+ panic(fmt.Sprintf("unexpected state machine type: %T", p))
+ }
+ }
+ return &network{
+ peers: npeers,
+ storage: nstorage,
+ dropm: make(map[connem]float64),
+ ignorem: make(map[pb.MessageType]bool),
+ }
+}
+
+func preVoteConfig(c *Config) {
+ c.PreVote = true
+}
+
+func (nw *network) send(msgs ...pb.Message) {
+ for len(msgs) > 0 {
+ m := msgs[0]
+ p := nw.peers[m.To]
+ p.Step(m)
+ msgs = append(msgs[1:], nw.filter(p.readMessages())...)
+ }
+}
+
+func (nw *network) drop(from, to uint64, perc float64) {
+ nw.dropm[connem{from, to}] = perc
+}
+
+func (nw *network) cut(one, other uint64) {
+ nw.drop(one, other, 1)
+ nw.drop(other, one, 1)
+}
+
+func (nw *network) isolate(id uint64) {
+ for i := 0; i < len(nw.peers); i++ {
+ nid := uint64(i) + 1
+ if nid != id {
+ nw.drop(id, nid, 1.0)
+ nw.drop(nid, id, 1.0)
+ }
+ }
+}
+
+func (nw *network) ignore(t pb.MessageType) {
+ nw.ignorem[t] = true
+}
+
+func (nw *network) recover() {
+ nw.dropm = make(map[connem]float64)
+ nw.ignorem = make(map[pb.MessageType]bool)
+}
+
+func (nw *network) filter(msgs []pb.Message) []pb.Message {
+ mm := []pb.Message{}
+ for _, m := range msgs {
+ if nw.ignorem[m.Type] {
+ continue
+ }
+ switch m.Type {
+ case pb.MsgHup:
+ // hups never go over the network, so don't drop them but panic
+ panic("unexpected msgHup")
+ default:
+ perc := nw.dropm[connem{m.From, m.To}]
+ if n := rand.Float64(); n < perc {
+ continue
+ }
+ }
+ mm = append(mm, m)
+ }
+ return mm
+}
+
+type connem struct {
+ from, to uint64
+}
+
+type blackHole struct{}
+
+func (blackHole) Step(pb.Message) error { return nil }
+func (blackHole) readMessages() []pb.Message { return nil }
+
+var nopStepper = &blackHole{}
+
+func idsBySize(size int) []uint64 {
+ ids := make([]uint64, size)
+ for i := 0; i < size; i++ {
+ ids[i] = 1 + uint64(i)
+ }
+ return ids
+}
+
+// setRandomizedElectionTimeout set up the value by caller instead of choosing
+// by system, in some test scenario we need to fill in some expected value to
+// ensure the certainty
+func setRandomizedElectionTimeout(r *raft, v int) {
+ r.randomizedElectionTimeout = v
+}
+
+func newTestConfig(id uint64, peers []uint64, election, heartbeat int, storage Storage) *Config {
+ return &Config{
+ ID: id,
+ peers: peers,
+ ElectionTick: election,
+ HeartbeatTick: heartbeat,
+ Storage: storage,
+ MaxSizePerMsg: noLimit,
+ MaxInflightMsgs: 256,
+ }
+}
+
+func newTestRaft(id uint64, peers []uint64, election, heartbeat int, storage Storage) *raft {
+ return newRaft(newTestConfig(id, peers, election, heartbeat, storage))
+}
diff --git a/vendor/github.com/coreos/etcd/raft/raftpb/raft.pb.go b/vendor/github.com/coreos/etcd/raft/raftpb/raft.pb.go
new file mode 100644
index 00000000..3c45eef0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/raftpb/raft.pb.go
@@ -0,0 +1,1900 @@
+// Code generated by protoc-gen-gogo.
+// source: raft.proto
+// DO NOT EDIT!
+
+/*
+ Package raftpb is a generated protocol buffer package.
+
+ It is generated from these files:
+ raft.proto
+
+ It has these top-level messages:
+ Entry
+ SnapshotMetadata
+ Snapshot
+ Message
+ HardState
+ ConfState
+ ConfChange
+*/
+package raftpb
+
+import (
+ "fmt"
+
+ proto "github.com/golang/protobuf/proto"
+
+ math "math"
+
+ io "io"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+type EntryType int32
+
+const (
+ EntryNormal EntryType = 0
+ EntryConfChange EntryType = 1
+)
+
+var EntryType_name = map[int32]string{
+ 0: "EntryNormal",
+ 1: "EntryConfChange",
+}
+var EntryType_value = map[string]int32{
+ "EntryNormal": 0,
+ "EntryConfChange": 1,
+}
+
+func (x EntryType) Enum() *EntryType {
+ p := new(EntryType)
+ *p = x
+ return p
+}
+func (x EntryType) String() string {
+ return proto.EnumName(EntryType_name, int32(x))
+}
+func (x *EntryType) UnmarshalJSON(data []byte) error {
+ value, err := proto.UnmarshalJSONEnum(EntryType_value, data, "EntryType")
+ if err != nil {
+ return err
+ }
+ *x = EntryType(value)
+ return nil
+}
+func (EntryType) EnumDescriptor() ([]byte, []int) { return fileDescriptorRaft, []int{0} }
+
+type MessageType int32
+
+const (
+ MsgHup MessageType = 0
+ MsgBeat MessageType = 1
+ MsgProp MessageType = 2
+ MsgApp MessageType = 3
+ MsgAppResp MessageType = 4
+ MsgVote MessageType = 5
+ MsgVoteResp MessageType = 6
+ MsgSnap MessageType = 7
+ MsgHeartbeat MessageType = 8
+ MsgHeartbeatResp MessageType = 9
+ MsgUnreachable MessageType = 10
+ MsgSnapStatus MessageType = 11
+ MsgCheckQuorum MessageType = 12
+ MsgTransferLeader MessageType = 13
+ MsgTimeoutNow MessageType = 14
+ MsgReadIndex MessageType = 15
+ MsgReadIndexResp MessageType = 16
+ MsgPreVote MessageType = 17
+ MsgPreVoteResp MessageType = 18
+)
+
+var MessageType_name = map[int32]string{
+ 0: "MsgHup",
+ 1: "MsgBeat",
+ 2: "MsgProp",
+ 3: "MsgApp",
+ 4: "MsgAppResp",
+ 5: "MsgVote",
+ 6: "MsgVoteResp",
+ 7: "MsgSnap",
+ 8: "MsgHeartbeat",
+ 9: "MsgHeartbeatResp",
+ 10: "MsgUnreachable",
+ 11: "MsgSnapStatus",
+ 12: "MsgCheckQuorum",
+ 13: "MsgTransferLeader",
+ 14: "MsgTimeoutNow",
+ 15: "MsgReadIndex",
+ 16: "MsgReadIndexResp",
+ 17: "MsgPreVote",
+ 18: "MsgPreVoteResp",
+}
+var MessageType_value = map[string]int32{
+ "MsgHup": 0,
+ "MsgBeat": 1,
+ "MsgProp": 2,
+ "MsgApp": 3,
+ "MsgAppResp": 4,
+ "MsgVote": 5,
+ "MsgVoteResp": 6,
+ "MsgSnap": 7,
+ "MsgHeartbeat": 8,
+ "MsgHeartbeatResp": 9,
+ "MsgUnreachable": 10,
+ "MsgSnapStatus": 11,
+ "MsgCheckQuorum": 12,
+ "MsgTransferLeader": 13,
+ "MsgTimeoutNow": 14,
+ "MsgReadIndex": 15,
+ "MsgReadIndexResp": 16,
+ "MsgPreVote": 17,
+ "MsgPreVoteResp": 18,
+}
+
+func (x MessageType) Enum() *MessageType {
+ p := new(MessageType)
+ *p = x
+ return p
+}
+func (x MessageType) String() string {
+ return proto.EnumName(MessageType_name, int32(x))
+}
+func (x *MessageType) UnmarshalJSON(data []byte) error {
+ value, err := proto.UnmarshalJSONEnum(MessageType_value, data, "MessageType")
+ if err != nil {
+ return err
+ }
+ *x = MessageType(value)
+ return nil
+}
+func (MessageType) EnumDescriptor() ([]byte, []int) { return fileDescriptorRaft, []int{1} }
+
+type ConfChangeType int32
+
+const (
+ ConfChangeAddNode ConfChangeType = 0
+ ConfChangeRemoveNode ConfChangeType = 1
+ ConfChangeUpdateNode ConfChangeType = 2
+)
+
+var ConfChangeType_name = map[int32]string{
+ 0: "ConfChangeAddNode",
+ 1: "ConfChangeRemoveNode",
+ 2: "ConfChangeUpdateNode",
+}
+var ConfChangeType_value = map[string]int32{
+ "ConfChangeAddNode": 0,
+ "ConfChangeRemoveNode": 1,
+ "ConfChangeUpdateNode": 2,
+}
+
+func (x ConfChangeType) Enum() *ConfChangeType {
+ p := new(ConfChangeType)
+ *p = x
+ return p
+}
+func (x ConfChangeType) String() string {
+ return proto.EnumName(ConfChangeType_name, int32(x))
+}
+func (x *ConfChangeType) UnmarshalJSON(data []byte) error {
+ value, err := proto.UnmarshalJSONEnum(ConfChangeType_value, data, "ConfChangeType")
+ if err != nil {
+ return err
+ }
+ *x = ConfChangeType(value)
+ return nil
+}
+func (ConfChangeType) EnumDescriptor() ([]byte, []int) { return fileDescriptorRaft, []int{2} }
+
+type Entry struct {
+ Term uint64 `protobuf:"varint,2,opt,name=Term" json:"Term"`
+ Index uint64 `protobuf:"varint,3,opt,name=Index" json:"Index"`
+ Type EntryType `protobuf:"varint,1,opt,name=Type,enum=raftpb.EntryType" json:"Type"`
+ Data []byte `protobuf:"bytes,4,opt,name=Data" json:"Data,omitempty"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *Entry) Reset() { *m = Entry{} }
+func (m *Entry) String() string { return proto.CompactTextString(m) }
+func (*Entry) ProtoMessage() {}
+func (*Entry) Descriptor() ([]byte, []int) { return fileDescriptorRaft, []int{0} }
+
+type SnapshotMetadata struct {
+ ConfState ConfState `protobuf:"bytes,1,opt,name=conf_state,json=confState" json:"conf_state"`
+ Index uint64 `protobuf:"varint,2,opt,name=index" json:"index"`
+ Term uint64 `protobuf:"varint,3,opt,name=term" json:"term"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *SnapshotMetadata) Reset() { *m = SnapshotMetadata{} }
+func (m *SnapshotMetadata) String() string { return proto.CompactTextString(m) }
+func (*SnapshotMetadata) ProtoMessage() {}
+func (*SnapshotMetadata) Descriptor() ([]byte, []int) { return fileDescriptorRaft, []int{1} }
+
+type Snapshot struct {
+ Data []byte `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
+ Metadata SnapshotMetadata `protobuf:"bytes,2,opt,name=metadata" json:"metadata"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *Snapshot) Reset() { *m = Snapshot{} }
+func (m *Snapshot) String() string { return proto.CompactTextString(m) }
+func (*Snapshot) ProtoMessage() {}
+func (*Snapshot) Descriptor() ([]byte, []int) { return fileDescriptorRaft, []int{2} }
+
+type Message struct {
+ Type MessageType `protobuf:"varint,1,opt,name=type,enum=raftpb.MessageType" json:"type"`
+ To uint64 `protobuf:"varint,2,opt,name=to" json:"to"`
+ From uint64 `protobuf:"varint,3,opt,name=from" json:"from"`
+ Term uint64 `protobuf:"varint,4,opt,name=term" json:"term"`
+ LogTerm uint64 `protobuf:"varint,5,opt,name=logTerm" json:"logTerm"`
+ Index uint64 `protobuf:"varint,6,opt,name=index" json:"index"`
+ Entries []Entry `protobuf:"bytes,7,rep,name=entries" json:"entries"`
+ Commit uint64 `protobuf:"varint,8,opt,name=commit" json:"commit"`
+ Snapshot Snapshot `protobuf:"bytes,9,opt,name=snapshot" json:"snapshot"`
+ Reject bool `protobuf:"varint,10,opt,name=reject" json:"reject"`
+ RejectHint uint64 `protobuf:"varint,11,opt,name=rejectHint" json:"rejectHint"`
+ Context []byte `protobuf:"bytes,12,opt,name=context" json:"context,omitempty"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *Message) Reset() { *m = Message{} }
+func (m *Message) String() string { return proto.CompactTextString(m) }
+func (*Message) ProtoMessage() {}
+func (*Message) Descriptor() ([]byte, []int) { return fileDescriptorRaft, []int{3} }
+
+type HardState struct {
+ Term uint64 `protobuf:"varint,1,opt,name=term" json:"term"`
+ Vote uint64 `protobuf:"varint,2,opt,name=vote" json:"vote"`
+ Commit uint64 `protobuf:"varint,3,opt,name=commit" json:"commit"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *HardState) Reset() { *m = HardState{} }
+func (m *HardState) String() string { return proto.CompactTextString(m) }
+func (*HardState) ProtoMessage() {}
+func (*HardState) Descriptor() ([]byte, []int) { return fileDescriptorRaft, []int{4} }
+
+type ConfState struct {
+ Nodes []uint64 `protobuf:"varint,1,rep,name=nodes" json:"nodes,omitempty"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *ConfState) Reset() { *m = ConfState{} }
+func (m *ConfState) String() string { return proto.CompactTextString(m) }
+func (*ConfState) ProtoMessage() {}
+func (*ConfState) Descriptor() ([]byte, []int) { return fileDescriptorRaft, []int{5} }
+
+type ConfChange struct {
+ ID uint64 `protobuf:"varint,1,opt,name=ID" json:"ID"`
+ Type ConfChangeType `protobuf:"varint,2,opt,name=Type,enum=raftpb.ConfChangeType" json:"Type"`
+ NodeID uint64 `protobuf:"varint,3,opt,name=NodeID" json:"NodeID"`
+ Context []byte `protobuf:"bytes,4,opt,name=Context" json:"Context,omitempty"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *ConfChange) Reset() { *m = ConfChange{} }
+func (m *ConfChange) String() string { return proto.CompactTextString(m) }
+func (*ConfChange) ProtoMessage() {}
+func (*ConfChange) Descriptor() ([]byte, []int) { return fileDescriptorRaft, []int{6} }
+
+func init() {
+ proto.RegisterType((*Entry)(nil), "raftpb.Entry")
+ proto.RegisterType((*SnapshotMetadata)(nil), "raftpb.SnapshotMetadata")
+ proto.RegisterType((*Snapshot)(nil), "raftpb.Snapshot")
+ proto.RegisterType((*Message)(nil), "raftpb.Message")
+ proto.RegisterType((*HardState)(nil), "raftpb.HardState")
+ proto.RegisterType((*ConfState)(nil), "raftpb.ConfState")
+ proto.RegisterType((*ConfChange)(nil), "raftpb.ConfChange")
+ proto.RegisterEnum("raftpb.EntryType", EntryType_name, EntryType_value)
+ proto.RegisterEnum("raftpb.MessageType", MessageType_name, MessageType_value)
+ proto.RegisterEnum("raftpb.ConfChangeType", ConfChangeType_name, ConfChangeType_value)
+}
+func (m *Entry) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *Entry) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Type))
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Term))
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Index))
+ if m.Data != nil {
+ dAtA[i] = 0x22
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(len(m.Data)))
+ i += copy(dAtA[i:], m.Data)
+ }
+ if m.XXX_unrecognized != nil {
+ i += copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return i, nil
+}
+
+func (m *SnapshotMetadata) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *SnapshotMetadata) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.ConfState.Size()))
+ n1, err := m.ConfState.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n1
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Index))
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Term))
+ if m.XXX_unrecognized != nil {
+ i += copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return i, nil
+}
+
+func (m *Snapshot) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *Snapshot) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if m.Data != nil {
+ dAtA[i] = 0xa
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(len(m.Data)))
+ i += copy(dAtA[i:], m.Data)
+ }
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Metadata.Size()))
+ n2, err := m.Metadata.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n2
+ if m.XXX_unrecognized != nil {
+ i += copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return i, nil
+}
+
+func (m *Message) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *Message) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Type))
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.To))
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.From))
+ dAtA[i] = 0x20
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Term))
+ dAtA[i] = 0x28
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.LogTerm))
+ dAtA[i] = 0x30
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Index))
+ if len(m.Entries) > 0 {
+ for _, msg := range m.Entries {
+ dAtA[i] = 0x3a
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(msg.Size()))
+ n, err := msg.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n
+ }
+ }
+ dAtA[i] = 0x40
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Commit))
+ dAtA[i] = 0x4a
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Snapshot.Size()))
+ n3, err := m.Snapshot.MarshalTo(dAtA[i:])
+ if err != nil {
+ return 0, err
+ }
+ i += n3
+ dAtA[i] = 0x50
+ i++
+ if m.Reject {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i++
+ dAtA[i] = 0x58
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.RejectHint))
+ if m.Context != nil {
+ dAtA[i] = 0x62
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(len(m.Context)))
+ i += copy(dAtA[i:], m.Context)
+ }
+ if m.XXX_unrecognized != nil {
+ i += copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return i, nil
+}
+
+func (m *HardState) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *HardState) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Term))
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Vote))
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Commit))
+ if m.XXX_unrecognized != nil {
+ i += copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return i, nil
+}
+
+func (m *ConfState) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *ConfState) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ if len(m.Nodes) > 0 {
+ for _, num := range m.Nodes {
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(num))
+ }
+ }
+ if m.XXX_unrecognized != nil {
+ i += copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return i, nil
+}
+
+func (m *ConfChange) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *ConfChange) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.ID))
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.Type))
+ dAtA[i] = 0x18
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(m.NodeID))
+ if m.Context != nil {
+ dAtA[i] = 0x22
+ i++
+ i = encodeVarintRaft(dAtA, i, uint64(len(m.Context)))
+ i += copy(dAtA[i:], m.Context)
+ }
+ if m.XXX_unrecognized != nil {
+ i += copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return i, nil
+}
+
+func encodeFixed64Raft(dAtA []byte, offset int, v uint64) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ dAtA[offset+4] = uint8(v >> 32)
+ dAtA[offset+5] = uint8(v >> 40)
+ dAtA[offset+6] = uint8(v >> 48)
+ dAtA[offset+7] = uint8(v >> 56)
+ return offset + 8
+}
+func encodeFixed32Raft(dAtA []byte, offset int, v uint32) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ return offset + 4
+}
+func encodeVarintRaft(dAtA []byte, offset int, v uint64) int {
+ for v >= 1<<7 {
+ dAtA[offset] = uint8(v&0x7f | 0x80)
+ v >>= 7
+ offset++
+ }
+ dAtA[offset] = uint8(v)
+ return offset + 1
+}
+func (m *Entry) Size() (n int) {
+ var l int
+ _ = l
+ n += 1 + sovRaft(uint64(m.Type))
+ n += 1 + sovRaft(uint64(m.Term))
+ n += 1 + sovRaft(uint64(m.Index))
+ if m.Data != nil {
+ l = len(m.Data)
+ n += 1 + l + sovRaft(uint64(l))
+ }
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *SnapshotMetadata) Size() (n int) {
+ var l int
+ _ = l
+ l = m.ConfState.Size()
+ n += 1 + l + sovRaft(uint64(l))
+ n += 1 + sovRaft(uint64(m.Index))
+ n += 1 + sovRaft(uint64(m.Term))
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *Snapshot) Size() (n int) {
+ var l int
+ _ = l
+ if m.Data != nil {
+ l = len(m.Data)
+ n += 1 + l + sovRaft(uint64(l))
+ }
+ l = m.Metadata.Size()
+ n += 1 + l + sovRaft(uint64(l))
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *Message) Size() (n int) {
+ var l int
+ _ = l
+ n += 1 + sovRaft(uint64(m.Type))
+ n += 1 + sovRaft(uint64(m.To))
+ n += 1 + sovRaft(uint64(m.From))
+ n += 1 + sovRaft(uint64(m.Term))
+ n += 1 + sovRaft(uint64(m.LogTerm))
+ n += 1 + sovRaft(uint64(m.Index))
+ if len(m.Entries) > 0 {
+ for _, e := range m.Entries {
+ l = e.Size()
+ n += 1 + l + sovRaft(uint64(l))
+ }
+ }
+ n += 1 + sovRaft(uint64(m.Commit))
+ l = m.Snapshot.Size()
+ n += 1 + l + sovRaft(uint64(l))
+ n += 2
+ n += 1 + sovRaft(uint64(m.RejectHint))
+ if m.Context != nil {
+ l = len(m.Context)
+ n += 1 + l + sovRaft(uint64(l))
+ }
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *HardState) Size() (n int) {
+ var l int
+ _ = l
+ n += 1 + sovRaft(uint64(m.Term))
+ n += 1 + sovRaft(uint64(m.Vote))
+ n += 1 + sovRaft(uint64(m.Commit))
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *ConfState) Size() (n int) {
+ var l int
+ _ = l
+ if len(m.Nodes) > 0 {
+ for _, e := range m.Nodes {
+ n += 1 + sovRaft(uint64(e))
+ }
+ }
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *ConfChange) Size() (n int) {
+ var l int
+ _ = l
+ n += 1 + sovRaft(uint64(m.ID))
+ n += 1 + sovRaft(uint64(m.Type))
+ n += 1 + sovRaft(uint64(m.NodeID))
+ if m.Context != nil {
+ l = len(m.Context)
+ n += 1 + l + sovRaft(uint64(l))
+ }
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func sovRaft(x uint64) (n int) {
+ for {
+ n++
+ x >>= 7
+ if x == 0 {
+ break
+ }
+ }
+ return n
+}
+func sozRaft(x uint64) (n int) {
+ return sovRaft(uint64((x << 1) ^ uint64((int64(x) >> 63))))
+}
+func (m *Entry) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: Entry: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: Entry: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
+ }
+ m.Type = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Type |= (EntryType(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
+ }
+ m.Term = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Term |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
+ }
+ m.Index = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Index |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 4:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRaft
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
+ if m.Data == nil {
+ m.Data = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRaft(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRaft
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *SnapshotMetadata) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: SnapshotMetadata: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: SnapshotMetadata: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ConfState", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaft
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if err := m.ConfState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
+ }
+ m.Index = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Index |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
+ }
+ m.Term = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Term |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRaft(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRaft
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *Snapshot) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: Snapshot: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: Snapshot: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRaft
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
+ if m.Data == nil {
+ m.Data = []byte{}
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaft
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRaft(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRaft
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *Message) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: Message: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: Message: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
+ }
+ m.Type = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Type |= (MessageType(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field To", wireType)
+ }
+ m.To = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.To |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field From", wireType)
+ }
+ m.From = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.From |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 4:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
+ }
+ m.Term = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Term |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 5:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field LogTerm", wireType)
+ }
+ m.LogTerm = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.LogTerm |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 6:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
+ }
+ m.Index = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Index |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 7:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaft
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Entries = append(m.Entries, Entry{})
+ if err := m.Entries[len(m.Entries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 8:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Commit", wireType)
+ }
+ m.Commit = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Commit |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 9:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Snapshot", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthRaft
+ }
+ postIndex := iNdEx + msglen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if err := m.Snapshot.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 10:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Reject", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Reject = bool(v != 0)
+ case 11:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field RejectHint", wireType)
+ }
+ m.RejectHint = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.RejectHint |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 12:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRaft
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Context = append(m.Context[:0], dAtA[iNdEx:postIndex]...)
+ if m.Context == nil {
+ m.Context = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRaft(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRaft
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *HardState) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: HardState: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: HardState: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
+ }
+ m.Term = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Term |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Vote", wireType)
+ }
+ m.Vote = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Vote |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Commit", wireType)
+ }
+ m.Commit = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Commit |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRaft(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRaft
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *ConfState) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: ConfState: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: ConfState: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Nodes", wireType)
+ }
+ var v uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Nodes = append(m.Nodes, v)
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRaft(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRaft
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *ConfChange) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: ConfChange: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: ConfChange: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
+ }
+ m.ID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ID |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
+ }
+ m.Type = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Type |= (ConfChangeType(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field NodeID", wireType)
+ }
+ m.NodeID = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.NodeID |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 4:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRaft
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Context = append(m.Context[:0], dAtA[iNdEx:postIndex]...)
+ if m.Context == nil {
+ m.Context = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRaft(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRaft
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func skipRaft(dAtA []byte) (n int, err error) {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ wireType := int(wire & 0x7)
+ switch wireType {
+ case 0:
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ iNdEx++
+ if dAtA[iNdEx-1] < 0x80 {
+ break
+ }
+ }
+ return iNdEx, nil
+ case 1:
+ iNdEx += 8
+ return iNdEx, nil
+ case 2:
+ var length int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ length |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ iNdEx += length
+ if length < 0 {
+ return 0, ErrInvalidLengthRaft
+ }
+ return iNdEx, nil
+ case 3:
+ for {
+ var innerWire uint64
+ var start int = iNdEx
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRaft
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ innerWire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ innerWireType := int(innerWire & 0x7)
+ if innerWireType == 4 {
+ break
+ }
+ next, err := skipRaft(dAtA[start:])
+ if err != nil {
+ return 0, err
+ }
+ iNdEx = start + next
+ }
+ return iNdEx, nil
+ case 4:
+ return iNdEx, nil
+ case 5:
+ iNdEx += 4
+ return iNdEx, nil
+ default:
+ return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
+ }
+ }
+ panic("unreachable")
+}
+
+var (
+ ErrInvalidLengthRaft = fmt.Errorf("proto: negative length found during unmarshaling")
+ ErrIntOverflowRaft = fmt.Errorf("proto: integer overflow")
+)
+
+func init() { proto.RegisterFile("raft.proto", fileDescriptorRaft) }
+
+var fileDescriptorRaft = []byte{
+ // 790 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x54, 0xcd, 0x6e, 0xdb, 0x46,
+ 0x10, 0x16, 0x29, 0xea, 0x6f, 0x28, 0xcb, 0xab, 0xb5, 0x5a, 0x2c, 0x0c, 0x43, 0x55, 0x85, 0x1e,
+ 0x04, 0x17, 0x76, 0x5b, 0x1d, 0x7a, 0xe8, 0xcd, 0x96, 0x0a, 0x58, 0x40, 0x65, 0xb8, 0xb2, 0xdc,
+ 0x43, 0x83, 0x20, 0x58, 0x8b, 0x2b, 0x4a, 0x89, 0xc9, 0x25, 0x96, 0x2b, 0xc7, 0xbe, 0x04, 0x79,
+ 0x80, 0x3c, 0x40, 0x2e, 0x79, 0x1f, 0x1f, 0x0d, 0xe4, 0x1e, 0xc4, 0xce, 0x8b, 0x04, 0xbb, 0x5c,
+ 0x4a, 0x94, 0x74, 0xdb, 0xf9, 0xbe, 0xe1, 0xcc, 0x37, 0xdf, 0xce, 0x12, 0x40, 0xd0, 0xa9, 0x3c,
+ 0x8e, 0x04, 0x97, 0x1c, 0x17, 0xd5, 0x39, 0xba, 0xde, 0x6f, 0xf8, 0xdc, 0xe7, 0x1a, 0xfa, 0x4d,
+ 0x9d, 0x12, 0xb6, 0xfd, 0x0e, 0x0a, 0x7f, 0x87, 0x52, 0xdc, 0xe3, 0x5f, 0xc1, 0x19, 0xdf, 0x47,
+ 0x8c, 0x58, 0x2d, 0xab, 0x53, 0xeb, 0xd6, 0x8f, 0x93, 0xaf, 0x8e, 0x35, 0xa9, 0x88, 0x53, 0xe7,
+ 0xe1, 0xcb, 0x4f, 0xb9, 0x91, 0x4e, 0xc2, 0x04, 0x9c, 0x31, 0x13, 0x01, 0xb1, 0x5b, 0x56, 0xc7,
+ 0x59, 0x32, 0x4c, 0x04, 0x78, 0x1f, 0x0a, 0x83, 0xd0, 0x63, 0x77, 0x24, 0x9f, 0xa1, 0x12, 0x08,
+ 0x63, 0x70, 0xfa, 0x54, 0x52, 0xe2, 0xb4, 0xac, 0x4e, 0x75, 0xa4, 0xcf, 0xed, 0xf7, 0x16, 0xa0,
+ 0xcb, 0x90, 0x46, 0xf1, 0x8c, 0xcb, 0x21, 0x93, 0xd4, 0xa3, 0x92, 0xe2, 0x3f, 0x01, 0x26, 0x3c,
+ 0x9c, 0xbe, 0x8a, 0x25, 0x95, 0x89, 0x22, 0x77, 0xa5, 0xa8, 0xc7, 0xc3, 0xe9, 0xa5, 0x22, 0x4c,
+ 0xf1, 0xca, 0x24, 0x05, 0x54, 0xf3, 0xb9, 0x6e, 0x9e, 0xd5, 0x95, 0x40, 0x4a, 0xb2, 0x54, 0x92,
+ 0xb3, 0xba, 0x34, 0xd2, 0xfe, 0x1f, 0xca, 0xa9, 0x02, 0x25, 0x51, 0x29, 0xd0, 0x3d, 0xab, 0x23,
+ 0x7d, 0xc6, 0x7f, 0x41, 0x39, 0x30, 0xca, 0x74, 0x61, 0xb7, 0x4b, 0x52, 0x2d, 0x9b, 0xca, 0x4d,
+ 0xdd, 0x65, 0x7e, 0xfb, 0x53, 0x1e, 0x4a, 0x43, 0x16, 0xc7, 0xd4, 0x67, 0xf8, 0x08, 0x1c, 0xb9,
+ 0x72, 0x78, 0x2f, 0xad, 0x61, 0xe8, 0xac, 0xc7, 0x2a, 0x0d, 0x37, 0xc0, 0x96, 0x7c, 0x6d, 0x12,
+ 0x5b, 0x72, 0x35, 0xc6, 0x54, 0xf0, 0x8d, 0x31, 0x14, 0xb2, 0x1c, 0xd0, 0xd9, 0x1c, 0x10, 0x37,
+ 0xa1, 0x74, 0xc3, 0x7d, 0x7d, 0x61, 0x85, 0x0c, 0x99, 0x82, 0x2b, 0xdb, 0x8a, 0xdb, 0xb6, 0x1d,
+ 0x41, 0x89, 0x85, 0x52, 0xcc, 0x59, 0x4c, 0x4a, 0xad, 0x7c, 0xc7, 0xed, 0xee, 0xac, 0x6d, 0x46,
+ 0x5a, 0xca, 0xe4, 0xe0, 0x03, 0x28, 0x4e, 0x78, 0x10, 0xcc, 0x25, 0x29, 0x67, 0x6a, 0x19, 0x0c,
+ 0x77, 0xa1, 0x1c, 0x1b, 0xc7, 0x48, 0x45, 0x3b, 0x89, 0x36, 0x9d, 0x4c, 0x1d, 0x4c, 0xf3, 0x54,
+ 0x45, 0xc1, 0x5e, 0xb3, 0x89, 0x24, 0xd0, 0xb2, 0x3a, 0xe5, 0xb4, 0x62, 0x82, 0xe1, 0x5f, 0x00,
+ 0x92, 0xd3, 0xd9, 0x3c, 0x94, 0xc4, 0xcd, 0xf4, 0xcc, 0xe0, 0x98, 0x40, 0x69, 0xc2, 0x43, 0xc9,
+ 0xee, 0x24, 0xa9, 0xea, 0x8b, 0x4d, 0xc3, 0xf6, 0x4b, 0xa8, 0x9c, 0x51, 0xe1, 0x25, 0xeb, 0x93,
+ 0x3a, 0x68, 0x6d, 0x39, 0x48, 0xc0, 0xb9, 0xe5, 0x92, 0xad, 0xef, 0xbb, 0x42, 0x32, 0x03, 0xe7,
+ 0xb7, 0x07, 0x6e, 0xff, 0x0c, 0x95, 0xe5, 0xba, 0xe2, 0x06, 0x14, 0x42, 0xee, 0xb1, 0x98, 0x58,
+ 0xad, 0x7c, 0xc7, 0x19, 0x25, 0x41, 0xfb, 0x83, 0x05, 0xa0, 0x72, 0x7a, 0x33, 0x1a, 0xfa, 0xfa,
+ 0xd6, 0x07, 0xfd, 0x35, 0x05, 0xf6, 0xa0, 0x8f, 0x7f, 0x37, 0x8f, 0xd3, 0xd6, 0xab, 0xf3, 0x63,
+ 0xf6, 0x29, 0x24, 0xdf, 0x6d, 0xbd, 0xd0, 0x03, 0x28, 0x9e, 0x73, 0x8f, 0x0d, 0xfa, 0xeb, 0xba,
+ 0x12, 0x4c, 0x19, 0xd2, 0x33, 0x86, 0x24, 0x8f, 0x31, 0x0d, 0x0f, 0xff, 0x80, 0xca, 0xf2, 0xc9,
+ 0xe3, 0x5d, 0x70, 0x75, 0x70, 0xce, 0x45, 0x40, 0x6f, 0x50, 0x0e, 0xef, 0xc1, 0xae, 0x06, 0x56,
+ 0x8d, 0x91, 0x75, 0xf8, 0xd9, 0x06, 0x37, 0xb3, 0xc4, 0x18, 0xa0, 0x38, 0x8c, 0xfd, 0xb3, 0x45,
+ 0x84, 0x72, 0xd8, 0x85, 0xd2, 0x30, 0xf6, 0x4f, 0x19, 0x95, 0xc8, 0x32, 0xc1, 0x85, 0xe0, 0x11,
+ 0xb2, 0x4d, 0xd6, 0x49, 0x14, 0xa1, 0x3c, 0xae, 0x01, 0x24, 0xe7, 0x11, 0x8b, 0x23, 0xe4, 0x98,
+ 0xc4, 0xff, 0xb8, 0x64, 0xa8, 0xa0, 0x44, 0x98, 0x40, 0xb3, 0x45, 0xc3, 0xaa, 0x85, 0x41, 0x25,
+ 0x8c, 0xa0, 0xaa, 0x9a, 0x31, 0x2a, 0xe4, 0xb5, 0xea, 0x52, 0xc6, 0x0d, 0x40, 0x59, 0x44, 0x7f,
+ 0x54, 0xc1, 0x18, 0x6a, 0xc3, 0xd8, 0xbf, 0x0a, 0x05, 0xa3, 0x93, 0x19, 0xbd, 0xbe, 0x61, 0x08,
+ 0x70, 0x1d, 0x76, 0x4c, 0x21, 0x75, 0x41, 0x8b, 0x18, 0xb9, 0x26, 0xad, 0x37, 0x63, 0x93, 0x37,
+ 0xff, 0x2e, 0xb8, 0x58, 0x04, 0xa8, 0x8a, 0x7f, 0x80, 0xfa, 0x30, 0xf6, 0xc7, 0x82, 0x86, 0xf1,
+ 0x94, 0x89, 0x7f, 0x18, 0xf5, 0x98, 0x40, 0x3b, 0xe6, 0xeb, 0xf1, 0x3c, 0x60, 0x7c, 0x21, 0xcf,
+ 0xf9, 0x5b, 0x54, 0x33, 0x62, 0x46, 0x8c, 0x7a, 0xfa, 0x87, 0x87, 0x76, 0x8d, 0x98, 0x25, 0xa2,
+ 0xc5, 0x20, 0x33, 0xef, 0x85, 0x60, 0x7a, 0xc4, 0xba, 0xe9, 0x6a, 0x62, 0x9d, 0x83, 0x0f, 0x5f,
+ 0x40, 0x6d, 0xfd, 0x7a, 0x95, 0x8e, 0x15, 0x72, 0xe2, 0x79, 0xea, 0x2e, 0x51, 0x0e, 0x13, 0x68,
+ 0xac, 0xe0, 0x11, 0x0b, 0xf8, 0x2d, 0xd3, 0x8c, 0xb5, 0xce, 0x5c, 0x45, 0x1e, 0x95, 0x09, 0x63,
+ 0x9f, 0x92, 0x87, 0xa7, 0x66, 0xee, 0xf1, 0xa9, 0x99, 0x7b, 0x78, 0x6e, 0x5a, 0x8f, 0xcf, 0x4d,
+ 0xeb, 0xeb, 0x73, 0xd3, 0xfa, 0xf8, 0xad, 0x99, 0xfb, 0x1e, 0x00, 0x00, 0xff, 0xff, 0xcf, 0x30,
+ 0x01, 0x41, 0x3a, 0x06, 0x00, 0x00,
+}
diff --git a/vendor/github.com/coreos/etcd/raft/raftpb/raft.proto b/vendor/github.com/coreos/etcd/raft/raftpb/raft.proto
new file mode 100644
index 00000000..806a4363
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/raftpb/raft.proto
@@ -0,0 +1,93 @@
+syntax = "proto2";
+package raftpb;
+
+import "gogoproto/gogo.proto";
+
+option (gogoproto.marshaler_all) = true;
+option (gogoproto.sizer_all) = true;
+option (gogoproto.unmarshaler_all) = true;
+option (gogoproto.goproto_getters_all) = false;
+option (gogoproto.goproto_enum_prefix_all) = false;
+
+enum EntryType {
+ EntryNormal = 0;
+ EntryConfChange = 1;
+}
+
+message Entry {
+ optional uint64 Term = 2 [(gogoproto.nullable) = false]; // must be 64-bit aligned for atomic operations
+ optional uint64 Index = 3 [(gogoproto.nullable) = false]; // must be 64-bit aligned for atomic operations
+ optional EntryType Type = 1 [(gogoproto.nullable) = false];
+ optional bytes Data = 4;
+}
+
+message SnapshotMetadata {
+ optional ConfState conf_state = 1 [(gogoproto.nullable) = false];
+ optional uint64 index = 2 [(gogoproto.nullable) = false];
+ optional uint64 term = 3 [(gogoproto.nullable) = false];
+}
+
+message Snapshot {
+ optional bytes data = 1;
+ optional SnapshotMetadata metadata = 2 [(gogoproto.nullable) = false];
+}
+
+enum MessageType {
+ MsgHup = 0;
+ MsgBeat = 1;
+ MsgProp = 2;
+ MsgApp = 3;
+ MsgAppResp = 4;
+ MsgVote = 5;
+ MsgVoteResp = 6;
+ MsgSnap = 7;
+ MsgHeartbeat = 8;
+ MsgHeartbeatResp = 9;
+ MsgUnreachable = 10;
+ MsgSnapStatus = 11;
+ MsgCheckQuorum = 12;
+ MsgTransferLeader = 13;
+ MsgTimeoutNow = 14;
+ MsgReadIndex = 15;
+ MsgReadIndexResp = 16;
+ MsgPreVote = 17;
+ MsgPreVoteResp = 18;
+}
+
+message Message {
+ optional MessageType type = 1 [(gogoproto.nullable) = false];
+ optional uint64 to = 2 [(gogoproto.nullable) = false];
+ optional uint64 from = 3 [(gogoproto.nullable) = false];
+ optional uint64 term = 4 [(gogoproto.nullable) = false];
+ optional uint64 logTerm = 5 [(gogoproto.nullable) = false];
+ optional uint64 index = 6 [(gogoproto.nullable) = false];
+ repeated Entry entries = 7 [(gogoproto.nullable) = false];
+ optional uint64 commit = 8 [(gogoproto.nullable) = false];
+ optional Snapshot snapshot = 9 [(gogoproto.nullable) = false];
+ optional bool reject = 10 [(gogoproto.nullable) = false];
+ optional uint64 rejectHint = 11 [(gogoproto.nullable) = false];
+ optional bytes context = 12;
+}
+
+message HardState {
+ optional uint64 term = 1 [(gogoproto.nullable) = false];
+ optional uint64 vote = 2 [(gogoproto.nullable) = false];
+ optional uint64 commit = 3 [(gogoproto.nullable) = false];
+}
+
+message ConfState {
+ repeated uint64 nodes = 1;
+}
+
+enum ConfChangeType {
+ ConfChangeAddNode = 0;
+ ConfChangeRemoveNode = 1;
+ ConfChangeUpdateNode = 2;
+}
+
+message ConfChange {
+ optional uint64 ID = 1 [(gogoproto.nullable) = false];
+ optional ConfChangeType Type = 2 [(gogoproto.nullable) = false];
+ optional uint64 NodeID = 3 [(gogoproto.nullable) = false];
+ optional bytes Context = 4;
+}
diff --git a/vendor/github.com/coreos/etcd/raft/rafttest/doc.go b/vendor/github.com/coreos/etcd/raft/rafttest/doc.go
new file mode 100644
index 00000000..bba9a1a3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/rafttest/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafttest provides functional tests for etcd's raft implementation.
+package rafttest
diff --git a/vendor/github.com/coreos/etcd/raft/rafttest/network.go b/vendor/github.com/coreos/etcd/raft/rafttest/network.go
new file mode 100644
index 00000000..d10530e8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/rafttest/network.go
@@ -0,0 +1,183 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafttest
+
+import (
+ "math/rand"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+// a network interface
+type iface interface {
+ send(m raftpb.Message)
+ recv() chan raftpb.Message
+ disconnect()
+ connect()
+}
+
+// a network
+type network interface {
+ // drop message at given rate (1.0 drops all messages)
+ drop(from, to uint64, rate float64)
+ // delay message for (0, d] randomly at given rate (1.0 delay all messages)
+ // do we need rate here?
+ delay(from, to uint64, d time.Duration, rate float64)
+ disconnect(id uint64)
+ connect(id uint64)
+ // heal heals the network
+ heal()
+}
+
+type raftNetwork struct {
+ mu sync.Mutex
+ disconnected map[uint64]bool
+ dropmap map[conn]float64
+ delaymap map[conn]delay
+ recvQueues map[uint64]chan raftpb.Message
+}
+
+type conn struct {
+ from, to uint64
+}
+
+type delay struct {
+ d time.Duration
+ rate float64
+}
+
+func newRaftNetwork(nodes ...uint64) *raftNetwork {
+ pn := &raftNetwork{
+ recvQueues: make(map[uint64]chan raftpb.Message),
+ dropmap: make(map[conn]float64),
+ delaymap: make(map[conn]delay),
+ disconnected: make(map[uint64]bool),
+ }
+
+ for _, n := range nodes {
+ pn.recvQueues[n] = make(chan raftpb.Message, 1024)
+ }
+ return pn
+}
+
+func (rn *raftNetwork) nodeNetwork(id uint64) iface {
+ return &nodeNetwork{id: id, raftNetwork: rn}
+}
+
+func (rn *raftNetwork) send(m raftpb.Message) {
+ rn.mu.Lock()
+ to := rn.recvQueues[m.To]
+ if rn.disconnected[m.To] {
+ to = nil
+ }
+ drop := rn.dropmap[conn{m.From, m.To}]
+ dl := rn.delaymap[conn{m.From, m.To}]
+ rn.mu.Unlock()
+
+ if to == nil {
+ return
+ }
+ if drop != 0 && rand.Float64() < drop {
+ return
+ }
+ // TODO: shall we dl without blocking the send call?
+ if dl.d != 0 && rand.Float64() < dl.rate {
+ rd := rand.Int63n(int64(dl.d))
+ time.Sleep(time.Duration(rd))
+ }
+
+ // use marshal/unmarshal to copy message to avoid data race.
+ b, err := m.Marshal()
+ if err != nil {
+ panic(err)
+ }
+
+ var cm raftpb.Message
+ err = cm.Unmarshal(b)
+ if err != nil {
+ panic(err)
+ }
+
+ select {
+ case to <- cm:
+ default:
+ // drop messages when the receiver queue is full.
+ }
+}
+
+func (rn *raftNetwork) recvFrom(from uint64) chan raftpb.Message {
+ rn.mu.Lock()
+ fromc := rn.recvQueues[from]
+ if rn.disconnected[from] {
+ fromc = nil
+ }
+ rn.mu.Unlock()
+
+ return fromc
+}
+
+func (rn *raftNetwork) drop(from, to uint64, rate float64) {
+ rn.mu.Lock()
+ defer rn.mu.Unlock()
+ rn.dropmap[conn{from, to}] = rate
+}
+
+func (rn *raftNetwork) delay(from, to uint64, d time.Duration, rate float64) {
+ rn.mu.Lock()
+ defer rn.mu.Unlock()
+ rn.delaymap[conn{from, to}] = delay{d, rate}
+}
+
+func (rn *raftNetwork) heal() {
+ rn.mu.Lock()
+ defer rn.mu.Unlock()
+ rn.dropmap = make(map[conn]float64)
+ rn.delaymap = make(map[conn]delay)
+}
+
+func (rn *raftNetwork) disconnect(id uint64) {
+ rn.mu.Lock()
+ defer rn.mu.Unlock()
+ rn.disconnected[id] = true
+}
+
+func (rn *raftNetwork) connect(id uint64) {
+ rn.mu.Lock()
+ defer rn.mu.Unlock()
+ rn.disconnected[id] = false
+}
+
+type nodeNetwork struct {
+ id uint64
+ *raftNetwork
+}
+
+func (nt *nodeNetwork) connect() {
+ nt.raftNetwork.connect(nt.id)
+}
+
+func (nt *nodeNetwork) disconnect() {
+ nt.raftNetwork.disconnect(nt.id)
+}
+
+func (nt *nodeNetwork) send(m raftpb.Message) {
+ nt.raftNetwork.send(m)
+}
+
+func (nt *nodeNetwork) recv() chan raftpb.Message {
+ return nt.recvFrom(nt.id)
+}
diff --git a/vendor/github.com/coreos/etcd/raft/rafttest/network_test.go b/vendor/github.com/coreos/etcd/raft/rafttest/network_test.go
new file mode 100644
index 00000000..52cde439
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/rafttest/network_test.go
@@ -0,0 +1,72 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafttest
+
+import (
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+func TestNetworkDrop(t *testing.T) {
+ // drop around 10% messages
+ sent := 1000
+ droprate := 0.1
+ nt := newRaftNetwork(1, 2)
+ nt.drop(1, 2, droprate)
+ for i := 0; i < sent; i++ {
+ nt.send(raftpb.Message{From: 1, To: 2})
+ }
+
+ c := nt.recvFrom(2)
+
+ received := 0
+ done := false
+ for !done {
+ select {
+ case <-c:
+ received++
+ default:
+ done = true
+ }
+ }
+
+ drop := sent - received
+ if drop > int((droprate+0.1)*float64(sent)) || drop < int((droprate-0.1)*float64(sent)) {
+ t.Errorf("drop = %d, want around %.2f", drop, droprate*float64(sent))
+ }
+}
+
+func TestNetworkDelay(t *testing.T) {
+ sent := 1000
+ delay := time.Millisecond
+ delayrate := 0.1
+ nt := newRaftNetwork(1, 2)
+
+ nt.delay(1, 2, delay, delayrate)
+ var total time.Duration
+ for i := 0; i < sent; i++ {
+ s := time.Now()
+ nt.send(raftpb.Message{From: 1, To: 2})
+ total += time.Since(s)
+ }
+
+ w := time.Duration(float64(sent)*delayrate/2) * delay
+ // there is some overhead in the send call since it generates random numbers.
+ if total < w {
+ t.Errorf("total = %v, want > %v", total, w)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/raft/rafttest/node.go b/vendor/github.com/coreos/etcd/raft/rafttest/node.go
new file mode 100644
index 00000000..a37a1683
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/rafttest/node.go
@@ -0,0 +1,150 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafttest
+
+import (
+ "log"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+ "golang.org/x/net/context"
+)
+
+type node struct {
+ raft.Node
+ id uint64
+ iface iface
+ stopc chan struct{}
+ pausec chan bool
+
+ // stable
+ storage *raft.MemoryStorage
+
+ mu sync.Mutex // guards state
+ state raftpb.HardState
+}
+
+func startNode(id uint64, peers []raft.Peer, iface iface) *node {
+ st := raft.NewMemoryStorage()
+ c := &raft.Config{
+ ID: id,
+ ElectionTick: 10,
+ HeartbeatTick: 1,
+ Storage: st,
+ MaxSizePerMsg: 1024 * 1024,
+ MaxInflightMsgs: 256,
+ }
+ rn := raft.StartNode(c, peers)
+ n := &node{
+ Node: rn,
+ id: id,
+ storage: st,
+ iface: iface,
+ pausec: make(chan bool),
+ }
+ n.start()
+ return n
+}
+
+func (n *node) start() {
+ n.stopc = make(chan struct{})
+ ticker := time.Tick(5 * time.Millisecond)
+
+ go func() {
+ for {
+ select {
+ case <-ticker:
+ n.Tick()
+ case rd := <-n.Ready():
+ if !raft.IsEmptyHardState(rd.HardState) {
+ n.mu.Lock()
+ n.state = rd.HardState
+ n.mu.Unlock()
+ n.storage.SetHardState(n.state)
+ }
+ n.storage.Append(rd.Entries)
+ time.Sleep(time.Millisecond)
+ // TODO: make send async, more like real world...
+ for _, m := range rd.Messages {
+ n.iface.send(m)
+ }
+ n.Advance()
+ case m := <-n.iface.recv():
+ go n.Step(context.TODO(), m)
+ case <-n.stopc:
+ n.Stop()
+ log.Printf("raft.%d: stop", n.id)
+ n.Node = nil
+ close(n.stopc)
+ return
+ case p := <-n.pausec:
+ recvms := make([]raftpb.Message, 0)
+ for p {
+ select {
+ case m := <-n.iface.recv():
+ recvms = append(recvms, m)
+ case p = <-n.pausec:
+ }
+ }
+ // step all pending messages
+ for _, m := range recvms {
+ n.Step(context.TODO(), m)
+ }
+ }
+ }
+ }()
+}
+
+// stop stops the node. stop a stopped node might panic.
+// All in memory state of node is discarded.
+// All stable MUST be unchanged.
+func (n *node) stop() {
+ n.iface.disconnect()
+ n.stopc <- struct{}{}
+ // wait for the shutdown
+ <-n.stopc
+}
+
+// restart restarts the node. restart a started node
+// blocks and might affect the future stop operation.
+func (n *node) restart() {
+ // wait for the shutdown
+ <-n.stopc
+ c := &raft.Config{
+ ID: n.id,
+ ElectionTick: 10,
+ HeartbeatTick: 1,
+ Storage: n.storage,
+ MaxSizePerMsg: 1024 * 1024,
+ MaxInflightMsgs: 256,
+ }
+ n.Node = raft.RestartNode(c)
+ n.start()
+ n.iface.connect()
+}
+
+// pause pauses the node.
+// The paused node buffers the received messages and replies
+// all of them when it resumes.
+func (n *node) pause() {
+ n.pausec <- true
+}
+
+// resume resumes the paused node.
+func (n *node) resume() {
+ n.pausec <- false
+}
diff --git a/vendor/github.com/coreos/etcd/raft/rafttest/node_bench_test.go b/vendor/github.com/coreos/etcd/raft/rafttest/node_bench_test.go
new file mode 100644
index 00000000..1aa13c7b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/rafttest/node_bench_test.go
@@ -0,0 +1,53 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafttest
+
+import (
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/raft"
+ "golang.org/x/net/context"
+)
+
+func BenchmarkProposal3Nodes(b *testing.B) {
+ peers := []raft.Peer{{1, nil}, {2, nil}, {3, nil}}
+ nt := newRaftNetwork(1, 2, 3)
+
+ nodes := make([]*node, 0)
+
+ for i := 1; i <= 3; i++ {
+ n := startNode(uint64(i), peers, nt.nodeNetwork(uint64(i)))
+ nodes = append(nodes, n)
+ }
+ // get ready and warm up
+ time.Sleep(50 * time.Millisecond)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ nodes[0].Propose(context.TODO(), []byte("somedata"))
+ }
+
+ for _, n := range nodes {
+ if n.state.Commit != uint64(b.N+4) {
+ continue
+ }
+ }
+ b.StopTimer()
+
+ for _, n := range nodes {
+ n.stop()
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/raft/rafttest/node_test.go b/vendor/github.com/coreos/etcd/raft/rafttest/node_test.go
new file mode 100644
index 00000000..c4f98de2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/rafttest/node_test.go
@@ -0,0 +1,175 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafttest
+
+import (
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/raft"
+ "golang.org/x/net/context"
+)
+
+func TestBasicProgress(t *testing.T) {
+ peers := []raft.Peer{{1, nil}, {2, nil}, {3, nil}, {4, nil}, {5, nil}}
+ nt := newRaftNetwork(1, 2, 3, 4, 5)
+
+ nodes := make([]*node, 0)
+
+ for i := 1; i <= 5; i++ {
+ n := startNode(uint64(i), peers, nt.nodeNetwork(uint64(i)))
+ nodes = append(nodes, n)
+ }
+
+ waitLeader(nodes)
+
+ for i := 0; i < 100; i++ {
+ nodes[0].Propose(context.TODO(), []byte("somedata"))
+ }
+
+ if !waitCommitConverge(nodes, 100) {
+ t.Errorf("commits failed to converge!")
+ }
+
+ for _, n := range nodes {
+ n.stop()
+ }
+}
+
+func TestRestart(t *testing.T) {
+ peers := []raft.Peer{{1, nil}, {2, nil}, {3, nil}, {4, nil}, {5, nil}}
+ nt := newRaftNetwork(1, 2, 3, 4, 5)
+
+ nodes := make([]*node, 0)
+
+ for i := 1; i <= 5; i++ {
+ n := startNode(uint64(i), peers, nt.nodeNetwork(uint64(i)))
+ nodes = append(nodes, n)
+ }
+
+ l := waitLeader(nodes)
+ k1, k2 := (l+1)%5, (l+2)%5
+
+ for i := 0; i < 30; i++ {
+ nodes[l].Propose(context.TODO(), []byte("somedata"))
+ }
+ nodes[k1].stop()
+ for i := 0; i < 30; i++ {
+ nodes[(l+3)%5].Propose(context.TODO(), []byte("somedata"))
+ }
+ nodes[k2].stop()
+ for i := 0; i < 30; i++ {
+ nodes[(l+4)%5].Propose(context.TODO(), []byte("somedata"))
+ }
+ nodes[k2].restart()
+ for i := 0; i < 30; i++ {
+ nodes[l].Propose(context.TODO(), []byte("somedata"))
+ }
+ nodes[k1].restart()
+
+ if !waitCommitConverge(nodes, 120) {
+ t.Errorf("commits failed to converge!")
+ }
+
+ for _, n := range nodes {
+ n.stop()
+ }
+}
+
+func TestPause(t *testing.T) {
+ peers := []raft.Peer{{1, nil}, {2, nil}, {3, nil}, {4, nil}, {5, nil}}
+ nt := newRaftNetwork(1, 2, 3, 4, 5)
+
+ nodes := make([]*node, 0)
+
+ for i := 1; i <= 5; i++ {
+ n := startNode(uint64(i), peers, nt.nodeNetwork(uint64(i)))
+ nodes = append(nodes, n)
+ }
+
+ waitLeader(nodes)
+
+ for i := 0; i < 30; i++ {
+ nodes[0].Propose(context.TODO(), []byte("somedata"))
+ }
+ nodes[1].pause()
+ for i := 0; i < 30; i++ {
+ nodes[0].Propose(context.TODO(), []byte("somedata"))
+ }
+ nodes[2].pause()
+ for i := 0; i < 30; i++ {
+ nodes[0].Propose(context.TODO(), []byte("somedata"))
+ }
+ nodes[2].resume()
+ for i := 0; i < 30; i++ {
+ nodes[0].Propose(context.TODO(), []byte("somedata"))
+ }
+ nodes[1].resume()
+
+ if !waitCommitConverge(nodes, 120) {
+ t.Errorf("commits failed to converge!")
+ }
+
+ for _, n := range nodes {
+ n.stop()
+ }
+}
+
+func waitLeader(ns []*node) int {
+ var l map[uint64]struct{}
+ var lindex int
+
+ for {
+ l = make(map[uint64]struct{})
+
+ for i, n := range ns {
+ lead := n.Status().SoftState.Lead
+ if lead != 0 {
+ l[lead] = struct{}{}
+ if n.id == lead {
+ lindex = i
+ }
+ }
+ }
+
+ if len(l) == 1 {
+ return lindex
+ }
+ }
+}
+
+func waitCommitConverge(ns []*node, target uint64) bool {
+ var c map[uint64]struct{}
+
+ for i := 0; i < 50; i++ {
+ c = make(map[uint64]struct{})
+ var good int
+
+ for _, n := range ns {
+ commit := n.Node.Status().HardState.Commit
+ c[commit] = struct{}{}
+ if commit > target {
+ good++
+ }
+ }
+
+ if len(c) == 1 && good == len(ns) {
+ return true
+ }
+ time.Sleep(100 * time.Millisecond)
+ }
+
+ return false
+}
diff --git a/vendor/github.com/coreos/etcd/raft/rawnode.go b/vendor/github.com/coreos/etcd/raft/rawnode.go
new file mode 100644
index 00000000..b950d516
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/rawnode.go
@@ -0,0 +1,264 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "errors"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+// ErrStepLocalMsg is returned when try to step a local raft message
+var ErrStepLocalMsg = errors.New("raft: cannot step raft local message")
+
+// ErrStepPeerNotFound is returned when try to step a response message
+// but there is no peer found in raft.prs for that node.
+var ErrStepPeerNotFound = errors.New("raft: cannot step as peer not found")
+
+// RawNode is a thread-unsafe Node.
+// The methods of this struct correspond to the methods of Node and are described
+// more fully there.
+type RawNode struct {
+ raft *raft
+ prevSoftSt *SoftState
+ prevHardSt pb.HardState
+}
+
+func (rn *RawNode) newReady() Ready {
+ return newReady(rn.raft, rn.prevSoftSt, rn.prevHardSt)
+}
+
+func (rn *RawNode) commitReady(rd Ready) {
+ if rd.SoftState != nil {
+ rn.prevSoftSt = rd.SoftState
+ }
+ if !IsEmptyHardState(rd.HardState) {
+ rn.prevHardSt = rd.HardState
+ }
+ if rn.prevHardSt.Commit != 0 {
+ // In most cases, prevHardSt and rd.HardState will be the same
+ // because when there are new entries to apply we just sent a
+ // HardState with an updated Commit value. However, on initial
+ // startup the two are different because we don't send a HardState
+ // until something changes, but we do send any un-applied but
+ // committed entries (and previously-committed entries may be
+ // incorporated into the snapshot, even if rd.CommittedEntries is
+ // empty). Therefore we mark all committed entries as applied
+ // whether they were included in rd.HardState or not.
+ rn.raft.raftLog.appliedTo(rn.prevHardSt.Commit)
+ }
+ if len(rd.Entries) > 0 {
+ e := rd.Entries[len(rd.Entries)-1]
+ rn.raft.raftLog.stableTo(e.Index, e.Term)
+ }
+ if !IsEmptySnap(rd.Snapshot) {
+ rn.raft.raftLog.stableSnapTo(rd.Snapshot.Metadata.Index)
+ }
+ if len(rd.ReadStates) != 0 {
+ rn.raft.readStates = nil
+ }
+}
+
+// NewRawNode returns a new RawNode given configuration and a list of raft peers.
+func NewRawNode(config *Config, peers []Peer) (*RawNode, error) {
+ if config.ID == 0 {
+ panic("config.ID must not be zero")
+ }
+ r := newRaft(config)
+ rn := &RawNode{
+ raft: r,
+ }
+ lastIndex, err := config.Storage.LastIndex()
+ if err != nil {
+ panic(err) // TODO(bdarnell)
+ }
+ // If the log is empty, this is a new RawNode (like StartNode); otherwise it's
+ // restoring an existing RawNode (like RestartNode).
+ // TODO(bdarnell): rethink RawNode initialization and whether the application needs
+ // to be able to tell us when it expects the RawNode to exist.
+ if lastIndex == 0 {
+ r.becomeFollower(1, None)
+ ents := make([]pb.Entry, len(peers))
+ for i, peer := range peers {
+ cc := pb.ConfChange{Type: pb.ConfChangeAddNode, NodeID: peer.ID, Context: peer.Context}
+ data, err := cc.Marshal()
+ if err != nil {
+ panic("unexpected marshal error")
+ }
+
+ ents[i] = pb.Entry{Type: pb.EntryConfChange, Term: 1, Index: uint64(i + 1), Data: data}
+ }
+ r.raftLog.append(ents...)
+ r.raftLog.committed = uint64(len(ents))
+ for _, peer := range peers {
+ r.addNode(peer.ID)
+ }
+ }
+
+ // Set the initial hard and soft states after performing all initialization.
+ rn.prevSoftSt = r.softState()
+ if lastIndex == 0 {
+ rn.prevHardSt = emptyState
+ } else {
+ rn.prevHardSt = r.hardState()
+ }
+
+ return rn, nil
+}
+
+// Tick advances the internal logical clock by a single tick.
+func (rn *RawNode) Tick() {
+ rn.raft.tick()
+}
+
+// TickQuiesced advances the internal logical clock by a single tick without
+// performing any other state machine processing. It allows the caller to avoid
+// periodic heartbeats and elections when all of the peers in a Raft group are
+// known to be at the same state. Expected usage is to periodically invoke Tick
+// or TickQuiesced depending on whether the group is "active" or "quiesced".
+//
+// WARNING: Be very careful about using this method as it subverts the Raft
+// state machine. You should probably be using Tick instead.
+func (rn *RawNode) TickQuiesced() {
+ rn.raft.electionElapsed++
+}
+
+// Campaign causes this RawNode to transition to candidate state.
+func (rn *RawNode) Campaign() error {
+ return rn.raft.Step(pb.Message{
+ Type: pb.MsgHup,
+ })
+}
+
+// Propose proposes data be appended to the raft log.
+func (rn *RawNode) Propose(data []byte) error {
+ return rn.raft.Step(pb.Message{
+ Type: pb.MsgProp,
+ From: rn.raft.id,
+ Entries: []pb.Entry{
+ {Data: data},
+ }})
+}
+
+// ProposeConfChange proposes a config change.
+func (rn *RawNode) ProposeConfChange(cc pb.ConfChange) error {
+ data, err := cc.Marshal()
+ if err != nil {
+ return err
+ }
+ return rn.raft.Step(pb.Message{
+ Type: pb.MsgProp,
+ Entries: []pb.Entry{
+ {Type: pb.EntryConfChange, Data: data},
+ },
+ })
+}
+
+// ApplyConfChange applies a config change to the local node.
+func (rn *RawNode) ApplyConfChange(cc pb.ConfChange) *pb.ConfState {
+ if cc.NodeID == None {
+ rn.raft.resetPendingConf()
+ return &pb.ConfState{Nodes: rn.raft.nodes()}
+ }
+ switch cc.Type {
+ case pb.ConfChangeAddNode:
+ rn.raft.addNode(cc.NodeID)
+ case pb.ConfChangeRemoveNode:
+ rn.raft.removeNode(cc.NodeID)
+ case pb.ConfChangeUpdateNode:
+ rn.raft.resetPendingConf()
+ default:
+ panic("unexpected conf type")
+ }
+ return &pb.ConfState{Nodes: rn.raft.nodes()}
+}
+
+// Step advances the state machine using the given message.
+func (rn *RawNode) Step(m pb.Message) error {
+ // ignore unexpected local messages receiving over network
+ if IsLocalMsg(m.Type) {
+ return ErrStepLocalMsg
+ }
+ if _, ok := rn.raft.prs[m.From]; ok || !IsResponseMsg(m.Type) {
+ return rn.raft.Step(m)
+ }
+ return ErrStepPeerNotFound
+}
+
+// Ready returns the current point-in-time state of this RawNode.
+func (rn *RawNode) Ready() Ready {
+ rd := rn.newReady()
+ rn.raft.msgs = nil
+ return rd
+}
+
+// HasReady called when RawNode user need to check if any Ready pending.
+// Checking logic in this method should be consistent with Ready.containsUpdates().
+func (rn *RawNode) HasReady() bool {
+ r := rn.raft
+ if !r.softState().equal(rn.prevSoftSt) {
+ return true
+ }
+ if hardSt := r.hardState(); !IsEmptyHardState(hardSt) && !isHardStateEqual(hardSt, rn.prevHardSt) {
+ return true
+ }
+ if r.raftLog.unstable.snapshot != nil && !IsEmptySnap(*r.raftLog.unstable.snapshot) {
+ return true
+ }
+ if len(r.msgs) > 0 || len(r.raftLog.unstableEntries()) > 0 || r.raftLog.hasNextEnts() {
+ return true
+ }
+ if len(r.readStates) != 0 {
+ return true
+ }
+ return false
+}
+
+// Advance notifies the RawNode that the application has applied and saved progress in the
+// last Ready results.
+func (rn *RawNode) Advance(rd Ready) {
+ rn.commitReady(rd)
+}
+
+// Status returns the current status of the given group.
+func (rn *RawNode) Status() *Status {
+ status := getStatus(rn.raft)
+ return &status
+}
+
+// ReportUnreachable reports the given node is not reachable for the last send.
+func (rn *RawNode) ReportUnreachable(id uint64) {
+ _ = rn.raft.Step(pb.Message{Type: pb.MsgUnreachable, From: id})
+}
+
+// ReportSnapshot reports the status of the sent snapshot.
+func (rn *RawNode) ReportSnapshot(id uint64, status SnapshotStatus) {
+ rej := status == SnapshotFailure
+
+ _ = rn.raft.Step(pb.Message{Type: pb.MsgSnapStatus, From: id, Reject: rej})
+}
+
+// TransferLeader tries to transfer leadership to the given transferee.
+func (rn *RawNode) TransferLeader(transferee uint64) {
+ _ = rn.raft.Step(pb.Message{Type: pb.MsgTransferLeader, From: transferee})
+}
+
+// ReadIndex requests a read state. The read state will be set in ready.
+// Read State has a read index. Once the application advances further than the read
+// index, any linearizable read requests issued before the read request can be
+// processed safely. The read state will have the same rctx attached.
+func (rn *RawNode) ReadIndex(rctx []byte) {
+ _ = rn.raft.Step(pb.Message{Type: pb.MsgReadIndex, Entries: []pb.Entry{{Data: rctx}}})
+}
diff --git a/vendor/github.com/coreos/etcd/raft/rawnode_test.go b/vendor/github.com/coreos/etcd/raft/rawnode_test.go
new file mode 100644
index 00000000..4ccf72de
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/rawnode_test.go
@@ -0,0 +1,402 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "bytes"
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+// TestRawNodeStep ensures that RawNode.Step ignore local message.
+func TestRawNodeStep(t *testing.T) {
+ for i, msgn := range raftpb.MessageType_name {
+ s := NewMemoryStorage()
+ rawNode, err := NewRawNode(newTestConfig(1, nil, 10, 1, s), []Peer{{ID: 1}})
+ if err != nil {
+ t.Fatal(err)
+ }
+ msgt := raftpb.MessageType(i)
+ err = rawNode.Step(raftpb.Message{Type: msgt})
+ // LocalMsg should be ignored.
+ if IsLocalMsg(msgt) {
+ if err != ErrStepLocalMsg {
+ t.Errorf("%d: step should ignore %s", msgt, msgn)
+ }
+ }
+ }
+}
+
+// TestNodeStepUnblock from node_test.go has no equivalent in rawNode because there is
+// no goroutine in RawNode.
+
+// TestRawNodeProposeAndConfChange ensures that RawNode.Propose and RawNode.ProposeConfChange
+// send the given proposal and ConfChange to the underlying raft.
+func TestRawNodeProposeAndConfChange(t *testing.T) {
+ s := NewMemoryStorage()
+ var err error
+ rawNode, err := NewRawNode(newTestConfig(1, nil, 10, 1, s), []Peer{{ID: 1}})
+ if err != nil {
+ t.Fatal(err)
+ }
+ rd := rawNode.Ready()
+ s.Append(rd.Entries)
+ rawNode.Advance(rd)
+
+ rawNode.Campaign()
+ proposed := false
+ var (
+ lastIndex uint64
+ ccdata []byte
+ )
+ for {
+ rd = rawNode.Ready()
+ s.Append(rd.Entries)
+ // Once we are the leader, propose a command and a ConfChange.
+ if !proposed && rd.SoftState.Lead == rawNode.raft.id {
+ rawNode.Propose([]byte("somedata"))
+
+ cc := raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 1}
+ ccdata, err = cc.Marshal()
+ if err != nil {
+ t.Fatal(err)
+ }
+ rawNode.ProposeConfChange(cc)
+
+ proposed = true
+ }
+ rawNode.Advance(rd)
+
+ // Exit when we have four entries: one ConfChange, one no-op for the election,
+ // our proposed command and proposed ConfChange.
+ lastIndex, err = s.LastIndex()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if lastIndex >= 4 {
+ break
+ }
+ }
+
+ entries, err := s.Entries(lastIndex-1, lastIndex+1, noLimit)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(entries) != 2 {
+ t.Fatalf("len(entries) = %d, want %d", len(entries), 2)
+ }
+ if !bytes.Equal(entries[0].Data, []byte("somedata")) {
+ t.Errorf("entries[0].Data = %v, want %v", entries[0].Data, []byte("somedata"))
+ }
+ if entries[1].Type != raftpb.EntryConfChange {
+ t.Fatalf("type = %v, want %v", entries[1].Type, raftpb.EntryConfChange)
+ }
+ if !bytes.Equal(entries[1].Data, ccdata) {
+ t.Errorf("data = %v, want %v", entries[1].Data, ccdata)
+ }
+}
+
+// TestRawNodeProposeAddDuplicateNode ensures that two proposes to add the same node should
+// not affect the later propose to add new node.
+func TestRawNodeProposeAddDuplicateNode(t *testing.T) {
+ s := NewMemoryStorage()
+ rawNode, err := NewRawNode(newTestConfig(1, nil, 10, 1, s), []Peer{{ID: 1}})
+ if err != nil {
+ t.Fatal(err)
+ }
+ rd := rawNode.Ready()
+ s.Append(rd.Entries)
+ rawNode.Advance(rd)
+
+ rawNode.Campaign()
+ for {
+ rd = rawNode.Ready()
+ s.Append(rd.Entries)
+ if rd.SoftState.Lead == rawNode.raft.id {
+ rawNode.Advance(rd)
+ break
+ }
+ rawNode.Advance(rd)
+ }
+
+ proposeConfChangeAndApply := func(cc raftpb.ConfChange) {
+ rawNode.ProposeConfChange(cc)
+ rd = rawNode.Ready()
+ s.Append(rd.Entries)
+ for _, entry := range rd.CommittedEntries {
+ if entry.Type == raftpb.EntryConfChange {
+ var cc raftpb.ConfChange
+ cc.Unmarshal(entry.Data)
+ rawNode.ApplyConfChange(cc)
+ }
+ }
+ rawNode.Advance(rd)
+ }
+
+ cc1 := raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 1}
+ ccdata1, err := cc1.Marshal()
+ if err != nil {
+ t.Fatal(err)
+ }
+ proposeConfChangeAndApply(cc1)
+
+ // try to add the same node again
+ proposeConfChangeAndApply(cc1)
+
+ // the new node join should be ok
+ cc2 := raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 2}
+ ccdata2, err := cc2.Marshal()
+ if err != nil {
+ t.Fatal(err)
+ }
+ proposeConfChangeAndApply(cc2)
+
+ lastIndex, err := s.LastIndex()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // the last three entries should be: ConfChange cc1, cc1, cc2
+ entries, err := s.Entries(lastIndex-2, lastIndex+1, noLimit)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(entries) != 3 {
+ t.Fatalf("len(entries) = %d, want %d", len(entries), 3)
+ }
+ if !bytes.Equal(entries[0].Data, ccdata1) {
+ t.Errorf("entries[0].Data = %v, want %v", entries[0].Data, ccdata1)
+ }
+ if !bytes.Equal(entries[2].Data, ccdata2) {
+ t.Errorf("entries[2].Data = %v, want %v", entries[2].Data, ccdata2)
+ }
+}
+
+// TestRawNodeReadIndex ensures that Rawnode.ReadIndex sends the MsgReadIndex message
+// to the underlying raft. It also ensures that ReadState can be read out.
+func TestRawNodeReadIndex(t *testing.T) {
+ msgs := []raftpb.Message{}
+ appendStep := func(r *raft, m raftpb.Message) {
+ msgs = append(msgs, m)
+ }
+ wrs := []ReadState{{Index: uint64(1), RequestCtx: []byte("somedata")}}
+
+ s := NewMemoryStorage()
+ c := newTestConfig(1, nil, 10, 1, s)
+ rawNode, err := NewRawNode(c, []Peer{{ID: 1}})
+ if err != nil {
+ t.Fatal(err)
+ }
+ rawNode.raft.readStates = wrs
+ // ensure the ReadStates can be read out
+ hasReady := rawNode.HasReady()
+ if !hasReady {
+ t.Errorf("HasReady() returns %t, want %t", hasReady, true)
+ }
+ rd := rawNode.Ready()
+ if !reflect.DeepEqual(rd.ReadStates, wrs) {
+ t.Errorf("ReadStates = %d, want %d", rd.ReadStates, wrs)
+ }
+ s.Append(rd.Entries)
+ rawNode.Advance(rd)
+ // ensure raft.readStates is reset after advance
+ if rawNode.raft.readStates != nil {
+ t.Errorf("readStates = %v, want %v", rawNode.raft.readStates, nil)
+ }
+
+ wrequestCtx := []byte("somedata2")
+ rawNode.Campaign()
+ for {
+ rd = rawNode.Ready()
+ s.Append(rd.Entries)
+
+ if rd.SoftState.Lead == rawNode.raft.id {
+ rawNode.Advance(rd)
+
+ // Once we are the leader, issue a ReadIndex request
+ rawNode.raft.step = appendStep
+ rawNode.ReadIndex(wrequestCtx)
+ break
+ }
+ rawNode.Advance(rd)
+ }
+ // ensure that MsgReadIndex message is sent to the underlying raft
+ if len(msgs) != 1 {
+ t.Fatalf("len(msgs) = %d, want %d", len(msgs), 1)
+ }
+ if msgs[0].Type != raftpb.MsgReadIndex {
+ t.Errorf("msg type = %d, want %d", msgs[0].Type, raftpb.MsgReadIndex)
+ }
+ if !bytes.Equal(msgs[0].Entries[0].Data, wrequestCtx) {
+ t.Errorf("data = %v, want %v", msgs[0].Entries[0].Data, wrequestCtx)
+ }
+}
+
+// TestBlockProposal from node_test.go has no equivalent in rawNode because there is
+// no leader check in RawNode.
+
+// TestNodeTick from node_test.go has no equivalent in rawNode because
+// it reaches into the raft object which is not exposed.
+
+// TestNodeStop from node_test.go has no equivalent in rawNode because there is
+// no goroutine in RawNode.
+
+// TestRawNodeStart ensures that a node can be started correctly. The node should
+// start with correct configuration change entries, and can accept and commit
+// proposals.
+func TestRawNodeStart(t *testing.T) {
+ cc := raftpb.ConfChange{Type: raftpb.ConfChangeAddNode, NodeID: 1}
+ ccdata, err := cc.Marshal()
+ if err != nil {
+ t.Fatalf("unexpected marshal error: %v", err)
+ }
+ wants := []Ready{
+ {
+ HardState: raftpb.HardState{Term: 1, Commit: 1, Vote: 0},
+ Entries: []raftpb.Entry{
+ {Type: raftpb.EntryConfChange, Term: 1, Index: 1, Data: ccdata},
+ },
+ CommittedEntries: []raftpb.Entry{
+ {Type: raftpb.EntryConfChange, Term: 1, Index: 1, Data: ccdata},
+ },
+ MustSync: true,
+ },
+ {
+ HardState: raftpb.HardState{Term: 2, Commit: 3, Vote: 1},
+ Entries: []raftpb.Entry{{Term: 2, Index: 3, Data: []byte("foo")}},
+ CommittedEntries: []raftpb.Entry{{Term: 2, Index: 3, Data: []byte("foo")}},
+ MustSync: true,
+ },
+ }
+
+ storage := NewMemoryStorage()
+ rawNode, err := NewRawNode(newTestConfig(1, nil, 10, 1, storage), []Peer{{ID: 1}})
+ if err != nil {
+ t.Fatal(err)
+ }
+ rd := rawNode.Ready()
+ t.Logf("rd %v", rd)
+ if !reflect.DeepEqual(rd, wants[0]) {
+ t.Fatalf("#%d: g = %+v,\n w %+v", 1, rd, wants[0])
+ } else {
+ storage.Append(rd.Entries)
+ rawNode.Advance(rd)
+ }
+ storage.Append(rd.Entries)
+ rawNode.Advance(rd)
+
+ rawNode.Campaign()
+ rd = rawNode.Ready()
+ storage.Append(rd.Entries)
+ rawNode.Advance(rd)
+
+ rawNode.Propose([]byte("foo"))
+ if rd = rawNode.Ready(); !reflect.DeepEqual(rd, wants[1]) {
+ t.Errorf("#%d: g = %+v,\n w %+v", 2, rd, wants[1])
+ } else {
+ storage.Append(rd.Entries)
+ rawNode.Advance(rd)
+ }
+
+ if rawNode.HasReady() {
+ t.Errorf("unexpected Ready: %+v", rawNode.Ready())
+ }
+}
+
+func TestRawNodeRestart(t *testing.T) {
+ entries := []raftpb.Entry{
+ {Term: 1, Index: 1},
+ {Term: 1, Index: 2, Data: []byte("foo")},
+ }
+ st := raftpb.HardState{Term: 1, Commit: 1}
+
+ want := Ready{
+ HardState: emptyState,
+ // commit up to commit index in st
+ CommittedEntries: entries[:st.Commit],
+ MustSync: true,
+ }
+
+ storage := NewMemoryStorage()
+ storage.SetHardState(st)
+ storage.Append(entries)
+ rawNode, err := NewRawNode(newTestConfig(1, nil, 10, 1, storage), nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ rd := rawNode.Ready()
+ if !reflect.DeepEqual(rd, want) {
+ t.Errorf("g = %+v,\n w %+v", rd, want)
+ }
+ rawNode.Advance(rd)
+ if rawNode.HasReady() {
+ t.Errorf("unexpected Ready: %+v", rawNode.Ready())
+ }
+}
+
+func TestRawNodeRestartFromSnapshot(t *testing.T) {
+ snap := raftpb.Snapshot{
+ Metadata: raftpb.SnapshotMetadata{
+ ConfState: raftpb.ConfState{Nodes: []uint64{1, 2}},
+ Index: 2,
+ Term: 1,
+ },
+ }
+ entries := []raftpb.Entry{
+ {Term: 1, Index: 3, Data: []byte("foo")},
+ }
+ st := raftpb.HardState{Term: 1, Commit: 3}
+
+ want := Ready{
+ HardState: emptyState,
+ // commit up to commit index in st
+ CommittedEntries: entries,
+ MustSync: true,
+ }
+
+ s := NewMemoryStorage()
+ s.SetHardState(st)
+ s.ApplySnapshot(snap)
+ s.Append(entries)
+ rawNode, err := NewRawNode(newTestConfig(1, nil, 10, 1, s), nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if rd := rawNode.Ready(); !reflect.DeepEqual(rd, want) {
+ t.Errorf("g = %+v,\n w %+v", rd, want)
+ } else {
+ rawNode.Advance(rd)
+ }
+ if rawNode.HasReady() {
+ t.Errorf("unexpected Ready: %+v", rawNode.HasReady())
+ }
+}
+
+// TestNodeAdvance from node_test.go has no equivalent in rawNode because there is
+// no dependency check between Ready() and Advance()
+
+func TestRawNodeStatus(t *testing.T) {
+ storage := NewMemoryStorage()
+ rawNode, err := NewRawNode(newTestConfig(1, nil, 10, 1, storage), []Peer{{ID: 1}})
+ if err != nil {
+ t.Fatal(err)
+ }
+ status := rawNode.Status()
+ if status == nil {
+ t.Errorf("expected status struct, got nil")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/raft/read_only.go b/vendor/github.com/coreos/etcd/raft/read_only.go
new file mode 100644
index 00000000..d0085237
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/read_only.go
@@ -0,0 +1,118 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 raft
+
+import pb "github.com/coreos/etcd/raft/raftpb"
+
+// ReadState provides state for read only query.
+// It's caller's responsibility to call ReadIndex first before getting
+// this state from ready, It's also caller's duty to differentiate if this
+// state is what it requests through RequestCtx, eg. given a unique id as
+// RequestCtx
+type ReadState struct {
+ Index uint64
+ RequestCtx []byte
+}
+
+type readIndexStatus struct {
+ req pb.Message
+ index uint64
+ acks map[uint64]struct{}
+}
+
+type readOnly struct {
+ option ReadOnlyOption
+ pendingReadIndex map[string]*readIndexStatus
+ readIndexQueue []string
+}
+
+func newReadOnly(option ReadOnlyOption) *readOnly {
+ return &readOnly{
+ option: option,
+ pendingReadIndex: make(map[string]*readIndexStatus),
+ }
+}
+
+// addRequest adds a read only reuqest into readonly struct.
+// `index` is the commit index of the raft state machine when it received
+// the read only request.
+// `m` is the original read only request message from the local or remote node.
+func (ro *readOnly) addRequest(index uint64, m pb.Message) {
+ ctx := string(m.Entries[0].Data)
+ if _, ok := ro.pendingReadIndex[ctx]; ok {
+ return
+ }
+ ro.pendingReadIndex[ctx] = &readIndexStatus{index: index, req: m, acks: make(map[uint64]struct{})}
+ ro.readIndexQueue = append(ro.readIndexQueue, ctx)
+}
+
+// recvAck notifies the readonly struct that the raft state machine received
+// an acknowledgment of the heartbeat that attached with the read only request
+// context.
+func (ro *readOnly) recvAck(m pb.Message) int {
+ rs, ok := ro.pendingReadIndex[string(m.Context)]
+ if !ok {
+ return 0
+ }
+
+ rs.acks[m.From] = struct{}{}
+ // add one to include an ack from local node
+ return len(rs.acks) + 1
+}
+
+// advance advances the read only request queue kept by the readonly struct.
+// It dequeues the requests until it finds the read only request that has
+// the same context as the given `m`.
+func (ro *readOnly) advance(m pb.Message) []*readIndexStatus {
+ var (
+ i int
+ found bool
+ )
+
+ ctx := string(m.Context)
+ rss := []*readIndexStatus{}
+
+ for _, okctx := range ro.readIndexQueue {
+ i++
+ rs, ok := ro.pendingReadIndex[okctx]
+ if !ok {
+ panic("cannot find corresponding read state from pending map")
+ }
+ rss = append(rss, rs)
+ if okctx == ctx {
+ found = true
+ break
+ }
+ }
+
+ if found {
+ ro.readIndexQueue = ro.readIndexQueue[i:]
+ for _, rs := range rss {
+ delete(ro.pendingReadIndex, string(rs.req.Entries[0].Data))
+ }
+ return rss
+ }
+
+ return nil
+}
+
+// lastPendingRequestCtx returns the context of the last pending read only
+// request in readonly struct.
+func (ro *readOnly) lastPendingRequestCtx() string {
+ if len(ro.readIndexQueue) == 0 {
+ return ""
+ }
+ return ro.readIndexQueue[len(ro.readIndexQueue)-1]
+}
diff --git a/vendor/github.com/coreos/etcd/raft/status.go b/vendor/github.com/coreos/etcd/raft/status.go
new file mode 100644
index 00000000..b690fa56
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/status.go
@@ -0,0 +1,76 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "fmt"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+type Status struct {
+ ID uint64
+
+ pb.HardState
+ SoftState
+
+ Applied uint64
+ Progress map[uint64]Progress
+}
+
+// getStatus gets a copy of the current raft status.
+func getStatus(r *raft) Status {
+ s := Status{ID: r.id}
+ s.HardState = r.hardState()
+ s.SoftState = *r.softState()
+
+ s.Applied = r.raftLog.applied
+
+ if s.RaftState == StateLeader {
+ s.Progress = make(map[uint64]Progress)
+ for id, p := range r.prs {
+ s.Progress[id] = *p
+ }
+ }
+
+ return s
+}
+
+// MarshalJSON translates the raft status into JSON.
+// TODO: try to simplify this by introducing ID type into raft
+func (s Status) MarshalJSON() ([]byte, error) {
+ j := fmt.Sprintf(`{"id":"%x","term":%d,"vote":"%x","commit":%d,"lead":"%x","raftState":%q,"progress":{`,
+ s.ID, s.Term, s.Vote, s.Commit, s.Lead, s.RaftState)
+
+ if len(s.Progress) == 0 {
+ j += "}}"
+ } else {
+ for k, v := range s.Progress {
+ subj := fmt.Sprintf(`"%x":{"match":%d,"next":%d,"state":%q},`, k, v.Match, v.Next, v.State)
+ j += subj
+ }
+ // remove the trailing ","
+ j = j[:len(j)-1] + "}}"
+ }
+ return []byte(j), nil
+}
+
+func (s Status) String() string {
+ b, err := s.MarshalJSON()
+ if err != nil {
+ raftLogger.Panicf("unexpected error: %v", err)
+ }
+ return string(b)
+}
diff --git a/vendor/github.com/coreos/etcd/raft/storage.go b/vendor/github.com/coreos/etcd/raft/storage.go
new file mode 100644
index 00000000..69c3a7d9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/storage.go
@@ -0,0 +1,271 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "errors"
+ "sync"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+// ErrCompacted is returned by Storage.Entries/Compact when a requested
+// index is unavailable because it predates the last snapshot.
+var ErrCompacted = errors.New("requested index is unavailable due to compaction")
+
+// ErrSnapOutOfDate is returned by Storage.CreateSnapshot when a requested
+// index is older than the existing snapshot.
+var ErrSnapOutOfDate = errors.New("requested index is older than the existing snapshot")
+
+// ErrUnavailable is returned by Storage interface when the requested log entries
+// are unavailable.
+var ErrUnavailable = errors.New("requested entry at index is unavailable")
+
+// ErrSnapshotTemporarilyUnavailable is returned by the Storage interface when the required
+// snapshot is temporarily unavailable.
+var ErrSnapshotTemporarilyUnavailable = errors.New("snapshot is temporarily unavailable")
+
+// Storage is an interface that may be implemented by the application
+// to retrieve log entries from storage.
+//
+// If any Storage method returns an error, the raft instance will
+// become inoperable and refuse to participate in elections; the
+// application is responsible for cleanup and recovery in this case.
+type Storage interface {
+ // InitialState returns the saved HardState and ConfState information.
+ InitialState() (pb.HardState, pb.ConfState, error)
+ // Entries returns a slice of log entries in the range [lo,hi).
+ // MaxSize limits the total size of the log entries returned, but
+ // Entries returns at least one entry if any.
+ Entries(lo, hi, maxSize uint64) ([]pb.Entry, error)
+ // Term returns the term of entry i, which must be in the range
+ // [FirstIndex()-1, LastIndex()]. The term of the entry before
+ // FirstIndex is retained for matching purposes even though the
+ // rest of that entry may not be available.
+ Term(i uint64) (uint64, error)
+ // LastIndex returns the index of the last entry in the log.
+ LastIndex() (uint64, error)
+ // FirstIndex returns the index of the first log entry that is
+ // possibly available via Entries (older entries have been incorporated
+ // into the latest Snapshot; if storage only contains the dummy entry the
+ // first log entry is not available).
+ FirstIndex() (uint64, error)
+ // Snapshot returns the most recent snapshot.
+ // If snapshot is temporarily unavailable, it should return ErrSnapshotTemporarilyUnavailable,
+ // so raft state machine could know that Storage needs some time to prepare
+ // snapshot and call Snapshot later.
+ Snapshot() (pb.Snapshot, error)
+}
+
+// MemoryStorage implements the Storage interface backed by an
+// in-memory array.
+type MemoryStorage struct {
+ // Protects access to all fields. Most methods of MemoryStorage are
+ // run on the raft goroutine, but Append() is run on an application
+ // goroutine.
+ sync.Mutex
+
+ hardState pb.HardState
+ snapshot pb.Snapshot
+ // ents[i] has raft log position i+snapshot.Metadata.Index
+ ents []pb.Entry
+}
+
+// NewMemoryStorage creates an empty MemoryStorage.
+func NewMemoryStorage() *MemoryStorage {
+ return &MemoryStorage{
+ // When starting from scratch populate the list with a dummy entry at term zero.
+ ents: make([]pb.Entry, 1),
+ }
+}
+
+// InitialState implements the Storage interface.
+func (ms *MemoryStorage) InitialState() (pb.HardState, pb.ConfState, error) {
+ return ms.hardState, ms.snapshot.Metadata.ConfState, nil
+}
+
+// SetHardState saves the current HardState.
+func (ms *MemoryStorage) SetHardState(st pb.HardState) error {
+ ms.Lock()
+ defer ms.Unlock()
+ ms.hardState = st
+ return nil
+}
+
+// Entries implements the Storage interface.
+func (ms *MemoryStorage) Entries(lo, hi, maxSize uint64) ([]pb.Entry, error) {
+ ms.Lock()
+ defer ms.Unlock()
+ offset := ms.ents[0].Index
+ if lo <= offset {
+ return nil, ErrCompacted
+ }
+ if hi > ms.lastIndex()+1 {
+ raftLogger.Panicf("entries' hi(%d) is out of bound lastindex(%d)", hi, ms.lastIndex())
+ }
+ // only contains dummy entries.
+ if len(ms.ents) == 1 {
+ return nil, ErrUnavailable
+ }
+
+ ents := ms.ents[lo-offset : hi-offset]
+ return limitSize(ents, maxSize), nil
+}
+
+// Term implements the Storage interface.
+func (ms *MemoryStorage) Term(i uint64) (uint64, error) {
+ ms.Lock()
+ defer ms.Unlock()
+ offset := ms.ents[0].Index
+ if i < offset {
+ return 0, ErrCompacted
+ }
+ if int(i-offset) >= len(ms.ents) {
+ return 0, ErrUnavailable
+ }
+ return ms.ents[i-offset].Term, nil
+}
+
+// LastIndex implements the Storage interface.
+func (ms *MemoryStorage) LastIndex() (uint64, error) {
+ ms.Lock()
+ defer ms.Unlock()
+ return ms.lastIndex(), nil
+}
+
+func (ms *MemoryStorage) lastIndex() uint64 {
+ return ms.ents[0].Index + uint64(len(ms.ents)) - 1
+}
+
+// FirstIndex implements the Storage interface.
+func (ms *MemoryStorage) FirstIndex() (uint64, error) {
+ ms.Lock()
+ defer ms.Unlock()
+ return ms.firstIndex(), nil
+}
+
+func (ms *MemoryStorage) firstIndex() uint64 {
+ return ms.ents[0].Index + 1
+}
+
+// Snapshot implements the Storage interface.
+func (ms *MemoryStorage) Snapshot() (pb.Snapshot, error) {
+ ms.Lock()
+ defer ms.Unlock()
+ return ms.snapshot, nil
+}
+
+// ApplySnapshot overwrites the contents of this Storage object with
+// those of the given snapshot.
+func (ms *MemoryStorage) ApplySnapshot(snap pb.Snapshot) error {
+ ms.Lock()
+ defer ms.Unlock()
+
+ //handle check for old snapshot being applied
+ msIndex := ms.snapshot.Metadata.Index
+ snapIndex := snap.Metadata.Index
+ if msIndex >= snapIndex {
+ return ErrSnapOutOfDate
+ }
+
+ ms.snapshot = snap
+ ms.ents = []pb.Entry{{Term: snap.Metadata.Term, Index: snap.Metadata.Index}}
+ return nil
+}
+
+// CreateSnapshot makes a snapshot which can be retrieved with Snapshot() and
+// can be used to reconstruct the state at that point.
+// If any configuration changes have been made since the last compaction,
+// the result of the last ApplyConfChange must be passed in.
+func (ms *MemoryStorage) CreateSnapshot(i uint64, cs *pb.ConfState, data []byte) (pb.Snapshot, error) {
+ ms.Lock()
+ defer ms.Unlock()
+ if i <= ms.snapshot.Metadata.Index {
+ return pb.Snapshot{}, ErrSnapOutOfDate
+ }
+
+ offset := ms.ents[0].Index
+ if i > ms.lastIndex() {
+ raftLogger.Panicf("snapshot %d is out of bound lastindex(%d)", i, ms.lastIndex())
+ }
+
+ ms.snapshot.Metadata.Index = i
+ ms.snapshot.Metadata.Term = ms.ents[i-offset].Term
+ if cs != nil {
+ ms.snapshot.Metadata.ConfState = *cs
+ }
+ ms.snapshot.Data = data
+ return ms.snapshot, nil
+}
+
+// Compact discards all log entries prior to compactIndex.
+// It is the application's responsibility to not attempt to compact an index
+// greater than raftLog.applied.
+func (ms *MemoryStorage) Compact(compactIndex uint64) error {
+ ms.Lock()
+ defer ms.Unlock()
+ offset := ms.ents[0].Index
+ if compactIndex <= offset {
+ return ErrCompacted
+ }
+ if compactIndex > ms.lastIndex() {
+ raftLogger.Panicf("compact %d is out of bound lastindex(%d)", compactIndex, ms.lastIndex())
+ }
+
+ i := compactIndex - offset
+ ents := make([]pb.Entry, 1, 1+uint64(len(ms.ents))-i)
+ ents[0].Index = ms.ents[i].Index
+ ents[0].Term = ms.ents[i].Term
+ ents = append(ents, ms.ents[i+1:]...)
+ ms.ents = ents
+ return nil
+}
+
+// Append the new entries to storage.
+// TODO (xiangli): ensure the entries are continuous and
+// entries[0].Index > ms.entries[0].Index
+func (ms *MemoryStorage) Append(entries []pb.Entry) error {
+ if len(entries) == 0 {
+ return nil
+ }
+
+ ms.Lock()
+ defer ms.Unlock()
+
+ first := ms.firstIndex()
+ last := entries[0].Index + uint64(len(entries)) - 1
+
+ // shortcut if there is no new entry.
+ if last < first {
+ return nil
+ }
+ // truncate compacted entries
+ if first > entries[0].Index {
+ entries = entries[first-entries[0].Index:]
+ }
+
+ offset := entries[0].Index - ms.ents[0].Index
+ switch {
+ case uint64(len(ms.ents)) > offset:
+ ms.ents = append([]pb.Entry{}, ms.ents[:offset]...)
+ ms.ents = append(ms.ents, entries...)
+ case uint64(len(ms.ents)) == offset:
+ ms.ents = append(ms.ents, entries...)
+ default:
+ raftLogger.Panicf("missing log entry [last: %d, append at: %d]",
+ ms.lastIndex(), entries[0].Index)
+ }
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/raft/storage_test.go b/vendor/github.com/coreos/etcd/raft/storage_test.go
new file mode 100644
index 00000000..71d50b4c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/storage_test.go
@@ -0,0 +1,285 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "math"
+ "reflect"
+ "testing"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+func TestStorageTerm(t *testing.T) {
+ ents := []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}}
+ tests := []struct {
+ i uint64
+
+ werr error
+ wterm uint64
+ wpanic bool
+ }{
+ {2, ErrCompacted, 0, false},
+ {3, nil, 3, false},
+ {4, nil, 4, false},
+ {5, nil, 5, false},
+ {6, ErrUnavailable, 0, false},
+ }
+
+ for i, tt := range tests {
+ s := &MemoryStorage{ents: ents}
+
+ func() {
+ defer func() {
+ if r := recover(); r != nil {
+ if !tt.wpanic {
+ t.Errorf("%d: panic = %v, want %v", i, true, tt.wpanic)
+ }
+ }
+ }()
+
+ term, err := s.Term(tt.i)
+ if err != tt.werr {
+ t.Errorf("#%d: err = %v, want %v", i, err, tt.werr)
+ }
+ if term != tt.wterm {
+ t.Errorf("#%d: term = %d, want %d", i, term, tt.wterm)
+ }
+ }()
+ }
+}
+
+func TestStorageEntries(t *testing.T) {
+ ents := []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 6}}
+ tests := []struct {
+ lo, hi, maxsize uint64
+
+ werr error
+ wentries []pb.Entry
+ }{
+ {2, 6, math.MaxUint64, ErrCompacted, nil},
+ {3, 4, math.MaxUint64, ErrCompacted, nil},
+ {4, 5, math.MaxUint64, nil, []pb.Entry{{Index: 4, Term: 4}}},
+ {4, 6, math.MaxUint64, nil, []pb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}}},
+ {4, 7, math.MaxUint64, nil, []pb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 6}}},
+ // even if maxsize is zero, the first entry should be returned
+ {4, 7, 0, nil, []pb.Entry{{Index: 4, Term: 4}}},
+ // limit to 2
+ {4, 7, uint64(ents[1].Size() + ents[2].Size()), nil, []pb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}}},
+ // limit to 2
+ {4, 7, uint64(ents[1].Size() + ents[2].Size() + ents[3].Size()/2), nil, []pb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}}},
+ {4, 7, uint64(ents[1].Size() + ents[2].Size() + ents[3].Size() - 1), nil, []pb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}}},
+ // all
+ {4, 7, uint64(ents[1].Size() + ents[2].Size() + ents[3].Size()), nil, []pb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 6}}},
+ }
+
+ for i, tt := range tests {
+ s := &MemoryStorage{ents: ents}
+ entries, err := s.Entries(tt.lo, tt.hi, tt.maxsize)
+ if err != tt.werr {
+ t.Errorf("#%d: err = %v, want %v", i, err, tt.werr)
+ }
+ if !reflect.DeepEqual(entries, tt.wentries) {
+ t.Errorf("#%d: entries = %v, want %v", i, entries, tt.wentries)
+ }
+ }
+}
+
+func TestStorageLastIndex(t *testing.T) {
+ ents := []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}}
+ s := &MemoryStorage{ents: ents}
+
+ last, err := s.LastIndex()
+ if err != nil {
+ t.Errorf("err = %v, want nil", err)
+ }
+ if last != 5 {
+ t.Errorf("term = %d, want %d", last, 5)
+ }
+
+ s.Append([]pb.Entry{{Index: 6, Term: 5}})
+ last, err = s.LastIndex()
+ if err != nil {
+ t.Errorf("err = %v, want nil", err)
+ }
+ if last != 6 {
+ t.Errorf("last = %d, want %d", last, 5)
+ }
+}
+
+func TestStorageFirstIndex(t *testing.T) {
+ ents := []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}}
+ s := &MemoryStorage{ents: ents}
+
+ first, err := s.FirstIndex()
+ if err != nil {
+ t.Errorf("err = %v, want nil", err)
+ }
+ if first != 4 {
+ t.Errorf("first = %d, want %d", first, 4)
+ }
+
+ s.Compact(4)
+ first, err = s.FirstIndex()
+ if err != nil {
+ t.Errorf("err = %v, want nil", err)
+ }
+ if first != 5 {
+ t.Errorf("first = %d, want %d", first, 5)
+ }
+}
+
+func TestStorageCompact(t *testing.T) {
+ ents := []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}}
+ tests := []struct {
+ i uint64
+
+ werr error
+ windex uint64
+ wterm uint64
+ wlen int
+ }{
+ {2, ErrCompacted, 3, 3, 3},
+ {3, ErrCompacted, 3, 3, 3},
+ {4, nil, 4, 4, 2},
+ {5, nil, 5, 5, 1},
+ }
+
+ for i, tt := range tests {
+ s := &MemoryStorage{ents: ents}
+ err := s.Compact(tt.i)
+ if err != tt.werr {
+ t.Errorf("#%d: err = %v, want %v", i, err, tt.werr)
+ }
+ if s.ents[0].Index != tt.windex {
+ t.Errorf("#%d: index = %d, want %d", i, s.ents[0].Index, tt.windex)
+ }
+ if s.ents[0].Term != tt.wterm {
+ t.Errorf("#%d: term = %d, want %d", i, s.ents[0].Term, tt.wterm)
+ }
+ if len(s.ents) != tt.wlen {
+ t.Errorf("#%d: len = %d, want %d", i, len(s.ents), tt.wlen)
+ }
+ }
+}
+
+func TestStorageCreateSnapshot(t *testing.T) {
+ ents := []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}}
+ cs := &pb.ConfState{Nodes: []uint64{1, 2, 3}}
+ data := []byte("data")
+
+ tests := []struct {
+ i uint64
+
+ werr error
+ wsnap pb.Snapshot
+ }{
+ {4, nil, pb.Snapshot{Data: data, Metadata: pb.SnapshotMetadata{Index: 4, Term: 4, ConfState: *cs}}},
+ {5, nil, pb.Snapshot{Data: data, Metadata: pb.SnapshotMetadata{Index: 5, Term: 5, ConfState: *cs}}},
+ }
+
+ for i, tt := range tests {
+ s := &MemoryStorage{ents: ents}
+ snap, err := s.CreateSnapshot(tt.i, cs, data)
+ if err != tt.werr {
+ t.Errorf("#%d: err = %v, want %v", i, err, tt.werr)
+ }
+ if !reflect.DeepEqual(snap, tt.wsnap) {
+ t.Errorf("#%d: snap = %+v, want %+v", i, snap, tt.wsnap)
+ }
+ }
+}
+
+func TestStorageAppend(t *testing.T) {
+ ents := []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}}
+ tests := []struct {
+ entries []pb.Entry
+
+ werr error
+ wentries []pb.Entry
+ }{
+ {
+ []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}},
+ nil,
+ []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}},
+ },
+ {
+ []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 6}, {Index: 5, Term: 6}},
+ nil,
+ []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 6}, {Index: 5, Term: 6}},
+ },
+ {
+ []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 5}},
+ nil,
+ []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 5}},
+ },
+ // truncate incoming entries, truncate the existing entries and append
+ {
+ []pb.Entry{{Index: 2, Term: 3}, {Index: 3, Term: 3}, {Index: 4, Term: 5}},
+ nil,
+ []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 5}},
+ },
+ // truncate the existing entries and append
+ {
+ []pb.Entry{{Index: 4, Term: 5}},
+ nil,
+ []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 5}},
+ },
+ // direct append
+ {
+ []pb.Entry{{Index: 6, Term: 5}},
+ nil,
+ []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 5}},
+ },
+ }
+
+ for i, tt := range tests {
+ s := &MemoryStorage{ents: ents}
+ err := s.Append(tt.entries)
+ if err != tt.werr {
+ t.Errorf("#%d: err = %v, want %v", i, err, tt.werr)
+ }
+ if !reflect.DeepEqual(s.ents, tt.wentries) {
+ t.Errorf("#%d: entries = %v, want %v", i, s.ents, tt.wentries)
+ }
+ }
+}
+
+func TestStorageApplySnapshot(t *testing.T) {
+ cs := &pb.ConfState{Nodes: []uint64{1, 2, 3}}
+ data := []byte("data")
+
+ tests := []pb.Snapshot{{Data: data, Metadata: pb.SnapshotMetadata{Index: 4, Term: 4, ConfState: *cs}},
+ {Data: data, Metadata: pb.SnapshotMetadata{Index: 3, Term: 3, ConfState: *cs}},
+ }
+
+ s := NewMemoryStorage()
+
+ //Apply Snapshot successful
+ i := 0
+ tt := tests[i]
+ err := s.ApplySnapshot(tt)
+ if err != nil {
+ t.Errorf("#%d: err = %v, want %v", i, err, nil)
+ }
+
+ //Apply Snapshot fails due to ErrSnapOutOfDate
+ i = 1
+ tt = tests[i]
+ err = s.ApplySnapshot(tt)
+ if err != ErrSnapOutOfDate {
+ t.Errorf("#%d: err = %v, want %v", i, err, ErrSnapOutOfDate)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/raft/util.go b/vendor/github.com/coreos/etcd/raft/util.go
new file mode 100644
index 00000000..f4141fe6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/util.go
@@ -0,0 +1,129 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "bytes"
+ "fmt"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+func (st StateType) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf("%q", st.String())), nil
+}
+
+// uint64Slice implements sort interface
+type uint64Slice []uint64
+
+func (p uint64Slice) Len() int { return len(p) }
+func (p uint64Slice) Less(i, j int) bool { return p[i] < p[j] }
+func (p uint64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+
+func min(a, b uint64) uint64 {
+ if a > b {
+ return b
+ }
+ return a
+}
+
+func max(a, b uint64) uint64 {
+ if a > b {
+ return a
+ }
+ return b
+}
+
+func IsLocalMsg(msgt pb.MessageType) bool {
+ return msgt == pb.MsgHup || msgt == pb.MsgBeat || msgt == pb.MsgUnreachable ||
+ msgt == pb.MsgSnapStatus || msgt == pb.MsgCheckQuorum
+}
+
+func IsResponseMsg(msgt pb.MessageType) bool {
+ return msgt == pb.MsgAppResp || msgt == pb.MsgVoteResp || msgt == pb.MsgHeartbeatResp || msgt == pb.MsgUnreachable || msgt == pb.MsgPreVoteResp
+}
+
+// voteResponseType maps vote and prevote message types to their corresponding responses.
+func voteRespMsgType(msgt pb.MessageType) pb.MessageType {
+ switch msgt {
+ case pb.MsgVote:
+ return pb.MsgVoteResp
+ case pb.MsgPreVote:
+ return pb.MsgPreVoteResp
+ default:
+ panic(fmt.Sprintf("not a vote message: %s", msgt))
+ }
+}
+
+// EntryFormatter can be implemented by the application to provide human-readable formatting
+// of entry data. Nil is a valid EntryFormatter and will use a default format.
+type EntryFormatter func([]byte) string
+
+// DescribeMessage returns a concise human-readable description of a
+// Message for debugging.
+func DescribeMessage(m pb.Message, f EntryFormatter) string {
+ var buf bytes.Buffer
+ fmt.Fprintf(&buf, "%x->%x %v Term:%d Log:%d/%d", m.From, m.To, m.Type, m.Term, m.LogTerm, m.Index)
+ if m.Reject {
+ fmt.Fprintf(&buf, " Rejected")
+ if m.RejectHint != 0 {
+ fmt.Fprintf(&buf, "(Hint:%d)", m.RejectHint)
+ }
+ }
+ if m.Commit != 0 {
+ fmt.Fprintf(&buf, " Commit:%d", m.Commit)
+ }
+ if len(m.Entries) > 0 {
+ fmt.Fprintf(&buf, " Entries:[")
+ for i, e := range m.Entries {
+ if i != 0 {
+ buf.WriteString(", ")
+ }
+ buf.WriteString(DescribeEntry(e, f))
+ }
+ fmt.Fprintf(&buf, "]")
+ }
+ if !IsEmptySnap(m.Snapshot) {
+ fmt.Fprintf(&buf, " Snapshot:%v", m.Snapshot)
+ }
+ return buf.String()
+}
+
+// DescribeEntry returns a concise human-readable description of an
+// Entry for debugging.
+func DescribeEntry(e pb.Entry, f EntryFormatter) string {
+ var formatted string
+ if e.Type == pb.EntryNormal && f != nil {
+ formatted = f(e.Data)
+ } else {
+ formatted = fmt.Sprintf("%q", e.Data)
+ }
+ return fmt.Sprintf("%d/%d %s %s", e.Term, e.Index, e.Type, formatted)
+}
+
+func limitSize(ents []pb.Entry, maxSize uint64) []pb.Entry {
+ if len(ents) == 0 {
+ return ents
+ }
+ size := ents[0].Size()
+ var limit int
+ for limit = 1; limit < len(ents); limit++ {
+ size += ents[limit].Size()
+ if uint64(size) > maxSize {
+ break
+ }
+ }
+ return ents[:limit]
+}
diff --git a/vendor/github.com/coreos/etcd/raft/util_test.go b/vendor/github.com/coreos/etcd/raft/util_test.go
new file mode 100644
index 00000000..9d7eeb07
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/raft/util_test.go
@@ -0,0 +1,106 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 raft
+
+import (
+ "math"
+ "reflect"
+ "strings"
+ "testing"
+
+ pb "github.com/coreos/etcd/raft/raftpb"
+)
+
+var testFormatter EntryFormatter = func(data []byte) string {
+ return strings.ToUpper(string(data))
+}
+
+func TestDescribeEntry(t *testing.T) {
+ entry := pb.Entry{
+ Term: 1,
+ Index: 2,
+ Type: pb.EntryNormal,
+ Data: []byte("hello\x00world"),
+ }
+
+ defaultFormatted := DescribeEntry(entry, nil)
+ if defaultFormatted != "1/2 EntryNormal \"hello\\x00world\"" {
+ t.Errorf("unexpected default output: %s", defaultFormatted)
+ }
+
+ customFormatted := DescribeEntry(entry, testFormatter)
+ if customFormatted != "1/2 EntryNormal HELLO\x00WORLD" {
+ t.Errorf("unexpected custom output: %s", customFormatted)
+ }
+}
+
+func TestLimitSize(t *testing.T) {
+ ents := []pb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 6}}
+ tests := []struct {
+ maxsize uint64
+ wentries []pb.Entry
+ }{
+ {math.MaxUint64, []pb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 6}}},
+ // even if maxsize is zero, the first entry should be returned
+ {0, []pb.Entry{{Index: 4, Term: 4}}},
+ // limit to 2
+ {uint64(ents[0].Size() + ents[1].Size()), []pb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}}},
+ // limit to 2
+ {uint64(ents[0].Size() + ents[1].Size() + ents[2].Size()/2), []pb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}}},
+ {uint64(ents[0].Size() + ents[1].Size() + ents[2].Size() - 1), []pb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}}},
+ // all
+ {uint64(ents[0].Size() + ents[1].Size() + ents[2].Size()), []pb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 6}}},
+ }
+
+ for i, tt := range tests {
+ if !reflect.DeepEqual(limitSize(ents, tt.maxsize), tt.wentries) {
+ t.Errorf("#%d: entries = %v, want %v", i, limitSize(ents, tt.maxsize), tt.wentries)
+ }
+ }
+}
+
+func TestIsLocalMsg(t *testing.T) {
+ tests := []struct {
+ msgt pb.MessageType
+ isLocal bool
+ }{
+ {pb.MsgHup, true},
+ {pb.MsgBeat, true},
+ {pb.MsgUnreachable, true},
+ {pb.MsgSnapStatus, true},
+ {pb.MsgCheckQuorum, true},
+ {pb.MsgTransferLeader, false},
+ {pb.MsgProp, false},
+ {pb.MsgApp, false},
+ {pb.MsgAppResp, false},
+ {pb.MsgVote, false},
+ {pb.MsgVoteResp, false},
+ {pb.MsgSnap, false},
+ {pb.MsgHeartbeat, false},
+ {pb.MsgHeartbeatResp, false},
+ {pb.MsgTimeoutNow, false},
+ {pb.MsgReadIndex, false},
+ {pb.MsgReadIndexResp, false},
+ {pb.MsgPreVote, false},
+ {pb.MsgPreVoteResp, false},
+ }
+
+ for i, tt := range tests {
+ got := IsLocalMsg(tt.msgt)
+ if got != tt.isLocal {
+ t.Errorf("#%d: got %v, want %v", i, got, tt.isLocal)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/coder.go b/vendor/github.com/coreos/etcd/rafthttp/coder.go
new file mode 100644
index 00000000..86ede972
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/coder.go
@@ -0,0 +1,27 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import "github.com/coreos/etcd/raft/raftpb"
+
+type encoder interface {
+ // encode encodes the given message to an output stream.
+ encode(m *raftpb.Message) error
+}
+
+type decoder interface {
+ // decode decodes the message from an input stream.
+ decode() (raftpb.Message, error)
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/doc.go b/vendor/github.com/coreos/etcd/rafthttp/doc.go
new file mode 100644
index 00000000..a9486a8b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp implements HTTP transportation layer for etcd/raft pkg.
+package rafthttp
diff --git a/vendor/github.com/coreos/etcd/rafthttp/fake_roundtripper_test.go b/vendor/github.com/coreos/etcd/rafthttp/fake_roundtripper_test.go
new file mode 100644
index 00000000..4e17dee8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/fake_roundtripper_test.go
@@ -0,0 +1,38 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "errors"
+ "net/http"
+)
+
+func (t *roundTripperBlocker) RoundTrip(req *http.Request) (*http.Response, error) {
+ c := make(chan struct{}, 1)
+ t.mu.Lock()
+ t.cancel[req] = c
+ t.mu.Unlock()
+ ctx := req.Context()
+ select {
+ case <-t.unblockc:
+ return &http.Response{StatusCode: http.StatusNoContent, Body: &nopReadCloser{}}, nil
+ case <-req.Cancel:
+ return nil, errors.New("request canceled")
+ case <-ctx.Done():
+ return nil, errors.New("request canceled")
+ case <-c:
+ return nil, errors.New("request canceled")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/functional_test.go b/vendor/github.com/coreos/etcd/rafthttp/functional_test.go
new file mode 100644
index 00000000..b4f04d3e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/functional_test.go
@@ -0,0 +1,178 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "net/http/httptest"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/stats"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+ "golang.org/x/net/context"
+)
+
+func TestSendMessage(t *testing.T) {
+ // member 1
+ tr := &Transport{
+ ID: types.ID(1),
+ ClusterID: types.ID(1),
+ Raft: &fakeRaft{},
+ ServerStats: newServerStats(),
+ LeaderStats: stats.NewLeaderStats("1"),
+ }
+ tr.Start()
+ srv := httptest.NewServer(tr.Handler())
+ defer srv.Close()
+
+ // member 2
+ recvc := make(chan raftpb.Message, 1)
+ p := &fakeRaft{recvc: recvc}
+ tr2 := &Transport{
+ ID: types.ID(2),
+ ClusterID: types.ID(1),
+ Raft: p,
+ ServerStats: newServerStats(),
+ LeaderStats: stats.NewLeaderStats("2"),
+ }
+ tr2.Start()
+ srv2 := httptest.NewServer(tr2.Handler())
+ defer srv2.Close()
+
+ tr.AddPeer(types.ID(2), []string{srv2.URL})
+ defer tr.Stop()
+ tr2.AddPeer(types.ID(1), []string{srv.URL})
+ defer tr2.Stop()
+ if !waitStreamWorking(tr.Get(types.ID(2)).(*peer)) {
+ t.Fatalf("stream from 1 to 2 is not in work as expected")
+ }
+
+ data := []byte("some data")
+ tests := []raftpb.Message{
+ // these messages are set to send to itself, which facilitates testing.
+ {Type: raftpb.MsgProp, From: 1, To: 2, Entries: []raftpb.Entry{{Data: data}}},
+ {Type: raftpb.MsgApp, From: 1, To: 2, Term: 1, Index: 3, LogTerm: 0, Entries: []raftpb.Entry{{Index: 4, Term: 1, Data: data}}, Commit: 3},
+ {Type: raftpb.MsgAppResp, From: 1, To: 2, Term: 1, Index: 3},
+ {Type: raftpb.MsgVote, From: 1, To: 2, Term: 1, Index: 3, LogTerm: 0},
+ {Type: raftpb.MsgVoteResp, From: 1, To: 2, Term: 1},
+ {Type: raftpb.MsgSnap, From: 1, To: 2, Term: 1, Snapshot: raftpb.Snapshot{Metadata: raftpb.SnapshotMetadata{Index: 1000, Term: 1}, Data: data}},
+ {Type: raftpb.MsgHeartbeat, From: 1, To: 2, Term: 1, Commit: 3},
+ {Type: raftpb.MsgHeartbeatResp, From: 1, To: 2, Term: 1},
+ }
+ for i, tt := range tests {
+ tr.Send([]raftpb.Message{tt})
+ msg := <-recvc
+ if !reflect.DeepEqual(msg, tt) {
+ t.Errorf("#%d: msg = %+v, want %+v", i, msg, tt)
+ }
+ }
+}
+
+// TestSendMessageWhenStreamIsBroken tests that message can be sent to the
+// remote in a limited time when all underlying connections are broken.
+func TestSendMessageWhenStreamIsBroken(t *testing.T) {
+ // member 1
+ tr := &Transport{
+ ID: types.ID(1),
+ ClusterID: types.ID(1),
+ Raft: &fakeRaft{},
+ ServerStats: newServerStats(),
+ LeaderStats: stats.NewLeaderStats("1"),
+ }
+ tr.Start()
+ srv := httptest.NewServer(tr.Handler())
+ defer srv.Close()
+
+ // member 2
+ recvc := make(chan raftpb.Message, 1)
+ p := &fakeRaft{recvc: recvc}
+ tr2 := &Transport{
+ ID: types.ID(2),
+ ClusterID: types.ID(1),
+ Raft: p,
+ ServerStats: newServerStats(),
+ LeaderStats: stats.NewLeaderStats("2"),
+ }
+ tr2.Start()
+ srv2 := httptest.NewServer(tr2.Handler())
+ defer srv2.Close()
+
+ tr.AddPeer(types.ID(2), []string{srv2.URL})
+ defer tr.Stop()
+ tr2.AddPeer(types.ID(1), []string{srv.URL})
+ defer tr2.Stop()
+ if !waitStreamWorking(tr.Get(types.ID(2)).(*peer)) {
+ t.Fatalf("stream from 1 to 2 is not in work as expected")
+ }
+
+ // break the stream
+ srv.CloseClientConnections()
+ srv2.CloseClientConnections()
+ var n int
+ for {
+ select {
+ // TODO: remove this resend logic when we add retry logic into the code
+ case <-time.After(time.Millisecond):
+ n++
+ tr.Send([]raftpb.Message{{Type: raftpb.MsgHeartbeat, From: 1, To: 2, Term: 1, Commit: 3}})
+ case <-recvc:
+ if n > 50 {
+ t.Errorf("disconnection time = %dms, want < 50ms", n)
+ }
+ return
+ }
+ }
+}
+
+func newServerStats() *stats.ServerStats {
+ return stats.NewServerStats("", "")
+}
+
+func waitStreamWorking(p *peer) bool {
+ for i := 0; i < 1000; i++ {
+ time.Sleep(time.Millisecond)
+ if _, ok := p.msgAppV2Writer.writec(); !ok {
+ continue
+ }
+ if _, ok := p.writer.writec(); !ok {
+ continue
+ }
+ return true
+ }
+ return false
+}
+
+type fakeRaft struct {
+ recvc chan<- raftpb.Message
+ err error
+ removedID uint64
+}
+
+func (p *fakeRaft) Process(ctx context.Context, m raftpb.Message) error {
+ select {
+ case p.recvc <- m:
+ default:
+ }
+ return p.err
+}
+
+func (p *fakeRaft) IsIDRemoved(id uint64) bool { return id == p.removedID }
+
+func (p *fakeRaft) ReportUnreachable(id uint64) {}
+
+func (p *fakeRaft) ReportSnapshot(id uint64, status raft.SnapshotStatus) {}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/http.go b/vendor/github.com/coreos/etcd/rafthttp/http.go
new file mode 100644
index 00000000..55df26e9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/http.go
@@ -0,0 +1,359 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "errors"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "path"
+ "strings"
+
+ pioutil "github.com/coreos/etcd/pkg/ioutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/snap"
+ "github.com/coreos/etcd/version"
+ "golang.org/x/net/context"
+)
+
+const (
+ // connReadLimitByte limits the number of bytes
+ // a single read can read out.
+ //
+ // 64KB should be large enough for not causing
+ // throughput bottleneck as well as small enough
+ // for not causing a read timeout.
+ connReadLimitByte = 64 * 1024
+)
+
+var (
+ RaftPrefix = "/raft"
+ ProbingPrefix = path.Join(RaftPrefix, "probing")
+ RaftStreamPrefix = path.Join(RaftPrefix, "stream")
+ RaftSnapshotPrefix = path.Join(RaftPrefix, "snapshot")
+
+ errIncompatibleVersion = errors.New("incompatible version")
+ errClusterIDMismatch = errors.New("cluster ID mismatch")
+)
+
+type peerGetter interface {
+ Get(id types.ID) Peer
+}
+
+type writerToResponse interface {
+ WriteTo(w http.ResponseWriter)
+}
+
+type pipelineHandler struct {
+ tr Transporter
+ r Raft
+ cid types.ID
+}
+
+// newPipelineHandler returns a handler for handling raft messages
+// from pipeline for RaftPrefix.
+//
+// The handler reads out the raft message from request body,
+// and forwards it to the given raft state machine for processing.
+func newPipelineHandler(tr Transporter, r Raft, cid types.ID) http.Handler {
+ return &pipelineHandler{
+ tr: tr,
+ r: r,
+ cid: cid,
+ }
+}
+
+func (h *pipelineHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ if r.Method != "POST" {
+ w.Header().Set("Allow", "POST")
+ http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
+ return
+ }
+
+ w.Header().Set("X-Etcd-Cluster-ID", h.cid.String())
+
+ if err := checkClusterCompatibilityFromHeader(r.Header, h.cid); err != nil {
+ http.Error(w, err.Error(), http.StatusPreconditionFailed)
+ return
+ }
+
+ if from, err := types.IDFromString(r.Header.Get("X-Server-From")); err != nil {
+ if urls := r.Header.Get("X-PeerURLs"); urls != "" {
+ h.tr.AddRemote(from, strings.Split(urls, ","))
+ }
+ }
+
+ // Limit the data size that could be read from the request body, which ensures that read from
+ // connection will not time out accidentally due to possible blocking in underlying implementation.
+ limitedr := pioutil.NewLimitedBufferReader(r.Body, connReadLimitByte)
+ b, err := ioutil.ReadAll(limitedr)
+ if err != nil {
+ plog.Errorf("failed to read raft message (%v)", err)
+ http.Error(w, "error reading raft message", http.StatusBadRequest)
+ recvFailures.WithLabelValues(r.RemoteAddr).Inc()
+ return
+ }
+
+ var m raftpb.Message
+ if err := m.Unmarshal(b); err != nil {
+ plog.Errorf("failed to unmarshal raft message (%v)", err)
+ http.Error(w, "error unmarshaling raft message", http.StatusBadRequest)
+ recvFailures.WithLabelValues(r.RemoteAddr).Inc()
+ return
+ }
+
+ receivedBytes.WithLabelValues(types.ID(m.From).String()).Add(float64(len(b)))
+
+ if err := h.r.Process(context.TODO(), m); err != nil {
+ switch v := err.(type) {
+ case writerToResponse:
+ v.WriteTo(w)
+ default:
+ plog.Warningf("failed to process raft message (%v)", err)
+ http.Error(w, "error processing raft message", http.StatusInternalServerError)
+ w.(http.Flusher).Flush()
+ // disconnect the http stream
+ panic(err)
+ }
+ return
+ }
+
+ // Write StatusNoContent header after the message has been processed by
+ // raft, which facilitates the client to report MsgSnap status.
+ w.WriteHeader(http.StatusNoContent)
+}
+
+type snapshotHandler struct {
+ tr Transporter
+ r Raft
+ snapshotter *snap.Snapshotter
+ cid types.ID
+}
+
+func newSnapshotHandler(tr Transporter, r Raft, snapshotter *snap.Snapshotter, cid types.ID) http.Handler {
+ return &snapshotHandler{
+ tr: tr,
+ r: r,
+ snapshotter: snapshotter,
+ cid: cid,
+ }
+}
+
+// ServeHTTP serves HTTP request to receive and process snapshot message.
+//
+// If request sender dies without closing underlying TCP connection,
+// the handler will keep waiting for the request body until TCP keepalive
+// finds out that the connection is broken after several minutes.
+// This is acceptable because
+// 1. snapshot messages sent through other TCP connections could still be
+// received and processed.
+// 2. this case should happen rarely, so no further optimization is done.
+func (h *snapshotHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ if r.Method != "POST" {
+ w.Header().Set("Allow", "POST")
+ http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
+ return
+ }
+
+ w.Header().Set("X-Etcd-Cluster-ID", h.cid.String())
+
+ if err := checkClusterCompatibilityFromHeader(r.Header, h.cid); err != nil {
+ http.Error(w, err.Error(), http.StatusPreconditionFailed)
+ return
+ }
+
+ if from, err := types.IDFromString(r.Header.Get("X-Server-From")); err != nil {
+ if urls := r.Header.Get("X-PeerURLs"); urls != "" {
+ h.tr.AddRemote(from, strings.Split(urls, ","))
+ }
+ }
+
+ dec := &messageDecoder{r: r.Body}
+ // let snapshots be very large since they can exceed 512MB for large installations
+ m, err := dec.decodeLimit(uint64(1 << 63))
+ if err != nil {
+ msg := fmt.Sprintf("failed to decode raft message (%v)", err)
+ plog.Errorf(msg)
+ http.Error(w, msg, http.StatusBadRequest)
+ recvFailures.WithLabelValues(r.RemoteAddr).Inc()
+ return
+ }
+
+ receivedBytes.WithLabelValues(types.ID(m.From).String()).Add(float64(m.Size()))
+
+ if m.Type != raftpb.MsgSnap {
+ plog.Errorf("unexpected raft message type %s on snapshot path", m.Type)
+ http.Error(w, "wrong raft message type", http.StatusBadRequest)
+ return
+ }
+
+ plog.Infof("receiving database snapshot [index:%d, from %s] ...", m.Snapshot.Metadata.Index, types.ID(m.From))
+ // save incoming database snapshot.
+ n, err := h.snapshotter.SaveDBFrom(r.Body, m.Snapshot.Metadata.Index)
+ if err != nil {
+ msg := fmt.Sprintf("failed to save KV snapshot (%v)", err)
+ plog.Error(msg)
+ http.Error(w, msg, http.StatusInternalServerError)
+ return
+ }
+ receivedBytes.WithLabelValues(types.ID(m.From).String()).Add(float64(n))
+ plog.Infof("received and saved database snapshot [index: %d, from: %s] successfully", m.Snapshot.Metadata.Index, types.ID(m.From))
+
+ if err := h.r.Process(context.TODO(), m); err != nil {
+ switch v := err.(type) {
+ // Process may return writerToResponse error when doing some
+ // additional checks before calling raft.Node.Step.
+ case writerToResponse:
+ v.WriteTo(w)
+ default:
+ msg := fmt.Sprintf("failed to process raft message (%v)", err)
+ plog.Warningf(msg)
+ http.Error(w, msg, http.StatusInternalServerError)
+ }
+ return
+ }
+ // Write StatusNoContent header after the message has been processed by
+ // raft, which facilitates the client to report MsgSnap status.
+ w.WriteHeader(http.StatusNoContent)
+}
+
+type streamHandler struct {
+ tr *Transport
+ peerGetter peerGetter
+ r Raft
+ id types.ID
+ cid types.ID
+}
+
+func newStreamHandler(tr *Transport, pg peerGetter, r Raft, id, cid types.ID) http.Handler {
+ return &streamHandler{
+ tr: tr,
+ peerGetter: pg,
+ r: r,
+ id: id,
+ cid: cid,
+ }
+}
+
+func (h *streamHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ if r.Method != "GET" {
+ w.Header().Set("Allow", "GET")
+ http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
+ return
+ }
+
+ w.Header().Set("X-Server-Version", version.Version)
+ w.Header().Set("X-Etcd-Cluster-ID", h.cid.String())
+
+ if err := checkClusterCompatibilityFromHeader(r.Header, h.cid); err != nil {
+ http.Error(w, err.Error(), http.StatusPreconditionFailed)
+ return
+ }
+
+ var t streamType
+ switch path.Dir(r.URL.Path) {
+ case streamTypeMsgAppV2.endpoint():
+ t = streamTypeMsgAppV2
+ case streamTypeMessage.endpoint():
+ t = streamTypeMessage
+ default:
+ plog.Debugf("ignored unexpected streaming request path %s", r.URL.Path)
+ http.Error(w, "invalid path", http.StatusNotFound)
+ return
+ }
+
+ fromStr := path.Base(r.URL.Path)
+ from, err := types.IDFromString(fromStr)
+ if err != nil {
+ plog.Errorf("failed to parse from %s into ID (%v)", fromStr, err)
+ http.Error(w, "invalid from", http.StatusNotFound)
+ return
+ }
+ if h.r.IsIDRemoved(uint64(from)) {
+ plog.Warningf("rejected the stream from peer %s since it was removed", from)
+ http.Error(w, "removed member", http.StatusGone)
+ return
+ }
+ p := h.peerGetter.Get(from)
+ if p == nil {
+ // This may happen in following cases:
+ // 1. user starts a remote peer that belongs to a different cluster
+ // with the same cluster ID.
+ // 2. local etcd falls behind of the cluster, and cannot recognize
+ // the members that joined after its current progress.
+ if urls := r.Header.Get("X-PeerURLs"); urls != "" {
+ h.tr.AddRemote(from, strings.Split(urls, ","))
+ }
+ plog.Errorf("failed to find member %s in cluster %s", from, h.cid)
+ http.Error(w, "error sender not found", http.StatusNotFound)
+ return
+ }
+
+ wto := h.id.String()
+ if gto := r.Header.Get("X-Raft-To"); gto != wto {
+ plog.Errorf("streaming request ignored (ID mismatch got %s want %s)", gto, wto)
+ http.Error(w, "to field mismatch", http.StatusPreconditionFailed)
+ return
+ }
+
+ w.WriteHeader(http.StatusOK)
+ w.(http.Flusher).Flush()
+
+ c := newCloseNotifier()
+ conn := &outgoingConn{
+ t: t,
+ Writer: w,
+ Flusher: w.(http.Flusher),
+ Closer: c,
+ }
+ p.attachOutgoingConn(conn)
+ <-c.closeNotify()
+}
+
+// checkClusterCompatibilityFromHeader checks the cluster compatibility of
+// the local member from the given header.
+// It checks whether the version of local member is compatible with
+// the versions in the header, and whether the cluster ID of local member
+// matches the one in the header.
+func checkClusterCompatibilityFromHeader(header http.Header, cid types.ID) error {
+ if err := checkVersionCompability(header.Get("X-Server-From"), serverVersion(header), minClusterVersion(header)); err != nil {
+ plog.Errorf("request version incompatibility (%v)", err)
+ return errIncompatibleVersion
+ }
+ if gcid := header.Get("X-Etcd-Cluster-ID"); gcid != cid.String() {
+ plog.Errorf("request cluster ID mismatch (got %s want %s)", gcid, cid)
+ return errClusterIDMismatch
+ }
+ return nil
+}
+
+type closeNotifier struct {
+ done chan struct{}
+}
+
+func newCloseNotifier() *closeNotifier {
+ return &closeNotifier{
+ done: make(chan struct{}),
+ }
+}
+
+func (n *closeNotifier) Close() error {
+ close(n.done)
+ return nil
+}
+
+func (n *closeNotifier) closeNotify() <-chan struct{} { return n.done }
diff --git a/vendor/github.com/coreos/etcd/rafthttp/http_test.go b/vendor/github.com/coreos/etcd/rafthttp/http_test.go
new file mode 100644
index 00000000..e7f6e034
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/http_test.go
@@ -0,0 +1,392 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "bytes"
+ "errors"
+ "fmt"
+ "io"
+ "net/http"
+ "net/http/httptest"
+ "net/url"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/snap"
+ "github.com/coreos/etcd/version"
+)
+
+func TestServeRaftPrefix(t *testing.T) {
+ testCases := []struct {
+ method string
+ body io.Reader
+ p Raft
+ clusterID string
+
+ wcode int
+ }{
+ {
+ // bad method
+ "GET",
+ bytes.NewReader(
+ pbutil.MustMarshal(&raftpb.Message{}),
+ ),
+ &fakeRaft{},
+ "0",
+ http.StatusMethodNotAllowed,
+ },
+ {
+ // bad method
+ "PUT",
+ bytes.NewReader(
+ pbutil.MustMarshal(&raftpb.Message{}),
+ ),
+ &fakeRaft{},
+ "0",
+ http.StatusMethodNotAllowed,
+ },
+ {
+ // bad method
+ "DELETE",
+ bytes.NewReader(
+ pbutil.MustMarshal(&raftpb.Message{}),
+ ),
+ &fakeRaft{},
+ "0",
+ http.StatusMethodNotAllowed,
+ },
+ {
+ // bad request body
+ "POST",
+ &errReader{},
+ &fakeRaft{},
+ "0",
+ http.StatusBadRequest,
+ },
+ {
+ // bad request protobuf
+ "POST",
+ strings.NewReader("malformed garbage"),
+ &fakeRaft{},
+ "0",
+ http.StatusBadRequest,
+ },
+ {
+ // good request, wrong cluster ID
+ "POST",
+ bytes.NewReader(
+ pbutil.MustMarshal(&raftpb.Message{}),
+ ),
+ &fakeRaft{},
+ "1",
+ http.StatusPreconditionFailed,
+ },
+ {
+ // good request, Processor failure
+ "POST",
+ bytes.NewReader(
+ pbutil.MustMarshal(&raftpb.Message{}),
+ ),
+ &fakeRaft{
+ err: &resWriterToError{code: http.StatusForbidden},
+ },
+ "0",
+ http.StatusForbidden,
+ },
+ {
+ // good request, Processor failure
+ "POST",
+ bytes.NewReader(
+ pbutil.MustMarshal(&raftpb.Message{}),
+ ),
+ &fakeRaft{
+ err: &resWriterToError{code: http.StatusInternalServerError},
+ },
+ "0",
+ http.StatusInternalServerError,
+ },
+ {
+ // good request, Processor failure
+ "POST",
+ bytes.NewReader(
+ pbutil.MustMarshal(&raftpb.Message{}),
+ ),
+ &fakeRaft{err: errors.New("blah")},
+ "0",
+ http.StatusInternalServerError,
+ },
+ {
+ // good request
+ "POST",
+ bytes.NewReader(
+ pbutil.MustMarshal(&raftpb.Message{}),
+ ),
+ &fakeRaft{},
+ "0",
+ http.StatusNoContent,
+ },
+ }
+ for i, tt := range testCases {
+ req, err := http.NewRequest(tt.method, "foo", tt.body)
+ if err != nil {
+ t.Fatalf("#%d: could not create request: %#v", i, err)
+ }
+ req.Header.Set("X-Etcd-Cluster-ID", tt.clusterID)
+ req.Header.Set("X-Server-Version", version.Version)
+ rw := httptest.NewRecorder()
+ h := newPipelineHandler(NewNopTransporter(), tt.p, types.ID(0))
+
+ // goroutine because the handler panics to disconnect on raft error
+ donec := make(chan struct{})
+ go func() {
+ defer func() {
+ recover()
+ close(donec)
+ }()
+ h.ServeHTTP(rw, req)
+ }()
+ <-donec
+
+ if rw.Code != tt.wcode {
+ t.Errorf("#%d: got code=%d, want %d", i, rw.Code, tt.wcode)
+ }
+ }
+}
+
+func TestServeRaftStreamPrefix(t *testing.T) {
+ tests := []struct {
+ path string
+ wtype streamType
+ }{
+ {
+ RaftStreamPrefix + "/message/1",
+ streamTypeMessage,
+ },
+ {
+ RaftStreamPrefix + "/msgapp/1",
+ streamTypeMsgAppV2,
+ },
+ }
+ for i, tt := range tests {
+ req, err := http.NewRequest("GET", "http://localhost:2380"+tt.path, nil)
+ if err != nil {
+ t.Fatalf("#%d: could not create request: %#v", i, err)
+ }
+ req.Header.Set("X-Etcd-Cluster-ID", "1")
+ req.Header.Set("X-Server-Version", version.Version)
+ req.Header.Set("X-Raft-To", "2")
+
+ peer := newFakePeer()
+ peerGetter := &fakePeerGetter{peers: map[types.ID]Peer{types.ID(1): peer}}
+ tr := &Transport{}
+ h := newStreamHandler(tr, peerGetter, &fakeRaft{}, types.ID(2), types.ID(1))
+
+ rw := httptest.NewRecorder()
+ go h.ServeHTTP(rw, req)
+
+ var conn *outgoingConn
+ select {
+ case conn = <-peer.connc:
+ case <-time.After(time.Second):
+ t.Fatalf("#%d: failed to attach outgoingConn", i)
+ }
+ if g := rw.Header().Get("X-Server-Version"); g != version.Version {
+ t.Errorf("#%d: X-Server-Version = %s, want %s", i, g, version.Version)
+ }
+ if conn.t != tt.wtype {
+ t.Errorf("#%d: type = %s, want %s", i, conn.t, tt.wtype)
+ }
+ conn.Close()
+ }
+}
+
+func TestServeRaftStreamPrefixBad(t *testing.T) {
+ removedID := uint64(5)
+ tests := []struct {
+ method string
+ path string
+ clusterID string
+ remote string
+
+ wcode int
+ }{
+ // bad method
+ {
+ "PUT",
+ RaftStreamPrefix + "/message/1",
+ "1",
+ "1",
+ http.StatusMethodNotAllowed,
+ },
+ // bad method
+ {
+ "POST",
+ RaftStreamPrefix + "/message/1",
+ "1",
+ "1",
+ http.StatusMethodNotAllowed,
+ },
+ // bad method
+ {
+ "DELETE",
+ RaftStreamPrefix + "/message/1",
+ "1",
+ "1",
+ http.StatusMethodNotAllowed,
+ },
+ // bad path
+ {
+ "GET",
+ RaftStreamPrefix + "/strange/1",
+ "1",
+ "1",
+ http.StatusNotFound,
+ },
+ // bad path
+ {
+ "GET",
+ RaftStreamPrefix + "/strange",
+ "1",
+ "1",
+ http.StatusNotFound,
+ },
+ // non-existent peer
+ {
+ "GET",
+ RaftStreamPrefix + "/message/2",
+ "1",
+ "1",
+ http.StatusNotFound,
+ },
+ // removed peer
+ {
+ "GET",
+ RaftStreamPrefix + "/message/" + fmt.Sprint(removedID),
+ "1",
+ "1",
+ http.StatusGone,
+ },
+ // wrong cluster ID
+ {
+ "GET",
+ RaftStreamPrefix + "/message/1",
+ "2",
+ "1",
+ http.StatusPreconditionFailed,
+ },
+ // wrong remote id
+ {
+ "GET",
+ RaftStreamPrefix + "/message/1",
+ "1",
+ "2",
+ http.StatusPreconditionFailed,
+ },
+ }
+ for i, tt := range tests {
+ req, err := http.NewRequest(tt.method, "http://localhost:2380"+tt.path, nil)
+ if err != nil {
+ t.Fatalf("#%d: could not create request: %#v", i, err)
+ }
+ req.Header.Set("X-Etcd-Cluster-ID", tt.clusterID)
+ req.Header.Set("X-Server-Version", version.Version)
+ req.Header.Set("X-Raft-To", tt.remote)
+ rw := httptest.NewRecorder()
+ tr := &Transport{}
+ peerGetter := &fakePeerGetter{peers: map[types.ID]Peer{types.ID(1): newFakePeer()}}
+ r := &fakeRaft{removedID: removedID}
+ h := newStreamHandler(tr, peerGetter, r, types.ID(1), types.ID(1))
+ h.ServeHTTP(rw, req)
+
+ if rw.Code != tt.wcode {
+ t.Errorf("#%d: code = %d, want %d", i, rw.Code, tt.wcode)
+ }
+ }
+}
+
+func TestCloseNotifier(t *testing.T) {
+ c := newCloseNotifier()
+ select {
+ case <-c.closeNotify():
+ t.Fatalf("received unexpected close notification")
+ default:
+ }
+ c.Close()
+ select {
+ case <-c.closeNotify():
+ default:
+ t.Fatalf("failed to get close notification")
+ }
+}
+
+// errReader implements io.Reader to facilitate a broken request.
+type errReader struct{}
+
+func (er *errReader) Read(_ []byte) (int, error) { return 0, errors.New("some error") }
+
+type resWriterToError struct {
+ code int
+}
+
+func (e *resWriterToError) Error() string { return "" }
+func (e *resWriterToError) WriteTo(w http.ResponseWriter) { w.WriteHeader(e.code) }
+
+type fakePeerGetter struct {
+ peers map[types.ID]Peer
+}
+
+func (pg *fakePeerGetter) Get(id types.ID) Peer { return pg.peers[id] }
+
+type fakePeer struct {
+ msgs []raftpb.Message
+ snapMsgs []snap.Message
+ peerURLs types.URLs
+ connc chan *outgoingConn
+ paused bool
+}
+
+func newFakePeer() *fakePeer {
+ fakeURL, _ := url.Parse("http://localhost")
+ return &fakePeer{
+ connc: make(chan *outgoingConn, 1),
+ peerURLs: types.URLs{*fakeURL},
+ }
+}
+
+func (pr *fakePeer) send(m raftpb.Message) {
+ if pr.paused {
+ return
+ }
+ pr.msgs = append(pr.msgs, m)
+}
+
+func (pr *fakePeer) sendSnap(m snap.Message) {
+ if pr.paused {
+ return
+ }
+ pr.snapMsgs = append(pr.snapMsgs, m)
+}
+
+func (pr *fakePeer) update(urls types.URLs) { pr.peerURLs = urls }
+func (pr *fakePeer) attachOutgoingConn(conn *outgoingConn) { pr.connc <- conn }
+func (pr *fakePeer) activeSince() time.Time { return time.Time{} }
+func (pr *fakePeer) stop() {}
+func (pr *fakePeer) Pause() { pr.paused = true }
+func (pr *fakePeer) Resume() { pr.paused = false }
diff --git a/vendor/github.com/coreos/etcd/rafthttp/metrics.go b/vendor/github.com/coreos/etcd/rafthttp/metrics.go
new file mode 100644
index 00000000..320bfe72
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/metrics.go
@@ -0,0 +1,73 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import "github.com/prometheus/client_golang/prometheus"
+
+var (
+ sentBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "network",
+ Name: "peer_sent_bytes_total",
+ Help: "The total number of bytes sent to peers.",
+ },
+ []string{"To"},
+ )
+
+ receivedBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "network",
+ Name: "peer_received_bytes_total",
+ Help: "The total number of bytes received from peers.",
+ },
+ []string{"From"},
+ )
+
+ sentFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "network",
+ Name: "peer_sent_failures_total",
+ Help: "The total number of send failures from peers.",
+ },
+ []string{"To"},
+ )
+
+ recvFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "network",
+ Name: "peer_received_failures_total",
+ Help: "The total number of receive failures from peers.",
+ },
+ []string{"From"},
+ )
+
+ rtts = prometheus.NewHistogramVec(prometheus.HistogramOpts{
+ Namespace: "etcd",
+ Subsystem: "network",
+ Name: "peer_round_trip_time_seconds",
+ Help: "Round-Trip-Time histogram between peers.",
+ Buckets: prometheus.ExponentialBuckets(0.0001, 2, 14),
+ },
+ []string{"To"},
+ )
+)
+
+func init() {
+ prometheus.MustRegister(sentBytes)
+ prometheus.MustRegister(receivedBytes)
+ prometheus.MustRegister(sentFailures)
+ prometheus.MustRegister(recvFailures)
+ prometheus.MustRegister(rtts)
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/msg_codec.go b/vendor/github.com/coreos/etcd/rafthttp/msg_codec.go
new file mode 100644
index 00000000..ef59bc88
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/msg_codec.go
@@ -0,0 +1,68 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "encoding/binary"
+ "errors"
+ "io"
+
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+// messageEncoder is a encoder that can encode all kinds of messages.
+// It MUST be used with a paired messageDecoder.
+type messageEncoder struct {
+ w io.Writer
+}
+
+func (enc *messageEncoder) encode(m *raftpb.Message) error {
+ if err := binary.Write(enc.w, binary.BigEndian, uint64(m.Size())); err != nil {
+ return err
+ }
+ _, err := enc.w.Write(pbutil.MustMarshal(m))
+ return err
+}
+
+// messageDecoder is a decoder that can decode all kinds of messages.
+type messageDecoder struct {
+ r io.Reader
+}
+
+var (
+ readBytesLimit uint64 = 512 * 1024 * 1024 // 512 MB
+ ErrExceedSizeLimit = errors.New("rafthttp: error limit exceeded")
+)
+
+func (dec *messageDecoder) decode() (raftpb.Message, error) {
+ return dec.decodeLimit(readBytesLimit)
+}
+
+func (dec *messageDecoder) decodeLimit(numBytes uint64) (raftpb.Message, error) {
+ var m raftpb.Message
+ var l uint64
+ if err := binary.Read(dec.r, binary.BigEndian, &l); err != nil {
+ return m, err
+ }
+ if l > numBytes {
+ return m, ErrExceedSizeLimit
+ }
+ buf := make([]byte, int(l))
+ if _, err := io.ReadFull(dec.r, buf); err != nil {
+ return m, err
+ }
+ return m, m.Unmarshal(buf)
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/msg_codec_test.go b/vendor/github.com/coreos/etcd/rafthttp/msg_codec_test.go
new file mode 100644
index 00000000..6e927713
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/msg_codec_test.go
@@ -0,0 +1,96 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "bytes"
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+func TestMessage(t *testing.T) {
+ // Lower readBytesLimit to make test pass in restricted resources environment
+ originalLimit := readBytesLimit
+ readBytesLimit = 1000
+ defer func() {
+ readBytesLimit = originalLimit
+ }()
+ tests := []struct {
+ msg raftpb.Message
+ encodeErr error
+ decodeErr error
+ }{
+ {
+ raftpb.Message{
+ Type: raftpb.MsgApp,
+ From: 1,
+ To: 2,
+ Term: 1,
+ LogTerm: 1,
+ Index: 3,
+ Entries: []raftpb.Entry{{Term: 1, Index: 4}},
+ },
+ nil,
+ nil,
+ },
+ {
+ raftpb.Message{
+ Type: raftpb.MsgProp,
+ From: 1,
+ To: 2,
+ Entries: []raftpb.Entry{
+ {Data: []byte("some data")},
+ {Data: []byte("some data")},
+ {Data: []byte("some data")},
+ },
+ },
+ nil,
+ nil,
+ },
+ {
+ raftpb.Message{
+ Type: raftpb.MsgProp,
+ From: 1,
+ To: 2,
+ Entries: []raftpb.Entry{
+ {Data: bytes.Repeat([]byte("a"), int(readBytesLimit+10))},
+ },
+ },
+ nil,
+ ErrExceedSizeLimit,
+ },
+ }
+ for i, tt := range tests {
+ b := &bytes.Buffer{}
+ enc := &messageEncoder{w: b}
+ if err := enc.encode(&tt.msg); err != tt.encodeErr {
+ t.Errorf("#%d: encode message error expected %v, got %v", i, tt.encodeErr, err)
+ continue
+ }
+ dec := &messageDecoder{r: b}
+ m, err := dec.decode()
+ if err != tt.decodeErr {
+ t.Errorf("#%d: decode message error expected %v, got %v", i, tt.decodeErr, err)
+ continue
+ }
+ if err == nil {
+ if !reflect.DeepEqual(m, tt.msg) {
+ t.Errorf("#%d: message = %+v, want %+v", i, m, tt.msg)
+ }
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/msgappv2_codec.go b/vendor/github.com/coreos/etcd/rafthttp/msgappv2_codec.go
new file mode 100644
index 00000000..013ffe7c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/msgappv2_codec.go
@@ -0,0 +1,248 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "encoding/binary"
+ "fmt"
+ "io"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/stats"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+const (
+ msgTypeLinkHeartbeat uint8 = 0
+ msgTypeAppEntries uint8 = 1
+ msgTypeApp uint8 = 2
+
+ msgAppV2BufSize = 1024 * 1024
+)
+
+// msgappv2 stream sends three types of message: linkHeartbeatMessage,
+// AppEntries and MsgApp. AppEntries is the MsgApp that is sent in
+// replicate state in raft, whose index and term are fully predictable.
+//
+// Data format of linkHeartbeatMessage:
+// | offset | bytes | description |
+// +--------+-------+-------------+
+// | 0 | 1 | \x00 |
+//
+// Data format of AppEntries:
+// | offset | bytes | description |
+// +--------+-------+-------------+
+// | 0 | 1 | \x01 |
+// | 1 | 8 | length of entries |
+// | 9 | 8 | length of first entry |
+// | 17 | n1 | first entry |
+// ...
+// | x | 8 | length of k-th entry data |
+// | x+8 | nk | k-th entry data |
+// | x+8+nk | 8 | commit index |
+//
+// Data format of MsgApp:
+// | offset | bytes | description |
+// +--------+-------+-------------+
+// | 0 | 1 | \x02 |
+// | 1 | 8 | length of encoded message |
+// | 9 | n | encoded message |
+type msgAppV2Encoder struct {
+ w io.Writer
+ fs *stats.FollowerStats
+
+ term uint64
+ index uint64
+ buf []byte
+ uint64buf []byte
+ uint8buf []byte
+}
+
+func newMsgAppV2Encoder(w io.Writer, fs *stats.FollowerStats) *msgAppV2Encoder {
+ return &msgAppV2Encoder{
+ w: w,
+ fs: fs,
+ buf: make([]byte, msgAppV2BufSize),
+ uint64buf: make([]byte, 8),
+ uint8buf: make([]byte, 1),
+ }
+}
+
+func (enc *msgAppV2Encoder) encode(m *raftpb.Message) error {
+ start := time.Now()
+ switch {
+ case isLinkHeartbeatMessage(m):
+ enc.uint8buf[0] = byte(msgTypeLinkHeartbeat)
+ if _, err := enc.w.Write(enc.uint8buf); err != nil {
+ return err
+ }
+ case enc.index == m.Index && enc.term == m.LogTerm && m.LogTerm == m.Term:
+ enc.uint8buf[0] = byte(msgTypeAppEntries)
+ if _, err := enc.w.Write(enc.uint8buf); err != nil {
+ return err
+ }
+ // write length of entries
+ binary.BigEndian.PutUint64(enc.uint64buf, uint64(len(m.Entries)))
+ if _, err := enc.w.Write(enc.uint64buf); err != nil {
+ return err
+ }
+ for i := 0; i < len(m.Entries); i++ {
+ // write length of entry
+ binary.BigEndian.PutUint64(enc.uint64buf, uint64(m.Entries[i].Size()))
+ if _, err := enc.w.Write(enc.uint64buf); err != nil {
+ return err
+ }
+ if n := m.Entries[i].Size(); n < msgAppV2BufSize {
+ if _, err := m.Entries[i].MarshalTo(enc.buf); err != nil {
+ return err
+ }
+ if _, err := enc.w.Write(enc.buf[:n]); err != nil {
+ return err
+ }
+ } else {
+ if _, err := enc.w.Write(pbutil.MustMarshal(&m.Entries[i])); err != nil {
+ return err
+ }
+ }
+ enc.index++
+ }
+ // write commit index
+ binary.BigEndian.PutUint64(enc.uint64buf, m.Commit)
+ if _, err := enc.w.Write(enc.uint64buf); err != nil {
+ return err
+ }
+ enc.fs.Succ(time.Since(start))
+ default:
+ if err := binary.Write(enc.w, binary.BigEndian, msgTypeApp); err != nil {
+ return err
+ }
+ // write size of message
+ if err := binary.Write(enc.w, binary.BigEndian, uint64(m.Size())); err != nil {
+ return err
+ }
+ // write message
+ if _, err := enc.w.Write(pbutil.MustMarshal(m)); err != nil {
+ return err
+ }
+
+ enc.term = m.Term
+ enc.index = m.Index
+ if l := len(m.Entries); l > 0 {
+ enc.index = m.Entries[l-1].Index
+ }
+ enc.fs.Succ(time.Since(start))
+ }
+ return nil
+}
+
+type msgAppV2Decoder struct {
+ r io.Reader
+ local, remote types.ID
+
+ term uint64
+ index uint64
+ buf []byte
+ uint64buf []byte
+ uint8buf []byte
+}
+
+func newMsgAppV2Decoder(r io.Reader, local, remote types.ID) *msgAppV2Decoder {
+ return &msgAppV2Decoder{
+ r: r,
+ local: local,
+ remote: remote,
+ buf: make([]byte, msgAppV2BufSize),
+ uint64buf: make([]byte, 8),
+ uint8buf: make([]byte, 1),
+ }
+}
+
+func (dec *msgAppV2Decoder) decode() (raftpb.Message, error) {
+ var (
+ m raftpb.Message
+ typ uint8
+ )
+ if _, err := io.ReadFull(dec.r, dec.uint8buf); err != nil {
+ return m, err
+ }
+ typ = uint8(dec.uint8buf[0])
+ switch typ {
+ case msgTypeLinkHeartbeat:
+ return linkHeartbeatMessage, nil
+ case msgTypeAppEntries:
+ m = raftpb.Message{
+ Type: raftpb.MsgApp,
+ From: uint64(dec.remote),
+ To: uint64(dec.local),
+ Term: dec.term,
+ LogTerm: dec.term,
+ Index: dec.index,
+ }
+
+ // decode entries
+ if _, err := io.ReadFull(dec.r, dec.uint64buf); err != nil {
+ return m, err
+ }
+ l := binary.BigEndian.Uint64(dec.uint64buf)
+ m.Entries = make([]raftpb.Entry, int(l))
+ for i := 0; i < int(l); i++ {
+ if _, err := io.ReadFull(dec.r, dec.uint64buf); err != nil {
+ return m, err
+ }
+ size := binary.BigEndian.Uint64(dec.uint64buf)
+ var buf []byte
+ if size < msgAppV2BufSize {
+ buf = dec.buf[:size]
+ if _, err := io.ReadFull(dec.r, buf); err != nil {
+ return m, err
+ }
+ } else {
+ buf = make([]byte, int(size))
+ if _, err := io.ReadFull(dec.r, buf); err != nil {
+ return m, err
+ }
+ }
+ dec.index++
+ // 1 alloc
+ pbutil.MustUnmarshal(&m.Entries[i], buf)
+ }
+ // decode commit index
+ if _, err := io.ReadFull(dec.r, dec.uint64buf); err != nil {
+ return m, err
+ }
+ m.Commit = binary.BigEndian.Uint64(dec.uint64buf)
+ case msgTypeApp:
+ var size uint64
+ if err := binary.Read(dec.r, binary.BigEndian, &size); err != nil {
+ return m, err
+ }
+ buf := make([]byte, int(size))
+ if _, err := io.ReadFull(dec.r, buf); err != nil {
+ return m, err
+ }
+ pbutil.MustUnmarshal(&m, buf)
+
+ dec.term = m.Term
+ dec.index = m.Index
+ if l := len(m.Entries); l > 0 {
+ dec.index = m.Entries[l-1].Index
+ }
+ default:
+ return m, fmt.Errorf("failed to parse type %d in msgappv2 stream", typ)
+ }
+ return m, nil
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/msgappv2_codec_test.go b/vendor/github.com/coreos/etcd/rafthttp/msgappv2_codec_test.go
new file mode 100644
index 00000000..394c63f0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/msgappv2_codec_test.go
@@ -0,0 +1,123 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "bytes"
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/etcdserver/stats"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+func TestMsgAppV2(t *testing.T) {
+ tests := []raftpb.Message{
+ linkHeartbeatMessage,
+ {
+ Type: raftpb.MsgApp,
+ From: 1,
+ To: 2,
+ Term: 1,
+ LogTerm: 1,
+ Index: 0,
+ Entries: []raftpb.Entry{
+ {Term: 1, Index: 1, Data: []byte("some data")},
+ {Term: 1, Index: 2, Data: []byte("some data")},
+ {Term: 1, Index: 3, Data: []byte("some data")},
+ },
+ },
+ // consecutive MsgApp
+ {
+ Type: raftpb.MsgApp,
+ From: 1,
+ To: 2,
+ Term: 1,
+ LogTerm: 1,
+ Index: 3,
+ Entries: []raftpb.Entry{
+ {Term: 1, Index: 4, Data: []byte("some data")},
+ },
+ },
+ linkHeartbeatMessage,
+ // consecutive MsgApp after linkHeartbeatMessage
+ {
+ Type: raftpb.MsgApp,
+ From: 1,
+ To: 2,
+ Term: 1,
+ LogTerm: 1,
+ Index: 4,
+ Entries: []raftpb.Entry{
+ {Term: 1, Index: 5, Data: []byte("some data")},
+ },
+ },
+ // MsgApp with higher term
+ {
+ Type: raftpb.MsgApp,
+ From: 1,
+ To: 2,
+ Term: 3,
+ LogTerm: 1,
+ Index: 5,
+ Entries: []raftpb.Entry{
+ {Term: 3, Index: 6, Data: []byte("some data")},
+ },
+ },
+ linkHeartbeatMessage,
+ // consecutive MsgApp
+ {
+ Type: raftpb.MsgApp,
+ From: 1,
+ To: 2,
+ Term: 3,
+ LogTerm: 2,
+ Index: 6,
+ Entries: []raftpb.Entry{
+ {Term: 3, Index: 7, Data: []byte("some data")},
+ },
+ },
+ // consecutive empty MsgApp
+ {
+ Type: raftpb.MsgApp,
+ From: 1,
+ To: 2,
+ Term: 3,
+ LogTerm: 2,
+ Index: 7,
+ Entries: nil,
+ },
+ linkHeartbeatMessage,
+ }
+ b := &bytes.Buffer{}
+ enc := newMsgAppV2Encoder(b, &stats.FollowerStats{})
+ dec := newMsgAppV2Decoder(b, types.ID(2), types.ID(1))
+
+ for i, tt := range tests {
+ if err := enc.encode(&tt); err != nil {
+ t.Errorf("#%d: unexpected encode message error: %v", i, err)
+ continue
+ }
+ m, err := dec.decode()
+ if err != nil {
+ t.Errorf("#%d: unexpected decode message error: %v", i, err)
+ continue
+ }
+ if !reflect.DeepEqual(m, tt) {
+ t.Errorf("#%d: message = %+v, want %+v", i, m, tt)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/peer.go b/vendor/github.com/coreos/etcd/rafthttp/peer.go
new file mode 100644
index 00000000..a82d7bee
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/peer.go
@@ -0,0 +1,307 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/stats"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/snap"
+ "golang.org/x/net/context"
+)
+
+const (
+ // ConnReadTimeout and ConnWriteTimeout are the i/o timeout set on each connection rafthttp pkg creates.
+ // A 5 seconds timeout is good enough for recycling bad connections. Or we have to wait for
+ // tcp keepalive failing to detect a bad connection, which is at minutes level.
+ // For long term streaming connections, rafthttp pkg sends application level linkHeartbeatMessage
+ // to keep the connection alive.
+ // For short term pipeline connections, the connection MUST be killed to avoid it being
+ // put back to http pkg connection pool.
+ ConnReadTimeout = 5 * time.Second
+ ConnWriteTimeout = 5 * time.Second
+
+ recvBufSize = 4096
+ // maxPendingProposals holds the proposals during one leader election process.
+ // Generally one leader election takes at most 1 sec. It should have
+ // 0-2 election conflicts, and each one takes 0.5 sec.
+ // We assume the number of concurrent proposers is smaller than 4096.
+ // One client blocks on its proposal for at least 1 sec, so 4096 is enough
+ // to hold all proposals.
+ maxPendingProposals = 4096
+
+ streamAppV2 = "streamMsgAppV2"
+ streamMsg = "streamMsg"
+ pipelineMsg = "pipeline"
+ sendSnap = "sendMsgSnap"
+)
+
+type Peer interface {
+ // send sends the message to the remote peer. The function is non-blocking
+ // and has no promise that the message will be received by the remote.
+ // When it fails to send message out, it will report the status to underlying
+ // raft.
+ send(m raftpb.Message)
+
+ // sendSnap sends the merged snapshot message to the remote peer. Its behavior
+ // is similar to send.
+ sendSnap(m snap.Message)
+
+ // update updates the urls of remote peer.
+ update(urls types.URLs)
+
+ // attachOutgoingConn attaches the outgoing connection to the peer for
+ // stream usage. After the call, the ownership of the outgoing
+ // connection hands over to the peer. The peer will close the connection
+ // when it is no longer used.
+ attachOutgoingConn(conn *outgoingConn)
+ // activeSince returns the time that the connection with the
+ // peer becomes active.
+ activeSince() time.Time
+ // stop performs any necessary finalization and terminates the peer
+ // elegantly.
+ stop()
+}
+
+// peer is the representative of a remote raft node. Local raft node sends
+// messages to the remote through peer.
+// Each peer has two underlying mechanisms to send out a message: stream and
+// pipeline.
+// A stream is a receiver initialized long-polling connection, which
+// is always open to transfer messages. Besides general stream, peer also has
+// a optimized stream for sending msgApp since msgApp accounts for large part
+// of all messages. Only raft leader uses the optimized stream to send msgApp
+// to the remote follower node.
+// A pipeline is a series of http clients that send http requests to the remote.
+// It is only used when the stream has not been established.
+type peer struct {
+ // id of the remote raft peer node
+ id types.ID
+ r Raft
+
+ status *peerStatus
+
+ picker *urlPicker
+
+ msgAppV2Writer *streamWriter
+ writer *streamWriter
+ pipeline *pipeline
+ snapSender *snapshotSender // snapshot sender to send v3 snapshot messages
+ msgAppV2Reader *streamReader
+ msgAppReader *streamReader
+
+ recvc chan raftpb.Message
+ propc chan raftpb.Message
+
+ mu sync.Mutex
+ paused bool
+
+ cancel context.CancelFunc // cancel pending works in go routine created by peer.
+ stopc chan struct{}
+}
+
+func startPeer(transport *Transport, urls types.URLs, peerID types.ID, fs *stats.FollowerStats) *peer {
+ plog.Infof("starting peer %s...", peerID)
+ defer plog.Infof("started peer %s", peerID)
+
+ status := newPeerStatus(peerID)
+ picker := newURLPicker(urls)
+ errorc := transport.ErrorC
+ r := transport.Raft
+ pipeline := &pipeline{
+ peerID: peerID,
+ tr: transport,
+ picker: picker,
+ status: status,
+ followerStats: fs,
+ raft: r,
+ errorc: errorc,
+ }
+ pipeline.start()
+
+ p := &peer{
+ id: peerID,
+ r: r,
+ status: status,
+ picker: picker,
+ msgAppV2Writer: startStreamWriter(peerID, status, fs, r),
+ writer: startStreamWriter(peerID, status, fs, r),
+ pipeline: pipeline,
+ snapSender: newSnapshotSender(transport, picker, peerID, status),
+ recvc: make(chan raftpb.Message, recvBufSize),
+ propc: make(chan raftpb.Message, maxPendingProposals),
+ stopc: make(chan struct{}),
+ }
+
+ ctx, cancel := context.WithCancel(context.Background())
+ p.cancel = cancel
+ go func() {
+ for {
+ select {
+ case mm := <-p.recvc:
+ if err := r.Process(ctx, mm); err != nil {
+ plog.Warningf("failed to process raft message (%v)", err)
+ }
+ case <-p.stopc:
+ return
+ }
+ }
+ }()
+
+ // r.Process might block for processing proposal when there is no leader.
+ // Thus propc must be put into a separate routine with recvc to avoid blocking
+ // processing other raft messages.
+ go func() {
+ for {
+ select {
+ case mm := <-p.propc:
+ if err := r.Process(ctx, mm); err != nil {
+ plog.Warningf("failed to process raft message (%v)", err)
+ }
+ case <-p.stopc:
+ return
+ }
+ }
+ }()
+
+ p.msgAppV2Reader = &streamReader{
+ peerID: peerID,
+ typ: streamTypeMsgAppV2,
+ tr: transport,
+ picker: picker,
+ status: status,
+ recvc: p.recvc,
+ propc: p.propc,
+ }
+ p.msgAppReader = &streamReader{
+ peerID: peerID,
+ typ: streamTypeMessage,
+ tr: transport,
+ picker: picker,
+ status: status,
+ recvc: p.recvc,
+ propc: p.propc,
+ }
+ p.msgAppV2Reader.start()
+ p.msgAppReader.start()
+
+ return p
+}
+
+func (p *peer) send(m raftpb.Message) {
+ p.mu.Lock()
+ paused := p.paused
+ p.mu.Unlock()
+
+ if paused {
+ return
+ }
+
+ writec, name := p.pick(m)
+ select {
+ case writec <- m:
+ default:
+ p.r.ReportUnreachable(m.To)
+ if isMsgSnap(m) {
+ p.r.ReportSnapshot(m.To, raft.SnapshotFailure)
+ }
+ if p.status.isActive() {
+ plog.MergeWarningf("dropped internal raft message to %s since %s's sending buffer is full (bad/overloaded network)", p.id, name)
+ }
+ plog.Debugf("dropped %s to %s since %s's sending buffer is full", m.Type, p.id, name)
+ }
+}
+
+func (p *peer) sendSnap(m snap.Message) {
+ go p.snapSender.send(m)
+}
+
+func (p *peer) update(urls types.URLs) {
+ p.picker.update(urls)
+}
+
+func (p *peer) attachOutgoingConn(conn *outgoingConn) {
+ var ok bool
+ switch conn.t {
+ case streamTypeMsgAppV2:
+ ok = p.msgAppV2Writer.attach(conn)
+ case streamTypeMessage:
+ ok = p.writer.attach(conn)
+ default:
+ plog.Panicf("unhandled stream type %s", conn.t)
+ }
+ if !ok {
+ conn.Close()
+ }
+}
+
+func (p *peer) activeSince() time.Time { return p.status.activeSince() }
+
+// Pause pauses the peer. The peer will simply drops all incoming
+// messages without returning an error.
+func (p *peer) Pause() {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+ p.paused = true
+ p.msgAppReader.pause()
+ p.msgAppV2Reader.pause()
+}
+
+// Resume resumes a paused peer.
+func (p *peer) Resume() {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+ p.paused = false
+ p.msgAppReader.resume()
+ p.msgAppV2Reader.resume()
+}
+
+func (p *peer) stop() {
+ plog.Infof("stopping peer %s...", p.id)
+ defer plog.Infof("stopped peer %s", p.id)
+
+ close(p.stopc)
+ p.cancel()
+ p.msgAppV2Writer.stop()
+ p.writer.stop()
+ p.pipeline.stop()
+ p.snapSender.stop()
+ p.msgAppV2Reader.stop()
+ p.msgAppReader.stop()
+}
+
+// pick picks a chan for sending the given message. The picked chan and the picked chan
+// string name are returned.
+func (p *peer) pick(m raftpb.Message) (writec chan<- raftpb.Message, picked string) {
+ var ok bool
+ // Considering MsgSnap may have a big size, e.g., 1G, and will block
+ // stream for a long time, only use one of the N pipelines to send MsgSnap.
+ if isMsgSnap(m) {
+ return p.pipeline.msgc, pipelineMsg
+ } else if writec, ok = p.msgAppV2Writer.writec(); ok && isMsgApp(m) {
+ return writec, streamAppV2
+ } else if writec, ok = p.writer.writec(); ok {
+ return writec, streamMsg
+ }
+ return p.pipeline.msgc, pipelineMsg
+}
+
+func isMsgApp(m raftpb.Message) bool { return m.Type == raftpb.MsgApp }
+
+func isMsgSnap(m raftpb.Message) bool { return m.Type == raftpb.MsgSnap }
diff --git a/vendor/github.com/coreos/etcd/rafthttp/peer_status.go b/vendor/github.com/coreos/etcd/rafthttp/peer_status.go
new file mode 100644
index 00000000..706144f6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/peer_status.go
@@ -0,0 +1,77 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "fmt"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/pkg/types"
+)
+
+type failureType struct {
+ source string
+ action string
+}
+
+type peerStatus struct {
+ id types.ID
+ mu sync.Mutex // protect variables below
+ active bool
+ since time.Time
+}
+
+func newPeerStatus(id types.ID) *peerStatus {
+ return &peerStatus{
+ id: id,
+ }
+}
+
+func (s *peerStatus) activate() {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ if !s.active {
+ plog.Infof("peer %s became active", s.id)
+ s.active = true
+ s.since = time.Now()
+ }
+}
+
+func (s *peerStatus) deactivate(failure failureType, reason string) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ msg := fmt.Sprintf("failed to %s %s on %s (%s)", failure.action, s.id, failure.source, reason)
+ if s.active {
+ plog.Errorf(msg)
+ plog.Infof("peer %s became inactive", s.id)
+ s.active = false
+ s.since = time.Time{}
+ return
+ }
+ plog.Debugf(msg)
+}
+
+func (s *peerStatus) isActive() bool {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ return s.active
+}
+
+func (s *peerStatus) activeSince() time.Time {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ return s.since
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/peer_test.go b/vendor/github.com/coreos/etcd/rafthttp/peer_test.go
new file mode 100644
index 00000000..00e00853
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/peer_test.go
@@ -0,0 +1,87 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "testing"
+
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+func TestPeerPick(t *testing.T) {
+ tests := []struct {
+ msgappWorking bool
+ messageWorking bool
+ m raftpb.Message
+ wpicked string
+ }{
+ {
+ true, true,
+ raftpb.Message{Type: raftpb.MsgSnap},
+ pipelineMsg,
+ },
+ {
+ true, true,
+ raftpb.Message{Type: raftpb.MsgApp, Term: 1, LogTerm: 1},
+ streamAppV2,
+ },
+ {
+ true, true,
+ raftpb.Message{Type: raftpb.MsgProp},
+ streamMsg,
+ },
+ {
+ true, true,
+ raftpb.Message{Type: raftpb.MsgHeartbeat},
+ streamMsg,
+ },
+ {
+ false, true,
+ raftpb.Message{Type: raftpb.MsgApp, Term: 1, LogTerm: 1},
+ streamMsg,
+ },
+ {
+ false, false,
+ raftpb.Message{Type: raftpb.MsgApp, Term: 1, LogTerm: 1},
+ pipelineMsg,
+ },
+ {
+ false, false,
+ raftpb.Message{Type: raftpb.MsgProp},
+ pipelineMsg,
+ },
+ {
+ false, false,
+ raftpb.Message{Type: raftpb.MsgSnap},
+ pipelineMsg,
+ },
+ {
+ false, false,
+ raftpb.Message{Type: raftpb.MsgHeartbeat},
+ pipelineMsg,
+ },
+ }
+ for i, tt := range tests {
+ peer := &peer{
+ msgAppV2Writer: &streamWriter{working: tt.msgappWorking},
+ writer: &streamWriter{working: tt.messageWorking},
+ pipeline: &pipeline{},
+ }
+ _, picked := peer.pick(tt.m)
+ if picked != tt.wpicked {
+ t.Errorf("#%d: picked = %v, want %v", i, picked, tt.wpicked)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/pipeline.go b/vendor/github.com/coreos/etcd/rafthttp/pipeline.go
new file mode 100644
index 00000000..d9f07c34
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/pipeline.go
@@ -0,0 +1,160 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "bytes"
+ "context"
+ "errors"
+ "io/ioutil"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/stats"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+const (
+ connPerPipeline = 4
+ // pipelineBufSize is the size of pipeline buffer, which helps hold the
+ // temporary network latency.
+ // The size ensures that pipeline does not drop messages when the network
+ // is out of work for less than 1 second in good path.
+ pipelineBufSize = 64
+)
+
+var errStopped = errors.New("stopped")
+
+type pipeline struct {
+ peerID types.ID
+
+ tr *Transport
+ picker *urlPicker
+ status *peerStatus
+ raft Raft
+ errorc chan error
+ // deprecate when we depercate v2 API
+ followerStats *stats.FollowerStats
+
+ msgc chan raftpb.Message
+ // wait for the handling routines
+ wg sync.WaitGroup
+ stopc chan struct{}
+}
+
+func (p *pipeline) start() {
+ p.stopc = make(chan struct{})
+ p.msgc = make(chan raftpb.Message, pipelineBufSize)
+ p.wg.Add(connPerPipeline)
+ for i := 0; i < connPerPipeline; i++ {
+ go p.handle()
+ }
+ plog.Infof("started HTTP pipelining with peer %s", p.peerID)
+}
+
+func (p *pipeline) stop() {
+ close(p.stopc)
+ p.wg.Wait()
+ plog.Infof("stopped HTTP pipelining with peer %s", p.peerID)
+}
+
+func (p *pipeline) handle() {
+ defer p.wg.Done()
+
+ for {
+ select {
+ case m := <-p.msgc:
+ start := time.Now()
+ err := p.post(pbutil.MustMarshal(&m))
+ end := time.Now()
+
+ if err != nil {
+ p.status.deactivate(failureType{source: pipelineMsg, action: "write"}, err.Error())
+
+ if m.Type == raftpb.MsgApp && p.followerStats != nil {
+ p.followerStats.Fail()
+ }
+ p.raft.ReportUnreachable(m.To)
+ if isMsgSnap(m) {
+ p.raft.ReportSnapshot(m.To, raft.SnapshotFailure)
+ }
+ sentFailures.WithLabelValues(types.ID(m.To).String()).Inc()
+ continue
+ }
+
+ p.status.activate()
+ if m.Type == raftpb.MsgApp && p.followerStats != nil {
+ p.followerStats.Succ(end.Sub(start))
+ }
+ if isMsgSnap(m) {
+ p.raft.ReportSnapshot(m.To, raft.SnapshotFinish)
+ }
+ sentBytes.WithLabelValues(types.ID(m.To).String()).Add(float64(m.Size()))
+ case <-p.stopc:
+ return
+ }
+ }
+}
+
+// post POSTs a data payload to a url. Returns nil if the POST succeeds,
+// error on any failure.
+func (p *pipeline) post(data []byte) (err error) {
+ u := p.picker.pick()
+ req := createPostRequest(u, RaftPrefix, bytes.NewBuffer(data), "application/protobuf", p.tr.URLs, p.tr.ID, p.tr.ClusterID)
+
+ done := make(chan struct{}, 1)
+ ctx, cancel := context.WithCancel(context.Background())
+ req = req.WithContext(ctx)
+ go func() {
+ select {
+ case <-done:
+ case <-p.stopc:
+ waitSchedule()
+ cancel()
+ }
+ }()
+
+ resp, err := p.tr.pipelineRt.RoundTrip(req)
+ done <- struct{}{}
+ if err != nil {
+ p.picker.unreachable(u)
+ return err
+ }
+ b, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ p.picker.unreachable(u)
+ return err
+ }
+ resp.Body.Close()
+
+ err = checkPostResponse(resp, b, req, p.peerID)
+ if err != nil {
+ p.picker.unreachable(u)
+ // errMemberRemoved is a critical error since a removed member should
+ // always be stopped. So we use reportCriticalError to report it to errorc.
+ if err == errMemberRemoved {
+ reportCriticalError(err, p.errorc)
+ }
+ return err
+ }
+
+ return nil
+}
+
+// waitSchedule waits other goroutines to be scheduled for a while
+func waitSchedule() { time.Sleep(time.Millisecond) }
diff --git a/vendor/github.com/coreos/etcd/rafthttp/pipeline_test.go b/vendor/github.com/coreos/etcd/rafthttp/pipeline_test.go
new file mode 100644
index 00000000..bdcdbc87
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/pipeline_test.go
@@ -0,0 +1,311 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "net/http"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/stats"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/version"
+)
+
+// TestPipelineSend tests that pipeline could send data using roundtripper
+// and increase success count in stats.
+func TestPipelineSend(t *testing.T) {
+ tr := &roundTripperRecorder{rec: testutil.NewRecorderStream()}
+ picker := mustNewURLPicker(t, []string{"http://localhost:2380"})
+ tp := &Transport{pipelineRt: tr}
+ p := startTestPipeline(tp, picker)
+
+ p.msgc <- raftpb.Message{Type: raftpb.MsgApp}
+ tr.rec.Wait(1)
+ p.stop()
+ if p.followerStats.Counts.Success != 1 {
+ t.Errorf("success = %d, want 1", p.followerStats.Counts.Success)
+ }
+}
+
+// TestPipelineKeepSendingWhenPostError tests that pipeline can keep
+// sending messages if previous messages meet post error.
+func TestPipelineKeepSendingWhenPostError(t *testing.T) {
+ tr := &respRoundTripper{rec: testutil.NewRecorderStream(), err: fmt.Errorf("roundtrip error")}
+ picker := mustNewURLPicker(t, []string{"http://localhost:2380"})
+ tp := &Transport{pipelineRt: tr}
+ p := startTestPipeline(tp, picker)
+ defer p.stop()
+
+ for i := 0; i < 50; i++ {
+ p.msgc <- raftpb.Message{Type: raftpb.MsgApp}
+ }
+
+ _, err := tr.rec.Wait(50)
+ if err != nil {
+ t.Errorf("unexpected wait error %v", err)
+ }
+}
+
+func TestPipelineExceedMaximumServing(t *testing.T) {
+ rt := newRoundTripperBlocker()
+ picker := mustNewURLPicker(t, []string{"http://localhost:2380"})
+ tp := &Transport{pipelineRt: rt}
+ p := startTestPipeline(tp, picker)
+ defer p.stop()
+
+ // keep the sender busy and make the buffer full
+ // nothing can go out as we block the sender
+ for i := 0; i < connPerPipeline+pipelineBufSize; i++ {
+ select {
+ case p.msgc <- raftpb.Message{}:
+ case <-time.After(time.Second):
+ t.Errorf("failed to send out message")
+ }
+ }
+
+ // try to send a data when we are sure the buffer is full
+ select {
+ case p.msgc <- raftpb.Message{}:
+ t.Errorf("unexpected message sendout")
+ default:
+ }
+
+ // unblock the senders and force them to send out the data
+ rt.unblock()
+
+ // It could send new data after previous ones succeed
+ select {
+ case p.msgc <- raftpb.Message{}:
+ case <-time.After(time.Second):
+ t.Errorf("failed to send out message")
+ }
+}
+
+// TestPipelineSendFailed tests that when send func meets the post error,
+// it increases fail count in stats.
+func TestPipelineSendFailed(t *testing.T) {
+ picker := mustNewURLPicker(t, []string{"http://localhost:2380"})
+ rt := newRespRoundTripper(0, errors.New("blah"))
+ rt.rec = testutil.NewRecorderStream()
+ tp := &Transport{pipelineRt: rt}
+ p := startTestPipeline(tp, picker)
+
+ p.msgc <- raftpb.Message{Type: raftpb.MsgApp}
+ if _, err := rt.rec.Wait(1); err != nil {
+ t.Fatal(err)
+ }
+
+ p.stop()
+
+ if p.followerStats.Counts.Fail != 1 {
+ t.Errorf("fail = %d, want 1", p.followerStats.Counts.Fail)
+ }
+}
+
+func TestPipelinePost(t *testing.T) {
+ tr := &roundTripperRecorder{rec: &testutil.RecorderBuffered{}}
+ picker := mustNewURLPicker(t, []string{"http://localhost:2380"})
+ tp := &Transport{ClusterID: types.ID(1), pipelineRt: tr}
+ p := startTestPipeline(tp, picker)
+ if err := p.post([]byte("some data")); err != nil {
+ t.Fatalf("unexpected post error: %v", err)
+ }
+ act, err := tr.rec.Wait(1)
+ if err != nil {
+ t.Fatal(err)
+ }
+ p.stop()
+
+ req := act[0].Params[0].(*http.Request)
+
+ if g := req.Method; g != "POST" {
+ t.Errorf("method = %s, want %s", g, "POST")
+ }
+ if g := req.URL.String(); g != "http://localhost:2380/raft" {
+ t.Errorf("url = %s, want %s", g, "http://localhost:2380/raft")
+ }
+ if g := req.Header.Get("Content-Type"); g != "application/protobuf" {
+ t.Errorf("content type = %s, want %s", g, "application/protobuf")
+ }
+ if g := req.Header.Get("X-Server-Version"); g != version.Version {
+ t.Errorf("version = %s, want %s", g, version.Version)
+ }
+ if g := req.Header.Get("X-Min-Cluster-Version"); g != version.MinClusterVersion {
+ t.Errorf("min version = %s, want %s", g, version.MinClusterVersion)
+ }
+ if g := req.Header.Get("X-Etcd-Cluster-ID"); g != "1" {
+ t.Errorf("cluster id = %s, want %s", g, "1")
+ }
+ b, err := ioutil.ReadAll(req.Body)
+ if err != nil {
+ t.Fatalf("unexpected ReadAll error: %v", err)
+ }
+ if string(b) != "some data" {
+ t.Errorf("body = %s, want %s", b, "some data")
+ }
+}
+
+func TestPipelinePostBad(t *testing.T) {
+ tests := []struct {
+ u string
+ code int
+ err error
+ }{
+ // RoundTrip returns error
+ {"http://localhost:2380", 0, errors.New("blah")},
+ // unexpected response status code
+ {"http://localhost:2380", http.StatusOK, nil},
+ {"http://localhost:2380", http.StatusCreated, nil},
+ }
+ for i, tt := range tests {
+ picker := mustNewURLPicker(t, []string{tt.u})
+ tp := &Transport{pipelineRt: newRespRoundTripper(tt.code, tt.err)}
+ p := startTestPipeline(tp, picker)
+ err := p.post([]byte("some data"))
+ p.stop()
+
+ if err == nil {
+ t.Errorf("#%d: err = nil, want not nil", i)
+ }
+ }
+}
+
+func TestPipelinePostErrorc(t *testing.T) {
+ tests := []struct {
+ u string
+ code int
+ err error
+ }{
+ {"http://localhost:2380", http.StatusForbidden, nil},
+ }
+ for i, tt := range tests {
+ picker := mustNewURLPicker(t, []string{tt.u})
+ tp := &Transport{pipelineRt: newRespRoundTripper(tt.code, tt.err)}
+ p := startTestPipeline(tp, picker)
+ p.post([]byte("some data"))
+ p.stop()
+ select {
+ case <-p.errorc:
+ default:
+ t.Fatalf("#%d: cannot receive from errorc", i)
+ }
+ }
+}
+
+func TestStopBlockedPipeline(t *testing.T) {
+ picker := mustNewURLPicker(t, []string{"http://localhost:2380"})
+ tp := &Transport{pipelineRt: newRoundTripperBlocker()}
+ p := startTestPipeline(tp, picker)
+ // send many messages that most of them will be blocked in buffer
+ for i := 0; i < connPerPipeline*10; i++ {
+ p.msgc <- raftpb.Message{}
+ }
+
+ done := make(chan struct{})
+ go func() {
+ p.stop()
+ done <- struct{}{}
+ }()
+ select {
+ case <-done:
+ case <-time.After(time.Second):
+ t.Fatalf("failed to stop pipeline in 1s")
+ }
+}
+
+type roundTripperBlocker struct {
+ unblockc chan struct{}
+ mu sync.Mutex
+ cancel map[*http.Request]chan struct{}
+}
+
+func newRoundTripperBlocker() *roundTripperBlocker {
+ return &roundTripperBlocker{
+ unblockc: make(chan struct{}),
+ cancel: make(map[*http.Request]chan struct{}),
+ }
+}
+
+func (t *roundTripperBlocker) unblock() {
+ close(t.unblockc)
+}
+
+func (t *roundTripperBlocker) CancelRequest(req *http.Request) {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ if c, ok := t.cancel[req]; ok {
+ c <- struct{}{}
+ delete(t.cancel, req)
+ }
+}
+
+type respRoundTripper struct {
+ mu sync.Mutex
+ rec testutil.Recorder
+
+ code int
+ header http.Header
+ err error
+}
+
+func newRespRoundTripper(code int, err error) *respRoundTripper {
+ return &respRoundTripper{code: code, err: err}
+}
+func (t *respRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ if t.rec != nil {
+ t.rec.Record(testutil.Action{Name: "req", Params: []interface{}{req}})
+ }
+ return &http.Response{StatusCode: t.code, Header: t.header, Body: &nopReadCloser{}}, t.err
+}
+
+type roundTripperRecorder struct {
+ rec testutil.Recorder
+}
+
+func (t *roundTripperRecorder) RoundTrip(req *http.Request) (*http.Response, error) {
+ if t.rec != nil {
+ t.rec.Record(testutil.Action{Name: "req", Params: []interface{}{req}})
+ }
+ return &http.Response{StatusCode: http.StatusNoContent, Body: &nopReadCloser{}}, nil
+}
+
+type nopReadCloser struct{}
+
+func (n *nopReadCloser) Read(p []byte) (int, error) { return 0, io.EOF }
+func (n *nopReadCloser) Close() error { return nil }
+
+func startTestPipeline(tr *Transport, picker *urlPicker) *pipeline {
+ p := &pipeline{
+ peerID: types.ID(1),
+ tr: tr,
+ picker: picker,
+ status: newPeerStatus(types.ID(1)),
+ raft: &fakeRaft{},
+ followerStats: &stats.FollowerStats{},
+ errorc: make(chan error, 1),
+ }
+ p.start()
+ return p
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/probing_status.go b/vendor/github.com/coreos/etcd/rafthttp/probing_status.go
new file mode 100644
index 00000000..c7a3c7ab
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/probing_status.go
@@ -0,0 +1,67 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "time"
+
+ "github.com/xiang90/probing"
+)
+
+var (
+ // proberInterval must be shorter than read timeout.
+ // Or the connection will time-out.
+ proberInterval = ConnReadTimeout - time.Second
+ statusMonitoringInterval = 30 * time.Second
+ statusErrorInterval = 5 * time.Second
+)
+
+func addPeerToProber(p probing.Prober, id string, us []string) {
+ hus := make([]string, len(us))
+ for i := range us {
+ hus[i] = us[i] + ProbingPrefix
+ }
+
+ p.AddHTTP(id, proberInterval, hus)
+
+ s, err := p.Status(id)
+ if err != nil {
+ plog.Errorf("failed to add peer %s into prober", id)
+ } else {
+ go monitorProbingStatus(s, id)
+ }
+}
+
+func monitorProbingStatus(s probing.Status, id string) {
+ // set the first interval short to log error early.
+ interval := statusErrorInterval
+ for {
+ select {
+ case <-time.After(interval):
+ if !s.Health() {
+ plog.Warningf("health check for peer %s could not connect: %v", id, s.Err())
+ interval = statusErrorInterval
+ } else {
+ interval = statusMonitoringInterval
+ }
+ if s.ClockDiff() > time.Second {
+ plog.Warningf("the clock difference against peer %s is too high [%v > %v]", id, s.ClockDiff(), time.Second)
+ }
+ rtts.WithLabelValues(id).Observe(s.SRTT().Seconds())
+ case <-s.StopNotify():
+ return
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/remote.go b/vendor/github.com/coreos/etcd/rafthttp/remote.go
new file mode 100644
index 00000000..c62c8182
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/remote.go
@@ -0,0 +1,69 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+type remote struct {
+ id types.ID
+ status *peerStatus
+ pipeline *pipeline
+}
+
+func startRemote(tr *Transport, urls types.URLs, id types.ID) *remote {
+ picker := newURLPicker(urls)
+ status := newPeerStatus(id)
+ pipeline := &pipeline{
+ peerID: id,
+ tr: tr,
+ picker: picker,
+ status: status,
+ raft: tr.Raft,
+ errorc: tr.ErrorC,
+ }
+ pipeline.start()
+
+ return &remote{
+ id: id,
+ status: status,
+ pipeline: pipeline,
+ }
+}
+
+func (g *remote) send(m raftpb.Message) {
+ select {
+ case g.pipeline.msgc <- m:
+ default:
+ if g.status.isActive() {
+ plog.MergeWarningf("dropped internal raft message to %s since sending buffer is full (bad/overloaded network)", g.id)
+ }
+ plog.Debugf("dropped %s to %s since sending buffer is full", m.Type, g.id)
+ }
+}
+
+func (g *remote) stop() {
+ g.pipeline.stop()
+}
+
+func (g *remote) Pause() {
+ g.stop()
+}
+
+func (g *remote) Resume() {
+ g.pipeline.start()
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/snapshot_sender.go b/vendor/github.com/coreos/etcd/rafthttp/snapshot_sender.go
new file mode 100644
index 00000000..52273c9d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/snapshot_sender.go
@@ -0,0 +1,157 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "bytes"
+ "context"
+ "io"
+ "io/ioutil"
+ "net/http"
+ "time"
+
+ "github.com/coreos/etcd/pkg/httputil"
+ pioutil "github.com/coreos/etcd/pkg/ioutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/snap"
+)
+
+var (
+ // timeout for reading snapshot response body
+ snapResponseReadTimeout = 5 * time.Second
+)
+
+type snapshotSender struct {
+ from, to types.ID
+ cid types.ID
+
+ tr *Transport
+ picker *urlPicker
+ status *peerStatus
+ r Raft
+ errorc chan error
+
+ stopc chan struct{}
+}
+
+func newSnapshotSender(tr *Transport, picker *urlPicker, to types.ID, status *peerStatus) *snapshotSender {
+ return &snapshotSender{
+ from: tr.ID,
+ to: to,
+ cid: tr.ClusterID,
+ tr: tr,
+ picker: picker,
+ status: status,
+ r: tr.Raft,
+ errorc: tr.ErrorC,
+ stopc: make(chan struct{}),
+ }
+}
+
+func (s *snapshotSender) stop() { close(s.stopc) }
+
+func (s *snapshotSender) send(merged snap.Message) {
+ m := merged.Message
+
+ body := createSnapBody(merged)
+ defer body.Close()
+
+ u := s.picker.pick()
+ req := createPostRequest(u, RaftSnapshotPrefix, body, "application/octet-stream", s.tr.URLs, s.from, s.cid)
+
+ plog.Infof("start to send database snapshot [index: %d, to %s]...", m.Snapshot.Metadata.Index, types.ID(m.To))
+
+ err := s.post(req)
+ defer merged.CloseWithError(err)
+ if err != nil {
+ plog.Warningf("database snapshot [index: %d, to: %s] failed to be sent out (%v)", m.Snapshot.Metadata.Index, types.ID(m.To), err)
+
+ // errMemberRemoved is a critical error since a removed member should
+ // always be stopped. So we use reportCriticalError to report it to errorc.
+ if err == errMemberRemoved {
+ reportCriticalError(err, s.errorc)
+ }
+
+ s.picker.unreachable(u)
+ s.status.deactivate(failureType{source: sendSnap, action: "post"}, err.Error())
+ s.r.ReportUnreachable(m.To)
+ // report SnapshotFailure to raft state machine. After raft state
+ // machine knows about it, it would pause a while and retry sending
+ // new snapshot message.
+ s.r.ReportSnapshot(m.To, raft.SnapshotFailure)
+ sentFailures.WithLabelValues(types.ID(m.To).String()).Inc()
+ return
+ }
+ s.status.activate()
+ s.r.ReportSnapshot(m.To, raft.SnapshotFinish)
+ plog.Infof("database snapshot [index: %d, to: %s] sent out successfully", m.Snapshot.Metadata.Index, types.ID(m.To))
+
+ sentBytes.WithLabelValues(types.ID(m.To).String()).Add(float64(merged.TotalSize))
+}
+
+// post posts the given request.
+// It returns nil when request is sent out and processed successfully.
+func (s *snapshotSender) post(req *http.Request) (err error) {
+ ctx, cancel := context.WithCancel(context.Background())
+ req = req.WithContext(ctx)
+ defer cancel()
+
+ type responseAndError struct {
+ resp *http.Response
+ body []byte
+ err error
+ }
+ result := make(chan responseAndError, 1)
+
+ go func() {
+ resp, err := s.tr.pipelineRt.RoundTrip(req)
+ if err != nil {
+ result <- responseAndError{resp, nil, err}
+ return
+ }
+
+ // close the response body when timeouts.
+ // prevents from reading the body forever when the other side dies right after
+ // successfully receives the request body.
+ time.AfterFunc(snapResponseReadTimeout, func() { httputil.GracefulClose(resp) })
+ body, err := ioutil.ReadAll(resp.Body)
+ result <- responseAndError{resp, body, err}
+ }()
+
+ select {
+ case <-s.stopc:
+ return errStopped
+ case r := <-result:
+ if r.err != nil {
+ return r.err
+ }
+ return checkPostResponse(r.resp, r.body, req, s.to)
+ }
+}
+
+func createSnapBody(merged snap.Message) io.ReadCloser {
+ buf := new(bytes.Buffer)
+ enc := &messageEncoder{w: buf}
+ // encode raft message
+ if err := enc.encode(&merged.Message); err != nil {
+ plog.Panicf("encode message error (%v)", err)
+ }
+
+ return &pioutil.ReaderAndCloser{
+ Reader: io.MultiReader(buf, merged.ReadCloser),
+ Closer: merged.ReadCloser,
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/snapshot_test.go b/vendor/github.com/coreos/etcd/rafthttp/snapshot_test.go
new file mode 100644
index 00000000..fbf482d0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/snapshot_test.go
@@ -0,0 +1,145 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "fmt"
+ "io"
+ "io/ioutil"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/snap"
+)
+
+type strReaderCloser struct{ *strings.Reader }
+
+func (s strReaderCloser) Close() error { return nil }
+
+func TestSnapshotSend(t *testing.T) {
+ tests := []struct {
+ m raftpb.Message
+ rc io.ReadCloser
+ size int64
+
+ wsent bool
+ wfiles int
+ }{
+ // sent and receive with no errors
+ {
+ m: raftpb.Message{Type: raftpb.MsgSnap, To: 1},
+ rc: strReaderCloser{strings.NewReader("hello")},
+ size: 5,
+
+ wsent: true,
+ wfiles: 1,
+ },
+ // error when reading snapshot for send
+ {
+ m: raftpb.Message{Type: raftpb.MsgSnap, To: 1},
+ rc: &errReadCloser{fmt.Errorf("snapshot error")},
+ size: 1,
+
+ wsent: false,
+ wfiles: 0,
+ },
+ // sends less than the given snapshot length
+ {
+ m: raftpb.Message{Type: raftpb.MsgSnap, To: 1},
+ rc: strReaderCloser{strings.NewReader("hello")},
+ size: 10000,
+
+ wsent: false,
+ wfiles: 0,
+ },
+ // sends less than actual snapshot length
+ {
+ m: raftpb.Message{Type: raftpb.MsgSnap, To: 1},
+ rc: strReaderCloser{strings.NewReader("hello")},
+ size: 1,
+
+ wsent: false,
+ wfiles: 0,
+ },
+ }
+
+ for i, tt := range tests {
+ sent, files := testSnapshotSend(t, snap.NewMessage(tt.m, tt.rc, tt.size))
+ if tt.wsent != sent {
+ t.Errorf("#%d: snapshot expected %v, got %v", i, tt.wsent, sent)
+ }
+ if tt.wfiles != len(files) {
+ t.Fatalf("#%d: expected %d files, got %d files", i, tt.wfiles, len(files))
+ }
+ }
+}
+
+func testSnapshotSend(t *testing.T, sm *snap.Message) (bool, []os.FileInfo) {
+ d, err := ioutil.TempDir(os.TempDir(), "snapdir")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(d)
+
+ r := &fakeRaft{}
+ tr := &Transport{pipelineRt: &http.Transport{}, ClusterID: types.ID(1), Raft: r}
+ ch := make(chan struct{}, 1)
+ h := &syncHandler{newSnapshotHandler(tr, r, snap.New(d), types.ID(1)), ch}
+ srv := httptest.NewServer(h)
+ defer srv.Close()
+
+ picker := mustNewURLPicker(t, []string{srv.URL})
+ snapsend := newSnapshotSender(tr, picker, types.ID(1), newPeerStatus(types.ID(1)))
+ defer snapsend.stop()
+
+ snapsend.send(*sm)
+
+ sent := false
+ select {
+ case <-time.After(time.Second):
+ t.Fatalf("timed out sending snapshot")
+ case sent = <-sm.CloseNotify():
+ }
+
+ // wait for handler to finish accepting snapshot
+ <-ch
+
+ files, rerr := ioutil.ReadDir(d)
+ if rerr != nil {
+ t.Fatal(rerr)
+ }
+ return sent, files
+}
+
+type errReadCloser struct{ err error }
+
+func (s *errReadCloser) Read(p []byte) (int, error) { return 0, s.err }
+func (s *errReadCloser) Close() error { return s.err }
+
+type syncHandler struct {
+ h http.Handler
+ ch chan<- struct{}
+}
+
+func (sh *syncHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ sh.h.ServeHTTP(w, r)
+ sh.ch <- struct{}{}
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/stream.go b/vendor/github.com/coreos/etcd/rafthttp/stream.go
new file mode 100644
index 00000000..2a6c620f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/stream.go
@@ -0,0 +1,527 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "context"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "net/http"
+ "path"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/stats"
+ "github.com/coreos/etcd/pkg/httputil"
+ "github.com/coreos/etcd/pkg/transport"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/version"
+ "github.com/coreos/go-semver/semver"
+)
+
+const (
+ streamTypeMessage streamType = "message"
+ streamTypeMsgAppV2 streamType = "msgappv2"
+
+ streamBufSize = 4096
+)
+
+var (
+ errUnsupportedStreamType = fmt.Errorf("unsupported stream type")
+
+ // the key is in string format "major.minor.patch"
+ supportedStream = map[string][]streamType{
+ "2.0.0": {},
+ "2.1.0": {streamTypeMsgAppV2, streamTypeMessage},
+ "2.2.0": {streamTypeMsgAppV2, streamTypeMessage},
+ "2.3.0": {streamTypeMsgAppV2, streamTypeMessage},
+ "3.0.0": {streamTypeMsgAppV2, streamTypeMessage},
+ "3.1.0": {streamTypeMsgAppV2, streamTypeMessage},
+ "3.2.0": {streamTypeMsgAppV2, streamTypeMessage},
+ }
+)
+
+type streamType string
+
+func (t streamType) endpoint() string {
+ switch t {
+ case streamTypeMsgAppV2:
+ return path.Join(RaftStreamPrefix, "msgapp")
+ case streamTypeMessage:
+ return path.Join(RaftStreamPrefix, "message")
+ default:
+ plog.Panicf("unhandled stream type %v", t)
+ return ""
+ }
+}
+
+func (t streamType) String() string {
+ switch t {
+ case streamTypeMsgAppV2:
+ return "stream MsgApp v2"
+ case streamTypeMessage:
+ return "stream Message"
+ default:
+ return "unknown stream"
+ }
+}
+
+var (
+ // linkHeartbeatMessage is a special message used as heartbeat message in
+ // link layer. It never conflicts with messages from raft because raft
+ // doesn't send out messages without From and To fields.
+ linkHeartbeatMessage = raftpb.Message{Type: raftpb.MsgHeartbeat}
+)
+
+func isLinkHeartbeatMessage(m *raftpb.Message) bool {
+ return m.Type == raftpb.MsgHeartbeat && m.From == 0 && m.To == 0
+}
+
+type outgoingConn struct {
+ t streamType
+ io.Writer
+ http.Flusher
+ io.Closer
+}
+
+// streamWriter writes messages to the attached outgoingConn.
+type streamWriter struct {
+ peerID types.ID
+ status *peerStatus
+ fs *stats.FollowerStats
+ r Raft
+
+ mu sync.Mutex // guard field working and closer
+ closer io.Closer
+ working bool
+
+ msgc chan raftpb.Message
+ connc chan *outgoingConn
+ stopc chan struct{}
+ done chan struct{}
+}
+
+// startStreamWriter creates a streamWrite and starts a long running go-routine that accepts
+// messages and writes to the attached outgoing connection.
+func startStreamWriter(id types.ID, status *peerStatus, fs *stats.FollowerStats, r Raft) *streamWriter {
+ w := &streamWriter{
+ peerID: id,
+ status: status,
+ fs: fs,
+ r: r,
+ msgc: make(chan raftpb.Message, streamBufSize),
+ connc: make(chan *outgoingConn),
+ stopc: make(chan struct{}),
+ done: make(chan struct{}),
+ }
+ go w.run()
+ return w
+}
+
+func (cw *streamWriter) run() {
+ var (
+ msgc chan raftpb.Message
+ heartbeatc <-chan time.Time
+ t streamType
+ enc encoder
+ flusher http.Flusher
+ batched int
+ )
+ tickc := time.NewTicker(ConnReadTimeout / 3)
+ defer tickc.Stop()
+ unflushed := 0
+
+ plog.Infof("started streaming with peer %s (writer)", cw.peerID)
+
+ for {
+ select {
+ case <-heartbeatc:
+ err := enc.encode(&linkHeartbeatMessage)
+ unflushed += linkHeartbeatMessage.Size()
+ if err == nil {
+ flusher.Flush()
+ batched = 0
+ sentBytes.WithLabelValues(cw.peerID.String()).Add(float64(unflushed))
+ unflushed = 0
+ continue
+ }
+
+ cw.status.deactivate(failureType{source: t.String(), action: "heartbeat"}, err.Error())
+
+ sentFailures.WithLabelValues(cw.peerID.String()).Inc()
+ cw.close()
+ plog.Warningf("lost the TCP streaming connection with peer %s (%s writer)", cw.peerID, t)
+ heartbeatc, msgc = nil, nil
+
+ case m := <-msgc:
+ err := enc.encode(&m)
+ if err == nil {
+ unflushed += m.Size()
+
+ if len(msgc) == 0 || batched > streamBufSize/2 {
+ flusher.Flush()
+ sentBytes.WithLabelValues(cw.peerID.String()).Add(float64(unflushed))
+ unflushed = 0
+ batched = 0
+ } else {
+ batched++
+ }
+
+ continue
+ }
+
+ cw.status.deactivate(failureType{source: t.String(), action: "write"}, err.Error())
+ cw.close()
+ plog.Warningf("lost the TCP streaming connection with peer %s (%s writer)", cw.peerID, t)
+ heartbeatc, msgc = nil, nil
+ cw.r.ReportUnreachable(m.To)
+ sentFailures.WithLabelValues(cw.peerID.String()).Inc()
+
+ case conn := <-cw.connc:
+ cw.mu.Lock()
+ closed := cw.closeUnlocked()
+ t = conn.t
+ switch conn.t {
+ case streamTypeMsgAppV2:
+ enc = newMsgAppV2Encoder(conn.Writer, cw.fs)
+ case streamTypeMessage:
+ enc = &messageEncoder{w: conn.Writer}
+ default:
+ plog.Panicf("unhandled stream type %s", conn.t)
+ }
+ flusher = conn.Flusher
+ unflushed = 0
+ cw.status.activate()
+ cw.closer = conn.Closer
+ cw.working = true
+ cw.mu.Unlock()
+
+ if closed {
+ plog.Warningf("closed an existing TCP streaming connection with peer %s (%s writer)", cw.peerID, t)
+ }
+ plog.Infof("established a TCP streaming connection with peer %s (%s writer)", cw.peerID, t)
+ heartbeatc, msgc = tickc.C, cw.msgc
+ case <-cw.stopc:
+ if cw.close() {
+ plog.Infof("closed the TCP streaming connection with peer %s (%s writer)", cw.peerID, t)
+ }
+ plog.Infof("stopped streaming with peer %s (writer)", cw.peerID)
+ close(cw.done)
+ return
+ }
+ }
+}
+
+func (cw *streamWriter) writec() (chan<- raftpb.Message, bool) {
+ cw.mu.Lock()
+ defer cw.mu.Unlock()
+ return cw.msgc, cw.working
+}
+
+func (cw *streamWriter) close() bool {
+ cw.mu.Lock()
+ defer cw.mu.Unlock()
+ return cw.closeUnlocked()
+}
+
+func (cw *streamWriter) closeUnlocked() bool {
+ if !cw.working {
+ return false
+ }
+ cw.closer.Close()
+ if len(cw.msgc) > 0 {
+ cw.r.ReportUnreachable(uint64(cw.peerID))
+ }
+ cw.msgc = make(chan raftpb.Message, streamBufSize)
+ cw.working = false
+ return true
+}
+
+func (cw *streamWriter) attach(conn *outgoingConn) bool {
+ select {
+ case cw.connc <- conn:
+ return true
+ case <-cw.done:
+ return false
+ }
+}
+
+func (cw *streamWriter) stop() {
+ close(cw.stopc)
+ <-cw.done
+}
+
+// streamReader is a long-running go-routine that dials to the remote stream
+// endpoint and reads messages from the response body returned.
+type streamReader struct {
+ peerID types.ID
+ typ streamType
+
+ tr *Transport
+ picker *urlPicker
+ status *peerStatus
+ recvc chan<- raftpb.Message
+ propc chan<- raftpb.Message
+
+ errorc chan<- error
+
+ mu sync.Mutex
+ paused bool
+ cancel func()
+ closer io.Closer
+
+ stopc chan struct{}
+ done chan struct{}
+}
+
+func (r *streamReader) start() {
+ r.stopc = make(chan struct{})
+ r.done = make(chan struct{})
+ if r.errorc == nil {
+ r.errorc = r.tr.ErrorC
+ }
+
+ go r.run()
+}
+
+func (cr *streamReader) run() {
+ t := cr.typ
+ plog.Infof("started streaming with peer %s (%s reader)", cr.peerID, t)
+ for {
+ rc, err := cr.dial(t)
+ if err != nil {
+ if err != errUnsupportedStreamType {
+ cr.status.deactivate(failureType{source: t.String(), action: "dial"}, err.Error())
+ }
+ } else {
+ cr.status.activate()
+ plog.Infof("established a TCP streaming connection with peer %s (%s reader)", cr.peerID, cr.typ)
+ err := cr.decodeLoop(rc, t)
+ plog.Warningf("lost the TCP streaming connection with peer %s (%s reader)", cr.peerID, cr.typ)
+ switch {
+ // all data is read out
+ case err == io.EOF:
+ // connection is closed by the remote
+ case transport.IsClosedConnError(err):
+ default:
+ cr.status.deactivate(failureType{source: t.String(), action: "read"}, err.Error())
+ }
+ }
+ select {
+ // Wait 100ms to create a new stream, so it doesn't bring too much
+ // overhead when retry.
+ case <-time.After(100 * time.Millisecond):
+ case <-cr.stopc:
+ plog.Infof("stopped streaming with peer %s (%s reader)", cr.peerID, t)
+ close(cr.done)
+ return
+ }
+ }
+}
+
+func (cr *streamReader) decodeLoop(rc io.ReadCloser, t streamType) error {
+ var dec decoder
+ cr.mu.Lock()
+ switch t {
+ case streamTypeMsgAppV2:
+ dec = newMsgAppV2Decoder(rc, cr.tr.ID, cr.peerID)
+ case streamTypeMessage:
+ dec = &messageDecoder{r: rc}
+ default:
+ plog.Panicf("unhandled stream type %s", t)
+ }
+ select {
+ case <-cr.stopc:
+ cr.mu.Unlock()
+ if err := rc.Close(); err != nil {
+ return err
+ }
+ return io.EOF
+ default:
+ cr.closer = rc
+ }
+ cr.mu.Unlock()
+
+ for {
+ m, err := dec.decode()
+ if err != nil {
+ cr.mu.Lock()
+ cr.close()
+ cr.mu.Unlock()
+ return err
+ }
+
+ receivedBytes.WithLabelValues(types.ID(m.From).String()).Add(float64(m.Size()))
+
+ cr.mu.Lock()
+ paused := cr.paused
+ cr.mu.Unlock()
+
+ if paused {
+ continue
+ }
+
+ if isLinkHeartbeatMessage(&m) {
+ // raft is not interested in link layer
+ // heartbeat message, so we should ignore
+ // it.
+ continue
+ }
+
+ recvc := cr.recvc
+ if m.Type == raftpb.MsgProp {
+ recvc = cr.propc
+ }
+
+ select {
+ case recvc <- m:
+ default:
+ if cr.status.isActive() {
+ plog.MergeWarningf("dropped internal raft message from %s since receiving buffer is full (overloaded network)", types.ID(m.From))
+ }
+ plog.Debugf("dropped %s from %s since receiving buffer is full", m.Type, types.ID(m.From))
+ recvFailures.WithLabelValues(types.ID(m.From).String()).Inc()
+ }
+ }
+}
+
+func (cr *streamReader) stop() {
+ close(cr.stopc)
+ cr.mu.Lock()
+ if cr.cancel != nil {
+ cr.cancel()
+ }
+ cr.close()
+ cr.mu.Unlock()
+ <-cr.done
+}
+
+func (cr *streamReader) dial(t streamType) (io.ReadCloser, error) {
+ u := cr.picker.pick()
+ uu := u
+ uu.Path = path.Join(t.endpoint(), cr.tr.ID.String())
+
+ req, err := http.NewRequest("GET", uu.String(), nil)
+ if err != nil {
+ cr.picker.unreachable(u)
+ return nil, fmt.Errorf("failed to make http request to %v (%v)", u, err)
+ }
+ req.Header.Set("X-Server-From", cr.tr.ID.String())
+ req.Header.Set("X-Server-Version", version.Version)
+ req.Header.Set("X-Min-Cluster-Version", version.MinClusterVersion)
+ req.Header.Set("X-Etcd-Cluster-ID", cr.tr.ClusterID.String())
+ req.Header.Set("X-Raft-To", cr.peerID.String())
+
+ setPeerURLsHeader(req, cr.tr.URLs)
+
+ ctx, cancel := context.WithCancel(context.Background())
+ req = req.WithContext(ctx)
+
+ cr.mu.Lock()
+ cr.cancel = cancel
+ select {
+ case <-cr.stopc:
+ cr.mu.Unlock()
+ return nil, fmt.Errorf("stream reader is stopped")
+ default:
+ }
+ cr.mu.Unlock()
+
+ resp, err := cr.tr.streamRt.RoundTrip(req)
+ if err != nil {
+ cr.picker.unreachable(u)
+ return nil, err
+ }
+
+ rv := serverVersion(resp.Header)
+ lv := semver.Must(semver.NewVersion(version.Version))
+ if compareMajorMinorVersion(rv, lv) == -1 && !checkStreamSupport(rv, t) {
+ httputil.GracefulClose(resp)
+ cr.picker.unreachable(u)
+ return nil, errUnsupportedStreamType
+ }
+
+ switch resp.StatusCode {
+ case http.StatusGone:
+ httputil.GracefulClose(resp)
+ cr.picker.unreachable(u)
+ reportCriticalError(errMemberRemoved, cr.errorc)
+ return nil, errMemberRemoved
+ case http.StatusOK:
+ return resp.Body, nil
+ case http.StatusNotFound:
+ httputil.GracefulClose(resp)
+ cr.picker.unreachable(u)
+ return nil, fmt.Errorf("peer %s failed to find local node %s", cr.peerID, cr.tr.ID)
+ case http.StatusPreconditionFailed:
+ b, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ cr.picker.unreachable(u)
+ return nil, err
+ }
+ httputil.GracefulClose(resp)
+ cr.picker.unreachable(u)
+
+ switch strings.TrimSuffix(string(b), "\n") {
+ case errIncompatibleVersion.Error():
+ plog.Errorf("request sent was ignored by peer %s (server version incompatible)", cr.peerID)
+ return nil, errIncompatibleVersion
+ case errClusterIDMismatch.Error():
+ plog.Errorf("request sent was ignored (cluster ID mismatch: peer[%s]=%s, local=%s)",
+ cr.peerID, resp.Header.Get("X-Etcd-Cluster-ID"), cr.tr.ClusterID)
+ return nil, errClusterIDMismatch
+ default:
+ return nil, fmt.Errorf("unhandled error %q when precondition failed", string(b))
+ }
+ default:
+ httputil.GracefulClose(resp)
+ cr.picker.unreachable(u)
+ return nil, fmt.Errorf("unhandled http status %d", resp.StatusCode)
+ }
+}
+
+func (cr *streamReader) close() {
+ if cr.closer != nil {
+ cr.closer.Close()
+ }
+ cr.closer = nil
+}
+
+func (cr *streamReader) pause() {
+ cr.mu.Lock()
+ defer cr.mu.Unlock()
+ cr.paused = true
+}
+
+func (cr *streamReader) resume() {
+ cr.mu.Lock()
+ defer cr.mu.Unlock()
+ cr.paused = false
+}
+
+// checkStreamSupport checks whether the stream type is supported in the
+// given version.
+func checkStreamSupport(v *semver.Version, t streamType) bool {
+ nv := &semver.Version{Major: v.Major, Minor: v.Minor}
+ for _, s := range supportedStream[nv.String()] {
+ if s == t {
+ return true
+ }
+ }
+ return false
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/stream_test.go b/vendor/github.com/coreos/etcd/rafthttp/stream_test.go
new file mode 100644
index 00000000..f48714e7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/stream_test.go
@@ -0,0 +1,439 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "net/http"
+ "net/http/httptest"
+ "reflect"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/stats"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/version"
+ "github.com/coreos/go-semver/semver"
+)
+
+// TestStreamWriterAttachOutgoingConn tests that outgoingConn can be attached
+// to streamWriter. After that, streamWriter can use it to send messages
+// continuously, and closes it when stopped.
+func TestStreamWriterAttachOutgoingConn(t *testing.T) {
+ sw := startStreamWriter(types.ID(1), newPeerStatus(types.ID(1)), &stats.FollowerStats{}, &fakeRaft{})
+ // the expected initial state of streamWriter is not working
+ if _, ok := sw.writec(); ok {
+ t.Errorf("initial working status = %v, want false", ok)
+ }
+
+ // repeat tests to ensure streamWriter can use last attached connection
+ var wfc *fakeWriteFlushCloser
+ for i := 0; i < 3; i++ {
+ prevwfc := wfc
+ wfc = newFakeWriteFlushCloser(nil)
+ sw.attach(&outgoingConn{t: streamTypeMessage, Writer: wfc, Flusher: wfc, Closer: wfc})
+
+ // previous attached connection should be closed
+ if prevwfc != nil {
+ select {
+ case <-prevwfc.closed:
+ case <-time.After(time.Second):
+ t.Errorf("#%d: close of previous connection timed out", i)
+ }
+ }
+
+ // if prevwfc != nil, the new msgc is ready since prevwfc has closed
+ // if prevwfc == nil, the first connection may be pending, but the first
+ // msgc is already available since it's set on calling startStreamwriter
+ msgc, _ := sw.writec()
+ msgc <- raftpb.Message{}
+
+ select {
+ case <-wfc.writec:
+ case <-time.After(time.Second):
+ t.Errorf("#%d: failed to write to the underlying connection", i)
+ }
+ // write chan is still available
+ if _, ok := sw.writec(); !ok {
+ t.Errorf("#%d: working status = %v, want true", i, ok)
+ }
+ }
+
+ sw.stop()
+ // write chan is unavailable since the writer is stopped.
+ if _, ok := sw.writec(); ok {
+ t.Errorf("working status after stop = %v, want false", ok)
+ }
+ if !wfc.Closed() {
+ t.Errorf("failed to close the underlying connection")
+ }
+}
+
+// TestStreamWriterAttachBadOutgoingConn tests that streamWriter with bad
+// outgoingConn will close the outgoingConn and fall back to non-working status.
+func TestStreamWriterAttachBadOutgoingConn(t *testing.T) {
+ sw := startStreamWriter(types.ID(1), newPeerStatus(types.ID(1)), &stats.FollowerStats{}, &fakeRaft{})
+ defer sw.stop()
+ wfc := newFakeWriteFlushCloser(errors.New("blah"))
+ sw.attach(&outgoingConn{t: streamTypeMessage, Writer: wfc, Flusher: wfc, Closer: wfc})
+
+ sw.msgc <- raftpb.Message{}
+ select {
+ case <-wfc.closed:
+ case <-time.After(time.Second):
+ t.Errorf("failed to close the underlying connection in time")
+ }
+ // no longer working
+ if _, ok := sw.writec(); ok {
+ t.Errorf("working = %v, want false", ok)
+ }
+}
+
+func TestStreamReaderDialRequest(t *testing.T) {
+ for i, tt := range []streamType{streamTypeMessage, streamTypeMsgAppV2} {
+ tr := &roundTripperRecorder{rec: &testutil.RecorderBuffered{}}
+ sr := &streamReader{
+ peerID: types.ID(2),
+ tr: &Transport{streamRt: tr, ClusterID: types.ID(1), ID: types.ID(1)},
+ picker: mustNewURLPicker(t, []string{"http://localhost:2380"}),
+ }
+ sr.dial(tt)
+
+ act, err := tr.rec.Wait(1)
+ if err != nil {
+ t.Fatal(err)
+ }
+ req := act[0].Params[0].(*http.Request)
+
+ wurl := fmt.Sprintf("http://localhost:2380" + tt.endpoint() + "/1")
+ if req.URL.String() != wurl {
+ t.Errorf("#%d: url = %s, want %s", i, req.URL.String(), wurl)
+ }
+ if w := "GET"; req.Method != w {
+ t.Errorf("#%d: method = %s, want %s", i, req.Method, w)
+ }
+ if g := req.Header.Get("X-Etcd-Cluster-ID"); g != "1" {
+ t.Errorf("#%d: header X-Etcd-Cluster-ID = %s, want 1", i, g)
+ }
+ if g := req.Header.Get("X-Raft-To"); g != "2" {
+ t.Errorf("#%d: header X-Raft-To = %s, want 2", i, g)
+ }
+ }
+}
+
+// TestStreamReaderDialResult tests the result of the dial func call meets the
+// HTTP response received.
+func TestStreamReaderDialResult(t *testing.T) {
+ tests := []struct {
+ code int
+ err error
+ wok bool
+ whalt bool
+ }{
+ {0, errors.New("blah"), false, false},
+ {http.StatusOK, nil, true, false},
+ {http.StatusMethodNotAllowed, nil, false, false},
+ {http.StatusNotFound, nil, false, false},
+ {http.StatusPreconditionFailed, nil, false, false},
+ {http.StatusGone, nil, false, true},
+ }
+ for i, tt := range tests {
+ h := http.Header{}
+ h.Add("X-Server-Version", version.Version)
+ tr := &respRoundTripper{
+ code: tt.code,
+ header: h,
+ err: tt.err,
+ }
+ sr := &streamReader{
+ peerID: types.ID(2),
+ tr: &Transport{streamRt: tr, ClusterID: types.ID(1)},
+ picker: mustNewURLPicker(t, []string{"http://localhost:2380"}),
+ errorc: make(chan error, 1),
+ }
+
+ _, err := sr.dial(streamTypeMessage)
+ if ok := err == nil; ok != tt.wok {
+ t.Errorf("#%d: ok = %v, want %v", i, ok, tt.wok)
+ }
+ if halt := len(sr.errorc) > 0; halt != tt.whalt {
+ t.Errorf("#%d: halt = %v, want %v", i, halt, tt.whalt)
+ }
+ }
+}
+
+// TestStreamReaderStopOnDial tests a stream reader closes the connection on stop.
+func TestStreamReaderStopOnDial(t *testing.T) {
+ defer testutil.AfterTest(t)
+ h := http.Header{}
+ h.Add("X-Server-Version", version.Version)
+ tr := &respWaitRoundTripper{rrt: &respRoundTripper{code: http.StatusOK, header: h}}
+ sr := &streamReader{
+ peerID: types.ID(2),
+ tr: &Transport{streamRt: tr, ClusterID: types.ID(1)},
+ picker: mustNewURLPicker(t, []string{"http://localhost:2380"}),
+ errorc: make(chan error, 1),
+ typ: streamTypeMessage,
+ status: newPeerStatus(types.ID(2)),
+ }
+ tr.onResp = func() {
+ // stop() waits for the run() goroutine to exit, but that exit
+ // needs a response from RoundTrip() first; use goroutine
+ go sr.stop()
+ // wait so that stop() is blocked on run() exiting
+ time.Sleep(10 * time.Millisecond)
+ // sr.run() completes dialing then begins decoding while stopped
+ }
+ sr.start()
+ select {
+ case <-sr.done:
+ case <-time.After(time.Second):
+ t.Fatal("streamReader did not stop in time")
+ }
+}
+
+type respWaitRoundTripper struct {
+ rrt *respRoundTripper
+ onResp func()
+}
+
+func (t *respWaitRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
+ resp, err := t.rrt.RoundTrip(req)
+ resp.Body = newWaitReadCloser()
+ t.onResp()
+ return resp, err
+}
+
+type waitReadCloser struct{ closec chan struct{} }
+
+func newWaitReadCloser() *waitReadCloser { return &waitReadCloser{make(chan struct{})} }
+func (wrc *waitReadCloser) Read(p []byte) (int, error) {
+ <-wrc.closec
+ return 0, io.EOF
+}
+func (wrc *waitReadCloser) Close() error {
+ close(wrc.closec)
+ return nil
+}
+
+// TestStreamReaderDialDetectUnsupport tests that dial func could find
+// out that the stream type is not supported by the remote.
+func TestStreamReaderDialDetectUnsupport(t *testing.T) {
+ for i, typ := range []streamType{streamTypeMsgAppV2, streamTypeMessage} {
+ // the response from etcd 2.0
+ tr := &respRoundTripper{
+ code: http.StatusNotFound,
+ header: http.Header{},
+ }
+ sr := &streamReader{
+ peerID: types.ID(2),
+ tr: &Transport{streamRt: tr, ClusterID: types.ID(1)},
+ picker: mustNewURLPicker(t, []string{"http://localhost:2380"}),
+ }
+
+ _, err := sr.dial(typ)
+ if err != errUnsupportedStreamType {
+ t.Errorf("#%d: error = %v, want %v", i, err, errUnsupportedStreamType)
+ }
+ }
+}
+
+// TestStream tests that streamReader and streamWriter can build stream to
+// send messages between each other.
+func TestStream(t *testing.T) {
+ recvc := make(chan raftpb.Message, streamBufSize)
+ propc := make(chan raftpb.Message, streamBufSize)
+ msgapp := raftpb.Message{
+ Type: raftpb.MsgApp,
+ From: 2,
+ To: 1,
+ Term: 1,
+ LogTerm: 1,
+ Index: 3,
+ Entries: []raftpb.Entry{{Term: 1, Index: 4}},
+ }
+
+ tests := []struct {
+ t streamType
+ m raftpb.Message
+ wc chan raftpb.Message
+ }{
+ {
+ streamTypeMessage,
+ raftpb.Message{Type: raftpb.MsgProp, To: 2},
+ propc,
+ },
+ {
+ streamTypeMessage,
+ msgapp,
+ recvc,
+ },
+ {
+ streamTypeMsgAppV2,
+ msgapp,
+ recvc,
+ },
+ }
+ for i, tt := range tests {
+ h := &fakeStreamHandler{t: tt.t}
+ srv := httptest.NewServer(h)
+ defer srv.Close()
+
+ sw := startStreamWriter(types.ID(1), newPeerStatus(types.ID(1)), &stats.FollowerStats{}, &fakeRaft{})
+ defer sw.stop()
+ h.sw = sw
+
+ picker := mustNewURLPicker(t, []string{srv.URL})
+ tr := &Transport{streamRt: &http.Transport{}, ClusterID: types.ID(1)}
+
+ sr := &streamReader{
+ peerID: types.ID(2),
+ typ: tt.t,
+ tr: tr,
+ picker: picker,
+ status: newPeerStatus(types.ID(2)),
+ recvc: recvc,
+ propc: propc,
+ }
+ sr.start()
+
+ // wait for stream to work
+ var writec chan<- raftpb.Message
+ for {
+ var ok bool
+ if writec, ok = sw.writec(); ok {
+ break
+ }
+ time.Sleep(time.Millisecond)
+ }
+
+ writec <- tt.m
+ var m raftpb.Message
+ select {
+ case m = <-tt.wc:
+ case <-time.After(time.Second):
+ t.Fatalf("#%d: failed to receive message from the channel", i)
+ }
+ if !reflect.DeepEqual(m, tt.m) {
+ t.Fatalf("#%d: message = %+v, want %+v", i, m, tt.m)
+ }
+
+ sr.stop()
+ }
+}
+
+func TestCheckStreamSupport(t *testing.T) {
+ tests := []struct {
+ v *semver.Version
+ t streamType
+ w bool
+ }{
+ // support
+ {
+ semver.Must(semver.NewVersion("2.1.0")),
+ streamTypeMsgAppV2,
+ true,
+ },
+ // ignore patch
+ {
+ semver.Must(semver.NewVersion("2.1.9")),
+ streamTypeMsgAppV2,
+ true,
+ },
+ // ignore prerelease
+ {
+ semver.Must(semver.NewVersion("2.1.0-alpha")),
+ streamTypeMsgAppV2,
+ true,
+ },
+ }
+ for i, tt := range tests {
+ if g := checkStreamSupport(tt.v, tt.t); g != tt.w {
+ t.Errorf("#%d: check = %v, want %v", i, g, tt.w)
+ }
+ }
+}
+
+type fakeWriteFlushCloser struct {
+ mu sync.Mutex
+ err error
+ written int
+ closed chan struct{}
+ writec chan struct{}
+}
+
+func newFakeWriteFlushCloser(err error) *fakeWriteFlushCloser {
+ return &fakeWriteFlushCloser{
+ err: err,
+ closed: make(chan struct{}),
+ writec: make(chan struct{}, 1),
+ }
+}
+
+func (wfc *fakeWriteFlushCloser) Write(p []byte) (n int, err error) {
+ wfc.mu.Lock()
+ defer wfc.mu.Unlock()
+ select {
+ case wfc.writec <- struct{}{}:
+ default:
+ }
+ wfc.written += len(p)
+ return len(p), wfc.err
+}
+
+func (wfc *fakeWriteFlushCloser) Flush() {}
+
+func (wfc *fakeWriteFlushCloser) Close() error {
+ close(wfc.closed)
+ return wfc.err
+}
+
+func (wfc *fakeWriteFlushCloser) Written() int {
+ wfc.mu.Lock()
+ defer wfc.mu.Unlock()
+ return wfc.written
+}
+
+func (wfc *fakeWriteFlushCloser) Closed() bool {
+ select {
+ case <-wfc.closed:
+ return true
+ default:
+ return false
+ }
+}
+
+type fakeStreamHandler struct {
+ t streamType
+ sw *streamWriter
+}
+
+func (h *fakeStreamHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ w.Header().Add("X-Server-Version", version.Version)
+ w.(http.Flusher).Flush()
+ c := newCloseNotifier()
+ h.sw.attach(&outgoingConn{
+ t: h.t,
+ Writer: w,
+ Flusher: w.(http.Flusher),
+ Closer: c,
+ })
+ <-c.closeNotify()
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/transport.go b/vendor/github.com/coreos/etcd/rafthttp/transport.go
new file mode 100644
index 00000000..1f0b4683
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/transport.go
@@ -0,0 +1,402 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "net/http"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/stats"
+ "github.com/coreos/etcd/pkg/logutil"
+ "github.com/coreos/etcd/pkg/transport"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/snap"
+ "github.com/coreos/pkg/capnslog"
+ "github.com/xiang90/probing"
+ "golang.org/x/net/context"
+)
+
+var plog = logutil.NewMergeLogger(capnslog.NewPackageLogger("github.com/coreos/etcd", "rafthttp"))
+
+type Raft interface {
+ Process(ctx context.Context, m raftpb.Message) error
+ IsIDRemoved(id uint64) bool
+ ReportUnreachable(id uint64)
+ ReportSnapshot(id uint64, status raft.SnapshotStatus)
+}
+
+type Transporter interface {
+ // Start starts the given Transporter.
+ // Start MUST be called before calling other functions in the interface.
+ Start() error
+ // Handler returns the HTTP handler of the transporter.
+ // A transporter HTTP handler handles the HTTP requests
+ // from remote peers.
+ // The handler MUST be used to handle RaftPrefix(/raft)
+ // endpoint.
+ Handler() http.Handler
+ // Send sends out the given messages to the remote peers.
+ // Each message has a To field, which is an id that maps
+ // to an existing peer in the transport.
+ // If the id cannot be found in the transport, the message
+ // will be ignored.
+ Send(m []raftpb.Message)
+ // SendSnapshot sends out the given snapshot message to a remote peer.
+ // The behavior of SendSnapshot is similar to Send.
+ SendSnapshot(m snap.Message)
+ // AddRemote adds a remote with given peer urls into the transport.
+ // A remote helps newly joined member to catch up the progress of cluster,
+ // and will not be used after that.
+ // It is the caller's responsibility to ensure the urls are all valid,
+ // or it panics.
+ AddRemote(id types.ID, urls []string)
+ // AddPeer adds a peer with given peer urls into the transport.
+ // It is the caller's responsibility to ensure the urls are all valid,
+ // or it panics.
+ // Peer urls are used to connect to the remote peer.
+ AddPeer(id types.ID, urls []string)
+ // RemovePeer removes the peer with given id.
+ RemovePeer(id types.ID)
+ // RemoveAllPeers removes all the existing peers in the transport.
+ RemoveAllPeers()
+ // UpdatePeer updates the peer urls of the peer with the given id.
+ // It is the caller's responsibility to ensure the urls are all valid,
+ // or it panics.
+ UpdatePeer(id types.ID, urls []string)
+ // ActiveSince returns the time that the connection with the peer
+ // of the given id becomes active.
+ // If the connection is active since peer was added, it returns the adding time.
+ // If the connection is currently inactive, it returns zero time.
+ ActiveSince(id types.ID) time.Time
+ // Stop closes the connections and stops the transporter.
+ Stop()
+}
+
+// Transport implements Transporter interface. It provides the functionality
+// to send raft messages to peers, and receive raft messages from peers.
+// User should call Handler method to get a handler to serve requests
+// received from peerURLs.
+// User needs to call Start before calling other functions, and call
+// Stop when the Transport is no longer used.
+type Transport struct {
+ DialTimeout time.Duration // maximum duration before timing out dial of the request
+ TLSInfo transport.TLSInfo // TLS information used when creating connection
+
+ ID types.ID // local member ID
+ URLs types.URLs // local peer URLs
+ ClusterID types.ID // raft cluster ID for request validation
+ Raft Raft // raft state machine, to which the Transport forwards received messages and reports status
+ Snapshotter *snap.Snapshotter
+ ServerStats *stats.ServerStats // used to record general transportation statistics
+ // used to record transportation statistics with followers when
+ // performing as leader in raft protocol
+ LeaderStats *stats.LeaderStats
+ // ErrorC is used to report detected critical errors, e.g.,
+ // the member has been permanently removed from the cluster
+ // When an error is received from ErrorC, user should stop raft state
+ // machine and thus stop the Transport.
+ ErrorC chan error
+
+ streamRt http.RoundTripper // roundTripper used by streams
+ pipelineRt http.RoundTripper // roundTripper used by pipelines
+
+ mu sync.RWMutex // protect the remote and peer map
+ remotes map[types.ID]*remote // remotes map that helps newly joined member to catch up
+ peers map[types.ID]Peer // peers map
+
+ prober probing.Prober
+}
+
+func (t *Transport) Start() error {
+ var err error
+ t.streamRt, err = newStreamRoundTripper(t.TLSInfo, t.DialTimeout)
+ if err != nil {
+ return err
+ }
+ t.pipelineRt, err = NewRoundTripper(t.TLSInfo, t.DialTimeout)
+ if err != nil {
+ return err
+ }
+ t.remotes = make(map[types.ID]*remote)
+ t.peers = make(map[types.ID]Peer)
+ t.prober = probing.NewProber(t.pipelineRt)
+ return nil
+}
+
+func (t *Transport) Handler() http.Handler {
+ pipelineHandler := newPipelineHandler(t, t.Raft, t.ClusterID)
+ streamHandler := newStreamHandler(t, t, t.Raft, t.ID, t.ClusterID)
+ snapHandler := newSnapshotHandler(t, t.Raft, t.Snapshotter, t.ClusterID)
+ mux := http.NewServeMux()
+ mux.Handle(RaftPrefix, pipelineHandler)
+ mux.Handle(RaftStreamPrefix+"/", streamHandler)
+ mux.Handle(RaftSnapshotPrefix, snapHandler)
+ mux.Handle(ProbingPrefix, probing.NewHandler())
+ return mux
+}
+
+func (t *Transport) Get(id types.ID) Peer {
+ t.mu.RLock()
+ defer t.mu.RUnlock()
+ return t.peers[id]
+}
+
+func (t *Transport) Send(msgs []raftpb.Message) {
+ for _, m := range msgs {
+ if m.To == 0 {
+ // ignore intentionally dropped message
+ continue
+ }
+ to := types.ID(m.To)
+
+ t.mu.RLock()
+ p, pok := t.peers[to]
+ g, rok := t.remotes[to]
+ t.mu.RUnlock()
+
+ if pok {
+ if m.Type == raftpb.MsgApp {
+ t.ServerStats.SendAppendReq(m.Size())
+ }
+ p.send(m)
+ continue
+ }
+
+ if rok {
+ g.send(m)
+ continue
+ }
+
+ plog.Debugf("ignored message %s (sent to unknown peer %s)", m.Type, to)
+ }
+}
+
+func (t *Transport) Stop() {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ for _, r := range t.remotes {
+ r.stop()
+ }
+ for _, p := range t.peers {
+ p.stop()
+ }
+ t.prober.RemoveAll()
+ if tr, ok := t.streamRt.(*http.Transport); ok {
+ tr.CloseIdleConnections()
+ }
+ if tr, ok := t.pipelineRt.(*http.Transport); ok {
+ tr.CloseIdleConnections()
+ }
+ t.peers = nil
+ t.remotes = nil
+}
+
+// CutPeer drops messages to the specified peer.
+func (t *Transport) CutPeer(id types.ID) {
+ t.mu.RLock()
+ p, pok := t.peers[id]
+ g, gok := t.remotes[id]
+ t.mu.RUnlock()
+
+ if pok {
+ p.(Pausable).Pause()
+ }
+ if gok {
+ g.Pause()
+ }
+}
+
+// MendPeer recovers the message dropping behavior of the given peer.
+func (t *Transport) MendPeer(id types.ID) {
+ t.mu.RLock()
+ p, pok := t.peers[id]
+ g, gok := t.remotes[id]
+ t.mu.RUnlock()
+
+ if pok {
+ p.(Pausable).Resume()
+ }
+ if gok {
+ g.Resume()
+ }
+}
+
+func (t *Transport) AddRemote(id types.ID, us []string) {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ if t.remotes == nil {
+ // there's no clean way to shutdown the golang http server
+ // (see: https://github.com/golang/go/issues/4674) before
+ // stopping the transport; ignore any new connections.
+ return
+ }
+ if _, ok := t.peers[id]; ok {
+ return
+ }
+ if _, ok := t.remotes[id]; ok {
+ return
+ }
+ urls, err := types.NewURLs(us)
+ if err != nil {
+ plog.Panicf("newURLs %+v should never fail: %+v", us, err)
+ }
+ t.remotes[id] = startRemote(t, urls, id)
+}
+
+func (t *Transport) AddPeer(id types.ID, us []string) {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+
+ if t.peers == nil {
+ panic("transport stopped")
+ }
+ if _, ok := t.peers[id]; ok {
+ return
+ }
+ urls, err := types.NewURLs(us)
+ if err != nil {
+ plog.Panicf("newURLs %+v should never fail: %+v", us, err)
+ }
+ fs := t.LeaderStats.Follower(id.String())
+ t.peers[id] = startPeer(t, urls, id, fs)
+ addPeerToProber(t.prober, id.String(), us)
+
+ plog.Infof("added peer %s", id)
+}
+
+func (t *Transport) RemovePeer(id types.ID) {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ t.removePeer(id)
+}
+
+func (t *Transport) RemoveAllPeers() {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ for id := range t.peers {
+ t.removePeer(id)
+ }
+}
+
+// the caller of this function must have the peers mutex.
+func (t *Transport) removePeer(id types.ID) {
+ if peer, ok := t.peers[id]; ok {
+ peer.stop()
+ } else {
+ plog.Panicf("unexpected removal of unknown peer '%d'", id)
+ }
+ delete(t.peers, id)
+ delete(t.LeaderStats.Followers, id.String())
+ t.prober.Remove(id.String())
+ plog.Infof("removed peer %s", id)
+}
+
+func (t *Transport) UpdatePeer(id types.ID, us []string) {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ // TODO: return error or just panic?
+ if _, ok := t.peers[id]; !ok {
+ return
+ }
+ urls, err := types.NewURLs(us)
+ if err != nil {
+ plog.Panicf("newURLs %+v should never fail: %+v", us, err)
+ }
+ t.peers[id].update(urls)
+
+ t.prober.Remove(id.String())
+ addPeerToProber(t.prober, id.String(), us)
+ plog.Infof("updated peer %s", id)
+}
+
+func (t *Transport) ActiveSince(id types.ID) time.Time {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ if p, ok := t.peers[id]; ok {
+ return p.activeSince()
+ }
+ return time.Time{}
+}
+
+func (t *Transport) SendSnapshot(m snap.Message) {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ p := t.peers[types.ID(m.To)]
+ if p == nil {
+ m.CloseWithError(errMemberNotFound)
+ return
+ }
+ p.sendSnap(m)
+}
+
+// Pausable is a testing interface for pausing transport traffic.
+type Pausable interface {
+ Pause()
+ Resume()
+}
+
+func (t *Transport) Pause() {
+ for _, p := range t.peers {
+ p.(Pausable).Pause()
+ }
+}
+
+func (t *Transport) Resume() {
+ for _, p := range t.peers {
+ p.(Pausable).Resume()
+ }
+}
+
+type nopTransporter struct{}
+
+func NewNopTransporter() Transporter {
+ return &nopTransporter{}
+}
+
+func (s *nopTransporter) Start() error { return nil }
+func (s *nopTransporter) Handler() http.Handler { return nil }
+func (s *nopTransporter) Send(m []raftpb.Message) {}
+func (s *nopTransporter) SendSnapshot(m snap.Message) {}
+func (s *nopTransporter) AddRemote(id types.ID, us []string) {}
+func (s *nopTransporter) AddPeer(id types.ID, us []string) {}
+func (s *nopTransporter) RemovePeer(id types.ID) {}
+func (s *nopTransporter) RemoveAllPeers() {}
+func (s *nopTransporter) UpdatePeer(id types.ID, us []string) {}
+func (s *nopTransporter) ActiveSince(id types.ID) time.Time { return time.Time{} }
+func (s *nopTransporter) Stop() {}
+func (s *nopTransporter) Pause() {}
+func (s *nopTransporter) Resume() {}
+
+type snapTransporter struct {
+ nopTransporter
+ snapDoneC chan snap.Message
+ snapDir string
+}
+
+func NewSnapTransporter(snapDir string) (Transporter, <-chan snap.Message) {
+ ch := make(chan snap.Message, 1)
+ tr := &snapTransporter{snapDoneC: ch, snapDir: snapDir}
+ return tr, ch
+}
+
+func (s *snapTransporter) SendSnapshot(m snap.Message) {
+ ss := snap.New(s.snapDir)
+ ss.SaveDBFrom(m.ReadCloser, m.Snapshot.Metadata.Index+1)
+ m.CloseWithError(nil)
+ s.snapDoneC <- m
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/transport_bench_test.go b/vendor/github.com/coreos/etcd/rafthttp/transport_bench_test.go
new file mode 100644
index 00000000..620e0dbf
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/transport_bench_test.go
@@ -0,0 +1,114 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "net/http/httptest"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/stats"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+ "golang.org/x/net/context"
+)
+
+func BenchmarkSendingMsgApp(b *testing.B) {
+ // member 1
+ tr := &Transport{
+ ID: types.ID(1),
+ ClusterID: types.ID(1),
+ Raft: &fakeRaft{},
+ ServerStats: newServerStats(),
+ LeaderStats: stats.NewLeaderStats("1"),
+ }
+ tr.Start()
+ srv := httptest.NewServer(tr.Handler())
+ defer srv.Close()
+
+ // member 2
+ r := &countRaft{}
+ tr2 := &Transport{
+ ID: types.ID(2),
+ ClusterID: types.ID(1),
+ Raft: r,
+ ServerStats: newServerStats(),
+ LeaderStats: stats.NewLeaderStats("2"),
+ }
+ tr2.Start()
+ srv2 := httptest.NewServer(tr2.Handler())
+ defer srv2.Close()
+
+ tr.AddPeer(types.ID(2), []string{srv2.URL})
+ defer tr.Stop()
+ tr2.AddPeer(types.ID(1), []string{srv.URL})
+ defer tr2.Stop()
+ if !waitStreamWorking(tr.Get(types.ID(2)).(*peer)) {
+ b.Fatalf("stream from 1 to 2 is not in work as expected")
+ }
+
+ b.ReportAllocs()
+ b.SetBytes(64)
+
+ b.ResetTimer()
+ data := make([]byte, 64)
+ for i := 0; i < b.N; i++ {
+ tr.Send([]raftpb.Message{
+ {
+ Type: raftpb.MsgApp,
+ From: 1,
+ To: 2,
+ Index: uint64(i),
+ Entries: []raftpb.Entry{
+ {
+ Index: uint64(i + 1),
+ Data: data,
+ },
+ },
+ },
+ })
+ }
+ // wait until all messages are received by the target raft
+ for r.count() != b.N {
+ time.Sleep(time.Millisecond)
+ }
+ b.StopTimer()
+}
+
+type countRaft struct {
+ mu sync.Mutex
+ cnt int
+}
+
+func (r *countRaft) Process(ctx context.Context, m raftpb.Message) error {
+ r.mu.Lock()
+ defer r.mu.Unlock()
+ r.cnt++
+ return nil
+}
+
+func (r *countRaft) IsIDRemoved(id uint64) bool { return false }
+
+func (r *countRaft) ReportUnreachable(id uint64) {}
+
+func (r *countRaft) ReportSnapshot(id uint64, status raft.SnapshotStatus) {}
+
+func (r *countRaft) count() int {
+ r.mu.Lock()
+ defer r.mu.Unlock()
+ return r.cnt
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/transport_test.go b/vendor/github.com/coreos/etcd/rafthttp/transport_test.go
new file mode 100644
index 00000000..e4cf3715
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/transport_test.go
@@ -0,0 +1,181 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "net/http"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/stats"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/xiang90/probing"
+)
+
+// TestTransportSend tests that transport can send messages using correct
+// underlying peer, and drop local or unknown-target messages.
+func TestTransportSend(t *testing.T) {
+ peer1 := newFakePeer()
+ peer2 := newFakePeer()
+ tr := &Transport{
+ ServerStats: stats.NewServerStats("", ""),
+ peers: map[types.ID]Peer{types.ID(1): peer1, types.ID(2): peer2},
+ }
+ wmsgsIgnored := []raftpb.Message{
+ // bad local message
+ {Type: raftpb.MsgBeat},
+ // bad remote message
+ {Type: raftpb.MsgProp, To: 3},
+ }
+ wmsgsTo1 := []raftpb.Message{
+ // good message
+ {Type: raftpb.MsgProp, To: 1},
+ {Type: raftpb.MsgApp, To: 1},
+ }
+ wmsgsTo2 := []raftpb.Message{
+ // good message
+ {Type: raftpb.MsgProp, To: 2},
+ {Type: raftpb.MsgApp, To: 2},
+ }
+ tr.Send(wmsgsIgnored)
+ tr.Send(wmsgsTo1)
+ tr.Send(wmsgsTo2)
+
+ if !reflect.DeepEqual(peer1.msgs, wmsgsTo1) {
+ t.Errorf("msgs to peer 1 = %+v, want %+v", peer1.msgs, wmsgsTo1)
+ }
+ if !reflect.DeepEqual(peer2.msgs, wmsgsTo2) {
+ t.Errorf("msgs to peer 2 = %+v, want %+v", peer2.msgs, wmsgsTo2)
+ }
+}
+
+func TestTransportCutMend(t *testing.T) {
+ peer1 := newFakePeer()
+ peer2 := newFakePeer()
+ tr := &Transport{
+ ServerStats: stats.NewServerStats("", ""),
+ peers: map[types.ID]Peer{types.ID(1): peer1, types.ID(2): peer2},
+ }
+
+ tr.CutPeer(types.ID(1))
+
+ wmsgsTo := []raftpb.Message{
+ // good message
+ {Type: raftpb.MsgProp, To: 1},
+ {Type: raftpb.MsgApp, To: 1},
+ }
+
+ tr.Send(wmsgsTo)
+ if len(peer1.msgs) > 0 {
+ t.Fatalf("msgs expected to be ignored, got %+v", peer1.msgs)
+ }
+
+ tr.MendPeer(types.ID(1))
+
+ tr.Send(wmsgsTo)
+ if !reflect.DeepEqual(peer1.msgs, wmsgsTo) {
+ t.Errorf("msgs to peer 1 = %+v, want %+v", peer1.msgs, wmsgsTo)
+ }
+}
+
+func TestTransportAdd(t *testing.T) {
+ ls := stats.NewLeaderStats("")
+ tr := &Transport{
+ LeaderStats: ls,
+ streamRt: &roundTripperRecorder{},
+ peers: make(map[types.ID]Peer),
+ prober: probing.NewProber(nil),
+ }
+ tr.AddPeer(1, []string{"http://localhost:2380"})
+
+ if _, ok := ls.Followers["1"]; !ok {
+ t.Errorf("FollowerStats[1] is nil, want exists")
+ }
+ s, ok := tr.peers[types.ID(1)]
+ if !ok {
+ tr.Stop()
+ t.Fatalf("senders[1] is nil, want exists")
+ }
+
+ // duplicate AddPeer is ignored
+ tr.AddPeer(1, []string{"http://localhost:2380"})
+ ns := tr.peers[types.ID(1)]
+ if s != ns {
+ t.Errorf("sender = %v, want %v", ns, s)
+ }
+
+ tr.Stop()
+}
+
+func TestTransportRemove(t *testing.T) {
+ tr := &Transport{
+ LeaderStats: stats.NewLeaderStats(""),
+ streamRt: &roundTripperRecorder{},
+ peers: make(map[types.ID]Peer),
+ prober: probing.NewProber(nil),
+ }
+ tr.AddPeer(1, []string{"http://localhost:2380"})
+ tr.RemovePeer(types.ID(1))
+ defer tr.Stop()
+
+ if _, ok := tr.peers[types.ID(1)]; ok {
+ t.Fatalf("senders[1] exists, want removed")
+ }
+}
+
+func TestTransportUpdate(t *testing.T) {
+ peer := newFakePeer()
+ tr := &Transport{
+ peers: map[types.ID]Peer{types.ID(1): peer},
+ prober: probing.NewProber(nil),
+ }
+ u := "http://localhost:2380"
+ tr.UpdatePeer(types.ID(1), []string{u})
+ wurls := types.URLs(testutil.MustNewURLs(t, []string{"http://localhost:2380"}))
+ if !reflect.DeepEqual(peer.peerURLs, wurls) {
+ t.Errorf("urls = %+v, want %+v", peer.peerURLs, wurls)
+ }
+}
+
+func TestTransportErrorc(t *testing.T) {
+ errorc := make(chan error, 1)
+ tr := &Transport{
+ Raft: &fakeRaft{},
+ LeaderStats: stats.NewLeaderStats(""),
+ ErrorC: errorc,
+ streamRt: newRespRoundTripper(http.StatusForbidden, nil),
+ pipelineRt: newRespRoundTripper(http.StatusForbidden, nil),
+ peers: make(map[types.ID]Peer),
+ prober: probing.NewProber(nil),
+ }
+ tr.AddPeer(1, []string{"http://localhost:2380"})
+ defer tr.Stop()
+
+ select {
+ case <-errorc:
+ t.Fatalf("received unexpected from errorc")
+ case <-time.After(10 * time.Millisecond):
+ }
+ tr.peers[1].send(raftpb.Message{})
+
+ select {
+ case <-errorc:
+ case <-time.After(1 * time.Second):
+ t.Fatalf("cannot receive error from errorc")
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/urlpick.go b/vendor/github.com/coreos/etcd/rafthttp/urlpick.go
new file mode 100644
index 00000000..61839dee
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/urlpick.go
@@ -0,0 +1,57 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "net/url"
+ "sync"
+
+ "github.com/coreos/etcd/pkg/types"
+)
+
+type urlPicker struct {
+ mu sync.Mutex // guards urls and picked
+ urls types.URLs
+ picked int
+}
+
+func newURLPicker(urls types.URLs) *urlPicker {
+ return &urlPicker{
+ urls: urls,
+ }
+}
+
+func (p *urlPicker) update(urls types.URLs) {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+ p.urls = urls
+ p.picked = 0
+}
+
+func (p *urlPicker) pick() url.URL {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+ return p.urls[p.picked]
+}
+
+// unreachable notices the picker that the given url is unreachable,
+// and it should use other possible urls.
+func (p *urlPicker) unreachable(u url.URL) {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+ if u == p.urls[p.picked] {
+ p.picked = (p.picked + 1) % len(p.urls)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/urlpick_test.go b/vendor/github.com/coreos/etcd/rafthttp/urlpick_test.go
new file mode 100644
index 00000000..70ebbd32
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/urlpick_test.go
@@ -0,0 +1,73 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "net/url"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+// TestURLPickerPickTwice tests that pick returns a possible url,
+// and always returns the same one.
+func TestURLPickerPickTwice(t *testing.T) {
+ picker := mustNewURLPicker(t, []string{"http://127.0.0.1:2380", "http://127.0.0.1:7001"})
+
+ u := picker.pick()
+ urlmap := map[url.URL]bool{
+ {Scheme: "http", Host: "127.0.0.1:2380"}: true,
+ {Scheme: "http", Host: "127.0.0.1:7001"}: true,
+ }
+ if !urlmap[u] {
+ t.Errorf("url picked = %+v, want a possible url in %+v", u, urlmap)
+ }
+
+ // pick out the same url when calling pick again
+ uu := picker.pick()
+ if u != uu {
+ t.Errorf("url picked = %+v, want %+v", uu, u)
+ }
+}
+
+func TestURLPickerUpdate(t *testing.T) {
+ picker := mustNewURLPicker(t, []string{"http://127.0.0.1:2380", "http://127.0.0.1:7001"})
+ picker.update(testutil.MustNewURLs(t, []string{"http://localhost:2380", "http://localhost:7001"}))
+
+ u := picker.pick()
+ urlmap := map[url.URL]bool{
+ {Scheme: "http", Host: "localhost:2380"}: true,
+ {Scheme: "http", Host: "localhost:7001"}: true,
+ }
+ if !urlmap[u] {
+ t.Errorf("url picked = %+v, want a possible url in %+v", u, urlmap)
+ }
+}
+
+func TestURLPickerUnreachable(t *testing.T) {
+ picker := mustNewURLPicker(t, []string{"http://127.0.0.1:2380", "http://127.0.0.1:7001"})
+ u := picker.pick()
+ picker.unreachable(u)
+
+ uu := picker.pick()
+ if u == uu {
+ t.Errorf("url picked = %+v, want other possible urls", uu)
+ }
+}
+
+func mustNewURLPicker(t *testing.T, us []string) *urlPicker {
+ urls := testutil.MustNewURLs(t, us)
+ return newURLPicker(urls)
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/util.go b/vendor/github.com/coreos/etcd/rafthttp/util.go
new file mode 100644
index 00000000..12e548c7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/util.go
@@ -0,0 +1,177 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "fmt"
+ "io"
+ "net"
+ "net/http"
+ "net/url"
+ "strings"
+ "time"
+
+ "github.com/coreos/etcd/pkg/transport"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/version"
+ "github.com/coreos/go-semver/semver"
+)
+
+var (
+ errMemberRemoved = fmt.Errorf("the member has been permanently removed from the cluster")
+ errMemberNotFound = fmt.Errorf("member not found")
+)
+
+// NewListener returns a listener for raft message transfer between peers.
+// It uses timeout listener to identify broken streams promptly.
+func NewListener(u url.URL, tlsinfo *transport.TLSInfo) (net.Listener, error) {
+ return transport.NewTimeoutListener(u.Host, u.Scheme, tlsinfo, ConnReadTimeout, ConnWriteTimeout)
+}
+
+// NewRoundTripper returns a roundTripper used to send requests
+// to rafthttp listener of remote peers.
+func NewRoundTripper(tlsInfo transport.TLSInfo, dialTimeout time.Duration) (http.RoundTripper, error) {
+ // It uses timeout transport to pair with remote timeout listeners.
+ // It sets no read/write timeout, because message in requests may
+ // take long time to write out before reading out the response.
+ return transport.NewTimeoutTransport(tlsInfo, dialTimeout, 0, 0)
+}
+
+// newStreamRoundTripper returns a roundTripper used to send stream requests
+// to rafthttp listener of remote peers.
+// Read/write timeout is set for stream roundTripper to promptly
+// find out broken status, which minimizes the number of messages
+// sent on broken connection.
+func newStreamRoundTripper(tlsInfo transport.TLSInfo, dialTimeout time.Duration) (http.RoundTripper, error) {
+ return transport.NewTimeoutTransport(tlsInfo, dialTimeout, ConnReadTimeout, ConnWriteTimeout)
+}
+
+// createPostRequest creates a HTTP POST request that sends raft message.
+func createPostRequest(u url.URL, path string, body io.Reader, ct string, urls types.URLs, from, cid types.ID) *http.Request {
+ uu := u
+ uu.Path = path
+ req, err := http.NewRequest("POST", uu.String(), body)
+ if err != nil {
+ plog.Panicf("unexpected new request error (%v)", err)
+ }
+ req.Header.Set("Content-Type", ct)
+ req.Header.Set("X-Server-From", from.String())
+ req.Header.Set("X-Server-Version", version.Version)
+ req.Header.Set("X-Min-Cluster-Version", version.MinClusterVersion)
+ req.Header.Set("X-Etcd-Cluster-ID", cid.String())
+ setPeerURLsHeader(req, urls)
+
+ return req
+}
+
+// checkPostResponse checks the response of the HTTP POST request that sends
+// raft message.
+func checkPostResponse(resp *http.Response, body []byte, req *http.Request, to types.ID) error {
+ switch resp.StatusCode {
+ case http.StatusPreconditionFailed:
+ switch strings.TrimSuffix(string(body), "\n") {
+ case errIncompatibleVersion.Error():
+ plog.Errorf("request sent was ignored by peer %s (server version incompatible)", to)
+ return errIncompatibleVersion
+ case errClusterIDMismatch.Error():
+ plog.Errorf("request sent was ignored (cluster ID mismatch: remote[%s]=%s, local=%s)",
+ to, resp.Header.Get("X-Etcd-Cluster-ID"), req.Header.Get("X-Etcd-Cluster-ID"))
+ return errClusterIDMismatch
+ default:
+ return fmt.Errorf("unhandled error %q when precondition failed", string(body))
+ }
+ case http.StatusForbidden:
+ return errMemberRemoved
+ case http.StatusNoContent:
+ return nil
+ default:
+ return fmt.Errorf("unexpected http status %s while posting to %q", http.StatusText(resp.StatusCode), req.URL.String())
+ }
+}
+
+// reportCriticalError reports the given error through sending it into
+// the given error channel.
+// If the error channel is filled up when sending error, it drops the error
+// because the fact that error has happened is reported, which is
+// good enough.
+func reportCriticalError(err error, errc chan<- error) {
+ select {
+ case errc <- err:
+ default:
+ }
+}
+
+// compareMajorMinorVersion returns an integer comparing two versions based on
+// their major and minor version. The result will be 0 if a==b, -1 if a < b,
+// and 1 if a > b.
+func compareMajorMinorVersion(a, b *semver.Version) int {
+ na := &semver.Version{Major: a.Major, Minor: a.Minor}
+ nb := &semver.Version{Major: b.Major, Minor: b.Minor}
+ switch {
+ case na.LessThan(*nb):
+ return -1
+ case nb.LessThan(*na):
+ return 1
+ default:
+ return 0
+ }
+}
+
+// serverVersion returns the server version from the given header.
+func serverVersion(h http.Header) *semver.Version {
+ verStr := h.Get("X-Server-Version")
+ // backward compatibility with etcd 2.0
+ if verStr == "" {
+ verStr = "2.0.0"
+ }
+ return semver.Must(semver.NewVersion(verStr))
+}
+
+// serverVersion returns the min cluster version from the given header.
+func minClusterVersion(h http.Header) *semver.Version {
+ verStr := h.Get("X-Min-Cluster-Version")
+ // backward compatibility with etcd 2.0
+ if verStr == "" {
+ verStr = "2.0.0"
+ }
+ return semver.Must(semver.NewVersion(verStr))
+}
+
+// checkVersionCompability checks whether the given version is compatible
+// with the local version.
+func checkVersionCompability(name string, server, minCluster *semver.Version) error {
+ localServer := semver.Must(semver.NewVersion(version.Version))
+ localMinCluster := semver.Must(semver.NewVersion(version.MinClusterVersion))
+ if compareMajorMinorVersion(server, localMinCluster) == -1 {
+ return fmt.Errorf("remote version is too low: remote[%s]=%s, local=%s", name, server, localServer)
+ }
+ if compareMajorMinorVersion(minCluster, localServer) == 1 {
+ return fmt.Errorf("local version is too low: remote[%s]=%s, local=%s", name, server, localServer)
+ }
+ return nil
+}
+
+// setPeerURLsHeader reports local urls for peer discovery
+func setPeerURLsHeader(req *http.Request, urls types.URLs) {
+ if urls == nil {
+ // often not set in unit tests
+ return
+ }
+ peerURLs := make([]string, urls.Len())
+ for i := range urls {
+ peerURLs[i] = urls[i].String()
+ }
+ req.Header.Set("X-PeerURLs", strings.Join(peerURLs, ","))
+}
diff --git a/vendor/github.com/coreos/etcd/rafthttp/util_test.go b/vendor/github.com/coreos/etcd/rafthttp/util_test.go
new file mode 100644
index 00000000..6ff47969
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/rafthttp/util_test.go
@@ -0,0 +1,220 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 rafthttp
+
+import (
+ "bytes"
+ "encoding/binary"
+ "io"
+ "net/http"
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/version"
+ "github.com/coreos/go-semver/semver"
+)
+
+func TestEntry(t *testing.T) {
+ tests := []raftpb.Entry{
+ {},
+ {Term: 1, Index: 1},
+ {Term: 1, Index: 1, Data: []byte("some data")},
+ }
+ for i, tt := range tests {
+ b := &bytes.Buffer{}
+ if err := writeEntryTo(b, &tt); err != nil {
+ t.Errorf("#%d: unexpected write ents error: %v", i, err)
+ continue
+ }
+ var ent raftpb.Entry
+ if err := readEntryFrom(b, &ent); err != nil {
+ t.Errorf("#%d: unexpected read ents error: %v", i, err)
+ continue
+ }
+ if !reflect.DeepEqual(ent, tt) {
+ t.Errorf("#%d: ent = %+v, want %+v", i, ent, tt)
+ }
+ }
+}
+
+func TestCompareMajorMinorVersion(t *testing.T) {
+ tests := []struct {
+ va, vb *semver.Version
+ w int
+ }{
+ // equal to
+ {
+ semver.Must(semver.NewVersion("2.1.0")),
+ semver.Must(semver.NewVersion("2.1.0")),
+ 0,
+ },
+ // smaller than
+ {
+ semver.Must(semver.NewVersion("2.0.0")),
+ semver.Must(semver.NewVersion("2.1.0")),
+ -1,
+ },
+ // bigger than
+ {
+ semver.Must(semver.NewVersion("2.2.0")),
+ semver.Must(semver.NewVersion("2.1.0")),
+ 1,
+ },
+ // ignore patch
+ {
+ semver.Must(semver.NewVersion("2.1.1")),
+ semver.Must(semver.NewVersion("2.1.0")),
+ 0,
+ },
+ // ignore prerelease
+ {
+ semver.Must(semver.NewVersion("2.1.0-alpha.0")),
+ semver.Must(semver.NewVersion("2.1.0")),
+ 0,
+ },
+ }
+ for i, tt := range tests {
+ if g := compareMajorMinorVersion(tt.va, tt.vb); g != tt.w {
+ t.Errorf("#%d: compare = %d, want %d", i, g, tt.w)
+ }
+ }
+}
+
+func TestServerVersion(t *testing.T) {
+ tests := []struct {
+ h http.Header
+ wv *semver.Version
+ }{
+ // backward compatibility with etcd 2.0
+ {
+ http.Header{},
+ semver.Must(semver.NewVersion("2.0.0")),
+ },
+ {
+ http.Header{"X-Server-Version": []string{"2.1.0"}},
+ semver.Must(semver.NewVersion("2.1.0")),
+ },
+ {
+ http.Header{"X-Server-Version": []string{"2.1.0-alpha.0+git"}},
+ semver.Must(semver.NewVersion("2.1.0-alpha.0+git")),
+ },
+ }
+ for i, tt := range tests {
+ v := serverVersion(tt.h)
+ if v.String() != tt.wv.String() {
+ t.Errorf("#%d: version = %s, want %s", i, v, tt.wv)
+ }
+ }
+}
+
+func TestMinClusterVersion(t *testing.T) {
+ tests := []struct {
+ h http.Header
+ wv *semver.Version
+ }{
+ // backward compatibility with etcd 2.0
+ {
+ http.Header{},
+ semver.Must(semver.NewVersion("2.0.0")),
+ },
+ {
+ http.Header{"X-Min-Cluster-Version": []string{"2.1.0"}},
+ semver.Must(semver.NewVersion("2.1.0")),
+ },
+ {
+ http.Header{"X-Min-Cluster-Version": []string{"2.1.0-alpha.0+git"}},
+ semver.Must(semver.NewVersion("2.1.0-alpha.0+git")),
+ },
+ }
+ for i, tt := range tests {
+ v := minClusterVersion(tt.h)
+ if v.String() != tt.wv.String() {
+ t.Errorf("#%d: version = %s, want %s", i, v, tt.wv)
+ }
+ }
+}
+
+func TestCheckVersionCompatibility(t *testing.T) {
+ ls := semver.Must(semver.NewVersion(version.Version))
+ lmc := semver.Must(semver.NewVersion(version.MinClusterVersion))
+ tests := []struct {
+ server *semver.Version
+ minCluster *semver.Version
+ wok bool
+ }{
+ // the same version as local
+ {
+ ls,
+ lmc,
+ true,
+ },
+ // one version lower
+ {
+ lmc,
+ &semver.Version{},
+ true,
+ },
+ // one version higher
+ {
+ &semver.Version{Major: ls.Major + 1},
+ ls,
+ true,
+ },
+ // too low version
+ {
+ &semver.Version{Major: lmc.Major - 1},
+ &semver.Version{},
+ false,
+ },
+ // too high version
+ {
+ &semver.Version{Major: ls.Major + 1, Minor: 1},
+ &semver.Version{Major: ls.Major + 1},
+ false,
+ },
+ }
+ for i, tt := range tests {
+ err := checkVersionCompability("", tt.server, tt.minCluster)
+ if ok := err == nil; ok != tt.wok {
+ t.Errorf("#%d: ok = %v, want %v", i, ok, tt.wok)
+ }
+ }
+}
+
+func writeEntryTo(w io.Writer, ent *raftpb.Entry) error {
+ size := ent.Size()
+ if err := binary.Write(w, binary.BigEndian, uint64(size)); err != nil {
+ return err
+ }
+ b, err := ent.Marshal()
+ if err != nil {
+ return err
+ }
+ _, err = w.Write(b)
+ return err
+}
+
+func readEntryFrom(r io.Reader, ent *raftpb.Entry) error {
+ var l uint64
+ if err := binary.Read(r, binary.BigEndian, &l); err != nil {
+ return err
+ }
+ buf := make([]byte, int(l))
+ if _, err := io.ReadFull(r, buf); err != nil {
+ return err
+ }
+ return ent.Unmarshal(buf)
+}
diff --git a/vendor/github.com/coreos/etcd/scripts/build-aci b/vendor/github.com/coreos/etcd/scripts/build-aci
new file mode 100755
index 00000000..7a4cff93
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/scripts/build-aci
@@ -0,0 +1,84 @@
+#!/usr/bin/env bash
+
+set -e
+
+BINARYDIR=${BINARYDIR:-bin}
+BUILDDIR=${BUILDDIR:-bin}
+
+# A non-installed acbuild can be used, for example:
+# ACBUILD=../../appc/acbuild/bin/acbuild
+ACBUILD=${ACBUILD:-acbuild}
+
+VERSION=$1
+
+go2aci() {
+ case "${1}" in
+ "arm64") echo "aarch64";;
+ *) echo "${1}";;
+ esac
+}
+
+if ! command -v $ACBUILD >/dev/null; then
+ echo "acbuild ($ACBUILD) is not executable"
+ exit 1
+fi
+
+if [ ! -x $BINARYDIR/etcd ] ; then
+ echo "$BINARYDIR/etcd not found. Is it compiled?"
+ exit 1
+fi
+
+if [ -z "$VERSION" ] ; then
+ echo "Usage: scripts/build-aci VERSION"
+ exit 1
+fi
+
+acbuild --debug begin
+
+TMPHOSTS="$(mktemp)"
+ACI_ARCH="$(go2aci ${GOARCH})"
+
+acbuildEnd() {
+ rm "$TMPHOSTS"
+ export EXIT=$?
+ acbuild --debug end && exit $EXIT
+}
+trap acbuildEnd EXIT
+
+cat <<DF > $TMPHOSTS
+127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
+DF
+
+acbuild --debug set-name coreos.com/etcd
+acbuild --debug annotation add appc.io/executor/supports-systemd-notify true
+
+acbuild --debug copy $BINARYDIR/etcd /usr/local/bin/etcd
+acbuild --debug copy $BINARYDIR/etcdctl /usr/local/bin/etcdctl
+
+acbuild --debug copy README.md README.md
+acbuild --debug copy etcdctl/README.md README-etcdctl.md
+acbuild --debug copy etcdctl/READMEv2.md READMEv2-etcdctl.md
+acbuild --debug copy-to-dir Documentation .
+
+acbuild --debug environment add ETCD_DATA_DIR /var/lib/etcd
+acbuild --debug mount add data-dir /var/lib/etcd
+
+acbuild --debug label add version "$VERSION"
+
+acbuild --debug set-exec -- /usr/local/bin/etcd
+
+acbuild --debug port add client tcp 2379
+acbuild --debug port add peer tcp 2380
+
+acbuild --debug copy "$TMPHOSTS" /etc/hosts
+
+acbuild --debug label add arch "${ACI_ARCH}"
+
+# mkdir default data-dir
+mkdir -p .acbuild/currentaci/rootfs/var/lib/etcd
+
+# symlinks for backward-compatibility
+ln -s ./usr/local/bin/etcd .acbuild/currentaci/rootfs/etcd
+ln -s ./usr/local/bin/etcdctl .acbuild/currentaci/rootfs/etcdctl
+
+acbuild --debug write --overwrite $BUILDDIR/etcd-${1}-linux-${ACI_ARCH}.aci
diff --git a/vendor/github.com/coreos/etcd/scripts/build-binary b/vendor/github.com/coreos/etcd/scripts/build-binary
new file mode 100755
index 00000000..3b4b763d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/scripts/build-binary
@@ -0,0 +1,91 @@
+#!/usr/bin/env bash
+
+set -e
+
+VER=$1
+PROJ="etcd"
+
+if [ -z "$1" ]; then
+ echo "Usage: ${0} VERSION" >> /dev/stderr
+ exit 255
+fi
+
+set -u
+
+function setup_env {
+ local proj=${1}
+ local ver=${2}
+
+ if [ ! -d ${proj} ]; then
+ git clone https://github.com/coreos/${proj}
+ fi
+
+ pushd ${proj} >/dev/null
+ git checkout master
+ git fetch --all
+ git reset --hard origin/master
+ git checkout $ver
+ popd >/dev/null
+}
+
+
+function package {
+ local target=${1}
+ local srcdir="${2}/bin"
+
+ local ccdir="${srcdir}/${GOOS}_${GOARCH}"
+ if [ -d ${ccdir} ]; then
+ srcdir=${ccdir}
+ fi
+ local ext=""
+ if [ ${GOOS} == "windows" ]; then
+ ext=".exe"
+ fi
+ for bin in etcd etcdctl; do
+ cp ${srcdir}/${bin} ${target}/${bin}${ext}
+ done
+
+ cp etcd/README.md ${target}/README.md
+ cp etcd/etcdctl/README.md ${target}/README-etcdctl.md
+ cp etcd/etcdctl/READMEv2.md ${target}/READMEv2-etcdctl.md
+
+ cp -R etcd/Documentation ${target}/Documentation
+}
+
+function main {
+ mkdir release
+ cd release
+ setup_env ${PROJ} ${VER}
+
+ for os in darwin windows linux; do
+ export GOOS=${os}
+ TARGET_ARCHS=("amd64")
+
+ if [ ${GOOS} == "linux" ]; then
+ TARGET_ARCHS+=("arm64")
+ TARGET_ARCHS+=("ppc64le")
+ fi
+
+ for TARGET_ARCH in "${TARGET_ARCHS[@]}"; do
+ export GOARCH=${TARGET_ARCH}
+
+ pushd etcd >/dev/null
+ GO_LDFLAGS="-s" ./build
+ popd >/dev/null
+
+ TARGET="etcd-${VER}-${GOOS}-${GOARCH}"
+ mkdir ${TARGET}
+ package ${TARGET} ${PROJ}
+
+ if [ ${GOOS} == "linux" ]; then
+ tar cfz ${TARGET}.tar.gz ${TARGET}
+ echo "Wrote release/${TARGET}.tar.gz"
+ else
+ zip -qr ${TARGET}.zip ${TARGET}
+ echo "Wrote release/${TARGET}.zip"
+ fi
+ done
+ done
+}
+
+main
diff --git a/vendor/github.com/coreos/etcd/scripts/build-docker b/vendor/github.com/coreos/etcd/scripts/build-docker
new file mode 100755
index 00000000..b7aea2bc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/scripts/build-docker
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+
+set -e
+
+if [ "$#" -ne 1 ]; then
+ echo "Usage: $0 VERSION" >&2
+ exit 1
+fi
+
+VERSION=${1}
+ARCH=$(go env GOARCH)
+DOCKERFILE="Dockerfile-release"
+: ${TAG:="quay.io/coreos/etcd"}
+
+if [ -z ${BINARYDIR} ]; then
+ RELEASE="etcd-${1}"-`go env GOOS`-`go env GOARCH`
+ BINARYDIR="${RELEASE}"
+ TARFILE="${RELEASE}.tar.gz"
+ TARURL="https://github.com/coreos/etcd/releases/download/${1}/${TARFILE}"
+ if ! curl -f -L -o ${TARFILE} ${TARURL} ; then
+ echo "Failed to download ${TARURL}."
+ exit 1
+ fi
+ tar -zvxf ${TARFILE}
+fi
+
+if [ ${ARCH} != "amd64" ]; then
+ DOCKERFILE+=".${ARCH}"
+ VERSION+="-${ARCH}"
+fi
+
+BINARYDIR=${BINARYDIR:-.}
+BUILDDIR=${BUILDDIR:-.}
+
+IMAGEDIR=${BUILDDIR}/image-docker
+
+mkdir -p ${IMAGEDIR}/var/etcd
+mkdir -p ${IMAGEDIR}/var/lib/etcd
+cp ${BINARYDIR}/etcd ${BINARYDIR}/etcdctl ${IMAGEDIR}
+
+cat ./${DOCKERFILE} > ${IMAGEDIR}/Dockerfile
+
+docker build -t ${TAG}:${VERSION} ${IMAGEDIR}
diff --git a/vendor/github.com/coreos/etcd/scripts/genproto.sh b/vendor/github.com/coreos/etcd/scripts/genproto.sh
new file mode 100755
index 00000000..1b460734
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/scripts/genproto.sh
@@ -0,0 +1,135 @@
+#!/usr/bin/env bash
+#
+# Generate all etcd protobuf bindings.
+# Run from repository root.
+#
+set -e
+
+if ! [[ "$0" =~ "scripts/genproto.sh" ]]; then
+ echo "must be run from repository root"
+ exit 255
+fi
+
+# for now, be conservative about what version of protoc we expect
+if ! [[ $(protoc --version) =~ "3.2.0" ]]; then
+ echo "could not find protoc 3.2.0, is it installed + in PATH?"
+ exit 255
+fi
+
+# directories containing protos to be built
+DIRS="./wal/walpb ./etcdserver/etcdserverpb ./snap/snappb ./raft/raftpb ./mvcc/mvccpb ./lease/leasepb ./auth/authpb ./etcdserver/api/v3lock/v3lockpb ./etcdserver/api/v3election/v3electionpb"
+
+# exact version of protoc-gen-gogo to build
+GOGO_PROTO_SHA="8d70fb3182befc465c4a1eac8ad4d38ff49778e2"
+GRPC_GATEWAY_SHA="84398b94e188ee336f307779b57b3aa91af7063c"
+
+# set up self-contained GOPATH for building
+export GOPATH=${PWD}/gopath.proto
+export GOBIN=${PWD}/bin
+export PATH="${GOBIN}:${PATH}"
+
+COREOS_ROOT="${GOPATH}/src/github.com/coreos"
+ETCD_ROOT="${COREOS_ROOT}/etcd"
+GOGOPROTO_ROOT="${GOPATH}/src/github.com/gogo/protobuf"
+GOGOPROTO_PATH="${GOGOPROTO_ROOT}:${GOGOPROTO_ROOT}/protobuf"
+GRPC_GATEWAY_ROOT="${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway"
+
+rm -f "${ETCD_ROOT}"
+mkdir -p "${COREOS_ROOT}"
+ln -s "${PWD}" "${ETCD_ROOT}"
+
+# Ensure we have the right version of protoc-gen-gogo by building it every time.
+# TODO(jonboulle): vendor this instead of `go get`ting it.
+go get -u github.com/gogo/protobuf/{proto,protoc-gen-gogo,gogoproto}
+go get -u golang.org/x/tools/cmd/goimports
+pushd "${GOGOPROTO_ROOT}"
+ git reset --hard "${GOGO_PROTO_SHA}"
+ make install
+popd
+
+# generate gateway code
+go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
+go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
+pushd "${GRPC_GATEWAY_ROOT}"
+ git reset --hard "${GRPC_GATEWAY_SHA}"
+ go install ./protoc-gen-grpc-gateway
+popd
+
+for dir in ${DIRS}; do
+ pushd ${dir}
+ protoc --gofast_out=plugins=grpc,import_prefix=github.com/coreos/:. -I=".:${GOGOPROTO_PATH}:${COREOS_ROOT}:${GRPC_GATEWAY_ROOT}/third_party/googleapis" *.proto
+ sed -i.bak -E "s/github\.com\/coreos\/(gogoproto|github\.com|golang\.org|google\.golang\.org)/\1/g" *.pb.go
+ sed -i.bak -E 's/github\.com\/coreos\/(errors|fmt|io)/\1/g' *.pb.go
+ sed -i.bak -E 's/import _ \"gogoproto\"//g' *.pb.go
+ sed -i.bak -E 's/import fmt \"fmt\"//g' *.pb.go
+ sed -i.bak -E 's/import _ \"github\.com\/coreos\/google\/api\"//g' *.pb.go
+ rm -f *.bak
+ goimports -w *.pb.go
+ popd
+done
+
+# remove old swagger files so it's obvious whether the files fail to generate
+rm -rf Documentation/dev-guide/apispec/swagger/*json
+for pb in etcdserverpb/rpc api/v3lock/v3lockpb/v3lock api/v3election/v3electionpb/v3election; do
+ protobase="etcdserver/${pb}"
+ protoc -I. \
+ -I${GRPC_GATEWAY_ROOT}/third_party/googleapis \
+ -I${GOGOPROTO_PATH} \
+ -I${COREOS_ROOT} \
+ --grpc-gateway_out=logtostderr=true:. \
+ --swagger_out=logtostderr=true:./Documentation/dev-guide/apispec/swagger/. \
+ ${protobase}.proto
+ # hack to move gw files around so client won't include them
+ pkgpath=`dirname ${protobase}`
+ pkg=`basename ${pkgpath}`
+ gwfile="${protobase}.pb.gw.go"
+ sed -i.bak -E "s/package $pkg/package gw/g" ${gwfile}
+ sed -i.bak -E "s/protoReq /&$pkg\./g" ${gwfile}
+ sed -i.bak -E "s/, client /, client $pkg./g" ${gwfile}
+ sed -i.bak -E "s/Client /, client $pkg./g" ${gwfile}
+ sed -i.bak -E "s/[^(]*Client, runtime/${pkg}.&/" ${gwfile}
+ sed -i.bak -E "s/New[A-Za-z]*Client/${pkg}.&/" ${gwfile}
+ # darwin doesn't like newlines in sed...
+ sed -i.bak -E "s|import \(|& \"github.com/coreos/etcd/${pkgpath}\"|" ${gwfile}
+ mkdir -p ${pkgpath}/gw/
+ go fmt ${gwfile}
+ mv ${gwfile} ${pkgpath}/gw/
+ rm -f ./etcdserver/${pb}*.bak
+ swaggerName=`basename ${pb}`
+ mv Documentation/dev-guide/apispec/swagger/etcdserver/${pb}.swagger.json \
+ Documentation/dev-guide/apispec/swagger/${swaggerName}.swagger.json
+done
+rm -rf Documentation/dev-guide/apispec/swagger/etcdserver/
+
+# install protodoc
+# go get -v -u github.com/coreos/protodoc
+#
+# by default, do not run this option.
+# only run when './scripts/genproto.sh -g'
+#
+if [ "$1" = "-g" ]; then
+ echo "protodoc is auto-generating grpc API reference documentation..."
+ go get -v -u github.com/coreos/protodoc
+ SHA_PROTODOC="4372ee725035a208404e2d5465ba921469decc32"
+ PROTODOC_PATH="${GOPATH}/src/github.com/coreos/protodoc"
+ pushd "${PROTODOC_PATH}"
+ git reset --hard "${SHA_PROTODOC}"
+ go install
+ echo "protodoc is updated"
+ popd
+
+ protodoc --directories="etcdserver/etcdserverpb=service_message,mvcc/mvccpb=service_message,lease/leasepb=service_message,auth/authpb=service_message" \
+ --title="etcd API Reference" \
+ --output="Documentation/dev-guide/api_reference_v3.md" \
+ --message-only-from-this-file="etcdserver/etcdserverpb/rpc.proto" \
+ --disclaimer="This is a generated documentation. Please read the proto files for more."
+
+ protodoc --directories="etcdserver/api/v3lock/v3lockpb=service_message,etcdserver/api/v3election/v3electionpb=service_message,mvcc/mvccpb=service_message" \
+ --title="etcd concurrency API Reference" \
+ --output="Documentation/dev-guide/api_concurrency_reference_v3.md" \
+ --disclaimer="This is a generated documentation. Please read the proto files for more."
+
+ echo "protodoc is finished..."
+else
+ echo "skipping grpc API reference document auto-generation..."
+fi
diff --git a/vendor/github.com/coreos/etcd/scripts/install-marker.sh b/vendor/github.com/coreos/etcd/scripts/install-marker.sh
new file mode 100755
index 00000000..0cca4017
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/scripts/install-marker.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+set -e
+
+ARCH=$1
+
+if [ -z "$1" ]; then
+ echo "Usage: ${0} [amd64 or darwin], defaulting to 'amd64'" >> /dev/stderr
+ ARCH=amd64
+fi
+
+MARKER_URL=https://storage.googleapis.com/etcd/test-binaries/marker-v0.4.0-x86_64-unknown-linux-gnu
+if [ ${ARCH} == "darwin" ]; then
+ MARKER_URL=https://storage.googleapis.com/etcd/test-binaries/marker-v0.4.0-x86_64-apple-darwin
+fi
+
+echo "Installing marker"
+curl -L ${MARKER_URL} -o ${GOPATH}/bin/marker
+chmod 755 ${GOPATH}/bin/marker
+
+${GOPATH}/bin/marker --version
diff --git a/vendor/github.com/coreos/etcd/scripts/release.sh b/vendor/github.com/coreos/etcd/scripts/release.sh
new file mode 100755
index 00000000..1c846694
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/scripts/release.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+#
+# Build all release binaries and images to directory ./release.
+# Run from repository root.
+#
+set -e
+
+VERSION=$1
+if [ -z "${VERSION}" ]; then
+ echo "Usage: ${0} VERSION" >> /dev/stderr
+ exit 255
+fi
+
+if ! command -v acbuild >/dev/null; then
+ echo "cannot find acbuild"
+ exit 1
+fi
+
+if ! command -v docker >/dev/null; then
+ echo "cannot find docker"
+ exit 1
+fi
+
+ETCD_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
+
+pushd ${ETCD_ROOT} >/dev/null
+ echo Building etcd binary...
+ ./scripts/build-binary ${VERSION}
+
+ # ppc64le not yet supported by acbuild.
+ for TARGET_ARCH in "amd64" "arm64"; do
+ echo Building ${TARGET_ARCH} aci image...
+ GOARCH=${TARGET_ARCH} BINARYDIR=release/etcd-${VERSION}-linux-${TARGET_ARCH} BUILDDIR=release ./scripts/build-aci ${VERSION}
+ done
+
+ for TARGET_ARCH in "amd64" "arm64" "ppc64le"; do
+ echo Building ${TARGET_ARCH} docker image...
+ GOARCH=${TARGET_ARCH} BINARYDIR=release/etcd-${VERSION}-linux-${TARGET_ARCH} BUILDDIR=release ./scripts/build-docker ${VERSION}
+ done
+popd >/dev/null
diff --git a/vendor/github.com/coreos/etcd/scripts/updatebom.sh b/vendor/github.com/coreos/etcd/scripts/updatebom.sh
new file mode 100755
index 00000000..08f59f28
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/scripts/updatebom.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+
+set -e
+
+if ! [[ "$0" =~ "scripts/updatebom.sh" ]]; then
+ echo "must be run from repository root"
+ exit 255
+fi
+
+echo "installing 'bill-of-materials.json'"
+go get -v -u github.com/coreos/license-bill-of-materials
+
+echo "setting up GOPATH"
+rm -rf ./gopath
+mkdir ./gopath
+mv ./cmd/vendor ./gopath/src
+
+echo "generating bill-of-materials.json"
+GOPATH=`pwd`/gopath license-bill-of-materials \
+ --override-file ./bill-of-materials.override.json \
+ github.com/coreos/etcd github.com/coreos/etcd/etcdctl > bill-of-materials.json
+
+echo "reverting GOPATH,vendor"
+mv ./gopath/src ./cmd/vendor
+rm -rf ./gopath
+
+echo "generated bill-of-materials.json"
+
diff --git a/vendor/github.com/coreos/etcd/scripts/updatedep.sh b/vendor/github.com/coreos/etcd/scripts/updatedep.sh
new file mode 100755
index 00000000..651aa3cd
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/scripts/updatedep.sh
@@ -0,0 +1,69 @@
+#!/usr/bin/env bash
+
+# A script for updating godep dependencies for the vendored directory /cmd/
+# without pulling in etcd itself as a dependency.
+#
+# update depedency
+# 1. edit glide.yaml with version, git SHA
+# 2. run ./scripts/updatedep.sh
+# 3. it automatically detects new git SHA, and vendors updates to cmd/vendor directory
+#
+# add depedency
+# 1. run ./scripts/updatedep.sh github.com/USER/PROJECT#^1.0.0
+# OR
+# ./scripts/updatedep.sh github.com/USER/PROJECT#9b772b54b3bf0be1eec083c9669766a56332559a
+# 2. make sure glide.yaml and glide.lock are updated
+
+if ! [[ "$0" =~ "scripts/updatedep.sh" ]]; then
+ echo "must be run from repository root"
+ exit 255
+fi
+
+rm -rf vendor
+mv cmd/vendor vendor
+
+# TODO: glide doesn't play well with symlink
+echo "manually deleting etcd-repo symlink in vendor"
+rm -f vendor/github.com/coreos/etcd
+
+GLIDE_ROOT="$GOPATH/src/github.com/Masterminds/glide"
+GLIDE_SHA=21ff6d397ccca910873d8eaabab6a941c364cc70
+go get -d -u github.com/Masterminds/glide
+pushd "${GLIDE_ROOT}"
+ git reset --hard ${GLIDE_SHA}
+ go install
+popd
+
+GLIDE_VC_ROOT="$GOPATH/src/github.com/sgotti/glide-vc"
+GLIDE_VC_SHA=d96375d23c85287e80296cdf48f9d21c227fa40a
+go get -d -u github.com/sgotti/glide-vc
+pushd "${GLIDE_VC_ROOT}"
+ git reset --hard ${GLIDE_VC_SHA}
+ go install
+popd
+
+if [ -n "$1" ]; then
+ echo "glide get on $1"
+ matches=`grep "name: $1" glide.lock`
+ if [ ! -z "$matches" ]; then
+ echo "glide update on $1"
+ glide update --strip-vendor $1
+ else
+ echo "glide get on $1"
+ glide get --strip-vendor $1
+ fi
+else
+ echo "glide update on *"
+ glide update --strip-vendor
+fi;
+
+echo "removing test files"
+glide vc --only-code --no-tests
+
+mv vendor cmd/
+
+echo "recreating symlink to etcd"
+ln -s ../../../../ cmd/vendor/github.com/coreos/etcd
+
+echo "done"
+
diff --git a/vendor/github.com/coreos/etcd/snap/db.go b/vendor/github.com/coreos/etcd/snap/db.go
new file mode 100644
index 00000000..01d897ae
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/snap/db.go
@@ -0,0 +1,77 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 snap
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+
+ "github.com/coreos/etcd/pkg/fileutil"
+)
+
+var ErrNoDBSnapshot = errors.New("snap: snapshot file doesn't exist")
+
+// SaveDBFrom saves snapshot of the database from the given reader. It
+// guarantees the save operation is atomic.
+func (s *Snapshotter) SaveDBFrom(r io.Reader, id uint64) (int64, error) {
+ f, err := ioutil.TempFile(s.dir, "tmp")
+ if err != nil {
+ return 0, err
+ }
+ var n int64
+ n, err = io.Copy(f, r)
+ if err == nil {
+ err = fileutil.Fsync(f)
+ }
+ f.Close()
+ if err != nil {
+ os.Remove(f.Name())
+ return n, err
+ }
+ fn := s.dbFilePath(id)
+ if fileutil.Exist(fn) {
+ os.Remove(f.Name())
+ return n, nil
+ }
+ err = os.Rename(f.Name(), fn)
+ if err != nil {
+ os.Remove(f.Name())
+ return n, err
+ }
+
+ plog.Infof("saved database snapshot to disk [total bytes: %d]", n)
+
+ return n, nil
+}
+
+// DBFilePath returns the file path for the snapshot of the database with
+// given id. If the snapshot does not exist, it returns error.
+func (s *Snapshotter) DBFilePath(id uint64) (string, error) {
+ if _, err := fileutil.ReadDir(s.dir); err != nil {
+ return "", err
+ }
+ if fn := s.dbFilePath(id); fileutil.Exist(fn) {
+ return fn, nil
+ }
+ return "", ErrNoDBSnapshot
+}
+
+func (s *Snapshotter) dbFilePath(id uint64) string {
+ return filepath.Join(s.dir, fmt.Sprintf("%016x.snap.db", id))
+}
diff --git a/vendor/github.com/coreos/etcd/snap/message.go b/vendor/github.com/coreos/etcd/snap/message.go
new file mode 100644
index 00000000..d73713ff
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/snap/message.go
@@ -0,0 +1,64 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 snap
+
+import (
+ "io"
+
+ "github.com/coreos/etcd/pkg/ioutil"
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+// Message is a struct that contains a raft Message and a ReadCloser. The type
+// of raft message MUST be MsgSnap, which contains the raft meta-data and an
+// additional data []byte field that contains the snapshot of the actual state
+// machine.
+// Message contains the ReadCloser field for handling large snapshot. This avoid
+// copying the entire snapshot into a byte array, which consumes a lot of memory.
+//
+// User of Message should close the Message after sending it.
+type Message struct {
+ raftpb.Message
+ ReadCloser io.ReadCloser
+ TotalSize int64
+ closeC chan bool
+}
+
+func NewMessage(rs raftpb.Message, rc io.ReadCloser, rcSize int64) *Message {
+ return &Message{
+ Message: rs,
+ ReadCloser: ioutil.NewExactReadCloser(rc, rcSize),
+ TotalSize: int64(rs.Size()) + rcSize,
+ closeC: make(chan bool, 1),
+ }
+}
+
+// CloseNotify returns a channel that receives a single value
+// when the message sent is finished. true indicates the sent
+// is successful.
+func (m Message) CloseNotify() <-chan bool {
+ return m.closeC
+}
+
+func (m Message) CloseWithError(err error) {
+ if cerr := m.ReadCloser.Close(); cerr != nil {
+ err = cerr
+ }
+ if err == nil {
+ m.closeC <- true
+ } else {
+ m.closeC <- false
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/snap/metrics.go b/vendor/github.com/coreos/etcd/snap/metrics.go
new file mode 100644
index 00000000..433ef09d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/snap/metrics.go
@@ -0,0 +1,41 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 snap
+
+import "github.com/prometheus/client_golang/prometheus"
+
+var (
+ // TODO: save_fsync latency?
+ saveDurations = prometheus.NewHistogram(prometheus.HistogramOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "snap",
+ Name: "save_total_duration_seconds",
+ Help: "The total latency distributions of save called by snapshot.",
+ Buckets: prometheus.ExponentialBuckets(0.001, 2, 14),
+ })
+
+ marshallingDurations = prometheus.NewHistogram(prometheus.HistogramOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "snap",
+ Name: "save_marshalling_duration_seconds",
+ Help: "The marshalling cost distributions of save called by snapshot.",
+ Buckets: prometheus.ExponentialBuckets(0.001, 2, 14),
+ })
+)
+
+func init() {
+ prometheus.MustRegister(saveDurations)
+ prometheus.MustRegister(marshallingDurations)
+}
diff --git a/vendor/github.com/coreos/etcd/snap/snappb/snap.pb.go b/vendor/github.com/coreos/etcd/snap/snappb/snap.pb.go
new file mode 100644
index 00000000..05a77ff9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/snap/snappb/snap.pb.go
@@ -0,0 +1,353 @@
+// Code generated by protoc-gen-gogo.
+// source: snap.proto
+// DO NOT EDIT!
+
+/*
+ Package snappb is a generated protocol buffer package.
+
+ It is generated from these files:
+ snap.proto
+
+ It has these top-level messages:
+ Snapshot
+*/
+package snappb
+
+import (
+ "fmt"
+
+ proto "github.com/golang/protobuf/proto"
+
+ math "math"
+
+ io "io"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+type Snapshot struct {
+ Crc uint32 `protobuf:"varint,1,opt,name=crc" json:"crc"`
+ Data []byte `protobuf:"bytes,2,opt,name=data" json:"data,omitempty"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *Snapshot) Reset() { *m = Snapshot{} }
+func (m *Snapshot) String() string { return proto.CompactTextString(m) }
+func (*Snapshot) ProtoMessage() {}
+func (*Snapshot) Descriptor() ([]byte, []int) { return fileDescriptorSnap, []int{0} }
+
+func init() {
+ proto.RegisterType((*Snapshot)(nil), "snappb.snapshot")
+}
+func (m *Snapshot) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *Snapshot) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintSnap(dAtA, i, uint64(m.Crc))
+ if m.Data != nil {
+ dAtA[i] = 0x12
+ i++
+ i = encodeVarintSnap(dAtA, i, uint64(len(m.Data)))
+ i += copy(dAtA[i:], m.Data)
+ }
+ if m.XXX_unrecognized != nil {
+ i += copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return i, nil
+}
+
+func encodeFixed64Snap(dAtA []byte, offset int, v uint64) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ dAtA[offset+4] = uint8(v >> 32)
+ dAtA[offset+5] = uint8(v >> 40)
+ dAtA[offset+6] = uint8(v >> 48)
+ dAtA[offset+7] = uint8(v >> 56)
+ return offset + 8
+}
+func encodeFixed32Snap(dAtA []byte, offset int, v uint32) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ return offset + 4
+}
+func encodeVarintSnap(dAtA []byte, offset int, v uint64) int {
+ for v >= 1<<7 {
+ dAtA[offset] = uint8(v&0x7f | 0x80)
+ v >>= 7
+ offset++
+ }
+ dAtA[offset] = uint8(v)
+ return offset + 1
+}
+func (m *Snapshot) Size() (n int) {
+ var l int
+ _ = l
+ n += 1 + sovSnap(uint64(m.Crc))
+ if m.Data != nil {
+ l = len(m.Data)
+ n += 1 + l + sovSnap(uint64(l))
+ }
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func sovSnap(x uint64) (n int) {
+ for {
+ n++
+ x >>= 7
+ if x == 0 {
+ break
+ }
+ }
+ return n
+}
+func sozSnap(x uint64) (n int) {
+ return sovSnap(uint64((x << 1) ^ uint64((int64(x) >> 63))))
+}
+func (m *Snapshot) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowSnap
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: snapshot: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: snapshot: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Crc", wireType)
+ }
+ m.Crc = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowSnap
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Crc |= (uint32(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowSnap
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthSnap
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
+ if m.Data == nil {
+ m.Data = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipSnap(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthSnap
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func skipSnap(dAtA []byte) (n int, err error) {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowSnap
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ wireType := int(wire & 0x7)
+ switch wireType {
+ case 0:
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowSnap
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ iNdEx++
+ if dAtA[iNdEx-1] < 0x80 {
+ break
+ }
+ }
+ return iNdEx, nil
+ case 1:
+ iNdEx += 8
+ return iNdEx, nil
+ case 2:
+ var length int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowSnap
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ length |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ iNdEx += length
+ if length < 0 {
+ return 0, ErrInvalidLengthSnap
+ }
+ return iNdEx, nil
+ case 3:
+ for {
+ var innerWire uint64
+ var start int = iNdEx
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowSnap
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ innerWire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ innerWireType := int(innerWire & 0x7)
+ if innerWireType == 4 {
+ break
+ }
+ next, err := skipSnap(dAtA[start:])
+ if err != nil {
+ return 0, err
+ }
+ iNdEx = start + next
+ }
+ return iNdEx, nil
+ case 4:
+ return iNdEx, nil
+ case 5:
+ iNdEx += 4
+ return iNdEx, nil
+ default:
+ return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
+ }
+ }
+ panic("unreachable")
+}
+
+var (
+ ErrInvalidLengthSnap = fmt.Errorf("proto: negative length found during unmarshaling")
+ ErrIntOverflowSnap = fmt.Errorf("proto: integer overflow")
+)
+
+func init() { proto.RegisterFile("snap.proto", fileDescriptorSnap) }
+
+var fileDescriptorSnap = []byte{
+ // 126 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2a, 0xce, 0x4b, 0x2c,
+ 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x03, 0xb1, 0x0b, 0x92, 0xa4, 0x44, 0xd2, 0xf3,
+ 0xd3, 0xf3, 0xc1, 0x42, 0xfa, 0x20, 0x16, 0x44, 0x56, 0xc9, 0x8c, 0x8b, 0x03, 0x24, 0x5f, 0x9c,
+ 0x91, 0x5f, 0x22, 0x24, 0xc6, 0xc5, 0x9c, 0x5c, 0x94, 0x2c, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0xeb,
+ 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, 0x48, 0x40, 0x48, 0x88, 0x8b, 0x25, 0x25, 0xb1, 0x24,
+ 0x51, 0x82, 0x49, 0x81, 0x51, 0x83, 0x27, 0x08, 0xcc, 0x76, 0x12, 0x39, 0xf1, 0x50, 0x8e, 0xe1,
+ 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf1, 0x58, 0x8e,
+ 0x01, 0x10, 0x00, 0x00, 0xff, 0xff, 0xd8, 0x0f, 0x32, 0xb2, 0x78, 0x00, 0x00, 0x00,
+}
diff --git a/vendor/github.com/coreos/etcd/snap/snappb/snap.proto b/vendor/github.com/coreos/etcd/snap/snappb/snap.proto
new file mode 100644
index 00000000..cd3d21d0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/snap/snappb/snap.proto
@@ -0,0 +1,14 @@
+syntax = "proto2";
+package snappb;
+
+import "gogoproto/gogo.proto";
+
+option (gogoproto.marshaler_all) = true;
+option (gogoproto.sizer_all) = true;
+option (gogoproto.unmarshaler_all) = true;
+option (gogoproto.goproto_getters_all) = false;
+
+message snapshot {
+ optional uint32 crc = 1 [(gogoproto.nullable) = false];
+ optional bytes data = 2;
+}
diff --git a/vendor/github.com/coreos/etcd/snap/snapshotter.go b/vendor/github.com/coreos/etcd/snap/snapshotter.go
new file mode 100644
index 00000000..00755592
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/snap/snapshotter.go
@@ -0,0 +1,204 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 snap stores raft nodes' states with snapshots.
+package snap
+
+import (
+ "errors"
+ "fmt"
+ "hash/crc32"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "sort"
+ "strings"
+ "time"
+
+ pioutil "github.com/coreos/etcd/pkg/ioutil"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/snap/snappb"
+
+ "github.com/coreos/pkg/capnslog"
+)
+
+const (
+ snapSuffix = ".snap"
+)
+
+var (
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "snap")
+
+ ErrNoSnapshot = errors.New("snap: no available snapshot")
+ ErrEmptySnapshot = errors.New("snap: empty snapshot")
+ ErrCRCMismatch = errors.New("snap: crc mismatch")
+ crcTable = crc32.MakeTable(crc32.Castagnoli)
+
+ // A map of valid files that can be present in the snap folder.
+ validFiles = map[string]bool{
+ "db": true,
+ }
+)
+
+type Snapshotter struct {
+ dir string
+}
+
+func New(dir string) *Snapshotter {
+ return &Snapshotter{
+ dir: dir,
+ }
+}
+
+func (s *Snapshotter) SaveSnap(snapshot raftpb.Snapshot) error {
+ if raft.IsEmptySnap(snapshot) {
+ return nil
+ }
+ return s.save(&snapshot)
+}
+
+func (s *Snapshotter) save(snapshot *raftpb.Snapshot) error {
+ start := time.Now()
+
+ fname := fmt.Sprintf("%016x-%016x%s", snapshot.Metadata.Term, snapshot.Metadata.Index, snapSuffix)
+ b := pbutil.MustMarshal(snapshot)
+ crc := crc32.Update(0, crcTable, b)
+ snap := snappb.Snapshot{Crc: crc, Data: b}
+ d, err := snap.Marshal()
+ if err != nil {
+ return err
+ } else {
+ marshallingDurations.Observe(float64(time.Since(start)) / float64(time.Second))
+ }
+
+ err = pioutil.WriteAndSyncFile(filepath.Join(s.dir, fname), d, 0666)
+ if err == nil {
+ saveDurations.Observe(float64(time.Since(start)) / float64(time.Second))
+ } else {
+ err1 := os.Remove(filepath.Join(s.dir, fname))
+ if err1 != nil {
+ plog.Errorf("failed to remove broken snapshot file %s", filepath.Join(s.dir, fname))
+ }
+ }
+ return err
+}
+
+func (s *Snapshotter) Load() (*raftpb.Snapshot, error) {
+ names, err := s.snapNames()
+ if err != nil {
+ return nil, err
+ }
+ var snap *raftpb.Snapshot
+ for _, name := range names {
+ if snap, err = loadSnap(s.dir, name); err == nil {
+ break
+ }
+ }
+ if err != nil {
+ return nil, ErrNoSnapshot
+ }
+ return snap, nil
+}
+
+func loadSnap(dir, name string) (*raftpb.Snapshot, error) {
+ fpath := filepath.Join(dir, name)
+ snap, err := Read(fpath)
+ if err != nil {
+ renameBroken(fpath)
+ }
+ return snap, err
+}
+
+// Read reads the snapshot named by snapname and returns the snapshot.
+func Read(snapname string) (*raftpb.Snapshot, error) {
+ b, err := ioutil.ReadFile(snapname)
+ if err != nil {
+ plog.Errorf("cannot read file %v: %v", snapname, err)
+ return nil, err
+ }
+
+ if len(b) == 0 {
+ plog.Errorf("unexpected empty snapshot")
+ return nil, ErrEmptySnapshot
+ }
+
+ var serializedSnap snappb.Snapshot
+ if err = serializedSnap.Unmarshal(b); err != nil {
+ plog.Errorf("corrupted snapshot file %v: %v", snapname, err)
+ return nil, err
+ }
+
+ if len(serializedSnap.Data) == 0 || serializedSnap.Crc == 0 {
+ plog.Errorf("unexpected empty snapshot")
+ return nil, ErrEmptySnapshot
+ }
+
+ crc := crc32.Update(0, crcTable, serializedSnap.Data)
+ if crc != serializedSnap.Crc {
+ plog.Errorf("corrupted snapshot file %v: crc mismatch", snapname)
+ return nil, ErrCRCMismatch
+ }
+
+ var snap raftpb.Snapshot
+ if err = snap.Unmarshal(serializedSnap.Data); err != nil {
+ plog.Errorf("corrupted snapshot file %v: %v", snapname, err)
+ return nil, err
+ }
+ return &snap, nil
+}
+
+// snapNames returns the filename of the snapshots in logical time order (from newest to oldest).
+// If there is no available snapshots, an ErrNoSnapshot will be returned.
+func (s *Snapshotter) snapNames() ([]string, error) {
+ dir, err := os.Open(s.dir)
+ if err != nil {
+ return nil, err
+ }
+ defer dir.Close()
+ names, err := dir.Readdirnames(-1)
+ if err != nil {
+ return nil, err
+ }
+ snaps := checkSuffix(names)
+ if len(snaps) == 0 {
+ return nil, ErrNoSnapshot
+ }
+ sort.Sort(sort.Reverse(sort.StringSlice(snaps)))
+ return snaps, nil
+}
+
+func checkSuffix(names []string) []string {
+ snaps := []string{}
+ for i := range names {
+ if strings.HasSuffix(names[i], snapSuffix) {
+ snaps = append(snaps, names[i])
+ } else {
+ // If we find a file which is not a snapshot then check if it's
+ // a vaild file. If not throw out a warning.
+ if _, ok := validFiles[names[i]]; !ok {
+ plog.Warningf("skipped unexpected non snapshot file %v", names[i])
+ }
+ }
+ }
+ return snaps
+}
+
+func renameBroken(path string) {
+ brokenPath := path + ".broken"
+ if err := os.Rename(path, brokenPath); err != nil {
+ plog.Warningf("cannot rename broken snapshot file %v to %v: %v", path, brokenPath, err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/snap/snapshotter_test.go b/vendor/github.com/coreos/etcd/snap/snapshotter_test.go
new file mode 100644
index 00000000..6af823f0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/snap/snapshotter_test.go
@@ -0,0 +1,230 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 snap
+
+import (
+ "fmt"
+ "hash/crc32"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+var testSnap = &raftpb.Snapshot{
+ Data: []byte("some snapshot"),
+ Metadata: raftpb.SnapshotMetadata{
+ ConfState: raftpb.ConfState{
+ Nodes: []uint64{1, 2, 3},
+ },
+ Index: 1,
+ Term: 1,
+ },
+}
+
+func TestSaveAndLoad(t *testing.T) {
+ dir := filepath.Join(os.TempDir(), "snapshot")
+ err := os.Mkdir(dir, 0700)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(dir)
+ ss := New(dir)
+ err = ss.save(testSnap)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ g, err := ss.Load()
+ if err != nil {
+ t.Errorf("err = %v, want nil", err)
+ }
+ if !reflect.DeepEqual(g, testSnap) {
+ t.Errorf("snap = %#v, want %#v", g, testSnap)
+ }
+}
+
+func TestBadCRC(t *testing.T) {
+ dir := filepath.Join(os.TempDir(), "snapshot")
+ err := os.Mkdir(dir, 0700)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(dir)
+ ss := New(dir)
+ err = ss.save(testSnap)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer func() { crcTable = crc32.MakeTable(crc32.Castagnoli) }()
+ // switch to use another crc table
+ // fake a crc mismatch
+ crcTable = crc32.MakeTable(crc32.Koopman)
+
+ _, err = Read(filepath.Join(dir, fmt.Sprintf("%016x-%016x.snap", 1, 1)))
+ if err == nil || err != ErrCRCMismatch {
+ t.Errorf("err = %v, want %v", err, ErrCRCMismatch)
+ }
+}
+
+func TestFailback(t *testing.T) {
+ dir := filepath.Join(os.TempDir(), "snapshot")
+ err := os.Mkdir(dir, 0700)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(dir)
+
+ large := fmt.Sprintf("%016x-%016x-%016x.snap", 0xFFFF, 0xFFFF, 0xFFFF)
+ err = ioutil.WriteFile(filepath.Join(dir, large), []byte("bad data"), 0666)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ ss := New(dir)
+ err = ss.save(testSnap)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ g, err := ss.Load()
+ if err != nil {
+ t.Errorf("err = %v, want nil", err)
+ }
+ if !reflect.DeepEqual(g, testSnap) {
+ t.Errorf("snap = %#v, want %#v", g, testSnap)
+ }
+ if f, err := os.Open(filepath.Join(dir, large) + ".broken"); err != nil {
+ t.Fatal("broken snapshot does not exist")
+ } else {
+ f.Close()
+ }
+}
+
+func TestSnapNames(t *testing.T) {
+ dir := filepath.Join(os.TempDir(), "snapshot")
+ err := os.Mkdir(dir, 0700)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(dir)
+ for i := 1; i <= 5; i++ {
+ var f *os.File
+ if f, err = os.Create(filepath.Join(dir, fmt.Sprintf("%d.snap", i))); err != nil {
+ t.Fatal(err)
+ } else {
+ f.Close()
+ }
+ }
+ ss := New(dir)
+ names, err := ss.snapNames()
+ if err != nil {
+ t.Errorf("err = %v, want nil", err)
+ }
+ if len(names) != 5 {
+ t.Errorf("len = %d, want 10", len(names))
+ }
+ w := []string{"5.snap", "4.snap", "3.snap", "2.snap", "1.snap"}
+ if !reflect.DeepEqual(names, w) {
+ t.Errorf("names = %v, want %v", names, w)
+ }
+}
+
+func TestLoadNewestSnap(t *testing.T) {
+ dir := filepath.Join(os.TempDir(), "snapshot")
+ err := os.Mkdir(dir, 0700)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(dir)
+ ss := New(dir)
+ err = ss.save(testSnap)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ newSnap := *testSnap
+ newSnap.Metadata.Index = 5
+ err = ss.save(&newSnap)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ g, err := ss.Load()
+ if err != nil {
+ t.Errorf("err = %v, want nil", err)
+ }
+ if !reflect.DeepEqual(g, &newSnap) {
+ t.Errorf("snap = %#v, want %#v", g, &newSnap)
+ }
+}
+
+func TestNoSnapshot(t *testing.T) {
+ dir := filepath.Join(os.TempDir(), "snapshot")
+ err := os.Mkdir(dir, 0700)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(dir)
+ ss := New(dir)
+ _, err = ss.Load()
+ if err != ErrNoSnapshot {
+ t.Errorf("err = %v, want %v", err, ErrNoSnapshot)
+ }
+}
+
+func TestEmptySnapshot(t *testing.T) {
+ dir := filepath.Join(os.TempDir(), "snapshot")
+ err := os.Mkdir(dir, 0700)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(dir)
+
+ err = ioutil.WriteFile(filepath.Join(dir, "1.snap"), []byte(""), 0x700)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ _, err = Read(filepath.Join(dir, "1.snap"))
+ if err != ErrEmptySnapshot {
+ t.Errorf("err = %v, want %v", err, ErrEmptySnapshot)
+ }
+}
+
+// TestAllSnapshotBroken ensures snapshotter returns
+// ErrNoSnapshot if all the snapshots are broken.
+func TestAllSnapshotBroken(t *testing.T) {
+ dir := filepath.Join(os.TempDir(), "snapshot")
+ err := os.Mkdir(dir, 0700)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(dir)
+
+ err = ioutil.WriteFile(filepath.Join(dir, "1.snap"), []byte("bad"), 0x700)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ ss := New(dir)
+ _, err = ss.Load()
+ if err != ErrNoSnapshot {
+ t.Errorf("err = %v, want %v", err, ErrNoSnapshot)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/store/doc.go b/vendor/github.com/coreos/etcd/store/doc.go
new file mode 100644
index 00000000..612df927
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store defines etcd's in-memory key/value store.
+package store
diff --git a/vendor/github.com/coreos/etcd/store/event.go b/vendor/github.com/coreos/etcd/store/event.go
new file mode 100644
index 00000000..efcddb0e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/event.go
@@ -0,0 +1,71 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+const (
+ Get = "get"
+ Create = "create"
+ Set = "set"
+ Update = "update"
+ Delete = "delete"
+ CompareAndSwap = "compareAndSwap"
+ CompareAndDelete = "compareAndDelete"
+ Expire = "expire"
+)
+
+type Event struct {
+ Action string `json:"action"`
+ Node *NodeExtern `json:"node,omitempty"`
+ PrevNode *NodeExtern `json:"prevNode,omitempty"`
+ EtcdIndex uint64 `json:"-"`
+ Refresh bool `json:"refresh,omitempty"`
+}
+
+func newEvent(action string, key string, modifiedIndex, createdIndex uint64) *Event {
+ n := &NodeExtern{
+ Key: key,
+ ModifiedIndex: modifiedIndex,
+ CreatedIndex: createdIndex,
+ }
+
+ return &Event{
+ Action: action,
+ Node: n,
+ }
+}
+
+func (e *Event) IsCreated() bool {
+ if e.Action == Create {
+ return true
+ }
+ return e.Action == Set && e.PrevNode == nil
+}
+
+func (e *Event) Index() uint64 {
+ return e.Node.ModifiedIndex
+}
+
+func (e *Event) Clone() *Event {
+ return &Event{
+ Action: e.Action,
+ EtcdIndex: e.EtcdIndex,
+ Node: e.Node.Clone(),
+ PrevNode: e.PrevNode.Clone(),
+ }
+}
+
+func (e *Event) SetRefresh() {
+ e.Refresh = true
+}
diff --git a/vendor/github.com/coreos/etcd/store/event_history.go b/vendor/github.com/coreos/etcd/store/event_history.go
new file mode 100644
index 00000000..235d87a2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/event_history.go
@@ -0,0 +1,129 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "fmt"
+ "path"
+ "strings"
+ "sync"
+
+ etcdErr "github.com/coreos/etcd/error"
+)
+
+type EventHistory struct {
+ Queue eventQueue
+ StartIndex uint64
+ LastIndex uint64
+ rwl sync.RWMutex
+}
+
+func newEventHistory(capacity int) *EventHistory {
+ return &EventHistory{
+ Queue: eventQueue{
+ Capacity: capacity,
+ Events: make([]*Event, capacity),
+ },
+ }
+}
+
+// addEvent function adds event into the eventHistory
+func (eh *EventHistory) addEvent(e *Event) *Event {
+ eh.rwl.Lock()
+ defer eh.rwl.Unlock()
+
+ eh.Queue.insert(e)
+
+ eh.LastIndex = e.Index()
+
+ eh.StartIndex = eh.Queue.Events[eh.Queue.Front].Index()
+
+ return e
+}
+
+// scan enumerates events from the index history and stops at the first point
+// where the key matches.
+func (eh *EventHistory) scan(key string, recursive bool, index uint64) (*Event, *etcdErr.Error) {
+ eh.rwl.RLock()
+ defer eh.rwl.RUnlock()
+
+ // index should be after the event history's StartIndex
+ if index < eh.StartIndex {
+ return nil,
+ etcdErr.NewError(etcdErr.EcodeEventIndexCleared,
+ fmt.Sprintf("the requested history has been cleared [%v/%v]",
+ eh.StartIndex, index), 0)
+ }
+
+ // the index should come before the size of the queue minus the duplicate count
+ if index > eh.LastIndex { // future index
+ return nil, nil
+ }
+
+ offset := index - eh.StartIndex
+ i := (eh.Queue.Front + int(offset)) % eh.Queue.Capacity
+
+ for {
+ e := eh.Queue.Events[i]
+
+ if !e.Refresh {
+ ok := (e.Node.Key == key)
+
+ if recursive {
+ // add tailing slash
+ nkey := path.Clean(key)
+ if nkey[len(nkey)-1] != '/' {
+ nkey = nkey + "/"
+ }
+
+ ok = ok || strings.HasPrefix(e.Node.Key, nkey)
+ }
+
+ if (e.Action == Delete || e.Action == Expire) && e.PrevNode != nil && e.PrevNode.Dir {
+ ok = ok || strings.HasPrefix(key, e.PrevNode.Key)
+ }
+
+ if ok {
+ return e, nil
+ }
+ }
+
+ i = (i + 1) % eh.Queue.Capacity
+
+ if i == eh.Queue.Back {
+ return nil, nil
+ }
+ }
+}
+
+// clone will be protected by a stop-world lock
+// do not need to obtain internal lock
+func (eh *EventHistory) clone() *EventHistory {
+ clonedQueue := eventQueue{
+ Capacity: eh.Queue.Capacity,
+ Events: make([]*Event, eh.Queue.Capacity),
+ Size: eh.Queue.Size,
+ Front: eh.Queue.Front,
+ Back: eh.Queue.Back,
+ }
+
+ copy(clonedQueue.Events, eh.Queue.Events)
+ return &EventHistory{
+ StartIndex: eh.StartIndex,
+ Queue: clonedQueue,
+ LastIndex: eh.LastIndex,
+ }
+
+}
diff --git a/vendor/github.com/coreos/etcd/store/event_queue.go b/vendor/github.com/coreos/etcd/store/event_queue.go
new file mode 100644
index 00000000..767b8359
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/event_queue.go
@@ -0,0 +1,34 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+type eventQueue struct {
+ Events []*Event
+ Size int
+ Front int
+ Back int
+ Capacity int
+}
+
+func (eq *eventQueue) insert(e *Event) {
+ eq.Events[eq.Back] = e
+ eq.Back = (eq.Back + 1) % eq.Capacity
+
+ if eq.Size == eq.Capacity { //dequeue
+ eq.Front = (eq.Front + 1) % eq.Capacity
+ } else {
+ eq.Size++
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/store/event_test.go b/vendor/github.com/coreos/etcd/store/event_test.go
new file mode 100644
index 00000000..ba3c06c6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/event_test.go
@@ -0,0 +1,162 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "testing"
+
+ etcdErr "github.com/coreos/etcd/error"
+)
+
+// TestEventQueue tests a queue with capacity = 100
+// Add 200 events into that queue, and test if the
+// previous 100 events have been swapped out.
+func TestEventQueue(t *testing.T) {
+
+ eh := newEventHistory(100)
+
+ // Add
+ for i := 0; i < 200; i++ {
+ e := newEvent(Create, "/foo", uint64(i), uint64(i))
+ eh.addEvent(e)
+ }
+
+ // Test
+ j := 100
+ i := eh.Queue.Front
+ n := eh.Queue.Size
+ for ; n > 0; n-- {
+ e := eh.Queue.Events[i]
+ if e.Index() != uint64(j) {
+ t.Fatalf("queue error!")
+ }
+ j++
+ i = (i + 1) % eh.Queue.Capacity
+ }
+}
+
+func TestScanHistory(t *testing.T) {
+ eh := newEventHistory(100)
+
+ // Add
+ eh.addEvent(newEvent(Create, "/foo", 1, 1))
+ eh.addEvent(newEvent(Create, "/foo/bar", 2, 2))
+ eh.addEvent(newEvent(Create, "/foo/foo", 3, 3))
+ eh.addEvent(newEvent(Create, "/foo/bar/bar", 4, 4))
+ eh.addEvent(newEvent(Create, "/foo/foo/foo", 5, 5))
+
+ // Delete a dir
+ de := newEvent(Delete, "/foo", 6, 6)
+ de.PrevNode = newDir(nil, "/foo", 1, nil, Permanent).Repr(false, false, nil)
+ eh.addEvent(de)
+
+ e, err := eh.scan("/foo", false, 1)
+ if err != nil || e.Index() != 1 {
+ t.Fatalf("scan error [/foo] [1] %d (%v)", e.Index(), err)
+ }
+
+ e, err = eh.scan("/foo/bar", false, 1)
+
+ if err != nil || e.Index() != 2 {
+ t.Fatalf("scan error [/foo/bar] [2] %d (%v)", e.Index(), err)
+ }
+
+ e, err = eh.scan("/foo/bar", true, 3)
+
+ if err != nil || e.Index() != 4 {
+ t.Fatalf("scan error [/foo/bar/bar] [4] %d (%v)", e.Index(), err)
+ }
+
+ e, err = eh.scan("/foo/foo/foo", false, 6)
+ if err != nil || e.Index() != 6 {
+ t.Fatalf("scan error [/foo/foo/foo] [6] %d (%v)", e.Index(), err)
+ }
+
+ e, _ = eh.scan("/foo/bar", true, 7)
+ if e != nil {
+ t.Fatalf("bad index shoud reuturn nil")
+ }
+}
+
+func TestEventIndexHistoryCleared(t *testing.T) {
+ eh := newEventHistory(5)
+
+ // Add
+ eh.addEvent(newEvent(Create, "/foo", 1, 1))
+ eh.addEvent(newEvent(Create, "/foo/bar", 2, 2))
+ eh.addEvent(newEvent(Create, "/foo/foo", 3, 3))
+ eh.addEvent(newEvent(Create, "/foo/bar/bar", 4, 4))
+ eh.addEvent(newEvent(Create, "/foo/foo/foo", 5, 5))
+
+ // Add a new event which will replace/de-queue the first entry
+ eh.addEvent(newEvent(Create, "/foo/bar/bar/bar", 6, 6))
+
+ // test for the event which has been replaced.
+ _, err := eh.scan("/foo", false, 1)
+ if err == nil || err.ErrorCode != etcdErr.EcodeEventIndexCleared {
+ t.Fatalf("scan error cleared index should return err with %d got (%v)", etcdErr.EcodeEventIndexCleared, err)
+ }
+}
+
+// TestFullEventQueue tests a queue with capacity = 10
+// Add 1000 events into that queue, and test if scanning
+// works still for previous events.
+func TestFullEventQueue(t *testing.T) {
+
+ eh := newEventHistory(10)
+
+ // Add
+ for i := 0; i < 1000; i++ {
+ ce := newEvent(Create, "/foo", uint64(i), uint64(i))
+ eh.addEvent(ce)
+ e, err := eh.scan("/foo", true, uint64(i-1))
+ if i > 0 {
+ if e == nil || err != nil {
+ t.Fatalf("scan error [/foo] [%v] %v", i-1, i)
+ }
+ }
+ }
+}
+
+func TestCloneEvent(t *testing.T) {
+ e1 := &Event{
+ Action: Create,
+ EtcdIndex: 1,
+ Node: nil,
+ PrevNode: nil,
+ }
+ e2 := e1.Clone()
+ if e2.Action != Create {
+ t.Fatalf("Action=%q, want %q", e2.Action, Create)
+ }
+ if e2.EtcdIndex != e1.EtcdIndex {
+ t.Fatalf("EtcdIndex=%d, want %d", e2.EtcdIndex, e1.EtcdIndex)
+ }
+ // Changing the cloned node should not affect the original
+ e2.Action = Delete
+ e2.EtcdIndex = uint64(5)
+ if e1.Action != Create {
+ t.Fatalf("Action=%q, want %q", e1.Action, Create)
+ }
+ if e1.EtcdIndex != uint64(1) {
+ t.Fatalf("EtcdIndex=%d, want %d", e1.EtcdIndex, uint64(1))
+ }
+ if e2.Action != Delete {
+ t.Fatalf("Action=%q, want %q", e2.Action, Delete)
+ }
+ if e2.EtcdIndex != uint64(5) {
+ t.Fatalf("EtcdIndex=%d, want %d", e2.EtcdIndex, uint64(5))
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/store/heap_test.go b/vendor/github.com/coreos/etcd/store/heap_test.go
new file mode 100644
index 00000000..0ff49615
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/heap_test.go
@@ -0,0 +1,94 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "fmt"
+ "testing"
+ "time"
+)
+
+func TestHeapPushPop(t *testing.T) {
+ h := newTtlKeyHeap()
+
+ // add from older expire time to earlier expire time
+ // the path is equal to ttl from now
+ for i := 0; i < 10; i++ {
+ path := fmt.Sprintf("%v", 10-i)
+ m := time.Duration(10 - i)
+ n := newKV(nil, path, path, 0, nil, time.Now().Add(time.Second*m))
+ h.push(n)
+ }
+
+ min := time.Now()
+
+ for i := 0; i < 10; i++ {
+ node := h.pop()
+ if node.ExpireTime.Before(min) {
+ t.Fatal("heap sort wrong!")
+ }
+ min = node.ExpireTime
+ }
+
+}
+
+func TestHeapUpdate(t *testing.T) {
+ h := newTtlKeyHeap()
+
+ kvs := make([]*node, 10)
+
+ // add from older expire time to earlier expire time
+ // the path is equal to ttl from now
+ for i := range kvs {
+ path := fmt.Sprintf("%v", 10-i)
+ m := time.Duration(10 - i)
+ n := newKV(nil, path, path, 0, nil, time.Now().Add(time.Second*m))
+ kvs[i] = n
+ h.push(n)
+ }
+
+ // Path 7
+ kvs[3].ExpireTime = time.Now().Add(time.Second * 11)
+
+ // Path 5
+ kvs[5].ExpireTime = time.Now().Add(time.Second * 12)
+
+ h.update(kvs[3])
+ h.update(kvs[5])
+
+ min := time.Now()
+
+ for i := 0; i < 10; i++ {
+ node := h.pop()
+ if node.ExpireTime.Before(min) {
+ t.Fatal("heap sort wrong!")
+ }
+ min = node.ExpireTime
+
+ if i == 8 {
+ if node.Path != "7" {
+ t.Fatal("heap sort wrong!", node.Path)
+ }
+ }
+
+ if i == 9 {
+ if node.Path != "5" {
+ t.Fatal("heap sort wrong!")
+ }
+ }
+
+ }
+
+}
diff --git a/vendor/github.com/coreos/etcd/store/metrics.go b/vendor/github.com/coreos/etcd/store/metrics.go
new file mode 100644
index 00000000..26404ba7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/metrics.go
@@ -0,0 +1,128 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "github.com/prometheus/client_golang/prometheus"
+)
+
+// Set of raw Prometheus metrics.
+// Labels
+// * action = declared in event.go
+// * outcome = Outcome
+// Do not increment directly, use Report* methods.
+var (
+ readCounter = prometheus.NewCounterVec(
+ prometheus.CounterOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "store",
+ Name: "reads_total",
+ Help: "Total number of reads action by (get/getRecursive), local to this member.",
+ }, []string{"action"})
+
+ writeCounter = prometheus.NewCounterVec(
+ prometheus.CounterOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "store",
+ Name: "writes_total",
+ Help: "Total number of writes (e.g. set/compareAndDelete) seen by this member.",
+ }, []string{"action"})
+
+ readFailedCounter = prometheus.NewCounterVec(
+ prometheus.CounterOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "store",
+ Name: "reads_failed_total",
+ Help: "Failed read actions by (get/getRecursive), local to this member.",
+ }, []string{"action"})
+
+ writeFailedCounter = prometheus.NewCounterVec(
+ prometheus.CounterOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "store",
+ Name: "writes_failed_total",
+ Help: "Failed write actions (e.g. set/compareAndDelete), seen by this member.",
+ }, []string{"action"})
+
+ expireCounter = prometheus.NewCounter(
+ prometheus.CounterOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "store",
+ Name: "expires_total",
+ Help: "Total number of expired keys.",
+ })
+
+ watchRequests = prometheus.NewCounter(
+ prometheus.CounterOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "store",
+ Name: "watch_requests_total",
+ Help: "Total number of incoming watch requests (new or reestablished).",
+ })
+
+ watcherCount = prometheus.NewGauge(
+ prometheus.GaugeOpts{
+ Namespace: "etcd_debugging",
+ Subsystem: "store",
+ Name: "watchers",
+ Help: "Count of currently active watchers.",
+ })
+)
+
+const (
+ GetRecursive = "getRecursive"
+)
+
+func init() {
+ prometheus.MustRegister(readCounter)
+ prometheus.MustRegister(writeCounter)
+ prometheus.MustRegister(expireCounter)
+ prometheus.MustRegister(watchRequests)
+ prometheus.MustRegister(watcherCount)
+}
+
+func reportReadSuccess(read_action string) {
+ readCounter.WithLabelValues(read_action).Inc()
+}
+
+func reportReadFailure(read_action string) {
+ readCounter.WithLabelValues(read_action).Inc()
+ readFailedCounter.WithLabelValues(read_action).Inc()
+}
+
+func reportWriteSuccess(write_action string) {
+ writeCounter.WithLabelValues(write_action).Inc()
+}
+
+func reportWriteFailure(write_action string) {
+ writeCounter.WithLabelValues(write_action).Inc()
+ writeFailedCounter.WithLabelValues(write_action).Inc()
+}
+
+func reportExpiredKey() {
+ expireCounter.Inc()
+}
+
+func reportWatchRequest() {
+ watchRequests.Inc()
+}
+
+func reportWatcherAdded() {
+ watcherCount.Inc()
+}
+
+func reportWatcherRemoved() {
+ watcherCount.Dec()
+}
diff --git a/vendor/github.com/coreos/etcd/store/node.go b/vendor/github.com/coreos/etcd/store/node.go
new file mode 100644
index 00000000..54159553
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/node.go
@@ -0,0 +1,395 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "path"
+ "sort"
+ "time"
+
+ etcdErr "github.com/coreos/etcd/error"
+ "github.com/jonboulle/clockwork"
+)
+
+// explanations of Compare function result
+const (
+ CompareMatch = iota
+ CompareIndexNotMatch
+ CompareValueNotMatch
+ CompareNotMatch
+)
+
+var Permanent time.Time
+
+// node is the basic element in the store system.
+// A key-value pair will have a string value
+// A directory will have a children map
+type node struct {
+ Path string
+
+ CreatedIndex uint64
+ ModifiedIndex uint64
+
+ Parent *node `json:"-"` // should not encode this field! avoid circular dependency.
+
+ ExpireTime time.Time
+ Value string // for key-value pair
+ Children map[string]*node // for directory
+
+ // A reference to the store this node is attached to.
+ store *store
+}
+
+// newKV creates a Key-Value pair
+func newKV(store *store, nodePath string, value string, createdIndex uint64, parent *node, expireTime time.Time) *node {
+ return &node{
+ Path: nodePath,
+ CreatedIndex: createdIndex,
+ ModifiedIndex: createdIndex,
+ Parent: parent,
+ store: store,
+ ExpireTime: expireTime,
+ Value: value,
+ }
+}
+
+// newDir creates a directory
+func newDir(store *store, nodePath string, createdIndex uint64, parent *node, expireTime time.Time) *node {
+ return &node{
+ Path: nodePath,
+ CreatedIndex: createdIndex,
+ ModifiedIndex: createdIndex,
+ Parent: parent,
+ ExpireTime: expireTime,
+ Children: make(map[string]*node),
+ store: store,
+ }
+}
+
+// IsHidden function checks if the node is a hidden node. A hidden node
+// will begin with '_'
+// A hidden node will not be shown via get command under a directory
+// For example if we have /foo/_hidden and /foo/notHidden, get "/foo"
+// will only return /foo/notHidden
+func (n *node) IsHidden() bool {
+ _, name := path.Split(n.Path)
+
+ return name[0] == '_'
+}
+
+// IsPermanent function checks if the node is a permanent one.
+func (n *node) IsPermanent() bool {
+ // we use a uninitialized time.Time to indicate the node is a
+ // permanent one.
+ // the uninitialized time.Time should equal zero.
+ return n.ExpireTime.IsZero()
+}
+
+// IsDir function checks whether the node is a directory.
+// If the node is a directory, the function will return true.
+// Otherwise the function will return false.
+func (n *node) IsDir() bool {
+ return n.Children != nil
+}
+
+// Read function gets the value of the node.
+// If the receiver node is not a key-value pair, a "Not A File" error will be returned.
+func (n *node) Read() (string, *etcdErr.Error) {
+ if n.IsDir() {
+ return "", etcdErr.NewError(etcdErr.EcodeNotFile, "", n.store.CurrentIndex)
+ }
+
+ return n.Value, nil
+}
+
+// Write function set the value of the node to the given value.
+// If the receiver node is a directory, a "Not A File" error will be returned.
+func (n *node) Write(value string, index uint64) *etcdErr.Error {
+ if n.IsDir() {
+ return etcdErr.NewError(etcdErr.EcodeNotFile, "", n.store.CurrentIndex)
+ }
+
+ n.Value = value
+ n.ModifiedIndex = index
+
+ return nil
+}
+
+func (n *node) expirationAndTTL(clock clockwork.Clock) (*time.Time, int64) {
+ if !n.IsPermanent() {
+ /* compute ttl as:
+ ceiling( (expireTime - timeNow) / nanosecondsPerSecond )
+ which ranges from 1..n
+ rather than as:
+ ( (expireTime - timeNow) / nanosecondsPerSecond ) + 1
+ which ranges 1..n+1
+ */
+ ttlN := n.ExpireTime.Sub(clock.Now())
+ ttl := ttlN / time.Second
+ if (ttlN % time.Second) > 0 {
+ ttl++
+ }
+ t := n.ExpireTime.UTC()
+ return &t, int64(ttl)
+ }
+ return nil, 0
+}
+
+// List function return a slice of nodes under the receiver node.
+// If the receiver node is not a directory, a "Not A Directory" error will be returned.
+func (n *node) List() ([]*node, *etcdErr.Error) {
+ if !n.IsDir() {
+ return nil, etcdErr.NewError(etcdErr.EcodeNotDir, "", n.store.CurrentIndex)
+ }
+
+ nodes := make([]*node, len(n.Children))
+
+ i := 0
+ for _, node := range n.Children {
+ nodes[i] = node
+ i++
+ }
+
+ return nodes, nil
+}
+
+// GetChild function returns the child node under the directory node.
+// On success, it returns the file node
+func (n *node) GetChild(name string) (*node, *etcdErr.Error) {
+ if !n.IsDir() {
+ return nil, etcdErr.NewError(etcdErr.EcodeNotDir, n.Path, n.store.CurrentIndex)
+ }
+
+ child, ok := n.Children[name]
+
+ if ok {
+ return child, nil
+ }
+
+ return nil, nil
+}
+
+// Add function adds a node to the receiver node.
+// If the receiver is not a directory, a "Not A Directory" error will be returned.
+// If there is an existing node with the same name under the directory, a "Already Exist"
+// error will be returned
+func (n *node) Add(child *node) *etcdErr.Error {
+ if !n.IsDir() {
+ return etcdErr.NewError(etcdErr.EcodeNotDir, "", n.store.CurrentIndex)
+ }
+
+ _, name := path.Split(child.Path)
+
+ if _, ok := n.Children[name]; ok {
+ return etcdErr.NewError(etcdErr.EcodeNodeExist, "", n.store.CurrentIndex)
+ }
+
+ n.Children[name] = child
+
+ return nil
+}
+
+// Remove function remove the node.
+func (n *node) Remove(dir, recursive bool, callback func(path string)) *etcdErr.Error {
+ if !n.IsDir() { // key-value pair
+ _, name := path.Split(n.Path)
+
+ // find its parent and remove the node from the map
+ if n.Parent != nil && n.Parent.Children[name] == n {
+ delete(n.Parent.Children, name)
+ }
+
+ if callback != nil {
+ callback(n.Path)
+ }
+
+ if !n.IsPermanent() {
+ n.store.ttlKeyHeap.remove(n)
+ }
+
+ return nil
+ }
+
+ if !dir {
+ // cannot delete a directory without dir set to true
+ return etcdErr.NewError(etcdErr.EcodeNotFile, n.Path, n.store.CurrentIndex)
+ }
+
+ if len(n.Children) != 0 && !recursive {
+ // cannot delete a directory if it is not empty and the operation
+ // is not recursive
+ return etcdErr.NewError(etcdErr.EcodeDirNotEmpty, n.Path, n.store.CurrentIndex)
+ }
+
+ for _, child := range n.Children { // delete all children
+ child.Remove(true, true, callback)
+ }
+
+ // delete self
+ _, name := path.Split(n.Path)
+ if n.Parent != nil && n.Parent.Children[name] == n {
+ delete(n.Parent.Children, name)
+
+ if callback != nil {
+ callback(n.Path)
+ }
+
+ if !n.IsPermanent() {
+ n.store.ttlKeyHeap.remove(n)
+ }
+ }
+
+ return nil
+}
+
+func (n *node) Repr(recursive, sorted bool, clock clockwork.Clock) *NodeExtern {
+ if n.IsDir() {
+ node := &NodeExtern{
+ Key: n.Path,
+ Dir: true,
+ ModifiedIndex: n.ModifiedIndex,
+ CreatedIndex: n.CreatedIndex,
+ }
+ node.Expiration, node.TTL = n.expirationAndTTL(clock)
+
+ if !recursive {
+ return node
+ }
+
+ children, _ := n.List()
+ node.Nodes = make(NodeExterns, len(children))
+
+ // we do not use the index in the children slice directly
+ // we need to skip the hidden one
+ i := 0
+
+ for _, child := range children {
+
+ if child.IsHidden() { // get will not list hidden node
+ continue
+ }
+
+ node.Nodes[i] = child.Repr(recursive, sorted, clock)
+
+ i++
+ }
+
+ // eliminate hidden nodes
+ node.Nodes = node.Nodes[:i]
+ if sorted {
+ sort.Sort(node.Nodes)
+ }
+
+ return node
+ }
+
+ // since n.Value could be changed later, so we need to copy the value out
+ value := n.Value
+ node := &NodeExtern{
+ Key: n.Path,
+ Value: &value,
+ ModifiedIndex: n.ModifiedIndex,
+ CreatedIndex: n.CreatedIndex,
+ }
+ node.Expiration, node.TTL = n.expirationAndTTL(clock)
+ return node
+}
+
+func (n *node) UpdateTTL(expireTime time.Time) {
+ if !n.IsPermanent() {
+ if expireTime.IsZero() {
+ // from ttl to permanent
+ n.ExpireTime = expireTime
+ // remove from ttl heap
+ n.store.ttlKeyHeap.remove(n)
+ return
+ }
+
+ // update ttl
+ n.ExpireTime = expireTime
+ // update ttl heap
+ n.store.ttlKeyHeap.update(n)
+ return
+ }
+
+ if expireTime.IsZero() {
+ return
+ }
+
+ // from permanent to ttl
+ n.ExpireTime = expireTime
+ // push into ttl heap
+ n.store.ttlKeyHeap.push(n)
+}
+
+// Compare function compares node index and value with provided ones.
+// second result value explains result and equals to one of Compare.. constants
+func (n *node) Compare(prevValue string, prevIndex uint64) (ok bool, which int) {
+ indexMatch := (prevIndex == 0 || n.ModifiedIndex == prevIndex)
+ valueMatch := (prevValue == "" || n.Value == prevValue)
+ ok = valueMatch && indexMatch
+ switch {
+ case valueMatch && indexMatch:
+ which = CompareMatch
+ case indexMatch && !valueMatch:
+ which = CompareValueNotMatch
+ case valueMatch && !indexMatch:
+ which = CompareIndexNotMatch
+ default:
+ which = CompareNotMatch
+ }
+ return
+}
+
+// Clone function clone the node recursively and return the new node.
+// If the node is a directory, it will clone all the content under this directory.
+// If the node is a key-value pair, it will clone the pair.
+func (n *node) Clone() *node {
+ if !n.IsDir() {
+ newkv := newKV(n.store, n.Path, n.Value, n.CreatedIndex, n.Parent, n.ExpireTime)
+ newkv.ModifiedIndex = n.ModifiedIndex
+ return newkv
+ }
+
+ clone := newDir(n.store, n.Path, n.CreatedIndex, n.Parent, n.ExpireTime)
+ clone.ModifiedIndex = n.ModifiedIndex
+
+ for key, child := range n.Children {
+ clone.Children[key] = child.Clone()
+ }
+
+ return clone
+}
+
+// recoverAndclean function help to do recovery.
+// Two things need to be done: 1. recovery structure; 2. delete expired nodes
+//
+// If the node is a directory, it will help recover children's parent pointer and recursively
+// call this function on its children.
+// We check the expire last since we need to recover the whole structure first and add all the
+// notifications into the event history.
+func (n *node) recoverAndclean() {
+ if n.IsDir() {
+ for _, child := range n.Children {
+ child.Parent = n
+ child.store = n.store
+ child.recoverAndclean()
+ }
+ }
+
+ if !n.ExpireTime.IsZero() {
+ n.store.ttlKeyHeap.push(n)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/store/node_extern.go b/vendor/github.com/coreos/etcd/store/node_extern.go
new file mode 100644
index 00000000..7ba870cb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/node_extern.go
@@ -0,0 +1,116 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "sort"
+ "time"
+
+ "github.com/jonboulle/clockwork"
+)
+
+// NodeExtern is the external representation of the
+// internal node with additional fields
+// PrevValue is the previous value of the node
+// TTL is time to live in second
+type NodeExtern struct {
+ Key string `json:"key,omitempty"`
+ Value *string `json:"value,omitempty"`
+ Dir bool `json:"dir,omitempty"`
+ Expiration *time.Time `json:"expiration,omitempty"`
+ TTL int64 `json:"ttl,omitempty"`
+ Nodes NodeExterns `json:"nodes,omitempty"`
+ ModifiedIndex uint64 `json:"modifiedIndex,omitempty"`
+ CreatedIndex uint64 `json:"createdIndex,omitempty"`
+}
+
+func (eNode *NodeExtern) loadInternalNode(n *node, recursive, sorted bool, clock clockwork.Clock) {
+ if n.IsDir() { // node is a directory
+ eNode.Dir = true
+
+ children, _ := n.List()
+ eNode.Nodes = make(NodeExterns, len(children))
+
+ // we do not use the index in the children slice directly
+ // we need to skip the hidden one
+ i := 0
+
+ for _, child := range children {
+ if child.IsHidden() { // get will not return hidden nodes
+ continue
+ }
+
+ eNode.Nodes[i] = child.Repr(recursive, sorted, clock)
+ i++
+ }
+
+ // eliminate hidden nodes
+ eNode.Nodes = eNode.Nodes[:i]
+
+ if sorted {
+ sort.Sort(eNode.Nodes)
+ }
+
+ } else { // node is a file
+ value, _ := n.Read()
+ eNode.Value = &value
+ }
+
+ eNode.Expiration, eNode.TTL = n.expirationAndTTL(clock)
+}
+
+func (eNode *NodeExtern) Clone() *NodeExtern {
+ if eNode == nil {
+ return nil
+ }
+ nn := &NodeExtern{
+ Key: eNode.Key,
+ Dir: eNode.Dir,
+ TTL: eNode.TTL,
+ ModifiedIndex: eNode.ModifiedIndex,
+ CreatedIndex: eNode.CreatedIndex,
+ }
+ if eNode.Value != nil {
+ s := *eNode.Value
+ nn.Value = &s
+ }
+ if eNode.Expiration != nil {
+ t := *eNode.Expiration
+ nn.Expiration = &t
+ }
+ if eNode.Nodes != nil {
+ nn.Nodes = make(NodeExterns, len(eNode.Nodes))
+ for i, n := range eNode.Nodes {
+ nn.Nodes[i] = n.Clone()
+ }
+ }
+ return nn
+}
+
+type NodeExterns []*NodeExtern
+
+// interfaces for sorting
+
+func (ns NodeExterns) Len() int {
+ return len(ns)
+}
+
+func (ns NodeExterns) Less(i, j int) bool {
+ return ns[i].Key < ns[j].Key
+}
+
+func (ns NodeExterns) Swap(i, j int) {
+ ns[i], ns[j] = ns[j], ns[i]
+}
diff --git a/vendor/github.com/coreos/etcd/store/node_extern_test.go b/vendor/github.com/coreos/etcd/store/node_extern_test.go
new file mode 100644
index 00000000..7875e47f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/node_extern_test.go
@@ -0,0 +1,108 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "reflect"
+ "testing"
+ "time"
+ "unsafe"
+
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+func TestNodeExternClone(t *testing.T) {
+ var eNode *NodeExtern
+ if g := eNode.Clone(); g != nil {
+ t.Fatalf("nil.Clone=%v, want nil", g)
+ }
+
+ const (
+ key string = "/foo/bar"
+ ttl int64 = 123456789
+ ci uint64 = 123
+ mi uint64 = 321
+ )
+ var (
+ val = "some_data"
+ valp = &val
+ exp = time.Unix(12345, 67890)
+ expp = &exp
+ child = NodeExtern{}
+ childp = &child
+ childs = []*NodeExtern{childp}
+ )
+
+ eNode = &NodeExtern{
+ Key: key,
+ TTL: ttl,
+ CreatedIndex: ci,
+ ModifiedIndex: mi,
+ Value: valp,
+ Expiration: expp,
+ Nodes: childs,
+ }
+
+ gNode := eNode.Clone()
+ // Check the clone is as expected
+ testutil.AssertEqual(t, gNode.Key, key)
+ testutil.AssertEqual(t, gNode.TTL, ttl)
+ testutil.AssertEqual(t, gNode.CreatedIndex, ci)
+ testutil.AssertEqual(t, gNode.ModifiedIndex, mi)
+ // values should be the same
+ testutil.AssertEqual(t, *gNode.Value, val)
+ testutil.AssertEqual(t, *gNode.Expiration, exp)
+ testutil.AssertEqual(t, len(gNode.Nodes), len(childs))
+ testutil.AssertEqual(t, *gNode.Nodes[0], child)
+ // but pointers should differ
+ if gNode.Value == eNode.Value {
+ t.Fatalf("expected value pointers to differ, but got same!")
+ }
+ if gNode.Expiration == eNode.Expiration {
+ t.Fatalf("expected expiration pointers to differ, but got same!")
+ }
+ if sameSlice(gNode.Nodes, eNode.Nodes) {
+ t.Fatalf("expected nodes pointers to differ, but got same!")
+ }
+ // Original should be the same
+ testutil.AssertEqual(t, eNode.Key, key)
+ testutil.AssertEqual(t, eNode.TTL, ttl)
+ testutil.AssertEqual(t, eNode.CreatedIndex, ci)
+ testutil.AssertEqual(t, eNode.ModifiedIndex, mi)
+ testutil.AssertEqual(t, eNode.Value, valp)
+ testutil.AssertEqual(t, eNode.Expiration, expp)
+ if !sameSlice(eNode.Nodes, childs) {
+ t.Fatalf("expected nodes pointer to same, but got different!")
+ }
+ // Change the clone and ensure the original is not affected
+ gNode.Key = "/baz"
+ gNode.TTL = 0
+ gNode.Nodes[0].Key = "uno"
+ testutil.AssertEqual(t, eNode.Key, key)
+ testutil.AssertEqual(t, eNode.TTL, ttl)
+ testutil.AssertEqual(t, eNode.CreatedIndex, ci)
+ testutil.AssertEqual(t, eNode.ModifiedIndex, mi)
+ testutil.AssertEqual(t, *eNode.Nodes[0], child)
+ // Change the original and ensure the clone is not affected
+ eNode.Key = "/wuf"
+ testutil.AssertEqual(t, eNode.Key, "/wuf")
+ testutil.AssertEqual(t, gNode.Key, "/baz")
+}
+
+func sameSlice(a, b []*NodeExtern) bool {
+ ah := (*reflect.SliceHeader)(unsafe.Pointer(&a))
+ bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
+ return *ah == *bh
+}
diff --git a/vendor/github.com/coreos/etcd/store/node_test.go b/vendor/github.com/coreos/etcd/store/node_test.go
new file mode 100644
index 00000000..96fde8a9
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/node_test.go
@@ -0,0 +1,246 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "testing"
+ "time"
+
+ "github.com/jonboulle/clockwork"
+)
+
+var (
+ key, val = "foo", "bar"
+ val1, val2 = "bar1", "bar2"
+ expiration = time.Minute
+)
+
+func TestNewKVIs(t *testing.T) {
+ nd := newTestNode()
+
+ if nd.IsHidden() {
+ t.Errorf("nd.Hidden() = %v, want = false", nd.IsHidden())
+ }
+
+ if nd.IsPermanent() {
+ t.Errorf("nd.IsPermanent() = %v, want = false", nd.IsPermanent())
+ }
+
+ if nd.IsDir() {
+ t.Errorf("nd.IsDir() = %v, want = false", nd.IsDir())
+ }
+}
+
+func TestNewKVReadWriteCompare(t *testing.T) {
+ nd := newTestNode()
+
+ if v, err := nd.Read(); v != val || err != nil {
+ t.Errorf("value = %s and err = %v, want value = %s and err = nil", v, err, val)
+ }
+
+ if err := nd.Write(val1, nd.CreatedIndex+1); err != nil {
+ t.Errorf("nd.Write error = %v, want = nil", err)
+ } else {
+ if v, err := nd.Read(); v != val1 || err != nil {
+ t.Errorf("value = %s and err = %v, want value = %s and err = nil", v, err, val1)
+ }
+ }
+ if err := nd.Write(val2, nd.CreatedIndex+2); err != nil {
+ t.Errorf("nd.Write error = %v, want = nil", err)
+ } else {
+ if v, err := nd.Read(); v != val2 || err != nil {
+ t.Errorf("value = %s and err = %v, want value = %s and err = nil", v, err, val2)
+ }
+ }
+
+ if ok, which := nd.Compare(val2, 2); !ok || which != 0 {
+ t.Errorf("ok = %v and which = %d, want ok = true and which = 0", ok, which)
+ }
+}
+
+func TestNewKVExpiration(t *testing.T) {
+ nd := newTestNode()
+
+ if _, ttl := nd.expirationAndTTL(clockwork.NewFakeClock()); ttl > expiration.Nanoseconds() {
+ t.Errorf("ttl = %d, want %d < %d", ttl, ttl, expiration.Nanoseconds())
+ }
+
+ newExpiration := time.Hour
+ nd.UpdateTTL(time.Now().Add(newExpiration))
+ if _, ttl := nd.expirationAndTTL(clockwork.NewFakeClock()); ttl > newExpiration.Nanoseconds() {
+ t.Errorf("ttl = %d, want %d < %d", ttl, ttl, newExpiration.Nanoseconds())
+ }
+ if ns, err := nd.List(); ns != nil || err == nil {
+ t.Errorf("nodes = %v and err = %v, want nodes = nil and err != nil", ns, err)
+ }
+
+ en := nd.Repr(false, false, clockwork.NewFakeClock())
+ if en.Key != nd.Path {
+ t.Errorf("en.Key = %s, want = %s", en.Key, nd.Path)
+ }
+ if *(en.Value) != nd.Value {
+ t.Errorf("*(en.Key) = %s, want = %s", *(en.Value), nd.Value)
+ }
+}
+
+func TestNewKVListReprCompareClone(t *testing.T) {
+ nd := newTestNode()
+
+ if ns, err := nd.List(); ns != nil || err == nil {
+ t.Errorf("nodes = %v and err = %v, want nodes = nil and err != nil", ns, err)
+ }
+
+ en := nd.Repr(false, false, clockwork.NewFakeClock())
+ if en.Key != nd.Path {
+ t.Errorf("en.Key = %s, want = %s", en.Key, nd.Path)
+ }
+ if *(en.Value) != nd.Value {
+ t.Errorf("*(en.Key) = %s, want = %s", *(en.Value), nd.Value)
+ }
+
+ cn := nd.Clone()
+ if cn.Path != nd.Path {
+ t.Errorf("cn.Path = %s, want = %s", cn.Path, nd.Path)
+ }
+ if cn.Value != nd.Value {
+ t.Errorf("cn.Value = %s, want = %s", cn.Value, nd.Value)
+ }
+}
+
+func TestNewKVRemove(t *testing.T) {
+ nd := newTestNode()
+
+ if v, err := nd.Read(); v != val || err != nil {
+ t.Errorf("value = %s and err = %v, want value = %s and err = nil", v, err, val)
+ }
+
+ if err := nd.Write(val1, nd.CreatedIndex+1); err != nil {
+ t.Errorf("nd.Write error = %v, want = nil", err)
+ } else {
+ if v, err := nd.Read(); v != val1 || err != nil {
+ t.Errorf("value = %s and err = %v, want value = %s and err = nil", v, err, val1)
+ }
+ }
+ if err := nd.Write(val2, nd.CreatedIndex+2); err != nil {
+ t.Errorf("nd.Write error = %v, want = nil", err)
+ } else {
+ if v, err := nd.Read(); v != val2 || err != nil {
+ t.Errorf("value = %s and err = %v, want value = %s and err = nil", v, err, val2)
+ }
+ }
+
+ if err := nd.Remove(false, false, nil); err != nil {
+ t.Errorf("nd.Remove err = %v, want = nil", err)
+ } else {
+ // still readable
+ if v, err := nd.Read(); v != val2 || err != nil {
+ t.Errorf("value = %s and err = %v, want value = %s and err = nil", v, err, val2)
+ }
+ if len(nd.store.ttlKeyHeap.array) != 0 {
+ t.Errorf("len(nd.store.ttlKeyHeap.array) = %d, want = 0", len(nd.store.ttlKeyHeap.array))
+ }
+ if len(nd.store.ttlKeyHeap.keyMap) != 0 {
+ t.Errorf("len(nd.store.ttlKeyHeap.keyMap) = %d, want = 0", len(nd.store.ttlKeyHeap.keyMap))
+ }
+ }
+}
+
+func TestNewDirIs(t *testing.T) {
+ nd, _ := newTestNodeDir()
+ if nd.IsHidden() {
+ t.Errorf("nd.Hidden() = %v, want = false", nd.IsHidden())
+ }
+
+ if nd.IsPermanent() {
+ t.Errorf("nd.IsPermanent() = %v, want = false", nd.IsPermanent())
+ }
+
+ if !nd.IsDir() {
+ t.Errorf("nd.IsDir() = %v, want = true", nd.IsDir())
+ }
+}
+
+func TestNewDirReadWriteListReprClone(t *testing.T) {
+ nd, _ := newTestNodeDir()
+
+ if _, err := nd.Read(); err == nil {
+ t.Errorf("err = %v, want err != nil", err)
+ }
+
+ if err := nd.Write(val, nd.CreatedIndex+1); err == nil {
+ t.Errorf("err = %v, want err != nil", err)
+ }
+
+ if ns, err := nd.List(); ns == nil && err != nil {
+ t.Errorf("nodes = %v and err = %v, want nodes = nil and err == nil", ns, err)
+ }
+
+ en := nd.Repr(false, false, clockwork.NewFakeClock())
+ if en.Key != nd.Path {
+ t.Errorf("en.Key = %s, want = %s", en.Key, nd.Path)
+ }
+
+ cn := nd.Clone()
+ if cn.Path != nd.Path {
+ t.Errorf("cn.Path = %s, want = %s", cn.Path, nd.Path)
+ }
+}
+
+func TestNewDirExpirationTTL(t *testing.T) {
+ nd, _ := newTestNodeDir()
+
+ if _, ttl := nd.expirationAndTTL(clockwork.NewFakeClock()); ttl > expiration.Nanoseconds() {
+ t.Errorf("ttl = %d, want %d < %d", ttl, ttl, expiration.Nanoseconds())
+ }
+
+ newExpiration := time.Hour
+ nd.UpdateTTL(time.Now().Add(newExpiration))
+ if _, ttl := nd.expirationAndTTL(clockwork.NewFakeClock()); ttl > newExpiration.Nanoseconds() {
+ t.Errorf("ttl = %d, want %d < %d", ttl, ttl, newExpiration.Nanoseconds())
+ }
+}
+
+func TestNewDirChild(t *testing.T) {
+ nd, child := newTestNodeDir()
+
+ if err := nd.Add(child); err != nil {
+ t.Errorf("nd.Add(child) err = %v, want = nil", err)
+ } else {
+ if len(nd.Children) == 0 {
+ t.Errorf("len(nd.Children) = %d, want = 1", len(nd.Children))
+ }
+ }
+
+ if err := child.Remove(true, true, nil); err != nil {
+ t.Errorf("child.Remove err = %v, want = nil", err)
+ } else {
+ if len(nd.Children) != 0 {
+ t.Errorf("len(nd.Children) = %d, want = 0", len(nd.Children))
+ }
+ }
+}
+
+func newTestNode() *node {
+ nd := newKV(newStore(), key, val, 0, nil, time.Now().Add(expiration))
+ return nd
+}
+
+func newTestNodeDir() (*node, *node) {
+ s := newStore()
+ nd := newDir(s, key, 0, nil, time.Now().Add(expiration))
+ cKey, cVal := "hello", "world"
+ child := newKV(s, cKey, cVal, 0, nd, time.Now().Add(expiration))
+ return nd, child
+}
diff --git a/vendor/github.com/coreos/etcd/store/stats.go b/vendor/github.com/coreos/etcd/store/stats.go
new file mode 100644
index 00000000..59b45f2b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/stats.go
@@ -0,0 +1,146 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "encoding/json"
+ "sync/atomic"
+)
+
+const (
+ SetSuccess = iota
+ SetFail
+ DeleteSuccess
+ DeleteFail
+ CreateSuccess
+ CreateFail
+ UpdateSuccess
+ UpdateFail
+ CompareAndSwapSuccess
+ CompareAndSwapFail
+ GetSuccess
+ GetFail
+ ExpireCount
+ CompareAndDeleteSuccess
+ CompareAndDeleteFail
+)
+
+type Stats struct {
+
+ // Number of get requests
+
+ GetSuccess uint64 `json:"getsSuccess"`
+ GetFail uint64 `json:"getsFail"`
+
+ // Number of sets requests
+
+ SetSuccess uint64 `json:"setsSuccess"`
+ SetFail uint64 `json:"setsFail"`
+
+ // Number of delete requests
+
+ DeleteSuccess uint64 `json:"deleteSuccess"`
+ DeleteFail uint64 `json:"deleteFail"`
+
+ // Number of update requests
+
+ UpdateSuccess uint64 `json:"updateSuccess"`
+ UpdateFail uint64 `json:"updateFail"`
+
+ // Number of create requests
+
+ CreateSuccess uint64 `json:"createSuccess"`
+ CreateFail uint64 `json:"createFail"`
+
+ // Number of testAndSet requests
+
+ CompareAndSwapSuccess uint64 `json:"compareAndSwapSuccess"`
+ CompareAndSwapFail uint64 `json:"compareAndSwapFail"`
+
+ // Number of compareAndDelete requests
+
+ CompareAndDeleteSuccess uint64 `json:"compareAndDeleteSuccess"`
+ CompareAndDeleteFail uint64 `json:"compareAndDeleteFail"`
+
+ ExpireCount uint64 `json:"expireCount"`
+
+ Watchers uint64 `json:"watchers"`
+}
+
+func newStats() *Stats {
+ s := new(Stats)
+ return s
+}
+
+func (s *Stats) clone() *Stats {
+ return &Stats{
+ GetSuccess: s.GetSuccess,
+ GetFail: s.GetFail,
+ SetSuccess: s.SetSuccess,
+ SetFail: s.SetFail,
+ DeleteSuccess: s.DeleteSuccess,
+ DeleteFail: s.DeleteFail,
+ UpdateSuccess: s.UpdateSuccess,
+ UpdateFail: s.UpdateFail,
+ CreateSuccess: s.CreateSuccess,
+ CreateFail: s.CreateFail,
+ CompareAndSwapSuccess: s.CompareAndSwapSuccess,
+ CompareAndSwapFail: s.CompareAndSwapFail,
+ CompareAndDeleteSuccess: s.CompareAndDeleteSuccess,
+ CompareAndDeleteFail: s.CompareAndDeleteFail,
+ ExpireCount: s.ExpireCount,
+ Watchers: s.Watchers,
+ }
+}
+
+func (s *Stats) toJson() []byte {
+ b, _ := json.Marshal(s)
+ return b
+}
+
+func (s *Stats) Inc(field int) {
+ switch field {
+ case SetSuccess:
+ atomic.AddUint64(&s.SetSuccess, 1)
+ case SetFail:
+ atomic.AddUint64(&s.SetFail, 1)
+ case CreateSuccess:
+ atomic.AddUint64(&s.CreateSuccess, 1)
+ case CreateFail:
+ atomic.AddUint64(&s.CreateFail, 1)
+ case DeleteSuccess:
+ atomic.AddUint64(&s.DeleteSuccess, 1)
+ case DeleteFail:
+ atomic.AddUint64(&s.DeleteFail, 1)
+ case GetSuccess:
+ atomic.AddUint64(&s.GetSuccess, 1)
+ case GetFail:
+ atomic.AddUint64(&s.GetFail, 1)
+ case UpdateSuccess:
+ atomic.AddUint64(&s.UpdateSuccess, 1)
+ case UpdateFail:
+ atomic.AddUint64(&s.UpdateFail, 1)
+ case CompareAndSwapSuccess:
+ atomic.AddUint64(&s.CompareAndSwapSuccess, 1)
+ case CompareAndSwapFail:
+ atomic.AddUint64(&s.CompareAndSwapFail, 1)
+ case CompareAndDeleteSuccess:
+ atomic.AddUint64(&s.CompareAndDeleteSuccess, 1)
+ case CompareAndDeleteFail:
+ atomic.AddUint64(&s.CompareAndDeleteFail, 1)
+ case ExpireCount:
+ atomic.AddUint64(&s.ExpireCount, 1)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/store/stats_test.go b/vendor/github.com/coreos/etcd/store/stats_test.go
new file mode 100644
index 00000000..ec105a58
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/stats_test.go
@@ -0,0 +1,112 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "testing"
+ "time"
+
+ "github.com/coreos/etcd/pkg/testutil"
+)
+
+// Ensure that a successful Get is recorded in the stats.
+func TestStoreStatsGetSuccess(t *testing.T) {
+ s := newStore()
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Get("/foo", false, false)
+ testutil.AssertEqual(t, uint64(1), s.Stats.GetSuccess, "")
+}
+
+// Ensure that a failed Get is recorded in the stats.
+func TestStoreStatsGetFail(t *testing.T) {
+ s := newStore()
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Get("/no_such_key", false, false)
+ testutil.AssertEqual(t, uint64(1), s.Stats.GetFail, "")
+}
+
+// Ensure that a successful Create is recorded in the stats.
+func TestStoreStatsCreateSuccess(t *testing.T) {
+ s := newStore()
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertEqual(t, uint64(1), s.Stats.CreateSuccess, "")
+}
+
+// Ensure that a failed Create is recorded in the stats.
+func TestStoreStatsCreateFail(t *testing.T) {
+ s := newStore()
+ s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertEqual(t, uint64(1), s.Stats.CreateFail, "")
+}
+
+// Ensure that a successful Update is recorded in the stats.
+func TestStoreStatsUpdateSuccess(t *testing.T) {
+ s := newStore()
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertEqual(t, uint64(1), s.Stats.UpdateSuccess, "")
+}
+
+// Ensure that a failed Update is recorded in the stats.
+func TestStoreStatsUpdateFail(t *testing.T) {
+ s := newStore()
+ s.Update("/foo", "bar", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertEqual(t, uint64(1), s.Stats.UpdateFail, "")
+}
+
+// Ensure that a successful CAS is recorded in the stats.
+func TestStoreStatsCompareAndSwapSuccess(t *testing.T) {
+ s := newStore()
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ s.CompareAndSwap("/foo", "bar", 0, "baz", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertEqual(t, uint64(1), s.Stats.CompareAndSwapSuccess, "")
+}
+
+// Ensure that a failed CAS is recorded in the stats.
+func TestStoreStatsCompareAndSwapFail(t *testing.T) {
+ s := newStore()
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ s.CompareAndSwap("/foo", "wrong_value", 0, "baz", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertEqual(t, uint64(1), s.Stats.CompareAndSwapFail, "")
+}
+
+// Ensure that a successful Delete is recorded in the stats.
+func TestStoreStatsDeleteSuccess(t *testing.T) {
+ s := newStore()
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Delete("/foo", false, false)
+ testutil.AssertEqual(t, uint64(1), s.Stats.DeleteSuccess, "")
+}
+
+// Ensure that a failed Delete is recorded in the stats.
+func TestStoreStatsDeleteFail(t *testing.T) {
+ s := newStore()
+ s.Delete("/foo", false, false)
+ testutil.AssertEqual(t, uint64(1), s.Stats.DeleteFail, "")
+}
+
+//Ensure that the number of expirations is recorded in the stats.
+func TestStoreStatsExpireCount(t *testing.T) {
+ s := newStore()
+ fc := newFakeClock()
+ s.clock = fc
+
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)})
+ testutil.AssertEqual(t, uint64(0), s.Stats.ExpireCount, "")
+ fc.Advance(600 * time.Millisecond)
+ s.DeleteExpiredKeys(fc.Now())
+ testutil.AssertEqual(t, uint64(1), s.Stats.ExpireCount, "")
+}
diff --git a/vendor/github.com/coreos/etcd/store/store.go b/vendor/github.com/coreos/etcd/store/store.go
new file mode 100644
index 00000000..edf7f219
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/store.go
@@ -0,0 +1,791 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "encoding/json"
+ "fmt"
+ "path"
+ "strconv"
+ "strings"
+ "sync"
+ "time"
+
+ etcdErr "github.com/coreos/etcd/error"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/jonboulle/clockwork"
+)
+
+// The default version to set when the store is first initialized.
+const defaultVersion = 2
+
+var minExpireTime time.Time
+
+func init() {
+ minExpireTime, _ = time.Parse(time.RFC3339, "2000-01-01T00:00:00Z")
+}
+
+type Store interface {
+ Version() int
+ Index() uint64
+
+ Get(nodePath string, recursive, sorted bool) (*Event, error)
+ Set(nodePath string, dir bool, value string, expireOpts TTLOptionSet) (*Event, error)
+ Update(nodePath string, newValue string, expireOpts TTLOptionSet) (*Event, error)
+ Create(nodePath string, dir bool, value string, unique bool,
+ expireOpts TTLOptionSet) (*Event, error)
+ CompareAndSwap(nodePath string, prevValue string, prevIndex uint64,
+ value string, expireOpts TTLOptionSet) (*Event, error)
+ Delete(nodePath string, dir, recursive bool) (*Event, error)
+ CompareAndDelete(nodePath string, prevValue string, prevIndex uint64) (*Event, error)
+
+ Watch(prefix string, recursive, stream bool, sinceIndex uint64) (Watcher, error)
+
+ Save() ([]byte, error)
+ Recovery(state []byte) error
+
+ Clone() Store
+ SaveNoCopy() ([]byte, error)
+
+ JsonStats() []byte
+ DeleteExpiredKeys(cutoff time.Time)
+
+ HasTTLKeys() bool
+}
+
+type TTLOptionSet struct {
+ ExpireTime time.Time
+ Refresh bool
+}
+
+type store struct {
+ Root *node
+ WatcherHub *watcherHub
+ CurrentIndex uint64
+ Stats *Stats
+ CurrentVersion int
+ ttlKeyHeap *ttlKeyHeap // need to recovery manually
+ worldLock sync.RWMutex // stop the world lock
+ clock clockwork.Clock
+ readonlySet types.Set
+}
+
+// New creates a store where the given namespaces will be created as initial directories.
+func New(namespaces ...string) Store {
+ s := newStore(namespaces...)
+ s.clock = clockwork.NewRealClock()
+ return s
+}
+
+func newStore(namespaces ...string) *store {
+ s := new(store)
+ s.CurrentVersion = defaultVersion
+ s.Root = newDir(s, "/", s.CurrentIndex, nil, Permanent)
+ for _, namespace := range namespaces {
+ s.Root.Add(newDir(s, namespace, s.CurrentIndex, s.Root, Permanent))
+ }
+ s.Stats = newStats()
+ s.WatcherHub = newWatchHub(1000)
+ s.ttlKeyHeap = newTtlKeyHeap()
+ s.readonlySet = types.NewUnsafeSet(append(namespaces, "/")...)
+ return s
+}
+
+// Version retrieves current version of the store.
+func (s *store) Version() int {
+ return s.CurrentVersion
+}
+
+// Index retrieves the current index of the store.
+func (s *store) Index() uint64 {
+ s.worldLock.RLock()
+ defer s.worldLock.RUnlock()
+ return s.CurrentIndex
+}
+
+// Get returns a get event.
+// If recursive is true, it will return all the content under the node path.
+// If sorted is true, it will sort the content by keys.
+func (s *store) Get(nodePath string, recursive, sorted bool) (*Event, error) {
+ var err *etcdErr.Error
+
+ s.worldLock.RLock()
+ defer s.worldLock.RUnlock()
+
+ defer func() {
+ if err == nil {
+ s.Stats.Inc(GetSuccess)
+ if recursive {
+ reportReadSuccess(GetRecursive)
+ } else {
+ reportReadSuccess(Get)
+ }
+ return
+ }
+
+ s.Stats.Inc(GetFail)
+ if recursive {
+ reportReadFailure(GetRecursive)
+ } else {
+ reportReadFailure(Get)
+ }
+ }()
+
+ n, err := s.internalGet(nodePath)
+ if err != nil {
+ return nil, err
+ }
+
+ e := newEvent(Get, nodePath, n.ModifiedIndex, n.CreatedIndex)
+ e.EtcdIndex = s.CurrentIndex
+ e.Node.loadInternalNode(n, recursive, sorted, s.clock)
+
+ return e, nil
+}
+
+// Create creates the node at nodePath. Create will help to create intermediate directories with no ttl.
+// If the node has already existed, create will fail.
+// If any node on the path is a file, create will fail.
+func (s *store) Create(nodePath string, dir bool, value string, unique bool, expireOpts TTLOptionSet) (*Event, error) {
+ var err *etcdErr.Error
+
+ s.worldLock.Lock()
+ defer s.worldLock.Unlock()
+
+ defer func() {
+ if err == nil {
+ s.Stats.Inc(CreateSuccess)
+ reportWriteSuccess(Create)
+ return
+ }
+
+ s.Stats.Inc(CreateFail)
+ reportWriteFailure(Create)
+ }()
+
+ e, err := s.internalCreate(nodePath, dir, value, unique, false, expireOpts.ExpireTime, Create)
+ if err != nil {
+ return nil, err
+ }
+
+ e.EtcdIndex = s.CurrentIndex
+ s.WatcherHub.notify(e)
+
+ return e, nil
+}
+
+// Set creates or replace the node at nodePath.
+func (s *store) Set(nodePath string, dir bool, value string, expireOpts TTLOptionSet) (*Event, error) {
+ var err *etcdErr.Error
+
+ s.worldLock.Lock()
+ defer s.worldLock.Unlock()
+
+ defer func() {
+ if err == nil {
+ s.Stats.Inc(SetSuccess)
+ reportWriteSuccess(Set)
+ return
+ }
+
+ s.Stats.Inc(SetFail)
+ reportWriteFailure(Set)
+ }()
+
+ // Get prevNode value
+ n, getErr := s.internalGet(nodePath)
+ if getErr != nil && getErr.ErrorCode != etcdErr.EcodeKeyNotFound {
+ err = getErr
+ return nil, err
+ }
+
+ if expireOpts.Refresh {
+ if getErr != nil {
+ err = getErr
+ return nil, err
+ } else {
+ value = n.Value
+ }
+ }
+
+ // Set new value
+ e, err := s.internalCreate(nodePath, dir, value, false, true, expireOpts.ExpireTime, Set)
+ if err != nil {
+ return nil, err
+ }
+ e.EtcdIndex = s.CurrentIndex
+
+ // Put prevNode into event
+ if getErr == nil {
+ prev := newEvent(Get, nodePath, n.ModifiedIndex, n.CreatedIndex)
+ prev.Node.loadInternalNode(n, false, false, s.clock)
+ e.PrevNode = prev.Node
+ }
+
+ if !expireOpts.Refresh {
+ s.WatcherHub.notify(e)
+ } else {
+ e.SetRefresh()
+ s.WatcherHub.add(e)
+ }
+
+ return e, nil
+}
+
+// returns user-readable cause of failed comparison
+func getCompareFailCause(n *node, which int, prevValue string, prevIndex uint64) string {
+ switch which {
+ case CompareIndexNotMatch:
+ return fmt.Sprintf("[%v != %v]", prevIndex, n.ModifiedIndex)
+ case CompareValueNotMatch:
+ return fmt.Sprintf("[%v != %v]", prevValue, n.Value)
+ default:
+ return fmt.Sprintf("[%v != %v] [%v != %v]", prevValue, n.Value, prevIndex, n.ModifiedIndex)
+ }
+}
+
+func (s *store) CompareAndSwap(nodePath string, prevValue string, prevIndex uint64,
+ value string, expireOpts TTLOptionSet) (*Event, error) {
+
+ var err *etcdErr.Error
+
+ s.worldLock.Lock()
+ defer s.worldLock.Unlock()
+
+ defer func() {
+ if err == nil {
+ s.Stats.Inc(CompareAndSwapSuccess)
+ reportWriteSuccess(CompareAndSwap)
+ return
+ }
+
+ s.Stats.Inc(CompareAndSwapFail)
+ reportWriteFailure(CompareAndSwap)
+ }()
+
+ nodePath = path.Clean(path.Join("/", nodePath))
+ // we do not allow the user to change "/"
+ if s.readonlySet.Contains(nodePath) {
+ return nil, etcdErr.NewError(etcdErr.EcodeRootROnly, "/", s.CurrentIndex)
+ }
+
+ n, err := s.internalGet(nodePath)
+ if err != nil {
+ return nil, err
+ }
+ if n.IsDir() { // can only compare and swap file
+ err = etcdErr.NewError(etcdErr.EcodeNotFile, nodePath, s.CurrentIndex)
+ return nil, err
+ }
+
+ // If both of the prevValue and prevIndex are given, we will test both of them.
+ // Command will be executed, only if both of the tests are successful.
+ if ok, which := n.Compare(prevValue, prevIndex); !ok {
+ cause := getCompareFailCause(n, which, prevValue, prevIndex)
+ err = etcdErr.NewError(etcdErr.EcodeTestFailed, cause, s.CurrentIndex)
+ return nil, err
+ }
+
+ if expireOpts.Refresh {
+ value = n.Value
+ }
+
+ // update etcd index
+ s.CurrentIndex++
+
+ e := newEvent(CompareAndSwap, nodePath, s.CurrentIndex, n.CreatedIndex)
+ e.EtcdIndex = s.CurrentIndex
+ e.PrevNode = n.Repr(false, false, s.clock)
+ eNode := e.Node
+
+ // if test succeed, write the value
+ n.Write(value, s.CurrentIndex)
+ n.UpdateTTL(expireOpts.ExpireTime)
+
+ // copy the value for safety
+ valueCopy := value
+ eNode.Value = &valueCopy
+ eNode.Expiration, eNode.TTL = n.expirationAndTTL(s.clock)
+
+ if !expireOpts.Refresh {
+ s.WatcherHub.notify(e)
+ } else {
+ e.SetRefresh()
+ s.WatcherHub.add(e)
+ }
+
+ return e, nil
+}
+
+// Delete deletes the node at the given path.
+// If the node is a directory, recursive must be true to delete it.
+func (s *store) Delete(nodePath string, dir, recursive bool) (*Event, error) {
+ var err *etcdErr.Error
+
+ s.worldLock.Lock()
+ defer s.worldLock.Unlock()
+
+ defer func() {
+ if err == nil {
+ s.Stats.Inc(DeleteSuccess)
+ reportWriteSuccess(Delete)
+ return
+ }
+
+ s.Stats.Inc(DeleteFail)
+ reportWriteFailure(Delete)
+ }()
+
+ nodePath = path.Clean(path.Join("/", nodePath))
+ // we do not allow the user to change "/"
+ if s.readonlySet.Contains(nodePath) {
+ return nil, etcdErr.NewError(etcdErr.EcodeRootROnly, "/", s.CurrentIndex)
+ }
+
+ // recursive implies dir
+ if recursive {
+ dir = true
+ }
+
+ n, err := s.internalGet(nodePath)
+ if err != nil { // if the node does not exist, return error
+ return nil, err
+ }
+
+ nextIndex := s.CurrentIndex + 1
+ e := newEvent(Delete, nodePath, nextIndex, n.CreatedIndex)
+ e.EtcdIndex = nextIndex
+ e.PrevNode = n.Repr(false, false, s.clock)
+ eNode := e.Node
+
+ if n.IsDir() {
+ eNode.Dir = true
+ }
+
+ callback := func(path string) { // notify function
+ // notify the watchers with deleted set true
+ s.WatcherHub.notifyWatchers(e, path, true)
+ }
+
+ err = n.Remove(dir, recursive, callback)
+ if err != nil {
+ return nil, err
+ }
+
+ // update etcd index
+ s.CurrentIndex++
+
+ s.WatcherHub.notify(e)
+
+ return e, nil
+}
+
+func (s *store) CompareAndDelete(nodePath string, prevValue string, prevIndex uint64) (*Event, error) {
+ var err *etcdErr.Error
+
+ s.worldLock.Lock()
+ defer s.worldLock.Unlock()
+
+ defer func() {
+ if err == nil {
+ s.Stats.Inc(CompareAndDeleteSuccess)
+ reportWriteSuccess(CompareAndDelete)
+ return
+ }
+
+ s.Stats.Inc(CompareAndDeleteFail)
+ reportWriteFailure(CompareAndDelete)
+ }()
+
+ nodePath = path.Clean(path.Join("/", nodePath))
+
+ n, err := s.internalGet(nodePath)
+ if err != nil { // if the node does not exist, return error
+ return nil, err
+ }
+ if n.IsDir() { // can only compare and delete file
+ return nil, etcdErr.NewError(etcdErr.EcodeNotFile, nodePath, s.CurrentIndex)
+ }
+
+ // If both of the prevValue and prevIndex are given, we will test both of them.
+ // Command will be executed, only if both of the tests are successful.
+ if ok, which := n.Compare(prevValue, prevIndex); !ok {
+ cause := getCompareFailCause(n, which, prevValue, prevIndex)
+ return nil, etcdErr.NewError(etcdErr.EcodeTestFailed, cause, s.CurrentIndex)
+ }
+
+ // update etcd index
+ s.CurrentIndex++
+
+ e := newEvent(CompareAndDelete, nodePath, s.CurrentIndex, n.CreatedIndex)
+ e.EtcdIndex = s.CurrentIndex
+ e.PrevNode = n.Repr(false, false, s.clock)
+
+ callback := func(path string) { // notify function
+ // notify the watchers with deleted set true
+ s.WatcherHub.notifyWatchers(e, path, true)
+ }
+
+ err = n.Remove(false, false, callback)
+ if err != nil {
+ return nil, err
+ }
+
+ s.WatcherHub.notify(e)
+
+ return e, nil
+}
+
+func (s *store) Watch(key string, recursive, stream bool, sinceIndex uint64) (Watcher, error) {
+ s.worldLock.RLock()
+ defer s.worldLock.RUnlock()
+
+ key = path.Clean(path.Join("/", key))
+ if sinceIndex == 0 {
+ sinceIndex = s.CurrentIndex + 1
+ }
+ // WatcherHub does not know about the current index, so we need to pass it in
+ w, err := s.WatcherHub.watch(key, recursive, stream, sinceIndex, s.CurrentIndex)
+ if err != nil {
+ return nil, err
+ }
+
+ return w, nil
+}
+
+// walk walks all the nodePath and apply the walkFunc on each directory
+func (s *store) walk(nodePath string, walkFunc func(prev *node, component string) (*node, *etcdErr.Error)) (*node, *etcdErr.Error) {
+ components := strings.Split(nodePath, "/")
+
+ curr := s.Root
+ var err *etcdErr.Error
+
+ for i := 1; i < len(components); i++ {
+ if len(components[i]) == 0 { // ignore empty string
+ return curr, nil
+ }
+
+ curr, err = walkFunc(curr, components[i])
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ return curr, nil
+}
+
+// Update updates the value/ttl of the node.
+// If the node is a file, the value and the ttl can be updated.
+// If the node is a directory, only the ttl can be updated.
+func (s *store) Update(nodePath string, newValue string, expireOpts TTLOptionSet) (*Event, error) {
+ var err *etcdErr.Error
+
+ s.worldLock.Lock()
+ defer s.worldLock.Unlock()
+
+ defer func() {
+ if err == nil {
+ s.Stats.Inc(UpdateSuccess)
+ reportWriteSuccess(Update)
+ return
+ }
+
+ s.Stats.Inc(UpdateFail)
+ reportWriteFailure(Update)
+ }()
+
+ nodePath = path.Clean(path.Join("/", nodePath))
+ // we do not allow the user to change "/"
+ if s.readonlySet.Contains(nodePath) {
+ return nil, etcdErr.NewError(etcdErr.EcodeRootROnly, "/", s.CurrentIndex)
+ }
+
+ currIndex, nextIndex := s.CurrentIndex, s.CurrentIndex+1
+
+ n, err := s.internalGet(nodePath)
+ if err != nil { // if the node does not exist, return error
+ return nil, err
+ }
+ if n.IsDir() && len(newValue) != 0 {
+ // if the node is a directory, we cannot update value to non-empty
+ return nil, etcdErr.NewError(etcdErr.EcodeNotFile, nodePath, currIndex)
+ }
+
+ if expireOpts.Refresh {
+ newValue = n.Value
+ }
+
+ e := newEvent(Update, nodePath, nextIndex, n.CreatedIndex)
+ e.EtcdIndex = nextIndex
+ e.PrevNode = n.Repr(false, false, s.clock)
+ eNode := e.Node
+
+ n.Write(newValue, nextIndex)
+
+ if n.IsDir() {
+ eNode.Dir = true
+ } else {
+ // copy the value for safety
+ newValueCopy := newValue
+ eNode.Value = &newValueCopy
+ }
+
+ // update ttl
+ n.UpdateTTL(expireOpts.ExpireTime)
+
+ eNode.Expiration, eNode.TTL = n.expirationAndTTL(s.clock)
+
+ if !expireOpts.Refresh {
+ s.WatcherHub.notify(e)
+ } else {
+ e.SetRefresh()
+ s.WatcherHub.add(e)
+ }
+
+ s.CurrentIndex = nextIndex
+
+ return e, nil
+}
+
+func (s *store) internalCreate(nodePath string, dir bool, value string, unique, replace bool,
+ expireTime time.Time, action string) (*Event, *etcdErr.Error) {
+
+ currIndex, nextIndex := s.CurrentIndex, s.CurrentIndex+1
+
+ if unique { // append unique item under the node path
+ nodePath += "/" + fmt.Sprintf("%020s", strconv.FormatUint(nextIndex, 10))
+ }
+
+ nodePath = path.Clean(path.Join("/", nodePath))
+
+ // we do not allow the user to change "/"
+ if s.readonlySet.Contains(nodePath) {
+ return nil, etcdErr.NewError(etcdErr.EcodeRootROnly, "/", currIndex)
+ }
+
+ // Assume expire times that are way in the past are
+ // This can occur when the time is serialized to JS
+ if expireTime.Before(minExpireTime) {
+ expireTime = Permanent
+ }
+
+ dirName, nodeName := path.Split(nodePath)
+
+ // walk through the nodePath, create dirs and get the last directory node
+ d, err := s.walk(dirName, s.checkDir)
+
+ if err != nil {
+ s.Stats.Inc(SetFail)
+ reportWriteFailure(action)
+ err.Index = currIndex
+ return nil, err
+ }
+
+ e := newEvent(action, nodePath, nextIndex, nextIndex)
+ eNode := e.Node
+
+ n, _ := d.GetChild(nodeName)
+
+ // force will try to replace an existing file
+ if n != nil {
+ if replace {
+ if n.IsDir() {
+ return nil, etcdErr.NewError(etcdErr.EcodeNotFile, nodePath, currIndex)
+ }
+ e.PrevNode = n.Repr(false, false, s.clock)
+
+ n.Remove(false, false, nil)
+ } else {
+ return nil, etcdErr.NewError(etcdErr.EcodeNodeExist, nodePath, currIndex)
+ }
+ }
+
+ if !dir { // create file
+ // copy the value for safety
+ valueCopy := value
+ eNode.Value = &valueCopy
+
+ n = newKV(s, nodePath, value, nextIndex, d, expireTime)
+
+ } else { // create directory
+ eNode.Dir = true
+
+ n = newDir(s, nodePath, nextIndex, d, expireTime)
+ }
+
+ // we are sure d is a directory and does not have the children with name n.Name
+ d.Add(n)
+
+ // node with TTL
+ if !n.IsPermanent() {
+ s.ttlKeyHeap.push(n)
+
+ eNode.Expiration, eNode.TTL = n.expirationAndTTL(s.clock)
+ }
+
+ s.CurrentIndex = nextIndex
+
+ return e, nil
+}
+
+// InternalGet gets the node of the given nodePath.
+func (s *store) internalGet(nodePath string) (*node, *etcdErr.Error) {
+ nodePath = path.Clean(path.Join("/", nodePath))
+
+ walkFunc := func(parent *node, name string) (*node, *etcdErr.Error) {
+
+ if !parent.IsDir() {
+ err := etcdErr.NewError(etcdErr.EcodeNotDir, parent.Path, s.CurrentIndex)
+ return nil, err
+ }
+
+ child, ok := parent.Children[name]
+ if ok {
+ return child, nil
+ }
+
+ return nil, etcdErr.NewError(etcdErr.EcodeKeyNotFound, path.Join(parent.Path, name), s.CurrentIndex)
+ }
+
+ f, err := s.walk(nodePath, walkFunc)
+
+ if err != nil {
+ return nil, err
+ }
+ return f, nil
+}
+
+// DeleteExpiredKeys will delete all expired keys
+func (s *store) DeleteExpiredKeys(cutoff time.Time) {
+ s.worldLock.Lock()
+ defer s.worldLock.Unlock()
+
+ for {
+ node := s.ttlKeyHeap.top()
+ if node == nil || node.ExpireTime.After(cutoff) {
+ break
+ }
+
+ s.CurrentIndex++
+ e := newEvent(Expire, node.Path, s.CurrentIndex, node.CreatedIndex)
+ e.EtcdIndex = s.CurrentIndex
+ e.PrevNode = node.Repr(false, false, s.clock)
+ if node.IsDir() {
+ e.Node.Dir = true
+ }
+
+ callback := func(path string) { // notify function
+ // notify the watchers with deleted set true
+ s.WatcherHub.notifyWatchers(e, path, true)
+ }
+
+ s.ttlKeyHeap.pop()
+ node.Remove(true, true, callback)
+
+ reportExpiredKey()
+ s.Stats.Inc(ExpireCount)
+
+ s.WatcherHub.notify(e)
+ }
+
+}
+
+// checkDir will check whether the component is a directory under parent node.
+// If it is a directory, this function will return the pointer to that node.
+// If it does not exist, this function will create a new directory and return the pointer to that node.
+// If it is a file, this function will return error.
+func (s *store) checkDir(parent *node, dirName string) (*node, *etcdErr.Error) {
+ node, ok := parent.Children[dirName]
+
+ if ok {
+ if node.IsDir() {
+ return node, nil
+ }
+
+ return nil, etcdErr.NewError(etcdErr.EcodeNotDir, node.Path, s.CurrentIndex)
+ }
+
+ n := newDir(s, path.Join(parent.Path, dirName), s.CurrentIndex+1, parent, Permanent)
+
+ parent.Children[dirName] = n
+
+ return n, nil
+}
+
+// Save saves the static state of the store system.
+// It will not be able to save the state of watchers.
+// It will not save the parent field of the node. Or there will
+// be cyclic dependencies issue for the json package.
+func (s *store) Save() ([]byte, error) {
+ b, err := json.Marshal(s.Clone())
+ if err != nil {
+ return nil, err
+ }
+
+ return b, nil
+}
+
+func (s *store) SaveNoCopy() ([]byte, error) {
+ b, err := json.Marshal(s)
+ if err != nil {
+ return nil, err
+ }
+
+ return b, nil
+}
+
+func (s *store) Clone() Store {
+ s.worldLock.Lock()
+
+ clonedStore := newStore()
+ clonedStore.CurrentIndex = s.CurrentIndex
+ clonedStore.Root = s.Root.Clone()
+ clonedStore.WatcherHub = s.WatcherHub.clone()
+ clonedStore.Stats = s.Stats.clone()
+ clonedStore.CurrentVersion = s.CurrentVersion
+
+ s.worldLock.Unlock()
+ return clonedStore
+}
+
+// Recovery recovers the store system from a static state
+// It needs to recover the parent field of the nodes.
+// It needs to delete the expired nodes since the saved time and also
+// needs to create monitoring go routines.
+func (s *store) Recovery(state []byte) error {
+ s.worldLock.Lock()
+ defer s.worldLock.Unlock()
+ err := json.Unmarshal(state, s)
+
+ if err != nil {
+ return err
+ }
+
+ s.ttlKeyHeap = newTtlKeyHeap()
+
+ s.Root.recoverAndclean()
+ return nil
+}
+
+func (s *store) JsonStats() []byte {
+ s.Stats.Watchers = uint64(s.WatcherHub.count)
+ return s.Stats.toJson()
+}
+
+func (s *store) HasTTLKeys() bool {
+ s.worldLock.RLock()
+ defer s.worldLock.RUnlock()
+ return s.ttlKeyHeap.Len() != 0
+}
diff --git a/vendor/github.com/coreos/etcd/store/store_bench_test.go b/vendor/github.com/coreos/etcd/store/store_bench_test.go
new file mode 100644
index 00000000..e96dd400
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/store_bench_test.go
@@ -0,0 +1,219 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "encoding/json"
+ "fmt"
+ "runtime"
+ "testing"
+)
+
+func BenchmarkStoreSet128Bytes(b *testing.B) {
+ benchStoreSet(b, 128, nil)
+}
+
+func BenchmarkStoreSet1024Bytes(b *testing.B) {
+ benchStoreSet(b, 1024, nil)
+}
+
+func BenchmarkStoreSet4096Bytes(b *testing.B) {
+ benchStoreSet(b, 4096, nil)
+}
+
+func BenchmarkStoreSetWithJson128Bytes(b *testing.B) {
+ benchStoreSet(b, 128, json.Marshal)
+}
+
+func BenchmarkStoreSetWithJson1024Bytes(b *testing.B) {
+ benchStoreSet(b, 1024, json.Marshal)
+}
+
+func BenchmarkStoreSetWithJson4096Bytes(b *testing.B) {
+ benchStoreSet(b, 4096, json.Marshal)
+}
+
+func BenchmarkStoreDelete(b *testing.B) {
+ b.StopTimer()
+
+ s := newStore()
+ kvs, _ := generateNRandomKV(b.N, 128)
+
+ memStats := new(runtime.MemStats)
+ runtime.GC()
+ runtime.ReadMemStats(memStats)
+
+ for i := 0; i < b.N; i++ {
+ _, err := s.Set(kvs[i][0], false, kvs[i][1], TTLOptionSet{ExpireTime: Permanent})
+ if err != nil {
+ panic(err)
+ }
+ }
+
+ setMemStats := new(runtime.MemStats)
+ runtime.GC()
+ runtime.ReadMemStats(setMemStats)
+
+ b.StartTimer()
+
+ for i := range kvs {
+ s.Delete(kvs[i][0], false, false)
+ }
+
+ b.StopTimer()
+
+ // clean up
+ e, err := s.Get("/", false, false)
+ if err != nil {
+ panic(err)
+ }
+
+ for _, n := range e.Node.Nodes {
+ _, err := s.Delete(n.Key, true, true)
+ if err != nil {
+ panic(err)
+ }
+ }
+ s.WatcherHub.EventHistory = nil
+
+ deleteMemStats := new(runtime.MemStats)
+ runtime.GC()
+ runtime.ReadMemStats(deleteMemStats)
+
+ fmt.Printf("\nBefore set Alloc: %v; After set Alloc: %v, After delete Alloc: %v\n",
+ memStats.Alloc/1000, setMemStats.Alloc/1000, deleteMemStats.Alloc/1000)
+}
+
+func BenchmarkWatch(b *testing.B) {
+ b.StopTimer()
+ s := newStore()
+ kvs, _ := generateNRandomKV(b.N, 128)
+ b.StartTimer()
+
+ memStats := new(runtime.MemStats)
+ runtime.GC()
+ runtime.ReadMemStats(memStats)
+
+ for i := 0; i < b.N; i++ {
+ w, _ := s.Watch(kvs[i][0], false, false, 0)
+
+ e := newEvent("set", kvs[i][0], uint64(i+1), uint64(i+1))
+ s.WatcherHub.notify(e)
+ <-w.EventChan()
+ s.CurrentIndex++
+ }
+
+ s.WatcherHub.EventHistory = nil
+ afterMemStats := new(runtime.MemStats)
+ runtime.GC()
+ runtime.ReadMemStats(afterMemStats)
+ fmt.Printf("\nBefore Alloc: %v; After Alloc: %v\n",
+ memStats.Alloc/1000, afterMemStats.Alloc/1000)
+}
+
+func BenchmarkWatchWithSet(b *testing.B) {
+ b.StopTimer()
+ s := newStore()
+ kvs, _ := generateNRandomKV(b.N, 128)
+ b.StartTimer()
+
+ for i := 0; i < b.N; i++ {
+ w, _ := s.Watch(kvs[i][0], false, false, 0)
+
+ s.Set(kvs[i][0], false, "test", TTLOptionSet{ExpireTime: Permanent})
+ <-w.EventChan()
+ }
+}
+
+func BenchmarkWatchWithSetBatch(b *testing.B) {
+ b.StopTimer()
+ s := newStore()
+ kvs, _ := generateNRandomKV(b.N, 128)
+ b.StartTimer()
+
+ watchers := make([]Watcher, b.N)
+
+ for i := 0; i < b.N; i++ {
+ watchers[i], _ = s.Watch(kvs[i][0], false, false, 0)
+ }
+
+ for i := 0; i < b.N; i++ {
+ s.Set(kvs[i][0], false, "test", TTLOptionSet{ExpireTime: Permanent})
+ }
+
+ for i := 0; i < b.N; i++ {
+ <-watchers[i].EventChan()
+ }
+
+}
+
+func BenchmarkWatchOneKey(b *testing.B) {
+ s := newStore()
+ watchers := make([]Watcher, b.N)
+
+ for i := 0; i < b.N; i++ {
+ watchers[i], _ = s.Watch("/foo", false, false, 0)
+ }
+
+ s.Set("/foo", false, "", TTLOptionSet{ExpireTime: Permanent})
+
+ for i := 0; i < b.N; i++ {
+ <-watchers[i].EventChan()
+ }
+}
+
+func benchStoreSet(b *testing.B, valueSize int, process func(interface{}) ([]byte, error)) {
+ s := newStore()
+ b.StopTimer()
+ kvs, size := generateNRandomKV(b.N, valueSize)
+ b.StartTimer()
+
+ for i := 0; i < b.N; i++ {
+ resp, err := s.Set(kvs[i][0], false, kvs[i][1], TTLOptionSet{ExpireTime: Permanent})
+ if err != nil {
+ panic(err)
+ }
+
+ if process != nil {
+ _, err = process(resp)
+ if err != nil {
+ panic(err)
+ }
+ }
+ }
+
+ kvs = nil
+ b.StopTimer()
+ memStats := new(runtime.MemStats)
+ runtime.GC()
+ runtime.ReadMemStats(memStats)
+ fmt.Printf("\nAlloc: %vKB; Data: %vKB; Kvs: %v; Alloc/Data:%v\n",
+ memStats.Alloc/1000, size/1000, b.N, memStats.Alloc/size)
+}
+
+func generateNRandomKV(n int, valueSize int) ([][]string, uint64) {
+ var size uint64
+ kvs := make([][]string, n)
+ bytes := make([]byte, valueSize)
+
+ for i := 0; i < n; i++ {
+ kvs[i] = make([]string, 2)
+ kvs[i][0] = fmt.Sprintf("/%010d/%010d/%010d", n, n, n)
+ kvs[i][1] = string(bytes)
+ size = size + uint64(len(kvs[i][0])) + uint64(len(kvs[i][1]))
+ }
+
+ return kvs, size
+}
diff --git a/vendor/github.com/coreos/etcd/store/store_test.go b/vendor/github.com/coreos/etcd/store/store_test.go
new file mode 100644
index 00000000..49f6fc62
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/store_test.go
@@ -0,0 +1,1122 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "testing"
+ "time"
+
+ etcdErr "github.com/coreos/etcd/error"
+ "github.com/coreos/etcd/pkg/testutil"
+ "github.com/jonboulle/clockwork"
+)
+
+func TestNewStoreWithNamespaces(t *testing.T) {
+ s := newStore("/0", "/1")
+
+ _, err := s.Get("/0", false, false)
+ testutil.AssertNil(t, err)
+ _, err = s.Get("/1", false, false)
+ testutil.AssertNil(t, err)
+}
+
+// Ensure that the store can retrieve an existing value.
+func TestStoreGetValue(t *testing.T) {
+ s := newStore()
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ var eidx uint64 = 1
+ e, err := s.Get("/foo", false, false)
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "get")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ testutil.AssertEqual(t, *e.Node.Value, "bar")
+}
+
+// Ensure that any TTL <= minExpireTime becomes Permanent
+func TestMinExpireTime(t *testing.T) {
+ s := newStore()
+ fc := clockwork.NewFakeClock()
+ s.clock = fc
+ // FakeClock starts at 0, so minExpireTime should be far in the future.. but just in case
+ testutil.AssertTrue(t, minExpireTime.After(fc.Now()), "minExpireTime should be ahead of FakeClock!")
+ s.Create("/foo", false, "Y", false, TTLOptionSet{ExpireTime: fc.Now().Add(3 * time.Second)})
+ fc.Advance(5 * time.Second)
+ // Ensure it hasn't expired
+ s.DeleteExpiredKeys(fc.Now())
+ var eidx uint64 = 1
+ e, err := s.Get("/foo", true, false)
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "get")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ testutil.AssertEqual(t, e.Node.TTL, int64(0))
+}
+
+// Ensure that the store can recursively retrieve a directory listing.
+// Note that hidden files should not be returned.
+func TestStoreGetDirectory(t *testing.T) {
+ s := newStore()
+ fc := newFakeClock()
+ s.clock = fc
+ s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/bar", false, "X", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/_hidden", false, "*", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/baz", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/baz/bat", false, "Y", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/baz/_hidden", false, "*", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/baz/ttl", false, "Y", false, TTLOptionSet{ExpireTime: fc.Now().Add(time.Second * 3)})
+ var eidx uint64 = 7
+ e, err := s.Get("/foo", true, false)
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "get")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ testutil.AssertEqual(t, len(e.Node.Nodes), 2)
+ var bazNodes NodeExterns
+ for _, node := range e.Node.Nodes {
+ switch node.Key {
+ case "/foo/bar":
+ testutil.AssertEqual(t, *node.Value, "X")
+ testutil.AssertEqual(t, node.Dir, false)
+ case "/foo/baz":
+ testutil.AssertEqual(t, node.Dir, true)
+ testutil.AssertEqual(t, len(node.Nodes), 2)
+ bazNodes = node.Nodes
+ default:
+ t.Errorf("key = %s, not matched", node.Key)
+ }
+ }
+ for _, node := range bazNodes {
+ switch node.Key {
+ case "/foo/baz/bat":
+ testutil.AssertEqual(t, *node.Value, "Y")
+ testutil.AssertEqual(t, node.Dir, false)
+ case "/foo/baz/ttl":
+ testutil.AssertEqual(t, *node.Value, "Y")
+ testutil.AssertEqual(t, node.Dir, false)
+ testutil.AssertEqual(t, node.TTL, int64(3))
+ default:
+ t.Errorf("key = %s, not matched", node.Key)
+ }
+ }
+}
+
+// Ensure that the store can retrieve a directory in sorted order.
+func TestStoreGetSorted(t *testing.T) {
+ s := newStore()
+ s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/x", false, "0", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/z", false, "0", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/y", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/y/a", false, "0", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/y/b", false, "0", false, TTLOptionSet{ExpireTime: Permanent})
+ var eidx uint64 = 6
+ e, err := s.Get("/foo", true, true)
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+
+ var yNodes NodeExterns
+ sortedStrings := []string{"/foo/x", "/foo/y", "/foo/z"}
+ for i := range e.Node.Nodes {
+ node := e.Node.Nodes[i]
+ if node.Key != sortedStrings[i] {
+ t.Errorf("expect key = %s, got key = %s", sortedStrings[i], node.Key)
+ }
+ if node.Key == "/foo/y" {
+ yNodes = node.Nodes
+ }
+ }
+
+ sortedStrings = []string{"/foo/y/a", "/foo/y/b"}
+ for i := range yNodes {
+ node := yNodes[i]
+ if node.Key != sortedStrings[i] {
+ t.Errorf("expect key = %s, got key = %s", sortedStrings[i], node.Key)
+ }
+ }
+}
+
+func TestSet(t *testing.T) {
+ s := newStore()
+
+ // Set /foo=""
+ var eidx uint64 = 1
+ e, err := s.Set("/foo", false, "", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "set")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ testutil.AssertFalse(t, e.Node.Dir)
+ testutil.AssertEqual(t, *e.Node.Value, "")
+ testutil.AssertNil(t, e.Node.Nodes)
+ testutil.AssertNil(t, e.Node.Expiration)
+ testutil.AssertEqual(t, e.Node.TTL, int64(0))
+ testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(1))
+
+ // Set /foo="bar"
+ eidx = 2
+ e, err = s.Set("/foo", false, "bar", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "set")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ testutil.AssertFalse(t, e.Node.Dir)
+ testutil.AssertEqual(t, *e.Node.Value, "bar")
+ testutil.AssertNil(t, e.Node.Nodes)
+ testutil.AssertNil(t, e.Node.Expiration)
+ testutil.AssertEqual(t, e.Node.TTL, int64(0))
+ testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(2))
+ // check prevNode
+ testutil.AssertNotNil(t, e.PrevNode)
+ testutil.AssertEqual(t, e.PrevNode.Key, "/foo")
+ testutil.AssertEqual(t, *e.PrevNode.Value, "")
+ testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1))
+ // Set /foo="baz" (for testing prevNode)
+ eidx = 3
+ e, err = s.Set("/foo", false, "baz", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "set")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ testutil.AssertFalse(t, e.Node.Dir)
+ testutil.AssertEqual(t, *e.Node.Value, "baz")
+ testutil.AssertNil(t, e.Node.Nodes)
+ testutil.AssertNil(t, e.Node.Expiration)
+ testutil.AssertEqual(t, e.Node.TTL, int64(0))
+ testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(3))
+ // check prevNode
+ testutil.AssertNotNil(t, e.PrevNode)
+ testutil.AssertEqual(t, e.PrevNode.Key, "/foo")
+ testutil.AssertEqual(t, *e.PrevNode.Value, "bar")
+ testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(2))
+
+ // Set /dir as a directory
+ eidx = 4
+ e, err = s.Set("/dir", true, "", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "set")
+ testutil.AssertEqual(t, e.Node.Key, "/dir")
+ testutil.AssertTrue(t, e.Node.Dir)
+ testutil.AssertNil(t, e.Node.Value)
+ testutil.AssertNil(t, e.Node.Nodes)
+ testutil.AssertNil(t, e.Node.Expiration)
+ testutil.AssertEqual(t, e.Node.TTL, int64(0))
+ testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(4))
+}
+
+// Ensure that the store can create a new key if it doesn't already exist.
+func TestStoreCreateValue(t *testing.T) {
+ s := newStore()
+ // Create /foo=bar
+ var eidx uint64 = 1
+ e, err := s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "create")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ testutil.AssertFalse(t, e.Node.Dir)
+ testutil.AssertEqual(t, *e.Node.Value, "bar")
+ testutil.AssertNil(t, e.Node.Nodes)
+ testutil.AssertNil(t, e.Node.Expiration)
+ testutil.AssertEqual(t, e.Node.TTL, int64(0))
+ testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(1))
+
+ // Create /empty=""
+ eidx = 2
+ e, err = s.Create("/empty", false, "", false, TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "create")
+ testutil.AssertEqual(t, e.Node.Key, "/empty")
+ testutil.AssertFalse(t, e.Node.Dir)
+ testutil.AssertEqual(t, *e.Node.Value, "")
+ testutil.AssertNil(t, e.Node.Nodes)
+ testutil.AssertNil(t, e.Node.Expiration)
+ testutil.AssertEqual(t, e.Node.TTL, int64(0))
+ testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(2))
+
+}
+
+// Ensure that the store can create a new directory if it doesn't already exist.
+func TestStoreCreateDirectory(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 1
+ e, err := s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "create")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ testutil.AssertTrue(t, e.Node.Dir)
+}
+
+// Ensure that the store fails to create a key if it already exists.
+func TestStoreCreateFailsIfExists(t *testing.T) {
+ s := newStore()
+ // create /foo as dir
+ s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+
+ // create /foo as dir again
+ e, _err := s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ err := _err.(*etcdErr.Error)
+ testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeNodeExist)
+ testutil.AssertEqual(t, err.Message, "Key already exists")
+ testutil.AssertEqual(t, err.Cause, "/foo")
+ testutil.AssertEqual(t, err.Index, uint64(1))
+ testutil.AssertNil(t, e)
+}
+
+// Ensure that the store can update a key if it already exists.
+func TestStoreUpdateValue(t *testing.T) {
+ s := newStore()
+ // create /foo=bar
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ // update /foo="bzr"
+ var eidx uint64 = 2
+ e, err := s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "update")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ testutil.AssertFalse(t, e.Node.Dir)
+ testutil.AssertEqual(t, *e.Node.Value, "baz")
+ testutil.AssertEqual(t, e.Node.TTL, int64(0))
+ testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(2))
+ // check prevNode
+ testutil.AssertEqual(t, e.PrevNode.Key, "/foo")
+ testutil.AssertEqual(t, *e.PrevNode.Value, "bar")
+ testutil.AssertEqual(t, e.PrevNode.TTL, int64(0))
+ testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1))
+
+ e, _ = s.Get("/foo", false, false)
+ testutil.AssertEqual(t, *e.Node.Value, "baz")
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+
+ // update /foo=""
+ eidx = 3
+ e, err = s.Update("/foo", "", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "update")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ testutil.AssertFalse(t, e.Node.Dir)
+ testutil.AssertEqual(t, *e.Node.Value, "")
+ testutil.AssertEqual(t, e.Node.TTL, int64(0))
+ testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(3))
+ // check prevNode
+ testutil.AssertEqual(t, e.PrevNode.Key, "/foo")
+ testutil.AssertEqual(t, *e.PrevNode.Value, "baz")
+ testutil.AssertEqual(t, e.PrevNode.TTL, int64(0))
+ testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(2))
+
+ e, _ = s.Get("/foo", false, false)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, *e.Node.Value, "")
+}
+
+// Ensure that the store cannot update a directory.
+func TestStoreUpdateFailsIfDirectory(t *testing.T) {
+ s := newStore()
+ s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ e, _err := s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent})
+ err := _err.(*etcdErr.Error)
+ testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeNotFile)
+ testutil.AssertEqual(t, err.Message, "Not a file")
+ testutil.AssertEqual(t, err.Cause, "/foo")
+ testutil.AssertNil(t, e)
+}
+
+// Ensure that the store can update the TTL on a value.
+func TestStoreUpdateValueTTL(t *testing.T) {
+ s := newStore()
+ fc := newFakeClock()
+ s.clock = fc
+
+ var eidx uint64 = 2
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ _, err := s.Update("/foo", "baz", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)})
+ testutil.AssertNil(t, err)
+ e, _ := s.Get("/foo", false, false)
+ testutil.AssertEqual(t, *e.Node.Value, "baz")
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ fc.Advance(600 * time.Millisecond)
+ s.DeleteExpiredKeys(fc.Now())
+ e, err = s.Get("/foo", false, false)
+ testutil.AssertNil(t, e)
+ testutil.AssertEqual(t, err.(*etcdErr.Error).ErrorCode, etcdErr.EcodeKeyNotFound)
+}
+
+// Ensure that the store can update the TTL on a directory.
+func TestStoreUpdateDirTTL(t *testing.T) {
+ s := newStore()
+ fc := newFakeClock()
+ s.clock = fc
+
+ var eidx uint64 = 3
+ s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent})
+ e, err := s.Update("/foo", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)})
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.Node.Dir, true)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ e, _ = s.Get("/foo/bar", false, false)
+ testutil.AssertEqual(t, *e.Node.Value, "baz")
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+
+ fc.Advance(600 * time.Millisecond)
+ s.DeleteExpiredKeys(fc.Now())
+ e, err = s.Get("/foo/bar", false, false)
+ testutil.AssertNil(t, e)
+ testutil.AssertEqual(t, err.(*etcdErr.Error).ErrorCode, etcdErr.EcodeKeyNotFound)
+}
+
+// Ensure that the store can delete a value.
+func TestStoreDeleteValue(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 2
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ e, err := s.Delete("/foo", false, false)
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "delete")
+ // check prevNode
+ testutil.AssertNotNil(t, e.PrevNode)
+ testutil.AssertEqual(t, e.PrevNode.Key, "/foo")
+ testutil.AssertEqual(t, *e.PrevNode.Value, "bar")
+}
+
+// Ensure that the store can delete a directory if recursive is specified.
+func TestStoreDeleteDiretory(t *testing.T) {
+ s := newStore()
+ // create directory /foo
+ var eidx uint64 = 2
+ s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ // delete /foo with dir = true and recursive = false
+ // this should succeed, since the directory is empty
+ e, err := s.Delete("/foo", true, false)
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "delete")
+ // check prevNode
+ testutil.AssertNotNil(t, e.PrevNode)
+ testutil.AssertEqual(t, e.PrevNode.Key, "/foo")
+ testutil.AssertEqual(t, e.PrevNode.Dir, true)
+
+ // create directory /foo and directory /foo/bar
+ s.Create("/foo/bar", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ // delete /foo with dir = true and recursive = false
+ // this should fail, since the directory is not empty
+ _, err = s.Delete("/foo", true, false)
+ testutil.AssertNotNil(t, err)
+
+ // delete /foo with dir=false and recursive = true
+ // this should succeed, since recursive implies dir=true
+ // and recursively delete should be able to delete all
+ // items under the given directory
+ e, err = s.Delete("/foo", false, true)
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.Action, "delete")
+
+}
+
+// Ensure that the store cannot delete a directory if both of recursive
+// and dir are not specified.
+func TestStoreDeleteDiretoryFailsIfNonRecursiveAndDir(t *testing.T) {
+ s := newStore()
+ s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ e, _err := s.Delete("/foo", false, false)
+ err := _err.(*etcdErr.Error)
+ testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeNotFile)
+ testutil.AssertEqual(t, err.Message, "Not a file")
+ testutil.AssertNil(t, e)
+}
+
+func TestRootRdOnly(t *testing.T) {
+ s := newStore("/0")
+
+ for _, tt := range []string{"/", "/0"} {
+ _, err := s.Set(tt, true, "", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNotNil(t, err)
+
+ _, err = s.Delete(tt, true, true)
+ testutil.AssertNotNil(t, err)
+
+ _, err = s.Create(tt, true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNotNil(t, err)
+
+ _, err = s.Update(tt, "", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNotNil(t, err)
+
+ _, err = s.CompareAndSwap(tt, "", 0, "", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNotNil(t, err)
+ }
+}
+
+func TestStoreCompareAndDeletePrevValue(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 2
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ e, err := s.CompareAndDelete("/foo", "bar", 0)
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "compareAndDelete")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+
+ // check prevNode
+ testutil.AssertNotNil(t, e.PrevNode)
+ testutil.AssertEqual(t, e.PrevNode.Key, "/foo")
+ testutil.AssertEqual(t, *e.PrevNode.Value, "bar")
+ testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1))
+ testutil.AssertEqual(t, e.PrevNode.CreatedIndex, uint64(1))
+}
+
+func TestStoreCompareAndDeletePrevValueFailsIfNotMatch(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 1
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ e, _err := s.CompareAndDelete("/foo", "baz", 0)
+ err := _err.(*etcdErr.Error)
+ testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeTestFailed)
+ testutil.AssertEqual(t, err.Message, "Compare failed")
+ testutil.AssertNil(t, e)
+ e, _ = s.Get("/foo", false, false)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, *e.Node.Value, "bar")
+}
+
+func TestStoreCompareAndDeletePrevIndex(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 2
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ e, err := s.CompareAndDelete("/foo", "", 1)
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "compareAndDelete")
+ // check prevNode
+ testutil.AssertNotNil(t, e.PrevNode)
+ testutil.AssertEqual(t, e.PrevNode.Key, "/foo")
+ testutil.AssertEqual(t, *e.PrevNode.Value, "bar")
+ testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1))
+ testutil.AssertEqual(t, e.PrevNode.CreatedIndex, uint64(1))
+}
+
+func TestStoreCompareAndDeletePrevIndexFailsIfNotMatch(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 1
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ e, _err := s.CompareAndDelete("/foo", "", 100)
+ testutil.AssertNotNil(t, _err)
+ err := _err.(*etcdErr.Error)
+ testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeTestFailed)
+ testutil.AssertEqual(t, err.Message, "Compare failed")
+ testutil.AssertNil(t, e)
+ e, _ = s.Get("/foo", false, false)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, *e.Node.Value, "bar")
+}
+
+// Ensure that the store cannot delete a directory.
+func TestStoreCompareAndDeleteDiretoryFail(t *testing.T) {
+ s := newStore()
+ s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ _, _err := s.CompareAndDelete("/foo", "", 0)
+ testutil.AssertNotNil(t, _err)
+ err := _err.(*etcdErr.Error)
+ testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeNotFile)
+}
+
+// Ensure that the store can conditionally update a key if it has a previous value.
+func TestStoreCompareAndSwapPrevValue(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 2
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ e, err := s.CompareAndSwap("/foo", "bar", 0, "baz", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "compareAndSwap")
+ testutil.AssertEqual(t, *e.Node.Value, "baz")
+ // check prevNode
+ testutil.AssertNotNil(t, e.PrevNode)
+ testutil.AssertEqual(t, e.PrevNode.Key, "/foo")
+ testutil.AssertEqual(t, *e.PrevNode.Value, "bar")
+ testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1))
+ testutil.AssertEqual(t, e.PrevNode.CreatedIndex, uint64(1))
+
+ e, _ = s.Get("/foo", false, false)
+ testutil.AssertEqual(t, *e.Node.Value, "baz")
+}
+
+// Ensure that the store cannot conditionally update a key if it has the wrong previous value.
+func TestStoreCompareAndSwapPrevValueFailsIfNotMatch(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 1
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ e, _err := s.CompareAndSwap("/foo", "wrong_value", 0, "baz", TTLOptionSet{ExpireTime: Permanent})
+ err := _err.(*etcdErr.Error)
+ testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeTestFailed)
+ testutil.AssertEqual(t, err.Message, "Compare failed")
+ testutil.AssertNil(t, e)
+ e, _ = s.Get("/foo", false, false)
+ testutil.AssertEqual(t, *e.Node.Value, "bar")
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+}
+
+// Ensure that the store can conditionally update a key if it has a previous index.
+func TestStoreCompareAndSwapPrevIndex(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 2
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ e, err := s.CompareAndSwap("/foo", "", 1, "baz", TTLOptionSet{ExpireTime: Permanent})
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "compareAndSwap")
+ testutil.AssertEqual(t, *e.Node.Value, "baz")
+ // check prevNode
+ testutil.AssertNotNil(t, e.PrevNode)
+ testutil.AssertEqual(t, e.PrevNode.Key, "/foo")
+ testutil.AssertEqual(t, *e.PrevNode.Value, "bar")
+ testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1))
+ testutil.AssertEqual(t, e.PrevNode.CreatedIndex, uint64(1))
+
+ e, _ = s.Get("/foo", false, false)
+ testutil.AssertEqual(t, *e.Node.Value, "baz")
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+}
+
+// Ensure that the store cannot conditionally update a key if it has the wrong previous index.
+func TestStoreCompareAndSwapPrevIndexFailsIfNotMatch(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 1
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ e, _err := s.CompareAndSwap("/foo", "", 100, "baz", TTLOptionSet{ExpireTime: Permanent})
+ err := _err.(*etcdErr.Error)
+ testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeTestFailed)
+ testutil.AssertEqual(t, err.Message, "Compare failed")
+ testutil.AssertNil(t, e)
+ e, _ = s.Get("/foo", false, false)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, *e.Node.Value, "bar")
+}
+
+// Ensure that the store can watch for key creation.
+func TestStoreWatchCreate(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 0
+ w, _ := s.Watch("/foo", false, false, 0)
+ c := w.EventChan()
+ testutil.AssertEqual(t, w.StartIndex(), eidx)
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ eidx = 1
+ e := nbselect(c)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "create")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ e = nbselect(c)
+ testutil.AssertNil(t, e)
+}
+
+// Ensure that the store can watch for recursive key creation.
+func TestStoreWatchRecursiveCreate(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 0
+ w, _ := s.Watch("/foo", true, false, 0)
+ testutil.AssertEqual(t, w.StartIndex(), eidx)
+ eidx = 1
+ s.Create("/foo/bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent})
+ e := nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "create")
+ testutil.AssertEqual(t, e.Node.Key, "/foo/bar")
+}
+
+// Ensure that the store can watch for key updates.
+func TestStoreWatchUpdate(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 1
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ w, _ := s.Watch("/foo", false, false, 0)
+ testutil.AssertEqual(t, w.StartIndex(), eidx)
+ eidx = 2
+ s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent})
+ e := nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "update")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+}
+
+// Ensure that the store can watch for recursive key updates.
+func TestStoreWatchRecursiveUpdate(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 1
+ s.Create("/foo/bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent})
+ w, _ := s.Watch("/foo", true, false, 0)
+ testutil.AssertEqual(t, w.StartIndex(), eidx)
+ eidx = 2
+ s.Update("/foo/bar", "baz", TTLOptionSet{ExpireTime: Permanent})
+ e := nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "update")
+ testutil.AssertEqual(t, e.Node.Key, "/foo/bar")
+}
+
+// Ensure that the store can watch for key deletions.
+func TestStoreWatchDelete(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 1
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ w, _ := s.Watch("/foo", false, false, 0)
+ testutil.AssertEqual(t, w.StartIndex(), eidx)
+ eidx = 2
+ s.Delete("/foo", false, false)
+ e := nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "delete")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+}
+
+// Ensure that the store can watch for recursive key deletions.
+func TestStoreWatchRecursiveDelete(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 1
+ s.Create("/foo/bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent})
+ w, _ := s.Watch("/foo", true, false, 0)
+ testutil.AssertEqual(t, w.StartIndex(), eidx)
+ eidx = 2
+ s.Delete("/foo/bar", false, false)
+ e := nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "delete")
+ testutil.AssertEqual(t, e.Node.Key, "/foo/bar")
+}
+
+// Ensure that the store can watch for CAS updates.
+func TestStoreWatchCompareAndSwap(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 1
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ w, _ := s.Watch("/foo", false, false, 0)
+ testutil.AssertEqual(t, w.StartIndex(), eidx)
+ eidx = 2
+ s.CompareAndSwap("/foo", "bar", 0, "baz", TTLOptionSet{ExpireTime: Permanent})
+ e := nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "compareAndSwap")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+}
+
+// Ensure that the store can watch for recursive CAS updates.
+func TestStoreWatchRecursiveCompareAndSwap(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 1
+ s.Create("/foo/bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent})
+ w, _ := s.Watch("/foo", true, false, 0)
+ testutil.AssertEqual(t, w.StartIndex(), eidx)
+ eidx = 2
+ s.CompareAndSwap("/foo/bar", "baz", 0, "bat", TTLOptionSet{ExpireTime: Permanent})
+ e := nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "compareAndSwap")
+ testutil.AssertEqual(t, e.Node.Key, "/foo/bar")
+}
+
+// Ensure that the store can watch for key expiration.
+func TestStoreWatchExpire(t *testing.T) {
+ s := newStore()
+ fc := newFakeClock()
+ s.clock = fc
+
+ var eidx uint64 = 3
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(400 * time.Millisecond)})
+ s.Create("/foofoo", false, "barbarbar", false, TTLOptionSet{ExpireTime: fc.Now().Add(450 * time.Millisecond)})
+ s.Create("/foodir", true, "", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)})
+
+ w, _ := s.Watch("/", true, false, 0)
+ testutil.AssertEqual(t, w.StartIndex(), eidx)
+ c := w.EventChan()
+ e := nbselect(c)
+ testutil.AssertNil(t, e)
+ fc.Advance(600 * time.Millisecond)
+ s.DeleteExpiredKeys(fc.Now())
+ eidx = 4
+ e = nbselect(c)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "expire")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ w, _ = s.Watch("/", true, false, 5)
+ eidx = 6
+ testutil.AssertEqual(t, w.StartIndex(), eidx)
+ e = nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "expire")
+ testutil.AssertEqual(t, e.Node.Key, "/foofoo")
+ w, _ = s.Watch("/", true, false, 6)
+ e = nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "expire")
+ testutil.AssertEqual(t, e.Node.Key, "/foodir")
+ testutil.AssertEqual(t, e.Node.Dir, true)
+}
+
+// Ensure that the store can watch for key expiration when refreshing.
+func TestStoreWatchExpireRefresh(t *testing.T) {
+ s := newStore()
+ fc := newFakeClock()
+ s.clock = fc
+
+ var eidx uint64 = 2
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true})
+ s.Create("/foofoo", false, "barbarbar", false, TTLOptionSet{ExpireTime: fc.Now().Add(1200 * time.Millisecond), Refresh: true})
+
+ // Make sure we set watch updates when Refresh is true for newly created keys
+ w, _ := s.Watch("/", true, false, 0)
+ testutil.AssertEqual(t, w.StartIndex(), eidx)
+ c := w.EventChan()
+ e := nbselect(c)
+ testutil.AssertNil(t, e)
+ fc.Advance(600 * time.Millisecond)
+ s.DeleteExpiredKeys(fc.Now())
+ eidx = 3
+ e = nbselect(c)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "expire")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+
+ s.Update("/foofoo", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true})
+ w, _ = s.Watch("/", true, false, 4)
+ fc.Advance(700 * time.Millisecond)
+ s.DeleteExpiredKeys(fc.Now())
+ eidx = 5 // We should skip 4 because a TTL update should occur with no watch notification if set `TTLOptionSet.Refresh` to true
+ testutil.AssertEqual(t, w.StartIndex(), eidx-1)
+ e = nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "expire")
+ testutil.AssertEqual(t, e.Node.Key, "/foofoo")
+}
+
+// Ensure that the store can watch for key expiration when refreshing with an empty value.
+func TestStoreWatchExpireEmptyRefresh(t *testing.T) {
+ s := newStore()
+ fc := newFakeClock()
+ s.clock = fc
+
+ var eidx uint64 = 1
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true})
+ // Should be no-op
+ fc.Advance(200 * time.Millisecond)
+ s.DeleteExpiredKeys(fc.Now())
+
+ s.Update("/foo", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true})
+ w, _ := s.Watch("/", true, false, 2)
+ fc.Advance(700 * time.Millisecond)
+ s.DeleteExpiredKeys(fc.Now())
+ eidx = 3 // We should skip 2 because a TTL update should occur with no watch notification if set `TTLOptionSet.Refresh` to true
+ testutil.AssertEqual(t, w.StartIndex(), eidx-1)
+ e := nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "expire")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ testutil.AssertEqual(t, *e.PrevNode.Value, "bar")
+}
+
+// Update TTL of a key (set TTLOptionSet.Refresh to false) and send notification
+func TestStoreWatchNoRefresh(t *testing.T) {
+ s := newStore()
+ fc := newFakeClock()
+ s.clock = fc
+
+ var eidx uint64 = 1
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true})
+ // Should be no-op
+ fc.Advance(200 * time.Millisecond)
+ s.DeleteExpiredKeys(fc.Now())
+
+ // Update key's TTL with setting `TTLOptionSet.Refresh` to false will cause an update event
+ s.Update("/foo", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: false})
+ w, _ := s.Watch("/", true, false, 2)
+ fc.Advance(700 * time.Millisecond)
+ s.DeleteExpiredKeys(fc.Now())
+ eidx = 2
+ testutil.AssertEqual(t, w.StartIndex(), eidx)
+ e := nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "update")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ testutil.AssertEqual(t, *e.PrevNode.Value, "bar")
+}
+
+// Ensure that the store can update the TTL on a value with refresh.
+func TestStoreRefresh(t *testing.T) {
+ s := newStore()
+ fc := newFakeClock()
+ s.clock = fc
+
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)})
+ s.Create("/bar", true, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)})
+ _, err := s.Update("/foo", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true})
+ testutil.AssertNil(t, err)
+
+ _, err = s.Set("/foo", false, "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true})
+ testutil.AssertNil(t, err)
+
+ _, err = s.Update("/bar", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true})
+ testutil.AssertNil(t, err)
+
+ _, err = s.CompareAndSwap("/foo", "bar", 0, "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true})
+ testutil.AssertNil(t, err)
+}
+
+// Ensure that the store can watch in streaming mode.
+func TestStoreWatchStream(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 1
+ w, _ := s.Watch("/foo", false, true, 0)
+ // first modification
+ s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ e := nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "create")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ testutil.AssertEqual(t, *e.Node.Value, "bar")
+ e = nbselect(w.EventChan())
+ testutil.AssertNil(t, e)
+ // second modification
+ eidx = 2
+ s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent})
+ e = nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "update")
+ testutil.AssertEqual(t, e.Node.Key, "/foo")
+ testutil.AssertEqual(t, *e.Node.Value, "baz")
+ e = nbselect(w.EventChan())
+ testutil.AssertNil(t, e)
+}
+
+// Ensure that the store can recover from a previously saved state.
+func TestStoreRecover(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 4
+ s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/x", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Update("/foo/x", "barbar", TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/y", false, "baz", false, TTLOptionSet{ExpireTime: Permanent})
+ b, err := s.Save()
+ testutil.AssertNil(t, err)
+
+ s2 := newStore()
+ s2.Recovery(b)
+
+ e, err := s.Get("/foo/x", false, false)
+ testutil.AssertEqual(t, e.Node.CreatedIndex, uint64(2))
+ testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(3))
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, *e.Node.Value, "barbar")
+
+ e, err = s.Get("/foo/y", false, false)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, *e.Node.Value, "baz")
+}
+
+// Ensure that the store can recover from a previously saved state that includes an expiring key.
+func TestStoreRecoverWithExpiration(t *testing.T) {
+ s := newStore()
+ s.clock = newFakeClock()
+
+ fc := newFakeClock()
+
+ var eidx uint64 = 4
+ s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/x", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ s.Create("/foo/y", false, "baz", false, TTLOptionSet{ExpireTime: fc.Now().Add(5 * time.Millisecond)})
+ b, err := s.Save()
+ testutil.AssertNil(t, err)
+
+ time.Sleep(10 * time.Millisecond)
+
+ s2 := newStore()
+ s2.clock = fc
+
+ s2.Recovery(b)
+
+ fc.Advance(600 * time.Millisecond)
+ s.DeleteExpiredKeys(fc.Now())
+
+ e, err := s.Get("/foo/x", false, false)
+ testutil.AssertNil(t, err)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, *e.Node.Value, "bar")
+
+ e, err = s.Get("/foo/y", false, false)
+ testutil.AssertNotNil(t, err)
+ testutil.AssertNil(t, e)
+}
+
+// Ensure that the store can watch for hidden keys as long as it's an exact path match.
+func TestStoreWatchCreateWithHiddenKey(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 1
+ w, _ := s.Watch("/_foo", false, false, 0)
+ s.Create("/_foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ e := nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "create")
+ testutil.AssertEqual(t, e.Node.Key, "/_foo")
+ e = nbselect(w.EventChan())
+ testutil.AssertNil(t, e)
+}
+
+// Ensure that the store doesn't see hidden key creates without an exact path match in recursive mode.
+func TestStoreWatchRecursiveCreateWithHiddenKey(t *testing.T) {
+ s := newStore()
+ w, _ := s.Watch("/foo", true, false, 0)
+ s.Create("/foo/_bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent})
+ e := nbselect(w.EventChan())
+ testutil.AssertNil(t, e)
+ w, _ = s.Watch("/foo", true, false, 0)
+ s.Create("/foo/_baz", true, "", false, TTLOptionSet{ExpireTime: Permanent})
+ e = nbselect(w.EventChan())
+ testutil.AssertNil(t, e)
+ s.Create("/foo/_baz/quux", false, "quux", false, TTLOptionSet{ExpireTime: Permanent})
+ e = nbselect(w.EventChan())
+ testutil.AssertNil(t, e)
+}
+
+// Ensure that the store doesn't see hidden key updates.
+func TestStoreWatchUpdateWithHiddenKey(t *testing.T) {
+ s := newStore()
+ s.Create("/_foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ w, _ := s.Watch("/_foo", false, false, 0)
+ s.Update("/_foo", "baz", TTLOptionSet{ExpireTime: Permanent})
+ e := nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.Action, "update")
+ testutil.AssertEqual(t, e.Node.Key, "/_foo")
+ e = nbselect(w.EventChan())
+ testutil.AssertNil(t, e)
+}
+
+// Ensure that the store doesn't see hidden key updates without an exact path match in recursive mode.
+func TestStoreWatchRecursiveUpdateWithHiddenKey(t *testing.T) {
+ s := newStore()
+ s.Create("/foo/_bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent})
+ w, _ := s.Watch("/foo", true, false, 0)
+ s.Update("/foo/_bar", "baz", TTLOptionSet{ExpireTime: Permanent})
+ e := nbselect(w.EventChan())
+ testutil.AssertNil(t, e)
+}
+
+// Ensure that the store can watch for key deletions.
+func TestStoreWatchDeleteWithHiddenKey(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 2
+ s.Create("/_foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
+ w, _ := s.Watch("/_foo", false, false, 0)
+ s.Delete("/_foo", false, false)
+ e := nbselect(w.EventChan())
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "delete")
+ testutil.AssertEqual(t, e.Node.Key, "/_foo")
+ e = nbselect(w.EventChan())
+ testutil.AssertNil(t, e)
+}
+
+// Ensure that the store doesn't see hidden key deletes without an exact path match in recursive mode.
+func TestStoreWatchRecursiveDeleteWithHiddenKey(t *testing.T) {
+ s := newStore()
+ s.Create("/foo/_bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent})
+ w, _ := s.Watch("/foo", true, false, 0)
+ s.Delete("/foo/_bar", false, false)
+ e := nbselect(w.EventChan())
+ testutil.AssertNil(t, e)
+}
+
+// Ensure that the store doesn't see expirations of hidden keys.
+func TestStoreWatchExpireWithHiddenKey(t *testing.T) {
+ s := newStore()
+ fc := newFakeClock()
+ s.clock = fc
+
+ s.Create("/_foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)})
+ s.Create("/foofoo", false, "barbarbar", false, TTLOptionSet{ExpireTime: fc.Now().Add(1000 * time.Millisecond)})
+
+ w, _ := s.Watch("/", true, false, 0)
+ c := w.EventChan()
+ e := nbselect(c)
+ testutil.AssertNil(t, e)
+ fc.Advance(600 * time.Millisecond)
+ s.DeleteExpiredKeys(fc.Now())
+ e = nbselect(c)
+ testutil.AssertNil(t, e)
+ fc.Advance(600 * time.Millisecond)
+ s.DeleteExpiredKeys(fc.Now())
+ e = nbselect(c)
+ testutil.AssertEqual(t, e.Action, "expire")
+ testutil.AssertEqual(t, e.Node.Key, "/foofoo")
+}
+
+// Ensure that the store does see hidden key creates if watching deeper than a hidden key in recursive mode.
+func TestStoreWatchRecursiveCreateDeeperThanHiddenKey(t *testing.T) {
+ s := newStore()
+ var eidx uint64 = 1
+ w, _ := s.Watch("/_foo/bar", true, false, 0)
+ s.Create("/_foo/bar/baz", false, "baz", false, TTLOptionSet{ExpireTime: Permanent})
+
+ e := nbselect(w.EventChan())
+ testutil.AssertNotNil(t, e)
+ testutil.AssertEqual(t, e.EtcdIndex, eidx)
+ testutil.AssertEqual(t, e.Action, "create")
+ testutil.AssertEqual(t, e.Node.Key, "/_foo/bar/baz")
+}
+
+// Ensure that slow consumers are handled properly.
+//
+// Since Watcher.EventChan() has a buffer of size 100 we can only queue 100
+// event per watcher. If the consumer cannot consume the event on time and
+// another event arrives, the channel is closed and event is discarded.
+// This test ensures that after closing the channel, the store can continue
+// to operate correctly.
+func TestStoreWatchSlowConsumer(t *testing.T) {
+ s := newStore()
+ s.Watch("/foo", true, true, 0) // stream must be true
+ // Fill watch channel with 100 events
+ for i := 1; i <= 100; i++ {
+ s.Set("/foo", false, string(i), TTLOptionSet{ExpireTime: Permanent}) // ok
+ }
+ testutil.AssertEqual(t, s.WatcherHub.count, int64(1))
+ s.Set("/foo", false, "101", TTLOptionSet{ExpireTime: Permanent}) // ok
+ // remove watcher
+ testutil.AssertEqual(t, s.WatcherHub.count, int64(0))
+ s.Set("/foo", false, "102", TTLOptionSet{ExpireTime: Permanent}) // must not panic
+}
+
+// Performs a non-blocking select on an event channel.
+func nbselect(c <-chan *Event) *Event {
+ select {
+ case e := <-c:
+ return e
+ default:
+ return nil
+ }
+}
+
+// newFakeClock creates a new FakeClock that has been advanced to at least minExpireTime
+func newFakeClock() clockwork.FakeClock {
+ fc := clockwork.NewFakeClock()
+ for minExpireTime.After(fc.Now()) {
+ fc.Advance((0x1 << 62) * time.Nanosecond)
+ }
+ return fc
+}
diff --git a/vendor/github.com/coreos/etcd/store/ttl_key_heap.go b/vendor/github.com/coreos/etcd/store/ttl_key_heap.go
new file mode 100644
index 00000000..21ae9b7c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/ttl_key_heap.go
@@ -0,0 +1,99 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "container/heap"
+)
+
+// An TTLKeyHeap is a min-heap of TTLKeys order by expiration time
+type ttlKeyHeap struct {
+ array []*node
+ keyMap map[*node]int
+}
+
+func newTtlKeyHeap() *ttlKeyHeap {
+ h := &ttlKeyHeap{keyMap: make(map[*node]int)}
+ heap.Init(h)
+ return h
+}
+
+func (h ttlKeyHeap) Len() int {
+ return len(h.array)
+}
+
+func (h ttlKeyHeap) Less(i, j int) bool {
+ return h.array[i].ExpireTime.Before(h.array[j].ExpireTime)
+}
+
+func (h ttlKeyHeap) Swap(i, j int) {
+ // swap node
+ h.array[i], h.array[j] = h.array[j], h.array[i]
+
+ // update map
+ h.keyMap[h.array[i]] = i
+ h.keyMap[h.array[j]] = j
+}
+
+func (h *ttlKeyHeap) Push(x interface{}) {
+ n, _ := x.(*node)
+ h.keyMap[n] = len(h.array)
+ h.array = append(h.array, n)
+}
+
+func (h *ttlKeyHeap) Pop() interface{} {
+ old := h.array
+ n := len(old)
+ x := old[n-1]
+ // Set slice element to nil, so GC can recycle the node.
+ // This is due to golang GC doesn't support partial recycling:
+ // https://github.com/golang/go/issues/9618
+ old[n-1] = nil
+ h.array = old[0 : n-1]
+ delete(h.keyMap, x)
+ return x
+}
+
+func (h *ttlKeyHeap) top() *node {
+ if h.Len() != 0 {
+ return h.array[0]
+ }
+ return nil
+}
+
+func (h *ttlKeyHeap) pop() *node {
+ x := heap.Pop(h)
+ n, _ := x.(*node)
+ return n
+}
+
+func (h *ttlKeyHeap) push(x interface{}) {
+ heap.Push(h, x)
+}
+
+func (h *ttlKeyHeap) update(n *node) {
+ index, ok := h.keyMap[n]
+ if ok {
+ heap.Remove(h, index)
+ heap.Push(h, n)
+ }
+}
+
+func (h *ttlKeyHeap) remove(n *node) {
+ index, ok := h.keyMap[n]
+ if ok {
+ heap.Remove(h, index)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/store/watcher.go b/vendor/github.com/coreos/etcd/store/watcher.go
new file mode 100644
index 00000000..a236ec77
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/watcher.go
@@ -0,0 +1,95 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+type Watcher interface {
+ EventChan() chan *Event
+ StartIndex() uint64 // The EtcdIndex at which the Watcher was created
+ Remove()
+}
+
+type watcher struct {
+ eventChan chan *Event
+ stream bool
+ recursive bool
+ sinceIndex uint64
+ startIndex uint64
+ hub *watcherHub
+ removed bool
+ remove func()
+}
+
+func (w *watcher) EventChan() chan *Event {
+ return w.eventChan
+}
+
+func (w *watcher) StartIndex() uint64 {
+ return w.startIndex
+}
+
+// notify function notifies the watcher. If the watcher interests in the given path,
+// the function will return true.
+func (w *watcher) notify(e *Event, originalPath bool, deleted bool) bool {
+ // watcher is interested the path in three cases and under one condition
+ // the condition is that the event happens after the watcher's sinceIndex
+
+ // 1. the path at which the event happens is the path the watcher is watching at.
+ // For example if the watcher is watching at "/foo" and the event happens at "/foo",
+ // the watcher must be interested in that event.
+
+ // 2. the watcher is a recursive watcher, it interests in the event happens after
+ // its watching path. For example if watcher A watches at "/foo" and it is a recursive
+ // one, it will interest in the event happens at "/foo/bar".
+
+ // 3. when we delete a directory, we need to force notify all the watchers who watches
+ // at the file we need to delete.
+ // For example a watcher is watching at "/foo/bar". And we deletes "/foo". The watcher
+ // should get notified even if "/foo" is not the path it is watching.
+ if (w.recursive || originalPath || deleted) && e.Index() >= w.sinceIndex {
+ // We cannot block here if the eventChan capacity is full, otherwise
+ // etcd will hang. eventChan capacity is full when the rate of
+ // notifications are higher than our send rate.
+ // If this happens, we close the channel.
+ select {
+ case w.eventChan <- e:
+ default:
+ // We have missed a notification. Remove the watcher.
+ // Removing the watcher also closes the eventChan.
+ w.remove()
+ }
+ return true
+ }
+ return false
+}
+
+// Remove removes the watcher from watcherHub
+// The actual remove function is guaranteed to only be executed once
+func (w *watcher) Remove() {
+ w.hub.mutex.Lock()
+ defer w.hub.mutex.Unlock()
+
+ close(w.eventChan)
+ if w.remove != nil {
+ w.remove()
+ }
+}
+
+// nopWatcher is a watcher that receives nothing, always blocking.
+type nopWatcher struct{}
+
+func NewNopWatcher() Watcher { return &nopWatcher{} }
+func (w *nopWatcher) EventChan() chan *Event { return nil }
+func (w *nopWatcher) StartIndex() uint64 { return 0 }
+func (w *nopWatcher) Remove() {}
diff --git a/vendor/github.com/coreos/etcd/store/watcher_hub.go b/vendor/github.com/coreos/etcd/store/watcher_hub.go
new file mode 100644
index 00000000..13c23e39
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/watcher_hub.go
@@ -0,0 +1,200 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "container/list"
+ "path"
+ "strings"
+ "sync"
+ "sync/atomic"
+
+ etcdErr "github.com/coreos/etcd/error"
+)
+
+// A watcherHub contains all subscribed watchers
+// watchers is a map with watched path as key and watcher as value
+// EventHistory keeps the old events for watcherHub. It is used to help
+// watcher to get a continuous event history. Or a watcher might miss the
+// event happens between the end of the first watch command and the start
+// of the second command.
+type watcherHub struct {
+ // count must be the first element to keep 64-bit alignment for atomic
+ // access
+
+ count int64 // current number of watchers.
+
+ mutex sync.Mutex
+ watchers map[string]*list.List
+ EventHistory *EventHistory
+}
+
+// newWatchHub creates a watcherHub. The capacity determines how many events we will
+// keep in the eventHistory.
+// Typically, we only need to keep a small size of history[smaller than 20K].
+// Ideally, it should smaller than 20K/s[max throughput] * 2 * 50ms[RTT] = 2000
+func newWatchHub(capacity int) *watcherHub {
+ return &watcherHub{
+ watchers: make(map[string]*list.List),
+ EventHistory: newEventHistory(capacity),
+ }
+}
+
+// Watch function returns a Watcher.
+// If recursive is true, the first change after index under key will be sent to the event channel of the watcher.
+// If recursive is false, the first change after index at key will be sent to the event channel of the watcher.
+// If index is zero, watch will start from the current index + 1.
+func (wh *watcherHub) watch(key string, recursive, stream bool, index, storeIndex uint64) (Watcher, *etcdErr.Error) {
+ reportWatchRequest()
+ event, err := wh.EventHistory.scan(key, recursive, index)
+
+ if err != nil {
+ err.Index = storeIndex
+ return nil, err
+ }
+
+ w := &watcher{
+ eventChan: make(chan *Event, 100), // use a buffered channel
+ recursive: recursive,
+ stream: stream,
+ sinceIndex: index,
+ startIndex: storeIndex,
+ hub: wh,
+ }
+
+ wh.mutex.Lock()
+ defer wh.mutex.Unlock()
+ // If the event exists in the known history, append the EtcdIndex and return immediately
+ if event != nil {
+ ne := event.Clone()
+ ne.EtcdIndex = storeIndex
+ w.eventChan <- ne
+ return w, nil
+ }
+
+ l, ok := wh.watchers[key]
+
+ var elem *list.Element
+
+ if ok { // add the new watcher to the back of the list
+ elem = l.PushBack(w)
+ } else { // create a new list and add the new watcher
+ l = list.New()
+ elem = l.PushBack(w)
+ wh.watchers[key] = l
+ }
+
+ w.remove = func() {
+ if w.removed { // avoid removing it twice
+ return
+ }
+ w.removed = true
+ l.Remove(elem)
+ atomic.AddInt64(&wh.count, -1)
+ reportWatcherRemoved()
+ if l.Len() == 0 {
+ delete(wh.watchers, key)
+ }
+ }
+
+ atomic.AddInt64(&wh.count, 1)
+ reportWatcherAdded()
+
+ return w, nil
+}
+
+func (wh *watcherHub) add(e *Event) {
+ wh.EventHistory.addEvent(e)
+}
+
+// notify function accepts an event and notify to the watchers.
+func (wh *watcherHub) notify(e *Event) {
+ e = wh.EventHistory.addEvent(e) // add event into the eventHistory
+
+ segments := strings.Split(e.Node.Key, "/")
+
+ currPath := "/"
+
+ // walk through all the segments of the path and notify the watchers
+ // if the path is "/foo/bar", it will notify watchers with path "/",
+ // "/foo" and "/foo/bar"
+
+ for _, segment := range segments {
+ currPath = path.Join(currPath, segment)
+ // notify the watchers who interests in the changes of current path
+ wh.notifyWatchers(e, currPath, false)
+ }
+}
+
+func (wh *watcherHub) notifyWatchers(e *Event, nodePath string, deleted bool) {
+ wh.mutex.Lock()
+ defer wh.mutex.Unlock()
+
+ l, ok := wh.watchers[nodePath]
+ if ok {
+ curr := l.Front()
+
+ for curr != nil {
+ next := curr.Next() // save reference to the next one in the list
+
+ w, _ := curr.Value.(*watcher)
+
+ originalPath := (e.Node.Key == nodePath)
+ if (originalPath || !isHidden(nodePath, e.Node.Key)) && w.notify(e, originalPath, deleted) {
+ if !w.stream { // do not remove the stream watcher
+ // if we successfully notify a watcher
+ // we need to remove the watcher from the list
+ // and decrease the counter
+ w.removed = true
+ l.Remove(curr)
+ atomic.AddInt64(&wh.count, -1)
+ reportWatcherRemoved()
+ }
+ }
+
+ curr = next // update current to the next element in the list
+ }
+
+ if l.Len() == 0 {
+ // if we have notified all watcher in the list
+ // we can delete the list
+ delete(wh.watchers, nodePath)
+ }
+ }
+}
+
+// clone function clones the watcherHub and return the cloned one.
+// only clone the static content. do not clone the current watchers.
+func (wh *watcherHub) clone() *watcherHub {
+ clonedHistory := wh.EventHistory.clone()
+
+ return &watcherHub{
+ EventHistory: clonedHistory,
+ }
+}
+
+// isHidden checks to see if key path is considered hidden to watch path i.e. the
+// last element is hidden or it's within a hidden directory
+func isHidden(watchPath, keyPath string) bool {
+ // When deleting a directory, watchPath might be deeper than the actual keyPath
+ // For example, when deleting /foo we also need to notify watchers on /foo/bar.
+ if len(watchPath) > len(keyPath) {
+ return false
+ }
+ // if watch path is just a "/", after path will start without "/"
+ // add a "/" to deal with the special case when watchPath is "/"
+ afterPath := path.Clean("/" + keyPath[len(watchPath):])
+ return strings.Contains(afterPath, "/_")
+}
diff --git a/vendor/github.com/coreos/etcd/store/watcher_hub_test.go b/vendor/github.com/coreos/etcd/store/watcher_hub_test.go
new file mode 100644
index 00000000..314ff4f6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/watcher_hub_test.go
@@ -0,0 +1,66 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "testing"
+)
+
+// TestIsHidden tests isHidden functions.
+func TestIsHidden(t *testing.T) {
+ // watch at "/"
+ // key is "/_foo", hidden to "/"
+ // expected: hidden = true
+ watch := "/"
+ key := "/_foo"
+ hidden := isHidden(watch, key)
+ if !hidden {
+ t.Fatalf("%v should be hidden to %v\n", key, watch)
+ }
+
+ // watch at "/_foo"
+ // key is "/_foo", not hidden to "/_foo"
+ // expected: hidden = false
+ watch = "/_foo"
+ hidden = isHidden(watch, key)
+ if hidden {
+ t.Fatalf("%v should not be hidden to %v\n", key, watch)
+ }
+
+ // watch at "/_foo/"
+ // key is "/_foo/foo", not hidden to "/_foo"
+ key = "/_foo/foo"
+ hidden = isHidden(watch, key)
+ if hidden {
+ t.Fatalf("%v should not be hidden to %v\n", key, watch)
+ }
+
+ // watch at "/_foo/"
+ // key is "/_foo/_foo", hidden to "/_foo"
+ key = "/_foo/_foo"
+ hidden = isHidden(watch, key)
+ if !hidden {
+ t.Fatalf("%v should be hidden to %v\n", key, watch)
+ }
+
+ // watch at "/_foo/foo"
+ // key is "/_foo"
+ watch = "_foo/foo"
+ key = "/_foo/"
+ hidden = isHidden(watch, key)
+ if hidden {
+ t.Fatalf("%v should not be hidden to %v\n", key, watch)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/store/watcher_test.go b/vendor/github.com/coreos/etcd/store/watcher_test.go
new file mode 100644
index 00000000..f7344fa3
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/store/watcher_test.go
@@ -0,0 +1,92 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 store
+
+import (
+ "testing"
+)
+
+func TestWatcher(t *testing.T) {
+ s := newStore()
+ wh := s.WatcherHub
+ w, err := wh.watch("/foo", true, false, 1, 1)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ c := w.EventChan()
+
+ select {
+ case <-c:
+ t.Fatal("should not receive from channel before send the event")
+ default:
+ // do nothing
+ }
+
+ e := newEvent(Create, "/foo/bar", 1, 1)
+
+ wh.notify(e)
+
+ re := <-c
+
+ if e != re {
+ t.Fatal("recv != send")
+ }
+
+ w, _ = wh.watch("/foo", false, false, 2, 1)
+ c = w.EventChan()
+
+ e = newEvent(Create, "/foo/bar", 2, 2)
+
+ wh.notify(e)
+
+ select {
+ case re = <-c:
+ t.Fatal("should not receive from channel if not recursive ", re)
+ default:
+ // do nothing
+ }
+
+ e = newEvent(Create, "/foo", 3, 3)
+
+ wh.notify(e)
+
+ re = <-c
+
+ if e != re {
+ t.Fatal("recv != send")
+ }
+
+ // ensure we are doing exact matching rather than prefix matching
+ w, _ = wh.watch("/fo", true, false, 1, 1)
+ c = w.EventChan()
+
+ select {
+ case re = <-c:
+ t.Fatal("should not receive from channel:", re)
+ default:
+ // do nothing
+ }
+
+ e = newEvent(Create, "/fo/bar", 3, 3)
+
+ wh.notify(e)
+
+ re = <-c
+
+ if e != re {
+ t.Fatal("recv != send")
+ }
+
+}
diff --git a/vendor/github.com/coreos/etcd/test b/vendor/github.com/coreos/etcd/test
new file mode 100755
index 00000000..96ab3233
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/test
@@ -0,0 +1,454 @@
+#!/usr/bin/env bash
+#
+# Run all etcd tests
+# ./test
+# ./test -v
+#
+# Run tests for one package
+#
+# PKG=./wal ./test
+# PKG=snap ./test
+#
+# Run code coverage
+# COVERDIR must either be a absolute path or a relative path to the etcd root
+# COVERDIR=coverage PASSES="build_cov cov" ./test
+set -e
+
+source ./build
+
+# build before setting up test GOPATH
+if [[ "${PASSES}" == *"functional"* ]]; then
+ ./tools/functional-tester/build
+fi
+
+# build tests with vendored dependencies
+etcd_setup_gopath
+
+if [ -z "$PASSES" ]; then
+ PASSES="fmt bom dep compile build unit"
+fi
+
+USERPKG=${PKG:-}
+
+# Invoke ./cover for HTML output
+COVER=${COVER:-"-cover"}
+
+# Hack: gofmt ./ will recursively check the .git directory. So use *.go for gofmt.
+IGNORE_PKGS="(cmd/|etcdserverpb|rafttest|gopath.proto|v3lockpb|v3electionpb)"
+INTEGRATION_PKGS="(integration|e2e|contrib|functional-tester)"
+
+# all github.com/coreos/etcd/whatever pkgs that are not auto-generated / tools
+PKGS=`find . -name \*.go | while read a; do dirname $a; done | sort | uniq | egrep -v "$IGNORE_PKGS" | egrep -v "(tools/|contrib/|e2e|pb)" | sed "s|\.|${REPO_PATH}|g" | xargs echo`
+# pkg1,pkg2,pkg3
+PKGS_COMMA=${PKGS// /,}
+
+TEST_PKGS=`find . -name \*_test.go | while read a; do dirname $a; done | sort | uniq | egrep -v "$IGNORE_PKGS" | sed "s|\./||g"`
+FORMATTABLE=`find . -name \*.go | while read a; do echo "$(dirname $a)/*.go"; done | sort | uniq | egrep -v "$IGNORE_PKGS" | sed "s|\./||g"`
+TESTABLE_AND_FORMATTABLE=`echo "$TEST_PKGS" | egrep -v "$INTEGRATION_PKGS"`
+
+# check if user provided PKG override
+if [ -z "${USERPKG}" ]; then
+ TEST=$TESTABLE_AND_FORMATTABLE
+ FMT=$FORMATTABLE
+else
+ # strip out leading dotslashes and trailing slashes from PKG=./foo/
+ TEST=${USERPKG/#./}
+ TEST=${TEST/#\//}
+ TEST=${TEST/%\//}
+ # only run gofmt on packages provided by user
+ FMT="$TEST"
+fi
+
+# split TEST into an array and prepend REPO_PATH to each local package
+split=(${TEST// / })
+TEST=${split/#/${REPO_PATH}/}
+
+# TODO: 'client' pkg fails with gosimple from generated files
+# TODO: 'rafttest' is failing with unused
+STATIC_ANALYSIS_PATHS=`find . -name \*.go | while read a; do dirname $a; done | sort | uniq | egrep -v "$IGNORE_PKGS" | grep -v 'client'`
+
+if [ -z "$GOARCH" ]; then
+ GOARCH=$(go env GOARCH);
+fi
+
+
+# determine whether target supports race detection
+if [ "$GOARCH" == "amd64" ]; then
+ RACE="--race"
+fi
+
+function unit_pass {
+ echo "Running unit tests..."
+ # only -run=Test so examples can run in integration tests
+ go test -timeout 3m ${COVER} ${RACE} -cpu 1,2,4 -run=Test $@ ${TEST}
+}
+
+function integration_pass {
+ echo "Running integration tests..."
+ go test -timeout 15m -v -cpu 1,2,4 $@ ${REPO_PATH}/integration
+ go test -timeout 1m -v ${RACE} -cpu 1,2,4 $@ ${REPO_PATH}/client/integration
+ go test -timeout 10m -v ${RACE} -cpu 1,2,4 $@ ${REPO_PATH}/clientv3/integration
+ go test -timeout 1m -v -cpu 1,2,4 $@ ${REPO_PATH}/contrib/raftexample
+ go test -timeout 1m -v ${RACE} -cpu 1,2,4 -run=Example $@ ${TEST}
+}
+
+function functional_pass {
+ for a in 1 2 3; do
+ mkdir -p ./agent-$a
+ ./bin/etcd-agent -etcd-path ./bin/etcd -etcd-log-dir "./agent-$a" -port ":${a}9027" -use-root=false &
+ pid="$!"
+ agent_pids="${agent_pids} $pid"
+ done
+
+ for a in 1 2 3; do
+ echo "Waiting for 'etcd-agent' on ${a}9027..."
+ while ! nc -z localhost ${a}9027; do
+ sleep 1
+ done
+ done
+
+ echo "Starting 'etcd-tester'"
+ ./bin/etcd-tester \
+ -agent-endpoints "127.0.0.1:19027,127.0.0.1:29027,127.0.0.1:39027" \
+ -client-ports 12379,22379,32379 \
+ -peer-ports 12380,22380,32380 \
+ -limit 1 \
+ -schedule-cases "0 1 2 3 4 5" \
+ -exit-on-failure && echo "'etcd-tester' succeeded"
+ ETCD_TESTER_EXIT_CODE=$?
+ echo "ETCD_TESTER_EXIT_CODE:" ${ETCD_TESTER_EXIT_CODE}
+
+ echo "Waiting for processes to exit"
+ kill -s TERM ${agent_pids}
+ for a in ${agent_pids}; do wait $a || true; done
+ rm -rf ./agent-*
+
+ if [[ "${ETCD_TESTER_EXIT_CODE}" -ne "0" ]]; then
+ echo "FAIL with exit code" ${ETCD_TESTER_EXIT_CODE}
+ exit ${ETCD_TESTER_EXIT_CODE}
+ fi
+}
+
+function cov_pass {
+ echo "Running code coverage..."
+ # install gocovmerge before running code coverage from github.com/wadey/gocovmerge
+ # gocovmerge merges coverage files
+ if ! which gocovmerge >/dev/null; then
+ echo "gocovmerge not installed"
+ exit 255
+ fi
+
+ if [ -z "$COVERDIR" ]; then
+ echo "COVERDIR undeclared"
+ exit 255
+ fi
+
+ if [ ! -f "bin/etcd_test" ]; then
+ echo "etcd_test binary not found"
+ exit 255
+ fi
+
+ mkdir -p "$COVERDIR"
+
+ # run code coverage for unit and integration tests
+ GOCOVFLAGS="-covermode=set -coverpkg $PKGS_COMMA -v -timeout 15m"
+ failed=""
+ for t in `echo "${TEST_PKGS}" | egrep -v "(e2e|functional-tester)"`; do
+ tf=`echo $t | tr / _`
+ # cache package compilation data for faster repeated builds
+ go test $GOCOVFLAGS -i ${REPO_PATH}/$t || true
+ # uses -run=Test to skip examples because clientv3/ example tests will leak goroutines
+ go test $GOCOVFLAGS -run=Test -coverprofile "$COVERDIR/${tf}.coverprofile" ${REPO_PATH}/$t || failed="$failed $t"
+ done
+
+ # proxy tests
+ go test -tags cluster_proxy $GOCOVFLAGS -coverprofile "$COVERDIR/proxy_integration.coverprofile" ${REPO_PATH}/integration || failed="$failed proxy-integration"
+ go test -tags cluster_proxy $GOCOVFLAGS -coverprofile "$COVERDIR/proxy_clientv3.coverprofile" ${REPO_PATH}/clientv3/integration || failed="$failed proxy-clientv3/integration"
+
+ # run code coverage for e2e tests
+ # use 30m timeout because e2e coverage takes longer
+ # due to many tests cause etcd process to wait
+ # on leadership transfer timeout during gracefully shutdown
+ go test -tags cov -timeout 30m -v ${REPO_PATH}"/e2e" || failed="$failed e2e"
+
+ gocovmerge "$COVERDIR"/*.coverprofile >"$COVERDIR"/cover.out
+ # strip out generated files (using GNU-style sed)
+ sed --in-place '/generated.go/d' "$COVERDIR"/cover.out || true
+
+ # held failures to generate the full coverage file, now fail
+ if [ -n "$failed" ]; then
+ for f in $failed; do
+ echo FAIL $f
+ done
+ exit 255
+ fi
+}
+
+function e2e_pass {
+ echo "Running e2e tests..."
+ go test -timeout 15m -v -cpu 1,2,4 $@ ${REPO_PATH}/e2e
+}
+
+function integration_e2e_pass {
+ echo "Running integration and e2e tests..."
+
+ go test -timeout 15m -v -cpu 1,2,4 $@ ${REPO_PATH}/e2e &
+ e2epid="$!"
+ go test -timeout 15m -v -cpu 1,2,4 $@ ${REPO_PATH}/integration &
+ intpid="$!"
+ wait $e2epid
+ wait $intpid
+ go test -timeout 1m -v ${RACE} -cpu 1,2,4 $@ ${REPO_PATH}/client/integration
+ go test -timeout 10m -v ${RACE} -cpu 1,2,4 $@ ${REPO_PATH}/clientv3/integration
+ go test -timeout 1m -v -cpu 1,2,4 $@ ${REPO_PATH}/contrib/raftexample
+ go test -timeout 1m -v ${RACE} -cpu 1,2,4 -run=Example $@ ${TEST}
+}
+
+function grpcproxy_pass {
+ go test -timeout 15m -v ${RACE} -tags cluster_proxy -cpu 1,2,4 $@ ${REPO_PATH}/integration
+ go test -timeout 15m -v ${RACE} -tags cluster_proxy -cpu 1,2,4 $@ ${REPO_PATH}/clientv3/integration
+}
+
+function release_pass {
+ rm -f ./bin/etcd-last-release
+ # to grab latest patch release; bump this up for every minor release
+ UPGRADE_VER=$(git tag -l --sort=-version:refname "v3.2.*" | head -1)
+ if [ -n "$MANUAL_VER" ]; then
+ # in case, we need to test against different version
+ UPGRADE_VER=$MANUAL_VER
+ fi
+ if [[ -z ${UPGRADE_VER} ]]; then
+ UPGRADE_VER="v3.2.0"
+ echo "fallback to" ${UPGRADE_VER}
+ fi
+
+ local file="etcd-$UPGRADE_VER-linux-$GOARCH.tar.gz"
+ echo "Downloading $file"
+
+ set +e
+ curl --fail -L https://github.com/coreos/etcd/releases/download/$UPGRADE_VER/$file -o /tmp/$file
+ local result=$?
+ set -e
+ case $result in
+ 0) ;;
+ *) echo "FAIL with" ${result}
+ exit $result
+ ;;
+ esac
+
+ tar xzvf /tmp/$file -C /tmp/ --strip-components=1
+ mkdir -p ./bin
+ mv /tmp/etcd ./bin/etcd-last-release
+}
+
+function fmt_pass {
+ toggle_failpoints disable
+
+ echo "Checking gofmt..."
+ fmtRes=$(gofmt -l -s -d $FMT)
+ if [ -n "${fmtRes}" ]; then
+ echo -e "gofmt checking failed:\n${fmtRes}"
+ exit 255
+ fi
+
+ echo "Checking govet..."
+ vetRes=$(go vet $TEST)
+ if [ -n "${vetRes}" ]; then
+ echo -e "govet checking failed:\n${vetRes}"
+ exit 255
+ fi
+
+ echo "Checking 'go tool vet -all -shadow'..."
+ fmtpkgs=$(echo $FMT | xargs dirname | sort | uniq | sed '/\./d')
+ vetRes=$(go tool vet -all -shadow ${fmtpkgs} 2>&1 | grep -v '/gw/' || true)
+ if [ -n "${vetRes}" ]; then
+ echo -e "govet -all -shadow checking failed:\n${vetRes}"
+ exit 255
+ fi
+
+ if which shellcheck >/dev/null; then
+ echo "Checking shellcheck..."
+ shellcheckResult=$(shellcheck -fgcc build test scripts/* 2>&1 || true)
+ if [ -n "${shellcheckResult}" ]; then
+ # mask the most common ones; fix later
+ SHELLCHECK_MASK="SC(2086|2006|2068|2196|2035|2162|2076)"
+ errs=$(echo "${shellcheckResult}" | egrep -v "${SHELLCHECK_MASK}" || true)
+ if [ -n "${errs}" ]; then
+ echo -e "shellcheck checking failed:\n${shellcheckResult}\n===\nFailed:\n${errs}"
+ exit 255
+ fi
+ suppressed=$(echo "${shellcheckResult}" | cut -f4- -d':' | sort | uniq -c | sort -n)
+ echo -e "shellcheck suppressed warnings:\n${suppressed}"
+ fi
+ fi
+
+ echo "Checking documentation style..."
+ # eschew you
+ yous=`find . -name \*.md -exec egrep --color "[Yy]ou[r]?[ '.,;]" {} + | grep -v /v2/ || true`
+ if [ ! -z "$yous" ]; then
+ echo -e "found 'you' in documentation:\n${yous}"
+ exit 255
+ fi
+
+ # TODO: check other markdown files when marker handles headers with '[]'
+ if which marker >/dev/null; then
+ echo "Checking marker to find broken links..."
+ markerResult=`marker --skip-http --root ./Documentation 2>&1 || true`
+ if [ -n "${markerResult}" ]; then
+ echo -e "marker checking failed:\n${markerResult}"
+ exit 255
+ fi
+ else
+ echo "Skipping marker..."
+ fi
+
+ if which goword >/dev/null; then
+ echo "Checking goword..."
+ # get all go files to process
+ gofiles=`find $FMT -iname '*.go' 2>/dev/null`
+ # ignore tests and protobuf files
+ gofiles=`echo ${gofiles} | sort | uniq | sed "s/ /\n/g" | egrep -v "(\\_test.go|\\.pb\\.go)"`
+ # only check for broken exported godocs
+ gowordRes=`goword -use-spell=false ${gofiles} | grep godoc-export | sort`
+ if [ ! -z "$gowordRes" ]; then
+ echo -e "goword checking failed:\n${gowordRes}"
+ exit 255
+ fi
+ else
+ echo "Skipping goword..."
+ fi
+
+ if which gosimple >/dev/null; then
+ echo "Checking gosimple..."
+ gosimpleResult=`gosimple ${STATIC_ANALYSIS_PATHS} 2>&1 || true`
+ if [ -n "${gosimpleResult}" ]; then
+ # TODO: resolve these after go1.8 migration
+ SIMPLE_CHECK_MASK="S(1024)"
+ if echo "${gosimpleResult}" | egrep -v "$SIMPLE_CHECK_MASK"; then
+ echo -e "gosimple checking failed:\n${gosimpleResult}"
+ exit 255
+ else
+ echo -e "gosimple warning:\n${gosimpleResult}"
+ fi
+ fi
+ else
+ echo "Skipping gosimple..."
+ fi
+
+ if which unused >/dev/null; then
+ echo "Checking unused..."
+ unusedResult=`unused ${STATIC_ANALYSIS_PATHS} 2>&1 || true`
+ if [ -n "${unusedResult}" ]; then
+ echo -e "unused checking failed:\n${unusedResult}"
+ exit 255
+ fi
+ else
+ echo "Skipping unused..."
+ fi
+
+ if which staticcheck >/dev/null; then
+ echo "Checking staticcheck..."
+ staticcheckResult=`staticcheck ${STATIC_ANALYSIS_PATHS} 2>&1 || true`
+ if [ -n "${staticcheckResult}" ]; then
+ # TODO: resolve these after go1.8 migration
+ # See https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck
+ STATIC_CHECK_MASK="SA(1019|2002)"
+ if echo "${staticcheckResult}" | egrep -v "$STATIC_CHECK_MASK"; then
+ echo -e "staticcheck checking failed:\n${staticcheckResult}"
+ exit 255
+ else
+ suppressed=`echo "${staticcheckResult}" | sed 's/ /\n/g' | grep "(SA" | sort | uniq -c`
+ echo -e "staticcheck suppressed warnings:\n${suppressed}"
+ fi
+ fi
+ else
+ echo "Skipping staticcheck..."
+ fi
+
+ echo "Checking for license header..."
+ licRes=""
+ files=$(find . -type f -iname '*.go' ! -path './cmd/*' ! -path './gopath.proto/*')
+ for file in $files; do
+ if ! head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED)" ; then
+ licRes="${licRes}"$(echo -e " ${file}")
+ fi
+ done
+ if [ -n "${licRes}" ]; then
+ echo -e "license header checking failed:\n${licRes}"
+ exit 255
+ fi
+
+ echo "Checking commit titles..."
+ git log --oneline "$(git merge-base HEAD master)"...HEAD | while read l; do
+ commitMsg=`echo "$l" | cut -f2- -d' '`
+ if [[ "$commitMsg" == Merge* ]]; then
+ # ignore "Merge pull" commits
+ continue
+ fi
+ if [[ "$commitMsg" == Revert* ]]; then
+ # ignore revert commits
+ continue
+ fi
+
+ pkgPrefix=`echo "$commitMsg" | cut -f1 -d':'`
+ spaceCommas=`echo "$commitMsg" | sed 's/ /\n/g' | grep -c ',$' || echo 0`
+ commaSpaces=`echo "$commitMsg" | sed 's/,/\n/g' | grep -c '^ ' || echo 0`
+ if [[ `echo $commitMsg | grep -c ":..*"` == 0 || "$commitMsg" == "$pkgPrefix" || "$spaceCommas" != "$commaSpaces" ]]; then
+ echo "$l"...
+ echo "Expected commit title format '<package>{\", \"<package>}: <description>'"
+ echo "Got: $l"
+ exit 255
+ fi
+ done
+}
+
+function bom_pass {
+ if ! which license-bill-of-materials >/dev/null; then
+ return
+ fi
+ echo "Checking bill of materials..."
+ license-bill-of-materials \
+ --override-file bill-of-materials.override.json \
+ github.com/coreos/etcd github.com/coreos/etcd/etcdctl >bom-now.json || true
+ if ! diff bill-of-materials.json bom-now.json; then
+ echo "vendored licenses do not match given bill of materials"
+ exit 255
+ fi
+ rm bom-now.json
+}
+
+function dep_pass {
+ echo "Checking package dependencies..."
+ # don't pull in etcdserver package
+ pushd clientv3 >/dev/null
+ badpkg="(etcdserver$|mvcc$|backend$|grpc-gateway)"
+ deps=`go list -f '{{ .Deps }}' | sed 's/ /\n/g' | egrep "${badpkg}" || echo ""`
+ popd >/dev/null
+ if [ ! -z "$deps" ]; then
+ echo -e "clientv3 has masked dependencies:\n${deps}"
+ exit 255
+ fi
+}
+
+function build_cov_pass {
+ out="bin"
+ if [ -n "${BINDIR}" ]; then out="${BINDIR}"; fi
+ go test -tags cov -c -covermode=set -coverpkg=$PKGS_COMMA -o ${out}/etcd_test
+ go test -tags cov -c -covermode=set -coverpkg=$PKGS_COMMA -o ${out}/etcdctl_test ${REPO_PATH}/etcdctl
+}
+
+function compile_pass {
+ echo "Checking build..."
+ go build -v ./tools/...
+}
+
+# fail fast on static tests
+function build_pass {
+ GO_BUILD_FLAGS="-a -v" etcd_build
+}
+
+for pass in $PASSES; do
+ ${pass}_pass $@
+done
+
+echo "Success"
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/.gitignore b/vendor/github.com/coreos/etcd/tools/benchmark/.gitignore
new file mode 100644
index 00000000..d83a1b2f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/.gitignore
@@ -0,0 +1 @@
+benchmark
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/cmd/doc.go b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/doc.go
new file mode 100644
index 00000000..962f5c7c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 cmd implements individual benchmark commands for the benchmark utility.
+package cmd
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/cmd/lease.go b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/lease.go
new file mode 100644
index 00000000..8743ed27
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/lease.go
@@ -0,0 +1,85 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 cmd
+
+import (
+ "fmt"
+ "time"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/pkg/report"
+
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+ "gopkg.in/cheggaaa/pb.v1"
+)
+
+var leaseKeepaliveCmd = &cobra.Command{
+ Use: "lease-keepalive",
+ Short: "Benchmark lease keepalive",
+
+ Run: leaseKeepaliveFunc,
+}
+
+var (
+ leaseKeepaliveTotal int
+)
+
+func init() {
+ RootCmd.AddCommand(leaseKeepaliveCmd)
+ leaseKeepaliveCmd.Flags().IntVar(&leaseKeepaliveTotal, "total", 10000, "Total number of lease keepalive requests")
+}
+
+func leaseKeepaliveFunc(cmd *cobra.Command, args []string) {
+ requests := make(chan struct{})
+ clients := mustCreateClients(totalClients, totalConns)
+
+ bar = pb.New(leaseKeepaliveTotal)
+ bar.Format("Bom !")
+ bar.Start()
+
+ r := newReport()
+ for i := range clients {
+ wg.Add(1)
+ go func(c v3.Lease) {
+ defer wg.Done()
+ resp, err := c.Grant(context.Background(), 100)
+ if err != nil {
+ panic(err)
+ }
+ for range requests {
+ st := time.Now()
+ _, err := c.KeepAliveOnce(context.TODO(), resp.ID)
+ r.Results() <- report.Result{Err: err, Start: st, End: time.Now()}
+ bar.Increment()
+ }
+ }(clients[i])
+ }
+
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ for i := 0; i < leaseKeepaliveTotal; i++ {
+ requests <- struct{}{}
+ }
+ close(requests)
+ }()
+
+ rc := r.Run()
+ wg.Wait()
+ close(r.Results())
+ bar.Finish()
+ fmt.Printf("%s", <-rc)
+}
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/cmd/mvcc-put.go b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/mvcc-put.go
new file mode 100644
index 00000000..bebb13d8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/mvcc-put.go
@@ -0,0 +1,123 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 cmd
+
+import (
+ "crypto/rand"
+ "fmt"
+ "os"
+ "runtime/pprof"
+ "time"
+
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/pkg/report"
+
+ "github.com/spf13/cobra"
+)
+
+// mvccPutCmd represents a storage put performance benchmarking tool
+var mvccPutCmd = &cobra.Command{
+ Use: "put",
+ Short: "Benchmark put performance of storage",
+
+ Run: mvccPutFunc,
+}
+
+var (
+ totalNrKeys int
+ storageKeySize int
+ valueSize int
+ txn bool
+)
+
+func init() {
+ mvccCmd.AddCommand(mvccPutCmd)
+
+ mvccPutCmd.Flags().IntVar(&totalNrKeys, "total", 100, "a total number of keys to put")
+ mvccPutCmd.Flags().IntVar(&storageKeySize, "key-size", 64, "a size of key (Byte)")
+ mvccPutCmd.Flags().IntVar(&valueSize, "value-size", 64, "a size of value (Byte)")
+ mvccPutCmd.Flags().BoolVar(&txn, "txn", false, "put a key in transaction or not")
+
+ // TODO: after the PR https://github.com/spf13/cobra/pull/220 is merged, the below pprof related flags should be moved to RootCmd
+ mvccPutCmd.Flags().StringVar(&cpuProfPath, "cpuprofile", "", "the path of file for storing cpu profile result")
+ mvccPutCmd.Flags().StringVar(&memProfPath, "memprofile", "", "the path of file for storing heap profile result")
+
+}
+
+func createBytesSlice(bytesN, sliceN int) [][]byte {
+ rs := make([][]byte, sliceN)
+ for i := range rs {
+ rs[i] = make([]byte, bytesN)
+ if _, err := rand.Read(rs[i]); err != nil {
+ panic(err)
+ }
+ }
+ return rs
+}
+
+func mvccPutFunc(cmd *cobra.Command, args []string) {
+ if cpuProfPath != "" {
+ f, err := os.Create(cpuProfPath)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, "Failed to create a file for storing cpu profile result: ", err)
+ os.Exit(1)
+ }
+
+ err = pprof.StartCPUProfile(f)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, "Failed to start cpu profile: ", err)
+ os.Exit(1)
+ }
+ defer pprof.StopCPUProfile()
+ }
+
+ if memProfPath != "" {
+ f, err := os.Create(memProfPath)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, "Failed to create a file for storing heap profile result: ", err)
+ os.Exit(1)
+ }
+
+ defer func() {
+ err := pprof.WriteHeapProfile(f)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, "Failed to write heap profile result: ", err)
+ // can do nothing for handling the error
+ }
+ }()
+ }
+
+ keys := createBytesSlice(storageKeySize, totalNrKeys)
+ vals := createBytesSlice(valueSize, totalNrKeys)
+
+ r := newReport()
+ rrc := r.Results()
+
+ rc := r.Run()
+ for i := 0; i < totalNrKeys; i++ {
+ st := time.Now()
+ if txn {
+ tw := s.Write()
+ tw.Put(keys[i], vals[i], lease.NoLease)
+ tw.End()
+ } else {
+ s.Put(keys[i], vals[i], lease.NoLease)
+ }
+ rrc <- report.Result{Start: st, End: time.Now()}
+ }
+
+ close(r.Results())
+ fmt.Printf("%s", <-rc)
+}
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/cmd/mvcc.go b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/mvcc.go
new file mode 100644
index 00000000..446ffed5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/mvcc.go
@@ -0,0 +1,61 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 cmd
+
+import (
+ "os"
+ "time"
+
+ "github.com/coreos/etcd/lease"
+ "github.com/coreos/etcd/mvcc"
+ "github.com/coreos/etcd/mvcc/backend"
+ "github.com/spf13/cobra"
+)
+
+var (
+ batchInterval int
+ batchLimit int
+
+ s mvcc.KV
+)
+
+func initMVCC() {
+ bcfg := backend.DefaultBackendConfig()
+ bcfg.Path, bcfg.BatchInterval, bcfg.BatchLimit = "mvcc-bench", time.Duration(batchInterval)*time.Millisecond, batchLimit
+ be := backend.New(bcfg)
+ s = mvcc.NewStore(be, &lease.FakeLessor{}, nil)
+ os.Remove("mvcc-bench") // boltDB has an opened fd, so removing the file is ok
+}
+
+// mvccCmd represents the MVCC storage benchmarking tools
+var mvccCmd = &cobra.Command{
+ Use: "mvcc",
+ Short: "Benchmark mvcc",
+ Long: `storage subcommand is a set of various benchmark tools for MVCC storage subsystem of etcd.
+Actual benchmarks are implemented as its subcommands.`,
+
+ PersistentPreRun: mvccPreRun,
+}
+
+func init() {
+ RootCmd.AddCommand(mvccCmd)
+
+ mvccCmd.PersistentFlags().IntVar(&batchInterval, "batch-interval", 100, "Interval of batching (milliseconds)")
+ mvccCmd.PersistentFlags().IntVar(&batchLimit, "batch-limit", 10000, "A limit of batched transaction")
+}
+
+func mvccPreRun(cmd *cobra.Command, args []string) {
+ initMVCC()
+}
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/cmd/put.go b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/put.go
new file mode 100644
index 00000000..760c032e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/put.go
@@ -0,0 +1,152 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 cmd
+
+import (
+ "encoding/binary"
+ "fmt"
+ "math"
+ "math/rand"
+ "os"
+ "time"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/pkg/report"
+
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+ "golang.org/x/time/rate"
+ "gopkg.in/cheggaaa/pb.v1"
+)
+
+// putCmd represents the put command
+var putCmd = &cobra.Command{
+ Use: "put",
+ Short: "Benchmark put",
+
+ Run: putFunc,
+}
+
+var (
+ keySize int
+ valSize int
+
+ putTotal int
+ putRate int
+
+ keySpaceSize int
+ seqKeys bool
+
+ compactInterval time.Duration
+ compactIndexDelta int64
+)
+
+func init() {
+ RootCmd.AddCommand(putCmd)
+ putCmd.Flags().IntVar(&keySize, "key-size", 8, "Key size of put request")
+ putCmd.Flags().IntVar(&valSize, "val-size", 8, "Value size of put request")
+ putCmd.Flags().IntVar(&putRate, "rate", 0, "Maximum puts per second (0 is no limit)")
+
+ putCmd.Flags().IntVar(&putTotal, "total", 10000, "Total number of put requests")
+ putCmd.Flags().IntVar(&keySpaceSize, "key-space-size", 1, "Maximum possible keys")
+ putCmd.Flags().BoolVar(&seqKeys, "sequential-keys", false, "Use sequential keys")
+ putCmd.Flags().DurationVar(&compactInterval, "compact-interval", 0, `Interval to compact database (do not duplicate this with etcd's 'auto-compaction-retention' flag) (e.g. --compact-interval=5m compacts every 5-minute)`)
+ putCmd.Flags().Int64Var(&compactIndexDelta, "compact-index-delta", 1000, "Delta between current revision and compact revision (e.g. current revision 10000, compact at 9000)")
+}
+
+func putFunc(cmd *cobra.Command, args []string) {
+ if keySpaceSize <= 0 {
+ fmt.Fprintf(os.Stderr, "expected positive --key-space-size, got (%v)", keySpaceSize)
+ os.Exit(1)
+ }
+
+ requests := make(chan v3.Op, totalClients)
+ if putRate == 0 {
+ putRate = math.MaxInt32
+ }
+ limit := rate.NewLimiter(rate.Limit(putRate), 1)
+ clients := mustCreateClients(totalClients, totalConns)
+ k, v := make([]byte, keySize), string(mustRandBytes(valSize))
+
+ bar = pb.New(putTotal)
+ bar.Format("Bom !")
+ bar.Start()
+
+ r := newReport()
+ for i := range clients {
+ wg.Add(1)
+ go func(c *v3.Client) {
+ defer wg.Done()
+ for op := range requests {
+ limit.Wait(context.Background())
+
+ st := time.Now()
+ _, err := c.Do(context.Background(), op)
+ r.Results() <- report.Result{Err: err, Start: st, End: time.Now()}
+ bar.Increment()
+ }
+ }(clients[i])
+ }
+
+ go func() {
+ for i := 0; i < putTotal; i++ {
+ if seqKeys {
+ binary.PutVarint(k, int64(i%keySpaceSize))
+ } else {
+ binary.PutVarint(k, int64(rand.Intn(keySpaceSize)))
+ }
+ requests <- v3.OpPut(string(k), v)
+ }
+ close(requests)
+ }()
+
+ if compactInterval > 0 {
+ go func() {
+ for {
+ time.Sleep(compactInterval)
+ compactKV(clients)
+ }
+ }()
+ }
+
+ rc := r.Run()
+ wg.Wait()
+ close(r.Results())
+ bar.Finish()
+ fmt.Println(<-rc)
+}
+
+func compactKV(clients []*v3.Client) {
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ resp, err := clients[0].KV.Get(ctx, "foo")
+ cancel()
+ if err != nil {
+ panic(err)
+ }
+ revToCompact := max(0, resp.Header.Revision-compactIndexDelta)
+ ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
+ _, err = clients[0].KV.Compact(ctx, revToCompact)
+ cancel()
+ if err != nil {
+ panic(err)
+ }
+}
+
+func max(n1, n2 int64) int64 {
+ if n1 > n2 {
+ return n1
+ }
+ return n2
+}
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/cmd/range.go b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/range.go
new file mode 100644
index 00000000..1a83d221
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/range.go
@@ -0,0 +1,119 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 cmd
+
+import (
+ "fmt"
+ "math"
+ "os"
+ "time"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/pkg/report"
+
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+ "golang.org/x/time/rate"
+ "gopkg.in/cheggaaa/pb.v1"
+)
+
+// rangeCmd represents the range command
+var rangeCmd = &cobra.Command{
+ Use: "range key [end-range]",
+ Short: "Benchmark range",
+
+ Run: rangeFunc,
+}
+
+var (
+ rangeRate int
+ rangeTotal int
+ rangeConsistency string
+)
+
+func init() {
+ RootCmd.AddCommand(rangeCmd)
+ rangeCmd.Flags().IntVar(&rangeRate, "rate", 0, "Maximum range requests per second (0 is no limit)")
+ rangeCmd.Flags().IntVar(&rangeTotal, "total", 10000, "Total number of range requests")
+ rangeCmd.Flags().StringVar(&rangeConsistency, "consistency", "l", "Linearizable(l) or Serializable(s)")
+}
+
+func rangeFunc(cmd *cobra.Command, args []string) {
+ if len(args) == 0 || len(args) > 2 {
+ fmt.Fprintln(os.Stderr, cmd.Usage())
+ os.Exit(1)
+ }
+
+ k := args[0]
+ end := ""
+ if len(args) == 2 {
+ end = args[1]
+ }
+
+ if rangeConsistency == "l" {
+ fmt.Println("bench with linearizable range")
+ } else if rangeConsistency == "s" {
+ fmt.Println("bench with serializable range")
+ } else {
+ fmt.Fprintln(os.Stderr, cmd.Usage())
+ os.Exit(1)
+ }
+
+ if rangeRate == 0 {
+ rangeRate = math.MaxInt32
+ }
+ limit := rate.NewLimiter(rate.Limit(rangeRate), 1)
+
+ requests := make(chan v3.Op, totalClients)
+ clients := mustCreateClients(totalClients, totalConns)
+
+ bar = pb.New(rangeTotal)
+ bar.Format("Bom !")
+ bar.Start()
+
+ r := newReport()
+ for i := range clients {
+ wg.Add(1)
+ go func(c *v3.Client) {
+ defer wg.Done()
+ for op := range requests {
+ limit.Wait(context.Background())
+
+ st := time.Now()
+ _, err := c.Do(context.Background(), op)
+ r.Results() <- report.Result{Err: err, Start: st, End: time.Now()}
+ bar.Increment()
+ }
+ }(clients[i])
+ }
+
+ go func() {
+ for i := 0; i < rangeTotal; i++ {
+ opts := []v3.OpOption{v3.WithRange(end)}
+ if rangeConsistency == "s" {
+ opts = append(opts, v3.WithSerializable())
+ }
+ op := v3.OpGet(k, opts...)
+ requests <- op
+ }
+ close(requests)
+ }()
+
+ rc := r.Run()
+ wg.Wait()
+ close(r.Results())
+ bar.Finish()
+ fmt.Printf("%s", <-rc)
+}
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/cmd/root.go b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/root.go
new file mode 100644
index 00000000..6ac798f5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/root.go
@@ -0,0 +1,74 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 cmd
+
+import (
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/pkg/transport"
+
+ "github.com/spf13/cobra"
+ "gopkg.in/cheggaaa/pb.v1"
+)
+
+// This represents the base command when called without any subcommands
+var RootCmd = &cobra.Command{
+ Use: "benchmark",
+ Short: "A low-level benchmark tool for etcd3",
+ Long: `benchmark is a low-level benchmark tool for etcd3.
+It uses gRPC client directly and does not depend on
+etcd client library.
+ `,
+}
+
+var (
+ endpoints []string
+ totalConns uint
+ totalClients uint
+ precise bool
+ sample bool
+
+ bar *pb.ProgressBar
+ wg sync.WaitGroup
+
+ tls transport.TLSInfo
+
+ cpuProfPath string
+ memProfPath string
+
+ user string
+
+ dialTimeout time.Duration
+
+ targetLeader bool
+)
+
+func init() {
+ RootCmd.PersistentFlags().StringSliceVar(&endpoints, "endpoints", []string{"127.0.0.1:2379"}, "gRPC endpoints")
+ RootCmd.PersistentFlags().UintVar(&totalConns, "conns", 1, "Total number of gRPC connections")
+ RootCmd.PersistentFlags().UintVar(&totalClients, "clients", 1, "Total number of gRPC clients")
+
+ RootCmd.PersistentFlags().BoolVar(&precise, "precise", false, "use full floating point precision")
+ RootCmd.PersistentFlags().BoolVar(&sample, "sample", false, "'true' to sample requests for every second")
+ RootCmd.PersistentFlags().StringVar(&tls.CertFile, "cert", "", "identify HTTPS client using this SSL certificate file")
+ RootCmd.PersistentFlags().StringVar(&tls.KeyFile, "key", "", "identify HTTPS client using this SSL key file")
+ RootCmd.PersistentFlags().StringVar(&tls.CAFile, "cacert", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
+
+ RootCmd.PersistentFlags().StringVar(&user, "user", "", "specify username and password in username:password format")
+ RootCmd.PersistentFlags().DurationVar(&dialTimeout, "dial-timeout", 0, "dial timeout for client connections")
+
+ RootCmd.PersistentFlags().BoolVar(&targetLeader, "target-leader", false, "connect only to the leader node")
+}
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/cmd/stm.go b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/stm.go
new file mode 100644
index 00000000..5d0f6cc6
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/stm.go
@@ -0,0 +1,208 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 cmd
+
+import (
+ "encoding/binary"
+ "fmt"
+ "math"
+ "math/rand"
+ "os"
+ "time"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ v3sync "github.com/coreos/etcd/clientv3/concurrency"
+ "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb"
+ "github.com/coreos/etcd/pkg/report"
+
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+ "golang.org/x/time/rate"
+ "gopkg.in/cheggaaa/pb.v1"
+)
+
+// stmCmd represents the STM benchmark command
+var stmCmd = &cobra.Command{
+ Use: "stm",
+ Short: "Benchmark STM",
+
+ Run: stmFunc,
+}
+
+type stmApply func(v3sync.STM) error
+
+var (
+ stmIsolation string
+ stmIso v3sync.Isolation
+
+ stmTotal int
+ stmKeysPerTxn int
+ stmKeyCount int
+ stmValSize int
+ stmWritePercent int
+ stmLocker string
+ stmRate int
+)
+
+func init() {
+ RootCmd.AddCommand(stmCmd)
+
+ stmCmd.Flags().StringVar(&stmIsolation, "isolation", "r", "Read Committed (c), Repeatable Reads (r), Serializable (s), or Snapshot (ss)")
+ stmCmd.Flags().IntVar(&stmKeyCount, "keys", 1, "Total unique keys accessible by the benchmark")
+ stmCmd.Flags().IntVar(&stmTotal, "total", 10000, "Total number of completed STM transactions")
+ stmCmd.Flags().IntVar(&stmKeysPerTxn, "keys-per-txn", 1, "Number of keys to access per transaction")
+ stmCmd.Flags().IntVar(&stmWritePercent, "txn-wr-percent", 50, "Percentage of keys to overwrite per transaction")
+ stmCmd.Flags().StringVar(&stmLocker, "stm-locker", "stm", "Wrap STM transaction with a custom locking mechanism (stm, lock-client, lock-rpc)")
+ stmCmd.Flags().IntVar(&stmValSize, "val-size", 8, "Value size of each STM put request")
+ stmCmd.Flags().IntVar(&stmRate, "rate", 0, "Maximum STM transactions per second (0 is no limit)")
+}
+
+func stmFunc(cmd *cobra.Command, args []string) {
+ if stmKeyCount <= 0 {
+ fmt.Fprintf(os.Stderr, "expected positive --keys, got (%v)", stmKeyCount)
+ os.Exit(1)
+ }
+
+ if stmWritePercent < 0 || stmWritePercent > 100 {
+ fmt.Fprintf(os.Stderr, "expected [0, 100] --txn-wr-percent, got (%v)", stmWritePercent)
+ os.Exit(1)
+ }
+
+ if stmKeysPerTxn < 0 || stmKeysPerTxn > stmKeyCount {
+ fmt.Fprintf(os.Stderr, "expected --keys-per-txn between 0 and %v, got (%v)", stmKeyCount, stmKeysPerTxn)
+ os.Exit(1)
+ }
+
+ switch stmIsolation {
+ case "c":
+ stmIso = v3sync.ReadCommitted
+ case "r":
+ stmIso = v3sync.RepeatableReads
+ case "s":
+ stmIso = v3sync.Serializable
+ case "ss":
+ stmIso = v3sync.SerializableSnapshot
+ default:
+ fmt.Fprintln(os.Stderr, cmd.Usage())
+ os.Exit(1)
+ }
+
+ if stmRate == 0 {
+ stmRate = math.MaxInt32
+ }
+ limit := rate.NewLimiter(rate.Limit(stmRate), 1)
+
+ requests := make(chan stmApply, totalClients)
+ clients := mustCreateClients(totalClients, totalConns)
+
+ bar = pb.New(stmTotal)
+ bar.Format("Bom !")
+ bar.Start()
+
+ r := newReport()
+ for i := range clients {
+ wg.Add(1)
+ go doSTM(clients[i], requests, r.Results())
+ }
+
+ go func() {
+ for i := 0; i < stmTotal; i++ {
+ kset := make(map[string]struct{})
+ for len(kset) != stmKeysPerTxn {
+ k := make([]byte, 16)
+ binary.PutVarint(k, int64(rand.Intn(stmKeyCount)))
+ s := string(k)
+ kset[s] = struct{}{}
+ }
+
+ applyf := func(s v3sync.STM) error {
+ limit.Wait(context.Background())
+ wrs := int(float32(len(kset)*stmWritePercent) / 100.0)
+ for k := range kset {
+ s.Get(k)
+ if wrs > 0 {
+ s.Put(k, string(mustRandBytes(stmValSize)))
+ wrs--
+ }
+ }
+ return nil
+ }
+
+ requests <- applyf
+ }
+ close(requests)
+ }()
+
+ rc := r.Run()
+ wg.Wait()
+ close(r.Results())
+ bar.Finish()
+ fmt.Printf("%s", <-rc)
+}
+
+func doSTM(client *v3.Client, requests <-chan stmApply, results chan<- report.Result) {
+ defer wg.Done()
+
+ lock, unlock := func() error { return nil }, func() error { return nil }
+ switch stmLocker {
+ case "lock-client":
+ s, err := v3sync.NewSession(client)
+ if err != nil {
+ panic(err)
+ }
+ defer s.Close()
+ m := v3sync.NewMutex(s, "stmlock")
+ lock = func() error { return m.Lock(context.TODO()) }
+ unlock = func() error { return m.Unlock(context.TODO()) }
+ case "lock-rpc":
+ var lockKey []byte
+ s, err := v3sync.NewSession(client)
+ if err != nil {
+ panic(err)
+ }
+ defer s.Close()
+ lc := v3lockpb.NewLockClient(client.ActiveConnection())
+ lock = func() error {
+ req := &v3lockpb.LockRequest{Name: []byte("stmlock"), Lease: int64(s.Lease())}
+ resp, err := lc.Lock(context.TODO(), req)
+ if resp != nil {
+ lockKey = resp.Key
+ }
+ return err
+ }
+ unlock = func() error {
+ req := &v3lockpb.UnlockRequest{Key: lockKey}
+ _, err := lc.Unlock(context.TODO(), req)
+ return err
+ }
+ case "stm":
+ default:
+ fmt.Fprintf(os.Stderr, "unexpected stm locker %q\n", stmLocker)
+ os.Exit(1)
+ }
+
+ for applyf := range requests {
+ st := time.Now()
+ if lerr := lock(); lerr != nil {
+ panic(lerr)
+ }
+ _, err := v3sync.NewSTM(client, applyf, v3sync.WithIsolation(stmIso))
+ if lerr := unlock(); lerr != nil {
+ panic(lerr)
+ }
+ results <- report.Result{Err: err, Start: st, End: time.Now()}
+ bar.Increment()
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/cmd/txn_put.go b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/txn_put.go
new file mode 100644
index 00000000..c6a6c07f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/txn_put.go
@@ -0,0 +1,108 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 cmd
+
+import (
+ "encoding/binary"
+ "fmt"
+ "math"
+ "os"
+ "time"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/pkg/report"
+
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+ "golang.org/x/time/rate"
+ "gopkg.in/cheggaaa/pb.v1"
+)
+
+// txnPutCmd represents the txnPut command
+var txnPutCmd = &cobra.Command{
+ Use: "txn-put",
+ Short: "Benchmark txn-put",
+
+ Run: txnPutFunc,
+}
+
+var (
+ txnPutTotal int
+ txnPutRate int
+ txnPutOpsPerTxn int
+)
+
+func init() {
+ RootCmd.AddCommand(txnPutCmd)
+ txnPutCmd.Flags().IntVar(&keySize, "key-size", 8, "Key size of txn put")
+ txnPutCmd.Flags().IntVar(&valSize, "val-size", 8, "Value size of txn put")
+ txnPutCmd.Flags().IntVar(&txnPutOpsPerTxn, "txn-ops", 1, "Number of puts per txn")
+ txnPutCmd.Flags().IntVar(&txnPutRate, "rate", 0, "Maximum txns per second (0 is no limit)")
+
+ txnPutCmd.Flags().IntVar(&txnPutTotal, "total", 10000, "Total number of txn requests")
+ txnPutCmd.Flags().IntVar(&keySpaceSize, "key-space-size", 1, "Maximum possible keys")
+}
+
+func txnPutFunc(cmd *cobra.Command, args []string) {
+ if keySpaceSize <= 0 {
+ fmt.Fprintf(os.Stderr, "expected positive --key-space-size, got (%v)", keySpaceSize)
+ os.Exit(1)
+ }
+
+ requests := make(chan []v3.Op, totalClients)
+ if txnPutRate == 0 {
+ txnPutRate = math.MaxInt32
+ }
+ limit := rate.NewLimiter(rate.Limit(txnPutRate), 1)
+ clients := mustCreateClients(totalClients, totalConns)
+ k, v := make([]byte, keySize), string(mustRandBytes(valSize))
+
+ bar = pb.New(txnPutTotal)
+ bar.Format("Bom !")
+ bar.Start()
+
+ r := newReport()
+ for i := range clients {
+ wg.Add(1)
+ go func(c *v3.Client) {
+ defer wg.Done()
+ for ops := range requests {
+ limit.Wait(context.Background())
+ st := time.Now()
+ _, err := c.Txn(context.TODO()).Then(ops...).Commit()
+ r.Results() <- report.Result{Err: err, Start: st, End: time.Now()}
+ bar.Increment()
+ }
+ }(clients[i])
+ }
+
+ go func() {
+ for i := 0; i < txnPutTotal; i++ {
+ ops := make([]v3.Op, txnPutOpsPerTxn)
+ for j := 0; j < txnPutOpsPerTxn; j++ {
+ binary.PutVarint(k, int64(((i*txnPutOpsPerTxn)+j)%keySpaceSize))
+ ops[j] = v3.OpPut(string(k), v)
+ }
+ requests <- ops
+ }
+ close(requests)
+ }()
+
+ rc := r.Run()
+ wg.Wait()
+ close(r.Results())
+ bar.Finish()
+ fmt.Println(<-rc)
+}
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/cmd/util.go b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/util.go
new file mode 100644
index 00000000..a5872913
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/util.go
@@ -0,0 +1,143 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 cmd
+
+import (
+ "crypto/rand"
+ "fmt"
+ "log"
+ "os"
+ "strings"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/pkg/report"
+ "golang.org/x/net/context"
+)
+
+var (
+ // dialTotal counts the number of mustCreateConn calls so that endpoint
+ // connections can be handed out in round-robin order
+ dialTotal int
+
+ // leaderEps is a cache for holding endpoints of a leader node
+ leaderEps []string
+)
+
+func mustFindLeaderEndpoints(c *clientv3.Client) {
+ resp, lerr := c.MemberList(context.TODO())
+ if lerr != nil {
+ fmt.Fprintf(os.Stderr, "failed to get a member list: %s\n", lerr)
+ os.Exit(1)
+ }
+
+ leaderId := uint64(0)
+ for _, ep := range c.Endpoints() {
+ if sresp, serr := c.Status(context.TODO(), ep); serr == nil {
+ leaderId = sresp.Leader
+ break
+ }
+ }
+
+ for _, m := range resp.Members {
+ if m.ID == leaderId {
+ leaderEps = m.ClientURLs
+ return
+ }
+ }
+
+ fmt.Fprintf(os.Stderr, "failed to find a leader endpoint\n")
+ os.Exit(1)
+}
+
+func mustCreateConn() *clientv3.Client {
+ connEndpoints := leaderEps
+ if len(connEndpoints) == 0 {
+ connEndpoints = []string{endpoints[dialTotal%len(endpoints)]}
+ dialTotal++
+ }
+ cfg := clientv3.Config{
+ Endpoints: connEndpoints,
+ DialTimeout: dialTimeout,
+ }
+ if !tls.Empty() {
+ cfgtls, err := tls.ClientConfig()
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "bad tls config: %v\n", err)
+ os.Exit(1)
+ }
+ cfg.TLS = cfgtls
+ }
+
+ if len(user) != 0 {
+ splitted := strings.SplitN(user, ":", 2)
+ if len(splitted) != 2 {
+ fmt.Fprintf(os.Stderr, "bad user information: %s\n", user)
+ os.Exit(1)
+ }
+
+ cfg.Username = splitted[0]
+ cfg.Password = splitted[1]
+ }
+
+ client, err := clientv3.New(cfg)
+ if targetLeader && len(leaderEps) == 0 {
+ mustFindLeaderEndpoints(client)
+ client.Close()
+ return mustCreateConn()
+ }
+
+ clientv3.SetLogger(log.New(os.Stderr, "grpc", 0))
+
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "dial error: %v\n", err)
+ os.Exit(1)
+ }
+
+ return client
+}
+
+func mustCreateClients(totalClients, totalConns uint) []*clientv3.Client {
+ conns := make([]*clientv3.Client, totalConns)
+ for i := range conns {
+ conns[i] = mustCreateConn()
+ }
+
+ clients := make([]*clientv3.Client, totalClients)
+ for i := range clients {
+ clients[i] = conns[i%int(totalConns)]
+ }
+ return clients
+}
+
+func mustRandBytes(n int) []byte {
+ rb := make([]byte, n)
+ _, err := rand.Read(rb)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "failed to generate value: %v\n", err)
+ os.Exit(1)
+ }
+ return rb
+}
+
+func newReport() report.Report {
+ p := "%4.4f"
+ if precise {
+ p = "%g"
+ }
+ if sample {
+ return report.NewReportSample(p)
+ }
+ return report.NewReport(p)
+}
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/cmd/watch.go b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/watch.go
new file mode 100644
index 00000000..5b2f57fc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/watch.go
@@ -0,0 +1,247 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 cmd
+
+import (
+ "context"
+ "encoding/binary"
+ "fmt"
+ "math/rand"
+ "os"
+ "sync/atomic"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/pkg/report"
+
+ "github.com/spf13/cobra"
+ "golang.org/x/time/rate"
+ "gopkg.in/cheggaaa/pb.v1"
+)
+
+// watchCmd represents the watch command
+var watchCmd = &cobra.Command{
+ Use: "watch",
+ Short: "Benchmark watch",
+ Long: `Benchmark watch tests the performance of processing watch requests and
+sending events to watchers. It tests the sending performance by
+changing the value of the watched keys with concurrent put
+requests.
+
+During the test, each watcher watches (--total/--watchers) keys
+
+(a watcher might watch on the same key multiple times if
+--watched-key-total is small).
+
+Each key is watched by (--total/--watched-key-total) watchers.
+`,
+ Run: watchFunc,
+}
+
+var (
+ watchStreams int
+ watchWatchesPerStream int
+ watchedKeyTotal int
+
+ watchPutRate int
+ watchPutTotal int
+
+ watchKeySize int
+ watchKeySpaceSize int
+ watchSeqKeys bool
+)
+
+type watchedKeys struct {
+ watched []string
+ numWatchers map[string]int
+
+ watches []clientv3.WatchChan
+
+ // ctx to control all watches
+ ctx context.Context
+ cancel context.CancelFunc
+}
+
+func init() {
+ RootCmd.AddCommand(watchCmd)
+ watchCmd.Flags().IntVar(&watchStreams, "streams", 10, "Total watch streams")
+ watchCmd.Flags().IntVar(&watchWatchesPerStream, "watch-per-stream", 100, "Total watchers per stream")
+ watchCmd.Flags().IntVar(&watchedKeyTotal, "watched-key-total", 1, "Total number of keys to be watched")
+
+ watchCmd.Flags().IntVar(&watchPutRate, "put-rate", 0, "Number of keys to put per second")
+ watchCmd.Flags().IntVar(&watchPutTotal, "put-total", 1000, "Number of put requests")
+
+ watchCmd.Flags().IntVar(&watchKeySize, "key-size", 32, "Key size of watch request")
+ watchCmd.Flags().IntVar(&watchKeySpaceSize, "key-space-size", 1, "Maximum possible keys")
+ watchCmd.Flags().BoolVar(&watchSeqKeys, "sequential-keys", false, "Use sequential keys")
+}
+
+func watchFunc(cmd *cobra.Command, args []string) {
+ if watchKeySpaceSize <= 0 {
+ fmt.Fprintf(os.Stderr, "expected positive --key-space-size, got (%v)", watchKeySpaceSize)
+ os.Exit(1)
+ }
+ grpcConns := int(totalClients)
+ if totalClients > totalConns {
+ grpcConns = int(totalConns)
+ }
+ wantedConns := 1 + (watchStreams / 100)
+ if grpcConns < wantedConns {
+ fmt.Fprintf(os.Stderr, "warning: grpc limits 100 streams per client connection, have %d but need %d\n", grpcConns, wantedConns)
+ }
+ clients := mustCreateClients(totalClients, totalConns)
+ wk := newWatchedKeys()
+ benchMakeWatches(clients, wk)
+ benchPutWatches(clients, wk)
+}
+
+func benchMakeWatches(clients []*clientv3.Client, wk *watchedKeys) {
+ streams := make([]clientv3.Watcher, watchStreams)
+ for i := range streams {
+ streams[i] = clientv3.NewWatcher(clients[i%len(clients)])
+ }
+
+ keyc := make(chan string, watchStreams)
+ bar = pb.New(watchStreams * watchWatchesPerStream)
+ bar.Format("Bom !")
+ bar.Start()
+
+ r := newReport()
+ rch := r.Results()
+
+ wg.Add(len(streams) + 1)
+ wc := make(chan []clientv3.WatchChan, len(streams))
+ for _, s := range streams {
+ go func(s clientv3.Watcher) {
+ defer wg.Done()
+ var ws []clientv3.WatchChan
+ for i := 0; i < watchWatchesPerStream; i++ {
+ k := <-keyc
+ st := time.Now()
+ wch := s.Watch(wk.ctx, k)
+ rch <- report.Result{Start: st, End: time.Now()}
+ ws = append(ws, wch)
+ bar.Increment()
+ }
+ wc <- ws
+ }(s)
+ }
+ go func() {
+ defer func() {
+ close(keyc)
+ wg.Done()
+ }()
+ for i := 0; i < watchStreams*watchWatchesPerStream; i++ {
+ key := wk.watched[i%len(wk.watched)]
+ keyc <- key
+ wk.numWatchers[key]++
+ }
+ }()
+
+ rc := r.Run()
+ wg.Wait()
+ bar.Finish()
+ close(r.Results())
+ fmt.Printf("Watch creation summary:\n%s", <-rc)
+
+ for i := 0; i < len(streams); i++ {
+ wk.watches = append(wk.watches, (<-wc)...)
+ }
+}
+
+func newWatchedKeys() *watchedKeys {
+ watched := make([]string, watchedKeyTotal)
+ for i := range watched {
+ k := make([]byte, watchKeySize)
+ if watchSeqKeys {
+ binary.PutVarint(k, int64(i%watchKeySpaceSize))
+ } else {
+ binary.PutVarint(k, int64(rand.Intn(watchKeySpaceSize)))
+ }
+ watched[i] = string(k)
+ }
+ ctx, cancel := context.WithCancel(context.TODO())
+ return &watchedKeys{
+ watched: watched,
+ numWatchers: make(map[string]int),
+ ctx: ctx,
+ cancel: cancel,
+ }
+}
+
+func benchPutWatches(clients []*clientv3.Client, wk *watchedKeys) {
+ eventsTotal := 0
+ for i := 0; i < watchPutTotal; i++ {
+ eventsTotal += wk.numWatchers[wk.watched[i%len(wk.watched)]]
+ }
+
+ bar = pb.New(eventsTotal)
+ bar.Format("Bom !")
+ bar.Start()
+
+ r := newReport()
+
+ wg.Add(len(wk.watches))
+ nrRxed := int32(eventsTotal)
+ for _, w := range wk.watches {
+ go func(wc clientv3.WatchChan) {
+ defer wg.Done()
+ recvWatchChan(wc, r.Results(), &nrRxed)
+ wk.cancel()
+ }(w)
+ }
+
+ putreqc := make(chan clientv3.Op, len(clients))
+ go func() {
+ defer close(putreqc)
+ for i := 0; i < watchPutTotal; i++ {
+ putreqc <- clientv3.OpPut(wk.watched[i%(len(wk.watched))], "data")
+ }
+ }()
+
+ limit := rate.NewLimiter(rate.Limit(watchPutRate), 1)
+ for _, cc := range clients {
+ go func(c *clientv3.Client) {
+ for op := range putreqc {
+ if err := limit.Wait(context.TODO()); err != nil {
+ panic(err)
+ }
+ if _, err := c.Do(context.TODO(), op); err != nil {
+ panic(err)
+ }
+ }
+ }(cc)
+ }
+
+ rc := r.Run()
+ wg.Wait()
+ bar.Finish()
+ close(r.Results())
+ fmt.Printf("Watch events received summary:\n%s", <-rc)
+
+}
+
+func recvWatchChan(wch clientv3.WatchChan, results chan<- report.Result, nrRxed *int32) {
+ for r := range wch {
+ st := time.Now()
+ for range r.Events {
+ results <- report.Result{Start: st, End: time.Now()}
+ bar.Increment()
+ if atomic.AddInt32(nrRxed, -1) <= 0 {
+ return
+ }
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/cmd/watch_get.go b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/watch_get.go
new file mode 100644
index 00000000..3eb4a1be
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/watch_get.go
@@ -0,0 +1,118 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 cmd
+
+import (
+ "fmt"
+ "sync"
+ "time"
+
+ v3 "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/pkg/report"
+
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+ "gopkg.in/cheggaaa/pb.v1"
+)
+
+// watchGetCmd represents the watch command
+var watchGetCmd = &cobra.Command{
+ Use: "watch-get",
+ Short: "Benchmark watch with get",
+ Long: `Benchmark for serialized key gets with many unsynced watchers`,
+ Run: watchGetFunc,
+}
+
+var (
+ watchGetTotalWatchers int
+ watchGetTotalStreams int
+ watchEvents int
+ firstWatch sync.Once
+)
+
+func init() {
+ RootCmd.AddCommand(watchGetCmd)
+ watchGetCmd.Flags().IntVar(&watchGetTotalWatchers, "watchers", 10000, "Total number of watchers")
+ watchGetCmd.Flags().IntVar(&watchGetTotalStreams, "streams", 1, "Total number of watcher streams")
+ watchGetCmd.Flags().IntVar(&watchEvents, "events", 8, "Number of events per watcher")
+}
+
+func watchGetFunc(cmd *cobra.Command, args []string) {
+ clients := mustCreateClients(totalClients, totalConns)
+ getClient := mustCreateClients(1, 1)
+
+ // setup keys for watchers
+ watchRev := int64(0)
+ for i := 0; i < watchEvents; i++ {
+ v := fmt.Sprintf("%d", i)
+ resp, err := clients[0].Put(context.TODO(), "watchkey", v)
+ if err != nil {
+ panic(err)
+ }
+ if i == 0 {
+ watchRev = resp.Header.Revision
+ }
+ }
+
+ streams := make([]v3.Watcher, watchGetTotalStreams)
+ for i := range streams {
+ streams[i] = v3.NewWatcher(clients[i%len(clients)])
+ }
+
+ bar = pb.New(watchGetTotalWatchers * watchEvents)
+ bar.Format("Bom !")
+ bar.Start()
+
+ // report from trying to do serialized gets with concurrent watchers
+ r := newReport()
+ ctx, cancel := context.WithCancel(context.TODO())
+ f := func() {
+ defer close(r.Results())
+ for {
+ st := time.Now()
+ _, err := getClient[0].Get(ctx, "abc", v3.WithSerializable())
+ if ctx.Err() != nil {
+ break
+ }
+ r.Results() <- report.Result{Err: err, Start: st, End: time.Now()}
+ }
+ }
+
+ wg.Add(watchGetTotalWatchers)
+ for i := 0; i < watchGetTotalWatchers; i++ {
+ go doUnsyncWatch(streams[i%len(streams)], watchRev, f)
+ }
+
+ rc := r.Run()
+ wg.Wait()
+ cancel()
+ bar.Finish()
+ fmt.Printf("Get during watch summary:\n%s", <-rc)
+}
+
+func doUnsyncWatch(stream v3.Watcher, rev int64, f func()) {
+ defer wg.Done()
+ wch := stream.Watch(context.TODO(), "watchkey", v3.WithRev(rev))
+ if wch == nil {
+ panic("could not open watch channel")
+ }
+ firstWatch.Do(func() { go f() })
+ i := 0
+ for i < watchEvents {
+ wev := <-wch
+ i += len(wev.Events)
+ bar.Add(len(wev.Events))
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/cmd/watch_latency.go b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/watch_latency.go
new file mode 100644
index 00000000..3a070d26
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/cmd/watch_latency.go
@@ -0,0 +1,111 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 cmd
+
+import (
+ "fmt"
+ "os"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/pkg/report"
+
+ "github.com/spf13/cobra"
+ "golang.org/x/net/context"
+ "golang.org/x/time/rate"
+ "gopkg.in/cheggaaa/pb.v1"
+)
+
+// watchLatencyCmd represents the watch latency command
+var watchLatencyCmd = &cobra.Command{
+ Use: "watch-latency",
+ Short: "Benchmark watch latency",
+ Long: `Benchmarks the latency for watches by measuring
+ the latency between writing to a key and receiving the
+ associated watch response.`,
+ Run: watchLatencyFunc,
+}
+
+var (
+ watchLTotal int
+ watchLPutRate int
+ watchLKeySize int
+ watchLValueSize int
+)
+
+func init() {
+ RootCmd.AddCommand(watchLatencyCmd)
+ watchLatencyCmd.Flags().IntVar(&watchLTotal, "total", 10000, "Total number of put requests")
+ watchLatencyCmd.Flags().IntVar(&watchLPutRate, "put-rate", 100, "Number of keys to put per second")
+ watchLatencyCmd.Flags().IntVar(&watchLKeySize, "key-size", 32, "Key size of watch response")
+ watchLatencyCmd.Flags().IntVar(&watchLValueSize, "val-size", 32, "Value size of watch response")
+}
+
+func watchLatencyFunc(cmd *cobra.Command, args []string) {
+ key := string(mustRandBytes(watchLKeySize))
+ value := string(mustRandBytes(watchLValueSize))
+
+ clients := mustCreateClients(totalClients, totalConns)
+ putClient := mustCreateConn()
+
+ wchs := make([]clientv3.WatchChan, len(clients))
+ for i := range wchs {
+ wchs[i] = clients[i].Watch(context.TODO(), key)
+ }
+
+ bar = pb.New(watchLTotal)
+ bar.Format("Bom !")
+ bar.Start()
+
+ limiter := rate.NewLimiter(rate.Limit(watchLPutRate), watchLPutRate)
+ r := newReport()
+ rc := r.Run()
+
+ for i := 0; i < watchLTotal; i++ {
+ // limit key put as per reqRate
+ if err := limiter.Wait(context.TODO()); err != nil {
+ break
+ }
+
+ var st time.Time
+ var wg sync.WaitGroup
+ wg.Add(len(clients))
+ barrierc := make(chan struct{})
+ for _, wch := range wchs {
+ ch := wch
+ go func() {
+ <-barrierc
+ <-ch
+ r.Results() <- report.Result{Start: st, End: time.Now()}
+ wg.Done()
+ }()
+ }
+
+ if _, err := putClient.Put(context.TODO(), key, value); err != nil {
+ fmt.Fprintf(os.Stderr, "Failed to Put for watch latency benchmark: %v\n", err)
+ os.Exit(1)
+ }
+
+ st = time.Now()
+ close(barrierc)
+ wg.Wait()
+ bar.Increment()
+ }
+
+ close(r.Results())
+ bar.Finish()
+ fmt.Printf("%s", <-rc)
+}
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/doc.go b/vendor/github.com/coreos/etcd/tools/benchmark/doc.go
new file mode 100644
index 00000000..0e4dc629
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// benchmark is a program for benchmarking etcd v3 API performance.
+package main
diff --git a/vendor/github.com/coreos/etcd/tools/benchmark/main.go b/vendor/github.com/coreos/etcd/tools/benchmark/main.go
new file mode 100644
index 00000000..2b0396b2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/benchmark/main.go
@@ -0,0 +1,29 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "os"
+
+ "github.com/coreos/etcd/tools/benchmark/cmd"
+)
+
+func main() {
+ if err := cmd.RootCmd.Execute(); err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(-1)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/tools/etcd-dump-db/README.md b/vendor/github.com/coreos/etcd/tools/etcd-dump-db/README.md
new file mode 100644
index 00000000..05fc4f94
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/etcd-dump-db/README.md
@@ -0,0 +1,74 @@
+### etcd-dump-db
+
+etcd-dump-db inspects etcd db files.
+
+```
+Usage:
+ etcd-dump-db [command]
+
+Available Commands:
+ list-bucket bucket lists all buckets.
+ iterate-bucket iterate-bucket lists key-value pairs in reverse order.
+ hash hash computes the hash of db file.
+
+Flags:
+ -h, --help[=false]: help for etcd-dump-db
+
+Use "etcd-dump-db [command] --help" for more information about a command.
+```
+
+
+#### list-bucket [data dir or db file path]
+
+Lists all buckets.
+
+```
+$ etcd-dump-db list-bucket agent01/agent.etcd
+
+alarm
+auth
+authRoles
+authUsers
+cluster
+key
+lease
+members
+members_removed
+meta
+```
+
+
+#### hash [data dir or db file path]
+
+Computes the hash of db file.
+
+```
+$ etcd-dump-db hash agent01/agent.etcd
+db path: agent01/agent.etcd/member/snap/db
+Hash: 3700260467
+
+
+$ etcd-dump-db hash agent02/agent.etcd
+
+db path: agent02/agent.etcd/member/snap/db
+Hash: 3700260467
+
+
+$ etcd-dump-db hash agent03/agent.etcd
+
+db path: agent03/agent.etcd/member/snap/db
+Hash: 3700260467
+```
+
+
+#### iterate-bucket [data dir or db file path]
+
+Lists key-value pairs in reverse order.
+
+```
+$ etcd-dump-db iterate-bucket agent03/agent.etcd --bucket=key --limit 3
+
+key="\x00\x00\x00\x00\x005@x_\x00\x00\x00\x00\x00\x00\x00\tt", value="\n\x153640412599896088633_9"
+key="\x00\x00\x00\x00\x005@x_\x00\x00\x00\x00\x00\x00\x00\bt", value="\n\x153640412599896088633_8"
+key="\x00\x00\x00\x00\x005@x_\x00\x00\x00\x00\x00\x00\x00\at", value="\n\x153640412599896088633_7"
+```
diff --git a/vendor/github.com/coreos/etcd/tools/etcd-dump-db/backend.go b/vendor/github.com/coreos/etcd/tools/etcd-dump-db/backend.go
new file mode 100644
index 00000000..5a509586
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/etcd-dump-db/backend.go
@@ -0,0 +1,83 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "path/filepath"
+
+ "github.com/boltdb/bolt"
+ "github.com/coreos/etcd/mvcc"
+ "github.com/coreos/etcd/mvcc/backend"
+)
+
+func snapDir(dataDir string) string {
+ return filepath.Join(dataDir, "member", "snap")
+}
+
+func getBuckets(dbPath string) (buckets []string, err error) {
+ db, derr := bolt.Open(dbPath, 0600, &bolt.Options{})
+ if derr != nil {
+ return nil, derr
+ }
+ defer db.Close()
+
+ err = db.View(func(tx *bolt.Tx) error {
+ return tx.ForEach(func(b []byte, _ *bolt.Bucket) error {
+ buckets = append(buckets, string(b))
+ return nil
+ })
+ })
+ return
+}
+
+func iterateBucket(dbPath, bucket string, limit uint64) (err error) {
+ db, derr := bolt.Open(dbPath, 0600, &bolt.Options{})
+ if derr != nil {
+ return derr
+ }
+ defer db.Close()
+
+ err = db.View(func(tx *bolt.Tx) error {
+ b := tx.Bucket([]byte(bucket))
+ if b == nil {
+ return fmt.Errorf("got nil bucket for %s", bucket)
+ }
+
+ c := b.Cursor()
+
+ // iterate in reverse order (use First() and Next() for ascending order)
+ for k, v := c.Last(); k != nil; k, v = c.Prev() {
+ fmt.Printf("key=%q, value=%q\n", k, v)
+
+ limit--
+ if limit == 0 {
+ break
+ }
+ }
+
+ return nil
+ })
+ return
+}
+
+func getHash(dbPath string) (hash uint32, err error) {
+ b := backend.NewDefaultBackend(dbPath)
+ return b.Hash(mvcc.DefaultIgnores)
+}
+
+// TODO: revert by revision and find specified hash value
+// currently, it's hard because lease is in separate bucket
+// and does not modify revision
diff --git a/vendor/github.com/coreos/etcd/tools/etcd-dump-db/doc.go b/vendor/github.com/coreos/etcd/tools/etcd-dump-db/doc.go
new file mode 100644
index 00000000..59dde33b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/etcd-dump-db/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// etcd-dump-db inspects etcd db files.
+package main
diff --git a/vendor/github.com/coreos/etcd/tools/etcd-dump-db/main.go b/vendor/github.com/coreos/etcd/tools/etcd-dump-db/main.go
new file mode 100644
index 00000000..b5262c90
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/etcd-dump-db/main.go
@@ -0,0 +1,130 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "log"
+ "os"
+ "path/filepath"
+ "strings"
+
+ "github.com/spf13/cobra"
+)
+
+var (
+ rootCommand = &cobra.Command{
+ Use: "etcd-dump-db",
+ Short: "etcd-dump-db inspects etcd db files.",
+ }
+ listBucketCommand = &cobra.Command{
+ Use: "list-bucket [data dir or db file path]",
+ Short: "bucket lists all buckets.",
+ Run: listBucketCommandFunc,
+ }
+ iterateBucketCommand = &cobra.Command{
+ Use: "iterate-bucket [data dir or db file path]",
+ Short: "iterate-bucket lists key-value pairs in reverse order.",
+ Run: iterateBucketCommandFunc,
+ }
+ getHashCommand = &cobra.Command{
+ Use: "hash [data dir or db file path]",
+ Short: "hash computes the hash of db file.",
+ Run: getHashCommandFunc,
+ }
+)
+
+var (
+ iterateBucketName string
+ iterateBucketLimit uint64
+)
+
+func init() {
+ iterateBucketCommand.PersistentFlags().StringVar(&iterateBucketName, "bucket", "", "bucket name to iterate")
+ iterateBucketCommand.PersistentFlags().Uint64Var(&iterateBucketLimit, "limit", 0, "max number of key-value pairs to iterate (0< to iterate all)")
+
+ rootCommand.AddCommand(listBucketCommand)
+ rootCommand.AddCommand(iterateBucketCommand)
+ rootCommand.AddCommand(getHashCommand)
+}
+
+func main() {
+ if err := rootCommand.Execute(); err != nil {
+ fmt.Fprintln(os.Stdout, err)
+ os.Exit(1)
+ }
+}
+
+func listBucketCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) < 1 {
+ log.Fatalf("Must provide at least 1 argument (got %v)", args)
+ }
+ dp := args[0]
+ if !strings.HasSuffix(dp, "db") {
+ dp = filepath.Join(snapDir(dp), "db")
+ }
+ if !existFileOrDir(dp) {
+ log.Fatalf("%q does not exist", dp)
+ }
+
+ bts, err := getBuckets(dp)
+ if err != nil {
+ log.Fatal(err)
+ }
+ for _, b := range bts {
+ fmt.Println(b)
+ }
+}
+
+func iterateBucketCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) < 1 {
+ log.Fatalf("Must provide at least 1 argument (got %v)", args)
+ }
+ dp := args[0]
+ if !strings.HasSuffix(dp, "db") {
+ dp = filepath.Join(snapDir(dp), "db")
+ }
+ if !existFileOrDir(dp) {
+ log.Fatalf("%q does not exist", dp)
+ }
+
+ if iterateBucketName == "" {
+ log.Fatal("got empty bucket name")
+ }
+
+ err := iterateBucket(dp, iterateBucketName, iterateBucketLimit)
+ if err != nil {
+ log.Fatal(err)
+ }
+}
+
+func getHashCommandFunc(cmd *cobra.Command, args []string) {
+ if len(args) < 1 {
+ log.Fatalf("Must provide at least 1 argument (got %v)", args)
+ }
+ dp := args[0]
+ if !strings.HasSuffix(dp, "db") {
+ dp = filepath.Join(snapDir(dp), "db")
+ }
+ if !existFileOrDir(dp) {
+ log.Fatalf("%q does not exist", dp)
+ }
+
+ hash, err := getHash(dp)
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Printf("db path: %s\nHash: %d\n", dp, hash)
+}
diff --git a/vendor/github.com/coreos/etcd/tools/etcd-dump-db/utils.go b/vendor/github.com/coreos/etcd/tools/etcd-dump-db/utils.go
new file mode 100644
index 00000000..3af585a8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/etcd-dump-db/utils.go
@@ -0,0 +1,22 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 "os"
+
+func existFileOrDir(name string) bool {
+ _, err := os.Stat(name)
+ return err == nil
+}
diff --git a/vendor/github.com/coreos/etcd/tools/etcd-dump-logs/doc.go b/vendor/github.com/coreos/etcd/tools/etcd-dump-logs/doc.go
new file mode 100644
index 00000000..234ee92f
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/etcd-dump-logs/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// etcd-dump-logs is a program for analyzing etcd server write ahead logs.
+package main
diff --git a/vendor/github.com/coreos/etcd/tools/etcd-dump-logs/main.go b/vendor/github.com/coreos/etcd/tools/etcd-dump-logs/main.go
new file mode 100644
index 00000000..87275c95
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/etcd-dump-logs/main.go
@@ -0,0 +1,162 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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"
+ "log"
+ "path/filepath"
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/snap"
+ "github.com/coreos/etcd/wal"
+ "github.com/coreos/etcd/wal/walpb"
+)
+
+func main() {
+ from := flag.String("data-dir", "", "")
+ snapfile := flag.String("start-snap", "", "The base name of snapshot file to start dumping")
+ index := flag.Uint64("start-index", 0, "The index to start dumping")
+ flag.Parse()
+ if *from == "" {
+ log.Fatal("Must provide -data-dir flag.")
+ }
+ if *snapfile != "" && *index != 0 {
+ log.Fatal("start-snap and start-index flags cannot be used together.")
+ }
+
+ var (
+ walsnap walpb.Snapshot
+ snapshot *raftpb.Snapshot
+ err error
+ )
+
+ isIndex := *index != 0
+
+ if isIndex {
+ fmt.Printf("Start dumping log entries from index %d.\n", *index)
+ walsnap.Index = *index
+ } else {
+ if *snapfile == "" {
+ ss := snap.New(snapDir(*from))
+ snapshot, err = ss.Load()
+ } else {
+ snapshot, err = snap.Read(filepath.Join(snapDir(*from), *snapfile))
+ }
+
+ switch err {
+ case nil:
+ walsnap.Index, walsnap.Term = snapshot.Metadata.Index, snapshot.Metadata.Term
+ nodes := genIDSlice(snapshot.Metadata.ConfState.Nodes)
+ fmt.Printf("Snapshot:\nterm=%d index=%d nodes=%s\n",
+ walsnap.Term, walsnap.Index, nodes)
+ case snap.ErrNoSnapshot:
+ fmt.Printf("Snapshot:\nempty\n")
+ default:
+ log.Fatalf("Failed loading snapshot: %v", err)
+ }
+ fmt.Println("Start dupmping log entries from snapshot.")
+ }
+
+ w, err := wal.OpenForRead(walDir(*from), walsnap)
+ if err != nil {
+ log.Fatalf("Failed opening WAL: %v", err)
+ }
+ wmetadata, state, ents, err := w.ReadAll()
+ w.Close()
+ if err != nil && (!isIndex || err != wal.ErrSnapshotNotFound) {
+ log.Fatalf("Failed reading WAL: %v", err)
+ }
+ id, cid := parseWALMetadata(wmetadata)
+ vid := types.ID(state.Vote)
+ fmt.Printf("WAL metadata:\nnodeID=%s clusterID=%s term=%d commitIndex=%d vote=%s\n",
+ id, cid, state.Term, state.Commit, vid)
+
+ fmt.Printf("WAL entries:\n")
+ fmt.Printf("lastIndex=%d\n", ents[len(ents)-1].Index)
+ fmt.Printf("%4s\t%10s\ttype\tdata\n", "term", "index")
+ for _, e := range ents {
+ msg := fmt.Sprintf("%4d\t%10d", e.Term, e.Index)
+ switch e.Type {
+ case raftpb.EntryNormal:
+ msg = fmt.Sprintf("%s\tnorm", msg)
+
+ var rr etcdserverpb.InternalRaftRequest
+ if err := rr.Unmarshal(e.Data); err == nil {
+ msg = fmt.Sprintf("%s\t%s", msg, rr.String())
+ break
+ }
+
+ var r etcdserverpb.Request
+ if err := r.Unmarshal(e.Data); err == nil {
+ switch r.Method {
+ case "":
+ msg = fmt.Sprintf("%s\tnoop", msg)
+ case "SYNC":
+ msg = fmt.Sprintf("%s\tmethod=SYNC time=%q", msg, time.Unix(0, r.Time))
+ case "QGET", "DELETE":
+ msg = fmt.Sprintf("%s\tmethod=%s path=%s", msg, r.Method, excerpt(r.Path, 64, 64))
+ default:
+ msg = fmt.Sprintf("%s\tmethod=%s path=%s val=%s", msg, r.Method, excerpt(r.Path, 64, 64), excerpt(r.Val, 128, 0))
+ }
+ break
+ }
+ msg = fmt.Sprintf("%s\t???", msg)
+ case raftpb.EntryConfChange:
+ msg = fmt.Sprintf("%s\tconf", msg)
+ var r raftpb.ConfChange
+ if err := r.Unmarshal(e.Data); err != nil {
+ msg = fmt.Sprintf("%s\t???", msg)
+ } else {
+ msg = fmt.Sprintf("%s\tmethod=%s id=%s", msg, r.Type, types.ID(r.NodeID))
+ }
+ }
+ fmt.Println(msg)
+ }
+}
+
+func walDir(dataDir string) string { return filepath.Join(dataDir, "member", "wal") }
+
+func snapDir(dataDir string) string { return filepath.Join(dataDir, "member", "snap") }
+
+func parseWALMetadata(b []byte) (id, cid types.ID) {
+ var metadata etcdserverpb.Metadata
+ pbutil.MustUnmarshal(&metadata, b)
+ id = types.ID(metadata.NodeID)
+ cid = types.ID(metadata.ClusterID)
+ return
+}
+
+func genIDSlice(a []uint64) []types.ID {
+ ids := make([]types.ID, len(a))
+ for i, id := range a {
+ ids[i] = types.ID(id)
+ }
+ return ids
+}
+
+// excerpt replaces middle part with ellipsis and returns a double-quoted
+// string safely escaped with Go syntax.
+func excerpt(str string, pre, suf int) string {
+ if pre+suf > len(str) {
+ return fmt.Sprintf("%q", str)
+ }
+ return fmt.Sprintf("%q...%q", str[:pre], str[len(str)-suf:])
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/Procfile b/vendor/github.com/coreos/etcd/tools/functional-tester/Procfile
new file mode 100644
index 00000000..cbff2da0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/Procfile
@@ -0,0 +1,4 @@
+agent-1: mkdir -p agent-1 && cd agent-1 && ../bin/etcd-agent -etcd-path ../bin/etcd -port 127.0.0.1:19027 -use-root=false
+agent-2: mkdir -p agent-2 && cd agent-2 && ../bin/etcd-agent -etcd-path ../bin/etcd -port 127.0.0.1:29027 -use-root=false
+agent-3: mkdir -p agent-3 && cd agent-3 && ../bin/etcd-agent -etcd-path ../bin/etcd -port 127.0.0.1:39027 -use-root=false
+stresser: sleep 1s && bin/etcd-tester -agent-endpoints "127.0.0.1:19027,127.0.0.1:29027,127.0.0.1:39027" -client-ports 12379,22379,32379 -peer-ports 12380,22380,32380
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/README.md b/vendor/github.com/coreos/etcd/tools/functional-tester/README.md
new file mode 100644
index 00000000..78e9b26b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/README.md
@@ -0,0 +1,51 @@
+# etcd functional test suite
+
+etcd functional test suite tests the functionality of an etcd cluster with a focus on failure resistance under high pressure. It sets up an etcd cluster and inject failures into the cluster by killing the process or isolate the network of the process. It expects the etcd cluster to recover within a short amount of time after fixing the fault.
+
+etcd functional test suite has two components: etcd-agent and etcd-tester. etcd-agent runs on every test machines and etcd-tester is a single controller of the test. etcd-tester controls all the etcd-agent to start etcd clusters and simulate various failure cases.
+
+## requirements
+
+The environment of the cluster must be stable enough, so etcd test suite can assume that most of the failures are generated by itself.
+
+## etcd agent
+
+etcd agent is a daemon on each machines. It can start, stop, restart, isolate and terminate an etcd process. The agent exposes these functionality via HTTP RPC.
+
+## etcd tester
+
+etcd functional tester control the progress of the functional tests. It calls the RPC of the etcd agent to simulate various test cases. For example, it can start a three members cluster by sending three start RPC calls to three different etcd agents. It can make one of the member failed by sending stop RPC call to one etcd agent.
+
+## with Docker (optionally)
+
+To run the functional tests using Docker, the provided script can be used to set up an environment using Docker Compose.
+
+Script (on linux):
+```sh
+./tools/functional-tester/test
+```
+
+Running the script requires:
+
+- Docker 1.9+ (with networking support) - to create isolated network
+- docker-compose - to create etcd cluster and tester
+- A multi-arch Go toolchain (OSX)
+
+Notes:
+- Docker image is based on Alpine Linux OS running in privileged mode to allow iptables manipulation.
+- To specify testing parameters (etcd-tester arguments) modify tools/functional-tester/docker/docker-compose.yml or start etcd-tester manually
+- (OSX) make sure that etcd binary is built for linux/amd64 (eg. `rm bin/etcd;GOOS=linux GOARCH=amd64 ./tools/functional-tester/test`) otherwise it will return `exec format error`
+
+
+## with Goreman
+
+To run the functional tests on a single machine using Goreman, build with the provided build script and run with the provided Procfile:
+
+```sh
+./tools/functional-tester/build
+goreman -f tools/functional-tester/Procfile start
+```
+
+Notes:
+- The etcd-agent will not run with root privileges; iptables manipulation is disabled.
+- To specify testing parameters (etcd-tester arguments) modify tools/functional-tester/Procfile or start etcd-tester manually
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/build b/vendor/github.com/coreos/etcd/tools/functional-tester/build
new file mode 100755
index 00000000..ef116820
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/build
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+if ! [[ "$0" =~ "tools/functional-tester/build" ]]; then
+ echo "must be run from repository root"
+ exit 255
+fi
+
+CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags "-s" -o bin/etcd-agent ./cmd/tools/functional-tester/etcd-agent
+CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags "-s" -o bin/etcd-tester ./cmd/tools/functional-tester/etcd-tester
+CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags "-s" -o bin/etcd-runner ./cmd/tools/functional-tester/etcd-runner
+
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/docker/Dockerfile b/vendor/github.com/coreos/etcd/tools/functional-tester/docker/Dockerfile
new file mode 100644
index 00000000..0c8e49f7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/docker/Dockerfile
@@ -0,0 +1,8 @@
+FROM alpine
+RUN apk update
+RUN apk add -v iptables sudo
+ADD bin/etcd-agent /
+ADD bin/etcd /
+ADD bin/etcd-tester /
+RUN mkdir /failure_archive
+CMD ["./etcd-agent", "-etcd-path", "./etcd"]
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/docker/docker-compose.yml b/vendor/github.com/coreos/etcd/tools/functional-tester/docker/docker-compose.yml
new file mode 100644
index 00000000..5aa7659b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/docker/docker-compose.yml
@@ -0,0 +1,28 @@
+# build according provided Dockerfile
+a1:
+ build: .
+ privileged: true
+ net: etcd-functional
+a2:
+ build: .
+ privileged: true
+ net: etcd-functional
+a3:
+ build: .
+ privileged: true
+ net: etcd-functional
+tester:
+ build: .
+ privileged: true
+ net: etcd-functional
+ command:
+ - /etcd-tester
+ - -agent-endpoints
+ - "172.20.0.2:9027,172.20.0.3:9027,172.20.0.4:9027"
+ - -limit
+ - "1"
+ - -stress-key-count
+ - "1"
+ - -stress-key-size
+ - "1"
+
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/agent.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/agent.go
new file mode 100644
index 00000000..b7be2909
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/agent.go
@@ -0,0 +1,243 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "os"
+ "os/exec"
+ "path/filepath"
+ "syscall"
+ "time"
+
+ "github.com/coreos/etcd/pkg/fileutil"
+ "github.com/coreos/etcd/pkg/netutil"
+ "github.com/coreos/etcd/tools/functional-tester/etcd-agent/client"
+)
+
+const (
+ stateUninitialized = "uninitialized"
+ stateStarted = "started"
+ stateStopped = "stopped"
+ stateTerminated = "terminated"
+)
+
+type Agent struct {
+ state string // the state of etcd process
+
+ cmd *exec.Cmd
+ logfile *os.File
+
+ cfg AgentConfig
+}
+
+type AgentConfig struct {
+ EtcdPath string
+ LogDir string
+ FailpointAddr string
+ UseRoot bool
+}
+
+func newAgent(cfg AgentConfig) (*Agent, error) {
+ // check if the file exists
+ _, err := os.Stat(cfg.EtcdPath)
+ if err != nil {
+ return nil, err
+ }
+
+ c := exec.Command(cfg.EtcdPath)
+
+ err = fileutil.TouchDirAll(cfg.LogDir)
+ if err != nil {
+ return nil, err
+ }
+
+ var f *os.File
+ f, err = os.Create(filepath.Join(cfg.LogDir, "etcd.log"))
+ if err != nil {
+ return nil, err
+ }
+
+ return &Agent{state: stateUninitialized, cmd: c, logfile: f, cfg: cfg}, nil
+}
+
+// start starts a new etcd process with the given args.
+func (a *Agent) start(args ...string) error {
+ args = append(args, "--data-dir", a.dataDir())
+ a.cmd = exec.Command(a.cmd.Path, args...)
+ a.cmd.Env = []string{"GOFAIL_HTTP=" + a.cfg.FailpointAddr}
+ a.cmd.Stdout = a.logfile
+ a.cmd.Stderr = a.logfile
+ err := a.cmd.Start()
+ if err != nil {
+ return err
+ }
+
+ a.state = stateStarted
+ return nil
+}
+
+// stop stops the existing etcd process the agent started.
+func (a *Agent) stopWithSig(sig os.Signal) error {
+ if a.state != stateStarted {
+ return nil
+ }
+
+ err := stopWithSig(a.cmd, sig)
+ if err != nil {
+ return err
+ }
+
+ a.state = stateStopped
+ return nil
+}
+
+func stopWithSig(cmd *exec.Cmd, sig os.Signal) error {
+ err := cmd.Process.Signal(sig)
+ if err != nil {
+ return err
+ }
+
+ errc := make(chan error)
+ go func() {
+ _, ew := cmd.Process.Wait()
+ errc <- ew
+ close(errc)
+ }()
+
+ select {
+ case <-time.After(5 * time.Second):
+ cmd.Process.Kill()
+ case e := <-errc:
+ return e
+ }
+ err = <-errc
+ return err
+}
+
+// restart restarts the stopped etcd process.
+func (a *Agent) restart() error {
+ return a.start(a.cmd.Args[1:]...)
+}
+
+func (a *Agent) cleanup() error {
+ // exit with stackstrace
+ if err := a.stopWithSig(syscall.SIGQUIT); err != nil {
+ return err
+ }
+ a.state = stateUninitialized
+
+ a.logfile.Close()
+ if err := archiveLogAndDataDir(a.cfg.LogDir, a.dataDir()); err != nil {
+ return err
+ }
+
+ if err := fileutil.TouchDirAll(a.cfg.LogDir); err != nil {
+ return err
+ }
+
+ f, err := os.Create(filepath.Join(a.cfg.LogDir, "etcd.log"))
+ if err != nil {
+ return err
+ }
+ a.logfile = f
+
+ // https://www.kernel.org/doc/Documentation/sysctl/vm.txt
+ // https://github.com/torvalds/linux/blob/master/fs/drop_caches.c
+ cmd := exec.Command("/bin/sh", "-c", `echo "echo 1 > /proc/sys/vm/drop_caches" | sudo sh`)
+ if err := cmd.Run(); err != nil {
+ plog.Infof("error when cleaning page cache (%v)", err)
+ }
+ return nil
+}
+
+// terminate stops the exiting etcd process the agent started
+// and removes the data dir.
+func (a *Agent) terminate() error {
+ err := a.stopWithSig(syscall.SIGTERM)
+ if err != nil {
+ return err
+ }
+ err = os.RemoveAll(a.dataDir())
+ if err != nil {
+ return err
+ }
+ a.state = stateTerminated
+ return nil
+}
+
+func (a *Agent) dropPort(port int) error {
+ if !a.cfg.UseRoot {
+ return nil
+ }
+ return netutil.DropPort(port)
+}
+
+func (a *Agent) recoverPort(port int) error {
+ if !a.cfg.UseRoot {
+ return nil
+ }
+ return netutil.RecoverPort(port)
+}
+
+func (a *Agent) setLatency(ms, rv int) error {
+ if !a.cfg.UseRoot {
+ return nil
+ }
+ if ms == 0 {
+ return netutil.RemoveLatency()
+ }
+ return netutil.SetLatency(ms, rv)
+}
+
+func (a *Agent) status() client.Status {
+ return client.Status{State: a.state}
+}
+
+func (a *Agent) dataDir() string {
+ return filepath.Join(a.cfg.LogDir, "etcd.data")
+}
+
+func existDir(fpath string) bool {
+ st, err := os.Stat(fpath)
+ if err != nil {
+ if os.IsNotExist(err) {
+ return false
+ }
+ } else {
+ return st.IsDir()
+ }
+ return false
+}
+
+func archiveLogAndDataDir(logDir string, datadir string) error {
+ dir := filepath.Join(logDir, "failure_archive", time.Now().Format(time.RFC3339))
+ if existDir(dir) {
+ dir = filepath.Join(logDir, "failure_archive", time.Now().Add(time.Second).Format(time.RFC3339))
+ }
+ if err := fileutil.TouchDirAll(dir); err != nil {
+ return err
+ }
+ if err := os.Rename(filepath.Join(logDir, "etcd.log"), filepath.Join(dir, "etcd.log")); err != nil {
+ if !os.IsNotExist(err) {
+ return err
+ }
+ }
+ if err := os.Rename(datadir, filepath.Join(dir, filepath.Base(datadir))); err != nil {
+ if !os.IsNotExist(err) {
+ return err
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/agent_test.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/agent_test.go
new file mode 100644
index 00000000..8c22dcfe
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/agent_test.go
@@ -0,0 +1,92 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "syscall"
+ "testing"
+)
+
+var etcdPath = filepath.Join(os.Getenv("GOPATH"), "bin/etcd")
+
+func TestAgentStart(t *testing.T) {
+ defer os.Remove("etcd.log")
+
+ a, dir := newTestAgent(t)
+ defer a.terminate()
+
+ err := a.start("--data-dir", dir)
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestAgentRestart(t *testing.T) {
+ defer os.Remove("etcd.log")
+
+ a, dir := newTestAgent(t)
+ defer a.terminate()
+
+ err := a.start("--data-dir", dir)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ err = a.stopWithSig(syscall.SIGTERM)
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = a.restart()
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestAgentTerminate(t *testing.T) {
+ defer os.Remove("etcd.log")
+
+ a, dir := newTestAgent(t)
+
+ err := a.start("--data-dir", dir)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ err = a.terminate()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if _, err := os.Stat(dir); !os.IsNotExist(err) {
+ t.Fatal(err)
+ }
+}
+
+// newTestAgent creates a test agent and with a temp data directory.
+func newTestAgent(t *testing.T) (*Agent, string) {
+ a, err := newAgent(AgentConfig{EtcdPath: etcdPath, LogDir: "etcd.log"})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ dir, err := ioutil.TempDir(os.TempDir(), "etcd-agent")
+ if err != nil {
+ t.Fatal(err)
+ }
+ return a, dir
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/client/client.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/client/client.go
new file mode 100644
index 00000000..53d28d03
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/client/client.go
@@ -0,0 +1,118 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 client
+
+import "net/rpc"
+
+type Status struct {
+ // State gives the human-readable status of an agent (e.g., "started" or "terminated")
+ State string
+
+ // TODO: gather more informations
+ // TODO: memory usage, raft information, etc..
+}
+
+type Agent interface {
+ ID() uint64
+ // Start starts a new etcd with the given args on the agent machine.
+ Start(args ...string) (int, error)
+ // Stop stops the existing etcd the agent started.
+ Stop() error
+ // Restart restarts the existing etcd the agent stopped.
+ Restart() (int, error)
+ // Cleanup stops the exiting etcd the agent started, then archives log and its data dir.
+ Cleanup() error
+ // Terminate stops the exiting etcd the agent started and removes its data dir.
+ Terminate() error
+ // DropPort drops all network packets at the given port.
+ DropPort(port int) error
+ // RecoverPort stops dropping all network packets at the given port.
+ RecoverPort(port int) error
+ // SetLatency slows down network by introducing latency.
+ SetLatency(ms, rv int) error
+ // RemoveLatency removes latency introduced by SetLatency.
+ RemoveLatency() error
+ // Status returns the status of etcd on the agent
+ Status() (Status, error)
+}
+
+type agent struct {
+ endpoint string
+ rpcClient *rpc.Client
+}
+
+func NewAgent(endpoint string) (Agent, error) {
+ c, err := rpc.DialHTTP("tcp", endpoint)
+ if err != nil {
+ return nil, err
+ }
+ return &agent{endpoint, c}, nil
+}
+
+func (a *agent) Start(args ...string) (int, error) {
+ var pid int
+ err := a.rpcClient.Call("Agent.RPCStart", args, &pid)
+ if err != nil {
+ return -1, err
+ }
+ return pid, nil
+}
+
+func (a *agent) Stop() error {
+ return a.rpcClient.Call("Agent.RPCStop", struct{}{}, nil)
+}
+
+func (a *agent) Restart() (int, error) {
+ var pid int
+ err := a.rpcClient.Call("Agent.RPCRestart", struct{}{}, &pid)
+ if err != nil {
+ return -1, err
+ }
+ return pid, nil
+}
+
+func (a *agent) Cleanup() error {
+ return a.rpcClient.Call("Agent.RPCCleanup", struct{}{}, nil)
+}
+
+func (a *agent) Terminate() error {
+ return a.rpcClient.Call("Agent.RPCTerminate", struct{}{}, nil)
+}
+
+func (a *agent) DropPort(port int) error {
+ return a.rpcClient.Call("Agent.RPCDropPort", port, nil)
+}
+
+func (a *agent) RecoverPort(port int) error {
+ return a.rpcClient.Call("Agent.RPCRecoverPort", port, nil)
+}
+
+func (a *agent) SetLatency(ms, rv int) error {
+ return a.rpcClient.Call("Agent.RPCSetLatency", []int{ms, rv}, nil)
+}
+
+func (a *agent) RemoveLatency() error {
+ return a.rpcClient.Call("Agent.RPCRemoveLatency", struct{}{}, nil)
+}
+
+func (a *agent) Status() (Status, error) {
+ var s Status
+ err := a.rpcClient.Call("Agent.RPCStatus", struct{}{}, &s)
+ return s, err
+}
+
+func (a *agent) ID() uint64 {
+ panic("not implemented")
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/client/doc.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/client/doc.go
new file mode 100644
index 00000000..9a9958ff
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/client/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 client provides a client implementation to control an etcd-agent.
+package client
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/doc.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/doc.go
new file mode 100644
index 00000000..2bed7352
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// etcd-agent is a daemon for controlling an etcd process via HTTP RPC.
+package main
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/main.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/main.go
new file mode 100644
index 00000000..901750d8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/main.go
@@ -0,0 +1,59 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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"
+ "os"
+ "path/filepath"
+
+ "github.com/coreos/pkg/capnslog"
+)
+
+var plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "etcd-agent")
+
+func main() {
+ etcdPath := flag.String("etcd-path", filepath.Join(os.Getenv("GOPATH"), "bin/etcd"), "the path to etcd binary")
+ etcdLogDir := flag.String("etcd-log-dir", "etcd-log", "directory to store etcd logs, data directories, failure archive")
+ port := flag.String("port", ":9027", "port to serve agent server")
+ useRoot := flag.Bool("use-root", true, "use root permissions")
+ failpointAddr := flag.String("failpoint-addr", ":2381", "interface for gofail's HTTP server")
+ flag.Parse()
+
+ cfg := AgentConfig{
+ EtcdPath: *etcdPath,
+ LogDir: *etcdLogDir,
+ FailpointAddr: *failpointAddr,
+ UseRoot: *useRoot,
+ }
+
+ if *useRoot && os.Getuid() != 0 {
+ fmt.Println("got --use-root=true but not root user")
+ os.Exit(1)
+ }
+ if !*useRoot {
+ fmt.Println("root permissions disabled, agent will not modify network")
+ }
+
+ a, err := newAgent(cfg)
+ if err != nil {
+ plog.Fatal(err)
+ }
+ a.serveRPC(*port)
+
+ var done chan struct{}
+ <-done
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/rpc.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/rpc.go
new file mode 100644
index 00000000..c9cc7a39
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/rpc.go
@@ -0,0 +1,131 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "net"
+ "net/http"
+ "net/rpc"
+ "syscall"
+
+ "github.com/coreos/etcd/tools/functional-tester/etcd-agent/client"
+)
+
+func (a *Agent) serveRPC(port string) {
+ rpc.Register(a)
+ rpc.HandleHTTP()
+ l, e := net.Listen("tcp", port)
+ if e != nil {
+ plog.Fatal(e)
+ }
+ plog.Println("agent listening on", port)
+ go http.Serve(l, nil)
+}
+
+func (a *Agent) RPCStart(args []string, pid *int) error {
+ plog.Printf("start etcd with args %v", args)
+ err := a.start(args...)
+ if err != nil {
+ plog.Println("error starting etcd", err)
+ return err
+ }
+ *pid = a.cmd.Process.Pid
+ return nil
+}
+
+func (a *Agent) RPCStop(args struct{}, reply *struct{}) error {
+ plog.Printf("stop etcd")
+ err := a.stopWithSig(syscall.SIGTERM)
+ if err != nil {
+ plog.Println("error stopping etcd", err)
+ return err
+ }
+ return nil
+}
+
+func (a *Agent) RPCRestart(args struct{}, pid *int) error {
+ plog.Printf("restart etcd")
+ err := a.restart()
+ if err != nil {
+ plog.Println("error restarting etcd", err)
+ return err
+ }
+ *pid = a.cmd.Process.Pid
+ return nil
+}
+
+func (a *Agent) RPCCleanup(args struct{}, reply *struct{}) error {
+ plog.Printf("cleanup etcd")
+ err := a.cleanup()
+ if err != nil {
+ plog.Println("error cleaning up etcd", err)
+ return err
+ }
+ return nil
+}
+
+func (a *Agent) RPCTerminate(args struct{}, reply *struct{}) error {
+ plog.Printf("terminate etcd")
+ err := a.terminate()
+ if err != nil {
+ plog.Println("error terminating etcd", err)
+ }
+ return nil
+}
+
+func (a *Agent) RPCDropPort(port int, reply *struct{}) error {
+ plog.Printf("drop port %d", port)
+ err := a.dropPort(port)
+ if err != nil {
+ plog.Println("error dropping port", err)
+ }
+ return nil
+}
+
+func (a *Agent) RPCRecoverPort(port int, reply *struct{}) error {
+ plog.Printf("recover port %d", port)
+ err := a.recoverPort(port)
+ if err != nil {
+ plog.Println("error recovering port", err)
+ }
+ return nil
+}
+
+func (a *Agent) RPCSetLatency(args []int, reply *struct{}) error {
+ if len(args) != 2 {
+ return fmt.Errorf("SetLatency needs two args, got (%v)", args)
+ }
+ plog.Printf("set latency of %dms (+/- %dms)", args[0], args[1])
+ err := a.setLatency(args[0], args[1])
+ if err != nil {
+ plog.Println("error setting latency", err)
+ }
+ return nil
+}
+
+func (a *Agent) RPCRemoveLatency(args struct{}, reply *struct{}) error {
+ plog.Println("removing latency")
+ err := a.setLatency(0, 0)
+ if err != nil {
+ plog.Println("error removing latency")
+ }
+ return nil
+}
+
+func (a *Agent) RPCStatus(args struct{}, status *client.Status) error {
+ *status = a.status()
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/rpc_test.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/rpc_test.go
new file mode 100644
index 00000000..5db98099
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-agent/rpc_test.go
@@ -0,0 +1,166 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "io/ioutil"
+ "log"
+ "net/rpc"
+ "os"
+ "testing"
+
+ "github.com/coreos/etcd/tools/functional-tester/etcd-agent/client"
+)
+
+func init() {
+ defaultAgent, err := newAgent(AgentConfig{EtcdPath: etcdPath, LogDir: "etcd.log"})
+ if err != nil {
+ log.Panic(err)
+ }
+ defaultAgent.serveRPC(":9027")
+}
+
+func TestRPCStart(t *testing.T) {
+ c, err := rpc.DialHTTP("tcp", ":9027")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ dir, err := ioutil.TempDir(os.TempDir(), "etcd-agent")
+ if err != nil {
+ t.Fatal(err)
+ }
+ var pid int
+ err = c.Call("Agent.RPCStart", []string{"--data-dir", dir}, &pid)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer c.Call("Agent.RPCTerminate", struct{}{}, nil)
+
+ _, err = os.FindProcess(pid)
+ if err != nil {
+ t.Errorf("unexpected error %v when find process %d", err, pid)
+ }
+}
+
+func TestRPCRestart(t *testing.T) {
+ c, err := rpc.DialHTTP("tcp", ":9027")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ dir, err := ioutil.TempDir(os.TempDir(), "etcd-agent")
+ if err != nil {
+ t.Fatal(err)
+ }
+ var pid int
+ err = c.Call("Agent.RPCStart", []string{"--data-dir", dir}, &pid)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer c.Call("Agent.RPCTerminate", struct{}{}, nil)
+
+ err = c.Call("Agent.RPCStop", struct{}{}, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var npid int
+ err = c.Call("Agent.RPCRestart", struct{}{}, &npid)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if npid == pid {
+ t.Errorf("pid = %v, want not equal to %d", npid, pid)
+ }
+
+ s, err := os.FindProcess(pid)
+ if err != nil {
+ t.Errorf("unexpected error %v when find process %d", err, pid)
+ }
+ _, err = s.Wait()
+ if err == nil {
+ t.Errorf("err = nil, want killed error")
+ }
+ _, err = os.FindProcess(npid)
+ if err != nil {
+ t.Errorf("unexpected error %v when find process %d", err, npid)
+ }
+}
+
+func TestRPCTerminate(t *testing.T) {
+ c, err := rpc.DialHTTP("tcp", ":9027")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ dir, err := ioutil.TempDir(os.TempDir(), "etcd-agent")
+ if err != nil {
+ t.Fatal(err)
+ }
+ var pid int
+ err = c.Call("Agent.RPCStart", []string{"--data-dir", dir}, &pid)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ err = c.Call("Agent.RPCTerminate", struct{}{}, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if _, err := os.Stat(dir); !os.IsNotExist(err) {
+ t.Fatal(err)
+ }
+}
+
+func TestRPCStatus(t *testing.T) {
+ c, err := rpc.DialHTTP("tcp", ":9027")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ var s client.Status
+ err = c.Call("Agent.RPCStatus", struct{}{}, &s)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if s.State != stateTerminated {
+ t.Errorf("state = %s, want %s", s.State, stateTerminated)
+ }
+
+ dir, err := ioutil.TempDir(os.TempDir(), "etcd-agent")
+ if err != nil {
+ t.Fatal(err)
+ }
+ var pid int
+ err = c.Call("Agent.RPCStart", []string{"--data-dir", dir}, &pid)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ err = c.Call("Agent.RPCStatus", struct{}{}, &s)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if s.State != stateStarted {
+ t.Errorf("state = %s, want %s", s.State, stateStarted)
+ }
+
+ err = c.Call("Agent.RPCTerminate", struct{}{}, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/election_command.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/election_command.go
new file mode 100644
index 00000000..174670b8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/election_command.go
@@ -0,0 +1,144 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "context"
+ "errors"
+ "fmt"
+
+ "github.com/coreos/etcd/clientv3/concurrency"
+
+ "github.com/spf13/cobra"
+)
+
+// NewElectionCommand returns the cobra command for "election runner".
+func NewElectionCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "election [election name (defaults to 'elector')]",
+ Short: "Performs election operation",
+ Run: runElectionFunc,
+ }
+ cmd.Flags().IntVar(&totalClientConnections, "total-client-connections", 10, "total number of client connections")
+ return cmd
+}
+
+func runElectionFunc(cmd *cobra.Command, args []string) {
+ election := "elector"
+ if len(args) == 1 {
+ election = args[0]
+ }
+ if len(args) > 1 {
+ ExitWithError(ExitBadArgs, errors.New("election takes at most one argument"))
+ }
+
+ rcs := make([]roundClient, totalClientConnections)
+ validatec := make(chan struct{}, len(rcs))
+ // nextc closes when election is ready for next round.
+ nextc := make(chan struct{})
+ eps := endpointsFromFlag(cmd)
+
+ for i := range rcs {
+ v := fmt.Sprintf("%d", i)
+ observedLeader := ""
+ validateWaiters := 0
+ var rcNextc chan struct{}
+ setRcNextc := func() {
+ rcNextc = nextc
+ }
+
+ rcs[i].c = newClient(eps, dialTimeout)
+ var (
+ s *concurrency.Session
+ err error
+ )
+ for {
+ s, err = concurrency.NewSession(rcs[i].c)
+ if err == nil {
+ break
+ }
+ }
+
+ e := concurrency.NewElection(s, election)
+ rcs[i].acquire = func() (err error) {
+ ctx, cancel := context.WithCancel(context.Background())
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ for ctx.Err() == nil {
+ if ol, ok := <-e.Observe(ctx); ok {
+ observedLeader = string(ol.Kvs[0].Value)
+ break
+ }
+ }
+ if observedLeader != v {
+ cancel()
+ }
+ }()
+ err = e.Campaign(ctx, v)
+ cancel()
+ <-donec
+ if err == nil {
+ observedLeader = v
+ }
+ if observedLeader == v {
+ validateWaiters = len(rcs)
+ }
+ select {
+ case <-ctx.Done():
+ return nil
+ default:
+ return err
+ }
+ }
+ rcs[i].validate = func() error {
+ l, err := e.Leader(context.TODO())
+ if err == nil && string(l.Kvs[0].Value) != observedLeader {
+ return fmt.Errorf("expected leader %q, got %q", observedLeader, l.Kvs[0].Value)
+ }
+ if err != nil {
+ return err
+ }
+ setRcNextc()
+ validatec <- struct{}{}
+ return nil
+ }
+ rcs[i].release = func() error {
+ for validateWaiters > 0 {
+ select {
+ case <-validatec:
+ validateWaiters--
+ default:
+ return fmt.Errorf("waiting on followers")
+ }
+ }
+ if err := e.Resign(context.TODO()); err != nil {
+ return err
+ }
+ if observedLeader == v {
+ oldNextc := nextc
+ nextc = make(chan struct{})
+ close(oldNextc)
+
+ }
+ <-rcNextc
+ observedLeader = ""
+ return nil
+ }
+ }
+ // each client creates 1 key from Campaign() and delete it from Resign()
+ // a round involves in 2*len(rcs) requests.
+ doRounds(rcs, rounds, 2*len(rcs))
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/error.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/error.go
new file mode 100644
index 00000000..3188cd5e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/error.go
@@ -0,0 +1,42 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/coreos/etcd/client"
+)
+
+const (
+ // http://tldp.org/LDP/abs/html/exitcodes.html
+ ExitSuccess = iota
+ ExitError
+ ExitBadConnection
+ ExitInvalidInput // for txn, watch command
+ ExitBadFeature // provided a valid flag with an unsupported value
+ ExitInterrupted
+ ExitIO
+ ExitBadArgs = 128
+)
+
+func ExitWithError(code int, err error) {
+ fmt.Fprintln(os.Stderr, "Error: ", err)
+ if cerr, ok := err.(*client.ClusterError); ok {
+ fmt.Fprintln(os.Stderr, cerr.Detail())
+ }
+ os.Exit(code)
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/global.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/global.go
new file mode 100644
index 00000000..02ae92dc
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/global.go
@@ -0,0 +1,114 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "context"
+ "fmt"
+ "log"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+
+ "github.com/spf13/cobra"
+ "golang.org/x/time/rate"
+)
+
+// shared flags
+var (
+ totalClientConnections int // total number of client connections to be made with server
+ endpoints []string
+ dialTimeout time.Duration
+ rounds int // total number of rounds to run; set to <= 0 to run forever.
+ reqRate int // maximum number of requests per second.
+)
+
+type roundClient struct {
+ c *clientv3.Client
+ progress int
+ acquire func() error
+ validate func() error
+ release func() error
+}
+
+func newClient(eps []string, timeout time.Duration) *clientv3.Client {
+ c, err := clientv3.New(clientv3.Config{
+ Endpoints: eps,
+ DialTimeout: time.Duration(timeout) * time.Second,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ return c
+}
+
+func doRounds(rcs []roundClient, rounds int, requests int) {
+ var wg sync.WaitGroup
+
+ wg.Add(len(rcs))
+ finished := make(chan struct{})
+ limiter := rate.NewLimiter(rate.Limit(reqRate), reqRate)
+ for i := range rcs {
+ go func(rc *roundClient) {
+ defer wg.Done()
+ for rc.progress < rounds || rounds <= 0 {
+ if err := limiter.WaitN(context.Background(), requests/len(rcs)); err != nil {
+ log.Panicf("rate limiter error %v", err)
+ }
+
+ for rc.acquire() != nil { /* spin */
+ }
+
+ if err := rc.validate(); err != nil {
+ log.Fatal(err)
+ }
+
+ time.Sleep(10 * time.Millisecond)
+ rc.progress++
+ finished <- struct{}{}
+
+ for rc.release() != nil { /* spin */
+ }
+ }
+ }(&rcs[i])
+ }
+
+ start := time.Now()
+ for i := 1; i < len(rcs)*rounds+1 || rounds <= 0; i++ {
+ select {
+ case <-finished:
+ if i%100 == 0 {
+ fmt.Printf("finished %d, took %v\n", i, time.Since(start))
+ start = time.Now()
+ }
+ case <-time.After(time.Minute):
+ log.Panic("no progress after 1 minute!")
+ }
+ }
+ wg.Wait()
+
+ for _, rc := range rcs {
+ rc.c.Close()
+ }
+}
+
+func endpointsFromFlag(cmd *cobra.Command) []string {
+ endpoints, err := cmd.Flags().GetStringSlice("endpoints")
+ if err != nil {
+ ExitWithError(ExitError, err)
+ }
+ return endpoints
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/help.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/help.go
new file mode 100644
index 00000000..e7d7a4e8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/help.go
@@ -0,0 +1,174 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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.
+
+// copied from https://github.com/rkt/rkt/blob/master/rkt/help.go
+
+package command
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "os"
+ "strings"
+ "text/tabwriter"
+ "text/template"
+
+ "github.com/coreos/etcd/version"
+ "github.com/spf13/cobra"
+ "github.com/spf13/pflag"
+)
+
+var (
+ commandUsageTemplate *template.Template
+ templFuncs = template.FuncMap{
+ "descToLines": func(s string) []string {
+ // trim leading/trailing whitespace and split into slice of lines
+ return strings.Split(strings.Trim(s, "\n\t "), "\n")
+ },
+ "cmdName": func(cmd *cobra.Command, startCmd *cobra.Command) string {
+ parts := []string{cmd.Name()}
+ for cmd.HasParent() && cmd.Parent().Name() != startCmd.Name() {
+ cmd = cmd.Parent()
+ parts = append([]string{cmd.Name()}, parts...)
+ }
+ return strings.Join(parts, " ")
+ },
+ }
+)
+
+func init() {
+ commandUsage := `
+{{ $cmd := .Cmd }}\
+{{ $cmdname := cmdName .Cmd .Cmd.Root }}\
+NAME:
+{{ if not .Cmd.HasParent }}\
+{{printf "\t%s - %s" .Cmd.Name .Cmd.Short}}
+{{else}}\
+{{printf "\t%s - %s" $cmdname .Cmd.Short}}
+{{end}}\
+
+USAGE:
+{{printf "\t%s" .Cmd.UseLine}}
+{{ if not .Cmd.HasParent }}\
+
+VERSION:
+{{printf "\t%s" .Version}}
+{{end}}\
+{{if .Cmd.HasSubCommands}}\
+
+API VERSION:
+{{printf "\t%s" .APIVersion}}
+{{end}}\
+{{if .Cmd.HasSubCommands}}\
+
+
+COMMANDS:
+{{range .SubCommands}}\
+{{ $cmdname := cmdName . $cmd }}\
+{{ if .Runnable }}\
+{{printf "\t%s\t%s" $cmdname .Short}}
+{{end}}\
+{{end}}\
+{{end}}\
+{{ if .Cmd.Long }}\
+
+DESCRIPTION:
+{{range $line := descToLines .Cmd.Long}}{{printf "\t%s" $line}}
+{{end}}\
+{{end}}\
+{{if .Cmd.HasLocalFlags}}\
+
+OPTIONS:
+{{.LocalFlags}}\
+{{end}}\
+{{if .Cmd.HasInheritedFlags}}\
+
+GLOBAL OPTIONS:
+{{.GlobalFlags}}\
+{{end}}
+`[1:]
+
+ commandUsageTemplate = template.Must(template.New("command_usage").Funcs(templFuncs).Parse(strings.Replace(commandUsage, "\\\n", "", -1)))
+}
+
+func etcdFlagUsages(flagSet *pflag.FlagSet) string {
+ x := new(bytes.Buffer)
+
+ flagSet.VisitAll(func(flag *pflag.Flag) {
+ if len(flag.Deprecated) > 0 {
+ return
+ }
+ format := ""
+ if len(flag.Shorthand) > 0 {
+ format = " -%s, --%s"
+ } else {
+ format = " %s --%s"
+ }
+ if len(flag.NoOptDefVal) > 0 {
+ format = format + "["
+ }
+ if flag.Value.Type() == "string" {
+ // put quotes on the value
+ format = format + "=%q"
+ } else {
+ format = format + "=%s"
+ }
+ if len(flag.NoOptDefVal) > 0 {
+ format = format + "]"
+ }
+ format = format + "\t%s\n"
+ shorthand := flag.Shorthand
+ fmt.Fprintf(x, format, shorthand, flag.Name, flag.DefValue, flag.Usage)
+ })
+
+ return x.String()
+}
+
+func getSubCommands(cmd *cobra.Command) []*cobra.Command {
+ var subCommands []*cobra.Command
+ for _, subCmd := range cmd.Commands() {
+ subCommands = append(subCommands, subCmd)
+ subCommands = append(subCommands, getSubCommands(subCmd)...)
+ }
+ return subCommands
+}
+
+func usageFunc(cmd *cobra.Command) error {
+ subCommands := getSubCommands(cmd)
+ tabOut := getTabOutWithWriter(os.Stdout)
+ commandUsageTemplate.Execute(tabOut, struct {
+ Cmd *cobra.Command
+ LocalFlags string
+ GlobalFlags string
+ SubCommands []*cobra.Command
+ Version string
+ APIVersion string
+ }{
+ cmd,
+ etcdFlagUsages(cmd.LocalFlags()),
+ etcdFlagUsages(cmd.InheritedFlags()),
+ subCommands,
+ version.Version,
+ version.APIVersion,
+ })
+ tabOut.Flush()
+ return nil
+}
+
+func getTabOutWithWriter(writer io.Writer) *tabwriter.Writer {
+ aTabOut := new(tabwriter.Writer)
+ aTabOut.Init(writer, 0, 8, 1, '\t', 0)
+ return aTabOut
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/lease_renewer_command.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/lease_renewer_command.go
new file mode 100644
index 00000000..1e95958c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/lease_renewer_command.go
@@ -0,0 +1,91 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "log"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+
+ "github.com/spf13/cobra"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+)
+
+var (
+ leaseTTL int64
+)
+
+// NewLeaseRenewerCommand returns the cobra command for "lease-renewer runner".
+func NewLeaseRenewerCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "lease-renewer",
+ Short: "Performs lease renew operation",
+ Run: runLeaseRenewerFunc,
+ }
+ cmd.Flags().Int64Var(&leaseTTL, "ttl", 5, "lease's ttl")
+ return cmd
+}
+
+func runLeaseRenewerFunc(cmd *cobra.Command, args []string) {
+ if len(args) > 0 {
+ ExitWithError(ExitBadArgs, errors.New("lease-renewer does not take any argument"))
+ }
+
+ eps := endpointsFromFlag(cmd)
+ c := newClient(eps, dialTimeout)
+ ctx := context.Background()
+
+ for {
+ var (
+ l *clientv3.LeaseGrantResponse
+ lk *clientv3.LeaseKeepAliveResponse
+ err error
+ )
+ for {
+ l, err = c.Lease.Grant(ctx, leaseTTL)
+ if err == nil {
+ break
+ }
+ }
+ expire := time.Now().Add(time.Duration(l.TTL-1) * time.Second)
+
+ for {
+ lk, err = c.Lease.KeepAliveOnce(ctx, l.ID)
+ if grpc.Code(err) == codes.NotFound {
+ if time.Since(expire) < 0 {
+ log.Fatalf("bad renew! exceeded: %v", time.Since(expire))
+ for {
+ lk, err = c.Lease.KeepAliveOnce(ctx, l.ID)
+ fmt.Println(lk, err)
+ time.Sleep(time.Second)
+ }
+ }
+ log.Fatalf("lost lease %d, expire: %v\n", l.ID, expire)
+ break
+ }
+ if err != nil {
+ continue
+ }
+ expire = time.Now().Add(time.Duration(lk.TTL-1) * time.Second)
+ log.Printf("renewed lease %d, expire: %v\n", lk.ID, expire)
+ time.Sleep(time.Duration(lk.TTL-2) * time.Second)
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/lock_racer_command.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/lock_racer_command.go
new file mode 100644
index 00000000..6cd36d50
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/lock_racer_command.go
@@ -0,0 +1,94 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "sync"
+
+ "github.com/coreos/etcd/clientv3/concurrency"
+
+ "github.com/spf13/cobra"
+)
+
+// NewLockRacerCommand returns the cobra command for "lock-racer runner".
+func NewLockRacerCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "lock-racer [name of lock (defaults to 'racers')]",
+ Short: "Performs lock race operation",
+ Run: runRacerFunc,
+ }
+ cmd.Flags().IntVar(&totalClientConnections, "total-client-connections", 10, "total number of client connections")
+ return cmd
+}
+
+func runRacerFunc(cmd *cobra.Command, args []string) {
+ racers := "racers"
+ if len(args) == 1 {
+ racers = args[0]
+ }
+
+ if len(args) > 1 {
+ ExitWithError(ExitBadArgs, errors.New("lock-racer takes at most one argument"))
+ }
+
+ rcs := make([]roundClient, totalClientConnections)
+ ctx := context.Background()
+ // mu ensures validate and release funcs are atomic.
+ var mu sync.Mutex
+ cnt := 0
+
+ eps := endpointsFromFlag(cmd)
+
+ for i := range rcs {
+ var (
+ s *concurrency.Session
+ err error
+ )
+
+ rcs[i].c = newClient(eps, dialTimeout)
+
+ for {
+ s, err = concurrency.NewSession(rcs[i].c)
+ if err == nil {
+ break
+ }
+ }
+ m := concurrency.NewMutex(s, racers)
+ rcs[i].acquire = func() error { return m.Lock(ctx) }
+ rcs[i].validate = func() error {
+ mu.Lock()
+ defer mu.Unlock()
+ if cnt++; cnt != 1 {
+ return fmt.Errorf("bad lock; count: %d", cnt)
+ }
+ return nil
+ }
+ rcs[i].release = func() error {
+ mu.Lock()
+ defer mu.Unlock()
+ if err := m.Unlock(ctx); err != nil {
+ return err
+ }
+ cnt = 0
+ return nil
+ }
+ }
+ // each client creates 1 key from NewMutex() and delete it from Unlock()
+ // a round involves in 2*len(rcs) requests.
+ doRounds(rcs, rounds, 2*len(rcs))
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/root.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/root.go
new file mode 100644
index 00000000..cc4347b8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/root.go
@@ -0,0 +1,70 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 command implements individual etcd-runner commands for the etcd-runner utility.
+package command
+
+import (
+ "log"
+ "math/rand"
+ "time"
+
+ "github.com/spf13/cobra"
+)
+
+const (
+ cliName = "etcd-runner"
+ cliDescription = "Stress tests using clientv3 functionality.."
+
+ defaultDialTimeout = 2 * time.Second
+)
+
+var (
+ rootCmd = &cobra.Command{
+ Use: cliName,
+ Short: cliDescription,
+ SuggestFor: []string{"etcd-runner"},
+ }
+)
+
+func init() {
+ cobra.EnablePrefixMatching = true
+
+ rand.Seed(time.Now().UnixNano())
+
+ log.SetFlags(log.Lmicroseconds)
+
+ rootCmd.PersistentFlags().StringSliceVar(&endpoints, "endpoints", []string{"127.0.0.1:2379"}, "gRPC endpoints")
+ rootCmd.PersistentFlags().DurationVar(&dialTimeout, "dial-timeout", defaultDialTimeout, "dial timeout for client connections")
+ rootCmd.PersistentFlags().IntVar(&reqRate, "req-rate", 30, "maximum number of requests per second")
+ rootCmd.PersistentFlags().IntVar(&rounds, "rounds", 100, "number of rounds to run; 0 to run forever")
+
+ rootCmd.AddCommand(
+ NewElectionCommand(),
+ NewLeaseRenewerCommand(),
+ NewLockRacerCommand(),
+ NewWatchCommand(),
+ )
+}
+
+func Start() {
+ rootCmd.SetUsageFunc(usageFunc)
+
+ // Make help just show the usage
+ rootCmd.SetHelpTemplate(`{{.UsageString}}`)
+
+ if err := rootCmd.Execute(); err != nil {
+ ExitWithError(ExitError, err)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/watch_command.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/watch_command.go
new file mode 100644
index 00000000..c74bef39
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/command/watch_command.go
@@ -0,0 +1,210 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 command
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "log"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/pkg/stringutil"
+
+ "github.com/spf13/cobra"
+ "golang.org/x/time/rate"
+)
+
+var (
+ runningTime time.Duration // time for which operation should be performed
+ noOfPrefixes int // total number of prefixes which will be watched upon
+ watchPerPrefix int // number of watchers per prefix
+ watchPrefix string // prefix append to keys in watcher
+ totalKeys int // total number of keys for operation
+)
+
+// NewWatchCommand returns the cobra command for "watcher runner".
+func NewWatchCommand() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "watcher",
+ Short: "Performs watch operation",
+ Run: runWatcherFunc,
+ }
+ cmd.Flags().DurationVar(&runningTime, "running-time", 60, "number of seconds to run")
+ cmd.Flags().StringVar(&watchPrefix, "prefix", "", "the prefix to append on all keys")
+ cmd.Flags().IntVar(&noOfPrefixes, "total-prefixes", 10, "total no of prefixes to use")
+ cmd.Flags().IntVar(&watchPerPrefix, "watch-per-prefix", 10, "number of watchers per prefix")
+ cmd.Flags().IntVar(&totalKeys, "total-keys", 1000, "total number of keys to watch")
+
+ return cmd
+}
+
+func runWatcherFunc(cmd *cobra.Command, args []string) {
+ if len(args) > 0 {
+ ExitWithError(ExitBadArgs, errors.New("watcher does not take any argument"))
+ }
+
+ ctx := context.Background()
+ for round := 0; round < rounds || rounds <= 0; round++ {
+ fmt.Println("round", round)
+ performWatchOnPrefixes(ctx, cmd, round)
+ }
+}
+
+func performWatchOnPrefixes(ctx context.Context, cmd *cobra.Command, round int) {
+ keyPerPrefix := totalKeys / noOfPrefixes
+ prefixes := stringutil.UniqueStrings(5, noOfPrefixes)
+ keys := stringutil.RandomStrings(10, keyPerPrefix)
+
+ roundPrefix := fmt.Sprintf("%16x", round)
+
+ eps := endpointsFromFlag(cmd)
+
+ var (
+ revision int64
+ wg sync.WaitGroup
+ gr *clientv3.GetResponse
+ err error
+ )
+
+ client := newClient(eps, dialTimeout)
+ defer client.Close()
+
+ gr, err = getKey(ctx, client, "non-existent")
+ if err != nil {
+ log.Fatalf("failed to get the initial revision: %v", err)
+ }
+ revision = gr.Header.Revision
+
+ ctxt, cancel := context.WithDeadline(ctx, time.Now().Add(runningTime*time.Second))
+ defer cancel()
+
+ // generate and put keys in cluster
+ limiter := rate.NewLimiter(rate.Limit(reqRate), reqRate)
+
+ go func() {
+ for _, key := range keys {
+ for _, prefix := range prefixes {
+ if err = limiter.Wait(ctxt); err != nil {
+ return
+ }
+ if err = putKeyAtMostOnce(ctxt, client, watchPrefix+"-"+roundPrefix+"-"+prefix+"-"+key); err != nil {
+ log.Fatalf("failed to put key: %v", err)
+ return
+ }
+ }
+ }
+ }()
+
+ ctxc, cancelc := context.WithCancel(ctx)
+
+ wcs := make([]clientv3.WatchChan, 0)
+ rcs := make([]*clientv3.Client, 0)
+
+ for _, prefix := range prefixes {
+ for j := 0; j < watchPerPrefix; j++ {
+ rc := newClient(eps, dialTimeout)
+ rcs = append(rcs, rc)
+
+ wprefix := watchPrefix + "-" + roundPrefix + "-" + prefix
+
+ wc := rc.Watch(ctxc, wprefix, clientv3.WithPrefix(), clientv3.WithRev(revision))
+ wcs = append(wcs, wc)
+
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ checkWatchResponse(wc, wprefix, keys)
+ }()
+ }
+ }
+ wg.Wait()
+
+ cancelc()
+
+ // verify all watch channels are closed
+ for e, wc := range wcs {
+ if _, ok := <-wc; ok {
+ log.Fatalf("expected wc to be closed, but received %v", e)
+ }
+ }
+
+ for _, rc := range rcs {
+ rc.Close()
+ }
+
+ if err = deletePrefix(ctx, client, watchPrefix); err != nil {
+ log.Fatalf("failed to clean up keys after test: %v", err)
+ }
+}
+
+func checkWatchResponse(wc clientv3.WatchChan, prefix string, keys []string) {
+ for n := 0; n < len(keys); {
+ wr, more := <-wc
+ if !more {
+ log.Fatalf("expect more keys (received %d/%d) for %s", n, len(keys), prefix)
+ }
+ for _, event := range wr.Events {
+ expectedKey := prefix + "-" + keys[n]
+ receivedKey := string(event.Kv.Key)
+ if expectedKey != receivedKey {
+ log.Fatalf("expected key %q, got %q for prefix : %q\n", expectedKey, receivedKey, prefix)
+ }
+ n++
+ }
+ }
+}
+
+func putKeyAtMostOnce(ctx context.Context, client *clientv3.Client, key string) error {
+ gr, err := getKey(ctx, client, key)
+ if err != nil {
+ return err
+ }
+
+ var modrev int64
+ if len(gr.Kvs) > 0 {
+ modrev = gr.Kvs[0].ModRevision
+ }
+
+ for ctx.Err() == nil {
+ _, err := client.Txn(ctx).If(clientv3.Compare(clientv3.ModRevision(key), "=", modrev)).Then(clientv3.OpPut(key, key)).Commit()
+
+ if err == nil {
+ return nil
+ }
+ }
+
+ return ctx.Err()
+}
+
+func deletePrefix(ctx context.Context, client *clientv3.Client, key string) error {
+ for ctx.Err() == nil {
+ if _, err := client.Delete(ctx, key, clientv3.WithPrefix()); err == nil {
+ return nil
+ }
+ }
+ return ctx.Err()
+}
+
+func getKey(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, error) {
+ for ctx.Err() == nil {
+ if gr, err := client.Get(ctx, key); err == nil {
+ return gr, nil
+ }
+ }
+ return nil, ctx.Err()
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/doc.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/doc.go
new file mode 100644
index 00000000..9fb3ba2c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// etcd-runner is a program for testing etcd clientv3 features against a fault injected cluster.
+package main
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/main.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/main.go
new file mode 100644
index 00000000..04fede09
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-runner/main.go
@@ -0,0 +1,22 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// etcd-runner is a command line application that performs tests on etcd.
+package main
+
+import "github.com/coreos/etcd/tools/functional-tester/etcd-runner/command"
+
+func main() {
+ command.Start()
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/checks.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/checks.go
new file mode 100644
index 00000000..f3c5de9b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/checks.go
@@ -0,0 +1,264 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "time"
+
+ "google.golang.org/grpc"
+
+ "github.com/coreos/etcd/clientv3"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "golang.org/x/net/context"
+)
+
+const (
+ retries = 7
+)
+
+type Checker interface {
+ // Check returns an error if the system fails a consistency check.
+ Check() error
+}
+
+type hashAndRevGetter interface {
+ getRevisionHash() (revs map[string]int64, hashes map[string]int64, err error)
+}
+
+type hashChecker struct {
+ hrg hashAndRevGetter
+}
+
+func newHashChecker(hrg hashAndRevGetter) Checker { return &hashChecker{hrg} }
+
+const leaseCheckerTimeout = 10 * time.Second
+
+func (hc *hashChecker) checkRevAndHashes() (err error) {
+ var (
+ revs map[string]int64
+ hashes map[string]int64
+ )
+
+ // retries in case of transient failure or etcd cluster has not stablized yet.
+ for i := 0; i < retries; i++ {
+ revs, hashes, err = hc.hrg.getRevisionHash()
+ if err != nil {
+ plog.Warningf("retry %d. failed to retrieve revison and hash (%v)", i, err)
+ } else {
+ sameRev := getSameValue(revs)
+ sameHashes := getSameValue(hashes)
+ if sameRev && sameHashes {
+ return nil
+ }
+ plog.Warningf("retry %d. etcd cluster is not stable: [revisions: %v] and [hashes: %v]", i, revs, hashes)
+ }
+ time.Sleep(time.Second)
+ }
+
+ if err != nil {
+ return fmt.Errorf("failed revision and hash check (%v)", err)
+ }
+
+ return fmt.Errorf("etcd cluster is not stable: [revisions: %v] and [hashes: %v]", revs, hashes)
+}
+
+func (hc *hashChecker) Check() error {
+ return hc.checkRevAndHashes()
+}
+
+type leaseChecker struct {
+ endpoint string
+ ls *leaseStresser
+ leaseClient pb.LeaseClient
+ kvc pb.KVClient
+}
+
+func (lc *leaseChecker) Check() error {
+ conn, err := grpc.Dial(lc.ls.endpoint, grpc.WithInsecure(), grpc.WithBackoffMaxDelay(1))
+ if err != nil {
+ return fmt.Errorf("%v (%s)", err, lc.ls.endpoint)
+ }
+ defer func() {
+ if conn != nil {
+ conn.Close()
+ }
+ }()
+ lc.kvc = pb.NewKVClient(conn)
+ lc.leaseClient = pb.NewLeaseClient(conn)
+ if err := lc.check(true, lc.ls.revokedLeases.leases); err != nil {
+ return err
+ }
+ if err := lc.check(false, lc.ls.aliveLeases.leases); err != nil {
+ return err
+ }
+ return lc.checkShortLivedLeases()
+}
+
+// checkShortLivedLeases ensures leases expire.
+func (lc *leaseChecker) checkShortLivedLeases() error {
+ ctx, cancel := context.WithTimeout(context.Background(), leaseCheckerTimeout)
+ errc := make(chan error)
+ defer cancel()
+ for leaseID := range lc.ls.shortLivedLeases.leases {
+ go func(id int64) {
+ errc <- lc.checkShortLivedLease(ctx, id)
+ }(leaseID)
+ }
+
+ var errs []error
+ for range lc.ls.shortLivedLeases.leases {
+ if err := <-errc; err != nil {
+ errs = append(errs, err)
+ }
+ }
+ return errsToError(errs)
+}
+
+func (lc *leaseChecker) checkShortLivedLease(ctx context.Context, leaseID int64) (err error) {
+ // retry in case of transient failure or lease is expired but not yet revoked due to the fact that etcd cluster didn't have enought time to delete it.
+ var resp *pb.LeaseTimeToLiveResponse
+ for i := 0; i < retries; i++ {
+ resp, err = lc.getLeaseByID(ctx, leaseID)
+ // lease not found, for ~v3.1 compatibilities, check ErrLeaseNotFound
+ if (err == nil && resp.TTL == -1) || (err != nil && rpctypes.Error(err) == rpctypes.ErrLeaseNotFound) {
+ return nil
+ }
+ if err != nil {
+ plog.Debugf("retry %d. failed to retrieve lease %v error (%v)", i, leaseID, err)
+ continue
+ }
+ if resp.TTL > 0 {
+ plog.Debugf("lease %v is not expired. sleep for %d until it expires.", leaseID, resp.TTL)
+ time.Sleep(time.Duration(resp.TTL) * time.Second)
+ } else {
+ plog.Debugf("retry %d. lease %v is expired but not yet revoked", i, leaseID)
+ time.Sleep(time.Second)
+ }
+ if err = lc.checkLease(ctx, false, leaseID); err != nil {
+ continue
+ }
+ return nil
+ }
+ return err
+}
+
+func (lc *leaseChecker) checkLease(ctx context.Context, expired bool, leaseID int64) error {
+ keysExpired, err := lc.hasKeysAttachedToLeaseExpired(ctx, leaseID)
+ if err != nil {
+ plog.Errorf("hasKeysAttachedToLeaseExpired error %v (endpoint %q)", err, lc.endpoint)
+ return err
+ }
+ leaseExpired, err := lc.hasLeaseExpired(ctx, leaseID)
+ if err != nil {
+ plog.Errorf("hasLeaseExpired error %v (endpoint %q)", err, lc.endpoint)
+ return err
+ }
+ if leaseExpired != keysExpired {
+ return fmt.Errorf("lease %v expiration mismatch (lease expired=%v, keys expired=%v)", leaseID, leaseExpired, keysExpired)
+ }
+ if leaseExpired != expired {
+ return fmt.Errorf("lease %v expected expired=%v, got %v", leaseID, expired, leaseExpired)
+ }
+ return nil
+}
+
+func (lc *leaseChecker) check(expired bool, leases map[int64]time.Time) error {
+ ctx, cancel := context.WithTimeout(context.Background(), leaseCheckerTimeout)
+ defer cancel()
+ for leaseID := range leases {
+ if err := lc.checkLease(ctx, expired, leaseID); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func (lc *leaseChecker) getLeaseByID(ctx context.Context, leaseID int64) (*pb.LeaseTimeToLiveResponse, error) {
+ ltl := &pb.LeaseTimeToLiveRequest{ID: leaseID, Keys: true}
+ return lc.leaseClient.LeaseTimeToLive(ctx, ltl, grpc.FailFast(false))
+}
+
+func (lc *leaseChecker) hasLeaseExpired(ctx context.Context, leaseID int64) (bool, error) {
+ // keep retrying until lease's state is known or ctx is being canceled
+ for ctx.Err() == nil {
+ resp, err := lc.getLeaseByID(ctx, leaseID)
+ if err != nil {
+ // for ~v3.1 compatibilities
+ if rpctypes.Error(err) == rpctypes.ErrLeaseNotFound {
+ return true, nil
+ }
+ } else {
+ return resp.TTL == -1, nil
+ }
+ plog.Warningf("hasLeaseExpired %v resp %v error %v (endpoint %q)", leaseID, resp, err, lc.endpoint)
+ }
+ return false, ctx.Err()
+}
+
+// The keys attached to the lease has the format of "<leaseID>_<idx>" where idx is the ordering key creation
+// Since the format of keys contains about leaseID, finding keys base on "<leaseID>" prefix
+// determines whether the attached keys for a given leaseID has been deleted or not
+func (lc *leaseChecker) hasKeysAttachedToLeaseExpired(ctx context.Context, leaseID int64) (bool, error) {
+ resp, err := lc.kvc.Range(ctx, &pb.RangeRequest{
+ Key: []byte(fmt.Sprintf("%d", leaseID)),
+ RangeEnd: []byte(clientv3.GetPrefixRangeEnd(fmt.Sprintf("%d", leaseID))),
+ }, grpc.FailFast(false))
+ if err != nil {
+ plog.Errorf("retrieving keys attached to lease %v error %v (endpoint %q)", leaseID, err, lc.endpoint)
+ return false, err
+ }
+ return len(resp.Kvs) == 0, nil
+}
+
+// compositeChecker implements a checker that runs a slice of Checkers concurrently.
+type compositeChecker struct{ checkers []Checker }
+
+func newCompositeChecker(checkers []Checker) Checker {
+ return &compositeChecker{checkers}
+}
+
+func (cchecker *compositeChecker) Check() error {
+ errc := make(chan error)
+ for _, c := range cchecker.checkers {
+ go func(chk Checker) { errc <- chk.Check() }(c)
+ }
+ var errs []error
+ for range cchecker.checkers {
+ if err := <-errc; err != nil {
+ errs = append(errs, err)
+ }
+ }
+ return errsToError(errs)
+}
+
+type runnerChecker struct {
+ errc chan error
+}
+
+func (rc *runnerChecker) Check() error {
+ select {
+ case err := <-rc.errc:
+ return err
+ default:
+ return nil
+ }
+}
+
+type noChecker struct{}
+
+func newNoChecker() Checker { return &noChecker{} }
+func (nc *noChecker) Check() error { return nil }
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/cluster.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/cluster.go
new file mode 100644
index 00000000..61f36f0c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/cluster.go
@@ -0,0 +1,257 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "math/rand"
+ "net"
+ "strings"
+ "time"
+
+ "golang.org/x/net/context"
+
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/tools/functional-tester/etcd-agent/client"
+ "google.golang.org/grpc"
+)
+
+// agentConfig holds information needed to interact/configure an agent and its etcd process
+type agentConfig struct {
+ endpoint string
+ clientPort int
+ peerPort int
+ failpointPort int
+}
+
+type cluster struct {
+ agents []agentConfig
+ Size int
+ Members []*member
+}
+
+type ClusterStatus struct {
+ AgentStatuses map[string]client.Status
+}
+
+func (c *cluster) bootstrap() error {
+ size := len(c.agents)
+
+ members := make([]*member, size)
+ memberNameURLs := make([]string, size)
+ for i, a := range c.agents {
+ agent, err := client.NewAgent(a.endpoint)
+ if err != nil {
+ return err
+ }
+ host, _, err := net.SplitHostPort(a.endpoint)
+ if err != nil {
+ return err
+ }
+ members[i] = &member{
+ Agent: agent,
+ Endpoint: a.endpoint,
+ Name: fmt.Sprintf("etcd-%d", i),
+ ClientURL: fmt.Sprintf("http://%s:%d", host, a.clientPort),
+ PeerURL: fmt.Sprintf("http://%s:%d", host, a.peerPort),
+ FailpointURL: fmt.Sprintf("http://%s:%d", host, a.failpointPort),
+ }
+ memberNameURLs[i] = members[i].ClusterEntry()
+ }
+ clusterStr := strings.Join(memberNameURLs, ",")
+ token := fmt.Sprint(rand.Int())
+
+ for i, m := range members {
+ flags := append(
+ m.Flags(),
+ "--initial-cluster-token", token,
+ "--initial-cluster", clusterStr,
+ "--snapshot-count", "10000")
+
+ if _, err := m.Agent.Start(flags...); err != nil {
+ // cleanup
+ for _, m := range members[:i] {
+ m.Agent.Terminate()
+ }
+ return err
+ }
+ }
+
+ c.Size = size
+ c.Members = members
+ return nil
+}
+
+func (c *cluster) Reset() error { return c.bootstrap() }
+
+func (c *cluster) WaitHealth() error {
+ var err error
+ // wait 60s to check cluster health.
+ // TODO: set it to a reasonable value. It is set that high because
+ // follower may use long time to catch up the leader when reboot under
+ // reasonable workload (https://github.com/coreos/etcd/issues/2698)
+ for i := 0; i < 60; i++ {
+ for _, m := range c.Members {
+ if err = m.SetHealthKeyV3(); err != nil {
+ break
+ }
+ }
+ if err == nil {
+ return nil
+ }
+ plog.Warningf("#%d setHealthKey error (%v)", i, err)
+ time.Sleep(time.Second)
+ }
+ return err
+}
+
+// GetLeader returns the index of leader and error if any.
+func (c *cluster) GetLeader() (int, error) {
+ for i, m := range c.Members {
+ isLeader, err := m.IsLeader()
+ if isLeader || err != nil {
+ return i, err
+ }
+ }
+ return 0, fmt.Errorf("no leader found")
+}
+
+func (c *cluster) Cleanup() error {
+ var lasterr error
+ for _, m := range c.Members {
+ if err := m.Agent.Cleanup(); err != nil {
+ lasterr = err
+ }
+ }
+ return lasterr
+}
+
+func (c *cluster) Terminate() {
+ for _, m := range c.Members {
+ m.Agent.Terminate()
+ }
+}
+
+func (c *cluster) Status() ClusterStatus {
+ cs := ClusterStatus{
+ AgentStatuses: make(map[string]client.Status),
+ }
+
+ for _, m := range c.Members {
+ s, err := m.Agent.Status()
+ // TODO: add a.Desc() as a key of the map
+ desc := m.Endpoint
+ if err != nil {
+ cs.AgentStatuses[desc] = client.Status{State: "unknown"}
+ plog.Printf("failed to get the status of agent [%s]", desc)
+ }
+ cs.AgentStatuses[desc] = s
+ }
+ return cs
+}
+
+// maxRev returns the maximum revision found on the cluster.
+func (c *cluster) maxRev() (rev int64, err error) {
+ ctx, cancel := context.WithTimeout(context.TODO(), time.Second)
+ defer cancel()
+ revc, errc := make(chan int64, len(c.Members)), make(chan error, len(c.Members))
+ for i := range c.Members {
+ go func(m *member) {
+ mrev, merr := m.Rev(ctx)
+ revc <- mrev
+ errc <- merr
+ }(c.Members[i])
+ }
+ for i := 0; i < len(c.Members); i++ {
+ if merr := <-errc; merr != nil {
+ err = merr
+ }
+ if mrev := <-revc; mrev > rev {
+ rev = mrev
+ }
+ }
+ return rev, err
+}
+
+func (c *cluster) getRevisionHash() (map[string]int64, map[string]int64, error) {
+ revs := make(map[string]int64)
+ hashes := make(map[string]int64)
+ for _, m := range c.Members {
+ rev, hash, err := m.RevHash()
+ if err != nil {
+ return nil, nil, err
+ }
+ revs[m.ClientURL] = rev
+ hashes[m.ClientURL] = hash
+ }
+ return revs, hashes, nil
+}
+
+func (c *cluster) compactKV(rev int64, timeout time.Duration) (err error) {
+ if rev <= 0 {
+ return nil
+ }
+
+ for i, m := range c.Members {
+ u := m.ClientURL
+ conn, derr := m.dialGRPC()
+ if derr != nil {
+ plog.Printf("[compact kv #%d] dial error %v (endpoint %s)", i, derr, u)
+ err = derr
+ continue
+ }
+ kvc := pb.NewKVClient(conn)
+ ctx, cancel := context.WithTimeout(context.Background(), timeout)
+ plog.Printf("[compact kv #%d] starting (endpoint %s)", i, u)
+ _, cerr := kvc.Compact(ctx, &pb.CompactionRequest{Revision: rev, Physical: true}, grpc.FailFast(false))
+ cancel()
+ conn.Close()
+ succeed := true
+ if cerr != nil {
+ if strings.Contains(cerr.Error(), "required revision has been compacted") && i > 0 {
+ plog.Printf("[compact kv #%d] already compacted (endpoint %s)", i, u)
+ } else {
+ plog.Warningf("[compact kv #%d] error %v (endpoint %s)", i, cerr, u)
+ err = cerr
+ succeed = false
+ }
+ }
+ if succeed {
+ plog.Printf("[compact kv #%d] done (endpoint %s)", i, u)
+ }
+ }
+ return err
+}
+
+func (c *cluster) checkCompact(rev int64) error {
+ if rev == 0 {
+ return nil
+ }
+ for _, m := range c.Members {
+ if err := m.CheckCompact(rev); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func (c *cluster) defrag() error {
+ for _, m := range c.Members {
+ if err := m.Defrag(); err != nil {
+ return err
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/doc.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/doc.go
new file mode 100644
index 00000000..1cf0eca0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// etcd-tester is a single controller for all etcd-agents to manage an etcd cluster and simulate failures.
+package main
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/etcd_runner_stresser.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/etcd_runner_stresser.go
new file mode 100644
index 00000000..23636bf5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/etcd_runner_stresser.go
@@ -0,0 +1,97 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "io/ioutil"
+ "os/exec"
+ "syscall"
+
+ "golang.org/x/time/rate"
+)
+
+type runnerStresser struct {
+ cmd *exec.Cmd
+ cmdStr string
+ args []string
+ rl *rate.Limiter
+ reqRate int
+
+ errc chan error
+ donec chan struct{}
+}
+
+func newRunnerStresser(cmdStr string, args []string, rl *rate.Limiter, reqRate int) *runnerStresser {
+ rl.SetLimit(rl.Limit() - rate.Limit(reqRate))
+ return &runnerStresser{
+ cmdStr: cmdStr,
+ args: args,
+ rl: rl,
+ reqRate: reqRate,
+ errc: make(chan error, 1),
+ donec: make(chan struct{}),
+ }
+}
+
+func (rs *runnerStresser) setupOnce() (err error) {
+ if rs.cmd != nil {
+ return nil
+ }
+
+ rs.cmd = exec.Command(rs.cmdStr, rs.args...)
+ stderr, err := rs.cmd.StderrPipe()
+ if err != nil {
+ return err
+ }
+
+ go func() {
+ defer close(rs.donec)
+ out, err := ioutil.ReadAll(stderr)
+ if err != nil {
+ rs.errc <- err
+ } else {
+ rs.errc <- fmt.Errorf("(%v %v) stderr %v", rs.cmdStr, rs.args, string(out))
+ }
+ }()
+
+ return rs.cmd.Start()
+}
+
+func (rs *runnerStresser) Stress() (err error) {
+ if err = rs.setupOnce(); err != nil {
+ return err
+ }
+ return syscall.Kill(rs.cmd.Process.Pid, syscall.SIGCONT)
+}
+
+func (rs *runnerStresser) Pause() {
+ syscall.Kill(rs.cmd.Process.Pid, syscall.SIGSTOP)
+}
+
+func (rs *runnerStresser) Close() {
+ syscall.Kill(rs.cmd.Process.Pid, syscall.SIGINT)
+ rs.cmd.Wait()
+ <-rs.donec
+ rs.rl.SetLimit(rs.rl.Limit() + rate.Limit(rs.reqRate))
+}
+
+func (rs *runnerStresser) ModifiedKeys() int64 {
+ return 1
+}
+
+func (rs *runnerStresser) Checker() Checker {
+ return &runnerChecker{rs.errc}
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/failpoint.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/failpoint.go
new file mode 100644
index 00000000..bfb93743
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/failpoint.go
@@ -0,0 +1,160 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "strings"
+ "sync"
+ "time"
+)
+
+type failpointStats struct {
+ // crashes counts the number of crashes for a failpoint
+ crashes map[string]int
+ // mu protects crashes
+ mu sync.Mutex
+}
+
+var fpStats failpointStats
+
+func failpointFailures(c *cluster, failpoints []string) (ret []failure, err error) {
+ var fps []string
+ fps, err = failpointPaths(c.Members[0].FailpointURL)
+ if err != nil {
+ return nil, err
+ }
+ // create failure objects for all failpoints
+ for _, fp := range fps {
+ if len(fp) == 0 {
+ continue
+ }
+ fpFails := failuresFromFailpoint(fp, failpoints)
+ // wrap in delays so failpoint has time to trigger
+ for i, fpf := range fpFails {
+ if strings.Contains(fp, "Snap") {
+ // hack to trigger snapshot failpoints
+ fpFails[i] = &failureUntilSnapshot{fpf}
+ } else {
+ fpFails[i] = &failureDelay{fpf, 3 * time.Second}
+ }
+ }
+ ret = append(ret, fpFails...)
+ }
+ fpStats.crashes = make(map[string]int)
+ return ret, err
+}
+
+func failpointPaths(endpoint string) ([]string, error) {
+ resp, err := http.Get(endpoint)
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+ body, rerr := ioutil.ReadAll(resp.Body)
+ if rerr != nil {
+ return nil, rerr
+ }
+ var fps []string
+ for _, l := range strings.Split(string(body), "\n") {
+ fp := strings.Split(l, "=")[0]
+ fps = append(fps, fp)
+ }
+ return fps, nil
+}
+
+// failpoints follows FreeBSD KFAIL_POINT syntax.
+// e.g. panic("etcd-tester"),1*sleep(1000)->panic("etcd-tester")
+func failuresFromFailpoint(fp string, failpoints []string) (fs []failure) {
+ recov := makeRecoverFailpoint(fp)
+ for _, failpoint := range failpoints {
+ inject := makeInjectFailpoint(fp, failpoint)
+ fs = append(fs, []failure{
+ &failureOne{
+ description: description(fmt.Sprintf("failpoint %s (one: %s)", fp, failpoint)),
+ injectMember: inject,
+ recoverMember: recov,
+ },
+ &failureAll{
+ description: description(fmt.Sprintf("failpoint %s (all: %s)", fp, failpoint)),
+ injectMember: inject,
+ recoverMember: recov,
+ },
+ &failureMajority{
+ description: description(fmt.Sprintf("failpoint %s (majority: %s)", fp, failpoint)),
+ injectMember: inject,
+ recoverMember: recov,
+ },
+ &failureLeader{
+ failureByFunc{
+ description: description(fmt.Sprintf("failpoint %s (leader: %s)", fp, failpoint)),
+ injectMember: inject,
+ recoverMember: recov,
+ },
+ 0,
+ },
+ }...)
+ }
+ return fs
+}
+
+func makeInjectFailpoint(fp, val string) injectMemberFunc {
+ return func(m *member) (err error) {
+ return putFailpoint(m.FailpointURL, fp, val)
+ }
+}
+
+func makeRecoverFailpoint(fp string) recoverMemberFunc {
+ return func(m *member) error {
+ if err := delFailpoint(m.FailpointURL, fp); err == nil {
+ return nil
+ }
+ // node not responding, likely dead from fp panic; restart
+ fpStats.mu.Lock()
+ fpStats.crashes[fp]++
+ fpStats.mu.Unlock()
+ return recoverStop(m)
+ }
+}
+
+func putFailpoint(ep, fp, val string) error {
+ req, _ := http.NewRequest(http.MethodPut, ep+"/"+fp, strings.NewReader(val))
+ c := http.Client{}
+ resp, err := c.Do(req)
+ if err != nil {
+ return err
+ }
+ resp.Body.Close()
+ if resp.StatusCode/100 != 2 {
+ return fmt.Errorf("failed to PUT %s=%s at %s (%v)", fp, val, ep, resp.Status)
+ }
+ return nil
+}
+
+func delFailpoint(ep, fp string) error {
+ req, _ := http.NewRequest(http.MethodDelete, ep+"/"+fp, strings.NewReader(""))
+ c := http.Client{}
+ resp, err := c.Do(req)
+ if err != nil {
+ return err
+ }
+ resp.Body.Close()
+ if resp.StatusCode/100 != 2 {
+ return fmt.Errorf("failed to DELETE %s at %s (%v)", fp, ep, resp.Status)
+ }
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/failure.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/failure.go
new file mode 100644
index 00000000..cbc4a52e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/failure.go
@@ -0,0 +1,202 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "math/rand"
+ "os/exec"
+ "time"
+)
+
+type failure interface {
+ // Inject injeccts the failure into the testing cluster at the given
+ // round. When calling the function, the cluster should be in health.
+ Inject(c *cluster, round int) error
+ // Recover recovers the injected failure caused by the injection of the
+ // given round and wait for the recovery of the testing cluster.
+ Recover(c *cluster, round int) error
+ // Desc returns a description of the failure
+ Desc() string
+}
+
+type description string
+
+func (d description) Desc() string { return string(d) }
+
+type injectMemberFunc func(*member) error
+type recoverMemberFunc func(*member) error
+
+type failureByFunc struct {
+ description
+ injectMember injectMemberFunc
+ recoverMember recoverMemberFunc
+}
+
+type failureOne failureByFunc
+type failureAll failureByFunc
+type failureMajority failureByFunc
+type failureLeader struct {
+ failureByFunc
+ idx int
+}
+
+type failureDelay struct {
+ failure
+ delayDuration time.Duration
+}
+
+// failureUntilSnapshot injects a failure and waits for a snapshot event
+type failureUntilSnapshot struct{ failure }
+
+func (f *failureOne) Inject(c *cluster, round int) error {
+ return f.injectMember(c.Members[round%c.Size])
+}
+
+func (f *failureOne) Recover(c *cluster, round int) error {
+ if err := f.recoverMember(c.Members[round%c.Size]); err != nil {
+ return err
+ }
+ return c.WaitHealth()
+}
+
+func (f *failureAll) Inject(c *cluster, round int) error {
+ for _, m := range c.Members {
+ if err := f.injectMember(m); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func (f *failureAll) Recover(c *cluster, round int) error {
+ for _, m := range c.Members {
+ if err := f.recoverMember(m); err != nil {
+ return err
+ }
+ }
+ return c.WaitHealth()
+}
+
+func (f *failureMajority) Inject(c *cluster, round int) error {
+ for i := range killMap(c.Size, round) {
+ if err := f.injectMember(c.Members[i]); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func (f *failureMajority) Recover(c *cluster, round int) error {
+ for i := range killMap(c.Size, round) {
+ if err := f.recoverMember(c.Members[i]); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func (f *failureLeader) Inject(c *cluster, round int) error {
+ idx, err := c.GetLeader()
+ if err != nil {
+ return err
+ }
+ f.idx = idx
+ return f.injectMember(c.Members[idx])
+}
+
+func (f *failureLeader) Recover(c *cluster, round int) error {
+ if err := f.recoverMember(c.Members[f.idx]); err != nil {
+ return err
+ }
+ return c.WaitHealth()
+}
+
+func (f *failureDelay) Inject(c *cluster, round int) error {
+ if err := f.failure.Inject(c, round); err != nil {
+ return err
+ }
+ time.Sleep(f.delayDuration)
+ return nil
+}
+
+func (f *failureUntilSnapshot) Inject(c *cluster, round int) error {
+ if err := f.failure.Inject(c, round); err != nil {
+ return err
+ }
+ if c.Size < 3 {
+ return nil
+ }
+ // maxRev may fail since failure just injected, retry if failed.
+ startRev, err := c.maxRev()
+ for i := 0; i < 10 && startRev == 0; i++ {
+ startRev, err = c.maxRev()
+ }
+ if startRev == 0 {
+ return err
+ }
+ lastRev := startRev
+ // Normal healthy cluster could accept 1000req/s at least.
+ // Give it 3-times time to create a new snapshot.
+ retry := snapshotCount / 1000 * 3
+ for j := 0; j < retry; j++ {
+ lastRev, _ = c.maxRev()
+ // If the number of proposals committed is bigger than snapshot count,
+ // a new snapshot should have been created.
+ if lastRev-startRev > snapshotCount {
+ return nil
+ }
+ time.Sleep(time.Second)
+ }
+ return fmt.Errorf("cluster too slow: only commit %d requests in %ds", lastRev-startRev, retry)
+}
+
+func (f *failureUntilSnapshot) Desc() string {
+ return f.failure.Desc() + " for a long time and expect it to recover from an incoming snapshot"
+}
+
+func killMap(size int, seed int) map[int]bool {
+ m := make(map[int]bool)
+ r := rand.New(rand.NewSource(int64(seed)))
+ majority := size/2 + 1
+ for {
+ m[r.Intn(size)] = true
+ if len(m) >= majority {
+ return m
+ }
+ }
+}
+
+type failureNop failureByFunc
+
+func (f *failureNop) Inject(c *cluster, round int) error { return nil }
+func (f *failureNop) Recover(c *cluster, round int) error { return nil }
+
+type failureExternal struct {
+ failure
+
+ description string
+ scriptPath string
+}
+
+func (f *failureExternal) Inject(c *cluster, round int) error {
+ return exec.Command(f.scriptPath, "enable", fmt.Sprintf("%d", round)).Run()
+}
+
+func (f *failureExternal) Recover(c *cluster, round int) error {
+ return exec.Command(f.scriptPath, "disable", fmt.Sprintf("%d", round)).Run()
+}
+
+func (f *failureExternal) Desc() string { return f.description }
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/failure_agent.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/failure_agent.go
new file mode 100644
index 00000000..5dddec53
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/failure_agent.go
@@ -0,0 +1,154 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "time"
+)
+
+const (
+ snapshotCount = 10000
+ slowNetworkLatency = 500 // 500 millisecond
+ randomVariation = 50
+
+ // Wait more when it recovers from slow network, because network layer
+ // needs extra time to propagate traffic control (tc command) change.
+ // Otherwise, we get different hash values from the previous revision.
+ // For more detail, please see https://github.com/coreos/etcd/issues/5121.
+ waitRecover = 5 * time.Second
+)
+
+func injectStop(m *member) error { return m.Agent.Stop() }
+func recoverStop(m *member) error {
+ _, err := m.Agent.Restart()
+ return err
+}
+
+func newFailureKillAll() failure {
+ return &failureAll{
+ description: "kill all members",
+ injectMember: injectStop,
+ recoverMember: recoverStop,
+ }
+}
+
+func newFailureKillMajority() failure {
+ return &failureMajority{
+ description: "kill majority of the cluster",
+ injectMember: injectStop,
+ recoverMember: recoverStop,
+ }
+}
+
+func newFailureKillOne() failure {
+ return &failureOne{
+ description: "kill one random member",
+ injectMember: injectStop,
+ recoverMember: recoverStop,
+ }
+}
+
+func newFailureKillLeader() failure {
+ ff := failureByFunc{
+ description: "kill leader member",
+ injectMember: injectStop,
+ recoverMember: recoverStop,
+ }
+ return &failureLeader{ff, 0}
+}
+
+func newFailureKillOneForLongTime() failure {
+ return &failureUntilSnapshot{newFailureKillOne()}
+}
+
+func newFailureKillLeaderForLongTime() failure {
+ return &failureUntilSnapshot{newFailureKillLeader()}
+}
+
+func injectDropPort(m *member) error { return m.Agent.DropPort(m.peerPort()) }
+func recoverDropPort(m *member) error { return m.Agent.RecoverPort(m.peerPort()) }
+
+func newFailureIsolate() failure {
+ return &failureOne{
+ description: "isolate one member",
+ injectMember: injectDropPort,
+ recoverMember: recoverDropPort,
+ }
+}
+
+func newFailureIsolateAll() failure {
+ return &failureAll{
+ description: "isolate all members",
+ injectMember: injectDropPort,
+ recoverMember: recoverDropPort,
+ }
+}
+
+func injectLatency(m *member) error {
+ if err := m.Agent.SetLatency(slowNetworkLatency, randomVariation); err != nil {
+ m.Agent.RemoveLatency()
+ return err
+ }
+ return nil
+}
+
+func recoverLatency(m *member) error {
+ if err := m.Agent.RemoveLatency(); err != nil {
+ return err
+ }
+ time.Sleep(waitRecover)
+ return nil
+}
+
+func newFailureSlowNetworkOneMember() failure {
+ desc := fmt.Sprintf("slow down one member's network by adding %d ms latency", slowNetworkLatency)
+ return &failureOne{
+ description: description(desc),
+ injectMember: injectLatency,
+ recoverMember: recoverLatency,
+ }
+}
+
+func newFailureSlowNetworkLeader() failure {
+ desc := fmt.Sprintf("slow down leader's network by adding %d ms latency", slowNetworkLatency)
+ ff := failureByFunc{
+ description: description(desc),
+ injectMember: injectLatency,
+ recoverMember: recoverLatency,
+ }
+ return &failureLeader{ff, 0}
+}
+
+func newFailureSlowNetworkAll() failure {
+ return &failureAll{
+ description: "slow down all members' network",
+ injectMember: injectLatency,
+ recoverMember: recoverLatency,
+ }
+}
+
+func newFailureNop() failure {
+ return &failureNop{
+ description: "no failure",
+ }
+}
+
+func newFailureExternal(scriptPath string) failure {
+ return &failureExternal{
+ description: fmt.Sprintf("external fault injector (script: %s)", scriptPath),
+ scriptPath: scriptPath,
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/http.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/http.go
new file mode 100644
index 00000000..a9d9a30a
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/http.go
@@ -0,0 +1,44 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "encoding/json"
+ "net/http"
+)
+
+type statusHandler struct {
+ status *Status
+}
+
+func (sh statusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "application/json")
+ en := json.NewEncoder(w)
+
+ sh.status.mu.Lock()
+ defer sh.status.mu.Unlock()
+
+ if err := en.Encode(Status{
+ Since: sh.status.Since,
+ Failures: sh.status.Failures,
+ RoundLimit: sh.status.RoundLimit,
+ Cluster: sh.status.cluster.Status(),
+ cluster: sh.status.cluster,
+ Round: sh.status.Round,
+ Case: sh.status.Case,
+ }); err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/key_stresser.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/key_stresser.go
new file mode 100644
index 00000000..1e351b7e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/key_stresser.go
@@ -0,0 +1,248 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "math/rand"
+ "sync"
+ "sync/atomic"
+ "time"
+
+ "golang.org/x/net/context" // grpc does a comparison on context.Cancel; can't use "context" package
+ "golang.org/x/time/rate"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/transport"
+
+ "github.com/coreos/etcd/etcdserver"
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+)
+
+type keyStresser struct {
+ Endpoint string
+
+ keyLargeSize int
+ keySize int
+ keySuffixRange int
+
+ N int
+
+ rateLimiter *rate.Limiter
+
+ wg sync.WaitGroup
+
+ cancel func()
+ conn *grpc.ClientConn
+ // atomicModifiedKeys records the number of keys created and deleted by the stresser.
+ atomicModifiedKeys int64
+
+ stressTable *stressTable
+}
+
+func (s *keyStresser) Stress() error {
+ // TODO: add backoff option
+ conn, err := grpc.Dial(s.Endpoint, grpc.WithInsecure())
+ if err != nil {
+ return fmt.Errorf("%v (%s)", err, s.Endpoint)
+ }
+ ctx, cancel := context.WithCancel(context.Background())
+
+ s.wg.Add(s.N)
+ s.conn = conn
+ s.cancel = cancel
+
+ kvc := pb.NewKVClient(conn)
+
+ var stressEntries = []stressEntry{
+ {weight: 0.7, f: newStressPut(kvc, s.keySuffixRange, s.keySize)},
+ {
+ weight: 0.7 * float32(s.keySize) / float32(s.keyLargeSize),
+ f: newStressPut(kvc, s.keySuffixRange, s.keyLargeSize),
+ },
+ {weight: 0.07, f: newStressRange(kvc, s.keySuffixRange)},
+ {weight: 0.07, f: newStressRangeInterval(kvc, s.keySuffixRange)},
+ {weight: 0.07, f: newStressDelete(kvc, s.keySuffixRange)},
+ {weight: 0.07, f: newStressDeleteInterval(kvc, s.keySuffixRange)},
+ }
+ s.stressTable = createStressTable(stressEntries)
+
+ for i := 0; i < s.N; i++ {
+ go s.run(ctx)
+ }
+
+ plog.Infof("keyStresser %q is started", s.Endpoint)
+ return nil
+}
+
+func (s *keyStresser) run(ctx context.Context) {
+ defer s.wg.Done()
+
+ for {
+ if err := s.rateLimiter.Wait(ctx); err == context.Canceled {
+ return
+ }
+
+ // TODO: 10-second is enough timeout to cover leader failure
+ // and immediate leader election. Find out what other cases this
+ // could be timed out.
+ sctx, scancel := context.WithTimeout(ctx, 10*time.Second)
+ err, modifiedKeys := s.stressTable.choose()(sctx)
+ scancel()
+ if err == nil {
+ atomic.AddInt64(&s.atomicModifiedKeys, modifiedKeys)
+ continue
+ }
+
+ switch grpc.ErrorDesc(err) {
+ case context.DeadlineExceeded.Error():
+ // This retries when request is triggered at the same time as
+ // leader failure. When we terminate the leader, the request to
+ // that leader cannot be processed, and times out. Also requests
+ // to followers cannot be forwarded to the old leader, so timing out
+ // as well. We want to keep stressing until the cluster elects a
+ // new leader and start processing requests again.
+ case etcdserver.ErrTimeoutDueToLeaderFail.Error(), etcdserver.ErrTimeout.Error():
+ // This retries when request is triggered at the same time as
+ // leader failure and follower nodes receive time out errors
+ // from losing their leader. Followers should retry to connect
+ // to the new leader.
+ case etcdserver.ErrStopped.Error():
+ // one of the etcd nodes stopped from failure injection
+ case transport.ErrConnClosing.Desc:
+ // server closed the transport (failure injected node)
+ case rpctypes.ErrNotCapable.Error():
+ // capability check has not been done (in the beginning)
+ case rpctypes.ErrTooManyRequests.Error():
+ // hitting the recovering member.
+ case context.Canceled.Error():
+ // from stresser.Cancel method:
+ return
+ case grpc.ErrClientConnClosing.Error():
+ // from stresser.Cancel method:
+ return
+ default:
+ plog.Errorf("keyStresser %v exited with error (%v)", s.Endpoint, err)
+ return
+ }
+ }
+}
+
+func (s *keyStresser) Pause() {
+ s.Close()
+}
+
+func (s *keyStresser) Close() {
+ s.cancel()
+ s.conn.Close()
+ s.wg.Wait()
+ plog.Infof("keyStresser %q is closed", s.Endpoint)
+
+}
+
+func (s *keyStresser) ModifiedKeys() int64 {
+ return atomic.LoadInt64(&s.atomicModifiedKeys)
+}
+
+func (s *keyStresser) Checker() Checker { return nil }
+
+type stressFunc func(ctx context.Context) (err error, modifiedKeys int64)
+
+type stressEntry struct {
+ weight float32
+ f stressFunc
+}
+
+type stressTable struct {
+ entries []stressEntry
+ sumWeights float32
+}
+
+func createStressTable(entries []stressEntry) *stressTable {
+ st := stressTable{entries: entries}
+ for _, entry := range st.entries {
+ st.sumWeights += entry.weight
+ }
+ return &st
+}
+
+func (st *stressTable) choose() stressFunc {
+ v := rand.Float32() * st.sumWeights
+ var sum float32
+ var idx int
+ for i := range st.entries {
+ sum += st.entries[i].weight
+ if sum >= v {
+ idx = i
+ break
+ }
+ }
+ return st.entries[idx].f
+}
+
+func newStressPut(kvc pb.KVClient, keySuffixRange, keySize int) stressFunc {
+ return func(ctx context.Context) (error, int64) {
+ _, err := kvc.Put(ctx, &pb.PutRequest{
+ Key: []byte(fmt.Sprintf("foo%016x", rand.Intn(keySuffixRange))),
+ Value: randBytes(keySize),
+ }, grpc.FailFast(false))
+ return err, 1
+ }
+}
+
+func newStressRange(kvc pb.KVClient, keySuffixRange int) stressFunc {
+ return func(ctx context.Context) (error, int64) {
+ _, err := kvc.Range(ctx, &pb.RangeRequest{
+ Key: []byte(fmt.Sprintf("foo%016x", rand.Intn(keySuffixRange))),
+ }, grpc.FailFast(false))
+ return err, 0
+ }
+}
+
+func newStressRangeInterval(kvc pb.KVClient, keySuffixRange int) stressFunc {
+ return func(ctx context.Context) (error, int64) {
+ start := rand.Intn(keySuffixRange)
+ end := start + 500
+ _, err := kvc.Range(ctx, &pb.RangeRequest{
+ Key: []byte(fmt.Sprintf("foo%016x", start)),
+ RangeEnd: []byte(fmt.Sprintf("foo%016x", end)),
+ }, grpc.FailFast(false))
+ return err, 0
+ }
+}
+
+func newStressDelete(kvc pb.KVClient, keySuffixRange int) stressFunc {
+ return func(ctx context.Context) (error, int64) {
+ _, err := kvc.DeleteRange(ctx, &pb.DeleteRangeRequest{
+ Key: []byte(fmt.Sprintf("foo%016x", rand.Intn(keySuffixRange))),
+ }, grpc.FailFast(false))
+ return err, 1
+ }
+}
+
+func newStressDeleteInterval(kvc pb.KVClient, keySuffixRange int) stressFunc {
+ return func(ctx context.Context) (error, int64) {
+ start := rand.Intn(keySuffixRange)
+ end := start + 500
+ resp, err := kvc.DeleteRange(ctx, &pb.DeleteRangeRequest{
+ Key: []byte(fmt.Sprintf("foo%016x", start)),
+ RangeEnd: []byte(fmt.Sprintf("foo%016x", end)),
+ }, grpc.FailFast(false))
+ if err == nil {
+ return nil, resp.Deleted
+ }
+ return err, 0
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/lease_stresser.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/lease_stresser.go
new file mode 100644
index 00000000..0767ccc2
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/lease_stresser.go
@@ -0,0 +1,381 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "math/rand"
+ "sync"
+ "sync/atomic"
+
+ "time"
+
+ "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "golang.org/x/net/context"
+ "golang.org/x/time/rate"
+ "google.golang.org/grpc"
+)
+
+const (
+ // time to live for lease
+ TTL = 120
+ TTLShort = 2
+)
+
+type leaseStresser struct {
+ endpoint string
+ cancel func()
+ conn *grpc.ClientConn
+ kvc pb.KVClient
+ lc pb.LeaseClient
+ ctx context.Context
+
+ rateLimiter *rate.Limiter
+ // atomicModifiedKey records the number of keys created and deleted during a test case
+ atomicModifiedKey int64
+ numLeases int
+ keysPerLease int
+
+ aliveLeases *atomicLeases
+ revokedLeases *atomicLeases
+ shortLivedLeases *atomicLeases
+
+ runWg sync.WaitGroup
+ aliveWg sync.WaitGroup
+}
+
+type atomicLeases struct {
+ // rwLock is used to protect read/write access of leases map
+ // which are accessed and modified by different go routines.
+ rwLock sync.RWMutex
+ leases map[int64]time.Time
+}
+
+func (al *atomicLeases) add(leaseID int64, t time.Time) {
+ al.rwLock.Lock()
+ al.leases[leaseID] = t
+ al.rwLock.Unlock()
+}
+
+func (al *atomicLeases) update(leaseID int64, t time.Time) {
+ al.rwLock.Lock()
+ _, ok := al.leases[leaseID]
+ if ok {
+ al.leases[leaseID] = t
+ }
+ al.rwLock.Unlock()
+}
+
+func (al *atomicLeases) read(leaseID int64) (rv time.Time, ok bool) {
+ al.rwLock.RLock()
+ rv, ok = al.leases[leaseID]
+ al.rwLock.RUnlock()
+ return rv, ok
+}
+
+func (al *atomicLeases) remove(leaseID int64) {
+ al.rwLock.Lock()
+ delete(al.leases, leaseID)
+ al.rwLock.Unlock()
+}
+
+func (al *atomicLeases) getLeasesMap() map[int64]time.Time {
+ leasesCopy := make(map[int64]time.Time)
+ al.rwLock.RLock()
+ for k, v := range al.leases {
+ leasesCopy[k] = v
+ }
+ al.rwLock.RUnlock()
+ return leasesCopy
+}
+
+func (ls *leaseStresser) setupOnce() error {
+ if ls.aliveLeases != nil {
+ return nil
+ }
+ if ls.numLeases == 0 {
+ panic("expect numLeases to be set")
+ }
+ if ls.keysPerLease == 0 {
+ panic("expect keysPerLease to be set")
+ }
+
+ ls.aliveLeases = &atomicLeases{leases: make(map[int64]time.Time)}
+
+ return nil
+}
+
+func (ls *leaseStresser) Stress() error {
+ plog.Infof("lease Stresser %v starting ...", ls.endpoint)
+ if err := ls.setupOnce(); err != nil {
+ return err
+ }
+
+ conn, err := grpc.Dial(ls.endpoint, grpc.WithInsecure(), grpc.WithBackoffMaxDelay(1*time.Second))
+ if err != nil {
+ return fmt.Errorf("%v (%s)", err, ls.endpoint)
+ }
+ ls.conn = conn
+ ls.kvc = pb.NewKVClient(conn)
+ ls.lc = pb.NewLeaseClient(conn)
+ ls.revokedLeases = &atomicLeases{leases: make(map[int64]time.Time)}
+ ls.shortLivedLeases = &atomicLeases{leases: make(map[int64]time.Time)}
+
+ ctx, cancel := context.WithCancel(context.Background())
+ ls.cancel = cancel
+ ls.ctx = ctx
+
+ ls.runWg.Add(1)
+ go ls.run()
+ return nil
+}
+
+func (ls *leaseStresser) run() {
+ defer ls.runWg.Done()
+ ls.restartKeepAlives()
+ for {
+ // the number of keys created and deleted is roughly 2x the number of created keys for an iteration.
+ // the rateLimiter therefore consumes 2x ls.numLeases*ls.keysPerLease tokens where each token represents a create/delete operation for key.
+ err := ls.rateLimiter.WaitN(ls.ctx, 2*ls.numLeases*ls.keysPerLease)
+ if err == context.Canceled {
+ return
+ }
+ plog.Debugf("creating lease on %v", ls.endpoint)
+ ls.createLeases()
+ plog.Debugf("done creating lease on %v", ls.endpoint)
+ plog.Debugf("dropping lease on %v", ls.endpoint)
+ ls.randomlyDropLeases()
+ plog.Debugf("done dropping lease on %v", ls.endpoint)
+ }
+}
+
+func (ls *leaseStresser) restartKeepAlives() {
+ for leaseID := range ls.aliveLeases.getLeasesMap() {
+ ls.aliveWg.Add(1)
+ go func(id int64) {
+ ls.keepLeaseAlive(id)
+ }(leaseID)
+ }
+}
+
+func (ls *leaseStresser) createLeases() {
+ ls.createAliveLeases()
+ ls.createShortLivedLeases()
+}
+
+func (ls *leaseStresser) createAliveLeases() {
+ neededLeases := ls.numLeases - len(ls.aliveLeases.getLeasesMap())
+ var wg sync.WaitGroup
+ for i := 0; i < neededLeases; i++ {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ leaseID, err := ls.createLeaseWithKeys(TTL)
+ if err != nil {
+ plog.Debugf("lease creation error: (%v)", err)
+ return
+ }
+ ls.aliveLeases.add(leaseID, time.Now())
+ // keep track of all the keep lease alive go routines
+ ls.aliveWg.Add(1)
+ go ls.keepLeaseAlive(leaseID)
+ }()
+ }
+ wg.Wait()
+}
+
+func (ls *leaseStresser) createShortLivedLeases() {
+ // one round of createLeases() might not create all the short lived leases we want due to falures.
+ // thus, we want to create remaining short lived leases in the future round.
+ neededLeases := ls.numLeases - len(ls.shortLivedLeases.getLeasesMap())
+ var wg sync.WaitGroup
+ for i := 0; i < neededLeases; i++ {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ leaseID, err := ls.createLeaseWithKeys(TTLShort)
+ if err != nil {
+ return
+ }
+ ls.shortLivedLeases.add(leaseID, time.Now())
+ }()
+ }
+ wg.Wait()
+}
+
+func (ls *leaseStresser) createLeaseWithKeys(ttl int64) (int64, error) {
+ leaseID, err := ls.createLease(ttl)
+ if err != nil {
+ plog.Debugf("lease creation error: (%v)", err)
+ return -1, err
+ }
+ plog.Debugf("lease %v created ", leaseID)
+ if err := ls.attachKeysWithLease(leaseID); err != nil {
+ return -1, err
+ }
+ return leaseID, nil
+}
+
+func (ls *leaseStresser) randomlyDropLeases() {
+ var wg sync.WaitGroup
+ for l := range ls.aliveLeases.getLeasesMap() {
+ wg.Add(1)
+ go func(leaseID int64) {
+ defer wg.Done()
+ dropped, err := ls.randomlyDropLease(leaseID)
+ // if randomlyDropLease encountered an error such as context is cancelled, remove the lease from aliveLeases
+ // because we can't tell whether the lease is dropped or not.
+ if err != nil {
+ plog.Debugf("drop lease %v has failed error (%v)", leaseID, err)
+ ls.aliveLeases.remove(leaseID)
+ return
+ }
+ if !dropped {
+ return
+ }
+ plog.Debugf("lease %v dropped", leaseID)
+ ls.revokedLeases.add(leaseID, time.Now())
+ ls.aliveLeases.remove(leaseID)
+ }(l)
+ }
+ wg.Wait()
+}
+
+func (ls *leaseStresser) createLease(ttl int64) (int64, error) {
+ resp, err := ls.lc.LeaseGrant(ls.ctx, &pb.LeaseGrantRequest{TTL: ttl})
+ if err != nil {
+ return -1, err
+ }
+ return resp.ID, nil
+}
+
+func (ls *leaseStresser) keepLeaseAlive(leaseID int64) {
+ defer ls.aliveWg.Done()
+ ctx, cancel := context.WithCancel(ls.ctx)
+ stream, err := ls.lc.LeaseKeepAlive(ctx)
+ defer func() { cancel() }()
+ for {
+ select {
+ case <-time.After(500 * time.Millisecond):
+ case <-ls.ctx.Done():
+ plog.Debugf("keepLeaseAlive lease %v context canceled ", leaseID)
+ // it is possible that lease expires at invariant checking phase but not at keepLeaseAlive() phase.
+ // this scenerio is possible when alive lease is just about to expire when keepLeaseAlive() exists and expires at invariant checking phase.
+ // to circumvent that scenerio, we check each lease before keepalive loop exist to see if it has been renewed in last TTL/2 duration.
+ // if it is renewed, this means that invariant checking have at least ttl/2 time before lease exipres which is long enough for the checking to finish.
+ // if it is not renewed, we remove the lease from the alive map so that the lease doesn't exipre during invariant checking
+ renewTime, ok := ls.aliveLeases.read(leaseID)
+ if ok && renewTime.Add(TTL/2*time.Second).Before(time.Now()) {
+ ls.aliveLeases.remove(leaseID)
+ plog.Debugf("keepLeaseAlive lease %v has not been renewed. drop it.", leaseID)
+ }
+ return
+ }
+
+ if err != nil {
+ plog.Debugf("keepLeaseAlive lease %v creates stream error: (%v)", leaseID, err)
+ cancel()
+ ctx, cancel = context.WithCancel(ls.ctx)
+ stream, err = ls.lc.LeaseKeepAlive(ctx)
+ continue
+ }
+ err = stream.Send(&pb.LeaseKeepAliveRequest{ID: leaseID})
+ plog.Debugf("keepLeaseAlive stream sends lease %v keepalive request", leaseID)
+ if err != nil {
+ plog.Debugf("keepLeaseAlive stream sends lease %v error (%v)", leaseID, err)
+ continue
+ }
+ leaseRenewTime := time.Now()
+ plog.Debugf("keepLeaseAlive stream sends lease %v keepalive request succeed", leaseID)
+ respRC, err := stream.Recv()
+ if err != nil {
+ plog.Debugf("keepLeaseAlive stream receives lease %v stream error (%v)", leaseID, err)
+ continue
+ }
+ // lease expires after TTL become 0
+ // don't send keepalive if the lease has expired
+ if respRC.TTL <= 0 {
+ plog.Debugf("keepLeaseAlive stream receives lease %v has TTL <= 0", leaseID)
+ ls.aliveLeases.remove(leaseID)
+ return
+ }
+ // renew lease timestamp only if lease is present
+ plog.Debugf("keepLeaseAlive renew lease %v", leaseID)
+ ls.aliveLeases.update(leaseID, leaseRenewTime)
+ }
+}
+
+// attachKeysWithLease function attaches keys to the lease.
+// the format of key is the concat of leaseID + '_' + '<order of key creation>'
+// e.g 5186835655248304152_0 for first created key and 5186835655248304152_1 for second created key
+func (ls *leaseStresser) attachKeysWithLease(leaseID int64) error {
+ var txnPuts []*pb.RequestOp
+ for j := 0; j < ls.keysPerLease; j++ {
+ txnput := &pb.RequestOp{Request: &pb.RequestOp_RequestPut{RequestPut: &pb.PutRequest{Key: []byte(fmt.Sprintf("%d%s%d", leaseID, "_", j)),
+ Value: []byte(fmt.Sprintf("bar")), Lease: leaseID}}}
+ txnPuts = append(txnPuts, txnput)
+ }
+ // keep retrying until lease is not found or ctx is being canceled
+ for ls.ctx.Err() == nil {
+ txn := &pb.TxnRequest{Success: txnPuts}
+ _, err := ls.kvc.Txn(ls.ctx, txn)
+ if err == nil {
+ // since all created keys will be deleted too, the number of operations on keys will be roughly 2x the number of created keys
+ atomic.AddInt64(&ls.atomicModifiedKey, 2*int64(ls.keysPerLease))
+ return nil
+ }
+ if rpctypes.Error(err) == rpctypes.ErrLeaseNotFound {
+ return err
+ }
+ }
+ return ls.ctx.Err()
+}
+
+// randomlyDropLease drops the lease only when the rand.Int(2) returns 1.
+// This creates a 50/50 percents chance of dropping a lease
+func (ls *leaseStresser) randomlyDropLease(leaseID int64) (bool, error) {
+ if rand.Intn(2) != 0 {
+ return false, nil
+ }
+ // keep retrying until a lease is dropped or ctx is being canceled
+ for ls.ctx.Err() == nil {
+ _, err := ls.lc.LeaseRevoke(ls.ctx, &pb.LeaseRevokeRequest{ID: leaseID})
+ if err == nil || rpctypes.Error(err) == rpctypes.ErrLeaseNotFound {
+ return true, nil
+ }
+ }
+ plog.Debugf("randomlyDropLease error: (%v)", ls.ctx.Err())
+ return false, ls.ctx.Err()
+}
+
+func (ls *leaseStresser) Pause() {
+ ls.Close()
+}
+
+func (ls *leaseStresser) Close() {
+ plog.Debugf("lease stresser %q is closing...", ls.endpoint)
+ ls.cancel()
+ ls.runWg.Wait()
+ ls.aliveWg.Wait()
+ ls.conn.Close()
+ plog.Infof("lease stresser %q is closed", ls.endpoint)
+}
+
+func (ls *leaseStresser) ModifiedKeys() int64 {
+ return atomic.LoadInt64(&ls.atomicModifiedKey)
+}
+
+func (ls *leaseStresser) Checker() Checker { return &leaseChecker{endpoint: ls.endpoint, ls: ls} }
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/main.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/main.go
new file mode 100644
index 00000000..16d55bbf
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/main.go
@@ -0,0 +1,211 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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"
+ "net/http"
+ "os"
+ "strings"
+
+ "github.com/coreos/etcd/pkg/debugutil"
+
+ "github.com/coreos/pkg/capnslog"
+ "github.com/prometheus/client_golang/prometheus"
+ "golang.org/x/time/rate"
+)
+
+var plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "etcd-tester")
+
+const (
+ defaultClientPort = 2379
+ defaultPeerPort = 2380
+ defaultFailpointPort = 2381
+)
+
+func main() {
+ endpointStr := flag.String("agent-endpoints", "localhost:9027", "HTTP RPC endpoints of agents. Do not specify the schema.")
+ clientPorts := flag.String("client-ports", "", "etcd client port for each agent endpoint")
+ peerPorts := flag.String("peer-ports", "", "etcd peer port for each agent endpoint")
+ failpointPorts := flag.String("failpoint-ports", "", "etcd failpoint port for each agent endpoint")
+
+ stressKeyLargeSize := flag.Uint("stress-key-large-size", 32*1024+1, "the size of each large key written into etcd.")
+ stressKeySize := flag.Uint("stress-key-size", 100, "the size of each small key written into etcd.")
+ stressKeySuffixRange := flag.Uint("stress-key-count", 250000, "the count of key range written into etcd.")
+ limit := flag.Int("limit", -1, "the limit of rounds to run failure set (-1 to run without limits).")
+ exitOnFailure := flag.Bool("exit-on-failure", false, "exit tester on first failure")
+ stressQPS := flag.Int("stress-qps", 10000, "maximum number of stresser requests per second.")
+ schedCases := flag.String("schedule-cases", "", "test case schedule")
+ consistencyCheck := flag.Bool("consistency-check", true, "true to check consistency (revision, hash)")
+ stresserType := flag.String("stresser", "keys,lease", "comma separated list of stressers (keys, lease, v2keys, nop, election-runner, watch-runner, lock-racer-runner, lease-runner).")
+ etcdRunnerPath := flag.String("etcd-runner", "", "specify a path of etcd runner binary")
+ failureTypes := flag.String("failures", "default,failpoints", "specify failures (concat of \"default\" and \"failpoints\").")
+ failpoints := flag.String("failpoints", `panic("etcd-tester")`, `comma separated list of failpoint terms to inject (e.g. 'panic("etcd-tester"),1*sleep(1000)')`)
+ externalFailures := flag.String("external-failures", "", "specify a path of script for enabling/disabling an external fault injector")
+ enablePprof := flag.Bool("enable-pprof", false, "true to enable pprof")
+ flag.Parse()
+
+ eps := strings.Split(*endpointStr, ",")
+ cports := portsFromArg(*clientPorts, len(eps), defaultClientPort)
+ pports := portsFromArg(*peerPorts, len(eps), defaultPeerPort)
+ fports := portsFromArg(*failpointPorts, len(eps), defaultFailpointPort)
+ agents := make([]agentConfig, len(eps))
+
+ for i := range eps {
+ agents[i].endpoint = eps[i]
+ agents[i].clientPort = cports[i]
+ agents[i].peerPort = pports[i]
+ agents[i].failpointPort = fports[i]
+ }
+
+ c := &cluster{agents: agents}
+ if err := c.bootstrap(); err != nil {
+ plog.Fatal(err)
+ }
+ defer c.Terminate()
+
+ // ensure cluster is fully booted to know failpoints are available
+ c.WaitHealth()
+
+ var failures []failure
+
+ if failureTypes != nil && *failureTypes != "" {
+ types, failpoints := strings.Split(*failureTypes, ","), strings.Split(*failpoints, ",")
+ failures = makeFailures(types, failpoints, c)
+ }
+
+ if externalFailures != nil && *externalFailures != "" {
+ if len(failures) != 0 {
+ plog.Errorf("specify only one of -failures or -external-failures")
+ os.Exit(1)
+ }
+ failures = append(failures, newFailureExternal(*externalFailures))
+ }
+
+ if len(failures) == 0 {
+ plog.Infof("no failures\n")
+ failures = append(failures, newFailureNop())
+ }
+
+ schedule := failures
+ if schedCases != nil && *schedCases != "" {
+ cases := strings.Split(*schedCases, " ")
+ schedule = make([]failure, len(cases))
+ for i := range cases {
+ caseNum := 0
+ n, err := fmt.Sscanf(cases[i], "%d", &caseNum)
+ if n == 0 || err != nil {
+ plog.Fatalf(`couldn't parse case "%s" (%v)`, cases[i], err)
+ }
+ schedule[i] = failures[caseNum]
+ }
+ }
+
+ scfg := stressConfig{
+ rateLimiter: rate.NewLimiter(rate.Limit(*stressQPS), *stressQPS),
+ keyLargeSize: int(*stressKeyLargeSize),
+ keySize: int(*stressKeySize),
+ keySuffixRange: int(*stressKeySuffixRange),
+ numLeases: 10,
+ keysPerLease: 10,
+
+ etcdRunnerPath: *etcdRunnerPath,
+ }
+
+ t := &tester{
+ failures: schedule,
+ cluster: c,
+ limit: *limit,
+ exitOnFailure: *exitOnFailure,
+
+ scfg: scfg,
+ stresserType: *stresserType,
+ doChecks: *consistencyCheck,
+ }
+
+ sh := statusHandler{status: &t.status}
+ http.Handle("/status", sh)
+ http.Handle("/metrics", prometheus.Handler())
+
+ if *enablePprof {
+ for p, h := range debugutil.PProfHandlers() {
+ http.Handle(p, h)
+ }
+ }
+
+ go func() { plog.Fatal(http.ListenAndServe(":9028", nil)) }()
+
+ t.runLoop()
+}
+
+// portsFromArg converts a comma separated list into a slice of ints
+func portsFromArg(arg string, n, defaultPort int) []int {
+ ret := make([]int, n)
+ if len(arg) == 0 {
+ for i := range ret {
+ ret[i] = defaultPort
+ }
+ return ret
+ }
+ s := strings.Split(arg, ",")
+ if len(s) != n {
+ fmt.Printf("expected %d ports, got %d (%s)\n", n, len(s), arg)
+ os.Exit(1)
+ }
+ for i := range s {
+ if _, err := fmt.Sscanf(s[i], "%d", &ret[i]); err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+ }
+ return ret
+}
+
+func makeFailures(types, failpoints []string, c *cluster) []failure {
+ var failures []failure
+ for i := range types {
+ switch types[i] {
+ case "default":
+ defaultFailures := []failure{
+ newFailureKillAll(),
+ newFailureKillMajority(),
+ newFailureKillOne(),
+ newFailureKillLeader(),
+ newFailureKillOneForLongTime(),
+ newFailureKillLeaderForLongTime(),
+ newFailureIsolate(),
+ newFailureIsolateAll(),
+ newFailureSlowNetworkOneMember(),
+ newFailureSlowNetworkLeader(),
+ newFailureSlowNetworkAll(),
+ }
+ failures = append(failures, defaultFailures...)
+
+ case "failpoints":
+ fpFailures, fperr := failpointFailures(c, failpoints)
+ if len(fpFailures) == 0 {
+ plog.Infof("no failpoints found (%v)", fperr)
+ }
+ failures = append(failures, fpFailures...)
+
+ default:
+ plog.Errorf("unknown failure: %s\n", types[i])
+ os.Exit(1)
+ }
+ }
+
+ return failures
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/member.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/member.go
new file mode 100644
index 00000000..7954e534
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/member.go
@@ -0,0 +1,185 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "net"
+ "net/url"
+ "time"
+
+ "golang.org/x/net/context"
+ "google.golang.org/grpc"
+
+ "github.com/coreos/etcd/clientv3"
+ pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+ "github.com/coreos/etcd/tools/functional-tester/etcd-agent/client"
+)
+
+type member struct {
+ Agent client.Agent
+ Endpoint string
+ Name string
+ ClientURL string
+ PeerURL string
+ FailpointURL string
+}
+
+func (m *member) ClusterEntry() string { return m.Name + "=" + m.PeerURL }
+
+func (m *member) Flags() []string {
+ return []string{
+ "--name", m.Name,
+ "--listen-client-urls", m.ClientURL,
+ "--advertise-client-urls", m.ClientURL,
+ "--listen-peer-urls", m.PeerURL,
+ "--initial-advertise-peer-urls", m.PeerURL,
+ "--initial-cluster-state", "new",
+ }
+}
+
+func (m *member) CheckCompact(rev int64) error {
+ cli, err := m.newClientV3()
+ if err != nil {
+ return fmt.Errorf("%v (endpoint %s)", err, m.ClientURL)
+ }
+ defer cli.Close()
+
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ wch := cli.Watch(ctx, "\x00", clientv3.WithFromKey(), clientv3.WithRev(rev-1))
+ wr, ok := <-wch
+ cancel()
+
+ if !ok {
+ return fmt.Errorf("watch channel terminated (endpoint %s)", m.ClientURL)
+ }
+ if wr.CompactRevision != rev {
+ return fmt.Errorf("got compact revision %v, wanted %v (endpoint %s)", wr.CompactRevision, rev, m.ClientURL)
+ }
+
+ return nil
+}
+
+func (m *member) Defrag() error {
+ plog.Printf("defragmenting %s\n", m.ClientURL)
+ cli, err := m.newClientV3()
+ if err != nil {
+ return err
+ }
+ defer cli.Close()
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
+ _, err = cli.Defragment(ctx, m.ClientURL)
+ cancel()
+ if err != nil {
+ return err
+ }
+ plog.Printf("defragmented %s\n", m.ClientURL)
+ return nil
+}
+
+func (m *member) RevHash() (int64, int64, error) {
+ conn, err := m.dialGRPC()
+ if err != nil {
+ return 0, 0, err
+ }
+ mt := pb.NewMaintenanceClient(conn)
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ resp, err := mt.Hash(ctx, &pb.HashRequest{}, grpc.FailFast(false))
+ cancel()
+ conn.Close()
+
+ if err != nil {
+ return 0, 0, err
+ }
+
+ return resp.Header.Revision, int64(resp.Hash), nil
+}
+
+func (m *member) Rev(ctx context.Context) (int64, error) {
+ cli, err := m.newClientV3()
+ if err != nil {
+ return 0, err
+ }
+ defer cli.Close()
+ resp, err := cli.Status(ctx, m.ClientURL)
+ if err != nil {
+ return 0, err
+ }
+ return resp.Header.Revision, nil
+}
+
+func (m *member) IsLeader() (bool, error) {
+ cli, err := m.newClientV3()
+ if err != nil {
+ return false, err
+ }
+ defer cli.Close()
+ resp, err := cli.Status(context.Background(), m.ClientURL)
+ if err != nil {
+ return false, err
+ }
+ return resp.Header.MemberId == resp.Leader, nil
+}
+
+func (m *member) SetHealthKeyV3() error {
+ cli, err := m.newClientV3()
+ if err != nil {
+ return fmt.Errorf("%v (%s)", err, m.ClientURL)
+ }
+ defer cli.Close()
+ // give enough time-out in case expensive requests (range/delete) are pending
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ _, err = cli.Put(ctx, "health", "good")
+ cancel()
+ if err != nil {
+ return fmt.Errorf("%v (%s)", err, m.ClientURL)
+ }
+ return nil
+}
+
+func (m *member) newClientV3() (*clientv3.Client, error) {
+ return clientv3.New(clientv3.Config{
+ Endpoints: []string{m.ClientURL},
+ DialTimeout: 5 * time.Second,
+ })
+}
+
+func (m *member) dialGRPC() (*grpc.ClientConn, error) {
+ return grpc.Dial(m.grpcAddr(), grpc.WithInsecure(), grpc.WithTimeout(5*time.Second), grpc.WithBlock())
+}
+
+// grpcAddr gets the host from clientURL so it works with grpc.Dial()
+func (m *member) grpcAddr() string {
+ u, err := url.Parse(m.ClientURL)
+ if err != nil {
+ panic(err)
+ }
+ return u.Host
+}
+
+func (m *member) peerPort() (port int) {
+ u, err := url.Parse(m.PeerURL)
+ if err != nil {
+ panic(err)
+ }
+ _, portStr, err := net.SplitHostPort(u.Host)
+ if err != nil {
+ panic(err)
+ }
+ if _, err = fmt.Sscanf(portStr, "%d", &port); err != nil {
+ panic(err)
+ }
+ return port
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/metrics.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/metrics.go
new file mode 100644
index 00000000..7018ba57
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/metrics.go
@@ -0,0 +1,64 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 (
+ "github.com/prometheus/client_golang/prometheus"
+)
+
+var (
+ caseTotalCounter = prometheus.NewCounterVec(
+ prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "funcational_tester",
+ Name: "case_total",
+ Help: "Total number of finished test cases",
+ },
+ []string{"desc"},
+ )
+
+ caseFailedTotalCounter = prometheus.NewCounterVec(
+ prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "funcational_tester",
+ Name: "case_failed_total",
+ Help: "Total number of failed test cases",
+ },
+ []string{"desc"},
+ )
+
+ roundTotalCounter = prometheus.NewCounter(
+ prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "funcational_tester",
+ Name: "round_total",
+ Help: "Total number of finished test rounds.",
+ })
+
+ roundFailedTotalCounter = prometheus.NewCounter(
+ prometheus.CounterOpts{
+ Namespace: "etcd",
+ Subsystem: "funcational_tester",
+ Name: "round_failed_total",
+ Help: "Total number of failed test rounds.",
+ })
+)
+
+func init() {
+ prometheus.MustRegister(caseTotalCounter)
+ prometheus.MustRegister(caseFailedTotalCounter)
+ prometheus.MustRegister(roundTotalCounter)
+ prometheus.MustRegister(roundFailedTotalCounter)
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/status.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/status.go
new file mode 100644
index 00000000..3721c807
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/status.go
@@ -0,0 +1,57 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 (
+ "sync"
+ "time"
+)
+
+type Status struct {
+ Since time.Time
+ Failures []string
+ RoundLimit int
+
+ Cluster ClusterStatus
+ cluster *cluster
+
+ mu sync.Mutex // guards Round and Case
+ Round int
+ Case int
+}
+
+func (s *Status) setRound(r int) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ s.Round = r
+}
+
+func (s *Status) getRound() int {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ return s.Round
+}
+
+func (s *Status) setCase(c int) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ s.Case = c
+}
+
+func (s *Status) getCase() int {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ return s.Case
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/stresser.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/stresser.go
new file mode 100644
index 00000000..30e8d47d
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/stresser.go
@@ -0,0 +1,217 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "strings"
+ "sync"
+ "time"
+
+ "golang.org/x/time/rate"
+ "google.golang.org/grpc/grpclog"
+)
+
+func init() { grpclog.SetLogger(plog) }
+
+type Stresser interface {
+ // Stress starts to stress the etcd cluster
+ Stress() error
+ // Pause stops the stresser from sending requests to etcd. Resume by calling Stress.
+ Pause()
+ // Close releases all of the Stresser's resources.
+ Close()
+ // ModifiedKeys reports the number of keys created and deleted by stresser
+ ModifiedKeys() int64
+ // Checker returns an invariant checker for after the stresser is canceled.
+ Checker() Checker
+}
+
+// nopStresser implements Stresser that does nothing
+type nopStresser struct {
+ start time.Time
+ qps int
+}
+
+func (s *nopStresser) Stress() error { return nil }
+func (s *nopStresser) Pause() {}
+func (s *nopStresser) Close() {}
+func (s *nopStresser) ModifiedKeys() int64 {
+ return 0
+}
+func (s *nopStresser) Checker() Checker { return nil }
+
+// compositeStresser implements a Stresser that runs a slice of
+// stressers concurrently.
+type compositeStresser struct {
+ stressers []Stresser
+}
+
+func (cs *compositeStresser) Stress() error {
+ for i, s := range cs.stressers {
+ if err := s.Stress(); err != nil {
+ for j := 0; j < i; j++ {
+ cs.stressers[i].Close()
+ }
+ return err
+ }
+ }
+ return nil
+}
+
+func (cs *compositeStresser) Pause() {
+ var wg sync.WaitGroup
+ wg.Add(len(cs.stressers))
+ for i := range cs.stressers {
+ go func(s Stresser) {
+ defer wg.Done()
+ s.Pause()
+ }(cs.stressers[i])
+ }
+ wg.Wait()
+}
+
+func (cs *compositeStresser) Close() {
+ var wg sync.WaitGroup
+ wg.Add(len(cs.stressers))
+ for i := range cs.stressers {
+ go func(s Stresser) {
+ defer wg.Done()
+ s.Close()
+ }(cs.stressers[i])
+ }
+ wg.Wait()
+}
+
+func (cs *compositeStresser) ModifiedKeys() (modifiedKey int64) {
+ for _, stress := range cs.stressers {
+ modifiedKey += stress.ModifiedKeys()
+ }
+ return modifiedKey
+}
+
+func (cs *compositeStresser) Checker() Checker {
+ var chks []Checker
+ for _, s := range cs.stressers {
+ if chk := s.Checker(); chk != nil {
+ chks = append(chks, chk)
+ }
+ }
+ if len(chks) == 0 {
+ return nil
+ }
+ return newCompositeChecker(chks)
+}
+
+type stressConfig struct {
+ keyLargeSize int
+ keySize int
+ keySuffixRange int
+
+ numLeases int
+ keysPerLease int
+
+ rateLimiter *rate.Limiter
+
+ etcdRunnerPath string
+}
+
+// NewStresser creates stresser from a comma separated list of stresser types.
+func NewStresser(s string, sc *stressConfig, m *member) Stresser {
+ types := strings.Split(s, ",")
+ if len(types) > 1 {
+ stressers := make([]Stresser, len(types))
+ for i, stype := range types {
+ stressers[i] = NewStresser(stype, sc, m)
+ }
+ return &compositeStresser{stressers}
+ }
+ switch s {
+ case "nop":
+ return &nopStresser{start: time.Now(), qps: int(sc.rateLimiter.Limit())}
+ case "keys":
+ // TODO: Too intensive stressers can panic etcd member with
+ // 'out of memory' error. Put rate limits in server side.
+ return &keyStresser{
+ Endpoint: m.grpcAddr(),
+ keyLargeSize: sc.keyLargeSize,
+ keySize: sc.keySize,
+ keySuffixRange: sc.keySuffixRange,
+ N: 100,
+ rateLimiter: sc.rateLimiter,
+ }
+ case "v2keys":
+ return &v2Stresser{
+ Endpoint: m.ClientURL,
+ keySize: sc.keySize,
+ keySuffixRange: sc.keySuffixRange,
+ N: 100,
+ rateLimiter: sc.rateLimiter,
+ }
+ case "lease":
+ return &leaseStresser{
+ endpoint: m.grpcAddr(),
+ numLeases: sc.numLeases,
+ keysPerLease: sc.keysPerLease,
+ rateLimiter: sc.rateLimiter,
+ }
+ case "election-runner":
+ reqRate := 100
+ args := []string{
+ "election",
+ fmt.Sprintf("%v", time.Now().UnixNano()), // election name as current nano time
+ "--dial-timeout=10s",
+ "--endpoints", m.grpcAddr(),
+ "--total-client-connections=10",
+ "--rounds=0", // runs forever
+ "--req-rate", fmt.Sprintf("%v", reqRate),
+ }
+ return newRunnerStresser(sc.etcdRunnerPath, args, sc.rateLimiter, reqRate)
+ case "watch-runner":
+ reqRate := 100
+ args := []string{
+ "watcher",
+ "--prefix", fmt.Sprintf("%v", time.Now().UnixNano()), // prefix all keys with nano time
+ "--total-keys=1",
+ "--total-prefixes=1",
+ "--watch-per-prefix=1",
+ "--endpoints", m.grpcAddr(),
+ "--rounds=0", // runs forever
+ "--req-rate", fmt.Sprintf("%v", reqRate),
+ }
+ return newRunnerStresser(sc.etcdRunnerPath, args, sc.rateLimiter, reqRate)
+ case "lock-racer-runner":
+ reqRate := 100
+ args := []string{
+ "lock-racer",
+ fmt.Sprintf("%v", time.Now().UnixNano()), // locker name as current nano time
+ "--endpoints", m.grpcAddr(),
+ "--total-client-connections=10",
+ "--rounds=0", // runs forever
+ "--req-rate", fmt.Sprintf("%v", reqRate),
+ }
+ return newRunnerStresser(sc.etcdRunnerPath, args, sc.rateLimiter, reqRate)
+ case "lease-runner":
+ args := []string{
+ "lease-renewer",
+ "--ttl=30",
+ "--endpoints", m.grpcAddr(),
+ }
+ return newRunnerStresser(sc.etcdRunnerPath, args, sc.rateLimiter, 0)
+ default:
+ plog.Panicf("unknown stresser type: %s\n", s)
+ }
+ return nil // never reach here
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/tester.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/tester.go
new file mode 100644
index 00000000..6a0c72af
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/tester.go
@@ -0,0 +1,286 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "os"
+ "time"
+)
+
+type tester struct {
+ cluster *cluster
+ limit int
+ exitOnFailure bool
+
+ failures []failure
+ status Status
+ currentRevision int64
+
+ stresserType string
+ scfg stressConfig
+ doChecks bool
+
+ stresser Stresser
+ checker Checker
+}
+
+// compactQPS is rough number of compact requests per second.
+// Previous tests showed etcd can compact about 60,000 entries per second.
+const compactQPS = 50000
+
+func (tt *tester) runLoop() {
+ tt.status.Since = time.Now()
+ tt.status.RoundLimit = tt.limit
+ tt.status.cluster = tt.cluster
+ for _, f := range tt.failures {
+ tt.status.Failures = append(tt.status.Failures, f.Desc())
+ }
+
+ if err := tt.resetStressCheck(); err != nil {
+ plog.Errorf("%s failed to start stresser (%v)", tt.logPrefix(), err)
+ tt.failed()
+ return
+ }
+
+ var preModifiedKey int64
+ for round := 0; round < tt.limit || tt.limit == -1; round++ {
+ tt.status.setRound(round)
+ roundTotalCounter.Inc()
+
+ if err := tt.doRound(round); err != nil {
+ plog.Warningf("%s functional-tester returning with error (%v)", tt.logPrefix(), err)
+ if tt.cleanup() != nil {
+ return
+ }
+ // reset preModifiedKey after clean up
+ preModifiedKey = 0
+ continue
+ }
+ // -1 so that logPrefix doesn't print out 'case'
+ tt.status.setCase(-1)
+
+ revToCompact := max(0, tt.currentRevision-10000)
+ currentModifiedKey := tt.stresser.ModifiedKeys()
+ modifiedKey := currentModifiedKey - preModifiedKey
+ preModifiedKey = currentModifiedKey
+ timeout := 10 * time.Second
+ timeout += time.Duration(modifiedKey/compactQPS) * time.Second
+ plog.Infof("%s compacting %d modifications (timeout %v)", tt.logPrefix(), modifiedKey, timeout)
+ if err := tt.compact(revToCompact, timeout); err != nil {
+ plog.Warningf("%s functional-tester compact got error (%v)", tt.logPrefix(), err)
+ if tt.cleanup() != nil {
+ return
+ }
+ // reset preModifiedKey after clean up
+ preModifiedKey = 0
+ }
+ if round > 0 && round%500 == 0 { // every 500 rounds
+ if err := tt.defrag(); err != nil {
+ plog.Warningf("%s functional-tester returning with error (%v)", tt.logPrefix(), err)
+ tt.failed()
+ return
+ }
+ }
+ }
+
+ plog.Infof("%s functional-tester is finished", tt.logPrefix())
+}
+
+func (tt *tester) doRound(round int) error {
+ for j, f := range tt.failures {
+ caseTotalCounter.WithLabelValues(f.Desc()).Inc()
+ tt.status.setCase(j)
+
+ if err := tt.cluster.WaitHealth(); err != nil {
+ return fmt.Errorf("wait full health error: %v", err)
+ }
+ plog.Infof("%s injecting failure %q", tt.logPrefix(), f.Desc())
+ if err := f.Inject(tt.cluster, round); err != nil {
+ return fmt.Errorf("injection error: %v", err)
+ }
+ plog.Infof("%s injected failure", tt.logPrefix())
+
+ plog.Infof("%s recovering failure %q", tt.logPrefix(), f.Desc())
+ if err := f.Recover(tt.cluster, round); err != nil {
+ return fmt.Errorf("recovery error: %v", err)
+ }
+ plog.Infof("%s recovered failure", tt.logPrefix())
+ tt.pauseStresser()
+ plog.Infof("%s wait until cluster is healthy", tt.logPrefix())
+ if err := tt.cluster.WaitHealth(); err != nil {
+ return fmt.Errorf("wait full health error: %v", err)
+ }
+ plog.Infof("%s cluster is healthy", tt.logPrefix())
+
+ plog.Infof("%s checking consistency and invariant of cluster", tt.logPrefix())
+ if err := tt.checkConsistency(); err != nil {
+ return fmt.Errorf("tt.checkConsistency error (%v)", err)
+ }
+ plog.Infof("%s checking consistency and invariant of cluster done", tt.logPrefix())
+
+ plog.Infof("%s succeed!", tt.logPrefix())
+ }
+ return nil
+}
+
+func (tt *tester) updateRevision() error {
+ revs, _, err := tt.cluster.getRevisionHash()
+ for _, rev := range revs {
+ tt.currentRevision = rev
+ break // just need get one of the current revisions
+ }
+
+ plog.Infof("%s updated current revision to %d", tt.logPrefix(), tt.currentRevision)
+ return err
+}
+
+func (tt *tester) checkConsistency() (err error) {
+ defer func() {
+ if err != nil {
+ return
+ }
+ if err = tt.updateRevision(); err != nil {
+ plog.Warningf("%s functional-tester returning with tt.updateRevision error (%v)", tt.logPrefix(), err)
+ return
+ }
+ err = tt.startStresser()
+ }()
+ if err = tt.checker.Check(); err != nil {
+ plog.Infof("%s %v", tt.logPrefix(), err)
+ }
+ return err
+}
+
+func (tt *tester) compact(rev int64, timeout time.Duration) (err error) {
+ tt.pauseStresser()
+ defer func() {
+ if err == nil {
+ err = tt.startStresser()
+ }
+ }()
+
+ plog.Infof("%s compacting storage (current revision %d, compact revision %d)", tt.logPrefix(), tt.currentRevision, rev)
+ if err = tt.cluster.compactKV(rev, timeout); err != nil {
+ return err
+ }
+ plog.Infof("%s compacted storage (compact revision %d)", tt.logPrefix(), rev)
+
+ plog.Infof("%s checking compaction (compact revision %d)", tt.logPrefix(), rev)
+ if err = tt.cluster.checkCompact(rev); err != nil {
+ plog.Warningf("%s checkCompact error (%v)", tt.logPrefix(), err)
+ return err
+ }
+
+ plog.Infof("%s confirmed compaction (compact revision %d)", tt.logPrefix(), rev)
+ return nil
+}
+
+func (tt *tester) defrag() error {
+ plog.Infof("%s defragmenting...", tt.logPrefix())
+ if err := tt.cluster.defrag(); err != nil {
+ plog.Warningf("%s defrag error (%v)", tt.logPrefix(), err)
+ if cerr := tt.cleanup(); cerr != nil {
+ return fmt.Errorf("%s, %s", err, cerr)
+ }
+ return err
+ }
+ plog.Infof("%s defragmented...", tt.logPrefix())
+ return nil
+}
+
+func (tt *tester) logPrefix() string {
+ var (
+ rd = tt.status.getRound()
+ cs = tt.status.getCase()
+ prefix = fmt.Sprintf("[round#%d case#%d]", rd, cs)
+ )
+ if cs == -1 {
+ prefix = fmt.Sprintf("[round#%d]", rd)
+ }
+ return prefix
+}
+
+func (tt *tester) failed() {
+ if !tt.exitOnFailure {
+ return
+ }
+ plog.Warningf("%s exiting on failure", tt.logPrefix())
+ tt.cluster.Terminate()
+ os.Exit(2)
+}
+
+func (tt *tester) cleanup() error {
+ defer tt.failed()
+
+ roundFailedTotalCounter.Inc()
+ desc := "compact/defrag"
+ if tt.status.Case != -1 {
+ desc = tt.failures[tt.status.Case].Desc()
+ }
+ caseFailedTotalCounter.WithLabelValues(desc).Inc()
+
+ tt.closeStresser()
+ if err := tt.cluster.Cleanup(); err != nil {
+ plog.Warningf("%s cleanup error: %v", tt.logPrefix(), err)
+ return err
+ }
+ if err := tt.cluster.Reset(); err != nil {
+ plog.Warningf("%s cleanup Bootstrap error: %v", tt.logPrefix(), err)
+ return err
+ }
+ return tt.resetStressCheck()
+}
+
+func (tt *tester) pauseStresser() {
+ plog.Infof("%s pausing the stressers...", tt.logPrefix())
+ tt.stresser.Pause()
+ plog.Infof("%s paused stressers", tt.logPrefix())
+}
+
+func (tt *tester) startStresser() (err error) {
+ plog.Infof("%s starting the stressers...", tt.logPrefix())
+ err = tt.stresser.Stress()
+ plog.Infof("%s started stressers", tt.logPrefix())
+ return err
+}
+
+func (tt *tester) closeStresser() {
+ plog.Infof("%s closing the stressers...", tt.logPrefix())
+ tt.stresser.Close()
+ plog.Infof("%s closed stressers", tt.logPrefix())
+}
+
+func (tt *tester) resetStressCheck() error {
+ plog.Infof("%s resetting stressers and checkers...", tt.logPrefix())
+ cs := &compositeStresser{}
+ for _, m := range tt.cluster.Members {
+ s := NewStresser(tt.stresserType, &tt.scfg, m)
+ cs.stressers = append(cs.stressers, s)
+ }
+ tt.stresser = cs
+ if !tt.doChecks {
+ tt.checker = newNoChecker()
+ return tt.startStresser()
+ }
+ chk := newHashChecker(hashAndRevGetter(tt.cluster))
+ if schk := cs.Checker(); schk != nil {
+ chk = newCompositeChecker([]Checker{chk, schk})
+ }
+ tt.checker = chk
+ return tt.startStresser()
+}
+
+func (tt *tester) Report() int64 { return tt.stresser.ModifiedKeys() }
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/util.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/util.go
new file mode 100644
index 00000000..697ab72e
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/util.go
@@ -0,0 +1,51 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 (
+ "fmt"
+ "strings"
+)
+
+func getSameValue(vals map[string]int64) bool {
+ var rv int64
+ for _, v := range vals {
+ if rv == 0 {
+ rv = v
+ }
+ if rv != v {
+ return false
+ }
+ }
+ return true
+}
+
+func max(n1, n2 int64) int64 {
+ if n1 > n2 {
+ return n1
+ }
+ return n2
+}
+
+func errsToError(errs []error) error {
+ if len(errs) == 0 {
+ return nil
+ }
+ stringArr := make([]string, len(errs))
+ for i, err := range errs {
+ stringArr[i] = err.Error()
+ }
+ return fmt.Errorf(strings.Join(stringArr, ", "))
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/v2_stresser.go b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/v2_stresser.go
new file mode 100644
index 00000000..620532e0
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/etcd-tester/v2_stresser.go
@@ -0,0 +1,117 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 (
+ "context"
+ "fmt"
+ "math/rand"
+ "net"
+ "net/http"
+ "sync"
+ "sync/atomic"
+ "time"
+
+ "golang.org/x/time/rate"
+
+ clientV2 "github.com/coreos/etcd/client"
+)
+
+type v2Stresser struct {
+ Endpoint string
+
+ keySize int
+ keySuffixRange int
+
+ N int
+
+ rateLimiter *rate.Limiter
+
+ wg sync.WaitGroup
+
+ atomicModifiedKey int64
+
+ cancel func()
+}
+
+func (s *v2Stresser) Stress() error {
+ cfg := clientV2.Config{
+ Endpoints: []string{s.Endpoint},
+ Transport: &http.Transport{
+ Dial: (&net.Dialer{
+ Timeout: time.Second,
+ KeepAlive: 30 * time.Second,
+ }).Dial,
+ MaxIdleConnsPerHost: s.N,
+ },
+ }
+ c, err := clientV2.New(cfg)
+ if err != nil {
+ return err
+ }
+
+ kv := clientV2.NewKeysAPI(c)
+ ctx, cancel := context.WithCancel(context.Background())
+ s.cancel = cancel
+ s.wg.Add(s.N)
+ for i := 0; i < s.N; i++ {
+ go func() {
+ defer s.wg.Done()
+ s.run(ctx, kv)
+ }()
+ }
+ return nil
+}
+
+func (s *v2Stresser) run(ctx context.Context, kv clientV2.KeysAPI) {
+ for {
+ if err := s.rateLimiter.Wait(ctx); err == context.Canceled {
+ return
+ }
+ setctx, setcancel := context.WithTimeout(ctx, clientV2.DefaultRequestTimeout)
+ key := fmt.Sprintf("foo%016x", rand.Intn(s.keySuffixRange))
+ _, err := kv.Set(setctx, key, string(randBytes(s.keySize)), nil)
+ if err == nil {
+ atomic.AddInt64(&s.atomicModifiedKey, 1)
+ }
+ setcancel()
+ if err == context.Canceled {
+ return
+ }
+ }
+}
+
+func (s *v2Stresser) Pause() {
+ s.cancel()
+ s.wg.Wait()
+}
+
+func (s *v2Stresser) Close() {
+ s.Pause()
+}
+
+func (s *v2Stresser) ModifiedKeys() int64 {
+ return atomic.LoadInt64(&s.atomicModifiedKey)
+}
+
+func (s *v2Stresser) Checker() Checker { return nil }
+
+func randBytes(size int) []byte {
+ data := make([]byte, size)
+ for i := 0; i < size; i++ {
+ data[i] = byte(int('a') + rand.Intn(26))
+ }
+ return data
+}
diff --git a/vendor/github.com/coreos/etcd/tools/functional-tester/test b/vendor/github.com/coreos/etcd/tools/functional-tester/test
new file mode 100755
index 00000000..e8d0e4c5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/functional-tester/test
@@ -0,0 +1,23 @@
+#!/bin/sh -e
+set -x
+set -e
+
+# 1. build etcd binaries
+[ -f bin/etcd ] || ./build
+
+# 2. build agent & tester
+[ -f bin/etcd-agent -a -f bin/etcd-tester ] || ./tools/functional-tester/build
+
+# 3. build docker image (alpine based)
+mkdir -p ./tools/functional-tester/docker/bin
+cp -v bin/etcd-agent bin/etcd-tester bin/etcd ./tools/functional-tester/docker/bin
+docker-compose -f tools/functional-tester/docker/docker-compose.yml build
+
+# 4. create network (assumption - no overlaps)
+docker network ls | grep etcd-functional || docker network create --subnet 172.20.0.0/16 etcd-functional
+
+# 5. run cluster and tester (assumption - agents'll get first ip addresses)
+docker-compose -f tools/functional-tester/docker/docker-compose.yml up -d a1 a2 a3
+
+# 6. run tester
+docker-compose -f tools/functional-tester/docker/docker-compose.yml run tester
diff --git a/vendor/github.com/coreos/etcd/tools/local-tester/Procfile b/vendor/github.com/coreos/etcd/tools/local-tester/Procfile
new file mode 100644
index 00000000..ba150278
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/local-tester/Procfile
@@ -0,0 +1,21 @@
+# Use goreman to run `go get github.com/mattn/goreman`
+
+# peer bridges
+pbridge1: tools/local-tester/bridge/bridge 127.0.0.1:11111 127.0.0.1:12380
+pbridge2: tools/local-tester/bridge/bridge 127.0.0.1:22222 127.0.0.1:22380
+pbridge3: tools/local-tester/bridge/bridge 127.0.0.1:33333 127.0.0.1:32380
+
+# client bridges
+cbridge1: tools/local-tester/bridge/bridge 127.0.0.1:2379 127.0.0.1:11119
+cbridge2: tools/local-tester/bridge/bridge 127.0.0.1:22379 127.0.0.1:22229
+cbridge3: tools/local-tester/bridge/bridge 127.0.0.1:32379 127.0.0.1:33339
+
+faults: tools/local-tester/faults.sh
+
+stress-put: tools/benchmark/benchmark --endpoints=127.0.0.1:2379,127.0.0.1:22379,127.0.0.1:32379 --clients=27 --conns=3 put --sequential-keys --key-space-size=100000 --total=100000
+
+etcd1: GOFAIL_HTTP="127.0.0.1:11180" bin/etcd --name infra1 --snapshot-count=1000 --listen-client-urls http://127.0.0.1:11119 --advertise-client-urls http://127.0.0.1:2379 --listen-peer-urls http://127.0.0.1:12380 --initial-advertise-peer-urls http://127.0.0.1:11111 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:11111,infra2=http://127.0.0.1:22222,infra3=http://127.0.0.1:33333' --initial-cluster-state new --enable-pprof
+etcd2: GOFAIL_HTTP="127.0.0.1:22280" bin/etcd --name infra2 --snapshot-count=1000 --listen-client-urls http://127.0.0.1:22229 --advertise-client-urls http://127.0.0.1:22379 --listen-peer-urls http://127.0.0.1:22380 --initial-advertise-peer-urls http://127.0.0.1:22222 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:11111,infra2=http://127.0.0.1:22222,infra3=http://127.0.0.1:33333' --initial-cluster-state new --enable-pprof
+etcd3: GOFAIL_HTTP="127.0.0.1:33380" bin/etcd --name infra3 --snapshot-count=1000 --listen-client-urls http://127.0.0.1:33339 --advertise-client-urls http://127.0.0.1:32379 --listen-peer-urls http://127.0.0.1:32380 --initial-advertise-peer-urls http://127.0.0.1:33333 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:11111,infra2=http://127.0.0.1:22222,infra3=http://127.0.0.1:33333' --initial-cluster-state new --enable-pprof
+# in future, use proxy to listen on 2379
+#proxy: bin/etcd --name infra-proxy1 --proxy=on --listen-client-urls http://127.0.0.1:2378 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --enable-pprof
diff --git a/vendor/github.com/coreos/etcd/tools/local-tester/README.md b/vendor/github.com/coreos/etcd/tools/local-tester/README.md
new file mode 100644
index 00000000..62e96d1b
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/local-tester/README.md
@@ -0,0 +1,25 @@
+# etcd local-tester
+
+The etcd local-tester runs a fault injected cluster using local processes. It sets up an etcd cluster with unreliable network bridges on its peer and client interfaces. The cluster runs with a constant stream of `Put` requests to simulate client usage. A fault injection script periodically kills cluster members and disrupts bridge connectivity.
+
+# Requirements
+
+local-tester depends on `goreman` to manage its processes and `bash` to run fault injection.
+
+# Building
+
+local-tester needs `etcd`, `benchmark`, and `bridge` binaries. To build these binaries, run the following from the etcd repository root:
+
+```sh
+./build
+pushd tools/benchmark/ && go build && popd
+pushd tools/local-tester/bridge && go build && popd
+```
+
+# Running
+
+The fault injected cluster is invoked with `goreman`:
+
+```sh
+goreman -f tools/local-tester/Procfile start
+```
diff --git a/vendor/github.com/coreos/etcd/tools/local-tester/bridge/bridge.go b/vendor/github.com/coreos/etcd/tools/local-tester/bridge/bridge.go
new file mode 100644
index 00000000..e6b87075
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/local-tester/bridge/bridge.go
@@ -0,0 +1,316 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 is the entry point for the local tester network bridge.
+package main
+
+import (
+ "flag"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "log"
+ "math/rand"
+ "net"
+ "sync"
+ "time"
+)
+
+type bridgeConn struct {
+ in net.Conn
+ out net.Conn
+ d dispatcher
+}
+
+func newBridgeConn(in net.Conn, d dispatcher) (*bridgeConn, error) {
+ out, err := net.Dial("tcp", flag.Args()[1])
+ if err != nil {
+ in.Close()
+ return nil, err
+ }
+ return &bridgeConn{in, out, d}, nil
+}
+
+func (b *bridgeConn) String() string {
+ return fmt.Sprintf("%v <-> %v", b.in.RemoteAddr(), b.out.RemoteAddr())
+}
+
+func (b *bridgeConn) Close() {
+ b.in.Close()
+ b.out.Close()
+}
+
+func bridge(b *bridgeConn) {
+ log.Println("bridging", b.String())
+ go b.d.Copy(b.out, makeFetch(b.in))
+ b.d.Copy(b.in, makeFetch(b.out))
+}
+
+func delayBridge(b *bridgeConn, txDelay, rxDelay time.Duration) {
+ go b.d.Copy(b.out, makeFetchDelay(makeFetch(b.in), txDelay))
+ b.d.Copy(b.in, makeFetchDelay(makeFetch(b.out), rxDelay))
+}
+
+func timeBridge(b *bridgeConn) {
+ go func() {
+ t := time.Duration(rand.Intn(5)+1) * time.Second
+ time.Sleep(t)
+ log.Printf("killing connection %s after %v\n", b.String(), t)
+ b.Close()
+ }()
+ bridge(b)
+}
+
+func blackhole(b *bridgeConn) {
+ log.Println("blackholing connection", b.String())
+ io.Copy(ioutil.Discard, b.in)
+ b.Close()
+}
+
+func readRemoteOnly(b *bridgeConn) {
+ log.Println("one way (<-)", b.String())
+ b.d.Copy(b.in, makeFetch(b.out))
+}
+
+func writeRemoteOnly(b *bridgeConn) {
+ log.Println("one way (->)", b.String())
+ b.d.Copy(b.out, makeFetch(b.in))
+}
+
+func corruptReceive(b *bridgeConn) {
+ log.Println("corruptReceive", b.String())
+ go b.d.Copy(b.in, makeFetchCorrupt(makeFetch(b.out)))
+ b.d.Copy(b.out, makeFetch(b.in))
+}
+
+func corruptSend(b *bridgeConn) {
+ log.Println("corruptSend", b.String())
+ go b.d.Copy(b.out, makeFetchCorrupt(makeFetch(b.in)))
+ b.d.Copy(b.in, makeFetch(b.out))
+}
+
+func makeFetch(c io.Reader) fetchFunc {
+ return func() ([]byte, error) {
+ b := make([]byte, 4096)
+ n, err := c.Read(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+
+func makeFetchCorrupt(f func() ([]byte, error)) fetchFunc {
+ return func() ([]byte, error) {
+ b, err := f()
+ if err != nil {
+ return nil, err
+ }
+ // corrupt one byte approximately every 16K
+ for i := 0; i < len(b); i++ {
+ if rand.Intn(16*1024) == 0 {
+ b[i] = b[i] + 1
+ }
+ }
+ return b, nil
+ }
+}
+
+func makeFetchRand(f func() ([]byte, error)) fetchFunc {
+ return func() ([]byte, error) {
+ if rand.Intn(10) == 0 {
+ return nil, fmt.Errorf("fetchRand: done")
+ }
+ b, err := f()
+ if err != nil {
+ return nil, err
+ }
+ return b, nil
+ }
+}
+
+func makeFetchDelay(f fetchFunc, delay time.Duration) fetchFunc {
+ return func() ([]byte, error) {
+ b, err := f()
+ if err != nil {
+ return nil, err
+ }
+ time.Sleep(delay)
+ return b, nil
+ }
+}
+
+func randomBlackhole(b *bridgeConn) {
+ log.Println("random blackhole: connection", b.String())
+
+ var wg sync.WaitGroup
+ wg.Add(2)
+ go func() {
+ b.d.Copy(b.in, makeFetchRand(makeFetch(b.out)))
+ wg.Done()
+ }()
+ go func() {
+ b.d.Copy(b.out, makeFetchRand(makeFetch(b.in)))
+ wg.Done()
+ }()
+ wg.Wait()
+ b.Close()
+}
+
+type config struct {
+ delayAccept bool
+ resetListen bool
+
+ connFaultRate float64
+ immediateClose bool
+ blackhole bool
+ timeClose bool
+ writeRemoteOnly bool
+ readRemoteOnly bool
+ randomBlackhole bool
+ corruptSend bool
+ corruptReceive bool
+ reorder bool
+
+ txDelay string
+ rxDelay string
+}
+
+type acceptFaultFunc func()
+type connFaultFunc func(*bridgeConn)
+
+func main() {
+ var cfg config
+
+ flag.BoolVar(&cfg.delayAccept, "delay-accept", true, "delays accepting new connections")
+ flag.BoolVar(&cfg.resetListen, "reset-listen", true, "resets the listening port")
+
+ flag.Float64Var(&cfg.connFaultRate, "conn-fault-rate", 0.25, "rate of faulty connections")
+ flag.BoolVar(&cfg.immediateClose, "immediate-close", true, "close after accept")
+ flag.BoolVar(&cfg.blackhole, "blackhole", true, "reads nothing, writes go nowhere")
+ flag.BoolVar(&cfg.timeClose, "time-close", true, "close after random time")
+ flag.BoolVar(&cfg.writeRemoteOnly, "write-remote-only", true, "only write, no read")
+ flag.BoolVar(&cfg.readRemoteOnly, "read-remote-only", true, "only read, no write")
+ flag.BoolVar(&cfg.randomBlackhole, "random-blackhole", true, "blackhole after data xfer")
+ flag.BoolVar(&cfg.corruptReceive, "corrupt-receive", true, "corrupt packets received from destination")
+ flag.BoolVar(&cfg.corruptSend, "corrupt-send", true, "corrupt packets sent to destination")
+ flag.BoolVar(&cfg.reorder, "reorder", true, "reorder packet delivery")
+
+ flag.StringVar(&cfg.txDelay, "tx-delay", "0", "duration to delay client transmission to server")
+ flag.StringVar(&cfg.rxDelay, "rx-delay", "0", "duration to delay client receive from server")
+
+ flag.Parse()
+
+ lAddr := flag.Args()[0]
+ fwdAddr := flag.Args()[1]
+ log.Println("listening on ", lAddr)
+ log.Println("forwarding to ", fwdAddr)
+ l, err := net.Listen("tcp", lAddr)
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer l.Close()
+
+ acceptFaults := []acceptFaultFunc{func() {}}
+ if cfg.delayAccept {
+ f := func() {
+ log.Println("delaying accept")
+ time.Sleep(3 * time.Second)
+ }
+ acceptFaults = append(acceptFaults, f)
+ }
+ if cfg.resetListen {
+ f := func() {
+ log.Println("reset listen port")
+ l.Close()
+ newListener, err := net.Listen("tcp", lAddr)
+ if err != nil {
+ log.Fatal(err)
+ }
+ l = newListener
+
+ }
+ acceptFaults = append(acceptFaults, f)
+ }
+
+ connFaults := []connFaultFunc{func(b *bridgeConn) { bridge(b) }}
+ if cfg.immediateClose {
+ f := func(b *bridgeConn) {
+ log.Printf("terminating connection %s immediately", b.String())
+ b.Close()
+ }
+ connFaults = append(connFaults, f)
+ }
+ if cfg.blackhole {
+ connFaults = append(connFaults, blackhole)
+ }
+ if cfg.timeClose {
+ connFaults = append(connFaults, timeBridge)
+ }
+ if cfg.writeRemoteOnly {
+ connFaults = append(connFaults, writeRemoteOnly)
+ }
+ if cfg.readRemoteOnly {
+ connFaults = append(connFaults, readRemoteOnly)
+ }
+ if cfg.randomBlackhole {
+ connFaults = append(connFaults, randomBlackhole)
+ }
+ if cfg.corruptSend {
+ connFaults = append(connFaults, corruptSend)
+ }
+ if cfg.corruptReceive {
+ connFaults = append(connFaults, corruptReceive)
+ }
+
+ txd, txdErr := time.ParseDuration(cfg.txDelay)
+ if txdErr != nil {
+ log.Fatal(txdErr)
+ }
+ rxd, rxdErr := time.ParseDuration(cfg.rxDelay)
+ if rxdErr != nil {
+ log.Fatal(rxdErr)
+ }
+ if txd != 0 || rxd != 0 {
+ f := func(b *bridgeConn) { delayBridge(b, txd, rxd) }
+ connFaults = append(connFaults, f)
+ }
+
+ var disp dispatcher
+ if cfg.reorder {
+ disp = newDispatcherPool()
+ } else {
+ disp = newDispatcherImmediate()
+ }
+
+ for {
+ acceptFaults[rand.Intn(len(acceptFaults))]()
+ conn, err := l.Accept()
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ r := rand.Intn(len(connFaults))
+ if rand.Intn(100) > int(100.0*cfg.connFaultRate) {
+ r = 0
+ }
+
+ bc, err := newBridgeConn(conn, disp)
+ if err != nil {
+ log.Printf("oops %v", err)
+ continue
+ }
+ go connFaults[r](bc)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/tools/local-tester/bridge/dispatch.go b/vendor/github.com/coreos/etcd/tools/local-tester/bridge/dispatch.go
new file mode 100644
index 00000000..b385cefe
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/local-tester/bridge/dispatch.go
@@ -0,0 +1,140 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 (
+ "io"
+ "math/rand"
+ "sync"
+ "time"
+)
+
+var (
+ // dispatchPoolDelay is the time to wait before flushing all buffered packets
+ dispatchPoolDelay = 100 * time.Millisecond
+ // dispatchPacketBytes is how many bytes to send until choosing a new connection
+ dispatchPacketBytes = 32
+)
+
+type dispatcher interface {
+ // Copy works like io.Copy using buffers provided by fetchFunc
+ Copy(io.Writer, fetchFunc) error
+}
+
+type fetchFunc func() ([]byte, error)
+
+type dispatcherPool struct {
+ // mu protects the dispatch packet queue 'q'
+ mu sync.Mutex
+ q []dispatchPacket
+}
+
+type dispatchPacket struct {
+ buf []byte
+ out io.Writer
+}
+
+func newDispatcherPool() dispatcher {
+ d := &dispatcherPool{}
+ go d.writeLoop()
+ return d
+}
+
+func (d *dispatcherPool) writeLoop() {
+ for {
+ time.Sleep(dispatchPoolDelay)
+ d.flush()
+ }
+}
+
+func (d *dispatcherPool) flush() {
+ d.mu.Lock()
+ pkts := d.q
+ d.q = nil
+ d.mu.Unlock()
+ if len(pkts) == 0 {
+ return
+ }
+
+ // sort by sockets; preserve the packet ordering within a socket
+ pktmap := make(map[io.Writer][]dispatchPacket)
+ outs := []io.Writer{}
+ for _, pkt := range pkts {
+ opkts, ok := pktmap[pkt.out]
+ if !ok {
+ outs = append(outs, pkt.out)
+ }
+ pktmap[pkt.out] = append(opkts, pkt)
+ }
+
+ // send all packets in pkts
+ for len(outs) != 0 {
+ // randomize writer on every write
+ r := rand.Intn(len(outs))
+ rpkts := pktmap[outs[r]]
+ rpkts[0].out.Write(rpkts[0].buf)
+ // dequeue packet
+ rpkts = rpkts[1:]
+ if len(rpkts) == 0 {
+ delete(pktmap, outs[r])
+ outs = append(outs[:r], outs[r+1:]...)
+ } else {
+ pktmap[outs[r]] = rpkts
+ }
+ }
+}
+
+func (d *dispatcherPool) Copy(w io.Writer, f fetchFunc) error {
+ for {
+ b, err := f()
+ if err != nil {
+ return err
+ }
+
+ pkts := []dispatchPacket{}
+ for len(b) > 0 {
+ pkt := b
+ if len(b) > dispatchPacketBytes {
+ pkt = pkt[:dispatchPacketBytes]
+ b = b[dispatchPacketBytes:]
+ } else {
+ b = nil
+ }
+ pkts = append(pkts, dispatchPacket{pkt, w})
+ }
+
+ d.mu.Lock()
+ d.q = append(d.q, pkts...)
+ d.mu.Unlock()
+ }
+}
+
+type dispatcherImmediate struct{}
+
+func newDispatcherImmediate() dispatcher {
+ return &dispatcherImmediate{}
+}
+
+func (d *dispatcherImmediate) Copy(w io.Writer, f fetchFunc) error {
+ for {
+ b, err := f()
+ if err != nil {
+ return err
+ }
+ if _, err := w.Write(b); err != nil {
+ return err
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/tools/local-tester/faults.sh b/vendor/github.com/coreos/etcd/tools/local-tester/faults.sh
new file mode 100755
index 00000000..1349f592
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/tools/local-tester/faults.sh
@@ -0,0 +1,108 @@
+#!/bin/bash
+
+PROCFILE="tools/local-tester/Procfile"
+HTTPFAIL=(127.0.0.1:11180 127.0.0.1:22280 127.0.0.1:33380)
+
+function wait_time {
+ expr $RANDOM % 10 + 1
+}
+
+function cycle {
+ for a; do
+ echo "cycling $a"
+ goreman -f $PROCFILE run stop $a || echo "could not stop $a"
+ sleep `wait_time`s
+ goreman -f $PROCFILE run restart $a || echo "could not restart $a"
+ done
+}
+
+function cycle_members {
+ cycle etcd1 etcd2 etcd3
+}
+function cycle_pbridge {
+ cycle pbridge1 pbridge2 pbridge3
+}
+function cycle_cbridge {
+ cycle cbridge1 cbridge2 cbridge3
+}
+function cycle_stresser {
+ cycle stress-put
+}
+
+function kill_maj {
+ idx="etcd"`expr $RANDOM % 3 + 1`
+ idx2="$idx"
+ while [ "$idx" == "$idx2" ]; do
+ idx2="etcd"`expr $RANDOM % 3 + 1`
+ done
+ echo "kill majority $idx $idx2"
+ goreman -f $PROCFILE run stop $idx || echo "could not stop $idx"
+ goreman -f $PROCFILE run stop $idx2 || echo "could not stop $idx2"
+ sleep `wait_time`s
+ goreman -f $PROCFILE run restart $idx || echo "could not restart $idx"
+ goreman -f $PROCFILE run restart $idx2 || echo "could not restart $idx2"
+}
+
+function kill_all {
+ for a in etcd1 etcd2 etcd3; do
+ goreman -f $PROCFILE run stop $a || echo "could not stop $a"
+ done
+ sleep `wait_time`s
+ for a in etcd1 etcd2 etcd3; do
+ goreman -f $PROCFILE run restart $a || echo "could not restart $a"
+ done
+}
+
+function rand_fp {
+ echo "$FAILPOINTS" | sed `expr $RANDOM % $NUMFPS + 1`"q;d"
+}
+
+# fp_activate <http> <fppath> <value>
+function fp_activate {
+ curl "$1"/"$2" -XPUT -d "$3" >/dev/null 2>&1
+}
+
+function fp_rand_single {
+ fp=`rand_fp`
+ fp_activate ${HTTPFAIL[`expr $RANDOM % ${#HTTPFAIL[@]}`]} $fp 'panic("'$fp'")'
+ sleep `wait_time`s
+}
+
+function fp_rand_all {
+ fp=`rand_fp`
+ for a in `seq ${#HTTPFAIL[@]}`; do fp_activate ${HTTPFAIL[$a]} "$fp" 'panic("'$fp'")'; done
+ sleep `wait_time`s
+}
+
+function fp_all_rand_fire {
+ for fp in $FAILPOINTS; do
+ for url in "${HTTPFAIL[@]}"; do
+ fp_activate "$url" "$fp" '0.5%panic("0.5%'$fp'")'
+ done
+ done
+}
+
+function choose {
+ fault=${FAULTS[`expr $RANDOM % ${#FAULTS[@]}`]}
+ echo $fault
+ $fault || echo "failed: $fault"
+}
+
+sleep 2s
+
+FAULTS=(cycle_members kill_maj kill_all cycle_pbridge cycle_cbridge cycle_stresser)
+
+# add failpoint faults if available
+FAILPOINTS=`curl http://"${HTTPFAIL[0]}" 2>/dev/null | cut -f1 -d'=' | grep -v "^$"`
+NUMFPS=`echo $(echo "$FAILPOINTS" | wc -l)`
+if [ "$NUMFPS" != "0" ]; then
+ FAULTS+=(fp_rand_single)
+ FAULTS+=(fp_rand_all)
+fi
+
+while [ 1 ]; do
+ choose
+ # start any nodes that have been killed by failpoints
+ for a in etcd1 etcd2 etcd3; do goreman -f $PROCFILE run start $a; done
+ fp_all_rand_fire
+done
diff --git a/vendor/github.com/coreos/etcd/version/version.go b/vendor/github.com/coreos/etcd/version/version.go
new file mode 100644
index 00000000..c7e96aad
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/version/version.go
@@ -0,0 +1,56 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 version implements etcd version parsing and contains latest version
+// information.
+package version
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/coreos/go-semver/semver"
+)
+
+var (
+ // MinClusterVersion is the min cluster version this etcd binary is compatible with.
+ MinClusterVersion = "3.0.0"
+ Version = "3.2.5"
+ APIVersion = "unknown"
+
+ // Git SHA Value will be set during build
+ GitSHA = "Not provided (use ./build instead of go build)"
+)
+
+func init() {
+ ver, err := semver.NewVersion(Version)
+ if err == nil {
+ APIVersion = fmt.Sprintf("%d.%d", ver.Major, ver.Minor)
+ }
+}
+
+type Versions struct {
+ Server string `json:"etcdserver"`
+ Cluster string `json:"etcdcluster"`
+ // TODO: raft state machine version
+}
+
+// Cluster only keeps the major.minor.
+func Cluster(v string) string {
+ vs := strings.Split(v, ".")
+ if len(vs) <= 2 {
+ return v
+ }
+ return fmt.Sprintf("%s.%s", vs[0], vs[1])
+}
diff --git a/vendor/github.com/coreos/etcd/wal/decoder.go b/vendor/github.com/coreos/etcd/wal/decoder.go
new file mode 100644
index 00000000..0d9b4428
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/decoder.go
@@ -0,0 +1,185 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wal
+
+import (
+ "bufio"
+ "encoding/binary"
+ "hash"
+ "io"
+ "sync"
+
+ "github.com/coreos/etcd/pkg/crc"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/wal/walpb"
+)
+
+const minSectorSize = 512
+
+type decoder struct {
+ mu sync.Mutex
+ brs []*bufio.Reader
+
+ // lastValidOff file offset following the last valid decoded record
+ lastValidOff int64
+ crc hash.Hash32
+}
+
+func newDecoder(r ...io.Reader) *decoder {
+ readers := make([]*bufio.Reader, len(r))
+ for i := range r {
+ readers[i] = bufio.NewReader(r[i])
+ }
+ return &decoder{
+ brs: readers,
+ crc: crc.New(0, crcTable),
+ }
+}
+
+func (d *decoder) decode(rec *walpb.Record) error {
+ rec.Reset()
+ d.mu.Lock()
+ defer d.mu.Unlock()
+ return d.decodeRecord(rec)
+}
+
+func (d *decoder) decodeRecord(rec *walpb.Record) error {
+ if len(d.brs) == 0 {
+ return io.EOF
+ }
+
+ l, err := readInt64(d.brs[0])
+ if err == io.EOF || (err == nil && l == 0) {
+ // hit end of file or preallocated space
+ d.brs = d.brs[1:]
+ if len(d.brs) == 0 {
+ return io.EOF
+ }
+ d.lastValidOff = 0
+ return d.decodeRecord(rec)
+ }
+ if err != nil {
+ return err
+ }
+
+ recBytes, padBytes := decodeFrameSize(l)
+
+ data := make([]byte, recBytes+padBytes)
+ if _, err = io.ReadFull(d.brs[0], data); err != nil {
+ // ReadFull returns io.EOF only if no bytes were read
+ // the decoder should treat this as an ErrUnexpectedEOF instead.
+ if err == io.EOF {
+ err = io.ErrUnexpectedEOF
+ }
+ return err
+ }
+ if err := rec.Unmarshal(data[:recBytes]); err != nil {
+ if d.isTornEntry(data) {
+ return io.ErrUnexpectedEOF
+ }
+ return err
+ }
+
+ // skip crc checking if the record type is crcType
+ if rec.Type != crcType {
+ d.crc.Write(rec.Data)
+ if err := rec.Validate(d.crc.Sum32()); err != nil {
+ if d.isTornEntry(data) {
+ return io.ErrUnexpectedEOF
+ }
+ return err
+ }
+ }
+ // record decoded as valid; point last valid offset to end of record
+ d.lastValidOff += recBytes + padBytes + 8
+ return nil
+}
+
+func decodeFrameSize(lenField int64) (recBytes int64, padBytes int64) {
+ // the record size is stored in the lower 56 bits of the 64-bit length
+ recBytes = int64(uint64(lenField) & ^(uint64(0xff) << 56))
+ // non-zero padding is indicated by set MSb / a negative length
+ if lenField < 0 {
+ // padding is stored in lower 3 bits of length MSB
+ padBytes = int64((uint64(lenField) >> 56) & 0x7)
+ }
+ return
+}
+
+// isTornEntry determines whether the last entry of the WAL was partially written
+// and corrupted because of a torn write.
+func (d *decoder) isTornEntry(data []byte) bool {
+ if len(d.brs) != 1 {
+ return false
+ }
+
+ fileOff := d.lastValidOff + 8
+ curOff := 0
+ chunks := [][]byte{}
+ // split data on sector boundaries
+ for curOff < len(data) {
+ chunkLen := int(minSectorSize - (fileOff % minSectorSize))
+ if chunkLen > len(data)-curOff {
+ chunkLen = len(data) - curOff
+ }
+ chunks = append(chunks, data[curOff:curOff+chunkLen])
+ fileOff += int64(chunkLen)
+ curOff += chunkLen
+ }
+
+ // if any data for a sector chunk is all 0, it's a torn write
+ for _, sect := range chunks {
+ isZero := true
+ for _, v := range sect {
+ if v != 0 {
+ isZero = false
+ break
+ }
+ }
+ if isZero {
+ return true
+ }
+ }
+ return false
+}
+
+func (d *decoder) updateCRC(prevCrc uint32) {
+ d.crc = crc.New(prevCrc, crcTable)
+}
+
+func (d *decoder) lastCRC() uint32 {
+ return d.crc.Sum32()
+}
+
+func (d *decoder) lastOffset() int64 { return d.lastValidOff }
+
+func mustUnmarshalEntry(d []byte) raftpb.Entry {
+ var e raftpb.Entry
+ pbutil.MustUnmarshal(&e, d)
+ return e
+}
+
+func mustUnmarshalState(d []byte) raftpb.HardState {
+ var s raftpb.HardState
+ pbutil.MustUnmarshal(&s, d)
+ return s
+}
+
+func readInt64(r io.Reader) (int64, error) {
+ var n int64
+ err := binary.Read(r, binary.LittleEndian, &n)
+ return n, err
+}
diff --git a/vendor/github.com/coreos/etcd/wal/doc.go b/vendor/github.com/coreos/etcd/wal/doc.go
new file mode 100644
index 00000000..a3abd696
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/doc.go
@@ -0,0 +1,75 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wal provides an implementation of a write ahead log that is used by
+etcd.
+
+A WAL is created at a particular directory and is made up of a number of
+segmented WAL files. Inside of each file the raft state and entries are appended
+to it with the Save method:
+
+ metadata := []byte{}
+ w, err := wal.Create("/var/lib/etcd", metadata)
+ ...
+ err := w.Save(s, ents)
+
+After saving a raft snapshot to disk, SaveSnapshot method should be called to
+record it. So WAL can match with the saved snapshot when restarting.
+
+ err := w.SaveSnapshot(walpb.Snapshot{Index: 10, Term: 2})
+
+When a user has finished using a WAL it must be closed:
+
+ w.Close()
+
+Each WAL file is a stream of WAL records. A WAL record is a length field and a wal record
+protobuf. The record protobuf contains a CRC, a type, and a data payload. The length field is a
+64-bit packed structure holding the length of the remaining logical record data in its lower
+56 bits and its physical padding in the first three bits of the most significant byte. Each
+record is 8-byte aligned so that the length field is never torn. The CRC contains the CRC32
+value of all record protobufs preceding the current record.
+
+WAL files are placed inside of the directory in the following format:
+$seq-$index.wal
+
+The first WAL file to be created will be 0000000000000000-0000000000000000.wal
+indicating an initial sequence of 0 and an initial raft index of 0. The first
+entry written to WAL MUST have raft index 0.
+
+WAL will cut its current tail wal file if its size exceeds 64MB. This will increment an internal
+sequence number and cause a new file to be created. If the last raft index saved
+was 0x20 and this is the first time cut has been called on this WAL then the sequence will
+increment from 0x0 to 0x1. The new file will be: 0000000000000001-0000000000000021.wal.
+If a second cut issues 0x10 entries with incremental index later then the file will be called:
+0000000000000002-0000000000000031.wal.
+
+At a later time a WAL can be opened at a particular snapshot. If there is no
+snapshot, an empty snapshot should be passed in.
+
+ w, err := wal.Open("/var/lib/etcd", walpb.Snapshot{Index: 10, Term: 2})
+ ...
+
+The snapshot must have been written to the WAL.
+
+Additional items cannot be Saved to this WAL until all of the items from the given
+snapshot to the end of the WAL are read first:
+
+ metadata, state, ents, err := w.ReadAll()
+
+This will give you the metadata, the last raft.State and the slice of
+raft.Entry items in the log.
+
+*/
+package wal
diff --git a/vendor/github.com/coreos/etcd/wal/encoder.go b/vendor/github.com/coreos/etcd/wal/encoder.go
new file mode 100644
index 00000000..aac1e197
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/encoder.go
@@ -0,0 +1,120 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wal
+
+import (
+ "encoding/binary"
+ "hash"
+ "io"
+ "os"
+ "sync"
+
+ "github.com/coreos/etcd/pkg/crc"
+ "github.com/coreos/etcd/pkg/ioutil"
+ "github.com/coreos/etcd/wal/walpb"
+)
+
+// walPageBytes is the alignment for flushing records to the backing Writer.
+// It should be a multiple of the minimum sector size so that WAL can safely
+// distinguish between torn writes and ordinary data corruption.
+const walPageBytes = 8 * minSectorSize
+
+type encoder struct {
+ mu sync.Mutex
+ bw *ioutil.PageWriter
+
+ crc hash.Hash32
+ buf []byte
+ uint64buf []byte
+}
+
+func newEncoder(w io.Writer, prevCrc uint32, pageOffset int) *encoder {
+ return &encoder{
+ bw: ioutil.NewPageWriter(w, walPageBytes, pageOffset),
+ crc: crc.New(prevCrc, crcTable),
+ // 1MB buffer
+ buf: make([]byte, 1024*1024),
+ uint64buf: make([]byte, 8),
+ }
+}
+
+// newFileEncoder creates a new encoder with current file offset for the page writer.
+func newFileEncoder(f *os.File, prevCrc uint32) (*encoder, error) {
+ offset, err := f.Seek(0, io.SeekCurrent)
+ if err != nil {
+ return nil, err
+ }
+ return newEncoder(f, prevCrc, int(offset)), nil
+}
+
+func (e *encoder) encode(rec *walpb.Record) error {
+ e.mu.Lock()
+ defer e.mu.Unlock()
+
+ e.crc.Write(rec.Data)
+ rec.Crc = e.crc.Sum32()
+ var (
+ data []byte
+ err error
+ n int
+ )
+
+ if rec.Size() > len(e.buf) {
+ data, err = rec.Marshal()
+ if err != nil {
+ return err
+ }
+ } else {
+ n, err = rec.MarshalTo(e.buf)
+ if err != nil {
+ return err
+ }
+ data = e.buf[:n]
+ }
+
+ lenField, padBytes := encodeFrameSize(len(data))
+ if err = writeUint64(e.bw, lenField, e.uint64buf); err != nil {
+ return err
+ }
+
+ if padBytes != 0 {
+ data = append(data, make([]byte, padBytes)...)
+ }
+ _, err = e.bw.Write(data)
+ return err
+}
+
+func encodeFrameSize(dataBytes int) (lenField uint64, padBytes int) {
+ lenField = uint64(dataBytes)
+ // force 8 byte alignment so length never gets a torn write
+ padBytes = (8 - (dataBytes % 8)) % 8
+ if padBytes != 0 {
+ lenField |= uint64(0x80|padBytes) << 56
+ }
+ return
+}
+
+func (e *encoder) flush() error {
+ e.mu.Lock()
+ defer e.mu.Unlock()
+ return e.bw.Flush()
+}
+
+func writeUint64(w io.Writer, n uint64, buf []byte) error {
+ // http://golang.org/src/encoding/binary/binary.go
+ binary.LittleEndian.PutUint64(buf, n)
+ _, err := w.Write(buf)
+ return err
+}
diff --git a/vendor/github.com/coreos/etcd/wal/file_pipeline.go b/vendor/github.com/coreos/etcd/wal/file_pipeline.go
new file mode 100644
index 00000000..5e32a069
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/file_pipeline.go
@@ -0,0 +1,97 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 wal
+
+import (
+ "fmt"
+ "os"
+ "path/filepath"
+
+ "github.com/coreos/etcd/pkg/fileutil"
+)
+
+// filePipeline pipelines allocating disk space
+type filePipeline struct {
+ // dir to put files
+ dir string
+ // size of files to make, in bytes
+ size int64
+ // count number of files generated
+ count int
+
+ filec chan *fileutil.LockedFile
+ errc chan error
+ donec chan struct{}
+}
+
+func newFilePipeline(dir string, fileSize int64) *filePipeline {
+ fp := &filePipeline{
+ dir: dir,
+ size: fileSize,
+ filec: make(chan *fileutil.LockedFile),
+ errc: make(chan error, 1),
+ donec: make(chan struct{}),
+ }
+ go fp.run()
+ return fp
+}
+
+// Open returns a fresh file for writing. Rename the file before calling
+// Open again or there will be file collisions.
+func (fp *filePipeline) Open() (f *fileutil.LockedFile, err error) {
+ select {
+ case f = <-fp.filec:
+ case err = <-fp.errc:
+ }
+ return
+}
+
+func (fp *filePipeline) Close() error {
+ close(fp.donec)
+ return <-fp.errc
+}
+
+func (fp *filePipeline) alloc() (f *fileutil.LockedFile, err error) {
+ // count % 2 so this file isn't the same as the one last published
+ fpath := filepath.Join(fp.dir, fmt.Sprintf("%d.tmp", fp.count%2))
+ if f, err = fileutil.LockFile(fpath, os.O_CREATE|os.O_WRONLY, fileutil.PrivateFileMode); err != nil {
+ return nil, err
+ }
+ if err = fileutil.Preallocate(f.File, fp.size, true); err != nil {
+ plog.Errorf("failed to allocate space when creating new wal file (%v)", err)
+ f.Close()
+ return nil, err
+ }
+ fp.count++
+ return f, nil
+}
+
+func (fp *filePipeline) run() {
+ defer close(fp.errc)
+ for {
+ f, err := fp.alloc()
+ if err != nil {
+ fp.errc <- err
+ return
+ }
+ select {
+ case fp.filec <- f:
+ case <-fp.donec:
+ os.Remove(f.Name())
+ f.Close()
+ return
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/wal/metrics.go b/vendor/github.com/coreos/etcd/wal/metrics.go
new file mode 100644
index 00000000..9e089d38
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/metrics.go
@@ -0,0 +1,31 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wal
+
+import "github.com/prometheus/client_golang/prometheus"
+
+var (
+ syncDurations = prometheus.NewHistogram(prometheus.HistogramOpts{
+ Namespace: "etcd",
+ Subsystem: "disk",
+ Name: "wal_fsync_duration_seconds",
+ Help: "The latency distributions of fsync called by wal.",
+ Buckets: prometheus.ExponentialBuckets(0.001, 2, 14),
+ })
+)
+
+func init() {
+ prometheus.MustRegister(syncDurations)
+}
diff --git a/vendor/github.com/coreos/etcd/wal/record_test.go b/vendor/github.com/coreos/etcd/wal/record_test.go
new file mode 100644
index 00000000..2a6904a8
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/record_test.go
@@ -0,0 +1,86 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wal
+
+import (
+ "bytes"
+ "hash/crc32"
+ "io"
+ "io/ioutil"
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/wal/walpb"
+)
+
+var (
+ infoData = []byte("\b\xef\xfd\x02")
+ infoRecord = append([]byte("\x0e\x00\x00\x00\x00\x00\x00\x00\b\x01\x10\x99\xb5\xe4\xd0\x03\x1a\x04"), infoData...)
+)
+
+func TestReadRecord(t *testing.T) {
+ badInfoRecord := make([]byte, len(infoRecord))
+ copy(badInfoRecord, infoRecord)
+ badInfoRecord[len(badInfoRecord)-1] = 'a'
+
+ tests := []struct {
+ data []byte
+ wr *walpb.Record
+ we error
+ }{
+ {infoRecord, &walpb.Record{Type: 1, Crc: crc32.Checksum(infoData, crcTable), Data: infoData}, nil},
+ {[]byte(""), &walpb.Record{}, io.EOF},
+ {infoRecord[:8], &walpb.Record{}, io.ErrUnexpectedEOF},
+ {infoRecord[:len(infoRecord)-len(infoData)-8], &walpb.Record{}, io.ErrUnexpectedEOF},
+ {infoRecord[:len(infoRecord)-len(infoData)], &walpb.Record{}, io.ErrUnexpectedEOF},
+ {infoRecord[:len(infoRecord)-8], &walpb.Record{}, io.ErrUnexpectedEOF},
+ {badInfoRecord, &walpb.Record{}, walpb.ErrCRCMismatch},
+ }
+
+ rec := &walpb.Record{}
+ for i, tt := range tests {
+ buf := bytes.NewBuffer(tt.data)
+ decoder := newDecoder(ioutil.NopCloser(buf))
+ e := decoder.decode(rec)
+ if !reflect.DeepEqual(rec, tt.wr) {
+ t.Errorf("#%d: block = %v, want %v", i, rec, tt.wr)
+ }
+ if !reflect.DeepEqual(e, tt.we) {
+ t.Errorf("#%d: err = %v, want %v", i, e, tt.we)
+ }
+ rec = &walpb.Record{}
+ }
+}
+
+func TestWriteRecord(t *testing.T) {
+ b := &walpb.Record{}
+ typ := int64(0xABCD)
+ d := []byte("Hello world!")
+ buf := new(bytes.Buffer)
+ e := newEncoder(buf, 0, 0)
+ e.encode(&walpb.Record{Type: typ, Data: d})
+ e.flush()
+ decoder := newDecoder(ioutil.NopCloser(buf))
+ err := decoder.decode(b)
+ if err != nil {
+ t.Errorf("err = %v, want nil", err)
+ }
+ if b.Type != typ {
+ t.Errorf("type = %d, want %d", b.Type, typ)
+ }
+ if !reflect.DeepEqual(b.Data, d) {
+ t.Errorf("data = %v, want %v", b.Data, d)
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/wal/repair.go b/vendor/github.com/coreos/etcd/wal/repair.go
new file mode 100644
index 00000000..091036b5
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/repair.go
@@ -0,0 +1,99 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wal
+
+import (
+ "io"
+ "os"
+ "path/filepath"
+
+ "github.com/coreos/etcd/pkg/fileutil"
+ "github.com/coreos/etcd/wal/walpb"
+)
+
+// Repair tries to repair ErrUnexpectedEOF in the
+// last wal file by truncating.
+func Repair(dirpath string) bool {
+ f, err := openLast(dirpath)
+ if err != nil {
+ return false
+ }
+ defer f.Close()
+
+ rec := &walpb.Record{}
+ decoder := newDecoder(f)
+ for {
+ lastOffset := decoder.lastOffset()
+ err := decoder.decode(rec)
+ switch err {
+ case nil:
+ // update crc of the decoder when necessary
+ switch rec.Type {
+ case crcType:
+ crc := decoder.crc.Sum32()
+ // current crc of decoder must match the crc of the record.
+ // do no need to match 0 crc, since the decoder is a new one at this case.
+ if crc != 0 && rec.Validate(crc) != nil {
+ return false
+ }
+ decoder.updateCRC(rec.Crc)
+ }
+ continue
+ case io.EOF:
+ return true
+ case io.ErrUnexpectedEOF:
+ plog.Noticef("repairing %v", f.Name())
+ bf, bferr := os.Create(f.Name() + ".broken")
+ if bferr != nil {
+ plog.Errorf("could not repair %v, failed to create backup file", f.Name())
+ return false
+ }
+ defer bf.Close()
+
+ if _, err = f.Seek(0, io.SeekStart); err != nil {
+ plog.Errorf("could not repair %v, failed to read file", f.Name())
+ return false
+ }
+
+ if _, err = io.Copy(bf, f); err != nil {
+ plog.Errorf("could not repair %v, failed to copy file", f.Name())
+ return false
+ }
+
+ if err = f.Truncate(int64(lastOffset)); err != nil {
+ plog.Errorf("could not repair %v, failed to truncate file", f.Name())
+ return false
+ }
+ if err = fileutil.Fsync(f.File); err != nil {
+ plog.Errorf("could not repair %v, failed to sync file", f.Name())
+ return false
+ }
+ return true
+ default:
+ plog.Errorf("could not repair error (%v)", err)
+ return false
+ }
+ }
+}
+
+// openLast opens the last wal file for read and write.
+func openLast(dirpath string) (*fileutil.LockedFile, error) {
+ names, err := readWalNames(dirpath)
+ if err != nil {
+ return nil, err
+ }
+ last := filepath.Join(dirpath, names[len(names)-1])
+ return fileutil.LockFile(last, os.O_RDWR, fileutil.PrivateFileMode)
+}
diff --git a/vendor/github.com/coreos/etcd/wal/repair_test.go b/vendor/github.com/coreos/etcd/wal/repair_test.go
new file mode 100644
index 00000000..be9c016c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/repair_test.go
@@ -0,0 +1,184 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wal
+
+import (
+ "fmt"
+ "io"
+ "io/ioutil"
+ "os"
+ "testing"
+
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/wal/walpb"
+)
+
+type corruptFunc func(string, int64) error
+
+// TestRepairTruncate ensures a truncated file can be repaired
+func TestRepairTruncate(t *testing.T) {
+ corruptf := func(p string, offset int64) error {
+ f, err := openLast(p)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+ return f.Truncate(offset - 4)
+ }
+
+ testRepair(t, makeEnts(10), corruptf, 9)
+}
+
+func testRepair(t *testing.T, ents [][]raftpb.Entry, corrupt corruptFunc, expectedEnts int) {
+ p, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+ // create WAL
+ w, err := Create(p, nil)
+ defer func() {
+ if err = w.Close(); err != nil {
+ t.Fatal(err)
+ }
+ }()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ for _, es := range ents {
+ if err = w.Save(raftpb.HardState{}, es); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ offset, err := w.tail().Seek(0, io.SeekCurrent)
+ if err != nil {
+ t.Fatal(err)
+ }
+ w.Close()
+
+ err = corrupt(p, offset)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // verify we broke the wal
+ w, err = Open(p, walpb.Snapshot{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, _, _, err = w.ReadAll()
+ if err != io.ErrUnexpectedEOF {
+ t.Fatalf("err = %v, want error %v", err, io.ErrUnexpectedEOF)
+ }
+ w.Close()
+
+ // repair the wal
+ if ok := Repair(p); !ok {
+ t.Fatalf("fix = %t, want %t", ok, true)
+ }
+
+ // read it back
+ w, err = Open(p, walpb.Snapshot{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, _, walEnts, err := w.ReadAll()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(walEnts) != expectedEnts {
+ t.Fatalf("len(ents) = %d, want %d", len(walEnts), expectedEnts)
+ }
+
+ // write some more entries to repaired log
+ for i := 1; i <= 10; i++ {
+ es := []raftpb.Entry{{Index: uint64(expectedEnts + i)}}
+ if err = w.Save(raftpb.HardState{}, es); err != nil {
+ t.Fatal(err)
+ }
+ }
+ w.Close()
+
+ // read back entries following repair, ensure it's all there
+ w, err = Open(p, walpb.Snapshot{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, _, walEnts, err = w.ReadAll()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(walEnts) != expectedEnts+10 {
+ t.Fatalf("len(ents) = %d, want %d", len(walEnts), expectedEnts+10)
+ }
+}
+
+func makeEnts(ents int) (ret [][]raftpb.Entry) {
+ for i := 1; i <= ents; i++ {
+ ret = append(ret, []raftpb.Entry{{Index: uint64(i)}})
+ }
+ return ret
+}
+
+// TestRepairWriteTearLast repairs the WAL in case the last record is a torn write
+// that straddled two sectors.
+func TestRepairWriteTearLast(t *testing.T) {
+ corruptf := func(p string, offset int64) error {
+ f, err := openLast(p)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+ // 512 bytes perfectly aligns the last record, so use 1024
+ if offset < 1024 {
+ return fmt.Errorf("got offset %d, expected >1024", offset)
+ }
+ if terr := f.Truncate(1024); terr != nil {
+ return terr
+ }
+ if terr := f.Truncate(offset); terr != nil {
+ return terr
+ }
+ return nil
+ }
+ testRepair(t, makeEnts(50), corruptf, 40)
+}
+
+// TestRepairWriteTearMiddle repairs the WAL when there is write tearing
+// in the middle of a record.
+func TestRepairWriteTearMiddle(t *testing.T) {
+ corruptf := func(p string, offset int64) error {
+ f, err := openLast(p)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+ // corrupt middle of 2nd record
+ _, werr := f.WriteAt(make([]byte, 512), 4096+512)
+ return werr
+ }
+ ents := makeEnts(5)
+ // 4096 bytes of data so a middle sector is easy to corrupt
+ dat := make([]byte, 4096)
+ for i := range dat {
+ dat[i] = byte(i)
+ }
+ for i := range ents {
+ ents[i][0].Data = dat
+ }
+ testRepair(t, ents, corruptf, 1)
+}
diff --git a/vendor/github.com/coreos/etcd/wal/util.go b/vendor/github.com/coreos/etcd/wal/util.go
new file mode 100644
index 00000000..5c56e228
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/util.go
@@ -0,0 +1,107 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wal
+
+import (
+ "errors"
+ "fmt"
+ "strings"
+
+ "github.com/coreos/etcd/pkg/fileutil"
+)
+
+var (
+ badWalName = errors.New("bad wal name")
+)
+
+func Exist(dirpath string) bool {
+ names, err := fileutil.ReadDir(dirpath)
+ if err != nil {
+ return false
+ }
+ return len(names) != 0
+}
+
+// searchIndex returns the last array index of names whose raft index section is
+// equal to or smaller than the given index.
+// The given names MUST be sorted.
+func searchIndex(names []string, index uint64) (int, bool) {
+ for i := len(names) - 1; i >= 0; i-- {
+ name := names[i]
+ _, curIndex, err := parseWalName(name)
+ if err != nil {
+ plog.Panicf("parse correct name should never fail: %v", err)
+ }
+ if index >= curIndex {
+ return i, true
+ }
+ }
+ return -1, false
+}
+
+// names should have been sorted based on sequence number.
+// isValidSeq checks whether seq increases continuously.
+func isValidSeq(names []string) bool {
+ var lastSeq uint64
+ for _, name := range names {
+ curSeq, _, err := parseWalName(name)
+ if err != nil {
+ plog.Panicf("parse correct name should never fail: %v", err)
+ }
+ if lastSeq != 0 && lastSeq != curSeq-1 {
+ return false
+ }
+ lastSeq = curSeq
+ }
+ return true
+}
+func readWalNames(dirpath string) ([]string, error) {
+ names, err := fileutil.ReadDir(dirpath)
+ if err != nil {
+ return nil, err
+ }
+ wnames := checkWalNames(names)
+ if len(wnames) == 0 {
+ return nil, ErrFileNotFound
+ }
+ return wnames, nil
+}
+
+func checkWalNames(names []string) []string {
+ wnames := make([]string, 0)
+ for _, name := range names {
+ if _, _, err := parseWalName(name); err != nil {
+ // don't complain about left over tmp files
+ if !strings.HasSuffix(name, ".tmp") {
+ plog.Warningf("ignored file %v in wal", name)
+ }
+ continue
+ }
+ wnames = append(wnames, name)
+ }
+ return wnames
+}
+
+func parseWalName(str string) (seq, index uint64, err error) {
+ if !strings.HasSuffix(str, ".wal") {
+ return 0, 0, badWalName
+ }
+ _, err = fmt.Sscanf(str, "%016x-%016x.wal", &seq, &index)
+ return seq, index, err
+}
+
+func walName(seq, index uint64) string {
+ return fmt.Sprintf("%016x-%016x.wal", seq, index)
+}
diff --git a/vendor/github.com/coreos/etcd/wal/wal.go b/vendor/github.com/coreos/etcd/wal/wal.go
new file mode 100644
index 00000000..2cac25c1
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/wal.go
@@ -0,0 +1,628 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wal
+
+import (
+ "bytes"
+ "errors"
+ "fmt"
+ "hash/crc32"
+ "io"
+ "os"
+ "path/filepath"
+ "sync"
+ "time"
+
+ "github.com/coreos/etcd/pkg/fileutil"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/raft"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/wal/walpb"
+
+ "github.com/coreos/pkg/capnslog"
+)
+
+const (
+ metadataType int64 = iota + 1
+ entryType
+ stateType
+ crcType
+ snapshotType
+
+ // warnSyncDuration is the amount of time allotted to an fsync before
+ // logging a warning
+ warnSyncDuration = time.Second
+)
+
+var (
+ // SegmentSizeBytes is the preallocated size of each wal segment file.
+ // The actual size might be larger than this. In general, the default
+ // value should be used, but this is defined as an exported variable
+ // so that tests can set a different segment size.
+ SegmentSizeBytes int64 = 64 * 1000 * 1000 // 64MB
+
+ plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "wal")
+
+ ErrMetadataConflict = errors.New("wal: conflicting metadata found")
+ ErrFileNotFound = errors.New("wal: file not found")
+ ErrCRCMismatch = errors.New("wal: crc mismatch")
+ ErrSnapshotMismatch = errors.New("wal: snapshot mismatch")
+ ErrSnapshotNotFound = errors.New("wal: snapshot not found")
+ crcTable = crc32.MakeTable(crc32.Castagnoli)
+)
+
+// WAL is a logical representation of the stable storage.
+// WAL is either in read mode or append mode but not both.
+// A newly created WAL is in append mode, and ready for appending records.
+// A just opened WAL is in read mode, and ready for reading records.
+// The WAL will be ready for appending after reading out all the previous records.
+type WAL struct {
+ dir string // the living directory of the underlay files
+
+ // dirFile is a fd for the wal directory for syncing on Rename
+ dirFile *os.File
+
+ metadata []byte // metadata recorded at the head of each WAL
+ state raftpb.HardState // hardstate recorded at the head of WAL
+
+ start walpb.Snapshot // snapshot to start reading
+ decoder *decoder // decoder to decode records
+ readClose func() error // closer for decode reader
+
+ mu sync.Mutex
+ enti uint64 // index of the last entry saved to the wal
+ encoder *encoder // encoder to encode records
+
+ locks []*fileutil.LockedFile // the locked files the WAL holds (the name is increasing)
+ fp *filePipeline
+}
+
+// Create creates a WAL ready for appending records. The given metadata is
+// recorded at the head of each WAL file, and can be retrieved with ReadAll.
+func Create(dirpath string, metadata []byte) (*WAL, error) {
+ if Exist(dirpath) {
+ return nil, os.ErrExist
+ }
+
+ // keep temporary wal directory so WAL initialization appears atomic
+ tmpdirpath := filepath.Clean(dirpath) + ".tmp"
+ if fileutil.Exist(tmpdirpath) {
+ if err := os.RemoveAll(tmpdirpath); err != nil {
+ return nil, err
+ }
+ }
+ if err := fileutil.CreateDirAll(tmpdirpath); err != nil {
+ return nil, err
+ }
+
+ p := filepath.Join(tmpdirpath, walName(0, 0))
+ f, err := fileutil.LockFile(p, os.O_WRONLY|os.O_CREATE, fileutil.PrivateFileMode)
+ if err != nil {
+ return nil, err
+ }
+ if _, err = f.Seek(0, io.SeekEnd); err != nil {
+ return nil, err
+ }
+ if err = fileutil.Preallocate(f.File, SegmentSizeBytes, true); err != nil {
+ return nil, err
+ }
+
+ w := &WAL{
+ dir: dirpath,
+ metadata: metadata,
+ }
+ w.encoder, err = newFileEncoder(f.File, 0)
+ if err != nil {
+ return nil, err
+ }
+ w.locks = append(w.locks, f)
+ if err = w.saveCrc(0); err != nil {
+ return nil, err
+ }
+ if err = w.encoder.encode(&walpb.Record{Type: metadataType, Data: metadata}); err != nil {
+ return nil, err
+ }
+ if err = w.SaveSnapshot(walpb.Snapshot{}); err != nil {
+ return nil, err
+ }
+
+ if w, err = w.renameWal(tmpdirpath); err != nil {
+ return nil, err
+ }
+
+ // directory was renamed; sync parent dir to persist rename
+ pdir, perr := fileutil.OpenDir(filepath.Dir(w.dir))
+ if perr != nil {
+ return nil, perr
+ }
+ if perr = fileutil.Fsync(pdir); perr != nil {
+ return nil, perr
+ }
+ if perr = pdir.Close(); err != nil {
+ return nil, perr
+ }
+
+ return w, nil
+}
+
+// Open opens the WAL at the given snap.
+// The snap SHOULD have been previously saved to the WAL, or the following
+// ReadAll will fail.
+// The returned WAL is ready to read and the first record will be the one after
+// the given snap. The WAL cannot be appended to before reading out all of its
+// previous records.
+func Open(dirpath string, snap walpb.Snapshot) (*WAL, error) {
+ w, err := openAtIndex(dirpath, snap, true)
+ if err != nil {
+ return nil, err
+ }
+ if w.dirFile, err = fileutil.OpenDir(w.dir); err != nil {
+ return nil, err
+ }
+ return w, nil
+}
+
+// OpenForRead only opens the wal files for read.
+// Write on a read only wal panics.
+func OpenForRead(dirpath string, snap walpb.Snapshot) (*WAL, error) {
+ return openAtIndex(dirpath, snap, false)
+}
+
+func openAtIndex(dirpath string, snap walpb.Snapshot, write bool) (*WAL, error) {
+ names, err := readWalNames(dirpath)
+ if err != nil {
+ return nil, err
+ }
+
+ nameIndex, ok := searchIndex(names, snap.Index)
+ if !ok || !isValidSeq(names[nameIndex:]) {
+ return nil, ErrFileNotFound
+ }
+
+ // open the wal files
+ rcs := make([]io.ReadCloser, 0)
+ rs := make([]io.Reader, 0)
+ ls := make([]*fileutil.LockedFile, 0)
+ for _, name := range names[nameIndex:] {
+ p := filepath.Join(dirpath, name)
+ if write {
+ l, err := fileutil.TryLockFile(p, os.O_RDWR, fileutil.PrivateFileMode)
+ if err != nil {
+ closeAll(rcs...)
+ return nil, err
+ }
+ ls = append(ls, l)
+ rcs = append(rcs, l)
+ } else {
+ rf, err := os.OpenFile(p, os.O_RDONLY, fileutil.PrivateFileMode)
+ if err != nil {
+ closeAll(rcs...)
+ return nil, err
+ }
+ ls = append(ls, nil)
+ rcs = append(rcs, rf)
+ }
+ rs = append(rs, rcs[len(rcs)-1])
+ }
+
+ closer := func() error { return closeAll(rcs...) }
+
+ // create a WAL ready for reading
+ w := &WAL{
+ dir: dirpath,
+ start: snap,
+ decoder: newDecoder(rs...),
+ readClose: closer,
+ locks: ls,
+ }
+
+ if write {
+ // write reuses the file descriptors from read; don't close so
+ // WAL can append without dropping the file lock
+ w.readClose = nil
+ if _, _, err := parseWalName(filepath.Base(w.tail().Name())); err != nil {
+ closer()
+ return nil, err
+ }
+ w.fp = newFilePipeline(w.dir, SegmentSizeBytes)
+ }
+
+ return w, nil
+}
+
+// ReadAll reads out records of the current WAL.
+// If opened in write mode, it must read out all records until EOF. Or an error
+// will be returned.
+// If opened in read mode, it will try to read all records if possible.
+// If it cannot read out the expected snap, it will return ErrSnapshotNotFound.
+// If loaded snap doesn't match with the expected one, it will return
+// all the records and error ErrSnapshotMismatch.
+// TODO: detect not-last-snap error.
+// TODO: maybe loose the checking of match.
+// After ReadAll, the WAL will be ready for appending new records.
+func (w *WAL) ReadAll() (metadata []byte, state raftpb.HardState, ents []raftpb.Entry, err error) {
+ w.mu.Lock()
+ defer w.mu.Unlock()
+
+ rec := &walpb.Record{}
+ decoder := w.decoder
+
+ var match bool
+ for err = decoder.decode(rec); err == nil; err = decoder.decode(rec) {
+ switch rec.Type {
+ case entryType:
+ e := mustUnmarshalEntry(rec.Data)
+ if e.Index > w.start.Index {
+ ents = append(ents[:e.Index-w.start.Index-1], e)
+ }
+ w.enti = e.Index
+ case stateType:
+ state = mustUnmarshalState(rec.Data)
+ case metadataType:
+ if metadata != nil && !bytes.Equal(metadata, rec.Data) {
+ state.Reset()
+ return nil, state, nil, ErrMetadataConflict
+ }
+ metadata = rec.Data
+ case crcType:
+ crc := decoder.crc.Sum32()
+ // current crc of decoder must match the crc of the record.
+ // do no need to match 0 crc, since the decoder is a new one at this case.
+ if crc != 0 && rec.Validate(crc) != nil {
+ state.Reset()
+ return nil, state, nil, ErrCRCMismatch
+ }
+ decoder.updateCRC(rec.Crc)
+ case snapshotType:
+ var snap walpb.Snapshot
+ pbutil.MustUnmarshal(&snap, rec.Data)
+ if snap.Index == w.start.Index {
+ if snap.Term != w.start.Term {
+ state.Reset()
+ return nil, state, nil, ErrSnapshotMismatch
+ }
+ match = true
+ }
+ default:
+ state.Reset()
+ return nil, state, nil, fmt.Errorf("unexpected block type %d", rec.Type)
+ }
+ }
+
+ switch w.tail() {
+ case nil:
+ // We do not have to read out all entries in read mode.
+ // The last record maybe a partial written one, so
+ // ErrunexpectedEOF might be returned.
+ if err != io.EOF && err != io.ErrUnexpectedEOF {
+ state.Reset()
+ return nil, state, nil, err
+ }
+ default:
+ // We must read all of the entries if WAL is opened in write mode.
+ if err != io.EOF {
+ state.Reset()
+ return nil, state, nil, err
+ }
+ // decodeRecord() will return io.EOF if it detects a zero record,
+ // but this zero record may be followed by non-zero records from
+ // a torn write. Overwriting some of these non-zero records, but
+ // not all, will cause CRC errors on WAL open. Since the records
+ // were never fully synced to disk in the first place, it's safe
+ // to zero them out to avoid any CRC errors from new writes.
+ if _, err = w.tail().Seek(w.decoder.lastOffset(), io.SeekStart); err != nil {
+ return nil, state, nil, err
+ }
+ if err = fileutil.ZeroToEnd(w.tail().File); err != nil {
+ return nil, state, nil, err
+ }
+ }
+
+ err = nil
+ if !match {
+ err = ErrSnapshotNotFound
+ }
+
+ // close decoder, disable reading
+ if w.readClose != nil {
+ w.readClose()
+ w.readClose = nil
+ }
+ w.start = walpb.Snapshot{}
+
+ w.metadata = metadata
+
+ if w.tail() != nil {
+ // create encoder (chain crc with the decoder), enable appending
+ w.encoder, err = newFileEncoder(w.tail().File, w.decoder.lastCRC())
+ if err != nil {
+ return
+ }
+ }
+ w.decoder = nil
+
+ return metadata, state, ents, err
+}
+
+// cut closes current file written and creates a new one ready to append.
+// cut first creates a temp wal file and writes necessary headers into it.
+// Then cut atomically rename temp wal file to a wal file.
+func (w *WAL) cut() error {
+ // close old wal file; truncate to avoid wasting space if an early cut
+ off, serr := w.tail().Seek(0, io.SeekCurrent)
+ if serr != nil {
+ return serr
+ }
+ if err := w.tail().Truncate(off); err != nil {
+ return err
+ }
+ if err := w.sync(); err != nil {
+ return err
+ }
+
+ fpath := filepath.Join(w.dir, walName(w.seq()+1, w.enti+1))
+
+ // create a temp wal file with name sequence + 1, or truncate the existing one
+ newTail, err := w.fp.Open()
+ if err != nil {
+ return err
+ }
+
+ // update writer and save the previous crc
+ w.locks = append(w.locks, newTail)
+ prevCrc := w.encoder.crc.Sum32()
+ w.encoder, err = newFileEncoder(w.tail().File, prevCrc)
+ if err != nil {
+ return err
+ }
+ if err = w.saveCrc(prevCrc); err != nil {
+ return err
+ }
+ if err = w.encoder.encode(&walpb.Record{Type: metadataType, Data: w.metadata}); err != nil {
+ return err
+ }
+ if err = w.saveState(&w.state); err != nil {
+ return err
+ }
+ // atomically move temp wal file to wal file
+ if err = w.sync(); err != nil {
+ return err
+ }
+
+ off, err = w.tail().Seek(0, io.SeekCurrent)
+ if err != nil {
+ return err
+ }
+
+ if err = os.Rename(newTail.Name(), fpath); err != nil {
+ return err
+ }
+ if err = fileutil.Fsync(w.dirFile); err != nil {
+ return err
+ }
+
+ newTail.Close()
+
+ if newTail, err = fileutil.LockFile(fpath, os.O_WRONLY, fileutil.PrivateFileMode); err != nil {
+ return err
+ }
+ if _, err = newTail.Seek(off, io.SeekStart); err != nil {
+ return err
+ }
+
+ w.locks[len(w.locks)-1] = newTail
+
+ prevCrc = w.encoder.crc.Sum32()
+ w.encoder, err = newFileEncoder(w.tail().File, prevCrc)
+ if err != nil {
+ return err
+ }
+
+ plog.Infof("segmented wal file %v is created", fpath)
+ return nil
+}
+
+func (w *WAL) sync() error {
+ if w.encoder != nil {
+ if err := w.encoder.flush(); err != nil {
+ return err
+ }
+ }
+ start := time.Now()
+ err := fileutil.Fdatasync(w.tail().File)
+
+ duration := time.Since(start)
+ if duration > warnSyncDuration {
+ plog.Warningf("sync duration of %v, expected less than %v", duration, warnSyncDuration)
+ }
+ syncDurations.Observe(duration.Seconds())
+
+ return err
+}
+
+// ReleaseLockTo releases the locks, which has smaller index than the given index
+// except the largest one among them.
+// For example, if WAL is holding lock 1,2,3,4,5,6, ReleaseLockTo(4) will release
+// lock 1,2 but keep 3. ReleaseLockTo(5) will release 1,2,3 but keep 4.
+func (w *WAL) ReleaseLockTo(index uint64) error {
+ w.mu.Lock()
+ defer w.mu.Unlock()
+
+ var smaller int
+ found := false
+
+ for i, l := range w.locks {
+ _, lockIndex, err := parseWalName(filepath.Base(l.Name()))
+ if err != nil {
+ return err
+ }
+ if lockIndex >= index {
+ smaller = i - 1
+ found = true
+ break
+ }
+ }
+
+ // if no lock index is greater than the release index, we can
+ // release lock up to the last one(excluding).
+ if !found && len(w.locks) != 0 {
+ smaller = len(w.locks) - 1
+ }
+
+ if smaller <= 0 {
+ return nil
+ }
+
+ for i := 0; i < smaller; i++ {
+ if w.locks[i] == nil {
+ continue
+ }
+ w.locks[i].Close()
+ }
+ w.locks = w.locks[smaller:]
+
+ return nil
+}
+
+func (w *WAL) Close() error {
+ w.mu.Lock()
+ defer w.mu.Unlock()
+
+ if w.fp != nil {
+ w.fp.Close()
+ w.fp = nil
+ }
+
+ if w.tail() != nil {
+ if err := w.sync(); err != nil {
+ return err
+ }
+ }
+ for _, l := range w.locks {
+ if l == nil {
+ continue
+ }
+ if err := l.Close(); err != nil {
+ plog.Errorf("failed to unlock during closing wal: %s", err)
+ }
+ }
+
+ return w.dirFile.Close()
+}
+
+func (w *WAL) saveEntry(e *raftpb.Entry) error {
+ // TODO: add MustMarshalTo to reduce one allocation.
+ b := pbutil.MustMarshal(e)
+ rec := &walpb.Record{Type: entryType, Data: b}
+ if err := w.encoder.encode(rec); err != nil {
+ return err
+ }
+ w.enti = e.Index
+ return nil
+}
+
+func (w *WAL) saveState(s *raftpb.HardState) error {
+ if raft.IsEmptyHardState(*s) {
+ return nil
+ }
+ w.state = *s
+ b := pbutil.MustMarshal(s)
+ rec := &walpb.Record{Type: stateType, Data: b}
+ return w.encoder.encode(rec)
+}
+
+func (w *WAL) Save(st raftpb.HardState, ents []raftpb.Entry) error {
+ w.mu.Lock()
+ defer w.mu.Unlock()
+
+ // short cut, do not call sync
+ if raft.IsEmptyHardState(st) && len(ents) == 0 {
+ return nil
+ }
+
+ mustSync := raft.MustSync(st, w.state, len(ents))
+
+ // TODO(xiangli): no more reference operator
+ for i := range ents {
+ if err := w.saveEntry(&ents[i]); err != nil {
+ return err
+ }
+ }
+ if err := w.saveState(&st); err != nil {
+ return err
+ }
+
+ curOff, err := w.tail().Seek(0, io.SeekCurrent)
+ if err != nil {
+ return err
+ }
+ if curOff < SegmentSizeBytes {
+ if mustSync {
+ return w.sync()
+ }
+ return nil
+ }
+
+ return w.cut()
+}
+
+func (w *WAL) SaveSnapshot(e walpb.Snapshot) error {
+ b := pbutil.MustMarshal(&e)
+
+ w.mu.Lock()
+ defer w.mu.Unlock()
+
+ rec := &walpb.Record{Type: snapshotType, Data: b}
+ if err := w.encoder.encode(rec); err != nil {
+ return err
+ }
+ // update enti only when snapshot is ahead of last index
+ if w.enti < e.Index {
+ w.enti = e.Index
+ }
+ return w.sync()
+}
+
+func (w *WAL) saveCrc(prevCrc uint32) error {
+ return w.encoder.encode(&walpb.Record{Type: crcType, Crc: prevCrc})
+}
+
+func (w *WAL) tail() *fileutil.LockedFile {
+ if len(w.locks) > 0 {
+ return w.locks[len(w.locks)-1]
+ }
+ return nil
+}
+
+func (w *WAL) seq() uint64 {
+ t := w.tail()
+ if t == nil {
+ return 0
+ }
+ seq, _, err := parseWalName(filepath.Base(t.Name()))
+ if err != nil {
+ plog.Fatalf("bad wal name %s (%v)", t.Name(), err)
+ }
+ return seq
+}
+
+func closeAll(rcs ...io.ReadCloser) error {
+ for _, f := range rcs {
+ if err := f.Close(); err != nil {
+ return err
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/coreos/etcd/wal/wal_bench_test.go b/vendor/github.com/coreos/etcd/wal/wal_bench_test.go
new file mode 100644
index 00000000..914e61c7
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/wal_bench_test.go
@@ -0,0 +1,68 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wal
+
+import (
+ "io/ioutil"
+ "os"
+ "testing"
+
+ "github.com/coreos/etcd/raft/raftpb"
+)
+
+func BenchmarkWrite100EntryWithoutBatch(b *testing.B) { benchmarkWriteEntry(b, 100, 0) }
+func BenchmarkWrite100EntryBatch10(b *testing.B) { benchmarkWriteEntry(b, 100, 10) }
+func BenchmarkWrite100EntryBatch100(b *testing.B) { benchmarkWriteEntry(b, 100, 100) }
+func BenchmarkWrite100EntryBatch500(b *testing.B) { benchmarkWriteEntry(b, 100, 500) }
+func BenchmarkWrite100EntryBatch1000(b *testing.B) { benchmarkWriteEntry(b, 100, 1000) }
+
+func BenchmarkWrite1000EntryWithoutBatch(b *testing.B) { benchmarkWriteEntry(b, 1000, 0) }
+func BenchmarkWrite1000EntryBatch10(b *testing.B) { benchmarkWriteEntry(b, 1000, 10) }
+func BenchmarkWrite1000EntryBatch100(b *testing.B) { benchmarkWriteEntry(b, 1000, 100) }
+func BenchmarkWrite1000EntryBatch500(b *testing.B) { benchmarkWriteEntry(b, 1000, 500) }
+func BenchmarkWrite1000EntryBatch1000(b *testing.B) { benchmarkWriteEntry(b, 1000, 1000) }
+
+func benchmarkWriteEntry(b *testing.B, size int, batch int) {
+ p, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ b.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+
+ w, err := Create(p, []byte("somedata"))
+ if err != nil {
+ b.Fatalf("err = %v, want nil", err)
+ }
+ data := make([]byte, size)
+ for i := 0; i < size; i++ {
+ data[i] = byte(i)
+ }
+ e := &raftpb.Entry{Data: data}
+
+ b.ResetTimer()
+ n := 0
+ b.SetBytes(int64(e.Size()))
+ for i := 0; i < b.N; i++ {
+ err := w.saveEntry(e)
+ if err != nil {
+ b.Fatal(err)
+ }
+ n++
+ if n > batch {
+ w.sync()
+ n = 0
+ }
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/wal/wal_test.go b/vendor/github.com/coreos/etcd/wal/wal_test.go
new file mode 100644
index 00000000..4528e229
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/wal_test.go
@@ -0,0 +1,795 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 wal
+
+import (
+ "bytes"
+ "io"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "reflect"
+ "testing"
+
+ "github.com/coreos/etcd/pkg/fileutil"
+ "github.com/coreos/etcd/pkg/pbutil"
+ "github.com/coreos/etcd/raft/raftpb"
+ "github.com/coreos/etcd/wal/walpb"
+)
+
+func TestNew(t *testing.T) {
+ p, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+
+ w, err := Create(p, []byte("somedata"))
+ if err != nil {
+ t.Fatalf("err = %v, want nil", err)
+ }
+ if g := filepath.Base(w.tail().Name()); g != walName(0, 0) {
+ t.Errorf("name = %+v, want %+v", g, walName(0, 0))
+ }
+ defer w.Close()
+
+ // file is preallocated to segment size; only read data written by wal
+ off, err := w.tail().Seek(0, io.SeekCurrent)
+ if err != nil {
+ t.Fatal(err)
+ }
+ gd := make([]byte, off)
+ f, err := os.Open(filepath.Join(p, filepath.Base(w.tail().Name())))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer f.Close()
+ if _, err = io.ReadFull(f, gd); err != nil {
+ t.Fatalf("err = %v, want nil", err)
+ }
+
+ var wb bytes.Buffer
+ e := newEncoder(&wb, 0, 0)
+ err = e.encode(&walpb.Record{Type: crcType, Crc: 0})
+ if err != nil {
+ t.Fatalf("err = %v, want nil", err)
+ }
+ err = e.encode(&walpb.Record{Type: metadataType, Data: []byte("somedata")})
+ if err != nil {
+ t.Fatalf("err = %v, want nil", err)
+ }
+ r := &walpb.Record{
+ Type: snapshotType,
+ Data: pbutil.MustMarshal(&walpb.Snapshot{}),
+ }
+ if err = e.encode(r); err != nil {
+ t.Fatalf("err = %v, want nil", err)
+ }
+ e.flush()
+ if !bytes.Equal(gd, wb.Bytes()) {
+ t.Errorf("data = %v, want %v", gd, wb.Bytes())
+ }
+}
+
+func TestNewForInitedDir(t *testing.T) {
+ p, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+
+ os.Create(filepath.Join(p, walName(0, 0)))
+ if _, err = Create(p, nil); err == nil || err != os.ErrExist {
+ t.Errorf("err = %v, want %v", err, os.ErrExist)
+ }
+}
+
+func TestOpenAtIndex(t *testing.T) {
+ dir, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(dir)
+
+ f, err := os.Create(filepath.Join(dir, walName(0, 0)))
+ if err != nil {
+ t.Fatal(err)
+ }
+ f.Close()
+
+ w, err := Open(dir, walpb.Snapshot{})
+ if err != nil {
+ t.Fatalf("err = %v, want nil", err)
+ }
+ if g := filepath.Base(w.tail().Name()); g != walName(0, 0) {
+ t.Errorf("name = %+v, want %+v", g, walName(0, 0))
+ }
+ if w.seq() != 0 {
+ t.Errorf("seq = %d, want %d", w.seq(), 0)
+ }
+ w.Close()
+
+ wname := walName(2, 10)
+ f, err = os.Create(filepath.Join(dir, wname))
+ if err != nil {
+ t.Fatal(err)
+ }
+ f.Close()
+
+ w, err = Open(dir, walpb.Snapshot{Index: 5})
+ if err != nil {
+ t.Fatalf("err = %v, want nil", err)
+ }
+ if g := filepath.Base(w.tail().Name()); g != wname {
+ t.Errorf("name = %+v, want %+v", g, wname)
+ }
+ if w.seq() != 2 {
+ t.Errorf("seq = %d, want %d", w.seq(), 2)
+ }
+ w.Close()
+
+ emptydir, err := ioutil.TempDir(os.TempDir(), "waltestempty")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(emptydir)
+ if _, err = Open(emptydir, walpb.Snapshot{}); err != ErrFileNotFound {
+ t.Errorf("err = %v, want %v", err, ErrFileNotFound)
+ }
+}
+
+// TODO: split it into smaller tests for better readability
+func TestCut(t *testing.T) {
+ p, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+
+ w, err := Create(p, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer w.Close()
+
+ state := raftpb.HardState{Term: 1}
+ if err = w.Save(state, nil); err != nil {
+ t.Fatal(err)
+ }
+ if err = w.cut(); err != nil {
+ t.Fatal(err)
+ }
+ wname := walName(1, 1)
+ if g := filepath.Base(w.tail().Name()); g != wname {
+ t.Errorf("name = %s, want %s", g, wname)
+ }
+
+ es := []raftpb.Entry{{Index: 1, Term: 1, Data: []byte{1}}}
+ if err = w.Save(raftpb.HardState{}, es); err != nil {
+ t.Fatal(err)
+ }
+ if err = w.cut(); err != nil {
+ t.Fatal(err)
+ }
+ snap := walpb.Snapshot{Index: 2, Term: 1}
+ if err = w.SaveSnapshot(snap); err != nil {
+ t.Fatal(err)
+ }
+ wname = walName(2, 2)
+ if g := filepath.Base(w.tail().Name()); g != wname {
+ t.Errorf("name = %s, want %s", g, wname)
+ }
+
+ // check the state in the last WAL
+ // We do check before closing the WAL to ensure that Cut syncs the data
+ // into the disk.
+ f, err := os.Open(filepath.Join(p, wname))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer f.Close()
+ nw := &WAL{
+ decoder: newDecoder(f),
+ start: snap,
+ }
+ _, gst, _, err := nw.ReadAll()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !reflect.DeepEqual(gst, state) {
+ t.Errorf("state = %+v, want %+v", gst, state)
+ }
+}
+
+func TestSaveWithCut(t *testing.T) {
+ p, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+
+ w, err := Create(p, []byte("metadata"))
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ state := raftpb.HardState{Term: 1}
+ if err = w.Save(state, nil); err != nil {
+ t.Fatal(err)
+ }
+ bigData := make([]byte, 500)
+ strdata := "Hello World!!"
+ copy(bigData, strdata)
+ // set a lower value for SegmentSizeBytes, else the test takes too long to complete
+ restoreLater := SegmentSizeBytes
+ const EntrySize int = 500
+ SegmentSizeBytes = 2 * 1024
+ defer func() { SegmentSizeBytes = restoreLater }()
+ var index uint64 = 0
+ for totalSize := 0; totalSize < int(SegmentSizeBytes); totalSize += EntrySize {
+ ents := []raftpb.Entry{{Index: index, Term: 1, Data: bigData}}
+ if err = w.Save(state, ents); err != nil {
+ t.Fatal(err)
+ }
+ index++
+ }
+
+ w.Close()
+
+ neww, err := Open(p, walpb.Snapshot{})
+ if err != nil {
+ t.Fatalf("err = %v, want nil", err)
+ }
+ defer neww.Close()
+ wname := walName(1, index)
+ if g := filepath.Base(neww.tail().Name()); g != wname {
+ t.Errorf("name = %s, want %s", g, wname)
+ }
+
+ _, newhardstate, entries, err := neww.ReadAll()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if !reflect.DeepEqual(newhardstate, state) {
+ t.Errorf("Hard State = %+v, want %+v", newhardstate, state)
+ }
+ if len(entries) != int(SegmentSizeBytes/int64(EntrySize)) {
+ t.Errorf("Number of entries = %d, expected = %d", len(entries), int(SegmentSizeBytes/int64(EntrySize)))
+ }
+ for _, oneent := range entries {
+ if !bytes.Equal(oneent.Data, bigData) {
+ t.Errorf("the saved data does not match at Index %d : found: %s , want :%s", oneent.Index, oneent.Data, bigData)
+ }
+ }
+}
+
+func TestRecover(t *testing.T) {
+ p, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+
+ w, err := Create(p, []byte("metadata"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = w.SaveSnapshot(walpb.Snapshot{}); err != nil {
+ t.Fatal(err)
+ }
+ ents := []raftpb.Entry{{Index: 1, Term: 1, Data: []byte{1}}, {Index: 2, Term: 2, Data: []byte{2}}}
+ if err = w.Save(raftpb.HardState{}, ents); err != nil {
+ t.Fatal(err)
+ }
+ sts := []raftpb.HardState{{Term: 1, Vote: 1, Commit: 1}, {Term: 2, Vote: 2, Commit: 2}}
+ for _, s := range sts {
+ if err = w.Save(s, nil); err != nil {
+ t.Fatal(err)
+ }
+ }
+ w.Close()
+
+ if w, err = Open(p, walpb.Snapshot{}); err != nil {
+ t.Fatal(err)
+ }
+ metadata, state, entries, err := w.ReadAll()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if !bytes.Equal(metadata, []byte("metadata")) {
+ t.Errorf("metadata = %s, want %s", metadata, "metadata")
+ }
+ if !reflect.DeepEqual(entries, ents) {
+ t.Errorf("ents = %+v, want %+v", entries, ents)
+ }
+ // only the latest state is recorded
+ s := sts[len(sts)-1]
+ if !reflect.DeepEqual(state, s) {
+ t.Errorf("state = %+v, want %+v", state, s)
+ }
+ w.Close()
+}
+
+func TestSearchIndex(t *testing.T) {
+ tests := []struct {
+ names []string
+ index uint64
+ widx int
+ wok bool
+ }{
+ {
+ []string{
+ "0000000000000000-0000000000000000.wal",
+ "0000000000000001-0000000000001000.wal",
+ "0000000000000002-0000000000002000.wal",
+ },
+ 0x1000, 1, true,
+ },
+ {
+ []string{
+ "0000000000000001-0000000000004000.wal",
+ "0000000000000002-0000000000003000.wal",
+ "0000000000000003-0000000000005000.wal",
+ },
+ 0x4000, 1, true,
+ },
+ {
+ []string{
+ "0000000000000001-0000000000002000.wal",
+ "0000000000000002-0000000000003000.wal",
+ "0000000000000003-0000000000005000.wal",
+ },
+ 0x1000, -1, false,
+ },
+ }
+ for i, tt := range tests {
+ idx, ok := searchIndex(tt.names, tt.index)
+ if idx != tt.widx {
+ t.Errorf("#%d: idx = %d, want %d", i, idx, tt.widx)
+ }
+ if ok != tt.wok {
+ t.Errorf("#%d: ok = %v, want %v", i, ok, tt.wok)
+ }
+ }
+}
+
+func TestScanWalName(t *testing.T) {
+ tests := []struct {
+ str string
+ wseq, windex uint64
+ wok bool
+ }{
+ {"0000000000000000-0000000000000000.wal", 0, 0, true},
+ {"0000000000000000.wal", 0, 0, false},
+ {"0000000000000000-0000000000000000.snap", 0, 0, false},
+ }
+ for i, tt := range tests {
+ s, index, err := parseWalName(tt.str)
+ if g := err == nil; g != tt.wok {
+ t.Errorf("#%d: ok = %v, want %v", i, g, tt.wok)
+ }
+ if s != tt.wseq {
+ t.Errorf("#%d: seq = %d, want %d", i, s, tt.wseq)
+ }
+ if index != tt.windex {
+ t.Errorf("#%d: index = %d, want %d", i, index, tt.windex)
+ }
+ }
+}
+
+func TestRecoverAfterCut(t *testing.T) {
+ p, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+
+ md, err := Create(p, []byte("metadata"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ for i := 0; i < 10; i++ {
+ if err = md.SaveSnapshot(walpb.Snapshot{Index: uint64(i)}); err != nil {
+ t.Fatal(err)
+ }
+ es := []raftpb.Entry{{Index: uint64(i)}}
+ if err = md.Save(raftpb.HardState{}, es); err != nil {
+ t.Fatal(err)
+ }
+ if err = md.cut(); err != nil {
+ t.Fatal(err)
+ }
+ }
+ md.Close()
+
+ if err := os.Remove(filepath.Join(p, walName(4, 4))); err != nil {
+ t.Fatal(err)
+ }
+
+ for i := 0; i < 10; i++ {
+ w, err := Open(p, walpb.Snapshot{Index: uint64(i)})
+ if err != nil {
+ if i <= 4 {
+ if err != ErrFileNotFound {
+ t.Errorf("#%d: err = %v, want %v", i, err, ErrFileNotFound)
+ }
+ } else {
+ t.Errorf("#%d: err = %v, want nil", i, err)
+ }
+ continue
+ }
+ metadata, _, entries, err := w.ReadAll()
+ if err != nil {
+ t.Errorf("#%d: err = %v, want nil", i, err)
+ continue
+ }
+ if !bytes.Equal(metadata, []byte("metadata")) {
+ t.Errorf("#%d: metadata = %s, want %s", i, metadata, "metadata")
+ }
+ for j, e := range entries {
+ if e.Index != uint64(j+i+1) {
+ t.Errorf("#%d: ents[%d].Index = %+v, want %+v", i, j, e.Index, j+i+1)
+ }
+ }
+ w.Close()
+ }
+}
+
+func TestOpenAtUncommittedIndex(t *testing.T) {
+ p, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+
+ w, err := Create(p, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = w.SaveSnapshot(walpb.Snapshot{}); err != nil {
+ t.Fatal(err)
+ }
+ if err = w.Save(raftpb.HardState{}, []raftpb.Entry{{Index: 0}}); err != nil {
+ t.Fatal(err)
+ }
+ w.Close()
+
+ w, err = Open(p, walpb.Snapshot{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ // commit up to index 0, try to read index 1
+ if _, _, _, err = w.ReadAll(); err != nil {
+ t.Errorf("err = %v, want nil", err)
+ }
+ w.Close()
+}
+
+// TestOpenForRead tests that OpenForRead can load all files.
+// The tests creates WAL directory, and cut out multiple WAL files. Then
+// it releases the lock of part of data, and excepts that OpenForRead
+// can read out all files even if some are locked for write.
+func TestOpenForRead(t *testing.T) {
+ p, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+ // create WAL
+ w, err := Create(p, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer w.Close()
+ // make 10 separate files
+ for i := 0; i < 10; i++ {
+ es := []raftpb.Entry{{Index: uint64(i)}}
+ if err = w.Save(raftpb.HardState{}, es); err != nil {
+ t.Fatal(err)
+ }
+ if err = w.cut(); err != nil {
+ t.Fatal(err)
+ }
+ }
+ // release the lock to 5
+ unlockIndex := uint64(5)
+ w.ReleaseLockTo(unlockIndex)
+
+ // All are available for read
+ w2, err := OpenForRead(p, walpb.Snapshot{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer w2.Close()
+ _, _, ents, err := w2.ReadAll()
+ if err != nil {
+ t.Fatalf("err = %v, want nil", err)
+ }
+ if g := ents[len(ents)-1].Index; g != 9 {
+ t.Errorf("last index read = %d, want %d", g, 9)
+ }
+}
+
+func TestSaveEmpty(t *testing.T) {
+ var buf bytes.Buffer
+ var est raftpb.HardState
+ w := WAL{
+ encoder: newEncoder(&buf, 0, 0),
+ }
+ if err := w.saveState(&est); err != nil {
+ t.Errorf("err = %v, want nil", err)
+ }
+ if len(buf.Bytes()) != 0 {
+ t.Errorf("buf.Bytes = %d, want 0", len(buf.Bytes()))
+ }
+}
+
+func TestReleaseLockTo(t *testing.T) {
+ p, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+ // create WAL
+ w, err := Create(p, nil)
+ defer func() {
+ if err = w.Close(); err != nil {
+ t.Fatal(err)
+ }
+ }()
+ if err != nil {
+ t.Fatal(err)
+ }
+ // make 10 separate files
+ for i := 0; i < 10; i++ {
+ es := []raftpb.Entry{{Index: uint64(i)}}
+ if err = w.Save(raftpb.HardState{}, es); err != nil {
+ t.Fatal(err)
+ }
+ if err = w.cut(); err != nil {
+ t.Fatal(err)
+ }
+ }
+ // release the lock to 5
+ unlockIndex := uint64(5)
+ w.ReleaseLockTo(unlockIndex)
+
+ // expected remaining are 4,5,6,7,8,9,10
+ if len(w.locks) != 7 {
+ t.Errorf("len(w.locks) = %d, want %d", len(w.locks), 7)
+ }
+ for i, l := range w.locks {
+ var lockIndex uint64
+ _, lockIndex, err = parseWalName(filepath.Base(l.Name()))
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if lockIndex != uint64(i+4) {
+ t.Errorf("#%d: lockindex = %d, want %d", i, lockIndex, uint64(i+4))
+ }
+ }
+
+ // release the lock to 15
+ unlockIndex = uint64(15)
+ w.ReleaseLockTo(unlockIndex)
+
+ // expected remaining is 10
+ if len(w.locks) != 1 {
+ t.Errorf("len(w.locks) = %d, want %d", len(w.locks), 1)
+ }
+ _, lockIndex, err := parseWalName(filepath.Base(w.locks[0].Name()))
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if lockIndex != uint64(10) {
+ t.Errorf("lockindex = %d, want %d", lockIndex, 10)
+ }
+}
+
+// TestTailWriteNoSlackSpace ensures that tail writes append if there's no preallocated space.
+func TestTailWriteNoSlackSpace(t *testing.T) {
+ p, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+
+ // create initial WAL
+ w, err := Create(p, []byte("metadata"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ // write some entries
+ for i := 1; i <= 5; i++ {
+ es := []raftpb.Entry{{Index: uint64(i), Term: 1, Data: []byte{byte(i)}}}
+ if err = w.Save(raftpb.HardState{Term: 1}, es); err != nil {
+ t.Fatal(err)
+ }
+ }
+ // get rid of slack space by truncating file
+ off, serr := w.tail().Seek(0, io.SeekCurrent)
+ if serr != nil {
+ t.Fatal(serr)
+ }
+ if terr := w.tail().Truncate(off); terr != nil {
+ t.Fatal(terr)
+ }
+ w.Close()
+
+ // open, write more
+ w, err = Open(p, walpb.Snapshot{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, _, ents, rerr := w.ReadAll()
+ if rerr != nil {
+ t.Fatal(rerr)
+ }
+ if len(ents) != 5 {
+ t.Fatalf("got entries %+v, expected 5 entries", ents)
+ }
+ // write more entries
+ for i := 6; i <= 10; i++ {
+ es := []raftpb.Entry{{Index: uint64(i), Term: 1, Data: []byte{byte(i)}}}
+ if err = w.Save(raftpb.HardState{Term: 1}, es); err != nil {
+ t.Fatal(err)
+ }
+ }
+ w.Close()
+
+ // confirm all writes
+ w, err = Open(p, walpb.Snapshot{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, _, ents, rerr = w.ReadAll()
+ if rerr != nil {
+ t.Fatal(rerr)
+ }
+ if len(ents) != 10 {
+ t.Fatalf("got entries %+v, expected 10 entries", ents)
+ }
+ w.Close()
+}
+
+// TestRestartCreateWal ensures that an interrupted WAL initialization is clobbered on restart
+func TestRestartCreateWal(t *testing.T) {
+ p, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+
+ // make temporary directory so it looks like initialization is interrupted
+ tmpdir := filepath.Clean(p) + ".tmp"
+ if err = os.Mkdir(tmpdir, fileutil.PrivateDirMode); err != nil {
+ t.Fatal(err)
+ }
+ if _, err = os.OpenFile(filepath.Join(tmpdir, "test"), os.O_WRONLY|os.O_CREATE, fileutil.PrivateFileMode); err != nil {
+ t.Fatal(err)
+ }
+
+ w, werr := Create(p, []byte("abc"))
+ if werr != nil {
+ t.Fatal(werr)
+ }
+ w.Close()
+ if Exist(tmpdir) {
+ t.Fatalf("got %q exists, expected it to not exist", tmpdir)
+ }
+
+ if w, err = OpenForRead(p, walpb.Snapshot{}); err != nil {
+ t.Fatal(err)
+ }
+ defer w.Close()
+
+ if meta, _, _, rerr := w.ReadAll(); rerr != nil || string(meta) != "abc" {
+ t.Fatalf("got error %v and meta %q, expected nil and %q", rerr, meta, "abc")
+ }
+}
+
+// TestOpenOnTornWrite ensures that entries past the torn write are truncated.
+func TestOpenOnTornWrite(t *testing.T) {
+ maxEntries := 40
+ clobberIdx := 20
+ overwriteEntries := 5
+
+ p, err := ioutil.TempDir(os.TempDir(), "waltest")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(p)
+ w, err := Create(p, nil)
+ defer func() {
+ if err = w.Close(); err != nil && err != os.ErrInvalid {
+ t.Fatal(err)
+ }
+ }()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // get offset of end of each saved entry
+ offsets := make([]int64, maxEntries)
+ for i := range offsets {
+ es := []raftpb.Entry{{Index: uint64(i)}}
+ if err = w.Save(raftpb.HardState{}, es); err != nil {
+ t.Fatal(err)
+ }
+ if offsets[i], err = w.tail().Seek(0, io.SeekCurrent); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ fn := filepath.Join(p, filepath.Base(w.tail().Name()))
+ w.Close()
+
+ // clobber some entry with 0's to simulate a torn write
+ f, ferr := os.OpenFile(fn, os.O_WRONLY, fileutil.PrivateFileMode)
+ if ferr != nil {
+ t.Fatal(ferr)
+ }
+ defer f.Close()
+ _, err = f.Seek(offsets[clobberIdx], io.SeekStart)
+ if err != nil {
+ t.Fatal(err)
+ }
+ zeros := make([]byte, offsets[clobberIdx+1]-offsets[clobberIdx])
+ _, err = f.Write(zeros)
+ if err != nil {
+ t.Fatal(err)
+ }
+ f.Close()
+
+ w, err = Open(p, walpb.Snapshot{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ // seek up to clobbered entry
+ _, _, _, err = w.ReadAll()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // write a few entries past the clobbered entry
+ for i := 0; i < overwriteEntries; i++ {
+ // Index is different from old, truncated entries
+ es := []raftpb.Entry{{Index: uint64(i + clobberIdx), Data: []byte("new")}}
+ if err = w.Save(raftpb.HardState{}, es); err != nil {
+ t.Fatal(err)
+ }
+ }
+ w.Close()
+
+ // read back the entries, confirm number of entries matches expectation
+ w, err = OpenForRead(p, walpb.Snapshot{})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ _, _, ents, rerr := w.ReadAll()
+ if rerr != nil {
+ // CRC error? the old entries were likely never truncated away
+ t.Fatal(rerr)
+ }
+ wEntries := (clobberIdx - 1) + overwriteEntries
+ if len(ents) != wEntries {
+ t.Fatalf("expected len(ents) = %d, got %d", wEntries, len(ents))
+ }
+}
diff --git a/vendor/github.com/coreos/etcd/wal/wal_unix.go b/vendor/github.com/coreos/etcd/wal/wal_unix.go
new file mode 100644
index 00000000..82fd6a17
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/wal_unix.go
@@ -0,0 +1,44 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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.
+
+// +build !windows
+
+package wal
+
+import (
+ "os"
+
+ "github.com/coreos/etcd/pkg/fileutil"
+)
+
+func (w *WAL) renameWal(tmpdirpath string) (*WAL, error) {
+ // On non-Windows platforms, hold the lock while renaming. Releasing
+ // the lock and trying to reacquire it quickly can be flaky because
+ // it's possible the process will fork to spawn a process while this is
+ // happening. The fds are set up as close-on-exec by the Go runtime,
+ // but there is a window between the fork and the exec where another
+ // process holds the lock.
+
+ if err := os.RemoveAll(w.dir); err != nil {
+ return nil, err
+ }
+ if err := os.Rename(tmpdirpath, w.dir); err != nil {
+ return nil, err
+ }
+
+ w.fp = newFilePipeline(w.dir, SegmentSizeBytes)
+ df, err := fileutil.OpenDir(w.dir)
+ w.dirFile = df
+ return w, err
+}
diff --git a/vendor/github.com/coreos/etcd/wal/wal_windows.go b/vendor/github.com/coreos/etcd/wal/wal_windows.go
new file mode 100644
index 00000000..0b9e434c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/wal_windows.go
@@ -0,0 +1,41 @@
+// Copyright 2016 The etcd Authors
+//
+// Licensed 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 wal
+
+import (
+ "os"
+
+ "github.com/coreos/etcd/wal/walpb"
+)
+
+func (w *WAL) renameWal(tmpdirpath string) (*WAL, error) {
+ // rename of directory with locked files doesn't work on
+ // windows; close the WAL to release the locks so the directory
+ // can be renamed
+ w.Close()
+ if err := os.Rename(tmpdirpath, w.dir); err != nil {
+ return nil, err
+ }
+ // reopen and relock
+ newWAL, oerr := Open(w.dir, walpb.Snapshot{})
+ if oerr != nil {
+ return nil, oerr
+ }
+ if _, _, _, err := newWAL.ReadAll(); err != nil {
+ newWAL.Close()
+ return nil, err
+ }
+ return newWAL, nil
+}
diff --git a/vendor/github.com/coreos/etcd/wal/walpb/record.go b/vendor/github.com/coreos/etcd/wal/walpb/record.go
new file mode 100644
index 00000000..30a05e0c
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/walpb/record.go
@@ -0,0 +1,29 @@
+// Copyright 2015 The etcd Authors
+//
+// Licensed 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 walpb
+
+import "errors"
+
+var (
+ ErrCRCMismatch = errors.New("walpb: crc mismatch")
+)
+
+func (rec *Record) Validate(crc uint32) error {
+ if rec.Crc == crc {
+ return nil
+ }
+ rec.Reset()
+ return ErrCRCMismatch
+}
diff --git a/vendor/github.com/coreos/etcd/wal/walpb/record.pb.go b/vendor/github.com/coreos/etcd/wal/walpb/record.pb.go
new file mode 100644
index 00000000..664fae13
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/walpb/record.pb.go
@@ -0,0 +1,521 @@
+// Code generated by protoc-gen-gogo.
+// source: record.proto
+// DO NOT EDIT!
+
+/*
+ Package walpb is a generated protocol buffer package.
+
+ It is generated from these files:
+ record.proto
+
+ It has these top-level messages:
+ Record
+ Snapshot
+*/
+package walpb
+
+import (
+ "fmt"
+
+ proto "github.com/golang/protobuf/proto"
+
+ math "math"
+
+ io "io"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+type Record struct {
+ Type int64 `protobuf:"varint,1,opt,name=type" json:"type"`
+ Crc uint32 `protobuf:"varint,2,opt,name=crc" json:"crc"`
+ Data []byte `protobuf:"bytes,3,opt,name=data" json:"data,omitempty"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *Record) Reset() { *m = Record{} }
+func (m *Record) String() string { return proto.CompactTextString(m) }
+func (*Record) ProtoMessage() {}
+func (*Record) Descriptor() ([]byte, []int) { return fileDescriptorRecord, []int{0} }
+
+type Snapshot struct {
+ Index uint64 `protobuf:"varint,1,opt,name=index" json:"index"`
+ Term uint64 `protobuf:"varint,2,opt,name=term" json:"term"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *Snapshot) Reset() { *m = Snapshot{} }
+func (m *Snapshot) String() string { return proto.CompactTextString(m) }
+func (*Snapshot) ProtoMessage() {}
+func (*Snapshot) Descriptor() ([]byte, []int) { return fileDescriptorRecord, []int{1} }
+
+func init() {
+ proto.RegisterType((*Record)(nil), "walpb.Record")
+ proto.RegisterType((*Snapshot)(nil), "walpb.Snapshot")
+}
+func (m *Record) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *Record) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRecord(dAtA, i, uint64(m.Type))
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRecord(dAtA, i, uint64(m.Crc))
+ if m.Data != nil {
+ dAtA[i] = 0x1a
+ i++
+ i = encodeVarintRecord(dAtA, i, uint64(len(m.Data)))
+ i += copy(dAtA[i:], m.Data)
+ }
+ if m.XXX_unrecognized != nil {
+ i += copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return i, nil
+}
+
+func (m *Snapshot) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalTo(dAtA)
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *Snapshot) MarshalTo(dAtA []byte) (int, error) {
+ var i int
+ _ = i
+ var l int
+ _ = l
+ dAtA[i] = 0x8
+ i++
+ i = encodeVarintRecord(dAtA, i, uint64(m.Index))
+ dAtA[i] = 0x10
+ i++
+ i = encodeVarintRecord(dAtA, i, uint64(m.Term))
+ if m.XXX_unrecognized != nil {
+ i += copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return i, nil
+}
+
+func encodeFixed64Record(dAtA []byte, offset int, v uint64) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ dAtA[offset+4] = uint8(v >> 32)
+ dAtA[offset+5] = uint8(v >> 40)
+ dAtA[offset+6] = uint8(v >> 48)
+ dAtA[offset+7] = uint8(v >> 56)
+ return offset + 8
+}
+func encodeFixed32Record(dAtA []byte, offset int, v uint32) int {
+ dAtA[offset] = uint8(v)
+ dAtA[offset+1] = uint8(v >> 8)
+ dAtA[offset+2] = uint8(v >> 16)
+ dAtA[offset+3] = uint8(v >> 24)
+ return offset + 4
+}
+func encodeVarintRecord(dAtA []byte, offset int, v uint64) int {
+ for v >= 1<<7 {
+ dAtA[offset] = uint8(v&0x7f | 0x80)
+ v >>= 7
+ offset++
+ }
+ dAtA[offset] = uint8(v)
+ return offset + 1
+}
+func (m *Record) Size() (n int) {
+ var l int
+ _ = l
+ n += 1 + sovRecord(uint64(m.Type))
+ n += 1 + sovRecord(uint64(m.Crc))
+ if m.Data != nil {
+ l = len(m.Data)
+ n += 1 + l + sovRecord(uint64(l))
+ }
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *Snapshot) Size() (n int) {
+ var l int
+ _ = l
+ n += 1 + sovRecord(uint64(m.Index))
+ n += 1 + sovRecord(uint64(m.Term))
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func sovRecord(x uint64) (n int) {
+ for {
+ n++
+ x >>= 7
+ if x == 0 {
+ break
+ }
+ }
+ return n
+}
+func sozRecord(x uint64) (n int) {
+ return sovRecord(uint64((x << 1) ^ uint64((int64(x) >> 63))))
+}
+func (m *Record) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRecord
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: Record: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: Record: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
+ }
+ m.Type = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRecord
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Type |= (int64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Crc", wireType)
+ }
+ m.Crc = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRecord
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Crc |= (uint32(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRecord
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthRecord
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
+ if m.Data == nil {
+ m.Data = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRecord(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRecord
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *Snapshot) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRecord
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: Snapshot: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: Snapshot: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
+ }
+ m.Index = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRecord
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Index |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
+ }
+ m.Term = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowRecord
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Term |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipRecord(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthRecord
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func skipRecord(dAtA []byte) (n int, err error) {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRecord
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ wireType := int(wire & 0x7)
+ switch wireType {
+ case 0:
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRecord
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ iNdEx++
+ if dAtA[iNdEx-1] < 0x80 {
+ break
+ }
+ }
+ return iNdEx, nil
+ case 1:
+ iNdEx += 8
+ return iNdEx, nil
+ case 2:
+ var length int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRecord
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ length |= (int(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ iNdEx += length
+ if length < 0 {
+ return 0, ErrInvalidLengthRecord
+ }
+ return iNdEx, nil
+ case 3:
+ for {
+ var innerWire uint64
+ var start int = iNdEx
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return 0, ErrIntOverflowRecord
+ }
+ if iNdEx >= l {
+ return 0, io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ innerWire |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ innerWireType := int(innerWire & 0x7)
+ if innerWireType == 4 {
+ break
+ }
+ next, err := skipRecord(dAtA[start:])
+ if err != nil {
+ return 0, err
+ }
+ iNdEx = start + next
+ }
+ return iNdEx, nil
+ case 4:
+ return iNdEx, nil
+ case 5:
+ iNdEx += 4
+ return iNdEx, nil
+ default:
+ return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
+ }
+ }
+ panic("unreachable")
+}
+
+var (
+ ErrInvalidLengthRecord = fmt.Errorf("proto: negative length found during unmarshaling")
+ ErrIntOverflowRecord = fmt.Errorf("proto: integer overflow")
+)
+
+func init() { proto.RegisterFile("record.proto", fileDescriptorRecord) }
+
+var fileDescriptorRecord = []byte{
+ // 186 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x29, 0x4a, 0x4d, 0xce,
+ 0x2f, 0x4a, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2d, 0x4f, 0xcc, 0x29, 0x48, 0x92,
+ 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x8b, 0xe8, 0x83, 0x58, 0x10, 0x49, 0x25, 0x3f, 0x2e, 0xb6,
+ 0x20, 0xb0, 0x62, 0x21, 0x09, 0x2e, 0x96, 0x92, 0xca, 0x82, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d,
+ 0x66, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xc0, 0x22, 0x42, 0x62, 0x5c, 0xcc, 0xc9, 0x45,
+ 0xc9, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xbc, 0x50, 0x09, 0x90, 0x80, 0x90, 0x10, 0x17, 0x4b, 0x4a,
+ 0x62, 0x49, 0xa2, 0x04, 0xb3, 0x02, 0xa3, 0x06, 0x4f, 0x10, 0x98, 0xad, 0xe4, 0xc0, 0xc5, 0x11,
+ 0x9c, 0x97, 0x58, 0x50, 0x9c, 0x91, 0x5f, 0x22, 0x24, 0xc5, 0xc5, 0x9a, 0x99, 0x97, 0x92, 0x5a,
+ 0x01, 0x36, 0x92, 0x05, 0xaa, 0x13, 0x22, 0x04, 0xb6, 0x2d, 0xb5, 0x28, 0x17, 0x6c, 0x28, 0x0b,
+ 0xdc, 0xb6, 0xd4, 0xa2, 0x5c, 0x27, 0x91, 0x13, 0x0f, 0xe5, 0x18, 0x4e, 0x3c, 0x92, 0x63, 0xbc,
+ 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x19, 0x8f, 0xe5, 0x18, 0x00, 0x01, 0x00, 0x00,
+ 0xff, 0xff, 0x7f, 0x5e, 0x5c, 0x46, 0xd3, 0x00, 0x00, 0x00,
+}
diff --git a/vendor/github.com/coreos/etcd/wal/walpb/record.proto b/vendor/github.com/coreos/etcd/wal/walpb/record.proto
new file mode 100644
index 00000000..b694cb23
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/wal/walpb/record.proto
@@ -0,0 +1,20 @@
+syntax = "proto2";
+package walpb;
+
+import "gogoproto/gogo.proto";
+
+option (gogoproto.marshaler_all) = true;
+option (gogoproto.sizer_all) = true;
+option (gogoproto.unmarshaler_all) = true;
+option (gogoproto.goproto_getters_all) = false;
+
+message Record {
+ optional int64 type = 1 [(gogoproto.nullable) = false];
+ optional uint32 crc = 2 [(gogoproto.nullable) = false];
+ optional bytes data = 3;
+}
+
+message Snapshot {
+ optional uint64 index = 1 [(gogoproto.nullable) = false];
+ optional uint64 term = 2 [(gogoproto.nullable) = false];
+}
diff --git a/vendor/github.com/coreos/go-semver/.travis.yml b/vendor/github.com/coreos/go-semver/.travis.yml
new file mode 100644
index 00000000..05f548c9
--- /dev/null
+++ b/vendor/github.com/coreos/go-semver/.travis.yml
@@ -0,0 +1,8 @@
+language: go
+sudo: false
+go:
+ - 1.4
+ - 1.5
+ - 1.6
+ - tip
+script: cd semver && go test
diff --git a/vendor/github.com/coreos/go-semver/LICENSE b/vendor/github.com/coreos/go-semver/LICENSE
new file mode 100644
index 00000000..d6456956
--- /dev/null
+++ b/vendor/github.com/coreos/go-semver/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
diff --git a/vendor/github.com/coreos/go-semver/README.md b/vendor/github.com/coreos/go-semver/README.md
new file mode 100644
index 00000000..5bc9263c
--- /dev/null
+++ b/vendor/github.com/coreos/go-semver/README.md
@@ -0,0 +1,28 @@
+# go-semver - Semantic Versioning Library
+
+[![Build Status](https://travis-ci.org/coreos/go-semver.svg?branch=master)](https://travis-ci.org/coreos/go-semver)
+[![GoDoc](https://godoc.org/github.com/coreos/go-semver/semver?status.svg)](https://godoc.org/github.com/coreos/go-semver/semver)
+
+go-semver is a [semantic versioning][semver] library for Go. It lets you parse
+and compare two semantic version strings.
+
+[semver]: http://semver.org/
+
+## Usage
+
+```go
+vA := semver.New("1.2.3")
+vB := semver.New("3.2.1")
+
+fmt.Printf("%s < %s == %t\n", vA, vB, vA.LessThan(*vB))
+```
+
+## Example Application
+
+```
+$ go run example.go 1.2.3 3.2.1
+1.2.3 < 3.2.1 == true
+
+$ go run example.go 5.2.3 3.2.1
+5.2.3 < 3.2.1 == false
+```
diff --git a/vendor/github.com/coreos/go-semver/example.go b/vendor/github.com/coreos/go-semver/example.go
new file mode 100644
index 00000000..fd2ee5af
--- /dev/null
+++ b/vendor/github.com/coreos/go-semver/example.go
@@ -0,0 +1,20 @@
+package main
+
+import (
+ "fmt"
+ "github.com/coreos/go-semver/semver"
+ "os"
+)
+
+func main() {
+ vA, err := semver.NewVersion(os.Args[1])
+ if err != nil {
+ fmt.Println(err.Error())
+ }
+ vB, err := semver.NewVersion(os.Args[2])
+ if err != nil {
+ fmt.Println(err.Error())
+ }
+
+ fmt.Printf("%s < %s == %t\n", vA, vB, vA.LessThan(*vB))
+}
diff --git a/vendor/github.com/coreos/go-semver/semver/semver.go b/vendor/github.com/coreos/go-semver/semver/semver.go
new file mode 100644
index 00000000..110fc23e
--- /dev/null
+++ b/vendor/github.com/coreos/go-semver/semver/semver.go
@@ -0,0 +1,268 @@
+// Copyright 2013-2015 CoreOS, Inc.
+//
+// Licensed 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.
+
+// Semantic Versions http://semver.org
+package semver
+
+import (
+ "bytes"
+ "errors"
+ "fmt"
+ "strconv"
+ "strings"
+)
+
+type Version struct {
+ Major int64
+ Minor int64
+ Patch int64
+ PreRelease PreRelease
+ Metadata string
+}
+
+type PreRelease string
+
+func splitOff(input *string, delim string) (val string) {
+ parts := strings.SplitN(*input, delim, 2)
+
+ if len(parts) == 2 {
+ *input = parts[0]
+ val = parts[1]
+ }
+
+ return val
+}
+
+func New(version string) *Version {
+ return Must(NewVersion(version))
+}
+
+func NewVersion(version string) (*Version, error) {
+ v := Version{}
+
+ if err := v.Set(version); err != nil {
+ return nil, err
+ }
+
+ return &v, nil
+}
+
+// Must is a helper for wrapping NewVersion and will panic if err is not nil.
+func Must(v *Version, err error) *Version {
+ if err != nil {
+ panic(err)
+ }
+ return v
+}
+
+// Set parses and updates v from the given version string. Implements flag.Value
+func (v *Version) Set(version string) error {
+ metadata := splitOff(&version, "+")
+ preRelease := PreRelease(splitOff(&version, "-"))
+ dotParts := strings.SplitN(version, ".", 3)
+
+ if len(dotParts) != 3 {
+ return fmt.Errorf("%s is not in dotted-tri format", version)
+ }
+
+ parsed := make([]int64, 3, 3)
+
+ for i, v := range dotParts[:3] {
+ val, err := strconv.ParseInt(v, 10, 64)
+ parsed[i] = val
+ if err != nil {
+ return err
+ }
+ }
+
+ v.Metadata = metadata
+ v.PreRelease = preRelease
+ v.Major = parsed[0]
+ v.Minor = parsed[1]
+ v.Patch = parsed[2]
+ return nil
+}
+
+func (v Version) String() string {
+ var buffer bytes.Buffer
+
+ fmt.Fprintf(&buffer, "%d.%d.%d", v.Major, v.Minor, v.Patch)
+
+ if v.PreRelease != "" {
+ fmt.Fprintf(&buffer, "-%s", v.PreRelease)
+ }
+
+ if v.Metadata != "" {
+ fmt.Fprintf(&buffer, "+%s", v.Metadata)
+ }
+
+ return buffer.String()
+}
+
+func (v *Version) UnmarshalYAML(unmarshal func(interface{}) error) error {
+ var data string
+ if err := unmarshal(&data); err != nil {
+ return err
+ }
+ return v.Set(data)
+}
+
+func (v Version) MarshalJSON() ([]byte, error) {
+ return []byte(`"` + v.String() + `"`), nil
+}
+
+func (v *Version) UnmarshalJSON(data []byte) error {
+ l := len(data)
+ if l == 0 || string(data) == `""` {
+ return nil
+ }
+ if l < 2 || data[0] != '"' || data[l-1] != '"' {
+ return errors.New("invalid semver string")
+ }
+ return v.Set(string(data[1 : l-1]))
+}
+
+// Compare tests if v is less than, equal to, or greater than versionB,
+// returning -1, 0, or +1 respectively.
+func (v Version) Compare(versionB Version) int {
+ if cmp := recursiveCompare(v.Slice(), versionB.Slice()); cmp != 0 {
+ return cmp
+ }
+ return preReleaseCompare(v, versionB)
+}
+
+// Equal tests if v is equal to versionB.
+func (v Version) Equal(versionB Version) bool {
+ return v.Compare(versionB) == 0
+}
+
+// LessThan tests if v is less than versionB.
+func (v Version) LessThan(versionB Version) bool {
+ return v.Compare(versionB) < 0
+}
+
+// Slice converts the comparable parts of the semver into a slice of integers.
+func (v Version) Slice() []int64 {
+ return []int64{v.Major, v.Minor, v.Patch}
+}
+
+func (p PreRelease) Slice() []string {
+ preRelease := string(p)
+ return strings.Split(preRelease, ".")
+}
+
+func preReleaseCompare(versionA Version, versionB Version) int {
+ a := versionA.PreRelease
+ b := versionB.PreRelease
+
+ /* Handle the case where if two versions are otherwise equal it is the
+ * one without a PreRelease that is greater */
+ if len(a) == 0 && (len(b) > 0) {
+ return 1
+ } else if len(b) == 0 && (len(a) > 0) {
+ return -1
+ }
+
+ // If there is a prerelease, check and compare each part.
+ return recursivePreReleaseCompare(a.Slice(), b.Slice())
+}
+
+func recursiveCompare(versionA []int64, versionB []int64) int {
+ if len(versionA) == 0 {
+ return 0
+ }
+
+ a := versionA[0]
+ b := versionB[0]
+
+ if a > b {
+ return 1
+ } else if a < b {
+ return -1
+ }
+
+ return recursiveCompare(versionA[1:], versionB[1:])
+}
+
+func recursivePreReleaseCompare(versionA []string, versionB []string) int {
+ // A larger set of pre-release fields has a higher precedence than a smaller set,
+ // if all of the preceding identifiers are equal.
+ if len(versionA) == 0 {
+ if len(versionB) > 0 {
+ return -1
+ }
+ return 0
+ } else if len(versionB) == 0 {
+ // We're longer than versionB so return 1.
+ return 1
+ }
+
+ a := versionA[0]
+ b := versionB[0]
+
+ aInt := false
+ bInt := false
+
+ aI, err := strconv.Atoi(versionA[0])
+ if err == nil {
+ aInt = true
+ }
+
+ bI, err := strconv.Atoi(versionB[0])
+ if err == nil {
+ bInt = true
+ }
+
+ // Handle Integer Comparison
+ if aInt && bInt {
+ if aI > bI {
+ return 1
+ } else if aI < bI {
+ return -1
+ }
+ }
+
+ // Handle String Comparison
+ if a > b {
+ return 1
+ } else if a < b {
+ return -1
+ }
+
+ return recursivePreReleaseCompare(versionA[1:], versionB[1:])
+}
+
+// BumpMajor increments the Major field by 1 and resets all other fields to their default values
+func (v *Version) BumpMajor() {
+ v.Major += 1
+ v.Minor = 0
+ v.Patch = 0
+ v.PreRelease = PreRelease("")
+ v.Metadata = ""
+}
+
+// BumpMinor increments the Minor field by 1 and resets all other fields to their default values
+func (v *Version) BumpMinor() {
+ v.Minor += 1
+ v.Patch = 0
+ v.PreRelease = PreRelease("")
+ v.Metadata = ""
+}
+
+// BumpPatch increments the Patch field by 1 and resets all other fields to their default values
+func (v *Version) BumpPatch() {
+ v.Patch += 1
+ v.PreRelease = PreRelease("")
+ v.Metadata = ""
+}
diff --git a/vendor/github.com/coreos/go-semver/semver/semver_test.go b/vendor/github.com/coreos/go-semver/semver/semver_test.go
new file mode 100644
index 00000000..876c68e0
--- /dev/null
+++ b/vendor/github.com/coreos/go-semver/semver/semver_test.go
@@ -0,0 +1,370 @@
+// Copyright 2013-2015 CoreOS, Inc.
+//
+// Licensed 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 semver
+
+import (
+ "bytes"
+ "encoding/json"
+ "errors"
+ "flag"
+ "fmt"
+ "math/rand"
+ "reflect"
+ "testing"
+ "time"
+
+ "gopkg.in/yaml.v2"
+)
+
+type fixture struct {
+ GreaterVersion string
+ LesserVersion string
+}
+
+var fixtures = []fixture{
+ fixture{"0.0.0", "0.0.0-foo"},
+ fixture{"0.0.1", "0.0.0"},
+ fixture{"1.0.0", "0.9.9"},
+ fixture{"0.10.0", "0.9.0"},
+ fixture{"0.99.0", "0.10.0"},
+ fixture{"2.0.0", "1.2.3"},
+ fixture{"0.0.0", "0.0.0-foo"},
+ fixture{"0.0.1", "0.0.0"},
+ fixture{"1.0.0", "0.9.9"},
+ fixture{"0.10.0", "0.9.0"},
+ fixture{"0.99.0", "0.10.0"},
+ fixture{"2.0.0", "1.2.3"},
+ fixture{"0.0.0", "0.0.0-foo"},
+ fixture{"0.0.1", "0.0.0"},
+ fixture{"1.0.0", "0.9.9"},
+ fixture{"0.10.0", "0.9.0"},
+ fixture{"0.99.0", "0.10.0"},
+ fixture{"2.0.0", "1.2.3"},
+ fixture{"1.2.3", "1.2.3-asdf"},
+ fixture{"1.2.3", "1.2.3-4"},
+ fixture{"1.2.3", "1.2.3-4-foo"},
+ fixture{"1.2.3-5-foo", "1.2.3-5"},
+ fixture{"1.2.3-5", "1.2.3-4"},
+ fixture{"1.2.3-5-foo", "1.2.3-5-Foo"},
+ fixture{"3.0.0", "2.7.2+asdf"},
+ fixture{"3.0.0+foobar", "2.7.2"},
+ fixture{"1.2.3-a.10", "1.2.3-a.5"},
+ fixture{"1.2.3-a.b", "1.2.3-a.5"},
+ fixture{"1.2.3-a.b", "1.2.3-a"},
+ fixture{"1.2.3-a.b.c.10.d.5", "1.2.3-a.b.c.5.d.100"},
+ fixture{"1.0.0", "1.0.0-rc.1"},
+ fixture{"1.0.0-rc.2", "1.0.0-rc.1"},
+ fixture{"1.0.0-rc.1", "1.0.0-beta.11"},
+ fixture{"1.0.0-beta.11", "1.0.0-beta.2"},
+ fixture{"1.0.0-beta.2", "1.0.0-beta"},
+ fixture{"1.0.0-beta", "1.0.0-alpha.beta"},
+ fixture{"1.0.0-alpha.beta", "1.0.0-alpha.1"},
+ fixture{"1.0.0-alpha.1", "1.0.0-alpha"},
+}
+
+func TestCompare(t *testing.T) {
+ for _, v := range fixtures {
+ gt, err := NewVersion(v.GreaterVersion)
+ if err != nil {
+ t.Error(err)
+ }
+
+ lt, err := NewVersion(v.LesserVersion)
+ if err != nil {
+ t.Error(err)
+ }
+
+ if gt.LessThan(*lt) {
+ t.Errorf("%s should not be less than %s", gt, lt)
+ }
+ if gt.Equal(*lt) {
+ t.Errorf("%s should not be equal to %s", gt, lt)
+ }
+ if gt.Compare(*lt) <= 0 {
+ t.Errorf("%s should be greater than %s", gt, lt)
+ }
+ if !lt.LessThan(*gt) {
+ t.Errorf("%s should be less than %s", lt, gt)
+ }
+ if !lt.Equal(*lt) {
+ t.Errorf("%s should be equal to %s", lt, lt)
+ }
+ if lt.Compare(*gt) > 0 {
+ t.Errorf("%s should not be greater than %s", lt, gt)
+ }
+ }
+}
+
+func testString(t *testing.T, orig string, version *Version) {
+ if orig != version.String() {
+ t.Errorf("%s != %s", orig, version)
+ }
+}
+
+func TestString(t *testing.T) {
+ for _, v := range fixtures {
+ gt, err := NewVersion(v.GreaterVersion)
+ if err != nil {
+ t.Error(err)
+ }
+ testString(t, v.GreaterVersion, gt)
+
+ lt, err := NewVersion(v.LesserVersion)
+ if err != nil {
+ t.Error(err)
+ }
+ testString(t, v.LesserVersion, lt)
+ }
+}
+
+func shuffleStringSlice(src []string) []string {
+ dest := make([]string, len(src))
+ rand.Seed(time.Now().Unix())
+ perm := rand.Perm(len(src))
+ for i, v := range perm {
+ dest[v] = src[i]
+ }
+ return dest
+}
+
+func TestSort(t *testing.T) {
+ sortedVersions := []string{"1.0.0", "1.0.2", "1.2.0", "3.1.1"}
+ unsortedVersions := shuffleStringSlice(sortedVersions)
+
+ semvers := []*Version{}
+ for _, v := range unsortedVersions {
+ sv, err := NewVersion(v)
+ if err != nil {
+ t.Fatal(err)
+ }
+ semvers = append(semvers, sv)
+ }
+
+ Sort(semvers)
+
+ for idx, sv := range semvers {
+ if sv.String() != sortedVersions[idx] {
+ t.Fatalf("incorrect sort at index %v", idx)
+ }
+ }
+}
+
+func TestBumpMajor(t *testing.T) {
+ version, _ := NewVersion("1.0.0")
+ version.BumpMajor()
+ if version.Major != 2 {
+ t.Fatalf("bumping major on 1.0.0 resulted in %v", version)
+ }
+
+ version, _ = NewVersion("1.5.2")
+ version.BumpMajor()
+ if version.Minor != 0 && version.Patch != 0 {
+ t.Fatalf("bumping major on 1.5.2 resulted in %v", version)
+ }
+
+ version, _ = NewVersion("1.0.0+build.1-alpha.1")
+ version.BumpMajor()
+ if version.PreRelease != "" && version.PreRelease != "" {
+ t.Fatalf("bumping major on 1.0.0+build.1-alpha.1 resulted in %v", version)
+ }
+}
+
+func TestBumpMinor(t *testing.T) {
+ version, _ := NewVersion("1.0.0")
+ version.BumpMinor()
+
+ if version.Major != 1 {
+ t.Fatalf("bumping minor on 1.0.0 resulted in %v", version)
+ }
+
+ if version.Minor != 1 {
+ t.Fatalf("bumping major on 1.0.0 resulted in %v", version)
+ }
+
+ version, _ = NewVersion("1.0.0+build.1-alpha.1")
+ version.BumpMinor()
+ if version.PreRelease != "" && version.PreRelease != "" {
+ t.Fatalf("bumping major on 1.0.0+build.1-alpha.1 resulted in %v", version)
+ }
+}
+
+func TestBumpPatch(t *testing.T) {
+ version, _ := NewVersion("1.0.0")
+ version.BumpPatch()
+
+ if version.Major != 1 {
+ t.Fatalf("bumping minor on 1.0.0 resulted in %v", version)
+ }
+
+ if version.Minor != 0 {
+ t.Fatalf("bumping major on 1.0.0 resulted in %v", version)
+ }
+
+ if version.Patch != 1 {
+ t.Fatalf("bumping major on 1.0.0 resulted in %v", version)
+ }
+
+ version, _ = NewVersion("1.0.0+build.1-alpha.1")
+ version.BumpPatch()
+ if version.PreRelease != "" && version.PreRelease != "" {
+ t.Fatalf("bumping major on 1.0.0+build.1-alpha.1 resulted in %v", version)
+ }
+}
+
+func TestMust(t *testing.T) {
+ tests := []struct {
+ versionStr string
+
+ version *Version
+ recov interface{}
+ }{
+ {
+ versionStr: "1.0.0",
+ version: &Version{Major: 1},
+ },
+ {
+ versionStr: "version number",
+ recov: errors.New("version number is not in dotted-tri format"),
+ },
+ }
+
+ for _, tt := range tests {
+ func() {
+ defer func() {
+ recov := recover()
+ if !reflect.DeepEqual(tt.recov, recov) {
+ t.Fatalf("incorrect panic for %q: want %v, got %v", tt.versionStr, tt.recov, recov)
+ }
+ }()
+
+ version := Must(NewVersion(tt.versionStr))
+ if !reflect.DeepEqual(tt.version, version) {
+ t.Fatalf("incorrect version for %q: want %+v, got %+v", tt.versionStr, tt.version, version)
+ }
+ }()
+ }
+}
+
+type fixtureJSON struct {
+ GreaterVersion *Version
+ LesserVersion *Version
+}
+
+func TestJSON(t *testing.T) {
+ fj := make([]fixtureJSON, len(fixtures))
+ for i, v := range fixtures {
+ var err error
+ fj[i].GreaterVersion, err = NewVersion(v.GreaterVersion)
+ if err != nil {
+ t.Fatal(err)
+ }
+ fj[i].LesserVersion, err = NewVersion(v.LesserVersion)
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ fromStrings, err := json.Marshal(fixtures)
+ if err != nil {
+ t.Fatal(err)
+ }
+ fromVersions, err := json.Marshal(fj)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(fromStrings, fromVersions) {
+ t.Errorf("Expected: %s", fromStrings)
+ t.Errorf("Unexpected: %s", fromVersions)
+ }
+
+ fromJson := make([]fixtureJSON, 0, len(fj))
+ err = json.Unmarshal(fromStrings, &fromJson)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !reflect.DeepEqual(fromJson, fj) {
+ t.Error("Expected: ", fj)
+ t.Error("Unexpected: ", fromJson)
+ }
+}
+
+func TestYAML(t *testing.T) {
+ document, err := yaml.Marshal(fixtures)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ expected := make([]fixtureJSON, len(fixtures))
+ for i, v := range fixtures {
+ var err error
+ expected[i].GreaterVersion, err = NewVersion(v.GreaterVersion)
+ if err != nil {
+ t.Fatal(err)
+ }
+ expected[i].LesserVersion, err = NewVersion(v.LesserVersion)
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ fromYAML := make([]fixtureJSON, 0, len(fixtures))
+ err = yaml.Unmarshal(document, &fromYAML)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if !reflect.DeepEqual(fromYAML, expected) {
+ t.Error("Expected: ", expected)
+ t.Error("Unexpected: ", fromYAML)
+ }
+}
+
+func TestBadInput(t *testing.T) {
+ bad := []string{
+ "1.2",
+ "1.2.3x",
+ "0x1.3.4",
+ "-1.2.3",
+ "1.2.3.4",
+ }
+ for _, b := range bad {
+ if _, err := NewVersion(b); err == nil {
+ t.Error("Improperly accepted value: ", b)
+ }
+ }
+}
+
+func TestFlag(t *testing.T) {
+ v := Version{}
+ f := flag.NewFlagSet("version", flag.ContinueOnError)
+ f.Var(&v, "version", "set version")
+
+ if err := f.Set("version", "1.2.3"); err != nil {
+ t.Fatal(err)
+ }
+
+ if v.String() != "1.2.3" {
+ t.Errorf("Set wrong value %q", v)
+ }
+}
+
+func ExampleVersion_LessThan() {
+ vA := New("1.2.3")
+ vB := New("3.2.1")
+
+ fmt.Printf("%s < %s == %t\n", vA, vB, vA.LessThan(*vB))
+ // Output:
+ // 1.2.3 < 3.2.1 == true
+}
diff --git a/vendor/github.com/coreos/go-semver/semver/sort.go b/vendor/github.com/coreos/go-semver/semver/sort.go
new file mode 100644
index 00000000..e256b41a
--- /dev/null
+++ b/vendor/github.com/coreos/go-semver/semver/sort.go
@@ -0,0 +1,38 @@
+// Copyright 2013-2015 CoreOS, Inc.
+//
+// Licensed 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 semver
+
+import (
+ "sort"
+)
+
+type Versions []*Version
+
+func (s Versions) Len() int {
+ return len(s)
+}
+
+func (s Versions) Swap(i, j int) {
+ s[i], s[j] = s[j], s[i]
+}
+
+func (s Versions) Less(i, j int) bool {
+ return s[i].LessThan(*s[j])
+}
+
+// Sort sorts the given slice of Version
+func Sort(versions []*Version) {
+ sort.Sort(Versions(versions))
+}
diff --git a/newt/vendor/github.com/spf13/jwalterweatherman/.gitignore b/vendor/github.com/davecgh/go-spew/.gitignore
similarity index 100%
rename from newt/vendor/github.com/spf13/jwalterweatherman/.gitignore
rename to vendor/github.com/davecgh/go-spew/.gitignore
diff --git a/vendor/github.com/davecgh/go-spew/.travis.yml b/vendor/github.com/davecgh/go-spew/.travis.yml
new file mode 100644
index 00000000..984e0736
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/.travis.yml
@@ -0,0 +1,14 @@
+language: go
+go:
+ - 1.5.4
+ - 1.6.3
+ - 1.7
+install:
+ - go get -v golang.org/x/tools/cmd/cover
+script:
+ - go test -v -tags=safe ./spew
+ - go test -v -tags=testcgo ./spew -covermode=count -coverprofile=profile.cov
+after_success:
+ - go get -v github.com/mattn/goveralls
+ - export PATH=$PATH:$HOME/gopath/bin
+ - goveralls -coverprofile=profile.cov -service=travis-ci
diff --git a/vendor/github.com/davecgh/go-spew/LICENSE b/vendor/github.com/davecgh/go-spew/LICENSE
new file mode 100644
index 00000000..c8364161
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/LICENSE
@@ -0,0 +1,15 @@
+ISC License
+
+Copyright (c) 2012-2016 Dave Collins <da...@davec.name>
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/vendor/github.com/davecgh/go-spew/README.md b/vendor/github.com/davecgh/go-spew/README.md
new file mode 100644
index 00000000..26243044
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/README.md
@@ -0,0 +1,205 @@
+go-spew
+=======
+
+[![Build Status](https://img.shields.io/travis/davecgh/go-spew.svg)]
+(https://travis-ci.org/davecgh/go-spew) [![ISC License]
+(http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) [![Coverage Status]
+(https://img.shields.io/coveralls/davecgh/go-spew.svg)]
+(https://coveralls.io/r/davecgh/go-spew?branch=master)
+
+
+Go-spew implements a deep pretty printer for Go data structures to aid in
+debugging. A comprehensive suite of tests with 100% test coverage is provided
+to ensure proper functionality. See `test_coverage.txt` for the gocov coverage
+report. Go-spew is licensed under the liberal ISC license, so it may be used in
+open source or commercial projects.
+
+If you're interested in reading about how this package came to life and some
+of the challenges involved in providing a deep pretty printer, there is a blog
+post about it
+[here](https://web.archive.org/web/20160304013555/https://blog.cyphertite.com/go-spew-a-journey-into-dumping-go-data-structures/).
+
+## Documentation
+
+[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)]
+(http://godoc.org/github.com/davecgh/go-spew/spew)
+
+Full `go doc` style documentation for the project can be viewed online without
+installing this package by using the excellent GoDoc site here:
+http://godoc.org/github.com/davecgh/go-spew/spew
+
+You can also view the documentation locally once the package is installed with
+the `godoc` tool by running `godoc -http=":6060"` and pointing your browser to
+http://localhost:6060/pkg/github.com/davecgh/go-spew/spew
+
+## Installation
+
+```bash
+$ go get -u github.com/davecgh/go-spew/spew
+```
+
+## Quick Start
+
+Add this import line to the file you're working in:
+
+```Go
+import "github.com/davecgh/go-spew/spew"
+```
+
+To dump a variable with full newlines, indentation, type, and pointer
+information use Dump, Fdump, or Sdump:
+
+```Go
+spew.Dump(myVar1, myVar2, ...)
+spew.Fdump(someWriter, myVar1, myVar2, ...)
+str := spew.Sdump(myVar1, myVar2, ...)
+```
+
+Alternatively, if you would prefer to use format strings with a compacted inline
+printing style, use the convenience wrappers Printf, Fprintf, etc with %v (most
+compact), %+v (adds pointer addresses), %#v (adds types), or %#+v (adds types
+and pointer addresses):
+
+```Go
+spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2)
+spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
+spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2)
+spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
+```
+
+## Debugging a Web Application Example
+
+Here is an example of how you can use `spew.Sdump()` to help debug a web application. Please be sure to wrap your output using the `html.EscapeString()` function for safety reasons. You should also only use this debugging technique in a development environment, never in production.
+
+```Go
+package main
+
+import (
+ "fmt"
+ "html"
+ "net/http"
+
+ "github.com/davecgh/go-spew/spew"
+)
+
+func handler(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "text/html")
+ fmt.Fprintf(w, "Hi there, %s!", r.URL.Path[1:])
+ fmt.Fprintf(w, "<!--\n" + html.EscapeString(spew.Sdump(w)) + "\n-->")
+}
+
+func main() {
+ http.HandleFunc("/", handler)
+ http.ListenAndServe(":8080", nil)
+}
+```
+
+## Sample Dump Output
+
+```
+(main.Foo) {
+ unexportedField: (*main.Bar)(0xf84002e210)({
+ flag: (main.Flag) flagTwo,
+ data: (uintptr) <nil>
+ }),
+ ExportedField: (map[interface {}]interface {}) {
+ (string) "one": (bool) true
+ }
+}
+([]uint8) {
+ 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... |
+ 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0|
+ 00000020 31 32 |12|
+}
+```
+
+## Sample Formatter Output
+
+Double pointer to a uint8:
+```
+ %v: <**>5
+ %+v: <**>(0xf8400420d0->0xf8400420c8)5
+ %#v: (**uint8)5
+ %#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5
+```
+
+Pointer to circular struct with a uint8 field and a pointer to itself:
+```
+ %v: <*>{1 <*><shown>}
+ %+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)<shown>}
+ %#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)<shown>}
+ %#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)<shown>}
+```
+
+## Configuration Options
+
+Configuration of spew is handled by fields in the ConfigState type. For
+convenience, all of the top-level functions use a global state available via the
+spew.Config global.
+
+It is also possible to create a ConfigState instance that provides methods
+equivalent to the top-level functions. This allows concurrent configuration
+options. See the ConfigState documentation for more details.
+
+```
+* Indent
+ String to use for each indentation level for Dump functions.
+ It is a single space by default. A popular alternative is "\t".
+
+* MaxDepth
+ Maximum number of levels to descend into nested data structures.
+ There is no limit by default.
+
+* DisableMethods
+ Disables invocation of error and Stringer interface methods.
+ Method invocation is enabled by default.
+
+* DisablePointerMethods
+ Disables invocation of error and Stringer interface methods on types
+ which only accept pointer receivers from non-pointer variables. This option
+ relies on access to the unsafe package, so it will not have any effect when
+ running in environments without access to the unsafe package such as Google
+ App Engine or with the "safe" build tag specified.
+ Pointer method invocation is enabled by default.
+
+* DisablePointerAddresses
+ DisablePointerAddresses specifies whether to disable the printing of
+ pointer addresses. This is useful when diffing data structures in tests.
+
+* DisableCapacities
+ DisableCapacities specifies whether to disable the printing of capacities
+ for arrays, slices, maps and channels. This is useful when diffing data
+ structures in tests.
+
+* ContinueOnMethod
+ Enables recursion into types after invoking error and Stringer interface
+ methods. Recursion after method invocation is disabled by default.
+
+* SortKeys
+ Specifies map keys should be sorted before being printed. Use
+ this to have a more deterministic, diffable output. Note that
+ only native types (bool, int, uint, floats, uintptr and string)
+ and types which implement error or Stringer interfaces are supported,
+ with other types sorted according to the reflect.Value.String() output
+ which guarantees display stability. Natural map order is used by
+ default.
+
+* SpewKeys
+ SpewKeys specifies that, as a last resort attempt, map keys should be
+ spewed to strings and sorted by those strings. This is only considered
+ if SortKeys is true.
+
+```
+
+## Unsafe Package Dependency
+
+This package relies on the unsafe package to perform some of the more advanced
+features, however it also supports a "limited" mode which allows it to work in
+environments where the unsafe package is not available. By default, it will
+operate in this mode on Google App Engine and when compiled with GopherJS. The
+"safe" build tag may also be specified to force the package to build without
+using the unsafe package.
+
+## License
+
+Go-spew is licensed under the [copyfree](http://copyfree.org) ISC License.
diff --git a/vendor/github.com/davecgh/go-spew/cov_report.sh b/vendor/github.com/davecgh/go-spew/cov_report.sh
new file mode 100644
index 00000000..9579497e
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/cov_report.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# This script uses gocov to generate a test coverage report.
+# The gocov tool my be obtained with the following command:
+# go get github.com/axw/gocov/gocov
+#
+# It will be installed to $GOPATH/bin, so ensure that location is in your $PATH.
+
+# Check for gocov.
+if ! type gocov >/dev/null 2>&1; then
+ echo >&2 "This script requires the gocov tool."
+ echo >&2 "You may obtain it with the following command:"
+ echo >&2 "go get github.com/axw/gocov/gocov"
+ exit 1
+fi
+
+# Only run the cgo tests if gcc is installed.
+if type gcc >/dev/null 2>&1; then
+ (cd spew && gocov test -tags testcgo | gocov report)
+else
+ (cd spew && gocov test | gocov report)
+fi
diff --git a/vendor/github.com/davecgh/go-spew/spew/bypass.go b/vendor/github.com/davecgh/go-spew/spew/bypass.go
new file mode 100644
index 00000000..8a4a6589
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/spew/bypass.go
@@ -0,0 +1,152 @@
+// Copyright (c) 2015-2016 Dave Collins <da...@davec.name>
+//
+// Permission to use, copy, modify, and distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+// NOTE: Due to the following build constraints, this file will only be compiled
+// when the code is not running on Google App Engine, compiled by GopherJS, and
+// "-tags safe" is not added to the go build command line. The "disableunsafe"
+// tag is deprecated and thus should not be used.
+// +build !js,!appengine,!safe,!disableunsafe
+
+package spew
+
+import (
+ "reflect"
+ "unsafe"
+)
+
+const (
+ // UnsafeDisabled is a build-time constant which specifies whether or
+ // not access to the unsafe package is available.
+ UnsafeDisabled = false
+
+ // ptrSize is the size of a pointer on the current arch.
+ ptrSize = unsafe.Sizeof((*byte)(nil))
+)
+
+var (
+ // offsetPtr, offsetScalar, and offsetFlag are the offsets for the
+ // internal reflect.Value fields. These values are valid before golang
+ // commit ecccf07e7f9d which changed the format. The are also valid
+ // after commit 82f48826c6c7 which changed the format again to mirror
+ // the original format. Code in the init function updates these offsets
+ // as necessary.
+ offsetPtr = uintptr(ptrSize)
+ offsetScalar = uintptr(0)
+ offsetFlag = uintptr(ptrSize * 2)
+
+ // flagKindWidth and flagKindShift indicate various bits that the
+ // reflect package uses internally to track kind information.
+ //
+ // flagRO indicates whether or not the value field of a reflect.Value is
+ // read-only.
+ //
+ // flagIndir indicates whether the value field of a reflect.Value is
+ // the actual data or a pointer to the data.
+ //
+ // These values are valid before golang commit 90a7c3c86944 which
+ // changed their positions. Code in the init function updates these
+ // flags as necessary.
+ flagKindWidth = uintptr(5)
+ flagKindShift = uintptr(flagKindWidth - 1)
+ flagRO = uintptr(1 << 0)
+ flagIndir = uintptr(1 << 1)
+)
+
+func init() {
+ // Older versions of reflect.Value stored small integers directly in the
+ // ptr field (which is named val in the older versions). Versions
+ // between commits ecccf07e7f9d and 82f48826c6c7 added a new field named
+ // scalar for this purpose which unfortunately came before the flag
+ // field, so the offset of the flag field is different for those
+ // versions.
+ //
+ // This code constructs a new reflect.Value from a known small integer
+ // and checks if the size of the reflect.Value struct indicates it has
+ // the scalar field. When it does, the offsets are updated accordingly.
+ vv := reflect.ValueOf(0xf00)
+ if unsafe.Sizeof(vv) == (ptrSize * 4) {
+ offsetScalar = ptrSize * 2
+ offsetFlag = ptrSize * 3
+ }
+
+ // Commit 90a7c3c86944 changed the flag positions such that the low
+ // order bits are the kind. This code extracts the kind from the flags
+ // field and ensures it's the correct type. When it's not, the flag
+ // order has been changed to the newer format, so the flags are updated
+ // accordingly.
+ upf := unsafe.Pointer(uintptr(unsafe.Pointer(&vv)) + offsetFlag)
+ upfv := *(*uintptr)(upf)
+ flagKindMask := uintptr((1<<flagKindWidth - 1) << flagKindShift)
+ if (upfv&flagKindMask)>>flagKindShift != uintptr(reflect.Int) {
+ flagKindShift = 0
+ flagRO = 1 << 5
+ flagIndir = 1 << 6
+
+ // Commit adf9b30e5594 modified the flags to separate the
+ // flagRO flag into two bits which specifies whether or not the
+ // field is embedded. This causes flagIndir to move over a bit
+ // and means that flagRO is the combination of either of the
+ // original flagRO bit and the new bit.
+ //
+ // This code detects the change by extracting what used to be
+ // the indirect bit to ensure it's set. When it's not, the flag
+ // order has been changed to the newer format, so the flags are
+ // updated accordingly.
+ if upfv&flagIndir == 0 {
+ flagRO = 3 << 5
+ flagIndir = 1 << 7
+ }
+ }
+}
+
+// unsafeReflectValue converts the passed reflect.Value into a one that bypasses
+// the typical safety restrictions preventing access to unaddressable and
+// unexported data. It works by digging the raw pointer to the underlying
+// value out of the protected value and generating a new unprotected (unsafe)
+// reflect.Value to it.
+//
+// This allows us to check for implementations of the Stringer and error
+// interfaces to be used for pretty printing ordinarily unaddressable and
+// inaccessible values such as unexported struct fields.
+func unsafeReflectValue(v reflect.Value) (rv reflect.Value) {
+ indirects := 1
+ vt := v.Type()
+ upv := unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + offsetPtr)
+ rvf := *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + offsetFlag))
+ if rvf&flagIndir != 0 {
+ vt = reflect.PtrTo(v.Type())
+ indirects++
+ } else if offsetScalar != 0 {
+ // The value is in the scalar field when it's not one of the
+ // reference types.
+ switch vt.Kind() {
+ case reflect.Uintptr:
+ case reflect.Chan:
+ case reflect.Func:
+ case reflect.Map:
+ case reflect.Ptr:
+ case reflect.UnsafePointer:
+ default:
+ upv = unsafe.Pointer(uintptr(unsafe.Pointer(&v)) +
+ offsetScalar)
+ }
+ }
+
+ pv := reflect.NewAt(vt, upv)
+ rv = pv
+ for i := 0; i < indirects; i++ {
+ rv = rv.Elem()
+ }
+ return rv
+}
diff --git a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go
new file mode 100644
index 00000000..1fe3cf3d
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go
@@ -0,0 +1,38 @@
+// Copyright (c) 2015-2016 Dave Collins <da...@davec.name>
+//
+// Permission to use, copy, modify, and distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+// NOTE: Due to the following build constraints, this file will only be compiled
+// when the code is running on Google App Engine, compiled by GopherJS, or
+// "-tags safe" is added to the go build command line. The "disableunsafe"
+// tag is deprecated and thus should not be used.
+// +build js appengine safe disableunsafe
+
+package spew
+
+import "reflect"
+
+const (
+ // UnsafeDisabled is a build-time constant which specifies whether or
+ // not access to the unsafe package is available.
+ UnsafeDisabled = true
+)
+
+// unsafeReflectValue typically converts the passed reflect.Value into a one
+// that bypasses the typical safety restrictions preventing access to
+// unaddressable and unexported data. However, doing this relies on access to
+// the unsafe package. This is a stub version which simply returns the passed
+// reflect.Value when the unsafe package is not available.
+func unsafeReflectValue(v reflect.Value) reflect.Value {
+ return v
+}
diff --git a/vendor/github.com/davecgh/go-spew/spew/common.go b/vendor/github.com/davecgh/go-spew/spew/common.go
new file mode 100644
index 00000000..7c519ff4
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/spew/common.go
@@ -0,0 +1,341 @@
+/*
+ * Copyright (c) 2013-2016 Dave Collins <da...@davec.name>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package spew
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "reflect"
+ "sort"
+ "strconv"
+)
+
+// Some constants in the form of bytes to avoid string overhead. This mirrors
+// the technique used in the fmt package.
+var (
+ panicBytes = []byte("(PANIC=")
+ plusBytes = []byte("+")
+ iBytes = []byte("i")
+ trueBytes = []byte("true")
+ falseBytes = []byte("false")
+ interfaceBytes = []byte("(interface {})")
+ commaNewlineBytes = []byte(",\n")
+ newlineBytes = []byte("\n")
+ openBraceBytes = []byte("{")
+ openBraceNewlineBytes = []byte("{\n")
+ closeBraceBytes = []byte("}")
+ asteriskBytes = []byte("*")
+ colonBytes = []byte(":")
+ colonSpaceBytes = []byte(": ")
+ openParenBytes = []byte("(")
+ closeParenBytes = []byte(")")
+ spaceBytes = []byte(" ")
+ pointerChainBytes = []byte("->")
+ nilAngleBytes = []byte("<nil>")
+ maxNewlineBytes = []byte("<max depth reached>\n")
+ maxShortBytes = []byte("<max>")
+ circularBytes = []byte("<already shown>")
+ circularShortBytes = []byte("<shown>")
+ invalidAngleBytes = []byte("<invalid>")
+ openBracketBytes = []byte("[")
+ closeBracketBytes = []byte("]")
+ percentBytes = []byte("%")
+ precisionBytes = []byte(".")
+ openAngleBytes = []byte("<")
+ closeAngleBytes = []byte(">")
+ openMapBytes = []byte("map[")
+ closeMapBytes = []byte("]")
+ lenEqualsBytes = []byte("len=")
+ capEqualsBytes = []byte("cap=")
+)
+
+// hexDigits is used to map a decimal value to a hex digit.
+var hexDigits = "0123456789abcdef"
+
+// catchPanic handles any panics that might occur during the handleMethods
+// calls.
+func catchPanic(w io.Writer, v reflect.Value) {
+ if err := recover(); err != nil {
+ w.Write(panicBytes)
+ fmt.Fprintf(w, "%v", err)
+ w.Write(closeParenBytes)
+ }
+}
+
+// handleMethods attempts to call the Error and String methods on the underlying
+// type the passed reflect.Value represents and outputes the result to Writer w.
+//
+// It handles panics in any called methods by catching and displaying the error
+// as the formatted value.
+func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool) {
+ // We need an interface to check if the type implements the error or
+ // Stringer interface. However, the reflect package won't give us an
+ // interface on certain things like unexported struct fields in order
+ // to enforce visibility rules. We use unsafe, when it's available,
+ // to bypass these restrictions since this package does not mutate the
+ // values.
+ if !v.CanInterface() {
+ if UnsafeDisabled {
+ return false
+ }
+
+ v = unsafeReflectValue(v)
+ }
+
+ // Choose whether or not to do error and Stringer interface lookups against
+ // the base type or a pointer to the base type depending on settings.
+ // Technically calling one of these methods with a pointer receiver can
+ // mutate the value, however, types which choose to satisify an error or
+ // Stringer interface with a pointer receiver should not be mutating their
+ // state inside these interface methods.
+ if !cs.DisablePointerMethods && !UnsafeDisabled && !v.CanAddr() {
+ v = unsafeReflectValue(v)
+ }
+ if v.CanAddr() {
+ v = v.Addr()
+ }
+
+ // Is it an error or Stringer?
+ switch iface := v.Interface().(type) {
+ case error:
+ defer catchPanic(w, v)
+ if cs.ContinueOnMethod {
+ w.Write(openParenBytes)
+ w.Write([]byte(iface.Error()))
+ w.Write(closeParenBytes)
+ w.Write(spaceBytes)
+ return false
+ }
+
+ w.Write([]byte(iface.Error()))
+ return true
+
+ case fmt.Stringer:
+ defer catchPanic(w, v)
+ if cs.ContinueOnMethod {
+ w.Write(openParenBytes)
+ w.Write([]byte(iface.String()))
+ w.Write(closeParenBytes)
+ w.Write(spaceBytes)
+ return false
+ }
+ w.Write([]byte(iface.String()))
+ return true
+ }
+ return false
+}
+
+// printBool outputs a boolean value as true or false to Writer w.
+func printBool(w io.Writer, val bool) {
+ if val {
+ w.Write(trueBytes)
+ } else {
+ w.Write(falseBytes)
+ }
+}
+
+// printInt outputs a signed integer value to Writer w.
+func printInt(w io.Writer, val int64, base int) {
+ w.Write([]byte(strconv.FormatInt(val, base)))
+}
+
+// printUint outputs an unsigned integer value to Writer w.
+func printUint(w io.Writer, val uint64, base int) {
+ w.Write([]byte(strconv.FormatUint(val, base)))
+}
+
+// printFloat outputs a floating point value using the specified precision,
+// which is expected to be 32 or 64bit, to Writer w.
+func printFloat(w io.Writer, val float64, precision int) {
+ w.Write([]byte(strconv.FormatFloat(val, 'g', -1, precision)))
+}
+
+// printComplex outputs a complex value using the specified float precision
+// for the real and imaginary parts to Writer w.
+func printComplex(w io.Writer, c complex128, floatPrecision int) {
+ r := real(c)
+ w.Write(openParenBytes)
+ w.Write([]byte(strconv.FormatFloat(r, 'g', -1, floatPrecision)))
+ i := imag(c)
+ if i >= 0 {
+ w.Write(plusBytes)
+ }
+ w.Write([]byte(strconv.FormatFloat(i, 'g', -1, floatPrecision)))
+ w.Write(iBytes)
+ w.Write(closeParenBytes)
+}
+
+// printHexPtr outputs a uintptr formatted as hexidecimal with a leading '0x'
+// prefix to Writer w.
+func printHexPtr(w io.Writer, p uintptr) {
+ // Null pointer.
+ num := uint64(p)
+ if num == 0 {
+ w.Write(nilAngleBytes)
+ return
+ }
+
+ // Max uint64 is 16 bytes in hex + 2 bytes for '0x' prefix
+ buf := make([]byte, 18)
+
+ // It's simpler to construct the hex string right to left.
+ base := uint64(16)
+ i := len(buf) - 1
+ for num >= base {
+ buf[i] = hexDigits[num%base]
+ num /= base
+ i--
+ }
+ buf[i] = hexDigits[num]
+
+ // Add '0x' prefix.
+ i--
+ buf[i] = 'x'
+ i--
+ buf[i] = '0'
+
+ // Strip unused leading bytes.
+ buf = buf[i:]
+ w.Write(buf)
+}
+
+// valuesSorter implements sort.Interface to allow a slice of reflect.Value
+// elements to be sorted.
+type valuesSorter struct {
+ values []reflect.Value
+ strings []string // either nil or same len and values
+ cs *ConfigState
+}
+
+// newValuesSorter initializes a valuesSorter instance, which holds a set of
+// surrogate keys on which the data should be sorted. It uses flags in
+// ConfigState to decide if and how to populate those surrogate keys.
+func newValuesSorter(values []reflect.Value, cs *ConfigState) sort.Interface {
+ vs := &valuesSorter{values: values, cs: cs}
+ if canSortSimply(vs.values[0].Kind()) {
+ return vs
+ }
+ if !cs.DisableMethods {
+ vs.strings = make([]string, len(values))
+ for i := range vs.values {
+ b := bytes.Buffer{}
+ if !handleMethods(cs, &b, vs.values[i]) {
+ vs.strings = nil
+ break
+ }
+ vs.strings[i] = b.String()
+ }
+ }
+ if vs.strings == nil && cs.SpewKeys {
+ vs.strings = make([]string, len(values))
+ for i := range vs.values {
+ vs.strings[i] = Sprintf("%#v", vs.values[i].Interface())
+ }
+ }
+ return vs
+}
+
+// canSortSimply tests whether a reflect.Kind is a primitive that can be sorted
+// directly, or whether it should be considered for sorting by surrogate keys
+// (if the ConfigState allows it).
+func canSortSimply(kind reflect.Kind) bool {
+ // This switch parallels valueSortLess, except for the default case.
+ switch kind {
+ case reflect.Bool:
+ return true
+ case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
+ return true
+ case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
+ return true
+ case reflect.Float32, reflect.Float64:
+ return true
+ case reflect.String:
+ return true
+ case reflect.Uintptr:
+ return true
+ case reflect.Array:
+ return true
+ }
+ return false
+}
+
+// Len returns the number of values in the slice. It is part of the
+// sort.Interface implementation.
+func (s *valuesSorter) Len() int {
+ return len(s.values)
+}
+
+// Swap swaps the values at the passed indices. It is part of the
+// sort.Interface implementation.
+func (s *valuesSorter) Swap(i, j int) {
+ s.values[i], s.values[j] = s.values[j], s.values[i]
+ if s.strings != nil {
+ s.strings[i], s.strings[j] = s.strings[j], s.strings[i]
+ }
+}
+
+// valueSortLess returns whether the first value should sort before the second
+// value. It is used by valueSorter.Less as part of the sort.Interface
+// implementation.
+func valueSortLess(a, b reflect.Value) bool {
+ switch a.Kind() {
+ case reflect.Bool:
+ return !a.Bool() && b.Bool()
+ case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
+ return a.Int() < b.Int()
+ case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
+ return a.Uint() < b.Uint()
+ case reflect.Float32, reflect.Float64:
+ return a.Float() < b.Float()
+ case reflect.String:
+ return a.String() < b.String()
+ case reflect.Uintptr:
+ return a.Uint() < b.Uint()
+ case reflect.Array:
+ // Compare the contents of both arrays.
+ l := a.Len()
+ for i := 0; i < l; i++ {
+ av := a.Index(i)
+ bv := b.Index(i)
+ if av.Interface() == bv.Interface() {
+ continue
+ }
+ return valueSortLess(av, bv)
+ }
+ }
+ return a.String() < b.String()
+}
+
+// Less returns whether the value at index i should sort before the
+// value at index j. It is part of the sort.Interface implementation.
+func (s *valuesSorter) Less(i, j int) bool {
+ if s.strings == nil {
+ return valueSortLess(s.values[i], s.values[j])
+ }
+ return s.strings[i] < s.strings[j]
+}
+
+// sortValues is a sort function that handles both native types and any type that
+// can be converted to error or Stringer. Other inputs are sorted according to
+// their Value.String() value to ensure display stability.
+func sortValues(values []reflect.Value, cs *ConfigState) {
+ if len(values) == 0 {
+ return
+ }
+ sort.Sort(newValuesSorter(values, cs))
+}
diff --git a/vendor/github.com/davecgh/go-spew/spew/common_test.go b/vendor/github.com/davecgh/go-spew/spew/common_test.go
new file mode 100644
index 00000000..0f5ce47d
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/spew/common_test.go
@@ -0,0 +1,298 @@
+/*
+ * Copyright (c) 2013-2016 Dave Collins <da...@davec.name>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package spew_test
+
+import (
+ "fmt"
+ "reflect"
+ "testing"
+
+ "github.com/davecgh/go-spew/spew"
+)
+
+// custom type to test Stinger interface on non-pointer receiver.
+type stringer string
+
+// String implements the Stringer interface for testing invocation of custom
+// stringers on types with non-pointer receivers.
+func (s stringer) String() string {
+ return "stringer " + string(s)
+}
+
+// custom type to test Stinger interface on pointer receiver.
+type pstringer string
+
+// String implements the Stringer interface for testing invocation of custom
+// stringers on types with only pointer receivers.
+func (s *pstringer) String() string {
+ return "stringer " + string(*s)
+}
+
+// xref1 and xref2 are cross referencing structs for testing circular reference
+// detection.
+type xref1 struct {
+ ps2 *xref2
+}
+type xref2 struct {
+ ps1 *xref1
+}
+
+// indirCir1, indirCir2, and indirCir3 are used to generate an indirect circular
+// reference for testing detection.
+type indirCir1 struct {
+ ps2 *indirCir2
+}
+type indirCir2 struct {
+ ps3 *indirCir3
+}
+type indirCir3 struct {
+ ps1 *indirCir1
+}
+
+// embed is used to test embedded structures.
+type embed struct {
+ a string
+}
+
+// embedwrap is used to test embedded structures.
+type embedwrap struct {
+ *embed
+ e *embed
+}
+
+// panicer is used to intentionally cause a panic for testing spew properly
+// handles them
+type panicer int
+
+func (p panicer) String() string {
+ panic("test panic")
+}
+
+// customError is used to test custom error interface invocation.
+type customError int
+
+func (e customError) Error() string {
+ return fmt.Sprintf("error: %d", int(e))
+}
+
+// stringizeWants converts a slice of wanted test output into a format suitable
+// for a test error message.
+func stringizeWants(wants []string) string {
+ s := ""
+ for i, want := range wants {
+ if i > 0 {
+ s += fmt.Sprintf("want%d: %s", i+1, want)
+ } else {
+ s += "want: " + want
+ }
+ }
+ return s
+}
+
+// testFailed returns whether or not a test failed by checking if the result
+// of the test is in the slice of wanted strings.
+func testFailed(result string, wants []string) bool {
+ for _, want := range wants {
+ if result == want {
+ return false
+ }
+ }
+ return true
+}
+
+type sortableStruct struct {
+ x int
+}
+
+func (ss sortableStruct) String() string {
+ return fmt.Sprintf("ss.%d", ss.x)
+}
+
+type unsortableStruct struct {
+ x int
+}
+
+type sortTestCase struct {
+ input []reflect.Value
+ expected []reflect.Value
+}
+
+func helpTestSortValues(tests []sortTestCase, cs *spew.ConfigState, t *testing.T) {
+ getInterfaces := func(values []reflect.Value) []interface{} {
+ interfaces := []interface{}{}
+ for _, v := range values {
+ interfaces = append(interfaces, v.Interface())
+ }
+ return interfaces
+ }
+
+ for _, test := range tests {
+ spew.SortValues(test.input, cs)
+ // reflect.DeepEqual cannot really make sense of reflect.Value,
+ // probably because of all the pointer tricks. For instance,
+ // v(2.0) != v(2.0) on a 32-bits system. Turn them into interface{}
+ // instead.
+ input := getInterfaces(test.input)
+ expected := getInterfaces(test.expected)
+ if !reflect.DeepEqual(input, expected) {
+ t.Errorf("Sort mismatch:\n %v != %v", input, expected)
+ }
+ }
+}
+
+// TestSortValues ensures the sort functionality for relect.Value based sorting
+// works as intended.
+func TestSortValues(t *testing.T) {
+ v := reflect.ValueOf
+
+ a := v("a")
+ b := v("b")
+ c := v("c")
+ embedA := v(embed{"a"})
+ embedB := v(embed{"b"})
+ embedC := v(embed{"c"})
+ tests := []sortTestCase{
+ // No values.
+ {
+ []reflect.Value{},
+ []reflect.Value{},
+ },
+ // Bools.
+ {
+ []reflect.Value{v(false), v(true), v(false)},
+ []reflect.Value{v(false), v(false), v(true)},
+ },
+ // Ints.
+ {
+ []reflect.Value{v(2), v(1), v(3)},
+ []reflect.Value{v(1), v(2), v(3)},
+ },
+ // Uints.
+ {
+ []reflect.Value{v(uint8(2)), v(uint8(1)), v(uint8(3))},
+ []reflect.Value{v(uint8(1)), v(uint8(2)), v(uint8(3))},
+ },
+ // Floats.
+ {
+ []reflect.Value{v(2.0), v(1.0), v(3.0)},
+ []reflect.Value{v(1.0), v(2.0), v(3.0)},
+ },
+ // Strings.
+ {
+ []reflect.Value{b, a, c},
+ []reflect.Value{a, b, c},
+ },
+ // Array
+ {
+ []reflect.Value{v([3]int{3, 2, 1}), v([3]int{1, 3, 2}), v([3]int{1, 2, 3})},
+ []reflect.Value{v([3]int{1, 2, 3}), v([3]int{1, 3, 2}), v([3]int{3, 2, 1})},
+ },
+ // Uintptrs.
+ {
+ []reflect.Value{v(uintptr(2)), v(uintptr(1)), v(uintptr(3))},
+ []reflect.Value{v(uintptr(1)), v(uintptr(2)), v(uintptr(3))},
+ },
+ // SortableStructs.
+ {
+ // Note: not sorted - DisableMethods is set.
+ []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
+ []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
+ },
+ // UnsortableStructs.
+ {
+ // Note: not sorted - SpewKeys is false.
+ []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
+ []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
+ },
+ // Invalid.
+ {
+ []reflect.Value{embedB, embedA, embedC},
+ []reflect.Value{embedB, embedA, embedC},
+ },
+ }
+ cs := spew.ConfigState{DisableMethods: true, SpewKeys: false}
+ helpTestSortValues(tests, &cs, t)
+}
+
+// TestSortValuesWithMethods ensures the sort functionality for relect.Value
+// based sorting works as intended when using string methods.
+func TestSortValuesWithMethods(t *testing.T) {
+ v := reflect.ValueOf
+
+ a := v("a")
+ b := v("b")
+ c := v("c")
+ tests := []sortTestCase{
+ // Ints.
+ {
+ []reflect.Value{v(2), v(1), v(3)},
+ []reflect.Value{v(1), v(2), v(3)},
+ },
+ // Strings.
+ {
+ []reflect.Value{b, a, c},
+ []reflect.Value{a, b, c},
+ },
+ // SortableStructs.
+ {
+ []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
+ []reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})},
+ },
+ // UnsortableStructs.
+ {
+ // Note: not sorted - SpewKeys is false.
+ []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
+ []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
+ },
+ }
+ cs := spew.ConfigState{DisableMethods: false, SpewKeys: false}
+ helpTestSortValues(tests, &cs, t)
+}
+
+// TestSortValuesWithSpew ensures the sort functionality for relect.Value
+// based sorting works as intended when using spew to stringify keys.
+func TestSortValuesWithSpew(t *testing.T) {
+ v := reflect.ValueOf
+
+ a := v("a")
+ b := v("b")
+ c := v("c")
+ tests := []sortTestCase{
+ // Ints.
+ {
+ []reflect.Value{v(2), v(1), v(3)},
+ []reflect.Value{v(1), v(2), v(3)},
+ },
+ // Strings.
+ {
+ []reflect.Value{b, a, c},
+ []reflect.Value{a, b, c},
+ },
+ // SortableStructs.
+ {
+ []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
+ []reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})},
+ },
+ // UnsortableStructs.
+ {
+ []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
+ []reflect.Value{v(unsortableStruct{1}), v(unsortableStruct{2}), v(unsortableStruct{3})},
+ },
+ }
+ cs := spew.ConfigState{DisableMethods: true, SpewKeys: true}
+ helpTestSortValues(tests, &cs, t)
+}
diff --git a/vendor/github.com/davecgh/go-spew/spew/config.go b/vendor/github.com/davecgh/go-spew/spew/config.go
new file mode 100644
index 00000000..2e3d22f3
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/spew/config.go
@@ -0,0 +1,306 @@
+/*
+ * Copyright (c) 2013-2016 Dave Collins <da...@davec.name>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package spew
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "os"
+)
+
+// ConfigState houses the configuration options used by spew to format and
+// display values. There is a global instance, Config, that is used to control
+// all top-level Formatter and Dump functionality. Each ConfigState instance
+// provides methods equivalent to the top-level functions.
+//
+// The zero value for ConfigState provides no indentation. You would typically
+// want to set it to a space or a tab.
+//
+// Alternatively, you can use NewDefaultConfig to get a ConfigState instance
+// with default settings. See the documentation of NewDefaultConfig for default
+// values.
+type ConfigState struct {
+ // Indent specifies the string to use for each indentation level. The
+ // global config instance that all top-level functions use set this to a
+ // single space by default. If you would like more indentation, you might
+ // set this to a tab with "\t" or perhaps two spaces with " ".
+ Indent string
+
+ // MaxDepth controls the maximum number of levels to descend into nested
+ // data structures. The default, 0, means there is no limit.
+ //
+ // NOTE: Circular data structures are properly detected, so it is not
+ // necessary to set this value unless you specifically want to limit deeply
+ // nested data structures.
+ MaxDepth int
+
+ // DisableMethods specifies whether or not error and Stringer interfaces are
+ // invoked for types that implement them.
+ DisableMethods bool
+
+ // DisablePointerMethods specifies whether or not to check for and invoke
+ // error and Stringer interfaces on types which only accept a pointer
+ // receiver when the current type is not a pointer.
+ //
+ // NOTE: This might be an unsafe action since calling one of these methods
+ // with a pointer receiver could technically mutate the value, however,
+ // in practice, types which choose to satisify an error or Stringer
+ // interface with a pointer receiver should not be mutating their state
+ // inside these interface methods. As a result, this option relies on
+ // access to the unsafe package, so it will not have any effect when
+ // running in environments without access to the unsafe package such as
+ // Google App Engine or with the "safe" build tag specified.
+ DisablePointerMethods bool
+
+ // DisablePointerAddresses specifies whether to disable the printing of
+ // pointer addresses. This is useful when diffing data structures in tests.
+ DisablePointerAddresses bool
+
+ // DisableCapacities specifies whether to disable the printing of capacities
+ // for arrays, slices, maps and channels. This is useful when diffing
+ // data structures in tests.
+ DisableCapacities bool
+
+ // ContinueOnMethod specifies whether or not recursion should continue once
+ // a custom error or Stringer interface is invoked. The default, false,
+ // means it will print the results of invoking the custom error or Stringer
+ // interface and return immediately instead of continuing to recurse into
+ // the internals of the data type.
+ //
+ // NOTE: This flag does not have any effect if method invocation is disabled
+ // via the DisableMethods or DisablePointerMethods options.
+ ContinueOnMethod bool
+
+ // SortKeys specifies map keys should be sorted before being printed. Use
+ // this to have a more deterministic, diffable output. Note that only
+ // native types (bool, int, uint, floats, uintptr and string) and types
+ // that support the error or Stringer interfaces (if methods are
+ // enabled) are supported, with other types sorted according to the
+ // reflect.Value.String() output which guarantees display stability.
+ SortKeys bool
+
+ // SpewKeys specifies that, as a last resort attempt, map keys should
+ // be spewed to strings and sorted by those strings. This is only
+ // considered if SortKeys is true.
+ SpewKeys bool
+}
+
+// Config is the active configuration of the top-level functions.
+// The configuration can be changed by modifying the contents of spew.Config.
+var Config = ConfigState{Indent: " "}
+
+// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the formatted string as a value that satisfies error. See NewFormatter
+// for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Errorf(format, c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Errorf(format string, a ...interface{}) (err error) {
+ return fmt.Errorf(format, c.convertArgs(a)...)
+}
+
+// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Fprint(w, c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+ return fmt.Fprint(w, c.convertArgs(a)...)
+}
+
+// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Fprintf(w, format, c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
+ return fmt.Fprintf(w, format, c.convertArgs(a)...)
+}
+
+// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it
+// passed with a Formatter interface returned by c.NewFormatter. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Fprintln(w, c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
+ return fmt.Fprintln(w, c.convertArgs(a)...)
+}
+
+// Print is a wrapper for fmt.Print that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Print(c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Print(a ...interface{}) (n int, err error) {
+ return fmt.Print(c.convertArgs(a)...)
+}
+
+// Printf is a wrapper for fmt.Printf that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Printf(format, c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Printf(format string, a ...interface{}) (n int, err error) {
+ return fmt.Printf(format, c.convertArgs(a)...)
+}
+
+// Println is a wrapper for fmt.Println that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Println(c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Println(a ...interface{}) (n int, err error) {
+ return fmt.Println(c.convertArgs(a)...)
+}
+
+// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the resulting string. See NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Sprint(c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Sprint(a ...interface{}) string {
+ return fmt.Sprint(c.convertArgs(a)...)
+}
+
+// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the resulting string. See NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Sprintf(format, c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Sprintf(format string, a ...interface{}) string {
+ return fmt.Sprintf(format, c.convertArgs(a)...)
+}
+
+// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it
+// were passed with a Formatter interface returned by c.NewFormatter. It
+// returns the resulting string. See NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Sprintln(c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Sprintln(a ...interface{}) string {
+ return fmt.Sprintln(c.convertArgs(a)...)
+}
+
+/*
+NewFormatter returns a custom formatter that satisfies the fmt.Formatter
+interface. As a result, it integrates cleanly with standard fmt package
+printing functions. The formatter is useful for inline printing of smaller data
+types similar to the standard %v format specifier.
+
+The custom formatter only responds to the %v (most compact), %+v (adds pointer
+addresses), %#v (adds types), and %#+v (adds types and pointer addresses) verb
+combinations. Any other verbs such as %x and %q will be sent to the the
+standard fmt package for formatting. In addition, the custom formatter ignores
+the width and precision arguments (however they will still work on the format
+specifiers not handled by the custom formatter).
+
+Typically this function shouldn't be called directly. It is much easier to make
+use of the custom formatter by calling one of the convenience functions such as
+c.Printf, c.Println, or c.Printf.
+*/
+func (c *ConfigState) NewFormatter(v interface{}) fmt.Formatter {
+ return newFormatter(c, v)
+}
+
+// Fdump formats and displays the passed arguments to io.Writer w. It formats
+// exactly the same as Dump.
+func (c *ConfigState) Fdump(w io.Writer, a ...interface{}) {
+ fdump(c, w, a...)
+}
+
+/*
+Dump displays the passed parameters to standard out with newlines, customizable
+indentation, and additional debug information such as complete types and all
+pointer addresses used to indirect to the final value. It provides the
+following features over the built-in printing facilities provided by the fmt
+package:
+
+ * Pointers are dereferenced and followed
+ * Circular data structures are detected and handled properly
+ * Custom Stringer/error interfaces are optionally invoked, including
+ on unexported types
+ * Custom types which only implement the Stringer/error interfaces via
+ a pointer receiver are optionally invoked when passing non-pointer
+ variables
+ * Byte arrays and slices are dumped like the hexdump -C command which
+ includes offsets, byte values in hex, and ASCII output
+
+The configuration options are controlled by modifying the public members
+of c. See ConfigState for options documentation.
+
+See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to
+get the formatted result as a string.
+*/
+func (c *ConfigState) Dump(a ...interface{}) {
+ fdump(c, os.Stdout, a...)
+}
+
+// Sdump returns a string with the passed arguments formatted exactly the same
+// as Dump.
+func (c *ConfigState) Sdump(a ...interface{}) string {
+ var buf bytes.Buffer
+ fdump(c, &buf, a...)
+ return buf.String()
+}
+
+// convertArgs accepts a slice of arguments and returns a slice of the same
+// length with each argument converted to a spew Formatter interface using
+// the ConfigState associated with s.
+func (c *ConfigState) convertArgs(args []interface{}) (formatters []interface{}) {
+ formatters = make([]interface{}, len(args))
+ for index, arg := range args {
+ formatters[index] = newFormatter(c, arg)
+ }
+ return formatters
+}
+
+// NewDefaultConfig returns a ConfigState with the following default settings.
+//
+// Indent: " "
+// MaxDepth: 0
+// DisableMethods: false
+// DisablePointerMethods: false
+// ContinueOnMethod: false
+// SortKeys: false
+func NewDefaultConfig() *ConfigState {
+ return &ConfigState{Indent: " "}
+}
diff --git a/vendor/github.com/davecgh/go-spew/spew/doc.go b/vendor/github.com/davecgh/go-spew/spew/doc.go
new file mode 100644
index 00000000..aacaac6f
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/spew/doc.go
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2013-2016 Dave Collins <da...@davec.name>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS"